@evref-bl/pharo-agent 0.12.2 → 0.13.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/.claude-plugin/plugin.json +1 -1
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/skills/pharo-setup/SKILL.md +1 -1
- package/src/init.js +6 -3
- package/src/mcpServer.js +72 -10
- package/src/runtime.js +8 -1
package/package.json
CHANGED
package/plugin.json
CHANGED
|
@@ -8,7 +8,7 @@ Run this only when the user asks to enable or refresh Pharo tooling in this proj
|
|
|
8
8
|
From the project root, run the released CLI that matches this plugin:
|
|
9
9
|
|
|
10
10
|
```sh
|
|
11
|
-
npx --yes @evref-bl/pharo-agent@0.
|
|
11
|
+
npx --yes @evref-bl/pharo-agent@0.13.0 init --host claude
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
Name the host this chat runs in: `--host claude` in Claude Code,
|
package/src/init.js
CHANGED
|
@@ -120,7 +120,9 @@ outside generated/copied files and outside the host guide's managed block.
|
|
|
120
120
|
Refreshing project files does not install a newer package or upgrade image tools.
|
|
121
121
|
|
|
122
122
|
\`plexus.json\` declares this project's images. A freshly initialized
|
|
123
|
-
project declares none; register one before the first
|
|
123
|
+
project declares none; register one before the first image start. With the
|
|
124
|
+
pharo-agent plugin enabled, that is \`image_templates\` and then \`image_add\`,
|
|
125
|
+
with no shell. Otherwise:
|
|
124
126
|
|
|
125
127
|
\`\`\`sh
|
|
126
128
|
pharo-agent image templates
|
|
@@ -142,8 +144,9 @@ installed the image's source is also projected under \`.pharo-agent/mounts\`
|
|
|
142
144
|
and can be edited as files; everywhere else the Pharo tools are the way in,
|
|
143
145
|
and \`image start\` says so.
|
|
144
146
|
|
|
145
|
-
With the pharo-agent plugin enabled for this project,
|
|
146
|
-
|
|
147
|
+
With the pharo-agent plugin enabled for this project, this is all MCP tools:
|
|
148
|
+
declare an image with \`image_add\`, start it with \`image_start\`, and call the
|
|
149
|
+
image's own tools by name. Without it,
|
|
147
150
|
call a tool with \`pharo-agent pharo <tool> [arguments-json]\`, and
|
|
148
151
|
\`pharo-agent mcp\` serves the same surface as a command-scoped stdio MCP
|
|
149
152
|
server.
|
package/src/mcpServer.js
CHANGED
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
version,
|
|
12
12
|
withImageSelector,
|
|
13
13
|
} from "./gateway.js";
|
|
14
|
-
import { listImages } from "./images.js";
|
|
15
|
-
import { startAgentImage, stopAgentImage } from "./live.js";
|
|
14
|
+
import { addImage, listImages } from "./images.js";
|
|
15
|
+
import { listImageTemplates, startAgentImage, stopAgentImage } from "./live.js";
|
|
16
16
|
import { readRunningImage } from "./runtime.js";
|
|
17
17
|
|
|
18
18
|
// The host loads only tool names and these instructions at session start and
|
|
@@ -26,15 +26,57 @@ and projecting image source as files on disk.
|
|
|
26
26
|
Search these tools whenever the task involves Pharo, Smalltalk, a Tonel
|
|
27
27
|
package, or a .st file. Start an image with image_start before calling the
|
|
28
28
|
image's own tools, which are listed once an image answers; image_list says
|
|
29
|
-
what is already running.
|
|
29
|
+
what is already running. A project that declares no image yet needs
|
|
30
|
+
image_templates and image_add first.
|
|
30
31
|
|
|
31
32
|
The image advertises the common tools rather than all of it. Use tool_search
|
|
32
33
|
and tool_get to find the rest, then call one by name like any other.`;
|
|
33
34
|
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
// an
|
|
37
|
-
|
|
35
|
+
// This server's own tools, in the order a project meets them: declare an
|
|
36
|
+
// image, start it, and the image's tools join the list. Listed whether or not
|
|
37
|
+
// an image is running, so the list is never empty — a host that caches tools
|
|
38
|
+
// and ignores tools/list_changed would otherwise hold an empty list for the
|
|
39
|
+
// whole session and never learn that one had started.
|
|
40
|
+
const projectTools = [
|
|
41
|
+
{
|
|
42
|
+
name: "image_templates",
|
|
43
|
+
description:
|
|
44
|
+
"List the images Pharo Launcher can create, with the category of each. "
|
|
45
|
+
+ "A template name that two categories offer is flagged, and needs its "
|
|
46
|
+
+ "category when it is declared.",
|
|
47
|
+
inputSchema: { type: "object", properties: {} },
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "image_add",
|
|
51
|
+
description:
|
|
52
|
+
"Declare an image in this project, from a template image_templates "
|
|
53
|
+
+ "names. Declaring does not create the image: the first image_start "
|
|
54
|
+
+ "does, from this template. The first image declared becomes the "
|
|
55
|
+
+ "project's default.",
|
|
56
|
+
inputSchema: {
|
|
57
|
+
type: "object",
|
|
58
|
+
properties: {
|
|
59
|
+
id: {
|
|
60
|
+
type: "string",
|
|
61
|
+
description: "Short id this project calls the image by, such as dev.",
|
|
62
|
+
},
|
|
63
|
+
template: {
|
|
64
|
+
type: "string",
|
|
65
|
+
description: "Template name, exactly as image_templates gives it.",
|
|
66
|
+
},
|
|
67
|
+
category: {
|
|
68
|
+
type: "string",
|
|
69
|
+
description:
|
|
70
|
+
"Template category. Needed only for a name two categories offer.",
|
|
71
|
+
},
|
|
72
|
+
profile: {
|
|
73
|
+
type: "string",
|
|
74
|
+
description: "Pharo Launcher profile to create the image under.",
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
required: ["id", "template"],
|
|
78
|
+
},
|
|
79
|
+
},
|
|
38
80
|
{
|
|
39
81
|
name: "image_start",
|
|
40
82
|
description:
|
|
@@ -95,6 +137,20 @@ async function runningImageTools(projectRoot, defaultImage) {
|
|
|
95
137
|
.map((tool) => withImageSelector(tool, running.imageId));
|
|
96
138
|
}
|
|
97
139
|
|
|
140
|
+
// A schema is a description, not a guard: nothing between the model and here
|
|
141
|
+
// enforces it, and a declaration missing its template would otherwise fail
|
|
142
|
+
// somewhere further in, naming a field the caller never saw.
|
|
143
|
+
function declarationFrom(argumentsValue) {
|
|
144
|
+
const { id, template, category, profile } = argumentsValue;
|
|
145
|
+
if (typeof id !== "string" || id === "") {
|
|
146
|
+
throw new Error("image_add needs the id this project will call the image by.");
|
|
147
|
+
}
|
|
148
|
+
if (typeof template !== "string" || template === "") {
|
|
149
|
+
throw new Error("image_add needs a template name, as image_templates gives it.");
|
|
150
|
+
}
|
|
151
|
+
return { id, template, category, profile };
|
|
152
|
+
}
|
|
153
|
+
|
|
98
154
|
export async function serveImagesMcp(resolveProjectRoot, defaultImage) {
|
|
99
155
|
const server = new Server(
|
|
100
156
|
{ name: "pharo-agent", version },
|
|
@@ -108,10 +164,10 @@ export async function serveImagesMcp(resolveProjectRoot, defaultImage) {
|
|
|
108
164
|
} catch {
|
|
109
165
|
// No project here. The lifecycle tools are still listed rather than
|
|
110
166
|
// nothing, so the host has a server that works and a call can say why.
|
|
111
|
-
return { tools:
|
|
167
|
+
return { tools: projectTools };
|
|
112
168
|
}
|
|
113
169
|
return {
|
|
114
|
-
tools: [...
|
|
170
|
+
tools: [...projectTools, ...(await runningImageTools(projectRoot, defaultImage))],
|
|
115
171
|
};
|
|
116
172
|
});
|
|
117
173
|
|
|
@@ -121,9 +177,15 @@ export async function serveImagesMcp(resolveProjectRoot, defaultImage) {
|
|
|
121
177
|
// Throws when there is no project, which is the answer the caller needs.
|
|
122
178
|
const projectRoot = resolveProjectRoot();
|
|
123
179
|
|
|
124
|
-
// Matched before the image's catalogue: these
|
|
180
|
+
// Matched before the image's catalogue: these names belong to this
|
|
125
181
|
// server, and an image that happened to hold one must not decide what
|
|
126
182
|
// starting an image means.
|
|
183
|
+
if (request.params.name === "image_templates") {
|
|
184
|
+
return toolResult({ ok: true, ...(await listImageTemplates(projectRoot)) });
|
|
185
|
+
}
|
|
186
|
+
if (request.params.name === "image_add") {
|
|
187
|
+
return toolResult({ ok: true, ...addImage(projectRoot, declarationFrom(argumentsValue)) });
|
|
188
|
+
}
|
|
127
189
|
if (request.params.name === "image_start") {
|
|
128
190
|
const started = await startAgentImage(projectRoot, selected);
|
|
129
191
|
await server.sendToolListChanged();
|
package/src/runtime.js
CHANGED
|
@@ -23,11 +23,18 @@ export function configPath(projectRoot) {
|
|
|
23
23
|
return path.join(pluginDirectory(projectRoot), "config.json");
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
// A project can hold a plexus.json this plugin never initialized, and now that
|
|
27
|
+
// an image can be declared from a chat it is reached before `.pharo-agent`
|
|
28
|
+
// exists. An absent settings file is a project with no settings, not an error
|
|
29
|
+
// about a path the caller never named.
|
|
26
30
|
export function readConfig(projectRoot) {
|
|
27
|
-
|
|
31
|
+
const filePath = configPath(projectRoot);
|
|
32
|
+
if (!fs.existsSync(filePath)) return {};
|
|
33
|
+
return readJson(filePath);
|
|
28
34
|
}
|
|
29
35
|
|
|
30
36
|
export function writeConfig(projectRoot, config) {
|
|
37
|
+
fs.mkdirSync(pluginDirectory(projectRoot), { recursive: true });
|
|
31
38
|
fs.writeFileSync(configPath(projectRoot), `${JSON.stringify(config, null, 2)}\n`);
|
|
32
39
|
}
|
|
33
40
|
|