feat: bundle required utils (stringifyError, jsonOutput, ToolOutput)#10
Merged
beogip merged 2 commits intoMay 23, 2026
Conversation
) - Re-export jsonOutput and stringifyError from src/index.ts public API - Add dedicated unit tests for utils (stringifyError + jsonOutput) - Add plan artifact for issue #4
Greptile SummaryThis PR completes the public API surface for the package by re-exporting
Confidence Score: 5/5Safe to merge — the change is a minimal one-line barrel export plus a new test file with no modifications to existing logic. The change is narrowly scoped: one new export line in the barrel and a test file. No files require special attention.
|
| Filename | Overview |
|---|---|
| src/index.ts | Adds one line re-exporting jsonOutput and stringifyError from ./utils.ts; straightforward barrel export with no issues. |
| tests/utils.test.ts | New unit test file covering all 7 stringifyError edge cases and 2 jsonOutput scenarios; mock setup/teardown correctly placed in beforeEach/afterEach. |
| docs/specs/issue-4-bundle-required-utils.md | Plan artifact documenting the implementation approach, acceptance criteria, and edge cases; informational only. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Consumer imports from package root] --> B["import { jsonOutput, stringifyError } from '@code-first-agents/tool'"]
B --> C[src/index.ts barrel]
C --> D["export { jsonOutput, stringifyError } from './utils.ts'"]
C --> E["export type { ToolOutput } from './utils.ts'"]
D --> F[src/utils.ts]
E --> F
F --> G["jsonOutput(data: ToolOutput): never\nconsole.log(JSON.stringify(data))\nprocess.exit(0)"]
F --> H["stringifyError(err: unknown): string\nerr instanceof Error ? err.message : String(err)"]
Reviews (2): Last reviewed commit: "refactor: consolidate jsonOutput test mo..." | Re-trigger Greptile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bundles the 3 required utility exports (
stringifyError,jsonOutput,ToolOutput) into the package's public API surface.jsonOutputandstringifyErrorfromsrc/index.ts(alongside the existingToolOutputtype export)tests/utils.test.tscovering all edge cases (Error, string, null, undefined, number, plain object, custom toString, process.exit mocking)docs/specs/Note:
src/utils.tswas already created by PR #9 (issue #3) with the correct exports. This PR completes the public API surface and adds test coverage.Closes #4
Acceptance Criteria
src/utils.tsexportsstringifyError,jsonOutput, andToolOutputtype (AC-1)tool-class.tsandenvelopes.tsimport from./utils.ts— local, not kael.factory (AC-2)Files Changed
src/index.tsjsonOutput+stringifyErrortests/utils.test.tsdocs/specs/issue-4-bundle-required-utils.mdTest Plan
bun test— 24 tests pass (42 assertions)bunx tsc --noEmit— type check cleanbunx biome check .— lint cleanPlan level: lean (9/13) | Depth: medium