oira666_pi-subagent 0.1.4 → 0.1.6
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 +10 -0
- package/agents.ts +7 -4
- package/package.json +1 -1
- package/runner.ts +7 -1
package/README.md
CHANGED
|
@@ -62,8 +62,12 @@ Three fallback agents ship with the extension (used when no user/project agents
|
|
|
62
62
|
Create Markdown files with YAML frontmatter:
|
|
63
63
|
|
|
64
64
|
- **User agents:** `~/.pi/agent/agents/*.md`
|
|
65
|
+
- **Env agents:** `$PI_CODING_AGENT_DIR/agents/*.md` *(when `PI_CODING_AGENT_DIR` is set)*
|
|
65
66
|
- **Project agents:** `.pi/agents/*.md` *(may prompt for confirmation — see `PI_SUBAGENT_CONFIRM_PROJECT_AGENTS`)*
|
|
66
67
|
|
|
68
|
+
Agent discovery priority (highest wins on name collision): project > env > user.
|
|
69
|
+
Built-in agents are only used as a fallback when **all three** locations are empty.
|
|
70
|
+
|
|
67
71
|
```markdown
|
|
68
72
|
---
|
|
69
73
|
name: writer
|
|
@@ -112,6 +116,12 @@ pi --no-subagent-prevent-cycles # allow cycles (not recommended)
|
|
|
112
116
|
| `PI_SUBAGENT_MAX_PARALLEL_TASKS` | `16` | Max tasks per single call |
|
|
113
117
|
| `PI_SUBAGENT_MAX_CONCURRENCY` | `8` | Max subagents running simultaneously |
|
|
114
118
|
|
|
119
|
+
## Agent Discovery
|
|
120
|
+
|
|
121
|
+
| Env Var | Description |
|
|
122
|
+
| ----------------------- | ------------------------------------------------------------ |
|
|
123
|
+
| `PI_CODING_AGENT_DIR` | Base path for an additional agents directory (`$PI_CODING_AGENT_DIR/agents/*.md`). Agents here override user agents but are overridden by project agents. Built-in agents are only used when user, env, and project locations all yield zero agents. |
|
|
124
|
+
|
|
115
125
|
## CLI Argument Proxying
|
|
116
126
|
|
|
117
127
|
All flags passed to the parent `pi` process are forwarded to subagent child processes, so they
|
package/agents.ts
CHANGED
|
@@ -5,14 +5,13 @@
|
|
|
5
5
|
* optional model/tools, and a system prompt body.
|
|
6
6
|
*
|
|
7
7
|
* Lookup locations:
|
|
8
|
-
* - User agents: ~/.pi/agent/agents/*.md
|
|
8
|
+
* - User agents: ~/.pi/agent/agents/*.md (or $PI_CODING_AGENT_DIR/agents/ when env var is set)
|
|
9
9
|
* - Project agents: .pi/agents/*.md (walks up from cwd)
|
|
10
10
|
* - Bundled agents: ./agents/*.md (fallback only when no user/project agents exist)
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import { parseFrontmatter } from "@mariozechner/pi-coding-agent";
|
|
13
|
+
import { getAgentDir, parseFrontmatter } from "@mariozechner/pi-coding-agent";
|
|
14
14
|
import * as fs from "node:fs";
|
|
15
|
-
import * as os from "node:os";
|
|
16
15
|
import * as path from "node:path";
|
|
17
16
|
import { fileURLToPath } from "node:url";
|
|
18
17
|
|
|
@@ -144,6 +143,10 @@ function loadAgentsFromDir(dir: string, source: AgentSource): AgentConfig[] {
|
|
|
144
143
|
return agents;
|
|
145
144
|
}
|
|
146
145
|
|
|
146
|
+
/**
|
|
147
|
+
* Merge agents with last-write-wins deduplication by name.
|
|
148
|
+
* Priority (lowest → highest): user < project.
|
|
149
|
+
*/
|
|
147
150
|
function dedupeAgents(
|
|
148
151
|
userAgents: AgentConfig[],
|
|
149
152
|
projectAgents: AgentConfig[],
|
|
@@ -165,7 +168,7 @@ function dedupeAgents(
|
|
|
165
168
|
* If no user or project agents exist at all, bundled fallback agents are returned.
|
|
166
169
|
*/
|
|
167
170
|
export function discoverAgents(cwd: string, scope: AgentScope): AgentDiscoveryResult {
|
|
168
|
-
const userDir = path.join(
|
|
171
|
+
const userDir = path.join(getAgentDir(), "agents");
|
|
169
172
|
const projectAgentsDir = findNearestProjectAgentsDir(cwd);
|
|
170
173
|
|
|
171
174
|
const userAgents = loadAgentsFromDir(userDir, "user");
|
package/package.json
CHANGED
package/runner.ts
CHANGED
|
@@ -482,7 +482,13 @@ export async function runAgent(opts: RunAgentOptions): Promise<SingleResult> {
|
|
|
482
482
|
const nextDepth = Math.max(0, Math.floor(parentDepth)) + 1;
|
|
483
483
|
const propagatedMaxDepth = Math.max(0, Math.floor(maxDepth));
|
|
484
484
|
const propagatedStack = [...parentAgentStack, agentName];
|
|
485
|
-
|
|
485
|
+
// On Windows, `pi` is a .CMD shim that requires the shell to execute,
|
|
486
|
+
// but shell:true splits arguments on whitespace — breaking task strings.
|
|
487
|
+
// Fix: reuse the running node binary + the pi CLI script path directly,
|
|
488
|
+
// so the child is spawned without a shell and args are passed safely.
|
|
489
|
+
const spawnCmd = process.platform === "win32" ? process.execPath : "pi";
|
|
490
|
+
const spawnArgs = process.platform === "win32" ? [process.argv[1], ...piArgs] : piArgs;
|
|
491
|
+
const proc = spawn(spawnCmd, spawnArgs, {
|
|
486
492
|
cwd: taskCwd ?? cwd,
|
|
487
493
|
shell: false,
|
|
488
494
|
stdio: ["ignore", "pipe", "pipe"],
|