cc-workspace 4.2.0 → 4.2.1

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,7 +225,8 @@ 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
- withMatcher("Teammate", "validate-spawn-prompt.sh", 5)
228
+ withMatcher("Teammate", "validate-spawn-prompt.sh", 5),
229
+ withMatcher("Bash", "guard-session-checkout.sh", 5)
229
230
  ],
230
231
  SessionStart: [
231
232
  withoutMatcher("session-start-context.sh", 10)
@@ -19,11 +19,16 @@ You are a focused implementer. You receive tasks and deliver clean code.
19
19
  ## Git workflow (CRITICAL — do this first)
20
20
  You are in a temporary worktree. If you don't commit, YOUR WORK WILL BE LOST.
21
21
 
22
- 1. **FIRST**: check out the session branch specified in your instructions:
23
- `git checkout session/{name}`
22
+ **CRITICAL**: Do NOT run `git checkout` in the main repo. Do NOT use `git -C ../repo checkout`.
23
+ You are already in an isolated worktree — all git commands run HERE, not in the main repo.
24
+
25
+ 1. **FIRST**: Switch to the session branch inside your worktree:
26
+ `git checkout session/{name}` (safe — you're in a worktree)
24
27
  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.
28
+ 3. If checkout fails: `git fetch origin session/{name}` then retry
29
+ 4. **Do NOT stay on `worktree-agent-*` branches** always switch to the session branch
30
+ 5. **Commit after each logical unit** — never wait until the end
31
+ 6. **Before reporting back**: `git status` must show clean working tree.
27
32
  If anything is uncommitted: COMMIT IT NOW before reporting.
28
33
 
29
34
  ## Workflow
@@ -102,8 +102,15 @@ 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: Do NOT run `git checkout` in the main repo. Do NOT use `git -C ../repo checkout`.
108
+ You are in an isolated worktree — all git commands run HERE.
109
+ 1. git checkout session/{name} (switch to session branch inside your worktree)
110
+ 2. git branch --show-current (verify: must show session/{name})
111
+ 3. Do NOT stay on worktree-agent-* branches — use the session branch.
112
+ Branch session/{name} ALREADY EXISTS. ALL commits go on this branch.
113
+ ```
107
114
 
108
115
  ### During collection
109
116
  - Verify commits are on the session branch via Task subagent:
@@ -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]
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env bash
2
+ # guard-session-checkout.sh
3
+ # PreToolUse hook (matcher: Bash): blocks `git checkout session/` in main repos.
4
+ # Session branches must only be checked out INSIDE worktrees, never in main repos
5
+ # (doing so disrupts other parallel sessions).
6
+ # v4.2.1: hard guardrail — this hook BLOCKS (exit 0 + deny JSON).
7
+ set -euo pipefail
8
+
9
+ INPUT=$(cat)
10
+ COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null) || true
11
+
12
+ [ -z "$COMMAND" ] && exit 0
13
+
14
+ # Only care about git checkout/switch targeting session/ branches
15
+ if ! echo "$COMMAND" | grep -qE 'git\s+(checkout|switch)\s+.*session/' 2>/dev/null; then
16
+ exit 0
17
+ fi
18
+
19
+ # Pattern 1: git -C <repo> checkout session/ — always wrong (targets main repo from outside)
20
+ if echo "$COMMAND" | grep -qE 'git\s+-C\s+\S+\s+(checkout|switch)\s+.*session/' 2>/dev/null; then
21
+ printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"BLOCKED: git checkout session/ with -C targets the main repo directly. This disrupts other parallel sessions. You are in a worktree — run `git checkout session/{name}` from INSIDE your worktree (without -C) instead. If you are not in a worktree, something is wrong with your isolation setup."}}'
22
+ exit 0
23
+ fi
24
+
25
+ # Pattern 2: git checkout session/ without -C — check if we are in a main repo
26
+ # In a worktree, .git is a FILE (gitdir pointer). In a main repo, .git is a DIRECTORY.
27
+ if [ -d ".git" ] && [ ! -f ".git" ]; then
28
+ printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"BLOCKED: git checkout session/ detected in a main repo (not a worktree). Checking out a session branch in the main repo disrupts other parallel sessions. You must work in an isolated worktree. If you are a teammate, your worktree should already exist — run `git checkout session/{name}` from inside it."}}'
29
+ exit 0
30
+ fi
31
+
32
+ # We are in a worktree (.git is a file) — allow the checkout
33
+ exit 0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-workspace",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
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"