Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .claude/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
Expand Down
6 changes: 3 additions & 3 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs
path: docs/site

deploy:
needs: build
Expand Down
File renamed without changes.
32 changes: 16 additions & 16 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
35 changes: 3 additions & 32 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
82 changes: 4 additions & 78 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ A multi-agent orchestrator that runs parallel coding agents in git worktrees. Su
## Documentation

- GitHub Pages: <https://agent-next.github.io/cc-manager/>
- 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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
@@ -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.

---

Expand Down
2 changes: 1 addition & 1 deletion docs/GETTING_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ curl http://localhost:8080/api/tasks/<task-id>/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
Expand Down
3 changes: 1 addition & 2 deletions docs/OPERATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions v1/package-lock.json → package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions v1/package.json → package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions v1/src/types.ts → src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
};

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion v1/src/worktree-pool.ts → src/worktree-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) });
}
Expand Down
File renamed without changes.