@evref-bl/pharo-agent 0.12.1 → 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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pharo-agent",
3
3
  "displayName": "Pharo Agent",
4
- "version": "0.12.1",
4
+ "version": "0.13.0",
5
5
  "description": "Terminal-first Pharo image setup for coding agents.",
6
6
  "author": {
7
7
  "name": "Evref-BL",
package/.mcp.json CHANGED
@@ -1,12 +1,8 @@
1
1
  {
2
2
  "mcpServers": {
3
- "image": {
4
- "command": "npx",
5
- "args": [
6
- "--yes",
7
- "@evref-bl/pharo-agent@0.12.1",
8
- "mcp"
9
- ]
3
+ "pharo": {
4
+ "command": "node",
5
+ "args": ["${CLAUDE_PLUGIN_ROOT}/bin/pharo-agent.js", "mcp"]
10
6
  }
11
7
  }
12
8
  }
package/README.md CHANGED
@@ -1,8 +1,44 @@
1
1
  # pharo-agent
2
2
 
3
- `pharo-agent` gives a coding agent a live Pharo image: semantic tools over MCP,
4
- and the image's source projected as files it can read and edit. It works with
5
- Claude Code, Codex and OpenCode.
3
+ `pharo-agent` gives a coding agent a Pharo Launcher of its own. It can see the
4
+ templates the launcher offers, create images from them, start and stop them,
5
+ and work inside the ones it started: classes, methods, senders, tests,
6
+ refactorings, critiques, and the rest of what a Pharo IDE does. On macOS it
7
+ can also read and edit an image's source as files.
8
+
9
+ It works with Claude Code, Codex and OpenCode.
10
+
11
+ ## What it is made of
12
+
13
+ This plugin is the glue. Three projects do the work, and each is useful on its
14
+ own:
15
+
16
+ - [PLexus](https://github.com/Evref-BL/PLexus) drives Pharo Launcher. It
17
+ creates, starts and stops a project's images, keeps their state outside the
18
+ images, and forwards MCP calls to the server running in each one.
19
+ - [MCP for Pharo](https://github.com/Evref-BL/MCP) is that server. It works
20
+ through Pharo's own compiler, refactorings, SUnit, Iceberg and Epicea rather
21
+ than patching exported text, and it maintains the Pharo guidance a project
22
+ gets.
23
+ - [pharo-image-fs](https://github.com/Evref-BL/pharo-image-fs) projects a live
24
+ image's source as a filesystem, so ordinary file tools edit the image
25
+ itself.
26
+
27
+ The plugin pins one released version of each, so a project gets a set that was
28
+ tested together, and gives the agent one command surface over the lot.
29
+
30
+ ## Requirements
31
+
32
+ - Node 22.12 or later.
33
+ - [Pharo Launcher](https://pharo-project.github.io/pharo-launcher/), which is
34
+ where images and templates come from.
35
+ - For editing source as files: macOS with [fuse-t](https://www.fuse-t.org/),
36
+ installed with `brew install --cask fuse-t`. Its daemon is downloaded for
37
+ you. Everywhere else images start with their Pharo tools and no projection,
38
+ rather than failing.
39
+
40
+ The image tools cover Pharo 12 to 15. An image outside that range still
41
+ starts, and says what it will not have.
6
42
 
7
43
  ## Setup
8
44
 
@@ -14,57 +50,64 @@ In Claude Code, install it as a plugin:
14
50
  ```
15
51
 
16
52
  Then ask the agent to enable Pharo tooling in a project. The plugin carries a
17
- setup skill that runs the command below for you, and declares the `image` MCP
18
- server, so the running image's tools reach the chat without a server
19
- configured by hand. [Hosts](docs/hosts.md) covers enabling it per project
20
- rather than everywhere.
53
+ setup skill that does it, and declares the `pharo` MCP server, so a running
54
+ image's tools reach the chat with nothing configured by hand.
55
+ [Hosts](docs/hosts.md) covers enabling it per project rather than everywhere.
21
56
 
22
- Any host can run the CLI instead, which is the whole of the setup either way.
23
- In the project directory:
57
+ Any host can run the CLI instead. In the project directory, once:
24
58
 
25
59
  ```sh
26
60
  npx --yes @evref-bl/pharo-agent init --host <claude|codex|opencode>
27
61
  ```
28
62
 
29
- That is all of it. `init` writes the project's Pharo guidance and copies the
30
- workflow skills that guidance refers to. From there the agent registers the
31
- image the project needs, starts it and uses its tools by following what was
32
- written; ask it for Pharo work as you would for anything else.
33
-
34
- ## Refreshing an existing project
35
-
36
- After upgrading the plugin/CLI through your usual installation method, re-run
37
- `pharo-agent init --host <claude|codex|opencode>` from the project root with
38
- the same host. This refreshes the generated guidance, skills, and references
39
- using that CLI version's pinned templates. Image declarations, existing plugin
40
- settings, and guidance outside the host's managed block are preserved when
41
- you omit `--mount-root`.
42
-
43
- Generated/copied files are overwritten, so keep project-specific instructions
44
- outside them. Refreshing project files does not upgrade the installed package
45
- or update, restart, or save existing images. See [Hosts](docs/hosts.md) for
46
- the file ownership rules and [Images](docs/images.md) for image-side MCP updates.
47
-
48
- ## Requirements
49
-
50
- Node 22.12 or later.
51
-
52
- Images and their Pharo tools run anywhere Node does. The source projection is
53
- the exception: it needs macOS with [fuse-t](https://www.fuse-t.org/), whose
54
- daemon is downloaded for you. Everywhere else an image starts with its tools
55
- and says that the projection is not available, rather than failing.
56
-
57
63
  ## What the agent gets
58
64
 
59
- Use `pharo-agent --help` for the command overview, or append `--help` to a
60
- command for its options, defaults, and an example: `pharo-agent init --help`
61
- or `pharo-agent image add --help`. Help works before project setup.
62
-
63
- Reference, for reading rather than typing: these are the commands the guidance
64
- hands to the agent.
65
-
66
- - [Hosts](docs/hosts.md) — what `init` writes, and installing as a plugin.
65
+ **The launcher.** `image templates` names every template the installation
66
+ offers. `image add <id> --template <name>` declares an image, and
67
+ `image start <id>` creates it from that template the first time and starts it.
68
+ A project can declare as many images as it likes — one per Pharo version, one
69
+ to throw away — and run them at once; `image list` says what is declared and
70
+ what is running. [Images](docs/images.md) has the rest.
71
+
72
+ **The tools of each running image.** Classes, methods, senders, tests and
73
+ evaluation are advertised; the fuller catalogue, such as packages,
74
+ repositories, change history and debuggers, is searched rather than listed, so
75
+ its schemas stay out of the agent's context. The tools belong to the image, so
76
+ what exists depends on what that image has loaded. [Tools](docs/tools.md)
77
+ covers both, and serving a different MCP from an image.
78
+
79
+ **Source as files, on macOS.** Starting an image mounts its source below
80
+ `.pharo-agent/mounts`. A file edited there is compiled into the live image:
81
+ the files and the tools are two views of one image, not of an export and an
82
+ image.
83
+
84
+ **Guidance for the agent.** Setting a project up writes a Pharo guide into it,
85
+ and a conditional line in the host's own guide pointing at that guide for
86
+ Pharo work only, so Pharo instructions stay out of unrelated chats. The guide
87
+ and what it refers to are maintained by the MCP project and copied from the
88
+ release this plugin pins. [Hosts](docs/hosts.md) lists the paths it owns.
89
+
90
+ ## Refreshing after an upgrade
91
+
92
+ Upgrade the plugin the way you installed it, then run the setup command again
93
+ in the project, naming the same host. That rewrites the generated guide and
94
+ the files copied with it, from the templates the new version pins.
95
+
96
+ Image declarations, runtime state and settings are kept, as long as you omit
97
+ `--mount-root`, and so is anything outside the block the plugin marks as its
98
+ own. Generated and copied files are overwritten, so keep project-specific
99
+ instructions out of them. Refreshing a project upgrades neither the installed
100
+ plugin nor the code inside a running image; [Images](docs/images.md) covers
101
+ the image side.
102
+
103
+ ## Reading further
104
+
105
+ `pharo-agent --help` gives the command overview, and `--help` on a command
106
+ gives its options, defaults and an example. Help works before a project is set
107
+ up.
108
+
109
+ - [Hosts](docs/hosts.md) — what setup writes, and installing as a plugin.
67
110
  - [Images](docs/images.md) — templates and categories, several images at once,
68
111
  Pharo versions outside the MCP range.
69
- - [Tools](docs/tools.md) — the advertised surface, finding the rest, and the
70
- stdio bundle.
112
+ - [Tools](docs/tools.md) — the advertised surface, finding the rest, the stdio
113
+ bundle, and serving a different MCP.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evref-bl/pharo-agent",
3
- "version": "0.12.1",
3
+ "version": "0.13.0",
4
4
  "private": false,
5
5
  "description": "Terminal-first Pharo integration for coding agents.",
6
6
  "license": "Apache-2.0",
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "pharo-agent",
4
- "version": "0.12.1",
4
+ "version": "0.13.0",
5
5
  "description": "Terminal-first Pharo image setup for coding agents.",
6
6
  "author": {
7
7
  "name": "Evref-BL",
@@ -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.12.1 init --host claude
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 \`pharo-agent image start\`:
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, the image's tools are MCP
146
- tools: start an image with \`image_start\` and call the rest by name. Without it,
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
- // Listed whether or not an image is running, so the list is never empty. A
35
- // host that caches tools and ignores tools/list_changed would otherwise hold
36
- // an empty list for the whole session and never learn that one had started.
37
- const lifecycleTools = [
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: lifecycleTools };
167
+ return { tools: projectTools };
112
168
  }
113
169
  return {
114
- tools: [...lifecycleTools, ...(await runningImageTools(projectRoot, defaultImage))],
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 three names belong to this
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
- return readJson(configPath(projectRoot));
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