codexspec 0.7.22__tar.gz → 0.7.24__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 (137) hide show
  1. {codexspec-0.7.22 → codexspec-0.7.24}/PKG-INFO +4 -1
  2. {codexspec-0.7.22 → codexspec-0.7.24}/README.md +3 -0
  3. {codexspec-0.7.22 → codexspec-0.7.24}/pyproject.toml +1 -1
  4. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/__init__.py +45 -1
  5. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/commit_guidance.py +10 -3
  6. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/i18n.py +5 -0
  7. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/integrations/codex.py +2 -0
  8. codexspec-0.7.24/src/codexspec/review_maintenance.py +150 -0
  9. codexspec-0.7.24/src/codexspec/review_standards.py +33 -0
  10. codexspec-0.7.24/src/codexspec/specs_context.py +86 -0
  11. {codexspec-0.7.22 → codexspec-0.7.24}/templates/commands/analyze.md +16 -0
  12. {codexspec-0.7.22 → codexspec-0.7.24}/templates/commands/blueprint.md +16 -0
  13. {codexspec-0.7.22 → codexspec-0.7.24}/templates/commands/commit-staged.md +1 -1
  14. {codexspec-0.7.22 → codexspec-0.7.24}/templates/commands/config.md +20 -0
  15. {codexspec-0.7.22 → codexspec-0.7.24}/templates/commands/debug.md +16 -0
  16. {codexspec-0.7.22 → codexspec-0.7.24}/templates/commands/design-to-plan.md +16 -0
  17. {codexspec-0.7.22 → codexspec-0.7.24}/templates/commands/generate-spec.md +16 -0
  18. {codexspec-0.7.22 → codexspec-0.7.24}/templates/commands/implement-tasks.md +40 -7
  19. {codexspec-0.7.22 → codexspec-0.7.24}/templates/commands/plan-to-tasks.md +16 -0
  20. {codexspec-0.7.22 → codexspec-0.7.24}/templates/commands/quick.md +16 -0
  21. codexspec-0.7.24/templates/commands/review-code.md +281 -0
  22. {codexspec-0.7.22 → codexspec-0.7.24}/templates/commands/review-design.md +16 -0
  23. {codexspec-0.7.22 → codexspec-0.7.24}/templates/commands/review-plan.md +16 -0
  24. {codexspec-0.7.22 → codexspec-0.7.24}/templates/commands/review-spec.md +16 -0
  25. {codexspec-0.7.22 → codexspec-0.7.24}/templates/commands/review-tasks.md +16 -0
  26. {codexspec-0.7.22 → codexspec-0.7.24}/templates/commands/spec-to-design.md +16 -0
  27. {codexspec-0.7.22 → codexspec-0.7.24}/templates/commands/specify.md +16 -0
  28. codexspec-0.7.24/templates/review-code/change-review.md +351 -0
  29. codexspec-0.7.24/templates/review-code/common.md +63 -0
  30. codexspec-0.7.24/templates/review-code/dimensions/business-semantics.md +55 -0
  31. codexspec-0.7.24/templates/review-code/dimensions/concurrency.md +51 -0
  32. codexspec-0.7.24/templates/review-code/dimensions/logic.md +107 -0
  33. codexspec-0.7.24/templates/review-code/dimensions/maintainability.md +35 -0
  34. codexspec-0.7.24/templates/review-code/dimensions/performance.md +43 -0
  35. codexspec-0.7.24/templates/review-code/dimensions/robustness.md +91 -0
  36. codexspec-0.7.24/templates/review-code/dimensions/security.md +107 -0
  37. codexspec-0.7.24/templates/review-code/frameworks/react.md +46 -0
  38. codexspec-0.7.24/templates/review-code/index.md +51 -0
  39. codexspec-0.7.24/templates/review-code/languages/c.md +49 -0
  40. codexspec-0.7.24/templates/review-code/languages/cpp.md +53 -0
  41. codexspec-0.7.24/templates/review-code/languages/csharp.md +19 -0
  42. codexspec-0.7.24/templates/review-code/languages/go.md +75 -0
  43. codexspec-0.7.24/templates/review-code/languages/java.md +50 -0
  44. codexspec-0.7.24/templates/review-code/languages/javascript.md +23 -0
  45. codexspec-0.7.24/templates/review-code/languages/kotlin.md +50 -0
  46. codexspec-0.7.24/templates/review-code/languages/php.md +19 -0
  47. codexspec-0.7.24/templates/review-code/languages/python.md +62 -0
  48. codexspec-0.7.24/templates/review-code/languages/ruby.md +54 -0
  49. codexspec-0.7.24/templates/review-code/languages/rust.md +54 -0
  50. codexspec-0.7.24/templates/review-code/languages/shell.md +54 -0
  51. codexspec-0.7.24/templates/review-code/languages/swift.md +19 -0
  52. codexspec-0.7.24/templates/review-code/languages/typescript.md +58 -0
  53. codexspec-0.7.24/templates/review-code/quality-assessment.md +410 -0
  54. codexspec-0.7.22/templates/commands/review-code.md +0 -1273
  55. {codexspec-0.7.22 → codexspec-0.7.24}/.gitignore +0 -0
  56. {codexspec-0.7.22 → codexspec-0.7.24}/LICENSE +0 -0
  57. {codexspec-0.7.22 → codexspec-0.7.24}/codexspec-icon.svg +0 -0
  58. {codexspec-0.7.22 → codexspec-0.7.24}/codexspec-logo-dark.svg +0 -0
  59. {codexspec-0.7.22 → codexspec-0.7.24}/codexspec-logo-light.svg +0 -0
  60. {codexspec-0.7.22 → codexspec-0.7.24}/scripts/bash/check-i18n-completeness.sh +0 -0
  61. {codexspec-0.7.22 → codexspec-0.7.24}/scripts/bash/check-i18n-structure.sh +0 -0
  62. {codexspec-0.7.22 → codexspec-0.7.24}/scripts/bash/check-prerequisites.sh +0 -0
  63. {codexspec-0.7.22 → codexspec-0.7.24}/scripts/bash/common.sh +0 -0
  64. {codexspec-0.7.22 → codexspec-0.7.24}/scripts/bash/create-new-feature.sh +0 -0
  65. {codexspec-0.7.22 → codexspec-0.7.24}/scripts/bash/review-context.sh +0 -0
  66. {codexspec-0.7.22 → codexspec-0.7.24}/scripts/powershell/check-prerequisites.ps1 +0 -0
  67. {codexspec-0.7.22 → codexspec-0.7.24}/scripts/powershell/common.ps1 +0 -0
  68. {codexspec-0.7.22 → codexspec-0.7.24}/scripts/powershell/create-new-feature.ps1 +0 -0
  69. {codexspec-0.7.22 → codexspec-0.7.24}/scripts/powershell/review-context.ps1 +0 -0
  70. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/automation.py +0 -0
  71. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/blueprint.py +0 -0
  72. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/commands/__init__.py +0 -0
  73. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/commands/installer.py +0 -0
  74. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/commit_runtime.py +0 -0
  75. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/distill_review/__init__.py +0 -0
  76. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/distill_review/assets/app.js +0 -0
  77. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/distill_review/assets/i18n/ar.json +0 -0
  78. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/distill_review/assets/i18n/de.json +0 -0
  79. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/distill_review/assets/i18n/en.json +0 -0
  80. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/distill_review/assets/i18n/es.json +0 -0
  81. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/distill_review/assets/i18n/fr.json +0 -0
  82. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/distill_review/assets/i18n/hi.json +0 -0
  83. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/distill_review/assets/i18n/it.json +0 -0
  84. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/distill_review/assets/i18n/ja.json +0 -0
  85. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/distill_review/assets/i18n/ko.json +0 -0
  86. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/distill_review/assets/i18n/pt.json +0 -0
  87. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/distill_review/assets/i18n/ru.json +0 -0
  88. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/distill_review/assets/i18n/zh-CN.json +0 -0
  89. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/distill_review/assets/i18n/zh-TW.json +0 -0
  90. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/distill_review/assets/index.html +0 -0
  91. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/distill_review/assets/styles.css +0 -0
  92. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/distill_review/domain.py +0 -0
  93. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/distill_review/lease.py +0 -0
  94. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/distill_review/models.py +0 -0
  95. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/distill_review/records.py +0 -0
  96. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/distill_review/server.py +0 -0
  97. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/distill_review/session.py +0 -0
  98. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/distill_review/terminal.py +0 -0
  99. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/distill_review/transaction.py +0 -0
  100. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/idea.md +0 -0
  101. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/integrations/__init__.py +0 -0
  102. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/integrations/base.py +0 -0
  103. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/integrations/claude.py +0 -0
  104. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/merge_commits.py +0 -0
  105. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/profile.py +0 -0
  106. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/staged_commits.py +0 -0
  107. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/translator.py +0 -0
  108. {codexspec-0.7.22 → codexspec-0.7.24}/src/codexspec/worktrees.py +0 -0
  109. {codexspec-0.7.22 → codexspec-0.7.24}/templates/commands/auto-dev.md +0 -0
  110. {codexspec-0.7.22 → codexspec-0.7.24}/templates/commands/checklist.md +0 -0
  111. {codexspec-0.7.22 → codexspec-0.7.24}/templates/commands/clarify.md +0 -0
  112. {codexspec-0.7.22 → codexspec-0.7.24}/templates/commands/constitution.md +0 -0
  113. {codexspec-0.7.22 → codexspec-0.7.24}/templates/commands/distill.md +0 -0
  114. {codexspec-0.7.22 → codexspec-0.7.24}/templates/commands/evolve.md +0 -0
  115. {codexspec-0.7.22 → codexspec-0.7.24}/templates/commands/onboard.md +0 -0
  116. {codexspec-0.7.22 → codexspec-0.7.24}/templates/commands/pr.md +0 -0
  117. {codexspec-0.7.22 → codexspec-0.7.24}/templates/commands/release-notes.md +0 -0
  118. {codexspec-0.7.22 → codexspec-0.7.24}/templates/commands/reverse-spec.md +0 -0
  119. {codexspec-0.7.22 → codexspec-0.7.24}/templates/commands/tasks-to-issues.md +0 -0
  120. {codexspec-0.7.22 → codexspec-0.7.24}/templates/docs/checklist-template.md +0 -0
  121. {codexspec-0.7.22 → codexspec-0.7.24}/templates/docs/constitution-template.md +0 -0
  122. {codexspec-0.7.22 → codexspec-0.7.24}/templates/docs/design-template.md +0 -0
  123. {codexspec-0.7.22 → codexspec-0.7.24}/templates/docs/plan-template-detailed.md +0 -0
  124. {codexspec-0.7.22 → codexspec-0.7.24}/templates/docs/plan-template-simple.md +0 -0
  125. {codexspec-0.7.22 → codexspec-0.7.24}/templates/docs/requirements-template.md +0 -0
  126. {codexspec-0.7.22 → codexspec-0.7.24}/templates/docs/spec-template-detailed.md +0 -0
  127. {codexspec-0.7.22 → codexspec-0.7.24}/templates/docs/spec-template-simple.md +0 -0
  128. {codexspec-0.7.22 → codexspec-0.7.24}/templates/docs/tasks-template-detailed.md +0 -0
  129. {codexspec-0.7.22 → codexspec-0.7.24}/templates/docs/tasks-template-simple.md +0 -0
  130. {codexspec-0.7.22 → codexspec-0.7.24}/templates/translations/de.json +0 -0
  131. {codexspec-0.7.22 → codexspec-0.7.24}/templates/translations/en.json +0 -0
  132. {codexspec-0.7.22 → codexspec-0.7.24}/templates/translations/es.json +0 -0
  133. {codexspec-0.7.22 → codexspec-0.7.24}/templates/translations/fr.json +0 -0
  134. {codexspec-0.7.22 → codexspec-0.7.24}/templates/translations/ja.json +0 -0
  135. {codexspec-0.7.22 → codexspec-0.7.24}/templates/translations/ko.json +0 -0
  136. {codexspec-0.7.22 → codexspec-0.7.24}/templates/translations/pt-BR.json +0 -0
  137. {codexspec-0.7.22 → codexspec-0.7.24}/templates/translations/zh-CN.json +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: codexspec
3
- Version: 0.7.22
3
+ Version: 0.7.24
4
4
  Summary: CodexSpec - A Requirements-First SDD toolkit for Claude Code
5
5
  Project-URL: Homepage, https://github.com/Zts0hg/codexspec
6
6
  Project-URL: Repository, https://github.com/Zts0hg/codexspec
@@ -565,6 +565,7 @@ Implementation follows **conditional TDD workflow**:
565
565
  | `--set-commit-lang`, `-c` | Set the commit-message language |
566
566
  | `--list-langs` | List all supported languages |
567
567
  | `--auto-next` | Toggle/set `workflow.auto_next` (bare toggles; or on/off) |
568
+ | `--auto-maintenance` | Toggle/set `workflow.auto_maintenance` (default on; bare toggles; or on/off) |
568
569
  | `--auto-distill` | Toggle/set `workflow.auto_distill` (default on; bare toggles; or on/off) |
569
570
  | `--worktrees` | Toggle/set checkout-local worktree isolation (default on; bare toggles; or on/off) |
570
571
 
@@ -713,6 +714,8 @@ codexspec config --set-commit-lang en
713
714
  codexspec config --auto-next
714
715
  ```
715
716
 
717
+ `codexspec config --auto-maintenance on|off` persists `workflow.auto_maintenance` as a YAML boolean in `.codexspec/config.yml`; an absent key means `true`. Both workflow switches accept case-insensitive `on/true/1/yes` and `off/false/0/no`. `implement-tasks` reads this setting when it automatically repairs reviewed code: `on` includes substantiated incremental maintenance improvements; `off` still reports them. Actual defects and required verification remain mandatory. This setting is independent of `auto-next` and is not an `implement-tasks` invocation parameter.
718
+
716
719
  ### Supported Languages
717
720
 
718
721
  | Code | Language |
@@ -520,6 +520,7 @@ Implementation follows **conditional TDD workflow**:
520
520
  | `--set-commit-lang`, `-c` | Set the commit-message language |
521
521
  | `--list-langs` | List all supported languages |
522
522
  | `--auto-next` | Toggle/set `workflow.auto_next` (bare toggles; or on/off) |
523
+ | `--auto-maintenance` | Toggle/set `workflow.auto_maintenance` (default on; bare toggles; or on/off) |
523
524
  | `--auto-distill` | Toggle/set `workflow.auto_distill` (default on; bare toggles; or on/off) |
524
525
  | `--worktrees` | Toggle/set checkout-local worktree isolation (default on; bare toggles; or on/off) |
525
526
 
@@ -668,6 +669,8 @@ codexspec config --set-commit-lang en
668
669
  codexspec config --auto-next
669
670
  ```
670
671
 
672
+ `codexspec config --auto-maintenance on|off` persists `workflow.auto_maintenance` as a YAML boolean in `.codexspec/config.yml`; an absent key means `true`. Both workflow switches accept case-insensitive `on/true/1/yes` and `off/false/0/no`. `implement-tasks` reads this setting when it automatically repairs reviewed code: `on` includes substantiated incremental maintenance improvements; `off` still reports them. Actual defects and required verification remain mandatory. This setting is independent of `auto-next` and is not an `implement-tasks` invocation parameter.
673
+
671
674
  ### Supported Languages
672
675
 
673
676
  | Code | Language |
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "codexspec"
3
- version = "0.7.22"
3
+ version = "0.7.24"
4
4
  description = "CodexSpec - A Requirements-First SDD toolkit for Claude Code"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -64,6 +64,9 @@ from .i18n import (
64
64
  )
65
65
  from .integrations import get_integrations
66
66
  from .profile import ensure_profile_scaffold, inject_profile_block
67
+ from .review_maintenance import read_auto_maintenance, write_auto_maintenance
68
+ from .review_standards import install_review_standards
69
+ from .specs_context import inject_specs_context
67
70
  from .translator import SUPPORTED_LANGUAGES, translate
68
71
  from .worktrees import (
69
72
  MAINTENANCE_NAME,
@@ -77,7 +80,7 @@ from .worktrees import (
77
80
  )
78
81
 
79
82
  # Version info
80
- __version__ = "0.7.22"
83
+ __version__ = "0.7.24"
81
84
  __author__ = "CodexSpec Team"
82
85
 
83
86
  # Constitution file path constants
@@ -636,6 +639,7 @@ _AUTO_NEXT_ACCEPTED = "on/off, true/false, 1/0, yes/no"
636
639
  # (opt-out): only the literal ``false`` disables it. Reuses the auto_next token
637
640
  # sets for parsing; a distinct sentinel keeps the bare-toggle rewrites separate.
638
641
  _AUTO_DISTILL_SENTINEL = "__toggle_distill__"
642
+ _AUTO_MAINTENANCE_SENTINEL = "__toggle_maintenance__"
639
643
 
640
644
  # review.decided_by: who decides about a review-code finding whose trigger lies
641
645
  # outside the project's real operating context. ``reviewer`` (default) keeps
@@ -703,6 +707,11 @@ def config(
703
707
  "--auto-distill",
704
708
  help="Toggle workflow.auto_distill (bare), or set it (on/off|true/false|1/0|yes/no).",
705
709
  ),
710
+ auto_maintenance: Optional[str] = typer.Option(
711
+ None,
712
+ "--auto-maintenance",
713
+ help="Set automatic incremental maintenance (on/off; default on), or toggle with the bare option.",
714
+ ),
706
715
  worktrees: Optional[str] = typer.Option(
707
716
  None, "--worktrees", help="Toggle checkout-local worktree isolation (default on), or set on/off."
708
717
  ),
@@ -751,6 +760,7 @@ def config(
751
760
  for value, sentinel, option in (
752
761
  (auto_next, _AUTO_NEXT_SENTINEL, "--auto-next"),
753
762
  (auto_distill, _AUTO_DISTILL_SENTINEL, "--auto-distill"),
763
+ (auto_maintenance, _AUTO_MAINTENANCE_SENTINEL, "--auto-maintenance"),
754
764
  (worktrees, "__toggle_worktrees__", "--worktrees"),
755
765
  ):
756
766
  if value is not None and value != sentinel:
@@ -771,6 +781,7 @@ def config(
771
781
  for value in (
772
782
  auto_next,
773
783
  auto_distill,
784
+ auto_maintenance,
774
785
  worktrees,
775
786
  decided_by,
776
787
  set_lang,
@@ -817,6 +828,21 @@ def config(
817
828
  raise typer.Exit(1)
818
829
  return
819
830
 
831
+ # Maintenance is an independent repair policy, never a stage-advance switch.
832
+ if auto_maintenance is not None:
833
+ try:
834
+ target = (
835
+ not read_auto_maintenance(config_file)
836
+ if auto_maintenance == _AUTO_MAINTENANCE_SENTINEL
837
+ else parse_auto_next_value(auto_maintenance)
838
+ )
839
+ write_auto_maintenance(config_file, target)
840
+ except (AutomationError, OSError, ValueError) as exc:
841
+ console.print(str(exc), markup=False)
842
+ raise typer.Exit(1) from exc
843
+ console.print(f"workflow.auto_maintenance = {str(target).lower()}")
844
+ return
845
+
820
846
  # Handle auto-next toggle/set
821
847
  if auto_next is not None:
822
848
  if auto_next == _AUTO_NEXT_SENTINEL:
@@ -996,6 +1022,11 @@ def config(
996
1022
  return
997
1023
 
998
1024
  # Display current configuration
1025
+ try:
1026
+ policy = str(read_auto_maintenance(config_file)).lower()
1027
+ except (AutomationError, OSError) as exc:
1028
+ policy = f"invalid ({exc})"
1029
+ console.print(f"Effective workflow.auto_maintenance: {policy}", markup=False)
999
1030
  console.print(f"Effective workflow.worktrees: {str(read_worktrees(config_file)).lower()}")
1000
1031
  stored_mode = _read_review_decided_by(config_file)
1001
1032
  if stored_mode in _DECIDED_BY_VALUES:
@@ -1327,6 +1358,7 @@ def init(
1327
1358
  )
1328
1359
  raise typer.Exit(1)
1329
1360
 
1361
+ refresh_review_standards = force
1330
1362
  if "claude" in integration_keys:
1331
1363
  # Create .claude/commands directory for slash commands
1332
1364
  claude_dir = target_dir / ".claude"
@@ -1360,6 +1392,7 @@ def init(
1360
1392
  if migration_happened:
1361
1393
  # Migration moved files, ask if user wants to update/translate them
1362
1394
  if force or Confirm.ask(translate("cli.init.update_confirm", normalized_lang), default=True):
1395
+ refresh_review_standards = True
1363
1396
  count = install_commands_to_subdir(
1364
1397
  codexspec_commands_dir, templates_dir, force=True, language=normalized_lang
1365
1398
  )
@@ -1367,6 +1400,7 @@ def init(
1367
1400
  elif should_update_commands(codexspec_dir):
1368
1401
  console.print()
1369
1402
  if force or Confirm.ask(translate("cli.init.update_confirm", normalized_lang), default=True):
1403
+ refresh_review_standards = True
1370
1404
  count = install_commands_to_subdir(
1371
1405
  codexspec_commands_dir, templates_dir, force=True, language=normalized_lang
1372
1406
  )
@@ -1386,6 +1420,13 @@ def init(
1386
1420
  "[/green]"
1387
1421
  )
1388
1422
 
1423
+ # Shared resources are installed once, outside platform-specific branches.
1424
+ try:
1425
+ install_review_standards(get_templates_dir() / "review-code", target_dir, force=refresh_review_standards)
1426
+ except (AutomationError, OSError) as exc:
1427
+ console.print(str(exc), markup=False)
1428
+ raise typer.Exit(1) from exc
1429
+
1389
1430
  # Create constitution template
1390
1431
  constitution_file = codexspec_dir / "memory" / "constitution.md"
1391
1432
  if not constitution_file.exists():
@@ -1463,6 +1504,7 @@ def init(
1463
1504
  # the compliance @import or the user's body (bounded, idempotent).
1464
1505
  inject_profile_block(claude_md)
1465
1506
  inject_commit_guidance(claude_md, "/codexspec:commit-staged")
1507
+ inject_specs_context(claude_md)
1466
1508
 
1467
1509
  # Initialize git if requested
1468
1510
  if not no_git and not (target_dir / ".git").exists():
@@ -2312,6 +2354,8 @@ def main() -> None:
2312
2354
  sys.argv = _normalize_auto_next_argv(sys.argv)
2313
2355
  if "--auto-distill" in sys.argv:
2314
2356
  sys.argv = _normalize_auto_distill_argv(sys.argv)
2357
+ if "--auto-maintenance" in sys.argv:
2358
+ sys.argv = _normalize_optional_value_argv(sys.argv, "--auto-maintenance", _AUTO_MAINTENANCE_SENTINEL)
2315
2359
  if "--worktrees" in sys.argv:
2316
2360
  sys.argv = _normalize_optional_value_argv(sys.argv, "--worktrees", "__toggle_worktrees__")
2317
2361
  app()
@@ -1,10 +1,12 @@
1
- """Managed context instructions for staged commit analysis."""
1
+ """Managed commit instructions and shared plugin startup guidance."""
2
2
 
3
3
  import json
4
4
  import re
5
5
  import shlex
6
6
  from pathlib import Path
7
7
 
8
+ from .specs_context import render_specs_context
9
+
8
10
  START = "<!-- CODEXSPEC COMMITS START -->"
9
11
  END = "<!-- CODEXSPEC COMMITS END -->"
10
12
 
@@ -44,8 +46,13 @@ def inject_commit_guidance(path: Path, invocation: str) -> None:
44
46
  path.write_text(updated, encoding="utf-8", newline="\n")
45
47
 
46
48
 
49
+ def render_plugin_guidance() -> str:
50
+ """Compose startup rules without duplicating either policy's source."""
51
+ return render_commit_guidance("/codexspec:commit-staged") + "\n\n" + render_specs_context()
52
+
53
+
47
54
  def install_plugin_commit_guidance(plugin: Path) -> Path:
48
- """Install SessionStart context without needing the CLI or project init.
55
+ """Install commit and specs context without needing the CLI or project init.
49
56
 
50
57
  Git is already required for commits. Its shell alias provides printf on all
51
58
  Git platforms; exec-form hooks pass this static command without host-shell
@@ -59,7 +66,7 @@ def install_plugin_commit_guidance(plugin: Path) -> Path:
59
66
  raise AutomationError("linked_commit_guidance", str(part))
60
67
  if destination.exists() and (not destination.is_file() or destination.stat().st_nlink != 1):
61
68
  raise AutomationError("shared_commit_guidance", str(destination))
62
- guidance = render_commit_guidance("/codexspec:commit-staged")
69
+ guidance = render_plugin_guidance()
63
70
  hook = {
64
71
  "type": "command",
65
72
  "command": "git",
@@ -207,6 +207,11 @@ language:
207
207
  project:
208
208
  ai: "claude"
209
209
  created: "{created}"
210
+
211
+ # Automatically apply substantiated incremental maintenance during repairs.
212
+ # Independent of workflow.auto_next, which controls stage advancement.
213
+ workflow:
214
+ auto_maintenance: true
210
215
  """
211
216
 
212
217
 
@@ -17,6 +17,7 @@ from codexspec.commands.installer import (
17
17
  )
18
18
  from codexspec.commit_guidance import inject_commit_guidance
19
19
  from codexspec.profile import inject_profile_block
20
+ from codexspec.specs_context import inject_specs_context
20
21
  from codexspec.translator import load_translation_cache, translate_template_frontmatter
21
22
 
22
23
  CODEXSPEC_CONTEXT_START = "<!-- CODEXSPEC START -->"
@@ -114,6 +115,7 @@ class CodexIntegration:
114
115
  # skills section, as its own bounded, idempotent managed block.
115
116
  inject_profile_block(context_path)
116
117
  inject_commit_guidance(context_path, self.invocation_for("commit-staged"))
118
+ inject_specs_context(context_path)
117
119
 
118
120
  def render_skill(self, command_name: str, content: str, fallback_description: str = "") -> str:
119
121
  """Render one command template into a Codex SKILL.md."""
@@ -0,0 +1,150 @@
1
+ """Persistent maintenance policy and target-bound review suggestion validation."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import re
7
+ from pathlib import Path, PurePosixPath, PureWindowsPath
8
+ from typing import Any
9
+
10
+ import yaml
11
+
12
+ from .automation import AutomationError
13
+ from .worktrees import write_config_scalar
14
+
15
+
16
+ def read_auto_maintenance(config: Path) -> bool:
17
+ """Read the boolean policy; absence defaults on, invalid explicit state refuses edits."""
18
+ try:
19
+ # Inspect the entry itself so an unreadable link is not treated as absent.
20
+ config.lstat()
21
+ except FileNotFoundError:
22
+ return True
23
+ except OSError as exc:
24
+ raise AutomationError("invalid_maintenance_config", str(config)) from exc
25
+ try:
26
+ # Use the existing writer's dry-run validation for duplicate keys, YAML
27
+ # layouts and aliases; read and write must agree on the managed field.
28
+ write_config_scalar(
29
+ config,
30
+ "workflow",
31
+ "auto_maintenance",
32
+ "true",
33
+ True,
34
+ error_prefix="maintenance",
35
+ dry_run=True,
36
+ )
37
+ data = yaml.safe_load(config.read_bytes().decode("utf-8")) or {}
38
+ except (OSError, UnicodeDecodeError, yaml.YAMLError) as exc:
39
+ raise AutomationError("invalid_maintenance_config", str(config)) from exc
40
+ if "workflow" not in data:
41
+ return True
42
+ workflow = data["workflow"]
43
+ if not isinstance(workflow, dict):
44
+ raise AutomationError("invalid_workflow_section", str(config))
45
+ if "auto_maintenance" not in workflow:
46
+ return True
47
+ value = workflow["auto_maintenance"]
48
+ if type(value) is not bool:
49
+ raise AutomationError("invalid_auto_maintenance", "Use an unquoted YAML boolean true or false.")
50
+ return value
51
+
52
+
53
+ def write_auto_maintenance(config: Path, value: bool) -> None:
54
+ """Persist only this policy, preserving unrelated YAML and formatting."""
55
+ if type(value) is not bool:
56
+ raise ValueError("auto_maintenance requires a boolean")
57
+ write_config_scalar(
58
+ config,
59
+ "workflow",
60
+ "auto_maintenance",
61
+ str(value).lower(),
62
+ value,
63
+ error_prefix="maintenance",
64
+ )
65
+
66
+
67
+ def _nonempty(value: object) -> bool:
68
+ return isinstance(value, str) and bool(value.strip())
69
+
70
+
71
+ def _strings(value: object) -> bool:
72
+ return isinstance(value, list) and bool(value) and all(_nonempty(item) for item in value)
73
+
74
+
75
+ def _safe_path(value: str) -> bool:
76
+ windows = PureWindowsPath(value)
77
+ path = PurePosixPath(value.replace("\\", "/"))
78
+ return (
79
+ bool(path.parts)
80
+ and not windows.drive
81
+ and not path.is_absolute()
82
+ and ".." not in path.parts
83
+ and "\x00" not in value
84
+ )
85
+
86
+
87
+ def _unique_object(pairs: list[tuple[str, Any]]) -> dict[str, Any]:
88
+ result: dict[str, Any] = {}
89
+ for key, value in pairs:
90
+ if key in result:
91
+ raise ValueError(f"Duplicate maintenance field: {key}")
92
+ result[key] = value
93
+ return result
94
+
95
+
96
+ def parse_maintenance_result(output: str, fingerprint: str | None) -> dict[str, Any]:
97
+ """Validate exactly one companion against the defect report's target identity.
98
+
99
+ This validates shape and relationships. Repair callers still independently
100
+ establish present benefit, change attribution and behavioral compatibility.
101
+ """
102
+ start, end = "<review-code-maintenance>", "</review-code-maintenance>"
103
+ if output.count(start) != 1 or output.count(end) != 1:
104
+ raise ValueError("Expected exactly one review-code-maintenance block")
105
+ match = re.search(re.escape(start) + r"\s*(.*?)\s*" + re.escape(end), output, re.DOTALL)
106
+ if match is None:
107
+ raise ValueError("Malformed maintenance block")
108
+ try:
109
+ result = json.loads(match.group(1), object_pairs_hook=_unique_object)
110
+ except (json.JSONDecodeError, RecursionError) as exc:
111
+ raise ValueError("Invalid maintenance JSON") from exc
112
+ if not isinstance(result, dict) or set(result) != {"schema_version", "target_fingerprint", "suggestions"}:
113
+ raise ValueError("Invalid maintenance object fields")
114
+ if result["schema_version"] != "1":
115
+ raise ValueError("Unsupported maintenance schema")
116
+ target = result["target_fingerprint"]
117
+ if target != fingerprint or (target is not None and not _nonempty(target)):
118
+ raise ValueError("Maintenance target fingerprint mismatch")
119
+ suggestions = result["suggestions"]
120
+ if not isinstance(suggestions, list) or (target is None and suggestions):
121
+ raise ValueError("Suggestions require a resolved target")
122
+ keys = {
123
+ "id",
124
+ "location",
125
+ "summary",
126
+ "problem",
127
+ "improvement",
128
+ "benefit",
129
+ "evidence",
130
+ "affected_paths",
131
+ "compatibility",
132
+ }
133
+ identities = set()
134
+ for item in suggestions:
135
+ if not isinstance(item, dict) or set(item) != keys:
136
+ raise ValueError("Invalid maintenance suggestion fields")
137
+ if any(not _nonempty(item[key]) for key in keys - {"evidence", "affected_paths"}):
138
+ raise ValueError("Maintenance text fields must be nonempty")
139
+ identity = item["id"]
140
+ if not re.fullmatch(r"M-[A-Za-z0-9-]+", identity) or identity in identities:
141
+ raise ValueError("Invalid or duplicate maintenance identity")
142
+ identities.add(identity)
143
+ if not _strings(item["evidence"]) or not _strings(item["affected_paths"]):
144
+ raise ValueError("Maintenance requires benefit evidence and affected paths")
145
+ if any(not _safe_path(path) for path in item["affected_paths"]):
146
+ raise ValueError("Maintenance paths must be project-relative")
147
+ location = re.fullmatch(r"(.+):([1-9][0-9]*)", item["location"])
148
+ if location is None or location.group(1) not in item["affected_paths"]:
149
+ raise ValueError("Maintenance location must identify an affected path and line")
150
+ return result
@@ -0,0 +1,33 @@
1
+ """Install the shared runtime review standards into a selected project."""
2
+
3
+ from pathlib import Path
4
+
5
+ from .automation import AutomationError
6
+ from .worktrees import validate_write_path
7
+
8
+
9
+ def install_review_standards(source: Path, project: Path, *, force: bool = False) -> int:
10
+ """Copy distributed Markdown bytes, preserving existing edits unless updating.
11
+
12
+ All destinations are checked before the first copy. Unrelated extension
13
+ files remain project-owned; no source/development mechanism is interpreted.
14
+ """
15
+ if not source.is_dir():
16
+ raise AutomationError("missing_review_standards", str(source))
17
+ files = sorted(source.rglob("*.md"))
18
+ if not files:
19
+ raise AutomationError("missing_review_standards", str(source))
20
+ destination = project / ".codexspec" / "review-code"
21
+ copies = [(path, destination / path.relative_to(source)) for path in files]
22
+ for _, target in copies:
23
+ validate_write_path(project, target)
24
+ if target.exists() and not target.is_file():
25
+ raise AutomationError("unsafe_write_path", f"Review standard destination is not a regular file: {target}")
26
+ count = 0
27
+ for path, target in copies:
28
+ if target.exists() and not force:
29
+ continue
30
+ target.parent.mkdir(parents=True, exist_ok=True)
31
+ target.write_bytes(path.read_bytes())
32
+ count += 1
33
+ return count
@@ -0,0 +1,86 @@
1
+ """Task-dependent historical-spec recall instructions for both agent integrations."""
2
+
3
+ import re
4
+ from pathlib import Path
5
+
6
+ START = "<!-- CODEXSPEC SPECS START -->"
7
+ END = "<!-- CODEXSPEC SPECS END -->"
8
+
9
+
10
+ _GUIDANCE = """## CodexSpec Historical Specs
11
+
12
+ Before substantive requirements, behavior, design, implementation, debugging, or
13
+ review judgments, actively recall relevant history under `.codexspec/specs/`.
14
+ This applies in ordinary conversation and SDD workflows. Prepare background before
15
+ questioning the user. Purely mechanical edits, such as spelling or formatting
16
+ with no substantive judgment, may omit recall.
17
+
18
+ Select related features by the task's capabilities, affected modules, interfaces,
19
+ and terminology; use directory names, artifact headings, and targeted text search
20
+ to find candidates. Read relevant requirements and follow earlier and later
21
+ additions, changes, and references. Do not stop at the first matching document or
22
+ load every historical artifact. Use feature-directory timestamps to reconstruct
23
+ the iteration timeline, together with explicit confirmation and replacement
24
+ records, including later revisions inside an older feature directory.
25
+
26
+ Confirmed content in each `requirements.md` is an authoritative user decision
27
+ record. Older unchanged requirements remain applicable; an unrelated later feature
28
+ does not replace them. Combine later additions with earlier requirements. A later
29
+ explicit change updates the same matter while retaining the earlier rationale
30
+ and unrelated requirements. Open proposals are not confirmed decisions. When a
31
+ relationship is unclear, explain the specific difference and ask a concise
32
+ question; do not assume an earlier requirement expired.
33
+
34
+ The user's latest explicit decision in the current interaction takes precedence
35
+ over historical specs: history must never override or replace it. Explain relevant
36
+ changes and implications. Do not ask again about the same explicit decision merely
37
+ because history differs. Use the owning requirements workflow to reflect changed
38
+ requirements before downstream artifacts rely on them, without repeating an
39
+ already answered question. Historical background must not silently rewrite current
40
+ requirements or broaden the selected target, permissions, or staged-only inputs.
41
+
42
+ Read to the depth needed for the scenario:
43
+
44
+ - Requirements discussion (including specify, quick, blueprint): reconstruct the
45
+ requirements timeline; read design rationale when needed to explain a trade-off.
46
+ Prepare known background, applicable requirements, and differences to confirm.
47
+ - Design and planning: use confirmed requirements plus relevant historical designs,
48
+ alternatives, and trade-offs; consult plans when implementation experience matters.
49
+ - Implementation and debugging: establish expected behavior and its successive
50
+ changes, then examine relevant design, code and tests; plans alone do not prove implementation.
51
+ - Code review: trace concrete changes and concerns to relevant requirements and
52
+ designs, checking current requirements, compatibility, and repeated problems.
53
+
54
+ Reuse applicable established information instead of asking the user to reconstruct
55
+ it. If continued applicability needs confirmation, present the known background
56
+ and a short targeted question. If history is missing or incomplete, distinguish
57
+ what is known from what remains uncertain; never invent decisions or confirmation.
58
+ For legacy artifacts without requirements, use available evidence and disclose
59
+ that original user confirmation cannot be established from those artifacts alone.
60
+
61
+ Stop expanding retrieval when relevant requirements, decision evolution, and
62
+ applicability support the current judgment. Do not expand into unrelated history;
63
+ ask about any remaining material ambiguity instead of silently choosing an answer.
64
+ Reuse prepared background across workflow stages and duplicate entry points.
65
+ Supplement retrieval when scope changes, new evidence appears, or the background
66
+ is insufficient for the judgment required. Reuse never makes incomplete evidence
67
+ sufficient. Keep relevant source paths and decision relationships with the prepared
68
+ background so later stages can reuse it without reconstructing the entire history."""
69
+
70
+
71
+ def render_specs_context() -> str:
72
+ """Return constant-size guidance; historical artifacts are read by the agent on demand."""
73
+ return "\n".join((START, _GUIDANCE, END))
74
+
75
+
76
+ def inject_specs_context(path: Path) -> None:
77
+ """Update only the bounded block, retaining surrounding UTF-8 text verbatim."""
78
+ block = render_specs_context()
79
+ existing = path.read_bytes().decode("utf-8") if path.exists() else ""
80
+ pattern = re.compile(re.escape(START) + r".*?" + re.escape(END), re.DOTALL)
81
+ if pattern.search(existing):
82
+ updated = pattern.sub(lambda _match: block, existing)
83
+ else:
84
+ separator = "" if not existing else "\n" if existing.endswith("\n") else "\n\n"
85
+ updated = existing + separator + block + "\n"
86
+ path.write_bytes(updated.encode("utf-8"))
@@ -112,6 +112,22 @@ override or imply immediate changes to main's effective value. Completion retain
112
112
  does not automatically merge to main or delete them. Any occupied path, invalid identity, failed
113
113
  creation, or unusable baseline is an explicit stop, never permission to fall back to main writes.
114
114
 
115
+ ## Historical Specs Before Decisions
116
+
117
+ Use the CodexSpec Historical Specs guidance to prepare relevant background from
118
+ `.codexspec/specs/` before substantive judgments or questions. Select related
119
+ features and trace earlier and later confirmed decisions; read requirements first,
120
+ then design, plans, or implementation evidence as the current scenario needs.
121
+ Reuse sufficient background; supplement it when scope, evidence, or judgment needs
122
+ change. Explain specific unresolved differences in concise questions instead of
123
+ asking the user to reconstruct known history.
124
+
125
+ The latest explicit user decision takes precedence over historical specs. History
126
+ does not silently change current requirements, broaden the selected target, or
127
+ override this command's write permissions or staged-only input restrictions.
128
+ When a confirmed decision changes current requirements, use the owning requirements
129
+ workflow to record it without asking the user to decide the same matter again.
130
+
115
131
  ## User Input
116
132
 
117
133
  `$ARGUMENTS`
@@ -114,6 +114,22 @@ override or imply immediate changes to main's effective value. Completion retain
114
114
  does not automatically merge to main or delete them. Any occupied path, invalid identity, failed
115
115
  creation, or unusable baseline is an explicit stop, never permission to fall back to main writes.
116
116
 
117
+ ## Historical Specs Before Decisions
118
+
119
+ Use the CodexSpec Historical Specs guidance to prepare relevant background from
120
+ `.codexspec/specs/` before substantive judgments or questions. Select related
121
+ features and trace earlier and later confirmed decisions; read requirements first,
122
+ then design, plans, or implementation evidence as the current scenario needs.
123
+ Reuse sufficient background; supplement it when scope, evidence, or judgment needs
124
+ change. Explain specific unresolved differences in concise questions instead of
125
+ asking the user to reconstruct known history.
126
+
127
+ The latest explicit user decision takes precedence over historical specs. History
128
+ does not silently change current requirements, broaden the selected target, or
129
+ override this command's write permissions or staged-only input restrictions.
130
+ When a confirmed decision changes current requirements, use the owning requirements
131
+ workflow to record it without asking the user to decide the same matter again.
132
+
117
133
  ## User Input
118
134
 
119
135
  `$ARGUMENTS`
@@ -187,7 +187,7 @@ repair staging, or include unstaged changes. Report unexpected or empty staging.
187
187
  Resolve one runtime for this invocation, without changing the input workspace:
188
188
 
189
189
  - When loaded from a Claude plugin, use its bundled
190
- `${CLAUDE_PLUGIN_ROOT}/commit-staged-helper.py`.
190
+ `${CLAUDE_PLUGIN_ROOT}/.claude/commands/codexspec/commit-staged-helper.py`.
191
191
  - After project initialization (including one-time `uvx` initialization), use
192
192
  `<original workspace>/.codexspec/scripts/commit-staged-helper.py` when present.
193
193
  - Otherwise, an installed `codexspec _commit-staged-helper` is the same protocol.
@@ -206,6 +206,7 @@ Display the configuration as in Step 2, then exit.
206
206
  {"label": "Commit language", "description": "Language for commit messages (currently: {current value})"},
207
207
  {"label": "Auto-next chain", "description": "Auto-advance the SDD pipeline once a stage passes (workflow.auto_next) (currently: {current value})"},
208
208
  {"label": "Auto-distill", "description": "Run /codexspec:distill on completion of wrap-up commands to capture reusable knowledge (workflow.auto_distill) (currently: {current value})"},
209
+ {"label": "Auto-maintenance", "description": "Automatically apply substantiated incremental maintenance during repairs (workflow.auto_maintenance; default on), independently of stage advancement"},
209
210
  {"label": "Review decision mode", "description": "Who decides about review-code findings whose trigger lies outside the project's real operating context (review.decided_by) (currently: {current value})"},
210
211
  {"label": "Back", "description": "Return to main menu"}
211
212
  ]
@@ -299,6 +300,19 @@ Display the configuration as in Step 2, then exit.
299
300
  neither `reviewer` nor `ask`, report it as invalid (review-code rejects it as an argument error) and
300
301
  offer to correct it.
301
302
 
303
+ 3d. For "Auto-maintenance", offer on (default), off, or Back. Persist
304
+ `workflow.auto_maintenance` as an unquoted YAML boolean true/false, preserving
305
+ all unrelated values, comments and line endings. Missing means enabled; an
306
+ explicit non-boolean or unreadable existing configuration is invalid and must
307
+ be corrected rather than guessed. CLI users can set it with
308
+ `codexspec config --auto-maintenance on|off`; bare use toggles the destination
309
+ checkout's value, using the same on/true/1/yes and off/false/0/no aliases,
310
+ case/whitespace handling as other switches. Help/examples use on/off.
311
+ Repair callers read this persistent setting; implementation commands do not
312
+ receive this setter option or a per-run override. Review still reports
313
+ maintenance when off; actual defects and required verification remain mandatory.
314
+ `auto_next` controls stage advancement separately.
315
+
302
316
  4. Update the configuration file with the new value
303
317
  5. Display the updated configuration
304
318
  6. Exit
@@ -331,6 +345,8 @@ language:
331
345
  project:
332
346
  ai: "claude"
333
347
  created: "{current_date}"
348
+ workflow:
349
+ auto_maintenance: true
334
350
  ```
335
351
 
336
352
  3. Display confirmation and exit
@@ -396,6 +412,8 @@ language:
396
412
  project:
397
413
  ai: "claude"
398
414
  created: "{current_date}"
415
+ workflow:
416
+ auto_maintenance: true
399
417
  ```
400
418
 
401
419
  5. Save to `.codexspec/config.yml`
@@ -428,6 +446,8 @@ language:
428
446
  project:
429
447
  ai: "claude"
430
448
  created: "{current_date}"
449
+ workflow:
450
+ auto_maintenance: true
431
451
  ```
432
452
 
433
453
  ## Supported Languages