@goondocks/myco 0.4.3 → 0.5.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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +5 -1
- package/dist/chunk-2AMAOSRF.js +105 -0
- package/dist/chunk-2AMAOSRF.js.map +1 -0
- package/dist/{chunk-I7PNZEBO.js → chunk-6LTNFMXO.js} +12 -1
- package/dist/{chunk-I7PNZEBO.js.map → chunk-6LTNFMXO.js.map} +1 -1
- package/dist/{chunk-2GJFTIWX.js → chunk-7KQB22DP.js} +2 -2
- package/dist/{chunk-JBD5KP5G.js → chunk-B6WVNDA5.js} +14 -2
- package/dist/chunk-B6WVNDA5.js.map +1 -0
- package/dist/chunk-FIA5NTRH.js +159 -0
- package/dist/chunk-FIA5NTRH.js.map +1 -0
- package/dist/{chunk-GFBG73P4.js → chunk-FIRMTYFH.js} +3 -3
- package/dist/{chunk-XCPQHC4X.js → chunk-HJG7Z6SJ.js} +2 -2
- package/dist/chunk-HL2S5QZG.js +385 -0
- package/dist/chunk-HL2S5QZG.js.map +1 -0
- package/dist/{chunk-WBT5DWGC.js → chunk-IURC35BF.js} +2 -2
- package/dist/{chunk-67R6EMYD.js → chunk-JI6M2L2W.js} +31 -52
- package/dist/chunk-JI6M2L2W.js.map +1 -0
- package/dist/{chunk-FPEDTLQ6.js → chunk-JJL6AMDA.js} +3 -101
- package/dist/chunk-JJL6AMDA.js.map +1 -0
- package/dist/chunk-KYL67SKZ.js +150 -0
- package/dist/chunk-KYL67SKZ.js.map +1 -0
- package/dist/{chunk-ZCBL5HER.js → chunk-ND4VK6C7.js} +2 -2
- package/dist/{chunk-V2OWD2VV.js → chunk-R6LQT3U7.js} +24 -146
- package/dist/chunk-R6LQT3U7.js.map +1 -0
- package/dist/{chunk-IYFKPSRP.js → chunk-RCV2I4AI.js} +3 -3
- package/dist/{chunk-BNIYWCST.js → chunk-X6TKHO22.js} +2 -2
- package/dist/{chunk-OUFSLZTX.js → chunk-ZWUFTOG3.js} +21 -9
- package/dist/chunk-ZWUFTOG3.js.map +1 -0
- package/dist/{cli-PMOFCZQL.js → cli-BLYNNKGJ.js} +24 -18
- package/dist/cli-BLYNNKGJ.js.map +1 -0
- package/dist/{client-5SUO2UYH.js → client-5GB4WVXE.js} +5 -5
- package/dist/curate-S4HOYWXA.js +231 -0
- package/dist/curate-S4HOYWXA.js.map +1 -0
- package/dist/{detect-providers-IRL2TTLK.js → detect-providers-BIHYFK5M.js} +3 -3
- package/dist/digest-7NKYXM6G.js +96 -0
- package/dist/digest-7NKYXM6G.js.map +1 -0
- package/dist/{init-NUF5UBUJ.js → init-HPQ77WWF.js} +5 -5
- package/dist/{main-2XEBVUR6.js → main-NFQ4II75.js} +253 -576
- package/dist/main-NFQ4II75.js.map +1 -0
- package/dist/{rebuild-E6YFIRYZ.js → rebuild-KQ6G2GZM.js} +8 -7
- package/dist/{rebuild-E6YFIRYZ.js.map → rebuild-KQ6G2GZM.js.map} +1 -1
- package/dist/{reprocess-7G7KQWCN.js → reprocess-ZL4HKTSC.js} +95 -24
- package/dist/reprocess-ZL4HKTSC.js.map +1 -0
- package/dist/{restart-ABW4ZK3P.js → restart-FYW662DR.js} +6 -6
- package/dist/{search-MPD7SFK6.js → search-E5JQMTXV.js} +6 -6
- package/dist/{server-NZLZRITH.js → server-TV3D35HZ.js} +38 -15
- package/dist/{server-NZLZRITH.js.map → server-TV3D35HZ.js.map} +1 -1
- package/dist/{session-start-YB4A4PZB.js → session-start-5MFEOVQ5.js} +6 -6
- package/dist/{setup-digest-K732MGOJ.js → setup-digest-DZAFIBEF.js} +5 -5
- package/dist/{setup-llm-XCCH5LYD.js → setup-llm-4BZM33YT.js} +5 -5
- package/dist/src/cli.js +4 -4
- package/dist/src/daemon/main.js +4 -4
- package/dist/src/hooks/post-tool-use.js +5 -5
- package/dist/src/hooks/session-end.js +5 -5
- package/dist/src/hooks/session-start.js +4 -4
- package/dist/src/hooks/stop.js +6 -6
- package/dist/src/hooks/stop.js.map +1 -1
- package/dist/src/hooks/user-prompt-submit.js +5 -5
- package/dist/src/mcp/server.js +4 -4
- package/dist/src/prompts/extraction.md +1 -1
- package/dist/src/prompts/summary.md +1 -11
- package/dist/src/prompts/supersession.md +32 -0
- package/dist/{stats-6G7SN5YZ.js → stats-ZIIJ2GB3.js} +5 -5
- package/dist/{verify-JFHQH55Z.js → verify-RACBFT2P.js} +4 -4
- package/dist/{version-5B2TWXQJ.js → version-HJTVNPOO.js} +4 -4
- package/package.json +1 -1
- package/skills/setup/SKILL.md +56 -28
- package/skills/setup/references/model-recommendations.md +49 -43
- package/dist/chunk-67R6EMYD.js.map +0 -1
- package/dist/chunk-FPEDTLQ6.js.map +0 -1
- package/dist/chunk-JBD5KP5G.js.map +0 -1
- package/dist/chunk-OUFSLZTX.js.map +0 -1
- package/dist/chunk-V2OWD2VV.js.map +0 -1
- package/dist/cli-PMOFCZQL.js.map +0 -1
- package/dist/main-2XEBVUR6.js.map +0 -1
- package/dist/reprocess-7G7KQWCN.js.map +0 -1
- /package/dist/{chunk-2GJFTIWX.js.map → chunk-7KQB22DP.js.map} +0 -0
- /package/dist/{chunk-GFBG73P4.js.map → chunk-FIRMTYFH.js.map} +0 -0
- /package/dist/{chunk-XCPQHC4X.js.map → chunk-HJG7Z6SJ.js.map} +0 -0
- /package/dist/{chunk-WBT5DWGC.js.map → chunk-IURC35BF.js.map} +0 -0
- /package/dist/{chunk-ZCBL5HER.js.map → chunk-ND4VK6C7.js.map} +0 -0
- /package/dist/{chunk-IYFKPSRP.js.map → chunk-RCV2I4AI.js.map} +0 -0
- /package/dist/{chunk-BNIYWCST.js.map → chunk-X6TKHO22.js.map} +0 -0
- /package/dist/{client-5SUO2UYH.js.map → client-5GB4WVXE.js.map} +0 -0
- /package/dist/{detect-providers-IRL2TTLK.js.map → detect-providers-BIHYFK5M.js.map} +0 -0
- /package/dist/{init-NUF5UBUJ.js.map → init-HPQ77WWF.js.map} +0 -0
- /package/dist/{restart-ABW4ZK3P.js.map → restart-FYW662DR.js.map} +0 -0
- /package/dist/{search-MPD7SFK6.js.map → search-E5JQMTXV.js.map} +0 -0
- /package/dist/{session-start-YB4A4PZB.js.map → session-start-5MFEOVQ5.js.map} +0 -0
- /package/dist/{setup-digest-K732MGOJ.js.map → setup-digest-DZAFIBEF.js.map} +0 -0
- /package/dist/{setup-llm-XCCH5LYD.js.map → setup-llm-4BZM33YT.js.map} +0 -0
- /package/dist/{stats-6G7SN5YZ.js.map → stats-ZIIJ2GB3.js.map} +0 -0
- /package/dist/{verify-JFHQH55Z.js.map → verify-RACBFT2P.js.map} +0 -0
- /package/dist/{version-5B2TWXQJ.js.map → version-HJTVNPOO.js.map} +0 -0
|
@@ -2,19 +2,16 @@ import { createRequire as __cr } from 'node:module'; const require = __cr(import
|
|
|
2
2
|
import {
|
|
3
3
|
BufferProcessor,
|
|
4
4
|
TranscriptMiner,
|
|
5
|
-
buildSimilarityPrompt,
|
|
6
|
-
extractNumber,
|
|
7
5
|
extractTurnsFromBuffer,
|
|
8
|
-
loadPrompt,
|
|
9
|
-
stripReasoningTokens,
|
|
10
6
|
writeObservationNotes
|
|
11
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-R6LQT3U7.js";
|
|
12
8
|
import {
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
DigestEngine,
|
|
10
|
+
Metabolism
|
|
11
|
+
} from "./chunk-HL2S5QZG.js";
|
|
15
12
|
import {
|
|
16
|
-
|
|
17
|
-
} from "./chunk-
|
|
13
|
+
handleMycoContext
|
|
14
|
+
} from "./chunk-IURC35BF.js";
|
|
18
15
|
import {
|
|
19
16
|
VaultWriter,
|
|
20
17
|
bareSessionId,
|
|
@@ -22,31 +19,40 @@ import {
|
|
|
22
19
|
sessionNoteId,
|
|
23
20
|
sessionRelativePath,
|
|
24
21
|
sessionWikilink
|
|
25
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-6LTNFMXO.js";
|
|
23
|
+
import {
|
|
24
|
+
DaemonLogger
|
|
25
|
+
} from "./chunk-5EZ7QF6J.js";
|
|
26
|
+
import {
|
|
27
|
+
checkSupersession
|
|
28
|
+
} from "./chunk-FIA5NTRH.js";
|
|
26
29
|
import {
|
|
27
30
|
indexNote,
|
|
28
31
|
rebuildIndex
|
|
29
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-JJL6AMDA.js";
|
|
30
33
|
import {
|
|
31
34
|
generateEmbedding
|
|
32
35
|
} from "./chunk-RGVBGTD6.js";
|
|
33
|
-
import {
|
|
34
|
-
createEmbeddingProvider,
|
|
35
|
-
createLlmProvider
|
|
36
|
-
} from "./chunk-IYFKPSRP.js";
|
|
37
36
|
import {
|
|
38
37
|
VectorIndex
|
|
39
38
|
} from "./chunk-XQXXF6MU.js";
|
|
40
39
|
import {
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
buildSimilarityPrompt,
|
|
41
|
+
extractNumber
|
|
42
|
+
} from "./chunk-KYL67SKZ.js";
|
|
43
|
+
import "./chunk-2AMAOSRF.js";
|
|
44
|
+
import {
|
|
45
|
+
createEmbeddingProvider,
|
|
46
|
+
createLlmProvider
|
|
47
|
+
} from "./chunk-RCV2I4AI.js";
|
|
48
|
+
import "./chunk-MIU3DKLN.js";
|
|
43
49
|
import {
|
|
44
50
|
initFts
|
|
45
51
|
} from "./chunk-6FQISQNA.js";
|
|
46
52
|
import {
|
|
47
53
|
MycoIndex
|
|
48
54
|
} from "./chunk-AK6GNLPV.js";
|
|
49
|
-
import "./chunk-
|
|
55
|
+
import "./chunk-JI6M2L2W.js";
|
|
50
56
|
import {
|
|
51
57
|
loadConfig
|
|
52
58
|
} from "./chunk-TBRZAJ7W.js";
|
|
@@ -59,32 +65,28 @@ import {
|
|
|
59
65
|
} from "./chunk-HIN3UVOG.js";
|
|
60
66
|
import {
|
|
61
67
|
getPluginVersion
|
|
62
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-7KQB22DP.js";
|
|
63
69
|
import {
|
|
64
70
|
claudeCodeAdapter,
|
|
65
71
|
createPerProjectAdapter,
|
|
66
72
|
extensionForMimeType
|
|
67
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-X6TKHO22.js";
|
|
68
74
|
import {
|
|
69
75
|
CANDIDATE_CONTENT_PREVIEW,
|
|
70
|
-
CHARS_PER_TOKEN,
|
|
71
76
|
CONTENT_SNIPPET_CHARS,
|
|
72
77
|
CONTEXT_SESSION_PREVIEW_CHARS,
|
|
73
|
-
DIGEST_LLM_REQUEST_TIMEOUT_MS,
|
|
74
|
-
DIGEST_SUBSTRATE_TYPE_WEIGHTS,
|
|
75
|
-
DIGEST_TIER_MIN_CONTEXT,
|
|
76
78
|
EMBEDDING_INPUT_LIMIT,
|
|
77
79
|
FILE_WATCH_STABILITY_MS,
|
|
78
80
|
LINEAGE_RECENT_SESSIONS_LIMIT,
|
|
81
|
+
LLM_REASONING_MODE,
|
|
79
82
|
MAX_SLUG_LENGTH,
|
|
80
83
|
PROMPT_CONTEXT_MAX_SPORES,
|
|
81
84
|
PROMPT_CONTEXT_MIN_LENGTH,
|
|
82
85
|
PROMPT_CONTEXT_MIN_SIMILARITY,
|
|
83
86
|
RELATED_SPORES_LIMIT,
|
|
84
87
|
SESSION_CONTEXT_MAX_PLANS,
|
|
85
|
-
STALE_BUFFER_MAX_AGE_MS
|
|
86
|
-
|
|
87
|
-
} from "./chunk-JBD5KP5G.js";
|
|
88
|
+
STALE_BUFFER_MAX_AGE_MS
|
|
89
|
+
} from "./chunk-B6WVNDA5.js";
|
|
88
90
|
import {
|
|
89
91
|
__toESM
|
|
90
92
|
} from "./chunk-PZUWP5VK.js";
|
|
@@ -496,7 +498,7 @@ var ReaddirpStream = class extends Readable {
|
|
|
496
498
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
497
499
|
const statMethod = opts.lstat ? lstat : stat;
|
|
498
500
|
if (wantBigintFsStats) {
|
|
499
|
-
this._stat = (
|
|
501
|
+
this._stat = (path7) => statMethod(path7, { bigint: true });
|
|
500
502
|
} else {
|
|
501
503
|
this._stat = statMethod;
|
|
502
504
|
}
|
|
@@ -521,8 +523,8 @@ var ReaddirpStream = class extends Readable {
|
|
|
521
523
|
const par = this.parent;
|
|
522
524
|
const fil = par && par.files;
|
|
523
525
|
if (fil && fil.length > 0) {
|
|
524
|
-
const { path:
|
|
525
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
526
|
+
const { path: path7, depth } = par;
|
|
527
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path7));
|
|
526
528
|
const awaited = await Promise.all(slice);
|
|
527
529
|
for (const entry of awaited) {
|
|
528
530
|
if (!entry)
|
|
@@ -562,20 +564,20 @@ var ReaddirpStream = class extends Readable {
|
|
|
562
564
|
this.reading = false;
|
|
563
565
|
}
|
|
564
566
|
}
|
|
565
|
-
async _exploreDir(
|
|
567
|
+
async _exploreDir(path7, depth) {
|
|
566
568
|
let files;
|
|
567
569
|
try {
|
|
568
|
-
files = await readdir(
|
|
570
|
+
files = await readdir(path7, this._rdOptions);
|
|
569
571
|
} catch (error) {
|
|
570
572
|
this._onError(error);
|
|
571
573
|
}
|
|
572
|
-
return { files, depth, path:
|
|
574
|
+
return { files, depth, path: path7 };
|
|
573
575
|
}
|
|
574
|
-
async _formatEntry(dirent,
|
|
576
|
+
async _formatEntry(dirent, path7) {
|
|
575
577
|
let entry;
|
|
576
578
|
const basename3 = this._isDirent ? dirent.name : dirent;
|
|
577
579
|
try {
|
|
578
|
-
const fullPath = presolve(pjoin(
|
|
580
|
+
const fullPath = presolve(pjoin(path7, basename3));
|
|
579
581
|
entry = { path: prelative(this._root, fullPath), fullPath, basename: basename3 };
|
|
580
582
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
581
583
|
} catch (err) {
|
|
@@ -975,16 +977,16 @@ var delFromSet = (main2, prop, item) => {
|
|
|
975
977
|
};
|
|
976
978
|
var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
|
|
977
979
|
var FsWatchInstances = /* @__PURE__ */ new Map();
|
|
978
|
-
function createFsWatchInstance(
|
|
980
|
+
function createFsWatchInstance(path7, options, listener, errHandler, emitRaw) {
|
|
979
981
|
const handleEvent = (rawEvent, evPath) => {
|
|
980
|
-
listener(
|
|
981
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
982
|
-
if (evPath &&
|
|
983
|
-
fsWatchBroadcast(sp.resolve(
|
|
982
|
+
listener(path7);
|
|
983
|
+
emitRaw(rawEvent, evPath, { watchedPath: path7 });
|
|
984
|
+
if (evPath && path7 !== evPath) {
|
|
985
|
+
fsWatchBroadcast(sp.resolve(path7, evPath), KEY_LISTENERS, sp.join(path7, evPath));
|
|
984
986
|
}
|
|
985
987
|
};
|
|
986
988
|
try {
|
|
987
|
-
return fs_watch(
|
|
989
|
+
return fs_watch(path7, {
|
|
988
990
|
persistent: options.persistent
|
|
989
991
|
}, handleEvent);
|
|
990
992
|
} catch (error) {
|
|
@@ -1000,12 +1002,12 @@ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
|
|
|
1000
1002
|
listener(val1, val2, val3);
|
|
1001
1003
|
});
|
|
1002
1004
|
};
|
|
1003
|
-
var setFsWatchListener = (
|
|
1005
|
+
var setFsWatchListener = (path7, fullPath, options, handlers) => {
|
|
1004
1006
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
1005
1007
|
let cont = FsWatchInstances.get(fullPath);
|
|
1006
1008
|
let watcher;
|
|
1007
1009
|
if (!options.persistent) {
|
|
1008
|
-
watcher = createFsWatchInstance(
|
|
1010
|
+
watcher = createFsWatchInstance(path7, options, listener, errHandler, rawEmitter);
|
|
1009
1011
|
if (!watcher)
|
|
1010
1012
|
return;
|
|
1011
1013
|
return watcher.close.bind(watcher);
|
|
@@ -1016,7 +1018,7 @@ var setFsWatchListener = (path8, fullPath, options, handlers) => {
|
|
|
1016
1018
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
1017
1019
|
} else {
|
|
1018
1020
|
watcher = createFsWatchInstance(
|
|
1019
|
-
|
|
1021
|
+
path7,
|
|
1020
1022
|
options,
|
|
1021
1023
|
fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
|
|
1022
1024
|
errHandler,
|
|
@@ -1031,7 +1033,7 @@ var setFsWatchListener = (path8, fullPath, options, handlers) => {
|
|
|
1031
1033
|
cont.watcherUnusable = true;
|
|
1032
1034
|
if (isWindows && error.code === "EPERM") {
|
|
1033
1035
|
try {
|
|
1034
|
-
const fd = await open(
|
|
1036
|
+
const fd = await open(path7, "r");
|
|
1035
1037
|
await fd.close();
|
|
1036
1038
|
broadcastErr(error);
|
|
1037
1039
|
} catch (err) {
|
|
@@ -1062,7 +1064,7 @@ var setFsWatchListener = (path8, fullPath, options, handlers) => {
|
|
|
1062
1064
|
};
|
|
1063
1065
|
};
|
|
1064
1066
|
var FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
1065
|
-
var setFsWatchFileListener = (
|
|
1067
|
+
var setFsWatchFileListener = (path7, fullPath, options, handlers) => {
|
|
1066
1068
|
const { listener, rawEmitter } = handlers;
|
|
1067
1069
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
1068
1070
|
const copts = cont && cont.options;
|
|
@@ -1084,7 +1086,7 @@ var setFsWatchFileListener = (path8, fullPath, options, handlers) => {
|
|
|
1084
1086
|
});
|
|
1085
1087
|
const currmtime = curr.mtimeMs;
|
|
1086
1088
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
1087
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
1089
|
+
foreach(cont.listeners, (listener2) => listener2(path7, curr));
|
|
1088
1090
|
}
|
|
1089
1091
|
})
|
|
1090
1092
|
};
|
|
@@ -1114,13 +1116,13 @@ var NodeFsHandler = class {
|
|
|
1114
1116
|
* @param listener on fs change
|
|
1115
1117
|
* @returns closer for the watcher instance
|
|
1116
1118
|
*/
|
|
1117
|
-
_watchWithNodeFs(
|
|
1119
|
+
_watchWithNodeFs(path7, listener) {
|
|
1118
1120
|
const opts = this.fsw.options;
|
|
1119
|
-
const directory = sp.dirname(
|
|
1120
|
-
const basename3 = sp.basename(
|
|
1121
|
+
const directory = sp.dirname(path7);
|
|
1122
|
+
const basename3 = sp.basename(path7);
|
|
1121
1123
|
const parent = this.fsw._getWatchedDir(directory);
|
|
1122
1124
|
parent.add(basename3);
|
|
1123
|
-
const absolutePath = sp.resolve(
|
|
1125
|
+
const absolutePath = sp.resolve(path7);
|
|
1124
1126
|
const options = {
|
|
1125
1127
|
persistent: opts.persistent
|
|
1126
1128
|
};
|
|
@@ -1130,12 +1132,12 @@ var NodeFsHandler = class {
|
|
|
1130
1132
|
if (opts.usePolling) {
|
|
1131
1133
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
1132
1134
|
options.interval = enableBin && isBinaryPath(basename3) ? opts.binaryInterval : opts.interval;
|
|
1133
|
-
closer = setFsWatchFileListener(
|
|
1135
|
+
closer = setFsWatchFileListener(path7, absolutePath, options, {
|
|
1134
1136
|
listener,
|
|
1135
1137
|
rawEmitter: this.fsw._emitRaw
|
|
1136
1138
|
});
|
|
1137
1139
|
} else {
|
|
1138
|
-
closer = setFsWatchListener(
|
|
1140
|
+
closer = setFsWatchListener(path7, absolutePath, options, {
|
|
1139
1141
|
listener,
|
|
1140
1142
|
errHandler: this._boundHandleError,
|
|
1141
1143
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -1157,7 +1159,7 @@ var NodeFsHandler = class {
|
|
|
1157
1159
|
let prevStats = stats;
|
|
1158
1160
|
if (parent.has(basename3))
|
|
1159
1161
|
return;
|
|
1160
|
-
const listener = async (
|
|
1162
|
+
const listener = async (path7, newStats) => {
|
|
1161
1163
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
|
|
1162
1164
|
return;
|
|
1163
1165
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -1171,11 +1173,11 @@ var NodeFsHandler = class {
|
|
|
1171
1173
|
this.fsw._emit(EV.CHANGE, file, newStats2);
|
|
1172
1174
|
}
|
|
1173
1175
|
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
1174
|
-
this.fsw._closeFile(
|
|
1176
|
+
this.fsw._closeFile(path7);
|
|
1175
1177
|
prevStats = newStats2;
|
|
1176
1178
|
const closer2 = this._watchWithNodeFs(file, listener);
|
|
1177
1179
|
if (closer2)
|
|
1178
|
-
this.fsw._addPathCloser(
|
|
1180
|
+
this.fsw._addPathCloser(path7, closer2);
|
|
1179
1181
|
} else {
|
|
1180
1182
|
prevStats = newStats2;
|
|
1181
1183
|
}
|
|
@@ -1207,7 +1209,7 @@ var NodeFsHandler = class {
|
|
|
1207
1209
|
* @param item basename of this item
|
|
1208
1210
|
* @returns true if no more processing is needed for this entry.
|
|
1209
1211
|
*/
|
|
1210
|
-
async _handleSymlink(entry, directory,
|
|
1212
|
+
async _handleSymlink(entry, directory, path7, item) {
|
|
1211
1213
|
if (this.fsw.closed) {
|
|
1212
1214
|
return;
|
|
1213
1215
|
}
|
|
@@ -1217,7 +1219,7 @@ var NodeFsHandler = class {
|
|
|
1217
1219
|
this.fsw._incrReadyCount();
|
|
1218
1220
|
let linkPath;
|
|
1219
1221
|
try {
|
|
1220
|
-
linkPath = await fsrealpath(
|
|
1222
|
+
linkPath = await fsrealpath(path7);
|
|
1221
1223
|
} catch (e) {
|
|
1222
1224
|
this.fsw._emitReady();
|
|
1223
1225
|
return true;
|
|
@@ -1227,12 +1229,12 @@ var NodeFsHandler = class {
|
|
|
1227
1229
|
if (dir.has(item)) {
|
|
1228
1230
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
1229
1231
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
1230
|
-
this.fsw._emit(EV.CHANGE,
|
|
1232
|
+
this.fsw._emit(EV.CHANGE, path7, entry.stats);
|
|
1231
1233
|
}
|
|
1232
1234
|
} else {
|
|
1233
1235
|
dir.add(item);
|
|
1234
1236
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
1235
|
-
this.fsw._emit(EV.ADD,
|
|
1237
|
+
this.fsw._emit(EV.ADD, path7, entry.stats);
|
|
1236
1238
|
}
|
|
1237
1239
|
this.fsw._emitReady();
|
|
1238
1240
|
return true;
|
|
@@ -1262,9 +1264,9 @@ var NodeFsHandler = class {
|
|
|
1262
1264
|
return;
|
|
1263
1265
|
}
|
|
1264
1266
|
const item = entry.path;
|
|
1265
|
-
let
|
|
1267
|
+
let path7 = sp.join(directory, item);
|
|
1266
1268
|
current.add(item);
|
|
1267
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
1269
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path7, item)) {
|
|
1268
1270
|
return;
|
|
1269
1271
|
}
|
|
1270
1272
|
if (this.fsw.closed) {
|
|
@@ -1273,8 +1275,8 @@ var NodeFsHandler = class {
|
|
|
1273
1275
|
}
|
|
1274
1276
|
if (item === target || !target && !previous.has(item)) {
|
|
1275
1277
|
this.fsw._incrReadyCount();
|
|
1276
|
-
|
|
1277
|
-
this._addToNodeFs(
|
|
1278
|
+
path7 = sp.join(dir, sp.relative(dir, path7));
|
|
1279
|
+
this._addToNodeFs(path7, initialAdd, wh, depth + 1);
|
|
1278
1280
|
}
|
|
1279
1281
|
}).on(EV.ERROR, this._boundHandleError);
|
|
1280
1282
|
return new Promise((resolve3, reject) => {
|
|
@@ -1343,13 +1345,13 @@ var NodeFsHandler = class {
|
|
|
1343
1345
|
* @param depth Child path actually targeted for watch
|
|
1344
1346
|
* @param target Child path actually targeted for watch
|
|
1345
1347
|
*/
|
|
1346
|
-
async _addToNodeFs(
|
|
1348
|
+
async _addToNodeFs(path7, initialAdd, priorWh, depth, target) {
|
|
1347
1349
|
const ready = this.fsw._emitReady;
|
|
1348
|
-
if (this.fsw._isIgnored(
|
|
1350
|
+
if (this.fsw._isIgnored(path7) || this.fsw.closed) {
|
|
1349
1351
|
ready();
|
|
1350
1352
|
return false;
|
|
1351
1353
|
}
|
|
1352
|
-
const wh = this.fsw._getWatchHelpers(
|
|
1354
|
+
const wh = this.fsw._getWatchHelpers(path7);
|
|
1353
1355
|
if (priorWh) {
|
|
1354
1356
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
1355
1357
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -1365,8 +1367,8 @@ var NodeFsHandler = class {
|
|
|
1365
1367
|
const follow = this.fsw.options.followSymlinks;
|
|
1366
1368
|
let closer;
|
|
1367
1369
|
if (stats.isDirectory()) {
|
|
1368
|
-
const absPath = sp.resolve(
|
|
1369
|
-
const targetPath = follow ? await fsrealpath(
|
|
1370
|
+
const absPath = sp.resolve(path7);
|
|
1371
|
+
const targetPath = follow ? await fsrealpath(path7) : path7;
|
|
1370
1372
|
if (this.fsw.closed)
|
|
1371
1373
|
return;
|
|
1372
1374
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -1376,29 +1378,29 @@ var NodeFsHandler = class {
|
|
|
1376
1378
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
1377
1379
|
}
|
|
1378
1380
|
} else if (stats.isSymbolicLink()) {
|
|
1379
|
-
const targetPath = follow ? await fsrealpath(
|
|
1381
|
+
const targetPath = follow ? await fsrealpath(path7) : path7;
|
|
1380
1382
|
if (this.fsw.closed)
|
|
1381
1383
|
return;
|
|
1382
1384
|
const parent = sp.dirname(wh.watchPath);
|
|
1383
1385
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
1384
1386
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
1385
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
1387
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path7, wh, targetPath);
|
|
1386
1388
|
if (this.fsw.closed)
|
|
1387
1389
|
return;
|
|
1388
1390
|
if (targetPath !== void 0) {
|
|
1389
|
-
this.fsw._symlinkPaths.set(sp.resolve(
|
|
1391
|
+
this.fsw._symlinkPaths.set(sp.resolve(path7), targetPath);
|
|
1390
1392
|
}
|
|
1391
1393
|
} else {
|
|
1392
1394
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
1393
1395
|
}
|
|
1394
1396
|
ready();
|
|
1395
1397
|
if (closer)
|
|
1396
|
-
this.fsw._addPathCloser(
|
|
1398
|
+
this.fsw._addPathCloser(path7, closer);
|
|
1397
1399
|
return false;
|
|
1398
1400
|
} catch (error) {
|
|
1399
1401
|
if (this.fsw._handleError(error)) {
|
|
1400
1402
|
ready();
|
|
1401
|
-
return
|
|
1403
|
+
return path7;
|
|
1402
1404
|
}
|
|
1403
1405
|
}
|
|
1404
1406
|
}
|
|
@@ -1441,24 +1443,24 @@ function createPattern(matcher) {
|
|
|
1441
1443
|
}
|
|
1442
1444
|
return () => false;
|
|
1443
1445
|
}
|
|
1444
|
-
function normalizePath(
|
|
1445
|
-
if (typeof
|
|
1446
|
+
function normalizePath(path7) {
|
|
1447
|
+
if (typeof path7 !== "string")
|
|
1446
1448
|
throw new Error("string expected");
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
+
path7 = sp2.normalize(path7);
|
|
1450
|
+
path7 = path7.replace(/\\/g, "/");
|
|
1449
1451
|
let prepend = false;
|
|
1450
|
-
if (
|
|
1452
|
+
if (path7.startsWith("//"))
|
|
1451
1453
|
prepend = true;
|
|
1452
|
-
|
|
1454
|
+
path7 = path7.replace(DOUBLE_SLASH_RE, "/");
|
|
1453
1455
|
if (prepend)
|
|
1454
|
-
|
|
1455
|
-
return
|
|
1456
|
+
path7 = "/" + path7;
|
|
1457
|
+
return path7;
|
|
1456
1458
|
}
|
|
1457
1459
|
function matchPatterns(patterns, testString, stats) {
|
|
1458
|
-
const
|
|
1460
|
+
const path7 = normalizePath(testString);
|
|
1459
1461
|
for (let index = 0; index < patterns.length; index++) {
|
|
1460
1462
|
const pattern = patterns[index];
|
|
1461
|
-
if (pattern(
|
|
1463
|
+
if (pattern(path7, stats)) {
|
|
1462
1464
|
return true;
|
|
1463
1465
|
}
|
|
1464
1466
|
}
|
|
@@ -1496,19 +1498,19 @@ var toUnix = (string) => {
|
|
|
1496
1498
|
}
|
|
1497
1499
|
return str;
|
|
1498
1500
|
};
|
|
1499
|
-
var normalizePathToUnix = (
|
|
1500
|
-
var normalizeIgnored = (cwd = "") => (
|
|
1501
|
-
if (typeof
|
|
1502
|
-
return normalizePathToUnix(sp2.isAbsolute(
|
|
1501
|
+
var normalizePathToUnix = (path7) => toUnix(sp2.normalize(toUnix(path7)));
|
|
1502
|
+
var normalizeIgnored = (cwd = "") => (path7) => {
|
|
1503
|
+
if (typeof path7 === "string") {
|
|
1504
|
+
return normalizePathToUnix(sp2.isAbsolute(path7) ? path7 : sp2.join(cwd, path7));
|
|
1503
1505
|
} else {
|
|
1504
|
-
return
|
|
1506
|
+
return path7;
|
|
1505
1507
|
}
|
|
1506
1508
|
};
|
|
1507
|
-
var getAbsolutePath = (
|
|
1508
|
-
if (sp2.isAbsolute(
|
|
1509
|
-
return
|
|
1509
|
+
var getAbsolutePath = (path7, cwd) => {
|
|
1510
|
+
if (sp2.isAbsolute(path7)) {
|
|
1511
|
+
return path7;
|
|
1510
1512
|
}
|
|
1511
|
-
return sp2.join(cwd,
|
|
1513
|
+
return sp2.join(cwd, path7);
|
|
1512
1514
|
};
|
|
1513
1515
|
var EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
1514
1516
|
var DirEntry = class {
|
|
@@ -1573,10 +1575,10 @@ var WatchHelper = class {
|
|
|
1573
1575
|
dirParts;
|
|
1574
1576
|
followSymlinks;
|
|
1575
1577
|
statMethod;
|
|
1576
|
-
constructor(
|
|
1578
|
+
constructor(path7, follow, fsw) {
|
|
1577
1579
|
this.fsw = fsw;
|
|
1578
|
-
const watchPath =
|
|
1579
|
-
this.path =
|
|
1580
|
+
const watchPath = path7;
|
|
1581
|
+
this.path = path7 = path7.replace(REPLACER_RE, "");
|
|
1580
1582
|
this.watchPath = watchPath;
|
|
1581
1583
|
this.fullWatchPath = sp2.resolve(watchPath);
|
|
1582
1584
|
this.dirParts = [];
|
|
@@ -1716,20 +1718,20 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1716
1718
|
this._closePromise = void 0;
|
|
1717
1719
|
let paths = unifyPaths(paths_);
|
|
1718
1720
|
if (cwd) {
|
|
1719
|
-
paths = paths.map((
|
|
1720
|
-
const absPath = getAbsolutePath(
|
|
1721
|
+
paths = paths.map((path7) => {
|
|
1722
|
+
const absPath = getAbsolutePath(path7, cwd);
|
|
1721
1723
|
return absPath;
|
|
1722
1724
|
});
|
|
1723
1725
|
}
|
|
1724
|
-
paths.forEach((
|
|
1725
|
-
this._removeIgnoredPath(
|
|
1726
|
+
paths.forEach((path7) => {
|
|
1727
|
+
this._removeIgnoredPath(path7);
|
|
1726
1728
|
});
|
|
1727
1729
|
this._userIgnored = void 0;
|
|
1728
1730
|
if (!this._readyCount)
|
|
1729
1731
|
this._readyCount = 0;
|
|
1730
1732
|
this._readyCount += paths.length;
|
|
1731
|
-
Promise.all(paths.map(async (
|
|
1732
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
1733
|
+
Promise.all(paths.map(async (path7) => {
|
|
1734
|
+
const res = await this._nodeFsHandler._addToNodeFs(path7, !_internal, void 0, 0, _origAdd);
|
|
1733
1735
|
if (res)
|
|
1734
1736
|
this._emitReady();
|
|
1735
1737
|
return res;
|
|
@@ -1751,17 +1753,17 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1751
1753
|
return this;
|
|
1752
1754
|
const paths = unifyPaths(paths_);
|
|
1753
1755
|
const { cwd } = this.options;
|
|
1754
|
-
paths.forEach((
|
|
1755
|
-
if (!sp2.isAbsolute(
|
|
1756
|
+
paths.forEach((path7) => {
|
|
1757
|
+
if (!sp2.isAbsolute(path7) && !this._closers.has(path7)) {
|
|
1756
1758
|
if (cwd)
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
+
path7 = sp2.join(cwd, path7);
|
|
1760
|
+
path7 = sp2.resolve(path7);
|
|
1759
1761
|
}
|
|
1760
|
-
this._closePath(
|
|
1761
|
-
this._addIgnoredPath(
|
|
1762
|
-
if (this._watched.has(
|
|
1762
|
+
this._closePath(path7);
|
|
1763
|
+
this._addIgnoredPath(path7);
|
|
1764
|
+
if (this._watched.has(path7)) {
|
|
1763
1765
|
this._addIgnoredPath({
|
|
1764
|
-
path:
|
|
1766
|
+
path: path7,
|
|
1765
1767
|
recursive: true
|
|
1766
1768
|
});
|
|
1767
1769
|
}
|
|
@@ -1825,38 +1827,38 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1825
1827
|
* @param stats arguments to be passed with event
|
|
1826
1828
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
1827
1829
|
*/
|
|
1828
|
-
async _emit(event,
|
|
1830
|
+
async _emit(event, path7, stats) {
|
|
1829
1831
|
if (this.closed)
|
|
1830
1832
|
return;
|
|
1831
1833
|
const opts = this.options;
|
|
1832
1834
|
if (isWindows)
|
|
1833
|
-
|
|
1835
|
+
path7 = sp2.normalize(path7);
|
|
1834
1836
|
if (opts.cwd)
|
|
1835
|
-
|
|
1836
|
-
const args = [
|
|
1837
|
+
path7 = sp2.relative(opts.cwd, path7);
|
|
1838
|
+
const args = [path7];
|
|
1837
1839
|
if (stats != null)
|
|
1838
1840
|
args.push(stats);
|
|
1839
1841
|
const awf = opts.awaitWriteFinish;
|
|
1840
1842
|
let pw;
|
|
1841
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
1843
|
+
if (awf && (pw = this._pendingWrites.get(path7))) {
|
|
1842
1844
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
1843
1845
|
return this;
|
|
1844
1846
|
}
|
|
1845
1847
|
if (opts.atomic) {
|
|
1846
1848
|
if (event === EVENTS.UNLINK) {
|
|
1847
|
-
this._pendingUnlinks.set(
|
|
1849
|
+
this._pendingUnlinks.set(path7, [event, ...args]);
|
|
1848
1850
|
setTimeout(() => {
|
|
1849
|
-
this._pendingUnlinks.forEach((entry,
|
|
1851
|
+
this._pendingUnlinks.forEach((entry, path8) => {
|
|
1850
1852
|
this.emit(...entry);
|
|
1851
1853
|
this.emit(EVENTS.ALL, ...entry);
|
|
1852
|
-
this._pendingUnlinks.delete(
|
|
1854
|
+
this._pendingUnlinks.delete(path8);
|
|
1853
1855
|
});
|
|
1854
1856
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
1855
1857
|
return this;
|
|
1856
1858
|
}
|
|
1857
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
1859
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path7)) {
|
|
1858
1860
|
event = EVENTS.CHANGE;
|
|
1859
|
-
this._pendingUnlinks.delete(
|
|
1861
|
+
this._pendingUnlinks.delete(path7);
|
|
1860
1862
|
}
|
|
1861
1863
|
}
|
|
1862
1864
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -1874,16 +1876,16 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1874
1876
|
this.emitWithAll(event, args);
|
|
1875
1877
|
}
|
|
1876
1878
|
};
|
|
1877
|
-
this._awaitWriteFinish(
|
|
1879
|
+
this._awaitWriteFinish(path7, awf.stabilityThreshold, event, awfEmit);
|
|
1878
1880
|
return this;
|
|
1879
1881
|
}
|
|
1880
1882
|
if (event === EVENTS.CHANGE) {
|
|
1881
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
1883
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path7, 50);
|
|
1882
1884
|
if (isThrottled)
|
|
1883
1885
|
return this;
|
|
1884
1886
|
}
|
|
1885
1887
|
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
1886
|
-
const fullPath = opts.cwd ? sp2.join(opts.cwd,
|
|
1888
|
+
const fullPath = opts.cwd ? sp2.join(opts.cwd, path7) : path7;
|
|
1887
1889
|
let stats2;
|
|
1888
1890
|
try {
|
|
1889
1891
|
stats2 = await stat3(fullPath);
|
|
@@ -1914,23 +1916,23 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1914
1916
|
* @param timeout duration of time to suppress duplicate actions
|
|
1915
1917
|
* @returns tracking object or false if action should be suppressed
|
|
1916
1918
|
*/
|
|
1917
|
-
_throttle(actionType,
|
|
1919
|
+
_throttle(actionType, path7, timeout) {
|
|
1918
1920
|
if (!this._throttled.has(actionType)) {
|
|
1919
1921
|
this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
1920
1922
|
}
|
|
1921
1923
|
const action = this._throttled.get(actionType);
|
|
1922
1924
|
if (!action)
|
|
1923
1925
|
throw new Error("invalid throttle");
|
|
1924
|
-
const actionPath = action.get(
|
|
1926
|
+
const actionPath = action.get(path7);
|
|
1925
1927
|
if (actionPath) {
|
|
1926
1928
|
actionPath.count++;
|
|
1927
1929
|
return false;
|
|
1928
1930
|
}
|
|
1929
1931
|
let timeoutObject;
|
|
1930
1932
|
const clear = () => {
|
|
1931
|
-
const item = action.get(
|
|
1933
|
+
const item = action.get(path7);
|
|
1932
1934
|
const count = item ? item.count : 0;
|
|
1933
|
-
action.delete(
|
|
1935
|
+
action.delete(path7);
|
|
1934
1936
|
clearTimeout(timeoutObject);
|
|
1935
1937
|
if (item)
|
|
1936
1938
|
clearTimeout(item.timeoutObject);
|
|
@@ -1938,7 +1940,7 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1938
1940
|
};
|
|
1939
1941
|
timeoutObject = setTimeout(clear, timeout);
|
|
1940
1942
|
const thr = { timeoutObject, clear, count: 0 };
|
|
1941
|
-
action.set(
|
|
1943
|
+
action.set(path7, thr);
|
|
1942
1944
|
return thr;
|
|
1943
1945
|
}
|
|
1944
1946
|
_incrReadyCount() {
|
|
@@ -1952,44 +1954,44 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1952
1954
|
* @param event
|
|
1953
1955
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
1954
1956
|
*/
|
|
1955
|
-
_awaitWriteFinish(
|
|
1957
|
+
_awaitWriteFinish(path7, threshold, event, awfEmit) {
|
|
1956
1958
|
const awf = this.options.awaitWriteFinish;
|
|
1957
1959
|
if (typeof awf !== "object")
|
|
1958
1960
|
return;
|
|
1959
1961
|
const pollInterval = awf.pollInterval;
|
|
1960
1962
|
let timeoutHandler;
|
|
1961
|
-
let fullPath =
|
|
1962
|
-
if (this.options.cwd && !sp2.isAbsolute(
|
|
1963
|
-
fullPath = sp2.join(this.options.cwd,
|
|
1963
|
+
let fullPath = path7;
|
|
1964
|
+
if (this.options.cwd && !sp2.isAbsolute(path7)) {
|
|
1965
|
+
fullPath = sp2.join(this.options.cwd, path7);
|
|
1964
1966
|
}
|
|
1965
1967
|
const now = /* @__PURE__ */ new Date();
|
|
1966
1968
|
const writes = this._pendingWrites;
|
|
1967
1969
|
function awaitWriteFinishFn(prevStat) {
|
|
1968
1970
|
statcb(fullPath, (err, curStat) => {
|
|
1969
|
-
if (err || !writes.has(
|
|
1971
|
+
if (err || !writes.has(path7)) {
|
|
1970
1972
|
if (err && err.code !== "ENOENT")
|
|
1971
1973
|
awfEmit(err);
|
|
1972
1974
|
return;
|
|
1973
1975
|
}
|
|
1974
1976
|
const now2 = Number(/* @__PURE__ */ new Date());
|
|
1975
1977
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
1976
|
-
writes.get(
|
|
1978
|
+
writes.get(path7).lastChange = now2;
|
|
1977
1979
|
}
|
|
1978
|
-
const pw = writes.get(
|
|
1980
|
+
const pw = writes.get(path7);
|
|
1979
1981
|
const df = now2 - pw.lastChange;
|
|
1980
1982
|
if (df >= threshold) {
|
|
1981
|
-
writes.delete(
|
|
1983
|
+
writes.delete(path7);
|
|
1982
1984
|
awfEmit(void 0, curStat);
|
|
1983
1985
|
} else {
|
|
1984
1986
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
1985
1987
|
}
|
|
1986
1988
|
});
|
|
1987
1989
|
}
|
|
1988
|
-
if (!writes.has(
|
|
1989
|
-
writes.set(
|
|
1990
|
+
if (!writes.has(path7)) {
|
|
1991
|
+
writes.set(path7, {
|
|
1990
1992
|
lastChange: now,
|
|
1991
1993
|
cancelWait: () => {
|
|
1992
|
-
writes.delete(
|
|
1994
|
+
writes.delete(path7);
|
|
1993
1995
|
clearTimeout(timeoutHandler);
|
|
1994
1996
|
return event;
|
|
1995
1997
|
}
|
|
@@ -2000,8 +2002,8 @@ var FSWatcher = class extends EventEmitter {
|
|
|
2000
2002
|
/**
|
|
2001
2003
|
* Determines whether user has asked to ignore this path.
|
|
2002
2004
|
*/
|
|
2003
|
-
_isIgnored(
|
|
2004
|
-
if (this.options.atomic && DOT_RE.test(
|
|
2005
|
+
_isIgnored(path7, stats) {
|
|
2006
|
+
if (this.options.atomic && DOT_RE.test(path7))
|
|
2005
2007
|
return true;
|
|
2006
2008
|
if (!this._userIgnored) {
|
|
2007
2009
|
const { cwd } = this.options;
|
|
@@ -2011,17 +2013,17 @@ var FSWatcher = class extends EventEmitter {
|
|
|
2011
2013
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
2012
2014
|
this._userIgnored = anymatch(list, void 0);
|
|
2013
2015
|
}
|
|
2014
|
-
return this._userIgnored(
|
|
2016
|
+
return this._userIgnored(path7, stats);
|
|
2015
2017
|
}
|
|
2016
|
-
_isntIgnored(
|
|
2017
|
-
return !this._isIgnored(
|
|
2018
|
+
_isntIgnored(path7, stat4) {
|
|
2019
|
+
return !this._isIgnored(path7, stat4);
|
|
2018
2020
|
}
|
|
2019
2021
|
/**
|
|
2020
2022
|
* Provides a set of common helpers and properties relating to symlink handling.
|
|
2021
2023
|
* @param path file or directory pattern being watched
|
|
2022
2024
|
*/
|
|
2023
|
-
_getWatchHelpers(
|
|
2024
|
-
return new WatchHelper(
|
|
2025
|
+
_getWatchHelpers(path7) {
|
|
2026
|
+
return new WatchHelper(path7, this.options.followSymlinks, this);
|
|
2025
2027
|
}
|
|
2026
2028
|
// Directory helpers
|
|
2027
2029
|
// -----------------
|
|
@@ -2053,63 +2055,63 @@ var FSWatcher = class extends EventEmitter {
|
|
|
2053
2055
|
* @param item base path of item/directory
|
|
2054
2056
|
*/
|
|
2055
2057
|
_remove(directory, item, isDirectory) {
|
|
2056
|
-
const
|
|
2057
|
-
const fullPath = sp2.resolve(
|
|
2058
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
2059
|
-
if (!this._throttle("remove",
|
|
2058
|
+
const path7 = sp2.join(directory, item);
|
|
2059
|
+
const fullPath = sp2.resolve(path7);
|
|
2060
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path7) || this._watched.has(fullPath);
|
|
2061
|
+
if (!this._throttle("remove", path7, 100))
|
|
2060
2062
|
return;
|
|
2061
2063
|
if (!isDirectory && this._watched.size === 1) {
|
|
2062
2064
|
this.add(directory, item, true);
|
|
2063
2065
|
}
|
|
2064
|
-
const wp = this._getWatchedDir(
|
|
2066
|
+
const wp = this._getWatchedDir(path7);
|
|
2065
2067
|
const nestedDirectoryChildren = wp.getChildren();
|
|
2066
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
2068
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path7, nested));
|
|
2067
2069
|
const parent = this._getWatchedDir(directory);
|
|
2068
2070
|
const wasTracked = parent.has(item);
|
|
2069
2071
|
parent.remove(item);
|
|
2070
2072
|
if (this._symlinkPaths.has(fullPath)) {
|
|
2071
2073
|
this._symlinkPaths.delete(fullPath);
|
|
2072
2074
|
}
|
|
2073
|
-
let relPath =
|
|
2075
|
+
let relPath = path7;
|
|
2074
2076
|
if (this.options.cwd)
|
|
2075
|
-
relPath = sp2.relative(this.options.cwd,
|
|
2077
|
+
relPath = sp2.relative(this.options.cwd, path7);
|
|
2076
2078
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
2077
2079
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
2078
2080
|
if (event === EVENTS.ADD)
|
|
2079
2081
|
return;
|
|
2080
2082
|
}
|
|
2081
|
-
this._watched.delete(
|
|
2083
|
+
this._watched.delete(path7);
|
|
2082
2084
|
this._watched.delete(fullPath);
|
|
2083
2085
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
2084
|
-
if (wasTracked && !this._isIgnored(
|
|
2085
|
-
this._emit(eventName,
|
|
2086
|
-
this._closePath(
|
|
2086
|
+
if (wasTracked && !this._isIgnored(path7))
|
|
2087
|
+
this._emit(eventName, path7);
|
|
2088
|
+
this._closePath(path7);
|
|
2087
2089
|
}
|
|
2088
2090
|
/**
|
|
2089
2091
|
* Closes all watchers for a path
|
|
2090
2092
|
*/
|
|
2091
|
-
_closePath(
|
|
2092
|
-
this._closeFile(
|
|
2093
|
-
const dir = sp2.dirname(
|
|
2094
|
-
this._getWatchedDir(dir).remove(sp2.basename(
|
|
2093
|
+
_closePath(path7) {
|
|
2094
|
+
this._closeFile(path7);
|
|
2095
|
+
const dir = sp2.dirname(path7);
|
|
2096
|
+
this._getWatchedDir(dir).remove(sp2.basename(path7));
|
|
2095
2097
|
}
|
|
2096
2098
|
/**
|
|
2097
2099
|
* Closes only file-specific watchers
|
|
2098
2100
|
*/
|
|
2099
|
-
_closeFile(
|
|
2100
|
-
const closers = this._closers.get(
|
|
2101
|
+
_closeFile(path7) {
|
|
2102
|
+
const closers = this._closers.get(path7);
|
|
2101
2103
|
if (!closers)
|
|
2102
2104
|
return;
|
|
2103
2105
|
closers.forEach((closer) => closer());
|
|
2104
|
-
this._closers.delete(
|
|
2106
|
+
this._closers.delete(path7);
|
|
2105
2107
|
}
|
|
2106
|
-
_addPathCloser(
|
|
2108
|
+
_addPathCloser(path7, closer) {
|
|
2107
2109
|
if (!closer)
|
|
2108
2110
|
return;
|
|
2109
|
-
let list = this._closers.get(
|
|
2111
|
+
let list = this._closers.get(path7);
|
|
2110
2112
|
if (!list) {
|
|
2111
2113
|
list = [];
|
|
2112
|
-
this._closers.set(
|
|
2114
|
+
this._closers.set(path7, list);
|
|
2113
2115
|
}
|
|
2114
2116
|
list.push(closer);
|
|
2115
2117
|
}
|
|
@@ -2205,358 +2207,10 @@ var PlanWatcher = class {
|
|
|
2205
2207
|
}
|
|
2206
2208
|
};
|
|
2207
2209
|
|
|
2208
|
-
// src/daemon/digest.ts
|
|
2209
|
-
var import_yaml = __toESM(require_dist(), 1);
|
|
2210
|
-
import fs3 from "fs";
|
|
2211
|
-
import path4 from "path";
|
|
2212
|
-
import crypto from "crypto";
|
|
2213
|
-
var PREVIOUS_EXTRACT_OVERHEAD_TOKENS = 50;
|
|
2214
|
-
var CONTEXT_SAFETY_MARGIN = 0.7;
|
|
2215
|
-
var EXTRACT_TYPE = "extract";
|
|
2216
|
-
var DigestEngine = class {
|
|
2217
|
-
vaultDir;
|
|
2218
|
-
index;
|
|
2219
|
-
llm;
|
|
2220
|
-
config;
|
|
2221
|
-
log;
|
|
2222
|
-
lastCycleTimestampCache = void 0;
|
|
2223
|
-
cycleInProgress = false;
|
|
2224
|
-
modelReady = false;
|
|
2225
|
-
constructor(engineConfig) {
|
|
2226
|
-
this.vaultDir = engineConfig.vaultDir;
|
|
2227
|
-
this.index = engineConfig.index;
|
|
2228
|
-
this.llm = engineConfig.llmProvider;
|
|
2229
|
-
this.config = engineConfig.config;
|
|
2230
|
-
this.log = engineConfig.log ?? (() => {
|
|
2231
|
-
});
|
|
2232
|
-
}
|
|
2233
|
-
/**
|
|
2234
|
-
* Query index for recent vault notes to feed into the digest.
|
|
2235
|
-
* Filters out extract notes (our own output) and caps at max_notes_per_cycle.
|
|
2236
|
-
*/
|
|
2237
|
-
discoverSubstrate(lastCycleTimestamp) {
|
|
2238
|
-
const maxNotes = this.config.digest.substrate.max_notes_per_cycle;
|
|
2239
|
-
const notes = lastCycleTimestamp ? this.index.query({ updatedSince: lastCycleTimestamp, limit: maxNotes }) : this.index.query({ limit: maxNotes });
|
|
2240
|
-
const filtered = notes.filter((n) => n.type !== EXTRACT_TYPE);
|
|
2241
|
-
filtered.sort((a, b) => {
|
|
2242
|
-
const weightA = DIGEST_SUBSTRATE_TYPE_WEIGHTS[a.type] ?? 0;
|
|
2243
|
-
const weightB = DIGEST_SUBSTRATE_TYPE_WEIGHTS[b.type] ?? 0;
|
|
2244
|
-
if (weightB !== weightA) return weightB - weightA;
|
|
2245
|
-
return b.created.localeCompare(a.created);
|
|
2246
|
-
});
|
|
2247
|
-
return filtered.slice(0, maxNotes);
|
|
2248
|
-
}
|
|
2249
|
-
/**
|
|
2250
|
-
* Filter configured tiers by the context window available.
|
|
2251
|
-
* Only tiers whose minimum context requirement is met are eligible.
|
|
2252
|
-
*/
|
|
2253
|
-
getEligibleTiers() {
|
|
2254
|
-
const contextWindow = this.config.digest.intelligence.context_window;
|
|
2255
|
-
return this.config.digest.tiers.filter((tier) => {
|
|
2256
|
-
const minContext = DIGEST_TIER_MIN_CONTEXT[tier];
|
|
2257
|
-
return minContext !== void 0 && minContext <= contextWindow;
|
|
2258
|
-
});
|
|
2259
|
-
}
|
|
2260
|
-
/**
|
|
2261
|
-
* Format notes compactly for inclusion in the digest prompt.
|
|
2262
|
-
* Stops adding notes once the token budget is exceeded.
|
|
2263
|
-
*/
|
|
2264
|
-
formatSubstrate(notes, tokenBudget) {
|
|
2265
|
-
const charBudget = tokenBudget * CHARS_PER_TOKEN;
|
|
2266
|
-
const parts = [];
|
|
2267
|
-
let usedChars = 0;
|
|
2268
|
-
for (const note of notes) {
|
|
2269
|
-
const entry = `### [${note.type}] ${note.id} \u2014 "${note.title}"
|
|
2270
|
-
${note.content}`;
|
|
2271
|
-
if (usedChars + entry.length > charBudget && parts.length > 0) break;
|
|
2272
|
-
parts.push(entry);
|
|
2273
|
-
usedChars += entry.length;
|
|
2274
|
-
}
|
|
2275
|
-
return parts.join("\n\n");
|
|
2276
|
-
}
|
|
2277
|
-
/**
|
|
2278
|
-
* Read a previously generated extract for a given tier.
|
|
2279
|
-
* Returns the body (stripped of YAML frontmatter), or null if not found.
|
|
2280
|
-
*/
|
|
2281
|
-
readPreviousExtract(tier) {
|
|
2282
|
-
const extractPath = path4.join(this.vaultDir, "digest", `extract-${tier}.md`);
|
|
2283
|
-
let content;
|
|
2284
|
-
try {
|
|
2285
|
-
content = fs3.readFileSync(extractPath, "utf-8");
|
|
2286
|
-
} catch {
|
|
2287
|
-
return null;
|
|
2288
|
-
}
|
|
2289
|
-
return stripFrontmatter(content).body;
|
|
2290
|
-
}
|
|
2291
|
-
/**
|
|
2292
|
-
* Write a digest extract to the vault with YAML frontmatter.
|
|
2293
|
-
* Uses atomic write pattern (temp file + rename).
|
|
2294
|
-
*/
|
|
2295
|
-
writeExtract(tier, body, cycleId, model, substrateCount) {
|
|
2296
|
-
const digestDir = path4.join(this.vaultDir, "digest");
|
|
2297
|
-
fs3.mkdirSync(digestDir, { recursive: true });
|
|
2298
|
-
const frontmatter = {
|
|
2299
|
-
type: EXTRACT_TYPE,
|
|
2300
|
-
tier,
|
|
2301
|
-
generated: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2302
|
-
cycle_id: cycleId,
|
|
2303
|
-
substrate_count: substrateCount,
|
|
2304
|
-
model
|
|
2305
|
-
};
|
|
2306
|
-
const fmYaml = import_yaml.default.stringify(frontmatter, {
|
|
2307
|
-
defaultStringType: "QUOTE_DOUBLE",
|
|
2308
|
-
defaultKeyType: "PLAIN"
|
|
2309
|
-
}).trim();
|
|
2310
|
-
const file = `---
|
|
2311
|
-
${fmYaml}
|
|
2312
|
-
---
|
|
2313
|
-
|
|
2314
|
-
${body}
|
|
2315
|
-
`;
|
|
2316
|
-
const fullPath = path4.join(digestDir, `extract-${tier}.md`);
|
|
2317
|
-
const tmpPath = `${fullPath}.tmp`;
|
|
2318
|
-
fs3.writeFileSync(tmpPath, file, "utf-8");
|
|
2319
|
-
fs3.renameSync(tmpPath, fullPath);
|
|
2320
|
-
}
|
|
2321
|
-
/**
|
|
2322
|
-
* Append a digest cycle result as a JSON line to trace.jsonl.
|
|
2323
|
-
*/
|
|
2324
|
-
appendTrace(record) {
|
|
2325
|
-
const digestDir = path4.join(this.vaultDir, "digest");
|
|
2326
|
-
fs3.mkdirSync(digestDir, { recursive: true });
|
|
2327
|
-
const tracePath = path4.join(digestDir, "trace.jsonl");
|
|
2328
|
-
fs3.appendFileSync(tracePath, JSON.stringify(record) + "\n", "utf-8");
|
|
2329
|
-
this.lastCycleTimestampCache = record.timestamp;
|
|
2330
|
-
}
|
|
2331
|
-
/**
|
|
2332
|
-
* Read the last cycle timestamp from trace.jsonl.
|
|
2333
|
-
* Cached in memory after first read — subsequent calls are O(1).
|
|
2334
|
-
*/
|
|
2335
|
-
getLastCycleTimestamp() {
|
|
2336
|
-
if (this.lastCycleTimestampCache !== void 0) return this.lastCycleTimestampCache;
|
|
2337
|
-
const tracePath = path4.join(this.vaultDir, "digest", "trace.jsonl");
|
|
2338
|
-
let content;
|
|
2339
|
-
try {
|
|
2340
|
-
content = fs3.readFileSync(tracePath, "utf-8").trim();
|
|
2341
|
-
} catch {
|
|
2342
|
-
this.lastCycleTimestampCache = null;
|
|
2343
|
-
return null;
|
|
2344
|
-
}
|
|
2345
|
-
if (!content) {
|
|
2346
|
-
this.lastCycleTimestampCache = null;
|
|
2347
|
-
return null;
|
|
2348
|
-
}
|
|
2349
|
-
const lines = content.split("\n");
|
|
2350
|
-
const lastLine = lines[lines.length - 1];
|
|
2351
|
-
try {
|
|
2352
|
-
const record = JSON.parse(lastLine);
|
|
2353
|
-
this.lastCycleTimestampCache = record.timestamp;
|
|
2354
|
-
return record.timestamp;
|
|
2355
|
-
} catch {
|
|
2356
|
-
this.lastCycleTimestampCache = null;
|
|
2357
|
-
return null;
|
|
2358
|
-
}
|
|
2359
|
-
}
|
|
2360
|
-
/**
|
|
2361
|
-
* Run a full digest cycle: discover substrate, generate extracts for each tier.
|
|
2362
|
-
* Returns the cycle result, or null if no substrate was found.
|
|
2363
|
-
*/
|
|
2364
|
-
async runCycle() {
|
|
2365
|
-
if (this.cycleInProgress) {
|
|
2366
|
-
this.log("debug", "Cycle already in progress \u2014 skipping");
|
|
2367
|
-
return null;
|
|
2368
|
-
}
|
|
2369
|
-
this.cycleInProgress = true;
|
|
2370
|
-
try {
|
|
2371
|
-
return await this.runCycleInternal();
|
|
2372
|
-
} finally {
|
|
2373
|
-
this.cycleInProgress = false;
|
|
2374
|
-
}
|
|
2375
|
-
}
|
|
2376
|
-
async runCycleInternal() {
|
|
2377
|
-
if (!this.modelReady && this.llm.ensureLoaded) {
|
|
2378
|
-
const { context_window: contextWindow, gpu_kv_cache: gpuKvCache } = this.config.digest.intelligence;
|
|
2379
|
-
this.log("info", "Loading digest model", { contextWindow, gpuKvCache });
|
|
2380
|
-
await this.llm.ensureLoaded(contextWindow, gpuKvCache);
|
|
2381
|
-
this.modelReady = true;
|
|
2382
|
-
}
|
|
2383
|
-
const startTime = Date.now();
|
|
2384
|
-
const lastTimestamp = this.getLastCycleTimestamp();
|
|
2385
|
-
const substrate = this.discoverSubstrate(lastTimestamp);
|
|
2386
|
-
this.log("debug", "Discovering substrate", { lastTimestamp: lastTimestamp ?? "cold start", substrateCount: substrate.length });
|
|
2387
|
-
if (substrate.length === 0) {
|
|
2388
|
-
this.log("debug", "No substrate found \u2014 skipping cycle");
|
|
2389
|
-
return null;
|
|
2390
|
-
}
|
|
2391
|
-
this.log("info", `Starting digest cycle`, { substrateCount: substrate.length });
|
|
2392
|
-
const cycleId = crypto.randomUUID();
|
|
2393
|
-
const eligibleTiers = this.getEligibleTiers();
|
|
2394
|
-
this.log("debug", `Eligible tiers: [${eligibleTiers.join(", ")}]`);
|
|
2395
|
-
const tiersGenerated = [];
|
|
2396
|
-
let totalTokensUsed = 0;
|
|
2397
|
-
let model = "";
|
|
2398
|
-
const typeToKey = {
|
|
2399
|
-
session: "sessions",
|
|
2400
|
-
spore: "spores",
|
|
2401
|
-
plan: "plans",
|
|
2402
|
-
artifact: "artifacts",
|
|
2403
|
-
"team-member": "team"
|
|
2404
|
-
};
|
|
2405
|
-
const substrateIndex = {
|
|
2406
|
-
sessions: [],
|
|
2407
|
-
spores: [],
|
|
2408
|
-
plans: [],
|
|
2409
|
-
artifacts: [],
|
|
2410
|
-
team: []
|
|
2411
|
-
};
|
|
2412
|
-
for (const note of substrate) {
|
|
2413
|
-
const key = typeToKey[note.type];
|
|
2414
|
-
if (key) {
|
|
2415
|
-
substrateIndex[key].push(note.id);
|
|
2416
|
-
}
|
|
2417
|
-
}
|
|
2418
|
-
const systemPrompt = loadPrompt("digest-system");
|
|
2419
|
-
for (const tier of eligibleTiers) {
|
|
2420
|
-
const tierPrompt = loadPrompt(`digest-${tier}`);
|
|
2421
|
-
const previousExtract = this.readPreviousExtract(tier);
|
|
2422
|
-
const contextWindow = this.config.digest.intelligence.context_window;
|
|
2423
|
-
const systemPromptTokens = estimateTokens(systemPrompt);
|
|
2424
|
-
const tierPromptTokens = estimateTokens(tierPrompt);
|
|
2425
|
-
const previousExtractTokens = previousExtract ? estimateTokens(previousExtract) + PREVIOUS_EXTRACT_OVERHEAD_TOKENS : 0;
|
|
2426
|
-
const availableTokens = Math.floor(contextWindow * CONTEXT_SAFETY_MARGIN);
|
|
2427
|
-
const substrateBudget = availableTokens - tier - systemPromptTokens - tierPromptTokens - previousExtractTokens;
|
|
2428
|
-
if (substrateBudget <= 0) continue;
|
|
2429
|
-
const formattedSubstrate = this.formatSubstrate(substrate, substrateBudget);
|
|
2430
|
-
const promptParts = [tierPrompt];
|
|
2431
|
-
if (previousExtract) {
|
|
2432
|
-
promptParts.push("", "## Previous Synthesis", "", previousExtract);
|
|
2433
|
-
}
|
|
2434
|
-
promptParts.push("", "## New Substrate", "", formattedSubstrate);
|
|
2435
|
-
promptParts.push(
|
|
2436
|
-
"",
|
|
2437
|
-
"---",
|
|
2438
|
-
"Produce your updated synthesis now. Stay within the token budget specified above."
|
|
2439
|
-
);
|
|
2440
|
-
const userPrompt = promptParts.join("\n");
|
|
2441
|
-
const promptTokens = estimateTokens(systemPrompt + userPrompt);
|
|
2442
|
-
this.log("debug", `Tier ${tier}: sending LLM request`, { promptTokens, maxTokens: tier, substrateBudget });
|
|
2443
|
-
const tierStart = Date.now();
|
|
2444
|
-
const digestConfig = this.config.digest.intelligence;
|
|
2445
|
-
const opts = {
|
|
2446
|
-
maxTokens: tier,
|
|
2447
|
-
timeoutMs: DIGEST_LLM_REQUEST_TIMEOUT_MS,
|
|
2448
|
-
contextLength: contextWindow,
|
|
2449
|
-
reasoning: "off",
|
|
2450
|
-
systemPrompt,
|
|
2451
|
-
keepAlive: digestConfig.keep_alive ?? void 0
|
|
2452
|
-
};
|
|
2453
|
-
const response = await this.llm.summarize(userPrompt, opts);
|
|
2454
|
-
const tierDuration = Date.now() - tierStart;
|
|
2455
|
-
const extractText = stripReasoningTokens(response.text);
|
|
2456
|
-
model = response.model;
|
|
2457
|
-
const responseTokens = estimateTokens(extractText);
|
|
2458
|
-
totalTokensUsed += promptTokens + responseTokens;
|
|
2459
|
-
this.log("info", `Tier ${tier}: completed`, { durationMs: tierDuration, responseTokens, model: response.model });
|
|
2460
|
-
this.writeExtract(tier, extractText, cycleId, response.model, substrate.length);
|
|
2461
|
-
tiersGenerated.push(tier);
|
|
2462
|
-
}
|
|
2463
|
-
const result = {
|
|
2464
|
-
cycleId,
|
|
2465
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2466
|
-
substrate: substrateIndex,
|
|
2467
|
-
tiersGenerated,
|
|
2468
|
-
model,
|
|
2469
|
-
durationMs: Date.now() - startTime,
|
|
2470
|
-
tokensUsed: totalTokensUsed
|
|
2471
|
-
};
|
|
2472
|
-
this.appendTrace(result);
|
|
2473
|
-
return result;
|
|
2474
|
-
}
|
|
2475
|
-
};
|
|
2476
|
-
var MS_PER_SECOND2 = 1e3;
|
|
2477
|
-
var Metabolism = class {
|
|
2478
|
-
state = "active";
|
|
2479
|
-
currentIntervalMs;
|
|
2480
|
-
cooldownStep = 0;
|
|
2481
|
-
lastSubstrateTime;
|
|
2482
|
-
timer = null;
|
|
2483
|
-
activeIntervalMs;
|
|
2484
|
-
cooldownIntervalsMs;
|
|
2485
|
-
dormancyThresholdMs;
|
|
2486
|
-
constructor(config) {
|
|
2487
|
-
this.activeIntervalMs = config.active_interval * MS_PER_SECOND2;
|
|
2488
|
-
this.cooldownIntervalsMs = config.cooldown_intervals.map((s) => s * MS_PER_SECOND2);
|
|
2489
|
-
this.dormancyThresholdMs = config.dormancy_threshold * MS_PER_SECOND2;
|
|
2490
|
-
this.currentIntervalMs = this.activeIntervalMs;
|
|
2491
|
-
this.lastSubstrateTime = Date.now();
|
|
2492
|
-
}
|
|
2493
|
-
/** Reset to active state when new substrate is found. */
|
|
2494
|
-
onSubstrateFound() {
|
|
2495
|
-
this.state = "active";
|
|
2496
|
-
this.cooldownStep = 0;
|
|
2497
|
-
this.currentIntervalMs = this.activeIntervalMs;
|
|
2498
|
-
this.lastSubstrateTime = Date.now();
|
|
2499
|
-
}
|
|
2500
|
-
/** Advance cooldown when a cycle finds no new substrate. */
|
|
2501
|
-
onEmptyCycle() {
|
|
2502
|
-
if (this.state === "dormant") return;
|
|
2503
|
-
this.state = "cooling";
|
|
2504
|
-
if (this.cooldownStep < this.cooldownIntervalsMs.length) {
|
|
2505
|
-
this.currentIntervalMs = this.cooldownIntervalsMs[this.cooldownStep];
|
|
2506
|
-
this.cooldownStep++;
|
|
2507
|
-
}
|
|
2508
|
-
this.checkDormancy();
|
|
2509
|
-
}
|
|
2510
|
-
/** Enter dormant state if enough time has elapsed since last substrate. */
|
|
2511
|
-
checkDormancy() {
|
|
2512
|
-
const elapsed = Date.now() - this.lastSubstrateTime;
|
|
2513
|
-
if (elapsed >= this.dormancyThresholdMs) {
|
|
2514
|
-
this.state = "dormant";
|
|
2515
|
-
}
|
|
2516
|
-
}
|
|
2517
|
-
/** Return to active from any state, resetting timers and rescheduling immediately. */
|
|
2518
|
-
activate() {
|
|
2519
|
-
this.onSubstrateFound();
|
|
2520
|
-
if (this.callback) {
|
|
2521
|
-
this.reschedule();
|
|
2522
|
-
}
|
|
2523
|
-
}
|
|
2524
|
-
/** Set lastSubstrateTime explicitly (for testing). */
|
|
2525
|
-
markLastSubstrate(time) {
|
|
2526
|
-
this.lastSubstrateTime = time;
|
|
2527
|
-
}
|
|
2528
|
-
/** Begin scheduling digest cycles with adaptive intervals. */
|
|
2529
|
-
start(callback) {
|
|
2530
|
-
this.callback = callback;
|
|
2531
|
-
this.reschedule();
|
|
2532
|
-
}
|
|
2533
|
-
/** Stop the timer. */
|
|
2534
|
-
stop() {
|
|
2535
|
-
if (this.timer) {
|
|
2536
|
-
clearTimeout(this.timer);
|
|
2537
|
-
this.timer = null;
|
|
2538
|
-
}
|
|
2539
|
-
}
|
|
2540
|
-
callback = null;
|
|
2541
|
-
reschedule() {
|
|
2542
|
-
this.stop();
|
|
2543
|
-
if (!this.callback) return;
|
|
2544
|
-
const cb = this.callback;
|
|
2545
|
-
const schedule = () => {
|
|
2546
|
-
this.timer = setTimeout(async () => {
|
|
2547
|
-
await cb();
|
|
2548
|
-
schedule();
|
|
2549
|
-
}, this.currentIntervalMs);
|
|
2550
|
-
this.timer.unref();
|
|
2551
|
-
};
|
|
2552
|
-
schedule();
|
|
2553
|
-
}
|
|
2554
|
-
};
|
|
2555
|
-
|
|
2556
2210
|
// src/artifacts/candidates.ts
|
|
2557
2211
|
import { execFileSync } from "child_process";
|
|
2558
|
-
import
|
|
2559
|
-
import
|
|
2212
|
+
import fs3 from "fs";
|
|
2213
|
+
import path4 from "path";
|
|
2560
2214
|
var EXCLUDED_FILENAMES = /* @__PURE__ */ new Set([
|
|
2561
2215
|
"claude.md",
|
|
2562
2216
|
"agents.md",
|
|
@@ -2577,7 +2231,7 @@ var EXCLUDED_PREFIXES = [
|
|
|
2577
2231
|
".github/"
|
|
2578
2232
|
];
|
|
2579
2233
|
function isExcludedPath(relativePath) {
|
|
2580
|
-
const basename3 =
|
|
2234
|
+
const basename3 = path4.basename(relativePath).toLowerCase();
|
|
2581
2235
|
if (EXCLUDED_FILENAMES.has(basename3)) return true;
|
|
2582
2236
|
const normalized = relativePath.replace(/\\/g, "/");
|
|
2583
2237
|
return EXCLUDED_PREFIXES.some((prefix) => normalized.startsWith(prefix));
|
|
@@ -2585,7 +2239,7 @@ function isExcludedPath(relativePath) {
|
|
|
2585
2239
|
function collectArtifactCandidates(filePaths, config, projectRoot) {
|
|
2586
2240
|
if (filePaths.size === 0) return [];
|
|
2587
2241
|
const extFiltered = [...filePaths].filter(
|
|
2588
|
-
(absPath) => config.artifact_extensions.includes(
|
|
2242
|
+
(absPath) => config.artifact_extensions.includes(path4.extname(absPath))
|
|
2589
2243
|
);
|
|
2590
2244
|
if (extFiltered.length === 0) return [];
|
|
2591
2245
|
const ignoredSet = getGitIgnored(extFiltered, projectRoot);
|
|
@@ -2593,8 +2247,8 @@ function collectArtifactCandidates(filePaths, config, projectRoot) {
|
|
|
2593
2247
|
for (const absPath of extFiltered) {
|
|
2594
2248
|
if (ignoredSet.has(absPath)) continue;
|
|
2595
2249
|
try {
|
|
2596
|
-
const content =
|
|
2597
|
-
const relativePath =
|
|
2250
|
+
const content = fs3.readFileSync(absPath, "utf-8");
|
|
2251
|
+
const relativePath = path4.relative(projectRoot, absPath);
|
|
2598
2252
|
if (isExcludedPath(relativePath)) continue;
|
|
2599
2253
|
candidates.push({ path: relativePath, content });
|
|
2600
2254
|
} catch {
|
|
@@ -2616,23 +2270,23 @@ function getGitIgnored(filePaths, cwd) {
|
|
|
2616
2270
|
}
|
|
2617
2271
|
|
|
2618
2272
|
// src/artifacts/slugify.ts
|
|
2619
|
-
import
|
|
2620
|
-
import
|
|
2273
|
+
import crypto from "crypto";
|
|
2274
|
+
import path5 from "path";
|
|
2621
2275
|
function slugifyPath(relativePath) {
|
|
2622
|
-
const ext =
|
|
2276
|
+
const ext = path5.extname(relativePath);
|
|
2623
2277
|
const withoutExt = ext ? relativePath.slice(0, -ext.length) : relativePath;
|
|
2624
2278
|
let slug = withoutExt.replace(/[/\\]/g, "-").toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "");
|
|
2625
2279
|
if (slug.length > MAX_SLUG_LENGTH) {
|
|
2626
|
-
const hash =
|
|
2280
|
+
const hash = crypto.createHash("sha256").update(relativePath).digest("hex").slice(0, 6);
|
|
2627
2281
|
slug = slug.slice(0, MAX_SLUG_LENGTH) + "-" + hash;
|
|
2628
2282
|
}
|
|
2629
2283
|
return slug;
|
|
2630
2284
|
}
|
|
2631
2285
|
|
|
2632
2286
|
// src/daemon/main.ts
|
|
2633
|
-
var
|
|
2634
|
-
import
|
|
2635
|
-
import
|
|
2287
|
+
var import_yaml = __toESM(require_dist(), 1);
|
|
2288
|
+
import fs4 from "fs";
|
|
2289
|
+
import path6 from "path";
|
|
2636
2290
|
function indexAndEmbed(relativePath, noteId, embeddingText, metadata, deps) {
|
|
2637
2291
|
indexNote(deps.index, deps.vaultDir, relativePath);
|
|
2638
2292
|
if (deps.vectorIndex && embeddingText) {
|
|
@@ -2652,6 +2306,25 @@ ${note.observation.content}`,
|
|
|
2652
2306
|
);
|
|
2653
2307
|
deps.logger.info("processor", "Observation written", { type: note.observation.type, title: note.observation.title, session_id: sessionId });
|
|
2654
2308
|
}
|
|
2309
|
+
if (written.length > 0) {
|
|
2310
|
+
const curationDeps = {
|
|
2311
|
+
index: deps.index,
|
|
2312
|
+
vectorIndex: deps.vectorIndex,
|
|
2313
|
+
embeddingProvider: deps.embeddingProvider,
|
|
2314
|
+
llmProvider: deps.llmProvider,
|
|
2315
|
+
vaultDir: deps.vaultDir,
|
|
2316
|
+
log: ((level, msg, data) => deps.logger[level]("curation", msg, data))
|
|
2317
|
+
};
|
|
2318
|
+
(async () => {
|
|
2319
|
+
for (const note of written) {
|
|
2320
|
+
try {
|
|
2321
|
+
await checkSupersession(note.id, curationDeps);
|
|
2322
|
+
} catch (err) {
|
|
2323
|
+
deps.logger.debug("curation", "Supersession check failed", { id: note.id, error: err.message });
|
|
2324
|
+
}
|
|
2325
|
+
}
|
|
2326
|
+
})();
|
|
2327
|
+
}
|
|
2655
2328
|
}
|
|
2656
2329
|
async function captureArtifacts(candidates, classified, sessionId, deps, lineage) {
|
|
2657
2330
|
const candidateMap = new Map(candidates.map((c) => [c.path, c]));
|
|
@@ -2685,28 +2358,28 @@ ${candidate.content}`,
|
|
|
2685
2358
|
}
|
|
2686
2359
|
}
|
|
2687
2360
|
function migrateSporeFiles(vaultDir) {
|
|
2688
|
-
const sporesDir =
|
|
2689
|
-
if (!
|
|
2361
|
+
const sporesDir = path6.join(vaultDir, "spores");
|
|
2362
|
+
if (!fs4.existsSync(sporesDir)) return 0;
|
|
2690
2363
|
let moved = 0;
|
|
2691
|
-
const entries =
|
|
2364
|
+
const entries = fs4.readdirSync(sporesDir);
|
|
2692
2365
|
for (const entry of entries) {
|
|
2693
|
-
const fullPath =
|
|
2366
|
+
const fullPath = path6.join(sporesDir, entry);
|
|
2694
2367
|
if (!entry.endsWith(".md")) continue;
|
|
2695
|
-
if (
|
|
2368
|
+
if (fs4.statSync(fullPath).isDirectory()) continue;
|
|
2696
2369
|
try {
|
|
2697
|
-
const content =
|
|
2370
|
+
const content = fs4.readFileSync(fullPath, "utf-8");
|
|
2698
2371
|
const fmMatch = content.match(/^---\n([\s\S]*?)\n---/);
|
|
2699
2372
|
if (!fmMatch) continue;
|
|
2700
|
-
const parsed =
|
|
2373
|
+
const parsed = import_yaml.default.parse(fmMatch[1]);
|
|
2701
2374
|
const obsType = parsed.observation_type;
|
|
2702
2375
|
if (!obsType) continue;
|
|
2703
2376
|
const normalizedType = obsType.replace(/_/g, "-");
|
|
2704
|
-
const targetDir =
|
|
2705
|
-
|
|
2706
|
-
const targetPath =
|
|
2707
|
-
|
|
2377
|
+
const targetDir = path6.join(sporesDir, normalizedType);
|
|
2378
|
+
fs4.mkdirSync(targetDir, { recursive: true });
|
|
2379
|
+
const targetPath = path6.join(targetDir, entry);
|
|
2380
|
+
fs4.renameSync(fullPath, targetPath);
|
|
2708
2381
|
const now = /* @__PURE__ */ new Date();
|
|
2709
|
-
|
|
2382
|
+
fs4.utimesSync(targetPath, now, now);
|
|
2710
2383
|
moved++;
|
|
2711
2384
|
} catch {
|
|
2712
2385
|
}
|
|
@@ -2719,9 +2392,9 @@ async function main() {
|
|
|
2719
2392
|
process.stderr.write("Usage: mycod --vault <path>\n");
|
|
2720
2393
|
process.exit(1);
|
|
2721
2394
|
}
|
|
2722
|
-
const vaultDir =
|
|
2395
|
+
const vaultDir = path6.resolve(vaultArg);
|
|
2723
2396
|
const config = loadConfig(vaultDir);
|
|
2724
|
-
const logger = new DaemonLogger(
|
|
2397
|
+
const logger = new DaemonLogger(path6.join(vaultDir, "logs"), {
|
|
2725
2398
|
level: config.daemon.log_level,
|
|
2726
2399
|
maxSize: config.daemon.max_log_size
|
|
2727
2400
|
});
|
|
@@ -2744,14 +2417,14 @@ async function main() {
|
|
|
2744
2417
|
let vectorIndex = null;
|
|
2745
2418
|
try {
|
|
2746
2419
|
const testEmbed = await embeddingProvider.embed("test");
|
|
2747
|
-
vectorIndex = new VectorIndex(
|
|
2420
|
+
vectorIndex = new VectorIndex(path6.join(vaultDir, "vectors.db"), testEmbed.dimensions);
|
|
2748
2421
|
logger.info("embeddings", "Vector index initialized", { dimensions: testEmbed.dimensions });
|
|
2749
2422
|
} catch (error) {
|
|
2750
2423
|
logger.warn("embeddings", "Vector index unavailable", { error: error.message });
|
|
2751
2424
|
}
|
|
2752
2425
|
const processor = new BufferProcessor(llmProvider, config.intelligence.llm.context_window, config.capture);
|
|
2753
2426
|
const vault = new VaultWriter(vaultDir);
|
|
2754
|
-
const index = new MycoIndex(
|
|
2427
|
+
const index = new MycoIndex(path6.join(vaultDir, "index.db"));
|
|
2755
2428
|
const lineageGraph = new LineageGraph(vaultDir);
|
|
2756
2429
|
const transcriptMiner = new TranscriptMiner({
|
|
2757
2430
|
additionalAdapters: config.capture.transcript_paths.map(
|
|
@@ -2759,18 +2432,18 @@ async function main() {
|
|
|
2759
2432
|
)
|
|
2760
2433
|
});
|
|
2761
2434
|
let activeStopProcessing = null;
|
|
2762
|
-
const indexDeps = { index, vaultDir, vectorIndex, embeddingProvider, logger };
|
|
2763
|
-
const bufferDir =
|
|
2435
|
+
const indexDeps = { index, vaultDir, vectorIndex, embeddingProvider, llmProvider, logger };
|
|
2436
|
+
const bufferDir = path6.join(vaultDir, "buffer");
|
|
2764
2437
|
const sessionBuffers = /* @__PURE__ */ new Map();
|
|
2765
2438
|
const sessionFilePaths = /* @__PURE__ */ new Map();
|
|
2766
2439
|
const capturedArtifactPaths = /* @__PURE__ */ new Map();
|
|
2767
|
-
if (
|
|
2440
|
+
if (fs4.existsSync(bufferDir)) {
|
|
2768
2441
|
const cutoff = Date.now() - STALE_BUFFER_MAX_AGE_MS;
|
|
2769
|
-
for (const file of
|
|
2770
|
-
const filePath =
|
|
2771
|
-
const stat4 =
|
|
2442
|
+
for (const file of fs4.readdirSync(bufferDir)) {
|
|
2443
|
+
const filePath = path6.join(bufferDir, file);
|
|
2444
|
+
const stat4 = fs4.statSync(filePath);
|
|
2772
2445
|
if (stat4.mtimeMs < cutoff) {
|
|
2773
|
-
|
|
2446
|
+
fs4.unlinkSync(filePath);
|
|
2774
2447
|
logger.debug("daemon", "Cleaned stale buffer", { file });
|
|
2775
2448
|
}
|
|
2776
2449
|
}
|
|
@@ -2807,10 +2480,10 @@ async function main() {
|
|
|
2807
2480
|
logger.info("watcher", "Plan detected", { source: event.source, file: event.filePath });
|
|
2808
2481
|
if (event.filePath) {
|
|
2809
2482
|
try {
|
|
2810
|
-
const content =
|
|
2811
|
-
const relativePath =
|
|
2812
|
-
const title = content.match(/^#\s+(.+)$/m)?.[1] ??
|
|
2813
|
-
const planId = `plan-${
|
|
2483
|
+
const content = fs4.readFileSync(event.filePath, "utf-8");
|
|
2484
|
+
const relativePath = path6.relative(vaultDir, event.filePath);
|
|
2485
|
+
const title = content.match(/^#\s+(.+)$/m)?.[1] ?? path6.basename(event.filePath);
|
|
2486
|
+
const planId = `plan-${path6.basename(event.filePath, ".md")}`;
|
|
2814
2487
|
indexAndEmbed(
|
|
2815
2488
|
relativePath,
|
|
2816
2489
|
planId,
|
|
@@ -2858,6 +2531,7 @@ ${content}`,
|
|
|
2858
2531
|
}
|
|
2859
2532
|
}).catch((err) => {
|
|
2860
2533
|
logger.warn("digest", "Initial digest cycle failed", { error: err.message });
|
|
2534
|
+
metabolism.onEmptyCycle();
|
|
2861
2535
|
});
|
|
2862
2536
|
metabolism.start(async () => {
|
|
2863
2537
|
try {
|
|
@@ -2906,7 +2580,7 @@ ${content}`,
|
|
|
2906
2580
|
}
|
|
2907
2581
|
const captured = capturedArtifactPaths.get(sessionId);
|
|
2908
2582
|
for (const c of candidates) {
|
|
2909
|
-
const absPath =
|
|
2583
|
+
const absPath = path6.resolve(process.cwd(), c.path);
|
|
2910
2584
|
captured.add(absPath);
|
|
2911
2585
|
}
|
|
2912
2586
|
}).catch((err) => logger.warn("processor", "Incremental artifact capture failed", {
|
|
@@ -2946,14 +2620,14 @@ ${content}`,
|
|
|
2946
2620
|
registry.unregister(session_id);
|
|
2947
2621
|
try {
|
|
2948
2622
|
const cutoff = Date.now() - STALE_BUFFER_MAX_AGE_MS;
|
|
2949
|
-
for (const file of
|
|
2623
|
+
for (const file of fs4.readdirSync(bufferDir)) {
|
|
2950
2624
|
if (!file.endsWith(".jsonl")) continue;
|
|
2951
2625
|
const bufferSessionId = file.replace(".jsonl", "");
|
|
2952
2626
|
if (bufferSessionId === session_id) continue;
|
|
2953
|
-
const filePath =
|
|
2954
|
-
const stat4 =
|
|
2627
|
+
const filePath = path6.join(bufferDir, file);
|
|
2628
|
+
const stat4 = fs4.statSync(filePath);
|
|
2955
2629
|
if (stat4.mtimeMs < cutoff) {
|
|
2956
|
-
|
|
2630
|
+
fs4.unlinkSync(filePath);
|
|
2957
2631
|
logger.debug("daemon", "Cleaned stale buffer", { file });
|
|
2958
2632
|
}
|
|
2959
2633
|
}
|
|
@@ -3048,15 +2722,15 @@ ${content}`,
|
|
|
3048
2722
|
}
|
|
3049
2723
|
const ended = (/* @__PURE__ */ new Date()).toISOString();
|
|
3050
2724
|
let started = allTurns.length > 0 && allTurns[0].timestamp ? allTurns[0].timestamp : ended;
|
|
3051
|
-
const sessionsDir =
|
|
2725
|
+
const sessionsDir = path6.join(vaultDir, "sessions");
|
|
3052
2726
|
const sessionFileName = `${sessionNoteId(sessionId)}.md`;
|
|
3053
2727
|
let existingContent;
|
|
3054
2728
|
const duplicatePaths = [];
|
|
3055
2729
|
try {
|
|
3056
|
-
for (const dateDir of
|
|
3057
|
-
const candidate =
|
|
2730
|
+
for (const dateDir of fs4.readdirSync(sessionsDir)) {
|
|
2731
|
+
const candidate = path6.join(sessionsDir, dateDir, sessionFileName);
|
|
3058
2732
|
try {
|
|
3059
|
-
const content =
|
|
2733
|
+
const content = fs4.readFileSync(candidate, "utf-8");
|
|
3060
2734
|
if (!existingContent || content.length > existingContent.length) {
|
|
3061
2735
|
existingContent = content;
|
|
3062
2736
|
}
|
|
@@ -3068,8 +2742,11 @@ ${content}`,
|
|
|
3068
2742
|
}
|
|
3069
2743
|
let existingTurnCount = 0;
|
|
3070
2744
|
if (existingContent) {
|
|
3071
|
-
const
|
|
3072
|
-
if (
|
|
2745
|
+
const fmMatch = existingContent.match(/^---\n([\s\S]*?)\n---/);
|
|
2746
|
+
if (fmMatch) {
|
|
2747
|
+
const parsed = import_yaml.default.parse(fmMatch[1]);
|
|
2748
|
+
if (typeof parsed.started === "string") started = parsed.started;
|
|
2749
|
+
}
|
|
3073
2750
|
const turnMatches = existingContent.match(/^### Turn \d+/gm);
|
|
3074
2751
|
existingTurnCount = turnMatches?.length ?? 0;
|
|
3075
2752
|
}
|
|
@@ -3116,20 +2793,20 @@ ${conversationText}`;
|
|
|
3116
2793
|
}
|
|
3117
2794
|
const date = started.slice(0, 10);
|
|
3118
2795
|
const relativePath = sessionRelativePath(sessionId, date);
|
|
3119
|
-
const targetFullPath =
|
|
2796
|
+
const targetFullPath = path6.join(vaultDir, relativePath);
|
|
3120
2797
|
for (const dup of duplicatePaths) {
|
|
3121
2798
|
if (dup !== targetFullPath) {
|
|
3122
2799
|
try {
|
|
3123
|
-
|
|
2800
|
+
fs4.unlinkSync(dup);
|
|
3124
2801
|
logger.debug("lifecycle", "Removed duplicate session file", { path: dup });
|
|
3125
2802
|
} catch {
|
|
3126
2803
|
}
|
|
3127
2804
|
}
|
|
3128
2805
|
}
|
|
3129
|
-
const attachmentsDir =
|
|
2806
|
+
const attachmentsDir = path6.join(vaultDir, "attachments");
|
|
3130
2807
|
const hasImages = allTurns.some((t) => t.images?.length);
|
|
3131
2808
|
if (hasImages) {
|
|
3132
|
-
|
|
2809
|
+
fs4.mkdirSync(attachmentsDir, { recursive: true });
|
|
3133
2810
|
}
|
|
3134
2811
|
const turnImageNames = /* @__PURE__ */ new Map();
|
|
3135
2812
|
for (let i = 0; i < allTurns.length; i++) {
|
|
@@ -3140,9 +2817,9 @@ ${conversationText}`;
|
|
|
3140
2817
|
const img = turn.images[j];
|
|
3141
2818
|
const ext = extensionForMimeType(img.mediaType);
|
|
3142
2819
|
const filename = `${bareSessionId(sessionId)}-t${i + 1}-${j + 1}.${ext}`;
|
|
3143
|
-
const filePath =
|
|
3144
|
-
if (!
|
|
3145
|
-
|
|
2820
|
+
const filePath = path6.join(attachmentsDir, filename);
|
|
2821
|
+
if (!fs4.existsSync(filePath)) {
|
|
2822
|
+
fs4.writeFileSync(filePath, Buffer.from(img.data, "base64"));
|
|
3146
2823
|
logger.debug("processor", "Image saved", { filename, turn: i + 1 });
|
|
3147
2824
|
}
|
|
3148
2825
|
names.push(filename);
|
|
@@ -3208,7 +2885,7 @@ ${conversationText}`;
|
|
|
3208
2885
|
if (!note) return { id: candidate.id, score: 0 };
|
|
3209
2886
|
try {
|
|
3210
2887
|
const prompt = buildSimilarityPrompt(narrative, note.content.slice(0, CANDIDATE_CONTENT_PREVIEW));
|
|
3211
|
-
const response = await llmProvider.summarize(prompt, { maxTokens: LINEAGE_SIMILARITY_MAX_TOKENS });
|
|
2888
|
+
const response = await llmProvider.summarize(prompt, { maxTokens: LINEAGE_SIMILARITY_MAX_TOKENS, reasoning: LLM_REASONING_MODE });
|
|
3212
2889
|
const score = extractNumber(response.text);
|
|
3213
2890
|
return { id: candidate.id, score: isNaN(score) ? 0 : score };
|
|
3214
2891
|
} catch {
|
|
@@ -3376,4 +3053,4 @@ export {
|
|
|
3376
3053
|
chokidar/index.js:
|
|
3377
3054
|
(*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) *)
|
|
3378
3055
|
*/
|
|
3379
|
-
//# sourceMappingURL=main-
|
|
3056
|
+
//# sourceMappingURL=main-NFQ4II75.js.map
|