@ureck/alexandria 1.6.0 → 1.6.2
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/README.md +198 -76
- package/dist/{chunk-SSTG2NOO.js → chunk-AAHJNPLB.js} +1 -1
- package/dist/{chunk-44QPE5IM.js → chunk-DELBYC3Y.js} +14 -3
- package/dist/{chunk-OGVWOBYH.js → chunk-EVF6HDVH.js} +1 -1
- package/dist/{chunk-WVZQGLRI.js → chunk-JJ62U6UP.js} +1 -1
- package/dist/chunk-KRMDWHCZ.js +82 -0
- package/dist/{chunk-EDYBSJSS.js → chunk-LUAVB3CA.js} +12 -8
- package/dist/{chunk-BXVNQVLX.js → chunk-MKGNA7ZC.js} +4 -4
- package/dist/{chunk-I5H4BN3F.js → chunk-NUG7HLOU.js} +7 -27
- package/dist/{chunk-WSVNMMNN.js → chunk-VCVBX3VT.js} +2 -2
- package/dist/{chunk-47S5I3D3.js → chunk-WSKQM5XI.js} +2 -2
- package/dist/cli.js +45 -21
- package/dist/{embedder-7Z4XNL6H.js → embedder-JBYRHKR4.js} +1 -1
- package/dist/hooks/on-bash.js +3 -3
- package/dist/hooks/on-prompt.js +4 -4
- package/dist/hooks/on-read.js +2 -2
- package/dist/hooks/on-session-start.js +3 -3
- package/dist/hooks/on-stop.js +27 -8
- package/dist/mcp/server.js +7 -7
- package/dist/{viewer-T2SEBP6Z.js → viewer-V7WGXOFM.js} +3 -3
- package/dist/xlsx-THZM4FNX.js +128 -0
- package/package.json +3 -3
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/core/lock.ts
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import path from "path";
|
|
6
|
+
var STALE_MS = 3 * 60 * 60 * 1e3;
|
|
7
|
+
function reindexLockPath(vault) {
|
|
8
|
+
return path.join(vault.cache, "reindex.lock");
|
|
9
|
+
}
|
|
10
|
+
function pidAlive(pid) {
|
|
11
|
+
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
12
|
+
try {
|
|
13
|
+
process.kill(pid, 0);
|
|
14
|
+
return true;
|
|
15
|
+
} catch (e) {
|
|
16
|
+
return e.code === "EPERM";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function reindexLockHolder(vault) {
|
|
20
|
+
try {
|
|
21
|
+
const file = reindexLockPath(vault);
|
|
22
|
+
const st = fs.statSync(file);
|
|
23
|
+
const pid = Number.parseInt(fs.readFileSync(file, "utf8").trim(), 10);
|
|
24
|
+
if (Date.now() - st.mtimeMs > STALE_MS) return null;
|
|
25
|
+
return pidAlive(pid) ? pid : null;
|
|
26
|
+
} catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function acquireReindexLock(vault, opts = {}) {
|
|
31
|
+
const pid = opts.pid ?? process.pid;
|
|
32
|
+
const file = reindexLockPath(vault);
|
|
33
|
+
fs.mkdirSync(vault.cache, { recursive: true });
|
|
34
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
35
|
+
try {
|
|
36
|
+
fs.writeFileSync(file, String(pid), { flag: "wx" });
|
|
37
|
+
return true;
|
|
38
|
+
} catch (e) {
|
|
39
|
+
if (e.code !== "EEXIST") return false;
|
|
40
|
+
}
|
|
41
|
+
let holder = null;
|
|
42
|
+
try {
|
|
43
|
+
holder = Number.parseInt(fs.readFileSync(file, "utf8").trim(), 10);
|
|
44
|
+
} catch {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (holder === pid || opts.adoptFrom !== void 0 && holder === opts.adoptFrom) {
|
|
48
|
+
fs.writeFileSync(file, String(pid));
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
if (reindexLockHolder(vault) !== null) return false;
|
|
52
|
+
try {
|
|
53
|
+
fs.rmSync(file, { force: true });
|
|
54
|
+
} catch {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
function transferReindexLock(vault, toPid, fromPid = process.pid) {
|
|
61
|
+
const file = reindexLockPath(vault);
|
|
62
|
+
try {
|
|
63
|
+
if (Number.parseInt(fs.readFileSync(file, "utf8").trim(), 10) === fromPid) {
|
|
64
|
+
fs.writeFileSync(file, String(toPid));
|
|
65
|
+
}
|
|
66
|
+
} catch {
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function releaseReindexLock(vault, pid = process.pid) {
|
|
70
|
+
const file = reindexLockPath(vault);
|
|
71
|
+
try {
|
|
72
|
+
if (Number.parseInt(fs.readFileSync(file, "utf8").trim(), 10) === pid) fs.rmSync(file, { force: true });
|
|
73
|
+
} catch {
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export {
|
|
78
|
+
reindexLockHolder,
|
|
79
|
+
acquireReindexLock,
|
|
80
|
+
transferReindexLock,
|
|
81
|
+
releaseReindexLock
|
|
82
|
+
};
|
|
@@ -55,15 +55,19 @@ async function embed(texts, kind = "passage", onProgress) {
|
|
|
55
55
|
if (texts.length === 0) return [];
|
|
56
56
|
const pipe = await getEmbedder(onProgress);
|
|
57
57
|
const prefixed = texts.map((t) => `${kind}: ${t}`);
|
|
58
|
-
const rows =
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const
|
|
58
|
+
const rows = new Array(prefixed.length);
|
|
59
|
+
const order = prefixed.map((_, i) => i).sort((a, b) => prefixed[a].length - prefixed[b].length);
|
|
60
|
+
const BATCH = 8;
|
|
61
|
+
for (let i = 0; i < order.length; i += BATCH) {
|
|
62
|
+
const ids = order.slice(i, i + BATCH);
|
|
63
|
+
const out = await pipe(
|
|
64
|
+
ids.map((k) => prefixed[k]),
|
|
65
|
+
{ pooling: "mean", normalize: true }
|
|
66
|
+
);
|
|
63
67
|
const dim = out.dims[out.dims.length - 1];
|
|
64
|
-
|
|
65
|
-
rows
|
|
66
|
-
}
|
|
68
|
+
ids.forEach((k, j) => {
|
|
69
|
+
rows[k] = out.data.slice(j * dim, (j + 1) * dim);
|
|
70
|
+
});
|
|
67
71
|
}
|
|
68
72
|
return rows;
|
|
69
73
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
hybridSearch
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-WSKQM5XI.js";
|
|
5
5
|
import {
|
|
6
6
|
slugify
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-DELBYC3Y.js";
|
|
8
8
|
import {
|
|
9
9
|
convertFile,
|
|
10
10
|
htmlToMarkdown
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-NUG7HLOU.js";
|
|
12
12
|
import {
|
|
13
13
|
logDocUse
|
|
14
14
|
} from "./chunk-X4V6SYYA.js";
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
dot,
|
|
21
21
|
embed,
|
|
22
22
|
modelPresent
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-LUAVB3CA.js";
|
|
24
24
|
|
|
25
25
|
// src/core/planning.ts
|
|
26
26
|
var MAX_ITEMS = 2;
|
|
@@ -163,7 +163,7 @@ function inferType(values) {
|
|
|
163
163
|
function sheetsToMarkdown(sheets) {
|
|
164
164
|
const out = [];
|
|
165
165
|
for (const { name, rows } of sheets) {
|
|
166
|
-
const clean = rows.filter((r) => r.some((c) => c !== ""));
|
|
166
|
+
const clean = rows.map((r) => Array.from(r ?? [], (c) => c ?? "")).filter((r) => r.some((c) => c !== ""));
|
|
167
167
|
if (clean.length === 0) continue;
|
|
168
168
|
const [header, ...data] = clean;
|
|
169
169
|
const cols = header.map((h, i) => h || `col${i + 1}`);
|
|
@@ -188,35 +188,15 @@ function sheetsToMarkdown(sheets) {
|
|
|
188
188
|
return out.join("\n\n");
|
|
189
189
|
}
|
|
190
190
|
async function xlsxToMarkdown(buf) {
|
|
191
|
-
const
|
|
192
|
-
const
|
|
193
|
-
await wb.xlsx.load(buf);
|
|
194
|
-
const sheets = [];
|
|
191
|
+
const { readXlsx } = await import("./xlsx-THZM4FNX.js");
|
|
192
|
+
const sheets = await readXlsx(buf);
|
|
195
193
|
let totalRows = 0;
|
|
196
194
|
let rawChars = 0;
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
const vals = row.values.slice(1).map(cellText);
|
|
201
|
-
rows.push(vals);
|
|
202
|
-
rawChars += vals.join(",").length + 1;
|
|
203
|
-
});
|
|
204
|
-
totalRows += Math.max(0, rows.length - 1);
|
|
205
|
-
sheets.push({ name: ws.name, rows });
|
|
206
|
-
});
|
|
207
|
-
return { format: "xlsx", markdown: sheetsToMarkdown(sheets), rows: totalRows, tokensOriginal: Math.ceil(rawChars / 4) };
|
|
208
|
-
}
|
|
209
|
-
function cellText(v) {
|
|
210
|
-
if (v === null || v === void 0) return "";
|
|
211
|
-
if (v instanceof Date) return v.toISOString().slice(0, 10);
|
|
212
|
-
if (typeof v === "object") {
|
|
213
|
-
const o = v;
|
|
214
|
-
if (o.richText) return o.richText.map((t) => t.text).join("");
|
|
215
|
-
if (o.text !== void 0) return String(o.text);
|
|
216
|
-
if (o.result !== void 0) return cellText(o.result);
|
|
217
|
-
return "";
|
|
195
|
+
for (const sh of sheets) {
|
|
196
|
+
totalRows += Math.max(0, sh.rows.length - 1);
|
|
197
|
+
for (const r of sh.rows) rawChars += r.join(",").length + 1;
|
|
218
198
|
}
|
|
219
|
-
return
|
|
199
|
+
return { format: "xlsx", markdown: sheetsToMarkdown(sheets), rows: totalRows, tokensOriginal: Math.ceil(rawChars / 4) };
|
|
220
200
|
}
|
|
221
201
|
function sniffDelimiter(text) {
|
|
222
202
|
const first = text.split(/\r?\n/, 1)[0] ?? "";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
isoDate,
|
|
4
4
|
supersedeNote
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-DELBYC3Y.js";
|
|
6
6
|
import {
|
|
7
7
|
charsToTokens
|
|
8
8
|
} from "./chunk-X4V6SYYA.js";
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
MODEL_ID,
|
|
14
14
|
dot,
|
|
15
15
|
modelCacheDir
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-LUAVB3CA.js";
|
|
17
17
|
|
|
18
18
|
// src/core/clean.ts
|
|
19
19
|
import fs from "fs";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
VaultIndex
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-DELBYC3Y.js";
|
|
5
5
|
import {
|
|
6
6
|
dot,
|
|
7
7
|
embed,
|
|
8
8
|
modelPresent
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-LUAVB3CA.js";
|
|
10
10
|
|
|
11
11
|
// src/core/search.ts
|
|
12
12
|
import MiniSearch from "minisearch";
|
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
serveGraph
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-AAHJNPLB.js";
|
|
5
|
+
import {
|
|
6
|
+
acquireReindexLock,
|
|
7
|
+
reindexLockHolder,
|
|
8
|
+
releaseReindexLock
|
|
9
|
+
} from "./chunk-KRMDWHCZ.js";
|
|
5
10
|
import {
|
|
6
11
|
architectBlock,
|
|
7
12
|
distDir,
|
|
@@ -24,11 +29,11 @@ import {
|
|
|
24
29
|
serverCommand,
|
|
25
30
|
symbolSource,
|
|
26
31
|
unregisterHooks
|
|
27
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-MKGNA7ZC.js";
|
|
28
33
|
import {
|
|
29
34
|
hybridSearch,
|
|
30
35
|
protocolChain
|
|
31
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-WSKQM5XI.js";
|
|
32
37
|
import {
|
|
33
38
|
ARCHIVE_DIR,
|
|
34
39
|
applyClean,
|
|
@@ -36,24 +41,24 @@ import {
|
|
|
36
41
|
markCleaned,
|
|
37
42
|
planClean,
|
|
38
43
|
searchArchive
|
|
39
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-VCVBX3VT.js";
|
|
40
45
|
import {
|
|
41
46
|
VaultIndex,
|
|
42
47
|
createNote,
|
|
43
48
|
slugify,
|
|
44
49
|
supersedeNote,
|
|
45
50
|
upsertNote
|
|
46
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-DELBYC3Y.js";
|
|
47
52
|
import {
|
|
48
53
|
formatOf
|
|
49
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-NUG7HLOU.js";
|
|
50
55
|
import {
|
|
51
56
|
listRuns,
|
|
52
57
|
runCommand,
|
|
53
58
|
saveRun,
|
|
54
59
|
shouldFoldOutput,
|
|
55
60
|
showRun
|
|
56
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-EVF6HDVH.js";
|
|
57
62
|
import {
|
|
58
63
|
logFold,
|
|
59
64
|
readSessionUsage,
|
|
@@ -80,7 +85,7 @@ import {
|
|
|
80
85
|
embed,
|
|
81
86
|
getEmbedder,
|
|
82
87
|
modelPresent
|
|
83
|
-
} from "./chunk-
|
|
88
|
+
} from "./chunk-LUAVB3CA.js";
|
|
84
89
|
|
|
85
90
|
// src/cli.ts
|
|
86
91
|
import fs7 from "fs";
|
|
@@ -1980,14 +1985,24 @@ program.command("scan").description("Escanea el proyecto (API, env-nombres, dato
|
|
|
1980
1985
|
program.command("reindex").description("Reindexar la b\xF3veda (incremental; --force para todo)").option("--force", "reindexar todo desde cero").action(async (opts) => {
|
|
1981
1986
|
const vault = getVault();
|
|
1982
1987
|
ensureVaultStructure(vault);
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1988
|
+
const parent = Number.parseInt(process.env.ALEXANDRIA_REINDEX_PARENT ?? "", 10);
|
|
1989
|
+
if (!acquireReindexLock(vault, { adoptFrom: Number.isNaN(parent) ? void 0 : parent })) {
|
|
1990
|
+
console.log(pc.yellow(`\u26A0 Ya hay un reindex en curso (pid ${reindexLockHolder(vault) ?? "?"}) \u2014 espera a que termine`));
|
|
1991
|
+
process.exitCode = 1;
|
|
1992
|
+
return;
|
|
1993
|
+
}
|
|
1994
|
+
try {
|
|
1995
|
+
await downloadModelIfMissing();
|
|
1996
|
+
const idx = VaultIndex.load(vault);
|
|
1997
|
+
const res = await idx.refresh(modelPresent(), opts.force);
|
|
1998
|
+
console.log(
|
|
1999
|
+
pc.green(
|
|
2000
|
+
`\u2713 ${res.changed} notas reindexadas, ${res.removed} eliminadas \u2014 ${Object.keys(idx.meta.notes).length} notas, ${idx.meta.links.length} conexiones${res.embedded ? "" : " (keyword-only)"}`
|
|
2001
|
+
)
|
|
2002
|
+
);
|
|
2003
|
+
} finally {
|
|
2004
|
+
releaseReindexLock(vault);
|
|
2005
|
+
}
|
|
1991
2006
|
});
|
|
1992
2007
|
program.command("graph").description("Visor del grafo de conocimiento (local, estilo Obsidian/Graphify)").option("--out <file>", "escribir HTML autocontenido en vez de servir").option("--no-open", "no abrir el navegador").action(async (opts) => {
|
|
1993
2008
|
const { vault } = await ensureReady();
|
|
@@ -2169,11 +2184,20 @@ program.command("doctor").description("Verifica y repara la instalaci\xF3n (mode
|
|
|
2169
2184
|
} else if (idx.emb) {
|
|
2170
2185
|
console.log(`${pc.green("\u2713")} Embeddings alineados (${idx.meta.chunks.length} chunks)`);
|
|
2171
2186
|
} else if (idx.meta.chunks.length > 0 && model) {
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2187
|
+
const holder = reindexLockHolder(vault);
|
|
2188
|
+
if (holder !== null || !acquireReindexLock(vault)) {
|
|
2189
|
+
console.log(pc.yellow(`\u26A0 \xCDndice SIN vectores \u2014 ya hay un reindex en curso (pid ${holder ?? "?"}); se repara solo al terminar`));
|
|
2190
|
+
} else {
|
|
2191
|
+
try {
|
|
2192
|
+
console.log(pc.yellow(`\u26A0 \xCDndice SIN vectores (${idx.meta.chunks.length} chunks) \u2014 b\xFAsqueda degradada a keyword. Reconstruyendo\u2026`));
|
|
2193
|
+
const rebuilt = await idx.refresh(true, true);
|
|
2194
|
+
console.log(
|
|
2195
|
+
idx.emb ? `${pc.green("\u2713")} \xCDndice sem\xE1ntico reconstruido (${rebuilt.changed} notas)` : pc.yellow("\u26A0 No se pudo reconstruir \u2014 corre `ale reindex --force` y revisa el modelo")
|
|
2196
|
+
);
|
|
2197
|
+
} finally {
|
|
2198
|
+
releaseReindexLock(vault);
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2177
2201
|
}
|
|
2178
2202
|
try {
|
|
2179
2203
|
const name = path7.basename(cwd);
|
package/dist/hooks/on-bash.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
runHook
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-JJ62U6UP.js";
|
|
5
5
|
import {
|
|
6
6
|
saveRun,
|
|
7
7
|
shouldFoldOutput
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-EVF6HDVH.js";
|
|
9
9
|
import {
|
|
10
10
|
logFold
|
|
11
11
|
} from "../chunk-X4V6SYYA.js";
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
toggleEnabled,
|
|
15
15
|
vaultExists
|
|
16
16
|
} from "../chunk-YICWI3U3.js";
|
|
17
|
-
import "../chunk-
|
|
17
|
+
import "../chunk-LUAVB3CA.js";
|
|
18
18
|
|
|
19
19
|
// src/hooks/on-bash.ts
|
|
20
20
|
runHook(3e3, async (input) => {
|
package/dist/hooks/on-prompt.js
CHANGED
|
@@ -8,14 +8,14 @@ import {
|
|
|
8
8
|
projectName,
|
|
9
9
|
runHook,
|
|
10
10
|
truncate
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-JJ62U6UP.js";
|
|
12
12
|
import {
|
|
13
13
|
hybridSearch
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-WSKQM5XI.js";
|
|
15
15
|
import {
|
|
16
16
|
createNote,
|
|
17
17
|
touchNote
|
|
18
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-DELBYC3Y.js";
|
|
19
19
|
import {
|
|
20
20
|
logInjection
|
|
21
21
|
} from "../chunk-X4V6SYYA.js";
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
toggleEnabled,
|
|
26
26
|
vaultExists
|
|
27
27
|
} from "../chunk-YICWI3U3.js";
|
|
28
|
-
import "../chunk-
|
|
28
|
+
import "../chunk-LUAVB3CA.js";
|
|
29
29
|
|
|
30
30
|
// src/hooks/on-prompt.ts
|
|
31
31
|
import fs from "fs";
|
package/dist/hooks/on-read.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
runHook
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-JJ62U6UP.js";
|
|
5
5
|
import {
|
|
6
6
|
PDF_TOKENS_PER_PAGE,
|
|
7
7
|
formatOf
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-NUG7HLOU.js";
|
|
9
9
|
import {
|
|
10
10
|
resolveVault,
|
|
11
11
|
toggleEnabled,
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
projectName,
|
|
9
9
|
runHook,
|
|
10
10
|
truncate
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-JJ62U6UP.js";
|
|
12
12
|
import {
|
|
13
13
|
VaultIndex
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-DELBYC3Y.js";
|
|
15
15
|
import {
|
|
16
16
|
logInjection
|
|
17
17
|
} from "../chunk-X4V6SYYA.js";
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
toggleEnabled,
|
|
22
22
|
vaultExists
|
|
23
23
|
} from "../chunk-YICWI3U3.js";
|
|
24
|
-
import "../chunk-
|
|
24
|
+
import "../chunk-LUAVB3CA.js";
|
|
25
25
|
|
|
26
26
|
// src/hooks/on-session-start.ts
|
|
27
27
|
import fs from "fs";
|
package/dist/hooks/on-stop.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
acquireReindexLock,
|
|
4
|
+
releaseReindexLock,
|
|
5
|
+
transferReindexLock
|
|
6
|
+
} from "../chunk-KRMDWHCZ.js";
|
|
2
7
|
import {
|
|
3
8
|
buildCapsule,
|
|
4
9
|
extractSession,
|
|
@@ -9,15 +14,15 @@ import {
|
|
|
9
14
|
projectName,
|
|
10
15
|
runHook,
|
|
11
16
|
truncate
|
|
12
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-JJ62U6UP.js";
|
|
13
18
|
import {
|
|
14
19
|
autoCleanDue,
|
|
15
20
|
markCleaned
|
|
16
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-VCVBX3VT.js";
|
|
17
22
|
import {
|
|
18
23
|
VaultIndex,
|
|
19
24
|
appendToNote
|
|
20
|
-
} from "../chunk-
|
|
25
|
+
} from "../chunk-DELBYC3Y.js";
|
|
21
26
|
import "../chunk-X4V6SYYA.js";
|
|
22
27
|
import {
|
|
23
28
|
ensureVaultStructure,
|
|
@@ -26,11 +31,12 @@ import {
|
|
|
26
31
|
toggleEnabled,
|
|
27
32
|
vaultExists
|
|
28
33
|
} from "../chunk-YICWI3U3.js";
|
|
29
|
-
import "../chunk-
|
|
34
|
+
import "../chunk-LUAVB3CA.js";
|
|
30
35
|
|
|
31
36
|
// src/hooks/on-stop.ts
|
|
32
37
|
import fs from "fs";
|
|
33
38
|
import path from "path";
|
|
39
|
+
import os from "os";
|
|
34
40
|
import { spawn } from "child_process";
|
|
35
41
|
import { fileURLToPath } from "url";
|
|
36
42
|
runHook(25e3, async (input) => {
|
|
@@ -96,23 +102,36 @@ function maybeCleanInBackground(vault) {
|
|
|
96
102
|
} catch {
|
|
97
103
|
}
|
|
98
104
|
}
|
|
99
|
-
async function maybeRebuildInBackground(vault) {
|
|
105
|
+
async function maybeRebuildInBackground(vault, cli = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "cli.js")) {
|
|
106
|
+
let locked = false;
|
|
100
107
|
try {
|
|
101
108
|
if (!toggleEnabled("index.autoRebuild")) return;
|
|
102
109
|
const idx = VaultIndex.load(vault);
|
|
103
110
|
if (!idx.needsRebuild() && !idx.isDegraded()) return;
|
|
104
|
-
const cli = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "cli.js");
|
|
105
111
|
if (!fs.existsSync(cli)) return;
|
|
112
|
+
if (!acquireReindexLock(vault)) return;
|
|
113
|
+
locked = true;
|
|
106
114
|
const child = spawn(process.execPath, [cli, "--vault", vault.root, "reindex", "--force"], {
|
|
107
115
|
detached: true,
|
|
108
116
|
stdio: "ignore",
|
|
109
117
|
windowsHide: true,
|
|
110
118
|
// Windows: sin esto puede parpadear una consola al cerrar sesión
|
|
111
|
-
|
|
112
|
-
|
|
119
|
+
// proceso CLI: sí puede reconstruir; ALEXANDRIA_REINDEX_PARENT le permite adoptar el candado
|
|
120
|
+
env: { ...process.env, ALEXANDRIA_HOOK: "", ALEXANDRIA_REINDEX_PARENT: String(process.pid) }
|
|
113
121
|
});
|
|
122
|
+
if (!child.pid) {
|
|
123
|
+
releaseReindexLock(vault);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
transferReindexLock(vault, child.pid);
|
|
127
|
+
locked = false;
|
|
128
|
+
try {
|
|
129
|
+
os.setPriority(child.pid, 10);
|
|
130
|
+
} catch {
|
|
131
|
+
}
|
|
114
132
|
child.unref();
|
|
115
133
|
} catch {
|
|
134
|
+
if (locked) releaseReindexLock(vault);
|
|
116
135
|
}
|
|
117
136
|
}
|
|
118
137
|
export {
|
package/dist/mcp/server.js
CHANGED
|
@@ -10,13 +10,13 @@ import {
|
|
|
10
10
|
planQualityHints,
|
|
11
11
|
readDoc,
|
|
12
12
|
symbolSource
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-MKGNA7ZC.js";
|
|
14
14
|
import {
|
|
15
15
|
hybridSearch
|
|
16
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-WSKQM5XI.js";
|
|
17
17
|
import {
|
|
18
18
|
searchArchive
|
|
19
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-VCVBX3VT.js";
|
|
20
20
|
import {
|
|
21
21
|
VaultIndex,
|
|
22
22
|
createNote,
|
|
@@ -24,18 +24,18 @@ import {
|
|
|
24
24
|
slugify,
|
|
25
25
|
supersedeNote,
|
|
26
26
|
upsertNote
|
|
27
|
-
} from "../chunk-
|
|
28
|
-
import "../chunk-
|
|
27
|
+
} from "../chunk-DELBYC3Y.js";
|
|
28
|
+
import "../chunk-NUG7HLOU.js";
|
|
29
29
|
import {
|
|
30
30
|
showRun
|
|
31
|
-
} from "../chunk-
|
|
31
|
+
} from "../chunk-EVF6HDVH.js";
|
|
32
32
|
import "../chunk-X4V6SYYA.js";
|
|
33
33
|
import {
|
|
34
34
|
ensureVaultStructure,
|
|
35
35
|
resolveVault,
|
|
36
36
|
toggleEnabled
|
|
37
37
|
} from "../chunk-YICWI3U3.js";
|
|
38
|
-
import "../chunk-
|
|
38
|
+
import "../chunk-LUAVB3CA.js";
|
|
39
39
|
|
|
40
40
|
// src/mcp/server.ts
|
|
41
41
|
import path from "path";
|
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
renderGraphHtml,
|
|
5
5
|
serveGraph,
|
|
6
6
|
writeStaticGraph
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-AAHJNPLB.js";
|
|
8
|
+
import "./chunk-DELBYC3Y.js";
|
|
9
|
+
import "./chunk-LUAVB3CA.js";
|
|
10
10
|
export {
|
|
11
11
|
buildGraphData,
|
|
12
12
|
renderGraphHtml,
|