@mariozechner/pi-coding-agent 0.23.3 → 0.23.5
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/CHANGELOG.md +61 -0
- package/README.md +20 -13
- package/dist/core/custom-tools/loader.d.ts.map +1 -1
- package/dist/core/custom-tools/loader.js +56 -4
- package/dist/core/custom-tools/loader.js.map +1 -1
- package/dist/core/custom-tools/types.d.ts +9 -1
- package/dist/core/custom-tools/types.d.ts.map +1 -1
- package/dist/core/custom-tools/types.js.map +1 -1
- package/dist/core/hooks/index.d.ts +2 -1
- package/dist/core/hooks/index.d.ts.map +1 -1
- package/dist/core/hooks/index.js +1 -0
- package/dist/core/hooks/index.js.map +1 -1
- package/dist/core/hooks/loader.d.ts.map +1 -1
- package/dist/core/hooks/loader.js +4 -2
- package/dist/core/hooks/loader.js.map +1 -1
- package/dist/core/hooks/runner.d.ts.map +1 -1
- package/dist/core/hooks/runner.js +44 -4
- package/dist/core/hooks/runner.js.map +1 -1
- package/dist/core/hooks/tool-wrapper.d.ts.map +1 -1
- package/dist/core/hooks/tool-wrapper.js +5 -9
- package/dist/core/hooks/tool-wrapper.js.map +1 -1
- package/dist/core/hooks/types.d.ts +73 -11
- package/dist/core/hooks/types.d.ts.map +1 -1
- package/dist/core/hooks/types.js +22 -1
- package/dist/core/hooks/types.js.map +1 -1
- package/dist/core/skills.d.ts +18 -5
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +183 -72
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +2 -2
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +2 -2
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +5 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/find.d.ts +5 -0
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +6 -0
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts +6 -5
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/ls.d.ts +5 -0
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/read.d.ts +4 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +4 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +1 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +16 -7
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/diff.d.ts +12 -0
- package/dist/modes/interactive/components/diff.d.ts.map +1 -0
- package/dist/modes/interactive/components/diff.js +133 -0
- package/dist/modes/interactive/components/diff.js.map +1 -0
- package/dist/modes/interactive/components/hook-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/hook-input.js +2 -2
- package/dist/modes/interactive/components/hook-input.js.map +1 -1
- package/dist/modes/interactive/components/hook-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/hook-selector.js +2 -2
- package/dist/modes/interactive/components/hook-selector.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +2 -2
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +2 -2
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +3 -3
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +26 -20
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +3 -3
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +2 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +63 -1
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/dark.json +9 -9
- package/dist/modes/interactive/theme/light.json +9 -9
- package/dist/modes/interactive/theme/theme.d.ts +10 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +131 -3
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +10 -0
- package/dist/modes/print-mode.js.map +1 -1
- package/docs/custom-tools.md +43 -4
- package/docs/hooks.md +104 -5
- package/docs/skills.md +65 -24
- package/examples/custom-tools/README.md +18 -7
- package/examples/custom-tools/subagent/README.md +172 -0
- package/examples/custom-tools/subagent/agents/planner.md +37 -0
- package/examples/custom-tools/subagent/agents/reviewer.md +35 -0
- package/examples/custom-tools/subagent/agents/scout.md +50 -0
- package/examples/custom-tools/subagent/agents/worker.md +24 -0
- package/examples/custom-tools/subagent/agents.ts +157 -0
- package/examples/custom-tools/subagent/commands/implement-and-review.md +10 -0
- package/examples/custom-tools/subagent/commands/implement.md +10 -0
- package/examples/custom-tools/subagent/commands/scout-and-plan.md +9 -0
- package/examples/custom-tools/subagent/index.ts +772 -0
- package/package.json +6 -6
- /package/examples/custom-tools/{hello.ts → hello/index.ts} +0 -0
- /package/examples/custom-tools/{question.ts → question/index.ts} +0 -0
- /package/examples/custom-tools/{todo.ts → todo/index.ts} +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: reviewer
|
|
3
|
+
description: Code review specialist for quality and security analysis
|
|
4
|
+
tools: read, grep, find, ls, bash
|
|
5
|
+
model: claude-sonnet-4-5
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
You are a senior code reviewer. Analyze code for quality, security, and maintainability.
|
|
9
|
+
|
|
10
|
+
Bash is for read-only commands only: `git diff`, `git log`, `git show`. Do NOT modify files or run builds.
|
|
11
|
+
Assume tool permissions are not perfectly enforceable; keep all bash usage strictly read-only.
|
|
12
|
+
|
|
13
|
+
Strategy:
|
|
14
|
+
1. Run `git diff` to see recent changes (if applicable)
|
|
15
|
+
2. Read the modified files
|
|
16
|
+
3. Check for bugs, security issues, code smells
|
|
17
|
+
|
|
18
|
+
Output format:
|
|
19
|
+
|
|
20
|
+
## Files Reviewed
|
|
21
|
+
- `path/to/file.ts` (lines X-Y)
|
|
22
|
+
|
|
23
|
+
## Critical (must fix)
|
|
24
|
+
- `file.ts:42` - Issue description
|
|
25
|
+
|
|
26
|
+
## Warnings (should fix)
|
|
27
|
+
- `file.ts:100` - Issue description
|
|
28
|
+
|
|
29
|
+
## Suggestions (consider)
|
|
30
|
+
- `file.ts:150` - Improvement idea
|
|
31
|
+
|
|
32
|
+
## Summary
|
|
33
|
+
Overall assessment in 2-3 sentences.
|
|
34
|
+
|
|
35
|
+
Be specific with file paths and line numbers.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: scout
|
|
3
|
+
description: Fast codebase recon that returns compressed context for handoff to other agents
|
|
4
|
+
tools: read, grep, find, ls, bash
|
|
5
|
+
model: claude-haiku-4-5
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
You are a scout. Quickly investigate a codebase and return structured findings that another agent can use without re-reading everything.
|
|
9
|
+
|
|
10
|
+
Your output will be passed to an agent who has NOT seen the files you explored.
|
|
11
|
+
|
|
12
|
+
Thoroughness (infer from task, default medium):
|
|
13
|
+
- Quick: Targeted lookups, key files only
|
|
14
|
+
- Medium: Follow imports, read critical sections
|
|
15
|
+
- Thorough: Trace all dependencies, check tests/types
|
|
16
|
+
|
|
17
|
+
Strategy:
|
|
18
|
+
1. grep/find to locate relevant code
|
|
19
|
+
2. Read key sections (not entire files)
|
|
20
|
+
3. Identify types, interfaces, key functions
|
|
21
|
+
4. Note dependencies between files
|
|
22
|
+
|
|
23
|
+
Output format:
|
|
24
|
+
|
|
25
|
+
## Files Retrieved
|
|
26
|
+
List with exact line ranges:
|
|
27
|
+
1. `path/to/file.ts` (lines 10-50) - Description of what's here
|
|
28
|
+
2. `path/to/other.ts` (lines 100-150) - Description
|
|
29
|
+
3. ...
|
|
30
|
+
|
|
31
|
+
## Key Code
|
|
32
|
+
Critical types, interfaces, or functions:
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
interface Example {
|
|
36
|
+
// actual code from the files
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
function keyFunction() {
|
|
42
|
+
// actual implementation
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Architecture
|
|
47
|
+
Brief explanation of how the pieces connect.
|
|
48
|
+
|
|
49
|
+
## Start Here
|
|
50
|
+
Which file to look at first and why.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: worker
|
|
3
|
+
description: General-purpose subagent with full capabilities, isolated context
|
|
4
|
+
model: claude-sonnet-4-5
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are a worker agent with full capabilities. You operate in an isolated context window to handle delegated tasks without polluting the main conversation.
|
|
8
|
+
|
|
9
|
+
Work autonomously to complete the assigned task. Use all available tools as needed.
|
|
10
|
+
|
|
11
|
+
Output format when finished:
|
|
12
|
+
|
|
13
|
+
## Completed
|
|
14
|
+
What was done.
|
|
15
|
+
|
|
16
|
+
## Files Changed
|
|
17
|
+
- `path/to/file.ts` - what changed
|
|
18
|
+
|
|
19
|
+
## Notes (if any)
|
|
20
|
+
Anything the main agent should know.
|
|
21
|
+
|
|
22
|
+
If handing off to another agent (e.g. reviewer), include:
|
|
23
|
+
- Exact file paths changed
|
|
24
|
+
- Key functions/types touched (short list)
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent discovery and configuration
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as fs from "node:fs";
|
|
6
|
+
import * as os from "node:os";
|
|
7
|
+
import * as path from "node:path";
|
|
8
|
+
|
|
9
|
+
export type AgentScope = "user" | "project" | "both";
|
|
10
|
+
|
|
11
|
+
export interface AgentConfig {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
tools?: string[];
|
|
15
|
+
model?: string;
|
|
16
|
+
systemPrompt: string;
|
|
17
|
+
source: "user" | "project";
|
|
18
|
+
filePath: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface AgentDiscoveryResult {
|
|
22
|
+
agents: AgentConfig[];
|
|
23
|
+
projectAgentsDir: string | null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function parseFrontmatter(content: string): { frontmatter: Record<string, string>; body: string } {
|
|
27
|
+
const frontmatter: Record<string, string> = {};
|
|
28
|
+
const normalized = content.replace(/\r\n/g, "\n");
|
|
29
|
+
|
|
30
|
+
if (!normalized.startsWith("---")) {
|
|
31
|
+
return { frontmatter, body: normalized };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const endIndex = normalized.indexOf("\n---", 3);
|
|
35
|
+
if (endIndex === -1) {
|
|
36
|
+
return { frontmatter, body: normalized };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const frontmatterBlock = normalized.slice(4, endIndex);
|
|
40
|
+
const body = normalized.slice(endIndex + 4).trim();
|
|
41
|
+
|
|
42
|
+
for (const line of frontmatterBlock.split("\n")) {
|
|
43
|
+
const match = line.match(/^([\w-]+):\s*(.*)$/);
|
|
44
|
+
if (match) {
|
|
45
|
+
let value = match[2].trim();
|
|
46
|
+
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
|
|
47
|
+
value = value.slice(1, -1);
|
|
48
|
+
}
|
|
49
|
+
frontmatter[match[1]] = value;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return { frontmatter, body };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function loadAgentsFromDir(dir: string, source: "user" | "project"): AgentConfig[] {
|
|
57
|
+
const agents: AgentConfig[] = [];
|
|
58
|
+
|
|
59
|
+
if (!fs.existsSync(dir)) {
|
|
60
|
+
return agents;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
let entries: fs.Dirent[];
|
|
64
|
+
try {
|
|
65
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
66
|
+
} catch {
|
|
67
|
+
return agents;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
for (const entry of entries) {
|
|
71
|
+
if (!entry.name.endsWith(".md")) continue;
|
|
72
|
+
if (!entry.isFile() && !entry.isSymbolicLink()) continue;
|
|
73
|
+
|
|
74
|
+
const filePath = path.join(dir, entry.name);
|
|
75
|
+
let content: string;
|
|
76
|
+
try {
|
|
77
|
+
content = fs.readFileSync(filePath, "utf-8");
|
|
78
|
+
} catch {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const { frontmatter, body } = parseFrontmatter(content);
|
|
83
|
+
|
|
84
|
+
if (!frontmatter.name || !frontmatter.description) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const tools = frontmatter.tools
|
|
89
|
+
?.split(",")
|
|
90
|
+
.map((t) => t.trim())
|
|
91
|
+
.filter(Boolean);
|
|
92
|
+
|
|
93
|
+
agents.push({
|
|
94
|
+
name: frontmatter.name,
|
|
95
|
+
description: frontmatter.description,
|
|
96
|
+
tools: tools && tools.length > 0 ? tools : undefined,
|
|
97
|
+
model: frontmatter.model,
|
|
98
|
+
systemPrompt: body,
|
|
99
|
+
source,
|
|
100
|
+
filePath,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return agents;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function isDirectory(p: string): boolean {
|
|
108
|
+
try {
|
|
109
|
+
return fs.statSync(p).isDirectory();
|
|
110
|
+
} catch {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function findNearestProjectAgentsDir(cwd: string): string | null {
|
|
116
|
+
let currentDir = cwd;
|
|
117
|
+
while (true) {
|
|
118
|
+
const candidate = path.join(currentDir, ".pi", "agents");
|
|
119
|
+
if (isDirectory(candidate)) return candidate;
|
|
120
|
+
|
|
121
|
+
const parentDir = path.dirname(currentDir);
|
|
122
|
+
if (parentDir === currentDir) return null;
|
|
123
|
+
currentDir = parentDir;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function discoverAgents(cwd: string, scope: AgentScope): AgentDiscoveryResult {
|
|
128
|
+
const userDir = path.join(os.homedir(), ".pi", "agent", "agents");
|
|
129
|
+
const projectAgentsDir = findNearestProjectAgentsDir(cwd);
|
|
130
|
+
|
|
131
|
+
const userAgents = scope === "project" ? [] : loadAgentsFromDir(userDir, "user");
|
|
132
|
+
const projectAgents =
|
|
133
|
+
scope === "user" || !projectAgentsDir ? [] : loadAgentsFromDir(projectAgentsDir, "project");
|
|
134
|
+
|
|
135
|
+
const agentMap = new Map<string, AgentConfig>();
|
|
136
|
+
|
|
137
|
+
if (scope === "both") {
|
|
138
|
+
for (const agent of userAgents) agentMap.set(agent.name, agent);
|
|
139
|
+
for (const agent of projectAgents) agentMap.set(agent.name, agent);
|
|
140
|
+
} else if (scope === "user") {
|
|
141
|
+
for (const agent of userAgents) agentMap.set(agent.name, agent);
|
|
142
|
+
} else {
|
|
143
|
+
for (const agent of projectAgents) agentMap.set(agent.name, agent);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return { agents: Array.from(agentMap.values()), projectAgentsDir };
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export function formatAgentList(agents: AgentConfig[], maxItems: number): { text: string; remaining: number } {
|
|
150
|
+
if (agents.length === 0) return { text: "none", remaining: 0 };
|
|
151
|
+
const listed = agents.slice(0, maxItems);
|
|
152
|
+
const remaining = agents.length - listed.length;
|
|
153
|
+
return {
|
|
154
|
+
text: listed.map((a) => `${a.name} (${a.source}): ${a.description}`).join("; "),
|
|
155
|
+
remaining,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Worker implements, reviewer reviews, worker applies feedback
|
|
3
|
+
---
|
|
4
|
+
Use the subagent tool with the chain parameter to execute this workflow:
|
|
5
|
+
|
|
6
|
+
1. First, use the "worker" agent to implement: $@
|
|
7
|
+
2. Then, use the "reviewer" agent to review the implementation from the previous step (use {previous} placeholder)
|
|
8
|
+
3. Finally, use the "worker" agent to apply the feedback from the review (use {previous} placeholder)
|
|
9
|
+
|
|
10
|
+
Execute this as a chain, passing output between steps via {previous}.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Full implementation workflow - scout gathers context, planner creates plan, worker implements
|
|
3
|
+
---
|
|
4
|
+
Use the subagent tool with the chain parameter to execute this workflow:
|
|
5
|
+
|
|
6
|
+
1. First, use the "scout" agent to find all code relevant to: $@
|
|
7
|
+
2. Then, use the "planner" agent to create an implementation plan for "$@" using the context from the previous step (use {previous} placeholder)
|
|
8
|
+
3. Finally, use the "worker" agent to implement the plan from the previous step (use {previous} placeholder)
|
|
9
|
+
|
|
10
|
+
Execute this as a chain, passing output between steps via {previous}.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Scout gathers context, planner creates implementation plan (no implementation)
|
|
3
|
+
---
|
|
4
|
+
Use the subagent tool with the chain parameter to execute this workflow:
|
|
5
|
+
|
|
6
|
+
1. First, use the "scout" agent to find all code relevant to: $@
|
|
7
|
+
2. Then, use the "planner" agent to create an implementation plan for "$@" using the context from the previous step (use {previous} placeholder)
|
|
8
|
+
|
|
9
|
+
Execute this as a chain, passing output between steps via {previous}. Do NOT implement - just return the plan.
|