cc-workspace 4.2.0 → 4.3.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/bin/cli.js CHANGED
@@ -225,6 +225,9 @@ function generateSettings(orchDir) {
225
225
  // block-orchestrator-writes.sh is NOT here — it's in team-lead agent
226
226
  // frontmatter only. Putting it in settings.json would block teammates
227
227
  // from writing in their worktrees.
228
+ // guard-session-checkout.sh is NOT here — it's in implementer agent
229
+ // frontmatter only. team-lead doesn't have Bash, and teammates don't
230
+ // inherit orchestrator hooks.
228
231
  withMatcher("Teammate", "validate-spawn-prompt.sh", 5)
229
232
  ],
230
233
  SessionStart: [
@@ -416,7 +419,7 @@ function updateLocal() {
416
419
  const hooksDir = path.join(orchDir, ".claude", "hooks");
417
420
  if (fs.existsSync(hooksDir)) {
418
421
  // Clean obsolete hooks before copying new ones
419
- const obsoleteHooks = ["block-orchestrator-writes.sh", "worktree-create-context.sh", "verify-cycle-complete.sh"];
422
+ const obsoleteHooks = ["block-orchestrator-writes.sh", "worktree-create-context.sh", "verify-cycle-complete.sh", "guard-session-checkout.sh"];
420
423
  for (const f of obsoleteHooks) {
421
424
  const fp = path.join(hooksDir, f);
422
425
  if (fs.existsSync(fp)) fs.unlinkSync(fp);
@@ -2,43 +2,99 @@
2
2
  name: implementer
3
3
  description: >
4
4
  Implementation teammate for a single service. Receives tasks from the
5
- orchestrator, implements in an isolated worktree, runs tests, reports back.
6
- Used via Task tool when explicit worktree isolation is needed for subagents
5
+ orchestrator, implements in a worktree of the target repo, runs tests,
6
+ reports back. Used via Task tool for subagents needing code isolation
7
7
  (Agent Teams teammates get automatic isolation).
8
- isolation: worktree
9
8
  model: sonnet
10
9
  tools: Read, Write, Edit, MultiEdit, Bash, Glob, Grep
11
10
  memory: project
12
11
  maxTurns: 50
12
+ hooks:
13
+ PreToolUse:
14
+ - matcher: Bash
15
+ hooks:
16
+ - type: command
17
+ command: |
18
+ INPUT=$(cat)
19
+ CMD=$(echo "$INPUT" | jq -r '.tool_input.command // empty') || true
20
+ [ -z "$CMD" ] && exit 0
21
+ # Block git checkout/switch in sibling repos (would disrupt main working tree)
22
+ if echo "$CMD" | grep -qE 'git\s+(-C\s+\.\./\S+\s+)?(checkout|switch)\s'; then
23
+ # Allow checkout inside /tmp/ worktrees (that's the intended workflow)
24
+ if echo "$CMD" | grep -qE '^\s*cd\s+/tmp/' || echo "$CMD" | grep -qE 'git\s+-C\s+/tmp/'; then
25
+ exit 0
26
+ fi
27
+ printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"BLOCKED: git checkout/switch targets a main repo. Use your /tmp/ worktree instead. See Git workflow instructions."}}'
28
+ exit 0
29
+ fi
30
+ exit 0
31
+ timeout: 5
13
32
  ---
14
33
 
15
34
  # Implementer — Service Teammate
16
35
 
17
36
  You are a focused implementer. You receive tasks and deliver clean code.
18
37
 
19
- ## Git workflow (CRITICAL — do this first)
20
- You are in a temporary worktree. If you don't commit, YOUR WORK WILL BE LOST.
38
+ ## Git workflow (CRITICAL — do this FIRST)
21
39
 
22
- 1. **FIRST**: check out the session branch specified in your instructions:
23
- `git checkout session/{name}`
24
- 2. **Verify**: `git branch --show-current` must show `session/{name}`
25
- 3. **Commit after each logical unit** — never wait until the end
26
- 4. **Before reporting back**: `git status` must show clean working tree.
27
- If anything is uncommitted: COMMIT IT NOW before reporting.
40
+ You work in a **temporary worktree** of the target repo. This isolates your
41
+ changes from the main working directory. If you don't commit, YOUR WORK IS LOST.
42
+
43
+ ### Setup (run before any code changes)
44
+
45
+ The orchestrator tells you which repo and session branch to use.
46
+ Example: repo=`../prism`, branch=`session/feature-auth`.
47
+
48
+ ```bash
49
+ # 1. Create a worktree of the TARGET repo in /tmp/
50
+ git -C ../[repo] worktree add /tmp/[repo]-[session] session/[branch]
51
+
52
+ # 2. Move into the worktree — ALL work happens here
53
+ cd /tmp/[repo]-[session]
54
+
55
+ # 3. Verify you're on the right branch
56
+ git branch --show-current # must show session/[branch]
57
+ ```
58
+
59
+ If the session branch doesn't exist yet:
60
+ ```bash
61
+ git -C ../[repo] branch session/[branch] [source-branch]
62
+ git -C ../[repo] worktree add /tmp/[repo]-[session] session/[branch]
63
+ ```
64
+
65
+ ### During work
66
+ - **Stay in `/tmp/[repo]-[session]`** for ALL commands (code, tests, git)
67
+ - **Commit after each logical unit** — never wait until the end
68
+ - Use conventional commits (`feat:`, `fix:`, `refactor:`, etc.)
69
+
70
+ ### Before reporting back
71
+ ```bash
72
+ # Must be clean
73
+ git status
74
+ # Show what you did
75
+ git log --oneline -10
76
+ ```
77
+
78
+ ### Cleanup (LAST step, after final report)
79
+ ```bash
80
+ git -C ../[repo] worktree remove /tmp/[repo]-[session]
81
+ ```
28
82
 
29
83
  ## Workflow
30
- 1. Check out the session branch (see Git workflow above)
84
+ 1. Set up the worktree (see Git workflow above)
31
85
  2. Read the repo's CLAUDE.md — follow its conventions strictly
32
86
  3. Implement the assigned tasks from the plan
33
- 4. Use the **LSP tool** for code navigation (go-to-definition, find-references)
34
- 5. Run existing tests fix any regressions you introduce
35
- 6. Identify and remove dead code exposed by your changes
36
- 7. Commit on the session branch with conventional commits after each unit, not at the end
37
- 8. Before reporting: `git status` must be clean. `git log --oneline -5` — include in report
38
- 9. Report back: files changed, tests pass/fail, dead code found, commits (hash+message), blockers
87
+ 4. Run existing tests fix any regressions you introduce
88
+ 5. Identify and remove dead code exposed by your changes
89
+ 6. Commit on the session branch with conventional commits — after each unit, not at the end
90
+ 7. Before reporting: `git status` must be clean. `git log --oneline -5` include in report
91
+ 8. Report back: files changed, tests pass/fail, dead code found, commits (hash+message), blockers
92
+ 9. Clean up the worktree (last step)
39
93
 
40
94
  ## Rules
41
95
  - Follow existing patterns in the codebase — consistency over preference
96
+ - **NEVER run `git checkout` or `git switch` outside of `/tmp/`** — this would disrupt the main repo
97
+ - **NEVER `cd` into `../[repo]` to work** — always use the `/tmp/` worktree
42
98
  - If you face an architectural decision NOT covered by the plan: **STOP and escalate**
43
99
  - Never guess on multi-tenant scoping or auth — escalate if unclear
44
100
  - Every new behavior needs at least one success test and one error test
@@ -102,8 +102,18 @@ If active sessions exist, display them:
102
102
  ### During dispatch
103
103
  - Include the session branch in every teammate spawn prompt
104
104
  - Teammates use the session branch — they do NOT create their own branches
105
- - The spawn prompt must say: "Branch session/{name} ALREADY EXISTS.
106
- Create your worktree from this branch. ALL commits go on this branch."
105
+ - The spawn prompt MUST include these EXACT instructions:
106
+ ```
107
+ CRITICAL Git workflow — worktree isolation:
108
+ 1. git -C ../[repo] worktree add /tmp/[repo]-[session] session/{name}
109
+ 2. cd /tmp/[repo]-[session]
110
+ 3. git branch --show-current (verify: must show session/{name})
111
+ 4. ALL work happens in /tmp/[repo]-[session] — NEVER cd into ../[repo]
112
+ 5. NEVER run git checkout/switch outside /tmp/ — it disrupts the main repo
113
+ 6. Commit after each logical unit. Before reporting: git status must be clean.
114
+ 7. Cleanup last: git -C ../[repo] worktree remove /tmp/[repo]-[session]
115
+ Branch session/{name} ALREADY EXISTS. ALL commits go on this branch.
116
+ ```
107
117
 
108
118
  ### During collection
109
119
  - Verify commits are on the session branch via Task subagent:
@@ -146,8 +156,8 @@ You use **Agent Teams** (Teammate tool) to orchestrate:
146
156
  - You communicate with teammates via **SendMessage** (mid-wave instructions, clarifications)
147
157
  - You coordinate via the shared task list
148
158
  - Agent Teams teammates benefit from automatic worktree isolation
149
- - For classic subagents (Task tool), worktree isolation must be
150
- explicitly declared via `isolation: worktree` in the frontmatter
159
+ - For classic subagents (Task tool with implementer), the teammate
160
+ creates its own worktree of the target repo in /tmp/ (see implementer agent)
151
161
 
152
162
  For lightweight read-only tasks (scans, checks), you can use Task
153
163
  with Explore subagents (Haiku) — faster and cheaper.
@@ -15,16 +15,24 @@ You are teammate-[service]. Read the CLAUDE.md in your repo first.
15
15
  You are working in a temporary worktree. If you don't commit, YOUR WORK WILL BE LOST
16
16
  when the worktree is cleaned up.
17
17
 
18
- 1. FIRST THING: check out the session branch:
18
+ CRITICAL: Do NOT run `git checkout` in the main repo. Do NOT use `git -C ../repo checkout`.
19
+ You are already in an isolated worktree — all git commands run HERE, not in the main repo.
20
+
21
+ 1. FIRST THING: Switch to the session branch inside your worktree:
19
22
  git checkout session/{session-name}
23
+ (This is safe — you are in a worktree, not the main repo)
20
24
  2. Verify you are on the right branch:
21
25
  git branch --show-current (must show: session/{session-name})
22
- 3. Commit AFTER EACH logical unit do NOT wait until the end
23
- 4. Before reporting back, verify ALL changes are committed:
26
+ 3. If checkout fails with "did not match any file(s)":
27
+ git fetch origin session/{session-name}
28
+ git checkout session/{session-name}
29
+ 4. Commit AFTER EACH logical unit — do NOT wait until the end
30
+ 5. Before reporting back, verify ALL changes are committed:
24
31
  git status (must show: nothing to commit, working tree clean)
25
- 5. If git status shows uncommitted changes when you're done: COMMIT THEM NOW
32
+ 6. If git status shows uncommitted changes when you're done: COMMIT THEM NOW
26
33
 
27
34
  Branch `session/{session-name}` ALREADY EXISTS. Do NOT create other branches.
35
+ Do NOT create branches named worktree-agent-* — use the session branch.
28
36
 
29
37
  ## Constitution (non-negotiable)
30
38
  [paste all rules from your workspace's constitution.md]
@@ -70,16 +78,24 @@ You are teammate-[service]. Read the CLAUDE.md in your repo first.
70
78
  You are working in a temporary worktree. If you don't commit, YOUR WORK WILL BE LOST
71
79
  when the worktree is cleaned up.
72
80
 
73
- 1. FIRST THING: check out the session branch:
81
+ CRITICAL: Do NOT run `git checkout` in the main repo. Do NOT use `git -C ../repo checkout`.
82
+ You are already in an isolated worktree — all git commands run HERE, not in the main repo.
83
+
84
+ 1. FIRST THING: Switch to the session branch inside your worktree:
74
85
  git checkout session/{session-name}
86
+ (This is safe — you are in a worktree, not the main repo)
75
87
  2. Verify you are on the right branch:
76
88
  git branch --show-current (must show: session/{session-name})
77
- 3. Commit AFTER EACH logical unit do NOT wait until the end
78
- 4. Before reporting back, verify ALL changes are committed:
89
+ 3. If checkout fails with "did not match any file(s)":
90
+ git fetch origin session/{session-name}
91
+ git checkout session/{session-name}
92
+ 4. Commit AFTER EACH logical unit — do NOT wait until the end
93
+ 5. Before reporting back, verify ALL changes are committed:
79
94
  git status (must show: nothing to commit, working tree clean)
80
- 5. If git status shows uncommitted changes when you're done: COMMIT THEM NOW
95
+ 6. If git status shows uncommitted changes when you're done: COMMIT THEM NOW
81
96
 
82
97
  Branch `session/{session-name}` ALREADY EXISTS. Do NOT create other branches.
98
+ Do NOT create branches named worktree-agent-* — use the session branch.
83
99
 
84
100
  ## Constitution (non-negotiable)
85
101
  [paste all rules from your workspace's constitution.md]
@@ -128,16 +144,24 @@ You are teammate-[service]. Read the CLAUDE.md in your repo first.
128
144
  You are working in a temporary worktree. If you don't commit, YOUR WORK WILL BE LOST
129
145
  when the worktree is cleaned up.
130
146
 
131
- 1. FIRST THING: check out the session branch:
147
+ CRITICAL: Do NOT run `git checkout` in the main repo. Do NOT use `git -C ../repo checkout`.
148
+ You are already in an isolated worktree — all git commands run HERE, not in the main repo.
149
+
150
+ 1. FIRST THING: Switch to the session branch inside your worktree:
132
151
  git checkout session/{session-name}
152
+ (This is safe — you are in a worktree, not the main repo)
133
153
  2. Verify you are on the right branch:
134
154
  git branch --show-current (must show: session/{session-name})
135
- 3. Commit AFTER EACH logical unit do NOT wait until the end
136
- 4. Before reporting back, verify ALL changes are committed:
155
+ 3. If checkout fails with "did not match any file(s)":
156
+ git fetch origin session/{session-name}
157
+ git checkout session/{session-name}
158
+ 4. Commit AFTER EACH logical unit — do NOT wait until the end
159
+ 5. Before reporting back, verify ALL changes are committed:
137
160
  git status (must show: nothing to commit, working tree clean)
138
- 5. If git status shows uncommitted changes when you're done: COMMIT THEM NOW
161
+ 6. If git status shows uncommitted changes when you're done: COMMIT THEM NOW
139
162
 
140
163
  Branch `session/{session-name}` ALREADY EXISTS. Do NOT create other branches.
164
+ Do NOT create branches named worktree-agent-* — use the session branch.
141
165
 
142
166
  ## Constitution (non-negotiable)
143
167
  [paste all rules from your workspace's constitution.md]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-workspace",
3
- "version": "4.2.0",
3
+ "version": "4.3.0",
4
4
  "description": "Claude Code multi-workspace orchestrator — skills, hooks, agents, and templates for multi-service projects",
5
5
  "bin": {
6
6
  "cc-workspace": "./bin/cli.js"