Commit Graph

46 Commits

Author SHA1 Message Date
Dave
38a2de472b story-kit: merge 232_story_fix_incorrect_bug_tool_descriptions_in_mcp_tools_list 2026-02-27 10:57:35 +00:00
Dave
850ca15a6c story-kit: merge 226_bug_mergemaster_accepts_stories_without_squash_merging_code 2026-02-27 10:39:45 +00:00
Dave
f8bbe1ea31 story-kit: merge 225_story_surface_merge_conflicts_and_failures_in_the_web_ui 2026-02-27 10:26:28 +00:00
Dave
eeec745abc story-219: add Always Allow button to web UI permission dialog
Cherry-pick from feature branch — code was never squash-merged
despite story being accepted (bug 226).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 10:00:33 +00:00
Dave
80904dc2d1 fix: permission-prompt-tool response format and scaffold .claude/settings.json
- Return { behavior: "allow", updatedInput: <input> } from prompt_permission
  to match the Claude Code SDK expected format (was returning just
  { behavior: "allow" } which failed validation)
- Scaffold .claude/settings.json with sensible permission defaults (Edit,
  Write, common Bash commands, mcp__story-kit__*) so fresh projects don't
  trigger constant permission prompts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 19:02:11 +00:00
Dave
d908a54fc4 story-kit: merge 180_bug_web_ui_permissions_handling_unreliable 2026-02-26 17:10:54 +00:00
Dave
ac087f1a58 chore: add MERGE-DEBUG traces for project_root lifecycle
Temporary diagnostic logging to track why project_root becomes None
during merge pipeline operations. Tagged with MERGE-DEBUG for easy
grep-and-remove once the root cause is confirmed fixed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 17:01:38 +00:00
Dave
774a731042 bug-210: prevent pipeline from moving story to done when mergemaster reports failure
The pipeline advancement logic was ignoring report_merge_failure and
blindly trusting the server-owned completion gates_passed result. Now
report_merge_failure sets a flag on the agent entry that the pipeline
checks before advancing — stories stay in 4_merge/ when merge fails.

Squash merge of feature/story-210

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-26 16:12:23 +00:00
Dave
81065a3ada fix: replace fast-forward with cherry-pick in mergemaster squash-merge
The mergemaster pipeline used git merge --ff-only to apply the squash
commit from a merge-queue branch onto master. This raced with the
filesystem watcher which auto-commits pipeline file moves to master,
causing the fast-forward to fail. The mergemaster agent would then
improvise by manually moving stories to done without the code merge.

- Replace --ff-only with cherry-pick so concurrent watcher commits
  don't block the merge
- Add report_merge_failure MCP tool for explicit failure handling
- Update mergemaster prompt to forbid manual file moves
- Fix cleanup_merge_workspace to handle stale directories

Squash merge of feature/story-205

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 14:16:35 +00:00
Dave
411653ab15 story-kit: merge 190_story_auto_select_available_agent_for_stage_in_start_agent 2026-02-25 16:17:38 +00:00
Dave
aa423cae22 story-kit: merge 177_bug_no_mcp_tool_to_edit_story_acceptance_criteria 2026-02-25 11:34:37 +00:00
Dave
073ec03afe story-kit: merge 171_story_persist_test_results_to_story_files 2026-02-25 09:50:31 +00:00
Dave
d70285adda story-kit: merge 176_bug_stories_moved_to_current_get_supervisor_instead_of_coder 2026-02-25 09:30:15 +00:00
Dave
7b3853bad0 story-kit: merge 165_bug_pipeline_log_message_says_archived_instead_of_done 2026-02-24 18:38:13 +00:00
Dave
aef022c74c story-kit: merge 151_story_split_archived_into_done_and_archived_with_time_based_promotion
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 17:01:57 +00:00
Dave
57430d73bd story-kit: merge 146_bug_permission_approval_still_returns_wrong_format_needs_updatedinput_not_behavior_allow 2026-02-24 14:06:00 +00:00
Dave
73614fe5e8 story-kit: merge 141_story_improve_server_logging_with_timestamps_and_error_visibility 2026-02-24 13:48:25 +00:00
Dave
6170a7d984 story-kit: merge 133_story_clean_up_agent_state_on_story_archive_and_add_ttl_for_completed_entries 2026-02-24 13:20:59 +00:00
Dave
c5ddd15273 story-kit: merge 132_story_fix_toctou_race_in_agent_check_and_insert 2026-02-24 12:49:29 +00:00
Dave
d6f394d28d story-kit: merge 130_bug_permission_approval_returns_wrong_format_tools_fail_after_user_approves 2026-02-24 11:51:00 +00:00
Dave
5481f65e8b story-kit: merge 129_story_test_coverage_http_mcp_rs 2026-02-24 00:30:54 +00:00
Dave
b928eace9c story-kit: merge 119_story_mergemaster_should_resolve_merge_conflicts_instead_of_leaving_conflict_markers_on_master 2026-02-23 23:22:24 +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
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
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
a25553f1bc story-kit: merge 78_story_create_spike_mcp_tool 2026-02-23 20:27:09 +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
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
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
bd2414437a story-kit: start 63_story_auto_spawn_mergemaster_on_merge 2026-02-23 12:12:20 +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
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
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
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
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
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
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