@goondocks/myco 0.2.13 → 0.2.14
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-UUFDD2FB.js +56 -0
- package/dist/chunk-UUFDD2FB.js.map +1 -0
- package/dist/{main-ORWCEWNJ.js → main-UJAXPP6S.js} +32 -2
- package/dist/{main-ORWCEWNJ.js.map → main-UJAXPP6S.js.map} +1 -1
- package/dist/src/cli.js +6 -0
- package/dist/src/cli.js.map +1 -1
- package/dist/src/daemon/main.js +7 -1
- package/dist/src/daemon/main.js.map +1 -1
- package/dist/src/hooks/session-start.js +6 -0
- package/dist/src/hooks/session-start.js.map +1 -1
- package/dist/src/mcp/server.js +6 -0
- package/dist/src/mcp/server.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
AgentRegistry
|
|
4
|
+
} from "./chunk-BXFS4PCJ.js";
|
|
5
|
+
|
|
6
|
+
// src/native-deps.ts
|
|
7
|
+
import { execFileSync } from "child_process";
|
|
8
|
+
import { createRequire } from "module";
|
|
9
|
+
import path from "path";
|
|
10
|
+
import fs from "fs";
|
|
11
|
+
var NATIVE_PACKAGES = ["better-sqlite3", "sqlite-vec"];
|
|
12
|
+
function findPluginRoot() {
|
|
13
|
+
const fromRegistry = new AgentRegistry().resolvePluginRoot();
|
|
14
|
+
if (fromRegistry) return fromRegistry;
|
|
15
|
+
let dir = path.dirname(new URL(import.meta.url).pathname);
|
|
16
|
+
for (let i = 0; i < 5; i++) {
|
|
17
|
+
if (fs.existsSync(path.join(dir, "package.json"))) return dir;
|
|
18
|
+
dir = path.dirname(dir);
|
|
19
|
+
}
|
|
20
|
+
return process.cwd();
|
|
21
|
+
}
|
|
22
|
+
function ensureNativeDeps() {
|
|
23
|
+
const pluginRoot = findPluginRoot();
|
|
24
|
+
const require2 = createRequire(path.join(pluginRoot, "node_modules", ".package.json"));
|
|
25
|
+
const missing = [];
|
|
26
|
+
for (const pkg of NATIVE_PACKAGES) {
|
|
27
|
+
try {
|
|
28
|
+
require2.resolve(pkg);
|
|
29
|
+
} catch {
|
|
30
|
+
missing.push(pkg);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (missing.length === 0) return;
|
|
34
|
+
const nodeModulesDir = path.join(pluginRoot, "node_modules");
|
|
35
|
+
if (!fs.existsSync(nodeModulesDir)) {
|
|
36
|
+
fs.mkdirSync(nodeModulesDir, { recursive: true });
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
execFileSync("npm", ["install", "--no-save", "--no-package-lock", ...missing], {
|
|
40
|
+
cwd: pluginRoot,
|
|
41
|
+
stdio: "pipe",
|
|
42
|
+
timeout: 12e4
|
|
43
|
+
});
|
|
44
|
+
} catch (error) {
|
|
45
|
+
const msg = error.message;
|
|
46
|
+
process.stderr.write(`[myco] Failed to install native dependencies: ${msg}
|
|
47
|
+
`);
|
|
48
|
+
process.stderr.write(`[myco] You can install them manually: cd ${pluginRoot} && npm install ${missing.join(" ")}
|
|
49
|
+
`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export {
|
|
54
|
+
ensureNativeDeps
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=chunk-UUFDD2FB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/native-deps.ts"],"sourcesContent":["/**\n * Ensures native npm dependencies (better-sqlite3, sqlite-vec) are available.\n *\n * When the plugin is installed from a marketplace, only the bundled\n * JS files are present in the cache directory — node_modules is stripped.\n * Native modules cannot be bundled by tsup/esbuild, so we install them on\n * first use into the plugin's cache directory.\n */\nimport { execFileSync } from 'node:child_process';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\nimport fs from 'node:fs';\nimport { AgentRegistry } from './agents/registry.js';\n\nconst NATIVE_PACKAGES = ['better-sqlite3', 'sqlite-vec'] as const;\n\n/**\n * Detect the plugin root via the active agent's env var (CLAUDE_PLUGIN_ROOT,\n * CURSOR_PLUGIN_ROOT, etc.), falling back to walking up from this file.\n */\nfunction findPluginRoot(): string {\n const fromRegistry = new AgentRegistry().resolvePluginRoot();\n if (fromRegistry) return fromRegistry;\n\n // Fallback: walk up from dist/src/ to find package.json\n let dir = path.dirname(new URL(import.meta.url).pathname);\n for (let i = 0; i < 5; i++) {\n if (fs.existsSync(path.join(dir, 'package.json'))) return dir;\n dir = path.dirname(dir);\n }\n return process.cwd();\n}\n\nexport function ensureNativeDeps(): void {\n const pluginRoot = findPluginRoot();\n const require = createRequire(path.join(pluginRoot, 'node_modules', '.package.json'));\n\n const missing: string[] = [];\n for (const pkg of NATIVE_PACKAGES) {\n try {\n require.resolve(pkg);\n } catch {\n missing.push(pkg);\n }\n }\n\n if (missing.length === 0) return;\n\n const nodeModulesDir = path.join(pluginRoot, 'node_modules');\n if (!fs.existsSync(nodeModulesDir)) {\n fs.mkdirSync(nodeModulesDir, { recursive: true });\n }\n\n try {\n execFileSync('npm', ['install', '--no-save', '--no-package-lock', ...missing], {\n cwd: pluginRoot,\n stdio: 'pipe',\n timeout: 120_000,\n });\n } catch (error) {\n const msg = (error as Error).message;\n process.stderr.write(`[myco] Failed to install native dependencies: ${msg}\\n`);\n process.stderr.write(`[myco] You can install them manually: cd ${pluginRoot} && npm install ${missing.join(' ')}\\n`);\n }\n}\n"],"mappings":";;;;;;AAQA,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,OAAO,UAAU;AACjB,OAAO,QAAQ;AAGf,IAAM,kBAAkB,CAAC,kBAAkB,YAAY;AAMvD,SAAS,iBAAyB;AAChC,QAAM,eAAe,IAAI,cAAc,EAAE,kBAAkB;AAC3D,MAAI,aAAc,QAAO;AAGzB,MAAI,MAAM,KAAK,QAAQ,IAAI,IAAI,YAAY,GAAG,EAAE,QAAQ;AACxD,WAAS,IAAI,GAAG,IAAI,GAAG,KAAK;AAC1B,QAAI,GAAG,WAAW,KAAK,KAAK,KAAK,cAAc,CAAC,EAAG,QAAO;AAC1D,UAAM,KAAK,QAAQ,GAAG;AAAA,EACxB;AACA,SAAO,QAAQ,IAAI;AACrB;AAEO,SAAS,mBAAyB;AACvC,QAAM,aAAa,eAAe;AAClC,QAAMA,WAAU,cAAc,KAAK,KAAK,YAAY,gBAAgB,eAAe,CAAC;AAEpF,QAAM,UAAoB,CAAC;AAC3B,aAAW,OAAO,iBAAiB;AACjC,QAAI;AACF,MAAAA,SAAQ,QAAQ,GAAG;AAAA,IACrB,QAAQ;AACN,cAAQ,KAAK,GAAG;AAAA,IAClB;AAAA,EACF;AAEA,MAAI,QAAQ,WAAW,EAAG;AAE1B,QAAM,iBAAiB,KAAK,KAAK,YAAY,cAAc;AAC3D,MAAI,CAAC,GAAG,WAAW,cAAc,GAAG;AAClC,OAAG,UAAU,gBAAgB,EAAE,WAAW,KAAK,CAAC;AAAA,EAClD;AAEA,MAAI;AACF,iBAAa,OAAO,CAAC,WAAW,aAAa,qBAAqB,GAAG,OAAO,GAAG;AAAA,MAC7E,KAAK;AAAA,MACL,OAAO;AAAA,MACP,SAAS;AAAA,IACX,CAAC;AAAA,EACH,SAAS,OAAO;AACd,UAAM,MAAO,MAAgB;AAC7B,YAAQ,OAAO,MAAM,iDAAiD,GAAG;AAAA,CAAI;AAC7E,YAAQ,OAAO,MAAM,4CAA4C,UAAU,mBAAmB,QAAQ,KAAK,GAAG,CAAC;AAAA,CAAI;AAAA,EACrH;AACF;","names":["require"]}
|
|
@@ -2696,6 +2696,7 @@ async function main() {
|
|
|
2696
2696
|
const bufferDir = path7.join(vaultDir, "buffer");
|
|
2697
2697
|
const sessionBuffers = /* @__PURE__ */ new Map();
|
|
2698
2698
|
const sessionFilePaths = /* @__PURE__ */ new Map();
|
|
2699
|
+
const capturedArtifactPaths = /* @__PURE__ */ new Map();
|
|
2699
2700
|
if (fs5.existsSync(bufferDir)) {
|
|
2700
2701
|
const cutoff = Date.now() - STALE_BUFFER_MAX_AGE_MS;
|
|
2701
2702
|
for (const file of fs5.readdirSync(bufferDir)) {
|
|
@@ -2776,6 +2777,31 @@ ${content}`,
|
|
|
2776
2777
|
observations: result.observations.length,
|
|
2777
2778
|
degraded: result.degraded
|
|
2778
2779
|
});
|
|
2780
|
+
const allPaths = sessionFilePaths.get(sessionId);
|
|
2781
|
+
const alreadyCaptured = capturedArtifactPaths.get(sessionId) ?? /* @__PURE__ */ new Set();
|
|
2782
|
+
if (allPaths && allPaths.size > alreadyCaptured.size) {
|
|
2783
|
+
const newPaths = new Set([...allPaths].filter((p) => !alreadyCaptured.has(p)));
|
|
2784
|
+
const candidates = collectArtifactCandidates(
|
|
2785
|
+
newPaths,
|
|
2786
|
+
{ artifact_extensions: config.capture.artifact_extensions },
|
|
2787
|
+
process.cwd()
|
|
2788
|
+
);
|
|
2789
|
+
if (candidates.length > 0) {
|
|
2790
|
+
processor.classifyArtifacts(candidates, sessionId).then((classified) => captureArtifacts(candidates, classified, sessionId, { vault, ...indexDeps }, lineageGraph)).then(() => {
|
|
2791
|
+
if (!capturedArtifactPaths.has(sessionId)) {
|
|
2792
|
+
capturedArtifactPaths.set(sessionId, /* @__PURE__ */ new Set());
|
|
2793
|
+
}
|
|
2794
|
+
const captured = capturedArtifactPaths.get(sessionId);
|
|
2795
|
+
for (const c of candidates) {
|
|
2796
|
+
const absPath = path7.resolve(process.cwd(), c.path);
|
|
2797
|
+
captured.add(absPath);
|
|
2798
|
+
}
|
|
2799
|
+
}).catch((err) => logger.warn("processor", "Incremental artifact capture failed", {
|
|
2800
|
+
session_id: sessionId,
|
|
2801
|
+
error: err.message
|
|
2802
|
+
}));
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2779
2805
|
});
|
|
2780
2806
|
server.registerRoute("POST", "/sessions/register", async (body) => {
|
|
2781
2807
|
const { session_id, branch, started_at } = RegisterBody.parse(body);
|
|
@@ -2821,6 +2847,7 @@ ${content}`,
|
|
|
2821
2847
|
}
|
|
2822
2848
|
sessionBuffers.delete(session_id);
|
|
2823
2849
|
sessionFilePaths.delete(session_id);
|
|
2850
|
+
capturedArtifactPaths.delete(session_id);
|
|
2824
2851
|
server.updateDaemonJsonSessions(registry.sessions);
|
|
2825
2852
|
logger.info("lifecycle", "Session unregistered", { session_id });
|
|
2826
2853
|
return { ok: true, sessions: registry.sessions };
|
|
@@ -2849,6 +2876,7 @@ ${content}`,
|
|
|
2849
2876
|
sessionFilePaths.set(event.session_id, /* @__PURE__ */ new Set());
|
|
2850
2877
|
}
|
|
2851
2878
|
sessionFilePaths.get(event.session_id).add(filePath);
|
|
2879
|
+
capturedArtifactPaths.get(event.session_id)?.delete(filePath);
|
|
2852
2880
|
}
|
|
2853
2881
|
}
|
|
2854
2882
|
}
|
|
@@ -2932,8 +2960,10 @@ ${content}`,
|
|
|
2932
2960
|
existingTurnCount = turnMatches?.length ?? 0;
|
|
2933
2961
|
}
|
|
2934
2962
|
const writtenFiles = sessionFilePaths.get(sessionId) ?? /* @__PURE__ */ new Set();
|
|
2963
|
+
const alreadyCaptured = capturedArtifactPaths.get(sessionId) ?? /* @__PURE__ */ new Set();
|
|
2964
|
+
const uncapturedFiles = new Set([...writtenFiles].filter((p) => !alreadyCaptured.has(p)));
|
|
2935
2965
|
const artifactCandidates = collectArtifactCandidates(
|
|
2936
|
-
|
|
2966
|
+
uncapturedFiles,
|
|
2937
2967
|
{ artifact_extensions: config.capture.artifact_extensions },
|
|
2938
2968
|
process.cwd()
|
|
2939
2969
|
);
|
|
@@ -3211,4 +3241,4 @@ export {
|
|
|
3211
3241
|
chokidar/index.js:
|
|
3212
3242
|
(*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) *)
|
|
3213
3243
|
*/
|
|
3214
|
-
//# sourceMappingURL=main-
|
|
3244
|
+
//# sourceMappingURL=main-UJAXPP6S.js.map
|