@evref-bl/pharo-mcp 0.0.0-stage → 0.0.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 (31) hide show
  1. package/README.md +79 -2
  2. package/bin/pharo-mcp.js +22 -0
  3. package/node/index.js +1 -0
  4. package/node/installer.js +151 -0
  5. package/package.json +33 -4
  6. package/templates/.claude/mcp.json +8 -0
  7. package/templates/.codex/config.toml +4 -0
  8. package/templates/.opencode/opencode.json +10 -0
  9. package/templates/pharo-references/debugger-driven-development.md +101 -0
  10. package/templates/pharo-references/debugging.md +147 -0
  11. package/templates/pharo-references/getting-started.md +143 -0
  12. package/templates/pharo-references/pharo-coding-rules.md +147 -0
  13. package/templates/pharo-references/pharo-coding-style.md +139 -0
  14. package/templates/pharo-references/safety-and-ecosystem.md +256 -0
  15. package/templates/pharo-references/source-vs-live-image.md +75 -0
  16. package/templates/pharo-references/tool-reference.md +273 -0
  17. package/templates/pharo-references/troubleshooting.md +137 -0
  18. package/templates/pharo-references/using-pharo-mcp.md +156 -0
  19. package/templates/pharo-skills/pharo-ci-repro/SKILL.md +46 -0
  20. package/templates/pharo-skills/pharo-ci-repro/agents/openai.yaml +4 -0
  21. package/templates/pharo-skills/pharo-ci-repro/references/pharo-smalltalkci.md +102 -0
  22. package/templates/pharo-skills/pharo-ci-repro/scripts/run-smalltalkci-docker.sh +172 -0
  23. package/templates/pharo-skills/pharo-image-git-handoff/SKILL.md +37 -0
  24. package/templates/pharo-skills/pharo-image-git-handoff/agents/openai.yaml +4 -0
  25. package/templates/pharo-skills/pharo-mcp-recovery/SKILL.md +34 -0
  26. package/templates/pharo-skills/pharo-mcp-recovery/agents/openai.yaml +4 -0
  27. package/templates/pharo-skills/pharo-project-load/SKILL.md +47 -0
  28. package/templates/pharo-skills/pharo-project-load/agents/openai.yaml +4 -0
  29. package/templates/pharo-skills/pharo-version-compat/SKILL.md +57 -0
  30. package/templates/pharo-skills/pharo-version-compat/agents/openai.yaml +4 -0
  31. package/templates/pharo.AGENTS.md +42 -0
@@ -0,0 +1,102 @@
1
+ # Pharo smalltalkCI Log Reading Notes
2
+
3
+ Use this reference after a local Docker/smalltalkCI run has produced logs.
4
+
5
+ ## Phase Boundaries
6
+
7
+ smalltalkCI logs usually split into:
8
+
9
+ 1. Preparing folders.
10
+ 2. Starting Pharo build.
11
+ 3. Downloading image and VM.
12
+ 4. Preparing image and loading SmalltalkCI.
13
+ 5. Loading project.
14
+ 6. Testing project.
15
+ 7. Coverage/upload/teardown.
16
+
17
+ If the crash happens after `Testing project...`, project code loaded. If it
18
+ happens during `Loading project...`, inspect the last Metacello package loaded
19
+ and the first missing global/class/selector.
20
+
21
+ ## Useful Evidence To Extract
22
+
23
+ - `Image Information`, including `Pharo13.1.0SNAPSHOT` or similar.
24
+ - Build information SHA.
25
+ - VM version, when printed.
26
+ - The first test class/method named before a failure.
27
+ - The first Smalltalk exception, before any secondary cleanup failure.
28
+ - For segfaults, both the native C frames and the Smalltalk frames immediately
29
+ above the crash.
30
+
31
+ ## Focused Config Pattern
32
+
33
+ To narrow a failing class while preserving the same load path, create a
34
+ temporary config next to `.smalltalk.ston`:
35
+
36
+ ```ston
37
+ SmalltalkCISpec {
38
+ #loading : [
39
+ SCIMetacelloLoadSpec {
40
+ #baseline : 'MyProject',
41
+ #directory : 'src',
42
+ #ignoreImage : true,
43
+ #onConflict : #useIncoming,
44
+ #onUpgrade : #useIncoming
45
+ }
46
+ ],
47
+ #testing : {
48
+ #classes : [
49
+ #MyProjectSuspectTest
50
+ ],
51
+ #hidePassingTests : true,
52
+ #failOnZeroTests : true
53
+ }
54
+ }
55
+ ```
56
+
57
+ Adjust the baseline, directory, and class for the project under test.
58
+
59
+ ## Pharo 13 / Iceberg / libgit2 Pattern
60
+
61
+ In a Pharo MCP investigation on 2026-05-16, a P13 flaky CI crash reproduced
62
+ locally inside Docker. It was not a dependency download issue: loading
63
+ completed and testing had started.
64
+
65
+ Crash signatures included:
66
+
67
+ - C stack in `libgit2.so.1.4.4`
68
+ - `git_repository_head_unborn`
69
+ - `git_commit_lookup`
70
+ - Smalltalk frames through `IceLibgitRepository`, `IceRepository>>headCommit`,
71
+ or `IceRepository>>validateCanCommit`
72
+ - Test frames in a repository-management test
73
+
74
+ The practical mitigation was to avoid unnecessary test-side `repository
75
+ headCommit` reads and skip a P13 test that deliberately forced empty libgit2
76
+ config values for a P12-only fallback path.
77
+
78
+ General lesson: if a Pharo 13 Linux CI segfault points into libgit2 while
79
+ testing fresh temporary repositories, treat it as a native stability surface.
80
+ Avoid poking Iceberg head/commit metadata in tests unless the assertion is
81
+ essential.
82
+
83
+ ## Interpreting Common Noise
84
+
85
+ - `fatal: not a git repository`: often harmless when running smalltalkCI from a
86
+ scratch copy without `.git`. It matters only if the failing behavior depends
87
+ on Git metadata.
88
+ - Metacello SSH authentication warnings followed by HTTPS fallback: often
89
+ harmless in Docker if the dependency eventually loads.
90
+ - `StackOverflow` after a segfault: often VM aftermath, not the root cause.
91
+ - `NewUndeclaredWarning`: can be benign during dependency load, but if it names
92
+ a project class/global required by the current package, investigate.
93
+
94
+ ## Verification Discipline
95
+
96
+ After a fix:
97
+
98
+ - Run the failing Pharo platform full suite.
99
+ - Run adjacent supported platforms, usually P12 and P13 for MCP.
100
+ - Run focused repeats for the flaky class/method if the original failure was
101
+ intermittent.
102
+ - Keep the captured failing log path in the report.
@@ -0,0 +1,172 @@
1
+ #!/usr/bin/env bash
2
+ set -u
3
+
4
+ usage() {
5
+ cat <<'USAGE'
6
+ Usage:
7
+ run-smalltalkci-docker.sh --repo REPO_DIR [options]
8
+
9
+ Options:
10
+ --repo DIR Source repository or working tree to test.
11
+ --platform NAME smalltalkCI platform, default Pharo64-13.
12
+ --spec FILE smalltalkCI spec file, default .smalltalk.ston.
13
+ --attempts N Number of attempts, default 1.
14
+ --out DIR Scratch/log directory, default /tmp/pharo-ci-repro-<timestamp>.
15
+ --image IMAGE Docker image, default hpiswa/smalltalkci:24.04.
16
+ --docker-platform PLATFORM
17
+ Docker platform, default linux/amd64.
18
+ --include-git Copy .git into each scratch tree.
19
+ --keep-going Continue after failures instead of stopping at first one.
20
+ --help Show this help.
21
+
22
+ Each attempt gets a fresh copied work tree and a log at OUT/logs/attempt-N.log.
23
+ USAGE
24
+ }
25
+
26
+ repo=""
27
+ platform="Pharo64-13"
28
+ spec=".smalltalk.ston"
29
+ attempts="1"
30
+ out=""
31
+ image="hpiswa/smalltalkci:24.04"
32
+ docker_platform="linux/amd64"
33
+ include_git="false"
34
+ keep_going="false"
35
+
36
+ while [ "$#" -gt 0 ]; do
37
+ case "$1" in
38
+ --repo)
39
+ repo="${2:-}"
40
+ shift 2
41
+ ;;
42
+ --platform)
43
+ platform="${2:-}"
44
+ shift 2
45
+ ;;
46
+ --spec)
47
+ spec="${2:-}"
48
+ shift 2
49
+ ;;
50
+ --attempts)
51
+ attempts="${2:-}"
52
+ shift 2
53
+ ;;
54
+ --out)
55
+ out="${2:-}"
56
+ shift 2
57
+ ;;
58
+ --image)
59
+ image="${2:-}"
60
+ shift 2
61
+ ;;
62
+ --docker-platform)
63
+ docker_platform="${2:-}"
64
+ shift 2
65
+ ;;
66
+ --include-git)
67
+ include_git="true"
68
+ shift
69
+ ;;
70
+ --keep-going)
71
+ keep_going="true"
72
+ shift
73
+ ;;
74
+ --help|-h)
75
+ usage
76
+ exit 0
77
+ ;;
78
+ *)
79
+ echo "Unknown argument: $1" >&2
80
+ usage >&2
81
+ exit 2
82
+ ;;
83
+ esac
84
+ done
85
+
86
+ if [ -z "$repo" ]; then
87
+ echo "--repo is required" >&2
88
+ usage >&2
89
+ exit 2
90
+ fi
91
+
92
+ if [ ! -d "$repo" ]; then
93
+ echo "Repo directory does not exist: $repo" >&2
94
+ exit 2
95
+ fi
96
+
97
+ case "$attempts" in
98
+ ''|*[!0-9]*)
99
+ echo "--attempts must be a positive integer" >&2
100
+ exit 2
101
+ ;;
102
+ esac
103
+
104
+ if [ "$attempts" -lt 1 ]; then
105
+ echo "--attempts must be at least 1" >&2
106
+ exit 2
107
+ fi
108
+
109
+ if ! command -v docker >/dev/null 2>&1; then
110
+ echo "Docker CLI not found. Install a container runtime that provides the Docker CLI/API, or use a local smalltalkCI fallback." >&2
111
+ exit 69
112
+ fi
113
+
114
+ if ! docker info >/dev/null 2>&1; then
115
+ echo "Docker API is not reachable. Start or repair the local container runtime, then retry this command." >&2
116
+ echo "If container reproduction is not available and the failure is not OS/runtime-sensitive, use a local smalltalkCI fallback with isolated smalltalkCI homes for parallel jobs." >&2
117
+ exit 69
118
+ fi
119
+
120
+ if [ -z "$out" ]; then
121
+ out="/tmp/pharo-ci-repro-$(date +%Y%m%d%H%M%S)"
122
+ fi
123
+
124
+ mkdir -p "$out/logs"
125
+
126
+ echo "Source: $repo"
127
+ echo "Platform: $platform"
128
+ echo "Spec: $spec"
129
+ echo "Attempts: $attempts"
130
+ echo "Output: $out"
131
+ echo "Docker platform: $docker_platform"
132
+ echo
133
+
134
+ status=0
135
+ i=1
136
+ while [ "$i" -le "$attempts" ]; do
137
+ work="$out/work-$i"
138
+ log="$out/logs/attempt-$i.log"
139
+ rm -rf "$work"
140
+ mkdir -p "$work"
141
+
142
+ if [ "$include_git" = "true" ]; then
143
+ rsync -a --exclude coverage "$repo"/ "$work"/
144
+ else
145
+ rsync -a --exclude .git --exclude coverage "$repo"/ "$work"/
146
+ fi
147
+
148
+ echo "=== Attempt $i/$attempts ==="
149
+ echo "Log: $log"
150
+
151
+ docker run --rm --platform "$docker_platform" \
152
+ -v "$work:/work/project" \
153
+ -w /work/project \
154
+ "$image" \
155
+ smalltalkci -s "$platform" "$spec" 2>&1 | tee "$log"
156
+
157
+ attempt_status="${PIPESTATUS[0]}"
158
+ if [ "$attempt_status" -ne 0 ]; then
159
+ echo "Attempt $i failed with status $attempt_status"
160
+ echo "Failure log: $log"
161
+ status="$attempt_status"
162
+ if [ "$keep_going" != "true" ]; then
163
+ exit "$status"
164
+ fi
165
+ else
166
+ echo "Attempt $i passed"
167
+ fi
168
+
169
+ i=$((i + 1))
170
+ done
171
+
172
+ exit "$status"
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: pharo-image-git-handoff
3
+ description: Reconcile live Pharo, Iceberg, Tonel, and Git state before exporting, reviewing, committing, or pushing image-side changes. Use for dirty or detached Iceberg state, linked worktrees, package-membership mismatches, and image-to-Git delivery.
4
+ ---
5
+
6
+ # Pharo Image Git Handoff
7
+
8
+ Image objects, Tonel files, Iceberg working copies, and Git refs are distinct.
9
+ A clean Git worktree does not prove the image is clean, and an Iceberg diff does
10
+ not prove files changed on disk.
11
+
12
+ ## Workflow
13
+
14
+ 1. Inspect the image repository with Pharo MCP tools: identity, location,
15
+ branch/head, source directory, package membership, and modified packages.
16
+ 2. Inspect disk with read-only Git commands: `git status --short --branch`,
17
+ `git diff`, and `git remote -v`.
18
+ 3. Export only for an intended Tonel/Git handoff. Verify repository identity and
19
+ inspect the image-side change list first.
20
+ 4. After export, recheck Iceberg and Git. Review every changed Tonel, project,
21
+ and documentation path.
22
+ 5. Commit only the intended diff. Push only when explicitly requested or
23
+ clearly approved.
24
+
25
+ ## Stop Before Mutation
26
+
27
+ Stop and diagnose detached or missing heads, wrong branches/remotes, duplicate
28
+ repository names, source-directory or package-membership mismatches, linked
29
+ worktree confusion, and unexplained disagreement between Git and Iceberg.
30
+
31
+ Adopt the current Git HEAD only when the image contents are known to match it.
32
+ Ask the user before resolving real divergence or discarding image changes.
33
+
34
+ ## Report
35
+
36
+ Report image repository state before and after export, why export was needed,
37
+ Git branch/status and diff summary, checks run, and unresolved ambiguity.
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "Pharo Image Git Handoff"
3
+ short_description: "Export Pharo image changes safely"
4
+ default_prompt: "Use $pharo-image-git-handoff to turn these Pharo image changes into clean Tonel/Git changes safely."
@@ -0,0 +1,34 @@
1
+ ---
2
+ name: pharo-mcp-recovery
3
+ description: Recover an unreachable or crashed standalone Pharo MCP image while preserving logs, image files, changes, repository state, and Epicea history. Use for local MCP restart, replacement-image creation, and image-side change recovery.
4
+ ---
5
+
6
+ # Pharo MCP Recovery
7
+
8
+ Use project-managed lifecycle tools when they exist. This workflow is for a
9
+ standalone image without a safer environment-specific recovery surface.
10
+
11
+ ## Workflow
12
+
13
+ 1. Determine whether the failure is the client route, MCP server, image, or
14
+ process.
15
+ 2. Preserve the image, changes, sources, VM logs, launch command, MCP URL, and
16
+ repository/Git facts before mutation.
17
+ 3. Restart the same image first. Inspect `isRunning`, `isListening`, and
18
+ `localUrlString`; restart the existing MCP instance when possible.
19
+ 4. Create a replacement image only after preserving the original. Use
20
+ `pharo-project-load` to restore MCP and the target project.
21
+ 5. Recover changes by inspecting Epicea history before confirmed application.
22
+ Use `pharo-image-git-handoff` before repository attachment or Tonel export.
23
+ 6. Verify the recovered behavior with focused inspection or tests.
24
+
25
+ ## Stop And Ask
26
+
27
+ Ask before deleting images, resetting repositories, discarding changes,
28
+ checking out a branch that changes loaded packages, or applying ambiguous
29
+ history entries.
30
+
31
+ ## Report
32
+
33
+ Report the failure boundary, evidence preserved, image used, restart/recovery
34
+ actions, recovered behavior, checks run, and unrecovered state.
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "Pharo MCP Recovery"
3
+ short_description: "Recover a stopped Pharo MCP image"
4
+ default_prompt: "Use $pharo-mcp-recovery to restart Pharo MCP and recover image changes."
@@ -0,0 +1,47 @@
1
+ ---
2
+ name: pharo-project-load
3
+ description: Load or smoke-test a Pharo project from Tonel, Metacello, or Iceberg and diagnose baseline, branch, source-directory, group, dependency, or version-specific load failures. Use for fresh-image loads and CI-equivalent project loading.
4
+ ---
5
+
6
+ # Pharo Project Load
7
+
8
+ ## Context
9
+
10
+ Before loading, read the project README, baseline, `.smalltalk.ston`, and any
11
+ repository-specific agent guidance. Prefer dedicated Pharo MCP load tools when
12
+ a live image is available.
13
+
14
+ ## Workflow
15
+
16
+ 1. Identify the Pharo version, repository URL/path, branch or commit, source
17
+ directory, baseline name, and required load group.
18
+ 2. Confirm that `BaselineOf<Name>` and the Tonel packages exist under the
19
+ selected source directory. Check that repository URLs and `.project` agree.
20
+ 3. Load the default baseline first. Specify a group only when project or CI
21
+ configuration requires it.
22
+ 4. Verify loaded packages/classes and run focused or project tests.
23
+ 5. Inspect Iceberg state when later edits or export are in scope.
24
+
25
+ Minimal remote load:
26
+
27
+ ```smalltalk
28
+ Metacello new
29
+ baseline: 'MyProject';
30
+ repository: 'github://Owner/MyProject:main/src';
31
+ load
32
+ ```
33
+
34
+ For local Tonel, use an absolute `tonel:///.../src` URL.
35
+
36
+ ## Diagnose By Phase
37
+
38
+ - Baseline/package not found: verify branch and source directory.
39
+ - Missing global/class/selector: compare the project API surface with the
40
+ target Pharo version; use `pharo-version-compat` when appropriate.
41
+ - Metacello conflict: reproduce the project's documented or CI conflict policy.
42
+ - Native or CI-only failure: reproduce once, then use `pharo-ci-repro`.
43
+
44
+ ## Report
45
+
46
+ Report the Pharo version, repository and revision, source directory, baseline,
47
+ group, load result, verification result, and first meaningful failure.
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "Pharo Project Load"
3
+ short_description: "Load Pharo Tonel projects"
4
+ default_prompt: "Use $pharo-project-load to load this Pharo project into an image and diagnose any Metacello or Tonel load failures."
@@ -0,0 +1,57 @@
1
+ ---
2
+ name: pharo-version-compat
3
+ description: Use PharoCompatibility to load and test a project across supported Pharo versions. Use for missing or renamed Pharo globals, classes, selectors, packages, notices, or semantics; baseline surface selection; and reusable cross-version shims.
4
+ ---
5
+
6
+ # Pharo Version Compatibility
7
+
8
+ ## Model
9
+
10
+ `PharoCompatibility` handles Pharo-version differences, not library-specific
11
+ workarounds. A project declares the Pharo API surface its source expects; the
12
+ runtime loads the compatibility packages needed by the current image.
13
+
14
+ Known source surfaces include `Pharo12Surface` and `Pharo13Surface`. Omit a
15
+ surface only when the project needs the core helper API alone.
16
+
17
+ ## Workflow
18
+
19
+ 1. Read the project baseline, supported-version policy, and CI matrix.
20
+ 2. Identify the source Pharo surface and target runtime versions.
21
+ 3. Load the matching surface from the project baseline:
22
+
23
+ ```smalltalk
24
+ spec
25
+ baseline: 'PharoCompatibility'
26
+ with: [
27
+ spec
28
+ repository: 'github://Evref-BL/PharoCompatibility:main/src';
29
+ loads: #( 'Pharo13Surface' ) ]
30
+ ```
31
+
32
+ 4. Reproduce on every affected Pharo version and classify the failure: missing
33
+ binding, missing selector, rename, semantic change, notice behavior, or
34
+ native/tooling failure.
35
+ 5. Choose the narrowest owner:
36
+ - transparent shim for equivalent APIs;
37
+ - explicit PharoCompatibility helper for reusable behavior;
38
+ - project abstraction for irreducible semantic differences;
39
+ - project-local fix for library-specific behavior.
40
+ 6. Verify both PharoCompatibility and the consuming project across the matrix.
41
+
42
+ ## Extending PharoCompatibility
43
+
44
+ - Confirm the difference is general and assign it to a source surface and
45
+ runtime version.
46
+ - Put runtime code in the matching conditional package and baseline group.
47
+ - Use late lookup for optional globals.
48
+ - Keep shims additive when possible and test the compatibility contract, not
49
+ only package loading.
50
+
51
+ Use `pharo-project-load` for load-path failures and `pharo-ci-repro` for
52
+ smalltalkCI or runner-specific failures.
53
+
54
+ ## Report
55
+
56
+ Report source surface, runtimes tested, failure classification, shim owner,
57
+ packages changed, and matrix results.
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "Pharo Version Compatibility"
3
+ short_description: "Use PharoCompatibility surfaces"
4
+ default_prompt: "Use $pharo-version-compat to make this Pharo project compatible across supported Pharo versions with PharoCompatibility."
@@ -0,0 +1,42 @@
1
+ # Pharo MCP Agent Guide
2
+
3
+ Use the configured `pharo` MCP server whenever a task depends on the running
4
+ image. Preserve unrelated changes and report unavailable live checks instead of
5
+ guessing from source.
6
+
7
+ ## Read First
8
+
9
+ - Inspect the tools and schemas exposed by the current client; do not rely on
10
+ remembered names.
11
+ - Prefer the least-mutating dedicated tool. Use `image_evaluate` only when no
12
+ dedicated tool fits.
13
+ - Treat image, Tonel, Iceberg, and Git state as separate.
14
+ - Successful mutating tools save the image; use a safe image boundary.
15
+
16
+ ## Context Loading
17
+
18
+ - Before Pharo source changes: read the project's Pharo coding and testing
19
+ guidance. If none exists, use the local
20
+ [coding rules](pharo-references/pharo-coding-rules.md) and
21
+ [coding style](pharo-references/pharo-coding-style.md).
22
+ - Before loading a project: use `skills/pharo-project-load/SKILL.md`.
23
+ - Before cross-version work: use `skills/pharo-version-compat/SKILL.md`.
24
+ - Before exporting image changes or changing Git state: use
25
+ `skills/pharo-image-git-handoff/SKILL.md`.
26
+ - Before reproducing smalltalkCI or GitHub failures: use
27
+ `skills/pharo-ci-repro/SKILL.md`.
28
+ - Before recovering a stopped standalone image: use
29
+ `skills/pharo-mcp-recovery/SKILL.md`.
30
+ - Before debugger sessions or repairs: read the local
31
+ [debugging guide](pharo-references/debugging.md).
32
+
33
+ ## Workflow
34
+
35
+ 1. Discover the exact tool and inspect the target with read-only calls.
36
+ 2. Preview or verify identity before risky mutation.
37
+ 3. Make the narrowest image-side change.
38
+ 4. Run focused SUnit tests and inspect the result.
39
+ 5. Use the handoff skill before exporting or committing Tonel changes.
40
+
41
+ For repository work, verify repository identity before mutation and inspect the
42
+ image-side diff before export or commit.