@greenharness/greenrack-cli 0.0.0-stage → 7.0.0
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 +335 -2
- package/agents/design-system-lookup.md +59 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +145 -0
- package/dist/bin.js.map +1 -0
- package/dist/catalog.d.ts +13 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +67 -0
- package/dist/catalog.js.map +1 -0
- package/dist/commands/context.d.ts +17 -0
- package/dist/commands/context.d.ts.map +1 -0
- package/dist/commands/context.js +110 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/doctor.d.ts +75 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +1008 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/hook.d.ts +10 -0
- package/dist/commands/hook.d.ts.map +1 -0
- package/dist/commands/hook.js +323 -0
- package/dist/commands/hook.js.map +1 -0
- package/dist/commands/list.d.ts +4 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +59 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/lookup.d.ts +13 -0
- package/dist/commands/lookup.d.ts.map +1 -0
- package/dist/commands/lookup.js +66 -0
- package/dist/commands/lookup.js.map +1 -0
- package/dist/commands/manifest.d.ts +5 -0
- package/dist/commands/manifest.d.ts.map +1 -0
- package/dist/commands/manifest.js +33 -0
- package/dist/commands/manifest.js.map +1 -0
- package/dist/commands/mcp.d.ts +159 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +235 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/mockup.d.ts +80 -0
- package/dist/commands/mockup.d.ts.map +1 -0
- package/dist/commands/mockup.js +714 -0
- package/dist/commands/mockup.js.map +1 -0
- package/dist/commands/skill.d.ts +15 -0
- package/dist/commands/skill.d.ts.map +1 -0
- package/dist/commands/skill.js +398 -0
- package/dist/commands/skill.js.map +1 -0
- package/dist/disambiguation.d.ts +24 -0
- package/dist/disambiguation.d.ts.map +1 -0
- package/dist/disambiguation.js +56 -0
- package/dist/disambiguation.js.map +1 -0
- package/dist/extension-pointer.d.ts +7 -0
- package/dist/extension-pointer.d.ts.map +1 -0
- package/dist/extension-pointer.js +30 -0
- package/dist/extension-pointer.js.map +1 -0
- package/dist/format.d.ts +19 -0
- package/dist/format.d.ts.map +1 -0
- package/dist/format.js +213 -0
- package/dist/format.js.map +1 -0
- package/dist/hook-script.d.ts +73 -0
- package/dist/hook-script.d.ts.map +1 -0
- package/dist/hook-script.js +165 -0
- package/dist/hook-script.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/legacy-names.d.ts +26 -0
- package/dist/legacy-names.d.ts.map +1 -0
- package/dist/legacy-names.js +26 -0
- package/dist/legacy-names.js.map +1 -0
- package/dist/manifest.d.ts +51 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +229 -0
- package/dist/manifest.js.map +1 -0
- package/dist/registry-types.d.ts +106 -0
- package/dist/registry-types.d.ts.map +1 -0
- package/dist/registry-types.js +2 -0
- package/dist/registry-types.js.map +1 -0
- package/dist/registry.d.ts +52 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +95 -0
- package/dist/registry.js.map +1 -0
- package/dist/scan.d.ts +19 -0
- package/dist/scan.d.ts.map +1 -0
- package/dist/scan.js +29 -0
- package/dist/scan.js.map +1 -0
- package/dist/search.d.ts +16 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +75 -0
- package/dist/search.js.map +1 -0
- package/dist/skill-template.d.ts +24 -0
- package/dist/skill-template.d.ts.map +1 -0
- package/dist/skill-template.js +140 -0
- package/dist/skill-template.js.map +1 -0
- package/greenharness.toml +38 -0
- package/package.json +76 -3
- package/registry.json +12893 -0
- package/skills/colors/LICENSE +21 -0
- package/skills/colors/NOTICE.md +36 -0
- package/skills/colors/SKILL.md +101 -0
- package/skills/colors/color-formats.md +90 -0
- package/skills/colors/color-usage.md +109 -0
- package/skills/colors/contrast.md +70 -0
- package/skills/colors/palette-generation.md +108 -0
- package/skills/colors/palette-structure.md +72 -0
- package/skills/colors/token-naming.md +99 -0
- package/skills/greenrack-mockup/SKILL.md +115 -0
- package/skills/typography/LICENSE +21 -0
- package/skills/typography/NOTICE.md +36 -0
- package/skills/typography/SKILL.md +171 -0
- package/skills/typography/choosing-fonts.md +53 -0
- package/skills/typography/css-cheat-sheet.md +67 -0
- package/skills/typography/details-and-accessibility.md +84 -0
- package/skills/typography/spacing-and-sizing.md +87 -0
- package/skills/typography/variable-fonts-and-opentype.md +100 -0
- package/skills/typography/wrapping-and-punctuation.md +23 -0
- package/skills/ui/LICENSE +21 -0
- package/skills/ui/NOTICE.md +38 -0
- package/skills/ui/SKILL.md +141 -0
- package/skills/ui/animations.md +170 -0
- package/skills/ui/enter-exit.md +157 -0
- package/skills/ui/icon-transitions.md +72 -0
- package/skills/ui/icons.md +105 -0
- package/skills/ui/performance.md +63 -0
- package/skills/ui/surfaces.md +166 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { buildManifest, COMMANDS } from '../manifest.js';
|
|
3
|
+
export function cliVersion() {
|
|
4
|
+
try {
|
|
5
|
+
const pkg = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8'));
|
|
6
|
+
return pkg.version ?? '0.0.0';
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
return '0.0.0';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export function runManifest(registry) {
|
|
13
|
+
const manifest = buildManifest(registry, cliVersion());
|
|
14
|
+
const text = [
|
|
15
|
+
`greenrack — ${manifest.description}`,
|
|
16
|
+
'',
|
|
17
|
+
`USAGE ${manifest.usage}`,
|
|
18
|
+
'',
|
|
19
|
+
...COMMANDS.map((command) => {
|
|
20
|
+
const flags = command.flags.map((flag) => `--${flag.name}`).join(' ');
|
|
21
|
+
return [
|
|
22
|
+
` greenrack ${command.name === 'lookup' ? '<name>' : command.name}${flags ? ` [${flags}]` : ''}`,
|
|
23
|
+
` ${command.summary}`,
|
|
24
|
+
...command.examples.map((example) => ` $ ${example}`),
|
|
25
|
+
].join('\n');
|
|
26
|
+
}),
|
|
27
|
+
'',
|
|
28
|
+
`GLOBAL ${manifest.globalFlags.map((flag) => `--${flag.name}`).join(' · ')}`,
|
|
29
|
+
`NAMES ${manifest.enums.names.length} — greenrack list`,
|
|
30
|
+
].join('\n');
|
|
31
|
+
return { text, data: manifest };
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../src/commands/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,SAAS,CAAA;AAEpC,OAAO,EAAC,aAAa,EAAE,QAAQ,EAAC,MAAM,gBAAgB,CAAA;AAGtD,MAAM,UAAU,UAAU;IACxB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CACpB,YAAY,CAAC,IAAI,GAAG,CAAC,oBAAoB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAGrE,CAAA;QACD,OAAO,GAAG,CAAC,OAAO,IAAI,OAAO,CAAA;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAA;IAChB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,QAAkB;IAC5C,MAAM,QAAQ,GAAG,aAAa,CAAC,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAA;IACtD,MAAM,IAAI,GAAG;QACX,eAAe,QAAQ,CAAC,WAAW,EAAE;QACrC,EAAE;QACF,UAAU,QAAQ,CAAC,KAAK,EAAE;QAC1B,EAAE;QACF,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;YAC1B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YACrE,OAAO;gBACL,eAAe,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;gBAClG,SAAS,OAAO,CAAC,OAAO,EAAE;gBAC1B,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,OAAO,EAAE,CAAC;aAC3D,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACd,CAAC,CAAC;QACF,EAAE;QACF,WAAW,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;QAC7E,WAAW,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,mBAAmB;KAC1D,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACZ,OAAO,EAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAC,CAAA;AAC/B,CAAC"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type { Registry } from '../registry-types.js';
|
|
2
|
+
/** The MCP tools, JSON Schemas hand-written (no zod dependency). */
|
|
3
|
+
export declare function toolDefinitions(registry: Registry): ({
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
inputSchema: {
|
|
7
|
+
type: string;
|
|
8
|
+
properties: {
|
|
9
|
+
name: {
|
|
10
|
+
type: string;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
part: {
|
|
14
|
+
type: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
sourceOnly: {
|
|
18
|
+
type: string;
|
|
19
|
+
description: string;
|
|
20
|
+
};
|
|
21
|
+
kind?: undefined;
|
|
22
|
+
html?: undefined;
|
|
23
|
+
file?: undefined;
|
|
24
|
+
artboards?: undefined;
|
|
25
|
+
title?: undefined;
|
|
26
|
+
};
|
|
27
|
+
required: string[];
|
|
28
|
+
};
|
|
29
|
+
} | {
|
|
30
|
+
name: string;
|
|
31
|
+
description: string;
|
|
32
|
+
inputSchema: {
|
|
33
|
+
type: string;
|
|
34
|
+
properties: {
|
|
35
|
+
kind: {
|
|
36
|
+
type: string;
|
|
37
|
+
enum: string[];
|
|
38
|
+
};
|
|
39
|
+
name?: undefined;
|
|
40
|
+
part?: undefined;
|
|
41
|
+
sourceOnly?: undefined;
|
|
42
|
+
html?: undefined;
|
|
43
|
+
file?: undefined;
|
|
44
|
+
artboards?: undefined;
|
|
45
|
+
title?: undefined;
|
|
46
|
+
};
|
|
47
|
+
required?: undefined;
|
|
48
|
+
};
|
|
49
|
+
} | {
|
|
50
|
+
name: string;
|
|
51
|
+
description: string;
|
|
52
|
+
inputSchema: {
|
|
53
|
+
type: string;
|
|
54
|
+
properties: {
|
|
55
|
+
name?: undefined;
|
|
56
|
+
part?: undefined;
|
|
57
|
+
sourceOnly?: undefined;
|
|
58
|
+
kind?: undefined;
|
|
59
|
+
html?: undefined;
|
|
60
|
+
file?: undefined;
|
|
61
|
+
artboards?: undefined;
|
|
62
|
+
title?: undefined;
|
|
63
|
+
};
|
|
64
|
+
required?: undefined;
|
|
65
|
+
};
|
|
66
|
+
} | {
|
|
67
|
+
name: string;
|
|
68
|
+
description: string;
|
|
69
|
+
inputSchema: {
|
|
70
|
+
type: string;
|
|
71
|
+
properties: {
|
|
72
|
+
html: {
|
|
73
|
+
type: string;
|
|
74
|
+
description: string;
|
|
75
|
+
};
|
|
76
|
+
file: {
|
|
77
|
+
type: string;
|
|
78
|
+
description: string;
|
|
79
|
+
};
|
|
80
|
+
name?: undefined;
|
|
81
|
+
part?: undefined;
|
|
82
|
+
sourceOnly?: undefined;
|
|
83
|
+
kind?: undefined;
|
|
84
|
+
artboards?: undefined;
|
|
85
|
+
title?: undefined;
|
|
86
|
+
};
|
|
87
|
+
required: string[];
|
|
88
|
+
};
|
|
89
|
+
} | {
|
|
90
|
+
name: string;
|
|
91
|
+
description: string;
|
|
92
|
+
inputSchema: {
|
|
93
|
+
type: string;
|
|
94
|
+
properties: {
|
|
95
|
+
artboards: {
|
|
96
|
+
type: string;
|
|
97
|
+
description: string;
|
|
98
|
+
items: {
|
|
99
|
+
type: string;
|
|
100
|
+
properties: {
|
|
101
|
+
file: {
|
|
102
|
+
type: string;
|
|
103
|
+
description: string;
|
|
104
|
+
};
|
|
105
|
+
html: {
|
|
106
|
+
type: string;
|
|
107
|
+
description: string;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
required: string[];
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
title: {
|
|
114
|
+
type: string;
|
|
115
|
+
description: string;
|
|
116
|
+
};
|
|
117
|
+
name?: undefined;
|
|
118
|
+
part?: undefined;
|
|
119
|
+
sourceOnly?: undefined;
|
|
120
|
+
kind?: undefined;
|
|
121
|
+
html?: undefined;
|
|
122
|
+
file?: undefined;
|
|
123
|
+
};
|
|
124
|
+
required: string[];
|
|
125
|
+
};
|
|
126
|
+
})[];
|
|
127
|
+
/**
|
|
128
|
+
* The wire shape of a tools/call answer. `structuredContent` must be a JSON
|
|
129
|
+
* object — a bare array is rejected by the SDK's result schema, which is how
|
|
130
|
+
* greenrack_list (a ListEntry[]) used to fail with -32602 — so arrays ride under
|
|
131
|
+
* `entries`.
|
|
132
|
+
*/
|
|
133
|
+
export declare function toolResponse(registry: Registry, name: string, args: Record<string, unknown>): {
|
|
134
|
+
content: {
|
|
135
|
+
type: "text";
|
|
136
|
+
text: string;
|
|
137
|
+
}[];
|
|
138
|
+
structuredContent: Record<string, unknown>;
|
|
139
|
+
isError: boolean;
|
|
140
|
+
};
|
|
141
|
+
export declare function callTool(registry: Registry, name: string, args: Record<string, unknown>): {
|
|
142
|
+
text: string;
|
|
143
|
+
data: unknown;
|
|
144
|
+
isError: boolean;
|
|
145
|
+
};
|
|
146
|
+
export declare function listResources(registry: Registry): {
|
|
147
|
+
uri: string;
|
|
148
|
+
name: string;
|
|
149
|
+
mimeType: string;
|
|
150
|
+
}[];
|
|
151
|
+
export declare function readResource(registry: Registry, uri: string): {
|
|
152
|
+
contents: {
|
|
153
|
+
uri: string;
|
|
154
|
+
mimeType: string;
|
|
155
|
+
text: string;
|
|
156
|
+
}[];
|
|
157
|
+
};
|
|
158
|
+
export declare function runMcp(registry: Registry): Promise<void>;
|
|
159
|
+
//# sourceMappingURL=mcp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/commands/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAA;AAclD,oEAAoE;AACpE,wBAAgB,eAAe,CAAC,QAAQ,EAAE,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4EjD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;uBAInB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;EAG/F;AAED,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;EAwCvF;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,EAAE,CAkBjG;AAED,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,MAAM,GACV;IAAC,QAAQ,EAAE;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,EAAE,CAAA;CAAC,CAoB7D;AAED,wBAAsB,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAmE9D"}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { buildManifest } from '../manifest.js';
|
|
2
|
+
import { guideNames, lookupGuide } from '../registry.js';
|
|
3
|
+
import { runLookup } from './lookup.js';
|
|
4
|
+
import { runList } from './list.js';
|
|
5
|
+
import { cliVersion } from './manifest.js';
|
|
6
|
+
import { renderComponent, renderRecipe } from '../format.js';
|
|
7
|
+
import { buildCanvas, checkArtboard } from './mockup.js';
|
|
8
|
+
const INSTALL_HINT = `greenrack mcp needs @modelcontextprotocol/sdk (an optional peer).
|
|
9
|
+
npm i -D @modelcontextprotocol/sdk
|
|
10
|
+
or run it without installing:
|
|
11
|
+
npx -y -p @greenharness/greenrack-cli -p @modelcontextprotocol/sdk greenrack mcp`;
|
|
12
|
+
/** The MCP tools, JSON Schemas hand-written (no zod dependency). */
|
|
13
|
+
export function toolDefinitions(registry) {
|
|
14
|
+
return [
|
|
15
|
+
{
|
|
16
|
+
name: 'greenrack_lookup',
|
|
17
|
+
description: 'Docs for anything in the greenrack design system by name: a component (props, usage, example), a recipe (runnable source), a token group, "icons", "rules", or an interface guide ("guide:colors", "guide:typography", "guide:ui"; "guide:<skill>/<file>" for one of its reference files). Free text falls back to a ranked search over usage metadata — pass what you need, e.g. "tags that wrap".',
|
|
18
|
+
inputSchema: {
|
|
19
|
+
type: 'object',
|
|
20
|
+
properties: {
|
|
21
|
+
name: {
|
|
22
|
+
type: 'string',
|
|
23
|
+
description: 'Component/recipe/token-group name, "icons", "rules", "guide:<skill>[/<file>]", or free text to search',
|
|
24
|
+
},
|
|
25
|
+
part: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
description: 'Narrow a compound component to one part (e.g. Root)',
|
|
28
|
+
},
|
|
29
|
+
sourceOnly: { type: 'boolean', description: 'Recipes: return just the source file' },
|
|
30
|
+
},
|
|
31
|
+
required: ['name'],
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'greenrack_list',
|
|
36
|
+
description: `One-line index of everything documented (${Object.keys(registry.components).length} components, ${Object.keys(registry.recipes).length} recipes, token groups; kind "guides" lists the interface guides).`,
|
|
37
|
+
inputSchema: {
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: {
|
|
40
|
+
kind: { type: 'string', enum: ['components', 'recipes', 'tokens', 'guides'] },
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: 'greenrack_manifest',
|
|
46
|
+
description: 'The greenrack command spec plus all valid lookup names.',
|
|
47
|
+
inputSchema: { type: 'object', properties: {} },
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'greenrack_mockup_check',
|
|
51
|
+
description: 'Check a mockup artboard (.dc.html source) against the design system: every colour, spacing, radius, font, shadow and duration must be a var(--gr-*) token, media queries must sit on the breakpoint scale, and every control must carry data-gr="<Component>" naming an @greenharness/greenrack-ui component. Returns findings; an empty list means the artboard is a valid handoff contract.',
|
|
52
|
+
inputSchema: {
|
|
53
|
+
type: 'object',
|
|
54
|
+
properties: {
|
|
55
|
+
html: { type: 'string', description: 'The full artboard HTML' },
|
|
56
|
+
file: { type: 'string', description: 'A name for the findings, e.g. Main.dc.html' },
|
|
57
|
+
},
|
|
58
|
+
required: ['html'],
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'greenrack_mockup_canvas',
|
|
63
|
+
description: 'One self-contained HTML review page for a set of mockup artboards: each direction (Tree.dc.html and Tree-Phone.dc.html are direction Tree) under a letter, every artboard inlined and scaled to its frame. Publish the page for the person to pick a direction. Nothing is built while an artboard fails greenrack_mockup_check: the findings come back instead.',
|
|
64
|
+
inputSchema: {
|
|
65
|
+
type: 'object',
|
|
66
|
+
properties: {
|
|
67
|
+
artboards: {
|
|
68
|
+
type: 'array',
|
|
69
|
+
description: 'The artboards, each with its file name and full HTML',
|
|
70
|
+
items: {
|
|
71
|
+
type: 'object',
|
|
72
|
+
properties: {
|
|
73
|
+
file: { type: 'string', description: 'e.g. Tree-Phone.dc.html' },
|
|
74
|
+
html: { type: 'string', description: 'The full artboard HTML' },
|
|
75
|
+
},
|
|
76
|
+
required: ['file', 'html'],
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
title: { type: 'string', description: 'The page title' },
|
|
80
|
+
},
|
|
81
|
+
required: ['artboards'],
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The wire shape of a tools/call answer. `structuredContent` must be a JSON
|
|
88
|
+
* object — a bare array is rejected by the SDK's result schema, which is how
|
|
89
|
+
* greenrack_list (a ListEntry[]) used to fail with -32602 — so arrays ride under
|
|
90
|
+
* `entries`.
|
|
91
|
+
*/
|
|
92
|
+
export function toolResponse(registry, name, args) {
|
|
93
|
+
const { text, data, isError } = callTool(registry, name, args);
|
|
94
|
+
return {
|
|
95
|
+
content: [{ type: 'text', text: text || JSON.stringify(data, null, 2) }],
|
|
96
|
+
structuredContent: (Array.isArray(data) ? { entries: data } : data),
|
|
97
|
+
isError,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export function callTool(registry, name, args) {
|
|
101
|
+
switch (name) {
|
|
102
|
+
case 'greenrack_lookup': {
|
|
103
|
+
const result = runLookup(registry, String(args.name ?? ''), {
|
|
104
|
+
part: typeof args.part === 'string' ? args.part : undefined,
|
|
105
|
+
sourceOnly: args.sourceOnly === true,
|
|
106
|
+
});
|
|
107
|
+
return { text: result.text, data: result.data, isError: result.exitCode === 1 };
|
|
108
|
+
}
|
|
109
|
+
case 'greenrack_list': {
|
|
110
|
+
const result = runList(registry, typeof args.kind === 'string' ? args.kind : undefined);
|
|
111
|
+
return { text: result.text, data: result.data, isError: result.exitCode !== undefined };
|
|
112
|
+
}
|
|
113
|
+
case 'greenrack_manifest':
|
|
114
|
+
return { text: '', data: buildManifest(registry, cliVersion()), isError: false };
|
|
115
|
+
case 'greenrack_mockup_check': {
|
|
116
|
+
const file = typeof args.file === 'string' ? args.file : 'artboard.dc.html';
|
|
117
|
+
const findings = checkArtboard(registry, file, String(args.html ?? ''));
|
|
118
|
+
const text = findings.length === 0
|
|
119
|
+
? `${file}: speaks tokens and names its components`
|
|
120
|
+
: findings.map((f) => `${f.file}:${f.line} ${f.rule}: ${f.message}`).join('\n');
|
|
121
|
+
return { text, data: { ok: findings.length === 0, findings }, isError: false };
|
|
122
|
+
}
|
|
123
|
+
case 'greenrack_mockup_canvas': {
|
|
124
|
+
const artboards = (Array.isArray(args.artboards) ? args.artboards : [])
|
|
125
|
+
.filter((a) => typeof a === 'object' && a !== null)
|
|
126
|
+
.map((a) => ({ file: String(a.file ?? 'artboard.dc.html'), html: String(a.html ?? '') }));
|
|
127
|
+
if (artboards.length === 0) {
|
|
128
|
+
return { text: 'give at least one artboard', data: { ok: false }, isError: true };
|
|
129
|
+
}
|
|
130
|
+
const title = typeof args.title === 'string' ? args.title : undefined;
|
|
131
|
+
const { html, findings } = buildCanvas(registry, artboards, { title });
|
|
132
|
+
const text = html ?? findings.map((f) => `${f.file}:${f.line} ${f.rule}: ${f.message}`).join('\n');
|
|
133
|
+
return { text, data: { ok: html !== null, html, findings }, isError: false };
|
|
134
|
+
}
|
|
135
|
+
default:
|
|
136
|
+
throw new Error(`unknown tool ${name}`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
export function listResources(registry) {
|
|
140
|
+
return [
|
|
141
|
+
...Object.keys(registry.components).map((name) => ({
|
|
142
|
+
uri: `greenrack://component/${encodeURIComponent(name)}`,
|
|
143
|
+
name: `${name} docs`,
|
|
144
|
+
mimeType: 'text/plain',
|
|
145
|
+
})),
|
|
146
|
+
...Object.keys(registry.recipes).map((name) => ({
|
|
147
|
+
uri: `greenrack://recipe/${name}`,
|
|
148
|
+
name: `${name} recipe`,
|
|
149
|
+
mimeType: 'text/plain',
|
|
150
|
+
})),
|
|
151
|
+
...guideNames(registry).map((name) => ({
|
|
152
|
+
uri: `greenrack://guide/${name.slice('guide:'.length)}`,
|
|
153
|
+
name: `${name} guide`,
|
|
154
|
+
mimeType: 'text/markdown',
|
|
155
|
+
})),
|
|
156
|
+
];
|
|
157
|
+
}
|
|
158
|
+
export function readResource(registry, uri) {
|
|
159
|
+
const componentMatch = /^greenrack:\/\/component\/(.+)$/.exec(uri);
|
|
160
|
+
const recipeMatch = /^greenrack:\/\/recipe\/(.+)$/.exec(uri);
|
|
161
|
+
const guideMatch = /^greenrack:\/\/guide\/(.+)$/.exec(uri);
|
|
162
|
+
let text = null;
|
|
163
|
+
let mimeType = 'text/plain';
|
|
164
|
+
if (guideMatch) {
|
|
165
|
+
const guide = lookupGuide(registry, `guide:${guideMatch[1]}`);
|
|
166
|
+
if (guide.ok)
|
|
167
|
+
text = guide.content;
|
|
168
|
+
mimeType = 'text/markdown';
|
|
169
|
+
}
|
|
170
|
+
else if (componentMatch) {
|
|
171
|
+
const key = decodeURIComponent(componentMatch[1]);
|
|
172
|
+
const entry = registry.components[key];
|
|
173
|
+
if (entry)
|
|
174
|
+
text = renderComponent(registry, key, entry);
|
|
175
|
+
}
|
|
176
|
+
else if (recipeMatch) {
|
|
177
|
+
const entry = registry.recipes[recipeMatch[1]];
|
|
178
|
+
if (entry)
|
|
179
|
+
text = renderRecipe(entry);
|
|
180
|
+
}
|
|
181
|
+
if (text === null)
|
|
182
|
+
throw new Error(`unknown resource ${uri}`);
|
|
183
|
+
return { contents: [{ uri, mimeType, text }] };
|
|
184
|
+
}
|
|
185
|
+
export async function runMcp(registry) {
|
|
186
|
+
let sdkServer, sdkStdio, sdkTypes;
|
|
187
|
+
try {
|
|
188
|
+
sdkServer = await import('@modelcontextprotocol/sdk/server/index.js');
|
|
189
|
+
sdkStdio = await import('@modelcontextprotocol/sdk/server/stdio.js');
|
|
190
|
+
sdkTypes = await import('@modelcontextprotocol/sdk/types.js');
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
process.stderr.write(INSTALL_HINT + '\n');
|
|
194
|
+
process.exit(2);
|
|
195
|
+
}
|
|
196
|
+
const server = new sdkServer.Server({ name: 'greenrack', version: cliVersion() }, { capabilities: { tools: {}, resources: {}, prompts: {} } });
|
|
197
|
+
server.setRequestHandler(sdkTypes.ListToolsRequestSchema, () => ({
|
|
198
|
+
tools: toolDefinitions(registry),
|
|
199
|
+
}));
|
|
200
|
+
server.setRequestHandler(sdkTypes.CallToolRequestSchema, (request) => toolResponse(registry, request.params.name, (request.params.arguments ?? {})));
|
|
201
|
+
server.setRequestHandler(sdkTypes.ListResourcesRequestSchema, () => ({
|
|
202
|
+
resources: listResources(registry),
|
|
203
|
+
}));
|
|
204
|
+
server.setRequestHandler(sdkTypes.ReadResourceRequestSchema, (request) => readResource(registry, request.params.uri));
|
|
205
|
+
server.setRequestHandler(sdkTypes.ListPromptsRequestSchema, () => ({
|
|
206
|
+
prompts: [
|
|
207
|
+
{
|
|
208
|
+
name: 'greenrack/build-ui',
|
|
209
|
+
description: 'Prime a session with the greenrack critical rules and component index',
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
}));
|
|
213
|
+
server.setRequestHandler(sdkTypes.GetPromptRequestSchema, (request) => {
|
|
214
|
+
if (request.params.name !== 'greenrack/build-ui') {
|
|
215
|
+
throw new Error(`unknown prompt ${request.params.name}`);
|
|
216
|
+
}
|
|
217
|
+
const componentIndex = Object.entries(registry.components)
|
|
218
|
+
.map(([key, entry]) => `${key}: ${entry.meta?.description ?? entry.kind}`)
|
|
219
|
+
.join('\n');
|
|
220
|
+
return {
|
|
221
|
+
messages: [
|
|
222
|
+
{
|
|
223
|
+
role: 'user',
|
|
224
|
+
content: {
|
|
225
|
+
type: 'text',
|
|
226
|
+
text: `You are building UI with the greenrack design system. Follow these rules:\n\n${registry.rules.critical}\n\nAvailable components:\n${componentIndex}\n\nQuery details with the greenrack_lookup tool.`,
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
],
|
|
230
|
+
};
|
|
231
|
+
});
|
|
232
|
+
const transport = new sdkStdio.StdioServerTransport();
|
|
233
|
+
await server.connect(transport);
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=mcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../src/commands/mcp.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAC,UAAU,EAAE,WAAW,EAAC,MAAM,gBAAgB,CAAA;AACtD,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAA;AACrC,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAA;AACxC,OAAO,EAAC,eAAe,EAAE,YAAY,EAAC,MAAM,cAAc,CAAA;AAC1D,OAAO,EAAC,WAAW,EAAE,aAAa,EAAC,MAAM,aAAa,CAAA;AAEtD,MAAM,YAAY,GAAG;;;mFAG8D,CAAA;AAEnF,oEAAoE;AACpE,M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AE,CAAC;aACzE,IAAI,CAAC,IAAI,CAAC,CAAA;QACb,OAAO;YACL,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,MAAM;oBACZ,OAAO,EAAE;wBACP,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,gFAAgF,QAAQ,CAAC,KAAK,CAAC,QAAQ,8BAA8B,cAAc,mDAAmD;qBAC7M;iBACF;aACF;SACF,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,MAAM,SAAS,GAAG,IAAI,QAAQ,CAAC,oBAAoB,EAAE,CAAA;IACrD,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;AACjC,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { type ThemableGroup, type ThemeTokens } from '@greenharness/greenrack-tokens/theme';
|
|
2
|
+
import type { Registry } from '../registry-types.js';
|
|
3
|
+
import type { CommandResult } from './lookup.js';
|
|
4
|
+
import { MOCKUP_SUBCOMMANDS } from '../manifest.js';
|
|
5
|
+
export declare const TOKENS_START = "/* greenrack:tokens start */";
|
|
6
|
+
export declare const TOKENS_END = "/* greenrack:tokens end */";
|
|
7
|
+
/** The artboard size, on the root element and in the review canvas's frames. */
|
|
8
|
+
export declare const ARTBOARD_WIDTH = 1120;
|
|
9
|
+
export declare const ARTBOARD_HEIGHT = 840;
|
|
10
|
+
export declare const MOCKUP_THEMES: readonly ["dark", "light", "high-contrast"];
|
|
11
|
+
export type MockupTheme = (typeof MOCKUP_THEMES)[number];
|
|
12
|
+
export interface SeedOptions {
|
|
13
|
+
/** Directory to write into. Defaults to docs/mockups/<name>. */
|
|
14
|
+
out?: string;
|
|
15
|
+
/** Artboard file stem (default Main). */
|
|
16
|
+
name?: string;
|
|
17
|
+
theme?: string;
|
|
18
|
+
/** A theme JSON file: the `tokens` shape ThemeProvider takes, or a flat map of colour token keys to colours. */
|
|
19
|
+
overrides?: string;
|
|
20
|
+
cwd?: string;
|
|
21
|
+
}
|
|
22
|
+
/** Theme overrides read from a file: the file's name for the comment, and the validated tokens. */
|
|
23
|
+
export interface SeedOverrides {
|
|
24
|
+
file: string;
|
|
25
|
+
tokens: ThemeTokens;
|
|
26
|
+
}
|
|
27
|
+
export interface CheckOptions {
|
|
28
|
+
cwd?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface CanvasOptions {
|
|
31
|
+
/** Where to write the page. Defaults to <dir>/canvas.html. */
|
|
32
|
+
out?: string;
|
|
33
|
+
/** The page title. Defaults to "<dir name> directions". */
|
|
34
|
+
title?: string;
|
|
35
|
+
cwd?: string;
|
|
36
|
+
}
|
|
37
|
+
/** One artboard handed to the canvas: its file name and its HTML. */
|
|
38
|
+
export interface CanvasArtboard {
|
|
39
|
+
file: string;
|
|
40
|
+
html: string;
|
|
41
|
+
}
|
|
42
|
+
export interface Finding {
|
|
43
|
+
file: string;
|
|
44
|
+
line: number;
|
|
45
|
+
rule: 'raw-color' | 'raw-length' | 'raw-breakpoint' | 'unknown-component' | 'no-component-map' | 'unannotated-control';
|
|
46
|
+
message: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The artboard skeleton: support.js verbatim, one <x-dc>, one
|
|
50
|
+
* <helmet><style>. Everything a
|
|
51
|
+
* finished artboard adds goes inside the same style block and the root div.
|
|
52
|
+
*/
|
|
53
|
+
export declare function seedArtboard(registry: Registry, name: string, theme: MockupTheme, overrides?: SeedOverrides): string;
|
|
54
|
+
/**
|
|
55
|
+
* The CSS variable a token publishes: `--gr-<alias>-<kebab key>`, named by
|
|
56
|
+
* the module ThemeProvider and the registry build use, so it matches what
|
|
57
|
+
* registry.tokens.mockupCss declares.
|
|
58
|
+
*/
|
|
59
|
+
export declare function tokenVariableName(group: ThemableGroup, key: string): string;
|
|
60
|
+
export declare function runMockupSeed(registry: Registry, options?: SeedOptions): CommandResult;
|
|
61
|
+
/** Every finding for one artboard's HTML. Exported for the MCP tool and tests. */
|
|
62
|
+
export declare function checkArtboard(registry: Registry, file: string, source: string): Finding[];
|
|
63
|
+
export declare function runMockupCheck(registry: Registry, files: string[], options?: CheckOptions): CommandResult;
|
|
64
|
+
/**
|
|
65
|
+
* The review page: every direction side by side, each artboard inlined by
|
|
66
|
+
* srcdoc so the page is one file (an Artifact needs no supporting files, and
|
|
67
|
+
* a local copy opens from disk). The frames are sandboxed: an artboard is
|
|
68
|
+
* untrusted HTML (the MCP tool takes it from the caller) and needs no script. Nothing is built while an artboard fails the
|
|
69
|
+
* check: the person picks from contracts, not from sketches that drift.
|
|
70
|
+
*/
|
|
71
|
+
export declare function buildCanvas(registry: Registry, artboards: CanvasArtboard[], options: {
|
|
72
|
+
title?: string;
|
|
73
|
+
}): {
|
|
74
|
+
html: string | null;
|
|
75
|
+
findings: Finding[];
|
|
76
|
+
};
|
|
77
|
+
export declare function runMockupCanvas(registry: Registry, dir: string | undefined, options?: CanvasOptions): CommandResult;
|
|
78
|
+
export { MOCKUP_SUBCOMMANDS };
|
|
79
|
+
export declare function runMockup(registry: Registry, sub: string | undefined, rest: string[], options: SeedOptions & CheckOptions & CanvasOptions): CommandResult;
|
|
80
|
+
//# sourceMappingURL=mockup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mockup.d.ts","sourceRoot":"","sources":["../../src/commands/mockup.ts"],"names":[],"mappings":"AAUA,OAAO,EAQL,KAAK,aAAa,EAClB,KAAK,WAAW,EACjB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,aAAa,CAAA;AAI9C,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAA;AAuBjD,eAAO,MAAM,YAAY,iCAAiC,CAAA;AAC1D,eAAO,MAAM,UAAU,+BAA+B,CAAA;AAEtD,gFAAgF;AAChF,eAAO,MAAM,cAAc,OAAO,CAAA;AAClC,eAAO,MAAM,eAAe,MAAM,CAAA;AAElC,eAA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