@mrciphersmith/keryx 0.4.40 → 0.4.41
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/dist/cli.js +26506 -13626
- package/dist/core.js +600 -556
- package/dist/keryx-general-worker-entry.js +8494 -7993
- package/package.json +1 -1
- package/src/gdgraph/treesitter/adapter.ts +11 -3
- package/src/gdskills/bundled/skills/review/review-orchestrator/reviewer-input.schema.json +3 -2
package/dist/core.js
CHANGED
|
@@ -7179,25 +7179,25 @@ var init_self_protect = __esm(() => {
|
|
|
7179
7179
|
});
|
|
7180
7180
|
|
|
7181
7181
|
// src/lib/descriptor-read.ts
|
|
7182
|
-
import { constants, fstatSync, lstatSync as lstatSync2,
|
|
7182
|
+
import { closeSync, constants, fstatSync, lstatSync as lstatSync2, readSync } from "fs";
|
|
7183
7183
|
import path19 from "path";
|
|
7184
|
-
import { dlopen, FFIType
|
|
7185
|
-
function
|
|
7184
|
+
import { dlopen, FFIType } from "bun:ffi";
|
|
7185
|
+
function openDescriptorChain(workspaceRoot, absolutePath, options = {}) {
|
|
7186
7186
|
const relativePath = path19.relative(workspaceRoot, absolutePath);
|
|
7187
7187
|
const components = relativePath.split(path19.sep);
|
|
7188
|
-
if (!relativePath || path19.isAbsolute(relativePath) || components.some((component) => !component || component === "." || component === "..")) {
|
|
7188
|
+
if (!relativePath || path19.isAbsolute(relativePath) || components.some((component) => !component || component.includes("\x00") || component === "." || component === "..")) {
|
|
7189
7189
|
throw new DescriptorReadError("invalid-path", "safe source path is not workspace-relative");
|
|
7190
7190
|
}
|
|
7191
7191
|
if (options.maxBytes !== undefined && (!Number.isSafeInteger(options.maxBytes) || options.maxBytes < 0)) {
|
|
7192
7192
|
throw new DescriptorReadError("too-large", "safe source byte limit is invalid");
|
|
7193
7193
|
}
|
|
7194
7194
|
const libc = loadPosixLibrary();
|
|
7195
|
-
if (!libc || !Number.isInteger(constants.O_DIRECTORY) || !Number.isInteger(constants.O_NOFOLLOW)) {
|
|
7195
|
+
if (!libc || !Number.isInteger(constants.O_DIRECTORY) || !Number.isInteger(constants.O_NOFOLLOW) || options.requireRegularFile && !Number.isInteger(constants.O_NONBLOCK)) {
|
|
7196
7196
|
throw new DescriptorReadError("unavailable", "safe descriptor source reads are unavailable on this platform");
|
|
7197
7197
|
}
|
|
7198
7198
|
const opened = [];
|
|
7199
7199
|
try {
|
|
7200
|
-
const rootStat = lstatSync2(workspaceRoot);
|
|
7200
|
+
const rootStat = lstatSync2(workspaceRoot, { bigint: true });
|
|
7201
7201
|
if (!rootStat.isDirectory() || rootStat.isSymbolicLink()) {
|
|
7202
7202
|
throw new DescriptorReadError("race", "safe source owner root changed");
|
|
7203
7203
|
}
|
|
@@ -7206,7 +7206,7 @@ function readDescriptorChain(workspaceRoot, absolutePath, options = {}) {
|
|
|
7206
7206
|
}
|
|
7207
7207
|
const parent = openAt(libc, atFdcwd, workspaceRoot, constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);
|
|
7208
7208
|
opened.push(parent);
|
|
7209
|
-
if (!sameIdentity(rootStat, fstatSync(parent))) {
|
|
7209
|
+
if (!sameIdentity(rootStat, fstatSync(parent, { bigint: true }))) {
|
|
7210
7210
|
throw new DescriptorReadError("race", "safe source owner root changed");
|
|
7211
7211
|
}
|
|
7212
7212
|
let directoryFd = parent;
|
|
@@ -7217,16 +7217,20 @@ function readDescriptorChain(workspaceRoot, absolutePath, options = {}) {
|
|
|
7217
7217
|
const name = components.at(-1);
|
|
7218
7218
|
if (!name)
|
|
7219
7219
|
throw new DescriptorReadError("invalid-path", "safe source path has no final component");
|
|
7220
|
-
const
|
|
7221
|
-
|
|
7220
|
+
const target = lstatSync2(absolutePath, { bigint: true });
|
|
7221
|
+
if (options.requireRegularFile && !target.isFile())
|
|
7222
|
+
throw new DescriptorReadError("not-regular", "safe source is not a regular file");
|
|
7223
|
+
const expected = options.expectedTargetIdentity ?? target;
|
|
7224
|
+
const finalFlags = constants.O_RDONLY | constants.O_NOFOLLOW | (options.directory ? constants.O_DIRECTORY : 0) | (options.requireRegularFile ? constants.O_NONBLOCK : 0);
|
|
7222
7225
|
const file = openAt(libc, directoryFd, name, finalFlags);
|
|
7223
7226
|
opened.push(file);
|
|
7224
|
-
const actual = fstatSync(file);
|
|
7227
|
+
const actual = fstatSync(file, { bigint: true });
|
|
7225
7228
|
if (!sameIdentity(expected, actual))
|
|
7226
7229
|
throw new DescriptorReadError("race", "safe source target changed");
|
|
7227
7230
|
if (options.requireRegularFile && !actual.isFile())
|
|
7228
7231
|
throw new DescriptorReadError("not-regular", "safe source is not a regular file");
|
|
7229
|
-
|
|
7232
|
+
opened.pop();
|
|
7233
|
+
return file;
|
|
7230
7234
|
} catch (error) {
|
|
7231
7235
|
if (error instanceof DescriptorReadError)
|
|
7232
7236
|
throw error;
|
|
@@ -7234,7 +7238,18 @@ function readDescriptorChain(workspaceRoot, absolutePath, options = {}) {
|
|
|
7234
7238
|
} finally {
|
|
7235
7239
|
for (const fd of opened.reverse())
|
|
7236
7240
|
libc.symbols.close(fd);
|
|
7237
|
-
|
|
7241
|
+
}
|
|
7242
|
+
}
|
|
7243
|
+
function readDescriptorChain(workspaceRoot, absolutePath, options = {}) {
|
|
7244
|
+
const fd = openDescriptorChain(workspaceRoot, absolutePath, options);
|
|
7245
|
+
try {
|
|
7246
|
+
return readAll(fd, fstatSync(fd), options.maxBytes);
|
|
7247
|
+
} catch (error) {
|
|
7248
|
+
if (error instanceof DescriptorReadError)
|
|
7249
|
+
throw error;
|
|
7250
|
+
throw new DescriptorReadError("read-failed", "safe descriptor source read failed");
|
|
7251
|
+
} finally {
|
|
7252
|
+
closeSync(fd);
|
|
7238
7253
|
}
|
|
7239
7254
|
}
|
|
7240
7255
|
async function readDescriptorChainAsync(workspaceRoot, absolutePath, options = {}) {
|
|
@@ -7245,13 +7260,15 @@ async function readDescriptorChainAsync(workspaceRoot, absolutePath, options = {
|
|
|
7245
7260
|
return readDescriptorChain(workspaceRoot, absolutePath, options);
|
|
7246
7261
|
}
|
|
7247
7262
|
function loadPosixLibrary() {
|
|
7263
|
+
if (posixLibrary)
|
|
7264
|
+
return posixLibrary;
|
|
7248
7265
|
for (const candidate of libcCandidates) {
|
|
7249
7266
|
try {
|
|
7250
|
-
|
|
7267
|
+
posixLibrary = dlopen(candidate, {
|
|
7251
7268
|
openat: { args: [FFIType.i32, FFIType.cstring, FFIType.i32, FFIType.i32], returns: FFIType.i32 },
|
|
7252
|
-
read: { args: [FFIType.i32, FFIType.ptr, FFIType.u64], returns: FFIType.i64 },
|
|
7253
7269
|
close: { args: [FFIType.i32], returns: FFIType.i32 }
|
|
7254
7270
|
});
|
|
7271
|
+
return posixLibrary;
|
|
7255
7272
|
} catch {}
|
|
7256
7273
|
}
|
|
7257
7274
|
return;
|
|
@@ -7265,7 +7282,7 @@ function openAt(libc, directoryFd, component, flags) {
|
|
|
7265
7282
|
function sameIdentity(left, right) {
|
|
7266
7283
|
return left.dev === right.dev && left.ino === right.ino;
|
|
7267
7284
|
}
|
|
7268
|
-
function readAll(
|
|
7285
|
+
function readAll(fd, descriptor, maxBytes) {
|
|
7269
7286
|
if (maxBytes !== undefined && descriptor.size > maxBytes)
|
|
7270
7287
|
throw new DescriptorReadError("too-large", "safe source exceeds the byte limit");
|
|
7271
7288
|
const chunks = [];
|
|
@@ -7279,19 +7296,19 @@ function readAll(libc, fd, descriptor, maxBytes) {
|
|
|
7279
7296
|
return Buffer.concat(chunks);
|
|
7280
7297
|
}
|
|
7281
7298
|
const chunk = Buffer.allocUnsafe(Math.min(READ_CHUNK_BYTES, remaining));
|
|
7282
|
-
|
|
7283
|
-
|
|
7299
|
+
let length;
|
|
7300
|
+
try {
|
|
7301
|
+
length = readSync(fd, chunk, 0, chunk.length, null);
|
|
7302
|
+
} catch {
|
|
7284
7303
|
throw new DescriptorReadError("read-failed", "safe descriptor source read failed");
|
|
7285
|
-
|
|
7304
|
+
}
|
|
7305
|
+
if (!length)
|
|
7286
7306
|
return Buffer.concat(chunks);
|
|
7287
|
-
const length = Number(read);
|
|
7288
|
-
if (!Number.isSafeInteger(length) || length > chunk.length)
|
|
7289
|
-
throw new DescriptorReadError("read-failed", "safe descriptor source read returned an invalid length");
|
|
7290
7307
|
total += length;
|
|
7291
7308
|
chunks.push(chunk.subarray(0, length));
|
|
7292
7309
|
}
|
|
7293
7310
|
}
|
|
7294
|
-
var DescriptorReadError, atFdcwd, libcCandidates, READ_CHUNK_BYTES;
|
|
7311
|
+
var DescriptorReadError, atFdcwd, libcCandidates, READ_CHUNK_BYTES, posixLibrary;
|
|
7295
7312
|
var init_descriptor_read = __esm(() => {
|
|
7296
7313
|
DescriptorReadError = class DescriptorReadError extends Error {
|
|
7297
7314
|
code;
|
|
@@ -7322,13 +7339,13 @@ async function readContainedFile(ownerRoot, candidatePath, options = {}) {
|
|
|
7322
7339
|
let rootIdentity;
|
|
7323
7340
|
let targetIdentity;
|
|
7324
7341
|
try {
|
|
7325
|
-
const rootStat = await lstat4(ownerRoot);
|
|
7342
|
+
const rootStat = await lstat4(ownerRoot, { bigint: true });
|
|
7326
7343
|
if (!rootStat.isDirectory() || rootStat.isSymbolicLink())
|
|
7327
7344
|
throw new ContainedReadError("CONTAINED_READ_RACE", "contained source owner root changed");
|
|
7328
7345
|
rootIdentity = rootStat;
|
|
7329
7346
|
rootReal = await realpath4(ownerRoot);
|
|
7330
7347
|
targetReal = await realpath4(candidatePath);
|
|
7331
|
-
const targetStat = await stat3(targetReal);
|
|
7348
|
+
const targetStat = await stat3(targetReal, { bigint: true });
|
|
7332
7349
|
if (options.requireRegularFile !== false && !targetStat.isFile()) {
|
|
7333
7350
|
throw new ContainedReadError("CONTAINED_READ_NOT_REGULAR", "contained source is not a regular file");
|
|
7334
7351
|
}
|
|
@@ -8538,9 +8555,9 @@ function revisionOperand(ref) {
|
|
|
8538
8555
|
// src/lib/git-worktrees.ts
|
|
8539
8556
|
import { readdir as readdir3, readFile as readFile7, realpath as realpath7, stat as stat6 } from "fs/promises";
|
|
8540
8557
|
import path23 from "path";
|
|
8541
|
-
async function resolveGitCommonDir(cwd) {
|
|
8558
|
+
async function resolveGitCommonDir(cwd, env) {
|
|
8542
8559
|
try {
|
|
8543
|
-
const proc = Bun.spawn(["git", "rev-parse", "--git-common-dir"], { cwd, stdout: "pipe", stderr: "ignore" });
|
|
8560
|
+
const proc = Bun.spawn(["git", "rev-parse", "--git-common-dir"], { cwd, ...env && { env }, stdout: "pipe", stderr: "ignore" });
|
|
8544
8561
|
const out = (await new Response(proc.stdout).text()).trim();
|
|
8545
8562
|
if (await proc.exited !== 0 || out.length === 0) {
|
|
8546
8563
|
return;
|
|
@@ -18851,6 +18868,17 @@ var init_config3 = __esm(() => {
|
|
|
18851
18868
|
};
|
|
18852
18869
|
});
|
|
18853
18870
|
|
|
18871
|
+
// src/lib/self-invocation.ts
|
|
18872
|
+
import path81 from "path";
|
|
18873
|
+
function isCompiledBinaryEntry(entry) {
|
|
18874
|
+
return entry.startsWith("/$bunfs/") || /^[A-Za-z]:[\\/]~BUN[\\/]/.test(entry);
|
|
18875
|
+
}
|
|
18876
|
+
function desktopResourceDirectory(entry = process.argv[1] ?? "", executable = process.execPath) {
|
|
18877
|
+
const bin = path81.dirname(executable);
|
|
18878
|
+
return isCompiledBinaryEntry(entry) && path81.basename(bin) === "MacOS" ? path81.resolve(bin, "../Resources") : undefined;
|
|
18879
|
+
}
|
|
18880
|
+
var init_self_invocation = () => {};
|
|
18881
|
+
|
|
18854
18882
|
// src/gdgraph/treesitter/extract.ts
|
|
18855
18883
|
function calleeShape(callee) {
|
|
18856
18884
|
const withoutCall = callee.replace(/\(.*$/s, "").trim();
|
|
@@ -19395,7 +19423,7 @@ var init_extract = __esm(() => {
|
|
|
19395
19423
|
});
|
|
19396
19424
|
|
|
19397
19425
|
// src/gdgraph/treesitter/grammars.ts
|
|
19398
|
-
import
|
|
19426
|
+
import path82 from "path";
|
|
19399
19427
|
function grammarAssetId(language) {
|
|
19400
19428
|
return `tree-sitter-${language}`;
|
|
19401
19429
|
}
|
|
@@ -19411,7 +19439,7 @@ function symbolLanguage(language) {
|
|
|
19411
19439
|
async function resolveGrammar(cwd, language, grammarsPath) {
|
|
19412
19440
|
const id = grammarAssetId(language);
|
|
19413
19441
|
const lock = await loadAssetsLock(cwd);
|
|
19414
|
-
const overrides = grammarsPath ? { [id]: { path:
|
|
19442
|
+
const overrides = grammarsPath ? { [id]: { path: path82.join(grammarsPath, `${id}.wasm`) } } : undefined;
|
|
19415
19443
|
const registry = registryFromLock(lock, overrides);
|
|
19416
19444
|
const resolved = await resolveAsset(registry, id);
|
|
19417
19445
|
if (!resolved) {
|
|
@@ -19441,7 +19469,7 @@ function toGrammarLanguages(languages) {
|
|
|
19441
19469
|
return out;
|
|
19442
19470
|
}
|
|
19443
19471
|
function grammarForFile(file, available) {
|
|
19444
|
-
const ext =
|
|
19472
|
+
const ext = path82.extname(file);
|
|
19445
19473
|
const preference = ext === ".tsx" ? ["tsx", "typescript"] : ext === ".ts" ? ["typescript"] : ext === ".jsx" || ext === ".js" || ext === ".mjs" || ext === ".cjs" ? ["javascript"] : ext === ".java" ? ["java"] : ext === ".py" ? ["python"] : [];
|
|
19446
19474
|
for (const language of preference) {
|
|
19447
19475
|
if (available.includes(language)) {
|
|
@@ -19456,6 +19484,7 @@ var init_grammars = __esm(() => {
|
|
|
19456
19484
|
});
|
|
19457
19485
|
|
|
19458
19486
|
// src/gdgraph/treesitter/adapter.ts
|
|
19487
|
+
import path83 from "path";
|
|
19459
19488
|
function describeGrammarDiagnoses(diagnoses) {
|
|
19460
19489
|
if (diagnoses.length === 0) {
|
|
19461
19490
|
return "no grammar languages configured";
|
|
@@ -19671,7 +19700,12 @@ function normalizeParserApi(dep) {
|
|
|
19671
19700
|
return Promise.reject(new Error("web-tree-sitter: no Language.load"));
|
|
19672
19701
|
};
|
|
19673
19702
|
return {
|
|
19674
|
-
...init ? { init
|
|
19703
|
+
...init ? { init: () => {
|
|
19704
|
+
const resources = desktopResourceDirectory();
|
|
19705
|
+
if (!resources)
|
|
19706
|
+
return init();
|
|
19707
|
+
return init({ locateFile: (name, prefix) => name === "tree-sitter.wasm" ? path83.join(resources, "tree-sitter.wasm") : path83.resolve(prefix, name) });
|
|
19708
|
+
} } : {},
|
|
19675
19709
|
loadLanguage,
|
|
19676
19710
|
create: () => new ParserClass
|
|
19677
19711
|
};
|
|
@@ -19695,6 +19729,7 @@ function compareCalls2(a, b) {
|
|
|
19695
19729
|
return a.kind < b.kind ? -1 : a.kind > b.kind ? 1 : 0;
|
|
19696
19730
|
}
|
|
19697
19731
|
var init_adapter = __esm(() => {
|
|
19732
|
+
init_self_invocation();
|
|
19698
19733
|
init_seam();
|
|
19699
19734
|
init_warn_once();
|
|
19700
19735
|
init_extract();
|
|
@@ -19703,7 +19738,7 @@ var init_adapter = __esm(() => {
|
|
|
19703
19738
|
|
|
19704
19739
|
// src/gdgraph/enrich.ts
|
|
19705
19740
|
import { mkdir as mkdir14, writeFile as writeFile8 } from "fs/promises";
|
|
19706
|
-
import
|
|
19741
|
+
import path84 from "path";
|
|
19707
19742
|
async function enrichBuildWithSymbols(cwd, files, resolve, dataDir) {
|
|
19708
19743
|
const config = await loadGdgraphConfig(cwd);
|
|
19709
19744
|
const treesitterConfig = {
|
|
@@ -19721,10 +19756,10 @@ async function enrichBuildWithSymbols(cwd, files, resolve, dataDir) {
|
|
|
19721
19756
|
async function writeSymbolLayer(cwd, layer, dataDir) {
|
|
19722
19757
|
const storageDir = gdgraphStorageDir(cwd, dataDir);
|
|
19723
19758
|
await mkdir14(storageDir, { recursive: true });
|
|
19724
|
-
await writeFile8(
|
|
19759
|
+
await writeFile8(path84.join(storageDir, "symbols.jsonl"), layer.symbols.map((symbol) => JSON.stringify(symbol)).join(`
|
|
19725
19760
|
`) + `
|
|
19726
19761
|
`, "utf8");
|
|
19727
|
-
await writeFile8(
|
|
19762
|
+
await writeFile8(path84.join(storageDir, "calls.jsonl"), layer.calls.map((call) => JSON.stringify(call)).join(`
|
|
19728
19763
|
`) + `
|
|
19729
19764
|
`, "utf8");
|
|
19730
19765
|
}
|
|
@@ -19918,10 +19953,10 @@ var init_describes = () => {};
|
|
|
19918
19953
|
|
|
19919
19954
|
// src/sync/provenance.ts
|
|
19920
19955
|
import { mkdir as mkdir15, readFile as readFile40, writeFile as writeFile9 } from "fs/promises";
|
|
19921
|
-
import
|
|
19956
|
+
import path85 from "path";
|
|
19922
19957
|
import { spawn } from "child_process";
|
|
19923
19958
|
function provenancePath(cwd, module) {
|
|
19924
|
-
return
|
|
19959
|
+
return path85.join(cwd, ".metaproject", "data", module, ".provenance.json");
|
|
19925
19960
|
}
|
|
19926
19961
|
function gitCmdResult(cwd, args) {
|
|
19927
19962
|
return new Promise((resolve) => {
|
|
@@ -19966,7 +20001,7 @@ async function recordProvenance(cwd, module, at) {
|
|
|
19966
20001
|
if (!head)
|
|
19967
20002
|
return;
|
|
19968
20003
|
const file = provenancePath(cwd, module);
|
|
19969
|
-
await mkdir15(
|
|
20004
|
+
await mkdir15(path85.dirname(file), { recursive: true });
|
|
19970
20005
|
const provenance = { commit: head.commit, branch: head.branch, builtAt: at };
|
|
19971
20006
|
await writeFile9(file, `${JSON.stringify(provenance, null, 2)}
|
|
19972
20007
|
`, "utf8");
|
|
@@ -19992,7 +20027,7 @@ var init_provenance = __esm(() => {
|
|
|
19992
20027
|
// src/gdgraph/staleness.ts
|
|
19993
20028
|
import { spawn as spawn2 } from "child_process";
|
|
19994
20029
|
import { stat as stat12 } from "fs/promises";
|
|
19995
|
-
import
|
|
20030
|
+
import path86 from "path";
|
|
19996
20031
|
function gitStatusPorcelain(cwd) {
|
|
19997
20032
|
return new Promise((resolve) => {
|
|
19998
20033
|
try {
|
|
@@ -20015,10 +20050,10 @@ function gitStatusPorcelain(cwd) {
|
|
|
20015
20050
|
});
|
|
20016
20051
|
}
|
|
20017
20052
|
function nodesJsonlPath(cwd) {
|
|
20018
|
-
return
|
|
20053
|
+
return path86.join(cwd, ".metaproject", "data", "gdgraph", "storage", "nodes.jsonl");
|
|
20019
20054
|
}
|
|
20020
20055
|
function gdgraphConfigPath2(cwd) {
|
|
20021
|
-
return
|
|
20056
|
+
return path86.join(cwd, ".metaproject", "gdgraph.config.json");
|
|
20022
20057
|
}
|
|
20023
20058
|
function categorizeStatusEntries(entries, rootPrefix) {
|
|
20024
20059
|
const metaprojectPrefix = `${rootPrefix}.metaproject/`;
|
|
@@ -20113,7 +20148,7 @@ async function checkGraphStaleness(cwd, statusObservation) {
|
|
|
20113
20148
|
}
|
|
20114
20149
|
} else {
|
|
20115
20150
|
provenanceMissing = true;
|
|
20116
|
-
const logsHeadStat = await stat12(
|
|
20151
|
+
const logsHeadStat = await stat12(path86.join(cwd, ".git", "logs", "HEAD")).catch(() => null);
|
|
20117
20152
|
if (logsHeadStat && logsHeadStat.mtimeMs > nodesStat.mtimeMs) {
|
|
20118
20153
|
reasons.push("repo HEAD moved since the graph was built (no build provenance recorded; inferred from .git/logs/HEAD)");
|
|
20119
20154
|
}
|
|
@@ -20141,7 +20176,7 @@ async function checkGraphStaleness(cwd, statusObservation) {
|
|
|
20141
20176
|
if (projectRelative === null) {
|
|
20142
20177
|
continue;
|
|
20143
20178
|
}
|
|
20144
|
-
const fileStat = await stat12(
|
|
20179
|
+
const fileStat = await stat12(path86.join(cwd, projectRelative)).catch(() => null);
|
|
20145
20180
|
if (fileStat && fileStat.mtimeMs > nodesStat.mtimeMs) {
|
|
20146
20181
|
postBuildEdits.push(displayPath);
|
|
20147
20182
|
}
|
|
@@ -20277,15 +20312,15 @@ var init_types3 = __esm(() => {
|
|
|
20277
20312
|
|
|
20278
20313
|
// src/wiki/collect.ts
|
|
20279
20314
|
import { readFile as readFile41, readdir as readdir16 } from "fs/promises";
|
|
20280
|
-
import
|
|
20315
|
+
import path87 from "path";
|
|
20281
20316
|
function wikiRootPath(cwd) {
|
|
20282
|
-
return
|
|
20317
|
+
return path87.join(cwd, ".metaproject", "wiki");
|
|
20283
20318
|
}
|
|
20284
20319
|
async function collectPages(cwd) {
|
|
20285
20320
|
const root = wikiRootPath(cwd);
|
|
20286
20321
|
const pages = [];
|
|
20287
20322
|
for (const { type, folder } of WIKI_PAGE_TYPES) {
|
|
20288
|
-
const dir =
|
|
20323
|
+
const dir = path87.join(root, folder);
|
|
20289
20324
|
let names;
|
|
20290
20325
|
try {
|
|
20291
20326
|
names = await readdir16(dir);
|
|
@@ -20300,7 +20335,7 @@ async function collectPages(cwd) {
|
|
|
20300
20335
|
if (!entry.endsWith(".md")) {
|
|
20301
20336
|
continue;
|
|
20302
20337
|
}
|
|
20303
|
-
const absolutePath =
|
|
20338
|
+
const absolutePath = path87.join(dir, entry);
|
|
20304
20339
|
let content;
|
|
20305
20340
|
try {
|
|
20306
20341
|
content = await readFile41(absolutePath, "utf8");
|
|
@@ -21161,9 +21196,9 @@ var MEMORY_EMBEDDING_ID = "memory.embedding", DEFAULT_EMBED_DIMS = 96;
|
|
|
21161
21196
|
// src/memory/embedding/index.ts
|
|
21162
21197
|
import { createHash as createHash14 } from "crypto";
|
|
21163
21198
|
import { mkdir as mkdir16, readFile as readFile42, writeFile as writeFile10 } from "fs/promises";
|
|
21164
|
-
import
|
|
21199
|
+
import path88 from "path";
|
|
21165
21200
|
function embeddingsDir(cwd) {
|
|
21166
|
-
return
|
|
21201
|
+
return path88.join(cwd, ".metaproject", "data", "memory", "embeddings");
|
|
21167
21202
|
}
|
|
21168
21203
|
function entryText(entry) {
|
|
21169
21204
|
return `${entry.title}
|
|
@@ -21192,17 +21227,17 @@ async function buildEmbeddingIndex(cwd, entries, embedder, model, now) {
|
|
|
21192
21227
|
};
|
|
21193
21228
|
const dir = embeddingsDir(cwd);
|
|
21194
21229
|
await mkdir16(dir, { recursive: true });
|
|
21195
|
-
await writeFile10(
|
|
21230
|
+
await writeFile10(path88.join(dir, "index.meta.json"), `${JSON.stringify(meta, null, 2)}
|
|
21196
21231
|
`, "utf8");
|
|
21197
|
-
await writeFile10(
|
|
21232
|
+
await writeFile10(path88.join(dir, "vectors.jsonl"), records.map((record) => JSON.stringify(record)).join(`
|
|
21198
21233
|
`) + (records.length > 0 ? `
|
|
21199
21234
|
` : ""), "utf8");
|
|
21200
21235
|
return toIndex(meta, records);
|
|
21201
21236
|
}
|
|
21202
21237
|
async function loadEmbeddingIndex(cwd) {
|
|
21203
21238
|
const dir = embeddingsDir(cwd);
|
|
21204
|
-
const metaPath =
|
|
21205
|
-
const vectorsPath =
|
|
21239
|
+
const metaPath = path88.join(dir, "index.meta.json");
|
|
21240
|
+
const vectorsPath = path88.join(dir, "vectors.jsonl");
|
|
21206
21241
|
if (!await pathExists(metaPath) || !await pathExists(vectorsPath)) {
|
|
21207
21242
|
return null;
|
|
21208
21243
|
}
|
|
@@ -21283,10 +21318,10 @@ var init_embedding = __esm(() => {
|
|
|
21283
21318
|
});
|
|
21284
21319
|
|
|
21285
21320
|
// src/wiki/section-tombstone.ts
|
|
21286
|
-
import
|
|
21321
|
+
import path89 from "path";
|
|
21287
21322
|
import { stat as stat13 } from "fs/promises";
|
|
21288
21323
|
function sectionRegistryPath(cwd) {
|
|
21289
|
-
return
|
|
21324
|
+
return path89.join(cwd, ".metaproject", "wiki", ".sections.json");
|
|
21290
21325
|
}
|
|
21291
21326
|
function emptySectionRegistry() {
|
|
21292
21327
|
return { version: SECTION_REGISTRY_VERSION, entries: [], tombstones: [], lifted: [] };
|
|
@@ -21588,10 +21623,10 @@ var init_section_tombstone = __esm(() => {
|
|
|
21588
21623
|
|
|
21589
21624
|
// src/memory/cross-layer.ts
|
|
21590
21625
|
import { readFile as readFile43 } from "fs/promises";
|
|
21591
|
-
import
|
|
21626
|
+
import path90 from "path";
|
|
21592
21627
|
function extractWikiReferences(entryRelativePath, entryAbsolutePath, content, wikiRoot) {
|
|
21593
21628
|
const references = [];
|
|
21594
|
-
const entryDir =
|
|
21629
|
+
const entryDir = path90.dirname(entryAbsolutePath);
|
|
21595
21630
|
const lines = content.split(`
|
|
21596
21631
|
`);
|
|
21597
21632
|
for (let index = 0;index < lines.length; index += 1) {
|
|
@@ -21606,16 +21641,16 @@ function extractWikiReferences(entryRelativePath, entryAbsolutePath, content, wi
|
|
|
21606
21641
|
if (withoutAnchor.length === 0) {
|
|
21607
21642
|
continue;
|
|
21608
21643
|
}
|
|
21609
|
-
const absolute =
|
|
21610
|
-
const relativeToWiki =
|
|
21611
|
-
if (relativeToWiki.startsWith("..") ||
|
|
21644
|
+
const absolute = path90.resolve(entryDir, withoutAnchor);
|
|
21645
|
+
const relativeToWiki = path90.relative(wikiRoot, absolute);
|
|
21646
|
+
if (relativeToWiki.startsWith("..") || path90.isAbsolute(relativeToWiki)) {
|
|
21612
21647
|
continue;
|
|
21613
21648
|
}
|
|
21614
21649
|
references.push({
|
|
21615
21650
|
entry: entryRelativePath,
|
|
21616
21651
|
kind: "page-path",
|
|
21617
21652
|
raw: href,
|
|
21618
|
-
target: relativeToWiki.split(
|
|
21653
|
+
target: relativeToWiki.split(path90.sep).join("/"),
|
|
21619
21654
|
line
|
|
21620
21655
|
});
|
|
21621
21656
|
}
|
|
@@ -21635,7 +21670,7 @@ function isDangling(finding) {
|
|
|
21635
21670
|
return finding.state !== "intact";
|
|
21636
21671
|
}
|
|
21637
21672
|
async function loadWikiKnowledgeView(cwd) {
|
|
21638
|
-
const wikiRoot =
|
|
21673
|
+
const wikiRoot = path90.join(cwd, ".metaproject", "wiki");
|
|
21639
21674
|
const pages = await collectPages(cwd);
|
|
21640
21675
|
const index = buildSectionIndex(await Promise.all(pages.map(async (page) => ({
|
|
21641
21676
|
page,
|
|
@@ -21853,7 +21888,7 @@ function round2(value) {
|
|
|
21853
21888
|
var init_dedup = () => {};
|
|
21854
21889
|
|
|
21855
21890
|
// src/memory/check.ts
|
|
21856
|
-
import
|
|
21891
|
+
import path91 from "path";
|
|
21857
21892
|
async function checkMemory(cwd, config) {
|
|
21858
21893
|
const entries = await collectEntries(cwd);
|
|
21859
21894
|
const issues = [];
|
|
@@ -21869,7 +21904,7 @@ async function checkMemory(cwd, config) {
|
|
|
21869
21904
|
}
|
|
21870
21905
|
for (const file of entry.scopes.files) {
|
|
21871
21906
|
const clean = file.replace(/^`|`$/g, "");
|
|
21872
|
-
if (!await pathExists(
|
|
21907
|
+
if (!await pathExists(path91.resolve(cwd, clean))) {
|
|
21873
21908
|
issues.push({ path: entry.relativePath, kind: "link", message: `related file not found: ${clean}` });
|
|
21874
21909
|
}
|
|
21875
21910
|
}
|
|
@@ -21924,12 +21959,12 @@ var init_check = __esm(() => {
|
|
|
21924
21959
|
|
|
21925
21960
|
// src/memory/write.ts
|
|
21926
21961
|
import { mkdir as mkdir17, open as open3, readFile as readFile44, rename as rename5, rm as rm5, writeFile as writeFile11 } from "fs/promises";
|
|
21927
|
-
import
|
|
21962
|
+
import path92 from "path";
|
|
21928
21963
|
async function resolveCanonicalEntryPath(cwd, relativePath) {
|
|
21929
|
-
const root =
|
|
21930
|
-
const absolutePath =
|
|
21931
|
-
const normalized = toPosix2(
|
|
21932
|
-
if (!normalized || normalized.startsWith("../") ||
|
|
21964
|
+
const root = path92.resolve(memoryRoot(cwd));
|
|
21965
|
+
const absolutePath = path92.resolve(root, relativePath);
|
|
21966
|
+
const normalized = toPosix2(path92.relative(root, absolutePath));
|
|
21967
|
+
if (!normalized || normalized.startsWith("../") || path92.isAbsolute(normalized) || !normalized.endsWith(".md")) {
|
|
21933
21968
|
return null;
|
|
21934
21969
|
}
|
|
21935
21970
|
return { absolutePath, relativePath: normalized };
|
|
@@ -22025,9 +22060,9 @@ function validateNextEntry(relativePath, content) {
|
|
|
22025
22060
|
return null;
|
|
22026
22061
|
}
|
|
22027
22062
|
async function replaceAtomically(target, content) {
|
|
22028
|
-
const dir =
|
|
22063
|
+
const dir = path92.dirname(target);
|
|
22029
22064
|
await mkdir17(dir, { recursive: true });
|
|
22030
|
-
const tmp =
|
|
22065
|
+
const tmp = path92.join(dir, `.${path92.basename(target)}.keryx-tmp-${process.pid}-${Math.random().toString(16).slice(2)}`);
|
|
22031
22066
|
try {
|
|
22032
22067
|
await writeFile11(tmp, content, "utf8");
|
|
22033
22068
|
const file = await open3(tmp, "r");
|
|
@@ -22063,7 +22098,7 @@ function header(content, name) {
|
|
|
22063
22098
|
return content.match(new RegExp(`^${name}:\\s*(.+)$`, "mi"))?.[1]?.trim() ?? null;
|
|
22064
22099
|
}
|
|
22065
22100
|
function toPosix2(value) {
|
|
22066
|
-
return value.split(
|
|
22101
|
+
return value.split(path92.sep).join("/");
|
|
22067
22102
|
}
|
|
22068
22103
|
function message(cause) {
|
|
22069
22104
|
return cause instanceof Error ? cause.message : String(cause);
|
|
@@ -22077,9 +22112,9 @@ var init_write = __esm(() => {
|
|
|
22077
22112
|
// src/memory/ingest.ts
|
|
22078
22113
|
import { existsSync as existsSync10 } from "fs";
|
|
22079
22114
|
import { readFile as readFile45 } from "fs/promises";
|
|
22080
|
-
import
|
|
22115
|
+
import path93 from "path";
|
|
22081
22116
|
async function ingestMemory(cwd, source, filePath, config, now) {
|
|
22082
|
-
const absolute =
|
|
22117
|
+
const absolute = path93.resolve(cwd, filePath);
|
|
22083
22118
|
if (!await pathExists(absolute)) {
|
|
22084
22119
|
throw new Error(`Ingest source not found: ${filePath}`);
|
|
22085
22120
|
}
|
|
@@ -22096,8 +22131,8 @@ async function ingestMemory(cwd, source, filePath, config, now) {
|
|
|
22096
22131
|
const securityWarnings = [];
|
|
22097
22132
|
const securitySkipped = [];
|
|
22098
22133
|
let skippedDuplicates = 0;
|
|
22099
|
-
const dir =
|
|
22100
|
-
const link =
|
|
22134
|
+
const dir = path93.join(memoryRoot(cwd), folder);
|
|
22135
|
+
const link = path93.relative(cwd, absolute);
|
|
22101
22136
|
const date = dateString(now);
|
|
22102
22137
|
for (const text of candidates) {
|
|
22103
22138
|
const title = toTitle(text);
|
|
@@ -22278,7 +22313,7 @@ function uniqueSlug(dir, title) {
|
|
|
22278
22313
|
const base = slugify2(title) || "entry";
|
|
22279
22314
|
let slug = base;
|
|
22280
22315
|
let counter = 2;
|
|
22281
|
-
while (existsSync10(
|
|
22316
|
+
while (existsSync10(path93.join(dir, `${slug}.md`))) {
|
|
22282
22317
|
slug = `${base}-${counter}`;
|
|
22283
22318
|
counter += 1;
|
|
22284
22319
|
}
|
|
@@ -22313,7 +22348,7 @@ var init_ingest = __esm(() => {
|
|
|
22313
22348
|
|
|
22314
22349
|
// src/memory/supersede.ts
|
|
22315
22350
|
import { readFile as readFile46 } from "fs/promises";
|
|
22316
|
-
import
|
|
22351
|
+
import path94 from "path";
|
|
22317
22352
|
async function supersedeEntry(input, now) {
|
|
22318
22353
|
const date = input.date ?? now.toISOString().slice(0, 10);
|
|
22319
22354
|
const today = now.toISOString().slice(0, 10);
|
|
@@ -22373,12 +22408,12 @@ async function supersedeEntry(input, now) {
|
|
|
22373
22408
|
async function resolveEntryPath(cwd, raw) {
|
|
22374
22409
|
const root = memoryRoot(cwd);
|
|
22375
22410
|
const candidates = [
|
|
22376
|
-
|
|
22377
|
-
|
|
22378
|
-
|
|
22411
|
+
path94.resolve(cwd, raw),
|
|
22412
|
+
path94.resolve(root, raw),
|
|
22413
|
+
path94.isAbsolute(raw) ? raw : path94.join(cwd, raw)
|
|
22379
22414
|
];
|
|
22380
22415
|
for (const absolute of candidates) {
|
|
22381
|
-
const confined = await resolveCanonicalEntryPath(cwd,
|
|
22416
|
+
const confined = await resolveCanonicalEntryPath(cwd, path94.relative(root, absolute));
|
|
22382
22417
|
if (confined && await pathExists(confined.absolutePath)) {
|
|
22383
22418
|
return { absolute: confined.absolutePath, relative: confined.relativePath };
|
|
22384
22419
|
}
|
|
@@ -22574,9 +22609,9 @@ __export(exports_service3, {
|
|
|
22574
22609
|
});
|
|
22575
22610
|
import { createHash as createHash15 } from "crypto";
|
|
22576
22611
|
import { mkdir as mkdir18, readFile as readFile47, writeFile as writeFile12 } from "fs/promises";
|
|
22577
|
-
import
|
|
22612
|
+
import path95 from "path";
|
|
22578
22613
|
function dataRoot2(cwd) {
|
|
22579
|
-
return
|
|
22614
|
+
return path95.join(cwd, ".metaproject", "data", "memory");
|
|
22580
22615
|
}
|
|
22581
22616
|
function createMemoryService() {
|
|
22582
22617
|
const reportStore = createMemoryReportStore();
|
|
@@ -22591,9 +22626,9 @@ function createMemoryService() {
|
|
|
22591
22626
|
if (!/^[a-z0-9][a-z0-9-]*$/.test(slug)) {
|
|
22592
22627
|
throw new Error(`Invalid slug: ${slug}. Use lowercase letters, digits, and hyphens.`);
|
|
22593
22628
|
}
|
|
22594
|
-
const dir =
|
|
22595
|
-
const filePath =
|
|
22596
|
-
const relativePath =
|
|
22629
|
+
const dir = path95.join(memoryRoot(input.cwd), typeConfig.folder);
|
|
22630
|
+
const filePath = path95.join(dir, `${slug}.md`);
|
|
22631
|
+
const relativePath = path95.relative(input.cwd, filePath);
|
|
22597
22632
|
if (await pathExists(filePath) && !input.force) {
|
|
22598
22633
|
throw new Error(`Entry already exists: ${relativePath}. Use --force to overwrite.`);
|
|
22599
22634
|
}
|
|
@@ -22624,9 +22659,9 @@ function createMemoryService() {
|
|
|
22624
22659
|
async index(input) {
|
|
22625
22660
|
const entries = await collectEntries(input.cwd);
|
|
22626
22661
|
const generatedAt = new Date().toISOString();
|
|
22627
|
-
const indexDir = input.indexDir ??
|
|
22662
|
+
const indexDir = input.indexDir ?? path95.join(dataRoot2(input.cwd), "index");
|
|
22628
22663
|
await mkdir18(indexDir, { recursive: true });
|
|
22629
|
-
const indexPath =
|
|
22664
|
+
const indexPath = path95.join(indexDir, "index.json");
|
|
22630
22665
|
await writeFile12(indexPath, `${JSON.stringify({
|
|
22631
22666
|
catalogVersion: 1,
|
|
22632
22667
|
sourceFingerprint: createHash15("sha256").update(JSON.stringify(entries.map((e) => ({
|
|
@@ -22647,7 +22682,7 @@ function createMemoryService() {
|
|
|
22647
22682
|
}, null, 2)}
|
|
22648
22683
|
`, "utf8");
|
|
22649
22684
|
const result = {
|
|
22650
|
-
path:
|
|
22685
|
+
path: path95.relative(input.cwd, indexPath),
|
|
22651
22686
|
entryCount: entries.length,
|
|
22652
22687
|
generatedAt
|
|
22653
22688
|
};
|
|
@@ -22660,7 +22695,7 @@ function createMemoryService() {
|
|
|
22660
22695
|
const built = await buildEmbeddingIndex(input.cwd, entries, embedder.embed, embedder.model, new Date);
|
|
22661
22696
|
result.embeddings = {
|
|
22662
22697
|
built: true,
|
|
22663
|
-
path:
|
|
22698
|
+
path: path95.relative(input.cwd, embeddingsDir(input.cwd)),
|
|
22664
22699
|
vectorCount: built.meta.entryCount,
|
|
22665
22700
|
model: built.meta.model
|
|
22666
22701
|
};
|
|
@@ -23262,7 +23297,7 @@ var init_ask = __esm(() => {
|
|
|
23262
23297
|
});
|
|
23263
23298
|
|
|
23264
23299
|
// src/wiki/backlinks.ts
|
|
23265
|
-
import
|
|
23300
|
+
import path96 from "path";
|
|
23266
23301
|
function extractCodePaths(content) {
|
|
23267
23302
|
const out = [];
|
|
23268
23303
|
let match;
|
|
@@ -23292,8 +23327,8 @@ function resolveLink(fromRepoPath, raw) {
|
|
|
23292
23327
|
const clean = (raw.split("#")[0] ?? "").trim();
|
|
23293
23328
|
if (!clean)
|
|
23294
23329
|
return "";
|
|
23295
|
-
const fromDir =
|
|
23296
|
-
return
|
|
23330
|
+
const fromDir = path96.posix.dirname(fromRepoPath.split(path96.sep).join("/"));
|
|
23331
|
+
return path96.posix.normalize(path96.posix.join(fromDir, clean));
|
|
23297
23332
|
}
|
|
23298
23333
|
function buildBacklinkIndex(pages) {
|
|
23299
23334
|
const index = new Map;
|
|
@@ -23307,18 +23342,18 @@ function buildBacklinkIndex(pages) {
|
|
|
23307
23342
|
}
|
|
23308
23343
|
};
|
|
23309
23344
|
for (const page of pages) {
|
|
23310
|
-
const from = page.repoPath.split(
|
|
23345
|
+
const from = page.repoPath.split(path96.sep).join("/");
|
|
23311
23346
|
for (const raw of extractLinks(page.content))
|
|
23312
23347
|
add(resolveLink(from, raw), from);
|
|
23313
23348
|
for (const raw of extractCodePaths(page.content))
|
|
23314
|
-
add(
|
|
23349
|
+
add(path96.posix.normalize(raw), from);
|
|
23315
23350
|
}
|
|
23316
23351
|
for (const list of index.values())
|
|
23317
23352
|
list.sort();
|
|
23318
23353
|
return index;
|
|
23319
23354
|
}
|
|
23320
23355
|
function backlinksFor(index, targetRepoPath) {
|
|
23321
|
-
const key =
|
|
23356
|
+
const key = path96.posix.normalize(targetRepoPath.split(path96.sep).join("/"));
|
|
23322
23357
|
return index.get(key) ?? [];
|
|
23323
23358
|
}
|
|
23324
23359
|
var LINK, CODE_SPAN, FILE_LIKE;
|
|
@@ -23331,7 +23366,7 @@ var init_backlinks = __esm(() => {
|
|
|
23331
23366
|
// src/ctx/assembly.ts
|
|
23332
23367
|
import { createHash as createHash16 } from "crypto";
|
|
23333
23368
|
import { mkdir as mkdir19, rename as rename6, writeFile as writeFile13 } from "fs/promises";
|
|
23334
|
-
import
|
|
23369
|
+
import path97 from "path";
|
|
23335
23370
|
function assembleContext(input) {
|
|
23336
23371
|
let items = 0;
|
|
23337
23372
|
let tokens = 0;
|
|
@@ -23375,9 +23410,9 @@ async function recordNoContentContext(input) {
|
|
|
23375
23410
|
return assembly;
|
|
23376
23411
|
}
|
|
23377
23412
|
async function recordContextAssembly(input) {
|
|
23378
|
-
const directory =
|
|
23413
|
+
const directory = path97.join(input.workspaceRoot, ".metaproject", "context-operations", "traces");
|
|
23379
23414
|
await mkdir19(directory, { recursive: true });
|
|
23380
|
-
const target =
|
|
23415
|
+
const target = path97.join(directory, path97.basename(input.assembly.traceRef));
|
|
23381
23416
|
const temporary = `${target}.${process.pid}.tmp`;
|
|
23382
23417
|
await writeFile13(temporary, `${JSON.stringify({ schemaVersion: "1.0", correlationId: input.correlationId, outcome: input.outcome, configurationRevision: input.assembly.configurationRevision, policy: { ref: input.assembly.policyRef, revision: input.assembly.policyRevision }, selected: input.assembly.selected, omittedOptional: input.assembly.omittedOptional, partial: input.assembly.partial })}
|
|
23383
23418
|
`, { mode: 384 });
|
|
@@ -23777,9 +23812,9 @@ var init_evidence = __esm(() => {
|
|
|
23777
23812
|
});
|
|
23778
23813
|
|
|
23779
23814
|
// src/wiki/config.ts
|
|
23780
|
-
import
|
|
23815
|
+
import path98 from "path";
|
|
23781
23816
|
function wikiConfigPath(cwd) {
|
|
23782
|
-
return
|
|
23817
|
+
return path98.join(cwd, ".metaproject", "wiki.config.json");
|
|
23783
23818
|
}
|
|
23784
23819
|
function mergeWikiConfig(parsed) {
|
|
23785
23820
|
const base = DEFAULT_WIKI_CONFIG;
|
|
@@ -23857,12 +23892,12 @@ var init_config4 = __esm(() => {
|
|
|
23857
23892
|
// src/wiki/history.ts
|
|
23858
23893
|
import { createHash as createHash17, randomBytes as randomBytes5 } from "crypto";
|
|
23859
23894
|
import { appendFile as appendFile4, mkdir as mkdir20, open as open4, readFile as readFile49, rm as rm6, stat as stat14, writeFile as writeFile14 } from "fs/promises";
|
|
23860
|
-
import
|
|
23895
|
+
import path99 from "path";
|
|
23861
23896
|
function wikiRootPath2(cwd) {
|
|
23862
|
-
return
|
|
23897
|
+
return path99.join(cwd, ".metaproject", "wiki");
|
|
23863
23898
|
}
|
|
23864
23899
|
function wikiHistoryRoot(cwd) {
|
|
23865
|
-
return
|
|
23900
|
+
return path99.join(cwd, ".metaproject", "data", "gdwiki", "history");
|
|
23866
23901
|
}
|
|
23867
23902
|
function newWikiRunId(now = new Date) {
|
|
23868
23903
|
const stamp = now.toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
|
|
@@ -23883,29 +23918,29 @@ async function openWikiWriteContext(cwd, command) {
|
|
|
23883
23918
|
return createWikiWriteContext(cwd, command, { keep: (await loadWikiConfig(cwd)).history.keep });
|
|
23884
23919
|
}
|
|
23885
23920
|
function wikiPageKey(cwd, absolutePath) {
|
|
23886
|
-
const relative =
|
|
23887
|
-
if (relative === "" || relative.startsWith("..") ||
|
|
23921
|
+
const relative = path99.relative(wikiRootPath2(cwd), path99.resolve(absolutePath));
|
|
23922
|
+
if (relative === "" || relative.startsWith("..") || path99.isAbsolute(relative)) {
|
|
23888
23923
|
throw new Error(`not a wiki page: ${absolutePath}`);
|
|
23889
23924
|
}
|
|
23890
23925
|
return toPosix(relative);
|
|
23891
23926
|
}
|
|
23892
23927
|
function assertPageKey(page) {
|
|
23893
23928
|
const segments = page.split("/");
|
|
23894
|
-
if (page.length === 0 || page.includes("\\") ||
|
|
23929
|
+
if (page.length === 0 || page.includes("\\") || path99.isAbsolute(page) || segments.some((segment) => segment === "" || segment === "." || segment === "..")) {
|
|
23895
23930
|
throw new Error(`not a wiki page path: ${page}`);
|
|
23896
23931
|
}
|
|
23897
23932
|
return page;
|
|
23898
23933
|
}
|
|
23899
23934
|
function pageHistoryDir(cwd, page) {
|
|
23900
|
-
return
|
|
23935
|
+
return path99.join(wikiHistoryRoot(cwd), ...assertPageKey(page).replace(/\.md$/i, "").split("/"));
|
|
23901
23936
|
}
|
|
23902
23937
|
function pagePath(cwd, page) {
|
|
23903
|
-
return
|
|
23938
|
+
return path99.join(wikiRootPath2(cwd), ...assertPageKey(page).split("/"));
|
|
23904
23939
|
}
|
|
23905
23940
|
function versionFilePath(cwd, page, file) {
|
|
23906
23941
|
const dir = pageHistoryDir(cwd, page);
|
|
23907
|
-
const target =
|
|
23908
|
-
if (!VERSION_FILE.test(file) ||
|
|
23942
|
+
const target = path99.join(dir, file);
|
|
23943
|
+
if (!VERSION_FILE.test(file) || path99.dirname(target) !== dir) {
|
|
23909
23944
|
throw new Error(`history index names an invalid version file for ${page}: ${file}`);
|
|
23910
23945
|
}
|
|
23911
23946
|
return target;
|
|
@@ -23978,7 +24013,7 @@ function parsePageHistoryIndex(markdown, page) {
|
|
|
23978
24013
|
return { page, rows };
|
|
23979
24014
|
}
|
|
23980
24015
|
async function readPageHistory(cwd, page) {
|
|
23981
|
-
const indexPath =
|
|
24016
|
+
const indexPath = path99.join(pageHistoryDir(cwd, page), INDEX_FILE);
|
|
23982
24017
|
const raw = await readBufferOrNull(indexPath);
|
|
23983
24018
|
if (raw === null)
|
|
23984
24019
|
return null;
|
|
@@ -23990,8 +24025,8 @@ async function readPageHistory(cwd, page) {
|
|
|
23990
24025
|
}
|
|
23991
24026
|
async function storeVersion(cwd, page, version, at, content) {
|
|
23992
24027
|
const fileName = `${versionLabel(version)}-${at.replace(/[:.]/g, "-")}.md`;
|
|
23993
|
-
const target =
|
|
23994
|
-
await mkdir20(
|
|
24028
|
+
const target = path99.join(pageHistoryDir(cwd, page), fileName);
|
|
24029
|
+
await mkdir20(path99.dirname(target), { recursive: true });
|
|
23995
24030
|
await writeFile14(target, content);
|
|
23996
24031
|
if (sha2562(await readFile49(target)) !== sha2562(content)) {
|
|
23997
24032
|
throw new Error(`history: stored version does not match the page bytes: ${target}`);
|
|
@@ -24029,7 +24064,7 @@ function planPrune(history, keep, maxRows = MAX_INDEX_ROWS) {
|
|
|
24029
24064
|
}
|
|
24030
24065
|
async function ensureHistoryRoot(cwd) {
|
|
24031
24066
|
const root = wikiHistoryRoot(cwd);
|
|
24032
|
-
const ignore =
|
|
24067
|
+
const ignore = path99.join(root, ".gitignore");
|
|
24033
24068
|
if (await readBufferOrNull(ignore))
|
|
24034
24069
|
return;
|
|
24035
24070
|
await mkdir20(root, { recursive: true });
|
|
@@ -24059,14 +24094,14 @@ async function endsWithoutNewline(file) {
|
|
|
24059
24094
|
}
|
|
24060
24095
|
async function appendRun(cwd, entry) {
|
|
24061
24096
|
const root = wikiHistoryRoot(cwd);
|
|
24062
|
-
const file =
|
|
24097
|
+
const file = path99.join(root, RUNS_FILE);
|
|
24063
24098
|
const lead = await endsWithoutNewline(file) ? `
|
|
24064
24099
|
` : "";
|
|
24065
24100
|
await appendFile4(file, `${lead}${JSON.stringify(entry)}
|
|
24066
24101
|
`, "utf8");
|
|
24067
24102
|
if ((await stat14(file)).size <= MAX_RUNS_BYTES)
|
|
24068
24103
|
return;
|
|
24069
|
-
await withFileLock(
|
|
24104
|
+
await withFileLock(path99.join(root, ".runs.lock"), async () => {
|
|
24070
24105
|
if ((await stat14(file)).size <= MAX_RUNS_BYTES)
|
|
24071
24106
|
return;
|
|
24072
24107
|
const lines = (await readFile49(file, "utf8")).split(`
|
|
@@ -24080,7 +24115,7 @@ async function mutatePage(ctx, absolutePath, next) {
|
|
|
24080
24115
|
const page = wikiPageKey(ctx.cwd, absolutePath);
|
|
24081
24116
|
const dir = pageHistoryDir(ctx.cwd, page);
|
|
24082
24117
|
await ensureHistoryRoot(ctx.cwd);
|
|
24083
|
-
return withFileLock(
|
|
24118
|
+
return withFileLock(path99.join(path99.dirname(dir), `.${path99.basename(dir)}.lock`), async () => {
|
|
24084
24119
|
const live = await readBufferOrNull(absolutePath);
|
|
24085
24120
|
if (next === null ? live === null : live !== null && live.equals(next)) {
|
|
24086
24121
|
return { changed: false };
|
|
@@ -24104,7 +24139,7 @@ async function mutatePage(ctx, absolutePath, next) {
|
|
|
24104
24139
|
if (next === null) {
|
|
24105
24140
|
await rm6(absolutePath, { force: true });
|
|
24106
24141
|
} else {
|
|
24107
|
-
await mkdir20(
|
|
24142
|
+
await mkdir20(path99.dirname(absolutePath), { recursive: true });
|
|
24108
24143
|
await writeFile14(absolutePath, next);
|
|
24109
24144
|
}
|
|
24110
24145
|
} catch (error) {
|
|
@@ -24112,7 +24147,7 @@ async function mutatePage(ctx, absolutePath, next) {
|
|
|
24112
24147
|
await rm6(versionFilePath(ctx.cwd, page, row.file), { force: true });
|
|
24113
24148
|
throw error;
|
|
24114
24149
|
}
|
|
24115
|
-
await writeFileAtomic(
|
|
24150
|
+
await writeFileAtomic(path99.join(dir, INDEX_FILE), renderPageHistoryIndex(history));
|
|
24116
24151
|
for (const file of pruned)
|
|
24117
24152
|
await rm6(versionFilePath(ctx.cwd, page, file), { force: true });
|
|
24118
24153
|
return { changed: true, action };
|
|
@@ -24125,7 +24160,7 @@ async function deleteWikiPage(ctx, absolutePath) {
|
|
|
24125
24160
|
return mutatePage(ctx, absolutePath, null);
|
|
24126
24161
|
}
|
|
24127
24162
|
async function readWikiRuns(cwd) {
|
|
24128
|
-
const raw = await readBufferOrNull(
|
|
24163
|
+
const raw = await readBufferOrNull(path99.join(wikiHistoryRoot(cwd), RUNS_FILE));
|
|
24129
24164
|
if (raw === null)
|
|
24130
24165
|
return [];
|
|
24131
24166
|
const entries = [];
|
|
@@ -24817,7 +24852,7 @@ var init_page_invariants = __esm(() => {
|
|
|
24817
24852
|
});
|
|
24818
24853
|
|
|
24819
24854
|
// src/wiki/readme-links.ts
|
|
24820
|
-
import
|
|
24855
|
+
import path100 from "path";
|
|
24821
24856
|
function rewriteReadmeLinks(text, readmeDir, pageLink) {
|
|
24822
24857
|
return text.replace(MARKDOWN_LINK, (whole, bang, label, target) => {
|
|
24823
24858
|
if (target === "" || HAS_SCHEME.test(target)) {
|
|
@@ -24827,7 +24862,7 @@ function rewriteReadmeLinks(text, readmeDir, pageLink) {
|
|
|
24827
24862
|
if (filePart === "") {
|
|
24828
24863
|
return label;
|
|
24829
24864
|
}
|
|
24830
|
-
const resolved =
|
|
24865
|
+
const resolved = path100.posix.normalize(filePart.startsWith("/") ? filePart.replace(/^\/+/, "") : path100.posix.join(readmeDir, filePart));
|
|
24831
24866
|
const codePath = resolved.replace(/\/+$/, "");
|
|
24832
24867
|
if (codePath === "" || codePath === "." || codePath === ".." || codePath.startsWith("../")) {
|
|
24833
24868
|
return label;
|
|
@@ -24842,12 +24877,12 @@ function rewriteReadmeLinks(text, readmeDir, pageLink) {
|
|
|
24842
24877
|
});
|
|
24843
24878
|
}
|
|
24844
24879
|
function moduleOfTarget(filePart, codePath) {
|
|
24845
|
-
const base =
|
|
24880
|
+
const base = path100.posix.basename(codePath);
|
|
24846
24881
|
if (filePart.endsWith("/") || !/\.[A-Za-z0-9]+$/.test(base)) {
|
|
24847
24882
|
return codePath;
|
|
24848
24883
|
}
|
|
24849
24884
|
if (DOC_ENTRY.test(base)) {
|
|
24850
|
-
const dir =
|
|
24885
|
+
const dir = path100.posix.dirname(codePath);
|
|
24851
24886
|
return dir === "." ? null : dir;
|
|
24852
24887
|
}
|
|
24853
24888
|
return null;
|
|
@@ -25295,15 +25330,15 @@ __export(exports_service4, {
|
|
|
25295
25330
|
import { spawn as spawn3 } from "child_process";
|
|
25296
25331
|
import { createHash as createHash19 } from "crypto";
|
|
25297
25332
|
import { mkdir as mkdir21, readFile as readFile50, readdir as readdir17, writeFile as writeFile15 } from "fs/promises";
|
|
25298
|
-
import
|
|
25333
|
+
import path101 from "path";
|
|
25299
25334
|
function wikiRootPath3(cwd) {
|
|
25300
|
-
return
|
|
25335
|
+
return path101.join(cwd, ".metaproject", "wiki");
|
|
25301
25336
|
}
|
|
25302
25337
|
function dataRootPath(cwd) {
|
|
25303
|
-
return
|
|
25338
|
+
return path101.join(cwd, ".metaproject", "data", "gdwiki");
|
|
25304
25339
|
}
|
|
25305
25340
|
function linkCheckReportPath(cwd) {
|
|
25306
|
-
return
|
|
25341
|
+
return path101.join(dataRootPath(cwd), "link-check", "latest.md");
|
|
25307
25342
|
}
|
|
25308
25343
|
async function wikiStatus(cwd) {
|
|
25309
25344
|
const root = wikiRootPath3(cwd);
|
|
@@ -25311,7 +25346,7 @@ async function wikiStatus(cwd) {
|
|
|
25311
25346
|
const pages = enabled ? await collectPages(cwd) : [];
|
|
25312
25347
|
return {
|
|
25313
25348
|
enabled,
|
|
25314
|
-
wikiRoot:
|
|
25349
|
+
wikiRoot: path101.relative(cwd, root),
|
|
25315
25350
|
totalPages: pages.length,
|
|
25316
25351
|
countsByType: WIKI_PAGE_TYPES.map(({ type }) => ({
|
|
25317
25352
|
type,
|
|
@@ -25342,9 +25377,9 @@ async function wikiCreatePage(input) {
|
|
|
25342
25377
|
if (!/^[a-z0-9][a-z0-9-]*$/.test(input.slug)) {
|
|
25343
25378
|
throw new Error(`Invalid slug: ${input.slug}. Use lowercase letters, digits, and hyphens.`);
|
|
25344
25379
|
}
|
|
25345
|
-
const dir =
|
|
25346
|
-
const filePath =
|
|
25347
|
-
const relativePath =
|
|
25380
|
+
const dir = path101.join(wikiRootPath3(input.cwd), typeConfig.folder);
|
|
25381
|
+
const filePath = path101.join(dir, `${input.slug}.md`);
|
|
25382
|
+
const relativePath = path101.relative(input.cwd, filePath);
|
|
25348
25383
|
if (await pathExists(filePath) && !input.force) {
|
|
25349
25384
|
throw new Error(`Page already exists: ${relativePath}. Use --force to overwrite.`);
|
|
25350
25385
|
}
|
|
@@ -25356,7 +25391,7 @@ async function wikiCreatePage(input) {
|
|
|
25356
25391
|
}
|
|
25357
25392
|
async function wikiGenerateIndex(cwd, history) {
|
|
25358
25393
|
const root = wikiRootPath3(cwd);
|
|
25359
|
-
const indexPath =
|
|
25394
|
+
const indexPath = path101.join(root, "index.md");
|
|
25360
25395
|
const pages = await collectPages(cwd);
|
|
25361
25396
|
const generatedAt = new Date().toISOString();
|
|
25362
25397
|
const managedBlock = `${WIKI_INDEX_BEGIN}
|
|
@@ -25373,7 +25408,7 @@ ${managedBlock}
|
|
|
25373
25408
|
`;
|
|
25374
25409
|
await writeWikiPage(history ?? await openWikiWriteContext(cwd, "wiki index"), indexPath, next);
|
|
25375
25410
|
return {
|
|
25376
|
-
path:
|
|
25411
|
+
path: path101.relative(cwd, indexPath),
|
|
25377
25412
|
pageCount: pages.length,
|
|
25378
25413
|
generatedAt
|
|
25379
25414
|
};
|
|
@@ -25381,13 +25416,13 @@ ${managedBlock}
|
|
|
25381
25416
|
async function wikiCheckLinks(cwd) {
|
|
25382
25417
|
const root = wikiRootPath3(cwd);
|
|
25383
25418
|
const allFiles = await pathExists(root) ? await walkMarkdown(root) : [];
|
|
25384
|
-
const files = allFiles.filter((absolutePath) => !
|
|
25419
|
+
const files = allFiles.filter((absolutePath) => !path101.relative(root, absolutePath).startsWith(`templates${path101.sep}`));
|
|
25385
25420
|
const broken = [];
|
|
25386
25421
|
let checkedLinks = 0;
|
|
25387
25422
|
let skippedExternal = 0;
|
|
25388
25423
|
for (const absolutePath of files) {
|
|
25389
25424
|
const content = await readFile50(absolutePath, "utf8");
|
|
25390
|
-
const pageRelative =
|
|
25425
|
+
const pageRelative = path101.relative(cwd, absolutePath);
|
|
25391
25426
|
for (const target of extractLinkTargets(content)) {
|
|
25392
25427
|
if (EXTERNAL_LINK.test(target)) {
|
|
25393
25428
|
skippedExternal += 1;
|
|
@@ -25398,7 +25433,7 @@ async function wikiCheckLinks(cwd) {
|
|
|
25398
25433
|
continue;
|
|
25399
25434
|
}
|
|
25400
25435
|
checkedLinks += 1;
|
|
25401
|
-
const resolved =
|
|
25436
|
+
const resolved = path101.resolve(path101.dirname(absolutePath), filePart);
|
|
25402
25437
|
if (!await pathExists(resolved)) {
|
|
25403
25438
|
broken.push({
|
|
25404
25439
|
page: pageRelative,
|
|
@@ -25410,7 +25445,7 @@ async function wikiCheckLinks(cwd) {
|
|
|
25410
25445
|
}
|
|
25411
25446
|
const generatedAt = new Date().toISOString();
|
|
25412
25447
|
const reportPath = linkCheckReportPath(cwd);
|
|
25413
|
-
await mkdir21(
|
|
25448
|
+
await mkdir21(path101.dirname(reportPath), { recursive: true });
|
|
25414
25449
|
await writeFile15(reportPath, renderLinkCheckReport({
|
|
25415
25450
|
generatedAt,
|
|
25416
25451
|
checkedPages: files.length,
|
|
@@ -25419,7 +25454,7 @@ async function wikiCheckLinks(cwd) {
|
|
|
25419
25454
|
broken
|
|
25420
25455
|
}), "utf8");
|
|
25421
25456
|
return {
|
|
25422
|
-
reportPath:
|
|
25457
|
+
reportPath: path101.relative(cwd, reportPath),
|
|
25423
25458
|
checkedPages: files.length,
|
|
25424
25459
|
checkedLinks,
|
|
25425
25460
|
skippedExternal,
|
|
@@ -25470,7 +25505,7 @@ async function wikiValidate(cwd) {
|
|
|
25470
25505
|
}
|
|
25471
25506
|
if (await isIndexStale(cwd, pages)) {
|
|
25472
25507
|
issues.push({
|
|
25473
|
-
page:
|
|
25508
|
+
page: path101.join(path101.relative(cwd, wikiRootPath3(cwd)), "index.md"),
|
|
25474
25509
|
kind: "index",
|
|
25475
25510
|
message: "index out of date, run `keryx wiki index`"
|
|
25476
25511
|
});
|
|
@@ -25516,7 +25551,7 @@ function collectCommandLabel(input) {
|
|
|
25516
25551
|
return ["wiki collect", ...flags].join(" ");
|
|
25517
25552
|
}
|
|
25518
25553
|
async function wikiPruneOrphans(cwd, history) {
|
|
25519
|
-
const componentsDir =
|
|
25554
|
+
const componentsDir = path101.join(wikiRootPath3(cwd), "components");
|
|
25520
25555
|
if (!await pathExists(componentsDir)) {
|
|
25521
25556
|
return { pruned: [], orphanedAccepted: [] };
|
|
25522
25557
|
}
|
|
@@ -25536,15 +25571,15 @@ async function wikiPruneOrphans(cwd, history) {
|
|
|
25536
25571
|
if (validSlugs.has(slug)) {
|
|
25537
25572
|
continue;
|
|
25538
25573
|
}
|
|
25539
|
-
const filePath =
|
|
25574
|
+
const filePath = path101.join(componentsDir, entry);
|
|
25540
25575
|
const current = await readFile50(filePath, "utf8");
|
|
25541
25576
|
const isUnmodifiedDraft = /\nStatus:\s*draft\s*\n/.test(current) && current.includes("Generated by `keryx wiki collect`");
|
|
25542
25577
|
if (isUnmodifiedDraft) {
|
|
25543
25578
|
run ??= history ?? await openWikiWriteContext(cwd, "wiki prune");
|
|
25544
25579
|
await deleteWikiPage(run, filePath);
|
|
25545
|
-
pruned.push(
|
|
25580
|
+
pruned.push(path101.relative(cwd, filePath));
|
|
25546
25581
|
} else {
|
|
25547
|
-
orphanedAccepted.push(
|
|
25582
|
+
orphanedAccepted.push(path101.relative(cwd, filePath));
|
|
25548
25583
|
}
|
|
25549
25584
|
}
|
|
25550
25585
|
return { pruned, orphanedAccepted };
|
|
@@ -25554,7 +25589,7 @@ async function validModuleNames(cwd, dataDir) {
|
|
|
25554
25589
|
return counts === undefined ? undefined : new Set(counts.keys());
|
|
25555
25590
|
}
|
|
25556
25591
|
async function moduleFileCounts(cwd, dataDir) {
|
|
25557
|
-
const nodesPath =
|
|
25592
|
+
const nodesPath = path101.join(gdgraphStorageDir(cwd, dataDir), "nodes.jsonl");
|
|
25558
25593
|
if (!await pathExists(nodesPath)) {
|
|
25559
25594
|
return;
|
|
25560
25595
|
}
|
|
@@ -25625,9 +25660,9 @@ async function wikiEvidence(input) {
|
|
|
25625
25660
|
});
|
|
25626
25661
|
}
|
|
25627
25662
|
function resolveEvidenceScope(cwd, override) {
|
|
25628
|
-
const absolute =
|
|
25663
|
+
const absolute = path101.resolve(cwd);
|
|
25629
25664
|
return {
|
|
25630
|
-
projectId: override?.projectId ?? (
|
|
25665
|
+
projectId: override?.projectId ?? (path101.basename(absolute) || "project"),
|
|
25631
25666
|
checkoutId: override?.checkoutId ?? `checkout:${createHash19("sha256").update(absolute).digest("hex").slice(0, 16)}`,
|
|
25632
25667
|
...override?.workspaceId ? { workspaceId: override.workspaceId } : {},
|
|
25633
25668
|
...override?.taskId ? { taskId: override.taskId } : {}
|
|
@@ -25642,7 +25677,7 @@ function isMachineAuthoredPage(pageType, relativePath, content) {
|
|
|
25642
25677
|
if (source === null) {
|
|
25643
25678
|
return false;
|
|
25644
25679
|
}
|
|
25645
|
-
const normalised = relativePath.split(
|
|
25680
|
+
const normalised = relativePath.split(path101.sep).join("/").replace(/^wiki\//, "");
|
|
25646
25681
|
return WIKI_PAGE_PRODUCERS.some((producer) => producer.source === source && producer.pageType === pageType && producer.path.test(normalised) && /^-[ \t]+Link:.*\bsha256\b/m.test(content));
|
|
25647
25682
|
}
|
|
25648
25683
|
function createGdWikiService() {
|
|
@@ -25658,8 +25693,8 @@ function createGdWikiService() {
|
|
|
25658
25693
|
};
|
|
25659
25694
|
}
|
|
25660
25695
|
async function collectGraphWikiCandidates(cwd, generatedAt, limit, onlyModules, dataDir) {
|
|
25661
|
-
const nodesPath =
|
|
25662
|
-
const edgesPath =
|
|
25696
|
+
const nodesPath = path101.join(gdgraphStorageDir(cwd, dataDir), "nodes.jsonl");
|
|
25697
|
+
const edgesPath = path101.join(gdgraphStorageDir(cwd, dataDir), "edges.jsonl");
|
|
25663
25698
|
if (!await pathExists(nodesPath) || !await pathExists(edgesPath)) {
|
|
25664
25699
|
return [];
|
|
25665
25700
|
}
|
|
@@ -25746,7 +25781,7 @@ async function collectGraphWikiCandidates(cwd, generatedAt, limit, onlyModules,
|
|
|
25746
25781
|
};
|
|
25747
25782
|
const moduleCandidates = [];
|
|
25748
25783
|
const pageModules = new Set(topModules.map((entry) => entry.name));
|
|
25749
|
-
const componentsDir =
|
|
25784
|
+
const componentsDir = path101.join(wikiRootPath3(cwd), "components");
|
|
25750
25785
|
const existingSlugs = new Set((await pathExists(componentsDir) ? await readdir17(componentsDir) : []).filter((entry) => entry.endsWith(".md")).map((entry) => entry.slice(0, -3)));
|
|
25751
25786
|
const pageLink = (name) => {
|
|
25752
25787
|
const slug = slugifyPath(name);
|
|
@@ -25854,7 +25889,7 @@ function topCounts(bucket, limit) {
|
|
|
25854
25889
|
return [...bucket.entries()].sort((a, b) => b[1] - a[1]).slice(0, limit);
|
|
25855
25890
|
}
|
|
25856
25891
|
async function readModuleReadme(cwd, moduleName, pageLink) {
|
|
25857
|
-
const readmePath =
|
|
25892
|
+
const readmePath = path101.join(cwd, ...moduleName.split("/"), "README.md");
|
|
25858
25893
|
if (!await pathExists(readmePath)) {
|
|
25859
25894
|
return null;
|
|
25860
25895
|
}
|
|
@@ -25875,7 +25910,7 @@ async function extractModuleExports(cwd, files) {
|
|
|
25875
25910
|
const declRe = /export\s+(?:async\s+)?(?:default\s+)?(?:const|let|var|function|class|type|interface|enum)\s+([A-Za-z_$][\w$]*)/g;
|
|
25876
25911
|
const braceRe = /export\s*\{([^}]+)\}/g;
|
|
25877
25912
|
for (const file of files.slice(0, 4)) {
|
|
25878
|
-
const filePath =
|
|
25913
|
+
const filePath = path101.join(cwd, ...file.split("/"));
|
|
25879
25914
|
if (!await pathExists(filePath)) {
|
|
25880
25915
|
continue;
|
|
25881
25916
|
}
|
|
@@ -25906,7 +25941,7 @@ async function extractModuleExports(cwd, files) {
|
|
|
25906
25941
|
}
|
|
25907
25942
|
async function extractModuleApi(cwd, files, dataDir) {
|
|
25908
25943
|
const names = await extractModuleExports(cwd, files);
|
|
25909
|
-
const symbolsPath =
|
|
25944
|
+
const symbolsPath = path101.join(gdgraphStorageDir(cwd, dataDir), "symbols.jsonl");
|
|
25910
25945
|
if (names.length === 0 || !await pathExists(symbolsPath)) {
|
|
25911
25946
|
return names.map((name) => "`" + name + "`");
|
|
25912
25947
|
}
|
|
@@ -25932,7 +25967,7 @@ async function extractModuleApi(cwd, files, dataDir) {
|
|
|
25932
25967
|
});
|
|
25933
25968
|
}
|
|
25934
25969
|
async function collectHealthWikiCandidates(cwd, generatedAt) {
|
|
25935
|
-
const healthPath =
|
|
25970
|
+
const healthPath = path101.join(cwd, ".metaproject", "data", "health", "artifacts", "latest.json");
|
|
25936
25971
|
if (!await pathExists(healthPath)) {
|
|
25937
25972
|
return [];
|
|
25938
25973
|
}
|
|
@@ -25974,7 +26009,7 @@ async function collectHealthWikiCandidates(cwd, generatedAt) {
|
|
|
25974
26009
|
}];
|
|
25975
26010
|
}
|
|
25976
26011
|
async function collectTestingWikiCandidates(cwd, generatedAt) {
|
|
25977
|
-
const contextPath =
|
|
26012
|
+
const contextPath = path101.join(cwd, ".metaproject", "data", "testing", "context.md");
|
|
25978
26013
|
if (!await pathExists(contextPath)) {
|
|
25979
26014
|
return [];
|
|
25980
26015
|
}
|
|
@@ -26005,8 +26040,8 @@ async function writeCollectedPage(cwd, candidate, force, history) {
|
|
|
26005
26040
|
if (!folder) {
|
|
26006
26041
|
throw new Error(`Unsupported collected wiki type: ${candidate.type}`);
|
|
26007
26042
|
}
|
|
26008
|
-
const filePath =
|
|
26009
|
-
const relativePath =
|
|
26043
|
+
const filePath = path101.join(wikiRootPath3(cwd), folder, `${candidate.slug}.md`);
|
|
26044
|
+
const relativePath = path101.relative(cwd, filePath);
|
|
26010
26045
|
const exists = await pathExists(filePath);
|
|
26011
26046
|
if (exists && !force) {
|
|
26012
26047
|
return { path: relativePath, type: candidate.type, source: candidate.source, action: "skipped" };
|
|
@@ -26057,7 +26092,7 @@ async function writeCollectedPage(cwd, candidate, force, history) {
|
|
|
26057
26092
|
async function wikiPagesForFile(cwd, targetRepoPath) {
|
|
26058
26093
|
const pages = await collectPages(cwd);
|
|
26059
26094
|
const refs = await Promise.all(pages.map(async (page) => ({
|
|
26060
|
-
repoPath:
|
|
26095
|
+
repoPath: path101.relative(cwd, page.absolutePath).split(path101.sep).join("/"),
|
|
26061
26096
|
content: await readFile50(page.absolutePath, "utf8")
|
|
26062
26097
|
})));
|
|
26063
26098
|
return backlinksFor(buildBacklinkIndex(refs), targetRepoPath);
|
|
@@ -26096,7 +26131,7 @@ function renderIndexBody(pages, generatedAt) {
|
|
|
26096
26131
|
`).trimEnd();
|
|
26097
26132
|
}
|
|
26098
26133
|
async function isIndexStale(cwd, pages) {
|
|
26099
|
-
const indexPath =
|
|
26134
|
+
const indexPath = path101.join(wikiRootPath3(cwd), "index.md");
|
|
26100
26135
|
if (!await pathExists(indexPath)) {
|
|
26101
26136
|
return true;
|
|
26102
26137
|
}
|
|
@@ -26114,7 +26149,7 @@ async function walkMarkdown(root) {
|
|
|
26114
26149
|
const results = [];
|
|
26115
26150
|
const entries = await readdir17(root, { withFileTypes: true });
|
|
26116
26151
|
for (const entry of entries) {
|
|
26117
|
-
const absolutePath =
|
|
26152
|
+
const absolutePath = path101.join(root, entry.name);
|
|
26118
26153
|
if (entry.isDirectory()) {
|
|
26119
26154
|
results.push(...await walkMarkdown(absolutePath));
|
|
26120
26155
|
} else if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
@@ -26171,7 +26206,7 @@ ${JSON.stringify(state, null, 2)}
|
|
|
26171
26206
|
`;
|
|
26172
26207
|
}
|
|
26173
26208
|
async function readIndexGeneratedAt(cwd) {
|
|
26174
|
-
const indexPath =
|
|
26209
|
+
const indexPath = path101.join(wikiRootPath3(cwd), "index.md");
|
|
26175
26210
|
if (!await pathExists(indexPath)) {
|
|
26176
26211
|
return null;
|
|
26177
26212
|
}
|
|
@@ -26411,7 +26446,7 @@ async function validateStructure(cwd, pages, issues) {
|
|
|
26411
26446
|
if (pattern.includes("*")) {
|
|
26412
26447
|
continue;
|
|
26413
26448
|
}
|
|
26414
|
-
if (!await pathExists(
|
|
26449
|
+
if (!await pathExists(path101.join(cwd, pattern))) {
|
|
26415
26450
|
issues.push({
|
|
26416
26451
|
page: page.relativePath,
|
|
26417
26452
|
kind: "describes",
|
|
@@ -26481,7 +26516,7 @@ async function validatePageInvariants(cwd, pages, issues) {
|
|
|
26481
26516
|
}
|
|
26482
26517
|
}
|
|
26483
26518
|
function toPosixPath(value) {
|
|
26484
|
-
return value.split(
|
|
26519
|
+
return value.split(path101.sep).join("/");
|
|
26485
26520
|
}
|
|
26486
26521
|
function compareSemver(a, b) {
|
|
26487
26522
|
const pa = a.split(".").map(Number);
|
|
@@ -26527,7 +26562,7 @@ var init_service4 = __esm(() => {
|
|
|
26527
26562
|
// src/gdgraph/wiki-layer.ts
|
|
26528
26563
|
import { createHash as createHash20 } from "crypto";
|
|
26529
26564
|
import { mkdir as mkdir22, stat as stat15, writeFile as writeFile16 } from "fs/promises";
|
|
26530
|
-
import
|
|
26565
|
+
import path102 from "path";
|
|
26531
26566
|
function storageDir(projectRoot, dataDir) {
|
|
26532
26567
|
return gdgraphStorageDir(projectRoot, dataDir);
|
|
26533
26568
|
}
|
|
@@ -26595,11 +26630,11 @@ async function enrichBuildWithWikiLayer(input) {
|
|
|
26595
26630
|
const mtimes = new Map;
|
|
26596
26631
|
for (const record of input.fileRecords) {
|
|
26597
26632
|
try {
|
|
26598
|
-
const info = await stat15(
|
|
26633
|
+
const info = await stat15(path102.join(input.projectRoot, record.path));
|
|
26599
26634
|
mtimes.set(record.path, info.mtimeMs);
|
|
26600
26635
|
} catch {}
|
|
26601
26636
|
}
|
|
26602
|
-
await writeFile16(
|
|
26637
|
+
await writeFile16(path102.join(dir, BUILD_MANIFEST_FILE), `${JSON.stringify({ version: 1, files: computeFingerprints(input.fileRecords, mtimes) }, null, 2)}
|
|
26603
26638
|
`, "utf8");
|
|
26604
26639
|
const validModules = input.validModules !== undefined ? input.validModules : await (input.loadValidModules ?? ((root) => defaultLoadValidModules(root, input.dataDir)))(input.projectRoot);
|
|
26605
26640
|
const wikiPages = await collectPages(input.projectRoot);
|
|
@@ -26624,8 +26659,8 @@ async function enrichBuildWithWikiLayer(input) {
|
|
|
26624
26659
|
version: page.version
|
|
26625
26660
|
}))
|
|
26626
26661
|
});
|
|
26627
|
-
await writeJsonl(
|
|
26628
|
-
await writeJsonl(
|
|
26662
|
+
await writeJsonl(path102.join(dir, WIKI_PAGES_FILE), layer.pages);
|
|
26663
|
+
await writeJsonl(path102.join(dir, DESCRIBES_FILE), layer.describes);
|
|
26629
26664
|
return layer;
|
|
26630
26665
|
}
|
|
26631
26666
|
async function defaultLoadValidModules(projectRoot, dataDir) {
|
|
@@ -26721,7 +26756,7 @@ function personalizedPageRank(nodes, edges, options) {
|
|
|
26721
26756
|
|
|
26722
26757
|
// src/gdgraph/repomap.ts
|
|
26723
26758
|
import { mkdir as mkdir24, writeFile as writeFile18 } from "fs/promises";
|
|
26724
|
-
import
|
|
26759
|
+
import path105 from "path";
|
|
26725
26760
|
function estimateTokens2(text) {
|
|
26726
26761
|
return Math.ceil(text.length / 4);
|
|
26727
26762
|
}
|
|
@@ -26752,7 +26787,7 @@ function overflowContent(required, missing, budget) {
|
|
|
26752
26787
|
`);
|
|
26753
26788
|
}
|
|
26754
26789
|
function repomapArtifactPath(cwd) {
|
|
26755
|
-
return
|
|
26790
|
+
return path105.join(cwd, ".metaproject", "data", "gdgraph", "artifacts", "repomap.md");
|
|
26756
26791
|
}
|
|
26757
26792
|
function buildRankEdges(graph, config) {
|
|
26758
26793
|
const edges = [];
|
|
@@ -26889,7 +26924,7 @@ function computeRepomap(graph, config, options = {}) {
|
|
|
26889
26924
|
async function writeRepomap(cwd, graph, config, options = {}) {
|
|
26890
26925
|
const result = computeRepomap(graph, config, options);
|
|
26891
26926
|
const artifactPath = repomapArtifactPath(cwd);
|
|
26892
|
-
await mkdir24(
|
|
26927
|
+
await mkdir24(path105.dirname(artifactPath), { recursive: true });
|
|
26893
26928
|
await writeFile18(artifactPath, result.content, "utf8");
|
|
26894
26929
|
return { ...result, path: artifactPath };
|
|
26895
26930
|
}
|
|
@@ -26909,7 +26944,7 @@ var init_repomap = __esm(() => {
|
|
|
26909
26944
|
// src/gdskills/contracts.ts
|
|
26910
26945
|
import { readFile as readFile62 } from "fs/promises";
|
|
26911
26946
|
import { existsSync as existsSync20 } from "fs";
|
|
26912
|
-
import
|
|
26947
|
+
import path129 from "path";
|
|
26913
26948
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
26914
26949
|
async function loadSchema(name) {
|
|
26915
26950
|
const contract = CONTRACTS.find((entry) => entry.name === name);
|
|
@@ -26920,10 +26955,13 @@ async function loadSchema(name) {
|
|
|
26920
26955
|
return JSON.parse(raw);
|
|
26921
26956
|
}
|
|
26922
26957
|
function contractPath(contract) {
|
|
26923
|
-
|
|
26958
|
+
if (desktopResources !== undefined) {
|
|
26959
|
+
return contract.sourcePath ? path129.join(desktopResources, "review-skills", path129.relative("src/gdskills/bundled/skills", contract.sourcePath)) : path129.join(desktopResources, "review-contracts", contract.fileName);
|
|
26960
|
+
}
|
|
26961
|
+
const here = path129.dirname(fileURLToPath2(import.meta.url));
|
|
26924
26962
|
if (contract.sourcePath) {
|
|
26925
|
-
for (const root of [
|
|
26926
|
-
const candidate =
|
|
26963
|
+
for (const root of [path129.join(here, "..", ".."), path129.join(here, ".."), here]) {
|
|
26964
|
+
const candidate = path129.resolve(root, contract.sourcePath);
|
|
26927
26965
|
if (existsSync20(candidate)) {
|
|
26928
26966
|
return candidate;
|
|
26929
26967
|
}
|
|
@@ -26933,14 +26971,15 @@ function contractPath(contract) {
|
|
|
26933
26971
|
if (existsSync20(directPath)) {
|
|
26934
26972
|
return directPath;
|
|
26935
26973
|
}
|
|
26936
|
-
const packagedSourcePath =
|
|
26974
|
+
const packagedSourcePath = path129.join(here, "..", "src", "gdskills", "contracts", contract.fileName);
|
|
26937
26975
|
if (existsSync20(packagedSourcePath)) {
|
|
26938
26976
|
return packagedSourcePath;
|
|
26939
26977
|
}
|
|
26940
26978
|
return directPath;
|
|
26941
26979
|
}
|
|
26942
|
-
var CONTRACTS, SCHEMA_ROOTS;
|
|
26980
|
+
var CONTRACTS, desktopResources, SCHEMA_ROOTS;
|
|
26943
26981
|
var init_contracts = __esm(() => {
|
|
26982
|
+
init_self_invocation();
|
|
26944
26983
|
CONTRACTS = [
|
|
26945
26984
|
{
|
|
26946
26985
|
name: "agent-event",
|
|
@@ -27063,7 +27102,9 @@ var init_contracts = __esm(() => {
|
|
|
27063
27102
|
}
|
|
27064
27103
|
}
|
|
27065
27104
|
];
|
|
27105
|
+
desktopResources = desktopResourceDirectory();
|
|
27066
27106
|
SCHEMA_ROOTS = [
|
|
27107
|
+
...desktopResources ? [path129.join(desktopResources, "review-contracts"), path129.join(desktopResources, "review-skills/review/review-orchestrator")] : [],
|
|
27067
27108
|
fileURLToPath2(new URL("./contracts/", import.meta.url)),
|
|
27068
27109
|
fileURLToPath2(new URL("./bundled/skills/review/review-orchestrator/", import.meta.url)),
|
|
27069
27110
|
fileURLToPath2(new URL("../src/gdskills/contracts/", import.meta.url)),
|
|
@@ -27075,7 +27116,7 @@ var init_contracts = __esm(() => {
|
|
|
27075
27116
|
import {
|
|
27076
27117
|
appendFileSync,
|
|
27077
27118
|
chmodSync as chmodSync2,
|
|
27078
|
-
closeSync,
|
|
27119
|
+
closeSync as closeSync2,
|
|
27079
27120
|
constants as constants3,
|
|
27080
27121
|
copyFileSync,
|
|
27081
27122
|
fstatSync as fstatSync2,
|
|
@@ -27083,15 +27124,34 @@ import {
|
|
|
27083
27124
|
openSync,
|
|
27084
27125
|
readFileSync as readFileSync12,
|
|
27085
27126
|
renameSync as renameSync3,
|
|
27086
|
-
statSync as
|
|
27127
|
+
statSync as statSync2,
|
|
27087
27128
|
unlinkSync,
|
|
27088
27129
|
writeFileSync as writeFileSync3,
|
|
27089
27130
|
writeSync
|
|
27090
27131
|
} from "fs";
|
|
27132
|
+
import { homedir as homedir2 } from "os";
|
|
27133
|
+
import path132 from "path";
|
|
27134
|
+
function keryxConfigDir(dir) {
|
|
27135
|
+
if (dir !== undefined) {
|
|
27136
|
+
return dir;
|
|
27137
|
+
}
|
|
27138
|
+
const home = homedir2();
|
|
27139
|
+
if (process.platform === "win32") {
|
|
27140
|
+
const appData = process.env.APPDATA;
|
|
27141
|
+
const base = appData !== undefined && appData.length > 0 ? appData : path132.join(home, "AppData", "Roaming");
|
|
27142
|
+
return path132.join(base, "keryx");
|
|
27143
|
+
}
|
|
27144
|
+
const xdg = process.env.XDG_DATA_HOME;
|
|
27145
|
+
const base = xdg !== undefined && xdg.length > 0 ? xdg : path132.join(home, ".local", "share");
|
|
27146
|
+
return path132.join(base, "keryx");
|
|
27147
|
+
}
|
|
27148
|
+
function keryxDataDir(override) {
|
|
27149
|
+
return override || process.env.KERYX_DATA_DIR || keryxConfigDir();
|
|
27150
|
+
}
|
|
27091
27151
|
function readBoundedFile(file, maxBytes) {
|
|
27092
27152
|
let stats;
|
|
27093
27153
|
try {
|
|
27094
|
-
stats =
|
|
27154
|
+
stats = statSync2(file);
|
|
27095
27155
|
} catch {
|
|
27096
27156
|
return { ok: false, reason: "absent" };
|
|
27097
27157
|
}
|
|
@@ -27121,8 +27181,8 @@ var init_config_dir = __esm(() => {
|
|
|
27121
27181
|
|
|
27122
27182
|
// src/session/preservation.ts
|
|
27123
27183
|
import { createHash as createHash23, randomUUID as randomUUID3 } from "crypto";
|
|
27124
|
-
import { closeSync as
|
|
27125
|
-
import
|
|
27184
|
+
import { closeSync as closeSync3, fsyncSync, mkdirSync as mkdirSync3, openSync as openSync2, readdirSync as readdirSync3, readFileSync as readFileSync13, renameSync as renameSync4, unlinkSync as unlinkSync2, writeFileSync as writeFileSync4 } from "fs";
|
|
27185
|
+
import path133 from "path";
|
|
27126
27186
|
function syncDir(dir) {
|
|
27127
27187
|
if (process.platform === "win32")
|
|
27128
27188
|
return;
|
|
@@ -27130,11 +27190,11 @@ function syncDir(dir) {
|
|
|
27130
27190
|
try {
|
|
27131
27191
|
fsyncSync(fd);
|
|
27132
27192
|
} finally {
|
|
27133
|
-
|
|
27193
|
+
closeSync3(fd);
|
|
27134
27194
|
}
|
|
27135
27195
|
}
|
|
27136
27196
|
function writePreservationFile(file, body) {
|
|
27137
|
-
const dir =
|
|
27197
|
+
const dir = path133.dirname(file);
|
|
27138
27198
|
mkdirSync3(dir, { recursive: true, mode: 448 });
|
|
27139
27199
|
const tmp = `${file}.${randomUUID3()}.tmp`;
|
|
27140
27200
|
const fd = openSync2(tmp, "wx", 384);
|
|
@@ -27142,7 +27202,7 @@ function writePreservationFile(file, body) {
|
|
|
27142
27202
|
writeFileSync4(fd, body, "utf8");
|
|
27143
27203
|
fsyncSync(fd);
|
|
27144
27204
|
} finally {
|
|
27145
|
-
|
|
27205
|
+
closeSync3(fd);
|
|
27146
27206
|
}
|
|
27147
27207
|
try {
|
|
27148
27208
|
renameSync4(tmp, file);
|
|
@@ -27159,11 +27219,11 @@ function writePreservationFile(file, body) {
|
|
|
27159
27219
|
}
|
|
27160
27220
|
}
|
|
27161
27221
|
function readPreservation(dir, snapshotId) {
|
|
27162
|
-
const base =
|
|
27222
|
+
const base = path133.join(dir, "preservation");
|
|
27163
27223
|
let id = snapshotId;
|
|
27164
27224
|
if (id === undefined) {
|
|
27165
27225
|
try {
|
|
27166
|
-
id = readFileSync13(
|
|
27226
|
+
id = readFileSync13(path133.join(base, "CURRENT"), "utf8");
|
|
27167
27227
|
} catch (e) {
|
|
27168
27228
|
if (e.code === "ENOENT")
|
|
27169
27229
|
return;
|
|
@@ -27172,7 +27232,7 @@ function readPreservation(dir, snapshotId) {
|
|
|
27172
27232
|
}
|
|
27173
27233
|
if (!/^[a-f0-9]{64}$/.test(id))
|
|
27174
27234
|
throw new Error("invalid preservation identity");
|
|
27175
|
-
const read = readTranscriptFile(
|
|
27235
|
+
const read = readTranscriptFile(path133.join(base, "generations", `${id}.json`));
|
|
27176
27236
|
if (!read.ok)
|
|
27177
27237
|
throw new Error(`snapshot unreadable: ${read.reason}`);
|
|
27178
27238
|
if (hash(read.text) !== id)
|
|
@@ -27190,9 +27250,9 @@ function readPreservation(dir, snapshotId) {
|
|
|
27190
27250
|
return parsed;
|
|
27191
27251
|
}
|
|
27192
27252
|
function readPendingHistory(dir) {
|
|
27193
|
-
let read = readConfigFile(
|
|
27253
|
+
let read = readConfigFile(path133.join(dir, "preservation", "HISTORY"));
|
|
27194
27254
|
if (!read.ok && read.reason === "absent") {
|
|
27195
|
-
read = readConfigFile(
|
|
27255
|
+
read = readConfigFile(path133.join(dir, "preservation", "MIRRORING"));
|
|
27196
27256
|
}
|
|
27197
27257
|
if (!read.ok) {
|
|
27198
27258
|
if (read.reason === "absent")
|
|
@@ -27216,12 +27276,12 @@ var init_preservation = __esm(() => {
|
|
|
27216
27276
|
|
|
27217
27277
|
// src/session/slate.ts
|
|
27218
27278
|
import { mkdir as mkdir33, readFile as readFile66, readdir as readdir23, stat as stat18 } from "fs/promises";
|
|
27219
|
-
import
|
|
27279
|
+
import path138 from "path";
|
|
27220
27280
|
function isSlateSeedKind(value) {
|
|
27221
27281
|
return typeof value === "string" && SLATE_SEED_KINDS.includes(value);
|
|
27222
27282
|
}
|
|
27223
27283
|
function slatePath(dir) {
|
|
27224
|
-
return
|
|
27284
|
+
return path138.join(dir, "slate.json");
|
|
27225
27285
|
}
|
|
27226
27286
|
function slateLockPath(dir) {
|
|
27227
27287
|
return `${slatePath(dir)}.lock`;
|
|
@@ -35174,10 +35234,11 @@ async function gitCommonDir(cwd) {
|
|
|
35174
35234
|
return null;
|
|
35175
35235
|
}
|
|
35176
35236
|
}
|
|
35177
|
-
async function gitToplevel(cwd) {
|
|
35237
|
+
async function gitToplevel(cwd, env) {
|
|
35178
35238
|
try {
|
|
35179
35239
|
const proc = Bun.spawn(["git", "rev-parse", "--show-toplevel"], {
|
|
35180
35240
|
cwd,
|
|
35241
|
+
...env === undefined ? {} : { env },
|
|
35181
35242
|
stdout: "pipe",
|
|
35182
35243
|
stderr: "ignore"
|
|
35183
35244
|
});
|
|
@@ -37288,7 +37349,7 @@ async function acCriterionKnown(input) {
|
|
|
37288
37349
|
init_data_dir();
|
|
37289
37350
|
import { mkdir as mkdir23, readdir as readdir18, readFile as readFile51, writeFile as writeFile17 } from "fs/promises";
|
|
37290
37351
|
import { existsSync as existsSync11 } from "fs";
|
|
37291
|
-
import
|
|
37352
|
+
import path103 from "path";
|
|
37292
37353
|
|
|
37293
37354
|
// src/gdgraph/types.ts
|
|
37294
37355
|
var UNKNOWN_IMPORT_KIND = "unknown-static";
|
|
@@ -37355,7 +37416,7 @@ async function buildGraph(projectRoot, options = {}) {
|
|
|
37355
37416
|
const assetNodes = new Map;
|
|
37356
37417
|
const fileRecords = [];
|
|
37357
37418
|
for (const file of files) {
|
|
37358
|
-
const absolutePath =
|
|
37419
|
+
const absolutePath = path103.join(projectRoot, file);
|
|
37359
37420
|
const content = await readFile51(absolutePath, "utf8");
|
|
37360
37421
|
fileRecords.push({ path: file, content });
|
|
37361
37422
|
const language = getLanguage(file);
|
|
@@ -37408,24 +37469,24 @@ async function collectSourceFiles(projectRoot) {
|
|
|
37408
37469
|
const result = [];
|
|
37409
37470
|
const skippedDirectories = [];
|
|
37410
37471
|
async function walk(relativeDir) {
|
|
37411
|
-
const absoluteDir =
|
|
37472
|
+
const absoluteDir = path103.join(projectRoot, relativeDir);
|
|
37412
37473
|
const entries = await readdir18(absoluteDir, { withFileTypes: true });
|
|
37413
37474
|
for (const entry of entries) {
|
|
37414
37475
|
if (entry.isDirectory()) {
|
|
37415
37476
|
if (IGNORE_DIRS.has(entry.name)) {
|
|
37416
|
-
skippedDirectories.push(normalizePath3(
|
|
37477
|
+
skippedDirectories.push(normalizePath3(path103.posix.join(relativeDir, entry.name)).replace(/^\.\//, ""));
|
|
37417
37478
|
continue;
|
|
37418
37479
|
}
|
|
37419
|
-
await walk(normalizePath3(
|
|
37480
|
+
await walk(normalizePath3(path103.posix.join(relativeDir, entry.name)));
|
|
37420
37481
|
continue;
|
|
37421
37482
|
}
|
|
37422
37483
|
if (!entry.isFile()) {
|
|
37423
37484
|
continue;
|
|
37424
37485
|
}
|
|
37425
|
-
if (!SOURCE_EXTENSIONS.includes(
|
|
37486
|
+
if (!SOURCE_EXTENSIONS.includes(path103.extname(entry.name))) {
|
|
37426
37487
|
continue;
|
|
37427
37488
|
}
|
|
37428
|
-
result.push(normalizePath3(
|
|
37489
|
+
result.push(normalizePath3(path103.posix.join(relativeDir, entry.name)).replace(/^\.\//, ""));
|
|
37429
37490
|
}
|
|
37430
37491
|
}
|
|
37431
37492
|
await walk(".");
|
|
@@ -37507,8 +37568,8 @@ function resolveImport(projectRoot, fromFile, specifier, fileSet, resolver) {
|
|
|
37507
37568
|
}
|
|
37508
37569
|
function resolveAssetImport(projectRoot, fromFile, specifier, resolver) {
|
|
37509
37570
|
for (const candidate of importCandidateBases(projectRoot, fromFile, specifier, resolver)) {
|
|
37510
|
-
const extension =
|
|
37511
|
-
if (ASSET_EXTENSIONS.includes(extension) && existsSync11(
|
|
37571
|
+
const extension = path103.posix.extname(candidate);
|
|
37572
|
+
if (ASSET_EXTENSIONS.includes(extension) && existsSync11(path103.join(projectRoot, candidate))) {
|
|
37512
37573
|
return candidate;
|
|
37513
37574
|
}
|
|
37514
37575
|
}
|
|
@@ -37517,17 +37578,17 @@ function resolveAssetImport(projectRoot, fromFile, specifier, resolver) {
|
|
|
37517
37578
|
function importCandidateBases(projectRoot, fromFile, specifier, resolver) {
|
|
37518
37579
|
const normalizedSpecifier = stripImportSuffix(specifier);
|
|
37519
37580
|
if (normalizedSpecifier.startsWith(".") && getLanguage(fromFile) !== "python") {
|
|
37520
|
-
const fromDir =
|
|
37521
|
-
return [normalizePath3(
|
|
37581
|
+
const fromDir = path103.posix.dirname(fromFile);
|
|
37582
|
+
return [normalizePath3(path103.posix.normalize(path103.posix.join(fromDir, normalizedSpecifier)))];
|
|
37522
37583
|
}
|
|
37523
|
-
return resolver.candidateBases(normalizedSpecifier, fromFile).map((candidate) => normalizePath3(
|
|
37584
|
+
return resolver.candidateBases(normalizedSpecifier, fromFile).map((candidate) => normalizePath3(path103.relative(projectRoot, path103.join(projectRoot, candidate))));
|
|
37524
37585
|
}
|
|
37525
37586
|
function resolveSourceCandidate(base, fileSet) {
|
|
37526
37587
|
const candidates = [
|
|
37527
37588
|
base,
|
|
37528
37589
|
...SOURCE_RESOLUTION_EXTENSIONS.map((extension) => `${base}${extension}`),
|
|
37529
|
-
...SOURCE_RESOLUTION_EXTENSIONS.map((extension) =>
|
|
37530
|
-
|
|
37590
|
+
...SOURCE_RESOLUTION_EXTENSIONS.map((extension) => path103.posix.join(base, `index${extension}`)),
|
|
37591
|
+
path103.posix.join(base, "__init__.py")
|
|
37531
37592
|
];
|
|
37532
37593
|
return candidates.find((candidate) => fileSet.has(candidate)) ?? null;
|
|
37533
37594
|
}
|
|
@@ -37557,7 +37618,7 @@ async function loadJavaResolver(projectRoot) {
|
|
|
37557
37618
|
return createJavaResolver(roots);
|
|
37558
37619
|
}
|
|
37559
37620
|
async function discoverJavaSourceRoots(projectRoot) {
|
|
37560
|
-
const pomPath =
|
|
37621
|
+
const pomPath = path103.join(projectRoot, "pom.xml");
|
|
37561
37622
|
if (existsSync11(pomPath)) {
|
|
37562
37623
|
try {
|
|
37563
37624
|
const roots = parseMavenSourceRoots(await readFile51(pomPath, "utf8"));
|
|
@@ -37567,7 +37628,7 @@ async function discoverJavaSourceRoots(projectRoot) {
|
|
|
37567
37628
|
} catch {}
|
|
37568
37629
|
}
|
|
37569
37630
|
for (const gradleName of ["build.gradle", "build.gradle.kts"]) {
|
|
37570
|
-
const gradlePath =
|
|
37631
|
+
const gradlePath = path103.join(projectRoot, gradleName);
|
|
37571
37632
|
if (existsSync11(gradlePath)) {
|
|
37572
37633
|
try {
|
|
37573
37634
|
const roots = parseGradleSourceRoots(await readFile51(gradlePath, "utf8"));
|
|
@@ -37589,12 +37650,12 @@ function createJavaResolver(sourceRoots) {
|
|
|
37589
37650
|
return [];
|
|
37590
37651
|
}
|
|
37591
37652
|
const relative = specifier.split(".").join("/");
|
|
37592
|
-
return sourceRoots.map((root) => normalizePath3(
|
|
37653
|
+
return sourceRoots.map((root) => normalizePath3(path103.posix.join(root, relative)));
|
|
37593
37654
|
}
|
|
37594
37655
|
};
|
|
37595
37656
|
}
|
|
37596
37657
|
function loadPythonResolver(projectRoot) {
|
|
37597
|
-
const hasSrc = existsSync11(
|
|
37658
|
+
const hasSrc = existsSync11(path103.join(projectRoot, "src"));
|
|
37598
37659
|
return createPythonResolver(hasSrc);
|
|
37599
37660
|
}
|
|
37600
37661
|
function createPythonResolver(hasSrc) {
|
|
@@ -37607,16 +37668,16 @@ function createPythonResolver(hasSrc) {
|
|
|
37607
37668
|
if (specifier.startsWith(".")) {
|
|
37608
37669
|
const dots = /^\.+/.exec(specifier)?.[0].length ?? 0;
|
|
37609
37670
|
const rest = specifier.slice(dots);
|
|
37610
|
-
let baseDir =
|
|
37671
|
+
let baseDir = path103.posix.dirname(fromFile);
|
|
37611
37672
|
for (let level = 1;level < dots; level += 1) {
|
|
37612
|
-
baseDir =
|
|
37673
|
+
baseDir = path103.posix.dirname(baseDir);
|
|
37613
37674
|
}
|
|
37614
37675
|
const suffix = rest ? rest.split(".").join("/") : "";
|
|
37615
|
-
const base = suffix ?
|
|
37676
|
+
const base = suffix ? path103.posix.join(baseDir, suffix) : baseDir;
|
|
37616
37677
|
return [normalizePath3(base)];
|
|
37617
37678
|
}
|
|
37618
37679
|
const relative = specifier.split(".").join("/");
|
|
37619
|
-
return roots.map((root) => normalizePath3(root ?
|
|
37680
|
+
return roots.map((root) => normalizePath3(root ? path103.posix.join(root, relative) : relative));
|
|
37620
37681
|
}
|
|
37621
37682
|
};
|
|
37622
37683
|
}
|
|
@@ -37625,8 +37686,8 @@ function parseMavenSourceRoots(pomXml) {
|
|
|
37625
37686
|
for (const match of pomXml.matchAll(/<module>\s*([^<]+?)\s*<\/module>/g)) {
|
|
37626
37687
|
const moduleDir = match[1]?.trim();
|
|
37627
37688
|
if (moduleDir && !moduleDir.includes("${")) {
|
|
37628
|
-
roots.add(normalizePath3(
|
|
37629
|
-
roots.add(normalizePath3(
|
|
37689
|
+
roots.add(normalizePath3(path103.posix.join(moduleDir, "src/main/java")));
|
|
37690
|
+
roots.add(normalizePath3(path103.posix.join(moduleDir, "src/test/java")));
|
|
37630
37691
|
}
|
|
37631
37692
|
}
|
|
37632
37693
|
for (const tag of ["sourceDirectory", "testSourceDirectory"]) {
|
|
@@ -37659,7 +37720,7 @@ function parseGradleSourceRoots(buildGradle) {
|
|
|
37659
37720
|
var TSCONFIG_EXTENDS_MAX_DEPTH = 10;
|
|
37660
37721
|
async function loadTsconfigResolver(projectRoot) {
|
|
37661
37722
|
const empty = createTsconfigResolver(null, []);
|
|
37662
|
-
const tsconfigPath =
|
|
37723
|
+
const tsconfigPath = path103.join(projectRoot, "tsconfig.json");
|
|
37663
37724
|
if (!existsSync11(tsconfigPath)) {
|
|
37664
37725
|
return empty;
|
|
37665
37726
|
}
|
|
@@ -37672,7 +37733,7 @@ async function loadTsconfigResolver(projectRoot) {
|
|
|
37672
37733
|
return createTsconfigResolver(resolved.baseUrl, paths);
|
|
37673
37734
|
}
|
|
37674
37735
|
function toProjectRelativeDir(projectRoot, absoluteDir) {
|
|
37675
|
-
const relative = normalizePath3(
|
|
37736
|
+
const relative = normalizePath3(path103.relative(projectRoot, absoluteDir)).replace(/^\.\//, "");
|
|
37676
37737
|
return relative === "." ? "" : relative;
|
|
37677
37738
|
}
|
|
37678
37739
|
async function readTsconfigJson(configPath) {
|
|
@@ -37687,11 +37748,11 @@ function resolveTsconfigExtendsPath(configDir, extendsSpecifier) {
|
|
|
37687
37748
|
if (!extendsSpecifier.startsWith(".") && !extendsSpecifier.startsWith("/")) {
|
|
37688
37749
|
return null;
|
|
37689
37750
|
}
|
|
37690
|
-
const resolved =
|
|
37751
|
+
const resolved = path103.resolve(configDir, extendsSpecifier);
|
|
37691
37752
|
return resolved.endsWith(".json") ? resolved : `${resolved}.json`;
|
|
37692
37753
|
}
|
|
37693
37754
|
async function resolveTsconfigOptions(configPath, visited, depth, projectRoot) {
|
|
37694
|
-
const resolvedPath =
|
|
37755
|
+
const resolvedPath = path103.resolve(configPath);
|
|
37695
37756
|
if (depth > TSCONFIG_EXTENDS_MAX_DEPTH || visited.has(resolvedPath)) {
|
|
37696
37757
|
return null;
|
|
37697
37758
|
}
|
|
@@ -37702,15 +37763,15 @@ async function resolveTsconfigOptions(configPath, visited, depth, projectRoot) {
|
|
|
37702
37763
|
}
|
|
37703
37764
|
let inherited = null;
|
|
37704
37765
|
if (typeof parsed.extends === "string") {
|
|
37705
|
-
const basePath = resolveTsconfigExtendsPath(
|
|
37766
|
+
const basePath = resolveTsconfigExtendsPath(path103.dirname(resolvedPath), parsed.extends);
|
|
37706
37767
|
if (basePath) {
|
|
37707
37768
|
inherited = await resolveTsconfigOptions(basePath, visited, depth + 1, projectRoot);
|
|
37708
37769
|
}
|
|
37709
37770
|
}
|
|
37710
|
-
const configDir =
|
|
37771
|
+
const configDir = path103.dirname(resolvedPath);
|
|
37711
37772
|
const declaringDir = toProjectRelativeDir(projectRoot, configDir);
|
|
37712
37773
|
const options = parsed.compilerOptions ?? {};
|
|
37713
|
-
const ownBaseUrl = typeof options.baseUrl === "string" ? toProjectRelativeDir(projectRoot,
|
|
37774
|
+
const ownBaseUrl = typeof options.baseUrl === "string" ? toProjectRelativeDir(projectRoot, path103.resolve(configDir, options.baseUrl)) : null;
|
|
37714
37775
|
const baseUrl = ownBaseUrl ?? inherited?.baseUrl ?? null;
|
|
37715
37776
|
const ownPaths = isRecord5(options.paths) ? Object.entries(options.paths).filter((entry) => Array.isArray(entry[1])).map(([pattern, targets]) => ({
|
|
37716
37777
|
pattern,
|
|
@@ -37739,7 +37800,7 @@ function createTsconfigResolver(baseUrl, mappings) {
|
|
|
37739
37800
|
}
|
|
37740
37801
|
}
|
|
37741
37802
|
if (baseUrl !== null) {
|
|
37742
|
-
candidates.push(normalizePath3(
|
|
37803
|
+
candidates.push(normalizePath3(path103.posix.join(baseUrl, normalizedSpecifier)));
|
|
37743
37804
|
}
|
|
37744
37805
|
return [...new Set(candidates.map((candidate) => candidate.replace(/^\.\//, "")))];
|
|
37745
37806
|
}
|
|
@@ -37759,7 +37820,7 @@ function matchPathPattern(pattern, specifier) {
|
|
|
37759
37820
|
}
|
|
37760
37821
|
function applyPathTarget(base, target, wildcard) {
|
|
37761
37822
|
const replaced = target.includes("*") ? target.replace("*", wildcard) : target;
|
|
37762
|
-
return normalizePath3(
|
|
37823
|
+
return normalizePath3(path103.posix.normalize(path103.posix.join(base, replaced)));
|
|
37763
37824
|
}
|
|
37764
37825
|
function stripJsonComments(source) {
|
|
37765
37826
|
let out = "";
|
|
@@ -37816,13 +37877,13 @@ async function writeGraph(projectRoot, graph, dataDir) {
|
|
|
37816
37877
|
const artifactsDir = gdgraphArtifactsDir(projectRoot, dataDir);
|
|
37817
37878
|
await mkdir23(storageDir, { recursive: true });
|
|
37818
37879
|
await mkdir23(artifactsDir, { recursive: true });
|
|
37819
|
-
await writeFile17(
|
|
37880
|
+
await writeFile17(path103.join(storageDir, "nodes.jsonl"), graph.nodes.map((node) => JSON.stringify(node)).join(`
|
|
37820
37881
|
`) + `
|
|
37821
37882
|
`, "utf8");
|
|
37822
|
-
await writeFile17(
|
|
37883
|
+
await writeFile17(path103.join(storageDir, "edges.jsonl"), graph.edges.map((edge) => JSON.stringify(edge)).join(`
|
|
37823
37884
|
`) + `
|
|
37824
37885
|
`, "utf8");
|
|
37825
|
-
await writeFile17(
|
|
37886
|
+
await writeFile17(path103.join(artifactsDir, "module-map.json"), JSON.stringify(buildModuleMap(graph), null, 2) + `
|
|
37826
37887
|
`, "utf8");
|
|
37827
37888
|
}
|
|
37828
37889
|
async function writeSummary(projectRoot, graph, collection, dataDir) {
|
|
@@ -37841,7 +37902,7 @@ async function writeSummary(projectRoot, graph, collection, dataDir) {
|
|
|
37841
37902
|
`);
|
|
37842
37903
|
const skippedList = collection.skippedDirectories.length > 0 ? collection.skippedDirectories.slice(0, 30).map((dir) => `- \`${dir}\``).join(`
|
|
37843
37904
|
`) : "- none";
|
|
37844
|
-
const summaryPath =
|
|
37905
|
+
const summaryPath = path103.join(artifactsDir, "summary.md");
|
|
37845
37906
|
const content = `# gdgraph Summary
|
|
37846
37907
|
|
|
37847
37908
|
## Stats
|
|
@@ -37922,7 +37983,7 @@ function groupBy(items, getKey) {
|
|
|
37922
37983
|
}
|
|
37923
37984
|
function unresolvedType(specifier) {
|
|
37924
37985
|
const stripped = stripImportSuffix(specifier);
|
|
37925
|
-
const extension =
|
|
37986
|
+
const extension = path103.posix.extname(stripped);
|
|
37926
37987
|
if (extension) {
|
|
37927
37988
|
return extension;
|
|
37928
37989
|
}
|
|
@@ -37932,7 +37993,7 @@ function unresolvedType(specifier) {
|
|
|
37932
37993
|
return "package";
|
|
37933
37994
|
}
|
|
37934
37995
|
function normalizePath3(value) {
|
|
37935
|
-
return value.split(
|
|
37996
|
+
return value.split(path103.sep).join("/");
|
|
37936
37997
|
}
|
|
37937
37998
|
|
|
37938
37999
|
// src/gdgraph/service.ts
|
|
@@ -37941,17 +38002,17 @@ init_config3();
|
|
|
37941
38002
|
|
|
37942
38003
|
// src/gdgraph/query.ts
|
|
37943
38004
|
import { readFile as readFile52 } from "fs/promises";
|
|
37944
|
-
import
|
|
38005
|
+
import path104 from "path";
|
|
37945
38006
|
init_data_dir();
|
|
37946
38007
|
init_target();
|
|
37947
38008
|
async function loadGraph(projectRoot, dataDir) {
|
|
37948
38009
|
const storageDir = gdgraphStorageDir(projectRoot, dataDir);
|
|
37949
|
-
const nodes = await readJsonl(
|
|
37950
|
-
const edges = await readJsonl(
|
|
37951
|
-
const symbols = await readJsonl(
|
|
37952
|
-
const calls = await readJsonl(
|
|
37953
|
-
const wikiPages = await readJsonl(
|
|
37954
|
-
const describes = await readJsonl(
|
|
38010
|
+
const nodes = await readJsonl(path104.join(storageDir, "nodes.jsonl"));
|
|
38011
|
+
const edges = await readJsonl(path104.join(storageDir, "edges.jsonl"));
|
|
38012
|
+
const symbols = await readJsonl(path104.join(storageDir, "symbols.jsonl"));
|
|
38013
|
+
const calls = await readJsonl(path104.join(storageDir, "calls.jsonl"));
|
|
38014
|
+
const wikiPages = await readJsonl(path104.join(storageDir, "wiki-pages.jsonl"));
|
|
38015
|
+
const describes = await readJsonl(path104.join(storageDir, "describes.jsonl"));
|
|
37955
38016
|
const graph = { nodes, edges };
|
|
37956
38017
|
if (symbols.length > 0) {
|
|
37957
38018
|
graph.symbols = symbols;
|
|
@@ -38011,7 +38072,7 @@ async function bunfigPreloadRoots(projectRoot) {
|
|
|
38011
38072
|
const roots = new Set;
|
|
38012
38073
|
let text;
|
|
38013
38074
|
try {
|
|
38014
|
-
text = await readFile52(
|
|
38075
|
+
text = await readFile52(path104.join(projectRoot, "bunfig.toml"), "utf8");
|
|
38015
38076
|
} catch {
|
|
38016
38077
|
return roots;
|
|
38017
38078
|
}
|
|
@@ -38025,8 +38086,8 @@ async function bunfigPreloadRoots(projectRoot) {
|
|
|
38025
38086
|
if (raw.length === 0) {
|
|
38026
38087
|
continue;
|
|
38027
38088
|
}
|
|
38028
|
-
const absolute =
|
|
38029
|
-
const relative =
|
|
38089
|
+
const absolute = path104.resolve(projectRoot, raw);
|
|
38090
|
+
const relative = path104.relative(projectRoot, absolute).split(path104.sep).join("/");
|
|
38030
38091
|
roots.add(relative);
|
|
38031
38092
|
}
|
|
38032
38093
|
}
|
|
@@ -38181,12 +38242,12 @@ init_section_tombstone();
|
|
|
38181
38242
|
// src/forgetting/journal.ts
|
|
38182
38243
|
init_fs();
|
|
38183
38244
|
import { appendFile as appendFile5, mkdir as mkdir25, readFile as readFile53, stat as stat16 } from "fs/promises";
|
|
38184
|
-
import
|
|
38245
|
+
import path106 from "path";
|
|
38185
38246
|
function forgettingDataDir(cwd) {
|
|
38186
|
-
return
|
|
38247
|
+
return path106.join(cwd, ".metaproject", "data", "forgetting");
|
|
38187
38248
|
}
|
|
38188
38249
|
function deletionJournalPath(cwd) {
|
|
38189
|
-
return
|
|
38250
|
+
return path106.join(forgettingDataDir(cwd), "journal.jsonl");
|
|
38190
38251
|
}
|
|
38191
38252
|
async function readDeletionJournal(cwd) {
|
|
38192
38253
|
const file = deletionJournalPath(cwd);
|
|
@@ -38601,12 +38662,12 @@ function createGdgraphService() {
|
|
|
38601
38662
|
// src/health/service.ts
|
|
38602
38663
|
init_fs();
|
|
38603
38664
|
init_json();
|
|
38604
|
-
import
|
|
38665
|
+
import path126 from "path";
|
|
38605
38666
|
|
|
38606
38667
|
// src/health/config.ts
|
|
38607
38668
|
init_fs();
|
|
38608
38669
|
init_json();
|
|
38609
|
-
import
|
|
38670
|
+
import path107 from "path";
|
|
38610
38671
|
var DEFAULT_HEALTH_CONFIG = {
|
|
38611
38672
|
schemaVersion: 2,
|
|
38612
38673
|
ignore: {
|
|
@@ -38663,7 +38724,7 @@ var DEFAULT_HEALTH_CONFIG = {
|
|
|
38663
38724
|
}
|
|
38664
38725
|
};
|
|
38665
38726
|
function configPath2(cwd) {
|
|
38666
|
-
return
|
|
38727
|
+
return path107.join(cwd, ".metaproject", "health.config.json");
|
|
38667
38728
|
}
|
|
38668
38729
|
var STRICTEST_GATE = {
|
|
38669
38730
|
failOnPriorities: ["P0", "P1", "P2", "P3"],
|
|
@@ -38714,7 +38775,7 @@ async function loadHealthConfig(cwd) {
|
|
|
38714
38775
|
// src/health/run.ts
|
|
38715
38776
|
init_fs();
|
|
38716
38777
|
import { mkdir as mkdir29, writeFile as writeFile22 } from "fs/promises";
|
|
38717
|
-
import
|
|
38778
|
+
import path125 from "path";
|
|
38718
38779
|
|
|
38719
38780
|
// src/metrics/provenance.ts
|
|
38720
38781
|
async function collectGitProvenance(cwd) {
|
|
@@ -38827,12 +38888,12 @@ function computeGate2(input) {
|
|
|
38827
38888
|
}
|
|
38828
38889
|
|
|
38829
38890
|
// src/health/scopes.ts
|
|
38830
|
-
import
|
|
38891
|
+
import path110 from "path";
|
|
38831
38892
|
|
|
38832
38893
|
// src/health/util.ts
|
|
38833
38894
|
init_fs();
|
|
38834
38895
|
import { mkdir as mkdir26, readFile as readFile54, readdir as readdir19, writeFile as writeFile19 } from "fs/promises";
|
|
38835
|
-
import
|
|
38896
|
+
import path108 from "path";
|
|
38836
38897
|
var IGNORED_DIRS = new Set([
|
|
38837
38898
|
"node_modules",
|
|
38838
38899
|
".git",
|
|
@@ -38876,14 +38937,14 @@ async function toolVersion(command, cwd) {
|
|
|
38876
38937
|
}
|
|
38877
38938
|
}
|
|
38878
38939
|
function dataRoot3(cwd) {
|
|
38879
|
-
return
|
|
38940
|
+
return path108.join(cwd, ".metaproject", "data", "health");
|
|
38880
38941
|
}
|
|
38881
38942
|
async function writeRaw(cwd, source, content, stamp) {
|
|
38882
|
-
const dir =
|
|
38943
|
+
const dir = path108.join(dataRoot3(cwd), "raw", source);
|
|
38883
38944
|
await mkdir26(dir, { recursive: true });
|
|
38884
|
-
const file =
|
|
38945
|
+
const file = path108.join(dir, `${stamp}.log`);
|
|
38885
38946
|
await writeFile19(file, content, "utf8");
|
|
38886
|
-
return
|
|
38947
|
+
return path108.relative(cwd, file);
|
|
38887
38948
|
}
|
|
38888
38949
|
async function listSourceFiles(cwd, ignorePaths = []) {
|
|
38889
38950
|
const { files } = await listSourceFilesWithReasons(cwd, ignorePaths);
|
|
@@ -38903,7 +38964,7 @@ async function walk2(root, dir, out, incompleteReasons) {
|
|
|
38903
38964
|
try {
|
|
38904
38965
|
entries = await readdir19(dir, { withFileTypes: true });
|
|
38905
38966
|
} catch (error) {
|
|
38906
|
-
incompleteReasons.push(`${
|
|
38967
|
+
incompleteReasons.push(`${path108.relative(root, dir) || "."}: ${error instanceof Error ? error.message : String(error)}`);
|
|
38907
38968
|
return;
|
|
38908
38969
|
}
|
|
38909
38970
|
for (const entry of entries) {
|
|
@@ -38911,14 +38972,14 @@ async function walk2(root, dir, out, incompleteReasons) {
|
|
|
38911
38972
|
if (entry.isDirectory() && !IGNORED_DIRS.has(entry.name)) {}
|
|
38912
38973
|
continue;
|
|
38913
38974
|
}
|
|
38914
|
-
const abs =
|
|
38975
|
+
const abs = path108.join(dir, entry.name);
|
|
38915
38976
|
if (entry.isDirectory()) {
|
|
38916
38977
|
if (IGNORED_DIRS.has(entry.name)) {
|
|
38917
38978
|
continue;
|
|
38918
38979
|
}
|
|
38919
38980
|
await walk2(root, abs, out, incompleteReasons);
|
|
38920
|
-
} else if (entry.isFile() && SOURCE_EXT.has(
|
|
38921
|
-
out.push(
|
|
38981
|
+
} else if (entry.isFile() && SOURCE_EXT.has(path108.extname(entry.name))) {
|
|
38982
|
+
out.push(path108.relative(root, abs));
|
|
38922
38983
|
}
|
|
38923
38984
|
}
|
|
38924
38985
|
}
|
|
@@ -38933,7 +38994,7 @@ function moduleOfFile(file) {
|
|
|
38933
38994
|
return null;
|
|
38934
38995
|
}
|
|
38935
38996
|
function isSourceFile(file) {
|
|
38936
|
-
return SOURCE_EXT.has(
|
|
38997
|
+
return SOURCE_EXT.has(path108.extname(file));
|
|
38937
38998
|
}
|
|
38938
38999
|
function matchesAnyPattern(file, patterns) {
|
|
38939
39000
|
const normalized = file.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
@@ -39035,7 +39096,7 @@ function rankHotspots(files, churn, sourceAnalysis) {
|
|
|
39035
39096
|
// src/health/source-analysis.ts
|
|
39036
39097
|
init_fs();
|
|
39037
39098
|
import { readFile as readFile55 } from "fs/promises";
|
|
39038
|
-
import
|
|
39099
|
+
import path109 from "path";
|
|
39039
39100
|
|
|
39040
39101
|
// src/health/metrics/complexity.ts
|
|
39041
39102
|
var CONTROL_KEYWORDS = new Set([
|
|
@@ -39269,7 +39330,7 @@ async function analyzeSourceFiles(cwd, sourceFiles) {
|
|
|
39269
39330
|
return new Map(entries.filter((entry) => entry !== null));
|
|
39270
39331
|
}
|
|
39271
39332
|
async function analyzeSourceFile(cwd, file) {
|
|
39272
|
-
const abs =
|
|
39333
|
+
const abs = path109.join(cwd, file);
|
|
39273
39334
|
if (!await pathExists(abs)) {
|
|
39274
39335
|
return null;
|
|
39275
39336
|
}
|
|
@@ -39346,14 +39407,14 @@ async function computeMetrics(input) {
|
|
|
39346
39407
|
}
|
|
39347
39408
|
const components = new Map;
|
|
39348
39409
|
for (const file of sourceFiles) {
|
|
39349
|
-
const dir =
|
|
39410
|
+
const dir = path110.posix.dirname(file);
|
|
39350
39411
|
if (dir === "." || dir === moduleOfFile(file)) {
|
|
39351
39412
|
continue;
|
|
39352
39413
|
}
|
|
39353
39414
|
components.set(dir, [...components.get(dir) ?? [], file]);
|
|
39354
39415
|
}
|
|
39355
39416
|
for (const [name, files] of [...components.entries()].sort()) {
|
|
39356
|
-
const compFindings = findings.filter((f) => f.file &&
|
|
39417
|
+
const compFindings = findings.filter((f) => f.file && path110.posix.dirname(f.file) === name);
|
|
39357
39418
|
scopes.push(build("component", `component:${name}`, name, files, compFindings, averageCoverage(files, coverage)));
|
|
39358
39419
|
}
|
|
39359
39420
|
const findingFiles = findings.map((f) => f.file).filter((f) => Boolean(f));
|
|
@@ -39398,7 +39459,7 @@ function tally2(values) {
|
|
|
39398
39459
|
// src/health/baseline.ts
|
|
39399
39460
|
init_fs();
|
|
39400
39461
|
import { mkdir as mkdir27, readFile as readFile56, writeFile as writeFile20 } from "fs/promises";
|
|
39401
|
-
import
|
|
39462
|
+
import path111 from "path";
|
|
39402
39463
|
var LEGACY_BASELINE_SOURCES = Object.freeze([
|
|
39403
39464
|
"complexity",
|
|
39404
39465
|
"coverage",
|
|
@@ -39423,7 +39484,7 @@ function measuredSources(sources) {
|
|
|
39423
39484
|
return sources.filter((s) => s !== null && typeof s === "object").filter((s) => !didNotProduceResult(s)).map((s) => s.source).sort();
|
|
39424
39485
|
}
|
|
39425
39486
|
function baselinePath(cwd) {
|
|
39426
|
-
return
|
|
39487
|
+
return path111.join(cwd, ".metaproject", "health", "baselines", "scores.json");
|
|
39427
39488
|
}
|
|
39428
39489
|
async function readBaselineFile(cwd) {
|
|
39429
39490
|
const file = baselinePath(cwd);
|
|
@@ -39444,7 +39505,7 @@ async function loadBaselineSources(cwd) {
|
|
|
39444
39505
|
}
|
|
39445
39506
|
async function writeBaselineFile(cwd, data) {
|
|
39446
39507
|
const file = baselinePath(cwd);
|
|
39447
|
-
await mkdir27(
|
|
39508
|
+
await mkdir27(path111.dirname(file), { recursive: true });
|
|
39448
39509
|
await writeFile20(file, `${JSON.stringify(data, null, 2)}
|
|
39449
39510
|
`, "utf8");
|
|
39450
39511
|
}
|
|
@@ -39526,10 +39587,10 @@ async function getChurn(cwd, windowDays) {
|
|
|
39526
39587
|
|
|
39527
39588
|
// src/health/metrics/wiki-freshness.ts
|
|
39528
39589
|
import { readFile as readFile57, stat as stat17 } from "fs/promises";
|
|
39529
|
-
import
|
|
39590
|
+
import path112 from "path";
|
|
39530
39591
|
var DEFAULT_STALE_EVIDENCE_DAYS = 7;
|
|
39531
39592
|
function freshnessReportPath(cwd) {
|
|
39532
|
-
return
|
|
39593
|
+
return path112.join(cwd, ".metaproject", "data", "wiki", "freshness", "latest.json");
|
|
39533
39594
|
}
|
|
39534
39595
|
async function readWikiFreshnessMetric(cwd, options = {}) {
|
|
39535
39596
|
const file = freshnessReportPath(cwd);
|
|
@@ -39550,7 +39611,7 @@ async function readWikiFreshnessMetric(cwd, options = {}) {
|
|
|
39550
39611
|
} catch {
|
|
39551
39612
|
return {
|
|
39552
39613
|
status: "unreadable-report",
|
|
39553
|
-
reason: `${
|
|
39614
|
+
reason: `${path112.relative(cwd, file)} is not valid JSON; re-run \`keryx wiki freshness\`.`
|
|
39554
39615
|
};
|
|
39555
39616
|
}
|
|
39556
39617
|
const report = parsed;
|
|
@@ -39560,7 +39621,7 @@ async function readWikiFreshnessMetric(cwd, options = {}) {
|
|
|
39560
39621
|
if (pagesTotal === null || pagesFresh === null) {
|
|
39561
39622
|
return {
|
|
39562
39623
|
status: "unreadable-report",
|
|
39563
|
-
reason: `${
|
|
39624
|
+
reason: `${path112.relative(cwd, file)} is missing its totals; re-run \`keryx wiki freshness\`.`
|
|
39564
39625
|
};
|
|
39565
39626
|
}
|
|
39566
39627
|
const pagesUndecidable = numberOr3(totals.pagesUndecidable) ?? 0;
|
|
@@ -39614,12 +39675,12 @@ function renderWikiFreshnessLine(metric) {
|
|
|
39614
39675
|
}
|
|
39615
39676
|
|
|
39616
39677
|
// src/health/sources/helpers.ts
|
|
39617
|
-
import
|
|
39678
|
+
import path113 from "path";
|
|
39618
39679
|
import { existsSync as existsSync12 } from "fs";
|
|
39619
39680
|
class NoImportError extends Error {
|
|
39620
39681
|
}
|
|
39621
39682
|
function resolveBin(cwd, name) {
|
|
39622
|
-
const local =
|
|
39683
|
+
const local = path113.join(cwd, "node_modules", ".bin", name);
|
|
39623
39684
|
if (existsSync12(local)) {
|
|
39624
39685
|
return local;
|
|
39625
39686
|
}
|
|
@@ -39700,13 +39761,13 @@ async function getComplexityFindings(cwd, sourceFiles, config, sourceAnalysis) {
|
|
|
39700
39761
|
|
|
39701
39762
|
// src/health/metrics/coverage.ts
|
|
39702
39763
|
import { existsSync as existsSync13 } from "fs";
|
|
39703
|
-
import
|
|
39764
|
+
import path114 from "path";
|
|
39704
39765
|
var SUMMARY_PATHS = [
|
|
39705
39766
|
"coverage/coverage-summary.json",
|
|
39706
39767
|
"coverage/coverage-final.json"
|
|
39707
39768
|
];
|
|
39708
39769
|
async function getCoverage(cwd) {
|
|
39709
|
-
const summary = SUMMARY_PATHS.map((rel) =>
|
|
39770
|
+
const summary = SUMMARY_PATHS.map((rel) => path114.join(cwd, rel)).find((abs) => existsSync13(abs));
|
|
39710
39771
|
if (!summary) {
|
|
39711
39772
|
return { status: "missing", total: null, byFile: new Map };
|
|
39712
39773
|
}
|
|
@@ -39727,7 +39788,7 @@ async function getCoverage(cwd) {
|
|
|
39727
39788
|
total = pct;
|
|
39728
39789
|
continue;
|
|
39729
39790
|
}
|
|
39730
|
-
const relative =
|
|
39791
|
+
const relative = path114.isAbsolute(key) ? path114.relative(cwd, key) : key;
|
|
39731
39792
|
byFile.set(relative.replace(/\\/g, "/"), pct);
|
|
39732
39793
|
}
|
|
39733
39794
|
return { status: "available", total, byFile };
|
|
@@ -39860,10 +39921,10 @@ function renderWikiFreshness(metric) {
|
|
|
39860
39921
|
// src/health/skills.ts
|
|
39861
39922
|
init_fs();
|
|
39862
39923
|
import { readFile as readFile58 } from "fs/promises";
|
|
39863
|
-
import
|
|
39924
|
+
import path115 from "path";
|
|
39864
39925
|
var EMPTY = { skills: [], skillForFile: () => null };
|
|
39865
39926
|
async function loadSkillOwnership(cwd) {
|
|
39866
|
-
const manifestPath =
|
|
39927
|
+
const manifestPath = path115.join(cwd, ".metaproject", "metaproject.json");
|
|
39867
39928
|
if (!await pathExists(manifestPath)) {
|
|
39868
39929
|
return EMPTY;
|
|
39869
39930
|
}
|
|
@@ -39901,7 +39962,7 @@ function normalize(value) {
|
|
|
39901
39962
|
|
|
39902
39963
|
// src/health/sources/eslint.ts
|
|
39903
39964
|
import { existsSync as existsSync14 } from "fs";
|
|
39904
|
-
import
|
|
39965
|
+
import path116 from "path";
|
|
39905
39966
|
var CONFIG_FILES = [
|
|
39906
39967
|
".eslintrc",
|
|
39907
39968
|
".eslintrc.js",
|
|
@@ -39915,7 +39976,7 @@ var CONFIG_FILES = [
|
|
|
39915
39976
|
"eslint.config.ts"
|
|
39916
39977
|
];
|
|
39917
39978
|
function hasConfig(cwd) {
|
|
39918
|
-
return CONFIG_FILES.some((file) => existsSync14(
|
|
39979
|
+
return CONFIG_FILES.some((file) => existsSync14(path116.join(cwd, file)));
|
|
39919
39980
|
}
|
|
39920
39981
|
var eslintAdapter = {
|
|
39921
39982
|
id: "eslint",
|
|
@@ -39941,7 +40002,7 @@ var eslintAdapter = {
|
|
|
39941
40002
|
};
|
|
39942
40003
|
},
|
|
39943
40004
|
async import(ctx) {
|
|
39944
|
-
const report =
|
|
40005
|
+
const report = path116.join(ctx.cwd, "eslint-report.json");
|
|
39945
40006
|
if (!existsSync14(report)) {
|
|
39946
40007
|
throw new NoImportError("no eslint-report.json");
|
|
39947
40008
|
}
|
|
@@ -39968,7 +40029,7 @@ var eslintAdapter = {
|
|
|
39968
40029
|
}
|
|
39969
40030
|
const findings = [];
|
|
39970
40031
|
for (const file of data) {
|
|
39971
|
-
const relative =
|
|
40032
|
+
const relative = path116.isAbsolute(file.filePath) ? path116.relative(ctx.cwd, file.filePath) : file.filePath;
|
|
39972
40033
|
for (const message of file.messages ?? []) {
|
|
39973
40034
|
const isError = message.severity === 2;
|
|
39974
40035
|
findings.push(makeFinding({
|
|
@@ -40000,19 +40061,19 @@ var eslintAdapter = {
|
|
|
40000
40061
|
|
|
40001
40062
|
// src/health/sources/oxlint.ts
|
|
40002
40063
|
import { existsSync as existsSync15, readFileSync as readFileSync11 } from "fs";
|
|
40003
|
-
import
|
|
40064
|
+
import path117 from "path";
|
|
40004
40065
|
var CONFIG_FILES2 = [".oxlintrc.json", ".oxlintrc.jsonc"];
|
|
40005
40066
|
var OXLINT_FORMAT = "json";
|
|
40006
40067
|
var OXLINT_PARSE_ERROR = "oxlint JSON format was not recognized";
|
|
40007
40068
|
var OXLINT_NO_FILES = "oxlint found no files to lint (check its paths and ignore patterns)";
|
|
40008
40069
|
var NO_FILES_PREAMBLE = "No files found to lint";
|
|
40009
40070
|
function hasConfigFile(cwd) {
|
|
40010
|
-
if (CONFIG_FILES2.some((file) => existsSync15(
|
|
40071
|
+
if (CONFIG_FILES2.some((file) => existsSync15(path117.join(cwd, file))))
|
|
40011
40072
|
return true;
|
|
40012
|
-
return [".oxlintrc.js", ".oxlintrc.cjs", ".oxlintrc.mjs", ".oxlintrc.ts"].some((file) => existsSync15(
|
|
40073
|
+
return [".oxlintrc.js", ".oxlintrc.cjs", ".oxlintrc.mjs", ".oxlintrc.ts"].some((file) => existsSync15(path117.join(cwd, file)));
|
|
40013
40074
|
}
|
|
40014
40075
|
function packageNamesOxlint(cwd) {
|
|
40015
|
-
const file =
|
|
40076
|
+
const file = path117.join(cwd, "package.json");
|
|
40016
40077
|
if (!existsSync15(file))
|
|
40017
40078
|
return false;
|
|
40018
40079
|
try {
|
|
@@ -40070,7 +40131,7 @@ var oxlintAdapter = {
|
|
|
40070
40131
|
return [];
|
|
40071
40132
|
return data.map((diagnostic) => {
|
|
40072
40133
|
const filePath = diagnostic.filename ?? "";
|
|
40073
|
-
const relative = filePath &&
|
|
40134
|
+
const relative = filePath && path117.isAbsolute(filePath) ? path117.relative(ctx.cwd, filePath) : filePath;
|
|
40074
40135
|
const isError = diagnostic.severity === "error";
|
|
40075
40136
|
return makeFinding({
|
|
40076
40137
|
source: "oxlint",
|
|
@@ -40096,9 +40157,9 @@ var oxlintAdapter = {
|
|
|
40096
40157
|
|
|
40097
40158
|
// src/health/sources/typescript.ts
|
|
40098
40159
|
import { existsSync as existsSync16 } from "fs";
|
|
40099
|
-
import
|
|
40160
|
+
import path118 from "path";
|
|
40100
40161
|
function hasTsconfig(cwd) {
|
|
40101
|
-
return existsSync16(
|
|
40162
|
+
return existsSync16(path118.join(cwd, "tsconfig.json"));
|
|
40102
40163
|
}
|
|
40103
40164
|
var typescriptAdapter = {
|
|
40104
40165
|
id: "typescript",
|
|
@@ -40159,12 +40220,12 @@ init_fs();
|
|
|
40159
40220
|
init_contained_write();
|
|
40160
40221
|
import { existsSync as existsSync17 } from "fs";
|
|
40161
40222
|
import { readFile as readFile61, readdir as readdir20 } from "fs/promises";
|
|
40162
|
-
import
|
|
40223
|
+
import path122 from "path";
|
|
40163
40224
|
// src/metrics/lifecycle.ts
|
|
40164
40225
|
init_fs();
|
|
40165
40226
|
init_guard();
|
|
40166
40227
|
import { readFile as readFile59 } from "fs/promises";
|
|
40167
|
-
import
|
|
40228
|
+
import path119 from "path";
|
|
40168
40229
|
|
|
40169
40230
|
// src/metrics/record.ts
|
|
40170
40231
|
var RELIABILITIES = new Set(["exact", "estimated", "unknown"]);
|
|
@@ -40179,7 +40240,7 @@ var RETRY_TYPES = new Set([
|
|
|
40179
40240
|
|
|
40180
40241
|
// src/metrics/lifecycle.ts
|
|
40181
40242
|
async function readArtifactPointer(root, expected) {
|
|
40182
|
-
const pointerFile =
|
|
40243
|
+
const pointerFile = path119.join(root, "latest.json");
|
|
40183
40244
|
if (!await pathExists(pointerFile))
|
|
40184
40245
|
return { status: "missing", pointer: null };
|
|
40185
40246
|
let pointer;
|
|
@@ -40188,7 +40249,7 @@ async function readArtifactPointer(root, expected) {
|
|
|
40188
40249
|
} catch {
|
|
40189
40250
|
return { status: "stale", pointer: null, reason: "latest pointer is invalid JSON" };
|
|
40190
40251
|
}
|
|
40191
|
-
const recordFile = pointer.record ?
|
|
40252
|
+
const recordFile = pointer.record ? path119.join(root, pointer.record) : null;
|
|
40192
40253
|
if (!recordFile || !isPathInside(root, recordFile) || !await pathExists(recordFile)) {
|
|
40193
40254
|
return { status: "stale", pointer, reason: "pointer record is missing" };
|
|
40194
40255
|
}
|
|
@@ -40204,9 +40265,9 @@ init_guard();
|
|
|
40204
40265
|
// src/testing/capability.ts
|
|
40205
40266
|
init_fs();
|
|
40206
40267
|
init_json();
|
|
40207
|
-
import
|
|
40268
|
+
import path120 from "path";
|
|
40208
40269
|
async function isTestingCapabilityEnabled(cwd, capability) {
|
|
40209
|
-
const manifestPath =
|
|
40270
|
+
const manifestPath = path120.join(cwd, ".metaproject", "metaproject.json");
|
|
40210
40271
|
if (!await pathExists(manifestPath)) {
|
|
40211
40272
|
return false;
|
|
40212
40273
|
}
|
|
@@ -40232,10 +40293,10 @@ async function isTestingCapabilityEnabled(cwd, capability) {
|
|
|
40232
40293
|
init_fs();
|
|
40233
40294
|
init_guard();
|
|
40234
40295
|
import { readFile as readFile60, mkdir as mkdir28, writeFile as writeFile21 } from "fs/promises";
|
|
40235
|
-
import
|
|
40296
|
+
import path121 from "path";
|
|
40236
40297
|
var COVERAGE_MAP_SCHEMA_VERSION = 1;
|
|
40237
40298
|
function coverageMapPath(cwd, cfg) {
|
|
40238
|
-
return
|
|
40299
|
+
return path121.isAbsolute(cfg.coverageMap.artifact) ? cfg.coverageMap.artifact : path121.join(cwd, cfg.coverageMap.artifact);
|
|
40239
40300
|
}
|
|
40240
40301
|
async function loadCoverageMap(cwd, cfg) {
|
|
40241
40302
|
const file = coverageMapPath(cwd, cfg);
|
|
@@ -40370,7 +40431,7 @@ var DEFAULT_TESTING_CONFIG = {
|
|
|
40370
40431
|
}
|
|
40371
40432
|
};
|
|
40372
40433
|
function testingDataRoot(cwd) {
|
|
40373
|
-
return
|
|
40434
|
+
return path122.join(cwd, ".metaproject", "data", "testing");
|
|
40374
40435
|
}
|
|
40375
40436
|
async function computeTestingContext(cwd) {
|
|
40376
40437
|
const { files, incompleteReasons } = await listProjectFiles(cwd);
|
|
@@ -40545,7 +40606,7 @@ async function runTesting(input) {
|
|
|
40545
40606
|
return runResult;
|
|
40546
40607
|
}
|
|
40547
40608
|
async function loadTestingContext(cwd) {
|
|
40548
|
-
const file =
|
|
40609
|
+
const file = path122.join(testingDataRoot(cwd), "context.json");
|
|
40549
40610
|
if (!await pathExists(file)) {
|
|
40550
40611
|
return null;
|
|
40551
40612
|
}
|
|
@@ -40556,18 +40617,18 @@ async function loadTestingContext(cwd) {
|
|
|
40556
40617
|
}
|
|
40557
40618
|
}
|
|
40558
40619
|
async function loadTestingReport(cwd) {
|
|
40559
|
-
const file =
|
|
40620
|
+
const file = path122.join(testingDataRoot(cwd), "artifacts", "latest.json");
|
|
40560
40621
|
if (!await pathExists(file)) {
|
|
40561
40622
|
return null;
|
|
40562
40623
|
}
|
|
40563
40624
|
try {
|
|
40564
40625
|
const latest = JSON.parse(await readFile61(file, "utf8"));
|
|
40565
40626
|
if (typeof latest.record === "string") {
|
|
40566
|
-
const pointer = await readArtifactPointer(
|
|
40627
|
+
const pointer = await readArtifactPointer(path122.join(testingDataRoot(cwd), "artifacts"), await collectGitProvenance(cwd));
|
|
40567
40628
|
if (pointer.status !== "fresh")
|
|
40568
40629
|
return null;
|
|
40569
|
-
const recordFile =
|
|
40570
|
-
if (!isPathInside(
|
|
40630
|
+
const recordFile = path122.join(testingDataRoot(cwd), "artifacts", latest.record);
|
|
40631
|
+
if (!isPathInside(path122.join(testingDataRoot(cwd), "artifacts"), recordFile))
|
|
40571
40632
|
return null;
|
|
40572
40633
|
if (!await pathExists(recordFile))
|
|
40573
40634
|
return null;
|
|
@@ -40614,28 +40675,28 @@ async function ensureContext(cwd) {
|
|
|
40614
40675
|
}
|
|
40615
40676
|
async function writeContext(cwd, context) {
|
|
40616
40677
|
const root = testingDataRoot(cwd);
|
|
40617
|
-
const rel = (p) =>
|
|
40678
|
+
const rel = (p) => path122.relative(cwd, p);
|
|
40618
40679
|
await mkdirContained(cwd, rel(root));
|
|
40619
|
-
await writeContained(cwd, rel(
|
|
40680
|
+
await writeContained(cwd, rel(path122.join(root, "context.json")), `${JSON.stringify(context, null, 2)}
|
|
40620
40681
|
`);
|
|
40621
|
-
await writeContained(cwd, rel(
|
|
40622
|
-
await writeContained(cwd, rel(
|
|
40682
|
+
await writeContained(cwd, rel(path122.join(root, "context.md")), renderContextMarkdown(context));
|
|
40683
|
+
await writeContained(cwd, rel(path122.join(root, "recommendations.md")), renderRecommendationsMarkdown(context));
|
|
40623
40684
|
}
|
|
40624
40685
|
async function writeReport(cwd, report) {
|
|
40625
40686
|
const root = testingDataRoot(cwd);
|
|
40626
|
-
const artifacts =
|
|
40627
|
-
const history =
|
|
40628
|
-
const rel = (p) =>
|
|
40687
|
+
const artifacts = path122.join(root, "artifacts");
|
|
40688
|
+
const history = path122.join(root, "history");
|
|
40689
|
+
const rel = (p) => path122.relative(cwd, p);
|
|
40629
40690
|
await mkdirContained(cwd, rel(artifacts));
|
|
40630
40691
|
await mkdirContained(cwd, rel(history));
|
|
40631
40692
|
const stamp = report.generatedAt.replace(/[:.]/g, "-");
|
|
40632
|
-
const json =
|
|
40633
|
-
const markdown =
|
|
40693
|
+
const json = path122.join(artifacts, "latest.json");
|
|
40694
|
+
const markdown = path122.join(artifacts, "latest.md");
|
|
40634
40695
|
const serialized = `${JSON.stringify(report, null, 2)}
|
|
40635
40696
|
`;
|
|
40636
40697
|
if (report.runId) {
|
|
40637
|
-
const runJson =
|
|
40638
|
-
const runMarkdown =
|
|
40698
|
+
const runJson = path122.join(artifacts, "runs", `${report.runId}.json`);
|
|
40699
|
+
const runMarkdown = path122.join(artifacts, "runs", `${report.runId}.md`);
|
|
40639
40700
|
if (await pathExists(runJson))
|
|
40640
40701
|
throw new Error(`immutable testing run already exists: ${report.runId}`);
|
|
40641
40702
|
await writeContained(cwd, rel(runJson), serialized);
|
|
@@ -40646,26 +40707,26 @@ async function writeReport(cwd, report) {
|
|
|
40646
40707
|
branch: report.provenance?.branch ?? null,
|
|
40647
40708
|
worktree: report.provenance?.worktree ?? null,
|
|
40648
40709
|
generated_at: report.generatedAt,
|
|
40649
|
-
record:
|
|
40710
|
+
record: path122.posix.join("runs", `${report.runId}.json`)
|
|
40650
40711
|
}, null, 2)}
|
|
40651
40712
|
`);
|
|
40652
40713
|
} else {
|
|
40653
40714
|
await writeContained(cwd, rel(json), serialized);
|
|
40654
40715
|
}
|
|
40655
40716
|
await writeContained(cwd, rel(markdown), renderReportMarkdown3(report));
|
|
40656
|
-
await writeContained(cwd, rel(
|
|
40717
|
+
await writeContained(cwd, rel(path122.join(history, `${stamp}.json`)), serialized);
|
|
40657
40718
|
return {
|
|
40658
|
-
markdownPath:
|
|
40659
|
-
jsonPath:
|
|
40719
|
+
markdownPath: path122.relative(cwd, markdown),
|
|
40720
|
+
jsonPath: path122.relative(cwd, json)
|
|
40660
40721
|
};
|
|
40661
40722
|
}
|
|
40662
40723
|
async function writeRawLog(cwd, raw) {
|
|
40663
|
-
const logs =
|
|
40664
|
-
const rel = (p) =>
|
|
40724
|
+
const logs = path122.join(testingDataRoot(cwd), "logs");
|
|
40725
|
+
const rel = (p) => path122.relative(cwd, p);
|
|
40665
40726
|
await mkdirContained(cwd, rel(logs));
|
|
40666
|
-
const latest =
|
|
40727
|
+
const latest = path122.join(logs, "latest.raw.log");
|
|
40667
40728
|
await writeContained(cwd, rel(latest), raw);
|
|
40668
|
-
return
|
|
40729
|
+
return path122.relative(cwd, latest);
|
|
40669
40730
|
}
|
|
40670
40731
|
async function listProjectFiles(cwd) {
|
|
40671
40732
|
const out = [];
|
|
@@ -40678,11 +40739,11 @@ async function walk3(root, dir, out, incompleteReasons) {
|
|
|
40678
40739
|
try {
|
|
40679
40740
|
entries = await readdir20(dir, { withFileTypes: true });
|
|
40680
40741
|
} catch (error) {
|
|
40681
|
-
incompleteReasons.push(`${normalizePath6(
|
|
40742
|
+
incompleteReasons.push(`${normalizePath6(path122.relative(root, dir)) || "."}: ${error instanceof Error ? error.message : String(error)}`);
|
|
40682
40743
|
return;
|
|
40683
40744
|
}
|
|
40684
40745
|
for (const entry of entries) {
|
|
40685
|
-
const abs =
|
|
40746
|
+
const abs = path122.join(dir, entry.name);
|
|
40686
40747
|
if (entry.isDirectory()) {
|
|
40687
40748
|
if (IGNORED_DIRS2.has(entry.name) || entry.name.startsWith(".tmp-")) {
|
|
40688
40749
|
continue;
|
|
@@ -40691,12 +40752,12 @@ async function walk3(root, dir, out, incompleteReasons) {
|
|
|
40691
40752
|
continue;
|
|
40692
40753
|
}
|
|
40693
40754
|
if (entry.isFile()) {
|
|
40694
|
-
out.push(normalizePath6(
|
|
40755
|
+
out.push(normalizePath6(path122.relative(root, abs)));
|
|
40695
40756
|
}
|
|
40696
40757
|
}
|
|
40697
40758
|
}
|
|
40698
40759
|
async function readPackageJson(cwd) {
|
|
40699
|
-
const file =
|
|
40760
|
+
const file = path122.join(cwd, "package.json");
|
|
40700
40761
|
if (!await pathExists(file)) {
|
|
40701
40762
|
return null;
|
|
40702
40763
|
}
|
|
@@ -40707,7 +40768,7 @@ async function readPackageJson(cwd) {
|
|
|
40707
40768
|
}
|
|
40708
40769
|
}
|
|
40709
40770
|
async function loadTestingConfig(cwd) {
|
|
40710
|
-
const file =
|
|
40771
|
+
const file = path122.join(cwd, ".metaproject", "testing.config.json");
|
|
40711
40772
|
if (!await pathExists(file)) {
|
|
40712
40773
|
return DEFAULT_TESTING_CONFIG;
|
|
40713
40774
|
}
|
|
@@ -40772,7 +40833,7 @@ function detectFrameworks(input) {
|
|
|
40772
40833
|
async function extractConventions(cwd, files) {
|
|
40773
40834
|
const conventions = new Set;
|
|
40774
40835
|
for (const file of files.slice(0, 40)) {
|
|
40775
|
-
const abs =
|
|
40836
|
+
const abs = path122.join(cwd, file);
|
|
40776
40837
|
if (!await pathExists(abs)) {
|
|
40777
40838
|
continue;
|
|
40778
40839
|
}
|
|
@@ -40902,7 +40963,7 @@ async function findTestsByImportedTargets(cwd, targets, testFiles) {
|
|
|
40902
40963
|
const targetKeys = new Set(targets.map((target) => modulePathKey(normalizePath6(target))));
|
|
40903
40964
|
const selected = new Set;
|
|
40904
40965
|
for (const testFile of testFiles) {
|
|
40905
|
-
const absoluteTest =
|
|
40966
|
+
const absoluteTest = path122.join(cwd, testFile);
|
|
40906
40967
|
if (!await pathExists(absoluteTest)) {
|
|
40907
40968
|
continue;
|
|
40908
40969
|
}
|
|
@@ -40936,10 +40997,10 @@ function resolveImportPath(cwd, testFile, importPath) {
|
|
|
40936
40997
|
if (!importPath.startsWith(".")) {
|
|
40937
40998
|
return null;
|
|
40938
40999
|
}
|
|
40939
|
-
const importerDir =
|
|
40940
|
-
const absoluteResolved =
|
|
40941
|
-
const relative =
|
|
40942
|
-
if (relative.startsWith(`..${
|
|
41000
|
+
const importerDir = path122.dirname(testFile);
|
|
41001
|
+
const absoluteResolved = path122.resolve(path122.join(cwd, importerDir), importPath);
|
|
41002
|
+
const relative = path122.relative(cwd, absoluteResolved);
|
|
41003
|
+
if (relative.startsWith(`..${path122.sep}`) || relative === "..") {
|
|
40943
41004
|
return null;
|
|
40944
41005
|
}
|
|
40945
41006
|
const relativeNormalized = normalizePath6(relative);
|
|
@@ -40991,13 +41052,13 @@ function resolveTestCommand(cwd, context, input) {
|
|
|
40991
41052
|
}
|
|
40992
41053
|
var BUN_LOCKFILES = ["bun.lock", "bun.lockb"];
|
|
40993
41054
|
function detectPackageManager(cwd) {
|
|
40994
|
-
if (resolveBunBin() && BUN_LOCKFILES.some((name) => pathExistsSync(
|
|
41055
|
+
if (resolveBunBin() && BUN_LOCKFILES.some((name) => pathExistsSync(path122.join(cwd, name)))) {
|
|
40995
41056
|
return "bun";
|
|
40996
41057
|
}
|
|
40997
|
-
if (Bun.which("pnpm") && pathExistsSync(
|
|
41058
|
+
if (Bun.which("pnpm") && pathExistsSync(path122.join(cwd, "pnpm-lock.yaml"))) {
|
|
40998
41059
|
return "pnpm";
|
|
40999
41060
|
}
|
|
41000
|
-
if (Bun.which("yarn") && pathExistsSync(
|
|
41061
|
+
if (Bun.which("yarn") && pathExistsSync(path122.join(cwd, "yarn.lock"))) {
|
|
41001
41062
|
return "yarn";
|
|
41002
41063
|
}
|
|
41003
41064
|
return "npm";
|
|
@@ -41337,7 +41398,7 @@ async function compatibleReportForHealth(ctx) {
|
|
|
41337
41398
|
|
|
41338
41399
|
// src/health/sources/dependency-audit.ts
|
|
41339
41400
|
import { existsSync as existsSync18 } from "fs";
|
|
41340
|
-
import
|
|
41401
|
+
import path123 from "path";
|
|
41341
41402
|
function auditSeverityToPriority(severity) {
|
|
41342
41403
|
if (severity === "critical" || severity === "high")
|
|
41343
41404
|
return "P0";
|
|
@@ -41456,7 +41517,7 @@ var LOCKFILE_COMMANDS = [
|
|
|
41456
41517
|
];
|
|
41457
41518
|
function auditCommand(cwd) {
|
|
41458
41519
|
for (const entry of LOCKFILE_COMMANDS) {
|
|
41459
|
-
if (!entry.lockfiles.some((name) => existsSync18(
|
|
41520
|
+
if (!entry.lockfiles.some((name) => existsSync18(path123.join(cwd, name))))
|
|
41460
41521
|
continue;
|
|
41461
41522
|
const bin = resolveBin(cwd, entry.bin);
|
|
41462
41523
|
if (bin)
|
|
@@ -41515,13 +41576,13 @@ var dependencyAuditAdapter = {
|
|
|
41515
41576
|
|
|
41516
41577
|
// src/health/sources/sonarqube.ts
|
|
41517
41578
|
import { existsSync as existsSync19 } from "fs";
|
|
41518
|
-
import
|
|
41579
|
+
import path124 from "path";
|
|
41519
41580
|
var REPORT_FILES = ["sonar-issues.json", ".metaproject/data/health/sonar-issues.json"];
|
|
41520
41581
|
function reportPath(cwd) {
|
|
41521
41582
|
const fromEnv = process.env.SONAR_ISSUES_FILE;
|
|
41522
41583
|
const candidates = fromEnv ? [fromEnv, ...REPORT_FILES] : REPORT_FILES;
|
|
41523
41584
|
for (const rel of candidates) {
|
|
41524
|
-
const abs =
|
|
41585
|
+
const abs = path124.isAbsolute(rel) ? rel : path124.join(cwd, rel);
|
|
41525
41586
|
if (existsSync19(abs)) {
|
|
41526
41587
|
return abs;
|
|
41527
41588
|
}
|
|
@@ -41605,7 +41666,7 @@ var sonarqubeAdapter = {
|
|
|
41605
41666
|
function relativizeComponent(component, cwd) {
|
|
41606
41667
|
const colon = component.indexOf(":");
|
|
41607
41668
|
const value = colon >= 0 ? component.slice(colon + 1) : component;
|
|
41608
|
-
return
|
|
41669
|
+
return path124.isAbsolute(value) ? path124.relative(cwd, value) : value;
|
|
41609
41670
|
}
|
|
41610
41671
|
|
|
41611
41672
|
// src/health/sources/index.ts
|
|
@@ -41966,19 +42027,19 @@ function filteredInfo(source, cfg) {
|
|
|
41966
42027
|
};
|
|
41967
42028
|
}
|
|
41968
42029
|
async function writeOutputs(cwd, report, config, stamp) {
|
|
41969
|
-
const artifacts =
|
|
41970
|
-
const history =
|
|
42030
|
+
const artifacts = path125.join(dataRoot3(cwd), "artifacts");
|
|
42031
|
+
const history = path125.join(dataRoot3(cwd), "history");
|
|
41971
42032
|
await mkdir29(artifacts, { recursive: true });
|
|
41972
42033
|
await mkdir29(history, { recursive: true });
|
|
41973
|
-
const markdown =
|
|
41974
|
-
const json =
|
|
41975
|
-
const historyJson =
|
|
42034
|
+
const markdown = path125.join(artifacts, "latest.md");
|
|
42035
|
+
const json = path125.join(artifacts, "latest.json");
|
|
42036
|
+
const historyJson = path125.join(history, `${stamp}.json`);
|
|
41976
42037
|
const serialized = `${JSON.stringify(report, null, 2)}
|
|
41977
42038
|
`;
|
|
41978
42039
|
await writeFile22(markdown, renderReportMarkdown2(report, config), "utf8");
|
|
41979
42040
|
if (report.runId) {
|
|
41980
|
-
const runJson =
|
|
41981
|
-
const runMarkdown =
|
|
42041
|
+
const runJson = path125.join(artifacts, "runs", `${report.runId}.json`);
|
|
42042
|
+
const runMarkdown = path125.join(artifacts, "runs", `${report.runId}.md`);
|
|
41982
42043
|
if (await pathExists(runJson))
|
|
41983
42044
|
throw new Error(`immutable health run already exists: ${report.runId}`);
|
|
41984
42045
|
await writeFileAtomic(runJson, serialized);
|
|
@@ -41989,7 +42050,7 @@ async function writeOutputs(cwd, report, config, stamp) {
|
|
|
41989
42050
|
branch: report.provenance?.branch ?? null,
|
|
41990
42051
|
worktree: report.provenance?.worktree ?? null,
|
|
41991
42052
|
generated_at: report.generatedAt,
|
|
41992
|
-
record:
|
|
42053
|
+
record: path125.posix.join("runs", `${report.runId}.json`)
|
|
41993
42054
|
}, null, 2)}
|
|
41994
42055
|
`);
|
|
41995
42056
|
} else {
|
|
@@ -41997,8 +42058,8 @@ async function writeOutputs(cwd, report, config, stamp) {
|
|
|
41997
42058
|
}
|
|
41998
42059
|
await writeFile22(historyJson, serialized, "utf8");
|
|
41999
42060
|
return {
|
|
42000
|
-
markdownPath:
|
|
42001
|
-
jsonPath:
|
|
42061
|
+
markdownPath: path125.relative(cwd, markdown),
|
|
42062
|
+
jsonPath: path125.relative(cwd, json)
|
|
42002
42063
|
};
|
|
42003
42064
|
}
|
|
42004
42065
|
async function resolveChanged(cwd, selector) {
|
|
@@ -42051,7 +42112,7 @@ function hasGateShape(value) {
|
|
|
42051
42112
|
return Array.isArray(report.metrics) && Array.isArray(report.sources) && Array.isArray(report.findings);
|
|
42052
42113
|
}
|
|
42053
42114
|
async function readLatest(cwd) {
|
|
42054
|
-
const file =
|
|
42115
|
+
const file = path126.join(dataRoot3(cwd), "artifacts", "latest.json");
|
|
42055
42116
|
if (!await pathExists(file)) {
|
|
42056
42117
|
return null;
|
|
42057
42118
|
}
|
|
@@ -42062,11 +42123,11 @@ async function readLatest(cwd) {
|
|
|
42062
42123
|
const latest = read.value;
|
|
42063
42124
|
const record = latest.record;
|
|
42064
42125
|
if (typeof record === "string") {
|
|
42065
|
-
const pointer = await readArtifactPointer(
|
|
42126
|
+
const pointer = await readArtifactPointer(path126.join(dataRoot3(cwd), "artifacts"), await collectGitProvenance(cwd));
|
|
42066
42127
|
if (pointer.status !== "fresh")
|
|
42067
42128
|
return null;
|
|
42068
|
-
const recordFile =
|
|
42069
|
-
if (!isPathInside(
|
|
42129
|
+
const recordFile = path126.join(dataRoot3(cwd), "artifacts", record);
|
|
42130
|
+
if (!isPathInside(path126.join(dataRoot3(cwd), "artifacts"), recordFile))
|
|
42070
42131
|
return null;
|
|
42071
42132
|
if (!await pathExists(recordFile))
|
|
42072
42133
|
return null;
|
|
@@ -42139,7 +42200,7 @@ function createCodeHealthService() {
|
|
|
42139
42200
|
return {
|
|
42140
42201
|
run: (input) => runHealth(input),
|
|
42141
42202
|
async status(input) {
|
|
42142
|
-
const enabled = await pathExists(
|
|
42203
|
+
const enabled = await pathExists(path126.join(input.cwd, ".metaproject", "health.config.json"));
|
|
42143
42204
|
const latest = await readLatest(input.cwd);
|
|
42144
42205
|
const project = latest?.metrics.find((m) => m.key === "project") ?? null;
|
|
42145
42206
|
const decliningScopes = latest ? latest.metrics.filter((m) => m.regression_score > 0).length : 0;
|
|
@@ -42296,10 +42357,10 @@ function renderEvidenceBlock(evidences, siblings) {
|
|
|
42296
42357
|
init_fs();
|
|
42297
42358
|
init_contained_write();
|
|
42298
42359
|
init_json();
|
|
42299
|
-
import
|
|
42360
|
+
import path127 from "path";
|
|
42300
42361
|
import { createHash as createHash21 } from "crypto";
|
|
42301
42362
|
function impactEvidenceDataRoot(root) {
|
|
42302
|
-
return
|
|
42363
|
+
return path127.join(root, ".metaproject", "data", "security", "impact-evidence");
|
|
42303
42364
|
}
|
|
42304
42365
|
function sanitizeSessionId(sessionId) {
|
|
42305
42366
|
const cleaned = sessionId.replace(/[^A-Za-z0-9._-]/g, "_");
|
|
@@ -42311,7 +42372,7 @@ function sessionStateFilename(sessionId) {
|
|
|
42311
42372
|
return `${sanitized}-${suffix}.json`;
|
|
42312
42373
|
}
|
|
42313
42374
|
function sessionStatePath(root, sessionId) {
|
|
42314
|
-
return
|
|
42375
|
+
return path127.join(impactEvidenceDataRoot(root), "sessions", sessionStateFilename(sessionId));
|
|
42315
42376
|
}
|
|
42316
42377
|
async function loadSessionState(root, sessionId) {
|
|
42317
42378
|
const file = sessionStatePath(root, sessionId);
|
|
@@ -42330,11 +42391,11 @@ async function loadSessionState(root, sessionId) {
|
|
|
42330
42391
|
}
|
|
42331
42392
|
async function saveSessionState(root, sessionId, state) {
|
|
42332
42393
|
const file = sessionStatePath(root, sessionId);
|
|
42333
|
-
await writeContained(root,
|
|
42394
|
+
await writeContained(root, path127.relative(root, file), `${JSON.stringify(state, null, 2)}
|
|
42334
42395
|
`);
|
|
42335
42396
|
}
|
|
42336
42397
|
function logPath(root) {
|
|
42337
|
-
return
|
|
42398
|
+
return path127.join(impactEvidenceDataRoot(root), "log.jsonl");
|
|
42338
42399
|
}
|
|
42339
42400
|
async function appendLogRecord(root, record) {
|
|
42340
42401
|
const full = {
|
|
@@ -42345,7 +42406,7 @@ async function appendLogRecord(root, record) {
|
|
|
42345
42406
|
...record.detail !== undefined ? { detail: record.detail } : {}
|
|
42346
42407
|
};
|
|
42347
42408
|
const file = logPath(root);
|
|
42348
|
-
await appendContained(root,
|
|
42409
|
+
await appendContained(root, path127.relative(root, file), `${JSON.stringify(full)}
|
|
42349
42410
|
`);
|
|
42350
42411
|
return full;
|
|
42351
42412
|
}
|
|
@@ -42372,7 +42433,7 @@ init_command_risk();
|
|
|
42372
42433
|
init_shell_syntax();
|
|
42373
42434
|
init_fs();
|
|
42374
42435
|
init_service2();
|
|
42375
|
-
import
|
|
42436
|
+
import path128 from "path";
|
|
42376
42437
|
import { createHash as createHash22 } from "crypto";
|
|
42377
42438
|
import { realpathSync as realpathSync2 } from "fs";
|
|
42378
42439
|
function impactEvidenceHookClass(strict) {
|
|
@@ -42388,29 +42449,29 @@ function realpathNearestExisting(p) {
|
|
|
42388
42449
|
for (;; ) {
|
|
42389
42450
|
try {
|
|
42390
42451
|
const real = realpathSync2(current);
|
|
42391
|
-
return tail.length > 0 ?
|
|
42452
|
+
return tail.length > 0 ? path128.join(real, ...tail) : real;
|
|
42392
42453
|
} catch {
|
|
42393
|
-
const parent =
|
|
42454
|
+
const parent = path128.dirname(current);
|
|
42394
42455
|
if (parent === current) {
|
|
42395
|
-
return tail.length > 0 ?
|
|
42456
|
+
return tail.length > 0 ? path128.join(current, ...tail) : current;
|
|
42396
42457
|
}
|
|
42397
|
-
tail.unshift(
|
|
42458
|
+
tail.unshift(path128.basename(current));
|
|
42398
42459
|
current = parent;
|
|
42399
42460
|
}
|
|
42400
42461
|
}
|
|
42401
42462
|
}
|
|
42402
42463
|
function normalizeRequestFiles(root, files) {
|
|
42403
|
-
const rootReal = realpathNearestExisting(
|
|
42464
|
+
const rootReal = realpathNearestExisting(path128.resolve(root));
|
|
42404
42465
|
const normalized = [];
|
|
42405
42466
|
const rejected = [];
|
|
42406
42467
|
for (const file of files) {
|
|
42407
|
-
const lexicalAbsolute =
|
|
42468
|
+
const lexicalAbsolute = path128.isAbsolute(file) ? path128.resolve(file) : path128.resolve(rootReal, toPosix(file).replace(/^\.\//, ""));
|
|
42408
42469
|
const effective = realpathNearestExisting(lexicalAbsolute);
|
|
42409
42470
|
if (!isPathInside(rootReal, effective)) {
|
|
42410
42471
|
rejected.push(file);
|
|
42411
42472
|
continue;
|
|
42412
42473
|
}
|
|
42413
|
-
normalized.push(toPosix(
|
|
42474
|
+
normalized.push(toPosix(path128.relative(rootReal, effective)));
|
|
42414
42475
|
}
|
|
42415
42476
|
return { files: [...new Set(normalized)], rejected };
|
|
42416
42477
|
}
|
|
@@ -42692,7 +42753,7 @@ function hostDeliveryStatus() {
|
|
|
42692
42753
|
// src/job/service.ts
|
|
42693
42754
|
init_fs();
|
|
42694
42755
|
import { copyFile, mkdir as mkdir31 } from "fs/promises";
|
|
42695
|
-
import
|
|
42756
|
+
import path131 from "path";
|
|
42696
42757
|
|
|
42697
42758
|
// src/job/types.ts
|
|
42698
42759
|
var JOB_INTENTS = ["implement", "analyze", "review", "custom"];
|
|
@@ -42833,15 +42894,15 @@ init_validator();
|
|
|
42833
42894
|
init_contracts();
|
|
42834
42895
|
init_fs();
|
|
42835
42896
|
import { appendFile as appendFile6, mkdir as mkdir30, readFile as readFile63, readdir as readdir21 } from "fs/promises";
|
|
42836
|
-
import
|
|
42897
|
+
import path130 from "path";
|
|
42837
42898
|
function jobsRoot(cwd) {
|
|
42838
|
-
return
|
|
42899
|
+
return path130.join(cwd, ".metaproject", "jobs");
|
|
42839
42900
|
}
|
|
42840
42901
|
function jobDir(cwd, name) {
|
|
42841
|
-
return
|
|
42902
|
+
return path130.join(jobsRoot(cwd), name);
|
|
42842
42903
|
}
|
|
42843
42904
|
function jobStatePath(cwd, name) {
|
|
42844
|
-
return
|
|
42905
|
+
return path130.join(jobDir(cwd, name), "state.json");
|
|
42845
42906
|
}
|
|
42846
42907
|
var JOB_NAME_PATTERN = /^[a-z0-9-]+$/;
|
|
42847
42908
|
function assertJobName(name) {
|
|
@@ -42878,12 +42939,12 @@ async function writeJob(cwd, name, state) {
|
|
|
42878
42939
|
`));
|
|
42879
42940
|
}
|
|
42880
42941
|
const file = jobStatePath(cwd, name);
|
|
42881
|
-
await mkdir30(
|
|
42942
|
+
await mkdir30(path130.dirname(file), { recursive: true });
|
|
42882
42943
|
await writeFileAtomic(file, `${JSON.stringify(state, null, 2)}
|
|
42883
42944
|
`);
|
|
42884
42945
|
}
|
|
42885
42946
|
async function appendJournal2(cwd, name, at, line) {
|
|
42886
|
-
await appendFile6(
|
|
42947
|
+
await appendFile6(path130.join(jobDir(cwd, name), "journal.md"), `- ${at} - ${line}
|
|
42887
42948
|
`, "utf8");
|
|
42888
42949
|
}
|
|
42889
42950
|
function renderJournal2(name, at) {
|
|
@@ -42904,7 +42965,7 @@ function assertDocumentType(raw) {
|
|
|
42904
42965
|
return raw;
|
|
42905
42966
|
}
|
|
42906
42967
|
function documentFileName(type, sourcePath) {
|
|
42907
|
-
const extension =
|
|
42968
|
+
const extension = path130.extname(sourcePath) || ".md";
|
|
42908
42969
|
return `${type}${extension}`;
|
|
42909
42970
|
}
|
|
42910
42971
|
|
|
@@ -42912,7 +42973,7 @@ function documentFileName(type, sourcePath) {
|
|
|
42912
42973
|
function createJobService(deps) {
|
|
42913
42974
|
const now = () => deps.now().toISOString();
|
|
42914
42975
|
function lockPath(cwd, name) {
|
|
42915
|
-
return
|
|
42976
|
+
return path131.join(jobsRoot(cwd), `.job-lock-${name}`);
|
|
42916
42977
|
}
|
|
42917
42978
|
async function mutate(cwd, name, run) {
|
|
42918
42979
|
assertJobName(name);
|
|
@@ -42961,20 +43022,20 @@ function createJobService(deps) {
|
|
|
42961
43022
|
},
|
|
42962
43023
|
plan: { steps: defaultPlan(intent) },
|
|
42963
43024
|
documentation: {
|
|
42964
|
-
job_path:
|
|
43025
|
+
job_path: path131.join(".metaproject", "jobs", name),
|
|
42965
43026
|
documents_created: []
|
|
42966
43027
|
},
|
|
42967
43028
|
metrics: { steps: [] },
|
|
42968
|
-
jobs_root:
|
|
43029
|
+
jobs_root: path131.join(".metaproject", "jobs"),
|
|
42969
43030
|
updated_at: createdAt
|
|
42970
43031
|
};
|
|
42971
43032
|
const first = firstOpenStep(state.plan.steps);
|
|
42972
43033
|
if (first) {
|
|
42973
43034
|
state.plan.current_step = first.id;
|
|
42974
43035
|
}
|
|
42975
|
-
await writeFileAtomic(
|
|
43036
|
+
await writeFileAtomic(path131.join(absolute, "journal.md"), renderJournal2(name, createdAt));
|
|
42976
43037
|
await writeJob(input.cwd, name, state);
|
|
42977
|
-
return { state, dir:
|
|
43038
|
+
return { state, dir: path131.relative(input.cwd, absolute) };
|
|
42978
43039
|
},
|
|
42979
43040
|
async status({ cwd, name }) {
|
|
42980
43041
|
assertJobName(name);
|
|
@@ -42986,7 +43047,7 @@ function createJobService(deps) {
|
|
|
42986
43047
|
}
|
|
42987
43048
|
return {
|
|
42988
43049
|
state,
|
|
42989
|
-
dir:
|
|
43050
|
+
dir: path131.join(".metaproject", "jobs", name),
|
|
42990
43051
|
stepsDone: state.plan.steps.filter((step) => isTerminalStep(step.status)).length,
|
|
42991
43052
|
stepsTotal: state.plan.steps.length,
|
|
42992
43053
|
nextStep: firstOpenStep(state.plan.steps),
|
|
@@ -43043,23 +43104,23 @@ function createJobService(deps) {
|
|
|
43043
43104
|
if (!input.file) {
|
|
43044
43105
|
throw new Error("Missing --file. Usage: keryx job document <name> --type <type> --file <path>");
|
|
43045
43106
|
}
|
|
43046
|
-
const source =
|
|
43107
|
+
const source = path131.isAbsolute(input.file) ? input.file : path131.join(input.cwd, input.file);
|
|
43047
43108
|
if (!await pathExists(source)) {
|
|
43048
43109
|
throw new Error(`--file not found: ${input.file}. Write the document first, then record it.`);
|
|
43049
43110
|
}
|
|
43050
43111
|
let recorded;
|
|
43051
43112
|
await mutate(input.cwd, input.name, async (state) => {
|
|
43052
43113
|
const fileName = documentFileName(type, source);
|
|
43053
|
-
const target =
|
|
43114
|
+
const target = path131.join(jobDir(input.cwd, state.job_name), fileName);
|
|
43054
43115
|
await copyFile(source, target);
|
|
43055
43116
|
state.documentation ??= {};
|
|
43056
|
-
state.documentation.job_path ??=
|
|
43117
|
+
state.documentation.job_path ??= path131.join(".metaproject", "jobs", state.job_name);
|
|
43057
43118
|
const created = state.documentation.documents_created ?? [];
|
|
43058
43119
|
state.documentation.documents_created = created.includes(fileName) ? created : [...created, fileName];
|
|
43059
43120
|
recorded = {
|
|
43060
43121
|
state,
|
|
43061
43122
|
document: fileName,
|
|
43062
|
-
path:
|
|
43123
|
+
path: path131.join(".metaproject", "jobs", state.job_name, fileName)
|
|
43063
43124
|
};
|
|
43064
43125
|
return { state, event: "document", detail: `${type} -> ${fileName}` };
|
|
43065
43126
|
});
|
|
@@ -43094,7 +43155,7 @@ function createJobService(deps) {
|
|
|
43094
43155
|
name: state.job_name,
|
|
43095
43156
|
phase: state.phase,
|
|
43096
43157
|
intent: state.intent,
|
|
43097
|
-
dir:
|
|
43158
|
+
dir: path131.join(".metaproject", "jobs", name),
|
|
43098
43159
|
stepsDone: state.plan.steps.filter((step) => isTerminalStep(step.status)).length,
|
|
43099
43160
|
stepsTotal: state.plan.steps.length,
|
|
43100
43161
|
nextStep: firstOpenStep(state.plan.steps)?.id ?? null
|
|
@@ -43115,39 +43176,22 @@ init_fs();
|
|
|
43115
43176
|
init_preservation();
|
|
43116
43177
|
import { randomUUID as randomUUID8 } from "crypto";
|
|
43117
43178
|
import { lstat as lstat10, readdir as readdir26 } from "fs/promises";
|
|
43118
|
-
import
|
|
43179
|
+
import path146 from "path";
|
|
43119
43180
|
|
|
43120
43181
|
// src/session/paths.ts
|
|
43182
|
+
init_config_dir();
|
|
43183
|
+
init_config_dir();
|
|
43121
43184
|
import { existsSync as existsSync21 } from "fs";
|
|
43122
|
-
import
|
|
43123
|
-
import path131 from "path";
|
|
43124
|
-
function keryxDataDir(override) {
|
|
43125
|
-
if (override !== undefined && override.length > 0) {
|
|
43126
|
-
return override;
|
|
43127
|
-
}
|
|
43128
|
-
const env = process.env.KERYX_DATA_DIR;
|
|
43129
|
-
if (env !== undefined && env.length > 0) {
|
|
43130
|
-
return env;
|
|
43131
|
-
}
|
|
43132
|
-
const home = homedir2();
|
|
43133
|
-
if (process.platform === "win32") {
|
|
43134
|
-
const appData = process.env.APPDATA;
|
|
43135
|
-
const base = appData !== undefined && appData.length > 0 ? appData : path131.join(home, "AppData", "Roaming");
|
|
43136
|
-
return path131.join(base, "keryx");
|
|
43137
|
-
}
|
|
43138
|
-
const xdg = process.env.XDG_DATA_HOME;
|
|
43139
|
-
const base = xdg !== undefined && xdg.length > 0 ? xdg : path131.join(home, ".local", "share");
|
|
43140
|
-
return path131.join(base, "keryx");
|
|
43141
|
-
}
|
|
43185
|
+
import path134 from "path";
|
|
43142
43186
|
function resolveProjectRoot2(cwd) {
|
|
43143
|
-
const abs =
|
|
43187
|
+
const abs = path134.resolve(cwd);
|
|
43144
43188
|
let dir = abs;
|
|
43145
43189
|
for (;; ) {
|
|
43146
|
-
const gitPath =
|
|
43190
|
+
const gitPath = path134.join(dir, ".git");
|
|
43147
43191
|
if (existsSync21(gitPath)) {
|
|
43148
43192
|
return dir;
|
|
43149
43193
|
}
|
|
43150
|
-
const parent =
|
|
43194
|
+
const parent = path134.dirname(dir);
|
|
43151
43195
|
if (parent === dir) {
|
|
43152
43196
|
break;
|
|
43153
43197
|
}
|
|
@@ -43156,12 +43200,12 @@ function resolveProjectRoot2(cwd) {
|
|
|
43156
43200
|
return abs;
|
|
43157
43201
|
}
|
|
43158
43202
|
function projectKeyFromPath(projectPath) {
|
|
43159
|
-
const abs =
|
|
43203
|
+
const abs = path134.resolve(projectPath);
|
|
43160
43204
|
const encoded = encodeURIComponent(abs);
|
|
43161
43205
|
if (encoded.length <= 200) {
|
|
43162
43206
|
return encoded;
|
|
43163
43207
|
}
|
|
43164
|
-
const base =
|
|
43208
|
+
const base = path134.basename(abs).replace(/[^a-zA-Z0-9._-]+/g, "_").slice(0, 40);
|
|
43165
43209
|
let h = 0;
|
|
43166
43210
|
for (let i = 0;i < abs.length; i++) {
|
|
43167
43211
|
h = Math.imul(31, h) + abs.charCodeAt(i) | 0;
|
|
@@ -43171,22 +43215,22 @@ function projectKeyFromPath(projectPath) {
|
|
|
43171
43215
|
}
|
|
43172
43216
|
function projectSessionsDir(projectPath, dataDir) {
|
|
43173
43217
|
const key = projectKeyFromPath(resolveProjectRoot2(projectPath));
|
|
43174
|
-
return
|
|
43218
|
+
return path134.join(keryxDataDir(dataDir), "sessions", key);
|
|
43175
43219
|
}
|
|
43176
43220
|
function sessionDir(projectPath, sessionId, dataDir) {
|
|
43177
|
-
return
|
|
43221
|
+
return path134.join(projectSessionsDir(projectPath, dataDir), sessionId);
|
|
43178
43222
|
}
|
|
43179
43223
|
|
|
43180
43224
|
// src/sac/proposal-lifecycle.ts
|
|
43181
43225
|
init_fs();
|
|
43182
43226
|
import { createHash as createHash32, randomUUID as randomUUID7 } from "crypto";
|
|
43183
43227
|
import { appendFile as appendFile7, mkdir as mkdir35, readdir as readdir25, readFile as readFile73 } from "fs/promises";
|
|
43184
|
-
import
|
|
43228
|
+
import path145 from "path";
|
|
43185
43229
|
|
|
43186
43230
|
// src/sac/index.ts
|
|
43187
43231
|
import { access as access3, readFile as readFile64, realpath as realpath14 } from "fs/promises";
|
|
43188
43232
|
import { createHash as createHash24 } from "crypto";
|
|
43189
|
-
import
|
|
43233
|
+
import path135 from "path";
|
|
43190
43234
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
43191
43235
|
|
|
43192
43236
|
// src/sac/workspace-reference.ts
|
|
@@ -43246,21 +43290,21 @@ var normativeSchemaFiles = {
|
|
|
43246
43290
|
"review-decision": "review-decision.schema.json"
|
|
43247
43291
|
};
|
|
43248
43292
|
var normativeSchemas = new Map;
|
|
43249
|
-
var NORMATIVE_SCHEMA_DIR =
|
|
43293
|
+
var NORMATIVE_SCHEMA_DIR = path135.join("docs", "requirements", "shared-agent-context", "schemas");
|
|
43250
43294
|
async function resolveSacNormativeSchemaPath(fileName, searchFrom = [fileURLToPath3(new URL(".", import.meta.url)), process.cwd()]) {
|
|
43251
43295
|
const seen = new Set;
|
|
43252
43296
|
for (const start of searchFrom) {
|
|
43253
|
-
let dir =
|
|
43297
|
+
let dir = path135.resolve(start);
|
|
43254
43298
|
for (let i = 0;i < 10; i++) {
|
|
43255
43299
|
if (seen.has(dir))
|
|
43256
43300
|
break;
|
|
43257
43301
|
seen.add(dir);
|
|
43258
|
-
const candidate =
|
|
43302
|
+
const candidate = path135.join(dir, NORMATIVE_SCHEMA_DIR, fileName);
|
|
43259
43303
|
try {
|
|
43260
43304
|
await access3(candidate);
|
|
43261
43305
|
return candidate;
|
|
43262
43306
|
} catch {}
|
|
43263
|
-
const parent =
|
|
43307
|
+
const parent = path135.dirname(dir);
|
|
43264
43308
|
if (parent === dir)
|
|
43265
43309
|
break;
|
|
43266
43310
|
dir = parent;
|
|
@@ -43929,12 +43973,12 @@ class SacReferenceError extends Error {
|
|
|
43929
43973
|
code = "unsafe_workspace_reference";
|
|
43930
43974
|
}
|
|
43931
43975
|
async function resolveWorkspaceReference(input) {
|
|
43932
|
-
if (!workspacePathPattern.test(input.uri) ||
|
|
43976
|
+
if (!workspacePathPattern.test(input.uri) || path135.isAbsolute(input.uri) || /^[a-z][a-z0-9+.-]*:/i.test(input.uri) || input.uri.includes("\\"))
|
|
43933
43977
|
throw new SacReferenceError("unsafe workspace reference");
|
|
43934
|
-
const lexicalRoot =
|
|
43978
|
+
const lexicalRoot = path135.resolve(input.workspaceRoot);
|
|
43935
43979
|
const root = await realpath14(lexicalRoot);
|
|
43936
|
-
const candidate =
|
|
43937
|
-
if (candidate !== lexicalRoot && !candidate.startsWith(`${lexicalRoot}${
|
|
43980
|
+
const candidate = path135.resolve(lexicalRoot, input.uri.slice(2));
|
|
43981
|
+
if (candidate !== lexicalRoot && !candidate.startsWith(`${lexicalRoot}${path135.sep}`))
|
|
43938
43982
|
throw new SacReferenceError("workspace reference escapes root");
|
|
43939
43983
|
let resolved;
|
|
43940
43984
|
try {
|
|
@@ -43942,7 +43986,7 @@ async function resolveWorkspaceReference(input) {
|
|
|
43942
43986
|
} catch {
|
|
43943
43987
|
throw new SacReferenceError("workspace reference is not resolvable");
|
|
43944
43988
|
}
|
|
43945
|
-
if (resolved !== root && !resolved.startsWith(`${root}${
|
|
43989
|
+
if (resolved !== root && !resolved.startsWith(`${root}${path135.sep}`))
|
|
43946
43990
|
throw new SacReferenceError("workspace reference escapes root after realpath");
|
|
43947
43991
|
return candidate;
|
|
43948
43992
|
}
|
|
@@ -43998,16 +44042,16 @@ async function evaluateStrictSacGuard(input) {
|
|
|
43998
44042
|
init_fs();
|
|
43999
44043
|
import { mkdir as mkdir32, readdir as readdir22, readFile as readFile65 } from "fs/promises";
|
|
44000
44044
|
import { createHash as createHash25, randomUUID as randomUUID4 } from "crypto";
|
|
44001
|
-
import
|
|
44045
|
+
import path137 from "path";
|
|
44002
44046
|
|
|
44003
44047
|
// src/sac/secure-resource-read.ts
|
|
44004
44048
|
init_contained_read();
|
|
44005
44049
|
init_descriptor_read();
|
|
44006
|
-
import
|
|
44050
|
+
import path136 from "path";
|
|
44007
44051
|
function readWorkspaceFileNoFollow(workspaceRoot, absolutePath) {
|
|
44008
|
-
const relativePath =
|
|
44009
|
-
const components = relativePath.split(
|
|
44010
|
-
if (!relativePath ||
|
|
44052
|
+
const relativePath = path136.relative(workspaceRoot, absolutePath);
|
|
44053
|
+
const components = relativePath.split(path136.sep);
|
|
44054
|
+
if (!relativePath || path136.isAbsolute(relativePath) || components.some((component) => !component || component === "." || component === "..")) {
|
|
44011
44055
|
throw new Error("safe source path is not workspace-relative");
|
|
44012
44056
|
}
|
|
44013
44057
|
return readDescriptorChain(workspaceRoot, absolutePath, {
|
|
@@ -44034,8 +44078,8 @@ class WorkspaceService {
|
|
|
44034
44078
|
now;
|
|
44035
44079
|
constructor(options) {
|
|
44036
44080
|
this.options = options;
|
|
44037
|
-
this.root =
|
|
44038
|
-
this.storageRoot =
|
|
44081
|
+
this.root = path137.resolve(options.workspaceRoot);
|
|
44082
|
+
this.storageRoot = path137.resolve(options.storageRoot ?? path137.join(this.root, ".metaproject", "workspaces"));
|
|
44039
44083
|
this.now = options.now ?? (() => new Date);
|
|
44040
44084
|
}
|
|
44041
44085
|
async create(input) {
|
|
@@ -44361,13 +44405,13 @@ class WorkspaceService {
|
|
|
44361
44405
|
return parsed;
|
|
44362
44406
|
}
|
|
44363
44407
|
workspaceDir(id) {
|
|
44364
|
-
return
|
|
44408
|
+
return path137.join(this.storageRoot, id);
|
|
44365
44409
|
}
|
|
44366
44410
|
manifestPath(id) {
|
|
44367
|
-
return
|
|
44411
|
+
return path137.join(this.workspaceDir(id), "workspace.json");
|
|
44368
44412
|
}
|
|
44369
44413
|
lockPath(id) {
|
|
44370
|
-
return
|
|
44414
|
+
return path137.join(this.storageRoot, `.${id}.lock`);
|
|
44371
44415
|
}
|
|
44372
44416
|
timestamp() {
|
|
44373
44417
|
return this.now().toISOString();
|
|
@@ -44486,7 +44530,7 @@ function bindingHash(owner, intent) {
|
|
|
44486
44530
|
// src/sac/session-wrap-up.ts
|
|
44487
44531
|
import { createHash as createHash28 } from "crypto";
|
|
44488
44532
|
import { mkdir as mkdir34, writeFile as writeFile23 } from "fs/promises";
|
|
44489
|
-
import
|
|
44533
|
+
import path140 from "path";
|
|
44490
44534
|
|
|
44491
44535
|
// src/session/store.ts
|
|
44492
44536
|
init_preservation();
|
|
@@ -44499,7 +44543,7 @@ import {
|
|
|
44499
44543
|
renameSync as renameSync5,
|
|
44500
44544
|
writeFileSync as writeFileSync5
|
|
44501
44545
|
} from "fs";
|
|
44502
|
-
import
|
|
44546
|
+
import path139 from "path";
|
|
44503
44547
|
init_slate();
|
|
44504
44548
|
init_redact();
|
|
44505
44549
|
var SESSION_SCHEMA_VERSION = 1;
|
|
@@ -44592,7 +44636,7 @@ function parseRemote(value) {
|
|
|
44592
44636
|
function readSummaryFile(file) {
|
|
44593
44637
|
let pending;
|
|
44594
44638
|
try {
|
|
44595
|
-
pending = readPendingHistory(
|
|
44639
|
+
pending = readPendingHistory(path139.dirname(file));
|
|
44596
44640
|
} catch {
|
|
44597
44641
|
pending = undefined;
|
|
44598
44642
|
}
|
|
@@ -44644,11 +44688,11 @@ class TranscriptUnreadableError extends Error {
|
|
|
44644
44688
|
}
|
|
44645
44689
|
}
|
|
44646
44690
|
function readJsonl2(file) {
|
|
44647
|
-
const pending = readPendingHistory(
|
|
44691
|
+
const pending = readPendingHistory(path139.dirname(file));
|
|
44648
44692
|
if (pending === undefined && !existsSync22(file)) {
|
|
44649
44693
|
return [];
|
|
44650
44694
|
}
|
|
44651
|
-
const read = pending !== undefined ? { ok: true, text: pending.files[
|
|
44695
|
+
const read = pending !== undefined ? { ok: true, text: pending.files[path139.basename(file)] } : readTranscriptFile(file);
|
|
44652
44696
|
if (!read.ok) {
|
|
44653
44697
|
throw new TranscriptUnreadableError(file, read.reason);
|
|
44654
44698
|
}
|
|
@@ -44699,11 +44743,11 @@ function listSessions(cwd, dataDir) {
|
|
|
44699
44743
|
if (name.startsWith(".")) {
|
|
44700
44744
|
continue;
|
|
44701
44745
|
}
|
|
44702
|
-
const summary = readSummaryFile(
|
|
44746
|
+
const summary = readSummaryFile(path139.join(root, name, "summary.json"));
|
|
44703
44747
|
if (summary === undefined) {
|
|
44704
44748
|
continue;
|
|
44705
44749
|
}
|
|
44706
|
-
if (
|
|
44750
|
+
if (path139.resolve(summary.projectPath) !== path139.resolve(projectPath)) {
|
|
44707
44751
|
continue;
|
|
44708
44752
|
}
|
|
44709
44753
|
out.push(summary);
|
|
@@ -44736,15 +44780,15 @@ async function readSessionSlate(cwd, sessionId, dataDir) {
|
|
|
44736
44780
|
}
|
|
44737
44781
|
function loadContext(cwd, sessionId, dataDir) {
|
|
44738
44782
|
const dir = sessionDir(resolveProjectRoot2(cwd), sessionId, dataDir);
|
|
44739
|
-
const contextPath =
|
|
44783
|
+
const contextPath = path139.join(dir, "context.jsonl");
|
|
44740
44784
|
if (readPendingHistory(dir) !== undefined || existsSync22(contextPath)) {
|
|
44741
44785
|
return readJsonl2(contextPath);
|
|
44742
44786
|
}
|
|
44743
|
-
return readJsonl2(
|
|
44787
|
+
return readJsonl2(path139.join(dir, "transcript.jsonl"));
|
|
44744
44788
|
}
|
|
44745
44789
|
function loadArchive(cwd, sessionId, dataDir, onDegraded) {
|
|
44746
44790
|
const dir = sessionDir(resolveProjectRoot2(cwd), sessionId, dataDir);
|
|
44747
|
-
const archivePath =
|
|
44791
|
+
const archivePath = path139.join(dir, "archive.jsonl");
|
|
44748
44792
|
if (readPendingHistory(dir) !== undefined || existsSync22(archivePath)) {
|
|
44749
44793
|
try {
|
|
44750
44794
|
const archive = readJsonl2(archivePath);
|
|
@@ -44819,7 +44863,7 @@ function sessionEvidenceRef(workspaceId, sessionId) {
|
|
|
44819
44863
|
}
|
|
44820
44864
|
async function resolveSessionWrapUp(input) {
|
|
44821
44865
|
const now = input.now ?? (() => new Date);
|
|
44822
|
-
const sessionId =
|
|
44866
|
+
const sessionId = path140.posix.basename(input.sourceRef, ".md");
|
|
44823
44867
|
const summary = findSession(input.cwd, sessionId);
|
|
44824
44868
|
if (summary === undefined || input.sourceRef !== sessionEvidenceRef(input.workspaceId, summary.id)) {
|
|
44825
44869
|
throw new SessionWrapUpError("session_not_found", `no session matching "${input.sourceRef}" in this project \u2014 use \`keryx sessions list\``);
|
|
@@ -44836,7 +44880,7 @@ async function resolveSessionWrapUp(input) {
|
|
|
44836
44880
|
throw new SessionWrapUpError("session_unreadable", `session "${summary.id}" could not be read: ${cause.message}`);
|
|
44837
44881
|
}
|
|
44838
44882
|
const relPath = sessionEvidenceRef(input.workspaceId, summary.id).slice(2);
|
|
44839
|
-
const evidenceDir =
|
|
44883
|
+
const evidenceDir = path140.dirname(relPath);
|
|
44840
44884
|
const slate = await readSessionSlate(input.cwd, summary.id);
|
|
44841
44885
|
const diff = await gitDiff(input.cwd);
|
|
44842
44886
|
const diffBody = diff.kind === "measured" ? diff.text : unmeasurableDiffBody(diff.detail);
|
|
@@ -44858,23 +44902,23 @@ async function resolveSessionWrapUp(input) {
|
|
|
44858
44902
|
""
|
|
44859
44903
|
].join(`
|
|
44860
44904
|
`);
|
|
44861
|
-
const wrapUpRelPath =
|
|
44862
|
-
const diffRelPath =
|
|
44863
|
-
const noticeRelPath =
|
|
44905
|
+
const wrapUpRelPath = path140.join(evidenceDir, `${summary.id}.wrap-up.md`);
|
|
44906
|
+
const diffRelPath = path140.join(evidenceDir, `${summary.id}.diff.txt`);
|
|
44907
|
+
const noticeRelPath = path140.join(evidenceDir, `${summary.id}.redaction.md`);
|
|
44864
44908
|
const floor = await applyEvidenceRedactionFloor(input.cwd, [
|
|
44865
|
-
{ name:
|
|
44866
|
-
{ name:
|
|
44867
|
-
{ name:
|
|
44909
|
+
{ name: path140.basename(relPath), content: markdown, path: relPath, source: "generated" },
|
|
44910
|
+
{ name: path140.basename(wrapUpRelPath), content: wrapUpMarkdown, path: wrapUpRelPath, source: "generated" },
|
|
44911
|
+
{ name: path140.basename(diffRelPath), content: diffBody, path: diffRelPath, source: "tool-output" }
|
|
44868
44912
|
]);
|
|
44869
44913
|
if (!floor.ok)
|
|
44870
44914
|
throw new SessionWrapUpError("security_denied", floor.reason);
|
|
44871
44915
|
const [safeSession, safeWrapUp, safeDiff] = floor.bodies;
|
|
44872
|
-
await mkdir34(
|
|
44873
|
-
await writeFile23(
|
|
44874
|
-
await writeFile23(
|
|
44875
|
-
await writeFile23(
|
|
44916
|
+
await mkdir34(path140.join(input.cwd, evidenceDir), { recursive: true });
|
|
44917
|
+
await writeFile23(path140.join(input.cwd, relPath), safeSession.content, "utf8");
|
|
44918
|
+
await writeFile23(path140.join(input.cwd, wrapUpRelPath), safeWrapUp.content, "utf8");
|
|
44919
|
+
await writeFile23(path140.join(input.cwd, diffRelPath), safeDiff.content, "utf8");
|
|
44876
44920
|
if (floor.notice !== undefined)
|
|
44877
|
-
await writeFile23(
|
|
44921
|
+
await writeFile23(path140.join(input.cwd, noticeRelPath), floor.notice, "utf8");
|
|
44878
44922
|
const observedAt = now().toISOString();
|
|
44879
44923
|
const evidence = [
|
|
44880
44924
|
{ kind: "wrap-up", uri: `./${wrapUpRelPath}`, revision: createHash28("sha256").update(safeWrapUp.content).digest("hex"), observedAt },
|
|
@@ -44897,13 +44941,13 @@ async function resolveSessionWrapUp(input) {
|
|
|
44897
44941
|
init_fs();
|
|
44898
44942
|
import { createHash as createHash29, randomBytes as randomBytes6 } from "crypto";
|
|
44899
44943
|
import { readFile as readFile67 } from "fs/promises";
|
|
44900
|
-
import
|
|
44944
|
+
import path141 from "path";
|
|
44901
44945
|
var CONFIRM_TOKEN_TTL_MS = 2 * 60000;
|
|
44902
44946
|
function confirmTokenPath2(cwd, workspaceId, proposalId) {
|
|
44903
|
-
return
|
|
44947
|
+
return path141.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.confirm-token.json`);
|
|
44904
44948
|
}
|
|
44905
44949
|
function confirmReceiptPath(cwd, workspaceId, proposalId, idempotencyKey) {
|
|
44906
|
-
return
|
|
44950
|
+
return path141.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${sha2563(idempotencyKey)}.confirm-receipt.json`);
|
|
44907
44951
|
}
|
|
44908
44952
|
function sha2563(text) {
|
|
44909
44953
|
return createHash29("sha256").update(text).digest("hex");
|
|
@@ -44944,21 +44988,21 @@ init_store();
|
|
|
44944
44988
|
init_config2();
|
|
44945
44989
|
import { readFile as readFile69, readdir as readdir24 } from "fs/promises";
|
|
44946
44990
|
import { randomUUID as randomUUID6 } from "crypto";
|
|
44947
|
-
import
|
|
44991
|
+
import path143 from "path";
|
|
44948
44992
|
|
|
44949
44993
|
// src/sac/proposal-evidence.ts
|
|
44950
44994
|
init_fs();
|
|
44951
44995
|
import { createHash as createHash30 } from "crypto";
|
|
44952
44996
|
import { readFile as readFile68, rm as rm7 } from "fs/promises";
|
|
44953
|
-
import
|
|
44997
|
+
import path142 from "path";
|
|
44954
44998
|
function proposalPath(cwd, workspaceId, proposalId) {
|
|
44955
|
-
return
|
|
44999
|
+
return path142.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.json`);
|
|
44956
45000
|
}
|
|
44957
45001
|
function ownerReceiptPath(cwd, owner, workspaceId, idempotencyKey) {
|
|
44958
|
-
return
|
|
45002
|
+
return path142.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-write-receipts`, `${idempotencyKey}.json`);
|
|
44959
45003
|
}
|
|
44960
45004
|
function proposalNotePath(cwd, workspaceId, proposalId) {
|
|
44961
|
-
return
|
|
45005
|
+
return path142.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.note.txt`);
|
|
44962
45006
|
}
|
|
44963
45007
|
async function readVerifiedProposalEvidence(cwd, workspaceId, proposalId) {
|
|
44964
45008
|
let proposal;
|
|
@@ -44972,7 +45016,7 @@ async function readVerifiedProposalEvidence(cwd, workspaceId, proposalId) {
|
|
|
44972
45016
|
return { ok: false, code: "no_evidence_to_write" };
|
|
44973
45017
|
let content;
|
|
44974
45018
|
try {
|
|
44975
|
-
content = await readFile68(
|
|
45019
|
+
content = await readFile68(path142.join(cwd, evidence.uri), "utf8");
|
|
44976
45020
|
} catch {
|
|
44977
45021
|
return { ok: false, code: "evidence_file_unreadable" };
|
|
44978
45022
|
}
|
|
@@ -45002,22 +45046,22 @@ function targetRelPath(targetRef) {
|
|
|
45002
45046
|
return targetRef.replace(/^\.\//, "");
|
|
45003
45047
|
}
|
|
45004
45048
|
function targetAbsolutePath(cwd, targetRef) {
|
|
45005
|
-
return
|
|
45049
|
+
return path142.join(cwd, ".metaproject", targetRelPath(targetRef));
|
|
45006
45050
|
}
|
|
45007
45051
|
function targetKey(targetRef) {
|
|
45008
45052
|
return digestOf2(targetRelPath(targetRef)).slice(0, 32);
|
|
45009
45053
|
}
|
|
45010
45054
|
function ownerTargetVersionPath(cwd, owner, workspaceId, targetRef) {
|
|
45011
|
-
return
|
|
45055
|
+
return path142.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-target-versions`, `${targetKey(targetRef)}.json`);
|
|
45012
45056
|
}
|
|
45013
45057
|
function ownerTargetLockPath(cwd, owner, targetRef) {
|
|
45014
|
-
return
|
|
45058
|
+
return path142.join(cwd, ".metaproject", "data", "sac", "target-locks", owner, `${targetKey(targetRef)}.lock`);
|
|
45015
45059
|
}
|
|
45016
45060
|
function ownerStagingDir(cwd, owner, workspaceId, idempotencyKey) {
|
|
45017
|
-
return
|
|
45061
|
+
return path142.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-write-staging`, digestOf2(idempotencyKey).slice(0, 32));
|
|
45018
45062
|
}
|
|
45019
45063
|
function ownerConflictDir(cwd, owner, workspaceId, idempotencyKey) {
|
|
45020
|
-
return
|
|
45064
|
+
return path142.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-write-conflicts`, digestOf2(idempotencyKey).slice(0, 32));
|
|
45021
45065
|
}
|
|
45022
45066
|
async function readJson4(file) {
|
|
45023
45067
|
try {
|
|
@@ -45088,7 +45132,7 @@ async function applyGuardedTargetWrite(input) {
|
|
|
45088
45132
|
staged: input.staged,
|
|
45089
45133
|
stagedAt: receipt.completedAt
|
|
45090
45134
|
};
|
|
45091
|
-
await writeFileAtomic(
|
|
45135
|
+
await writeFileAtomic(path142.join(ownerStagingDir(cwd, owner, intent.workspaceId, intent.idempotencyKey), "plan.json"), `${JSON.stringify(staged, null, 2)}
|
|
45092
45136
|
`);
|
|
45093
45137
|
const applied = await input.apply(input.staged);
|
|
45094
45138
|
if (!applied.ok) {
|
|
@@ -45114,15 +45158,15 @@ async function recoverStagedOwnerWrite(input) {
|
|
|
45114
45158
|
});
|
|
45115
45159
|
}
|
|
45116
45160
|
async function readStagedOwnerWrite(cwd, owner, workspaceId, idempotencyKey) {
|
|
45117
|
-
return readJson4(
|
|
45161
|
+
return readJson4(path142.join(ownerStagingDir(cwd, owner, workspaceId, idempotencyKey), "plan.json"));
|
|
45118
45162
|
}
|
|
45119
45163
|
async function recordConflict(input) {
|
|
45120
45164
|
const base = { targetRef: input.targetRef, expectedVersion: input.expectedVersion, currentVersion: input.currentVersion };
|
|
45121
45165
|
if (input.proposedContent === undefined)
|
|
45122
45166
|
return base;
|
|
45123
45167
|
const dir = ownerConflictDir(input.cwd, input.owner, input.intent.workspaceId, input.intent.idempotencyKey);
|
|
45124
|
-
await writeFileAtomic(
|
|
45125
|
-
const diffRef = `./workspaces/${input.intent.workspaceId}/${input.owner}-write-conflicts/${
|
|
45168
|
+
await writeFileAtomic(path142.join(dir, "proposed"), input.proposedContent);
|
|
45169
|
+
const diffRef = `./workspaces/${input.intent.workspaceId}/${input.owner}-write-conflicts/${path142.basename(dir)}/proposed`;
|
|
45126
45170
|
return { ...base, diffRef };
|
|
45127
45171
|
}
|
|
45128
45172
|
|
|
@@ -45172,7 +45216,7 @@ async function resolveWorkspaceModule(cwd, workspaceId) {
|
|
|
45172
45216
|
}
|
|
45173
45217
|
}
|
|
45174
45218
|
async function collectWikiDecisionEntries(cwd) {
|
|
45175
|
-
const dir =
|
|
45219
|
+
const dir = path143.join(cwd, ".metaproject", "wiki", "decisions");
|
|
45176
45220
|
let files;
|
|
45177
45221
|
try {
|
|
45178
45222
|
files = (await readdir24(dir)).filter((name) => name.endsWith(".md"));
|
|
@@ -45181,12 +45225,12 @@ async function collectWikiDecisionEntries(cwd) {
|
|
|
45181
45225
|
}
|
|
45182
45226
|
const entries = [];
|
|
45183
45227
|
for (const file of files) {
|
|
45184
|
-
const absolutePath =
|
|
45228
|
+
const absolutePath = path143.join(dir, file);
|
|
45185
45229
|
try {
|
|
45186
45230
|
const content = await readFile69(absolutePath, "utf8");
|
|
45187
45231
|
entries.push({
|
|
45188
45232
|
absolutePath,
|
|
45189
|
-
relativePath:
|
|
45233
|
+
relativePath: path143.posix.join("decisions", file),
|
|
45190
45234
|
type: extractHeaderField(content, "Type") ?? "decision",
|
|
45191
45235
|
title: extractTitle(content),
|
|
45192
45236
|
version: extractHeaderField(content, "Version") ?? null,
|
|
@@ -45408,7 +45452,7 @@ function createRealMemoryOwnerWriter(cwd, opts) {
|
|
|
45408
45452
|
init_service4();
|
|
45409
45453
|
init_guard();
|
|
45410
45454
|
import { readFile as readFile71 } from "fs/promises";
|
|
45411
|
-
import
|
|
45455
|
+
import path144 from "path";
|
|
45412
45456
|
function renderWrapUpDecisionPage(input) {
|
|
45413
45457
|
const note = input.note?.trim();
|
|
45414
45458
|
return `# ${input.title}
|
|
@@ -45449,7 +45493,7 @@ export is the source of truth for what actually happened.
|
|
|
45449
45493
|
`;
|
|
45450
45494
|
}
|
|
45451
45495
|
function wikiPageRelativePath(proposalId) {
|
|
45452
|
-
return
|
|
45496
|
+
return path144.posix.join("decisions", `sac-${proposalId}.md`);
|
|
45453
45497
|
}
|
|
45454
45498
|
function createRealWikiOwnerWriter(cwd, opts) {
|
|
45455
45499
|
const now = opts?.now ?? (() => new Date);
|
|
@@ -45457,7 +45501,7 @@ function createRealWikiOwnerWriter(cwd, opts) {
|
|
|
45457
45501
|
const relativePath = staged.relativePath;
|
|
45458
45502
|
const content = staged.content;
|
|
45459
45503
|
const history = await openWikiWriteContext(cwd, "sac proposal accept");
|
|
45460
|
-
await writeWikiPage(history,
|
|
45504
|
+
await writeWikiPage(history, path144.join(cwd, ".metaproject", "wiki", relativePath), content);
|
|
45461
45505
|
return { ok: true };
|
|
45462
45506
|
};
|
|
45463
45507
|
return {
|
|
@@ -45606,7 +45650,7 @@ class ProposalLifecycleService {
|
|
|
45606
45650
|
now;
|
|
45607
45651
|
constructor(options) {
|
|
45608
45652
|
this.options = options;
|
|
45609
|
-
this.root =
|
|
45653
|
+
this.root = path145.resolve(options.workspaceRoot);
|
|
45610
45654
|
this.now = options.now ?? (() => new Date);
|
|
45611
45655
|
}
|
|
45612
45656
|
async create(input) {
|
|
@@ -45626,7 +45670,7 @@ class ProposalLifecycleService {
|
|
|
45626
45670
|
if (manifest.status === "archived")
|
|
45627
45671
|
throw new ProposalLifecycleError("guard_denied", "workspace is archived");
|
|
45628
45672
|
const file = this.proposalPath(workspaceId, proposal.id);
|
|
45629
|
-
await mkdir35(
|
|
45673
|
+
await mkdir35(path145.dirname(file), { recursive: true, mode: 448 });
|
|
45630
45674
|
return withFileLock(`${file}.lock`, async () => {
|
|
45631
45675
|
const consume = this.options.wrapUpAuthority.consume(input.wrapUp, { actor, workspaceId });
|
|
45632
45676
|
if (consume !== "ok")
|
|
@@ -45654,7 +45698,7 @@ class ProposalLifecycleService {
|
|
|
45654
45698
|
return this.options.workspaces.withAuthorizedActor({ actorContext: actor, workspaceId: input.workspaceId, action: "review", execute: async (manifest) => {
|
|
45655
45699
|
const proposal = await this.loadProposal(input.workspaceId, input.proposalId);
|
|
45656
45700
|
const ledger = this.ledgerPath(input.workspaceId);
|
|
45657
|
-
await mkdir35(
|
|
45701
|
+
await mkdir35(path145.dirname(ledger), { recursive: true, mode: 448 });
|
|
45658
45702
|
return withFileLock(`${ledger}.lock`, async () => {
|
|
45659
45703
|
const records = (await this.records(ledger)).filter((record) => record.proposalId === proposal.id);
|
|
45660
45704
|
const events = records.filter((record) => record.recordType === "proposal-transition");
|
|
@@ -45696,7 +45740,7 @@ class ProposalLifecycleService {
|
|
|
45696
45740
|
} });
|
|
45697
45741
|
}
|
|
45698
45742
|
async listProposedProposals(workspaceId) {
|
|
45699
|
-
const proposalsDir =
|
|
45743
|
+
const proposalsDir = path145.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals");
|
|
45700
45744
|
let entries;
|
|
45701
45745
|
try {
|
|
45702
45746
|
entries = (await readdir25(proposalsDir)).filter((name) => name.endsWith(".json"));
|
|
@@ -45708,7 +45752,7 @@ class ProposalLifecycleService {
|
|
|
45708
45752
|
const proposals = [];
|
|
45709
45753
|
for (const entry of entries) {
|
|
45710
45754
|
try {
|
|
45711
|
-
const parsed = JSON.parse(await readFile73(
|
|
45755
|
+
const parsed = JSON.parse(await readFile73(path145.join(proposalsDir, entry), "utf8"));
|
|
45712
45756
|
if (parsed.recordType === "proposal-created")
|
|
45713
45757
|
proposals.push(parsed);
|
|
45714
45758
|
} catch {}
|
|
@@ -45974,31 +46018,31 @@ class ProposalLifecycleService {
|
|
|
45974
46018
|
}
|
|
45975
46019
|
}
|
|
45976
46020
|
proposalPath(workspaceId, proposalId) {
|
|
45977
|
-
return
|
|
46021
|
+
return path145.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.json`);
|
|
45978
46022
|
}
|
|
45979
46023
|
decisionRef(proposalId, key) {
|
|
45980
46024
|
return `./proposals/${proposalId}.${hash2(key)}.decision.json`;
|
|
45981
46025
|
}
|
|
45982
46026
|
decisionPath(workspaceId, proposalId, key) {
|
|
45983
|
-
return
|
|
46027
|
+
return path145.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.decision.json`);
|
|
45984
46028
|
}
|
|
45985
46029
|
approvalRef(proposalId, key) {
|
|
45986
46030
|
return `./proposals/${proposalId}.${hash2(key)}.approval.json`;
|
|
45987
46031
|
}
|
|
45988
46032
|
approvalPath(workspaceId, proposalId, key) {
|
|
45989
|
-
return
|
|
46033
|
+
return path145.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.approval.json`);
|
|
45990
46034
|
}
|
|
45991
46035
|
writeResultPath(workspaceId, proposalId, key) {
|
|
45992
|
-
return
|
|
46036
|
+
return path145.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.write-result.json`);
|
|
45993
46037
|
}
|
|
45994
46038
|
intentRef(proposalId, key) {
|
|
45995
46039
|
return `./proposals/${proposalId}.${hash2(key)}.write-intent.json`;
|
|
45996
46040
|
}
|
|
45997
46041
|
intentPath(workspaceId, proposalId, key) {
|
|
45998
|
-
return
|
|
46042
|
+
return path145.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.write-intent.json`);
|
|
45999
46043
|
}
|
|
46000
46044
|
attemptPath(workspaceId, proposalId, key) {
|
|
46001
|
-
return
|
|
46045
|
+
return path145.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.owner-write-attempt.json`);
|
|
46002
46046
|
}
|
|
46003
46047
|
async loadWriteResult(workspaceId, proposalId, key) {
|
|
46004
46048
|
try {
|
|
@@ -46025,7 +46069,7 @@ class ProposalLifecycleService {
|
|
|
46025
46069
|
}
|
|
46026
46070
|
}
|
|
46027
46071
|
ledgerPath(workspaceId) {
|
|
46028
|
-
return
|
|
46072
|
+
return path145.join(this.root, ".metaproject", "workspaces", workspaceId, "activity.jsonl");
|
|
46029
46073
|
}
|
|
46030
46074
|
timestamp() {
|
|
46031
46075
|
return this.now().toISOString();
|
|
@@ -46144,11 +46188,11 @@ async function replayPreservation(input) {
|
|
|
46144
46188
|
if (typeof slate.workspaceId !== "string" || !/^[a-z][a-z0-9-]{2,63}$/.test(slate.workspaceId))
|
|
46145
46189
|
throw new Error("invalid workspace identity");
|
|
46146
46190
|
const workspaceId = slate.workspaceId;
|
|
46147
|
-
const outbox =
|
|
46148
|
-
const receipt = await readReplayJson(
|
|
46191
|
+
const outbox = path146.join(input.dir, "preservation", "outbox");
|
|
46192
|
+
const receipt = await readReplayJson(path146.join(outbox, `${input.snapshot}.json`));
|
|
46149
46193
|
if (receipt.version !== 1 || receipt.snapshot !== input.snapshot || receipt.state !== "pending-review")
|
|
46150
46194
|
throw new Error("invalid outbox receipt");
|
|
46151
|
-
return withFileLock(
|
|
46195
|
+
return withFileLock(path146.join(outbox, `${input.snapshot}.delivery.lock`), async () => {
|
|
46152
46196
|
input.signal?.throwIfAborted();
|
|
46153
46197
|
const { service, wrapUpAuthority, authorizationServer } = createHarnessProposalLifecycleService(input.cwd, {
|
|
46154
46198
|
workspaceId,
|
|
@@ -46175,12 +46219,12 @@ async function replayPreservation(input) {
|
|
|
46175
46219
|
} catch (error) {
|
|
46176
46220
|
if (!(error instanceof ProposalLifecycleError) || error.code !== "conflict")
|
|
46177
46221
|
throw error;
|
|
46178
|
-
const existing = await readReplayJson(
|
|
46222
|
+
const existing = await readReplayJson(path146.join(input.cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${id}.json`));
|
|
46179
46223
|
const refs = (evidence) => evidence.map((e) => [e.uri, e.revision]);
|
|
46180
46224
|
if (existing.workspaceId !== workspaceId || existing.author !== actor.subject || existing.kind !== "follow-up" || existing.proposalRevision !== input.snapshot || existing.wrapUp?.sourceRef !== sourceRef || existing.wrapUp?.sourceRevision !== wrapUp.sourceRevision || JSON.stringify(refs(existing.evidence)) !== JSON.stringify(refs(wrapUp.evidence)))
|
|
46181
46225
|
throw new Error("delivery conflict mismatch", { cause: error });
|
|
46182
46226
|
}
|
|
46183
|
-
const delivered =
|
|
46227
|
+
const delivered = path146.join(outbox, `${input.snapshot}.delivered`);
|
|
46184
46228
|
try {
|
|
46185
46229
|
const marker = await readReplayJson(delivered);
|
|
46186
46230
|
if (marker.version !== 1 || marker.workspaceId !== workspaceId || marker.proposalId !== id || marker.snapshot !== input.snapshot) {
|
|
@@ -46193,7 +46237,7 @@ async function replayPreservation(input) {
|
|
|
46193
46237
|
}
|
|
46194
46238
|
input.afterCreate?.();
|
|
46195
46239
|
input.signal?.throwIfAborted();
|
|
46196
|
-
writePreservationFile(
|
|
46240
|
+
writePreservationFile(path146.join(outbox, `${input.snapshot}.delivered`), JSON.stringify({ version: 1, workspaceId, proposalId: id, snapshot: input.snapshot }));
|
|
46197
46241
|
return "proposed";
|
|
46198
46242
|
}, input.signal ? { signal: input.signal } : {});
|
|
46199
46243
|
}
|
|
@@ -46216,14 +46260,14 @@ async function scanPreservationOutbox(input) {
|
|
|
46216
46260
|
const result = { proposed: 0, deferred: 0, unbound: 0 };
|
|
46217
46261
|
let entries;
|
|
46218
46262
|
try {
|
|
46219
|
-
entries = await readdir26(
|
|
46263
|
+
entries = await readdir26(path146.join(input.dir, "preservation", "outbox"));
|
|
46220
46264
|
} catch (error) {
|
|
46221
46265
|
if (error.code === "ENOENT")
|
|
46222
46266
|
return result;
|
|
46223
46267
|
throw error;
|
|
46224
46268
|
}
|
|
46225
46269
|
let attempted = 0;
|
|
46226
|
-
const cursorFile =
|
|
46270
|
+
const cursorFile = path146.join(input.dir, "preservation", "outbox", "SCAN_CURSOR");
|
|
46227
46271
|
for (const entry of resumeScan(entries.filter((name) => /^[a-f0-9]{64}\.json$/.test(name)), cursorFile)) {
|
|
46228
46272
|
if (input.signal?.aborted || Date.now() >= (input.deadline ?? Infinity) || attempted >= (input.maxItems ?? 8))
|
|
46229
46273
|
break;
|
|
@@ -46248,11 +46292,11 @@ async function replayProjectPreservationOutboxes(input) {
|
|
|
46248
46292
|
return boundedReplay(input, scanProjectPreservationOutboxes);
|
|
46249
46293
|
}
|
|
46250
46294
|
async function retryProjectPreservation(cwd) {
|
|
46251
|
-
return replayProjectPreservationOutboxes({ cwd, dir:
|
|
46295
|
+
return replayProjectPreservationOutboxes({ cwd, dir: path146.join(projectSessionsDir(cwd), ".explicit-retry") });
|
|
46252
46296
|
}
|
|
46253
46297
|
async function scanProjectPreservationOutboxes(input) {
|
|
46254
46298
|
const result = { proposed: 0, deferred: 0, unbound: 0 };
|
|
46255
|
-
const root =
|
|
46299
|
+
const root = path146.dirname(input.dir);
|
|
46256
46300
|
let entries;
|
|
46257
46301
|
try {
|
|
46258
46302
|
entries = await readdir26(root, { withFileTypes: true });
|
|
@@ -46263,7 +46307,7 @@ async function scanProjectPreservationOutboxes(input) {
|
|
|
46263
46307
|
}
|
|
46264
46308
|
const deadline = input.deadline ?? Date.now() + 2000;
|
|
46265
46309
|
let scanned = 0;
|
|
46266
|
-
const cursorFile =
|
|
46310
|
+
const cursorFile = path146.join(root, ".preservation-replay-cursor");
|
|
46267
46311
|
const candidates = entries.filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => entry.name);
|
|
46268
46312
|
for (const name of resumeScan(candidates, cursorFile)) {
|
|
46269
46313
|
if (input.signal?.aborted || Date.now() >= deadline || scanned >= 32)
|
|
@@ -46272,7 +46316,7 @@ async function scanProjectPreservationOutboxes(input) {
|
|
|
46272
46316
|
recordScanCursor(cursorFile, name);
|
|
46273
46317
|
scanned++;
|
|
46274
46318
|
try {
|
|
46275
|
-
const replay = await replayPreservationOutbox({ ...input, deadline, maxItems: 1, dir:
|
|
46319
|
+
const replay = await replayPreservationOutbox({ ...input, deadline, maxItems: 1, dir: path146.join(root, name) });
|
|
46276
46320
|
result.proposed += replay.proposed;
|
|
46277
46321
|
result.deferred += replay.deferred;
|
|
46278
46322
|
result.unbound += replay.unbound;
|
|
@@ -46311,7 +46355,7 @@ async function boundedReplay(input, scan) {
|
|
|
46311
46355
|
import { createHash as createHash35, randomUUID as randomUUID9 } from "crypto";
|
|
46312
46356
|
init_assembly();
|
|
46313
46357
|
import { appendFile as appendFile8, mkdir as mkdir36, open as open5, readFile as readFile74, rename as rename7, rm as rm8, stat as stat19, writeFile as writeFile24 } from "fs/promises";
|
|
46314
|
-
import
|
|
46358
|
+
import path147 from "path";
|
|
46315
46359
|
init_fs();
|
|
46316
46360
|
|
|
46317
46361
|
// src/sac/policy-experiment.ts
|
|
@@ -47054,7 +47098,7 @@ function hasReportIntegrity(report) {
|
|
|
47054
47098
|
return reportHashPattern.test(reportDigest) && sha2566(body) === reportDigest;
|
|
47055
47099
|
}
|
|
47056
47100
|
async function resolvePolicySelection(workspaceRoot, canonicalFallback) {
|
|
47057
|
-
const configPath =
|
|
47101
|
+
const configPath = path147.join(workspaceRoot, ...policyExperimentConfigPath);
|
|
47058
47102
|
let configJson;
|
|
47059
47103
|
try {
|
|
47060
47104
|
const raw = await readFile74(configPath, "utf8").catch((error) => {
|
|
@@ -47252,9 +47296,9 @@ class FwkReadService {
|
|
|
47252
47296
|
const recordedAt = nowIso2(now);
|
|
47253
47297
|
const id = `receipt-${randomUUID9().replace(/-/g, "").slice(0, 16)}`;
|
|
47254
47298
|
const base = { schemaVersion: "1.0", id, workspaceId, actor, action, decision, recordedAt, cost: { tokens: 0, toolCalls: 1, elapsedMs: 0 }, contextAssembly: { traceRef: assembly.traceRef, configurationRevision: assembly.configurationRevision, selected: assembly.selected.map((id) => `./ids/${id}`), omittedOptional: assembly.omittedOptional.map((id) => `./ids/${id}`) }, policy: { ref: assembly.policyRef, revision: assembly.policyRevision }, ...action === "resource" ? { resourceRef: `./ids/${resourceId ?? "unknown"}` } : {} };
|
|
47255
|
-
const ledger =
|
|
47256
|
-
const checkpointPath =
|
|
47257
|
-
await mkdir36(
|
|
47299
|
+
const ledger = path147.join(this.options.canonical.workspaceRoot, ".metaproject", "context-operations", "access-receipts.jsonl");
|
|
47300
|
+
const checkpointPath = path147.join(path147.dirname(ledger), "access-receipts.checkpoint.json");
|
|
47301
|
+
await mkdir36(path147.dirname(ledger), { recursive: true, mode: 448 });
|
|
47258
47302
|
return withFileLock(`${ledger}.lock`, async () => {
|
|
47259
47303
|
const state = await resolveLedgerState(ledger, checkpointPath, this.options.verifyReceiptLedger ?? verifyAccessReceiptLedger);
|
|
47260
47304
|
const receipt = sealAccessReceipt(base, state.headHash);
|
|
@@ -47392,7 +47436,7 @@ async function proposeFromSession(input) {
|
|
|
47392
47436
|
// src/sac/collaboration-service.ts
|
|
47393
47437
|
import { appendFile as appendFile9, mkdir as mkdir37, readFile as readFile75 } from "fs/promises";
|
|
47394
47438
|
import { randomUUID as randomUUID11 } from "crypto";
|
|
47395
|
-
import
|
|
47439
|
+
import path148 from "path";
|
|
47396
47440
|
class CollaborationServiceError extends Error {
|
|
47397
47441
|
code;
|
|
47398
47442
|
constructor(code, message) {
|
|
@@ -47407,7 +47451,7 @@ class CollaborationService {
|
|
|
47407
47451
|
this.input = input;
|
|
47408
47452
|
}
|
|
47409
47453
|
file(id) {
|
|
47410
|
-
return
|
|
47454
|
+
return path148.join(this.input.workspaceRoot, ".metaproject", "workspaces", id, "activity.jsonl");
|
|
47411
47455
|
}
|
|
47412
47456
|
async overview(input) {
|
|
47413
47457
|
const manifest = await this.input.workspaces.show(input);
|
|
@@ -47444,7 +47488,7 @@ class CollaborationService {
|
|
|
47444
47488
|
occurredAt: (this.input.now ?? (() => new Date))().toISOString(),
|
|
47445
47489
|
...suppliedHandoff ? { handoff: { ...suppliedHandoff, from: actor.subject } } : {}
|
|
47446
47490
|
});
|
|
47447
|
-
await mkdir37(
|
|
47491
|
+
await mkdir37(path148.dirname(this.file(manifest.id)), { recursive: true, mode: 448 });
|
|
47448
47492
|
await appendFile9(this.file(manifest.id), `${JSON.stringify(activity)}
|
|
47449
47493
|
`, { mode: 384 });
|
|
47450
47494
|
return normalizeCollaborationResult(activity);
|
|
@@ -47494,14 +47538,14 @@ function normalizeCollaborationResult(value) {
|
|
|
47494
47538
|
// src/session/external-slate.ts
|
|
47495
47539
|
init_fs();
|
|
47496
47540
|
import { mkdir as mkdir39, readdir as readdir27, readFile as readFile76 } from "fs/promises";
|
|
47497
|
-
import
|
|
47541
|
+
import path150 from "path";
|
|
47498
47542
|
|
|
47499
47543
|
// src/sac/machine-wrap-up.ts
|
|
47500
47544
|
init_fs();
|
|
47501
47545
|
init_slate();
|
|
47502
47546
|
import { createHash as createHash36, randomUUID as randomUUID13 } from "crypto";
|
|
47503
47547
|
import { mkdir as mkdir38 } from "fs/promises";
|
|
47504
|
-
import
|
|
47548
|
+
import path149 from "path";
|
|
47505
47549
|
|
|
47506
47550
|
// src/sac/workspace-resolve.ts
|
|
47507
47551
|
init_redact();
|
|
@@ -47644,11 +47688,11 @@ async function resolveMachineWrapUp(input) {
|
|
|
47644
47688
|
`;
|
|
47645
47689
|
const seedsJson = `${JSON.stringify(seedsForKind.map((seed) => ({ text: seed.text, source: describeSource(seed.source) })), null, 2)}
|
|
47646
47690
|
`;
|
|
47647
|
-
const evidenceRelBase =
|
|
47691
|
+
const evidenceRelBase = path149.posix.join(".metaproject", "workspaces", input.workspaceId, "machine-evidence");
|
|
47648
47692
|
const floor = await applyEvidenceRedactionFloor(input.cwd, [
|
|
47649
|
-
{ name: `${input.kind}.diff.txt`, content: diffBody, path:
|
|
47650
|
-
{ name: `${input.kind}.flow.json`, content: flowSnapshotJson, path:
|
|
47651
|
-
{ name: `${input.kind}.seeds.json`, content: seedsJson, path:
|
|
47693
|
+
{ name: `${input.kind}.diff.txt`, content: diffBody, path: path149.posix.join(evidenceRelBase, `${input.kind}.diff.txt`), source: "tool-output" },
|
|
47694
|
+
{ name: `${input.kind}.flow.json`, content: flowSnapshotJson, path: path149.posix.join(evidenceRelBase, `${input.kind}.flow.json`), source: "generated" },
|
|
47695
|
+
{ name: `${input.kind}.seeds.json`, content: seedsJson, path: path149.posix.join(evidenceRelBase, `${input.kind}.seeds.json`), source: "generated" }
|
|
47652
47696
|
]);
|
|
47653
47697
|
if (!floor.ok)
|
|
47654
47698
|
return { ok: false, code: "security_denied", detail: floor.reason };
|
|
@@ -47702,14 +47746,14 @@ ${safeSeeds.content}`;
|
|
|
47702
47746
|
}
|
|
47703
47747
|
summary = result.text.trim().length > 0 ? result.text.trim() : mechanicalSummary(summaryDiff, course);
|
|
47704
47748
|
}
|
|
47705
|
-
const evidenceDir =
|
|
47749
|
+
const evidenceDir = path149.join(input.cwd, ".metaproject", "workspaces", input.workspaceId, "machine-evidence");
|
|
47706
47750
|
await mkdir38(evidenceDir, { recursive: true });
|
|
47707
47751
|
const diffFile = `${input.kind}.${shortHash}.diff.txt`;
|
|
47708
47752
|
const flowFile = `${input.kind}.${shortHash}.flow.json`;
|
|
47709
47753
|
const seedsFile = `${input.kind}.${shortHash}.seeds.json`;
|
|
47710
|
-
await writeFileAtomic(
|
|
47711
|
-
await writeFileAtomic(
|
|
47712
|
-
await writeFileAtomic(
|
|
47754
|
+
await writeFileAtomic(path149.join(evidenceDir, diffFile), safeDiff.content);
|
|
47755
|
+
await writeFileAtomic(path149.join(evidenceDir, flowFile), safeFlow.content);
|
|
47756
|
+
await writeFileAtomic(path149.join(evidenceDir, seedsFile), safeSeeds.content);
|
|
47713
47757
|
const observedAt = now().toISOString();
|
|
47714
47758
|
const relBase = `./.metaproject/workspaces/${input.workspaceId}/machine-evidence`;
|
|
47715
47759
|
const evidence = [
|
|
@@ -47719,7 +47763,7 @@ ${safeSeeds.content}`;
|
|
|
47719
47763
|
];
|
|
47720
47764
|
if (floor.notice !== undefined) {
|
|
47721
47765
|
const noticeFile = `${input.kind}.${shortHash}.redaction.md`;
|
|
47722
|
-
await writeFileAtomic(
|
|
47766
|
+
await writeFileAtomic(path149.join(evidenceDir, noticeFile), floor.notice);
|
|
47723
47767
|
evidence.push({ kind: REDACTION_NOTICE_KIND, uri: `${relBase}/${noticeFile}`, revision: sha2567(floor.notice), observedAt });
|
|
47724
47768
|
}
|
|
47725
47769
|
return {
|
|
@@ -47738,18 +47782,18 @@ async function writeFlooredArchiveArtifact(params) {
|
|
|
47738
47782
|
{
|
|
47739
47783
|
name: params.filename,
|
|
47740
47784
|
content: params.content,
|
|
47741
|
-
path:
|
|
47785
|
+
path: path149.posix.join("slate-archive", params.filename),
|
|
47742
47786
|
source: "generated"
|
|
47743
47787
|
}
|
|
47744
47788
|
]);
|
|
47745
47789
|
if (!floor.ok)
|
|
47746
47790
|
return { ok: false, code: "security_denied", detail: floor.reason };
|
|
47747
47791
|
const body = floor.bodies[0];
|
|
47748
|
-
const archiveDir =
|
|
47792
|
+
const archiveDir = path149.join(params.dir, "slate-archive");
|
|
47749
47793
|
await mkdir38(archiveDir, { recursive: true });
|
|
47750
|
-
await writeFileAtomic(
|
|
47794
|
+
await writeFileAtomic(path149.join(archiveDir, params.filename), body.content);
|
|
47751
47795
|
if (floor.notice !== undefined) {
|
|
47752
|
-
await writeFileAtomic(
|
|
47796
|
+
await writeFileAtomic(path149.join(archiveDir, `${params.filename}${ARCHIVE_REDACTION_NOTICE_SUFFIX}`), floor.notice);
|
|
47753
47797
|
}
|
|
47754
47798
|
return { ok: true, altered: body.altered };
|
|
47755
47799
|
}
|
|
@@ -47785,9 +47829,9 @@ async function writeWrapUpOutcomeArtifact(cwd, dir, trigger, now, groups) {
|
|
|
47785
47829
|
return;
|
|
47786
47830
|
const refusalIso = now().toISOString();
|
|
47787
47831
|
const refusalFilename = `${refusalIso.replace(/[:.]/g, "-")}-wrap-up-outcome.json`;
|
|
47788
|
-
const archiveDir =
|
|
47832
|
+
const archiveDir = path149.join(dir, "slate-archive");
|
|
47789
47833
|
await mkdir38(archiveDir, { recursive: true });
|
|
47790
|
-
await writeFileAtomic(
|
|
47834
|
+
await writeFileAtomic(path149.join(archiveDir, refusalFilename), `${JSON.stringify({
|
|
47791
47835
|
recordType: "wrap-up-outcome",
|
|
47792
47836
|
trigger,
|
|
47793
47837
|
generatedAt: refusalIso,
|
|
@@ -47924,7 +47968,7 @@ async function runWrapUp(input) {
|
|
|
47924
47968
|
|
|
47925
47969
|
// src/session/external-slate.ts
|
|
47926
47970
|
function externalSlatesDir(cwd) {
|
|
47927
|
-
return
|
|
47971
|
+
return path150.join(cwd, ".keryx", "external-slates");
|
|
47928
47972
|
}
|
|
47929
47973
|
var EXTERNAL_SESSION_ID_PATTERN = /^[A-Za-z0-9_-]{1,128}$/;
|
|
47930
47974
|
function assertValidExternalSessionId(externalSessionId) {
|
|
@@ -47934,14 +47978,14 @@ function assertValidExternalSessionId(externalSessionId) {
|
|
|
47934
47978
|
}
|
|
47935
47979
|
function externalSlatePath(cwd, externalSessionId) {
|
|
47936
47980
|
assertValidExternalSessionId(externalSessionId);
|
|
47937
|
-
return
|
|
47981
|
+
return path150.join(externalSlatesDir(cwd), `${externalSessionId}.json`);
|
|
47938
47982
|
}
|
|
47939
47983
|
function externalSlateLockPath(cwd, externalSessionId) {
|
|
47940
47984
|
return `${externalSlatePath(cwd, externalSessionId)}.lock`;
|
|
47941
47985
|
}
|
|
47942
47986
|
function externalSlateEvidenceDir(cwd, externalSessionId) {
|
|
47943
47987
|
assertValidExternalSessionId(externalSessionId);
|
|
47944
|
-
return
|
|
47988
|
+
return path150.join(externalSlatesDir(cwd), externalSessionId);
|
|
47945
47989
|
}
|
|
47946
47990
|
async function readExternalSlate(cwd, externalSessionId) {
|
|
47947
47991
|
try {
|
|
@@ -48025,12 +48069,12 @@ init_service2();
|
|
|
48025
48069
|
|
|
48026
48070
|
// src/standard/service.ts
|
|
48027
48071
|
init_fs();
|
|
48028
|
-
import
|
|
48072
|
+
import path153 from "path";
|
|
48029
48073
|
import { readFile as readFile79 } from "fs/promises";
|
|
48030
48074
|
|
|
48031
48075
|
// src/standard/validate.ts
|
|
48032
48076
|
init_fs();
|
|
48033
|
-
import
|
|
48077
|
+
import path152 from "path";
|
|
48034
48078
|
import { readFile as readFile78 } from "fs/promises";
|
|
48035
48079
|
|
|
48036
48080
|
// src/standard/schemas.ts
|
|
@@ -48160,7 +48204,7 @@ var SCHEMA_REGISTRY2 = {
|
|
|
48160
48204
|
// src/standard/profiles.ts
|
|
48161
48205
|
init_fs();
|
|
48162
48206
|
init_entrypoint_targets();
|
|
48163
|
-
import
|
|
48207
|
+
import path151 from "path";
|
|
48164
48208
|
import { readFile as readFile77 } from "fs/promises";
|
|
48165
48209
|
var AGENT_MODULES = ["gdgraph", "gdctx", "gdskills", "gdwiki", "memory"];
|
|
48166
48210
|
var CI_MODULES = ["health", "testing"];
|
|
@@ -48185,7 +48229,7 @@ function enabledModuleKeys(manifest) {
|
|
|
48185
48229
|
}
|
|
48186
48230
|
async function rootEntrypointLinksIndex(cwd, manifest) {
|
|
48187
48231
|
for (const { path: name } of namedEntrypoints(manifest)) {
|
|
48188
|
-
const filePath =
|
|
48232
|
+
const filePath = path151.join(cwd, name);
|
|
48189
48233
|
if (!await pathExists(filePath)) {
|
|
48190
48234
|
continue;
|
|
48191
48235
|
}
|
|
@@ -48197,16 +48241,16 @@ async function rootEntrypointLinksIndex(cwd, manifest) {
|
|
|
48197
48241
|
return false;
|
|
48198
48242
|
}
|
|
48199
48243
|
async function minimalSatisfied(cwd) {
|
|
48200
|
-
const metaprojectRoot =
|
|
48244
|
+
const metaprojectRoot = path151.join(cwd, ".metaproject");
|
|
48201
48245
|
const requiredFiles = ["index.md", "README.md", "metaproject.json"];
|
|
48202
48246
|
const requiredDirs = ["modules", "rules", "skills", "data"];
|
|
48203
48247
|
for (const file of requiredFiles) {
|
|
48204
|
-
if (!await pathExists(
|
|
48248
|
+
if (!await pathExists(path151.join(metaprojectRoot, file))) {
|
|
48205
48249
|
return false;
|
|
48206
48250
|
}
|
|
48207
48251
|
}
|
|
48208
48252
|
for (const dir of requiredDirs) {
|
|
48209
|
-
if (!await pathExists(
|
|
48253
|
+
if (!await pathExists(path151.join(metaprojectRoot, dir))) {
|
|
48210
48254
|
return false;
|
|
48211
48255
|
}
|
|
48212
48256
|
}
|
|
@@ -48219,7 +48263,7 @@ async function ciSatisfied(cwd, manifest) {
|
|
|
48219
48263
|
return false;
|
|
48220
48264
|
}
|
|
48221
48265
|
for (const key of ciModules) {
|
|
48222
|
-
if (await pathExists(
|
|
48266
|
+
if (await pathExists(path151.join(cwd, ".metaproject", "data", key, "artifacts"))) {
|
|
48223
48267
|
return true;
|
|
48224
48268
|
}
|
|
48225
48269
|
}
|
|
@@ -48232,7 +48276,7 @@ async function evaluateProfiles(cwd, manifest) {
|
|
|
48232
48276
|
satisfied.push("minimal");
|
|
48233
48277
|
}
|
|
48234
48278
|
const hasAgentModule = AGENT_MODULES.some((key) => new Set(enabledModuleKeys(manifest)).has(key));
|
|
48235
|
-
const agent = minimal && hasAgentModule && await rootEntrypointLinksIndex(cwd, manifest) && await pathExists(
|
|
48279
|
+
const agent = minimal && hasAgentModule && await rootEntrypointLinksIndex(cwd, manifest) && await pathExists(path151.join(cwd, ".metaproject", "rules"));
|
|
48236
48280
|
if (agent) {
|
|
48237
48281
|
satisfied.push("agent");
|
|
48238
48282
|
}
|
|
@@ -48401,20 +48445,20 @@ var MANIFEST_TOP_LEVEL_SCHEMA = {
|
|
|
48401
48445
|
async function validateWorkspace2(cwd) {
|
|
48402
48446
|
const errors = [];
|
|
48403
48447
|
const warnings = [];
|
|
48404
|
-
const metaprojectRoot =
|
|
48448
|
+
const metaprojectRoot = path152.join(cwd, ".metaproject");
|
|
48405
48449
|
const requiredFiles = ["index.md", "README.md", "metaproject.json"];
|
|
48406
48450
|
for (const file of requiredFiles) {
|
|
48407
|
-
if (!await pathExists(
|
|
48451
|
+
if (!await pathExists(path152.join(metaprojectRoot, file))) {
|
|
48408
48452
|
errors.push(issue("missing-required-file", `Required file .metaproject/${file} is missing`, `Run \`keryx init\` to scaffold .metaproject/${file}.`));
|
|
48409
48453
|
}
|
|
48410
48454
|
}
|
|
48411
48455
|
const requiredDirs = ["modules", "rules", "skills", "data"];
|
|
48412
48456
|
for (const dir of requiredDirs) {
|
|
48413
|
-
if (!await pathExists(
|
|
48457
|
+
if (!await pathExists(path152.join(metaprojectRoot, dir))) {
|
|
48414
48458
|
errors.push(issue("missing-required-dir", `Required directory .metaproject/${dir}/ is missing`, `Run \`keryx init\` to create .metaproject/${dir}/.`));
|
|
48415
48459
|
}
|
|
48416
48460
|
}
|
|
48417
|
-
const manifestPath =
|
|
48461
|
+
const manifestPath = path152.join(metaprojectRoot, "metaproject.json");
|
|
48418
48462
|
if (!await pathExists(manifestPath)) {
|
|
48419
48463
|
return { ok: errors.length === 0, errors, warnings };
|
|
48420
48464
|
}
|
|
@@ -48446,7 +48490,7 @@ async function validateWorkspace2(cwd) {
|
|
|
48446
48490
|
if (typeof value !== "string") {
|
|
48447
48491
|
continue;
|
|
48448
48492
|
}
|
|
48449
|
-
if (!await pathExists(
|
|
48493
|
+
if (!await pathExists(path152.join(cwd, value))) {
|
|
48450
48494
|
errors.push(issue("missing-declared-path", `Declared path paths.${key} -> ${value} does not exist`, `Create ${value} or remove paths.${key} from metaproject.json.`));
|
|
48451
48495
|
}
|
|
48452
48496
|
}
|
|
@@ -48456,7 +48500,7 @@ async function validateWorkspace2(cwd) {
|
|
|
48456
48500
|
continue;
|
|
48457
48501
|
}
|
|
48458
48502
|
if (typeof entry.manifest === "string") {
|
|
48459
|
-
if (!await pathExists(
|
|
48503
|
+
if (!await pathExists(path152.join(cwd, entry.manifest))) {
|
|
48460
48504
|
errors.push(issue("missing-module-manifest", `Enabled module "${key}" manifest ${entry.manifest} is missing`, `Create ${entry.manifest} or run \`keryx update\` to regenerate module manifests.`));
|
|
48461
48505
|
}
|
|
48462
48506
|
}
|
|
@@ -48465,14 +48509,14 @@ async function validateWorkspace2(cwd) {
|
|
|
48465
48509
|
if (typeof value !== "string") {
|
|
48466
48510
|
continue;
|
|
48467
48511
|
}
|
|
48468
|
-
if (!await pathExists(
|
|
48512
|
+
if (!await pathExists(path152.join(cwd, value))) {
|
|
48469
48513
|
const sink = field === "data" ? warnings : errors;
|
|
48470
48514
|
sink.push(issue("missing-module-path", `Module "${key}" declares ${String(field)} ${value}, which does not exist`, field === "data" ? `Run the module (e.g. \`keryx ${key} ...\`) to generate ${value}, or update modules.${key}.data in metaproject.json.` : `Create ${value} or update modules.${key}.${String(field)} in metaproject.json.`));
|
|
48471
48515
|
}
|
|
48472
48516
|
}
|
|
48473
48517
|
}
|
|
48474
48518
|
for (const { path: name, scope } of namedEntrypoints(manifest)) {
|
|
48475
|
-
const filePath =
|
|
48519
|
+
const filePath = path152.join(cwd, name);
|
|
48476
48520
|
if (!await pathExists(filePath)) {
|
|
48477
48521
|
continue;
|
|
48478
48522
|
}
|
|
@@ -49509,7 +49553,7 @@ async function runDoctor(cwd) {
|
|
|
49509
49553
|
return validateWorkspace2(cwd);
|
|
49510
49554
|
}
|
|
49511
49555
|
async function readManifest3(cwd) {
|
|
49512
|
-
const manifestPath =
|
|
49556
|
+
const manifestPath = path153.join(cwd, ".metaproject", "metaproject.json");
|
|
49513
49557
|
if (!await pathExists(manifestPath)) {
|
|
49514
49558
|
throw new Error("Metaproject is not initialized (missing .metaproject/metaproject.json). Run `keryx init` first.");
|
|
49515
49559
|
}
|