Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(templates): add py: lines to command templates' scripts frontmatter#3403

Open
marcelsafin wants to merge 4 commits into
github:mainfrom
marcelsafin:feat/3283-py-script-lines
Open

feat(templates): add py: lines to command templates' scripts frontmatter#3403
marcelsafin wants to merge 4 commits into
github:mainfrom
marcelsafin:feat/3283-py-script-lines

Conversation

@marcelsafin

@marcelsafin marcelsafin commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #3283 (part of #3277)

Adds a py: line to the scripts: frontmatter block in the 6 command templates whose referenced Python script already ships in the repo (check_prerequisites.py). plan.md and tasks.md get their lines in #3386 together with setup_plan.py/setup_tasks.py; a test asserts every py: line points at an existing script, so a dangling reference cannot merge green. process_template already handles the py script type (interpreter resolution, quoting, path rewrite to .specify/scripts/python/), so this is the last wiring needed for --script py rendering.

Extension commands reference scripts inline in prose rather than through scripts: frontmatter, so no extension files change.

Testing

  • Tested locally with uv run specify --help
  • Ran existing tests with uv sync && uv run pytest (3834 passed)
  • Tested with a sample project (if applicable)

New tests/test_command_template_py_scripts.py (25 tests) discovers every scripted template and verifies: a py: line exists, --script py rendering produces an interpreter-prefixed Python invocation, and sh rendering is unchanged.

AI Disclosure

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

Written with GitHub Copilot CLI; I reviewed the diff and test results.

Every templates/commands/*.md with a scripts: block now declares a py:
variant so --script py renders a Python invocation via the existing
interpreter-prefixing in process_template.

Fixes github#3283

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings July 8, 2026 06:31
@marcelsafin marcelsafin requested a review from mnriem as a code owner July 8, 2026 06:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Spec Kit’s command templates to include a py: entry in their scripts: frontmatter blocks, and adds tests to ensure IntegrationBase.process_template(..., script_type="py") renders a Python-invocation string (supporting the --script py pathway described in #3283/#3277).

Changes:

  • Add py: script lines to all 8 templates/commands/*.md files that declare a scripts: block.
  • Add tests/test_command_template_py_scripts.py to validate py: presence and basic --script py rendering behavior.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/test_command_template_py_scripts.py New tests to discover scripted templates, assert py: lines exist, and validate process_template(..., "py") output shape
templates/commands/analyze.md Add py: script entry for check prerequisites
templates/commands/checklist.md Add py: script entry for check prerequisites
templates/commands/clarify.md Add py: script entry for check prerequisites
templates/commands/converge.md Add py: script entry for check prerequisites
templates/commands/implement.md Add py: script entry for check prerequisites
templates/commands/plan.md Add py: script entry for plan setup
templates/commands/tasks.md Add py: script entry for tasks setup
templates/commands/taskstoissues.md Add py: script entry for check prerequisites

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

scripts:
sh: scripts/bash/check-prerequisites.sh --json --require-tasks --include-tasks
ps: scripts/powershell/check-prerequisites.ps1 -Json -RequireTasks -IncludeTasks
py: scripts/python/check_prerequisites.py --json --require-tasks --include-tasks

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, thanks. install_shared_infra mapped every non-sh type to powershell. Fixed in aa7e627: py now maps to the python variant dir (with __pycache__ excluded from the copy), plus a test that runs the installer with --script py and asserts check_prerequisites.py lands in .specify/scripts/python/.

Comment thread templates/commands/plan.md Outdated
scripts:
sh: scripts/bash/setup-plan.sh --json
ps: scripts/powershell/setup-plan.ps1 -Json
py: scripts/python/setup_plan.py --json

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, setup_plan.py ships in #3386. Noted in the PR description: if merge order matters, #3386 should land first. I can drop the plan/tasks lines to a follow-up instead if you prefer this PR standalone.

Comment thread templates/commands/tasks.md Outdated
scripts:
sh: scripts/bash/setup-tasks.sh --json
ps: scripts/powershell/setup-tasks.ps1 -Json
py: scripts/python/setup_tasks.py --json

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the plan.md thread: setup_tasks.py ships in #3386, which should land before this one. Happy to split these two lines out if standalone mergeability matters more than epic order.

install_shared_infra mapped every non-sh script type to powershell, so
--script py rendered invocations pointing at files that were never
installed. Map py to the python variant dir and skip __pycache__
artifacts during the copy.

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings July 8, 2026 06:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.

Comment on lines +18 to +20
SCRIPTED_TEMPLATES = sorted(
p.name for p in TEMPLATES_DIR.glob("*.md") if "\nscripts:\n" in p.read_text()
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, all four read_text() calls now pass encoding="utf-8".


@pytest.mark.parametrize("name", SCRIPTED_TEMPLATES)
def test_template_declares_py_script(name: str):
content = (TEMPLATES_DIR / name).read_text()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, all four read_text() calls now pass encoding="utf-8".


@pytest.mark.parametrize("name", SCRIPTED_TEMPLATES)
def test_template_renders_python_invocation(name: str):
content = (TEMPLATES_DIR / name).read_text()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, all four read_text() calls now pass encoding="utf-8".

@pytest.mark.parametrize("name", SCRIPTED_TEMPLATES)
def test_sh_rendering_unchanged(name: str):
# Negative: adding py: lines must not leak into sh rendering.
content = (TEMPLATES_DIR / name).read_text()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, all four read_text() calls now pass encoding="utf-8".

Comment thread templates/commands/plan.md Outdated
Comment on lines +11 to +14
scripts:
sh: scripts/bash/setup-plan.sh --json
ps: scripts/powershell/setup-plan.ps1 -Json
py: scripts/python/setup_plan.py --json

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same dependency as the earlier plan.md thread: setup_plan.py ships in #3386, which should merge before this PR. Flagged in the description.

Comment thread templates/commands/tasks.md Outdated
Comment on lines +12 to +15
scripts:
sh: scripts/bash/setup-tasks.sh --json
ps: scripts/powershell/setup-tasks.ps1 -Json
py: scripts/python/setup_tasks.py --json

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Covered by the #3386 dependency noted in the description; setup_tasks.py lands there first.

Copilot AI review requested due to automatic review settings July 8, 2026 06:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Comment on lines +40 to +43
content = (TEMPLATES_DIR / name).read_text(encoding="utf-8")
assert re.search(r"^\s*py: scripts/python/\S+\.py", content, re.MULTILINE), (
f"{name} has a scripts: block but no py: line"
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, an existence check is stronger than a description note. Done in latest commit: the plan/tasks lines move to #3386 where the scripts ship, and the test now asserts every py: path exists in the repo, so a dangling reference cannot merge green. This PR is standalone now.

Drop the plan/tasks py: lines that referenced scripts shipping in the
core port (github#3280); they move to that PR. Tests now assert every py:
line points at a script the repo ships, so a dangling reference can
never merge green.

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings July 8, 2026 06:58
marcelsafin added a commit to marcelsafin/spec-kit that referenced this pull request Jul 8, 2026
Ships with the scripts they reference; the remaining templates got
their py: lines in github#3403.

Co-authored-by: Copilot <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add py: lines to command templates' scripts: frontmatter

2 participants