pure-point-guard 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.
@@ -0,0 +1,248 @@
1
+ # ppg CLI Command Reference
2
+
3
+ Quick reference for all ppg commands relevant to conductor workflows. Always use `--json` for machine-readable output.
4
+
5
+ ## ppg init
6
+
7
+ Initialize ppg in the current git repository. Creates `.pg/` directory structure, default config, empty manifest, and sample template.
8
+
9
+ ```bash
10
+ ppg init --json
11
+ ```
12
+
13
+ **JSON output:**
14
+ ```json
15
+ { "success": true, "projectRoot": "/path/to/repo", "sessionName": "ppg-repo", "pgDir": "/path/to/repo/.pg" }
16
+ ```
17
+
18
+ **Errors:** `NOT_GIT_REPO`, `TMUX_NOT_FOUND`
19
+
20
+ ## ppg spawn
21
+
22
+ Spawn a new worktree with agent(s), or add agents to an existing worktree.
23
+
24
+ ```bash
25
+ # New worktree + agent
26
+ ppg spawn --name <name> --prompt <text> --json --no-open
27
+
28
+ # Multiple agents in new worktree (same prompt)
29
+ ppg spawn --name <name> --prompt <text> --count <n> --json --no-open
30
+
31
+ # Add agent to existing worktree (different prompt)
32
+ ppg spawn --worktree <wt-id> --prompt <text> --json --no-open
33
+
34
+ # Specify base branch
35
+ ppg spawn --name <name> --prompt <text> --base <branch> --json --no-open
36
+
37
+ # Use a template
38
+ ppg spawn --name <name> --template <template-name> --var KEY=value --json --no-open
39
+
40
+ # Use a prompt file
41
+ ppg spawn --name <name> --prompt-file /path/to/prompt.md --json --no-open
42
+ ```
43
+
44
+ **Options:**
45
+ | Flag | Description |
46
+ |------|-------------|
47
+ | `-n, --name <name>` | Worktree/task name (default: auto-generated ID) |
48
+ | `-a, --agent <type>` | Agent type from config (default: `claude`) |
49
+ | `-p, --prompt <text>` | Inline prompt text |
50
+ | `-f, --prompt-file <path>` | Path to file containing prompt |
51
+ | `-t, --template <name>` | Template name from `.pg/templates/` |
52
+ | `--var <KEY=value>` | Template variable (repeatable) |
53
+ | `-b, --base <branch>` | Base branch (default: current branch) |
54
+ | `-w, --worktree <id>` | Add agent to existing worktree instead of creating new one |
55
+ | `-c, --count <n>` | Number of agents to spawn (default: 1) |
56
+ | `--no-open` | Suppress Terminal.app window |
57
+ | `--json` | JSON output |
58
+
59
+ **JSON output (new worktree):**
60
+ ```json
61
+ {
62
+ "success": true,
63
+ "worktree": { "id": "wt-abc123", "name": "task-name", "branch": "ppg/task-name", "path": "/path/.worktrees/wt-abc123", "tmuxWindow": "ppg-repo:1" },
64
+ "agents": [{ "id": "ag-xyz12345", "tmuxTarget": "ppg-repo:1" }]
65
+ }
66
+ ```
67
+
68
+ **JSON output (existing worktree):**
69
+ ```json
70
+ {
71
+ "success": true,
72
+ "worktree": { "id": "wt-abc123", "name": "task-name" },
73
+ "agents": [{ "id": "ag-new12345", "tmuxTarget": "%16" }]
74
+ }
75
+ ```
76
+
77
+ **Errors:** `NOT_INITIALIZED`, `WORKTREE_NOT_FOUND` (when using `--worktree`)
78
+
79
+ ## ppg status
80
+
81
+ Show status of all worktrees and agents. Refreshes agent statuses from tmux before returning.
82
+
83
+ ```bash
84
+ ppg status --json # All worktrees
85
+ ppg status <worktree-id> --json # Specific worktree
86
+ ```
87
+
88
+ **JSON output:**
89
+ ```json
90
+ {
91
+ "session": "ppg-repo",
92
+ "worktrees": {
93
+ "wt-abc123": {
94
+ "id": "wt-abc123",
95
+ "name": "task-name",
96
+ "path": "/path/.worktrees/wt-abc123",
97
+ "branch": "ppg/task-name",
98
+ "baseBranch": "main",
99
+ "status": "active",
100
+ "tmuxWindow": "ppg-repo:1",
101
+ "agents": {
102
+ "ag-xyz12345": {
103
+ "id": "ag-xyz12345",
104
+ "name": "claude",
105
+ "agentType": "claude",
106
+ "status": "running",
107
+ "tmuxTarget": "ppg-repo:1",
108
+ "prompt": "...",
109
+ "resultFile": "/path/.pg/results/ag-xyz12345.md",
110
+ "startedAt": "2025-01-01T00:00:00.000Z"
111
+ }
112
+ },
113
+ "createdAt": "2025-01-01T00:00:00.000Z"
114
+ }
115
+ }
116
+ }
117
+ ```
118
+
119
+ **Agent statuses:** `spawning` | `running` | `waiting` | `completed` | `failed` | `killed` | `lost`
120
+ **Worktree statuses:** `active` | `merging` | `merged` | `failed` | `cleaned`
121
+
122
+ ## ppg kill
123
+
124
+ Kill running agents. Can target a single agent, all agents in a worktree, or everything.
125
+
126
+ ```bash
127
+ ppg kill --agent <agent-id> --json # Kill one agent
128
+ ppg kill --worktree <wt-id> --json # Kill all agents in worktree
129
+ ppg kill --worktree <wt-id> --remove --json # Kill + remove worktree
130
+ ppg kill --all --json # Kill everything
131
+ ppg kill --all --remove --json # Kill everything + cleanup
132
+ ```
133
+
134
+ **JSON output:**
135
+ ```json
136
+ { "success": true, "killed": ["ag-xyz12345"], "removed": false }
137
+ ```
138
+
139
+ ## ppg aggregate
140
+
141
+ Collect result files from completed agents.
142
+
143
+ ```bash
144
+ ppg aggregate --all --json # All worktrees
145
+ ppg aggregate <worktree-id> --json # Specific worktree
146
+ ```
147
+
148
+ **JSON output:**
149
+ ```json
150
+ {
151
+ "results": [
152
+ {
153
+ "agentId": "ag-xyz12345",
154
+ "worktreeId": "wt-abc123",
155
+ "worktreeName": "task-name",
156
+ "branch": "ppg/task-name",
157
+ "status": "completed",
158
+ "content": "Full text content of the agent's result file..."
159
+ }
160
+ ]
161
+ }
162
+ ```
163
+
164
+ Results come from `.pg/results/<agentId>.md`. If no result file exists, falls back to tmux pane capture.
165
+
166
+ ## ppg merge
167
+
168
+ Merge a worktree's branch back into its base branch. Default strategy is squash.
169
+
170
+ ```bash
171
+ ppg merge <wt-id> --json # Squash merge + cleanup
172
+ ppg merge <wt-id> --strategy no-ff --json # Merge commit (preserves history)
173
+ ppg merge <wt-id> --no-cleanup --json # Merge but keep worktree alive
174
+ ppg merge <wt-id> --dry-run # Preview without doing anything
175
+ ppg merge <wt-id> --force --json # Merge even if agents aren't done
176
+ ```
177
+
178
+ **JSON output:**
179
+ ```json
180
+ {
181
+ "success": true,
182
+ "worktreeId": "wt-abc123",
183
+ "branch": "ppg/task-name",
184
+ "baseBranch": "main",
185
+ "strategy": "squash",
186
+ "cleaned": true
187
+ }
188
+ ```
189
+
190
+ **Errors:** `WORKTREE_NOT_FOUND`, merge conflict (git error), agents still running (without `--force`)
191
+
192
+ Cleanup sequence: kill tmux window, teardown env, `git worktree remove --force`, `git branch -D ppg/<name>`, set manifest status `cleaned`.
193
+
194
+ ## ppg logs
195
+
196
+ View an agent's tmux pane output.
197
+
198
+ ```bash
199
+ ppg logs <agent-id> --json # Last 100 lines
200
+ ppg logs <agent-id> --lines 500 --json # Last 500 lines
201
+ ppg logs <agent-id> --full --json # Full history
202
+ ```
203
+
204
+ **JSON output:**
205
+ ```json
206
+ { "agentId": "ag-xyz12345", "status": "running", "tmuxTarget": "ppg-repo:1", "output": "pane content..." }
207
+ ```
208
+
209
+ ## ppg worktree create
210
+
211
+ Create a standalone worktree without spawning any agents. Useful when you want to set up the worktree first, then add agents later.
212
+
213
+ ```bash
214
+ ppg worktree create --name <name> --json
215
+ ppg worktree create --name <name> --base <branch> --json
216
+ ```
217
+
218
+ **JSON output:**
219
+ ```json
220
+ {
221
+ "success": true,
222
+ "worktree": { "id": "wt-abc123", "name": "task-name", "branch": "ppg/task-name", "baseBranch": "main", "path": "/path/.worktrees/wt-abc123" }
223
+ }
224
+ ```
225
+
226
+ ## ppg list templates
227
+
228
+ List available prompt templates.
229
+
230
+ ```bash
231
+ ppg list templates --json
232
+ ```
233
+
234
+ **JSON output:**
235
+ ```json
236
+ { "templates": [{ "name": "default", "description": "Task template", "variables": ["TASK_NAME", "PROMPT", "WORKTREE_PATH"] }] }
237
+ ```
238
+
239
+ ## Error Codes
240
+
241
+ | Code | Meaning | Recovery |
242
+ |------|---------|----------|
243
+ | `TMUX_NOT_FOUND` | tmux not installed | Fatal — user must install tmux |
244
+ | `NOT_GIT_REPO` | Not inside a git repository | Fatal — user must cd to a repo |
245
+ | `NOT_INITIALIZED` | `.pg/` directory missing | Auto-fix: run `ppg init --json` |
246
+ | `MANIFEST_LOCK` | Could not acquire manifest lock | Retry after brief delay (rare) |
247
+ | `WORKTREE_NOT_FOUND` | Worktree ID/name not in manifest | Check `ppg status --json` for valid IDs |
248
+ | `AGENT_NOT_FOUND` | Agent ID not in manifest | Check `ppg status --json` for valid IDs |
@@ -0,0 +1,183 @@
1
+ # Conductor Loop Protocol
2
+
3
+ The conductor loop has 5 phases: Spawn, Poll, Aggregate, Merge, Summary.
4
+
5
+ ## Phase 1: Spawn
6
+
7
+ For each task, run `ppg spawn` and capture the JSON output.
8
+
9
+ ```bash
10
+ ppg spawn --name "<name>" --prompt "<self-contained prompt>" --json --no-open
11
+ ```
12
+
13
+ **Track the output.** Each spawn returns:
14
+ ```json
15
+ {
16
+ "success": true,
17
+ "worktree": { "id": "wt-abc123", "name": "task-name", "branch": "ppg/task-name", "path": "/path/to/.worktrees/wt-abc123", "tmuxWindow": "ppg-project:1" },
18
+ "agents": [{ "id": "ag-xyz12345", "tmuxTarget": "ppg-project:1" }]
19
+ }
20
+ ```
21
+
22
+ **Store a tracking table** with: worktree ID, agent IDs, name, and branch for each spawned task.
23
+
24
+ For swarm mode with different prompts, spawn the first agent (creates the worktree), then use `--worktree <wt-id>` for subsequent agents:
25
+ ```bash
26
+ # First agent — creates the worktree
27
+ ppg spawn --name "review" --prompt "Focus on code quality..." --json --no-open
28
+ # Additional agents — join existing worktree
29
+ ppg spawn --worktree wt-abc123 --prompt "Focus on security..." --json --no-open
30
+ ppg spawn --worktree wt-abc123 --prompt "Focus on performance..." --json --no-open
31
+ ```
32
+
33
+ **Error handling during spawn:**
34
+ - If spawn fails, report the error and continue with remaining tasks
35
+ - Common errors: `NOT_INITIALIZED` (auto-fix with `ppg init`), `TMUX_NOT_FOUND` (fatal — tell user to install tmux)
36
+
37
+ ## Phase 2: Poll
38
+
39
+ Poll `ppg status --json` every 5 seconds until all agents reach a terminal state.
40
+
41
+ ```bash
42
+ ppg status --json
43
+ ```
44
+
45
+ Returns:
46
+ ```json
47
+ {
48
+ "session": "ppg-project",
49
+ "worktrees": {
50
+ "wt-abc123": {
51
+ "id": "wt-abc123",
52
+ "name": "task-name",
53
+ "status": "active",
54
+ "branch": "ppg/task-name",
55
+ "agents": {
56
+ "ag-xyz12345": {
57
+ "id": "ag-xyz12345",
58
+ "status": "running",
59
+ "agentType": "claude",
60
+ "startedAt": "2025-01-01T00:00:00.000Z"
61
+ }
62
+ }
63
+ }
64
+ }
65
+ }
66
+ ```
67
+
68
+ **Terminal states** for agents: `completed`, `failed`, `killed`, `lost`
69
+ **Non-terminal states**: `spawning`, `running`, `waiting`
70
+
71
+ **Polling behavior:**
72
+ - Show a brief status update each cycle: `"Polling... 2/5 agents completed, 3 running"`
73
+ - After **2 minutes**: mention that agents are still running and show elapsed time
74
+ - After **10 minutes**: warn the user and offer to continue waiting or kill remaining agents
75
+ - On `failed` or `lost`: immediately report the agent ID and worktree, offer to re-spawn or skip
76
+
77
+ **Stop polling when:** all tracked agents are in terminal states.
78
+
79
+ ## Phase 3: Aggregate
80
+
81
+ Collect results from completed agents.
82
+
83
+ ```bash
84
+ ppg aggregate --all --json
85
+ ```
86
+
87
+ Returns:
88
+ ```json
89
+ {
90
+ "results": [
91
+ {
92
+ "agentId": "ag-xyz12345",
93
+ "worktreeId": "wt-abc123",
94
+ "worktreeName": "task-name",
95
+ "branch": "ppg/task-name",
96
+ "status": "completed",
97
+ "content": "## Results\n\nThe agent's output from its result file..."
98
+ }
99
+ ]
100
+ }
101
+ ```
102
+
103
+ **For swarm mode:**
104
+ - Read all results
105
+ - Identify common themes, agreements, and conflicts across agents
106
+ - Synthesize into a unified summary with attribution (which agent said what)
107
+ - Highlight any disagreements between agents
108
+
109
+ **For batch mode:**
110
+ - Present a table: task name | status | branch | brief summary of result
111
+ - For failed agents, show what went wrong
112
+ - Keep individual results available for the user to drill into
113
+
114
+ ## Phase 4: Merge (Batch Mode Only)
115
+
116
+ Swarm mode typically skips merge — the output is advisory. Only merge in swarm mode if agents were explicitly asked to make code changes AND the user confirms.
117
+
118
+ **For batch mode:**
119
+
120
+ Present a merge checklist:
121
+ ```
122
+ Ready to merge:
123
+ [1] fix-auth-bug (wt-abc123) — ppg/fix-auth-bug — completed
124
+ [2] add-dark-mode (wt-def456) — ppg/add-dark-mode — completed
125
+
126
+ Cannot merge:
127
+ [3] issue-15 (wt-ghi789) — ppg/issue-15 — failed
128
+
129
+ Which would you like to merge? (e.g., "1,2" or "all" or "none")
130
+ ```
131
+
132
+ Wait for user confirmation, then merge each confirmed worktree:
133
+
134
+ ```bash
135
+ ppg merge <wt-id> --json
136
+ ```
137
+
138
+ Returns:
139
+ ```json
140
+ {
141
+ "success": true,
142
+ "worktreeId": "wt-abc123",
143
+ "branch": "ppg/fix-auth-bug",
144
+ "baseBranch": "main",
145
+ "strategy": "squash",
146
+ "cleaned": true
147
+ }
148
+ ```
149
+
150
+ **Merge conflict handling:**
151
+ - If `ppg merge` fails, capture the error
152
+ - Report the conflict to the user with: branch name, conflicting files if available
153
+ - Offer options: "resolve manually", "skip this merge", "force merge"
154
+ - **Never auto-resolve conflicts** — the user must decide
155
+
156
+ **PR alternative:** If the user prefers PRs over direct merges, use `gh pr create` instead:
157
+ ```bash
158
+ gh pr create --head ppg/<name> --title "<title>" --body "<description from agent results>"
159
+ ```
160
+ Do NOT run `ppg merge` if creating PRs — the worktree and branch need to stay alive.
161
+
162
+ ## Phase 5: Summary
163
+
164
+ Present a final summary covering the entire run:
165
+
166
+ **For swarm mode:**
167
+ ```
168
+ ## Swarm Summary
169
+ - Subject: <what was reviewed/analyzed>
170
+ - Agents: N spawned, N completed, N failed
171
+ - Key findings: <synthesized highlights>
172
+ ```
173
+
174
+ **For batch mode:**
175
+ ```
176
+ ## Batch Summary
177
+ - Tasks: N spawned, N completed, N failed
178
+ - Merged: N worktrees into <base-branch>
179
+ - Skipped: N (list reasons)
180
+ - PRs created: N (if applicable)
181
+ ```
182
+
183
+ Include any follow-up actions the user might want to take.
@@ -0,0 +1,85 @@
1
+ # Conductor Modes
2
+
3
+ ## Swarm Mode — Multiple Agents, One Worktree
4
+
5
+ **Trigger signals:** "review", "audit", "analyze", "perspectives", "opinions", "critique", "evaluate", "assess", "examine", "check from multiple angles"
6
+
7
+ **Concept:** Multiple agents work on the SAME codebase in the SAME worktree. Each agent brings a different perspective or focus area. Their outputs are aggregated and synthesized — no merge needed because they produce analysis, not code changes.
8
+
9
+ **Task decomposition:**
10
+ 1. Identify the subject (PR, file, module, system)
11
+ 2. Define N perspectives — each gets a unique angle and prompt
12
+ 3. Each prompt should specify: what to focus on, what format to produce results in, and what the result file should contain
13
+
14
+ **Spawn patterns:**
15
+
16
+ Option A — Single spawn with `--count` (same prompt, N agents):
17
+ ```
18
+ ppg spawn --name "security-review" --prompt "Review for security vulnerabilities..." --count 3 --json --no-open
19
+ ```
20
+
21
+ Option B — Sequential spawns into same worktree (different prompts per agent):
22
+ ```
23
+ # First spawn creates the worktree
24
+ ppg spawn --name "pr-review" --prompt "Review code quality and readability..." --json --no-open
25
+ # Capture worktree ID from JSON output, then:
26
+ ppg spawn --worktree <wt-id> --prompt "Review for performance issues..." --json --no-open
27
+ ppg spawn --worktree <wt-id> --prompt "Review test coverage gaps..." --json --no-open
28
+ ```
29
+
30
+ **Option B is preferred** when each agent needs a distinct prompt (which is almost always the case).
31
+
32
+ **Post-completion:**
33
+ 1. Aggregate all results: `ppg aggregate --all --json`
34
+ 2. Synthesize findings — identify common themes, conflicts, and unique insights
35
+ 3. Present a unified summary to the user
36
+ 4. Typically NO merge — swarm output is advisory. If agents did make code changes, ask the user before merging.
37
+
38
+ **Suggested swarm sizes:**
39
+ - Code review: 3-4 agents (quality, security, performance, testing)
40
+ - Architecture review: 3 agents (design patterns, scalability, maintainability)
41
+ - Bug hunt: 2-3 agents (different hypotheses about root cause)
42
+
43
+ ## Batch Mode — One Worktree Per Task
44
+
45
+ **Trigger signals:** "issues", "tickets", "tasks", "fix all", "one PR per", "implement these features", "work on #N", "tackle", "each in its own branch"
46
+
47
+ **Concept:** Each task gets its own isolated worktree and branch. Agents work independently on separate concerns. Each completed worktree can be merged individually, becoming its own commit (or PR if the user wants).
48
+
49
+ **Task decomposition:**
50
+ 1. Gather the list of tasks — from GitHub issues, user description, or codebase analysis
51
+ 2. For each task, define:
52
+ - **name**: Short kebab-case identifier (e.g., `fix-auth-bug`, `add-dark-mode`, `issue-15`)
53
+ - **prompt**: Self-contained description with full context. The agent knows nothing about the other tasks or this conversation.
54
+ 3. Each prompt MUST include:
55
+ - What to do (the task)
56
+ - Where to find relevant code (files, modules, patterns)
57
+ - What "done" looks like (acceptance criteria)
58
+ - Instruction to write results to `{{RESULT_FILE}}`
59
+
60
+ **Spawn pattern:**
61
+ ```
62
+ ppg spawn --name "fix-auth-bug" --prompt "Fix the authentication bug where..." --json --no-open
63
+ ppg spawn --name "add-dark-mode" --prompt "Implement dark mode toggle..." --json --no-open
64
+ ppg spawn --name "issue-15" --prompt "Resolve issue #15: ..." --json --no-open
65
+ ```
66
+
67
+ Each command creates a separate worktree on its own `ppg/<name>` branch.
68
+
69
+ **Post-completion:**
70
+ 1. Aggregate results: `ppg aggregate --all --json`
71
+ 2. Present a summary table: task name, status, branch, key findings
72
+ 3. Present a **merge checklist** — list each worktree with its status and ask which to merge
73
+ 4. Merge confirmed ones: `ppg merge <wt-id> --json` (squash by default)
74
+ 5. Optionally create PRs: `gh pr create --head ppg/<name> --title "..." --body "..."` (if user wants PRs instead of direct merges)
75
+
76
+ **Important:** In batch mode, always surface results and get user confirmation before merging. The user may want to review diffs, skip some tasks, or create PRs instead.
77
+
78
+ ## GitHub Issue Integration
79
+
80
+ When the user references GitHub issues (e.g., `#12`, `#15`):
81
+
82
+ 1. Fetch issue details: `gh issue view <number> --json title,body,labels,assignees`
83
+ 2. Use the issue title and body as context for the agent prompt
84
+ 3. Name the worktree after the issue: `issue-<number>`
85
+ 4. After merge, optionally close the issue: `gh issue close <number>` (ask the user first)