context-mode 2.1.1 → 2.1.3
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 +164 -144
- package/copilot/plugin.json +1 -1
- package/gemini-extension.json +1 -1
- package/hook.mjs +85 -85
- package/opencode/plugin.js +348 -228
- package/package.json +1 -1
- package/pi/index.js +402 -280
- package/qwen-extension.json +1 -1
- package/run.mjs +19 -8
- package/search.mjs +19 -8
- package/server.mjs +374 -262
package/server.mjs
CHANGED
|
@@ -7,7 +7,7 @@ var __export = (target, all) => {
|
|
|
7
7
|
|
|
8
8
|
// src/entries/server.ts
|
|
9
9
|
import { randomUUID } from "node:crypto";
|
|
10
|
-
import { existsSync as
|
|
10
|
+
import { existsSync as existsSync25, realpathSync as realpathSync13, rmSync as rmSync12 } from "node:fs";
|
|
11
11
|
import { dirname as dirname13, join as join25 } from "node:path";
|
|
12
12
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
13
13
|
|
|
@@ -305,10 +305,10 @@ function mergeDefs(...defs) {
|
|
|
305
305
|
function cloneDef(schema) {
|
|
306
306
|
return mergeDefs(schema._zod.def);
|
|
307
307
|
}
|
|
308
|
-
function getElementAtPath(obj,
|
|
309
|
-
if (!
|
|
308
|
+
function getElementAtPath(obj, path8) {
|
|
309
|
+
if (!path8)
|
|
310
310
|
return obj;
|
|
311
|
-
return
|
|
311
|
+
return path8.reduce((acc, key) => acc?.[key], obj);
|
|
312
312
|
}
|
|
313
313
|
function promiseAllObject(promisesObj) {
|
|
314
314
|
const keys = Object.keys(promisesObj);
|
|
@@ -648,11 +648,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
648
648
|
}
|
|
649
649
|
return false;
|
|
650
650
|
}
|
|
651
|
-
function prefixIssues(
|
|
651
|
+
function prefixIssues(path8, issues) {
|
|
652
652
|
return issues.map((iss) => {
|
|
653
653
|
var _a5;
|
|
654
654
|
(_a5 = iss).path ?? (_a5.path = []);
|
|
655
|
-
iss.path.unshift(
|
|
655
|
+
iss.path.unshift(path8);
|
|
656
656
|
return iss;
|
|
657
657
|
});
|
|
658
658
|
}
|
|
@@ -1113,16 +1113,16 @@ function flattenError(error42, mapper = (issue4) => issue4.message) {
|
|
|
1113
1113
|
}
|
|
1114
1114
|
function formatError(error42, mapper = (issue4) => issue4.message) {
|
|
1115
1115
|
const fieldErrors = { _errors: [] };
|
|
1116
|
-
const processError = (error43,
|
|
1116
|
+
const processError = (error43, path8 = []) => {
|
|
1117
1117
|
for (const issue4 of error43.issues) {
|
|
1118
1118
|
if (issue4.code === "invalid_union" && issue4.errors.length) {
|
|
1119
|
-
issue4.errors.map((issues) => processError({ issues }, [...
|
|
1119
|
+
issue4.errors.map((issues) => processError({ issues }, [...path8, ...issue4.path]));
|
|
1120
1120
|
} else if (issue4.code === "invalid_key") {
|
|
1121
|
-
processError({ issues: issue4.issues }, [...
|
|
1121
|
+
processError({ issues: issue4.issues }, [...path8, ...issue4.path]);
|
|
1122
1122
|
} else if (issue4.code === "invalid_element") {
|
|
1123
|
-
processError({ issues: issue4.issues }, [...
|
|
1123
|
+
processError({ issues: issue4.issues }, [...path8, ...issue4.path]);
|
|
1124
1124
|
} else {
|
|
1125
|
-
const fullpath = [...
|
|
1125
|
+
const fullpath = [...path8, ...issue4.path];
|
|
1126
1126
|
if (fullpath.length === 0) {
|
|
1127
1127
|
fieldErrors._errors.push(mapper(issue4));
|
|
1128
1128
|
} else {
|
|
@@ -7886,10 +7886,10 @@ function mergeDefs2(...defs) {
|
|
|
7886
7886
|
function cloneDef2(schema) {
|
|
7887
7887
|
return mergeDefs2(schema._zod.def);
|
|
7888
7888
|
}
|
|
7889
|
-
function getElementAtPath2(obj,
|
|
7890
|
-
if (!
|
|
7889
|
+
function getElementAtPath2(obj, path8) {
|
|
7890
|
+
if (!path8)
|
|
7891
7891
|
return obj;
|
|
7892
|
-
return
|
|
7892
|
+
return path8.reduce((acc, key) => acc?.[key], obj);
|
|
7893
7893
|
}
|
|
7894
7894
|
function promiseAllObject2(promisesObj) {
|
|
7895
7895
|
const keys = Object.keys(promisesObj);
|
|
@@ -8229,11 +8229,11 @@ function explicitlyAborted2(x, startIndex = 0) {
|
|
|
8229
8229
|
}
|
|
8230
8230
|
return false;
|
|
8231
8231
|
}
|
|
8232
|
-
function prefixIssues2(
|
|
8232
|
+
function prefixIssues2(path8, issues) {
|
|
8233
8233
|
return issues.map((iss) => {
|
|
8234
8234
|
var _a5;
|
|
8235
8235
|
(_a5 = iss).path ?? (_a5.path = []);
|
|
8236
|
-
iss.path.unshift(
|
|
8236
|
+
iss.path.unshift(path8);
|
|
8237
8237
|
return iss;
|
|
8238
8238
|
});
|
|
8239
8239
|
}
|
|
@@ -8691,16 +8691,16 @@ function flattenError2(error42, mapper = (issue4) => issue4.message) {
|
|
|
8691
8691
|
}
|
|
8692
8692
|
function formatError2(error42, mapper = (issue4) => issue4.message) {
|
|
8693
8693
|
const fieldErrors = { _errors: [] };
|
|
8694
|
-
const processError = (error43,
|
|
8694
|
+
const processError = (error43, path8 = []) => {
|
|
8695
8695
|
for (const issue4 of error43.issues) {
|
|
8696
8696
|
if (issue4.code === "invalid_union" && issue4.errors.length) {
|
|
8697
|
-
issue4.errors.map((issues) => processError({ issues }, [...
|
|
8697
|
+
issue4.errors.map((issues) => processError({ issues }, [...path8, ...issue4.path]));
|
|
8698
8698
|
} else if (issue4.code === "invalid_key") {
|
|
8699
|
-
processError({ issues: issue4.issues }, [...
|
|
8699
|
+
processError({ issues: issue4.issues }, [...path8, ...issue4.path]);
|
|
8700
8700
|
} else if (issue4.code === "invalid_element") {
|
|
8701
|
-
processError({ issues: issue4.issues }, [...
|
|
8701
|
+
processError({ issues: issue4.issues }, [...path8, ...issue4.path]);
|
|
8702
8702
|
} else {
|
|
8703
|
-
const fullpath = [...
|
|
8703
|
+
const fullpath = [...path8, ...issue4.path];
|
|
8704
8704
|
if (fullpath.length === 0) {
|
|
8705
8705
|
fieldErrors._errors.push(mapper(issue4));
|
|
8706
8706
|
} else {
|
|
@@ -16916,9 +16916,9 @@ var rev2026Codec = {
|
|
|
16916
16916
|
});
|
|
16917
16917
|
const parsed = buildSchemas2026().RequestMetaEnvelopeSchema.safeParse(meta3);
|
|
16918
16918
|
if (!parsed.success) for (const issue4 of parsed.error.issues) {
|
|
16919
|
-
const
|
|
16920
|
-
const key =
|
|
16921
|
-
if (
|
|
16919
|
+
const path8 = issue4.path.map(String);
|
|
16920
|
+
const key = path8.length > 0 ? path8.join(".") : "_meta";
|
|
16921
|
+
if (path8.length === 1 && issues.some((existing) => existing.key === key && existing.problem === "missing")) continue;
|
|
16922
16922
|
issues.push({
|
|
16923
16923
|
key,
|
|
16924
16924
|
problem: issue4.message
|
|
@@ -17245,29 +17245,29 @@ var PERMITTED_X_MCP_HEADER_TYPES = /* @__PURE__ */ new Set([
|
|
|
17245
17245
|
function scanXMcpHeaderDeclarations(inputSchema) {
|
|
17246
17246
|
const declarations = [];
|
|
17247
17247
|
const seenLower = /* @__PURE__ */ new Map();
|
|
17248
|
-
const visit2 = (node3,
|
|
17248
|
+
const visit2 = (node3, path8, reachable) => {
|
|
17249
17249
|
if (node3 === null || typeof node3 !== "object") return void 0;
|
|
17250
17250
|
const schema = node3;
|
|
17251
17251
|
if (X_MCP_HEADER_KEY in schema) {
|
|
17252
|
-
if (!reachable ||
|
|
17252
|
+
if (!reachable || path8.length === 0) return `${pathName(path8)}: x-mcp-header is only permitted on properties statically reachable via a chain of 'properties' keys (not under items, additionalProperties, oneOf/anyOf/allOf/not, if/then/else, or $ref)`;
|
|
17253
17253
|
const raw = schema[X_MCP_HEADER_KEY];
|
|
17254
|
-
if (typeof raw !== "string" || raw.length === 0) return `${pathName(
|
|
17255
|
-
if (!RFC9110_TOKEN.test(raw)) return `${pathName(
|
|
17254
|
+
if (typeof raw !== "string" || raw.length === 0) return `${pathName(path8)}: x-mcp-header MUST be a non-empty string`;
|
|
17255
|
+
if (!RFC9110_TOKEN.test(raw)) return `${pathName(path8)}: x-mcp-header '${raw}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;
|
|
17256
17256
|
const type = typeof schema.type === "string" ? schema.type : void 0;
|
|
17257
|
-
if (type === void 0 || !PERMITTED_X_MCP_HEADER_TYPES.has(type)) return `${pathName(
|
|
17257
|
+
if (type === void 0 || !PERMITTED_X_MCP_HEADER_TYPES.has(type)) return `${pathName(path8)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${type ?? "<none>"}`;
|
|
17258
17258
|
const lower = raw.toLowerCase();
|
|
17259
17259
|
const prior = seenLower.get(lower);
|
|
17260
17260
|
if (prior !== void 0) return `x-mcp-header '${raw}' is not case-insensitively unique (also declared as '${prior}')`;
|
|
17261
17261
|
seenLower.set(lower, raw);
|
|
17262
17262
|
declarations.push({
|
|
17263
|
-
path:
|
|
17263
|
+
path: path8,
|
|
17264
17264
|
headerName: raw,
|
|
17265
17265
|
type
|
|
17266
17266
|
});
|
|
17267
17267
|
}
|
|
17268
17268
|
const properties = schema.properties;
|
|
17269
17269
|
if (properties !== null && typeof properties === "object") for (const [key, child] of Object.entries(properties)) {
|
|
17270
|
-
const fault$1 = visit2(child, [...
|
|
17270
|
+
const fault$1 = visit2(child, [...path8, key], reachable);
|
|
17271
17271
|
if (fault$1 !== void 0) return fault$1;
|
|
17272
17272
|
}
|
|
17273
17273
|
for (const k of NON_REACHABLE_SUBSCHEMA_KEYWORDS) {
|
|
@@ -17275,7 +17275,7 @@ function scanXMcpHeaderDeclarations(inputSchema) {
|
|
|
17275
17275
|
if (sub === void 0) continue;
|
|
17276
17276
|
const branches = Array.isArray(sub) ? sub : sub !== null && typeof sub === "object" && OBJECT_VALUED_SUBSCHEMA_KEYWORDS.has(k) ? Object.values(sub) : [sub];
|
|
17277
17277
|
for (const branch of branches) {
|
|
17278
|
-
const fault$1 = visit2(branch, [...
|
|
17278
|
+
const fault$1 = visit2(branch, [...path8, `<${k}>`], false);
|
|
17279
17279
|
if (fault$1 !== void 0) return fault$1;
|
|
17280
17280
|
}
|
|
17281
17281
|
}
|
|
@@ -17315,8 +17315,8 @@ var OBJECT_VALUED_SUBSCHEMA_KEYWORDS = /* @__PURE__ */ new Set([
|
|
|
17315
17315
|
"$defs",
|
|
17316
17316
|
"definitions"
|
|
17317
17317
|
]);
|
|
17318
|
-
function pathName(
|
|
17319
|
-
return
|
|
17318
|
+
function pathName(path8) {
|
|
17319
|
+
return path8.length === 0 ? "<root>" : path8.join(".");
|
|
17320
17320
|
}
|
|
17321
17321
|
var HEADER_MISMATCH_ERROR_CODE = -32020;
|
|
17322
17322
|
var INBOUND_VALIDATION_LADDER = [
|
|
@@ -17605,7 +17605,7 @@ var PROPERTY_KEYS_BY_TYPE = {
|
|
|
17605
17605
|
array: shapeKeys([UntitledMultiSelectEnumSchemaSchema, TitledMultiSelectEnumSchemaSchema])
|
|
17606
17606
|
};
|
|
17607
17607
|
var SUPPORTED_STRING_FORMATS = new Set(StringSchemaSchema.shape.format.unwrap().options);
|
|
17608
|
-
function walkProperty(node3,
|
|
17608
|
+
function walkProperty(node3, path8, vendor, unsupported) {
|
|
17609
17609
|
if (!isJsonObject(node3)) return node3;
|
|
17610
17610
|
const allowedKeys = typeof node3.type === "string" && Object.hasOwn(PROPERTY_KEYS_BY_TYPE, node3.type) ? PROPERTY_KEYS_BY_TYPE[node3.type] : void 0;
|
|
17611
17611
|
if (allowedKeys === void 0) return node3;
|
|
@@ -17613,8 +17613,8 @@ function walkProperty(node3, path7, vendor, unsupported) {
|
|
|
17613
17613
|
for (const [key, value] of Object.entries(node3)) if (allowedKeys.has(key) || isAnnotationOnlyJsonSchemaKeyword(key)) pruned[key] = value;
|
|
17614
17614
|
else if (key === "pattern" && node3.type === "string" && typeof node3.format === "string") {
|
|
17615
17615
|
if (!SUPPORTED_STRING_FORMATS.has(node3.format)) pruned[key] = value;
|
|
17616
|
-
else if (typeof value !== "string" || !isLibraryFormatPattern(node3.format, value, vendor)) unsupported.push(`${
|
|
17617
|
-
} else unsupported.push(`${
|
|
17616
|
+
else if (typeof value !== "string" || !isLibraryFormatPattern(node3.format, value, vendor)) unsupported.push(`${path8}.${key}`);
|
|
17617
|
+
} else unsupported.push(`${path8}.${key}`);
|
|
17618
17618
|
return pruned;
|
|
17619
17619
|
}
|
|
17620
17620
|
function walkRequestedSchema(converted, vendor) {
|
|
@@ -17631,11 +17631,11 @@ function describeUnsupportedProperties(pruned, fallback) {
|
|
|
17631
17631
|
const offenders = Object.entries(pruned.properties).filter(([, node3]) => !parseSchema(PrimitiveSchemaDefinitionSchema, node3).success).map(([name]) => `properties.${name}`);
|
|
17632
17632
|
return offenders.length > 0 ? offenders.join(", ") : fallback;
|
|
17633
17633
|
}
|
|
17634
|
-
function findDroppedConstraintPaths(original, parsed,
|
|
17635
|
-
if (Array.isArray(original) && Array.isArray(parsed)) return original.flatMap((item, index) => findDroppedConstraintPaths(item, parsed[index], `${
|
|
17634
|
+
function findDroppedConstraintPaths(original, parsed, path8 = "") {
|
|
17635
|
+
if (Array.isArray(original) && Array.isArray(parsed)) return original.flatMap((item, index) => findDroppedConstraintPaths(item, parsed[index], `${path8}[${index}]`));
|
|
17636
17636
|
if (!isJsonObject(original) || !isJsonObject(parsed)) return [];
|
|
17637
17637
|
return Object.entries(original).flatMap(([key, value]) => {
|
|
17638
|
-
const childPath =
|
|
17638
|
+
const childPath = path8 ? `${path8}.${key}` : key;
|
|
17639
17639
|
if (!Object.prototype.hasOwnProperty.call(parsed, key)) return isAnnotationOnlyJsonSchemaKeyword(key) ? [] : [childPath];
|
|
17640
17640
|
return findDroppedConstraintPaths(value, parsed[key], childPath);
|
|
17641
17641
|
});
|
|
@@ -21723,8 +21723,8 @@ var require_utils = /* @__PURE__ */ __commonJSMin((exports, module) => {
|
|
|
21723
21723
|
for (let i = 0; i < str.length; i++) if (str[i] === token) ind++;
|
|
21724
21724
|
return ind;
|
|
21725
21725
|
}
|
|
21726
|
-
function removeDotSegments(
|
|
21727
|
-
let input =
|
|
21726
|
+
function removeDotSegments(path8) {
|
|
21727
|
+
let input = path8;
|
|
21728
21728
|
const output = [];
|
|
21729
21729
|
let nextSlash = -1;
|
|
21730
21730
|
let len = 0;
|
|
@@ -21877,8 +21877,8 @@ var require_schemes = /* @__PURE__ */ __commonJSMin((exports, module) => {
|
|
|
21877
21877
|
wsComponent.secure = void 0;
|
|
21878
21878
|
}
|
|
21879
21879
|
if (wsComponent.resourceName) {
|
|
21880
|
-
const [
|
|
21881
|
-
wsComponent.path =
|
|
21880
|
+
const [path8, query] = wsComponent.resourceName.split("?");
|
|
21881
|
+
wsComponent.path = path8 && path8 !== "/" ? path8 : void 0;
|
|
21882
21882
|
wsComponent.query = query;
|
|
21883
21883
|
wsComponent.resourceName = void 0;
|
|
21884
21884
|
}
|
|
@@ -28066,6 +28066,8 @@ var POINTER_MIN = 640;
|
|
|
28066
28066
|
var STATE_CLOSE_TAG = "</context_mode_state>";
|
|
28067
28067
|
var INDEX_WRITE_CHUNK = 1048576;
|
|
28068
28068
|
var REPLACE_TRIGGER_BYTES = 4096;
|
|
28069
|
+
var RANGE_READ_TOOLS = Object.freeze(["Read", "view"]);
|
|
28070
|
+
var READ_RANGE_KEYS = Object.freeze(["offset", "limit", "view_range"]);
|
|
28069
28071
|
var MAX_CHUNK_BYTES = 4096;
|
|
28070
28072
|
var SEARCH_PAGE_SIZE = 20;
|
|
28071
28073
|
var MEMORY_LABEL_PREFIX = "memory ";
|
|
@@ -28407,7 +28409,7 @@ var DECISION_SOURCE = "decision";
|
|
|
28407
28409
|
var DECISION_USER_LABEL = "decision (user)";
|
|
28408
28410
|
var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
|
|
28409
28411
|
var RELEASE_BRANCH = "release";
|
|
28410
|
-
var BUNDLE_SHA = true ? "
|
|
28412
|
+
var BUNDLE_SHA = true ? "83f2da691359eaaf61f7baba841dea1942d3ccc1" : void 0;
|
|
28411
28413
|
var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
|
|
28412
28414
|
var DOCTOR_LABEL = Object.freeze({
|
|
28413
28415
|
D1: "version",
|
|
@@ -28671,6 +28673,7 @@ var REGEX_SPECIAL_CHARS = ".*+?^${}()|[]\\";
|
|
|
28671
28673
|
var REGEX_ESCAPE = "\\";
|
|
28672
28674
|
var CODEX_FEATURES_HOOKS_KEY = Object.freeze(["features", "hooks"]);
|
|
28673
28675
|
var D5_SHAPE_DETAIL = "hook output is not the agent's native shape";
|
|
28676
|
+
var D5_READ_RANGE_DETAIL = "PostToolUse Read with offset/limit over the replace trigger came back replaced: a bounded Read must reach the model whole";
|
|
28674
28677
|
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`;
|
|
28675
28678
|
function D5_SLOW_DETAIL(ms) {
|
|
28676
28679
|
return `hook round trip took ${ms} ms over bare node, over ${HOOK_P95_MS} ms`;
|
|
@@ -28729,6 +28732,11 @@ var V1_CACHE_HEAL_NAME = "context-mode-cache-heal";
|
|
|
28729
28732
|
var V1_CACHE_HEAL_EXTS = Object.freeze([".mjs", ".sh"]);
|
|
28730
28733
|
var V1_STATUSLINE_COMMAND = "context-mode statusline";
|
|
28731
28734
|
var V1_PI_PACKAGE = "npm:context-mode";
|
|
28735
|
+
var PI_NPM_DIR = "npm";
|
|
28736
|
+
var PI_NODE_MODULES_DIR = "node_modules";
|
|
28737
|
+
var PI_PACKAGE_JSON_FILE = "package.json";
|
|
28738
|
+
var PI_LIST_COMMAND = "pi list";
|
|
28739
|
+
var PI_CURRENT_MAJOR = 2;
|
|
28732
28740
|
var V1_OPENCODE_PLUGIN_SPEC = "context-mode";
|
|
28733
28741
|
var V1_TMP_PREFIX = "context-mode-";
|
|
28734
28742
|
var V1_TOML_SECTION_ROOT = "mcp_servers";
|
|
@@ -29169,9 +29177,9 @@ function readUserVersion(raw) {
|
|
|
29169
29177
|
const row5 = raw.prepare("PRAGMA user_version").get();
|
|
29170
29178
|
return row5.user_version;
|
|
29171
29179
|
}
|
|
29172
|
-
function createAtomically(sqlite,
|
|
29180
|
+
function createAtomically(sqlite, path8) {
|
|
29173
29181
|
const { randomUUID: randomUUID2 } = process.getBuiltinModule("node:crypto");
|
|
29174
|
-
const tmp =
|
|
29182
|
+
const tmp = path8 + "." + randomUUID2() + DB_TMP_SUFFIX;
|
|
29175
29183
|
try {
|
|
29176
29184
|
const raw = new sqlite.DatabaseSync(tmp, { timeout: DB_TIMEOUT_MS });
|
|
29177
29185
|
try {
|
|
@@ -29180,7 +29188,7 @@ function createAtomically(sqlite, path7) {
|
|
|
29180
29188
|
raw.close();
|
|
29181
29189
|
}
|
|
29182
29190
|
try {
|
|
29183
|
-
linkSync(tmp,
|
|
29191
|
+
linkSync(tmp, path8);
|
|
29184
29192
|
} catch (err) {
|
|
29185
29193
|
if (err.code !== "EEXIST") throw err;
|
|
29186
29194
|
}
|
|
@@ -29188,11 +29196,11 @@ function createAtomically(sqlite, path7) {
|
|
|
29188
29196
|
for (const suffix of ["", DB_WAL_SUFFIX, DB_SHM_SUFFIX]) rmSync(tmp + suffix, { force: true });
|
|
29189
29197
|
}
|
|
29190
29198
|
}
|
|
29191
|
-
function openWritable(sqlite,
|
|
29199
|
+
function openWritable(sqlite, path8) {
|
|
29192
29200
|
let raw = null;
|
|
29193
29201
|
try {
|
|
29194
|
-
if (!existsSync(
|
|
29195
|
-
raw = new sqlite.DatabaseSync(
|
|
29202
|
+
if (!existsSync(path8)) createAtomically(sqlite, path8);
|
|
29203
|
+
raw = new sqlite.DatabaseSync(path8, { timeout: DB_TIMEOUT_MS });
|
|
29196
29204
|
applyMigrations(raw, readUserVersion(raw));
|
|
29197
29205
|
return raw;
|
|
29198
29206
|
} catch (err) {
|
|
@@ -29200,8 +29208,8 @@ function openWritable(sqlite, path7) {
|
|
|
29200
29208
|
throw err;
|
|
29201
29209
|
}
|
|
29202
29210
|
}
|
|
29203
|
-
function openReadOnly(sqlite,
|
|
29204
|
-
const raw = new sqlite.DatabaseSync(
|
|
29211
|
+
function openReadOnly(sqlite, path8) {
|
|
29212
|
+
const raw = new sqlite.DatabaseSync(path8, { timeout: DB_TIMEOUT_MS, readOnly: true });
|
|
29205
29213
|
try {
|
|
29206
29214
|
const found = readUserVersion(raw);
|
|
29207
29215
|
if (found !== SCHEMA_VERSION) throw new CtxError("SCHEMA_STALE", { found, want: SCHEMA_VERSION });
|
|
@@ -29215,20 +29223,20 @@ async function openDb(project, opts) {
|
|
|
29215
29223
|
if (isBelow(process.version, NODE_MIN)) throw new CtxError("NODE_TOO_OLD", { v: process.version });
|
|
29216
29224
|
const sqlite = await loadSqlite();
|
|
29217
29225
|
mkdirSync(project.projectDir, { recursive: true });
|
|
29218
|
-
const
|
|
29219
|
-
const sibling = existsSync(
|
|
29220
|
-
if (sibling && !existsSync(
|
|
29226
|
+
const path8 = project.dbPath;
|
|
29227
|
+
const sibling = existsSync(path8 + DB_WAL_SUFFIX) || existsSync(path8 + DB_SHM_SUFFIX);
|
|
29228
|
+
if (sibling && !existsSync(path8)) {
|
|
29221
29229
|
throw new CtxError("DB_GONE");
|
|
29222
29230
|
}
|
|
29223
29231
|
try {
|
|
29224
29232
|
let raw;
|
|
29225
29233
|
if (opts?.readOnly === true) {
|
|
29226
|
-
if (!existsSync(
|
|
29227
|
-
raw = openReadOnly(sqlite,
|
|
29234
|
+
if (!existsSync(path8)) openWritable(sqlite, path8).close();
|
|
29235
|
+
raw = openReadOnly(sqlite, path8);
|
|
29228
29236
|
} else {
|
|
29229
|
-
raw = openWritable(sqlite,
|
|
29237
|
+
raw = openWritable(sqlite, path8);
|
|
29230
29238
|
}
|
|
29231
|
-
return { raw, projectKey: project.projectKey, path:
|
|
29239
|
+
return { raw, projectKey: project.projectKey, path: path8, ...opts?.readOnly === true ? { readOnly: true } : {} };
|
|
29232
29240
|
} catch (err) {
|
|
29233
29241
|
if (isCorrupt(err)) throw new CtxError("DB_CORRUPT");
|
|
29234
29242
|
throw err;
|
|
@@ -29401,21 +29409,21 @@ function kiroDirOf(env, home, platform = process.platform) {
|
|
|
29401
29409
|
if (dir === void 0 || dir === "" || !p.isAbsolute(dir)) return fallback;
|
|
29402
29410
|
if (platform === "win32" && p.parse(dir).root.length < 2) return fallback;
|
|
29403
29411
|
const abs = p.resolve(dir);
|
|
29404
|
-
const
|
|
29405
|
-
const target =
|
|
29412
|
+
const real3 = platform === process.platform ? realOrSelf : (x) => x;
|
|
29413
|
+
const target = real3(abs);
|
|
29406
29414
|
if (p.parse(target).root === target) return fallback;
|
|
29407
|
-
const up = p.relative(target,
|
|
29415
|
+
const up = p.relative(target, real3(p.resolve(home)));
|
|
29408
29416
|
if (!p.isAbsolute(up) && up.split(p.sep)[0] !== "..") return fallback;
|
|
29409
29417
|
return abs;
|
|
29410
29418
|
}
|
|
29411
|
-
function realOrSelf(
|
|
29419
|
+
function realOrSelf(path8) {
|
|
29412
29420
|
const tail = [];
|
|
29413
|
-
for (let at =
|
|
29421
|
+
for (let at = path8; ; ) {
|
|
29414
29422
|
try {
|
|
29415
29423
|
return join(realpathSync.native(at), ...tail.reverse());
|
|
29416
29424
|
} catch {
|
|
29417
29425
|
const up = dirname(at);
|
|
29418
|
-
if (up === at) return
|
|
29426
|
+
if (up === at) return path8;
|
|
29419
29427
|
tail.push(basename(at));
|
|
29420
29428
|
at = up;
|
|
29421
29429
|
}
|
|
@@ -33080,10 +33088,10 @@ function assignProp3(target, prop, value) {
|
|
|
33080
33088
|
configurable: true
|
|
33081
33089
|
});
|
|
33082
33090
|
}
|
|
33083
|
-
function getElementAtPath3(obj,
|
|
33084
|
-
if (!
|
|
33091
|
+
function getElementAtPath3(obj, path8) {
|
|
33092
|
+
if (!path8)
|
|
33085
33093
|
return obj;
|
|
33086
|
-
return
|
|
33094
|
+
return path8.reduce((acc, key) => acc?.[key], obj);
|
|
33087
33095
|
}
|
|
33088
33096
|
function promiseAllObject3(promisesObj) {
|
|
33089
33097
|
const keys = Object.keys(promisesObj);
|
|
@@ -33403,11 +33411,11 @@ function aborted3(x, startIndex = 0) {
|
|
|
33403
33411
|
}
|
|
33404
33412
|
return false;
|
|
33405
33413
|
}
|
|
33406
|
-
function prefixIssues3(
|
|
33414
|
+
function prefixIssues3(path8, issues) {
|
|
33407
33415
|
return issues.map((iss) => {
|
|
33408
33416
|
var _a5;
|
|
33409
33417
|
(_a5 = iss).path ?? (_a5.path = []);
|
|
33410
|
-
iss.path.unshift(
|
|
33418
|
+
iss.path.unshift(path8);
|
|
33411
33419
|
return iss;
|
|
33412
33420
|
});
|
|
33413
33421
|
}
|
|
@@ -33544,7 +33552,7 @@ function treeifyError2(error42, _mapper) {
|
|
|
33544
33552
|
return issue4.message;
|
|
33545
33553
|
};
|
|
33546
33554
|
const result = { errors: [] };
|
|
33547
|
-
const processError = (error43,
|
|
33555
|
+
const processError = (error43, path8 = []) => {
|
|
33548
33556
|
var _a5, _b;
|
|
33549
33557
|
for (const issue4 of error43.issues) {
|
|
33550
33558
|
if (issue4.code === "invalid_union" && issue4.errors.length) {
|
|
@@ -33554,7 +33562,7 @@ function treeifyError2(error42, _mapper) {
|
|
|
33554
33562
|
} else if (issue4.code === "invalid_element") {
|
|
33555
33563
|
processError({ issues: issue4.issues }, issue4.path);
|
|
33556
33564
|
} else {
|
|
33557
|
-
const fullpath = [...
|
|
33565
|
+
const fullpath = [...path8, ...issue4.path];
|
|
33558
33566
|
if (fullpath.length === 0) {
|
|
33559
33567
|
result.errors.push(mapper(issue4));
|
|
33560
33568
|
continue;
|
|
@@ -33584,9 +33592,9 @@ function treeifyError2(error42, _mapper) {
|
|
|
33584
33592
|
processError(error42);
|
|
33585
33593
|
return result;
|
|
33586
33594
|
}
|
|
33587
|
-
function toDotPath(
|
|
33595
|
+
function toDotPath(path8) {
|
|
33588
33596
|
const segs = [];
|
|
33589
|
-
for (const seg of
|
|
33597
|
+
for (const seg of path8) {
|
|
33590
33598
|
if (typeof seg === "number")
|
|
33591
33599
|
segs.push(`[${seg}]`);
|
|
33592
33600
|
else if (typeof seg === "symbol")
|
|
@@ -44161,19 +44169,19 @@ function steeringFiles(worktree) {
|
|
|
44161
44169
|
function readAutoMemory(project) {
|
|
44162
44170
|
const rows = [];
|
|
44163
44171
|
for (const segs of [...MEMORY_FILES, ...steeringFiles(project.worktree)]) {
|
|
44164
|
-
const
|
|
44165
|
-
if (!isInside(project.worktree,
|
|
44172
|
+
const path8 = join5(project.worktree, ...segs);
|
|
44173
|
+
if (!isInside(project.worktree, path8)) continue;
|
|
44166
44174
|
try {
|
|
44167
|
-
const st = statSync3(
|
|
44175
|
+
const st = statSync3(path8);
|
|
44168
44176
|
if (!st.isFile()) continue;
|
|
44169
44177
|
rows.push({
|
|
44170
44178
|
origin: "memory",
|
|
44171
44179
|
ts: Math.trunc(st.mtimeMs),
|
|
44172
44180
|
seq: null,
|
|
44173
44181
|
sourceId: null,
|
|
44174
|
-
path:
|
|
44182
|
+
path: path8,
|
|
44175
44183
|
label: segs.join("/"),
|
|
44176
|
-
text: readFileSync3(
|
|
44184
|
+
text: readFileSync3(path8, "utf8")
|
|
44177
44185
|
});
|
|
44178
44186
|
} catch {
|
|
44179
44187
|
}
|
|
@@ -44797,7 +44805,7 @@ var ctxBatch = Object.freeze({
|
|
|
44797
44805
|
});
|
|
44798
44806
|
|
|
44799
44807
|
// src/core/tools/doctor.ts
|
|
44800
|
-
import { readdirSync as readdirSync7, readFileSync as
|
|
44808
|
+
import { readdirSync as readdirSync7, readFileSync as readFileSync11, existsSync as existsSync16 } from "node:fs";
|
|
44801
44809
|
import { basename as basename5, join as join15 } from "node:path";
|
|
44802
44810
|
|
|
44803
44811
|
// src/adapters/claude-code.ts
|
|
@@ -45137,6 +45145,14 @@ function canonicalName3(name) {
|
|
|
45137
45145
|
if (Object.hasOwn(NATIVE_TO_CANONICAL3, name)) return NATIVE_TO_CANONICAL3[name];
|
|
45138
45146
|
return name;
|
|
45139
45147
|
}
|
|
45148
|
+
var isNum = (v) => typeof v === "number" && Number.isFinite(v);
|
|
45149
|
+
function viewRange(name, input) {
|
|
45150
|
+
const r = input.view_range;
|
|
45151
|
+
if (name !== "view" || !Array.isArray(r) || !isNum(r[0])) return input;
|
|
45152
|
+
const out = { ...input, offset: r[0] };
|
|
45153
|
+
if (isNum(r[1]) && r[1] >= r[0]) out.limit = r[1] - r[0] + 1;
|
|
45154
|
+
return out;
|
|
45155
|
+
}
|
|
45140
45156
|
function readArgs(v) {
|
|
45141
45157
|
if (isRecord(v)) return v;
|
|
45142
45158
|
if (typeof v !== "string") return {};
|
|
@@ -45181,7 +45197,7 @@ function decode7(raw) {
|
|
|
45181
45197
|
if (event === "UserPromptSubmit" && typeof raw.prompt === "string") ev.prompt = raw.prompt;
|
|
45182
45198
|
if (event === "PreToolUse" || event === "PostToolUse") {
|
|
45183
45199
|
const toolName2 = String(raw[k.tool] ?? "");
|
|
45184
|
-
const tool = { name: toolName2, canonicalName: canonicalName3(toolName2), input: readArgs(raw[k.args]) };
|
|
45200
|
+
const tool = { name: toolName2, canonicalName: canonicalName3(toolName2), input: viewRange(toolName2, readArgs(raw[k.args])) };
|
|
45185
45201
|
ev.tool = tool;
|
|
45186
45202
|
}
|
|
45187
45203
|
if (event === "PostToolUse") ev.result = readResult3(raw[k.result], native.casing, native.failure);
|
|
@@ -45229,18 +45245,18 @@ function canonicalName4(name) {
|
|
|
45229
45245
|
if (sep3 <= 0 || sep3 === rest.length - 1) return name;
|
|
45230
45246
|
return "mcp:" + rest.slice(0, sep3) + ":" + rest.slice(sep3 + MCP_SEP2.length);
|
|
45231
45247
|
}
|
|
45232
|
-
var
|
|
45248
|
+
var isNum2 = (v) => typeof v === "number" && Number.isFinite(v);
|
|
45233
45249
|
function policyInput(name, canonical, input) {
|
|
45234
45250
|
if (canonical === "Read" && READ_TOOL_NAMES.includes(name)) {
|
|
45235
45251
|
const out = { ...input };
|
|
45236
45252
|
if (name === "read_file") {
|
|
45237
45253
|
if (typeof input.filePath === "string") out.file_path = input.filePath;
|
|
45238
|
-
if (
|
|
45239
|
-
if (
|
|
45240
|
-
} else if (Array.isArray(input.view_range) &&
|
|
45254
|
+
if (isNum2(input.startLine)) out.offset = input.startLine;
|
|
45255
|
+
if (isNum2(input.startLine) && isNum2(input.endLine) && input.endLine >= input.startLine) out.limit = input.endLine - input.startLine + 1;
|
|
45256
|
+
} else if (Array.isArray(input.view_range) && isNum2(input.view_range[0])) {
|
|
45241
45257
|
out.offset = input.view_range[0];
|
|
45242
45258
|
const end = input.view_range[1];
|
|
45243
|
-
if (
|
|
45259
|
+
if (isNum2(end) && end >= input.view_range[0]) out.limit = end - input.view_range[0] + 1;
|
|
45244
45260
|
}
|
|
45245
45261
|
return out;
|
|
45246
45262
|
}
|
|
@@ -45430,7 +45446,7 @@ var PI_EVENTS = {
|
|
|
45430
45446
|
tool_call: { event: "PreToolUse" },
|
|
45431
45447
|
tool_result: { event: "PostToolUse" }
|
|
45432
45448
|
};
|
|
45433
|
-
var NATIVE_TO_CANONICAL6 = { bash: "Bash", read: "Read" };
|
|
45449
|
+
var NATIVE_TO_CANONICAL6 = { bash: "Bash", read: "Read", edit: "Edit", write: "Write" };
|
|
45434
45450
|
function record4(v) {
|
|
45435
45451
|
return typeof v === "object" && v !== null && !Array.isArray(v) ? v : {};
|
|
45436
45452
|
}
|
|
@@ -45700,8 +45716,9 @@ var ADAPTERS = Object.freeze([
|
|
|
45700
45716
|
installMode: "in-process",
|
|
45701
45717
|
projectSource: "pi:ctx.cwd",
|
|
45702
45718
|
toolNamePrefix: TOOL_NAME_PREFIX9,
|
|
45703
|
-
nativeTools: { shell: ["bash"], read: ["read"] },
|
|
45719
|
+
nativeTools: { shell: ["bash", "powershell"], read: ["read"] },
|
|
45704
45720
|
execReadOnlyHint: false,
|
|
45721
|
+
// D-R38-PI-PWSH-1: Pi on Windows names its shell tool "powershell"
|
|
45705
45722
|
eventMap: { SessionStart: "session_start", UserPromptSubmit: "input", PreToolUse: "tool_call", PostToolUse: "tool_result" },
|
|
45706
45723
|
compactDelivery: "pi-flag",
|
|
45707
45724
|
compactSummary: "none",
|
|
@@ -45768,7 +45785,7 @@ function ownBundleDir() {
|
|
|
45768
45785
|
}
|
|
45769
45786
|
|
|
45770
45787
|
// src/core/ops/doctor-config.ts
|
|
45771
|
-
import { existsSync as
|
|
45788
|
+
import { existsSync as existsSync9, readdirSync as readdirSync6 } from "node:fs";
|
|
45772
45789
|
import { join as join10 } from "node:path";
|
|
45773
45790
|
|
|
45774
45791
|
// src/core/ops/detect-v1.ts
|
|
@@ -47910,15 +47927,15 @@ function withLayout(text, layout) {
|
|
|
47910
47927
|
}
|
|
47911
47928
|
|
|
47912
47929
|
// src/core/ops/host-config.ts
|
|
47913
|
-
function formatOf(
|
|
47914
|
-
if (
|
|
47915
|
-
if (
|
|
47930
|
+
function formatOf(path8) {
|
|
47931
|
+
if (path8.endsWith(JSONC_EXT)) return "jsonc";
|
|
47932
|
+
if (path8.endsWith(TOML_EXT)) return "toml";
|
|
47916
47933
|
return "json";
|
|
47917
47934
|
}
|
|
47918
|
-
function readHostConfig(agent,
|
|
47919
|
-
let file2 =
|
|
47935
|
+
function readHostConfig(agent, path8) {
|
|
47936
|
+
let file2 = path8;
|
|
47920
47937
|
if (agent === "opencode") {
|
|
47921
|
-
const jsonc = join7(dirname5(
|
|
47938
|
+
const jsonc = join7(dirname5(path8), OPENCODE_CONFIG_FILES[0]);
|
|
47922
47939
|
if (existsSync5(jsonc)) file2 = jsonc;
|
|
47923
47940
|
}
|
|
47924
47941
|
const raw = existsSync5(file2) ? readFileSync4(file2, "utf8") : "";
|
|
@@ -48082,14 +48099,14 @@ function scanToml(text) {
|
|
|
48082
48099
|
continue;
|
|
48083
48100
|
}
|
|
48084
48101
|
if (!node3.resolvedKey.every((seg) => typeof seg === "string")) continue;
|
|
48085
|
-
const
|
|
48086
|
-
for (const kv of node3.body) addKey(
|
|
48102
|
+
const path8 = node3.resolvedKey;
|
|
48103
|
+
for (const kv of node3.body) addKey(path8, kv);
|
|
48087
48104
|
if (node3.kind !== "standard") continue;
|
|
48088
48105
|
const start = lineStartOf(text, node3.range[0]);
|
|
48089
48106
|
const headEnd = lineEndOf(text, node3.key.range[1]);
|
|
48090
48107
|
const last2 = node3.body[node3.body.length - 1];
|
|
48091
48108
|
tables.push({
|
|
48092
|
-
path:
|
|
48109
|
+
path: path8,
|
|
48093
48110
|
header: text.slice(start, text[headEnd - 1] === "\n" ? headEnd - 1 : headEnd),
|
|
48094
48111
|
start,
|
|
48095
48112
|
end: last2 === void 0 ? headEnd : lineEndOf(text, last2.range[1])
|
|
@@ -48100,16 +48117,16 @@ function scanToml(text) {
|
|
|
48100
48117
|
function tomlTableSpans(text) {
|
|
48101
48118
|
return scanToml(text).tables;
|
|
48102
48119
|
}
|
|
48103
|
-
function parseHostConfig(agent,
|
|
48120
|
+
function parseHostConfig(agent, path8, text, format) {
|
|
48104
48121
|
try {
|
|
48105
48122
|
return format === "toml" ? scanToml(text).value : scanJson(text, format).value;
|
|
48106
48123
|
} catch {
|
|
48107
|
-
throw new CtxError("CONFIG_PARSE_FAILED", { agent, path:
|
|
48124
|
+
throw new CtxError("CONFIG_PARSE_FAILED", { agent, path: path8, format });
|
|
48108
48125
|
}
|
|
48109
48126
|
}
|
|
48110
|
-
function hostConfigValueAt(value,
|
|
48127
|
+
function hostConfigValueAt(value, path8) {
|
|
48111
48128
|
let cur = value;
|
|
48112
|
-
for (const seg of
|
|
48129
|
+
for (const seg of path8) {
|
|
48113
48130
|
if (!isPlainObject6(cur)) return void 0;
|
|
48114
48131
|
cur = cur[seg];
|
|
48115
48132
|
}
|
|
@@ -48142,32 +48159,32 @@ function indentUnit(root, clean) {
|
|
|
48142
48159
|
function render(value, unit, base) {
|
|
48143
48160
|
return JSON.stringify(value, null, unit).split("\n").join("\n" + base);
|
|
48144
48161
|
}
|
|
48145
|
-
function nest(
|
|
48162
|
+
function nest(path8, value) {
|
|
48146
48163
|
let out = value;
|
|
48147
|
-
for (let k =
|
|
48164
|
+
for (let k = path8.length - 1; k >= 0; k -= 1) out = { [path8[k]]: out };
|
|
48148
48165
|
return out;
|
|
48149
48166
|
}
|
|
48150
|
-
function setJsonText(text, format,
|
|
48167
|
+
function setJsonText(text, format, path8, value) {
|
|
48151
48168
|
const doc = scanJson(text, format);
|
|
48152
48169
|
const unit = indentUnit(doc.root, doc.clean);
|
|
48153
|
-
if (doc.root === null) return render(nest(
|
|
48170
|
+
if (doc.root === null) return render(nest(path8, value), unit, "") + "\n";
|
|
48154
48171
|
let node3 = doc.root;
|
|
48155
48172
|
let depth = 0;
|
|
48156
|
-
while (depth <
|
|
48157
|
-
const hit = node3.members.find((m) => m.key ===
|
|
48173
|
+
while (depth < path8.length && node3.kind === "object") {
|
|
48174
|
+
const hit = node3.members.find((m) => m.key === path8[depth]);
|
|
48158
48175
|
if (hit === void 0) break;
|
|
48159
48176
|
node3 = hit.node;
|
|
48160
48177
|
depth += 1;
|
|
48161
48178
|
}
|
|
48162
|
-
if (depth ===
|
|
48179
|
+
if (depth === path8.length) {
|
|
48163
48180
|
return text.slice(0, node3.start) + render(value, unit, lineIndent(doc.clean, node3.start)) + text.slice(node3.end);
|
|
48164
48181
|
}
|
|
48165
|
-
if (node3.kind !== "object") throw new SyntaxError("not an object at " +
|
|
48166
|
-
const rest = nest(
|
|
48182
|
+
if (node3.kind !== "object") throw new SyntaxError("not an object at " + path8.slice(0, depth).join("."));
|
|
48183
|
+
const rest = nest(path8.slice(depth + 1), value);
|
|
48167
48184
|
const last2 = node3.members[node3.members.length - 1];
|
|
48168
48185
|
if (last2 === void 0) {
|
|
48169
48186
|
const base2 = lineIndent(doc.clean, node3.start);
|
|
48170
|
-
const member2 = "\n" + base2 + unit + JSON.stringify(
|
|
48187
|
+
const member2 = "\n" + base2 + unit + JSON.stringify(path8[depth]) + ": " + render(rest, unit, base2 + unit) + "\n" + base2;
|
|
48171
48188
|
return text.slice(0, node3.start + 1) + member2 + text.slice(node3.end - 1);
|
|
48172
48189
|
}
|
|
48173
48190
|
const base = lineIndent(doc.clean, last2.keyStart);
|
|
@@ -48175,7 +48192,7 @@ function setJsonText(text, format, path7, value) {
|
|
|
48175
48192
|
while (" \r\n".includes(doc.clean[at])) at += 1;
|
|
48176
48193
|
const trailing = doc.clean[at] === ",";
|
|
48177
48194
|
const insertAt = trailing ? at + 1 : last2.node.end;
|
|
48178
|
-
const member = (trailing ? "" : ",") + "\n" + base + JSON.stringify(
|
|
48195
|
+
const member = (trailing ? "" : ",") + "\n" + base + JSON.stringify(path8[depth]) + ": " + render(rest, unit, base);
|
|
48179
48196
|
return text.slice(0, insertAt) + member + text.slice(insertAt);
|
|
48180
48197
|
}
|
|
48181
48198
|
function tomlScalar(v) {
|
|
@@ -48193,17 +48210,17 @@ function tomlHeaderKey(seg) {
|
|
|
48193
48210
|
}
|
|
48194
48211
|
return seg;
|
|
48195
48212
|
}
|
|
48196
|
-
function tomlBlock(
|
|
48197
|
-
let out = "[" +
|
|
48213
|
+
function tomlBlock(path8, value) {
|
|
48214
|
+
let out = "[" + path8.map(tomlHeaderKey).join(".") + "]\n";
|
|
48198
48215
|
const subs = [];
|
|
48199
48216
|
for (const [k, v] of Object.entries(value)) {
|
|
48200
|
-
if (isPlainObject6(v)) subs.push(tomlBlock([...
|
|
48217
|
+
if (isPlainObject6(v)) subs.push(tomlBlock([...path8, k], v));
|
|
48201
48218
|
else out += tomlHeaderKey(k) + " = " + tomlScalar(v) + "\n";
|
|
48202
48219
|
}
|
|
48203
48220
|
return [out, ...subs].join("\n");
|
|
48204
48221
|
}
|
|
48205
|
-
function under(
|
|
48206
|
-
return
|
|
48222
|
+
function under(path8, prefix) {
|
|
48223
|
+
return path8.length >= prefix.length && prefix.every((seg, k) => path8[k] === seg);
|
|
48207
48224
|
}
|
|
48208
48225
|
function keyLineRange(text, k) {
|
|
48209
48226
|
const ls = lineStartOf(text, k.start);
|
|
@@ -48220,10 +48237,10 @@ function withValueAt(root, rel, value) {
|
|
|
48220
48237
|
else base[rel[0]] = next;
|
|
48221
48238
|
return base;
|
|
48222
48239
|
}
|
|
48223
|
-
function replaceToml(text, doc,
|
|
48224
|
-
const block = value === void 0 ? "" : tomlBlock(
|
|
48225
|
-
const owned = doc.tables.filter((t) => under(t.path,
|
|
48226
|
-
const cuts = doc.keys.filter((k) => under(k.full,
|
|
48240
|
+
function replaceToml(text, doc, path8, value) {
|
|
48241
|
+
const block = value === void 0 ? "" : tomlBlock(path8, value);
|
|
48242
|
+
const owned = doc.tables.filter((t) => under(t.path, path8));
|
|
48243
|
+
const cuts = doc.keys.filter((k) => under(k.full, path8) && !under(k.base, path8)).map((k) => [...keyLineRange(text, k), ""]);
|
|
48227
48244
|
owned.forEach((t, n) => cuts.push([t.start, t.end, n === 0 ? block : ""]));
|
|
48228
48245
|
cuts.sort((a, b) => b[0] - a[0]);
|
|
48229
48246
|
let out = text;
|
|
@@ -48233,27 +48250,27 @@ function replaceToml(text, doc, path7, value) {
|
|
|
48233
48250
|
return out + sep3 + block;
|
|
48234
48251
|
}
|
|
48235
48252
|
var tableLike = (v) => v === void 0 || isPlainObject6(v);
|
|
48236
|
-
function setTomlText(text,
|
|
48253
|
+
function setTomlText(text, path8, value) {
|
|
48237
48254
|
if (value !== void 0 && !isPlainObject6(value)) throw new SyntaxError("TOML edits replace a whole table");
|
|
48238
48255
|
const doc = scanToml(text);
|
|
48239
|
-
const cur = hostConfigValueAt(doc.value,
|
|
48256
|
+
const cur = hostConfigValueAt(doc.value, path8);
|
|
48240
48257
|
if (sameValue(cur, value)) return text;
|
|
48241
|
-
const inline = doc.keys.find((k) => k.inline && k.full.length <
|
|
48258
|
+
const inline = doc.keys.find((k) => k.inline && k.full.length < path8.length && under(path8, k.full));
|
|
48242
48259
|
if (inline !== void 0) {
|
|
48243
|
-
const whole2 = withValueAt(hostConfigValueAt(doc.value, inline.full),
|
|
48260
|
+
const whole2 = withValueAt(hostConfigValueAt(doc.value, inline.full), path8.slice(inline.full.length), value);
|
|
48244
48261
|
return replaceToml(text, doc, inline.full, whole2);
|
|
48245
48262
|
}
|
|
48246
48263
|
if (isPlainObject6(cur) && isPlainObject6(value)) {
|
|
48247
48264
|
const names = [.../* @__PURE__ */ new Set([...Object.keys(cur), ...Object.keys(value)])].filter((k) => !sameValue(cur[k], value[k]));
|
|
48248
48265
|
if (names.every((k) => tableLike(cur[k]) && tableLike(value[k]))) {
|
|
48249
48266
|
let out = text;
|
|
48250
|
-
for (const k of names) out = setTomlText(out, [...
|
|
48267
|
+
for (const k of names) out = setTomlText(out, [...path8, k], value[k]);
|
|
48251
48268
|
return out;
|
|
48252
48269
|
}
|
|
48253
48270
|
}
|
|
48254
|
-
return replaceToml(text, doc,
|
|
48271
|
+
return replaceToml(text, doc, path8, value);
|
|
48255
48272
|
}
|
|
48256
|
-
function setText(agent,
|
|
48273
|
+
function setText(agent, path8, text, format, key, value) {
|
|
48257
48274
|
try {
|
|
48258
48275
|
if (format !== "toml") return setJsonText(text, format, key, value);
|
|
48259
48276
|
const out = setTomlText(text, key, value);
|
|
@@ -48262,7 +48279,7 @@ function setText(agent, path7, text, format, key, value) {
|
|
|
48262
48279
|
if (!sameValue(landed, value) && !(emptyTable && landed === void 0)) throw new SyntaxError("edit did not land");
|
|
48263
48280
|
return out;
|
|
48264
48281
|
} catch {
|
|
48265
|
-
throw new CtxError("CONFIG_PARSE_FAILED", { agent, path:
|
|
48282
|
+
throw new CtxError("CONFIG_PARSE_FAILED", { agent, path: path8, format });
|
|
48266
48283
|
}
|
|
48267
48284
|
}
|
|
48268
48285
|
function serverScript() {
|
|
@@ -48309,14 +48326,14 @@ function ownTargets(agent, accept) {
|
|
|
48309
48326
|
if (agent === "pi") return [listTarget(PI_PACKAGES_KEY, PI_GIT_PACKAGE, V1_PI_PACKAGE)];
|
|
48310
48327
|
return [];
|
|
48311
48328
|
}
|
|
48312
|
-
function applyEdits(agent,
|
|
48313
|
-
const parsed = parseHostConfig(agent,
|
|
48329
|
+
function applyEdits(agent, path8, text, format, wanted) {
|
|
48330
|
+
const parsed = parseHostConfig(agent, path8, text, format);
|
|
48314
48331
|
let out = text;
|
|
48315
48332
|
const edits = [];
|
|
48316
48333
|
for (const [key, after] of wanted) {
|
|
48317
48334
|
const before = hostConfigValueAt(parsed, key);
|
|
48318
48335
|
if (sameValue(before, after)) continue;
|
|
48319
|
-
out = setText(agent,
|
|
48336
|
+
out = setText(agent, path8, out, format, key, after);
|
|
48320
48337
|
edits.push({ path: key.join("."), before, after });
|
|
48321
48338
|
}
|
|
48322
48339
|
return { text: out, format, edits };
|
|
@@ -48337,7 +48354,7 @@ function writeHostConfigEdit(_requested, current, patch) {
|
|
|
48337
48354
|
// src/core/ops/detect-v1.ts
|
|
48338
48355
|
var isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
48339
48356
|
var keyPath = (...parts) => parts.join(".");
|
|
48340
|
-
var finding = (file2,
|
|
48357
|
+
var finding = (file2, path8, reason) => ({ file: file2, path: path8, reason });
|
|
48341
48358
|
function stripJsonc(text) {
|
|
48342
48359
|
let out = "";
|
|
48343
48360
|
let inStr = false;
|
|
@@ -48542,12 +48559,17 @@ function scanKiro(agentHome, project, out) {
|
|
|
48542
48559
|
}
|
|
48543
48560
|
dataDir(join8(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
48544
48561
|
}
|
|
48562
|
+
function piNpmIsCurrent(piAgentDir) {
|
|
48563
|
+
const doc = readJson(join8(piAgentDir, PI_NPM_DIR, PI_NODE_MODULES_DIR, SERVER_KEY, PI_PACKAGE_JSON_FILE));
|
|
48564
|
+
const version4 = isObj(doc) && typeof doc.version === "string" ? doc.version : "";
|
|
48565
|
+
return Number.parseInt(version4, 10) >= PI_CURRENT_MAJOR;
|
|
48566
|
+
}
|
|
48545
48567
|
function scanPi(piAgentDir, agentHome, out) {
|
|
48546
48568
|
const file2 = join8(piAgentDir, SETTINGS_FILE);
|
|
48547
48569
|
const doc = readJson(file2);
|
|
48548
48570
|
listOf(isObj(doc) ? doc[PI_PACKAGES_KEY] : void 0).forEach((pkg, i) => {
|
|
48549
48571
|
const spec = isObj(pkg) ? pkg[PI_PACKAGE_SOURCE_KEY] : pkg;
|
|
48550
|
-
if (spec === V1_PI_PACKAGE) out.push(finding(file2, keyPath(PI_PACKAGES_KEY, i), V1_REASON.piNpm));
|
|
48572
|
+
if (spec === V1_PI_PACKAGE && !piNpmIsCurrent(piAgentDir)) out.push(finding(file2, keyPath(PI_PACKAGES_KEY, i), V1_REASON.piNpm));
|
|
48551
48573
|
});
|
|
48552
48574
|
dataDir(join8(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
48553
48575
|
}
|
|
@@ -48644,8 +48666,8 @@ function detectV1(agent, home, scope = {}) {
|
|
|
48644
48666
|
import { existsSync as existsSync7, readdirSync as readdirSync5, readFileSync as readFileSync6, realpathSync as realpathSync4 } from "node:fs";
|
|
48645
48667
|
import { dirname as dirname6, isAbsolute, join as join9, sep as sep2 } from "node:path";
|
|
48646
48668
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
48647
|
-
function missing(agent,
|
|
48648
|
-
return new CtxError("PLUGIN_ROOT_MISSING", { agent, path:
|
|
48669
|
+
function missing(agent, path8) {
|
|
48670
|
+
return new CtxError("PLUGIN_ROOT_MISSING", { agent, path: path8 });
|
|
48649
48671
|
}
|
|
48650
48672
|
var parseOrNull = (text) => {
|
|
48651
48673
|
try {
|
|
@@ -48674,9 +48696,9 @@ function recordedInstalls(text) {
|
|
|
48674
48696
|
}
|
|
48675
48697
|
return out;
|
|
48676
48698
|
}
|
|
48677
|
-
var realOrNull = (
|
|
48699
|
+
var realOrNull = (path8) => {
|
|
48678
48700
|
try {
|
|
48679
|
-
return realpathSync4.native(
|
|
48701
|
+
return realpathSync4.native(path8);
|
|
48680
48702
|
} catch {
|
|
48681
48703
|
return null;
|
|
48682
48704
|
}
|
|
@@ -48774,12 +48796,81 @@ function candidate(adapter, env, worktree) {
|
|
|
48774
48796
|
}
|
|
48775
48797
|
}
|
|
48776
48798
|
function resolvePluginRoot(adapter, env, worktree) {
|
|
48777
|
-
const
|
|
48799
|
+
const path8 = candidate(adapter, env, worktree);
|
|
48800
|
+
try {
|
|
48801
|
+
return realpathSync4.native(path8);
|
|
48802
|
+
} catch {
|
|
48803
|
+
throw missing(adapter.id, path8);
|
|
48804
|
+
}
|
|
48805
|
+
}
|
|
48806
|
+
|
|
48807
|
+
// src/setup/pi-gate.ts
|
|
48808
|
+
import { existsSync as existsSync8, readFileSync as readFileSync7, realpathSync as realpathSync5 } from "node:fs";
|
|
48809
|
+
import path4 from "node:path";
|
|
48810
|
+
var EXTENSIONS_KEY = "extensions";
|
|
48811
|
+
var PROJECT_DIR = ".pi";
|
|
48812
|
+
var TRUST_FILE = "trust.json";
|
|
48813
|
+
var ALWAYS = "always";
|
|
48814
|
+
var SOURCE_PREFIXES = ["npm:", "git:"];
|
|
48815
|
+
function load(file2) {
|
|
48816
|
+
if (!existsSync8(file2)) return void 0;
|
|
48778
48817
|
try {
|
|
48779
|
-
return
|
|
48818
|
+
return { file: file2, doc: parseHostConfig("pi", file2, hostText(readFileSync7(file2, "utf8")), "json") };
|
|
48780
48819
|
} catch {
|
|
48781
|
-
|
|
48820
|
+
return void 0;
|
|
48821
|
+
}
|
|
48822
|
+
}
|
|
48823
|
+
var real2 = (p) => {
|
|
48824
|
+
try {
|
|
48825
|
+
return realpathSync5(p);
|
|
48826
|
+
} catch {
|
|
48827
|
+
return path4.resolve(p);
|
|
48828
|
+
}
|
|
48829
|
+
};
|
|
48830
|
+
function sourceName(source) {
|
|
48831
|
+
let s = source;
|
|
48832
|
+
for (const p of SOURCE_PREFIXES) if (s.startsWith(p)) s = s.slice(p.length);
|
|
48833
|
+
const last2 = s.split("/").pop() ?? "";
|
|
48834
|
+
const at = last2.indexOf("@", 1);
|
|
48835
|
+
const name = at > 0 ? last2.slice(0, at) : last2;
|
|
48836
|
+
return name.endsWith(".git") ? name.slice(0, -4) : name;
|
|
48837
|
+
}
|
|
48838
|
+
function isOwn(source, pkgDir) {
|
|
48839
|
+
if (typeof source !== "string") return false;
|
|
48840
|
+
return real2(source) === real2(pkgDir) || sourceName(source) === SERVER_KEY;
|
|
48841
|
+
}
|
|
48842
|
+
function ownEntries(src, pkgDir) {
|
|
48843
|
+
const list3 = hostConfigValueAt(src.doc, [PI_PACKAGES_KEY]);
|
|
48844
|
+
if (!Array.isArray(list3)) return [];
|
|
48845
|
+
const out = [];
|
|
48846
|
+
for (const e of list3) {
|
|
48847
|
+
const obj = typeof e === "object" && e !== null && !Array.isArray(e) ? e : void 0;
|
|
48848
|
+
if (!isOwn(obj ? obj[PI_PACKAGE_SOURCE_KEY] : e, pkgDir)) continue;
|
|
48849
|
+
const ext = obj?.[EXTENSIONS_KEY];
|
|
48850
|
+
out.push({ source: src, patterns: Array.isArray(ext) ? ext.filter((x) => typeof x === "string") : void 0 });
|
|
48851
|
+
}
|
|
48852
|
+
return out;
|
|
48853
|
+
}
|
|
48854
|
+
function projectTrusted(agentDir, userDoc, cwd) {
|
|
48855
|
+
const trust = load(path4.join(agentDir, TRUST_FILE));
|
|
48856
|
+
const entries = /* @__PURE__ */ new Map();
|
|
48857
|
+
if (trust && typeof trust.doc === "object" && trust.doc !== null) for (const [k, v] of Object.entries(trust.doc)) entries.set(real2(k), v);
|
|
48858
|
+
let dir = real2(cwd);
|
|
48859
|
+
for (; ; ) {
|
|
48860
|
+
const v = entries.get(dir);
|
|
48861
|
+
if (v === true || v === false) return v;
|
|
48862
|
+
const up = path4.dirname(dir);
|
|
48863
|
+
if (up === dir) break;
|
|
48864
|
+
dir = up;
|
|
48782
48865
|
}
|
|
48866
|
+
return hostConfigValueAt(userDoc, ["defaultProjectTrust"]) === ALWAYS;
|
|
48867
|
+
}
|
|
48868
|
+
function piInstalledIn(env, home, pkgDir, cwd) {
|
|
48869
|
+
const agentDir = piAgentDirOf(env, home);
|
|
48870
|
+
const user = load(path4.join(agentDir, SETTINGS_FILE));
|
|
48871
|
+
const project = load(path4.join(cwd, PROJECT_DIR, SETTINGS_FILE));
|
|
48872
|
+
if (project && projectTrusted(agentDir, user?.doc, cwd) && ownEntries(project, pkgDir).length > 0) return project.file;
|
|
48873
|
+
return user && ownEntries(user, pkgDir).length > 0 ? user.file : void 0;
|
|
48783
48874
|
}
|
|
48784
48875
|
|
|
48785
48876
|
// src/core/ops/doctor-config.ts
|
|
@@ -48882,14 +48973,14 @@ function codexNativeDir(env, home) {
|
|
|
48882
48973
|
}
|
|
48883
48974
|
if (enabled !== true) return null;
|
|
48884
48975
|
const cache = join10(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
|
|
48885
|
-
if (!
|
|
48976
|
+
if (!existsSync9(cache)) return null;
|
|
48886
48977
|
const found = [];
|
|
48887
48978
|
for (const market of readdirSync6(cache)) {
|
|
48888
48979
|
const plugin = join10(cache, market, SERVER_KEY);
|
|
48889
|
-
if (!
|
|
48980
|
+
if (!existsSync9(plugin)) continue;
|
|
48890
48981
|
for (const version4 of readdirSync6(plugin).sort()) {
|
|
48891
48982
|
const dir = join10(plugin, version4, CODEX_PLUGIN_SUBDIR);
|
|
48892
|
-
if (
|
|
48983
|
+
if (existsSync9(join10(dir, CODEX_PLUGIN_MCP_FILE))) found.push(dir);
|
|
48893
48984
|
}
|
|
48894
48985
|
}
|
|
48895
48986
|
return found.length === 0 ? null : found[found.length - 1];
|
|
@@ -48980,12 +49071,17 @@ function checkHostConfig(row5, env, worktree) {
|
|
|
48980
49071
|
const choice = marketplaceChoice(env, worktree);
|
|
48981
49072
|
if ("installs" in choice) return fail("D3", D3_ROOT_DETAIL(choice.installs.map((r) => r.installPath)), D3_ROOT_FIX(choice.installs));
|
|
48982
49073
|
}
|
|
49074
|
+
if (row5.id === "pi") return checkPiInstall(env, home, worktree);
|
|
48983
49075
|
const parts = [...mcpWrong(row5, home, env, worktree) ? [PART_MCP] : [], ...hookParts(row5, home, env, worktree)];
|
|
48984
|
-
|
|
48985
|
-
if (parts.length === 0) return read === null ? pass("D3") : { ...pass("D3"), detail: read };
|
|
49076
|
+
if (parts.length === 0) return pass("D3");
|
|
48986
49077
|
const detail = D3_DETAIL(parts);
|
|
48987
49078
|
const fix = parts.includes(PART_MCP) ? D3_NO_SETUP_FIX(row5.id) : DOCTOR_FIX_UPGRADE;
|
|
48988
|
-
return fail("D3",
|
|
49079
|
+
return fail("D3", detail, fix);
|
|
49080
|
+
}
|
|
49081
|
+
function checkPiInstall(env, home, worktree) {
|
|
49082
|
+
const found = piInstalledIn(env, home, ownBundleDir(), worktree);
|
|
49083
|
+
if (found !== void 0) return { ...pass("D3"), detail: found };
|
|
49084
|
+
return fail("D3", D3_DETAIL([PART_MCP]) + D4_REASON_JOIN + join10(piAgentDirOf(env, home), SETTINGS_FILE), NATIVE_INSTALL.pi[0]);
|
|
48989
49085
|
}
|
|
48990
49086
|
function checkV1Leftovers(agent, home, scope = {}) {
|
|
48991
49087
|
const findings = detectV1(agent, home, scope);
|
|
@@ -49038,7 +49134,7 @@ function configPaths(row5, env, worktree) {
|
|
|
49038
49134
|
}
|
|
49039
49135
|
|
|
49040
49136
|
// src/core/ops/doctor-db.ts
|
|
49041
|
-
import { existsSync as
|
|
49137
|
+
import { existsSync as existsSync10, statSync as statSync4 } from "node:fs";
|
|
49042
49138
|
var unknown4 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail });
|
|
49043
49139
|
var pass2 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "PASS", detail });
|
|
49044
49140
|
var fail2 = (detail, fixCommand) => ({ id: "D8", label: DOCTOR_LABEL.D8, status: "FAIL", detail, fixCommand });
|
|
@@ -49057,8 +49153,8 @@ async function loadSqlite2() {
|
|
|
49057
49153
|
return null;
|
|
49058
49154
|
}
|
|
49059
49155
|
}
|
|
49060
|
-
function openRead(sqlite,
|
|
49061
|
-
return new sqlite.DatabaseSync(
|
|
49156
|
+
function openRead(sqlite, path8) {
|
|
49157
|
+
return new sqlite.DatabaseSync(path8, { timeout: DB_TIMEOUT_MS, readOnly: true });
|
|
49062
49158
|
}
|
|
49063
49159
|
var cell = (row5) => Object.values(row5)[0];
|
|
49064
49160
|
function readSchema(raw) {
|
|
@@ -49079,16 +49175,16 @@ function failsOnCorrupt(step) {
|
|
|
49079
49175
|
function orphanFiles(dbPath) {
|
|
49080
49176
|
const files = [];
|
|
49081
49177
|
for (const suffix of [DB_WAL_SUFFIX, DB_SHM_SUFFIX]) {
|
|
49082
|
-
const
|
|
49083
|
-
if (
|
|
49178
|
+
const path8 = dbPath + suffix;
|
|
49179
|
+
if (existsSync10(path8)) files.push({ path: path8, bytes: statSync4(path8).size });
|
|
49084
49180
|
}
|
|
49085
|
-
return files.length > 0 && !
|
|
49181
|
+
return files.length > 0 && !existsSync10(dbPath) ? files : [];
|
|
49086
49182
|
}
|
|
49087
49183
|
async function checkDb(project) {
|
|
49088
49184
|
const clean = { schemaStale: false, integrityFailed: false, orphan: [] };
|
|
49089
49185
|
const orphan = orphanFiles(project.dbPath);
|
|
49090
49186
|
if (orphan.length > 0) return { row: fail2(D8_ORPHAN_DETAIL(orphan), D8_ORPHAN_FIX), schemaStale: false, integrityFailed: false, orphan };
|
|
49091
|
-
if (!
|
|
49187
|
+
if (!existsSync10(project.dbPath)) return { row: pass2("D8", DOCTOR_PASS_DETAIL), ...clean };
|
|
49092
49188
|
const sqlite = await loadSqlite2();
|
|
49093
49189
|
if (sqlite === null) return { row: unknown4("D8", D2_SQLITE_DETAIL), ...clean };
|
|
49094
49190
|
let raw = null;
|
|
@@ -49114,7 +49210,7 @@ async function checkDb(project) {
|
|
|
49114
49210
|
}
|
|
49115
49211
|
}
|
|
49116
49212
|
async function checkIndex(project) {
|
|
49117
|
-
if (!
|
|
49213
|
+
if (!existsSync10(project.dbPath)) return pass2("D9", D9_INDEX_DETAIL(0, 0));
|
|
49118
49214
|
const sqlite = await loadSqlite2();
|
|
49119
49215
|
if (sqlite === null) return unknown4("D9", D2_SQLITE_DETAIL);
|
|
49120
49216
|
let raw = null;
|
|
@@ -49131,7 +49227,7 @@ async function checkIndex(project) {
|
|
|
49131
49227
|
}
|
|
49132
49228
|
|
|
49133
49229
|
// src/core/ops/doctor-env.ts
|
|
49134
|
-
import { existsSync as
|
|
49230
|
+
import { existsSync as existsSync11, readFileSync as readFileSync8, realpathSync as realpathSync6 } from "node:fs";
|
|
49135
49231
|
import { isAbsolute as isAbsolute2, join as join11, relative } from "node:path";
|
|
49136
49232
|
function pass3(id, detail = DOCTOR_PASS_DETAIL) {
|
|
49137
49233
|
return { id, label: DOCTOR_LABEL[id], status: "PASS", detail };
|
|
@@ -49144,7 +49240,7 @@ function fail3(id, detail, fixCommand) {
|
|
|
49144
49240
|
}
|
|
49145
49241
|
function bundleVersion(bundleDir2) {
|
|
49146
49242
|
try {
|
|
49147
|
-
const v = JSON.parse(
|
|
49243
|
+
const v = JSON.parse(readFileSync8(join11(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
|
|
49148
49244
|
return typeof v === "string" && v !== "" ? v : void 0;
|
|
49149
49245
|
} catch {
|
|
49150
49246
|
return void 0;
|
|
@@ -49294,8 +49390,8 @@ function checkMcp(ctx) {
|
|
|
49294
49390
|
return named2 || versioned ? pass3("D6") : unknown5("D6", D6_UNKNOWN_DETAIL);
|
|
49295
49391
|
}
|
|
49296
49392
|
function piCwdInside(worktree, piCwd) {
|
|
49297
|
-
if (piCwd === void 0 || !
|
|
49298
|
-
const rel = relative(worktree,
|
|
49393
|
+
if (piCwd === void 0 || !existsSync11(piCwd)) return false;
|
|
49394
|
+
const rel = relative(worktree, realpathSync6.native(piCwd));
|
|
49299
49395
|
return rel === "" || !rel.startsWith("..") && !isAbsolute2(rel);
|
|
49300
49396
|
}
|
|
49301
49397
|
function checkProject(i) {
|
|
@@ -49315,20 +49411,20 @@ function checkShell(env) {
|
|
|
49315
49411
|
}
|
|
49316
49412
|
|
|
49317
49413
|
// src/core/ops/doctor-hook.ts
|
|
49318
|
-
import { existsSync as
|
|
49414
|
+
import { existsSync as existsSync13, mkdtempSync, readFileSync as readFileSync9, realpathSync as realpathSync8, rmSync as rmSync4 } from "node:fs";
|
|
49319
49415
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
49320
|
-
import
|
|
49416
|
+
import path7 from "node:path";
|
|
49321
49417
|
|
|
49322
49418
|
// src/setup/codex-trust.ts
|
|
49323
49419
|
import { createHash } from "node:crypto";
|
|
49324
|
-
import { existsSync as
|
|
49325
|
-
import
|
|
49420
|
+
import { existsSync as existsSync12, realpathSync as realpathSync7 } from "node:fs";
|
|
49421
|
+
import path6 from "node:path";
|
|
49326
49422
|
import { spawn as spawn2, spawnSync as spawnSync2 } from "node:child_process";
|
|
49327
49423
|
|
|
49328
49424
|
// src/setup/spawn-bin.ts
|
|
49329
49425
|
import { spawnSync } from "node:child_process";
|
|
49330
49426
|
import { accessSync as accessSync2, constants as fsc, statSync as statSync5 } from "node:fs";
|
|
49331
|
-
import
|
|
49427
|
+
import path5 from "node:path";
|
|
49332
49428
|
var WIN_EXT = ".COM;.EXE;.BAT;.CMD";
|
|
49333
49429
|
var WIN_SHIM_EXTS = Object.freeze([".cmd", ".bat"]);
|
|
49334
49430
|
var DEFAULT_COMSPEC = "cmd.exe";
|
|
@@ -49339,10 +49435,10 @@ function whichBin(bin, env, platform = process.platform) {
|
|
|
49339
49435
|
const get = (k) => envGet(env, k);
|
|
49340
49436
|
const win = platform === "win32";
|
|
49341
49437
|
const exts = win ? (get("PATHEXT") || WIN_EXT).split(";").filter(Boolean) : [""];
|
|
49342
|
-
const names = win &&
|
|
49438
|
+
const names = win && path5.extname(bin) ? [bin] : exts.map((e) => bin + e.toLowerCase());
|
|
49343
49439
|
for (const dir of pathEntries(get("PATH") ?? "", platform)) {
|
|
49344
49440
|
for (const n of names) {
|
|
49345
|
-
const f =
|
|
49441
|
+
const f = path5.join(dir, n);
|
|
49346
49442
|
try {
|
|
49347
49443
|
accessSync2(f, fsc.X_OK);
|
|
49348
49444
|
if (statSync5(f).isFile()) return f;
|
|
@@ -49383,7 +49479,7 @@ function winCmdLine(file2, args, env = {}) {
|
|
|
49383
49479
|
return `"${[file2, ...args].map(q).join(" ")}"`;
|
|
49384
49480
|
}
|
|
49385
49481
|
function spawnForm(file2, args, env, platform = process.platform) {
|
|
49386
|
-
if (platform === "win32" && WIN_SHIM_EXTS.includes(
|
|
49482
|
+
if (platform === "win32" && WIN_SHIM_EXTS.includes(path5.extname(file2).toLowerCase())) {
|
|
49387
49483
|
return { command: envGet(env, "COMSPEC") || DEFAULT_COMSPEC, args: ["/d", "/v:off", "/s", "/c", winCmdLine(file2, args, env)], windowsVerbatimArguments: true };
|
|
49388
49484
|
}
|
|
49389
49485
|
return { command: file2, args, windowsVerbatimArguments: false };
|
|
@@ -49407,10 +49503,10 @@ function codexHomeFromReply(out) {
|
|
|
49407
49503
|
return void 0;
|
|
49408
49504
|
}
|
|
49409
49505
|
function sameDir(a, b, platform = process.platform) {
|
|
49410
|
-
if (platform !== "win32") return
|
|
49506
|
+
if (platform !== "win32") return path6.posix.normalize(a) === path6.posix.normalize(b);
|
|
49411
49507
|
const norm = (p) => {
|
|
49412
49508
|
const bare2 = p.startsWith(WIN_VERBATIM_PREFIX) ? p.slice(WIN_VERBATIM_PREFIX.length) : p;
|
|
49413
|
-
const n =
|
|
49509
|
+
const n = path6.win32.normalize(bare2).toLowerCase();
|
|
49414
49510
|
return n.length > 3 && n.endsWith("\\") ? n.slice(0, -1) : n;
|
|
49415
49511
|
};
|
|
49416
49512
|
return norm(a) === norm(b);
|
|
@@ -49543,11 +49639,11 @@ function isObject5(v) {
|
|
|
49543
49639
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
49544
49640
|
}
|
|
49545
49641
|
function loadFixture(bundleDir2, agent) {
|
|
49546
|
-
const file2 =
|
|
49547
|
-
if (!
|
|
49642
|
+
const file2 = path7.join(bundleDir2, HOOK_FIXTURE_DIR, HOOK_FIXTURE_FILE);
|
|
49643
|
+
if (!existsSync13(file2)) return { cause: D5_FIXTURE_FILE_ABSENT(file2) };
|
|
49548
49644
|
let all;
|
|
49549
49645
|
try {
|
|
49550
|
-
all = JSON.parse(hostText(
|
|
49646
|
+
all = JSON.parse(hostText(readFileSync9(file2, "utf8")));
|
|
49551
49647
|
} catch (err) {
|
|
49552
49648
|
return { cause: D5_FIXTURE_PARSE(file2, err instanceof Error ? err.message : String(err)) };
|
|
49553
49649
|
}
|
|
@@ -49607,9 +49703,9 @@ function isNativeShape(agent, stdout, exitCode, killed, event) {
|
|
|
49607
49703
|
}
|
|
49608
49704
|
}
|
|
49609
49705
|
var READ_PROBE_LINES = 4 * Math.ceil(REPLACE_TRIGGER_BYTES / 40);
|
|
49610
|
-
function readProbePayload(cwd) {
|
|
49706
|
+
function readProbePayload(cwd, ranged) {
|
|
49611
49707
|
const content = Array.from({ length: READ_PROBE_LINES }, (_, n) => "d5 read probe line " + n + " ".padEnd(20, "x")).join("\n");
|
|
49612
|
-
const filePath =
|
|
49708
|
+
const filePath = path7.join(cwd, "d5-read-probe.txt");
|
|
49613
49709
|
return {
|
|
49614
49710
|
session_id: "d5-read-probe",
|
|
49615
49711
|
transcript_path: "",
|
|
@@ -49617,7 +49713,7 @@ function readProbePayload(cwd) {
|
|
|
49617
49713
|
hook_event_name: "PostToolUse",
|
|
49618
49714
|
tool_name: "Read",
|
|
49619
49715
|
tool_use_id: "toolu_d5_read_probe",
|
|
49620
|
-
tool_input: { file_path: filePath },
|
|
49716
|
+
tool_input: ranged ? { file_path: filePath, offset: 1, limit: READ_PROBE_LINES } : { file_path: filePath },
|
|
49621
49717
|
tool_response: { type: "text", file: { filePath, content, numLines: READ_PROBE_LINES, startLine: 1, totalLines: READ_PROBE_LINES } }
|
|
49622
49718
|
};
|
|
49623
49719
|
}
|
|
@@ -49635,28 +49731,43 @@ function isReadShape(stdout) {
|
|
|
49635
49731
|
const f = r.file;
|
|
49636
49732
|
return typeof f.filePath === "string" && typeof f.content === "string" && ["numLines", "startLine", "totalLines"].every((k) => typeof f[k] === "number");
|
|
49637
49733
|
}
|
|
49638
|
-
async function
|
|
49639
|
-
const home = mkdtempSync(
|
|
49734
|
+
async function readProbe(i, timeoutMs, ranged) {
|
|
49735
|
+
const home = mkdtempSync(path7.join(tmpdir2(), "cm-d5-read-"));
|
|
49640
49736
|
try {
|
|
49641
|
-
const r = await runProcess([process.execPath,
|
|
49737
|
+
const r = await runProcess([process.execPath, path7.join(i.bundleDir, HOOK_ENTRY_FILE), AGENT_ARG, i.agent], {
|
|
49642
49738
|
cwd: i.bundleDir,
|
|
49643
49739
|
env: { ...i.env, HOME: home, USERPROFILE: home },
|
|
49644
49740
|
signal: i.signal,
|
|
49645
49741
|
timeoutMs,
|
|
49646
|
-
stdin: JSON.stringify(readProbePayload(i.worktree ?? home))
|
|
49742
|
+
stdin: JSON.stringify(readProbePayload(i.worktree ?? home, ranged))
|
|
49647
49743
|
});
|
|
49648
|
-
return
|
|
49744
|
+
return r.stdout.toString("utf8");
|
|
49649
49745
|
} finally {
|
|
49650
49746
|
rmSync4(home, { recursive: true, force: true });
|
|
49651
49747
|
}
|
|
49652
49748
|
}
|
|
49749
|
+
function isPassThrough(stdout) {
|
|
49750
|
+
if (stdout.trim() === "") return true;
|
|
49751
|
+
let out;
|
|
49752
|
+
try {
|
|
49753
|
+
out = JSON.parse(stdout);
|
|
49754
|
+
} catch {
|
|
49755
|
+
return false;
|
|
49756
|
+
}
|
|
49757
|
+
return !isObject5(out) || !isObject5(out.hookSpecificOutput) || !Object.hasOwn(out.hookSpecificOutput, "updatedToolOutput");
|
|
49758
|
+
}
|
|
49759
|
+
async function readProbeDetail(i, timeoutMs) {
|
|
49760
|
+
if (!isReadShape(await readProbe(i, timeoutMs, false))) return D5_READ_SHAPE_DETAIL;
|
|
49761
|
+
if (!isPassThrough(await readProbe(i, timeoutMs, true))) return D5_READ_RANGE_DETAIL;
|
|
49762
|
+
return null;
|
|
49763
|
+
}
|
|
49653
49764
|
function codexHookJournaled(db) {
|
|
49654
49765
|
if (db === null) return false;
|
|
49655
49766
|
return db.raw.prepare("SELECT 1 FROM events WHERE agent = ? LIMIT 1").get("codex") !== void 0;
|
|
49656
49767
|
}
|
|
49657
49768
|
function realDir(p) {
|
|
49658
49769
|
try {
|
|
49659
|
-
return
|
|
49770
|
+
return realpathSync8(p);
|
|
49660
49771
|
} catch {
|
|
49661
49772
|
return p;
|
|
49662
49773
|
}
|
|
@@ -49683,7 +49794,7 @@ async function checkHookRoundTrip(i) {
|
|
|
49683
49794
|
const trust = await codexPluginTrust(i);
|
|
49684
49795
|
if (trust !== null) return trust;
|
|
49685
49796
|
}
|
|
49686
|
-
if (i.agent === "codex" &&
|
|
49797
|
+
if (i.agent === "codex" && existsSync13(path7.join(i.codexConfigDir, HOOKS_JSON_FILE)) && !codexHookJournaled(i.db)) {
|
|
49687
49798
|
return row("UNKNOWN", D5_CODEX_UNTRUSTED_DETAIL);
|
|
49688
49799
|
}
|
|
49689
49800
|
const fixture = loadFixture(i.bundleDir, i.agent);
|
|
@@ -49703,7 +49814,7 @@ async function checkHookRoundTrip(i) {
|
|
|
49703
49814
|
let ms = 0;
|
|
49704
49815
|
for (let n = 1; n <= maxPairs; n++) {
|
|
49705
49816
|
const start = now();
|
|
49706
|
-
const r = await runProcess([process.execPath,
|
|
49817
|
+
const r = await runProcess([process.execPath, path7.join(i.bundleDir, HOOK_ENTRY_FILE), AGENT_ARG, i.agent], {
|
|
49707
49818
|
cwd: i.bundleDir,
|
|
49708
49819
|
env: i.env,
|
|
49709
49820
|
signal: i.signal,
|
|
@@ -49717,7 +49828,8 @@ async function checkHookRoundTrip(i) {
|
|
|
49717
49828
|
if (n >= minPairs && ms <= HOOK_P95_MS) break;
|
|
49718
49829
|
}
|
|
49719
49830
|
if (ms > HOOK_P95_MS) return row("FAIL", D5_SLOW_DETAIL(ms), D5_FIX);
|
|
49720
|
-
|
|
49831
|
+
const readDetail = i.agent === "claude-code" ? await readProbeDetail(i, timeoutMs) : null;
|
|
49832
|
+
if (readDetail !== null) return row("FAIL", readDetail, D5_FIX);
|
|
49721
49833
|
return row("PASS", DOCTOR_PASS_DETAIL);
|
|
49722
49834
|
}
|
|
49723
49835
|
|
|
@@ -49759,7 +49871,7 @@ function lastHookError(env) {
|
|
|
49759
49871
|
}
|
|
49760
49872
|
|
|
49761
49873
|
// src/core/ops/db-heal.ts
|
|
49762
|
-
import { existsSync as
|
|
49874
|
+
import { existsSync as existsSync14, mkdirSync as mkdirSync5, rmSync as rmSync5 } from "node:fs";
|
|
49763
49875
|
import { basename as basename4, dirname as dirname7, join as join13 } from "node:path";
|
|
49764
49876
|
function integrityOk2(rows) {
|
|
49765
49877
|
return rows.length === 1 && rows[0].integrity_check === INTEGRITY_OK;
|
|
@@ -49794,7 +49906,7 @@ function renameAside(dbPath) {
|
|
|
49794
49906
|
const ts = String(Date.now());
|
|
49795
49907
|
for (const suffix of DB_SIBLING_SUFFIXES) {
|
|
49796
49908
|
const file2 = dbPath + suffix;
|
|
49797
|
-
if (
|
|
49909
|
+
if (existsSync14(file2)) renameWithRetry(file2, file2 + HEAL_TS_SEP + ts + HEAL_BACKUP_SUFFIX);
|
|
49798
49910
|
}
|
|
49799
49911
|
return ts;
|
|
49800
49912
|
}
|
|
@@ -49901,7 +50013,7 @@ function buildReportHead(input) {
|
|
|
49901
50013
|
|
|
49902
50014
|
// src/core/ops/doctor-issue.ts
|
|
49903
50015
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
49904
|
-
import { closeSync, existsSync as
|
|
50016
|
+
import { closeSync, existsSync as existsSync15, fstatSync, mkdirSync as mkdirSync6, openSync, readFileSync as readFileSync10, readSync, realpathSync as realpathSync9, writeFileSync as writeFileSync3 } from "node:fs";
|
|
49905
50017
|
import { delimiter, join as join14 } from "node:path";
|
|
49906
50018
|
var TOKEN_PREFIXES = ["ghp_", "gho_", "github_pat_", "sk-", "xoxb-", "AKIA"];
|
|
49907
50019
|
function tildeOf(env) {
|
|
@@ -49909,8 +50021,8 @@ function tildeOf(env) {
|
|
|
49909
50021
|
if (home === null || home === "") return (t) => t;
|
|
49910
50022
|
const homes = [home];
|
|
49911
50023
|
try {
|
|
49912
|
-
const
|
|
49913
|
-
if (
|
|
50024
|
+
const real3 = realpathSync9.native(home);
|
|
50025
|
+
if (real3 !== home) homes.push(real3);
|
|
49914
50026
|
} catch {
|
|
49915
50027
|
}
|
|
49916
50028
|
homes.sort((a, b) => b.length - a.length);
|
|
@@ -49943,7 +50055,7 @@ function onPath(env, tool) {
|
|
|
49943
50055
|
const out = [];
|
|
49944
50056
|
for (const dir of (env.PATH ?? env.Path ?? "").split(delimiter)) {
|
|
49945
50057
|
if (dir === "") continue;
|
|
49946
|
-
for (const n of names) if (
|
|
50058
|
+
for (const n of names) if (existsSync15(join14(dir, n))) {
|
|
49947
50059
|
out.push(join14(dir, n));
|
|
49948
50060
|
break;
|
|
49949
50061
|
}
|
|
@@ -49952,7 +50064,7 @@ function onPath(env, tool) {
|
|
|
49952
50064
|
}
|
|
49953
50065
|
function hookLogTail(env) {
|
|
49954
50066
|
const file2 = hookLogPath(env);
|
|
49955
|
-
if (file2 === "" || !
|
|
50067
|
+
if (file2 === "" || !existsSync15(file2)) return [`(${file2 || "hook-errors.log"} holds zero lines)`];
|
|
49956
50068
|
try {
|
|
49957
50069
|
const fd = openSync(file2, "r");
|
|
49958
50070
|
try {
|
|
@@ -49972,7 +50084,7 @@ function hookLogTail(env) {
|
|
|
49972
50084
|
}
|
|
49973
50085
|
async function journalRows(ctx) {
|
|
49974
50086
|
const head = ["| kind | tool | bytes | ok | exit_code | created_at |", "|---|---|---|---|---|---|"];
|
|
49975
|
-
if (!
|
|
50087
|
+
if (!existsSync15(ctx.project.dbPath)) return [`(context.db is absent at ${ctx.project.dbPath})`];
|
|
49976
50088
|
try {
|
|
49977
50089
|
const db = await openDb(ctx.project, { readOnly: true });
|
|
49978
50090
|
try {
|
|
@@ -49998,13 +50110,13 @@ function agentConfig(adapter, env, worktree) {
|
|
|
49998
50110
|
for (const f of files) {
|
|
49999
50111
|
if (seen.has(f.path)) continue;
|
|
50000
50112
|
seen.add(f.path);
|
|
50001
|
-
if (!
|
|
50113
|
+
if (!existsSync15(f.path)) {
|
|
50002
50114
|
out.push(`${f.label}: ${f.path} (absent)`);
|
|
50003
50115
|
continue;
|
|
50004
50116
|
}
|
|
50005
50117
|
let text = "";
|
|
50006
50118
|
try {
|
|
50007
|
-
text =
|
|
50119
|
+
text = readFileSync10(f.path, "utf8");
|
|
50008
50120
|
} catch (err) {
|
|
50009
50121
|
out.push(`${f.label}: ${f.path} (read: ${err instanceof Error ? err.message : String(err)})`);
|
|
50010
50122
|
continue;
|
|
@@ -50122,7 +50234,7 @@ async function guard(id, run) {
|
|
|
50122
50234
|
}
|
|
50123
50235
|
}
|
|
50124
50236
|
async function codexDb(ctx, adapter) {
|
|
50125
|
-
if (adapter.id !== "codex" || !
|
|
50237
|
+
if (adapter.id !== "codex" || !existsSync16(ctx.project.dbPath)) return null;
|
|
50126
50238
|
try {
|
|
50127
50239
|
return await openDb(ctx.project, { readOnly: true });
|
|
50128
50240
|
} catch {
|
|
@@ -50153,10 +50265,10 @@ async function hookRow(ctx, adapter, host) {
|
|
|
50153
50265
|
}
|
|
50154
50266
|
function ownServerId(configDir, projectKey) {
|
|
50155
50267
|
const dir = join15(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
|
|
50156
|
-
if (!
|
|
50268
|
+
if (!existsSync16(dir)) return "";
|
|
50157
50269
|
for (const name of readdirSync7(dir)) {
|
|
50158
50270
|
if (!name.endsWith(OWNER_PID_EXT)) continue;
|
|
50159
|
-
if (
|
|
50271
|
+
if (readFileSync11(join15(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
|
|
50160
50272
|
}
|
|
50161
50273
|
return "";
|
|
50162
50274
|
}
|
|
@@ -50212,7 +50324,7 @@ async function doctorReply(ctx, host) {
|
|
|
50212
50324
|
const adapter = getAdapter(ctx.project.agent);
|
|
50213
50325
|
const rows = await runDoctorChecks(ctx, adapter, host);
|
|
50214
50326
|
const failed2 = rows.some((r) => r.status === "FAIL");
|
|
50215
|
-
const command = `context-mode ${failed2 ? "setup" : "doctor"} --agents ${adapter.id}`;
|
|
50327
|
+
const command = adapter.id === "pi" ? failed2 ? NATIVE_INSTALL.pi[0] : PI_LIST_COMMAND : `context-mode ${failed2 ? "setup" : "doctor"} --agents ${adapter.id}`;
|
|
50216
50328
|
const input = { agent: adapter.id, rows, env: reportEnv(host.env), command };
|
|
50217
50329
|
const envLine2 = environmentLine(ctx, adapter, host.env, bundleVersion(host.bundleDir));
|
|
50218
50330
|
const table3 = buildReport(input);
|
|
@@ -50239,7 +50351,7 @@ async function doctorReply(ctx, host) {
|
|
|
50239
50351
|
return { text, isError: false, sandboxBytes: bytes5 };
|
|
50240
50352
|
}
|
|
50241
50353
|
async function handler2(_input, ctx) {
|
|
50242
|
-
return doctorReply(ctx, { env: process.env, bundleDir: ownBundleDir(), piCwd:
|
|
50354
|
+
return doctorReply(ctx, { env: process.env, bundleDir: ownBundleDir(), piCwd: ctx.piCwd });
|
|
50243
50355
|
}
|
|
50244
50356
|
var ctxDoctor = Object.freeze({
|
|
50245
50357
|
name: "ctx_doctor",
|
|
@@ -50251,7 +50363,7 @@ var ctxDoctor = Object.freeze({
|
|
|
50251
50363
|
});
|
|
50252
50364
|
|
|
50253
50365
|
// src/core/tools/execute.ts
|
|
50254
|
-
import { existsSync as
|
|
50366
|
+
import { existsSync as existsSync17, mkdtempSync as mkdtempSync2, rmSync as rmSync6, writeFileSync as writeFileSync4 } from "node:fs";
|
|
50255
50367
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
50256
50368
|
import { dirname as dirname9, join as join16, parse as parse5, resolve as resolve4 } from "node:path";
|
|
50257
50369
|
|
|
@@ -50376,7 +50488,7 @@ function schemaLine(issue4) {
|
|
|
50376
50488
|
}
|
|
50377
50489
|
function fileError(given, abs, root) {
|
|
50378
50490
|
let dir = abs;
|
|
50379
|
-
while (!
|
|
50491
|
+
while (!existsSync17(dir) && dirname9(dir) !== dir) dir = dirname9(dir);
|
|
50380
50492
|
if (isInside(root, dir)) return null;
|
|
50381
50493
|
return new CtxError("OUTSIDE_ROOT", { p: given, root }).toLine();
|
|
50382
50494
|
}
|
|
@@ -50493,19 +50605,19 @@ var ctxExecute = {
|
|
|
50493
50605
|
};
|
|
50494
50606
|
|
|
50495
50607
|
// src/core/tools/index.ts
|
|
50496
|
-
import { existsSync as
|
|
50608
|
+
import { existsSync as existsSync18, readFileSync as readFileSync13, statSync as statSync7 } from "node:fs";
|
|
50497
50609
|
import { dirname as dirname10, extname, join as join18, relative as relative2, resolve as resolve5 } from "node:path";
|
|
50498
50610
|
|
|
50499
50611
|
// src/core/index/walk.ts
|
|
50500
|
-
import { readdirSync as readdirSync8, readFileSync as
|
|
50612
|
+
import { readdirSync as readdirSync8, readFileSync as readFileSync12, realpathSync as realpathSync10, statSync as statSync6 } from "node:fs";
|
|
50501
50613
|
import { join as join17 } from "node:path";
|
|
50502
50614
|
var GITIGNORE = ".gitignore";
|
|
50503
50615
|
var GIT_DIR = ".git";
|
|
50504
50616
|
function walkDir(root, containmentRoot) {
|
|
50505
|
-
const
|
|
50506
|
-
if (!isInside(containmentRoot,
|
|
50617
|
+
const real3 = realpathSync10(root);
|
|
50618
|
+
if (!isInside(containmentRoot, real3)) throw new CtxError("OUTSIDE_ROOT", { p: root, root: containmentRoot });
|
|
50507
50619
|
const found = [];
|
|
50508
|
-
visit(
|
|
50620
|
+
visit(real3, [], [], containmentRoot, /* @__PURE__ */ new Set([real3]), found);
|
|
50509
50621
|
found.sort(compareFound);
|
|
50510
50622
|
return found.map((f) => ({ absPath: f.absPath, relPath: join17(...f.dir, f.name) }));
|
|
50511
50623
|
}
|
|
@@ -50519,14 +50631,14 @@ function visit(abs, rel, parent, contain, seen, found) {
|
|
|
50519
50631
|
const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(join17(abs, GITIGNORE), rel)) : parent;
|
|
50520
50632
|
for (const e of entries) {
|
|
50521
50633
|
if (e.name === GIT_DIR) continue;
|
|
50522
|
-
const
|
|
50634
|
+
const path8 = join17(abs, e.name);
|
|
50523
50635
|
let isDir = e.isDirectory();
|
|
50524
50636
|
let isFile = e.isFile();
|
|
50525
|
-
let target =
|
|
50637
|
+
let target = path8;
|
|
50526
50638
|
if (e.isSymbolicLink()) {
|
|
50527
50639
|
let resolved;
|
|
50528
50640
|
try {
|
|
50529
|
-
resolved =
|
|
50641
|
+
resolved = realpathSync10(path8);
|
|
50530
50642
|
} catch {
|
|
50531
50643
|
continue;
|
|
50532
50644
|
}
|
|
@@ -50539,12 +50651,12 @@ function visit(abs, rel, parent, contain, seen, found) {
|
|
|
50539
50651
|
const segs = rel.concat(e.name);
|
|
50540
50652
|
if (ignored(rules, segs, isDir)) continue;
|
|
50541
50653
|
if (isFile) {
|
|
50542
|
-
found.push({ dir: rel, name: e.name, absPath:
|
|
50654
|
+
found.push({ dir: rel, name: e.name, absPath: path8 });
|
|
50543
50655
|
} else if (isDir) {
|
|
50544
|
-
const key = e.isSymbolicLink() ? target :
|
|
50656
|
+
const key = e.isSymbolicLink() ? target : realpathSync10(path8);
|
|
50545
50657
|
if (seen.has(key)) continue;
|
|
50546
50658
|
seen.add(key);
|
|
50547
|
-
visit(
|
|
50659
|
+
visit(path8, segs, rules, contain, seen, found);
|
|
50548
50660
|
}
|
|
50549
50661
|
}
|
|
50550
50662
|
}
|
|
@@ -50559,7 +50671,7 @@ function compareFound(a, b) {
|
|
|
50559
50671
|
function readRules(file2, base) {
|
|
50560
50672
|
let body;
|
|
50561
50673
|
try {
|
|
50562
|
-
body =
|
|
50674
|
+
body = readFileSync12(file2, "utf8");
|
|
50563
50675
|
} catch {
|
|
50564
50676
|
return [];
|
|
50565
50677
|
}
|
|
@@ -50735,12 +50847,12 @@ function tlsName(host) {
|
|
|
50735
50847
|
function request(u, conn, proxy, signal) {
|
|
50736
50848
|
const host = bare(u.hostname);
|
|
50737
50849
|
const port = u.port === "" ? defaultPort(u.protocol) : Number(u.port);
|
|
50738
|
-
const
|
|
50850
|
+
const path8 = u.pathname + u.search;
|
|
50739
50851
|
return new Promise((resolve6, reject) => {
|
|
50740
50852
|
const onErr = (err) => reject(fail5(causeCode(err)));
|
|
50741
50853
|
if (proxy === void 0) {
|
|
50742
50854
|
const mod = u.protocol === "https:" ? https : http;
|
|
50743
|
-
const req = mod.request({ host: conn.address, port, path:
|
|
50855
|
+
const req = mod.request({ host: conn.address, port, path: path8, signal, servername: tlsName(host), headers: { host: u.host } });
|
|
50744
50856
|
req.on("response", resolve6).on("error", onErr).end();
|
|
50745
50857
|
return;
|
|
50746
50858
|
}
|
|
@@ -50762,7 +50874,7 @@ function request(u, conn, proxy, signal) {
|
|
|
50762
50874
|
const req = https.request({
|
|
50763
50875
|
host,
|
|
50764
50876
|
port,
|
|
50765
|
-
path:
|
|
50877
|
+
path: path8,
|
|
50766
50878
|
signal,
|
|
50767
50879
|
headers: { host: u.host },
|
|
50768
50880
|
createConnection: () => tlsConnect({ socket, host, servername: tlsName(host) })
|
|
@@ -54642,14 +54754,14 @@ function kindOfType(contentType) {
|
|
|
54642
54754
|
}
|
|
54643
54755
|
function readUtf8(absPath) {
|
|
54644
54756
|
try {
|
|
54645
|
-
return utf8.decode(
|
|
54757
|
+
return utf8.decode(readFileSync13(absPath));
|
|
54646
54758
|
} catch {
|
|
54647
54759
|
return void 0;
|
|
54648
54760
|
}
|
|
54649
54761
|
}
|
|
54650
54762
|
function missingOrOutside(given, abs, root) {
|
|
54651
54763
|
let dir = abs;
|
|
54652
|
-
while (!
|
|
54764
|
+
while (!existsSync18(dir) && dirname10(dir) !== dir) dir = dirname10(dir);
|
|
54653
54765
|
if (dir !== abs && isInside(root, dir)) return new CtxError("INVALID_ARGS", { field: "path", action: "pass an existing file or folder" });
|
|
54654
54766
|
return new CtxError("OUTSIDE_ROOT", { p: given, root });
|
|
54655
54767
|
}
|
|
@@ -54860,8 +54972,8 @@ function buildCandidates(rows, sessionId) {
|
|
|
54860
54972
|
edits.set(r.path, { row: r, count: (edits.get(r.path)?.count ?? 0) + 1 });
|
|
54861
54973
|
}
|
|
54862
54974
|
const changedFiles = [];
|
|
54863
|
-
for (const [
|
|
54864
|
-
const c = make("changed_files", e.row, "edited " +
|
|
54975
|
+
for (const [path8, e] of edits) {
|
|
54976
|
+
const c = make("changed_files", e.row, "edited " + path8 + " x" + e.count, e.count, path8);
|
|
54865
54977
|
changedFiles.push({ ...c, editCount: e.count });
|
|
54866
54978
|
}
|
|
54867
54979
|
changedFiles.sort((a, b) => a.seq - b.seq);
|
|
@@ -55465,11 +55577,11 @@ var ctxStats = Object.freeze({
|
|
|
55465
55577
|
});
|
|
55466
55578
|
|
|
55467
55579
|
// src/core/tools/upgrade.ts
|
|
55468
|
-
import { existsSync as
|
|
55580
|
+
import { existsSync as existsSync24, realpathSync as realpathSync11, rmSync as rmSync11 } from "node:fs";
|
|
55469
55581
|
import { basename as basename7, dirname as dirname12, join as join24 } from "node:path";
|
|
55470
55582
|
|
|
55471
55583
|
// src/core/ops/host-write.ts
|
|
55472
|
-
import { copyFileSync, existsSync as
|
|
55584
|
+
import { copyFileSync, existsSync as existsSync19, mkdirSync as mkdirSync7, writeFileSync as writeFileSync5 } from "node:fs";
|
|
55473
55585
|
import { dirname as dirname11, join as join19 } from "node:path";
|
|
55474
55586
|
function defaultWrite(file2, text) {
|
|
55475
55587
|
writeFileSync5(file2, text, "utf8");
|
|
@@ -55498,7 +55610,7 @@ function toRow(file2, edit) {
|
|
|
55498
55610
|
function writeWithRollback(file2, text, write, atomic) {
|
|
55499
55611
|
const trash = file2 + UPGRADE_TRASH_SUFFIX;
|
|
55500
55612
|
const tmp = `${file2}${HOST_CONFIG_TMP_SUFFIX}.${process.pid}`;
|
|
55501
|
-
const had =
|
|
55613
|
+
const had = existsSync19(file2);
|
|
55502
55614
|
mkdirSync7(dirname11(file2), { recursive: true });
|
|
55503
55615
|
if (had) copyFileSync(file2, trash);
|
|
55504
55616
|
try {
|
|
@@ -55528,7 +55640,7 @@ function regenerateHostConfig(row5, home, opts = {}) {
|
|
|
55528
55640
|
if (requested === null) return [];
|
|
55529
55641
|
const current = readHostConfig(row5.id, requested);
|
|
55530
55642
|
const result = mergeOwnEntries(row5.id, current.text, current.format, row5);
|
|
55531
|
-
const exists =
|
|
55643
|
+
const exists = existsSync19(current.path);
|
|
55532
55644
|
if (exists && result.text === current.text) return [];
|
|
55533
55645
|
const text = result.text === "" && current.format !== "toml" ? JSON.stringify({}) : result.text;
|
|
55534
55646
|
writeWithRollback(current.path, current.layout === void 0 ? text : withLayout(text, current.layout), opts.write ?? defaultWrite, opts.atomic ?? {});
|
|
@@ -55536,15 +55648,15 @@ function regenerateHostConfig(row5, home, opts = {}) {
|
|
|
55536
55648
|
}
|
|
55537
55649
|
|
|
55538
55650
|
// src/core/ops/plugin-swap.ts
|
|
55539
|
-
import { existsSync as
|
|
55651
|
+
import { existsSync as existsSync20, lstatSync, readdirSync as readdirSync9, readlinkSync, rmSync as rmSync7, symlinkSync, unlinkSync as unlinkSync2 } from "node:fs";
|
|
55540
55652
|
import { basename as basename6, join as join20, win32 as win322 } from "node:path";
|
|
55541
|
-
function linkTarget(
|
|
55542
|
-
if (!isLink(
|
|
55543
|
-
const target = readlinkSync(
|
|
55653
|
+
function linkTarget(path8, win) {
|
|
55654
|
+
if (!isLink(path8)) return null;
|
|
55655
|
+
const target = readlinkSync(path8);
|
|
55544
55656
|
return win ? win322.basename(target) : target;
|
|
55545
55657
|
}
|
|
55546
|
-
function isLink(
|
|
55547
|
-
return lstatSync(
|
|
55658
|
+
function isLink(path8) {
|
|
55659
|
+
return lstatSync(path8, { throwIfNoEntry: false })?.isSymbolicLink() === true;
|
|
55548
55660
|
}
|
|
55549
55661
|
function generations(agentDir) {
|
|
55550
55662
|
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();
|
|
@@ -55557,7 +55669,7 @@ function settleLinks(link, tmp, old, opts) {
|
|
|
55557
55669
|
}
|
|
55558
55670
|
function swapPluginCurrent(agentDir, sha, opts = {}) {
|
|
55559
55671
|
const next = join20(agentDir, sha);
|
|
55560
|
-
if (!
|
|
55672
|
+
if (!existsSync20(next) || !lstatSync(next).isDirectory()) {
|
|
55561
55673
|
throw new CtxError("PLUGIN_ROOT_MISSING", { agent: basename6(agentDir), path: next });
|
|
55562
55674
|
}
|
|
55563
55675
|
const link = join20(agentDir, PLUGIN_CURRENT_LINK);
|
|
@@ -55577,12 +55689,12 @@ function swapPluginCurrent(agentDir, sha, opts = {}) {
|
|
|
55577
55689
|
if (before !== null) keep.add(before);
|
|
55578
55690
|
const removed = generations(agentDir).filter((name) => !keep.has(name)).map((name) => join20(agentDir, name));
|
|
55579
55691
|
for (const dir of removed) rmSync7(dir, { recursive: true, force: true });
|
|
55580
|
-
const previous = before !== null &&
|
|
55692
|
+
const previous = before !== null && existsSync20(join20(agentDir, before)) ? join20(agentDir, before) : null;
|
|
55581
55693
|
return { current: next, previous, removed };
|
|
55582
55694
|
}
|
|
55583
55695
|
|
|
55584
55696
|
// src/core/ops/release-fetch.ts
|
|
55585
|
-
import { existsSync as
|
|
55697
|
+
import { existsSync as existsSync21, mkdirSync as mkdirSync8, rmSync as rmSync8 } from "node:fs";
|
|
55586
55698
|
import { join as join21 } from "node:path";
|
|
55587
55699
|
function failed(r) {
|
|
55588
55700
|
if (r.exitCode === null && r.killed === null) return new CtxError("FETCH_FAILED", { code: GIT_NOT_STARTED });
|
|
@@ -55606,7 +55718,7 @@ async function fetchRelease(agent, url4, env, signal, opts = {}) {
|
|
|
55606
55718
|
await git2(gitBin, [...GIT_CLONE_ARGS, RELEASE_BRANCH, url4, fetchDir], agentDir, childEnv, signal);
|
|
55607
55719
|
const sha = await git2(gitBin, GIT_HEAD_SHA_ARGS, fetchDir, childEnv, signal);
|
|
55608
55720
|
const dir = join21(agentDir, sha);
|
|
55609
|
-
if (
|
|
55721
|
+
if (existsSync21(dir)) rmSync8(fetchDir, { recursive: true, force: true });
|
|
55610
55722
|
else renameWithRetry(fetchDir, dir, opts);
|
|
55611
55723
|
return { sha, dir };
|
|
55612
55724
|
} catch (e) {
|
|
@@ -55616,7 +55728,7 @@ async function fetchRelease(agent, url4, env, signal, opts = {}) {
|
|
|
55616
55728
|
}
|
|
55617
55729
|
|
|
55618
55730
|
// src/core/ops/uninstall.ts
|
|
55619
|
-
import { existsSync as
|
|
55731
|
+
import { existsSync as existsSync22, readdirSync as readdirSync10, rmSync as rmSync9, writeFileSync as writeFileSync6 } from "node:fs";
|
|
55620
55732
|
import { join as join22 } from "node:path";
|
|
55621
55733
|
function row2(area, before, after) {
|
|
55622
55734
|
return { area, before, after };
|
|
@@ -55650,7 +55762,7 @@ function removeCache(adapter, env, configDir) {
|
|
|
55650
55762
|
}
|
|
55651
55763
|
case "plugin": {
|
|
55652
55764
|
const agentDir = join22(configDir, DATA_PLUGINS_DIR_NAME, adapter.id);
|
|
55653
|
-
if (!
|
|
55765
|
+
if (!existsSync22(agentDir)) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
|
|
55654
55766
|
rmSync9(agentDir, { recursive: true, force: true });
|
|
55655
55767
|
return row2(UPGRADE_CACHE_AREA, agentDir, UPGRADE_REMOVED);
|
|
55656
55768
|
}
|
|
@@ -55669,7 +55781,7 @@ function isObj3(v) {
|
|
|
55669
55781
|
function piSource(entry) {
|
|
55670
55782
|
return isObj3(entry) ? entry[PI_PACKAGE_SOURCE_KEY] : entry;
|
|
55671
55783
|
}
|
|
55672
|
-
function
|
|
55784
|
+
function ownEntries2(agent, env) {
|
|
55673
55785
|
const home = requireHomeDir(env);
|
|
55674
55786
|
const mcp = OWN_MCP_ENTRY[agent];
|
|
55675
55787
|
if (mcp !== void 0) {
|
|
@@ -55677,10 +55789,10 @@ function ownEntries(agent, env) {
|
|
|
55677
55789
|
const inner = mcp.key.slice(1, -1);
|
|
55678
55790
|
const own4 = mcp.key[mcp.key.length - 1];
|
|
55679
55791
|
const holder = (v) => inner.reduce((cur, k) => isObj3(cur) ? cur[k] : void 0, v);
|
|
55680
|
-
const without = (v,
|
|
55792
|
+
const without = (v, path8) => {
|
|
55681
55793
|
const o = v;
|
|
55682
|
-
if (
|
|
55683
|
-
return { ...o, [
|
|
55794
|
+
if (path8.length === 0) return Object.fromEntries(Object.entries(o).filter(([k]) => k !== own4));
|
|
55795
|
+
return { ...o, [path8[0]]: without(o[path8[0]], path8.slice(1)) };
|
|
55684
55796
|
};
|
|
55685
55797
|
return [{
|
|
55686
55798
|
file: ownMcpFileOf(agent, mcp.file, env, home),
|
|
@@ -55717,7 +55829,7 @@ function ownEntries(agent, env) {
|
|
|
55717
55829
|
}
|
|
55718
55830
|
function removeOwnEntries(agent, env) {
|
|
55719
55831
|
const rows = [];
|
|
55720
|
-
for (const entry of
|
|
55832
|
+
for (const entry of ownEntries2(agent, env)) {
|
|
55721
55833
|
const current = readHostConfig(agent, entry.file);
|
|
55722
55834
|
if (current.text === "") continue;
|
|
55723
55835
|
const value = hostConfigValueAt(parseHostConfig(agent, current.path, current.text, current.format), [entry.key]);
|
|
@@ -55730,7 +55842,7 @@ function removeOwnEntries(agent, env) {
|
|
|
55730
55842
|
function removeProjectData(configDir, projectKey) {
|
|
55731
55843
|
const projects = join22(configDir, PROJECTS_DIR_NAME);
|
|
55732
55844
|
const dir = join22(projects, projectKey);
|
|
55733
|
-
if (!
|
|
55845
|
+
if (!existsSync22(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
|
|
55734
55846
|
if (dir === projects || !isInside(projects, dir)) throw new CtxError("OUTSIDE_ROOT", { p: dir, root: projects });
|
|
55735
55847
|
for (const name of readdirSync10(dir)) {
|
|
55736
55848
|
if (name !== OWNERS_DIR_NAME) rmSync9(join22(dir, name), { recursive: true, force: true });
|
|
@@ -55746,7 +55858,7 @@ function runUninstall(input) {
|
|
|
55746
55858
|
}
|
|
55747
55859
|
|
|
55748
55860
|
// src/core/ops/v1-remove.ts
|
|
55749
|
-
import { copyFileSync as copyFileSync2, existsSync as
|
|
55861
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync23, readFileSync as readFileSync14, rmSync as rmSync10 } from "node:fs";
|
|
55750
55862
|
var isObj4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
55751
55863
|
var areaOf = (f) => f.path === "" ? f.file : f.file + UPGRADE_AREA_KEY_SEP + f.path;
|
|
55752
55864
|
var row3 = (f, after) => ({ area: areaOf(f), before: f.reason, after });
|
|
@@ -55776,8 +55888,8 @@ function cutTomlTable(text, header) {
|
|
|
55776
55888
|
function writeAtomic(file2, text) {
|
|
55777
55889
|
atomicWriteFile(file2, text);
|
|
55778
55890
|
}
|
|
55779
|
-
function locate(doc,
|
|
55780
|
-
const segs =
|
|
55891
|
+
function locate(doc, path8) {
|
|
55892
|
+
const segs = path8.split(V1_KEY_PATH_SEP);
|
|
55781
55893
|
let cur = doc;
|
|
55782
55894
|
for (const seg of segs.slice(0, -1)) {
|
|
55783
55895
|
if (Array.isArray(cur)) cur = cur[Number(seg)];
|
|
@@ -55790,8 +55902,8 @@ function locate(doc, path7) {
|
|
|
55790
55902
|
return null;
|
|
55791
55903
|
}
|
|
55792
55904
|
function stripJsonEntries(agent, file2, findings, kept, undo) {
|
|
55793
|
-
const layout = hostLayout(
|
|
55794
|
-
const text = hostText(
|
|
55905
|
+
const layout = hostLayout(readFileSync14(file2, "utf8"));
|
|
55906
|
+
const text = hostText(readFileSync14(file2, "utf8"));
|
|
55795
55907
|
const doc = parseHostConfig(agent, file2, text, "jsonc");
|
|
55796
55908
|
const hit = /* @__PURE__ */ new Set();
|
|
55797
55909
|
const byContainer = /* @__PURE__ */ new Map();
|
|
@@ -55827,19 +55939,19 @@ function removeV1(agent, findings) {
|
|
|
55827
55939
|
for (const f of findings) {
|
|
55828
55940
|
if (UPGRADE_REPORT_ONLY_REASONS.includes(f.reason)) done.set(f, UPGRADE_REPORT_ONLY);
|
|
55829
55941
|
else if (f.path === "") {
|
|
55830
|
-
if (
|
|
55942
|
+
if (existsSync23(f.file)) {
|
|
55831
55943
|
moveAside(f.file, undo);
|
|
55832
55944
|
done.set(f, UPGRADE_REMOVED);
|
|
55833
55945
|
} else done.set(f, UPGRADE_NOT_FOUND);
|
|
55834
55946
|
} else entries.set(f.file, [...entries.get(f.file) ?? [], f]);
|
|
55835
55947
|
}
|
|
55836
55948
|
for (const [file2, list3] of entries) {
|
|
55837
|
-
if (!
|
|
55949
|
+
if (!existsSync23(file2)) {
|
|
55838
55950
|
for (const f of list3) done.set(f, UPGRADE_NOT_FOUND);
|
|
55839
55951
|
continue;
|
|
55840
55952
|
}
|
|
55841
55953
|
if (file2.endsWith(TOML_EXT)) {
|
|
55842
|
-
const rawToml =
|
|
55954
|
+
const rawToml = readFileSync14(file2, "utf8");
|
|
55843
55955
|
const tomlLayout = hostLayout(rawToml);
|
|
55844
55956
|
let text = hostText(rawToml);
|
|
55845
55957
|
for (const f of list3) {
|
|
@@ -55867,7 +55979,7 @@ function removeV1(agent, findings) {
|
|
|
55867
55979
|
},
|
|
55868
55980
|
rollback() {
|
|
55869
55981
|
for (const u of undo.splice(0).reverse()) {
|
|
55870
|
-
if (!
|
|
55982
|
+
if (!existsSync23(u.trash)) continue;
|
|
55871
55983
|
rmSync10(u.target, { recursive: true, force: true });
|
|
55872
55984
|
renameWithRetry(u.trash, u.target);
|
|
55873
55985
|
}
|
|
@@ -55877,7 +55989,7 @@ function removeV1(agent, findings) {
|
|
|
55877
55989
|
|
|
55878
55990
|
// src/core/ops/verify-sums.ts
|
|
55879
55991
|
import { createHash as createHash2 } from "node:crypto";
|
|
55880
|
-
import { lstatSync as lstatSync2, readdirSync as readdirSync11, readFileSync as
|
|
55992
|
+
import { lstatSync as lstatSync2, readdirSync as readdirSync11, readFileSync as readFileSync15 } from "node:fs";
|
|
55881
55993
|
import { join as join23 } from "node:path";
|
|
55882
55994
|
function mismatch() {
|
|
55883
55995
|
return new CtxError("BUNDLE_HASH_MISMATCH");
|
|
@@ -55909,14 +56021,14 @@ function verifySums(dir) {
|
|
|
55909
56021
|
const sumsPath = join23(dir, RELEASE_SUMS_FILE);
|
|
55910
56022
|
const sumsStat = lstatSync2(sumsPath, { throwIfNoEntry: false });
|
|
55911
56023
|
if (sumsStat === void 0 || !sumsStat.isFile()) throw mismatch();
|
|
55912
|
-
const sums = parseSums(
|
|
56024
|
+
const sums = parseSums(readFileSync15(sumsPath, "utf8"));
|
|
55913
56025
|
const files = /* @__PURE__ */ new Map();
|
|
55914
56026
|
walk2(dir, "", files);
|
|
55915
56027
|
if (files.size !== sums.size) throw mismatch();
|
|
55916
56028
|
for (const [rel, abs] of files) {
|
|
55917
56029
|
const want = sums.get(rel);
|
|
55918
56030
|
if (want === void 0) throw mismatch();
|
|
55919
|
-
const got = createHash2(SUMS_HASH_ALGORITHM).update(
|
|
56031
|
+
const got = createHash2(SUMS_HASH_ALGORITHM).update(readFileSync15(abs)).digest(HASH_ENCODING);
|
|
55920
56032
|
if (got !== want) throw mismatch();
|
|
55921
56033
|
}
|
|
55922
56034
|
}
|
|
@@ -55945,7 +56057,7 @@ function pluginRootRow(adapter, env) {
|
|
|
55945
56057
|
}
|
|
55946
56058
|
function isCurrent(agentDir, dir) {
|
|
55947
56059
|
const link = join24(agentDir, PLUGIN_CURRENT_LINK);
|
|
55948
|
-
return
|
|
56060
|
+
return existsSync24(link) && realpathSync11.native(link) === realpathSync11.native(dir);
|
|
55949
56061
|
}
|
|
55950
56062
|
async function checkout(adapter, deps) {
|
|
55951
56063
|
const fetched = await fetchRelease(adapter.id, deps.releaseUrl, deps.env, deps.signal);
|
|
@@ -56064,12 +56176,12 @@ function checkCall(tool, input) {
|
|
|
56064
56176
|
}
|
|
56065
56177
|
|
|
56066
56178
|
// src/entries/is-entry.ts
|
|
56067
|
-
import { realpathSync as
|
|
56179
|
+
import { realpathSync as realpathSync12 } from "node:fs";
|
|
56068
56180
|
function isEntry(main, argv1, self) {
|
|
56069
56181
|
if (main !== void 0) return main;
|
|
56070
56182
|
if (argv1 === void 0 || argv1 === "") return false;
|
|
56071
56183
|
try {
|
|
56072
|
-
return
|
|
56184
|
+
return realpathSync12(argv1) === realpathSync12(self);
|
|
56073
56185
|
} catch {
|
|
56074
56186
|
return false;
|
|
56075
56187
|
}
|
|
@@ -56145,7 +56257,7 @@ function workspaceFromMeta(meta3) {
|
|
|
56145
56257
|
}
|
|
56146
56258
|
function realOrSame(p) {
|
|
56147
56259
|
try {
|
|
56148
|
-
return
|
|
56260
|
+
return realpathSync13.native(p);
|
|
56149
56261
|
} catch {
|
|
56150
56262
|
return p;
|
|
56151
56263
|
}
|
|
@@ -56193,7 +56305,7 @@ async function startServer(argv, env) {
|
|
|
56193
56305
|
opening.catch(() => pending.delete(project.dbPath));
|
|
56194
56306
|
}
|
|
56195
56307
|
const db = await opening;
|
|
56196
|
-
if (!
|
|
56308
|
+
if (!existsSync25(db.path)) throw new CtxError("DB_GONE");
|
|
56197
56309
|
return db;
|
|
56198
56310
|
}
|
|
56199
56311
|
function stopMarker(configDir, projectKey) {
|
|
@@ -56201,7 +56313,7 @@ async function startServer(argv, env) {
|
|
|
56201
56313
|
}
|
|
56202
56314
|
function stopRequested() {
|
|
56203
56315
|
const configDir = resolveConfigDir(process.env);
|
|
56204
|
-
return held.some((db) =>
|
|
56316
|
+
return held.some((db) => existsSync25(stopMarker(configDir, db.projectKey)));
|
|
56205
56317
|
}
|
|
56206
56318
|
async function journal(project, ctx, name, reply4) {
|
|
56207
56319
|
const db = await ownDb(project);
|