shellmates 0.1.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.
Files changed (38) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +134 -0
  3. package/bin/shellmates.js +112 -0
  4. package/lib/commands/config.js +88 -0
  5. package/lib/commands/init.js +56 -0
  6. package/lib/commands/install-hook.js +83 -0
  7. package/lib/commands/spawn.js +98 -0
  8. package/lib/commands/status.js +69 -0
  9. package/lib/utils/config.js +35 -0
  10. package/lib/utils/logo.js +84 -0
  11. package/lib/utils/tmux.js +46 -0
  12. package/package.json +39 -0
  13. package/scripts/dispatch.sh +331 -0
  14. package/scripts/launch-full-team.sh +77 -0
  15. package/scripts/launch.sh +183 -0
  16. package/scripts/monitor.sh +113 -0
  17. package/scripts/spawn-team.sh +302 -0
  18. package/scripts/status.sh +168 -0
  19. package/scripts/teardown.sh +211 -0
  20. package/scripts/view-session.sh +98 -0
  21. package/scripts/watch-inbox.sh +71 -0
  22. package/templates/.codex/agents/default.toml +5 -0
  23. package/templates/.codex/agents/executor.toml +7 -0
  24. package/templates/.codex/agents/explorer.toml +5 -0
  25. package/templates/.codex/agents/planner.toml +6 -0
  26. package/templates/.codex/agents/researcher.toml +6 -0
  27. package/templates/.codex/agents/reviewer.toml +5 -0
  28. package/templates/.codex/agents/verifier.toml +6 -0
  29. package/templates/.codex/agents/worker.toml +5 -0
  30. package/templates/.codex/config.toml +43 -0
  31. package/templates/AGENTS.md +109 -0
  32. package/templates/CLAUDE.md +50 -0
  33. package/templates/GEMINI.md +136 -0
  34. package/templates/config.json +10 -0
  35. package/templates/gitignore-additions.txt +2 -0
  36. package/templates/hooks/settings-addition.json +20 -0
  37. package/templates/hooks/shellmates-notify.sh +77 -0
  38. package/templates/task-header.txt +10 -0
@@ -0,0 +1,109 @@
1
+ # AGENTS.md
2
+
3
+ This file provides guidance to AI coding agents (Codex, Warp, Gemini CLI, etc.) operating in this repository.
4
+
5
+ > **Setup:** Replace `[BRACKETED]` sections with your project details.
6
+ > Ask Claude: *"Read the codebase and fill out AGENTS.md."*
7
+
8
+ ---
9
+
10
+ ## Project Overview
11
+
12
+ [2-3 sentences on what this project does.]
13
+
14
+ **Stack:** [e.g., Python/FastAPI + Next.js + PostgreSQL]
15
+ **Current milestone:** [e.g., v1.0 — MVP]
16
+
17
+ ---
18
+
19
+ ## Build & Run Commands
20
+
21
+ ```bash
22
+ # Backend
23
+ [start command]
24
+
25
+ # Frontend
26
+ [start command]
27
+
28
+ # Tests
29
+ [test command]
30
+
31
+ # Lint
32
+ [lint command]
33
+ ```
34
+
35
+ ---
36
+
37
+ ## Key Files
38
+
39
+ ```
40
+ [List your most important files]
41
+
42
+ Example:
43
+ backend/app/main.py — FastAPI entry point
44
+ backend/app/services/ — Business logic
45
+ frontend/app/ — Next.js pages
46
+ .planning/STATE.md — Current project state
47
+ .planning/ROADMAP.md — Phase roadmap
48
+ ```
49
+
50
+ ---
51
+
52
+ ## Multi-Agent Protocol
53
+
54
+ **You are a sub-agent.** Claude Code is the orchestrator at pane `orchestra:0.1`.
55
+
56
+ ### Completion signal — REQUIRED
57
+
58
+ After every task (code done, tests run, committed), output:
59
+
60
+ ```
61
+ PHASE_COMPLETE: Phase N — <one-line summary>
62
+ ```
63
+
64
+ Then output:
65
+ ```
66
+ AWAITING_INSTRUCTIONS
67
+ ```
68
+
69
+ ### Pinging Claude directly
70
+
71
+ When asked:
72
+ ```bash
73
+ tmux send-keys -t orchestra:0.1 "AGENT_PING: [task] complete. Files: [list]. Issues: [any]. Tests: [pass/fail]. — AWAITING_INSTRUCTIONS" Enter
74
+ ```
75
+
76
+ ### Rules
77
+
78
+ - Use non-interactive flags: `--yes`, `-y`, `--force`
79
+ - Always commit before PHASE_COMPLETE
80
+ - Run `git status --short` after committing
81
+ - Read `.planning/phases/N-slug/PLAN.md` before executing any phase
82
+ - Never start servers that block the terminal
83
+
84
+ ---
85
+
86
+ ## Code Conventions
87
+
88
+ [Your conventions here]
89
+
90
+ ---
91
+
92
+ ## Codex Multi-Agent Roles
93
+
94
+ This project includes `.codex/config.toml` with the following specialized roles:
95
+
96
+ | Role | Use for |
97
+ |------|---------|
98
+ | `planner` | Producing PLAN.md from a task description |
99
+ | `researcher` | Discovering constraints before planning |
100
+ | `executor` | Implementing an approved plan |
101
+ | `verifier` | Independent testing and UAT verification |
102
+ | `reviewer` | Code review for regressions and security |
103
+ | `explorer` | Read-only codebase mapping |
104
+
105
+ To invoke a role pattern:
106
+ ```
107
+ Run a [researcher] + [planner] + [executor] workflow for:
108
+ [task description]
109
+ ```
@@ -0,0 +1,50 @@
1
+ ## shellmates — Multi-Agent Orchestration
2
+
3
+ This project uses shellmates for multi-agent orchestration via tmux.
4
+ Full operating instructions: `ORCHESTRATOR.md` — read it before any orchestration session.
5
+
6
+ ### Dispatching tasks
7
+
8
+ Always use shellmates to dispatch — never raw `tmux send-keys` directly:
9
+
10
+ ```bash
11
+ # One-liner (spawns session + dispatches):
12
+ shellmates spawn --task-file /tmp/task.txt --project /path/to/project --watch
13
+
14
+ # Or via script directly:
15
+ bash scripts/spawn-team.sh --task-file /tmp/task.txt --project /path/to/project
16
+ ```
17
+
18
+ ### CRITICAL — Do not poll
19
+
20
+ After dispatching, **stop working and end your turn**.
21
+
22
+ - Do NOT run `tmux capture-pane` in a loop
23
+ - Do NOT sleep and re-check
24
+ - Do NOT monitor panes second by second
25
+
26
+ The agent will notify you when it finishes. The notification looks like:
27
+
28
+ ```
29
+ AGENT_PING: job-XXXXX complete. STATUS: complete. RESULT: ...
30
+ ```
31
+
32
+ This appears directly in your terminal when the background watcher detects the result.
33
+ Read it, then decide next steps.
34
+
35
+ ### If you need to check manually (once only)
36
+
37
+ ```bash
38
+ # Check inbox for latest result:
39
+ shellmates status
40
+
41
+ # Or read a specific result:
42
+ cat ~/.shellmates/inbox/<job-id>.txt
43
+ ```
44
+
45
+ ### Session management
46
+
47
+ ```bash
48
+ shellmates status # active sessions + inbox
49
+ shellmates teardown # clean up when done
50
+ ```
@@ -0,0 +1,136 @@
1
+ # Workspace Overview: [YOUR PROJECT NAME]
2
+
3
+ > **Setup instructions:** Replace every `[BRACKETED]` section below with your project's details.
4
+ > Ask Claude Code to fill this out for you: *"Read the codebase and fill out GEMINI.md."*
5
+
6
+ ---
7
+
8
+ ## What This Project Is
9
+
10
+ [2-3 sentences describing what the project does and what problem it solves.]
11
+
12
+ **Current goal:** [What you're working on right now — e.g., "v1.0 MVP", "Phase 3 — user auth"]
13
+
14
+ ---
15
+
16
+ ## Tech Stack
17
+
18
+ - **Backend:** [e.g., Python 3.11 / FastAPI]
19
+ - **Frontend:** [e.g., Next.js 14 / TypeScript / Tailwind]
20
+ - **Database:** [e.g., PostgreSQL 15]
21
+ - **AI/LLM:** [e.g., Gemini 2.0 Flash]
22
+ - **Tests:** [e.g., pytest / Jest]
23
+ - **Deploy:** [e.g., Docker / GCP Cloud Run]
24
+
25
+ ---
26
+
27
+ ## Project Layout
28
+
29
+ ```
30
+ [Paste your project tree here — just the key directories, not node_modules]
31
+
32
+ Example:
33
+ my-project/
34
+ ├── backend/
35
+ │ ├── app/
36
+ │ │ ├── main.py # FastAPI entry point
37
+ │ │ ├── routers/ # Route handlers
38
+ │ │ └── services/ # Business logic
39
+ │ └── tests/
40
+ ├── frontend/
41
+ │ ├── app/ # Next.js App Router pages
42
+ │ └── components/
43
+ └── .planning/ # GSD plans and state
44
+ ├── ROADMAP.md
45
+ └── STATE.md
46
+ ```
47
+
48
+ ---
49
+
50
+ ## Key Commands
51
+
52
+ ```bash
53
+ # Start backend
54
+ [your backend start command]
55
+
56
+ # Run tests
57
+ [your test command]
58
+
59
+ # Lint
60
+ [your lint command]
61
+
62
+ # Build
63
+ [your build command]
64
+ ```
65
+
66
+ ---
67
+
68
+ ## Code Conventions
69
+
70
+ [List your project's conventions. Examples:]
71
+ - Use `snake_case` for Python, `camelCase` for TypeScript
72
+ - All API endpoints require `X-API-Key` header
73
+ - Database queries go in `services/database.py`, not inline in routes
74
+ - Commit format: `type(scope): description` (e.g., `feat(auth): add login endpoint`)
75
+ - Never commit secrets or `.env` files
76
+
77
+ ---
78
+
79
+ ## Multi-Agent Protocol
80
+
81
+ **You are a sub-agent.** Claude Code is the orchestrator running in pane `orchestra:0.1`.
82
+ It sends you tasks via tmux and monitors your output. Follow these rules exactly.
83
+
84
+ ### How you receive tasks
85
+
86
+ Claude types tasks directly into your terminal via `tmux send-keys`. When you see a task appear, treat it as a new prompt and start working.
87
+
88
+ ### Completion signal — REQUIRED
89
+
90
+ After finishing every task (code written, tests passing, committed), output this exact line as your **final message**:
91
+
92
+ ```
93
+ PHASE_COMPLETE: Phase N — <one-line summary of what was done>
94
+ ```
95
+
96
+ Example:
97
+ ```
98
+ PHASE_COMPLETE: Phase 3 — POST /users endpoint added, validation + tests, all passing
99
+ ```
100
+
101
+ Then output:
102
+ ```
103
+ AWAITING_INSTRUCTIONS
104
+ ```
105
+
106
+ **This is how Claude knows you're done.** It polls your pane looking for `PHASE_COMPLETE`. If you don't output this, Claude will keep waiting.
107
+
108
+ ### Notifying Claude directly (when asked)
109
+
110
+ If Claude explicitly asks you to ping it, run this bash command — it types the message into Claude's terminal:
111
+
112
+ ```bash
113
+ tmux send-keys -t orchestra:0.1 "AGENT_PING: [task] complete. Files changed: [list]. Issues: [any deviations or problems]. Tests: [pass/fail + counts]. — AWAITING_INSTRUCTIONS" Enter
114
+ ```
115
+
116
+ ### Rules — read these carefully
117
+
118
+ 1. **Never start the next task until Claude sends it.** After PHASE_COMPLETE, wait.
119
+ 2. **Always use non-interactive flags.** `npm install --yes`, `apt install -y`, `npx --yes`. Never run a command that pauses for y/n — Claude can't respond to interactive sub-shells.
120
+ 3. **Always commit before signaling PHASE_COMPLETE.** Uncommitted work doesn't count.
121
+ 4. **Run `git status --short` after committing** to confirm a clean tree.
122
+ 5. **One task at a time.** Don't batch multiple phases into one response.
123
+ 6. **Don't start the backend server** (`uvicorn`, `gunicorn`, etc.) unless explicitly told to — it will block your terminal and you won't be able to run further commands.
124
+ 7. **Read the plan file first.** When told to execute a phase, read `.planning/phases/N-slug/PLAN.md` before writing any code.
125
+
126
+ ---
127
+
128
+ ## Planning Files Location
129
+
130
+ All GSD plans live in `.planning/phases/`. When told to execute a phase, the plan will be at:
131
+
132
+ ```
133
+ .planning/phases/N-phase-name/PLAN.md
134
+ ```
135
+
136
+ Read the entire PLAN.md before starting. It contains the task list, file list, and verification steps.
@@ -0,0 +1,10 @@
1
+ {
2
+ "permission_mode": "default",
3
+ "default_agent": "gemini",
4
+ "orchestrator": "claude",
5
+ "_docs": {
6
+ "permission_mode": "default | bypass — bypass starts agents in auto-approve mode (no confirmation prompts). gemini uses --yolo, codex uses --full-auto.",
7
+ "default_agent": "gemini | codex | ask — which CLI to use for worker tasks. 'ask' prompts you each time.",
8
+ "orchestrator": "claude | gemini | codex — which CLI acts as orchestrator. Determines which pane reads ORCHESTRATOR.md."
9
+ }
10
+ }
@@ -0,0 +1,2 @@
1
+ # Shellmates — add these to your project .gitignore
2
+ .shellmates/tasks/
@@ -0,0 +1,20 @@
1
+ {
2
+ "_comment": "Merge this into ~/.claude/settings.json (or ~/.claude/settings.local.json).",
3
+ "_comment2": "This hook fires after every Bash tool call. If it was a shellmates dispatch,",
4
+ "_comment3": "it waits for the inbox result and notifies Claude natively via asyncRewake.",
5
+ "hooks": {
6
+ "PostToolUse": [
7
+ {
8
+ "matcher": "Bash",
9
+ "hooks": [
10
+ {
11
+ "type": "command",
12
+ "command": "~/.claude/hooks/shellmates-notify.sh",
13
+ "async": true,
14
+ "asyncRewake": true
15
+ }
16
+ ]
17
+ }
18
+ ]
19
+ }
20
+ }
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env bash
2
+ # shellmates-notify.sh — Claude Code PostToolUse hook
3
+ #
4
+ # Fires after every Bash tool call. If the command was a shellmates dispatch,
5
+ # waits for the inbox result and exits with code 2 (asyncRewake) so Claude
6
+ # Code delivers the result as a native notification — no polling needed.
7
+ #
8
+ # Install:
9
+ # cp templates/hooks/shellmates-notify.sh ~/.claude/hooks/
10
+ # chmod +x ~/.claude/hooks/shellmates-notify.sh
11
+ # Merge templates/hooks/settings-addition.json into ~/.claude/settings.json
12
+
13
+ set -euo pipefail
14
+
15
+ INBOX_DIR="${HOME}/.shellmates/inbox"
16
+ TIMEOUT="${SHELLMATES_TIMEOUT:-300}"
17
+
18
+ # Hook receives { tool_name, tool_input, tool_response } as JSON on stdin
19
+ INPUT=$(cat)
20
+
21
+ # Only act on Bash tool calls that used shellmates
22
+ COMMAND=$(echo "$INPUT" | python3 -c "
23
+ import json, sys
24
+ data = json.load(sys.stdin)
25
+ cmd = data.get('tool_input', {}).get('command', '')
26
+ print(cmd)
27
+ " 2>/dev/null || echo "")
28
+
29
+ if ! echo "$COMMAND" | grep -qE "shellmates spawn|spawn-team\.sh|dispatch\.sh"; then
30
+ exit 0 # Not a shellmates dispatch — do nothing
31
+ fi
32
+
33
+ # Extract job ID from tool output (dispatch.sh prints "Job ID: job-XXXX")
34
+ TOOL_OUTPUT=$(echo "$INPUT" | python3 -c "
35
+ import json, sys
36
+ data = json.load(sys.stdin)
37
+ print(data.get('tool_response', {}).get('output', ''))
38
+ " 2>/dev/null || echo "")
39
+
40
+ JOB_ID=$(echo "$TOOL_OUTPUT" | grep -oE 'job-[0-9]+-[0-9]+' | head -1)
41
+
42
+ mkdir -p "$INBOX_DIR"
43
+
44
+ # Snapshot files before waiting
45
+ BEFORE=$(ls "$INBOX_DIR" 2>/dev/null | sort)
46
+
47
+ elapsed=0
48
+ while [[ $elapsed -lt $TIMEOUT ]]; do
49
+ sleep 2
50
+ elapsed=$((elapsed + 2))
51
+
52
+ AFTER=$(ls "$INBOX_DIR" 2>/dev/null | sort)
53
+ NEW=$(comm -13 <(echo "$BEFORE") <(echo "$AFTER") | grep '\.txt$' | head -1)
54
+
55
+ # If we have a specific job ID, wait for that file; otherwise take any new file
56
+ if [[ -n "$JOB_ID" ]]; then
57
+ TARGET="${INBOX_DIR}/${JOB_ID}.txt"
58
+ [[ -f "$TARGET" ]] && NEW="${JOB_ID}.txt"
59
+ fi
60
+
61
+ if [[ -n "$NEW" ]]; then
62
+ RESULT_FILE="${INBOX_DIR}/${NEW}"
63
+ CONTENT=$(cat "$RESULT_FILE" 2>/dev/null || echo "result file unreadable")
64
+ STATUS=$(echo "$CONTENT" | grep '^STATUS:' | cut -d: -f2- | xargs)
65
+ RESULT=$(echo "$CONTENT" | grep '^RESULT:' | cut -d: -f2- | xargs)
66
+ AGENT=$(echo "$CONTENT" | grep '^AGENT:' | cut -d: -f2- | xargs)
67
+
68
+ # Print notification — Claude Code will surface this when asyncRewake fires
69
+ echo "AGENT_PING: ${AGENT:-agent} finished. STATUS: ${STATUS:-complete}. RESULT: ${RESULT:-see inbox}. File: ${NEW}"
70
+
71
+ # Exit code 2 = asyncRewake — Claude Code re-enqueues this as a task notification
72
+ exit 2
73
+ fi
74
+ done
75
+
76
+ echo "AGENT_PING: timeout after ${TIMEOUT}s — check ~/.shellmates/inbox/ manually"
77
+ exit 2
@@ -0,0 +1,10 @@
1
+ ## AGENT COMMUNICATION PROTOCOL
2
+ You are a sub-agent. Respond like an API, not a human.
3
+ - NO greetings, preamble, or sign-offs
4
+ - NO markdown headers or decorative formatting
5
+ - Output ONLY: results, file paths changed, errors, decisions
6
+ - Status updates: ≤2 lines
7
+ - Task results: ≤10 lines unless detail is explicitly required
8
+ - Use key:value pairs over prose wherever possible
9
+ - When writing completion files: structured data only, no narrative
10
+