@aliou/pi-dev-kit 0.6.4 → 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 +15 -10
- package/src/commands/index.ts +5 -1
- package/src/commands/update.ts +139 -91
- package/src/skills/pi-extension/SKILL.md +108 -131
- package/src/skills/pi-extension/references/additional-apis.md +256 -173
- 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 +97 -92
- 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 +156 -245
- package/src/skills/pi-extension/references/testing.md +1 -1
- package/src/skills/pi-extension/references/tools.md +212 -816
- package/src/tools/changelog-tool.ts +237 -230
- package/src/tools/docs-tool.ts +127 -130
- package/src/tools/index.ts +5 -1
- package/src/tools/package-manager-tool.ts +152 -147
- package/src/tools/utils.ts +33 -23
- package/src/tools/version-tool.ts +51 -51
- package/src/index.ts +0 -8
package/src/tools/utils.ts
CHANGED
|
@@ -1,38 +1,48 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
2
3
|
import * as path from "node:path";
|
|
3
4
|
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
|
+
|
|
7
|
+
const PI_PACKAGE_NAMES = [
|
|
8
|
+
"@earendil-works/pi-coding-agent",
|
|
9
|
+
"@mariozechner/pi-coding-agent",
|
|
10
|
+
] as const;
|
|
11
|
+
|
|
4
12
|
/**
|
|
5
13
|
* Find the currently running Pi installation directory by resolving the
|
|
6
14
|
* pi-coding-agent package location.
|
|
7
15
|
*/
|
|
8
16
|
export function findPiInstallation(): string | null {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
let currentDir = path.dirname(scriptPath);
|
|
17
|
+
for (const packageName of PI_PACKAGE_NAMES) {
|
|
18
|
+
try {
|
|
19
|
+
const piModulePath = require.resolve(`${packageName}/package.json`);
|
|
20
|
+
return path.dirname(piModulePath);
|
|
21
|
+
} catch {
|
|
22
|
+
// Try the next package namespace.
|
|
23
|
+
}
|
|
24
|
+
}
|
|
18
25
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
const scriptPath = process.argv[1];
|
|
27
|
+
if (scriptPath) {
|
|
28
|
+
let currentDir = path.dirname(scriptPath);
|
|
29
|
+
|
|
30
|
+
while (currentDir !== path.dirname(currentDir)) {
|
|
31
|
+
const packageJsonPath = path.join(currentDir, "package.json");
|
|
32
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
33
|
+
try {
|
|
34
|
+
const packageContent = fs.readFileSync(packageJsonPath, "utf-8");
|
|
35
|
+
const packageJson = JSON.parse(packageContent);
|
|
36
|
+
if (PI_PACKAGE_NAMES.includes(packageJson.name)) {
|
|
37
|
+
return currentDir;
|
|
30
38
|
}
|
|
39
|
+
} catch {
|
|
40
|
+
// Continue searching
|
|
31
41
|
}
|
|
32
|
-
currentDir = path.dirname(currentDir);
|
|
33
42
|
}
|
|
43
|
+
currentDir = path.dirname(currentDir);
|
|
34
44
|
}
|
|
35
|
-
|
|
36
|
-
return null;
|
|
37
45
|
}
|
|
46
|
+
|
|
47
|
+
return null;
|
|
38
48
|
}
|
|
@@ -2,69 +2,69 @@ import { ToolCallHeader } from "@aliou/pi-utils-ui";
|
|
|
2
2
|
import type {
|
|
3
3
|
AgentToolResult,
|
|
4
4
|
ExtensionAPI,
|
|
5
|
-
ExtensionContext,
|
|
6
5
|
Theme,
|
|
7
|
-
|
|
8
|
-
} from "@
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { Type } from "@sinclair/typebox";
|
|
6
|
+
} from "@earendil-works/pi-coding-agent";
|
|
7
|
+
import { defineTool, VERSION } from "@earendil-works/pi-coding-agent";
|
|
8
|
+
import { Text } from "@earendil-works/pi-tui";
|
|
9
|
+
import { type Static, Type } from "typebox";
|
|
12
10
|
|
|
13
11
|
const VersionParams = Type.Object({});
|
|
14
|
-
type VersionParamsType =
|
|
12
|
+
type VersionParamsType = Static<typeof VersionParams>;
|
|
13
|
+
|
|
14
|
+
function renderVersionCall(_args: VersionParamsType, theme: Theme) {
|
|
15
|
+
return new ToolCallHeader({ toolName: "Pi Version" }, theme);
|
|
16
|
+
}
|
|
15
17
|
|
|
16
18
|
interface VersionDetails {
|
|
17
19
|
version?: string;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
],
|
|
22
|
+
const versionTool = defineTool({
|
|
23
|
+
name: "pi_version",
|
|
24
|
+
label: "Pi Version",
|
|
25
|
+
description: "Get the version of the currently running Pi instance",
|
|
26
|
+
promptSnippet: "Check the current Pi version.",
|
|
27
|
+
promptGuidelines: [
|
|
28
|
+
"Use pi_version when the user asks about the Pi version or when a task depends on knowing the installed version.",
|
|
29
|
+
],
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
parameters: VersionParams,
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
async execute(
|
|
34
|
+
_toolCallId,
|
|
35
|
+
_params,
|
|
36
|
+
_signal,
|
|
37
|
+
_onUpdate,
|
|
38
|
+
_ctx,
|
|
39
|
+
): Promise<AgentToolResult<VersionDetails>> {
|
|
40
|
+
return {
|
|
41
|
+
content: [{ type: "text", text: `Pi version ${VERSION}` }],
|
|
42
|
+
details: { version: VERSION },
|
|
43
|
+
};
|
|
44
|
+
},
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
renderCall(args, theme) {
|
|
47
|
+
return renderVersionCall(args, theme);
|
|
48
|
+
},
|
|
48
49
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
): Text {
|
|
54
|
-
const { details } = result;
|
|
50
|
+
renderResult(result, options, theme) {
|
|
51
|
+
if (options.isPartial) {
|
|
52
|
+
return new Text(theme.fg("dim", "Pi Version: loading..."), 0, 0);
|
|
53
|
+
}
|
|
55
54
|
|
|
56
|
-
|
|
57
|
-
const textBlock = result.content.find((c) => c.type === "text");
|
|
58
|
-
const msg =
|
|
59
|
-
(textBlock?.type === "text" && textBlock.text) || "Unknown version";
|
|
60
|
-
return new Text(theme.fg("error", msg), 0, 0);
|
|
61
|
-
}
|
|
55
|
+
const { details } = result;
|
|
62
56
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
57
|
+
if (!details?.version) {
|
|
58
|
+
const textBlock = result.content.find((c) => c.type === "text");
|
|
59
|
+
const msg =
|
|
60
|
+
(textBlock?.type === "text" && textBlock.text) || "Unknown version";
|
|
61
|
+
return new Text(theme.fg("error", msg), 0, 0);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return new Text(theme.fg("accent", `Pi version: ${details.version}`), 0, 0);
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export function setupVersionTool(pi: ExtensionAPI) {
|
|
69
|
+
pi.registerTool(versionTool);
|
|
70
70
|
}
|
package/src/index.ts
DELETED