spec-kit icon indicating copy to clipboard operation
spec-kit copied to clipboard

feat(scripts): port create-new-feature, setup-plan and setup-tasks to Python

Open marcelsafin opened this issue 4 months ago • 2 comments

Description

Ports the three core workflow scripts to Python, per #3280. Follows the pattern established by the check-prerequisites PoC (#3302): additive port with parity tests that run the bash and Python versions side by side and compare output. Two small non-additive touches: templates/commands/plan.md and templates/commands/tasks.md gain a scripts.py entry, and resolve_skill_placeholders accepts py as a script variant (with interpreter prefixing and a fallback when a command's frontmatter lacks the configured variant).

Scope:

  • scripts/python/create_new_feature.py — port of create-new-feature.sh, including branch-name generation (stop words, acronym detection, word limits), feature numbering (specs scan + timestamp-dir handling), the 244-char ref-length truncation, --allow-existing-branch mode, and feature.json persistence (byte-identical to the jq output).
  • scripts/python/setup_plan.py — port of setup-plan.sh, including plan template resolution and the status messages that go to stderr in --json mode.
  • scripts/python/setup_tasks.py — port of setup-tasks.sh, including plan/spec validation and the tasks-template requirement.
  • scripts/python/common.py — adds resolve_template() (overrides → presets via registry → extensions → core), shared by the three scripts above.
  • tests/parity_helpers.py — shared fixtures/helpers for parity tests, extracted from the pattern in test_check_prerequisites_python_parity.py.
  • 25 parity tests across three files: exact JSON equality against bash, normalized text output, PowerShell JSON parity (skipped when pwsh is unavailable).

One deliberate deviation: --number abc produces a clean error message in Python where bash surfaces a raw arithmetic error (10#abc: value too great for base). The parity test asserts exit code and empty stdout for that case, not the stderr text.

Testing

  • [x] Tested locally with uv run specify --help
  • [x] Ran existing tests with uv sync && uv run pytest (3801 passed, 110 skipped)
  • [x] Manual side-by-side runs of bash vs Python on a sample repo (23 cases: numbering, stop words, acronyms, truncation, collision handling, JSON/text modes)

AI Disclosure

  • [ ] I did not use AI assistance for this contribution
  • [x] I did use AI assistance (describe below)

Ported and tested with GitHub Copilot CLI. I reviewed the diff and verified parity behavior manually.

Fixes #3280

marcelsafin avatar Jul 06 '26 23:07 marcelsafin

@copilot review

marcelsafin avatar Jul 13 '26 22:07 marcelsafin

Please address Copilot feedback and resolve conflicts

mnriem avatar Jul 13 '26 23:07 mnriem

@copilot review

marcelsafin avatar Jul 14 '26 12:07 marcelsafin

@copilot review

marcelsafin avatar Jul 14 '26 13:07 marcelsafin

Please address Copilot feedback

mnriem avatar Jul 14 '26 15:07 mnriem

@copilot review

marcelsafin avatar Jul 16 '26 12:07 marcelsafin

Please address Copilot feedback

mnriem avatar Jul 16 '26 12:07 mnriem

@copilot review

marcelsafin avatar Jul 16 '26 13:07 marcelsafin

Please address Copilot feedback. If not applicable, please explain why

mnriem avatar Jul 16 '26 15:07 mnriem

@copilot review

marcelsafin avatar Jul 17 '26 15:07 marcelsafin

@copilot review

marcelsafin avatar Jul 17 '26 15:07 marcelsafin

@copilot review

marcelsafin avatar Jul 17 '26 15:07 marcelsafin

@copilot review

marcelsafin avatar Jul 17 '26 16:07 marcelsafin

@copilot review

marcelsafin avatar Jul 17 '26 16:07 marcelsafin

@copilot review

marcelsafin avatar Jul 17 '26 16:07 marcelsafin

@copilot review

marcelsafin avatar Jul 17 '26 17:07 marcelsafin

@copilot review

marcelsafin avatar Jul 17 '26 17:07 marcelsafin

@copilot review

marcelsafin avatar Jul 17 '26 17:07 marcelsafin

@copilot review

marcelsafin avatar Jul 17 '26 17:07 marcelsafin

@copilot review

marcelsafin avatar Jul 17 '26 17:07 marcelsafin