codexspec 0.7.17__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.17 → codexspec-0.7.19}/PKG-INFO +9 -1
- {codexspec-0.7.17 → codexspec-0.7.19}/README.md +8 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/pyproject.toml +1 -1
- {codexspec-0.7.17 → codexspec-0.7.19}/scripts/bash/create-new-feature.sh +11 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/scripts/powershell/create-new-feature.ps1 +28 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/__init__.py +300 -3
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/automation.py +17 -7
- codexspec-0.7.19/src/codexspec/worktrees.py +599 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/commands/analyze.md +72 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/commands/auto-dev.md +72 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/commands/blueprint.md +72 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/commands/checklist.md +72 -0
- codexspec-0.7.19/templates/commands/clarify.md +159 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/commands/commit-staged.md +72 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/commands/config.md +107 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/commands/constitution.md +72 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/commands/debug.md +76 -1
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/commands/distill.md +72 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/commands/evolve.md +72 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/commands/generate-spec.md +72 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/commands/implement-tasks.md +170 -20
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/commands/onboard.md +72 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/commands/plan-to-tasks.md +72 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/commands/pr.md +72 -0
- codexspec-0.7.19/templates/commands/quick.md +141 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/commands/release-notes.md +72 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/commands/reverse-spec.md +79 -7
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/commands/review-code.md +150 -10
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/commands/review-design.md +72 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/commands/review-plan.md +72 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/commands/review-spec.md +72 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/commands/review-tasks.md +72 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/commands/spec-to-design.md +72 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/commands/spec-to-plan.md +72 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/commands/specify.md +76 -1
- codexspec-0.7.19/templates/commands/tasks-to-issues.md +216 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/translations/de.json +1 -1
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/translations/en.json +1 -1
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/translations/es.json +1 -1
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/translations/fr.json +1 -1
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/translations/ja.json +1 -1
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/translations/ko.json +1 -1
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/translations/pt-BR.json +1 -1
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/translations/zh-CN.json +1 -1
- codexspec-0.7.17/templates/commands/clarify.md +0 -87
- codexspec-0.7.17/templates/commands/quick.md +0 -69
- codexspec-0.7.17/templates/commands/tasks-to-issues.md +0 -144
- {codexspec-0.7.17 → codexspec-0.7.19}/.gitignore +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/LICENSE +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/codexspec-icon.svg +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/codexspec-logo-dark.svg +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/codexspec-logo-light.svg +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/scripts/bash/check-i18n-completeness.sh +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/scripts/bash/check-i18n-structure.sh +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/scripts/bash/check-prerequisites.sh +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/scripts/bash/common.sh +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/scripts/bash/review-context.sh +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/scripts/powershell/check-prerequisites.ps1 +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/scripts/powershell/common.ps1 +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/scripts/powershell/review-context.ps1 +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/blueprint.py +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/commands/__init__.py +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/commands/installer.py +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/distill_review/__init__.py +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/distill_review/assets/app.js +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/distill_review/assets/i18n/ar.json +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/distill_review/assets/i18n/de.json +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/distill_review/assets/i18n/en.json +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/distill_review/assets/i18n/es.json +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/distill_review/assets/i18n/fr.json +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/distill_review/assets/i18n/hi.json +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/distill_review/assets/i18n/it.json +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/distill_review/assets/i18n/ja.json +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/distill_review/assets/i18n/ko.json +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/distill_review/assets/i18n/pt.json +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/distill_review/assets/i18n/ru.json +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/distill_review/assets/i18n/zh-CN.json +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/distill_review/assets/i18n/zh-TW.json +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/distill_review/assets/index.html +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/distill_review/assets/styles.css +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/distill_review/domain.py +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/distill_review/lease.py +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/distill_review/models.py +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/distill_review/records.py +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/distill_review/server.py +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/distill_review/session.py +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/distill_review/terminal.py +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/distill_review/transaction.py +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/i18n.py +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/idea.md +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/integrations/__init__.py +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/integrations/base.py +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/integrations/claude.py +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/integrations/codex.py +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/profile.py +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/src/codexspec/translator.py +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/docs/checklist-template.md +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/docs/constitution-template.md +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/docs/design-template.md +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/docs/plan-template-detailed.md +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/docs/plan-template-simple.md +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/docs/requirements-template.md +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/docs/spec-template-detailed.md +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/docs/spec-template-simple.md +0 -0
- {codexspec-0.7.17 → codexspec-0.7.19}/templates/docs/tasks-template-detailed.md +0 -0
- {codexspec-0.7.17 → 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
|
|
@@ -565,6 +565,7 @@ Implementation follows **conditional TDD workflow**:
|
|
|
565
565
|
| `--list-langs` | List all supported languages |
|
|
566
566
|
| `--auto-next` | Toggle/set `workflow.auto_next` (bare toggles; or on/off) |
|
|
567
567
|
| `--auto-distill` | Toggle/set `workflow.auto_distill` (default on; bare toggles; or on/off) |
|
|
568
|
+
| `--worktrees` | Toggle/set checkout-local worktree isolation (default on; bare toggles; or on/off) |
|
|
568
569
|
|
|
569
570
|
</details>
|
|
570
571
|
|
|
@@ -837,3 +838,10 @@ MIT License - see [LICENSE](LICENSE) for details.
|
|
|
837
838
|
|
|
838
839
|
- Inspired by [GitHub spec-kit](https://github.com/github/spec-kit)
|
|
839
840
|
- Built for [Claude Code](https://claude.ai/code)
|
|
841
|
+
|
|
842
|
+
Ordinary features develop in separate worktrees under the main checkout's sibling
|
|
843
|
+
`<repository-name>-codexspec-worktrees/`, starting before the first requirements write.
|
|
844
|
+
Blueprint and auto-dev retain their fixed shared worktree. Standalone project edits
|
|
845
|
+
use a maintenance worktree; settings take effect per checkout and reach other checkouts
|
|
846
|
+
through Git integration. See [worktree development](docs/en/user-guide/workflow.md#worktree-development)
|
|
847
|
+
and [configuration](docs/en/reference/configuration.md#workflowworktrees).
|
|
@@ -520,6 +520,7 @@ Implementation follows **conditional TDD workflow**:
|
|
|
520
520
|
| `--list-langs` | List all supported languages |
|
|
521
521
|
| `--auto-next` | Toggle/set `workflow.auto_next` (bare toggles; or on/off) |
|
|
522
522
|
| `--auto-distill` | Toggle/set `workflow.auto_distill` (default on; bare toggles; or on/off) |
|
|
523
|
+
| `--worktrees` | Toggle/set checkout-local worktree isolation (default on; bare toggles; or on/off) |
|
|
523
524
|
|
|
524
525
|
</details>
|
|
525
526
|
|
|
@@ -792,3 +793,10 @@ MIT License - see [LICENSE](LICENSE) for details.
|
|
|
792
793
|
|
|
793
794
|
- Inspired by [GitHub spec-kit](https://github.com/github/spec-kit)
|
|
794
795
|
- Built for [Claude Code](https://claude.ai/code)
|
|
796
|
+
|
|
797
|
+
Ordinary features develop in separate worktrees under the main checkout's sibling
|
|
798
|
+
`<repository-name>-codexspec-worktrees/`, starting before the first requirements write.
|
|
799
|
+
Blueprint and auto-dev retain their fixed shared worktree. Standalone project edits
|
|
800
|
+
use a maintenance worktree; settings take effect per checkout and reach other checkouts
|
|
801
|
+
through Git integration. See [worktree development](docs/en/user-guide/workflow.md#worktree-development)
|
|
802
|
+
and [configuration](docs/en/reference/configuration.md#workflowworktrees).
|
|
@@ -50,6 +50,17 @@ if [ -z "$FEATURE_SUFFIX" ]; then
|
|
|
50
50
|
exit 1
|
|
51
51
|
fi
|
|
52
52
|
|
|
53
|
+
# Resolve the switch before creating directories or changing Git state.
|
|
54
|
+
if ! command_exists codexspec; then
|
|
55
|
+
log_error "CodexSpec runtime is unavailable. Install codexspec before creating a feature."
|
|
56
|
+
exit 1
|
|
57
|
+
fi
|
|
58
|
+
WORKTREE_SETTING=$(codexspec _worktree-helper setting) || exit $?
|
|
59
|
+
case "$WORKTREE_SETTING" in
|
|
60
|
+
*'"enabled": false'*) ;; # Explicit opt-out retains the original in-place flow below.
|
|
61
|
+
*) exec codexspec _worktree-helper create --name "$FEATURE_SUFFIX" ;;
|
|
62
|
+
esac
|
|
63
|
+
|
|
53
64
|
TIMESTAMP=$(date +"%Y-%m%d-%H%M")
|
|
54
65
|
RANDOM_SUFFIX=$(LC_ALL=C tr -dc 'a-z0-9' </dev/urandom | head -c 2)
|
|
55
66
|
FEATURE_ID="${TIMESTAMP}${RANDOM_SUFFIX}"
|
|
@@ -132,6 +132,34 @@ if (-not $branchSuffix) {
|
|
|
132
132
|
exit 1
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
# Resolve isolation before any feature directory or branch mutation.
|
|
136
|
+
if (-not (Get-Command codexspec -ErrorAction SilentlyContinue)) {
|
|
137
|
+
Write-Error "CodexSpec runtime is unavailable. Install codexspec before creating a feature."
|
|
138
|
+
exit 1
|
|
139
|
+
}
|
|
140
|
+
$settingOutput = & codexspec _worktree-helper setting
|
|
141
|
+
if ($LASTEXITCODE -ne 0) { Write-Output $settingOutput; exit $LASTEXITCODE }
|
|
142
|
+
$setting = $settingOutput | ConvertFrom-Json
|
|
143
|
+
if ($setting.enabled) {
|
|
144
|
+
$workspaceOutput = & codexspec _worktree-helper create --name $branchSuffix
|
|
145
|
+
$workspaceExit = $LASTEXITCODE
|
|
146
|
+
if ($workspaceExit -ne 0) { Write-Output $workspaceOutput; exit $workspaceExit }
|
|
147
|
+
$workspace = $workspaceOutput | ConvertFrom-Json
|
|
148
|
+
$env:CODEXSPEC_FEATURE = $workspace.branch
|
|
149
|
+
$result = [PSCustomObject]@{
|
|
150
|
+
BRANCH_NAME = $workspace.branch
|
|
151
|
+
REQUIREMENTS_FILE = $workspace.requirements_file
|
|
152
|
+
FEATURE_ID = $workspace.feature_id
|
|
153
|
+
WORKTREE_PATH = $workspace.workspace
|
|
154
|
+
HAS_GIT = $true
|
|
155
|
+
STATUS = $workspace.status
|
|
156
|
+
WARNINGS = $workspace.warnings
|
|
157
|
+
}
|
|
158
|
+
if ($Json) { $result | ConvertTo-Json -Compress }
|
|
159
|
+
else { $result | Format-List | Out-String | Write-Output }
|
|
160
|
+
exit 0
|
|
161
|
+
}
|
|
162
|
+
|
|
135
163
|
$specsDir = Join-Path $repoRoot '.codexspec/specs'
|
|
136
164
|
New-Item -ItemType Directory -Path $specsDir -Force | Out-Null
|
|
137
165
|
|
|
@@ -14,9 +14,10 @@ import sys
|
|
|
14
14
|
import webbrowser
|
|
15
15
|
from datetime import datetime
|
|
16
16
|
from pathlib import Path
|
|
17
|
-
from typing import Optional
|
|
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
|
|
@@ -64,9 +65,19 @@ from .i18n import (
|
|
|
64
65
|
from .integrations import get_integrations
|
|
65
66
|
from .profile import ensure_profile_scaffold, inject_profile_block
|
|
66
67
|
from .translator import SUPPORTED_LANGUAGES, translate
|
|
68
|
+
from .worktrees import (
|
|
69
|
+
MAINTENANCE_NAME,
|
|
70
|
+
WorkspaceManager,
|
|
71
|
+
feature_name,
|
|
72
|
+
read_worktrees,
|
|
73
|
+
validate_write_path,
|
|
74
|
+
write_config_scalar,
|
|
75
|
+
write_destination,
|
|
76
|
+
write_worktrees,
|
|
77
|
+
)
|
|
67
78
|
|
|
68
79
|
# Version info
|
|
69
|
-
__version__ = "0.7.
|
|
80
|
+
__version__ = "0.7.19"
|
|
70
81
|
__author__ = "CodexSpec Team"
|
|
71
82
|
|
|
72
83
|
# Constitution file path constants
|
|
@@ -82,6 +93,51 @@ app = typer.Typer(
|
|
|
82
93
|
console = Console()
|
|
83
94
|
|
|
84
95
|
|
|
96
|
+
@app.command("_worktree-helper", hidden=True)
|
|
97
|
+
def worktree_helper(
|
|
98
|
+
action: str = typer.Argument(...),
|
|
99
|
+
name: Optional[str] = typer.Option(None, "--name"),
|
|
100
|
+
feature: Optional[str] = typer.Option(None, "--feature"),
|
|
101
|
+
verification: Optional[Path] = typer.Option(None, "--verification"),
|
|
102
|
+
) -> None:
|
|
103
|
+
"""Return structured workspace facts; never emit shell code for callers to evaluate."""
|
|
104
|
+
recovery: dict[str, Any] = {}
|
|
105
|
+
result: dict[str, Any]
|
|
106
|
+
try:
|
|
107
|
+
from .worktrees import checkout_root
|
|
108
|
+
|
|
109
|
+
root = checkout_root(Path.cwd())
|
|
110
|
+
if action == "setting":
|
|
111
|
+
result = {"enabled": read_worktrees(root / ".codexspec/config.yml")}
|
|
112
|
+
elif action == "route":
|
|
113
|
+
result = {"status": "ready", "workspace": str(write_destination(root))}
|
|
114
|
+
elif action == "create" and not read_worktrees(root / ".codexspec/config.yml"):
|
|
115
|
+
result = {"status": "disabled", "workspace": str(root.resolve())}
|
|
116
|
+
else:
|
|
117
|
+
manager = WorkspaceManager(root)
|
|
118
|
+
if action == "create":
|
|
119
|
+
if bool(name) == bool(feature):
|
|
120
|
+
raise AutomationError("expected_name_or_feature")
|
|
121
|
+
identity = feature if feature else feature_name(name or "")
|
|
122
|
+
branch, path, _ = manager._identity(identity)
|
|
123
|
+
recovery = {"branch": branch, "workspace": str(path)}
|
|
124
|
+
result = manager.create(identity, reuse=feature is not None)
|
|
125
|
+
elif action == "resolve" and feature:
|
|
126
|
+
result = manager.resolve(feature)
|
|
127
|
+
elif action == "maintenance":
|
|
128
|
+
result = manager.create(MAINTENANCE_NAME)
|
|
129
|
+
elif action == "finish" and feature and verification:
|
|
130
|
+
result = manager.finish(feature, json.loads(verification.read_text(encoding="utf-8")))
|
|
131
|
+
else:
|
|
132
|
+
raise AutomationError("invalid_workspace_action", action)
|
|
133
|
+
print(json.dumps(result, ensure_ascii=False))
|
|
134
|
+
if result.get("status") in {"creating", "merge_requires_resolution", "merge_requires_verification"}:
|
|
135
|
+
raise typer.Exit(3)
|
|
136
|
+
except (AutomationError, OSError, ValueError) as exc:
|
|
137
|
+
print(json.dumps({**recovery, "status": "blocked", "error": str(exc)}, ensure_ascii=False))
|
|
138
|
+
raise typer.Exit(1) from exc
|
|
139
|
+
|
|
140
|
+
|
|
85
141
|
@app.command("_distill-review-helper", hidden=True)
|
|
86
142
|
def distill_review_helper(
|
|
87
143
|
project_root: Path = typer.Option(Path("."), "--project-root"),
|
|
@@ -99,6 +155,17 @@ def distill_review_helper(
|
|
|
99
155
|
if not root.is_dir() or not (root / ".codexspec" / "profile").is_dir():
|
|
100
156
|
_review_result(language, {"status": "invalid_input", "error": "invalid_project_root"})
|
|
101
157
|
raise typer.Exit(2)
|
|
158
|
+
try:
|
|
159
|
+
root = write_destination(root)
|
|
160
|
+
except (AutomationError, OSError) as exc:
|
|
161
|
+
_review_result(language, {"status": "invalid_input", "error": str(exc)})
|
|
162
|
+
raise typer.Exit(2) from exc
|
|
163
|
+
language = get_interaction_language(root / ".codexspec" / "config.yml")
|
|
164
|
+
if not (root / ".codexspec" / "profile").is_dir():
|
|
165
|
+
_review_result(
|
|
166
|
+
language, {"status": "invalid_input", "error": "missing_destination_profile", "project_root": str(root)}
|
|
167
|
+
)
|
|
168
|
+
raise typer.Exit(2)
|
|
102
169
|
store = SessionStore(root)
|
|
103
170
|
lease = ReviewLease(root)
|
|
104
171
|
try:
|
|
@@ -479,6 +546,25 @@ _AUTO_NEXT_ACCEPTED = "on/off, true/false, 1/0, yes/no"
|
|
|
479
546
|
# sets for parsing; a distinct sentinel keeps the bare-toggle rewrites separate.
|
|
480
547
|
_AUTO_DISTILL_SENTINEL = "__toggle_distill__"
|
|
481
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
|
+
|
|
482
568
|
|
|
483
569
|
@app.command()
|
|
484
570
|
def config(
|
|
@@ -526,6 +612,14 @@ def config(
|
|
|
526
612
|
"--auto-distill",
|
|
527
613
|
help="Toggle workflow.auto_distill (bare), or set it (on/off|true/false|1/0|yes/no).",
|
|
528
614
|
),
|
|
615
|
+
worktrees: Optional[str] = typer.Option(
|
|
616
|
+
None, "--worktrees", help="Toggle checkout-local worktree isolation (default on), or set on/off."
|
|
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
|
+
),
|
|
529
623
|
) -> None:
|
|
530
624
|
"""
|
|
531
625
|
View or modify CodexSpec project configuration.
|
|
@@ -539,6 +633,7 @@ def config(
|
|
|
539
633
|
codexspec config --set-commit-lang en # Set commit messages to English
|
|
540
634
|
codexspec config --auto-next # Toggle workflow.auto_next
|
|
541
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
|
|
542
637
|
codexspec config --list-langs # List supported languages
|
|
543
638
|
"""
|
|
544
639
|
# Handle list languages
|
|
@@ -561,6 +656,76 @@ def config(
|
|
|
561
656
|
console.print("Run [cyan]codexspec init[/cyan] to create a new project.")
|
|
562
657
|
raise typer.Exit(1)
|
|
563
658
|
|
|
659
|
+
# Validate values before creating any destination workspace.
|
|
660
|
+
for value, sentinel, option in (
|
|
661
|
+
(auto_next, _AUTO_NEXT_SENTINEL, "--auto-next"),
|
|
662
|
+
(auto_distill, _AUTO_DISTILL_SENTINEL, "--auto-distill"),
|
|
663
|
+
(worktrees, "__toggle_worktrees__", "--worktrees"),
|
|
664
|
+
):
|
|
665
|
+
if value is not None and value != sentinel:
|
|
666
|
+
try:
|
|
667
|
+
parse_auto_next_value(value)
|
|
668
|
+
except ValueError:
|
|
669
|
+
console.print(f"[red]Invalid {option} value:[/red] {value!r}")
|
|
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)
|
|
678
|
+
modifying = any(
|
|
679
|
+
value is not None
|
|
680
|
+
for value in (
|
|
681
|
+
auto_next,
|
|
682
|
+
auto_distill,
|
|
683
|
+
worktrees,
|
|
684
|
+
decided_by,
|
|
685
|
+
set_lang,
|
|
686
|
+
set_commit_lang,
|
|
687
|
+
set_interaction_lang,
|
|
688
|
+
set_document_lang,
|
|
689
|
+
)
|
|
690
|
+
)
|
|
691
|
+
if modifying:
|
|
692
|
+
try:
|
|
693
|
+
isolated = read_worktrees(config_file)
|
|
694
|
+
destination = write_destination(config_file.parent.parent)
|
|
695
|
+
config_file = destination / ".codexspec" / "config.yml"
|
|
696
|
+
if isolated:
|
|
697
|
+
validate_write_path(destination, config_file)
|
|
698
|
+
if set_lang is not None or set_interaction_lang is not None:
|
|
699
|
+
_validate_command_frontmatter(destination)
|
|
700
|
+
if not config_file.is_file():
|
|
701
|
+
raise AutomationError("missing_destination_config", str(config_file))
|
|
702
|
+
console.print(f"Configuration destination: {config_file}", markup=False, soft_wrap=True)
|
|
703
|
+
console.print("Changes apply to this checkout; other checkouts receive them through Git integration.")
|
|
704
|
+
except (AutomationError, OSError) as exc:
|
|
705
|
+
console.print(str(exc), markup=False)
|
|
706
|
+
raise typer.Exit(1) from exc
|
|
707
|
+
if worktrees is not None:
|
|
708
|
+
target = (
|
|
709
|
+
not read_worktrees(config_file) if worktrees == "__toggle_worktrees__" else parse_auto_next_value(worktrees)
|
|
710
|
+
)
|
|
711
|
+
try:
|
|
712
|
+
write_worktrees(config_file, target)
|
|
713
|
+
except (AutomationError, OSError) as exc:
|
|
714
|
+
console.print(str(exc), markup=False)
|
|
715
|
+
raise typer.Exit(1) from exc
|
|
716
|
+
console.print(f"workflow.worktrees = {str(target).lower()}")
|
|
717
|
+
return
|
|
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
|
+
|
|
564
729
|
# Handle auto-next toggle/set
|
|
565
730
|
if auto_next is not None:
|
|
566
731
|
if auto_next == _AUTO_NEXT_SENTINEL:
|
|
@@ -740,6 +905,22 @@ def config(
|
|
|
740
905
|
return
|
|
741
906
|
|
|
742
907
|
# Display current configuration
|
|
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
|
+
)
|
|
743
924
|
console.print(
|
|
744
925
|
Panel(
|
|
745
926
|
config_file.read_text(encoding="utf-8"),
|
|
@@ -1228,6 +1409,15 @@ def init(
|
|
|
1228
1409
|
console.print(f"[yellow]{_important_action(integrations, normalized_lang)}[/yellow]")
|
|
1229
1410
|
|
|
1230
1411
|
|
|
1412
|
+
def _validate_command_frontmatter(root: Path) -> None:
|
|
1413
|
+
commands = root / ".claude" / "commands" / COMMANDS_SUBDIR
|
|
1414
|
+
validate_write_path(root, commands)
|
|
1415
|
+
if commands.exists() and not commands.is_dir():
|
|
1416
|
+
raise AutomationError("unsafe_write_path", str(commands))
|
|
1417
|
+
for command in commands.glob("*.md"):
|
|
1418
|
+
validate_write_path(root, command)
|
|
1419
|
+
|
|
1420
|
+
|
|
1231
1421
|
def _rerender_command_frontmatter(config_file: Path) -> None:
|
|
1232
1422
|
"""Re-render installed command frontmatter in the current interaction language.
|
|
1233
1423
|
|
|
@@ -1237,7 +1427,7 @@ def _rerender_command_frontmatter(config_file: Path) -> None:
|
|
|
1237
1427
|
pre-translated cache are not re-rendered here (that path would invoke the
|
|
1238
1428
|
``claude`` CLI once per command); the user is advised to run ``codexspec init``.
|
|
1239
1429
|
"""
|
|
1240
|
-
commands_subdir =
|
|
1430
|
+
commands_subdir = config_file.parent.parent / ".claude" / "commands" / COMMANDS_SUBDIR
|
|
1241
1431
|
if not commands_subdir.exists():
|
|
1242
1432
|
return
|
|
1243
1433
|
language = get_interaction_language(config_file) # re-read AFTER the config write
|
|
@@ -1472,6 +1662,111 @@ def _write_auto_distill(config_file: Path, value: bool) -> bool:
|
|
|
1472
1662
|
return True
|
|
1473
1663
|
|
|
1474
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
|
+
|
|
1475
1770
|
def _next_step_start(integration_keys: set[str], language: str) -> str:
|
|
1476
1771
|
"""Return a target-aware start instruction."""
|
|
1477
1772
|
if integration_keys == {"codex"}:
|
|
@@ -1919,6 +2214,8 @@ def main() -> None:
|
|
|
1919
2214
|
sys.argv = _normalize_auto_next_argv(sys.argv)
|
|
1920
2215
|
if "--auto-distill" in sys.argv:
|
|
1921
2216
|
sys.argv = _normalize_auto_distill_argv(sys.argv)
|
|
2217
|
+
if "--worktrees" in sys.argv:
|
|
2218
|
+
sys.argv = _normalize_optional_value_argv(sys.argv, "--worktrees", "__toggle_worktrees__")
|
|
1922
2219
|
app()
|
|
1923
2220
|
|
|
1924
2221
|
|
|
@@ -173,8 +173,12 @@ def locate_repository(cwd: Path | str, *, runner: GitRunner | None = None) -> Re
|
|
|
173
173
|
current = Path(cwd).resolve()
|
|
174
174
|
top = git.run(current, "rev-parse", "--show-toplevel", check=False)
|
|
175
175
|
if top.returncode != 0:
|
|
176
|
-
|
|
177
|
-
|
|
176
|
+
bare = git.run(current, "rev-parse", "--is-bare-repository", check=False)
|
|
177
|
+
if bare.returncode != 0 or bare.stdout.strip() != "true":
|
|
178
|
+
raise AutomationError("not_git_repository")
|
|
179
|
+
invoking_root = Path(git.run(current, "rev-parse", "--absolute-git-dir").stdout.strip()).resolve()
|
|
180
|
+
else:
|
|
181
|
+
invoking_root = Path(top.stdout.strip()).resolve()
|
|
178
182
|
worktrees = _parse_worktrees(git.run(invoking_root, "worktree", "list", "--porcelain").stdout)
|
|
179
183
|
if not worktrees:
|
|
180
184
|
raise AutomationError("worktree_registry_empty")
|
|
@@ -188,7 +192,7 @@ def locate_repository(cwd: Path | str, *, runner: GitRunner | None = None) -> Re
|
|
|
188
192
|
default_branch = remote_branch or _local_default_branch(git, primary_root, worktrees[0].get("branch"))
|
|
189
193
|
if remote_name and remote_ref is None:
|
|
190
194
|
remote_ref = f"refs/remotes/{remote_name}/{default_branch}"
|
|
191
|
-
worktree_path = Path(f"{primary_root}-worktrees") / WORKTREE_BASENAME
|
|
195
|
+
worktree_path = Path(f"{primary_root}-codexspec-worktrees") / WORKTREE_BASENAME
|
|
192
196
|
return RepositoryContext(
|
|
193
197
|
repository_root=primary_root,
|
|
194
198
|
common_git_dir=common_git_dir,
|
|
@@ -303,16 +307,22 @@ def _remote_default(git: GitRunner, root: Path) -> tuple[str | None, str | None,
|
|
|
303
307
|
if symbolic.returncode != 0:
|
|
304
308
|
return remote, None, None
|
|
305
309
|
ref = symbolic.stdout.strip()
|
|
306
|
-
return remote, ref, ref.
|
|
310
|
+
return remote, ref, ref.removeprefix(f"refs/remotes/{remote}/")
|
|
307
311
|
|
|
308
312
|
|
|
309
313
|
def _local_default_branch(git: GitRunner, root: Path, primary_branch_ref: str | None) -> str:
|
|
310
314
|
for candidate in ("main", "master"):
|
|
311
315
|
if git.run(root, "show-ref", "--verify", "--quiet", f"refs/heads/{candidate}", check=False).returncode == 0:
|
|
312
316
|
return candidate
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
317
|
+
configured = git.run(root, "config", "--get", "init.defaultBranch", check=False).stdout.strip()
|
|
318
|
+
if (
|
|
319
|
+
configured
|
|
320
|
+
and git.run(root, "show-ref", "--verify", "--quiet", f"refs/heads/{configured}", check=False).returncode == 0
|
|
321
|
+
):
|
|
322
|
+
return configured
|
|
323
|
+
raise AutomationError(
|
|
324
|
+
"default_branch_not_found", "Configure the remote default branch or a valid init.defaultBranch."
|
|
325
|
+
)
|
|
316
326
|
|
|
317
327
|
|
|
318
328
|
def _parse_worktrees(output: str) -> list[dict[str, Any]]:
|