diff --git a/skills/ppg-conductor/references/commands.md b/skills/ppg-conductor/references/commands.md index dbc01c0..c6b6c62 100644 --- a/skills/ppg-conductor/references/commands.md +++ b/skills/ppg-conductor/references/commands.md @@ -42,6 +42,7 @@ ppg spawn --name --prompt-file /path/to/prompt.md --json --no-open ``` **Options:** + | Flag | Description | |------|-------------| | `-n, --name ` | Worktree/task name (default: auto-generated ID) | @@ -195,6 +196,64 @@ ppg merge --force --json # Merge even if agents aren't Cleanup sequence: kill tmux window, teardown env, `git worktree remove --force`, `git branch -D ppg/`, set manifest status `cleaned`. +## ppg swarm + +Run a predefined swarm template — spawns multiple agents from `.pg/swarms/` with prompts from `.pg/prompts/`. + +```bash +# Run a swarm template (creates new worktree, spawns all agents) +ppg swarm code-review --var CONTEXT="Review the auth module" --json --no-open + +# Run a swarm against an existing worktree (e.g., review a PR's worktree) +ppg swarm code-review --worktree wt-abc123 --var CONTEXT="Review PR #42" --json --no-open + +# Override worktree name +ppg swarm code-review --name "auth-review" --var CONTEXT="Review auth changes" --json --no-open + +# Target by worktree name +ppg swarm code-review --worktree feature-auth --var CONTEXT="Review auth feature" --json --no-open +``` + +**Options:** + +| Flag | Description | +|------|-------------| +| `-w, --worktree ` | Target existing worktree by ID, name, or branch | +| `--var ` | Template variable (repeatable) | +| `-n, --name ` | Override worktree name (default: swarm name) | +| `-b, --base ` | Base branch for new worktree(s) | +| `--no-open` | Suppress Terminal.app windows | +| `--json` | JSON output | + +**JSON output (shared strategy):** +```json +{ + "success": true, + "swarm": "code-review", + "strategy": "shared", + "worktree": { "id": "wt-abc123", "name": "code-review", "branch": "ppg/code-review", "path": "/path/.worktrees/wt-abc123", "tmuxWindow": "ppg-repo:1" }, + "agents": [ + { "id": "ag-xyz12345", "tmuxTarget": "ppg-repo:1" }, + { "id": "ag-abc67890", "tmuxTarget": "ppg-repo:2" } + ] +} +``` + +**Errors:** `NOT_INITIALIZED`, `INVALID_ARGS` (missing template or prompt file), `WORKTREE_NOT_FOUND` + +## ppg list swarms + +List available swarm templates. + +```bash +ppg list swarms --json +``` + +**JSON output:** +```json +{ "swarms": [{ "name": "code-review", "description": "Multi-perspective code review", "strategy": "shared", "agents": 3 }] } +``` + ## ppg logs View an agent's tmux pane output. @@ -253,6 +312,7 @@ ppg wait --all --interval 10 --json # Poll every 10s (default: 5s) ``` **Options:** + | Flag | Description | |------|-------------| | `--all` | Wait for all agents across all worktrees | @@ -273,6 +333,7 @@ ppg send "C-c" --keys # Send raw tmux keys (e.g., Ctrl-C) ``` **Options:** + | Flag | Description | |------|-------------| | `--keys` | Send raw tmux key names instead of literal text | @@ -290,6 +351,7 @@ ppg restart --agent codex --json # Override agent type ``` **Options:** + | Flag | Description | |------|-------------| | `-p, --prompt ` | Override the original prompt | @@ -310,6 +372,7 @@ ppg diff --name-only # Changed file names only ``` **Options:** + | Flag | Description | |------|-------------| | `--stat` | Show diffstat summary | @@ -330,6 +393,7 @@ ppg clean --prune # Also run git worktree prune ``` **Options:** + | Flag | Description | |------|-------------| | `--all` | Also clean failed worktrees | diff --git a/skills/ppg-conductor/references/conductor.md b/skills/ppg-conductor/references/conductor.md index 780aeeb..da8bfde 100644 --- a/skills/ppg-conductor/references/conductor.md +++ b/skills/ppg-conductor/references/conductor.md @@ -21,7 +21,18 @@ ppg spawn --name "" --prompt "" --json --no-open **Store a tracking table** with: worktree ID, agent IDs, name, and branch for each spawned task. -For swarm mode with different prompts, spawn the first agent (creates the worktree), then use `--worktree ` for subsequent agents: +**Swarm templates** — If a matching swarm template exists in `.pg/swarms/`, prefer `ppg swarm` over manual multi-spawn: +```bash +# Use a predefined swarm template (much simpler than manual spawning) +ppg swarm code-review --var CONTEXT="Review the auth module" --json --no-open + +# Run a swarm against an existing worktree (e.g., review a PR's worktree) +ppg swarm code-review --worktree wt-abc123 --var CONTEXT="Review PR #42" --json --no-open +``` + +Check available swarms: `ppg list swarms --json` + +For **custom swarm mode** (when no template matches), spawn the first agent (creates the worktree), then use `--worktree ` for subsequent agents: ```bash # First agent — creates the worktree ppg spawn --name "review" --prompt "Focus on code quality..." --json --no-open diff --git a/skills/ppg-conductor/references/modes.md b/skills/ppg-conductor/references/modes.md index a1356f0..245aeab 100644 --- a/skills/ppg-conductor/references/modes.md +++ b/skills/ppg-conductor/references/modes.md @@ -13,12 +13,24 @@ **Spawn patterns:** -Option A — Single spawn with `--count` (same prompt, N agents): +Option A — **Swarm template** (preferred when a matching template exists): +``` +# Check available swarm templates +ppg list swarms --json + +# Run a predefined swarm +ppg swarm code-review --var CONTEXT="Review the auth module" --json --no-open + +# Run against an existing worktree +ppg swarm code-review --worktree --var CONTEXT="Review PR #42" --json --no-open +``` + +Option B — Single spawn with `--count` (same prompt, N agents): ``` ppg spawn --name "security-review" --prompt "Review for security vulnerabilities..." --count 3 --json --no-open ``` -Option B — Sequential spawns into same worktree (different prompts per agent): +Option C — Sequential spawns into same worktree (different prompts per agent): ``` # First spawn creates the worktree ppg spawn --name "pr-review" --prompt "Review code quality and readability..." --json --no-open @@ -27,7 +39,7 @@ ppg spawn --worktree --prompt "Review for performance issues..." --json ppg spawn --worktree --prompt "Review test coverage gaps..." --json --no-open ``` -**Option B is preferred** when each agent needs a distinct prompt (which is almost always the case). +**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. **Post-completion:** 1. Aggregate all results: `ppg aggregate --all --json` diff --git a/src/bundled/prompts.ts b/src/bundled/prompts.ts new file mode 100644 index 0000000..823bde7 --- /dev/null +++ b/src/bundled/prompts.ts @@ -0,0 +1,56 @@ +export const bundledPrompts: Record = { + 'review-quality': `# Code Quality Review + +## What to Review +{{CONTEXT}} + +## Your Focus +You are a senior engineer reviewing code for quality, readability, and maintainability. + +- Code clarity and naming conventions +- Function and module organization +- Error handling completeness +- DRY violations and unnecessary complexity +- API design and consistency +- Documentation gaps for non-obvious logic + +## Output +Write a structured review to {{RESULT_FILE}} with specific file:line references and improvement suggestions. +`, + 'review-security': `# Security Review + +## What to Review +{{CONTEXT}} + +## Your Focus +You are a security engineer reviewing code for vulnerabilities and risks. + +- Input validation and sanitization +- Injection vulnerabilities (SQL, XSS, command) +- Authentication and authorization issues +- Sensitive data exposure +- Dependency vulnerabilities +- Secrets or credentials in code + +## Output +Write a structured review to {{RESULT_FILE}} with severity ratings and remediation guidance. +`, + 'review-regression': `# Regression & Risk Review + +## What to Review +{{CONTEXT}} + +## Your Focus +You are a QA engineer reviewing code for regression risks and test coverage gaps. + +- Behavioral changes that could break existing functionality +- Edge cases and boundary conditions not covered +- Missing or inadequate test coverage +- Integration points that may be affected +- Data migration or compatibility concerns +- Performance regressions + +## Output +Write a structured review to {{RESULT_FILE}} with risk ratings and recommended test additions. +`, +}; diff --git a/src/bundled/swarms.ts b/src/bundled/swarms.ts new file mode 100644 index 0000000..9fd41e7 --- /dev/null +++ b/src/bundled/swarms.ts @@ -0,0 +1,11 @@ +export const bundledSwarms: Record = { + 'code-review': `name: code-review +description: Multi-perspective code review +strategy: shared + +agents: + - prompt: review-quality + - prompt: review-security + - prompt: review-regression +`, +}; diff --git a/src/cli.ts b/src/cli.ts index 3bd6416..b522247 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -115,10 +115,25 @@ program await mergeCommand(worktreeId, options); }); +program + .command('swarm') + .description('Run a swarm template — spawn multiple agents from a predefined workflow') + .argument('