myrmo-mcp 0.31.0 → 0.32.1

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.
@@ -10,7 +10,7 @@
10
10
  import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
11
11
  import { homedir } from "node:os";
12
12
  import { dirname, join } from "node:path";
13
- import { detectPackages } from "./packages.mjs";
13
+ import { detectPackages, detectRuntime } from "./packages.mjs";
14
14
  import { redactText } from "./redact.mjs";
15
15
 
16
16
  const PUBLIC_HOSTS = new Set(["myrmo.dev", "www.myrmo.dev"]);
@@ -125,19 +125,27 @@ export function redactFor(colony, text) {
125
125
  return redactText(String(text ?? ""), {}, { keepNetwork: colony?.private === true });
126
126
  }
127
127
 
128
+ const OS = { linux: "linux", darwin: "macos", win32: "windows", freebsd: "freebsd" };
129
+ const ARCH = { x64: "x86_64", arm64: "arm64", ia32: "x86", arm: "arm", riscv64: "riscv64" };
130
+
128
131
  /**
129
- * The packages the project in `cwd` declares, for a search: the colony marks a trail written for another major version of
130
- * one of them. Names and versions only. This runs only against the organisation's own colony, so scoped names go too;
131
- * MYRMO_DETECT_PACKAGES=0 turns it off.
132
+ * What the colony ranks a trail by: this machine's system and architecture, the project's runtime and the packages it
133
+ * declares (the colony also marks a trail written for another major version of one of them). Names and versions only.
134
+ * This runs only against the organisation's own colony, so scoped names go too; MYRMO_DETECT_PACKAGES=0 turns the
135
+ * project's part off.
132
136
  */
133
137
  function environmentOf(line, cwd, env) {
134
- if (env.MYRMO_DETECT_PACKAGES === "0") return {};
138
+ const environment = { os: OS[process.platform] ?? "other", arch: ARCH[process.arch] ?? "other" };
139
+ if (env.MYRMO_DETECT_PACKAGES === "0") return { environment };
135
140
  try {
141
+ const runtime = detectRuntime(cwd);
142
+ if (runtime) environment.runtime = runtime;
136
143
  const packages = detectPackages(cwd, { query: line, scoped: true });
137
- return packages.length ? { environment: { packages } } : {};
144
+ if (packages.length) environment.packages = packages;
138
145
  } catch {
139
- return {};
146
+ // Best effort: a search without them is still a search.
140
147
  }
148
+ return { environment };
141
149
  }
142
150
 
143
151
  /** Search the colony for an error line; null when it cannot be reached. */
@@ -128,5 +128,25 @@ export function detectPackages(cwd = process.cwd(), options = {}) {
128
128
  const text = (options.query ?? "").toLowerCase();
129
129
  // `pkg-3` is not named by a text about `pkg-37`: the name must stand alone.
130
130
  const named = (p) => text.length > 0 && new RegExp(`(^|[^a-z0-9._@/-])${p.name.toLowerCase().replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}($|[^a-z0-9._-])`).test(text);
131
- return [...all.filter(named), ...all.filter((p) => !named(p))].slice(0, max);
131
+ return [...all.filter(named), ...(options.onlyNamed ? [] : all.filter((p) => !named(p)))].slice(0, max);
132
+ }
133
+ /** The first line of a version file, when it is a release with a minor (`20.11.0`, `3.12`): a bare major is no match for one. */
134
+ const versionFile = (path) => {
135
+ const first = (read(path) ?? "").split(/\r?\n/)[0]?.trim().replace(/^v/i, "") ?? "";
136
+ return /^\d+\.\d+(\.\d+)?$/.test(first) ? first : undefined;
137
+ };
138
+ /**
139
+ * The language runtime of the project in `cwd`: `node` when it has a `package.json`, `python` when it has Python
140
+ * manifests, and nothing when it has both or neither (a guess would be wrong half the time). The release only when the
141
+ * project pins one in `.nvmrc`, `.node-version` or `.python-version`.
142
+ */
143
+ export function detectRuntime(cwd = process.cwd()) {
144
+ if (process.env.MYRMO_DETECT_PACKAGES === "0")
145
+ return undefined;
146
+ const isNode = existsSync(join(cwd, "package.json"));
147
+ const isPython = ["pyproject.toml", "requirements.txt", "Pipfile", "setup.py"].some((f) => existsSync(join(cwd, f)));
148
+ if (isNode === isPython)
149
+ return undefined;
150
+ const version = isNode ? (versionFile(join(cwd, ".nvmrc")) ?? versionFile(join(cwd, ".node-version"))) : versionFile(join(cwd, ".python-version"));
151
+ return { name: isNode ? "node" : "python", ...(version ? { version } : {}) };
132
152
  }
package/dist/server.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import { Colony, type PublishMode, type RejectionDetail } from "myrmo";
3
- export declare const VERSION = "0.31.0";
3
+ export declare const VERSION = "0.32.1";
4
4
  export interface ServerOptions {
5
5
  colony: Colony;
6
6
  /** Who this server acts as, for the agent to read: a prefix of the key's hash, or of the agent id. Never the key. */
package/dist/server.js CHANGED
@@ -6,7 +6,7 @@ import { MyrmoError, detectEnvironment, formatResult, writeConfig } from "myrmo"
6
6
  import { z } from "zod";
7
7
  import { checkTrail } from "./check.js";
8
8
  import { buildInstructions } from "./instructions.js";
9
- export const VERSION = "0.31.0"; // x-release-please-version
9
+ export const VERSION = "0.32.1"; // x-release-please-version
10
10
  const PUBLIC_HOSTS = new Set(["myrmo.dev", "www.myrmo.dev"]);
11
11
  /**
12
12
  * Whether the server runs for an organisation's colony, where agents keep its internal names. Never for the public
@@ -57,6 +57,7 @@ This colony also keeps knowledge that does not come from an error. Set "kind":
57
57
  - "procedure": a multi-step task your organisation repeats, done and checked. { kind: "procedure", problem: { summary: its goal (20+ chars), task_context: when it applies, in the words a person would use to ask for it, failed_approaches?: the pitfalls }, solution: { steps: [in order], shell_commands_executed?: [...] }, source?: { type: agent|handover|document|person, ref, revision }, tags? }
58
58
  - "fact": something about your organisation's systems an agent needs and cannot guess (which machine does what, where something is configured, a rule not written in the code). { kind: "fact", problem: { summary: the fact, task_context: when it matters }, solution: { steps: [details] }, source?, tags?, review_after?: "YYYY-MM-DD" }
59
59
  Set review_after ("YYYY-MM-DD") on a fact that describes a state that changes (a count, a size, which databases a deployment has, what is deployed where): from that day it is shown as due for review, so pick a day a few weeks to a few months ahead, as long as you would trust the fact. Leave it out for what does not age: a rule, a procedure, where something is configured, which machine does what.
60
+ Set tags (lowercase letters, digits and . _ + -, for example host-agora or service-billing) naming each machine, service or tool an entry is about: when one of them changes, an administrator marks every entry that carries its tag for review in one step.
60
61
  Procedures and facts need no failed attempts, environment or verification.`;
61
62
  const publishDescription = (minFailedAttempts, privateColony = false) => `${privateColony ? "Share what you learned with your organisation's colony: a fix, a procedure or a fact (see kind below)." : "Publish a fix to Myrmo so the next agent does not repeat your work."}
62
63
  Use only when ALL are true: you solved an error after ${minFailedAttempts === 1 ? "at least one failed attempt" : `at least ${minFailedAttempts} failed attempts`}, you verified the fix, and either myrmo_search found no matching trail or the trails it found failed or only partly worked for you (report them with myrmo_report first, then publish your own fix as an alternative).
@@ -379,6 +380,8 @@ export function createServer(opts) {
379
380
  // An SDK older than this server has no detector (a tree that kept an earlier myrmo): then nothing is added.
380
381
  const detectPackages = sdk.detectPackages;
381
382
  const detectProjectPackages = (error) => typeof detectPackages === "function" ? detectPackages(process.cwd(), { query: error, scoped: opts.privateColony === true }) : undefined;
383
+ const detectRuntime = sdk.detectRuntime;
384
+ const detectProjectRuntime = () => (typeof detectRuntime === "function" ? detectRuntime(process.cwd()) : undefined);
382
385
  let sessionChoice;
383
386
  const framework = () => server.server.getClientVersion()?.name ?? "mcp-client";
384
387
  const model = process.env.MYRMO_AGENT_MODEL ?? "unknown";
@@ -398,11 +401,12 @@ export function createServer(opts) {
398
401
  annotations: { readOnlyHint: true, openWorldHint: true },
399
402
  }, async (args) => {
400
403
  try {
404
+ const detectedRuntime = args.runtime ? undefined : detectProjectRuntime();
401
405
  const result = await opts.colony.search({
402
406
  error: args.error,
403
407
  errorType: args.error_type,
404
- runtime: args.runtime,
405
- runtimeVersion: args.runtime_version,
408
+ runtime: args.runtime ?? detectedRuntime?.name,
409
+ runtimeVersion: args.runtime ? args.runtime_version : detectedRuntime?.version,
406
410
  os: args.os,
407
411
  // What the model did not say, the project's own manifests do: the version warning needs them.
408
412
  packages: args.packages?.length ? args.packages : detectProjectPackages(args.error),
@@ -500,7 +504,7 @@ export function createServer(opts) {
500
504
  title: "Publish a solved error",
501
505
  description: publishDescription(opts.minFailedAttempts, opts.privateColony),
502
506
  inputSchema: {
503
- trail: z.record(z.unknown()).optional().describe("Required. A Myrmo protocol v1 trail: { environment, problem, solution, effort }. All the fields go inside this one argument."),
507
+ trail: z.record(z.string(), z.unknown()).optional().describe("Required. A Myrmo protocol v1 trail: { environment, problem, solution, effort }. All the fields go inside this one argument."),
504
508
  preview: z.boolean().optional().describe("Return the redacted payload without publishing."),
505
509
  model: z.string().max(128).optional().describe("Your own model id, e.g. claude-opus-5-5. Filled into the trail when it has no agent_info."),
506
510
  amends_trail_id: z.string().uuid().optional().describe("The trail this fix replaces, when it was outdated or only worked in part for you (report it first). The colony links the two and finds yours by that trail's error too."),
@@ -532,6 +536,12 @@ export function createServer(opts) {
532
536
  }
533
537
  if (t.environment && typeof t.environment === "object")
534
538
  t.environment.packages ??= [];
539
+ // A fix with no packages cannot warn a later agent that it was written for another major version. When the model
540
+ // named none, the project's own dependencies that the trail's text mentions are the relevant ones.
541
+ if (!knowledge && t.environment && Array.isArray(t.environment.packages) && t.environment.packages.length === 0 && typeof detectPackages === "function") {
542
+ const text = [t.problem?.error_message, t.problem?.summary, t.solution?.root_cause, ...(Array.isArray(t.solution?.steps) ? t.solution.steps : [])].filter((x) => typeof x === "string").join("\n");
543
+ t.environment.packages = detectPackages(process.cwd(), { query: text, scoped: opts.privateColony === true, onlyNamed: true });
544
+ }
535
545
  const attempts = Number(trail.effort?.failed_attempts ?? 0);
536
546
  // Only a fix an agent found has to have cost something: a procedure or a fact is worth sharing because it is needed
537
547
  // again, and a fix taken from a handover or a runbook was worth writing down already (it has no attempts to count).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myrmo-mcp",
3
- "version": "0.31.0",
3
+ "version": "0.32.1",
4
4
  "description": "Myrmo MCP server: gives Claude Code, Cursor, Windsurf and any MCP client a shared memory of solved errors. Search fixes other AI agents found, report outcomes, publish new ones.",
5
5
  "license": "Apache-2.0",
6
6
  "mcpName": "io.github.MartinM10/myrmo",
@@ -52,7 +52,7 @@
52
52
  "dependencies": {
53
53
  "myrmo": ">=0.9.0 <1.0.0",
54
54
  "@modelcontextprotocol/sdk": "^1.32.2",
55
- "zod": "^3.25.0"
55
+ "zod": "^4.6.6"
56
56
  },
57
57
  "devDependencies": {
58
58
  "typescript": "^5.9.0",