@zhushanwen/pi-subagent-workflow 0.4.0 → 0.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhushanwen/pi-subagent-workflow",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "type": "module",
5
5
  "main": "index.ts",
6
6
  "description": "Unified subagent execution and multi-agent workflow orchestration for Pi — spawned-process agent runtime with sync/background modes, stateful workflow management with persistence, state machine, and execution tracing.",
@@ -43,14 +43,14 @@
43
43
  "@xyz-agent/extension-protocol": "^0.2.0"
44
44
  },
45
45
  "peerDependencies": {
46
- "@mariozechner/pi-coding-agent": "*",
47
- "@mariozechner/pi-ai": "*",
48
- "@mariozechner/pi-tui": "*",
46
+ "@earendil-works/pi-coding-agent": "*",
47
+ "@earendil-works/pi-ai": "*",
48
+ "@earendil-works/pi-tui": "*",
49
49
  "@sinclair/typebox": "*",
50
- "@zhushanwen/pi-structured-output": "*"
50
+ "@zhushanwen/pi-structured-output": "0.3.5"
51
51
  },
52
52
  "peerDependenciesMeta": {
53
- "@mariozechner/pi-coding-agent": {
53
+ "@earendil-works/pi-coding-agent": {
54
54
  "optional": true
55
55
  },
56
56
  "@zhushanwen/pi-structured-output": {
@@ -8,7 +8,7 @@
8
8
  //
9
9
  // 测试用 mock theme(bg 记录调用色 token),不依赖真实 Pi Theme。
10
10
 
11
- import type { Theme } from "@mariozechner/pi-coding-agent";
11
+ import type { Theme } from "@earendil-works/pi-coding-agent";
12
12
  import { describe, expect, it } from "vitest";
13
13
 
14
14
  import { renderBgNotifyMessage } from "../../interface/bg-notify-render.ts";
@@ -17,13 +17,13 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
17
17
 
18
18
  // ── mock modules(在 import 前声明)──
19
19
 
20
- vi.mock("@mariozechner/pi-coding-agent", () => ({
20
+ vi.mock("@earendil-works/pi-coding-agent", () => ({
21
21
  getAgentDir: () => "/home/user/.pi/agent",
22
22
  }));
23
23
  vi.mock("@earendil-works/pi-coding-agent", () => ({
24
24
  getAgentDir: () => "/home/user/.pi/agent",
25
25
  }));
26
- vi.mock("@mariozechner/pi-ai", () => ({
26
+ vi.mock("@earendil-works/pi-ai", () => ({
27
27
  StringEnum: (values: string[]) => ({ type: "string", enum: values }),
28
28
  }));
29
29
  vi.mock("@earendil-works/pi-ai", () => ({
@@ -118,7 +118,7 @@ vi.mock("../../interface/commands.ts", () => ({
118
118
  }));
119
119
 
120
120
  // ── import 被测工厂 ──
121
- import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
121
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
122
122
 
123
123
  import subagentsExtension from "../../index.ts";
124
124
  import { Budget } from "../../orchestration/models/budget.ts";
@@ -13,7 +13,7 @@
13
13
  * Proxy 的 trap 对所有属性访问返回 override 值或 no-op 函数,运行时安全
14
14
  * (注册 handler 只调用被 override 的方法,其余方法测试不触及)。
15
15
  */
16
- import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
16
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
17
17
 
18
18
  export function mockExtensionApi(
19
19
  overrides: Record<string, unknown> = {},
@@ -28,7 +28,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
28
28
  // ExtensionContext/ExtensionMode 等 *类型*(编译期擦除)+ getAgentDir 运行时值。服务于
29
29
  // 全仓库绝大多数测试的类型解析与轻量 mock(不 import 真实重模块的测试直接吃 alias)。
30
30
  // 2. **本文件内联 vi.mock(下方)**:vi.mock 在运行时覆盖 config alias,确保本文件 import
31
- // 真实 index.ts(它 `import { getAgentDir } from "@mariozechner/pi-coding-agent"` +
31
+ // 真实 index.ts(它 `import { getAgentDir } from "@earendil-works/pi-coding-agent"` +
32
32
  // 一组 type-only import)时,运行时只暴露 getAgentDir,彻底隔离真实 SDK 的模块顶层
33
33
  // 副作用(避免 jiti 加载真实 pi 包触发未 mock 的依赖链)。
34
34
  // 3. 形状一致性:内联 mock 的运行时值形状(`{ getAgentDir }`)与 alias stub 的运行时值
@@ -39,13 +39,13 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
39
39
  // 测试统一用内联 vi.mock 覆盖),三者保持一致。
40
40
  // 结论:不抽共享 mocks 文件。alias 已承担类型解析,内联 vi.mock 承担运行时隔离,职责正交。
41
41
 
42
- vi.mock("@mariozechner/pi-coding-agent", () => ({
42
+ vi.mock("@earendil-works/pi-coding-agent", () => ({
43
43
  getAgentDir: () => "/home/user/.pi/agent",
44
44
  }));
45
45
  vi.mock("@earendil-works/pi-coding-agent", () => ({
46
46
  getAgentDir: () => "/home/user/.pi/agent",
47
47
  }));
48
- vi.mock("@mariozechner/pi-ai", () => ({
48
+ vi.mock("@earendil-works/pi-ai", () => ({
49
49
  StringEnum: (values: string[]) => ({ type: "string", enum: values }),
50
50
  }));
51
51
  vi.mock("@earendil-works/pi-ai", () => ({
@@ -155,7 +155,7 @@ vi.mock("../../interface/commands.ts", () => ({
155
155
  }));
156
156
 
157
157
  // ── import 被测工厂 ──
158
- import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
158
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
159
159
 
160
160
  import subagentsExtension from "../../index.ts";
161
161
 
@@ -18,7 +18,7 @@ import { describe, expect, it, vi } from "vitest";
18
18
 
19
19
  // registerSubagentTool 经 subagent-tool.ts 值导入 StringEnum(pi-ai)+ Type(typebox)。
20
20
  // shared/types stub 是 .d.ts(仅类型),pnpm optional-peer-dep 插件拦截值导入 → vi.mock 兜底。
21
- vi.mock("@mariozechner/pi-ai", () => ({
21
+ vi.mock("@earendil-works/pi-ai", () => ({
22
22
  StringEnum: (values: string[]) => ({ type: "string", enum: values }),
23
23
  }));
24
24
  vi.mock("@earendil-works/pi-ai", () => ({
@@ -9,13 +9,13 @@ import { beforeEach,describe, expect, it, vi } from "vitest";
9
9
 
10
10
  // ── mock modules(在 import 前声明)──
11
11
 
12
- vi.mock("@mariozechner/pi-coding-agent", () => ({
12
+ vi.mock("@earendil-works/pi-coding-agent", () => ({
13
13
  getAgentDir: () => "/home/user/.pi/agent",
14
14
  }));
15
15
  vi.mock("@earendil-works/pi-coding-agent", () => ({
16
16
  getAgentDir: () => "/home/user/.pi/agent",
17
17
  }));
18
- vi.mock("@mariozechner/pi-ai", () => ({
18
+ vi.mock("@earendil-works/pi-ai", () => ({
19
19
  StringEnum: (values: string[]) => ({ type: "string", enum: values }),
20
20
  }));
21
21
  vi.mock("@earendil-works/pi-ai", () => ({
@@ -104,7 +104,7 @@ vi.mock("../tui/bg-notify-render.ts", () => ({
104
104
  }));
105
105
 
106
106
  // ── import 被测工厂 ──
107
- import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
107
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
108
108
 
109
109
  import subagentsExtension from "../../index.ts";
110
110
 
@@ -9,7 +9,7 @@
9
9
  // realHandler 路由:channel 命中 → channelHandler(经 coerceUiResponse 形变);未命中 → defaultDialogForward(cancelled)。
10
10
  // 测接口契约,不测实现细节。
11
11
 
12
- import type { ExtensionContext, ExtensionMode } from "@mariozechner/pi-coding-agent";
12
+ import type { ExtensionContext, ExtensionMode } from "@earendil-works/pi-coding-agent";
13
13
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
14
14
 
15
15
  import { DialogGlobalQueue, type UiRequest } from "../dialog-queue.ts";
@@ -16,7 +16,7 @@
16
16
  // 集中到单一修改点,未来 Pi 新增 mode 值时只改本文件。
17
17
  // - 业务语义命名("gui"/"headless")比原始枚举值更清晰表达意图。
18
18
 
19
- import type { ExtensionMode } from "@mariozechner/pi-coding-agent";
19
+ import type { ExtensionMode } from "@earendil-works/pi-coding-agent";
20
20
 
21
21
  /** 主进程运行模式分类。基于 ExtensionMode 聚合为业务语义。
22
22
  * - "tui":纯 Pi TUI,ctx.ui.custom 可用,用户在终端交互
@@ -9,7 +9,7 @@
9
9
  import { type ChildProcess,execFileSync, spawn } from "node:child_process";
10
10
  import * as fs from "node:fs";
11
11
 
12
- import type { ExtensionMode } from "@mariozechner/pi-coding-agent";
12
+ import type { ExtensionMode } from "@earendil-works/pi-coding-agent";
13
13
 
14
14
  import { type MirrorFlags, mirrorMainProcessFlags } from "./argv-mirror.ts";
15
15
  import { writeAliveMarker } from "./alive-store.ts";
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { AsyncLocalStorage } from "node:async_hooks";
6
6
 
7
- import type { ExtensionMode } from "@mariozechner/pi-coding-agent";
7
+ import type { ExtensionMode } from "@earendil-works/pi-coding-agent";
8
8
 
9
9
  import type { AgentResult as WorkflowAgentResult } from "../orchestration/models/types.ts";
10
10
  // D-A10: workflow 侧 AgentResult 映射(executeAndAwait 出口)
@@ -18,7 +18,7 @@
18
18
  // SR-3:调用方(index.ts session_start)无论 new 还是 existing SubagentService 都必须调
19
19
  // setUiRequestHandler——/resume /fork 复用 existingService 时旧 handler 可能已失效。
20
20
 
21
- import type { ExtensionContext } from "@mariozechner/pi-coding-agent";
21
+ import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
22
22
 
23
23
  import { DialogGlobalQueue, type UiRequest, type UiRequestHandler, type UiResponse } from "./dialog-queue.ts";
24
24
  import { type HostMode, resolveHostMode } from "./host-mode.ts";
@@ -117,7 +117,7 @@ function coerceUiResponse(raw: unknown, reqId: string): UiResponse {
117
117
  * select 请求转发为普通 select(title 可能含 marker,主 agent 会忽略或当普通 select 渲染)。
118
118
  *
119
119
  * 实现依据(SDK ExtensionUIContext 真实签名,read from
120
- * @mariozechner/pi-coding-agent dist/core/extensions/types.d.ts):
120
+ * @earendil-works/pi-coding-agent dist/core/extensions/types.d.ts):
121
121
  * select(title: string, options: string[], opts?): Promise<string | undefined>
122
122
  * confirm(title: string, message: string, opts?): Promise<boolean>
123
123
  * input(title: string, placeholder?: string, opts?): Promise<string | undefined>
@@ -3,7 +3,7 @@
3
3
  // UI 请求可观测性状态(从 subagent-service.ts 提取,降低主文件行数)。
4
4
  // 持有 sessionMode + handler 缺失告警去重集合,供 SubagentService 委托调用。
5
5
 
6
- import type { ExtensionMode } from "@mariozechner/pi-coding-agent";
6
+ import type { ExtensionMode } from "@earendil-works/pi-coding-agent";
7
7
 
8
8
  // ── 跨模块桥接(ui-request-queue 无 ctx.service 引用时走这里) ──
9
9
  //
package/src/index.ts CHANGED
@@ -17,8 +17,8 @@ import * as fs from "node:fs";
17
17
  import * as os from "node:os";
18
18
  import * as path from "node:path";
19
19
 
20
- import type { ExtensionAPI, ExtensionContext, ModelSelectEvent, ResourcesDiscoverEvent, ResourcesDiscoverResult, SessionShutdownEvent, SessionStartEvent, SessionTreeEvent } from "@mariozechner/pi-coding-agent";
21
- import { getAgentDir } from "@mariozechner/pi-coding-agent";
20
+ import type { ExtensionAPI, ExtensionContext, ModelSelectEvent, ResourcesDiscoverEvent, ResourcesDiscoverResult, SessionShutdownEvent, SessionStartEvent, SessionTreeEvent } from "@earendil-works/pi-coding-agent";
21
+ import { getAgentDir } from "@earendil-works/pi-coding-agent";
22
22
 
23
23
  import type { AgentRegistry } from "./execution/agent-registry.ts";
24
24
  import { bestEffort } from "./execution/best-effort.ts";
@@ -60,7 +60,7 @@ import { WorkflowScriptRegistryImpl } from "./orchestration/workflow-script-regi
60
60
 
61
61
  // ── pi.__workflowRun 类型扩展(D-8 签名) ─────────────────
62
62
 
63
- declare module "@mariozechner/pi-coding-agent" {
63
+ declare module "@earendil-works/pi-coding-agent" {
64
64
  interface ExtensionAPI {
65
65
  __workflowRun?: (
66
66
  workflowName: string,
@@ -20,7 +20,7 @@
20
20
  // 故返回裸 Text 会丢失紫色背景,必须显式 Box 包裹。
21
21
 
22
22
  import type { Component } from "@earendil-works/pi-tui";
23
- import type { Theme } from "@mariozechner/pi-coding-agent";
23
+ import type { Theme } from "@earendil-works/pi-coding-agent";
24
24
 
25
25
  import {
26
26
  firstLine,
@@ -19,7 +19,7 @@
19
19
  * - spec.md UC-3(用户输入 /workflows,打开三级导航 TUI 面板)
20
20
  */
21
21
 
22
- import type { ExtensionAPI, ExtensionCommandContext, Theme } from "@mariozechner/pi-coding-agent";
22
+ import type { ExtensionAPI, ExtensionCommandContext, Theme } from "@earendil-works/pi-coding-agent";
23
23
 
24
24
  import type { LauncherDeps } from "../orchestration/launcher.ts";
25
25
  import { abortRun, pauseRun, resumeRun } from "../orchestration/lifecycle.ts";
@@ -8,7 +8,7 @@
8
8
  * 参考:domain-models.md §D-12。
9
9
  */
10
10
 
11
- import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
11
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
12
12
 
13
13
  import type { WorkflowRun } from "../orchestration/models/workflow-run.ts";
14
14
  import {
@@ -33,7 +33,7 @@
33
33
  // 9. 动画 setInterval(250ms) 安全:行数恒定(pad 到满屏),diff 只重画 spinner/elapsed
34
34
 
35
35
  import { matchesKey } from "@earendil-works/pi-tui";
36
- import type { ExtensionContext } from "@mariozechner/pi-coding-agent";
36
+ import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
37
37
 
38
38
  import type { SubagentService } from "../execution/subagent-service.ts";
39
39
  import type { SubagentRecord } from "../execution/types.ts";
@@ -8,7 +8,7 @@
8
8
  //
9
9
  // content(JSON 字符串)给 LLM,details(SubagentToolResult)给 renderResult,同源同处生成。
10
10
 
11
- import type { AgentToolResult } from "@mariozechner/pi-coding-agent";
11
+ import type { AgentToolResult } from "@earendil-works/pi-coding-agent";
12
12
  import {
13
13
  guiComponent,
14
14
  type GuiContext,
@@ -10,8 +10,8 @@
10
10
  // 抽到顶层后参数类型由 alias 提供,绕过该 quirk。
11
11
 
12
12
  import type { Component } from "@earendil-works/pi-tui";
13
- import { StringEnum } from "@mariozechner/pi-ai";
14
- import type { AgentToolResult, ExtensionAPI, ExtensionContext, Theme } from "@mariozechner/pi-coding-agent";
13
+ import { StringEnum } from "@earendil-works/pi-ai";
14
+ import type { AgentToolResult, ExtensionAPI, ExtensionContext, Theme } from "@earendil-works/pi-coding-agent";
15
15
  import { Type } from "@sinclair/typebox";
16
16
 
17
17
  import { SLUG_MAX_LENGTH } from "../execution/execute-options-mapper.ts";
@@ -5,7 +5,7 @@
5
5
  // 解析:args[0] 直接作可选 <id>(聚焦该 record)。
6
6
  // RPC 模式(xyz-agent GUI):解析 cancel action 直接执行,不打开 TUI。
7
7
 
8
- import type { ExtensionAPI, ExtensionCommandContext } from "@mariozechner/pi-coding-agent";
8
+ import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
9
9
 
10
10
  import { getSubagentService } from "../execution/subagent-service.ts";
11
11
  import { parseSubagentRpcCommand } from "./command-actions.ts";
@@ -19,7 +19,7 @@
19
19
 
20
20
  import type { Component } from "@earendil-works/pi-tui";
21
21
  import { Container, Text } from "@earendil-works/pi-tui";
22
- import type { AgentToolResult, Theme } from "@mariozechner/pi-coding-agent";
22
+ import type { AgentToolResult, Theme } from "@earendil-works/pi-coding-agent";
23
23
 
24
24
  import type {
25
25
  ListResponse,
@@ -18,9 +18,9 @@
18
18
  import { mkdirSync, writeFileSync } from "node:fs";
19
19
  import { resolve as pathResolve } from "node:path";
20
20
 
21
- import { StringEnum } from "@mariozechner/pi-ai";
22
- import type { ExtensionAPI, ExtensionContext, Theme } from "@mariozechner/pi-coding-agent";
23
- import { Text } from "@mariozechner/pi-tui";
21
+ import { StringEnum } from "@earendil-works/pi-ai";
22
+ import type { ExtensionAPI, ExtensionContext, Theme } from "@earendil-works/pi-coding-agent";
23
+ import { Text } from "@earendil-works/pi-tui";
24
24
  import { type Static, Type } from "typebox";
25
25
 
26
26
  import {
@@ -17,9 +17,9 @@
17
17
  * 参考:domain-models.md §FR-5(tool 收口 4→2)。
18
18
  */
19
19
 
20
- import { StringEnum } from "@mariozechner/pi-ai";
21
- import type { ExtensionAPI, ExtensionContext, Theme } from "@mariozechner/pi-coding-agent";
22
- import { Text } from "@mariozechner/pi-tui";
20
+ import { StringEnum } from "@earendil-works/pi-ai";
21
+ import type { ExtensionAPI, ExtensionContext, Theme } from "@earendil-works/pi-coding-agent";
22
+ import { Text } from "@earendil-works/pi-tui";
23
23
  import {
24
24
  guiComponent,
25
25
  type GuiContext,
@@ -26,8 +26,8 @@ import { promises as fsPromises } from "node:fs";
26
26
  import { homedir } from "node:os";
27
27
  import { join as pathJoin } from "node:path";
28
28
 
29
- import type { ExtensionContext } from "@mariozechner/pi-coding-agent";
30
- import { Key, matchesKey } from "@mariozechner/pi-tui";
29
+ import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
30
+ import { Key, matchesKey } from "@earendil-works/pi-tui";
31
31
 
32
32
  import {
33
33
  getAllToolCalls,
@@ -10,7 +10,7 @@
10
10
  * 避免两者发散(对齐 subagents buildDetailContent / detailContentLength)。
11
11
  */
12
12
 
13
- import { Key, matchesKey } from "@mariozechner/pi-tui";
13
+ import { Key, matchesKey } from "@earendil-works/pi-tui";
14
14
 
15
15
  import { getAllToolCalls, projectLiveProgress } from "../../execution/execution-record.ts";
16
16
  import type { AgentEventLogEntry } from "../../execution/types.ts";
@@ -5,7 +5,7 @@
5
5
  * All functions are pure: no Pi runtime, no side effects.
6
6
  */
7
7
 
8
- import { truncateToWidth, visibleWidth } from "@mariozechner/pi-tui";
8
+ import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
9
9
 
10
10
  import type { AgentEventLogEntry } from "../../execution/types.ts";
11
11
  import type { ExecutionTraceNode, ToolCallEntry } from "../../orchestration/models/types.ts";
@@ -14,7 +14,7 @@ import { resolve } from "node:path";
14
14
  import type { WorkflowMeta, WorkflowSource } from "./models/workflow-script.ts";
15
15
  export type { WorkflowMeta, WorkflowSource };
16
16
 
17
- import { getAgentDir } from "@mariozechner/pi-coding-agent";
17
+ import { getAgentDir } from "@earendil-works/pi-coding-agent";
18
18
 
19
19
  import {
20
20
  discoverResources,
@@ -6,7 +6,7 @@
6
6
  * 职责:持久化 WorkflowRun 聚合根到 JSONL 文件 + 跨 session 重水合。
7
7
  *
8
8
  * 层归属:Infra(D-12)。implements Engine 层的 RunStore port。
9
- * 依赖 @mariozechner/pi-coding-agent 的 ExtensionAPI/ExtensionContext(Infra 允许 Pi SDK)。
9
+ * 依赖 @earendil-works/pi-coding-agent 的 ExtensionAPI/ExtensionContext(Infra 允许 Pi SDK)。
10
10
  *
11
11
  * 设计:
12
12
  * - JsonlRunStore implements RunStore(而非散落的 persist/reconstruct 自由函数)。
@@ -26,7 +26,7 @@
26
26
  import * as fs from "node:fs";
27
27
  import * as path from "node:path";
28
28
 
29
- import type { ExtensionAPI, ExtensionContext } from "@mariozechner/pi-coding-agent";
29
+ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
30
30
 
31
31
  import { AgentCall } from "./models/agent-call.ts";
32
32
  import { Budget } from "./models/budget.ts";