sdtk-spec-kit 0.4.4 → 0.4.6

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 (128) hide show
  1. package/README.md +369 -376
  2. package/assets/atlas/build_atlas.py +880 -880
  3. package/assets/atlas/doc_atlas_viewer_template.html +3796 -3782
  4. package/assets/atlas/vendor/mermaid.min.js +2029 -2029
  5. package/assets/keys/spec-entitlement-public.pem +11 -11
  6. package/assets/manifest/toolkit-bundle.manifest.json +178 -178
  7. package/assets/manifest/toolkit-bundle.sha256.txt +83 -83
  8. package/assets/toolkit/toolkit/AGENTS.md +247 -245
  9. package/assets/toolkit/toolkit/README.md +50 -50
  10. package/assets/toolkit/toolkit/SDTK_TOOLKIT.md +207 -208
  11. package/assets/toolkit/toolkit/install.ps1 +21 -21
  12. package/assets/toolkit/toolkit/runtimes/claude/CLAUDE_TEMPLATE.md +92 -92
  13. package/assets/toolkit/toolkit/runtimes/codex/CODEX_TEMPLATE.md +70 -70
  14. package/assets/toolkit/toolkit/scripts/agents/run-claude-task.ps1 +332 -332
  15. package/assets/toolkit/toolkit/scripts/agents/run-codex-task.ps1 +618 -618
  16. package/assets/toolkit/toolkit/scripts/agents/validate-mailbox-formal-artifact.py +86 -86
  17. package/assets/toolkit/toolkit/scripts/init-feature.ps1 +262 -262
  18. package/assets/toolkit/toolkit/scripts/install-codex-skills.ps1 +209 -209
  19. package/assets/toolkit/toolkit/scripts/uninstall-claude-skills.ps1 +139 -139
  20. package/assets/toolkit/toolkit/scripts/uninstall-codex-skills.ps1 +143 -143
  21. package/assets/toolkit/toolkit/sdtk-spec.config.json +27 -27
  22. package/assets/toolkit/toolkit/sdtk-spec.config.profiles.example.json +49 -49
  23. package/assets/toolkit/toolkit/session/SDTK_ACTIVE_BOOTSTRAP.md +47 -47
  24. package/assets/toolkit/toolkit/session/SDTK_AGENT_WORKING_RULES.md +49 -49
  25. package/assets/toolkit/toolkit/skills/sdtk-api-design-spec/SKILL.md +111 -111
  26. package/assets/toolkit/toolkit/skills/sdtk-api-design-spec/scripts/generate_api_design_detail.py +732 -732
  27. package/assets/toolkit/toolkit/skills/sdtk-api-doc/SKILL.md +79 -79
  28. package/assets/toolkit/toolkit/skills/sdtk-arch/SKILL.md +85 -85
  29. package/assets/toolkit/toolkit/skills/sdtk-ba/SKILL.md +46 -46
  30. package/assets/toolkit/toolkit/skills/sdtk-design-layout/SKILL.md +91 -91
  31. package/assets/toolkit/toolkit/skills/sdtk-design-layout/scripts/render_design_layout_images.py +246 -246
  32. package/assets/toolkit/toolkit/skills/sdtk-dev/prompts/code-quality-reviewer.md +34 -34
  33. package/assets/toolkit/toolkit/skills/sdtk-dev/prompts/implementer.md +60 -60
  34. package/assets/toolkit/toolkit/skills/sdtk-dev/prompts/spec-reviewer.md +41 -41
  35. package/assets/toolkit/toolkit/skills/sdtk-dev-backend/SKILL.md +80 -80
  36. package/assets/toolkit/toolkit/skills/sdtk-dev-frontend/SKILL.md +80 -80
  37. package/assets/toolkit/toolkit/skills/sdtk-mailbox-dispatch/SKILL.md +2 -2
  38. package/assets/toolkit/toolkit/skills/sdtk-orchestrator/SKILL.md +17 -17
  39. package/assets/toolkit/toolkit/skills/sdtk-screen-design-spec/SKILL.md +106 -106
  40. package/assets/toolkit/toolkit/skills/sdtk-screen-design-spec/references/excel-image-export.md +50 -50
  41. package/assets/toolkit/toolkit/skills/sdtk-screen-design-spec/references/figma-mcp.md +53 -53
  42. package/assets/toolkit/toolkit/skills/sdtk-screen-design-spec/references/numbering-rules.md +28 -28
  43. package/assets/toolkit/toolkit/skills/sdtk-screen-design-spec/scripts/renumber_flow_action_spec_global.py +136 -136
  44. package/assets/toolkit/toolkit/skills/sdtk-screen-design-spec/scripts/validate_flow_action_spec_numbering.py +414 -414
  45. package/assets/toolkit/toolkit/skills/sdtk-test-case-spec/SKILL.md +110 -110
  46. package/assets/toolkit/toolkit/skills/sdtk-test-case-spec/scripts/validate_test_case_spec.py +97 -97
  47. package/assets/toolkit/toolkit/skills/skills.catalog.yaml +330 -330
  48. package/assets/toolkit/toolkit/skills-claude/api-design-spec/SKILL.md +116 -116
  49. package/assets/toolkit/toolkit/skills-claude/api-doc/SKILL.md +87 -87
  50. package/assets/toolkit/toolkit/skills-claude/arch/SKILL.md +59 -59
  51. package/assets/toolkit/toolkit/skills-claude/ba/SKILL.md +67 -67
  52. package/assets/toolkit/toolkit/skills-claude/design-layout/SKILL.md +91 -91
  53. package/assets/toolkit/toolkit/skills-claude/dev-backend/SKILL.md +73 -73
  54. package/assets/toolkit/toolkit/skills-claude/dev-frontend/SKILL.md +73 -73
  55. package/assets/toolkit/toolkit/skills-claude/mailbox-dispatch/SKILL.md +2 -2
  56. package/assets/toolkit/toolkit/skills-claude/orchestrator/SKILL.md +40 -40
  57. package/assets/toolkit/toolkit/skills-claude/pm/SKILL.md +88 -88
  58. package/assets/toolkit/toolkit/skills-claude/qa/SKILL.md +58 -58
  59. package/assets/toolkit/toolkit/skills-claude/screen-design-spec/SKILL.md +112 -112
  60. package/assets/toolkit/toolkit/skills-claude/test-case-spec/SKILL.md +115 -115
  61. package/assets/toolkit/toolkit/templates/README.md +68 -68
  62. package/assets/toolkit/toolkit/templates/docs/api/API_DESIGN_CREATION_RULES.md +21 -21
  63. package/assets/toolkit/toolkit/templates/docs/api/API_DESIGN_DETAIL_TEMPLATE.md +67 -67
  64. package/assets/toolkit/toolkit/templates/docs/api/API_DESIGN_FLOWCHART_CREATION_RULES.md +468 -468
  65. package/assets/toolkit/toolkit/templates/docs/api/API_ENDPOINTS_TEMPLATE.md +228 -228
  66. package/assets/toolkit/toolkit/templates/docs/api/FEATURE_API_TEMPLATE.yaml +20 -20
  67. package/assets/toolkit/toolkit/templates/docs/api/FLOWCHART_CREATION_RULES.md +20 -20
  68. package/assets/toolkit/toolkit/templates/docs/api/YAML_CREATION_RULES.md +128 -128
  69. package/assets/toolkit/toolkit/templates/docs/api/feature_api_flow_list_TEMPLATE.txt +12 -12
  70. package/assets/toolkit/toolkit/templates/docs/architecture/ARCH_DESIGN_TEMPLATE.md +107 -107
  71. package/assets/toolkit/toolkit/templates/docs/design/DESIGN_LAYOUT_TEMPLATE.md +60 -60
  72. package/assets/toolkit/toolkit/templates/docs/dev/OPS_HANDOFF_CREATION_RULES.md +369 -369
  73. package/assets/toolkit/toolkit/templates/docs/discovery/REQUIREMENT_TEMPLATE.md +155 -155
  74. package/assets/toolkit/toolkit/templates/docs/product/BACKLOG_TEMPLATE.md +50 -50
  75. package/assets/toolkit/toolkit/templates/docs/product/CONDENSED_UPSTREAM_INPUT_TEMPLATE.md +276 -276
  76. package/assets/toolkit/toolkit/templates/docs/product/PRD_TEMPLATE.md +66 -66
  77. package/assets/toolkit/toolkit/templates/docs/product/PROJECT_INITIATION_TEMPLATE.md +98 -98
  78. package/assets/toolkit/toolkit/templates/docs/qa/TEST_CASE_CREATION_RULES.md +129 -129
  79. package/assets/toolkit/toolkit/templates/docs/qa/TEST_CASE_TEMPLATE.md +104 -104
  80. package/assets/toolkit/toolkit/templates/docs/specs/BA_SPEC_TEMPLATE.md +139 -139
  81. package/assets/toolkit/toolkit/templates/docs/specs/FLOW_ACTION_SPEC_TEMPLATE.md +197 -197
  82. package/assets/toolkit/toolkit/templates/handoffs/ARCH_TO_DEV.md +31 -31
  83. package/assets/toolkit/toolkit/templates/handoffs/BA_TO_ARCH.md +28 -28
  84. package/assets/toolkit/toolkit/templates/handoffs/DEV_STAGE1_SPEC_REVIEW.md +26 -26
  85. package/assets/toolkit/toolkit/templates/handoffs/DEV_STAGE2_CODE_QUALITY_REVIEW.md +20 -20
  86. package/assets/toolkit/toolkit/templates/handoffs/DEV_TO_QA.md +33 -33
  87. package/assets/toolkit/toolkit/templates/handoffs/PM_TO_BA.md +29 -29
  88. package/assets/toolkit/toolkit/templates/handoffs/QA_RELEASE_DECISION.md +26 -26
  89. package/assets/toolkit/toolkit/templates/mailbox/AGENT_TASK_TEMPLATE.md +76 -76
  90. package/bin/sdtk.js +15 -15
  91. package/package.json +48 -48
  92. package/src/commands/activate.js +90 -90
  93. package/src/commands/analyze.js +11 -0
  94. package/src/commands/atlas.js +341 -352
  95. package/src/commands/auth.js +85 -85
  96. package/src/commands/entitlement.js +163 -163
  97. package/src/commands/generate.js +209 -147
  98. package/src/commands/help.js +41 -33
  99. package/src/commands/init.js +15 -15
  100. package/src/commands/project.js +51 -51
  101. package/src/commands/runtime.js +239 -239
  102. package/src/index.js +9 -6
  103. package/src/lib/activation-state.js +68 -68
  104. package/src/lib/args.js +116 -116
  105. package/src/lib/atlas-config.js +200 -200
  106. package/src/lib/atlas-runner.js +435 -355
  107. package/src/lib/browser-open.js +39 -39
  108. package/src/lib/capabilities.js +92 -92
  109. package/src/lib/design-handoff-provenance.js +189 -0
  110. package/src/lib/entitlements.js +238 -238
  111. package/src/lib/errors.js +41 -41
  112. package/src/lib/github-access.js +143 -143
  113. package/src/lib/legacy-auth-migration.js +55 -55
  114. package/src/lib/license-activation.js +375 -375
  115. package/src/lib/powershell.js +85 -85
  116. package/src/lib/premium-loader.js +126 -126
  117. package/src/lib/premium-packs.js +331 -331
  118. package/src/lib/premium-sync.js +235 -235
  119. package/src/lib/project-audit.js +332 -332
  120. package/src/lib/project-config.js +108 -108
  121. package/src/lib/project-ingest.js +450 -450
  122. package/src/lib/project-refresh.js +666 -666
  123. package/src/lib/requirement-analysis.js +472 -0
  124. package/src/lib/scope.js +83 -83
  125. package/src/lib/state.js +73 -73
  126. package/src/lib/suite-state.js +70 -70
  127. package/src/lib/toolkit-payload.js +99 -99
  128. package/src/lib/atlas-ask.js +0 -170
@@ -1,150 +1,212 @@
1
- "use strict";
2
-
3
- const fs = require("fs");
4
- const path = require("path");
5
- const { parseFlags, requireFlag, validatePattern } = require("../lib/args");
6
- const { verify, resolvePayloadFile } = require("../lib/toolkit-payload");
7
- const { runScript } = require("../lib/powershell");
8
- const { ValidationError } = require("../lib/errors");
9
-
10
- /**
11
- * Expected 17 output files from generate.
12
- * Placeholders: {KEY} = UPPER_SNAKE_CASE, {PASCAL} = PascalCase, {SNAKE} = lower_snake_case
13
- */
14
- const EXPECTED_OUTPUT_FILES = [
15
- "SHARED_PLANNING.md",
16
- "QUALITY_CHECKLIST.md",
17
- "docs/product/PROJECT_INITIATION_{KEY}.md",
18
- "docs/specs/BA_SPEC_{KEY}.md",
19
- "docs/specs/{KEY}_FLOW_ACTION_SPEC.md",
20
- "docs/product/PRD_{KEY}.md",
21
- "docs/product/BACKLOG_{KEY}.md",
22
- "docs/architecture/ARCH_DESIGN_{KEY}.md",
23
- "docs/database/DATABASE_SPEC_{KEY}.md",
24
- "docs/api/{PASCAL}_API.yaml",
25
- "docs/api/{KEY}_ENDPOINTS.md",
26
- "docs/api/{KEY}_API_DESIGN_DETAIL.md",
27
- "docs/api/{SNAKE}_api_flow_list.txt",
28
- "docs/design/DESIGN_LAYOUT_{KEY}.md",
29
- "docs/dev/FEATURE_IMPL_PLAN_{KEY}.md",
30
- "docs/qa/{KEY}_TEST_CASE.md",
31
- "docs/qa/QA_RELEASE_REPORT_{KEY}.md",
32
- ];
33
-
34
- /**
35
- * Convert text to PascalCase.
36
- * Mirrors init-feature.ps1 ConvertTo-PascalCase: split on non-alphanumeric,
37
- * capitalize first letter of each part, preserve rest of casing per part.
38
- * e.g. "Order Management" -> "OrderManagement", "USER_PROFILE" -> "UserProfile"
39
- */
40
- function toPascalCase(text) {
41
- const parts = text.split(/[^A-Za-z0-9]+/).filter((p) => p.length > 0);
42
- return parts
43
- .map((w) => w.charAt(0).toUpperCase() + w.slice(1))
44
- .join("");
45
- }
46
-
47
- /**
48
- * Derive PascalCase matching init-feature.ps1 logic:
49
- * prefer featureName, fallback to featureKey.
50
- */
51
- function derivePascalCase(featureName, featureKey) {
52
- const fromName = toPascalCase(featureName);
53
- return fromName || toPascalCase(featureKey);
54
- }
55
-
56
- /**
57
- * Convert UPPER_SNAKE_CASE to lower_snake_case.
58
- */
59
- function toSnakeCase(upperSnake) {
60
- return upperSnake.toLowerCase();
61
- }
62
-
63
- /**
64
- * Expand placeholders and return list of expected file paths relative to project root.
65
- */
66
- function expandExpectedFiles(featureKey, featureName) {
67
- const pascal = derivePascalCase(featureName, featureKey);
68
- const snake = toSnakeCase(featureKey);
69
- return EXPECTED_OUTPUT_FILES.map((tmpl) =>
70
- tmpl.replace(/\{KEY\}/g, featureKey).replace(/\{PASCAL\}/g, pascal).replace(/\{SNAKE\}/g, snake)
71
- );
72
- }
73
-
74
- /**
75
- * Verify all 17 expected output files exist under projectPath.
76
- * Returns list of missing files (empty if all present).
77
- */
78
- function verifyOutputContract(projectPath, featureKey, featureName) {
79
- const expected = expandExpectedFiles(featureKey, featureName);
80
- const missing = [];
81
- for (const rel of expected) {
82
- const full = path.join(projectPath, rel);
83
- if (!fs.existsSync(full)) {
84
- missing.push(rel);
85
- }
86
- }
87
- return missing;
88
- }
89
-
90
- const FLAG_DEFS = {
91
- "feature-key": { type: "string" },
92
- "feature-name": { type: "string" },
93
- "project-path": { type: "string" },
94
- force: { type: "boolean" },
95
- "validate-only": { type: "boolean" },
96
- verbose: { type: "boolean" },
97
- };
98
-
99
- const FEATURE_KEY_REGEX = /^[A-Z][A-Z0-9_]*$/;
100
-
1
+ "use strict";
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const { parseFlags, requireFlag, validatePattern } = require("../lib/args");
6
+ const { verify, resolvePayloadFile } = require("../lib/toolkit-payload");
7
+ const { runScript } = require("../lib/powershell");
8
+ const { ValidationError } = require("../lib/errors");
9
+
10
+ /**
11
+ * Expected 17 output files from generate.
12
+ * Placeholders: {KEY} = UPPER_SNAKE_CASE, {PASCAL} = PascalCase, {SNAKE} = lower_snake_case
13
+ */
14
+ const EXPECTED_OUTPUT_FILES = [
15
+ "SHARED_PLANNING.md",
16
+ "QUALITY_CHECKLIST.md",
17
+ "docs/product/PROJECT_INITIATION_{KEY}.md",
18
+ "docs/specs/BA_SPEC_{KEY}.md",
19
+ "docs/specs/{KEY}_FLOW_ACTION_SPEC.md",
20
+ "docs/product/PRD_{KEY}.md",
21
+ "docs/product/BACKLOG_{KEY}.md",
22
+ "docs/architecture/ARCH_DESIGN_{KEY}.md",
23
+ "docs/database/DATABASE_SPEC_{KEY}.md",
24
+ "docs/api/{PASCAL}_API.yaml",
25
+ "docs/api/{KEY}_ENDPOINTS.md",
26
+ "docs/api/{KEY}_API_DESIGN_DETAIL.md",
27
+ "docs/api/{SNAKE}_api_flow_list.txt",
28
+ "docs/design/DESIGN_LAYOUT_{KEY}.md",
29
+ "docs/dev/FEATURE_IMPL_PLAN_{KEY}.md",
30
+ "docs/qa/{KEY}_TEST_CASE.md",
31
+ "docs/qa/QA_RELEASE_REPORT_{KEY}.md",
32
+ ];
33
+
34
+ /**
35
+ * Convert text to PascalCase.
36
+ * Mirrors init-feature.ps1 ConvertTo-PascalCase: split on non-alphanumeric,
37
+ * capitalize first letter of each part, preserve rest of casing per part.
38
+ * e.g. "Order Management" -> "OrderManagement", "USER_PROFILE" -> "UserProfile"
39
+ */
40
+ function toPascalCase(text) {
41
+ const parts = text.split(/[^A-Za-z0-9]+/).filter((p) => p.length > 0);
42
+ return parts
43
+ .map((w) => w.charAt(0).toUpperCase() + w.slice(1))
44
+ .join("");
45
+ }
46
+
47
+ /**
48
+ * Derive PascalCase matching init-feature.ps1 logic:
49
+ * prefer featureName, fallback to featureKey.
50
+ */
51
+ function derivePascalCase(featureName, featureKey) {
52
+ const fromName = toPascalCase(featureName);
53
+ return fromName || toPascalCase(featureKey);
54
+ }
55
+
56
+ /**
57
+ * Convert UPPER_SNAKE_CASE to lower_snake_case.
58
+ */
59
+ function toSnakeCase(upperSnake) {
60
+ return upperSnake.toLowerCase();
61
+ }
62
+
63
+ /**
64
+ * Expand placeholders and return list of expected file paths relative to project root.
65
+ */
66
+ function expandExpectedFiles(featureKey, featureName) {
67
+ const pascal = derivePascalCase(featureName, featureKey);
68
+ const snake = toSnakeCase(featureKey);
69
+ return EXPECTED_OUTPUT_FILES.map((tmpl) =>
70
+ tmpl.replace(/\{KEY\}/g, featureKey).replace(/\{PASCAL\}/g, pascal).replace(/\{SNAKE\}/g, snake)
71
+ );
72
+ }
73
+
74
+ /**
75
+ * Verify all 17 expected output files exist under projectPath.
76
+ * Returns list of missing files (empty if all present).
77
+ */
78
+ function verifyOutputContract(projectPath, featureKey, featureName) {
79
+ const expected = expandExpectedFiles(featureKey, featureName);
80
+ const missing = [];
81
+ for (const rel of expected) {
82
+ const full = path.join(projectPath, rel);
83
+ if (!fs.existsSync(full)) {
84
+ missing.push(rel);
85
+ }
86
+ }
87
+ return missing;
88
+ }
89
+
90
+ const FLAG_DEFS = {
91
+ "feature-key": { type: "string" },
92
+ "feature-name": { type: "string" },
93
+ "project-path": { type: "string" },
94
+ force: { type: "boolean" },
95
+ "validate-only": { type: "boolean" },
96
+ verbose: { type: "boolean" },
97
+ };
98
+
99
+ const FEATURE_KEY_REGEX = /^[A-Z][A-Z0-9_]*$/;
100
+
101
101
  async function cmdGenerate(args) {
102
- const { flags } = parseFlags(args, FLAG_DEFS);
103
-
104
- // Validate required flags
105
- const featureKey = requireFlag(flags, "feature-key", "feature-key");
106
- const featureName = requireFlag(flags, "feature-name", "feature-name");
102
+ const { flags } = parseFlags(args, FLAG_DEFS);
103
+
104
+ // Validate required flags
105
+ const featureKey = requireFlag(flags, "feature-key", "feature-key");
106
+ const featureName = requireFlag(flags, "feature-name", "feature-name");
107
+
108
+ // Validate feature key format
109
+ validatePattern(
110
+ featureKey,
111
+ FEATURE_KEY_REGEX,
112
+ "feature-key",
113
+ "Must be UPPER_SNAKE_CASE (e.g., USER_PROFILE, ORDER_MANAGEMENT)."
114
+ );
115
+
116
+ // Resolve project path
117
+ const projectPath = flags["project-path"]
118
+ ? path.resolve(flags["project-path"])
119
+ : process.cwd();
120
+
121
+ // Verify payload integrity before proceeding
122
+ verify();
123
+
124
+ // Resolve bundled init-feature.ps1
125
+ const generateScript = resolvePayloadFile(
126
+ "toolkit/scripts/init-feature.ps1"
127
+ );
128
+
129
+ // Build PowerShell parameters
130
+ const params = {
131
+ FeatureKey: featureKey,
132
+ FeatureName: featureName,
133
+ ProjectPath: projectPath,
134
+ };
135
+ if (flags.force) params.Force = true;
136
+ if (flags["validate-only"]) params.ValidateOnly = true;
137
+
138
+ console.log(`Generating documentation for feature: ${featureKey}`);
139
+ console.log(` Feature name: ${featureName}`);
140
+ console.log(` Project path: ${projectPath}`);
141
+ if (flags["validate-only"]) {
142
+ console.log(" Mode: validate-only (no files will be written)");
143
+ }
144
+ console.log("");
145
+
146
+ const result = await runScript(generateScript, params, { silent: !flags.verbose });
147
+
148
+ if (result.exitCode !== 0) {
149
+ if (result.stderr) {
150
+ console.error(result.stderr);
151
+ }
152
+ throw new ValidationError(
153
+ `Generation failed (exit code ${result.exitCode}).`
154
+ );
155
+ }
156
+
157
+ // Enforce 17-file output contract (skip for validate-only mode)
158
+ if (!flags["validate-only"]) {
159
+ const missing = verifyOutputContract(projectPath, featureKey, featureName);
160
+ if (missing.length > 0) {
161
+ console.error("\nOutput contract violation -- missing files:");
162
+ for (const f of missing) {
163
+ console.error(` - ${f}`);
164
+ }
165
+ throw new ValidationError(
166
+ `Expected 17 output files but ${missing.length} missing. See list above.`
167
+ );
168
+ }
169
+ console.log("\nAll 17 expected output files verified.");
170
+ }
171
+
172
+ return 0;
173
+ }
107
174
 
108
- // Validate feature key format
109
- validatePattern(
175
+ async function ensureGeneratedScaffold(options) {
176
+ const {
110
177
  featureKey,
111
- FEATURE_KEY_REGEX,
112
- "feature-key",
113
- "Must be UPPER_SNAKE_CASE (e.g., USER_PROFILE, ORDER_MANAGEMENT)."
114
- );
115
-
116
- // Resolve project path
117
- const projectPath = flags["project-path"]
118
- ? path.resolve(flags["project-path"])
119
- : process.cwd();
178
+ featureName,
179
+ projectPath,
180
+ force = false,
181
+ verbose = false,
182
+ verifyPayload = true,
183
+ } = options;
184
+
185
+ const missingBefore = verifyOutputContract(projectPath, featureKey, featureName);
186
+ if (missingBefore.length === 0 && !force) {
187
+ return {
188
+ status: "SCAFFOLD_ALREADY_PRESENT",
189
+ expectedFiles: expandExpectedFiles(featureKey, featureName),
190
+ missingBefore,
191
+ missingAfter: [],
192
+ };
193
+ }
120
194
 
121
- // Verify payload integrity before proceeding
122
- verify();
195
+ if (verifyPayload) {
196
+ verify();
197
+ }
123
198
 
124
- // Resolve bundled init-feature.ps1
125
199
  const generateScript = resolvePayloadFile(
126
200
  "toolkit/scripts/init-feature.ps1"
127
201
  );
128
-
129
- // Build PowerShell parameters
130
202
  const params = {
131
203
  FeatureKey: featureKey,
132
204
  FeatureName: featureName,
133
205
  ProjectPath: projectPath,
134
206
  };
135
- if (flags.force) params.Force = true;
136
- if (flags["validate-only"]) params.ValidateOnly = true;
137
-
138
- console.log(`Generating documentation for feature: ${featureKey}`);
139
- console.log(` Feature name: ${featureName}`);
140
- console.log(` Project path: ${projectPath}`);
141
- if (flags["validate-only"]) {
142
- console.log(" Mode: validate-only (no files will be written)");
143
- }
144
- console.log("");
145
-
146
- const result = await runScript(generateScript, params, { silent: !flags.verbose });
207
+ if (force) params.Force = true;
147
208
 
209
+ const result = await runScript(generateScript, params, { silent: !verbose });
148
210
  if (result.exitCode !== 0) {
149
211
  if (result.stderr) {
150
212
  console.error(result.stderr);
@@ -154,24 +216,24 @@ async function cmdGenerate(args) {
154
216
  );
155
217
  }
156
218
 
157
- // Enforce 17-file output contract (skip for validate-only mode)
158
- if (!flags["validate-only"]) {
159
- const missing = verifyOutputContract(projectPath, featureKey, featureName);
160
- if (missing.length > 0) {
161
- console.error("\nOutput contract violation -- missing files:");
162
- for (const f of missing) {
163
- console.error(` - ${f}`);
164
- }
165
- throw new ValidationError(
166
- `Expected 17 output files but ${missing.length} missing. See list above.`
167
- );
168
- }
169
- console.log("\nAll 17 expected output files verified.");
219
+ const missingAfter = verifyOutputContract(projectPath, featureKey, featureName);
220
+ if (missingAfter.length > 0) {
221
+ throw new ValidationError(
222
+ `Expected 17 output files but ${missingAfter.length} missing after scaffold bootstrap.`
223
+ );
170
224
  }
171
225
 
172
- return 0;
226
+ return {
227
+ status: missingBefore.length > 0 ? "SCAFFOLD_CREATED" : "SCAFFOLD_ALREADY_PRESENT",
228
+ expectedFiles: expandExpectedFiles(featureKey, featureName),
229
+ missingBefore,
230
+ missingAfter,
231
+ };
173
232
  }
174
233
 
175
234
  module.exports = {
176
235
  cmdGenerate,
236
+ expandExpectedFiles,
237
+ verifyOutputContract,
238
+ ensureGeneratedScaffold,
177
239
  };
@@ -9,13 +9,14 @@ function cmdHelp() {
9
9
  "",
10
10
  "Commands:",
11
11
  " init Initialize SDTK-SPEC workspace (runtime adapter + config)",
12
- " atlas Build and browse a local document graph for your project",
12
+ " atlas Build and browse the free local Atlas compatibility graph",
13
13
  " runtime Manage runtime asset installation (install, uninstall, status)",
14
14
  " update Refresh the npm package and optionally re-apply managed project/runtime assets",
15
15
  " auth Manage GitHub authentication and entitlement",
16
16
  " activate Activate Pro features with a license key (public activation flow)",
17
- " entitlement Inspect local entitlement and capability state",
18
- " generate Scaffold feature documentation from templates (17 files)",
17
+ " entitlement Inspect local entitlement and capability state",
18
+ " generate Create the standard 17-file feature scaffold from templates",
19
+ " analyze Preserve requirement source, bootstrap scaffold, and create an agent task packet",
19
20
  "",
20
21
  "Init options:",
21
22
  " --runtime <codex|claude> Runtime adapter (default: codex)",
@@ -84,21 +85,28 @@ function cmdHelp() {
84
85
  " sdtk-spec entitlement status Show local entitlement and capability state (local-only, no network)",
85
86
  " sdtk-spec entitlement sync Fetch and verify a signed entitlement manifest; install required SPEC packs",
86
87
  "",
87
- "Generate options:",
88
+ "Generate options:",
88
89
  " --feature-key <KEY> Feature identifier (UPPER_SNAKE_CASE, required)",
89
90
  " --feature-name \"<text>\" Human-readable feature name (required)",
90
91
  " --project-path <path> Target project directory (default: cwd)",
91
92
  " --force Overwrite existing files",
92
93
  " --validate-only Validate templates without writing files",
93
- " --verbose Show detailed PowerShell script output",
94
- "",
95
- "Atlas subcommands:",
94
+ " --verbose Show detailed PowerShell script output",
95
+ "",
96
+ "Analyze options:",
97
+ " --source <file> Customer requirement Markdown/text file (required)",
98
+ " --feature-key <KEY> Feature identifier (UPPER_SNAKE_CASE, required)",
99
+ " --feature-name \"<text>\" Human-readable feature name (required)",
100
+ " --project-path <path> Target project directory (default: cwd)",
101
+ " --force Overwrite managed analysis artifacts",
102
+ " --json Print result summary as JSON",
103
+ "",
104
+ "Atlas subcommands (free compatibility path):",
96
105
  " sdtk-spec atlas init Initialize Atlas config and run first build (opens viewer)",
97
106
  " sdtk-spec atlas build Rebuild the local document graph from project markdown",
98
107
  " sdtk-spec atlas open Open the last successful atlas build in a local browser",
99
108
  " sdtk-spec atlas watch Watch for markdown changes and rebuild automatically",
100
109
  " sdtk-spec atlas status Show initialization state and last build summary",
101
- " sdtk-spec atlas ask Ask grounded questions over local Atlas docs (Pro)",
102
110
  "",
103
111
  "Project subcommands (Pro):",
104
112
  " sdtk-spec project ingest Build reusable project census and profile foundation from an existing repo (Pro)",
@@ -134,22 +142,14 @@ function cmdHelp() {
134
142
  " --port <port> Viewer server port (default: 8765)",
135
143
  " --no-open Skip opening the viewer after initial build",
136
144
  "",
137
- "Atlas options (ask):",
138
- " --project-path <path> Target project directory (default: cwd)",
139
- " --output-dir <path> Atlas output directory (default: <project>/.sdtk/atlas)",
140
- " --question <text> Question to ask (required; or provide as positional argument)",
141
- " --source <path-or-id> Explicit grounding hint (repeatable)",
142
- " --max-docs <number> Max documents hint passed to premium pack (default: 12)",
143
- " --json Print answer as JSON",
144
- " --verbose Show detailed output",
145
- "",
146
- "Atlas notes:",
147
- " - Free Atlas commands (init, build, open, watch, status) require no authentication or entitlement.",
148
- " - atlas ask is a Pro feature. It requires a valid Pro entitlement and a cached premium pack.",
149
- " - Run 'sdtk-spec entitlement sync' to install the required premium pack for atlas ask.",
150
- " - Atlas scans markdown files and builds a local document graph and static viewer.",
151
- " - Artifacts are written under <project>/.sdtk/atlas/ (project-local, not global).",
152
- " - Viewer server binds to 127.0.0.1 by default (loopback only).",
145
+ "Atlas notes:",
146
+ " - Free Atlas commands (init, build, open, watch, status) require no authentication or entitlement.",
147
+ " - Atlas scans markdown files and builds a local document graph and static viewer.",
148
+ " - sdtk-spec atlas is the R1 compatibility path; SDTK-WIKI is the canonical home for new wiki work.",
149
+ " - Artifacts are written under <project>/.sdtk/atlas/ (project-local compatibility output).",
150
+ " - Native SDTK-WIKI uses <project>/.sdtk/wiki/ and <project>/.sdtk/wiki/graph/.",
151
+ " - The old SPEC ask command path is not supported; native Ask is sdtk-wiki ask with capability wiki.ask.",
152
+ " - Viewer server binds to 127.0.0.1 by default (loopback only).",
153
153
  " - Requires Python 3.8+ in PATH for the build step.",
154
154
  "",
155
155
  "Project ingest options (Pro):",
@@ -200,11 +200,20 @@ function cmdHelp() {
200
200
  " - project refresh does not perform a read-only audit; use 'project audit' for that.",
201
201
  " - Maintainer-root guard: project refresh refuses the SDTK maintainer monorepo root as a refresh target.",
202
202
  "",
203
- "Generate behavior:",
204
- " The generate command creates 17 scaffold files with TBD placeholders.",
205
- " Scaffolds define document structure for each SDLC phase.",
206
- " Content is filled in by agents or manually (PM -> BA -> ARCH -> DEV -> QA).",
207
- " Output is written to docs/ subdirectories under the project path.",
203
+ "Generate behavior:",
204
+ " The generate command creates the standard 17-file scaffold with TBD placeholders.",
205
+ " Scaffolds define document structure for each SDLC phase.",
206
+ " Content is filled in by agents or manually (PM -> BA -> ARCH -> DEV -> QA).",
207
+ " Output is written to docs/ subdirectories under the project path.",
208
+ "",
209
+ "Analyze behavior:",
210
+ " The analyze command preserves a requirement source under .sdtk/spec/requirements/.",
211
+ " It bootstraps the standard 17-file scaffold when missing by reusing generate behavior.",
212
+ " It creates .sdtk/spec/tasks/<KEY>/ task packets for PM/BA/ARCH/DEV/QA agent analysis.",
213
+ " It reports likely mojibake/encoding risk and source hash traceability.",
214
+ " It does not fully understand arbitrary requirements by itself.",
215
+ " PM/BA/ARCH agents complete source-backed analysis inside the generated artifacts.",
216
+ " It does not modify the source project and does not create .sdtk/atlas.",
208
217
  "",
209
218
  "Global options:",
210
219
  " -h, --help Show this help",
@@ -233,8 +242,6 @@ function cmdHelp() {
233
242
  " sdtk-spec atlas open --project-path ./my-project --no-open",
234
243
  " sdtk-spec atlas watch --project-path ./my-project",
235
244
  " sdtk-spec atlas status --project-path ./my-project",
236
- " sdtk-spec atlas ask --project-path ./my-project --question \"How do I install this toolkit?\"",
237
- " sdtk-spec atlas ask --project-path ./my-project --question \"What does this project say about deployment?\" --json",
238
245
  " sdtk-spec init --runtime codex",
239
246
  " sdtk-spec init --runtime codex --runtime-scope project --project-path ./my-project",
240
247
  " sdtk-spec init --runtime claude --project-path ./my-project",
@@ -243,8 +250,9 @@ function cmdHelp() {
243
250
  " sdtk-spec update --version 1.2.3 --runtime codex --scope user",
244
251
  " sdtk-spec auth --token ghp_xxxxxxxxxxxx",
245
252
  " sdtk-spec auth --verify",
246
- ' sdtk-spec generate --feature-key USER_PROFILE --feature-name "User Profile"',
247
- " sdtk-spec generate --feature-key ORDER_MGMT --feature-name \"Order Management\" --validate-only",
253
+ ' sdtk-spec generate --feature-key USER_PROFILE --feature-name "User Profile"',
254
+ " sdtk-spec generate --feature-key ORDER_MGMT --feature-name \"Order Management\" --validate-only",
255
+ " sdtk-spec analyze --source ./requirements.md --feature-key ORDER_PORTAL --feature-name \"Order Portal\"",
248
256
  " sdtk-spec init --runtime claude --runtime-scope user",
249
257
  " sdtk-spec runtime install --runtime claude --scope project",
250
258
  " sdtk-spec runtime install --runtime codex --scope user",
@@ -96,21 +96,21 @@ async function cmdInit(args) {
96
96
  console.log(`Project-local Codex skills were installed into ${path.join(projectPath, ".codex", "skills")}.`);
97
97
  console.log("Launch Codex with CODEX_HOME=<project>/.codex to activate that local runtime home.");
98
98
  }
99
- console.log("");
100
- console.log("Next steps:");
101
- console.log(" 1. Review and customize sdtk-spec.config.json for your project stack.");
102
- console.log(" 2. Review bootstrap guidance:");
103
- console.log(` ${path.join(projectPath, "AGENTS.md")}`);
104
- if (runtime === "claude") {
105
- console.log(` ${path.join(projectPath, "CLAUDE.md")}`);
106
- } else if (runtime === "codex") {
107
- console.log(` ${path.join(projectPath, "CODEX.md")}`);
108
- }
109
- console.log(` ${path.join(projectPath, "governance", "ai", "session", "SDTK_ACTIVE_BOOTSTRAP.md")}`);
110
- console.log(` ${path.join(projectPath, "governance", "ai", "session", "SDTK_AGENT_WORKING_RULES.md")}`);
111
- console.log(' 3. Run "sdtk-spec generate --feature-key <KEY> --feature-name <name>" to scaffold docs.');
112
- return 0;
113
- }
99
+ console.log("");
100
+ console.log("Next steps:");
101
+ console.log(" 1. Review and customize sdtk-spec.config.json for your project stack.");
102
+ console.log(" 2. Review bootstrap guidance:");
103
+ console.log(` ${path.join(projectPath, "AGENTS.md")}`);
104
+ if (runtime === "claude") {
105
+ console.log(` ${path.join(projectPath, "CLAUDE.md")}`);
106
+ } else if (runtime === "codex") {
107
+ console.log(` ${path.join(projectPath, "CODEX.md")}`);
108
+ }
109
+ console.log(` ${path.join(projectPath, "governance", "ai", "session", "SDTK_ACTIVE_BOOTSTRAP.md")}`);
110
+ console.log(` ${path.join(projectPath, "governance", "ai", "session", "SDTK_AGENT_WORKING_RULES.md")}`);
111
+ console.log(' 3. Run "sdtk-spec generate --feature-key <KEY> --feature-name <name>" to scaffold docs.');
112
+ return 0;
113
+ }
114
114
 
115
115
  module.exports = {
116
116
  cmdInit,
@@ -1,51 +1,51 @@
1
- "use strict";
2
-
3
- const { runProjectIngest } = require("../lib/project-ingest");
4
- const { runProjectAudit } = require("../lib/project-audit");
5
- const { runProjectRefresh } = require("../lib/project-refresh");
6
- const { ValidationError } = require("../lib/errors");
7
-
8
- const PROJECT_SUBCOMMANDS = new Set(["ingest", "audit", "refresh"]);
9
-
10
- /**
11
- * Top-level dispatcher for `sdtk-spec project <subcommand>`.
12
- *
13
- * Subcommands (BK-083 R1):
14
- * ingest - Build reusable project census and profile foundation (Pro)
15
- *
16
- * Subcommands (BK-086 R1):
17
- * audit - Read-only audit report: readiness, gaps, risks, next steps (Pro)
18
- *
19
- * Subcommands (BK-085 R1):
20
- * refresh - Incremental managed refresh of .sdtk/project/ artifacts (Pro)
21
- *
22
- * @param {string[]} args - Remaining argv after "project"
23
- * @returns {Promise<number>} CLI exit code
24
- */
25
- async function cmdProject(args) {
26
- if (!args || args.length === 0) {
27
- console.error("[project] Usage: sdtk-spec project <subcommand> [options]");
28
- console.error(" Premium subcommands: ingest, audit, refresh (requires Pro entitlement)");
29
- console.error(" Run 'sdtk-spec --help' for full usage.");
30
- return 1;
31
- }
32
-
33
- const [subcommand, ...rest] = args;
34
-
35
- if (!PROJECT_SUBCOMMANDS.has(subcommand)) {
36
- throw new ValidationError(
37
- `Unknown project subcommand: "${subcommand}". Valid subcommands: ingest, audit, refresh.`
38
- );
39
- }
40
-
41
- switch (subcommand) {
42
- case "ingest":
43
- return runProjectIngest(rest);
44
- case "audit":
45
- return runProjectAudit(rest);
46
- case "refresh":
47
- return runProjectRefresh(rest);
48
- }
49
- }
50
-
51
- module.exports = { cmdProject };
1
+ "use strict";
2
+
3
+ const { runProjectIngest } = require("../lib/project-ingest");
4
+ const { runProjectAudit } = require("../lib/project-audit");
5
+ const { runProjectRefresh } = require("../lib/project-refresh");
6
+ const { ValidationError } = require("../lib/errors");
7
+
8
+ const PROJECT_SUBCOMMANDS = new Set(["ingest", "audit", "refresh"]);
9
+
10
+ /**
11
+ * Top-level dispatcher for `sdtk-spec project <subcommand>`.
12
+ *
13
+ * Subcommands (BK-083 R1):
14
+ * ingest - Build reusable project census and profile foundation (Pro)
15
+ *
16
+ * Subcommands (BK-086 R1):
17
+ * audit - Read-only audit report: readiness, gaps, risks, next steps (Pro)
18
+ *
19
+ * Subcommands (BK-085 R1):
20
+ * refresh - Incremental managed refresh of .sdtk/project/ artifacts (Pro)
21
+ *
22
+ * @param {string[]} args - Remaining argv after "project"
23
+ * @returns {Promise<number>} CLI exit code
24
+ */
25
+ async function cmdProject(args) {
26
+ if (!args || args.length === 0) {
27
+ console.error("[project] Usage: sdtk-spec project <subcommand> [options]");
28
+ console.error(" Premium subcommands: ingest, audit, refresh (requires Pro entitlement)");
29
+ console.error(" Run 'sdtk-spec --help' for full usage.");
30
+ return 1;
31
+ }
32
+
33
+ const [subcommand, ...rest] = args;
34
+
35
+ if (!PROJECT_SUBCOMMANDS.has(subcommand)) {
36
+ throw new ValidationError(
37
+ `Unknown project subcommand: "${subcommand}". Valid subcommands: ingest, audit, refresh.`
38
+ );
39
+ }
40
+
41
+ switch (subcommand) {
42
+ case "ingest":
43
+ return runProjectIngest(rest);
44
+ case "audit":
45
+ return runProjectAudit(rest);
46
+ case "refresh":
47
+ return runProjectRefresh(rest);
48
+ }
49
+ }
50
+
51
+ module.exports = { cmdProject };