pi-agent-flow 1.0.8 → 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/package.json CHANGED
@@ -1,26 +1,17 @@
1
1
  {
2
2
  "name": "pi-agent-flow",
3
- "version": "1.0.8",
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
- "index.ts",
9
- "agents.ts",
10
- "config.ts",
11
- "flow.ts",
12
- "hooks.ts",
13
- "runner-cli.js",
14
- "runner-events.js",
15
- "render.ts",
16
- "render-utils.ts",
17
- "types.ts",
8
+ "src/",
18
9
  "agents/",
19
10
  "README.md"
20
11
  ],
21
12
  "pi": {
22
13
  "extensions": [
23
- "./index.ts"
14
+ "./src/index.ts"
24
15
  ]
25
16
  },
26
17
  "keywords": [
@@ -35,7 +26,7 @@
35
26
  "url": "https://github.com/tuanhung303/pi-agent-flow"
36
27
  },
37
28
  "engines": {
38
- "node": ">=18"
29
+ "node": ">=20.19.0"
39
30
  },
40
31
  "scripts": {
41
32
  "lint": "tsc --noEmit",
@@ -43,7 +34,9 @@
43
34
  },
44
35
  "devDependencies": {
45
36
  "typescript": "^5.0.0",
46
- "vitest": "^3.2.4"
37
+ "vitest": "^3.2.4",
38
+ "@types/jsdom": "^28.0.1",
39
+ "@types/turndown": "^5.0.6"
47
40
  },
48
41
  "peerDependencies": {
49
42
  "@mariozechner/pi-agent-core": ">=0.37.0",
@@ -68,5 +61,9 @@
68
61
  "@sinclair/typebox": {
69
62
  "optional": true
70
63
  }
64
+ },
65
+ "dependencies": {
66
+ "jsdom": "^29.1.0",
67
+ "turndown": "^7.2.4"
71
68
  }
72
69
  }
@@ -42,14 +42,14 @@ export interface FlowDiscoveryResult {
42
42
  export function getFlowTier(flowName: string): FlowTier {
43
43
  const normalized = flowName.toLowerCase().trim();
44
44
  switch (normalized) {
45
- case "explore":
45
+ case "scout":
46
46
  case "debug":
47
47
  return "lite";
48
- case "code":
49
- case "review":
48
+ case "build":
49
+ case "audit":
50
50
  return "flash";
51
- case "brainstorm":
52
- case "architect":
51
+ case "ideas":
52
+ case "craft":
53
53
  return "full";
54
54
  default:
55
55
  return "flash";
@@ -72,22 +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
- // @ts-expect-error — import.meta.url may not exist in all contexts
77
77
  if (import.meta.url) {
78
- // @ts-expect-error
79
78
  const pluginDir = path.dirname(new URL(import.meta.url).pathname);
80
- const dir = path.join(pluginDir, "agents");
81
- if (fs.existsSync(dir)) return dir;
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
+ }
82
84
  }
83
85
  } catch {}
84
86
 
85
87
  // Method 2: __dirname (CommonJS / jiti)
86
88
  try {
87
- // @ts-expect-error — __dirname may not exist in ESM
88
89
  if (typeof __dirname !== "undefined") {
89
- const dir = path.join(__dirname, "agents");
90
- if (fs.existsSync(dir)) return dir;
90
+ for (const base of [__dirname, path.dirname(__dirname)]) {
91
+ const dir = path.join(base, "agents");
92
+ if (fs.existsSync(dir)) return dir;
93
+ }
91
94
  }
92
95
  } catch {}
93
96
 
@@ -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
+ }