feat(story-200): auto-prune worktrees when stories are archived

- Add `prune_worktree_sync` to worktree.rs: removes a story's worktree
  if it exists, delegating to `remove_worktree_sync` (best-effort,
  failures logged internally)
- Update `sweep_done_to_archived` to accept `git_root` and call
  `prune_worktree_sync` after promoting a story from 5_done to 6_archived
- Add Part 2 to the sweep: scan 6_archived and prune any stale worktrees
  for stories already there (catches items archived before this feature)
- All worktree removal failures are logged but never block file moves
- Add 5 new tests: prune noop, prune real worktree, sweep-on-promote,
  sweep-stale-archived, sweep-not-blocked-by-removal-failure

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Dave
2026-02-26 14:58:52 +00:00
parent 4e535dff18
commit 40d96008c9
11 changed files with 252 additions and 48 deletions

View File

@@ -1,31 +0,0 @@
---
name: "Project scaffold does not write .mcp.json to project root"
---
# Bug 208: Project scaffold does not write .mcp.json to project root
## Description
When a new project is opened/scaffolded, `.mcp.json` is not written to the project root. The `write_mcp_json()` function (worktree.rs:6) is only called during worktree creation, not during `scaffold_story_kit()` (io/fs.rs:464) or `open_project()` (io/fs.rs:503). This means claude-pty spawned with `--permission-prompt-tool mcp__story-kit__prompt_permission` immediately fails because the MCP tool isn't available.
Additionally, there is no way for the user to trigger scaffolding from the CLI — `find_story_kit_root()` in main.rs falls through without scaffolding if `.story_kit/` doesn't exist yet, so the only path is via the UI file chooser.
## How to Reproduce
1. Create an empty directory or navigate to a project without `.story_kit/`
2. Run `story-kit-server`
3. Open the project via the UI file chooser
4. Try to chat using the claude-code provider
## Actual Result
Claude Code exits immediately with: `Error: MCP tool mcp__story-kit__prompt_permission (passed via --permission-prompt-tool) not found. Available MCP tools: none`
## Expected Result
`.mcp.json` is written to the project root during scaffolding/open, so claude-code can connect to the story-kit MCP server.
## Acceptance Criteria
- [ ] write_mcp_json() is called as part of open_project() or scaffold_story_kit() to write .mcp.json to the project root
- [ ] claude-code provider works on first use in a newly scaffolded project

View File

@@ -1,21 +0,0 @@
---
name: "Accept optional positional path argument on startup"
---
# Story 209: Accept optional positional path argument on startup
## User Story
As a user, I want to run `story-kit-server .` or `story-kit-server /path/to/project` to start the server with that directory as the project, so that I don't have to use the UI file chooser.
## Acceptance Criteria
- [ ] Running `story-kit-server` with no args behaves as today (auto-detect from cwd)
- [ ] Running `story-kit-server .` opens the current directory as the project
- [ ] Running `story-kit-server /some/path` opens that path as the project
- [ ] If the path has no .story_kit/, it is scaffolded automatically
- [ ] Invalid paths produce a clear error message
## Out of Scope
- TBD