@zhushanwen/pi-agent-ext 1.2.1 → 1.3.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,10 +1,10 @@
1
1
  {
2
2
  "name": "@zhushanwen/pi-agent-ext",
3
- "version": "1.2.1",
4
- "description": "xyz-agent extension for Pi — internal host commands for extension reload and system prompt fetch",
3
+ "version": "1.3.0",
4
+ "description": "taiji extension for Pi — internal host commands for extension reload and system prompt fetch",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
7
- "xyz-agent": {
7
+ "taiji": {
8
8
  "role": "taiji"
9
9
  },
10
10
  "pi": {
@@ -3,18 +3,19 @@
3
3
  *
4
4
  * 复用 system-prompt-trace index-wiring.test.ts 的 Proxy 假体模式:
5
5
  * - pi 用 Proxy 假体:捕获 registerCommand 注册的命令定义 + appendEntry 落点
6
- * - ctx 只需 index.ts 实际消费的字段(reload / getSystemPrompt),
6
+ * - ctx 只需 index.ts 实际消费的字段(getSystemPrompt),
7
7
  * 以 ExtensionCommandContext 最小形状驱动 handler(SDK 双参契约 (args, ctx))
8
8
  * - index.ts 对 @earendil-works/pi-coding-agent 是 type-only import(运行时擦除),
9
9
  * 无需 vi.mock SDK 模块
10
10
  *
11
- * 锚定两命令注册面 + handler 行为:
12
- * - __xyz_reload__(host 触发的 skill/extension 重载内部命令)→ ctx.reload()
13
- * - __xyz_get_system_prompt__(Trace 视图「现取当前值」通道)→ pi.appendEntry
14
- * 写 xyz:current-system-prompt custom entry(fullText/charCount/fetchedAt 形状)
11
+ * 锚定命令注册面 + handler 行为:
12
+ * - __taiji_get_system_prompt__(Trace 视图「现取当前值」通道)→ pi.appendEntry
13
+ * 写 taiji:current-system-prompt custom entry(fullText/charCount/fetchedAt 形状)
15
14
  *
16
- * [HISTORICAL] xyz-navigate(session tree 导航)命令及其测试随命令删除一并移除
15
+ * [HISTORICAL] session tree 导航命令(旧品牌时期命名)及其测试随命令删除一并移除
17
16
  * (2026-08-31,桥接对端 runtime 消费端已在 monorepo 时代删除)。
17
+ * [HISTORICAL] __taiji_reload__ 及其测试随 W5 skill 变更→pi reload 编排退役一并移除
18
+ * (2026-09-25,消费端已 D7 切源 taiji SkillRegistry,pi 侧列表滞后归 ADR-0050 降级)。
18
19
  *
19
20
  * 运行:cd extensions/taiji/agent-ext && npx vitest run
20
21
  */
@@ -63,20 +64,17 @@ function createWiringHarness(): WiringHarness {
63
64
  return { pi, commands, entries };
64
65
  }
65
66
 
66
- /** ctx 假体(index.ts 实际消费:reload / getSystemPrompt;vi.fn 捕获调用)。 */
67
+ /** ctx 假体(index.ts 实际消费:getSystemPrompt;vi.fn 捕获调用)。 */
67
68
  function createCtx(prompt = "current system prompt"): {
68
69
  ctx: ExtensionCommandContext;
69
- reload: ReturnType<typeof vi.fn>;
70
70
  getSystemPrompt: ReturnType<typeof vi.fn>;
71
71
  } {
72
- const reload = vi.fn();
73
72
  const getSystemPrompt = vi.fn(() => prompt);
74
73
  const ctx = {
75
74
  cwd: "/home/user/project",
76
- reload,
77
75
  getSystemPrompt,
78
76
  } as unknown as ExtensionCommandContext;
79
- return { ctx, reload, getSystemPrompt };
77
+ return { ctx, getSystemPrompt };
80
78
  }
81
79
 
82
80
  /** 以 SDK 双参契约 (args, ctx) 驱动已注册命令 handler。 */
@@ -98,14 +96,11 @@ async function loadExtension(): Promise<(pi: ExtensionAPI) => void> {
98
96
  }
99
97
 
100
98
  describe("index.ts wiring SDK 契约", () => {
101
- it("注册恰好两个命令(__xyz_reload__ / __xyz_get_system_prompt__),各带非空 description", async () => {
99
+ it("注册恰好一个命令(__taiji_get_system_prompt__),带非空 description", async () => {
102
100
  const ext = await loadExtension();
103
101
  const h = createWiringHarness();
104
102
  ext(h.pi);
105
- expect([...h.commands.keys()].sort()).toEqual([
106
- "__xyz_get_system_prompt__",
107
- "__xyz_reload__",
108
- ]);
103
+ expect([...h.commands.keys()]).toEqual(["__taiji_get_system_prompt__"]);
109
104
  for (const def of h.commands.values()) {
110
105
  expect(typeof def.description).toBe("string");
111
106
  expect(def.description.length).toBeGreaterThan(0);
@@ -113,27 +108,17 @@ describe("index.ts wiring SDK 契约", () => {
113
108
  }
114
109
  });
115
110
 
116
- it("__xyz_reload__ handler → 调 ctx.reload()(host 触发的 skill/extension 重载,无参)", async () => {
117
- const ext = await loadExtension();
118
- const h = createWiringHarness();
119
- ext(h.pi);
120
- const { ctx, reload } = createCtx();
121
- await runCommand(h, "__xyz_reload__", "", ctx);
122
- expect(reload).toHaveBeenCalledTimes(1);
123
- expect(reload).toHaveBeenCalledWith();
124
- });
125
-
126
- it("__xyz_get_system_prompt__ → appendEntry 写 xyz:current-system-prompt(fullText/charCount/fetchedAt 形状,不写其他 customType)", async () => {
111
+ it("__taiji_get_system_prompt__ → appendEntry 写 taiji:current-system-prompt(fullText/charCount/fetchedAt 形状,不写其他 customType)", async () => {
127
112
  const ext = await loadExtension();
128
113
  const h = createWiringHarness();
129
114
  ext(h.pi);
130
115
  const prompt = "prompt body\nline-1";
131
116
  const { ctx, getSystemPrompt } = createCtx(prompt);
132
- await runCommand(h, "__xyz_get_system_prompt__", "", ctx);
117
+ await runCommand(h, "__taiji_get_system_prompt__", "", ctx);
133
118
 
134
119
  expect(getSystemPrompt).toHaveBeenCalledTimes(1);
135
120
  expect(h.entries).toHaveLength(1);
136
- expect(h.entries[0]?.customType).toBe("xyz:current-system-prompt");
121
+ expect(h.entries[0]?.customType).toBe("taiji:current-system-prompt");
137
122
  const data = h.entries[0]?.data as Record<string, unknown>;
138
123
  expect(data.fullText).toBe(prompt);
139
124
  expect(data.charCount).toBe(prompt.length);
package/src/index.ts CHANGED
@@ -1,45 +1,40 @@
1
1
  /**
2
- * xyz-agent extension for Pi — internal commands for the host.
2
+ * taiji extension for Pi — internal commands for the host.
3
3
  *
4
- * Registers `/__xyz_reload__` internal command for host-triggered
5
- * skill/extension reload, and `/__xyz_get_system_prompt__` for the Trace
4
+ * Registers `/__taiji_get_system_prompt__` for the Trace
6
5
  * view fetch-current button.
7
6
  *
8
- * [HISTORICAL] The former `/xyz-navigate` session tree command was removed
7
+ * [HISTORICAL] The former session tree navigation command was removed
9
8
  * (2026-08-31): its bridge consumer on the runtime side was deleted in the
10
- * monorepo era, so the command had no reachable caller. See
11
- * docs/adr/0008-extension-bridge-for-navigate-tree.md for the original design.
9
+ * monorepo era, so the command had no reachable caller. See the ADR-0008
10
+ * note in the retired-decisions genealogy of docs/adr/decisions.md for the
11
+ * original design.
12
+ * [HISTORICAL] `/__taiji_reload__` was removed (2026-09-25): the W5
13
+ * skill-change→pi-reload orchestration was retired — slash menu and composer
14
+ * injection resolve skills from the taiji SkillRegistry (D7 source switch),
15
+ * so a full pi reload (extension ctx invalidate + clearExtensionCache, which
16
+ * broke background-task completion notifications in the stale module world)
17
+ * bought nothing but stale-pi-side lists, accepted per ADR-0050 degradation.
12
18
  */
13
19
 
14
20
  import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
15
21
 
16
22
  export default function (pi: ExtensionAPI): void {
17
- // W5: builtin internal reload command. `/__xyz_reload__` 由 host 在 skill 文件变动时
18
- // 经 client.prompt 发起(不经 LLM),handler 调 pi ctx.reload() 重扫 skill + 重建 runtime。
19
- // 双下划线前缀 = 内部命令(前端 W4 internal-command-filter 过滤 `/__` 前缀不显示)。
20
- pi.registerCommand('__xyz_reload__', {
21
- description: 'Internal: reload skills/extensions/prompts (triggered by host on skill file change)',
22
- handler: async (_args: string, ctx: ExtensionCommandContext) => {
23
- await ctx.reload();
24
- },
25
- });
26
-
27
23
  // [fetch-current-system-prompt] Trace 视图「现取当前值」通道(session-trace design §3.1
28
24
  // 失败路径 / D2):pi RPC 无 get_system_prompt 命令、getSystemPrompt() 只在 extension
29
25
  // API,且现取不能依赖可禁的留痕包(system-prompt-trace 是 feature tier)——挂本
30
- // infrastructure 包(builtin 不可禁,原根目录 xyz-agent-extension.js 常驻文件随 main
31
- // 的 agent-ext 包化迁移至此)。host 经 client.prompt 发 /__xyz_get_system_prompt__
26
+ // infrastructure 包(builtin 不可禁)。host 经 client.prompt 发 /__taiji_get_system_prompt__
32
27
  // (双下划线 = 内部命令,前端过滤 /__ 前缀不显示),handler 取当前 system prompt 写
33
- // xyz:current-system-prompt custom entry(不进 LLM context,零模型侧影响——pi
28
+ // taiji:current-system-prompt custom entry(不进 LLM context,零模型侧影响——pi
34
29
  // sessionEntryToContextMessages 对 type=custom 落入末尾 return [],session-manager.ts:383-413),
35
30
  // runtime 轮询 get_entries(since) 拉到后返回前端(同条 entry 也会作为 DATA 行出现在 trace
36
31
  // 台账里,留下取值痕迹)。
37
- pi.registerCommand("__xyz_get_system_prompt__", {
32
+ pi.registerCommand("__taiji_get_system_prompt__", {
38
33
  description:
39
34
  "Internal: append a custom entry with the current system prompt (host-initiated for the Trace view fetch-current button)",
40
35
  handler: async (_args: string, ctx: ExtensionCommandContext) => {
41
36
  const fullText = ctx.getSystemPrompt();
42
- pi.appendEntry("xyz:current-system-prompt", {
37
+ pi.appendEntry("taiji:current-system-prompt", {
43
38
  fullText,
44
39
  charCount: fullText.length,
45
40
  fetchedAt: new Date().toISOString(),