switchman-dev 0.1.2 → 0.1.4

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.
package/README.md CHANGED
@@ -1,260 +1,150 @@
1
1
  # Switchman
2
2
 
3
- **Stop your AI agents from overwriting each other.**
3
+ **Run 10+ agents on one codebase. Safely.**
4
4
 
5
- When you run multiple Claude Code instances on the same repo, they have no idea what each other is doing. One agent edits a file while another rewrites it. Hours of work disappear at merge time.
5
+ Switchman acts like a project manager for your AI coding assistants. It hands out tasks, stops agents from editing the same file at the same time, and double-checks their work before saving.
6
6
 
7
- Switchman gives them a shared task queue and file locking so they stay on separate tracks and you stay in control.
7
+ When you run multiple agents on the same repo, they need shared coordination or they collide, duplicate work, and create risky merges. Switchman gives them leases, scoped ownership, merge gates, and landing workflows so they can move in parallel without stepping on each other.
8
8
 
9
- ---
9
+ In the docs, `workspace` means the folder each agent works in. Some commands still use the Git term `worktree`, because that is the underlying Git feature.
10
10
 
11
- ## Requirements
11
+ Questions, feedback, or testing Switchman with your team? Join the [Discord](https://discord.gg/pnT8BEC4D)
12
12
 
13
+ ## Install
14
+
15
+ Requirements:
13
16
  - Node.js 22.5+
14
17
  - Git 2.5+
15
18
 
16
- ---
17
-
18
- ## Install
19
-
20
19
  ```bash
21
20
  npm install -g @switchman-dev
22
21
  ```
23
22
 
24
- ---
23
+ ## Why Switchman?
24
+
25
+ Git worktrees, branches, and raw coding agents are useful, but they do not coordinate themselves.
25
26
 
26
- ## Pick your setup
27
+ What it adds that plain Git does not:
28
+ - task assignment, so agents do not duplicate work
29
+ - file locking, so parallel edits do not quietly collide
30
+ - live status, so you can see what is running, blocked, or stale
31
+ - stale-work recovery, so abandoned work does not clog the repo
32
+ - governed landing, so finished work reaches `main` one item at a time with retries and checks
27
33
 
28
- ### Option A — Claude Code (recommended)
34
+ In short:
35
+ - Git gives you branches
36
+ - Switchman gives you coordination
29
37
 
30
- Claude Code has a native Switchman integration via MCP. Your agents coordinate automatically — no manual CLI calls, no extra prompting.
38
+ ## Quickstart
31
39
 
32
- **Step 1 — Create your agent workspaces**
40
+ Recommended first run:
41
+ - editor: Cursor
42
+ - goal: feel safe parallel agent work in under 10 minutes
43
+ - proof: status stays clear, agents stay separated, and the repo gate passes
33
44
 
34
45
  ```bash
35
46
  cd my-project
36
- switchman setup --agents 3
37
- ```
38
-
39
- That's it. Switchman creates three isolated workspaces, one per agent, and initialises the database. You'll see the folder paths printed — you'll need them in step 4.
47
+ switchman setup --agents 5
40
48
 
41
- **Step 2 Add Switchman to Claude Code**
49
+ switchman task add "Implement auth helper" --priority 9
50
+ switchman task add "Add auth tests" --priority 8
51
+ switchman task add "Update auth docs" --priority 7
42
52
 
43
- Add this to `~/.claude/claude_desktop_config.json`:
44
-
45
- ```json
46
- {
47
- "mcpServers": {
48
- "switchman": {
49
- "command": "switchman-mcp",
50
- "args": []
51
- }
52
- }
53
- }
54
- ```
55
-
56
- Then restart Claude Code.
57
-
58
- **Step 3 — Copy CLAUDE.md into your repo root**
59
-
60
- ```bash
61
- curl -O https://raw.githubusercontent.com/switchman-dev/switchman/main/CLAUDE.md
53
+ switchman status
54
+ switchman status --watch
55
+ switchman gate ci
62
56
  ```
63
57
 
64
- This tells your agents how to use Switchman. Without it they won't know to coordinate.
58
+ What `switchman setup` gives you:
59
+ - one shared Switchman database in `.switchman/`
60
+ - linked workspaces for each agent
61
+ - local MCP config for Claude Code and Cursor
65
62
 
66
- **Step 4 Add your tasks**
63
+ Fastest path to success:
64
+ 1. Use Cursor for the first run.
65
+ 2. Open one Cursor window per generated workspace.
66
+ 3. Let each agent pick up one clearly separate task.
67
+ 4. Keep `switchman status --watch` open in another terminal.
68
+ 5. Run `switchman gate ci` when the tasks finish.
67
69
 
68
- ```bash
69
- switchman task add "Fix the login bug" --priority 8
70
- switchman task add "Add rate limiting" --priority 6
71
- switchman task add "Update README" --priority 2
72
- ```
70
+ If you want the recommended editor setup guide, start here:
71
+ - [Cursor setup](docs/setup-cursor.md)
73
72
 
74
- **Step 5 Open Claude Code in each workspace**
73
+ If you want a guided demo, see [examples/README.md](examples/README.md).
75
74
 
76
- Open a separate Claude Code window in each folder that `switchman setup` created. Each agent will automatically pick up a task, lock the files it needs, and release them when it's done.
75
+ ## What good looks like
77
76
 
78
- **Step 6 Check before merging**
77
+ You know the first run is working when:
78
+ - agents claim different files instead of stepping on each other
79
+ - `switchman status` stays calm and readable instead of filling with blocked work
80
+ - the landing queue moves finished work safely back toward `main`
81
+ - `switchman gate ci` passes cleanly
79
82
 
80
- ```bash
81
- switchman scan
82
- ```
83
+ That is the moment Switchman should feel different from “just using a few branches.”
83
84
 
84
- ---
85
+ ## Why not just use branches or worktrees?
85
86
 
86
- ### Option B Any other agent (Cursor, Windsurf, Aider, etc.)
87
+ Because branches and worktrees solve isolation, not coordination.
87
88
 
88
- Switchman works as a CLI tool with any agent that can run terminal commands. The coordination isn't automatic — you'll need to prompt your agents to use Switchman commands.
89
+ They do not tell you:
90
+ - which task each agent should take next
91
+ - who already owns a file
92
+ - whether a session is stale
93
+ - whether finished work is still safe to land
89
94
 
90
- **Step 1 Create your agent workspaces**
95
+ Switchman is for the point where “we can manage this by hand” stops being true.
91
96
 
92
- ```bash
93
- cd my-project
94
- switchman setup --agents 3
95
- ```
97
+ ## Choose your setup
96
98
 
97
- **Step 2 Add your tasks**
99
+ Pick the guide that matches how you work:
98
100
 
99
- ```bash
100
- switchman task add "Fix the login bug" --priority 8
101
- switchman task add "Add rate limiting" --priority 6
102
- ```
101
+ | Setup | Guide |
102
+ |------|------|
103
+ | Claude Code | [Claude Code setup](docs/setup-claude-code.md) |
104
+ | Cursor | [Cursor setup](docs/setup-cursor.md) |
105
+ | Windsurf | [Windsurf setup](docs/setup-windsurf.md) |
106
+ | Any CLI-driven agent | [CLI agent setup](docs/setup-cli-agents.md) |
103
107
 
104
- **Step 3 Give each agent this prompt**
108
+ ## If something feels stuck
105
109
 
106
- Paste this into your agent at the start of each session:
110
+ Use `switchman status` first.
107
111
 
108
- ```
109
- Before starting any work:
110
- 1. Run `switchman lease next --json` to get your assigned task and lease
111
- 2. Run `switchman claim <taskId> <worktreeName> <files...>` to lock the files you'll edit
112
- - If a file is already claimed, pick a different approach or different files
113
- 3. If the task runs for a while, refresh the lease with `switchman lease heartbeat <leaseId>`
114
- 4. When finished, run `switchman task done <taskId>`
115
-
116
- Never edit a file you haven't claimed. If a claim fails, do not use --force.
117
- ```
112
+ It is the main terminal dashboard for the repo:
113
+ - top health banner and compact counts
114
+ - boxed sections for `Running`, `Blocked`, `Warnings`, `Queue`, and `Next action`
115
+ - exact follow-up commands when something needs attention
116
+ - `--watch` mode for a live terminal view
118
117
 
119
- **Step 4 — Check before merging**
118
+ Useful commands:
120
119
 
121
120
  ```bash
122
- switchman scan
123
- ```
124
-
125
- ---
126
-
127
- ## What your agents will see
128
-
129
- Here's what a normal session looks like with Switchman running:
130
-
131
- ```
132
- # Agent 1 picks up a task
133
- switchman lease next
134
- ✓ Lease acquired: "Add rate limiting to all routes" [task-abc-123 / lease-xyz-123]
135
-
136
- # Agent 1 locks its files
137
- switchman claim task-abc-123 agent1 src/middleware/auth.js src/server.js
138
- ✓ 2 files locked — no conflicts
139
-
140
- # Agent 2 picks up a different task
141
- switchman lease next
142
- ✓ Lease acquired: "Add validation to POST /tasks" [task-def-456 / lease-xyz-456]
143
-
144
- # Agent 2 tries to claim a file already locked by Agent 1
145
- switchman claim task-def-456 agent2 src/middleware/auth.js
146
- ⚠ Conflict: auth.js is locked by agent1
147
-
148
- # Agent 2 claims different files instead
149
- switchman claim task-def-456 agent2 src/middleware/validate.js src/routes/tasks.js
150
- ✓ 2 files locked — no conflicts
151
-
152
- # Both agents working, zero collisions
153
121
  switchman status
154
- agent1 → "Add rate limiting" editing auth.js, server.js
155
- agent2 → "Add validation" editing validate.js, tasks.js
122
+ switchman status --watch
123
+ switchman status --json
124
+ switchman scan
125
+ switchman gate ci
156
126
  ```
157
127
 
158
- ---
159
-
160
- ## Commands
161
-
162
- ### `switchman setup`
163
- One-command setup — creates agent workspaces and initialises the database.
164
- - `--agents 3` — number of workspaces to create (default: 3, max: 10)
165
- - `--prefix switchman` — branch name prefix (default: switchman)
166
-
167
- ### `switchman init`
168
- Initialise in the current git repo without creating worktrees. Creates `.switchman/switchman.db` and auto-detects existing worktrees.
169
-
170
- ### `switchman task add <title>`
171
- Add a task to the queue.
172
- - `--priority 1-10` (default: 5)
173
- - `--description "..."`
174
-
175
- ### `switchman task list`
176
- List all tasks. Filter with `--status pending|in_progress|done|failed`.
177
-
178
- ### `switchman task next`
179
- Get and assign the next pending task. This is a compatibility shim over the lease workflow. Use `--json` for agent automation.
180
- - `--worktree <name>` — worktree to assign to (defaults to current folder name)
181
- - `--agent <name>` — agent identifier for logging
182
-
183
- ### `switchman lease next`
184
- Acquire the next pending task as a first-class lease. Use `--json` for agent automation.
185
- - `--worktree <name>` — worktree to assign to (defaults to current folder name)
186
- - `--agent <name>` — agent identifier for logging
187
-
188
- ### `switchman lease list`
189
- List active and historical leases. Filter with `--status active|completed|failed|expired`.
190
-
191
- ### `switchman lease heartbeat <leaseId>`
192
- Refresh the heartbeat timestamp for a long-running lease so it does not get treated as stale.
193
-
194
- ### `switchman lease reap`
195
- Expire stale leases, release their claims, and return their tasks to `pending`.
196
- - `--stale-after-minutes <n>` — staleness threshold (default: 15)
197
-
198
- ### `switchman task done <taskId>`
199
- Mark a task complete and release all file claims.
200
-
201
- ### `switchman task fail <taskId>`
202
- Mark a task failed and release all file claims.
203
-
204
- ### `switchman claim <taskId> <worktree> [files...]`
205
- Lock files before editing. Warns immediately if any file is already claimed by another agent.
206
-
207
- ### `switchman release <taskId>`
208
- Release all file claims for a task.
209
-
210
- ### `switchman scan`
211
- Check all worktrees for conflicts — both uncommitted file overlaps and branch-level merge conflicts. Run this before merging.
212
-
213
- ### `switchman status`
214
- Full overview: task counts, active leases, stale leases, locked files, and a quick conflict scan.
215
-
216
- ### `switchman worktree list`
217
- List all git worktrees with their registered agents and status.
218
-
219
- ### `switchman worktree sync`
220
- Re-sync git worktrees into the Switchman database (useful if you add worktrees after init).
221
-
222
- ---
223
-
224
- ## MCP tools (Claude Code)
225
-
226
- | Tool | What it does |
227
- |------|-------------|
228
- | `switchman_task_next` | Get + assign the next pending task |
229
- | `switchman_task_add` | Add a new task to the queue |
230
- | `switchman_task_claim` | Claim files before editing (conflict check) |
231
- | `switchman_task_done` | Mark task complete, release file claims |
232
- | `switchman_task_fail` | Mark task failed, release file claims |
233
- | `switchman_lease_heartbeat` | Refresh a long-running lease heartbeat |
234
- | `switchman_scan` | Scan all worktrees for conflicts |
235
- | `switchman_status` | Full system overview |
236
-
237
- ---
238
-
239
- ## Roadmap
240
-
241
- - [ ] Merge queue — serialize worktree→main merges with auto-retry
242
- - [ ] Automatic stale-lease policies — configurable heartbeat/reap behaviour
243
- - [ ] Cursor and Windsurf native MCP integration
244
- - [ ] Web dashboard
245
- - [ ] `brew install switchman`
128
+ More help:
129
+ - [Status and recovery](docs/status-and-recovery.md)
130
+ - [Merge queue](docs/merge-queue.md)
131
+ - [Stale lease policy](docs/stale-lease-policy.md)
246
132
 
247
- ---
133
+ ## More docs
248
134
 
249
- ## Feedback & contact
135
+ - [Merge queue](docs/merge-queue.md)
136
+ - [Pipelines and PRs](docs/pipelines.md)
137
+ - [Stale lease policy](docs/stale-lease-policy.md)
138
+ - [MCP tools](docs/mcp-tools.md)
139
+ - [Command reference](docs/command-reference.md)
250
140
 
251
- Building this in public — if you're running parallel agents and hit something broken or missing, I'd love to hear about it.
141
+ ## Feedback
252
142
 
253
- - **GitHub Issues** [github.com/switchman-dev/switchman/issues](https://github.com/switchman-dev/switchman/issues)
254
- - **Email** — [hello@switchman.dev](mailto:hello@switchman.dev)
143
+ Building this in public. If you're running parallel agents and hit something broken or missing, I’d love to hear about it.
255
144
 
256
- ---
145
+ - GitHub Issues: [github.com/switchman-dev/switchman/issues](https://github.com/switchman-dev/switchman/issues)
146
+ - Email: [hello@switchman.dev](mailto:hello@switchman.dev)
257
147
 
258
148
  ## License
259
149
 
260
- MIT — free to use, modify, and distribute.
150
+ MIT
@@ -25,6 +25,8 @@ examples/
25
25
 
26
26
  ## Quick start
27
27
 
28
+ This is the fastest way to understand Switchman as a new user.
29
+
28
30
  Make sure Switchman is installed globally first:
29
31
  ```bash
30
32
  npm install -g . # from the switchman repo root
@@ -36,16 +38,30 @@ bash examples/setup.sh
36
38
  bash examples/walkthrough.sh
37
39
  ```
38
40
 
41
+ If you want the shortest path:
42
+ - `setup.sh` creates the repo, worktrees, and seed tasks
43
+ - `walkthrough.sh` shows one complete 3-agent happy path, including a real claim conflict
44
+
39
45
  ## What the walkthrough shows
40
46
 
41
47
  1. **3 worktrees created** — simulating 3 parallel Claude Code instances each on their own branch
42
- 2. **Agent 1 picks up a task** — `switchman task next` returns the highest-priority item
48
+ 2. **Agent 1 picks up a task** — `switchman lease next` returns the highest-priority item and lease
43
49
  3. **Agent 1 claims files** — declares which files it will edit before touching them
44
50
  4. **Agent 2 picks up a task** — takes the next item from the queue
45
51
  5. **Agent 2 tries to claim a conflicting file** — Switchman blocks it
46
52
  6. **Agent 2 adapts** — claims only the safe files instead
47
53
  7. **Agent 1 finishes** — marks task done, releases file claims
48
- 8. **Final status** — queue updated, no lingering conflicts
54
+
55
+ Under the hood, Switchman now treats the lease as the execution record. That means reviewer artifacts and audit history can point back to the exact lease that performed the work, not just the task title.
56
+ 8. **Final status** — queue updated, readable status output, no lingering conflicts
57
+
58
+ ## What a good demo run looks like
59
+
60
+ At the end of the walkthrough, you want to see:
61
+ - tasks moving from `pending` -> `in_progress` -> `done`
62
+ - one agent blocked from claiming a file already owned by another
63
+ - `switchman scan` showing no unclaimed changes
64
+ - `switchman status` giving a clean overview of what happened
49
65
 
50
66
  ## The taskapi project
51
67
 
@@ -2,7 +2,7 @@
2
2
  # examples/walkthrough.sh
3
3
  #
4
4
  # Walks through the Switchman workflow step by step.
5
- # Simulates 3 agents working in parallel including a real conflict.
5
+ # Simulates 3 agents working in parallel, including a real file-claim conflict.
6
6
  #
7
7
  # Run AFTER setup.sh:
8
8
  # bash examples/walkthrough.sh
@@ -51,11 +51,11 @@ read -r
51
51
  # ── Step 2: Agent 1 picks up a task ──────────────────────────────────────────
52
52
 
53
53
  step "2. Agent 1 picks up the highest-priority task"
54
- agent "agent-rate-limiting" "calling: switchman task next --json"
54
+ agent "agent-rate-limiting" "calling: switchman lease next --json"
55
55
  echo ""
56
56
 
57
- TASK1=$(switchman task next --json 2>/dev/null || echo "null")
58
- TASK1_ID=$(echo "$TASK1" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d['id'])" 2>/dev/null || echo "")
57
+ TASK1=$(switchman lease next --json --worktree agent-rate-limiting --agent claude-code 2>/dev/null || echo "null")
58
+ TASK1_ID=$(echo "$TASK1" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d['task']['id'])" 2>/dev/null || echo "")
59
59
 
60
60
  if [ -z "$TASK1_ID" ]; then
61
61
  echo " No pending tasks found. Run setup.sh first."
@@ -63,9 +63,7 @@ if [ -z "$TASK1_ID" ]; then
63
63
  fi
64
64
 
65
65
  echo "$TASK1" | python3 -m json.tool 2>/dev/null || echo "$TASK1"
66
- echo ""
67
- switchman task assign "$TASK1_ID" agent-rate-limiting --agent claude-code
68
- ok "Task assigned to agent-rate-limiting"
66
+ ok "Task + lease assigned to agent-rate-limiting"
69
67
 
70
68
  read -r
71
69
 
@@ -86,14 +84,12 @@ read -r
86
84
  # ── Step 4: Agent 2 picks up a task ──────────────────────────────────────────
87
85
 
88
86
  step "4. Agent 2 picks up the next task"
89
- agent "agent-validation" "calling: switchman task next --json"
87
+ agent "agent-validation" "calling: switchman lease next --json"
90
88
  echo ""
91
89
 
92
- TASK2=$(switchman task next --json 2>/dev/null || echo "null")
93
- TASK2_ID=$(echo "$TASK2" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d['id'])" 2>/dev/null || echo "")
94
-
95
- switchman task assign "$TASK2_ID" agent-validation --agent cursor
96
- ok "Task assigned to agent-validation"
90
+ TASK2=$(switchman lease next --json --worktree agent-validation --agent claude-code 2>/dev/null || echo "null")
91
+ TASK2_ID=$(echo "$TASK2" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d['task']['id'])" 2>/dev/null || echo "")
92
+ ok "Task + lease assigned to agent-validation"
97
93
 
98
94
  read -r
99
95
 
@@ -145,7 +141,7 @@ step "8. Agent 1 finishes — marks task done and releases files"
145
141
  agent "agent-rate-limiting" "Rate limiting implemented and committed."
146
142
  echo ""
147
143
 
148
- switchman task done "$TASK1_ID" --release-files
144
+ switchman task done "$TASK1_ID"
149
145
  ok "Task done. src/middleware/auth.js and src/server.js are now free."
150
146
 
151
147
  read -r
@@ -161,11 +157,11 @@ echo ""
161
157
  echo -e "${GREEN}✓ Walkthrough complete.${RESET}"
162
158
  echo ""
163
159
  echo "What you saw:"
164
- echo " • 2 agents picked up tasks from the shared queue"
160
+ echo " • 2 agents picked up tasks from the shared queue with real leases"
165
161
  echo " • Agent 2 was blocked from claiming a file already owned by Agent 1"
166
162
  echo " • Agent 2 adapted by claiming different files"
167
163
  echo " • Agent 1 completed and released its claims"
168
- echo " • The queue updated in real time throughout"
164
+ echo " • switchman status and switchman scan stayed readable throughout"
169
165
  echo ""
170
166
  echo "To reset and run again:"
171
167
  echo " bash examples/teardown.sh && bash examples/setup.sh"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "switchman-dev",
3
- "version": "0.1.2",
4
- "description": "Route your AI agents so they don't collide",
3
+ "version": "0.1.4",
4
+ "description": "Project manager for AI coding assistants running safely on one codebase",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
7
7
  "bin": {
@@ -15,7 +15,7 @@
15
15
  "scripts": {
16
16
  "start": "node src/cli/index.js",
17
17
  "mcp": "node src/mcp/server.js",
18
- "test": "node tests/test.js"
18
+ "test": "NODE_NO_WARNINGS=1 node tests/test.js"
19
19
  },
20
20
  "dependencies": {
21
21
  "@modelcontextprotocol/sdk": "^1.27.1",