@hegemonart/get-design-done 1.27.6 → 1.28.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.
Files changed (71) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +6 -3
  3. package/CHANGELOG.md +113 -0
  4. package/agents/design-verifier.md +17 -0
  5. package/package.json +5 -4
  6. package/reference/accessibility.md +4 -0
  7. package/reference/audit-scoring.md +14 -0
  8. package/reference/color-theory.md +279 -0
  9. package/reference/composition.md +349 -0
  10. package/reference/contrast-advanced.md +205 -0
  11. package/reference/design-system-guidance.md +2 -0
  12. package/reference/form-patterns.md +2 -0
  13. package/reference/i18n.md +554 -0
  14. package/reference/iconography.md +2 -0
  15. package/reference/motion-interpolate.md +1 -0
  16. package/reference/palette-catalog.md +2 -0
  17. package/reference/proportion-systems.md +267 -0
  18. package/reference/registry.json +42 -0
  19. package/reference/rtl-cjk-cultural.md +2 -0
  20. package/reference/schemas/mcp-gdd-tools.schema.json +381 -0
  21. package/reference/style-vocabulary.md +2 -0
  22. package/reference/typography.md +4 -0
  23. package/reference/visual-hierarchy-layout.md +4 -0
  24. package/scripts/install.cjs +42 -0
  25. package/scripts/lib/gsd-health-mirror/index.cjs +105 -0
  26. package/scripts/lib/gsd-health-mirror/index.d.cts +14 -0
  27. package/scripts/lib/install/mcp-register.cjs +235 -0
  28. package/scripts/lib/install/mcp-register.d.cts +64 -0
  29. package/scripts/lib/intel-store/index.cjs +55 -0
  30. package/scripts/lib/intel-store/index.d.cts +11 -0
  31. package/scripts/lib/mcp-tools-lint/index.cjs +216 -0
  32. package/scripts/lib/mcp-tools-lint/index.d.cts +74 -0
  33. package/scripts/lib/reflections-reader/index.cjs +107 -0
  34. package/scripts/lib/reflections-reader/index.d.cts +18 -0
  35. package/scripts/lib/roadmap-reader/index.cjs +81 -0
  36. package/scripts/lib/roadmap-reader/index.d.cts +13 -0
  37. package/scripts/lib/snapshot-reader/index.cjs +70 -0
  38. package/scripts/lib/snapshot-reader/index.d.cts +28 -0
  39. package/scripts/mcp-servers/gdd-mcp/README.md +66 -0
  40. package/scripts/mcp-servers/gdd-mcp/schemas/gdd_cycle_recap.schema.json +30 -0
  41. package/scripts/mcp-servers/gdd-mcp/schemas/gdd_decisions_list.schema.json +32 -0
  42. package/scripts/mcp-servers/gdd-mcp/schemas/gdd_events_tail.schema.json +22 -0
  43. package/scripts/mcp-servers/gdd-mcp/schemas/gdd_health.schema.json +30 -0
  44. package/scripts/mcp-servers/gdd-mcp/schemas/gdd_intel_get.schema.json +24 -0
  45. package/scripts/mcp-servers/gdd-mcp/schemas/gdd_learnings_digest.schema.json +22 -0
  46. package/scripts/mcp-servers/gdd-mcp/schemas/gdd_phase_current.schema.json +22 -0
  47. package/scripts/mcp-servers/gdd-mcp/schemas/gdd_phases_list.schema.json +31 -0
  48. package/scripts/mcp-servers/gdd-mcp/schemas/gdd_plans_list.schema.json +33 -0
  49. package/scripts/mcp-servers/gdd-mcp/schemas/gdd_reflections_latest.schema.json +21 -0
  50. package/scripts/mcp-servers/gdd-mcp/schemas/gdd_status.schema.json +23 -0
  51. package/scripts/mcp-servers/gdd-mcp/schemas/gdd_telemetry_query.schema.json +23 -0
  52. package/scripts/mcp-servers/gdd-mcp/server.ts +317 -0
  53. package/scripts/mcp-servers/gdd-mcp/tools/gdd_cycle_recap.ts +37 -0
  54. package/scripts/mcp-servers/gdd-mcp/tools/gdd_decisions_list.ts +33 -0
  55. package/scripts/mcp-servers/gdd-mcp/tools/gdd_events_tail.ts +26 -0
  56. package/scripts/mcp-servers/gdd-mcp/tools/gdd_health.ts +19 -0
  57. package/scripts/mcp-servers/gdd-mcp/tools/gdd_intel_get.ts +32 -0
  58. package/scripts/mcp-servers/gdd-mcp/tools/gdd_learnings_digest.ts +23 -0
  59. package/scripts/mcp-servers/gdd-mcp/tools/gdd_phase_current.ts +29 -0
  60. package/scripts/mcp-servers/gdd-mcp/tools/gdd_phases_list.ts +26 -0
  61. package/scripts/mcp-servers/gdd-mcp/tools/gdd_plans_list.ts +39 -0
  62. package/scripts/mcp-servers/gdd-mcp/tools/gdd_reflections_latest.ts +25 -0
  63. package/scripts/mcp-servers/gdd-mcp/tools/gdd_status.ts +31 -0
  64. package/scripts/mcp-servers/gdd-mcp/tools/gdd_telemetry_query.ts +27 -0
  65. package/scripts/mcp-servers/gdd-mcp/tools/index.ts +75 -0
  66. package/scripts/mcp-servers/gdd-mcp/tools/shared.ts +134 -0
  67. package/skills/explore/SKILL.md +31 -0
  68. package/skills/health/SKILL.md +36 -0
  69. package/skills/next/SKILL.md +28 -3
  70. package/skills/progress/SKILL.md +21 -6
  71. package/skills/resume/SKILL.md +26 -1
@@ -0,0 +1,23 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "gdd_status",
4
+ "type": "object",
5
+ "properties": {
6
+ "input": {
7
+ "type": "object",
8
+ "additionalProperties": false,
9
+ "properties": {}
10
+ },
11
+ "output": {
12
+ "type": "object",
13
+ "required": ["phase", "branch", "last_decisions", "last_completed_plans", "blocker_count"],
14
+ "properties": {
15
+ "phase": { "type": ["string", "null"] },
16
+ "branch": { "type": ["string", "null"] },
17
+ "last_decisions": { "type": "array", "items": { "type": "object" } },
18
+ "last_completed_plans": { "type": "array", "items": { "type": "object" } },
19
+ "blocker_count": { "type": "integer", "minimum": 0 }
20
+ }
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "gdd_telemetry_query",
4
+ "type": "object",
5
+ "properties": {
6
+ "input": {
7
+ "type": "object",
8
+ "additionalProperties": false,
9
+ "properties": {
10
+ "type": { "type": "string" },
11
+ "since": { "type": "string", "format": "date-time" },
12
+ "limit": { "type": "integer", "minimum": 1, "maximum": 10000 }
13
+ }
14
+ },
15
+ "output": {
16
+ "type": "object",
17
+ "required": ["events"],
18
+ "properties": {
19
+ "events": { "type": "array", "items": { "type": "object" } }
20
+ }
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,317 @@
1
+ #!/usr/bin/env -S node --experimental-strip-types
2
+ // scripts/mcp-servers/gdd-mcp/server.ts
3
+ //
4
+ // MCP server `gdd-mcp` — read-mostly project-state surface (Phase 27.7).
5
+ // Exposes STATE.md sections, phases, decisions, plans, telemetry, intel
6
+ // slices, and the latest reflection as typed MCP tools backed by the
7
+ // same `scripts/lib/*` modules the CLI uses.
8
+ //
9
+ // Lifecycle (mirrors Phase 20 `gdd-state` server):
10
+ // 1. Construct a low-level Server (we use the low-level surface so we
11
+ // can speak JSON Schema directly — the high-level McpServer wants
12
+ // Zod shapes, and our per-tool schemas are Draft-07 JSON.)
13
+ // 2. Register `tools/list` — returns the registered tools with their
14
+ // input JSON Schemas loaded from disk. Scaffold ships with 0
15
+ // tools; Plan 27.7-02 populates `TOOL_MODULES` with 12 entries.
16
+ // 3. Register `tools/call` — dispatches by name to the matching
17
+ // handler. Each handler returns a typed ToolResponse; the server
18
+ // wraps it into the MCP CallToolResult shape. Unknown tool names
19
+ // return `isError: true` with a structured payload.
20
+ // 4. Attach StdioServerTransport; await connect. NO port allocation
21
+ // (D-05 stdio-only).
22
+ // 5. On SIGINT / SIGTERM: close the transport, exit 0. Re-entrant
23
+ // shutdown is guarded with a module-level `SHUTTING_DOWN` flag.
24
+ //
25
+ // Project-root discovery (D-05): `resolveProjectRoot()` lives in
26
+ // `./tools/shared.ts` and walks up from `process.cwd()` looking for
27
+ // `.design/` OR `.planning/` OR `.claude-plugin/plugin.json`. Server
28
+ // infrastructure is allowed to import `node:fs`/`node:path` directly;
29
+ // only individual TOOL files are bound by the thin-wrapper rule (D-06).
30
+ //
31
+ // Invariant: handler throws are contained. The dispatcher wraps every
32
+ // call in a try/catch that funnels through `toToolError()` — the MCP
33
+ // harness never sees an uncaught throw from our tools.
34
+
35
+ import { readFileSync, existsSync } from 'node:fs';
36
+ import { dirname, join, resolve } from 'node:path';
37
+
38
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
39
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
40
+ import {
41
+ CallToolRequestSchema,
42
+ ListToolsRequestSchema,
43
+ } from '@modelcontextprotocol/sdk/types.js';
44
+
45
+ import { toToolError } from '../../lib/gdd-errors/classification.ts';
46
+ import { TOOL_MODULES, type ToolModule } from './tools/index.ts';
47
+
48
+ /** Server metadata advertised on initialize. */
49
+ export const SERVER_NAME = 'gdd-mcp';
50
+ export const SERVER_VERSION = '1.27.7';
51
+
52
+ /**
53
+ * Resolve this module's directory. We deliberately avoid `import.meta.url`
54
+ * (not permitted by our tsconfig's Node16+CommonJS-compatible module
55
+ * resolution) and `__dirname` (not portable under strip-types ESM).
56
+ *
57
+ * Strategy: when this module is invoked as a script, `process.argv[1]`
58
+ * points at this file; resolve its dirname. When it is imported for
59
+ * tests, we fall back to walking from `process.cwd()` — tests run
60
+ * from the repo root by convention, so `scripts/mcp-servers/gdd-mcp`
61
+ * resolves reliably. Both branches are canonicalized against the
62
+ * on-disk tools directory.
63
+ */
64
+ function here(): string {
65
+ const expectedRel = join('scripts', 'mcp-servers', 'gdd-mcp');
66
+ // Script invocation: process.argv[1] === .../server.ts (or a shim).
67
+ const entry = process.argv[1];
68
+ if (typeof entry === 'string' && entry.length > 0) {
69
+ const entryDir = dirname(resolve(entry));
70
+ if (existsSync(join(entryDir, 'tools', 'index.ts'))) {
71
+ return entryDir;
72
+ }
73
+ }
74
+ // Library-import path (tests): walk cwd forward.
75
+ const candidate = resolve(process.cwd(), expectedRel);
76
+ if (existsSync(join(candidate, 'tools', 'index.ts'))) {
77
+ return candidate;
78
+ }
79
+ // Last-resort: return the expected path even if it does not exist —
80
+ // the subsequent readFileSync() call will produce a clear error.
81
+ return candidate;
82
+ }
83
+
84
+ /** Eager cache of input schemas keyed by tool name. We load them once at
85
+ * startup so a tool-call handler never hits the filesystem in the hot
86
+ * path; subsequent schema edits (JSON file on disk) require a server
87
+ * restart, which matches every other part of the pipeline.
88
+ *
89
+ * Scaffold ships with 0 tools — loadTools() returns []. Plan 27.7-02
90
+ * adds 12 tool modules, each with its own `schemaPath` pointing into
91
+ * `scripts/mcp-servers/gdd-mcp/schemas/`. */
92
+ interface LoadedTool extends ToolModule {
93
+ inputSchema: Record<string, unknown>;
94
+ }
95
+
96
+ function loadTools(): LoadedTool[] {
97
+ const baseDir = here();
98
+ return TOOL_MODULES.map((m) => {
99
+ const absPath = join(baseDir, 'tools', m.schemaPath);
100
+ const raw = readFileSync(absPath, 'utf8');
101
+ const parsed = JSON.parse(raw) as {
102
+ properties?: {
103
+ input?: { type?: string; properties?: Record<string, unknown> };
104
+ };
105
+ };
106
+ // The per-tool schema files are Draft-07 wrappers shaped as:
107
+ // { type: "object", properties: { input: {...}, output: {...} } }
108
+ // MCP's tools/list advertises only the INPUT half. We project
109
+ // `properties.input` here; when the schema is malformed we fall
110
+ // back to an open object so the tool is still listable.
111
+ const rawInput = parsed.properties?.input;
112
+ const inputSchema: Record<string, unknown> =
113
+ rawInput !== undefined && typeof rawInput === 'object'
114
+ ? (rawInput as Record<string, unknown>)
115
+ : { type: 'object' };
116
+ if (!('type' in inputSchema)) inputSchema['type'] = 'object';
117
+ return { ...m, inputSchema };
118
+ });
119
+ }
120
+
121
+ /**
122
+ * Tool descriptions — short, scannable, lifted from the plan. Skill
123
+ * prose uses these verbatim when suggesting a tool to the model.
124
+ *
125
+ * Plan 27.7-02 populates 12 entries — one per tool name in the canonical
126
+ * 12-tool list.
127
+ */
128
+ export const TOOL_DESCRIPTIONS: Record<string, string> = {
129
+ gdd_status:
130
+ 'gdd_status: current cycle phase, branch, last-3 decisions, last-3 completed plans, blocker count.',
131
+ gdd_phase_current:
132
+ 'gdd_phase_current: STATE.md <position> block (phase, stage, task_progress, status).',
133
+ gdd_phases_list:
134
+ 'gdd_phases_list: parsed ROADMAP.md overview (phase number, name, target version, shipped/planned).',
135
+ gdd_plans_list:
136
+ 'gdd_plans_list: plans tracked in STATE.md must_haves (optionally filtered by input.phase).',
137
+ gdd_decisions_list:
138
+ 'gdd_decisions_list: decisions from STATE.md (optionally filtered by input.status).',
139
+ gdd_intel_get:
140
+ 'gdd_intel_get: read a slice from .design/intel/ (input.slice_id required); directory_not_found if absent.',
141
+ gdd_telemetry_query:
142
+ 'gdd_telemetry_query: typed reader over .design/telemetry/*.jsonl with type/since/limit filters.',
143
+ gdd_cycle_recap:
144
+ 'gdd_cycle_recap: diff current STATE against latest .design/snapshots/ snapshot; directory_not_found if absent.',
145
+ gdd_reflections_latest:
146
+ 'gdd_reflections_latest: newest .design/reflections/ file (excerpt <= 4 KB); directory_not_found if absent.',
147
+ gdd_learnings_digest:
148
+ 'gdd_learnings_digest: aggregate last N reflections into a compact digest (<= 5 KB).',
149
+ gdd_events_tail:
150
+ 'gdd_events_tail: last-N events from .design/telemetry/events.jsonl with optional type filter.',
151
+ gdd_health:
152
+ 'gdd_health: read-only mirror of gdd-health SKILL — 4 checks (CLAUDE.md, .planning/, .design/, package.json).',
153
+ };
154
+
155
+ /** Human-readable annotation hints (MCP clients use these to style the
156
+ * tool in UI). `readOnlyHint: true` — tells clients this tool does NOT
157
+ * modify disk. v1 is read-only (D-04) so every entry is `true`. */
158
+ export const TOOL_READONLY: Record<string, boolean> = {
159
+ gdd_status: true,
160
+ gdd_phase_current: true,
161
+ gdd_phases_list: true,
162
+ gdd_plans_list: true,
163
+ gdd_decisions_list: true,
164
+ gdd_intel_get: true,
165
+ gdd_telemetry_query: true,
166
+ gdd_cycle_recap: true,
167
+ gdd_reflections_latest: true,
168
+ gdd_learnings_digest: true,
169
+ gdd_events_tail: true,
170
+ gdd_health: true,
171
+ };
172
+
173
+ /**
174
+ * Build the MCP server. The tools list and call handlers are the only
175
+ * two request handlers we register; everything else (initialize, ping,
176
+ * cancellation, shutdown) is handled internally by the Protocol class.
177
+ */
178
+ export function buildServer(): Server {
179
+ const tools = loadTools();
180
+ const byName: Map<string, LoadedTool> = new Map();
181
+ for (const t of tools) byName.set(t.name, t);
182
+
183
+ const server = new Server(
184
+ { name: SERVER_NAME, version: SERVER_VERSION },
185
+ {
186
+ capabilities: { tools: {} },
187
+ },
188
+ );
189
+
190
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
191
+ return {
192
+ tools: tools.map((t) => {
193
+ const description = TOOL_DESCRIPTIONS[t.name] ?? t.name;
194
+ const readOnly = TOOL_READONLY[t.name] ?? true;
195
+ return {
196
+ name: t.name,
197
+ description,
198
+ inputSchema: t.inputSchema as {
199
+ type: 'object';
200
+ properties?: Record<string, unknown>;
201
+ required?: string[];
202
+ },
203
+ annotations: {
204
+ readOnlyHint: readOnly,
205
+ destructiveHint: !readOnly,
206
+ idempotentHint: false,
207
+ },
208
+ };
209
+ }),
210
+ };
211
+ });
212
+
213
+ server.setRequestHandler(CallToolRequestSchema, async (req) => {
214
+ const { name: toolName, arguments: args } = req.params;
215
+ const tool = byName.get(toolName);
216
+ if (tool === undefined) {
217
+ // Unknown tool — return as CallToolResult isError=true so the
218
+ // client gets a structured error rather than a JSON-RPC error.
219
+ const payload = toToolError(
220
+ new Error(`unknown tool: ${toolName}`),
221
+ );
222
+ return {
223
+ isError: true,
224
+ content: [
225
+ {
226
+ type: 'text' as const,
227
+ text: JSON.stringify({ success: false, error: payload.error }),
228
+ },
229
+ ],
230
+ structuredContent: { success: false, error: payload.error },
231
+ };
232
+ }
233
+
234
+ let response;
235
+ try {
236
+ response = await tool.handle(args ?? {});
237
+ } catch (err) {
238
+ // Defensive catch — handlers shouldn't throw, but if one does
239
+ // we translate rather than crashing the server.
240
+ const payload = toToolError(err);
241
+ response = { success: false as const, error: payload.error };
242
+ }
243
+
244
+ const text = JSON.stringify(response);
245
+ if (response.success === true) {
246
+ return {
247
+ content: [{ type: 'text' as const, text }],
248
+ structuredContent: response as unknown as Record<string, unknown>,
249
+ };
250
+ }
251
+ return {
252
+ isError: true,
253
+ content: [{ type: 'text' as const, text }],
254
+ structuredContent: response as unknown as Record<string, unknown>,
255
+ };
256
+ });
257
+
258
+ return server;
259
+ }
260
+
261
+ /**
262
+ * Run the server against stdio and block until the transport closes.
263
+ * Called from CLI when this file is invoked as a script.
264
+ */
265
+ export async function runStdio(): Promise<void> {
266
+ const server = buildServer();
267
+ const transport = new StdioServerTransport();
268
+
269
+ const shutdown = async (signal: string): Promise<void> => {
270
+ // Re-entrant: signal handlers can fire more than once on flaky
271
+ // shells. Guard with a module-level flag.
272
+ if (SHUTTING_DOWN) return;
273
+ SHUTTING_DOWN = true;
274
+ try {
275
+ await server.close();
276
+ } catch {
277
+ // best-effort; we're exiting anyway.
278
+ }
279
+ // SIGTERM / SIGINT convention: exit(0) — orderly shutdown.
280
+ process.exit(signal === 'SIGTERM' ? 0 : 0);
281
+ };
282
+
283
+ process.on('SIGINT', () => {
284
+ void shutdown('SIGINT');
285
+ });
286
+ process.on('SIGTERM', () => {
287
+ void shutdown('SIGTERM');
288
+ });
289
+
290
+ await server.connect(transport);
291
+ }
292
+
293
+ /** Re-entrancy guard for `shutdown()`. */
294
+ let SHUTTING_DOWN = false;
295
+
296
+ /**
297
+ * Are we being invoked as a script? We compare the argv[1] file path's
298
+ * basename to `server.ts` — test imports never match this because
299
+ * `node --test tests/*.ts` sets argv[1] to the test runner entry, not
300
+ * our file. A direct `node scripts/mcp-servers/gdd-mcp/server.ts`
301
+ * invocation DOES match. The Windows-safe path normalization uses
302
+ * `.replace(/\\/g, '/')` before the endsWith check.
303
+ */
304
+ function isMain(): boolean {
305
+ const entry = process.argv[1];
306
+ if (typeof entry !== 'string' || entry.length === 0) return false;
307
+ return entry.replace(/\\/g, '/').endsWith('scripts/mcp-servers/gdd-mcp/server.ts');
308
+ }
309
+
310
+ if (isMain()) {
311
+ runStdio().catch((err) => {
312
+ const msg = err instanceof Error ? err.message : String(err);
313
+ // eslint-disable-next-line no-console
314
+ console.error(`[gdd-mcp] fatal: ${msg}`);
315
+ process.exit(1);
316
+ });
317
+ }
@@ -0,0 +1,37 @@
1
+ // scripts/mcp-servers/gdd-mcp/tools/gdd_cycle_recap.ts
2
+ //
3
+ // Plan 27.7-02. Diffs current STATE.md against the latest .design/snapshots/
4
+ // snapshot. SnapshotNotFoundError → directory_not_found via errorResponse.
5
+
6
+ import { read } from '../../../lib/gdd-state/index.ts';
7
+ import { readLatestSnapshot } from '../../../lib/snapshot-reader/index.cjs';
8
+ import { errorResponse, okResponse, resolveProjectRoot, resolveStatePath, type ToolResponse } from './shared.ts';
9
+
10
+ export const name = 'gdd_cycle_recap';
11
+ export const schemaPath = '../schemas/gdd_cycle_recap.schema.json';
12
+
13
+ function snapCount(snap: Record<string, unknown>, key: string, fallback: string): number {
14
+ if (typeof snap[key] === 'number') return snap[key] as number;
15
+ const arr = snap[fallback];
16
+ return Array.isArray(arr) ? arr.length : 0;
17
+ }
18
+
19
+ export async function handle(_input: unknown): Promise<ToolResponse> {
20
+ try {
21
+ const snap = await readLatestSnapshot(resolveProjectRoot());
22
+ const state = await read(resolveStatePath());
23
+ if (snap === null) return okResponse({ since: null, diff: { state_sections: [], decisions_delta: 0, completed_plans_delta: 0 } });
24
+ const decisionsNow = (state.decisions ?? []).length;
25
+ const completedNow = (state.must_haves ?? []).filter((m) => m.status === 'pass').length;
26
+ return okResponse({
27
+ since: snap.since,
28
+ diff: {
29
+ state_sections: Object.keys(state),
30
+ decisions_delta: decisionsNow - snapCount(snap.snapshot, 'decisions_count', 'last_n_decisions'),
31
+ completed_plans_delta: completedNow - snapCount(snap.snapshot, 'completed_plans_count', '_unused'),
32
+ },
33
+ });
34
+ } catch (err) {
35
+ return errorResponse(err);
36
+ }
37
+ }
@@ -0,0 +1,33 @@
1
+ // scripts/mcp-servers/gdd-mcp/tools/gdd_decisions_list.ts
2
+ //
3
+ // Plan 27.7-02. Reads <decisions> block from STATE.md. Optional
4
+ // input.status filter narrows the list to one DecisionStatus.
5
+
6
+ import { read } from '../../../lib/gdd-state/index.ts';
7
+ import {
8
+ errorResponse,
9
+ okResponse,
10
+ resolveStatePath,
11
+ type ToolResponse,
12
+ } from './shared.ts';
13
+
14
+ export const name = 'gdd_decisions_list';
15
+ export const schemaPath = '../schemas/gdd_decisions_list.schema.json';
16
+
17
+ interface DecisionsInput {
18
+ status?: string;
19
+ }
20
+
21
+ export async function handle(input: unknown): Promise<ToolResponse> {
22
+ try {
23
+ const typed = (input ?? {}) as DecisionsInput;
24
+ const state = await read(resolveStatePath());
25
+ let decisions = state.decisions ?? [];
26
+ if (typeof typed.status === 'string' && typed.status.length > 0) {
27
+ decisions = decisions.filter((d) => d.status === typed.status);
28
+ }
29
+ return okResponse({ decisions });
30
+ } catch (err) {
31
+ return errorResponse(err);
32
+ }
33
+ }
@@ -0,0 +1,26 @@
1
+ // scripts/mcp-servers/gdd-mcp/tools/gdd_events_tail.ts
2
+ //
3
+ // Plan 27.7-02. Last-N events from .design/telemetry/events.jsonl with
4
+ // optional type filter. Uses scripts/lib/event-stream readEvents.
5
+
6
+ import { readEvents } from '../../../lib/event-stream/index.ts';
7
+ import { errorResponse, okResponse, resolveTelemetryDir, type ToolResponse } from './shared.ts';
8
+
9
+ export const name = 'gdd_events_tail';
10
+ export const schemaPath = '../schemas/gdd_events_tail.schema.json';
11
+
12
+ interface TailInput { type?: string; limit?: number; }
13
+
14
+ export async function handle(input: unknown): Promise<ToolResponse> {
15
+ try {
16
+ const typed = (input ?? {}) as TailInput;
17
+ const limit = typeof typed.limit === 'number' && typed.limit > 0 ? typed.limit : 50;
18
+ const ring: unknown[] = [];
19
+ const opts: { path: string; type?: string } = { path: resolveTelemetryDir() + '/events.jsonl' };
20
+ if (typeof typed.type === 'string' && typed.type.length > 0) opts.type = typed.type;
21
+ for await (const ev of readEvents(opts)) { ring.push(ev); if (ring.length > limit) ring.shift(); }
22
+ return okResponse({ events: ring });
23
+ } catch (err) {
24
+ return errorResponse(err);
25
+ }
26
+ }
@@ -0,0 +1,19 @@
1
+ // scripts/mcp-servers/gdd-mcp/tools/gdd_health.ts
2
+ //
3
+ // Plan 27.7-02. Read-only mirror of skills/health/SKILL.md output via
4
+ // scripts/lib/gsd-health-mirror/. No subprocess spawn — pure inspection.
5
+
6
+ import { getHealthChecks } from '../../../lib/gsd-health-mirror/index.cjs';
7
+ import { errorResponse, okResponse, resolveProjectRoot, type ToolResponse } from './shared.ts';
8
+
9
+ export const name = 'gdd_health';
10
+ export const schemaPath = '../schemas/gdd_health.schema.json';
11
+
12
+ export async function handle(_input: unknown): Promise<ToolResponse> {
13
+ try {
14
+ const result = await getHealthChecks(resolveProjectRoot());
15
+ return okResponse({ checks: result.checks });
16
+ } catch (err) {
17
+ return errorResponse(err);
18
+ }
19
+ }
@@ -0,0 +1,32 @@
1
+ // scripts/mcp-servers/gdd-mcp/tools/gdd_intel_get.ts
2
+ //
3
+ // Plan 27.7-02. Reads a .design/intel/ slice via scripts/lib/intel-store/
4
+ // (Warning #7: NOT design-search.cjs). IntelNotFoundError surfaces
5
+ // gracefully via errorResponse's mcp_code projection (Warning #5).
6
+
7
+ import { readSlice } from '../../../lib/intel-store/index.cjs';
8
+ import { errorResponse, okResponse, resolveProjectRoot, type ToolResponse } from './shared.ts';
9
+
10
+ export const name = 'gdd_intel_get';
11
+ export const schemaPath = '../schemas/gdd_intel_get.schema.json';
12
+
13
+ interface IntelInput { slice_id: string; shape?: string[]; }
14
+
15
+ export async function handle(input: unknown): Promise<ToolResponse> {
16
+ try {
17
+ const typed = (input ?? {}) as IntelInput;
18
+ if (typeof typed.slice_id !== 'string' || typed.slice_id.length === 0) {
19
+ return errorResponse(new Error('slice_id is required'));
20
+ }
21
+ const data = await readSlice(resolveProjectRoot(), typed.slice_id);
22
+ if (data === null) return errorResponse(new Error('slice not found: ' + typed.slice_id));
23
+ if (Array.isArray(typed.shape) && typed.shape.length > 0 && typeof data === 'object' && data !== null) {
24
+ const projected: Record<string, unknown> = {};
25
+ for (const k of typed.shape) if (k in (data as Record<string, unknown>)) projected[k] = (data as Record<string, unknown>)[k];
26
+ return okResponse({ slice_id: typed.slice_id, data: projected });
27
+ }
28
+ return okResponse({ slice_id: typed.slice_id, data: data as Record<string, unknown> });
29
+ } catch (err) {
30
+ return errorResponse(err);
31
+ }
32
+ }
@@ -0,0 +1,23 @@
1
+ // scripts/mcp-servers/gdd-mcp/tools/gdd_learnings_digest.ts
2
+ //
3
+ // Plan 27.7-02. Aggregates last N reflections into a <= 5 KB digest
4
+ // via scripts/lib/reflections-reader/.
5
+
6
+ import { readNReflections, digestReflections } from '../../../lib/reflections-reader/index.cjs';
7
+ import { errorResponse, okResponse, resolveProjectRoot, type ToolResponse } from './shared.ts';
8
+
9
+ export const name = 'gdd_learnings_digest';
10
+ export const schemaPath = '../schemas/gdd_learnings_digest.schema.json';
11
+
12
+ interface DigestInput { cycles?: number; }
13
+
14
+ export async function handle(input: unknown): Promise<ToolResponse> {
15
+ try {
16
+ const typed = (input ?? {}) as DigestInput;
17
+ const n = typeof typed.cycles === 'number' && typed.cycles > 0 ? typed.cycles : 5;
18
+ const refls = await readNReflections(resolveProjectRoot(), n);
19
+ return okResponse({ digest: digestReflections(refls), cycles_included: refls.length });
20
+ } catch (err) {
21
+ return errorResponse(err);
22
+ }
23
+ }
@@ -0,0 +1,29 @@
1
+ // scripts/mcp-servers/gdd-mcp/tools/gdd_phase_current.ts
2
+ //
3
+ // Plan 27.7-02. Returns the <position> block from STATE.md.
4
+
5
+ import { read } from '../../../lib/gdd-state/index.ts';
6
+ import {
7
+ errorResponse,
8
+ okResponse,
9
+ resolveStatePath,
10
+ type ToolResponse,
11
+ } from './shared.ts';
12
+
13
+ export const name = 'gdd_phase_current';
14
+ export const schemaPath = '../schemas/gdd_phase_current.schema.json';
15
+
16
+ export async function handle(_input: unknown): Promise<ToolResponse> {
17
+ try {
18
+ const state = await read(resolveStatePath());
19
+ const p = state.position;
20
+ return okResponse({
21
+ phase: state.frontmatter.cycle ?? null,
22
+ stage: p?.stage ?? null,
23
+ task_progress: p?.task_progress ?? null,
24
+ status: p?.status ?? null,
25
+ });
26
+ } catch (err) {
27
+ return errorResponse(err);
28
+ }
29
+ }
@@ -0,0 +1,26 @@
1
+ // scripts/mcp-servers/gdd-mcp/tools/gdd_phases_list.ts
2
+ //
3
+ // Plan 27.7-02. Parses .planning/ROADMAP.md via scripts/lib/roadmap-reader.
4
+
5
+ import {
6
+ readRoadmapMd,
7
+ parsePhases,
8
+ } from '../../../lib/roadmap-reader/index.cjs';
9
+ import {
10
+ errorResponse,
11
+ okResponse,
12
+ resolveProjectRoot,
13
+ type ToolResponse,
14
+ } from './shared.ts';
15
+
16
+ export const name = 'gdd_phases_list';
17
+ export const schemaPath = '../schemas/gdd_phases_list.schema.json';
18
+
19
+ export async function handle(_input: unknown): Promise<ToolResponse> {
20
+ try {
21
+ const md = await readRoadmapMd(resolveProjectRoot());
22
+ return okResponse({ phases: parsePhases(md) });
23
+ } catch (err) {
24
+ return errorResponse(err);
25
+ }
26
+ }
@@ -0,0 +1,39 @@
1
+ // scripts/mcp-servers/gdd-mcp/tools/gdd_plans_list.ts
2
+ //
3
+ // Plan 27.7-02. STATE.md does not have a dedicated <plans> block — we
4
+ // surface must_haves as the closest analog (the per-plan acceptance
5
+ // criteria the pipeline tracks). Input.phase is reserved for future
6
+ // multi-phase indexing.
7
+
8
+ import { read } from '../../../lib/gdd-state/index.ts';
9
+ import {
10
+ errorResponse,
11
+ okResponse,
12
+ resolveStatePath,
13
+ type ToolResponse,
14
+ } from './shared.ts';
15
+
16
+ export const name = 'gdd_plans_list';
17
+ export const schemaPath = '../schemas/gdd_plans_list.schema.json';
18
+
19
+ interface PlansInput {
20
+ phase?: string;
21
+ }
22
+
23
+ export async function handle(input: unknown): Promise<ToolResponse> {
24
+ try {
25
+ const typed = (input ?? {}) as PlansInput;
26
+ const state = await read(resolveStatePath());
27
+ const plans = (state.must_haves ?? []).map((m) => ({
28
+ id: m.id,
29
+ name: m.text,
30
+ status: m.status,
31
+ }));
32
+ return okResponse({
33
+ phase: typed.phase ?? state.frontmatter.cycle ?? null,
34
+ plans,
35
+ });
36
+ } catch (err) {
37
+ return errorResponse(err);
38
+ }
39
+ }
@@ -0,0 +1,25 @@
1
+ // scripts/mcp-servers/gdd-mcp/tools/gdd_reflections_latest.ts
2
+ //
3
+ // Plan 27.7-02. Reads newest reflection under .design/reflections/.
4
+ // ReflectionsNotFoundError surfaces as mcp_code='directory_not_found'
5
+ // via errorResponse (Warning #5).
6
+
7
+ import { readLatestReflection } from '../../../lib/reflections-reader/index.cjs';
8
+ import { errorResponse, okResponse, resolveProjectRoot, type ToolResponse } from './shared.ts';
9
+
10
+ export const name = 'gdd_reflections_latest';
11
+ export const schemaPath = '../schemas/gdd_reflections_latest.schema.json';
12
+
13
+ export async function handle(_input: unknown): Promise<ToolResponse> {
14
+ try {
15
+ const r = await readLatestReflection(resolveProjectRoot());
16
+ if (r === null) return okResponse({ cycle: null, path: null, content_excerpt: '' });
17
+ return okResponse({
18
+ cycle: r.cycle,
19
+ path: r.path,
20
+ content_excerpt: r.content.slice(0, 4096),
21
+ });
22
+ } catch (err) {
23
+ return errorResponse(err);
24
+ }
25
+ }