context-mode 2.0.0-next.37 → 2.0.0-next.39
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/.codex-plugin/plugin.json +1 -1
- package/README.md +78 -76
- package/SHA256SUMS +14 -14
- package/copilot/plugin.json +1 -1
- package/gemini-extension.json +1 -1
- package/hook.mjs +7 -7
- package/opencode/plugin.js +125 -48
- package/package.json +1 -1
- package/pi/index.js +155 -78
- package/qwen-extension.json +1 -1
- package/run.mjs +1 -1
- package/search.mjs +1 -1
- package/server.mjs +151 -74
package/server.mjs
CHANGED
|
@@ -3497,26 +3497,26 @@ function isRecursive(inst, stack2, resolve6) {
|
|
|
3497
3497
|
let result = NONE;
|
|
3498
3498
|
const check2 = (child) => {
|
|
3499
3499
|
if (result !== PROVEN && child?._zod) {
|
|
3500
|
-
const
|
|
3501
|
-
if (
|
|
3502
|
-
result =
|
|
3500
|
+
const answer3 = isRecursive(child, stack2, resolve6);
|
|
3501
|
+
if (answer3 > result)
|
|
3502
|
+
result = answer3;
|
|
3503
3503
|
}
|
|
3504
3504
|
};
|
|
3505
3505
|
const shape = (sh, spread) => {
|
|
3506
|
-
let
|
|
3506
|
+
let answer3 = NONE;
|
|
3507
3507
|
for (const key of Reflect.ownKeys(sh)) {
|
|
3508
3508
|
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
3509
3509
|
if (spread && !desc.enumerable)
|
|
3510
3510
|
continue;
|
|
3511
3511
|
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack2, resolve6) : NONE;
|
|
3512
|
-
if (child >
|
|
3513
|
-
|
|
3512
|
+
if (child > answer3)
|
|
3513
|
+
answer3 = child;
|
|
3514
3514
|
}
|
|
3515
|
-
return
|
|
3515
|
+
return answer3;
|
|
3516
3516
|
};
|
|
3517
|
-
const merge5 = (
|
|
3518
|
-
if (
|
|
3519
|
-
result =
|
|
3517
|
+
const merge5 = (answer3) => {
|
|
3518
|
+
if (answer3 > result)
|
|
3519
|
+
result = answer3;
|
|
3520
3520
|
};
|
|
3521
3521
|
const def = inst._zod.def;
|
|
3522
3522
|
const kind = def.type;
|
|
@@ -3619,10 +3619,10 @@ function isRecursive(inst, stack2, resolve6) {
|
|
|
3619
3619
|
stack2.delete(inst);
|
|
3620
3620
|
return settle(inst, result);
|
|
3621
3621
|
}
|
|
3622
|
-
function settle(inst,
|
|
3623
|
-
if (
|
|
3624
|
-
recursive.set(inst,
|
|
3625
|
-
return
|
|
3622
|
+
function settle(inst, answer3) {
|
|
3623
|
+
if (answer3 !== ASSUMED)
|
|
3624
|
+
recursive.set(inst, answer3 === PROVEN);
|
|
3625
|
+
return answer3;
|
|
3626
3626
|
}
|
|
3627
3627
|
function bucketFor(state, inst) {
|
|
3628
3628
|
let bucket = state.buckets.get(inst);
|
|
@@ -11026,26 +11026,26 @@ function isRecursive2(inst, stack2, resolve6) {
|
|
|
11026
11026
|
let result = NONE2;
|
|
11027
11027
|
const check2 = (child) => {
|
|
11028
11028
|
if (result !== PROVEN2 && child?._zod) {
|
|
11029
|
-
const
|
|
11030
|
-
if (
|
|
11031
|
-
result =
|
|
11029
|
+
const answer3 = isRecursive2(child, stack2, resolve6);
|
|
11030
|
+
if (answer3 > result)
|
|
11031
|
+
result = answer3;
|
|
11032
11032
|
}
|
|
11033
11033
|
};
|
|
11034
11034
|
const shape = (sh, spread) => {
|
|
11035
|
-
let
|
|
11035
|
+
let answer3 = NONE2;
|
|
11036
11036
|
for (const key of Reflect.ownKeys(sh)) {
|
|
11037
11037
|
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
11038
11038
|
if (spread && !desc.enumerable)
|
|
11039
11039
|
continue;
|
|
11040
11040
|
const child = desc.get ? ASSUMED2 : desc.value?._zod ? isRecursive2(desc.value, stack2, resolve6) : NONE2;
|
|
11041
|
-
if (child >
|
|
11042
|
-
|
|
11041
|
+
if (child > answer3)
|
|
11042
|
+
answer3 = child;
|
|
11043
11043
|
}
|
|
11044
|
-
return
|
|
11044
|
+
return answer3;
|
|
11045
11045
|
};
|
|
11046
|
-
const merge5 = (
|
|
11047
|
-
if (
|
|
11048
|
-
result =
|
|
11046
|
+
const merge5 = (answer3) => {
|
|
11047
|
+
if (answer3 > result)
|
|
11048
|
+
result = answer3;
|
|
11049
11049
|
};
|
|
11050
11050
|
const def = inst._zod.def;
|
|
11051
11051
|
const kind = def.type;
|
|
@@ -11148,10 +11148,10 @@ function isRecursive2(inst, stack2, resolve6) {
|
|
|
11148
11148
|
stack2.delete(inst);
|
|
11149
11149
|
return settle2(inst, result);
|
|
11150
11150
|
}
|
|
11151
|
-
function settle2(inst,
|
|
11152
|
-
if (
|
|
11153
|
-
recursive2.set(inst,
|
|
11154
|
-
return
|
|
11151
|
+
function settle2(inst, answer3) {
|
|
11152
|
+
if (answer3 !== ASSUMED2)
|
|
11153
|
+
recursive2.set(inst, answer3 === PROVEN2);
|
|
11154
|
+
return answer3;
|
|
11155
11155
|
}
|
|
11156
11156
|
function bucketFor2(state, inst) {
|
|
11157
11157
|
let bucket = state.buckets.get(inst);
|
|
@@ -28067,6 +28067,7 @@ var STATE_CLOSE_TAG = "</context_mode_state>";
|
|
|
28067
28067
|
var INDEX_WRITE_CHUNK = 1048576;
|
|
28068
28068
|
var MAX_CHUNK_BYTES = 4096;
|
|
28069
28069
|
var SEARCH_PAGE_SIZE = 20;
|
|
28070
|
+
var MEMORY_LABEL_PREFIX = "memory ";
|
|
28070
28071
|
var SEARCH_REPLY_HITS = 5;
|
|
28071
28072
|
var SNIPPET_MAX_BYTES = 800;
|
|
28072
28073
|
var SNIPPET_CODE_MAX_BYTES = 2048;
|
|
@@ -28405,7 +28406,7 @@ var DECISION_SOURCE = "decision";
|
|
|
28405
28406
|
var DECISION_USER_LABEL = "decision (user)";
|
|
28406
28407
|
var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
|
|
28407
28408
|
var RELEASE_BRANCH = "release";
|
|
28408
|
-
var BUNDLE_SHA = true ? "
|
|
28409
|
+
var BUNDLE_SHA = true ? "1fdd9889d173fa80227ade07d30705291f097df5" : void 0;
|
|
28409
28410
|
var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
|
|
28410
28411
|
var DOCTOR_LABEL = Object.freeze({
|
|
28411
28412
|
D1: "version",
|
|
@@ -32088,7 +32089,7 @@ function ftsQueryTimeline(db, scope, ctx, sessionId, limit, after, source, memor
|
|
|
32088
32089
|
}
|
|
32089
32090
|
}
|
|
32090
32091
|
for (const m of memory) {
|
|
32091
|
-
if (m.ts > from && (source === void 0 || m.label === source)) merged.push(m);
|
|
32092
|
+
if (m.ts > from && (source === void 0 || m.label === source || MEMORY_LABEL_PREFIX + m.label === source)) merged.push(m);
|
|
32092
32093
|
}
|
|
32093
32094
|
merged.sort(timelineOrder);
|
|
32094
32095
|
let end = Math.min(limit, merged.length);
|
|
@@ -43538,7 +43539,7 @@ var TOOL_DESCRIPTIONS = Object.freeze({
|
|
|
43538
43539
|
ctx_execute: 'Example: `ctx_execute({language:"shell",code:"git log --oneline -5"})`. Required: language, code.\nWrite code that prints only the answer, not the raw data. Runs code in a sandboxed subprocess in the project directory (shell, powershell, javascript, typescript, python, or another runtime on PATH); only what the code prints comes back. For a large file, set `file` to its local path: the code gets it in the CTX_FILE environment variable. Set `intent` when output may be large: the matching sections come back and the full output is indexed for ctx_search. `timeoutMs` defaults to and caps at 600000; then the whole process tree is killed.',
|
|
43539
43540
|
ctx_batch: 'Example: `ctx_batch({commands:["git log --oneline -5"],queries:["recent changes"]})`. Required: commands, queries.\nRuns several shell commands, then answers several search queries over their combined output, in one call. Use it to collect facts from more than one command at once, for example test results plus recent commits, when you need specific answers rather than the full text. Returns the matching sections and a one-line footer.',
|
|
43540
43541
|
ctx_index: 'Example: `ctx_index({path:"docs/api.md"})`. Required: one of path, content, url.\nStores content so it can be searched later: a local file or folder (nested .gitignore files are respected), raw text, or a URL, which is fetched and converted to Markdown. Use it for documentation or large files you will query more than once, then use ctx_search instead of reading the content again. Returns the source label and how many chunks were stored.',
|
|
43541
|
-
ctx_search: 'Example: `ctx_search({queries:["auth middleware"]})`. Required: queries.\nSearches content stored with ctx_index and earlier sandbox output in this project. Pass several queries in one call. By default it searches the current worktree; set `scope` to `project` for all worktrees or `session` for this session only. Results from the current session rank first, then by relevance, ranked with measurably better recall than plain keyword search. Set `sort` to `timeline` for oldest-first order across this session, prior sessions and memory, paged with `after`; `offset` is for relevance order only. Set `source` to `decision` to search only rows where the user answered a question. Every hit names its source. When nothing matches, the reply states the scope and how many sources are indexed.',
|
|
43542
|
+
ctx_search: 'Example: `ctx_search({queries:["auth middleware"]})`. Required: queries.\nSearches content stored with ctx_index and earlier sandbox output in this project. Memory files such as AGENTS.md are searched too. Pass several queries in one call. By default it searches the current worktree; set `scope` to `project` for all worktrees or `session` for this session only. Results from the current session rank first, then by relevance, ranked with measurably better recall than plain keyword search. Set `sort` to `timeline` for oldest-first order across this session, prior sessions and memory, paged with `after`; `offset` is for relevance order only. Set `source` to `decision` to search only rows where the user answered a question. Every hit names its source. When nothing matches, the reply states the scope and how many sources are indexed.',
|
|
43542
43543
|
ctx_resume: "Example: `ctx_resume({})`. Required: none.\nReturns a summary of up to 2 KB for this session: the last task and user request, files changed, open errors, and search terms for ctx_search. A large row is shown as a pointer line instead of its full text; call `ctx_resume(seq: N)` with that line's number to read the full row. Call it with no `seq` to get the state block on demand. Use it after the conversation was compacted or resumed, before you repeat earlier work.",
|
|
43543
43544
|
ctx_stats: "Example: `ctx_stats({})`. Required: none.\nReports the bytes context-mode kept out of the chat: a text report (bars, per tool, per agent) and a Markdown table. Show the text block to the user unchanged, in a code block. Use it when the user asks what it saved.",
|
|
43544
43545
|
ctx_doctor: "Example: `ctx_doctor({})`. Required: none.\nChecks this context-mode install and reports a table with one row per check: version, Node and node:sqlite, host config and hooks for this agent, MCP connection, project and worktree, database health, index contents, and hook timing. Each failed row names its cause, the fix and a docs link. Use it when the user asks whether context-mode works, or after a context-mode error. Run each Fix first, then call ctx_doctor again. If a FAIL stays, show the user the report file it names (it holds paths and environment details) and ask before you run the printed gh issue command.\n",
|
|
@@ -44103,17 +44104,29 @@ function runProcess(argv, o) {
|
|
|
44103
44104
|
}
|
|
44104
44105
|
|
|
44105
44106
|
// src/core/index/auto-memory.ts
|
|
44106
|
-
import { readFileSync as readFileSync3, statSync as statSync3 } from "node:fs";
|
|
44107
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync3, statSync as statSync3 } from "node:fs";
|
|
44107
44108
|
import { join as join5 } from "node:path";
|
|
44108
|
-
var
|
|
44109
|
+
var MEMORY_FILES = Object.freeze([
|
|
44109
44110
|
Object.freeze(["CLAUDE.md"]),
|
|
44110
44111
|
Object.freeze(["CLAUDE.local.md"]),
|
|
44111
|
-
Object.freeze([".claude", "CLAUDE.md"])
|
|
44112
|
+
Object.freeze([".claude", "CLAUDE.md"]),
|
|
44113
|
+
Object.freeze(["AGENTS.md"]),
|
|
44114
|
+
Object.freeze(["GEMINI.md"]),
|
|
44115
|
+
Object.freeze(["QWEN.md"]),
|
|
44116
|
+
Object.freeze([".github", "copilot-instructions.md"])
|
|
44112
44117
|
]);
|
|
44118
|
+
var KIRO_STEERING = Object.freeze([".kiro", "steering"]);
|
|
44119
|
+
var MD = ".md";
|
|
44120
|
+
function steeringFiles(worktree) {
|
|
44121
|
+
try {
|
|
44122
|
+
return readdirSync3(join5(worktree, ...KIRO_STEERING)).filter((n) => n.endsWith(MD)).sort().map((n) => [...KIRO_STEERING, n]);
|
|
44123
|
+
} catch {
|
|
44124
|
+
return [];
|
|
44125
|
+
}
|
|
44126
|
+
}
|
|
44113
44127
|
function readAutoMemory(project) {
|
|
44114
|
-
if (project.agent !== "claude-code") return [];
|
|
44115
44128
|
const rows = [];
|
|
44116
|
-
for (const segs of
|
|
44129
|
+
for (const segs of [...MEMORY_FILES, ...steeringFiles(project.worktree)]) {
|
|
44117
44130
|
const path7 = join5(project.worktree, ...segs);
|
|
44118
44131
|
if (!isInside(project.worktree, path7)) continue;
|
|
44119
44132
|
try {
|
|
@@ -44133,6 +44146,24 @@ function readAutoMemory(project) {
|
|
|
44133
44146
|
}
|
|
44134
44147
|
return rows;
|
|
44135
44148
|
}
|
|
44149
|
+
function memoryFileNamed(rows, value) {
|
|
44150
|
+
const v = value.split("\\").join("/");
|
|
44151
|
+
return rows.find((r) => r.label === v || MEMORY_LABEL_PREFIX + r.label === v) ?? null;
|
|
44152
|
+
}
|
|
44153
|
+
function memoryChunks(rows) {
|
|
44154
|
+
const out = [];
|
|
44155
|
+
rows.forEach((r, i) => {
|
|
44156
|
+
for (const c of chunkText(r.text, "md")) out.push({ fileNo: i + 1, label: r.label, ord: c.ord, text: c.text });
|
|
44157
|
+
});
|
|
44158
|
+
return out;
|
|
44159
|
+
}
|
|
44160
|
+
function memoryHits(chunks, q, limit) {
|
|
44161
|
+
if (chunks.length === 0) return [];
|
|
44162
|
+
const texts = chunks.map((c) => c.text);
|
|
44163
|
+
const any3 = rankTexts(texts, q, "any");
|
|
44164
|
+
const all = rankTexts(texts, q, "all");
|
|
44165
|
+
return chunks.map((c, i) => ({ c, s: any3[i], full: all[i] > 0 })).filter((e) => e.s > 0).sort((a, b) => Number(b.full) - Number(a.full) || b.s - a.s || a.c.fileNo - b.c.fileNo || a.c.ord - b.c.ord).slice(0, limit).map((e) => ({ sourceId: -e.c.fileNo, label: MEMORY_LABEL_PREFIX + e.c.label, ord: e.c.ord, snippet: highlight(e.c.text, q, SNIPPET_MAX_BYTES), score: e.s, full: e.full }));
|
|
44166
|
+
}
|
|
44136
44167
|
|
|
44137
44168
|
// src/core/index/shape.ts
|
|
44138
44169
|
var SHAPE_MIN_ROWS = 20;
|
|
@@ -44223,8 +44254,8 @@ function sourceCount(db, scope, ctx, source) {
|
|
|
44223
44254
|
});
|
|
44224
44255
|
return Number(row5.n);
|
|
44225
44256
|
}
|
|
44226
|
-
function zeroHits(db, scope, ctx, source, offset = 0) {
|
|
44227
|
-
const n = sourceCount(db, scope, ctx, source);
|
|
44257
|
+
function zeroHits(db, scope, ctx, source, mem, offset = 0) {
|
|
44258
|
+
const n = sourceCount(db, scope, ctx, source) + mem.rows.length;
|
|
44228
44259
|
if (offset > 0) return reply("No more hits past offset " + offset + ' in scope "' + scope + '" across ' + n + " source(s).", false);
|
|
44229
44260
|
return reply('No hits in scope "' + scope + '" across ' + n + " source(s).", false);
|
|
44230
44261
|
}
|
|
@@ -44247,7 +44278,7 @@ function sourceCard(db, id, input, scope, arg) {
|
|
|
44247
44278
|
}
|
|
44248
44279
|
function callText(queries, scope, source, cursor) {
|
|
44249
44280
|
const src = source === void 0 ? "" : ", source:" + JSON.stringify(source);
|
|
44250
|
-
return "ctx_search({queries:" + JSON.stringify(queries) + ", scope:" + JSON.stringify(scope) + src + ", " + cursor + "})";
|
|
44281
|
+
return "ctx_search({queries:" + JSON.stringify(queries) + ", scope:" + JSON.stringify(scope) + src + (cursor === "" ? "" : ", " + cursor) + "})";
|
|
44251
44282
|
}
|
|
44252
44283
|
function decisionQueries(input) {
|
|
44253
44284
|
return input.source === DECISION_SOURCE && input.queries.length === 0 ? [""] : input.queries;
|
|
@@ -44324,14 +44355,46 @@ function replyHits(hits, size) {
|
|
|
44324
44355
|
while (n < size && n < hits.length && hits[n].full === true) n++;
|
|
44325
44356
|
return n;
|
|
44326
44357
|
}
|
|
44327
|
-
|
|
44358
|
+
var MEMORY_HITS = 2;
|
|
44359
|
+
function mergeMemory(content, memory) {
|
|
44360
|
+
const out = [];
|
|
44361
|
+
let c = 0;
|
|
44362
|
+
let m = 0;
|
|
44363
|
+
let lastMem = true;
|
|
44364
|
+
while (c < content.length || m < memory.length) {
|
|
44365
|
+
const rank = (h) => h === void 0 ? -1 : h.full === true ? 1 : 0;
|
|
44366
|
+
const rc = rank(content[c]);
|
|
44367
|
+
const rm = rank(memory[m]);
|
|
44368
|
+
const mem = rc < 0 || rm > rc || rm === rc && !lastMem;
|
|
44369
|
+
if (mem) {
|
|
44370
|
+
out.push(memory[m++]);
|
|
44371
|
+
lastMem = true;
|
|
44372
|
+
} else {
|
|
44373
|
+
out.push(content[c++]);
|
|
44374
|
+
lastMem = false;
|
|
44375
|
+
}
|
|
44376
|
+
}
|
|
44377
|
+
return out;
|
|
44378
|
+
}
|
|
44379
|
+
var contentIn = (hits, n) => hits.slice(0, n).filter((h) => h.sourceId > 0).length;
|
|
44380
|
+
function relevance(db, given, scope, ctx, nm, ms, indexed) {
|
|
44328
44381
|
const input = { ...given, queries: decisionQueries(given) };
|
|
44329
44382
|
const offset = input.offset ?? 0;
|
|
44330
44383
|
const size = pageSize(input);
|
|
44331
|
-
const
|
|
44384
|
+
const mem = ms.named || offset === 0 ? memoryChunks(ms.rows) : [];
|
|
44385
|
+
const count2 = (hits, n) => ms.named ? Math.min(n, hits.length) : contentIn(hits, n);
|
|
44386
|
+
const fetched = input.queries.map((q) => {
|
|
44387
|
+
if (ms.named) {
|
|
44388
|
+
const want = offset + size + 1;
|
|
44389
|
+
const content2 = indexed ? ftsQuery(db, q, scope, ctx.project, ctx.sessionId, want, 0, input.source) : [];
|
|
44390
|
+
return mergeMemory(content2, memoryHits(mem, q, want)).slice(offset, want);
|
|
44391
|
+
}
|
|
44392
|
+
const content = page(db, q, input, scope, ctx, offset, 1);
|
|
44393
|
+
return mem.length === 0 ? content : mergeMemory(content, memoryHits(mem, q, MEMORY_HITS));
|
|
44394
|
+
});
|
|
44332
44395
|
const take = fetched.map((h) => replyHits(h, size));
|
|
44333
44396
|
const pages = fetched.map((h, i) => h.slice(0, take[i]));
|
|
44334
|
-
if (pages.every((p) => p.length === 0)) return zeroHits(db, scope, ctx, input.source, offset);
|
|
44397
|
+
if (pages.every((p) => p.length === 0)) return zeroHits(db, scope, ctx, input.source, ms, offset);
|
|
44335
44398
|
const moreLine3 = (q, pos) => "More: " + callText([q], scope, nm.arg, "offset:" + pos);
|
|
44336
44399
|
let reserve = 0;
|
|
44337
44400
|
for (const q of input.queries) reserve += bytes2(moreLine3(q, offset + size)) + 1;
|
|
@@ -44364,13 +44427,13 @@ function relevance(db, given, scope, ctx, nm) {
|
|
|
44364
44427
|
}
|
|
44365
44428
|
const line = shownLabel(hit.label, hit.sourceId) + " #" + hit.ord + ": " + hit.snippet;
|
|
44366
44429
|
if (used + bytes2(line) + 1 + reserve > OUTPUT_CAP) {
|
|
44367
|
-
cut = offset + i;
|
|
44430
|
+
cut = offset + count2(hits, i);
|
|
44368
44431
|
stopped = true;
|
|
44369
44432
|
break;
|
|
44370
44433
|
}
|
|
44371
44434
|
const room = total.get(hit.sourceId);
|
|
44372
44435
|
if (room !== void 0 && mine.has(hit.sourceId) && (spent.get(hit.sourceId) ?? 0) + bytes2(line) + 1 > room * SMALL_SOURCE_SHARE * (qi + 1) / input.queries.length) {
|
|
44373
|
-
cut = offset + i;
|
|
44436
|
+
cut = offset + count2(hits, i);
|
|
44374
44437
|
break;
|
|
44375
44438
|
}
|
|
44376
44439
|
lines.push(line);
|
|
@@ -44385,7 +44448,7 @@ function relevance(db, given, scope, ctx, nm) {
|
|
|
44385
44448
|
used += bytes2(line) + 1;
|
|
44386
44449
|
}
|
|
44387
44450
|
if (cut >= 0) more.push({ q, pos: cut });
|
|
44388
|
-
else if (fetched[qi].length > take[qi]) more.push({ q, pos: offset + take[qi] });
|
|
44451
|
+
else if (count2(fetched[qi], fetched[qi].length) > count2(fetched[qi], take[qi])) more.push({ q, pos: offset + count2(fetched[qi], take[qi]) });
|
|
44389
44452
|
});
|
|
44390
44453
|
const moreLines = [];
|
|
44391
44454
|
const byPos = /* @__PURE__ */ new Map();
|
|
@@ -44399,10 +44462,9 @@ function timelineLine(r) {
|
|
|
44399
44462
|
const seq = r.seq === null ? "" : " #" + r.seq;
|
|
44400
44463
|
return "[" + new Date(r.ts).toISOString() + "] " + shownLabel(r.label, r.sourceId) + seq + " " + first;
|
|
44401
44464
|
}
|
|
44402
|
-
function timeline(db, input, scope, ctx, nm) {
|
|
44403
|
-
const
|
|
44404
|
-
|
|
44405
|
-
if (page2.rows.length === 0) return zeroHits(db, scope, ctx, input.source);
|
|
44465
|
+
function timeline(db, input, scope, ctx, nm, ms) {
|
|
44466
|
+
const page2 = ftsQueryTimeline(db, scope, ctx.project, ctx.sessionId, SEARCH_PAGE_SIZE, input.after ?? null, input.source, ms.rows);
|
|
44467
|
+
if (page2.rows.length === 0) return zeroHits(db, scope, ctx, input.source, ms);
|
|
44406
44468
|
const moreLine3 = (ts) => "more: " + callText(input.queries, scope, nm.arg, 'sort:"timeline", after:' + ts);
|
|
44407
44469
|
const reserve = bytes2(moreLine3(page2.rows[page2.rows.length - 1].ts)) + 1;
|
|
44408
44470
|
const lines = nm.note === null ? [] : [nm.note];
|
|
@@ -44431,6 +44493,15 @@ function timeline(db, input, scope, ctx, nm) {
|
|
|
44431
44493
|
if (more && lastTs !== null) lines.push(moreLine3(lastTs));
|
|
44432
44494
|
return reply(lines.join("\n"), false);
|
|
44433
44495
|
}
|
|
44496
|
+
function answer(db, input, scope, ctx, nm, ms, indexed, sort, pick4) {
|
|
44497
|
+
if (sort === "timeline") return timeline(db, input, scope, ctx, nm, ms);
|
|
44498
|
+
if (pick4 !== null && pick4.id !== null && input.queries.length === 0) {
|
|
44499
|
+
const card = sourceCard(db, pick4.id, input, scope, nm.arg);
|
|
44500
|
+
if (card !== null) return card;
|
|
44501
|
+
}
|
|
44502
|
+
const rows = ms.named ? null : jsonRowsReply(db, input, scope, ctx, nm);
|
|
44503
|
+
return rows ?? relevance(db, input, scope, ctx, nm, ms, indexed);
|
|
44504
|
+
}
|
|
44434
44505
|
async function handler(input, ctx) {
|
|
44435
44506
|
const sort = input.sort ?? "relevance";
|
|
44436
44507
|
if (sort === "timeline" && input.offset !== void 0) {
|
|
@@ -44446,12 +44517,18 @@ async function handler(input, ctx) {
|
|
|
44446
44517
|
const pick4 = given !== void 0 && given !== DECISION_SOURCE ? pickSource(db, given) : null;
|
|
44447
44518
|
if (pick4 !== null) input = { ...input, source: pick4.label };
|
|
44448
44519
|
const nm = named(given, pick4);
|
|
44449
|
-
|
|
44450
|
-
|
|
44451
|
-
|
|
44452
|
-
|
|
44453
|
-
|
|
44454
|
-
|
|
44520
|
+
const indexed = pick4 !== null && pick4.id !== null;
|
|
44521
|
+
const files = scope !== "session" || given !== void 0 ? readAutoMemory(ctx.project) : [];
|
|
44522
|
+
const file2 = given === void 0 || given === DECISION_SOURCE ? null : memoryFileNamed(files, given);
|
|
44523
|
+
const ms = { rows: scope === "session" ? [] : file2 !== null ? [file2] : given === void 0 ? files : [], named: file2 !== null };
|
|
44524
|
+
if (file2 !== null && indexed && scope !== "session") {
|
|
44525
|
+
const both = "Source " + JSON.stringify(given) + ": searched the indexed source " + shownLabel(pick4.label, pick4.id) + " and the memory file " + file2.label + ".";
|
|
44526
|
+
nm.note = nm.note === null ? both : nm.note + "\n" + both;
|
|
44527
|
+
}
|
|
44528
|
+
const out = answer(db, input, scope, ctx, nm, ms, indexed, sort, pick4);
|
|
44529
|
+
if (file2 === null || scope !== "session") return out;
|
|
44530
|
+
const call = callText(input.queries, "worktree", nm.arg, sort === "timeline" ? 'sort:"timeline"' : "");
|
|
44531
|
+
return reply(out.text + "\nMemory file " + file2.label + ' is in scope "worktree": ' + call + " searches it.", out.isError);
|
|
44455
44532
|
} finally {
|
|
44456
44533
|
closeDb(db);
|
|
44457
44534
|
}
|
|
@@ -44587,7 +44664,7 @@ function indexCombined(db, ctx, label2, ran, deadline, budgetBytes) {
|
|
|
44587
44664
|
function bytes3(s) {
|
|
44588
44665
|
return Buffer.byteLength(s, "utf8");
|
|
44589
44666
|
}
|
|
44590
|
-
function
|
|
44667
|
+
function answer2(db, ctx, ownIds, queries, share, own4) {
|
|
44591
44668
|
const seen = /* @__PURE__ */ new Set();
|
|
44592
44669
|
const lines = [];
|
|
44593
44670
|
for (const [qi, q] of queries.entries()) {
|
|
@@ -44650,7 +44727,7 @@ async function runBatch(input, ctx, boundMs, budgetBytes) {
|
|
|
44650
44727
|
notice = cut === null ? stop : cause === null ? cut : cause + " " + cut;
|
|
44651
44728
|
const fixed = (exitLine === null ? 0 : bytes3(exitLine) + 1) + (notice === null ? 0 : bytes3(notice) + 1) + bytes3(footer);
|
|
44652
44729
|
const share = Math.floor((OUTPUT_CAP - fixed) / queries.length);
|
|
44653
|
-
const answered =
|
|
44730
|
+
const answered = answer2(db, ctx, idx.ids, queries, share, idx.bodies);
|
|
44654
44731
|
sections = answered.lines;
|
|
44655
44732
|
const unseen = [...idx.bodies].filter(([k, text]) => text !== "" && !answered.seen.has(k)).map(([k]) => idx.raw.get(k));
|
|
44656
44733
|
const unseenBytes = unseen.reduce((n, t) => n + bytes3(t) + 1, 0);
|
|
@@ -44686,7 +44763,7 @@ var ctxBatch = Object.freeze({
|
|
|
44686
44763
|
});
|
|
44687
44764
|
|
|
44688
44765
|
// src/core/tools/doctor.ts
|
|
44689
|
-
import { readdirSync as
|
|
44766
|
+
import { readdirSync as readdirSync7, readFileSync as readFileSync10, existsSync as existsSync14 } from "node:fs";
|
|
44690
44767
|
import { basename as basename5, dirname as dirname7, join as join14 } from "node:path";
|
|
44691
44768
|
|
|
44692
44769
|
// src/adapters/claude-code.ts
|
|
@@ -45576,11 +45653,11 @@ function getAdapter(id) {
|
|
|
45576
45653
|
}
|
|
45577
45654
|
|
|
45578
45655
|
// src/core/ops/doctor-config.ts
|
|
45579
|
-
import { existsSync as existsSync7, readdirSync as
|
|
45656
|
+
import { existsSync as existsSync7, readdirSync as readdirSync6 } from "node:fs";
|
|
45580
45657
|
import { join as join9 } from "node:path";
|
|
45581
45658
|
|
|
45582
45659
|
// src/core/ops/detect-v1.ts
|
|
45583
|
-
import { existsSync as existsSync5, opendirSync, readdirSync as
|
|
45660
|
+
import { existsSync as existsSync5, opendirSync, readdirSync as readdirSync4, readFileSync as readFileSync5 } from "node:fs";
|
|
45584
45661
|
import { tmpdir } from "node:os";
|
|
45585
45662
|
import { join as join7 } from "node:path";
|
|
45586
45663
|
|
|
@@ -48323,7 +48400,7 @@ function scanVscode(agentHome, project, out) {
|
|
|
48323
48400
|
}
|
|
48324
48401
|
function jsonFiles(dir) {
|
|
48325
48402
|
try {
|
|
48326
|
-
return
|
|
48403
|
+
return readdirSync4(dir).filter((name) => name.endsWith(KIRO_AGENT_FILE_EXT)).sort();
|
|
48327
48404
|
} catch {
|
|
48328
48405
|
return [];
|
|
48329
48406
|
}
|
|
@@ -48449,7 +48526,7 @@ function detectV1(agent, home, scope = {}) {
|
|
|
48449
48526
|
}
|
|
48450
48527
|
|
|
48451
48528
|
// src/core/ops/plugin-root.ts
|
|
48452
|
-
import { existsSync as existsSync6, readdirSync as
|
|
48529
|
+
import { existsSync as existsSync6, readdirSync as readdirSync5, readFileSync as readFileSync6, realpathSync as realpathSync4 } from "node:fs";
|
|
48453
48530
|
import { dirname as dirname5, isAbsolute, join as join8, sep as sep2 } from "node:path";
|
|
48454
48531
|
import { fileURLToPath } from "node:url";
|
|
48455
48532
|
function missing(agent, path7) {
|
|
@@ -48549,7 +48626,7 @@ function marketplaceRoot(adapter, env, worktree) {
|
|
|
48549
48626
|
if (ownReal !== null && cacheReal !== null && ownReal.startsWith(cacheReal + sep2) && existsSync6(join8(ownReal, SERVER_ENTRY_FILE))) return ownReal;
|
|
48550
48627
|
const pattern = join8(cache, "*", PLUGIN_NAME);
|
|
48551
48628
|
if (!existsSync6(cache)) throw missing(adapter.id, pattern);
|
|
48552
|
-
const found =
|
|
48629
|
+
const found = readdirSync5(cache).sort().map((marketplace) => join8(cache, marketplace, PLUGIN_NAME)).filter((dir) => existsSync6(dir));
|
|
48553
48630
|
if (found.length !== 1) throw missing(adapter.id, found.length === 0 ? pattern : found.join(", "));
|
|
48554
48631
|
return found[0];
|
|
48555
48632
|
}
|
|
@@ -48692,10 +48769,10 @@ function codexNativeDir(env, home) {
|
|
|
48692
48769
|
const cache = join9(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
|
|
48693
48770
|
if (!existsSync7(cache)) return null;
|
|
48694
48771
|
const found = [];
|
|
48695
|
-
for (const market of
|
|
48772
|
+
for (const market of readdirSync6(cache)) {
|
|
48696
48773
|
const plugin = join9(cache, market, SERVER_KEY);
|
|
48697
48774
|
if (!existsSync7(plugin)) continue;
|
|
48698
|
-
for (const version4 of
|
|
48775
|
+
for (const version4 of readdirSync6(plugin).sort()) {
|
|
48699
48776
|
const dir = join9(plugin, version4, CODEX_PLUGIN_SUBDIR);
|
|
48700
48777
|
if (existsSync7(join9(dir, CODEX_PLUGIN_MCP_FILE))) found.push(dir);
|
|
48701
48778
|
}
|
|
@@ -49898,7 +49975,7 @@ async function hookRow(ctx, adapter, host) {
|
|
|
49898
49975
|
function ownServerId(configDir, projectKey) {
|
|
49899
49976
|
const dir = join14(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
|
|
49900
49977
|
if (!existsSync14(dir)) return "";
|
|
49901
|
-
for (const name of
|
|
49978
|
+
for (const name of readdirSync7(dir)) {
|
|
49902
49979
|
if (!name.endsWith(OWNER_PID_EXT)) continue;
|
|
49903
49980
|
if (readFileSync10(join14(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
|
|
49904
49981
|
}
|
|
@@ -50241,7 +50318,7 @@ import { existsSync as existsSync16, readFileSync as readFileSync12, statSync as
|
|
|
50241
50318
|
import { dirname as dirname9, extname, join as join17, relative as relative2, resolve as resolve5 } from "node:path";
|
|
50242
50319
|
|
|
50243
50320
|
// src/core/index/walk.ts
|
|
50244
|
-
import { readdirSync as
|
|
50321
|
+
import { readdirSync as readdirSync8, readFileSync as readFileSync11, realpathSync as realpathSync9, statSync as statSync6 } from "node:fs";
|
|
50245
50322
|
import { join as join16 } from "node:path";
|
|
50246
50323
|
var GITIGNORE = ".gitignore";
|
|
50247
50324
|
var GIT_DIR = ".git";
|
|
@@ -50256,7 +50333,7 @@ function walkDir(root, containmentRoot) {
|
|
|
50256
50333
|
function visit(abs, rel, parent, contain, seen, found) {
|
|
50257
50334
|
let entries;
|
|
50258
50335
|
try {
|
|
50259
|
-
entries =
|
|
50336
|
+
entries = readdirSync8(abs, { withFileTypes: true });
|
|
50260
50337
|
} catch {
|
|
50261
50338
|
return;
|
|
50262
50339
|
}
|
|
@@ -55280,7 +55357,7 @@ function regenerateHostConfig(row5, home, opts = {}) {
|
|
|
55280
55357
|
}
|
|
55281
55358
|
|
|
55282
55359
|
// src/core/ops/plugin-swap.ts
|
|
55283
|
-
import { existsSync as existsSync18, lstatSync, readdirSync as
|
|
55360
|
+
import { existsSync as existsSync18, lstatSync, readdirSync as readdirSync9, readlinkSync, rmSync as rmSync6, symlinkSync, unlinkSync as unlinkSync2 } from "node:fs";
|
|
55284
55361
|
import { basename as basename6, join as join19, win32 as win322 } from "node:path";
|
|
55285
55362
|
function linkTarget(path7, win) {
|
|
55286
55363
|
if (!isLink(path7)) return null;
|
|
@@ -55291,7 +55368,7 @@ function isLink(path7) {
|
|
|
55291
55368
|
return lstatSync(path7, { throwIfNoEntry: false })?.isSymbolicLink() === true;
|
|
55292
55369
|
}
|
|
55293
55370
|
function generations(agentDir) {
|
|
55294
|
-
return
|
|
55371
|
+
return readdirSync9(agentDir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).filter((name) => !name.startsWith(UPGRADE_FETCH_DIR_PREFIX) && !name.endsWith(UPGRADE_TRASH_SUFFIX)).sort();
|
|
55295
55372
|
}
|
|
55296
55373
|
function settleLinks(link, tmp, old, opts) {
|
|
55297
55374
|
if (isLink(tmp)) unlinkSync2(tmp);
|
|
@@ -55360,7 +55437,7 @@ async function fetchRelease(agent, url4, env, signal, opts = {}) {
|
|
|
55360
55437
|
}
|
|
55361
55438
|
|
|
55362
55439
|
// src/core/ops/uninstall.ts
|
|
55363
|
-
import { existsSync as existsSync20, readdirSync as
|
|
55440
|
+
import { existsSync as existsSync20, readdirSync as readdirSync10, rmSync as rmSync8, writeFileSync as writeFileSync6 } from "node:fs";
|
|
55364
55441
|
import { join as join21 } from "node:path";
|
|
55365
55442
|
function row2(area, before, after) {
|
|
55366
55443
|
return { area, before, after };
|
|
@@ -55476,7 +55553,7 @@ function removeProjectData(configDir, projectKey) {
|
|
|
55476
55553
|
const dir = join21(projects, projectKey);
|
|
55477
55554
|
if (!existsSync20(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
|
|
55478
55555
|
if (dir === projects || !isInside(projects, dir)) throw new CtxError("OUTSIDE_ROOT", { p: dir, root: projects });
|
|
55479
|
-
for (const name of
|
|
55556
|
+
for (const name of readdirSync10(dir)) {
|
|
55480
55557
|
if (name !== OWNERS_DIR_NAME) rmSync8(join21(dir, name), { recursive: true, force: true });
|
|
55481
55558
|
}
|
|
55482
55559
|
return row2(UPGRADE_DATA_AREA, dir, UPGRADE_DATA_DELETED);
|
|
@@ -55621,7 +55698,7 @@ function removeV1(agent, findings) {
|
|
|
55621
55698
|
|
|
55622
55699
|
// src/core/ops/verify-sums.ts
|
|
55623
55700
|
import { createHash as createHash2 } from "node:crypto";
|
|
55624
|
-
import { lstatSync as lstatSync2, readdirSync as
|
|
55701
|
+
import { lstatSync as lstatSync2, readdirSync as readdirSync11, readFileSync as readFileSync14 } from "node:fs";
|
|
55625
55702
|
import { join as join22 } from "node:path";
|
|
55626
55703
|
function mismatch() {
|
|
55627
55704
|
return new CtxError("BUNDLE_HASH_MISMATCH");
|
|
@@ -55640,7 +55717,7 @@ function parseSums(text) {
|
|
|
55640
55717
|
return sums;
|
|
55641
55718
|
}
|
|
55642
55719
|
function walk2(dir, prefix, out) {
|
|
55643
|
-
for (const entry of
|
|
55720
|
+
for (const entry of readdirSync11(dir, { withFileTypes: true })) {
|
|
55644
55721
|
const rel = prefix === "" ? entry.name : prefix + "/" + entry.name;
|
|
55645
55722
|
if (prefix === "" && (entry.name === GIT_DIR_NAME || entry.name === RELEASE_SUMS_FILE)) continue;
|
|
55646
55723
|
const abs = join22(dir, entry.name);
|