@jerryan/pi-subagent-tools 0.3.0 → 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/index.ts CHANGED
@@ -1,19 +1,19 @@
1
- /**
2
- * pi-subagent-tools — Specialized subagent delegation for pi
3
- *
4
- * Registers four tools for the "agent as project manager" workflow:
5
- * review — Read-only code review in the current project
6
- * explore — Read-only exploration of external projects (requires cwd)
7
- * delegate — General-purpose worker with full tool access
8
- * follow_up — Continue an existing subagent's session with full context
9
- *
10
- * Subagents run in-process as SDK AgentSessions (see agents.ts). Interactive
11
- * prompts route to the parent TUI via the UI bridge (see ui-bridge.ts).
12
- */
13
-
14
- import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
15
- import { AgentManager, registerAgentTools } from "./agents.ts";
16
-
17
- export default function (pi: ExtensionAPI) {
18
- registerAgentTools(pi, new AgentManager());
19
- }
1
+ /**
2
+ * pi-subagent-tools — Specialized subagent delegation for pi
3
+ *
4
+ * Registers four tools for the "agent as project manager" workflow:
5
+ * review — Read-only code review in the current project
6
+ * explore — Read-only exploration of external projects (requires cwd)
7
+ * delegate — General-purpose worker with full tool access
8
+ * follow_up — Continue an existing subagent's session with full context
9
+ *
10
+ * Subagents run in-process as SDK AgentSessions (see agents.ts). Interactive
11
+ * prompts route to the parent TUI via the UI bridge (see ui-bridge.ts).
12
+ */
13
+
14
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
15
+ import { AgentManager, registerAgentTools } from "./agents.ts";
16
+
17
+ export default function (pi: ExtensionAPI) {
18
+ registerAgentTools(pi, new AgentManager());
19
+ }
package/package.json CHANGED
@@ -1,63 +1,63 @@
1
- {
2
- "name": "@jerryan/pi-subagent-tools",
3
- "version": "0.3.0",
4
- "description": "Minimal pi extension: delegate, review, and explore via in-process subagent sessions",
5
- "type": "module",
6
- "main": "index.ts",
7
- "files": [
8
- "index.ts",
9
- "agents.ts",
10
- "render.ts",
11
- "sandbox-bash.ts",
12
- "ui-bridge.ts",
13
- "tui.ts",
14
- "prompts/*.md",
15
- "CHANGELOG.md",
16
- "README.md",
17
- "LICENSE"
18
- ],
19
- "keywords": [
20
- "pi",
21
- "pi-extension",
22
- "pi-package",
23
- "subagent",
24
- "delegate",
25
- "review",
26
- "explore"
27
- ],
28
- "license": "MIT",
29
- "author": "Zerui An",
30
- "repository": {
31
- "type": "git",
32
- "url": "https://github.com/JerryAZR/pi-subagent-tools"
33
- },
34
- "publishConfig": {
35
- "registry": "https://registry.npmjs.org/"
36
- },
37
- "scripts": {
38
- "test": "node --experimental-strip-types --import ./test/register-mocks.mjs --test test/*.test.ts",
39
- "typecheck": "tsc --noEmit"
40
- },
41
- "pi": {
42
- "extensions": [
43
- "./index.ts"
44
- ]
45
- },
46
- "peerDependencies": {
47
- "@earendil-works/pi-ai": ">=0.84.0",
48
- "@earendil-works/pi-coding-agent": ">=0.84.0",
49
- "@earendil-works/pi-tui": ">=0.84.0"
50
- },
51
- "devDependencies": {
52
- "@earendil-works/pi-ai": "^0.84.4",
53
- "@earendil-works/pi-coding-agent": "^0.84.4",
54
- "@earendil-works/pi-tui": "^0.84.4",
55
- "@sinclair/typebox": "^0.34.0",
56
- "@types/node": "^20.0.0",
57
- "typescript": "^5.4.0"
58
- },
59
- "dependencies": {
60
- "just-bash": "^3.4.2",
61
- "just-git": "^1.8.0"
62
- }
63
- }
1
+ {
2
+ "name": "@jerryan/pi-subagent-tools",
3
+ "version": "0.4.0",
4
+ "description": "Minimal pi extension: delegate, review, and explore via in-process subagent sessions",
5
+ "type": "module",
6
+ "main": "index.ts",
7
+ "files": [
8
+ "index.ts",
9
+ "agents.ts",
10
+ "render.ts",
11
+ "sandbox-bash.ts",
12
+ "sandbox-python.ts",
13
+ "ui-bridge.ts",
14
+ "tui.ts",
15
+ "prompts/*.md",
16
+ "CHANGELOG.md",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
20
+ "keywords": [
21
+ "pi",
22
+ "pi-extension",
23
+ "pi-package",
24
+ "subagent",
25
+ "delegate",
26
+ "review",
27
+ "explore"
28
+ ],
29
+ "license": "MIT",
30
+ "author": "Zerui An",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/JerryAZR/pi-subagent-tools"
34
+ },
35
+ "publishConfig": {
36
+ "registry": "https://registry.npmjs.org/"
37
+ },
38
+ "scripts": {
39
+ "test": "node --experimental-strip-types --import ./test/register-mocks.mjs --test test/*.test.ts"
40
+ },
41
+ "pi": {
42
+ "extensions": [
43
+ "./index.ts"
44
+ ]
45
+ },
46
+ "peerDependencies": {
47
+ "@earendil-works/pi-ai": ">=0.84.0",
48
+ "@earendil-works/pi-coding-agent": ">=0.84.0",
49
+ "@earendil-works/pi-tui": ">=0.84.0"
50
+ },
51
+ "devDependencies": {
52
+ "@earendil-works/pi-ai": "^0.84.4",
53
+ "@earendil-works/pi-coding-agent": "^0.84.4",
54
+ "@earendil-works/pi-tui": "^0.84.4",
55
+ "@sinclair/typebox": "^0.34.0",
56
+ "@types/node": "^20.0.0",
57
+ "typescript": "^5.4.0"
58
+ },
59
+ "dependencies": {
60
+ "@jerryan/just-bash": "^3.10.0",
61
+ "just-git": "^1.9.0"
62
+ }
63
+ }
@@ -1,6 +1,6 @@
1
- You are a task worker. Your job is to execute the assigned task directly — do the work, don't discuss it.
2
- You have full file and bash access. Make changes, run commands, and complete the task.
3
- You do not need to present plans for approval. If requirements are clear, implement immediately.
4
- Minor uncertainties: proceed with a reasonable assumption, state it clearly in your result.
5
- Major uncertainties or obstacles: cannot be resolved — report back, suggest the caller investigate and re-delegate with clarification.
6
- Be concise. Deliver results, not deliberation.
1
+ You are a task worker. Your job is to execute the assigned task directly — do the work, don't discuss it.
2
+ You have full file and bash access. Make changes, run commands, and complete the task.
3
+ You do not need to present plans for approval. If requirements are clear, implement immediately.
4
+ Minor uncertainties: proceed with a reasonable assumption, state it clearly in your result.
5
+ Major uncertainties or obstacles: cannot be resolved — report back, suggest the caller investigate and re-delegate with clarification.
6
+ Be concise. Deliver results, not deliberation.
@@ -1,4 +1,4 @@
1
- You are a codebase explorer. Map the structure, identify key files, and report patterns.
2
- You are in read-only mode — project files cannot be modified (writes to them fail by design). Use bash for searching, file inspection, and git history.
3
- Focus on entry points, architecture, dependencies, and areas of interest.
4
- End with a clear summary of the codebase structure and notable findings.
1
+ You are a codebase explorer. Map the structure, identify key files, and report patterns.
2
+ You are in read-only mode — project files cannot be modified (writes to them fail by design). Use bash for searching, file inspection, and git history.
3
+ Focus on entry points, architecture, dependencies, and areas of interest.
4
+ End with a clear summary of the codebase structure and notable findings.
package/prompts/review.md CHANGED
@@ -1,4 +1,4 @@
1
- You are a code reviewer. Inspect code, find issues, and report findings clearly.
2
- You are in read-only mode — project files cannot be modified (writes to them fail by design). Use bash for searching, file inspection, and git history.
3
- Focus on correctness, edge cases, readability, and adherence to the task requirements.
4
- End with a clear summary of findings organized by severity.
1
+ You are a code reviewer. Inspect code, find issues, and report findings clearly.
2
+ You are in read-only mode — project files cannot be modified (writes to them fail by design). Use bash for searching, file inspection, and git history.
3
+ Focus on correctness, edge cases, readability, and adherence to the task requirements.
4
+ End with a clear summary of findings organized by severity.
package/render.ts CHANGED
@@ -1,87 +1,87 @@
1
- /**
2
- * TUI rendering for subagent tool calls and results.
3
- */
4
-
5
- import { getMarkdownTheme } from "@earendil-works/pi-coding-agent";
6
- import { Container, Spacer, Text, Markdown } from "@earendil-works/pi-tui";
7
- import { formatUsage, spinnerFrame, truncate, TOOL_LINE_PREFIX } from "./tui.ts";
8
-
9
- // ---------------------------------------------------------------------------
10
- // Compact preview component — delegates to Text.render(width) for wrapping
11
- // ---------------------------------------------------------------------------
12
-
13
- export class CompactPreview {
14
- private textComp: Text;
15
- private maxLines: number;
16
-
17
- constructor(text: string, maxLines: number = 5) {
18
- this.maxLines = maxLines;
19
- this.textComp = new Text(text, 0, 0);
20
- }
21
-
22
- render(width: number): string[] {
23
- const lines = this.textComp.render(width);
24
- if (lines.length === 0) return [];
25
-
26
- if (lines.length <= this.maxLines) return lines;
27
-
28
- return ["...", ...lines.slice(-this.maxLines)];
29
- }
30
-
31
- invalidate() {
32
- this.textComp.invalidate();
33
- }
34
- }
35
-
36
- // ---------------------------------------------------------------------------
37
- // Call / result renderers shared by all subagent tools
38
- // ---------------------------------------------------------------------------
39
-
40
- export function renderSubagentCall(
41
- label: string,
42
- args: { task: string; hint?: string },
43
- theme: any,
44
- ) {
45
- const firstLine = args.task.split("\n")[0];
46
- const combined = args.hint ? `${args.hint} | ${firstLine}` : firstLine;
47
- const preview = truncate(combined, 80);
48
- return new Text(
49
- `${theme.fg("toolTitle", theme.bold(label))}${theme.fg("dim", preview)}`,
50
- 0, 0,
51
- );
52
- }
53
-
54
- export function renderSubagentResult(
55
- result: { content: Array<{ type: string; text?: string }>; isError?: boolean; details?: any },
56
- options: { expanded: boolean },
57
- theme: any,
58
- _context: { toolCallId: string },
59
- ) {
60
- const raw = result.content.filter((c: any) => c.type === "text").map((c: any) => c.text).join("");
61
- const output = raw.split("\n").map(l => l.startsWith(TOOL_LINE_PREFIX) ? theme.fg("muted", l) : l).join("\n");
62
- const container = new Container();
63
-
64
- if (!options.expanded) {
65
- const text = output || theme.fg("dim", "(no output)");
66
- const usage = result.details?.usage;
67
- const hint = ` · ${theme.fg("dim", "Ctrl+O to expand")}`;
68
- const status = usage ? formatUsage(usage, spinnerFrame) + hint : "";
69
- container.addChild(new CompactPreview(text));
70
- if (status) container.addChild(new Text(theme.fg("dim", status), 0, 0));
71
- return container;
72
- }
73
-
74
- const isFinal = !!result.details?.final;
75
- if (isFinal) {
76
- const mdTheme = getMarkdownTheme();
77
- container.addChild(new Markdown(raw, 0, 0, mdTheme));
78
- } else {
79
- container.addChild(new CompactPreview(output, 15));
80
- }
81
- if (result.details?.usage) {
82
- container.addChild(new Spacer(1));
83
- container.addChild(new Text(theme.fg("dim", formatUsage(result.details.usage, spinnerFrame)), 0, 0));
84
- }
85
-
86
- return container;
87
- }
1
+ /**
2
+ * TUI rendering for subagent tool calls and results.
3
+ */
4
+
5
+ import { getMarkdownTheme } from "@earendil-works/pi-coding-agent";
6
+ import { Container, Spacer, Text, Markdown } from "@earendil-works/pi-tui";
7
+ import { formatUsage, spinnerFrame, truncate, TOOL_LINE_PREFIX } from "./tui.ts";
8
+
9
+ // ---------------------------------------------------------------------------
10
+ // Compact preview component — delegates to Text.render(width) for wrapping
11
+ // ---------------------------------------------------------------------------
12
+
13
+ export class CompactPreview {
14
+ private textComp: Text;
15
+ private maxLines: number;
16
+
17
+ constructor(text: string, maxLines: number = 5) {
18
+ this.maxLines = maxLines;
19
+ this.textComp = new Text(text, 0, 0);
20
+ }
21
+
22
+ render(width: number): string[] {
23
+ const lines = this.textComp.render(width);
24
+ if (lines.length === 0) return [];
25
+
26
+ if (lines.length <= this.maxLines) return lines;
27
+
28
+ return ["...", ...lines.slice(-this.maxLines)];
29
+ }
30
+
31
+ invalidate() {
32
+ this.textComp.invalidate();
33
+ }
34
+ }
35
+
36
+ // ---------------------------------------------------------------------------
37
+ // Call / result renderers shared by all subagent tools
38
+ // ---------------------------------------------------------------------------
39
+
40
+ export function renderSubagentCall(
41
+ label: string,
42
+ args: { task: string; hint?: string },
43
+ theme: any,
44
+ ) {
45
+ const firstLine = args.task.split("\n")[0];
46
+ const combined = args.hint ? `${args.hint} | ${firstLine}` : firstLine;
47
+ const preview = truncate(combined, 80);
48
+ return new Text(
49
+ `${theme.fg("toolTitle", theme.bold(label))}${theme.fg("dim", preview)}`,
50
+ 0, 0,
51
+ );
52
+ }
53
+
54
+ export function renderSubagentResult(
55
+ result: { content: Array<{ type: string; text?: string }>; isError?: boolean; details?: any },
56
+ options: { expanded: boolean },
57
+ theme: any,
58
+ _context: { toolCallId: string },
59
+ ) {
60
+ const raw = result.content.filter((c: any) => c.type === "text").map((c: any) => c.text).join("");
61
+ const output = raw.split("\n").map(l => l.startsWith(TOOL_LINE_PREFIX) ? theme.fg("muted", l) : l).join("\n");
62
+ const container = new Container();
63
+
64
+ if (!options.expanded) {
65
+ const text = output || theme.fg("dim", "(no output)");
66
+ const usage = result.details?.usage;
67
+ const hint = ` · ${theme.fg("dim", "Ctrl+O to expand")}`;
68
+ const status = usage ? formatUsage(usage, spinnerFrame) + hint : "";
69
+ container.addChild(new CompactPreview(text));
70
+ if (status) container.addChild(new Text(theme.fg("dim", status), 0, 0));
71
+ return container;
72
+ }
73
+
74
+ const isFinal = !!result.details?.final;
75
+ if (isFinal) {
76
+ const mdTheme = getMarkdownTheme();
77
+ container.addChild(new Markdown(raw, 0, 0, mdTheme));
78
+ } else {
79
+ container.addChild(new CompactPreview(output, 15));
80
+ }
81
+ if (result.details?.usage) {
82
+ container.addChild(new Spacer(1));
83
+ container.addChild(new Text(theme.fg("dim", formatUsage(result.details.usage, spinnerFrame)), 0, 0));
84
+ }
85
+
86
+ return container;
87
+ }