Commit Graph

79 Commits

Author SHA1 Message Date
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
Dave
1487092216 Refactored a few things from main into modules 2026-02-23 11:39:22 +00:00
Dave
7deacabea9 Fixed up dependencies warning. 2026-02-23 11:23:08 +00:00
Dave
810608d3d8 Spike 61: filesystem watcher and UI simplification
Add notify-based filesystem watcher for .story_kit/work/ that
auto-commits changes with deterministic messages and broadcasts
events over WebSocket. Push full pipeline state (Upcoming, Current,
QA, To Merge) to frontend on connect and after every watcher event.

Strip dead UI: remove ReviewPanel, GatePanel, TodoPanel,
UpcomingPanel and all associated REST polling. Replace with 4
generic StagePanel components driven by WebSocket. Simplify
AgentPanel to roster-only.

Delete all 11 workflow HTTP endpoints and 16 request/response types
from the server. Clean dead code from workflow module. MCP tools
call Rust functions directly and need none of the HTTP layer.

Net: ~4,100 lines deleted, ~400 added.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 19:39:19 +00:00
Dave
122f481ab9 Story 53: Add QA agent role with request_qa MCP tool
- Add `qa` agent entry to `.story_kit/project.toml` with a detailed
  prompt covering code quality scan, test verification, manual testing
  support, and structured report generation
- Add `move_story_to_qa` function in `agents.rs` that moves a work item
  from `work/2_current/` to `work/3_qa/` and auto-commits (idempotent)
- Add `request_qa` MCP tool in `mcp.rs` that moves the story to
  `work/3_qa/` and starts the QA agent on the existing worktree
- Add unit tests for `move_story_to_qa` (moves, idempotent, error cases)
- Update `tools_list_returns_all_tools` test to expect 27 tools

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 17:45:43 +00:00
Dave
9dab18d597 Story 52: Mergemaster agent role with merge_agent_work MCP tool
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 17:36:35 +00:00
Dave
e15fbffbb8 Fix 25 tests for work/ directory restructure (story 60)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 17:24:26 +00:00
Dave
e1e0d49759 Story 60: Status-Based Directory Layout with work/ pipeline
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 17:17:12 +00:00
Dave
158550e889 Story 54: add cross-platform binary distribution support
- Add Makefile with build-macos and build-linux targets
  - build-macos: cargo build --release (native macOS binary)
  - build-linux: cross build --release --target x86_64-unknown-linux-musl
    (produces a fully static binary via Docker/cross; zero dynamic deps)
- Document cross-platform build process in README.md including
  how to verify macOS dynamic deps (otool -L) and Linux static
  linking (file + ldd)
- reqwest 0.13 already uses rustls by default (no OpenSSL); verified
  in Cargo.lock – no Cargo.toml changes needed
- Add unit tests to http/assets.rs covering:
  - SPA fallback routing for non-asset paths
  - 404 for missing assets/ paths
  - Panic-free behaviour on empty path
  - rust-embed EmbeddedAssets iter compiles and runs correctly

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 17:15:28 +00:00
Dave
2d28304a41 Story 49: Deterministic Bug Lifecycle Management
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 16:41:04 +00:00
Dave
7f672cae5f Story 50: Unified Current Work Directory
- Move current/ to .story_kit/current/ (out of stories/)
- Type-aware routing for bugs, spikes, stories
- close_bug_to_archive() for bug lifecycle
- All path references updated across agents.rs, workflow.rs, mcp.rs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 16:25:08 +00:00
Dave
01e7d67f1f Fix bug 5: truncate coverage error output to last 5 lines
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 15:45:56 +00:00
Dave
928cc64bfa Story 46: Deterministic Story Mutations with Auto-Commit
- Add git_stage_and_commit() helper for deterministic commits
- move_story_to_current() auto-commits on start_agent
- accept_story auto-commits move to archived/
- New MCP tools: check_criterion, set_test_plan (total: 21)
- create_story MCP always auto-commits
- Tests for check_criterion and set_test_plan

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 15:34:41 +00:00
Dave
5c164f4855 Accept story 45: Deterministic Story Lifecycle Management
- accept_story MCP tool moves current/ to archived/
- move_story_to_archived helper with idempotent behavior
- start_agent auto-moves upcoming/ to current/

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 15:09:39 +00:00
Dave
1b71449dd0 Story 44: Agent Completion Report via MCP
- report_completion MCP tool for agents to signal done
- Rejects if worktree has uncommitted changes
- Runs acceptance gates (clippy, tests) automatically
- Stores completion status on agent record
- 10 new tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 15:02:34 +00:00
Dave
ed5f34b776 Story 37: Editor Command for Worktrees
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 14:49:36 +00:00
Dave
44bc82d23a Story 43: Unified chat UI for Claude Code and regular chat
Integrate Claude Code provider into the chat UI alongside regular
Ollama/Anthropic providers. Updates AgentPanel and Chat components.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 14:26:40 +00:00
Dave
a9d45bbcd5 Story 42: Deterministic worktree management via REST/MCP API
Add REST and MCP endpoints for creating, listing, and removing worktrees.
Includes worktree lifecycle management and cleanup operations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 14:22:09 +00:00
Dave
91534b4a59 Accept story 38: Auto-Open Project on Server Startup
Server detects .story_kit/ in cwd or parent directories at startup and
automatically opens the project. MCP tools work immediately without
manual project-open step. Falls back to cwd when no .story_kit/ found.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 14:11:53 +00:00
Dave
a3c20eb4d4 Accept story 40: MCP Server Obeys STORYKIT_PORT
Agent worktrees now get a .mcp.json written with the correct port from
the running server. AgentPool receives the port at construction and
passes it through to create_worktree, which writes .mcp.json on both
new creation and reuse.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 13:24:35 +00:00
Dave
1eae2410f3 Fix bugs 2 and 3: agent panel expand and stale worktree references
Bug 2: Expand triangle now works when no agents are started - shows
"No agents started" message. AgentPanel moved to top of panels.

Bug 3: Run `git worktree prune` before `git worktree add` to clean
stale references from externally-deleted worktree directories.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 13:17:20 +00:00
Dave
c6a04f5e53 Accept story 41: Agent Completion Notification via MCP
Add wait_for_agent MCP tool that blocks until an agent reaches a terminal
state (completed, failed, stopped). Returns final status with session_id,
worktree_path, and git commits made by the agent.

- Subscribe-before-check pattern avoids race conditions
- Handles lagged receivers, channel closure, and configurable timeout
- Default timeout 5 minutes, includes git log of agent commits in response
- 11 new tests covering all paths

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 13:16:04 +00:00
Dave
39b67ff754 Story 33: Copy-paste diff commands for agent worktrees
- Add base_branch detection to WorktreeInfo (from project root HEAD)
- Expose base_branch in AgentInfo API response
- Add {{base_branch}} template variable to agent config rendering
- Show git difftool command with copy-to-clipboard in AgentPanel UI
- Add diff command instruction to coder agent prompts
- Add AgentPanel tests for diff command rendering and clipboard

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 12:48:50 +00:00
Dave
db2d055f60 Spike 3: Sub-agent infrastructure fixes for multi-agent coordination
- Fix CLAUDECODE env var blocking nested Claude Code sessions
- Add drain-based event_log for reliable get_agent_output polling
- Add non-SSE get_agent_output fallback (critical for MCP tool calls)
- Preserve worktrees on agent stop instead of destroying work
- Reap zombie processes with child.wait() after kill
- Increase broadcast buffer from 256 to 1024
- Engineer supervisor and coder prompts in project.toml
- Point .mcp.json to test port 3002

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 12:14:36 +00:00
Dave
cde75bd7fb Accept story 39: Persistent Claude Code Sessions in Web UI
Use --resume <session_id> with claude -p so the web UI claude-code-pty
provider maintains full conversation context across messages, identical
to a long-running terminal Claude Code session.

Changes:
- Capture session_id from claude -p stream-json system event
- Pass --resume on subsequent messages in same chat session
- Thread session_id through ProviderConfig, ChatResult, WsResponse
- Frontend stores sessionId per chat, clears on New Session
- Unset CLAUDECODE env to allow nested spawning from server
- Wait for clean process exit to ensure transcript flush to disk

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 11:51:19 +00:00
Dave
45f1234a06 Accept spike 2: MCP HTTP endpoint for workflow and agent tools
Adds POST /mcp endpoint speaking MCP Streamable HTTP (JSON-RPC 2.0)
with 12 tools for workflow management and agent orchestration.
Supports both JSON and SSE response modes. Includes real-time agent
output streaming over SSE, Content-Type validation, and 15 integration
tests (134 total).

Tools: create_story, validate_stories, list_upcoming, get_story_todos,
record_tests, ensure_acceptance, start_agent, stop_agent, list_agents,
get_agent_config, reload_agent_config, get_agent_output.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 19:34:03 +00:00
Dave
6d57b06636 Accept story 34: Per-Project Agent Configuration and Role Definitions
Replace single [agent] config with multi-agent [[agent]] roster system.
Each agent has name, role, model, allowed_tools, max_turns, max_budget_usd,
and system_prompt fields that map to Claude CLI flags at spawn time.

- AgentConfig expanded with structured fields, validated at startup (panics
  on duplicate names, empty names, non-positive budgets/turns)
- Backwards-compatible: legacy [agent] format auto-wraps with deprecation warning
- AgentPool uses composite "story_id:agent_name" keys for concurrent agents
- agent_name added to AgentEvent variants, AgentInfo, start/stop/subscribe APIs
- GET /agents/config returns roster, POST /agents/config/reload hot-reloads
- POST /agents/start accepts optional agent_name, /agents/stop requires it
- SSE route updated to /agents/:story_id/:agent_name/stream
- Frontend: roster badges, agent selector dropdown, composite-key state
- Project root initialized to cwd at startup so config endpoints work immediately

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 18:46:14 +00:00