switchman-dev 0.1.1 → 0.1.3
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 +327 -16
- package/examples/README.md +18 -2
- package/examples/walkthrough.sh +12 -16
- package/package.json +1 -1
- package/src/cli/index.js +2077 -216
- package/src/core/ci.js +114 -0
- package/src/core/db.js +1848 -73
- package/src/core/detector.js +109 -7
- package/src/core/enforcement.js +966 -0
- package/src/core/git.js +42 -5
- package/src/core/ignore.js +47 -0
- package/src/core/mcp.js +47 -0
- package/src/core/merge-gate.js +305 -0
- package/src/core/monitor.js +39 -0
- package/src/core/outcome.js +153 -0
- package/src/core/pipeline.js +1113 -0
- package/src/core/planner.js +508 -0
- package/src/core/semantic.js +311 -0
- package/src/mcp/server.js +491 -23
package/README.md
CHANGED
|
@@ -23,6 +23,80 @@ npm install -g @switchman-dev
|
|
|
23
23
|
|
|
24
24
|
---
|
|
25
25
|
|
|
26
|
+
## First successful run: 3 agents on one repo
|
|
27
|
+
|
|
28
|
+
If you only try one thing, try this.
|
|
29
|
+
|
|
30
|
+
### 1. Create a test repo and three agent worktrees
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
cd my-project
|
|
34
|
+
switchman setup --agents 3
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
This gives you:
|
|
38
|
+
- one shared Switchman database in `.switchman/`
|
|
39
|
+
- three linked worktrees
|
|
40
|
+
- local `.mcp.json` files so Claude Code can discover Switchman automatically
|
|
41
|
+
|
|
42
|
+
### 2. Add three small, separate tasks
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
switchman task add "Implement auth helper" --priority 9
|
|
46
|
+
switchman task add "Add auth tests" --priority 8
|
|
47
|
+
switchman task add "Update auth docs" --priority 7
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Use real tasks from your repo. If a task looks broad enough to fan out across many files or shared areas, Switchman will warn and suggest using `switchman pipeline start` instead.
|
|
51
|
+
|
|
52
|
+
### 3. Open one Claude Code window per worktree
|
|
53
|
+
|
|
54
|
+
Open each generated worktree folder in its own Claude Code window.
|
|
55
|
+
|
|
56
|
+
If Claude Code sees the local `.mcp.json`, each agent can use Switchman without extra setup.
|
|
57
|
+
|
|
58
|
+
### 4. Tell each agent to work through Switchman
|
|
59
|
+
|
|
60
|
+
Use this exact instruction:
|
|
61
|
+
|
|
62
|
+
```text
|
|
63
|
+
Use Switchman for all task coordination in this repo.
|
|
64
|
+
|
|
65
|
+
1. Run `switchman lease next --json` to get your task and lease.
|
|
66
|
+
2. Before editing anything, run `switchman claim <taskId> <worktree> <files...>`.
|
|
67
|
+
3. Only edit files you have claimed.
|
|
68
|
+
4. If a claim is blocked, do not use --force. Pick a different file or different approach.
|
|
69
|
+
5. When finished, run `switchman task done <taskId>`.
|
|
70
|
+
|
|
71
|
+
Do not read or write `.switchman/switchman.db` directly.
|
|
72
|
+
Do not bypass Switchman for file coordination.
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 5. Watch the run
|
|
76
|
+
|
|
77
|
+
In the repo root:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
switchman status
|
|
81
|
+
switchman scan
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
What a good first run looks like:
|
|
85
|
+
- all three tasks end in `done`
|
|
86
|
+
- `switchman scan` reports no conflicts
|
|
87
|
+
- `switchman gate ci` passes
|
|
88
|
+
|
|
89
|
+
### 6. If you want a built-in local demo instead
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
bash examples/setup.sh
|
|
93
|
+
bash examples/walkthrough.sh
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
That runs the included 3-agent demo against the example API in [examples/README.md](/Users/ned/Documents/GitHub/switchman/examples/README.md).
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
26
100
|
## Pick your setup
|
|
27
101
|
|
|
28
102
|
### Option A — Claude Code (recommended)
|
|
@@ -40,7 +114,9 @@ That's it. Switchman creates three isolated workspaces, one per agent, and initi
|
|
|
40
114
|
|
|
41
115
|
**Step 2 — Add Switchman to Claude Code**
|
|
42
116
|
|
|
43
|
-
|
|
117
|
+
`switchman setup` now writes a project-local `.mcp.json` into the repo root and each generated worktree, so Claude Code can discover Switchman automatically when you open those folders.
|
|
118
|
+
|
|
119
|
+
If you prefer a global fallback, add this to `~/.claude/claude_desktop_config.json`:
|
|
44
120
|
|
|
45
121
|
```json
|
|
46
122
|
{
|
|
@@ -53,7 +129,7 @@ Add this to `~/.claude/claude_desktop_config.json`:
|
|
|
53
129
|
}
|
|
54
130
|
```
|
|
55
131
|
|
|
56
|
-
Then restart Claude Code.
|
|
132
|
+
Then restart Claude Code. The project-local `.mcp.json` is the preferred path because it travels with the repo and the generated worktrees.
|
|
57
133
|
|
|
58
134
|
**Step 3 — Copy CLAUDE.md into your repo root**
|
|
59
135
|
|
|
@@ -61,7 +137,7 @@ Then restart Claude Code.
|
|
|
61
137
|
curl -O https://raw.githubusercontent.com/switchman-dev/switchman/main/CLAUDE.md
|
|
62
138
|
```
|
|
63
139
|
|
|
64
|
-
This tells your agents how to use Switchman. Without it they
|
|
140
|
+
This tells your agents how to use Switchman. Without it they may bypass Switchman entirely, so keep it in the repo root and do not let agents talk to `.switchman/switchman.db` directly.
|
|
65
141
|
|
|
66
142
|
**Step 4 — Add your tasks**
|
|
67
143
|
|
|
@@ -73,7 +149,7 @@ switchman task add "Update README" --priority 2
|
|
|
73
149
|
|
|
74
150
|
**Step 5 — Open Claude Code in each workspace**
|
|
75
151
|
|
|
76
|
-
Open a separate Claude Code window in each folder that `switchman setup` created. Each agent
|
|
152
|
+
Open a separate Claude Code window in each folder that `switchman setup` created. Each agent should automatically see the local MCP config, pick up a task, lock the files it needs, and release them when it's done.
|
|
77
153
|
|
|
78
154
|
**Step 6 — Check before merging**
|
|
79
155
|
|
|
@@ -107,10 +183,11 @@ Paste this into your agent at the start of each session:
|
|
|
107
183
|
|
|
108
184
|
```
|
|
109
185
|
Before starting any work:
|
|
110
|
-
1. Run `switchman
|
|
186
|
+
1. Run `switchman lease next --json` to get your assigned task and lease
|
|
111
187
|
2. Run `switchman claim <taskId> <worktreeName> <files...>` to lock the files you'll edit
|
|
112
188
|
- If a file is already claimed, pick a different approach or different files
|
|
113
|
-
3.
|
|
189
|
+
3. If the task runs for a while, refresh the lease with `switchman lease heartbeat <leaseId>`
|
|
190
|
+
4. When finished, run `switchman task done <taskId>`
|
|
114
191
|
|
|
115
192
|
Never edit a file you haven't claimed. If a claim fails, do not use --force.
|
|
116
193
|
```
|
|
@@ -129,16 +206,16 @@ Here's what a normal session looks like with Switchman running:
|
|
|
129
206
|
|
|
130
207
|
```
|
|
131
208
|
# Agent 1 picks up a task
|
|
132
|
-
switchman
|
|
133
|
-
✓
|
|
209
|
+
switchman lease next
|
|
210
|
+
✓ Lease acquired: "Add rate limiting to all routes" [task-abc-123 / lease-xyz-123]
|
|
134
211
|
|
|
135
212
|
# Agent 1 locks its files
|
|
136
213
|
switchman claim task-abc-123 agent1 src/middleware/auth.js src/server.js
|
|
137
214
|
✓ 2 files locked — no conflicts
|
|
138
215
|
|
|
139
216
|
# Agent 2 picks up a different task
|
|
140
|
-
switchman
|
|
141
|
-
✓
|
|
217
|
+
switchman lease next
|
|
218
|
+
✓ Lease acquired: "Add validation to POST /tasks" [task-def-456 / lease-xyz-456]
|
|
142
219
|
|
|
143
220
|
# Agent 2 tries to claim a file already locked by Agent 1
|
|
144
221
|
switchman claim task-def-456 agent2 src/middleware/auth.js
|
|
@@ -156,12 +233,74 @@ switchman status
|
|
|
156
233
|
|
|
157
234
|
---
|
|
158
235
|
|
|
236
|
+
## If something goes wrong
|
|
237
|
+
|
|
238
|
+
Start here before digging into the internals.
|
|
239
|
+
|
|
240
|
+
### `switchman status`
|
|
241
|
+
|
|
242
|
+
Use this first when a run feels stuck.
|
|
243
|
+
|
|
244
|
+
It answers:
|
|
245
|
+
- what is running
|
|
246
|
+
- what is blocked
|
|
247
|
+
- what failed
|
|
248
|
+
- what needs attention next
|
|
249
|
+
|
|
250
|
+
### `switchman scan`
|
|
251
|
+
|
|
252
|
+
Use this before merge, or any time you suspect agents overlapped.
|
|
253
|
+
|
|
254
|
+
It tells you:
|
|
255
|
+
- changed files per worktree
|
|
256
|
+
- unclaimed or unmanaged changes
|
|
257
|
+
- conflict signals across worktrees
|
|
258
|
+
|
|
259
|
+
### `switchman gate ci`
|
|
260
|
+
|
|
261
|
+
Use this as the final repo-level check.
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
switchman gate ci
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
If it fails, Switchman has detected unmanaged changes, stale state, or merge-governance problems.
|
|
268
|
+
|
|
269
|
+
### Common recovery cases
|
|
270
|
+
|
|
271
|
+
`A file claim is blocked`
|
|
272
|
+
- another task already owns that file
|
|
273
|
+
- do not use `--force`
|
|
274
|
+
- choose a different file or let the other task finish first
|
|
275
|
+
|
|
276
|
+
`A task is still in progress but the agent is gone`
|
|
277
|
+
- inspect with `switchman status`
|
|
278
|
+
- if the lease is stale, run:
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
switchman lease reap
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
`A pipeline task failed`
|
|
285
|
+
- run:
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
switchman pipeline status <pipelineId>
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
Switchman now prints:
|
|
292
|
+
- `why:` what failed
|
|
293
|
+
- `next:` what to do next
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
159
297
|
## Commands
|
|
160
298
|
|
|
161
299
|
### `switchman setup`
|
|
162
300
|
One-command setup — creates agent workspaces and initialises the database.
|
|
163
301
|
- `--agents 3` — number of workspaces to create (default: 3, max: 10)
|
|
164
302
|
- `--prefix switchman` — branch name prefix (default: switchman)
|
|
303
|
+
- Writes `.mcp.json` to the repo root and each generated worktree so Claude Code can attach the Switchman MCP server automatically
|
|
165
304
|
|
|
166
305
|
### `switchman init`
|
|
167
306
|
Initialise in the current git repo without creating worktrees. Creates `.switchman/switchman.db` and auto-detects existing worktrees.
|
|
@@ -175,15 +314,32 @@ Add a task to the queue.
|
|
|
175
314
|
List all tasks. Filter with `--status pending|in_progress|done|failed`.
|
|
176
315
|
|
|
177
316
|
### `switchman task next`
|
|
178
|
-
Get and assign the next pending task. Use `--json` for agent automation.
|
|
317
|
+
Get and assign the next pending task. This is a compatibility shim over the lease workflow. Use `--json` for agent automation.
|
|
179
318
|
- `--worktree <name>` — worktree to assign to (defaults to current folder name)
|
|
180
319
|
- `--agent <name>` — agent identifier for logging
|
|
181
320
|
|
|
321
|
+
### `switchman lease next`
|
|
322
|
+
Acquire the next pending task as a first-class lease. Use `--json` for agent automation.
|
|
323
|
+
- `--worktree <name>` — worktree to assign to (defaults to current folder name)
|
|
324
|
+
- `--agent <name>` — agent identifier for logging
|
|
325
|
+
|
|
326
|
+
### `switchman lease list`
|
|
327
|
+
List active and historical leases. Filter with `--status active|completed|failed|expired`.
|
|
328
|
+
|
|
329
|
+
### `switchman lease heartbeat <leaseId>`
|
|
330
|
+
Refresh the heartbeat timestamp for a long-running lease so it does not get treated as stale.
|
|
331
|
+
|
|
332
|
+
### `switchman lease reap`
|
|
333
|
+
Expire stale leases, release their claims, and return their tasks to `pending`.
|
|
334
|
+
- `--stale-after-minutes <n>` — staleness threshold (default: 15)
|
|
335
|
+
|
|
182
336
|
### `switchman task done <taskId>`
|
|
183
|
-
Mark a task complete and release all file claims.
|
|
337
|
+
Mark a task complete and automatically release all file claims.
|
|
338
|
+
When the task has an active lease, Switchman finalises the execution through that lease so provenance stays tied to the live session.
|
|
184
339
|
|
|
185
340
|
### `switchman task fail <taskId>`
|
|
186
|
-
Mark a task failed and release all file claims.
|
|
341
|
+
Mark a task failed and automatically release all file claims.
|
|
342
|
+
When the task has an active lease, Switchman records the failure against that lease so execution history stays lease-first.
|
|
187
343
|
|
|
188
344
|
### `switchman claim <taskId> <worktree> [files...]`
|
|
189
345
|
Lock files before editing. Warns immediately if any file is already claimed by another agent.
|
|
@@ -193,9 +349,10 @@ Release all file claims for a task.
|
|
|
193
349
|
|
|
194
350
|
### `switchman scan`
|
|
195
351
|
Check all worktrees for conflicts — both uncommitted file overlaps and branch-level merge conflicts. Run this before merging.
|
|
352
|
+
By default, common generated paths such as `node_modules/`, `dist/`, `build/`, and `coverage/` are ignored.
|
|
196
353
|
|
|
197
354
|
### `switchman status`
|
|
198
|
-
Full overview: task counts, active
|
|
355
|
+
Full overview: task counts, active leases, stale leases, locked files, a quick conflict scan, and readable failure explanations.
|
|
199
356
|
|
|
200
357
|
### `switchman worktree list`
|
|
201
358
|
List all git worktrees with their registered agents and status.
|
|
@@ -205,6 +362,159 @@ Re-sync git worktrees into the Switchman database (useful if you add worktrees a
|
|
|
205
362
|
|
|
206
363
|
---
|
|
207
364
|
|
|
365
|
+
## Pipelines and PRs
|
|
366
|
+
|
|
367
|
+
Switchman can now take a backlog item through planning, governed execution, review, and PR handoff.
|
|
368
|
+
|
|
369
|
+
### Happy-path pipeline flow
|
|
370
|
+
|
|
371
|
+
```bash
|
|
372
|
+
switchman pipeline start "Harden auth API permissions" \
|
|
373
|
+
--description "Update login permissions for the public API and add migration checks"
|
|
374
|
+
|
|
375
|
+
switchman pipeline exec pipe-123 "/path/to/your-agent-command"
|
|
376
|
+
switchman pipeline status pipe-123
|
|
377
|
+
switchman pipeline pr pipe-123
|
|
378
|
+
switchman pipeline publish pipe-123 --base main --draft
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
The intended operator loop is:
|
|
382
|
+
1. start the pipeline
|
|
383
|
+
2. run it
|
|
384
|
+
3. inspect `pipeline status` if anything blocks
|
|
385
|
+
4. review the PR artifact or publish the PR
|
|
386
|
+
|
|
387
|
+
### Create a pipeline from one issue
|
|
388
|
+
|
|
389
|
+
```bash
|
|
390
|
+
switchman pipeline start "Harden auth API permissions" \
|
|
391
|
+
--description "Update login permissions for the public API and add migration checks"
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
This creates structured subtasks with task specs, dependencies, and suggested worktrees.
|
|
395
|
+
|
|
396
|
+
### Run the pipeline
|
|
397
|
+
|
|
398
|
+
```bash
|
|
399
|
+
switchman pipeline exec pipe-123 "/path/to/your-agent-command"
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
This dispatches dependency-ready tasks, launches agents with `SWITCHMAN_*` task context, applies retries/timeouts from the task spec, and runs review follow-ups until the pipeline is ready or blocked.
|
|
403
|
+
|
|
404
|
+
### Generate a reviewer-facing PR summary
|
|
405
|
+
|
|
406
|
+
```bash
|
|
407
|
+
switchman pipeline pr pipe-123
|
|
408
|
+
switchman pipeline pr pipe-123 --json
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
Use this to inspect the current PR-ready summary, gate results, risk notes, and provenance.
|
|
412
|
+
Completed work provenance now includes the lease that executed the work, not just the task and worktree.
|
|
413
|
+
|
|
414
|
+
### Export a PR bundle
|
|
415
|
+
|
|
416
|
+
```bash
|
|
417
|
+
switchman pipeline bundle pipe-123 .switchman/pr-bundles/auth-hardening
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
This writes:
|
|
421
|
+
|
|
422
|
+
- `pr-summary.json`
|
|
423
|
+
- `pr-summary.md`
|
|
424
|
+
- `pr-body.md`
|
|
425
|
+
|
|
426
|
+
The exported reviewer bundle includes lease-aware provenance, so a reviewer can see which execution session produced each completed task.
|
|
427
|
+
|
|
428
|
+
### Publish a GitHub PR
|
|
429
|
+
|
|
430
|
+
```bash
|
|
431
|
+
switchman pipeline publish pipe-123 --base main --draft
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
This uses `gh pr create` with the generated PR title and body. Requirements:
|
|
435
|
+
|
|
436
|
+
- GitHub CLI (`gh`) installed
|
|
437
|
+
- `gh auth login` already completed
|
|
438
|
+
- the pipeline worktree branch pushed or otherwise available as the PR head branch
|
|
439
|
+
|
|
440
|
+
---
|
|
441
|
+
|
|
442
|
+
## CI and GitHub Actions
|
|
443
|
+
|
|
444
|
+
Switchman can publish CI-friendly gate output and install a ready-to-run GitHub Actions workflow.
|
|
445
|
+
|
|
446
|
+
### Run the repo gate in CI
|
|
447
|
+
|
|
448
|
+
```bash
|
|
449
|
+
switchman gate ci
|
|
450
|
+
switchman gate ci --json
|
|
451
|
+
switchman gate ci --github
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
`switchman gate ci` fails non-zero when the repo contains unmanaged changes, stale compliance problems, or merge-governance issues.
|
|
455
|
+
|
|
456
|
+
When run under GitHub Actions with `--github`, Switchman writes:
|
|
457
|
+
|
|
458
|
+
- a step summary markdown report
|
|
459
|
+
- `GITHUB_OUTPUT` values such as `switchman_ok=true|false`
|
|
460
|
+
|
|
461
|
+
You can also point these explicitly:
|
|
462
|
+
|
|
463
|
+
```bash
|
|
464
|
+
switchman gate ci \
|
|
465
|
+
--github-step-summary /path/to/summary.md \
|
|
466
|
+
--github-output /path/to/output.txt
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
### Install the GitHub Actions workflow
|
|
470
|
+
|
|
471
|
+
```bash
|
|
472
|
+
switchman gate install-ci
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
This writes `.github/workflows/switchman-gate.yml`, which runs the Switchman CI gate on pushes and pull requests.
|
|
476
|
+
|
|
477
|
+
---
|
|
478
|
+
|
|
479
|
+
## Tamper-evident audit trail
|
|
480
|
+
|
|
481
|
+
Switchman now keeps a signed audit trail for governed work.
|
|
482
|
+
|
|
483
|
+
Every audit event is:
|
|
484
|
+
- appended with a monotonic sequence number
|
|
485
|
+
- chained to the previous event with `prev_hash`
|
|
486
|
+
- hashed into its own `entry_hash`
|
|
487
|
+
- signed with a per-project audit key stored at `.switchman/audit.key`
|
|
488
|
+
|
|
489
|
+
That means Switchman can detect if someone edits stored audit history after the fact.
|
|
490
|
+
|
|
491
|
+
### Verify the audit trail
|
|
492
|
+
|
|
493
|
+
```bash
|
|
494
|
+
switchman audit verify
|
|
495
|
+
switchman audit verify --json
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
Use this when you want proof that the recorded history still matches the project audit key and the stored event chain.
|
|
499
|
+
|
|
500
|
+
What a successful verification means:
|
|
501
|
+
- every event is still in the expected sequence
|
|
502
|
+
- every `prev_hash` still matches the prior event
|
|
503
|
+
- every event payload still matches its stored `entry_hash`
|
|
504
|
+
- every signature still matches the project audit key
|
|
505
|
+
|
|
506
|
+
If verification fails, Switchman exits non-zero and reports the reason, for example:
|
|
507
|
+
- `sequence_gap`
|
|
508
|
+
- `prev_hash_mismatch`
|
|
509
|
+
- `entry_hash_mismatch`
|
|
510
|
+
- `signature_mismatch`
|
|
511
|
+
|
|
512
|
+
This is different from normal CI:
|
|
513
|
+
- `switchman gate ci` answers whether the repo is safe and governed right now
|
|
514
|
+
- `switchman audit verify` answers whether the recorded audit history has been tampered with
|
|
515
|
+
|
|
516
|
+
---
|
|
517
|
+
|
|
208
518
|
## MCP tools (Claude Code)
|
|
209
519
|
|
|
210
520
|
| Tool | What it does |
|
|
@@ -214,6 +524,7 @@ Re-sync git worktrees into the Switchman database (useful if you add worktrees a
|
|
|
214
524
|
| `switchman_task_claim` | Claim files before editing (conflict check) |
|
|
215
525
|
| `switchman_task_done` | Mark task complete, release file claims |
|
|
216
526
|
| `switchman_task_fail` | Mark task failed, release file claims |
|
|
527
|
+
| `switchman_lease_heartbeat` | Refresh a long-running lease heartbeat |
|
|
217
528
|
| `switchman_scan` | Scan all worktrees for conflicts |
|
|
218
529
|
| `switchman_status` | Full system overview |
|
|
219
530
|
|
|
@@ -222,7 +533,7 @@ Re-sync git worktrees into the Switchman database (useful if you add worktrees a
|
|
|
222
533
|
## Roadmap
|
|
223
534
|
|
|
224
535
|
- [ ] Merge queue — serialize worktree→main merges with auto-retry
|
|
225
|
-
- [ ]
|
|
536
|
+
- [ ] Automatic stale-lease policies — configurable heartbeat/reap behaviour
|
|
226
537
|
- [ ] Cursor and Windsurf native MCP integration
|
|
227
538
|
- [ ] Web dashboard
|
|
228
539
|
- [ ] `brew install switchman`
|
|
@@ -240,4 +551,4 @@ Building this in public — if you're running parallel agents and hit something
|
|
|
240
551
|
|
|
241
552
|
## License
|
|
242
553
|
|
|
243
|
-
MIT — free to use, modify, and distribute.
|
|
554
|
+
MIT — free to use, modify, and distribute.
|
package/examples/README.md
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
|
package/examples/walkthrough.sh
CHANGED
|
@@ -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
|
|
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
|
|
54
|
+
agent "agent-rate-limiting" "calling: switchman lease next --json"
|
|
55
55
|
echo ""
|
|
56
56
|
|
|
57
|
-
TASK1=$(switchman
|
|
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
|
-
|
|
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
|
|
87
|
+
agent "agent-validation" "calling: switchman lease next --json"
|
|
90
88
|
echo ""
|
|
91
89
|
|
|
92
|
-
TASK2=$(switchman
|
|
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"
|
|
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 " •
|
|
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"
|