@hegemonart/get-design-done 1.30.6 → 1.31.5
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/.claude-plugin/marketplace.json +6 -3
- package/.claude-plugin/plugin.json +5 -2
- package/CHANGELOG.md +105 -0
- package/NOTICE +224 -0
- package/README.md +22 -1
- package/SKILL.md +1 -0
- package/agents/design-authority-watcher.md +1 -1
- package/agents/perf-analyzer.md +2 -2
- package/bin/gdd-mcp +78 -0
- package/bin/gdd-sdk +34 -24
- package/bin/gdd-state-mcp +78 -0
- package/{README.de.md → docs/i18n/README.de.md} +1 -1
- package/{README.fr.md → docs/i18n/README.fr.md} +1 -1
- package/{README.it.md → docs/i18n/README.it.md} +1 -1
- package/{README.ja.md → docs/i18n/README.ja.md} +1 -1
- package/{README.ko.md → docs/i18n/README.ko.md} +1 -1
- package/{README.zh-CN.md → docs/i18n/README.zh-CN.md} +1 -1
- package/hooks/_hook-emit.js +1 -1
- package/hooks/budget-enforcer.ts +5 -5
- package/hooks/context-exhaustion.ts +2 -2
- package/hooks/gdd-precompact-snapshot.js +3 -3
- package/hooks/gdd-read-injection-scanner.ts +2 -2
- package/hooks/gdd-sessionstart-recap.js +1 -1
- package/hooks/gdd-turn-closeout.js +1 -1
- package/package.json +24 -10
- package/recipes/.gitkeep +0 -0
- package/reference/schemas/recipe.schema.json +33 -0
- package/scripts/cli/gdd-events.mjs +5 -5
- package/scripts/lib/cache/gdd-cache-manager.cjs +1 -1
- package/scripts/lib/cli/index.ts +22 -160
- package/scripts/lib/connection-probe/index.cjs +1 -1
- package/scripts/lib/discuss-parallel-runner/aggregator.ts +1 -1
- package/scripts/lib/discuss-parallel-runner/index.ts +1 -1
- package/scripts/lib/error-classifier.cjs +24 -227
- package/scripts/lib/event-stream/index.ts +25 -193
- package/scripts/lib/figma-extract/digest.cjs +430 -0
- package/scripts/lib/figma-extract/parse-url.cjs +87 -0
- package/scripts/lib/figma-extract/payload-schema.json +108 -0
- package/scripts/lib/figma-extract/pull.cjs +394 -0
- package/scripts/lib/figma-extract/receiver.cjs +273 -0
- package/scripts/lib/figma-extract/render-md.cjs +143 -0
- package/scripts/lib/figma-extract/styles-resolver.cjs +147 -0
- package/scripts/lib/figma-extract/walk.cjs +100 -0
- package/scripts/lib/gdd-errors/index.ts +24 -213
- package/scripts/lib/gdd-state/index.ts +23 -161
- package/scripts/lib/health-mirror/index.cjs +88 -1
- package/scripts/lib/iteration-budget.cjs +23 -199
- package/scripts/lib/jittered-backoff.cjs +24 -107
- package/scripts/lib/lockfile.cjs +23 -195
- package/scripts/lib/logger/index.ts +1 -1
- package/scripts/lib/parallelism-engine/concurrency-tuner.cjs +1 -1
- package/scripts/lib/perf-analyzer/index.cjs +1 -1
- package/scripts/lib/pipeline-runner/index.ts +4 -4
- package/scripts/lib/pipeline-runner/state-machine.ts +1 -1
- package/scripts/lib/prompt-dedup/index.cjs +1 -1
- package/scripts/lib/rate-guard.cjs +2 -2
- package/scripts/lib/recipe-loader.cjs +142 -0
- package/scripts/lib/session-runner/errors.ts +3 -3
- package/scripts/lib/session-runner/index.ts +3 -3
- package/scripts/lib/session-runner/transcript.ts +1 -1
- package/scripts/lib/tool-scoping/index.ts +1 -1
- package/scripts/mcp-servers/gdd-mcp/server.ts +29 -311
- package/scripts/mcp-servers/gdd-state/server.ts +28 -282
- package/sdk/README.md +45 -0
- package/{scripts/lib → sdk}/cli/commands/audit.ts +3 -3
- package/{scripts/lib → sdk}/cli/commands/init.ts +3 -3
- package/{scripts/lib → sdk}/cli/commands/query.ts +4 -4
- package/{scripts/lib → sdk}/cli/commands/run.ts +5 -5
- package/{scripts/lib → sdk}/cli/commands/stage.ts +5 -5
- package/sdk/cli/index.js +8091 -0
- package/sdk/cli/index.ts +172 -0
- package/{scripts/lib → sdk}/cli/parse-args.ts +2 -2
- package/{scripts/lib/gdd-errors → sdk/errors}/classification.ts +1 -1
- package/sdk/errors/index.ts +218 -0
- package/{scripts/lib → sdk}/event-stream/emitter.ts +1 -1
- package/sdk/event-stream/index.ts +197 -0
- package/{scripts/lib → sdk}/event-stream/reader.ts +1 -1
- package/{scripts/lib → sdk}/event-stream/types.ts +2 -2
- package/{scripts/lib → sdk}/event-stream/writer.ts +1 -1
- package/sdk/index.ts +19 -0
- package/{scripts/mcp-servers → sdk/mcp}/gdd-mcp/README.md +3 -3
- package/sdk/mcp/gdd-mcp/server.js +1924 -0
- package/sdk/mcp/gdd-mcp/server.ts +325 -0
- package/{scripts/mcp-servers → sdk/mcp}/gdd-mcp/tools/gdd_cycle_recap.ts +3 -3
- package/{scripts/mcp-servers → sdk/mcp}/gdd-mcp/tools/gdd_decisions_list.ts +2 -2
- package/{scripts/mcp-servers → sdk/mcp}/gdd-mcp/tools/gdd_events_tail.ts +3 -3
- package/{scripts/mcp-servers → sdk/mcp}/gdd-mcp/tools/gdd_health.ts +2 -2
- package/{scripts/mcp-servers → sdk/mcp}/gdd-mcp/tools/gdd_intel_get.ts +2 -2
- package/{scripts/mcp-servers → sdk/mcp}/gdd-mcp/tools/gdd_learnings_digest.ts +2 -2
- package/{scripts/mcp-servers → sdk/mcp}/gdd-mcp/tools/gdd_phase_current.ts +2 -2
- package/{scripts/mcp-servers → sdk/mcp}/gdd-mcp/tools/gdd_phases_list.ts +2 -2
- package/{scripts/mcp-servers → sdk/mcp}/gdd-mcp/tools/gdd_plans_list.ts +2 -2
- package/{scripts/mcp-servers → sdk/mcp}/gdd-mcp/tools/gdd_reflections_latest.ts +2 -2
- package/{scripts/mcp-servers → sdk/mcp}/gdd-mcp/tools/gdd_status.ts +3 -3
- package/{scripts/mcp-servers → sdk/mcp}/gdd-mcp/tools/gdd_telemetry_query.ts +3 -3
- package/{scripts/mcp-servers → sdk/mcp}/gdd-mcp/tools/index.ts +2 -2
- package/{scripts/mcp-servers → sdk/mcp}/gdd-mcp/tools/shared.ts +3 -3
- package/sdk/mcp/gdd-state/server.js +2790 -0
- package/sdk/mcp/gdd-state/server.ts +294 -0
- package/{scripts/mcp-servers → sdk/mcp}/gdd-state/tools/add_blocker.ts +3 -3
- package/{scripts/mcp-servers → sdk/mcp}/gdd-state/tools/add_decision.ts +3 -3
- package/{scripts/mcp-servers → sdk/mcp}/gdd-state/tools/add_must_have.ts +3 -3
- package/{scripts/mcp-servers → sdk/mcp}/gdd-state/tools/checkpoint.ts +2 -2
- package/{scripts/mcp-servers → sdk/mcp}/gdd-state/tools/frontmatter_update.ts +2 -2
- package/{scripts/mcp-servers → sdk/mcp}/gdd-state/tools/get.ts +3 -3
- package/{scripts/mcp-servers → sdk/mcp}/gdd-state/tools/index.ts +1 -1
- package/{scripts/mcp-servers → sdk/mcp}/gdd-state/tools/probe_connections.ts +3 -3
- package/{scripts/mcp-servers → sdk/mcp}/gdd-state/tools/resolve_blocker.ts +3 -3
- package/{scripts/mcp-servers → sdk/mcp}/gdd-state/tools/set_status.ts +2 -2
- package/{scripts/mcp-servers → sdk/mcp}/gdd-state/tools/shared.ts +8 -8
- package/{scripts/mcp-servers → sdk/mcp}/gdd-state/tools/transition_stage.ts +4 -4
- package/{scripts/mcp-servers → sdk/mcp}/gdd-state/tools/update_progress.ts +2 -2
- package/sdk/primitives/error-classifier.cjs +232 -0
- package/sdk/primitives/iteration-budget.cjs +205 -0
- package/sdk/primitives/jittered-backoff.cjs +112 -0
- package/sdk/primitives/lockfile.cjs +201 -0
- package/{scripts/lib/gdd-state → sdk/state}/gates.ts +1 -1
- package/sdk/state/index.ts +167 -0
- package/{scripts/lib/gdd-state → sdk/state}/lockfile.ts +1 -1
- package/{scripts/lib/gdd-state → sdk/state}/mutator.ts +1 -1
- package/{scripts/lib/gdd-state → sdk/state}/parser.ts +1 -1
- package/{scripts/lib/gdd-state → sdk/state}/types.ts +4 -4
- package/skills/figma-extract/SKILL.md +64 -0
- package/skills/health/SKILL.md +10 -0
- package/skills/quality-gate/SKILL.md +2 -2
- package/scripts/aggregate-agent-metrics.ts +0 -282
- package/scripts/bootstrap-manifest.txt +0 -3
- package/scripts/bootstrap.sh +0 -80
- package/scripts/build-distribution-bundles.cjs +0 -549
- package/scripts/build-intel.cjs +0 -486
- package/scripts/codegen-schema-types.ts +0 -149
- package/scripts/detect-stale-refs.cjs +0 -107
- package/scripts/e2e/run-headless.ts +0 -514
- package/scripts/extract-changelog-section.cjs +0 -58
- package/scripts/gsd-cleanup-incubator.cjs +0 -367
- package/scripts/injection-patterns.cjs +0 -58
- package/scripts/lint-agentskills-spec.cjs +0 -457
- package/scripts/release-smoke-test.cjs +0 -200
- package/scripts/rollback-release.sh +0 -42
- package/scripts/run-injection-scanner-ci.cjs +0 -83
- package/scripts/tests/test-authority-rejected-kinds.sh +0 -58
- package/scripts/tests/test-authority-watcher-diff.sh +0 -113
- package/scripts/tests/test-motion-provenance.sh +0 -64
- package/scripts/validate-frontmatter.ts +0 -409
- package/scripts/validate-incubator-scope.cjs +0 -133
- package/scripts/validate-schemas.ts +0 -401
- package/scripts/validate-skill-length.cjs +0 -283
- package/scripts/verify-version-sync.cjs +0 -30
- /package/{scripts/mcp-servers → sdk/mcp}/gdd-mcp/schemas/gdd_cycle_recap.schema.json +0 -0
- /package/{scripts/mcp-servers → sdk/mcp}/gdd-mcp/schemas/gdd_decisions_list.schema.json +0 -0
- /package/{scripts/mcp-servers → sdk/mcp}/gdd-mcp/schemas/gdd_events_tail.schema.json +0 -0
- /package/{scripts/mcp-servers → sdk/mcp}/gdd-mcp/schemas/gdd_health.schema.json +0 -0
- /package/{scripts/mcp-servers → sdk/mcp}/gdd-mcp/schemas/gdd_intel_get.schema.json +0 -0
- /package/{scripts/mcp-servers → sdk/mcp}/gdd-mcp/schemas/gdd_learnings_digest.schema.json +0 -0
- /package/{scripts/mcp-servers → sdk/mcp}/gdd-mcp/schemas/gdd_phase_current.schema.json +0 -0
- /package/{scripts/mcp-servers → sdk/mcp}/gdd-mcp/schemas/gdd_phases_list.schema.json +0 -0
- /package/{scripts/mcp-servers → sdk/mcp}/gdd-mcp/schemas/gdd_plans_list.schema.json +0 -0
- /package/{scripts/mcp-servers → sdk/mcp}/gdd-mcp/schemas/gdd_reflections_latest.schema.json +0 -0
- /package/{scripts/mcp-servers → sdk/mcp}/gdd-mcp/schemas/gdd_status.schema.json +0 -0
- /package/{scripts/mcp-servers → sdk/mcp}/gdd-mcp/schemas/gdd_telemetry_query.schema.json +0 -0
- /package/{scripts/mcp-servers → sdk/mcp}/gdd-state/schemas/add_blocker.schema.json +0 -0
- /package/{scripts/mcp-servers → sdk/mcp}/gdd-state/schemas/add_decision.schema.json +0 -0
- /package/{scripts/mcp-servers → sdk/mcp}/gdd-state/schemas/add_must_have.schema.json +0 -0
- /package/{scripts/mcp-servers → sdk/mcp}/gdd-state/schemas/checkpoint.schema.json +0 -0
- /package/{scripts/mcp-servers → sdk/mcp}/gdd-state/schemas/frontmatter_update.schema.json +0 -0
- /package/{scripts/mcp-servers → sdk/mcp}/gdd-state/schemas/get.schema.json +0 -0
- /package/{scripts/mcp-servers → sdk/mcp}/gdd-state/schemas/probe_connections.schema.json +0 -0
- /package/{scripts/mcp-servers → sdk/mcp}/gdd-state/schemas/resolve_blocker.schema.json +0 -0
- /package/{scripts/mcp-servers → sdk/mcp}/gdd-state/schemas/set_status.schema.json +0 -0
- /package/{scripts/mcp-servers → sdk/mcp}/gdd-state/schemas/transition_stage.schema.json +0 -0
- /package/{scripts/mcp-servers → sdk/mcp}/gdd-state/schemas/update_progress.schema.json +0 -0
- /package/{scripts/lib → sdk/primitives}/error-classifier.d.cts +0 -0
- /package/{scripts/lib → sdk/primitives}/iteration-budget.d.cts +0 -0
- /package/{scripts/lib → sdk/primitives}/jittered-backoff.d.cts +0 -0
- /package/{scripts/lib → sdk/primitives}/lockfile.d.cts +0 -0
|
@@ -1,288 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
// scripts/mcp-servers/gdd-state/server.ts
|
|
1
|
+
// scripts/mcp-servers/gdd-state/server.ts — GDD-DEPRECATION-SHIM (Plan 31-5-06, SDK-05, D-02).
|
|
3
2
|
//
|
|
4
|
-
// MCP
|
|
5
|
-
//
|
|
3
|
+
// Thin deprecation shim. The real MCP `gdd-state` server moved to
|
|
4
|
+
// sdk/mcp/gdd-state/server.ts in Plan 31-5-04 (SDK consolidation). This file
|
|
5
|
+
// is re-created at the OLD path so undocumented EXTERNAL importers / invokers
|
|
6
|
+
// (anyone who reached into node_modules/@hegemonart/get-design-done/scripts/
|
|
7
|
+
// mcp-servers/gdd-state/server.ts directly) keep working for one minor grace
|
|
8
|
+
// window.
|
|
6
9
|
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
// 3. Register `tools/call` — dispatches by name to the matching
|
|
14
|
-
// handler. Each handler returns a typed ToolResponse; the server
|
|
15
|
-
// wraps it into the MCP CallToolResult shape (one text content
|
|
16
|
-
// item, JSON-stringified response; plus `structuredContent` for
|
|
17
|
-
// richer clients; `isError: true` when `success:false`).
|
|
18
|
-
// 4. Attach StdioServerTransport; await connect.
|
|
19
|
-
// 5. On SIGINT / SIGTERM: close the transport, flush nothing (the
|
|
20
|
-
// event writer uses `appendFileSync` so every write is already
|
|
21
|
-
// durable), and exit 0.
|
|
10
|
+
// REMOVED IN v1.33.0 (D-02). Grace window: 1.31.5 ships with shims →
|
|
11
|
+
// 1.32.0 still has them → 1.33.0 removes them. The canonical invocation is
|
|
12
|
+
// now the `bin/gdd-state-mcp` trampoline (Plan 31-5-05); internal callers
|
|
13
|
+
// already use the sdk/ path. This shim is external-only; 31-5-10's
|
|
14
|
+
// no-stale-internal-refs guard excludes files carrying the
|
|
15
|
+
// GDD-DEPRECATION-SHIM marker above.
|
|
22
16
|
//
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
import { toToolError } from '../../lib/gdd-errors/classification.ts';
|
|
38
|
-
import { TOOL_MODULES, type ToolModule } from './tools/index.ts';
|
|
39
|
-
|
|
40
|
-
/** Server metadata advertised on initialize. */
|
|
41
|
-
const SERVER_NAME = 'gdd-state';
|
|
42
|
-
const SERVER_VERSION = '1.20.0';
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Resolve this module's directory. We deliberately avoid `import.meta.url`
|
|
46
|
-
* (not permitted by our tsconfig's Node16+CommonJS-compatible module
|
|
47
|
-
* resolution) and `__dirname` (not portable under strip-types ESM).
|
|
48
|
-
*
|
|
49
|
-
* Strategy: when this module is invoked as a script, `process.argv[1]`
|
|
50
|
-
* points at this file; resolve its dirname. When it is imported for
|
|
51
|
-
* tests, we fall back to walking from `process.cwd()` — tests run
|
|
52
|
-
* from the repo root by convention, so `scripts/mcp-servers/gdd-state`
|
|
53
|
-
* resolves reliably. Both branches are canonicalized against the
|
|
54
|
-
* on-disk tools directory.
|
|
55
|
-
*/
|
|
56
|
-
function here(): string {
|
|
57
|
-
const expectedRel = join('scripts', 'mcp-servers', 'gdd-state');
|
|
58
|
-
// Script invocation: process.argv[1] === .../server.ts (or a shim).
|
|
59
|
-
const entry = process.argv[1];
|
|
60
|
-
if (typeof entry === 'string' && entry.length > 0) {
|
|
61
|
-
const entryDir = dirname(resolve(entry));
|
|
62
|
-
if (existsSync(join(entryDir, 'tools', 'index.ts'))) {
|
|
63
|
-
return entryDir;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
// Library-import path (tests): walk cwd forward.
|
|
67
|
-
const candidate = resolve(process.cwd(), expectedRel);
|
|
68
|
-
if (existsSync(join(candidate, 'tools', 'index.ts'))) {
|
|
69
|
-
return candidate;
|
|
70
|
-
}
|
|
71
|
-
// Last-resort: return the expected path even if it does not exist —
|
|
72
|
-
// the subsequent readFileSync() call will produce a clear error.
|
|
73
|
-
return candidate;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/** Eager cache of input schemas keyed by tool name. We load them once at
|
|
77
|
-
* startup so a tool-call handler never hits the filesystem in the hot
|
|
78
|
-
* path; subsequent schema edits (JSON file on disk) require a server
|
|
79
|
-
* restart, which matches every other part of the pipeline. */
|
|
80
|
-
interface LoadedTool extends ToolModule {
|
|
81
|
-
inputSchema: Record<string, unknown>;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function loadTools(): LoadedTool[] {
|
|
85
|
-
const baseDir = here();
|
|
86
|
-
return TOOL_MODULES.map((m) => {
|
|
87
|
-
const absPath = join(baseDir, 'tools', m.schemaPath);
|
|
88
|
-
const raw = readFileSync(absPath, 'utf8');
|
|
89
|
-
const parsed = JSON.parse(raw) as {
|
|
90
|
-
properties?: {
|
|
91
|
-
input?: { type?: string; properties?: Record<string, unknown> };
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
// The per-tool schema files are Draft-07 wrappers shaped as:
|
|
95
|
-
// { type: "object", properties: { input: {...}, output: {...} } }
|
|
96
|
-
// MCP's tools/list advertises only the INPUT half. We project
|
|
97
|
-
// `properties.input` here; when the schema is malformed we fall
|
|
98
|
-
// back to an open object so the tool is still listable.
|
|
99
|
-
const rawInput = parsed.properties?.input;
|
|
100
|
-
const inputSchema: Record<string, unknown> =
|
|
101
|
-
rawInput !== undefined && typeof rawInput === 'object'
|
|
102
|
-
? (rawInput as Record<string, unknown>)
|
|
103
|
-
: { type: 'object' };
|
|
104
|
-
// MCP clients require inputSchema.type === "object" for tools/list.
|
|
105
|
-
// Our per-tool inputs are already objects; defensively stamp the
|
|
106
|
-
// field when absent.
|
|
107
|
-
if (!('type' in inputSchema)) inputSchema['type'] = 'object';
|
|
108
|
-
return { ...m, inputSchema };
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Tool descriptions — short, scannable, lifted from the plan. Skill
|
|
114
|
-
* prose uses these verbatim when suggesting a tool to the model.
|
|
115
|
-
*/
|
|
116
|
-
const TOOL_DESCRIPTIONS: Record<string, string> = {
|
|
117
|
-
gdd_state__get:
|
|
118
|
-
'Read current STATE.md (parsed). Read-only; no event emitted. Optionally projects a subset of fields.',
|
|
119
|
-
gdd_state__update_progress:
|
|
120
|
-
'Update <position>.task_progress and/or status. Emits state.mutation.',
|
|
121
|
-
gdd_state__transition_stage:
|
|
122
|
-
'Run gate and advance <position>.stage on pass. Gate vetoes return {success:false, error:{context:{blockers:[...]}}}; never crashes the server. Emits state.transition.',
|
|
123
|
-
gdd_state__add_blocker:
|
|
124
|
-
'Append one entry to <blockers>. Defaults stage to current position.stage and date to today (UTC). Emits state.mutation.',
|
|
125
|
-
gdd_state__resolve_blocker:
|
|
126
|
-
'Remove one <blockers> entry by 0-based index or exact text match. Returns operation_failed when no row matches. Emits state.mutation on removal.',
|
|
127
|
-
gdd_state__add_decision:
|
|
128
|
-
'Append one entry to <decisions>. Auto-allocates D-N id when not supplied. Emits state.mutation.',
|
|
129
|
-
gdd_state__add_must_have:
|
|
130
|
-
'Append one entry to <must_haves>. Auto-allocates M-N id when not supplied. Emits state.mutation.',
|
|
131
|
-
gdd_state__set_status:
|
|
132
|
-
'Update <position>.status. Emits state.mutation.',
|
|
133
|
-
gdd_state__checkpoint:
|
|
134
|
-
'Update frontmatter.last_checkpoint and append a <timestamps> entry. Emits state.mutation.',
|
|
135
|
-
gdd_state__probe_connections:
|
|
136
|
-
'Merge probe results into <connections>. Overwrites keys present in the input; does NOT delete keys not in the input. Emits state.mutation.',
|
|
137
|
-
gdd_state__frontmatter_update:
|
|
138
|
-
'Patch one or more frontmatter fields. Rejects pipeline_state_version and stage (use transition_stage). Emits state.mutation.',
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
/** Human-readable annotation hints (MCP clients use these to style the
|
|
142
|
-
* tool in UI). `readOnlyHint: true` — tells clients this tool does NOT
|
|
143
|
-
* modify disk; `false` — tells them it does. */
|
|
144
|
-
const TOOL_READONLY: Record<string, boolean> = {
|
|
145
|
-
gdd_state__get: true,
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Build the MCP server. The tools list and call handlers are the only
|
|
150
|
-
* two request handlers we register; everything else (initialize, ping,
|
|
151
|
-
* cancellation, shutdown) is handled internally by the Protocol class.
|
|
152
|
-
*/
|
|
153
|
-
export function buildServer(): Server {
|
|
154
|
-
const tools = loadTools();
|
|
155
|
-
const byName: Map<string, LoadedTool> = new Map();
|
|
156
|
-
for (const t of tools) byName.set(t.name, t);
|
|
157
|
-
|
|
158
|
-
const server = new Server(
|
|
159
|
-
{ name: SERVER_NAME, version: SERVER_VERSION },
|
|
160
|
-
{
|
|
161
|
-
capabilities: { tools: {} },
|
|
162
|
-
},
|
|
17
|
+
// Re-exporting the sdk/ server keeps the library surface (buildServer,
|
|
18
|
+
// runStdio) reachable via the old path. The sdk/ server's own isMain()
|
|
19
|
+
// entry guard keys off process.argv[1] ending with its own sdk/ path, so a
|
|
20
|
+
// re-export does NOT auto-start the server — direct execution should go
|
|
21
|
+
// through the bin trampoline. Runs under --experimental-strip-types.
|
|
22
|
+
|
|
23
|
+
import { emitWarning } from 'node:process';
|
|
24
|
+
|
|
25
|
+
let warned = false;
|
|
26
|
+
if (!warned) {
|
|
27
|
+
warned = true;
|
|
28
|
+
emitWarning(
|
|
29
|
+
'scripts/mcp-servers/gdd-state/server.ts is deprecated; use the bin/gdd-state-mcp trampoline or import sdk/mcp/gdd-state instead. Removed in v1.33.0.',
|
|
30
|
+
'DeprecationWarning',
|
|
163
31
|
);
|
|
164
|
-
|
|
165
|
-
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
166
|
-
return {
|
|
167
|
-
tools: tools.map((t) => {
|
|
168
|
-
const description = TOOL_DESCRIPTIONS[t.name] ?? t.name;
|
|
169
|
-
const readOnly = TOOL_READONLY[t.name] ?? false;
|
|
170
|
-
return {
|
|
171
|
-
name: t.name,
|
|
172
|
-
description,
|
|
173
|
-
inputSchema: t.inputSchema as {
|
|
174
|
-
type: 'object';
|
|
175
|
-
properties?: Record<string, unknown>;
|
|
176
|
-
required?: string[];
|
|
177
|
-
},
|
|
178
|
-
annotations: {
|
|
179
|
-
readOnlyHint: readOnly,
|
|
180
|
-
destructiveHint: !readOnly,
|
|
181
|
-
idempotentHint: false,
|
|
182
|
-
},
|
|
183
|
-
};
|
|
184
|
-
}),
|
|
185
|
-
};
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
server.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
189
|
-
const { name: toolName, arguments: args } = req.params;
|
|
190
|
-
const tool = byName.get(toolName);
|
|
191
|
-
if (tool === undefined) {
|
|
192
|
-
// Unknown tool — return as CallToolResult isError=true so the
|
|
193
|
-
// client gets a structured error rather than a JSON-RPC error.
|
|
194
|
-
const payload = toToolError(
|
|
195
|
-
new Error(`unknown tool: ${toolName}`),
|
|
196
|
-
);
|
|
197
|
-
return {
|
|
198
|
-
isError: true,
|
|
199
|
-
content: [
|
|
200
|
-
{ type: 'text' as const, text: JSON.stringify({ success: false, error: payload.error }) },
|
|
201
|
-
],
|
|
202
|
-
structuredContent: { success: false, error: payload.error },
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
let response;
|
|
207
|
-
try {
|
|
208
|
-
response = await tool.handle(args ?? {});
|
|
209
|
-
} catch (err) {
|
|
210
|
-
// Defensive catch — handlers shouldn't throw, but if one does
|
|
211
|
-
// we translate rather than crashing the server.
|
|
212
|
-
const payload = toToolError(err);
|
|
213
|
-
response = { success: false as const, error: payload.error };
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const text = JSON.stringify(response);
|
|
217
|
-
if (response.success === true) {
|
|
218
|
-
return {
|
|
219
|
-
content: [{ type: 'text' as const, text }],
|
|
220
|
-
structuredContent: response as unknown as Record<string, unknown>,
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
return {
|
|
224
|
-
isError: true,
|
|
225
|
-
content: [{ type: 'text' as const, text }],
|
|
226
|
-
structuredContent: response as unknown as Record<string, unknown>,
|
|
227
|
-
};
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
return server;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Run the server against stdio and block until the transport closes.
|
|
235
|
-
* Called from CLI when this file is invoked as a script.
|
|
236
|
-
*/
|
|
237
|
-
export async function runStdio(): Promise<void> {
|
|
238
|
-
const server = buildServer();
|
|
239
|
-
const transport = new StdioServerTransport();
|
|
240
|
-
|
|
241
|
-
const shutdown = async (signal: string): Promise<void> => {
|
|
242
|
-
// Re-entrant: signal handlers can fire more than once on flaky
|
|
243
|
-
// shells. Guard with a module-level flag.
|
|
244
|
-
if (SHUTTING_DOWN) return;
|
|
245
|
-
SHUTTING_DOWN = true;
|
|
246
|
-
try {
|
|
247
|
-
await server.close();
|
|
248
|
-
} catch {
|
|
249
|
-
// best-effort; we're exiting anyway.
|
|
250
|
-
}
|
|
251
|
-
// SIGTERM / SIGINT convention: exit(0) — orderly shutdown.
|
|
252
|
-
process.exit(signal === 'SIGTERM' ? 0 : 0);
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
process.on('SIGINT', () => {
|
|
256
|
-
void shutdown('SIGINT');
|
|
257
|
-
});
|
|
258
|
-
process.on('SIGTERM', () => {
|
|
259
|
-
void shutdown('SIGTERM');
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
await server.connect(transport);
|
|
263
32
|
}
|
|
264
33
|
|
|
265
|
-
|
|
266
|
-
let SHUTTING_DOWN = false;
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Are we being invoked as a script? We compare the argv[1] file path's
|
|
270
|
-
* basename to `server.ts` — test imports never match this because
|
|
271
|
-
* `node --test tests/*.ts` sets argv[1] to the test runner entry, not
|
|
272
|
-
* our file. A direct `node scripts/mcp-servers/gdd-state/server.ts`
|
|
273
|
-
* invocation DOES match.
|
|
274
|
-
*/
|
|
275
|
-
function isMain(): boolean {
|
|
276
|
-
const entry = process.argv[1];
|
|
277
|
-
if (typeof entry !== 'string' || entry.length === 0) return false;
|
|
278
|
-
return entry.replace(/\\/g, '/').endsWith('scripts/mcp-servers/gdd-state/server.ts');
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
if (isMain()) {
|
|
282
|
-
runStdio().catch((err) => {
|
|
283
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
284
|
-
// eslint-disable-next-line no-console
|
|
285
|
-
console.error(`[gdd-state] fatal: ${msg}`);
|
|
286
|
-
process.exit(1);
|
|
287
|
-
});
|
|
288
|
-
}
|
|
34
|
+
export * from '../../../sdk/mcp/gdd-state/server.ts';
|
package/sdk/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# `@hegemonart/get-design-done` SDK
|
|
2
|
+
|
|
3
|
+
The SDK is the typed, runtime-tested core that the GDD pipeline and both MCP
|
|
4
|
+
servers are built on. It is plain TypeScript run under Node 22+
|
|
5
|
+
`--experimental-strip-types` (no build step). Five concerns live here: the
|
|
6
|
+
**`gdd-state` MCP server** (11 typed STATE.md tools over stdio), **lockfile-safe
|
|
7
|
+
STATE.md** read / mutate / transition, the **append-only event stream** (JSONL +
|
|
8
|
+
in-process bus), the four **resilience primitives** (`.cjs` + `.d.cts`), and the
|
|
9
|
+
headless **`gdd-sdk` CLI**.
|
|
10
|
+
|
|
11
|
+
## Import contract (D-04)
|
|
12
|
+
|
|
13
|
+
Prefer the **explicit per-module path** for the surface you need. The
|
|
14
|
+
`sdk/index.ts` barrel re-exports state / event-stream / errors / cli for callers
|
|
15
|
+
who want one entry point; the bare-package root import is reserved for the
|
|
16
|
+
install bin. Every path below is importable from the published package.
|
|
17
|
+
|
|
18
|
+
| Module | Public import | Helpers (key exports) | Stability |
|
|
19
|
+
| --------------- | --------------------------------------------------- | ------------------------------------------------------------------------------------- | --------- |
|
|
20
|
+
| cli | `@hegemonart/get-design-done/sdk/cli` | `dispatch`, `main`, `USAGE`, `DispatcherDeps` | beta |
|
|
21
|
+
| state | `@hegemonart/get-design-done/sdk/state` | `read`, `mutate`, `transition`, `ParsedState`, `Stage` | beta |
|
|
22
|
+
| event-stream | `@hegemonart/get-design-done/sdk/event-stream` | `appendEvent`, `getWriter`, `getBus`, `subscribe`, `subscribeAll`, `reset`, `readEvents`, `aggregate`, `EventBus`, `EventWriter`, `KNOWN_EVENT_TYPES` | beta |
|
|
23
|
+
| errors | `@hegemonart/get-design-done/sdk/errors` | `GDDError`, `ValidationError`, `StateConflictError`, `OperationFailedError`, `TransitionGateFailed`, `LockAcquisitionError`, `ParseError` | beta |
|
|
24
|
+
| primitives/error-classifier | `@hegemonart/get-design-done/sdk/primitives/error-classifier` | `classify`, `FailoverReason` | stable |
|
|
25
|
+
| primitives/iteration-budget | `@hegemonart/get-design-done/sdk/primitives/iteration-budget` | `consume`, `refund`, `remaining`, `reset`, `IterationBudgetExhaustedError` | stable |
|
|
26
|
+
| primitives/jittered-backoff | `@hegemonart/get-design-done/sdk/primitives/jittered-backoff` | `delayMs`, `sleep`, `DEFAULTS` | stable |
|
|
27
|
+
| primitives/lockfile | `@hegemonart/get-design-done/sdk/primitives/lockfile` | `acquire`, `renameWithRetry` | stable |
|
|
28
|
+
| mcp/gdd-state | `@hegemonart/get-design-done/sdk/mcp/gdd-state` | `buildServer` (server.ts) — 11 STATE.md tools over stdio | beta |
|
|
29
|
+
|
|
30
|
+
The barrel: `import { read, appendEvent, ValidationError } from '@hegemonart/get-design-done/sdk'`.
|
|
31
|
+
|
|
32
|
+
## Notes
|
|
33
|
+
|
|
34
|
+
- **Primitives are `stable`** (D-05): they ship as `.cjs` + `.d.cts` pairs and
|
|
35
|
+
are the most-imported surface; the TS migration is a separate phase.
|
|
36
|
+
- **`state` re-exports the three error classes** (`TransitionGateFailed`,
|
|
37
|
+
`LockAcquisitionError`, `ParseError`) from `errors` verbatim, so importing
|
|
38
|
+
them from either path yields the same identity.
|
|
39
|
+
- The event stream persists to `.design/telemetry/events.jsonl`; `appendEvent`
|
|
40
|
+
is persist-first / broadcast-second and never throws on the persist path.
|
|
41
|
+
- `mutate()` / `transition()` take an advisory sibling lockfile; one process per
|
|
42
|
+
`.design/` is the design contract.
|
|
43
|
+
|
|
44
|
+
See `connections/gdd-state.md` for the MCP wiring and the runtime fallback that
|
|
45
|
+
imports the `state` module directly when the MCP is `not_configured`.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// sdk/cli/commands/audit.ts — Plan 21-09 Task 5 (SDK-21).
|
|
2
2
|
//
|
|
3
3
|
// `gdd-sdk audit` — regression + verification dry-run.
|
|
4
4
|
//
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
import { existsSync, readFileSync } from 'node:fs';
|
|
26
26
|
import { resolve as resolvePath } from 'node:path';
|
|
27
27
|
|
|
28
|
-
import { read } from '../../
|
|
29
|
-
import type { ConnectionStatus, ParsedState } from '../../
|
|
28
|
+
import { read } from '../../state/index.ts';
|
|
29
|
+
import type { ConnectionStatus, ParsedState } from '../../state/types.ts';
|
|
30
30
|
|
|
31
31
|
import {
|
|
32
32
|
coerceFlags,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// sdk/cli/commands/init.ts — Plan 21-09 Task 6 (SDK-21).
|
|
2
2
|
//
|
|
3
3
|
// `gdd-sdk init` — bootstrap a new project's `.design/` directory by
|
|
4
4
|
// delegating to `init-runner.run()` (Plan 21-08).
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
import {
|
|
17
17
|
run as defaultInitRun,
|
|
18
18
|
type InitRunnerResult,
|
|
19
|
-
} from '
|
|
20
|
-
import { getLogger } from '
|
|
19
|
+
} from '../../../scripts/lib/init-runner/index.ts';
|
|
20
|
+
import { getLogger } from '../../../scripts/lib/logger/index.ts';
|
|
21
21
|
|
|
22
22
|
import {
|
|
23
23
|
coerceFlags,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// sdk/cli/commands/query.ts — Plan 21-09 Task 4 (SDK-21).
|
|
2
2
|
//
|
|
3
3
|
// `gdd-sdk query <op>` — typed STATE.md read operations. Mirrors the
|
|
4
4
|
// read side of the gdd-state MCP server. Never mutates — use the
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
import { existsSync, readFileSync } from 'node:fs';
|
|
21
21
|
import { resolve as resolvePath } from 'node:path';
|
|
22
22
|
|
|
23
|
-
import { read } from '../../
|
|
24
|
-
import { gateFor } from '../../
|
|
25
|
-
import { isStage, type ParsedState, type Stage } from '../../
|
|
23
|
+
import { read } from '../../state/index.ts';
|
|
24
|
+
import { gateFor } from '../../state/gates.ts';
|
|
25
|
+
import { isStage, type ParsedState, type Stage } from '../../state/types.ts';
|
|
26
26
|
|
|
27
27
|
import {
|
|
28
28
|
coerceFlags,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// sdk/cli/commands/run.ts — Plan 21-09 Task 2 (SDK-21),
|
|
2
2
|
// extended by Plan 21-11 Task 3 (dry-run).
|
|
3
3
|
//
|
|
4
4
|
// `gdd-sdk run` — drives the full design pipeline via
|
|
@@ -36,10 +36,10 @@ import {
|
|
|
36
36
|
type RunOverrides,
|
|
37
37
|
type Stage,
|
|
38
38
|
type StageOutcome,
|
|
39
|
-
} from '
|
|
40
|
-
import { getLogger } from '
|
|
41
|
-
import { ValidationError } from '../../
|
|
42
|
-
import type { SessionResult, SessionRunnerOptions } from '
|
|
39
|
+
} from '../../../scripts/lib/pipeline-runner/index.ts';
|
|
40
|
+
import { getLogger } from '../../../scripts/lib/logger/index.ts';
|
|
41
|
+
import { ValidationError } from '../../errors/index.ts';
|
|
42
|
+
import type { SessionResult, SessionRunnerOptions } from '../../../scripts/lib/session-runner/types.ts';
|
|
43
43
|
|
|
44
44
|
import {
|
|
45
45
|
coerceFlags,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// sdk/cli/commands/stage.ts — Plan 21-09 Task 3 (SDK-21).
|
|
2
2
|
//
|
|
3
3
|
// `gdd-sdk stage <name>` — run a single pipeline stage. Delegates to
|
|
4
4
|
// `pipeline-runner.run()` with `stages: [<name>]` for design-pipeline
|
|
@@ -24,16 +24,16 @@ import {
|
|
|
24
24
|
type PipelineConfig,
|
|
25
25
|
type PipelineResult,
|
|
26
26
|
type Stage,
|
|
27
|
-
} from '
|
|
27
|
+
} from '../../../scripts/lib/pipeline-runner/index.ts';
|
|
28
28
|
import {
|
|
29
29
|
run as defaultExploreParallelRun,
|
|
30
30
|
type ExploreRunnerResult,
|
|
31
|
-
} from '
|
|
31
|
+
} from '../../../scripts/lib/explore-parallel-runner/index.ts';
|
|
32
32
|
import {
|
|
33
33
|
run as defaultDiscussParallelRun,
|
|
34
34
|
type DiscussRunnerResult,
|
|
35
|
-
} from '
|
|
36
|
-
import { getLogger } from '
|
|
35
|
+
} from '../../../scripts/lib/discuss-parallel-runner/index.ts';
|
|
36
|
+
import { getLogger } from '../../../scripts/lib/logger/index.ts';
|
|
37
37
|
|
|
38
38
|
import {
|
|
39
39
|
coerceFlags,
|