@gonzih/cc-agent 0.1.11 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +101 -38
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,60 +1,109 @@
1
1
  # cc-agent
2
2
 
3
- MCP server for spawning Claude Code agents in cloned repos. Give Claude Code the ability to **branch itself** — clone a repo and kick off a sub-agent to work on it autonomously.
3
+ MCP server for spawning Claude Code agents in GitHub repos. Give Claude Code the ability to **branch itself** — clone a repo and kick off a sub-agent to work on it autonomously, with persistent state across MCP restarts.
4
4
 
5
- ## What it does
6
-
7
- Exposes 5 MCP tools:
8
-
9
- | Tool | Description |
10
- |------|-------------|
11
- | `spawn_agent` | Clone a git repo and run Claude Code on a task inside it |
12
- | `get_job_status` | Check status of a spawned job |
13
- | `get_job_output` | Stream output lines from a job |
14
- | `list_jobs` | List all jobs |
15
- | `cancel_job` | Cancel a running job |
16
-
17
- Claude submits a job → cc-agent clones the repo → starts Claude Code in it with the task → returns immediately with a job ID → caller polls for output.
5
+ Built by [@Gonzih](https://github.com/Gonzih).
18
6
 
19
7
  ## Quickstart
20
8
 
21
9
  ```bash
22
- # Add to Claude Code MCP config
23
10
  claude mcp add cc-agent -- npx @gonzih/cc-agent
24
11
  ```
25
12
 
26
13
  Set one of:
27
14
  ```bash
28
- CLAUDE_CODE_TOKEN=sk-ant-oat01-... # OAuth token
29
- ANTHROPIC_API_KEY=sk-ant-api03-... # API key
15
+ CLAUDE_CODE_OAUTH_TOKEN=sk-ant-oat01-... # OAuth token (recommended)
16
+ ANTHROPIC_API_KEY=sk-ant-api03-... # API key
30
17
  ```
31
18
 
32
- Then restart Claude Code.
19
+ Restart Claude Code. You now have 7 new MCP tools.
33
20
 
34
- ## Example usage (from within Claude Code)
21
+ ## MCP Tools
22
+
23
+ | Tool | Description |
24
+ |------|-------------|
25
+ | `spawn_agent` | Clone a repo, optionally create a branch, run Claude Code on a task |
26
+ | `list_jobs` | List all jobs with status, recent tool calls, and exit info |
27
+ | `get_job_status` | Check status of a specific job |
28
+ | `get_job_output` | Stream output lines from a job (supports offset for tailing) |
29
+ | `cancel_job` | Kill a running job |
30
+ | `send_message` | Write a message to a running agent's stdin mid-task |
31
+ | `get_version` | Return the running cc-agent version |
32
+
33
+ ## spawn_agent parameters
34
+
35
+ | Parameter | Type | Required | Description |
36
+ |-----------|------|----------|-------------|
37
+ | `repo_url` | string | yes | Git repo to clone (HTTPS) |
38
+ | `task` | string | yes | Task prompt for Claude Code |
39
+ | `branch` | string | no | Existing branch to check out after clone |
40
+ | `create_branch` | string | no | New branch to create (e.g. `feat/my-feature`) |
41
+ | `claude_token` | string | no | Per-job token override |
42
+ | `continue_session` | boolean | no | Pass `--continue` to resume last Claude session in workdir |
43
+ | `max_budget_usd` | number | no | Spend cap in USD (default: 20). Prevents runaway costs |
44
+
45
+ ## Usage example
35
46
 
36
47
  ```
37
48
  spawn_agent({
38
49
  repo_url: "https://github.com/yourorg/yourrepo",
39
- task: "Find all TODO comments and create a summary in TODO_SUMMARY.md",
40
- create_branch: "agent/todo-summary"
50
+ task: "Add error handling to all API endpoints. Open a PR when done.",
51
+ create_branch: "feat/error-handling",
52
+ max_budget_usd: 5
41
53
  })
42
54
  // → { job_id: "abc-123", status: "started" }
43
55
 
44
- get_job_output({ job_id: "abc-123" })
45
- // → { lines: ["[cc-agent] Cloning...", "..."], done: false }
56
+ list_jobs()
57
+ // → [{ id: "abc-123", status: "running", recentTools: ["Read", "Edit", "Bash", ...] }]
58
+
59
+ get_job_output({ job_id: "abc-123", offset: 0 })
60
+ // → { lines: ["[cc-agent] Cloning...", "Reading src/api.ts...", ...], done: false }
61
+
62
+ send_message({ job_id: "abc-123", message: "Also update the tests." })
63
+ // → { ok: true }
46
64
  ```
47
65
 
48
- ## Environment variables
66
+ ## Persistent job storage
49
67
 
50
- | Variable | Description |
51
- |----------|-------------|
52
- | `CLAUDE_CODE_TOKEN` | Claude OAuth token (sk-ant-oat01-...) |
53
- | `ANTHROPIC_API_KEY` | Anthropic API key (sk-ant-api03-...) |
68
+ Job state is persisted to `<cwd>/.cc-agent/` across MCP server restarts:
69
+
70
+ - `.cc-agent/jobs.json` full job metadata (status, exit code, PID, params)
71
+ - `.cc-agent/jobs/<id>.log` per-job output log
72
+
73
+ On restart, jobs whose processes are still alive are recovered as `running`. Dead PIDs are marked `failed` automatically. This means **you don't lose job history if the MCP server restarts**.
74
+
75
+ `.cc-agent/` is gitignored automatically.
76
+
77
+ ## Tool call visibility
78
+
79
+ `list_jobs` returns `recentTools` — the last 10 tool names Claude called per job (e.g. `["Read", "Edit", "Bash", "Glob"]`). `get_job_output` returns the full `tool_calls` array. This gives insight into what agents are actually doing during silent periods.
54
80
 
55
- Per-job token override available via `claude_token` argument on `spawn_agent`.
81
+ ## Budget control
56
82
 
57
- ## MCP config example
83
+ Set `max_budget_usd` per job to cap spend. Default is $20. Claude Code is killed with SIGTERM when the budget is exhausted (exit code 143).
84
+
85
+ ```
86
+ spawn_agent({ ..., max_budget_usd: 10 }) // up to $10 for this task
87
+ spawn_agent({ ..., max_budget_usd: 2 }) // quick/cheap task
88
+ ```
89
+
90
+ ## Agent delegation pattern
91
+
92
+ The recommended mental model: **you are the tech lead, agents are your team**.
93
+
94
+ - Spawn agents for any task touching a codebase (multiple files, running tests, opening PRs)
95
+ - Do research, quick edits, and orchestration yourself
96
+ - Always end agent prompts with the terminal steps: `gh pr create → gh pr merge → npm publish` (or whatever ships the work)
97
+ - Monitor with `list_jobs` + `get_job_output`, respawn if budget runs out
98
+
99
+ ```
100
+ # Standard agent task prompt ending:
101
+ gh pr create --title "feat: ..." --body "..." --base main
102
+ gh pr merge --squash --auto
103
+ npm version patch && npm publish # if it's a library
104
+ ```
105
+
106
+ ## MCP config (claude.json)
58
107
 
59
108
  ```json
60
109
  {
@@ -62,7 +111,7 @@ Per-job token override available via `claude_token` argument on `spawn_agent`.
62
111
  "command": "npx",
63
112
  "args": ["@gonzih/cc-agent"],
64
113
  "env": {
65
- "ANTHROPIC_API_KEY": "sk-ant-api03-..."
114
+ "CLAUDE_CODE_OAUTH_TOKEN": "sk-ant-oat01-..."
66
115
  }
67
116
  }
68
117
  }
@@ -70,14 +119,28 @@ Per-job token override available via `claude_token` argument on `spawn_agent`.
70
119
 
71
120
  ## How it works
72
121
 
73
- 1. `spawn_agent` creates a job and returns immediately
122
+ 1. `spawn_agent` creates a job record (persisted to disk) and returns immediately with a job ID
74
123
  2. In background: `git clone --depth 1 <repo>` into a temp dir
75
- 3. Optionally checks out a branch or creates a new one
76
- 4. Runs `claude --print --output-format stream-json --dangerously-skip-permissions "<task>"`
77
- 5. Streams output into job record
78
- 6. Temp dir cleaned up 10 minutes after job finishes
79
- 7. Jobs expire after 1 hour
124
+ 3. Optionally checks out an existing branch or creates a new one
125
+ 4. Runs `claude --print --output-format stream-json --verbose --dangerously-skip-permissions --max-budget-usd <N> <task>`
126
+ 5. Streams stdout/stderr into the job's output log (in memory + disk)
127
+ 6. Tool calls are captured from the stream-JSON and stored in `tool_calls[]`
128
+ 7. On exit: job marked done/failed, workdir cleaned up after 10 minutes
129
+ 8. Jobs expire from memory after 1 hour (log file remains on disk)
130
+
131
+ ## Environment variables
132
+
133
+ | Variable | Description |
134
+ |----------|-------------|
135
+ | `CLAUDE_CODE_OAUTH_TOKEN` | Claude OAuth token (recommended) |
136
+ | `ANTHROPIC_API_KEY` | Anthropic API key (alternative) |
137
+
138
+ ## Requirements
139
+
140
+ - Node.js 18+
141
+ - `claude` CLI: `npm install -g @anthropic-ai/claude-code`
142
+ - Git
80
143
 
81
144
  ## Related
82
145
 
83
- - [cc-tg](https://github.com/Gonzih/cc-tg) — Claude Code Telegram bot (same author)
146
+ - [cc-tg](https://github.com/Gonzih/cc-tg) — Claude Code Telegram bot by [@Gonzih](https://github.com/Gonzih)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gonzih/cc-agent",
3
- "version": "0.1.11",
3
+ "version": "0.2.0",
4
4
  "description": "MCP server for spawning Claude Code agents in cloned repos — branch your agents",
5
5
  "type": "module",
6
6
  "bin": {