pi-agent-flow 1.1.0 → 1.2.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 +158 -44
- package/agents/audit.md +37 -17
- package/agents/build.md +42 -38
- package/agents/craft.md +33 -17
- package/agents/debug.md +32 -15
- package/agents/ideas.md +33 -11
- package/agents/scout.md +32 -12
- package/package.json +4 -15
- package/{agents.ts → src/agents.ts} +10 -4
- package/src/ambient.d.ts +85 -0
- package/{batch.ts → src/batch.ts} +256 -118
- package/src/cli-args.ts +283 -0
- package/src/config.ts +305 -0
- package/{flow.ts → src/flow.ts} +39 -18
- package/{hooks.ts → src/hooks.ts} +6 -6
- package/{index.ts → src/index.ts} +361 -102
- package/{render-utils.ts → src/render-utils.ts} +2 -2
- package/{render.ts → src/render.ts} +15 -10
- package/src/runner-events.ts +692 -0
- package/{types.ts → src/types.ts} +2 -0
- package/config.ts +0 -102
- package/runner-cli.js +0 -254
- package/runner-events.js +0 -559
- /package/{web-tool.ts → src/web-tool.ts} +0 -0
package/agents/ideas.md
CHANGED
|
@@ -1,29 +1,51 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ideas
|
|
3
|
-
description: Generate ideas, explore possibilities, and think creatively
|
|
3
|
+
description: Generate ideas, explore possibilities, and think creatively using inherited context as background
|
|
4
4
|
tools: batch, bash
|
|
5
|
-
inheritContext: false
|
|
6
5
|
maxDepth: 0
|
|
7
6
|
---
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
## Mission
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
During this ideas flow — your mission is to generate and compare possible directions. Use inherited context as background and constraints, but avoid anchoring too tightly on prior solutions.
|
|
11
|
+
|
|
12
|
+
## Workflow
|
|
13
|
+
|
|
14
|
+
1. Diverge — explore many possibilities without judging too early.
|
|
15
|
+
2. Evaluate — compare trade-offs, risks, effort, and reversibility.
|
|
16
|
+
3. Recommend — identify the strongest options and explain why.
|
|
17
|
+
4. Package — present choices clearly enough for planning or implementation handoff.
|
|
18
|
+
|
|
19
|
+
## Rules
|
|
20
|
+
|
|
21
|
+
- Stay focused on the requested intent; creativity should still serve the objective.
|
|
22
|
+
- Prefer several distinct options over variations of the same idea.
|
|
23
|
+
- Make assumptions explicit when evidence is limited.
|
|
24
|
+
- If file context is needed, use `batch` with `o: "read"`, `s: <offset>`, and `l: <limit>` for targeted reading instead of bash `sed`/`head`/`tail`.
|
|
25
|
+
- Do not implement changes from this flow.
|
|
26
|
+
|
|
27
|
+
## Handoff Guidance
|
|
28
|
+
|
|
29
|
+
- Recommend [craft] when the best option should become a concrete design or plan.
|
|
30
|
+
- Recommend [scout] when more repository evidence is needed before choosing.
|
|
31
|
+
- Recommend [build] only when the chosen option is simple and ready to implement.
|
|
32
|
+
- Recommend [audit] when an option needs quality, security, or correctness review.
|
|
33
|
+
- Recommend [debug] when uncertainty comes from broken or unexplained behavior.
|
|
34
|
+
|
|
35
|
+
## Output Format
|
|
15
36
|
|
|
16
37
|
When accomplished, end your response with:
|
|
17
38
|
|
|
18
39
|
flow [ideas] accomplished
|
|
19
40
|
|
|
20
|
-
[Summary]
|
|
41
|
+
[Summary]
|
|
42
|
+
- What was explored and the recommended direction in 2–4 concise sentences.
|
|
21
43
|
|
|
22
44
|
[Done]
|
|
23
|
-
-
|
|
45
|
+
- Ideas generated, trade-offs considered, and recommendation rationale.
|
|
24
46
|
|
|
25
47
|
[Not Done]
|
|
26
|
-
-
|
|
48
|
+
- Incomplete items, unresolved assumptions, or reasons work was deferred.
|
|
27
49
|
|
|
28
50
|
[Next Steps]
|
|
29
|
-
- recommended follow-up
|
|
51
|
+
- Specific recommended follow-up actions or next flow.
|
package/agents/scout.md
CHANGED
|
@@ -1,31 +1,51 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: scout
|
|
3
3
|
description: Discover files, trace code paths, map architecture
|
|
4
|
-
tools:
|
|
4
|
+
tools: batch_read, bash, find, grep, ls
|
|
5
5
|
maxDepth: 0
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
## Mission
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
During this scout flow — your mission is to discover relevant context. Move fast, stay surgical, and treat the conversation history above as background reference only.
|
|
11
|
+
|
|
12
|
+
## Workflow
|
|
13
|
+
|
|
14
|
+
1. Survey — use `ls`, `find`, and `grep` to locate relevant files and symbols before reading whole files.
|
|
15
|
+
2. Inspect — use `batch_read` with `o: "read"`, `s: <offset>`, and `l: <limit>` for targeted file reading instead of bash `sed`/`head`/`tail`.
|
|
16
|
+
3. Trace — follow code paths, dependencies, configuration, and tests that explain the requested area.
|
|
17
|
+
4. Report — cite concrete evidence and stop when the requested context is mapped.
|
|
18
|
+
|
|
19
|
+
## Rules
|
|
20
|
+
|
|
21
|
+
- This is a read-oriented flow: do not modify files.
|
|
22
|
+
- Cite every finding with a precise file path and line number or range.
|
|
23
|
+
- Include relevant snippets or evidence inline so citations are verifiable.
|
|
15
24
|
- Show actual code/data, not excessive summaries.
|
|
16
|
-
- If not found, say so
|
|
25
|
+
- If something is not found, say so directly — do not guess.
|
|
26
|
+
|
|
27
|
+
## Handoff Guidance
|
|
28
|
+
|
|
29
|
+
- Recommend [craft] when findings need to become a design or implementation plan.
|
|
30
|
+
- Recommend [build] when the change is obvious, localized, and ready to implement.
|
|
31
|
+
- Recommend [debug] when evidence points to a defect or unexplained behavior.
|
|
32
|
+
- Recommend [ideas] when multiple viable directions need exploration.
|
|
33
|
+
- Recommend [audit] when discovered code needs quality, security, or correctness verification.
|
|
34
|
+
|
|
35
|
+
## Output Format
|
|
17
36
|
|
|
18
37
|
When accomplished, end your response with:
|
|
19
38
|
|
|
20
39
|
flow [scout] accomplished
|
|
21
40
|
|
|
22
|
-
[Summary]
|
|
41
|
+
[Summary]
|
|
42
|
+
- What was investigated and the outcome in 2–4 concise sentences.
|
|
23
43
|
|
|
24
44
|
[Done]
|
|
25
|
-
-
|
|
45
|
+
- Completed discovery items with file:line references and inline evidence snippets.
|
|
26
46
|
|
|
27
47
|
[Not Done]
|
|
28
|
-
-
|
|
48
|
+
- Incomplete items and reasons, or "All objectives met."
|
|
29
49
|
|
|
30
50
|
[Next Steps]
|
|
31
|
-
- recommended follow-up actions
|
|
51
|
+
- Specific recommended follow-up actions or next flow.
|
package/package.json
CHANGED
|
@@ -1,28 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-flow",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Flow-state delegation extension for Pi coding agent.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "index.ts",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
7
|
"files": [
|
|
8
|
-
"
|
|
9
|
-
"web-tool.ts",
|
|
10
|
-
"agents.ts",
|
|
11
|
-
"config.ts",
|
|
12
|
-
"flow.ts",
|
|
13
|
-
"hooks.ts",
|
|
14
|
-
"runner-cli.js",
|
|
15
|
-
"runner-events.js",
|
|
16
|
-
"render.ts",
|
|
17
|
-
"render-utils.ts",
|
|
18
|
-
"types.ts",
|
|
19
|
-
"batch.ts",
|
|
8
|
+
"src/",
|
|
20
9
|
"agents/",
|
|
21
10
|
"README.md"
|
|
22
11
|
],
|
|
23
12
|
"pi": {
|
|
24
13
|
"extensions": [
|
|
25
|
-
"./index.ts"
|
|
14
|
+
"./src/index.ts"
|
|
26
15
|
]
|
|
27
16
|
},
|
|
28
17
|
"keywords": [
|
|
@@ -72,19 +72,25 @@ function getUserFlowsDir(): string {
|
|
|
72
72
|
/** Get the bundled flows directory from the plugin's location. */
|
|
73
73
|
function getBundledFlowsDir(): string {
|
|
74
74
|
// Method 1: import.meta.url (ESM)
|
|
75
|
+
// When source lives in src/, agents/ is one level up at the package root.
|
|
75
76
|
try {
|
|
76
77
|
if (import.meta.url) {
|
|
77
78
|
const pluginDir = path.dirname(new URL(import.meta.url).pathname);
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
// Check same directory first, then parent (for src/ layout)
|
|
80
|
+
for (const base of [pluginDir, path.dirname(pluginDir)]) {
|
|
81
|
+
const dir = path.join(base, "agents");
|
|
82
|
+
if (fs.existsSync(dir)) return dir;
|
|
83
|
+
}
|
|
80
84
|
}
|
|
81
85
|
} catch {}
|
|
82
86
|
|
|
83
87
|
// Method 2: __dirname (CommonJS / jiti)
|
|
84
88
|
try {
|
|
85
89
|
if (typeof __dirname !== "undefined") {
|
|
86
|
-
const
|
|
87
|
-
|
|
90
|
+
for (const base of [__dirname, path.dirname(__dirname)]) {
|
|
91
|
+
const dir = path.join(base, "agents");
|
|
92
|
+
if (fs.existsSync(dir)) return dir;
|
|
93
|
+
}
|
|
88
94
|
}
|
|
89
95
|
} catch {}
|
|
90
96
|
|
package/src/ambient.d.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/** Minimal ambient declarations for peer dependencies */
|
|
2
|
+
|
|
3
|
+
declare module "@mariozechner/pi-coding-agent" {
|
|
4
|
+
export interface ExtensionAPI {
|
|
5
|
+
registerFlag(name: string, config: { description: string; type: string }): void;
|
|
6
|
+
getFlag(name: string): unknown;
|
|
7
|
+
getActiveTools(): string[];
|
|
8
|
+
on(event: string, callback: (...args: any[]) => any): void;
|
|
9
|
+
registerTool(tool: {
|
|
10
|
+
name: string;
|
|
11
|
+
label: string;
|
|
12
|
+
description: string;
|
|
13
|
+
parameters: any;
|
|
14
|
+
execute: (...args: any[]) => Promise<any>;
|
|
15
|
+
renderCall?: (...args: any[]) => any;
|
|
16
|
+
renderResult?: (...args: any[]) => any;
|
|
17
|
+
}): void;
|
|
18
|
+
setActiveTools(tools: string[]): void;
|
|
19
|
+
}
|
|
20
|
+
export interface ExtensionContext {
|
|
21
|
+
cwd: string;
|
|
22
|
+
hasUI: boolean;
|
|
23
|
+
ui: { confirm: (title: string, body: string) => Promise<boolean> };
|
|
24
|
+
sessionManager: { getSessionDir(): string };
|
|
25
|
+
}
|
|
26
|
+
export function parseFrontmatter<T extends Record<string, unknown>>(content: string): { frontmatter: T; body: string };
|
|
27
|
+
export function getMarkdownTheme(): any;
|
|
28
|
+
export const DEFAULT_MAX_BYTES: number;
|
|
29
|
+
export const DEFAULT_MAX_LINES: number;
|
|
30
|
+
export function truncateHead(text: string, options: { maxBytes?: number; maxLines?: number }): { content: string };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
declare module "@mariozechner/pi-tui" {
|
|
34
|
+
export class Text {
|
|
35
|
+
constructor(text: string, width: number, height: number);
|
|
36
|
+
toString(): string;
|
|
37
|
+
}
|
|
38
|
+
export class TruncatedText {
|
|
39
|
+
constructor(text: string, paddingX?: number, paddingY?: number);
|
|
40
|
+
toString(): string;
|
|
41
|
+
}
|
|
42
|
+
export class Container {
|
|
43
|
+
children: any[];
|
|
44
|
+
addChild(child: any): void;
|
|
45
|
+
}
|
|
46
|
+
export class Markdown {
|
|
47
|
+
constructor(text: string, width: number, height: number, theme?: any);
|
|
48
|
+
}
|
|
49
|
+
export class Spacer {
|
|
50
|
+
constructor(height: number);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
declare module "@mariozechner/pi-agent-core" {
|
|
55
|
+
export interface AgentToolResult<T = any> {
|
|
56
|
+
content: any[];
|
|
57
|
+
details?: T;
|
|
58
|
+
isError?: boolean;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
declare module "@mariozechner/pi-ai" {
|
|
63
|
+
export interface Message {
|
|
64
|
+
role: string;
|
|
65
|
+
content: string | any[];
|
|
66
|
+
usage?: any;
|
|
67
|
+
model?: string;
|
|
68
|
+
stopReason?: string;
|
|
69
|
+
errorMessage?: string;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
declare module "@sinclair/typebox" {
|
|
74
|
+
export const Type: {
|
|
75
|
+
Object: (properties: Record<string, any>, options?: any) => any;
|
|
76
|
+
String: (options?: any) => any;
|
|
77
|
+
Number: (options?: any) => any;
|
|
78
|
+
Array: (items: any, options?: any) => any;
|
|
79
|
+
Optional: (schema: any) => any;
|
|
80
|
+
Boolean: (options?: any) => any;
|
|
81
|
+
Union: (variants: any[], options?: any) => any;
|
|
82
|
+
Literal: (value: string) => any;
|
|
83
|
+
};
|
|
84
|
+
export type Static<T> = any;
|
|
85
|
+
}
|