@mrciphersmith/keryx 0.4.41 → 0.4.42
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 +19964 -15066
- package/dist/core.js +179 -164
- package/dist/keryx-general-worker-entry.js +619 -514
- package/package.json +5 -4
- package/src/gdskills/bundled/skills/review/review-orchestrator/SKILL.md +1 -1
package/dist/core.js
CHANGED
|
@@ -5438,13 +5438,55 @@ var init_entropy_gate = __esm(() => {
|
|
|
5438
5438
|
cachedEnabled = DEFAULT_SECURITY_CONFIG.backends.entropy.enabled;
|
|
5439
5439
|
});
|
|
5440
5440
|
|
|
5441
|
+
// src/security/display-redaction.ts
|
|
5442
|
+
function maskFor(match) {
|
|
5443
|
+
return `[REDACTED:${match.mask ?? "sensitive"}]`;
|
|
5444
|
+
}
|
|
5445
|
+
function applyRedaction(content, matches) {
|
|
5446
|
+
const redactable = matches.filter((m) => m.mask !== undefined).sort((a, b) => a.start - b.start || b.end - a.end);
|
|
5447
|
+
let out = "";
|
|
5448
|
+
let cursor = 0;
|
|
5449
|
+
for (const match of redactable) {
|
|
5450
|
+
if (match.end <= cursor) {
|
|
5451
|
+
continue;
|
|
5452
|
+
}
|
|
5453
|
+
if (match.start < cursor) {
|
|
5454
|
+
cursor = match.end;
|
|
5455
|
+
continue;
|
|
5456
|
+
}
|
|
5457
|
+
out += content.slice(cursor, match.start);
|
|
5458
|
+
out += maskFor(match);
|
|
5459
|
+
cursor = match.end;
|
|
5460
|
+
}
|
|
5461
|
+
out += content.slice(cursor);
|
|
5462
|
+
return out;
|
|
5463
|
+
}
|
|
5464
|
+
function redactDisplayText(text, includeEntropy = true) {
|
|
5465
|
+
if (text.length === 0) {
|
|
5466
|
+
return text;
|
|
5467
|
+
}
|
|
5468
|
+
const matches = [
|
|
5469
|
+
...detectSecrets(text),
|
|
5470
|
+
...detectPii(text),
|
|
5471
|
+
...detectExfil(text),
|
|
5472
|
+
...includeEntropy ? detectEntropy(text) : []
|
|
5473
|
+
];
|
|
5474
|
+
if (matches.length === 0) {
|
|
5475
|
+
return text;
|
|
5476
|
+
}
|
|
5477
|
+
return applyRedaction(text, matches);
|
|
5478
|
+
}
|
|
5479
|
+
var init_display_redaction = __esm(() => {
|
|
5480
|
+
init_secrets();
|
|
5481
|
+
init_pii();
|
|
5482
|
+
init_exfil();
|
|
5483
|
+
init_entropy();
|
|
5484
|
+
});
|
|
5485
|
+
|
|
5441
5486
|
// src/security/redact.ts
|
|
5442
5487
|
import path12 from "path";
|
|
5443
5488
|
import { createHmac, randomBytes as randomBytes2 } from "crypto";
|
|
5444
5489
|
import { mkdir as mkdir3, readFile as readFile3, writeFile as writeFile2, chmod as chmod3 } from "fs/promises";
|
|
5445
|
-
function maskFor(match) {
|
|
5446
|
-
return `[REDACTED:${match.mask ?? "sensitive"}]`;
|
|
5447
|
-
}
|
|
5448
5490
|
function tidy(value) {
|
|
5449
5491
|
return value.replace(/\s+/g, " ").trim();
|
|
5450
5492
|
}
|
|
@@ -5487,39 +5529,8 @@ function locationFor(content, match) {
|
|
|
5487
5529
|
end: match.end
|
|
5488
5530
|
};
|
|
5489
5531
|
}
|
|
5490
|
-
function applyRedaction(content, matches) {
|
|
5491
|
-
const redactable = matches.filter((m) => m.mask !== undefined).sort((a, b) => a.start - b.start || b.end - a.end);
|
|
5492
|
-
let out = "";
|
|
5493
|
-
let cursor = 0;
|
|
5494
|
-
for (const match of redactable) {
|
|
5495
|
-
if (match.end <= cursor) {
|
|
5496
|
-
continue;
|
|
5497
|
-
}
|
|
5498
|
-
if (match.start < cursor) {
|
|
5499
|
-
cursor = match.end;
|
|
5500
|
-
continue;
|
|
5501
|
-
}
|
|
5502
|
-
out += content.slice(cursor, match.start);
|
|
5503
|
-
out += maskFor(match);
|
|
5504
|
-
cursor = match.end;
|
|
5505
|
-
}
|
|
5506
|
-
out += content.slice(cursor);
|
|
5507
|
-
return out;
|
|
5508
|
-
}
|
|
5509
5532
|
function redactSensitiveText(text) {
|
|
5510
|
-
|
|
5511
|
-
return text;
|
|
5512
|
-
}
|
|
5513
|
-
const matches = [
|
|
5514
|
-
...detectSecrets(text),
|
|
5515
|
-
...detectPii(text),
|
|
5516
|
-
...detectExfil(text),
|
|
5517
|
-
...isEntropyBackendEnabled() ? detectEntropy(text) : []
|
|
5518
|
-
];
|
|
5519
|
-
if (matches.length === 0) {
|
|
5520
|
-
return text;
|
|
5521
|
-
}
|
|
5522
|
-
return applyRedaction(text, matches);
|
|
5533
|
+
return redactDisplayText(text, isEntropyBackendEnabled());
|
|
5523
5534
|
}
|
|
5524
5535
|
function keyDir(cwd) {
|
|
5525
5536
|
return path12.join(securityDataRoot(cwd), "raw");
|
|
@@ -5549,10 +5560,8 @@ var PREVIEW_WINDOW = 24, KEY_FILE = "hmac.key";
|
|
|
5549
5560
|
var init_redact = __esm(() => {
|
|
5550
5561
|
init_fs();
|
|
5551
5562
|
init_config();
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
init_exfil();
|
|
5555
|
-
init_entropy();
|
|
5563
|
+
init_display_redaction();
|
|
5564
|
+
init_display_redaction();
|
|
5556
5565
|
init_entropy_gate();
|
|
5557
5566
|
});
|
|
5558
5567
|
|
|
@@ -7089,7 +7098,7 @@ var init_incidents = __esm(() => {
|
|
|
7089
7098
|
|
|
7090
7099
|
// src/security/self-protect.ts
|
|
7091
7100
|
import path18 from "path";
|
|
7092
|
-
import {
|
|
7101
|
+
import { readFile as readFile6 } from "fs/promises";
|
|
7093
7102
|
function currentState(config) {
|
|
7094
7103
|
const policies = {};
|
|
7095
7104
|
for (const [name, policy] of Object.entries(config.policies)) {
|
|
@@ -7162,9 +7171,8 @@ async function readState(cwd) {
|
|
|
7162
7171
|
}
|
|
7163
7172
|
async function writeState(cwd, state) {
|
|
7164
7173
|
const file = stateFile(cwd);
|
|
7165
|
-
await
|
|
7166
|
-
|
|
7167
|
-
`, "utf8");
|
|
7174
|
+
await writeFileAtomic(file, `${JSON.stringify(state, null, 2)}
|
|
7175
|
+
`);
|
|
7168
7176
|
}
|
|
7169
7177
|
var MODE_RANK;
|
|
7170
7178
|
var init_self_protect = __esm(() => {
|
|
@@ -12194,7 +12202,7 @@ var init_surfaces_agents = __esm(() => {
|
|
|
12194
12202
|
});
|
|
12195
12203
|
|
|
12196
12204
|
// src/lib/git-local-ignore.ts
|
|
12197
|
-
import { lstat as lstat6, mkdir as
|
|
12205
|
+
import { lstat as lstat6, mkdir as mkdir6, readFile as readFile11, realpath as realpath9, writeFile as writeFile4 } from "fs/promises";
|
|
12198
12206
|
import path32 from "path";
|
|
12199
12207
|
async function isPathIgnored(projectRoot, relativePath) {
|
|
12200
12208
|
if (await resolveGitCommonDir(projectRoot) === undefined)
|
|
@@ -12215,8 +12223,8 @@ async function resolveLocalExcludePath(projectRoot) {
|
|
|
12215
12223
|
return commonDir === undefined ? undefined : path32.join(commonDir, "info", "exclude");
|
|
12216
12224
|
}
|
|
12217
12225
|
async function writeExcludeFile(infoDir, excludePath, content) {
|
|
12218
|
-
await
|
|
12219
|
-
await
|
|
12226
|
+
await mkdir6(infoDir, { recursive: true });
|
|
12227
|
+
await writeFile4(excludePath, content, "utf8");
|
|
12220
12228
|
}
|
|
12221
12229
|
async function replaceLocalIgnoreBlock(projectRoot, lines) {
|
|
12222
12230
|
const commonDir = await resolveGitCommonDir(projectRoot);
|
|
@@ -16992,15 +17000,17 @@ async function detectAndResolve(cwd, input, context, opts) {
|
|
|
16992
17000
|
return contextual.warning !== undefined ? { decision, warning: contextual.warning } : { decision };
|
|
16993
17001
|
}
|
|
16994
17002
|
async function runSelfProtection(cwd, config) {
|
|
16995
|
-
|
|
16996
|
-
|
|
16997
|
-
|
|
16998
|
-
|
|
16999
|
-
|
|
17000
|
-
|
|
17001
|
-
|
|
17002
|
-
|
|
17003
|
-
|
|
17003
|
+
return withFileLock(path41.join(securityDataRoot(cwd), "raw", "self-protection.lock"), async () => {
|
|
17004
|
+
const previous = await readState(cwd);
|
|
17005
|
+
const selfProtection = evaluateSelfProtection(config, previous);
|
|
17006
|
+
if (selfProtection.incidents.length > 0) {
|
|
17007
|
+
await appendIncidents(cwd, selfProtection.incidents);
|
|
17008
|
+
}
|
|
17009
|
+
if (!config.configUnreadable) {
|
|
17010
|
+
await writeState(cwd, currentState(config));
|
|
17011
|
+
}
|
|
17012
|
+
return { findings: selfProtection.findings, warnings: selfProtection.warnings };
|
|
17013
|
+
});
|
|
17004
17014
|
}
|
|
17005
17015
|
async function analyze(cwd, input, opts = {}) {
|
|
17006
17016
|
const context = await loadAnalysisContext(cwd);
|
|
@@ -18269,7 +18279,7 @@ function titleSimilarity(a, b) {
|
|
|
18269
18279
|
|
|
18270
18280
|
// src/memory/report.ts
|
|
18271
18281
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
18272
|
-
import { access as access2, mkdir as
|
|
18282
|
+
import { access as access2, mkdir as mkdir9, readdir as readdir15, rename as rename4, rm as rm4, stat as stat11, writeFile as writeFile6 } from "fs/promises";
|
|
18273
18283
|
import path65 from "path";
|
|
18274
18284
|
function runtimeRoot(cwd) {
|
|
18275
18285
|
return path65.join(cwd, ".metaproject", "runtime", "memory");
|
|
@@ -18509,8 +18519,8 @@ class MemoryReportStore {
|
|
|
18509
18519
|
const destination = path65.join(searchRoot, runId);
|
|
18510
18520
|
if (await exists(destination))
|
|
18511
18521
|
throw new Error(`Memory report run already exists: ${runId}`);
|
|
18512
|
-
await
|
|
18513
|
-
await
|
|
18522
|
+
await mkdir9(searchRoot, { recursive: true });
|
|
18523
|
+
await mkdir9(tempRoot, { recursive: true });
|
|
18514
18524
|
const staleBefore = this.clock().getTime() - STALE_STAGING_MS;
|
|
18515
18525
|
for (const name of await readdir15(tempRoot)) {
|
|
18516
18526
|
const candidate = path65.join(tempRoot, name);
|
|
@@ -18519,11 +18529,11 @@ class MemoryReportStore {
|
|
|
18519
18529
|
}
|
|
18520
18530
|
const staging = path65.join(tempRoot, `${runId}.${randomUUID2()}`);
|
|
18521
18531
|
try {
|
|
18522
|
-
await
|
|
18532
|
+
await mkdir9(staging);
|
|
18523
18533
|
await Promise.all([
|
|
18524
|
-
|
|
18534
|
+
writeFile6(path65.join(staging, "report.json"), `${JSON.stringify(report, null, 2)}
|
|
18525
18535
|
`, "utf8"),
|
|
18526
|
-
|
|
18536
|
+
writeFile6(path65.join(staging, "report.md"), renderMemorySearchReportMarkdown(report), "utf8")
|
|
18527
18537
|
]);
|
|
18528
18538
|
if (await exists(destination))
|
|
18529
18539
|
throw new Error(`Memory report run already exists: ${runId}`);
|
|
@@ -19737,7 +19747,7 @@ var init_adapter = __esm(() => {
|
|
|
19737
19747
|
});
|
|
19738
19748
|
|
|
19739
19749
|
// src/gdgraph/enrich.ts
|
|
19740
|
-
import { mkdir as
|
|
19750
|
+
import { mkdir as mkdir13, writeFile as writeFile7 } from "fs/promises";
|
|
19741
19751
|
import path84 from "path";
|
|
19742
19752
|
async function enrichBuildWithSymbols(cwd, files, resolve, dataDir) {
|
|
19743
19753
|
const config = await loadGdgraphConfig(cwd);
|
|
@@ -19755,11 +19765,11 @@ async function enrichBuildWithSymbols(cwd, files, resolve, dataDir) {
|
|
|
19755
19765
|
}
|
|
19756
19766
|
async function writeSymbolLayer(cwd, layer, dataDir) {
|
|
19757
19767
|
const storageDir = gdgraphStorageDir(cwd, dataDir);
|
|
19758
|
-
await
|
|
19759
|
-
await
|
|
19768
|
+
await mkdir13(storageDir, { recursive: true });
|
|
19769
|
+
await writeFile7(path84.join(storageDir, "symbols.jsonl"), layer.symbols.map((symbol) => JSON.stringify(symbol)).join(`
|
|
19760
19770
|
`) + `
|
|
19761
19771
|
`, "utf8");
|
|
19762
|
-
await
|
|
19772
|
+
await writeFile7(path84.join(storageDir, "calls.jsonl"), layer.calls.map((call) => JSON.stringify(call)).join(`
|
|
19763
19773
|
`) + `
|
|
19764
19774
|
`, "utf8");
|
|
19765
19775
|
}
|
|
@@ -19952,7 +19962,7 @@ var NOT_CODE_SCOPED = "none";
|
|
|
19952
19962
|
var init_describes = () => {};
|
|
19953
19963
|
|
|
19954
19964
|
// src/sync/provenance.ts
|
|
19955
|
-
import { mkdir as
|
|
19965
|
+
import { mkdir as mkdir14, readFile as readFile40, writeFile as writeFile8 } from "fs/promises";
|
|
19956
19966
|
import path85 from "path";
|
|
19957
19967
|
import { spawn } from "child_process";
|
|
19958
19968
|
function provenancePath(cwd, module) {
|
|
@@ -20001,9 +20011,9 @@ async function recordProvenance(cwd, module, at) {
|
|
|
20001
20011
|
if (!head)
|
|
20002
20012
|
return;
|
|
20003
20013
|
const file = provenancePath(cwd, module);
|
|
20004
|
-
await
|
|
20014
|
+
await mkdir14(path85.dirname(file), { recursive: true });
|
|
20005
20015
|
const provenance = { commit: head.commit, branch: head.branch, builtAt: at };
|
|
20006
|
-
await
|
|
20016
|
+
await writeFile8(file, `${JSON.stringify(provenance, null, 2)}
|
|
20007
20017
|
`, "utf8");
|
|
20008
20018
|
}
|
|
20009
20019
|
async function readProvenance(cwd, module) {
|
|
@@ -21195,7 +21205,7 @@ var MEMORY_EMBEDDING_ID = "memory.embedding", DEFAULT_EMBED_DIMS = 96;
|
|
|
21195
21205
|
|
|
21196
21206
|
// src/memory/embedding/index.ts
|
|
21197
21207
|
import { createHash as createHash14 } from "crypto";
|
|
21198
|
-
import { mkdir as
|
|
21208
|
+
import { mkdir as mkdir15, readFile as readFile42, writeFile as writeFile9 } from "fs/promises";
|
|
21199
21209
|
import path88 from "path";
|
|
21200
21210
|
function embeddingsDir(cwd) {
|
|
21201
21211
|
return path88.join(cwd, ".metaproject", "data", "memory", "embeddings");
|
|
@@ -21226,10 +21236,10 @@ async function buildEmbeddingIndex(cwd, entries, embedder, model, now) {
|
|
|
21226
21236
|
entryCount: records.length
|
|
21227
21237
|
};
|
|
21228
21238
|
const dir = embeddingsDir(cwd);
|
|
21229
|
-
await
|
|
21230
|
-
await
|
|
21239
|
+
await mkdir15(dir, { recursive: true });
|
|
21240
|
+
await writeFile9(path88.join(dir, "index.meta.json"), `${JSON.stringify(meta, null, 2)}
|
|
21231
21241
|
`, "utf8");
|
|
21232
|
-
await
|
|
21242
|
+
await writeFile9(path88.join(dir, "vectors.jsonl"), records.map((record) => JSON.stringify(record)).join(`
|
|
21233
21243
|
`) + (records.length > 0 ? `
|
|
21234
21244
|
` : ""), "utf8");
|
|
21235
21245
|
return toIndex(meta, records);
|
|
@@ -21958,7 +21968,7 @@ var init_check = __esm(() => {
|
|
|
21958
21968
|
});
|
|
21959
21969
|
|
|
21960
21970
|
// src/memory/write.ts
|
|
21961
|
-
import { mkdir as
|
|
21971
|
+
import { mkdir as mkdir16, open as open3, readFile as readFile44, rename as rename5, rm as rm5, writeFile as writeFile10 } from "fs/promises";
|
|
21962
21972
|
import path92 from "path";
|
|
21963
21973
|
async function resolveCanonicalEntryPath(cwd, relativePath) {
|
|
21964
21974
|
const root = path92.resolve(memoryRoot(cwd));
|
|
@@ -22061,10 +22071,10 @@ function validateNextEntry(relativePath, content) {
|
|
|
22061
22071
|
}
|
|
22062
22072
|
async function replaceAtomically(target, content) {
|
|
22063
22073
|
const dir = path92.dirname(target);
|
|
22064
|
-
await
|
|
22074
|
+
await mkdir16(dir, { recursive: true });
|
|
22065
22075
|
const tmp = path92.join(dir, `.${path92.basename(target)}.keryx-tmp-${process.pid}-${Math.random().toString(16).slice(2)}`);
|
|
22066
22076
|
try {
|
|
22067
|
-
await
|
|
22077
|
+
await writeFile10(tmp, content, "utf8");
|
|
22068
22078
|
const file = await open3(tmp, "r");
|
|
22069
22079
|
try {
|
|
22070
22080
|
await file.sync();
|
|
@@ -22608,7 +22618,7 @@ __export(exports_service3, {
|
|
|
22608
22618
|
selectHandoffEntries: () => selectHandoffEntries
|
|
22609
22619
|
});
|
|
22610
22620
|
import { createHash as createHash15 } from "crypto";
|
|
22611
|
-
import { mkdir as
|
|
22621
|
+
import { mkdir as mkdir17, readFile as readFile47, writeFile as writeFile11 } from "fs/promises";
|
|
22612
22622
|
import path95 from "path";
|
|
22613
22623
|
function dataRoot2(cwd) {
|
|
22614
22624
|
return path95.join(cwd, ".metaproject", "data", "memory");
|
|
@@ -22660,9 +22670,9 @@ function createMemoryService() {
|
|
|
22660
22670
|
const entries = await collectEntries(input.cwd);
|
|
22661
22671
|
const generatedAt = new Date().toISOString();
|
|
22662
22672
|
const indexDir = input.indexDir ?? path95.join(dataRoot2(input.cwd), "index");
|
|
22663
|
-
await
|
|
22673
|
+
await mkdir17(indexDir, { recursive: true });
|
|
22664
22674
|
const indexPath = path95.join(indexDir, "index.json");
|
|
22665
|
-
await
|
|
22675
|
+
await writeFile11(indexPath, `${JSON.stringify({
|
|
22666
22676
|
catalogVersion: 1,
|
|
22667
22677
|
sourceFingerprint: createHash15("sha256").update(JSON.stringify(entries.map((e) => ({
|
|
22668
22678
|
path: e.relativePath,
|
|
@@ -23365,7 +23375,7 @@ var init_backlinks = __esm(() => {
|
|
|
23365
23375
|
|
|
23366
23376
|
// src/ctx/assembly.ts
|
|
23367
23377
|
import { createHash as createHash16 } from "crypto";
|
|
23368
|
-
import { mkdir as
|
|
23378
|
+
import { mkdir as mkdir18, rename as rename6, writeFile as writeFile12 } from "fs/promises";
|
|
23369
23379
|
import path97 from "path";
|
|
23370
23380
|
function assembleContext(input) {
|
|
23371
23381
|
let items = 0;
|
|
@@ -23411,10 +23421,10 @@ async function recordNoContentContext(input) {
|
|
|
23411
23421
|
}
|
|
23412
23422
|
async function recordContextAssembly(input) {
|
|
23413
23423
|
const directory = path97.join(input.workspaceRoot, ".metaproject", "context-operations", "traces");
|
|
23414
|
-
await
|
|
23424
|
+
await mkdir18(directory, { recursive: true });
|
|
23415
23425
|
const target = path97.join(directory, path97.basename(input.assembly.traceRef));
|
|
23416
23426
|
const temporary = `${target}.${process.pid}.tmp`;
|
|
23417
|
-
await
|
|
23427
|
+
await writeFile12(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 })}
|
|
23418
23428
|
`, { mode: 384 });
|
|
23419
23429
|
await rename6(temporary, target);
|
|
23420
23430
|
}
|
|
@@ -23891,7 +23901,7 @@ var init_config4 = __esm(() => {
|
|
|
23891
23901
|
|
|
23892
23902
|
// src/wiki/history.ts
|
|
23893
23903
|
import { createHash as createHash17, randomBytes as randomBytes5 } from "crypto";
|
|
23894
|
-
import { appendFile as appendFile4, mkdir as
|
|
23904
|
+
import { appendFile as appendFile4, mkdir as mkdir19, open as open4, readFile as readFile49, rm as rm6, stat as stat14, writeFile as writeFile13 } from "fs/promises";
|
|
23895
23905
|
import path99 from "path";
|
|
23896
23906
|
function wikiRootPath2(cwd) {
|
|
23897
23907
|
return path99.join(cwd, ".metaproject", "wiki");
|
|
@@ -24026,8 +24036,8 @@ async function readPageHistory(cwd, page) {
|
|
|
24026
24036
|
async function storeVersion(cwd, page, version, at, content) {
|
|
24027
24037
|
const fileName = `${versionLabel(version)}-${at.replace(/[:.]/g, "-")}.md`;
|
|
24028
24038
|
const target = path99.join(pageHistoryDir(cwd, page), fileName);
|
|
24029
|
-
await
|
|
24030
|
-
await
|
|
24039
|
+
await mkdir19(path99.dirname(target), { recursive: true });
|
|
24040
|
+
await writeFile13(target, content);
|
|
24031
24041
|
if (sha2562(await readFile49(target)) !== sha2562(content)) {
|
|
24032
24042
|
throw new Error(`history: stored version does not match the page bytes: ${target}`);
|
|
24033
24043
|
}
|
|
@@ -24067,8 +24077,8 @@ async function ensureHistoryRoot(cwd) {
|
|
|
24067
24077
|
const ignore = path99.join(root, ".gitignore");
|
|
24068
24078
|
if (await readBufferOrNull(ignore))
|
|
24069
24079
|
return;
|
|
24070
|
-
await
|
|
24071
|
-
await
|
|
24080
|
+
await mkdir19(root, { recursive: true });
|
|
24081
|
+
await writeFile13(ignore, `# keryx wiki page history (flow 367): local undo state, never committed.
|
|
24072
24082
|
*
|
|
24073
24083
|
`, "utf8");
|
|
24074
24084
|
}
|
|
@@ -24139,8 +24149,8 @@ async function mutatePage(ctx, absolutePath, next) {
|
|
|
24139
24149
|
if (next === null) {
|
|
24140
24150
|
await rm6(absolutePath, { force: true });
|
|
24141
24151
|
} else {
|
|
24142
|
-
await
|
|
24143
|
-
await
|
|
24152
|
+
await mkdir19(path99.dirname(absolutePath), { recursive: true });
|
|
24153
|
+
await writeFile13(absolutePath, next);
|
|
24144
24154
|
}
|
|
24145
24155
|
} catch (error) {
|
|
24146
24156
|
if (VERSION_FILE.test(row.file))
|
|
@@ -25329,7 +25339,7 @@ __export(exports_service4, {
|
|
|
25329
25339
|
});
|
|
25330
25340
|
import { spawn as spawn3 } from "child_process";
|
|
25331
25341
|
import { createHash as createHash19 } from "crypto";
|
|
25332
|
-
import { mkdir as
|
|
25342
|
+
import { mkdir as mkdir20, readFile as readFile50, readdir as readdir17, writeFile as writeFile14 } from "fs/promises";
|
|
25333
25343
|
import path101 from "path";
|
|
25334
25344
|
function wikiRootPath3(cwd) {
|
|
25335
25345
|
return path101.join(cwd, ".metaproject", "wiki");
|
|
@@ -25383,7 +25393,7 @@ async function wikiCreatePage(input) {
|
|
|
25383
25393
|
if (await pathExists(filePath) && !input.force) {
|
|
25384
25394
|
throw new Error(`Page already exists: ${relativePath}. Use --force to overwrite.`);
|
|
25385
25395
|
}
|
|
25386
|
-
await
|
|
25396
|
+
await mkdir20(dir, { recursive: true });
|
|
25387
25397
|
const title = input.title ?? slugToTitle2(input.slug);
|
|
25388
25398
|
const history = input.history ?? await openWikiWriteContext(input.cwd, input.force ? "wiki new --force" : "wiki new");
|
|
25389
25399
|
await writeWikiPage(history, filePath, renderWikiPage({ title, type: typeConfig.type }));
|
|
@@ -25445,8 +25455,8 @@ async function wikiCheckLinks(cwd) {
|
|
|
25445
25455
|
}
|
|
25446
25456
|
const generatedAt = new Date().toISOString();
|
|
25447
25457
|
const reportPath = linkCheckReportPath(cwd);
|
|
25448
|
-
await
|
|
25449
|
-
await
|
|
25458
|
+
await mkdir20(path101.dirname(reportPath), { recursive: true });
|
|
25459
|
+
await writeFile14(reportPath, renderLinkCheckReport({
|
|
25450
25460
|
generatedAt,
|
|
25451
25461
|
checkedPages: files.length,
|
|
25452
25462
|
checkedLinks,
|
|
@@ -26561,7 +26571,7 @@ var init_service4 = __esm(() => {
|
|
|
26561
26571
|
|
|
26562
26572
|
// src/gdgraph/wiki-layer.ts
|
|
26563
26573
|
import { createHash as createHash20 } from "crypto";
|
|
26564
|
-
import { mkdir as
|
|
26574
|
+
import { mkdir as mkdir21, stat as stat15, writeFile as writeFile15 } from "fs/promises";
|
|
26565
26575
|
import path102 from "path";
|
|
26566
26576
|
function storageDir(projectRoot, dataDir) {
|
|
26567
26577
|
return gdgraphStorageDir(projectRoot, dataDir);
|
|
@@ -26621,12 +26631,12 @@ function computeFingerprints(fileRecords, mtimes) {
|
|
|
26621
26631
|
async function writeJsonl(filePath, rows) {
|
|
26622
26632
|
const body = rows.map((row) => JSON.stringify(row)).join(`
|
|
26623
26633
|
`);
|
|
26624
|
-
await
|
|
26634
|
+
await writeFile15(filePath, rows.length > 0 ? `${body}
|
|
26625
26635
|
` : "", "utf8");
|
|
26626
26636
|
}
|
|
26627
26637
|
async function enrichBuildWithWikiLayer(input) {
|
|
26628
26638
|
const dir = storageDir(input.projectRoot, input.dataDir);
|
|
26629
|
-
await
|
|
26639
|
+
await mkdir21(dir, { recursive: true });
|
|
26630
26640
|
const mtimes = new Map;
|
|
26631
26641
|
for (const record of input.fileRecords) {
|
|
26632
26642
|
try {
|
|
@@ -26634,7 +26644,7 @@ async function enrichBuildWithWikiLayer(input) {
|
|
|
26634
26644
|
mtimes.set(record.path, info.mtimeMs);
|
|
26635
26645
|
} catch {}
|
|
26636
26646
|
}
|
|
26637
|
-
await
|
|
26647
|
+
await writeFile15(path102.join(dir, BUILD_MANIFEST_FILE), `${JSON.stringify({ version: 1, files: computeFingerprints(input.fileRecords, mtimes) }, null, 2)}
|
|
26638
26648
|
`, "utf8");
|
|
26639
26649
|
const validModules = input.validModules !== undefined ? input.validModules : await (input.loadValidModules ?? ((root) => defaultLoadValidModules(root, input.dataDir)))(input.projectRoot);
|
|
26640
26650
|
const wikiPages = await collectPages(input.projectRoot);
|
|
@@ -26755,7 +26765,7 @@ function personalizedPageRank(nodes, edges, options) {
|
|
|
26755
26765
|
}
|
|
26756
26766
|
|
|
26757
26767
|
// src/gdgraph/repomap.ts
|
|
26758
|
-
import { mkdir as
|
|
26768
|
+
import { mkdir as mkdir23, writeFile as writeFile17 } from "fs/promises";
|
|
26759
26769
|
import path105 from "path";
|
|
26760
26770
|
function estimateTokens2(text) {
|
|
26761
26771
|
return Math.ceil(text.length / 4);
|
|
@@ -26924,8 +26934,8 @@ function computeRepomap(graph, config, options = {}) {
|
|
|
26924
26934
|
async function writeRepomap(cwd, graph, config, options = {}) {
|
|
26925
26935
|
const result = computeRepomap(graph, config, options);
|
|
26926
26936
|
const artifactPath = repomapArtifactPath(cwd);
|
|
26927
|
-
await
|
|
26928
|
-
await
|
|
26937
|
+
await mkdir23(path105.dirname(artifactPath), { recursive: true });
|
|
26938
|
+
await writeFile17(artifactPath, result.content, "utf8");
|
|
26929
26939
|
return { ...result, path: artifactPath };
|
|
26930
26940
|
}
|
|
26931
26941
|
var HEADER2;
|
|
@@ -27275,7 +27285,7 @@ var init_preservation = __esm(() => {
|
|
|
27275
27285
|
});
|
|
27276
27286
|
|
|
27277
27287
|
// src/session/slate.ts
|
|
27278
|
-
import { mkdir as
|
|
27288
|
+
import { mkdir as mkdir32, readFile as readFile66, readdir as readdir23, stat as stat18 } from "fs/promises";
|
|
27279
27289
|
import path138 from "path";
|
|
27280
27290
|
function isSlateSeedKind(value) {
|
|
27281
27291
|
return typeof value === "string" && SLATE_SEED_KINDS.includes(value);
|
|
@@ -27297,7 +27307,7 @@ async function readSlate(dir) {
|
|
|
27297
27307
|
}
|
|
27298
27308
|
}
|
|
27299
27309
|
async function writeSlate(dir, update, signal) {
|
|
27300
|
-
await
|
|
27310
|
+
await mkdir32(dir, { recursive: true });
|
|
27301
27311
|
return withFileLock(slateLockPath(dir), async () => {
|
|
27302
27312
|
const prev = await readSlate(dir);
|
|
27303
27313
|
signal?.throwIfAborted();
|
|
@@ -27808,7 +27818,7 @@ function completionExceptionQuestion(id, selected, context) {
|
|
|
27808
27818
|
// src/flow/service.ts
|
|
27809
27819
|
init_fs();
|
|
27810
27820
|
init_validator();
|
|
27811
|
-
import { mkdir as
|
|
27821
|
+
import { mkdir as mkdir12, readFile as readFile39 } from "fs/promises";
|
|
27812
27822
|
import path78 from "path";
|
|
27813
27823
|
|
|
27814
27824
|
// src/flow/machine.ts
|
|
@@ -30331,7 +30341,7 @@ var identityCache = new Map;
|
|
|
30331
30341
|
// src/flow/store.ts
|
|
30332
30342
|
init_fs();
|
|
30333
30343
|
import { createHash as createHash7 } from "crypto";
|
|
30334
|
-
import { appendFile as appendFile2, mkdir as
|
|
30344
|
+
import { appendFile as appendFile2, mkdir as mkdir7, readFile as readFile21, readdir as readdir9 } from "fs/promises";
|
|
30335
30345
|
import path47 from "path";
|
|
30336
30346
|
function flowsRoot(cwd) {
|
|
30337
30347
|
return path47.join(cwd, ".metaproject", "flows");
|
|
@@ -30471,7 +30481,7 @@ function migrateTask(task, createdAt, history) {
|
|
|
30471
30481
|
}
|
|
30472
30482
|
async function writeFlow(cwd, dir, flow) {
|
|
30473
30483
|
const file = path47.join(flowsRoot(cwd), dir, "flow.json");
|
|
30474
|
-
await
|
|
30484
|
+
await mkdir7(path47.dirname(file), { recursive: true });
|
|
30475
30485
|
await writeFileAtomic(file, `${JSON.stringify(flow, null, 2)}
|
|
30476
30486
|
`);
|
|
30477
30487
|
}
|
|
@@ -30640,7 +30650,6 @@ var DECISION_SOURCES = {
|
|
|
30640
30650
|
hostQuestion: "host-question"
|
|
30641
30651
|
};
|
|
30642
30652
|
var WORK_DECISION_SOURCES = Object.values(DECISION_SOURCES);
|
|
30643
|
-
|
|
30644
30653
|
// src/decisions/quality.ts
|
|
30645
30654
|
var SHELL_OPERATORS = new Set(["|", "&", ";", "<", ">", "`", "(", ")"]);
|
|
30646
30655
|
|
|
@@ -30861,7 +30870,7 @@ function decisionWriters(kind, packageArg = "<review-dir>") {
|
|
|
30861
30870
|
|
|
30862
30871
|
// src/review/mutate.ts
|
|
30863
30872
|
import { constants as constants2, existsSync as existsSync7, writeFileSync as writeFileSync2 } from "fs";
|
|
30864
|
-
import { cp, lstat as lstat8, mkdir as
|
|
30873
|
+
import { cp, lstat as lstat8, mkdir as mkdir8, mkdtemp, open as open2, readFile as readFile22, readdir as readdir11, realpath as realpath12, rm as rm3, stat as stat10, symlink, utimes as utimes2, writeFile as writeFile5 } from "fs/promises";
|
|
30865
30874
|
import path50 from "path";
|
|
30866
30875
|
|
|
30867
30876
|
// src/lib/git-env.ts
|
|
@@ -34943,7 +34952,7 @@ async function intentNoteForNewFlow(cwd, dir) {
|
|
|
34943
34952
|
init_service2();
|
|
34944
34953
|
init_fs();
|
|
34945
34954
|
import { createHash as createHash11 } from "crypto";
|
|
34946
|
-
import { chmod as chmod4, mkdir as
|
|
34955
|
+
import { chmod as chmod4, mkdir as mkdir10, readFile as readFile33 } from "fs/promises";
|
|
34947
34956
|
import path70 from "path";
|
|
34948
34957
|
var AC_LINE2 = /^\s*[-*]\s*(AC\d+)\s*:\s?(.*)$/i;
|
|
34949
34958
|
function parseAcceptanceCriteria(content) {
|
|
@@ -35156,7 +35165,7 @@ async function readAcCheckCache(cachePath) {
|
|
|
35156
35165
|
}
|
|
35157
35166
|
}
|
|
35158
35167
|
async function writeAcCheckCache(cachePath, record) {
|
|
35159
|
-
await
|
|
35168
|
+
await mkdir10(path70.dirname(cachePath), { recursive: true });
|
|
35160
35169
|
await writeFileAtomic(cachePath, `${JSON.stringify(record, null, 2)}
|
|
35161
35170
|
`, { mode: 384 });
|
|
35162
35171
|
if (process.platform !== "win32") {
|
|
@@ -35213,7 +35222,7 @@ function renderAcCheckAdvisoryNotice(verdicts) {
|
|
|
35213
35222
|
return `acceptance-criteria check (advisory): ${counts.likelyMet} likely met, ${counts.notEvident} not evident, ${counts.notCheckable} not checkable` + (inDoubt.length > 0 ? ` \u2014 in doubt: ${inDoubt.join(", ")}` : "") + ` (\`keryx flow check-ac\` for detail)`;
|
|
35214
35223
|
}
|
|
35215
35224
|
// src/flow/allocation.ts
|
|
35216
|
-
import { appendFile as appendFile3, mkdir as
|
|
35225
|
+
import { appendFile as appendFile3, mkdir as mkdir11, readFile as readFile34 } from "fs/promises";
|
|
35217
35226
|
import path72 from "path";
|
|
35218
35227
|
|
|
35219
35228
|
// src/lib/clone-scope.ts
|
|
@@ -35304,7 +35313,7 @@ async function recordAllocation(scope, record) {
|
|
|
35304
35313
|
if (!scope.ledgerPath) {
|
|
35305
35314
|
return;
|
|
35306
35315
|
}
|
|
35307
|
-
await
|
|
35316
|
+
await mkdir11(path72.dirname(scope.ledgerPath), { recursive: true });
|
|
35308
35317
|
await appendFile3(scope.ledgerPath, `${JSON.stringify(record)}
|
|
35309
35318
|
`, "utf8");
|
|
35310
35319
|
}
|
|
@@ -36239,7 +36248,7 @@ function createFlowService(deps) {
|
|
|
36239
36248
|
if (await pathExists(absolute)) {
|
|
36240
36249
|
throw new Error(`Flow directory already exists: ${dir}`);
|
|
36241
36250
|
}
|
|
36242
|
-
await
|
|
36251
|
+
await mkdir12(absolute, { recursive: true });
|
|
36243
36252
|
const createdAt = now();
|
|
36244
36253
|
const flow = {
|
|
36245
36254
|
schemaVersion: 1,
|
|
@@ -37347,7 +37356,7 @@ async function acCriterionKnown(input) {
|
|
|
37347
37356
|
}
|
|
37348
37357
|
// src/gdgraph/build.ts
|
|
37349
37358
|
init_data_dir();
|
|
37350
|
-
import { mkdir as
|
|
37359
|
+
import { mkdir as mkdir22, readdir as readdir18, readFile as readFile51, writeFile as writeFile16 } from "fs/promises";
|
|
37351
37360
|
import { existsSync as existsSync11 } from "fs";
|
|
37352
37361
|
import path103 from "path";
|
|
37353
37362
|
|
|
@@ -37875,20 +37884,20 @@ function isRecord5(value) {
|
|
|
37875
37884
|
async function writeGraph(projectRoot, graph, dataDir) {
|
|
37876
37885
|
const storageDir = gdgraphStorageDir(projectRoot, dataDir);
|
|
37877
37886
|
const artifactsDir = gdgraphArtifactsDir(projectRoot, dataDir);
|
|
37878
|
-
await
|
|
37879
|
-
await
|
|
37880
|
-
await
|
|
37887
|
+
await mkdir22(storageDir, { recursive: true });
|
|
37888
|
+
await mkdir22(artifactsDir, { recursive: true });
|
|
37889
|
+
await writeFile16(path103.join(storageDir, "nodes.jsonl"), graph.nodes.map((node) => JSON.stringify(node)).join(`
|
|
37881
37890
|
`) + `
|
|
37882
37891
|
`, "utf8");
|
|
37883
|
-
await
|
|
37892
|
+
await writeFile16(path103.join(storageDir, "edges.jsonl"), graph.edges.map((edge) => JSON.stringify(edge)).join(`
|
|
37884
37893
|
`) + `
|
|
37885
37894
|
`, "utf8");
|
|
37886
|
-
await
|
|
37895
|
+
await writeFile16(path103.join(artifactsDir, "module-map.json"), JSON.stringify(buildModuleMap(graph), null, 2) + `
|
|
37887
37896
|
`, "utf8");
|
|
37888
37897
|
}
|
|
37889
37898
|
async function writeSummary(projectRoot, graph, collection, dataDir) {
|
|
37890
37899
|
const artifactsDir = gdgraphArtifactsDir(projectRoot, dataDir);
|
|
37891
|
-
await
|
|
37900
|
+
await mkdir22(artifactsDir, { recursive: true });
|
|
37892
37901
|
const unresolved = graph.edges.filter((edge) => edge.kind === "unresolved");
|
|
37893
37902
|
const imports = graph.edges.filter((edge) => edge.kind === "imports");
|
|
37894
37903
|
const assets = graph.edges.filter((edge) => edge.kind === "asset");
|
|
@@ -37947,7 +37956,7 @@ keryx gdgraph query orphans
|
|
|
37947
37956
|
keryx gdgraph affected <file>
|
|
37948
37957
|
\`\`\`
|
|
37949
37958
|
`;
|
|
37950
|
-
await
|
|
37959
|
+
await writeFile16(summaryPath, content, "utf8");
|
|
37951
37960
|
return summaryPath;
|
|
37952
37961
|
}
|
|
37953
37962
|
function buildModuleMap(graph) {
|
|
@@ -38241,7 +38250,7 @@ init_section_tombstone();
|
|
|
38241
38250
|
|
|
38242
38251
|
// src/forgetting/journal.ts
|
|
38243
38252
|
init_fs();
|
|
38244
|
-
import { appendFile as appendFile5, mkdir as
|
|
38253
|
+
import { appendFile as appendFile5, mkdir as mkdir24, readFile as readFile53, stat as stat16 } from "fs/promises";
|
|
38245
38254
|
import path106 from "path";
|
|
38246
38255
|
function forgettingDataDir(cwd) {
|
|
38247
38256
|
return path106.join(cwd, ".metaproject", "data", "forgetting");
|
|
@@ -38774,7 +38783,7 @@ async function loadHealthConfig(cwd) {
|
|
|
38774
38783
|
|
|
38775
38784
|
// src/health/run.ts
|
|
38776
38785
|
init_fs();
|
|
38777
|
-
import { mkdir as
|
|
38786
|
+
import { mkdir as mkdir28, writeFile as writeFile21 } from "fs/promises";
|
|
38778
38787
|
import path125 from "path";
|
|
38779
38788
|
|
|
38780
38789
|
// src/metrics/provenance.ts
|
|
@@ -38892,7 +38901,7 @@ import path110 from "path";
|
|
|
38892
38901
|
|
|
38893
38902
|
// src/health/util.ts
|
|
38894
38903
|
init_fs();
|
|
38895
|
-
import { mkdir as
|
|
38904
|
+
import { mkdir as mkdir25, readFile as readFile54, readdir as readdir19, writeFile as writeFile18 } from "fs/promises";
|
|
38896
38905
|
import path108 from "path";
|
|
38897
38906
|
var IGNORED_DIRS = new Set([
|
|
38898
38907
|
"node_modules",
|
|
@@ -38941,9 +38950,9 @@ function dataRoot3(cwd) {
|
|
|
38941
38950
|
}
|
|
38942
38951
|
async function writeRaw(cwd, source, content, stamp) {
|
|
38943
38952
|
const dir = path108.join(dataRoot3(cwd), "raw", source);
|
|
38944
|
-
await
|
|
38953
|
+
await mkdir25(dir, { recursive: true });
|
|
38945
38954
|
const file = path108.join(dir, `${stamp}.log`);
|
|
38946
|
-
await
|
|
38955
|
+
await writeFile18(file, content, "utf8");
|
|
38947
38956
|
return path108.relative(cwd, file);
|
|
38948
38957
|
}
|
|
38949
38958
|
async function listSourceFiles(cwd, ignorePaths = []) {
|
|
@@ -39458,7 +39467,7 @@ function tally2(values) {
|
|
|
39458
39467
|
|
|
39459
39468
|
// src/health/baseline.ts
|
|
39460
39469
|
init_fs();
|
|
39461
|
-
import { mkdir as
|
|
39470
|
+
import { mkdir as mkdir26, readFile as readFile56, writeFile as writeFile19 } from "fs/promises";
|
|
39462
39471
|
import path111 from "path";
|
|
39463
39472
|
var LEGACY_BASELINE_SOURCES = Object.freeze([
|
|
39464
39473
|
"complexity",
|
|
@@ -39505,8 +39514,8 @@ async function loadBaselineSources(cwd) {
|
|
|
39505
39514
|
}
|
|
39506
39515
|
async function writeBaselineFile(cwd, data) {
|
|
39507
39516
|
const file = baselinePath(cwd);
|
|
39508
|
-
await
|
|
39509
|
-
await
|
|
39517
|
+
await mkdir26(path111.dirname(file), { recursive: true });
|
|
39518
|
+
await writeFile19(file, `${JSON.stringify(data, null, 2)}
|
|
39510
39519
|
`, "utf8");
|
|
39511
39520
|
}
|
|
39512
39521
|
async function loadBaseline(cwd) {
|
|
@@ -40292,7 +40301,7 @@ async function isTestingCapabilityEnabled(cwd, capability) {
|
|
|
40292
40301
|
// src/testing/coverage-map.ts
|
|
40293
40302
|
init_fs();
|
|
40294
40303
|
init_guard();
|
|
40295
|
-
import { readFile as readFile60, mkdir as
|
|
40304
|
+
import { readFile as readFile60, mkdir as mkdir27, writeFile as writeFile20 } from "fs/promises";
|
|
40296
40305
|
import path121 from "path";
|
|
40297
40306
|
var COVERAGE_MAP_SCHEMA_VERSION = 1;
|
|
40298
40307
|
function coverageMapPath(cwd, cfg) {
|
|
@@ -42029,14 +42038,14 @@ function filteredInfo(source, cfg) {
|
|
|
42029
42038
|
async function writeOutputs(cwd, report, config, stamp) {
|
|
42030
42039
|
const artifacts = path125.join(dataRoot3(cwd), "artifacts");
|
|
42031
42040
|
const history = path125.join(dataRoot3(cwd), "history");
|
|
42032
|
-
await
|
|
42033
|
-
await
|
|
42041
|
+
await mkdir28(artifacts, { recursive: true });
|
|
42042
|
+
await mkdir28(history, { recursive: true });
|
|
42034
42043
|
const markdown = path125.join(artifacts, "latest.md");
|
|
42035
42044
|
const json = path125.join(artifacts, "latest.json");
|
|
42036
42045
|
const historyJson = path125.join(history, `${stamp}.json`);
|
|
42037
42046
|
const serialized = `${JSON.stringify(report, null, 2)}
|
|
42038
42047
|
`;
|
|
42039
|
-
await
|
|
42048
|
+
await writeFile21(markdown, renderReportMarkdown2(report, config), "utf8");
|
|
42040
42049
|
if (report.runId) {
|
|
42041
42050
|
const runJson = path125.join(artifacts, "runs", `${report.runId}.json`);
|
|
42042
42051
|
const runMarkdown = path125.join(artifacts, "runs", `${report.runId}.md`);
|
|
@@ -42054,9 +42063,9 @@ async function writeOutputs(cwd, report, config, stamp) {
|
|
|
42054
42063
|
}, null, 2)}
|
|
42055
42064
|
`);
|
|
42056
42065
|
} else {
|
|
42057
|
-
await
|
|
42066
|
+
await writeFile21(json, serialized, "utf8");
|
|
42058
42067
|
}
|
|
42059
|
-
await
|
|
42068
|
+
await writeFile21(historyJson, serialized, "utf8");
|
|
42060
42069
|
return {
|
|
42061
42070
|
markdownPath: path125.relative(cwd, markdown),
|
|
42062
42071
|
jsonPath: path125.relative(cwd, json)
|
|
@@ -42752,7 +42761,7 @@ function hostDeliveryStatus() {
|
|
|
42752
42761
|
}
|
|
42753
42762
|
// src/job/service.ts
|
|
42754
42763
|
init_fs();
|
|
42755
|
-
import { copyFile, mkdir as
|
|
42764
|
+
import { copyFile, mkdir as mkdir30 } from "fs/promises";
|
|
42756
42765
|
import path131 from "path";
|
|
42757
42766
|
|
|
42758
42767
|
// src/job/types.ts
|
|
@@ -42893,7 +42902,7 @@ function defaultPlan(intent) {
|
|
|
42893
42902
|
init_validator();
|
|
42894
42903
|
init_contracts();
|
|
42895
42904
|
init_fs();
|
|
42896
|
-
import { appendFile as appendFile6, mkdir as
|
|
42905
|
+
import { appendFile as appendFile6, mkdir as mkdir29, readFile as readFile63, readdir as readdir21 } from "fs/promises";
|
|
42897
42906
|
import path130 from "path";
|
|
42898
42907
|
function jobsRoot(cwd) {
|
|
42899
42908
|
return path130.join(cwd, ".metaproject", "jobs");
|
|
@@ -42939,7 +42948,7 @@ async function writeJob(cwd, name, state) {
|
|
|
42939
42948
|
`));
|
|
42940
42949
|
}
|
|
42941
42950
|
const file = jobStatePath(cwd, name);
|
|
42942
|
-
await
|
|
42951
|
+
await mkdir29(path130.dirname(file), { recursive: true });
|
|
42943
42952
|
await writeFileAtomic(file, `${JSON.stringify(state, null, 2)}
|
|
42944
42953
|
`);
|
|
42945
42954
|
}
|
|
@@ -43011,7 +43020,7 @@ function createJobService(deps) {
|
|
|
43011
43020
|
if (await pathExists(absolute)) {
|
|
43012
43021
|
throw new Error(`Job package already exists: .metaproject/jobs/${name}. ` + `Run: keryx job status ${name}`);
|
|
43013
43022
|
}
|
|
43014
|
-
await
|
|
43023
|
+
await mkdir30(absolute, { recursive: true });
|
|
43015
43024
|
const createdAt = now();
|
|
43016
43025
|
const state = {
|
|
43017
43026
|
phase: "PLAN",
|
|
@@ -43224,7 +43233,7 @@ function sessionDir(projectPath, sessionId, dataDir) {
|
|
|
43224
43233
|
// src/sac/proposal-lifecycle.ts
|
|
43225
43234
|
init_fs();
|
|
43226
43235
|
import { createHash as createHash32, randomUUID as randomUUID7 } from "crypto";
|
|
43227
|
-
import { appendFile as appendFile7, mkdir as
|
|
43236
|
+
import { appendFile as appendFile7, mkdir as mkdir34, readdir as readdir25, readFile as readFile73 } from "fs/promises";
|
|
43228
43237
|
import path145 from "path";
|
|
43229
43238
|
|
|
43230
43239
|
// src/sac/index.ts
|
|
@@ -44040,7 +44049,7 @@ async function evaluateStrictSacGuard(input) {
|
|
|
44040
44049
|
|
|
44041
44050
|
// src/sac/workspace-service.ts
|
|
44042
44051
|
init_fs();
|
|
44043
|
-
import { mkdir as
|
|
44052
|
+
import { mkdir as mkdir31, readdir as readdir22, readFile as readFile65 } from "fs/promises";
|
|
44044
44053
|
import { createHash as createHash25, randomUUID as randomUUID4 } from "crypto";
|
|
44045
44054
|
import path137 from "path";
|
|
44046
44055
|
|
|
@@ -44099,7 +44108,7 @@ class WorkspaceService {
|
|
|
44099
44108
|
if (input.component)
|
|
44100
44109
|
manifest.resources = [await this.pinResource(input.component)];
|
|
44101
44110
|
const dir = this.workspaceDir(manifest.id);
|
|
44102
|
-
await
|
|
44111
|
+
await mkdir31(this.storageRoot, { recursive: true, mode: 448 });
|
|
44103
44112
|
await withFileLock(this.lockPath(manifest.id), async () => {
|
|
44104
44113
|
try {
|
|
44105
44114
|
await readFile65(this.manifestPath(manifest.id), "utf8");
|
|
@@ -44108,7 +44117,7 @@ class WorkspaceService {
|
|
|
44108
44117
|
if (error instanceof WorkspaceServiceError || !isNotFound(error))
|
|
44109
44118
|
throw error;
|
|
44110
44119
|
}
|
|
44111
|
-
await
|
|
44120
|
+
await mkdir31(dir, { recursive: true, mode: 448 });
|
|
44112
44121
|
await writeFileAtomic(this.manifestPath(manifest.id), `${JSON.stringify(manifest, null, 2)}
|
|
44113
44122
|
`);
|
|
44114
44123
|
});
|
|
@@ -44127,7 +44136,7 @@ class WorkspaceService {
|
|
|
44127
44136
|
}
|
|
44128
44137
|
async enumerateVisible(actor, includeArchived) {
|
|
44129
44138
|
try {
|
|
44130
|
-
await
|
|
44139
|
+
await mkdir31(this.storageRoot, { recursive: true, mode: 448 });
|
|
44131
44140
|
} catch {
|
|
44132
44141
|
return [];
|
|
44133
44142
|
}
|
|
@@ -44529,7 +44538,7 @@ function bindingHash(owner, intent) {
|
|
|
44529
44538
|
|
|
44530
44539
|
// src/sac/session-wrap-up.ts
|
|
44531
44540
|
import { createHash as createHash28 } from "crypto";
|
|
44532
|
-
import { mkdir as
|
|
44541
|
+
import { mkdir as mkdir33, writeFile as writeFile22 } from "fs/promises";
|
|
44533
44542
|
import path140 from "path";
|
|
44534
44543
|
|
|
44535
44544
|
// src/session/store.ts
|
|
@@ -44913,12 +44922,12 @@ async function resolveSessionWrapUp(input) {
|
|
|
44913
44922
|
if (!floor.ok)
|
|
44914
44923
|
throw new SessionWrapUpError("security_denied", floor.reason);
|
|
44915
44924
|
const [safeSession, safeWrapUp, safeDiff] = floor.bodies;
|
|
44916
|
-
await
|
|
44917
|
-
await
|
|
44918
|
-
await
|
|
44919
|
-
await
|
|
44925
|
+
await mkdir33(path140.join(input.cwd, evidenceDir), { recursive: true });
|
|
44926
|
+
await writeFile22(path140.join(input.cwd, relPath), safeSession.content, "utf8");
|
|
44927
|
+
await writeFile22(path140.join(input.cwd, wrapUpRelPath), safeWrapUp.content, "utf8");
|
|
44928
|
+
await writeFile22(path140.join(input.cwd, diffRelPath), safeDiff.content, "utf8");
|
|
44920
44929
|
if (floor.notice !== undefined)
|
|
44921
|
-
await
|
|
44930
|
+
await writeFile22(path140.join(input.cwd, noticeRelPath), floor.notice, "utf8");
|
|
44922
44931
|
const observedAt = now().toISOString();
|
|
44923
44932
|
const evidence = [
|
|
44924
44933
|
{ kind: "wrap-up", uri: `./${wrapUpRelPath}`, revision: createHash28("sha256").update(safeWrapUp.content).digest("hex"), observedAt },
|
|
@@ -45670,7 +45679,7 @@ class ProposalLifecycleService {
|
|
|
45670
45679
|
if (manifest.status === "archived")
|
|
45671
45680
|
throw new ProposalLifecycleError("guard_denied", "workspace is archived");
|
|
45672
45681
|
const file = this.proposalPath(workspaceId, proposal.id);
|
|
45673
|
-
await
|
|
45682
|
+
await mkdir34(path145.dirname(file), { recursive: true, mode: 448 });
|
|
45674
45683
|
return withFileLock(`${file}.lock`, async () => {
|
|
45675
45684
|
const consume = this.options.wrapUpAuthority.consume(input.wrapUp, { actor, workspaceId });
|
|
45676
45685
|
if (consume !== "ok")
|
|
@@ -45698,7 +45707,7 @@ class ProposalLifecycleService {
|
|
|
45698
45707
|
return this.options.workspaces.withAuthorizedActor({ actorContext: actor, workspaceId: input.workspaceId, action: "review", execute: async (manifest) => {
|
|
45699
45708
|
const proposal = await this.loadProposal(input.workspaceId, input.proposalId);
|
|
45700
45709
|
const ledger = this.ledgerPath(input.workspaceId);
|
|
45701
|
-
await
|
|
45710
|
+
await mkdir34(path145.dirname(ledger), { recursive: true, mode: 448 });
|
|
45702
45711
|
return withFileLock(`${ledger}.lock`, async () => {
|
|
45703
45712
|
const records = (await this.records(ledger)).filter((record) => record.proposalId === proposal.id);
|
|
45704
45713
|
const events = records.filter((record) => record.recordType === "proposal-transition");
|
|
@@ -46354,7 +46363,7 @@ async function boundedReplay(input, scan) {
|
|
|
46354
46363
|
// src/sac/fwk-service.ts
|
|
46355
46364
|
import { createHash as createHash35, randomUUID as randomUUID9 } from "crypto";
|
|
46356
46365
|
init_assembly();
|
|
46357
|
-
import { appendFile as appendFile8, mkdir as
|
|
46366
|
+
import { appendFile as appendFile8, mkdir as mkdir35, open as open5, readFile as readFile74, rename as rename7, rm as rm8, stat as stat19, writeFile as writeFile23 } from "fs/promises";
|
|
46358
46367
|
import path147 from "path";
|
|
46359
46368
|
init_fs();
|
|
46360
46369
|
|
|
@@ -46981,7 +46990,7 @@ async function writeCheckpoint(checkpointPath, body) {
|
|
|
46981
46990
|
const temporary = `${checkpointPath}.${process.pid}.${randomUUID9()}.tmp`;
|
|
46982
46991
|
const checkpoint = { ...body, integrity: { checkpointHash: checkpointHash(body) } };
|
|
46983
46992
|
try {
|
|
46984
|
-
await
|
|
46993
|
+
await writeFile23(temporary, `${JSON.stringify(checkpoint)}
|
|
46985
46994
|
`, { mode: 384, flag: "wx" });
|
|
46986
46995
|
await rename7(temporary, checkpointPath);
|
|
46987
46996
|
} catch (error) {
|
|
@@ -47298,7 +47307,7 @@ class FwkReadService {
|
|
|
47298
47307
|
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"}` } : {} };
|
|
47299
47308
|
const ledger = path147.join(this.options.canonical.workspaceRoot, ".metaproject", "context-operations", "access-receipts.jsonl");
|
|
47300
47309
|
const checkpointPath = path147.join(path147.dirname(ledger), "access-receipts.checkpoint.json");
|
|
47301
|
-
await
|
|
47310
|
+
await mkdir35(path147.dirname(ledger), { recursive: true, mode: 448 });
|
|
47302
47311
|
return withFileLock(`${ledger}.lock`, async () => {
|
|
47303
47312
|
const state = await resolveLedgerState(ledger, checkpointPath, this.options.verifyReceiptLedger ?? verifyAccessReceiptLedger);
|
|
47304
47313
|
const receipt = sealAccessReceipt(base, state.headHash);
|
|
@@ -47401,7 +47410,7 @@ function normalizeFwkResult(result) {
|
|
|
47401
47410
|
// src/sac/propose-from-session.ts
|
|
47402
47411
|
init_guard();
|
|
47403
47412
|
import { randomUUID as randomUUID10 } from "crypto";
|
|
47404
|
-
import { writeFile as
|
|
47413
|
+
import { writeFile as writeFile24 } from "fs/promises";
|
|
47405
47414
|
async function proposeFromSession(input) {
|
|
47406
47415
|
const { cwd, workspaceId, kind, sessionRef } = input;
|
|
47407
47416
|
const session = findSession(cwd, sessionRef);
|
|
@@ -47430,11 +47439,11 @@ async function proposeFromSession(input) {
|
|
|
47430
47439
|
wrapUp
|
|
47431
47440
|
});
|
|
47432
47441
|
if (persistedNote)
|
|
47433
|
-
await
|
|
47442
|
+
await writeFile24(notePath, persistedNote, "utf8");
|
|
47434
47443
|
return { ok: true, result: normalizeProposalLifecycleResult(proposal) };
|
|
47435
47444
|
}
|
|
47436
47445
|
// src/sac/collaboration-service.ts
|
|
47437
|
-
import { appendFile as appendFile9, mkdir as
|
|
47446
|
+
import { appendFile as appendFile9, mkdir as mkdir36, readFile as readFile75 } from "fs/promises";
|
|
47438
47447
|
import { randomUUID as randomUUID11 } from "crypto";
|
|
47439
47448
|
import path148 from "path";
|
|
47440
47449
|
class CollaborationServiceError extends Error {
|
|
@@ -47488,7 +47497,7 @@ class CollaborationService {
|
|
|
47488
47497
|
occurredAt: (this.input.now ?? (() => new Date))().toISOString(),
|
|
47489
47498
|
...suppliedHandoff ? { handoff: { ...suppliedHandoff, from: actor.subject } } : {}
|
|
47490
47499
|
});
|
|
47491
|
-
await
|
|
47500
|
+
await mkdir36(path148.dirname(this.file(manifest.id)), { recursive: true, mode: 448 });
|
|
47492
47501
|
await appendFile9(this.file(manifest.id), `${JSON.stringify(activity)}
|
|
47493
47502
|
`, { mode: 384 });
|
|
47494
47503
|
return normalizeCollaborationResult(activity);
|
|
@@ -47537,14 +47546,14 @@ function normalizeCollaborationResult(value) {
|
|
|
47537
47546
|
}
|
|
47538
47547
|
// src/session/external-slate.ts
|
|
47539
47548
|
init_fs();
|
|
47540
|
-
import { mkdir as
|
|
47549
|
+
import { mkdir as mkdir38, readdir as readdir27, readFile as readFile76 } from "fs/promises";
|
|
47541
47550
|
import path150 from "path";
|
|
47542
47551
|
|
|
47543
47552
|
// src/sac/machine-wrap-up.ts
|
|
47544
47553
|
init_fs();
|
|
47545
47554
|
init_slate();
|
|
47546
47555
|
import { createHash as createHash36, randomUUID as randomUUID13 } from "crypto";
|
|
47547
|
-
import { mkdir as
|
|
47556
|
+
import { mkdir as mkdir37 } from "fs/promises";
|
|
47548
47557
|
import path149 from "path";
|
|
47549
47558
|
|
|
47550
47559
|
// src/sac/workspace-resolve.ts
|
|
@@ -47747,7 +47756,7 @@ ${safeSeeds.content}`;
|
|
|
47747
47756
|
summary = result.text.trim().length > 0 ? result.text.trim() : mechanicalSummary(summaryDiff, course);
|
|
47748
47757
|
}
|
|
47749
47758
|
const evidenceDir = path149.join(input.cwd, ".metaproject", "workspaces", input.workspaceId, "machine-evidence");
|
|
47750
|
-
await
|
|
47759
|
+
await mkdir37(evidenceDir, { recursive: true });
|
|
47751
47760
|
const diffFile = `${input.kind}.${shortHash}.diff.txt`;
|
|
47752
47761
|
const flowFile = `${input.kind}.${shortHash}.flow.json`;
|
|
47753
47762
|
const seedsFile = `${input.kind}.${shortHash}.seeds.json`;
|
|
@@ -47790,7 +47799,7 @@ async function writeFlooredArchiveArtifact(params) {
|
|
|
47790
47799
|
return { ok: false, code: "security_denied", detail: floor.reason };
|
|
47791
47800
|
const body = floor.bodies[0];
|
|
47792
47801
|
const archiveDir = path149.join(params.dir, "slate-archive");
|
|
47793
|
-
await
|
|
47802
|
+
await mkdir37(archiveDir, { recursive: true });
|
|
47794
47803
|
await writeFileAtomic(path149.join(archiveDir, params.filename), body.content);
|
|
47795
47804
|
if (floor.notice !== undefined) {
|
|
47796
47805
|
await writeFileAtomic(path149.join(archiveDir, `${params.filename}${ARCHIVE_REDACTION_NOTICE_SUFFIX}`), floor.notice);
|
|
@@ -47830,7 +47839,7 @@ async function writeWrapUpOutcomeArtifact(cwd, dir, trigger, now, groups) {
|
|
|
47830
47839
|
const refusalIso = now().toISOString();
|
|
47831
47840
|
const refusalFilename = `${refusalIso.replace(/[:.]/g, "-")}-wrap-up-outcome.json`;
|
|
47832
47841
|
const archiveDir = path149.join(dir, "slate-archive");
|
|
47833
|
-
await
|
|
47842
|
+
await mkdir37(archiveDir, { recursive: true });
|
|
47834
47843
|
await writeFileAtomic(path149.join(archiveDir, refusalFilename), `${JSON.stringify({
|
|
47835
47844
|
recordType: "wrap-up-outcome",
|
|
47836
47845
|
trigger,
|
|
@@ -47998,7 +48007,7 @@ async function readExternalSlate(cwd, externalSessionId) {
|
|
|
47998
48007
|
}
|
|
47999
48008
|
}
|
|
48000
48009
|
async function writeExternalSlate(cwd, externalSessionId, update) {
|
|
48001
|
-
await
|
|
48010
|
+
await mkdir38(externalSlatesDir(cwd), { recursive: true });
|
|
48002
48011
|
return withFileLock(externalSlateLockPath(cwd, externalSessionId), async () => {
|
|
48003
48012
|
const prev = await readExternalSlate(cwd, externalSessionId);
|
|
48004
48013
|
const next = update(prev);
|
|
@@ -48024,7 +48033,7 @@ function isExternalSlateStale(slate, now = () => new Date) {
|
|
|
48024
48033
|
return now().getTime() - lastWriteMs > DEFAULT_LOCK_STALE_MS;
|
|
48025
48034
|
}
|
|
48026
48035
|
async function closeExternalSlate(cwd, externalSessionId, trigger, now = () => new Date) {
|
|
48027
|
-
await
|
|
48036
|
+
await mkdir38(externalSlatesDir(cwd), { recursive: true });
|
|
48028
48037
|
return withFileLock(externalSlateLockPath(cwd, externalSessionId), async () => {
|
|
48029
48038
|
const external = await readExternalSlate(cwd, externalSessionId);
|
|
48030
48039
|
if (!external || external.closedAt !== undefined)
|
|
@@ -49321,6 +49330,12 @@ var HELP_GROUPS = [
|
|
|
49321
49330
|
group: "Maintenance and diagnostics",
|
|
49322
49331
|
summary: "Read the deletion trail \u2014 was this removed, or did it never exist?"
|
|
49323
49332
|
},
|
|
49333
|
+
{
|
|
49334
|
+
kind: "cli",
|
|
49335
|
+
name: "worktree",
|
|
49336
|
+
group: "Managed work",
|
|
49337
|
+
summary: "Ready a linked git worktree (env files, dependencies, ports, memory index) and carry its findings out before removal."
|
|
49338
|
+
},
|
|
49324
49339
|
{
|
|
49325
49340
|
kind: "cli",
|
|
49326
49341
|
name: "commands",
|