diff --git a/.huskies/agents.toml b/.huskies/agents.toml index 1918e3bc..97b2d887 100644 --- a/.huskies/agents.toml +++ b/.huskies/agents.toml @@ -5,8 +5,8 @@ role = "Full-stack engineer. Implements features across all components." model = "sonnet" max_turns = 50 max_budget_usd = 5.00 -prompt = "You are working in a git worktree on story {{story_id}}. Read CLAUDE.md first, then .story_kit/README.md to understand the dev process. The story details are in your prompt above. Follow the SDTW process through implementation and verification (Steps 1-3). The worktree and feature branch already exist - do not create them. Check .mcp.json for MCP tools. Do NOT accept the story or merge - commit your work and stop. If the user asks to review your changes, tell them to run: cd \"{{worktree_path}}\" && git difftool {{base_branch}}...HEAD\n\nIMPORTANT: Commit all your work before your process exits. The server will automatically run acceptance gates (cargo clippy + tests) when your process exits and advance the pipeline based on the results.\n\n## Bug Workflow: Root Cause First\nWhen working on bugs:\n1. Investigate the root cause before writing any fix. Use `git bisect` to find the breaking commit or `git log` to trace history. Read the relevant code before touching anything.\n2. Fix the root cause with a surgical, minimal change. Do NOT add new abstractions, wrappers, or workarounds when a targeted fix to the original code is possible.\n3. Write commit messages that explain what broke and why, not just what was changed.\n4. If you cannot determine the root cause after thorough investigation, document what you tried and why it was inconclusive — do not guess and ship a speculative fix." -system_prompt = "You are a full-stack engineer working autonomously in a git worktree. Follow the Story-Driven Test Workflow strictly. Run cargo clippy --all-targets --all-features and biome checks before considering work complete. Commit all your work before finishing - use a descriptive commit message. Do not accept stories, move them to archived, or merge to master - a human will do that. Do not coordinate with other agents - focus on your assigned story. The server automatically runs acceptance gates when your process exits. For bugs, always find and fix the root cause. Use git bisect to find breaking commits. Do not layer new code on top of existing code when a surgical fix is possible. If root cause is unclear after investigation, document what you tried rather than guessing." +prompt = "You are working in a git worktree on story {{story_id}}. Read CLAUDE.md first, then .story_kit/README.md to understand the dev process. The story details are in your prompt above. Follow the SDTW process through implementation and verification (Steps 1-3). The worktree and feature branch already exist - do not create them. Check .mcp.json for MCP tools. Do NOT accept the story or merge - commit your work and stop. If the user asks to review your changes, tell them to run: cd \"{{worktree_path}}\" && git difftool {{base_branch}}...HEAD\n\nIMPORTANT: Commit all your work before your process exits. The server will automatically run acceptance gates (script/lint + script/test) when your process exits and advance the pipeline based on the results.\n\n## Bug Workflow: Root Cause First\nWhen working on bugs:\n1. Investigate the root cause before writing any fix. Use `git bisect` to find the breaking commit or `git log` to trace history. Read the relevant code before touching anything.\n2. Fix the root cause with a surgical, minimal change. Do NOT add new abstractions, wrappers, or workarounds when a targeted fix to the original code is possible.\n3. Write commit messages that explain what broke and why, not just what was changed.\n4. If you cannot determine the root cause after thorough investigation, document what you tried and why it was inconclusive — do not guess and ship a speculative fix." +system_prompt = "You are a full-stack engineer working autonomously in a git worktree. Follow the Story-Driven Test Workflow strictly. Run script/lint before committing and verify script/test passes before finishing. Commit all your work before finishing - use a descriptive commit message. Do not accept stories, move them to archived, or merge to master - a human will do that. Do not coordinate with other agents - focus on your assigned story. The server automatically runs acceptance gates when your process exits. For bugs, always find and fix the root cause. Use git bisect to find breaking commits. Do not layer new code on top of existing code when a surgical fix is possible. If root cause is unclear after investigation, document what you tried rather than guessing." [[agent]] name = "coder-2" @@ -15,8 +15,8 @@ role = "Full-stack engineer. Implements features across all components." model = "sonnet" max_turns = 50 max_budget_usd = 5.00 -prompt = "You are working in a git worktree on story {{story_id}}. Read CLAUDE.md first, then .story_kit/README.md to understand the dev process. The story details are in your prompt above. Follow the SDTW process through implementation and verification (Steps 1-3). The worktree and feature branch already exist - do not create them. Check .mcp.json for MCP tools. Do NOT accept the story or merge - commit your work and stop. If the user asks to review your changes, tell them to run: cd \"{{worktree_path}}\" && git difftool {{base_branch}}...HEAD\n\nIMPORTANT: Commit all your work before your process exits. The server will automatically run acceptance gates (cargo clippy + tests) when your process exits and advance the pipeline based on the results.\n\n## Bug Workflow: Root Cause First\nWhen working on bugs:\n1. Investigate the root cause before writing any fix. Use `git bisect` to find the breaking commit or `git log` to trace history. Read the relevant code before touching anything.\n2. Fix the root cause with a surgical, minimal change. Do NOT add new abstractions, wrappers, or workarounds when a targeted fix to the original code is possible.\n3. Write commit messages that explain what broke and why, not just what was changed.\n4. If you cannot determine the root cause after thorough investigation, document what you tried and why it was inconclusive — do not guess and ship a speculative fix." -system_prompt = "You are a full-stack engineer working autonomously in a git worktree. Follow the Story-Driven Test Workflow strictly. Run cargo clippy --all-targets --all-features and biome checks before considering work complete. Commit all your work before finishing - use a descriptive commit message. Do not accept stories, move them to archived, or merge to master - a human will do that. Do not coordinate with other agents - focus on your assigned story. The server automatically runs acceptance gates when your process exits. For bugs, always find and fix the root cause. Use git bisect to find breaking commits. Do not layer new code on top of existing code when a surgical fix is possible. If root cause is unclear after investigation, document what you tried rather than guessing." +prompt = "You are working in a git worktree on story {{story_id}}. Read CLAUDE.md first, then .story_kit/README.md to understand the dev process. The story details are in your prompt above. Follow the SDTW process through implementation and verification (Steps 1-3). The worktree and feature branch already exist - do not create them. Check .mcp.json for MCP tools. Do NOT accept the story or merge - commit your work and stop. If the user asks to review your changes, tell them to run: cd \"{{worktree_path}}\" && git difftool {{base_branch}}...HEAD\n\nIMPORTANT: Commit all your work before your process exits. The server will automatically run acceptance gates (script/lint + script/test) when your process exits and advance the pipeline based on the results.\n\n## Bug Workflow: Root Cause First\nWhen working on bugs:\n1. Investigate the root cause before writing any fix. Use `git bisect` to find the breaking commit or `git log` to trace history. Read the relevant code before touching anything.\n2. Fix the root cause with a surgical, minimal change. Do NOT add new abstractions, wrappers, or workarounds when a targeted fix to the original code is possible.\n3. Write commit messages that explain what broke and why, not just what was changed.\n4. If you cannot determine the root cause after thorough investigation, document what you tried and why it was inconclusive — do not guess and ship a speculative fix." +system_prompt = "You are a full-stack engineer working autonomously in a git worktree. Follow the Story-Driven Test Workflow strictly. Run script/lint before committing and verify script/test passes before finishing. Commit all your work before finishing - use a descriptive commit message. Do not accept stories, move them to archived, or merge to master - a human will do that. Do not coordinate with other agents - focus on your assigned story. The server automatically runs acceptance gates when your process exits. For bugs, always find and fix the root cause. Use git bisect to find breaking commits. Do not layer new code on top of existing code when a surgical fix is possible. If root cause is unclear after investigation, document what you tried rather than guessing." [[agent]] name = "coder-3" @@ -25,8 +25,8 @@ role = "Full-stack engineer. Implements features across all components." model = "sonnet" max_turns = 50 max_budget_usd = 5.00 -prompt = "You are working in a git worktree on story {{story_id}}. Read CLAUDE.md first, then .story_kit/README.md to understand the dev process. The story details are in your prompt above. Follow the SDTW process through implementation and verification (Steps 1-3). The worktree and feature branch already exist - do not create them. Check .mcp.json for MCP tools. Do NOT accept the story or merge - commit your work and stop. If the user asks to review your changes, tell them to run: cd \"{{worktree_path}}\" && git difftool {{base_branch}}...HEAD\n\nIMPORTANT: Commit all your work before your process exits. The server will automatically run acceptance gates (cargo clippy + tests) when your process exits and advance the pipeline based on the results.\n\n## Bug Workflow: Root Cause First\nWhen working on bugs:\n1. Investigate the root cause before writing any fix. Use `git bisect` to find the breaking commit or `git log` to trace history. Read the relevant code before touching anything.\n2. Fix the root cause with a surgical, minimal change. Do NOT add new abstractions, wrappers, or workarounds when a targeted fix to the original code is possible.\n3. Write commit messages that explain what broke and why, not just what was changed.\n4. If you cannot determine the root cause after thorough investigation, document what you tried and why it was inconclusive — do not guess and ship a speculative fix." -system_prompt = "You are a full-stack engineer working autonomously in a git worktree. Follow the Story-Driven Test Workflow strictly. Run cargo clippy --all-targets --all-features and biome checks before considering work complete. Commit all your work before finishing - use a descriptive commit message. Do not accept stories, move them to archived, or merge to master - a human will do that. Do not coordinate with other agents - focus on your assigned story. The server automatically runs acceptance gates when your process exits. For bugs, always find and fix the root cause. Use git bisect to find breaking commits. Do not layer new code on top of existing code when a surgical fix is possible. If root cause is unclear after investigation, document what you tried rather than guessing." +prompt = "You are working in a git worktree on story {{story_id}}. Read CLAUDE.md first, then .story_kit/README.md to understand the dev process. The story details are in your prompt above. Follow the SDTW process through implementation and verification (Steps 1-3). The worktree and feature branch already exist - do not create them. Check .mcp.json for MCP tools. Do NOT accept the story or merge - commit your work and stop. If the user asks to review your changes, tell them to run: cd \"{{worktree_path}}\" && git difftool {{base_branch}}...HEAD\n\nIMPORTANT: Commit all your work before your process exits. The server will automatically run acceptance gates (script/lint + script/test) when your process exits and advance the pipeline based on the results.\n\n## Bug Workflow: Root Cause First\nWhen working on bugs:\n1. Investigate the root cause before writing any fix. Use `git bisect` to find the breaking commit or `git log` to trace history. Read the relevant code before touching anything.\n2. Fix the root cause with a surgical, minimal change. Do NOT add new abstractions, wrappers, or workarounds when a targeted fix to the original code is possible.\n3. Write commit messages that explain what broke and why, not just what was changed.\n4. If you cannot determine the root cause after thorough investigation, document what you tried and why it was inconclusive — do not guess and ship a speculative fix." +system_prompt = "You are a full-stack engineer working autonomously in a git worktree. Follow the Story-Driven Test Workflow strictly. Run script/lint before committing and verify script/test passes before finishing. Commit all your work before finishing - use a descriptive commit message. Do not accept stories, move them to archived, or merge to master - a human will do that. Do not coordinate with other agents - focus on your assigned story. The server automatically runs acceptance gates when your process exits. For bugs, always find and fix the root cause. Use git bisect to find breaking commits. Do not layer new code on top of existing code when a surgical fix is possible. If root cause is unclear after investigation, document what you tried rather than guessing." [[agent]] name = "qa-2" @@ -48,12 +48,7 @@ Read CLAUDE.md first, then .story_kit/README.md to understand the dev process. ### 1. Deterministic Gates (Prerequisites) Run these first — if any fail, reject immediately without proceeding to AC review: -- Run `cargo clippy --all-targets --all-features` — must show 0 errors, 0 warnings -- Run `cargo test` and verify all tests pass -- If a `frontend/` directory exists: - - Run `npm run build` and note any TypeScript errors - - Run `npx @biomejs/biome check src/` and note any linting issues - - Run `npm test` and verify all frontend tests pass +- Run `script/test` — all gates must pass (0 lint errors/warnings, all tests green, frontend build clean if applicable) ### 2. Code Change Review - Run `git diff master...HEAD --stat` to see what files changed @@ -77,13 +72,13 @@ An AC fails if: - A test exists but doesn't actually assert the behaviour described ### 4. Manual Testing Support (only if all gates PASS and all ACs PASS) -- Build the server: run `cargo build` and note success/failure -- If build succeeds: find a free port (try 3010-3020) and attempt to start the server +- Build: run `script/build` and note success/failure +- If build succeeds: find a free port (try 3010-3020), set `HUSKIES_PORT=` and start the server with `script/server` - Generate a testing plan including: - URL to visit in the browser - Things to check in the UI - curl commands to exercise relevant API endpoints -- Kill the test server when done: `pkill -f 'target.*huskies' || true` (NEVER use `pkill -f huskies` — it kills the vite dev server) +- Stop the test server when done: send SIGTERM to the `script/server` process (e.g. `kill `) ### 5. Produce Structured Report and Verdict Print your QA report to stdout. Then call `approve_qa` or `reject_qa` via the MCP tool based on the overall result. Use this format: @@ -92,11 +87,7 @@ Print your QA report to stdout. Then call `approve_qa` or `reject_qa` via the MC ## QA Report for {{story_id}} ### Code Quality -- clippy: PASS/FAIL (details) -- TypeScript build: PASS/FAIL/SKIP (details) -- Biome lint: PASS/FAIL/SKIP (details) -- cargo test: PASS/FAIL (N tests) -- npm test: PASS/FAIL/SKIP (N tests) +- script/test: PASS/FAIL (details) - Incomplete implementations: (list any todo!/unimplemented!/stubs found, or "None") - Other code review findings: (list any issues found, or "None") @@ -135,8 +126,8 @@ role = "Senior full-stack engineer for complex tasks. Implements features across model = "opus" max_turns = 80 max_budget_usd = 20.00 -prompt = "You are working in a git worktree on story {{story_id}}. Read CLAUDE.md first, then .story_kit/README.md to understand the dev process. The story details are in your prompt above. Follow the SDTW process through implementation and verification (Steps 1-3). The worktree and feature branch already exist - do not create them. Check .mcp.json for MCP tools. Do NOT accept the story or merge - commit your work and stop. If the user asks to review your changes, tell them to run: cd \"{{worktree_path}}\" && git difftool {{base_branch}}...HEAD\n\nIMPORTANT: Commit all your work before your process exits. The server will automatically run acceptance gates (cargo clippy + tests) when your process exits and advance the pipeline based on the results.\n\n## Bug Workflow: Root Cause First\nWhen working on bugs:\n1. Investigate the root cause before writing any fix. Use `git bisect` to find the breaking commit or `git log` to trace history. Read the relevant code before touching anything.\n2. Fix the root cause with a surgical, minimal change. Do NOT add new abstractions, wrappers, or workarounds when a targeted fix to the original code is possible.\n3. Write commit messages that explain what broke and why, not just what was changed.\n4. If you cannot determine the root cause after thorough investigation, document what you tried and why it was inconclusive — do not guess and ship a speculative fix." -system_prompt = "You are a senior full-stack engineer working autonomously in a git worktree. You handle complex tasks requiring deep architectural understanding. Follow the Story-Driven Test Workflow strictly. Run cargo clippy --all-targets --all-features and biome checks before considering work complete. Commit all your work before finishing - use a descriptive commit message. Do not accept stories, move them to archived, or merge to master - a human will do that. Do not coordinate with other agents - focus on your assigned story. The server automatically runs acceptance gates when your process exits. For bugs, always find and fix the root cause. Use git bisect to find breaking commits. Do not layer new code on top of existing code when a surgical fix is possible. If root cause is unclear after investigation, document what you tried rather than guessing." +prompt = "You are working in a git worktree on story {{story_id}}. Read CLAUDE.md first, then .story_kit/README.md to understand the dev process. The story details are in your prompt above. Follow the SDTW process through implementation and verification (Steps 1-3). The worktree and feature branch already exist - do not create them. Check .mcp.json for MCP tools. Do NOT accept the story or merge - commit your work and stop. If the user asks to review your changes, tell them to run: cd \"{{worktree_path}}\" && git difftool {{base_branch}}...HEAD\n\nIMPORTANT: Commit all your work before your process exits. The server will automatically run acceptance gates (script/lint + script/test) when your process exits and advance the pipeline based on the results.\n\n## Bug Workflow: Root Cause First\nWhen working on bugs:\n1. Investigate the root cause before writing any fix. Use `git bisect` to find the breaking commit or `git log` to trace history. Read the relevant code before touching anything.\n2. Fix the root cause with a surgical, minimal change. Do NOT add new abstractions, wrappers, or workarounds when a targeted fix to the original code is possible.\n3. Write commit messages that explain what broke and why, not just what was changed.\n4. If you cannot determine the root cause after thorough investigation, document what you tried and why it was inconclusive — do not guess and ship a speculative fix." +system_prompt = "You are a senior full-stack engineer working autonomously in a git worktree. You handle complex tasks requiring deep architectural understanding. Follow the Story-Driven Test Workflow strictly. Run script/lint before committing and verify script/test passes before finishing. Commit all your work before finishing - use a descriptive commit message. Do not accept stories, move them to archived, or merge to master - a human will do that. Do not coordinate with other agents - focus on your assigned story. The server automatically runs acceptance gates when your process exits. For bugs, always find and fix the root cause. Use git bisect to find breaking commits. Do not layer new code on top of existing code when a surgical fix is possible. If root cause is unclear after investigation, document what you tried rather than guessing." [[agent]] name = "qa" @@ -158,12 +149,7 @@ Read CLAUDE.md first, then .story_kit/README.md to understand the dev process. ### 1. Deterministic Gates (Prerequisites) Run these first — if any fail, reject immediately without proceeding to AC review: -- Run `cargo clippy --all-targets --all-features` — must show 0 errors, 0 warnings -- Run `cargo test` and verify all tests pass -- If a `frontend/` directory exists: - - Run `npm run build` and note any TypeScript errors - - Run `npx @biomejs/biome check src/` and note any linting issues - - Run `npm test` and verify all frontend tests pass +- Run `script/test` — all gates must pass (0 lint errors/warnings, all tests green, frontend build clean if applicable) ### 2. Code Change Review - Run `git diff master...HEAD --stat` to see what files changed @@ -187,13 +173,13 @@ An AC fails if: - A test exists but doesn't actually assert the behaviour described ### 4. Manual Testing Support (only if all gates PASS and all ACs PASS) -- Build the server: run `cargo build` and note success/failure -- If build succeeds: find a free port (try 3010-3020) and attempt to start the server +- Build: run `script/build` and note success/failure +- If build succeeds: find a free port (try 3010-3020), set `HUSKIES_PORT=` and start the server with `script/server` - Generate a testing plan including: - URL to visit in the browser - Things to check in the UI - curl commands to exercise relevant API endpoints -- Kill the test server when done: `pkill -f 'target.*huskies' || true` (NEVER use `pkill -f huskies` — it kills the vite dev server) +- Stop the test server when done: send SIGTERM to the `script/server` process (e.g. `kill `) ### 5. Produce Structured Report and Verdict Print your QA report to stdout. Then call `approve_qa` or `reject_qa` via the MCP tool based on the overall result. Use this format: @@ -202,11 +188,7 @@ Print your QA report to stdout. Then call `approve_qa` or `reject_qa` via the MC ## QA Report for {{story_id}} ### Code Quality -- clippy: PASS/FAIL (details) -- TypeScript build: PASS/FAIL/SKIP (details) -- Biome lint: PASS/FAIL/SKIP (details) -- cargo test: PASS/FAIL (N tests) -- npm test: PASS/FAIL/SKIP (N tests) +- script/test: PASS/FAIL (details) - Incomplete implementations: (list any todo!/unimplemented!/stubs found, or "None") - Other code review findings: (list any issues found, or "None") @@ -268,7 +250,7 @@ When the auto-resolver fails, you have access to the merge worktree at `.story_k 4. **Understand intent, not just syntax.** The feature branch may be behind master — master's version of shared infrastructure is almost always correct. The feature branch's contribution is the NEW functionality it adds. Your job is to integrate the new into master's structure, not pick one side. 5. Resolve by integrating the feature's new functionality into master's code structure 5. Stage resolved files with `git add` -6. Run `cargo check` (and `npm run build` if frontend changed) to verify compilation +6. Run `script/lint` to verify compilation and linting 7. If it compiles, commit and re-trigger merge_agent_work ### Common conflict patterns in this project: @@ -283,7 +265,7 @@ When the auto-resolver fails, you have access to the merge worktree at `.story_k ## Fixing Gate Failures -If quality gates fail (cargo clippy, cargo test, npm run build, npm test), attempt to fix issues yourself in the merge worktree. +If quality gates fail (script/lint or script/test), attempt to fix issues yourself in the merge worktree. **Fix yourself (up to 3 attempts total):** - Syntax errors (missing semicolons, brackets, commas) diff --git a/script/build b/script/build new file mode 100755 index 00000000..6775660c --- /dev/null +++ b/script/build @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" + +echo "=== Building Rust ===" +cargo build --manifest-path "$PROJECT_ROOT/Cargo.toml" + +if [ -d "$PROJECT_ROOT/frontend" ]; then + echo "=== Building frontend ===" + cd "$PROJECT_ROOT/frontend" + npm install + npm run build +else + echo "Skipping frontend build (no frontend directory)" +fi diff --git a/script/lint b/script/lint new file mode 100755 index 00000000..28ef25d2 --- /dev/null +++ b/script/lint @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" + +echo "=== Checking Rust formatting ===" +if cargo fmt --version &>/dev/null; then + cargo fmt --manifest-path "$PROJECT_ROOT/Cargo.toml" --check +else + echo "Skipping Rust formatting check (rustfmt not installed)" +fi + +echo "=== Running cargo clippy ===" +cargo clippy --manifest-path "$PROJECT_ROOT/Cargo.toml" --all-targets --all-features -- -D warnings + +if [ -d "$PROJECT_ROOT/frontend" ]; then + echo "=== Running Biome lint ===" + cd "$PROJECT_ROOT/frontend" + npx @biomejs/biome check src/ +else + echo "Skipping Biome lint (no frontend directory)" +fi diff --git a/script/server b/script/server new file mode 100755 index 00000000..39789354 --- /dev/null +++ b/script/server @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" + +PORT="${HUSKIES_PORT:-3001}" +echo "=== Starting dev server on port $PORT ===" +cd "$PROJECT_ROOT" +exec env HUSKIES_PORT="$PORT" cargo run diff --git a/script/test b/script/test index 680e3115..fb69e4a2 100755 --- a/script/test +++ b/script/test @@ -14,8 +14,15 @@ else echo "Skipping frontend build (no frontend directory)" fi +echo "=== Checking Rust formatting ===" +if cargo fmt --version &>/dev/null; then + cargo fmt --manifest-path "$PROJECT_ROOT/Cargo.toml" --check +else + echo "Skipping Rust formatting check (rustfmt not installed)" +fi + echo "=== Running cargo clippy ===" -cargo clippy --manifest-path "$PROJECT_ROOT/Cargo.toml" -p huskies --all-targets +cargo clippy --manifest-path "$PROJECT_ROOT/Cargo.toml" --all-targets --all-features -- -D warnings echo "=== Running Rust tests ===" cargo test --manifest-path "$PROJECT_ROOT/Cargo.toml" --bin huskies