@evref-bl/pharo-mcp 3.0.0 → 3.2.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.
Files changed (24) hide show
  1. package/README.md +5 -7
  2. package/package.json +1 -1
  3. package/templates/pharo-references/pharo-coding.md +105 -0
  4. package/templates/pharo-references/tool-reference.md +78 -158
  5. package/templates/pharo-skills/pharo-ci-repro/references/pharo-smalltalkci.md +4 -28
  6. package/templates/pharo-skills/pharo-code-profiling/SKILL.md +19 -38
  7. package/templates/pharo-skills/pharo-image-sync/SKILL.md +47 -0
  8. package/templates/pharo-skills/pharo-image-sync/agents/openai.yaml +4 -0
  9. package/templates/pharo-skills/pharo-mcp-recovery/SKILL.md +1 -1
  10. package/templates/pharo-skills/pharo-project-load/SKILL.md +2 -1
  11. package/templates/pharo.AGENTS.md +16 -14
  12. package/templates/pharo-references/building-on-mcp.md +0 -473
  13. package/templates/pharo-references/debugging.md +0 -70
  14. package/templates/pharo-references/getting-started.md +0 -151
  15. package/templates/pharo-references/pharo-coding-rules.md +0 -147
  16. package/templates/pharo-references/pharo-coding-style.md +0 -141
  17. package/templates/pharo-references/safety-and-ecosystem.md +0 -323
  18. package/templates/pharo-references/source-vs-live-image.md +0 -75
  19. package/templates/pharo-references/troubleshooting.md +0 -145
  20. package/templates/pharo-references/using-pharo-mcp.md +0 -86
  21. package/templates/pharo-skills/pharo-image-git-handoff/SKILL.md +0 -40
  22. package/templates/pharo-skills/pharo-image-git-handoff/agents/openai.yaml +0 -4
  23. package/templates/pharo-skills/pharo-version-compat/SKILL.md +0 -54
  24. package/templates/pharo-skills/pharo-version-compat/agents/openai.yaml +0 -4
@@ -1,151 +0,0 @@
1
- # Getting Started
2
-
3
- This is the canonical guide for loading MCP, starting its HTTP endpoint, and
4
- connecting a client.
5
-
6
- ## Requirements
7
-
8
- - Pharo 12, 13, 14, or 15
9
- - An MCP client that supports Streamable HTTP directly or through a local bridge
10
- - Network access from the client to the image host
11
-
12
- For local use, keep the image and client on the same machine and use
13
- `127.0.0.1`.
14
-
15
- ## Load MCP
16
-
17
- Evaluate in a supported image:
18
-
19
- ```smalltalk
20
- Metacello new
21
- baseline: 'MCP';
22
- repository: 'github://Evref-BL/MCP:main/src';
23
- load.
24
- ```
25
-
26
- As a project dependency:
27
-
28
- ```smalltalk
29
- spec
30
- baseline: 'MCP'
31
- with: [ spec repository: 'github://Evref-BL/MCP:main/src' ].
32
- ```
33
-
34
- ## Load Groups
35
-
36
- The default load includes the server, optional UI, and their tests.
37
-
38
- | Group | Contents |
39
- | --- | --- |
40
- | `default` | `Core`, `UI`, `Tests`, and `UI Tests` |
41
- | `Core` | The `MCP` server package |
42
- | `UI` | `MCP-UI` and its required core package |
43
- | `Tests` | Core server tests and test resources |
44
- | `UI Tests` | UI tests and their required test dependencies |
45
- | `OpenTelemetry` | Optional OpenTelemetry backend |
46
- | `all` | Every package, including the optional OpenTelemetry backend |
47
-
48
- For a headless image, load only the core server:
49
-
50
- ```smalltalk
51
- Metacello new
52
- baseline: 'MCP';
53
- repository: 'github://Evref-BL/MCP:main/src';
54
- load: 'Core'.
55
- ```
56
-
57
- Dependencies can select the same group with `loads: #( 'Core' )`.
58
-
59
- ## Start And Stop
60
-
61
- ```smalltalk
62
- mcp := MCP startOnPort: 4000.
63
- ```
64
-
65
- That answers the server already on 4000 when the image has one, rather than
66
- failing on the port it holds. Build one by hand when it needs configuring
67
- before it starts:
68
-
69
- ```smalltalk
70
- mcp := MCP new.
71
- mcp port: 4000.
72
- mcp start.
73
- ```
74
-
75
- Tool calls return canonical LLM-facing `content` by default. If a client or
76
- integration needs programmatic payloads, configure the response fields before
77
- starting:
78
-
79
- ```smalltalk
80
- mcp useStructuredContentOnlyToolResponses.
81
- mcp useContentAndStructuredContentToolResponses.
82
- ```
83
-
84
- Inspect or control the server with:
85
-
86
- ```smalltalk
87
- mcp localUrlString.
88
- mcp isRunning.
89
- mcp isListening.
90
- mcp restart.
91
- mcp stop.
92
- ```
93
-
94
- The server lives in the image and stops when the image exits.
95
-
96
- ## Connect A Client
97
-
98
- The endpoint above is:
99
-
100
- ```text
101
- http://127.0.0.1:4000
102
- ```
103
-
104
- Client configuration formats differ. Configure a Streamable HTTP MCP server
105
- using the client documentation rather than copying another client's JSON.
106
- Loopback addresses work only when the client connects from the local machine;
107
- cloud-brokered connectors cannot reach `127.0.0.1`.
108
-
109
- Install the supplied guide, local references, workflow skills, and direct MCP
110
- configuration into the current agent project:
111
-
112
- ```sh
113
- npx @evref-bl/pharo-mcp install --host codex
114
- ```
115
-
116
- Use `--host claude` or `--host opencode` for those hosts. The direct MCP
117
- configuration expects port `4000`; update it when the image uses another port.
118
-
119
- ## First Calls
120
-
121
- Start with catalog discovery:
122
-
123
- ```text
124
- tools/list
125
- tool_search
126
- tool_get
127
- ```
128
-
129
- Then inspect the image with focused read-only tools such as:
130
-
131
- ```text
132
- class_search
133
- class_get
134
- method_search
135
- method_source_search
136
- method_reference_search
137
- method_get
138
- ```
139
-
140
- `package_search` and the specialized tools are found with `tool_search`.
141
-
142
- Before mutation, inspect the target and use a copied or disposable image.
143
- Prefer dedicated tools such as `class_create`, `method_compile`, refactoring
144
- tools, and `test_run` over `image_evaluate`.
145
-
146
- Continue with:
147
-
148
- - [Using MCP from an agent](using-pharo-mcp.md)
149
- - [Tool reference](tool-reference.md)
150
- - [Safety and ecosystem integration](safety-and-ecosystem.md)
151
- - [Troubleshooting](troubleshooting.md)
@@ -1,147 +0,0 @@
1
- # Pharo Coding Rules For MCP Users
2
-
3
- Applies when using MCP to inspect, write, review, or refactor Pharo source in
4
- any project.
5
-
6
- This file covers object-design and correctness-oriented rules. For
7
- expression-level readability heuristics, also read
8
- [Pharo coding style](pharo-coding-style.md).
9
-
10
- ## First Principle
11
-
12
- Pharo code should communicate through messages and protocols. Prefer normal
13
- dispatch over representation checks, class checks, reflective lookup, or
14
- dynamic selector tricks.
15
-
16
- ## Dispatch Over Inspection
17
-
18
- Do:
19
-
20
- - send a domain message to the receiver;
21
- - add or refine a protocol on the object that owns the behavior;
22
- - use polymorphic collaborators, strategy objects, double dispatch, or visitors
23
- when behavior varies by object role.
24
-
25
- Avoid in application behavior:
26
-
27
- - `class = ...`;
28
- - `isKindOf:` and `isMemberOf:`;
29
- - `respondsTo:` as control flow;
30
- - `perform:` as a disguised switch;
31
- - method dictionary or instance-variable reflection.
32
-
33
- Reflection is acceptable for tools, proxies, compatibility shims, and explicit
34
- framework boundaries. Keep reflective behavior isolated and named as tooling
35
- or boundary behavior; do not spread it through ordinary domain logic.
36
-
37
- ## Tell, Do Not Ask
38
-
39
- Do not pull state out of an object, compute externally, then push state back
40
- when the object can own the behavior.
41
-
42
- Prefer:
43
-
44
- - `aCommand executeOn: aModel`;
45
- - `aDocument writeOn: aStream`;
46
- - `aPolicy accepts: anObject`.
47
-
48
- over clients branching on concrete classes or internal fields.
49
-
50
- ## Object APIs, Not Data Bags
51
-
52
- - Keep domain objects behavior-rich instead of using them only as data bags.
53
- - Avoid dictionaries or arrays as internal domain models unless the data is
54
- genuinely unstructured external input.
55
- - If several clients repeat the same extraction and calculation, move the
56
- behavior to the object with the knowledge.
57
- - Avoid long message chains through internals; add a meaningful domain method.
58
-
59
- ## Small Methods And Hooks
60
-
61
- - Extract meaningful steps into small named methods.
62
- - Use self-send hooks when subclass or compatibility variation is plausible.
63
- - Keep block bodies short; move domain logic from blocks into methods.
64
- - Do not add wrappers that only rename obvious library calls unless the wrapper
65
- captures a domain concept or extension hook.
66
- - Trust collaborators first. Prefer direct sends to the documented protocol of
67
- the object you were given; add adapters or project-specific extensions only
68
- when the code truly accepts multiple concrete framework shapes or compatibility
69
- differences.
70
- - Be especially conservative with extensions on broad system classes such as
71
- `Object`, `Behavior`, `String`, or `Exception`. They should model a real
72
- boundary protocol, not hypothetical defense against wrong callers.
73
-
74
- ## Nil And Error Handling
75
-
76
- - Return empty collections for "no elements".
77
- - Use a null object when "do nothing" is valid behavior.
78
- - Signal or return structured domain errors for exceptional cases.
79
- - Do not use `nil` as a normal status code.
80
- - Do not swallow broad `Error` silently.
81
- - Catch the most specific exception class that matches the recovery policy.
82
- - Use `ensure:` for cleanup.
83
-
84
- ## Initialization
85
-
86
- - Instance-side `initialize` starts with `super initialize`.
87
- - Initialize sensible defaults.
88
- - Methods without an explicit return answer `self`. Do not add a trailing
89
- `^ self` to initializers or mutators only to return the receiver; keep
90
- explicit returns for early exits or non-self results.
91
- - Do not redefine class-side `new` just to call `initialize`.
92
- - Use class-side creation messages such as `on:`, `with:`, or domain-specific
93
- constructors when required data exists.
94
- - Use `basicNew` only when deliberately bypassing initialization.
95
-
96
- ## Names And Selectors
97
-
98
- - Use domain vocabulary.
99
- - Getter selector is the variable name; setter selector is `name:`.
100
- - Do not use `getName` or `setName:`.
101
- - Predicates should read as predicates: `isReady`, `hasErrors`,
102
- `canHandle:`.
103
- - Action selectors should use verbs: `parseRequest:`, `addTool:`,
104
- `writeResponseOn:`.
105
- - Conversion selectors should start with `as`.
106
-
107
- ## Collections And Streams
108
-
109
- - Prefer collection protocol such as `collect:`, `select:`, `reject:`,
110
- `detect:ifNone:`, `inject:into:`, `anySatisfy:`, and `allSatisfy:`.
111
- - Do not mutate a collection while iterating it unless iterating a copy is
112
- intentional.
113
- - Do not rely on `add:` answering the collection; use a variable or cascade
114
- with `yourself`.
115
- - Override `hash` when overriding `=`.
116
- - Use `String streamContents:` or writer streams for string construction.
117
- - Do not concatenate strings with `,` in loops or recursive code.
118
-
119
- ## Tests
120
-
121
- - Add or update SUnit tests for behavior changes.
122
- - Use `assert:equals:` for comparisons when possible.
123
- - Use `deny:` for negative assertions.
124
- - Use `should:raise:` and `shouldnt:raise:` with blocks for exception
125
- behavior.
126
- - Prefer focused tests around the public protocol.
127
- - Use memory filesystems, fakes, or injected collaborators for unit tests when
128
- possible.
129
- - Keep live-image and external-state tests separate from source-only checks.
130
-
131
- ## Review Checklist
132
-
133
- Before finishing a Pharo source change, scan for:
134
-
135
- - class checks or reflection used as ordinary dispatch;
136
- - `perform:` selector registries;
137
- - normal control flow through `nil`;
138
- - repeated client-side extraction from an object;
139
- - long methods or blocks hiding named domain steps;
140
- - project-specific extensions on broad system classes that only defend
141
- hypothetical collaborators;
142
- - missing `super initialize`;
143
- - stream/file cleanup without `ensure:`;
144
- - string concatenation in loops;
145
- - overridden `=` without `hash`;
146
- - broad exception handlers that hide failures;
147
- - missing tests for changed public behavior.
@@ -1,141 +0,0 @@
1
- # Pharo Coding Style
2
-
3
- Applies when writing or reviewing the shape of Pharo source code after loading
4
- [Pharo coding rules](pharo-coding-rules.md).
5
-
6
- ## Goal
7
-
8
- Keep Pharo code readable, scannable, and idiomatic. These are readability
9
- heuristics, not mechanical laws. Prefer the shape that makes dependencies,
10
- main operations, and exceptional paths easiest to understand.
11
-
12
- ## Main Send
13
-
14
- - Make the main send easy to see. When both branches of a conditional perform
15
- the same operation, lift the branch-invariant send out of the branches and
16
- use the conditional only for the receiver or argument that varies.
17
- - This applies to return expressions, assigned values, message arguments, and
18
- nested expressions.
19
- - Do not over-compress multi-step domain logic into one expression.
20
-
21
- Prefer:
22
-
23
- ```smalltalk
24
- result := self transform: (condition ifTrue: [ selectedValue ])
25
- ```
26
-
27
- over duplicating the same `transform:` send inside both conditional branches.
28
-
29
- ## Guards
30
-
31
- - Guard before dependent work. If `nil`, invalid bounds, failed lookup, or
32
- missing capability exits early or returns a fallback, check it before sends,
33
- computations, or mutations that assume the value is present.
34
- - Keep the normal path visible. Use early returns for local exceptional or
35
- fallback cases when they keep the main path low-indentation.
36
- - Do not mechanically move every condition to the top. Choose the order that
37
- makes dependencies and intent clearest.
38
- - Prefer "win fast" when the successful case is tiny, obvious, and safe to
39
- attempt before fallback work.
40
-
41
- ## Temporaries
42
-
43
- - Prefer short supporting expressions for simple receiver or argument
44
- computation.
45
- - Use a temporary when the value has domain meaning, is reused, names an
46
- important step, or helps debugging and review.
47
- - Keep temporaries near their use.
48
-
49
- ## Collections
50
-
51
- Common collection families, as a protocol reminder rather than a reason to
52
- branch on concrete collection classes:
53
-
54
- ```text
55
- Collection
56
- HashedCollection
57
- Dictionary
58
- Set
59
- OrderedDictionary
60
- SequenceableCollection
61
- OrderedCollection
62
- SortedCollection
63
- ArrayedCollection
64
- Array
65
- String
66
- ```
67
-
68
- - Build the collection you mean to return. When the result type matters, use
69
- messages such as `collect:as:`, `select:as:`, or `flatCollect:as:` instead
70
- of collecting into one species and immediately converting to another.
71
- - Avoid intermediate collections. Prefer fused messages such as
72
- `select:thenCollect:` and `reject:thenCollect:` when filtering and
73
- transforming. When a filtered or transformed collection exists only to feed
74
- iteration, use `select:thenDo:`, `reject:thenDo:`, or `collect:thenDo:`.
75
- Use `groupedBy:` for simple grouping.
76
- - Prefer direct queries over filtered collections. Use `detect:ifNone:` for a
77
- first match with fallback, and `anySatisfy:`, `allSatisfy:`, or
78
- `noneSatisfy:` when asking a boolean question.
79
- - Use streaming constructors such as `Array streamContents:` and
80
- `String streamContents:` when code conditionally appends values or would
81
- otherwise need a temporary `OrderedCollection`.
82
- - Avoid conversion chains that exist only to sort or change species, such as
83
- `asSortedCollection asArray`. Sort a `SequenceableCollection` in-place with
84
- `sort`/`sort:`, or make a copy with `sorted`/`sorted:`.
85
-
86
- ## Conditions
87
-
88
- - Avoid assignment inside boolean conditions. Conditions should decide control
89
- flow, not also mutate state.
90
- - Keep questions pure: predicates should answer questions, not mutate state.
91
- - When the fallback value is `nil`, prefer a one-arm conditional. In Pharo,
92
- `ifTrue:` answers `nil` when the condition is false, and `ifFalse:` answers
93
- `nil` when the condition is true.
94
- - Use `ifNotNil:` for local nil traversal when a boundary API can genuinely
95
- return `nil` and the next step is asking the non-nil object for a value.
96
- - Prefer presence-aware lookup messages over lookup-to-nil followed by a nil
97
- check. Use `ifPresent:` or `ifPresent:ifAbsent:` variants when they keep the
98
- present case local; add `ifAbsent: [ ]` when absence should be an explicit
99
- no-op.
100
- - Keep simple boolean predicates simple. Expressions such as
101
- `value notNil and: [ value isReady ]` are idiomatic when the result is a
102
- boolean. Do not rewrite them into `ifNil:/ifNotNil:` only to return a
103
- boolean literal from one branch.
104
- - Remove nil-only branches from nil traversal. Both `receiver ifNil: [ nil ]
105
- ifNotNil: [ ... ]` and `receiver ifNotNil: [ ... ] ifNil: [ nil ]` should
106
- normally become `receiver ifNotNil: [ ... ]`.
107
- - Avoid defensive type or protocol checks in private helpers unless the helper
108
- is an explicit boundary. Let incorrect callers fail or validate at the
109
- boundary with a named policy.
110
- - Prefer a direct send to a known collaborator over a defensive wrapper. Add a
111
- wrapper or extension after concrete variation appears, not before.
112
-
113
- ## Review Smells
114
-
115
- Scan for:
116
-
117
- - duplicated sends in both conditional branches when only one receiver or
118
- argument changes;
119
- - dependent work performed before a guard proves the value is present or valid;
120
- - assignment embedded inside boolean conditions;
121
- - repeated `isNotNil` checks where `ifNotNil:` would express local nil
122
- traversal;
123
- - lookup with `ifAbsent: [ nil ]` followed by a nil check where an
124
- `ifPresent:` variant can express the positive path directly;
125
- - `ifNil:/ifNotNil:` expressions that return only `true` or `false` from one
126
- branch and would read more directly as a boolean condition;
127
- - `ifNil: [ nil ] ifNotNil: [...]` or `ifNotNil: [...] ifNil: [ nil ]`
128
- branches where plain `ifNotNil:` communicates the same behavior;
129
- - collection pipelines that allocate intermediate collections only to
130
- immediately convert, sort, query emptiness, take a first match, or group
131
- values manually;
132
- - `select:`, `reject:`, or `collect:` immediately followed by `do:` when a
133
- `thenDo:` variant would avoid the intermediate collection;
134
- - sorting through conversion chains instead of sorting a result array directly;
135
- - defensive type checks in private helpers that hide caller bugs;
136
- - cascaded stream writes, where `stream << a; << b` says what `stream << a << b`
137
- says with more punctuation, since `<<` answers the stream;
138
- - wrapper methods or extensions that exist only because a collaborator might be
139
- wrong someday;
140
- - dense nested expressions that would be clearer with a temporary or extracted
141
- method.