Skip to content

feat: export public API via barrel file (#5)#11

Merged
beogip merged 1 commit into
feat/1-implement-code-first-agentstool-packagefrom
feat/5-export-public-api-via-barrel-file
May 23, 2026
Merged

feat: export public API via barrel file (#5)#11
beogip merged 1 commit into
feat/1-implement-code-first-agentstool-packagefrom
feat/5-export-public-api-via-barrel-file

Conversation

@beogip
Copy link
Copy Markdown
Owner

@beogip beogip commented May 23, 2026

Summary

  • Export parseArgs and validateInput from src/index.ts barrel file, completing the public API surface
  • Move zod from dependencies to peerDependencies to avoid dual-instance class identity issues for consumers
  • Update JSDoc module example to include the newly exported symbols

Closes #5

Files changed

  • src/index.ts — Added re-exports for parseArgs, validateInput from ./args.ts; updated JSDoc example
  • package.json — Moved zod to peerDependencies, added to devDependencies
  • docs/specs/issue-5-export-public-api-via-barrel-file.md — Plan artifact

Context

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 23, 2026

Greptile Summary

This PR completes the public API surface of the @code-first-agents/tool barrel file by re-exporting parseArgs and validateInput from args.ts, and moves zod from dependencies to peerDependencies (with a matching devDependencies entry) to prevent dual-instance class-identity issues for consumers.

  • src/index.ts adds two value exports (parseArgs, validateInput) and updates the JSDoc example; RESERVED_SUBCOMMANDS is correctly kept internal.
  • package.json promotes zod to a peer dependency pinned at ^4.0.0, which is the right pattern for a schema library but means any consumer still on Zod v3 will receive only a soft warning rather than a hard install failure.
  • docs/specs/issue-5-export-public-api-via-barrel-file.md is a plan artifact with no runtime impact.

Confidence Score: 4/5

Safe to merge — changes are small, correct, and well-scoped; the only concern is the Zod v4-only peer dependency range, which may surprise consumers still on v3.

The barrel additions and JSDoc update are straightforward and match the stated acceptance criteria. The peerDependencies move is the right pattern for avoiding dual-instance issues, but pinning exclusively to ^4.0.0 means a v3 consumer gets a soft warning rather than a hard failure, which could lead to confusing runtime errors. No functional bugs in the changed code itself.

package.json — the peerDependencies Zod version range deserves a second look before this package is published more broadly.

Important Files Changed

Filename Overview
src/index.ts Adds parseArgs and validateInput re-exports from ./args.ts; updates JSDoc example to reflect new exports. Change is minimal and correct — RESERVED_SUBCOMMANDS is intentionally not re-exported.
package.json Moves zod from dependencies to peerDependencies (also added to devDependencies). Correct approach to prevent dual-instance issues; consumers must now explicitly install zod ^4.0.0.
docs/specs/issue-5-export-public-api-via-barrel-file.md New plan artifact documenting design decisions, acceptance criteria, and implementation steps. Documentation-only, no functional impact.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    Consumer["Consumer\n`import { Tool, parseArgs, validateInput } from '@code-first-agents/tool'`"]

    subgraph Package ["@code-first-agents/tool"]
        Index["src/index.ts (barrel)"]
        Args["src/args.ts\nexports: parseArgs, validateInput"]
        Tool["src/tool-class.ts\nexports: Tool"]
        Envelopes["src/envelopes.ts\nexports: ToolError"]
        Types["src/types.ts\nexports: types"]
    end

    PeerZod["zod (peerDependency ^4.0.0)\nresolved from consumer's node_modules"]

    Consumer --> Index
    Index -->|"export { parseArgs, validateInput } NEW"| Args
    Index --> Tool
    Index --> Envelopes
    Index --> Types
    Args -.->|"import type { z }"| PeerZod
    Tool -.->|uses Zod schemas| PeerZod
Loading

Reviews (1): Last reviewed commit: "feat: export public API via barrel file ..." | Re-trigger Greptile

Comment thread package.json
@beogip beogip merged commit a4a5326 into feat/1-implement-code-first-agentstool-package May 23, 2026
@beogip beogip deleted the feat/5-export-public-api-via-barrel-file branch May 23, 2026 15:02
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