@zhushanwen/pi-agent-ext 1.2.0 → 1.2.2

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.0",
4
- "description": "xyz-agent extension for Pi — internal host commands for extension reload and system prompt fetch",
3
+ "version": "1.2.2",
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": {
@@ -9,11 +9,11 @@
9
9
  * 无需 vi.mock SDK 模块
10
10
  *
11
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 形状)
12
+ * - __taiji_reload__(host 触发的 skill/extension 重载内部命令)→ ctx.reload()
13
+ * - __taiji_get_system_prompt__(Trace 视图「现取当前值」通道)→ pi.appendEntry
14
+ * 写 taiji:current-system-prompt custom entry(fullText/charCount/fetchedAt 形状)
15
15
  *
16
- * [HISTORICAL] xyz-navigate(session tree 导航)命令及其测试随命令删除一并移除
16
+ * [HISTORICAL] session tree 导航命令(旧品牌时期命名)及其测试随命令删除一并移除
17
17
  * (2026-08-31,桥接对端 runtime 消费端已在 monorepo 时代删除)。
18
18
  *
19
19
  * 运行:cd extensions/taiji/agent-ext && npx vitest run
@@ -98,13 +98,13 @@ async function loadExtension(): Promise<(pi: ExtensionAPI) => void> {
98
98
  }
99
99
 
100
100
  describe("index.ts wiring SDK 契约", () => {
101
- it("注册恰好两个命令(__xyz_reload__ / __xyz_get_system_prompt__),各带非空 description", async () => {
101
+ it("注册恰好两个命令(__taiji_reload__ / __taiji_get_system_prompt__),各带非空 description", async () => {
102
102
  const ext = await loadExtension();
103
103
  const h = createWiringHarness();
104
104
  ext(h.pi);
105
105
  expect([...h.commands.keys()].sort()).toEqual([
106
- "__xyz_get_system_prompt__",
107
- "__xyz_reload__",
106
+ "__taiji_get_system_prompt__",
107
+ "__taiji_reload__",
108
108
  ]);
109
109
  for (const def of h.commands.values()) {
110
110
  expect(typeof def.description).toBe("string");
@@ -113,27 +113,27 @@ describe("index.ts wiring SDK 契约", () => {
113
113
  }
114
114
  });
115
115
 
116
- it("__xyz_reload__ handler → 调 ctx.reload()(host 触发的 skill/extension 重载,无参)", async () => {
116
+ it("__taiji_reload__ handler → 调 ctx.reload()(host 触发的 skill/extension 重载,无参)", async () => {
117
117
  const ext = await loadExtension();
118
118
  const h = createWiringHarness();
119
119
  ext(h.pi);
120
120
  const { ctx, reload } = createCtx();
121
- await runCommand(h, "__xyz_reload__", "", ctx);
121
+ await runCommand(h, "__taiji_reload__", "", ctx);
122
122
  expect(reload).toHaveBeenCalledTimes(1);
123
123
  expect(reload).toHaveBeenCalledWith();
124
124
  });
125
125
 
126
- it("__xyz_get_system_prompt__ → appendEntry 写 xyz:current-system-prompt(fullText/charCount/fetchedAt 形状,不写其他 customType)", async () => {
126
+ it("__taiji_get_system_prompt__ → appendEntry 写 taiji:current-system-prompt(fullText/charCount/fetchedAt 形状,不写其他 customType)", async () => {
127
127
  const ext = await loadExtension();
128
128
  const h = createWiringHarness();
129
129
  ext(h.pi);
130
130
  const prompt = "prompt body\nline-1";
131
131
  const { ctx, getSystemPrompt } = createCtx(prompt);
132
- await runCommand(h, "__xyz_get_system_prompt__", "", ctx);
132
+ await runCommand(h, "__taiji_get_system_prompt__", "", ctx);
133
133
 
134
134
  expect(getSystemPrompt).toHaveBeenCalledTimes(1);
135
135
  expect(h.entries).toHaveLength(1);
136
- expect(h.entries[0]?.customType).toBe("xyz:current-system-prompt");
136
+ expect(h.entries[0]?.customType).toBe("taiji:current-system-prompt");
137
137
  const data = h.entries[0]?.data as Record<string, unknown>;
138
138
  expect(data.fullText).toBe(prompt);
139
139
  expect(data.charCount).toBe(prompt.length);
package/src/index.ts CHANGED
@@ -1,23 +1,24 @@
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_reload__` internal command for host-triggered
5
+ * skill/extension reload, and `/__taiji_get_system_prompt__` for the Trace
6
6
  * view fetch-current button.
7
7
  *
8
- * [HISTORICAL] The former `/xyz-navigate` session tree command was removed
8
+ * [HISTORICAL] The former session tree navigation command was removed
9
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
+ * monorepo era, so the command had no reachable caller. See the ADR-0008
11
+ * note in the retired-decisions genealogy of docs/adr/decisions.md for the
12
+ * original design.
12
13
  */
13
14
 
14
15
  import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
15
16
 
16
17
  export default function (pi: ExtensionAPI): void {
17
- // W5: builtin internal reload command. `/__xyz_reload__` 由 host 在 skill 文件变动时
18
+ // W5: builtin internal reload command. `/__taiji_reload__` 由 host 在 skill 文件变动时
18
19
  // 经 client.prompt 发起(不经 LLM),handler 调 pi ctx.reload() 重扫 skill + 重建 runtime。
19
20
  // 双下划线前缀 = 内部命令(前端 W4 internal-command-filter 过滤 `/__` 前缀不显示)。
20
- pi.registerCommand('__xyz_reload__', {
21
+ pi.registerCommand('__taiji_reload__', {
21
22
  description: 'Internal: reload skills/extensions/prompts (triggered by host on skill file change)',
22
23
  handler: async (_args: string, ctx: ExtensionCommandContext) => {
23
24
  await ctx.reload();
@@ -27,19 +28,18 @@ export default function (pi: ExtensionAPI): void {
27
28
  // [fetch-current-system-prompt] Trace 视图「现取当前值」通道(session-trace design §3.1
28
29
  // 失败路径 / D2):pi RPC 无 get_system_prompt 命令、getSystemPrompt() 只在 extension
29
30
  // API,且现取不能依赖可禁的留痕包(system-prompt-trace 是 feature tier)——挂本
30
- // infrastructure 包(builtin 不可禁,原根目录 xyz-agent-extension.js 常驻文件随 main
31
- // 的 agent-ext 包化迁移至此)。host 经 client.prompt 发 /__xyz_get_system_prompt__
31
+ // infrastructure 包(builtin 不可禁)。host 经 client.prompt /__taiji_get_system_prompt__
32
32
  // (双下划线 = 内部命令,前端过滤 /__ 前缀不显示),handler 取当前 system prompt 写
33
- // xyz:current-system-prompt custom entry(不进 LLM context,零模型侧影响——pi
33
+ // taiji:current-system-prompt custom entry(不进 LLM context,零模型侧影响——pi
34
34
  // sessionEntryToContextMessages 对 type=custom 落入末尾 return [],session-manager.ts:383-413),
35
35
  // runtime 轮询 get_entries(since) 拉到后返回前端(同条 entry 也会作为 DATA 行出现在 trace
36
36
  // 台账里,留下取值痕迹)。
37
- pi.registerCommand("__xyz_get_system_prompt__", {
37
+ pi.registerCommand("__taiji_get_system_prompt__", {
38
38
  description:
39
39
  "Internal: append a custom entry with the current system prompt (host-initiated for the Trace view fetch-current button)",
40
40
  handler: async (_args: string, ctx: ExtensionCommandContext) => {
41
41
  const fullText = ctx.getSystemPrompt();
42
- pi.appendEntry("xyz:current-system-prompt", {
42
+ pi.appendEntry("taiji:current-system-prompt", {
43
43
  fullText,
44
44
  charCount: fullText.length,
45
45
  fetchedAt: new Date().toISOString(),