Skip to content

docs(context-refresh): phase-3 kickoff skeleton + release verification gates#178

Merged
stackbilt-admin merged 4 commits into
mainfrom
feat/context-refresh-phase3-kickoff
May 23, 2026
Merged

docs(context-refresh): phase-3 kickoff skeleton + release verification gates#178
stackbilt-admin merged 4 commits into
mainfrom
feat/context-refresh-phase3-kickoff

Conversation

@stackbilt-admin
Copy link
Copy Markdown
Member

Summary

Kickoff skeleton for #155 Phase 3 (session continuity / charter_context MCP tool) plus hard post-release verification gates.

Included

  • docs/context-refresh-resume.md
    • adds Phase 3 kickoff checklist (serve wiring, runtime behavior, tests, docs)
    • adds explicit Phase 3 definition of done
  • PUBLISHING.md
    • adds required release-completion gates (release artifact, workflow success, npm verification, tracker hygiene)
    • adds copy/paste npm verification loop for all 12 workspace packages

Why

  • reduce restart churn by giving one canonical Phase 3 execution checklist
  • codify release verification criteria that were manually enforced for v0.16.0

Refs #155

@stackbilt-admin
Copy link
Copy Markdown
Member Author

Phase 3 implementation update landed in this branch:

  • Added new MCP tool: charter_context in serve.ts
    • refresh=false (default): reads .ai/context.snapshot.json
    • refresh=true: runs context-refresh first, then returns refreshed snapshot
    • deterministic actionable error when snapshot is missing and refresh is not requested
  • Added focused tests: packages/cli/src/__tests__/serve-context.test.ts
    • existing snapshot read
    • missing snapshot error path
    • refresh path creates snapshot + context.adf
  • Updated setup/docs so Codex is first-class alongside Claude/Cursor:
    • README MCP section
    • cli reference (charter serve and tool table)
    • bootstrap next-step messaging
    • CLI usage text (charter serve description)

Validation run on branch:

  • pnpm exec vitest run packages/cli/src/__tests__/serve-context.test.ts packages/cli/src/__tests__/context-refresh.test.ts packages/cli/src/__tests__/adf-init.test.ts
  • pnpm exec tsc --noEmit -p tsconfig.json

All green locally.

@stackbilt-admin
Copy link
Copy Markdown
Member Author

Follow-up shipped for Codex MCP onboarding parity.

What changed

  • charter bootstrap now auto-creates/updates .mcp.json with a charter MCP server entry pointing to:
    • npx @stackbilt/cli serve --ai-dir <absolute .ai path>
  • Behavior is non-destructive by default:
    • If .mcp.json already has mcpServers.charter, bootstrap leaves it unchanged unless --force is passed.
    • Invalid .mcp.json structures are skipped with explicit setup warnings.

Coverage

  • Added bootstrap tests for:
    • .mcp.json creation with correct charter wiring.
    • no overwrite when mcpServers.charter already exists and --force is not used.

Docs/help alignment

  • Updated serve/bootstrap wording to explicitly include Claude Code, Codex, and Cursor.

@stackbilt-admin
Copy link
Copy Markdown
Member Author

Addressed the blocking review items and pushed 6d2cc74.

Fixed

  1. console.log global mutation race in charter_context refresh path
  • Removed console.log = () => {} override in serve.ts.
  • Added optional IO injection to contextRefreshCommand(options, args, io?) and now call with { log: () => {} } from loadCharterContextSnapshot.
  • This avoids global mutation and is concurrency-safe for parallel MCP calls.
  1. Input boundary validation for rawInput
  • Added CharterContextInputSchema in serve.ts and now parse with:
    • const input = CharterContextInputSchema.parse(rawInput ?? {})
  • inputSchema is now derived from the same schema to keep runtime validation + tool contract aligned.
  1. snapshotPathRel || '.' cleanup
  • Removed unreachable fallback in loadCharterContextSnapshot.
  1. Absolute path warning for .mcp.json bootstrap wiring
  • ensureProjectMcpConfig now returns a warning when it creates/updates .mcp.json with an absolute --ai-dir path.
  • Warning is surfaced in bootstrap setup warnings.
  1. Refresh-path test flakiness
  • Reworked serve-context.test.ts refresh test to mock contextRefreshCommand and assert deterministic local file writes.
  • No git/network/env dependency in this unit test now.
  1. Potential interactive hang in non-interactive environments
  • Hardened promptYesNo in bootstrap: if stdin is non-TTY, it now returns false immediately instead of opening readline.

Validation

  • pnpm exec vitest run packages/cli/src/__tests__/serve-context.test.ts packages/cli/src/__tests__/bootstrap.test.ts packages/cli/src/__tests__/context-refresh.test.ts --maxWorkers=1
  • pnpm exec tsc --noEmit -p tsconfig.json

Both passed locally.

@stackbilt-admin stackbilt-admin marked this pull request as ready for review May 23, 2026 10:50
@stackbilt-admin stackbilt-admin merged commit f8ae34c into main May 23, 2026
5 checks passed
@stackbilt-admin stackbilt-admin deleted the feat/context-refresh-phase3-kickoff branch May 23, 2026 10:50
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