@getchomp/mcp 0.0.0-stage → 0.2.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -2
- package/dist/conventionsReference.d.ts +84 -0
- package/dist/conventionsReference.js +313 -0
- package/dist/designSystem/astScanner.d.ts +153 -0
- package/dist/designSystem/astScanner.js +2014 -0
- package/dist/designSystem/baseline.d.ts +65 -0
- package/dist/designSystem/baseline.js +136 -0
- package/dist/designSystem/color.d.ts +35 -0
- package/dist/designSystem/color.js +265 -0
- package/dist/designSystem/config.d.ts +183 -0
- package/dist/designSystem/config.js +469 -0
- package/dist/designSystem/contrast.d.ts +55 -0
- package/dist/designSystem/contrast.js +377 -0
- package/dist/designSystem/cssParser.d.ts +63 -0
- package/dist/designSystem/cssParser.js +469 -0
- package/dist/designSystem/merges.d.ts +57 -0
- package/dist/designSystem/merges.js +94 -0
- package/dist/designSystem/preprocessors.d.ts +46 -0
- package/dist/designSystem/preprocessors.js +1108 -0
- package/dist/designSystem/presentation.d.ts +45 -0
- package/dist/designSystem/presentation.js +796 -0
- package/dist/designSystem/styleVectors.d.ts +27 -0
- package/dist/designSystem/styleVectors.js +484 -0
- package/dist/designSystem/tokens.d.ts +39 -0
- package/dist/designSystem/tokens.js +409 -0
- package/dist/designSystem/topology.d.ts +64 -0
- package/dist/designSystem/topology.js +254 -0
- package/dist/designSystem/types.d.ts +857 -0
- package/dist/designSystem/types.js +113 -0
- package/dist/designSystem/typography.d.ts +25 -0
- package/dist/designSystem/typography.js +244 -0
- package/dist/designSystem/uiShapes.d.ts +74 -0
- package/dist/designSystem/uiShapes.js +285 -0
- package/dist/designSystem/valueClusters.d.ts +76 -0
- package/dist/designSystem/valueClusters.js +281 -0
- package/dist/designSystemPlugin.d.ts +321 -0
- package/dist/designSystemPlugin.js +4730 -0
- package/dist/enrichNodesPlugin.d.ts +160 -0
- package/dist/enrichNodesPlugin.js +957 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.js +1298 -0
- package/dist/intelligence.d.ts +502 -0
- package/dist/intelligence.js +3058 -0
- package/dist/pluginRunner.d.ts +364 -0
- package/dist/pluginRunner.js +1096 -0
- package/dist/plugins/design-system/index.d.ts +14 -0
- package/dist/plugins/design-system/index.js +241 -0
- package/dist/plugins/enrich-nodes/index.d.ts +388 -0
- package/dist/plugins/enrich-nodes/index.js +697 -0
- package/dist/plugins/index.d.ts +15 -0
- package/dist/plugins/index.js +20 -0
- package/dist/plugins/local-shims/index.d.ts +121 -0
- package/dist/plugins/local-shims/index.js +237 -0
- package/dist/shimsPlugin.d.ts +134 -0
- package/dist/shimsPlugin.js +1392 -0
- package/package.json +38 -3
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* packages/mcp/src/plugins/design-system/index.ts
|
|
3
|
+
*
|
|
4
|
+
* Self-contained `design-system` plugin module (`L1_DESIGN_SYSTEM`).
|
|
5
|
+
* Auto-discovered from `packages/mcp/src/plugins/` with zero external plumbing:
|
|
6
|
+
* - State & settings folder: `.chomp/plugins/design-system/` (`baseline.json`, `settings.json`)
|
|
7
|
+
* - Declarative Settings UI (`settingsSchema`)
|
|
8
|
+
* - Inspector & HUD Presentation (`PluginPresentation` v1)
|
|
9
|
+
* - Active View Spotlight (`ctx.setActiveView` + `summary.views`)
|
|
10
|
+
* - Owned MCP tools (`chomp_audit_design_system`, `chomp_diff_design_system`)
|
|
11
|
+
* - Owned CLI summary formatter (`formatCliSummary`)
|
|
12
|
+
*/
|
|
13
|
+
export declare const designSystemPluginModule: import("../../pluginRunner.js").ChompPlugin;
|
|
14
|
+
export default designSystemPluginModule;
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* packages/mcp/src/plugins/design-system/index.ts
|
|
3
|
+
*
|
|
4
|
+
* Self-contained `design-system` plugin module (`L1_DESIGN_SYSTEM`).
|
|
5
|
+
* Auto-discovered from `packages/mcp/src/plugins/` with zero external plumbing:
|
|
6
|
+
* - State & settings folder: `.chomp/plugins/design-system/` (`baseline.json`, `settings.json`)
|
|
7
|
+
* - Declarative Settings UI (`settingsSchema`)
|
|
8
|
+
* - Inspector & HUD Presentation (`PluginPresentation` v1)
|
|
9
|
+
* - Active View Spotlight (`ctx.setActiveView` + `summary.views`)
|
|
10
|
+
* - Owned MCP tools (`chomp_audit_design_system`, `chomp_diff_design_system`)
|
|
11
|
+
* - Owned CLI summary formatter (`formatCliSummary`)
|
|
12
|
+
*/
|
|
13
|
+
import { execSync } from "node:child_process";
|
|
14
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
15
|
+
import { basename, resolve } from "node:path";
|
|
16
|
+
import { CORE_EXTRACTOR_VERSION, analyzeTarget } from "@getchomp/core";
|
|
17
|
+
import { z } from "zod";
|
|
18
|
+
import { auditDesignSystem, createDesignSystemPlugin, diffDesignSystem, } from "../../designSystemPlugin.js";
|
|
19
|
+
import { defineChompPlugin } from "../../pluginRunner.js";
|
|
20
|
+
function resolveLiveGraphIfDirty(repoPath, dbPath) {
|
|
21
|
+
let needsLive = !existsSync(dbPath);
|
|
22
|
+
if (!needsLive) {
|
|
23
|
+
try {
|
|
24
|
+
const status = execSync("git status --porcelain", {
|
|
25
|
+
cwd: repoPath,
|
|
26
|
+
encoding: "utf8",
|
|
27
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
28
|
+
});
|
|
29
|
+
needsLive = status.trim().length > 0;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
needsLive = false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (!needsLive)
|
|
36
|
+
return undefined;
|
|
37
|
+
let excludeWorkspaces = ["fixtures/cloned-repos", "fixtures/test-repos", "fixtures/research"];
|
|
38
|
+
const cfgPath = resolve(repoPath, "chomp.config.json");
|
|
39
|
+
if (existsSync(cfgPath)) {
|
|
40
|
+
try {
|
|
41
|
+
const parsed = JSON.parse(readFileSync(cfgPath, "utf8"));
|
|
42
|
+
const ex = parsed.excludeWorkspaces ?? parsed.exclude_workspaces;
|
|
43
|
+
if (Array.isArray(ex)) {
|
|
44
|
+
excludeWorkspaces = ex.map(String);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
// keep default exclusions on malformed config
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return analyzeTarget(repoPath, CORE_EXTRACTOR_VERSION, undefined, excludeWorkspaces);
|
|
52
|
+
}
|
|
53
|
+
const baseDesignSystemPlugin = createDesignSystemPlugin();
|
|
54
|
+
export const designSystemPluginModule = defineChompPlugin({
|
|
55
|
+
...baseDesignSystemPlugin,
|
|
56
|
+
defaultEnabled: true,
|
|
57
|
+
settingsSchema: [
|
|
58
|
+
{
|
|
59
|
+
key: "autoPinCleanBaseline",
|
|
60
|
+
label: "Auto-pin clean baseline",
|
|
61
|
+
description: "Save a baseline on first audit when the working tree is clean.",
|
|
62
|
+
kind: "boolean",
|
|
63
|
+
defaultValue: true,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
key: "maxDiagnosticsPerList",
|
|
67
|
+
label: "Diagnostic limit",
|
|
68
|
+
description: "Max items returned per list in chomp_audit_design_system.",
|
|
69
|
+
kind: "number",
|
|
70
|
+
defaultValue: 25,
|
|
71
|
+
min: 5,
|
|
72
|
+
max: 100,
|
|
73
|
+
step: 5,
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
formatCliSummary: (res, ansi) => {
|
|
77
|
+
const dsReport = res.summary?.report;
|
|
78
|
+
if (!dsReport)
|
|
79
|
+
return [];
|
|
80
|
+
const lines = [];
|
|
81
|
+
const s = dsReport.summary;
|
|
82
|
+
const score = s.agentExtendabilityScore;
|
|
83
|
+
const extColor = score === null ? ansi.dim : score >= 80 ? ansi.green : score >= 65 ? ansi.cyan : ansi.yellow;
|
|
84
|
+
const m = dsReport.agentExtendability.measures;
|
|
85
|
+
const pct = (v) => (v === null ? "n/a" : `${v}%`);
|
|
86
|
+
lines.push(`${ansi.dim("System:")} ${ansi.bold(dsReport.system.mode)} mode · ${dsReport.system.packages.filter((p) => p.frontend).length} frontend package(s) in scope · ${ansi.dim(dsReport.system.modeReason)}`);
|
|
87
|
+
lines.push(`${ansi.dim("Extendability:")} ${extColor(score === null ? "N/A (insufficient evidence)" : `${score}/100 (${s.agentExtendabilityGrade})`)} · ${ansi.dim("token adherence")} ${pct(m.tokenAdherence)} · ${ansi.dim("atom adoption")} ${pct(m.atomAdoption)} · ${ansi.dim("dryness")} ${pct(m.dryness)} · ${ansi.dim("encapsulation")} ${pct(m.encapsulation)}`);
|
|
88
|
+
lines.push(`${ansi.dim("Hierarchy:")} ${s.routeCount} Route, ${s.templateCount} Template, ${s.organismCount} Organism, ${s.moleculeCount} Molecule, ${s.atomCount} Atom, ${s.utilityCount} Utility`);
|
|
89
|
+
lines.push(`${ansi.dim("CSS Tokens:")} ${ansi.bold(String(s.totalDefinedTokens))} (${s.primitiveTokenCount} primitive, ${s.semanticTokenCount} semantic, ${s.componentTokenCount} component, ${s.themeBridgeTokenCount} @theme)`);
|
|
90
|
+
const candidateTotal = s.contrastCandidateCount ?? s.contrastPairsAudited;
|
|
91
|
+
const passingContrast = s.contrastPairsAudited - s.contrastFailureCount;
|
|
92
|
+
const contrastStatus = candidateTotal === 0
|
|
93
|
+
? ansi.yellow("0 of 0 candidate pairs audited (none discovered)")
|
|
94
|
+
: s.contrastFailureCount === 0 && s.contrastPairsUnresolved === 0
|
|
95
|
+
? ansi.green(`${s.contrastPairsAudited} of ${candidateTotal} candidate pairs audited (${passingContrast}/${s.contrastPairsAudited} PASS)`)
|
|
96
|
+
: ansi.yellow(`${s.contrastPairsAudited} of ${candidateTotal} candidate pairs audited (${passingContrast}/${s.contrastPairsAudited} PASS${s.contrastFailureCount > 0 ? `, ${s.contrastFailureCount} fail` : ""}${s.contrastPairsUnresolved > 0 ? `, ${s.contrastPairsUnresolved} unresolved` : ""})`);
|
|
97
|
+
lines.push(`${ansi.dim("WCAG Contrast:")} ${contrastStatus} · ${ansi.dim("Undefined var():")} ${s.undefinedTokenCount === 0 ? ansi.green("0") : ansi.yellow(String(s.undefinedTokenCount))} · ${ansi.dim("Duplicate tokens:")} ${s.duplicateTokenCount}`);
|
|
98
|
+
if (s.contrastPairsUnresolved > 0 || s.unsupportedFileCount > 0) {
|
|
99
|
+
lines.push(`${ansi.yellow("Not evaluated:")} ${s.contrastPairsUnresolved} contrast pair/theme(s) · ${s.unsupportedFileCount} unsupported file(s) (${dsReport.coverage.unsupportedFiles.map((u) => u.extension).join(", ") || "none"})`);
|
|
100
|
+
}
|
|
101
|
+
lines.push(`${ansi.dim("Hardcoded:")} ${s.hardcodedLiteralCount} literal(s) → ${s.derivedTokenProposalCount} derived token proposal(s) · ${s.invariantViolationCount} prop-literal violation(s) · ${s.composabilityIssueCount} composability issue(s)`);
|
|
102
|
+
lines.push(`${ansi.dim("Alignment/DRY:")} ${s.structuralJsxCloneCount} JSX clone pattern(s) · ${s.bypassedAtomCount} bypassed atom(s) · ${s.parallelTwinGroupCount} parallel twin group(s) · ${s.callSiteOverrideCount} call-site override(s)`);
|
|
103
|
+
lines.push(`${ansi.dim("UI Contracts:")} ${s.componentsProfiled} profiled · ${ansi.dim("Arbitrary Tailwind:")} ${s.arbitraryTailwindCount} · ${ansi.dim("Canvas slots:")} ${s.canvasCssSlotCount} css / ${s.canvasTsConstSlotCount} tsConst / ${s.canvasLiteralSlotCount} lit`);
|
|
104
|
+
if (dsReport.atomicConsolidation.length > 0) {
|
|
105
|
+
const atoms = dsReport.atomicConsolidation
|
|
106
|
+
.map((a) => `<${a.atomName}> (${a.instanceCount} raw${a.adoptionRate !== null ? `, ${a.adoptionRate}% adopted` : ""})`)
|
|
107
|
+
.join(", ");
|
|
108
|
+
lines.push(`${ansi.dim("Atomic Targets:")} ${atoms}`);
|
|
109
|
+
}
|
|
110
|
+
return lines;
|
|
111
|
+
},
|
|
112
|
+
mcpTools: [
|
|
113
|
+
{
|
|
114
|
+
name: "chomp_audit_design_system",
|
|
115
|
+
description: "QUERY BEFORE WRITE — DESIGN SYSTEM & FRONTEND AGENT HARNESS: Call this tool BEFORE authoring or refactoring frontend CSS, Tailwind, or React/TSX components. Deterministically extracts and returns: (1) the repository's CSS custom property token catalog across primitive, semantic, and component tiers (:root, [data-theme], @theme), (2) atomic component consolidation targets (<Switch>, <Drawer>, <Badge>, <Banner>, <Button>, <KeyValueList>, <Tooltip>), (3) undefined var(--*) leaks, duplicate/forked token declarations, unused tokens, and computed WCAG 2.1 contrast ratios across Dark and Light themes, and (4) per-component styling convention mix, arbitrary Tailwind bracket values, primitive scale skips, and canvas styling slot provenance. Refreshes EXTRACTED L1_DESIGN_SYSTEM display overlays in .chomp/graph.db; the diff baseline (.chomp/plugins/design-system/baseline.json) is created if absent and clean, and replaced only with set_baseline.",
|
|
116
|
+
inputSchema: {
|
|
117
|
+
packageName: z
|
|
118
|
+
.string()
|
|
119
|
+
.optional()
|
|
120
|
+
.describe("Optional filter by frontend package name (e.g., 'web', '@acme/web')"),
|
|
121
|
+
package_name: z.string().optional().describe("Alias for packageName (snake_case)"),
|
|
122
|
+
search_term: z
|
|
123
|
+
.string()
|
|
124
|
+
.optional()
|
|
125
|
+
.describe("Optional case-insensitive filter on component name, file path, or atomic primitive candidate (e.g., 'Button', 'Dialog', 'Badge')"),
|
|
126
|
+
searchTerm: z.string().optional().describe("Alias for search_term (camelCase)"),
|
|
127
|
+
limit: z
|
|
128
|
+
.number()
|
|
129
|
+
.optional()
|
|
130
|
+
.describe("Maximum entries per diagnostic/component list (default: 25)"),
|
|
131
|
+
persist_overlays: z
|
|
132
|
+
.boolean()
|
|
133
|
+
.optional()
|
|
134
|
+
.describe("When true (default), persists EXTRACTED L1_DESIGN_SYSTEM overlays into .chomp/graph.db with runId prune-on-recommit"),
|
|
135
|
+
persistOverlays: z.boolean().optional().describe("Alias for persist_overlays (camelCase)"),
|
|
136
|
+
set_baseline: z
|
|
137
|
+
.boolean()
|
|
138
|
+
.optional()
|
|
139
|
+
.describe("When true, (re)pins the current working tree as the diff baseline snapshot (.chomp/plugins/design-system/baseline.json)."),
|
|
140
|
+
setBaseline: z.boolean().optional().describe("Alias for set_baseline (camelCase)"),
|
|
141
|
+
create_view: z
|
|
142
|
+
.boolean()
|
|
143
|
+
.optional()
|
|
144
|
+
.describe("When true, updates .chomp/current_view.json with L1_DESIGN_SYSTEM Spotlight highlights. Leave false (default) during coding tasks; pass true only when answering user questions or visual walkthrough requests."),
|
|
145
|
+
createView: z.boolean().optional().describe("Alias for create_view (camelCase)"),
|
|
146
|
+
},
|
|
147
|
+
handler: async (args, ctx) => {
|
|
148
|
+
const persistOverlays = args.persist_overlays ?? args.persistOverlays ?? existsSync(ctx.dbPath);
|
|
149
|
+
const defaultLimit = typeof ctx.settings.maxDiagnosticsPerList === "number"
|
|
150
|
+
? ctx.settings.maxDiagnosticsPerList
|
|
151
|
+
: 25;
|
|
152
|
+
const liveGraph = resolveLiveGraphIfDirty(ctx.repoPath, ctx.dbPath);
|
|
153
|
+
const report = await auditDesignSystem({
|
|
154
|
+
repoPath: ctx.repoPath,
|
|
155
|
+
repoId: ctx.repoId,
|
|
156
|
+
repoName: ctx.repoName,
|
|
157
|
+
dbPath: ctx.dbPath,
|
|
158
|
+
...(liveGraph ? { graph: liveGraph } : {}),
|
|
159
|
+
packageName: args.packageName ?? args.package_name,
|
|
160
|
+
searchTerm: args.search_term ?? args.searchTerm,
|
|
161
|
+
limit: args.limit ?? defaultLimit,
|
|
162
|
+
persistOverlays,
|
|
163
|
+
setBaseline: args.set_baseline ?? args.setBaseline,
|
|
164
|
+
autoPinCleanBaseline: ctx.settings.autoPinCleanBaseline !== false,
|
|
165
|
+
});
|
|
166
|
+
if (persistOverlays) {
|
|
167
|
+
ctx.invalidateCache();
|
|
168
|
+
}
|
|
169
|
+
if ((args.create_view ?? args.createView) && report.recommendedHighlightNodeIds.length > 0) {
|
|
170
|
+
const pkgFilter = args.packageName ??
|
|
171
|
+
args.package_name ??
|
|
172
|
+
report.system.packages
|
|
173
|
+
.filter((p) => p.frontend)
|
|
174
|
+
.map((p) => p.name?.replace(/^@[^/]+\//, "") ??
|
|
175
|
+
(p.dir === "." ? ctx.repoName : basename(p.dir)))[0] ??
|
|
176
|
+
ctx.repoName;
|
|
177
|
+
ctx.setActiveView({
|
|
178
|
+
title: "Frontend token & contrast audit",
|
|
179
|
+
description: `${report.summary.totalDefinedTokens} tokens | ${report.summary.componentsProfiled} components | ${report.summary.undefinedTokenCount} undefined var() | ${report.summary.contrastFailureCount} contrast failures`,
|
|
180
|
+
highlightNodeIds: report.recommendedHighlightNodeIds,
|
|
181
|
+
viewLevel: "package",
|
|
182
|
+
packageName: pkgFilter,
|
|
183
|
+
pills: [
|
|
184
|
+
`${report.summary.totalDefinedTokens} tokens`,
|
|
185
|
+
`${report.summary.contrastPairsAudited - report.summary.contrastFailureCount}/${report.summary.contrastCandidateCount ?? report.summary.contrastPairsAudited} contrast pass (${report.summary.contrastPairsAudited}/${report.summary.contrastCandidateCount ?? report.summary.contrastPairsAudited} audited)`,
|
|
186
|
+
`${report.summary.arbitraryTailwindCount} arbitrary Tw`,
|
|
187
|
+
],
|
|
188
|
+
metrics: {
|
|
189
|
+
tokens: report.summary.totalDefinedTokens,
|
|
190
|
+
undefinedVars: report.summary.undefinedTokenCount,
|
|
191
|
+
arbitraryTw: report.summary.arbitraryTailwindCount,
|
|
192
|
+
contrastFails: report.summary.contrastFailureCount,
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
return report;
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
name: "chomp_diff_design_system",
|
|
201
|
+
description: "VERIFY AFTER WRITE — CLOSED-LOOP FRONTEND DESIGN DIFF GATE: Call this tool AFTER modifying CSS or React/TSX components to compare your dirty working tree against the pinned baseline snapshot (default .chomp/plugins/design-system/baseline.json; created by chomp_audit_design_system, never moved by a re-audit). Flags newly introduced undefined var(--*) tokens, arbitrary Tailwind values, primitive skips, hardcoded color/length literals, prop-literal violations, raw elements bypassing shared atoms, composability issues, and WCAG 2.1 contrast regressions.",
|
|
202
|
+
inputSchema: {
|
|
203
|
+
package_name: z
|
|
204
|
+
.string()
|
|
205
|
+
.optional()
|
|
206
|
+
.describe("Optional frontend package to focus the Spotlight view on."),
|
|
207
|
+
packageName: z.string().optional().describe("Alias for package_name (camelCase)"),
|
|
208
|
+
create_view: z
|
|
209
|
+
.boolean()
|
|
210
|
+
.optional()
|
|
211
|
+
.describe("When true, updates .chomp/current_view.json to highlight components with design system changes. Leave false (default) during coding tasks."),
|
|
212
|
+
createView: z.boolean().optional().describe("Alias for create_view (camelCase)"),
|
|
213
|
+
},
|
|
214
|
+
handler: async (args, ctx) => {
|
|
215
|
+
const liveGraph = resolveLiveGraphIfDirty(ctx.repoPath, ctx.dbPath);
|
|
216
|
+
const diffResult = await diffDesignSystem({
|
|
217
|
+
repoPath: ctx.repoPath,
|
|
218
|
+
repoId: ctx.repoId,
|
|
219
|
+
repoName: ctx.repoName,
|
|
220
|
+
dbPath: ctx.dbPath,
|
|
221
|
+
...(liveGraph ? { graph: liveGraph } : {}),
|
|
222
|
+
});
|
|
223
|
+
if ((args.create_view ?? args.createView) && diffResult.componentDeltas.length > 0) {
|
|
224
|
+
const diffPkg = args.packageName ??
|
|
225
|
+
args.package_name ??
|
|
226
|
+
diffResult.frontendPackages[0] ??
|
|
227
|
+
ctx.repoName;
|
|
228
|
+
ctx.setActiveView({
|
|
229
|
+
title: `Working tree diff (${diffResult.gateStatus})`,
|
|
230
|
+
description: `New undefined vars: ${diffResult.summary.newUndefinedTokenCount} | New arbitrary Tw: ${diffResult.summary.newArbitraryTailwindCount} | Contrast fails: ${diffResult.summary.newContrastFailureCount}`,
|
|
231
|
+
highlightNodeIds: diffResult.componentDeltas.flatMap((d) => d.entityId ? [d.entityId] : []),
|
|
232
|
+
viewLevel: "package",
|
|
233
|
+
packageName: diffPkg,
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
return diffResult;
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
],
|
|
240
|
+
});
|
|
241
|
+
export default designSystemPluginModule;
|
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* packages/mcp/src/plugins/enrich-nodes/index.ts
|
|
3
|
+
*
|
|
4
|
+
* Self-contained `enrich-nodes` plugin module (`L1_SEMANTIC`).
|
|
5
|
+
* Auto-discovered from `packages/mcp/src/plugins/` with zero external plumbing:
|
|
6
|
+
* - State & settings folder: `.chomp/plugins/enrich-nodes/` (`settings.json`)
|
|
7
|
+
* - Declarative Settings UI (`settingsSchema`)
|
|
8
|
+
* - Inspector & HUD Presentation (`PluginPresentation` v1, including honest `Un-enriched` state)
|
|
9
|
+
* - Active View Spotlight (`ctx.setActiveView` + per-domain `summary.views`)
|
|
10
|
+
* - Owned MCP tool (`chomp_enrich_nodes`)
|
|
11
|
+
* - Owned CLI summary formatter (`formatCliSummary`)
|
|
12
|
+
*/
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
import { ENRICH_NODES_PLUGIN_NAME } from "../../enrichNodesPlugin.js";
|
|
15
|
+
export declare const enrichNodesPluginModule: {
|
|
16
|
+
defaultEnabled: true;
|
|
17
|
+
scanRepoFiles: false;
|
|
18
|
+
settingsSchema: ({
|
|
19
|
+
key: string;
|
|
20
|
+
label: string;
|
|
21
|
+
description: string;
|
|
22
|
+
kind: "boolean";
|
|
23
|
+
defaultValue: true;
|
|
24
|
+
} | {
|
|
25
|
+
key: string;
|
|
26
|
+
label: string;
|
|
27
|
+
description: string;
|
|
28
|
+
kind: "boolean";
|
|
29
|
+
defaultValue: false;
|
|
30
|
+
})[];
|
|
31
|
+
formatCliSummary: (res: import("../../pluginRunner.js").RunChompPluginResult, ansi: import("../../pluginRunner.js").ChompCliAnsiHelpers) => string[];
|
|
32
|
+
mcpTools: {
|
|
33
|
+
name: string;
|
|
34
|
+
description: string;
|
|
35
|
+
inputSchema: {
|
|
36
|
+
action: z.ZodOptional<z.ZodEnum<["upsert", "queue", "status", "refresh", "export", "import"]>>;
|
|
37
|
+
packageName: z.ZodOptional<z.ZodString>;
|
|
38
|
+
package_name: z.ZodOptional<z.ZodString>;
|
|
39
|
+
status: z.ZodOptional<z.ZodEnum<["needs_enrichment", "unenriched", "stale", "all"]>>;
|
|
40
|
+
includeTypes: z.ZodOptional<z.ZodBoolean>;
|
|
41
|
+
include_types: z.ZodOptional<z.ZodBoolean>;
|
|
42
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
cursor: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
includeContext: z.ZodOptional<z.ZodBoolean>;
|
|
45
|
+
include_context: z.ZodOptional<z.ZodBoolean>;
|
|
46
|
+
contextLines: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
context_lines: z.ZodOptional<z.ZodNumber>;
|
|
48
|
+
deferRefresh: z.ZodOptional<z.ZodBoolean>;
|
|
49
|
+
defer_refresh: z.ZodOptional<z.ZodBoolean>;
|
|
50
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
51
|
+
nodes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
52
|
+
nodeId: z.ZodString;
|
|
53
|
+
domain: z.ZodOptional<z.ZodString>;
|
|
54
|
+
humanLabel: z.ZodOptional<z.ZodString>;
|
|
55
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
56
|
+
rationale: z.ZodOptional<z.ZodString>;
|
|
57
|
+
action: z.ZodOptional<z.ZodEnum<["middleware_badge", "component_badge", "micro_node", "station_node"]>>;
|
|
58
|
+
badgeLabel: z.ZodOptional<z.ZodString>;
|
|
59
|
+
badgeMode: z.ZodOptional<z.ZodEnum<["fold_into_callers", "badge_on_node"]>>;
|
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
|
61
|
+
nodeId: string;
|
|
62
|
+
humanLabel?: string | undefined;
|
|
63
|
+
domain?: string | undefined;
|
|
64
|
+
summary?: string | undefined;
|
|
65
|
+
rationale?: string | undefined;
|
|
66
|
+
action?: "middleware_badge" | "component_badge" | "micro_node" | "station_node" | undefined;
|
|
67
|
+
badgeLabel?: string | undefined;
|
|
68
|
+
badgeMode?: "fold_into_callers" | "badge_on_node" | undefined;
|
|
69
|
+
}, {
|
|
70
|
+
nodeId: string;
|
|
71
|
+
humanLabel?: string | undefined;
|
|
72
|
+
domain?: string | undefined;
|
|
73
|
+
summary?: string | undefined;
|
|
74
|
+
rationale?: string | undefined;
|
|
75
|
+
action?: "middleware_badge" | "component_badge" | "micro_node" | "station_node" | undefined;
|
|
76
|
+
badgeLabel?: string | undefined;
|
|
77
|
+
badgeMode?: "fold_into_callers" | "badge_on_node" | undefined;
|
|
78
|
+
}>, "many">>;
|
|
79
|
+
overlays: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
80
|
+
entityId: z.ZodString;
|
|
81
|
+
layer: z.ZodDefault<z.ZodString>;
|
|
82
|
+
source: z.ZodDefault<z.ZodString>;
|
|
83
|
+
environment: z.ZodDefault<z.ZodString>;
|
|
84
|
+
payload: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
85
|
+
bodyHash: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
86
|
+
derivation: z.ZodOptional<z.ZodEnum<["EXTRACTED", "INFERRED", "AI_HYPOTHESIS"]>>;
|
|
87
|
+
inputs: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
88
|
+
path: z.ZodString;
|
|
89
|
+
hash: z.ZodString;
|
|
90
|
+
}, "strip", z.ZodTypeAny, {
|
|
91
|
+
hash: string;
|
|
92
|
+
path: string;
|
|
93
|
+
}, {
|
|
94
|
+
hash: string;
|
|
95
|
+
path: string;
|
|
96
|
+
}>, "many">>;
|
|
97
|
+
evidence: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
98
|
+
filePath: z.ZodString;
|
|
99
|
+
lineNumber: z.ZodOptional<z.ZodNumber>;
|
|
100
|
+
snippet: z.ZodOptional<z.ZodString>;
|
|
101
|
+
evidenceRole: z.ZodOptional<z.ZodString>;
|
|
102
|
+
}, "strip", z.ZodTypeAny, {
|
|
103
|
+
filePath: string;
|
|
104
|
+
lineNumber?: number | undefined;
|
|
105
|
+
snippet?: string | undefined;
|
|
106
|
+
evidenceRole?: string | undefined;
|
|
107
|
+
}, {
|
|
108
|
+
filePath: string;
|
|
109
|
+
lineNumber?: number | undefined;
|
|
110
|
+
snippet?: string | undefined;
|
|
111
|
+
evidenceRole?: string | undefined;
|
|
112
|
+
}>, "many">>;
|
|
113
|
+
runId: z.ZodOptional<z.ZodString>;
|
|
114
|
+
pruneStaleBySource: z.ZodOptional<z.ZodBoolean>;
|
|
115
|
+
merge: z.ZodOptional<z.ZodBoolean>;
|
|
116
|
+
}, "strip", z.ZodTypeAny, {
|
|
117
|
+
payload: Record<string, any>;
|
|
118
|
+
layer: string;
|
|
119
|
+
source: string;
|
|
120
|
+
environment: string;
|
|
121
|
+
entityId: string;
|
|
122
|
+
evidence?: {
|
|
123
|
+
filePath: string;
|
|
124
|
+
lineNumber?: number | undefined;
|
|
125
|
+
snippet?: string | undefined;
|
|
126
|
+
evidenceRole?: string | undefined;
|
|
127
|
+
}[] | undefined;
|
|
128
|
+
inputs?: {
|
|
129
|
+
hash: string;
|
|
130
|
+
path: string;
|
|
131
|
+
}[] | undefined;
|
|
132
|
+
runId?: string | undefined;
|
|
133
|
+
pruneStaleBySource?: boolean | undefined;
|
|
134
|
+
bodyHash?: string | null | undefined;
|
|
135
|
+
derivation?: "EXTRACTED" | "INFERRED" | "AI_HYPOTHESIS" | undefined;
|
|
136
|
+
merge?: boolean | undefined;
|
|
137
|
+
}, {
|
|
138
|
+
payload: Record<string, any>;
|
|
139
|
+
entityId: string;
|
|
140
|
+
evidence?: {
|
|
141
|
+
filePath: string;
|
|
142
|
+
lineNumber?: number | undefined;
|
|
143
|
+
snippet?: string | undefined;
|
|
144
|
+
evidenceRole?: string | undefined;
|
|
145
|
+
}[] | undefined;
|
|
146
|
+
layer?: string | undefined;
|
|
147
|
+
inputs?: {
|
|
148
|
+
hash: string;
|
|
149
|
+
path: string;
|
|
150
|
+
}[] | undefined;
|
|
151
|
+
runId?: string | undefined;
|
|
152
|
+
source?: string | undefined;
|
|
153
|
+
environment?: string | undefined;
|
|
154
|
+
pruneStaleBySource?: boolean | undefined;
|
|
155
|
+
bodyHash?: string | null | undefined;
|
|
156
|
+
derivation?: "EXTRACTED" | "INFERRED" | "AI_HYPOTHESIS" | undefined;
|
|
157
|
+
merge?: boolean | undefined;
|
|
158
|
+
}>, "many">>;
|
|
159
|
+
runId: z.ZodOptional<z.ZodString>;
|
|
160
|
+
pruneStaleBySource: z.ZodOptional<z.ZodBoolean>;
|
|
161
|
+
rules: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
162
|
+
id: z.ZodOptional<z.ZodString>;
|
|
163
|
+
name: z.ZodString;
|
|
164
|
+
description: z.ZodOptional<z.ZodString>;
|
|
165
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
166
|
+
match: z.ZodObject<{
|
|
167
|
+
nodeId: z.ZodOptional<z.ZodString>;
|
|
168
|
+
namePattern: z.ZodOptional<z.ZodString>;
|
|
169
|
+
entityType: z.ZodOptional<z.ZodString>;
|
|
170
|
+
patternId: z.ZodOptional<z.ZodString>;
|
|
171
|
+
packageLabel: z.ZodOptional<z.ZodString>;
|
|
172
|
+
filePathPattern: z.ZodOptional<z.ZodString>;
|
|
173
|
+
overlayLayer: z.ZodOptional<z.ZodString>;
|
|
174
|
+
overlaySource: z.ZodOptional<z.ZodString>;
|
|
175
|
+
overlayField: z.ZodOptional<z.ZodString>;
|
|
176
|
+
overlayValue: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
177
|
+
}, "strip", z.ZodTypeAny, {
|
|
178
|
+
entityType?: string | undefined;
|
|
179
|
+
patternId?: string | undefined;
|
|
180
|
+
nodeId?: string | undefined;
|
|
181
|
+
packageLabel?: string | undefined;
|
|
182
|
+
namePattern?: string | undefined;
|
|
183
|
+
filePathPattern?: string | undefined;
|
|
184
|
+
overlayLayer?: string | undefined;
|
|
185
|
+
overlaySource?: string | undefined;
|
|
186
|
+
overlayField?: string | undefined;
|
|
187
|
+
overlayValue?: string | number | boolean | undefined;
|
|
188
|
+
}, {
|
|
189
|
+
entityType?: string | undefined;
|
|
190
|
+
patternId?: string | undefined;
|
|
191
|
+
nodeId?: string | undefined;
|
|
192
|
+
packageLabel?: string | undefined;
|
|
193
|
+
namePattern?: string | undefined;
|
|
194
|
+
filePathPattern?: string | undefined;
|
|
195
|
+
overlayLayer?: string | undefined;
|
|
196
|
+
overlaySource?: string | undefined;
|
|
197
|
+
overlayField?: string | undefined;
|
|
198
|
+
overlayValue?: string | number | boolean | undefined;
|
|
199
|
+
}>;
|
|
200
|
+
action: z.ZodEnum<["middleware_badge", "component_badge", "micro_node", "station_node"]>;
|
|
201
|
+
badgeLabel: z.ZodOptional<z.ZodString>;
|
|
202
|
+
badgeMode: z.ZodOptional<z.ZodEnum<["fold_into_callers", "badge_on_node"]>>;
|
|
203
|
+
}, "strip", z.ZodTypeAny, {
|
|
204
|
+
match: {
|
|
205
|
+
entityType?: string | undefined;
|
|
206
|
+
patternId?: string | undefined;
|
|
207
|
+
nodeId?: string | undefined;
|
|
208
|
+
packageLabel?: string | undefined;
|
|
209
|
+
namePattern?: string | undefined;
|
|
210
|
+
filePathPattern?: string | undefined;
|
|
211
|
+
overlayLayer?: string | undefined;
|
|
212
|
+
overlaySource?: string | undefined;
|
|
213
|
+
overlayField?: string | undefined;
|
|
214
|
+
overlayValue?: string | number | boolean | undefined;
|
|
215
|
+
};
|
|
216
|
+
name: string;
|
|
217
|
+
action: "middleware_badge" | "component_badge" | "micro_node" | "station_node";
|
|
218
|
+
id?: string | undefined;
|
|
219
|
+
description?: string | undefined;
|
|
220
|
+
enabled?: boolean | undefined;
|
|
221
|
+
badgeLabel?: string | undefined;
|
|
222
|
+
badgeMode?: "fold_into_callers" | "badge_on_node" | undefined;
|
|
223
|
+
}, {
|
|
224
|
+
match: {
|
|
225
|
+
entityType?: string | undefined;
|
|
226
|
+
patternId?: string | undefined;
|
|
227
|
+
nodeId?: string | undefined;
|
|
228
|
+
packageLabel?: string | undefined;
|
|
229
|
+
namePattern?: string | undefined;
|
|
230
|
+
filePathPattern?: string | undefined;
|
|
231
|
+
overlayLayer?: string | undefined;
|
|
232
|
+
overlaySource?: string | undefined;
|
|
233
|
+
overlayField?: string | undefined;
|
|
234
|
+
overlayValue?: string | number | boolean | undefined;
|
|
235
|
+
};
|
|
236
|
+
name: string;
|
|
237
|
+
action: "middleware_badge" | "component_badge" | "micro_node" | "station_node";
|
|
238
|
+
id?: string | undefined;
|
|
239
|
+
description?: string | undefined;
|
|
240
|
+
enabled?: boolean | undefined;
|
|
241
|
+
badgeLabel?: string | undefined;
|
|
242
|
+
badgeMode?: "fold_into_callers" | "badge_on_node" | undefined;
|
|
243
|
+
}>, "many">>;
|
|
244
|
+
defaults: z.ZodOptional<z.ZodObject<{
|
|
245
|
+
foldMiddleware: z.ZodOptional<z.ZodBoolean>;
|
|
246
|
+
foldComponents: z.ZodOptional<z.ZodBoolean>;
|
|
247
|
+
foldMicroNodes: z.ZodOptional<z.ZodBoolean>;
|
|
248
|
+
}, "strip", z.ZodTypeAny, {
|
|
249
|
+
foldMiddleware?: boolean | undefined;
|
|
250
|
+
foldComponents?: boolean | undefined;
|
|
251
|
+
foldMicroNodes?: boolean | undefined;
|
|
252
|
+
}, {
|
|
253
|
+
foldMiddleware?: boolean | undefined;
|
|
254
|
+
foldComponents?: boolean | undefined;
|
|
255
|
+
foldMicroNodes?: boolean | undefined;
|
|
256
|
+
}>>;
|
|
257
|
+
create_view: z.ZodOptional<z.ZodBoolean>;
|
|
258
|
+
createView: z.ZodOptional<z.ZodBoolean>;
|
|
259
|
+
};
|
|
260
|
+
handler: (args: Record<string, any>, ctx: import("../../pluginRunner.js").ChompPluginToolContext) => Promise<{
|
|
261
|
+
action: "status";
|
|
262
|
+
totalContracts: number;
|
|
263
|
+
enrichedContracts: number;
|
|
264
|
+
unenrichedContracts: number;
|
|
265
|
+
staleContracts: number;
|
|
266
|
+
coveragePct: number | null;
|
|
267
|
+
includeExportedTypes: boolean;
|
|
268
|
+
sidecarPath: ".chomp/plugins/enrich-nodes/semantic.json";
|
|
269
|
+
sidecarExists: boolean;
|
|
270
|
+
domains: {
|
|
271
|
+
domain: string;
|
|
272
|
+
count: number;
|
|
273
|
+
}[];
|
|
274
|
+
packages: {
|
|
275
|
+
packageLabel: string;
|
|
276
|
+
packageKey: string;
|
|
277
|
+
totalContracts: number;
|
|
278
|
+
enrichedContracts: number;
|
|
279
|
+
unenrichedContracts: number;
|
|
280
|
+
staleContracts: number;
|
|
281
|
+
coveragePct: number | null;
|
|
282
|
+
}[];
|
|
283
|
+
} | {
|
|
284
|
+
action: "queue";
|
|
285
|
+
statusFilter: "needs_enrichment" | "unenriched" | "stale" | "all";
|
|
286
|
+
totalMatching: number;
|
|
287
|
+
returnedCount: number;
|
|
288
|
+
cursor: number;
|
|
289
|
+
nextCursor: number | null;
|
|
290
|
+
existingDomains: {
|
|
291
|
+
domain: string;
|
|
292
|
+
count: number;
|
|
293
|
+
}[];
|
|
294
|
+
byPackage: Record<string, {
|
|
295
|
+
totalMatching: number;
|
|
296
|
+
unenriched: number;
|
|
297
|
+
stale: number;
|
|
298
|
+
}>;
|
|
299
|
+
items: import("../../enrichNodesPlugin.js").EnrichmentQueueItem[];
|
|
300
|
+
} | {
|
|
301
|
+
action: string;
|
|
302
|
+
path: string;
|
|
303
|
+
exportedCount: number;
|
|
304
|
+
totalSidecarNodes: number;
|
|
305
|
+
domains: string[];
|
|
306
|
+
sidecarExists?: undefined;
|
|
307
|
+
importedCount?: undefined;
|
|
308
|
+
skippedExistingCount?: undefined;
|
|
309
|
+
unknownNodeIds?: undefined;
|
|
310
|
+
remainingUnenriched?: undefined;
|
|
311
|
+
remainingStale?: undefined;
|
|
312
|
+
coveragePct?: undefined;
|
|
313
|
+
} | {
|
|
314
|
+
action: string;
|
|
315
|
+
path: ".chomp/plugins/enrich-nodes/semantic.json";
|
|
316
|
+
sidecarExists: boolean;
|
|
317
|
+
importedCount: number;
|
|
318
|
+
skippedExistingCount: number;
|
|
319
|
+
unknownNodeIds: never[];
|
|
320
|
+
exportedCount?: undefined;
|
|
321
|
+
totalSidecarNodes?: undefined;
|
|
322
|
+
domains?: undefined;
|
|
323
|
+
remainingUnenriched?: undefined;
|
|
324
|
+
remainingStale?: undefined;
|
|
325
|
+
coveragePct?: undefined;
|
|
326
|
+
} | {
|
|
327
|
+
action: string;
|
|
328
|
+
path: ".chomp/plugins/enrich-nodes/semantic.json";
|
|
329
|
+
sidecarExists: boolean;
|
|
330
|
+
importedCount: number;
|
|
331
|
+
skippedExistingCount: number;
|
|
332
|
+
unknownNodeIds: string[];
|
|
333
|
+
remainingUnenriched: any;
|
|
334
|
+
remainingStale: any;
|
|
335
|
+
coveragePct: any;
|
|
336
|
+
exportedCount?: undefined;
|
|
337
|
+
totalSidecarNodes?: undefined;
|
|
338
|
+
domains?: undefined;
|
|
339
|
+
} | {
|
|
340
|
+
action: string;
|
|
341
|
+
summary: string;
|
|
342
|
+
path?: undefined;
|
|
343
|
+
exportedCount?: undefined;
|
|
344
|
+
totalSidecarNodes?: undefined;
|
|
345
|
+
domains?: undefined;
|
|
346
|
+
sidecarExists?: undefined;
|
|
347
|
+
importedCount?: undefined;
|
|
348
|
+
skippedExistingCount?: undefined;
|
|
349
|
+
unknownNodeIds?: undefined;
|
|
350
|
+
remainingUnenriched?: undefined;
|
|
351
|
+
remainingStale?: undefined;
|
|
352
|
+
coveragePct?: undefined;
|
|
353
|
+
} | {
|
|
354
|
+
remainingUnenriched?: any;
|
|
355
|
+
remainingStale?: any;
|
|
356
|
+
coveragePct?: any;
|
|
357
|
+
action: string;
|
|
358
|
+
summary: string;
|
|
359
|
+
writtenByLayer: Record<string, number>;
|
|
360
|
+
rulesAddedOrUpdated: number;
|
|
361
|
+
unknownNodeIds: string[];
|
|
362
|
+
newDomains: string[];
|
|
363
|
+
deferredRefresh: boolean;
|
|
364
|
+
sidecarSynced: boolean;
|
|
365
|
+
path?: undefined;
|
|
366
|
+
exportedCount?: undefined;
|
|
367
|
+
totalSidecarNodes?: undefined;
|
|
368
|
+
domains?: undefined;
|
|
369
|
+
sidecarExists?: undefined;
|
|
370
|
+
importedCount?: undefined;
|
|
371
|
+
skippedExistingCount?: undefined;
|
|
372
|
+
}>;
|
|
373
|
+
}[];
|
|
374
|
+
name: string;
|
|
375
|
+
version: string;
|
|
376
|
+
layer: import("@getchomp/db").OverlayLayer;
|
|
377
|
+
displayName?: string;
|
|
378
|
+
description: string;
|
|
379
|
+
order?: number;
|
|
380
|
+
legacySources?: string[];
|
|
381
|
+
inspectorScopes?: import("@getchomp/core").PluginInspectorScope[];
|
|
382
|
+
accepts: (filePath: string) => boolean;
|
|
383
|
+
extract: (ctx: import("../../pluginRunner.js").ChompPluginContext) => Promise<import("../../pluginRunner.js").ChompPluginExtractResult | import("@getchomp/db").EntityOverlayInput[]> | import("../../pluginRunner.js").ChompPluginExtractResult | import("@getchomp/db").EntityOverlayInput[];
|
|
384
|
+
projectGraph?: (ctx: import("../../pluginRunner.js").ChompPluginProjectionContext) => import("@getchomp/core").RepresentationGraph;
|
|
385
|
+
isStructuralOverlay?: (overlay: import("../../pluginRunner.js").ChompPluginProjectionOverlayLike) => boolean;
|
|
386
|
+
};
|
|
387
|
+
export default enrichNodesPluginModule;
|
|
388
|
+
export { ENRICH_NODES_PLUGIN_NAME };
|