switchman-dev 0.1.7 → 0.1.8

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.
@@ -0,0 +1,26 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - name: Check out repo
14
+ uses: actions/checkout@v4
15
+
16
+ - name: Set up Node
17
+ uses: actions/setup-node@v4
18
+ with:
19
+ node-version: '22'
20
+ cache: 'npm'
21
+
22
+ - name: Install dependencies
23
+ run: npm install
24
+
25
+ - name: Run test suite
26
+ run: npm test
package/CHANGELOG.md ADDED
@@ -0,0 +1,36 @@
1
+ # Changelog
2
+
3
+ All notable changes to Switchman will be documented in this file.
4
+
5
+ The format is based on Keep a Changelog, adapted for the project’s current stage.
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.1.7] - 2026-03-13
10
+
11
+ ### Added
12
+ - plan-aware merge queue execution with merge budgets
13
+ - clearer first-run guidance in `switchman setup`, `switchman demo`, and `switchman status`
14
+ - richer queue planning, stale-wave handling, policy evidence, and governed landing documentation
15
+ - CI workflow for running the test suite on pushes and pull requests
16
+
17
+ ### Changed
18
+ - `switchman status` now leads with a simpler summary, top attention item, and one exact next command
19
+ - `switchman queue status` no longer crashes on an empty queue summary shape
20
+ - `switchman setup` now re-registers existing worktrees cleanly without leaking raw git branch-exists noise
21
+ - CLI output now suppresses the noisy Node SQLite experimental warning on normal happy-path runs
22
+
23
+ ### Fixed
24
+ - broken install docs that pointed at the org name instead of the package name
25
+ - queue status regression found in manual smoke testing before publish
26
+
27
+ ## [0.1.6] - 2026-03-12
28
+
29
+ ### Added
30
+ - stronger governed landing flows, recovery loops, and PR/CI handoff
31
+ - policy-aware planning, policy evidence, and landing enforcement
32
+ - stale cluster grouping, stale-wave reasoning, and richer operator explainability
33
+ - synthetic landing branches, refresh, recover, resume, and cleanup
34
+
35
+ ### Changed
36
+ - the core product moved from basic coordination toward governed parallel delivery
package/CLAUDE.md ADDED
@@ -0,0 +1,113 @@
1
+ # Switchman Agent Instructions
2
+
3
+ This repository uses **Switchman** to coordinate parallel AI coding agents.
4
+ You MUST follow these instructions every session to avoid conflicting with other agents.
5
+
6
+ You must use the Switchman MCP tools for coordination. Do not read from or write to `.switchman/switchman.db` directly, and do not bypass Switchman by issuing raw SQLite queries.
7
+
8
+ ---
9
+
10
+ ## Your worktree
11
+
12
+ Find your worktree name by running:
13
+ ```bash
14
+ git worktree list
15
+ ```
16
+ The path that matches your current directory is your worktree. Use the last path segment as your worktree name (e.g. `/projects/myapp-feature-auth` → `feature-auth`). The main repo root is always named `main`.
17
+
18
+ ---
19
+
20
+ ## Required workflow — follow this every session
21
+
22
+ ### 1. Start of session — get your task
23
+
24
+ Call the `switchman_task_next` MCP tool with your worktree name:
25
+ ```
26
+ switchman_task_next({ worktree: "<your-worktree-name>", agent: "claude-code" })
27
+ ```
28
+
29
+ - If `task` is `null` — the queue is empty. Ask the user what to work on, or stop.
30
+ - If you receive a task — note the `task.id`. You'll need it in the next steps.
31
+ - If the `switchman_*` tools are unavailable, stop and tell the user the MCP server is not connected. Do not fall back to direct SQLite access.
32
+
33
+ ### 2. Before editing any files — claim them
34
+
35
+ Call `switchman_task_claim` with every file you plan to edit **before you edit them**:
36
+ ```
37
+ switchman_task_claim({
38
+ task_id: "<task-id>",
39
+ worktree: "<your-worktree-name>",
40
+ files: ["src/auth/login.js", "tests/auth.test.js"]
41
+ })
42
+ ```
43
+
44
+ - If `safe_to_proceed` is `false` — there are conflicts. Do NOT edit those files.
45
+ Read the `conflicts` array to see which worktrees own them, then either:
46
+ - Choose different files that accomplish the same goal
47
+ - Ask the user how to proceed
48
+
49
+ - If `safe_to_proceed` is `true` — you are clear to edit.
50
+
51
+ ### 3. Do the work
52
+
53
+ Implement the task. Make commits as normal. Other agents will avoid your claimed files.
54
+
55
+ If you discover mid-task that you need to edit additional files, call `switchman_task_claim` again for those files before editing them.
56
+
57
+ When MCP write tools are available, prefer the Switchman enforcement gateway over native file writes:
58
+ ```text
59
+ switchman_write_file(...)
60
+ switchman_append_file(...)
61
+ switchman_make_directory(...)
62
+ switchman_move_path(...)
63
+ switchman_remove_path(...)
64
+ ```
65
+
66
+ These tools validate your active lease and claimed paths before changing the filesystem. Use native file writes only when the Switchman write tools are unavailable and you have already claimed the path.
67
+
68
+ ### 4. End of session — mark complete or failed
69
+
70
+ **On success:**
71
+ ```
72
+ switchman_task_done({ task_id: "<task-id>" })
73
+ ```
74
+
75
+ **On failure (can't complete the task):**
76
+ ```
77
+ switchman_task_fail({ task_id: "<task-id>", reason: "Brief explanation of what blocked you" })
78
+ ```
79
+
80
+ Always call one of these before ending your session. Released file claims allow other agents to proceed.
81
+
82
+ ---
83
+
84
+ ## Checking for conflicts
85
+
86
+ At any time you can scan for conflicts across all worktrees:
87
+ ```
88
+ switchman_scan()
89
+ ```
90
+
91
+ Run this before merging your branch. If `safe_to_proceed` is `false`, do not merge until conflicts are resolved.
92
+
93
+ ---
94
+
95
+ ## Checking system state
96
+
97
+ To see what other agents are doing:
98
+ ```
99
+ switchman_status()
100
+ ```
101
+
102
+ This shows all pending and in-progress tasks, file claims per worktree, and worktree list.
103
+
104
+ ---
105
+
106
+ ## Rules
107
+
108
+ 1. **Always claim files before editing them** — not after.
109
+ 2. **Always call `switchman_task_done` or `switchman_task_fail` at end of session** — never leave tasks as `in_progress` when you stop.
110
+ 3. **If `safe_to_proceed` is false, do not edit the conflicting files** — coordinate first.
111
+ 4. **Do not claim files you don't need** — over-claiming blocks other agents unnecessarily.
112
+ 5. **One task per session** — complete or fail your current task before taking another.
113
+ 6. **Never query or mutate the Switchman SQLite database directly** — use MCP tools only.
package/README.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  **Run 10+ agents on one codebase. Safely.**
4
4
 
5
+ [![CI](https://github.com/switchman-dev/switchman/actions/workflows/ci.yml/badge.svg)](https://github.com/switchman-dev/switchman/actions/workflows/ci.yml)
6
+ [![npm version](https://img.shields.io/npm/v/switchman-dev.svg)](https://www.npmjs.com/package/switchman-dev)
7
+
5
8
  Switchman is the coordination and governance layer for AI-native software teams. It helps you plan work, route tasks across agents, prevent overlap, and land changes safely instead of stitching parallel output back together by hand.
6
9
 
7
10
  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, policy gates, queue planning, and governed landing workflows so they can move in parallel without stepping on each other.
@@ -16,8 +19,16 @@ Requirements:
16
19
  - Node.js 22.5+
17
20
  - Git 2.5+
18
21
 
22
+ Why Node 22.5+?
23
+ - Switchman uses the built-in `node:sqlite` runtime support for its repo-local coordination database.
24
+ - Keeping that dependency in the Node runtime makes install and recovery simpler, but it currently means targeting newer Node releases on purpose.
25
+
26
+ TypeScript and API surface
27
+ - Switchman is CLI-first today. The supported interface is the `switchman` command and the MCP integration, not a stable embeddable library API yet.
28
+ - That means there are no published TypeScript types right now by design. We plan to add typed surfaces once the programmatic API is stable enough to support cleanly.
29
+
19
30
  ```bash
20
- npm install -g @switchman-dev
31
+ npm install -g switchman-dev
21
32
  ```
22
33
 
23
34
  ## 2 minute proof
@@ -84,22 +95,20 @@ Recommended first run:
84
95
 
85
96
  ```bash
86
97
  cd my-project
87
- switchman setup --agents 5
88
- switchman verify-setup
89
-
98
+ switchman demo
99
+ switchman setup --agents 3
90
100
  switchman task add "Implement auth helper" --priority 9
91
- switchman task add "Add auth tests" --priority 8
92
- switchman task add "Update auth docs" --priority 7
93
-
94
- switchman status
95
101
  switchman status --watch
96
102
  switchman gate ci
103
+ switchman queue run
97
104
  ```
98
105
 
99
- If you only do three things on the first run, do these:
100
- 1. `switchman setup --agents 5`
101
- 2. `switchman task add "Implement auth helper" --priority 9`
102
- 3. `switchman status --watch`
106
+ If you only do five things on the first run, do these:
107
+ 1. `switchman demo`
108
+ 2. `switchman setup --agents 3`
109
+ 3. `switchman task add "Implement auth helper" --priority 9`
110
+ 4. `switchman status --watch`
111
+ 5. `switchman gate ci && switchman queue run`
103
112
 
104
113
  What `switchman setup` gives you:
105
114
  - one shared Switchman database in `.switchman/`
@@ -113,14 +122,18 @@ Fastest path to success:
113
122
  1. Use Claude Code for the first run.
114
123
  2. Run `switchman verify-setup` once so editor wiring is confirmed before you start.
115
124
  3. Open one Claude Code window per generated workspace.
116
- 4. Let each agent pick up one clearly separate task.
117
- 5. Keep `switchman status --watch` open in another terminal.
118
- 6. Run `switchman gate ci` when the tasks finish.
125
+ 4. Add clear tasks before the agents start.
126
+ 5. Let each agent pick up one clearly separate task.
127
+ 6. Keep `switchman status --watch` open in another terminal.
128
+ 7. Run `switchman gate ci`, then `switchman queue run`, when the tasks finish.
119
129
 
120
130
  If you want the recommended editor setup guide, start here:
121
131
  - [Claude Code setup](docs/setup-claude-code.md)
122
132
 
123
133
  If you want a guided demo, see [examples/README.md](examples/README.md).
134
+ If you want the deeper multi-task planning and PR workflow, see [docs/pipelines.md](docs/pipelines.md).
135
+
136
+ > Free tier supports up to 3 agents. Run `switchman upgrade` for unlimited.
124
137
 
125
138
  ## What good looks like
126
139
 
@@ -136,10 +149,21 @@ That is the moment Switchman should feel different from “just using a few bran
136
149
 
137
150
  If you are trying to decide where to start:
138
151
  - want the fastest proof: run `switchman demo`
139
- - want to wire up a real repo: run `switchman setup --agents 5`
152
+ - want to wire up a real repo: run `switchman setup --agents 3`
153
+ - want to add real work: run `switchman task add "Your task" --priority 8`
140
154
  - want to understand blocked or stale work: run `switchman status`
141
155
  - want a longer hands-on walkthrough: open [examples/README.md](examples/README.md)
142
156
 
157
+ ## Enforcement Gateway
158
+
159
+ Switchman is strongest when agents write through the governed gateway instead of editing files directly.
160
+
161
+ - MCP agents should prefer `switchman_write_file`, `switchman_append_file`, `switchman_make_directory`, `switchman_move_path`, and `switchman_remove_path`
162
+ - CLI operators can use `switchman write` and `switchman wrap` for governed writes and wrapped commands
163
+ - `switchman monitor` is started automatically by `switchman setup` unless you opt out, so rogue edits are detected in the background
164
+
165
+ That closes the gap between "please follow the claiming protocol" and "Switchman can actually catch ungoverned writes when something goes wrong."
166
+
143
167
  ## The Workflow
144
168
 
145
169
  Switchman is built for the workflow of turning multiple competing engineering goals into coordinated parallel execution and a trusted, dependency-aware path to merge.
@@ -217,6 +241,96 @@ They do not tell you:
217
241
 
218
242
  Switchman is for the point where “we can manage this by hand” stops being true.
219
243
 
244
+ ## Safety note on `--force`
245
+
246
+ `switchman claim --force` exists for manual recovery, not normal operation.
247
+
248
+ Legitimate use:
249
+ - you have already confirmed the conflicting claim is stale, abandoned, or otherwise incorrect
250
+ - you are performing operator-led cleanup and need to unblock the repo deliberately
251
+
252
+ Not a legitimate use:
253
+ - "the other agent is probably done"
254
+ - "I just want to keep moving"
255
+ - "we'll clean it up in the PR later"
256
+
257
+ Normal path:
258
+ 1. run `switchman status`
259
+ 2. run `switchman explain claim <path>`
260
+ 3. reap or retry the stale work if needed
261
+ 4. only then use `--force` if you intentionally want to override a known-bad claim
262
+
263
+ If that feels too risky, that is the point. It is meant to be an escape hatch, not a convenience flag.
264
+
265
+ ## Releases and changelog
266
+
267
+ If you want to track what changed between versions:
268
+ - [CHANGELOG.md](CHANGELOG.md)
269
+ - [GitHub releases](https://github.com/switchman-dev/switchman/releases)
270
+
271
+ ## What's included today
272
+
273
+ Today Switchman already includes:
274
+ - agent worktree setup and repo verification
275
+ - lease, claim, heartbeat, and stale-reap coordination
276
+ - governed write gateways and a rogue-edit monitor
277
+ - repo status, repair, queue planning, and safe landing
278
+ - pipeline planning, execution, PR bundles, and GitHub sync
279
+ - audit trail, change policy enforcement, and CI integration
280
+ - MCP support for Claude Code, Cursor, and Windsurf
281
+
282
+ ## Switchman Pro
283
+
284
+ Pro gives you unlimited agents, cloud-synced team coordination, and 90-day history.
285
+
286
+ ```bash
287
+ switchman upgrade # open switchman.dev/pro in your browser
288
+ switchman login # activate Pro after subscribing
289
+ switchman login --status # check your current plan
290
+ ```
291
+
292
+ **What's included in Pro:**
293
+ - Unlimited concurrent agents (free tier: up to 3)
294
+ - Cloud-synced task queues and lease state across your team
295
+ - Team invites — `switchman team invite alice@example.com`
296
+ - AI task planning — `switchman plan "Add authentication"` proposes parallel tasks from an explicit goal
297
+ - 90-day audit trail (free tier: 7 days)
298
+ - Email support within 48 hours
299
+
300
+ **Pricing:** $25/month or $250/year per seat · [switchman.dev/pro](https://switchman.dev/pro)
301
+
302
+ After subscribing, activate in your terminal:
303
+ ```bash
304
+ switchman login
305
+ # Opens GitHub sign-in, saves credentials locally
306
+ # Credentials cached 24h · works offline for 7 days
307
+
308
+ switchman setup --agents 10
309
+ # Pro removes the 3-agent limit
310
+ ```
311
+
312
+ ### Pro planning launch order
313
+
314
+ Switchman Pro planning ships in this order:
315
+ - `switchman plan "goal"` first
316
+ - `switchman plan --issue 47` next
317
+ - zero-argument `switchman plan` later, once real usage data makes that inference trustworthy
318
+
319
+ Today, the supported Pro planning flow is:
320
+
321
+ ```bash
322
+ switchman plan "Add authentication"
323
+ switchman plan "Add authentication" --apply
324
+ ```
325
+
326
+ ## What's next
327
+
328
+ The next product steps are:
329
+ - `switchman plan --issue 47`
330
+ - a more magical zero-argument planning flow that can read richer repo and issue context
331
+ - a web dashboard for repo and landing visibility
332
+ - a Homebrew install path for faster first-run setup
333
+
220
334
  ## Choose your setup
221
335
 
222
336
  Pick the guide that matches how you work:
@@ -45,12 +45,19 @@ Good rule of thumb:
45
45
  - want the 2-minute proof: `switchman demo`
46
46
  - want the 5-10 minute “how would a team actually use this?” version: use `examples/`
47
47
 
48
- Make sure Switchman is installed globally first:
48
+ Make sure Switchman is installed globally first.
49
+
50
+ If you cloned the Switchman repo:
49
51
  ```bash
50
52
  npm install -g . # from the switchman repo root
51
53
  ```
52
54
 
53
- Then from the switchman repo root:
55
+ If you installed from npm instead:
56
+ ```bash
57
+ cd "$(npm root -g)/switchman-dev"
58
+ ```
59
+
60
+ Then from the Switchman package root:
54
61
  ```bash
55
62
  bash examples/setup.sh
56
63
  bash examples/demo.sh
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "switchman-dev",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Project manager for AI coding assistants running safely on one codebase",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -17,11 +17,16 @@
17
17
  "mcp": "node src/mcp/server.js",
18
18
  "test": "NODE_NO_WARNINGS=1 node tests/test.js"
19
19
  },
20
+ "engines": {
21
+ "node": ">=22.5.0"
22
+ },
20
23
  "dependencies": {
24
+ "@anthropic-ai/sdk": "^0.78.0",
21
25
  "@modelcontextprotocol/sdk": "^1.27.1",
22
26
  "chalk": "^5.3.0",
23
27
  "commander": "^12.0.0",
24
28
  "node-sqlite3-wasm": "^0.8.35",
29
+ "open": "^11.0.0",
25
30
  "ora": "^8.0.1",
26
31
  "zod": "^4.3.6"
27
32
  },