teamtrail 0.61.0 → 0.61.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js
CHANGED
|
@@ -11223,9 +11223,9 @@ var deliverySource = {
|
|
|
11223
11223
|
// ../core/src/attention/escapeRule.ts
|
|
11224
11224
|
var MAX_GLOBS = 5;
|
|
11225
11225
|
var PLAIN_PATH = /^[\w./@+-]+$/;
|
|
11226
|
-
function globOf(
|
|
11227
|
-
const at2 =
|
|
11228
|
-
return at2 > 0 ? `${
|
|
11226
|
+
function globOf(file9) {
|
|
11227
|
+
const at2 = file9.lastIndexOf("/");
|
|
11228
|
+
return at2 > 0 ? `${file9.slice(0, at2)}/**` : file9;
|
|
11229
11229
|
}
|
|
11230
11230
|
function escapeRule(e) {
|
|
11231
11231
|
const plain2 = e.files.filter((f) => PLAIN_PATH.test(f) && !f.split("/").includes(".."));
|
|
@@ -12900,8 +12900,8 @@ function serializeMapFile(m) {
|
|
|
12900
12900
|
}
|
|
12901
12901
|
|
|
12902
12902
|
// ../core/src/adapters/markdown/unreadDecision.ts
|
|
12903
|
-
function unreadDecision(
|
|
12904
|
-
if (e.code !== "ENOENT") console.warn(`Teamtrail: decision ${
|
|
12903
|
+
function unreadDecision(file9, e) {
|
|
12904
|
+
if (e.code !== "ENOENT") console.warn(`Teamtrail: decision ${file9} can't be read: ${e.message}`);
|
|
12905
12905
|
return void 0;
|
|
12906
12906
|
}
|
|
12907
12907
|
|
|
@@ -13056,9 +13056,9 @@ var MarkdownAdapter = class {
|
|
|
13056
13056
|
}
|
|
13057
13057
|
async createDecision(mapId, input2) {
|
|
13058
13058
|
const d = await this.putNew(async () => {
|
|
13059
|
-
const
|
|
13060
|
-
this.external.remember(
|
|
13061
|
-
return
|
|
13059
|
+
const file9 = await newDecisionFile(this.fs, mapId, input2);
|
|
13060
|
+
this.external.remember(file9.path, file9.text);
|
|
13061
|
+
return file9;
|
|
13062
13062
|
});
|
|
13063
13063
|
this.events.emit({ kind: "decision.recorded", mapId, decisionId: d.id, ticketId: d.ticketId, at: Date.now() });
|
|
13064
13064
|
return d;
|
|
@@ -16631,26 +16631,26 @@ function costShares(tickets2, sessions) {
|
|
|
16631
16631
|
return share;
|
|
16632
16632
|
}
|
|
16633
16633
|
function row2(key, items, minSample, extra = {}) {
|
|
16634
|
-
const
|
|
16634
|
+
const verified2 = items.filter((i) => i.t.verified);
|
|
16635
16635
|
const firstTime = items.filter((i) => i.t.verified && i.t.attempts.length === 1 && i.t.attempts[0].result === "pass");
|
|
16636
16636
|
const costUsd = items.reduce((n, i) => n + i.costUsd, 0);
|
|
16637
16637
|
const findings = { info: 0, warn: 0, error: 0 };
|
|
16638
16638
|
for (const { t } of items) for (const k of ["info", "warn", "error"]) findings[k] += t.findings[k];
|
|
16639
|
-
const attempts =
|
|
16639
|
+
const attempts = verified2.reduce((n, i) => n + i.t.attempts.length, 0);
|
|
16640
16640
|
const everVerified = items.filter((i) => i.t.verified || i.t.escaped).length;
|
|
16641
16641
|
const escaped3 = items.filter((i) => i.t.escaped).length;
|
|
16642
16642
|
return {
|
|
16643
16643
|
key,
|
|
16644
16644
|
...extra,
|
|
16645
16645
|
tickets: items.length,
|
|
16646
|
-
verified:
|
|
16646
|
+
verified: verified2.length,
|
|
16647
16647
|
verifiedFirstTime: firstTime.length,
|
|
16648
16648
|
firstTimeRate: items.length ? round2(firstTime.length / items.length, 3) : 0,
|
|
16649
16649
|
reworkRate: items.length ? round2(items.filter((i) => i.t.attempts.length > 1).length / items.length, 3) : 0,
|
|
16650
|
-
attemptsPerVerified:
|
|
16650
|
+
attemptsPerVerified: verified2.length ? round2(attempts / verified2.length, 2) : void 0,
|
|
16651
16651
|
costUsd: round2(costUsd, 4),
|
|
16652
|
-
costPerVerifiedUsd:
|
|
16653
|
-
medianLeadMs: median2(
|
|
16652
|
+
costPerVerifiedUsd: verified2.length && costUsd ? round2(costUsd / verified2.length, 4) : void 0,
|
|
16653
|
+
medianLeadMs: median2(verified2.flatMap((i) => i.t.leadMs === void 0 ? [] : [i.t.leadMs])),
|
|
16654
16654
|
findings,
|
|
16655
16655
|
escaped: escaped3,
|
|
16656
16656
|
escapeRate: everVerified ? round2(escaped3 / everVerified, 3) : void 0,
|
|
@@ -17095,8 +17095,8 @@ var inode = (p) => {
|
|
|
17095
17095
|
return void 0;
|
|
17096
17096
|
}
|
|
17097
17097
|
};
|
|
17098
|
-
function withFileLock(
|
|
17099
|
-
const lock = `${
|
|
17098
|
+
function withFileLock(file9, fn) {
|
|
17099
|
+
const lock = `${file9}.lock`;
|
|
17100
17100
|
const token = `${process.pid}.${randomBytes(8).toString("hex")}`;
|
|
17101
17101
|
const until = Date.now() + WAIT_MS;
|
|
17102
17102
|
for (; ; ) {
|
|
@@ -17109,7 +17109,7 @@ function withFileLock(file10, fn) {
|
|
|
17109
17109
|
if (e.code !== "EEXIST") throw e;
|
|
17110
17110
|
const seen2 = inode(lock);
|
|
17111
17111
|
if (seen2?.old) removeIf(lock, (moved) => statSync2(moved).ino === seen2.ino);
|
|
17112
|
-
else if (Date.now() > until) throw new Error(`${
|
|
17112
|
+
else if (Date.now() > until) throw new Error(`${file9} is locked by another process`);
|
|
17113
17113
|
else Atomics.wait(pause, 0, 0, 5);
|
|
17114
17114
|
}
|
|
17115
17115
|
}
|
|
@@ -17129,10 +17129,10 @@ function ensurePrivateDir(dir4) {
|
|
|
17129
17129
|
if ((statSync3(dir4).mode & 63) !== 0) chmodSync(dir4, 448);
|
|
17130
17130
|
for (const name2 of readdirSync(dir4)) tighten(`${dir4}/${name2}`);
|
|
17131
17131
|
}
|
|
17132
|
-
function tighten(
|
|
17132
|
+
function tighten(file9) {
|
|
17133
17133
|
try {
|
|
17134
|
-
const st = statSync3(
|
|
17135
|
-
if (st.isFile() && (st.mode & 63) !== 0) chmodSync(
|
|
17134
|
+
const st = statSync3(file9);
|
|
17135
|
+
if (st.isFile() && (st.mode & 63) !== 0) chmodSync(file9, 384);
|
|
17136
17136
|
} catch {
|
|
17137
17137
|
}
|
|
17138
17138
|
}
|
|
@@ -17152,36 +17152,36 @@ function configDir(env = process.env) {
|
|
|
17152
17152
|
const base2 = env.XDG_CONFIG_HOME || process.platform === "win32" && env.APPDATA || path2.join(os.homedir(), ".config");
|
|
17153
17153
|
return path2.join(base2, BRAND.slug);
|
|
17154
17154
|
}
|
|
17155
|
-
function readJson(
|
|
17155
|
+
function readJson(file9, fallback) {
|
|
17156
17156
|
try {
|
|
17157
|
-
return { ...fallback, ...parseJsonSafe(readFileSync2(
|
|
17157
|
+
return { ...fallback, ...parseJsonSafe(readFileSync2(file9, "utf8")) };
|
|
17158
17158
|
} catch {
|
|
17159
17159
|
return fallback;
|
|
17160
17160
|
}
|
|
17161
17161
|
}
|
|
17162
|
-
function writeJson(
|
|
17163
|
-
if (secret) ensurePrivateDir(path2.dirname(
|
|
17164
|
-
else mkdirSync2(path2.dirname(
|
|
17165
|
-
const tmp = `${
|
|
17162
|
+
function writeJson(file9, value, secret = false) {
|
|
17163
|
+
if (secret) ensurePrivateDir(path2.dirname(file9));
|
|
17164
|
+
else mkdirSync2(path2.dirname(file9), { recursive: true });
|
|
17165
|
+
const tmp = `${file9}.${process.pid}.tmp`;
|
|
17166
17166
|
writeFileSync(tmp, JSON.stringify(value, null, 2) + "\n", secret ? { mode: 384 } : {});
|
|
17167
|
-
renameSync2(tmp,
|
|
17167
|
+
renameSync2(tmp, file9);
|
|
17168
17168
|
}
|
|
17169
17169
|
function projectConfig(trackerRoot) {
|
|
17170
|
-
const
|
|
17170
|
+
const file9 = path2.join(trackerRoot, "trackers.json");
|
|
17171
17171
|
return {
|
|
17172
|
-
file:
|
|
17173
|
-
read: () => readJson(
|
|
17174
|
-
write: (c) => writeJson(
|
|
17172
|
+
file: file9,
|
|
17173
|
+
read: () => readJson(file9, { active: "markdown" }),
|
|
17174
|
+
write: (c) => writeJson(file9, c)
|
|
17175
17175
|
};
|
|
17176
17176
|
}
|
|
17177
17177
|
function credentialStore(dir4 = configDir()) {
|
|
17178
|
-
const
|
|
17178
|
+
const file9 = path2.join(dir4, "credentials.json");
|
|
17179
17179
|
return {
|
|
17180
|
-
file:
|
|
17181
|
-
read: () => readJson(
|
|
17180
|
+
file: file9,
|
|
17181
|
+
read: () => readJson(file9, {}),
|
|
17182
17182
|
write(c) {
|
|
17183
17183
|
ensurePrivateDir(dir4);
|
|
17184
|
-
withFileLock(
|
|
17184
|
+
withFileLock(file9, () => writeJson(file9, c, true));
|
|
17185
17185
|
},
|
|
17186
17186
|
/**
|
|
17187
17187
|
* Read, change and write under one lock: what every change should use, so a Lookout and an `mcp` process
|
|
@@ -17189,9 +17189,9 @@ function credentialStore(dir4 = configDir()) {
|
|
|
17189
17189
|
*/
|
|
17190
17190
|
update(change3) {
|
|
17191
17191
|
ensurePrivateDir(dir4);
|
|
17192
|
-
return withFileLock(
|
|
17193
|
-
const next = change3(readJson(
|
|
17194
|
-
writeJson(
|
|
17192
|
+
return withFileLock(file9, () => {
|
|
17193
|
+
const next = change3(readJson(file9, {}));
|
|
17194
|
+
writeJson(file9, next, true);
|
|
17195
17195
|
return next;
|
|
17196
17196
|
});
|
|
17197
17197
|
}
|
|
@@ -17235,19 +17235,19 @@ async function detectGitHubRepo(cwd, exec) {
|
|
|
17235
17235
|
function privateTarget(dir4) {
|
|
17236
17236
|
return path3.resolve(dir4) === path3.resolve(configDir()) || isPrivateDir(dir4);
|
|
17237
17237
|
}
|
|
17238
|
-
function writeJsonAtomic(
|
|
17239
|
-
const dir4 = path3.dirname(
|
|
17238
|
+
function writeJsonAtomic(file9, value, opts = {}) {
|
|
17239
|
+
const dir4 = path3.dirname(file9);
|
|
17240
17240
|
const secret = opts.private || privateTarget(dir4);
|
|
17241
17241
|
if (secret) ensurePrivateDir(dir4);
|
|
17242
17242
|
else mkdirSync3(dir4, { recursive: true });
|
|
17243
|
-
const tmp = `${
|
|
17243
|
+
const tmp = `${file9}.${process.pid}.tmp`;
|
|
17244
17244
|
writeFileSync2(tmp, JSON.stringify(value, null, 2), secret ? { mode: 384 } : {});
|
|
17245
|
-
renameSync3(tmp,
|
|
17246
|
-
if (secret && process.platform !== "win32") chmodSync2(
|
|
17245
|
+
renameSync3(tmp, file9);
|
|
17246
|
+
if (secret && process.platform !== "win32") chmodSync2(file9, 384);
|
|
17247
17247
|
}
|
|
17248
|
-
function readJsonFile(
|
|
17248
|
+
function readJsonFile(file9) {
|
|
17249
17249
|
try {
|
|
17250
|
-
return parseJsonSafe(readFileSync3(
|
|
17250
|
+
return parseJsonSafe(readFileSync3(file9, "utf8"));
|
|
17251
17251
|
} catch {
|
|
17252
17252
|
return void 0;
|
|
17253
17253
|
}
|
|
@@ -17269,17 +17269,17 @@ var machineId = (root) => createHash("sha256").update(canonical(root)).digest("h
|
|
|
17269
17269
|
// ../core/src/machine/writePrivateFile.ts
|
|
17270
17270
|
import { chmodSync as chmodSync3, mkdirSync as mkdirSync4, renameSync as renameSync4, writeFileSync as writeFileSync3 } from "node:fs";
|
|
17271
17271
|
import path5 from "node:path";
|
|
17272
|
-
function writePrivateFile(
|
|
17273
|
-
const dir4 = path5.dirname(
|
|
17272
|
+
function writePrivateFile(file9, text11) {
|
|
17273
|
+
const dir4 = path5.dirname(file9);
|
|
17274
17274
|
mkdirSync4(dir4, { recursive: true, mode: 448 });
|
|
17275
17275
|
try {
|
|
17276
17276
|
chmodSync3(dir4, 448);
|
|
17277
17277
|
} catch {
|
|
17278
17278
|
}
|
|
17279
|
-
const tmp = `${
|
|
17279
|
+
const tmp = `${file9}.${process.pid}.tmp`;
|
|
17280
17280
|
writeFileSync3(tmp, text11, { mode: 384 });
|
|
17281
|
-
renameSync4(tmp,
|
|
17282
|
-
chmodSync3(
|
|
17281
|
+
renameSync4(tmp, file9);
|
|
17282
|
+
chmodSync3(file9, 384);
|
|
17283
17283
|
}
|
|
17284
17284
|
|
|
17285
17285
|
// ../core/src/machine/machineStore.ts
|
|
@@ -17287,15 +17287,15 @@ var MACHINE_PROJECTS_DIR = "projects";
|
|
|
17287
17287
|
function machineStore(root, dir4 = configDir()) {
|
|
17288
17288
|
const id = machineId(root);
|
|
17289
17289
|
const base2 = path6.join(dir4, MACHINE_PROJECTS_DIR, id);
|
|
17290
|
-
const
|
|
17290
|
+
const file9 = (name2) => path6.join(base2, name2);
|
|
17291
17291
|
return {
|
|
17292
17292
|
id,
|
|
17293
17293
|
dir: base2,
|
|
17294
|
-
file:
|
|
17295
|
-
read: (name2) => readJsonFile(
|
|
17296
|
-
write: (name2, value) => writePrivateFile(
|
|
17294
|
+
file: file9,
|
|
17295
|
+
read: (name2) => readJsonFile(file9(name2)),
|
|
17296
|
+
write: (name2, value) => writePrivateFile(file9(name2), `${JSON.stringify(value, null, 2)}
|
|
17297
17297
|
`),
|
|
17298
|
-
remove: (name2) => rmSync2(
|
|
17298
|
+
remove: (name2) => rmSync2(file9(name2), { force: true })
|
|
17299
17299
|
};
|
|
17300
17300
|
}
|
|
17301
17301
|
|
|
@@ -17626,19 +17626,19 @@ function cachedFields(item2, text11) {
|
|
|
17626
17626
|
}
|
|
17627
17627
|
var texts = lru(MAX_ENTRIES);
|
|
17628
17628
|
var isOversized = (t) => typeof t === "object";
|
|
17629
|
-
function oversizedFile(
|
|
17630
|
-
const s = statSync5(
|
|
17629
|
+
function oversizedFile(file9) {
|
|
17630
|
+
const s = statSync5(file9, { throwIfNoEntry: false });
|
|
17631
17631
|
return s?.isFile() && s.size > MAX_ITEM_BYTES ? s.size : void 0;
|
|
17632
17632
|
}
|
|
17633
|
-
function cachedText(
|
|
17634
|
-
const s = statSync5(
|
|
17633
|
+
function cachedText(file9) {
|
|
17634
|
+
const s = statSync5(file9, { throwIfNoEntry: false });
|
|
17635
17635
|
if (!s?.isFile()) return void 0;
|
|
17636
17636
|
if (s.size > MAX_ITEM_BYTES) return { oversized: s.size };
|
|
17637
17637
|
const stamp2 = `${s.ino}:${s.mtimeMs}:${s.size}`;
|
|
17638
|
-
const hit = texts.get(
|
|
17638
|
+
const hit = texts.get(file9);
|
|
17639
17639
|
if (hit?.stamp === stamp2) return hit.text;
|
|
17640
|
-
const text11 = readFileSync5(
|
|
17641
|
-
texts.set(
|
|
17640
|
+
const text11 = readFileSync5(file9, "utf8");
|
|
17641
|
+
texts.set(file9, { stamp: stamp2, text: text11 });
|
|
17642
17642
|
return text11;
|
|
17643
17643
|
}
|
|
17644
17644
|
|
|
@@ -17716,10 +17716,10 @@ import { linkSync as linkSync2, readFileSync as readFileSync6, rmSync as rmSync4
|
|
|
17716
17716
|
import path8 from "node:path";
|
|
17717
17717
|
var MACHINE_KEY_FILE = "machine.key";
|
|
17718
17718
|
var KEY2 = /^[0-9a-f]{64}$/;
|
|
17719
|
-
function readKey(
|
|
17719
|
+
function readKey(file9) {
|
|
17720
17720
|
let text11;
|
|
17721
17721
|
try {
|
|
17722
|
-
text11 = readFileSync6(
|
|
17722
|
+
text11 = readFileSync6(file9, "utf8").trim();
|
|
17723
17723
|
} catch (e) {
|
|
17724
17724
|
if (e.code === "ENOENT") return void 0;
|
|
17725
17725
|
throw e;
|
|
@@ -17727,24 +17727,24 @@ function readKey(file10) {
|
|
|
17727
17727
|
return KEY2.test(text11) ? text11 : void 0;
|
|
17728
17728
|
}
|
|
17729
17729
|
function machineKey(dir4 = configDir()) {
|
|
17730
|
-
const
|
|
17731
|
-
const known4 = readKey(
|
|
17730
|
+
const file9 = path8.join(dir4, MACHINE_KEY_FILE);
|
|
17731
|
+
const known4 = readKey(file9);
|
|
17732
17732
|
if (known4) return known4;
|
|
17733
|
-
const draft = `${
|
|
17733
|
+
const draft = `${file9}.${process.pid}.${randomBytes2(4).toString("hex")}`;
|
|
17734
17734
|
writePrivateFile(draft, `${randomBytes2(32).toString("hex")}
|
|
17735
17735
|
`);
|
|
17736
17736
|
try {
|
|
17737
|
-
linkSync2(draft,
|
|
17737
|
+
linkSync2(draft, file9);
|
|
17738
17738
|
} catch (e) {
|
|
17739
17739
|
if (e.code !== "EEXIST") throw e;
|
|
17740
17740
|
} finally {
|
|
17741
17741
|
rmSync4(draft, { force: true });
|
|
17742
17742
|
}
|
|
17743
|
-
const made = readKey(
|
|
17743
|
+
const made = readKey(file9);
|
|
17744
17744
|
if (made) return made;
|
|
17745
|
-
writePrivateFile(
|
|
17745
|
+
writePrivateFile(file9, `${randomBytes2(32).toString("hex")}
|
|
17746
17746
|
`);
|
|
17747
|
-
return readKey(
|
|
17747
|
+
return readKey(file9);
|
|
17748
17748
|
}
|
|
17749
17749
|
function machineSign(parts2, dir4) {
|
|
17750
17750
|
const mac4 = createHmac("sha256", machineKey(dir4));
|
|
@@ -17771,8 +17771,8 @@ var signed = (root, mapId, entries2) => [
|
|
|
17771
17771
|
JSON.stringify(entries2)
|
|
17772
17772
|
];
|
|
17773
17773
|
var cache = /* @__PURE__ */ new Map();
|
|
17774
|
-
function stampOf(
|
|
17775
|
-
const s = statSync6(
|
|
17774
|
+
function stampOf(file9) {
|
|
17775
|
+
const s = statSync6(file9, { throwIfNoEntry: false });
|
|
17776
17776
|
return s ? `${s.ino}:${s.mtimeMs}:${s.size}` : void 0;
|
|
17777
17777
|
}
|
|
17778
17778
|
function unreadable(mapId, why2) {
|
|
@@ -17799,18 +17799,18 @@ function parseRecord(root, mapId, text11) {
|
|
|
17799
17799
|
return { entries: entries2 };
|
|
17800
17800
|
}
|
|
17801
17801
|
function readStateRecord(root, mapId) {
|
|
17802
|
-
const
|
|
17803
|
-
const stamp2 = stampOf(
|
|
17802
|
+
const file9 = stateRecordFile(root, mapId);
|
|
17803
|
+
const stamp2 = stampOf(file9);
|
|
17804
17804
|
if (!stamp2) return { entries: {} };
|
|
17805
|
-
const hit = cache.get(
|
|
17805
|
+
const hit = cache.get(file9);
|
|
17806
17806
|
if (hit?.stamp === stamp2) return hit.record;
|
|
17807
17807
|
let record3;
|
|
17808
17808
|
try {
|
|
17809
|
-
record3 = parseRecord(root, mapId, readFileSync7(
|
|
17809
|
+
record3 = parseRecord(root, mapId, readFileSync7(file9, "utf8"));
|
|
17810
17810
|
} catch {
|
|
17811
17811
|
record3 = { entries: {}, problem: machineAccess() ?? unreadable(mapId, "no access").problem, blocked: true };
|
|
17812
17812
|
}
|
|
17813
|
-
if (!record3.blocked) cache.set(
|
|
17813
|
+
if (!record3.blocked) cache.set(file9, { stamp: stamp2, record: record3 });
|
|
17814
17814
|
return record3;
|
|
17815
17815
|
}
|
|
17816
17816
|
function writeStateRecord(root, mapId, entries2) {
|
|
@@ -17828,8 +17828,8 @@ function entriesToChange(root, mapId) {
|
|
|
17828
17828
|
const record3 = readStateRecord(root, mapId);
|
|
17829
17829
|
if (record3.blocked) throw new Error(record3.problem);
|
|
17830
17830
|
if (!record3.problem) return { ...record3.entries };
|
|
17831
|
-
const
|
|
17832
|
-
renameSync5(
|
|
17831
|
+
const file9 = stateRecordFile(root, mapId);
|
|
17832
|
+
renameSync5(file9, `${file9}.unreadable-${Date.now()}`);
|
|
17833
17833
|
return {};
|
|
17834
17834
|
}
|
|
17835
17835
|
function changeStateRecord(root, mapId, fn) {
|
|
@@ -18035,14 +18035,14 @@ function writeTrackerFile(input2) {
|
|
|
18035
18035
|
refuseLinks(root, rel);
|
|
18036
18036
|
const dir4 = realFolder(root, rel);
|
|
18037
18037
|
trackerWriteHooks.afterCheck?.(dir4);
|
|
18038
|
-
const
|
|
18038
|
+
const file9 = path10.join(dir4, path10.basename(rel));
|
|
18039
18039
|
const tmp = path10.join(dir4, `.${path10.basename(rel)}.${randomBytes3(6).toString("hex")}.tmp`);
|
|
18040
18040
|
writeFileSync5(tmp, text11, { flag: "wx" });
|
|
18041
18041
|
try {
|
|
18042
18042
|
confirmLanded(tmp, rel);
|
|
18043
|
-
if (input2.create) linkSync3(tmp,
|
|
18044
|
-
else renameSync6(tmp,
|
|
18045
|
-
confirmLanded(
|
|
18043
|
+
if (input2.create) linkSync3(tmp, file9);
|
|
18044
|
+
else renameSync6(tmp, file9);
|
|
18045
|
+
confirmLanded(file9, rel);
|
|
18046
18046
|
return true;
|
|
18047
18047
|
} catch (e) {
|
|
18048
18048
|
if (input2.create && e.code === "EEXIST") return false;
|
|
@@ -18062,10 +18062,10 @@ function removeTrackerFile(root, rel) {
|
|
|
18062
18062
|
// ../core/src/signedState/signedWrite.ts
|
|
18063
18063
|
function readIfThere(root, rel) {
|
|
18064
18064
|
refuseLinks(root, rel);
|
|
18065
|
-
const
|
|
18066
|
-
if (oversizedFile(
|
|
18065
|
+
const file9 = path11.join(root, rel);
|
|
18066
|
+
if (oversizedFile(file9)) return void 0;
|
|
18067
18067
|
try {
|
|
18068
|
-
return readFileSync8(
|
|
18068
|
+
return readFileSync8(file9, "utf8");
|
|
18069
18069
|
} catch (e) {
|
|
18070
18070
|
if (e.code === "ENOENT") return void 0;
|
|
18071
18071
|
throw e;
|
|
@@ -18231,10 +18231,10 @@ function watchFolders(root, onChange) {
|
|
|
18231
18231
|
for (const e of entries2(dir4)) {
|
|
18232
18232
|
const full = path13.join(dir4, e.name);
|
|
18233
18233
|
if (announce) onChange(relOf(full));
|
|
18234
|
-
if (e.isDirectory())
|
|
18234
|
+
if (e.isDirectory()) folder2(full, announce);
|
|
18235
18235
|
}
|
|
18236
18236
|
}
|
|
18237
|
-
function
|
|
18237
|
+
function folder2(full, announce) {
|
|
18238
18238
|
const s = lstatSync3(full, { throwIfNoEntry: false });
|
|
18239
18239
|
if (!s?.isDirectory()) return unwatchUnder(full);
|
|
18240
18240
|
if (watched.get(full)?.ino === s.ino) return;
|
|
@@ -18244,7 +18244,7 @@ function watchFolders(root, onChange) {
|
|
|
18244
18244
|
function changed(full) {
|
|
18245
18245
|
if (closed) return;
|
|
18246
18246
|
onChange(relOf(full));
|
|
18247
|
-
|
|
18247
|
+
folder2(full, true);
|
|
18248
18248
|
}
|
|
18249
18249
|
const top = lstatSync3(root, { throwIfNoEntry: false });
|
|
18250
18250
|
if (top?.isDirectory()) add3(root, top.ino, false);
|
|
@@ -18268,7 +18268,7 @@ function watchTree(root, onChange, opts = {}) {
|
|
|
18268
18268
|
function rawMarkdownFs(root) {
|
|
18269
18269
|
const abs = path15.resolve(root);
|
|
18270
18270
|
mkdirSync8(abs, { recursive: true });
|
|
18271
|
-
const
|
|
18271
|
+
const safe18 = (p) => {
|
|
18272
18272
|
const full = path15.resolve(abs, p);
|
|
18273
18273
|
if (full !== abs && !full.startsWith(abs + path15.sep)) throw new Error("path escapes root");
|
|
18274
18274
|
return full;
|
|
@@ -18285,15 +18285,15 @@ function rawMarkdownFs(root) {
|
|
|
18285
18285
|
}
|
|
18286
18286
|
return {
|
|
18287
18287
|
list: () => walk(abs),
|
|
18288
|
-
read: (p) => fs.readFile(
|
|
18288
|
+
read: (p) => fs.readFile(safe18(p), "utf8"),
|
|
18289
18289
|
async write(p, text11) {
|
|
18290
|
-
await fs.mkdir(path15.dirname(
|
|
18291
|
-
await fs.writeFile(
|
|
18290
|
+
await fs.mkdir(path15.dirname(safe18(p)), { recursive: true });
|
|
18291
|
+
await fs.writeFile(safe18(p), text11);
|
|
18292
18292
|
},
|
|
18293
18293
|
async create(p, text11) {
|
|
18294
|
-
await fs.mkdir(path15.dirname(
|
|
18294
|
+
await fs.mkdir(path15.dirname(safe18(p)), { recursive: true });
|
|
18295
18295
|
try {
|
|
18296
|
-
await fs.writeFile(
|
|
18296
|
+
await fs.writeFile(safe18(p), text11, { flag: "wx" });
|
|
18297
18297
|
return true;
|
|
18298
18298
|
} catch (e) {
|
|
18299
18299
|
if (e.code === "EEXIST") return false;
|
|
@@ -18350,14 +18350,14 @@ function localRepoFiles(repoRoot) {
|
|
|
18350
18350
|
if (!existsSync6(path17.join(real7, ".git"))) return void 0;
|
|
18351
18351
|
return {
|
|
18352
18352
|
async read(rel) {
|
|
18353
|
-
const
|
|
18354
|
-
const s =
|
|
18355
|
-
if (!
|
|
18356
|
-
return readFile(
|
|
18353
|
+
const file9 = await inside(real7, rel);
|
|
18354
|
+
const s = file9 ? await stat(file9).catch(() => void 0) : void 0;
|
|
18355
|
+
if (!file9 || !s?.isFile() || s.size > MAX_SCREEN_BYTES) return void 0;
|
|
18356
|
+
return readFile(file9, "utf8").catch(() => void 0);
|
|
18357
18357
|
},
|
|
18358
18358
|
async kind(rel) {
|
|
18359
|
-
const
|
|
18360
|
-
const s =
|
|
18359
|
+
const file9 = await inside(real7, rel);
|
|
18360
|
+
const s = file9 ? await stat(file9).catch(() => void 0) : void 0;
|
|
18361
18361
|
if (s?.isDirectory()) return "dir";
|
|
18362
18362
|
return s?.isFile() ? "file" : void 0;
|
|
18363
18363
|
}
|
|
@@ -18463,24 +18463,24 @@ import path20 from "node:path";
|
|
|
18463
18463
|
|
|
18464
18464
|
// ../core/src/policy/stricterPolicy.ts
|
|
18465
18465
|
var rank3 = (l) => RISK_LEVELS.indexOf(l);
|
|
18466
|
-
function keptRule(approved,
|
|
18467
|
-
const now2 =
|
|
18466
|
+
function keptRule(approved, file9) {
|
|
18467
|
+
const now2 = file9.filter((r) => r.glob === approved.glob);
|
|
18468
18468
|
if (!now2.length) return { rule: approved, line: `path rule ${approved.glob} (${approved.level}) was removed` };
|
|
18469
18469
|
const highest = now2.reduce((a, b) => rank3(b.level) > rank3(a.level) ? b : a);
|
|
18470
18470
|
if (rank3(highest.level) >= rank3(approved.level)) return void 0;
|
|
18471
18471
|
return { rule: approved, line: `path rule ${approved.glob}: ${approved.level} \u2192 ${highest.level}` };
|
|
18472
18472
|
}
|
|
18473
|
-
function stricterPolicy(
|
|
18473
|
+
function stricterPolicy(file9, approved) {
|
|
18474
18474
|
const lowered = [];
|
|
18475
|
-
const categories = { ...
|
|
18475
|
+
const categories = { ...file9.categories };
|
|
18476
18476
|
for (const c of RISK_CATEGORIES) {
|
|
18477
|
-
if (rank3(
|
|
18478
|
-
lowered.push(`${c}: ${approved.categories[c]} \u2192 ${
|
|
18477
|
+
if (rank3(file9.categories[c]) >= rank3(approved.categories[c])) continue;
|
|
18478
|
+
lowered.push(`${c}: ${approved.categories[c]} \u2192 ${file9.categories[c]}`);
|
|
18479
18479
|
categories[c] = approved.categories[c];
|
|
18480
18480
|
}
|
|
18481
|
-
const kept = approved.paths.map((r) => keptRule(r,
|
|
18481
|
+
const kept = approved.paths.map((r) => keptRule(r, file9.paths)).filter((k) => k !== void 0);
|
|
18482
18482
|
lowered.push(...kept.map((k) => k.line));
|
|
18483
|
-
return { policy: { v: 1, categories, paths: [...
|
|
18483
|
+
return { policy: { v: 1, categories, paths: [...file9.paths, ...kept.map((k) => k.rule)] }, lowered };
|
|
18484
18484
|
}
|
|
18485
18485
|
|
|
18486
18486
|
// ../core/src/policy/policyStore.ts
|
|
@@ -18758,33 +18758,33 @@ var checkSha = (spec) => sha(JSON.stringify({ run: spec.run, cwd: spec.cwd ?? nu
|
|
|
18758
18758
|
var LOCK_CHANGED = "guides.lock.json changed outside Teamtrail (by an agent, or pulled with git); waiting for your approval";
|
|
18759
18759
|
var NOT_APPROVED_HERE = "approved elsewhere, not on this machine yet; approvals are kept per machine, outside the repo, and a repo that moved is asked again";
|
|
18760
18760
|
var pendingChecks = (guide, lock) => Object.entries(guide.proposedChecks).filter(([name2, spec]) => lock?.approvedChecks[name2] !== checkSha(spec)).map(([name2]) => name2);
|
|
18761
|
-
function guideStatus(
|
|
18762
|
-
const lint = lintGuide(
|
|
18763
|
-
const sha256 = guideSha(
|
|
18761
|
+
function guideStatus(file9) {
|
|
18762
|
+
const lint = lintGuide(file9.text);
|
|
18763
|
+
const sha256 = guideSha(file9.text);
|
|
18764
18764
|
const base2 = {
|
|
18765
|
-
id:
|
|
18766
|
-
origin:
|
|
18765
|
+
id: file9.id,
|
|
18766
|
+
origin: file9.origin,
|
|
18767
18767
|
sha256,
|
|
18768
18768
|
...lint.guide ? { guide: lint.guide } : {},
|
|
18769
|
-
...
|
|
18769
|
+
...file9.lock ? { lock: file9.lock } : {},
|
|
18770
18770
|
findings: lint.findings,
|
|
18771
|
-
pendingChecks: lint.guide &&
|
|
18772
|
-
overridesBuiltin: !!
|
|
18771
|
+
pendingChecks: lint.guide && file9.origin === "local" ? pendingChecks(lint.guide, file9.lock) : [],
|
|
18772
|
+
overridesBuiltin: !!file9.overridesBuiltin
|
|
18773
18773
|
};
|
|
18774
18774
|
const firstError = lint.findings.find((f) => f.level === "error");
|
|
18775
18775
|
if (firstError) return { ...base2, status: "invalid", reason: `line ${firstError.line}: ${firstError.message}` };
|
|
18776
|
-
if (lint.guide?.id !==
|
|
18776
|
+
if (lint.guide?.id !== file9.id)
|
|
18777
18777
|
return {
|
|
18778
18778
|
...base2,
|
|
18779
18779
|
status: "invalid",
|
|
18780
|
-
reason: `its id "${lint.guide?.id}" doesn't match the file name ${
|
|
18780
|
+
reason: `its id "${lint.guide?.id}" doesn't match the file name ${file9.id}.md`
|
|
18781
18781
|
};
|
|
18782
|
-
if (
|
|
18783
|
-
if (
|
|
18784
|
-
if (
|
|
18785
|
-
if (!
|
|
18786
|
-
if (
|
|
18787
|
-
return { ...base2, status: "tampered", reason: `changed since version ${
|
|
18782
|
+
if (file9.origin === "builtin") return { ...base2, status: "active" };
|
|
18783
|
+
if (file9.lockChanged && !file9.lock) return { ...base2, status: "unapproved", reason: NOT_APPROVED_HERE };
|
|
18784
|
+
if (file9.lockChanged) return { ...base2, status: "tampered", reason: LOCK_CHANGED };
|
|
18785
|
+
if (!file9.lock) return { ...base2, status: "unapproved", reason: "not approved by the trail lead yet" };
|
|
18786
|
+
if (file9.lock.sha256 !== sha256)
|
|
18787
|
+
return { ...base2, status: "tampered", reason: `changed since version ${file9.lock.version} was approved` };
|
|
18788
18788
|
return { ...base2, status: "active" };
|
|
18789
18789
|
}
|
|
18790
18790
|
var missingGuide = (id, lock) => ({
|
|
@@ -19022,11 +19022,11 @@ import path26 from "node:path";
|
|
|
19022
19022
|
var STATE_DIR2 = ".attention";
|
|
19023
19023
|
var STATE_FILE = "state.json";
|
|
19024
19024
|
function readAttentionPolicy(root) {
|
|
19025
|
-
const
|
|
19026
|
-
if (!existsSync9(
|
|
19025
|
+
const file9 = path26.join(root, ATTENTION_FILE);
|
|
19026
|
+
if (!existsSync9(file9)) return { file: ATTENTION_FILE, exists: false, ...parseAttentionPolicy({ v: 1 }) };
|
|
19027
19027
|
let raw;
|
|
19028
19028
|
try {
|
|
19029
|
-
raw = parseJsonSafe(readFileSync14(
|
|
19029
|
+
raw = parseJsonSafe(readFileSync14(file9, "utf8"));
|
|
19030
19030
|
} catch (err) {
|
|
19031
19031
|
const parsed3 = parseAttentionPolicy({ v: 1 });
|
|
19032
19032
|
return { file: ATTENTION_FILE, exists: true, value: parsed3.value, errors: [`not valid JSON: ${String(err)}`] };
|
|
@@ -19140,9 +19140,9 @@ function orphans(dir4, key) {
|
|
|
19140
19140
|
}
|
|
19141
19141
|
return names.filter((n) => n.startsWith(`${key}.`) && n.endsWith(".json") && !owned(n.slice(key.length + 1, -".json".length))).sort();
|
|
19142
19142
|
}
|
|
19143
|
-
function readWrites(
|
|
19143
|
+
function readWrites(file9) {
|
|
19144
19144
|
try {
|
|
19145
|
-
const doc = JSON.parse(readFileSync15(
|
|
19145
|
+
const doc = JSON.parse(readFileSync15(file9, "utf8"));
|
|
19146
19146
|
return doc.v === 1 && Array.isArray(doc.writes) ? doc.writes.filter(isQueuedWrite) : [];
|
|
19147
19147
|
} catch {
|
|
19148
19148
|
return [];
|
|
@@ -19153,15 +19153,15 @@ function orphanedWrites(dir4, key) {
|
|
|
19153
19153
|
}
|
|
19154
19154
|
function outboxFile(dir4, key) {
|
|
19155
19155
|
const owner = `${process.pid}-${++instances}`;
|
|
19156
|
-
const
|
|
19156
|
+
const file9 = path27.join(dir4, `${key}.${owner}.json`);
|
|
19157
19157
|
let released = false;
|
|
19158
19158
|
const save2 = (writes) => {
|
|
19159
19159
|
if (released) return;
|
|
19160
|
-
if (!writes.length) return void rmSync6(
|
|
19161
|
-
writePrivateFile(
|
|
19160
|
+
if (!writes.length) return void rmSync6(file9, { force: true });
|
|
19161
|
+
writePrivateFile(file9, JSON.stringify({ v: 1, writes }, null, 2) + "\n");
|
|
19162
19162
|
};
|
|
19163
19163
|
return {
|
|
19164
|
-
file:
|
|
19164
|
+
file: file9,
|
|
19165
19165
|
load() {
|
|
19166
19166
|
live.add(owner);
|
|
19167
19167
|
const claimed = [];
|
|
@@ -19189,9 +19189,9 @@ function outboxFile(dir4, key) {
|
|
|
19189
19189
|
|
|
19190
19190
|
// ../core/src/adapters/remote/legacyOutbox.ts
|
|
19191
19191
|
var targetOf = (name2) => name2.replace(/\.[^.]*\.json$/, "");
|
|
19192
|
-
function readQueue(
|
|
19192
|
+
function readQueue(file9) {
|
|
19193
19193
|
try {
|
|
19194
|
-
const doc = JSON.parse(readFileSync16(
|
|
19194
|
+
const doc = JSON.parse(readFileSync16(file9, "utf8"));
|
|
19195
19195
|
return doc.v === 1 && Array.isArray(doc.writes) ? doc.writes.filter(isQueuedWrite) : [];
|
|
19196
19196
|
} catch {
|
|
19197
19197
|
return [];
|
|
@@ -19330,10 +19330,10 @@ import path31 from "node:path";
|
|
|
19330
19330
|
var safe5 = (s) => s.replace(/[^\w.-]/g, "_");
|
|
19331
19331
|
var briefPath = (root, mapId) => path31.join(root, BRIEF_DIR, `${safe5(mapId)}.md`);
|
|
19332
19332
|
function readBriefFile(root, mapId) {
|
|
19333
|
-
const
|
|
19334
|
-
if (!existsSync10(
|
|
19333
|
+
const file9 = briefPath(root, mapId);
|
|
19334
|
+
if (!existsSync10(file9)) return void 0;
|
|
19335
19335
|
try {
|
|
19336
|
-
const text11 = readFileSync18(
|
|
19336
|
+
const text11 = readFileSync18(file9, "utf8");
|
|
19337
19337
|
return { brief: parseBrief(mapId, text11), text: text11 };
|
|
19338
19338
|
} catch {
|
|
19339
19339
|
return void 0;
|
|
@@ -19484,9 +19484,9 @@ function nextKnowledgeId(root) {
|
|
|
19484
19484
|
const n = Math.max(0, ...listKnowledge(root).map((e) => Number(e.id.slice(2)) || 0));
|
|
19485
19485
|
return `K-${n + 1}`;
|
|
19486
19486
|
}
|
|
19487
|
-
function blobHash(repo,
|
|
19487
|
+
function blobHash(repo, file9) {
|
|
19488
19488
|
const top = path33.resolve(repo);
|
|
19489
|
-
const abs = path33.resolve(top,
|
|
19489
|
+
const abs = path33.resolve(top, file9);
|
|
19490
19490
|
if (!abs.startsWith(top + path33.sep) || !existsSync11(abs)) return void 0;
|
|
19491
19491
|
const content = readFileSync19(abs);
|
|
19492
19492
|
return createHash5("sha1").update(`blob ${content.length}\0`).update(content).digest("hex");
|
|
@@ -19554,14 +19554,14 @@ import path34 from "node:path";
|
|
|
19554
19554
|
var VERIFICATION_FILE = "verification.json";
|
|
19555
19555
|
var configHash = (text11) => `sha256:${createHash6("sha256").update(text11).digest("hex")}`;
|
|
19556
19556
|
function readVerificationConfig(root) {
|
|
19557
|
-
const
|
|
19557
|
+
const file9 = path34.join(root, VERIFICATION_FILE);
|
|
19558
19558
|
let text11;
|
|
19559
19559
|
try {
|
|
19560
|
-
text11 = readFileSync20(
|
|
19560
|
+
text11 = readFileSync20(file9, "utf8");
|
|
19561
19561
|
} catch {
|
|
19562
|
-
return { path:
|
|
19562
|
+
return { path: file9, exists: false, errors: [] };
|
|
19563
19563
|
}
|
|
19564
|
-
return { path:
|
|
19564
|
+
return { path: file9, exists: true, ...parseVerificationConfig(text11), hash: configHash(text11) };
|
|
19565
19565
|
}
|
|
19566
19566
|
|
|
19567
19567
|
// ../core/src/verification/checksApproval.ts
|
|
@@ -19586,9 +19586,9 @@ function checksApproval(root) {
|
|
|
19586
19586
|
return { state, waiting: state !== "approved" && state !== "none", text: text11, hash: hash2, approved };
|
|
19587
19587
|
}
|
|
19588
19588
|
function parsed2(root, text11) {
|
|
19589
|
-
const
|
|
19590
|
-
if (!text11) return { path:
|
|
19591
|
-
return { path:
|
|
19589
|
+
const file9 = path35.join(root, VERIFICATION_FILE);
|
|
19590
|
+
if (!text11) return { path: file9, exists: false, errors: [] };
|
|
19591
|
+
return { path: file9, exists: true, ...parseVerificationConfig(text11), hash: contentHash(text11) };
|
|
19592
19592
|
}
|
|
19593
19593
|
function trustedChecks(root) {
|
|
19594
19594
|
const approval = checksApproval(root);
|
|
@@ -19687,18 +19687,18 @@ function latestMainRun(root, budgetMs = 0) {
|
|
|
19687
19687
|
function lockMainRun(root, id, budgetMs) {
|
|
19688
19688
|
ensureLocalDir(path36.join(root, EVIDENCE_DIR));
|
|
19689
19689
|
ensureLocalDir(path36.join(root, MAIN_DIR));
|
|
19690
|
-
const
|
|
19690
|
+
const file9 = path36.join(root, RUNNING2);
|
|
19691
19691
|
for (let tries = 0; tries < 2; tries++) {
|
|
19692
19692
|
try {
|
|
19693
|
-
const fd = openSync2(
|
|
19693
|
+
const fd = openSync2(file9, "wx");
|
|
19694
19694
|
writeSync2(fd, JSON.stringify({ id, pid: process.pid, at: Date.now() }));
|
|
19695
19695
|
closeSync2(fd);
|
|
19696
|
-
return { ok: true, release: () => rmSync11(
|
|
19696
|
+
return { ok: true, release: () => rmSync11(file9, { force: true }) };
|
|
19697
19697
|
} catch {
|
|
19698
|
-
const held = readJsonFile(
|
|
19698
|
+
const held = readJsonFile(file9);
|
|
19699
19699
|
const live2 = !!held?.pid && processAlive(held.pid) && Date.now() - (held.at ?? 0) < budgetMs + STUCK_MARGIN_MS;
|
|
19700
19700
|
if (live2) return { ok: false };
|
|
19701
|
-
rmSync11(
|
|
19701
|
+
rmSync11(file9, { force: true });
|
|
19702
19702
|
}
|
|
19703
19703
|
}
|
|
19704
19704
|
return { ok: false };
|
|
@@ -19937,9 +19937,9 @@ var safe9 = (s) => s.replace(/[^\w.-]/g, "_");
|
|
|
19937
19937
|
var recordsDir = (root) => path39.join(root, AGENTS_DIR, "workspaces");
|
|
19938
19938
|
var recordFile = (root, mapId, ticketId) => path39.join(recordsDir(root), `${safe9(mapId)}--${safe9(ticketId)}.json`);
|
|
19939
19939
|
function readWorkspaceSettings(root) {
|
|
19940
|
-
const
|
|
19941
|
-
if (!existsSync12(
|
|
19942
|
-
const parsed3 = parseWorkspaceSettings(readFileSync23(
|
|
19940
|
+
const file9 = path39.join(root, WORKSPACES_FILE);
|
|
19941
|
+
if (!existsSync12(file9)) return { settings: DEFAULT_WORKSPACE_SETTINGS, errors: [], exists: false };
|
|
19942
|
+
const parsed3 = parseWorkspaceSettings(readFileSync23(file9, "utf8"));
|
|
19943
19943
|
return { settings: parsed3.settings ?? DEFAULT_WORKSPACE_SETTINGS, errors: parsed3.errors, exists: true };
|
|
19944
19944
|
}
|
|
19945
19945
|
function writeWorkspaceSettings(root, s) {
|
|
@@ -20033,11 +20033,11 @@ function commonGitDir(repo) {
|
|
|
20033
20033
|
const at2 = abs.lastIndexOf(`${path40.sep}worktrees${path40.sep}`);
|
|
20034
20034
|
return at2 === -1 ? abs : abs.slice(0, at2);
|
|
20035
20035
|
}
|
|
20036
|
-
function ownWorktree(
|
|
20037
|
-
const dotGit = path40.join(
|
|
20036
|
+
function ownWorktree(folder2, gitDir) {
|
|
20037
|
+
const dotGit = path40.join(folder2, ".git");
|
|
20038
20038
|
if (!existsSync14(dotGit) || statSync8(dotGit).isDirectory()) return false;
|
|
20039
20039
|
const pointed = /^gitdir:\s*(.+)$/m.exec(readFileSync24(dotGit, "utf8"))?.[1]?.trim() ?? "";
|
|
20040
|
-
return real2(path40.resolve(
|
|
20040
|
+
return real2(path40.resolve(folder2, pointed)).startsWith(`${gitDir}${path40.sep}worktrees${path40.sep}`);
|
|
20041
20041
|
}
|
|
20042
20042
|
function siblingProblem(o) {
|
|
20043
20043
|
if (o.target === o.parent) return "is the folder your projects live in";
|
|
@@ -20232,10 +20232,10 @@ function noChangesFlag(i) {
|
|
|
20232
20232
|
|
|
20233
20233
|
// ../core/src/evidence/pathCovered.ts
|
|
20234
20234
|
var WILD2 = /[*?[{]/;
|
|
20235
|
-
function pathCovered(glob,
|
|
20235
|
+
function pathCovered(glob, file9) {
|
|
20236
20236
|
const g = glob.replace(/^\.\//, "").replace(/\/+$/, "");
|
|
20237
|
-
if (WILD2.test(g)) return globMatch(g,
|
|
20238
|
-
return
|
|
20237
|
+
if (WILD2.test(g)) return globMatch(g, file9);
|
|
20238
|
+
return file9 === g || file9.startsWith(`${g}/`);
|
|
20239
20239
|
}
|
|
20240
20240
|
|
|
20241
20241
|
// ../core/src/evidence/scopeFlag.ts
|
|
@@ -20310,9 +20310,9 @@ function readRunnerReport(o) {
|
|
|
20310
20310
|
function resultOf(asked, got, log) {
|
|
20311
20311
|
const raw = typeof got.output === "string" ? got.output : "";
|
|
20312
20312
|
const output2 = redact(raw.slice(-MAX_OUTPUT));
|
|
20313
|
-
const
|
|
20313
|
+
const file9 = `${safe10(asked.name)}.log`;
|
|
20314
20314
|
mkdirSync19(log.dir, { recursive: true });
|
|
20315
|
-
writeFileSync13(path45.join(log.dir,
|
|
20315
|
+
writeFileSync13(path45.join(log.dir, file9), output2);
|
|
20316
20316
|
const error63 = text(got.error, 300);
|
|
20317
20317
|
return {
|
|
20318
20318
|
name: asked.name,
|
|
@@ -20323,7 +20323,7 @@ function resultOf(asked, got, log) {
|
|
|
20323
20323
|
timedOut: got.timedOut === true,
|
|
20324
20324
|
durationMs: Number.isFinite(got.durationMs) ? Math.max(0, Math.round(got.durationMs)) : 0,
|
|
20325
20325
|
...error63 ? { error: error63 } : {},
|
|
20326
|
-
log: `${log.rel}/${
|
|
20326
|
+
log: `${log.rel}/${file9}`,
|
|
20327
20327
|
tail: tailOf(output2),
|
|
20328
20328
|
truncated: raw.length > MAX_OUTPUT
|
|
20329
20329
|
};
|
|
@@ -20348,6 +20348,10 @@ async function ask(runner, job, ms) {
|
|
|
20348
20348
|
clearTimeout(timer);
|
|
20349
20349
|
}
|
|
20350
20350
|
}
|
|
20351
|
+
function otherCommit(o) {
|
|
20352
|
+
if (!o.asked || o.ran === o.asked) return void 0;
|
|
20353
|
+
return `${o.runner} ran on ${o.ran?.slice(0, 7) ?? "no commit it named"}, not ${o.asked.slice(0, 7)} as asked`;
|
|
20354
|
+
}
|
|
20351
20355
|
async function runMainOnRunner(o) {
|
|
20352
20356
|
const runner = o.runner.name;
|
|
20353
20357
|
if (!o.runner.runMain)
|
|
@@ -20359,8 +20363,8 @@ async function runMainOnRunner(o) {
|
|
|
20359
20363
|
runner,
|
|
20360
20364
|
note: `${runner} doesn't run checks on main`
|
|
20361
20365
|
};
|
|
20362
|
-
const head = o.head
|
|
20363
|
-
const known4 = "note" in head ? {} : { branch: head.branch, commit: head.commit };
|
|
20366
|
+
const head = o.head === void 0 ? await defaultHead(o.repoRoot) : o.head;
|
|
20367
|
+
const known4 = !head || "note" in head ? {} : { branch: head.branch, commit: head.commit };
|
|
20364
20368
|
const asked = o.names.map((name2) => ({ name: name2, spec: o.config.checks[name2] }));
|
|
20365
20369
|
const job = {
|
|
20366
20370
|
runId: o.id,
|
|
@@ -20384,8 +20388,11 @@ async function runMainOnRunner(o) {
|
|
|
20384
20388
|
ticketType: "research"
|
|
20385
20389
|
});
|
|
20386
20390
|
if ("error" in read4) return { ...at2, result: "unavailable", checks: [], note: read4.error };
|
|
20391
|
+
const ran = read4.git.tree?.head ?? null;
|
|
20392
|
+
const moved = otherCommit({ runner, asked: known4.commit, ran });
|
|
20393
|
+
if (moved) return { ...at2, result: "unavailable", checks: [], note: moved };
|
|
20387
20394
|
const checks = read4.checks.map((c) => mainCheckResult(o.root, c, []));
|
|
20388
|
-
const commit =
|
|
20395
|
+
const commit = ran ?? at2.commit;
|
|
20389
20396
|
const said = Array.isArray(report3.contains) ? report3.contains : [];
|
|
20390
20397
|
const contains2 = o.contains ? { contains: o.contains.filter((c) => said.includes(c)) } : {};
|
|
20391
20398
|
if (checks.length < asked.length && checks.every((c) => c.passed))
|
|
@@ -20660,10 +20667,10 @@ function trackerPin(root, configDir2) {
|
|
|
20660
20667
|
return {
|
|
20661
20668
|
/** The tracker to use now, and the one waiting for approval when `trackers.json` names another. */
|
|
20662
20669
|
read() {
|
|
20663
|
-
const
|
|
20670
|
+
const file9 = project.read();
|
|
20664
20671
|
const pin = pinned();
|
|
20665
|
-
if (trackerTargetKey(
|
|
20666
|
-
return { config: pin, pending:
|
|
20672
|
+
if (trackerTargetKey(file9) === trackerTargetKey(pin)) return { config: file9 };
|
|
20673
|
+
return { config: pin, pending: file9 };
|
|
20667
20674
|
},
|
|
20668
20675
|
/** The human chose this target on this machine (Settings, or approving a change to `trackers.json`). */
|
|
20669
20676
|
approve(config4) {
|
|
@@ -20767,9 +20774,14 @@ async function here(env, o) {
|
|
|
20767
20774
|
const found = await runMainHere({ ...job, head, logRel: trailPaths.logs(o.mapId, o.id) });
|
|
20768
20775
|
return { ...found, merges: marked(o.merges, (c) => head.contained.has(c)) };
|
|
20769
20776
|
}
|
|
20777
|
+
async function namedHead(repoRoot, commits) {
|
|
20778
|
+
const head = await trailHead(repoRoot, commits);
|
|
20779
|
+
if ("note" in head || head.contained.size < commits.length) return { note: "not every merge is here" };
|
|
20780
|
+
return head;
|
|
20781
|
+
}
|
|
20770
20782
|
async function onRunner(env, o) {
|
|
20771
20783
|
const repoRoot = env.repoRoot ?? path50.dirname(env.root);
|
|
20772
|
-
const known4 = await
|
|
20784
|
+
const known4 = await namedHead(repoRoot, commitsOf(o.merges));
|
|
20773
20785
|
const found = await runMainOnRunner({
|
|
20774
20786
|
root: env.root,
|
|
20775
20787
|
repoRoot,
|
|
@@ -20778,7 +20790,7 @@ async function onRunner(env, o) {
|
|
|
20778
20790
|
config: o.plan.config,
|
|
20779
20791
|
names: o.plan.names,
|
|
20780
20792
|
signal: env.signal,
|
|
20781
|
-
|
|
20793
|
+
head: "note" in known4 ? null : { branch: known4.branch, commit: known4.commit },
|
|
20782
20794
|
contains: commitsOf(o.merges),
|
|
20783
20795
|
logRel: trailPaths.logs(o.mapId, o.id)
|
|
20784
20796
|
});
|
|
@@ -20926,9 +20938,9 @@ function judgeFile(root, item2, strict, out) {
|
|
|
20926
20938
|
out.changes.push({ ...item2, fields: ["oversized"], counts: entry?.f, signed: !!entry, ...unreadable2 });
|
|
20927
20939
|
return;
|
|
20928
20940
|
}
|
|
20929
|
-
const
|
|
20930
|
-
if (text11 !== void 0 && !
|
|
20931
|
-
const judged2 = judgeItem({ kind: item2.kind, entry, raw:
|
|
20941
|
+
const file9 = text11 === void 0 ? void 0 : cachedFields(item2, text11);
|
|
20942
|
+
if (text11 !== void 0 && !file9) return;
|
|
20943
|
+
const judged2 = judgeItem({ kind: item2.kind, entry, raw: file9, text: text11, strict });
|
|
20932
20944
|
if (judged2.textEdited) out.textEdits.push(item2);
|
|
20933
20945
|
if (!judged2.outside.length) return;
|
|
20934
20946
|
const signedText2 = entry?.text ? { signedText: entry.text } : {};
|
|
@@ -20939,7 +20951,7 @@ function judgeFile(root, item2, strict, out) {
|
|
|
20939
20951
|
...item2,
|
|
20940
20952
|
fields: judged2.outside,
|
|
20941
20953
|
counts: judged2.base,
|
|
20942
|
-
file:
|
|
20954
|
+
file: file9,
|
|
20943
20955
|
signed: signed3,
|
|
20944
20956
|
...keep3,
|
|
20945
20957
|
...unreadable2,
|
|
@@ -21449,8 +21461,8 @@ function briefItems(root, ledger) {
|
|
|
21449
21461
|
const j = judged(ledger, trustKey.brief(mapId), read4.text);
|
|
21450
21462
|
if (!j) return [];
|
|
21451
21463
|
const lines = j.standing === "changed" ? j.lines : firstLines(read4.brief.sections.summary || read4.text);
|
|
21452
|
-
const
|
|
21453
|
-
return [{ ...j, lines, kind: "brief", title: "Accepted discovery brief", mapId, file:
|
|
21464
|
+
const file9 = `${BRIEF_DIR}/${mapId}.md`;
|
|
21465
|
+
return [{ ...j, lines, kind: "brief", title: "Accepted discovery brief", mapId, file: file9 }];
|
|
21454
21466
|
});
|
|
21455
21467
|
}
|
|
21456
21468
|
function criteriaItems(root, ledger) {
|
|
@@ -21459,8 +21471,8 @@ function criteriaItems(root, ledger) {
|
|
|
21459
21471
|
const j = judged(ledger, trustKey.criteria(mapId, t.ticketId), criteriaContent(t));
|
|
21460
21472
|
if (!j) return [];
|
|
21461
21473
|
const title = `Confirmed criteria of ${t.ticketKey}`;
|
|
21462
|
-
const
|
|
21463
|
-
return [{ ...j, kind: "criteria", title, mapId, ticketId: t.ticketId, file:
|
|
21474
|
+
const file9 = `${CRITERIA_DIR}/${mapId}.md`;
|
|
21475
|
+
return [{ ...j, kind: "criteria", title, mapId, ticketId: t.ticketId, file: file9 }];
|
|
21464
21476
|
})
|
|
21465
21477
|
);
|
|
21466
21478
|
}
|
|
@@ -21552,7 +21564,7 @@ function applyGuard(graded, o) {
|
|
|
21552
21564
|
kind: "check-guard",
|
|
21553
21565
|
level: held ? "alert" : "warn",
|
|
21554
21566
|
message: `the work changed what its checks run: ${reason}`,
|
|
21555
|
-
files: [...new Set(guard2.findings.map((f) => f.file))]
|
|
21567
|
+
files: [...new Set(guard2.findings.map((f) => f.file).filter(Boolean))]
|
|
21556
21568
|
};
|
|
21557
21569
|
if (graded.git) graded.git.flags.push(flag);
|
|
21558
21570
|
if (graded.result === "pass")
|
|
@@ -21743,70 +21755,70 @@ var RUNNER_CONFIGS = {
|
|
|
21743
21755
|
var base = (f) => f.split("/").pop() ?? f;
|
|
21744
21756
|
var dirOf = (f) => f.split("/").slice(0, -1).join("/");
|
|
21745
21757
|
var near = (a, b) => !a || !b || a === b || a.startsWith(`${b}/`) || b.startsWith(`${a}/`);
|
|
21746
|
-
var unread2 = (
|
|
21758
|
+
var unread2 = (file9) => ({
|
|
21747
21759
|
kind: "unread",
|
|
21748
|
-
file:
|
|
21749
|
-
text: `${
|
|
21760
|
+
file: file9,
|
|
21761
|
+
text: `${file9} changed; Teamtrail couldn't read it to compare`
|
|
21750
21762
|
});
|
|
21751
|
-
function packageFindings(
|
|
21763
|
+
function packageFindings(file9, texts2, reach, tools) {
|
|
21752
21764
|
const [b, a] = texts2.map(packageJson);
|
|
21753
|
-
if (b === "invalid" || a === "invalid") return [{ kind: "script", file:
|
|
21765
|
+
if (b === "invalid" || a === "invalid") return [{ kind: "script", file: file9, text: `${file9} isn't valid JSON` }];
|
|
21754
21766
|
const empty = { scripts: {}, keys: {} };
|
|
21755
21767
|
const before = b ?? empty;
|
|
21756
21768
|
const after = a ?? empty;
|
|
21757
|
-
const names = [...reach.scripts.get(
|
|
21758
|
-
const scripts = names.filter((n) => before.scripts[n] !== after.scripts[n]).map((n) => ({ kind: "script", file:
|
|
21769
|
+
const names = [...reach.scripts.get(file9) ?? []].sort();
|
|
21770
|
+
const scripts = names.filter((n) => before.scripts[n] !== after.scripts[n]).map((n) => ({ kind: "script", file: file9, text: `${file9} scripts.${n} changed` }));
|
|
21759
21771
|
const keys2 = tools.flatMap(
|
|
21760
|
-
(tool) => (RUNNER_CONFIGS[tool]?.pkgKeys ?? []).filter((k) => before.keys[k] !== after.keys[k]).map((k) => ({ kind: "runner-config", file:
|
|
21772
|
+
(tool) => (RUNNER_CONFIGS[tool]?.pkgKeys ?? []).filter((k) => before.keys[k] !== after.keys[k]).map((k) => ({ kind: "runner-config", file: file9, text: `${file9} "${k}" changed (${tool}'s config)` }))
|
|
21761
21773
|
);
|
|
21762
21774
|
return [...scripts, ...keys2];
|
|
21763
21775
|
}
|
|
21764
|
-
function configFindings(
|
|
21765
|
-
const name2 = base(
|
|
21776
|
+
function configFindings(file9, texts2, tools) {
|
|
21777
|
+
const name2 = base(file9);
|
|
21766
21778
|
const out = [];
|
|
21767
21779
|
for (const tool of tools) {
|
|
21768
21780
|
const c = RUNNER_CONFIGS[tool];
|
|
21769
21781
|
if (!c) continue;
|
|
21770
21782
|
if (c.files.some((r) => r.test(name2)))
|
|
21771
|
-
out.push({ kind: "runner-config", file:
|
|
21783
|
+
out.push({ kind: "runner-config", file: file9, text: `${file9} changed (${tool}'s config)` });
|
|
21772
21784
|
for (const s of c.sections ?? []) {
|
|
21773
21785
|
if (!s.file.test(name2)) continue;
|
|
21774
21786
|
const [b, a] = texts2.map((t) => configSection(t, s.header));
|
|
21775
|
-
if (b !== a) out.push({ kind: "runner-config", file:
|
|
21787
|
+
if (b !== a) out.push({ kind: "runner-config", file: file9, text: `${file9} changed in ${tool}'s section` });
|
|
21776
21788
|
}
|
|
21777
21789
|
}
|
|
21778
21790
|
return out;
|
|
21779
21791
|
}
|
|
21780
|
-
function makeFindings(
|
|
21792
|
+
function makeFindings(file9, texts2, targets) {
|
|
21781
21793
|
return [...targets].filter((t) => {
|
|
21782
21794
|
const [b, a] = texts2.map((x) => x == null ? void 0 : makeReach(x, t || void 0).relevant);
|
|
21783
21795
|
return b !== a;
|
|
21784
|
-
}).map((t) => ({ kind: "makefile", file:
|
|
21796
|
+
}).map((t) => ({ kind: "makefile", file: file9, text: `${file9} changed for \`make${t ? ` ${t}` : ""}\`` }));
|
|
21785
21797
|
}
|
|
21786
|
-
var toolsNear = (
|
|
21787
|
-
function needsText(
|
|
21788
|
-
if (reach.scripts.has(
|
|
21789
|
-
if (base(
|
|
21790
|
-
return tools.some((t) => RUNNER_CONFIGS[t]?.sections?.some((s) => s.file.test(base(
|
|
21798
|
+
var toolsNear = (file9, reach) => [...reach.tools].filter(([, dirs2]) => [...dirs2].some((d) => near(dirOf(file9), d))).map(([tool]) => tool).sort();
|
|
21799
|
+
function needsText(file9, reach, tools) {
|
|
21800
|
+
if (reach.scripts.has(file9) || reach.makefiles.has(file9)) return true;
|
|
21801
|
+
if (base(file9) === "package.json") return tools.some((t) => RUNNER_CONFIGS[t]?.pkgKeys?.length);
|
|
21802
|
+
return tools.some((t) => RUNNER_CONFIGS[t]?.sections?.some((s) => s.file.test(base(file9))));
|
|
21791
21803
|
}
|
|
21792
|
-
async function fileFindings(
|
|
21793
|
-
const tools = toolsNear(
|
|
21804
|
+
async function fileFindings(file9, reach, read4) {
|
|
21805
|
+
const tools = toolsNear(file9, reach);
|
|
21794
21806
|
const out = [];
|
|
21795
|
-
if (reach.files.has(
|
|
21796
|
-
const guard2 = reach.guards.find((g) => globMatch(g.replace(/^\.\//, ""),
|
|
21797
|
-
if (guard2) out.push({ kind: "guarded", file:
|
|
21798
|
-
if (!needsText(
|
|
21799
|
-
const texts2 = [await read4.before(
|
|
21800
|
-
if (texts2[0] === void 0 || texts2[1] === void 0) return [...out, unread2(
|
|
21801
|
-
if (base(
|
|
21802
|
-
const targets = reach.makefiles.get(
|
|
21803
|
-
if (targets) out.push(...makeFindings(
|
|
21804
|
-
return [...out, ...configFindings(
|
|
21807
|
+
if (reach.files.has(file9)) out.push({ kind: "named-file", file: file9, text: `${file9} changed (the check runs it)` });
|
|
21808
|
+
const guard2 = reach.guards.find((g) => globMatch(g.replace(/^\.\//, ""), file9));
|
|
21809
|
+
if (guard2) out.push({ kind: "guarded", file: file9, text: `${file9} changed (guarded by ${guard2})` });
|
|
21810
|
+
if (!needsText(file9, reach, tools)) return [...out, ...configFindings(file9, [null, null], tools)];
|
|
21811
|
+
const texts2 = [await read4.before(file9), await read4.after(file9)];
|
|
21812
|
+
if (texts2[0] === void 0 || texts2[1] === void 0) return [...out, unread2(file9)];
|
|
21813
|
+
if (base(file9) === "package.json") out.push(...packageFindings(file9, texts2, reach, tools));
|
|
21814
|
+
const targets = reach.makefiles.get(file9);
|
|
21815
|
+
if (targets) out.push(...makeFindings(file9, texts2, targets));
|
|
21816
|
+
return [...out, ...configFindings(file9, texts2, tools)];
|
|
21805
21817
|
}
|
|
21806
21818
|
async function checkInputFindings(o) {
|
|
21807
21819
|
const out = [];
|
|
21808
|
-
for (const
|
|
21809
|
-
for (const f of await fileFindings(
|
|
21820
|
+
for (const file9 of o.changed)
|
|
21821
|
+
for (const f of await fileFindings(file9, o.reach, o.read)) out.push({ ...f, check: o.reach.check });
|
|
21810
21822
|
return out;
|
|
21811
21823
|
}
|
|
21812
21824
|
|
|
@@ -21962,15 +21974,15 @@ function pkgArgs(args, dir4) {
|
|
|
21962
21974
|
}
|
|
21963
21975
|
function makeArgs(args, dir4) {
|
|
21964
21976
|
let at2 = dir4;
|
|
21965
|
-
let
|
|
21977
|
+
let file9;
|
|
21966
21978
|
let target2 = "";
|
|
21967
21979
|
for (let n = 0; n < args.length; n++) {
|
|
21968
21980
|
const a = args[n];
|
|
21969
21981
|
if (a === "-C" || a === "--directory") at2 = repoPath2(at2, args[++n]) ?? at2;
|
|
21970
|
-
else if (a === "-f" || a === "--file" || a === "--makefile")
|
|
21982
|
+
else if (a === "-f" || a === "--file" || a === "--makefile") file9 = args[++n];
|
|
21971
21983
|
else if (!a.startsWith("-") && !a.includes("=") && !target2) target2 = a;
|
|
21972
21984
|
}
|
|
21973
|
-
return { at: at2, file:
|
|
21985
|
+
return { at: at2, file: file9, target: target2 };
|
|
21974
21986
|
}
|
|
21975
21987
|
var Walk = class {
|
|
21976
21988
|
constructor(name2, guards, read4, changed) {
|
|
@@ -22037,7 +22049,7 @@ var Walk = class {
|
|
|
22037
22049
|
}
|
|
22038
22050
|
if (plan2.kind !== "script") return;
|
|
22039
22051
|
await this.script(at2, plan2.name);
|
|
22040
|
-
if (across) for (const
|
|
22052
|
+
if (across) for (const folder2 of await this.packagesUnder(at2)) await this.script(folder2, plan2.name);
|
|
22041
22053
|
}
|
|
22042
22054
|
/** A package.json script, its pre and post scripts, and the commands they run, read before and after. */
|
|
22043
22055
|
async script(dir4, name2) {
|
|
@@ -22062,21 +22074,21 @@ var Walk = class {
|
|
|
22062
22074
|
for (let n = parts2.length; n > (dir4 ? dir4.split("/").length : 0); n--) folders.add(parts2.slice(0, n).join("/"));
|
|
22063
22075
|
}
|
|
22064
22076
|
const out = [];
|
|
22065
|
-
for (const
|
|
22066
|
-
const [b, a] = await this.both(`${
|
|
22067
|
-
if (b != null || a != null) out.push(
|
|
22077
|
+
for (const folder2 of folders) {
|
|
22078
|
+
const [b, a] = await this.both(`${folder2}/package.json`);
|
|
22079
|
+
if (b != null || a != null) out.push(folder2);
|
|
22068
22080
|
}
|
|
22069
22081
|
return out;
|
|
22070
22082
|
}
|
|
22071
22083
|
/** `make -C dir -f file target`: the makefile, its target, and the recipes the target reaches. */
|
|
22072
22084
|
async make(args, dir4) {
|
|
22073
|
-
const { at: at2, file:
|
|
22074
|
-
const names =
|
|
22085
|
+
const { at: at2, file: file9, target: target2 } = makeArgs(args, dir4);
|
|
22086
|
+
const names = file9 ? [file9] : MAKEFILES;
|
|
22075
22087
|
for (const name2 of names) {
|
|
22076
22088
|
const rel = repoPath2(at2, name2);
|
|
22077
22089
|
if (!rel) continue;
|
|
22078
22090
|
const texts2 = await this.both(rel);
|
|
22079
|
-
if (texts2.every((t) => t == null) && !
|
|
22091
|
+
if (texts2.every((t) => t == null) && !file9) continue;
|
|
22080
22092
|
const targets = this.reach.makefiles.get(rel) ?? /* @__PURE__ */ new Set();
|
|
22081
22093
|
this.reach.makefiles.set(rel, targets.add(target2));
|
|
22082
22094
|
const recipes = texts2.flatMap((text11) => text11 == null ? [] : makeReach(text11, target2 || void 0).recipes);
|
|
@@ -22127,28 +22139,28 @@ var TEST_PATTERNS = [
|
|
|
22127
22139
|
var TEST_PATH = /(^|\/)(tests?|__tests__|specs?|e2e)\/|[._-](test|spec)s?\.[^/]+$|(^|\/)test_[^/]*\.py$|Tests?\.(java|kt)$|\.rs$/;
|
|
22128
22140
|
var count = (text11, r) => text11 && r ? (text11.match(r) ?? []).length : 0;
|
|
22129
22141
|
var tests = (n) => `${n} test${n === 1 ? "" : "s"}`;
|
|
22130
|
-
function weakened(
|
|
22142
|
+
function weakened(file9, p, before, after) {
|
|
22131
22143
|
const had = count(before, p.test);
|
|
22132
22144
|
if (after === null)
|
|
22133
|
-
return had ? [{ kind: "deleted-tests", file:
|
|
22145
|
+
return had ? [{ kind: "deleted-tests", file: file9, text: `${file9} deleted (${tests(had)})` }] : [];
|
|
22134
22146
|
if (after === void 0) return [];
|
|
22135
22147
|
const out = [];
|
|
22136
22148
|
const removed = had - count(after, p.test);
|
|
22137
|
-
if (removed > 0) out.push({ kind: "removed-tests", file:
|
|
22149
|
+
if (removed > 0) out.push({ kind: "removed-tests", file: file9, text: `${tests(removed)} removed from ${file9}` });
|
|
22138
22150
|
const skipped = count(after, p.skip) - count(before, p.skip);
|
|
22139
|
-
if (skipped > 0) out.push({ kind: "skipped", file:
|
|
22151
|
+
if (skipped > 0) out.push({ kind: "skipped", file: file9, text: `${tests(skipped)} skipped in ${file9}` });
|
|
22140
22152
|
const focused = count(after, p.focus) - count(before, p.focus);
|
|
22141
|
-
if (focused > 0) out.push({ kind: "focused", file:
|
|
22153
|
+
if (focused > 0) out.push({ kind: "focused", file: file9, text: `${tests(focused)} focused with .only in ${file9}` });
|
|
22142
22154
|
return out;
|
|
22143
22155
|
}
|
|
22144
22156
|
async function testFindings(o) {
|
|
22145
22157
|
const out = [];
|
|
22146
|
-
for (const
|
|
22147
|
-
const p = TEST_PATTERNS.find((x) => x.file.test(
|
|
22148
|
-
if (!p || !TEST_PATH.test(
|
|
22149
|
-
const before = await o.read.before(
|
|
22158
|
+
for (const file9 of o.changed) {
|
|
22159
|
+
const p = TEST_PATTERNS.find((x) => x.file.test(file9));
|
|
22160
|
+
if (!p || !TEST_PATH.test(file9) || file9.split("/").includes("node_modules")) continue;
|
|
22161
|
+
const before = await o.read.before(file9);
|
|
22150
22162
|
if (typeof before !== "string") continue;
|
|
22151
|
-
out.push(...weakened(
|
|
22163
|
+
out.push(...weakened(file9, p, before, await o.read.after(file9)));
|
|
22152
22164
|
}
|
|
22153
22165
|
return out;
|
|
22154
22166
|
}
|
|
@@ -22212,9 +22224,17 @@ function prefixOf(toplevel, checkout) {
|
|
|
22212
22224
|
const rel = path57.relative(real3(toplevel), real3(checkout)).split(path57.sep).join("/");
|
|
22213
22225
|
return rel.startsWith("..") || path57.isAbsolute(rel) ? "" : rel;
|
|
22214
22226
|
}
|
|
22227
|
+
function noBaseline(config4) {
|
|
22228
|
+
const mode = gateModeFor(config4, "check-guard");
|
|
22229
|
+
if (mode === "off") return void 0;
|
|
22230
|
+
const text11 = "no baseline this machine recorded at the claim: the check guard couldn't tell what the work changed";
|
|
22231
|
+
return { mode, findings: [{ kind: "unread", file: "", text: text11 }] };
|
|
22232
|
+
}
|
|
22215
22233
|
async function localGuard(o) {
|
|
22216
22234
|
const { tree, base: base2 } = o.git;
|
|
22217
|
-
if (!tree
|
|
22235
|
+
if (!tree) return void 0;
|
|
22236
|
+
if (!o.git.baseline) return noBaseline(o.config);
|
|
22237
|
+
if (!base2?.head || !o.git.changed.length) return void 0;
|
|
22218
22238
|
return guardAttempt({
|
|
22219
22239
|
config: o.config,
|
|
22220
22240
|
checks: o.checks,
|
|
@@ -22235,15 +22255,77 @@ async function withLocalGuard(graded, o) {
|
|
|
22235
22255
|
// ../core/src/evidence/collectEvidence.ts
|
|
22236
22256
|
import { existsSync as existsSync21 } from "node:fs";
|
|
22237
22257
|
|
|
22238
|
-
// ../core/src/evidence/
|
|
22239
|
-
import { readdirSync as readdirSync17 } from "node:fs";
|
|
22240
|
-
import
|
|
22258
|
+
// ../core/src/evidence/baselineStore.ts
|
|
22259
|
+
import { linkSync as linkSync4, mkdirSync as mkdirSync21, readdirSync as readdirSync17, rmSync as rmSync13, writeFileSync as writeFileSync15 } from "node:fs";
|
|
22260
|
+
import path58 from "node:path";
|
|
22261
|
+
var DIR = "baselines";
|
|
22262
|
+
var RE = /^baseline-(\d+)\.json$/;
|
|
22263
|
+
var safe13 = (s) => s.replace(/[^\w-]/g, "_");
|
|
22264
|
+
var folder = (root, mapId, ticketId) => path58.join(machineStore(root).dir, DIR, `${safe13(mapId)}--${safe13(ticketId)}`);
|
|
22265
|
+
var macParts = (root, b) => [
|
|
22266
|
+
"baseline",
|
|
22267
|
+
machineId(root),
|
|
22268
|
+
b.mapId,
|
|
22269
|
+
b.ticketId,
|
|
22270
|
+
JSON.stringify(b)
|
|
22271
|
+
];
|
|
22272
|
+
function numbers(dir4) {
|
|
22273
|
+
try {
|
|
22274
|
+
return readdirSync17(dir4).map((n) => Number(n.match(RE)?.[1])).filter((n) => n > 0).sort((a, b) => a - b);
|
|
22275
|
+
} catch {
|
|
22276
|
+
return [];
|
|
22277
|
+
}
|
|
22278
|
+
}
|
|
22279
|
+
function verified(root, o) {
|
|
22280
|
+
const raw = readJsonFile(o.file);
|
|
22281
|
+
const b = raw?.baseline;
|
|
22282
|
+
if (raw?.v !== 1 || b?.v !== 1 || b.mapId !== o.mapId || b.ticketId !== o.ticketId) return void 0;
|
|
22283
|
+
try {
|
|
22284
|
+
return machineSigned(macParts(root, b), raw.mac) ? b : void 0;
|
|
22285
|
+
} catch {
|
|
22286
|
+
return void 0;
|
|
22287
|
+
}
|
|
22288
|
+
}
|
|
22289
|
+
function createWhole(file9, text11) {
|
|
22290
|
+
const tmp = `${file9}.${process.pid}.${Date.now()}.tmp`;
|
|
22291
|
+
writeFileSync15(tmp, text11, { mode: 384, flag: "wx" });
|
|
22292
|
+
try {
|
|
22293
|
+
linkSync4(tmp, file9);
|
|
22294
|
+
} finally {
|
|
22295
|
+
rmSync13(tmp, { force: true });
|
|
22296
|
+
}
|
|
22297
|
+
}
|
|
22298
|
+
var baselineStore = {
|
|
22299
|
+
/** The ticket's most recent baseline as this machine recorded it; undefined when there is none it signed. */
|
|
22300
|
+
latest(root, mapId, ticketId) {
|
|
22301
|
+
const dir4 = folder(root, mapId, ticketId);
|
|
22302
|
+
const n = numbers(dir4).at(-1);
|
|
22303
|
+
return n ? verified(root, { mapId, ticketId, file: path58.join(dir4, `baseline-${n}.json`) }) : void 0;
|
|
22304
|
+
},
|
|
22305
|
+
/** Records a new baseline under the next number, signed; returns it with its id. Throws when it can't be kept. */
|
|
22306
|
+
add(root, rec) {
|
|
22307
|
+
const dir4 = folder(root, rec.mapId, rec.ticketId);
|
|
22308
|
+
mkdirSync21(dir4, { recursive: true, mode: 448 });
|
|
22309
|
+
for (; ; ) {
|
|
22310
|
+
const id = `baseline-${(numbers(dir4).at(-1) ?? 0) + 1}`;
|
|
22311
|
+
const baseline = { ...rec, id };
|
|
22312
|
+
const signed3 = { v: 1, baseline, mac: machineSign(macParts(root, baseline)) };
|
|
22313
|
+
try {
|
|
22314
|
+
createWhole(path58.join(dir4, `${id}.json`), `${JSON.stringify(signed3, null, 2)}
|
|
22315
|
+
`);
|
|
22316
|
+
return baseline;
|
|
22317
|
+
} catch (e) {
|
|
22318
|
+
if (e.code !== "EEXIST") throw e;
|
|
22319
|
+
}
|
|
22320
|
+
}
|
|
22321
|
+
}
|
|
22322
|
+
};
|
|
22241
22323
|
|
|
22242
22324
|
// ../core/src/evidence/treeState.ts
|
|
22243
22325
|
import { createHash as createHash7 } from "node:crypto";
|
|
22244
22326
|
import { existsSync as existsSync20, realpathSync as realpathSync10 } from "node:fs";
|
|
22245
|
-
import
|
|
22246
|
-
var posix = (p) => p.split(
|
|
22327
|
+
import path59 from "node:path";
|
|
22328
|
+
var posix = (p) => p.split(path59.sep).join("/");
|
|
22247
22329
|
async function findWorktree(cwd, trackerRoot) {
|
|
22248
22330
|
if (!existsSync20(cwd)) return { error: `${cwd} does not exist` };
|
|
22249
22331
|
const r = await git(cwd, ["rev-parse", "--show-toplevel"]);
|
|
@@ -22252,15 +22334,15 @@ async function findWorktree(cwd, trackerRoot) {
|
|
|
22252
22334
|
const toplevel = realpathSync10(r.stdout.toString("utf8").trim());
|
|
22253
22335
|
const pathspec = ["--", "."];
|
|
22254
22336
|
if (trackerRoot && existsSync20(trackerRoot)) {
|
|
22255
|
-
const rel =
|
|
22256
|
-
if (rel && !rel.startsWith("..") && !
|
|
22337
|
+
const rel = path59.relative(toplevel, realpathSync10(trackerRoot));
|
|
22338
|
+
if (rel && !rel.startsWith("..") && !path59.isAbsolute(rel)) pathspec.push(`:(exclude)${posix(rel)}`);
|
|
22257
22339
|
}
|
|
22258
22340
|
return { toplevel, pathspec };
|
|
22259
22341
|
}
|
|
22260
22342
|
var emptyTree = (wt) => gitText(wt.toplevel, ["hash-object", "-t", "tree", "--stdin"], "").then((s) => s ?? "");
|
|
22261
22343
|
async function hashFiles(wt, files) {
|
|
22262
22344
|
const out = {};
|
|
22263
|
-
const present = files.filter((f) => existsSync20(
|
|
22345
|
+
const present = files.filter((f) => existsSync20(path59.join(wt.toplevel, f)));
|
|
22264
22346
|
for (const f of files) out[f] = null;
|
|
22265
22347
|
if (!present.length) return out;
|
|
22266
22348
|
const r = await git(wt.toplevel, ["hash-object", "--stdin-paths"], present.join("\n") + "\n");
|
|
@@ -22285,22 +22367,8 @@ async function readTreeState(wt) {
|
|
|
22285
22367
|
}
|
|
22286
22368
|
|
|
22287
22369
|
// ../core/src/evidence/baseline.ts
|
|
22288
|
-
var RE = /^baseline-(\d+)\.json$/;
|
|
22289
|
-
function numbers(root, mapId, ticketId) {
|
|
22290
|
-
try {
|
|
22291
|
-
return readdirSync17(path59.join(root, evidencePaths.ticket(mapId, ticketId))).map((n) => Number(n.match(RE)?.[1])).filter((n) => n > 0).sort((a, b) => a - b);
|
|
22292
|
-
} catch {
|
|
22293
|
-
return [];
|
|
22294
|
-
}
|
|
22295
|
-
}
|
|
22296
|
-
var file3 = (mapId, ticketId, id) => `${evidencePaths.ticket(mapId, ticketId)}/${id}.json`;
|
|
22297
|
-
var readBaseline = (root, mapId, ticketId, id) => {
|
|
22298
|
-
const b = readJsonFile(path59.join(root, file3(mapId, ticketId, id)));
|
|
22299
|
-
return b?.v === 1 ? b : void 0;
|
|
22300
|
-
};
|
|
22301
22370
|
function latestBaseline(root, mapId, ticketId) {
|
|
22302
|
-
|
|
22303
|
-
return n ? readBaseline(root, mapId, ticketId, `baseline-${n}`) : void 0;
|
|
22371
|
+
return baselineStore.latest(root, mapId, ticketId);
|
|
22304
22372
|
}
|
|
22305
22373
|
async function captureBaseline(c) {
|
|
22306
22374
|
const wt = await findWorktree(c.cwd, c.root);
|
|
@@ -22316,16 +22384,10 @@ async function captureBaseline(c) {
|
|
|
22316
22384
|
..."error" in wt ? { git: null, note: wt.error } : { git: await readTreeState(wt) },
|
|
22317
22385
|
...config4.hash ? { configHash: config4.hash } : {}
|
|
22318
22386
|
};
|
|
22319
|
-
|
|
22320
|
-
|
|
22321
|
-
|
|
22322
|
-
|
|
22323
|
-
return { ...rec, id };
|
|
22324
|
-
} catch (e) {
|
|
22325
|
-
const code2 = e.code;
|
|
22326
|
-
if (code2 === "EEXIST") continue;
|
|
22327
|
-
return { ...rec, id, note: `baseline not saved: ${e.message}` };
|
|
22328
|
-
}
|
|
22387
|
+
try {
|
|
22388
|
+
return baselineStore.add(c.root, rec);
|
|
22389
|
+
} catch (e) {
|
|
22390
|
+
return { ...rec, id: "baseline-unsaved", note: `baseline not saved: ${e.message}` };
|
|
22329
22391
|
}
|
|
22330
22392
|
}
|
|
22331
22393
|
async function baselineForClaim(c) {
|
|
@@ -22449,7 +22511,7 @@ function evidenceFlags(i) {
|
|
|
22449
22511
|
out.push({
|
|
22450
22512
|
kind: "no-baseline",
|
|
22451
22513
|
level: "warn",
|
|
22452
|
-
message: "no
|
|
22514
|
+
message: "no baseline this machine recorded at the claim: changes cannot be told apart from earlier work"
|
|
22453
22515
|
});
|
|
22454
22516
|
return out;
|
|
22455
22517
|
}
|
|
@@ -22929,11 +22991,11 @@ ${note}` : reviewBody(t, a)
|
|
|
22929
22991
|
}
|
|
22930
22992
|
|
|
22931
22993
|
// ../core/src/verification/runLock.ts
|
|
22932
|
-
import { mkdirSync as
|
|
22994
|
+
import { mkdirSync as mkdirSync22, readdirSync as readdirSync18, renameSync as renameSync9, rmSync as rmSync14, writeFileSync as writeFileSync16 } from "node:fs";
|
|
22933
22995
|
import path64 from "node:path";
|
|
22934
22996
|
var RUNS_DIR = `${AGENTS_DIR}/runs`;
|
|
22935
|
-
var
|
|
22936
|
-
var lockFile = (root, mapId, ticketId) => path64.join(root, RUNS_DIR, `${
|
|
22997
|
+
var safe14 = (s) => s.replace(/[^\w.-]/g, "_");
|
|
22998
|
+
var lockFile = (root, mapId, ticketId) => path64.join(root, RUNS_DIR, `${safe14(mapId)}--${safe14(ticketId)}.json`);
|
|
22937
22999
|
var readRunLock = (root, mapId, ticketId) => readJsonFile(lockFile(root, mapId, ticketId));
|
|
22938
23000
|
function readRunLocks(root) {
|
|
22939
23001
|
let names = [];
|
|
@@ -22945,18 +23007,18 @@ function readRunLocks(root) {
|
|
|
22945
23007
|
return names.map((n) => readJsonFile(path64.join(root, RUNS_DIR, n))).filter((l) => l?.v === 1 && !!l.ticketId);
|
|
22946
23008
|
}
|
|
22947
23009
|
function recover(root, lock, now2) {
|
|
22948
|
-
const
|
|
22949
|
-
const claimed = `${
|
|
23010
|
+
const file9 = lockFile(root, lock.mapId, lock.ticketId);
|
|
23011
|
+
const claimed = `${file9}.${process.pid}.recover`;
|
|
22950
23012
|
try {
|
|
22951
|
-
renameSync9(
|
|
23013
|
+
renameSync9(file9, claimed);
|
|
22952
23014
|
} catch {
|
|
22953
23015
|
return void 0;
|
|
22954
23016
|
}
|
|
22955
23017
|
const held = readJsonFile(claimed);
|
|
22956
|
-
|
|
23018
|
+
rmSync14(claimed, { force: true });
|
|
22957
23019
|
if (held && held.pid !== lock.pid) {
|
|
22958
23020
|
try {
|
|
22959
|
-
|
|
23021
|
+
writeFileSync16(file9, JSON.stringify(held, null, 2), { flag: "wx" });
|
|
22960
23022
|
} catch {
|
|
22961
23023
|
}
|
|
22962
23024
|
return void 0;
|
|
@@ -22979,14 +23041,14 @@ function recover(root, lock, now2) {
|
|
|
22979
23041
|
return a;
|
|
22980
23042
|
}
|
|
22981
23043
|
function acquireRunLock(root, lock, now2 = Date.now()) {
|
|
22982
|
-
const
|
|
23044
|
+
const file9 = lockFile(root, lock.mapId, lock.ticketId);
|
|
22983
23045
|
const mine2 = { ...lock, pid: process.pid, startedAt: now2 };
|
|
22984
23046
|
let recovered;
|
|
22985
23047
|
ensureLocalDir(path64.join(root, AGENTS_DIR));
|
|
22986
|
-
|
|
23048
|
+
mkdirSync22(path64.dirname(file9), { recursive: true });
|
|
22987
23049
|
for (let i = 0; i < 3; i++) {
|
|
22988
23050
|
try {
|
|
22989
|
-
|
|
23051
|
+
writeFileSync16(file9, JSON.stringify(mine2, null, 2), { flag: "wx" });
|
|
22990
23052
|
return { ok: true, lock: mine2, ...recovered ? { recovered } : {} };
|
|
22991
23053
|
} catch (e) {
|
|
22992
23054
|
if (e.code !== "EEXIST") throw e;
|
|
@@ -22994,7 +23056,7 @@ function acquireRunLock(root, lock, now2 = Date.now()) {
|
|
|
22994
23056
|
const holder2 = readRunLock(root, lock.mapId, lock.ticketId);
|
|
22995
23057
|
if (holder2 && processAlive(holder2.pid)) return { ok: false, holder: holder2 };
|
|
22996
23058
|
if (holder2) recovered = recover(root, holder2, now2) ?? recovered;
|
|
22997
|
-
else
|
|
23059
|
+
else rmSync14(file9, { force: true });
|
|
22998
23060
|
}
|
|
22999
23061
|
const holder = readRunLock(root, lock.mapId, lock.ticketId);
|
|
23000
23062
|
if (holder) return { ok: false, holder };
|
|
@@ -23002,7 +23064,7 @@ function acquireRunLock(root, lock, now2 = Date.now()) {
|
|
|
23002
23064
|
}
|
|
23003
23065
|
function releaseRunLock(root, mapId, ticketId, pid = process.pid) {
|
|
23004
23066
|
const held = readRunLock(root, mapId, ticketId);
|
|
23005
|
-
if (held?.pid === pid)
|
|
23067
|
+
if (held?.pid === pid) rmSync14(lockFile(root, mapId, ticketId), { force: true });
|
|
23006
23068
|
}
|
|
23007
23069
|
var recoverInterrupted = (root, now2 = Date.now()) => readRunLocks(root).filter((l) => !processAlive(l.pid)).map((l) => recover(root, l, now2)).filter((a) => !!a);
|
|
23008
23070
|
|
|
@@ -23144,13 +23206,13 @@ function outcomeOf3(checks, asked) {
|
|
|
23144
23206
|
}
|
|
23145
23207
|
|
|
23146
23208
|
// ../core/src/verification/checkWaivers.ts
|
|
23147
|
-
import { mkdirSync as
|
|
23209
|
+
import { mkdirSync as mkdirSync23 } from "node:fs";
|
|
23148
23210
|
var FILE8 = "waivers.json";
|
|
23149
23211
|
var keyOf5 = (mapId, ticketId) => `${mapId}/${ticketId}`;
|
|
23150
23212
|
function change(root, fn) {
|
|
23151
23213
|
try {
|
|
23152
23214
|
const store = machineStore(root);
|
|
23153
|
-
|
|
23215
|
+
mkdirSync23(store.dir, { recursive: true, mode: 448 });
|
|
23154
23216
|
withFileLock2(store.file(`${FILE8}.lock`), () => {
|
|
23155
23217
|
const all = store.read(FILE8) ?? {};
|
|
23156
23218
|
fn(all);
|
|
@@ -23230,7 +23292,7 @@ function matchRules(rules2, files) {
|
|
|
23230
23292
|
}
|
|
23231
23293
|
|
|
23232
23294
|
// ../core/src/verification/ruleWaivers.ts
|
|
23233
|
-
import { mkdirSync as
|
|
23295
|
+
import { mkdirSync as mkdirSync24 } from "node:fs";
|
|
23234
23296
|
var FILE9 = "rule-waivers.json";
|
|
23235
23297
|
var keyOf6 = (mapId, ticketId) => `${mapId}/${ticketId}`;
|
|
23236
23298
|
var ruleWaivers = {
|
|
@@ -23246,7 +23308,7 @@ var ruleWaivers = {
|
|
|
23246
23308
|
add(root, w) {
|
|
23247
23309
|
try {
|
|
23248
23310
|
const store = machineStore(root);
|
|
23249
|
-
|
|
23311
|
+
mkdirSync24(store.dir, { recursive: true, mode: 448 });
|
|
23250
23312
|
withFileLock2(store.file(`${FILE9}.lock`), () => {
|
|
23251
23313
|
const all = store.read(FILE9) ?? {};
|
|
23252
23314
|
const key = keyOf6(w.mapId, w.ticketId);
|
|
@@ -23258,6 +23320,26 @@ var ruleWaivers = {
|
|
|
23258
23320
|
`Couldn't keep it in Teamtrail's config folder on this machine: ${e.message}`
|
|
23259
23321
|
);
|
|
23260
23322
|
}
|
|
23323
|
+
},
|
|
23324
|
+
/** Removes the ticket's waiver of `rule` under the file's lock; returns it, or undefined when there was none. */
|
|
23325
|
+
remove(root, at2) {
|
|
23326
|
+
try {
|
|
23327
|
+
const store = machineStore(root);
|
|
23328
|
+
mkdirSync24(store.dir, { recursive: true, mode: 448 });
|
|
23329
|
+
return withFileLock2(store.file(`${FILE9}.lock`), () => {
|
|
23330
|
+
const all = store.read(FILE9) ?? {};
|
|
23331
|
+
const key = keyOf6(at2.mapId, at2.ticketId);
|
|
23332
|
+
const gone = all[key]?.find((x) => x.rule === at2.rule);
|
|
23333
|
+
if (!gone) return void 0;
|
|
23334
|
+
const left = all[key].filter((x) => x !== gone);
|
|
23335
|
+
if (left.length) all[key] = left;
|
|
23336
|
+
else delete all[key];
|
|
23337
|
+
store.write(FILE9, all);
|
|
23338
|
+
return gone;
|
|
23339
|
+
});
|
|
23340
|
+
} catch (e) {
|
|
23341
|
+
throw new OperationError(`Couldn't change Teamtrail's config folder on this machine: ${e.message}`);
|
|
23342
|
+
}
|
|
23261
23343
|
}
|
|
23262
23344
|
};
|
|
23263
23345
|
|
|
@@ -23508,14 +23590,14 @@ function reviewItem({ base: base2, last, verdict: verdict2 }, level) {
|
|
|
23508
23590
|
|
|
23509
23591
|
// ../core/src/workspaces/integrationStore.ts
|
|
23510
23592
|
import path67 from "node:path";
|
|
23511
|
-
var
|
|
23593
|
+
var file3 = (root) => path67.join(root, AGENTS_DIR, "integration.json");
|
|
23512
23594
|
function readIntegrationScan(root) {
|
|
23513
|
-
const s = readJsonFile(
|
|
23595
|
+
const s = readJsonFile(file3(root));
|
|
23514
23596
|
return s?.v === 1 ? s : { v: 1, at: 0, overlaps: [] };
|
|
23515
23597
|
}
|
|
23516
23598
|
function writeIntegrationScan(root, s) {
|
|
23517
23599
|
ensureLocalDir(path67.join(root, AGENTS_DIR));
|
|
23518
|
-
writeJsonAtomic(
|
|
23600
|
+
writeJsonAtomic(file3(root), s);
|
|
23519
23601
|
}
|
|
23520
23602
|
|
|
23521
23603
|
// ../core/src/precedent/precedentAreas.ts
|
|
@@ -23603,12 +23685,12 @@ async function readViolations(input2) {
|
|
|
23603
23685
|
}
|
|
23604
23686
|
|
|
23605
23687
|
// ../core/src/planning/reroute/rerouteStore.ts
|
|
23606
|
-
import { mkdirSync as
|
|
23688
|
+
import { mkdirSync as mkdirSync25, readdirSync as readdirSync19, writeFileSync as writeFileSync17 } from "node:fs";
|
|
23607
23689
|
import path68 from "node:path";
|
|
23608
23690
|
var REROUTES_DIR = ".reroutes";
|
|
23609
|
-
var
|
|
23610
|
-
var mapDir = (root, mapId) => path68.join(root, REROUTES_DIR,
|
|
23611
|
-
var fileOf = (root, mapId, id) => path68.join(mapDir(root, mapId), `${
|
|
23691
|
+
var safe15 = (s) => s.replace(/[^\w.-]/g, "_");
|
|
23692
|
+
var mapDir = (root, mapId) => path68.join(root, REROUTES_DIR, safe15(mapId));
|
|
23693
|
+
var fileOf = (root, mapId, id) => path68.join(mapDir(root, mapId), `${safe15(id)}.json`);
|
|
23612
23694
|
var idNumber2 = (id) => Number(id.match(/^R-(\d+)$/)?.[1] ?? 0);
|
|
23613
23695
|
function listReroutes(root, mapId) {
|
|
23614
23696
|
let names = [];
|
|
@@ -23632,12 +23714,12 @@ var readReroute = (root, mapId, id) => readJsonFile(fileOf(root, mapId, id));
|
|
|
23632
23714
|
function createReroute(root, draft) {
|
|
23633
23715
|
const dir4 = mapDir(root, draft.mapId);
|
|
23634
23716
|
ensureLocalDir(path68.join(root, REROUTES_DIR));
|
|
23635
|
-
|
|
23717
|
+
mkdirSync25(dir4, { recursive: true });
|
|
23636
23718
|
let n = Math.max(0, ...listReroutes(root, draft.mapId).map((p) => idNumber2(p.id))) + 1;
|
|
23637
23719
|
for (; ; ) {
|
|
23638
23720
|
const p = { ...draft, id: `R-${n}` };
|
|
23639
23721
|
try {
|
|
23640
|
-
|
|
23722
|
+
writeFileSync17(fileOf(root, draft.mapId, p.id), JSON.stringify(p, null, 2), { flag: "wx" });
|
|
23641
23723
|
return p;
|
|
23642
23724
|
} catch (e) {
|
|
23643
23725
|
if (e.code !== "EEXIST") throw e;
|
|
@@ -23773,11 +23855,11 @@ async function attentionView(input2) {
|
|
|
23773
23855
|
import { existsSync as existsSync24, readFileSync as readFileSync27 } from "node:fs";
|
|
23774
23856
|
import path69 from "node:path";
|
|
23775
23857
|
function writeReviewLimit(root, limit) {
|
|
23776
|
-
const
|
|
23858
|
+
const file9 = path69.join(root, ATTENTION_FILE);
|
|
23777
23859
|
let raw = { v: 1 };
|
|
23778
|
-
if (existsSync24(
|
|
23860
|
+
if (existsSync24(file9)) {
|
|
23779
23861
|
try {
|
|
23780
|
-
const read4 = parseJsonSafe(readFileSync27(
|
|
23862
|
+
const read4 = parseJsonSafe(readFileSync27(file9, "utf8"));
|
|
23781
23863
|
if (!read4 || typeof read4 !== "object" || Array.isArray(read4)) throw new Error("not a JSON object");
|
|
23782
23864
|
raw = read4;
|
|
23783
23865
|
} catch (err) {
|
|
@@ -23792,7 +23874,7 @@ function writeReviewLimit(root, limit) {
|
|
|
23792
23874
|
const parsed3 = parseAttentionPolicy(next);
|
|
23793
23875
|
const own3 = parsed3.errors.filter((e) => e.includes('"reviewLimit"'));
|
|
23794
23876
|
if (own3.length) return { value: parsed3.value, errors: own3 };
|
|
23795
|
-
writeJsonAtomic(
|
|
23877
|
+
writeJsonAtomic(file9, next);
|
|
23796
23878
|
return { value: parsed3.value, errors: [] };
|
|
23797
23879
|
}
|
|
23798
23880
|
|
|
@@ -23927,8 +24009,8 @@ async function handleBriefs({ root, active }, req, res, url2) {
|
|
|
23927
24009
|
if (url2.pathname === "/briefs" && req.method === "GET") {
|
|
23928
24010
|
const mapId2 = url2.searchParams.get("mapId");
|
|
23929
24011
|
if (!trailId(mapId2)) throw new BadRequest('"mapId" is required');
|
|
23930
|
-
const
|
|
23931
|
-
const hash2 =
|
|
24012
|
+
const file9 = readBriefFile(root, mapId2);
|
|
24013
|
+
const hash2 = file9 ? { hash: contentHash(file9.text) } : {};
|
|
23932
24014
|
sendJson(res, 200, { brief: readBrief(root, mapId2) ?? null, gated: requiresDiscovery(root, mapId2), ...hash2 });
|
|
23933
24015
|
return true;
|
|
23934
24016
|
}
|
|
@@ -23988,30 +24070,30 @@ async function seedAssumptions(adapter, brief) {
|
|
|
23988
24070
|
}
|
|
23989
24071
|
|
|
23990
24072
|
// ../core/src/criteria/criteriaProposals.ts
|
|
23991
|
-
import { rmSync as
|
|
24073
|
+
import { rmSync as rmSync15 } from "node:fs";
|
|
23992
24074
|
import path71 from "node:path";
|
|
23993
24075
|
|
|
23994
24076
|
// ../core/src/agents/ignoreAgentsDir.ts
|
|
23995
|
-
import { existsSync as existsSync25, mkdirSync as
|
|
24077
|
+
import { existsSync as existsSync25, mkdirSync as mkdirSync26, writeFileSync as writeFileSync18 } from "node:fs";
|
|
23996
24078
|
import path70 from "node:path";
|
|
23997
24079
|
function ignoreAgentsDir(root) {
|
|
23998
24080
|
const ignore = path70.join(root, AGENTS_DIR, ".gitignore");
|
|
23999
|
-
|
|
24000
|
-
if (!existsSync25(ignore))
|
|
24081
|
+
mkdirSync26(path70.dirname(ignore), { recursive: true });
|
|
24082
|
+
if (!existsSync25(ignore)) writeFileSync18(ignore, "*\n");
|
|
24001
24083
|
}
|
|
24002
24084
|
|
|
24003
24085
|
// ../core/src/criteria/criteriaProposals.ts
|
|
24004
|
-
var
|
|
24005
|
-
var
|
|
24086
|
+
var safe16 = (s) => s.replace(/[^\w.-]/g, "_");
|
|
24087
|
+
var file4 = (root, mapId) => path71.join(root, AGENTS_DIR, "criteria-proposals", `${safe16(mapId)}.json`);
|
|
24006
24088
|
var isProposal = (p) => !!p && typeof p.ticketId === "string" && typeof p.by === "string" && Array.isArray(p.criteria);
|
|
24007
24089
|
function readCriteriaProposals(root, mapId) {
|
|
24008
|
-
const f = readJsonFile(
|
|
24090
|
+
const f = readJsonFile(file4(root, mapId));
|
|
24009
24091
|
return f?.v === 1 && Array.isArray(f.proposals) ? f.proposals.filter(isProposal) : [];
|
|
24010
24092
|
}
|
|
24011
24093
|
function save(root, mapId, proposals) {
|
|
24012
24094
|
ignoreAgentsDir(root);
|
|
24013
|
-
if (proposals.length) writeJsonAtomic(
|
|
24014
|
-
else
|
|
24095
|
+
if (proposals.length) writeJsonAtomic(file4(root, mapId), { v: 1, proposals });
|
|
24096
|
+
else rmSync15(file4(root, mapId), { force: true });
|
|
24015
24097
|
}
|
|
24016
24098
|
function writeCriteriaProposal(root, mapId, p) {
|
|
24017
24099
|
save(root, mapId, [...readCriteriaProposals(root, mapId).filter((x) => x.ticketId !== p.ticketId), p]);
|
|
@@ -24112,7 +24194,7 @@ async function handleDecisionMemory(ctx, req, res, url2) {
|
|
|
24112
24194
|
}
|
|
24113
24195
|
|
|
24114
24196
|
// ../core/src/policy/lookoutOnlyTickets.ts
|
|
24115
|
-
import { mkdirSync as
|
|
24197
|
+
import { mkdirSync as mkdirSync27 } from "node:fs";
|
|
24116
24198
|
var FILE10 = "lookout-only.json";
|
|
24117
24199
|
var keyOf7 = (mapId, ticketId) => `${mapId}/${ticketId}`;
|
|
24118
24200
|
var lookoutOnlyTickets = {
|
|
@@ -24120,7 +24202,7 @@ var lookoutOnlyTickets = {
|
|
|
24120
24202
|
mark(root, o) {
|
|
24121
24203
|
try {
|
|
24122
24204
|
const store = machineStore(root);
|
|
24123
|
-
|
|
24205
|
+
mkdirSync27(store.dir, { recursive: true, mode: 448 });
|
|
24124
24206
|
withFileLock2(store.file(`${FILE10}.lock`), () => {
|
|
24125
24207
|
const marks = store.read(FILE10) ?? {};
|
|
24126
24208
|
const was = marks[keyOf7(o.mapId, o.ticketId)];
|
|
@@ -24375,15 +24457,15 @@ async function handleFlakyChecks(ctx, req, res, url2) {
|
|
|
24375
24457
|
}
|
|
24376
24458
|
|
|
24377
24459
|
// ../core/src/guides/approveCheck.ts
|
|
24378
|
-
import { writeFileSync as
|
|
24460
|
+
import { writeFileSync as writeFileSync19 } from "node:fs";
|
|
24379
24461
|
import path73 from "node:path";
|
|
24380
24462
|
|
|
24381
24463
|
// ../core/src/verification/rawConfig.ts
|
|
24382
24464
|
import { readFileSync as readFileSync28 } from "node:fs";
|
|
24383
|
-
function readRawConfig(
|
|
24465
|
+
function readRawConfig(file9, fresh2) {
|
|
24384
24466
|
let text11;
|
|
24385
24467
|
try {
|
|
24386
|
-
text11 = readFileSync28(
|
|
24468
|
+
text11 = readFileSync28(file9, "utf8");
|
|
24387
24469
|
} catch {
|
|
24388
24470
|
return fresh2;
|
|
24389
24471
|
}
|
|
@@ -24395,7 +24477,7 @@ function readRawConfig(file10, fresh2) {
|
|
|
24395
24477
|
}
|
|
24396
24478
|
|
|
24397
24479
|
// ../core/src/guides/approveCheck.ts
|
|
24398
|
-
var readRaw2 = (
|
|
24480
|
+
var readRaw2 = (file9) => readRawConfig(file9, { v: 1, default: "off", checks: {} });
|
|
24399
24481
|
var specOf = (p) => ({
|
|
24400
24482
|
run: p.run,
|
|
24401
24483
|
...p.timeoutSec ? { timeoutSec: p.timeoutSec } : {},
|
|
@@ -24412,8 +24494,8 @@ function approveCheck(input2) {
|
|
|
24412
24494
|
const notice = checkNotice(proposed2);
|
|
24413
24495
|
if (notice && !input2.acknowledged)
|
|
24414
24496
|
throw new OperationError(`check ${input2.name}: ${notice}; approve it again, acknowledging that`);
|
|
24415
|
-
const
|
|
24416
|
-
const raw = readRaw2(
|
|
24497
|
+
const file9 = path73.join(input2.root, VERIFICATION_FILE);
|
|
24498
|
+
const raw = readRaw2(file9);
|
|
24417
24499
|
const checks = { ...raw.checks ?? {} };
|
|
24418
24500
|
const spec = specOf(proposed2);
|
|
24419
24501
|
const existing = checks[input2.name];
|
|
@@ -24429,7 +24511,7 @@ function approveCheck(input2) {
|
|
|
24429
24511
|
const { errors } = parseVerificationConfig(text11);
|
|
24430
24512
|
if (errors.length) throw new OperationError(`${VERIFICATION_FILE} would be invalid: ${errors.join("; ")}`);
|
|
24431
24513
|
const wasApproved = !checksApproval(input2.root).waiting;
|
|
24432
|
-
|
|
24514
|
+
writeFileSync19(file9, text11);
|
|
24433
24515
|
if (wasApproved) approveChecksHere(input2.root, "trail lead", text11);
|
|
24434
24516
|
lock.guides[input2.id].approvedChecks[input2.name] = checkSha(proposed2);
|
|
24435
24517
|
writeGuideLock(input2.root, lock, input2.id);
|
|
@@ -24452,7 +24534,7 @@ function readChecklist(root, mapId, ticketId) {
|
|
|
24452
24534
|
}
|
|
24453
24535
|
|
|
24454
24536
|
// ../core/src/guides/installGuide.ts
|
|
24455
|
-
import { mkdirSync as
|
|
24537
|
+
import { mkdirSync as mkdirSync28, readFileSync as readFileSync29, writeFileSync as writeFileSync20 } from "node:fs";
|
|
24456
24538
|
function lintRefusal(text11) {
|
|
24457
24539
|
const lint = lintGuide(text11);
|
|
24458
24540
|
if (lint.ok) return void 0;
|
|
@@ -24466,8 +24548,8 @@ function installGuide(input2) {
|
|
|
24466
24548
|
const guide = lintGuide(input2.text).guide;
|
|
24467
24549
|
if (input2.expectId && guide.id !== input2.expectId)
|
|
24468
24550
|
throw new OperationError(`the file is guide "${guide.id}", not "${input2.expectId}"`);
|
|
24469
|
-
|
|
24470
|
-
|
|
24551
|
+
mkdirSync28(guidesDir(input2.root), { recursive: true });
|
|
24552
|
+
writeFileSync20(guideFilePath(input2.root, guide.id), input2.text);
|
|
24471
24553
|
const lock = readGuideLock(input2.root);
|
|
24472
24554
|
const prev = lock.guides[guide.id];
|
|
24473
24555
|
const approvedHere = readApprovedLock(input2.root).guides[guide.id]?.approvedChecks ?? {};
|
|
@@ -24512,14 +24594,14 @@ function approveGuide(input2) {
|
|
|
24512
24594
|
}
|
|
24513
24595
|
|
|
24514
24596
|
// ../core/src/guides/removeGuide.ts
|
|
24515
|
-
import { rmSync as
|
|
24597
|
+
import { rmSync as rmSync16 } from "node:fs";
|
|
24516
24598
|
function removeGuide(input2) {
|
|
24517
24599
|
const lock = readGuideLock(input2.root);
|
|
24518
|
-
const
|
|
24600
|
+
const file9 = guideFilePath(input2.root, input2.id);
|
|
24519
24601
|
const pinned = input2.id in lock.guides;
|
|
24520
24602
|
let had = false;
|
|
24521
24603
|
try {
|
|
24522
|
-
|
|
24604
|
+
rmSync16(file9);
|
|
24523
24605
|
had = true;
|
|
24524
24606
|
} catch {
|
|
24525
24607
|
}
|
|
@@ -25094,7 +25176,7 @@ function canonicalJson(value) {
|
|
|
25094
25176
|
var gapsHash = (o) => contentHash(canonicalJson({ head: o.head, gaps: o.gaps }));
|
|
25095
25177
|
|
|
25096
25178
|
// ../core/src/proof/mergeAcceptances.ts
|
|
25097
|
-
import { mkdirSync as
|
|
25179
|
+
import { mkdirSync as mkdirSync29 } from "node:fs";
|
|
25098
25180
|
var FILE11 = "merge-anyway.json";
|
|
25099
25181
|
var KEPT = 20;
|
|
25100
25182
|
var keyOf8 = (mapId, ticketId) => `${mapId}/${ticketId}`;
|
|
@@ -25111,7 +25193,7 @@ var mergeAcceptances = {
|
|
|
25111
25193
|
add(root, a) {
|
|
25112
25194
|
try {
|
|
25113
25195
|
const store = machineStore(root);
|
|
25114
|
-
|
|
25196
|
+
mkdirSync29(store.dir, { recursive: true, mode: 448 });
|
|
25115
25197
|
withFileLock2(store.file(`${FILE11}.lock`), () => {
|
|
25116
25198
|
const all = store.read(FILE11) ?? {};
|
|
25117
25199
|
const key = keyOf8(a.mapId, a.ticketId);
|
|
@@ -25469,9 +25551,9 @@ async function handleMergeAnyway(ctx, req, res, url2) {
|
|
|
25469
25551
|
import { existsSync as existsSync26, readFileSync as readFileSync30 } from "node:fs";
|
|
25470
25552
|
import path76 from "node:path";
|
|
25471
25553
|
function readModelsConfig(root) {
|
|
25472
|
-
const
|
|
25473
|
-
if (!existsSync26(
|
|
25474
|
-
const parsed3 = parseModelsConfig(readFileSync30(
|
|
25554
|
+
const file9 = path76.join(root, MODELS_FILE);
|
|
25555
|
+
if (!existsSync26(file9)) return { models: {}, errors: [], exists: false };
|
|
25556
|
+
const parsed3 = parseModelsConfig(readFileSync30(file9, "utf8"));
|
|
25475
25557
|
return { models: parsed3.models ?? {}, errors: parsed3.errors, exists: true };
|
|
25476
25558
|
}
|
|
25477
25559
|
|
|
@@ -25539,14 +25621,14 @@ function proofPostSetting(root, dir4) {
|
|
|
25539
25621
|
|
|
25540
25622
|
// ../core/src/proof/proofPostStore.ts
|
|
25541
25623
|
import path77 from "node:path";
|
|
25542
|
-
var
|
|
25624
|
+
var file5 = (root, mapId, ticketId) => path77.join(root, evidencePaths.ticket(mapId, ticketId), "proof-post.json");
|
|
25543
25625
|
function readProofPost(root, mapId, ticketId) {
|
|
25544
|
-
const r = readJsonFile(
|
|
25626
|
+
const r = readJsonFile(file5(root, mapId, ticketId));
|
|
25545
25627
|
return r?.v === 1 ? r : void 0;
|
|
25546
25628
|
}
|
|
25547
25629
|
function writeProofPost(root, r) {
|
|
25548
25630
|
ensureLocalDir(path77.join(root, EVIDENCE_DIR));
|
|
25549
|
-
writeJsonAtomic(
|
|
25631
|
+
writeJsonAtomic(file5(root, r.mapId, r.ticketId), r);
|
|
25550
25632
|
}
|
|
25551
25633
|
|
|
25552
25634
|
// ../core/src/proof/proofStatus.ts
|
|
@@ -25762,18 +25844,18 @@ function proofMarkdown(p, signature4) {
|
|
|
25762
25844
|
}
|
|
25763
25845
|
|
|
25764
25846
|
// ../core/src/proof/repoProofKey.ts
|
|
25765
|
-
import { existsSync as existsSync27, mkdirSync as
|
|
25847
|
+
import { existsSync as existsSync27, mkdirSync as mkdirSync30, writeFileSync as writeFileSync21 } from "node:fs";
|
|
25766
25848
|
import path80 from "node:path";
|
|
25767
25849
|
|
|
25768
25850
|
// ../core/src/machine/proofKey.ts
|
|
25769
25851
|
import { createHash as createHash9, createPrivateKey, generateKeyPairSync, randomBytes as randomBytes6 } from "node:crypto";
|
|
25770
|
-
import { linkSync as
|
|
25852
|
+
import { linkSync as linkSync5, readFileSync as readFileSync31, rmSync as rmSync17 } from "node:fs";
|
|
25771
25853
|
import path79 from "node:path";
|
|
25772
25854
|
var PROOF_KEY_FILE = "proof-key.json";
|
|
25773
25855
|
var proofKeyId = (publicKeyB64) => createHash9("sha256").update(Buffer.from(publicKeyB64, "base64")).digest("hex").slice(0, 16);
|
|
25774
|
-
function read(
|
|
25856
|
+
function read(file9) {
|
|
25775
25857
|
try {
|
|
25776
|
-
const s = JSON.parse(readFileSync31(
|
|
25858
|
+
const s = JSON.parse(readFileSync31(file9, "utf8"));
|
|
25777
25859
|
return s?.v === 1 && s.id === proofKeyId(s.publicKey) ? s : void 0;
|
|
25778
25860
|
} catch (e) {
|
|
25779
25861
|
if (e.code === "ENOENT" || e instanceof SyntaxError) return void 0;
|
|
@@ -25791,21 +25873,21 @@ function fresh() {
|
|
|
25791
25873
|
};
|
|
25792
25874
|
}
|
|
25793
25875
|
function machineProofKey(dir4 = configDir()) {
|
|
25794
|
-
const
|
|
25795
|
-
let s = read(
|
|
25876
|
+
const file9 = path79.join(dir4, PROOF_KEY_FILE);
|
|
25877
|
+
let s = read(file9);
|
|
25796
25878
|
if (!s) {
|
|
25797
|
-
const draft = `${
|
|
25879
|
+
const draft = `${file9}.${process.pid}.${randomBytes6(4).toString("hex")}`;
|
|
25798
25880
|
writePrivateFile(draft, `${JSON.stringify(fresh())}
|
|
25799
25881
|
`);
|
|
25800
25882
|
try {
|
|
25801
|
-
|
|
25883
|
+
linkSync5(draft, file9);
|
|
25802
25884
|
} catch (e) {
|
|
25803
25885
|
if (e.code !== "EEXIST") throw e;
|
|
25804
25886
|
} finally {
|
|
25805
|
-
|
|
25887
|
+
rmSync17(draft, { force: true });
|
|
25806
25888
|
}
|
|
25807
|
-
s = read(
|
|
25808
|
-
if (!s) throw new Error(`${
|
|
25889
|
+
s = read(file9);
|
|
25890
|
+
if (!s) throw new Error(`${file9} is not a proof key: move it away and Teamtrail makes a new one`);
|
|
25809
25891
|
}
|
|
25810
25892
|
return { id: s.id, publicKey: s.publicKey, privateKey: createPrivateKey(s.privateKey) };
|
|
25811
25893
|
}
|
|
@@ -25822,11 +25904,11 @@ function ensureRepoProofKey(root, dir4) {
|
|
|
25822
25904
|
return void 0;
|
|
25823
25905
|
}
|
|
25824
25906
|
const rel = path80.join(PROOF_KEYS_DIR, `${key.id}.pub`);
|
|
25825
|
-
const
|
|
25826
|
-
if (!existsSync27(
|
|
25827
|
-
|
|
25907
|
+
const file9 = path80.join(root, rel);
|
|
25908
|
+
if (!existsSync27(file9)) {
|
|
25909
|
+
mkdirSync30(path80.dirname(file9), { recursive: true });
|
|
25828
25910
|
try {
|
|
25829
|
-
|
|
25911
|
+
writeFileSync21(file9, proofKeyLine(key.publicKey), { flag: "wx" });
|
|
25830
25912
|
} catch (e) {
|
|
25831
25913
|
if (e.code !== "EEXIST") throw e;
|
|
25832
25914
|
}
|
|
@@ -26050,7 +26132,7 @@ function redactResponse(res, places = []) {
|
|
|
26050
26132
|
}
|
|
26051
26133
|
|
|
26052
26134
|
// ../core/src/remoteAgents/mcpEndpoints.ts
|
|
26053
|
-
import { readdirSync as readdirSync20, rmSync as
|
|
26135
|
+
import { readdirSync as readdirSync20, rmSync as rmSync18 } from "node:fs";
|
|
26054
26136
|
import os3 from "node:os";
|
|
26055
26137
|
import path81 from "node:path";
|
|
26056
26138
|
|
|
@@ -26090,17 +26172,17 @@ function ownEndpointUrl(raw, addresses) {
|
|
|
26090
26172
|
}
|
|
26091
26173
|
|
|
26092
26174
|
// ../core/src/remoteAgents/mcpEndpoints.ts
|
|
26093
|
-
var
|
|
26175
|
+
var DIR2 = `${AGENTS_DIR}/mcp-endpoints`;
|
|
26094
26176
|
var ENDPOINT_SIG = "mcp-endpoint";
|
|
26095
26177
|
var fieldsOf = (e) => [e.url, e.pid, e.kind, e.network === true, e.startedAt];
|
|
26096
26178
|
function writeMcpEndpoint(root, e) {
|
|
26097
|
-
const
|
|
26179
|
+
const file9 = path81.join(root, DIR2, `${process.pid}.json`);
|
|
26098
26180
|
ensureLocalDir(path81.join(root, AGENTS_DIR));
|
|
26099
26181
|
const base2 = { url: e.url, kind: e.kind, network: e.network, pid: process.pid, startedAt: Date.now() };
|
|
26100
26182
|
const sig = announcementSig(root, ENDPOINT_SIG, fieldsOf(base2));
|
|
26101
26183
|
const endpoint = { ...base2, ...sig ? { sig } : {} };
|
|
26102
|
-
writeJsonAtomic(
|
|
26103
|
-
return () =>
|
|
26184
|
+
writeJsonAtomic(file9, endpoint);
|
|
26185
|
+
return () => rmSync18(file9, { force: true });
|
|
26104
26186
|
}
|
|
26105
26187
|
var ownAddresses = () => Object.values(os3.networkInterfaces()).flatMap((list8) => list8 ?? []).map((a) => a.address.toLowerCase());
|
|
26106
26188
|
function believed(root, at2, e) {
|
|
@@ -26115,12 +26197,12 @@ function believed(root, at2, e) {
|
|
|
26115
26197
|
function readMcpEndpoints(root) {
|
|
26116
26198
|
let names = [];
|
|
26117
26199
|
try {
|
|
26118
|
-
names = readdirSync20(path81.join(root,
|
|
26200
|
+
names = readdirSync20(path81.join(root, DIR2)).filter((n) => n.endsWith(".json"));
|
|
26119
26201
|
} catch {
|
|
26120
26202
|
return [];
|
|
26121
26203
|
}
|
|
26122
26204
|
const addresses = ownAddresses();
|
|
26123
|
-
return names.map((n) => believed(root, { name: n, addresses }, readJsonFile(path81.join(root,
|
|
26205
|
+
return names.map((n) => believed(root, { name: n, addresses }, readJsonFile(path81.join(root, DIR2, n)))).filter((e) => !!e).sort((a, b) => Number(b.kind === "standalone") - Number(a.kind === "standalone") || a.startedAt - b.startedAt);
|
|
26124
26206
|
}
|
|
26125
26207
|
|
|
26126
26208
|
// ../core/src/remoteAgents/remoteTokens.ts
|
|
@@ -26388,11 +26470,11 @@ function write(root, p, by) {
|
|
|
26388
26470
|
}
|
|
26389
26471
|
var keepApprovedReroute = write;
|
|
26390
26472
|
var keepRerouteProgress = write;
|
|
26391
|
-
function approvedReroute(root,
|
|
26392
|
-
const kept = read2(root,
|
|
26473
|
+
function approvedReroute(root, file9) {
|
|
26474
|
+
const kept = read2(root, file9);
|
|
26393
26475
|
if (!kept) return void 0;
|
|
26394
26476
|
const changes2 = kept.core.changes;
|
|
26395
|
-
return { ...
|
|
26477
|
+
return { ...file9, ...kept.core, changes: changes2, applied: kept.applied, created: kept.created ?? {} };
|
|
26396
26478
|
}
|
|
26397
26479
|
|
|
26398
26480
|
// ../core/src/discovery/skipDiscoveryHere.ts
|
|
@@ -26734,10 +26816,10 @@ var ALL = { recentMs: Number.MAX_SAFE_INTEGER, limit: Number.MAX_SAFE_INTEGER };
|
|
|
26734
26816
|
var guidesOf2 = (guides) => guides ? { guides: guides.map((g) => g.id) } : {};
|
|
26735
26817
|
var passed6 = (c) => c.exitCode === 0 && !c.timedOut && !c.error;
|
|
26736
26818
|
function escapeFields(attempts, escape3) {
|
|
26737
|
-
const
|
|
26819
|
+
const verified2 = attempts.find((a) => a.id === escape3?.attemptId) ?? [...attempts].reverse().find((a) => a.result === "pass");
|
|
26738
26820
|
return {
|
|
26739
26821
|
...escape3 ? { escaped: true } : {},
|
|
26740
|
-
...
|
|
26822
|
+
...verified2 ? { passedChecks: verified2.checks.filter(passed6).map((c) => c.name) } : {}
|
|
26741
26823
|
};
|
|
26742
26824
|
}
|
|
26743
26825
|
function ticketOf2(input2) {
|
|
@@ -27433,14 +27515,14 @@ async function handleLinearTeams(req, res, o) {
|
|
|
27433
27515
|
}
|
|
27434
27516
|
|
|
27435
27517
|
// ../core/src/adapters/remote/acceptedSettingsFile.ts
|
|
27436
|
-
import { existsSync as existsSync28, mkdirSync as
|
|
27518
|
+
import { existsSync as existsSync28, mkdirSync as mkdirSync31, rmSync as rmSync19 } from "node:fs";
|
|
27437
27519
|
import { open, rename, rm, stat as stat2 } from "node:fs/promises";
|
|
27438
27520
|
import path83 from "node:path";
|
|
27439
27521
|
var ACCEPTED_DIR = "tracker-settings";
|
|
27440
27522
|
var acceptedSettingsPath = (root, target2) => path83.join(machineStore(root).dir, ACCEPTED_DIR, `${target2}.json`);
|
|
27441
27523
|
var LOCK_STALE_MS = 5e3;
|
|
27442
27524
|
var BACKOFF_MS = [0, 5, 10, 20, 40, 80, 160, 320, 400];
|
|
27443
|
-
var
|
|
27525
|
+
var macParts2 = (root, target2, issues) => [
|
|
27444
27526
|
"tracker-settings",
|
|
27445
27527
|
machineId(root),
|
|
27446
27528
|
target2,
|
|
@@ -27448,14 +27530,14 @@ var macParts = (root, target2, issues) => [
|
|
|
27448
27530
|
];
|
|
27449
27531
|
function signed2(root, target2, issues, mac4) {
|
|
27450
27532
|
try {
|
|
27451
|
-
return machineSigned(
|
|
27533
|
+
return machineSigned(macParts2(root, target2, issues), mac4);
|
|
27452
27534
|
} catch {
|
|
27453
27535
|
return false;
|
|
27454
27536
|
}
|
|
27455
27537
|
}
|
|
27456
27538
|
var isEntry2 = (e) => !!e && typeof e === "object" && !Array.isArray(e);
|
|
27457
|
-
function readDoc(root,
|
|
27458
|
-
const raw = readJsonFile(
|
|
27539
|
+
function readDoc(root, file9, target2) {
|
|
27540
|
+
const raw = readJsonFile(file9);
|
|
27459
27541
|
if (raw?.v !== 1 || raw.target !== target2 || !raw.issues || typeof raw.issues !== "object") return {};
|
|
27460
27542
|
if (!signed2(root, target2, raw.issues, raw.mac)) return {};
|
|
27461
27543
|
return Object.fromEntries(Object.entries(raw.issues).filter(([, e]) => isEntry2(e)));
|
|
@@ -27474,8 +27556,8 @@ async function clearStale2(lock) {
|
|
|
27474
27556
|
);
|
|
27475
27557
|
if (moved) await rm(aside2, { force: true });
|
|
27476
27558
|
}
|
|
27477
|
-
async function withLock(
|
|
27478
|
-
const lock = `${
|
|
27559
|
+
async function withLock(file9, fn) {
|
|
27560
|
+
const lock = `${file9}.lock`;
|
|
27479
27561
|
for (const wait of BACKOFF_MS) {
|
|
27480
27562
|
if (wait) await sleep(wait);
|
|
27481
27563
|
if (await tryLock(lock)) {
|
|
@@ -27497,35 +27579,35 @@ function migrate(root, target2) {
|
|
|
27497
27579
|
if (legacy === target2 || !existsSync28(from) || existsSync28(to)) return;
|
|
27498
27580
|
const issues = readDoc(root, from, legacy);
|
|
27499
27581
|
try {
|
|
27500
|
-
const mac4 = machineSign(
|
|
27582
|
+
const mac4 = machineSign(macParts2(root, target2, issues));
|
|
27501
27583
|
writePrivateFile(to, `${JSON.stringify({ v: 1, target: target2, issues, mac: mac4 }, null, 2)}
|
|
27502
27584
|
`);
|
|
27503
|
-
|
|
27585
|
+
rmSync19(from, { force: true });
|
|
27504
27586
|
} catch {
|
|
27505
27587
|
}
|
|
27506
27588
|
}
|
|
27507
27589
|
function acceptedSettingsFile(root, target2) {
|
|
27508
27590
|
migrate(root, target2);
|
|
27509
|
-
const
|
|
27591
|
+
const file9 = acceptedSettingsPath(root, target2);
|
|
27510
27592
|
return {
|
|
27511
|
-
read: () => readDoc(root,
|
|
27593
|
+
read: () => readDoc(root, file9, target2),
|
|
27512
27594
|
async update(change3) {
|
|
27513
27595
|
try {
|
|
27514
|
-
|
|
27596
|
+
mkdirSync31(path83.dirname(file9), { recursive: true, mode: 448 });
|
|
27515
27597
|
} catch {
|
|
27516
27598
|
return false;
|
|
27517
27599
|
}
|
|
27518
|
-
const done2 = await withLock(
|
|
27519
|
-
const issues = readDoc(root,
|
|
27600
|
+
const done2 = await withLock(file9, () => {
|
|
27601
|
+
const issues = readDoc(root, file9, target2);
|
|
27520
27602
|
for (const [id, e] of Object.entries(change3(issues))) {
|
|
27521
27603
|
if (e) issues[id] = e;
|
|
27522
27604
|
else delete issues[id];
|
|
27523
27605
|
}
|
|
27524
|
-
const mac4 = machineSign(
|
|
27525
|
-
writePrivateFile(
|
|
27606
|
+
const mac4 = machineSign(macParts2(root, target2, issues));
|
|
27607
|
+
writePrivateFile(file9, `${JSON.stringify({ v: 1, target: target2, issues, mac: mac4 }, null, 2)}
|
|
27526
27608
|
`);
|
|
27527
27609
|
});
|
|
27528
|
-
if (!done2) console.warn(`teamtrail: ${path83.basename(
|
|
27610
|
+
if (!done2) console.warn(`teamtrail: ${path83.basename(file9)} is locked; settings not recorded this time`);
|
|
27529
27611
|
return done2;
|
|
27530
27612
|
}
|
|
27531
27613
|
};
|
|
@@ -28577,10 +28659,10 @@ async function nearest(i, names) {
|
|
|
28577
28659
|
}
|
|
28578
28660
|
return void 0;
|
|
28579
28661
|
}
|
|
28580
|
-
async function screenModule(i,
|
|
28581
|
-
if (await nearest(i, [
|
|
28662
|
+
async function screenModule(i, file9) {
|
|
28663
|
+
if (await nearest(i, [file9])) return [];
|
|
28582
28664
|
const where2 = i.cwd ? ` in \`${i.cwd}\` or above it` : "";
|
|
28583
|
-
return [{ severity: "wont-run", text: `No ${
|
|
28665
|
+
return [{ severity: "wont-run", text: `No ${file9}${where2}` }];
|
|
28584
28666
|
}
|
|
28585
28667
|
async function screenPytest(i) {
|
|
28586
28668
|
if (await nearest(i, PYTEST_FILES)) return [];
|
|
@@ -28596,15 +28678,15 @@ function scriptOf(args) {
|
|
|
28596
28678
|
}
|
|
28597
28679
|
return {};
|
|
28598
28680
|
}
|
|
28599
|
-
async function screenFile(i,
|
|
28600
|
-
const rel = repoPath2(i.cwd,
|
|
28681
|
+
async function screenFile(i, file9) {
|
|
28682
|
+
const rel = repoPath2(i.cwd, file9);
|
|
28601
28683
|
if (rel === void 0 || await i.files.kind(rel)) return [];
|
|
28602
28684
|
return [{ severity: "wont-run", text: `No \`${rel}\`` }];
|
|
28603
28685
|
}
|
|
28604
28686
|
async function screenInterpreter(i) {
|
|
28605
|
-
const { module, file:
|
|
28687
|
+
const { module, file: file9 } = scriptOf(i.args);
|
|
28606
28688
|
if (module === "pytest") return screenPytest(i);
|
|
28607
|
-
if (
|
|
28689
|
+
if (file9) return screenFile(i, file9);
|
|
28608
28690
|
return [];
|
|
28609
28691
|
}
|
|
28610
28692
|
var INTERPRETERS2 = /* @__PURE__ */ new Set(["node", "bash", "sh", "zsh", "python", "python3", "ruby", "tsx"]);
|
|
@@ -28998,19 +29080,19 @@ function ticketEvidence(root, mapId, ticketId) {
|
|
|
28998
29080
|
}
|
|
28999
29081
|
function readEvidenceLog(root, rel) {
|
|
29000
29082
|
if (!rel.endsWith(".log")) return void 0;
|
|
29001
|
-
let
|
|
29083
|
+
let file9;
|
|
29002
29084
|
let base2;
|
|
29003
29085
|
try {
|
|
29004
29086
|
base2 = realpathSync14(path86.join(root, EVIDENCE_DIR));
|
|
29005
|
-
|
|
29087
|
+
file9 = realpathSync14(path86.join(root, rel));
|
|
29006
29088
|
} catch {
|
|
29007
29089
|
return void 0;
|
|
29008
29090
|
}
|
|
29009
|
-
if (!
|
|
29010
|
-
const size3 = statSync9(
|
|
29091
|
+
if (!file9.startsWith(base2 + path86.sep)) return void 0;
|
|
29092
|
+
const size3 = statSync9(file9).size;
|
|
29011
29093
|
const len = Math.min(size3, LOG_VIEW_BYTES);
|
|
29012
29094
|
const buf = Buffer.alloc(len);
|
|
29013
|
-
const fd = openSync3(
|
|
29095
|
+
const fd = openSync3(file9, "r");
|
|
29014
29096
|
try {
|
|
29015
29097
|
readSync(fd, buf, 0, len, size3 - len);
|
|
29016
29098
|
} finally {
|
|
@@ -29023,17 +29105,17 @@ function readEvidenceLog(root, rel) {
|
|
|
29023
29105
|
import path88 from "node:path";
|
|
29024
29106
|
|
|
29025
29107
|
// ../core/src/verification/writeApprovedConfig.ts
|
|
29026
|
-
import { lstatSync as lstatSync6, renameSync as renameSync10, writeFileSync as
|
|
29108
|
+
import { lstatSync as lstatSync6, renameSync as renameSync10, writeFileSync as writeFileSync22 } from "node:fs";
|
|
29027
29109
|
import path87 from "node:path";
|
|
29028
29110
|
function writeApprovedConfig(o) {
|
|
29029
29111
|
const { errors } = parseVerificationConfig(o.text);
|
|
29030
29112
|
if (errors.length) throw new OperationError(`${VERIFICATION_FILE} would be invalid: ${errors.join("; ")}`);
|
|
29031
|
-
const
|
|
29032
|
-
if (lstatSync6(
|
|
29113
|
+
const file9 = path87.join(o.root, VERIFICATION_FILE);
|
|
29114
|
+
if (lstatSync6(file9, { throwIfNoEntry: false })?.isSymbolicLink())
|
|
29033
29115
|
throw new OperationError(`${VERIFICATION_FILE} is a link; replace it by hand`);
|
|
29034
|
-
const tmp = `${
|
|
29035
|
-
|
|
29036
|
-
renameSync10(tmp,
|
|
29116
|
+
const tmp = `${file9}.${process.pid}.tmp`;
|
|
29117
|
+
writeFileSync22(tmp, o.text, { flag: "wx" });
|
|
29118
|
+
renameSync10(tmp, file9);
|
|
29037
29119
|
const approval = approveChecksHere(o.root, o.by, o.text);
|
|
29038
29120
|
journalFile(o.root).append({
|
|
29039
29121
|
v: 1,
|
|
@@ -29076,8 +29158,8 @@ function setChecks(o) {
|
|
|
29076
29158
|
if (o.base !== now2.hash) throw new StaleChecks(`${VERIFICATION_FILE} changed since you opened it; look again`);
|
|
29077
29159
|
const problem = problemOf(o.checks, o.acknowledged === true);
|
|
29078
29160
|
if (problem) throw new OperationError(problem);
|
|
29079
|
-
const
|
|
29080
|
-
const raw = readRawConfig(
|
|
29161
|
+
const file9 = path88.join(o.root, VERIFICATION_FILE);
|
|
29162
|
+
const raw = readRawConfig(file9, { v: 1, default: "checks" });
|
|
29081
29163
|
const kept = raw.checks ?? {};
|
|
29082
29164
|
const checks = Object.fromEntries(o.checks.map((c) => [c.name, { ...kept[c.name] ?? {}, run: c.run }]));
|
|
29083
29165
|
const text11 = `${JSON.stringify({ ...raw, v: 1, checks, run: o.checks.map((c) => c.name) }, null, 2)}
|
|
@@ -29153,11 +29235,11 @@ function setGateMode(o) {
|
|
|
29153
29235
|
const mode = o.mode;
|
|
29154
29236
|
const now2 = checksApproval(o.root);
|
|
29155
29237
|
if (o.base !== now2.hash) throw new StaleChecks(`${VERIFICATION_FILE} changed since you opened it; look again`);
|
|
29156
|
-
const
|
|
29157
|
-
if (!existsSync29(
|
|
29238
|
+
const file9 = path89.join(o.root, VERIFICATION_FILE);
|
|
29239
|
+
if (!existsSync29(file9)) throw new OperationError("Set the checks first: without them nothing is verified");
|
|
29158
29240
|
if (now2.waiting)
|
|
29159
29241
|
throw new OperationError(`Approve ${VERIFICATION_FILE} first: it changed since it was approved here`);
|
|
29160
|
-
const raw = readRawConfig(
|
|
29242
|
+
const raw = readRawConfig(file9, { v: 1 });
|
|
29161
29243
|
const gates = { ...isObject3(raw.gates) ? raw.gates : {}, [gate]: mode };
|
|
29162
29244
|
const text11 = `${JSON.stringify({ ...raw, gates }, null, 2)}
|
|
29163
29245
|
`;
|
|
@@ -29201,11 +29283,11 @@ function setScope(o) {
|
|
|
29201
29283
|
const scope = o.scope;
|
|
29202
29284
|
const now2 = checksApproval(o.root);
|
|
29203
29285
|
if (o.base !== now2.hash) throw new StaleChecks(`${VERIFICATION_FILE} changed since you opened it; look again`);
|
|
29204
|
-
const
|
|
29205
|
-
if (!existsSync30(
|
|
29286
|
+
const file9 = path90.join(o.root, VERIFICATION_FILE);
|
|
29287
|
+
if (!existsSync30(file9)) throw new OperationError("Set the checks first: without them nothing is verified");
|
|
29206
29288
|
if (now2.waiting)
|
|
29207
29289
|
throw new OperationError(`Approve ${VERIFICATION_FILE} first: it changed since it was approved here`);
|
|
29208
|
-
const raw = readRawConfig(
|
|
29290
|
+
const raw = readRawConfig(file9, { v: 1 });
|
|
29209
29291
|
const text11 = `${JSON.stringify({ ...raw, scope }, null, 2)}
|
|
29210
29292
|
`;
|
|
29211
29293
|
return writeApprovedConfig({
|
|
@@ -29301,20 +29383,20 @@ async function handleVerification({ root, active, local, repoFiles }, req, res,
|
|
|
29301
29383
|
}
|
|
29302
29384
|
|
|
29303
29385
|
// ../core/src/verification/heldRulesStore.ts
|
|
29304
|
-
import { rmSync as
|
|
29386
|
+
import { rmSync as rmSync20 } from "node:fs";
|
|
29305
29387
|
import path91 from "node:path";
|
|
29306
|
-
var
|
|
29388
|
+
var file6 = (root, mapId, ticketId) => path91.join(root, evidencePaths.ticket(mapId, ticketId), "rules-held.json");
|
|
29307
29389
|
var heldRulesStore = {
|
|
29308
29390
|
read(root, mapId, ticketId) {
|
|
29309
|
-
const r = readJsonFile(
|
|
29391
|
+
const r = readJsonFile(file6(root, mapId, ticketId));
|
|
29310
29392
|
return r?.v === 1 && Array.isArray(r.rules) ? r : void 0;
|
|
29311
29393
|
},
|
|
29312
29394
|
write(root, mapId, ticketId, held) {
|
|
29313
29395
|
ensureLocalDir(path91.join(root, EVIDENCE_DIR));
|
|
29314
|
-
writeJsonAtomic(
|
|
29396
|
+
writeJsonAtomic(file6(root, mapId, ticketId), held);
|
|
29315
29397
|
},
|
|
29316
29398
|
clear(root, mapId, ticketId) {
|
|
29317
|
-
|
|
29399
|
+
rmSync20(file6(root, mapId, ticketId), { force: true });
|
|
29318
29400
|
}
|
|
29319
29401
|
};
|
|
29320
29402
|
|
|
@@ -29366,11 +29448,11 @@ function setRules(o) {
|
|
|
29366
29448
|
const rules2 = shapeRules(o.rules);
|
|
29367
29449
|
const now2 = checksApproval(o.root);
|
|
29368
29450
|
if (o.base !== now2.hash) throw new StaleChecks(`${VERIFICATION_FILE} changed since you opened it; look again`);
|
|
29369
|
-
const
|
|
29370
|
-
if (!existsSync31(
|
|
29451
|
+
const file9 = path93.join(o.root, VERIFICATION_FILE);
|
|
29452
|
+
if (!existsSync31(file9)) throw new OperationError("Set the checks first: without them nothing is verified");
|
|
29371
29453
|
if (now2.waiting)
|
|
29372
29454
|
throw new OperationError(`Approve ${VERIFICATION_FILE} first: it changed since it was approved here`);
|
|
29373
|
-
const { rules: _old, ...raw } = readRawConfig(
|
|
29455
|
+
const { rules: _old, ...raw } = readRawConfig(file9, { v: 1 });
|
|
29374
29456
|
const written = `${JSON.stringify(rules2.length ? { ...raw, rules: rules2 } : raw, null, 2)}
|
|
29375
29457
|
`;
|
|
29376
29458
|
return writeApprovedConfig({
|
|
@@ -29381,15 +29463,46 @@ function setRules(o) {
|
|
|
29381
29463
|
});
|
|
29382
29464
|
}
|
|
29383
29465
|
|
|
29384
|
-
// ../core/src/verification/
|
|
29385
|
-
|
|
29386
|
-
|
|
29387
|
-
async function assertMay(root, r, key) {
|
|
29388
|
-
if (r.via === "slack" || r.via === "chat") throw new OperationError(`Waiving a rule for ${key} is for the Lookout.`);
|
|
29466
|
+
// ../core/src/verification/assertMayWaiveRule.ts
|
|
29467
|
+
async function assertMayWaiveRule(root, r) {
|
|
29468
|
+
if (r.via === "slack" || r.via === "chat") throw new OperationError(`${r.doing} for ${r.key} is for the Lookout.`);
|
|
29389
29469
|
if (!await ticketNeedsLookout(root, r.mapId, r.ticketId)) return;
|
|
29390
|
-
if (r.via !== "lookout") throw new OperationError(highRiskRefusal(key, r.via));
|
|
29391
|
-
if (!r.local) throw new OperationError(`${key} is high risk:
|
|
29470
|
+
if (r.via !== "lookout") throw new OperationError(highRiskRefusal(r.key, r.via));
|
|
29471
|
+
if (!r.local) throw new OperationError(`${r.key} is high risk: change its rules in the Lookout on its machine.`);
|
|
29472
|
+
}
|
|
29473
|
+
|
|
29474
|
+
// ../core/src/verification/undoRuleWaiver.ts
|
|
29475
|
+
var TRAIL_LEAD4 = "trail lead";
|
|
29476
|
+
async function undoRuleWaiver(env, r) {
|
|
29477
|
+
const snap = await env.adapter.loadMap(r.mapId);
|
|
29478
|
+
const t = snap.tickets.find((x) => x.id === r.ticketId);
|
|
29479
|
+
if (!t) throw new OperationError(`ticket ${r.ticketId} not found`);
|
|
29480
|
+
await assertMayWaiveRule(env.root, { ...r, key: t.key, doing: `Undoing Go without ${r.rule}` });
|
|
29481
|
+
const gone = ruleWaivers.remove(env.root, { mapId: r.mapId, ticketId: t.id, rule: r.rule });
|
|
29482
|
+
if (!gone) throw new OperationError(`${t.key} isn't going without ${r.rule}.`);
|
|
29483
|
+
const by = r.person ?? TRAIL_LEAD4;
|
|
29484
|
+
journalFile(env.root).append({
|
|
29485
|
+
v: 1,
|
|
29486
|
+
kind: "rule-waiver",
|
|
29487
|
+
at: Date.now(),
|
|
29488
|
+
mapId: r.mapId,
|
|
29489
|
+
ticketId: t.id,
|
|
29490
|
+
ticketKey: t.key,
|
|
29491
|
+
rule: gone.rule,
|
|
29492
|
+
action: "undone",
|
|
29493
|
+
reason: gone.reason,
|
|
29494
|
+
actor: by,
|
|
29495
|
+
actorKind: "trail lead"
|
|
29496
|
+
});
|
|
29497
|
+
await env.adapter.comment(r.mapId, t.id, TRAIL_LEAD4, `**${gone.rule} asks again**
|
|
29498
|
+
|
|
29499
|
+
${by} undid going without it.`);
|
|
29500
|
+
return { rule: gone.rule, waived: false };
|
|
29392
29501
|
}
|
|
29502
|
+
|
|
29503
|
+
// ../core/src/verification/waiveRule.ts
|
|
29504
|
+
var TRAIL_LEAD5 = "trail lead";
|
|
29505
|
+
var MAX_REASON2 = 500;
|
|
29393
29506
|
async function waiveRule(env, r) {
|
|
29394
29507
|
const reason = oneLine(r.reason).slice(0, MAX_REASON2);
|
|
29395
29508
|
if (!reason) throw new OperationError("Say why it can go without the answer.");
|
|
@@ -29398,7 +29511,7 @@ async function waiveRule(env, r) {
|
|
|
29398
29511
|
if (!t) throw new OperationError(`ticket ${r.ticketId} not found`);
|
|
29399
29512
|
const rule = trustedChecks(env.root).config.config?.rules.find((x) => x.id === r.rule);
|
|
29400
29513
|
if (!rule?.ask) throw new OperationError(`${r.rule} is not an approved rule that asks a question.`);
|
|
29401
|
-
await
|
|
29514
|
+
await assertMayWaiveRule(env.root, { ...r, key: t.key, doing: "Waiving a rule" });
|
|
29402
29515
|
const w = {
|
|
29403
29516
|
v: 1,
|
|
29404
29517
|
mapId: r.mapId,
|
|
@@ -29406,7 +29519,7 @@ async function waiveRule(env, r) {
|
|
|
29406
29519
|
ticketKey: t.key,
|
|
29407
29520
|
rule: rule.id,
|
|
29408
29521
|
reason,
|
|
29409
|
-
by: r.person ??
|
|
29522
|
+
by: r.person ?? TRAIL_LEAD5,
|
|
29410
29523
|
via: r.via,
|
|
29411
29524
|
at: Date.now()
|
|
29412
29525
|
};
|
|
@@ -29419,6 +29532,7 @@ async function waiveRule(env, r) {
|
|
|
29419
29532
|
ticketId: w.ticketId,
|
|
29420
29533
|
ticketKey: w.ticketKey,
|
|
29421
29534
|
rule: w.rule,
|
|
29535
|
+
action: "waived",
|
|
29422
29536
|
reason,
|
|
29423
29537
|
actor: w.by,
|
|
29424
29538
|
actorKind: "trail lead"
|
|
@@ -29427,7 +29541,7 @@ async function waiveRule(env, r) {
|
|
|
29427
29541
|
const left = held?.rules.filter((x) => x.id !== rule.id) ?? [];
|
|
29428
29542
|
if (held && left.length) heldRulesStore.write(env.root, r.mapId, t.id, { ...held, rules: left });
|
|
29429
29543
|
else heldRulesStore.clear(env.root, r.mapId, t.id);
|
|
29430
|
-
await env.adapter.comment(r.mapId, t.id,
|
|
29544
|
+
await env.adapter.comment(r.mapId, t.id, TRAIL_LEAD5, `**Went without ${rule.id}**
|
|
29431
29545
|
|
|
29432
29546
|
${reason}
|
|
29433
29547
|
|
|
@@ -29450,7 +29564,7 @@ async function putRules(o, req, res) {
|
|
|
29450
29564
|
sendJson(res, e instanceof StaleChecks ? 409 : 400, { error: e.message });
|
|
29451
29565
|
}
|
|
29452
29566
|
}
|
|
29453
|
-
async function waive(o, req, res) {
|
|
29567
|
+
async function waive(o, req, res, undo) {
|
|
29454
29568
|
const b = await readJson2(req, "{}");
|
|
29455
29569
|
const [mapId, ticketId, rule] = [str12(b.mapId), str12(b.ticketId), str12(b.rule, 20)];
|
|
29456
29570
|
const reason = typeof b.reason === "string" ? b.reason : "";
|
|
@@ -29458,7 +29572,8 @@ async function waive(o, req, res) {
|
|
|
29458
29572
|
const who = { person: personOfRequest(req)?.name, via: lookoutVia(req), local: o.local !== false };
|
|
29459
29573
|
try {
|
|
29460
29574
|
const env = { adapter: await o.active(), root: o.root };
|
|
29461
|
-
|
|
29575
|
+
const ids2 = { mapId, ticketId, rule, ...who };
|
|
29576
|
+
sendJson(res, 200, undo ? await undoRuleWaiver(env, ids2) : await waiveRule(env, { ...ids2, reason }));
|
|
29462
29577
|
} catch (e) {
|
|
29463
29578
|
if (!(e instanceof OperationError)) throw e;
|
|
29464
29579
|
sendJson(res, 409, { error: e.message });
|
|
@@ -29472,13 +29587,14 @@ async function handleRules(o, req, res, url2) {
|
|
|
29472
29587
|
if (p === "/verification/rules/held" && req.method === "GET") {
|
|
29473
29588
|
if (!q("mapId") || !q("ticketId")) throw new BadRequest('"mapId" and "ticketId" are required');
|
|
29474
29589
|
const held = heldRulesStore.read(o.root, q("mapId"), q("ticketId"));
|
|
29475
|
-
const waived = ruleWaivers.list(o.root, q("mapId"), q("ticketId")).map((w) => ({ rule: w.rule, by: w.by, at: w.at }));
|
|
29590
|
+
const waived = ruleWaivers.list(o.root, q("mapId"), q("ticketId")).map((w) => ({ rule: w.rule, by: w.by, at: w.at, reason: w.reason }));
|
|
29476
29591
|
return sendJson(res, 200, { ...held ? { held } : {}, waived }), true;
|
|
29477
29592
|
}
|
|
29478
|
-
const
|
|
29593
|
+
const waiving = req.method === "POST" && (p === "/verification/rules/waive" || p === "/verification/rules/waive/undo");
|
|
29594
|
+
const write2 = p === "/verification/rules" && req.method === "PUT" || waiving;
|
|
29479
29595
|
if (!write2) return false;
|
|
29480
29596
|
if (crossSite(req)) return sendJson(res, 403, { error: "cross-site request refused" }), true;
|
|
29481
|
-
await (
|
|
29597
|
+
await (waiving ? waive(o, req, res, p.endsWith("/undo")) : putRules(o, req, res));
|
|
29482
29598
|
return true;
|
|
29483
29599
|
}
|
|
29484
29600
|
|
|
@@ -29709,7 +29825,7 @@ function linked(i) {
|
|
|
29709
29825
|
}
|
|
29710
29826
|
|
|
29711
29827
|
// ../core/src/verification/undoWaiver.ts
|
|
29712
|
-
var
|
|
29828
|
+
var TRAIL_LEAD6 = "trail lead";
|
|
29713
29829
|
async function undoWaiver(env, r) {
|
|
29714
29830
|
if (r.via === "slack" || r.via === "chat") throw new OperationError("Undo it in the Lookout.");
|
|
29715
29831
|
const snap = await env.adapter.loadMap(r.mapId);
|
|
@@ -29718,14 +29834,14 @@ async function undoWaiver(env, r) {
|
|
|
29718
29834
|
if (!activeWaivers(env.root, r.mapId, t.id).length) throw new OperationError(`${t.key} has no waived check to undo.`);
|
|
29719
29835
|
if (r.via !== "lookout" && await ticketNeedsLookout(env.root, r.mapId, t.id))
|
|
29720
29836
|
throw new OperationError(highRiskRefusal(t.key, r.via));
|
|
29721
|
-
const by = r.person ??
|
|
29837
|
+
const by = r.person ?? TRAIL_LEAD6;
|
|
29722
29838
|
const undone = checkWaivers.undo(env.root, { mapId: r.mapId, ticketId: t.id, by });
|
|
29723
29839
|
const names = [...new Set(undone.flatMap((w) => w.checks.map((c) => c.name)))].join(", ");
|
|
29724
29840
|
for (const w of undone) {
|
|
29725
29841
|
journal5(env.root, { w, t, by });
|
|
29726
29842
|
await supersede2(env, { w, t, r, names });
|
|
29727
29843
|
}
|
|
29728
|
-
await env.adapter.comment(r.mapId, t.id,
|
|
29844
|
+
await env.adapter.comment(r.mapId, t.id, TRAIL_LEAD6, `**${names} runs again**
|
|
29729
29845
|
|
|
29730
29846
|
${by} undid accepting it without.`);
|
|
29731
29847
|
if (t.state === "closed" && t.closeReason === "completed")
|
|
@@ -29763,7 +29879,7 @@ async function supersede2(env, o) {
|
|
|
29763
29879
|
ticketKey: t.key,
|
|
29764
29880
|
answer: `Run ${o.names} again.`,
|
|
29765
29881
|
summary: `${t.key} runs ${o.names} again`,
|
|
29766
|
-
decidedBy:
|
|
29882
|
+
decidedBy: TRAIL_LEAD6,
|
|
29767
29883
|
...r.person ? { decidedByName: r.person } : {},
|
|
29768
29884
|
source: { kind: "lookout", label: "Undid accepting without a check" },
|
|
29769
29885
|
transcript: [],
|
|
@@ -29787,7 +29903,7 @@ async function assertMayWaive(root, o) {
|
|
|
29787
29903
|
|
|
29788
29904
|
// ../core/src/verification/waiveChecks.ts
|
|
29789
29905
|
var HELD = ["rework", "blocked", "working"];
|
|
29790
|
-
var
|
|
29906
|
+
var TRAIL_LEAD7 = "trail lead";
|
|
29791
29907
|
async function waiveChecks(env, r) {
|
|
29792
29908
|
const reason = r.reason.trim();
|
|
29793
29909
|
if (!reason) throw new OperationError("Say why it can go without them.");
|
|
@@ -29828,7 +29944,7 @@ async function keep2(env, o) {
|
|
|
29828
29944
|
attemptId: r.attemptId,
|
|
29829
29945
|
checks,
|
|
29830
29946
|
reason: r.reason,
|
|
29831
|
-
by: r.person ??
|
|
29947
|
+
by: r.person ?? TRAIL_LEAD7,
|
|
29832
29948
|
via: r.via,
|
|
29833
29949
|
at: Date.now()
|
|
29834
29950
|
};
|
|
@@ -29844,7 +29960,7 @@ async function keep2(env, o) {
|
|
|
29844
29960
|
answer: r.reason,
|
|
29845
29961
|
summary: `Accepted ${t.key} without ${list8}: ${firstSentence(r.reason)}`,
|
|
29846
29962
|
rationale: r.reason,
|
|
29847
|
-
decidedBy:
|
|
29963
|
+
decidedBy: TRAIL_LEAD7,
|
|
29848
29964
|
...r.person ? { decidedByName: r.person } : {},
|
|
29849
29965
|
source: { kind: "lookout", ref: `waiver:${w.id}`, label: "Accepted without a check" },
|
|
29850
29966
|
transcript: []
|
|
@@ -29866,7 +29982,7 @@ async function keep2(env, o) {
|
|
|
29866
29982
|
actorKind: "trail lead",
|
|
29867
29983
|
reason: r.reason
|
|
29868
29984
|
});
|
|
29869
|
-
await env.adapter.comment(r.mapId, t.id,
|
|
29985
|
+
await env.adapter.comment(r.mapId, t.id, TRAIL_LEAD7, `**Accepted without ${list8}**
|
|
29870
29986
|
|
|
29871
29987
|
${r.reason}
|
|
29872
29988
|
|
|
@@ -30380,13 +30496,13 @@ var real5 = (p) => {
|
|
|
30380
30496
|
}
|
|
30381
30497
|
};
|
|
30382
30498
|
var inside3 = (dir4, p) => p.startsWith(dir4 + path97.sep);
|
|
30383
|
-
async function ownWorktree2(root,
|
|
30499
|
+
async function ownWorktree2(root, folder2) {
|
|
30384
30500
|
const top = await gitText(path97.dirname(root), ["rev-parse", "--show-toplevel"]);
|
|
30385
30501
|
if (!top) return void 0;
|
|
30386
30502
|
const listed3 = await git(top, ["worktree", "list", "--porcelain", "-z"]);
|
|
30387
30503
|
if (listed3.code !== 0) return void 0;
|
|
30388
30504
|
const linked2 = listed3.stdout.toString("utf8").split("\0").filter((l) => l.startsWith("worktree ")).map((l) => real5(l.slice("worktree ".length))).filter((p) => p !== real5(top));
|
|
30389
|
-
const target2 = real5(
|
|
30505
|
+
const target2 = real5(folder2);
|
|
30390
30506
|
if (!linked2.includes(target2)) return void 0;
|
|
30391
30507
|
const dirs2 = [worktreeDir(top, readWorkspaceSettings(root).settings.dir), worktreeDir(top)];
|
|
30392
30508
|
const allowed2 = dirs2.flatMap((d) => "dir" in d ? [real5(d.dir)] : []);
|
|
@@ -30681,7 +30797,7 @@ function activeTracker(o) {
|
|
|
30681
30797
|
}
|
|
30682
30798
|
|
|
30683
30799
|
// ../core/src/agents/lookoutLock.ts
|
|
30684
|
-
import { rmSync as
|
|
30800
|
+
import { rmSync as rmSync21 } from "node:fs";
|
|
30685
30801
|
import path100 from "node:path";
|
|
30686
30802
|
var LOCK_SIG = "lookout-lock";
|
|
30687
30803
|
function writeLookoutLock(root, url2) {
|
|
@@ -30698,7 +30814,7 @@ function writeLookoutLock(root, url2) {
|
|
|
30698
30814
|
writeLocalJson(root, agentPaths.lock, lock);
|
|
30699
30815
|
return () => {
|
|
30700
30816
|
const cur = readJsonFile(path100.join(root, agentPaths.lock));
|
|
30701
|
-
if (cur?.pid === process.pid)
|
|
30817
|
+
if (cur?.pid === process.pid) rmSync21(path100.join(root, agentPaths.lock), { force: true });
|
|
30702
30818
|
};
|
|
30703
30819
|
}
|
|
30704
30820
|
function readLookoutLock(root) {
|
|
@@ -30874,8 +30990,8 @@ function readProjects(configDir2) {
|
|
|
30874
30990
|
const projects = list8.filter((p) => !seen2.has(p.id) && seen2.add(p.id));
|
|
30875
30991
|
return { v: 1, projects, autoRegister: raw.autoRegister !== false };
|
|
30876
30992
|
}
|
|
30877
|
-
function writeProjects(configDir2,
|
|
30878
|
-
writeJsonAtomic(projectsPath(configDir2),
|
|
30993
|
+
function writeProjects(configDir2, file9) {
|
|
30994
|
+
writeJsonAtomic(projectsPath(configDir2), file9, { private: true });
|
|
30879
30995
|
}
|
|
30880
30996
|
function updateProjects(configDir2, change3) {
|
|
30881
30997
|
const next = change3(readProjects(configDir2));
|
|
@@ -30889,11 +31005,11 @@ function homeEntry(root) {
|
|
|
30889
31005
|
return { id: projectId(root), name: projectName(real7), path: repoOfRoot(real7), root: real7, addedAt: 0 };
|
|
30890
31006
|
}
|
|
30891
31007
|
function projectEntries(configDir2, homeRoot) {
|
|
30892
|
-
const
|
|
31008
|
+
const file9 = readProjects(configDir2);
|
|
30893
31009
|
const home = homeEntry(homeRoot);
|
|
30894
|
-
const registeredHome =
|
|
30895
|
-
const others =
|
|
30896
|
-
return { entries: [registeredHome ?? home, ...others], autoRegister:
|
|
31010
|
+
const registeredHome = file9.projects.find((p) => p.id === home.id);
|
|
31011
|
+
const others = file9.projects.filter((p) => p.id !== home.id);
|
|
31012
|
+
return { entries: [registeredHome ?? home, ...others], autoRegister: file9.autoRegister };
|
|
30897
31013
|
}
|
|
30898
31014
|
|
|
30899
31015
|
// ../core/src/projects/projectState.ts
|
|
@@ -31054,7 +31170,7 @@ async function projectBriefing(input2) {
|
|
|
31054
31170
|
}
|
|
31055
31171
|
|
|
31056
31172
|
// ../core/src/projects/registerProject.ts
|
|
31057
|
-
import { existsSync as existsSync36, mkdirSync as
|
|
31173
|
+
import { existsSync as existsSync36, mkdirSync as mkdirSync32, statSync as statSync13 } from "node:fs";
|
|
31058
31174
|
import path105 from "node:path";
|
|
31059
31175
|
var ProjectPathError = class extends Error {
|
|
31060
31176
|
};
|
|
@@ -31063,7 +31179,7 @@ function trackerRootFor(input2, opts = {}) {
|
|
|
31063
31179
|
if (!existsSync36(abs) || !statSync13(abs).isDirectory()) throw new ProjectPathError(`no folder at ${abs}`);
|
|
31064
31180
|
if (path105.basename(abs) === BRAND.dataDir || existsSync36(path105.join(abs, "trackers.json"))) return realRoot(abs);
|
|
31065
31181
|
const root = path105.join(abs, BRAND.dataDir);
|
|
31066
|
-
if (!existsSync36(root) && opts.create)
|
|
31182
|
+
if (!existsSync36(root) && opts.create) mkdirSync32(root, { recursive: true });
|
|
31067
31183
|
return realRoot(root);
|
|
31068
31184
|
}
|
|
31069
31185
|
function registerProject(input2) {
|
|
@@ -31226,7 +31342,7 @@ function findByHash(entries2, secret) {
|
|
|
31226
31342
|
}
|
|
31227
31343
|
|
|
31228
31344
|
// ../core/src/signIn/signInStore.ts
|
|
31229
|
-
import { mkdirSync as
|
|
31345
|
+
import { mkdirSync as mkdirSync33, statSync as statSync14 } from "node:fs";
|
|
31230
31346
|
var SIGN_IN_FILE = "sign-in.json";
|
|
31231
31347
|
var EMPTY3 = { v: 1, sessions: [], codes: [] };
|
|
31232
31348
|
var isSession = (s) => {
|
|
@@ -31248,10 +31364,10 @@ function readSignIns(at2) {
|
|
|
31248
31364
|
}
|
|
31249
31365
|
function updateSignIns(at2, change3) {
|
|
31250
31366
|
const store = machineStore(at2.root, at2.configDir);
|
|
31251
|
-
|
|
31367
|
+
mkdirSync33(store.dir, { recursive: true, mode: 448 });
|
|
31252
31368
|
return withFileLock2(store.file(`${SIGN_IN_FILE}.lock`), () => {
|
|
31253
|
-
const { file:
|
|
31254
|
-
store.write(SIGN_IN_FILE,
|
|
31369
|
+
const { file: file9, result: result2 } = change3(readSignIns(at2));
|
|
31370
|
+
store.write(SIGN_IN_FILE, file9);
|
|
31255
31371
|
return result2;
|
|
31256
31372
|
});
|
|
31257
31373
|
}
|
|
@@ -31301,9 +31417,9 @@ function mintPairCode(at2) {
|
|
|
31301
31417
|
expiresAt,
|
|
31302
31418
|
...at2.via ? { via: at2.via } : {}
|
|
31303
31419
|
};
|
|
31304
|
-
updateSignIns(at2, (
|
|
31305
|
-
const live2 =
|
|
31306
|
-
return { file: { ...
|
|
31420
|
+
updateSignIns(at2, (file9) => {
|
|
31421
|
+
const live2 = file9.codes.filter((c) => c.expiresAt > now2);
|
|
31422
|
+
return { file: { ...file9, codes: [...live2, entry].slice(-MAX_CODES) }, result: void 0 };
|
|
31307
31423
|
});
|
|
31308
31424
|
return { code: at2.kind === "machine" ? code2 : showTypedCode(code2), expiresAt };
|
|
31309
31425
|
}
|
|
@@ -31706,12 +31822,12 @@ var MAX_SESSIONS = 50;
|
|
|
31706
31822
|
function pairWithCode(at2) {
|
|
31707
31823
|
const now2 = at2.now ?? Date.now();
|
|
31708
31824
|
const code2 = normalizePairCode(at2.code)?.code;
|
|
31709
|
-
return updateSignIns(at2, (
|
|
31710
|
-
const codes =
|
|
31825
|
+
return updateSignIns(at2, (file9) => {
|
|
31826
|
+
const codes = file9.codes.filter((c) => c.expiresAt > now2);
|
|
31711
31827
|
const mine2 = codes.filter((c) => c.instance === at2.instance);
|
|
31712
31828
|
const used = code2 ? findByHash(mine2, code2) : void 0;
|
|
31713
31829
|
const rest = codes.filter((c) => c !== used);
|
|
31714
|
-
if (!used) return { file: { ...
|
|
31830
|
+
if (!used) return { file: { ...file9, codes: rest }, result: { kind: "refused" } };
|
|
31715
31831
|
const kind2 = used.kind === "machine" && at2.local ? "machine" : "device";
|
|
31716
31832
|
const secret = newSessionSecret();
|
|
31717
31833
|
const session2 = {
|
|
@@ -31726,7 +31842,7 @@ function pairWithCode(at2) {
|
|
|
31726
31842
|
expiresAt: now2 + SESSION_MS,
|
|
31727
31843
|
...used.via ? { via: used.via } : {}
|
|
31728
31844
|
};
|
|
31729
|
-
const live2 =
|
|
31845
|
+
const live2 = file9.sessions.filter((s) => s.expiresAt > now2 && (s.start === at2.start || processAlive(s.instance))).sort((a, b) => a.lastUsedAt - b.lastUsedAt);
|
|
31730
31846
|
const sessions = [...live2, session2].slice(-MAX_SESSIONS);
|
|
31731
31847
|
return { file: { v: 1, sessions, codes: rest }, result: { kind: "paired", secret, session: session2 } };
|
|
31732
31848
|
});
|
|
@@ -31734,25 +31850,25 @@ function pairWithCode(at2) {
|
|
|
31734
31850
|
function burnPairCode(at2) {
|
|
31735
31851
|
const code2 = normalizePairCode(at2.code)?.code;
|
|
31736
31852
|
if (!code2) return;
|
|
31737
|
-
updateSignIns(at2, (
|
|
31738
|
-
const used = findByHash(
|
|
31739
|
-
return { file: { ...
|
|
31853
|
+
updateSignIns(at2, (file9) => {
|
|
31854
|
+
const used = findByHash(file9.codes, code2);
|
|
31855
|
+
return { file: { ...file9, codes: file9.codes.filter((c) => c !== used) }, result: void 0 };
|
|
31740
31856
|
});
|
|
31741
31857
|
}
|
|
31742
31858
|
function removeSession(at2) {
|
|
31743
|
-
return updateSignIns(at2, (
|
|
31744
|
-
const gone =
|
|
31745
|
-
return { file: { ...
|
|
31859
|
+
return updateSignIns(at2, (file9) => {
|
|
31860
|
+
const gone = file9.sessions.find((s) => s.id === at2.id);
|
|
31861
|
+
return { file: { ...file9, sessions: file9.sessions.filter((s) => s !== gone) }, result: gone };
|
|
31746
31862
|
});
|
|
31747
31863
|
}
|
|
31748
31864
|
function touchSessions(at2) {
|
|
31749
31865
|
if (!at2.used.size) return;
|
|
31750
|
-
updateSignIns(at2, (
|
|
31751
|
-
const sessions =
|
|
31866
|
+
updateSignIns(at2, (file9) => {
|
|
31867
|
+
const sessions = file9.sessions.map((s) => {
|
|
31752
31868
|
const when = at2.used.get(s.id);
|
|
31753
31869
|
return when && when > s.lastUsedAt ? { ...s, lastUsedAt: when, expiresAt: when + SESSION_MS } : s;
|
|
31754
31870
|
});
|
|
31755
|
-
return { file: { ...
|
|
31871
|
+
return { file: { ...file9, sessions }, result: void 0 };
|
|
31756
31872
|
});
|
|
31757
31873
|
}
|
|
31758
31874
|
|
|
@@ -31780,7 +31896,7 @@ function streamTickets(now2) {
|
|
|
31780
31896
|
}
|
|
31781
31897
|
|
|
31782
31898
|
// ../core/src/signIn/sweepSignInRedirects.ts
|
|
31783
|
-
import { readdirSync as readdirSync25, readFileSync as readFileSync33, rmSync as
|
|
31899
|
+
import { readdirSync as readdirSync25, readFileSync as readFileSync33, rmSync as rmSync22, statSync as statSync15 } from "node:fs";
|
|
31784
31900
|
|
|
31785
31901
|
// ../core/src/signIn/signInRedirectFile.ts
|
|
31786
31902
|
import { randomBytes as randomBytes12 } from "node:crypto";
|
|
@@ -31809,10 +31925,10 @@ function sweepSignInRedirects(at2) {
|
|
|
31809
31925
|
const now2 = at2.now ?? Date.now();
|
|
31810
31926
|
const pending = at2.keep === "pending" ? readSignIns(at2).codes.filter((c) => c.expiresAt > now2) : void 0;
|
|
31811
31927
|
for (const name2 of names) {
|
|
31812
|
-
const
|
|
31928
|
+
const file9 = store.file(name2);
|
|
31813
31929
|
try {
|
|
31814
|
-
const keep3 = pending ? stillPending({ file:
|
|
31815
|
-
if (!keep3)
|
|
31930
|
+
const keep3 = pending ? stillPending({ file: file9, name: name2, pending }) : false;
|
|
31931
|
+
if (!keep3) rmSync22(file9, { force: true });
|
|
31816
31932
|
} catch {
|
|
31817
31933
|
}
|
|
31818
31934
|
}
|
|
@@ -31950,7 +32066,7 @@ async function runningLookout(root, fetcher = fetch) {
|
|
|
31950
32066
|
}
|
|
31951
32067
|
|
|
31952
32068
|
// ../core/src/signIn/writeSignInRedirect.ts
|
|
31953
|
-
import { chmodSync as chmodSync4, linkSync as
|
|
32069
|
+
import { chmodSync as chmodSync4, linkSync as linkSync6, mkdirSync as mkdirSync34, rmSync as rmSync23, writeFileSync as writeFileSync23 } from "node:fs";
|
|
31954
32070
|
|
|
31955
32071
|
// ../core/src/signIn/signInRedirectPage.ts
|
|
31956
32072
|
import { createHash as createHash14 } from "node:crypto";
|
|
@@ -31975,20 +32091,20 @@ function signInRedirectPage(link) {
|
|
|
31975
32091
|
// ../core/src/signIn/writeSignInRedirect.ts
|
|
31976
32092
|
function writeSignInRedirect(at2) {
|
|
31977
32093
|
const store = machineStore(at2.root, at2.configDir);
|
|
31978
|
-
const
|
|
31979
|
-
const tmp = `${
|
|
32094
|
+
const file9 = store.file(SIGN_IN_REDIRECT.newName());
|
|
32095
|
+
const tmp = `${file9}.${process.pid}.tmp`;
|
|
31980
32096
|
try {
|
|
31981
|
-
|
|
32097
|
+
mkdirSync34(store.dir, { recursive: true, mode: 448 });
|
|
31982
32098
|
chmodSync4(store.dir, 448);
|
|
31983
|
-
|
|
32099
|
+
writeFileSync23(tmp, signInRedirectPage(at2.link), { mode: 384, flag: "wx" });
|
|
31984
32100
|
chmodSync4(tmp, 384);
|
|
31985
|
-
|
|
32101
|
+
linkSync6(tmp, file9);
|
|
31986
32102
|
} catch (e) {
|
|
31987
32103
|
throw new Error(machineAccess(at2.configDir) ?? e.message);
|
|
31988
32104
|
} finally {
|
|
31989
|
-
|
|
32105
|
+
rmSync23(tmp, { force: true });
|
|
31990
32106
|
}
|
|
31991
|
-
return
|
|
32107
|
+
return file9;
|
|
31992
32108
|
}
|
|
31993
32109
|
|
|
31994
32110
|
// ../core/src/projects/autoRegister.ts
|
|
@@ -32305,7 +32421,7 @@ function ttyIo() {
|
|
|
32305
32421
|
import path112 from "node:path";
|
|
32306
32422
|
|
|
32307
32423
|
// ../core/src/agents/agentDocWriter.ts
|
|
32308
|
-
import { rmSync as
|
|
32424
|
+
import { rmSync as rmSync24 } from "node:fs";
|
|
32309
32425
|
import path108 from "node:path";
|
|
32310
32426
|
var teamtrailVersion = () => {
|
|
32311
32427
|
const v = runningVersion();
|
|
@@ -32373,12 +32489,12 @@ var AgentDocWriter = class {
|
|
|
32373
32489
|
*/
|
|
32374
32490
|
pullAnswers() {
|
|
32375
32491
|
for (const q of this.activity.snapshot.pending) {
|
|
32376
|
-
const
|
|
32377
|
-
const ans = readJsonFile(
|
|
32378
|
-
if (ans) this.take(
|
|
32492
|
+
const file9 = path108.join(this.root, agentPaths.answer(q.sessionId, q.id));
|
|
32493
|
+
const ans = readJsonFile(file9);
|
|
32494
|
+
if (ans) this.take(file9, ans, q);
|
|
32379
32495
|
}
|
|
32380
32496
|
}
|
|
32381
|
-
take(
|
|
32497
|
+
take(file9, ans, q) {
|
|
32382
32498
|
let check2;
|
|
32383
32499
|
try {
|
|
32384
32500
|
check2 = checkAgentAnswer(this.root, ans, { sessionId: q.sessionId, questionId: q.id });
|
|
@@ -32386,7 +32502,7 @@ var AgentDocWriter = class {
|
|
|
32386
32502
|
return this.cannotVerify(q.sessionId);
|
|
32387
32503
|
}
|
|
32388
32504
|
if (check2.kind === "forged" && this.newerWriter(ans.writer)) return this.skewed(q.sessionId, ans.writer);
|
|
32389
|
-
|
|
32505
|
+
rmSync24(file9, { force: true });
|
|
32390
32506
|
if (check2.kind === "signed") return this.activity.answer(q.id, ans.text, ans.author || "trail lead", check2.how);
|
|
32391
32507
|
this.activity.push({
|
|
32392
32508
|
source: "system",
|
|
@@ -32445,35 +32561,35 @@ function claimTrailName(root, family, taken = /* @__PURE__ */ new Set(), holder)
|
|
|
32445
32561
|
for (let n = 1; ; n++) {
|
|
32446
32562
|
const trailName = name(family, n);
|
|
32447
32563
|
if (taken.has(trailName)) continue;
|
|
32448
|
-
const
|
|
32564
|
+
const file9 = path109.join(dir4, `${trailName}.json`);
|
|
32449
32565
|
try {
|
|
32450
|
-
fs3.writeFileSync(
|
|
32566
|
+
fs3.writeFileSync(file9, JSON.stringify({ pid: process.pid, holder, at: Date.now() }), { flag: "wx" });
|
|
32451
32567
|
} catch (e) {
|
|
32452
32568
|
if (e.code !== "EEXIST") throw e;
|
|
32453
|
-
const lock = readLock(
|
|
32569
|
+
const lock = readLock(file9);
|
|
32454
32570
|
if (!lock) continue;
|
|
32455
32571
|
const owner = lock.pid ?? 0;
|
|
32456
32572
|
if (owner === process.pid && lock.holder === holder) return trailName;
|
|
32457
32573
|
if (processAlive(owner)) continue;
|
|
32458
|
-
fs3.rmSync(
|
|
32574
|
+
fs3.rmSync(file9, { force: true });
|
|
32459
32575
|
n--;
|
|
32460
32576
|
continue;
|
|
32461
32577
|
}
|
|
32462
|
-
if (holder === void 0) process.once("exit", () => fs3.rmSync(
|
|
32578
|
+
if (holder === void 0) process.once("exit", () => fs3.rmSync(file9, { force: true }));
|
|
32463
32579
|
return trailName;
|
|
32464
32580
|
}
|
|
32465
32581
|
}
|
|
32466
|
-
function readLock(
|
|
32582
|
+
function readLock(file9) {
|
|
32467
32583
|
try {
|
|
32468
|
-
return JSON.parse(fs3.readFileSync(
|
|
32584
|
+
return JSON.parse(fs3.readFileSync(file9, "utf8"));
|
|
32469
32585
|
} catch {
|
|
32470
32586
|
return void 0;
|
|
32471
32587
|
}
|
|
32472
32588
|
}
|
|
32473
32589
|
function releaseTrailName(root, trailName, holder) {
|
|
32474
|
-
const
|
|
32475
|
-
const lock = readLock(
|
|
32476
|
-
if (lock?.pid === process.pid && lock.holder === holder) fs3.rmSync(
|
|
32590
|
+
const file9 = path109.join(root, AGENTS_DIR, TRAIL_NAMES_DIR, `${trailName}.json`);
|
|
32591
|
+
const lock = readLock(file9);
|
|
32592
|
+
if (lock?.pid === process.pid && lock.holder === holder) fs3.rmSync(file9, { force: true });
|
|
32477
32593
|
}
|
|
32478
32594
|
|
|
32479
32595
|
// ../core/src/policy/repoRootSpellings.ts
|
|
@@ -32488,16 +32604,16 @@ function repoRootSpellings(repoRoot) {
|
|
|
32488
32604
|
|
|
32489
32605
|
// ../core/src/agents/chartedStore.ts
|
|
32490
32606
|
import path110 from "node:path";
|
|
32491
|
-
var
|
|
32492
|
-
var
|
|
32607
|
+
var safe17 = (s) => s.replace(/[^\w.-]/g, "_");
|
|
32608
|
+
var file7 = (root, mapId) => path110.join(root, AGENTS_DIR, "charted", `${safe17(mapId)}.json`);
|
|
32493
32609
|
var read3 = (root, mapId) => {
|
|
32494
|
-
const f = readJsonFile(
|
|
32610
|
+
const f = readJsonFile(file7(root, mapId));
|
|
32495
32611
|
return f?.v === 1 && f.tickets && typeof f.tickets === "object" ? f.tickets : {};
|
|
32496
32612
|
};
|
|
32497
32613
|
function recordCharted(root, mapId, ticketIds, by) {
|
|
32498
32614
|
ignoreAgentsDir(root);
|
|
32499
32615
|
const tickets2 = { ...read3(root, mapId), ...Object.fromEntries(ticketIds.map((id) => [id, by])) };
|
|
32500
|
-
writeJsonAtomic(
|
|
32616
|
+
writeJsonAtomic(file7(root, mapId), { v: 1, tickets: tickets2 });
|
|
32501
32617
|
}
|
|
32502
32618
|
var chartedBy = (root, mapId, ticketId) => read3(root, mapId)[ticketId];
|
|
32503
32619
|
|
|
@@ -32793,7 +32909,7 @@ async function findCatalogGuide(input2) {
|
|
|
32793
32909
|
}
|
|
32794
32910
|
|
|
32795
32911
|
// ../core/src/guides/newGuide.ts
|
|
32796
|
-
import { existsSync as existsSync38, mkdirSync as
|
|
32912
|
+
import { existsSync as existsSync38, mkdirSync as mkdirSync35, writeFileSync as writeFileSync24 } from "node:fs";
|
|
32797
32913
|
var ID_RE2 = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
|
|
32798
32914
|
var nameOf3 = (id) => {
|
|
32799
32915
|
const words7 = id.split("-").join(" ");
|
|
@@ -32830,12 +32946,12 @@ function newGuide(input2) {
|
|
|
32830
32946
|
throw new OperationError(
|
|
32831
32947
|
`${input2.id} is a built-in guide; pick another id (a file named ${input2.id}.md replaces it)`
|
|
32832
32948
|
);
|
|
32833
|
-
const
|
|
32834
|
-
if (existsSync38(
|
|
32949
|
+
const file9 = guideFilePath(input2.root, input2.id);
|
|
32950
|
+
if (existsSync38(file9)) throw new OperationError(`${file9} already exists`);
|
|
32835
32951
|
const text11 = guideTemplate(input2);
|
|
32836
|
-
|
|
32837
|
-
|
|
32838
|
-
return { file:
|
|
32952
|
+
mkdirSync35(guidesDir(input2.root), { recursive: true });
|
|
32953
|
+
writeFileSync24(file9, text11);
|
|
32954
|
+
return { file: file9, lint: lintGuide(text11) };
|
|
32839
32955
|
}
|
|
32840
32956
|
|
|
32841
32957
|
// src/approve/showItem.ts
|
|
@@ -32959,7 +33075,7 @@ function parseArgs(argv2) {
|
|
|
32959
33075
|
process.exit(0);
|
|
32960
33076
|
case "-v":
|
|
32961
33077
|
case "--version":
|
|
32962
|
-
process.stdout.write(`${"0.61.
|
|
33078
|
+
process.stdout.write(`${"0.61.2"}
|
|
32963
33079
|
`);
|
|
32964
33080
|
process.exit(0);
|
|
32965
33081
|
case "--no-open":
|
|
@@ -33032,11 +33148,11 @@ var scout_default = "---\ndescription: Teamtrail trails: new, resume, status, in
|
|
|
33032
33148
|
// src/files.ts
|
|
33033
33149
|
import fs4 from "node:fs";
|
|
33034
33150
|
import path114 from "node:path";
|
|
33035
|
-
function writeIfChanged(
|
|
33036
|
-
const prev = fs4.existsSync(
|
|
33151
|
+
function writeIfChanged(file9, text11) {
|
|
33152
|
+
const prev = fs4.existsSync(file9) ? fs4.readFileSync(file9, "utf8") : void 0;
|
|
33037
33153
|
if (prev === text11) return "unchanged";
|
|
33038
|
-
fs4.mkdirSync(path114.dirname(
|
|
33039
|
-
fs4.writeFileSync(
|
|
33154
|
+
fs4.mkdirSync(path114.dirname(file9), { recursive: true });
|
|
33155
|
+
fs4.writeFileSync(file9, text11);
|
|
33040
33156
|
return prev === void 0 ? "added" : "updated";
|
|
33041
33157
|
}
|
|
33042
33158
|
|
|
@@ -33054,10 +33170,10 @@ var claudeSettingsFile = (env = process.env) => path116.join(env.CLAUDE_CONFIG_D
|
|
|
33054
33170
|
|
|
33055
33171
|
// src/protect/readSettings.ts
|
|
33056
33172
|
import fs5 from "node:fs";
|
|
33057
|
-
function readSettings(
|
|
33058
|
-
if (!fs5.existsSync(
|
|
33173
|
+
function readSettings(file9) {
|
|
33174
|
+
if (!fs5.existsSync(file9)) return {};
|
|
33059
33175
|
try {
|
|
33060
|
-
const parsed3 = JSON.parse(fs5.readFileSync(
|
|
33176
|
+
const parsed3 = JSON.parse(fs5.readFileSync(file9, "utf8"));
|
|
33061
33177
|
const plain2 = typeof parsed3 === "object" && parsed3 !== null && !Array.isArray(parsed3);
|
|
33062
33178
|
return plain2 ? parsed3 : void 0;
|
|
33063
33179
|
} catch {
|
|
@@ -33066,18 +33182,18 @@ function readSettings(file10) {
|
|
|
33066
33182
|
}
|
|
33067
33183
|
|
|
33068
33184
|
// src/protect/claudeSandboxState.ts
|
|
33069
|
-
function enabledIn(
|
|
33070
|
-
const sandbox = readSettings(
|
|
33185
|
+
function enabledIn(file9) {
|
|
33186
|
+
const sandbox = readSettings(file9)?.sandbox;
|
|
33071
33187
|
if (typeof sandbox !== "object" || sandbox === null) return void 0;
|
|
33072
33188
|
const enabled = sandbox.enabled;
|
|
33073
33189
|
return typeof enabled === "boolean" ? enabled : void 0;
|
|
33074
33190
|
}
|
|
33075
33191
|
function claudeSandboxState(cwd, env = process.env) {
|
|
33076
33192
|
const files = [claudeLocalSettings(cwd), path117.join(cwd, ".claude", "settings.json"), claudeSettingsFile(env)];
|
|
33077
|
-
for (const
|
|
33078
|
-
const enabled = enabledIn(
|
|
33193
|
+
for (const file9 of files) {
|
|
33194
|
+
const enabled = enabledIn(file9);
|
|
33079
33195
|
if (enabled === void 0) continue;
|
|
33080
|
-
return enabled ? { kind: "on", file:
|
|
33196
|
+
return enabled ? { kind: "on", file: file9 } : { kind: "off", file: file9 };
|
|
33081
33197
|
}
|
|
33082
33198
|
return { kind: "unset" };
|
|
33083
33199
|
}
|
|
@@ -33089,8 +33205,8 @@ function indentOf(text11) {
|
|
|
33089
33205
|
const m = text11?.match(/^[{[][^\n]*\n([ \t]+)\S/);
|
|
33090
33206
|
return m ? m[1] : 2;
|
|
33091
33207
|
}
|
|
33092
|
-
function writeSettings(
|
|
33093
|
-
const target2 = fs6.existsSync(
|
|
33208
|
+
function writeSettings(file9, settings2) {
|
|
33209
|
+
const target2 = fs6.existsSync(file9) ? fs6.realpathSync(file9) : file9;
|
|
33094
33210
|
const before = fs6.existsSync(target2) ? fs6.readFileSync(target2, "utf8") : void 0;
|
|
33095
33211
|
const mode = before === void 0 ? void 0 : fs6.statSync(target2).mode & 511;
|
|
33096
33212
|
fs6.mkdirSync(path118.dirname(target2), { recursive: true });
|
|
@@ -33106,27 +33222,27 @@ function writeSettings(file10, settings2) {
|
|
|
33106
33222
|
}
|
|
33107
33223
|
|
|
33108
33224
|
// src/protect/enableClaudeSandbox.ts
|
|
33109
|
-
function enableClaudeSandbox(
|
|
33110
|
-
const settings2 = readSettings(
|
|
33225
|
+
function enableClaudeSandbox(file9) {
|
|
33226
|
+
const settings2 = readSettings(file9);
|
|
33111
33227
|
if (!settings2) return "unreadable";
|
|
33112
33228
|
const sandbox = settings2.sandbox ?? {};
|
|
33113
33229
|
if (typeof sandbox !== "object" || sandbox === null || Array.isArray(sandbox)) return "unreadable";
|
|
33114
33230
|
const current = sandbox;
|
|
33115
33231
|
if (current.enabled === true) return "unchanged";
|
|
33116
33232
|
const prompts = typeof current.autoAllowBashIfSandboxed === "boolean" ? {} : { autoAllowBashIfSandboxed: false };
|
|
33117
|
-
writeSettings(
|
|
33233
|
+
writeSettings(file9, { ...settings2, sandbox: { ...current, enabled: true, ...prompts } });
|
|
33118
33234
|
return "enabled";
|
|
33119
33235
|
}
|
|
33120
33236
|
|
|
33121
33237
|
// src/protect/applySandbox.ts
|
|
33122
33238
|
function applySandbox(o) {
|
|
33123
|
-
const
|
|
33239
|
+
const file9 = claudeLocalSettings(o.cwd);
|
|
33124
33240
|
const state = claudeSandboxState(o.cwd);
|
|
33125
33241
|
if (state.kind === "on") return { kind: "already-on", file: state.file };
|
|
33126
|
-
if (o.choice !== "on") return { kind: "left", why: o.choice, file:
|
|
33127
|
-
const done2 = enableClaudeSandbox(
|
|
33128
|
-
if (done2 === "unreadable") return { kind: "unreadable", file:
|
|
33129
|
-
return { kind: "turned-on", file:
|
|
33242
|
+
if (o.choice !== "on") return { kind: "left", why: o.choice, file: file9 };
|
|
33243
|
+
const done2 = enableClaudeSandbox(file9);
|
|
33244
|
+
if (done2 === "unreadable") return { kind: "unreadable", file: file9 };
|
|
33245
|
+
return { kind: "turned-on", file: file9 };
|
|
33130
33246
|
}
|
|
33131
33247
|
|
|
33132
33248
|
// src/protect/protectConfig.ts
|
|
@@ -33137,18 +33253,18 @@ import path121 from "node:path";
|
|
|
33137
33253
|
var PAD = " ";
|
|
33138
33254
|
var WHY3 = "Claude Code's own file tools can't read or change it. That is best effort unless Claude Code's sandbox is on: without it, a shell command (cat) can still read the folder; with it, sandboxed commands can't either. Teamtrail's own MCP server is not affected";
|
|
33139
33255
|
function claudeProtectionLines(p, dirs2) {
|
|
33140
|
-
const
|
|
33256
|
+
const folder2 = dirs2.join(" and ");
|
|
33141
33257
|
switch (p.kind) {
|
|
33142
33258
|
case "added":
|
|
33143
33259
|
return [
|
|
33144
|
-
` Config folder protected \xB7 ${
|
|
33260
|
+
` Config folder protected \xB7 ${folder2} \xB7 added to ${p.file}:`,
|
|
33145
33261
|
...p.added.map((a) => `${PAD}+ ${a}`),
|
|
33146
33262
|
`${PAD}${WHY3}.`,
|
|
33147
33263
|
`${PAD}To remove: delete those entries from ${p.file}; connect with --no-protect-config to skip this.`
|
|
33148
33264
|
];
|
|
33149
33265
|
case "unchanged":
|
|
33150
33266
|
return [
|
|
33151
|
-
` Config folder already protected \xB7 ${
|
|
33267
|
+
` Config folder already protected \xB7 ${folder2} \xB7 deny rules in ${p.file}`,
|
|
33152
33268
|
`${PAD}To remove: delete the entries naming it from ${p.file}; connect with --no-protect-config to skip this.`
|
|
33153
33269
|
];
|
|
33154
33270
|
case "pattern-path":
|
|
@@ -33227,20 +33343,20 @@ function merge(s, dirs2) {
|
|
|
33227
33343
|
];
|
|
33228
33344
|
return parts2.some((p) => !p) ? void 0 : parts2.flatMap((p) => p);
|
|
33229
33345
|
}
|
|
33230
|
-
function protectClaude(
|
|
33346
|
+
function protectClaude(file9, dirs2) {
|
|
33231
33347
|
const all = claudeRules(dirs2);
|
|
33232
33348
|
const byHand = [
|
|
33233
33349
|
...all.deny.map((r) => `permissions.deny: ${r}`),
|
|
33234
33350
|
...all.denyRead.map((d) => `sandbox.filesystem.denyRead: ${d}`),
|
|
33235
33351
|
...all.denyWrite.map((d) => `sandbox.filesystem.denyWrite: ${d}`)
|
|
33236
33352
|
];
|
|
33237
|
-
if (dirs2.some((d) => PATTERN.test(d))) return { kind: "pattern-path", file:
|
|
33238
|
-
const settings2 = readSettings(
|
|
33353
|
+
if (dirs2.some((d) => PATTERN.test(d))) return { kind: "pattern-path", file: file9, rules: byHand };
|
|
33354
|
+
const settings2 = readSettings(file9);
|
|
33239
33355
|
const added = settings2 && merge(settings2, dirs2);
|
|
33240
|
-
if (!settings2 || !added) return { kind: "unreadable", file:
|
|
33241
|
-
if (!added.length) return { kind: "unchanged", file:
|
|
33242
|
-
writeSettings(
|
|
33243
|
-
return { kind: "added", file:
|
|
33356
|
+
if (!settings2 || !added) return { kind: "unreadable", file: file9, rules: byHand };
|
|
33357
|
+
if (!added.length) return { kind: "unchanged", file: file9 };
|
|
33358
|
+
writeSettings(file9, settings2);
|
|
33359
|
+
return { kind: "added", file: file9, added };
|
|
33244
33360
|
}
|
|
33245
33361
|
|
|
33246
33362
|
// src/protect/protectedDirs.ts
|
|
@@ -33369,11 +33485,11 @@ function hookCommand(dir4, self) {
|
|
|
33369
33485
|
const where2 = dir4 && dir4 !== BRAND.dataDir ? ["--dir", dir4] : [];
|
|
33370
33486
|
return shellLine([self.command, ...self.args, "hook", "claude", ...where2]);
|
|
33371
33487
|
}
|
|
33372
|
-
function installClaudeHook(
|
|
33488
|
+
function installClaudeHook(file9, dir4, self) {
|
|
33373
33489
|
let settings2 = {};
|
|
33374
|
-
if (fs8.existsSync(
|
|
33490
|
+
if (fs8.existsSync(file9)) {
|
|
33375
33491
|
try {
|
|
33376
|
-
settings2 = JSON.parse(fs8.readFileSync(
|
|
33492
|
+
settings2 = JSON.parse(fs8.readFileSync(file9, "utf8"));
|
|
33377
33493
|
} catch {
|
|
33378
33494
|
return "skipped (settings file is not valid JSON)";
|
|
33379
33495
|
}
|
|
@@ -33386,7 +33502,7 @@ function installClaudeHook(file10, dir4, self) {
|
|
|
33386
33502
|
...settings2,
|
|
33387
33503
|
hooks: { ...settings2.hooks, SessionStart: [...kept, { hooks: [{ type: "command", command, timeout: 30 }] }] }
|
|
33388
33504
|
};
|
|
33389
|
-
return writeIfChanged(
|
|
33505
|
+
return writeIfChanged(file9, `${JSON.stringify(next, null, 2)}
|
|
33390
33506
|
`);
|
|
33391
33507
|
}
|
|
33392
33508
|
|
|
@@ -33443,8 +33559,8 @@ function registerClaude(o, server) {
|
|
|
33443
33559
|
return `not updated (${again.out || `exit ${again.status}`}). Run: claude mcp remove ${BRAND.slug}, then ${shown3}`;
|
|
33444
33560
|
}
|
|
33445
33561
|
function connectClaude(o) {
|
|
33446
|
-
const
|
|
33447
|
-
o.print(` /scout command ${writeIfChanged(
|
|
33562
|
+
const file9 = path124.join(o.cwd, ".claude", "commands", "scout.md");
|
|
33563
|
+
o.print(` /scout command ${writeIfChanged(file9, scout_default)} \xB7 ${path124.relative(o.cwd, file9)}`);
|
|
33448
33564
|
o.print(` MCP server ${registerClaude(o, serverCommand(o.self, o.dir))}`);
|
|
33449
33565
|
const settings2 = claudeLocalSettings(o.cwd);
|
|
33450
33566
|
o.print(
|
|
@@ -33453,8 +33569,8 @@ function connectClaude(o) {
|
|
|
33453
33569
|
}
|
|
33454
33570
|
function connectCodex(o) {
|
|
33455
33571
|
const home = process.env.CODEX_HOME || path124.join(os8.homedir(), ".codex");
|
|
33456
|
-
const
|
|
33457
|
-
o.print(` /scout prompt ${writeIfChanged(
|
|
33572
|
+
const file9 = path124.join(home, "prompts", "scout.md");
|
|
33573
|
+
o.print(` /scout prompt ${writeIfChanged(file9, scout_default)} \xB7 ${file9}`);
|
|
33458
33574
|
const [command, ...args] = serverCommand(o.self, o.dir);
|
|
33459
33575
|
const env = process.env.CODEX_HOME ? ["--env", `CODEX_HOME=${process.env.CODEX_HOME}`] : [];
|
|
33460
33576
|
const r = o.run("codex", ["mcp", "add", BRAND.slug, ...env, "--", command, ...args]);
|
|
@@ -33564,8 +33680,8 @@ function connectClaude2(o) {
|
|
|
33564
33680
|
fail(
|
|
33565
33681
|
`Claude Code keeps the token in its config, so connect needs it: --token-stdin, $${BRAND.tokenEnv} or --token`
|
|
33566
33682
|
);
|
|
33567
|
-
const
|
|
33568
|
-
o.print(` /scout command ${writeIfChanged(
|
|
33683
|
+
const file9 = path125.join(o.cwd, ".claude", "commands", "scout.md");
|
|
33684
|
+
o.print(` /scout command ${writeIfChanged(file9, scout_default)} \xB7 ${path125.relative(o.cwd, file9)}`);
|
|
33569
33685
|
const shown3 = `claude mcp add --transport http ${BRAND.slug} ${o.url} --header "Authorization: Bearer $${BRAND.tokenEnv}"`;
|
|
33570
33686
|
const add3 = ["mcp", "add", "--transport", "http", BRAND.slug, o.url, "--header", `Authorization: Bearer ${o.token}`];
|
|
33571
33687
|
const r = (o.run ?? runCli2)("claude", add3);
|
|
@@ -33585,8 +33701,8 @@ function connectClaude2(o) {
|
|
|
33585
33701
|
}
|
|
33586
33702
|
function connectCodex2(o) {
|
|
33587
33703
|
const home = process.env.CODEX_HOME || path125.join(os9.homedir(), ".codex");
|
|
33588
|
-
const
|
|
33589
|
-
o.print(` /scout prompt ${writeIfChanged(
|
|
33704
|
+
const file9 = path125.join(home, "prompts", "scout.md");
|
|
33705
|
+
o.print(` /scout prompt ${writeIfChanged(file9, scout_default)} \xB7 ${file9}`);
|
|
33590
33706
|
const args = ["mcp", "add", BRAND.slug, "--url", o.url, "--bearer-token-env-var", BRAND.tokenEnv];
|
|
33591
33707
|
const r = (o.run ?? runCli2)("codex", args);
|
|
33592
33708
|
const config4 = path125.join(home, "config.toml");
|
|
@@ -33921,8 +34037,8 @@ function guidesNew(a, io) {
|
|
|
33921
34037
|
}
|
|
33922
34038
|
const root = path129.resolve(a.dir);
|
|
33923
34039
|
const author = a.author ?? gitName(path129.dirname(root));
|
|
33924
|
-
const { file:
|
|
33925
|
-
const shown3 = path129.relative(process.cwd(),
|
|
34040
|
+
const { file: file9, lint } = newGuide({ root, id, author });
|
|
34041
|
+
const shown3 = path129.relative(process.cwd(), file9) || file9;
|
|
33926
34042
|
printFindings(io, shown3, lint.findings);
|
|
33927
34043
|
io.out(
|
|
33928
34044
|
[
|
|
@@ -34149,8 +34265,8 @@ async function guidesCli(argv2) {
|
|
|
34149
34265
|
// src/knowledgeImport.ts
|
|
34150
34266
|
import { readFileSync as readFileSync37 } from "node:fs";
|
|
34151
34267
|
import path133 from "node:path";
|
|
34152
|
-
function importKnowledge(root,
|
|
34153
|
-
const parts2 = splitForImport(readFileSync37(
|
|
34268
|
+
function importKnowledge(root, file9) {
|
|
34269
|
+
const parts2 = splitForImport(readFileSync37(file9, "utf8"), path133.basename(file9));
|
|
34154
34270
|
const now2 = Date.now();
|
|
34155
34271
|
const ids2 = [];
|
|
34156
34272
|
for (const p of parts2) {
|
|
@@ -34186,7 +34302,7 @@ function mcpHttpOptions(o, root) {
|
|
|
34186
34302
|
allowHosts: o.allowHosts,
|
|
34187
34303
|
leaseMinutes: o.leaseMinutes,
|
|
34188
34304
|
noRegister: o.noRegister,
|
|
34189
|
-
version: "0.61.
|
|
34305
|
+
version: "0.61.2"
|
|
34190
34306
|
};
|
|
34191
34307
|
}
|
|
34192
34308
|
|
|
@@ -44760,7 +44876,7 @@ import { randomUUID as randomUUID4 } from "node:crypto";
|
|
|
44760
44876
|
import path134 from "node:path";
|
|
44761
44877
|
|
|
44762
44878
|
// src/ownVersion.ts
|
|
44763
|
-
var OWN_VERSION = true ? "0.61.
|
|
44879
|
+
var OWN_VERSION = true ? "0.61.2" : void 0;
|
|
44764
44880
|
|
|
44765
44881
|
// src/mcp/trail/agentLeases.ts
|
|
44766
44882
|
var AgentLeases = class {
|
|
@@ -47075,22 +47191,22 @@ async function complete(c, wait) {
|
|
|
47075
47191
|
const transcript = wantsTranscript ? log.map((e) => `**${e.author}:** ${e.text}`).join("\n\n") : void 0;
|
|
47076
47192
|
const { info } = levelFor(ctx.root, snap, t);
|
|
47077
47193
|
assertConfirmed(t, info);
|
|
47078
|
-
const
|
|
47194
|
+
const verified2 = info.level !== "off";
|
|
47079
47195
|
const declared = declaredPaths({
|
|
47080
47196
|
remote: ctx.remote,
|
|
47081
|
-
verified,
|
|
47197
|
+
verified: verified2,
|
|
47082
47198
|
paths: input2.paths,
|
|
47083
47199
|
noCodeReason: input2.noCodeReason,
|
|
47084
47200
|
repoRoot: pathRoots(ctx)
|
|
47085
47201
|
});
|
|
47086
47202
|
assertCriteria(ctx.root, snap, t, info.level);
|
|
47087
|
-
if (
|
|
47203
|
+
if (verified2)
|
|
47088
47204
|
await assertRulesAnswered(ctx, { snap, ticket: t, declared, answers: input2.ruleAnswers, agent: c.agent });
|
|
47089
47205
|
const checked = checkedAnswers(ctx, { snap, ticket: t, given: input2.checklist });
|
|
47090
47206
|
await keepAnswers(ctx, { snap, ticket: t, checked });
|
|
47091
47207
|
spend(c.human, `the close of ${t.key}`);
|
|
47092
47208
|
let unverified = {};
|
|
47093
|
-
if (!
|
|
47209
|
+
if (!verified2) {
|
|
47094
47210
|
unverified = { warning: await flagUnverified(ctx, { snap, ticket: t, seen: c.seen }) };
|
|
47095
47211
|
await resolveDirectly(c, { meta: meta4, transcript });
|
|
47096
47212
|
} else {
|
|
@@ -47233,7 +47349,7 @@ async function findPrecedentTool(ctx, input2) {
|
|
|
47233
47349
|
}
|
|
47234
47350
|
|
|
47235
47351
|
// src/mcp/trail/types.ts
|
|
47236
|
-
var
|
|
47352
|
+
var TRAIL_LEAD8 = "trail lead";
|
|
47237
47353
|
|
|
47238
47354
|
// src/mcp/trail/hitl.ts
|
|
47239
47355
|
async function ask3(ctx, input2, ctl = {}) {
|
|
@@ -47262,7 +47378,7 @@ async function ask3(ctx, input2, ctl = {}) {
|
|
|
47262
47378
|
ctx.waits.set(
|
|
47263
47379
|
q.id,
|
|
47264
47380
|
answer3.then((text11) => {
|
|
47265
|
-
const author = [...ctx.activity.snapshot.chats].reverse().find((c) => c.sessionId === sid && c.from === "human")?.author ??
|
|
47381
|
+
const author = [...ctx.activity.snapshot.chats].reverse().find((c) => c.sessionId === sid && c.from === "human")?.author ?? TRAIL_LEAD8;
|
|
47266
47382
|
const { via, chatOf, by } = ctx.activity.snapshot.answered.find((a) => a.id === q.id) ?? {};
|
|
47267
47383
|
const at2 = Date.now();
|
|
47268
47384
|
const where2 = chatNote({ via, chatOf });
|
|
@@ -47379,7 +47495,7 @@ async function answerQuestion(ctx, input2) {
|
|
|
47379
47495
|
const given = { via: "chat", note: CHAT_GUIDES };
|
|
47380
47496
|
const own3 = ctx.activity.snapshot.pending.find((p) => p.id === input2.questionId);
|
|
47381
47497
|
if (own3) {
|
|
47382
|
-
ctx.activity.answer(own3.id, input2.answer.trim(),
|
|
47498
|
+
ctx.activity.answer(own3.id, input2.answer.trim(), TRAIL_LEAD8, { via: "chat", chatOf });
|
|
47383
47499
|
return { delivered: true, to: own3.agent, ...given };
|
|
47384
47500
|
}
|
|
47385
47501
|
const doc = (await readAgentDocs(ctx.root)).find((d) => d.pending.some((q) => q.id === input2.questionId));
|
|
@@ -47388,7 +47504,7 @@ async function answerQuestion(ctx, input2) {
|
|
|
47388
47504
|
sessionId: doc.session.id,
|
|
47389
47505
|
questionId: input2.questionId,
|
|
47390
47506
|
text: input2.answer,
|
|
47391
|
-
author:
|
|
47507
|
+
author: TRAIL_LEAD8,
|
|
47392
47508
|
via: "chat",
|
|
47393
47509
|
chatOf
|
|
47394
47510
|
});
|
|
@@ -56004,10 +56120,10 @@ import path135 from "node:path";
|
|
|
56004
56120
|
|
|
56005
56121
|
// src/usage/quietFs.ts
|
|
56006
56122
|
import fs9 from "node:fs";
|
|
56007
|
-
function tail(
|
|
56123
|
+
function tail(file9, bytes2 = 256 << 10) {
|
|
56008
56124
|
try {
|
|
56009
|
-
const size3 = fs9.statSync(
|
|
56010
|
-
const fd = fs9.openSync(
|
|
56125
|
+
const size3 = fs9.statSync(file9).size;
|
|
56126
|
+
const fd = fs9.openSync(file9, "r");
|
|
56011
56127
|
try {
|
|
56012
56128
|
const buf = Buffer.alloc(Math.min(size3, bytes2));
|
|
56013
56129
|
fs9.readSync(fd, buf, 0, buf.length, size3 - buf.length);
|
|
@@ -56019,16 +56135,16 @@ function tail(file10, bytes2 = 256 << 10) {
|
|
|
56019
56135
|
return "";
|
|
56020
56136
|
}
|
|
56021
56137
|
}
|
|
56022
|
-
var size2 = (
|
|
56138
|
+
var size2 = (file9) => {
|
|
56023
56139
|
try {
|
|
56024
|
-
return fs9.statSync(
|
|
56140
|
+
return fs9.statSync(file9).size;
|
|
56025
56141
|
} catch {
|
|
56026
56142
|
return -1;
|
|
56027
56143
|
}
|
|
56028
56144
|
};
|
|
56029
|
-
var recent = (
|
|
56145
|
+
var recent = (file9, since2) => {
|
|
56030
56146
|
try {
|
|
56031
|
-
return fs9.statSync(
|
|
56147
|
+
return fs9.statSync(file9).mtimeMs >= since2;
|
|
56032
56148
|
} catch {
|
|
56033
56149
|
return false;
|
|
56034
56150
|
}
|
|
@@ -56184,8 +56300,8 @@ function codexRolloutParser() {
|
|
|
56184
56300
|
};
|
|
56185
56301
|
}
|
|
56186
56302
|
var LogFile = class {
|
|
56187
|
-
constructor(
|
|
56188
|
-
this.file =
|
|
56303
|
+
constructor(file9, parser) {
|
|
56304
|
+
this.file = file9;
|
|
56189
56305
|
this.parser = parser;
|
|
56190
56306
|
}
|
|
56191
56307
|
offset = 0;
|
|
@@ -56275,10 +56391,10 @@ var UsageMeter = class {
|
|
|
56275
56391
|
const codexMeta = meta4?.["x-codex-turn-metadata"];
|
|
56276
56392
|
const thread = meta4?.threadId ?? codexMeta?.thread_id ?? codexMeta?.session_id;
|
|
56277
56393
|
if (typeof thread === "string" && thread !== this.threadId) {
|
|
56278
|
-
const
|
|
56279
|
-
if (
|
|
56394
|
+
const file9 = findCodexRollout(thread, this.env, this.home);
|
|
56395
|
+
if (file9) {
|
|
56280
56396
|
this.threadId = thread;
|
|
56281
|
-
this.attach(
|
|
56397
|
+
this.attach(file9, "codex");
|
|
56282
56398
|
}
|
|
56283
56399
|
}
|
|
56284
56400
|
const toolUse = meta4?.["claudecode/toolUseId"];
|
|
@@ -56303,14 +56419,14 @@ var UsageMeter = class {
|
|
|
56303
56419
|
}
|
|
56304
56420
|
return void 0;
|
|
56305
56421
|
}
|
|
56306
|
-
attach(
|
|
56307
|
-
if (this.files.has(
|
|
56422
|
+
attach(file9, source) {
|
|
56423
|
+
if (this.files.has(file9)) return;
|
|
56308
56424
|
this.source = source;
|
|
56309
|
-
this.files.set(
|
|
56425
|
+
this.files.set(file9, new LogFile(file9, source === "codex" ? codexRolloutParser() : claudeTranscriptParser()));
|
|
56310
56426
|
}
|
|
56311
56427
|
poll() {
|
|
56312
|
-
for (const [
|
|
56313
|
-
const own3 = path136.basename(path136.dirname(
|
|
56428
|
+
for (const [file9, f] of this.files) {
|
|
56429
|
+
const own3 = path136.basename(path136.dirname(file9)) !== "subagents";
|
|
56314
56430
|
for (const e of f.read()) {
|
|
56315
56431
|
if (own3 && e.model && (!this.latest || e.at >= this.latest.at)) this.latest = { at: e.at, model: e.model };
|
|
56316
56432
|
const prev = this.events.get(e.key);
|
|
@@ -56330,9 +56446,9 @@ var UsageMeter = class {
|
|
|
56330
56446
|
}
|
|
56331
56447
|
/** Subagent (Task) transcripts sit next to the main one, under `<session>/subagents/`. */
|
|
56332
56448
|
attachSubagents() {
|
|
56333
|
-
for (const
|
|
56334
|
-
if (path136.basename(path136.dirname(
|
|
56335
|
-
const dir4 = path136.join(
|
|
56449
|
+
for (const file9 of [...this.files.keys()]) {
|
|
56450
|
+
if (path136.basename(path136.dirname(file9)) === "subagents") continue;
|
|
56451
|
+
const dir4 = path136.join(file9.replace(/\.jsonl$/, ""), "subagents");
|
|
56336
56452
|
for (const n of ls(dir4)) if (n.endsWith(".jsonl")) this.attach(path136.join(dir4, n), "claude-code");
|
|
56337
56453
|
}
|
|
56338
56454
|
}
|
|
@@ -56544,7 +56660,7 @@ __export(external_exports, {
|
|
|
56544
56660
|
endsWith: () => _endsWith2,
|
|
56545
56661
|
enum: () => _enum3,
|
|
56546
56662
|
exactOptional: () => exactOptional2,
|
|
56547
|
-
file: () =>
|
|
56663
|
+
file: () => file8,
|
|
56548
56664
|
flattenError: () => flattenError2,
|
|
56549
56665
|
float32: () => float32,
|
|
56550
56666
|
float64: () => float64,
|
|
@@ -73482,7 +73598,7 @@ __export(schemas_exports2, {
|
|
|
73482
73598
|
emoji: () => emoji3,
|
|
73483
73599
|
enum: () => _enum3,
|
|
73484
73600
|
exactOptional: () => exactOptional2,
|
|
73485
|
-
file: () =>
|
|
73601
|
+
file: () => file8,
|
|
73486
73602
|
float32: () => float32,
|
|
73487
73603
|
float64: () => float64,
|
|
73488
73604
|
function: () => _function,
|
|
@@ -74783,7 +74899,7 @@ var ZodFile = /* @__PURE__ */ $constructor2("ZodFile", (inst, def) => {
|
|
|
74783
74899
|
inst.max = (size3, params) => inst.check(_maxSize2(size3, params));
|
|
74784
74900
|
inst.mime = (types2, params) => inst.check(_mime2(Array.isArray(types2) ? types2 : [types2], params));
|
|
74785
74901
|
});
|
|
74786
|
-
function
|
|
74902
|
+
function file8(params) {
|
|
74787
74903
|
return _file2(ZodFile, params);
|
|
74788
74904
|
}
|
|
74789
74905
|
var ZodTransform2 = /* @__PURE__ */ $constructor2("ZodTransform", (inst, def) => {
|
|
@@ -77172,7 +77288,7 @@ import path138 from "node:path";
|
|
|
77172
77288
|
|
|
77173
77289
|
// src/serve/openSignedIn.ts
|
|
77174
77290
|
import { spawn as spawn4 } from "node:child_process";
|
|
77175
|
-
import { rmSync as
|
|
77291
|
+
import { rmSync as rmSync25 } from "node:fs";
|
|
77176
77292
|
|
|
77177
77293
|
// src/serve/browser/httpHandler.ts
|
|
77178
77294
|
import { execFileSync } from "node:child_process";
|
|
@@ -77202,7 +77318,7 @@ function linuxHttpHandler(deps) {
|
|
|
77202
77318
|
if (/snap|flatpak/i.test(`${entry}
|
|
77203
77319
|
${text11}`))
|
|
77204
77320
|
return { kind: "none", why: `the default browser (${id}) is a snap or Flatpak, which can't read the page` };
|
|
77205
|
-
return { kind: "app", name: id, command: (
|
|
77321
|
+
return { kind: "app", name: id, command: (file9) => ["gio", ["launch", entry, file9]] };
|
|
77206
77322
|
}
|
|
77207
77323
|
return { kind: "none", why: `the default browser's desktop entry (${id}) wasn't found` };
|
|
77208
77324
|
}
|
|
@@ -77222,7 +77338,7 @@ function macHttpHandler(deps) {
|
|
|
77222
77338
|
return { kind: "none", why: `couldn't ask macOS for the default browser (${e.message.split("\n")[0]})` };
|
|
77223
77339
|
}
|
|
77224
77340
|
if (!BUNDLE_ID.test(id)) return { kind: "none", why: "macOS named no default browser" };
|
|
77225
|
-
return { kind: "app", name: id, command: (
|
|
77341
|
+
return { kind: "app", name: id, command: (file9) => ["open", ["-b", id, file9]] };
|
|
77226
77342
|
}
|
|
77227
77343
|
|
|
77228
77344
|
// src/serve/browser/windowsHttpHandler.ts
|
|
@@ -77234,10 +77350,10 @@ function parseCommand(line5) {
|
|
|
77234
77350
|
if (!m) return void 0;
|
|
77235
77351
|
return { exe: m[1], args: m[2].split(/\s+/).filter(Boolean) };
|
|
77236
77352
|
}
|
|
77237
|
-
function withFile(args,
|
|
77353
|
+
function withFile(args, file9) {
|
|
77238
77354
|
const hasSlot = args.some((a) => a.includes("%1"));
|
|
77239
|
-
const filled = args.map((a) => a.includes("%1") ?
|
|
77240
|
-
return hasSlot ? filled : [...filled,
|
|
77355
|
+
const filled = args.map((a) => a.includes("%1") ? file9 : a);
|
|
77356
|
+
return hasSlot ? filled : [...filled, file9];
|
|
77241
77357
|
}
|
|
77242
77358
|
function openCommand(run3) {
|
|
77243
77359
|
const progId = regValue(run3("reg", ["query", USER_CHOICE, "/v", "ProgId"]));
|
|
@@ -77255,16 +77371,16 @@ function windowsHttpHandler(deps) {
|
|
|
77255
77371
|
}
|
|
77256
77372
|
if (!found) return { kind: "none", why: "no default browser is set for http" };
|
|
77257
77373
|
const { progId, exe, args } = found;
|
|
77258
|
-
return { kind: "app", name: progId, command: (
|
|
77374
|
+
return { kind: "app", name: progId, command: (file9) => [exe, withFile(args, file9)] };
|
|
77259
77375
|
}
|
|
77260
77376
|
|
|
77261
77377
|
// src/serve/browser/httpHandler.ts
|
|
77262
77378
|
var DEFAULT_DEPS = {
|
|
77263
77379
|
run: (cmd, args) => execFileSync(cmd, args, { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"] }),
|
|
77264
77380
|
env: process.env,
|
|
77265
|
-
readFile: (
|
|
77381
|
+
readFile: (file9) => {
|
|
77266
77382
|
try {
|
|
77267
|
-
return readFileSync38(
|
|
77383
|
+
return readFileSync38(file9, "utf8");
|
|
77268
77384
|
} catch {
|
|
77269
77385
|
return void 0;
|
|
77270
77386
|
}
|
|
@@ -77309,15 +77425,15 @@ function bare(o, why2) {
|
|
|
77309
77425
|
function openSignedIn(o) {
|
|
77310
77426
|
const browser = (o.handler ?? httpHandler)();
|
|
77311
77427
|
if (browser.kind === "none") return bare(o, browser.why);
|
|
77312
|
-
let
|
|
77428
|
+
let file9;
|
|
77313
77429
|
try {
|
|
77314
|
-
|
|
77430
|
+
file9 = writeSignInRedirect({ root: o.root, configDir: o.configDir, link: o.mint() });
|
|
77315
77431
|
} catch (e) {
|
|
77316
77432
|
return bare(o, e.message);
|
|
77317
77433
|
}
|
|
77318
|
-
const [cmd, args] = browser.command(
|
|
77434
|
+
const [cmd, args] = browser.command(file9);
|
|
77319
77435
|
const failed = (e) => {
|
|
77320
|
-
|
|
77436
|
+
rmSync25(file9, { force: true });
|
|
77321
77437
|
bare(o, `${browser.name} didn't start: ${e.message}`);
|
|
77322
77438
|
};
|
|
77323
77439
|
try {
|
|
@@ -77327,7 +77443,7 @@ function openSignedIn(o) {
|
|
|
77327
77443
|
} catch (e) {
|
|
77328
77444
|
failed(e);
|
|
77329
77445
|
}
|
|
77330
|
-
return { kind: "sign-in-page", file:
|
|
77446
|
+
return { kind: "sign-in-page", file: file9, browser: browser.name };
|
|
77331
77447
|
}
|
|
77332
77448
|
|
|
77333
77449
|
// src/serve/pairLink.ts
|
|
@@ -77423,7 +77539,7 @@ ${footer}
|
|
|
77423
77539
|
function printGreeting() {
|
|
77424
77540
|
process.stdout.write(
|
|
77425
77541
|
greeting({
|
|
77426
|
-
version: "0.61.
|
|
77542
|
+
version: "0.61.2",
|
|
77427
77543
|
tagline: BRAND.tagline,
|
|
77428
77544
|
isTTY: !!process.stdout.isTTY,
|
|
77429
77545
|
columns: process.stdout.columns ?? 80,
|
|
@@ -77755,7 +77871,7 @@ function statusOf2(ctx) {
|
|
|
77755
77871
|
}
|
|
77756
77872
|
|
|
77757
77873
|
// ../connector-slack/src/service/slackJournal.ts
|
|
77758
|
-
var
|
|
77874
|
+
var TRAIL_LEAD9 = "trail lead";
|
|
77759
77875
|
function journalSlack(ctx, e) {
|
|
77760
77876
|
const { who, by } = e;
|
|
77761
77877
|
try {
|
|
@@ -77768,7 +77884,7 @@ function journalSlack(ctx, e) {
|
|
|
77768
77884
|
...who ? { user: who.id } : {},
|
|
77769
77885
|
...who?.name ? { name: who.name } : {},
|
|
77770
77886
|
...who?.via ? { via: who.via } : {},
|
|
77771
|
-
actor: by === "lead" ?
|
|
77887
|
+
actor: by === "lead" ? TRAIL_LEAD9 : BRAND.slug,
|
|
77772
77888
|
actorKind: by === "lead" ? "trail lead" : "engine"
|
|
77773
77889
|
});
|
|
77774
77890
|
} catch {
|
|
@@ -78773,9 +78889,9 @@ async function decisionForm(ctx, adapter, target2, o) {
|
|
|
78773
78889
|
const candidates = snap.tickets.filter((t) => t.state === "open");
|
|
78774
78890
|
const risky = /* @__PURE__ */ new Set();
|
|
78775
78891
|
for (const t of candidates) if (await ticketNeedsLookout(ctx.o.root, mapId, t.id)) risky.add(t.id);
|
|
78776
|
-
const
|
|
78777
|
-
const related = relatedTicket(
|
|
78778
|
-
const tickets2 =
|
|
78892
|
+
const safe18 = { ...snap, tickets: snap.tickets.filter((t) => !risky.has(t.id)) };
|
|
78893
|
+
const related = relatedTicket(safe18, docs, o.related);
|
|
78894
|
+
const tickets2 = safe18.tickets.filter((t) => isDecisionTicket(t) || t.id === related?.id);
|
|
78779
78895
|
return {
|
|
78780
78896
|
trails: maps.map((m) => ({ id: m.id, label: `${m.key} ${m.title}` })),
|
|
78781
78897
|
mapId,
|
|
@@ -79953,11 +80069,11 @@ import { readFileSync as readFileSync40 } from "node:fs";
|
|
|
79953
80069
|
import path143 from "node:path";
|
|
79954
80070
|
var FILE13 = ".agents/slack-settings.json";
|
|
79955
80071
|
function settingStore(root) {
|
|
79956
|
-
const
|
|
80072
|
+
const file9 = path143.join(root, FILE13);
|
|
79957
80073
|
return {
|
|
79958
80074
|
read: () => {
|
|
79959
80075
|
try {
|
|
79960
|
-
return JSON.parse(readFileSync40(
|
|
80076
|
+
return JSON.parse(readFileSync40(file9, "utf8")).posted ?? {};
|
|
79961
80077
|
} catch {
|
|
79962
80078
|
return {};
|
|
79963
80079
|
}
|
|
@@ -79967,7 +80083,7 @@ function settingStore(root) {
|
|
|
79967
80083
|
}
|
|
79968
80084
|
|
|
79969
80085
|
// ../connector-slack/src/store.ts
|
|
79970
|
-
import { readFileSync as readFileSync41, rmSync as
|
|
80086
|
+
import { readFileSync as readFileSync41, rmSync as rmSync26 } from "node:fs";
|
|
79971
80087
|
import path144 from "node:path";
|
|
79972
80088
|
var DEFAULTS = {
|
|
79973
80089
|
enabled: false,
|
|
@@ -79977,19 +80093,19 @@ var DEFAULTS = {
|
|
|
79977
80093
|
command: DEFAULT_COMMAND,
|
|
79978
80094
|
channelTrail: {}
|
|
79979
80095
|
};
|
|
79980
|
-
function readJson3(
|
|
80096
|
+
function readJson3(file9) {
|
|
79981
80097
|
try {
|
|
79982
|
-
return JSON.parse(readFileSync41(
|
|
80098
|
+
return JSON.parse(readFileSync41(file9, "utf8"));
|
|
79983
80099
|
} catch {
|
|
79984
80100
|
return {};
|
|
79985
80101
|
}
|
|
79986
80102
|
}
|
|
79987
80103
|
var KEPT2 = ["enabled", "workspace", "bot", "appId", "owners", "allow", "notify", "command", "channelTrail"];
|
|
79988
80104
|
function slackStore(dir4) {
|
|
79989
|
-
const
|
|
80105
|
+
const file9 = path144.join(dir4, "slack.json");
|
|
79990
80106
|
const creds = credentialStore(dir4);
|
|
79991
80107
|
const read4 = () => {
|
|
79992
|
-
const c = readJson3(
|
|
80108
|
+
const c = readJson3(file9);
|
|
79993
80109
|
const kept = Object.fromEntries(KEPT2.filter((k) => c[k] !== void 0).map((k) => [k, c[k]]));
|
|
79994
80110
|
return {
|
|
79995
80111
|
...DEFAULTS,
|
|
@@ -80002,14 +80118,14 @@ function slackStore(dir4) {
|
|
|
80002
80118
|
};
|
|
80003
80119
|
};
|
|
80004
80120
|
return {
|
|
80005
|
-
file:
|
|
80121
|
+
file: file9,
|
|
80006
80122
|
read: read4,
|
|
80007
80123
|
write(c) {
|
|
80008
|
-
writeJsonAtomic(
|
|
80124
|
+
writeJsonAtomic(file9, c);
|
|
80009
80125
|
},
|
|
80010
80126
|
update(patch) {
|
|
80011
80127
|
const next = { ...read4(), ...patch };
|
|
80012
|
-
writeJsonAtomic(
|
|
80128
|
+
writeJsonAtomic(file9, next);
|
|
80013
80129
|
return next;
|
|
80014
80130
|
},
|
|
80015
80131
|
link() {
|
|
@@ -80031,7 +80147,7 @@ function slackStore(dir4) {
|
|
|
80031
80147
|
const { slack: _gone, ...rest } = c;
|
|
80032
80148
|
return rest;
|
|
80033
80149
|
});
|
|
80034
|
-
|
|
80150
|
+
rmSync26(file9, { force: true });
|
|
80035
80151
|
}
|
|
80036
80152
|
};
|
|
80037
80153
|
}
|
|
@@ -80045,9 +80161,9 @@ function alive3(pid) {
|
|
|
80045
80161
|
}
|
|
80046
80162
|
}
|
|
80047
80163
|
function slackLock(dir4, owner) {
|
|
80048
|
-
const
|
|
80164
|
+
const file9 = path144.join(dir4, "slack.lock");
|
|
80049
80165
|
const current = () => {
|
|
80050
|
-
const l = readJson3(
|
|
80166
|
+
const l = readJson3(file9);
|
|
80051
80167
|
return l.pid && alive3(l.pid) ? l : void 0;
|
|
80052
80168
|
};
|
|
80053
80169
|
return {
|
|
@@ -80055,7 +80171,7 @@ function slackLock(dir4, owner) {
|
|
|
80055
80171
|
acquire(root) {
|
|
80056
80172
|
const l = current();
|
|
80057
80173
|
if (l && l.owner !== owner) return { ok: false, heldBy: l.root };
|
|
80058
|
-
writeJsonAtomic(
|
|
80174
|
+
writeJsonAtomic(file9, { pid: process.pid, owner, root, at: Date.now() });
|
|
80059
80175
|
return { ok: true };
|
|
80060
80176
|
},
|
|
80061
80177
|
/** The tracker folder of another live process that holds the connection, if one does. */
|
|
@@ -80064,23 +80180,23 @@ function slackLock(dir4, owner) {
|
|
|
80064
80180
|
return l && l.owner !== owner ? l.root : void 0;
|
|
80065
80181
|
},
|
|
80066
80182
|
release() {
|
|
80067
|
-
if (current()?.owner === owner)
|
|
80183
|
+
if (current()?.owner === owner) rmSync26(file9, { force: true });
|
|
80068
80184
|
}
|
|
80069
80185
|
};
|
|
80070
80186
|
}
|
|
80071
80187
|
var ASKS_FILE = ".agents/slack.json";
|
|
80072
80188
|
var APPROVALS_FILE = ".agents/slack-approvals.json";
|
|
80073
80189
|
function askStore(root) {
|
|
80074
|
-
const
|
|
80190
|
+
const file9 = path144.join(root, ASKS_FILE);
|
|
80075
80191
|
return {
|
|
80076
|
-
read: () => readJson3(
|
|
80192
|
+
read: () => readJson3(file9).asks ?? {},
|
|
80077
80193
|
write: (asks) => writeLocalJson(root, ASKS_FILE, { asks })
|
|
80078
80194
|
};
|
|
80079
80195
|
}
|
|
80080
80196
|
function approvalStore(root) {
|
|
80081
|
-
const
|
|
80197
|
+
const file9 = path144.join(root, APPROVALS_FILE);
|
|
80082
80198
|
return {
|
|
80083
|
-
read: () => readJson3(
|
|
80199
|
+
read: () => readJson3(file9).approvals ?? {},
|
|
80084
80200
|
write: (approvals) => writeLocalJson(root, APPROVALS_FILE, { approvals })
|
|
80085
80201
|
};
|
|
80086
80202
|
}
|
|
@@ -80499,14 +80615,14 @@ function decoded(pathname) {
|
|
|
80499
80615
|
}
|
|
80500
80616
|
async function serveStatic(appDir, pathname, res) {
|
|
80501
80617
|
let rel = decoded(pathname);
|
|
80502
|
-
let
|
|
80503
|
-
if (!
|
|
80618
|
+
let file9 = path145.join(appDir, path145.normalize(rel));
|
|
80619
|
+
if (!file9.startsWith(appDir + path145.sep) || !existsSync41(file9) || statSync17(file9).isDirectory()) {
|
|
80504
80620
|
rel = "/index.html";
|
|
80505
|
-
|
|
80621
|
+
file9 = path145.join(appDir, "index.html");
|
|
80506
80622
|
}
|
|
80507
|
-
res.setHeader("Content-Type", TYPES[path145.extname(
|
|
80623
|
+
res.setHeader("Content-Type", TYPES[path145.extname(file9)] ?? "application/octet-stream");
|
|
80508
80624
|
res.setHeader("Cache-Control", rel.startsWith("/assets/") ? "public, max-age=31536000, immutable" : "no-cache");
|
|
80509
|
-
res.end(await fs12.readFile(
|
|
80625
|
+
res.end(await fs12.readFile(file9));
|
|
80510
80626
|
}
|
|
80511
80627
|
|
|
80512
80628
|
// src/serve/lookoutHandler.ts
|
|
@@ -80553,7 +80669,7 @@ async function serveLookout(opts, slackSetup) {
|
|
|
80553
80669
|
const root = path146.resolve(process.cwd(), opts.dir);
|
|
80554
80670
|
const mcp = createMcpHttp({
|
|
80555
80671
|
auth: tokenFileAuth(root),
|
|
80556
|
-
open: remoteAgentOpener({ root, version: "0.61.
|
|
80672
|
+
open: remoteAgentOpener({ root, version: "0.61.2" }),
|
|
80557
80673
|
thisMachineOnly: true
|
|
80558
80674
|
});
|
|
80559
80675
|
let hub;
|
|
@@ -80590,7 +80706,7 @@ async function serveLookout(opts, slackSetup) {
|
|
|
80590
80706
|
const howToSignIn = opts.open ? "Your browser opens ready to sign in: one click, within a minute. For another browser, open this link" : "Open it to sign in the browser";
|
|
80591
80707
|
process.stdout.write(
|
|
80592
80708
|
`
|
|
80593
|
-
${BRAND.name} ${"0.61.
|
|
80709
|
+
${BRAND.name} ${"0.61.2"} \xB7 ${BRAND.assistant.name} online
|
|
80594
80710
|
|
|
80595
80711
|
Lookout ${url2}
|
|
80596
80712
|
Sign in ${signInLink}
|
|
@@ -80609,7 +80725,7 @@ async function serveLookout(opts, slackSetup) {
|
|
|
80609
80725
|
openSignedIn({ root: bridge.root, mint, fallback: `${url2}${next}` });
|
|
80610
80726
|
}
|
|
80611
80727
|
const unlock = writeLookoutLock(bridge.root, url2);
|
|
80612
|
-
for (const w of await agentVersionWarnings(bridge.root, "0.61.
|
|
80728
|
+
for (const w of await agentVersionWarnings(bridge.root, "0.61.2"))
|
|
80613
80729
|
process.stdout.write(` Heads up ${w}
|
|
80614
80730
|
`);
|
|
80615
80731
|
const unlist = writeMcpEndpoint(bridge.root, {
|
|
@@ -80656,7 +80772,7 @@ async function mcpCommand(argv2) {
|
|
|
80656
80772
|
agent: o.agent,
|
|
80657
80773
|
leaseMinutes: o.leaseMinutes,
|
|
80658
80774
|
noRegister: o.noRegister,
|
|
80659
|
-
version: "0.61.
|
|
80775
|
+
version: "0.61.2"
|
|
80660
80776
|
});
|
|
80661
80777
|
}
|
|
80662
80778
|
function sandboxFlagFits(o, target2) {
|
|
@@ -80701,7 +80817,7 @@ async function connectCommand(argv2) {
|
|
|
80701
80817
|
protectConfig: !o.noProtectConfig
|
|
80702
80818
|
});
|
|
80703
80819
|
else {
|
|
80704
|
-
const self = selfCommand({ version: "0.61.
|
|
80820
|
+
const self = selfCommand({ version: "0.61.2", file: fileURLToPath2(import.meta.url) });
|
|
80705
80821
|
const protect = !o.noProtectConfig;
|
|
80706
80822
|
const sandbox = target2 === "claude" ? await askSandbox({ cwd: process.cwd(), flag: o.sandbox, protect }) : void 0;
|
|
80707
80823
|
runConnect(target2, {
|
|
@@ -80716,7 +80832,7 @@ async function connectCommand(argv2) {
|
|
|
80716
80832
|
process.stdout.write("\n");
|
|
80717
80833
|
}
|
|
80718
80834
|
async function main() {
|
|
80719
|
-
setRunningVersion("0.61.
|
|
80835
|
+
setRunningVersion("0.61.2");
|
|
80720
80836
|
const argv2 = process.argv.slice(2);
|
|
80721
80837
|
if (argv2[0] === "mcp") return mcpCommand(argv2.slice(1));
|
|
80722
80838
|
if (argv2[0] === "hook") {
|