specfact-cli 0.4.2__py3-none-any.whl → 0.6.8__py3-none-any.whl

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 (66) hide show
  1. specfact_cli/__init__.py +1 -1
  2. specfact_cli/agents/analyze_agent.py +2 -3
  3. specfact_cli/analyzers/__init__.py +2 -1
  4. specfact_cli/analyzers/ambiguity_scanner.py +601 -0
  5. specfact_cli/analyzers/code_analyzer.py +462 -30
  6. specfact_cli/analyzers/constitution_evidence_extractor.py +491 -0
  7. specfact_cli/analyzers/contract_extractor.py +419 -0
  8. specfact_cli/analyzers/control_flow_analyzer.py +281 -0
  9. specfact_cli/analyzers/requirement_extractor.py +337 -0
  10. specfact_cli/analyzers/test_pattern_extractor.py +330 -0
  11. specfact_cli/cli.py +151 -206
  12. specfact_cli/commands/constitution.py +281 -0
  13. specfact_cli/commands/enforce.py +42 -34
  14. specfact_cli/commands/import_cmd.py +481 -152
  15. specfact_cli/commands/init.py +224 -55
  16. specfact_cli/commands/plan.py +2133 -547
  17. specfact_cli/commands/repro.py +100 -78
  18. specfact_cli/commands/sync.py +701 -186
  19. specfact_cli/enrichers/constitution_enricher.py +765 -0
  20. specfact_cli/enrichers/plan_enricher.py +294 -0
  21. specfact_cli/importers/speckit_converter.py +364 -48
  22. specfact_cli/importers/speckit_scanner.py +65 -0
  23. specfact_cli/models/plan.py +42 -0
  24. specfact_cli/resources/mappings/node-async.yaml +49 -0
  25. specfact_cli/resources/mappings/python-async.yaml +47 -0
  26. specfact_cli/resources/mappings/speckit-default.yaml +82 -0
  27. specfact_cli/resources/prompts/specfact-enforce.md +185 -0
  28. specfact_cli/resources/prompts/specfact-import-from-code.md +626 -0
  29. specfact_cli/resources/prompts/specfact-plan-add-feature.md +188 -0
  30. specfact_cli/resources/prompts/specfact-plan-add-story.md +212 -0
  31. specfact_cli/resources/prompts/specfact-plan-compare.md +571 -0
  32. specfact_cli/resources/prompts/specfact-plan-init.md +531 -0
  33. specfact_cli/resources/prompts/specfact-plan-promote.md +352 -0
  34. specfact_cli/resources/prompts/specfact-plan-review.md +1276 -0
  35. specfact_cli/resources/prompts/specfact-plan-select.md +401 -0
  36. specfact_cli/resources/prompts/specfact-plan-update-feature.md +242 -0
  37. specfact_cli/resources/prompts/specfact-plan-update-idea.md +211 -0
  38. specfact_cli/resources/prompts/specfact-repro.md +268 -0
  39. specfact_cli/resources/prompts/specfact-sync.md +497 -0
  40. specfact_cli/resources/schemas/deviation.schema.json +61 -0
  41. specfact_cli/resources/schemas/plan.schema.json +204 -0
  42. specfact_cli/resources/schemas/protocol.schema.json +53 -0
  43. specfact_cli/resources/templates/github-action.yml.j2 +140 -0
  44. specfact_cli/resources/templates/plan.bundle.yaml.j2 +141 -0
  45. specfact_cli/resources/templates/pr-template.md.j2 +58 -0
  46. specfact_cli/resources/templates/protocol.yaml.j2 +24 -0
  47. specfact_cli/resources/templates/telemetry.yaml.example +35 -0
  48. specfact_cli/sync/__init__.py +10 -1
  49. specfact_cli/sync/watcher.py +268 -0
  50. specfact_cli/telemetry.py +440 -0
  51. specfact_cli/utils/acceptance_criteria.py +127 -0
  52. specfact_cli/utils/enrichment_parser.py +445 -0
  53. specfact_cli/utils/feature_keys.py +12 -3
  54. specfact_cli/utils/ide_setup.py +170 -0
  55. specfact_cli/utils/structure.py +179 -2
  56. specfact_cli/utils/yaml_utils.py +33 -0
  57. specfact_cli/validators/repro_checker.py +22 -1
  58. specfact_cli/validators/schema.py +15 -4
  59. specfact_cli-0.6.8.dist-info/METADATA +456 -0
  60. specfact_cli-0.6.8.dist-info/RECORD +99 -0
  61. {specfact_cli-0.4.2.dist-info → specfact_cli-0.6.8.dist-info}/entry_points.txt +1 -0
  62. specfact_cli-0.6.8.dist-info/licenses/LICENSE.md +202 -0
  63. specfact_cli-0.4.2.dist-info/METADATA +0 -370
  64. specfact_cli-0.4.2.dist-info/RECORD +0 -62
  65. specfact_cli-0.4.2.dist-info/licenses/LICENSE.md +0 -61
  66. {specfact_cli-0.4.2.dist-info → specfact_cli-0.6.8.dist-info}/WHEEL +0 -0
@@ -0,0 +1,352 @@
1
+ ---
2
+ description: Promote a plan bundle through development stages with quality gate validation.
3
+ ---
4
+
5
+ # SpecFact Promote Plan Bundle Command
6
+
7
+ ## User Input
8
+
9
+ ```text
10
+ $ARGUMENTS
11
+ ```
12
+
13
+ You **MUST** consider the user input before proceeding (if not empty).
14
+
15
+ ## ⚠️ CRITICAL: CLI Usage Enforcement
16
+
17
+ **YOU MUST ALWAYS USE THE SPECFACT CLI**. Never create artifacts directly or search bundle files.
18
+
19
+ ### Rules
20
+
21
+ 1. **ALWAYS execute CLI first**: Run `specfact plan promote` before any promotion
22
+ 2. **NEVER create YAML/JSON directly**: All plan bundle updates must be CLI-generated
23
+ 3. **NEVER bypass CLI validation**: CLI ensures schema compliance and metadata
24
+ 4. **NEVER search bundle files directly**: Use CLI commands to get plan information (stage, metadata, etc.)
25
+ 5. **Use CLI output as grounding**: Parse CLI output, don't regenerate it or read files directly
26
+
27
+ ### What Happens If You Don't Follow This
28
+
29
+ - ❌ Artifacts may not match CLI schema versions
30
+ - ❌ Missing metadata and telemetry
31
+ - ❌ Format inconsistencies
32
+ - ❌ Validation failures
33
+ - ❌ Out-of-sync information if bundle files are read directly
34
+
35
+ ## ⏸️ Wait States: User Input Required
36
+
37
+ **When user input is required, you MUST wait for the user's response.**
38
+
39
+ ### Wait State Rules
40
+
41
+ 1. **Never assume**: If input is missing, ask and wait
42
+ 2. **Never continue**: Do not proceed until user responds
43
+ 3. **Be explicit**: Clearly state what information you need
44
+ 4. **Provide options**: Give examples or default suggestions
45
+
46
+ ## Goal
47
+
48
+ Help the user promote their plan bundle through development stages (draft → review → approved → released) to track progress and ensure quality gates are met.
49
+
50
+ ## Operating Constraints
51
+
52
+ **STRICTLY READ-WRITE**: This command modifies plan bundle metadata. All updates must be performed by the specfact CLI.
53
+
54
+ **Command**: `specfact plan promote`
55
+
56
+ ### ⚠️ IMPORTANT: Non-Interactive Mode
57
+
58
+ The `promote` command does **NOT** have a `--mode` or `--non-interactive` parameter. To avoid interactive confirmation prompts in CI/CD or non-interactive environments, use the `--force` flag:
59
+
60
+ ```bash
61
+ # Non-interactive/CI/CD usage (bypasses confirmation prompts)
62
+ specfact plan promote --stage review --plan <plan_path> --force
63
+
64
+ # Interactive usage (may prompt for confirmation)
65
+ specfact plan promote --stage review --plan <plan_path>
66
+ ```
67
+
68
+ **Mode Auto-Detection**: The CLI automatically detects operational mode (CI/CD or CoPilot) based on environment for telemetry/routing purposes only. This does **NOT** disable interactive prompts. Mode is detected from:
69
+
70
+ - Environment variables (`SPECFACT_MODE`)
71
+ - CoPilot API availability
72
+ - IDE integration (VS Code/Cursor with CoPilot)
73
+ - Defaults to CI/CD mode if none detected
74
+
75
+ **Note**: Mode auto-detection is used for telemetry and routing only. It does **NOT** affect whether the command prompts for confirmation. Use `--force` to bypass interactive confirmations.
76
+
77
+ ## What This Command Does
78
+
79
+ The `specfact plan promote` command helps move a plan bundle through its lifecycle:
80
+
81
+ - **draft**: Initial state - can be modified freely
82
+ - **review**: Plan is ready for review - should be stable
83
+ - **approved**: Plan approved for implementation
84
+ - **released**: Plan released and should be immutable
85
+
86
+ ## Execution Steps
87
+
88
+ ### 1. List Available Plans Using CLI (REQUIRED FIRST STEP)
89
+
90
+ **⚠️ CRITICAL: NEVER search the repository directly or read bundle files. Always use the CLI to get plan information.**
91
+
92
+ **Execute `specfact plan select` (without arguments) to list all available plans**:
93
+
94
+ ```bash
95
+ specfact plan select
96
+ ```
97
+
98
+ **⚠️ Note on Interactive Prompt**: This command will display a table and then wait for user input. The copilot should:
99
+
100
+ 1. **Capture the table output** that appears before the prompt
101
+ 2. **Parse the table** to extract plan information including **current stage** (already included in the table)
102
+ 3. **Handle the interactive prompt** by either:
103
+ - Using a timeout to cancel after parsing (e.g., `timeout 5 specfact plan select` or similar)
104
+ - Sending an interrupt signal after capturing the output
105
+ - Or in a copilot environment, the output may be available before the prompt blocks
106
+
107
+ **This command will**:
108
+
109
+ - Scan `.specfact/plans/` for all `*.bundle.yaml` files
110
+ - Extract metadata for each plan (name, features, stories, **stage**, modified date, active status)
111
+ - Display a numbered table with all available plans including **current stage** (before the interactive prompt)
112
+
113
+ **The table includes a "Stage" column** showing the current stage for each plan. Use this information - do NOT read bundle files to get the stage.
114
+
115
+ **Parse the CLI output** and present it to the user as a Markdown table:
116
+
117
+ ```markdown
118
+ ## Available Plans
119
+
120
+ | # | Status | Plan Name | Features | Stories | Stage | Modified |
121
+ |---|--------|-----------|----------|---------|-------|----------|
122
+ | 1 | | specfact-cli.2025-11-17T08-52-30.bundle.yaml | 32 | 80 | draft | 2025-11-17T08:52:30 |
123
+ | 2 | [ACTIVE] | main.bundle.yaml | 62 | 73 | approved | 2025-11-17T00:16:00 |
124
+ | 3 | | auto-derived.2025-11-16T23-44-17.bundle.yaml | 19 | 45 | draft | 2025-11-16T23:44:17 |
125
+ ```
126
+
127
+ **After showing the list, extract and display detailed information for each plan** so the user can make an informed decision:
128
+
129
+ ```markdown
130
+ **Plan Details**:
131
+
132
+ 1. **specfact-cli.2025-11-17T08-52-30.bundle.yaml**
133
+ - Features: 32
134
+ - Stories: 80
135
+ - Stage: draft
136
+ - Modified: 2025-11-17T08:52:30
137
+
138
+ 2. **main.bundle.yaml** [ACTIVE]
139
+ - Features: 62
140
+ - Stories: 73
141
+ - Stage: approved
142
+ - Modified: 2025-11-17T00:16:00
143
+
144
+ 3. **auto-derived.2025-11-16T23-44-17.bundle.yaml**
145
+ - Features: 19
146
+ - Stories: 45
147
+ - Stage: draft
148
+ - Modified: 2025-11-16T23:44:17
149
+ ```
150
+
151
+ ### 2. Parse Arguments and Determine Current Stage
152
+
153
+ **Parse user input** to extract:
154
+
155
+ - Target stage (draft, review, approved, or released) - infer from context if not explicit
156
+ - Plan selection - can be:
157
+ - Plan number from the list (e.g., "1", "2", "3")
158
+ - Plan name (e.g., "main.bundle.yaml", "specfact-cli.2025-11-17T08-52-30.bundle.yaml")
159
+ - Special cases: "main plan", "active plan", "last brownfield"
160
+ - Validation preference (default: yes)
161
+ - Force promotion (default: no)
162
+
163
+ #### Get Current Stage from CLI Only
164
+
165
+ **⚠️ CRITICAL: NEVER search bundle files directly**. The `specfact plan select` command already includes the stage in its table output. Use one of these methods:
166
+
167
+ 1. **Parse stage from the table** (already displayed in step 1) - The stage column shows the current stage for each plan
168
+ 2. **Get stage for specific plan** - If you need to verify the current stage for a specific plan, use:
169
+
170
+ ```bash
171
+ specfact plan select <plan_number>
172
+ ```
173
+
174
+ This command will output the plan details including the stage, for example:
175
+
176
+ ```text
177
+ Active plan set to: specfact-import-test-v2.2025-11-17T13-53-31.bundle.yaml
178
+ Features: 44
179
+ Stories: 101
180
+ Stage: review
181
+ ```
182
+
183
+ **Special cases to handle**:
184
+
185
+ - **"main plan"** or **"default plan"**: Use `.specfact/plans/main.bundle.yaml`
186
+ - **"active plan"**: Use the plan marked as `[ACTIVE]` in the list
187
+ - **"last brownfield"** or **"last imported"**: Find the latest file by modification date from the CLI table
188
+ - **Missing target stage**: Infer next logical stage (draft→review→approved→released) based on current stage from CLI output
189
+
190
+ **WAIT STATE**: If plan selection is unclear, show the plan list again and ask the user directly:
191
+
192
+ ```text
193
+ "Which plan bundle would you like to promote?
194
+ (Enter number from the list above, plan name, 'main plan', 'active plan', or 'last brownfield')
195
+ [WAIT FOR USER RESPONSE - DO NOT CONTINUE]"
196
+ ```
197
+
198
+ **If target stage is missing**, infer from context using the current stage from the CLI table output:
199
+
200
+ - If current stage is **draft** → next stage is **review**
201
+ - If current stage is **review** → next stage is **approved**
202
+ - If current stage is **approved** → next stage is **released**
203
+ - If current stage is **released** → cannot promote further
204
+
205
+ If the current stage is not clear from the table, use `specfact plan select <plan_number>` to get the current stage, then infer the next stage.
206
+
207
+ If still unclear, ask:
208
+
209
+ ```text
210
+ "Which stage would you like to promote to?
211
+ (Current stage: draft → Next: review)
212
+ [WAIT FOR USER RESPONSE - DO NOT CONTINUE]"
213
+ ```
214
+
215
+ ### 3. Resolve Plan Path and Current Stage
216
+
217
+ **⚠️ CRITICAL: Use CLI to resolve plan path and get current stage. NEVER search bundle files directly.**
218
+
219
+ **Resolve the plan selection to an actual file path**:
220
+
221
+ - **If user selected a number**: Use the plan name from the CLI table (e.g., plan #1 → `specfact-cli.2025-11-17T08-52-30.bundle.yaml`)
222
+ - **If user selected a plan name**: Use it directly (may need to add `.bundle.yaml` suffix if missing)
223
+ - **If user selected "main plan"**: Use `.specfact/plans/main.bundle.yaml`
224
+ - **If user selected "active plan"**: Use the plan marked as `[ACTIVE]` from the CLI table
225
+ - **If user selected "last brownfield"**: Use the plan with the latest modification date from the CLI table
226
+
227
+ **Get current stage from CLI**:
228
+
229
+ If the current stage is not clear from the table output, use the CLI to get it:
230
+
231
+ ```bash
232
+ # Get plan details including current stage
233
+ specfact plan select <plan_number>
234
+ ```
235
+
236
+ The CLI output will show:
237
+
238
+ - Plan name
239
+ - Features count
240
+ - Stories count
241
+ - **Stage** (current stage)
242
+
243
+ **Verify the plan path exists** by attempting to use it with the CLI. If the CLI reports the plan doesn't exist, show an error and ask the user to select again.
244
+
245
+ ### 4. Execute CLI Command (REQUIRED)
246
+
247
+ **ALWAYS execute the specfact CLI** to perform the promotion:
248
+
249
+ ```bash
250
+ # For non-interactive/CI/CD use (bypasses confirmation prompts)
251
+ specfact plan promote --stage <target_stage> --plan <plan_path> [--validate] --force
252
+
253
+ # For interactive use (may prompt for confirmation)
254
+ specfact plan promote --stage <target_stage> --plan <plan_path> [--validate]
255
+ ```
256
+
257
+ **⚠️ Critical Notes**:
258
+
259
+ - **No `--mode` or `--non-interactive` flag**: The `promote` command does NOT have these parameters
260
+ - **Use `--force` for non-interactive**: The `--force` flag bypasses interactive confirmation prompts when there are partial/missing important categories
261
+ - **Mode auto-detection**: Only affects telemetry/routing, NOT interactive prompts
262
+ - **When `--force` is used**: The command will skip the `prompt_confirm()` call and proceed automatically
263
+
264
+ **The CLI performs**:
265
+
266
+ - Plan bundle loading and validation
267
+ - Current stage checking
268
+ - Promotion rule validation (cannot promote backward, quality gates)
269
+ - **Coverage status validation** (checks for missing critical categories)
270
+ - Metadata updates (stage, promoted_at, promoted_by)
271
+ - Plan bundle saving with updated metadata
272
+
273
+ **Capture CLI output**:
274
+
275
+ - Promotion result (success/failure)
276
+ - Validation results (if enabled)
277
+ - Updated plan bundle path
278
+ - Any error messages or warnings
279
+
280
+ **If CLI execution fails**:
281
+
282
+ - Report the error to the user
283
+ - Do not attempt to update plan bundles manually
284
+ - Suggest fixes based on error message
285
+
286
+ ### 5. Present Results
287
+
288
+ **Present the CLI promotion results** to the user:
289
+
290
+ - **Promotion status**: Show if promotion succeeded or failed
291
+ - **Current stage**: Show the new stage after promotion
292
+ - **Validation results**: Show any validation warnings or errors
293
+ - **Next steps**: Suggest next actions based on promotion result
294
+
295
+ **Example CLI output**:
296
+
297
+ ```markdown
298
+ ✓ Plan Promotion Successful
299
+
300
+ **Plan**: `.specfact/plans/auto-derived-2025-11-04T23-00-41.bundle.yaml`
301
+ **Stage**: draft → review
302
+ **Promoted at**: 2025-11-04T22:02:43.478499+00:00
303
+ **Promoted by**: dom
304
+
305
+ **Validation**: ✓ Passed
306
+ - ✓ All features have at least one story (11 features, 22 stories)
307
+ - ✓ Plan structure is valid
308
+ - ✓ All required fields are present
309
+
310
+ **Next Steps**:
311
+ - Review the plan bundle for completeness
312
+ - Ensure all features have acceptance criteria
313
+ - When ready, promote to approved: `/specfact-cli/specfact-plan-promote approved`
314
+ ```
315
+
316
+ **If there are issues**, present them from CLI output:
317
+
318
+ ```markdown
319
+ ❌ Plan Promotion Failed
320
+
321
+ **Plan**: `.specfact/plans/auto-derived-2025-11-04T23-00-41.bundle.yaml`
322
+ **Current Stage**: draft
323
+ **Target Stage**: review
324
+
325
+ **Validation Errors** (from CLI):
326
+ - FEATURE-001: User Authentication
327
+ - FEATURE-002: Payment Processing
328
+
329
+ **Coverage Validation**:
330
+ - ❌ Constraints & Tradeoffs: Missing (blocks promotion)
331
+ - ⚠️ Data Model: Partial (warns but allows with confirmation)
332
+
333
+ **Fix**:
334
+ - Add at least one story to each feature
335
+ - Run `specfact plan review` to resolve missing critical categories
336
+ **Alternative**: Use `--force` flag to promote anyway (bypasses interactive confirmation, suitable for CI/CD/non-interactive use)
337
+ ```
338
+
339
+ ## Tips for the User
340
+
341
+ - **Start at draft**: New plans begin at draft stage automatically
342
+ - **Review before approving**: Make sure all features have stories and acceptance criteria before promoting to approved
343
+ - **Use validation**: Validation is enabled by default to catch issues early
344
+ - **Stage progression**: You can only move forward (draft → review → approved → released), not backward
345
+ - **Natural language**: You can say "promote plan 1 to review" or "promote main plan to review" or "promote active plan to approved"
346
+ - **List plans first**: The command will automatically list all available plans using `specfact plan select` so you can see what's available
347
+ - **Non-interactive use**: Use `--force` flag to bypass interactive confirmation prompts (required for CI/CD automation)
348
+ - **Interactive prompts**: Without `--force`, the command may prompt for confirmation when there are partial/missing important categories
349
+
350
+ ## Context
351
+
352
+ {ARGS}