Skip to content

Commit 6a1b8b6

Browse files
author
zenus
committed
feat: restore worktree teams and bitlesson setup flow
1 parent 3b3ebb0 commit 6a1b8b6

14 files changed

Lines changed: 1390 additions & 81 deletions

commands/setup-worktree-teams.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
description: "Provision worker/reviewer git worktree lanes for document-centered worktree orchestration"
3+
argument-hint: "[--workers N] [--reviewers N] [--loop-dir PATH] [--worktree-root PATH] [--branch-prefix PREFIX] [--base-ref REF]"
4+
allowed-tools: ["Bash(${CLAUDE_PLUGIN_ROOT}/scripts/setup-worktree-teams.sh:*)"]
5+
hide-from-slash-command-tool: "true"
6+
---
7+
8+
# Setup Worktree Teams
9+
10+
Execute the setup script to create worker/reviewer worktree lanes:
11+
12+
```bash
13+
"${CLAUDE_PLUGIN_ROOT}/scripts/setup-worktree-teams.sh" $ARGUMENTS
14+
```
15+
16+
This command:
17+
18+
1. Finds the active RLCR loop (or uses `--loop-dir`)
19+
2. Creates isolated worker/reviewer `git worktree` lanes
20+
3. Reuses existing lanes if they already exist
21+
4. Writes lane mapping to `worktree-assignment.md` in the loop directory
22+
23+
## Common Usage
24+
25+
```bash
26+
/humanize:setup-worktree-teams --workers 3 --reviewers 2
27+
```
28+
29+
## Notes
30+
31+
- Run this after `/humanize:start-rlcr-loop` (agent/worktree modes are default-on when supported)
32+
- `--reviewers` defaults to the same count as `--workers`
33+
- `--worktree-root` defaults to state value, then `.humanize/worktrees/<loop-id>`
34+
- `--base-ref` defaults to `start_branch` from loop state, then current branch

hooks/lib/loop-common.sh

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,34 @@ readonly FIELD_FULL_REVIEW_ROUND="full_review_round"
3838
readonly FIELD_ASK_CODEX_QUESTION="ask_codex_question"
3939
readonly FIELD_SESSION_ID="session_id"
4040
readonly FIELD_AGENT_TEAMS="agent_teams"
41+
readonly FIELD_WORKTREE_TEAMS="worktree_teams"
42+
readonly FIELD_WORKTREE_ROOT="worktree_root"
43+
readonly FIELD_DELEGATION_ENFORCEMENT="delegation_enforcement"
4144

4245
# Default Codex configuration (single source of truth - all scripts reference this)
43-
# Both use :- so scripts can override before sourcing when needed.
46+
# Both use :- so scripts can override before sourcing (e.g. PR loop sets different model/effort).
4447
#
45-
# Role split:
46-
# - Analyzer/Reviewer: gpt-5.2 (non-codex)
47-
# - Worker (implementation): gpt-5.3-codex
48+
# Role split (hybrid: role-based defaults + runtime-aware worker model):
49+
# - Analyzer/Reviewer (DEFAULT_CODEX_MODEL): gpt-5.2 in all modes (always available)
50+
# - Worker/Implementer (DEFAULT_CODEX_WORKER_MODEL): runtime-aware
51+
# Claude Code plugin mode -> gpt-5.3-codex (available in plugin sandbox)
52+
# Skill mode (Codex/Kimi) -> gpt-5.2 (gpt-5.3-codex unavailable outside plugin)
53+
#
54+
# Detection: check BASH_SOURCE path for .claude/plugins/cache/ (CLAUDE_PLUGIN_ROOT is a
55+
# config-time template variable, not a runtime env var, so we cannot check it directly).
4856
DEFAULT_CODEX_MODEL="${DEFAULT_CODEX_MODEL:-gpt-5.2}"
4957
DEFAULT_CODEX_EFFORT="${DEFAULT_CODEX_EFFORT:-xhigh}"
5058

5159
# Default worker configuration (used by /humanize:codex-worker).
52-
DEFAULT_CODEX_WORKER_MODEL="${DEFAULT_CODEX_WORKER_MODEL:-gpt-5.3-codex}"
60+
if [[ -z "${DEFAULT_CODEX_WORKER_MODEL:-}" ]]; then
61+
_LOOP_COMMON_SELF="${BASH_SOURCE[0]:-$0}"
62+
if [[ "$_LOOP_COMMON_SELF" == */.claude/plugins/cache/* ]]; then
63+
DEFAULT_CODEX_WORKER_MODEL="gpt-5.3-codex"
64+
else
65+
DEFAULT_CODEX_WORKER_MODEL="gpt-5.2"
66+
fi
67+
unset _LOOP_COMMON_SELF
68+
fi
5369
DEFAULT_CODEX_WORKER_EFFORT="${DEFAULT_CODEX_WORKER_EFFORT:-xhigh}"
5470

5571
# Codex review markers
@@ -336,6 +352,9 @@ _parse_state_fields() {
336352
STATE_ASK_CODEX_QUESTION=$(echo "$STATE_FRONTMATTER" | grep "^${FIELD_ASK_CODEX_QUESTION}:" | sed "s/${FIELD_ASK_CODEX_QUESTION}: *//" | tr -d ' ' || true)
337353
STATE_SESSION_ID=$(echo "$STATE_FRONTMATTER" | grep "^${FIELD_SESSION_ID}:" | sed "s/${FIELD_SESSION_ID}: *//" || true)
338354
STATE_AGENT_TEAMS=$(echo "$STATE_FRONTMATTER" | grep "^${FIELD_AGENT_TEAMS}:" | sed "s/${FIELD_AGENT_TEAMS}: *//" | tr -d ' ' || true)
355+
STATE_WORKTREE_TEAMS=$(echo "$STATE_FRONTMATTER" | grep "^${FIELD_WORKTREE_TEAMS}:" | sed "s/${FIELD_WORKTREE_TEAMS}: *//" | tr -d ' ' || true)
356+
STATE_WORKTREE_ROOT=$(echo "$STATE_FRONTMATTER" | grep "^${FIELD_WORKTREE_ROOT}:" | sed "s/${FIELD_WORKTREE_ROOT}: *//" | sed 's/^"//; s/"$//' || true)
357+
STATE_DELEGATION_ENFORCEMENT=$(echo "$STATE_FRONTMATTER" | grep "^${FIELD_DELEGATION_ENFORCEMENT}:" | sed "s/${FIELD_DELEGATION_ENFORCEMENT}: *//" | tr -d ' ' || true)
339358
}
340359

341360
# Parse state file frontmatter and set variables (tolerant mode with defaults)
@@ -355,6 +374,10 @@ _parse_state_fields() {
355374
# STATE_REVIEW_STARTED - "true" or "false"
356375
# STATE_FULL_REVIEW_ROUND - interval for Full Alignment Check (default: 5)
357376
# STATE_ASK_CODEX_QUESTION - "true" or "false" (v1.6.5+)
377+
# STATE_AGENT_TEAMS - "true" or "false"
378+
# STATE_WORKTREE_TEAMS - "true" or "false"
379+
# STATE_WORKTREE_ROOT - worktree root path when worktree teams are enabled
380+
# STATE_DELEGATION_ENFORCEMENT - "warn" or "strict"
358381
# Returns: 0 on success, 1 if file not found
359382
# Note: For strict validation, use parse_state_file_strict() instead
360383
parse_state_file() {
@@ -377,6 +400,9 @@ parse_state_file() {
377400
STATE_FULL_REVIEW_ROUND="${STATE_FULL_REVIEW_ROUND:-5}"
378401
STATE_ASK_CODEX_QUESTION="${STATE_ASK_CODEX_QUESTION:-true}"
379402
STATE_AGENT_TEAMS="${STATE_AGENT_TEAMS:-false}"
403+
STATE_WORKTREE_TEAMS="${STATE_WORKTREE_TEAMS:-false}"
404+
STATE_WORKTREE_ROOT="${STATE_WORKTREE_ROOT:-}"
405+
STATE_DELEGATION_ENFORCEMENT="${STATE_DELEGATION_ENFORCEMENT:-warn}"
380406
# STATE_REVIEW_STARTED left as-is (empty if missing, to allow schema validation)
381407

382408
return 0
@@ -452,6 +478,9 @@ parse_state_file_strict() {
452478
STATE_FULL_REVIEW_ROUND="${STATE_FULL_REVIEW_ROUND:-5}"
453479
STATE_ASK_CODEX_QUESTION="${STATE_ASK_CODEX_QUESTION:-true}"
454480
STATE_AGENT_TEAMS="${STATE_AGENT_TEAMS:-false}"
481+
STATE_WORKTREE_TEAMS="${STATE_WORKTREE_TEAMS:-false}"
482+
STATE_WORKTREE_ROOT="${STATE_WORKTREE_ROOT:-}"
483+
STATE_DELEGATION_ENFORCEMENT="${STATE_DELEGATION_ENFORCEMENT:-warn}"
455484

456485
return 0
457486
}

0 commit comments

Comments
 (0)