codexspec 0.7.18__tar.gz → 0.7.19__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.
- {codexspec-0.7.18 → codexspec-0.7.19}/PKG-INFO +1 -1
- {codexspec-0.7.18 → codexspec-0.7.19}/pyproject.toml +1 -1
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/__init__.py +166 -1
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/worktrees.py +153 -31
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/config.md +24 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/debug.md +4 -1
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/implement-tasks.md +98 -20
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/review-code.md +78 -10
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/translations/de.json +1 -1
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/translations/en.json +1 -1
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/translations/es.json +1 -1
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/translations/fr.json +1 -1
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/translations/ja.json +1 -1
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/translations/ko.json +1 -1
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/translations/pt-BR.json +1 -1
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/translations/zh-CN.json +1 -1
- {codexspec-0.7.18 → codexspec-0.7.19}/.gitignore +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/LICENSE +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/README.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/codexspec-icon.svg +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/codexspec-logo-dark.svg +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/codexspec-logo-light.svg +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/scripts/bash/check-i18n-completeness.sh +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/scripts/bash/check-i18n-structure.sh +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/scripts/bash/check-prerequisites.sh +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/scripts/bash/common.sh +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/scripts/bash/create-new-feature.sh +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/scripts/bash/review-context.sh +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/scripts/powershell/check-prerequisites.ps1 +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/scripts/powershell/common.ps1 +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/scripts/powershell/create-new-feature.ps1 +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/scripts/powershell/review-context.ps1 +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/automation.py +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/blueprint.py +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/commands/__init__.py +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/commands/installer.py +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/distill_review/__init__.py +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/distill_review/assets/app.js +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/distill_review/assets/i18n/ar.json +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/distill_review/assets/i18n/de.json +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/distill_review/assets/i18n/en.json +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/distill_review/assets/i18n/es.json +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/distill_review/assets/i18n/fr.json +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/distill_review/assets/i18n/hi.json +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/distill_review/assets/i18n/it.json +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/distill_review/assets/i18n/ja.json +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/distill_review/assets/i18n/ko.json +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/distill_review/assets/i18n/pt.json +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/distill_review/assets/i18n/ru.json +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/distill_review/assets/i18n/zh-CN.json +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/distill_review/assets/i18n/zh-TW.json +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/distill_review/assets/index.html +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/distill_review/assets/styles.css +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/distill_review/domain.py +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/distill_review/lease.py +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/distill_review/models.py +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/distill_review/records.py +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/distill_review/server.py +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/distill_review/session.py +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/distill_review/terminal.py +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/distill_review/transaction.py +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/i18n.py +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/idea.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/integrations/__init__.py +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/integrations/base.py +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/integrations/claude.py +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/integrations/codex.py +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/profile.py +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/src/codexspec/translator.py +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/analyze.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/auto-dev.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/blueprint.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/checklist.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/clarify.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/commit-staged.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/constitution.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/distill.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/evolve.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/generate-spec.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/onboard.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/plan-to-tasks.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/pr.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/quick.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/release-notes.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/reverse-spec.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/review-design.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/review-plan.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/review-spec.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/review-tasks.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/spec-to-design.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/spec-to-plan.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/specify.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/commands/tasks-to-issues.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/docs/checklist-template.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/docs/constitution-template.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/docs/design-template.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/docs/plan-template-detailed.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/docs/plan-template-simple.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/docs/requirements-template.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/docs/spec-template-detailed.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/docs/spec-template-simple.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/docs/tasks-template-detailed.md +0 -0
- {codexspec-0.7.18 → codexspec-0.7.19}/templates/docs/tasks-template-simple.md +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: codexspec
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.19
|
|
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
|
|
@@ -17,6 +17,7 @@ from pathlib import Path
|
|
|
17
17
|
from typing import Any, Optional
|
|
18
18
|
|
|
19
19
|
import typer
|
|
20
|
+
import yaml
|
|
20
21
|
from rich.console import Console
|
|
21
22
|
from rich.panel import Panel
|
|
22
23
|
from rich.prompt import Confirm, Prompt
|
|
@@ -70,12 +71,13 @@ from .worktrees import (
|
|
|
70
71
|
feature_name,
|
|
71
72
|
read_worktrees,
|
|
72
73
|
validate_write_path,
|
|
74
|
+
write_config_scalar,
|
|
73
75
|
write_destination,
|
|
74
76
|
write_worktrees,
|
|
75
77
|
)
|
|
76
78
|
|
|
77
79
|
# Version info
|
|
78
|
-
__version__ = "0.7.
|
|
80
|
+
__version__ = "0.7.19"
|
|
79
81
|
__author__ = "CodexSpec Team"
|
|
80
82
|
|
|
81
83
|
# Constitution file path constants
|
|
@@ -544,6 +546,25 @@ _AUTO_NEXT_ACCEPTED = "on/off, true/false, 1/0, yes/no"
|
|
|
544
546
|
# sets for parsing; a distinct sentinel keeps the bare-toggle rewrites separate.
|
|
545
547
|
_AUTO_DISTILL_SENTINEL = "__toggle_distill__"
|
|
546
548
|
|
|
549
|
+
# review.decided_by: who decides about a review-code finding whose trigger lies
|
|
550
|
+
# outside the project's real operating context. ``reviewer`` (default) keeps
|
|
551
|
+
# today's behavior; ``ask`` lets the user decide once.
|
|
552
|
+
_DECIDED_BY_VALUES = ("reviewer", "ask")
|
|
553
|
+
_DECIDED_BY_DEFAULT = "reviewer"
|
|
554
|
+
_DECIDED_BY_ACCEPTED = ", ".join(_DECIDED_BY_VALUES)
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
class _DecidedByRefusal(str):
|
|
558
|
+
"""Why the writer refuses config.yml; typed so it never collides with a stored value."""
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
# Writer refusal codes, as reported by the display; any other refusal is "unsupported layout".
|
|
562
|
+
_DECIDED_BY_REFUSALS = {
|
|
563
|
+
"invalid_review_config": "unparseable",
|
|
564
|
+
"duplicate_config_key": "duplicate keys",
|
|
565
|
+
"invalid_review_section": "invalid review section",
|
|
566
|
+
}
|
|
567
|
+
|
|
547
568
|
|
|
548
569
|
@app.command()
|
|
549
570
|
def config(
|
|
@@ -594,6 +615,11 @@ def config(
|
|
|
594
615
|
worktrees: Optional[str] = typer.Option(
|
|
595
616
|
None, "--worktrees", help="Toggle checkout-local worktree isolation (default on), or set on/off."
|
|
596
617
|
),
|
|
618
|
+
decided_by: Optional[str] = typer.Option(
|
|
619
|
+
None,
|
|
620
|
+
"--decided-by",
|
|
621
|
+
help="Set review.decided_by (reviewer|ask): who decides about out-of-context review findings.",
|
|
622
|
+
),
|
|
597
623
|
) -> None:
|
|
598
624
|
"""
|
|
599
625
|
View or modify CodexSpec project configuration.
|
|
@@ -607,6 +633,7 @@ def config(
|
|
|
607
633
|
codexspec config --set-commit-lang en # Set commit messages to English
|
|
608
634
|
codexspec config --auto-next # Toggle workflow.auto_next
|
|
609
635
|
codexspec config --auto-distill off # Disable workflow.auto_distill (default on)
|
|
636
|
+
codexspec config --decided-by ask # Ask the user about out-of-context review findings
|
|
610
637
|
codexspec config --list-langs # List supported languages
|
|
611
638
|
"""
|
|
612
639
|
# Handle list languages
|
|
@@ -641,12 +668,20 @@ def config(
|
|
|
641
668
|
except ValueError:
|
|
642
669
|
console.print(f"[red]Invalid {option} value:[/red] {value!r}")
|
|
643
670
|
raise typer.Exit(1)
|
|
671
|
+
if decided_by is not None:
|
|
672
|
+
try:
|
|
673
|
+
parse_decided_by_value(decided_by)
|
|
674
|
+
except ValueError:
|
|
675
|
+
console.print(f"[red]Invalid --decided-by value:[/red] {decided_by!r}")
|
|
676
|
+
console.print(f"Accepted values: {_DECIDED_BY_ACCEPTED}.")
|
|
677
|
+
raise typer.Exit(1)
|
|
644
678
|
modifying = any(
|
|
645
679
|
value is not None
|
|
646
680
|
for value in (
|
|
647
681
|
auto_next,
|
|
648
682
|
auto_distill,
|
|
649
683
|
worktrees,
|
|
684
|
+
decided_by,
|
|
650
685
|
set_lang,
|
|
651
686
|
set_commit_lang,
|
|
652
687
|
set_interaction_lang,
|
|
@@ -681,6 +716,16 @@ def config(
|
|
|
681
716
|
console.print(f"workflow.worktrees = {str(target).lower()}")
|
|
682
717
|
return
|
|
683
718
|
|
|
719
|
+
# Handle review.decided_by set
|
|
720
|
+
if decided_by is not None:
|
|
721
|
+
mode = parse_decided_by_value(decided_by)
|
|
722
|
+
if _write_review_decided_by(config_file, mode):
|
|
723
|
+
console.print(f"[green]review.decided_by = {mode}[/green]")
|
|
724
|
+
else:
|
|
725
|
+
console.print("[red]Failed to update review.decided_by[/red]")
|
|
726
|
+
raise typer.Exit(1)
|
|
727
|
+
return
|
|
728
|
+
|
|
684
729
|
# Handle auto-next toggle/set
|
|
685
730
|
if auto_next is not None:
|
|
686
731
|
if auto_next == _AUTO_NEXT_SENTINEL:
|
|
@@ -861,6 +906,21 @@ def config(
|
|
|
861
906
|
|
|
862
907
|
# Display current configuration
|
|
863
908
|
console.print(f"Effective workflow.worktrees: {str(read_worktrees(config_file)).lower()}")
|
|
909
|
+
stored_mode = _read_review_decided_by(config_file)
|
|
910
|
+
if stored_mode in _DECIDED_BY_VALUES:
|
|
911
|
+
console.print(f"Effective review.decided_by: {stored_mode}")
|
|
912
|
+
elif isinstance(stored_mode, _DecidedByRefusal):
|
|
913
|
+
console.print(
|
|
914
|
+
f"review.decided_by: config.yml cannot be managed ({stored_mode}); "
|
|
915
|
+
"fix the file by hand before setting it with --decided-by.",
|
|
916
|
+
markup=False,
|
|
917
|
+
)
|
|
918
|
+
else:
|
|
919
|
+
console.print(
|
|
920
|
+
f"review.decided_by: invalid value {stored_mode!r} (accepted: {_DECIDED_BY_ACCEPTED}); "
|
|
921
|
+
"review-code rejects it until it is corrected.",
|
|
922
|
+
markup=False,
|
|
923
|
+
)
|
|
864
924
|
console.print(
|
|
865
925
|
Panel(
|
|
866
926
|
config_file.read_text(encoding="utf-8"),
|
|
@@ -1602,6 +1662,111 @@ def _write_auto_distill(config_file: Path, value: bool) -> bool:
|
|
|
1602
1662
|
return True
|
|
1603
1663
|
|
|
1604
1664
|
|
|
1665
|
+
# --- review.decided_by helpers ---------------------------------------------
|
|
1666
|
+
|
|
1667
|
+
|
|
1668
|
+
def parse_decided_by_value(raw: str) -> str:
|
|
1669
|
+
"""Parse a ``review.decided_by`` value (``reviewer`` or ``ask``).
|
|
1670
|
+
|
|
1671
|
+
Case-insensitive; surrounding whitespace is ignored. Raises ``ValueError``
|
|
1672
|
+
for any other token so callers can report it instead of guessing a mode.
|
|
1673
|
+
"""
|
|
1674
|
+
token = (raw or "").strip().lower()
|
|
1675
|
+
if token in _DECIDED_BY_VALUES:
|
|
1676
|
+
return token
|
|
1677
|
+
raise ValueError(f"invalid review.decided_by value: {raw!r}")
|
|
1678
|
+
|
|
1679
|
+
|
|
1680
|
+
def _yaml_has_duplicate_keys(content: str) -> bool:
|
|
1681
|
+
"""Return True when any YAML mapping in ``content`` repeats a key."""
|
|
1682
|
+
try:
|
|
1683
|
+
root = yaml.compose(content)
|
|
1684
|
+
except yaml.YAMLError:
|
|
1685
|
+
return False
|
|
1686
|
+
stack = [root] if root is not None else []
|
|
1687
|
+
seen_nodes: set[int] = set()
|
|
1688
|
+
while stack:
|
|
1689
|
+
node = stack.pop()
|
|
1690
|
+
if id(node) in seen_nodes:
|
|
1691
|
+
continue
|
|
1692
|
+
seen_nodes.add(id(node))
|
|
1693
|
+
if isinstance(node, yaml.MappingNode):
|
|
1694
|
+
keys = [key.value for key, _ in node.value if isinstance(key, yaml.ScalarNode)]
|
|
1695
|
+
if len(keys) != len(set(keys)):
|
|
1696
|
+
return True
|
|
1697
|
+
stack.extend(value for _, value in node.value)
|
|
1698
|
+
elif isinstance(node, yaml.SequenceNode):
|
|
1699
|
+
stack.extend(node.value)
|
|
1700
|
+
return False
|
|
1701
|
+
|
|
1702
|
+
|
|
1703
|
+
def _read_review_decided_by(config_file: Path) -> str:
|
|
1704
|
+
"""Return the effective ``review.decided_by`` value, or why the file cannot be managed.
|
|
1705
|
+
|
|
1706
|
+
Validity comes from the writer itself: the file is checked with a dry run of
|
|
1707
|
+
``write_config_scalar`` (the writer behind ``--decided-by``), so a state shown as
|
|
1708
|
+
valid is always settable and a successful write is never shown as invalid. A file
|
|
1709
|
+
the writer refuses yields a ``_DecidedByRefusal`` (``"unparseable"``,
|
|
1710
|
+
``"duplicate keys"``, ``"invalid review section"``, or ``"unsupported layout"``),
|
|
1711
|
+
typed so a stored value with the same text is never mistaken for one. Otherwise the value is
|
|
1712
|
+
the one YAML resolves (merge keys included): ``reviewer`` when absent, ``"null"``
|
|
1713
|
+
for null, text for non-strings, so callers report invalid values rather than
|
|
1714
|
+
masking them as the default. An absent or unreadable file yields ``reviewer``.
|
|
1715
|
+
"""
|
|
1716
|
+
try:
|
|
1717
|
+
content = config_file.read_bytes().decode("utf-8")
|
|
1718
|
+
except (OSError, UnicodeDecodeError):
|
|
1719
|
+
return _DECIDED_BY_DEFAULT
|
|
1720
|
+
try:
|
|
1721
|
+
write_config_scalar(
|
|
1722
|
+
config_file,
|
|
1723
|
+
"review",
|
|
1724
|
+
"decided_by",
|
|
1725
|
+
_DECIDED_BY_DEFAULT,
|
|
1726
|
+
_DECIDED_BY_DEFAULT,
|
|
1727
|
+
error_prefix="review",
|
|
1728
|
+
invalid_section_code="invalid_review_section",
|
|
1729
|
+
dry_run=True,
|
|
1730
|
+
)
|
|
1731
|
+
data = yaml.safe_load(content)
|
|
1732
|
+
except (AutomationError, yaml.YAMLError) as exc:
|
|
1733
|
+
code = getattr(exc, "code", "invalid_review_config")
|
|
1734
|
+
return _DecidedByRefusal(_DECIDED_BY_REFUSALS.get(code, "unsupported layout"))
|
|
1735
|
+
review = data.get("review") if isinstance(data, dict) else None
|
|
1736
|
+
if not isinstance(review, dict) or "decided_by" not in review:
|
|
1737
|
+
return _DECIDED_BY_DEFAULT
|
|
1738
|
+
value = review["decided_by"]
|
|
1739
|
+
if value is None:
|
|
1740
|
+
return "null"
|
|
1741
|
+
return value if isinstance(value, str) else str(value)
|
|
1742
|
+
|
|
1743
|
+
|
|
1744
|
+
def _write_review_decided_by(config_file: Path, value: str) -> bool:
|
|
1745
|
+
"""Set ``review.decided_by`` to ``reviewer`` or ``ask``.
|
|
1746
|
+
|
|
1747
|
+
Delegates to the shared surgical writer used for ``workflow.worktrees``, which
|
|
1748
|
+
preserves comments, line endings, and every other value, handles block and
|
|
1749
|
+
flow mappings, and writes atomically only when the parsed document equals the
|
|
1750
|
+
original with just this key replaced. Returns ``False`` (file untouched) when
|
|
1751
|
+
the edit cannot be made that way or on I/O error; raises ``ValueError`` for an
|
|
1752
|
+
invalid value.
|
|
1753
|
+
"""
|
|
1754
|
+
token = parse_decided_by_value(value)
|
|
1755
|
+
try:
|
|
1756
|
+
write_config_scalar(
|
|
1757
|
+
config_file,
|
|
1758
|
+
"review",
|
|
1759
|
+
"decided_by",
|
|
1760
|
+
token,
|
|
1761
|
+
token,
|
|
1762
|
+
error_prefix="review",
|
|
1763
|
+
invalid_section_code="invalid_review_section",
|
|
1764
|
+
)
|
|
1765
|
+
except (AutomationError, OSError):
|
|
1766
|
+
return False
|
|
1767
|
+
return True
|
|
1768
|
+
|
|
1769
|
+
|
|
1605
1770
|
def _next_step_start(integration_keys: set[str], language: str) -> str:
|
|
1606
1771
|
"""Return a target-aware start instruction."""
|
|
1607
1772
|
if integration_keys == {"codex"}:
|
|
@@ -29,14 +29,14 @@ MAINTENANCE_BRANCH = "codexspec/maintenance"
|
|
|
29
29
|
MAINTENANCE_NAME = "worktree-for-codexspec-maintenance"
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
def _document(config: Path) -> tuple[str, Any]:
|
|
32
|
+
def _document(config: Path, invalid_code: str = "invalid_worktree_config") -> tuple[str, Any]:
|
|
33
33
|
content = config.read_bytes().decode("utf-8") if config.exists() else ""
|
|
34
34
|
try:
|
|
35
35
|
node = yaml.compose(content)
|
|
36
36
|
except yaml.YAMLError as exc:
|
|
37
|
-
raise AutomationError(
|
|
37
|
+
raise AutomationError(invalid_code, str(config)) from exc
|
|
38
38
|
if node is not None and not isinstance(node, yaml.MappingNode):
|
|
39
|
-
raise AutomationError(
|
|
39
|
+
raise AutomationError(invalid_code, str(config))
|
|
40
40
|
return content, node
|
|
41
41
|
|
|
42
42
|
|
|
@@ -49,6 +49,62 @@ def _field(node: Any, name: str) -> Any:
|
|
|
49
49
|
return matches[0] if matches else None
|
|
50
50
|
|
|
51
51
|
|
|
52
|
+
def _key_node(node: Any, value: Any) -> Any:
|
|
53
|
+
"""Return the key node paired with ``value`` in mapping ``node``."""
|
|
54
|
+
return next(key for key, item in node.value if item is value)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _key_tokens(content: str, key: Any) -> tuple[list[Any], int]:
|
|
58
|
+
"""Return the scanner tokens of ``content`` and the index of scalar ``key``'s token."""
|
|
59
|
+
tokens = list(yaml.scan(content))
|
|
60
|
+
index = next(
|
|
61
|
+
i
|
|
62
|
+
for i, token in enumerate(tokens)
|
|
63
|
+
if isinstance(token, yaml.ScalarToken) and token.end_mark.index == key.end_mark.index
|
|
64
|
+
)
|
|
65
|
+
return tokens, index
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def _explicit_indicator(tokens: list[Any], index: int) -> Any:
|
|
69
|
+
"""Return the ``?`` token that introduces the key at ``index``, or None for an implicit key."""
|
|
70
|
+
before = index - 1
|
|
71
|
+
while isinstance(tokens[before], (yaml.AnchorToken, yaml.TagToken)):
|
|
72
|
+
before -= 1
|
|
73
|
+
indicator = tokens[before]
|
|
74
|
+
explicit = isinstance(indicator, yaml.KeyToken) and indicator.end_mark.index > indicator.start_mark.index
|
|
75
|
+
return indicator if explicit else None
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def _implicit_value_offset(content: str, key: Any, start: int, newline: str) -> tuple[int, str]:
|
|
79
|
+
"""Return where to fill an empty value at ``start`` and the text that must precede it.
|
|
80
|
+
|
|
81
|
+
A key written without ``:`` (``{review}``, ``? review``) has an implicit null whose
|
|
82
|
+
mark points at the next token, so the value goes right after the key, behind a
|
|
83
|
+
``:`` indicator (on its own line for a block explicit key). Scanner tokens decide
|
|
84
|
+
this, so comments, a BOM, anchors, and tags are never mistaken for syntax.
|
|
85
|
+
"""
|
|
86
|
+
tokens, index = _key_tokens(content, key)
|
|
87
|
+
if index + 1 < len(tokens) and isinstance(tokens[index + 1], yaml.ValueToken):
|
|
88
|
+
return start, ""
|
|
89
|
+
indicator = _explicit_indicator(tokens, index)
|
|
90
|
+
flow_level = sum(
|
|
91
|
+
1 if isinstance(token, (yaml.FlowMappingStartToken, yaml.FlowSequenceStartToken)) else -1
|
|
92
|
+
for token in tokens[:index]
|
|
93
|
+
if isinstance(
|
|
94
|
+
token,
|
|
95
|
+
(
|
|
96
|
+
yaml.FlowMappingStartToken,
|
|
97
|
+
yaml.FlowSequenceStartToken,
|
|
98
|
+
yaml.FlowMappingEndToken,
|
|
99
|
+
yaml.FlowSequenceEndToken,
|
|
100
|
+
),
|
|
101
|
+
)
|
|
102
|
+
)
|
|
103
|
+
if indicator is not None and not flow_level:
|
|
104
|
+
return key.end_mark.index, f"{newline}{' ' * indicator.start_mark.column}: "
|
|
105
|
+
return key.end_mark.index, ": "
|
|
106
|
+
|
|
107
|
+
|
|
52
108
|
def read_worktrees(config: Path) -> bool:
|
|
53
109
|
"""Default on; only an unquoted literal false in workflow disables isolation."""
|
|
54
110
|
_, node = _document(config)
|
|
@@ -99,51 +155,117 @@ def _expand_aliases(content: str) -> str:
|
|
|
99
155
|
loader.dispose()
|
|
100
156
|
|
|
101
157
|
|
|
102
|
-
def
|
|
103
|
-
"""
|
|
104
|
-
|
|
158
|
+
def _is_null_node(node: Any) -> bool:
|
|
159
|
+
"""Return True for a YAML scalar node that resolves to null (empty, ``~``, ``null``)."""
|
|
160
|
+
return isinstance(node, yaml.ScalarNode) and node.tag == "tag:yaml.org,2002:null"
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def write_config_scalar(
|
|
164
|
+
config: Path,
|
|
165
|
+
section: str,
|
|
166
|
+
key: str,
|
|
167
|
+
token: str,
|
|
168
|
+
expected: Any,
|
|
169
|
+
*,
|
|
170
|
+
error_prefix: str = "worktree",
|
|
171
|
+
invalid_section_code: str = "invalid_workflow_section",
|
|
172
|
+
dry_run: bool = False,
|
|
173
|
+
) -> None:
|
|
174
|
+
"""Surgically set ``section.key`` to ``token`` without normalizing unrelated YAML.
|
|
175
|
+
|
|
176
|
+
Preserves comments, line endings, and every other value; handles block and
|
|
177
|
+
flow mappings, anchors, and an empty value. The edited document must parse to
|
|
178
|
+
the original with only ``section.key`` replaced by ``expected``; otherwise an
|
|
179
|
+
``AutomationError`` is raised and the file is left untouched. The write is
|
|
180
|
+
atomic. Error codes are ``invalid_<prefix>_config``, ``unsupported_<prefix>_config``,
|
|
181
|
+
``unrelated_config_change``, ``duplicate_config_key``, and ``invalid_section_code``.
|
|
182
|
+
``dry_run`` performs every check without writing, so a reader can ask whether
|
|
183
|
+
the current file is settable under exactly the rules the writer applies.
|
|
184
|
+
"""
|
|
185
|
+
original, node = _document(config, f"invalid_{error_prefix}_config")
|
|
105
186
|
newline = "\r\n" if "\r\n" in original else "\n"
|
|
106
187
|
try:
|
|
107
188
|
content = _expand_aliases(original)
|
|
108
189
|
node = yaml.compose(content)
|
|
109
190
|
except (yaml.YAMLError, RecursionError) as exc:
|
|
110
|
-
raise AutomationError("
|
|
111
|
-
|
|
112
|
-
value = _field(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
191
|
+
raise AutomationError(f"unsupported_{error_prefix}_config", str(config)) from exc
|
|
192
|
+
mapping = _field(node, section)
|
|
193
|
+
value = None if _is_null_node(mapping) else _field(mapping, key)
|
|
194
|
+
if _is_null_node(mapping):
|
|
195
|
+
# A present but empty/null section (``section:`` or ``section: ~``) is
|
|
196
|
+
# filled in place, like an absent mapping.
|
|
197
|
+
start, end = mapping.start_mark.index, mapping.end_mark.index
|
|
198
|
+
lead = ""
|
|
199
|
+
if start == end:
|
|
200
|
+
start, lead = _implicit_value_offset(content, _key_node(node, mapping), start, newline)
|
|
201
|
+
end = start
|
|
202
|
+
if lead:
|
|
203
|
+
addition = f"{lead}{{{key}: {token}}}"
|
|
204
|
+
elif start != end or (isinstance(node, yaml.MappingNode) and node.flow_style):
|
|
205
|
+
# Replace ``~``/``null``, or fill an empty value inside a flow mapping.
|
|
206
|
+
addition = f"{{{key}: {token}}}"
|
|
207
|
+
if start == end and content[start - 1 : start] not in (" ", "\t"):
|
|
208
|
+
addition = " " + addition
|
|
209
|
+
else:
|
|
210
|
+
addition = f"{newline} {key}: {token}"
|
|
211
|
+
content = content[:start] + addition + content[end:]
|
|
212
|
+
elif value is not None:
|
|
213
|
+
start, end = value.start_mark.index, value.end_mark.index
|
|
214
|
+
if isinstance(value, yaml.ScalarNode) and value.style in ("|", ">"):
|
|
215
|
+
# A block scalar's span includes its trailing line break(s); keep them.
|
|
216
|
+
while end > start and content[end - 1] in "\r\n":
|
|
217
|
+
end -= 1
|
|
218
|
+
replacement = token
|
|
219
|
+
if start == end and isinstance(value, yaml.ScalarNode) and value.value == "":
|
|
220
|
+
start, lead = _implicit_value_offset(content, _key_node(mapping, value), start, newline)
|
|
221
|
+
end = start
|
|
222
|
+
# An empty value: keep a separator between the colon and the new token.
|
|
223
|
+
replacement = lead + token if lead or content[start - 1 : start] == " " else " " + token
|
|
224
|
+
content = content[:start] + replacement + content[end:]
|
|
225
|
+
elif isinstance(mapping, yaml.MappingNode):
|
|
226
|
+
if mapping.flow_style:
|
|
227
|
+
offset = mapping.end_mark.index - 1
|
|
228
|
+
addition = (", " if mapping.value else "") + f"{key}: {token}"
|
|
120
229
|
else:
|
|
121
|
-
|
|
122
|
-
#
|
|
123
|
-
|
|
124
|
-
|
|
230
|
+
# Insert before the first key's own start: its '?' indicator when it is
|
|
231
|
+
# explicit, never a preceding mapping anchor.
|
|
232
|
+
first = mapping.value[0][0]
|
|
233
|
+
mark = first.start_mark
|
|
234
|
+
indicator = (
|
|
235
|
+
_explicit_indicator(*_key_tokens(content, first)) if isinstance(first, yaml.ScalarNode) else None
|
|
236
|
+
)
|
|
237
|
+
if indicator is not None:
|
|
238
|
+
mark = indicator.start_mark
|
|
239
|
+
offset, indent = mark.index, mark.column
|
|
240
|
+
addition = f"{key}: {token}{newline}" + " " * indent
|
|
125
241
|
content = content[:offset] + addition + content[offset:]
|
|
126
|
-
elif
|
|
127
|
-
raise AutomationError(
|
|
242
|
+
elif mapping is not None:
|
|
243
|
+
raise AutomationError(invalid_section_code, str(config))
|
|
128
244
|
elif isinstance(node, yaml.MappingNode) and node.flow_style:
|
|
129
245
|
offset = node.end_mark.index - 1
|
|
130
|
-
addition = (", " if node.value else "") + f"
|
|
246
|
+
addition = (", " if node.value else "") + f"{section}: {{{key}: {token}}}"
|
|
131
247
|
content = content[:offset] + addition + content[offset:]
|
|
132
248
|
else:
|
|
133
|
-
|
|
134
|
-
offset =
|
|
249
|
+
end_event = next((event for event in yaml.parse(content) if isinstance(event, yaml.DocumentEndEvent)), None)
|
|
250
|
+
offset = end_event.start_mark.index if end_event is not None and end_event.explicit else len(content)
|
|
135
251
|
prefix = content[:offset].rstrip("\r\n")
|
|
136
252
|
content = (
|
|
137
|
-
prefix + (newline if prefix else "") + f"
|
|
253
|
+
prefix + (newline if prefix else "") + f"{section}:{newline} {key}: {token}{newline}" + content[offset:]
|
|
138
254
|
)
|
|
139
255
|
try:
|
|
140
256
|
before = yaml.safe_load(original) or {}
|
|
141
|
-
|
|
142
|
-
if yaml.safe_load(content) !=
|
|
257
|
+
expected_document = {**before, section: {**(before.get(section) or {}), key: expected}}
|
|
258
|
+
if yaml.safe_load(content) != expected_document:
|
|
143
259
|
raise AutomationError("unrelated_config_change", str(config))
|
|
144
|
-
except (yaml.YAMLError, RecursionError) as exc:
|
|
145
|
-
raise AutomationError("
|
|
146
|
-
|
|
260
|
+
except (yaml.YAMLError, RecursionError, TypeError) as exc:
|
|
261
|
+
raise AutomationError(f"unsupported_{error_prefix}_config", str(config)) from exc
|
|
262
|
+
if not dry_run:
|
|
263
|
+
_atomic_bytes(config, content.encode("utf-8"))
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
def write_worktrees(config: Path, enabled: bool) -> None:
|
|
267
|
+
"""Surgically write one boolean without normalizing unrelated YAML or comments."""
|
|
268
|
+
write_config_scalar(config, "workflow", "worktrees", str(enabled).lower(), enabled)
|
|
147
269
|
|
|
148
270
|
|
|
149
271
|
def feature_name(short_name: str) -> str:
|
|
@@ -191,6 +191,7 @@ Display the configuration as in Step 2, then exit.
|
|
|
191
191
|
{"label": "Commit language", "description": "Language for commit messages (currently: {current value})"},
|
|
192
192
|
{"label": "Auto-next chain", "description": "Auto-advance the SDD pipeline once a stage passes (workflow.auto_next) (currently: {current value})"},
|
|
193
193
|
{"label": "Auto-distill", "description": "Run /codexspec:distill on completion of wrap-up commands to capture reusable knowledge (workflow.auto_distill) (currently: {current value})"},
|
|
194
|
+
{"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})"},
|
|
194
195
|
{"label": "Back", "description": "Return to main menu"}
|
|
195
196
|
]
|
|
196
197
|
}]
|
|
@@ -260,6 +261,29 @@ Display the configuration as in Step 2, then exit.
|
|
|
260
261
|
when the key exists; otherwise add `auto_distill: <bool>` under the `workflow:`
|
|
261
262
|
section, creating that section if absent), preserving every other line and comment.
|
|
262
263
|
|
|
264
|
+
3c. For "Review decision mode", ask who decides:
|
|
265
|
+
|
|
266
|
+
```json
|
|
267
|
+
{
|
|
268
|
+
"questions": [{
|
|
269
|
+
"question": "Set review.decided_by:",
|
|
270
|
+
"header": "Decided by",
|
|
271
|
+
"options": [
|
|
272
|
+
{"label": "reviewer (default)", "description": "The reviewer decides every finding; review-code behaves exactly as before"},
|
|
273
|
+
{"label": "ask", "description": "A finding whose trigger lies outside the project's real operating context is presented to you once to fix or accept; your decision is recorded in requirements.md"},
|
|
274
|
+
{"label": "Back", "description": "Return without changing"}
|
|
275
|
+
]
|
|
276
|
+
}]
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Then read `.codexspec/config.yml`. `reviewer` is the default: an absent key/section means `reviewer`.
|
|
281
|
+
Write `review.decided_by` as an unquoted `reviewer` or `ask` (update the value in place when the key
|
|
282
|
+
exists; otherwise add `decided_by: <value>` under the `review:` section, creating that section if
|
|
283
|
+
absent), preserving every other line and comment. Never write any other value. If the stored value is
|
|
284
|
+
neither `reviewer` nor `ask`, report it as invalid (review-code rejects it as an argument error) and
|
|
285
|
+
offer to correct it.
|
|
286
|
+
|
|
263
287
|
4. Update the configuration file with the new value
|
|
264
288
|
5. Display the updated configuration
|
|
265
289
|
6. Exit
|
|
@@ -122,6 +122,8 @@ When the symptom is too thin to act on, **reproduce-or-ask** before doing anythi
|
|
|
122
122
|
- If you still cannot reproduce it reliably, ask the user for exactly what is missing — reproduction steps, the precise input that triggers it, expected-vs-actual behavior, the verbatim error, and when it started.
|
|
123
123
|
- Do NOT propose a fix for an unreproduced symptom.
|
|
124
124
|
|
|
125
|
+
The symptom may also be a **recurring defect class** with its known instances — for example, when `implement-tasks` escalates a root-cause class that reappeared across review rounds. Treat the class as one defect: reproduce each known instance, and investigate the shared cause rather than any single location.
|
|
126
|
+
|
|
125
127
|
## Investigation Protocol
|
|
126
128
|
|
|
127
129
|
Work the phases in order. Phase 1 is a hard gate.
|
|
@@ -151,10 +153,11 @@ Work the phases in order. Phase 1 is a hard gate.
|
|
|
151
153
|
- Write a failing test first that captures the defect (a reproducing regression test) and observe it fail for the right reason. For a symptom with no natural unit test — a documentation or configuration defect, a production-log incident — construct the closest reproducing check instead.
|
|
152
154
|
- Apply a single, minimal fix that targets the root cause — not the symptom, and no "while I'm here" changes.
|
|
153
155
|
- Verify: the new test passes and no previously-passing test breaks.
|
|
156
|
+
- For a defect class, apply one uniform fix at the shared root cause instead of patching each instance, then search the codebase for every location of the class (equivalent callers, implementations, adapters, and entry surfaces) and cover each location with a regression check.
|
|
154
157
|
|
|
155
158
|
### Architecture Gate (≥3 failed fixes)
|
|
156
159
|
|
|
157
|
-
If three fixes for the same problem have failed, STOP. Do not attempt a fourth blind fix. Repeated failure is evidence that the model of the problem — or the architecture — is wrong. Surface it: state what was tried, why each attempt failed, and what architectural question must be answered before continuing.
|
|
160
|
+
If three fixes for the same problem have failed, STOP. Do not attempt a fourth blind fix. Repeated failure is evidence that the model of the problem — or the architecture — is wrong. Surface it: state what was tried, why each attempt failed, and what architectural question must be answered before continuing. For a defect class, the gate applies to the class as a whole: three failed fixes across its instances count toward the same gate.
|
|
158
161
|
|
|
159
162
|
## Completion
|
|
160
163
|
|