Skip to content

fix(presets): reconcile command files after priority changes - #5113

Open
mikamikasuki wants to merge 2 commits into
github:mainfrom
mikamikasuki:fix/5087-reconcile-command-priority
Open

mikamikasuki wants to merge 2 commits into
github:mainfrom
mikamikasuki:fix/5087-reconcile-command-priority

Conversation

@mikamikasuki

Copy link
Copy Markdown

Description

When a preset priority changes, the resolver can select a different command layer while the generated agent command file still contains the previous winner. Reconcile the affected command and skill artifacts against the full priority stack after updating the registry.

Closes #5087

Testing

  • The regression fails against main at 67e0f72 and passes with this change.
  • Preset tests: 744 passed, 1 skipped.
  • Ruff check and format checks pass for both changed files.
  • The regression invokes specify preset set-priority in a temporary Gemini project and verifies the generated command switches to the new winner.

AI Disclosure

  • I did use AI assistance (fill in the disclosure below)

AI disclosure: OpenAI Codex (GPT-6; reasoning effort not exposed in this task; autonomous); issue analysis, reproduction, code and regression-test generation, and validation.

Assisted-by: OpenAI Codex (model: GPT-6, autonomous)
@mikamikasuki
mikamikasuki requested a review from mnriem as a code owner October 25, 2026 02:38
@mnriem mnriem added the triage-must-have Verdict: high-value, important work for Spec Kit — do first label Oct 25, 2026
@mnriem
mnriem requested a max review from Copilot October 26, 2026 13:56

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.

🟡 Changes recommended

Priority changes can still produce incorrect agent artifacts for disabled presets and convention-provided command layers.

3 open issues
What changed in this PR

Addresses #5087 by refreshing generated agent artifacts when preset set-priority changes command precedence.

Changes:

  • Reconciles affected commands and skills against the updated priority stack.
  • Adds best-effort failure warnings and a Gemini CLI regression verifying that generated command content switches winners.

Validation relies on the reported before-and-after results; tests were not rerun.

AI disclosure: GitHub Copilot (model unknown; automated review) generated this review for the requesting contributor.

File Description
tests/​specify_cli/​presets/​test_command_set_priority.py Adds a CLI regression for generated command refresh.
src/​specify_cli/​presets/​command_set_priority.py Adds command and skill reconciliation after priority updates.

Review effort: Max

@mnriem

mnriem commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Please address Copilot feedback

@mnriem mnriem added the author-awaiting Waiting on author response label Oct 26, 2026
Assisted-by: OpenAI Codex (model: GPT-6, autonomous)
Copilot AI max review requested due to automatic review settings November 16, 2026 01:43
@mikamikasuki

Copy link
Copy Markdown
Author

Review follow-up by @mikamikasuki with OpenAI Codex (GPT-6, autonomous). AI authored the review analysis, implementation, regression tests, and this summary.

Updated priority reconciliation to include convention-based command files and to leave artifacts untouched when the target preset is disabled. Added coverage for skills-mode rematerialization and for command reconciliation failures while preserving the saved priority and constitution reconciliation.

Validation: test_command_set_priority.py — 11 passed; git diff --check passed. Ruff was unavailable in the local environment.

Commit: 826038047afc22a3bab012f47038ab2e5d2b56f9.

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.

Comment on lines +77 to +84
# Presets may also provide conventional commands without declaring
# them in preset.yml. Include those names so a priority change can
# rematerialize the command they participate in.
convention_commands = manager.presets_dir / preset_id / "commands"
if convention_commands.is_dir():
command_names.extend(
path.stem for path in convention_commands.glob("*.md")
)
Comment on lines +82 to +84
command_names.extend(
path.stem for path in convention_commands.glob("*.md")
)
command_names = list(dict.fromkeys(command_names))
if command_names:
manager._reconcile_composed_commands(command_names)
manager._reconcile_skills(command_names)
Comment on lines +177 to +186
assert "FROZEN" in command_file.read_text()

with patch.object(Path, "cwd", return_value=project_dir):
result = CliRunner().invoke(
app, ["preset", "set-priority", "disabled-priority", "25"]
)

assert result.exit_code == 0, result.output
assert PresetManager(project_dir).registry.get("disabled-priority")["priority"] == 25
assert "FROZEN" in command_file.read_text()

This branch has not been deployed

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

Labels

author-awaiting Waiting on author response triage-must-have Verdict: high-value, important work for Spec Kit — do first

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: specify preset set-priority does not update agent command files that are already written

3 participants