@zhushanwen/pi-agent-ext 1.0.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/index.ts +1 -0
- package/package.json +35 -0
- package/src/__tests__/agent-ext.test.ts +7 -0
- package/src/index.ts +33 -0
package/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./src/index.ts";
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zhushanwen/pi-agent-ext",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "xyz-agent extension for Pi — session tree navigation and internal reload command",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"pi": {
|
|
8
|
+
"extensions": [
|
|
9
|
+
"./index.ts"
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"pi-package",
|
|
14
|
+
"extension",
|
|
15
|
+
"agent",
|
|
16
|
+
"navigate",
|
|
17
|
+
"reload"
|
|
18
|
+
],
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"files": [
|
|
21
|
+
"src/",
|
|
22
|
+
"index.ts"
|
|
23
|
+
],
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"@earendil-works/pi-coding-agent": "*"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^24.0.0",
|
|
29
|
+
"vitest": "^4.1.8"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"typecheck": "npx tsc --noEmit",
|
|
33
|
+
"test": "vitest run"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* xyz-agent extension for Pi — session tree navigation.
|
|
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
|
|
8
|
+
* skill/extension reload.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
12
|
+
|
|
13
|
+
export default function (pi: ExtensionAPI): void {
|
|
14
|
+
// W5: builtin internal reload command. `/__xyz_reload__` 由 host 在 skill 文件变动时
|
|
15
|
+
// 经 client.prompt 发起(不经 LLM),handler 调 pi ctx.reload() 重扫 skill + 重建 runtime。
|
|
16
|
+
// 双下划线前缀 = 内部命令(前端 W4 internal-command-filter 过滤 `/__` 前缀不显示)。
|
|
17
|
+
pi.registerCommand('__xyz_reload__', {
|
|
18
|
+
description: 'Internal: reload skills/extensions/prompts (triggered by host on skill file change)',
|
|
19
|
+
handler: async (_args: string, ctx: ExtensionCommandContext) => {
|
|
20
|
+
await ctx.reload();
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
pi.registerCommand("xyz-navigate", {
|
|
25
|
+
description: "Navigate the session tree to a specified entry",
|
|
26
|
+
handler: async (args: string, ctx: ExtensionCommandContext) => {
|
|
27
|
+
const entryId = args.trim();
|
|
28
|
+
if (!entryId) return;
|
|
29
|
+
|
|
30
|
+
await ctx.navigateTree(entryId, { summarize: false });
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
}
|