@vpxa/aikit 0.1.378 → 0.1.380
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/package.json +1 -1
- package/packages/claude-desktop/dist/manifest.json +1 -1
- package/packages/cli/dist/index.js +3 -3
- package/packages/cli/dist/{init-gDbVIWiP.js → init-BTsNYC02.js} +1 -1
- package/packages/cli/dist/{templates-BPC4t5yz.js → templates-CRs_gkfS.js} +13 -12
- package/packages/core/dist/index.d.ts +30 -10
- package/packages/core/dist/index.js +1 -1
- package/packages/server/dist/bin.js +1 -1
- package/packages/server/dist/config-Bz8Uyzuq.js +2 -0
- package/packages/server/dist/config-DZskEKrY.js +1 -0
- package/packages/server/dist/dashboard-static-NghHzTNh.js +1 -0
- package/packages/server/dist/dashboard-static-gAOiHHqI.js +2 -0
- package/packages/server/dist/index.js +1 -1
- package/packages/server/dist/register-tools-Dgu64Px5.js +3034 -0
- package/packages/server/dist/register-tools-jgdif5r4.js +3035 -0
- package/packages/server/dist/server-BmVdf84Q.js +26 -0
- package/packages/server/dist/server-C43D7SrT.js +27 -0
- package/packages/server/dist/server-http-BCpGwi0k.js +1 -0
- package/packages/server/dist/server-http-YQ9jxThI.js +2 -0
- package/packages/server/dist/server-stdio-3hhuJU8B.js +2 -0
- package/packages/server/dist/server-stdio-CuLAgQjc.js +1 -0
- package/packages/server/dist/settings-static-DcTUiqr7.js +1 -0
- package/packages/server/dist/settings-static-PjpMR9Q7.js +2 -0
- package/packages/server/dist/startup-maintenance-B4xWqEjc.js +20 -0
- package/packages/server/dist/startup-maintenance-BnTozHs1.js +21 -0
- package/packages/tools/dist/index.d.ts +135 -203
- package/packages/tools/dist/index.js +129 -120
- package/scaffold/dist/adapters/_shared.mjs +12 -11
- package/scaffold/dist/adapters/claude-code.mjs +7 -7
- package/scaffold/dist/adapters/copilot.mjs +12 -12
- package/scaffold/dist/adapters/hermes.mjs +1 -1
- package/scaffold/dist/definitions/bodies.mjs +1 -1
- package/scaffold/dist/definitions/protocols.mjs +1 -1
- package/scaffold/dist/definitions/skills/present.mjs +8 -5
- package/scaffold/dist/definitions/tools.mjs +1 -1
- package/scaffold/general/hooks/scripts/__tests__/bash-guard.test.mjs +214 -0
- package/scaffold/general/hooks/scripts/__tests__/read-size-guard.test.mjs +183 -0
- package/scaffold/general/hooks/scripts/bash-guard.mjs +6 -0
- package/packages/server/dist/config-B4klhHVp.js +0 -2
- package/packages/server/dist/config-D3rRPB9X.js +0 -1
- package/packages/server/dist/dashboard-static-Dw7Nsq4f.js +0 -1
- package/packages/server/dist/dashboard-static-dPnij4uF.js +0 -2
- package/packages/server/dist/evolution-BX_zTSdj.js +0 -2
- package/packages/server/dist/evolution-DWaEE6XW.js +0 -3
- package/packages/server/dist/prelude-C4z3H1li.js +0 -1
- package/packages/server/dist/prelude-WsqQzR-u.js +0 -2
- package/packages/server/dist/promotion-DRnRfteq.js +0 -3
- package/packages/server/dist/promotion-DzVLWVtx.js +0 -2
- package/packages/server/dist/repair-json-B6Q_HRoP.js +0 -3
- package/packages/server/dist/repair-json-D4mft_HA.js +0 -4
- package/packages/server/dist/resolve-sibling-BmZ7AxaA.js +0 -1
- package/packages/server/dist/resolve-sibling-DrGKPpb0.js +0 -2
- package/packages/server/dist/rolldown-runtime-yuFVEuWy.js +0 -2
- package/packages/server/dist/sampling-Bpwc-4Jr.js +0 -2
- package/packages/server/dist/sampling-CfLD3fM_.js +0 -1
- package/packages/server/dist/server-D2a5Rjgk.js +0 -3084
- package/packages/server/dist/server-http-B841uX1k.js +0 -2
- package/packages/server/dist/server-http-tZxvg5ke.js +0 -1
- package/packages/server/dist/server-jZ_r6xLb.js +0 -3083
- package/packages/server/dist/server-stdio-B22xZT0d.js +0 -2
- package/packages/server/dist/server-stdio-DpGfc6DI.js +0 -1
- package/packages/server/dist/settings-static-BpQgaMRs.js +0 -1
- package/packages/server/dist/settings-static-MepJZjer.js +0 -2
- package/packages/server/dist/startup-maintenance-BPrX5-1U.js +0 -2
- package/packages/server/dist/startup-maintenance-CT6Z3734.js +0 -1
- package/packages/server/dist/supersession-CWEne3av.js +0 -2
- package/packages/server/dist/supersession-DO_ZROFl.js +0 -3
- package/packages/server/dist/version-check-C7xqQr9o.js +0 -1
- package/packages/server/dist/version-check-CH5SIhnq.js +0 -2
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Contract tests for read-size-guard.mjs (PreToolUse guard).
|
|
4
|
+
*
|
|
5
|
+
* Replicates the core logic (countLines + handler flow) to test
|
|
6
|
+
* decision boundary behavior without importing the un-exported handler.
|
|
7
|
+
*
|
|
8
|
+
* Creates temp files to exercise the fs-based line counting. Cleans up
|
|
9
|
+
* after each test file is created by the test itself (via after).
|
|
10
|
+
*
|
|
11
|
+
* @category test
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import assert from 'node:assert/strict';
|
|
15
|
+
import fs from 'node:fs';
|
|
16
|
+
import os from 'node:os';
|
|
17
|
+
import path from 'node:path';
|
|
18
|
+
import { after, describe, it } from 'node:test';
|
|
19
|
+
|
|
20
|
+
// ─── Exact replicas of read-size-guard.mjs constants & helpers ─────────────
|
|
21
|
+
|
|
22
|
+
const READ_TOOLS = new Set(['Read', 'read_file', 'readFile']);
|
|
23
|
+
const MAX_LINES = 100;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Counts lines by reading first 64KB. Exact replica of countLines
|
|
27
|
+
* from read-size-guard.mjs.
|
|
28
|
+
*/
|
|
29
|
+
function countLines(filePath) {
|
|
30
|
+
try {
|
|
31
|
+
const fd = fs.openSync(filePath, 'r');
|
|
32
|
+
try {
|
|
33
|
+
const buf = Buffer.alloc(65536);
|
|
34
|
+
const bytesRead = fs.readSync(fd, buf, 0, buf.length, 0);
|
|
35
|
+
if (bytesRead === 0) return 0;
|
|
36
|
+
const firstChunk = buf.toString('utf-8', 0, bytesRead);
|
|
37
|
+
const lines = firstChunk.split('\n').length;
|
|
38
|
+
if (bytesRead < buf.length) return lines;
|
|
39
|
+
// File >64KB — likely over MAX_LINES
|
|
40
|
+
return MAX_LINES + 1;
|
|
41
|
+
} finally {
|
|
42
|
+
fs.closeSync(fd);
|
|
43
|
+
}
|
|
44
|
+
} catch {
|
|
45
|
+
return 0;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Replica of the handler's core decision logic from read-size-guard.mjs.
|
|
51
|
+
* Returns true if the Read call would be denied.
|
|
52
|
+
*/
|
|
53
|
+
function isDenied(toolName, filePaths) {
|
|
54
|
+
if (!READ_TOOLS.has(toolName)) return false;
|
|
55
|
+
for (const filePath of filePaths) {
|
|
56
|
+
if (!filePath) continue;
|
|
57
|
+
const lineCount = countLines(filePath);
|
|
58
|
+
if (lineCount > MAX_LINES) return true;
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// ─── Test helpers ──────────────────────────────────────────────────────────
|
|
64
|
+
|
|
65
|
+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'read-size-guard-test-'));
|
|
66
|
+
|
|
67
|
+
/** Write a file with N lines (each line is "line N\\n"). */
|
|
68
|
+
function writeLines(fileName, lineCount) {
|
|
69
|
+
const filePath = path.join(tmpDir, fileName);
|
|
70
|
+
const lines = [];
|
|
71
|
+
for (let i = 1; i <= lineCount; i++) {
|
|
72
|
+
lines.push(`line ${i}`);
|
|
73
|
+
}
|
|
74
|
+
fs.writeFileSync(filePath, `${lines.join('\n')}\n`, 'utf-8');
|
|
75
|
+
return filePath;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Clean up temp files after all tests
|
|
79
|
+
after(() => {
|
|
80
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// ─── Tests ─────────────────────────────────────────────────────────────────
|
|
84
|
+
|
|
85
|
+
describe('read-size-guard — countLines', () => {
|
|
86
|
+
it('counts lines in a small file (trailing newline adds +1)', () => {
|
|
87
|
+
const fp = writeLines('small.txt', 5);
|
|
88
|
+
// split(\n) on "line 1\n...line 5\n" → 6 entries (trailing '' after last \n)
|
|
89
|
+
assert.equal(countLines(fp), 6);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('counts lines in a file at threshold boundary (100 lines)', () => {
|
|
93
|
+
const fp = writeLines('threshold.txt', 100);
|
|
94
|
+
// 100 lines with trailing newline → split(\n) gives 101 entries
|
|
95
|
+
assert.equal(countLines(fp), 101);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('returns MAX_LINES+1 for files >64KB', () => {
|
|
99
|
+
// 650 lines × ~110 chars each ≈ ~71KB > 64KB buffer
|
|
100
|
+
const longLine = 'x'.repeat(100);
|
|
101
|
+
const lines = Array.from({ length: 650 }, (_, i) => `${i}:${longLine}`);
|
|
102
|
+
const fp = path.join(tmpDir, 'large.txt');
|
|
103
|
+
fs.writeFileSync(fp, `${lines.join('\n')}\n`, 'utf-8');
|
|
104
|
+
// Buffer exhausted → returns MAX_LINES + 1
|
|
105
|
+
assert.equal(countLines(fp), MAX_LINES + 1);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('returns 0 for empty file', () => {
|
|
109
|
+
const fp = path.join(tmpDir, 'empty.txt');
|
|
110
|
+
fs.writeFileSync(fp, '', 'utf-8');
|
|
111
|
+
assert.equal(countLines(fp), 0);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('returns 0 for missing file (graceful fallback)', () => {
|
|
115
|
+
assert.equal(countLines('/nonexistent/path/file.ts'), 0);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
describe('read-size-guard — deny/allow decisions', () => {
|
|
120
|
+
it('allows Read on small files', () => {
|
|
121
|
+
const fp = writeLines('allow-small.txt', 10);
|
|
122
|
+
assert.ok(!isDenied('Read', [fp]));
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('denies Read on large files (>100 lines)', () => {
|
|
126
|
+
const fp = writeLines('deny-large.txt', 150);
|
|
127
|
+
assert.ok(isDenied('Read', [fp]));
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('allows file at exactly 100 lines (not > 100)', () => {
|
|
131
|
+
// 100 lines + trailing newline → countLines returns 101
|
|
132
|
+
// 101 > 100 → denied
|
|
133
|
+
// So at 99 lines, countLines returns 99 or 100 depending on trailing newline
|
|
134
|
+
const fp = writeLines('edge-99.txt', 99);
|
|
135
|
+
// 99 lines + trailing newline = 100 entries from split
|
|
136
|
+
assert.equal(countLines(fp), 100);
|
|
137
|
+
assert.ok(!isDenied('Read', [fp]));
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('allows non-Read tools regardless of file size', () => {
|
|
141
|
+
const fp = writeLines('non-read.txt', 500);
|
|
142
|
+
assert.ok(!isDenied('Edit', [fp]));
|
|
143
|
+
assert.ok(!isDenied('Glob', [fp]));
|
|
144
|
+
assert.ok(!isDenied('Bash', [fp]));
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('allows Read on missing files (countLines returns 0)', () => {
|
|
148
|
+
assert.ok(!isDenied('Read', ['/nonexistent/missing.ts']));
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('allows Read on empty filePaths array', () => {
|
|
152
|
+
assert.ok(!isDenied('Read', []));
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('skips null/undefined entries in filePaths', () => {
|
|
156
|
+
const existing = writeLines('skip-null.txt', 5);
|
|
157
|
+
assert.ok(!isDenied('Read', [null, undefined, '', existing]));
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('denies Read when any file in paths exceeds threshold', () => {
|
|
161
|
+
const small = writeLines('multi-small.txt', 3);
|
|
162
|
+
const big = writeLines('multi-big.txt', 200);
|
|
163
|
+
assert.ok(isDenied('Read', [small, big]));
|
|
164
|
+
// Order doesn't matter
|
|
165
|
+
assert.ok(isDenied('Read', [big, small]));
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
describe('read-size-guard — tool name variants', () => {
|
|
170
|
+
it('handles Read tool name variants', () => {
|
|
171
|
+
const fp = writeLines('tool-variant.txt', 200);
|
|
172
|
+
assert.ok(isDenied('Read', [fp]));
|
|
173
|
+
assert.ok(isDenied('read_file', [fp]));
|
|
174
|
+
assert.ok(isDenied('readFile', [fp]));
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('allows tools that sound similar but are not Read', () => {
|
|
178
|
+
const fp = writeLines('similar.txt', 200);
|
|
179
|
+
assert.ok(!isDenied('read', [fp]));
|
|
180
|
+
assert.ok(!isDenied('ReadFile', [fp]));
|
|
181
|
+
assert.ok(!isDenied('ReadAll', [fp]));
|
|
182
|
+
});
|
|
183
|
+
});
|
|
@@ -45,6 +45,12 @@ const REDIRECT_PATTERNS = [
|
|
|
45
45
|
tool: 'mcp__aikit__find({ glob }) or mcp__aikit__search',
|
|
46
46
|
reason: 'dir for exploration',
|
|
47
47
|
},
|
|
48
|
+
// Chained commands — catches `cd /tmp; grep` , `cd /tmp && grep` bypasses
|
|
49
|
+
{
|
|
50
|
+
re: /[;&|]{1,2}\s*(grep|find|cat|ls|rg|dir)\s/m,
|
|
51
|
+
tool: 'mcp__aikit__search or mcp__aikit__find',
|
|
52
|
+
reason: 'chained grep/find/cat/ls/rg/dir — use mcp tool instead',
|
|
53
|
+
},
|
|
48
54
|
];
|
|
49
55
|
|
|
50
56
|
/** Check if the command starts with a blocked pattern. */
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{o as e,t}from"./supersession-DO_ZROFl.js";import{fileURLToPath as n}from"node:url";import{AIKIT_RUNTIME_PATHS as r,DEFAULT_SERVER_NAME as i,EMBEDDING_DEFAULTS as a,computePartitionKey as o,createLogger as s,getPartitionDir as c,migrateLegacyWorkspaceLayout as l,safeCwd as u,serializeError as d}from"../../core/dist/index.js";import{existsSync as f,mkdirSync as p,readFileSync as m,writeFileSync as h}from"node:fs";import{dirname as g,isAbsolute as _,relative as v,resolve as y}from"node:path";import{homedir as b}from"node:os";const x={workingToEpisodicAccesses:2,episodicToSemanticReferences:3,semanticToProceduralVerifications:5},S={working:1,episodic:2,semantic:4,procedural:12};function C(e,t=x){switch(e.tier){case`working`:if(e.accessCount>=t.workingToEpisodicAccesses)return`episodic`;break;case`episodic`:if(e.accessCount>=t.workingToEpisodicAccesses+t.episodicToSemanticReferences)return`semantic`;break;case`semantic`:if(e.accessCount>=t.workingToEpisodicAccesses+t.episodicToSemanticReferences+t.semanticToProceduralVerifications)return`procedural`;break;case`procedural`:break;default:break}}function w(e,t,n){e.memoryMetaUpdateTier(t,n)}const T={stabilityHours:168,accessMultiplier:1.5,flagThreshold:.1,maxStabilityHours:8760};function E(e){return{...T,...e}}function D(e,t){if(!e)return t;let n=Date.parse(e);return Number.isNaN(n)?t:n}function O(e){return e&&e in S?e:`working`}function k(e,t,n,r=T,i){let a=typeof r==`string`?O(r):`working`,o=E(typeof r==`string`?i:r),s=D(e,D(n,Date.now())),c=Math.max(0,Date.now()-s)/(1e3*60*60),l=Math.min(o.stabilityHours*S[a]*o.accessMultiplier**Math.max(0,t),o.maxStabilityHours);return Math.exp(-c/l)}function A(e,t,n){let r=e.memoryMetaGet(t);if(!r)return;let i=k(r.lastAccessedAt,r.accessCount,r.createdAt,r.tier,n);return r.retentionScore!==i&&e.memoryMetaUpdateScore(t,i),e.memoryMetaGet(t)??{...r,retentionScore:i}}function j(e,t,n){e.memoryMetaGet(t)||e.memoryMetaCreate(t),e.memoryMetaTouch(t);let r=e.memoryMetaGet(t);if(!r)return 1;let i=k(r.lastAccessedAt,r.accessCount,r.createdAt,r.tier,n);return e.memoryMetaUpdateScore(t,i),i}function M(e,t){let n=E(t);return e.memoryMetaList().map(t=>A(e,t.entryId,n)??t).filter(e=>e.retentionScore<n.flagThreshold).sort((e,t)=>e.retentionScore-t.retentionScore)}const N=g(n(import.meta.url)),P=s(`server`),F=[`auto`,`manual`,`smart`],I={model:a.model,dimensions:a.dimensions,childProcess:!0,idleTimeoutMs:3e5};function L(e){return typeof e==`string`&&F.includes(e)}function R(e,t,n){let r=y(e),i=v(y(t),r);if(i.startsWith(`..`)||_(i))throw Error(`Config ${n} path escapes allowed root: ${e} is not under ${t}`);return r}function z(e,t){let n=y(e),r=v(y(t),n);return!(r.startsWith(`..`)||_(r))}function B(e){return c(o(e))}function V(e,t,n,r,i){let a=r?y(t,r):t;if(!n)return R(a,t,i);let o=y(e,n);return z(o,t)?r&&y(o)===y(t)?R(a,t,i):R(o,t,i):R(a,t,i)}function H(e){let t=[e.store?.path,e.curated?.path,e.onboardDir,e.stateDir,e.l0CardDir];for(let e of t)e&&p(e,{recursive:!0})}function U(e,t){l(t);let n=B(t);e.store={...e.store,path:V(t,n,e.store?.path,r.data,`store`)},e.curated={...e.curated,path:V(t,n,e.curated?.path,r.curated,`curated`)},e.onboardDir=V(t,n,e.onboardDir,r.onboard,`onboard`),e.stateDir=V(t,n,e.stateDir,r.state,`state`),e.l0CardDir=V(t,n,e.l0CardDir,r.l0Cards,`l0CardDir`)}function W(e){let t=process.env.AIKIT_INDEX_MODE;if(L(t))return t;if(e.indexMode)return e.indexMode;let n=process.env.AIKIT_AUTO_INDEX;return n===void 0?e.autoIndex===void 0?`smart`:e.autoIndex?`auto`:`manual`:n===`true`?`auto`:`manual`}function G(){let n=u(),r=process.env.AIKIT_CONFIG_PATH??(n&&f(y(n,`aikit.config.json`))?y(n,`aikit.config.json`):y(N,`..`,`..`,`..`,`aikit.config.json`));try{if(!f(r))return P.info(`No config file found, using defaults`,{configPath:r}),q();let n=m(r,`utf-8`),i=JSON.parse(n),a={...I,...i.embedding};if(i.embedding=a,i.memory={retention:{...T,...i.memory?.retention},lessons:{...e,...i.memory?.lessons},consolidation:{...x,...i.memory?.consolidation},supersession:{...t,...i.memory?.supersession}},i.logging?.errorDetails!==void 0&&typeof i.logging.errorDetails!=`boolean`)throw Error(`Config logging.errorDetails must be a boolean`);if(i.logging={errorDetails:i.logging?.errorDetails===!0},!i.sources||!Array.isArray(i.sources)||i.sources.length===0)throw Error(`Config must have at least one source`);if(!i.store?.path)throw Error(`Config must specify store.path`);if(i.autoIndex!==void 0&&typeof i.autoIndex!=`boolean`)throw Error(`Config autoIndex must be a boolean`);if(i.indexMode!==void 0&&!L(i.indexMode))throw Error(`Config indexMode must be one of: ${F.join(`, `)}`);if(typeof a.model!=`string`||a.model.trim()===``)throw Error(`Config embedding.model must be a non-empty string`);if(a.nativeDim!==void 0&&(!Number.isInteger(a.nativeDim)||a.nativeDim<=0))throw Error(`Config embedding.nativeDim must be a positive integer`);if(a.dimensions!==void 0&&(!Number.isInteger(a.dimensions)||a.dimensions<=0))throw Error(`Config embedding.dimensions must be a positive integer`);if(a.dimensions!==void 0&&a.nativeDim!==void 0&&a.dimensions>a.nativeDim)throw Error(`Config embedding.dimensions must not exceed embedding.nativeDim`);if(a.queryPrefix!==void 0&&typeof a.queryPrefix!=`string`)throw Error(`Config embedding.queryPrefix must be a string`);let o=g(r);return i.sources=i.sources.map(e=>({...e,path:R(y(o,e.path),o,`source`)})),J(i,r),U(i,o),i.layeredKnowledge===void 0&&(i.layeredKnowledge=process.env.AIKIT_LAYERED_KNOWLEDGE===`true`),i.indexMode=W(i),i}catch(e){let t=`Failed to load config from ${r}. ${e instanceof Error?e.message:String(e)}`;console.error(`\n ⚠ CONFIG ERROR — ${t}\n Check that the file exists, is valid JSON, and all required fields are present.\n`),P.error(`Failed to load config`,{configPath:r,...d(e)}),P.warn(`Falling back to default configuration`,{configPath:r});let n=q();return n.configError=t,n}}const K=[`.git/**`,`**/node_modules/**`,`*.lock`,`pnpm-lock.yaml`,`package-lock.json`,`**/dist/**`,`**/build/**`,`**/out/**`,`**/.output/**`,`**/cdk.out/**`,`**/.next/**`,`**/.nuxt/**`,`**/.vercel/**`,`**/.serverless/**`,`**/.turbo/**`,`**/.cache/**`,`**/.parcel-cache/**`,`**/coverage/**`,`**/.terraform/**`,`**/__pycache__/**`,`**/.venv/**`,`**/.docusaurus/**`,`**/.temp/**`,`**/tmp/**`];function q(){let n=process.env.AIKIT_WORKSPACE_ROOT??u()??b(),a=B(n),o={sources:[{path:n,excludePatterns:[...K]}],serverName:i,indexing:{chunkSize:800,chunkOverlap:150,minChunkSize:100},embedding:{...I},store:{backend:`sqlite-vec`,path:y(a,r.data)},curated:{path:y(a,r.curated)},memory:{retention:{...T},lessons:{...e},consolidation:{...x},supersession:{...t}},logging:{errorDetails:!1},onboardDir:y(a,r.onboard),stateDir:y(a,r.state)};return o.indexMode=W(o),o}function J(e,t){let n=e.configVersion??0;if(n>=1)return e;if(n<1)for(let t of e.sources){t.excludePatterns=t.excludePatterns??[];let e=new Set(t.excludePatterns);for(let n of K)e.has(n)||t.excludePatterns.push(n)}e.configVersion=1;try{h(t,`${JSON.stringify(e,null,2)}\n`,`utf-8`),P.info(`Config auto-upgraded`,{from:n,to:1,configPath:t})}catch(e){P.warn(`Failed to write upgraded config`,{configPath:t,...d(e)})}return e}function Y(e,t){if(!f(t))throw Error(`Workspace root does not exist: ${t}`);l(t),P.debug(`Reconfiguring for workspace root`,{workspaceRoot:t});try{process.chdir(t),P.debug(`Changed process cwd to workspace root`,{cwd:process.cwd()})}catch(e){P.warn(`Failed to chdir to workspace root`,{workspaceRoot:t,...d(e)})}e.sources=[{path:t,excludePatterns:e.sources[0]?.excludePatterns??[`node_modules/**`,`dist/**`,`.git/**`,`coverage/**`,`*.lock`,`pnpm-lock.yaml`]}],U(e,t),H(e)}export{K as DEFAULT_EXCLUDE_PATTERNS,C as a,x as i,G as loadConfig,A as n,w as o,j as r,Y as reconfigureForWorkspace,W as resolveIndexMode,M as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e,t}from"./supersession-CWEne3av.js";import{fileURLToPath as n}from"node:url";import{AIKIT_RUNTIME_PATHS as r,DEFAULT_SERVER_NAME as i,EMBEDDING_DEFAULTS as a,computePartitionKey as o,createLogger as s,getPartitionDir as c,migrateLegacyWorkspaceLayout as l,safeCwd as u,serializeError as d}from"../../core/dist/index.js";import{existsSync as f,mkdirSync as p,readFileSync as m,writeFileSync as h}from"node:fs";import{dirname as g,isAbsolute as _,relative as v,resolve as y}from"node:path";import{homedir as b}from"node:os";const x={workingToEpisodicAccesses:2,episodicToSemanticReferences:3,semanticToProceduralVerifications:5},S={working:1,episodic:2,semantic:4,procedural:12};function C(e,t=x){switch(e.tier){case`working`:if(e.accessCount>=t.workingToEpisodicAccesses)return`episodic`;break;case`episodic`:if(e.accessCount>=t.workingToEpisodicAccesses+t.episodicToSemanticReferences)return`semantic`;break;case`semantic`:if(e.accessCount>=t.workingToEpisodicAccesses+t.episodicToSemanticReferences+t.semanticToProceduralVerifications)return`procedural`;break;case`procedural`:break;default:break}}function w(e,t,n){e.memoryMetaUpdateTier(t,n)}const T={stabilityHours:168,accessMultiplier:1.5,flagThreshold:.1,maxStabilityHours:8760};function E(e){return{...T,...e}}function D(e,t){if(!e)return t;let n=Date.parse(e);return Number.isNaN(n)?t:n}function O(e){return e&&e in S?e:`working`}function k(e,t,n,r=T,i){let a=typeof r==`string`?O(r):`working`,o=E(typeof r==`string`?i:r),s=D(e,D(n,Date.now())),c=Math.max(0,Date.now()-s)/(1e3*60*60),l=Math.min(o.stabilityHours*S[a]*o.accessMultiplier**Math.max(0,t),o.maxStabilityHours);return Math.exp(-c/l)}function A(e,t,n){let r=e.memoryMetaGet(t);if(!r)return;let i=k(r.lastAccessedAt,r.accessCount,r.createdAt,r.tier,n);return r.retentionScore!==i&&e.memoryMetaUpdateScore(t,i),e.memoryMetaGet(t)??{...r,retentionScore:i}}function j(e,t,n){e.memoryMetaGet(t)||e.memoryMetaCreate(t),e.memoryMetaTouch(t);let r=e.memoryMetaGet(t);if(!r)return 1;let i=k(r.lastAccessedAt,r.accessCount,r.createdAt,r.tier,n);return e.memoryMetaUpdateScore(t,i),i}function M(e,t){let n=E(t);return e.memoryMetaList().map(t=>A(e,t.entryId,n)??t).filter(e=>e.retentionScore<n.flagThreshold).sort((e,t)=>e.retentionScore-t.retentionScore)}const N=g(n(import.meta.url)),P=s(`server`),F=[`auto`,`manual`,`smart`],I={model:a.model,dimensions:a.dimensions,childProcess:!0,idleTimeoutMs:3e5};function L(e){return typeof e==`string`&&F.includes(e)}function R(e,t,n){let r=y(e),i=v(y(t),r);if(i.startsWith(`..`)||_(i))throw Error(`Config ${n} path escapes allowed root: ${e} is not under ${t}`);return r}function z(e,t){let n=y(e),r=v(y(t),n);return!(r.startsWith(`..`)||_(r))}function B(e){return c(o(e))}function V(e,t,n,r,i){let a=r?y(t,r):t;if(!n)return R(a,t,i);let o=y(e,n);return z(o,t)?r&&y(o)===y(t)?R(a,t,i):R(o,t,i):R(a,t,i)}function H(e){let t=[e.store?.path,e.curated?.path,e.onboardDir,e.stateDir,e.l0CardDir];for(let e of t)e&&p(e,{recursive:!0})}function U(e,t){l(t);let n=B(t);e.store={...e.store,path:V(t,n,e.store?.path,r.data,`store`)},e.curated={...e.curated,path:V(t,n,e.curated?.path,r.curated,`curated`)},e.onboardDir=V(t,n,e.onboardDir,r.onboard,`onboard`),e.stateDir=V(t,n,e.stateDir,r.state,`state`),e.l0CardDir=V(t,n,e.l0CardDir,r.l0Cards,`l0CardDir`)}function W(e){let t=process.env.AIKIT_INDEX_MODE;if(L(t))return t;if(e.indexMode)return e.indexMode;let n=process.env.AIKIT_AUTO_INDEX;return n===void 0?e.autoIndex===void 0?`smart`:e.autoIndex?`auto`:`manual`:n===`true`?`auto`:`manual`}function G(){let n=u(),r=process.env.AIKIT_CONFIG_PATH??(n&&f(y(n,`aikit.config.json`))?y(n,`aikit.config.json`):y(N,`..`,`..`,`..`,`aikit.config.json`));try{if(!f(r))return P.info(`No config file found, using defaults`,{configPath:r}),q();let n=m(r,`utf-8`),i=JSON.parse(n),a={...I,...i.embedding};if(i.embedding=a,i.memory={retention:{...T,...i.memory?.retention},lessons:{...e,...i.memory?.lessons},consolidation:{...x,...i.memory?.consolidation},supersession:{...t,...i.memory?.supersession}},i.logging?.errorDetails!==void 0&&typeof i.logging.errorDetails!=`boolean`)throw Error(`Config logging.errorDetails must be a boolean`);if(i.logging={errorDetails:i.logging?.errorDetails===!0},!i.sources||!Array.isArray(i.sources)||i.sources.length===0)throw Error(`Config must have at least one source`);if(!i.store?.path)throw Error(`Config must specify store.path`);if(i.autoIndex!==void 0&&typeof i.autoIndex!=`boolean`)throw Error(`Config autoIndex must be a boolean`);if(i.indexMode!==void 0&&!L(i.indexMode))throw Error(`Config indexMode must be one of: ${F.join(`, `)}`);if(typeof a.model!=`string`||a.model.trim()===``)throw Error(`Config embedding.model must be a non-empty string`);if(a.nativeDim!==void 0&&(!Number.isInteger(a.nativeDim)||a.nativeDim<=0))throw Error(`Config embedding.nativeDim must be a positive integer`);if(a.dimensions!==void 0&&(!Number.isInteger(a.dimensions)||a.dimensions<=0))throw Error(`Config embedding.dimensions must be a positive integer`);if(a.dimensions!==void 0&&a.nativeDim!==void 0&&a.dimensions>a.nativeDim)throw Error(`Config embedding.dimensions must not exceed embedding.nativeDim`);if(a.queryPrefix!==void 0&&typeof a.queryPrefix!=`string`)throw Error(`Config embedding.queryPrefix must be a string`);let o=g(r);return i.sources=i.sources.map(e=>({...e,path:R(y(o,e.path),o,`source`)})),J(i,r),U(i,o),i.layeredKnowledge===void 0&&(i.layeredKnowledge=process.env.AIKIT_LAYERED_KNOWLEDGE===`true`),i.indexMode=W(i),i}catch(e){let t=`Failed to load config from ${r}. ${e instanceof Error?e.message:String(e)}`;console.error(`\n ⚠ CONFIG ERROR — ${t}\n Check that the file exists, is valid JSON, and all required fields are present.\n`),P.error(`Failed to load config`,{configPath:r,...d(e)}),P.warn(`Falling back to default configuration`,{configPath:r});let n=q();return n.configError=t,n}}const K=[`.git/**`,`**/node_modules/**`,`*.lock`,`pnpm-lock.yaml`,`package-lock.json`,`**/dist/**`,`**/build/**`,`**/out/**`,`**/.output/**`,`**/cdk.out/**`,`**/.next/**`,`**/.nuxt/**`,`**/.vercel/**`,`**/.serverless/**`,`**/.turbo/**`,`**/.cache/**`,`**/.parcel-cache/**`,`**/coverage/**`,`**/.terraform/**`,`**/__pycache__/**`,`**/.venv/**`,`**/.docusaurus/**`,`**/.temp/**`,`**/tmp/**`];function q(){let n=process.env.AIKIT_WORKSPACE_ROOT??u()??b(),a=B(n),o={sources:[{path:n,excludePatterns:[...K]}],serverName:i,indexing:{chunkSize:800,chunkOverlap:150,minChunkSize:100},embedding:{...I},store:{backend:`sqlite-vec`,path:y(a,r.data)},curated:{path:y(a,r.curated)},memory:{retention:{...T},lessons:{...e},consolidation:{...x},supersession:{...t}},logging:{errorDetails:!1},onboardDir:y(a,r.onboard),stateDir:y(a,r.state)};return o.indexMode=W(o),o}function J(e,t){let n=e.configVersion??0;if(n>=1)return e;if(n<1)for(let t of e.sources){t.excludePatterns=t.excludePatterns??[];let e=new Set(t.excludePatterns);for(let n of K)e.has(n)||t.excludePatterns.push(n)}e.configVersion=1;try{h(t,`${JSON.stringify(e,null,2)}\n`,`utf-8`),P.info(`Config auto-upgraded`,{from:n,to:1,configPath:t})}catch(e){P.warn(`Failed to write upgraded config`,{configPath:t,...d(e)})}return e}function Y(e,t){if(!f(t))throw Error(`Workspace root does not exist: ${t}`);l(t),P.debug(`Reconfiguring for workspace root`,{workspaceRoot:t});try{process.chdir(t),P.debug(`Changed process cwd to workspace root`,{cwd:process.cwd()})}catch(e){P.warn(`Failed to chdir to workspace root`,{workspaceRoot:t,...d(e)})}e.sources=[{path:t,excludePatterns:e.sources[0]?.excludePatterns??[`node_modules/**`,`dist/**`,`.git/**`,`coverage/**`,`*.lock`,`pnpm-lock.yaml`]}],U(e,t),H(e)}export{K as DEFAULT_EXCLUDE_PATTERNS,C as a,x as i,G as loadConfig,A as n,w as o,j as r,Y as reconfigureForWorkspace,W as resolveIndexMode,M as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./resolve-sibling-BmZ7AxaA.js";import{fileURLToPath as t}from"node:url";import{createReadStream as n,existsSync as r,statSync as i}from"node:fs";import{dirname as a,extname as o,join as s,resolve as c,sep as l}from"node:path";const u=import.meta.dirname??a(t(import.meta.url)),d={".html":`text/html`,".js":`application/javascript`,".css":`text/css`,".json":`application/json`,".png":`image/png`,".svg":`image/svg+xml`,".ico":`image/x-icon`,".woff":`font/woff`,".woff2":`font/woff2`};function f(t){return t?s(t,`..`,`..`,`dashboard`,`dist`):e(`dashboard`)??s(u,`..`,`..`,`dashboard`,`dist`)}function p(e,t){let n=t.replace(/^\/_dashboard\/?/,``)||`index.html`;try{n=decodeURIComponent(n)}catch{}let a=c(e,n);if(!(a===e||a.startsWith(`${e}${l}`)))return{kind:`forbidden`};try{if(i(a).isFile())return{kind:`file`,path:a,contentType:d[o(a)]??`application/octet-stream`}}catch{}let u=s(e,`index.html`);return r(u)?{kind:`spa`,path:u,contentType:`text/html`}:{kind:`not-found`}}function m(e,t,i){return r(t)?(e.get(`/_dashboard{/*path}`,(e,r)=>{let i=p(t,e.path);if(i.kind===`forbidden`){r.status(403).end(`Forbidden`);return}if(i.kind===`not-found`){r.status(404).end(`Not found`);return}r.setHeader(`Content-Type`,i.contentType),i.kind===`file`&&/\.[a-f0-9]{8,}\.(js|css)$/i.test(i.path)?r.setHeader(`Cache-Control`,`public, max-age=31536000, immutable`):r.setHeader(`Cache-Control`,`no-cache`),n(i.path).pipe(r)}),i.info(`Dashboard available`,{url:`/_dashboard/`,dir:t}),!0):!1}export{m as registerDashboardRoutes,f as resolveDashboardDir,p as resolveDashboardRequest};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{t as e}from"./resolve-sibling-DrGKPpb0.js";import{fileURLToPath as t}from"node:url";import{createReadStream as n,existsSync as r,statSync as i}from"node:fs";import{dirname as a,extname as o,join as s,resolve as c,sep as l}from"node:path";const u=import.meta.dirname??a(t(import.meta.url)),d={".html":`text/html`,".js":`application/javascript`,".css":`text/css`,".json":`application/json`,".png":`image/png`,".svg":`image/svg+xml`,".ico":`image/x-icon`,".woff":`font/woff`,".woff2":`font/woff2`};function f(t){return t?s(t,`..`,`..`,`dashboard`,`dist`):e(`dashboard`)??s(u,`..`,`..`,`dashboard`,`dist`)}function p(e,t){let n=t.replace(/^\/_dashboard\/?/,``)||`index.html`;try{n=decodeURIComponent(n)}catch{}let a=c(e,n);if(!(a===e||a.startsWith(`${e}${l}`)))return{kind:`forbidden`};try{if(i(a).isFile())return{kind:`file`,path:a,contentType:d[o(a)]??`application/octet-stream`}}catch{}let u=s(e,`index.html`);return r(u)?{kind:`spa`,path:u,contentType:`text/html`}:{kind:`not-found`}}function m(e,t,i){return r(t)?(e.get(`/_dashboard{/*path}`,(e,r)=>{let i=p(t,e.path);if(i.kind===`forbidden`){r.status(403).end(`Forbidden`);return}if(i.kind===`not-found`){r.status(404).end(`Not found`);return}r.setHeader(`Content-Type`,i.contentType),i.kind===`file`&&/\.[a-f0-9]{8,}\.(js|css)$/i.test(i.path)?r.setHeader(`Cache-Control`,`public, max-age=31536000, immutable`):r.setHeader(`Cache-Control`,`no-cache`),n(i.path).pipe(r)}),i.info(`Dashboard available`,{url:`/_dashboard/`,dir:t}),!0):!1}export{m as registerDashboardRoutes,f as resolveDashboardDir,p as resolveDashboardRequest};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./rolldown-runtime-DT7IzrpZ.js";import{l as t,o as n,p as r,r as i}from"./supersession-CWEne3av.js";import{join as a}from"node:path";import{readFile as o,writeFile as s}from"node:fs/promises";var c=e({DEFAULT_GROUP_CONFIG:()=>u,DEFAULT_PRUNE_CONFIG:()=>l,groupLessons:()=>w,pruneLessons:()=>C});const l={maxConfidence:15,minIdleDays:30,safetyDays:7,maxPrune:20,dryRun:!0},u={similarityThreshold:.7,minGroupSize:2,maxGroups:10,dryRun:!0},d=new Set([`the`,`a`,`to`,`for`,`in`,`of`,`and`,`is`,`use`]);function f(e){return{maxConfidence:Math.min(100,Math.max(0,Math.trunc(e?.maxConfidence??l.maxConfidence))),minIdleDays:Math.max(1,Math.trunc(e?.minIdleDays??l.minIdleDays)),safetyDays:Math.max(0,Math.trunc(e?.safetyDays??l.safetyDays)),maxPrune:Math.max(1,Math.trunc(e?.maxPrune??l.maxPrune)),dryRun:e?.dryRun??l.dryRun}}function p(e){return{similarityThreshold:Math.min(1,Math.max(0,e?.similarityThreshold??u.similarityThreshold)),minGroupSize:Math.max(2,Math.trunc(e?.minGroupSize??u.minGroupSize)),maxGroups:Math.max(1,Math.trunc(e?.maxGroups??u.maxGroups)),dryRun:e?.dryRun??u.dryRun}}function m(e){if(!e)return 0;let t=Date.parse(e);return Number.isNaN(t)?0:t}function h(e,t){let n=Math.max(m(e),m(t));return n===0?1/0:Math.max(0,Date.now()-n)/864e5}function g(e){return e.toLowerCase().match(/[a-z0-9]{2,}/g)??[]}function _(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,60)}function v(e,t){return`${[`---`,`title: "${e.title.replace(/"/g,`\\"`)}"`,`category: ${e.category}`,`tags: [${e.tags.map(e=>`"${e}"`).join(`, `)}]`,`created: ${e.created}`,`updated: ${e.updated}`,`version: ${e.version}`,`origin: ${e.origin}`,`changelog:`,...e.changelog.map(e=>` - version: ${e.version}\n date: ${e.date}\n reason: "${e.reason.replace(/"/g,`\\"`)}"`),`---`].join(`
|
|
2
|
-
`)}\n\n${t}\n`}function y(e,t){let n=e.map(()=>[]);for(let r=0;r<e.length;r+=1)for(let a=r+1;a<e.length;a+=1)i(e[r],e[a])>=t&&(n[r].push(a),n[a].push(r));return n}function b(e){let t=new Set,n=[];for(let r=0;r<e.length;r+=1){if(t.has(r))continue;let i=[r],a=[];for(t.add(r);i.length>0;){let n=i.pop();if(n!==void 0){a.push(n);for(let r of e[n])t.has(r)||(t.add(r),i.push(r))}}n.push(a)}return n}function x(e){let t=new Map,n=new Map,r=0;for(let i of e)for(let e of g(i))d.has(e)||(t.set(e,(t.get(e)??0)+1),n.has(e)||(n.set(e,r),r+=1));let i=[...t.entries()].sort((e,t)=>t[1]-e[1]||(n.get(e[0])??0)-(n.get(t[0])??0))[0];return i&&i[1]>1?_(i[0]):_(e.flatMap(e=>g(e)).find(e=>!d.has(e))??`lesson-group`)}async function S(e,t,n){let r=a(e.curatedDir,t),i=await o(r,`utf8`),{frontmatter:c,content:l}=e.parseFile(i),u=`group:${n}`;if(c.tags.includes(u))return;let d=new Date().toISOString(),f=(c.version??1)+1;await s(r,v({...c,tags:[...new Set([...c.tags,u])],updated:d,version:f,changelog:[...c.changelog??[],{version:f,date:d,reason:`Grouped lesson under ${n}`}]},l),`utf8`)}async function C(e,i,a,o){let s=f(a),c=r(o??n),l=(await e.list({category:`lessons`})).filter(e=>e.tags.includes(`lesson`)),u=l.map(e=>{let n=i.memoryMetaGet(e.path);if(!n||n.supersededBy!=null)return null;let r=h(n.lastAccessedAt,n.createdAt??e.created);if(r<s.safetyDays)return null;let a=t(n.confidence,n.lastAccessedAt,n.createdAt,c);return a>=s.maxConfidence||r<s.minIdleDays?null:{path:e.path,effectiveConfidence:a}}).filter(e=>e!==null).sort((e,t)=>e.effectiveConfidence-t.effectiveConfidence||e.path.localeCompare(t.path)).slice(0,s.maxPrune);if(!s.dryRun)for(let e of u)i.memoryMetaSetSuperseded(e.path,`lesson:auto-prune`);return{pruned:u.map(e=>e.path),skipped:l.length-u.length,dryRun:s.dryRun}}async function w(e,t,n){let r=p(n),i=(await e.list({category:`lessons`})).filter(e=>{if(!e.tags.includes(`lesson`)||e.tags.some(e=>e.startsWith(`group:`)))return!1;let n=t.memoryMetaGet(e.path);return n?.supersededBy==null||n===void 0});if(i.length<r.minGroupSize)return{groupsCreated:0,lessonsGrouped:0,groups:[],dryRun:r.dryRun};let a=b(y(i.map(e=>e.title),r.similarityThreshold)).filter(e=>e.length>=r.minGroupSize).map(e=>{let t=e.map(e=>i[e]).sort((e,t)=>e.path.localeCompare(t.path));return{label:x(t.map(e=>e.title)),members:t.map(e=>e.path)}}).sort((e,t)=>t.members.length-e.members.length||e.members[0].localeCompare(t.members[0])).slice(0,r.maxGroups);if(!r.dryRun&&a.length>0){for(let t of a)for(let n of t.members)await S(e,n,t.label);await e.reindexAll()}return{groupsCreated:a.length,lessonsGrouped:a.reduce((e,t)=>e+t.members.length,0),groups:a,dryRun:r.dryRun}}export{w as n,C as r,c as t};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{t as e}from"./rolldown-runtime-yuFVEuWy.js";import{l as t,o as n,p as r,r as i}from"./supersession-DO_ZROFl.js";import{join as a}from"node:path";import{readFile as o,writeFile as s}from"node:fs/promises";var c=e({DEFAULT_GROUP_CONFIG:()=>u,DEFAULT_PRUNE_CONFIG:()=>l,groupLessons:()=>w,pruneLessons:()=>C});const l={maxConfidence:15,minIdleDays:30,safetyDays:7,maxPrune:20,dryRun:!0},u={similarityThreshold:.7,minGroupSize:2,maxGroups:10,dryRun:!0},d=new Set([`the`,`a`,`to`,`for`,`in`,`of`,`and`,`is`,`use`]);function f(e){return{maxConfidence:Math.min(100,Math.max(0,Math.trunc(e?.maxConfidence??l.maxConfidence))),minIdleDays:Math.max(1,Math.trunc(e?.minIdleDays??l.minIdleDays)),safetyDays:Math.max(0,Math.trunc(e?.safetyDays??l.safetyDays)),maxPrune:Math.max(1,Math.trunc(e?.maxPrune??l.maxPrune)),dryRun:e?.dryRun??l.dryRun}}function p(e){return{similarityThreshold:Math.min(1,Math.max(0,e?.similarityThreshold??u.similarityThreshold)),minGroupSize:Math.max(2,Math.trunc(e?.minGroupSize??u.minGroupSize)),maxGroups:Math.max(1,Math.trunc(e?.maxGroups??u.maxGroups)),dryRun:e?.dryRun??u.dryRun}}function m(e){if(!e)return 0;let t=Date.parse(e);return Number.isNaN(t)?0:t}function h(e,t){let n=Math.max(m(e),m(t));return n===0?1/0:Math.max(0,Date.now()-n)/864e5}function g(e){return e.toLowerCase().match(/[a-z0-9]{2,}/g)??[]}function _(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,60)}function v(e,t){return`${[`---`,`title: "${e.title.replace(/"/g,`\\"`)}"`,`category: ${e.category}`,`tags: [${e.tags.map(e=>`"${e}"`).join(`, `)}]`,`created: ${e.created}`,`updated: ${e.updated}`,`version: ${e.version}`,`origin: ${e.origin}`,`changelog:`,...e.changelog.map(e=>` - version: ${e.version}\n date: ${e.date}\n reason: "${e.reason.replace(/"/g,`\\"`)}"`),`---`].join(`
|
|
3
|
-
`)}\n\n${t}\n`}function y(e,t){let n=e.map(()=>[]);for(let r=0;r<e.length;r+=1)for(let a=r+1;a<e.length;a+=1)i(e[r],e[a])>=t&&(n[r].push(a),n[a].push(r));return n}function b(e){let t=new Set,n=[];for(let r=0;r<e.length;r+=1){if(t.has(r))continue;let i=[r],a=[];for(t.add(r);i.length>0;){let n=i.pop();if(n!==void 0){a.push(n);for(let r of e[n])t.has(r)||(t.add(r),i.push(r))}}n.push(a)}return n}function x(e){let t=new Map,n=new Map,r=0;for(let i of e)for(let e of g(i))d.has(e)||(t.set(e,(t.get(e)??0)+1),n.has(e)||(n.set(e,r),r+=1));let i=[...t.entries()].sort((e,t)=>t[1]-e[1]||(n.get(e[0])??0)-(n.get(t[0])??0))[0];return i&&i[1]>1?_(i[0]):_(e.flatMap(e=>g(e)).find(e=>!d.has(e))??`lesson-group`)}async function S(e,t,n){let r=a(e.curatedDir,t),i=await o(r,`utf8`),{frontmatter:c,content:l}=e.parseFile(i),u=`group:${n}`;if(c.tags.includes(u))return;let d=new Date().toISOString(),f=(c.version??1)+1;await s(r,v({...c,tags:[...new Set([...c.tags,u])],updated:d,version:f,changelog:[...c.changelog??[],{version:f,date:d,reason:`Grouped lesson under ${n}`}]},l),`utf8`)}async function C(e,i,a,o){let s=f(a),c=r(o??n),l=(await e.list({category:`lessons`})).filter(e=>e.tags.includes(`lesson`)),u=l.map(e=>{let n=i.memoryMetaGet(e.path);if(!n||n.supersededBy!=null)return null;let r=h(n.lastAccessedAt,n.createdAt??e.created);if(r<s.safetyDays)return null;let a=t(n.confidence,n.lastAccessedAt,n.createdAt,c);return a>=s.maxConfidence||r<s.minIdleDays?null:{path:e.path,effectiveConfidence:a}}).filter(e=>e!==null).sort((e,t)=>e.effectiveConfidence-t.effectiveConfidence||e.path.localeCompare(t.path)).slice(0,s.maxPrune);if(!s.dryRun)for(let e of u)i.memoryMetaSetSuperseded(e.path,`lesson:auto-prune`);return{pruned:u.map(e=>e.path),skipped:l.length-u.length,dryRun:s.dryRun}}async function w(e,t,n){let r=p(n),i=(await e.list({category:`lessons`})).filter(e=>{if(!e.tags.includes(`lesson`)||e.tags.some(e=>e.startsWith(`group:`)))return!1;let n=t.memoryMetaGet(e.path);return n?.supersededBy==null||n===void 0});if(i.length<r.minGroupSize)return{groupsCreated:0,lessonsGrouped:0,groups:[],dryRun:r.dryRun};let a=b(y(i.map(e=>e.title),r.similarityThreshold)).filter(e=>e.length>=r.minGroupSize).map(e=>{let t=e.map(e=>i[e]).sort((e,t)=>e.path.localeCompare(t.path));return{label:x(t.map(e=>e.title)),members:t.map(e=>e.path)}}).sort((e,t)=>t.members.length-e.members.length||e.members[0].localeCompare(t.members[0])).slice(0,r.maxGroups);if(!r.dryRun&&a.length>0){for(let t of a)for(let n of t.members)await S(e,n,t.label);await e.reindexAll()}return{groupsCreated:a.length,lessonsGrouped:a.reduce((e,t)=>e+t.members.length,0),groups:a,dryRun:r.dryRun}}export{w as n,C as r,c as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./server-jZ_r6xLb.js";export{t as buildPreludeInjection,e as generatePrelude};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{t as e}from"./rolldown-runtime-yuFVEuWy.js";import{t}from"./bin.js";import{f as n,r,u as i}from"./supersession-DO_ZROFl.js";import{getGlobalDataDir as a,isUserInstalled as o,listWorkspaces as s}from"../../core/dist/index.js";import{existsSync as c,mkdirSync as l}from"node:fs";import{join as u}from"node:path";var d=e({DEFAULT_PROMOTE_CONFIG:()=>f,adjudicateCandidate:()=>E,checkPromotionGates:()=>w,collectWorkspaceLessons:()=>j,demoteLesson:()=>P,getGlobalCuratedDir:()=>A,promoteLessons:()=>N,scanForDuplicates:()=>M,scorePromotionCandidate:()=>T});const f={minWorkspaces:2,minAvgConfidence:80,similarityThreshold:.7,dryRun:!0};function p(e){return{minWorkspaces:Math.max(2,Math.trunc(e?.minWorkspaces??f.minWorkspaces)),minAvgConfidence:Math.min(100,Math.max(0,Math.trunc(e?.minAvgConfidence??f.minAvgConfidence))),similarityThreshold:Math.min(1,Math.max(0,e?.similarityThreshold??f.similarityThreshold)),dryRun:e?.dryRun??f.dryRun,layeredKnowledge:e?.layeredKnowledge??f.layeredKnowledge}}function m(e,t){let n=e.map(()=>[]);for(let i=0;i<e.length;i+=1)for(let a=i+1;a<e.length;a+=1)r(e[i].insight,e[a].insight)>=t&&(n[i].push(a),n[a].push(i));return n}function h(e){let t=new Set,n=[];for(let r=0;r<e.length;r+=1){if(t.has(r))continue;let i=[r],a=[];for(t.add(r);i.length>0;){let n=i.pop();if(n!==void 0){a.push(n);for(let r of e[n])t.has(r)||(t.add(r),i.push(r))}}n.push(a)}return n}function g(e){return new t(e,null,null)}function _(e){return(e??``).replace(/\s+/g,` `).trim()}function v(e){let t=_(e);return t.length<=80?t:`${t.slice(0,77).replace(/\s+\S*$/,``)}...`}function y(e){return i({title:v(e.insight),context:`Observed across ${e.foundIn.length} workspaces: ${e.foundIn.join(`, `)}`,insight:e.insight,evidence:[`Promoted from workspaces: ${e.foundIn.join(`, `)}`,`Average confidence: ${e.avgConfidence}/100`,`Reason: ${e.reason}`].join(`
|
|
3
|
-
`),confidence:e.avgConfidence,tags:[`lesson`,`promoted`,`global`]})}function b(e,t,n){return Math.max(t,Math.min(n,Math.round(e)))}function x(e){let t=(Date.now()-e.getTime())/(1440*60*1e3);return t<=1?10:t<=7?8:t<=14?6:t<=21?4:t<=30?2:1}function S(e){switch(e){case`high`:return 10;case`medium`:return 6;case`low`:return 2}}function C(e){let t=e.length/4;return t<=10?10:t<=25?8:t<=50?6:t<=100?4:t<=200?2:1}function w(e,t){let n=[],r=!!t?.topicKey;n.push({name:`canonical-topic-key`,passed:r,reason:r?void 0:`No canonical topic key provided`});let i=!!(t?.evidenceRefs&&t.evidenceRefs.length>0);n.push({name:`evidence-attached`,passed:i,reason:i?void 0:`No evidence refs attached`});let a=!0,o;if(t?.observedAt){let e=Date.now()-new Date(t.observedAt).getTime();a=e<2592e6,o=a?void 0:`Observation older than 30 days (${Math.round(e/(1440*60*1e3))}d)`}n.push({name:`freshness`,passed:a,reason:o});let s=!t?.hasConflict;n.push({name:`no-unresolved-conflict`,passed:s,reason:s?void 0:`Has unresolved conflict`});let c=!0,l;t?.scope&&t?.targetScope&&(c=t.scope===t.targetScope,l=c?void 0:`Scope "${t.scope}" does not match target "${t.targetScope}"`),n.push({name:`scope-matches`,passed:c,reason:l});let u=!1;t?.actionability&&(u=t.actionability===`high`||t.actionability===`medium`),n.push({name:`actionability-clear`,passed:u,reason:u?void 0:`Actionability is "${t?.actionability??`not set`}"`});let d=!0,f;t?.tokenBudgetRemaining!==void 0&&t?.minTokenBudget!==void 0&&(d=t.tokenBudgetRemaining>=t.minTokenBudget,f=d?void 0:`Token budget ${t.tokenBudgetRemaining} < required ${t.minTokenBudget}`),n.push({name:`token-budget-available`,passed:d,reason:f});let p=n.filter(e=>!e.passed).map(e=>e.name);return{passed:p.length===0,gates:n,failedGates:p}}function T(e,t){let n=b(t?.recurrence??1,1,10),r=b(t?.impact??5,1,10),i=b(e.foundIn.length,1,10),a=t?.observedAt?x(new Date(t.observedAt)):5,o=S(t?.actionability??`medium`),s=C(e.insight);return{signals:{recurrence:n,impact:r,sourceDiversity:i,freshness:a,actionability:o,tokenCost:s},totalScore:n+r+i+a+o+s}}function E(e,t,n,i,a){return t.passed?n&&i&&a&&n.some(e=>r(e,a.insight)>=i)?{decision:`supersede`,score:e.totalScore,reason:`Similar candidate already exists at L2`}:e.totalScore<20?{decision:`supersede`,score:e.totalScore,reason:`Score ${e.totalScore}/60 insufficient for promotion`}:e.totalScore<35?{decision:`hold-l3`,score:e.totalScore,reason:`Moderate score ${e.totalScore}/60, needs more evidence or recurrence`}:e.signals.recurrence<3&&e.signals.impact<8?{decision:`hold-l3`,score:e.totalScore,reason:`Low-impact repetition: recurrence=${e.signals.recurrence} < 3 despite score ${e.totalScore}/60`}:e.signals.recurrence<3&&e.signals.impact>=8?{decision:`promote`,score:e.totalScore,reason:`High-impact exception: impact=${e.signals.impact}, score=${e.totalScore}/60`}:{decision:`promote`,score:e.totalScore,reason:`Strong multi-signal score: ${e.totalScore}/60, recurrence=${e.signals.recurrence}, impact=${e.signals.impact}`}:{decision:`reject`,score:e.totalScore,reason:`Hard gates failed: ${t.failedGates.join(`, `)}`}}async function D(e,t){let r=await e.list({category:`lessons`,limit:1e3,orderBy:`updated`,order:`desc`});return(await Promise.all(r.map(async r=>{let i=await e.read(r.path),a=n(i.content),o=_(a.insight);return o?{workspace:t,path:r.path,title:a.title??i.title??r.title,insight:o,confidence:a.confidence??0}:null}))).filter(e=>e!==null)}async function O(e){return(await D(e,`global`)).map(e=>e.insight)}function k(e,t,n){return t.some(t=>r(t,e)>=n)}function A(){let e=u(a(),`global-knowledge`,`.ai`,`curated`);return c(e)||l(e,{recursive:!0}),e}async function j(e){let t=new Map;if(!o())return t;for(let e of s()){let n=u(e.workspacePath,`.ai`,`curated`);if(!c(n))continue;let r=await D(g(n),e.partition);r.length>0&&t.set(e.partition,r)}return t}function M(e,t=f,n){let r=p(t),i=[...e.values()].flat();if(i.length===0)return[];let a=h(m(i,r.similarityThreshold)),o=[];for(let e of a){let t=e.map(e=>i[e]),a=[...new Set(t.map(e=>e.workspace))].sort();if(a.length<r.minWorkspaces)continue;let s=Math.round(t.reduce((e,t)=>e+t.confidence,0)/t.length),c={insight:[...t].sort((e,t)=>t.confidence-e.confidence||e.title.localeCompare(t.title)||e.path.localeCompare(t.path))[0].insight,foundIn:a,avgConfidence:s,action:`skip`,reason:``};if(r.layeredKnowledge){let e=n?.get(c.insight),t=w(c,e),r=T(c,e),i=E(r,t,void 0,void 0,c);c.gateResult=t,c.scoringResult=r,c.adjudication=i,c.action=i.decision===`promote`?`promote`:`skip`,c.reason=i.reason}else c.action=s>=r.minAvgConfidence?`promote`:`skip`,c.reason=s>=r.minAvgConfidence?`Shared across ${a.length} workspaces`:`Below confidence threshold`;o.push(c)}return o.sort((e,t)=>Number(t.action===`promote`)-Number(e.action===`promote`)||t.foundIn.length-e.foundIn.length||t.avgConfidence-e.avgConfidence||e.insight.localeCompare(t.insight))}async function N(e,t,n=f){let r=p(n),i=[],a=await O(t);for(let n of e){if(!(r.layeredKnowledge?n.adjudication?.decision===`promote`:n.action===`promote`)||k(n.insight,a,r.similarityThreshold)||r.dryRun)continue;let e=await t.remember(v(n.insight),y(n),`lessons`,[`lesson`,`promoted`,`global`]);i.push(e.path),a.push(n.insight)}return{candidates:e,promoted:i}}async function P(e,t){try{return await e.forget(t,`Demoted from global knowledge partition`),{removed:!0,path:t}}catch(e){if(e instanceof Error&&/not found/i.test(e.message))return{removed:!1,path:t};throw e}}export{N as a,A as i,j as n,d as o,P as r,M as s,f as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./rolldown-runtime-DT7IzrpZ.js";import{t}from"./curated-manager-CBKTmAjM.js";import{f as n,r,u as i}from"./supersession-CWEne3av.js";import{getGlobalDataDir as a,isUserInstalled as o,listWorkspaces as s}from"../../core/dist/index.js";import{existsSync as c,mkdirSync as l}from"node:fs";import{join as u}from"node:path";var d=e({DEFAULT_PROMOTE_CONFIG:()=>f,adjudicateCandidate:()=>E,checkPromotionGates:()=>w,collectWorkspaceLessons:()=>j,demoteLesson:()=>P,getGlobalCuratedDir:()=>A,promoteLessons:()=>N,scanForDuplicates:()=>M,scorePromotionCandidate:()=>T});const f={minWorkspaces:2,minAvgConfidence:80,similarityThreshold:.7,dryRun:!0};function p(e){return{minWorkspaces:Math.max(2,Math.trunc(e?.minWorkspaces??f.minWorkspaces)),minAvgConfidence:Math.min(100,Math.max(0,Math.trunc(e?.minAvgConfidence??f.minAvgConfidence))),similarityThreshold:Math.min(1,Math.max(0,e?.similarityThreshold??f.similarityThreshold)),dryRun:e?.dryRun??f.dryRun,layeredKnowledge:e?.layeredKnowledge??f.layeredKnowledge}}function m(e,t){let n=e.map(()=>[]);for(let i=0;i<e.length;i+=1)for(let a=i+1;a<e.length;a+=1)r(e[i].insight,e[a].insight)>=t&&(n[i].push(a),n[a].push(i));return n}function h(e){let t=new Set,n=[];for(let r=0;r<e.length;r+=1){if(t.has(r))continue;let i=[r],a=[];for(t.add(r);i.length>0;){let n=i.pop();if(n!==void 0){a.push(n);for(let r of e[n])t.has(r)||(t.add(r),i.push(r))}}n.push(a)}return n}function g(e){return new t(e,null,null)}function _(e){return(e??``).replace(/\s+/g,` `).trim()}function v(e){let t=_(e);return t.length<=80?t:`${t.slice(0,77).replace(/\s+\S*$/,``)}...`}function y(e){return i({title:v(e.insight),context:`Observed across ${e.foundIn.length} workspaces: ${e.foundIn.join(`, `)}`,insight:e.insight,evidence:[`Promoted from workspaces: ${e.foundIn.join(`, `)}`,`Average confidence: ${e.avgConfidence}/100`,`Reason: ${e.reason}`].join(`
|
|
2
|
-
`),confidence:e.avgConfidence,tags:[`lesson`,`promoted`,`global`]})}function b(e,t,n){return Math.max(t,Math.min(n,Math.round(e)))}function x(e){let t=(Date.now()-e.getTime())/(1440*60*1e3);return t<=1?10:t<=7?8:t<=14?6:t<=21?4:t<=30?2:1}function S(e){switch(e){case`high`:return 10;case`medium`:return 6;case`low`:return 2}}function C(e){let t=e.length/4;return t<=10?10:t<=25?8:t<=50?6:t<=100?4:t<=200?2:1}function w(e,t){let n=[],r=!!t?.topicKey;n.push({name:`canonical-topic-key`,passed:r,reason:r?void 0:`No canonical topic key provided`});let i=!!(t?.evidenceRefs&&t.evidenceRefs.length>0);n.push({name:`evidence-attached`,passed:i,reason:i?void 0:`No evidence refs attached`});let a=!0,o;if(t?.observedAt){let e=Date.now()-new Date(t.observedAt).getTime();a=e<2592e6,o=a?void 0:`Observation older than 30 days (${Math.round(e/(1440*60*1e3))}d)`}n.push({name:`freshness`,passed:a,reason:o});let s=!t?.hasConflict;n.push({name:`no-unresolved-conflict`,passed:s,reason:s?void 0:`Has unresolved conflict`});let c=!0,l;t?.scope&&t?.targetScope&&(c=t.scope===t.targetScope,l=c?void 0:`Scope "${t.scope}" does not match target "${t.targetScope}"`),n.push({name:`scope-matches`,passed:c,reason:l});let u=!1;t?.actionability&&(u=t.actionability===`high`||t.actionability===`medium`),n.push({name:`actionability-clear`,passed:u,reason:u?void 0:`Actionability is "${t?.actionability??`not set`}"`});let d=!0,f;t?.tokenBudgetRemaining!==void 0&&t?.minTokenBudget!==void 0&&(d=t.tokenBudgetRemaining>=t.minTokenBudget,f=d?void 0:`Token budget ${t.tokenBudgetRemaining} < required ${t.minTokenBudget}`),n.push({name:`token-budget-available`,passed:d,reason:f});let p=n.filter(e=>!e.passed).map(e=>e.name);return{passed:p.length===0,gates:n,failedGates:p}}function T(e,t){let n=b(t?.recurrence??1,1,10),r=b(t?.impact??5,1,10),i=b(e.foundIn.length,1,10),a=t?.observedAt?x(new Date(t.observedAt)):5,o=S(t?.actionability??`medium`),s=C(e.insight);return{signals:{recurrence:n,impact:r,sourceDiversity:i,freshness:a,actionability:o,tokenCost:s},totalScore:n+r+i+a+o+s}}function E(e,t,n,i,a){return t.passed?n&&i&&a&&n.some(e=>r(e,a.insight)>=i)?{decision:`supersede`,score:e.totalScore,reason:`Similar candidate already exists at L2`}:e.totalScore<20?{decision:`supersede`,score:e.totalScore,reason:`Score ${e.totalScore}/60 insufficient for promotion`}:e.totalScore<35?{decision:`hold-l3`,score:e.totalScore,reason:`Moderate score ${e.totalScore}/60, needs more evidence or recurrence`}:e.signals.recurrence<3&&e.signals.impact<8?{decision:`hold-l3`,score:e.totalScore,reason:`Low-impact repetition: recurrence=${e.signals.recurrence} < 3 despite score ${e.totalScore}/60`}:e.signals.recurrence<3&&e.signals.impact>=8?{decision:`promote`,score:e.totalScore,reason:`High-impact exception: impact=${e.signals.impact}, score=${e.totalScore}/60`}:{decision:`promote`,score:e.totalScore,reason:`Strong multi-signal score: ${e.totalScore}/60, recurrence=${e.signals.recurrence}, impact=${e.signals.impact}`}:{decision:`reject`,score:e.totalScore,reason:`Hard gates failed: ${t.failedGates.join(`, `)}`}}async function D(e,t){let r=await e.list({category:`lessons`,limit:1e3,orderBy:`updated`,order:`desc`});return(await Promise.all(r.map(async r=>{let i=await e.read(r.path),a=n(i.content),o=_(a.insight);return o?{workspace:t,path:r.path,title:a.title??i.title??r.title,insight:o,confidence:a.confidence??0}:null}))).filter(e=>e!==null)}async function O(e){return(await D(e,`global`)).map(e=>e.insight)}function k(e,t,n){return t.some(t=>r(t,e)>=n)}function A(){let e=u(a(),`global-knowledge`,`.ai`,`curated`);return c(e)||l(e,{recursive:!0}),e}async function j(e){let t=new Map;if(!o())return t;for(let e of s()){let n=u(e.workspacePath,`.ai`,`curated`);if(!c(n))continue;let r=await D(g(n),e.partition);r.length>0&&t.set(e.partition,r)}return t}function M(e,t=f,n){let r=p(t),i=[...e.values()].flat();if(i.length===0)return[];let a=h(m(i,r.similarityThreshold)),o=[];for(let e of a){let t=e.map(e=>i[e]),a=[...new Set(t.map(e=>e.workspace))].sort();if(a.length<r.minWorkspaces)continue;let s=Math.round(t.reduce((e,t)=>e+t.confidence,0)/t.length),c={insight:[...t].sort((e,t)=>t.confidence-e.confidence||e.title.localeCompare(t.title)||e.path.localeCompare(t.path))[0].insight,foundIn:a,avgConfidence:s,action:`skip`,reason:``};if(r.layeredKnowledge){let e=n?.get(c.insight),t=w(c,e),r=T(c,e),i=E(r,t,void 0,void 0,c);c.gateResult=t,c.scoringResult=r,c.adjudication=i,c.action=i.decision===`promote`?`promote`:`skip`,c.reason=i.reason}else c.action=s>=r.minAvgConfidence?`promote`:`skip`,c.reason=s>=r.minAvgConfidence?`Shared across ${a.length} workspaces`:`Below confidence threshold`;o.push(c)}return o.sort((e,t)=>Number(t.action===`promote`)-Number(e.action===`promote`)||t.foundIn.length-e.foundIn.length||t.avgConfidence-e.avgConfidence||e.insight.localeCompare(t.insight))}async function N(e,t,n=f){let r=p(n),i=[],a=await O(t);for(let n of e){if(!(r.layeredKnowledge?n.adjudication?.decision===`promote`:n.action===`promote`)||k(n.insight,a,r.similarityThreshold)||r.dryRun)continue;let e=await t.remember(v(n.insight),y(n),`lessons`,[`lesson`,`promoted`,`global`]);i.push(e.path),a.push(n.insight)}return{candidates:e,promoted:i}}async function P(e,t){try{return await e.forget(t,`Demoted from global knowledge partition`),{removed:!0,path:t}}catch(e){if(e instanceof Error&&/not found/i.test(e.message))return{removed:!1,path:t};throw e}}export{N as a,A as i,j as n,d as o,P as r,M as s,f as t};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
function e(e){let t=[],n=!1,r=!1;for(let i of e){if(r){r=!1,t.push(i);continue}if(i===`\\`&&n){r=!0,t.push(i);continue}if(i===`"`){n=!n,t.push(i);continue}if(n&&(i===`
|
|
2
|
-
`||i===`\r`)){t.push(`\\n`);continue}t.push(i)}return t.join(``)}function t(e){let t=[],n=!1,r=!1;for(let i of e){if(r){r=!1,t.push(i);continue}if(i===`\\`&&n){r=!0,t.push(i);continue}if(i===`"`){n=!n,t.push(i);continue}if(n){t.push(i);continue}if(i===`]`||i===`}`)for(let e=t.length-1;e>=0;e--){let n=t[e];if(!(n===` `||n===`
|
|
3
|
-
`||n===` `||n===`\r`||n===``)){n===`,`&&(t[e]=``);break}}t.push(i)}return t.join(``)}function n(n){try{return JSON.parse(n)}catch{}let r=t(e(n));try{return JSON.parse(r)}catch(e){try{return JSON.parse(r.replaceAll(`'`,`"`))}catch{throw e}}}export{n as t};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
function e(e){let t=[],n=!1,r=!1;for(let i of e){if(r){r=!1,t.push(i);continue}if(i===`\\`&&n){r=!0,t.push(i);continue}if(i===`"`){n=!n,t.push(i);continue}if(n&&(i===`
|
|
3
|
-
`||i===`\r`)){t.push(`\\n`);continue}t.push(i)}return t.join(``)}function t(e){let t=[],n=!1,r=!1;for(let i of e){if(r){r=!1,t.push(i);continue}if(i===`\\`&&n){r=!0,t.push(i);continue}if(i===`"`){n=!n,t.push(i);continue}if(n){t.push(i);continue}if(i===`]`||i===`}`)for(let e=t.length-1;e>=0;e--){let n=t[e];if(!(n===` `||n===`
|
|
4
|
-
`||n===` `||n===`\r`||n===``)){n===`,`&&(t[e]=``);break}}t.push(i)}return t.join(``)}function n(n){try{return JSON.parse(n)}catch{}let r=t(e(n));try{return JSON.parse(r)}catch(e){try{return JSON.parse(r.replaceAll(`'`,`"`))}catch{throw e}}}export{n as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as e}from"node:module";import{fileURLToPath as t}from"node:url";import{existsSync as n}from"node:fs";import{dirname as r,join as i}from"node:path";const a=e(import.meta.url),o=import.meta.dirname??r(t(import.meta.url)),s=new Map;function c(e){let t=s.get(e);if(t!==void 0)return t;let c=i(o,`..`,`..`,e);if(n(i(c,`package.json`)))return s.set(e,c),c;try{let t=r(a.resolve(`@aikit/${e}/package.json`));return s.set(e,t),t}catch{}let l=o;for(let t=0;t<6;t++){let t=i(l,`packages`,e);if(n(i(t,`package.json`)))return s.set(e,t),t;let a=r(l);if(a===l)break;l=a}return s.set(e,null),null}function l(e,t=`dist`){let r=c(e);if(!r)return null;let a=i(r,t);return n(a)?a:null}function u(e,t){let r=c(e);if(!r)return null;for(let e of t){let t=i(r,e);if(n(t))return t}return null}export{u as n,c as r,l as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as e}from"node:module";import{fileURLToPath as t}from"node:url";import{existsSync as n}from"node:fs";import{dirname as r,join as i}from"node:path";const a=e(import.meta.url),o=import.meta.dirname??r(t(import.meta.url)),s=new Map;function c(e){let t=s.get(e);if(t!==void 0)return t;let c=i(o,`..`,`..`,e);if(n(i(c,`package.json`)))return s.set(e,c),c;try{let t=r(a.resolve(`@aikit/${e}/package.json`));return s.set(e,t),t}catch{}let l=o;for(let t=0;t<6;t++){let t=i(l,`packages`,e);if(n(i(t,`package.json`)))return s.set(e,t),t;let a=r(l);if(a===l)break;l=a}return s.set(e,null),null}function l(e,t=`dist`){let r=c(e);if(!r)return null;let a=i(r,t);return n(a)?a:null}function u(e,t){let r=c(e);if(!r)return null;for(let e of t){let t=i(r,e);if(n(t))return t}return null}export{u as n,c as r,l as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./server-jZ_r6xLb.js";export{e as createSamplingClient};
|