Add MCP dashboard-schema generator (replicates mxtommy/Kip #1072) - #47
Conversation
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.
Content review: accept-with-fixes — sound tooling, confirmed inert at runtimeRead the generator (
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
Fixes pushed
Verified: build excludes the artifact from Not changed: the hardcoded |
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.