specfact-cli 0.13.3__tar.gz → 0.14.2__tar.gz

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 (153) hide show
  1. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/PKG-INFO +1 -1
  2. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/pyproject.toml +1 -1
  3. specfact_cli-0.14.2/resources/prompts/shared/cli-enforcement.md +113 -0
  4. specfact_cli-0.14.2/resources/prompts/specfact.01-import.md +118 -0
  5. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/resources/prompts/specfact.02-plan.md +59 -1
  6. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/resources/prompts/specfact.03-review.md +57 -1
  7. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/resources/prompts/specfact.04-sdd.md +55 -1
  8. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/resources/prompts/specfact.05-enforce.md +55 -1
  9. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/resources/prompts/specfact.06-sync.md +55 -1
  10. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/resources/prompts/specfact.07-contracts.md +60 -6
  11. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/resources/prompts/specfact.compare.md +55 -1
  12. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/resources/prompts/specfact.validate.md +51 -0
  13. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/__init__.py +1 -1
  14. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/__init__.py +1 -1
  15. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/agents/analyze_agent.py +51 -0
  16. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/analyzers/code_analyzer.py +15 -0
  17. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/cli.py +8 -1
  18. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/commands/generate.py +1 -0
  19. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/commands/import_cmd.py +163 -36
  20. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/commands/init.py +1 -0
  21. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/commands/plan.py +6 -0
  22. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/commands/repro.py +1 -0
  23. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/commands/spec.py +1 -0
  24. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/commands/sync.py +4 -0
  25. specfact_cli-0.14.2/src/specfact_cli/sync/watcher_enhanced.py +493 -0
  26. specfact_cli-0.14.2/src/specfact_cli/templates/__init__.py +8 -0
  27. specfact_cli-0.14.2/src/specfact_cli/templates/specification_templates.py +146 -0
  28. specfact_cli-0.14.2/src/specfact_cli/utils/context_detection.py +269 -0
  29. specfact_cli-0.14.2/src/specfact_cli/utils/performance.py +219 -0
  30. specfact_cli-0.14.2/src/specfact_cli/utils/progressive_disclosure.py +326 -0
  31. specfact_cli-0.14.2/src/specfact_cli/utils/suggestions.py +155 -0
  32. specfact_cli-0.14.2/src/specfact_cli/validators/cli_first_validator.py +204 -0
  33. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/validators/repro_checker.py +24 -8
  34. specfact_cli-0.13.3/resources/prompts/shared/cli-enforcement.md +0 -34
  35. specfact_cli-0.13.3/resources/prompts/specfact.01-import.md +0 -60
  36. specfact_cli-0.13.3/src/specfact_cli/templates/__init__.py +0 -13
  37. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/.gitignore +0 -0
  38. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/LICENSE.md +0 -0
  39. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/README.md +0 -0
  40. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/resources/mappings/node-async.yaml +0 -0
  41. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/resources/mappings/python-async.yaml +0 -0
  42. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/resources/mappings/speckit-default.yaml +0 -0
  43. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/resources/schemas/deviation.schema.json +0 -0
  44. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/resources/schemas/plan.schema.json +0 -0
  45. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/resources/schemas/protocol.schema.json +0 -0
  46. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/resources/templates/github-action.yml.j2 +0 -0
  47. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/resources/templates/plan.bundle.yaml.j2 +0 -0
  48. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/resources/templates/pr-template.md.j2 +0 -0
  49. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/resources/templates/protocol.yaml.j2 +0 -0
  50. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/resources/templates/telemetry.yaml.example +0 -0
  51. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/agents/__init__.py +0 -0
  52. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/agents/base.py +0 -0
  53. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/agents/plan_agent.py +0 -0
  54. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/agents/registry.py +0 -0
  55. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/agents/sync_agent.py +0 -0
  56. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/analyzers/__init__.py +0 -0
  57. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/analyzers/ambiguity_scanner.py +0 -0
  58. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/analyzers/constitution_evidence_extractor.py +0 -0
  59. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/analyzers/contract_extractor.py +0 -0
  60. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/analyzers/control_flow_analyzer.py +0 -0
  61. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/analyzers/graph_analyzer.py +0 -0
  62. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/analyzers/relationship_mapper.py +0 -0
  63. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/analyzers/requirement_extractor.py +0 -0
  64. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/analyzers/test_pattern_extractor.py +0 -0
  65. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/commands/__init__.py +0 -0
  66. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/commands/analyze.py +0 -0
  67. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/commands/bridge.py +0 -0
  68. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/commands/drift.py +0 -0
  69. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/commands/enforce.py +0 -0
  70. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/commands/implement.py +0 -0
  71. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/commands/migrate.py +0 -0
  72. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/commands/run.py +0 -0
  73. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/commands/sdd.py +0 -0
  74. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/common/__init__.py +0 -0
  75. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/common/logger_setup.py +0 -0
  76. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/common/logging_utils.py +0 -0
  77. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/common/text_utils.py +0 -0
  78. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/common/utils.py +0 -0
  79. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/comparators/__init__.py +0 -0
  80. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/comparators/plan_comparator.py +0 -0
  81. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/enrichers/constitution_enricher.py +0 -0
  82. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/enrichers/plan_enricher.py +0 -0
  83. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/generators/__init__.py +0 -0
  84. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/generators/contract_generator.py +0 -0
  85. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/generators/openapi_extractor.py +0 -0
  86. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/generators/plan_generator.py +0 -0
  87. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/generators/protocol_generator.py +0 -0
  88. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/generators/report_generator.py +0 -0
  89. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/generators/task_generator.py +0 -0
  90. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/generators/test_to_openapi.py +0 -0
  91. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/generators/workflow_generator.py +0 -0
  92. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/importers/__init__.py +0 -0
  93. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/importers/speckit_converter.py +0 -0
  94. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/importers/speckit_scanner.py +0 -0
  95. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/integrations/__init__.py +0 -0
  96. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/integrations/specmatic.py +0 -0
  97. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/migrations/__init__.py +0 -0
  98. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/migrations/plan_migrator.py +0 -0
  99. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/models/__init__.py +0 -0
  100. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/models/bridge.py +0 -0
  101. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/models/deviation.py +0 -0
  102. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/models/enforcement.py +0 -0
  103. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/models/plan.py +0 -0
  104. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/models/project.py +0 -0
  105. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/models/protocol.py +0 -0
  106. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/models/quality.py +0 -0
  107. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/models/sdd.py +0 -0
  108. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/models/source_tracking.py +0 -0
  109. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/models/task.py +0 -0
  110. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/modes/__init__.py +0 -0
  111. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/modes/detector.py +0 -0
  112. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/modes/router.py +0 -0
  113. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/resources/semgrep/async.yml +0 -0
  114. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/resources/semgrep/code-quality.yml +0 -0
  115. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/resources/semgrep/feature-detection.yml +0 -0
  116. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/runtime.py +0 -0
  117. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/sync/__init__.py +0 -0
  118. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/sync/bridge_probe.py +0 -0
  119. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/sync/bridge_sync.py +0 -0
  120. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/sync/bridge_watch.py +0 -0
  121. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/sync/change_detector.py +0 -0
  122. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/sync/code_to_spec.py +0 -0
  123. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/sync/drift_detector.py +0 -0
  124. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/sync/repository_sync.py +0 -0
  125. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/sync/spec_to_code.py +0 -0
  126. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/sync/spec_to_tests.py +0 -0
  127. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/sync/speckit_sync.py +0 -0
  128. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/sync/watcher.py +0 -0
  129. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/telemetry.py +0 -0
  130. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/templates/bridge_templates.py +0 -0
  131. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/utils/__init__.py +0 -0
  132. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/utils/acceptance_criteria.py +0 -0
  133. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/utils/bundle_loader.py +0 -0
  134. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/utils/console.py +0 -0
  135. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/utils/enrichment_context.py +0 -0
  136. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/utils/enrichment_parser.py +0 -0
  137. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/utils/feature_keys.py +0 -0
  138. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/utils/git.py +0 -0
  139. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/utils/github_annotations.py +0 -0
  140. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/utils/ide_setup.py +0 -0
  141. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/utils/incremental_check.py +0 -0
  142. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/utils/optional_deps.py +0 -0
  143. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/utils/progress.py +0 -0
  144. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/utils/prompts.py +0 -0
  145. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/utils/sdd_discovery.py +0 -0
  146. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/utils/source_scanner.py +0 -0
  147. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/utils/structure.py +0 -0
  148. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/utils/structured_io.py +0 -0
  149. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/utils/yaml_utils.py +0 -0
  150. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/validators/__init__.py +0 -0
  151. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/validators/contract_validator.py +0 -0
  152. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/validators/fsm.py +0 -0
  153. {specfact_cli-0.13.3 → specfact_cli-0.14.2}/src/specfact_cli/validators/schema.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: specfact-cli
3
- Version: 0.13.3
3
+ Version: 0.14.2
4
4
  Summary: Brownfield-first CLI: Reverse engineer legacy Python → specs → enforced contracts. Automate legacy code documentation and prevent modernization regressions.
5
5
  Project-URL: Homepage, https://github.com/nold-ai/specfact-cli
6
6
  Project-URL: Repository, https://github.com/nold-ai/specfact-cli.git
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "specfact-cli"
7
- version = "0.13.3"
7
+ version = "0.14.2"
8
8
  description = "Brownfield-first CLI: Reverse engineer legacy Python → specs → enforced contracts. Automate legacy code documentation and prevent modernization regressions."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -0,0 +1,113 @@
1
+ # CLI Usage Enforcement Rules
2
+
3
+ ## Core Principle
4
+
5
+ **ALWAYS use SpecFact CLI commands. Never create artifacts directly.**
6
+
7
+ ## CLI vs LLM Capabilities
8
+
9
+ ### CLI-Only Operations (CI/CD Mode - No LLM Required)
10
+
11
+ The CLI can perform these operations **without LLM**:
12
+
13
+ - ✅ Tool execution (ruff, pylint, basedpyright, mypy, semgrep, specmatic)
14
+ - ✅ Bundle management (create, load, save, validate structure)
15
+ - ✅ Metadata management (timestamps, hashes, telemetry)
16
+ - ✅ Planning operations (init, add-feature, add-story, update-idea, update-feature)
17
+ - ✅ AST/Semgrep-based analysis (code structure, patterns, relationships)
18
+ - ✅ Specmatic validation (OpenAPI/AsyncAPI contract validation)
19
+ - ✅ Format validation (YAML/JSON schema compliance)
20
+ - ✅ Source tracking and drift detection
21
+
22
+ **CRITICAL LIMITATIONS**:
23
+
24
+ - ❌ **CANNOT generate code** - No LLM available in CLI-only mode
25
+ - ❌ **CANNOT do reasoning** - No semantic understanding without LLM
26
+
27
+ ### LLM-Required Operations (AI IDE Mode - Via Slash Prompts)
28
+
29
+ These operations **require LLM** and are only available via AI IDE slash prompts:
30
+
31
+ - ✅ Code generation (requires LLM reasoning)
32
+ - ✅ Code enhancement (contracts, refactoring, improvements)
33
+ - ✅ Semantic understanding (business logic, context, priorities)
34
+ - ✅ Plan enrichment (missing features, confidence adjustments, business context)
35
+ - ✅ Code reasoning (why decisions were made, trade-offs, constraints)
36
+
37
+ **Access**: Only available via AI IDE slash prompts (Cursor, CoPilot, etc.)
38
+ **Pattern**: Slash prompt → LLM generates → CLI validates → Apply if valid
39
+
40
+ ## Rules
41
+
42
+ 1. **Execute CLI First**: Always run CLI commands before any analysis
43
+ 2. **Use CLI for Writes**: All write operations must go through CLI
44
+ 3. **Read for Display Only**: Use file reading tools for display/analysis only
45
+ 4. **Never Modify .specfact/**: Do not create/modify files in `.specfact/` directly
46
+ 5. **Never Bypass Validation**: CLI ensures schema compliance and metadata
47
+ 6. **Code Generation Requires LLM**: Code generation is only possible via AI IDE slash prompts, not CLI-only
48
+
49
+ ## Standard Validation Loop Pattern (For LLM-Generated Code)
50
+
51
+ When generating or enhancing code via LLM, **ALWAYS** follow this pattern:
52
+
53
+ ```text
54
+ 1. CLI Prompt Generation (Required)
55
+
56
+ CLI generates structured prompt → saved to .specfact/prompts/
57
+ (e.g., `generate contracts-prompt`, future: `generate code-prompt`)
58
+
59
+ 2. LLM Execution (Required - AI IDE Only)
60
+
61
+ LLM reads prompt → generates enhanced code → writes to TEMPORARY file
62
+ (NEVER writes directly to original artifacts)
63
+ Pattern: `enhanced_<filename>.py` or `generated_<feature>.py`
64
+
65
+ 3. CLI Validation Loop (Required, up to N retries)
66
+
67
+ CLI validates temp file with all relevant tools:
68
+ - Syntax validation (py_compile)
69
+ - File size check (must be >= original)
70
+ - AST structure comparison (preserve functions/classes)
71
+ - Contract imports verification
72
+ - Code quality checks (ruff, pylint, basedpyright, mypy)
73
+ - Test execution (contract-test, pytest)
74
+
75
+ If validation fails:
76
+ - CLI provides detailed error feedback
77
+ - LLM fixes issues in temp file
78
+ - Re-validate (max 3 attempts)
79
+
80
+ If validation succeeds:
81
+ - CLI applies changes to original file
82
+ - CLI removes temporary file
83
+ - CLI updates metadata/telemetry
84
+ ```
85
+
86
+ **This pattern must be used for**:
87
+
88
+ - ✅ Contract enhancement (`generate contracts-prompt` / `contracts-apply`) - Already implemented
89
+ - ⏳ Code generation (future: `generate code-prompt` / `code-apply`) - Needs implementation
90
+ - ⏳ Plan enrichment (future: `plan enrich-prompt` / `enrich-apply`) - Needs implementation
91
+ - ⏳ Any LLM-enhanced artifact modification - Needs implementation
92
+
93
+ ## What Happens If You Don't Follow
94
+
95
+ - ❌ Artifacts may not match CLI schema versions
96
+ - ❌ Missing metadata and telemetry
97
+ - ❌ Format inconsistencies
98
+ - ❌ Validation failures
99
+ - ❌ Works only in Copilot mode, fails in CI/CD
100
+ - ❌ Code generation attempts in CLI-only mode will fail (no LLM available)
101
+
102
+ ## Available CLI Commands
103
+
104
+ - `specfact plan init <bundle-name>` - Initialize project bundle
105
+ - `specfact plan select <bundle-name>` - Set active plan (used as default for other commands)
106
+ - `specfact import from-code [<bundle-name>] --repo <path>` - Import from codebase (uses active plan if bundle not specified)
107
+ - `specfact plan review [<bundle-name>]` - Review plan (uses active plan if bundle not specified)
108
+ - `specfact plan harden [<bundle-name>]` - Create SDD manifest (uses active plan if bundle not specified)
109
+ - `specfact enforce sdd [<bundle-name>]` - Validate SDD (uses active plan if bundle not specified)
110
+ - `specfact sync bridge --adapter <adapter> --repo <path>` - Sync with external tools
111
+ - See [Command Reference](../../docs/reference/commands.md) for full list
112
+
113
+ **Note**: Most commands now support active plan fallback. If `--bundle` is not specified, commands automatically use the active plan set via `plan select`. This improves workflow efficiency in AI IDE environments.
@@ -0,0 +1,118 @@
1
+ ---
2
+ description: Import codebase → plan bundle. CLI extracts routes/schemas/relationships. LLM enriches with context.
3
+ ---
4
+
5
+ # SpecFact Import 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
+ ## Purpose
16
+
17
+ Import codebase → plan bundle. CLI extracts routes/schemas/relationships/contracts. LLM enriches context/"why"/completeness.
18
+
19
+ ## Parameters
20
+
21
+ **Target/Input**: `--bundle NAME` (optional, defaults to active plan), `--repo PATH`, `--entry-point PATH`, `--enrichment PATH`
22
+ **Output/Results**: `--report PATH`
23
+ **Behavior/Options**: `--shadow-only`, `--enrich-for-speckit`
24
+ **Advanced/Configuration**: `--confidence FLOAT` (0.0-1.0), `--key-format FORMAT` (classname|sequential)
25
+
26
+ ## Workflow
27
+
28
+ 1. **Execute CLI**: `specfact import from-code [<bundle>] --repo <path> [options]`
29
+ - CLI extracts: routes (FastAPI/Flask/Django), schemas (Pydantic), relationships, contracts (OpenAPI scaffolds), source tracking
30
+ - Uses active plan if bundle not specified
31
+
32
+ 2. **LLM Enrichment** (if `--enrichment` provided):
33
+ - Read `.specfact/projects/<bundle>/enrichment_context.md`
34
+ - Enrich: business context, "why" reasoning, missing acceptance criteria
35
+ - Validate: contracts vs code, feature/story alignment
36
+ - Save enrichment report to `.specfact/reports/enrichment/` (if created)
37
+
38
+ 3. **Present**: Bundle location, report path, summary (features/stories/contracts/relationships)
39
+
40
+ ## CLI Enforcement
41
+
42
+ **CRITICAL**: Always use SpecFact CLI commands. See [CLI Enforcement Rules](./shared/cli-enforcement.md) for details.
43
+
44
+ **Rules:**
45
+
46
+ - Execute CLI first - never create artifacts directly
47
+ - Use `--no-interactive` flag in CI/CD environments
48
+ - Never modify `.specfact/` directly
49
+ - Use CLI output as grounding for validation
50
+ - Code generation requires LLM (only via AI IDE slash prompts, not CLI-only)
51
+
52
+ ## Dual-Stack Workflow (Copilot Mode)
53
+
54
+ When in copilot mode, follow this three-phase workflow:
55
+
56
+ ### Phase 1: CLI Grounding (REQUIRED)
57
+
58
+ ```bash
59
+ # Execute CLI to get structured output
60
+ specfact import from-code [<bundle>] --repo <path> --no-interactive
61
+ ```
62
+
63
+ **Capture**:
64
+
65
+ - CLI-generated artifacts (plan bundles, reports)
66
+ - Metadata (timestamps, confidence scores)
67
+ - Telemetry (execution time, file counts)
68
+
69
+ ### Phase 2: LLM Enrichment (OPTIONAL, Copilot Only)
70
+
71
+ **Purpose**: Add semantic understanding to CLI output
72
+
73
+ **What to do**:
74
+
75
+ - Read CLI-generated artifacts (use file reading tools for display only)
76
+ - Research codebase for additional context
77
+ - Identify missing features/stories
78
+ - Suggest confidence adjustments
79
+ - Extract business context
80
+
81
+ **What NOT to do**:
82
+
83
+ - ❌ Create YAML/JSON artifacts directly
84
+ - ❌ Modify CLI artifacts directly (use CLI commands to update)
85
+ - ❌ Bypass CLI validation
86
+ - ❌ Write to `.specfact/` folder directly (always use CLI)
87
+ - ❌ Use direct file manipulation tools for writing (use CLI commands)
88
+
89
+ **Output**: Generate enrichment report (Markdown) saved to `.specfact/reports/enrichment/`
90
+
91
+ ### Phase 3: CLI Artifact Creation (REQUIRED)
92
+
93
+ ```bash
94
+ # Use enrichment to update plan via CLI
95
+ specfact import from-code [<bundle>] --repo <path> --enrichment <enrichment-report> --no-interactive
96
+ ```
97
+
98
+ **Result**: Final artifacts are CLI-generated with validated enrichments
99
+
100
+ **Note**: If code generation is needed, use the validation loop pattern (see [CLI Enforcement Rules](./shared/cli-enforcement.md#standard-validation-loop-pattern-for-llm-generated-code))
101
+
102
+ ## Expected Output
103
+
104
+ **Success**: Bundle location, report path, summary (features/stories/contracts/relationships)
105
+ **Error**: Missing bundle name or bundle already exists
106
+
107
+ ## Common Patterns
108
+
109
+ ```bash
110
+ /specfact.01-import --repo . # Uses active plan
111
+ /specfact.01-import --bundle legacy-api --repo .
112
+ /specfact.01-import --repo . --entry-point src/auth/
113
+ /specfact.01-import --repo . --enrichment report.md
114
+ ```
115
+
116
+ ## Context
117
+
118
+ {ARGS}
@@ -75,7 +75,65 @@ specfact plan update-story [--bundle <name>] --feature <feature-key> --key <stor
75
75
 
76
76
  **CRITICAL**: Always use SpecFact CLI commands. See [CLI Enforcement Rules](./shared/cli-enforcement.md) for details.
77
77
 
78
- **Rules:** Execute CLI first, use `--no-interactive` in CI/CD, never modify `.specfact/` directly, use CLI output as grounding.
78
+ **Rules:**
79
+
80
+ - Execute CLI first - never create artifacts directly
81
+ - Use `--no-interactive` flag in CI/CD environments
82
+ - Never modify `.specfact/` directly
83
+ - Use CLI output as grounding for validation
84
+ - Code generation requires LLM (only via AI IDE slash prompts, not CLI-only)
85
+
86
+ ## Dual-Stack Workflow (Copilot Mode)
87
+
88
+ When in copilot mode, follow this three-phase workflow:
89
+
90
+ ### Phase 1: CLI Grounding (REQUIRED)
91
+
92
+ ```bash
93
+ # Execute CLI to get structured output
94
+ specfact plan <operation> [--bundle <name>] [options] --no-interactive
95
+ ```
96
+
97
+ **Capture**:
98
+
99
+ - CLI-generated artifacts (plan bundles, features, stories)
100
+ - Metadata (timestamps, confidence scores)
101
+ - Telemetry (execution time, file counts)
102
+
103
+ ### Phase 2: LLM Enrichment (OPTIONAL, Copilot Only)
104
+
105
+ **Purpose**: Add semantic understanding to CLI output
106
+
107
+ **What to do**:
108
+
109
+ - Read CLI-generated artifacts (use file reading tools for display only)
110
+ - Research codebase for additional context
111
+ - Identify missing features/stories
112
+ - Suggest confidence adjustments
113
+ - Extract business context
114
+
115
+ **What NOT to do**:
116
+
117
+ - ❌ Create YAML/JSON artifacts directly
118
+ - ❌ Modify CLI artifacts directly (use CLI commands to update)
119
+ - ❌ Bypass CLI validation
120
+ - ❌ Write to `.specfact/` folder directly (always use CLI)
121
+ - ❌ Use direct file manipulation tools for writing (use CLI commands)
122
+
123
+ **Output**: Generate enrichment report (Markdown) or use `--batch-updates` JSON/YAML file
124
+
125
+ ### Phase 3: CLI Artifact Creation (REQUIRED)
126
+
127
+ ```bash
128
+ # Use enrichment to update plan via CLI
129
+ specfact plan update-feature [--bundle <name>] --key <key> [options] --no-interactive
130
+ # Or use batch updates:
131
+ specfact plan update-feature [--bundle <name>] --batch-updates <updates.json> --no-interactive
132
+ ```
133
+
134
+ **Result**: Final artifacts are CLI-generated with validated enrichments
135
+
136
+ **Note**: If code generation is needed, use the validation loop pattern (see [CLI Enforcement Rules](./shared/cli-enforcement.md#standard-validation-loop-pattern-for-llm-generated-code))
79
137
 
80
138
  ## Expected Output
81
139
 
@@ -151,7 +151,63 @@ specfact import from-code [<bundle-name>] --repo . --enrichment enrichment-repor
151
151
 
152
152
  **CRITICAL**: Always use SpecFact CLI commands. See [CLI Enforcement Rules](./shared/cli-enforcement.md) for details.
153
153
 
154
- **Rules:** Execute CLI first, use `--no-interactive` in CI/CD, never modify `.specfact/` directly, use CLI output as grounding.
154
+ **Rules:**
155
+
156
+ - Execute CLI first - never create artifacts directly
157
+ - Use `--no-interactive` flag in CI/CD environments
158
+ - Never modify `.specfact/` directly
159
+ - Use CLI output as grounding for validation
160
+ - Code generation requires LLM (only via AI IDE slash prompts, not CLI-only)
161
+
162
+ ## Dual-Stack Workflow (Copilot Mode)
163
+
164
+ When in copilot mode, follow this three-phase workflow:
165
+
166
+ ### Phase 1: CLI Grounding (REQUIRED)
167
+
168
+ ```bash
169
+ # Execute CLI to get structured output
170
+ specfact plan review [<bundle-name>] --list-findings --findings-format json --no-interactive
171
+ ```
172
+
173
+ **Capture**:
174
+
175
+ - CLI-generated findings (ambiguities, missing information)
176
+ - Structured JSON/YAML output for bulk processing
177
+ - Metadata (timestamps, confidence scores)
178
+
179
+ ### Phase 2: LLM Enrichment (OPTIONAL, Copilot Only)
180
+
181
+ **Purpose**: Add semantic understanding to CLI findings
182
+
183
+ **What to do**:
184
+
185
+ - Read CLI-generated findings (use file reading tools for display only)
186
+ - Research codebase for additional context
187
+ - Generate enrichment report or batch update file
188
+ - Address ambiguities with business context
189
+
190
+ **What NOT to do**:
191
+
192
+ - ❌ Create YAML/JSON artifacts directly
193
+ - ❌ Modify CLI artifacts directly (use CLI commands to update)
194
+ - ❌ Bypass CLI validation
195
+ - ❌ Write to `.specfact/` folder directly (always use CLI)
196
+
197
+ **Output**: Generate enrichment report (Markdown) or batch update JSON/YAML file
198
+
199
+ ### Phase 3: CLI Artifact Creation (REQUIRED)
200
+
201
+ ```bash
202
+ # Use enrichment to update plan via CLI
203
+ specfact plan update-feature [--bundle <name>] --batch-updates <updates.json> --no-interactive
204
+ # Or use auto-enrich:
205
+ specfact plan review [<bundle-name>] --auto-enrich --no-interactive
206
+ ```
207
+
208
+ **Result**: Final artifacts are CLI-generated with validated enrichments
209
+
210
+ **Note**: If code generation is needed, use the validation loop pattern (see [CLI Enforcement Rules](./shared/cli-enforcement.md#standard-validation-loop-pattern-for-llm-generated-code))
155
211
 
156
212
  ## Expected Output
157
213
 
@@ -58,7 +58,61 @@ specfact plan harden [<bundle-name>] [--sdd <path>] [--output-format <format>]
58
58
 
59
59
  **CRITICAL**: Always use SpecFact CLI commands. See [CLI Enforcement Rules](./shared/cli-enforcement.md) for details.
60
60
 
61
- **Rules:** Execute CLI first, use `--no-interactive` in CI/CD, never modify `.specfact/` directly, use CLI output as grounding.
61
+ **Rules:**
62
+
63
+ - Execute CLI first - never create artifacts directly
64
+ - Use `--no-interactive` flag in CI/CD environments
65
+ - Never modify `.specfact/` directly
66
+ - Use CLI output as grounding for validation
67
+ - Code generation requires LLM (only via AI IDE slash prompts, not CLI-only)
68
+
69
+ ## Dual-Stack Workflow (Copilot Mode)
70
+
71
+ When in copilot mode, follow this three-phase workflow:
72
+
73
+ ### Phase 1: CLI Grounding (REQUIRED)
74
+
75
+ ```bash
76
+ # Execute CLI to get structured output
77
+ specfact plan harden [<bundle-name>] [--sdd <path>] --no-interactive
78
+ ```
79
+
80
+ **Capture**:
81
+
82
+ - CLI-generated SDD manifest
83
+ - Metadata (hash, coverage metrics)
84
+ - Telemetry (execution time, file counts)
85
+
86
+ ### Phase 2: LLM Enrichment (OPTIONAL, Copilot Only)
87
+
88
+ **Purpose**: Add semantic understanding to SDD content
89
+
90
+ **What to do**:
91
+
92
+ - Read CLI-generated SDD (use file reading tools for display only)
93
+ - Research codebase for additional context
94
+ - Suggest improvements to WHY/WHAT/HOW sections
95
+
96
+ **What NOT to do**:
97
+
98
+ - ❌ Create YAML/JSON artifacts directly
99
+ - ❌ Modify CLI artifacts directly (use CLI commands to update)
100
+ - ❌ Bypass CLI validation
101
+ - ❌ Write to `.specfact/` folder directly (always use CLI)
102
+
103
+ **Output**: Generate enrichment report (Markdown) with suggestions
104
+
105
+ ### Phase 3: CLI Artifact Creation (REQUIRED)
106
+
107
+ ```bash
108
+ # Use enrichment to update plan via CLI, then regenerate SDD
109
+ specfact plan update-idea [--bundle <name>] [options] --no-interactive
110
+ specfact plan harden [<bundle-name>] --no-interactive
111
+ ```
112
+
113
+ **Result**: Final SDD is CLI-generated with validated enrichments
114
+
115
+ **Note**: If code generation is needed, use the validation loop pattern (see [CLI Enforcement Rules](./shared/cli-enforcement.md#standard-validation-loop-pattern-for-llm-generated-code))
62
116
 
63
117
  ## Expected Output
64
118
 
@@ -62,7 +62,61 @@ specfact enforce sdd [<bundle-name>] [--sdd <path>] [--output-format <format>] [
62
62
 
63
63
  **CRITICAL**: Always use SpecFact CLI commands. See [CLI Enforcement Rules](./shared/cli-enforcement.md) for details.
64
64
 
65
- **Rules:** Execute CLI first, use `--no-interactive` in CI/CD, never modify `.specfact/` directly, use CLI output as grounding.
65
+ **Rules:**
66
+
67
+ - Execute CLI first - never create artifacts directly
68
+ - Use `--no-interactive` flag in CI/CD environments
69
+ - Never modify `.specfact/` directly
70
+ - Use CLI output as grounding for validation
71
+ - Code generation requires LLM (only via AI IDE slash prompts, not CLI-only)
72
+
73
+ ## Dual-Stack Workflow (Copilot Mode)
74
+
75
+ When in copilot mode, follow this three-phase workflow:
76
+
77
+ ### Phase 1: CLI Grounding (REQUIRED)
78
+
79
+ ```bash
80
+ # Execute CLI to get structured output
81
+ specfact enforce sdd [<bundle-name>] [--sdd <path>] --no-interactive
82
+ ```
83
+
84
+ **Capture**:
85
+
86
+ - CLI-generated validation report
87
+ - Deviation counts and severity
88
+ - Coverage metrics vs thresholds
89
+
90
+ ### Phase 2: LLM Enrichment (OPTIONAL, Copilot Only)
91
+
92
+ **Purpose**: Add semantic understanding to validation results
93
+
94
+ **What to do**:
95
+
96
+ - Read CLI-generated validation report (use file reading tools for display only)
97
+ - Research codebase for context on deviations
98
+ - Suggest fixes for validation failures
99
+
100
+ **What NOT to do**:
101
+
102
+ - ❌ Create YAML/JSON artifacts directly
103
+ - ❌ Modify CLI artifacts directly (use CLI commands to update)
104
+ - ❌ Bypass CLI validation
105
+ - ❌ Write to `.specfact/` folder directly (always use CLI)
106
+
107
+ **Output**: Generate fix suggestions report (Markdown)
108
+
109
+ ### Phase 3: CLI Artifact Creation (REQUIRED)
110
+
111
+ ```bash
112
+ # Apply fixes via CLI commands, then re-validate
113
+ specfact plan update-feature [--bundle <name>] [options] --no-interactive
114
+ specfact enforce sdd [<bundle-name>] --no-interactive
115
+ ```
116
+
117
+ **Result**: Final artifacts are CLI-generated with validated fixes
118
+
119
+ **Note**: If code generation is needed, use the validation loop pattern (see [CLI Enforcement Rules](./shared/cli-enforcement.md#standard-validation-loop-pattern-for-llm-generated-code))
66
120
 
67
121
  ## Expected Output
68
122
 
@@ -65,7 +65,61 @@ specfact sync bridge --adapter <adapter> --repo <path> [--bidirectional] [--bund
65
65
 
66
66
  **CRITICAL**: Always use SpecFact CLI commands. See [CLI Enforcement Rules](./shared/cli-enforcement.md) for details.
67
67
 
68
- **Rules:** Execute CLI first, use appropriate flags in CI/CD, never modify `.specfact/` or `.specify/` directly, use CLI output as grounding.
68
+ **Rules:**
69
+
70
+ - Execute CLI first - never create artifacts directly
71
+ - Use `--no-interactive` flag in CI/CD environments
72
+ - Never modify `.specfact/` or `.specify/` directly
73
+ - Use CLI output as grounding for validation
74
+ - Code generation requires LLM (only via AI IDE slash prompts, not CLI-only)
75
+
76
+ ## Dual-Stack Workflow (Copilot Mode)
77
+
78
+ When in copilot mode, follow this three-phase workflow:
79
+
80
+ ### Phase 1: CLI Grounding (REQUIRED)
81
+
82
+ ```bash
83
+ # Execute CLI to get structured output
84
+ specfact sync bridge --adapter <adapter> --repo <path> [options] --no-interactive
85
+ ```
86
+
87
+ **Capture**:
88
+
89
+ - CLI-generated sync results
90
+ - Artifacts synchronized
91
+ - Conflict resolution status
92
+
93
+ ### Phase 2: LLM Enrichment (OPTIONAL, Copilot Only)
94
+
95
+ **Purpose**: Add semantic understanding to sync results
96
+
97
+ **What to do**:
98
+
99
+ - Read CLI-generated sync results (use file reading tools for display only)
100
+ - Research codebase for context on conflicts
101
+ - Suggest resolution strategies
102
+
103
+ **What NOT to do**:
104
+
105
+ - ❌ Create YAML/JSON artifacts directly
106
+ - ❌ Modify CLI artifacts directly (use CLI commands to update)
107
+ - ❌ Bypass CLI validation
108
+ - ❌ Write to `.specfact/` or `.specify/` folders directly (always use CLI)
109
+
110
+ **Output**: Generate conflict resolution suggestions (Markdown)
111
+
112
+ ### Phase 3: CLI Artifact Creation (REQUIRED)
113
+
114
+ ```bash
115
+ # Apply resolutions via CLI commands, then re-sync
116
+ specfact plan update-feature [--bundle <name>] [options] --no-interactive
117
+ specfact sync bridge --adapter <adapter> --repo <path> --no-interactive
118
+ ```
119
+
120
+ **Result**: Final artifacts are CLI-generated with validated resolutions
121
+
122
+ **Note**: If code generation is needed, use the validation loop pattern (see [CLI Enforcement Rules](./shared/cli-enforcement.md#standard-validation-loop-pattern-for-llm-generated-code))
69
123
 
70
124
  ## Expected Output
71
125