- Extend `WatcherEvent` to an enum with `WorkItem` and `ConfigChanged` variants
so the watcher can distinguish between pipeline-file changes and config changes
- Watch `.story_kit/project.toml` at the project root (ignoring worktree copies)
and broadcast `WatcherEvent::ConfigChanged` on modification
- Forward `agent_config_changed` WebSocket message to connected clients; skip
pipeline state refresh for config-only events
- Add `is_config_file()` helper with unit tests covering root vs. worktree paths
- Accept `configVersion` prop in `AgentPanel` and re-fetch the agent roster
whenever it increments
- Increment `agentConfigVersion` in `Chat` on receipt of `agent_config_changed`
WS event via new `onAgentConfigChanged` handler in `ChatWebSocket`
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds log_buffer ring buffer and slog! macro for in-memory server log
capture, plus get_server_logs MCP tool for agents to read recent logs.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The agent pool allowed the same agent (e.g. "qa") to run concurrently
on multiple stories because start_agent() only checked whether that
story+agent combo was already active. It did not check whether the
agent was busy on a different story.
Two concurrent QA runs each spawn cargo clippy + cargo test + vitest,
causing extreme CPU load (load average >33 on M1 Mac).
Fix: before registering a new agent as Pending, scan all active entries
for any Running or Pending entry with the same agent_name. If one is
found, return an error explaining that the story will be picked up when
the agent becomes available.
The existing auto_assign_available_work() mechanism already scans
pipeline directories (3_qa/, 4_merge/, etc.) for unassigned stories
and uses find_free_agent_for_stage() — which respects single-instance
limits — to assign work when an agent slot opens up. So the queuing
behaviour is naturally provided: the story stays in its directory,
and auto-assign picks it up when the previous run completes.
Adds two regression tests:
- start_agent_rejects_when_same_agent_already_running_on_another_story
- start_agent_allows_new_story_when_previous_run_is_completed
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add log_buffer module: bounded 1000-line ring buffer with push/get_recent API
- Add slog! macro: drop-in for eprintln! that also captures to ring buffer
- Replace all eprintln! calls across agents, watcher, search, chat, worktree, claude_code with slog!
- Add get_server_logs MCP tool: accepts count (1-500) and optional filter params
- 5 unit tests for log_buffer covering push/retrieve, eviction, filtering, count limits, empty buffer
- 262 tests passing, clippy clean
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The --directory flag does not exist in Claude Code CLI. It was added in
c169cfc but caused every agent spawn to exit immediately with "unknown
option", resulting in Session: None errors. The process cwd (set via
cmd.cwd()) already correctly pins agents to the worktree directory.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The test_plan field was a gate from the old interactive web UI workflow
where a human would approve a test plan before the LLM could write code.
With autonomous coder agents, this gate is dead weight — coders sometimes
obey the README's "wait for approval" instruction and produce no code.
Removes: TestPlanStatus enum, ensure_test_plan_approved checks in fs/shell,
set_test_plan MCP tool + handler, test_plan from story/bug front matter
creation, test_plan validation in validate_story_dirs, and all related tests.
Updates README to remove Step 2 (Test Planning) and renumber steps.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The worktree doesn't have .story_kit/work/ so agents had no access to
the story requirements. Read the story file from the project root and
prepend it to the prompt. Without this, coders would start, read
CLAUDE.md, have nothing to implement, and exit with no code.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude Code resolves its project root by walking up from cwd looking
for .git. In worktrees, .git is a file pointing back to the main
checkout, so Claude Code would resolve the main repo as its project
and write files there instead of in the worktree. Adding --directory
explicitly pins it to the worktree path.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
model = "sonnet-4.6" is not a valid Claude CLI model identifier,
causing all coder/qa/mergemaster agents to get 404 errors from the
API and exit immediately with no work done. Change to
"claude-sonnet-4-6". Also disable automatic worktree cleanup on
archive so agent work can be inspected post-mortem.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Both sparse checkout and skip-worktree leak state from worktrees back
to the main checkout's config/index, corrupting the working tree.
Disable the isolation for now — merge conflicts from pipeline file
moves will be handled at merge time by the mergemaster instead.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sparse checkout (both manual config and git sparse-checkout set) kept
leaking config to the main checkout, hiding .story_kit/work/ and
breaking the IDE. Replace with git update-index --skip-worktree which
marks work files as unchanged without removing them from the worktree.
Files are present (builds work), but changes are invisible to git
(no merge conflicts).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace manual git config + file write + read-tree with
`git sparse-checkout set --no-cone` which correctly isolates
sparse checkout config to the worktree without polluting the
shared .git/config.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use extensions.worktreeConfig + --worktree flag so core.sparseCheckout
is set per-worktree only, preventing the main checkout from losing its
.story_kit/work/ directory.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Configures sparse checkout on new and existing worktrees to exclude
the pipeline state directory. This prevents feature branches from
containing .story_kit/work/ file moves that cause rename/delete merge
conflicts when merging back to master.
Also removes "pick up the story from .story_kit/work/" instruction
from agent prompts since the story content is already in the prompt.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Keep master's quiet system/rate_limit_event handlers while preserving
the story-62 permission_request handler (the core feature).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When Claude Code requires user approval before executing a tool (file
writes, commits, etc.) the agent sends a permission_request message
over the WebSocket. The web UI now intercepts that message, surfaces a
modal dialog showing the tool name and input, and lets the user approve
or deny. The decision is sent back as a permission_response, allowing
the agent to continue or adjust its approach.
Backend changes:
- claude_code.rs: parse "permission_request" NDJSON events from the PTY,
block the PTY thread via a sync channel, and write the user's decision
back to the PTY stdin as a JSON permission_response.
- chat.rs: thread an optional UnboundedSender<PermissionReqMsg> through
to the provider.
- ws.rs: create a permission-request channel, forward requests to the
client, collect responses via a pending-perms map, and interleave all
of this with the active chat session using tokio::select!.
Frontend changes:
- client.ts: add permission_request to WsResponse, permission_response
to WsRequest, onPermissionRequest handler to ChatWebSocket.connect(),
and sendPermissionResponse() method.
- types.ts: mirror the same type additions.
- Chat.tsx: add permissionRequest state, wire onPermissionRequest
callback, and render an approval modal with tool name, input context,
Approve and Deny buttons.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When an agent process exits normally, the server now automatically runs
acceptance gates (uncommitted changes check + cargo clippy + tests) and
advances the pipeline based on results. This replaces the previous model
where agents had to explicitly call report_completion as an MCP tool.
Changes:
- Add run_server_owned_completion() free function in agents.rs that runs
gates on process exit, stores a CompletionReport, and advances pipeline
- Wire it into start_agent's spawned task (replaces simple status setting)
- Remove report_completion from MCP tools list and handler (mcp.rs)
- Update default_agent_prompt() to not reference report_completion
- Update all agent prompts in project.toml (supervisor, coders, qa,
mergemaster) to reflect server-owned completion
- Add guard: skip gates if completion was already recorded (legacy path)
- Add 4 new tests for server-owned completion behavior
- Update tools_list test (26 tools, report_completion excluded)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>