myrmo-mcp 0.33.0 → 0.34.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/hooks/cline-hook.mjs +169 -0
- package/dist/hooks/worklog.mjs +17 -5
- package/dist/init.d.ts +15 -0
- package/dist/init.js +91 -5
- package/dist/server.d.ts +1 -1
- package/dist/server.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The work log for Cline: the same thing the Claude Code hook (worklog-hook.mjs) does, with the events Cline has.
|
|
3
|
+
//
|
|
4
|
+
// Cline runs a hook as an executable named after the event, in ~/Documents/Cline/Hooks (or a project's .clinerules/hooks),
|
|
5
|
+
// writes a JSON object to its standard input and reads a JSON object back. Measured in Cline 4.1.26 (every field below
|
|
6
|
+
// was seen, not read in a document):
|
|
7
|
+
//
|
|
8
|
+
// UserPromptSubmit { taskId, workspaceRoots, userPromptSubmit: { prompt } } -> { contextModification } reaches the model
|
|
9
|
+
// PostToolUse { taskId, postToolUse: { toolName, parameters, success } } -> { contextModification } reaches the model
|
|
10
|
+
// TaskComplete { taskId, taskComplete: { taskMetadata: { result } } } the agent's last words (nothing to return)
|
|
11
|
+
// TaskCancel { taskId }
|
|
12
|
+
//
|
|
13
|
+
// The prompt arrives wrapped in <user_input mode="act">…</user_input>. Cline 4.1.26 does not pass a command's output to
|
|
14
|
+
// PostToolUse (the result is the text "[object Object]"), so what the agent did is recorded as the tool and its command,
|
|
15
|
+
// and a failed call as an error line. A new user message is a new run with a new taskId: the state that joins a request to
|
|
16
|
+
// its answer is keyed by it.
|
|
17
|
+
//
|
|
18
|
+
// It never holds the agent back and answers nothing whenever it has nothing to say or anything goes wrong. Like the Claude
|
|
19
|
+
// Code hook it does nothing unless MYRMO_WORKLOG=1, the colony is the organisation's own, the person is enrolled and the
|
|
20
|
+
// folder is covered (worklog.mjs: worklogTarget). A request that starts with //privado or //private is never logged.
|
|
21
|
+
|
|
22
|
+
import { mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
23
|
+
import { homedir } from "node:os";
|
|
24
|
+
import { join } from "node:path";
|
|
25
|
+
import { personalText, taskOf } from "./lookup.mjs";
|
|
26
|
+
import { readSettings } from "./on-failure.mjs";
|
|
27
|
+
import { redactText } from "./redact.mjs";
|
|
28
|
+
import { digestMatters, digestNote, isContinuation, isPrivate, recallEvents, recallNote, redactRandom, send, worklogTarget } from "./worklog.mjs";
|
|
29
|
+
|
|
30
|
+
const DAY = 86_400_000;
|
|
31
|
+
/** How long before the digest of what colleagues did is shown again for a repository: a Cline run is not a session. */
|
|
32
|
+
export const DIGEST_EVERY_MS = 4 * 3_600_000;
|
|
33
|
+
|
|
34
|
+
export const stateDir = (env = process.env) => env.MYRMO_WORKLOG_STATE_DIR || join(homedir(), ".myrmo", "worklog-state");
|
|
35
|
+
const safeId = (id) => String(id ?? "none").replace(/[^A-Za-z0-9_-]/g, "").slice(0, 64) || "none";
|
|
36
|
+
const fileOf = (dir, id) => join(dir, `cline-${safeId(id)}.json`);
|
|
37
|
+
|
|
38
|
+
/** What the person typed: Cline wraps it in <user_input …>…</user_input>. */
|
|
39
|
+
export function promptOf(text) {
|
|
40
|
+
const raw = String(text ?? "");
|
|
41
|
+
const m = /<user_input(?:\s[^>]*)?>([\s\S]*?)<\/user_input>/i.exec(raw);
|
|
42
|
+
return (m ? m[1] : raw).trim();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const oneLine = (text, max) => String(text ?? "").replace(/\s+/g, " ").trim().slice(0, max);
|
|
46
|
+
|
|
47
|
+
/** One short line for a tool call: its name and what it was asked to do. */
|
|
48
|
+
export function toolLine(name, parameters) {
|
|
49
|
+
let p = parameters ?? {};
|
|
50
|
+
const target = p.commands ?? p.command ?? p.file_path ?? p.path ?? p.paths ?? p.pattern ?? p.query ?? p.url ?? p.description ?? "";
|
|
51
|
+
let text = typeof target === "string" ? target : JSON.stringify(target);
|
|
52
|
+
try {
|
|
53
|
+
const list = JSON.parse(text);
|
|
54
|
+
if (Array.isArray(list)) text = list.join(" ; "); // Cline gives the commands as a JSON list inside a string
|
|
55
|
+
} catch {
|
|
56
|
+
/* not a list */
|
|
57
|
+
}
|
|
58
|
+
return `${name}: ${oneLine(text, 200)}`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const safe = (target, text) => redactRandom(redactText(String(text ?? ""), {}, { keepNetwork: true, keepPersonal: target.keepPersonal === true }));
|
|
62
|
+
|
|
63
|
+
function readState(file) {
|
|
64
|
+
try {
|
|
65
|
+
return JSON.parse(readFileSync(file, "utf8"));
|
|
66
|
+
} catch {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function sweep(dir, now) {
|
|
72
|
+
try {
|
|
73
|
+
for (const name of readdirSync(dir)) {
|
|
74
|
+
const path = join(dir, name);
|
|
75
|
+
if (name.startsWith("cline-") && now - statSync(path).mtimeMs > DAY) rmSync(path, { force: true });
|
|
76
|
+
}
|
|
77
|
+
} catch {
|
|
78
|
+
/* nothing to sweep */
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const digestFile = (dir, repo) => join(dir, `cline-digest-${safeId(repo)}.stamp`);
|
|
83
|
+
|
|
84
|
+
function digestDue(dir, repo, now) {
|
|
85
|
+
try {
|
|
86
|
+
return now - Number(readFileSync(digestFile(dir, repo), "utf8")) > DIGEST_EVERY_MS;
|
|
87
|
+
} catch {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Handles one hook call. Returns what to say to Cline ({contextModification}) or null.
|
|
94
|
+
* `deps` lets a test choose the clock, the environment, the folder for state and the way to reach the colony.
|
|
95
|
+
*/
|
|
96
|
+
export async function handle(input, { env = process.env, settings = readSettings(env), now = Date.now(), dir = stateDir(env), poster = send, recall = recallEvents, digest = digestMatters } = {}) {
|
|
97
|
+
const event = String(input?.hookName ?? "");
|
|
98
|
+
const id = input?.taskId;
|
|
99
|
+
const cwd = Array.isArray(input?.workspaceRoots) && input.workspaceRoots[0] ? input.workspaceRoots[0] : process.cwd();
|
|
100
|
+
const file = fileOf(dir, id);
|
|
101
|
+
|
|
102
|
+
if (event === "TaskCancel") {
|
|
103
|
+
rmSync(file, { force: true });
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
const target = worklogTarget({ cwd }, { env, settings });
|
|
107
|
+
if (!target) return null;
|
|
108
|
+
|
|
109
|
+
if (event === "UserPromptSubmit") {
|
|
110
|
+
const prompt = promptOf(input.userPromptSubmit?.prompt);
|
|
111
|
+
rmSync(file, { force: true });
|
|
112
|
+
if (!prompt || isPrivate(prompt)) return null; // marked private: nothing is kept, nothing is asked of the colony
|
|
113
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
114
|
+
sweep(dir, now);
|
|
115
|
+
writeFileSync(file, JSON.stringify({ prompt, tools: [], at: now }), { mode: 0o600 });
|
|
116
|
+
const notes = [];
|
|
117
|
+
const task = taskOf(prompt);
|
|
118
|
+
if (task || isContinuation(prompt)) {
|
|
119
|
+
const note = recallNote(await recall({ prompt, session_id: id }, target, task));
|
|
120
|
+
if (note) notes.push(note);
|
|
121
|
+
}
|
|
122
|
+
if (digestDue(dir, target.repo, now)) {
|
|
123
|
+
writeFileSync(digestFile(dir, target.repo), String(now), { mode: 0o600 });
|
|
124
|
+
const note = digestNote(await digest({ session_id: id }, target));
|
|
125
|
+
if (note) notes.push(note);
|
|
126
|
+
}
|
|
127
|
+
return notes.length ? { context: notes.join("\n\n"), contextModification: notes.join("\n\n") } : null;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (event === "PostToolUse") {
|
|
131
|
+
const state = readState(file);
|
|
132
|
+
if (!state) return null; // a request marked private, or one this hook did not see
|
|
133
|
+
const call = input.postToolUse ?? {};
|
|
134
|
+
const lines = [toolLine(call.toolName, call.parameters)];
|
|
135
|
+
if (call.success === false) lines.push(`error: ${call.toolName} failed`);
|
|
136
|
+
state.tools = [...(state.tools ?? []), ...lines].slice(-60);
|
|
137
|
+
writeFileSync(file, JSON.stringify(state), { mode: 0o600 });
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (event === "TaskComplete") {
|
|
142
|
+
const state = readState(file);
|
|
143
|
+
rmSync(file, { force: true });
|
|
144
|
+
const answer = String(input.taskComplete?.taskMetadata?.result ?? "").trim();
|
|
145
|
+
if (!state || !state.prompt || !answer) return null;
|
|
146
|
+
await poster(target, "/v1/worklog/exchanges", {
|
|
147
|
+
session: `cline-${safeId(id)}`.slice(0, 64),
|
|
148
|
+
scope: target.scope,
|
|
149
|
+
repo: target.repo,
|
|
150
|
+
branch: target.branch,
|
|
151
|
+
prompt: safe(target, personalText(state.prompt).trim()).slice(0, 4000),
|
|
152
|
+
answer: safe(target, answer).slice(0, 6000),
|
|
153
|
+
activity: safe(target, (state.tools ?? []).join("\n")).slice(0, 3000),
|
|
154
|
+
}, { timeoutMs: 8000 });
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
async function main() {
|
|
161
|
+
let raw = "";
|
|
162
|
+
for await (const chunk of process.stdin) raw += chunk;
|
|
163
|
+
const out = await handle(JSON.parse(raw));
|
|
164
|
+
if (out) process.stdout.write(JSON.stringify(out));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (process.argv[1]?.endsWith("cline-hook.mjs")) {
|
|
168
|
+
main().catch(() => {}).finally(() => process.exit(0));
|
|
169
|
+
}
|
package/dist/hooks/worklog.mjs
CHANGED
|
@@ -74,7 +74,7 @@ export function worklogTarget(input, { env = process.env, settings = {}, run = e
|
|
|
74
74
|
return scope ? { colony, keepPersonal, scope, repo: where.repo || basename(cwd), branch: where.branch } : null;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
async function send(target, path, body, { fetcher = fetch, timeoutMs = 3000 } = {}) {
|
|
77
|
+
export async function send(target, path, body, { fetcher = fetch, timeoutMs = 3000 } = {}) {
|
|
78
78
|
const ctrl = new AbortController();
|
|
79
79
|
const timer = setTimeout(() => ctrl.abort(), timeoutMs);
|
|
80
80
|
try {
|
|
@@ -221,9 +221,20 @@ export async function recallEvents(input, target, task, options) {
|
|
|
221
221
|
const LABEL = { decision: "decided", fact: "fact", conclusion: "concluded", failed_attempt: "tried and failed", state: "state", resolved: "resolved" };
|
|
222
222
|
|
|
223
223
|
/** At most three lines for the agent, as untrusted data. */
|
|
224
|
-
|
|
224
|
+
/** "25 min ago" or "3 h ago" for what happened today, else the date: an agent should know when a colleague is on it now. */
|
|
225
|
+
export function whenSaid(at, now = Date.now()) {
|
|
226
|
+
const t = Date.parse(String(at ?? ""));
|
|
227
|
+
const date = String(at ?? "").slice(0, 10).replace(/[^0-9-]/g, "");
|
|
228
|
+
if (!Number.isFinite(t)) return date;
|
|
229
|
+
const minutes = Math.max(0, Math.round((now - t) / 60_000));
|
|
230
|
+
if (minutes < 60) return `${minutes} min ago`;
|
|
231
|
+
if (minutes < 24 * 60) return `${Math.round(minutes / 60)} h ago`;
|
|
232
|
+
return date;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export function recallNote(events, now = Date.now()) {
|
|
225
236
|
const lines = events.slice(0, 3).map((e) => {
|
|
226
|
-
const when =
|
|
237
|
+
const when = whenSaid(e.at, now);
|
|
227
238
|
return `- [${LABEL[e.kind] ?? "note"}, ${clip(e.person, 40)}, ${when}] ${clip(e.matter, 80)}: ${clip(e.text, 300)}`;
|
|
228
239
|
});
|
|
229
240
|
if (!lines.length) return null;
|
|
@@ -247,9 +258,10 @@ export async function digestMatters(input, target, options) {
|
|
|
247
258
|
export const DIGEST_SOURCES = ["startup", "resume", "clear"];
|
|
248
259
|
|
|
249
260
|
/** The lines for the agent, as untrusted data, or null when there is nothing to say. */
|
|
250
|
-
export function digestNote(matters) {
|
|
261
|
+
export function digestNote(matters, now = Date.now()) {
|
|
251
262
|
const lines = (matters ?? []).slice(0, 3).map((m) => {
|
|
252
|
-
const when =
|
|
263
|
+
const when = whenSaid(m.last_at, now);
|
|
264
|
+
if (m.for_you) return `- ${clip(m.matter, 70)} WAITS ON THIS PERSON (${clip((m.people ?? [])[0], 30)}, ${when}): ${clip(m.text, 200)}`;
|
|
253
265
|
const who = (Array.isArray(m.people) ? m.people : []).slice(0, 3).map((p) => clip(p, 30)).join(", ");
|
|
254
266
|
const more = Number(m.new_events) > 1 ? `, ${Number(m.new_events)} new` : "";
|
|
255
267
|
return `- ${clip(m.matter, 70)} (${who}, ${when}${more}) ${LABEL[m.kind] ?? "note"}: ${clip(m.text, 160)}`;
|
package/dist/init.d.ts
CHANGED
|
@@ -49,6 +49,7 @@ export interface InitOptions {
|
|
|
49
49
|
agentsMd?: string;
|
|
50
50
|
readOnly?: boolean;
|
|
51
51
|
private?: boolean;
|
|
52
|
+
worklog?: boolean;
|
|
52
53
|
url?: string;
|
|
53
54
|
key?: string;
|
|
54
55
|
keySource?: "argument" | "file" | "stdin";
|
|
@@ -92,6 +93,20 @@ export declare function mergeHooks(current: string | undefined, command: string)
|
|
|
92
93
|
*/
|
|
93
94
|
/** The scripts the hooks are made of, copied together (scripts/copy-hooks.mjs puts them in dist/hooks). */
|
|
94
95
|
export declare const HOOK_SCRIPTS: string[];
|
|
96
|
+
/** The events Cline runs a hook for that the work log uses. Cline looks for an executable named after the event. */
|
|
97
|
+
export declare const CLINE_HOOK_EVENTS: string[];
|
|
98
|
+
/** Cline's global hooks folder, where it looks on every project (Cline 4.1: ~/Documents/Cline/Hooks). */
|
|
99
|
+
export declare const clineHooksDir: (home: string) => string;
|
|
100
|
+
/** Whether Cline is on this machine: its data folder, its documents folder or its VS Code extension. */
|
|
101
|
+
export declare function clineInstalled(home: string): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* What goes in the file Cline runs for an event. The node that runs init is written in as an absolute path: VS Code starts
|
|
104
|
+
* a hook with the PATH of the desktop session, which often lacks the node that nvm or conda put in a terminal's PATH.
|
|
105
|
+
* MYRMO_WORKLOG=1 is set here, because Cline passes the hook no environment of the person's shell.
|
|
106
|
+
*/
|
|
107
|
+
export declare function clineWrapper(node: string, script: string, platform?: NodeJS.Platform): string;
|
|
108
|
+
/** Installs the work log's hooks for Cline, or says how to. Only with --worklog, and never over a hook the person wrote. */
|
|
109
|
+
export declare function installClineHooks(opts: InitOptions, home: string, log: (l: string) => void): void;
|
|
95
110
|
/** This machine or a private network: where plain http does not carry a key across the internet. */
|
|
96
111
|
export declare function nearbyHost(hostname: string): boolean;
|
|
97
112
|
/** What to tell the person about how their key is handled, one line each. */
|
package/dist/init.js
CHANGED
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
// read safely (JSON that does not parse, a TOML file that already defines "myrmo" in a way that adding
|
|
14
14
|
// a table would break).
|
|
15
15
|
import { spawnSync } from "node:child_process";
|
|
16
|
-
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
16
|
+
import { chmodSync, copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
17
17
|
import { homedir } from "node:os";
|
|
18
18
|
import { dirname, join } from "node:path";
|
|
19
19
|
import { fileURLToPath } from "node:url";
|
|
20
|
-
import { writeConfig } from "myrmo";
|
|
20
|
+
import { readConfig, writeConfig } from "myrmo";
|
|
21
21
|
import { VERSION } from "./server.js";
|
|
22
22
|
import { t as tx } from "./i18n.js";
|
|
23
23
|
export const AGENTS_BLOCK = `<!-- myrmo:start -->
|
|
@@ -323,7 +323,78 @@ export function mergeHooks(current, command) {
|
|
|
323
323
|
* which apply only to that colony), and for Antigravity installs the hook that looks errors up there.
|
|
324
324
|
*/
|
|
325
325
|
/** The scripts the hooks are made of, copied together (scripts/copy-hooks.mjs puts them in dist/hooks). */
|
|
326
|
-
export const HOOK_SCRIPTS = ["antigravity-hook.mjs", "on-failure.mjs", "lookup.mjs", "worklog.mjs", "effort.mjs", "state.mjs", "redact.mjs", "packages.mjs"];
|
|
326
|
+
export const HOOK_SCRIPTS = ["cline-hook.mjs", "antigravity-hook.mjs", "on-failure.mjs", "lookup.mjs", "worklog.mjs", "effort.mjs", "state.mjs", "redact.mjs", "packages.mjs"];
|
|
327
|
+
/** The events Cline runs a hook for that the work log uses. Cline looks for an executable named after the event. */
|
|
328
|
+
export const CLINE_HOOK_EVENTS = ["UserPromptSubmit", "PostToolUse", "TaskComplete", "TaskCancel"];
|
|
329
|
+
const CLINE_MARK = "myrmo-work-log (written by myrmo-mcp init)";
|
|
330
|
+
/** Cline's global hooks folder, where it looks on every project (Cline 4.1: ~/Documents/Cline/Hooks). */
|
|
331
|
+
export const clineHooksDir = (home) => join(home, "Documents", "Cline", "Hooks");
|
|
332
|
+
/** Whether Cline is on this machine: its data folder, its documents folder or its VS Code extension. */
|
|
333
|
+
export function clineInstalled(home) {
|
|
334
|
+
if (existsSync(join(home, ".cline")) || existsSync(join(home, "Documents", "Cline")))
|
|
335
|
+
return true;
|
|
336
|
+
for (const dir of [join(home, ".vscode", "extensions"), join(home, ".vscode-server", "extensions")]) {
|
|
337
|
+
try {
|
|
338
|
+
if (readdirSync(dir).some((n) => n.startsWith("saoudrizwan.claude-dev")))
|
|
339
|
+
return true;
|
|
340
|
+
}
|
|
341
|
+
catch {
|
|
342
|
+
/* no such folder */
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return false;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* What goes in the file Cline runs for an event. The node that runs init is written in as an absolute path: VS Code starts
|
|
349
|
+
* a hook with the PATH of the desktop session, which often lacks the node that nvm or conda put in a terminal's PATH.
|
|
350
|
+
* MYRMO_WORKLOG=1 is set here, because Cline passes the hook no environment of the person's shell.
|
|
351
|
+
*/
|
|
352
|
+
export function clineWrapper(node, script, platform = process.platform) {
|
|
353
|
+
if (platform === "win32")
|
|
354
|
+
return `# ${CLINE_MARK}\r\n$env:MYRMO_WORKLOG = '1'\r\n$input | & "${node}" "${script}"\r\n`;
|
|
355
|
+
const q = (v) => `'${v.replace(/'/g, `'\\''`)}'`;
|
|
356
|
+
return `#!/bin/sh\n# ${CLINE_MARK}\nMYRMO_WORKLOG=1 exec ${q(node)} ${q(script)}\n`;
|
|
357
|
+
}
|
|
358
|
+
/** Installs the work log's hooks for Cline, or says how to. Only with --worklog, and never over a hook the person wrote. */
|
|
359
|
+
export function installClineHooks(opts, home, log) {
|
|
360
|
+
if (!opts.private || !clineInstalled(home))
|
|
361
|
+
return;
|
|
362
|
+
if (!opts.worklog) {
|
|
363
|
+
log(tx("Cline: found. To keep your work log from Cline as well, run this again with --worklog (what the hooks do: https://myrmo.dev/docs)", "Cline: encontrado. Para guardar también tu registro de trabajo desde Cline, ejecuta esto otra vez con --worklog (qué hacen los hooks: https://myrmo.dev/docs)"));
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
const win = process.platform === "win32";
|
|
367
|
+
const dir = clineHooksDir(home);
|
|
368
|
+
const scripts = join(home, ".myrmo", "hooks");
|
|
369
|
+
const source = opts.hooksSource ?? join(dirname(fileURLToPath(import.meta.url)), "hooks");
|
|
370
|
+
const script = join(scripts, "cline-hook.mjs");
|
|
371
|
+
const verb = opts.dryRun ? "would" : "did";
|
|
372
|
+
const kept = [];
|
|
373
|
+
const written = [];
|
|
374
|
+
for (const event of CLINE_HOOK_EVENTS) {
|
|
375
|
+
const file = join(dir, win ? `${event}.ps1` : event);
|
|
376
|
+
if (existsSync(file) && !readFileSync(file, "utf8").includes(CLINE_MARK)) {
|
|
377
|
+
kept.push(event);
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
380
|
+
written.push(event);
|
|
381
|
+
if (opts.dryRun)
|
|
382
|
+
continue;
|
|
383
|
+
mkdirSync(dir, { recursive: true });
|
|
384
|
+
writeFileSync(file, clineWrapper(process.execPath, script), { mode: 0o755 });
|
|
385
|
+
if (!win)
|
|
386
|
+
chmodSync(file, 0o755);
|
|
387
|
+
}
|
|
388
|
+
if (!opts.dryRun && written.length) {
|
|
389
|
+
mkdirSync(scripts, { recursive: true });
|
|
390
|
+
for (const name of HOOK_SCRIPTS)
|
|
391
|
+
copyFileSync(join(source, name), join(scripts, name));
|
|
392
|
+
}
|
|
393
|
+
if (written.length)
|
|
394
|
+
log(tx(`Cline: ${verb} install the work log hooks (${written.join(", ")}) in ${dir}; restart VS Code so Cline picks them up`, `Cline: ${opts.dryRun ? "se instalarían" : "instalados"} los hooks del registro de trabajo (${written.join(", ")}) en ${dir}; reinicia VS Code para que Cline los recoja`));
|
|
395
|
+
if (kept.length)
|
|
396
|
+
log(tx(`Cline: ${kept.join(", ")} in ${dir} are hooks of your own, left untouched; the work log will not see those events`, `Cline: ${kept.join(", ")} en ${dir} son hooks tuyos, no se han tocado; el registro de trabajo no verá esos eventos`));
|
|
397
|
+
}
|
|
327
398
|
/** This machine or a private network: where plain http does not carry a key across the internet. */
|
|
328
399
|
export function nearbyHost(hostname) {
|
|
329
400
|
const h = hostname.toLowerCase().replace(/^\[|\]$/g, "");
|
|
@@ -354,11 +425,16 @@ function setUpColony(opts, home, log, wanted) {
|
|
|
354
425
|
for (const line of keyWarnings(opts))
|
|
355
426
|
log(line);
|
|
356
427
|
const url = opts.url.trim().replace(/\/+$/, "");
|
|
357
|
-
|
|
428
|
+
// Running init again for the same colony (to add --worklog, say) keeps what is saved for it: the colony is written as a
|
|
429
|
+
// whole, and without this a run with no --key would drop the key and the publish choice.
|
|
430
|
+
const saved = readConfig().colony;
|
|
431
|
+
const kept = saved && typeof saved.url === "string" && saved.url.trim().replace(/\/+$/, "") === url ? saved : {};
|
|
432
|
+
const colony = { ...kept, url, ...(opts.key ? { api_key: opts.key } : {}), ...(opts.private ? { private: true } : {}), ...(opts.publish ? { publish: opts.publish } : {}) };
|
|
358
433
|
if (!opts.dryRun)
|
|
359
434
|
writeConfig({ colony });
|
|
360
435
|
const what = [opts.key ? tx("its access key", "su clave de acceso") : "", opts.private ? tx("private mode", "el modo privado") : "", opts.publish ? `publish ${opts.publish}` : ""].filter(Boolean).join(", ");
|
|
361
436
|
log(tx(`Colony: ${verb} save ${url}${what ? ` with ${what}` : ""} in the settings file; the key and the choices apply only to that colony`, `Colonia: ${opts.dryRun ? "se guardaría" : "guardada"} ${url}${what ? ` con ${what}` : ""} en el fichero de configuración; la clave y las elecciones solo se aplican a esa colonia`));
|
|
437
|
+
installClineHooks(opts, home, log);
|
|
362
438
|
// Antigravity has no plugin: copy the hook next to the settings and register it, so that after a failed command it
|
|
363
439
|
// looks the error up in this colony (and reminds the agent to report and to publish).
|
|
364
440
|
const agy = targets(home).find((t) => t.id === "antigravity");
|
|
@@ -399,6 +475,14 @@ export function runInit(opts) {
|
|
|
399
475
|
const verb = opts.dryRun ? "would" : "did";
|
|
400
476
|
if (opts.url)
|
|
401
477
|
setUpColony(opts, home, log, wanted);
|
|
478
|
+
else if (opts.worklog) {
|
|
479
|
+
// `init --worklog` on a machine already pointed at its organisation's colony: only the Cline hooks are added.
|
|
480
|
+
const saved = readConfig().colony;
|
|
481
|
+
if (saved?.url && (saved.private === true || Boolean(saved.api_key)))
|
|
482
|
+
installClineHooks({ ...opts, private: true }, home, log);
|
|
483
|
+
else
|
|
484
|
+
log(tx("--worklog needs your organisation's colony: run init with --url and --key first", "--worklog necesita la colonia de tu organización: ejecuta antes init con --url y --key"));
|
|
485
|
+
}
|
|
402
486
|
const alreadyThere = wanted(CLAUDE_CODE) ? claudeCodeSetUp(home) : null;
|
|
403
487
|
const slash = tx(`In Claude Code's chat run: /plugin marketplace add ${MARKETPLACE} then /plugin install ${PLUGIN}`, `En el chat de Claude Code ejecuta: /plugin marketplace add ${MARKETPLACE} y después /plugin install ${PLUGIN}`);
|
|
404
488
|
if (alreadyThere) {
|
|
@@ -523,6 +607,8 @@ export function parseInitArgs(args, readStdin = () => readFileSync(0, "utf8")) {
|
|
|
523
607
|
opts.rules = false;
|
|
524
608
|
else if (a === "--private")
|
|
525
609
|
opts.private = true;
|
|
610
|
+
else if (a === "--worklog")
|
|
611
|
+
opts.worklog = true;
|
|
526
612
|
else if (a === "--key-file") {
|
|
527
613
|
// The key stays out of the command line, so out of the shell's history and the process list.
|
|
528
614
|
const file = args[++i];
|
|
@@ -572,7 +658,7 @@ export function parseInitArgs(args, readStdin = () => readFileSync(0, "utf8")) {
|
|
|
572
658
|
return tx("--publish takes auto, ask or off", "--publish acepta auto, ask u off");
|
|
573
659
|
}
|
|
574
660
|
else
|
|
575
|
-
return tx(`Unknown option ${a}.`, `Opción desconocida ${a}.`) + ` ${tx("Usage:", "Uso:")} myrmo-mcp init [--client <id>]... [--agents-md [file] [--read-only]] [--url <colony> [--key <key> | --key - | --key-file <file>] [--private] [--publish auto|ask|off]] [--no-rules] [--dry-run]`;
|
|
661
|
+
return tx(`Unknown option ${a}.`, `Opción desconocida ${a}.`) + ` ${tx("Usage:", "Uso:")} myrmo-mcp init [--client <id>]... [--agents-md [file] [--read-only]] [--url <colony> [--key <key> | --key - | --key-file <file>] [--private] [--publish auto|ask|off]] [--no-rules] [--worklog] [--dry-run]`;
|
|
576
662
|
}
|
|
577
663
|
if ((opts.key || opts.publish) && !opts.url)
|
|
578
664
|
return tx("--key and --publish go with --url: they belong to one colony", "--key y --publish van con --url: pertenecen a una colonia");
|
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.
|
|
3
|
+
export declare const VERSION = "0.34.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
|
@@ -7,7 +7,7 @@ import { z } from "zod";
|
|
|
7
7
|
import { checkTrail } from "./check.js";
|
|
8
8
|
import { buildInstructions } from "./instructions.js";
|
|
9
9
|
import { MATTER_DESCRIPTION, MATTERS_DESCRIPTION, formatMatter, formatMatters } from "./worklog.js";
|
|
10
|
-
export const VERSION = "0.
|
|
10
|
+
export const VERSION = "0.34.0"; // x-release-please-version
|
|
11
11
|
const PUBLIC_HOSTS = new Set(["myrmo.dev", "www.myrmo.dev"]);
|
|
12
12
|
/**
|
|
13
13
|
* Whether the server runs for an organisation's colony, where agents keep its internal names. Never for the public
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "myrmo-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.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",
|