@aliou/pi-dev-kit 0.6.5 → 0.7.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/README.md +2 -2
- package/package.json +11 -10
- package/src/commands/index.ts +5 -1
- package/src/commands/update.ts +139 -91
- package/src/skills/pi-extension/SKILL.md +108 -137
- package/src/skills/pi-extension/references/additional-apis.md +252 -208
- package/src/skills/pi-extension/references/commands.md +113 -33
- package/src/skills/pi-extension/references/components.md +267 -102
- package/src/skills/pi-extension/references/hooks.md +229 -156
- package/src/skills/pi-extension/references/messages.md +94 -106
- package/src/skills/pi-extension/references/modes.md +80 -90
- package/src/skills/pi-extension/references/providers.md +255 -96
- package/src/skills/pi-extension/references/publish.md +76 -62
- package/src/skills/pi-extension/references/state.md +80 -33
- package/src/skills/pi-extension/references/structure.md +126 -269
- package/src/skills/pi-extension/references/testing.md +1 -1
- package/src/skills/pi-extension/references/tools.md +198 -823
- package/src/tools/changelog-tool.ts +15 -3
- package/src/tools/docs-tool.ts +3 -3
- package/src/tools/index.ts +5 -1
- package/src/tools/package-manager-tool.ts +8 -4
- package/src/tools/utils.ts +33 -23
- package/src/tools/version-tool.ts +8 -4
- package/src/index.ts +0 -8
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ Returns the version of the currently running Pi instance.
|
|
|
51
51
|
|
|
52
52
|
### `pi_docs`
|
|
53
53
|
|
|
54
|
-
Lists
|
|
54
|
+
Lists Pi markdown documentation files from the Pi installation: `README.md`, `docs/`, and `examples/`.
|
|
55
55
|
|
|
56
56
|
### `pi_changelog`
|
|
57
57
|
|
|
@@ -59,4 +59,4 @@ Parses the Pi changelog and returns entries for a specific version (or the lates
|
|
|
59
59
|
|
|
60
60
|
## Compatibility
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
Tested against Pi 0.74.0 and the `@earendil-works/*` Pi package namespace.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aliou/pi-dev-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
},
|
|
18
18
|
"pi": {
|
|
19
19
|
"extensions": [
|
|
20
|
-
"./src/index.ts"
|
|
20
|
+
"./src/tools/index.ts",
|
|
21
|
+
"./src/commands/index.ts"
|
|
21
22
|
],
|
|
22
23
|
"skills": [
|
|
23
24
|
"./src/skills"
|
|
@@ -35,28 +36,28 @@
|
|
|
35
36
|
"README.md"
|
|
36
37
|
],
|
|
37
38
|
"dependencies": {
|
|
38
|
-
"@aliou/pi-utils-ui": "^0.
|
|
39
|
+
"@aliou/pi-utils-ui": "^0.4.0"
|
|
39
40
|
},
|
|
40
41
|
"peerDependencies": {
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"typebox": "
|
|
42
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
43
|
+
"@earendil-works/pi-tui": "*",
|
|
44
|
+
"typebox": "*"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@biomejs/biome": "^2.3.13",
|
|
47
48
|
"@changesets/cli": "^2.27.11",
|
|
48
|
-
"@
|
|
49
|
-
"@
|
|
49
|
+
"@earendil-works/pi-coding-agent": "0.74.0",
|
|
50
|
+
"@earendil-works/pi-tui": "0.74.0",
|
|
50
51
|
"typebox": "1.1.24",
|
|
51
52
|
"@types/node": "^25.0.10",
|
|
52
53
|
"husky": "^9.1.7",
|
|
53
54
|
"typescript": "^5.9.3"
|
|
54
55
|
},
|
|
55
56
|
"peerDependenciesMeta": {
|
|
56
|
-
"@
|
|
57
|
+
"@earendil-works/pi-coding-agent": {
|
|
57
58
|
"optional": true
|
|
58
59
|
},
|
|
59
|
-
"@
|
|
60
|
+
"@earendil-works/pi-tui": {
|
|
60
61
|
"optional": true
|
|
61
62
|
},
|
|
62
63
|
"typebox": {
|
package/src/commands/index.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import type { ExtensionAPI } from "@
|
|
1
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { registerUpdateCommand } from "./update";
|
|
3
3
|
|
|
4
4
|
export function registerCommands(pi: ExtensionAPI) {
|
|
5
5
|
registerUpdateCommand(pi);
|
|
6
6
|
}
|
|
7
|
+
|
|
8
|
+
export default function commandsExtension(pi: ExtensionAPI) {
|
|
9
|
+
registerCommands(pi);
|
|
10
|
+
}
|
package/src/commands/update.ts
CHANGED
|
@@ -1,102 +1,150 @@
|
|
|
1
|
-
import type { ExtensionAPI } from "@
|
|
2
|
-
import { VERSION } from "@
|
|
1
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { VERSION } from "@earendil-works/pi-coding-agent";
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
"https://registry.npmjs.org/@
|
|
4
|
+
const NPM_REGISTRY_URLS = [
|
|
5
|
+
"https://registry.npmjs.org/@earendil-works/pi-coding-agent/latest",
|
|
6
|
+
"https://registry.npmjs.org/@mariozechner/pi-coding-agent/latest",
|
|
7
|
+
] as const;
|
|
6
8
|
|
|
7
9
|
async function fetchLatestVersion(): Promise<string | null> {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
for (const url of NPM_REGISTRY_URLS) {
|
|
11
|
+
try {
|
|
12
|
+
const res = await fetch(url);
|
|
13
|
+
if (!res.ok) continue;
|
|
14
|
+
const data = (await res.json()) as { version?: string };
|
|
15
|
+
if (data.version) return data.version;
|
|
16
|
+
} catch {
|
|
17
|
+
// Try the next registry URL.
|
|
18
|
+
}
|
|
15
19
|
}
|
|
20
|
+
return null;
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
const UPDATE_PROMPT = `# Update Pi Extensions
|
|
19
24
|
|
|
20
|
-
Update this project's Pi extensions, themes, and
|
|
21
|
-
|
|
22
|
-
##
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
-
|
|
64
|
-
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
-
|
|
92
|
-
-
|
|
93
|
-
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
-
|
|
98
|
-
-
|
|
99
|
-
-
|
|
25
|
+
Update this project's Pi extensions, themes, skills, prompt templates, and package metadata to the specified target Pi version.
|
|
26
|
+
|
|
27
|
+
## Operating Rules
|
|
28
|
+
|
|
29
|
+
- Keep the update focused on Pi compatibility and current extension best practices.
|
|
30
|
+
- Read the relevant Pi docs before changing code. Follow linked docs when a page points to them.
|
|
31
|
+
- Present a concrete plan and wait for user confirmation before editing files.
|
|
32
|
+
- If a migration is ambiguous or changes public behavior, ask the user instead of guessing.
|
|
33
|
+
- Preserve existing extension behavior unless the target Pi version requires a change.
|
|
34
|
+
|
|
35
|
+
## 1. Detect Package Manager
|
|
36
|
+
|
|
37
|
+
Use \`detect_package_manager\` to identify npm, pnpm, yarn, or bun. Use the detected install and run commands for every later step.
|
|
38
|
+
|
|
39
|
+
## 2. Inspect Package State
|
|
40
|
+
|
|
41
|
+
Read \`./package.json\` and any sub-package \`package.json\` files. Find Pi core packages in all dependency sections, peer dependency metadata, pnpm overrides, imports, docs, and examples.
|
|
42
|
+
|
|
43
|
+
Current Pi core packages are:
|
|
44
|
+
- \`@earendil-works/pi-coding-agent\`
|
|
45
|
+
- \`@earendil-works/pi-agent-core\`
|
|
46
|
+
- \`@earendil-works/pi-ai\`
|
|
47
|
+
- \`@earendil-works/pi-tui\`
|
|
48
|
+
- \`typebox\`
|
|
49
|
+
|
|
50
|
+
Legacy packages under \`@mariozechner/*\` may still be present. Treat them as Pi core packages. Prefer \`@earendil-works/*\` when the target version exists on npm; if the new namespace is not published for the target version yet, keep the legacy namespace and report that decision.
|
|
51
|
+
|
|
52
|
+
For distributed Pi packages:
|
|
53
|
+
- Put imported Pi core packages in \`peerDependencies\` with \`"*"\` and mark each one \`optional: true\` in \`peerDependenciesMeta\`.
|
|
54
|
+
- Keep the same Pi core packages in \`devDependencies\` at the exact target version for local type checking.
|
|
55
|
+
- Keep \`typebox\` 1.x. Do not use \`@sinclair/typebox\` in new code.
|
|
56
|
+
|
|
57
|
+
Report current versions/namespaces vs target before planning code changes. If everything already matches and no code/docs best-practice updates are needed, stop.
|
|
58
|
+
|
|
59
|
+
## 3. Gather Pi Documentation
|
|
60
|
+
|
|
61
|
+
If an update is needed:
|
|
62
|
+
1. Use \`pi_changelog_versions\` and \`pi_changelog\` for every version between the current and target versions.
|
|
63
|
+
2. Use \`pi_docs\` to locate installed Pi docs.
|
|
64
|
+
3. Read relevant docs completely before editing, especially:
|
|
65
|
+
- \`docs/extensions.md\`
|
|
66
|
+
- \`docs/tui.md\` for components and renderers
|
|
67
|
+
- \`docs/packages.md\` for package metadata and peer dependency rules
|
|
68
|
+
- \`docs/custom-provider.md\` and \`docs/models.md\` for providers
|
|
69
|
+
- \`docs/rpc.md\` when UI or mode behavior is touched
|
|
70
|
+
- \`docs/skills.md\` when package skills are touched
|
|
71
|
+
4. Read examples that match the changed area, not just the docs.
|
|
72
|
+
|
|
73
|
+
## 4. Analyze Source and Docs
|
|
74
|
+
|
|
75
|
+
Scan all source, tests, README, skills, prompts, and examples for Pi usage.
|
|
76
|
+
|
|
77
|
+
For tools, verify:
|
|
78
|
+
- Standalone tool objects use \`defineTool({...})\` from Pi so \`execute\`, \`renderCall\`, and \`renderResult\` infer params from \`parameters\`. Do not pass explicit generic arguments to \`defineTool\` and avoid callback parameter annotations unless TypeScript needs help.
|
|
79
|
+
- Define \`type MyToolParams = Static<typeof parameters>\` for helper/action APIs, but prefer inference inside \`defineTool\` callbacks.
|
|
80
|
+
- Every tool has \`label\`. Add \`promptSnippet\` when the tool should appear in Available tools.
|
|
81
|
+
- Every \`promptGuidelines\` bullet names the exact tool, because Pi injects bullets flat into the global Guidelines section. Do not write "this tool".
|
|
82
|
+
- Execute signature is \`(toolCallId, params, signal, onUpdate, ctx)\`; signal comes before \`onUpdate\`.
|
|
83
|
+
- Use \`onUpdate?.(...)\` and forward \`signal\` to \`fetch\`, \`pi.exec\`, SDK clients, and long work.
|
|
84
|
+
- Use \`StringEnum\` from \`@earendil-works/pi-ai\`/legacy \`@mariozechner/pi-ai\` for string enums; avoid \`Type.Union([Type.Literal(...)])\` for model-facing enums.
|
|
85
|
+
- Use \`prepareArguments(args)\` only for backward-compatible schema shims before validation.
|
|
86
|
+
- Use \`executionMode: "sequential"\` for tools whose sibling calls mutate shared in-memory state or otherwise must not run concurrently.
|
|
87
|
+
- File-mutating tools normalize leading \`@\` in paths and wrap the full read-modify-write window in \`withFileMutationQueue()\`.
|
|
88
|
+
- Tools returning large output use \`truncateHead\` or \`truncateTail\`, tell the LLM what was truncated, and write full output to a temp file.
|
|
89
|
+
- Do not use Node \`child_process\` for normal commands; use \`pi.exec(command, args, { signal, cwd, timeout })\`.
|
|
90
|
+
|
|
91
|
+
For rendering and TUI, verify:
|
|
92
|
+
- \`renderCall\` and \`renderResult\` return Pi TUI \`Component\` objects, not raw strings.
|
|
93
|
+
- \`renderResult\` handles \`options.isPartial\` first with a stable tool-scoped message.
|
|
94
|
+
- Tool errors are detected via missing expected fields in \`details\` or the 4th render context \`context.isError\`.
|
|
95
|
+
- Use \`ToolCallHeader\`, \`ToolBody\`, and \`ToolFooter\` consistently. Omit empty footers.
|
|
96
|
+
- Use \`keyHint("app.tools.expand", "to expand")\` for expand hints.
|
|
97
|
+
- Use \`Container\`, \`Text\`, \`Markdown\`, \`SelectList\`, \`SettingsList\`, \`BorderedLoader\`, and \`DynamicBorder\` before writing custom UI.
|
|
98
|
+
- Custom components implement \`render(width): string[]\`, \`handleInput(data)\`, and \`invalidate()\`; use \`matchesKey\` and keep rendered lines within width.
|
|
99
|
+
- \`ctx.ui.custom()\` has RPC/print fallback and interactive close paths use explicit sentinels such as \`null\` or \`"closed"\`, not \`done(undefined)\`.
|
|
100
|
+
|
|
101
|
+
For extension APIs, verify:
|
|
102
|
+
- Hook return shapes match current Pi docs: \`input\` returns \`{ action: "continue" | "transform" | "handled", ... }\`; \`before_agent_start\` returns \`{ systemPrompt }\`; \`tool_result\` returns result patches.
|
|
103
|
+
- Session replacement uses \`withSession\` after \`ctx.newSession()\`, \`ctx.fork()\`, or \`ctx.switchSession()\`; do not reuse captured old \`pi\`, command \`ctx\`, or \`ctx.sessionManager\`.
|
|
104
|
+
- Reload command handlers treat \`await ctx.reload(); return;\` as terminal.
|
|
105
|
+
- Fire-and-forget UI methods do not need \`ctx.hasUI\`; dialog methods that gate behavior do.
|
|
106
|
+
- Providers use current \`pi.registerProvider(name, config)\`, \`name\`, \`authHeader\`, OAuth, per-model \`baseUrl\`, and \`thinkingLevelMap\` when relevant. Dynamic model discovery belongs in an async extension factory, not \`session_start\`.
|
|
107
|
+
- Use SDK helpers for Pi paths instead of \`homedir()\` when helpers exist.
|
|
108
|
+
|
|
109
|
+
For project structure and package docs, verify:
|
|
110
|
+
- Prefer one extension entry point per feature directory: \`src/tools/index.ts\`, \`src/commands/index.ts\`, \`src/hooks/index.ts\`, \`src/providers/index.ts\`.
|
|
111
|
+
- Avoid a root \`src/index.ts\` fan-out registrar for new code.
|
|
112
|
+
- Keep domain logic in Pi-free core modules and tools as thin wrappers.
|
|
113
|
+
- Config uses TypeScript raw/resolved interfaces with \`ConfigLoader<Raw, Resolved>\`, not TypeBox schemas.
|
|
114
|
+
- No \`.js\` suffixes in TypeScript imports.
|
|
115
|
+
|
|
116
|
+
## 5. Create Update Plan
|
|
117
|
+
|
|
118
|
+
Present a detailed plan with:
|
|
119
|
+
- Package namespace/version changes and whether \`@earendil-works/*\` is available for the target.
|
|
120
|
+
- Files to change and why.
|
|
121
|
+
- API migrations required by changelogs/docs.
|
|
122
|
+
- Best-practice cleanups found in source, README, skills, prompts, and examples.
|
|
123
|
+
- Verification commands to run.
|
|
124
|
+
|
|
125
|
+
Ask for confirmation before editing.
|
|
126
|
+
|
|
127
|
+
## 6. Execute After Confirmation
|
|
128
|
+
|
|
129
|
+
After the user confirms:
|
|
130
|
+
1. Apply package metadata changes.
|
|
131
|
+
2. Apply source/docs/skill/prompt changes.
|
|
132
|
+
3. Run the detected install command.
|
|
133
|
+
4. Run typecheck.
|
|
134
|
+
5. Run lint if available.
|
|
135
|
+
6. Report changed files, verification results, and any remaining risks.
|
|
136
|
+
|
|
137
|
+
## 7. Commit Changes When Asked
|
|
138
|
+
|
|
139
|
+
Only commit if the user asks. If committing:
|
|
140
|
+
1. Run \`git status\`.
|
|
141
|
+
2. Stage only files changed for this update; never use \`git add .\`.
|
|
142
|
+
3. Follow the repository's commit style, defaulting to \`chore: update pi packages to X.Y.Z\`.
|
|
143
|
+
4. Include a short body listing breaking changes handled.
|
|
144
|
+
|
|
145
|
+
## Fallbacks
|
|
146
|
+
|
|
147
|
+
If \`pi_changelog\`, \`pi_docs\`, or \`detect_package_manager\` fail, manually inspect the installed Pi package directory, its \`CHANGELOG.md\`, \`README.md\`, \`docs/\`, \`examples/\`, lockfiles, and \`package.json\`.`;
|
|
100
148
|
|
|
101
149
|
export function registerUpdateCommand(pi: ExtensionAPI) {
|
|
102
150
|
pi.registerCommand("extensions:update", {
|