Skip to content

Add MCP dashboard-schema generator (replicates mxtommy/Kip #1072) - #47

Merged
mairas merged 12 commits into
mainfrom
replicate/pr-1072-mcp-schema-generator
Jul 1, 2026
Merged

Add MCP dashboard-schema generator (replicates mxtommy/Kip #1072)#47
mairas merged 12 commits into
mainfrom
replicate/pr-1072-mcp-schema-generator

Conversation

@mairas

@mairas mairas commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Replicates upstream PR mxtommy/Kip#1072 ("Add MCP dashboard-schema generator") by dillan.

Method: commit-by-commit cherry-pick (10 commits, linear history) preserving original authorship.

This is an experimental replica carried in the fork for evaluation only. It has not been built or test-run as part of replication.

dillan added 10 commits July 1, 2026 00:07
Begin the KIP dashboard-schema generator test-first. The new vitest suite (run via test:mcp-schema, in an isolated node environment) describes the widget catalog the generator must extract from widget.service.ts.

These tests fail on purpose: the generator is still a stub. The ts-morph implementation lands in the next commit.
Extract KIP's widget catalog from widget.service.ts using the TypeScript Compiler API (already a KIP dependency, so no new packages). The _widgetDefinition literal is read statically and each entry validated; the generator fails loudly if the shape changes, and commented-out widgets are naturally excluded.

For stable, consistent diffs of the generated artifact, output is canonical: object keys sorted recursively (serialize.ts), widgets sorted by selector, and plugin lists sorted.
Extend the generator test-first to cover per-widget DEFAULT_CONFIG, the structural binding kind (paths-record / paths-array / datachart / none), and path-slot extraction.

These tests fail on purpose against a stub; the implementation lands in the next commit.
Read each widget component's static DEFAULT_CONFIG via the TypeScript Compiler API, resolving the component file from its import in widget.service.ts. Derive bindingKind structurally and extract path slots for record-bound widgets.

The 'every widget' test confirms all active widget DEFAULT_CONFIGs are pure static literals, so static extraction is sound.
Cover the 24-column grid geometry, colour tokens, theme names, dashboard icons, and unit groups the generator must read from KIP source. These fail on purpose against a stub.
Read the 24-column grid geometry from dashboard.component.ts, colour tokens from app-service.ts, unit groups from units.service.ts, and dashboard icons from the SVG sprite. Colours and unit groups keep their authored order; icons are sorted and de-duplicated.
Cover buildSchema: version-stamped meta plus the assembled widgets and design system. Fails on purpose against a stub.
Add buildSchema (version-stamped meta + widgets + design system) and generate src/assets/kip-dashboard-schema.json, which KIP's static host serves at /@mxtommy/kip/assets/kip-dashboard-schema.json for the kip-mcp-server to fetch.

The artifact is deterministic (no timestamps) and canonical. The new gen:mcp-schema script regenerates it; a drift-gate test fails if a widget or the design system changes without regenerating.
Read each token's base hex from the $kip-dark-color SCSS map and add it
to the generated schema's colour list, so previews can render the real
KIP palette instead of guessing.
@mairas mairas added the upstream-replica Replica of an upstream mxtommy/Kip PR label Jun 30, 2026
@mairas

mairas commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Content review: accept-with-fixes — sound tooling, confirmed inert at runtime

Read the generator (generate.ts, ast.ts, serialize.ts) in full. Confirmed runtime-inertness: nothing under src/ imports the tool or the artifact, and package.json adds only two npm scripts (no bin/postinstall/prepare). The generator is genuinely careful — no child_process/exec/eval/dynamic require; all fs reads are hardcoded paths; parsing is pure syntactic ts.createSourceFile (Kip source is never executed); literalToValue fails loud on anything it can't statically resolve rather than guessing; output is deterministic with a CI drift gate.

  • [low · design] the ~92 KB src/assets/kip-dashboard-schema.json is swept into the Angular assets glob → shipped to every device and served at /assets/..., though only the external MCP server consumes it. Move it out of src/assets or exclude it from the glob.
  • [low · correctness] SCHEMA_VERSION/CONFIG_FILE_VERSION/theme constants are hardcoded with no test binding them to their source of truth → silent drift if Kip bumps them (the rest of the generator reads from source and fails on drift; these don't).
  • [info] stale doc comment (references ts-morph; the tool uses the TS compiler API), and unrelated d3/branding changes ride along (the d3-selection/d3-shape dep removals are verified safe — src/ imports only the umbrella d3).

Sound dev-only tooling; the fixes are hygiene, none touch on-device data paths.

… (content review)

The ~91 KB kip-dashboard-schema.json is consumed by the external MCP server,
not the app runtime, but sat under src/assets and shipped to every device
(served at /assets/kip-dashboard-schema.json). Exclude it from the Angular
assets glob; it stays in the repo for the generator + external consumer.
Also correct a stale doc comment (the tool uses the TS compiler API, not
ts-morph).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ETfeXXs8R5ciw6nGxGYj2C
@mairas

mairas commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Fixes pushed

  • Bundle bloat / served artifact: the ~91 KB kip-dashboard-schema.json is now excluded from the Angular assets glob, so it no longer ships to every device or gets served at /assets/.... It stays in the repo for the generator and the external MCP-server consumer.
  • Doc comment: corrected the stale "ts-morph" reference (the tool uses the TypeScript compiler API).

Verified: build excludes the artifact from public/, generator test suite 24/24 still green, app builds.

Not changed: the hardcoded SCHEMA_VERSION / CONFIG_FILE_VERSION / theme constants (low, drift risk). Binding them to their source of truth would need a source-reading assertion in the drift-guard spec; deferred as this is external-only dev tooling with no on-device runtime footprint.

@mairas
mairas merged commit 50415c2 into main Jul 1, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

upstream-replica Replica of an upstream mxtommy/Kip PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants