Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions scripts/bash/setup-plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@ if $JSON_MODE; then
jq -cn \
--arg feature_spec "$FEATURE_SPEC" \
--arg impl_plan "$IMPL_PLAN" \
--arg specs_dir "$FEATURE_DIR" \
--arg feature_dir "$FEATURE_DIR" \
--arg branch "$CURRENT_BRANCH" \
'{FEATURE_SPEC:$feature_spec,IMPL_PLAN:$impl_plan,SPECS_DIR:$specs_dir,BRANCH:$branch}'
'{FEATURE_SPEC:$feature_spec,IMPL_PLAN:$impl_plan,FEATURE_DIR:$feature_dir,BRANCH:$branch}'
else
printf '{"FEATURE_SPEC":"%s","IMPL_PLAN":"%s","SPECS_DIR":"%s","BRANCH":"%s"}\n' \
printf '{"FEATURE_SPEC":"%s","IMPL_PLAN":"%s","FEATURE_DIR":"%s","BRANCH":"%s"}\n' \
"$(json_escape "$FEATURE_SPEC")" "$(json_escape "$IMPL_PLAN")" "$(json_escape "$FEATURE_DIR")" "$(json_escape "$CURRENT_BRANCH")"
fi
else
echo "FEATURE_SPEC: $FEATURE_SPEC"
echo "IMPL_PLAN: $IMPL_PLAN"
echo "SPECS_DIR: $FEATURE_DIR"
echo "FEATURE_DIR: $FEATURE_DIR"
echo "BRANCH: $CURRENT_BRANCH"
fi
4 changes: 2 additions & 2 deletions scripts/powershell/setup-plan.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ if ($Json) {
$result = [PSCustomObject]@{
FEATURE_SPEC = $paths.FEATURE_SPEC
IMPL_PLAN = $paths.IMPL_PLAN
SPECS_DIR = $paths.FEATURE_DIR
FEATURE_DIR = $paths.FEATURE_DIR
BRANCH = $paths.CURRENT_BRANCH
}
$result | ConvertTo-Json -Compress
} else {
Write-Output "FEATURE_SPEC: $($paths.FEATURE_SPEC)"
Write-Output "IMPL_PLAN: $($paths.IMPL_PLAN)"
Write-Output "SPECS_DIR: $($paths.FEATURE_DIR)"
Write-Output "FEATURE_DIR: $($paths.FEATURE_DIR)"
Write-Output "BRANCH: $($paths.CURRENT_BRANCH)"
}
4 changes: 2 additions & 2 deletions scripts/python/setup_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ def main(argv: list[str] | None = None) -> int:
{
"FEATURE_SPEC": str(paths.feature_spec),
"IMPL_PLAN": str(paths.impl_plan),
"SPECS_DIR": str(paths.feature_dir),
"FEATURE_DIR": str(paths.feature_dir),
"BRANCH": paths.current_branch,
}
)
)
else:
print(f"FEATURE_SPEC: {paths.feature_spec}")
print(f"IMPL_PLAN: {paths.impl_plan}")
print(f"SPECS_DIR: {paths.feature_dir}")
print(f"FEATURE_DIR: {paths.feature_dir}")
print(f"BRANCH: {paths.current_branch}")
return 0

Expand Down
2 changes: 1 addition & 1 deletion templates/commands/plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ You **MUST** consider the user input before proceeding (if not empty).

## Outline

1. **Setup**: Run `{SCRIPT}` from repo root and parse JSON for FEATURE_SPEC, IMPL_PLAN, SPECS_DIR, BRANCH. For single quotes in args like "I'm Groot", use escape syntax: e.g 'I'\''m Groot' (or double-quote if possible: "I'm Groot").
1. **Setup**: Run `{SCRIPT}` from repo root and parse JSON for FEATURE_SPEC, IMPL_PLAN, FEATURE_DIR, BRANCH. For single quotes in args like "I'm Groot", use escape syntax: e.g 'I'\''m Groot' (or double-quote if possible: "I'm Groot").

2. **Load context**: Read FEATURE_SPEC and `/memory/constitution.md`. Load IMPL_PLAN template (already copied).

Expand Down
54 changes: 54 additions & 0 deletions tests/test_setup_plan_python_parity.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,3 +374,57 @@ def test_python_json_output_matches_powershell(repo: Path) -> None:

assert py.returncode == ps.returncode == 0
assert json_stdout(py) == json_stdout(ps)


@requires_bash
@pytest.mark.parametrize("args", [("--json",), ()], ids=["json", "text"])
def test_all_variants_emit_feature_dir_not_specs_dir(
repo: Path, args: tuple[str, ...]
) -> None:
r"""Pin the output key name, not just cross-port agreement.

The other tests here compare the ports against each other, so all three
could regress to ``SPECS_DIR`` together and still pass. This asserts the
contract absolutely: the key is ``FEATURE_DIR``, it carries the feature
directory rather than the specs root, and the old name is gone.
``SPECS_DIR`` means the specs root in ``create-new-feature.sh``, so
re-emitting it here would reintroduce one name for two paths.

The value is matched by suffix because the ports legitimately differ in
path flavour -- under MSYS bash reports ``/tmp/...`` where the Python and
PowerShell ports report ``C:\...``. The suffix still separates
``specs/001-my-feature`` from a bare ``specs``, which is the regression
this guards.
"""
json_mode = args == ("--json",)
suffix = ("specs", "001-my-feature")

commands = [bash_cmd(repo, SCRIPT, *args), py_cmd(repo, SCRIPT, *args)]
if HAS_POWERSHELL:
commands.append(ps_cmd(repo, SCRIPT, *(("-Json",) if json_mode else ())))

for cmd in commands:
result = run(cmd, repo)
assert result.returncode == 0, result.stderr
assert "SPECS_DIR" not in result.stdout

if json_mode:
payload = json_stdout(result)
assert isinstance(payload, dict)
assert sorted(payload) == [
"BRANCH",
"FEATURE_DIR",
"FEATURE_SPEC",
"IMPL_PLAN",
]
value = payload["FEATURE_DIR"]
else:
lines = dict(
line.split(": ", 1)
for line in result.stdout.splitlines()
if ": " in line
)
assert "FEATURE_DIR" in lines
value = lines["FEATURE_DIR"]

assert tuple(value.replace("\\", "/").rstrip("/").split("/")[-2:]) == suffix