Skip to content

Commit 2316fa3

Browse files
committed
fix: resolve remaining PR1690 review threads
1 parent 598d9f6 commit 2316fa3

File tree

4 files changed

+38
-13
lines changed

4 files changed

+38
-13
lines changed

.devcontainer/post-create.sh

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ echo "✅ Done"
5454
echo -e "\n🤖 Installing Kiro CLI..."
5555
# https://kiro.dev/docs/cli/
5656
KIRO_INSTALLER_URL="https://cli.kiro.dev/install"
57+
KIRO_INSTALLER_SHA256="7487a65cf310b7fb59b357c4b5e6e3f3259d383f4394ecedb39acf70f307cffb"
5758
KIRO_INSTALLER_PATH="$(mktemp)"
5859

5960
cleanup_kiro_installer() {
@@ -62,17 +63,7 @@ cleanup_kiro_installer() {
6263
trap cleanup_kiro_installer EXIT
6364

6465
run_command "curl -fsSL \"$KIRO_INSTALLER_URL\" -o \"$KIRO_INSTALLER_PATH\""
65-
66-
if [ -n "${KIRO_INSTALLER_SHA256:-}" ]; then
67-
run_command "echo \"$KIRO_INSTALLER_SHA256 $KIRO_INSTALLER_PATH\" | sha256sum -c -"
68-
elif [ "${KIRO_SKIP_KIRO_INSTALLER_VERIFY:-0}" = "1" ]; then
69-
echo -e "\033[0;33m[WARN] KIRO_INSTALLER_SHA256 is not set; proceeding without installer checksum verification.\033[0m" >&2
70-
echo -e "\033[0;33m[WARN] Set KIRO_INSTALLER_SHA256 to enforce verification, or intentionally override with KIRO_SKIP_KIRO_INSTALLER_VERIFY=1.\033[0m" >&2
71-
else
72-
echo -e "\033[0;31m[ERROR] Refusing to run unverified Kiro installer.\033[0m" >&2
73-
echo -e "\033[0;31mSet KIRO_INSTALLER_SHA256 (recommended) or explicitly set KIRO_SKIP_KIRO_INSTALLER_VERIFY=1 to proceed.\033[0m" >&2
74-
exit 1
75-
fi
66+
run_command "echo \"$KIRO_INSTALLER_SHA256 $KIRO_INSTALLER_PATH\" | sha256sum -c -"
7667

7768
run_command "bash \"$KIRO_INSTALLER_PATH\""
7869

src/specify_cli/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1489,8 +1489,9 @@ def init(
14891489
if skills_ok and not here:
14901490
agent_cfg = AGENT_CONFIG.get(selected_ai, {})
14911491
agent_folder = agent_cfg.get("folder", "")
1492+
commands_subdir = agent_cfg.get("commands_subdir", "commands")
14921493
if agent_folder:
1493-
cmds_dir = project_path / agent_folder.rstrip("/") / "commands"
1494+
cmds_dir = project_path / agent_folder.rstrip("/") / commands_subdir
14941495
if cmds_dir.exists():
14951496
try:
14961497
shutil.rmtree(cmds_dir)

tests/test_agent_config_consistency.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ def test_init_ai_help_includes_roo_and_kiro_alias(self):
6262
assert "roo" in AI_ASSISTANT_HELP
6363
assert "Use 'kiro' as an alias for 'kiro-cli'." in AI_ASSISTANT_HELP
6464

65+
def test_devcontainer_kiro_installer_uses_pinned_checksum(self):
66+
"""Devcontainer installer should always verify Kiro installer via pinned SHA256."""
67+
post_create_text = (REPO_ROOT / ".devcontainer" / "post-create.sh").read_text(encoding="utf-8")
68+
69+
assert 'KIRO_INSTALLER_SHA256="7487a65cf310b7fb59b357c4b5e6e3f3259d383f4394ecedb39acf70f307cffb"' in post_create_text
70+
assert "sha256sum -c -" in post_create_text
71+
assert "KIRO_SKIP_KIRO_INSTALLER_VERIFY" not in post_create_text
72+
6573
def test_release_output_targets_kiro_prompt_dir(self):
6674
"""Packaging and release scripts should no longer emit amazonq artifacts."""
6775
sh_text = (REPO_ROOT / ".github" / "workflows" / "scripts" / "create-release-packages.sh").read_text(encoding="utf-8")

tests/test_ai_skills.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,9 @@ def _fake_extract(self, agent, project_path, **_kwargs):
465465
"""Simulate template extraction: create agent commands dir."""
466466
agent_cfg = AGENT_CONFIG.get(agent, {})
467467
agent_folder = agent_cfg.get("folder", "")
468+
commands_subdir = agent_cfg.get("commands_subdir", "commands")
468469
if agent_folder:
469-
cmds_dir = project_path / agent_folder.rstrip("/") / "commands"
470+
cmds_dir = project_path / agent_folder.rstrip("/") / commands_subdir
470471
cmds_dir.mkdir(parents=True, exist_ok=True)
471472
(cmds_dir / "speckit.specify.md").write_text("# spec")
472473

@@ -496,6 +497,30 @@ def fake_download(project_path, *args, **kwargs):
496497
cmds_dir = target / ".claude" / "commands"
497498
assert not cmds_dir.exists()
498499

500+
def test_new_project_nonstandard_commands_subdir_removed_after_skills_succeed(self, tmp_path):
501+
"""For non-standard agents, configured commands_subdir should be removed on success."""
502+
from typer.testing import CliRunner
503+
504+
runner = CliRunner()
505+
target = tmp_path / "new-kiro-proj"
506+
507+
def fake_download(project_path, *args, **kwargs):
508+
self._fake_extract("kiro-cli", project_path)
509+
510+
with patch("specify_cli.download_and_extract_template", side_effect=fake_download), \
511+
patch("specify_cli.ensure_executable_scripts"), \
512+
patch("specify_cli.ensure_constitution_from_template"), \
513+
patch("specify_cli.install_ai_skills", return_value=True) as mock_skills, \
514+
patch("specify_cli.is_git_repo", return_value=False), \
515+
patch("specify_cli.shutil.which", return_value="/usr/bin/git"):
516+
result = runner.invoke(app, ["init", str(target), "--ai", "kiro-cli", "--ai-skills", "--script", "sh", "--no-git"])
517+
518+
assert result.exit_code == 0
519+
mock_skills.assert_called_once()
520+
521+
prompts_dir = target / ".kiro" / "prompts"
522+
assert not prompts_dir.exists()
523+
499524
def test_commands_preserved_when_skills_fail(self, tmp_path):
500525
"""If skills fail, commands should NOT be removed (safety net)."""
501526
from typer.testing import CliRunner

0 commit comments

Comments
 (0)