gswd 1.0.1 → 1.1.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 (85) hide show
  1. package/bin/gswd-tools.cjs +228 -0
  2. package/commands/gswd/imagine.md +7 -1
  3. package/commands/gswd/start.md +507 -32
  4. package/dist/lib/audit.d.ts +205 -0
  5. package/dist/lib/audit.js +805 -0
  6. package/dist/lib/bootstrap.d.ts +103 -0
  7. package/dist/lib/bootstrap.js +563 -0
  8. package/dist/lib/compile.d.ts +239 -0
  9. package/dist/lib/compile.js +1152 -0
  10. package/dist/lib/config.d.ts +49 -0
  11. package/dist/lib/config.js +150 -0
  12. package/dist/lib/imagine-agents.d.ts +54 -0
  13. package/dist/lib/imagine-agents.js +185 -0
  14. package/dist/lib/imagine-gate.d.ts +47 -0
  15. package/dist/lib/imagine-gate.js +131 -0
  16. package/dist/lib/imagine-input.d.ts +46 -0
  17. package/dist/lib/imagine-input.js +233 -0
  18. package/dist/lib/imagine-synthesis.d.ts +90 -0
  19. package/dist/lib/imagine-synthesis.js +453 -0
  20. package/dist/lib/imagine.d.ts +56 -0
  21. package/dist/lib/imagine.js +413 -0
  22. package/dist/lib/intake.d.ts +27 -0
  23. package/dist/lib/intake.js +82 -0
  24. package/dist/lib/parse.d.ts +59 -0
  25. package/dist/lib/parse.js +171 -0
  26. package/dist/lib/render.d.ts +309 -0
  27. package/dist/lib/render.js +624 -0
  28. package/dist/lib/specify-agents.d.ts +120 -0
  29. package/dist/lib/specify-agents.js +269 -0
  30. package/dist/lib/specify-journeys.d.ts +124 -0
  31. package/dist/lib/specify-journeys.js +279 -0
  32. package/dist/lib/specify-nfr.d.ts +45 -0
  33. package/dist/lib/specify-nfr.js +159 -0
  34. package/dist/lib/specify-roles.d.ts +46 -0
  35. package/dist/lib/specify-roles.js +88 -0
  36. package/dist/lib/specify.d.ts +70 -0
  37. package/dist/lib/specify.js +676 -0
  38. package/dist/lib/state.d.ts +140 -0
  39. package/dist/lib/state.js +340 -0
  40. package/dist/tests/audit.test.d.ts +4 -0
  41. package/dist/tests/audit.test.js +1579 -0
  42. package/dist/tests/bootstrap.test.d.ts +5 -0
  43. package/dist/tests/bootstrap.test.js +611 -0
  44. package/dist/tests/compile.test.d.ts +4 -0
  45. package/dist/tests/compile.test.js +862 -0
  46. package/dist/tests/config.test.d.ts +4 -0
  47. package/dist/tests/config.test.js +191 -0
  48. package/dist/tests/imagine-agents.test.d.ts +6 -0
  49. package/dist/tests/imagine-agents.test.js +179 -0
  50. package/dist/tests/imagine-gate.test.d.ts +6 -0
  51. package/dist/tests/imagine-gate.test.js +264 -0
  52. package/dist/tests/imagine-input.test.d.ts +6 -0
  53. package/dist/tests/imagine-input.test.js +283 -0
  54. package/dist/tests/imagine-synthesis.test.d.ts +7 -0
  55. package/dist/tests/imagine-synthesis.test.js +380 -0
  56. package/dist/tests/imagine.test.d.ts +8 -0
  57. package/dist/tests/imagine.test.js +406 -0
  58. package/dist/tests/parse.test.d.ts +4 -0
  59. package/dist/tests/parse.test.js +285 -0
  60. package/dist/tests/render.test.d.ts +4 -0
  61. package/dist/tests/render.test.js +236 -0
  62. package/dist/tests/specify-agents.test.d.ts +4 -0
  63. package/dist/tests/specify-agents.test.js +352 -0
  64. package/dist/tests/specify-journeys.test.d.ts +5 -0
  65. package/dist/tests/specify-journeys.test.js +440 -0
  66. package/dist/tests/specify-nfr.test.d.ts +4 -0
  67. package/dist/tests/specify-nfr.test.js +205 -0
  68. package/dist/tests/specify-roles.test.d.ts +4 -0
  69. package/dist/tests/specify-roles.test.js +136 -0
  70. package/dist/tests/specify.test.d.ts +9 -0
  71. package/dist/tests/specify.test.js +544 -0
  72. package/dist/tests/state.test.d.ts +4 -0
  73. package/dist/tests/state.test.js +316 -0
  74. package/lib/bootstrap.ts +37 -11
  75. package/lib/compile.ts +426 -4
  76. package/lib/imagine-agents.ts +53 -7
  77. package/lib/imagine-synthesis.ts +170 -6
  78. package/lib/imagine.ts +59 -5
  79. package/lib/intake.ts +60 -0
  80. package/lib/parse.ts +2 -1
  81. package/lib/render.ts +566 -5
  82. package/lib/specify-agents.ts +25 -3
  83. package/lib/state.ts +115 -0
  84. package/package.json +3 -2
  85. package/templates/gswd/DECISIONS.template.md +3 -0
package/lib/state.ts CHANGED
@@ -43,6 +43,18 @@ export interface IdRegistry {
43
43
  allocated_ranges: Record<string, IdRange[]>;
44
44
  }
45
45
 
46
+ export interface ManualModeState {
47
+ enabled: boolean;
48
+ reruns: {
49
+ imagine: number;
50
+ specify: number;
51
+ audit: number;
52
+ compile: number;
53
+ };
54
+ last_checkpoint_stage: string | null;
55
+ interrupt_type: 'mid_stage' | 'between_stages' | null;
56
+ }
57
+
46
58
  export interface GswdState {
47
59
  version: number;
48
60
  project_slug: string;
@@ -51,6 +63,7 @@ export interface GswdState {
51
63
  stage: 'init' | 'imagine' | 'specify' | 'audit' | 'compile' | 'done';
52
64
  stage_status: StageStatus;
53
65
  last_checkpoint: Checkpoint | null;
66
+ first_run_complete?: boolean;
54
67
  auto: {
55
68
  enabled: boolean;
56
69
  policy: 'strict' | 'balanced' | 'aggressive';
@@ -63,8 +76,14 @@ export interface GswdState {
63
76
  paid_integrations: PaidIntegration[];
64
77
  };
65
78
  id_registry?: IdRegistry;
79
+ manual_mode?: ManualModeState;
66
80
  }
67
81
 
82
+ // ─── Stage Order ─────────────────────────────────────────────────────────────
83
+
84
+ export const STAGE_ORDER = ['imagine', 'specify', 'audit', 'compile'] as const;
85
+ export type StageName = typeof STAGE_ORDER[number];
86
+
68
87
  // ─── Atomic File I/O ─────────────────────────────────────────────────────────
69
88
 
70
89
  /**
@@ -137,6 +156,7 @@ export function createDefaultState(projectSlug: string): GswdState {
137
156
  compile: 'not_started',
138
157
  },
139
158
  last_checkpoint: null,
159
+ first_run_complete: false,
140
160
  auto: {
141
161
  enabled: false,
142
162
  policy: 'balanced',
@@ -148,6 +168,12 @@ export function createDefaultState(projectSlug: string): GswdState {
148
168
  data_store: 'unapproved',
149
169
  paid_integrations: [],
150
170
  },
171
+ manual_mode: {
172
+ enabled: false,
173
+ reruns: { imagine: 0, specify: 0, audit: 0, compile: 0 },
174
+ last_checkpoint_stage: null,
175
+ interrupt_type: null,
176
+ },
151
177
  };
152
178
  }
153
179
 
@@ -303,3 +329,92 @@ export function resetIdRegistry(statePath: string): void {
303
329
  state.id_registry = { allocated_ranges: {} };
304
330
  writeState(statePath, state);
305
331
  }
332
+
333
+ // ─── Manual Mode ──────────────────────────────────────────────────────────────
334
+
335
+ /**
336
+ * Mark all stages downstream of the re-run stage as 'not_started'.
337
+ * Also increments the re-run counter for the given stage.
338
+ * Performs a single atomic STATE.json write.
339
+ */
340
+ export function cascadeInvalidate(statePath: string, fromStage: StageName): void {
341
+ const state = readState(statePath);
342
+ if (!state) {
343
+ throw new Error(`Cannot read STATE.json at ${statePath}`);
344
+ }
345
+
346
+ const idx = STAGE_ORDER.indexOf(fromStage);
347
+ if (idx === -1) return;
348
+
349
+ // Invalidate all downstream stages
350
+ for (let i = idx + 1; i < STAGE_ORDER.length; i++) {
351
+ (state.stage_status as unknown as Record<string, string>)[STAGE_ORDER[i]] = 'not_started';
352
+ }
353
+
354
+ // Ensure manual_mode exists
355
+ if (!state.manual_mode) {
356
+ state.manual_mode = {
357
+ enabled: false,
358
+ reruns: { imagine: 0, specify: 0, audit: 0, compile: 0 },
359
+ last_checkpoint_stage: null,
360
+ interrupt_type: null,
361
+ };
362
+ }
363
+
364
+ // Increment re-run counter for this stage
365
+ state.manual_mode.reruns[fromStage] = (state.manual_mode.reruns[fromStage] || 0) + 1;
366
+
367
+ // Single atomic write (re-run count + cascade in one operation)
368
+ writeState(statePath, state);
369
+ }
370
+
371
+ /**
372
+ * Update the manual mode checkpoint tracking in STATE.json.
373
+ * Called when entering or completing a stage boundary checkpoint.
374
+ */
375
+ export function updateManualCheckpoint(
376
+ statePath: string,
377
+ stage: StageName | null,
378
+ interruptType: 'mid_stage' | 'between_stages' | null,
379
+ ): void {
380
+ const state = readState(statePath);
381
+ if (!state) {
382
+ throw new Error(`Cannot read STATE.json at ${statePath}`);
383
+ }
384
+
385
+ if (!state.manual_mode) {
386
+ state.manual_mode = {
387
+ enabled: false,
388
+ reruns: { imagine: 0, specify: 0, audit: 0, compile: 0 },
389
+ last_checkpoint_stage: null,
390
+ interrupt_type: null,
391
+ };
392
+ }
393
+
394
+ state.manual_mode.last_checkpoint_stage = stage;
395
+ state.manual_mode.interrupt_type = interruptType;
396
+ writeState(statePath, state);
397
+ }
398
+
399
+ /**
400
+ * Set manual mode enabled/disabled in STATE.json.
401
+ */
402
+ export function setManualMode(statePath: string, enabled: boolean): void {
403
+ const state = readState(statePath);
404
+ if (!state) {
405
+ throw new Error(`Cannot read STATE.json at ${statePath}`);
406
+ }
407
+
408
+ if (!state.manual_mode) {
409
+ state.manual_mode = {
410
+ enabled,
411
+ reruns: { imagine: 0, specify: 0, audit: 0, compile: 0 },
412
+ last_checkpoint_stage: null,
413
+ interrupt_type: null,
414
+ };
415
+ } else {
416
+ state.manual_mode.enabled = enabled;
417
+ }
418
+
419
+ writeState(statePath, state);
420
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gswd",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "type": "commonjs",
5
5
  "description": "Get Shit Well Done — CLI meta-prompting and spec-generation system",
6
6
  "bin": {
@@ -13,7 +13,8 @@
13
13
  "lib/",
14
14
  "templates/",
15
15
  "agents/",
16
- "commands/"
16
+ "commands/",
17
+ "dist/"
17
18
  ],
18
19
  "scripts": {
19
20
  "postinstall": "node ./bin/install.js",
@@ -1,5 +1,8 @@
1
1
  # Decisions
2
2
 
3
+ ## Vision
4
+ <!-- GSWD:CONTENT - Aspirational future state the product enables -->
5
+
3
6
  ## Frozen Decisions
4
7
  <!-- GSWD:CONTENT - Minimum 8 frozen decisions required -->
5
8