@paths.design/caws-cli 10.1.0 → 10.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.
- package/dist/commands/agents.js +124 -0
- package/dist/commands/specs.js +214 -6
- package/dist/commands/status.js +21 -0
- package/dist/commands/worktree.js +134 -18
- package/dist/gates/scope-boundary.js +26 -7
- package/dist/index.js +29 -0
- package/dist/policy/PolicyManager.js +5 -0
- package/dist/templates/.caws/schemas/policy.schema.json +5 -0
- package/dist/templates/.caws/schemas/working-spec.schema.json +2 -2
- package/dist/templates/.claude/rules/worktree-isolation.md +21 -3
- package/dist/templates/CLAUDE.md +22 -0
- package/dist/templates/agents.md +26 -0
- package/dist/utils/agent-display.js +210 -0
- package/dist/utils/agent-session.js +142 -0
- package/dist/validation/spec-validation.js +7 -4
- package/dist/worktree/worktree-manager.js +407 -46
- package/package.json +1 -1
- package/templates/.caws/schemas/policy.schema.json +5 -0
- package/templates/.caws/schemas/working-spec.schema.json +2 -2
- package/templates/.claude/rules/worktree-isolation.md +21 -3
- package/templates/CLAUDE.md +22 -0
- package/templates/agents.md +26 -0
|
@@ -10,9 +10,27 @@ When multiple agents are working on this project, each agent MUST work in its ow
|
|
|
10
10
|
## Before starting work
|
|
11
11
|
|
|
12
12
|
1. Check if worktrees exist: `caws worktree list` shows all active worktrees with last commit time and owner
|
|
13
|
-
2.
|
|
14
|
-
3. If
|
|
15
|
-
4.
|
|
13
|
+
2. Check who's actually working: `caws agents list` shows registered sessions and their bound worktree/spec, formatted as `<sessionId>:<platform>`
|
|
14
|
+
3. If you're inside a worktree, run `caws status` — the Claim panel shows the current owner, last heartbeat, and any session-log path under `tmp/<sessionId>/`
|
|
15
|
+
4. If worktrees are active and you are on the base branch, switch to your assigned worktree
|
|
16
|
+
5. If no worktree exists for you, create one with `caws worktree create <name>` or `caws parallel setup <plan-file>`
|
|
17
|
+
6. **Never touch a worktree you did not create.** Do not destroy, prune, stash, or "clean up" another agent's worktree — even if it looks stale. Another agent may be actively working in it. If you think a worktree is abandoned, leave it alone and let the user decide.
|
|
18
|
+
|
|
19
|
+
## Foreign-claim soft-block
|
|
20
|
+
|
|
21
|
+
`caws worktree bind`, `merge`, and `claim` refuse to mutate a worktree whose `worktrees.json:owner` is a session id different from the current session — unless `--takeover` is supplied. The refusal prints a structured warning naming the claimer, the heartbeat age, any session-log pointer under `tmp/<sessionId>/`, and the exact `--takeover` command:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
Worktree 'wt-foo' is claimed by 8be65780-...:claude-code
|
|
25
|
+
Last heartbeat: 2026-04-27T17:04:00Z (23 min ago)
|
|
26
|
+
Session log: tmp/8be65780-72e0-4fc7-a989-4ebac148c18d
|
|
27
|
+
15 turns, last turn 2026-04-27T17:26:49Z
|
|
28
|
+
To proceed: caws worktree claim wt-foo --takeover
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Decision-gating uses session-id equality only.** A stale heartbeat is NOT authorization to take over — paused sessions are not ended sessions. Read the session log under `tmp/<sessionId>/` for context first. Take over only when you have explicit user authorization.
|
|
32
|
+
|
|
33
|
+
`--takeover` writes a durable `prior_owners` audit on the worktree entry (sessionId, platform, lastSeen-at-takeover, takenOver_at) so the handoff is traceable in `worktrees.json`, not just in agent memory.
|
|
16
34
|
|
|
17
35
|
## Forbidden operations when worktrees are active
|
|
18
36
|
|
package/templates/CLAUDE.md
CHANGED
|
@@ -102,6 +102,12 @@ caws scope show
|
|
|
102
102
|
|
|
103
103
|
# Fix a broken binding
|
|
104
104
|
caws worktree bind <spec-id>
|
|
105
|
+
|
|
106
|
+
# Inspect the agent registry — who is currently working what
|
|
107
|
+
caws agents list
|
|
108
|
+
|
|
109
|
+
# Inspect a specific worktree's claim (read-only by default)
|
|
110
|
+
caws worktree claim <name>
|
|
105
111
|
```
|
|
106
112
|
|
|
107
113
|
**Recovery checklist** (when the scope guard blocks you unexpectedly):
|
|
@@ -110,6 +116,22 @@ caws worktree bind <spec-id>
|
|
|
110
116
|
3. If authoritative but still blocked: the file is genuinely outside your spec's scope. Update your spec's `scope.in` if the file should be in scope, or request a waiver
|
|
111
117
|
4. Do NOT modify another spec's `scope.out` to unblock yourself — that defeats the isolation
|
|
112
118
|
|
|
119
|
+
### Agent Claims & Multi-Agent Coordination
|
|
120
|
+
|
|
121
|
+
Each session gets registered in `.caws/agents.json` automatically (via the session-log hook and on every CAWS lifecycle CLI invocation). Worktree session ownership is tracked in `.caws/worktrees.json:owner` as a session id.
|
|
122
|
+
|
|
123
|
+
`caws worktree bind`, `merge`, and `claim` will refuse to mutate a worktree owned by a different session id without explicit `--takeover`. The refusal prints a structured warning naming the claimer as `<sessionId>:<platform>`, the heartbeat age, and any matching `tmp/<sessionId>/` session-log path so you can read context before deciding.
|
|
124
|
+
|
|
125
|
+
**Decision-gating uses session-id equality only.** TTL pruning of `agents.json` is registry hygiene; it does NOT authorize takeover. A stale heartbeat doesn't mean the prior session is dead — it may be paused.
|
|
126
|
+
|
|
127
|
+
`--takeover` writes a durable `prior_owners` audit on the worktree entry (sessionId, platform, lastSeen-at-takeover, takenOver_at) so handoffs are traceable in `worktrees.json`, not just in agent memory.
|
|
128
|
+
|
|
129
|
+
### Spec lifecycle: archive
|
|
130
|
+
|
|
131
|
+
Use `caws specs archive <id>` to move a closed spec to the canonical `.caws/specs/.archive/` directory. The directory is filesystem-authoritative — `caws specs list` reports any file under `.archive/` as `status: archived` regardless of the YAML literal. This means manually-moved legacy specs (no registry entry) are correctly classified.
|
|
132
|
+
|
|
133
|
+
If you try to `caws specs create <id>` for an id that already exists in `.archive/`, the command refuses without `--force`. With `--force`, the archived YAML is removed and a fresh draft is created — useful for resurrecting an old id with new intent.
|
|
134
|
+
|
|
113
135
|
> **Budget note**: `change_budget:` in a spec is informational documentation only. CAWS
|
|
114
136
|
> derives the enforced budget from `policy.yaml` keyed on `risk_tier`. The field in the
|
|
115
137
|
> spec is not used by `caws validate` for enforcement.
|
package/templates/agents.md
CHANGED
|
@@ -59,6 +59,32 @@ caws worktree bind <spec-id>
|
|
|
59
59
|
3. If authoritative but blocked: update your spec's `scope.in`
|
|
60
60
|
4. Do NOT edit another spec's `scope.out` to unblock yourself
|
|
61
61
|
|
|
62
|
+
## Multi-Agent Claims
|
|
63
|
+
|
|
64
|
+
Each session is registered in `.caws/agents.json` automatically. Worktree session ownership is recorded in `.caws/worktrees.json:owner` as a session id. `caws worktree bind`, `merge`, and `claim` will refuse to mutate a worktree owned by a different session id without `--takeover`.
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# See registered agents (composite <sessionId>:<platform> format)
|
|
68
|
+
caws agents list
|
|
69
|
+
|
|
70
|
+
# Inspect a worktree's claim — read-only by default
|
|
71
|
+
caws worktree claim <name>
|
|
72
|
+
|
|
73
|
+
# Take over a foreign claim (writes prior_owners audit)
|
|
74
|
+
caws worktree claim <name> --takeover
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
When a refusal fires, the warning includes the claimer's session id, heartbeat age, and a pointer to any `tmp/<sessionId>/` session-log directory — read that log for context before deciding to take over. A stale heartbeat does NOT mean the prior session is dead; it may be paused.
|
|
78
|
+
|
|
79
|
+
## Spec Lifecycle: Archive
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Move a closed spec to the canonical archive
|
|
83
|
+
caws specs archive <spec-id>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
The `.caws/specs/.archive/` directory is filesystem-authoritative — `caws specs list` reports any file under it as `archived` regardless of YAML status. `caws specs create` refuses ids that collide with archived files unless `--force` is supplied (which removes the archived copy and writes a fresh draft).
|
|
87
|
+
|
|
62
88
|
## Key Rules
|
|
63
89
|
|
|
64
90
|
1. **Stay in scope** -- only edit files listed in `scope.in`, never touch `scope.out`
|