@melihmucuk/pi-crew 1.0.21 → 1.0.22
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 +5 -5
- package/extension/catalog.ts +6 -4
- package/extension/subagent-session.ts +15 -8
- package/extension/tools.ts +6 -3
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -115,15 +115,15 @@ Read-only bundled subagents still keep `bash` for inspection workflows like `git
|
|
|
115
115
|
|
|
116
116
|
Subagent definitions are discovered from three locations, in priority order:
|
|
117
117
|
|
|
118
|
-
1. **Project**: `<cwd>/.pi/agents/*.md`
|
|
119
|
-
2. **User global**: `~/.pi/agent/agents/*.md`
|
|
118
|
+
1. **Project**: `<cwd>/<CONFIG_DIR_NAME>/agents/*.md` (default: `<cwd>/.pi/agents/*.md`)
|
|
119
|
+
2. **User global**: `<agentDir>/agents/*.md` (default: `~/.pi/agent/agents/*.md`)
|
|
120
120
|
3. **Bundled**: shipped with this package
|
|
121
121
|
|
|
122
122
|
When multiple sources define a subagent with the same `name`, the higher-priority source wins. This lets you override any bundled subagent by placing a file with the same name in your project or user directory.
|
|
123
123
|
|
|
124
124
|
## Custom Subagents
|
|
125
125
|
|
|
126
|
-
Create `.md` files in `<cwd>/.pi/agents/`
|
|
126
|
+
Create `.md` files in Pi's project config agents directory (default `<cwd>/.pi/agents/`) or global agent directory (default `~/.pi/agent/agents/`) with YAML frontmatter:
|
|
127
127
|
|
|
128
128
|
```markdown
|
|
129
129
|
---
|
|
@@ -159,8 +159,8 @@ You can override selected frontmatter fields without editing the `.md` definitio
|
|
|
159
159
|
|
|
160
160
|
Config locations:
|
|
161
161
|
|
|
162
|
-
- Global: `~/.pi/agent/pi-crew.json`
|
|
163
|
-
- Project: `<cwd>/.pi/pi-crew.json`
|
|
162
|
+
- Global: `<agentDir>/pi-crew.json` (default `~/.pi/agent/pi-crew.json`)
|
|
163
|
+
- Project: `<cwd>/<CONFIG_DIR_NAME>/pi-crew.json` (default `<cwd>/.pi/pi-crew.json`)
|
|
164
164
|
|
|
165
165
|
Project config overrides global config. Only these fields are overridable:
|
|
166
166
|
|
package/extension/catalog.ts
CHANGED
|
@@ -2,7 +2,9 @@ import * as fs from "node:fs";
|
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import type { ThinkingLevel } from "@earendil-works/pi-agent-core";
|
|
5
|
-
import
|
|
5
|
+
import * as piCodingAgent from "@earendil-works/pi-coding-agent";
|
|
6
|
+
|
|
7
|
+
const PROJECT_CONFIG_DIR_NAME = piCodingAgent.CONFIG_DIR_NAME ?? ".pi";
|
|
6
8
|
|
|
7
9
|
const SUPPORTED_TOOL_NAMES_LITERAL = [
|
|
8
10
|
"read",
|
|
@@ -304,7 +306,7 @@ function parseAgentDefinition(content: string, filePath: string): ParseResult {
|
|
|
304
306
|
let frontmatter: Record<string, unknown>;
|
|
305
307
|
let body: string;
|
|
306
308
|
try {
|
|
307
|
-
const parsed = parseFrontmatter<Record<string, unknown>>(content);
|
|
309
|
+
const parsed = piCodingAgent.parseFrontmatter<Record<string, unknown>>(content);
|
|
308
310
|
frontmatter = parsed.frontmatter;
|
|
309
311
|
body = parsed.body;
|
|
310
312
|
} catch (error) {
|
|
@@ -526,13 +528,13 @@ const bundledAgentsDir = path.resolve(path.dirname(fileURLToPath(import.meta.url
|
|
|
526
528
|
|
|
527
529
|
class FilesystemAgentCatalogSource implements AgentCatalogSource {
|
|
528
530
|
loadAgentDefinitionGroups(cwd: string): AgentDefinitionSourceGroup[] {
|
|
529
|
-
return [path.join(cwd,
|
|
531
|
+
return [path.join(cwd, PROJECT_CONFIG_DIR_NAME, "agents"), path.join(piCodingAgent.getAgentDir(), "agents"), bundledAgentsDir]
|
|
530
532
|
.map(loadAgentDefinitionGroup)
|
|
531
533
|
.filter((group): group is AgentDefinitionSourceGroup => group !== null);
|
|
532
534
|
}
|
|
533
535
|
|
|
534
536
|
loadConfigFiles(cwd: string): AgentConfigFile[] {
|
|
535
|
-
return [path.join(getAgentDir(), "pi-crew.json"), path.join(cwd,
|
|
537
|
+
return [path.join(piCodingAgent.getAgentDir(), "pi-crew.json"), path.join(cwd, PROJECT_CONFIG_DIR_NAME, "pi-crew.json")]
|
|
536
538
|
.map(loadConfigFile)
|
|
537
539
|
.filter((file): file is AgentConfigFile => file !== null);
|
|
538
540
|
}
|
|
@@ -203,15 +203,22 @@ export class SubagentSessionRunner implements SubagentRunner {
|
|
|
203
203
|
|
|
204
204
|
private attachSessionListeners(state: SubagentState, session: AgentSession): void {
|
|
205
205
|
state.unsubscribe = session.subscribe((event) => {
|
|
206
|
-
if (event.type
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
206
|
+
if (event.type === "turn_end") {
|
|
207
|
+
state.turns++;
|
|
208
|
+
const msg = event.message;
|
|
209
|
+
if (msg.role === "assistant") {
|
|
210
|
+
const assistantMsg = msg as AssistantMessage;
|
|
211
|
+
state.contextTokens = assistantMsg.usage.totalTokens;
|
|
212
|
+
state.model = assistantMsg.model;
|
|
213
|
+
}
|
|
214
|
+
this.callbacks.onProgress(state.ownerSessionId);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (event.type === "compaction_end" && event.result?.estimatedTokensAfter !== undefined) {
|
|
219
|
+
state.contextTokens = event.result.estimatedTokensAfter;
|
|
220
|
+
this.callbacks.onProgress(state.ownerSessionId);
|
|
213
221
|
}
|
|
214
|
-
this.callbacks.onProgress(state.ownerSessionId);
|
|
215
222
|
});
|
|
216
223
|
}
|
|
217
224
|
|
package/extension/tools.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AgentToolResult } from "@earendil-works/pi-agent-core";
|
|
2
|
-
import
|
|
2
|
+
import * as piCodingAgent from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
3
4
|
import { Text } from "@earendil-works/pi-tui";
|
|
4
5
|
import { Type } from "typebox";
|
|
5
6
|
import {
|
|
@@ -15,6 +16,8 @@ export type CrewToolResult = AgentToolResult<unknown> & {
|
|
|
15
16
|
terminate?: boolean;
|
|
16
17
|
};
|
|
17
18
|
|
|
19
|
+
const PROJECT_CONFIG_DIR_NAME = piCodingAgent.CONFIG_DIR_NAME ?? ".pi";
|
|
20
|
+
|
|
18
21
|
type RegisteredTool = Parameters<ExtensionAPI["registerTool"]>[0];
|
|
19
22
|
type ToolRenderCall = Exclude<RegisteredTool["renderCall"], undefined>;
|
|
20
23
|
|
|
@@ -52,7 +55,7 @@ function toolSuccess(
|
|
|
52
55
|
|
|
53
56
|
function formatAvailableAgents(agents: AgentConfig[]): string[] {
|
|
54
57
|
if (agents.length === 0) {
|
|
55
|
-
return [
|
|
58
|
+
return [`No valid subagent definitions found. Add \`.md\` files to \`<cwd>/${PROJECT_CONFIG_DIR_NAME}/agents/\` or \`${piCodingAgent.getAgentDir()}/agents/\`.`];
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
return agents.flatMap((agent) => {
|
|
@@ -216,7 +219,7 @@ export function registerCrewTools(pi: ExtensionAPI, crew: CrewRuntime, extension
|
|
|
216
219
|
brief,
|
|
217
220
|
model: ctx.model,
|
|
218
221
|
modelRegistry: ctx.modelRegistry,
|
|
219
|
-
agentDir: getAgentDir(),
|
|
222
|
+
agentDir: piCodingAgent.getAgentDir(),
|
|
220
223
|
parentSessionFile: ctx.sessionManager.getSessionFile(),
|
|
221
224
|
onWarning: (msg) => ctx.ui.notify(msg, "warning"),
|
|
222
225
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@melihmucuk/pi-crew",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.22",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Non-blocking subagent orchestration for pi coding agent",
|
|
6
6
|
"files": [
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"typebox": "*"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@earendil-works/pi-agent-core": "^0.
|
|
47
|
-
"@earendil-works/pi-ai": "^0.
|
|
48
|
-
"@earendil-works/pi-coding-agent": "^0.
|
|
49
|
-
"@earendil-works/pi-tui": "^0.
|
|
46
|
+
"@earendil-works/pi-agent-core": "^0.80.2",
|
|
47
|
+
"@earendil-works/pi-ai": "^0.80.2",
|
|
48
|
+
"@earendil-works/pi-coding-agent": "^0.80.2",
|
|
49
|
+
"@earendil-works/pi-tui": "^0.80.2",
|
|
50
50
|
"@types/node": "^25.9.3",
|
|
51
51
|
"tsx": "^4.22.4",
|
|
52
|
-
"typebox": "^1.
|
|
52
|
+
"typebox": "^1.3.0",
|
|
53
53
|
"typescript": "^6.0.3"
|
|
54
54
|
}
|
|
55
55
|
}
|