myrmo-mcp 0.28.3 → 0.29.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/dist/doctor.js CHANGED
@@ -51,7 +51,7 @@ export async function diagnose(input) {
51
51
  name: "Reaching the colony",
52
52
  detail: refused ? "the machine answered but nothing listens on that port" : `no answer (${ready.error})`,
53
53
  fix: refused
54
- ? "Ask whoever runs the colony whether it is up (bash deploy/private-colony.sh status on its machine)."
54
+ ? "Ask whoever runs the colony whether it is up."
55
55
  : "Check that you are on the team's network and that the address and port are right; from this machine try: curl " + input.url + "/readyz",
56
56
  });
57
57
  return checks;
@@ -260,16 +260,32 @@ export async function lookupTask(task, { env = process.env, settings = {}, fetch
260
260
 
261
261
  const KINDS = { procedure: "procedure", fact: "fact", fix: "known error" };
262
262
 
263
+ /**
264
+ * The hits worth showing unasked: a suggestion the agent did not ask for has to be clearly about the task, or it teaches
265
+ * the agent to ignore the next one. A hit below `min` is left out, and so is one far below the best (more than `spread`).
266
+ * Measured on an organisation's colony: the right entry scored 0.63 to 0.79, unrelated ones 0.55 to 0.59, so no single
267
+ * cut separates them, but the two together do. A hit without a score (an older colony) is kept.
268
+ */
269
+ export function relevantHits(results, { min = 0.6, spread = 0.15 } = {}) {
270
+ const score = (hit) => Number(hit?.match?.score);
271
+ const scored = results.filter((hit) => Number.isFinite(score(hit)));
272
+ if (!scored.length) return results;
273
+ const best = Math.max(...scored.map(score));
274
+ return results.filter((hit) => !Number.isFinite(score(hit)) || (score(hit) >= min && score(hit) >= best - spread));
275
+ }
276
+
263
277
  /**
264
278
  * The short list for the agent, and the state that lets the Stop hook ask for reports on what was shown. No note when
265
279
  * nothing matched.
266
280
  */
267
- export function briefNote(task, body, state = {}, now = Date.now(), how = "") {
281
+ export function briefNote(task, body, state = {}, now = Date.now(), how = "", { min = 0.6, spread = 0.15 } = {}) {
268
282
  // An entry already shown in this session is not shown again: the agent has it, and repeating an unrelated one on every
269
283
  // prompt is noise.
270
284
  const seen = Array.isArray(state.briefSeen) ? state.briefSeen : [];
271
285
  const idOf = (hit) => String(hit?.trail_id ?? "").replace(/[^0-9a-fA-F-]/g, "").slice(0, 36);
272
- const hits = (Array.isArray(body?.results) ? body.results : []).filter((hit) => !seen.includes(idOf(hit))).slice(0, 3);
286
+ const hits = relevantHits(Array.isArray(body?.results) ? body.results : [], { min, spread })
287
+ .filter((hit) => !seen.includes(idOf(hit)))
288
+ .slice(0, 3);
273
289
  if (!hits.length) return { note: null, state };
274
290
  const ids = [];
275
291
  const lines = hits.map((hit, i) => {
@@ -281,7 +297,9 @@ export function briefNote(task, body, state = {}, now = Date.now(), how = "") {
281
297
  const about = clip(t.problem?.summary || t.problem?.error_message || t.problem?.error_type, 160);
282
298
  const o = hit.outcomes ?? {};
283
299
  const strength = Number(hit.strength ?? 0);
284
- return `${i + 1}. [${kind}] ${about} (strength ${Number.isFinite(strength) ? strength.toFixed(2) : "?"}, worked ${num(o.worked, "0")}, failed ${num(o.failed, "0")}) id ${id}`;
300
+ const due = /^\d{4}-\d{2}-\d{2}$/.exec(String(hit.review_due ?? ""))?.[0];
301
+ const review = due ? ` [review due since ${due}: may be out of date]` : "";
302
+ return `${i + 1}. [${kind}] ${about} (strength ${Number.isFinite(strength) ? strength.toFixed(2) : "?"}, worked ${num(o.worked, "0")}, failed ${num(o.failed, "0")})${review} id ${id}`;
285
303
  });
286
304
  const note = [
287
305
  "Myrmo (your organisation's private colony) already has knowledge that may help with this task:",
@@ -21,7 +21,7 @@
21
21
  // 5. After a failed command, the hook searches the colony itself and shows a strong match (lookup.mjs).
22
22
  // 6. When the user sends a request, the hook asks the colony what the organisation already knows about that task and
23
23
  // shows a short list (UserPromptSubmit; lookup.mjs `briefNote`). MYRMO_HOOK_BRIEF=off turns only this off.
24
- // 7. When the agent stops after a turn in which commands failed or knowledge was shown, it is asked once to report what
24
+ // 7. (In the public colony too, only for trails shown and not reported on.) When the agent stops after a turn in which commands failed or knowledge was shown, it is asked once to report what
25
25
  // it relied on and to share what the next person's agent would need (Stop hook): what is learned in a session
26
26
  // otherwise leaves with it.
27
27
  //
@@ -51,6 +51,7 @@ const SHELLS = new Set(["Bash", "PowerShell"]);
51
51
  const SEARCH_TOOL = /^mcp__.*myrmo_search$/;
52
52
  const REPORT_TOOL = /^mcp__.*myrmo_report$/;
53
53
  const PUBLISH_TOOL = /^mcp__.*myrmo_publish$/;
54
+ const BRIEF_TOOL = /^mcp__.*myrmo_brief$/;
54
55
  // The id each trail is listed under in a search reply (`## Trail 1 of 2 · id <uuid>`).
55
56
  const TRAIL_ID = /^## Trail \d+ of \d+ · id ([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i;
56
57
 
@@ -183,6 +184,29 @@ function segmentsWithPipes(text) {
183
184
  return out.map((w) => w.filter((x) => !/^\d*[<>]&?\d*$/.test(x) && !/^\d*>&\d+$/.test(x)));
184
185
  }
185
186
 
187
+ // A tool saying it was called wrongly (a mistyped flag): the agent's own slip, fixed by reading the line, not knowledge to
188
+ // look up or share.
189
+ const USAGE_LINE = /\b(?:unknown (?:shorthand )?flag|unknown option|unrecognized option|invalid option|illegal option)\b|^\s*usage:/im;
190
+
191
+ /** Whether the command ends in a test whose "false" is an answer: `... ; [ -f x ] && echo found`, also as the last
192
+ * statement of a loop body. Exit 1 then says the condition did not hold, not that anything failed. */
193
+ export function endsInTest(command) {
194
+ const body = String(command).trim().replace(/(?:\s*;?\s*\b(?:done|fi)\b)+\s*$/, "");
195
+ const last = body.split(/;|\n|\bdo\b|\bthen\b/).at(-1)?.trim() ?? "";
196
+ // After `||` or a pipe the exit code is another command's: `test -d x || mkdir x` failing is mkdir failing.
197
+ if (/\|/.test(last)) return false;
198
+ const isTest = (part) => /^(?:\[\[?|test\b)/.test(part);
199
+ const parts = last.split(/&&/).map((part) => part.trim());
200
+ // `[ ... ]` alone, `[ ... ] && echo yes`, or a chain whose test comes right before the final echo.
201
+ return isTest(parts[0]) && parts.length <= 2
202
+ || (parts.length >= 2 && isTest(parts.at(-2)) && /^(?:echo|printf|true|:)(?:\s|$)/.test(parts.at(-1)));
203
+ }
204
+
205
+ /** A line in the shape a program gives its messages, `program: what happened`, and not data such as `key=value`. */
206
+ function toolMessage(line) {
207
+ return /^[\w.\/-]+:\s+\S/.test(line) && !/\w=\S/.test(line) ? line : "";
208
+ }
209
+
186
210
  const HELP_LINE = /\[Help \d+\]|re-run maven|for more information about the errors|to see the full stack trace|^\[(?:ERROR|FATAL)\]\s*$/i;
187
211
 
188
212
  /** The user's settings file (the same one the SDKs and the MCP server read). Missing or damaged means defaults. */
@@ -323,6 +347,11 @@ export function decide(input, { now = Date.now(), state = {}, env = process.env,
323
347
  }
324
348
  return quiet(state);
325
349
  }
350
+ // The agent read the knowledge the hook suggested (myrmo_brief) or searched itself: only then may it be asked to report.
351
+ if (BRIEF_TOOL.test(String(tool)) || (SEARCH_TOOL.test(String(tool)) && state.brief && !state.brief.used)) {
352
+ if (state.brief && !state.brief.reported) state = { ...state, brief: { ...state.brief, used: true } };
353
+ if (BRIEF_TOOL.test(String(tool))) return quiet(state);
354
+ }
326
355
  // 4b. The agent reported: nothing left to remind. A trail that worked for the open problem: what it cost with help.
327
356
  if (REPORT_TOOL.test(String(tool))) {
328
357
  const brief = state.brief ? { ...state.brief, reported: true } : state.brief;
@@ -336,7 +365,7 @@ export function decide(input, { now = Date.now(), state = {}, env = process.env,
336
365
  }
337
366
  // The agent shared what it learned: the failures so far need no further asking when it stops.
338
367
  if (PUBLISH_TOOL.test(String(tool))) {
339
- return quiet({ ...state, harvestedAt: Math.max(Number(state.harvestedAt ?? 0), Number(state.failures ?? 0)), publishedTs: now });
368
+ return quiet({ ...state, harvestedAt: Math.max(Number(state.harvestedAt ?? 0), Number(state.failures ?? 0)), harvestedResolved: Number(state.resolved ?? 0), publishedTs: now });
340
369
  }
341
370
  if (!SHELLS.has(tool)) return quiet(state);
342
371
 
@@ -357,10 +386,14 @@ export function decide(input, { now = Date.now(), state = {}, env = process.env,
357
386
  // 1. A command failed.
358
387
  if (failed) {
359
388
  if (input.is_interrupt === true || STOPPED.has(code) || isProbe(command) || answered(command, code)) return quiet(state);
389
+ if (code === 1 && endsInTest(command)) return quiet(state);
360
390
  const output = errorText.replace(/^Exit code \d+\r?\n?/, "");
361
- // A company's own tools print errors in no known shape (`migrate: lock 'migrate' is held by ci-runner-17`), and those
362
- // are what a private colony is for: for a command that failed, its last line is the best guess.
363
- const line = lastErrorLine(output, { loose: true }) || lastLine(output);
391
+ // A company's own tools print errors in shapes no pattern knows (`migrate: lock 'migrate' is held by ci-runner-17`):
392
+ // the loose patterns take a line that says something failed, or else a last line in the shape tools give their
393
+ // messages (`program: message`). Nothing else is quoted or looked up: the last line of a loop that printed data
394
+ // (`bucket-a objects=95`) is not an error, and searching for it only teaches the agent to ignore the note.
395
+ const line = lastErrorLine(output, { loose: true }) || toolMessage(lastLine(output));
396
+ if (line && USAGE_LINE.test(line)) return quiet(state);
364
397
  const problem = openProblem(state, now) ?? (line ? { at: now, line } : null);
365
398
  const next = { ...state, failed: { key: commandKey(command), at: now, line }, failures: (state.failures ?? 0) + 1, problem };
366
399
  const sig = signature(line);
@@ -377,6 +410,11 @@ export function decide(input, { now = Date.now(), state = {}, env = process.env,
377
410
 
378
411
  if (mode === "failures" || event === undefined || isProbe(command)) return quiet(state);
379
412
 
413
+ // A command that failed now works: something was solved, which is what the Stop hook may ask to share.
414
+ if (state.failed && !state.failed.resolved && commandKey(command) === state.failed.key && now - state.failed.at < PROBLEM_MS) {
415
+ state = { ...state, failed: { ...state.failed, resolved: true }, resolved: Number(state.resolved ?? 0) + 1 };
416
+ }
417
+
380
418
  // 3b. A command that failed earlier now works, and Myrmo had nothing: the agent may have solved something new.
381
419
  const nomatch = state.nomatch;
382
420
  if (nomatch && !nomatch.nudged && now - nomatch.at < 45 * 60_000 && state.failed && commandKey(command) === state.failed.key && !spent) {
@@ -450,21 +488,51 @@ export function decide(input, { now = Date.now(), state = {}, env = process.env,
450
488
  }
451
489
 
452
490
  /**
453
- * 6. The agent is about to stop. In a private colony, after a turn in which commands failed, ask it once to share what
454
- * it learned before it finishes: Claude Code then continues with this as its next instruction. At most once every
455
- * MYRMO_HARVEST_MINUTES (default 30) and three times a session, never while it is already continuing because of this
456
- * hook, and only for failures that happened since the last time it was asked.
491
+ * 6b. The agent is about to stop in the public colony, with trails shown to it and not reported on: ask once for the
492
+ * report, and nothing else. Measured on the public colony, 8 reports followed 235 searches that returned trails: the
493
+ * reminder after a failed command succeeds again rarely applies (a fix is often checked by another command), and
494
+ * without the outcome a trail can neither rise nor fade. Not after the reminder of case 4 (it already asked), not for
495
+ * trails shown more than 12 hours ago, and once per set of trails.
496
+ */
497
+ function askToReport(state, now) {
498
+ const found = state.found;
499
+ const none = { reason: null, state };
500
+ if (!found || found.nudged || found.asked || !Array.isArray(found.ids) || !found.ids.length) return none;
501
+ if (now - found.at > 12 * 3_600_000) return none;
502
+ const reason =
503
+ `Myrmo: before you finish, call myrmo_report once for each trail it showed you (${found.ids.join(", ")}) that you tried: ` +
504
+ "worked, partially_worked, or failed if it was wrong or out of date, saying what changed; not_applicable if it was about something else. " +
505
+ "It is how good trails rise and stale ones fade. If you tried none, finish.";
506
+ return { reason, state: { ...state, found: { ...found, asked: true } } };
507
+ }
508
+
509
+ /**
510
+ * 6. The agent is about to stop. In a private colony, after a turn in which a failed command was made to work, ask it once
511
+ * to share what it learned before it finishes: Claude Code then continues with this as its next instruction. At most once
512
+ * every MYRMO_HARVEST_MINUTES (default 30) and three times a session, never while it is already continuing because of this
513
+ * hook, and only for what was solved since the last time it was asked. Knowledge the hook suggested is asked about only
514
+ * if the agent read it (myrmo_brief or myrmo_search): a suggestion it never opened was not relied on.
457
515
  */
458
516
  export function decideStop(input, { now = Date.now(), state = {}, env = process.env, settings = {} } = {}) {
459
517
  const none = { reason: null, state };
460
- if (hookMode(env, settings) === "off" || !privateColony(env, settings) || env.MYRMO_HARVEST === "off") return none;
518
+ if (hookMode(env, settings) === "off" || env.MYRMO_HARVEST === "off") return none;
461
519
  if (input?.stop_hook_active === true) return none;
462
- const failures = Number(state.failures ?? 0);
463
- // Knowledge shown at the start of the task and not reported on yet: worth asking once, failures or not.
464
- const shown = state.brief && !state.brief.reported && !state.brief.asked ? state.brief : null;
465
- if (failures <= Number(state.harvestedAt ?? 0) && !shown) return none;
520
+ if (!privateColony(env, settings)) return askToReport(state, now);
521
+ const resolved = Number(state.resolved ?? 0);
522
+ const solvedSince = resolved > Number(state.harvestedResolved ?? 0);
523
+ // Knowledge shown at the start of the task, read by the agent and not reported on yet: worth asking once.
524
+ const shown = state.brief && state.brief.used && !state.brief.reported && !state.brief.asked ? state.brief : null;
525
+ if (!solvedSince && !shown) return none;
466
526
  const minMs = Number(env.MYRMO_HARVEST_MINUTES ?? 30) * 60_000;
467
527
  if ((state.harvests ?? 0) >= 3 || (state.harvestedTs && now - state.harvestedTs < minMs)) return none;
528
+ // Nothing new failed since this session last published: what is left is only reporting on what was shown, so ask that alone
529
+ // instead of asking again to share what was learned.
530
+ if (!solvedSince && shown) {
531
+ const reason =
532
+ `Myrmo: before you finish, call myrmo_report for each entry it showed you for this task (${shown.ids.join(", ")}) that you actually relied on ` +
533
+ "(worked, partially_worked, or failed if it was wrong or out of date, saying what changed); skip the ones you did not use. If you used none, finish.";
534
+ return { reason, state: { ...state, brief: { ...shown, asked: true }, harvestedTs: now, harvests: (state.harvests ?? 0) + 1 } };
535
+ }
468
536
  const reportShown = shown
469
537
  ? `Myrmo showed you knowledge for this task (${shown.ids.join(", ")}): call myrmo_report for each entry you actually relied on (worked, partially_worked, or failed if it was wrong or out of date, saying what changed); skip the ones you did not use. `
470
538
  : "For a trail Myrmo gave you, call myrmo_report if you have not. ";
@@ -478,7 +546,7 @@ export function decideStop(input, { now = Date.now(), state = {}, env = process.
478
546
  "what, where something is configured), publish it with kind \"fact\". Keep internal names and addresses as printed; never include credentials or personal data. " +
479
547
  "If nothing qualifies, say so in one line and finish.";
480
548
  const brief = shown ? { ...shown, asked: true } : state.brief;
481
- return { reason, state: { ...state, brief, harvestedAt: failures, harvestedTs: now, harvests: (state.harvests ?? 0) + 1 } };
549
+ return { reason, state: { ...state, brief, harvestedAt: Number(state.failures ?? 0), harvestedResolved: resolved, harvestedTs: now, harvests: (state.harvests ?? 0) + 1 } };
482
550
  }
483
551
 
484
552
  /** Without the file (a folder that cannot be trusted, a full disk) the notes are simply not throttled. */
@@ -507,7 +575,9 @@ async function main() {
507
575
  const task = taskOf(input.prompt);
508
576
  if (!task || hookMode(process.env, settings) === "off" || !briefEnabled(process.env, settings)) return;
509
577
  const body = await lookupTask(task, { settings, agent: "myrmo-claude-code-hook/1" });
510
- const out = briefNote(task, body, state);
578
+ // MYRMO_HOOK_BRIEF_MIN: the lowest score a suggestion may have (default 0.6).
579
+ const min = Number(process.env.MYRMO_HOOK_BRIEF_MIN);
580
+ const out = briefNote(task, body, state, Date.now(), "", Number.isFinite(min) && min > 0 ? { min } : {});
511
581
  save(file, state, out.state);
512
582
  if (out.note) process.stdout.write(JSON.stringify({ hookSpecificOutput: { hookEventName: "UserPromptSubmit", additionalContext: out.note } }));
513
583
  return;
@@ -1,7 +1,7 @@
1
1
  // Generated from clients/typescript/packages/myrmo/src/redact.ts by clients/typescript/scripts/sync-plugin-redact.mjs.
2
2
  // Do not edit: change the SDK, build it and run that script. The SDK's tests check that this copy is current.
3
3
  // Client-side redaction: the same detectors the colony runs, applied before anything leaves the
4
- // machine. Keep in sync with server/src/redact.rs and clients/python/src/myrmo/redact.py: all
4
+ // machine. Keep in sync with the colony server's redaction and clients/python/src/myrmo/redact.py: all
5
5
  // three must reproduce protocol/redact.v1.vectors.json exactly.
6
6
  //
7
7
  // Rules run in order, most specific first. A rule's replacement never matches a later rule (it
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.28.3";
3
+ export declare const VERSION = "0.29.0";
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.28.3"; // x-release-please-version
9
+ export const VERSION = "0.29.0"; // 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
@@ -55,7 +55,8 @@ const PRIVATE_REMOVE = "This colony is private to your organisation: keep its in
55
55
  const KNOWLEDGE_FORMAT = `
56
56
  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
- - "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? }
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
+ 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.
59
60
  Procedures and facts need no failed attempts, environment or verification.`;
60
61
  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."}
61
62
  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).
@@ -81,6 +82,8 @@ Use preview: true to check the payload without publishing.`;
81
82
  export function noteLine(note, reason) {
82
83
  if (note === "shown_with_trail")
83
84
  return " Your note will be shown to the next agents with the trail.";
85
+ if (note === "shown_as_author_note")
86
+ return " Your report did not count (you wrote the trail), but your note will be shown with it as the author's note.";
84
87
  if (note === "not_counted")
85
88
  return " Your note was not kept either.";
86
89
  if (note === "withheld") {
@@ -212,6 +215,14 @@ function errorText(err) {
212
215
  const issues = err.details.map((d) => ({ path: String(d.path ?? ""), message: String(d.message ?? "") }));
213
216
  return `The colony would not accept this trail (invalid_trail). Fix these and try again:\n${describeIssues(issues)}`;
214
217
  }
218
+ if (err instanceof MyrmoError && err.code === "rate_limited") {
219
+ const wait = err.retryAfter ? `${err.retryAfter} seconds` : "a minute";
220
+ return `Too many requests to the colony this minute, even after waiting once. Wait ${wait}, then repeat this call; when publishing many entries, publish them one at a time, not in parallel.`;
221
+ }
222
+ if (err instanceof MyrmoError && err.code === "publish_limited") {
223
+ const wait = err.retryAfter ? ` Publishing opens again in about ${Math.ceil(err.retryAfter / 60)} minutes.` : "";
224
+ return `${lineText(err.message)}${wait} This is the colony's hourly publishing quota, not an error in the trail: keep the remaining entries and publish them later, or ask the operator to raise the quota.`;
225
+ }
215
226
  if (err instanceof MyrmoError && err.code === "unavailable") {
216
227
  return `${err.message} The request was already repeated a few times. Continue without Myrmo for now and search again in a minute.`;
217
228
  }
@@ -518,10 +529,15 @@ export function createServer(opts) {
518
529
  if (t.environment && typeof t.environment === "object")
519
530
  t.environment.packages ??= [];
520
531
  const attempts = Number(trail.effort?.failed_attempts ?? 0);
521
- // Only a fix has to have cost something: a procedure or a fact is worth sharing because it is needed again.
522
- if (!knowledge && attempts < opts.minFailedAttempts && !args.preview) {
523
- return text(`Not published: this fix took ${attempts} failed attempts and the colony only accepts fixes that took ${opts.minFailedAttempts} or more. Easy fixes are not worth other agents' context.`);
524
- }
532
+ // Only a fix an agent found has to have cost something: a procedure or a fact is worth sharing because it is needed
533
+ // again, and a fix taken from a handover or a runbook was worth writing down already (it has no attempts to count).
534
+ const sourceType = trail.source?.type;
535
+ const fromWriting = sourceType === "handover" || sourceType === "document" || sourceType === "person";
536
+ const tooEasy = !knowledge && !fromWriting && attempts < opts.minFailedAttempts
537
+ ? `this fix took ${attempts} failed attempts and the colony only accepts fixes that took ${opts.minFailedAttempts} or more. Easy fixes are not worth other agents' context.`
538
+ : "";
539
+ if (tooEasy && !args.preview)
540
+ return text(`Not published: ${tooEasy}`);
525
541
  // `names` arrived with myrmo 0.10: an older SDK has none, and then there is simply no warning to show.
526
542
  const { trail: redacted, redactions, names = [] } = opts.colony.preview(trail);
527
543
  const removed = Object.entries(redactions).map(([k, v]) => `${v} ${k}`).join(", ") || "nothing";
@@ -543,7 +559,9 @@ export function createServer(opts) {
543
559
  : issues.length
544
560
  ? `The colony would REJECT this trail (invalid_trail). Fix these before publishing:\n${describeIssues(issues)}`
545
561
  : "The trail matches the protocol. Nothing was sent: the colony checks it again when it is published.";
546
- return text(`${preview}\n\n${verdict}`);
562
+ // Said in the preview too, so the agent does not write a whole trail that publishing will then refuse.
563
+ const gate = tooEasy ? `\n\nIt would NOT be published: ${tooEasy}` : "";
564
+ return text(`${preview}\n\n${verdict}${gate}`);
547
565
  }
548
566
  if (issues?.length) {
549
567
  return text(`Not published: the colony would reject this trail (invalid_trail), so the user was not asked and nothing was sent. Fix these and try again:\n${describeIssues(issues)}`);
@@ -35,6 +35,11 @@
35
35
  "enum": ["fix", "procedure", "fact"],
36
36
  "default": "fix"
37
37
  },
38
+ "review_after": {
39
+ "description": "The day from which this entry should be re-checked (YYYY-MM-DD), for knowledge that describes a state of a system and goes stale: a count, a size, which databases a deployment has. After that day a colony shows the entry as due for review instead of as current. Optional; leave it out for knowledge that does not age.",
40
+ "type": "string",
41
+ "pattern": "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$"
42
+ },
38
43
  "source": {
39
44
  "description": "Where the knowledge comes from, when an agent did not find it out itself: a handover document, a repository's documentation, a person. A colony shows it as provenance and counts entries by source. `revision` records which version of the source was read, so that a person can tell whether the entry is behind it; the colony does not compare it with the source itself.",
40
45
  "type": "object",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myrmo-mcp",
3
- "version": "0.28.3",
3
+ "version": "0.29.0",
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",