@marcoscale98/pi-extensible-workflows 5.14.1-fork.1

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.
Files changed (204) hide show
  1. package/CHANGELOG.md +536 -0
  2. package/README.md +64 -0
  3. package/dist/src/agent-execution.d.ts +338 -0
  4. package/dist/src/agent-execution.js +1633 -0
  5. package/dist/src/background-widget.d.ts +74 -0
  6. package/dist/src/background-widget.js +1340 -0
  7. package/dist/src/budget.d.ts +38 -0
  8. package/dist/src/budget.js +188 -0
  9. package/dist/src/changelog.d.ts +6 -0
  10. package/dist/src/changelog.js +112 -0
  11. package/dist/src/decoders.d.ts +96 -0
  12. package/dist/src/decoders.js +629 -0
  13. package/dist/src/execution.d.ts +19 -0
  14. package/dist/src/execution.js +749 -0
  15. package/dist/src/herdr.d.ts +53 -0
  16. package/dist/src/herdr.js +270 -0
  17. package/dist/src/host-delivery.d.ts +95 -0
  18. package/dist/src/host-delivery.js +376 -0
  19. package/dist/src/host-navigator.d.ts +83 -0
  20. package/dist/src/host-navigator.js +1087 -0
  21. package/dist/src/host-phases.d.ts +89 -0
  22. package/dist/src/host-phases.js +320 -0
  23. package/dist/src/host-recovery.d.ts +141 -0
  24. package/dist/src/host-recovery.js +356 -0
  25. package/dist/src/host-runtime.d.ts +78 -0
  26. package/dist/src/host-runtime.js +378 -0
  27. package/dist/src/host-view.d.ts +116 -0
  28. package/dist/src/host-view.js +868 -0
  29. package/dist/src/host.d.ts +40 -0
  30. package/dist/src/host.js +1641 -0
  31. package/dist/src/index.d.ts +29 -0
  32. package/dist/src/index.js +13725 -0
  33. package/dist/src/index.js.map +6 -0
  34. package/dist/src/io.d.ts +14 -0
  35. package/dist/src/io.js +82 -0
  36. package/dist/src/package-identity.d.ts +4 -0
  37. package/dist/src/package-identity.js +6 -0
  38. package/dist/src/paths.d.ts +14 -0
  39. package/dist/src/paths.js +51 -0
  40. package/dist/src/persistence.d.ts +5 -0
  41. package/dist/src/persistence.js +5 -0
  42. package/dist/src/pi-runtime-adapter.d.ts +27 -0
  43. package/dist/src/pi-runtime-adapter.js +243 -0
  44. package/dist/src/pi-runtime-runner.d.ts +42 -0
  45. package/dist/src/pi-runtime-runner.js +505 -0
  46. package/dist/src/registry.d.ts +48 -0
  47. package/dist/src/registry.js +379 -0
  48. package/dist/src/retention.d.ts +17 -0
  49. package/dist/src/retention.js +195 -0
  50. package/dist/src/runtime/agent-runner.d.ts +143 -0
  51. package/dist/src/runtime/agent-runner.js +12 -0
  52. package/dist/src/runtime/index.d.ts +2 -0
  53. package/dist/src/runtime/index.js +2 -0
  54. package/dist/src/runtime/namespace.d.ts +14 -0
  55. package/dist/src/runtime/namespace.js +1 -0
  56. package/dist/src/runtime/workflow-result.d.ts +2 -0
  57. package/dist/src/runtime/workflow-result.js +6 -0
  58. package/dist/src/session-handoff.d.ts +2 -0
  59. package/dist/src/session-handoff.js +82 -0
  60. package/dist/src/session-lease.d.ts +12 -0
  61. package/dist/src/session-lease.js +180 -0
  62. package/dist/src/store.d.ts +95 -0
  63. package/dist/src/store.js +951 -0
  64. package/dist/src/subagent-manager-handle.d.ts +4 -0
  65. package/dist/src/subagent-manager-handle.js +6 -0
  66. package/dist/src/tool-timing.d.ts +12 -0
  67. package/dist/src/tool-timing.js +33 -0
  68. package/dist/src/trajectory-contracts.d.ts +8 -0
  69. package/dist/src/trajectory-contracts.js +9 -0
  70. package/dist/src/trajectory-host-handle.d.ts +12 -0
  71. package/dist/src/trajectory-host-handle.js +6 -0
  72. package/dist/src/trajectory.d.ts +128 -0
  73. package/dist/src/trajectory.js +594 -0
  74. package/dist/src/types.d.ts +960 -0
  75. package/dist/src/types.js +60 -0
  76. package/dist/src/utils.d.ts +57 -0
  77. package/dist/src/utils.js +225 -0
  78. package/dist/src/validation.d.ts +29 -0
  79. package/dist/src/validation.js +1100 -0
  80. package/dist/src/workflow-artifacts.d.ts +14 -0
  81. package/dist/src/workflow-artifacts.js +40 -0
  82. package/dist/starter/index.d.ts +1 -0
  83. package/dist/starter/index.js +103 -0
  84. package/dist/starter/index.js.map +6 -0
  85. package/dist/starter/review-loop.d.ts +72 -0
  86. package/dist/starter/review-loop.js +43 -0
  87. package/dist/starter/roles/developer.md +6 -0
  88. package/dist/starter/roles/oracle.md +18 -0
  89. package/dist/starter/roles/researcher.md +20 -0
  90. package/dist/starter/roles/reviewer.md +19 -0
  91. package/dist/starter/roles/scout.md +18 -0
  92. package/dist/subagents/index.d.ts +8 -0
  93. package/dist/subagents/index.js +8021 -0
  94. package/dist/subagents/index.js.map +6 -0
  95. package/dist/subagents/src/contracts.d.ts +173 -0
  96. package/dist/subagents/src/contracts.js +68 -0
  97. package/dist/subagents/src/decode.d.ts +15 -0
  98. package/dist/subagents/src/decode.js +182 -0
  99. package/dist/subagents/src/index.d.ts +12 -0
  100. package/dist/subagents/src/index.js +180 -0
  101. package/dist/subagents/src/manager.d.ts +3 -0
  102. package/dist/subagents/src/manager.js +1636 -0
  103. package/dist/subagents/src/navigator.d.ts +5 -0
  104. package/dist/subagents/src/navigator.js +627 -0
  105. package/dist/subagents/src/view.d.ts +70 -0
  106. package/dist/subagents/src/view.js +387 -0
  107. package/dist/subagents/src/worktree.d.ts +34 -0
  108. package/dist/subagents/src/worktree.js +68 -0
  109. package/dist/trajectory/assets/favicon.png +0 -0
  110. package/dist/trajectory/assets/index.html +772 -0
  111. package/dist/trajectory/assets/marked.min.js +6 -0
  112. package/dist/trajectory/assets/morphdom.min.js +1 -0
  113. package/dist/trajectory/index.d.ts +5 -0
  114. package/dist/trajectory/index.js +3459 -0
  115. package/dist/trajectory/index.js.map +6 -0
  116. package/dist/trajectory/src/assets/favicon.png +0 -0
  117. package/dist/trajectory/src/assets/index.html +772 -0
  118. package/dist/trajectory/src/assets/marked.min.js +6 -0
  119. package/dist/trajectory/src/assets/morphdom.min.js +1 -0
  120. package/dist/trajectory/src/export.d.ts +25 -0
  121. package/dist/trajectory/src/export.js +80 -0
  122. package/dist/trajectory/src/index.d.ts +26 -0
  123. package/dist/trajectory/src/index.js +732 -0
  124. package/dist/trajectory/src/server.d.ts +7 -0
  125. package/dist/trajectory/src/server.js +2534 -0
  126. package/dist/trajectory/src/server.js.map +6 -0
  127. package/examples/advanced-patterns/auto-model-router.mjs +78 -0
  128. package/examples/workflow-extension-template/README.md +37 -0
  129. package/examples/workflow-extension-template/extension.test.mjs +59 -0
  130. package/examples/workflow-extension-template/index.js +51 -0
  131. package/examples/workflow-extension-template/roles/reviewer.md +4 -0
  132. package/package.json +105 -0
  133. package/skills/pi-extensible-workflows/SKILL.md +160 -0
  134. package/src/agent-execution.ts +1533 -0
  135. package/src/background-widget.ts +1496 -0
  136. package/src/budget.ts +109 -0
  137. package/src/changelog.ts +114 -0
  138. package/src/decoders.ts +567 -0
  139. package/src/execution.ts +652 -0
  140. package/src/herdr.ts +240 -0
  141. package/src/host-delivery.ts +346 -0
  142. package/src/host-navigator.ts +871 -0
  143. package/src/host-phases.ts +264 -0
  144. package/src/host-recovery.ts +333 -0
  145. package/src/host-runtime.ts +373 -0
  146. package/src/host-view.ts +828 -0
  147. package/src/host.ts +1502 -0
  148. package/src/index.ts +29 -0
  149. package/src/io.ts +73 -0
  150. package/src/package-identity.ts +7 -0
  151. package/src/paths.ts +49 -0
  152. package/src/persistence.ts +11 -0
  153. package/src/pi-runtime-adapter.ts +247 -0
  154. package/src/pi-runtime-runner.ts +436 -0
  155. package/src/registry.ts +321 -0
  156. package/src/retention.ts +178 -0
  157. package/src/runtime/agent-runner.ts +158 -0
  158. package/src/runtime/index.ts +2 -0
  159. package/src/runtime/namespace.ts +16 -0
  160. package/src/runtime/workflow-result.ts +8 -0
  161. package/src/session-handoff.ts +78 -0
  162. package/src/session-lease.ts +125 -0
  163. package/src/store.ts +832 -0
  164. package/src/subagent-manager-handle.ts +8 -0
  165. package/src/tool-timing.ts +47 -0
  166. package/src/trajectory-contracts.ts +13 -0
  167. package/src/trajectory-host-handle.ts +16 -0
  168. package/src/trajectory.ts +543 -0
  169. package/src/types.ts +374 -0
  170. package/src/utils.ts +192 -0
  171. package/src/validation.ts +910 -0
  172. package/src/workflow-artifacts.ts +35 -0
  173. package/starter/index.ts +35 -0
  174. package/starter/prompts/council.md +16 -0
  175. package/starter/prompts/deep-research.md +16 -0
  176. package/starter/prompts/oracle.md +14 -0
  177. package/starter/prompts/parallel-review.md +22 -0
  178. package/starter/prompts/parallel-scout.md +16 -0
  179. package/starter/prompts/review-loop.md +14 -0
  180. package/starter/prompts/review.md +14 -0
  181. package/starter/prompts/scout.md +14 -0
  182. package/starter/review-loop.ts +73 -0
  183. package/starter/roles/developer.md +6 -0
  184. package/starter/roles/oracle.md +18 -0
  185. package/starter/roles/researcher.md +20 -0
  186. package/starter/roles/reviewer.md +19 -0
  187. package/starter/roles/scout.md +18 -0
  188. package/subagents/README.md +145 -0
  189. package/subagents/index.ts +8 -0
  190. package/subagents/src/contracts.ts +176 -0
  191. package/subagents/src/decode.ts +158 -0
  192. package/subagents/src/index.ts +194 -0
  193. package/subagents/src/manager.ts +1560 -0
  194. package/subagents/src/navigator.ts +488 -0
  195. package/subagents/src/view.ts +376 -0
  196. package/subagents/src/worktree.ts +99 -0
  197. package/trajectory/index.ts +5 -0
  198. package/trajectory/src/assets/favicon.png +0 -0
  199. package/trajectory/src/assets/index.html +772 -0
  200. package/trajectory/src/assets/marked.min.js +6 -0
  201. package/trajectory/src/assets/morphdom.min.js +1 -0
  202. package/trajectory/src/export.ts +85 -0
  203. package/trajectory/src/index.ts +604 -0
  204. package/trajectory/src/server.ts +447 -0
@@ -0,0 +1,14 @@
1
+ import type { JsonValue } from "./types.js";
2
+ export interface WorkflowArtifact {
3
+ extension: ".js" | ".json" | ".md";
4
+ content: string;
5
+ }
6
+ export type WorkflowTui = {
7
+ stop(): void;
8
+ start(): void;
9
+ requestRender(force?: boolean): void;
10
+ };
11
+ export declare function workflowScriptArtifact(script: string): WorkflowArtifact;
12
+ export declare function workflowPromptArtifact(prompt: string): WorkflowArtifact;
13
+ export declare function workflowResultArtifact(value: JsonValue): WorkflowArtifact;
14
+ export declare function openWorkflowArtifact(tui: WorkflowTui, command: string, artifact: WorkflowArtifact): Promise<number | null>;
@@ -0,0 +1,40 @@
1
+ import { spawn } from "node:child_process";
2
+ import { mkdtemp, rm, writeFile } from "node:fs/promises";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+ export function workflowScriptArtifact(script) { return { extension: ".js", content: script }; }
6
+ export function workflowPromptArtifact(prompt) { return { extension: ".md", content: prompt }; }
7
+ export function workflowResultArtifact(value) { return typeof value === "string" ? { extension: ".md", content: value } : { extension: ".json", content: `${JSON.stringify(value, null, 2)}\n` }; }
8
+ async function spawnWorkflowEditor(command, path) {
9
+ const [editor, ...editorArgs] = command.split(" ");
10
+ if (!editor)
11
+ return null;
12
+ return new Promise((resolve) => {
13
+ try {
14
+ const child = spawn(editor, [...editorArgs, path], { stdio: "inherit", shell: process.platform === "win32" });
15
+ child.once("error", () => { resolve(null); });
16
+ child.once("close", (code) => { resolve(code); });
17
+ }
18
+ catch {
19
+ resolve(null);
20
+ }
21
+ });
22
+ }
23
+ export async function openWorkflowArtifact(tui, command, artifact) {
24
+ const directory = await mkdtemp(join(tmpdir(), "pi-workflow-editor-"));
25
+ const path = join(directory, `artifact${artifact.extension}`);
26
+ try {
27
+ await writeFile(path, artifact.content, { encoding: "utf8", mode: 0o600 });
28
+ tui.stop();
29
+ try {
30
+ return await spawnWorkflowEditor(command, path);
31
+ }
32
+ finally {
33
+ tui.start();
34
+ tui.requestRender(true);
35
+ }
36
+ }
37
+ finally {
38
+ await rm(directory, { recursive: true, force: true });
39
+ }
40
+ }
@@ -0,0 +1 @@
1
+ export default function (): void;
@@ -0,0 +1,103 @@
1
+ // starter/index.ts
2
+ import {
3
+ registerWorkflowExtension
4
+ } from "@marcoscale98/pi-extensible-workflows";
5
+
6
+ // starter/review-loop.ts
7
+ import { Type } from "typebox";
8
+ import {
9
+ defineWorkflowFunction
10
+ } from "@marcoscale98/pi-extensible-workflows";
11
+ var reviewLoop = defineWorkflowFunction({
12
+ description: "Run developer and reviewer agents until review passes or the iteration limit is reached",
13
+ async run({ task, maxIterations = 5 }, { agent, prompt }) {
14
+ const reviewSchema = Type.Object(
15
+ {
16
+ pass: Type.Boolean(),
17
+ findings: Type.Array(Type.String())
18
+ },
19
+ { additionalProperties: false }
20
+ );
21
+ let devResult = null;
22
+ let review = { pass: false, findings: [] };
23
+ for (let iterations = 1; iterations <= maxIterations; iterations += 1) {
24
+ const devPrompt = iterations === 1 ? prompt("Implement this task:\n\n{task}", { task }) : prompt(
25
+ `Address the previous review findings and complete the task.
26
+ <original_task>{task}</original_task>
27
+ <last_review>{review}</last_review>`,
28
+ { task, review: review.findings }
29
+ );
30
+ devResult = await agent(devPrompt, { role: "developer" });
31
+ review = await agent(
32
+ prompt(
33
+ `Review the implementation against the task. Set pass=true only when the task is complete and correct. The developer may have addressed a previous review run of yours. So its summary is related to the last round of review if present.
34
+ <original_task>{task}</original_task>
35
+ <last_review>{review}</last_review>
36
+ <dev_summary>{devResult}</dev_summary>`,
37
+ { task, devResult, review: review.findings }
38
+ ),
39
+ { role: "reviewer", outputSchema: reviewSchema }
40
+ );
41
+ if (review.pass) return { pass: true, iterations, devResult, review };
42
+ }
43
+ return { pass: false, iterations: maxIterations, devResult, review };
44
+ },
45
+ input: Type.Object(
46
+ {
47
+ task: Type.String(),
48
+ maxIterations: Type.Optional(Type.Integer({ minimum: 1 }))
49
+ },
50
+ { additionalProperties: false }
51
+ ),
52
+ output: Type.Object(
53
+ {
54
+ pass: Type.Boolean(),
55
+ iterations: Type.Integer(),
56
+ devResult: Type.Any(),
57
+ review: Type.Object(
58
+ {
59
+ pass: Type.Boolean(),
60
+ findings: Type.Array(Type.String())
61
+ },
62
+ { additionalProperties: false }
63
+ )
64
+ },
65
+ { additionalProperties: false }
66
+ )
67
+ });
68
+ var reviewLoopInputSchema = reviewLoop.input;
69
+ var reviewLoopOutputSchema = reviewLoop.output;
70
+
71
+ // starter/index.ts
72
+ var extension = {
73
+ source: import.meta.url,
74
+ dependencies: ["typebox"],
75
+ version: "1.0.0",
76
+ headline: "Developer-review starter workflows",
77
+ functions: { reviewLoop },
78
+ modelAliases: {
79
+ "reviewer-model": {
80
+ resolve: ({ rootModel }) => `${rootModel.provider}/${rootModel.model}`
81
+ },
82
+ "developer-model": {
83
+ resolve: ({ rootModel }) => `${rootModel.provider}/${rootModel.model}`
84
+ },
85
+ "scout-model": {
86
+ resolve: ({ rootModel }) => `${rootModel.provider}/${rootModel.model}`
87
+ },
88
+ "oracle-model": {
89
+ resolve: ({ rootModel }) => `${rootModel.provider}/${rootModel.model}`
90
+ },
91
+ "researcher-model": {
92
+ resolve: ({ rootModel }) => `${rootModel.provider}/${rootModel.model}`
93
+ }
94
+ },
95
+ roleDirectories: [new URL("./roles/", import.meta.url)]
96
+ };
97
+ function starter_default() {
98
+ registerWorkflowExtension(extension);
99
+ }
100
+ export {
101
+ starter_default as default
102
+ };
103
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../starter/index.ts", "../../starter/review-loop.ts"],
4
+ "mappings": "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",
5
+ "names": []
6
+ }
@@ -0,0 +1,72 @@
1
+ import { Type } from "typebox";
2
+ import { type JsonValue } from "@marcoscale98/pi-extensible-workflows";
3
+ export declare const reviewLoop: Omit<{
4
+ description: string;
5
+ input: Type.TObject<{
6
+ task: Type.TString;
7
+ maxIterations: Type.TOptional<Type.TInteger>;
8
+ }>;
9
+ output: Type.TObject<{
10
+ pass: Type.TBoolean;
11
+ iterations: Type.TInteger;
12
+ devResult: Type.TAny;
13
+ review: Type.TObject<{
14
+ pass: Type.TBoolean;
15
+ findings: Type.TArray<Type.TString>;
16
+ }>;
17
+ }>;
18
+ run: (input: Readonly<{
19
+ maxIterations?: number;
20
+ task: string;
21
+ }>, context: Readonly<import("@marcoscale98/pi-extensible-workflows").WorkflowFunctionContext>) => {
22
+ review: {
23
+ pass: boolean;
24
+ findings: string[];
25
+ };
26
+ pass: boolean;
27
+ iterations: number;
28
+ devResult: any;
29
+ } | Promise<{
30
+ review: {
31
+ pass: boolean;
32
+ findings: string[];
33
+ };
34
+ pass: boolean;
35
+ iterations: number;
36
+ devResult: any;
37
+ }>;
38
+ }, "run"> & {
39
+ run: ({ task, maxIterations }: Readonly<{
40
+ maxIterations?: number;
41
+ task: string;
42
+ }>, { agent, prompt }: Readonly<import("@marcoscale98/pi-extensible-workflows").WorkflowFunctionContext>) => Promise<{
43
+ pass: true;
44
+ iterations: number;
45
+ devResult: JsonValue;
46
+ review: {
47
+ pass: boolean;
48
+ findings: string[];
49
+ };
50
+ } | {
51
+ pass: false;
52
+ iterations: number;
53
+ devResult: JsonValue;
54
+ review: {
55
+ pass: boolean;
56
+ findings: string[];
57
+ };
58
+ }>;
59
+ };
60
+ export declare const reviewLoopInputSchema: Type.TObject<{
61
+ task: Type.TString;
62
+ maxIterations: Type.TOptional<Type.TInteger>;
63
+ }>;
64
+ export declare const reviewLoopOutputSchema: Type.TObject<{
65
+ pass: Type.TBoolean;
66
+ iterations: Type.TInteger;
67
+ devResult: Type.TAny;
68
+ review: Type.TObject<{
69
+ pass: Type.TBoolean;
70
+ findings: Type.TArray<Type.TString>;
71
+ }>;
72
+ }>;
@@ -0,0 +1,43 @@
1
+ import { Type } from "typebox";
2
+ import { defineWorkflowFunction, } from "@marcoscale98/pi-extensible-workflows";
3
+ export const reviewLoop = defineWorkflowFunction({
4
+ description: "Run developer and reviewer agents until review passes or the iteration limit is reached",
5
+ async run({ task, maxIterations = 5 }, { agent, prompt }) {
6
+ const reviewSchema = Type.Object({
7
+ pass: Type.Boolean(),
8
+ findings: Type.Array(Type.String()),
9
+ }, { additionalProperties: false });
10
+ let devResult = null;
11
+ let review = { pass: false, findings: [] };
12
+ for (let iterations = 1; iterations <= maxIterations; iterations += 1) {
13
+ const devPrompt = iterations === 1
14
+ ? prompt("Implement this task:\n\n{task}", { task })
15
+ : prompt(`Address the previous review findings and complete the task.
16
+ <original_task>{task}</original_task>
17
+ <last_review>{review}</last_review>`, { task, review: review.findings });
18
+ devResult = await agent(devPrompt, { role: "developer" });
19
+ review = await agent(prompt(`Review the implementation against the task. Set pass=true only when the task is complete and correct. The developer may have addressed a previous review run of yours. So its summary is related to the last round of review if present.
20
+ <original_task>{task}</original_task>
21
+ <last_review>{review}</last_review>
22
+ <dev_summary>{devResult}</dev_summary>`, { task, devResult, review: review.findings }), { role: "reviewer", outputSchema: reviewSchema });
23
+ if (review.pass)
24
+ return { pass: true, iterations, devResult, review };
25
+ }
26
+ return { pass: false, iterations: maxIterations, devResult, review };
27
+ },
28
+ input: Type.Object({
29
+ task: Type.String(),
30
+ maxIterations: Type.Optional(Type.Integer({ minimum: 1 })),
31
+ }, { additionalProperties: false }),
32
+ output: Type.Object({
33
+ pass: Type.Boolean(),
34
+ iterations: Type.Integer(),
35
+ devResult: Type.Any(),
36
+ review: Type.Object({
37
+ pass: Type.Boolean(),
38
+ findings: Type.Array(Type.String()),
39
+ }, { additionalProperties: false }),
40
+ }, { additionalProperties: false }),
41
+ });
42
+ export const reviewLoopInputSchema = reviewLoop.input;
43
+ export const reviewLoopOutputSchema = reviewLoop.output;
@@ -0,0 +1,6 @@
1
+ ---
2
+ model: developer-model
3
+ description: Developer focused agent
4
+ ---
5
+
6
+ Act as a senior developer. Implement the requested task with the smallest working change. Read the relevant flow first, reuse existing project patterns, keep the change surgical, and verify the result with the smallest relevant check.
@@ -0,0 +1,18 @@
1
+ ---
2
+ model: oracle-model
3
+ tools: ["!*", "read", "grep", "find", "ls", "bash"]
4
+ description: Oracle. Use for a second opinion on a plan, design, or decision before committing to it
5
+ ---
6
+
7
+ Give a second opinion on the presented plan, design, or decision. Do not edit files. You are not a second decision-maker; you challenge, verify, and report.
8
+
9
+ Reconstruct the stated goals and constraints first, then verify the claims against the actual code, tests, and docs. Run read-only commands when they settle a question. When source contradicts the plan or its assumptions, trust source and report the conflict.
10
+
11
+ Return:
12
+
13
+ - The strongest challenge to the proposal, with evidence.
14
+ - Hidden assumptions or contradictions you found.
15
+ - What the proposal gets right and should keep.
16
+ - A recommendation, naming any decision that still belongs to the caller.
17
+
18
+ If the proposal is sound, say so plainly instead of inventing objections.
@@ -0,0 +1,20 @@
1
+ ---
2
+ model: researcher-model
3
+ tools: ["!edit", "!write", "!bash"]
4
+ description: Researcher. Use for deep research across the codebase, docs, and the web when web tools are available
5
+ ---
6
+
7
+ Research the requested question in depth. Do not edit files.
8
+
9
+ Use every read and search capability you have: code, files, docs, and any web search or fetch tools present in this session. If the question needs web evidence and no web tool is available, say so explicitly instead of guessing.
10
+
11
+ Verify claims against primary sources: the actual code, official docs, or the cited page. Prefer primary sources over aggregators.
12
+
13
+ Return a research brief:
14
+
15
+ - Direct answer to the question.
16
+ - Evidence per claim, citing files and lines for code and URLs for web sources.
17
+ - Contradictions or version-specific caveats you found.
18
+ - What is known, what is uncertain, and what would settle the open questions.
19
+
20
+ Report only what you verified. Mark everything else as unverified.
@@ -0,0 +1,19 @@
1
+ ---
2
+ model: reviewer-model
3
+ tools: ["!*", "read", "grep", "find", "ls"]
4
+ description: Reviewer. Use when we need to review decisions or code changes
5
+ ---
6
+
7
+ Inspect the requested change for correctness, missed callers, broken assumptions, regressions, security or data-loss risk, and missing verification. Do not edit files.
8
+
9
+ Filter findings on evidence, not severity: report only concrete, current issues caused or made reachable by the change, backed by source proof, a failing test or repro, or a contract contradiction. Cite exact files and lines. Ignore style unless it hides a real defect. Do not report speculative or pre-existing issues unless asked.
10
+
11
+ Label each finding:
12
+
13
+ - P0: blocks merge (broken behavior, data loss, security).
14
+ - P1: should be fixed before release.
15
+ - P2: report-only note.
16
+
17
+ If nothing qualifies, say exactly `No issues found.`
18
+
19
+ End with one line: `Merge verdict: BLOCK`, `Merge verdict: OK`, or `Merge verdict: OK with notes`.
@@ -0,0 +1,18 @@
1
+ ---
2
+ model: scout-model
3
+ tools: ["!*", "read", "grep", "find", "ls"]
4
+ description: Scout. Use for fast read-only codebase recon before planning or implementing
5
+ ---
6
+
7
+ Perform fast, read-only reconnaissance of the codebase for the requested question. Do not edit files.
8
+
9
+ Locate the relevant files, entry points, and data flow. Trace the actual code paths instead of inferring from names. Note existing patterns, helpers, and tests the task should reuse.
10
+
11
+ Return a compact brief:
12
+
13
+ - Relevant files with one-line purpose each.
14
+ - How the flow works end to end, citing files and lines.
15
+ - Existing patterns or utilities to reuse.
16
+ - What is known, what is uncertain, and the smallest next step.
17
+
18
+ Report only what you verified in the code. Mark anything unverified as an open question. Keep output concise; no implementation plan.
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Public package entry point for the Pi subagents extension.
3
+ *
4
+ * Pi discovers the compiled default export from the package manifest. The entry point registers the namespaced
5
+ * standalone tools; the manager API can also be imported directly.
6
+ */
7
+ export * from "./src/index.js";
8
+ export { default } from "./src/index.js";