@maplezzk/pi-dynamic-workflows 1.0.0 → 1.1.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.
package/README.md CHANGED
@@ -10,19 +10,19 @@ Claude-Code-style dynamic workflow orchestration for Pi.
10
10
  - Static validation of workflow scripts via acorn AST parsing
11
11
  - Optional subagent backend via `pi-interactive-subagents` for real tool access per agent
12
12
  - Async background execution mode with live status widget
13
- - Configurable via `/workflow-config` slash command (persisted to JSON)
13
+ - Configurable via `/config:workflow` slash command (persisted to JSON)
14
14
 
15
15
  ## Installation
16
16
 
17
17
  ```bash
18
- pi install @maplezzk/pi-dynamic-workflows
18
+ pi install npm:@maplezzk/pi-dynamic-workflows
19
19
  ```
20
20
 
21
21
  ## Configuration
22
22
 
23
- Run `/workflow-config` to interactively configure:
23
+ Run `/config:workflow` to interactively configure:
24
24
 
25
- - **Execution backend**: `workflow` (built-in in-process agent) or `subagent` (requires `pi-interactive-subagents`)
25
+ - **Execution backend**: `workflow` (built-in in-process agent) or `subagent` (requires `pi-interactive-subagents` to be installed and loaded; each agent gets a real tool session)
26
26
  - **Async mode**: run workflows in the background with a live status widget
27
27
 
28
28
  Config is persisted to `~/.pi/agent/extensions/pi-dynamic-workflows/config.json`.
@@ -36,6 +36,32 @@ Environment variables are supported as fallback only:
36
36
 
37
37
  JSON config takes priority over environment variables.
38
38
 
39
+ > **Note:** The `subagent` backend depends on the `pi-interactive-subagents` extension injecting its capabilities into `globalThis.__pi_subagents` at runtime. If the backend is set to `subagent` but that extension is not installed/loaded, every `agent()` call in the workflow will fail.
40
+
41
+ ## Troubleshooting
42
+
43
+ ### Error: the subagent execution backend requires the pi-interactive-subagents extension, which is not currently loaded
44
+
45
+ **Cause**: the workflow execution backend is set to `subagent`, but the `pi-interactive-subagents` extension is not installed or not loaded, so `globalThis.__pi_subagents` is not injected.
46
+
47
+ The `subagent` backend can be activated by either of:
48
+
49
+ - The `PI_WORKFLOW_BACKEND=subagent` environment variable
50
+ - The persisted config written by `/workflow-config` (`~/.pi/agent/extensions/pi-dynamic-workflows/config.json`)
51
+
52
+ **Fix (choose one)**:
53
+
54
+ 1. Install and load the extension (keep using the subagent backend):
55
+
56
+ ```bash
57
+ pi install npm:@maplezzk/pi-interactive-subagents
58
+ ```
59
+
60
+ 2. Switch back to the built-in `workflow` backend: run `/config:workflow` and set the execution backend to `workflow`. The persisted config takes priority over environment variables, so this overrides `PI_WORKFLOW_BACKEND`.
61
+ 3. If you enabled it via an environment variable, remove `export PI_WORKFLOW_BACKEND=subagent` from your shell config (e.g. `.zshrc` / `.zshenv`) and restart pi.
62
+
63
+ `/workflow-config` and `/pi-workflow-config` remain available as compatibility aliases.
64
+
39
65
  ## Usage
40
66
 
41
67
  ```js
package/README.zh-CN.md CHANGED
@@ -10,19 +10,19 @@
10
10
  - 通过 acorn AST 解析对 workflow 脚本进行静态校验
11
11
  - 可选 subagent 后端(依赖 `pi-interactive-subagents`),每个 agent 拥有真实工具访问
12
12
  - 异步后台执行模式,带实时状态 widget
13
- - 通过 `/workflow-config` 斜杠命令配置(持久化到 JSON)
13
+ - 通过 `/config:workflow` 斜杠命令配置(持久化到 JSON)
14
14
 
15
15
  ## 安装
16
16
 
17
17
  ```bash
18
- pi install @maplezzk/pi-dynamic-workflows
18
+ pi install npm:@maplezzk/pi-dynamic-workflows
19
19
  ```
20
20
 
21
21
  ## 配置
22
22
 
23
- 运行 `/workflow-config` 进行交互式配置:
23
+ 运行 `/config:workflow` 进行交互式配置:
24
24
 
25
- - **执行后端**:`workflow`(内置进程内 agent)或 `subagent`(需安装 `pi-interactive-subagents`)
25
+ - **执行后端**:`workflow`(内置进程内 agent)或 `subagent`(需安装并加载 `pi-interactive-subagents`,每个 agent 拥有真实工具会话)
26
26
  - **异步模式**:后台运行 workflow,带实时状态 widget
27
27
 
28
28
  配置持久化到 `~/.pi/agent/extensions/pi-dynamic-workflows/config.json`。
@@ -36,6 +36,32 @@ pi install @maplezzk/pi-dynamic-workflows
36
36
 
37
37
  JSON 配置优先级高于环境变量。
38
38
 
39
+ > **注意**:`subagent` 后端依赖 `pi-interactive-subagents` 扩展在运行时向 `globalThis.__pi_subagents` 注入能力。若后端被设为 `subagent` 但该扩展未安装/未加载,workflow 中的每个 `agent()` 都会失败。
40
+
41
+ ## 常见问题
42
+
43
+ ### 报错:subagent 执行后端需要 pi-interactive-subagents 扩展,但当前未加载
44
+
45
+ **原因**:workflow 的执行后端被设为 `subagent`,但 `pi-interactive-subagents` 扩展未安装或未加载,导致 `globalThis.__pi_subagents` 未注入。
46
+
47
+ `subagent` 后端可能由以下任一来源触发:
48
+
49
+ - 环境变量 `PI_WORKFLOW_BACKEND=subagent`
50
+ - `/workflow-config` 写入的持久化配置(`~/.pi/agent/extensions/pi-dynamic-workflows/config.json`)
51
+
52
+ **解决方式(任选其一)**:
53
+
54
+ 1. 安装并加载扩展(继续使用 subagent 后端):
55
+
56
+ ```bash
57
+ pi install npm:@maplezzk/pi-interactive-subagents
58
+ ```
59
+
60
+ 2. 切回内置 `workflow` 后端:运行 `/config:workflow`,将执行后端改为 `workflow`。持久化配置优先级高于环境变量,可覆盖 `PI_WORKFLOW_BACKEND`。
61
+ 3. 若是通过环境变量启用,移除 shell 配置(如 `.zshrc` / `.zshenv`)中的 `export PI_WORKFLOW_BACKEND=subagent` 后重启 pi。
62
+
63
+ `/workflow-config` 和 `/pi-workflow-config` 仍作为兼容别名保留。
64
+
39
65
  ## 用法
40
66
 
41
67
  ```js
@@ -72,7 +72,7 @@
72
72
  "en-US": "📄 Result: {path}"
73
73
  },
74
74
  "subagentRequired": {
75
- "zh-CN": "PI_WORKFLOW_BACKEND=subagent 需要 pi-interactive-subagents 扩展。\n安装: pi install pi-interactive-subagents",
76
- "en-US": "PI_WORKFLOW_BACKEND=subagent requires the pi-interactive-subagents extension.\nInstall: pi install pi-interactive-subagents"
75
+ "zh-CN": "subagent 执行后端需要 pi-interactive-subagents 扩展,但当前未加载。\n\n解决方式(任选其一):\n1. 安装扩展:pi install npm:@maplezzk/pi-interactive-subagents\n2. 运行 /workflow-config 将执行后端切回 workflow\n\n说明:subagent 后端由环境变量 PI_WORKFLOW_BACKEND=subagent 或 /workflow-config 持久化配置触发。",
76
+ "en-US": "The subagent execution backend requires the pi-interactive-subagents extension, which is not currently loaded.\n\nFix (choose one):\n1. Install the extension: pi install npm:@maplezzk/pi-interactive-subagents\n2. Run /workflow-config to switch the execution backend back to workflow\n\nNote: the subagent backend is activated by the PI_WORKFLOW_BACKEND=subagent environment variable or the /workflow-config persisted setting."
77
77
  }
78
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maplezzk/pi-dynamic-workflows",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "Claude-Code-style dynamic workflow orchestration for Pi. Fork of michaelliv/pi-dynamic-workflows.",
5
5
  "type": "module",
6
6
  "main": "./index.ts",
package/src/config.ts CHANGED
@@ -5,7 +5,7 @@ import { dirname, join } from "node:path";
5
5
  /**
6
6
  * Workflow 运行时配置。
7
7
  *
8
- * 优先级:JSON 配置文件(由 /workflow-config 斜杠命令写入)> 环境变量兜底 > 默认值。
8
+ * 优先级:JSON 配置文件(由 /config:workflow 斜杠命令写入)> 环境变量兜底 > 默认值。
9
9
  * 环境变量仅作为兜底支持(PI_WORKFLOW_BACKEND / PI_WORKFLOW_ASYNC)。
10
10
  */
11
11
  export type WorkflowBackend = "workflow" | "subagent";
package/src/extension.ts CHANGED
@@ -101,9 +101,9 @@ export default function extension(pi: ExtensionAPI) {
101
101
  });
102
102
  }
103
103
 
104
- /** /workflow-config 交互式配置命令:切换执行后端与异步模式,持久化到 JSON。 */
104
+ /** /config:workflow 交互式配置命令;旧名称保留为兼容别名。 */
105
105
  function registerConfigCommand(pi: ExtensionAPI) {
106
- pi.registerCommand("workflow-config", {
106
+ const command = {
107
107
  description: i18n.t("commandDescription"),
108
108
  handler: async (_args, ctx) => {
109
109
  if (!ctx.hasUI) return;
@@ -132,5 +132,8 @@ function registerConfigCommand(pi: ExtensionAPI) {
132
132
  }
133
133
  }
134
134
  },
135
- });
135
+ };
136
+ for (const name of ["config:workflow", "workflow-config", "pi-workflow-config"] as const) {
137
+ pi.registerCommand(name, command);
138
+ }
136
139
  }