@yandy0725/pi-subagents 0.2.2 → 0.4.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/README.md +1 -2
- package/README.zh.md +1 -2
- package/index.ts +1 -0
- package/package.json +4 -5
- package/src/config/agent-types.ts +2 -2
- package/src/config/default-agents.ts +0 -51
- package/src/lifecycle/subagent-manager.ts +7 -2
- package/src/session/prompts.ts +0 -5
- package/src/tools/agent-tool.ts +1 -5
package/README.md
CHANGED
|
@@ -44,7 +44,6 @@ Foreground agents block until complete. Background agents return an ID immediate
|
|
|
44
44
|
|------|-------|-------|-------------|
|
|
45
45
|
| `general-purpose` | all | inherit | Full parent system prompt — same rules, same conventions |
|
|
46
46
|
| `Explore` | read, bash, grep, find, ls | haiku (fallback: inherit) | Fast codebase exploration (read-only) |
|
|
47
|
-
| `Plan` | read, bash, grep, find, ls | inherit | Software architect for implementation planning (read-only) |
|
|
48
47
|
|
|
49
48
|
## Custom Agents
|
|
50
49
|
|
|
@@ -142,7 +141,7 @@ When `@yandy0725/pi-permission-system` is installed, the package integrates auto
|
|
|
142
141
|
|
|
143
142
|
```bash
|
|
144
143
|
npm run typecheck # tsc --noEmit
|
|
145
|
-
npm run
|
|
144
|
+
npm run lint # biome lint
|
|
146
145
|
npm test # vitest run
|
|
147
146
|
```
|
|
148
147
|
|
package/README.zh.md
CHANGED
|
@@ -44,7 +44,6 @@ subagent({
|
|
|
44
44
|
|------|------|------|------|
|
|
45
45
|
| `general-purpose` | 全部 | 继承父级 | 完整父级系统提示词——相同规则、相同约定 |
|
|
46
46
|
| `Explore` | read, bash, grep, find, ls | haiku(回退:继承) | 快速代码库探索(只读) |
|
|
47
|
-
| `Plan` | read, bash, grep, find, ls | 继承父级 | 软件架构师,实现方案设计(只读) |
|
|
48
47
|
|
|
49
48
|
## 自定义代理
|
|
50
49
|
|
|
@@ -142,7 +141,7 @@ max_turns: 30
|
|
|
142
141
|
|
|
143
142
|
```bash
|
|
144
143
|
npm run typecheck # tsc --noEmit
|
|
145
|
-
npm run
|
|
144
|
+
npm run lint # biome lint
|
|
146
145
|
npm test # vitest run
|
|
147
146
|
```
|
|
148
147
|
|
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.4.0",
|
|
7
7
|
"description": "Focused, in-process sub-agent core for pi — autonomous agents plus a typed API and lifecycle events",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"repository": {
|
|
@@ -24,8 +24,7 @@
|
|
|
24
24
|
"test:watch": "vitest",
|
|
25
25
|
"typecheck": "tsc --noEmit",
|
|
26
26
|
"lint": "biome lint .",
|
|
27
|
-
"format": "biome format --write ."
|
|
28
|
-
"check": "biome check ."
|
|
27
|
+
"format": "biome format --write ."
|
|
29
28
|
},
|
|
30
29
|
"pi": {
|
|
31
30
|
"extensions": [
|
|
@@ -39,9 +38,9 @@
|
|
|
39
38
|
"@sinclair/typebox": "*"
|
|
40
39
|
},
|
|
41
40
|
"devDependencies": {
|
|
42
|
-
"@biomejs/biome": "^2.5.
|
|
41
|
+
"@biomejs/biome": "^2.5.2",
|
|
43
42
|
"@types/node": "^22.0.0",
|
|
44
|
-
"typescript": "~
|
|
43
|
+
"typescript": "~7.0.2",
|
|
45
44
|
"vitest": "^3.0.0"
|
|
46
45
|
}
|
|
47
46
|
}
|
|
@@ -31,8 +31,8 @@ export interface AgentConfigLookup {
|
|
|
31
31
|
export class AgentTypeRegistry implements AgentConfigLookup {
|
|
32
32
|
private agents = new Map<string, AgentConfig>();
|
|
33
33
|
|
|
34
|
-
/** The
|
|
35
|
-
static readonly DEFAULT_AGENT_NAMES = ["general-purpose", "Explore"
|
|
34
|
+
/** The two embedded default agent names. */
|
|
35
|
+
static readonly DEFAULT_AGENT_NAMES = ["general-purpose", "Explore"] as const;
|
|
36
36
|
|
|
37
37
|
constructor(private loadUserAgents: () => Map<string, AgentConfig>) {
|
|
38
38
|
this.reload();
|
|
@@ -63,55 +63,4 @@ Use Bash ONLY for read-only operations: ls, git status, git log, git diff, find,
|
|
|
63
63
|
isDefault: true,
|
|
64
64
|
},
|
|
65
65
|
],
|
|
66
|
-
[
|
|
67
|
-
"Plan",
|
|
68
|
-
{
|
|
69
|
-
name: "Plan",
|
|
70
|
-
displayName: "Plan",
|
|
71
|
-
description: "Software architect for implementation planning (read-only)",
|
|
72
|
-
builtinToolNames: READ_ONLY_TOOLS,
|
|
73
|
-
systemPrompt: `# CRITICAL: READ-ONLY MODE - NO FILE MODIFICATIONS
|
|
74
|
-
You are a software architect and planning specialist.
|
|
75
|
-
Your role is EXCLUSIVELY to explore the codebase and design implementation plans.
|
|
76
|
-
You do NOT have access to file editing tools — attempting to edit files will fail.
|
|
77
|
-
|
|
78
|
-
You are STRICTLY PROHIBITED from:
|
|
79
|
-
- Creating new files
|
|
80
|
-
- Modifying existing files
|
|
81
|
-
- Deleting files
|
|
82
|
-
- Moving or copying files
|
|
83
|
-
- Creating temporary files anywhere, including /tmp
|
|
84
|
-
- Using redirect operators (>, >>, |) or heredocs to write to files
|
|
85
|
-
- Running ANY commands that change system state
|
|
86
|
-
|
|
87
|
-
# Planning Process
|
|
88
|
-
1. Understand requirements
|
|
89
|
-
2. Explore thoroughly (read files, find patterns, understand architecture)
|
|
90
|
-
3. Design solution based on your assigned perspective
|
|
91
|
-
4. Detail the plan with step-by-step implementation strategy
|
|
92
|
-
|
|
93
|
-
# Requirements
|
|
94
|
-
- Consider trade-offs and architectural decisions
|
|
95
|
-
- Identify dependencies and sequencing
|
|
96
|
-
- Anticipate potential challenges
|
|
97
|
-
- Follow existing patterns where appropriate
|
|
98
|
-
|
|
99
|
-
# Tool Usage
|
|
100
|
-
- Use the find tool for file pattern matching (NOT the bash find command)
|
|
101
|
-
- Use the grep tool for content search (NOT bash grep/rg command)
|
|
102
|
-
- Use the read tool for reading files (NOT bash cat/head/tail)
|
|
103
|
-
- Use Bash ONLY for read-only operations
|
|
104
|
-
|
|
105
|
-
# Output Format
|
|
106
|
-
- Use absolute file paths
|
|
107
|
-
- Do not use emojis
|
|
108
|
-
- End your response with:
|
|
109
|
-
|
|
110
|
-
### Critical Files for Implementation
|
|
111
|
-
List 3-5 files most critical for implementing this plan:
|
|
112
|
-
- /absolute/path/to/file.ts - [Brief reason]`,
|
|
113
|
-
promptMode: "replace",
|
|
114
|
-
isDefault: true,
|
|
115
|
-
},
|
|
116
|
-
],
|
|
117
66
|
]);
|
|
@@ -258,10 +258,15 @@ export class SubagentManager {
|
|
|
258
258
|
const record = this.agents.get(id);
|
|
259
259
|
if (!record) return false;
|
|
260
260
|
|
|
261
|
-
// A queued agent has not started; mark it stopped
|
|
262
|
-
// becomes a no-op (status guard) when
|
|
261
|
+
// A queued agent has not started; mark it stopped and notify observers.
|
|
262
|
+
// Its scheduled thunk becomes a no-op (status guard) when the slot opens.
|
|
263
263
|
if (record.status === "queued") {
|
|
264
264
|
record.markStopped();
|
|
265
|
+
try {
|
|
266
|
+
this.observer?.onSubagentCompleted(record);
|
|
267
|
+
} catch (err) {
|
|
268
|
+
debugLog("onSubagentCompleted observer", err);
|
|
269
|
+
}
|
|
265
270
|
return true;
|
|
266
271
|
}
|
|
267
272
|
|
package/src/session/prompts.ts
CHANGED
|
@@ -46,11 +46,6 @@ Platform: ${env.platform}`;
|
|
|
46
46
|
if (config.promptMode === "append") {
|
|
47
47
|
const bridge = `<sub_agent_context>
|
|
48
48
|
You are operating as a sub-agent invoked to handle a specific task.
|
|
49
|
-
- Use the read tool instead of cat/head/tail
|
|
50
|
-
- Use the edit tool instead of sed/awk
|
|
51
|
-
- Use the write tool instead of echo/heredoc
|
|
52
|
-
- Use the find tool instead of bash find/ls for file search
|
|
53
|
-
- Use the grep tool instead of bash grep/rg for content search
|
|
54
49
|
- Make independent tool calls in parallel
|
|
55
50
|
- Use absolute file paths
|
|
56
51
|
- Do not use emojis
|
package/src/tools/agent-tool.ts
CHANGED
|
@@ -113,7 +113,6 @@ export class AgentTool {
|
|
|
113
113
|
toToolDefinition() {
|
|
114
114
|
const typeListText = this.typeListText;
|
|
115
115
|
const availableTypesText = this.availableTypesText;
|
|
116
|
-
const agentDir = this.agentDir;
|
|
117
116
|
const registry = this.registry;
|
|
118
117
|
|
|
119
118
|
return defineTool({
|
|
@@ -129,9 +128,6 @@ ${typeListText}
|
|
|
129
128
|
|
|
130
129
|
Guidelines:
|
|
131
130
|
- For parallel work, use run_in_background: true on each agent. Foreground calls run sequentially — only one executes at a time.
|
|
132
|
-
- Use Explore for codebase searches and code understanding.
|
|
133
|
-
- Use Plan for architecture and implementation planning.
|
|
134
|
-
- Use general-purpose for complex tasks that need file editing.
|
|
135
131
|
- Provide clear, detailed prompts so the agent can work autonomously.
|
|
136
132
|
- Subagent results are returned as text — summarize them for the user.
|
|
137
133
|
- Use run_in_background for work you don't need immediately. You will be notified when it completes.
|
|
@@ -149,7 +145,7 @@ Guidelines:
|
|
|
149
145
|
description: "A short (3-5 word) description of the task (shown in UI).",
|
|
150
146
|
}),
|
|
151
147
|
subagent_type: Type.String({
|
|
152
|
-
description: `The type of specialized agent to use. Available types: ${availableTypesText}
|
|
148
|
+
description: `The type of specialized agent to use. Available types: ${availableTypesText}.`,
|
|
153
149
|
}),
|
|
154
150
|
model: Type.Optional(
|
|
155
151
|
Type.String({
|