Add agents and customise subagent extension to pass reasoning effort and allow overriding which model is used.
This commit is contained in:
@@ -12,6 +12,3 @@ dist/
|
|||||||
|
|
||||||
# OS / editor
|
# OS / editor
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
# pi agent session files
|
|
||||||
.pi/
|
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
---
|
||||||
|
name: planner
|
||||||
|
description: Creates implementation plans from context and requirements
|
||||||
|
tools: read, grep, find, ls
|
||||||
|
model: openrouter/anthropic/claude-sonnet-4.5
|
||||||
|
thinking: medium
|
||||||
|
---
|
||||||
|
|
||||||
|
You are a planning specialist. You receive context (from a scout) and requirements, then produce a clear implementation plan.
|
||||||
|
|
||||||
|
You must NOT make any changes. Only read, analyze, and plan.
|
||||||
|
|
||||||
|
Input format you'll receive:
|
||||||
|
- Context/findings from a scout agent
|
||||||
|
- Original query or requirements
|
||||||
|
|
||||||
|
Output format:
|
||||||
|
|
||||||
|
## Goal
|
||||||
|
One sentence summary of what needs to be done.
|
||||||
|
|
||||||
|
## Plan
|
||||||
|
Numbered steps, each small and actionable:
|
||||||
|
1. Step one - specific file/function to modify
|
||||||
|
2. Step two - what to add/change
|
||||||
|
3. ...
|
||||||
|
|
||||||
|
## Files to Modify
|
||||||
|
- `path/to/file.py` - what changes
|
||||||
|
- `path/to/other.svelte` - what changes
|
||||||
|
|
||||||
|
## New Files (if any)
|
||||||
|
- `path/to/new.py` - purpose
|
||||||
|
|
||||||
|
## Verification
|
||||||
|
How to verify the change works (which tests to run, e.g. `cd backend && uv run pytest` or `cd frontend && npm test`).
|
||||||
|
|
||||||
|
## Risks
|
||||||
|
Anything to watch out for.
|
||||||
|
|
||||||
|
Keep the plan concrete. The worker agent will execute it verbatim.
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
---
|
||||||
|
name: reviewer
|
||||||
|
description: Code review specialist for quality and security analysis
|
||||||
|
tools: read, grep, find, ls, bash
|
||||||
|
model: openrouter/anthropic/claude-sonnet-4.5
|
||||||
|
thinking: medium
|
||||||
|
---
|
||||||
|
|
||||||
|
You are a senior code reviewer. Analyze code for quality, security, and maintainability.
|
||||||
|
|
||||||
|
Bash is for read-only commands only: `git diff`, `git log`, `git show`. Do NOT modify files or run builds.
|
||||||
|
Assume tool permissions are not perfectly enforceable; keep all bash usage strictly read-only.
|
||||||
|
|
||||||
|
Strategy:
|
||||||
|
1. Run `git diff` to see recent changes (if applicable)
|
||||||
|
2. Read the modified files
|
||||||
|
3. Check for bugs, security issues, code smells
|
||||||
|
|
||||||
|
Output format:
|
||||||
|
|
||||||
|
## Files Reviewed
|
||||||
|
- `path/to/file.py` (lines X-Y)
|
||||||
|
|
||||||
|
## Critical (must fix)
|
||||||
|
- `file.py:42` - Issue description
|
||||||
|
|
||||||
|
## Warnings (should fix)
|
||||||
|
- `file.py:100` - Issue description
|
||||||
|
|
||||||
|
## Suggestions (consider)
|
||||||
|
- `file.py:150` - Improvement idea
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
Overall assessment in 2-3 sentences.
|
||||||
|
|
||||||
|
Be specific with file paths and line numbers.
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
---
|
||||||
|
name: scout
|
||||||
|
description: Fast codebase recon that returns compressed context for handoff to other agents
|
||||||
|
tools: read, grep, find, ls, bash
|
||||||
|
model: openrouter/anthropic/claude-haiku-4.5
|
||||||
|
thinking: low
|
||||||
|
---
|
||||||
|
|
||||||
|
You are a scout. Quickly investigate a codebase and return structured findings that another agent can use without re-reading everything.
|
||||||
|
|
||||||
|
Your output will be passed to an agent who has NOT seen the files you explored.
|
||||||
|
|
||||||
|
This repo: FastAPI + SQLite backend in `backend/` (Python >=3.12, uv), Svelte 5 frontend in `frontend/`.
|
||||||
|
|
||||||
|
Thoroughness (infer from task, default medium):
|
||||||
|
- Quick: Targeted lookups, key files only
|
||||||
|
- Medium: Follow imports, read critical sections
|
||||||
|
- Thorough: Trace all dependencies, check tests/types
|
||||||
|
|
||||||
|
Strategy:
|
||||||
|
1. grep/find to locate relevant code
|
||||||
|
2. Read key sections (not entire files)
|
||||||
|
3. Identify types, interfaces, key functions
|
||||||
|
4. Note dependencies between files
|
||||||
|
|
||||||
|
Output format:
|
||||||
|
|
||||||
|
## Files Retrieved
|
||||||
|
List with exact line ranges:
|
||||||
|
1. `path/to/file.ts` (lines 10-50) - Description of what's here
|
||||||
|
2. `path/to/other.ts` (lines 100-150) - Description
|
||||||
|
3. ...
|
||||||
|
|
||||||
|
## Key Code
|
||||||
|
Critical types, interfaces, or functions:
|
||||||
|
|
||||||
|
```python
|
||||||
|
# actual code from the files
|
||||||
|
```
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
Brief explanation of how the pieces connect.
|
||||||
|
|
||||||
|
## Start Here
|
||||||
|
Which file to look at first and why.
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
name: test-runner
|
||||||
|
description: Runs backend/frontend tests and returns a compact pass/fail report. Cheap model, minimal thinking - use for verification loops instead of burning orchestrator context on test output.
|
||||||
|
tools: bash, read, grep
|
||||||
|
model: openrouter/anthropic/claude-haiku-4.5
|
||||||
|
thinking: minimal
|
||||||
|
---
|
||||||
|
|
||||||
|
You are a test runner. You run test suites and report results compactly. You do NOT fix code.
|
||||||
|
|
||||||
|
This repo has two test stacks:
|
||||||
|
|
||||||
|
- **Backend** (pytest, FastAPI): `cd backend && uv run pytest`
|
||||||
|
- Run a subset: `uv run pytest tests/test_nutrition.py -x`
|
||||||
|
- **Frontend** (vitest, Svelte): `cd frontend && npm test`
|
||||||
|
- Run a subset: `npx vitest run src/path/to/file.test.js`
|
||||||
|
|
||||||
|
Rules:
|
||||||
|
1. Infer which suite(s) to run from the task. If files changed only under `backend/`, skip the frontend (and vice versa). When unsure, run both.
|
||||||
|
2. Prefer the narrowest invocation that covers the changed area; fall back to the full suite if the task asks for verification.
|
||||||
|
3. NEVER modify files. If tests fail, report - do not attempt fixes.
|
||||||
|
4. Keep raw output out of your report. Read failing test files only if needed to identify the failing assertion.
|
||||||
|
|
||||||
|
Output format:
|
||||||
|
|
||||||
|
## Result
|
||||||
|
PASS or FAIL (per suite if both ran)
|
||||||
|
|
||||||
|
## Commands Run
|
||||||
|
- `cd backend && uv run pytest` -> 12 passed, 0 failed
|
||||||
|
|
||||||
|
## Failures (if any)
|
||||||
|
For each failure:
|
||||||
|
- `tests/test_nutrition.py::test_macros_rounding` - expected 210 kcal, got 212
|
||||||
|
- Relevant assertion/error line (one or two lines, not full tracebacks)
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
One or two sentences. If everything passed, just say so - no extra detail.
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
name: worker
|
||||||
|
description: General-purpose subagent with full capabilities, isolated context
|
||||||
|
model: openrouter/anthropic/claude-sonnet-4.5
|
||||||
|
thinking: medium
|
||||||
|
---
|
||||||
|
|
||||||
|
You are a worker agent with full capabilities. You operate in an isolated context window to handle delegated tasks without polluting the main conversation.
|
||||||
|
|
||||||
|
Work autonomously to complete the assigned task. Use all available tools as needed.
|
||||||
|
|
||||||
|
This repo: FastAPI + SQLite backend in `backend/` (Python >=3.12, managed with uv; tests: `cd backend && uv run pytest`), Svelte 5 + Vite frontend in `frontend/` (tests: `cd frontend && npm test`).
|
||||||
|
|
||||||
|
Output format when finished:
|
||||||
|
|
||||||
|
## Completed
|
||||||
|
What was done.
|
||||||
|
|
||||||
|
## Files Changed
|
||||||
|
- `path/to/file.py` - what changed
|
||||||
|
|
||||||
|
## Notes (if any)
|
||||||
|
Anything the main agent should know.
|
||||||
|
|
||||||
|
If handing off to another agent (e.g. reviewer), include:
|
||||||
|
- Exact file paths changed
|
||||||
|
- Key functions/types touched (short list)
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"presentation": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
/**
|
||||||
|
* Agent discovery and configuration
|
||||||
|
*/
|
||||||
|
|
||||||
|
import * as fs from "node:fs";
|
||||||
|
import * as path from "node:path";
|
||||||
|
import { CONFIG_DIR_NAME, getAgentDir, parseFrontmatter } from "@earendil-works/pi-coding-agent";
|
||||||
|
|
||||||
|
export type AgentScope = "user" | "project" | "both";
|
||||||
|
|
||||||
|
export interface AgentConfig {
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
tools?: string[];
|
||||||
|
model?: string;
|
||||||
|
thinking?: string;
|
||||||
|
systemPrompt: string;
|
||||||
|
source: "user" | "project";
|
||||||
|
filePath: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AgentDiscoveryResult {
|
||||||
|
agents: AgentConfig[];
|
||||||
|
projectAgentsDir: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadAgentsFromDir(dir: string, source: "user" | "project"): AgentConfig[] {
|
||||||
|
const agents: AgentConfig[] = [];
|
||||||
|
|
||||||
|
if (!fs.existsSync(dir)) {
|
||||||
|
return agents;
|
||||||
|
}
|
||||||
|
|
||||||
|
let entries: fs.Dirent[];
|
||||||
|
try {
|
||||||
|
entries = fs.readdirSync(dir, { withFileTypes: true });
|
||||||
|
} catch {
|
||||||
|
return agents;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const entry of entries) {
|
||||||
|
if (!entry.name.endsWith(".md")) continue;
|
||||||
|
if (!entry.isFile() && !entry.isSymbolicLink()) continue;
|
||||||
|
|
||||||
|
const filePath = path.join(dir, entry.name);
|
||||||
|
let content: string;
|
||||||
|
try {
|
||||||
|
content = fs.readFileSync(filePath, "utf-8");
|
||||||
|
} catch {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { frontmatter, body } = parseFrontmatter<Record<string, string>>(content);
|
||||||
|
|
||||||
|
if (!frontmatter.name || !frontmatter.description) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const tools = frontmatter.tools
|
||||||
|
?.split(",")
|
||||||
|
.map((t: string) => t.trim())
|
||||||
|
.filter(Boolean);
|
||||||
|
|
||||||
|
agents.push({
|
||||||
|
name: frontmatter.name,
|
||||||
|
description: frontmatter.description,
|
||||||
|
tools: tools && tools.length > 0 ? tools : undefined,
|
||||||
|
model: frontmatter.model,
|
||||||
|
thinking: frontmatter.thinking,
|
||||||
|
systemPrompt: body,
|
||||||
|
source,
|
||||||
|
filePath,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return agents;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isDirectory(p: string): boolean {
|
||||||
|
try {
|
||||||
|
return fs.statSync(p).isDirectory();
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function findNearestProjectAgentsDir(cwd: string): string | null {
|
||||||
|
let currentDir = cwd;
|
||||||
|
while (true) {
|
||||||
|
const candidate = path.join(currentDir, CONFIG_DIR_NAME, "agents");
|
||||||
|
if (isDirectory(candidate)) return candidate;
|
||||||
|
|
||||||
|
const parentDir = path.dirname(currentDir);
|
||||||
|
if (parentDir === currentDir) return null;
|
||||||
|
currentDir = parentDir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function discoverAgents(cwd: string, scope: AgentScope): AgentDiscoveryResult {
|
||||||
|
const userDir = path.join(getAgentDir(), "agents");
|
||||||
|
const projectAgentsDir = findNearestProjectAgentsDir(cwd);
|
||||||
|
|
||||||
|
const userAgents = scope === "project" ? [] : loadAgentsFromDir(userDir, "user");
|
||||||
|
const projectAgents = scope === "user" || !projectAgentsDir ? [] : loadAgentsFromDir(projectAgentsDir, "project");
|
||||||
|
|
||||||
|
const agentMap = new Map<string, AgentConfig>();
|
||||||
|
|
||||||
|
if (scope === "both") {
|
||||||
|
for (const agent of userAgents) agentMap.set(agent.name, agent);
|
||||||
|
for (const agent of projectAgents) agentMap.set(agent.name, agent);
|
||||||
|
} else if (scope === "user") {
|
||||||
|
for (const agent of userAgents) agentMap.set(agent.name, agent);
|
||||||
|
} else {
|
||||||
|
for (const agent of projectAgents) agentMap.set(agent.name, agent);
|
||||||
|
}
|
||||||
|
|
||||||
|
return { agents: Array.from(agentMap.values()), projectAgentsDir };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function formatAgentList(agents: AgentConfig[], maxItems: number): { text: string; remaining: number } {
|
||||||
|
if (agents.length === 0) return { text: "none", remaining: 0 };
|
||||||
|
const listed = agents.slice(0, maxItems);
|
||||||
|
const remaining = agents.length - listed.length;
|
||||||
|
return {
|
||||||
|
text: listed.map((a) => `${a.name} (${a.source}): ${a.description}`).join("; "),
|
||||||
|
remaining,
|
||||||
|
};
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
description: Worker implements, reviewer reviews, worker applies feedback
|
||||||
|
---
|
||||||
|
Use the subagent tool with the chain parameter to execute this workflow:
|
||||||
|
|
||||||
|
1. First, use the "worker" agent to implement: $@
|
||||||
|
2. Then, use the "reviewer" agent to review the implementation from the previous step (use {previous} placeholder)
|
||||||
|
3. Finally, use the "worker" agent to apply the feedback from the review (use {previous} placeholder)
|
||||||
|
|
||||||
|
Execute this as a chain, passing output between steps via {previous}.
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
description: Full implementation workflow - scout gathers context, planner creates plan, worker implements
|
||||||
|
---
|
||||||
|
Use the subagent tool with the chain parameter to execute this workflow:
|
||||||
|
|
||||||
|
1. First, use the "scout" agent to find all code relevant to: $@
|
||||||
|
2. Then, use the "planner" agent to create an implementation plan for "$@" using the context from the previous step (use {previous} placeholder)
|
||||||
|
3. Finally, use the "worker" agent to implement the plan from the previous step (use {previous} placeholder)
|
||||||
|
|
||||||
|
Execute this as a chain, passing output between steps via {previous}.
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
description: Scout gathers context, planner creates implementation plan (no implementation)
|
||||||
|
---
|
||||||
|
Use the subagent tool with the chain parameter to execute this workflow:
|
||||||
|
|
||||||
|
1. First, use the "scout" agent to find all code relevant to: $@
|
||||||
|
2. Then, use the "planner" agent to create an implementation plan for "$@" using the context from the previous step (use {previous} placeholder)
|
||||||
|
|
||||||
|
Execute this as a chain, passing output between steps via {previous}. Do NOT implement - just return the plan.
|
||||||
Reference in New Issue
Block a user