pure-point-guard 0.1.2 → 0.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pure-point-guard",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "description": "Pure Point Guard — local orchestration runtime for parallel CLI coding agents",
6
6
  "bin": {
@@ -38,7 +38,7 @@ After classifying the mode:
38
38
  2. Read the CLI command reference at `~/.claude/skills/ppg-conductor/references/commands.md`
39
39
  3. Decompose the user's request into concrete tasks (names + prompts)
40
40
  4. **Spawn immediately** — do not ask for confirmation. The user invoked `/ppg` which signals intent to run.
41
- 5. Drive the full spawn -> poll -> aggregate -> merge loop
41
+ 5. Drive the full spawn -> poll -> aggregate -> present loop
42
42
 
43
43
  ## Core Principles
44
44
 
@@ -46,7 +46,8 @@ After classifying the mode:
46
46
  - **Always use `--no-open`** to suppress Terminal.app windows (you're driving programmatically, not watching panes)
47
47
  - **Poll every 5 seconds** — `ppg status --json` in a loop until all agents reach a terminal state
48
48
  - **One concern per worktree** — in batch mode, each task gets its own isolated worktree for clean merges
49
- - **Surface results before merging** always show the user what agents produced before offering to merge
49
+ - **Surface results and let the user decide next steps** — present what agents produced, then ask: create PRs, merge directly, review diffs, or do nothing
50
+ - **Never auto-merge or auto-PR** — always stop after presenting results and wait for the user to choose
50
51
  - **Report failures clearly** — if an agent fails, show its ID, the error, and offer to re-spawn or skip
51
52
  - **Never auto-resolve merge conflicts** — escalate to the user with the conflict details
52
53
  - **Prompt quality matters** — each agent prompt must be self-contained with full context. The agent has no memory of this conversation.
@@ -42,6 +42,7 @@ ppg spawn --name <name> --prompt-file /path/to/prompt.md --json --no-open
42
42
  ```
43
43
 
44
44
  **Options:**
45
+
45
46
  | Flag | Description |
46
47
  |------|-------------|
47
48
  | `-n, --name <name>` | Worktree/task name (default: auto-generated ID) |
@@ -167,6 +168,77 @@ ppg aggregate <worktree-id> --json # Specific worktree
167
168
 
168
169
  Results come from `.pg/results/<agentId>.md`. If no result file exists, falls back to tmux pane capture.
169
170
 
171
+ ## ppg pr
172
+
173
+ Create a GitHub PR from a worktree's branch. Pushes the branch to origin and runs `gh pr create`.
174
+
175
+ ```bash
176
+ ppg pr <wt-id> --json # Create PR (title = worktree name, body = agent results)
177
+ ppg pr <wt-id> --title "Fix auth bug" --json # Custom title
178
+ ppg pr <wt-id> --body "Description" --json # Custom body
179
+ ppg pr <wt-id> --draft --json # Create as draft PR
180
+ ```
181
+
182
+ **Options:**
183
+
184
+ | Flag | Description |
185
+ |------|-------------|
186
+ | `--title <text>` | PR title (default: worktree name) |
187
+ | `--body <text>` | PR body (default: agent result file content) |
188
+ | `--draft` | Create as draft PR |
189
+ | `--json` | JSON output |
190
+
191
+ **JSON output:**
192
+ ```json
193
+ {
194
+ "success": true,
195
+ "worktreeId": "wt-abc123",
196
+ "branch": "ppg/fix-auth-bug",
197
+ "baseBranch": "main",
198
+ "prUrl": "https://github.com/user/repo/pull/42"
199
+ }
200
+ ```
201
+
202
+ **Errors:** `WORKTREE_NOT_FOUND`, `INVALID_ARGS` (gh not installed, push failed, PR creation failed)
203
+
204
+ **Notes:**
205
+ - Requires GitHub CLI (`gh`) to be installed and authenticated
206
+ - Stores the PR URL in the manifest (`prUrl` field on the worktree entry)
207
+ - Does NOT merge or clean up the worktree — the branch stays alive for the PR lifecycle
208
+
209
+ ## ppg reset
210
+
211
+ Nuclear cleanup: kill all agents, remove all worktrees, wipe manifest entries. Includes safety checks.
212
+
213
+ ```bash
214
+ ppg reset --json # Reset (refuses if unmerged/un-PR'd work exists)
215
+ ppg reset --force --json # Force reset even with unmerged work
216
+ ppg reset --force --prune --json # Force reset + git worktree prune
217
+ ```
218
+
219
+ **Options:**
220
+
221
+ | Flag | Description |
222
+ |------|-------------|
223
+ | `--force` | Reset even if worktrees have completed work that hasn't been merged or PR'd |
224
+ | `--prune` | Also run `git worktree prune` |
225
+ | `--json` | JSON output |
226
+
227
+ **JSON output:**
228
+ ```json
229
+ {
230
+ "success": true,
231
+ "killed": ["ag-xyz12345", "ag-abc67890"],
232
+ "removed": ["wt-abc123", "wt-def456"],
233
+ "warned": ["fix-auth-bug"],
234
+ "pruned": false
235
+ }
236
+ ```
237
+
238
+ **Safety:** Without `--force`, refuses to reset if any worktree has completed agents but no PR URL and isn't merged. This prevents accidental loss of work.
239
+
240
+ **Errors:** `NOT_INITIALIZED`, `AGENTS_RUNNING` (without `--force`, when unmerged work exists)
241
+
170
242
  ## ppg merge
171
243
 
172
244
  Merge a worktree's branch back into its base branch. Default strategy is squash.
@@ -195,6 +267,64 @@ ppg merge <wt-id> --force --json # Merge even if agents aren't
195
267
 
196
268
  Cleanup sequence: kill tmux window, teardown env, `git worktree remove --force`, `git branch -D ppg/<name>`, set manifest status `cleaned`.
197
269
 
270
+ ## ppg swarm
271
+
272
+ Run a predefined swarm template — spawns multiple agents from `.pg/swarms/` with prompts from `.pg/prompts/`.
273
+
274
+ ```bash
275
+ # Run a swarm template (creates new worktree, spawns all agents)
276
+ ppg swarm code-review --var CONTEXT="Review the auth module" --json --no-open
277
+
278
+ # Run a swarm against an existing worktree (e.g., review a PR's worktree)
279
+ ppg swarm code-review --worktree wt-abc123 --var CONTEXT="Review PR #42" --json --no-open
280
+
281
+ # Override worktree name
282
+ ppg swarm code-review --name "auth-review" --var CONTEXT="Review auth changes" --json --no-open
283
+
284
+ # Target by worktree name
285
+ ppg swarm code-review --worktree feature-auth --var CONTEXT="Review auth feature" --json --no-open
286
+ ```
287
+
288
+ **Options:**
289
+
290
+ | Flag | Description |
291
+ |------|-------------|
292
+ | `-w, --worktree <ref>` | Target existing worktree by ID, name, or branch |
293
+ | `--var <KEY=value>` | Template variable (repeatable) |
294
+ | `-n, --name <name>` | Override worktree name (default: swarm name) |
295
+ | `-b, --base <branch>` | Base branch for new worktree(s) |
296
+ | `--no-open` | Suppress Terminal.app windows |
297
+ | `--json` | JSON output |
298
+
299
+ **JSON output (shared strategy):**
300
+ ```json
301
+ {
302
+ "success": true,
303
+ "swarm": "code-review",
304
+ "strategy": "shared",
305
+ "worktree": { "id": "wt-abc123", "name": "code-review", "branch": "ppg/code-review", "path": "/path/.worktrees/wt-abc123", "tmuxWindow": "ppg-repo:1" },
306
+ "agents": [
307
+ { "id": "ag-xyz12345", "tmuxTarget": "ppg-repo:1" },
308
+ { "id": "ag-abc67890", "tmuxTarget": "ppg-repo:2" }
309
+ ]
310
+ }
311
+ ```
312
+
313
+ **Errors:** `NOT_INITIALIZED`, `INVALID_ARGS` (missing template or prompt file), `WORKTREE_NOT_FOUND`
314
+
315
+ ## ppg list swarms
316
+
317
+ List available swarm templates.
318
+
319
+ ```bash
320
+ ppg list swarms --json
321
+ ```
322
+
323
+ **JSON output:**
324
+ ```json
325
+ { "swarms": [{ "name": "code-review", "description": "Multi-perspective code review", "strategy": "shared", "agents": 3 }] }
326
+ ```
327
+
198
328
  ## ppg logs
199
329
 
200
330
  View an agent's tmux pane output.
@@ -253,6 +383,7 @@ ppg wait --all --interval 10 --json # Poll every 10s (default: 5s)
253
383
  ```
254
384
 
255
385
  **Options:**
386
+
256
387
  | Flag | Description |
257
388
  |------|-------------|
258
389
  | `--all` | Wait for all agents across all worktrees |
@@ -273,6 +404,7 @@ ppg send <agent-id> "C-c" --keys # Send raw tmux keys (e.g., Ctrl-C)
273
404
  ```
274
405
 
275
406
  **Options:**
407
+
276
408
  | Flag | Description |
277
409
  |------|-------------|
278
410
  | `--keys` | Send raw tmux key names instead of literal text |
@@ -290,6 +422,7 @@ ppg restart <agent-id> --agent codex --json # Override agent type
290
422
  ```
291
423
 
292
424
  **Options:**
425
+
293
426
  | Flag | Description |
294
427
  |------|-------------|
295
428
  | `-p, --prompt <text>` | Override the original prompt |
@@ -310,6 +443,7 @@ ppg diff <wt-id> --name-only # Changed file names only
310
443
  ```
311
444
 
312
445
  **Options:**
446
+
313
447
  | Flag | Description |
314
448
  |------|-------------|
315
449
  | `--stat` | Show diffstat summary |
@@ -330,6 +464,7 @@ ppg clean --prune # Also run git worktree prune
330
464
  ```
331
465
 
332
466
  **Options:**
467
+
333
468
  | Flag | Description |
334
469
  |------|-------------|
335
470
  | `--all` | Also clean failed worktrees |
@@ -1,6 +1,6 @@
1
1
  # Conductor Loop Protocol
2
2
 
3
- The conductor loop has 5 phases: Spawn, Poll, Aggregate, Merge, Summary.
3
+ The conductor loop has 5 phases: Spawn, Poll, Aggregate, Present, Summary.
4
4
 
5
5
  ## Phase 1: Spawn
6
6
 
@@ -21,7 +21,18 @@ ppg spawn --name "<name>" --prompt "<self-contained prompt>" --json --no-open
21
21
 
22
22
  **Store a tracking table** with: worktree ID, agent IDs, name, and branch for each spawned task.
23
23
 
24
- For swarm mode with different prompts, spawn the first agent (creates the worktree), then use `--worktree <wt-id>` for subsequent agents:
24
+ **Swarm templates** If a matching swarm template exists in `.pg/swarms/`, prefer `ppg swarm` over manual multi-spawn:
25
+ ```bash
26
+ # Use a predefined swarm template (much simpler than manual spawning)
27
+ ppg swarm code-review --var CONTEXT="Review the auth module" --json --no-open
28
+
29
+ # Run a swarm against an existing worktree (e.g., review a PR's worktree)
30
+ ppg swarm code-review --worktree wt-abc123 --var CONTEXT="Review PR #42" --json --no-open
31
+ ```
32
+
33
+ Check available swarms: `ppg list swarms --json`
34
+
35
+ For **custom swarm mode** (when no template matches), spawn the first agent (creates the worktree), then use `--worktree <wt-id>` for subsequent agents:
25
36
  ```bash
26
37
  # First agent — creates the worktree
27
38
  ppg spawn --name "review" --prompt "Focus on code quality..." --json --no-open
@@ -118,40 +129,42 @@ Returns:
118
129
  - For failed agents, show what went wrong
119
130
  - Keep individual results available for the user to drill into
120
131
 
121
- ## Phase 4: Merge (Batch Mode Only)
132
+ ## Phase 4: Present Results
133
+
134
+ **Stop here and let the user decide.** Do NOT auto-merge or auto-PR.
122
135
 
123
- 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.
136
+ **For swarm mode:**
137
+ - Present synthesized findings
138
+ - The output is advisory — typically no further action needed
139
+ - If agents made code changes, ask the user what to do with them
124
140
 
125
141
  **For batch mode:**
126
142
 
127
- Present a merge checklist:
143
+ Present a results table:
128
144
  ```
129
- Ready to merge:
130
- [1] fix-auth-bug (wt-abc123) — ppg/fix-auth-bug — completed
131
- [2] add-dark-mode (wt-def456) — ppg/add-dark-mode — completed
145
+ Completed:
146
+ [1] fix-auth-bug (wt-abc123) — ppg/fix-auth-bug
147
+ [2] add-dark-mode (wt-def456) — ppg/add-dark-mode
132
148
 
133
- Cannot merge:
134
- [3] issue-15 (wt-ghi789) — ppg/issue-15 — failed
149
+ Failed:
150
+ [3] issue-15 (wt-ghi789) — ppg/issue-15
135
151
 
136
- Which would you like to merge? (e.g., "1,2" or "all" or "none")
152
+ What would you like to do?
153
+ - Create PRs: "pr 1,2" or "pr all"
154
+ - Merge directly: "merge 1,2" or "merge all"
155
+ - Review diffs first: "diff 1"
156
+ - Do nothing for now
137
157
  ```
138
158
 
139
- Wait for user confirmation, then merge each confirmed worktree:
140
-
159
+ **When the user chooses PRs:**
141
160
  ```bash
142
- ppg merge <wt-id> --json
161
+ ppg pr <wt-id> --json
143
162
  ```
163
+ This pushes the branch and creates a GitHub PR. The worktree stays alive for the PR lifecycle.
144
164
 
145
- Returns:
146
- ```json
147
- {
148
- "success": true,
149
- "worktreeId": "wt-abc123",
150
- "branch": "ppg/fix-auth-bug",
151
- "baseBranch": "main",
152
- "strategy": "squash",
153
- "cleaned": true
154
- }
165
+ **When the user chooses direct merge:**
166
+ ```bash
167
+ ppg merge <wt-id> --json
155
168
  ```
156
169
 
157
170
  **Merge conflict handling:**
@@ -160,11 +173,12 @@ Returns:
160
173
  - Offer options: "resolve manually", "skip this merge", "force merge"
161
174
  - **Never auto-resolve conflicts** — the user must decide
162
175
 
163
- **PR alternative:** If the user prefers PRs over direct merges, use `gh pr create` instead:
176
+ **Cleanup after PRs are merged externally:**
164
177
  ```bash
165
- gh pr create --head ppg/<name> --title "<title>" --body "<description from agent results>"
178
+ ppg reset --json # Refuses if unmerged work exists
179
+ ppg reset --force --json # Force cleanup
180
+ ppg clean --json # Clean only terminal-state worktrees
166
181
  ```
167
- Do NOT run `ppg merge` if creating PRs — the worktree and branch need to stay alive.
168
182
 
169
183
  ## Phase 5: Summary
170
184
 
@@ -13,12 +13,24 @@
13
13
 
14
14
  **Spawn patterns:**
15
15
 
16
- Option A — Single spawn with `--count` (same prompt, N agents):
16
+ Option A — **Swarm template** (preferred when a matching template exists):
17
+ ```
18
+ # Check available swarm templates
19
+ ppg list swarms --json
20
+
21
+ # Run a predefined swarm
22
+ ppg swarm code-review --var CONTEXT="Review the auth module" --json --no-open
23
+
24
+ # Run against an existing worktree
25
+ ppg swarm code-review --worktree <wt-id> --var CONTEXT="Review PR #42" --json --no-open
26
+ ```
27
+
28
+ Option B — Single spawn with `--count` (same prompt, N agents):
17
29
  ```
18
30
  ppg spawn --name "security-review" --prompt "Review for security vulnerabilities..." --count 3 --json --no-open
19
31
  ```
20
32
 
21
- Option B — Sequential spawns into same worktree (different prompts per agent):
33
+ Option C — Sequential spawns into same worktree (different prompts per agent):
22
34
  ```
23
35
  # First spawn creates the worktree
24
36
  ppg spawn --name "pr-review" --prompt "Review code quality and readability..." --json --no-open
@@ -27,7 +39,7 @@ ppg spawn --worktree <wt-id> --prompt "Review for performance issues..." --json
27
39
  ppg spawn --worktree <wt-id> --prompt "Review test coverage gaps..." --json --no-open
28
40
  ```
29
41
 
30
- **Option B is preferred** when each agent needs a distinct prompt (which is almost always the case).
42
+ **Option A is preferred** when a matching swarm template exists. **Option C is preferred** for custom swarm workflows where each agent needs a distinct prompt.
31
43
 
32
44
  **Post-completion:**
33
45
  1. Aggregate all results: `ppg aggregate --all --json`
@@ -69,11 +81,14 @@ Each command creates a separate worktree on its own `ppg/<name>` branch.
69
81
  **Post-completion:**
70
82
  1. Aggregate results: `ppg aggregate --all --json`
71
83
  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.
84
+ 3. **Stop and ask the user what to do next.** Options:
85
+ - Create PRs: `ppg pr <wt-id> --json` (pushes branch, creates GitHub PR)
86
+ - Merge directly: `ppg merge <wt-id> --json` (squash by default)
87
+ - Review diffs first: `ppg diff <wt-id> --json`
88
+ - Do nothing leave worktrees for manual review
89
+ 4. After PRs are merged externally: `ppg reset --json` to clean up
90
+
91
+ **Important:** Never auto-merge or auto-PR. Always present results and let the user choose the next step.
77
92
 
78
93
  ## GitHub Issue Integration
79
94