refactor(surface,cli,serve): Zod-Core-Out vertical slice for surface (#114)#117
Merged
stackbilt-admin merged 1 commit intomainfrom Apr 18, 2026
Merged
Conversation
…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
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>
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
@stackbilt/surface:SurfaceInputSchema+SurfaceOutputSchemaare now the authoritative contract,analyze(input)composesextractSurface, andcharter_surfacejoinscharter_blastas an MCP tool incharter serve.analyze()output — without Zod-validated schemas the brief shape would reshape on every surface primitive refactor.extractSurface/extractRoutes/extractSchema/formatSurfaceMarkdownexports preserved.Route/SchemaTable/SchemaColumnbecomez.infer<>aliases of their schemas — structurally identical to the prior interfaces, no consumer breakage.Changes
@stackbilt/surface(additive)zod ^3.24.1runtime dependencyRouteSchema,SchemaTableSchema,SchemaColumnSchema,SurfaceInputSchema,SurfaceOutputSchemaDEFAULT_SURFACE_EXTENSIONSandDEFAULT_SURFACE_IGNORE_DIRS— shared between schema defaults andextractSurfacefallback, sameDEFAULT_MAX_DEPTHpattern as blastanalyze(input: SurfaceInput): SurfaceOutput— the Core-Out entry point for CLI + MCP adaptersanalyze()@stackbilt/cli(additive)commands/surface.ts— argv routed throughSurfaceInputSchema.parse, ZodError mapped toCLIError(same shape as blast's CLI adapter)commands/serve.ts—charter_surfaceMCP tool registered following thecharter_blastpattern. Supportsformat: "json" | "markdown"input so agents can ask for a pre-digested summary instead of the full structured payload.Decisions locked per #114
server.registerTool, no new library@stackbilt/surface(Zod becomes a runtime dep — programmatic consumers need the authoritative schema from the package boundary)SurfaceOutputSchema.parseon fixtures, no byte-identical snapshots.default()and primitive fallbackAcceptance criteria (#114)
@stackbilt/surfaceexportsSurfaceInputSchema,SurfaceOutputSchema,SurfaceInput,SurfaceOutput,analyzeextractSurface,extractRoutes,extractSchema,formatSurfaceMarkdownexports preservedcharter surface <root>CLI output structurally equivalent to current behaviorcharter serveregisterscharter_surface;tools/listsurfaces the JSON schema with per-field.describe()stringsSurfaceOutputSchema.parse(analyze(...))succeeds on a representative fixture with both routes and D1 tablespackages/surface/package.jsonlistszodas adependency, notdevDependencyanalyzevia synthetic fixturesTest plan
pnpm build— clean (no TS errors)pnpm test— 37 files / 431 tests passingnode packages/cli/dist/bin.js surfaceon the Charter repo itself — confirm text output unchangednode packages/cli/dist/bin.js serve+ MCPtools/list— confirmcharter_surfaceappears with schema + descriptionsRelated
🤖 Generated with Claude Code