context-mode 2.0.0-next.37 → 2.0.0-next.38
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 +1 -1
- package/opencode/plugin.js +82 -30
- package/package.json +1 -1
- package/pi/index.js +84 -32
- package/qwen-extension.json +1 -1
- package/run.mjs +1 -1
- package/search.mjs +1 -1
- package/server.mjs +80 -28
package/pi/index.js
CHANGED
|
@@ -11570,7 +11570,7 @@ var DECISION_OPTION_KEY = "option";
|
|
|
11570
11570
|
var DECISION_LABEL_JOIN = " | ";
|
|
11571
11571
|
var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
|
|
11572
11572
|
var RELEASE_BRANCH = "release";
|
|
11573
|
-
var BUNDLE_SHA = true ? "
|
|
11573
|
+
var BUNDLE_SHA = true ? "ede83923546ab97898750ef7cebe34cf82e9534c" : void 0;
|
|
11574
11574
|
var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
|
|
11575
11575
|
var DOCTOR_LABEL = Object.freeze({
|
|
11576
11576
|
D1: "version",
|
|
@@ -14896,7 +14896,7 @@ var TOOL_DESCRIPTIONS = Object.freeze({
|
|
|
14896
14896
|
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.',
|
|
14897
14897
|
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.',
|
|
14898
14898
|
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.',
|
|
14899
|
-
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.',
|
|
14899
|
+
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.',
|
|
14900
14900
|
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.",
|
|
14901
14901
|
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.",
|
|
14902
14902
|
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",
|
|
@@ -20232,17 +20232,29 @@ function runProcess(argv, o) {
|
|
|
20232
20232
|
}
|
|
20233
20233
|
|
|
20234
20234
|
// src/core/index/auto-memory.ts
|
|
20235
|
-
import { readFileSync as readFileSync5, statSync as statSync4 } from "node:fs";
|
|
20235
|
+
import { readdirSync, readFileSync as readFileSync5, statSync as statSync4 } from "node:fs";
|
|
20236
20236
|
import { join as join7 } from "node:path";
|
|
20237
|
-
var
|
|
20237
|
+
var MEMORY_FILES = Object.freeze([
|
|
20238
20238
|
Object.freeze(["CLAUDE.md"]),
|
|
20239
20239
|
Object.freeze(["CLAUDE.local.md"]),
|
|
20240
|
-
Object.freeze([".claude", "CLAUDE.md"])
|
|
20240
|
+
Object.freeze([".claude", "CLAUDE.md"]),
|
|
20241
|
+
Object.freeze(["AGENTS.md"]),
|
|
20242
|
+
Object.freeze(["GEMINI.md"]),
|
|
20243
|
+
Object.freeze(["QWEN.md"]),
|
|
20244
|
+
Object.freeze([".github", "copilot-instructions.md"])
|
|
20241
20245
|
]);
|
|
20246
|
+
var KIRO_STEERING = Object.freeze([".kiro", "steering"]);
|
|
20247
|
+
var MD = ".md";
|
|
20248
|
+
function steeringFiles(worktree) {
|
|
20249
|
+
try {
|
|
20250
|
+
return readdirSync(join7(worktree, ...KIRO_STEERING)).filter((n) => n.endsWith(MD)).sort().map((n) => [...KIRO_STEERING, n]);
|
|
20251
|
+
} catch {
|
|
20252
|
+
return [];
|
|
20253
|
+
}
|
|
20254
|
+
}
|
|
20242
20255
|
function readAutoMemory(project) {
|
|
20243
|
-
if (project.agent !== "claude-code") return [];
|
|
20244
20256
|
const rows = [];
|
|
20245
|
-
for (const segs of
|
|
20257
|
+
for (const segs of [...MEMORY_FILES, ...steeringFiles(project.worktree)]) {
|
|
20246
20258
|
const path7 = join7(project.worktree, ...segs);
|
|
20247
20259
|
if (!isInside(project.worktree, path7)) continue;
|
|
20248
20260
|
try {
|
|
@@ -20262,6 +20274,20 @@ function readAutoMemory(project) {
|
|
|
20262
20274
|
}
|
|
20263
20275
|
return rows;
|
|
20264
20276
|
}
|
|
20277
|
+
function memoryChunks(rows) {
|
|
20278
|
+
const out = [];
|
|
20279
|
+
rows.forEach((r, i) => {
|
|
20280
|
+
for (const c of chunkText(r.text, "md")) out.push({ fileNo: i + 1, label: r.label, ord: c.ord, text: c.text });
|
|
20281
|
+
});
|
|
20282
|
+
return out;
|
|
20283
|
+
}
|
|
20284
|
+
function memoryHits(chunks, q, limit) {
|
|
20285
|
+
if (chunks.length === 0) return [];
|
|
20286
|
+
const texts = chunks.map((c) => c.text);
|
|
20287
|
+
const any3 = rankTexts(texts, q, "any");
|
|
20288
|
+
const all = rankTexts(texts, q, "all");
|
|
20289
|
+
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 " + e.c.label, ord: e.c.ord, snippet: highlight(e.c.text, q, SNIPPET_MAX_BYTES), score: e.s, full: e.full }));
|
|
20290
|
+
}
|
|
20265
20291
|
|
|
20266
20292
|
// src/core/tools/search.ts
|
|
20267
20293
|
function unknownField(issue4) {
|
|
@@ -20399,11 +20425,37 @@ function replyHits(hits, size) {
|
|
|
20399
20425
|
while (n < size && n < hits.length && hits[n].full === true) n++;
|
|
20400
20426
|
return n;
|
|
20401
20427
|
}
|
|
20428
|
+
var MEMORY_HITS = 2;
|
|
20429
|
+
function mergeMemory(content, memory) {
|
|
20430
|
+
const out = [];
|
|
20431
|
+
let c = 0;
|
|
20432
|
+
let m = 0;
|
|
20433
|
+
let lastMem = true;
|
|
20434
|
+
while (c < content.length || m < memory.length) {
|
|
20435
|
+
const rank = (h) => h === void 0 ? -1 : h.full === true ? 1 : 0;
|
|
20436
|
+
const rc = rank(content[c]);
|
|
20437
|
+
const rm = rank(memory[m]);
|
|
20438
|
+
const mem = rc < 0 || rm > rc || rm === rc && !lastMem;
|
|
20439
|
+
if (mem) {
|
|
20440
|
+
out.push(memory[m++]);
|
|
20441
|
+
lastMem = true;
|
|
20442
|
+
} else {
|
|
20443
|
+
out.push(content[c++]);
|
|
20444
|
+
lastMem = false;
|
|
20445
|
+
}
|
|
20446
|
+
}
|
|
20447
|
+
return out;
|
|
20448
|
+
}
|
|
20449
|
+
var contentIn = (hits, n) => hits.slice(0, n).filter((h) => h.sourceId > 0).length;
|
|
20402
20450
|
function relevance(db, given, scope, ctx, nm) {
|
|
20403
20451
|
const input = { ...given, queries: decisionQueries(given) };
|
|
20404
20452
|
const offset = input.offset ?? 0;
|
|
20405
20453
|
const size = pageSize(input);
|
|
20406
|
-
const
|
|
20454
|
+
const mem = offset === 0 && scope !== "session" && input.source === void 0 ? memoryChunks(readAutoMemory(ctx.project)) : [];
|
|
20455
|
+
const fetched = input.queries.map((q) => {
|
|
20456
|
+
const content = page(db, q, input, scope, ctx, offset, 1);
|
|
20457
|
+
return mem.length === 0 ? content : mergeMemory(content, memoryHits(mem, q, MEMORY_HITS));
|
|
20458
|
+
});
|
|
20407
20459
|
const take = fetched.map((h) => replyHits(h, size));
|
|
20408
20460
|
const pages = fetched.map((h, i) => h.slice(0, take[i]));
|
|
20409
20461
|
if (pages.every((p) => p.length === 0)) return zeroHits(db, scope, ctx, input.source, offset);
|
|
@@ -20439,13 +20491,13 @@ function relevance(db, given, scope, ctx, nm) {
|
|
|
20439
20491
|
}
|
|
20440
20492
|
const line = shownLabel(hit.label, hit.sourceId) + " #" + hit.ord + ": " + hit.snippet;
|
|
20441
20493
|
if (used + bytes2(line) + 1 + reserve > OUTPUT_CAP) {
|
|
20442
|
-
cut = offset + i;
|
|
20494
|
+
cut = offset + contentIn(hits, i);
|
|
20443
20495
|
stopped = true;
|
|
20444
20496
|
break;
|
|
20445
20497
|
}
|
|
20446
20498
|
const room = total.get(hit.sourceId);
|
|
20447
20499
|
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) {
|
|
20448
|
-
cut = offset + i;
|
|
20500
|
+
cut = offset + contentIn(hits, i);
|
|
20449
20501
|
break;
|
|
20450
20502
|
}
|
|
20451
20503
|
lines.push(line);
|
|
@@ -20460,7 +20512,7 @@ function relevance(db, given, scope, ctx, nm) {
|
|
|
20460
20512
|
used += bytes2(line) + 1;
|
|
20461
20513
|
}
|
|
20462
20514
|
if (cut >= 0) more.push({ q, pos: cut });
|
|
20463
|
-
else if (fetched[qi].length > take[qi]) more.push({ q, pos: offset + take[qi] });
|
|
20515
|
+
else if (contentIn(fetched[qi], fetched[qi].length) > contentIn(fetched[qi], take[qi])) more.push({ q, pos: offset + contentIn(fetched[qi], take[qi]) });
|
|
20464
20516
|
});
|
|
20465
20517
|
const moreLines = [];
|
|
20466
20518
|
const byPos = /* @__PURE__ */ new Map();
|
|
@@ -20761,15 +20813,15 @@ var ctxBatch = Object.freeze({
|
|
|
20761
20813
|
});
|
|
20762
20814
|
|
|
20763
20815
|
// src/core/tools/doctor.ts
|
|
20764
|
-
import { readdirSync as
|
|
20816
|
+
import { readdirSync as readdirSync6, readFileSync as readFileSync13, existsSync as existsSync13 } from "node:fs";
|
|
20765
20817
|
import { basename as basename5, dirname as dirname8, join as join16 } from "node:path";
|
|
20766
20818
|
|
|
20767
20819
|
// src/core/ops/doctor-config.ts
|
|
20768
|
-
import { existsSync as existsSync6, readdirSync as
|
|
20820
|
+
import { existsSync as existsSync6, readdirSync as readdirSync4 } from "node:fs";
|
|
20769
20821
|
import { join as join11 } from "node:path";
|
|
20770
20822
|
|
|
20771
20823
|
// src/core/ops/detect-v1.ts
|
|
20772
|
-
import { existsSync as existsSync4, opendirSync, readdirSync, readFileSync as readFileSync7 } from "node:fs";
|
|
20824
|
+
import { existsSync as existsSync4, opendirSync, readdirSync as readdirSync2, readFileSync as readFileSync7 } from "node:fs";
|
|
20773
20825
|
import { tmpdir } from "node:os";
|
|
20774
20826
|
import { join as join9 } from "node:path";
|
|
20775
20827
|
|
|
@@ -23489,7 +23541,7 @@ function scanVscode(agentHome, project, out) {
|
|
|
23489
23541
|
}
|
|
23490
23542
|
function jsonFiles(dir) {
|
|
23491
23543
|
try {
|
|
23492
|
-
return
|
|
23544
|
+
return readdirSync2(dir).filter((name) => name.endsWith(KIRO_AGENT_FILE_EXT)).sort();
|
|
23493
23545
|
} catch {
|
|
23494
23546
|
return [];
|
|
23495
23547
|
}
|
|
@@ -23615,7 +23667,7 @@ function detectV1(agent, home, scope = {}) {
|
|
|
23615
23667
|
}
|
|
23616
23668
|
|
|
23617
23669
|
// src/core/ops/plugin-root.ts
|
|
23618
|
-
import { existsSync as existsSync5, readdirSync as
|
|
23670
|
+
import { existsSync as existsSync5, readdirSync as readdirSync3, readFileSync as readFileSync8, realpathSync as realpathSync4 } from "node:fs";
|
|
23619
23671
|
import { dirname as dirname6, isAbsolute as isAbsolute2, join as join10, sep as sep3 } from "node:path";
|
|
23620
23672
|
import { fileURLToPath } from "node:url";
|
|
23621
23673
|
function missing(agent, path7) {
|
|
@@ -23715,7 +23767,7 @@ function marketplaceRoot(adapter, env, worktree) {
|
|
|
23715
23767
|
if (ownReal !== null && cacheReal !== null && ownReal.startsWith(cacheReal + sep3) && existsSync5(join10(ownReal, SERVER_ENTRY_FILE))) return ownReal;
|
|
23716
23768
|
const pattern = join10(cache, "*", PLUGIN_NAME);
|
|
23717
23769
|
if (!existsSync5(cache)) throw missing(adapter.id, pattern);
|
|
23718
|
-
const found =
|
|
23770
|
+
const found = readdirSync3(cache).sort().map((marketplace) => join10(cache, marketplace, PLUGIN_NAME)).filter((dir) => existsSync5(dir));
|
|
23719
23771
|
if (found.length !== 1) throw missing(adapter.id, found.length === 0 ? pattern : found.join(", "));
|
|
23720
23772
|
return found[0];
|
|
23721
23773
|
}
|
|
@@ -23858,10 +23910,10 @@ function codexNativeDir(env, home) {
|
|
|
23858
23910
|
const cache = join11(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
|
|
23859
23911
|
if (!existsSync6(cache)) return null;
|
|
23860
23912
|
const found = [];
|
|
23861
|
-
for (const market of
|
|
23913
|
+
for (const market of readdirSync4(cache)) {
|
|
23862
23914
|
const plugin = join11(cache, market, SERVER_KEY);
|
|
23863
23915
|
if (!existsSync6(plugin)) continue;
|
|
23864
|
-
for (const version4 of
|
|
23916
|
+
for (const version4 of readdirSync4(plugin).sort()) {
|
|
23865
23917
|
const dir = join11(plugin, version4, CODEX_PLUGIN_SUBDIR);
|
|
23866
23918
|
if (existsSync6(join11(dir, CODEX_PLUGIN_MCP_FILE))) found.push(dir);
|
|
23867
23919
|
}
|
|
@@ -24636,7 +24688,7 @@ import { existsSync as existsSync11, mkdirSync as mkdirSync5, rmSync as rmSync3
|
|
|
24636
24688
|
import { basename as basename4, dirname as dirname7, join as join14 } from "node:path";
|
|
24637
24689
|
|
|
24638
24690
|
// src/core/store/owners.ts
|
|
24639
|
-
import { mkdirSync as mkdirSync4, readdirSync as
|
|
24691
|
+
import { mkdirSync as mkdirSync4, readdirSync as readdirSync5, readFileSync as readFileSync11, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
24640
24692
|
import { basename as basename3, join as join13 } from "node:path";
|
|
24641
24693
|
function ownersDir(configDir, projectKey) {
|
|
24642
24694
|
return join13(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
|
|
@@ -24669,7 +24721,7 @@ function listLiveOwners(configDir, projectKey) {
|
|
|
24669
24721
|
const dir = ownersDir(configDir, projectKey);
|
|
24670
24722
|
let names;
|
|
24671
24723
|
try {
|
|
24672
|
-
names =
|
|
24724
|
+
names = readdirSync5(dir);
|
|
24673
24725
|
} catch (err) {
|
|
24674
24726
|
if (errCode2(err) === "ENOENT") return [];
|
|
24675
24727
|
throw err;
|
|
@@ -25067,7 +25119,7 @@ async function hookRow(ctx, adapter, host) {
|
|
|
25067
25119
|
function ownServerId(configDir, projectKey) {
|
|
25068
25120
|
const dir = join16(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
|
|
25069
25121
|
if (!existsSync13(dir)) return "";
|
|
25070
|
-
for (const name of
|
|
25122
|
+
for (const name of readdirSync6(dir)) {
|
|
25071
25123
|
if (!name.endsWith(OWNER_PID_EXT)) continue;
|
|
25072
25124
|
if (readFileSync13(join16(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
|
|
25073
25125
|
}
|
|
@@ -25371,7 +25423,7 @@ import { existsSync as existsSync15, readFileSync as readFileSync15, statSync as
|
|
|
25371
25423
|
import { dirname as dirname10, extname, join as join19, relative as relative3, resolve as resolve7 } from "node:path";
|
|
25372
25424
|
|
|
25373
25425
|
// src/core/index/walk.ts
|
|
25374
|
-
import { readdirSync as
|
|
25426
|
+
import { readdirSync as readdirSync7, readFileSync as readFileSync14, realpathSync as realpathSync9, statSync as statSync7 } from "node:fs";
|
|
25375
25427
|
import { join as join18 } from "node:path";
|
|
25376
25428
|
var GITIGNORE = ".gitignore";
|
|
25377
25429
|
var GIT_DIR = ".git";
|
|
@@ -25386,7 +25438,7 @@ function walkDir(root, containmentRoot) {
|
|
|
25386
25438
|
function visit(abs, rel, parent, contain, seen, found) {
|
|
25387
25439
|
let entries;
|
|
25388
25440
|
try {
|
|
25389
|
-
entries =
|
|
25441
|
+
entries = readdirSync7(abs, { withFileTypes: true });
|
|
25390
25442
|
} catch {
|
|
25391
25443
|
return;
|
|
25392
25444
|
}
|
|
@@ -30145,7 +30197,7 @@ function regenerateHostConfig(row5, home, opts = {}) {
|
|
|
30145
30197
|
}
|
|
30146
30198
|
|
|
30147
30199
|
// src/core/ops/plugin-swap.ts
|
|
30148
|
-
import { existsSync as existsSync17, lstatSync, readdirSync as
|
|
30200
|
+
import { existsSync as existsSync17, lstatSync, readdirSync as readdirSync8, readlinkSync, rmSync as rmSync5, symlinkSync, unlinkSync as unlinkSync2 } from "node:fs";
|
|
30149
30201
|
import { basename as basename6, join as join21, win32 as win322 } from "node:path";
|
|
30150
30202
|
function linkTarget(path7, win) {
|
|
30151
30203
|
if (!isLink(path7)) return null;
|
|
@@ -30156,7 +30208,7 @@ function isLink(path7) {
|
|
|
30156
30208
|
return lstatSync(path7, { throwIfNoEntry: false })?.isSymbolicLink() === true;
|
|
30157
30209
|
}
|
|
30158
30210
|
function generations(agentDir) {
|
|
30159
|
-
return
|
|
30211
|
+
return readdirSync8(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();
|
|
30160
30212
|
}
|
|
30161
30213
|
function settleLinks(link, tmp, old, opts) {
|
|
30162
30214
|
if (isLink(tmp)) unlinkSync2(tmp);
|
|
@@ -30225,7 +30277,7 @@ async function fetchRelease(agent, url4, env, signal, opts = {}) {
|
|
|
30225
30277
|
}
|
|
30226
30278
|
|
|
30227
30279
|
// src/core/ops/uninstall.ts
|
|
30228
|
-
import { existsSync as existsSync19, readdirSync as
|
|
30280
|
+
import { existsSync as existsSync19, readdirSync as readdirSync9, rmSync as rmSync7, writeFileSync as writeFileSync6 } from "node:fs";
|
|
30229
30281
|
import { join as join23 } from "node:path";
|
|
30230
30282
|
function row2(area, before, after) {
|
|
30231
30283
|
return { area, before, after };
|
|
@@ -30341,7 +30393,7 @@ function removeProjectData(configDir, projectKey) {
|
|
|
30341
30393
|
const dir = join23(projects, projectKey);
|
|
30342
30394
|
if (!existsSync19(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
|
|
30343
30395
|
if (dir === projects || !isInside(projects, dir)) throw new CtxError("OUTSIDE_ROOT", { p: dir, root: projects });
|
|
30344
|
-
for (const name of
|
|
30396
|
+
for (const name of readdirSync9(dir)) {
|
|
30345
30397
|
if (name !== OWNERS_DIR_NAME) rmSync7(join23(dir, name), { recursive: true, force: true });
|
|
30346
30398
|
}
|
|
30347
30399
|
return row2(UPGRADE_DATA_AREA, dir, UPGRADE_DATA_DELETED);
|
|
@@ -30486,7 +30538,7 @@ function removeV1(agent, findings) {
|
|
|
30486
30538
|
|
|
30487
30539
|
// src/core/ops/verify-sums.ts
|
|
30488
30540
|
import { createHash as createHash2 } from "node:crypto";
|
|
30489
|
-
import { lstatSync as lstatSync2, readdirSync as
|
|
30541
|
+
import { lstatSync as lstatSync2, readdirSync as readdirSync10, readFileSync as readFileSync17 } from "node:fs";
|
|
30490
30542
|
import { join as join24 } from "node:path";
|
|
30491
30543
|
function mismatch() {
|
|
30492
30544
|
return new CtxError("BUNDLE_HASH_MISMATCH");
|
|
@@ -30505,7 +30557,7 @@ function parseSums(text) {
|
|
|
30505
30557
|
return sums;
|
|
30506
30558
|
}
|
|
30507
30559
|
function walk3(dir, prefix, out) {
|
|
30508
|
-
for (const entry of
|
|
30560
|
+
for (const entry of readdirSync10(dir, { withFileTypes: true })) {
|
|
30509
30561
|
const rel = prefix === "" ? entry.name : prefix + "/" + entry.name;
|
|
30510
30562
|
if (prefix === "" && (entry.name === GIT_DIR_NAME || entry.name === RELEASE_SUMS_FILE)) continue;
|
|
30511
30563
|
const abs = join24(dir, entry.name);
|
|
@@ -58740,7 +58792,7 @@ function installExitGuard(opts) {
|
|
|
58740
58792
|
}
|
|
58741
58793
|
|
|
58742
58794
|
// src/core/store/cleanup.ts
|
|
58743
|
-
import { existsSync as existsSync22, readdirSync as
|
|
58795
|
+
import { existsSync as existsSync22, readdirSync as readdirSync11, rmSync as rmSync10 } from "node:fs";
|
|
58744
58796
|
import { join as join26 } from "node:path";
|
|
58745
58797
|
function deleteSource(raw, id) {
|
|
58746
58798
|
raw.prepare("DELETE FROM sources WHERE id = ?").run(id);
|
|
@@ -58811,7 +58863,7 @@ function sweepOne(configDir, projectKey, cutoff) {
|
|
|
58811
58863
|
function sweepDeadProjects(configDir) {
|
|
58812
58864
|
let entries;
|
|
58813
58865
|
try {
|
|
58814
|
-
entries =
|
|
58866
|
+
entries = readdirSync11(join26(configDir, PROJECTS_DIR_NAME), { withFileTypes: true });
|
|
58815
58867
|
} catch (err) {
|
|
58816
58868
|
if (err.code === "ENOENT") return [];
|
|
58817
58869
|
throw err;
|
package/qwen-extension.json
CHANGED
package/run.mjs
CHANGED
|
@@ -5019,7 +5019,7 @@ var TOOL_DESCRIPTIONS = Object.freeze({
|
|
|
5019
5019
|
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.',
|
|
5020
5020
|
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.',
|
|
5021
5021
|
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.',
|
|
5022
|
-
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.',
|
|
5022
|
+
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.',
|
|
5023
5023
|
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.",
|
|
5024
5024
|
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.",
|
|
5025
5025
|
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",
|
package/search.mjs
CHANGED
|
@@ -5019,7 +5019,7 @@ var TOOL_DESCRIPTIONS = Object.freeze({
|
|
|
5019
5019
|
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.',
|
|
5020
5020
|
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.',
|
|
5021
5021
|
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.',
|
|
5022
|
-
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.',
|
|
5022
|
+
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.',
|
|
5023
5023
|
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.",
|
|
5024
5024
|
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.",
|
|
5025
5025
|
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",
|
package/server.mjs
CHANGED
|
@@ -28405,7 +28405,7 @@ var DECISION_SOURCE = "decision";
|
|
|
28405
28405
|
var DECISION_USER_LABEL = "decision (user)";
|
|
28406
28406
|
var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
|
|
28407
28407
|
var RELEASE_BRANCH = "release";
|
|
28408
|
-
var BUNDLE_SHA = true ? "
|
|
28408
|
+
var BUNDLE_SHA = true ? "ede83923546ab97898750ef7cebe34cf82e9534c" : void 0;
|
|
28409
28409
|
var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
|
|
28410
28410
|
var DOCTOR_LABEL = Object.freeze({
|
|
28411
28411
|
D1: "version",
|
|
@@ -43538,7 +43538,7 @@ var TOOL_DESCRIPTIONS = Object.freeze({
|
|
|
43538
43538
|
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
43539
|
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
43540
|
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.',
|
|
43541
|
+
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
43542
|
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
43543
|
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
43544
|
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 +44103,29 @@ function runProcess(argv, o) {
|
|
|
44103
44103
|
}
|
|
44104
44104
|
|
|
44105
44105
|
// src/core/index/auto-memory.ts
|
|
44106
|
-
import { readFileSync as readFileSync3, statSync as statSync3 } from "node:fs";
|
|
44106
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync3, statSync as statSync3 } from "node:fs";
|
|
44107
44107
|
import { join as join5 } from "node:path";
|
|
44108
|
-
var
|
|
44108
|
+
var MEMORY_FILES = Object.freeze([
|
|
44109
44109
|
Object.freeze(["CLAUDE.md"]),
|
|
44110
44110
|
Object.freeze(["CLAUDE.local.md"]),
|
|
44111
|
-
Object.freeze([".claude", "CLAUDE.md"])
|
|
44111
|
+
Object.freeze([".claude", "CLAUDE.md"]),
|
|
44112
|
+
Object.freeze(["AGENTS.md"]),
|
|
44113
|
+
Object.freeze(["GEMINI.md"]),
|
|
44114
|
+
Object.freeze(["QWEN.md"]),
|
|
44115
|
+
Object.freeze([".github", "copilot-instructions.md"])
|
|
44112
44116
|
]);
|
|
44117
|
+
var KIRO_STEERING = Object.freeze([".kiro", "steering"]);
|
|
44118
|
+
var MD = ".md";
|
|
44119
|
+
function steeringFiles(worktree) {
|
|
44120
|
+
try {
|
|
44121
|
+
return readdirSync3(join5(worktree, ...KIRO_STEERING)).filter((n) => n.endsWith(MD)).sort().map((n) => [...KIRO_STEERING, n]);
|
|
44122
|
+
} catch {
|
|
44123
|
+
return [];
|
|
44124
|
+
}
|
|
44125
|
+
}
|
|
44113
44126
|
function readAutoMemory(project) {
|
|
44114
|
-
if (project.agent !== "claude-code") return [];
|
|
44115
44127
|
const rows = [];
|
|
44116
|
-
for (const segs of
|
|
44128
|
+
for (const segs of [...MEMORY_FILES, ...steeringFiles(project.worktree)]) {
|
|
44117
44129
|
const path7 = join5(project.worktree, ...segs);
|
|
44118
44130
|
if (!isInside(project.worktree, path7)) continue;
|
|
44119
44131
|
try {
|
|
@@ -44133,6 +44145,20 @@ function readAutoMemory(project) {
|
|
|
44133
44145
|
}
|
|
44134
44146
|
return rows;
|
|
44135
44147
|
}
|
|
44148
|
+
function memoryChunks(rows) {
|
|
44149
|
+
const out = [];
|
|
44150
|
+
rows.forEach((r, i) => {
|
|
44151
|
+
for (const c of chunkText(r.text, "md")) out.push({ fileNo: i + 1, label: r.label, ord: c.ord, text: c.text });
|
|
44152
|
+
});
|
|
44153
|
+
return out;
|
|
44154
|
+
}
|
|
44155
|
+
function memoryHits(chunks, q, limit) {
|
|
44156
|
+
if (chunks.length === 0) return [];
|
|
44157
|
+
const texts = chunks.map((c) => c.text);
|
|
44158
|
+
const any3 = rankTexts(texts, q, "any");
|
|
44159
|
+
const all = rankTexts(texts, q, "all");
|
|
44160
|
+
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 " + e.c.label, ord: e.c.ord, snippet: highlight(e.c.text, q, SNIPPET_MAX_BYTES), score: e.s, full: e.full }));
|
|
44161
|
+
}
|
|
44136
44162
|
|
|
44137
44163
|
// src/core/index/shape.ts
|
|
44138
44164
|
var SHAPE_MIN_ROWS = 20;
|
|
@@ -44324,11 +44350,37 @@ function replyHits(hits, size) {
|
|
|
44324
44350
|
while (n < size && n < hits.length && hits[n].full === true) n++;
|
|
44325
44351
|
return n;
|
|
44326
44352
|
}
|
|
44353
|
+
var MEMORY_HITS = 2;
|
|
44354
|
+
function mergeMemory(content, memory) {
|
|
44355
|
+
const out = [];
|
|
44356
|
+
let c = 0;
|
|
44357
|
+
let m = 0;
|
|
44358
|
+
let lastMem = true;
|
|
44359
|
+
while (c < content.length || m < memory.length) {
|
|
44360
|
+
const rank = (h) => h === void 0 ? -1 : h.full === true ? 1 : 0;
|
|
44361
|
+
const rc = rank(content[c]);
|
|
44362
|
+
const rm = rank(memory[m]);
|
|
44363
|
+
const mem = rc < 0 || rm > rc || rm === rc && !lastMem;
|
|
44364
|
+
if (mem) {
|
|
44365
|
+
out.push(memory[m++]);
|
|
44366
|
+
lastMem = true;
|
|
44367
|
+
} else {
|
|
44368
|
+
out.push(content[c++]);
|
|
44369
|
+
lastMem = false;
|
|
44370
|
+
}
|
|
44371
|
+
}
|
|
44372
|
+
return out;
|
|
44373
|
+
}
|
|
44374
|
+
var contentIn = (hits, n) => hits.slice(0, n).filter((h) => h.sourceId > 0).length;
|
|
44327
44375
|
function relevance(db, given, scope, ctx, nm) {
|
|
44328
44376
|
const input = { ...given, queries: decisionQueries(given) };
|
|
44329
44377
|
const offset = input.offset ?? 0;
|
|
44330
44378
|
const size = pageSize(input);
|
|
44331
|
-
const
|
|
44379
|
+
const mem = offset === 0 && scope !== "session" && input.source === void 0 ? memoryChunks(readAutoMemory(ctx.project)) : [];
|
|
44380
|
+
const fetched = input.queries.map((q) => {
|
|
44381
|
+
const content = page(db, q, input, scope, ctx, offset, 1);
|
|
44382
|
+
return mem.length === 0 ? content : mergeMemory(content, memoryHits(mem, q, MEMORY_HITS));
|
|
44383
|
+
});
|
|
44332
44384
|
const take = fetched.map((h) => replyHits(h, size));
|
|
44333
44385
|
const pages = fetched.map((h, i) => h.slice(0, take[i]));
|
|
44334
44386
|
if (pages.every((p) => p.length === 0)) return zeroHits(db, scope, ctx, input.source, offset);
|
|
@@ -44364,13 +44416,13 @@ function relevance(db, given, scope, ctx, nm) {
|
|
|
44364
44416
|
}
|
|
44365
44417
|
const line = shownLabel(hit.label, hit.sourceId) + " #" + hit.ord + ": " + hit.snippet;
|
|
44366
44418
|
if (used + bytes2(line) + 1 + reserve > OUTPUT_CAP) {
|
|
44367
|
-
cut = offset + i;
|
|
44419
|
+
cut = offset + contentIn(hits, i);
|
|
44368
44420
|
stopped = true;
|
|
44369
44421
|
break;
|
|
44370
44422
|
}
|
|
44371
44423
|
const room = total.get(hit.sourceId);
|
|
44372
44424
|
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;
|
|
44425
|
+
cut = offset + contentIn(hits, i);
|
|
44374
44426
|
break;
|
|
44375
44427
|
}
|
|
44376
44428
|
lines.push(line);
|
|
@@ -44385,7 +44437,7 @@ function relevance(db, given, scope, ctx, nm) {
|
|
|
44385
44437
|
used += bytes2(line) + 1;
|
|
44386
44438
|
}
|
|
44387
44439
|
if (cut >= 0) more.push({ q, pos: cut });
|
|
44388
|
-
else if (fetched[qi].length > take[qi]) more.push({ q, pos: offset + take[qi] });
|
|
44440
|
+
else if (contentIn(fetched[qi], fetched[qi].length) > contentIn(fetched[qi], take[qi])) more.push({ q, pos: offset + contentIn(fetched[qi], take[qi]) });
|
|
44389
44441
|
});
|
|
44390
44442
|
const moreLines = [];
|
|
44391
44443
|
const byPos = /* @__PURE__ */ new Map();
|
|
@@ -44686,7 +44738,7 @@ var ctxBatch = Object.freeze({
|
|
|
44686
44738
|
});
|
|
44687
44739
|
|
|
44688
44740
|
// src/core/tools/doctor.ts
|
|
44689
|
-
import { readdirSync as
|
|
44741
|
+
import { readdirSync as readdirSync7, readFileSync as readFileSync10, existsSync as existsSync14 } from "node:fs";
|
|
44690
44742
|
import { basename as basename5, dirname as dirname7, join as join14 } from "node:path";
|
|
44691
44743
|
|
|
44692
44744
|
// src/adapters/claude-code.ts
|
|
@@ -45576,11 +45628,11 @@ function getAdapter(id) {
|
|
|
45576
45628
|
}
|
|
45577
45629
|
|
|
45578
45630
|
// src/core/ops/doctor-config.ts
|
|
45579
|
-
import { existsSync as existsSync7, readdirSync as
|
|
45631
|
+
import { existsSync as existsSync7, readdirSync as readdirSync6 } from "node:fs";
|
|
45580
45632
|
import { join as join9 } from "node:path";
|
|
45581
45633
|
|
|
45582
45634
|
// src/core/ops/detect-v1.ts
|
|
45583
|
-
import { existsSync as existsSync5, opendirSync, readdirSync as
|
|
45635
|
+
import { existsSync as existsSync5, opendirSync, readdirSync as readdirSync4, readFileSync as readFileSync5 } from "node:fs";
|
|
45584
45636
|
import { tmpdir } from "node:os";
|
|
45585
45637
|
import { join as join7 } from "node:path";
|
|
45586
45638
|
|
|
@@ -48323,7 +48375,7 @@ function scanVscode(agentHome, project, out) {
|
|
|
48323
48375
|
}
|
|
48324
48376
|
function jsonFiles(dir) {
|
|
48325
48377
|
try {
|
|
48326
|
-
return
|
|
48378
|
+
return readdirSync4(dir).filter((name) => name.endsWith(KIRO_AGENT_FILE_EXT)).sort();
|
|
48327
48379
|
} catch {
|
|
48328
48380
|
return [];
|
|
48329
48381
|
}
|
|
@@ -48449,7 +48501,7 @@ function detectV1(agent, home, scope = {}) {
|
|
|
48449
48501
|
}
|
|
48450
48502
|
|
|
48451
48503
|
// src/core/ops/plugin-root.ts
|
|
48452
|
-
import { existsSync as existsSync6, readdirSync as
|
|
48504
|
+
import { existsSync as existsSync6, readdirSync as readdirSync5, readFileSync as readFileSync6, realpathSync as realpathSync4 } from "node:fs";
|
|
48453
48505
|
import { dirname as dirname5, isAbsolute, join as join8, sep as sep2 } from "node:path";
|
|
48454
48506
|
import { fileURLToPath } from "node:url";
|
|
48455
48507
|
function missing(agent, path7) {
|
|
@@ -48549,7 +48601,7 @@ function marketplaceRoot(adapter, env, worktree) {
|
|
|
48549
48601
|
if (ownReal !== null && cacheReal !== null && ownReal.startsWith(cacheReal + sep2) && existsSync6(join8(ownReal, SERVER_ENTRY_FILE))) return ownReal;
|
|
48550
48602
|
const pattern = join8(cache, "*", PLUGIN_NAME);
|
|
48551
48603
|
if (!existsSync6(cache)) throw missing(adapter.id, pattern);
|
|
48552
|
-
const found =
|
|
48604
|
+
const found = readdirSync5(cache).sort().map((marketplace) => join8(cache, marketplace, PLUGIN_NAME)).filter((dir) => existsSync6(dir));
|
|
48553
48605
|
if (found.length !== 1) throw missing(adapter.id, found.length === 0 ? pattern : found.join(", "));
|
|
48554
48606
|
return found[0];
|
|
48555
48607
|
}
|
|
@@ -48692,10 +48744,10 @@ function codexNativeDir(env, home) {
|
|
|
48692
48744
|
const cache = join9(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
|
|
48693
48745
|
if (!existsSync7(cache)) return null;
|
|
48694
48746
|
const found = [];
|
|
48695
|
-
for (const market of
|
|
48747
|
+
for (const market of readdirSync6(cache)) {
|
|
48696
48748
|
const plugin = join9(cache, market, SERVER_KEY);
|
|
48697
48749
|
if (!existsSync7(plugin)) continue;
|
|
48698
|
-
for (const version4 of
|
|
48750
|
+
for (const version4 of readdirSync6(plugin).sort()) {
|
|
48699
48751
|
const dir = join9(plugin, version4, CODEX_PLUGIN_SUBDIR);
|
|
48700
48752
|
if (existsSync7(join9(dir, CODEX_PLUGIN_MCP_FILE))) found.push(dir);
|
|
48701
48753
|
}
|
|
@@ -49898,7 +49950,7 @@ async function hookRow(ctx, adapter, host) {
|
|
|
49898
49950
|
function ownServerId(configDir, projectKey) {
|
|
49899
49951
|
const dir = join14(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
|
|
49900
49952
|
if (!existsSync14(dir)) return "";
|
|
49901
|
-
for (const name of
|
|
49953
|
+
for (const name of readdirSync7(dir)) {
|
|
49902
49954
|
if (!name.endsWith(OWNER_PID_EXT)) continue;
|
|
49903
49955
|
if (readFileSync10(join14(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
|
|
49904
49956
|
}
|
|
@@ -50241,7 +50293,7 @@ import { existsSync as existsSync16, readFileSync as readFileSync12, statSync as
|
|
|
50241
50293
|
import { dirname as dirname9, extname, join as join17, relative as relative2, resolve as resolve5 } from "node:path";
|
|
50242
50294
|
|
|
50243
50295
|
// src/core/index/walk.ts
|
|
50244
|
-
import { readdirSync as
|
|
50296
|
+
import { readdirSync as readdirSync8, readFileSync as readFileSync11, realpathSync as realpathSync9, statSync as statSync6 } from "node:fs";
|
|
50245
50297
|
import { join as join16 } from "node:path";
|
|
50246
50298
|
var GITIGNORE = ".gitignore";
|
|
50247
50299
|
var GIT_DIR = ".git";
|
|
@@ -50256,7 +50308,7 @@ function walkDir(root, containmentRoot) {
|
|
|
50256
50308
|
function visit(abs, rel, parent, contain, seen, found) {
|
|
50257
50309
|
let entries;
|
|
50258
50310
|
try {
|
|
50259
|
-
entries =
|
|
50311
|
+
entries = readdirSync8(abs, { withFileTypes: true });
|
|
50260
50312
|
} catch {
|
|
50261
50313
|
return;
|
|
50262
50314
|
}
|
|
@@ -55280,7 +55332,7 @@ function regenerateHostConfig(row5, home, opts = {}) {
|
|
|
55280
55332
|
}
|
|
55281
55333
|
|
|
55282
55334
|
// src/core/ops/plugin-swap.ts
|
|
55283
|
-
import { existsSync as existsSync18, lstatSync, readdirSync as
|
|
55335
|
+
import { existsSync as existsSync18, lstatSync, readdirSync as readdirSync9, readlinkSync, rmSync as rmSync6, symlinkSync, unlinkSync as unlinkSync2 } from "node:fs";
|
|
55284
55336
|
import { basename as basename6, join as join19, win32 as win322 } from "node:path";
|
|
55285
55337
|
function linkTarget(path7, win) {
|
|
55286
55338
|
if (!isLink(path7)) return null;
|
|
@@ -55291,7 +55343,7 @@ function isLink(path7) {
|
|
|
55291
55343
|
return lstatSync(path7, { throwIfNoEntry: false })?.isSymbolicLink() === true;
|
|
55292
55344
|
}
|
|
55293
55345
|
function generations(agentDir) {
|
|
55294
|
-
return
|
|
55346
|
+
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
55347
|
}
|
|
55296
55348
|
function settleLinks(link, tmp, old, opts) {
|
|
55297
55349
|
if (isLink(tmp)) unlinkSync2(tmp);
|
|
@@ -55360,7 +55412,7 @@ async function fetchRelease(agent, url4, env, signal, opts = {}) {
|
|
|
55360
55412
|
}
|
|
55361
55413
|
|
|
55362
55414
|
// src/core/ops/uninstall.ts
|
|
55363
|
-
import { existsSync as existsSync20, readdirSync as
|
|
55415
|
+
import { existsSync as existsSync20, readdirSync as readdirSync10, rmSync as rmSync8, writeFileSync as writeFileSync6 } from "node:fs";
|
|
55364
55416
|
import { join as join21 } from "node:path";
|
|
55365
55417
|
function row2(area, before, after) {
|
|
55366
55418
|
return { area, before, after };
|
|
@@ -55476,7 +55528,7 @@ function removeProjectData(configDir, projectKey) {
|
|
|
55476
55528
|
const dir = join21(projects, projectKey);
|
|
55477
55529
|
if (!existsSync20(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
|
|
55478
55530
|
if (dir === projects || !isInside(projects, dir)) throw new CtxError("OUTSIDE_ROOT", { p: dir, root: projects });
|
|
55479
|
-
for (const name of
|
|
55531
|
+
for (const name of readdirSync10(dir)) {
|
|
55480
55532
|
if (name !== OWNERS_DIR_NAME) rmSync8(join21(dir, name), { recursive: true, force: true });
|
|
55481
55533
|
}
|
|
55482
55534
|
return row2(UPGRADE_DATA_AREA, dir, UPGRADE_DATA_DELETED);
|
|
@@ -55621,7 +55673,7 @@ function removeV1(agent, findings) {
|
|
|
55621
55673
|
|
|
55622
55674
|
// src/core/ops/verify-sums.ts
|
|
55623
55675
|
import { createHash as createHash2 } from "node:crypto";
|
|
55624
|
-
import { lstatSync as lstatSync2, readdirSync as
|
|
55676
|
+
import { lstatSync as lstatSync2, readdirSync as readdirSync11, readFileSync as readFileSync14 } from "node:fs";
|
|
55625
55677
|
import { join as join22 } from "node:path";
|
|
55626
55678
|
function mismatch() {
|
|
55627
55679
|
return new CtxError("BUNDLE_HASH_MISMATCH");
|
|
@@ -55640,7 +55692,7 @@ function parseSums(text) {
|
|
|
55640
55692
|
return sums;
|
|
55641
55693
|
}
|
|
55642
55694
|
function walk2(dir, prefix, out) {
|
|
55643
|
-
for (const entry of
|
|
55695
|
+
for (const entry of readdirSync11(dir, { withFileTypes: true })) {
|
|
55644
55696
|
const rel = prefix === "" ? entry.name : prefix + "/" + entry.name;
|
|
55645
55697
|
if (prefix === "" && (entry.name === GIT_DIR_NAME || entry.name === RELEASE_SUMS_FILE)) continue;
|
|
55646
55698
|
const abs = join22(dir, entry.name);
|