Skip to content

feat(mcp-supervisor): add @platformos/platformos-mcp-supervisor package (v1: validate_code)#63

Open
fklosowski wants to merge 7 commits into
masterfrom
fk-pos-supervisor-migration
Open

feat(mcp-supervisor): add @platformos/platformos-mcp-supervisor package (v1: validate_code)#63
fklosowski wants to merge 7 commits into
masterfrom
fk-pos-supervisor-migration

Conversation

@fklosowski

Copy link
Copy Markdown

Adds a new monorepo workspace package — @platformos/platformos-mcp-supervisor — that ports the validate_code surface of the external pos-supervisor project into platformos-tools as a
TypeScript-first, single-tool MCP server speaking stdio.

The supervisor wraps @platformos/platformos-language-server-node in-process (no pos-cli subprocess, no PATH dependency) and layers platformOS-specific structural checks, enrichment, fix
generation, schema/translation validators, a 15-step diagnostic pipeline, and a 32-module rule engine on top.

v1 ships exactly one MCP tool: validate_code. Eight other tools from the source repo (validate_intent, scaffold, project_map, analyze_project, lookup, domain_guide (tool), module_info,
enrich_error, server_status, load_development_guide), the analytics / CAC / case-base / promoted-rules / dashboard / HTTP transport / session-event-bus / blob-store / fs-watcher
subsystems, and pending-state suppression (pending_files/pending_pages/pending_translations) are deferred. The deferred surface is enumerated in
docs/mcp-supervisor/decisions/001-package/README.md with mitigation strategies per item.

What's in this PR

  • New package at packages/platformos-mcp-supervisor/ (~15.5k LOC of TS + ~520 KB of fixtures + 19 spec files).
  • ADR at docs/mcp-supervisor/decisions/001-package/README.md following the repo's existing per-package decision convention.
  • Engineer-facing README + ARCHITECTURE.md (this PR also adds the architecture deep-dive — see file index below).
  • Zero changes to existing platformos-tools packages. The supervisor is strictly additive.

Architecture (one-liner)

agent → stdio (JSON-RPC) → McpServer → validate_code handler

parse (liquid-html-parser) → in-process LSP (PassThrough + protocol)
→ enrich (rule engine + regex fallback)
→ 15-step diagnostic pipeline (suppress / verify / stamp)
→ schema / translation / GraphQL validators
→ structural warnings (16 detectors)
→ diff-aware (RemovedRender / AddedParam)
→ domain guide → fix generator → cluster + scorecard
→ bridge rules → stamp defaults → force-disable filter
→ ValidateCodeResult (JSON)

Full module-level breakdown in packages/platformos-mcp-supervisor/ARCHITECTURE.md.

File index

  • packages/platformos-mcp-supervisor/
    • package.json — workspace deps (@platformos/...@0.0.19, MCP SDK 1.29, Zod, vscode-languageserver-*)
    • tsconfig.json, tsconfig.build.json — rootDir: src, CJS emit, refs to in-monorepo workspace deps
    • vitest.config.mts — single-fork-isolate (matches root pattern)
    • scripts/copy-data.mjs — post-build src/data → dist/data mirror
    • scripts/smoke-stdio.mjs — real-bin verification (MCP SDK Client + StdioClientTransport)
    • scripts/record-parity.mjs + scripts/_parity-corpus.mjs — re-capture pos-supervisor baselines
    • src/bin/platformos-mcp-supervisor.ts — CLI entry (compiles to dist/bin/...; preserves shebang)
    • src/server.ts — startServer({ projectDir, log? }) orchestrator
    • src/index.ts — public re-exports (startServer, validateCodeTool, all result/context types)
    • src/core/*.ts — 25 source modules (parser, enricher, fix-generator, pipeline, structural-warnings, validators, project scanner, fact graph, LSP client, logger, utils, etc.)
    • src/core/rules/*.ts — engine + 32 per-check rule modules (92 rules total)
    • src/data/ — verbatim hints + knowledge base (the only cp-style copy from source)
    • src/test/index-stubs.ts — shared FiltersIndex / ObjectsIndex / TagsIndex stubs
    • src/tools/validate-code.ts — orchestrator (~1010 LOC)
    • test/fixtures/project/ + test/fixtures/broken-project/ — platformOS project fixtures (69 files, 524 KB; verbatim from source minus runtime artifacts — diff -r --brief
      --exclude='.pos-supervisor' --exclude='pos-supervisor.jsonl' is empty)
    • test/fixtures/parity/ — corpus (corpus.ts) + 13 captured .expected.json baselines (~1.1k LOC)
    • test/helpers/server.ts — stdio test client
    • test/integration/validate-code-features.spec.ts
    • test/parity/validate-code-parity.spec.ts
    • test/upstream/lsp-diagnostic-contract.spec.ts
    • test/POS_CLI_AUDIT.md — durable migration audit
    • README.md — engineer-facing
    • ARCHITECTURE.md — module / boot / pipeline deep-dive (added in this PR)
  • docs/mcp-supervisor/decisions/
    • README.md — directory index
    • ADR_TEMPLATE.md — copied from docs/language-server/decisions/
    • 001-package/README.md — Status / tl;dr / Context / Decision / Consequences

This commit introduces a new test suite for the _canonicalUri function, ensuring its behavior aligns with expected properties such as idempotency, proper handling of Windows drive letters, and tolerance for non-URI strings. The tests cover various scenarios, including empty input, backslash handling, and percent-decoded path segments, to maintain robustness and prevent regressions.
…SP checks and adding warm-up for LSP initialization
…ogic; add unit tests for argument parsing and directory resolution
@@ -0,0 +1,33 @@
/**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldn't be here - platformos-check already has the concept of fixers

@@ -0,0 +1,151 @@
/**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldn't be here - this belongs to platformos-check (and it is already there - we mark deprecated tags in the platformOS engine repo, based on which we generate API reference documentation, based on which platformos-check knows, which tags are deprecated)

@@ -0,0 +1,36 @@
/**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

platformos-check should already cover this)

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.

2 participants