@zhushanwen/pi-agent-ext 1.1.1 → 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,7 +1,7 @@
1
1
  {
2
2
  "name": "@zhushanwen/pi-agent-ext",
3
- "version": "1.1.1",
4
- "description": "xyz-agent extension for Pi — session tree navigation and internal reload command",
3
+ "version": "1.2.0",
4
+ "description": "xyz-agent extension for Pi — internal host commands for extension reload and system prompt fetch",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
7
7
  "xyz-agent": {
@@ -16,7 +16,6 @@
16
16
  "pi-package",
17
17
  "extension",
18
18
  "agent",
19
- "navigate",
20
19
  "reload"
21
20
  ],
22
21
  "license": "MIT",
@@ -25,7 +24,7 @@
25
24
  "index.ts"
26
25
  ],
27
26
  "peerDependencies": {
28
- "@earendil-works/pi-coding-agent": "^0.84.1"
27
+ "@earendil-works/pi-coding-agent": "^0.84.4"
29
28
  },
30
29
  "devDependencies": {
31
30
  "@types/node": "^24.0.0",
@@ -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 / navigateTree / getSystemPrompt),
6
+ * - ctx 只需 index.ts 实际消费的字段(reload / 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 行为:
11
+ * 锚定两命令注册面 + handler 行为:
12
12
  * - __xyz_reload__(host 触发的 skill/extension 重载内部命令)→ ctx.reload()
13
- * - xyz-navigate(session tree 导航)→ 空 entryId 早退;有效 entryId →
14
- * ctx.navigateTree(entryId, { summarize: false })
15
13
  * - __xyz_get_system_prompt__(Trace 视图「现取当前值」通道)→ pi.appendEntry
16
14
  * 写 xyz:current-system-prompt custom entry(fullText/charCount/fetchedAt 形状)
17
15
  *
16
+ * [HISTORICAL] xyz-navigate(session tree 导航)命令及其测试随命令删除一并移除
17
+ * (2026-08-31,桥接对端 runtime 消费端已在 monorepo 时代删除)。
18
+ *
18
19
  * 运行:cd extensions/taiji/agent-ext && npx vitest run
19
20
  */
20
21
  import { describe, it, expect, vi } from "vitest";
@@ -62,23 +63,20 @@ function createWiringHarness(): WiringHarness {
62
63
  return { pi, commands, entries };
63
64
  }
64
65
 
65
- /** ctx 假体(index.ts 实际消费:reload / navigateTree / getSystemPrompt;vi.fn 捕获调用)。 */
66
+ /** ctx 假体(index.ts 实际消费:reload / getSystemPrompt;vi.fn 捕获调用)。 */
66
67
  function createCtx(prompt = "current system prompt"): {
67
68
  ctx: ExtensionCommandContext;
68
69
  reload: ReturnType<typeof vi.fn>;
69
- navigateTree: ReturnType<typeof vi.fn>;
70
70
  getSystemPrompt: ReturnType<typeof vi.fn>;
71
71
  } {
72
72
  const reload = vi.fn();
73
- const navigateTree = vi.fn();
74
73
  const getSystemPrompt = vi.fn(() => prompt);
75
74
  const ctx = {
76
75
  cwd: "/home/user/project",
77
76
  reload,
78
- navigateTree,
79
77
  getSystemPrompt,
80
78
  } as unknown as ExtensionCommandContext;
81
- return { ctx, reload, navigateTree, getSystemPrompt };
79
+ return { ctx, reload, getSystemPrompt };
82
80
  }
83
81
 
84
82
  /** 以 SDK 双参契约 (args, ctx) 驱动已注册命令 handler。 */
@@ -100,14 +98,13 @@ async function loadExtension(): Promise<(pi: ExtensionAPI) => void> {
100
98
  }
101
99
 
102
100
  describe("index.ts wiring SDK 契约", () => {
103
- it("注册恰好三个命令(__xyz_reload__ / xyz-navigate / __xyz_get_system_prompt__),各带非空 description", async () => {
101
+ it("注册恰好两个命令(__xyz_reload__ / __xyz_get_system_prompt__),各带非空 description", async () => {
104
102
  const ext = await loadExtension();
105
103
  const h = createWiringHarness();
106
104
  ext(h.pi);
107
105
  expect([...h.commands.keys()].sort()).toEqual([
108
106
  "__xyz_get_system_prompt__",
109
107
  "__xyz_reload__",
110
- "xyz-navigate",
111
108
  ]);
112
109
  for (const def of h.commands.values()) {
113
110
  expect(typeof def.description).toBe("string");
@@ -126,26 +123,6 @@ describe("index.ts wiring SDK 契约", () => {
126
123
  expect(reload).toHaveBeenCalledWith();
127
124
  });
128
125
 
129
- it("xyz-navigate 空 entryId(空串/纯空白)→ 早退,不调 ctx.navigateTree", async () => {
130
- const ext = await loadExtension();
131
- const h = createWiringHarness();
132
- ext(h.pi);
133
- const { ctx, navigateTree } = createCtx();
134
- await runCommand(h, "xyz-navigate", "", ctx);
135
- await runCommand(h, "xyz-navigate", " ", ctx);
136
- expect(navigateTree).not.toHaveBeenCalled();
137
- });
138
-
139
- it("xyz-navigate 有效 entryId → ctx.navigateTree(entryId, { summarize: false })(args 去首尾空白)", async () => {
140
- const ext = await loadExtension();
141
- const h = createWiringHarness();
142
- ext(h.pi);
143
- const { ctx, navigateTree } = createCtx();
144
- await runCommand(h, "xyz-navigate", " 0198f-entry-1 ", ctx);
145
- expect(navigateTree).toHaveBeenCalledTimes(1);
146
- expect(navigateTree).toHaveBeenCalledWith("0198f-entry-1", { summarize: false });
147
- });
148
-
149
126
  it("__xyz_get_system_prompt__ → appendEntry 写 xyz:current-system-prompt(fullText/charCount/fetchedAt 形状,不写其他 customType)", async () => {
150
127
  const ext = await loadExtension();
151
128
  const h = createWiringHarness();
package/src/index.ts CHANGED
@@ -1,12 +1,14 @@
1
1
  /**
2
- * xyz-agent extension for Pi — session tree navigation.
2
+ * xyz-agent extension for Pi — internal commands for the host.
3
3
  *
4
- * Registers the `/xyz-navigate` command. The command handler calls
5
- * `ctx.navigateTree()` to move the session leaf.
6
- *
7
- * Also registers `/__xyz_reload__` internal command for host-triggered
4
+ * Registers `/__xyz_reload__` internal command for host-triggered
8
5
  * skill/extension reload, and `/__xyz_get_system_prompt__` for the Trace
9
6
  * view fetch-current button.
7
+ *
8
+ * [HISTORICAL] The former `/xyz-navigate` session tree command was removed
9
+ * (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.
10
12
  */
11
13
 
12
14
  import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
@@ -22,16 +24,6 @@ export default function (pi: ExtensionAPI): void {
22
24
  },
23
25
  });
24
26
 
25
- pi.registerCommand("xyz-navigate", {
26
- description: "Navigate the session tree to a specified entry",
27
- handler: async (args: string, ctx: ExtensionCommandContext) => {
28
- const entryId = args.trim();
29
- if (!entryId) return;
30
-
31
- await ctx.navigateTree(entryId, { summarize: false });
32
- },
33
- });
34
-
35
27
  // [fetch-current-system-prompt] Trace 视图「现取当前值」通道(session-trace design §3.1
36
28
  // 失败路径 / D2):pi RPC 无 get_system_prompt 命令、getSystemPrompt() 只在 extension
37
29
  // API,且现取不能依赖可禁的留痕包(system-prompt-trace 是 feature tier)——挂本