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,401 @@
1
+ ---
2
+ description: Select active plan from available plan bundles
3
+ ---
4
+
5
+ # SpecFact Plan Select Command
6
+
7
+ ## ⚠️ CRITICAL: This is a CLI Usage Prompt, NOT an Implementation Guide
8
+
9
+ **THIS PROMPT IS FOR USING THE EXISTING CLI COMMAND, NOT FOR IMPLEMENTING IT.**
10
+
11
+ ### Quick Summary
12
+
13
+ - ✅ **DO**: Execute `specfact plan select` CLI command (it already exists)
14
+ - ✅ **DO**: Parse and format CLI output for the user
15
+ - ✅ **DO**: Read plan bundle YAML files for display purposes (when user requests details)
16
+ - ❌ **DON'T**: Write code to implement this command
17
+ - ❌ **DON'T**: Modify `.specfact/plans/config.yaml` directly (the CLI handles this)
18
+ - ❌ **DON'T**: Implement plan loading, selection, or config writing logic
19
+ - ❌ **DON'T**: Create new Python functions or classes for plan selection
20
+
21
+ **The `specfact plan select` command already exists and handles all the logic. Your job is to execute it and present its output to the user.**
22
+
23
+ ### What You Should Do
24
+
25
+ 1. **Execute the CLI**: Run `specfact plan select` (or `specfact plan select <plan>` if user provides a plan)
26
+ 2. **Format output**: Parse the CLI's Rich table output and convert it to a Markdown table for Copilot readability
27
+ 3. **Handle user input**: If user wants details, read the plan bundle YAML file (read-only) to display information
28
+ 4. **Execute selection**: When user selects a plan, execute `specfact plan select <number>` or `specfact plan select <plan_name>`
29
+ 5. **Present results**: Show the CLI's output to confirm the selection
30
+
31
+ ### What You Should NOT Do
32
+
33
+ - Do NOT write Python code to implement plan selection
34
+ - Do NOT modify `.specfact/plans/config.yaml` directly
35
+ - Do NOT create new functions or classes
36
+ - Do NOT implement file scanning, metadata extraction, or config writing logic
37
+
38
+ ## User Input
39
+
40
+ ```text
41
+ $ARGUMENTS
42
+ ```
43
+
44
+ You **MUST** consider the user input before proceeding (if not empty).
45
+
46
+ ## ⚠️ CRITICAL: CLI Usage Enforcement
47
+
48
+ **YOU MUST ALWAYS EXECUTE THE SPECFACT CLI COMMAND**. Never create artifacts directly or implement functionality.
49
+
50
+ ### Rules
51
+
52
+ 1. **ALWAYS execute CLI first**: Run `specfact plan select` (the command already exists) - execute the CLI command before any other operations
53
+ 2. **NEVER write code**: Do not implement plan selection logic - the CLI handles this
54
+ 3. **NEVER create YAML/JSON directly**: All config updates must be done via CLI execution
55
+ 4. **NEVER bypass CLI validation**: The CLI ensures schema compliance and metadata - use it, don't bypass its validation
56
+ 5. **Use CLI output as grounding**: Parse and format the CLI's output, don't regenerate or recreate it - use the CLI output as the source of truth
57
+
58
+ ### What Happens If You Don't Follow This
59
+
60
+ - ❌ Artifacts may not match CLI schema versions
61
+ - ❌ Missing metadata and telemetry
62
+ - ❌ Format inconsistencies
63
+ - ❌ Validation failures
64
+
65
+ ## ⏸️ Wait States: User Input Required
66
+
67
+ **When user input is required, you MUST wait for the user's response.**
68
+
69
+ ### Wait State Rules
70
+
71
+ 1. **Never assume**: If input is missing, ask and wait
72
+ 2. **Never continue**: Do not proceed until user responds
73
+ 3. **Be explicit**: Clearly state what information you need
74
+ 4. **Provide options**: Give examples or default suggestions
75
+
76
+ ## Goal
77
+
78
+ **Execute the existing `specfact plan select` CLI command** to display a numbered list of available plan bundles and allow the user to select one as the active plan. The CLI command handles all the logic - you just need to execute it and format its output.
79
+
80
+ ## Operating Constraints
81
+
82
+ **STRICTLY READ-WRITE**: This command modifies `.specfact/plans/config.yaml` to set the active plan pointer. All updates must be performed by the specfact CLI.
83
+
84
+ **Command**: `specfact plan select`
85
+
86
+ **Mode Auto-Detection**: The CLI automatically detects operational mode (CI/CD or CoPilot) based on environment. No need to specify `--mode` flag. Mode is detected from:
87
+
88
+ - Environment variables (`SPECFACT_MODE`)
89
+ - CoPilot API availability
90
+ - IDE integration (VS Code/Cursor with CoPilot)
91
+ - Defaults to CI/CD mode if none detected
92
+
93
+ ## Execution Steps
94
+
95
+ ### 1. Execute CLI Command (REQUIRED - The Command Already Exists)
96
+
97
+ **The `specfact plan select` command already exists. Execute it to list and select plans:**
98
+
99
+ ```bash
100
+ # Interactive mode (no arguments)
101
+ specfact plan select
102
+
103
+ # Select by number
104
+ specfact plan select <number>
105
+
106
+ # Select by plan name
107
+ specfact plan select <plan_name>
108
+ ```
109
+
110
+ **Note**: Mode is auto-detected by the CLI. No need to specify `--mode` flag.
111
+
112
+ **The CLI command (which already exists) performs**:
113
+
114
+ - Scans `.specfact/plans/` for all `*.bundle.yaml` files
115
+ - Extracts metadata for each plan
116
+ - Displays numbered list (if no plan argument provided)
117
+ - Updates `.specfact/plans/config.yaml` with selected plan
118
+
119
+ **You don't need to implement any of this - just execute the CLI command.**
120
+
121
+ **Important**: The plan is a **positional argument**, not a `--plan` option. Use:
122
+
123
+ - `specfact plan select 20` (select by number)
124
+ - `specfact plan select main.bundle.yaml` (select by name)
125
+ - NOT `specfact plan select --plan 20` (this will fail)
126
+
127
+ **Capture CLI output**:
128
+
129
+ - List of available plans with metadata
130
+ - Active plan selection result
131
+ - Any error messages or warnings
132
+
133
+ **If CLI execution fails**:
134
+
135
+ - Report the error to the user
136
+ - Do not attempt to update config manually
137
+ - Suggest fixes based on error message
138
+
139
+ ### 2. Format and Present Plans (Copilot-Friendly Format)
140
+
141
+ **⚠️ CRITICAL**: In Copilot mode, you MUST format the plan list as a **Markdown table** for better readability. The CLI's Rich table output is not copilot-friendly.
142
+
143
+ **Parse the CLI output** and reformat it as a Markdown table:
144
+
145
+ ```markdown
146
+ ## Available Plans
147
+
148
+ | # | Status | Plan Name | Features | Stories | Stage | Modified |
149
+ |---|--------|-----------|----------|---------|-------|----------|
150
+ | 1 | | specfact-cli.2025-11-04T23-35-00.bundle.yaml | 32 | 80 | draft | 2025-11-04T23:35:00 |
151
+ | 2 | [ACTIVE] | main.bundle.yaml | 62 | 73 | approved | 2025-11-04T22:17:22 |
152
+ | 3 | | api-client-v2.2025-11-04T22-17-22.bundle.yaml | 19 | 45 | draft | 2025-11-04T22:17:22 |
153
+
154
+ **Selection Options:**
155
+ - Enter a **number** (1-3) to select that plan
156
+ - Enter **`<number> details`** (e.g., "1 details") to view detailed information about a plan before selecting
157
+ - Enter **`q`** or **`quit`** to cancel
158
+
159
+ **Example:**
160
+ - `1` - Select plan #1
161
+ - `1 details` - Show details for plan #1, then ask for selection
162
+ - `q` - Cancel selection
163
+
164
+ [WAIT FOR USER RESPONSE - DO NOT CONTINUE]
165
+ ```
166
+
167
+ ### 3. Handle Plan Details Request (If User Requests Details)
168
+
169
+ **If user requests details** (e.g., "1 details" or "show 1"):
170
+
171
+ 1. **Read the plan bundle YAML file** (for display only - don't modify it):
172
+ - Use file reading tools to load the plan bundle YAML file
173
+ - Extract: idea section, product themes, feature list (first 10 features), business context, metadata
174
+ - **Note**: This is just for displaying information to the user. The CLI handles all actual selection logic.
175
+
176
+ 2. **Present detailed information**:
177
+
178
+ ```markdown
179
+ ## Plan Details: specfact-cli.2025-11-04T23-35-00.bundle.yaml
180
+
181
+ **Overview:**
182
+ - Features: 32
183
+ - Stories: 80
184
+ - Stage: draft
185
+ - Modified: 2025-11-04T23:35:00
186
+
187
+ **Idea:**
188
+ - Title: SpecFact CLI
189
+ - Narrative: [extract narrative if available]
190
+ - Target Users: [extract if available]
191
+
192
+ **Product Themes:**
193
+ - CLI
194
+ - Validation
195
+ - Contract Enforcement
196
+
197
+ **Top Features** (showing first 10):
198
+ 1. Contract First Test Manager (FEATURE-CONTRACTFIRSTTESTMANAGER) - Confidence: 0.9
199
+ 2. Prompt Validator (FEATURE-PROMPTVALIDATOR) - Confidence: 0.7
200
+ 3. Smart Coverage Manager (FEATURE-SMARTCOVERAGEMANAGER) - Confidence: 0.7
201
+ ...
202
+
203
+ **Business Context:**
204
+ - Priority: [extract if available]
205
+ - Constraints: [extract if available]
206
+
207
+ **Would you like to select this plan?** (y/n)
208
+ [WAIT FOR USER RESPONSE - DO NOT CONTINUE]
209
+ ```
210
+
211
+ 1. **After showing details**, ask if user wants to select the plan:
212
+ - If **yes**: Execute `specfact plan select <number>` or `specfact plan select <plan_name>` (use positional argument, NOT `--plan` option)
213
+ - If **no**: Return to the plan list and ask for selection again
214
+
215
+ ### 4. Handle User Selection
216
+
217
+ **After user provides selection** (number or plan name), execute CLI with the selected plan:
218
+
219
+ **⚠️ CRITICAL**: The plan is a **positional argument**, not a `--plan` option.
220
+
221
+ **If user provided a number** (e.g., "20"):
222
+
223
+ ```bash
224
+ # Use the number directly as positional argument
225
+ specfact plan select 20
226
+ ```
227
+
228
+ **If user provided a plan name** (e.g., "main.bundle.yaml"):
229
+
230
+ ```bash
231
+ # Use the plan name directly as positional argument
232
+ specfact plan select main.bundle.yaml
233
+ ```
234
+
235
+ **If you need to resolve a number to a plan name first** (for logging/display purposes):
236
+
237
+ ```python
238
+ # Example: User selected "1"
239
+ # Resolve: plans[0]["name"] → "specfact-cli.2025-11-04T23-35-00.bundle.yaml"
240
+ # Then execute: specfact plan select 1 (use the number, not the name)
241
+ ```
242
+
243
+ **Note**: The CLI accepts both numbers and plan names as positional arguments. You can use either format directly.
244
+
245
+ ### 5. Present Results
246
+
247
+ **Present the CLI selection results** to the user:
248
+
249
+ - **Active plan**: Show which plan is now active
250
+ - **Config location**: Show where the config was updated
251
+ - **Next steps**: Explain how this affects other commands
252
+
253
+ ## Reference: What the CLI Command Does (For Your Understanding Only)
254
+
255
+ **⚠️ IMPORTANT**: This section describes what the existing CLI command does internally. You should NOT implement this logic - just execute the CLI command.
256
+
257
+ ### 1. List Available Plans (The CLI Command Handles This)
258
+
259
+ **The CLI command loads all plan bundles** from `.specfact/plans/` directory:
260
+
261
+ - Scan for all `*.bundle.yaml` files
262
+ - Extract metadata for each plan:
263
+ - Plan name (filename)
264
+ - Number of features
265
+ - Number of stories
266
+ - Stage (draft, review, approved, released)
267
+ - File size
268
+ - Last modified date
269
+ - Active status (if currently selected)
270
+
271
+ ### 2. Display Plans as Markdown Table (Copilot-Friendly)
272
+
273
+ **⚠️ CRITICAL**: Always format the plan list as a **Markdown table** for Copilot readability. The CLI's Rich table is not copilot-friendly.
274
+
275
+ **Parse CLI output and reformat as Markdown table**:
276
+
277
+ ```markdown
278
+ ## Available Plans
279
+
280
+ | # | Status | Plan Name | Features | Stories | Stage | Modified |
281
+ |---|--------|-----------|----------|---------|-------|----------|
282
+ | 1 | | specfact-cli.2025-11-04T23-35-00.bundle.yaml | 32 | 80 | draft | 2025-11-04T23:35:00 |
283
+ | 2 | [ACTIVE] | main.bundle.yaml | 62 | 73 | approved | 2025-11-04T22:17:22 |
284
+ | 3 | | api-client-v2.2025-11-04T22-17-22.bundle.yaml | 19 | 45 | draft | 2025-11-04T22:17:22 |
285
+
286
+ **Selection Options:**
287
+ - Enter a **number** (1-3) to select that plan
288
+ - Enter **`<number> details`** (e.g., "1 details") to view detailed information about a plan
289
+ - Enter **`q`** or **`quit`** to cancel
290
+
291
+ **Example commands:**
292
+ - `1` - Select plan #1
293
+ - `1 details` - Show details for plan #1, then ask for selection
294
+ - `q` - Cancel selection
295
+ ```
296
+
297
+ **Table Formatting Rules:**
298
+
299
+ - Use proper Markdown table syntax with pipes (`|`)
300
+ - Include all columns: #, Status, Plan Name, Features, Stories, Stage, Modified
301
+ - Truncate long plan names if needed (show first 50 chars + "...")
302
+ - Highlight active plan with `[ACTIVE]` in Status column
303
+ - Sort by modification date (oldest first, newest last) as per CLI behavior
304
+
305
+ ### 3. Handle User Selection
306
+
307
+ **If user provides a number** (e.g., "1"):
308
+
309
+ - Validate the number is within range
310
+ - Execute: `specfact plan select <number>` (use number as positional argument)
311
+ - Confirm the selection
312
+
313
+ **If user provides a number with "details"** (e.g., "1 details", "show 1"):
314
+
315
+ - Validate the number is within range
316
+ - Load the plan bundle YAML file
317
+ - Extract and display detailed information (see "Handle Plan Details Request" section)
318
+ - Ask if user wants to select this plan
319
+ - If yes: Execute `specfact plan select <number>` (use number as positional argument, NOT `--plan` option)
320
+ - If no: Return to plan list and ask for selection again
321
+
322
+ **If user provides a plan name directly** (e.g., "main.bundle.yaml"):
323
+
324
+ - Validate the plan exists in the plans list
325
+ - Execute: `specfact plan select <plan_name>` (use plan name as positional argument, NOT `--plan` option)
326
+ - Confirm the selection
327
+
328
+ **If user provides 'q' or 'quit'**:
329
+
330
+ - Exit without changes
331
+ - Do not execute any CLI commands
332
+
333
+ ### 4. Update Active Plan Config (The CLI Command Handles This)
334
+
335
+ **The CLI command writes to `.specfact/plans/config.yaml`** when you execute `specfact plan select <plan>`:
336
+
337
+ ```yaml
338
+ active_plan: specfact-cli.2025-11-04T23-35-00.bundle.yaml
339
+ ```
340
+
341
+ **You should NOT write this file directly - execute the CLI command instead.**
342
+
343
+ ## Expected Output
344
+
345
+ **After selection**:
346
+
347
+ ```markdown
348
+ ✓ Active plan set to: specfact-cli.2025-11-04T23-35-00.bundle.yaml
349
+
350
+ This plan will now be used as the default for:
351
+ - specfact plan compare
352
+ - specfact plan promote
353
+ - specfact plan add-feature
354
+ - specfact plan add-story
355
+ - specfact sync spec-kit
356
+ ```
357
+
358
+ **If no plans found**:
359
+
360
+ ```markdown
361
+ ⚠ No plan bundles found in .specfact/plans/
362
+
363
+ Create a plan with:
364
+ - specfact plan init
365
+ - specfact import from-code
366
+ ```
367
+
368
+ ## Interactive Flow
369
+
370
+ **Step 1**: Check if a plan argument is provided in user input.
371
+
372
+ - **If provided**: Execute `specfact plan select <plan>` directly (the CLI handles setting it as active)
373
+ - **If missing**: Execute `specfact plan select` (interactive mode - the CLI displays the list)
374
+
375
+ **Step 2**: Format the CLI output as a **Markdown table** (copilot-friendly):
376
+
377
+ - Execute `specfact plan select` (if no plan argument provided)
378
+ - Parse the CLI's output (Rich table format)
379
+ - Convert to Markdown table with columns: #, Status, Plan Name, Features, Stories, Stage, Modified
380
+ - Include selection instructions with examples
381
+
382
+ **Step 3**: Wait for user input:
383
+
384
+ - Number selection (e.g., "1", "2", "3") - Select plan directly
385
+ - Number with "details" (e.g., "1 details", "show 1") - Show plan details first
386
+ - Plan name (e.g., "main.bundle.yaml") - Select by name
387
+ - Quit command (e.g., "q", "quit") - Cancel
388
+
389
+ **Step 4**: Handle user input:
390
+
391
+ - **If details requested**: Read plan bundle YAML file (for display only), show detailed information, ask for confirmation
392
+ - **If selection provided**: Execute `specfact plan select <number>` or `specfact plan select <plan_name>` (positional argument, NOT `--plan` option) - the CLI handles the selection
393
+ - **If quit**: Exit without executing any CLI commands
394
+
395
+ **Step 5**: Present results and confirm selection.
396
+
397
+ ## Context
398
+
399
+ {ARGS}
400
+
401
+ --- End Command ---
@@ -0,0 +1,242 @@
1
+ ---
2
+ description: "Update an existing feature's metadata in a plan bundle"
3
+ ---
4
+
5
+ # SpecFact Update Feature 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.
18
+
19
+ ### Rules
20
+
21
+ 1. **ALWAYS execute CLI first**: Run `specfact plan update-feature` before any analysis - execute the CLI command before any other operations
22
+ 2. **NEVER write code**: Do not implement feature update logic - the CLI handles this
23
+ 3. **NEVER create YAML/JSON directly**: All plan bundle updates must be CLI-generated
24
+ 4. **NEVER bypass CLI validation**: CLI ensures schema compliance and metadata - use it, don't bypass its validation
25
+ 5. **Use CLI output as grounding**: Parse CLI output, don't regenerate or recreate it - use the CLI output as the source of truth
26
+ 6. **NEVER manipulate internal code**: Do NOT use Python code to directly modify PlanBundle objects, Feature objects, or any internal data structures. The CLI is THE interface - use it exclusively.
27
+ 7. **No internal knowledge required**: You should NOT need to know about internal implementation details (PlanBundle model, Feature class, etc.). All operations must be performed via CLI commands.
28
+ 8. **NEVER read artifacts directly**: Do NOT read plan bundle files directly to extract information unless for display purposes. Use CLI commands (`specfact plan select`) to get plan information.
29
+
30
+ ### What Happens If You Don't Follow This
31
+
32
+ - ❌ Artifacts may not match CLI schema versions
33
+ - ❌ Missing metadata and telemetry
34
+ - ❌ Format inconsistencies
35
+ - ❌ Validation failures
36
+ - ❌ Works only in Copilot mode, fails in CI/CD
37
+ - ❌ Breaks when CLI internals change
38
+ - ❌ Requires knowledge of internal code structure
39
+
40
+ ## ⏸️ Wait States: User Input Required
41
+
42
+ **When user input is required, you MUST wait for the user's response.**
43
+
44
+ ### Wait State Rules
45
+
46
+ 1. **Never assume**: If input is missing, ask and wait
47
+ 2. **Never continue**: Do not proceed until user responds
48
+ 3. **Be explicit**: Clearly state what information you need
49
+ 4. **Provide options**: Give examples or default suggestions
50
+
51
+ ## Goal
52
+
53
+ Update an existing feature's metadata in a plan bundle. This command allows updating feature properties (title, outcomes, acceptance criteria, constraints, confidence, draft status) in non-interactive environments (CI/CD, Copilot).
54
+
55
+ **Note**: All parameters except `--key` are optional - you only need to provide the fields you want to update.
56
+
57
+ ## Operating Constraints
58
+
59
+ **STRICTLY READ-WRITE**: This command modifies plan bundle metadata and content. All updates must be performed by the specfact CLI.
60
+
61
+ **Command**: `specfact plan update-feature`
62
+
63
+ **Mode Auto-Detection**: The CLI automatically detects operational mode (CI/CD or CoPilot) based on environment. No need to specify `--mode` flag.
64
+
65
+ ## What This Command Does
66
+
67
+ The `specfact plan update-feature` command:
68
+
69
+ 1. **Loads** the existing plan bundle (default: `.specfact/plans/main.bundle.yaml` or active plan)
70
+ 2. **Validates** the plan bundle structure
71
+ 3. **Finds** the feature by key
72
+ 4. **Updates** only the specified fields (all parameters except key are optional)
73
+ 5. **Validates** the updated plan bundle
74
+ 6. **Saves** the updated plan bundle
75
+
76
+ ## Execution Steps
77
+
78
+ ### 1. Parse Arguments and Validate Input
79
+
80
+ **Parse user input** to extract:
81
+
82
+ - Feature key (required, e.g., `FEATURE-001`)
83
+ - Title (optional)
84
+ - Outcomes (optional, comma-separated)
85
+ - Acceptance criteria (optional, comma-separated)
86
+ - Constraints (optional, comma-separated)
87
+ - Confidence (optional, 0.0-1.0)
88
+ - Draft status (optional, boolean flag: `--draft` sets True, `--no-draft` sets False, omit to leave unchanged)
89
+ - Plan bundle path (optional, defaults to active plan or `.specfact/plans/main.bundle.yaml`)
90
+
91
+ **WAIT STATE**: If feature key is missing, ask the user:
92
+
93
+ ```text
94
+ "Which feature would you like to update? Please provide the feature key (e.g., FEATURE-001):
95
+ [WAIT FOR USER RESPONSE - DO NOT CONTINUE]"
96
+ ```
97
+
98
+ **WAIT STATE**: If no update fields are specified, ask:
99
+
100
+ ```text
101
+ "Which fields would you like to update?
102
+ - Title
103
+ - Outcomes
104
+ - Acceptance criteria
105
+ - Constraints
106
+ - Confidence
107
+ - Draft status
108
+
109
+ Please specify the fields and values:
110
+ [WAIT FOR USER RESPONSE - DO NOT CONTINUE]"
111
+ ```
112
+
113
+ ### 2. Check Plan Bundle and Feature Existence
114
+
115
+ **Execute CLI** to check if plan exists:
116
+
117
+ ```bash
118
+ # Check if default plan exists
119
+ specfact plan select
120
+ ```
121
+
122
+ **If plan doesn't exist**:
123
+
124
+ - Report error: "Default plan not found. Create one with: `specfact plan init --interactive`"
125
+ - **WAIT STATE**: Ask user if they want to create a new plan or specify a different path
126
+
127
+ **If feature doesn't exist**:
128
+
129
+ - CLI will report: "Feature 'FEATURE-001' not found in plan"
130
+ - CLI will list available features
131
+ - **WAIT STATE**: Ask user to provide a valid feature key
132
+
133
+ ### 3. Execute Update Feature Command
134
+
135
+ **Execute CLI command**:
136
+
137
+ ```bash
138
+ # Update title and outcomes
139
+ specfact plan update-feature \
140
+ --key FEATURE-001 \
141
+ --title "Updated Title" \
142
+ --outcomes "Outcome 1, Outcome 2" \
143
+ --plan <plan_path>
144
+
145
+ # Update acceptance criteria and confidence
146
+ specfact plan update-feature \
147
+ --key FEATURE-001 \
148
+ --acceptance "Criterion 1, Criterion 2" \
149
+ --confidence 0.9 \
150
+ --plan <plan_path>
151
+
152
+ # Update constraints
153
+ specfact plan update-feature \
154
+ --key FEATURE-001 \
155
+ --constraints "Python 3.11+, Test coverage >= 80%" \
156
+ --plan <plan_path>
157
+
158
+ # Mark as draft (boolean flag: --draft sets True, --no-draft sets False)
159
+ specfact plan update-feature \
160
+ --key FEATURE-001 \
161
+ --draft \
162
+ --plan <plan_path>
163
+
164
+ # Unmark draft (set to False)
165
+ specfact plan update-feature \
166
+ --key FEATURE-001 \
167
+ --no-draft \
168
+ --plan <plan_path>
169
+ ```
170
+
171
+ **Capture from CLI**:
172
+
173
+ - Plan bundle loaded successfully
174
+ - Feature found by key
175
+ - Fields updated (only specified fields)
176
+ - Plan bundle saved successfully
177
+
178
+ ### 4. Handle Errors
179
+
180
+ **Common errors**:
181
+
182
+ - **Feature not found**: Report error and list available features
183
+ - **No updates specified**: Report warning and list available update options
184
+ - **Invalid confidence**: Report error if confidence is not 0.0-1.0
185
+ - **Plan bundle not found**: Report error and suggest creating plan with `specfact plan init`
186
+ - **Invalid plan structure**: Report validation error
187
+
188
+ ### 5. Report Completion
189
+
190
+ **After successful execution**:
191
+
192
+ ```markdown
193
+ ✓ Feature updated successfully!
194
+
195
+ **Feature**: FEATURE-001
196
+ **Updated Fields**: title, outcomes, acceptance, confidence
197
+ **Plan Bundle**: `.specfact/plans/main.bundle.yaml`
198
+
199
+ **Updated Metadata**:
200
+ - Title: Updated Title
201
+ - Outcomes: Outcome 1, Outcome 2
202
+ - Acceptance: Criterion 1, Criterion 2
203
+ - Confidence: 0.9
204
+
205
+ **Next Steps**:
206
+ - Add stories: `/specfact-cli/specfact-plan-add-story`
207
+ - Review plan: `/specfact-cli/specfact-plan-review`
208
+ - Promote plan: `/specfact-cli/specfact-plan-promote`
209
+ ```
210
+
211
+ ## Guidelines
212
+
213
+ ### Update Strategy
214
+
215
+ - **Partial updates**: Only specified fields are updated, others remain unchanged
216
+ - **Comma-separated lists**: Outcomes, acceptance, and constraints use comma-separated strings
217
+ - **Confidence range**: Must be between 0.0 and 1.0
218
+ - **Draft status**: Boolean flag - use `--draft` to set True, `--no-draft` to set False, omit to leave unchanged
219
+ - ❌ **WRONG**: `--draft true` or `--draft false` (Typer boolean flags don't accept values)
220
+ - ✅ **CORRECT**: `--draft` (sets True) or `--no-draft` (sets False) or omit (leaves unchanged)
221
+
222
+ ### Field Guidelines
223
+
224
+ - **Title**: Clear, concise description of the feature
225
+ - **Outcomes**: Expected results or benefits (comma-separated)
226
+ - **Acceptance**: Testable acceptance criteria (comma-separated)
227
+ - **Constraints**: Technical or business constraints (comma-separated)
228
+ - **Confidence**: Confidence score (0.0-1.0) based on requirements clarity
229
+ - **Draft**: Mark as draft if not ready for review
230
+
231
+ ### Best Practices
232
+
233
+ - Update features incrementally as requirements evolve
234
+ - Keep acceptance criteria testable and measurable
235
+ - Update confidence scores as requirements become clearer
236
+ - Use draft status to mark work-in-progress features
237
+
238
+ ## Context
239
+
240
+ {ARGS}
241
+
242
+ --- End Command ---