Skip to content

refactor(surface,cli,serve): Zod-Core-Out vertical slice for surface (#114)#117

Merged
stackbilt-admin merged 1 commit intomainfrom
refactor/surface-zod-core-out
Apr 18, 2026
Merged

refactor(surface,cli,serve): Zod-Core-Out vertical slice for surface (#114)#117
stackbilt-admin merged 1 commit intomainfrom
refactor/surface-zod-core-out

Conversation

@stackbilt-admin
Copy link
Copy Markdown
Member

Summary

Changes

@stackbilt/surface (additive)

  • Add zod ^3.24.1 runtime dependency
  • Export RouteSchema, SchemaTableSchema, SchemaColumnSchema, SurfaceInputSchema, SurfaceOutputSchema
  • Export DEFAULT_SURFACE_EXTENSIONS and DEFAULT_SURFACE_IGNORE_DIRS — shared between schema defaults and extractSurface fallback, same DEFAULT_MAX_DEPTH pattern as blast
  • Add analyze(input: SurfaceInput): SurfaceOutput — the Core-Out entry point for CLI + MCP adapters
  • README: "zero runtime dependencies" claim removed; programmatic example updated to lead with analyze()

@stackbilt/cli (additive)

  • commands/surface.ts — argv routed through SurfaceInputSchema.parse, ZodError mapped to CLIError (same shape as blast's CLI adapter)
  • commands/serve.tscharter_surface MCP tool registered following the charter_blast pattern. Supports format: "json" | "markdown" input so agents can ask for a pre-digested summary instead of the full structured payload.

Decisions locked per #114

  1. Zod → JSON-schema path: pass the raw shape directly to server.registerTool, no new library
  2. Schema location: @stackbilt/surface (Zod becomes a runtime dep — programmatic consumers need the authoritative schema from the package boundary)
  3. Tests: structural assertions via SurfaceOutputSchema.parse on fixtures, no byte-identical snapshots
  4. Defaults as shared constants referenced by both schema .default() and primitive fallback

Acceptance criteria (#114)

  • @stackbilt/surface exports SurfaceInputSchema, SurfaceOutputSchema, SurfaceInput, SurfaceOutput, analyze
  • Existing extractSurface, extractRoutes, extractSchema, formatSurfaceMarkdown exports preserved
  • charter surface <root> CLI output structurally equivalent to current behavior
  • charter serve registers charter_surface; tools/list surfaces the JSON schema with per-field .describe() strings
  • SurfaceOutputSchema.parse(analyze(...)) succeeds on a representative fixture with both routes and D1 tables
  • packages/surface/package.json lists zod as a dependency, not devDependency
  • Unit tests cover schema validation + analyze via synthetic fixtures
  • No removal or rename of existing public API

Test plan

  • pnpm build — clean (no TS errors)
  • pnpm test — 37 files / 431 tests passing
  • CI: typecheck + test on the PR branch
  • Manual: node packages/cli/dist/bin.js surface on the Charter repo itself — confirm text output unchanged
  • Manual: node packages/cli/dist/bin.js serve + MCP tools/list — confirm charter_surface appears with schema + descriptions

Related

🤖 Generated with Claude Code

…114)

Mirror the blast Core-Out refactor (#110) on @stackbilt/surface:
SurfaceInputSchema + SurfaceOutputSchema become the authoritative contract,
analyze(input) composes extractSurface, and `charter_surface` joins
`charter_blast` as an MCP tool in `charter serve`.

Motivation: prerequisite for the #113 repo-brief RFC. The brief's Surface
section consumes analyze() output; without Zod-validated schemas the brief
shape would reshape on every surface primitive refactor.

- @stackbilt/surface: add zod runtime dep, RouteSchema / SchemaTableSchema /
  SchemaColumnSchema / SurfaceInputSchema / SurfaceOutputSchema, analyze(),
  DEFAULT_SURFACE_EXTENSIONS / DEFAULT_SURFACE_IGNORE_DIRS exports
- @stackbilt/cli: route `charter surface` argv through SurfaceInputSchema,
  map ZodError to CLIError; register `charter_surface` MCP tool with
  format: "json" | "markdown" input
- Route/SchemaTable/SchemaColumn become z.infer<> aliases, structurally
  identical to the prior interfaces — OSS additive-only policy preserved
- Tests: schema validation + analyze structural assertions via
  SurfaceOutputSchema.parse on fixtures

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@stackbilt-admin stackbilt-admin merged commit bf0c1fc into main Apr 18, 2026
3 checks passed
@stackbilt-admin stackbilt-admin deleted the refactor/surface-zod-core-out branch April 18, 2026 10:48
stackbilt-admin pushed a commit that referenced this pull request Apr 18, 2026
Surface Zod-Core-Out vertical slice (#117):
- analyze() + Zod schemas on @stackbilt/surface
- charter_surface MCP tool in charter serve
- CLI argv routed through SurfaceInputSchema

First release cut through the automated Release workflow
(#118) with npm trusted-publisher OIDC auth across all 11
packages. Provenance attestations replace long-lived NPM_TOKEN.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
stackbilt-admin pushed a commit that referenced this pull request Apr 18, 2026
Surface Zod-Core-Out vertical slice (#117):
- analyze() + Zod schemas on @stackbilt/surface
- charter_surface MCP tool in charter serve
- CLI argv routed through SurfaceInputSchema

First release cut through the automated Release workflow
(#118) with npm trusted-publisher OIDC auth across all 11
packages. Provenance attestations replace long-lived NPM_TOKEN.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

refactor(surface,cli): Zod-Core-Out vertical slice for surface

1 participant