cc-workspace 4.7.0 → 4.7.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.
@@ -20,8 +20,8 @@ hooks:
20
20
  [ -z "$CMD" ] && exit 0
21
21
  # Block git checkout/switch in sibling repos (would disrupt main working tree)
22
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
23
+ # Allow checkout inside /tmp/ worktrees (macOS: /tmp -> /private/tmp)
24
+ if echo "$CMD" | grep -qE '^\s*cd\s+(/private)?/tmp/' || echo "$CMD" | grep -qE 'git\s+-C\s+(/private)?/tmp/'; then
25
25
  exit 0
26
26
  fi
27
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."}}'
@@ -51,23 +51,32 @@ Previous commits are already on the session branch — you'll see them in your w
51
51
 
52
52
  ## Git workflow (do this FIRST)
53
53
 
54
- You work in a **temporary worktree**. If you don't commit, YOUR WORK IS LOST.
54
+ You work in a **worktree**. If you don't commit, YOUR WORK IS LOST.
55
55
 
56
- ### Setup
56
+ ### Setup — ALWAYS check for existing worktree first
57
57
  ```bash
58
- # 1. Create worktree (or reuse if previous attempt left one)
59
- git -C ../[repo] worktree add /tmp/[repo]-[session] session/[branch]
60
- # If fails with "already checked out": previous crash left a worktree
61
- # → cd /tmp/[repo]-[session] && git status to assess state
62
-
63
- # 2. Move into worktree — ALL work happens here
64
- cd /tmp/[repo]-[session]
65
-
66
- # 3. Verify branch
58
+ # 1. FIRST: check if a worktree already exists for the session branch
59
+ WORKTREE_PATH=$(git -C ../[repo] worktree list --porcelain | grep -B1 'branch.*session/[branch]' | head -1 | sed 's/worktree //')
60
+
61
+ if [ -n "$WORKTREE_PATH" ] && [ -d "$WORKTREE_PATH" ]; then
62
+ # Worktree exists — REUSE IT (do NOT create a new one)
63
+ cd "$WORKTREE_PATH"
64
+ echo "Reusing existing worktree at $WORKTREE_PATH"
65
+ else
66
+ # No worktree — create one
67
+ git -C ../[repo] worktree add /tmp/[repo]-[session] session/[branch]
68
+ cd /tmp/[repo]-[session]
69
+ fi
70
+
71
+ # 2. Verify branch
67
72
  git branch --show-current # must show session/[branch]
68
73
 
69
- # 4. Check existing commits from previous implementers
74
+ # 3. Check existing commits from previous implementers
70
75
  git log --oneline -5
76
+
77
+ # 4. Check for leftover uncommitted changes from a crashed previous implementer
78
+ git status --short
79
+ # If dirty: assess changes — commit useful ones, discard junk with git checkout -- .
71
80
  ```
72
81
 
73
82
  If session branch doesn't exist:
@@ -76,13 +85,8 @@ git -C ../[repo] branch session/[branch] [source-branch]
76
85
  git -C ../[repo] worktree add /tmp/[repo]-[session] session/[branch]
77
86
  ```
78
87
 
79
- ### Recovering from a previous failed attempt
80
- If `git worktree add` fails because the worktree already exists:
81
- 1. `cd /tmp/[repo]-[session]` — enter the existing worktree
82
- 2. `git status` — check for uncommitted changes from the previous implementer
83
- 3. `git log --oneline -3` — check if the previous attempt committed anything
84
- 4. If changes exist but aren't committed: assess if they're useful, commit or discard
85
- 5. If clean: proceed normally with your commit unit
88
+ **IMPORTANT macOS paths**: `/tmp` is a symlink to `/private/tmp`.
89
+ Git worktree list shows `/private/tmp/...`. Both paths are valid. Use whichever `worktree list` reports.
86
90
 
87
91
  ## Workflow
88
92
 
@@ -116,9 +120,11 @@ Report:
116
120
  - Dead code found
117
121
  - Blockers or escalations
118
122
 
119
- Cleanup:
123
+ Cleanup — **do NOT remove the worktree** (next implementer will reuse it):
120
124
  ```bash
121
- git -C ../[repo] worktree remove /tmp/[repo]-[session]
125
+ # Only verify the tree is clean after commit
126
+ git status # must show "nothing to commit, working tree clean"
127
+ # The orchestrator or session close skill handles worktree cleanup
122
128
  ```
123
129
 
124
130
  ## Memory
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-workspace",
3
- "version": "4.7.0",
3
+ "version": "4.7.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"