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,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GSWD Audit Module — Coverage matrix, checks, report generation, auto-fix, workflow
|
|
3
|
+
*
|
|
4
|
+
* Mechanically checks spec artifacts for coverage gaps, cross-reference integrity,
|
|
5
|
+
* and heading compliance. Produces PASS or actionable FAIL checklist in AUDIT.md.
|
|
6
|
+
*
|
|
7
|
+
* Schema: GSWD_SPEC.md Section 8.4 (audit workflow), 6.1-6.3 (IDs and headings)
|
|
8
|
+
*/
|
|
9
|
+
import { type ExtractedId } from './parse.js';
|
|
10
|
+
export interface Finding {
|
|
11
|
+
id: string;
|
|
12
|
+
issue: string;
|
|
13
|
+
fix: string;
|
|
14
|
+
severity: 'error' | 'warning';
|
|
15
|
+
}
|
|
16
|
+
export interface CheckResult {
|
|
17
|
+
check: string;
|
|
18
|
+
passed: boolean;
|
|
19
|
+
findings: Finding[];
|
|
20
|
+
}
|
|
21
|
+
export interface CoverageMatrix {
|
|
22
|
+
journeyToFRs: Map<string, Set<string>>;
|
|
23
|
+
frToJourneys: Map<string, Set<string>>;
|
|
24
|
+
journeyToTests: Map<string, string[]>;
|
|
25
|
+
journeyToIntegrations: Map<string, Set<string>>;
|
|
26
|
+
integrationStatus: Map<string, {
|
|
27
|
+
status: string;
|
|
28
|
+
hasFallback: boolean;
|
|
29
|
+
}>;
|
|
30
|
+
frScopes: Map<string, string>;
|
|
31
|
+
allJourneyIds: string[];
|
|
32
|
+
allFRIds: string[];
|
|
33
|
+
allNFRIds: string[];
|
|
34
|
+
allIntegrationIds: string[];
|
|
35
|
+
}
|
|
36
|
+
export interface AuditResult {
|
|
37
|
+
passed: boolean;
|
|
38
|
+
checks: CheckResult[];
|
|
39
|
+
matrix: CoverageMatrix;
|
|
40
|
+
summary: {
|
|
41
|
+
total_checks: number;
|
|
42
|
+
passed: number;
|
|
43
|
+
failed: number;
|
|
44
|
+
findings_count: number;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Extract all ID types from artifact content using parse.ts extractIds().
|
|
49
|
+
* Works on content strings (not file paths) for testability.
|
|
50
|
+
*/
|
|
51
|
+
export declare function extractArtifactIds(content: string): {
|
|
52
|
+
journeyIds: ExtractedId[];
|
|
53
|
+
frIds: ExtractedId[];
|
|
54
|
+
nfrIds: ExtractedId[];
|
|
55
|
+
integrationIds: ExtractedId[];
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Split JOURNEYS.md by ### J-NNN headings.
|
|
59
|
+
* Returns map of normalized journey ID -> section content.
|
|
60
|
+
*/
|
|
61
|
+
export declare function parseJourneySections(journeysContent: string): Map<string, string>;
|
|
62
|
+
/**
|
|
63
|
+
* Extract FR scope tags from SPEC.md content.
|
|
64
|
+
* Looks for patterns: **Scope:** v1, Scope: v2, etc.
|
|
65
|
+
* Defaults to "v1" if scope not found (conservative).
|
|
66
|
+
*/
|
|
67
|
+
export declare function parseFRScope(specContent: string): Map<string, string>;
|
|
68
|
+
/**
|
|
69
|
+
* Parse integration statuses from INTEGRATIONS.md.
|
|
70
|
+
* Looks for Status: and Fallback: fields per integration.
|
|
71
|
+
*/
|
|
72
|
+
export declare function parseIntegrationStatus(integrationsContent: string): Map<string, {
|
|
73
|
+
status: string;
|
|
74
|
+
hasFallback: boolean;
|
|
75
|
+
}>;
|
|
76
|
+
/**
|
|
77
|
+
* Build the full coverage matrix from spec artifact contents.
|
|
78
|
+
*/
|
|
79
|
+
export declare function buildCoverageMatrix(files: {
|
|
80
|
+
journeys?: string;
|
|
81
|
+
spec?: string;
|
|
82
|
+
nfr?: string;
|
|
83
|
+
integrations?: string;
|
|
84
|
+
architecture?: string;
|
|
85
|
+
}): CoverageMatrix;
|
|
86
|
+
/**
|
|
87
|
+
* Check: Every journey references >= 1 FR (AUDT-02 partial)
|
|
88
|
+
*/
|
|
89
|
+
export declare function checkJourneyFRCoverage(matrix: CoverageMatrix): CheckResult;
|
|
90
|
+
/**
|
|
91
|
+
* Check: Every journey has >= 1 acceptance test (AUDT-02 partial)
|
|
92
|
+
*/
|
|
93
|
+
export declare function checkJourneyTestCoverage(matrix: CoverageMatrix): CheckResult;
|
|
94
|
+
/**
|
|
95
|
+
* Check: Every Scope:v1 FR is referenced by >= 1 journey (AUDT-03)
|
|
96
|
+
* Skips v2 and out-of-scope FRs.
|
|
97
|
+
*/
|
|
98
|
+
export declare function checkOrphanV1FRs(matrix: CoverageMatrix): CheckResult;
|
|
99
|
+
/**
|
|
100
|
+
* Check: No unapproved integration referenced by v1 journey without fallback (AUDT-04)
|
|
101
|
+
*/
|
|
102
|
+
export declare function checkIntegrationApproval(matrix: CoverageMatrix): CheckResult;
|
|
103
|
+
/**
|
|
104
|
+
* Check: All required headings exist in artifact files (AUDT-05)
|
|
105
|
+
*/
|
|
106
|
+
export declare function checkRequiredHeadings(files: Record<string, string>): CheckResult;
|
|
107
|
+
/**
|
|
108
|
+
* Run all audit checks and return structured result.
|
|
109
|
+
*/
|
|
110
|
+
export declare function runAudit(files: {
|
|
111
|
+
journeys?: string;
|
|
112
|
+
spec?: string;
|
|
113
|
+
nfr?: string;
|
|
114
|
+
integrations?: string;
|
|
115
|
+
architecture?: string;
|
|
116
|
+
}): AuditResult;
|
|
117
|
+
/**
|
|
118
|
+
* Format coverage matrix as a markdown table.
|
|
119
|
+
* Sorted by journey ID ascending.
|
|
120
|
+
*/
|
|
121
|
+
export declare function formatCoverageMatrixTable(matrix: CoverageMatrix): string;
|
|
122
|
+
/**
|
|
123
|
+
* Format a single check result as a markdown section.
|
|
124
|
+
*/
|
|
125
|
+
export declare function formatCheckSection(result: CheckResult): string;
|
|
126
|
+
/**
|
|
127
|
+
* Generate full AUDIT.md report content from audit result.
|
|
128
|
+
* Groups findings by check type. FAIL includes actionable checklist.
|
|
129
|
+
*/
|
|
130
|
+
export declare function generateAuditReport(result: AuditResult): string;
|
|
131
|
+
export interface AutoFixChange {
|
|
132
|
+
file: string;
|
|
133
|
+
change: string;
|
|
134
|
+
finding: Finding;
|
|
135
|
+
}
|
|
136
|
+
export interface AutoFixResult {
|
|
137
|
+
applied: AutoFixChange[];
|
|
138
|
+
skipped: Finding[];
|
|
139
|
+
updatedFiles: Map<string, string>;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Apply surgical auto-fixes to spec artifacts.
|
|
143
|
+
*
|
|
144
|
+
* CAN do:
|
|
145
|
+
* - Add stub acceptance tests for journeys missing them
|
|
146
|
+
* - Add fallback stubs for unapproved integrations
|
|
147
|
+
*
|
|
148
|
+
* CANNOT do:
|
|
149
|
+
* - Invent new FRs, journeys, or integrations
|
|
150
|
+
* - Approve paid integrations
|
|
151
|
+
* - Change existing content (only append)
|
|
152
|
+
*/
|
|
153
|
+
export declare function applyAutoFix(result: AuditResult, files: Record<string, string>): AutoFixResult;
|
|
154
|
+
/**
|
|
155
|
+
* Check audit gate: returns true ONLY when audit status is "pass".
|
|
156
|
+
* Fail-closed: returns false for any non-"pass" state, including read errors.
|
|
157
|
+
*/
|
|
158
|
+
export declare function checkAuditGate(statePath: string): boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Update STATE.json with audit result.
|
|
161
|
+
* Sets stage_status.audit to "pass" or "fail".
|
|
162
|
+
* On pass: also updates stage to "audit".
|
|
163
|
+
*/
|
|
164
|
+
export declare function updateAuditState(statePath: string, passed: boolean): void;
|
|
165
|
+
export interface AuditWorkflowResult {
|
|
166
|
+
passed: boolean;
|
|
167
|
+
auditResult: AuditResult;
|
|
168
|
+
reportPath: string;
|
|
169
|
+
autoFixCycles: number;
|
|
170
|
+
autoFixChanges: AutoFixChange[];
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Read all spec artifact files from a planning directory.
|
|
174
|
+
* Returns a content map. Missing files get empty string (audit checks will flag them).
|
|
175
|
+
*/
|
|
176
|
+
export declare function readArtifactFiles(planningDir: string): Record<string, string>;
|
|
177
|
+
/**
|
|
178
|
+
* Write AUDIT.md atomically to the planning directory.
|
|
179
|
+
* Returns the written file path.
|
|
180
|
+
*/
|
|
181
|
+
export declare function writeAuditReport(planningDir: string, reportContent: string): string;
|
|
182
|
+
/**
|
|
183
|
+
* Returns the list of artifact file names that audit checks.
|
|
184
|
+
*/
|
|
185
|
+
export declare function getAuditableFileTypes(): string[];
|
|
186
|
+
/**
|
|
187
|
+
* Full audit workflow orchestrator.
|
|
188
|
+
*
|
|
189
|
+
* Steps:
|
|
190
|
+
* 1. Update state -> in_progress
|
|
191
|
+
* 2. Read all artifact files
|
|
192
|
+
* 3. Run audit
|
|
193
|
+
* 4. If PASS -> generate report, write AUDIT.md, update state -> pass, write checkpoint, return
|
|
194
|
+
* 5. If FAIL and autoFix enabled:
|
|
195
|
+
* - Run auto-fix cycles (max 2 by default per GSWD_SPEC Section 10.4)
|
|
196
|
+
* - Write fixed files to disk after each cycle
|
|
197
|
+
* - Re-read files and re-run audit
|
|
198
|
+
* 6. Generate report, write AUDIT.md, update state -> pass or fail, write checkpoint
|
|
199
|
+
*/
|
|
200
|
+
export declare function runAuditWorkflow(options: {
|
|
201
|
+
planningDir: string;
|
|
202
|
+
statePath: string;
|
|
203
|
+
autoFix?: boolean;
|
|
204
|
+
maxCycles?: number;
|
|
205
|
+
}): AuditWorkflowResult;
|