Skip to content

feat(io): centralize shared IO utilities - #1832

Merged
aidandaly24 merged 1 commit into
refactorfrom
feat/shared-io
Jul 27, 2026
Merged

feat(io): centralize shared IO utilities#1832
aidandaly24 merged 1 commit into
refactorfrom
feat/shared-io

Conversation

@aidandaly24

Copy link
Copy Markdown
Contributor

Description

This PR introduces a shared src/io package for CLI input and output concerns:

  • Moves AppIO, ReadWriteJson, and FsReadWriteJson into src/io and migrates existing consumers.
  • Adds a class-based SourceResolver for inline values, file:// sources, and stdin, with byte and strict UTF-8 text resolution.
  • Enforces a single stdin consumer and provides consistent SourceResolutionError failures.
  • Supports optional AbortSignal cancellation for file and stdin reads, following the cancellation behavior introduced in feat(runtime): add Runtime invoke command #1820.

The io package has no dependency on handlers or global config. Existing exports were removed rather than temporarily re-exported so dependent PRs can rebase onto the intended package boundary.

Related Issue

N/A - this is maintainer-coordinated refactor work and does not have an associated issue.

Documentation PR

N/A

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Other (please describe): Internal package refactor

Testing

How have you tested the change?

  • I ran bun test (345 passed, 0 failed)
  • I ran bun run typecheck
  • I ran bun run lint:check
  • I ran bun run format:check
  • I ran bun run build
  • src/assets/ was not modified, so snapshots do not require updates

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published, or no published dependency is required

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.

@github-actions github-actions Bot added agentcore-harness-reviewing AgentCore Harness review in progress and removed agentcore-harness-reviewing AgentCore Harness review in progress labels Jul 27, 2026
@codecov-commenter

codecov-commenter commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.89%. Comparing base (e0de6ed) to head (255362b).

Additional details and impacted files
@@             Coverage Diff              @@
##           refactor    #1832      +/-   ##
============================================
+ Coverage     94.85%   94.89%   +0.04%     
============================================
  Files           149      151       +2     
  Lines          7360     7421      +61     
============================================
+ Hits           6981     7042      +61     
  Misses          379      379              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jariy17 jariy17 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, great CR! Left a few comments. Can we also update the README.md about this new SourceResolver so our agents try to use this?

Comment thread src/io/source.ts
signal?: AbortSignal;
};

export class SourceResolutionError extends TypeError {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we discuss about making all Errors, "AgentCoreErrors"? If so, we need to change this after @Hweinstock merges the AgentCore PR.

Comment thread src/io/source.test.ts

test("preserves AbortError from file resolution", async () => {
const path = await tempFile("payload");
const controller = new AbortController();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we update this test to abort after the file read starts? Aborting before resolveBytes() means throwIfAborted() exits early, so this never verifies that the signal reaches readFile().

@aidandaly24
aidandaly24 merged commit b57ed51 into refactor Jul 27, 2026
8 checks passed
@aidandaly24
aidandaly24 deleted the feat/shared-io branch July 27, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants