@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,218 +1,29 @@
|
|
|
1
|
-
// scripts/lib/gdd-errors/index.ts —
|
|
1
|
+
// scripts/lib/gdd-errors/index.ts — GDD-DEPRECATION-SHIM (Plan 31-5-06, SDK-05, D-02).
|
|
2
2
|
//
|
|
3
|
-
//
|
|
3
|
+
// Thin deprecation shim. The real implementation moved to sdk/errors/index.ts
|
|
4
|
+
// in Plan 31-5-04 (SDK consolidation). This file is re-created at the OLD
|
|
5
|
+
// path so undocumented EXTERNAL importers (anyone who reached into
|
|
6
|
+
// node_modules/@hegemonart/get-design-done/scripts/lib/gdd-errors/index.ts
|
|
7
|
+
// directly) keep working for one minor grace window.
|
|
4
8
|
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
// should branch on, not crash on
|
|
9
|
+
// REMOVED IN v1.33.0 (D-02). Grace window: 1.31.5 ships with shims →
|
|
10
|
+
// 1.32.0 still has them → 1.33.0 removes them. Internal callers already use
|
|
11
|
+
// the sdk/ path (Plan 31-5-04/05) — this shim is external-only; 31-5-10's
|
|
12
|
+
// no-stale-internal-refs guard excludes files carrying the
|
|
13
|
+
// GDD-DEPRECATION-SHIM marker above.
|
|
11
14
|
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Abstract base class — every GDD taxonomy error inherits from this.
|
|
27
|
-
*
|
|
28
|
-
* Subclasses set a literal `kind` discriminant so `classify()` can
|
|
29
|
-
* branch on it without `instanceof` chains, and `toJSON()` produces a
|
|
30
|
-
* lossless payload for tool-result transport.
|
|
31
|
-
*/
|
|
32
|
-
export abstract class GDDError extends Error {
|
|
33
|
-
abstract readonly kind: 'validation' | 'state_conflict' | 'operation_failed';
|
|
34
|
-
readonly code: GDDErrorCode;
|
|
35
|
-
readonly context: Readonly<Record<string, unknown>>;
|
|
36
|
-
|
|
37
|
-
constructor(
|
|
38
|
-
message: string,
|
|
39
|
-
code: GDDErrorCode,
|
|
40
|
-
context: Record<string, unknown> = {},
|
|
41
|
-
) {
|
|
42
|
-
super(message);
|
|
43
|
-
this.code = code;
|
|
44
|
-
this.context = Object.freeze({ ...context });
|
|
45
|
-
// Set .name to the concrete subclass name (LockAcquisitionError,
|
|
46
|
-
// ValidationError, etc.) so error serialization is human-meaningful.
|
|
47
|
-
this.name = new.target.name;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Serialize to a plain object safe for JSON.stringify. Round-trips
|
|
52
|
-
* through JSON without loss of `name`, `kind`, `code`, `message`, or
|
|
53
|
-
* `context`. Does NOT include the stack trace — MCP tool handlers do
|
|
54
|
-
* not forward stacks to the model.
|
|
55
|
-
*/
|
|
56
|
-
toJSON(): {
|
|
57
|
-
name: string;
|
|
58
|
-
kind: GDDError['kind'];
|
|
59
|
-
code: GDDErrorCode;
|
|
60
|
-
message: string;
|
|
61
|
-
context: Readonly<Record<string, unknown>>;
|
|
62
|
-
} {
|
|
63
|
-
return {
|
|
64
|
-
name: this.name,
|
|
65
|
-
kind: this.kind,
|
|
66
|
-
code: this.code,
|
|
67
|
-
message: this.message,
|
|
68
|
-
context: this.context,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Throw at boundary when the caller's input is malformed.
|
|
75
|
-
*
|
|
76
|
-
* Example: MCP tool handler receives an argument that fails schema
|
|
77
|
-
* validation; the correct response is `throw new ValidationError(...)`
|
|
78
|
-
* so the harness catches it and returns a structured error to the model.
|
|
79
|
-
* The model should fix its input and retry.
|
|
80
|
-
*/
|
|
81
|
-
export class ValidationError extends GDDError {
|
|
82
|
-
readonly kind = 'validation' as const;
|
|
83
|
-
constructor(
|
|
84
|
-
message: string,
|
|
85
|
-
code: GDDErrorCode = 'VALIDATION',
|
|
86
|
-
context?: Record<string, unknown>,
|
|
87
|
-
) {
|
|
88
|
-
super(message, code, context);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Throw when a concurrency primitive or transition guard vetoes the
|
|
94
|
-
* operation. Retryable by upstream — the caller may try again after a
|
|
95
|
-
* backoff, or surface the blocker to the operator.
|
|
96
|
-
*
|
|
97
|
-
* Examples: lockfile contention (LockAcquisitionError), transition
|
|
98
|
-
* gate failure (TransitionGateFailed).
|
|
99
|
-
*/
|
|
100
|
-
export class StateConflictError extends GDDError {
|
|
101
|
-
readonly kind = 'state_conflict' as const;
|
|
102
|
-
constructor(
|
|
103
|
-
message: string,
|
|
104
|
-
code: GDDErrorCode = 'STATE_CONFLICT',
|
|
105
|
-
context?: Record<string, unknown>,
|
|
106
|
-
) {
|
|
107
|
-
super(message, code, context);
|
|
108
|
-
}
|
|
15
|
+
// Runs under --experimental-strip-types, so `export *` re-export is
|
|
16
|
+
// strip-types-clean.
|
|
17
|
+
|
|
18
|
+
import { emitWarning } from 'node:process';
|
|
19
|
+
|
|
20
|
+
let warned = false;
|
|
21
|
+
if (!warned) {
|
|
22
|
+
warned = true;
|
|
23
|
+
emitWarning(
|
|
24
|
+
'scripts/lib/gdd-errors/index.ts is deprecated; import sdk/errors instead. Removed in v1.33.0.',
|
|
25
|
+
'DeprecationWarning',
|
|
26
|
+
);
|
|
109
27
|
}
|
|
110
28
|
|
|
111
|
-
|
|
112
|
-
* Return as `data.error` — do NOT throw. This is the expected failure
|
|
113
|
-
* mode the caller should branch on: the operation is well-formed, the
|
|
114
|
-
* state is valid, but the specific request cannot complete right now.
|
|
115
|
-
*
|
|
116
|
-
* Example: "try to advance to `design`, but no plan exists yet" — the
|
|
117
|
-
* model should be told, not crashed on.
|
|
118
|
-
*/
|
|
119
|
-
export class OperationFailedError extends GDDError {
|
|
120
|
-
readonly kind = 'operation_failed' as const;
|
|
121
|
-
constructor(
|
|
122
|
-
message: string,
|
|
123
|
-
code: GDDErrorCode = 'OPERATION_FAILED',
|
|
124
|
-
context?: Record<string, unknown>,
|
|
125
|
-
) {
|
|
126
|
-
super(message, code, context);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// -----------------------------------------------------------------------
|
|
131
|
-
// Plan 20-01 compatibility re-exports.
|
|
132
|
-
//
|
|
133
|
-
// These keep the `gdd-state` module's public surface stable post-refactor:
|
|
134
|
-
// - LockAcquisitionError — lockfile contention (plan 20-01 lockfile.ts)
|
|
135
|
-
// - TransitionGateFailed — transition gate veto (plan 20-01 transition())
|
|
136
|
-
// Both are StateConflictError subclasses (retryable / contention-class
|
|
137
|
-
// errors).
|
|
138
|
-
// -----------------------------------------------------------------------
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Error thrown when `acquire()` cannot obtain the lockfile within
|
|
142
|
-
* `maxWaitMs`. Carries the contents of the offending lockfile (as
|
|
143
|
-
* text — may be JSON, may be garbage if corrupted) so callers can
|
|
144
|
-
* surface them to operators.
|
|
145
|
-
*
|
|
146
|
-
* The `lockPath` and `lockContents` instance properties are preserved
|
|
147
|
-
* from the Plan 20-01 shape for API compat; they're also stored in
|
|
148
|
-
* the frozen `context` object for uniform GDDError serialization.
|
|
149
|
-
*/
|
|
150
|
-
export class LockAcquisitionError extends StateConflictError {
|
|
151
|
-
readonly lockPath: string;
|
|
152
|
-
readonly lockContents: string;
|
|
153
|
-
readonly waitedMs: number;
|
|
154
|
-
constructor(
|
|
155
|
-
lockPath: string,
|
|
156
|
-
lockContents: string,
|
|
157
|
-
waitedMs: number,
|
|
158
|
-
context?: Record<string, unknown>,
|
|
159
|
-
) {
|
|
160
|
-
super(
|
|
161
|
-
`failed to acquire lock at ${lockPath} after ${waitedMs}ms; current holder: ${lockContents}`,
|
|
162
|
-
'LOCK_ACQUISITION',
|
|
163
|
-
{ ...context, lockPath, lockContents, waitedMs },
|
|
164
|
-
);
|
|
165
|
-
this.lockPath = lockPath;
|
|
166
|
-
this.lockContents = lockContents;
|
|
167
|
-
this.waitedMs = waitedMs;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Error thrown when a transition gate vetoes a stage advance. Carries
|
|
173
|
-
* the frozen list of blocker messages so callers can surface them to
|
|
174
|
-
* operators or retry after resolving.
|
|
175
|
-
*
|
|
176
|
-
* The `blockers` instance property is preserved from the Plan 20-01
|
|
177
|
-
* shape (readonly string[]) for API compat; it's also mirrored into
|
|
178
|
-
* the frozen `context` object for uniform GDDError serialization.
|
|
179
|
-
*/
|
|
180
|
-
export class TransitionGateFailed extends StateConflictError {
|
|
181
|
-
readonly blockers: readonly string[];
|
|
182
|
-
readonly toStage: string;
|
|
183
|
-
constructor(
|
|
184
|
-
toStage: string,
|
|
185
|
-
blockers: string[],
|
|
186
|
-
context?: Record<string, unknown>,
|
|
187
|
-
) {
|
|
188
|
-
super(
|
|
189
|
-
`transition to "${toStage}" blocked by gate: ${blockers.join('; ') || '(no detail)'}`,
|
|
190
|
-
'TRANSITION_GATE_FAILED',
|
|
191
|
-
{ ...context, toStage, blockers: [...blockers] },
|
|
192
|
-
);
|
|
193
|
-
this.toStage = toStage;
|
|
194
|
-
this.blockers = Object.freeze([...blockers]);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Error thrown by STATE.md `parse()` when the input cannot be
|
|
200
|
-
* interpreted. `ValidationError` semantics: the caller (likely the
|
|
201
|
-
* operator or an upstream generator) gave us malformed input — fix
|
|
202
|
-
* your STATE.md and retry.
|
|
203
|
-
*
|
|
204
|
-
* The `line` instance property points at the 1-indexed line in the
|
|
205
|
-
* source markdown where the parser gave up. It's also mirrored into
|
|
206
|
-
* the frozen `context` object.
|
|
207
|
-
*/
|
|
208
|
-
export class ParseError extends ValidationError {
|
|
209
|
-
readonly line: number;
|
|
210
|
-
constructor(message: string, line: number, context?: Record<string, unknown>) {
|
|
211
|
-
super(
|
|
212
|
-
`STATE.md parse error at line ${line}: ${message}`,
|
|
213
|
-
'PARSE_ERROR',
|
|
214
|
-
{ ...context, line },
|
|
215
|
-
);
|
|
216
|
-
this.line = line;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
29
|
+
export * from '../../../sdk/errors/index.ts';
|
|
@@ -1,167 +1,29 @@
|
|
|
1
|
-
// scripts/lib/gdd-state/index.ts —
|
|
1
|
+
// scripts/lib/gdd-state/index.ts — GDD-DEPRECATION-SHIM (Plan 31-5-06, SDK-05, D-02).
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
// * ParsedState (type) — consumer-visible shape
|
|
9
|
-
// * Stage (type) — stage enum
|
|
3
|
+
// Thin deprecation shim. The real implementation moved to sdk/state/index.ts
|
|
4
|
+
// in Plan 31-5-04 (SDK consolidation). This file is re-created at the OLD
|
|
5
|
+
// path so undocumented EXTERNAL importers (anyone who reached into
|
|
6
|
+
// node_modules/@hegemonart/get-design-done/scripts/lib/gdd-state/index.ts
|
|
7
|
+
// directly) keep working for one minor grace window.
|
|
10
8
|
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
// (
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
import { acquire } from './lockfile.ts';
|
|
20
|
-
import { parse } from './parser.ts';
|
|
21
|
-
import { serialize } from './mutator.ts';
|
|
22
|
-
import { gateFor } from './gates.ts';
|
|
23
|
-
import {
|
|
24
|
-
TransitionGateFailed,
|
|
25
|
-
isStage,
|
|
26
|
-
type ParsedState,
|
|
27
|
-
type Stage,
|
|
28
|
-
type TransitionResult,
|
|
29
|
-
} from './types.ts';
|
|
30
|
-
|
|
31
|
-
export type { ParsedState, Stage } from './types.ts';
|
|
32
|
-
export { TransitionGateFailed, LockAcquisitionError, ParseError } from './types.ts';
|
|
9
|
+
// REMOVED IN v1.33.0 (D-02). Grace window: 1.31.5 ships with shims →
|
|
10
|
+
// 1.32.0 still has them → 1.33.0 removes them. Internal callers already use
|
|
11
|
+
// the sdk/ path (Plan 31-5-04/05) — this shim is external-only; 31-5-10's
|
|
12
|
+
// no-stale-internal-refs guard excludes files carrying the
|
|
13
|
+
// GDD-DEPRECATION-SHIM marker above.
|
|
14
|
+
//
|
|
15
|
+
// Runs under --experimental-strip-types, so `export *` re-export is
|
|
16
|
+
// strip-types-clean.
|
|
33
17
|
|
|
34
|
-
|
|
35
|
-
* Read STATE.md from disk and return the parsed state.
|
|
36
|
-
*
|
|
37
|
-
* Shared-read: no lock is taken. Reads are snapshot-safe for markdown
|
|
38
|
-
* (the OS guarantees a coherent view even if a writer is mid-rename —
|
|
39
|
-
* we either see the old file or the new file, never a torn write,
|
|
40
|
-
* because `mutate()` uses atomic rename).
|
|
41
|
-
*/
|
|
42
|
-
export async function read(path: string): Promise<ParsedState> {
|
|
43
|
-
const raw: string = readFileSync(path, 'utf8');
|
|
44
|
-
return parse(raw).state;
|
|
45
|
-
}
|
|
18
|
+
import { emitWarning } from 'node:process';
|
|
46
19
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
* 4. Serialize to a `.tmp` file next to `path`.
|
|
55
|
-
* 5. `renameSync(.tmp, path)` — POSIX-atomic; on Windows EPERM means
|
|
56
|
-
* a scanner held it briefly, retry once.
|
|
57
|
-
* 6. Release the lock (in `finally` — released even on mid-fn throw).
|
|
58
|
-
*
|
|
59
|
-
* Crash between write and rename is benign: STATE.md is untouched; the
|
|
60
|
-
* `.tmp` file is orphaned (cleaned up on the next acquire by the caller).
|
|
61
|
-
*/
|
|
62
|
-
export async function mutate(
|
|
63
|
-
path: string,
|
|
64
|
-
fn: (s: ParsedState) => ParsedState,
|
|
65
|
-
): Promise<ParsedState> {
|
|
66
|
-
const release = await acquire(path);
|
|
67
|
-
const tmpPath: string = `${path}.tmp`;
|
|
68
|
-
try {
|
|
69
|
-
const raw: string = readFileSync(path, 'utf8');
|
|
70
|
-
const { state, raw_bodies, raw_frontmatter, block_gaps, line_ending } =
|
|
71
|
-
parse(raw);
|
|
72
|
-
// Deep-clone so the consumer's fn cannot mutate the state we just
|
|
73
|
-
// parsed (defensive — apply() does this too for pure callers).
|
|
74
|
-
const clone = structuredClone(state);
|
|
75
|
-
const next = fn(clone);
|
|
76
|
-
const out = serialize(next, {
|
|
77
|
-
raw_frontmatter,
|
|
78
|
-
raw_bodies,
|
|
79
|
-
block_gaps,
|
|
80
|
-
line_ending,
|
|
81
|
-
});
|
|
82
|
-
writeFileSync(tmpPath, out, 'utf8');
|
|
83
|
-
try {
|
|
84
|
-
renameSync(tmpPath, path);
|
|
85
|
-
} catch (err) {
|
|
86
|
-
// Windows EPERM retry — AV / indexer holding STATE.md briefly.
|
|
87
|
-
const code =
|
|
88
|
-
typeof err === 'object' && err !== null && 'code' in err
|
|
89
|
-
? (err as { code?: unknown }).code
|
|
90
|
-
: undefined;
|
|
91
|
-
if (code === 'EPERM' || code === 'EBUSY') {
|
|
92
|
-
await new Promise((r) => setTimeout(r, 50));
|
|
93
|
-
renameSync(tmpPath, path);
|
|
94
|
-
} else {
|
|
95
|
-
throw err;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return next;
|
|
99
|
-
} catch (err) {
|
|
100
|
-
// Clean up the orphaned tmp file on failure so we don't pollute.
|
|
101
|
-
try {
|
|
102
|
-
if (existsSync(tmpPath)) unlinkSync(tmpPath);
|
|
103
|
-
} catch {
|
|
104
|
-
// best-effort; a leftover tmp file does not corrupt STATE.md.
|
|
105
|
-
}
|
|
106
|
-
throw err;
|
|
107
|
-
} finally {
|
|
108
|
-
await release();
|
|
109
|
-
}
|
|
20
|
+
let warned = false;
|
|
21
|
+
if (!warned) {
|
|
22
|
+
warned = true;
|
|
23
|
+
emitWarning(
|
|
24
|
+
'scripts/lib/gdd-state/index.ts is deprecated; import sdk/state instead. Removed in v1.33.0.',
|
|
25
|
+
'DeprecationWarning',
|
|
26
|
+
);
|
|
110
27
|
}
|
|
111
28
|
|
|
112
|
-
|
|
113
|
-
* Advance to `toStage` under the locked RMW protocol.
|
|
114
|
-
*
|
|
115
|
-
* Steps:
|
|
116
|
-
* 1. Read current state (outside the lock) to pass to the gate.
|
|
117
|
-
* 2. Resolve the gate via `gateFor(position.stage, toStage)`.
|
|
118
|
-
* - `null` → TransitionGateFailed "Invalid transition" (skip-stage,
|
|
119
|
-
* backward, same-stage, or from outside the Stage union).
|
|
120
|
-
* 3. Invoke the gate. If `pass: false`, throw TransitionGateFailed with
|
|
121
|
-
* the gate's blockers verbatim.
|
|
122
|
-
* 4. If `pass: true`, mutate STATE.md under the lock:
|
|
123
|
-
* - frontmatter.stage = toStage
|
|
124
|
-
* - position.stage = toStage
|
|
125
|
-
* - frontmatter.last_checkpoint = now (ISO)
|
|
126
|
-
* - timestamps[`${toStage}_started_at`] = now (ISO)
|
|
127
|
-
*
|
|
128
|
-
* Returns the updated state plus the gate response (for callers that
|
|
129
|
-
* want to log blockers — on pass, `blockers` is always `[]`).
|
|
130
|
-
*/
|
|
131
|
-
export async function transition(
|
|
132
|
-
path: string,
|
|
133
|
-
toStage: Stage,
|
|
134
|
-
): Promise<TransitionResult> {
|
|
135
|
-
// Read (outside the lock) to pass current state to the gate — the
|
|
136
|
-
// mutate() below will re-read under the lock before applying changes.
|
|
137
|
-
// This two-phase pattern matches the GSD reference implementation.
|
|
138
|
-
const beforeMutate = await read(path);
|
|
139
|
-
const from: string = beforeMutate.position.stage;
|
|
140
|
-
// `position.stage` is typed as `string` in ParsedState (parser tolerates
|
|
141
|
-
// `scan` and other pre-brief values). Narrow it to `Stage` before asking
|
|
142
|
-
// the gate registry — anything outside the union is an invalid FROM.
|
|
143
|
-
if (!isStage(from)) {
|
|
144
|
-
throw new TransitionGateFailed(toStage, [
|
|
145
|
-
`Invalid transition: from="${from}" is not a recognized Stage`,
|
|
146
|
-
]);
|
|
147
|
-
}
|
|
148
|
-
const gate = gateFor(from, toStage);
|
|
149
|
-
if (gate === null) {
|
|
150
|
-
throw new TransitionGateFailed(toStage, [
|
|
151
|
-
`Invalid transition: ${from} → ${toStage}`,
|
|
152
|
-
]);
|
|
153
|
-
}
|
|
154
|
-
const gateResult = gate(beforeMutate);
|
|
155
|
-
if (!gateResult.pass) {
|
|
156
|
-
throw new TransitionGateFailed(toStage, gateResult.blockers);
|
|
157
|
-
}
|
|
158
|
-
const nowIso: string = new Date().toISOString();
|
|
159
|
-
const nextState = await mutate(path, (s): ParsedState => {
|
|
160
|
-
s.frontmatter.stage = toStage;
|
|
161
|
-
s.frontmatter.last_checkpoint = nowIso;
|
|
162
|
-
s.position.stage = toStage;
|
|
163
|
-
s.timestamps[`${toStage}_started_at`] = nowIso;
|
|
164
|
-
return s;
|
|
165
|
-
});
|
|
166
|
-
return { pass: true, blockers: gateResult.blockers, state: nextState };
|
|
167
|
-
}
|
|
29
|
+
export * from '../../../sdk/state/index.ts';
|
|
@@ -8,12 +8,13 @@
|
|
|
8
8
|
// Surface:
|
|
9
9
|
// async getHealthChecks(rootDir) → { checks: HealthCheck[] }
|
|
10
10
|
//
|
|
11
|
-
// The
|
|
11
|
+
// The 6 checks (in stable order) are:
|
|
12
12
|
// 1. claude_md — CLAUDE.md presence
|
|
13
13
|
// 2. planning_dir — .planning/ presence
|
|
14
14
|
// 3. design_dir — .design/ presence
|
|
15
15
|
// 4. package_json — package.json present AND parseable
|
|
16
16
|
// 5. issue_reporter — kill-switch state (Plan 30-06 / D-08)
|
|
17
|
+
// 6. figma_extract — extract readiness + Free-tier signal (Plan 31-09)
|
|
17
18
|
//
|
|
18
19
|
// Check 5 was added in Plan 30-06 — surfaces the report-issue kill-switch
|
|
19
20
|
// (env or config disable) so users can verify why the command is
|
|
@@ -22,6 +23,17 @@
|
|
|
22
23
|
// - "issue reporter: disabled by env (GDD_DISABLE_ISSUE_REPORTER=1)"
|
|
23
24
|
// - "issue reporter: disabled by config (.design/config.json: issue_reporter=false)"
|
|
24
25
|
// When both env and config trigger, env wins (matches D-08 display contract).
|
|
26
|
+
//
|
|
27
|
+
// Check 6 was added in Plan 31-09 — surfaces figma-extract readiness so a user
|
|
28
|
+
// running /gdd:health immediately knows whether figma-extract is usable. The
|
|
29
|
+
// detail line is one of three exact strings:
|
|
30
|
+
// - "figma extract: ready (token set)"
|
|
31
|
+
// - "figma extract: token missing"
|
|
32
|
+
// - "figma extract: plugin sync needed for variables (Free tier detected)"
|
|
33
|
+
// D-10: only FIGMA_TOKEN *presence* is used — the token VALUE is never read,
|
|
34
|
+
// logged, or placed in the detail. The Free-tier state is derived from a LOCAL
|
|
35
|
+
// signal only (a prior pull's _meta.json recording a 403/skip on the Variables
|
|
36
|
+
// endpoint) — never a live network call (health-mirror is pure read-only).
|
|
25
37
|
|
|
26
38
|
const fs = require('node:fs');
|
|
27
39
|
const path = require('node:path');
|
|
@@ -135,7 +147,82 @@ async function getHealthChecks(rootDir) {
|
|
|
135
147
|
});
|
|
136
148
|
}
|
|
137
149
|
|
|
150
|
+
// 6. figma_extract — extract readiness + Free-tier plugin-sync signal (Plan 31-09)
|
|
151
|
+
// Reports exactly one of three states. PURE read-only: presence-only token
|
|
152
|
+
// check (D-10 — value never read/logged/printed) + a LOCAL Free-tier marker
|
|
153
|
+
// (a prior pull's _meta.json recording a 403/skip on the Variables endpoint —
|
|
154
|
+
// see scripts/lib/figma-extract/pull.cjs). NEVER throws, NEVER networks.
|
|
155
|
+
{
|
|
156
|
+
// D-10: presence only. The token VALUE is never bound to a variable that
|
|
157
|
+
// could be interpolated into detail/logs — only the boolean is kept.
|
|
158
|
+
const tokenSet = !!(process.env.FIGMA_TOKEN || process.env.FIGMA_PERSONAL_ACCESS_TOKEN);
|
|
159
|
+
|
|
160
|
+
let detail;
|
|
161
|
+
let status;
|
|
162
|
+
if (!tokenSet) {
|
|
163
|
+
detail = 'figma extract: token missing';
|
|
164
|
+
status = 'warn';
|
|
165
|
+
} else if (figmaVariablesBlockedLocally(rootDir)) {
|
|
166
|
+
// Token present but a prior pull recorded a 403/skip on the Variables REST
|
|
167
|
+
// path → Free/non-Enterprise tier. Actionable (plugin sync), not a hard fail.
|
|
168
|
+
detail = 'figma extract: plugin sync needed for variables (Free tier detected)';
|
|
169
|
+
status = 'warn';
|
|
170
|
+
} else {
|
|
171
|
+
detail = 'figma extract: ready (token set)';
|
|
172
|
+
status = 'ok';
|
|
173
|
+
}
|
|
174
|
+
checks.push({ name: 'figma_extract', status, detail });
|
|
175
|
+
}
|
|
176
|
+
|
|
138
177
|
return { checks };
|
|
139
178
|
}
|
|
140
179
|
|
|
180
|
+
/**
|
|
181
|
+
* Free-tier signal (LOCAL only — never a network call). The raw-pull stage
|
|
182
|
+
* (scripts/lib/figma-extract/pull.cjs) writes a _meta.json per file key under
|
|
183
|
+
* the gitignored cache dir; on a Variables 403 it records a totals[] entry
|
|
184
|
+
* `{ name: 'variables', skipped: true, reason: 'HTTP 403' }`. We scan the
|
|
185
|
+
* default cache root for any such marker. Defensive: malformed/absent markers
|
|
186
|
+
* default to NOT-free (→ 'ready') so the health probe never false-alarms and
|
|
187
|
+
* NEVER throws. NEVER reads the token; NEVER makes a request.
|
|
188
|
+
*
|
|
189
|
+
* @param {string} rootDir project root passed to getHealthChecks
|
|
190
|
+
* @returns {boolean} true iff a prior pull recorded a Variables 403/skip
|
|
191
|
+
*/
|
|
192
|
+
function figmaVariablesBlockedLocally(rootDir) {
|
|
193
|
+
try {
|
|
194
|
+
const rawRoot = path.join(rootDir, '.figma-extract-cache', 'raw');
|
|
195
|
+
let entries;
|
|
196
|
+
try {
|
|
197
|
+
entries = fs.readdirSync(rawRoot, { withFileTypes: true });
|
|
198
|
+
} catch {
|
|
199
|
+
return false; // no cache yet → default to ready
|
|
200
|
+
}
|
|
201
|
+
for (const ent of entries) {
|
|
202
|
+
if (!ent.isDirectory()) continue;
|
|
203
|
+
const metaPath = path.join(rawRoot, ent.name, '_meta.json');
|
|
204
|
+
let meta;
|
|
205
|
+
try {
|
|
206
|
+
meta = JSON.parse(fs.readFileSync(metaPath, 'utf8'));
|
|
207
|
+
} catch {
|
|
208
|
+
continue; // missing/garbage marker → ignore this dir, keep scanning
|
|
209
|
+
}
|
|
210
|
+
const totals = meta && Array.isArray(meta.totals) ? meta.totals : [];
|
|
211
|
+
const blocked = totals.some(
|
|
212
|
+
(t) =>
|
|
213
|
+
t &&
|
|
214
|
+
t.name === 'variables' &&
|
|
215
|
+
t.skipped === true &&
|
|
216
|
+
typeof t.reason === 'string' &&
|
|
217
|
+
/403/.test(t.reason)
|
|
218
|
+
);
|
|
219
|
+
if (blocked) return true;
|
|
220
|
+
}
|
|
221
|
+
return false;
|
|
222
|
+
} catch {
|
|
223
|
+
// Absolute safety net — the health probe must never crash on this check.
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
141
228
|
module.exports = { getHealthChecks };
|