skilld 1.0.0 → 1.1.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/README.md +45 -21
- package/dist/_chunks/agent.mjs +8 -7
- package/dist/_chunks/agent.mjs.map +1 -1
- package/dist/_chunks/assemble.mjs +134 -0
- package/dist/_chunks/assemble.mjs.map +1 -0
- package/dist/_chunks/cache2.mjs +1 -1
- package/dist/_chunks/detect.mjs +737 -0
- package/dist/_chunks/detect.mjs.map +1 -0
- package/dist/_chunks/embedding-cache.mjs +1 -1
- package/dist/_chunks/formatting.mjs +25 -294
- package/dist/_chunks/formatting.mjs.map +1 -1
- package/dist/_chunks/install.mjs +38 -12
- package/dist/_chunks/install.mjs.map +1 -1
- package/dist/_chunks/list.mjs +3 -1
- package/dist/_chunks/list.mjs.map +1 -1
- package/dist/_chunks/pool.mjs +113 -167
- package/dist/_chunks/pool.mjs.map +1 -1
- package/dist/_chunks/prompts.mjs +64 -735
- package/dist/_chunks/prompts.mjs.map +1 -1
- package/dist/_chunks/sanitize.mjs +2 -2
- package/dist/_chunks/sanitize.mjs.map +1 -1
- package/dist/_chunks/search-interactive.mjs +14 -3
- package/dist/_chunks/search-interactive.mjs.map +1 -1
- package/dist/_chunks/search.mjs +3 -1
- package/dist/_chunks/search2.mjs +180 -0
- package/dist/_chunks/search2.mjs.map +1 -0
- package/dist/_chunks/skills.mjs +292 -0
- package/dist/_chunks/skills.mjs.map +1 -0
- package/dist/_chunks/sync.mjs +313 -35
- package/dist/_chunks/sync.mjs.map +1 -1
- package/dist/_chunks/sync2.mjs +4 -2
- package/dist/_chunks/uninstall.mjs +6 -4
- package/dist/_chunks/uninstall.mjs.map +1 -1
- package/dist/_chunks/validate.mjs +2 -1
- package/dist/_chunks/validate.mjs.map +1 -1
- package/dist/agent/index.d.mts +29 -6
- package/dist/agent/index.d.mts.map +1 -1
- package/dist/agent/index.mjs +4 -3
- package/dist/cli.mjs +24 -13
- package/dist/cli.mjs.map +1 -1
- package/dist/retriv/index.d.mts +4 -1
- package/dist/retriv/index.d.mts.map +1 -1
- package/dist/retriv/index.mjs +25 -10
- package/dist/retriv/index.mjs.map +1 -1
- package/dist/retriv/worker.d.mts.map +1 -1
- package/dist/retriv/worker.mjs +2 -16
- package/dist/retriv/worker.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/_chunks/pool2.mjs +0 -115
- package/dist/_chunks/pool2.mjs.map +0 -1
package/dist/_chunks/pool2.mjs
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { dirname, join } from "pathe";
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
import { Worker } from "node:worker_threads";
|
|
5
|
-
let worker = null;
|
|
6
|
-
let taskId = 0;
|
|
7
|
-
const pending = /* @__PURE__ */ new Map();
|
|
8
|
-
const queue = [];
|
|
9
|
-
let running = false;
|
|
10
|
-
function resolveWorkerPath() {
|
|
11
|
-
const dir = dirname(fileURLToPath(import.meta.url));
|
|
12
|
-
for (const candidate of [join(dir, "worker.mjs"), join(dir, "..", "retriv", "worker.mjs")]) if (existsSync(candidate)) return { path: candidate };
|
|
13
|
-
return {
|
|
14
|
-
path: join(dir, "worker.ts"),
|
|
15
|
-
execArgv: ["--experimental-strip-types"]
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
function ensureWorker() {
|
|
19
|
-
if (worker) return worker;
|
|
20
|
-
const config = resolveWorkerPath();
|
|
21
|
-
const w = new Worker(config.path, { execArgv: config.execArgv });
|
|
22
|
-
w.on("message", (msg) => {
|
|
23
|
-
const task = pending.get(msg.id);
|
|
24
|
-
if (!task) return;
|
|
25
|
-
if (msg.type === "progress") task.onProgress?.({
|
|
26
|
-
phase: msg.phase,
|
|
27
|
-
current: msg.current,
|
|
28
|
-
total: msg.total
|
|
29
|
-
});
|
|
30
|
-
else if (msg.type === "done") {
|
|
31
|
-
pending.delete(msg.id);
|
|
32
|
-
task.resolve();
|
|
33
|
-
} else if (msg.type === "error") {
|
|
34
|
-
pending.delete(msg.id);
|
|
35
|
-
task.reject(new Error(msg.message));
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
w.on("error", (err) => {
|
|
39
|
-
for (const task of pending.values()) task.reject(err);
|
|
40
|
-
pending.clear();
|
|
41
|
-
worker = null;
|
|
42
|
-
});
|
|
43
|
-
w.on("exit", (code) => {
|
|
44
|
-
if (pending.size > 0) {
|
|
45
|
-
const err = /* @__PURE__ */ new Error(`Worker exited (code ${code}) with ${pending.size} pending tasks`);
|
|
46
|
-
for (const task of pending.values()) task.reject(err);
|
|
47
|
-
pending.clear();
|
|
48
|
-
}
|
|
49
|
-
worker = null;
|
|
50
|
-
});
|
|
51
|
-
worker = w;
|
|
52
|
-
return w;
|
|
53
|
-
}
|
|
54
|
-
function drainQueue() {
|
|
55
|
-
if (running || queue.length === 0) return;
|
|
56
|
-
queue.shift()();
|
|
57
|
-
}
|
|
58
|
-
async function createIndexInWorker(documents, config) {
|
|
59
|
-
return new Promise((resolve, reject) => {
|
|
60
|
-
const run = () => {
|
|
61
|
-
running = true;
|
|
62
|
-
const id = ++taskId;
|
|
63
|
-
let w;
|
|
64
|
-
try {
|
|
65
|
-
w = ensureWorker();
|
|
66
|
-
} catch (err) {
|
|
67
|
-
running = false;
|
|
68
|
-
drainQueue();
|
|
69
|
-
reject(err instanceof Error ? err : new Error(String(err)));
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
pending.set(id, {
|
|
73
|
-
id,
|
|
74
|
-
resolve: () => {
|
|
75
|
-
running = false;
|
|
76
|
-
drainQueue();
|
|
77
|
-
resolve();
|
|
78
|
-
},
|
|
79
|
-
reject: (err) => {
|
|
80
|
-
running = false;
|
|
81
|
-
drainQueue();
|
|
82
|
-
reject(err);
|
|
83
|
-
},
|
|
84
|
-
onProgress: config.onProgress
|
|
85
|
-
});
|
|
86
|
-
const msg = {
|
|
87
|
-
type: "index",
|
|
88
|
-
id,
|
|
89
|
-
documents,
|
|
90
|
-
dbPath: config.dbPath
|
|
91
|
-
};
|
|
92
|
-
w.postMessage(msg);
|
|
93
|
-
};
|
|
94
|
-
if (running) queue.push(run);
|
|
95
|
-
else run();
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
async function shutdownWorker() {
|
|
99
|
-
if (!worker) return;
|
|
100
|
-
const w = worker;
|
|
101
|
-
worker = null;
|
|
102
|
-
return new Promise((resolve) => {
|
|
103
|
-
const timeout = setTimeout(() => {
|
|
104
|
-
w.terminate().then(() => resolve(), () => resolve());
|
|
105
|
-
}, 5e3);
|
|
106
|
-
w.once("exit", () => {
|
|
107
|
-
clearTimeout(timeout);
|
|
108
|
-
resolve();
|
|
109
|
-
});
|
|
110
|
-
w.postMessage({ type: "shutdown" });
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
export { shutdownWorker as n, createIndexInWorker as t };
|
|
114
|
-
|
|
115
|
-
//# sourceMappingURL=pool2.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pool2.mjs","names":[],"sources":["../../src/retriv/pool.ts"],"sourcesContent":["import type { IndexConfig, Document as RetrivDocument } from './types.ts'\nimport type { WorkerMessage, WorkerResponse } from './worker.ts'\nimport { existsSync } from 'node:fs'\nimport { fileURLToPath } from 'node:url'\nimport { Worker } from 'node:worker_threads'\nimport { dirname, join } from 'pathe'\n\ninterface PendingTask {\n id: number\n resolve: () => void\n reject: (err: Error) => void\n onProgress?: IndexConfig['onProgress']\n}\n\nlet worker: Worker | null = null\nlet taskId = 0\nconst pending = new Map<number, PendingTask>()\nconst queue: Array<() => void> = []\nlet running = false\n\nfunction resolveWorkerPath(): { path: string, execArgv?: string[] } {\n const dir = dirname(fileURLToPath(import.meta.url))\n\n // Bundled: dist/retriv/worker.mjs (resolve from package root, not chunk dir)\n for (const candidate of [join(dir, 'worker.mjs'), join(dir, '..', 'retriv', 'worker.mjs')]) {\n if (existsSync(candidate))\n return { path: candidate }\n }\n\n // Dev stub: src/retriv/pool.ts → src/retriv/worker.ts\n return { path: join(dir, 'worker.ts'), execArgv: ['--experimental-strip-types'] }\n}\n\nfunction ensureWorker(): Worker {\n if (worker)\n return worker\n\n const config = resolveWorkerPath()\n const w = new Worker(config.path, {\n execArgv: config.execArgv,\n })\n\n w.on('message', (msg: WorkerResponse) => {\n const task = pending.get(msg.id)\n if (!task)\n return\n\n if (msg.type === 'progress') {\n task.onProgress?.({ phase: msg.phase as any, current: msg.current, total: msg.total })\n }\n else if (msg.type === 'done') {\n pending.delete(msg.id)\n task.resolve()\n }\n else if (msg.type === 'error') {\n pending.delete(msg.id)\n task.reject(new Error(msg.message))\n }\n })\n\n w.on('error', (err: Error) => {\n for (const task of pending.values())\n task.reject(err)\n pending.clear()\n worker = null\n })\n\n w.on('exit', (code) => {\n if (pending.size > 0) {\n const err = new Error(`Worker exited (code ${code}) with ${pending.size} pending tasks`)\n for (const task of pending.values())\n task.reject(err)\n pending.clear()\n }\n worker = null\n })\n\n worker = w\n return w\n}\n\nfunction drainQueue() {\n if (running || queue.length === 0)\n return\n const next = queue.shift()!\n next()\n}\n\nexport async function createIndexInWorker(\n documents: RetrivDocument[],\n config: IndexConfig,\n): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n const run = () => {\n running = true\n const id = ++taskId\n\n let w: Worker\n try {\n w = ensureWorker()\n }\n catch (err) {\n running = false\n drainQueue()\n reject(err instanceof Error ? err : new Error(String(err)))\n return\n }\n\n pending.set(id, {\n id,\n resolve: () => {\n running = false\n drainQueue()\n resolve()\n },\n reject: (err) => {\n running = false\n drainQueue()\n reject(err)\n },\n onProgress: config.onProgress,\n })\n\n const msg: WorkerMessage = {\n type: 'index',\n id,\n documents,\n dbPath: config.dbPath,\n }\n\n w.postMessage(msg)\n }\n\n if (running) {\n queue.push(run)\n }\n else {\n run()\n }\n })\n}\n\nexport async function shutdownWorker(): Promise<void> {\n if (!worker)\n return\n\n const w = worker\n worker = null\n\n return new Promise<void>((resolve) => {\n const timeout = setTimeout(() => {\n w.terminate().then(() => resolve(), () => resolve())\n }, 5000)\n\n w.once('exit', () => {\n clearTimeout(timeout)\n resolve()\n })\n\n w.postMessage({ type: 'shutdown' } satisfies WorkerMessage)\n })\n}\n"],"mappings":";;;;AAcA,IAAI,SAAwB;AAC5B,IAAI,SAAS;AACb,MAAM,0BAAU,IAAI,KAA0B;AAC9C,MAAM,QAA2B,EAAE;AACnC,IAAI,UAAU;AAEd,SAAS,oBAA2D;CAClE,MAAM,MAAM,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAGnD,MAAK,MAAM,aAAa,CAAC,KAAK,KAAK,aAAa,EAAE,KAAK,KAAK,MAAM,UAAU,aAAa,CAAC,CACxF,KAAI,WAAW,UAAU,CACvB,QAAO,EAAE,MAAM,WAAW;AAI9B,QAAO;EAAE,MAAM,KAAK,KAAK,YAAY;EAAE,UAAU,CAAC,6BAAA;EAA+B;;AAGnF,SAAS,eAAuB;AAC9B,KAAI,OACF,QAAO;CAET,MAAM,SAAS,mBAAmB;CAClC,MAAM,IAAI,IAAI,OAAO,OAAO,MAAM,EAChC,UAAU,OAAO,UAClB,CAAC;AAEF,GAAE,GAAG,YAAY,QAAwB;EACvC,MAAM,OAAO,QAAQ,IAAI,IAAI,GAAG;AAChC,MAAI,CAAC,KACH;AAEF,MAAI,IAAI,SAAS,WACf,MAAK,aAAa;GAAE,OAAO,IAAI;GAAc,SAAS,IAAI;GAAS,OAAO,IAAI;GAAO,CAAC;WAE/E,IAAI,SAAS,QAAQ;AAC5B,WAAQ,OAAO,IAAI,GAAG;AACtB,QAAK,SAAS;aAEP,IAAI,SAAS,SAAS;AAC7B,WAAQ,OAAO,IAAI,GAAG;AACtB,QAAK,OAAO,IAAI,MAAM,IAAI,QAAQ,CAAC;;GAErC;AAEF,GAAE,GAAG,UAAU,QAAe;AAC5B,OAAK,MAAM,QAAQ,QAAQ,QAAQ,CACjC,MAAK,OAAO,IAAI;AAClB,U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