context-mode 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/README.md +73 -73
- package/SHA256SUMS +15 -15
- package/cli.mjs +27 -3
- package/copilot/plugin.json +1 -1
- package/gemini-extension.json +1 -1
- package/hook.mjs +75 -73
- package/opencode/plugin.js +105 -34
- package/package.json +1 -1
- package/pi/index.js +110 -39
- package/qwen-extension.json +1 -1
- package/run.mjs +27 -3
- package/search.mjs +27 -3
- package/server.mjs +106 -34
package/opencode/plugin.js
CHANGED
|
@@ -426,7 +426,7 @@ var DECISION_OPTION_KEY = "option";
|
|
|
426
426
|
var DECISION_LABEL_JOIN = " | ";
|
|
427
427
|
var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
|
|
428
428
|
var RELEASE_BRANCH = "release";
|
|
429
|
-
var BUNDLE_SHA = true ? "
|
|
429
|
+
var BUNDLE_SHA = true ? "9f1916d761e6a8e55ac43858b99dcdcd3cc53caa" : void 0;
|
|
430
430
|
var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
|
|
431
431
|
var DOCTOR_LABEL = Object.freeze({
|
|
432
432
|
D1: "version",
|
|
@@ -685,6 +685,7 @@ var REGEX_SPECIAL_CHARS = ".*+?^${}()|[]\\";
|
|
|
685
685
|
var REGEX_ESCAPE = "\\";
|
|
686
686
|
var CODEX_FEATURES_HOOKS_KEY = Object.freeze(["features", "hooks"]);
|
|
687
687
|
var D5_SHAPE_DETAIL = "hook output is not the agent's native shape";
|
|
688
|
+
var D5_READ_SHAPE_DETAIL = `PostToolUse Read replace is not Read's output shape {type:"text", file:{filePath, content, numLines, startLine, totalLines}}: Claude Code drops it and shows a hook warning`;
|
|
688
689
|
function D5_SLOW_DETAIL(ms) {
|
|
689
690
|
return `hook round trip took ${ms} ms over bare node, over ${HOOK_P95_MS} ms`;
|
|
690
691
|
}
|
|
@@ -1039,9 +1040,28 @@ function outputOf(resp) {
|
|
|
1039
1040
|
return err === "" ? out : out === "" ? err : out + "\n" + err;
|
|
1040
1041
|
}
|
|
1041
1042
|
}
|
|
1042
|
-
if (typeof resp === "object" && resp !== null &&
|
|
1043
|
+
if (typeof resp === "object" && resp !== null && !Array.isArray(resp)) {
|
|
1044
|
+
const slot = textSlot(resp);
|
|
1045
|
+
if (slot !== null) return slot.text;
|
|
1046
|
+
}
|
|
1043
1047
|
return JSON.stringify(resp);
|
|
1044
1048
|
}
|
|
1049
|
+
function textSlot(r) {
|
|
1050
|
+
const file2 = r.file;
|
|
1051
|
+
if (r.type === "text" && typeof file2 === "object" && file2 !== null && typeof file2.content === "string") {
|
|
1052
|
+
return { text: file2.content, put: (o, output) => ({ ...o, file: { ...o.file, content: output } }) };
|
|
1053
|
+
}
|
|
1054
|
+
if (isGrepContent(r)) return { text: r.content, put: (o, output) => ({ ...o, content: output }) };
|
|
1055
|
+
if (Array.isArray(r.filenames) && r.filenames.every((f) => typeof f === "string")) {
|
|
1056
|
+
return { text: r.filenames.join("\n"), put: (o, output) => ({ ...o, filenames: output.split("\n") }) };
|
|
1057
|
+
}
|
|
1058
|
+
if (typeof r.result === "string") return { text: r.result, put: (o, output) => ({ ...o, result: output }) };
|
|
1059
|
+
return null;
|
|
1060
|
+
}
|
|
1061
|
+
function isShellShape(resp) {
|
|
1062
|
+
const r = resp;
|
|
1063
|
+
return typeof r.stdout === "string" || typeof r.stderr === "string";
|
|
1064
|
+
}
|
|
1045
1065
|
function isGrepContent(resp) {
|
|
1046
1066
|
const r = resp;
|
|
1047
1067
|
return r.mode === "content" && typeof r.content === "string";
|
|
@@ -1060,7 +1080,10 @@ function readResult(resp) {
|
|
|
1060
1080
|
const text = outputOf(resp);
|
|
1061
1081
|
const isError = typeof resp === "object" && resp !== null && resp.is_error === true;
|
|
1062
1082
|
const info = { isError, bytes: Buffer.byteLength(text), text };
|
|
1063
|
-
if (typeof resp === "object" && resp !== null && !Array.isArray(resp) &&
|
|
1083
|
+
if (typeof resp === "object" && resp !== null && !Array.isArray(resp) && !isShellShape(resp)) {
|
|
1084
|
+
if (textSlot(resp) !== null) info.shape = resp;
|
|
1085
|
+
else info.keep = true;
|
|
1086
|
+
}
|
|
1064
1087
|
if (Array.isArray(resp)) {
|
|
1065
1088
|
info.blocks = true;
|
|
1066
1089
|
if (blocksOf(resp).keep) info.keep = true;
|
|
@@ -1097,7 +1120,9 @@ function decodeClaudeShape(raw, agent, ownPrefix, sources) {
|
|
|
1097
1120
|
}
|
|
1098
1121
|
function replaceShape(ev, output) {
|
|
1099
1122
|
if (ev.tool?.canonicalName === "Bash") return { stdout: output, stderr: "", interrupted: false };
|
|
1100
|
-
|
|
1123
|
+
const shape = ev.result?.shape;
|
|
1124
|
+
const slot = shape === void 0 ? null : textSlot(shape);
|
|
1125
|
+
if (shape !== void 0 && slot !== null) return slot.put(shape, output);
|
|
1101
1126
|
if (ev.result?.blocks === true) return [{ type: "text", text: output }];
|
|
1102
1127
|
return output;
|
|
1103
1128
|
}
|
|
@@ -24026,7 +24051,7 @@ function checkV1Leftovers(agent, home, scope = {}) {
|
|
|
24026
24051
|
if (findings.length === 0) return pass("D4");
|
|
24027
24052
|
const detail = findings.map((f) => f.reason).join(D4_REASON_JOIN);
|
|
24028
24053
|
if (findings.every((f) => f.reason === V1_REASON.tmpFile)) return { ...pass("D4"), detail };
|
|
24029
|
-
return fail2("D4", detail, DOCTOR_FIX_UPGRADE);
|
|
24054
|
+
return { ...fail2("D4", detail, DOCTOR_FIX_UPGRADE), status: "WARN" };
|
|
24030
24055
|
}
|
|
24031
24056
|
function parsedOrNull(agent, file2, jsonc) {
|
|
24032
24057
|
try {
|
|
@@ -24349,7 +24374,8 @@ function checkShell(env) {
|
|
|
24349
24374
|
}
|
|
24350
24375
|
|
|
24351
24376
|
// src/core/ops/doctor-hook.ts
|
|
24352
|
-
import { existsSync as existsSync10, readFileSync as readFileSync10, realpathSync as realpathSync7 } from "node:fs";
|
|
24377
|
+
import { existsSync as existsSync10, mkdtempSync, readFileSync as readFileSync10, realpathSync as realpathSync7, rmSync as rmSync2 } from "node:fs";
|
|
24378
|
+
import { tmpdir as tmpdir2 } from "node:os";
|
|
24353
24379
|
import path6 from "node:path";
|
|
24354
24380
|
|
|
24355
24381
|
// src/setup/codex-trust.ts
|
|
@@ -24633,6 +24659,50 @@ function isNativeShape(agent, stdout, exitCode, killed, event) {
|
|
|
24633
24659
|
return COPILOT_KEYS.some((k) => Object.hasOwn(out, k));
|
|
24634
24660
|
}
|
|
24635
24661
|
}
|
|
24662
|
+
var READ_PROBE_LINES = 4 * Math.ceil(REPLACE_TRIGGER_BYTES / 40);
|
|
24663
|
+
function readProbePayload(cwd) {
|
|
24664
|
+
const content = Array.from({ length: READ_PROBE_LINES }, (_, n) => "d5 read probe line " + n + " ".padEnd(20, "x")).join("\n");
|
|
24665
|
+
const filePath = path6.join(cwd, "d5-read-probe.txt");
|
|
24666
|
+
return {
|
|
24667
|
+
session_id: "d5-read-probe",
|
|
24668
|
+
transcript_path: "",
|
|
24669
|
+
cwd,
|
|
24670
|
+
hook_event_name: "PostToolUse",
|
|
24671
|
+
tool_name: "Read",
|
|
24672
|
+
tool_use_id: "toolu_d5_read_probe",
|
|
24673
|
+
tool_input: { file_path: filePath },
|
|
24674
|
+
tool_response: { type: "text", file: { filePath, content, numLines: READ_PROBE_LINES, startLine: 1, totalLines: READ_PROBE_LINES } }
|
|
24675
|
+
};
|
|
24676
|
+
}
|
|
24677
|
+
function isReadShape(stdout) {
|
|
24678
|
+
if (stdout.trim() === "") return true;
|
|
24679
|
+
let out;
|
|
24680
|
+
try {
|
|
24681
|
+
out = JSON.parse(stdout);
|
|
24682
|
+
} catch {
|
|
24683
|
+
return false;
|
|
24684
|
+
}
|
|
24685
|
+
if (!isObject5(out) || !isObject5(out.hookSpecificOutput) || !Object.hasOwn(out.hookSpecificOutput, "updatedToolOutput")) return true;
|
|
24686
|
+
const r = out.hookSpecificOutput.updatedToolOutput;
|
|
24687
|
+
if (!isObject5(r) || r.type !== "text" || !isObject5(r.file)) return false;
|
|
24688
|
+
const f = r.file;
|
|
24689
|
+
return typeof f.filePath === "string" && typeof f.content === "string" && ["numLines", "startLine", "totalLines"].every((k) => typeof f[k] === "number");
|
|
24690
|
+
}
|
|
24691
|
+
async function readProbeOk(i, timeoutMs) {
|
|
24692
|
+
const home = mkdtempSync(path6.join(tmpdir2(), "cm-d5-read-"));
|
|
24693
|
+
try {
|
|
24694
|
+
const r = await runProcess([process.execPath, path6.join(i.bundleDir, HOOK_ENTRY_FILE), AGENT_ARG, i.agent], {
|
|
24695
|
+
cwd: i.bundleDir,
|
|
24696
|
+
env: { ...i.env, HOME: home, USERPROFILE: home },
|
|
24697
|
+
signal: i.signal,
|
|
24698
|
+
timeoutMs,
|
|
24699
|
+
stdin: JSON.stringify(readProbePayload(i.worktree ?? home))
|
|
24700
|
+
});
|
|
24701
|
+
return isReadShape(r.stdout.toString("utf8"));
|
|
24702
|
+
} finally {
|
|
24703
|
+
rmSync2(home, { recursive: true, force: true });
|
|
24704
|
+
}
|
|
24705
|
+
}
|
|
24636
24706
|
function codexHookJournaled(db) {
|
|
24637
24707
|
if (db === null) return false;
|
|
24638
24708
|
return db.raw.prepare("SELECT 1 FROM events WHERE agent = ? LIMIT 1").get("codex") !== void 0;
|
|
@@ -24700,15 +24770,16 @@ async function checkHookRoundTrip(i) {
|
|
|
24700
24770
|
if (n >= minPairs && ms <= HOOK_P95_MS) break;
|
|
24701
24771
|
}
|
|
24702
24772
|
if (ms > HOOK_P95_MS) return row("FAIL", D5_SLOW_DETAIL(ms), D5_FIX);
|
|
24773
|
+
if (i.agent === "claude-code" && !await readProbeOk(i, timeoutMs)) return row("FAIL", D5_READ_SHAPE_DETAIL, D5_FIX);
|
|
24703
24774
|
return row("PASS", DOCTOR_PASS_DETAIL);
|
|
24704
24775
|
}
|
|
24705
24776
|
|
|
24706
24777
|
// src/core/ops/db-heal.ts
|
|
24707
|
-
import { existsSync as existsSync11, mkdirSync as mkdirSync5, rmSync as
|
|
24778
|
+
import { existsSync as existsSync11, mkdirSync as mkdirSync5, rmSync as rmSync4 } from "node:fs";
|
|
24708
24779
|
import { basename as basename4, dirname as dirname7, join as join14 } from "node:path";
|
|
24709
24780
|
|
|
24710
24781
|
// src/core/store/owners.ts
|
|
24711
|
-
import { mkdirSync as mkdirSync4, readdirSync as readdirSync5, readFileSync as readFileSync11, rmSync as
|
|
24782
|
+
import { mkdirSync as mkdirSync4, readdirSync as readdirSync5, readFileSync as readFileSync11, rmSync as rmSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
|
24712
24783
|
import { basename as basename3, join as join13 } from "node:path";
|
|
24713
24784
|
function ownersDir(configDir, projectKey) {
|
|
24714
24785
|
return join13(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
|
|
@@ -24749,7 +24820,7 @@ function listLiveOwners(configDir, projectKey) {
|
|
|
24749
24820
|
}
|
|
24750
24821
|
const serverId = basename3(name, OWNER_PID_EXT);
|
|
24751
24822
|
if (isLive(Number(text.trim()))) live.push(serverId);
|
|
24752
|
-
else
|
|
24823
|
+
else rmSync3(file2, { force: true });
|
|
24753
24824
|
}
|
|
24754
24825
|
return live;
|
|
24755
24826
|
}
|
|
@@ -24761,7 +24832,7 @@ function integrityOk2(rows) {
|
|
|
24761
24832
|
async function healLossless(dbPath) {
|
|
24762
24833
|
const { DatabaseSync } = await import(SQLITE_MODULE);
|
|
24763
24834
|
const tmp = dbPath + HEAL_TMP_SUFFIX;
|
|
24764
|
-
|
|
24835
|
+
rmSync4(tmp, { force: true });
|
|
24765
24836
|
try {
|
|
24766
24837
|
const src = new DatabaseSync(dbPath, { readOnly: true, timeout: DB_TIMEOUT_MS });
|
|
24767
24838
|
try {
|
|
@@ -24777,11 +24848,11 @@ async function healLossless(dbPath) {
|
|
|
24777
24848
|
} finally {
|
|
24778
24849
|
copy.close();
|
|
24779
24850
|
}
|
|
24780
|
-
|
|
24781
|
-
|
|
24851
|
+
rmSync4(dbPath + DB_WAL_SUFFIX, { force: true });
|
|
24852
|
+
rmSync4(dbPath + DB_SHM_SUFFIX, { force: true });
|
|
24782
24853
|
renameWithRetry(tmp, dbPath);
|
|
24783
24854
|
} finally {
|
|
24784
|
-
|
|
24855
|
+
rmSync4(tmp, { force: true });
|
|
24785
24856
|
}
|
|
24786
24857
|
}
|
|
24787
24858
|
function renameAside(dbPath) {
|
|
@@ -25226,8 +25297,8 @@ var ctxDoctor = Object.freeze({
|
|
|
25226
25297
|
});
|
|
25227
25298
|
|
|
25228
25299
|
// src/core/tools/execute.ts
|
|
25229
|
-
import { existsSync as existsSync14, mkdtempSync, rmSync as
|
|
25230
|
-
import { tmpdir as
|
|
25300
|
+
import { existsSync as existsSync14, mkdtempSync as mkdtempSync2, rmSync as rmSync5, writeFileSync as writeFileSync4 } from "node:fs";
|
|
25301
|
+
import { tmpdir as tmpdir3 } from "node:os";
|
|
25231
25302
|
import { dirname as dirname9, join as join17, parse as parse3, resolve as resolve6 } from "node:path";
|
|
25232
25303
|
|
|
25233
25304
|
// src/core/sandbox/win-build.ts
|
|
@@ -25393,7 +25464,7 @@ async function handler3(raw, ctx) {
|
|
|
25393
25464
|
if (takesDashC(input.language, runtime)) {
|
|
25394
25465
|
argv = [runtime, "-c", input.language === "shell" ? rewriteWindowsBuildTools(input.code, process.platform) : input.code];
|
|
25395
25466
|
} else {
|
|
25396
|
-
tmpDir =
|
|
25467
|
+
tmpDir = mkdtempSync2(join17(tmpdir3(), TMP_PREFIX));
|
|
25397
25468
|
const file2 = join17(tmpDir, SCRIPT_NAME + (SCRIPT_EXT[input.language] ?? ""));
|
|
25398
25469
|
writeFileSync4(file2, scriptText(input.language, input.code), "utf8");
|
|
25399
25470
|
argv = scriptArgv(input.language, runtime, file2);
|
|
@@ -25417,7 +25488,7 @@ async function handler3(raw, ctx) {
|
|
|
25417
25488
|
}
|
|
25418
25489
|
throw err;
|
|
25419
25490
|
} finally {
|
|
25420
|
-
if (tmpDir !== null && !handedOff)
|
|
25491
|
+
if (tmpDir !== null && !handedOff) rmSync5(tmpDir, { recursive: true, force: true });
|
|
25421
25492
|
}
|
|
25422
25493
|
}
|
|
25423
25494
|
var ctxExecute = {
|
|
@@ -30136,7 +30207,7 @@ var ctxStats = Object.freeze({
|
|
|
30136
30207
|
});
|
|
30137
30208
|
|
|
30138
30209
|
// src/core/tools/upgrade.ts
|
|
30139
|
-
import { existsSync as existsSync21, realpathSync as realpathSync10, rmSync as
|
|
30210
|
+
import { existsSync as existsSync21, realpathSync as realpathSync10, rmSync as rmSync10 } from "node:fs";
|
|
30140
30211
|
import { basename as basename7, dirname as dirname12, join as join25 } from "node:path";
|
|
30141
30212
|
|
|
30142
30213
|
// src/core/ops/host-write.ts
|
|
@@ -30207,7 +30278,7 @@ function regenerateHostConfig(row5, home, opts = {}) {
|
|
|
30207
30278
|
}
|
|
30208
30279
|
|
|
30209
30280
|
// src/core/ops/plugin-swap.ts
|
|
30210
|
-
import { existsSync as existsSync17, lstatSync, readdirSync as readdirSync8, readlinkSync, rmSync as
|
|
30281
|
+
import { existsSync as existsSync17, lstatSync, readdirSync as readdirSync8, readlinkSync, rmSync as rmSync6, symlinkSync, unlinkSync as unlinkSync2 } from "node:fs";
|
|
30211
30282
|
import { basename as basename6, join as join21, win32 as win322 } from "node:path";
|
|
30212
30283
|
function linkTarget(path7, win) {
|
|
30213
30284
|
if (!isLink(path7)) return null;
|
|
@@ -30247,13 +30318,13 @@ function swapPluginCurrent(agentDir, sha, opts = {}) {
|
|
|
30247
30318
|
const keep = /* @__PURE__ */ new Set([sha]);
|
|
30248
30319
|
if (before !== null) keep.add(before);
|
|
30249
30320
|
const removed = generations(agentDir).filter((name) => !keep.has(name)).map((name) => join21(agentDir, name));
|
|
30250
|
-
for (const dir of removed)
|
|
30321
|
+
for (const dir of removed) rmSync6(dir, { recursive: true, force: true });
|
|
30251
30322
|
const previous = before !== null && existsSync17(join21(agentDir, before)) ? join21(agentDir, before) : null;
|
|
30252
30323
|
return { current: next, previous, removed };
|
|
30253
30324
|
}
|
|
30254
30325
|
|
|
30255
30326
|
// src/core/ops/release-fetch.ts
|
|
30256
|
-
import { existsSync as existsSync18, mkdirSync as mkdirSync8, rmSync as
|
|
30327
|
+
import { existsSync as existsSync18, mkdirSync as mkdirSync8, rmSync as rmSync7 } from "node:fs";
|
|
30257
30328
|
import { join as join22 } from "node:path";
|
|
30258
30329
|
function failed(r) {
|
|
30259
30330
|
if (r.exitCode === null && r.killed === null) return new CtxError("FETCH_FAILED", { code: GIT_NOT_STARTED });
|
|
@@ -30269,7 +30340,7 @@ async function fetchRelease(agent, url2, env, signal, opts = {}) {
|
|
|
30269
30340
|
const agentDir = join22(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, agent);
|
|
30270
30341
|
mkdirSync8(agentDir, { recursive: true });
|
|
30271
30342
|
const fetchDir = join22(agentDir, UPGRADE_FETCH_DIR_PREFIX + process.pid);
|
|
30272
|
-
|
|
30343
|
+
rmSync7(fetchDir, { recursive: true, force: true });
|
|
30273
30344
|
const gitBin = findRuntime(GIT_BIN, env);
|
|
30274
30345
|
if (gitBin === null) throw new CtxError("FETCH_FAILED", { code: GIT_NOT_STARTED });
|
|
30275
30346
|
const childEnv = buildChildEnv(env, { ...GIT_NO_PROMPT_ENV, ...GIT_NO_CRLF_ENV });
|
|
@@ -30277,17 +30348,17 @@ async function fetchRelease(agent, url2, env, signal, opts = {}) {
|
|
|
30277
30348
|
await git2(gitBin, [...GIT_CLONE_ARGS, RELEASE_BRANCH, url2, fetchDir], agentDir, childEnv, signal);
|
|
30278
30349
|
const sha = await git2(gitBin, GIT_HEAD_SHA_ARGS, fetchDir, childEnv, signal);
|
|
30279
30350
|
const dir = join22(agentDir, sha);
|
|
30280
|
-
if (existsSync18(dir))
|
|
30351
|
+
if (existsSync18(dir)) rmSync7(fetchDir, { recursive: true, force: true });
|
|
30281
30352
|
else renameWithRetry(fetchDir, dir, opts);
|
|
30282
30353
|
return { sha, dir };
|
|
30283
30354
|
} catch (e) {
|
|
30284
|
-
|
|
30355
|
+
rmSync7(fetchDir, { recursive: true, force: true });
|
|
30285
30356
|
throw e;
|
|
30286
30357
|
}
|
|
30287
30358
|
}
|
|
30288
30359
|
|
|
30289
30360
|
// src/core/ops/uninstall.ts
|
|
30290
|
-
import { existsSync as existsSync19, readdirSync as readdirSync9, rmSync as
|
|
30361
|
+
import { existsSync as existsSync19, readdirSync as readdirSync9, rmSync as rmSync8, writeFileSync as writeFileSync6 } from "node:fs";
|
|
30291
30362
|
import { join as join23 } from "node:path";
|
|
30292
30363
|
function row2(area, before, after) {
|
|
30293
30364
|
return { area, before, after };
|
|
@@ -30316,13 +30387,13 @@ function removeCache(adapter, env, configDir) {
|
|
|
30316
30387
|
const cache = join23(claudeDirOf(env, requireHomeDir(env)), HOST_PLUGINS_DIR_NAME, PLUGIN_CACHE_DIR_NAME);
|
|
30317
30388
|
if (!isInside(cache, root) || isInside(root, cache)) return row2(UPGRADE_CACHE_AREA, root, UPGRADE_CACHE_BY_HAND);
|
|
30318
30389
|
}
|
|
30319
|
-
|
|
30390
|
+
rmSync8(root, { recursive: true, force: true });
|
|
30320
30391
|
return row2(UPGRADE_CACHE_AREA, root, UPGRADE_REMOVED);
|
|
30321
30392
|
}
|
|
30322
30393
|
case "plugin": {
|
|
30323
30394
|
const agentDir = join23(configDir, DATA_PLUGINS_DIR_NAME, adapter.id);
|
|
30324
30395
|
if (!existsSync19(agentDir)) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
|
|
30325
|
-
|
|
30396
|
+
rmSync8(agentDir, { recursive: true, force: true });
|
|
30326
30397
|
return row2(UPGRADE_CACHE_AREA, agentDir, UPGRADE_REMOVED);
|
|
30327
30398
|
}
|
|
30328
30399
|
case "config-mcp":
|
|
@@ -30404,7 +30475,7 @@ function removeProjectData(configDir, projectKey) {
|
|
|
30404
30475
|
if (!existsSync19(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
|
|
30405
30476
|
if (dir === projects || !isInside(projects, dir)) throw new CtxError("OUTSIDE_ROOT", { p: dir, root: projects });
|
|
30406
30477
|
for (const name of readdirSync9(dir)) {
|
|
30407
|
-
if (name !== OWNERS_DIR_NAME)
|
|
30478
|
+
if (name !== OWNERS_DIR_NAME) rmSync8(join23(dir, name), { recursive: true, force: true });
|
|
30408
30479
|
}
|
|
30409
30480
|
return row2(UPGRADE_DATA_AREA, dir, UPGRADE_DATA_DELETED);
|
|
30410
30481
|
}
|
|
@@ -30417,20 +30488,20 @@ function runUninstall(input) {
|
|
|
30417
30488
|
}
|
|
30418
30489
|
|
|
30419
30490
|
// src/core/ops/v1-remove.ts
|
|
30420
|
-
import { copyFileSync as copyFileSync2, existsSync as existsSync20, readFileSync as readFileSync16, rmSync as
|
|
30491
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync20, readFileSync as readFileSync16, rmSync as rmSync9 } from "node:fs";
|
|
30421
30492
|
var isObj4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
30422
30493
|
var areaOf = (f) => f.path === "" ? f.file : f.file + UPGRADE_AREA_KEY_SEP + f.path;
|
|
30423
30494
|
var row3 = (f, after) => ({ area: areaOf(f), before: f.reason, after });
|
|
30424
30495
|
function moveAside(target, undo) {
|
|
30425
30496
|
const trash = target + UPGRADE_TRASH_SUFFIX;
|
|
30426
|
-
|
|
30497
|
+
rmSync9(trash, { recursive: true, force: true });
|
|
30427
30498
|
renameWithRetry(target, trash);
|
|
30428
30499
|
undo.push({ trash, target });
|
|
30429
30500
|
}
|
|
30430
30501
|
function keepOriginal(file2, kept, undo) {
|
|
30431
30502
|
if (kept.has(file2)) return;
|
|
30432
30503
|
const trash = file2 + UPGRADE_TRASH_SUFFIX;
|
|
30433
|
-
|
|
30504
|
+
rmSync9(trash, { recursive: true, force: true });
|
|
30434
30505
|
copyFileSync2(file2, trash);
|
|
30435
30506
|
kept.add(file2);
|
|
30436
30507
|
undo.push({ trash, target: file2 });
|
|
@@ -30534,12 +30605,12 @@ function removeV1(agent, findings) {
|
|
|
30534
30605
|
return {
|
|
30535
30606
|
rows: findings.map((f) => row3(f, done.get(f) ?? UPGRADE_NOT_FOUND)),
|
|
30536
30607
|
commit() {
|
|
30537
|
-
for (const u of undo.splice(0))
|
|
30608
|
+
for (const u of undo.splice(0)) rmSync9(u.trash, { recursive: true, force: true });
|
|
30538
30609
|
},
|
|
30539
30610
|
rollback() {
|
|
30540
30611
|
for (const u of undo.splice(0).reverse()) {
|
|
30541
30612
|
if (!existsSync20(u.trash)) continue;
|
|
30542
|
-
|
|
30613
|
+
rmSync9(u.target, { recursive: true, force: true });
|
|
30543
30614
|
renameWithRetry(u.trash, u.target);
|
|
30544
30615
|
}
|
|
30545
30616
|
}
|
|
@@ -30624,7 +30695,7 @@ async function checkout(adapter, deps) {
|
|
|
30624
30695
|
try {
|
|
30625
30696
|
verifySums(fetched.dir);
|
|
30626
30697
|
} catch (err) {
|
|
30627
|
-
if (!isCurrent(agentDir, fetched.dir))
|
|
30698
|
+
if (!isCurrent(agentDir, fetched.dir)) rmSync10(fetched.dir, { recursive: true, force: true });
|
|
30628
30699
|
throw err;
|
|
30629
30700
|
}
|
|
30630
30701
|
const swap = swapPluginCurrent(agentDir, fetched.sha);
|
package/package.json
CHANGED