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.
- package/bin/gswd-tools.cjs +228 -0
- package/commands/gswd/imagine.md +7 -1
- package/commands/gswd/start.md +507 -32
- package/dist/lib/audit.d.ts +205 -0
- package/dist/lib/audit.js +805 -0
- package/dist/lib/bootstrap.d.ts +103 -0
- package/dist/lib/bootstrap.js +563 -0
- package/dist/lib/compile.d.ts +239 -0
- package/dist/lib/compile.js +1152 -0
- package/dist/lib/config.d.ts +49 -0
- package/dist/lib/config.js +150 -0
- package/dist/lib/imagine-agents.d.ts +54 -0
- package/dist/lib/imagine-agents.js +185 -0
- package/dist/lib/imagine-gate.d.ts +47 -0
- package/dist/lib/imagine-gate.js +131 -0
- package/dist/lib/imagine-input.d.ts +46 -0
- package/dist/lib/imagine-input.js +233 -0
- package/dist/lib/imagine-synthesis.d.ts +90 -0
- package/dist/lib/imagine-synthesis.js +453 -0
- package/dist/lib/imagine.d.ts +56 -0
- package/dist/lib/imagine.js +413 -0
- package/dist/lib/intake.d.ts +27 -0
- package/dist/lib/intake.js +82 -0
- package/dist/lib/parse.d.ts +59 -0
- package/dist/lib/parse.js +171 -0
- package/dist/lib/render.d.ts +309 -0
- package/dist/lib/render.js +624 -0
- package/dist/lib/specify-agents.d.ts +120 -0
- package/dist/lib/specify-agents.js +269 -0
- package/dist/lib/specify-journeys.d.ts +124 -0
- package/dist/lib/specify-journeys.js +279 -0
- package/dist/lib/specify-nfr.d.ts +45 -0
- package/dist/lib/specify-nfr.js +159 -0
- package/dist/lib/specify-roles.d.ts +46 -0
- package/dist/lib/specify-roles.js +88 -0
- package/dist/lib/specify.d.ts +70 -0
- package/dist/lib/specify.js +676 -0
- package/dist/lib/state.d.ts +140 -0
- package/dist/lib/state.js +340 -0
- package/dist/tests/audit.test.d.ts +4 -0
- package/dist/tests/audit.test.js +1579 -0
- package/dist/tests/bootstrap.test.d.ts +5 -0
- package/dist/tests/bootstrap.test.js +611 -0
- package/dist/tests/compile.test.d.ts +4 -0
- package/dist/tests/compile.test.js +862 -0
- package/dist/tests/config.test.d.ts +4 -0
- package/dist/tests/config.test.js +191 -0
- package/dist/tests/imagine-agents.test.d.ts +6 -0
- package/dist/tests/imagine-agents.test.js +179 -0
- package/dist/tests/imagine-gate.test.d.ts +6 -0
- package/dist/tests/imagine-gate.test.js +264 -0
- package/dist/tests/imagine-input.test.d.ts +6 -0
- package/dist/tests/imagine-input.test.js +283 -0
- package/dist/tests/imagine-synthesis.test.d.ts +7 -0
- package/dist/tests/imagine-synthesis.test.js +380 -0
- package/dist/tests/imagine.test.d.ts +8 -0
- package/dist/tests/imagine.test.js +406 -0
- package/dist/tests/parse.test.d.ts +4 -0
- package/dist/tests/parse.test.js +285 -0
- package/dist/tests/render.test.d.ts +4 -0
- package/dist/tests/render.test.js +236 -0
- package/dist/tests/specify-agents.test.d.ts +4 -0
- package/dist/tests/specify-agents.test.js +352 -0
- package/dist/tests/specify-journeys.test.d.ts +5 -0
- package/dist/tests/specify-journeys.test.js +440 -0
- package/dist/tests/specify-nfr.test.d.ts +4 -0
- package/dist/tests/specify-nfr.test.js +205 -0
- package/dist/tests/specify-roles.test.d.ts +4 -0
- package/dist/tests/specify-roles.test.js +136 -0
- package/dist/tests/specify.test.d.ts +9 -0
- package/dist/tests/specify.test.js +544 -0
- package/dist/tests/state.test.d.ts +4 -0
- package/dist/tests/state.test.js +316 -0
- package/lib/bootstrap.ts +37 -11
- package/lib/compile.ts +426 -4
- package/lib/imagine-agents.ts +53 -7
- package/lib/imagine-synthesis.ts +170 -6
- package/lib/imagine.ts +59 -5
- package/lib/intake.ts +60 -0
- package/lib/parse.ts +2 -1
- package/lib/render.ts +566 -5
- package/lib/specify-agents.ts +25 -3
- package/lib/state.ts +115 -0
- package/package.json +3 -2
- package/templates/gswd/DECISIONS.template.md +3 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GSWD Compile Module — Deterministic contract doc generation
|
|
3
|
+
*
|
|
4
|
+
* Reads spec artifacts (IMAGINE.md, DECISIONS.md, SPEC.md, NFR.md, JOURNEYS.md, INTEGRATIONS.md),
|
|
5
|
+
* parses into a SpecBundle, and generates 4 GSD contract docs deterministically.
|
|
6
|
+
* Zero LLM calls, no randomness, no ordering variance.
|
|
7
|
+
*
|
|
8
|
+
* Schema: GSWD_SPEC.md Section 8.5, 9.2, 11.3
|
|
9
|
+
*/
|
|
10
|
+
export interface ParsedFR {
|
|
11
|
+
id: string;
|
|
12
|
+
description: string;
|
|
13
|
+
scope: 'v1' | 'v2' | 'out';
|
|
14
|
+
priority: 'P0' | 'P1' | 'P2';
|
|
15
|
+
sourceJourneys: string[];
|
|
16
|
+
acceptanceCriteria: string[];
|
|
17
|
+
}
|
|
18
|
+
export interface ParsedNFR {
|
|
19
|
+
id: string;
|
|
20
|
+
description: string;
|
|
21
|
+
category: string;
|
|
22
|
+
threshold: string;
|
|
23
|
+
}
|
|
24
|
+
export interface ParsedJourney {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
type: string;
|
|
28
|
+
linkedFRs: string[];
|
|
29
|
+
linkedIntegrations: string[];
|
|
30
|
+
}
|
|
31
|
+
export interface ParsedIntegration {
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
status: string;
|
|
35
|
+
fallback: string;
|
|
36
|
+
}
|
|
37
|
+
export interface SpecBundle {
|
|
38
|
+
vision: string;
|
|
39
|
+
targetUser: string;
|
|
40
|
+
productDirection: string;
|
|
41
|
+
wedge: string;
|
|
42
|
+
frozenDecisions: string[];
|
|
43
|
+
successMetrics: string[];
|
|
44
|
+
outOfScope: string[];
|
|
45
|
+
risks: string[];
|
|
46
|
+
openQuestions: string[];
|
|
47
|
+
approvals: Record<string, string>;
|
|
48
|
+
frs: ParsedFR[];
|
|
49
|
+
roles: string;
|
|
50
|
+
nfrs: ParsedNFR[];
|
|
51
|
+
journeys: ParsedJourney[];
|
|
52
|
+
integrations: ParsedIntegration[];
|
|
53
|
+
projectSlug: string;
|
|
54
|
+
architectureSummary: string;
|
|
55
|
+
icpHighlights: string;
|
|
56
|
+
competitionLandscape: string;
|
|
57
|
+
gtmPositioning: string;
|
|
58
|
+
journeyInsights: string;
|
|
59
|
+
}
|
|
60
|
+
export declare const SCOPE_ORDER: Record<string, number>;
|
|
61
|
+
export declare const PRIORITY_ORDER: Record<string, number>;
|
|
62
|
+
export declare const NFR_CATEGORY_ORDER: string[];
|
|
63
|
+
export declare const JOURNEY_TYPE_TO_PHASE: Record<string, number>;
|
|
64
|
+
export declare const PHASE_NAMES: Record<number, string>;
|
|
65
|
+
/**
|
|
66
|
+
* Sort FRs by scope (v1 first), then priority (P0 first), then numeric ID ascending.
|
|
67
|
+
*/
|
|
68
|
+
export declare function sortFRs(frs: ParsedFR[]): ParsedFR[];
|
|
69
|
+
/**
|
|
70
|
+
* Parse FR entries from SPEC.md content.
|
|
71
|
+
* Uses ### FR-NNN heading pattern, extracts description, scope, and priority.
|
|
72
|
+
* Accepts a frToJourneys map to populate sourceJourneys.
|
|
73
|
+
*/
|
|
74
|
+
export declare function parseFRsFromSpec(specContent: string, frToJourneys: Map<string, Set<string>>): ParsedFR[];
|
|
75
|
+
/**
|
|
76
|
+
* Parse NFR entries from NFR.md content.
|
|
77
|
+
* Extracts id, description, category (from **Category:** field), threshold (from **Threshold:** field).
|
|
78
|
+
* Sorts by NFR_CATEGORY_ORDER then numeric ID.
|
|
79
|
+
*/
|
|
80
|
+
export declare function parseNFRsFromContent(nfrContent: string): ParsedNFR[];
|
|
81
|
+
/**
|
|
82
|
+
* Parse journey entries from JOURNEYS.md content.
|
|
83
|
+
* Extracts id, name, type, linkedFRs, linkedIntegrations.
|
|
84
|
+
* Sorts by numeric ID.
|
|
85
|
+
*/
|
|
86
|
+
export declare function parseJourneysFromContent(journeysContent: string): ParsedJourney[];
|
|
87
|
+
/**
|
|
88
|
+
* Parse integration entries from INTEGRATIONS.md content.
|
|
89
|
+
* Extracts id, name, status, fallback.
|
|
90
|
+
* Sorts by numeric ID.
|
|
91
|
+
*/
|
|
92
|
+
export declare function parseIntegrationsFromContent(intContent: string): ParsedIntegration[];
|
|
93
|
+
/**
|
|
94
|
+
* Build SpecBundle from file contents.
|
|
95
|
+
*
|
|
96
|
+
* Uses extractHeadingContent() for IMAGINE.md and DECISIONS.md sections.
|
|
97
|
+
* Populates frToJourneys mapping from journey parsing.
|
|
98
|
+
* If statePath provided, reads STATE.json for approvals and projectSlug.
|
|
99
|
+
* If no statePath provided, projectSlug defaults to '' and approvals defaults to {}.
|
|
100
|
+
*/
|
|
101
|
+
export declare function parseSpecBundle(files: {
|
|
102
|
+
imagine: string;
|
|
103
|
+
decisions: string;
|
|
104
|
+
spec: string;
|
|
105
|
+
nfr: string;
|
|
106
|
+
journeys: string;
|
|
107
|
+
integrations: string;
|
|
108
|
+
architecture?: string;
|
|
109
|
+
icp?: string;
|
|
110
|
+
competition?: string;
|
|
111
|
+
gtm?: string;
|
|
112
|
+
researchSummary?: string;
|
|
113
|
+
features?: string;
|
|
114
|
+
}, statePath?: string): SpecBundle;
|
|
115
|
+
/**
|
|
116
|
+
* Generate PROJECT.md content from SpecBundle.
|
|
117
|
+
*
|
|
118
|
+
* Headings: # projectSlug, ## What This Is, ## Target User, ## Problem Statement,
|
|
119
|
+
* ## Wedge / MVP Boundary, ## Success Metrics (bulleted), ## Out of Scope (bulleted).
|
|
120
|
+
* CRITICAL: No Date, Date.now(), or any time-dependent call.
|
|
121
|
+
* CRITICAL: Ends with exactly one trailing newline.
|
|
122
|
+
*/
|
|
123
|
+
export declare function generateProjectDoc(bundle: SpecBundle): string;
|
|
124
|
+
/**
|
|
125
|
+
* Generate REQUIREMENTS.md content from SpecBundle.
|
|
126
|
+
*
|
|
127
|
+
* Structure:
|
|
128
|
+
* - # Requirements
|
|
129
|
+
* - ## Functional Requirements
|
|
130
|
+
* - ### v1 (In Scope) — FRs sorted by priority then ID
|
|
131
|
+
* - ### v2 (Future) — FRs sorted by priority then ID
|
|
132
|
+
* - ## Non-Functional Requirements — grouped by NFR_CATEGORY_ORDER
|
|
133
|
+
* - ## Traceability — FR to journey mapping table (v1 FRs only)
|
|
134
|
+
*
|
|
135
|
+
* CRITICAL: No Date, Date.now(), or any time-dependent call.
|
|
136
|
+
* CRITICAL: Ends with exactly one trailing newline.
|
|
137
|
+
*/
|
|
138
|
+
export declare function generateRequirementsDoc(bundle: SpecBundle): string;
|
|
139
|
+
/**
|
|
140
|
+
* Generate ROADMAP.md content from SpecBundle.
|
|
141
|
+
*
|
|
142
|
+
* Structure:
|
|
143
|
+
* - # Roadmap
|
|
144
|
+
* - ## Overview
|
|
145
|
+
* - ## Phases
|
|
146
|
+
* - ### Phase 1-3: journeys grouped by JOURNEY_TYPE_TO_PHASE, sorted by ID
|
|
147
|
+
* - ### Phase 4: observability+security NFRs sorted by ID
|
|
148
|
+
*
|
|
149
|
+
* CRITICAL: Always emit all 4 phases.
|
|
150
|
+
* CRITICAL: No Date, Date.now(), or any time-dependent call.
|
|
151
|
+
* CRITICAL: Ends with exactly one trailing newline.
|
|
152
|
+
*/
|
|
153
|
+
export declare function generateRoadmapDoc(bundle: SpecBundle): string;
|
|
154
|
+
/**
|
|
155
|
+
* Generate a GSD-format research SUMMARY.md from SpecBundle.
|
|
156
|
+
*
|
|
157
|
+
* Maps GSWD spec content to GSD research template headings.
|
|
158
|
+
* Pure function — no Date calls, no I/O.
|
|
159
|
+
* Versioned with <!-- gswd-schema-version: 1 --> header.
|
|
160
|
+
*/
|
|
161
|
+
export declare function generateResearchSummary(bundle: SpecBundle): string;
|
|
162
|
+
export interface ValidatorFinding {
|
|
163
|
+
check: 'v1_coverage' | 'orphan_requirement' | 'integration_sanity' | 'required_headings';
|
|
164
|
+
id: string;
|
|
165
|
+
issue: string;
|
|
166
|
+
}
|
|
167
|
+
export interface ValidatorResult {
|
|
168
|
+
passed: boolean;
|
|
169
|
+
findings: ValidatorFinding[];
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Validate generated contract docs against the spec bundle.
|
|
173
|
+
*
|
|
174
|
+
* 4 checks:
|
|
175
|
+
* 1. v1_coverage: Every v1 FR ID appears in the generated roadmap content
|
|
176
|
+
* 2. orphan_requirement: Every v1 FR has at least 1 source journey (sourceJourneys.length > 0)
|
|
177
|
+
* 3. integration_sanity: Every integration referenced by any journey is approved or deferred-with-fallback
|
|
178
|
+
* 4. required_headings: All 4 generated docs contain their REQUIRED_HEADINGS entries
|
|
179
|
+
*/
|
|
180
|
+
export declare function validateContracts(generatedDocs: {
|
|
181
|
+
project: string;
|
|
182
|
+
requirements: string;
|
|
183
|
+
roadmap: string;
|
|
184
|
+
state: string;
|
|
185
|
+
}, bundle: SpecBundle): ValidatorResult;
|
|
186
|
+
/**
|
|
187
|
+
* Generate STATE.md content from SpecBundle.
|
|
188
|
+
*
|
|
189
|
+
* Structure:
|
|
190
|
+
* - # Project State
|
|
191
|
+
* - ## Frozen Decisions (numbered list)
|
|
192
|
+
* - ## Approvals (key-value list from bundle.approvals)
|
|
193
|
+
* - ## Open Questions (bulleted)
|
|
194
|
+
* - ## Risks (bulleted)
|
|
195
|
+
*
|
|
196
|
+
* CRITICAL: No Date, Date.now(), or any time-dependent call.
|
|
197
|
+
* CRITICAL: Ends with exactly one trailing newline.
|
|
198
|
+
*/
|
|
199
|
+
export declare function generateStateDoc(bundle: SpecBundle): string;
|
|
200
|
+
/**
|
|
201
|
+
* Read all 6 spec artifact files from a planning directory.
|
|
202
|
+
* Also reads research files from .planning/research/ directory.
|
|
203
|
+
* Returns a content map keyed by artifact type.
|
|
204
|
+
* Missing files return empty string (does not throw).
|
|
205
|
+
*/
|
|
206
|
+
export declare function readSpecArtifacts(planningDir: string): Record<string, string>;
|
|
207
|
+
export interface CompileWorkflowResult {
|
|
208
|
+
passed: boolean;
|
|
209
|
+
error?: string;
|
|
210
|
+
validatorResult?: ValidatorResult;
|
|
211
|
+
filesWritten: string[];
|
|
212
|
+
generated?: {
|
|
213
|
+
project: string;
|
|
214
|
+
requirements: string;
|
|
215
|
+
roadmap: string;
|
|
216
|
+
state: string;
|
|
217
|
+
researchSummary: string;
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Full compile workflow orchestrator.
|
|
222
|
+
*
|
|
223
|
+
* Steps:
|
|
224
|
+
* 1. Check audit gate via checkAuditGate(). If false, return early with error.
|
|
225
|
+
* 2. Update stage status: compile -> in_progress.
|
|
226
|
+
* 3. Read spec artifacts from planningDir.
|
|
227
|
+
* 4. Parse into SpecBundle.
|
|
228
|
+
* 5. Generate all 4 contract docs (pure functions, no I/O).
|
|
229
|
+
* 6. Run validator: validateContracts().
|
|
230
|
+
* 7. If validator FAIL: update state -> fail. Return without writing files.
|
|
231
|
+
* 8. Write all 4 docs atomically via safeWriteFile().
|
|
232
|
+
* 9. Update state: stage_status.compile = 'done', stage = 'compile'.
|
|
233
|
+
* 10. Write checkpoint.
|
|
234
|
+
* 11. Return result with passed=true and filesWritten list.
|
|
235
|
+
*/
|
|
236
|
+
export declare function runCompileWorkflow(options: {
|
|
237
|
+
planningDir: string;
|
|
238
|
+
statePath: string;
|
|
239
|
+
}): CompileWorkflowResult;
|