diff --git a/.story_kit/stories/upcoming/32_worktree_agent_orchestration.md b/.story_kit/stories/upcoming/32_worktree_agent_orchestration.md new file mode 100644 index 0000000..a229859 --- /dev/null +++ b/.story_kit/stories/upcoming/32_worktree_agent_orchestration.md @@ -0,0 +1,18 @@ +# Story 32: Worktree Agent Orchestration — Dynamic Port Management + +## User Story +**As a** developer running multiple agents in parallel worktrees, +**I want** each server instance to bind to a unique port automatically, +**So that** I can run multiple worktree-based agents concurrently without port conflicts. + +## Acceptance Criteria +- [ ] Server discovers an available port instead of hardcoding 3001 (e.g., try 3001, then 3002, etc., or use port 0 and report back). +- [ ] Server prints the actual bound port on startup so callers can discover it. +- [ ] Frontend dev server proxy target is configurable (env var or auto-detected from server). +- [ ] WebSocket client in the frontend reads the port dynamically rather than hardcoding it. +- [ ] Agent pool can target agents at different worktree server instances by URL. +- [ ] A simple registry or file-based mechanism lets a supervisor discover which ports map to which worktrees. + +## Out of Scope +- Service mesh or container orchestration. +- Multi-machine distributed agents (local only for now). diff --git a/.story_kit/stories/upcoming/33_worktree_diff_and_editor_integration.md b/.story_kit/stories/upcoming/33_worktree_diff_and_editor_integration.md new file mode 100644 index 0000000..ffe3029 --- /dev/null +++ b/.story_kit/stories/upcoming/33_worktree_diff_and_editor_integration.md @@ -0,0 +1,20 @@ +# Story 33: Worktree Diff Inspection and Editor Integration + +## User Story +**As a** supervisor coordinating agents across worktrees, +**I want to** view diffs of in-progress agent work and open worktrees in my editor, +**So that** I can review changes, catch problems early, and intervene when needed. + +## Acceptance Criteria +- [ ] API endpoint (or CLI command) returns `git diff` output for a given worktree path. +- [ ] API endpoint returns `git diff --stat` summary for a quick overview. +- [ ] API endpoint can return diff against the base branch (e.g., `git diff main...HEAD`). +- [ ] A "open in editor" action launches the configured editor (e.g., `zed`) pointed at a worktree directory. +- [ ] Editor preference is configurable (stored in app settings, defaults to `$EDITOR` or `zed`). +- [ ] Frontend can trigger "open in editor" for any listed worktree/agent. +- [ ] Frontend can display a diff view for any worktree with syntax-highlighted changes. + +## Out of Scope +- Full code review workflow (comments, approvals). +- Automatic merge or conflict resolution. +- Editor plugin integration (just launching the editor at the worktree path is sufficient). diff --git a/frontend/src/api/client.ts b/frontend/src/api/client.ts index 7126129..2fa846c 100644 --- a/frontend/src/api/client.ts +++ b/frontend/src/api/client.ts @@ -226,7 +226,7 @@ export class ChatWebSocket { const protocol = window.location.protocol === "https:" ? "wss" : "ws"; const wsHost = import.meta.env.DEV - ? "127.0.0.1:3002" + ? "127.0.0.1:3001" : window.location.host; const wsUrl = `${protocol}://${wsHost}${wsPath}`; diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 5f9ac08..712153d 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -5,9 +5,9 @@ import { defineConfig } from "vite"; export default defineConfig(() => ({ plugins: [react()], server: { - port: 5174, + port: 5173, proxy: { - "/api": "http://127.0.0.1:3002", + "/api": "http://127.0.0.1:3001", }, }, build: { diff --git a/server/src/http/mod.rs b/server/src/http/mod.rs index 739a2d5..10b953d 100644 --- a/server/src/http/mod.rs +++ b/server/src/http/mod.rs @@ -65,7 +65,7 @@ pub fn build_openapi_service(ctx: Arc) -> (ApiService, ApiService) { ); let api_service = - OpenApiService::new(api, "Story Kit API", "1.0").server("http://127.0.0.1:3002/api"); + OpenApiService::new(api, "Story Kit API", "1.0").server("http://127.0.0.1:3001/api"); let docs_api = ( ProjectApi { ctx: ctx.clone() }, @@ -78,7 +78,7 @@ pub fn build_openapi_service(ctx: Arc) -> (ApiService, ApiService) { ); let docs_service = - OpenApiService::new(docs_api, "Story Kit API", "1.0").server("http://127.0.0.1:3002/api"); + OpenApiService::new(docs_api, "Story Kit API", "1.0").server("http://127.0.0.1:3001/api"); (api_service, docs_service) } diff --git a/server/src/main.rs b/server/src/main.rs index 9e5782b..5dd32ce 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -38,10 +38,10 @@ async fn main() -> Result<(), std::io::Error> { println!( "\x1b[95;1m ____ _ _ ___ _ \n / ___|| |_ ___ _ __| | _|_ _| |_ \n \\___ \\| __/ _ \\| '__| |/ /| || __|\n ___) | || (_) | | | < | || |_ \n |____/ \\__\\___/|_| |_|\\_\\___|\\__|\n\x1b[0m" ); - println!("\x1b[96;1mFrontend:\x1b[0m \x1b[94mhttp://127.0.0.1:3002\x1b[0m"); - println!("\x1b[92;1mOpenAPI Docs:\x1b[0m \x1b[94mhttp://127.0.0.1:3002/docs\x1b[0m"); + println!("\x1b[96;1mFrontend:\x1b[0m \x1b[94mhttp://127.0.0.1:3001\x1b[0m"); + println!("\x1b[92;1mOpenAPI Docs:\x1b[0m \x1b[94mhttp://127.0.0.1:3001/docs\x1b[0m"); - Server::new(TcpListener::bind("127.0.0.1:3002")) + Server::new(TcpListener::bind("127.0.0.1:3001")) .run(app) .await }