diff --git a/.claude/launch.json b/.claude/launch.json index bbcc96b..4e60b37 100644 --- a/.claude/launch.json +++ b/.claude/launch.json @@ -2,9 +2,9 @@ "version": "0.0.1", "configurations": [ { - "name": "cc-manager-v1", + "name": "cc-manager", "runtimeExecutable": "node", - "runtimeArgs": ["v1/dist/index.js", "--repo", ".", "--workers", "5", "--port", "8080"], + "runtimeArgs": ["dist/index.js", "--repo", ".", "--workers", "5", "--port", "8080"], "port": 8080 } ] diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 265b9dd..9257951 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -1,13 +1,13 @@ #!/usr/bin/env bash set -euo pipefail -# Only run checks when v1/ files are staged -if ! git diff --cached --name-only | grep -q '^v1/'; then +# Only run checks when src/ files are staged +if ! git diff --cached --name-only | grep -q '^src/'; then exit 0 fi echo "pre-commit: type checking..." -cd v1 && npx tsc --noEmit +npx tsc --noEmit echo "pre-commit: running tests..." # Clear GIT_DIR/GIT_INDEX_FILE so tests that create temp git repos work correctly diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a362ed3..064fd3c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,16 +20,16 @@ jobs: with: node-version: ${{ matrix.node-version }} cache: npm - cache-dependency-path: v1/package-lock.json + cache-dependency-path: package-lock.json - name: Install dependencies - run: cd v1 && npm ci + run: npm ci - name: Type check - run: cd v1 && npx tsc --noEmit + run: npx tsc --noEmit - name: Build - run: cd v1 && npm run build + run: npm run build - name: Test - run: cd v1 && npm test + run: npm test diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index ed1ba84..a130818 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -31,7 +31,7 @@ jobs: - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: - path: docs + path: docs/site deploy: needs: build diff --git a/v1/.npmignore b/.npmignore similarity index 100% rename from v1/.npmignore rename to .npmignore diff --git a/CLAUDE.md b/CLAUDE.md index 872a2fb..9f5d218 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -4,16 +4,16 @@ Multi-agent orchestrator that runs parallel Claude Code agents in git worktrees. Tasks submitted via REST API, monitored via SSE, agents auto-commit and merge to main. ## Architecture -- **v1/src/index.ts** — CLI entry point (Commander.js) -- **v1/src/server.ts** — Hono REST API + SSE -- **v1/src/scheduler.ts** — Task queue, priority dispatch, retry logic, stale worker recovery -- **v1/src/agent-runner.ts** — Multi-agent CLI spawning (Claude, Codex, generic), cost tracking, code review +- **src/index.ts** — CLI entry point (Commander.js) +- **src/server.ts** — Hono REST API + SSE +- **src/scheduler.ts** — Task queue, priority dispatch, retry logic, stale worker recovery +- **src/agent-runner.ts** — Multi-agent CLI spawning (Claude, Codex, generic), cost tracking, code review - Hybrid architecture: Claude Agent SDK (`claude-sdk`) for programmatic control + CLI spawning for all agents -- **v1/src/worktree-pool.ts** — Git worktree lifecycle, parallel init, merge -- **v1/src/store.ts** — SQLite persistence (better-sqlite3, WAL mode) -- **v1/src/types.ts** — Shared TypeScript types -- **v1/src/logger.ts** — Structured JSON logger -- **v1/src/web/index.html** — Dashboard (vanilla HTML/JS, dark theme) +- **src/worktree-pool.ts** — Git worktree lifecycle, parallel init, merge +- **src/store.ts** — SQLite persistence (better-sqlite3, WAL mode) +- **src/types.ts** — Shared TypeScript types +- **src/logger.ts** — Structured JSON logger +- **src/web/index.html** — Dashboard (vanilla HTML/JS, dark theme) ## Tech Stack - TypeScript 5 / Node.js ESM @@ -24,13 +24,13 @@ Multi-agent orchestrator that runs parallel Claude Code agents in git worktrees. ## Build, Test & Run ```bash -cd v1 && npx tsc && cp src/web/index.html dist/web/index.html +npx tsc && cp src/web/index.html dist/web/index.html node dist/index.js --repo /path/to/repo --workers 5 --port 8080 ``` ```bash # Run tests (217 tests across 5 suites) -cd v1 && node --import tsx --test src/__tests__/*.test.ts +node --import tsx --test src/__tests__/*.test.ts ``` ## Development Rules @@ -134,11 +134,11 @@ pending → running → success (branch merged to main) - **Technical debt** — Are we creating debt or paying it down? ## Test Files -- `v1/src/__tests__/store.test.ts` — Store CRUD, search, cleanup, errors (BDD-style) -- `v1/src/__tests__/worktree-pool.test.ts` — WorktreePool lifecycle -- `v1/src/__tests__/scheduler.test.ts` — Submit, cancel, stats, queue position -- `v1/src/__tests__/agent-runner.test.ts` — Cost estimation, code review, system prompt, CLI dispatch -- `v1/src/__tests__/server.test.ts` — API input validation (prompt, timeout, priority, tags, webhookUrl) +- `src/__tests__/store.test.ts` — Store CRUD, search, cleanup, errors (BDD-style) +- `src/__tests__/worktree-pool.test.ts` — WorktreePool lifecycle +- `src/__tests__/scheduler.test.ts` — Submit, cancel, stats, queue position +- `src/__tests__/agent-runner.test.ts` — Cost estimation, code review, system prompt, CLI dispatch +- `src/__tests__/server.test.ts` — API input validation (prompt, timeout, priority, tags, webhookUrl) ## Repository - **GitHub**: `agent-next/cc-manager` (private) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6581d00..3966b7e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,10 +11,7 @@ Thank you for your interest in contributing! This document covers everything you git clone https://github.com/agent-next/cc-manager.git cd cc-manager -# 2. Move into the main application directory -cd v1 - -# 3. Install dependencies (also sets up pre-commit hooks) +# 2. Install dependencies (also sets up pre-commit hooks) npm install # 4. Start the development server @@ -27,39 +24,13 @@ npm run dev ## Project Structure -``` -cc-manager/ -├── v1/ # Main TypeScript/Node.js application -│ ├── src/ -│ │ ├── index.ts # CLI entry point — parses options and wires up core components -│ │ ├── scheduler.ts # Task queue and worker orchestration (FIFO, priority levels) -│ │ ├── agent-runner.ts # Multi-agent spawning (SDK + CLI), cost tracking, code review -│ │ ├── worktree-pool.ts # Git worktree lifecycle — creates, resets, and merges worktrees -│ │ ├── server.ts # Hono REST API + Server-Sent Events endpoint -│ │ ├── store.ts # SQLite persistence via better-sqlite3 (WAL mode) -│ │ ├── types.ts # Shared TypeScript interfaces (Task, Worker, Stats, Config) -│ │ ├── logger.ts # Lightweight logging utility -│ │ └── web/ -│ │ └── index.html # Web dashboard — real-time task monitoring UI (no frameworks) -│ ├── tsconfig.json # TypeScript compiler configuration -│ └── package.json # Dependencies and npm scripts -├── .githooks/ # Git hooks (pre-commit: tsc + tests) -├── .github/workflows/ # CI/CD (GitHub Actions) -├── docs/ # Design documents, API reference, planning notes -├── README.md # Quick-start guide and API reference -├── CLAUDE.md # Development rules injected into agent system prompts -├── CHANGELOG.md # Release notes -└── CONTRIBUTING.md # This file -``` +See [ARCHITECTURE.md](ARCHITECTURE.md) for the full module dependency graph. --- ## Running Tests ```bash -# From the v1/ directory -cd v1 - # Run all tests (71 BDD-style tests across 5 suites) npm test @@ -99,7 +70,7 @@ Pre-commit hooks run both `tsc` and `npm test` automatically. All type errors an ## Code Style -- **Language:** All application code is written in **TypeScript**. Do not add plain `.js` source files under `v1/src/`. +- **Language:** All application code is written in **TypeScript**. Do not add plain `.js` source files under `src/`. - **Imports:** Always use `.js` extensions in import paths, even when importing `.ts` files: ```ts // correct diff --git a/README.md b/README.md index 535f500..4bb6558 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ A multi-agent orchestrator that runs parallel coding agents in git worktrees. Su ## Documentation - GitHub Pages: -- Docs home (in repo): [docs/index.html](docs/index.html) +- Docs home (in repo): [docs/site/index.html](docs/site/index.html) - Getting started: [docs/GETTING_STARTED.md](docs/GETTING_STARTED.md) - Operations guide: [docs/OPERATIONS.md](docs/OPERATIONS.md) - Configuration reference: [docs/CONFIGURATION.md](docs/CONFIGURATION.md) @@ -83,8 +83,6 @@ yarn global add cc-manager Or run from source (no global install): ```bash -cd v1 - # npm npm install && npm run build @@ -139,64 +137,9 @@ curl -X POST http://localhost:8080/api/tasks \ ## API -### Task Management - -| Method | Endpoint | Description | -|--------|----------|-------------| -| `POST` | `/api/tasks` | Submit a task | -| `POST` | `/api/tasks/batch` | Submit multiple tasks | -| `GET` | `/api/tasks` | List tasks (`?status`, `?limit`, `?offset`, `?tag`) | -| `GET` | `/api/tasks/search?q=keyword` | Search tasks by prompt/output | -| `GET` | `/api/tasks/errors` | Recent failures | -| `GET` | `/api/tasks/:id` | Full task detail with queue position | -| `GET` | `/api/tasks/:id/diff` | Git diff for completed task | -| `GET` | `/api/tasks/:id/output` | Raw task output | -| `POST` | `/api/tasks/:id/retry` | Requeue a failed task | -| `DELETE` | `/api/tasks/:id` | Cancel a pending task | -| `DELETE` | `/api/tasks/cleanup?days=30` | Remove old completed tasks | - -### Monitoring - -| Method | Endpoint | Description | -|--------|----------|-------------| -| `GET` | `/api/stats` | Queue depth, workers, cost breakdown | -| `GET` | `/api/stats/daily` | Daily stats (total, success, cost) | -| `GET` | `/api/workers` | Worker pool status | -| `GET` | `/api/events` | SSE stream | -| `GET` | `/api/health` | Health check | -| `GET` | `/api/budget` | Budget status and remaining spend | -| `GET` | `/api/insights` | Historical performance metrics | - -### Self-Evolution - -| Method | Endpoint | Description | -|--------|----------|-------------| -| `GET` | `/api/evolution/log` | Evolution analysis history | -| `POST` | `/api/evolution/analyze` | Trigger round analysis | -| `GET` | `/api/docs` | API documentation | - -### POST /api/tasks body - -```json -{ - "prompt": "Refactor the auth module to use JWT", - "timeout": 300, - "maxBudget": 5, - "priority": "high", - "tags": ["auth", "refactor"], - "agent": "claude", - "webhookUrl": "https://example.com/hook" -} -``` - -### SSE events on GET /api/events +See [docs/API.md](docs/API.md) for the complete API reference with request/response examples. -| Event | When | -|-------|------| -| `task_queued` | Task accepted into queue | -| `task_started` | Worker assigned, agent running | -| `task_progress` | Agent output streaming | -| `task_final` | Completed (success/failed/timeout) | +Quick overview: 20+ REST endpoints for task management, monitoring, and self-evolution. Real-time updates via SSE at `GET /api/events`. ## Multi-Agent Architecture @@ -220,24 +163,7 @@ pending → running → success (branch merged to main) ## Project Structure -``` -cc-manager/ -├── v1/ -│ ├── src/ -│ │ ├── index.ts # CLI entry point (Commander.js) -│ │ ├── scheduler.ts # Priority queue, retry, budget enforcement -│ │ ├── agent-runner.ts # Multi-agent CLI spawning + code review -│ │ ├── worktree-pool.ts # Git worktree lifecycle -│ │ ├── server.ts # Hono REST API + SSE -│ │ ├── store.ts # SQLite persistence (better-sqlite3) -│ │ ├── types.ts # Shared TypeScript types -│ │ ├── logger.ts # Structured JSON logger with levels -│ │ ├── web/index.html # Dashboard (dark/light theme) -│ │ └── __tests__/ # BDD-style test suites (71 tests) -│ ├── package.json -│ └── tsconfig.json -└── CLAUDE.md # Agent instructions & project spec -``` +See [ARCHITECTURE.md](ARCHITECTURE.md) for the module dependency graph and data flow. ## Tech Stack diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md index a1df830..9a28e64 100644 --- a/docs/CONFIGURATION.md +++ b/docs/CONFIGURATION.md @@ -1,6 +1,6 @@ # Configuration Reference -This document describes all configuration options for cc-manager (v1). +This document describes all configuration options for cc-manager. --- diff --git a/docs/GETTING_STARTED.md b/docs/GETTING_STARTED.md index e8bb75c..de57ea7 100644 --- a/docs/GETTING_STARTED.md +++ b/docs/GETTING_STARTED.md @@ -96,7 +96,7 @@ curl http://localhost:8080/api/tasks//diff ```bash git clone https://github.com/agent-next/cc-manager.git -cd cc-manager/v1 +cd cc-manager npm install npm run build node dist/index.js --repo /path/to/your/repo diff --git a/docs/OPERATIONS.md b/docs/OPERATIONS.md index 1381a06..5024203 100644 --- a/docs/OPERATIONS.md +++ b/docs/OPERATIONS.md @@ -57,14 +57,13 @@ sudo systemctl status cc-manager ## Upgrade Procedure 1. Pull latest code. -2. Install dependencies in `v1/`. +2. Install dependencies. 3. Build TypeScript output. 4. Restart service. 5. Run health and smoke checks. ```bash git pull -cd v1 npm ci npm run build sudo systemctl restart cc-manager diff --git a/docs/index.html b/docs/site/index.html similarity index 100% rename from docs/index.html rename to docs/site/index.html diff --git a/docs/site.css b/docs/site/site.css similarity index 100% rename from docs/site.css rename to docs/site/site.css diff --git a/v1/package-lock.json b/package-lock.json similarity index 99% rename from v1/package-lock.json rename to package-lock.json index bd76f7d..1f36b81 100644 --- a/v1/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cc-manager", - "version": "0.1.0-alpha", + "version": "0.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "cc-manager", - "version": "0.1.0-alpha", + "version": "0.1.0", "license": "MIT", "dependencies": { "@anthropic-ai/claude-agent-sdk": "^0.2.62", @@ -16,6 +16,7 @@ "hono": "^4.6.0" }, "bin": { + "cc-m": "dist/cli.js", "cc-manager": "dist/index.js" }, "devDependencies": { diff --git a/v1/package.json b/package.json similarity index 87% rename from v1/package.json rename to package.json index 3a703c0..eea524a 100644 --- a/v1/package.json +++ b/package.json @@ -22,11 +22,11 @@ "node": ">=20" }, "scripts": { - "build": "tsc", + "build": "tsc && mkdir -p dist/web && cp src/web/index.html dist/web/index.html", "start": "node dist/index.js", "dev": "tsx src/index.ts", "test": "node --import tsx --test src/__tests__/*.test.ts", - "prepare": "cd .. && git config core.hooksPath .githooks" + "prepare": "git config core.hooksPath .githooks" }, "dependencies": { "@anthropic-ai/claude-agent-sdk": "^0.2.62", diff --git a/v1/src/__tests__/agent-runner.test.ts b/src/__tests__/agent-runner.test.ts similarity index 100% rename from v1/src/__tests__/agent-runner.test.ts rename to src/__tests__/agent-runner.test.ts diff --git a/v1/src/__tests__/scheduler.test.ts b/src/__tests__/scheduler.test.ts similarity index 100% rename from v1/src/__tests__/scheduler.test.ts rename to src/__tests__/scheduler.test.ts diff --git a/v1/src/__tests__/server.test.ts b/src/__tests__/server.test.ts similarity index 100% rename from v1/src/__tests__/server.test.ts rename to src/__tests__/server.test.ts diff --git a/v1/src/__tests__/store.test.ts b/src/__tests__/store.test.ts similarity index 100% rename from v1/src/__tests__/store.test.ts rename to src/__tests__/store.test.ts diff --git a/v1/src/__tests__/worktree-pool.test.ts b/src/__tests__/worktree-pool.test.ts similarity index 100% rename from v1/src/__tests__/worktree-pool.test.ts rename to src/__tests__/worktree-pool.test.ts diff --git a/v1/src/agent-runner.ts b/src/agent-runner.ts similarity index 100% rename from v1/src/agent-runner.ts rename to src/agent-runner.ts diff --git a/v1/src/cli.ts b/src/cli.ts similarity index 100% rename from v1/src/cli.ts rename to src/cli.ts diff --git a/v1/src/index.ts b/src/index.ts similarity index 100% rename from v1/src/index.ts rename to src/index.ts diff --git a/v1/src/logger.ts b/src/logger.ts similarity index 100% rename from v1/src/logger.ts rename to src/logger.ts diff --git a/v1/src/scheduler.ts b/src/scheduler.ts similarity index 100% rename from v1/src/scheduler.ts rename to src/scheduler.ts diff --git a/v1/src/server.ts b/src/server.ts similarity index 100% rename from v1/src/server.ts rename to src/server.ts diff --git a/v1/src/store.ts b/src/store.ts similarity index 100% rename from v1/src/store.ts rename to src/store.ts diff --git a/v1/src/types.ts b/src/types.ts similarity index 97% rename from v1/src/types.ts rename to src/types.ts index c2bf244..c12de74 100644 --- a/v1/src/types.ts +++ b/src/types.ts @@ -144,11 +144,11 @@ export const defaultAutoFlywheelConfig: AutoFlywheelConfig = { minSuccessRate: 0.8, cooldownMinutes: 30, targetFiles: [ - "v1/src/types.ts", - "v1/src/queue.ts", - "v1/src/server.ts", - "v1/src/worker.ts", - "v1/src/routes.ts", + "src/types.ts", + "src/store.ts", + "src/server.ts", + "src/scheduler.ts", + "src/agent-runner.ts", ], }; diff --git a/v1/src/web/index.html b/src/web/index.html similarity index 100% rename from v1/src/web/index.html rename to src/web/index.html diff --git a/v1/src/worktree-pool.ts b/src/worktree-pool.ts similarity index 99% rename from v1/src/worktree-pool.ts rename to src/worktree-pool.ts index 07fe308..15b55ee 100644 --- a/v1/src/worktree-pool.ts +++ b/src/worktree-pool.ts @@ -149,7 +149,7 @@ export class WorktreePool { try { // Exclude node_modules from clean — we symlink it for build verification - await this.gitIn(w.path, "clean", "-fdx", "-e", "node_modules", "-e", "v1/node_modules"); + await this.gitIn(w.path, "clean", "-fdx", "-e", "node_modules"); } catch (err) { log("warn", "[pool] clean failed (non-fatal)", { worker: w.name, err: String(err) }); } diff --git a/v1/tsconfig.json b/tsconfig.json similarity index 100% rename from v1/tsconfig.json rename to tsconfig.json