@goondocks/myco 0.3.4 → 0.3.5
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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/dist/{chunk-I7PMGO6S.js → chunk-HIN3UVOG.js} +20 -2
- package/dist/chunk-HIN3UVOG.js.map +1 -0
- package/dist/{chunk-4RJ3IEPW.js → chunk-OLS7Z2RS.js} +26 -4
- package/dist/chunk-OLS7Z2RS.js.map +1 -0
- package/dist/{cli-YTICB2DH.js → cli-LGGOSXQT.js} +2 -2
- package/dist/{client-YI6RXFJD.js → client-IGWYN2Z4.js} +2 -2
- package/dist/{main-3BL45UM3.js → main-XXMF23OW.js} +2 -2
- package/dist/{restart-UGE2Y327.js → restart-QAO5MEOI.js} +2 -2
- package/dist/{server-YYCYIH5Z.js → server-REMXRVYP.js} +30 -25
- package/dist/{server-YYCYIH5Z.js.map → server-REMXRVYP.js.map} +1 -1
- package/dist/{session-start-4MNXDOYK.js → session-start-J6RBMYPY.js} +2 -2
- package/dist/src/cli.js +1 -1
- package/dist/src/daemon/main.js +1 -1
- package/dist/src/hooks/post-tool-use.js +2 -2
- package/dist/src/hooks/session-end.js +1 -1
- package/dist/src/hooks/session-start.js +1 -1
- package/dist/src/hooks/stop.js +1 -1
- package/dist/src/hooks/user-prompt-submit.js +2 -2
- package/dist/src/mcp/server.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-4RJ3IEPW.js.map +0 -1
- package/dist/chunk-I7PMGO6S.js.map +0 -1
- /package/dist/{cli-YTICB2DH.js.map → cli-LGGOSXQT.js.map} +0 -0
- /package/dist/{client-YI6RXFJD.js.map → client-IGWYN2Z4.js.map} +0 -0
- /package/dist/{main-3BL45UM3.js.map → main-XXMF23OW.js.map} +0 -0
- /package/dist/{restart-UGE2Y327.js.map → restart-QAO5MEOI.js.map} +0 -0
- /package/dist/{session-start-4MNXDOYK.js.map → session-start-J6RBMYPY.js.map} +0 -0
|
@@ -51,8 +51,26 @@ var EventBuffer = class {
|
|
|
51
51
|
return this.filePath;
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
|
+
function resolveSessionFromBuffer(bufferDir) {
|
|
55
|
+
try {
|
|
56
|
+
let bestSession;
|
|
57
|
+
let bestMtime = 0;
|
|
58
|
+
for (const file of fs.readdirSync(bufferDir)) {
|
|
59
|
+
if (!file.endsWith(".jsonl")) continue;
|
|
60
|
+
const mtime = fs.statSync(path.join(bufferDir, file)).mtimeMs;
|
|
61
|
+
if (mtime > bestMtime) {
|
|
62
|
+
bestMtime = mtime;
|
|
63
|
+
bestSession = file.replace(".jsonl", "");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return bestSession;
|
|
67
|
+
} catch {
|
|
68
|
+
return void 0;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
54
71
|
|
|
55
72
|
export {
|
|
56
|
-
EventBuffer
|
|
73
|
+
EventBuffer,
|
|
74
|
+
resolveSessionFromBuffer
|
|
57
75
|
};
|
|
58
|
-
//# sourceMappingURL=chunk-
|
|
76
|
+
//# sourceMappingURL=chunk-HIN3UVOG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/capture/buffer.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\ninterface BufferOptions {\n maxEvents?: number;\n}\n\nexport class EventBuffer {\n private filePath: string;\n private maxEvents: number;\n private eventCount = 0;\n\n constructor(\n private bufferDir: string,\n private sessionId: string,\n options: BufferOptions = {},\n ) {\n this.filePath = path.join(bufferDir, `${sessionId}.jsonl`);\n this.maxEvents = options.maxEvents ?? 500;\n\n if (fs.existsSync(this.filePath)) {\n const content = fs.readFileSync(this.filePath, 'utf-8').trim();\n this.eventCount = content ? content.split('\\n').length : 0;\n }\n }\n\n append(event: Record<string, unknown>): void {\n fs.mkdirSync(this.bufferDir, { recursive: true });\n\n const line = JSON.stringify({\n ...event,\n timestamp: event.timestamp ?? new Date().toISOString(),\n });\n\n fs.appendFileSync(this.filePath, line + '\\n');\n this.eventCount++;\n }\n\n readAll(): Array<Record<string, unknown>> {\n if (!fs.existsSync(this.filePath)) return [];\n const content = fs.readFileSync(this.filePath, 'utf-8').trim();\n if (!content) return [];\n return content.split('\\n').map((line) => JSON.parse(line));\n }\n\n count(): number {\n return this.eventCount;\n }\n\n exists(): boolean {\n return fs.existsSync(this.filePath);\n }\n\n delete(): void {\n if (fs.existsSync(this.filePath)) {\n fs.unlinkSync(this.filePath);\n }\n this.eventCount = 0;\n }\n\n isOverflow(): boolean {\n return this.eventCount > this.maxEvents;\n }\n\n getFilePath(): string {\n return this.filePath;\n }\n}\n\n/**\n * Find the most recently active session by buffer file mtime.\n * The UserPromptSubmit hook appends to the session's buffer on every prompt,\n * so the most recently modified buffer is the calling session.\n */\nexport function resolveSessionFromBuffer(bufferDir: string): string | undefined {\n try {\n let bestSession: string | undefined;\n let bestMtime = 0;\n for (const file of fs.readdirSync(bufferDir)) {\n if (!file.endsWith('.jsonl')) continue;\n const mtime = fs.statSync(path.join(bufferDir, file)).mtimeMs;\n if (mtime > bestMtime) {\n bestMtime = mtime;\n bestSession = file.replace('.jsonl', '');\n }\n }\n return bestSession;\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAMV,IAAM,cAAN,MAAkB;AAAA,EAKvB,YACU,WACA,WACR,UAAyB,CAAC,GAC1B;AAHQ;AACA;AAGR,SAAK,WAAW,KAAK,KAAK,WAAW,GAAG,SAAS,QAAQ;AACzD,SAAK,YAAY,QAAQ,aAAa;AAEtC,QAAI,GAAG,WAAW,KAAK,QAAQ,GAAG;AAChC,YAAM,UAAU,GAAG,aAAa,KAAK,UAAU,OAAO,EAAE,KAAK;AAC7D,WAAK,aAAa,UAAU,QAAQ,MAAM,IAAI,EAAE,SAAS;AAAA,IAC3D;AAAA,EACF;AAAA,EAhBQ;AAAA,EACA;AA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zC;AAAA,IACF;AACA,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -119,15 +119,37 @@ var DaemonClient = class {
|
|
|
119
119
|
return false;
|
|
120
120
|
}
|
|
121
121
|
spawnDaemon() {
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
if (!fs.existsSync(daemonScript)) return;
|
|
122
|
+
const daemonScript = this.resolveDaemonScript();
|
|
123
|
+
if (!daemonScript || !fs.existsSync(daemonScript)) return;
|
|
125
124
|
const child = spawn("node", [daemonScript, "--vault", this.vaultDir], {
|
|
126
125
|
detached: true,
|
|
127
126
|
stdio: "ignore"
|
|
128
127
|
});
|
|
129
128
|
child.unref();
|
|
130
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Resolve the daemon entry script path.
|
|
132
|
+
* Priority:
|
|
133
|
+
* 1. Plugin root env var (set by the agent host) → dist/src/daemon/main.js
|
|
134
|
+
* 2. Walk up from the current file to find the dist/ directory containing
|
|
135
|
+
* the daemon entry. This handles both chunk files (dist/chunk-*.js) and
|
|
136
|
+
* thin entry points (dist/src/hooks/*.js) after bundling.
|
|
137
|
+
*/
|
|
138
|
+
resolveDaemonScript() {
|
|
139
|
+
const pluginRoot = new AgentRegistry().resolvePluginRoot();
|
|
140
|
+
if (pluginRoot) {
|
|
141
|
+
return path.join(pluginRoot, "dist", "src", "daemon", "main.js");
|
|
142
|
+
}
|
|
143
|
+
let dir = import.meta.dirname;
|
|
144
|
+
for (let i = 0; i < 5; i++) {
|
|
145
|
+
const candidate = path.join(dir, "dist", "src", "daemon", "main.js");
|
|
146
|
+
if (fs.existsSync(candidate)) return candidate;
|
|
147
|
+
const inDist = path.join(dir, "src", "daemon", "main.js");
|
|
148
|
+
if (fs.existsSync(inDist)) return inDist;
|
|
149
|
+
dir = path.dirname(dir);
|
|
150
|
+
}
|
|
151
|
+
return void 0;
|
|
152
|
+
}
|
|
131
153
|
readDaemonJson() {
|
|
132
154
|
try {
|
|
133
155
|
const jsonPath = path.join(this.vaultDir, "daemon.json");
|
|
@@ -144,4 +166,4 @@ var DaemonClient = class {
|
|
|
144
166
|
export {
|
|
145
167
|
DaemonClient
|
|
146
168
|
};
|
|
147
|
-
//# sourceMappingURL=chunk-
|
|
169
|
+
//# sourceMappingURL=chunk-OLS7Z2RS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/client.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { spawn } from 'node:child_process';\nimport { DAEMON_CLIENT_TIMEOUT_MS, DAEMON_HEALTH_CHECK_TIMEOUT_MS, DAEMON_HEALTH_RETRY_DELAYS } from '../constants.js';\nimport { AgentRegistry } from '../agents/registry.js';\nimport { getPluginVersion } from '../version.js';\n\ninterface DaemonInfo {\n pid: number;\n port: number;\n}\n\ninterface HealthResponse {\n myco: boolean;\n version?: string;\n}\n\ninterface ClientResult {\n ok: boolean;\n data?: any;\n}\n\nexport class DaemonClient {\n private vaultDir: string;\n\n constructor(vaultDir: string) {\n this.vaultDir = vaultDir;\n }\n\n async post(endpoint: string, body: unknown): Promise<ClientResult> {\n try {\n const info = this.readDaemonJson();\n if (!info) return { ok: false };\n\n const res = await fetch(`http://127.0.0.1:${info.port}${endpoint}`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n signal: AbortSignal.timeout(DAEMON_CLIENT_TIMEOUT_MS),\n });\n\n if (!res.ok) return { ok: false };\n const data = await res.json();\n return { ok: true, data };\n } catch {\n return { ok: false };\n }\n }\n\n async get(endpoint: string): Promise<ClientResult> {\n try {\n const info = this.readDaemonJson();\n if (!info) return { ok: false };\n\n const res = await fetch(`http://127.0.0.1:${info.port}${endpoint}`, {\n signal: AbortSignal.timeout(DAEMON_CLIENT_TIMEOUT_MS),\n });\n\n if (!res.ok) return { ok: false };\n const data = await res.json();\n return { ok: true, data };\n } catch {\n return { ok: false };\n }\n }\n\n async isHealthy(): Promise<boolean> {\n try {\n const info = this.readDaemonJson();\n if (!info) return false;\n\n const res = await fetch(`http://127.0.0.1:${info.port}/health`, {\n signal: AbortSignal.timeout(DAEMON_HEALTH_CHECK_TIMEOUT_MS),\n });\n if (!res.ok) return false;\n const data = await res.json() as HealthResponse;\n return data.myco === true;\n } catch {\n return false;\n }\n }\n\n /**\n * Check if the daemon is running a stale version.\n * Returns true if the daemon's version doesn't match the current plugin version.\n */\n private async isStale(): Promise<boolean> {\n try {\n const info = this.readDaemonJson();\n if (!info) return false;\n\n const res = await fetch(`http://127.0.0.1:${info.port}/health`, {\n signal: AbortSignal.timeout(DAEMON_HEALTH_CHECK_TIMEOUT_MS),\n });\n if (!res.ok) return false;\n const data = await res.json() as HealthResponse;\n if (!data.myco) return false;\n\n // No version in response = old daemon that predates this check\n if (!data.version) return true;\n\n return data.version !== getPluginVersion();\n } catch {\n return false;\n }\n }\n\n /**\n * Kill the running daemon process.\n */\n private killDaemon(): void {\n try {\n const info = this.readDaemonJson();\n if (!info) return;\n process.kill(info.pid, 'SIGTERM');\n } catch { /* already dead */ }\n try {\n fs.unlinkSync(path.join(this.vaultDir, 'daemon.json'));\n } catch { /* already gone */ }\n }\n\n /**\n * Ensure the daemon is running the current version. Spawns it if unhealthy\n * or restarts it if the version is stale. Returns true if healthy after this call.\n */\n async ensureRunning(): Promise<boolean> {\n // Check if daemon is running but stale (version mismatch)\n if (await this.isStale()) {\n this.killDaemon();\n // Brief pause for port release\n await new Promise((r) => setTimeout(r, 200));\n } else if (await this.isHealthy()) {\n return true;\n }\n\n this.spawnDaemon();\n\n for (const delay of DAEMON_HEALTH_RETRY_DELAYS) {\n await new Promise((r) => setTimeout(r, delay));\n if (await this.isHealthy()) return true;\n }\n return false;\n }\n\n spawnDaemon(): void {\n const daemonScript = this.resolveDaemonScript();\n if (!daemonScript || !fs.existsSync(daemonScript)) return;\n\n const child = spawn('node', [daemonScript, '--vault', this.vaultDir], {\n detached: true,\n stdio: 'ignore',\n });\n child.unref();\n }\n\n /**\n * Resolve the daemon entry script path.\n * Priority:\n * 1. Plugin root env var (set by the agent host) → dist/src/daemon/main.js\n * 2. Walk up from the current file to find the dist/ directory containing\n * the daemon entry. This handles both chunk files (dist/chunk-*.js) and\n * thin entry points (dist/src/hooks/*.js) after bundling.\n */\n private resolveDaemonScript(): string | undefined {\n const pluginRoot = new AgentRegistry().resolvePluginRoot();\n if (pluginRoot) {\n return path.join(pluginRoot, 'dist', 'src', 'daemon', 'main.js');\n }\n\n // Walk up from import.meta.dirname looking for the daemon entry\n let dir = import.meta.dirname;\n for (let i = 0; i < 5; i++) {\n const candidate = path.join(dir, 'dist', 'src', 'daemon', 'main.js');\n if (fs.existsSync(candidate)) return candidate;\n // Also check if we're already inside dist/\n const inDist = path.join(dir, 'src', 'daemon', 'main.js');\n if (fs.existsSync(inDist)) return inDist;\n dir = path.dirname(dir);\n }\n return undefined;\n }\n\n private readDaemonJson(): DaemonInfo | null {\n try {\n const jsonPath = path.join(this.vaultDir, 'daemon.json');\n const content = fs.readFileSync(jsonPath, 'utf-8');\n const info = JSON.parse(content);\n if (typeof info.port !== 'number') return null;\n return info as DaemonInfo;\n } catch {\n return null;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,aAAa;AAoBf,IAAM,eAAN,MAAmB;AAAA,EAChB;AAAA,EAER,YAAY,UAAkB;AAC5B,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA,MAAM,KAAK,UAAkB,MAAsC;AACjE,QAAI;AACF,YAAM,OAAO,KAAK,eAAe;AACjC,UAAI,CAAC,KAAM,QAAO,EAAE,IAAI,MAAM;AAE9B,YAAM,MAAM,MAAM,MAAM,oBAAoB,KAAK,IAAI,GAAG,QAAQ,IAAI;AAAA,QAClE,QAAQ;AAAA,QACR,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,QAC9C,MAAM,KAAK,UAAU,IAAI;AAAA,QACzB,QAAQ,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AM,MAAM;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUQ,sBAA0C;AAChD,UAAM,aAAa,IAAI,cAAc,EAAE,kBAAkB;AACzD,QAAI,YAAY;AACd,aAAO,KAAK,KAAK,YAAY,QAAQ,OAAO,UAAU,SAAS;AAAA,IACjE;AAGA,QAAI,MAAM,YAAY;AACtB,aAAS,IAAI,GAAG,IAAI,GAAG,KAAK;AAC1B,YAAM,YAAY,KAAK,KAAK,KAAK,QAAQ,OAAO,UAAU,SAAS;AACnE,UAAI,GAAG,WAAW,SAAS,EAAG,QAAO;AAErC,YAAM,SAAS,KAAK,KAAK,KAAK,OAAO,UAAU,SAAS;AACxD,UAAI,GAAG,WAAW,MAAM,EAAG,QAAO;AAClC,YAAM,KAAK,QAAQ,GAAG;AAAA,IACxB;AACA,WAAO;AAAA,EACT;AAAA,EAEQ,iBAAoC;AAC1C,QAAI;AACF,YAAM,WAAW,KAAK,KAAK,KAAK,UAAU,aAAa;AACvD,YAAM,UAAU,GAAG,aAAa,UAAU,OAAO;AACjD,YAAM,OAAO,KAAK,MAAM,OAAO;AAC/B,UAAI,OAAO,KAAK,SAAS,SAAU,QAAO;AAC1C,aAAO;AAAA,IACT,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
|
|
@@ -65,7 +65,7 @@ async function main() {
|
|
|
65
65
|
case "session":
|
|
66
66
|
return (await import("./session-5GI2YU6R.js")).run(args, vaultDir);
|
|
67
67
|
case "restart":
|
|
68
|
-
return (await import("./restart-
|
|
68
|
+
return (await import("./restart-QAO5MEOI.js")).run(args, vaultDir);
|
|
69
69
|
case "rebuild":
|
|
70
70
|
return (await import("./rebuild-JW6BCHHZ.js")).run(args, vaultDir);
|
|
71
71
|
case "reprocess":
|
|
@@ -82,4 +82,4 @@ main().catch((err) => {
|
|
|
82
82
|
console.error(`myco: ${err.message}`);
|
|
83
83
|
process.exit(1);
|
|
84
84
|
});
|
|
85
|
-
//# sourceMappingURL=cli-
|
|
85
|
+
//# sourceMappingURL=cli-LGGOSXQT.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
DaemonClient
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-OLS7Z2RS.js";
|
|
5
5
|
import "./chunk-R2R243GC.js";
|
|
6
6
|
import "./chunk-Y3OYD4CX.js";
|
|
7
7
|
import "./chunk-7VPJK56U.js";
|
|
@@ -9,4 +9,4 @@ import "./chunk-PZUWP5VK.js";
|
|
|
9
9
|
export {
|
|
10
10
|
DaemonClient
|
|
11
11
|
};
|
|
12
|
-
//# sourceMappingURL=client-
|
|
12
|
+
//# sourceMappingURL=client-IGWYN2Z4.js.map
|
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
} from "./chunk-EF4JVH24.js";
|
|
49
49
|
import {
|
|
50
50
|
EventBuffer
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-HIN3UVOG.js";
|
|
52
52
|
import {
|
|
53
53
|
getPluginVersion
|
|
54
54
|
} from "./chunk-R2R243GC.js";
|
|
@@ -2947,4 +2947,4 @@ export {
|
|
|
2947
2947
|
chokidar/index.js:
|
|
2948
2948
|
(*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) *)
|
|
2949
2949
|
*/
|
|
2950
|
-
//# sourceMappingURL=main-
|
|
2950
|
+
//# sourceMappingURL=main-XXMF23OW.js.map
|
|
@@ -29,7 +29,7 @@ async function run(_args, vaultDir) {
|
|
|
29
29
|
} catch {
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
const { DaemonClient } = await import("./client-
|
|
32
|
+
const { DaemonClient } = await import("./client-IGWYN2Z4.js");
|
|
33
33
|
const client = new DaemonClient(vaultDir);
|
|
34
34
|
console.log("Waiting for health check...");
|
|
35
35
|
const healthy = await client.ensureRunning();
|
|
@@ -47,4 +47,4 @@ async function run(_args, vaultDir) {
|
|
|
47
47
|
export {
|
|
48
48
|
run
|
|
49
49
|
};
|
|
50
|
-
//# sourceMappingURL=restart-
|
|
50
|
+
//# sourceMappingURL=restart-QAO5MEOI.js.map
|
|
@@ -56,6 +56,9 @@ import {
|
|
|
56
56
|
unknown
|
|
57
57
|
} from "./chunk-ISCT2SI6.js";
|
|
58
58
|
import "./chunk-EF4JVH24.js";
|
|
59
|
+
import {
|
|
60
|
+
resolveSessionFromBuffer
|
|
61
|
+
} from "./chunk-HIN3UVOG.js";
|
|
59
62
|
import {
|
|
60
63
|
getPluginVersion
|
|
61
64
|
} from "./chunk-R2R243GC.js";
|
|
@@ -3270,8 +3273,8 @@ var require_utils = __commonJS({
|
|
|
3270
3273
|
}
|
|
3271
3274
|
return ind;
|
|
3272
3275
|
}
|
|
3273
|
-
function removeDotSegments(
|
|
3274
|
-
let input =
|
|
3276
|
+
function removeDotSegments(path6) {
|
|
3277
|
+
let input = path6;
|
|
3275
3278
|
const output = [];
|
|
3276
3279
|
let nextSlash = -1;
|
|
3277
3280
|
let len = 0;
|
|
@@ -3470,8 +3473,8 @@ var require_schemes = __commonJS({
|
|
|
3470
3473
|
wsComponent.secure = void 0;
|
|
3471
3474
|
}
|
|
3472
3475
|
if (wsComponent.resourceName) {
|
|
3473
|
-
const [
|
|
3474
|
-
wsComponent.path =
|
|
3476
|
+
const [path6, query] = wsComponent.resourceName.split("?");
|
|
3477
|
+
wsComponent.path = path6 && path6 !== "/" ? path6 : void 0;
|
|
3475
3478
|
wsComponent.query = query;
|
|
3476
3479
|
wsComponent.resourceName = void 0;
|
|
3477
3480
|
}
|
|
@@ -7205,8 +7208,8 @@ function getErrorMap() {
|
|
|
7205
7208
|
|
|
7206
7209
|
// node_modules/zod/v3/helpers/parseUtil.js
|
|
7207
7210
|
var makeIssue = (params) => {
|
|
7208
|
-
const { data, path:
|
|
7209
|
-
const fullPath = [...
|
|
7211
|
+
const { data, path: path6, errorMaps, issueData } = params;
|
|
7212
|
+
const fullPath = [...path6, ...issueData.path || []];
|
|
7210
7213
|
const fullIssue = {
|
|
7211
7214
|
...issueData,
|
|
7212
7215
|
path: fullPath
|
|
@@ -7321,11 +7324,11 @@ var errorUtil;
|
|
|
7321
7324
|
|
|
7322
7325
|
// node_modules/zod/v3/types.js
|
|
7323
7326
|
var ParseInputLazyPath = class {
|
|
7324
|
-
constructor(parent, value,
|
|
7327
|
+
constructor(parent, value, path6, key) {
|
|
7325
7328
|
this._cachedPath = [];
|
|
7326
7329
|
this.parent = parent;
|
|
7327
7330
|
this.data = value;
|
|
7328
|
-
this._path =
|
|
7331
|
+
this._path = path6;
|
|
7329
7332
|
this._key = key;
|
|
7330
7333
|
}
|
|
7331
7334
|
get path() {
|
|
@@ -14058,7 +14061,7 @@ var StdioServerTransport = class {
|
|
|
14058
14061
|
|
|
14059
14062
|
// src/mcp/server.ts
|
|
14060
14063
|
import fs3 from "fs";
|
|
14061
|
-
import
|
|
14064
|
+
import path5 from "path";
|
|
14062
14065
|
|
|
14063
14066
|
// src/mcp/tools/search.ts
|
|
14064
14067
|
async function handleMycoSearch(index, input, vectorIndex, backend) {
|
|
@@ -14144,19 +14147,21 @@ async function handleMycoRecall(index, input) {
|
|
|
14144
14147
|
|
|
14145
14148
|
// src/mcp/tools/remember.ts
|
|
14146
14149
|
import { randomBytes } from "crypto";
|
|
14150
|
+
import path from "path";
|
|
14147
14151
|
async function handleMycoRemember(vaultDir, index, input) {
|
|
14148
14152
|
const writer = new VaultWriter(vaultDir);
|
|
14149
14153
|
const id = `${input.type}-${randomBytes(4).toString("hex")}`;
|
|
14154
|
+
const session = input.session ?? resolveSessionFromBuffer(path.join(vaultDir, "buffer"));
|
|
14150
14155
|
const notePath = writer.writeMemory({
|
|
14151
14156
|
id,
|
|
14152
14157
|
observation_type: input.type,
|
|
14153
|
-
session
|
|
14158
|
+
session,
|
|
14154
14159
|
plan: input.related_plan ?? void 0,
|
|
14155
14160
|
tags: input.tags,
|
|
14156
14161
|
content: input.content
|
|
14157
14162
|
});
|
|
14158
14163
|
indexNote(index, vaultDir, notePath);
|
|
14159
|
-
return { note_path: notePath, id };
|
|
14164
|
+
return { note_path: notePath, id, session };
|
|
14160
14165
|
}
|
|
14161
14166
|
|
|
14162
14167
|
// src/mcp/tools/plans.ts
|
|
@@ -14378,15 +14383,15 @@ async function handleMycoOrphans(index) {
|
|
|
14378
14383
|
}
|
|
14379
14384
|
|
|
14380
14385
|
// src/mcp/tools/logs.ts
|
|
14381
|
-
import
|
|
14386
|
+
import path2 from "path";
|
|
14382
14387
|
async function handleMycoLogs(vaultDir, input) {
|
|
14383
|
-
const logDir =
|
|
14388
|
+
const logDir = path2.join(vaultDir, "logs");
|
|
14384
14389
|
return queryLogs(logDir, input);
|
|
14385
14390
|
}
|
|
14386
14391
|
|
|
14387
14392
|
// src/mcp/tools/supersede.ts
|
|
14388
14393
|
import fs from "fs";
|
|
14389
|
-
import
|
|
14394
|
+
import path3 from "path";
|
|
14390
14395
|
async function handleMycoSupersede(vaultDir, index, input) {
|
|
14391
14396
|
const writer = new VaultWriter(vaultDir);
|
|
14392
14397
|
const oldNotes = index.queryByIds([input.old_memory_id]);
|
|
@@ -14398,7 +14403,7 @@ async function handleMycoSupersede(vaultDir, index, input) {
|
|
|
14398
14403
|
status: "superseded",
|
|
14399
14404
|
superseded_by: input.new_memory_id
|
|
14400
14405
|
}, true);
|
|
14401
|
-
const fullPath =
|
|
14406
|
+
const fullPath = path3.join(vaultDir, oldNote.path);
|
|
14402
14407
|
const content = fs.readFileSync(fullPath, "utf-8");
|
|
14403
14408
|
if (!content.includes("Superseded by::")) {
|
|
14404
14409
|
const notice = `
|
|
@@ -14418,7 +14423,7 @@ Reason:: ${input.reason}` : "";
|
|
|
14418
14423
|
// src/mcp/tools/consolidate.ts
|
|
14419
14424
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
14420
14425
|
import fs2 from "fs";
|
|
14421
|
-
import
|
|
14426
|
+
import path4 from "path";
|
|
14422
14427
|
async function handleMycoConsolidate(vaultDir, index, input) {
|
|
14423
14428
|
const writer = new VaultWriter(vaultDir);
|
|
14424
14429
|
const wisdomId = `${input.observation_type}-wisdom-${randomBytes2(4).toString("hex")}`;
|
|
@@ -14447,7 +14452,7 @@ ${sourceLinks}`;
|
|
|
14447
14452
|
status: "superseded",
|
|
14448
14453
|
superseded_by: wisdomId
|
|
14449
14454
|
}, true);
|
|
14450
|
-
const fullPath =
|
|
14455
|
+
const fullPath = path4.join(vaultDir, notePath);
|
|
14451
14456
|
const content = fs2.readFileSync(fullPath, "utf-8");
|
|
14452
14457
|
if (!content.includes("Superseded by::")) {
|
|
14453
14458
|
const notice = `
|
|
@@ -14509,14 +14514,14 @@ var TOOL_DEFINITIONS = [
|
|
|
14509
14514
|
},
|
|
14510
14515
|
{
|
|
14511
14516
|
name: TOOL_REMEMBER,
|
|
14512
|
-
description: "Save a decision, gotcha, bug fix, discovery, or trade-off as a permanent memory. Use after making a key decision, fixing a tricky bug, discovering something non-obvious, or encountering a gotcha.
|
|
14517
|
+
description: "Save a decision, gotcha, bug fix, discovery, or trade-off as a permanent memory. Use after making a key decision, fixing a tricky bug, discovering something non-obvious, or encountering a gotcha.",
|
|
14513
14518
|
inputSchema: {
|
|
14514
14519
|
type: "object",
|
|
14515
14520
|
properties: {
|
|
14516
14521
|
content: { type: "string", description: "The observation \u2014 include context, reasoning, and what someone encountering this in the future needs to know" },
|
|
14517
14522
|
type: { type: "string", enum: OBSERVATION_TYPES, description: `Observation type: ${OBSERVATION_TYPES.join(", ")}` },
|
|
14518
14523
|
tags: { type: "array", items: { type: "string" }, description: PROP_TAGS },
|
|
14519
|
-
session: { type: "string", description:
|
|
14524
|
+
session: { type: "string", description: "Your current session ID \u2014 auto-detected if omitted" },
|
|
14520
14525
|
related_plan: { type: "string", description: "Plan ID if this observation relates to an active plan" }
|
|
14521
14526
|
},
|
|
14522
14527
|
required: ["content", "type"]
|
|
@@ -14629,7 +14634,7 @@ function createMycoServer(config2) {
|
|
|
14629
14634
|
{ name: "myco", version: getPluginVersion() },
|
|
14630
14635
|
{ capabilities: { tools: {} } }
|
|
14631
14636
|
);
|
|
14632
|
-
const dbPath =
|
|
14637
|
+
const dbPath = path5.join(config2.vaultDir, "index.db");
|
|
14633
14638
|
let index = null;
|
|
14634
14639
|
function getIndex() {
|
|
14635
14640
|
if (!index) {
|
|
@@ -14647,11 +14652,11 @@ function createMycoServer(config2) {
|
|
|
14647
14652
|
tools: TOOL_DEFINITIONS
|
|
14648
14653
|
}));
|
|
14649
14654
|
function logActivity(tool, detail) {
|
|
14650
|
-
const logDir =
|
|
14655
|
+
const logDir = path5.join(config2.vaultDir, "logs");
|
|
14651
14656
|
try {
|
|
14652
14657
|
fs3.mkdirSync(logDir, { recursive: true });
|
|
14653
14658
|
const entry = JSON.stringify({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), component: "mcp", level: "info", tool, ...detail }) + "\n";
|
|
14654
|
-
fs3.appendFileSync(
|
|
14659
|
+
fs3.appendFileSync(path5.join(logDir, "mcp.jsonl"), entry);
|
|
14655
14660
|
} catch {
|
|
14656
14661
|
}
|
|
14657
14662
|
}
|
|
@@ -14718,14 +14723,14 @@ function createMycoServer(config2) {
|
|
|
14718
14723
|
}
|
|
14719
14724
|
async function main() {
|
|
14720
14725
|
const vaultDir = resolveVaultDir();
|
|
14721
|
-
const config2 = fs3.existsSync(
|
|
14726
|
+
const config2 = fs3.existsSync(path5.join(vaultDir, "myco.yaml")) ? loadConfig(vaultDir) : void 0;
|
|
14722
14727
|
let embeddingProvider;
|
|
14723
14728
|
let vectorIndex;
|
|
14724
14729
|
if (config2) {
|
|
14725
14730
|
try {
|
|
14726
14731
|
embeddingProvider = createEmbeddingProvider(config2.intelligence.embedding);
|
|
14727
14732
|
const testEmbed = await embeddingProvider.embed("test");
|
|
14728
|
-
vectorIndex = new VectorIndex(
|
|
14733
|
+
vectorIndex = new VectorIndex(path5.join(vaultDir, "vectors.db"), testEmbed.dimensions);
|
|
14729
14734
|
} catch {
|
|
14730
14735
|
}
|
|
14731
14736
|
}
|
|
@@ -14741,4 +14746,4 @@ export {
|
|
|
14741
14746
|
createMycoServer,
|
|
14742
14747
|
main
|
|
14743
14748
|
};
|
|
14744
|
-
//# sourceMappingURL=server-
|
|
14749
|
+
//# sourceMappingURL=server-REMXRVYP.js.map
|