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,188 @@
1
+ ---
2
+ description: "Add a new feature to an existing plan bundle"
3
+ ---
4
+
5
+ # SpecFact Add 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 add-feature` before any analysis - execute the CLI command before any other operations
22
+ 2. **NEVER write code**: Do not implement feature addition 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
+ Add a new feature to an existing plan bundle. The feature will be added with the specified key, title, outcomes, and acceptance criteria.
54
+
55
+ ## Operating Constraints
56
+
57
+ **STRICTLY READ-WRITE**: This command modifies plan bundle metadata and content. All updates must be performed by the specfact CLI.
58
+
59
+ **Command**: `specfact plan add-feature`
60
+
61
+ **Mode Auto-Detection**: The CLI automatically detects operational mode (CI/CD or CoPilot) based on environment. No need to specify `--mode` flag.
62
+
63
+ ## What This Command Does
64
+
65
+ The `specfact plan add-feature` command:
66
+
67
+ 1. **Loads** the existing plan bundle (default: `.specfact/plans/main.bundle.yaml` or active plan)
68
+ 2. **Validates** the plan bundle structure
69
+ 3. **Checks** if the feature key already exists (prevents duplicates)
70
+ 4. **Creates** a new feature with specified metadata
71
+ 5. **Adds** the feature to the plan bundle
72
+ 6. **Validates** the updated plan bundle
73
+ 7. **Saves** the updated plan bundle
74
+
75
+ ## Execution Steps
76
+
77
+ ### 1. Parse Arguments and Validate Input
78
+
79
+ **Parse user input** to extract:
80
+
81
+ - Feature key (required, e.g., `FEATURE-001`)
82
+ - Feature title (required)
83
+ - Outcomes (optional, comma-separated)
84
+ - Acceptance criteria (optional, comma-separated)
85
+ - Plan bundle path (optional, defaults to active plan or `.specfact/plans/main.bundle.yaml`)
86
+
87
+ **WAIT STATE**: If required arguments are missing, ask the user:
88
+
89
+ ```text
90
+ "To add a feature, I need:
91
+ - Feature key (e.g., FEATURE-001)
92
+ - Feature title
93
+
94
+ Please provide these values:
95
+ [WAIT FOR USER RESPONSE - DO NOT CONTINUE]"
96
+ ```
97
+
98
+ ### 2. Check Plan Bundle Existence
99
+
100
+ **Execute CLI** to check if plan exists:
101
+
102
+ ```bash
103
+ # Check if default plan exists
104
+ specfact plan select
105
+ ```
106
+
107
+ **If plan doesn't exist**:
108
+
109
+ - Report error: "Default plan not found. Create one with: `specfact plan init --interactive`"
110
+ - **WAIT STATE**: Ask user if they want to create a new plan or specify a different path
111
+
112
+ ### 3. Execute Add Feature Command
113
+
114
+ **Execute CLI command**:
115
+
116
+ ```bash
117
+ # Basic usage
118
+ specfact plan add-feature --key FEATURE-001 --title "Feature Title" --plan <plan_path>
119
+
120
+ # With outcomes and acceptance
121
+ specfact plan add-feature \
122
+ --key FEATURE-001 \
123
+ --title "Feature Title" \
124
+ --outcomes "Outcome 1, Outcome 2" \
125
+ --acceptance "Criterion 1, Criterion 2" \
126
+ --plan <plan_path>
127
+ ```
128
+
129
+ **Capture from CLI**:
130
+
131
+ - Plan bundle loaded successfully
132
+ - Feature key validation (must not already exist)
133
+ - Feature created and added
134
+ - Plan bundle saved successfully
135
+
136
+ ### 4. Handle Errors
137
+
138
+ **Common errors**:
139
+
140
+ - **Feature key already exists**: Report error and suggest using `specfact plan update-feature` instead
141
+ - **Plan bundle not found**: Report error and suggest creating plan with `specfact plan init`
142
+ - **Invalid plan structure**: Report validation error
143
+
144
+ ### 5. Report Completion
145
+
146
+ **After successful execution**:
147
+
148
+ ```markdown
149
+ ✓ Feature added successfully!
150
+
151
+ **Feature**: FEATURE-001
152
+ **Title**: Feature Title
153
+ **Outcomes**: Outcome 1, Outcome 2
154
+ **Acceptance**: Criterion 1, Criterion 2
155
+ **Plan Bundle**: `.specfact/plans/main.bundle.yaml`
156
+
157
+ **Next Steps**:
158
+ - Add stories to this feature: `/specfact-cli/specfact-plan-add-story`
159
+ - Update feature metadata: `/specfact-cli/specfact-plan-update-feature`
160
+ - Review plan: `/specfact-cli/specfact-plan-review`
161
+ ```
162
+
163
+ ## Guidelines
164
+
165
+ ### Feature Key Format
166
+
167
+ - Use consistent format: `FEATURE-001`, `FEATURE-002`, etc.
168
+ - Keys must be unique within the plan bundle
169
+ - CLI will reject duplicate keys
170
+
171
+ ### Feature Metadata
172
+
173
+ - **Title**: Clear, concise description of the feature
174
+ - **Outcomes**: Expected results or benefits (comma-separated)
175
+ - **Acceptance**: Testable acceptance criteria (comma-separated)
176
+
177
+ ### Best Practices
178
+
179
+ - Add features incrementally as you discover requirements
180
+ - Use descriptive titles that explain the feature's purpose
181
+ - Include measurable outcomes and testable acceptance criteria
182
+ - Keep features focused and single-purpose
183
+
184
+ ## Context
185
+
186
+ {ARGS}
187
+
188
+ --- End Command ---
@@ -0,0 +1,212 @@
1
+ ---
2
+ description: "Add a new story to an existing feature in a plan bundle"
3
+ ---
4
+
5
+ # SpecFact Add Story 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 add-story` before any analysis - execute the CLI command before any other operations
22
+ 2. **NEVER write code**: Do not implement story addition 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, Story 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, Story 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
+ Add a new story to an existing feature in a plan bundle. The story will be added with the specified key, title, acceptance criteria, and optional story/value points.
54
+
55
+ ## Operating Constraints
56
+
57
+ **STRICTLY READ-WRITE**: This command modifies plan bundle metadata and content. All updates must be performed by the specfact CLI.
58
+
59
+ **Command**: `specfact plan add-story`
60
+
61
+ **Mode Auto-Detection**: The CLI automatically detects operational mode (CI/CD or CoPilot) based on environment. No need to specify `--mode` flag.
62
+
63
+ ## What This Command Does
64
+
65
+ The `specfact plan add-story` command:
66
+
67
+ 1. **Loads** the existing plan bundle (default: `.specfact/plans/main.bundle.yaml` or active plan)
68
+ 2. **Validates** the plan bundle structure
69
+ 3. **Finds** the parent feature by key
70
+ 4. **Checks** if the story key already exists in the feature (prevents duplicates)
71
+ 5. **Creates** a new story with specified metadata
72
+ 6. **Adds** the story to the feature
73
+ 7. **Validates** the updated plan bundle
74
+ 8. **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
+ - Parent feature key (required, e.g., `FEATURE-001`)
83
+ - Story key (required, e.g., `STORY-001`)
84
+ - Story title (required)
85
+ - Acceptance criteria (optional, comma-separated)
86
+ - Story points (optional, 0-100)
87
+ - Value points (optional, 0-100)
88
+ - Draft status (optional, default: false)
89
+ - Plan bundle path (optional, defaults to active plan or `.specfact/plans/main.bundle.yaml`)
90
+
91
+ **WAIT STATE**: If required arguments are missing, ask the user:
92
+
93
+ ```text
94
+ "To add a story, I need:
95
+ - Parent feature key (e.g., FEATURE-001)
96
+ - Story key (e.g., STORY-001)
97
+ - Story title
98
+
99
+ Please provide these values:
100
+ [WAIT FOR USER RESPONSE - DO NOT CONTINUE]"
101
+ ```
102
+
103
+ ### 2. Check Plan Bundle and Feature Existence
104
+
105
+ **Execute CLI** to check if plan exists:
106
+
107
+ ```bash
108
+ # Check if default plan exists
109
+ specfact plan select
110
+ ```
111
+
112
+ **If plan doesn't exist**:
113
+
114
+ - Report error: "Default plan not found. Create one with: `specfact plan init --interactive`"
115
+ - **WAIT STATE**: Ask user if they want to create a new plan or specify a different path
116
+
117
+ **If feature doesn't exist**:
118
+
119
+ - CLI will report: "Feature 'FEATURE-001' not found in plan"
120
+ - CLI will list available features
121
+ - **WAIT STATE**: Ask user to provide a valid feature key or create the feature first
122
+
123
+ ### 3. Execute Add Story Command
124
+
125
+ **Execute CLI command**:
126
+
127
+ ```bash
128
+ # Basic usage
129
+ specfact plan add-story \
130
+ --feature FEATURE-001 \
131
+ --key STORY-001 \
132
+ --title "Story Title" \
133
+ --plan <plan_path>
134
+
135
+ # With acceptance criteria and points
136
+ specfact plan add-story \
137
+ --feature FEATURE-001 \
138
+ --key STORY-001 \
139
+ --title "Story Title" \
140
+ --acceptance "Criterion 1, Criterion 2" \
141
+ --story-points 5 \
142
+ --value-points 3 \
143
+ --plan <plan_path>
144
+ ```
145
+
146
+ **Capture from CLI**:
147
+
148
+ - Plan bundle loaded successfully
149
+ - Parent feature found
150
+ - Story key validation (must not already exist in feature)
151
+ - Story created and added to feature
152
+ - Plan bundle saved successfully
153
+
154
+ ### 4. Handle Errors
155
+
156
+ **Common errors**:
157
+
158
+ - **Feature not found**: Report error and list available features
159
+ - **Story key already exists**: Report error and suggest using a different key
160
+ - **Plan bundle not found**: Report error and suggest creating plan with `specfact plan init`
161
+ - **Invalid plan structure**: Report validation error
162
+
163
+ ### 5. Report Completion
164
+
165
+ **After successful execution**:
166
+
167
+ ```markdown
168
+ ✓ Story added successfully!
169
+
170
+ **Feature**: FEATURE-001
171
+ **Story**: STORY-001
172
+ **Title**: Story Title
173
+ **Acceptance**: Criterion 1, Criterion 2
174
+ **Story Points**: 5
175
+ **Value Points**: 3
176
+ **Plan Bundle**: `.specfact/plans/main.bundle.yaml`
177
+
178
+ **Next Steps**:
179
+ - Add more stories: `/specfact-cli/specfact-plan-add-story`
180
+ - Update story metadata: Use `specfact plan update-feature` (stories are updated via feature)
181
+ - Review plan: `/specfact-cli/specfact-plan-review`
182
+ ```
183
+
184
+ ## Guidelines
185
+
186
+ ### Story Key Format
187
+
188
+ - Use consistent format: `STORY-001`, `STORY-002`, etc.
189
+ - Keys must be unique within the feature
190
+ - CLI will reject duplicate keys within the same feature
191
+
192
+ ### Story Metadata
193
+
194
+ - **Title**: Clear, user-focused description (e.g., "As a user, I can...")
195
+ - **Acceptance**: Testable acceptance criteria (comma-separated)
196
+ - **Story Points**: Complexity estimate (0-100, optional)
197
+ - **Value Points**: Business value estimate (0-100, optional)
198
+ - **Draft**: Mark as draft if not ready for review (optional)
199
+
200
+ ### Best Practices
201
+
202
+ - Write stories from the user's perspective
203
+ - Include testable acceptance criteria
204
+ - Use story points for complexity estimation
205
+ - Use value points for business value prioritization
206
+ - Keep stories focused and single-purpose
207
+
208
+ ## Context
209
+
210
+ {ARGS}
211
+
212
+ --- End Command ---