Commit Graph

105 Commits

Author SHA1 Message Date
Dave
908fcef353 story-kit: merge 118_bug_agent_pool_retains_stale_running_state_after_completion_blocking_auto_assign 2026-02-23 22:53:23 +00:00
Dave
85fddcb71a story-kit: merge 117_story_show_startup_reconciliation_progress_in_ui 2026-02-23 22:50:57 +00:00
Dave
649b422338 story-kit: merge 108_story_test_coverage_http_agents_rs_to_70 2026-02-23 22:26:46 +00:00
Dave
c395edca42 story-kit: merge 107_story_test_coverage_http_assets_rs_to_85 2026-02-23 22:24:29 +00:00
Dave
5acf3b73c3 story-kit: merge 106_story_test_coverage_http_settings_rs_to_80 2026-02-23 22:21:37 +00:00
Dave
c139e03bfd story-kit: merge 105_story_test_coverage_io_shell_rs_to_95 2026-02-23 22:16:33 +00:00
Dave
9a97d33bfa story-kit: merge 104_story_test_coverage_io_search_rs_to_95 2026-02-23 22:13:03 +00:00
Dave
04bce52959 story-kit: merge 103_story_test_coverage_http_project_rs_to_80 2026-02-23 22:07:58 +00:00
Dave
28146fc259 story-kit: merge 101_story_test_coverage_http_chat_rs_to_80 2026-02-23 22:02:55 +00:00
Dave
a759a59a46 story-kit: queue 101_story_test_coverage_http_chat_rs_to_80 for merge 2026-02-23 22:00:33 +00:00
Dave
d3a29aac1a story-kit: merge 100_story_test_coverage_http_context_rs_to_100 2026-02-23 21:41:25 +00:00
Dave
3087297b88 story-kit: merge 91_bug_permissions_dialog_never_triggers_in_web_ui 2026-02-23 21:38:45 +00:00
Dave
e21c982d8b story-kit: merge 102_story_test_coverage_http_model_rs_to_80 2026-02-23 21:37:20 +00:00
Dave
6d87355577 Merge branch 'feature/story-97_bug_agent_pool_allows_multiple_instances_of_the_same_agent_to_run_concurrently' 2026-02-23 20:53:54 +00:00
Dave
a0f317292c story-kit: merge 93_story_expose_server_logs_to_agents_via_mcp
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>
2026-02-23 20:53:37 +00:00
Dave
bed46fea1b story-kit: accept 96_story_reset_agent_lozenge_to_idle_state_when_returning_to_roster 2026-02-23 20:52:06 +00:00
Dave
b09b6ce4f1 fix(agents): enforce single-instance concurrency per agent name
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>
2026-02-23 20:46:51 +00:00
Dave
8c6bd4cf74 feat(story-93): expose server logs to agents via get_server_logs MCP tool
- 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>
2026-02-23 20:38:19 +00:00
Dave
cd902ff219 story-kit: merge 94_bug_stale_agent_state_persists_after_server_restart 2026-02-23 20:38:17 +00:00
Dave
a25553f1bc story-kit: merge 78_story_create_spike_mcp_tool 2026-02-23 20:27:09 +00:00
Dave
04e7a1e854 Remove invalid --directory flag that broke agent spawning
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>
2026-02-23 19:26:37 +00:00
Dave
31037f5bf5 Remove test_plan gate from the codebase
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>
2026-02-23 19:12:05 +00:00
Dave
1539e52b19 Inject story content into agent prompts so coders know what to build
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>
2026-02-23 18:50:41 +00:00
Dave
c169cfc9fa Pass --directory flag to Claude Code agents to prevent worktree escape
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>
2026-02-23 18:43:23 +00:00
Dave
af1625a132 story-kit: merge 86_story_show_live_activity_status_instead_of_static_thinking_indicator_in_chat 2026-02-23 18:38:15 +00:00
Dave
225073649b story-kit: start 88_story_auto_assign_agents_to_available_work_on_server_startup 2026-02-23 18:20:24 +00:00
Dave
3f008b7777 Fix invalid model names and preserve worktrees for debugging
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>
2026-02-23 18:05:26 +00:00
Dave
f99d6ee287 Disable worktree isolation of .story_kit/work/ (no-op)
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>
2026-02-23 17:47:34 +00:00
Dave
b56281c6ba Replace sparse checkout with skip-worktree for pipeline isolation
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>
2026-02-23 17:41:07 +00:00
Dave
3da8e19516 Fix sparse checkout leaking to main repo by using git sparse-checkout set
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>
2026-02-23 17:34:45 +00:00
Dave
4240696489 Fix sparse checkout leaking from worktrees to main checkout
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>
2026-02-23 16:55:56 +00:00
Dave
2eb5bfb8fe Sparse checkout excludes .story_kit/work/ from agent worktrees
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>
2026-02-23 16:36:15 +00:00
Dave
d3bd26a4de story-kit: start 62_story_allow_frontend_ui_to_accept_permissions_requests 2026-02-23 16:07:24 +00:00
Dave
214ddcd7af story-kit: merge 62_story_allow_frontend_ui_to_accept_permissions_requests 2026-02-23 16:01:25 +00:00
Dave
6962e92f0c fix: resolve merge conflict in claude_code.rs
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>
2026-02-23 16:01:22 +00:00
Dave
e0bc4bdc90 feat(story-62): add permission request prompts to web UI
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>
2026-02-23 15:56:01 +00:00
Dave
8133ef2847 story-kit: queue 80_story_remove_model_apikey_and_rate_limit_notifications_from_chat_ui for merge 2026-02-23 15:36:09 +00:00
Dave
c76f0b100c story-kit: merge 79_story_agents_panel_skips_archived_work_on_startup 2026-02-23 15:31:38 +00:00
Dave
31e66d7b46 story-kit: start 70_story_server_owned_agent_completion_remove_report_completion_dependency 2026-02-23 15:14:01 +00:00
Dave
9bd266eb3f Server-owned agent completion: remove report_completion dependency
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>
2026-02-23 15:00:10 +00:00
Dave
6e9b5da458 story-kit: merge 77_bug_create_bug_file_writes_no_yaml_front_matter 2026-02-23 14:56:08 +00:00
Dave
dd5fc48fb6 story-kit: merge 71_bug_server_health_endpoint_missing 2026-02-23 14:12:15 +00:00
Dave
0d7409ac89 story-kit: start 72_bug_story_creation_does_not_quote_yaml_special_characters_in_name 2026-02-23 14:01:15 +00:00
Dave
16989a12fc story-kit: merge 69_story_test_coverage_qa_gate 2026-02-23 13:40:12 +00:00
Dave
46644a6bc9 story-kit: merge 68_story_frontend_pipeline_state_stale_after_server_restart 2026-02-23 13:33:33 +00:00
Dave
9417ada89d story-kit: start 59_story_current_work_panel 2026-02-23 13:23:35 +00:00
Dave
00b212d7e3 Server drives pipeline as state machine
On agent completion, the server automatically runs script/test and
advances stories through the pipeline: coder → qa → mergemaster →
archive. Failed gates restart the agent with failure context. Agents
no longer need to call pipeline-advancing MCP tools.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 13:13:41 +00:00
Dave
cbd0233e5e story-kit: start 65_story_standardised_script_test_entry_point_for_all_projects 2026-02-23 12:59:55 +00:00
Dave
4353320b7e Watcher ignores file changes under .story_kit/worktrees/
Prevents agent code edits in worktrees from being auto-committed
to master. Only work item file moves in .story_kit/work/ trigger
watcher commits.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 12:50:59 +00:00
Dave
bd2414437a story-kit: start 63_story_auto_spawn_mergemaster_on_merge 2026-02-23 12:12:20 +00:00