Skip to content

feat: bundle required utils (stringifyError, jsonOutput, ToolOutput)#10

Merged
beogip merged 2 commits into
feat/1-implement-code-first-agentstool-packagefrom
feat/4-bundle-required-utils
May 23, 2026
Merged

feat: bundle required utils (stringifyError, jsonOutput, ToolOutput)#10
beogip merged 2 commits into
feat/1-implement-code-first-agentstool-packagefrom
feat/4-bundle-required-utils

Conversation

@beogip
Copy link
Copy Markdown
Owner

@beogip beogip commented May 23, 2026

Summary

Bundles the 3 required utility exports (stringifyError, jsonOutput, ToolOutput) into the package's public API surface.

  • Re-exports jsonOutput and stringifyError from src/index.ts (alongside the existing ToolOutput type export)
  • Adds dedicated unit tests in tests/utils.test.ts covering all edge cases (Error, string, null, undefined, number, plain object, custom toString, process.exit mocking)
  • Includes plan artifact in docs/specs/

Note: src/utils.ts was 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.ts exports stringifyError, jsonOutput, and ToolOutput type (AC-1)
  • tool-class.ts and envelopes.ts import from ./utils.ts — local, not kael.factory (AC-2)
  • Zero runtime dependency on kael.factory (AC-3)

Files Changed

File Change
src/index.ts +1 line: re-export jsonOutput + stringifyError
tests/utils.test.ts New: 9 tests (7 stringifyError + 2 jsonOutput)
docs/specs/issue-4-bundle-required-utils.md Plan artifact

Test Plan

  • bun test — 24 tests pass (42 assertions)
  • bunx tsc --noEmit — type check clean
  • bunx biome check . — lint clean
  • Code review + attack pipeline passed (0 P0, 0 P1 after fixes)

Plan level: lean (9/13) | Depth: medium

)

- 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-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 23, 2026

Greptile Summary

This PR completes the public API surface for the package by re-exporting jsonOutput and stringifyError from src/index.ts, and adds dedicated unit tests in tests/utils.test.ts for all three utility exports.

  • src/index.ts: One-line addition exporting jsonOutput and stringifyError alongside the existing ToolOutput type re-export; no structural changes.
  • tests/utils.test.ts: Nine new tests covering all stringifyError input types (Error, string, null, undefined, number, plain object, custom toString) and two jsonOutput scenarios (basic envelope, extra fields), with correct beforeEach/afterEach mock lifecycle.
  • docs/specs/issue-4-bundle-required-utils.md: Plan artifact; informational only.

Confidence Score: 5/5

Safe 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. src/utils.ts is unchanged, all existing tests continue to pass, and the new tests correctly mock process.exit to avoid killing the runner. No runtime behavior of the package is altered.

No files require special attention.

Important Files Changed

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)"]
Loading

Reviews (2): Last reviewed commit: "refactor: consolidate jsonOutput test mo..." | Re-trigger Greptile

Comment thread tests/utils.test.ts
Comment thread tests/utils.test.ts
@beogip beogip merged commit c0fdc42 into feat/1-implement-code-first-agentstool-package May 23, 2026
@beogip beogip deleted the feat/4-bundle-required-utils branch May 23, 2026 13:46
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.

1 participant