Skip to content

Commit 9a494c5

Browse files
authored
Merge pull request #73 from win4r/sync/upstream-2026-05-28-cherry-picks
Sync upstream/main 2026-05-28 (197 commits)
2 parents 24e162d + cc2b09a commit 9a494c5

147 files changed

Lines changed: 18546 additions & 1084 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 76 additions & 178 deletions
Original file line numberDiff line numberDiff line change
@@ -1,235 +1,133 @@
11
---
22
name: clawteam-dev
33
description: >
4-
This skill should be used when the user asks to "run e2e test", "test clawteam",
5-
"end-to-end test", "test agent team", "verify clawteam works", "dev test", or wants
6-
to validate the full ClawTeam lifecycle. Runs a complete end-to-end test: cleanup →
7-
create team → create tasks with dependencies → spawn agents → wait for completion →
8-
verify results → cleanup.
9-
version: 0.1.0
4+
Use this skill when working inside the ClawTeam repository itself: local development,
5+
debugging, reviewing, testing, validating multi-agent flows, or checking whether a
6+
code change actually works end-to-end. Use the repository bootstrap scripts to
7+
standardize the local `clawteam` command and to wire project-local `.agents` and
8+
`.claude` skills back to this repository. This skill is repository-development
9+
oriented, not a general end-user usage guide.
10+
version: 0.2.0
1011
---
1112

12-
# ClawTeam End-to-End Test
13+
# ClawTeam Local Development
1314

14-
This skill runs a full lifecycle test of ClawTeam: cleanup residual state, create a team
15-
with tasks and dependency chains, spawn real Claude agents in tmux, wait for all tasks to
16-
complete, verify results, and clean up.
15+
This skill is for developing and validating ClawTeam inside the ClawTeam repository.
16+
Use it when the task is about changing ClawTeam itself, testing local behavior, or
17+
verifying multi-agent workflows against the current checkout.
1718

18-
## Prerequisites
19-
20-
- ClawTeam installed (`pip install -e .` from the ClawTeam repo)
21-
- `tmux` available
22-
- `claude` CLI available
23-
- Current directory is the ClawTeam git repo (for worktree isolation)
24-
25-
## Test Procedure
19+
## Development Bootstrap
2620

27-
Follow these steps **exactly in order**. Run each bash block and verify the expected output
28-
before proceeding to the next step.
29-
30-
### Step 1: Cleanup ALL Previous State
31-
32-
Remove **all** residual clawteam teams, worktrees, tmux sessions, and branches from any prior runs.
33-
This ensures a clean slate regardless of what team names were used before or if a previous test crashed.
21+
Standardize the local development environment with the bootstrap script:
3422

3523
```bash
36-
# 1. Kill ALL clawteam tmux sessions
37-
for sess in $(tmux list-sessions -F '#{session_name}' 2>/dev/null | grep '^clawteam-'); do
38-
tmux kill-session -t "$sess" 2>/dev/null
39-
done
40-
echo "tmux sessions cleaned"
41-
42-
# 2. Remove ALL clawteam worktrees
43-
for wt in $(git worktree list --porcelain | grep 'worktree.*/\.clawteam/' | awk '{print $2}'); do
44-
git worktree remove --force "$wt" 2>/dev/null
45-
done
46-
echo "worktrees cleaned"
47-
48-
# 3. Delete ALL clawteam branches
49-
for br in $(git branch --list 'clawteam/*' | tr -d ' +'); do
50-
git branch -D "$br" 2>/dev/null
51-
done
52-
echo "branches cleaned"
53-
54-
# 4. Remove all team/task/workspace data (preserve config.json)
55-
rm -rf ~/.clawteam/teams/ ~/.clawteam/tasks/ ~/.clawteam/workspaces/ ~/.clawteam/inboxes/ ~/.clawteam/events/ ~/.clawteam/plans/
56-
echo "data cleaned"
57-
58-
# 5. Verify clean state
59-
echo "=== Verification ==="
60-
git worktree list
61-
git branch --list 'clawteam/*' | grep . || echo "OK: no clawteam branches"
62-
tmux list-sessions 2>&1 | grep '^clawteam-' || echo "OK: no clawteam tmux sessions"
63-
ls ~/.clawteam/ 2>/dev/null
24+
bash scripts/bootstrap_clawteam_dev.sh
6425
```
6526

66-
**Expected**: Only the main worktree remains, no clawteam branches, no clawteam tmux sessions,
67-
`~/.clawteam/` contains only `config.json`.
27+
This script lives in `scripts/bootstrap_clawteam_dev.sh` inside this skill folder.
6828

69-
### Step 2: Set Leader Identity
70-
71-
```bash
72-
export CLAWTEAM_AGENT_ID="e2e-leader-001"
73-
export CLAWTEAM_AGENT_NAME="leader"
74-
export CLAWTEAM_AGENT_TYPE="leader"
75-
```
29+
This script does all of the following:
7630

77-
These env vars MUST be set for all subsequent commands in this test.
31+
- Creates a fixed uv environment at `~/.clawteam-venv`
32+
- Installs the current repository into that environment with dev dependencies
33+
- Writes `~/.local/bin/clawteam` to point at the fixed environment
34+
- Adds a `clawteam()` shell function block to `~/.bashrc`
7835

79-
### Step 3: Create Team
36+
After it finishes:
8037

8138
```bash
82-
clawteam team spawn-team e2e-test -d "End-to-end test team" -n leader
39+
source ~/.bashrc
40+
clawteam --version
8341
```
8442

85-
**Expected**: `OK Team 'e2e-test' created`
86-
87-
### Step 4: Create Tasks with Dependencies
43+
Use this bootstrap whenever you want the same `clawteam` command across different
44+
Python environments on the machine.
8845

89-
Create 3 tasks: 2 independent tasks and 1 dependent task that is blocked until both complete.
90-
91-
```bash
92-
T1=$(clawteam --json task create e2e-test "Implement feature A" -o worker1 -d "Add a hello() function to a new file hello.py" | python3 -c "import sys,json;print(json.load(sys.stdin)['id'])")
93-
T2=$(clawteam --json task create e2e-test "Implement feature B" -o worker2 -d "Add a goodbye() function to a new file goodbye.py" | python3 -c "import sys,json;print(json.load(sys.stdin)['id'])")
94-
T3=$(clawteam --json task create e2e-test "Write tests" -o worker3 -d "Write pytest tests for hello.py and goodbye.py" --blocked-by "$T1,$T2" | python3 -c "import sys,json;print(json.load(sys.stdin)['id'])")
95-
echo "Tasks created: T1=$T1 T2=$T2 T3=$T3"
96-
```
46+
## Project Skill Wiring
9747

98-
**Expected**: Three task IDs printed. Then verify:
48+
To wire another local project so its `./.agents` and `./.claude` directories use
49+
this repository's local ClawTeam skills directly:
9950

10051
```bash
101-
clawteam task list e2e-test
52+
bash scripts/link_local_clawteam_skills.sh /path/to/project
10253
```
10354

104-
**Expected**: worker1 and worker2 tasks are `pending`, worker3 task is `blocked`.
55+
This script lives in `scripts/link_local_clawteam_skills.sh` inside this skill folder.
10556

106-
### Step 5: Spawn Agents
57+
This creates these symlinks inside the target project:
10758

108-
Spawn 3 agents. Each gets its own git worktree and tmux window.
59+
- `./.agents/skills/clawteam`
60+
- `./.claude/skills/clawteam`
10961

110-
```bash
111-
clawteam spawn --team e2e-test --agent-name worker1 \
112-
--task "Create hello.py with a hello() function that returns 'Hello, World!'. When done, mark your task as completed and send a summary to leader."
62+
Run the same script again any time you want to refresh or recreate those links.
11363

114-
clawteam spawn --team e2e-test --agent-name worker2 \
115-
--task "Create goodbye.py with a goodbye() function that returns 'Goodbye, World!'. When done, mark your task as completed and send a summary to leader."
64+
## Typical Uses
11665

117-
clawteam spawn --team e2e-test --agent-name worker3 \
118-
--task "Write pytest tests in test_all.py for hello.py (hello function) and goodbye.py (goodbye function). When done, mark your task as completed and send a summary to leader."
119-
```
66+
- Run targeted local validation after code changes
67+
- Reproduce a spawn / board / task / inbox / harness bug
68+
- Smoke-test the real CLI in tmux or subprocess mode
69+
- Review ClawTeam workflows end-to-end from the current repository checkout
12070

121-
**Expected**: Each prints `OK Agent '<name>' spawned in tmux (clawteam-e2e-test:<name>)` with a workspace path.
71+
## Fast Validation
12272

123-
### Step 6: Verify Team State
73+
Prefer the smallest validation that proves the change.
12474

12575
```bash
126-
clawteam team status e2e-test
127-
clawteam board show e2e-test
128-
git worktree list
129-
tmux list-windows -t clawteam-e2e-test
76+
ruff check clawteam/ tests/
77+
pytest tests/<target_file>.py -q
13078
```
13179

132-
**Expected**:
133-
- 4 members (leader + 3 workers)
134-
- Board shows 2 pending, 1 blocked tasks
135-
- 3 worktrees under `~/.clawteam/workspaces/e2e-test/`
136-
- 3 tmux windows
137-
138-
### Step 7: Wait for All Tasks to Complete
139-
140-
Block until all agents finish. Timeout 10 minutes, poll every 5 seconds.
80+
Use broader runs only when the change crosses modules:
14181

14282
```bash
143-
clawteam task wait e2e-test --timeout 600 --poll-interval 5
83+
pytest tests/test_cli_commands.py -q
84+
pytest tests/test_spawn_backends.py -q
85+
pytest tests/test_harness.py tests/test_event_bus.py -q
14486
```
14587

146-
**Expected**:
147-
- Progress updates as tasks complete (e.g., `1/3 tasks completed`)
148-
- Messages from workers displayed as they arrive
149-
- Final line: `All 3 tasks completed!`
150-
- Exit code 0
88+
## Prerequisites
15189

152-
### Step 8: Verify Results
90+
- `clawteam` command available
91+
- `tmux` available
92+
- A supported CLI agent such as `claude` or `codex` if you are spawning real workers
93+
- Current directory is the ClawTeam git repo when testing worktree isolation or local source changes
15394

154-
```bash
155-
# All tasks should be completed
156-
clawteam task list e2e-test
95+
## Local Smoke Test
15796

158-
# Board should show 3 completed, 0 pending/blocked
159-
clawteam board show e2e-test
97+
Use this when you need a real multi-agent workflow check instead of unit tests.
16098

161-
# Read any remaining inbox messages
162-
clawteam inbox receive e2e-test
99+
```bash
100+
clawteam team spawn-team dev-smoke -d "Local ClawTeam smoke test" -n leader
101+
clawteam task create dev-smoke "Smoke test worker" -o worker1 -p high
102+
clawteam spawn --team dev-smoke --agent-name worker1 --task "Report your status to leader and mark the task completed when done."
103+
clawteam board show dev-smoke
104+
clawteam task wait dev-smoke --timeout 300 --poll-interval 5
163105
```
164106

165-
**Expected**:
166-
- All 3 tasks show status `completed`
167-
- Board shows 3 in COMPLETED column
168-
- Messages from workers summarizing their work
169-
170-
### Step 9: Cleanup
171-
172-
Reuse the same full cleanup from Step 1 to remove everything created during this test.
107+
If you are validating harness behavior specifically:
173108

174109
```bash
175-
# Kill ALL clawteam tmux sessions
176-
for sess in $(tmux list-sessions -F '#{session_name}' 2>/dev/null | grep '^clawteam-'); do
177-
tmux kill-session -t "$sess" 2>/dev/null
178-
done
179-
180-
# Remove ALL clawteam worktrees
181-
for wt in $(git worktree list --porcelain | grep 'worktree.*/\.clawteam/' | awk '{print $2}'); do
182-
git worktree remove --force "$wt" 2>/dev/null
183-
done
184-
185-
# Delete ALL clawteam branches
186-
for br in $(git branch --list 'clawteam/*' | tr -d ' +'); do
187-
git branch -D "$br" 2>/dev/null
188-
done
189-
190-
# Remove all team/task/workspace data (preserve config.json)
191-
rm -rf ~/.clawteam/teams/ ~/.clawteam/tasks/ ~/.clawteam/workspaces/ ~/.clawteam/inboxes/ ~/.clawteam/events/ ~/.clawteam/plans/
192-
193-
echo "E2E test cleanup complete"
110+
clawteam harness conduct dev-harness \
111+
--goal "Create a small implementation plan and execute it with one worker" \
112+
--cli codex \
113+
--agents 1
194114
```
195115

196-
**Expected**: `E2E test cleanup complete`
116+
## Cleanup
197117

198-
### Step 10: Final Verification
118+
Use the real ClawTeam commands instead of ad-hoc directory assumptions whenever possible:
199119

200120
```bash
201-
git worktree list | grep -v '^\/' | head -1 # should show only main
202-
git branch --list 'clawteam/*' | grep . || echo "OK: no clawteam branches"
203-
tmux list-sessions 2>&1 | grep '^clawteam-' || echo "OK: no clawteam tmux sessions"
204-
ls ~/.clawteam/teams/ 2>&1 | grep -q "No such file" && echo "OK: no team data"
205-
ls ~/.clawteam/tasks/ 2>&1 | grep -q "No such file" && echo "OK: no task data"
206-
ls ~/.clawteam/workspaces/ 2>&1 | grep -q "No such file" && echo "OK: no workspace data"
121+
clawteam team cleanup dev-smoke
122+
clawteam team cleanup dev-harness
207123
```
208124

209-
**Expected**: All lines start with `OK:`.
210-
211-
## Test Variants
212-
213-
### With P2P Transport
214-
215-
Add `--transport p2p` and `export CLAWTEAM_TRANSPORT=p2p` before Step 3 to test ZeroMQ direct messaging with file fallback. The rest of the steps remain the same.
216-
217-
### With subprocess Backend
218-
219-
Replace `clawteam spawn` with `clawteam spawn subprocess claude` to test the subprocess backend instead of tmux. Note: `board attach` and tmux verification steps won't apply.
125+
If a crashed tmux session or worktree is left behind, clean it up explicitly after inspecting it.
220126

221-
## What This Test Validates
127+
## Development Rules
222128

223-
| Component | Validated |
224-
|-----------|-----------|
225-
| `team spawn-team` | Team creation with leader |
226-
| `task create --blocked-by` | Task dependency chains |
227-
| `spawn` (tmux backend) | Agent process launch with worktree isolation |
228-
| Identity propagation | Env vars passed to sub-agents |
229-
| Agent coordination | Workers update task status and send messages to leader |
230-
| Auto-unblock | Blocked task unblocked when dependencies complete |
231-
| `task wait` | Progress tracking, inbox drain, completion detection |
232-
| `inbox send/receive` | Point-to-point messaging between agents |
233-
| `board show` | Kanban board rendering |
234-
| `workspace` (auto) | Git worktree creation and isolation |
235-
| Cleanup | Worktree removal, branch deletion, data cleanup |
129+
- Prefer `clawteam` commands over editing state files directly.
130+
- Prefer targeted tests over broad end-to-end runs unless the change crosses spawn/runtime/workflow boundaries.
131+
- Use `board`, `task wait`, and `team status` to observe behavior before assuming a bug is in the spawn layer.
132+
- When testing agent coordination, keep the team small first: one leader and one or two workers.
133+
- Only escalate to harness or full swarm tests when the lower-level task/spawn/inbox path already works.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
5+
SKILL_DIR="$(cd -- "${SCRIPT_DIR}/.." && pwd)"
6+
REPO_ROOT="$(cd -- "${SKILL_DIR}/../../.." && pwd)"
7+
VENV_DIR="${HOME}/.clawteam-venv"
8+
LAUNCHER="${HOME}/.local/bin/clawteam"
9+
PYTHON_BIN="${VENV_DIR}/bin/python"
10+
11+
mkdir -p "${HOME}/.local/bin"
12+
13+
if ! command -v uv >/dev/null 2>&1; then
14+
echo "Error: uv is not installed or not on PATH." >&2
15+
exit 1
16+
fi
17+
18+
uv venv "${VENV_DIR}"
19+
(
20+
cd "${REPO_ROOT}"
21+
uv pip install --python "${PYTHON_BIN}" -e ".[dev]"
22+
)
23+
24+
cat > "${LAUNCHER}" <<EOF
25+
#!/usr/bin/env bash
26+
exec ${PYTHON_BIN} -m clawteam.cli.commands "\$@"
27+
EOF
28+
chmod +x "${LAUNCHER}"
29+
30+
python - <<'PY'
31+
from pathlib import Path
32+
33+
bashrc = Path.home() / ".bashrc"
34+
launcher = Path.home() / ".clawteam-venv" / "bin" / "python"
35+
block = f"""# >>> clawteam launcher >>>
36+
clawteam() {{
37+
{launcher} -m clawteam.cli.commands "$@"
38+
}}
39+
# <<< clawteam launcher <<<
40+
"""
41+
42+
text = bashrc.read_text() if bashrc.exists() else ""
43+
start = "# >>> clawteam launcher >>>"
44+
end = "# <<< clawteam launcher <<<"
45+
if start in text and end in text:
46+
prefix = text.split(start, 1)[0]
47+
suffix = text.split(end, 1)[1]
48+
updated = prefix + block + suffix
49+
else:
50+
updated = text.rstrip() + ("\n\n" if text.strip() else "") + block
51+
bashrc.write_text(updated)
52+
PY
53+
54+
echo "ClawTeam development environment is ready."
55+
echo "Launcher: ${LAUNCHER}"
56+
echo "Venv: ${VENV_DIR}"
57+
echo "Next: source ~/.bashrc && clawteam --version"

0 commit comments

Comments
 (0)