@howaboua/pi-chatgpt-sites 0.0.1 → 0.0.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/CHANGELOG.md +4 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +49 -4
- package/package.json +11 -2
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export default function sitesExtension(pi: ExtensionAPI): void
|
|
1
|
+
import { type ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
export default function sitesExtension(pi: ExtensionAPI): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { defineTool } from "@earendil-works/pi-coding-agent";
|
|
1
2
|
import { Type } from "typebox";
|
|
2
3
|
import { getSitesAuth } from "./src/auth.js";
|
|
3
4
|
import { SitesClient } from "./src/client.js";
|
|
@@ -36,11 +37,11 @@ async function result(run) {
|
|
|
36
37
|
function isRecord(value) {
|
|
37
38
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
38
39
|
}
|
|
39
|
-
export default function sitesExtension(pi) {
|
|
40
|
-
|
|
40
|
+
export default async function sitesExtension(pi) {
|
|
41
|
+
const sites = defineTool({
|
|
41
42
|
name: "sites",
|
|
42
43
|
label: "Sites",
|
|
43
|
-
description: "Manage ChatGPT Sites
|
|
44
|
+
description: "Manage ChatGPT Sites",
|
|
44
45
|
parameters: Type.Object({
|
|
45
46
|
resource: Type.Optional(Type.String()),
|
|
46
47
|
action: Type.Optional(Type.String()),
|
|
@@ -56,7 +57,7 @@ export default function sitesExtension(pi) {
|
|
|
56
57
|
: call(args, client, ctx.cwd, signal));
|
|
57
58
|
},
|
|
58
59
|
});
|
|
59
|
-
|
|
60
|
+
const guide = defineTool({
|
|
60
61
|
name: "sites_documentation",
|
|
61
62
|
label: "Sites documentation",
|
|
62
63
|
description: "Sites guide or current resource.action parameter schema",
|
|
@@ -65,4 +66,48 @@ export default function sitesExtension(pi) {
|
|
|
65
66
|
return result(() => documentation(args.topic === "help" ? "index" : args.topic, new SitesClient({ authProvider: () => getSitesAuth(ctx), signal })));
|
|
66
67
|
},
|
|
67
68
|
});
|
|
69
|
+
const tools = [
|
|
70
|
+
{
|
|
71
|
+
tool: sites,
|
|
72
|
+
gpt: "Manage ChatGPT Sites",
|
|
73
|
+
ordinary: sites.description,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
tool: guide,
|
|
77
|
+
gpt: "Sites guide or live resource.action parameter schema",
|
|
78
|
+
ordinary: guide.description,
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
for (const { tool } of tools)
|
|
82
|
+
pi.registerTool(tool);
|
|
83
|
+
try {
|
|
84
|
+
const { adaptToolForCodeMode, registerCodeModeExtensionTools } = await import("@howaboua/pi-codex-conversion/code-mode");
|
|
85
|
+
const registration = registerCodeModeExtensionTools(pi, () => tools.map(({ tool }) => adaptToolForCodeMode(tool, {
|
|
86
|
+
discovery: "help",
|
|
87
|
+
deferLoading: true,
|
|
88
|
+
})));
|
|
89
|
+
pi.on("session_shutdown", () => registration.unregister());
|
|
90
|
+
const { registerGptPromptMode } = await import("@howaboua/pi-codex-conversion/prompt-mode");
|
|
91
|
+
registerGptPromptMode(pi, (active) => {
|
|
92
|
+
for (const { tool, gpt, ordinary } of tools) {
|
|
93
|
+
const description = active ? gpt : ordinary;
|
|
94
|
+
if (tool.description !== description) {
|
|
95
|
+
tool.description = description;
|
|
96
|
+
pi.registerTool(tool);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return tools.map(({ tool }) => tool);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
if (!(error instanceof Error) ||
|
|
104
|
+
!("code" in error) ||
|
|
105
|
+
![
|
|
106
|
+
"ERR_MODULE_NOT_FOUND",
|
|
107
|
+
"MODULE_NOT_FOUND",
|
|
108
|
+
"ERR_PACKAGE_PATH_NOT_EXPORTED",
|
|
109
|
+
].includes(String(error.code)) ||
|
|
110
|
+
!error.message.includes("@howaboua/pi-codex-conversion"))
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
68
113
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@howaboua/pi-chatgpt-sites",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "ChatGPT Sites management for Pi, Code Mode and Notebook",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,9 +44,18 @@
|
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@earendil-works/pi-coding-agent": ">=1.1.0",
|
|
46
46
|
"typebox": "*",
|
|
47
|
-
"@earendil-works/pi-tui": ">=1.0.0"
|
|
47
|
+
"@earendil-works/pi-tui": ">=1.0.0",
|
|
48
|
+
"@howaboua/pi-codex-conversion": ">=4.0.2"
|
|
48
49
|
},
|
|
49
50
|
"publishConfig": {
|
|
50
51
|
"access": "public"
|
|
52
|
+
},
|
|
53
|
+
"peerDependenciesMeta": {
|
|
54
|
+
"@howaboua/pi-codex-conversion": {
|
|
55
|
+
"optional": true
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@howaboua/pi-codex-conversion": "4.0.2"
|
|
51
60
|
}
|
|
52
61
|
}
|