@open-tomato/rafa 0.52.1 → 0.53.0
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/bundled/operators/skills/rafa-stretch-pit-stop/SKILL.md +14 -8
- package/dist/bundled/operators/skills/rafa-stretch-sweep/SKILL.md +4 -2
- package/dist/cli.js +2504 -1400
- package/dist/config/index.js +2 -2
- package/dist/core/config/config-schema.d.ts +1 -1
- package/dist/effort/session-log-path.d.ts +34 -0
- package/dist/effort/store/answered-rows.d.ts +38 -0
- package/dist/effort/store/index.js +3 -3
- package/dist/effort/store/merge-conflicts.d.ts +8 -4
- package/dist/effort/store/merge-rules.d.ts +16 -5
- package/dist/effort/store/session-row-types.d.ts +6 -1
- package/dist/effort/store/sqlite.d.ts +4 -1
- package/dist/{index-nqaqh4zz.js → index-78zcdjf5.js} +1 -1
- package/dist/{index-1tdzcheq.js → index-anvmm83x.js} +108 -42
- package/dist/{index-m672ptpg.js → index-dj8en7fg.js} +1 -1
- package/dist/{index-4wy2nmyt.js → index-kqz8x8g9.js} +3 -3
- package/dist/{index-4dwaxd5r.js → index-rkrsdes6.js} +2 -2
- package/dist/index.js +1164 -461
- package/dist/learning/index.js +112 -53
- package/dist/ports/index.d.ts +5 -5
- package/dist/ports/learning.d.ts +28 -2
- package/dist/{ready-kac4ty0p.js → ready-cnzcnv4d.js} +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -78,11 +78,12 @@ import {
|
|
|
78
78
|
sqliteCatalogue,
|
|
79
79
|
sqliteStorePath,
|
|
80
80
|
stampedValues,
|
|
81
|
+
storedLogPath,
|
|
81
82
|
updateSession,
|
|
82
83
|
withSqliteStore,
|
|
83
84
|
writeNames,
|
|
84
85
|
writeSqliteStore
|
|
85
|
-
} from "./index-
|
|
86
|
+
} from "./index-anvmm83x.js";
|
|
86
87
|
import {
|
|
87
88
|
ACTION_SHAPE,
|
|
88
89
|
CONFIG_DEFAULTS,
|
|
@@ -98,7 +99,7 @@ import {
|
|
|
98
99
|
renderTitle,
|
|
99
100
|
suggestedEnvironment,
|
|
100
101
|
titleRoundTrips
|
|
101
|
-
} from "./index-
|
|
102
|
+
} from "./index-78zcdjf5.js";
|
|
102
103
|
import {
|
|
103
104
|
ABSENT,
|
|
104
105
|
ACCEPT_REFS_FLAG,
|
|
@@ -137,6 +138,7 @@ import {
|
|
|
137
138
|
SPEC_READY_LABEL,
|
|
138
139
|
ScopeError,
|
|
139
140
|
UNREADABLE,
|
|
141
|
+
activeLogger,
|
|
140
142
|
activeServices,
|
|
141
143
|
addedNotFilledWarning,
|
|
142
144
|
aheadClaimedLine,
|
|
@@ -269,7 +271,7 @@ import {
|
|
|
269
271
|
writeHopRecord,
|
|
270
272
|
writePositionFile,
|
|
271
273
|
writeRefsBlock
|
|
272
|
-
} from "./index-
|
|
274
|
+
} from "./index-kqz8x8g9.js";
|
|
273
275
|
import {
|
|
274
276
|
BLOCKER_GAP,
|
|
275
277
|
PLAN_BLOCK_KINDS,
|
|
@@ -321,7 +323,7 @@ import {
|
|
|
321
323
|
parseWorkingTree,
|
|
322
324
|
registerAdapters,
|
|
323
325
|
restoreAdapters
|
|
324
|
-
} from "./index-
|
|
326
|
+
} from "./index-rkrsdes6.js";
|
|
325
327
|
import {
|
|
326
328
|
activeOutput,
|
|
327
329
|
activeOutputMode,
|
|
@@ -358,7 +360,7 @@ import {
|
|
|
358
360
|
requiredPrerequisite,
|
|
359
361
|
resolveConfig,
|
|
360
362
|
scopeAt
|
|
361
|
-
} from "./index-
|
|
363
|
+
} from "./index-dj8en7fg.js";
|
|
362
364
|
import {
|
|
363
365
|
BOARD_PROJECT_TEMPLATE_DEFAULT,
|
|
364
366
|
BOARD_RELATIONSHIP_MODES,
|
|
@@ -402,7 +404,7 @@ import {
|
|
|
402
404
|
} from "./index-fpgmdmww.js";
|
|
403
405
|
|
|
404
406
|
// src/adapter-registry.ts
|
|
405
|
-
import { homedir as
|
|
407
|
+
import { homedir as homedir6 } from "os";
|
|
406
408
|
// packages/rafa-board/src/adapters/tracker/local.ts
|
|
407
409
|
import { mkdir, readdir, readFile, writeFile } from "fs/promises";
|
|
408
410
|
import { join } from "path";
|
|
@@ -3159,6 +3161,7 @@ function resolvePlanStub(branchStub, planStubs) {
|
|
|
3159
3161
|
|
|
3160
3162
|
// packages/rafa/src/effort/session-log.ts
|
|
3161
3163
|
import { createReadStream } from "fs";
|
|
3164
|
+
import { homedir } from "os";
|
|
3162
3165
|
import { basename } from "path";
|
|
3163
3166
|
import { createInterface } from "readline";
|
|
3164
3167
|
function emptyUsageTotals() {
|
|
@@ -3324,10 +3327,10 @@ function parseRecord(line) {
|
|
|
3324
3327
|
return null;
|
|
3325
3328
|
}
|
|
3326
3329
|
}
|
|
3327
|
-
async function readSessionLog(filePath) {
|
|
3330
|
+
async function readSessionLog(filePath, home = homedir()) {
|
|
3328
3331
|
return accumulateSessionStats(readLines(filePath), {
|
|
3329
3332
|
sessionId: sessionIdFromPath(filePath),
|
|
3330
|
-
filePath
|
|
3333
|
+
filePath: storedLogPath(filePath, home)
|
|
3331
3334
|
});
|
|
3332
3335
|
}
|
|
3333
3336
|
|
|
@@ -3426,6 +3429,7 @@ async function findFirstEnqueue(lines, scanWindow = ENQUEUE_SCAN_WINDOW) {
|
|
|
3426
3429
|
}
|
|
3427
3430
|
return { content: null, recordIndex: null, linesScanned };
|
|
3428
3431
|
}
|
|
3432
|
+
var ABSENT_LOG_CODES = new Set(["ENOENT", "ENOTDIR"]);
|
|
3429
3433
|
|
|
3430
3434
|
// packages/rafa-effort/src/effort/attribution.ts
|
|
3431
3435
|
var ISSUE_TEAM_KEYS = ["OPT"];
|
|
@@ -3547,14 +3551,128 @@ function attributeSession(stats, enqueueContent, planStubs) {
|
|
|
3547
3551
|
taskText: taskTextFromPrompt(enqueueContent)
|
|
3548
3552
|
};
|
|
3549
3553
|
}
|
|
3554
|
+
// packages/rafa-effort/src/effort/bug-fix-rows.ts
|
|
3555
|
+
import { existsSync } from "fs";
|
|
3556
|
+
var IS_BUG = "tracker_ref IS NOT NULL AND resolution IS NULL";
|
|
3557
|
+
var SELECT_BUGS = `
|
|
3558
|
+
SELECT *
|
|
3559
|
+
FROM findings
|
|
3560
|
+
WHERE ${IS_BUG}
|
|
3561
|
+
ORDER BY ${ACROSS_STORES_ORDER}
|
|
3562
|
+
`;
|
|
3563
|
+
var SELECT_OUT_OF_SCOPE = `
|
|
3564
|
+
SELECT session_id, what, artifact
|
|
3565
|
+
FROM out_of_scope_bugs
|
|
3566
|
+
WHERE session_id IN (SELECT session_id FROM findings WHERE ${IS_BUG})
|
|
3567
|
+
ORDER BY ${ACROSS_STORES_ORDER}
|
|
3568
|
+
`;
|
|
3569
|
+
var SELECT_RESOLVED = `
|
|
3570
|
+
SELECT session_id, plan_stub, task_line, artifact, resolution
|
|
3571
|
+
FROM findings
|
|
3572
|
+
WHERE resolution IS NOT NULL
|
|
3573
|
+
ORDER BY ${ACROSS_STORES_ORDER}
|
|
3574
|
+
`;
|
|
3575
|
+
var SELECT_DONE_REPORTS = `
|
|
3576
|
+
SELECT session_id, plan_stub, task_line, outcome, collected_at
|
|
3577
|
+
FROM task_reports
|
|
3578
|
+
WHERE status = 'done'
|
|
3579
|
+
ORDER BY ${ACROSS_STORES_ORDER}
|
|
3580
|
+
`;
|
|
3581
|
+
var NO_ROWS = Object.freeze({
|
|
3582
|
+
bugs: [],
|
|
3583
|
+
outOfScope: [],
|
|
3584
|
+
resolved: [],
|
|
3585
|
+
reports: []
|
|
3586
|
+
});
|
|
3587
|
+
function unreadableRow(path2, seq, reason) {
|
|
3588
|
+
return new Error(`effort store: ${path2}: findings row ${String(seq)} ${reason}`);
|
|
3589
|
+
}
|
|
3590
|
+
function stringField(value, key) {
|
|
3591
|
+
const field2 = value[key];
|
|
3592
|
+
return typeof field2 === "string" ? field2 : null;
|
|
3593
|
+
}
|
|
3594
|
+
function parseRefJson(json) {
|
|
3595
|
+
try {
|
|
3596
|
+
const value = JSON.parse(json);
|
|
3597
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
|
|
3598
|
+
} catch {
|
|
3599
|
+
return null;
|
|
3600
|
+
}
|
|
3601
|
+
}
|
|
3602
|
+
function trackerRefOf(path2, row) {
|
|
3603
|
+
const value = parseRefJson(row.tracker_ref);
|
|
3604
|
+
if (value === null)
|
|
3605
|
+
throw unreadableRow(path2, row.seq, "holds a tracker_ref that is no JSON object");
|
|
3606
|
+
const kind = stringField(value, "kind");
|
|
3607
|
+
const externalId = stringField(value, "externalId");
|
|
3608
|
+
if (kind === null || externalId === null) {
|
|
3609
|
+
throw unreadableRow(path2, row.seq, "holds a tracker_ref with no string kind and externalId");
|
|
3610
|
+
}
|
|
3611
|
+
return { kind, externalId, url: stringField(value, "url") };
|
|
3612
|
+
}
|
|
3613
|
+
function bugOf(path2, row) {
|
|
3614
|
+
if (row.artifact === null)
|
|
3615
|
+
throw unreadableRow(path2, row.seq, "holds a tracker_ref and no artifact");
|
|
3616
|
+
return {
|
|
3617
|
+
id: row.id,
|
|
3618
|
+
sessionId: row.session_id,
|
|
3619
|
+
planStub: row.plan_stub,
|
|
3620
|
+
taskLine: row.task_line,
|
|
3621
|
+
artifact: row.artifact,
|
|
3622
|
+
trackerRef: trackerRefOf(path2, row),
|
|
3623
|
+
outcome: row.outcome,
|
|
3624
|
+
collectedAt: row.collected_at
|
|
3625
|
+
};
|
|
3626
|
+
}
|
|
3627
|
+
function selectRows(db, path2) {
|
|
3628
|
+
const bugs = db.query(SELECT_BUGS).all();
|
|
3629
|
+
const outOfScope = db.query(SELECT_OUT_OF_SCOPE).all();
|
|
3630
|
+
const resolved = db.query(SELECT_RESOLVED).all();
|
|
3631
|
+
const reports = db.query(SELECT_DONE_REPORTS).all();
|
|
3632
|
+
return {
|
|
3633
|
+
bugs: bugs.map((row) => bugOf(path2, row)),
|
|
3634
|
+
outOfScope: outOfScope.map((row) => ({
|
|
3635
|
+
sessionId: row.session_id,
|
|
3636
|
+
what: row.what,
|
|
3637
|
+
artifact: row.artifact
|
|
3638
|
+
})),
|
|
3639
|
+
resolved: resolved.map((row) => ({
|
|
3640
|
+
sessionId: row.session_id,
|
|
3641
|
+
planStub: row.plan_stub,
|
|
3642
|
+
taskLine: row.task_line,
|
|
3643
|
+
artifact: row.artifact,
|
|
3644
|
+
resolution: row.resolution
|
|
3645
|
+
})),
|
|
3646
|
+
reports: reports.map((row) => ({
|
|
3647
|
+
sessionId: row.session_id,
|
|
3648
|
+
planStub: row.plan_stub,
|
|
3649
|
+
taskLine: row.task_line,
|
|
3650
|
+
outcome: row.outcome,
|
|
3651
|
+
collectedAt: row.collected_at
|
|
3652
|
+
}))
|
|
3653
|
+
};
|
|
3654
|
+
}
|
|
3655
|
+
function readBugFixRows(repoRoot) {
|
|
3656
|
+
const path2 = sqliteStorePath(repoRoot);
|
|
3657
|
+
if (!existsSync(path2)) {
|
|
3658
|
+
return {
|
|
3659
|
+
rows: NO_ROWS,
|
|
3660
|
+
note: `no effort store at ${path2}, so no bug findings to pair;` + " a store: ndjson project keeps its findings and reports in this file too"
|
|
3661
|
+
};
|
|
3662
|
+
}
|
|
3663
|
+
return {
|
|
3664
|
+
rows: withSqliteStore(path2, "read", false, (db) => selectRows(db, path2)),
|
|
3665
|
+
note: null
|
|
3666
|
+
};
|
|
3667
|
+
}
|
|
3550
3668
|
// packages/rafa-effort/src/effort/collect.ts
|
|
3551
|
-
import { existsSync as
|
|
3552
|
-
import { homedir as
|
|
3669
|
+
import { existsSync as existsSync6, readdirSync as readdirSync6 } from "fs";
|
|
3670
|
+
import { homedir as homedir3 } from "os";
|
|
3553
3671
|
import { resolve as resolve7 } from "path";
|
|
3554
3672
|
|
|
3555
3673
|
// packages/rafa/src/effort/session-log-dirs.ts
|
|
3556
|
-
import { existsSync, readdirSync, statSync as statSync2 } from "fs";
|
|
3557
|
-
import { homedir } from "os";
|
|
3674
|
+
import { existsSync as existsSync2, readdirSync, statSync as statSync2 } from "fs";
|
|
3675
|
+
import { homedir as homedir2 } from "os";
|
|
3558
3676
|
import { join as join8, resolve as resolve2 } from "path";
|
|
3559
3677
|
var LOG_DIR_SEPARATORS = /[/\\.]/g;
|
|
3560
3678
|
var SESSION_LOG_NAME = /\.jsonl$/i;
|
|
@@ -3562,13 +3680,13 @@ var PROJECT_LOG_ROOT = [".claude", "projects"];
|
|
|
3562
3680
|
function projectLogDirName(repoRoot) {
|
|
3563
3681
|
return repoRoot.replace(LOG_DIR_SEPARATORS, "-");
|
|
3564
3682
|
}
|
|
3565
|
-
function sessionLogDir(repoRoot, home =
|
|
3683
|
+
function sessionLogDir(repoRoot, home = homedir2()) {
|
|
3566
3684
|
return join8(home, ...PROJECT_LOG_ROOT, projectLogDirName(repoRoot));
|
|
3567
3685
|
}
|
|
3568
|
-
function projectLogDirs(repoRoot, worktreeDir, home =
|
|
3686
|
+
function projectLogDirs(repoRoot, worktreeDir, home = homedir2()) {
|
|
3569
3687
|
const main = { dir: sessionLogDir(repoRoot, home), worktree: null };
|
|
3570
3688
|
const root = join8(home, ...PROJECT_LOG_ROOT);
|
|
3571
|
-
if (!
|
|
3689
|
+
if (!existsSync2(root))
|
|
3572
3690
|
return [main];
|
|
3573
3691
|
const worktreeRoot = resolve2(repoRoot, worktreeDir);
|
|
3574
3692
|
const prefix = `${projectLogDirName(worktreeRoot)}-`;
|
|
@@ -3583,7 +3701,7 @@ function projectLogDirs(repoRoot, worktreeDir, home = homedir()) {
|
|
|
3583
3701
|
];
|
|
3584
3702
|
}
|
|
3585
3703
|
function listProjectSessionLogs(dirs) {
|
|
3586
|
-
const present = dirs.filter(({ dir }) =>
|
|
3704
|
+
const present = dirs.filter(({ dir }) => existsSync2(dir));
|
|
3587
3705
|
const first = dirs[0];
|
|
3588
3706
|
if (present.length === 0 && first !== undefined)
|
|
3589
3707
|
listSessionLogs(first.dir);
|
|
@@ -3601,7 +3719,7 @@ function listProjectSessionLogs(dirs) {
|
|
|
3601
3719
|
return { candidates: sortCandidates([...kept.values()]), duplicates };
|
|
3602
3720
|
}
|
|
3603
3721
|
function listSessionLogs(dir, worktree = null) {
|
|
3604
|
-
if (!
|
|
3722
|
+
if (!existsSync2(dir)) {
|
|
3605
3723
|
throw new Error(`effort collect: no session log directory at ${dir}` + " (pass logDir, or run with --no-sessions)");
|
|
3606
3724
|
}
|
|
3607
3725
|
const candidates = [];
|
|
@@ -3688,7 +3806,7 @@ function parseCollectArgs(args) {
|
|
|
3688
3806
|
}
|
|
3689
3807
|
|
|
3690
3808
|
// packages/rafa/src/effort/store/skill-invocations.ts
|
|
3691
|
-
import { existsSync as
|
|
3809
|
+
import { existsSync as existsSync3 } from "fs";
|
|
3692
3810
|
|
|
3693
3811
|
// packages/rafa/src/effort/store/findings.ts
|
|
3694
3812
|
import { randomUUID } from "crypto";
|
|
@@ -3908,21 +4026,71 @@ function invocationOf(row) {
|
|
|
3908
4026
|
}
|
|
3909
4027
|
function readSkillInvocations(repoRoot) {
|
|
3910
4028
|
const path2 = sqliteStorePath(repoRoot);
|
|
3911
|
-
if (!
|
|
4029
|
+
if (!existsSync3(path2))
|
|
3912
4030
|
return [];
|
|
3913
4031
|
const rows = withSqliteStore(path2, "read", false, (db) => db.query(SELECT_ALL).all());
|
|
3914
4032
|
return rows.map(invocationOf);
|
|
3915
4033
|
}
|
|
3916
4034
|
|
|
3917
4035
|
// packages/rafa-effort/src/effort/skill-use.ts
|
|
3918
|
-
import { existsSync as
|
|
3919
|
-
import { dirname as dirname10, join as
|
|
4036
|
+
import { existsSync as existsSync5, readdirSync as readdirSync5 } from "fs";
|
|
4037
|
+
import { dirname as dirname10, join as join22 } from "path";
|
|
4038
|
+
|
|
4039
|
+
// packages/rafa-inventory/src/adapters/learning/bug-fix-push.ts
|
|
4040
|
+
import { readFile as readFile3 } from "fs/promises";
|
|
4041
|
+
import { join as join12 } from "path";
|
|
4042
|
+
|
|
4043
|
+
// packages/rafa-inventory/src/adapters/learning/local.ts
|
|
4044
|
+
import { appendFile, mkdir as mkdir2, readFile as readFile2, rm, writeFile as writeFile2 } from "fs/promises";
|
|
4045
|
+
import { join as join11 } from "path";
|
|
3920
4046
|
|
|
3921
4047
|
// packages/rafa-inventory/src/learning/bless.ts
|
|
4048
|
+
import { createHash as createHash2 } from "crypto";
|
|
4049
|
+
|
|
4050
|
+
// packages/rafa-inventory/src/learning/identity.ts
|
|
3922
4051
|
import { createHash } from "crypto";
|
|
4052
|
+
var GAP = 0.1;
|
|
4053
|
+
var SOURCE_STEP = 0.05;
|
|
4054
|
+
var CONFIDENCE_MIN = 0.3;
|
|
4055
|
+
var CONFIDENCE_MAX = 0.9;
|
|
4056
|
+
var WHITESPACE_RUN = /\s+/g;
|
|
4057
|
+
function actionHash(action) {
|
|
4058
|
+
return createHash("sha256").update(action.trim().toLowerCase()).digest("hex");
|
|
4059
|
+
}
|
|
4060
|
+
function triggerKey(trigger) {
|
|
4061
|
+
return trigger.trim().toLowerCase().replace(WHITESPACE_RUN, " ");
|
|
4062
|
+
}
|
|
4063
|
+
|
|
4064
|
+
// packages/rafa-inventory/src/learning/pool.ts
|
|
3923
4065
|
var HUNDREDTHS = 100;
|
|
4066
|
+
var STEP_H = Math.round(SOURCE_STEP * HUNDREDTHS);
|
|
4067
|
+
var MIN_H = Math.round(CONFIDENCE_MIN * HUNDREDTHS);
|
|
4068
|
+
var MAX_H = Math.round(CONFIDENCE_MAX * HUNDREDTHS);
|
|
4069
|
+
function sourcesOf(record) {
|
|
4070
|
+
return record.sources !== undefined && record.sources.length > 0 ? [...new Set(record.sources)] : [record.id];
|
|
4071
|
+
}
|
|
4072
|
+
function pooledConfidence(ordered) {
|
|
4073
|
+
const seen = new Set;
|
|
4074
|
+
let weighted = 0;
|
|
4075
|
+
for (const member of ordered) {
|
|
4076
|
+
const own = sourcesOf(member);
|
|
4077
|
+
const fresh = own.filter((source) => !seen.has(source));
|
|
4078
|
+
const base = Math.round(member.confidence * HUNDREDTHS) - STEP_H * (own.length - 1);
|
|
4079
|
+
weighted += base * fresh.length;
|
|
4080
|
+
for (const source of fresh) {
|
|
4081
|
+
seen.add(source);
|
|
4082
|
+
}
|
|
4083
|
+
}
|
|
4084
|
+
const sources = [...seen].sort();
|
|
4085
|
+
const stepped = Math.round(weighted / sources.length + STEP_H * (sources.length - 1));
|
|
4086
|
+
const confidence = Math.min(MAX_H, Math.max(MIN_H, stepped)) / HUNDREDTHS;
|
|
4087
|
+
return { sources, confidence };
|
|
4088
|
+
}
|
|
4089
|
+
|
|
4090
|
+
// packages/rafa-inventory/src/learning/groups.ts
|
|
4091
|
+
var HUNDREDTHS2 = 100;
|
|
3924
4092
|
function hundredths(confidence) {
|
|
3925
|
-
return Math.round(confidence *
|
|
4093
|
+
return Math.round(confidence * HUNDREDTHS2);
|
|
3926
4094
|
}
|
|
3927
4095
|
function compareText(left, right) {
|
|
3928
4096
|
if (left < right) {
|
|
@@ -3933,46 +4101,78 @@ function compareText(left, right) {
|
|
|
3933
4101
|
}
|
|
3934
4102
|
return 0;
|
|
3935
4103
|
}
|
|
4104
|
+
function byAge(left, right) {
|
|
4105
|
+
return compareText(left.created_at, right.created_at) || compareText(left.id, right.id);
|
|
4106
|
+
}
|
|
3936
4107
|
function byTrust(left, right) {
|
|
3937
4108
|
return hundredths(right.confidence) - hundredths(left.confidence) || right.usage_count - left.usage_count || compareText(left.id, right.id);
|
|
3938
4109
|
}
|
|
4110
|
+
function byGroupTrust(left, right) {
|
|
4111
|
+
return hundredths(right.confidence) - hundredths(left.confidence) || right.sources.length - left.sources.length || compareText(left.named.id, right.named.id);
|
|
4112
|
+
}
|
|
4113
|
+
function groupOf(hash, records) {
|
|
4114
|
+
const { sources, confidence } = pooledConfidence([...records].sort(byAge));
|
|
4115
|
+
const members = [...records].sort(byTrust);
|
|
4116
|
+
return { action_hash: hash, members, sources, confidence, named: members[0] };
|
|
4117
|
+
}
|
|
4118
|
+
function sameActionGroups(held) {
|
|
4119
|
+
const byAction = new Map;
|
|
4120
|
+
for (const record of held) {
|
|
4121
|
+
if (record.status === "flagged") {
|
|
4122
|
+
continue;
|
|
4123
|
+
}
|
|
4124
|
+
const found = byAction.get(record.action_hash);
|
|
4125
|
+
if (found === undefined) {
|
|
4126
|
+
byAction.set(record.action_hash, [record]);
|
|
4127
|
+
} else {
|
|
4128
|
+
found.push(record);
|
|
4129
|
+
}
|
|
4130
|
+
}
|
|
4131
|
+
return [...byAction].map(([hash, records]) => groupOf(hash, records)).sort(byGroupTrust);
|
|
4132
|
+
}
|
|
4133
|
+
|
|
4134
|
+
// packages/rafa-inventory/src/learning/bless.ts
|
|
4135
|
+
var HUNDREDTHS3 = 100;
|
|
4136
|
+
function hundredths2(confidence) {
|
|
4137
|
+
return Math.round(confidence * HUNDREDTHS3);
|
|
4138
|
+
}
|
|
4139
|
+
function compareText2(left, right) {
|
|
4140
|
+
if (left < right) {
|
|
4141
|
+
return -1;
|
|
4142
|
+
}
|
|
4143
|
+
if (left > right) {
|
|
4144
|
+
return 1;
|
|
4145
|
+
}
|
|
4146
|
+
return 0;
|
|
4147
|
+
}
|
|
4148
|
+
function byTrust2(left, right) {
|
|
4149
|
+
return hundredths2(right.confidence) - hundredths2(left.confidence) || right.usage_count - left.usage_count || compareText2(left.id, right.id);
|
|
4150
|
+
}
|
|
4151
|
+
function isUsable(record) {
|
|
4152
|
+
return record.status === "active" && record.promoted_to === undefined;
|
|
4153
|
+
}
|
|
3939
4154
|
function blessedRecords(held, minConfidence) {
|
|
3940
|
-
const floor =
|
|
3941
|
-
return held.filter((each) => each
|
|
4155
|
+
const floor = hundredths2(minConfidence);
|
|
4156
|
+
return held.filter((each) => isUsable(each) && hundredths2(each.confidence) >= floor).sort(byTrust2);
|
|
3942
4157
|
}
|
|
3943
4158
|
function versionOf(instincts) {
|
|
3944
|
-
return
|
|
4159
|
+
return createHash2("sha256").update(JSON.stringify(instincts)).digest("hex");
|
|
3945
4160
|
}
|
|
3946
4161
|
function bless(held, options) {
|
|
3947
4162
|
const instincts = blessedRecords(held, options.minConfidence);
|
|
3948
4163
|
return { version: versionOf(instincts), instincts };
|
|
3949
4164
|
}
|
|
3950
4165
|
function promotable(held, options) {
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
// packages/rafa-inventory/src/learning/identity.ts
|
|
3954
|
-
import { createHash as createHash2 } from "crypto";
|
|
3955
|
-
var GAP = 0.1;
|
|
3956
|
-
var SOURCE_STEP = 0.05;
|
|
3957
|
-
var CONFIDENCE_MIN = 0.3;
|
|
3958
|
-
var CONFIDENCE_MAX = 0.9;
|
|
3959
|
-
var WHITESPACE_RUN = /\s+/g;
|
|
3960
|
-
function actionHash(action) {
|
|
3961
|
-
return createHash2("sha256").update(action.trim().toLowerCase()).digest("hex");
|
|
3962
|
-
}
|
|
3963
|
-
function triggerKey(trigger) {
|
|
3964
|
-
return trigger.trim().toLowerCase().replace(WHITESPACE_RUN, " ");
|
|
4166
|
+
const floor = hundredths2(options.minConfidence);
|
|
4167
|
+
return sameActionGroups(held.filter(isUsable)).filter((group) => group.sources.length >= options.after && hundredths2(group.confidence) >= floor).map((group) => group.named);
|
|
3965
4168
|
}
|
|
3966
4169
|
// packages/rafa-inventory/src/learning/merge.ts
|
|
3967
|
-
var
|
|
3968
|
-
var GAP_H = Math.round(GAP *
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
var MAX_H = Math.round(CONFIDENCE_MAX * HUNDREDTHS2);
|
|
3972
|
-
function hundredths2(confidence) {
|
|
3973
|
-
return Math.round(confidence * HUNDREDTHS2);
|
|
4170
|
+
var HUNDREDTHS4 = 100;
|
|
4171
|
+
var GAP_H = Math.round(GAP * HUNDREDTHS4);
|
|
4172
|
+
function hundredths3(confidence) {
|
|
4173
|
+
return Math.round(confidence * HUNDREDTHS4);
|
|
3974
4174
|
}
|
|
3975
|
-
function
|
|
4175
|
+
function compareText3(left, right) {
|
|
3976
4176
|
if (left < right) {
|
|
3977
4177
|
return -1;
|
|
3978
4178
|
}
|
|
@@ -3981,14 +4181,11 @@ function compareText2(left, right) {
|
|
|
3981
4181
|
}
|
|
3982
4182
|
return 0;
|
|
3983
4183
|
}
|
|
3984
|
-
function
|
|
3985
|
-
return
|
|
4184
|
+
function byAge2(left, right) {
|
|
4185
|
+
return compareText3(left.created_at, right.created_at) || compareText3(left.id, right.id);
|
|
3986
4186
|
}
|
|
3987
4187
|
function byConfidence(left, right) {
|
|
3988
|
-
return
|
|
3989
|
-
}
|
|
3990
|
-
function sourcesOf(record) {
|
|
3991
|
-
return record.sources !== undefined && record.sources.length > 0 ? [...new Set(record.sources)] : [record.id];
|
|
4188
|
+
return hundredths3(right.confidence) - hundredths3(left.confidence) || compareText3(left.id, right.id);
|
|
3992
4189
|
}
|
|
3993
4190
|
function withSource(record, sourceId) {
|
|
3994
4191
|
const sources = [...new Set([...record.sources ?? [], sourceId])].sort();
|
|
@@ -3999,25 +4196,12 @@ function firstOptional(ordered, key) {
|
|
|
3999
4196
|
return found === undefined ? {} : { [key]: found[key] };
|
|
4000
4197
|
}
|
|
4001
4198
|
function collapse(group) {
|
|
4002
|
-
const ordered = [...[...group.held].sort(
|
|
4199
|
+
const ordered = [...[...group.held].sort(byAge2), ...[...group.incoming].sort(byAge2)];
|
|
4003
4200
|
if (ordered.length === 1) {
|
|
4004
4201
|
return ordered[0];
|
|
4005
4202
|
}
|
|
4006
|
-
const
|
|
4007
|
-
|
|
4008
|
-
for (const member of ordered) {
|
|
4009
|
-
const own = sourcesOf(member);
|
|
4010
|
-
const fresh = own.filter((source) => !seen.has(source));
|
|
4011
|
-
const base = hundredths2(member.confidence) - STEP_H * (own.length - 1);
|
|
4012
|
-
weighted += base * fresh.length;
|
|
4013
|
-
for (const source of fresh) {
|
|
4014
|
-
seen.add(source);
|
|
4015
|
-
}
|
|
4016
|
-
}
|
|
4017
|
-
const sources = [...seen].sort();
|
|
4018
|
-
const stepped = Math.round(weighted / sources.length + STEP_H * (sources.length - 1));
|
|
4019
|
-
const confidence = Math.min(MAX_H, Math.max(MIN_H, stepped)) / HUNDREDTHS2;
|
|
4020
|
-
const byAgeAll = [...ordered].sort(byAge);
|
|
4203
|
+
const { sources, confidence } = pooledConfidence(ordered);
|
|
4204
|
+
const byAgeAll = [...ordered].sort(byAge2);
|
|
4021
4205
|
const lead = byAgeAll[0];
|
|
4022
4206
|
const rest = {};
|
|
4023
4207
|
for (const [key, value] of Object.entries(lead)) {
|
|
@@ -4054,7 +4238,7 @@ function withStatus(record, status) {
|
|
|
4054
4238
|
}
|
|
4055
4239
|
function groupByAction(held, incoming) {
|
|
4056
4240
|
const groups = new Map;
|
|
4057
|
-
const
|
|
4241
|
+
const groupOf2 = (hash) => {
|
|
4058
4242
|
const found = groups.get(hash);
|
|
4059
4243
|
if (found !== undefined) {
|
|
4060
4244
|
return found;
|
|
@@ -4064,10 +4248,10 @@ function groupByAction(held, incoming) {
|
|
|
4064
4248
|
return made;
|
|
4065
4249
|
};
|
|
4066
4250
|
for (const record of held) {
|
|
4067
|
-
|
|
4251
|
+
groupOf2(record.action_hash).held.push(record);
|
|
4068
4252
|
}
|
|
4069
4253
|
for (const record of incoming) {
|
|
4070
|
-
|
|
4254
|
+
groupOf2(record.action_hash).incoming.push(record);
|
|
4071
4255
|
}
|
|
4072
4256
|
return groups;
|
|
4073
4257
|
}
|
|
@@ -4083,11 +4267,11 @@ function settleOne(hash, group, held, now) {
|
|
|
4083
4267
|
return { produced: [record], discarded: [], rules: new Map([[hash, "same-action"]]) };
|
|
4084
4268
|
}
|
|
4085
4269
|
function settleMany(collapsed, held, now) {
|
|
4086
|
-
const leaderH = Math.max(...[...collapsed.values()].map((record) =>
|
|
4270
|
+
const leaderH = Math.max(...[...collapsed.values()].map((record) => hundredths3(record.confidence)));
|
|
4087
4271
|
const kept = new Map;
|
|
4088
4272
|
const discarded = [];
|
|
4089
4273
|
for (const [hash, record] of collapsed) {
|
|
4090
|
-
if (leaderH -
|
|
4274
|
+
if (leaderH - hundredths3(record.confidence) > GAP_H) {
|
|
4091
4275
|
discarded.push(record);
|
|
4092
4276
|
} else {
|
|
4093
4277
|
kept.set(hash, record);
|
|
@@ -4139,83 +4323,6 @@ function merge(held, payload, now) {
|
|
|
4139
4323
|
discarded: keys.flatMap((key) => outcomes.get(key).discarded)
|
|
4140
4324
|
};
|
|
4141
4325
|
}
|
|
4142
|
-
// packages/rafa-inventory/src/adapters/learning/held.ts
|
|
4143
|
-
function compareText3(left, right) {
|
|
4144
|
-
if (left < right) {
|
|
4145
|
-
return -1;
|
|
4146
|
-
}
|
|
4147
|
-
if (left > right) {
|
|
4148
|
-
return 1;
|
|
4149
|
-
}
|
|
4150
|
-
return 0;
|
|
4151
|
-
}
|
|
4152
|
-
function byAge2(left, right) {
|
|
4153
|
-
return compareText3(left.createdAt, right.createdAt) || compareText3(left.id, right.id);
|
|
4154
|
-
}
|
|
4155
|
-
function toHeldRecord(instinct) {
|
|
4156
|
-
return {
|
|
4157
|
-
id: instinct.id,
|
|
4158
|
-
trigger: instinct.trigger,
|
|
4159
|
-
action: instinct.action,
|
|
4160
|
-
action_hash: instinct.actionHash,
|
|
4161
|
-
confidence: instinct.confidence,
|
|
4162
|
-
usage_count: instinct.usageCount,
|
|
4163
|
-
...instinct.sources.length > 0 ? { sources: [...instinct.sources] } : {},
|
|
4164
|
-
...instinct.artifact === null ? {} : { artifact: instinct.artifact },
|
|
4165
|
-
signal: instinct.signal,
|
|
4166
|
-
status: "active",
|
|
4167
|
-
...instinct.promotedTo === null ? {} : { promoted_to: instinct.promotedTo },
|
|
4168
|
-
created_at: instinct.createdAt,
|
|
4169
|
-
updated_at: instinct.updatedAt
|
|
4170
|
-
};
|
|
4171
|
-
}
|
|
4172
|
-
function toHeldRecords(held) {
|
|
4173
|
-
const actions = new Map;
|
|
4174
|
-
for (const instinct of held) {
|
|
4175
|
-
const key = triggerKey(instinct.trigger);
|
|
4176
|
-
actions.set(key, (actions.get(key) ?? new Set).add(instinct.actionHash));
|
|
4177
|
-
}
|
|
4178
|
-
return held.map((instinct) => {
|
|
4179
|
-
const record = toHeldRecord(instinct);
|
|
4180
|
-
return actions.get(triggerKey(instinct.trigger)).size > 1 ? { ...record, status: "flagged" } : record;
|
|
4181
|
-
});
|
|
4182
|
-
}
|
|
4183
|
-
function earliestHeldMember(record, held) {
|
|
4184
|
-
const key = triggerKey(record.trigger);
|
|
4185
|
-
const members = held.filter((instinct) => instinct.actionHash === record.action_hash && triggerKey(instinct.trigger) === key);
|
|
4186
|
-
return [...members].sort(byAge2)[0] ?? null;
|
|
4187
|
-
}
|
|
4188
|
-
function toHeldInstinct(record, held, fallback) {
|
|
4189
|
-
const description = earliestHeldMember(record, held) ?? fallback;
|
|
4190
|
-
if (description === undefined) {
|
|
4191
|
-
return null;
|
|
4192
|
-
}
|
|
4193
|
-
return {
|
|
4194
|
-
id: record.id,
|
|
4195
|
-
trigger: record.trigger,
|
|
4196
|
-
kind: description.kind,
|
|
4197
|
-
domain: description.domain,
|
|
4198
|
-
confidence: record.confidence,
|
|
4199
|
-
usageCount: record.usage_count,
|
|
4200
|
-
sources: [...record.sources ?? []],
|
|
4201
|
-
artifact: record.artifact ?? null,
|
|
4202
|
-
signal: record.signal,
|
|
4203
|
-
scope: description.scope,
|
|
4204
|
-
projectId: description.projectId,
|
|
4205
|
-
source: description.source,
|
|
4206
|
-
evidence: [...description.evidence],
|
|
4207
|
-
promotedTo: record.promoted_to ?? null,
|
|
4208
|
-
createdAt: record.created_at,
|
|
4209
|
-
updatedAt: record.updated_at,
|
|
4210
|
-
action: record.action,
|
|
4211
|
-
cause: description.cause,
|
|
4212
|
-
actionHash: actionHash(record.action)
|
|
4213
|
-
};
|
|
4214
|
-
}
|
|
4215
|
-
// packages/rafa-inventory/src/adapters/learning/local.ts
|
|
4216
|
-
import { appendFile, mkdir as mkdir2, readFile as readFile2, rm, writeFile as writeFile2 } from "fs/promises";
|
|
4217
|
-
import { join as join11 } from "path";
|
|
4218
|
-
|
|
4219
4326
|
// packages/rafa/src/schema/frontmatter.ts
|
|
4220
4327
|
var FRONTMATTER_FENCE = "---";
|
|
4221
4328
|
var FRONTMATTER_INDENT = 2;
|
|
@@ -4898,14 +5005,127 @@ function readScope(scope, dir) {
|
|
|
4898
5005
|
records: recordFiles(dir).map((name) => readRecord(join10(dir, name), scope, recordId(name)))
|
|
4899
5006
|
};
|
|
4900
5007
|
}
|
|
4901
|
-
function readScopes(seams) {
|
|
4902
|
-
return resolveInstinctScopes(seams).map((location) => readScope(location.scope, location.dir));
|
|
4903
|
-
}
|
|
5008
|
+
function readScopes(seams) {
|
|
5009
|
+
return resolveInstinctScopes(seams).map((location) => readScope(location.scope, location.dir));
|
|
5010
|
+
}
|
|
5011
|
+
|
|
5012
|
+
// packages/rafa-inventory/src/adapters/learning/group-rule.ts
|
|
5013
|
+
var GROUPABLE = new Set(["new-trigger", "same-action"]);
|
|
5014
|
+
function withStatus2(record, status) {
|
|
5015
|
+
return record.status === status ? record : { ...record, status };
|
|
5016
|
+
}
|
|
5017
|
+
function heldAfterPush(before, result) {
|
|
5018
|
+
const touched = new Set(result.decisions.map((decision) => triggerKey(decision.incoming.trigger)));
|
|
5019
|
+
const produced = new Map;
|
|
5020
|
+
for (const record of result.decisions.flatMap((decision) => decision.produced)) {
|
|
5021
|
+
produced.set(record.id, record);
|
|
5022
|
+
}
|
|
5023
|
+
const held = [
|
|
5024
|
+
...before.filter((record) => !touched.has(triggerKey(record.trigger))),
|
|
5025
|
+
...produced.values()
|
|
5026
|
+
];
|
|
5027
|
+
const actions = new Map;
|
|
5028
|
+
for (const record of held) {
|
|
5029
|
+
const key = triggerKey(record.trigger);
|
|
5030
|
+
actions.set(key, (actions.get(key) ?? new Set).add(record.action_hash));
|
|
5031
|
+
}
|
|
5032
|
+
return held.map((record) => withStatus2(record, actions.get(triggerKey(record.trigger)).size > 1 ? "flagged" : "active"));
|
|
5033
|
+
}
|
|
5034
|
+
function loggedRule(decision, after) {
|
|
5035
|
+
if (!GROUPABLE.has(decision.rule)) {
|
|
5036
|
+
return decision.rule;
|
|
5037
|
+
}
|
|
5038
|
+
const hash = decision.incoming.action_hash;
|
|
5039
|
+
const own = decision.produced.find((record) => record.action_hash === hash);
|
|
5040
|
+
if (own === undefined) {
|
|
5041
|
+
return decision.rule;
|
|
5042
|
+
}
|
|
5043
|
+
const [group] = sameActionGroups(after.filter((record) => record.action_hash === hash));
|
|
5044
|
+
if (group === undefined || !group.members.some((member) => member.id === own.id)) {
|
|
5045
|
+
return decision.rule;
|
|
5046
|
+
}
|
|
5047
|
+
const key = triggerKey(own.trigger);
|
|
5048
|
+
return group.members.some((member) => triggerKey(member.trigger) !== key) ? "same-action-group" : decision.rule;
|
|
5049
|
+
}
|
|
5050
|
+
|
|
5051
|
+
// packages/rafa-inventory/src/adapters/learning/held.ts
|
|
5052
|
+
function compareText4(left, right) {
|
|
5053
|
+
if (left < right) {
|
|
5054
|
+
return -1;
|
|
5055
|
+
}
|
|
5056
|
+
if (left > right) {
|
|
5057
|
+
return 1;
|
|
5058
|
+
}
|
|
5059
|
+
return 0;
|
|
5060
|
+
}
|
|
5061
|
+
function byAge3(left, right) {
|
|
5062
|
+
return compareText4(left.createdAt, right.createdAt) || compareText4(left.id, right.id);
|
|
5063
|
+
}
|
|
5064
|
+
function toHeldRecord(instinct) {
|
|
5065
|
+
return {
|
|
5066
|
+
id: instinct.id,
|
|
5067
|
+
trigger: instinct.trigger,
|
|
5068
|
+
action: instinct.action,
|
|
5069
|
+
action_hash: instinct.actionHash,
|
|
5070
|
+
confidence: instinct.confidence,
|
|
5071
|
+
usage_count: instinct.usageCount,
|
|
5072
|
+
...instinct.sources.length > 0 ? { sources: [...instinct.sources] } : {},
|
|
5073
|
+
...instinct.artifact === null ? {} : { artifact: instinct.artifact },
|
|
5074
|
+
signal: instinct.signal,
|
|
5075
|
+
status: "active",
|
|
5076
|
+
...instinct.promotedTo === null ? {} : { promoted_to: instinct.promotedTo },
|
|
5077
|
+
created_at: instinct.createdAt,
|
|
5078
|
+
updated_at: instinct.updatedAt
|
|
5079
|
+
};
|
|
5080
|
+
}
|
|
5081
|
+
function toHeldRecords(held) {
|
|
5082
|
+
const actions = new Map;
|
|
5083
|
+
for (const instinct of held) {
|
|
5084
|
+
const key = triggerKey(instinct.trigger);
|
|
5085
|
+
actions.set(key, (actions.get(key) ?? new Set).add(instinct.actionHash));
|
|
5086
|
+
}
|
|
5087
|
+
return held.map((instinct) => {
|
|
5088
|
+
const record = toHeldRecord(instinct);
|
|
5089
|
+
return actions.get(triggerKey(instinct.trigger)).size > 1 ? { ...record, status: "flagged" } : record;
|
|
5090
|
+
});
|
|
5091
|
+
}
|
|
5092
|
+
function earliestHeldMember(record, held) {
|
|
5093
|
+
const key = triggerKey(record.trigger);
|
|
5094
|
+
const members = held.filter((instinct) => instinct.actionHash === record.action_hash && triggerKey(instinct.trigger) === key);
|
|
5095
|
+
return [...members].sort(byAge3)[0] ?? null;
|
|
5096
|
+
}
|
|
5097
|
+
function toHeldInstinct(record, held, fallback) {
|
|
5098
|
+
const description = earliestHeldMember(record, held) ?? fallback;
|
|
5099
|
+
if (description === undefined) {
|
|
5100
|
+
return null;
|
|
5101
|
+
}
|
|
5102
|
+
return {
|
|
5103
|
+
id: record.id,
|
|
5104
|
+
trigger: record.trigger,
|
|
5105
|
+
kind: description.kind,
|
|
5106
|
+
domain: description.domain,
|
|
5107
|
+
confidence: record.confidence,
|
|
5108
|
+
usageCount: record.usage_count,
|
|
5109
|
+
sources: [...record.sources ?? []],
|
|
5110
|
+
artifact: record.artifact ?? null,
|
|
5111
|
+
signal: record.signal,
|
|
5112
|
+
scope: description.scope,
|
|
5113
|
+
projectId: description.projectId,
|
|
5114
|
+
source: description.source,
|
|
5115
|
+
evidence: [...description.evidence],
|
|
5116
|
+
promotedTo: record.promoted_to ?? null,
|
|
5117
|
+
createdAt: record.created_at,
|
|
5118
|
+
updatedAt: record.updated_at,
|
|
5119
|
+
action: record.action,
|
|
5120
|
+
cause: description.cause,
|
|
5121
|
+
actionHash: actionHash(record.action)
|
|
5122
|
+
};
|
|
5123
|
+
}
|
|
4904
5124
|
|
|
4905
5125
|
// packages/rafa-inventory/src/adapters/learning/local.ts
|
|
4906
5126
|
var PREFIX3 = "local learning";
|
|
4907
5127
|
var PUSH_REFUSAL = `${PREFIX3}: refused to store a push`;
|
|
4908
|
-
var
|
|
5128
|
+
var PUSH_LOG_FILE = "instincts.ndjson";
|
|
4909
5129
|
var FLAGS_FILE = "flags.ndjson";
|
|
4910
5130
|
var RECORD_EXTENSION = ".md";
|
|
4911
5131
|
var MIN_CONFIDENCE = 0.3;
|
|
@@ -5073,7 +5293,7 @@ function userAdditions(userBlessed, projectHeld, flagged) {
|
|
|
5073
5293
|
const heldIds = new Set(projectHeld.map((record) => record.id));
|
|
5074
5294
|
return unflagged(userBlessed, flagged).filter((record) => !heldTriggers.has(triggerKey(record.trigger)) && !heldIds.has(record.id));
|
|
5075
5295
|
}
|
|
5076
|
-
function
|
|
5296
|
+
function byAge4(left, right) {
|
|
5077
5297
|
if (left.created_at !== right.created_at) {
|
|
5078
5298
|
return left.created_at < right.created_at ? -1 : 1;
|
|
5079
5299
|
}
|
|
@@ -5084,7 +5304,7 @@ function byAge3(left, right) {
|
|
|
5084
5304
|
function payloadDescription(record, described) {
|
|
5085
5305
|
const key = triggerKey(record.trigger);
|
|
5086
5306
|
const members = described.filter((candidate) => candidate.description !== undefined && candidate.action_hash === record.action_hash && triggerKey(candidate.trigger) === key);
|
|
5087
|
-
return [...members].sort(
|
|
5307
|
+
return [...members].sort(byAge4)[0]?.description;
|
|
5088
5308
|
}
|
|
5089
5309
|
function producedRecords(result) {
|
|
5090
5310
|
const byId = new Map;
|
|
@@ -5129,17 +5349,18 @@ function heldChanges(dir, held, result, described) {
|
|
|
5129
5349
|
const removals = held.files.filter((file) => touched.has(triggerKey(file.instinct.trigger)) && !kept.has(file.path)).map((file) => file.path);
|
|
5130
5350
|
return { writes, removals };
|
|
5131
5351
|
}
|
|
5132
|
-
function pushLogLines(sourceId, described, result) {
|
|
5352
|
+
function pushLogLines(sourceId, described, result, before, logLine) {
|
|
5353
|
+
const after = heldAfterPush(before, result);
|
|
5133
5354
|
return result.decisions.map((decision, index) => {
|
|
5134
5355
|
const key = triggerKey(decision.incoming.trigger);
|
|
5135
5356
|
const line = {
|
|
5136
5357
|
source_id: sourceId,
|
|
5137
|
-
rule: decision
|
|
5358
|
+
rule: loggedRule(decision, after),
|
|
5138
5359
|
incoming: loggedIncoming(described[index]),
|
|
5139
5360
|
produced: decision.produced.map((record) => record.id),
|
|
5140
5361
|
discarded: result.discarded.filter((record) => triggerKey(record.trigger) === key).map((record) => record.id)
|
|
5141
5362
|
};
|
|
5142
|
-
return JSON.stringify(line);
|
|
5363
|
+
return JSON.stringify(logLine(line, index));
|
|
5143
5364
|
});
|
|
5144
5365
|
}
|
|
5145
5366
|
function localInstinctsDir(repoRoot) {
|
|
@@ -5153,7 +5374,8 @@ function createLocalLearning(options) {
|
|
|
5153
5374
|
const userDir = userInstinctsDir(options.home);
|
|
5154
5375
|
const now = options.now ?? (() => new Date().toISOString());
|
|
5155
5376
|
const warn = options.warn ?? warnThroughActiveOutput2;
|
|
5156
|
-
const
|
|
5377
|
+
const logLine = options.logLine ?? ((line) => line);
|
|
5378
|
+
const instinctsPath = join11(instinctsDir, PUSH_LOG_FILE);
|
|
5157
5379
|
const flagsPath = join11(instinctsDir, FLAGS_FILE);
|
|
5158
5380
|
function readHeld(scope, dir) {
|
|
5159
5381
|
const { records } = readScope(scope, dir);
|
|
@@ -5193,9 +5415,10 @@ function createLocalLearning(options) {
|
|
|
5193
5415
|
}
|
|
5194
5416
|
const described = payload.instincts;
|
|
5195
5417
|
const held = heldSet();
|
|
5196
|
-
const
|
|
5418
|
+
const before = toHeldRecords(held.files.map((file) => file.instinct));
|
|
5419
|
+
const result = merge(before, { source_id: payload.source_id, instincts: described.map(copyInstinct) }, now());
|
|
5197
5420
|
const changes = heldChanges(instinctsDir, held, result, described);
|
|
5198
|
-
const lines = pushLogLines(payload.source_id, described, result);
|
|
5421
|
+
const lines = pushLogLines(payload.source_id, described, result, before, logLine);
|
|
5199
5422
|
if (lines.length > 0) {
|
|
5200
5423
|
await mkdir2(instinctsDir, { recursive: true });
|
|
5201
5424
|
await appendLines(instinctsPath, lines);
|
|
@@ -5229,25 +5452,121 @@ function createLocalLearning(options) {
|
|
|
5229
5452
|
};
|
|
5230
5453
|
return Object.freeze(learning);
|
|
5231
5454
|
}
|
|
5455
|
+
|
|
5456
|
+
// packages/rafa-inventory/src/adapters/learning/bug-fix-push.ts
|
|
5457
|
+
var BUG_FIX_PAIR_RULE = "bug-fix-pair";
|
|
5458
|
+
function bugFixPairKey(pair) {
|
|
5459
|
+
const { trackerRef, sessionId } = pair.bug;
|
|
5460
|
+
return { ref: trackerRef.url ?? `${trackerRef.kind}:${trackerRef.externalId}`, filed_by: sessionId };
|
|
5461
|
+
}
|
|
5462
|
+
function keyText(key) {
|
|
5463
|
+
return JSON.stringify([key.ref, key.filed_by]);
|
|
5464
|
+
}
|
|
5465
|
+
function hasCode3(error, code) {
|
|
5466
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === code;
|
|
5467
|
+
}
|
|
5468
|
+
function loggedKey(line) {
|
|
5469
|
+
let value;
|
|
5470
|
+
try {
|
|
5471
|
+
value = JSON.parse(line);
|
|
5472
|
+
} catch {
|
|
5473
|
+
return null;
|
|
5474
|
+
}
|
|
5475
|
+
if (!isMapping(value) || value.rule !== BUG_FIX_PAIR_RULE || !isMapping(value.pair))
|
|
5476
|
+
return null;
|
|
5477
|
+
const { ref, filed_by: filedBy } = value.pair;
|
|
5478
|
+
return typeof ref === "string" && typeof filedBy === "string" ? { ref, filed_by: filedBy } : null;
|
|
5479
|
+
}
|
|
5480
|
+
async function readLoggedPairs(dir) {
|
|
5481
|
+
let contents;
|
|
5482
|
+
try {
|
|
5483
|
+
contents = await readFile3(join12(dir, PUSH_LOG_FILE), "utf8");
|
|
5484
|
+
} catch (error) {
|
|
5485
|
+
if (hasCode3(error, "ENOENT"))
|
|
5486
|
+
return [];
|
|
5487
|
+
throw error;
|
|
5488
|
+
}
|
|
5489
|
+
const keys = new Map;
|
|
5490
|
+
for (const line of contents.split(`
|
|
5491
|
+
`)) {
|
|
5492
|
+
const key = line === "" ? null : loggedKey(line);
|
|
5493
|
+
if (key !== null && !keys.has(keyText(key)))
|
|
5494
|
+
keys.set(keyText(key), key);
|
|
5495
|
+
}
|
|
5496
|
+
return [...keys.values()];
|
|
5497
|
+
}
|
|
5498
|
+
function byFixingSession(pairs) {
|
|
5499
|
+
const groups = new Map;
|
|
5500
|
+
for (const pair of pairs) {
|
|
5501
|
+
const group = groups.get(pair.fix.sessionId);
|
|
5502
|
+
if (group === undefined)
|
|
5503
|
+
groups.set(pair.fix.sessionId, [pair]);
|
|
5504
|
+
else
|
|
5505
|
+
group.push(pair);
|
|
5506
|
+
}
|
|
5507
|
+
return [...groups.values()];
|
|
5508
|
+
}
|
|
5509
|
+
function problemLine(pair, refusal) {
|
|
5510
|
+
const key = bugFixPairKey(pair);
|
|
5511
|
+
return `bug-fix pair ${key.ref} filed by ${key.filed_by} was not pushed: ${refusal}`;
|
|
5512
|
+
}
|
|
5513
|
+
async function pushGroup(options, group, now) {
|
|
5514
|
+
const keys = group.map(bugFixPairKey);
|
|
5515
|
+
const learning = createLocalLearning({
|
|
5516
|
+
...options,
|
|
5517
|
+
now: () => now,
|
|
5518
|
+
logLine: (line, index) => ({ ...line, rule: BUG_FIX_PAIR_RULE, pair: keys[index] })
|
|
5519
|
+
});
|
|
5520
|
+
try {
|
|
5521
|
+
await learning.push({ source_id: group[0].fix.sessionId, instincts: group.map((pair) => pair.lesson) });
|
|
5522
|
+
return null;
|
|
5523
|
+
} catch (error) {
|
|
5524
|
+
return messageOf(error);
|
|
5525
|
+
}
|
|
5526
|
+
}
|
|
5527
|
+
async function pushBugFixPairs(options, pairs, now) {
|
|
5528
|
+
const logged = new Set((await readLoggedPairs(options.instinctsDir)).map(keyText));
|
|
5529
|
+
const isLogged = (pair) => logged.has(keyText(bugFixPairKey(pair)));
|
|
5530
|
+
const stamp2 = now.toISOString();
|
|
5531
|
+
const pushed = [];
|
|
5532
|
+
const problems = [];
|
|
5533
|
+
for (const group of byFixingSession(pairs.filter((pair) => !isLogged(pair)))) {
|
|
5534
|
+
const refusal = await pushGroup(options, group, stamp2);
|
|
5535
|
+
if (refusal === null) {
|
|
5536
|
+
pushed.push(...group);
|
|
5537
|
+
} else if (group.length === 1) {
|
|
5538
|
+
problems.push(problemLine(group[0], refusal));
|
|
5539
|
+
} else {
|
|
5540
|
+
for (const pair of group) {
|
|
5541
|
+
const alone = await pushGroup(options, [pair], stamp2);
|
|
5542
|
+
if (alone === null)
|
|
5543
|
+
pushed.push(pair);
|
|
5544
|
+
else
|
|
5545
|
+
problems.push(problemLine(pair, alone));
|
|
5546
|
+
}
|
|
5547
|
+
}
|
|
5548
|
+
}
|
|
5549
|
+
return { pushed, skipped: pairs.filter(isLogged), problems };
|
|
5550
|
+
}
|
|
5232
5551
|
// packages/rafa-inventory/src/agents/roster.ts
|
|
5233
5552
|
import { readdirSync as readdirSync4, readFileSync as readFileSync12, statSync as statSync6 } from "fs";
|
|
5234
|
-
import { join as
|
|
5553
|
+
import { join as join16 } from "path";
|
|
5235
5554
|
|
|
5236
5555
|
// packages/rafa/src/utils/agent-definition.ts
|
|
5237
5556
|
import { readFileSync as readFileSync7 } from "fs";
|
|
5238
|
-
import { join as
|
|
5239
|
-
var AGENT_DEFINITION_DIR =
|
|
5557
|
+
import { join as join13 } from "path";
|
|
5558
|
+
var AGENT_DEFINITION_DIR = join13(".claude", "agents");
|
|
5240
5559
|
function agentDefinitionCandidates(name, roots, settingSources) {
|
|
5241
5560
|
if (!isAgentName(name))
|
|
5242
5561
|
return [];
|
|
5243
5562
|
const file = `${name}.md`;
|
|
5244
5563
|
const project = {
|
|
5245
5564
|
scope: "project",
|
|
5246
|
-
path:
|
|
5565
|
+
path: join13(roots.repoRoot, AGENT_DEFINITION_DIR, file)
|
|
5247
5566
|
};
|
|
5248
5567
|
if (!settingSources.includes("user"))
|
|
5249
5568
|
return [project];
|
|
5250
|
-
return [project, { scope: "user", path:
|
|
5569
|
+
return [project, { scope: "user", path: join13(roots.home, AGENT_DEFINITION_DIR, file) }];
|
|
5251
5570
|
}
|
|
5252
5571
|
function readText(path2) {
|
|
5253
5572
|
try {
|
|
@@ -5280,7 +5599,7 @@ function agentEffortLookup(roots, settingSources) {
|
|
|
5280
5599
|
|
|
5281
5600
|
// packages/rafa-inventory/src/inventory/trees.ts
|
|
5282
5601
|
import { readFileSync as readFileSync9 } from "fs";
|
|
5283
|
-
import { dirname as dirname6, join as
|
|
5602
|
+
import { dirname as dirname6, join as join14, relative as relative3 } from "path";
|
|
5284
5603
|
|
|
5285
5604
|
// packages/rafa-inventory/src/check/run.ts
|
|
5286
5605
|
import { readFileSync as readFileSync8, writeFileSync as writeFileSync3 } from "fs";
|
|
@@ -5826,7 +6145,7 @@ function checkSkillFrontmatter(data) {
|
|
|
5826
6145
|
}
|
|
5827
6146
|
|
|
5828
6147
|
// packages/rafa-inventory/src/check/references.ts
|
|
5829
|
-
import { existsSync as
|
|
6148
|
+
import { existsSync as existsSync4, statSync as statSync5 } from "fs";
|
|
5830
6149
|
import { delimiter, isAbsolute, relative as relative2, resolve as resolve3 } from "path";
|
|
5831
6150
|
|
|
5832
6151
|
// packages/rafa-inventory/src/check/shell-lines.ts
|
|
@@ -6169,7 +6488,7 @@ function issueOf2(code, ref, sentence) {
|
|
|
6169
6488
|
};
|
|
6170
6489
|
}
|
|
6171
6490
|
function scriptIssue(ref, skillDir) {
|
|
6172
|
-
if (
|
|
6491
|
+
if (existsSync4(resolve3(skillDir, ref.text)))
|
|
6173
6492
|
return null;
|
|
6174
6493
|
return issueOf2("missing-script", ref, `${ref.text} names nothing under the skill directory`);
|
|
6175
6494
|
}
|
|
@@ -6177,17 +6496,17 @@ function isSkillPath(token, skillDir) {
|
|
|
6177
6496
|
const target = resolve3(skillDir, token);
|
|
6178
6497
|
if (!isInside(skillDir, target))
|
|
6179
6498
|
return false;
|
|
6180
|
-
if (
|
|
6499
|
+
if (existsSync4(target))
|
|
6181
6500
|
return true;
|
|
6182
6501
|
const head = token.split("/")[0] ?? "";
|
|
6183
|
-
return head !== "" && head !== "." && head !== ".." &&
|
|
6502
|
+
return head !== "" && head !== "." && head !== ".." && existsSync4(resolve3(skillDir, head));
|
|
6184
6503
|
}
|
|
6185
6504
|
function projectPathIssue(ref, projectRoot) {
|
|
6186
6505
|
const target = resolve3(projectRoot, ref.text);
|
|
6187
6506
|
if (!isInside(projectRoot, target)) {
|
|
6188
6507
|
return issueOf2("unresolved-path", ref, `${ref.text} points outside the project root`);
|
|
6189
6508
|
}
|
|
6190
|
-
if (
|
|
6509
|
+
if (existsSync4(target))
|
|
6191
6510
|
return null;
|
|
6192
6511
|
return issueOf2("unresolved-path", ref, `${ref.text} names nothing under the project root`);
|
|
6193
6512
|
}
|
|
@@ -6207,10 +6526,10 @@ function isSystemPath(token) {
|
|
|
6207
6526
|
function absoluteIssue(ref, seams) {
|
|
6208
6527
|
const { projectRoot, skillDir } = seams;
|
|
6209
6528
|
if (skillDir !== null && isInside(skillDir, ref.text)) {
|
|
6210
|
-
return
|
|
6529
|
+
return existsSync4(ref.text) ? null : issueOf2("missing-script", ref, `${ref.text} names nothing under the skill directory`);
|
|
6211
6530
|
}
|
|
6212
6531
|
if (projectRoot !== null && isInside(projectRoot, ref.text)) {
|
|
6213
|
-
return
|
|
6532
|
+
return existsSync4(ref.text) ? null : issueOf2("unresolved-path", ref, `${ref.text} names nothing under the project root`);
|
|
6214
6533
|
}
|
|
6215
6534
|
if (HOME_ROOTS.some((root) => ref.text.startsWith(root))) {
|
|
6216
6535
|
return issueOf2("home-path", ref, `${ref.text} is one machine home directory, outside both the project` + " and the skill directory");
|
|
@@ -6546,16 +6865,16 @@ function checkVerdict(issues) {
|
|
|
6546
6865
|
}
|
|
6547
6866
|
|
|
6548
6867
|
// packages/rafa-inventory/src/inventory/trees.ts
|
|
6549
|
-
var BUNDLED_AGENTS_DIR =
|
|
6868
|
+
var BUNDLED_AGENTS_DIR = join14("bundled", "agents");
|
|
6550
6869
|
function bundledAgentsDirectory(entry) {
|
|
6551
|
-
return
|
|
6870
|
+
return join14(dirname6(realEntry(entry ?? Bun.main)), BUNDLED_AGENTS_DIR);
|
|
6552
6871
|
}
|
|
6553
6872
|
function agentTreeDirectory(tier, seams) {
|
|
6554
6873
|
if (tier === "user")
|
|
6555
|
-
return
|
|
6874
|
+
return join14(seams.home, AGENT_DEFINITION_DIR);
|
|
6556
6875
|
if (tier === "rafa")
|
|
6557
6876
|
return bundledAgentsDirectory(seams.entry);
|
|
6558
|
-
return seams.projectRoot === null ? null :
|
|
6877
|
+
return seams.projectRoot === null ? null : join14(seams.projectRoot, AGENT_DEFINITION_DIR);
|
|
6559
6878
|
}
|
|
6560
6879
|
function readText2(path2) {
|
|
6561
6880
|
try {
|
|
@@ -6770,7 +7089,7 @@ function findTierItem(resolution, kind, name) {
|
|
|
6770
7089
|
|
|
6771
7090
|
// packages/rafa-inventory/src/tiers/serve.ts
|
|
6772
7091
|
import { cpSync, mkdirSync as mkdirSync2, readFileSync as readFileSync11, rmSync, writeFileSync as writeFileSync4 } from "fs";
|
|
6773
|
-
import { basename as basename3, dirname as dirname7, join as
|
|
7092
|
+
import { basename as basename3, dirname as dirname7, join as join15 } from "path";
|
|
6774
7093
|
|
|
6775
7094
|
// packages/rafa-inventory/src/tiers/delivery.ts
|
|
6776
7095
|
var SKILL_DELIVERY = "add-dir";
|
|
@@ -6781,7 +7100,7 @@ var SERVED_AGENTS_FILE = "agents.json";
|
|
|
6781
7100
|
var SERVED_PLUGIN_NAME = "rafa";
|
|
6782
7101
|
var SKILL_FILE2 = "SKILL.md";
|
|
6783
7102
|
var SERVED_SKILLS_PATH = {
|
|
6784
|
-
"add-dir":
|
|
7103
|
+
"add-dir": join15(".claude", "skills"),
|
|
6785
7104
|
"plugin-dir": "skills"
|
|
6786
7105
|
};
|
|
6787
7106
|
var SKILL_DELIVERY_FLAG = {
|
|
@@ -6792,7 +7111,7 @@ function servedDirectory(root, run) {
|
|
|
6792
7111
|
if (!isSessionId(run)) {
|
|
6793
7112
|
throw new Error(`served directory: unusable run id ${JSON.stringify(run)}`);
|
|
6794
7113
|
}
|
|
6795
|
-
return
|
|
7114
|
+
return join15(runsDir(root), run, SERVED_DIR);
|
|
6796
7115
|
}
|
|
6797
7116
|
function rafaWinners(resolution) {
|
|
6798
7117
|
return resolution.items.flatMap((item) => item.state === "served" && item.winner.source === "rafa" ? [item] : []);
|
|
@@ -6862,15 +7181,15 @@ function admit(row) {
|
|
|
6862
7181
|
return block.ok ? read : block;
|
|
6863
7182
|
}
|
|
6864
7183
|
function copySkill(row, skills) {
|
|
6865
|
-
const to =
|
|
7184
|
+
const to = join15(skills, row.name);
|
|
6866
7185
|
cpSync(dirname7(row.path), to, { recursive: true, dereference: true });
|
|
6867
7186
|
return { kind: "skill", name: row.name, from: row.path, to };
|
|
6868
7187
|
}
|
|
6869
7188
|
function writePluginManifest(dir) {
|
|
6870
|
-
const manifestDir =
|
|
7189
|
+
const manifestDir = join15(dir, ".claude-plugin");
|
|
6871
7190
|
mkdirSync2(manifestDir, { recursive: true });
|
|
6872
7191
|
const manifest = { name: SERVED_PLUGIN_NAME, description: "rafa-tier skills served to one loop session" };
|
|
6873
|
-
writeFileSync4(
|
|
7192
|
+
writeFileSync4(join15(manifestDir, "plugin.json"), `${JSON.stringify(manifest, null, 2)}
|
|
6874
7193
|
`);
|
|
6875
7194
|
}
|
|
6876
7195
|
function servedFlags(dir, delivery, skillCount, agents) {
|
|
@@ -6890,11 +7209,11 @@ function serveResolution(resolution, options) {
|
|
|
6890
7209
|
rmSync(dir, { recursive: true, force: true });
|
|
6891
7210
|
mkdirSync2(dir, { recursive: true });
|
|
6892
7211
|
const judged2 = rafaWinners(resolution).map((item) => ({ row: item.winner, verdict: serveVerdict(item.winner) }));
|
|
6893
|
-
const skillsDir =
|
|
7212
|
+
const skillsDir = join15(dir, SERVED_SKILLS_PATH[delivery]);
|
|
6894
7213
|
const skills = judged2.flatMap(({ row, verdict }) => verdict.ok && row.kind === "skill" ? [copySkill(row, skillsDir)] : []);
|
|
6895
7214
|
if (skills.length > 0 && delivery === "plugin-dir")
|
|
6896
7215
|
writePluginManifest(dir);
|
|
6897
|
-
const agentsFile =
|
|
7216
|
+
const agentsFile = join15(dir, SERVED_AGENTS_FILE);
|
|
6898
7217
|
const admitted = judged2.flatMap(({ row, verdict }) => verdict.ok && verdict.value !== null ? [{ row, definition: verdict.value }] : []);
|
|
6899
7218
|
const agentMap = Object.fromEntries(admitted.map(({ row, definition }) => [row.name, definition]));
|
|
6900
7219
|
if (admitted.length > 0)
|
|
@@ -6931,7 +7250,7 @@ function isFileEntry(dir, entry) {
|
|
|
6931
7250
|
return true;
|
|
6932
7251
|
if (!entry.isSymbolicLink())
|
|
6933
7252
|
return false;
|
|
6934
|
-
return statSync6(
|
|
7253
|
+
return statSync6(join16(dir, entry.name), { throwIfNoEntry: false })?.isFile() === true;
|
|
6935
7254
|
}
|
|
6936
7255
|
function markdownFiles(dir) {
|
|
6937
7256
|
let entries;
|
|
@@ -6952,7 +7271,7 @@ function definitionName(text) {
|
|
|
6952
7271
|
function readAgentDirectory(dir) {
|
|
6953
7272
|
const found = [];
|
|
6954
7273
|
for (const file of markdownFiles(dir)) {
|
|
6955
|
-
const path2 =
|
|
7274
|
+
const path2 = join16(dir, file);
|
|
6956
7275
|
const text = readText3(path2);
|
|
6957
7276
|
if (text === null)
|
|
6958
7277
|
continue;
|
|
@@ -7118,11 +7437,11 @@ function unresolvedSkillLine(unresolved) {
|
|
|
7118
7437
|
return `skill "${unresolved.name}" (${linesClause(unresolved.lines)}) cannot be served: ${unresolved.message}`;
|
|
7119
7438
|
}
|
|
7120
7439
|
// packages/rafa-inventory/src/backfill/backup.ts
|
|
7121
|
-
import { dirname as dirname8, isAbsolute as isAbsolute2, join as
|
|
7440
|
+
import { dirname as dirname8, isAbsolute as isAbsolute2, join as join18, relative as relative4, resolve as resolve4, sep } from "path";
|
|
7122
7441
|
|
|
7123
7442
|
// packages/rafa-inventory/src/backfill/proposal-file.ts
|
|
7124
|
-
import { join as
|
|
7125
|
-
var BACKFILL_PATH =
|
|
7443
|
+
import { join as join17 } from "path";
|
|
7444
|
+
var BACKFILL_PATH = join17(".rafa", "backfill");
|
|
7126
7445
|
var PROPOSAL_FILE_HEADER = [
|
|
7127
7446
|
"# Backfill proposals: one row per skill, written by one session.",
|
|
7128
7447
|
"#",
|
|
@@ -7139,7 +7458,7 @@ var PROPOSAL_FILE_HEADER = [
|
|
|
7139
7458
|
`);
|
|
7140
7459
|
|
|
7141
7460
|
// packages/rafa-inventory/src/backfill/backup.ts
|
|
7142
|
-
var BACKUP_PATH =
|
|
7461
|
+
var BACKUP_PATH = join18(BACKFILL_PATH, "backup");
|
|
7143
7462
|
// packages/rafa-inventory/src/demote/classify.ts
|
|
7144
7463
|
var RULE_VERDICTS = Object.freeze({
|
|
7145
7464
|
"no-frontmatter": "unclassified",
|
|
@@ -7197,18 +7516,18 @@ var DEFAULT_APPLY_SEAMS = Object.freeze({
|
|
|
7197
7516
|
pathDirs: []
|
|
7198
7517
|
});
|
|
7199
7518
|
// packages/rafa-inventory/src/demote/select.ts
|
|
7200
|
-
import { basename as basename4, dirname as dirname9, join as
|
|
7201
|
-
var DEMOTED_PATH =
|
|
7202
|
-
var INSTINCTS_PATH =
|
|
7519
|
+
import { basename as basename4, dirname as dirname9, join as join19 } from "path";
|
|
7520
|
+
var DEMOTED_PATH = join19(".rafa", "demoted");
|
|
7521
|
+
var INSTINCTS_PATH = join19(".rafa", "instincts");
|
|
7203
7522
|
// packages/rafa-inventory/src/inventory/disabled.ts
|
|
7204
|
-
import { join as
|
|
7523
|
+
import { join as join20 } from "path";
|
|
7205
7524
|
var SCOPE_FILES = {
|
|
7206
|
-
local:
|
|
7207
|
-
project:
|
|
7208
|
-
user:
|
|
7525
|
+
local: join20(".claude", "settings.local.json"),
|
|
7526
|
+
project: join20(".claude", "settings.json"),
|
|
7527
|
+
user: join20(".claude", "settings.json")
|
|
7209
7528
|
};
|
|
7210
7529
|
// packages/rafa-inventory/src/inventory/plugins.ts
|
|
7211
|
-
import { isAbsolute as isAbsolute3, join as
|
|
7530
|
+
import { isAbsolute as isAbsolute3, join as join21, relative as relative5, resolve as resolve5 } from "path";
|
|
7212
7531
|
|
|
7213
7532
|
// packages/rafa/src/modules/manifest.ts
|
|
7214
7533
|
var MANIFEST_VERSION = 1;
|
|
@@ -7480,7 +7799,7 @@ function validateManifest(raw, label = "rafa", seams = RUNNING_MANIFEST_SEAMS) {
|
|
|
7480
7799
|
}
|
|
7481
7800
|
|
|
7482
7801
|
// packages/rafa-inventory/src/inventory/plugins.ts
|
|
7483
|
-
var INSTALLED_PLUGINS_PATH =
|
|
7802
|
+
var INSTALLED_PLUGINS_PATH = join21(".claude", "plugins", "installed_plugins.json");
|
|
7484
7803
|
// packages/rafa-inventory/src/inventory/search/prompt.ts
|
|
7485
7804
|
var SEARCH_BLOCK_FENCE = "rafa:search";
|
|
7486
7805
|
var EXAMPLE_BLOCK = [
|
|
@@ -8054,13 +8373,12 @@ function lessonId(trigger, action) {
|
|
|
8054
8373
|
${actionHash(action)}`).digest("hex").slice(0, LESSON_HASH_LENGTH);
|
|
8055
8374
|
return `${slug === "" ? LESSON_ID_FALLBACK : slug}-${digest}`;
|
|
8056
8375
|
}
|
|
8057
|
-
function lessonEvidence(
|
|
8058
|
-
const { dispatch, outcome } = context;
|
|
8376
|
+
function lessonEvidence(session) {
|
|
8059
8377
|
return {
|
|
8060
|
-
...
|
|
8061
|
-
task:
|
|
8062
|
-
session:
|
|
8063
|
-
outcome
|
|
8378
|
+
...session.planStub === null ? {} : { plan: session.planStub },
|
|
8379
|
+
task: session.taskLine,
|
|
8380
|
+
session: session.sessionId,
|
|
8381
|
+
outcome: session.outcome
|
|
8064
8382
|
};
|
|
8065
8383
|
}
|
|
8066
8384
|
function toLesson(finding, context, at) {
|
|
@@ -8089,7 +8407,7 @@ function toLesson(finding, context, at) {
|
|
|
8089
8407
|
domain: finding.domain ?? DEFAULT_LESSON_DOMAIN,
|
|
8090
8408
|
scope: "project",
|
|
8091
8409
|
source: "task-report",
|
|
8092
|
-
evidence: [lessonEvidence(context)],
|
|
8410
|
+
evidence: [lessonEvidence({ ...context.dispatch, outcome: context.outcome })],
|
|
8093
8411
|
cause,
|
|
8094
8412
|
projectId: null
|
|
8095
8413
|
}
|
|
@@ -8102,6 +8420,157 @@ function reportLessons(record, context, now) {
|
|
|
8102
8420
|
const instincts = record.reading.report.findings.map((finding) => toLesson(finding, context, at)).filter((lesson) => lesson !== null);
|
|
8103
8421
|
return instincts.length === 0 ? null : { source_id: context.dispatch.sessionId, instincts };
|
|
8104
8422
|
}
|
|
8423
|
+
|
|
8424
|
+
// packages/rafa-inventory/src/report/bug-fix-pairs.ts
|
|
8425
|
+
var JOINED_KIND = "github";
|
|
8426
|
+
var ISSUE_NUMBER3 = /^\d+$/;
|
|
8427
|
+
function collapsed(text) {
|
|
8428
|
+
return text.replace(/\s+/g, " ").trim();
|
|
8429
|
+
}
|
|
8430
|
+
function sameArtifact(left, right) {
|
|
8431
|
+
return left !== null && collapsed(left) === collapsed(right);
|
|
8432
|
+
}
|
|
8433
|
+
function namesIssue(text, issue4) {
|
|
8434
|
+
return new RegExp(`(?<![\\w#])#${issue4}(?!\\w)`).test(text);
|
|
8435
|
+
}
|
|
8436
|
+
function isIssueStub(stub, issue4) {
|
|
8437
|
+
return stub === `rafa-${issue4}` || (stub?.startsWith(`rafa-${issue4}-`) ?? false);
|
|
8438
|
+
}
|
|
8439
|
+
function bugText(bug, outOfScope) {
|
|
8440
|
+
const key = collapsed(bug.artifact);
|
|
8441
|
+
let best = null;
|
|
8442
|
+
for (const row of outOfScope) {
|
|
8443
|
+
if (row.sessionId !== bug.sessionId || row.artifact === null)
|
|
8444
|
+
continue;
|
|
8445
|
+
const tail = collapsed(row.artifact);
|
|
8446
|
+
if (tail === "" || !key.endsWith(tail))
|
|
8447
|
+
continue;
|
|
8448
|
+
if (best === null || tail.length > collapsed(best.artifact ?? "").length)
|
|
8449
|
+
best = row;
|
|
8450
|
+
}
|
|
8451
|
+
return best === null || best.artifact === null ? { words: bug.artifact, artifact: bug.artifact } : { words: best.what, artifact: best.artifact };
|
|
8452
|
+
}
|
|
8453
|
+
function linkedUnits(issue4, links) {
|
|
8454
|
+
const byStub = new Map;
|
|
8455
|
+
for (const link of links) {
|
|
8456
|
+
if (!isIssueStub(link.stub, issue4))
|
|
8457
|
+
continue;
|
|
8458
|
+
const tasks = byStub.get(link.stub) ?? [];
|
|
8459
|
+
byStub.set(link.stub, [...tasks, ...link.tasks.map((line) => ({ line, stage: link.stage }))]);
|
|
8460
|
+
}
|
|
8461
|
+
if (byStub.size > 0) {
|
|
8462
|
+
return [...byStub].map(([stub, tasks]) => ({ link: "stub", stub, tasks }));
|
|
8463
|
+
}
|
|
8464
|
+
return links.filter((link) => link.context !== null && namesIssue(link.context, issue4)).map((link) => ({
|
|
8465
|
+
link: "stage-context",
|
|
8466
|
+
stub: link.stub,
|
|
8467
|
+
tasks: link.tasks.map((line) => ({ line, stage: link.stage }))
|
|
8468
|
+
}));
|
|
8469
|
+
}
|
|
8470
|
+
function unlinkedReason(issue4, links, rows) {
|
|
8471
|
+
const filed = new Set(links.map((link) => link.stub));
|
|
8472
|
+
const fileless = rows.reports.some((report) => report.planStub !== null && !filed.has(report.planStub) && (isIssueStub(report.planStub, issue4) || namesIssue(report.taskLine, issue4)));
|
|
8473
|
+
return fileless ? "no-plan-file" : "no-link";
|
|
8474
|
+
}
|
|
8475
|
+
function sameTaskLine(stored, planned) {
|
|
8476
|
+
return stripTaskDeclaration(stored) === stripTaskDeclaration(planned);
|
|
8477
|
+
}
|
|
8478
|
+
function matchingResolutions(rows, stub, line, artifact) {
|
|
8479
|
+
return rows.resolved.filter((row) => row.planStub === stub && sameTaskLine(row.taskLine, line) && sameArtifact(row.artifact, artifact));
|
|
8480
|
+
}
|
|
8481
|
+
function fixingTask(unit, issue4, artifact, rows) {
|
|
8482
|
+
const naming = unit.tasks.filter((task) => namesIssue(task.line, issue4));
|
|
8483
|
+
if (naming.length === 1)
|
|
8484
|
+
return naming[0] ?? null;
|
|
8485
|
+
if (unit.tasks.length === 1)
|
|
8486
|
+
return unit.tasks[0] ?? null;
|
|
8487
|
+
const holding = unit.tasks.filter((task) => matchingResolutions(rows, unit.stub, task.line, artifact).length > 0);
|
|
8488
|
+
return holding.length === 1 ? holding[0] ?? null : null;
|
|
8489
|
+
}
|
|
8490
|
+
function fixingReport(bug, stub, line, reports) {
|
|
8491
|
+
const filedAt = Date.parse(bug.collectedAt);
|
|
8492
|
+
const own = reports.filter((report) => report.planStub === stub && sameTaskLine(report.taskLine, line) && report.sessionId !== bug.sessionId);
|
|
8493
|
+
if (own.length === 0)
|
|
8494
|
+
return "no-done-report";
|
|
8495
|
+
const after = own.filter((report) => Date.parse(report.collectedAt) > filedAt).sort((left, right) => Date.parse(left.collectedAt) - Date.parse(right.collectedAt));
|
|
8496
|
+
return after[0] ?? "fixed-before-filed";
|
|
8497
|
+
}
|
|
8498
|
+
function fixAction(rows, fix, line, artifact) {
|
|
8499
|
+
const resolutions = matchingResolutions(rows, fix.planStub ?? "", line, artifact);
|
|
8500
|
+
const chosen = resolutions.find((row) => row.sessionId === fix.sessionId) ?? resolutions[0];
|
|
8501
|
+
return chosen?.resolution ?? stripTaskDeclaration(line);
|
|
8502
|
+
}
|
|
8503
|
+
function pairLesson(bug, text, fix, action, at) {
|
|
8504
|
+
return {
|
|
8505
|
+
id: lessonId(text.words, action),
|
|
8506
|
+
trigger: text.words,
|
|
8507
|
+
action,
|
|
8508
|
+
action_hash: actionHash(action),
|
|
8509
|
+
confidence: LESSON_CONFIDENCE,
|
|
8510
|
+
usage_count: 2,
|
|
8511
|
+
sources: [bug.sessionId, fix.sessionId],
|
|
8512
|
+
artifact: text.artifact,
|
|
8513
|
+
signal: "loud",
|
|
8514
|
+
status: "active",
|
|
8515
|
+
created_at: at,
|
|
8516
|
+
updated_at: at,
|
|
8517
|
+
description: {
|
|
8518
|
+
kind: "gotcha",
|
|
8519
|
+
domain: DEFAULT_LESSON_DOMAIN,
|
|
8520
|
+
scope: "project",
|
|
8521
|
+
source: "task-report",
|
|
8522
|
+
evidence: [lessonEvidence(bug), lessonEvidence(fix)],
|
|
8523
|
+
cause: text.words,
|
|
8524
|
+
projectId: null
|
|
8525
|
+
}
|
|
8526
|
+
};
|
|
8527
|
+
}
|
|
8528
|
+
function pairUnit(bug, issue4, text, unit, rows, at) {
|
|
8529
|
+
const task = fixingTask(unit, issue4, text.artifact, rows);
|
|
8530
|
+
if (task === null)
|
|
8531
|
+
return "ambiguous-stage";
|
|
8532
|
+
const fix = fixingReport(bug, unit.stub, task.line, rows.reports);
|
|
8533
|
+
if (typeof fix === "string")
|
|
8534
|
+
return fix;
|
|
8535
|
+
const action = fixAction(rows, fix, task.line, text.artifact);
|
|
8536
|
+
return {
|
|
8537
|
+
bug,
|
|
8538
|
+
issue: issue4,
|
|
8539
|
+
link: unit.link,
|
|
8540
|
+
plan: unit.stub,
|
|
8541
|
+
stage: task.stage,
|
|
8542
|
+
fix,
|
|
8543
|
+
lesson: pairLesson(bug, text, fix, action, at)
|
|
8544
|
+
};
|
|
8545
|
+
}
|
|
8546
|
+
function pairBug(bug, rows, links, at) {
|
|
8547
|
+
const issue4 = bug.trackerRef.externalId;
|
|
8548
|
+
if (bug.trackerRef.kind !== JOINED_KIND || !ISSUE_NUMBER3.test(issue4))
|
|
8549
|
+
return "local-ref";
|
|
8550
|
+
const units = linkedUnits(issue4, links);
|
|
8551
|
+
if (units.length === 0)
|
|
8552
|
+
return unlinkedReason(issue4, links, rows);
|
|
8553
|
+
const text = bugText(bug, rows.outOfScope);
|
|
8554
|
+
const answers = units.map((unit) => pairUnit(bug, issue4, text, unit, rows, at));
|
|
8555
|
+
const pairs = answers.filter((answer2) => typeof answer2 !== "string");
|
|
8556
|
+
if (pairs.length > 0)
|
|
8557
|
+
return pairs;
|
|
8558
|
+
return answers.find((answer2) => typeof answer2 === "string") ?? "no-link";
|
|
8559
|
+
}
|
|
8560
|
+
function pairBugFixes(rows, links, now) {
|
|
8561
|
+
const at = now.toISOString();
|
|
8562
|
+
const pairs = [];
|
|
8563
|
+
const unpaired = [];
|
|
8564
|
+
for (const bug of rows.bugs) {
|
|
8565
|
+
const answer2 = pairBug(bug, rows, links, at);
|
|
8566
|
+
if (typeof answer2 === "string") {
|
|
8567
|
+
unpaired.push({ bug, issue: bug.trackerRef.externalId, reason: answer2 });
|
|
8568
|
+
} else {
|
|
8569
|
+
pairs.push(...answer2);
|
|
8570
|
+
}
|
|
8571
|
+
}
|
|
8572
|
+
return { pairs, unpaired };
|
|
8573
|
+
}
|
|
8105
8574
|
// packages/rafa-inventory/src/start/serving.ts
|
|
8106
8575
|
function resolveSessionTiers(reading) {
|
|
8107
8576
|
const rows = readTrees({
|
|
@@ -8308,13 +8777,34 @@ function triggerCandidate(lesson) {
|
|
|
8308
8777
|
};
|
|
8309
8778
|
return { record, description: null, body: "" };
|
|
8310
8779
|
}
|
|
8311
|
-
function
|
|
8312
|
-
return scoreCandidate(triggerCandidate(lesson), words).words.length
|
|
8780
|
+
function triggerWordCount(lesson, words) {
|
|
8781
|
+
return scoreCandidate(triggerCandidate(lesson), words).words.length;
|
|
8782
|
+
}
|
|
8783
|
+
function compareIds(a, b) {
|
|
8784
|
+
if (a < b)
|
|
8785
|
+
return -1;
|
|
8786
|
+
if (a > b)
|
|
8787
|
+
return 1;
|
|
8788
|
+
return 0;
|
|
8789
|
+
}
|
|
8790
|
+
function compareMatches(a, b) {
|
|
8791
|
+
if (a.byArtifact !== b.byArtifact) {
|
|
8792
|
+
return a.byArtifact ? -1 : 1;
|
|
8793
|
+
}
|
|
8794
|
+
if (a.triggerWords !== b.triggerWords)
|
|
8795
|
+
return b.triggerWords - a.triggerWords;
|
|
8796
|
+
if (a.lesson.confidence !== b.lesson.confidence)
|
|
8797
|
+
return b.lesson.confidence - a.lesson.confidence;
|
|
8798
|
+
return compareIds(a.lesson.id, b.lesson.id);
|
|
8313
8799
|
}
|
|
8314
8800
|
function selectLessons(task, bundle) {
|
|
8315
8801
|
const words = questionWords(task.text);
|
|
8316
|
-
const
|
|
8317
|
-
|
|
8802
|
+
const matches = bundle.instincts.map((lesson) => ({
|
|
8803
|
+
lesson,
|
|
8804
|
+
byArtifact: artifactMatches(lesson, task),
|
|
8805
|
+
triggerWords: triggerWordCount(lesson, words)
|
|
8806
|
+
}));
|
|
8807
|
+
return matches.filter((match) => match.byArtifact || match.triggerWords >= TRIGGER_WORD_FLOOR).sort(compareMatches).slice(0, LESSON_LIMIT).map((match) => match.lesson);
|
|
8318
8808
|
}
|
|
8319
8809
|
// packages/rafa-effort/src/effort/skill-use.ts
|
|
8320
8810
|
var SKILL_USE_CLI_FLOOR = "2.1.280";
|
|
@@ -8333,10 +8823,10 @@ function parseRecord3(line) {
|
|
|
8333
8823
|
}
|
|
8334
8824
|
}
|
|
8335
8825
|
function subagentLogPaths(sessionLogPath) {
|
|
8336
|
-
const dir =
|
|
8337
|
-
if (!
|
|
8826
|
+
const dir = join22(dirname10(sessionLogPath), sessionIdFromPath(sessionLogPath), "subagents");
|
|
8827
|
+
if (!existsSync5(dir))
|
|
8338
8828
|
return [];
|
|
8339
|
-
return readdirSync5(dir, { withFileTypes: true }).filter((entry) => entry.isFile() && SUBAGENT_LOG_NAME.test(entry.name)).map((entry) =>
|
|
8829
|
+
return readdirSync5(dir, { withFileTypes: true }).filter((entry) => entry.isFile() && SUBAGENT_LOG_NAME.test(entry.name)).map((entry) => join22(dir, entry.name)).sort((a, b) => a.localeCompare(b));
|
|
8340
8830
|
}
|
|
8341
8831
|
function versionFields(version) {
|
|
8342
8832
|
if (typeof version !== "string")
|
|
@@ -8606,7 +9096,7 @@ function baseAdapterRegistry() {
|
|
|
8606
9096
|
|
|
8607
9097
|
// packages/rafa/src/modules/load.ts
|
|
8608
9098
|
import { readFileSync as readFileSync14 } from "fs";
|
|
8609
|
-
import { isAbsolute as isAbsolute4, join as
|
|
9099
|
+
import { isAbsolute as isAbsolute4, join as join23, relative as relative6, resolve as resolve6 } from "path";
|
|
8610
9100
|
import { pathToFileURL } from "url";
|
|
8611
9101
|
var importModuleEntry = (entry) => import(pathToFileURL(entry).href);
|
|
8612
9102
|
var ADAPTER_TYPES = ["tracker", "store", "planner", "output", "sync", "logger"];
|
|
@@ -8625,7 +9115,7 @@ function unread(name, directory, ...problems) {
|
|
|
8625
9115
|
}
|
|
8626
9116
|
function readPathSource(source, settings, seams) {
|
|
8627
9117
|
const directory = resolve6(settings.base, source.location);
|
|
8628
|
-
const file =
|
|
9118
|
+
const file = join23(directory, "package.json");
|
|
8629
9119
|
let parsed;
|
|
8630
9120
|
try {
|
|
8631
9121
|
parsed = JSON.parse((seams.readText ?? ((path2) => readFileSync14(path2, "utf8")))(file));
|
|
@@ -8961,11 +9451,11 @@ function selectCommits(rows, collected) {
|
|
|
8961
9451
|
return { pending, alreadyCollected };
|
|
8962
9452
|
}
|
|
8963
9453
|
function readPlanStubs(plansDir) {
|
|
8964
|
-
return
|
|
9454
|
+
return existsSync6(plansDir) ? planStubsFromFileNames(readdirSync6(plansDir)) : [];
|
|
8965
9455
|
}
|
|
8966
|
-
async function collectSessionRow(candidate, planStubs) {
|
|
9456
|
+
async function collectSessionRow(candidate, planStubs, home = homedir3()) {
|
|
8967
9457
|
const enqueue = await findFirstEnqueue(readLines(candidate.path));
|
|
8968
|
-
const stats = await readSessionLog(candidate.path);
|
|
9458
|
+
const stats = await readSessionLog(candidate.path, home);
|
|
8969
9459
|
const attribution = attributeSession(stats, enqueue.content, planStubs);
|
|
8970
9460
|
return {
|
|
8971
9461
|
...stats,
|
|
@@ -9003,7 +9493,7 @@ async function collectSessionHalf(context) {
|
|
|
9003
9493
|
let failed2 = 0;
|
|
9004
9494
|
for (const candidate of selection.pending) {
|
|
9005
9495
|
try {
|
|
9006
|
-
rows.push(await collectSessionRow(candidate, planStubs));
|
|
9496
|
+
rows.push(await collectSessionRow(candidate, planStubs, context.home));
|
|
9007
9497
|
read.push(candidate);
|
|
9008
9498
|
context.note(`sessions: read ${candidate.sessionId}`);
|
|
9009
9499
|
} catch (error) {
|
|
@@ -9073,6 +9563,7 @@ async function collectEffort(options) {
|
|
|
9073
9563
|
const { worktreeDir, ...sources } = await resolveSources(options, log);
|
|
9074
9564
|
const context = {
|
|
9075
9565
|
repoRoot,
|
|
9566
|
+
home: options.home,
|
|
9076
9567
|
logDirs: logDirsOf(options, worktreeDir),
|
|
9077
9568
|
...sources,
|
|
9078
9569
|
sinceEpochMs: options.sinceEpochMs ?? null,
|
|
@@ -9128,14 +9619,14 @@ async function collect2(args, repoRoot) {
|
|
|
9128
9619
|
try {
|
|
9129
9620
|
result = await collectEffort({
|
|
9130
9621
|
repoRoot,
|
|
9131
|
-
home:
|
|
9622
|
+
home: homedir3(),
|
|
9132
9623
|
sinceEpochMs: parsed.sinceEpochMs,
|
|
9133
9624
|
collectSessions: parsed.collectSessions,
|
|
9134
9625
|
collectCommits: parsed.collectCommits,
|
|
9135
9626
|
skills: parsed.collectHeldSkills ? "held" : "appended",
|
|
9136
9627
|
verbose: parsed.verbose
|
|
9137
9628
|
});
|
|
9138
|
-
resolved = await loadConfig({ root: repoRoot, home:
|
|
9629
|
+
resolved = await loadConfig({ root: repoRoot, home: homedir3() }, {}, () => {});
|
|
9139
9630
|
} catch (error) {
|
|
9140
9631
|
if (!(error instanceof ConfigError))
|
|
9141
9632
|
throw error;
|
|
@@ -9145,11 +9636,11 @@ async function collect2(args, repoRoot) {
|
|
|
9145
9636
|
activeOutput().info(line);
|
|
9146
9637
|
}
|
|
9147
9638
|
const warn = (message) => activeOutput().warn(message);
|
|
9148
|
-
await createHubContact({ root: repoRoot, home:
|
|
9639
|
+
await createHubContact({ root: repoRoot, home: homedir3(), resolved, warn }).pushThenPull();
|
|
9149
9640
|
}
|
|
9150
9641
|
// packages/rafa/src/core/loop/session-readings.ts
|
|
9151
9642
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
9152
|
-
import { join as
|
|
9643
|
+
import { join as join24, relative as relative7 } from "path";
|
|
9153
9644
|
var STOP_WAIT_MS = 30000;
|
|
9154
9645
|
var STOP_POLL_MS = 200;
|
|
9155
9646
|
function gitBranch(root) {
|
|
@@ -9686,10 +10177,10 @@ function findRecurrences(strings, facts, fromIndex, planCi) {
|
|
|
9686
10177
|
}
|
|
9687
10178
|
|
|
9688
10179
|
// packages/rafa-effort/src/effort/skill-facts.ts
|
|
9689
|
-
import { existsSync as
|
|
10180
|
+
import { existsSync as existsSync9 } from "fs";
|
|
9690
10181
|
|
|
9691
10182
|
// packages/rafa/src/effort/store/plan-ci.ts
|
|
9692
|
-
import { existsSync as
|
|
10183
|
+
import { existsSync as existsSync7, readdirSync as readdirSync7 } from "fs";
|
|
9693
10184
|
|
|
9694
10185
|
// packages/rafa/src/effort/store/check-rows.ts
|
|
9695
10186
|
function verdictOf2(rows) {
|
|
@@ -9725,7 +10216,7 @@ function rowOf3(stored) {
|
|
|
9725
10216
|
}
|
|
9726
10217
|
function readPlanCi(repoRoot, planStub) {
|
|
9727
10218
|
const path2 = sqliteStorePath(repoRoot);
|
|
9728
|
-
if (!
|
|
10219
|
+
if (!existsSync7(path2))
|
|
9729
10220
|
return [];
|
|
9730
10221
|
const rows = withSqliteStore(path2, "read", false, (db) => planStub === undefined ? db.query(`${SELECT_COLUMNS} ORDER BY seq`).all() : db.query(`${SELECT_COLUMNS} WHERE plan_stub = ? ORDER BY seq`).all(planStub));
|
|
9731
10222
|
return rows.map(rowOf3);
|
|
@@ -9733,7 +10224,7 @@ function readPlanCi(repoRoot, planStub) {
|
|
|
9733
10224
|
|
|
9734
10225
|
// packages/rafa/src/effort/store/reports.ts
|
|
9735
10226
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
9736
|
-
import { existsSync as
|
|
10227
|
+
import { existsSync as existsSync8 } from "fs";
|
|
9737
10228
|
var ROWS_PER_WRITE = 1;
|
|
9738
10229
|
var INSERT_REPORT = `
|
|
9739
10230
|
INSERT INTO task_reports (
|
|
@@ -9795,7 +10286,7 @@ var SELECT_TALLIES = `
|
|
|
9795
10286
|
`;
|
|
9796
10287
|
function readTaskReportTallies(repoRoot) {
|
|
9797
10288
|
const path2 = sqliteStorePath(repoRoot);
|
|
9798
|
-
if (!
|
|
10289
|
+
if (!existsSync8(path2))
|
|
9799
10290
|
return [];
|
|
9800
10291
|
const rows = withSqliteStore(path2, "read", false, (db) => db.query(SELECT_TALLIES).all());
|
|
9801
10292
|
return rows.map((row) => ({
|
|
@@ -9820,7 +10311,7 @@ function parseSkillsUsed(sessionId, json) {
|
|
|
9820
10311
|
}
|
|
9821
10312
|
function readReportedSkills(repoRoot) {
|
|
9822
10313
|
const path2 = sqliteStorePath(repoRoot);
|
|
9823
|
-
if (!
|
|
10314
|
+
if (!existsSync8(path2))
|
|
9824
10315
|
return [];
|
|
9825
10316
|
const rows = withSqliteStore(path2, "read", false, (db) => db.query(SELECT_REPORTED_SKILLS).all());
|
|
9826
10317
|
return rows.map((row) => ({
|
|
@@ -9909,7 +10400,7 @@ function orderedReports(reports, plans) {
|
|
|
9909
10400
|
return order.flatMap((plan) => reports.filter(({ planStub }) => planStub === plan));
|
|
9910
10401
|
}
|
|
9911
10402
|
function readSkillFacts(repoRoot, plans) {
|
|
9912
|
-
if (!
|
|
10403
|
+
if (!existsSync9(sqliteStorePath(repoRoot)))
|
|
9913
10404
|
return [];
|
|
9914
10405
|
const reports = orderedReports(readReportedSkills(repoRoot), plans);
|
|
9915
10406
|
if (reports.length === 0)
|
|
@@ -10148,10 +10639,10 @@ async function readSkillsReport(options) {
|
|
|
10148
10639
|
}
|
|
10149
10640
|
|
|
10150
10641
|
// packages/rafa-effort/src/effort/report-trend-read.ts
|
|
10151
|
-
import { homedir as
|
|
10642
|
+
import { homedir as homedir5 } from "os";
|
|
10152
10643
|
|
|
10153
10644
|
// packages/rafa/src/effort/store/dispatches.ts
|
|
10154
|
-
import { existsSync as
|
|
10645
|
+
import { existsSync as existsSync10 } from "fs";
|
|
10155
10646
|
var ROWS_PER_WRITE2 = 1;
|
|
10156
10647
|
var TEXT_KEYS = ["agent", "model", "effort"];
|
|
10157
10648
|
var INSERT_DISPATCH = `
|
|
@@ -10273,7 +10764,7 @@ var SELECT_BUDGETS = `
|
|
|
10273
10764
|
`;
|
|
10274
10765
|
function readSessionBudgets(repoRoot) {
|
|
10275
10766
|
const path2 = sqliteStorePath(repoRoot);
|
|
10276
|
-
if (!
|
|
10767
|
+
if (!existsSync10(path2))
|
|
10277
10768
|
return [];
|
|
10278
10769
|
const rows = withSqliteStore(path2, "read", false, (db) => db.query(SELECT_BUDGETS).all());
|
|
10279
10770
|
return rows.map((row) => ({
|
|
@@ -10291,17 +10782,17 @@ var SELECT_AGENTS = `
|
|
|
10291
10782
|
`;
|
|
10292
10783
|
function readSessionAgents(repoRoot) {
|
|
10293
10784
|
const path2 = sqliteStorePath(repoRoot);
|
|
10294
|
-
if (!
|
|
10785
|
+
if (!existsSync10(path2))
|
|
10295
10786
|
return [];
|
|
10296
10787
|
const rows = withSqliteStore(path2, "read", false, (db) => db.query(SELECT_AGENTS).all());
|
|
10297
10788
|
return rows.map((row) => ({ sessionId: row.session_id, agent: row.agent }));
|
|
10298
10789
|
}
|
|
10299
10790
|
|
|
10300
10791
|
// packages/rafa-effort/src/effort/report.ts
|
|
10301
|
-
import { homedir as
|
|
10792
|
+
import { homedir as homedir4 } from "os";
|
|
10302
10793
|
|
|
10303
10794
|
// packages/rafa/src/effort/store/preflight.ts
|
|
10304
|
-
import { existsSync as
|
|
10795
|
+
import { existsSync as existsSync11 } from "fs";
|
|
10305
10796
|
var TIERS = {
|
|
10306
10797
|
required: true,
|
|
10307
10798
|
optional: true
|
|
@@ -10416,7 +10907,7 @@ function haltedCheckOf(row) {
|
|
|
10416
10907
|
}
|
|
10417
10908
|
function readPreflightHalts(repoRoot) {
|
|
10418
10909
|
const path2 = sqliteStorePath(repoRoot);
|
|
10419
|
-
if (!
|
|
10910
|
+
if (!existsSync11(path2))
|
|
10420
10911
|
return [];
|
|
10421
10912
|
const rows = withSqliteStore(path2, "read", false, (db) => db.query(SELECT_HALTED).all());
|
|
10422
10913
|
const halts = new Map;
|
|
@@ -10596,7 +11087,7 @@ function budgetedSessions(rows, budgets) {
|
|
|
10596
11087
|
}
|
|
10597
11088
|
|
|
10598
11089
|
// packages/rafa-effort/src/effort/report-doc-bugs.ts
|
|
10599
|
-
import { existsSync as
|
|
11090
|
+
import { existsSync as existsSync12 } from "fs";
|
|
10600
11091
|
|
|
10601
11092
|
// packages/rafa/src/triage/doc-only.ts
|
|
10602
11093
|
var FILE_EXTENSIONS2 = [
|
|
@@ -10656,25 +11147,25 @@ var SELECT_FILED_BUGS = `
|
|
|
10656
11147
|
FROM out_of_scope_bugs
|
|
10657
11148
|
WHERE scope = 'rafa'
|
|
10658
11149
|
`;
|
|
10659
|
-
function
|
|
11150
|
+
function bugText2(bug) {
|
|
10660
11151
|
return bug.artifact === null ? bug.what : `${bug.what}
|
|
10661
11152
|
${bug.artifact}`;
|
|
10662
11153
|
}
|
|
10663
11154
|
function countDocOnlyBugs(bugs) {
|
|
10664
11155
|
return {
|
|
10665
11156
|
bugs: bugs.length,
|
|
10666
|
-
docOnly: bugs.filter((bug) => namesOnlyDocs(
|
|
11157
|
+
docOnly: bugs.filter((bug) => namesOnlyDocs(bugText2(bug))).length
|
|
10667
11158
|
};
|
|
10668
11159
|
}
|
|
10669
11160
|
function readDocOnlyBugs(repoRoot) {
|
|
10670
11161
|
const path2 = sqliteStorePath(repoRoot);
|
|
10671
|
-
if (!
|
|
11162
|
+
if (!existsSync12(path2))
|
|
10672
11163
|
return countDocOnlyBugs([]);
|
|
10673
11164
|
return countDocOnlyBugs(withSqliteStore(path2, "read", false, (db) => db.query(SELECT_FILED_BUGS).all()));
|
|
10674
11165
|
}
|
|
10675
11166
|
|
|
10676
11167
|
// packages/rafa-effort/src/effort/report-kinds.ts
|
|
10677
|
-
import { existsSync as
|
|
11168
|
+
import { existsSync as existsSync13 } from "fs";
|
|
10678
11169
|
var SELECT_ROUTED_ENTRIES = `
|
|
10679
11170
|
SELECT plan_stub AS planStub, kind, route
|
|
10680
11171
|
FROM bug_routes
|
|
@@ -10707,7 +11198,7 @@ function countBugKinds(rows) {
|
|
|
10707
11198
|
}
|
|
10708
11199
|
function readBugKinds(repoRoot) {
|
|
10709
11200
|
const path2 = sqliteStorePath(repoRoot);
|
|
10710
|
-
if (!
|
|
11201
|
+
if (!existsSync13(path2))
|
|
10711
11202
|
return { plans: [], problem: null };
|
|
10712
11203
|
try {
|
|
10713
11204
|
const rows = withSqliteStore(path2, "read", false, (db) => db.query(SELECT_ROUTED_ENTRIES).all());
|
|
@@ -11016,7 +11507,7 @@ function refuse2(problems) {
|
|
|
11016
11507
|
async function writeSkillsReport(plans, json, repoRoot) {
|
|
11017
11508
|
let built;
|
|
11018
11509
|
try {
|
|
11019
|
-
built = await readSkillsReport({ repoRoot, home:
|
|
11510
|
+
built = await readSkillsReport({ repoRoot, home: homedir4(), plans });
|
|
11020
11511
|
} catch (error) {
|
|
11021
11512
|
if (!(error instanceof ConfigError))
|
|
11022
11513
|
throw error;
|
|
@@ -11038,7 +11529,7 @@ async function report(args, repoRoot) {
|
|
|
11038
11529
|
const parsed = parseReportArgs(args);
|
|
11039
11530
|
if (parsed.errors.length > 0)
|
|
11040
11531
|
refuse2(parsed.errors);
|
|
11041
|
-
await pullBeforeRead({ roots: { root: repoRoot, home:
|
|
11532
|
+
await pullBeforeRead({ roots: { root: repoRoot, home: homedir4() }, warn: (line) => activeOutput().warn(line) });
|
|
11042
11533
|
if (parsed.skills) {
|
|
11043
11534
|
await writeSkillsReport(parsed.plans, parsed.json, repoRoot);
|
|
11044
11535
|
return;
|
|
@@ -11051,7 +11542,7 @@ async function report(args, repoRoot) {
|
|
|
11051
11542
|
try {
|
|
11052
11543
|
built = await buildReport({
|
|
11053
11544
|
repoRoot,
|
|
11054
|
-
home:
|
|
11545
|
+
home: homedir4(),
|
|
11055
11546
|
kinds: parsed.kinds,
|
|
11056
11547
|
entrypoints: parsed.entrypoints
|
|
11057
11548
|
});
|
|
@@ -11423,7 +11914,7 @@ async function readTrendReport({ repoRoot, home, options }) {
|
|
|
11423
11914
|
async function writeTrendReport(options, json, repoRoot) {
|
|
11424
11915
|
let built;
|
|
11425
11916
|
try {
|
|
11426
|
-
built = await readTrendReport({ repoRoot, home:
|
|
11917
|
+
built = await readTrendReport({ repoRoot, home: homedir5(), options });
|
|
11427
11918
|
} catch (error) {
|
|
11428
11919
|
if (!(error instanceof ConfigError))
|
|
11429
11920
|
throw error;
|
|
@@ -11479,8 +11970,8 @@ async function readDoctorEffortSync(input, seams = {}) {
|
|
|
11479
11970
|
}
|
|
11480
11971
|
}
|
|
11481
11972
|
// packages/rafa-effort/src/effort/sync/file.ts
|
|
11482
|
-
import { existsSync as
|
|
11483
|
-
import { join as
|
|
11973
|
+
import { existsSync as existsSync14 } from "fs";
|
|
11974
|
+
import { join as join25, resolve as resolve8 } from "path";
|
|
11484
11975
|
var REFUSAL2 = "effort sync (file)";
|
|
11485
11976
|
var NOTHING_COPIED = "Nothing was copied.";
|
|
11486
11977
|
|
|
@@ -11496,7 +11987,7 @@ function refuseUncarriable(backend, source) {
|
|
|
11496
11987
|
if (backend === "ndjson") {
|
|
11497
11988
|
throw new FileSyncRefusal(`${REFUSAL2}: this project keeps its sessions and commits as NDJSON (store: ndjson), and the file carried` + ` is effort.sqlite, which would hold none of them. ${NOTHING_COPIED} Next safe step: ${MOVE_TO_SQLITE}`);
|
|
11498
11989
|
}
|
|
11499
|
-
if (!
|
|
11990
|
+
if (!existsSync14(join25(source, SQLITE_STORE_FILE_NAME))) {
|
|
11500
11991
|
throw new FileSyncRefusal(`${REFUSAL2}: no ${SQLITE_STORE_FILE_NAME} in ${source}. ${NOTHING_COPIED}`);
|
|
11501
11992
|
}
|
|
11502
11993
|
}
|
|
@@ -11514,11 +12005,11 @@ function createFileSync(options) {
|
|
|
11514
12005
|
const source = storeDir();
|
|
11515
12006
|
refuseUncarriable(backend, source);
|
|
11516
12007
|
const copied = copyEffortStore({ source, target });
|
|
11517
|
-
return Object.freeze({ status: "pushed", path:
|
|
12008
|
+
return Object.freeze({ status: "pushed", path: join25(copied.directory, SQLITE_STORE_FILE_NAME) });
|
|
11518
12009
|
};
|
|
11519
12010
|
const pull = async ({ from, dryRun, sessionId = null }) => {
|
|
11520
12011
|
const otherPath = resolve8(repoRoot, requirePath("from", from));
|
|
11521
|
-
const path2 =
|
|
12012
|
+
const path2 = join25(storeDir(), SQLITE_STORE_FILE_NAME);
|
|
11522
12013
|
const stamp2 = fileStamp(now());
|
|
11523
12014
|
const merge2 = mergeStore({ ...mergeSeams(options), path: path2, otherPath, backend, dryRun, stamp: stamp2, now, sessionId });
|
|
11524
12015
|
return Object.freeze({ status: "pulled", merge: merge2 });
|
|
@@ -11594,8 +12085,8 @@ function createJsonOutput({
|
|
|
11594
12085
|
}
|
|
11595
12086
|
|
|
11596
12087
|
// src/adapters/planner/claude.ts
|
|
11597
|
-
import { existsSync as
|
|
11598
|
-
import { mkdir as mkdir3, readFile as
|
|
12088
|
+
import { existsSync as existsSync15 } from "fs";
|
|
12089
|
+
import { mkdir as mkdir3, readFile as readFile4 } from "fs/promises";
|
|
11599
12090
|
import { posix as posix2, resolve as resolve9 } from "path";
|
|
11600
12091
|
var FAILURE_EXIT_CODE = 1;
|
|
11601
12092
|
function planFilePath(planDir, fileName) {
|
|
@@ -11618,11 +12109,11 @@ function createClaudePlanner(options) {
|
|
|
11618
12109
|
const create = async ({ specPath, stub }) => {
|
|
11619
12110
|
const planPath = planFilePath(planDir, `PLAN-${stub}.md`);
|
|
11620
12111
|
const prerequisitesPath = planFilePath(planDir, `PREREQUISITES-${stub}.md`);
|
|
11621
|
-
const isWritten = (path2) =>
|
|
12112
|
+
const isWritten = (path2) => existsSync15(resolve9(root, path2));
|
|
11622
12113
|
if (isWritten(planPath)) {
|
|
11623
12114
|
throw new ClaudePlannerError(`${planPath} already exists`, FAILURE_EXIT_CODE);
|
|
11624
12115
|
}
|
|
11625
|
-
const specContent = await
|
|
12116
|
+
const specContent = await readFile4(resolve9(root, specPath), "utf8");
|
|
11626
12117
|
const absolutePlanDir = resolve9(root, planDir);
|
|
11627
12118
|
await mkdir3(absolutePlanDir, { recursive: true });
|
|
11628
12119
|
const prompt = buildPrompt(specContent, stub, absolutePlanDir);
|
|
@@ -11709,7 +12200,7 @@ var CORE_ADAPTERS = [
|
|
|
11709
12200
|
portVersion: PORT_VERSIONS.learning,
|
|
11710
12201
|
create: ({
|
|
11711
12202
|
repoRoot,
|
|
11712
|
-
home =
|
|
12203
|
+
home = homedir6(),
|
|
11713
12204
|
learningBlessMinConfidence = registeredBlessMinConfidence()
|
|
11714
12205
|
}) => createLocalLearning({
|
|
11715
12206
|
instinctsDir: localInstinctsDir(repoRoot),
|
|
@@ -11786,8 +12277,8 @@ function resolveBaseBranch(git, configured) {
|
|
|
11786
12277
|
return readRemoteHead(git) ?? DEFAULT_BASE_BRANCH;
|
|
11787
12278
|
}
|
|
11788
12279
|
// packages/rafa-release/src/release/status-readings.ts
|
|
11789
|
-
import { existsSync as
|
|
11790
|
-
import { join as
|
|
12280
|
+
import { existsSync as existsSync16, readFileSync as readFileSync16 } from "fs";
|
|
12281
|
+
import { join as join26 } from "path";
|
|
11791
12282
|
|
|
11792
12283
|
// packages/rafa-release/src/release/version.ts
|
|
11793
12284
|
var RELEASE_REMOTE = "origin";
|
|
@@ -11988,14 +12479,14 @@ function newestRootRelease(git) {
|
|
|
11988
12479
|
return reading.latest?.version ?? null;
|
|
11989
12480
|
}
|
|
11990
12481
|
function readUntagged(root, configured, tags) {
|
|
11991
|
-
const resolved =
|
|
12482
|
+
const resolved = join26(root, configured);
|
|
11992
12483
|
const text = textOf(resolved);
|
|
11993
12484
|
if (text === null) {
|
|
11994
12485
|
return {
|
|
11995
12486
|
path: configured,
|
|
11996
12487
|
released: [],
|
|
11997
12488
|
versions: [],
|
|
11998
|
-
missing: !
|
|
12489
|
+
missing: !existsSync16(resolved),
|
|
11999
12490
|
problem: `the changelog could not be read at ${resolved}`
|
|
12000
12491
|
};
|
|
12001
12492
|
}
|
|
@@ -13315,13 +13806,13 @@ function isRegularFile(full) {
|
|
|
13315
13806
|
return false;
|
|
13316
13807
|
}
|
|
13317
13808
|
}
|
|
13318
|
-
function
|
|
13809
|
+
function readFile5(repoRoot, path2) {
|
|
13319
13810
|
const resolved = resolve10(repoRoot, path2);
|
|
13320
13811
|
return { path: path2, resolved, present: isRegularFile(resolved) };
|
|
13321
13812
|
}
|
|
13322
13813
|
function resolveReleaseEnabled(settings, repoRoot) {
|
|
13323
|
-
const versionFile =
|
|
13324
|
-
const changelog =
|
|
13814
|
+
const versionFile = readFile5(repoRoot, settings.releaseVersionFile);
|
|
13815
|
+
const changelog = readFile5(repoRoot, settings.releaseChangelog);
|
|
13325
13816
|
if (settings.releaseEnabled === RELEASE_AUTO) {
|
|
13326
13817
|
return {
|
|
13327
13818
|
enabled: versionFile.present && changelog.present,
|
|
@@ -13334,7 +13825,7 @@ function resolveReleaseEnabled(settings, repoRoot) {
|
|
|
13334
13825
|
}
|
|
13335
13826
|
// packages/rafa/src/effort/store/changes.ts
|
|
13336
13827
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
13337
|
-
import { existsSync as
|
|
13828
|
+
import { existsSync as existsSync17 } from "fs";
|
|
13338
13829
|
var INSERT_CHANGE = `
|
|
13339
13830
|
INSERT INTO changes (
|
|
13340
13831
|
id, session_id, plan_stub, task_line,
|
|
@@ -13414,7 +13905,7 @@ var SELECT_PLAN_CHANGES = `
|
|
|
13414
13905
|
`;
|
|
13415
13906
|
function readPlanChanges(repoRoot, planStub) {
|
|
13416
13907
|
const path2 = sqliteStorePath(repoRoot);
|
|
13417
|
-
if (!
|
|
13908
|
+
if (!existsSync17(path2))
|
|
13418
13909
|
return [];
|
|
13419
13910
|
const rows = withSqliteStore(path2, "read", false, (db) => db.query(SELECT_PLAN_CHANGES).all(planStub));
|
|
13420
13911
|
return rows.map((row) => ({
|
|
@@ -13446,7 +13937,7 @@ function mergeGuardSettings(config) {
|
|
|
13446
13937
|
}
|
|
13447
13938
|
// packages/rafa-release/src/release/prepare.ts
|
|
13448
13939
|
import { mkdirSync as mkdirSync3, readFileSync as readFileSync17, writeFileSync as writeFileSync5 } from "fs";
|
|
13449
|
-
import { dirname as dirname11, join as
|
|
13940
|
+
import { dirname as dirname11, join as join27, posix as posix4 } from "path";
|
|
13450
13941
|
var NO_FRAGMENT = "no release fragment";
|
|
13451
13942
|
var WHITESPACE3 = /\s+/g;
|
|
13452
13943
|
function levelFields(reading) {
|
|
@@ -13539,7 +14030,7 @@ function prepareRelease(input) {
|
|
|
13539
14030
|
const fragment = { plan: input.plan, title, level, package: null, notes: lines.notes };
|
|
13540
14031
|
const name = allocateFragmentName(input.plan, read.base.waiting.map((waiting) => nameOf2(waiting.path)));
|
|
13541
14032
|
const path2 = posix4.join(input.settings.releaseFragments.replace(/\\/g, "/"), name);
|
|
13542
|
-
const resolved =
|
|
14033
|
+
const resolved = join27(input.repoRoot, path2);
|
|
13543
14034
|
const before = textOf2(resolved);
|
|
13544
14035
|
const after = serializeFragment(fragment);
|
|
13545
14036
|
const problems = lines.problem === null ? read.problems : [...read.problems, lines.problem];
|
|
@@ -13693,11 +14184,11 @@ var DEFAULT_RELEASE_PATHS = Object.freeze({
|
|
|
13693
14184
|
});
|
|
13694
14185
|
var MS_PER_DAY2 = 24 * 60 * 60 * 1000;
|
|
13695
14186
|
// packages/rafa-pr/src/cleanup/worktrees.ts
|
|
13696
|
-
import { join as
|
|
14187
|
+
import { join as join29, sep as sep2 } from "path";
|
|
13697
14188
|
|
|
13698
14189
|
// packages/rafa/src/start/worktree-dir.ts
|
|
13699
|
-
import { join as
|
|
13700
|
-
var WORKTREES_SUBDIR =
|
|
14190
|
+
import { join as join28, resolve as resolve11 } from "path";
|
|
14191
|
+
var WORKTREES_SUBDIR = join28(".rafa", "worktrees");
|
|
13701
14192
|
function worktreeDirAt(projectRoot, worktreeDir) {
|
|
13702
14193
|
return resolve11(projectRoot, worktreeDir);
|
|
13703
14194
|
}
|
|
@@ -13839,7 +14330,7 @@ function parseWorktrees(stdout) {
|
|
|
13839
14330
|
}
|
|
13840
14331
|
|
|
13841
14332
|
// packages/rafa-pr/src/cleanup/worktrees.ts
|
|
13842
|
-
var CLAUDE_WORKTREES_SUBDIR =
|
|
14333
|
+
var CLAUDE_WORKTREES_SUBDIR = join29(".claude", "worktrees");
|
|
13843
14334
|
var WORKTREE_LIST = Object.freeze(["worktree", "list", "--porcelain"]);
|
|
13844
14335
|
var GIT_DIR = Object.freeze(["rev-parse", "--absolute-git-dir"]);
|
|
13845
14336
|
var WORKTREE_STATUS = Object.freeze([
|
|
@@ -13848,7 +14339,7 @@ var WORKTREE_STATUS = Object.freeze([
|
|
|
13848
14339
|
"--porcelain=v1",
|
|
13849
14340
|
"--untracked-files=all"
|
|
13850
14341
|
]);
|
|
13851
|
-
var ADMIN_FILES = Object.freeze(["HEAD",
|
|
14342
|
+
var ADMIN_FILES = Object.freeze(["HEAD", join29("logs", "HEAD"), "index"]);
|
|
13852
14343
|
var MS_PER_DAY3 = 24 * 60 * 60 * 1000;
|
|
13853
14344
|
var LIVE_STATES = new Set(["running", "paused"]);
|
|
13854
14345
|
// packages/rafa-pr/src/commands/pr/declarations.ts
|
|
@@ -14820,11 +15311,11 @@ var DEFAULT_PR_SEAMS = Object.freeze({});
|
|
|
14820
15311
|
// packages/rafa-pr/src/commands/pr/open-pull.ts
|
|
14821
15312
|
var USAGE = PR_USAGE.open;
|
|
14822
15313
|
// packages/rafa-pr/src/docs/task-reading.ts
|
|
14823
|
-
import { homedir as
|
|
15314
|
+
import { homedir as homedir7 } from "os";
|
|
14824
15315
|
|
|
14825
15316
|
// packages/rafa/src/effort/store/stale-docs.ts
|
|
14826
15317
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
14827
|
-
import { existsSync as
|
|
15318
|
+
import { existsSync as existsSync18 } from "fs";
|
|
14828
15319
|
var STALE_DOC_KINDS = ["sighting", "unsettled"];
|
|
14829
15320
|
var INSERT_STALE_DOC = `
|
|
14830
15321
|
INSERT INTO stale_docs (
|
|
@@ -14909,7 +15400,7 @@ var SELECT_PLAN_STALE_DOCS = `
|
|
|
14909
15400
|
`;
|
|
14910
15401
|
function readStaleDocsForPlan(repoRoot, planStub) {
|
|
14911
15402
|
const path2 = sqliteStorePath(repoRoot);
|
|
14912
|
-
if (!
|
|
15403
|
+
if (!existsSync18(path2))
|
|
14913
15404
|
return [];
|
|
14914
15405
|
const rows = withSqliteStore(path2, "read", false, (db) => db.query(SELECT_PLAN_STALE_DOCS).all(planStub));
|
|
14915
15406
|
return rows.map((row) => ({
|
|
@@ -15055,7 +15546,7 @@ function fileLines(input) {
|
|
|
15055
15546
|
const more = rest > 0 ? [`- ...and ${rest} more.`] : [];
|
|
15056
15547
|
return [`The plan's commits touched these files since it left \`${base2}\`:`, ...listed2, ...more];
|
|
15057
15548
|
}
|
|
15058
|
-
function renderDocTaskSection(input, repoRoot, home =
|
|
15549
|
+
function renderDocTaskSection(input, repoRoot, home = homedir7()) {
|
|
15059
15550
|
const redact = localPathRedactor(repoRoot, home);
|
|
15060
15551
|
const lines = [DOC_TASK_HEADING, DOC_TASK_SENTENCE, ...sightingLines(input), ...fileLines(input)];
|
|
15061
15552
|
return redact(lines.join(`
|
|
@@ -15063,7 +15554,7 @@ function renderDocTaskSection(input, repoRoot, home = homedir6()) {
|
|
|
15063
15554
|
}
|
|
15064
15555
|
// packages/rafa-pr/src/plan/risk.ts
|
|
15065
15556
|
import { readFileSync as readFileSync19 } from "fs";
|
|
15066
|
-
import { isAbsolute as isAbsolute5, join as
|
|
15557
|
+
import { isAbsolute as isAbsolute5, join as join30, relative as relative8 } from "path";
|
|
15067
15558
|
|
|
15068
15559
|
// packages/rafa/src/plan/risk/secrets.ts
|
|
15069
15560
|
var SECRET_NAME_SHAPES = [
|
|
@@ -15174,8 +15665,8 @@ async function viewRepo(gh, target) {
|
|
|
15174
15665
|
}
|
|
15175
15666
|
return {
|
|
15176
15667
|
ok: true,
|
|
15177
|
-
name:
|
|
15178
|
-
visibility:
|
|
15668
|
+
name: stringField2(parsed, "nameWithOwner"),
|
|
15669
|
+
visibility: stringField2(parsed, "visibility")?.toLowerCase() ?? null
|
|
15179
15670
|
};
|
|
15180
15671
|
}
|
|
15181
15672
|
function parseJsonObject(text) {
|
|
@@ -15186,7 +15677,7 @@ function parseJsonObject(text) {
|
|
|
15186
15677
|
return null;
|
|
15187
15678
|
}
|
|
15188
15679
|
}
|
|
15189
|
-
function
|
|
15680
|
+
function stringField2(object, key) {
|
|
15190
15681
|
const value = object[key];
|
|
15191
15682
|
return typeof value === "string" && value !== "" ? value : null;
|
|
15192
15683
|
}
|
|
@@ -15255,7 +15746,7 @@ function toolsFinding(task, plan, seams) {
|
|
|
15255
15746
|
return null;
|
|
15256
15747
|
}
|
|
15257
15748
|
function displayPath(path2, seams) {
|
|
15258
|
-
const absolute = isAbsolute5(path2) ? path2 :
|
|
15749
|
+
const absolute = isAbsolute5(path2) ? path2 : join30(seams.repoRoot, path2);
|
|
15259
15750
|
const within = (root) => {
|
|
15260
15751
|
const step = relative8(root, absolute);
|
|
15261
15752
|
return step === "" || step.startsWith("..") || isAbsolute5(step) ? null : step;
|
|
@@ -15280,7 +15771,7 @@ function readText5(path2) {
|
|
|
15280
15771
|
function findSkillFile(name, seams) {
|
|
15281
15772
|
const tiers = resolveSkillTiers({ home: seams.home, projectRoot: seams.repoRoot, entry: seams.entry });
|
|
15282
15773
|
for (const { dir } of tiers) {
|
|
15283
|
-
const path2 =
|
|
15774
|
+
const path2 = join30(dir, name, "SKILL.md");
|
|
15284
15775
|
if (readText5(path2) !== null)
|
|
15285
15776
|
return path2;
|
|
15286
15777
|
}
|
|
@@ -15547,13 +16038,13 @@ async function retargetPullRequest(pull, base2, seams) {
|
|
|
15547
16038
|
return { kind: "retargeted", from, to: base2 };
|
|
15548
16039
|
}
|
|
15549
16040
|
// packages/rafa-pr/src/triage/base-run.ts
|
|
15550
|
-
import { existsSync as
|
|
16041
|
+
import { existsSync as existsSync20, mkdtempSync, readFileSync as readFileSync21, rmSync as rmSync3, symlinkSync } from "fs";
|
|
15551
16042
|
import { tmpdir } from "os";
|
|
15552
|
-
import { isAbsolute as isAbsolute7, join as
|
|
16043
|
+
import { isAbsolute as isAbsolute7, join as join32, normalize, relative as relative9, sep as sep3 } from "path";
|
|
15553
16044
|
|
|
15554
16045
|
// packages/rafa/src/suite/run.ts
|
|
15555
|
-
import { existsSync as
|
|
15556
|
-
import { basename as basename5, dirname as dirname12, extname, isAbsolute as isAbsolute6, join as
|
|
16046
|
+
import { existsSync as existsSync19, mkdirSync as mkdirSync4, readFileSync as readFileSync20, rmSync as rmSync2, writeFileSync as writeFileSync7 } from "fs";
|
|
16047
|
+
import { basename as basename5, dirname as dirname12, extname, isAbsolute as isAbsolute6, join as join31 } from "path";
|
|
15557
16048
|
|
|
15558
16049
|
// packages/rafa/src/suite/unhandled.ts
|
|
15559
16050
|
var UNHANDLED_HEADING = "# Unhandled error between tests";
|
|
@@ -15765,7 +16256,7 @@ var OUTPUT_SUFFIX = ".output.txt";
|
|
|
15765
16256
|
function outputFileFor(junitFile) {
|
|
15766
16257
|
const name = basename5(junitFile);
|
|
15767
16258
|
const stem = name.endsWith(JUNIT_SUFFIX) ? name.slice(0, -JUNIT_SUFFIX.length) : name.slice(0, name.length - extname(name).length);
|
|
15768
|
-
return
|
|
16259
|
+
return join31(dirname12(junitFile), `${stem}${OUTPUT_SUFFIX}`);
|
|
15769
16260
|
}
|
|
15770
16261
|
function suiteEnv(base2) {
|
|
15771
16262
|
return Object.fromEntries(Object.entries(base2).filter(([key]) => !SUITE_ENV_REMOVED.includes(key)));
|
|
@@ -15892,7 +16383,7 @@ function walkJunit(xml) {
|
|
|
15892
16383
|
return walk;
|
|
15893
16384
|
}
|
|
15894
16385
|
function readJunit(path2) {
|
|
15895
|
-
if (!
|
|
16386
|
+
if (!existsSync19(path2))
|
|
15896
16387
|
return { junit: "missing", failures: [], files: [], cases: [] };
|
|
15897
16388
|
let text;
|
|
15898
16389
|
try {
|
|
@@ -15975,13 +16466,13 @@ async function runInTree(tree, file, junitFile, commit, options) {
|
|
|
15975
16466
|
}
|
|
15976
16467
|
async function checkOutAndRun(tree, file, junitFile, commit, options) {
|
|
15977
16468
|
const short = shortCommit(commit);
|
|
15978
|
-
const modules =
|
|
15979
|
-
if (!
|
|
16469
|
+
const modules = join32(options.checkout, NODE_MODULES);
|
|
16470
|
+
if (!existsSync20(modules))
|
|
15980
16471
|
return failedRun(`The run checkout holds no ${NODE_MODULES} to link into the worktree at ${short}.`);
|
|
15981
|
-
if (!
|
|
16472
|
+
if (!existsSync20(join32(tree, file)))
|
|
15982
16473
|
return failedRun(`${file} does not exist at ${short}.`);
|
|
15983
16474
|
try {
|
|
15984
|
-
symlinkSync(modules,
|
|
16475
|
+
symlinkSync(modules, join32(tree, NODE_MODULES), "dir");
|
|
15985
16476
|
} catch (error) {
|
|
15986
16477
|
return failedRun(`Could not link ${NODE_MODULES} into the worktree at ${short}: ${messageOf(error)}`);
|
|
15987
16478
|
}
|
|
@@ -15999,18 +16490,18 @@ async function runFileAt(commit, file, options) {
|
|
|
15999
16490
|
const git = options.git ?? createGitRunner(options.checkout);
|
|
16000
16491
|
let scratch;
|
|
16001
16492
|
try {
|
|
16002
|
-
scratch = mkdtempSync(
|
|
16493
|
+
scratch = mkdtempSync(join32(options.tempRoot ?? tmpdir(), SCRATCH_PREFIX));
|
|
16003
16494
|
} catch (error) {
|
|
16004
16495
|
return failedRun(`Could not make a temporary folder for the worktree: ${messageOf(error)}`);
|
|
16005
16496
|
}
|
|
16006
|
-
const tree =
|
|
16497
|
+
const tree = join32(scratch, "worktree");
|
|
16007
16498
|
let added = false;
|
|
16008
16499
|
try {
|
|
16009
16500
|
const add = git(["worktree", "add", "--detach", "--quiet", tree, commit]);
|
|
16010
16501
|
if (!add.ok)
|
|
16011
16502
|
return failedRun(`Could not check out ${shortCommit(commit)} in a temporary worktree: ${gitSaid(add) || "git said nothing"}`);
|
|
16012
16503
|
added = true;
|
|
16013
|
-
return await checkOutAndRun(tree, file,
|
|
16504
|
+
return await checkOutAndRun(tree, file, join32(scratch, "base.junit.xml"), commit, options);
|
|
16014
16505
|
} catch (error) {
|
|
16015
16506
|
return failedRun(`Could not run ${file} at ${shortCommit(commit)}: ${messageOf(error)}`);
|
|
16016
16507
|
} finally {
|
|
@@ -16142,17 +16633,17 @@ function strippedText(text) {
|
|
|
16142
16633
|
const taken = text.replace(COMMIT_HASH, "").replace(FOLDER_PREFIX, "").replace(NUMBER, "");
|
|
16143
16634
|
return oneLine7(taken);
|
|
16144
16635
|
}
|
|
16145
|
-
function
|
|
16636
|
+
function keyText2(text) {
|
|
16146
16637
|
const stripped = strippedText(text);
|
|
16147
16638
|
return stripped.length > 0 ? stripped : oneLine7(text);
|
|
16148
16639
|
}
|
|
16149
16640
|
function testFailureKeyOf(failure2) {
|
|
16150
16641
|
const test = failure2.file === null ? oneLine7(failure2.name) : `${basename6(failure2.file)}${CASE_SEPARATOR}${oneLine7(failure2.name)}`;
|
|
16151
|
-
return failure2.evidence === null ? test : `${test}${KEY_SEPARATOR}${
|
|
16642
|
+
return failure2.evidence === null ? test : `${test}${KEY_SEPARATOR}${keyText2(failure2.evidence)}`;
|
|
16152
16643
|
}
|
|
16153
16644
|
function bugKeyOf(trackerPath, artifact, what = null) {
|
|
16154
16645
|
const failure2 = testFailureOf({ what, artifact });
|
|
16155
|
-
return failure2 === null ? `${basename6(trackerPath)}${KEY_SEPARATOR}${
|
|
16646
|
+
return failure2 === null ? `${basename6(trackerPath)}${KEY_SEPARATOR}${keyText2(artifact)}` : testFailureKeyOf(failure2);
|
|
16156
16647
|
}
|
|
16157
16648
|
function legacyBugKeyOf(trackerPath, artifact) {
|
|
16158
16649
|
return `${basename6(trackerPath)}${KEY_SEPARATOR}${oneLine7(artifact)}`;
|
|
@@ -16171,7 +16662,7 @@ function sameFailure(failure2, baseline) {
|
|
|
16171
16662
|
const message = baseline.message ?? null;
|
|
16172
16663
|
if (!sameTest || !hasText(message))
|
|
16173
16664
|
return sameTest;
|
|
16174
|
-
return evidence !== null &&
|
|
16665
|
+
return evidence !== null && keyText2(evidence).includes(keyText2(message));
|
|
16175
16666
|
}
|
|
16176
16667
|
function inheritedFailureOf(bug, failures) {
|
|
16177
16668
|
const failure2 = testFailureOf(bug);
|
|
@@ -16900,8 +17391,8 @@ function rankedCandidates(report2, record, openBugs, weights) {
|
|
|
16900
17391
|
return [...ranked].sort((a, b) => b.score - a.score);
|
|
16901
17392
|
}
|
|
16902
17393
|
// packages/rafa-pr/src/triage/triage.ts
|
|
16903
|
-
import { homedir as
|
|
16904
|
-
import { join as
|
|
17394
|
+
import { homedir as homedir8 } from "os";
|
|
17395
|
+
import { join as join34 } from "path";
|
|
16905
17396
|
|
|
16906
17397
|
// packages/rafa/src/effort/store/machine-fault.ts
|
|
16907
17398
|
var BUILD_FAILURE = /\b(?:abort(?:ed|s)?|broke|broken|crash(?:ed|es)?|error|errors|fail(?:ed|ing|s|ure|ures)?|unusable)\b/iu;
|
|
@@ -16967,7 +17458,7 @@ function machineFaultSentence(fault) {
|
|
|
16967
17458
|
|
|
16968
17459
|
// packages/rafa/src/effort/store/tracker-refs.ts
|
|
16969
17460
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
16970
|
-
import { existsSync as
|
|
17461
|
+
import { existsSync as existsSync21 } from "fs";
|
|
16971
17462
|
var SELECT_HELD2 = `
|
|
16972
17463
|
SELECT seq, tracker_ref FROM findings
|
|
16973
17464
|
WHERE session_id = ? AND artifact = ?
|
|
@@ -17116,7 +17607,7 @@ function writeTrackerRef(repoRoot, write, seams = {}) {
|
|
|
17116
17607
|
wanted.json,
|
|
17117
17608
|
collectedAt
|
|
17118
17609
|
];
|
|
17119
|
-
const [action, stored] = withSqliteStore(path2, "write", !
|
|
17610
|
+
const [action, stored] = withSqliteStore(path2, "write", !existsSync21(path2), (db) => {
|
|
17120
17611
|
const place = db.transaction(() => placeRef(db, path2, write, wanted, superseded, insertValues));
|
|
17121
17612
|
return place.immediate();
|
|
17122
17613
|
});
|
|
@@ -17125,7 +17616,7 @@ function writeTrackerRef(repoRoot, write, seams = {}) {
|
|
|
17125
17616
|
function readTrackerRef(repoRoot, artifact) {
|
|
17126
17617
|
checkArtifact2("read", artifact);
|
|
17127
17618
|
const path2 = sqliteStorePath(repoRoot);
|
|
17128
|
-
if (!
|
|
17619
|
+
if (!existsSync21(path2))
|
|
17129
17620
|
return null;
|
|
17130
17621
|
const newest = withSqliteStore(path2, "read", false, (db) => db.query(SELECT_NEWEST).get(artifact));
|
|
17131
17622
|
return newest === null ? null : heldRefOf(path2, newest.seq, newest.tracker_ref).ref;
|
|
@@ -17135,10 +17626,10 @@ function readTrackerRef(repoRoot, artifact) {
|
|
|
17135
17626
|
import { relative as relative11, resolve as resolve14, sep as sep4 } from "path";
|
|
17136
17627
|
|
|
17137
17628
|
// packages/rafa/src/project/package-of.ts
|
|
17138
|
-
import { existsSync as
|
|
17139
|
-
import { dirname as dirname13, isAbsolute as isAbsolute9, join as
|
|
17629
|
+
import { existsSync as existsSync22, readFileSync as readFileSync23 } from "fs";
|
|
17630
|
+
import { dirname as dirname13, isAbsolute as isAbsolute9, join as join33, relative as relative10, resolve as resolve13 } from "path";
|
|
17140
17631
|
var DISK_PACKAGE_FILE_SYSTEM = Object.freeze({
|
|
17141
|
-
exists: (path2) =>
|
|
17632
|
+
exists: (path2) => existsSync22(path2),
|
|
17142
17633
|
readFile: (path2) => readFileSync23(path2, "utf8")
|
|
17143
17634
|
});
|
|
17144
17635
|
var PACKAGE_MANIFESTS = Object.freeze(["package.json"]);
|
|
@@ -17150,7 +17641,7 @@ function textOrNull2(value) {
|
|
|
17150
17641
|
return typeof value === "string" && value.trim() !== "" ? value : null;
|
|
17151
17642
|
}
|
|
17152
17643
|
function ownerAt(dir, root, fs2) {
|
|
17153
|
-
const file = PACKAGE_MANIFESTS.map((name) =>
|
|
17644
|
+
const file = PACKAGE_MANIFESTS.map((name) => join33(dir, name)).find((path2) => fs2.exists(path2));
|
|
17154
17645
|
if (file === undefined)
|
|
17155
17646
|
return null;
|
|
17156
17647
|
try {
|
|
@@ -17412,10 +17903,10 @@ function triageStaleDocs(staleDocs, redact) {
|
|
|
17412
17903
|
}
|
|
17413
17904
|
|
|
17414
17905
|
// packages/rafa-pr/src/triage/triage.ts
|
|
17415
|
-
var PRIVATE_TRIAGE_DIR =
|
|
17906
|
+
var PRIVATE_TRIAGE_DIR = join34(".rafa", "triage", "private");
|
|
17416
17907
|
var BLOCKER_SEPARATOR = "; ";
|
|
17417
17908
|
function privateTriageDir(repoRoot) {
|
|
17418
|
-
return
|
|
17909
|
+
return join34(repoRoot, PRIVATE_TRIAGE_DIR);
|
|
17419
17910
|
}
|
|
17420
17911
|
function createPrivateTriageTracker(repoRoot, options = {}) {
|
|
17421
17912
|
return createLocalTracker({
|
|
@@ -17661,7 +18152,7 @@ async function triageReport(options) {
|
|
|
17661
18152
|
checkPrivateTracker(options.tracker, privateTracker);
|
|
17662
18153
|
const blocker = triageBlockers(options);
|
|
17663
18154
|
const checkout = options.checkout ?? repoRoot;
|
|
17664
|
-
const local = localPathRedactor([checkout, repoRoot], options.home ??
|
|
18155
|
+
const local = localPathRedactor([checkout, repoRoot], options.home ?? homedir8());
|
|
17665
18156
|
const redact = (text) => redactSecrets(local(text), options.secrets);
|
|
17666
18157
|
const verifyRefs = options.verifyRefs ?? createArtifactRefsVerifier(checkout, options.env);
|
|
17667
18158
|
const routes = {
|
|
@@ -17717,7 +18208,7 @@ async function triageReport(options) {
|
|
|
17717
18208
|
return { blocker, bugs, staleDocs: triageStaleDocs(options.report.staleDocs, redact) };
|
|
17718
18209
|
}
|
|
17719
18210
|
// packages/rafa-run/src/claims/device.ts
|
|
17720
|
-
import { existsSync as
|
|
18211
|
+
import { existsSync as existsSync23 } from "fs";
|
|
17721
18212
|
var NO_CLAIMANT = "no claim can name this device";
|
|
17722
18213
|
function ndjsonReason() {
|
|
17723
18214
|
return "this project's effort store is NDJSON (store: ndjson), which records no store id," + ` so ${NO_CLAIMANT}. Next safe step: ${MOVE_TO_SQLITE}`;
|
|
@@ -17732,7 +18223,7 @@ function readDeviceStoreId(repoRoot, config) {
|
|
|
17732
18223
|
if (config.store === "ndjson")
|
|
17733
18224
|
return { ok: false, cause: "ndjson", reason: ndjsonReason() };
|
|
17734
18225
|
const path2 = sqliteStorePath(repoRoot);
|
|
17735
|
-
if (!
|
|
18226
|
+
if (!existsSync23(path2))
|
|
17736
18227
|
return { ok: false, cause: "absent", reason: absentReason(path2) };
|
|
17737
18228
|
const ids = withSqliteStore(path2, "read", false, (db) => {
|
|
17738
18229
|
const meta = readStoreMeta(db);
|
|
@@ -18122,7 +18613,7 @@ var REMOTE_BRANCH_FORMAT = [
|
|
|
18122
18613
|
|
|
18123
18614
|
// packages/rafa-run/src/start/loop-events.ts
|
|
18124
18615
|
import { appendFileSync, mkdirSync as mkdirSync5 } from "fs";
|
|
18125
|
-
import { join as
|
|
18616
|
+
import { join as join35 } from "path";
|
|
18126
18617
|
|
|
18127
18618
|
// packages/rafa-run/src/start/suite-blocker.ts
|
|
18128
18619
|
import { readFileSync as readFileSync24, writeFileSync as writeFileSync8 } from "fs";
|
|
@@ -18443,7 +18934,7 @@ function eventsFilePath(root, sessionId) {
|
|
|
18443
18934
|
if (!isSessionId(sessionId)) {
|
|
18444
18935
|
throw new Error(`events file: unusable session id ${JSON.stringify(sessionId)}`);
|
|
18445
18936
|
}
|
|
18446
|
-
return
|
|
18937
|
+
return join35(runsDir(root), `${sessionId}${EVENTS_EXTENSION}`);
|
|
18447
18938
|
}
|
|
18448
18939
|
function bindEventsFile(root, sessionId, warn2 = (line) => {
|
|
18449
18940
|
process.stderr.write(line);
|
|
@@ -18494,7 +18985,7 @@ function injectionPlace(trackerContent, taskInfo) {
|
|
|
18494
18985
|
}
|
|
18495
18986
|
async function taskTokens(checkout, sessionId, home) {
|
|
18496
18987
|
try {
|
|
18497
|
-
const { usage } = await readSessionLog(
|
|
18988
|
+
const { usage } = await readSessionLog(join35(sessionLogDir(checkout, home), `${sessionId}.jsonl`));
|
|
18498
18989
|
return usage.inputTokens + usage.cacheCreationInputTokens + usage.outputTokens;
|
|
18499
18990
|
} catch {
|
|
18500
18991
|
return null;
|
|
@@ -18747,7 +19238,7 @@ var USAGE2 = "rafa switch <n | -> [--no-rehome]";
|
|
|
18747
19238
|
var SWITCH_REFUSAL_EXIT = 2;
|
|
18748
19239
|
var BACK = "-";
|
|
18749
19240
|
var REHOME_FLAG = "rehome";
|
|
18750
|
-
var
|
|
19241
|
+
var ISSUE_NUMBER4 = /^[1-9]\d*$/u;
|
|
18751
19242
|
function refusal3(message) {
|
|
18752
19243
|
return new CommandExit(SWITCH_REFUSAL_EXIT, `\u274C ${message}`);
|
|
18753
19244
|
}
|
|
@@ -18762,7 +19253,7 @@ function readSwitchTarget(args) {
|
|
|
18762
19253
|
throw lineRefusal(`Expected one target, got ${String(args.length)}: ${args.join(" ")}`, USAGE2);
|
|
18763
19254
|
if (word === BACK)
|
|
18764
19255
|
return { kind: "back" };
|
|
18765
|
-
if (!
|
|
19256
|
+
if (!ISSUE_NUMBER4.test(word)) {
|
|
18766
19257
|
throw lineRefusal(`"${word}" is no issue number, which is a whole number from 1, nor - for the previous place`, USAGE2);
|
|
18767
19258
|
}
|
|
18768
19259
|
return { kind: "number", number: Number(word) };
|
|
@@ -19113,11 +19604,11 @@ function parseArgs(argv, spec = {}) {
|
|
|
19113
19604
|
import { rmSync as rmSync5 } from "fs";
|
|
19114
19605
|
|
|
19115
19606
|
// packages/rafa-run/src/plan/list.ts
|
|
19116
|
-
import { existsSync as
|
|
19117
|
-
import { join as
|
|
19607
|
+
import { existsSync as existsSync24, readdirSync as readdirSync8, readFileSync as readFileSync25 } from "fs";
|
|
19608
|
+
import { join as join36 } from "path";
|
|
19118
19609
|
function listing(dir, stub) {
|
|
19119
|
-
const plan =
|
|
19120
|
-
const trackerPath =
|
|
19610
|
+
const plan = join36(dir, planFileName(stub, false));
|
|
19611
|
+
const trackerPath = join36(dir, planFileName(stub, true));
|
|
19121
19612
|
const tracker = isFile(trackerPath) ? trackerPath : null;
|
|
19122
19613
|
const planModel = parsePlan(readFileSync25(plan, "utf8"));
|
|
19123
19614
|
const counted4 = tracker === null ? planModel : parsePlan(readFileSync25(tracker, "utf8"));
|
|
@@ -19125,9 +19616,9 @@ function listing(dir, stub) {
|
|
|
19125
19616
|
}
|
|
19126
19617
|
function listPlans(plans) {
|
|
19127
19618
|
const dir = plans.path;
|
|
19128
|
-
if (!
|
|
19619
|
+
if (!existsSync24(dir))
|
|
19129
19620
|
return { dir, plans: [] };
|
|
19130
|
-
const stubs = readdirSync8(dir).filter((name) => isFile(
|
|
19621
|
+
const stubs = readdirSync8(dir).filter((name) => isFile(join36(dir, name))).map((name) => stubOfPlanFile(name)).filter((stub) => stub !== null).sort((a, b) => a.localeCompare(b));
|
|
19131
19622
|
return { dir, plans: stubs.map((stub) => listing(dir, stub)) };
|
|
19132
19623
|
}
|
|
19133
19624
|
|
|
@@ -19276,6 +19767,22 @@ function hasStartedBranch(sources, remote, refs, stub, note) {
|
|
|
19276
19767
|
return messages === null || !claimsOnly(messages);
|
|
19277
19768
|
});
|
|
19278
19769
|
}
|
|
19770
|
+
async function readMergedHeads(sources, note) {
|
|
19771
|
+
try {
|
|
19772
|
+
const merged = await sources.pulls.listMerged();
|
|
19773
|
+
return new Set(merged.map((pull) => pull.headRefName));
|
|
19774
|
+
} catch (error) {
|
|
19775
|
+
const said = messageOf(error).replace(/\s+/g, " ").trim();
|
|
19776
|
+
note(`the merged pull requests could not be read from the provider, so a plan whose branch merged from another clone may be offered again: ${said}`);
|
|
19777
|
+
return new Set;
|
|
19778
|
+
}
|
|
19779
|
+
}
|
|
19780
|
+
function firstUnmerged(sources, plans, first, merged, unstarted) {
|
|
19781
|
+
const isMerged = (plan) => merged.has(branchNameFor(plan.stub, sources.branchTemplate));
|
|
19782
|
+
if (!isMerged(first))
|
|
19783
|
+
return first;
|
|
19784
|
+
return plans.slice(plans.indexOf(first) + 1).find((plan) => !isMerged(plan) && unstarted(plan)) ?? null;
|
|
19785
|
+
}
|
|
19279
19786
|
function openWorld(sources) {
|
|
19280
19787
|
let problems = [];
|
|
19281
19788
|
const note = (problem) => {
|
|
@@ -19292,6 +19799,9 @@ function openWorld(sources) {
|
|
|
19292
19799
|
return reading;
|
|
19293
19800
|
});
|
|
19294
19801
|
const checkout = once(() => readCheckout(sources, note));
|
|
19802
|
+
const unstarted = (plan) => !hasRun(runs(), plan.stub) && !hasStartedBranch(sources, remote, refs(), plan.stub, note);
|
|
19803
|
+
const unstartedPlan = once(() => plans().find(unstarted) ?? null);
|
|
19804
|
+
const mergedHeads = once(() => readMergedHeads(sources, note));
|
|
19295
19805
|
return {
|
|
19296
19806
|
sources,
|
|
19297
19807
|
remote,
|
|
@@ -19302,7 +19812,13 @@ function openWorld(sources) {
|
|
|
19302
19812
|
tracked: once(() => readTracked(sources, note)),
|
|
19303
19813
|
checkout,
|
|
19304
19814
|
branchPlan: once(() => readBranchPlan(branch(), plans(), sources.branchTemplate)),
|
|
19305
|
-
unstartedPlan
|
|
19815
|
+
unstartedPlan,
|
|
19816
|
+
unmergedPlan: once(async () => {
|
|
19817
|
+
const first = unstartedPlan();
|
|
19818
|
+
if (first === null)
|
|
19819
|
+
return null;
|
|
19820
|
+
return firstUnmerged(sources, plans(), first, await mergedHeads(), unstarted);
|
|
19821
|
+
}),
|
|
19306
19822
|
openPull: once(() => readOpenPull(sources, branch(), note)),
|
|
19307
19823
|
roadmap,
|
|
19308
19824
|
picked: once(async () => {
|
|
@@ -20116,10 +20632,10 @@ async function readPrGreen(world) {
|
|
|
20116
20632
|
pullRequest: open.summary.number
|
|
20117
20633
|
};
|
|
20118
20634
|
}
|
|
20119
|
-
function readPlanUnstarted(world) {
|
|
20635
|
+
async function readPlanUnstarted(world) {
|
|
20120
20636
|
if (!onBase(world))
|
|
20121
20637
|
return null;
|
|
20122
|
-
const plan = world.
|
|
20638
|
+
const plan = await world.unmergedPlan();
|
|
20123
20639
|
if (plan === null)
|
|
20124
20640
|
return null;
|
|
20125
20641
|
return {
|
|
@@ -20483,14 +20999,14 @@ function isFirstDispatch(planPath) {
|
|
|
20483
20999
|
return tracker === null || !hasTickedTask(tracker);
|
|
20484
21000
|
}
|
|
20485
21001
|
// packages/rafa/src/project/bin-path.ts
|
|
20486
|
-
import { delimiter as delimiter2, isAbsolute as isAbsolute10, join as
|
|
20487
|
-
var RAFA_BIN_DIR =
|
|
20488
|
-
var BUN_BIN_DIR =
|
|
21002
|
+
import { delimiter as delimiter2, isAbsolute as isAbsolute10, join as join37, resolve as resolve15 } from "path";
|
|
21003
|
+
var RAFA_BIN_DIR = join37(SCOPE_DIR, "bin");
|
|
21004
|
+
var BUN_BIN_DIR = join37(".bun", "bin");
|
|
20489
21005
|
|
|
20490
21006
|
// packages/rafa-run/src/start/runtime.ts
|
|
20491
|
-
import { existsSync as
|
|
20492
|
-
import { homedir as
|
|
20493
|
-
import { isAbsolute as isAbsolute11, join as
|
|
21007
|
+
import { existsSync as existsSync25, readdirSync as readdirSync9, realpathSync as realpathSync2, statSync as statSync8 } from "fs";
|
|
21008
|
+
import { homedir as homedir9 } from "os";
|
|
21009
|
+
import { isAbsolute as isAbsolute11, join as join38, relative as relative13, resolve as resolve16, sep as sep5 } from "path";
|
|
20494
21010
|
|
|
20495
21011
|
// packages/rafa-run/src/start/session.ts
|
|
20496
21012
|
import { randomUUID as randomUUID6 } from "crypto";
|
|
@@ -20736,7 +21252,7 @@ function resolveRuntime(value, places) {
|
|
|
20736
21252
|
throw refusal4([`\u274C Refusing to start: \`--runtime\` names no runtime. Spell it ${SPELLING}.`]);
|
|
20737
21253
|
}
|
|
20738
21254
|
const isVersion = VERSION_SHAPE2.test(value);
|
|
20739
|
-
const named = isVersion ?
|
|
21255
|
+
const named = isVersion ? join38(places.home, RUNTIME_SUBDIR, value, RUNTIME_ENTRY) : resolve16(places.cwd, value);
|
|
20740
21256
|
refuseInsideSource(value, named, places);
|
|
20741
21257
|
const entry = entryOf2(value, named, isVersion, places.home);
|
|
20742
21258
|
const real = realpathSync2(entry);
|
|
@@ -20747,7 +21263,7 @@ function entryOf2(value, named, isVersion, home) {
|
|
|
20747
21263
|
if (isVersion) {
|
|
20748
21264
|
if (isFile4(named))
|
|
20749
21265
|
return named;
|
|
20750
|
-
const root =
|
|
21266
|
+
const root = join38(home, RUNTIME_SUBDIR);
|
|
20751
21267
|
const installed = installedVersions(root);
|
|
20752
21268
|
throw refusal4([
|
|
20753
21269
|
`\u274C Refusing to start: \`--runtime=${value}\` names no installed runtime: ${named} is no file.`,
|
|
@@ -20756,7 +21272,7 @@ function entryOf2(value, named, isVersion, home) {
|
|
|
20756
21272
|
}
|
|
20757
21273
|
if (isFile4(named))
|
|
20758
21274
|
return named;
|
|
20759
|
-
const inside =
|
|
21275
|
+
const inside = join38(named, RUNTIME_ENTRY);
|
|
20760
21276
|
if (isDirectory(named) && isFile4(inside))
|
|
20761
21277
|
return inside;
|
|
20762
21278
|
throw refusal4([
|
|
@@ -20774,8 +21290,8 @@ function refuseInsideSource(value, path3, places) {
|
|
|
20774
21290
|
]);
|
|
20775
21291
|
}
|
|
20776
21292
|
function sourceDirs({ cwd, root }) {
|
|
20777
|
-
const dirs = [
|
|
20778
|
-
const real = dirs.filter((dir) =>
|
|
21293
|
+
const dirs = [join38(cwd, SOURCE_DIR), join38(root, SOURCE_DIR)];
|
|
21294
|
+
const real = dirs.filter((dir) => existsSync25(dir)).map((dir) => realpathSync2(dir));
|
|
20779
21295
|
return [...new Set([...dirs, ...real])];
|
|
20780
21296
|
}
|
|
20781
21297
|
function isInside3(path3, dir) {
|
|
@@ -20784,7 +21300,7 @@ function isInside3(path3, dir) {
|
|
|
20784
21300
|
}
|
|
20785
21301
|
function installedVersions(root) {
|
|
20786
21302
|
try {
|
|
20787
|
-
return readdirSync9(root).filter((name) => isFile4(
|
|
21303
|
+
return readdirSync9(root).filter((name) => isFile4(join38(root, name, RUNTIME_ENTRY))).sort((a, b) => a.localeCompare(b));
|
|
20788
21304
|
} catch {
|
|
20789
21305
|
return [];
|
|
20790
21306
|
}
|
|
@@ -20812,7 +21328,7 @@ async function runFromSelectedRuntime(seams) {
|
|
|
20812
21328
|
if (value === undefined)
|
|
20813
21329
|
return false;
|
|
20814
21330
|
const cwd = seams.cwd ?? process.cwd();
|
|
20815
|
-
const entry = resolveRuntime(value, { cwd, root: seams.root, home: seams.home ??
|
|
21331
|
+
const entry = resolveRuntime(value, { cwd, root: seams.root, home: seams.home ?? homedir9() });
|
|
20816
21332
|
if (realOrResolved(seams.currentEntry ?? Bun.main) === entry)
|
|
20817
21333
|
return false;
|
|
20818
21334
|
const mode = activeOutputMode();
|
|
@@ -20944,12 +21460,12 @@ function markBudgetExit(options) {
|
|
|
20944
21460
|
activeOutput().error(" Raise its budget= or split it, then run again to retry.");
|
|
20945
21461
|
}
|
|
20946
21462
|
// packages/rafa-run/src/start/checkout-guard.ts
|
|
20947
|
-
import { existsSync as
|
|
21463
|
+
import { existsSync as existsSync26, realpathSync as realpathSync3 } from "fs";
|
|
20948
21464
|
var CHECKOUT_MOVED = "checkout moved";
|
|
20949
21465
|
var INDENT = " ";
|
|
20950
21466
|
var SHORT_COMMIT2 = 12;
|
|
20951
21467
|
function realDirOf(path3) {
|
|
20952
|
-
if (!
|
|
21468
|
+
if (!existsSync26(path3))
|
|
20953
21469
|
return null;
|
|
20954
21470
|
try {
|
|
20955
21471
|
return realpathSync3(path3);
|
|
@@ -21414,8 +21930,8 @@ function parseDecision(output) {
|
|
|
21414
21930
|
}
|
|
21415
21931
|
|
|
21416
21932
|
// packages/rafa-run/src/start/decision-prompt.ts
|
|
21417
|
-
import { existsSync as
|
|
21418
|
-
import { dirname as dirname14, join as
|
|
21933
|
+
import { existsSync as existsSync27, readFileSync as readFileSync28 } from "fs";
|
|
21934
|
+
import { dirname as dirname14, join as join39, resolve as resolve17 } from "path";
|
|
21419
21935
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
21420
21936
|
var MODULE_DIR4 = dirname14(fileURLToPath4(import.meta.url));
|
|
21421
21937
|
var DECISION_PROMPT_FILE = "continue-decision-prompt.md";
|
|
@@ -21439,18 +21955,18 @@ function chooseRetrySections(template, retriesLeft) {
|
|
|
21439
21955
|
var NO_HOLDS = "(no reason was recorded)";
|
|
21440
21956
|
var NO_OPEN_TASKS = "(no open task is left)";
|
|
21441
21957
|
function bundledCandidates(file, moduleDir = MODULE_DIR4) {
|
|
21442
|
-
return [
|
|
21958
|
+
return [join39(moduleDir, file), join39(moduleDir, "..", "..", "..", "..", "src", file)];
|
|
21443
21959
|
}
|
|
21444
21960
|
function readBundledFile(file, moduleDir = MODULE_DIR4) {
|
|
21445
21961
|
const candidates = bundledCandidates(file, moduleDir);
|
|
21446
|
-
const found = candidates.find((candidate) =>
|
|
21962
|
+
const found = candidates.find((candidate) => existsSync27(candidate));
|
|
21447
21963
|
if (found === undefined) {
|
|
21448
21964
|
throw new Error(`loop continue: ${file} is missing: no file at ${candidates.join(" or ")}`);
|
|
21449
21965
|
}
|
|
21450
21966
|
return readFileSync28(found, "utf8");
|
|
21451
21967
|
}
|
|
21452
21968
|
function readProjectFile(path3) {
|
|
21453
|
-
if (!
|
|
21969
|
+
if (!existsSync27(path3))
|
|
21454
21970
|
return { text: null };
|
|
21455
21971
|
try {
|
|
21456
21972
|
return { text: readFileSync28(path3, "utf8") };
|
|
@@ -21641,7 +22157,7 @@ class LoopEnd extends CommandExit {
|
|
|
21641
22157
|
}
|
|
21642
22158
|
}
|
|
21643
22159
|
// packages/rafa-run/src/start/continue-run.ts
|
|
21644
|
-
import { existsSync as
|
|
22160
|
+
import { existsSync as existsSync28, readFileSync as readFileSync29 } from "fs";
|
|
21645
22161
|
|
|
21646
22162
|
// packages/rafa-run/src/start/decision-session.ts
|
|
21647
22163
|
import { randomUUID as randomUUID7 } from "crypto";
|
|
@@ -21834,7 +22350,7 @@ function whenOf(stop) {
|
|
|
21834
22350
|
function openingList(seed, trackerPath) {
|
|
21835
22351
|
if (seed.length === 0)
|
|
21836
22352
|
return seed;
|
|
21837
|
-
const kept =
|
|
22353
|
+
const kept = existsSync28(trackerPath) ? seedFrom(seed, readFileSync29(trackerPath, "utf8")) : [];
|
|
21838
22354
|
const back = seed.length - kept.length;
|
|
21839
22355
|
if (back > 0) {
|
|
21840
22356
|
activeOutput().info(`\u21A9\uFE0F ${back} task(s) the last --continue run passed over no longer read [BLOCKED], so this run takes them again.`);
|
|
@@ -22131,7 +22647,7 @@ import { randomUUID as randomUUID11 } from "crypto";
|
|
|
22131
22647
|
|
|
22132
22648
|
// packages/rafa/src/effort/store/absences.ts
|
|
22133
22649
|
import { randomUUID as randomUUID8 } from "crypto";
|
|
22134
|
-
import { existsSync as
|
|
22650
|
+
import { existsSync as existsSync29 } from "fs";
|
|
22135
22651
|
var ABSENCE_REASONS = {
|
|
22136
22652
|
"no-block": true,
|
|
22137
22653
|
"unclosed-block": true,
|
|
@@ -22191,7 +22707,7 @@ function writeReportAbsence(repoRoot, write, seams = {}) {
|
|
|
22191
22707
|
write.outcome,
|
|
22192
22708
|
collectedAt
|
|
22193
22709
|
];
|
|
22194
|
-
const appended2 = withSqliteStore(path3, "write", !
|
|
22710
|
+
const appended2 = withSqliteStore(path3, "write", !existsSync29(path3), (db) => db.query(INSERT_ABSENCE).run(...values).changes);
|
|
22195
22711
|
return { path: path3, appended: appended2, skipped: 1 - appended2 };
|
|
22196
22712
|
}
|
|
22197
22713
|
|
|
@@ -22356,8 +22872,8 @@ function describeTaskReportRecord(record) {
|
|
|
22356
22872
|
}
|
|
22357
22873
|
|
|
22358
22874
|
// packages/rafa/src/utils/progress.ts
|
|
22359
|
-
import { existsSync as
|
|
22360
|
-
import { join as
|
|
22875
|
+
import { existsSync as existsSync30, writeFileSync as writeFileSync9 } from "fs";
|
|
22876
|
+
import { join as join40 } from "path";
|
|
22361
22877
|
var PROGRESS_FILE_NAME = "progress.txt";
|
|
22362
22878
|
var PROGRESS_CAP_BYTES = 16000;
|
|
22363
22879
|
var LISTED_FIELDS = [
|
|
@@ -22399,7 +22915,7 @@ var ESCAPED_CODE_POINTS = new Set([
|
|
|
22399
22915
|
8233
|
|
22400
22916
|
]);
|
|
22401
22917
|
function progressFilePath(repoRoot) {
|
|
22402
|
-
return
|
|
22918
|
+
return join40(repoRoot, PROGRESS_FILE_NAME);
|
|
22403
22919
|
}
|
|
22404
22920
|
function escapeValue(value) {
|
|
22405
22921
|
let escaped = "";
|
|
@@ -22460,7 +22976,7 @@ function renderProgressText(findings, capBytes = PROGRESS_CAP_BYTES) {
|
|
|
22460
22976
|
}
|
|
22461
22977
|
function readProgressFindings(repoRoot, planStub) {
|
|
22462
22978
|
const path3 = sqliteStorePath(repoRoot);
|
|
22463
|
-
if (!
|
|
22979
|
+
if (!existsSync30(path3))
|
|
22464
22980
|
return [];
|
|
22465
22981
|
const rows = withSqliteStore(path3, "read", false, (db) => {
|
|
22466
22982
|
const query = db.query(SELECT_FINDINGS2);
|
|
@@ -22581,17 +23097,17 @@ function renderInheritedSection(failures) {
|
|
|
22581
23097
|
|
|
22582
23098
|
// packages/rafa-run/src/start/preflight.ts
|
|
22583
23099
|
import { randomUUID as randomUUID10 } from "crypto";
|
|
22584
|
-
import { existsSync as
|
|
22585
|
-
import { homedir as
|
|
22586
|
-
import { basename as basename10, join as
|
|
23100
|
+
import { existsSync as existsSync32, readFileSync as readFileSync30 } from "fs";
|
|
23101
|
+
import { homedir as homedir10 } from "os";
|
|
23102
|
+
import { basename as basename10, join as join41 } from "path";
|
|
22587
23103
|
|
|
22588
23104
|
// packages/rafa/src/effort/store/schema-report.ts
|
|
22589
|
-
import { existsSync as
|
|
23105
|
+
import { existsSync as existsSync31 } from "fs";
|
|
22590
23106
|
import { Database } from "bun:sqlite";
|
|
22591
23107
|
var NO_NEXT_STEP = "none";
|
|
22592
23108
|
function readSchemaReport(path3, options = {}) {
|
|
22593
23109
|
guardTestProcess(path3);
|
|
22594
|
-
if (!
|
|
23110
|
+
if (!existsSync31(path3))
|
|
22595
23111
|
return absentReport(path3);
|
|
22596
23112
|
const catalogue = sqliteCatalogue(options.migrations ?? SQLITE_MIGRATIONS);
|
|
22597
23113
|
const store = readReadOnly(path3);
|
|
@@ -22981,7 +23497,7 @@ function knownMissingNotice(lines) {
|
|
|
22981
23497
|
}
|
|
22982
23498
|
function agentSourcePath(planPath) {
|
|
22983
23499
|
const tracker = trackerPathFor(planPath);
|
|
22984
|
-
return
|
|
23500
|
+
return existsSync32(tracker) ? tracker : planPath;
|
|
22985
23501
|
}
|
|
22986
23502
|
function readIfReadable2(path3) {
|
|
22987
23503
|
try {
|
|
@@ -23013,7 +23529,7 @@ function refuseUnresolvableAgents(options) {
|
|
|
23013
23529
|
};
|
|
23014
23530
|
const roots = {
|
|
23015
23531
|
repoRoot: options.repoRoot,
|
|
23016
|
-
home: agents.home ??
|
|
23532
|
+
home: agents.home ?? homedir10(),
|
|
23017
23533
|
...agents.entry === undefined ? {} : { entry: agents.entry }
|
|
23018
23534
|
};
|
|
23019
23535
|
const roster = resolveAgentRoster(roots, settings);
|
|
@@ -23137,7 +23653,7 @@ function announceReminders(planPath, reminders) {
|
|
|
23137
23653
|
function announceUnknownMigrations(repoRoot) {
|
|
23138
23654
|
const output = activeOutput();
|
|
23139
23655
|
try {
|
|
23140
|
-
const report2 = readSchemaReport(
|
|
23656
|
+
const report2 = readSchemaReport(join41(effortStoreDir(repoRoot), SQLITE_STORE_FILE_NAME));
|
|
23141
23657
|
for (const migration of unknownAdditive(report2))
|
|
23142
23658
|
output.warn(unknownAdditiveWarning(migration));
|
|
23143
23659
|
} catch (error) {
|
|
@@ -23209,9 +23725,9 @@ async function runStartPreflight(options) {
|
|
|
23209
23725
|
}
|
|
23210
23726
|
|
|
23211
23727
|
// packages/rafa-run/src/start/type-step.ts
|
|
23212
|
-
import { closeSync as closeSync2, existsSync as
|
|
23728
|
+
import { closeSync as closeSync2, existsSync as existsSync33, mkdtempSync as mkdtempSync2, openSync as openSync2, readSync as readSync2, realpathSync as realpathSync4, rmSync as rmSync6, symlinkSync as symlinkSync2, writeFileSync as writeFileSync10 } from "fs";
|
|
23213
23729
|
import { tmpdir as tmpdir2 } from "os";
|
|
23214
|
-
import { basename as basename11, dirname as dirname15, join as
|
|
23730
|
+
import { basename as basename11, dirname as dirname15, join as join42, relative as relative14, resolve as resolve18, sep as sep6 } from "path";
|
|
23215
23731
|
var TEST_FILE_SUFFIX = ".test.ts";
|
|
23216
23732
|
var TSC_FLAGS = ["--noEmit", "--pretty", "false"];
|
|
23217
23733
|
var CANNOT_START_CODES = [126, 127];
|
|
@@ -23285,8 +23801,8 @@ function findNodeModules(checkout, git) {
|
|
|
23285
23801
|
const stop = walkStop(git);
|
|
23286
23802
|
const top = stop !== null && isUnder(start, stop) ? stop : start;
|
|
23287
23803
|
for (let dir = start;; dir = dirname15(dir)) {
|
|
23288
|
-
const modules =
|
|
23289
|
-
if (
|
|
23804
|
+
const modules = join42(dir, NODE_MODULES2);
|
|
23805
|
+
if (existsSync33(join42(modules, ...TSC_BIN)))
|
|
23290
23806
|
return modules;
|
|
23291
23807
|
if (dir === top || dirname15(dir) === dir)
|
|
23292
23808
|
return null;
|
|
@@ -23295,9 +23811,9 @@ function findNodeModules(checkout, git) {
|
|
|
23295
23811
|
function scratchTsconfigFields(tree, files, modules) {
|
|
23296
23812
|
const root = resolve18(tree);
|
|
23297
23813
|
return {
|
|
23298
|
-
extends:
|
|
23299
|
-
compilerOptions: { typeRoots: [
|
|
23300
|
-
files: files.map((file) =>
|
|
23814
|
+
extends: join42(root, "tsconfig.json"),
|
|
23815
|
+
compilerOptions: { typeRoots: [join42(resolve18(modules), "@types")] },
|
|
23816
|
+
files: files.map((file) => join42(root, file)),
|
|
23301
23817
|
include: []
|
|
23302
23818
|
};
|
|
23303
23819
|
}
|
|
@@ -23306,13 +23822,13 @@ function scratchTsconfig(tree, files, modules) {
|
|
|
23306
23822
|
`;
|
|
23307
23823
|
}
|
|
23308
23824
|
function tscArgv(modules, scratch) {
|
|
23309
|
-
return [
|
|
23825
|
+
return [join42(modules, ...TSC_BIN), "-p", scratch, ...TSC_FLAGS];
|
|
23310
23826
|
}
|
|
23311
23827
|
function modulesFor(checkout, git) {
|
|
23312
|
-
return findNodeModules(checkout, git) ??
|
|
23828
|
+
return findNodeModules(checkout, git) ?? join42(resolve18(checkout), NODE_MODULES2);
|
|
23313
23829
|
}
|
|
23314
23830
|
function readTypeCheckRecipe(checkout, git) {
|
|
23315
|
-
if (!
|
|
23831
|
+
if (!existsSync33(join42(checkout, "tsconfig.json")))
|
|
23316
23832
|
return null;
|
|
23317
23833
|
const modules = findNodeModules(checkout, git);
|
|
23318
23834
|
return modules === null ? null : { checkout, modules };
|
|
@@ -23407,8 +23923,8 @@ ${run.stderr}`.split(`
|
|
|
23407
23923
|
`).map((line) => line.trim()).find((line) => line !== "");
|
|
23408
23924
|
}
|
|
23409
23925
|
async function checkTree(input, modules, tree, files) {
|
|
23410
|
-
const scratchDir = mkdtempSync2(
|
|
23411
|
-
const scratch =
|
|
23926
|
+
const scratchDir = mkdtempSync2(join42(tmpdir2(), "rafa-type-step-"));
|
|
23927
|
+
const scratch = join42(scratchDir, SCRATCH_NAME);
|
|
23412
23928
|
try {
|
|
23413
23929
|
writeFileSync10(scratch, scratchTsconfig(tree, files, modules), "utf8");
|
|
23414
23930
|
let run;
|
|
@@ -23435,21 +23951,21 @@ async function checkTree(input, modules, tree, files) {
|
|
|
23435
23951
|
}
|
|
23436
23952
|
}
|
|
23437
23953
|
async function inBaseTree(input, label, modules, check) {
|
|
23438
|
-
const parent = mkdtempSync2(
|
|
23439
|
-
const tree =
|
|
23954
|
+
const parent = mkdtempSync2(join42(tmpdir2(), "rafa-type-base-"));
|
|
23955
|
+
const tree = join42(parent, "tree");
|
|
23440
23956
|
try {
|
|
23441
23957
|
const added = input.git(["worktree", "add", "--detach", tree, input.base]);
|
|
23442
23958
|
if (!added.ok) {
|
|
23443
23959
|
activeOutput().warn(`\u26A0\uFE0F The ${label} could not check out ${input.base} (${gitSaid(added) || "nothing said"}); it reads no error as new.`);
|
|
23444
23960
|
return null;
|
|
23445
23961
|
}
|
|
23446
|
-
if (
|
|
23447
|
-
symlinkSync2(modules,
|
|
23448
|
-
if (!
|
|
23962
|
+
if (existsSync33(modules) && !existsSync33(join42(tree, NODE_MODULES2)))
|
|
23963
|
+
symlinkSync2(modules, join42(tree, NODE_MODULES2));
|
|
23964
|
+
if (!existsSync33(join42(tree, "tsconfig.json")))
|
|
23449
23965
|
return { kind: "read", errors: [] };
|
|
23450
23966
|
return await check(tree);
|
|
23451
23967
|
} finally {
|
|
23452
|
-
if (
|
|
23968
|
+
if (existsSync33(tree)) {
|
|
23453
23969
|
const removed = input.git(["worktree", "remove", "--force", tree]);
|
|
23454
23970
|
if (!removed.ok)
|
|
23455
23971
|
activeOutput().warn(`\u26A0\uFE0F The ${label} could not remove its worktree ${tree} (${gitSaid(removed) || "nothing said"}).`);
|
|
@@ -23481,13 +23997,13 @@ function interrupted(label) {
|
|
|
23481
23997
|
return INTERRUPTED2;
|
|
23482
23998
|
}
|
|
23483
23999
|
function cannotStart(label, modules, run) {
|
|
23484
|
-
const tsc =
|
|
24000
|
+
const tsc = join42(modules, ...TSC_BIN);
|
|
23485
24001
|
const blocker = cannotStartBlockerText(label, tsc, run.run, run.said, scriptInterpreter(tsc));
|
|
23486
24002
|
activeOutput().warn(`\u26A0\uFE0F ${blocker}`);
|
|
23487
24003
|
return { ran: false, red: false, interrupted: false, cannotStart: true, blocker };
|
|
23488
24004
|
}
|
|
23489
24005
|
function filesToCheck(input, label) {
|
|
23490
|
-
if (!
|
|
24006
|
+
if (!existsSync33(join42(input.checkout, "tsconfig.json"))) {
|
|
23491
24007
|
activeOutput().info(`\uD83D\uDD0E ${label}: no tsconfig.json at the checkout root; nothing to type-check.`);
|
|
23492
24008
|
return null;
|
|
23493
24009
|
}
|
|
@@ -23827,14 +24343,14 @@ async function holdWhilePaused(options) {
|
|
|
23827
24343
|
}
|
|
23828
24344
|
}
|
|
23829
24345
|
// packages/rafa-run/src/start/plan-path.ts
|
|
23830
|
-
import { existsSync as
|
|
24346
|
+
import { existsSync as existsSync34 } from "fs";
|
|
23831
24347
|
import { resolve as resolve19 } from "path";
|
|
23832
24348
|
var DEFAULT_PLAN_FILE = "PLAN.md";
|
|
23833
24349
|
function resolvePlanPath(repoRoot, planDir, planArg) {
|
|
23834
24350
|
if (planArg)
|
|
23835
24351
|
return resolve19(repoRoot, planArg);
|
|
23836
24352
|
const inPlanDir = resolve19(repoRoot, planDir, DEFAULT_PLAN_FILE);
|
|
23837
|
-
return
|
|
24353
|
+
return existsSync34(inPlanDir) ? inPlanDir : resolve19(repoRoot, DEFAULT_PLAN_FILE);
|
|
23838
24354
|
}
|
|
23839
24355
|
// packages/rafa/src/pr/ci-poll.ts
|
|
23840
24356
|
var CI_POLL_INTERVAL_MS = 20000;
|
|
@@ -24374,20 +24890,41 @@ function refuseWorktreeWhileTracking(args, config) {
|
|
|
24374
24890
|
async function resolveRunBranch(request, seams = DEFAULT_BRANCH_SEAMS) {
|
|
24375
24891
|
const { args, base: base2, standing } = request;
|
|
24376
24892
|
const noBranch = standing === "no-branch";
|
|
24377
|
-
|
|
24893
|
+
const onBase2 = DEFAULT_BRANCHES.includes(base2) || base2 === request.runBase;
|
|
24894
|
+
if (!noBranch && !onBase2)
|
|
24378
24895
|
return base2;
|
|
24896
|
+
const createBranch = args.includes(CREATE_BRANCH_FLAG);
|
|
24379
24897
|
const outcome = await offerRunBranch({
|
|
24380
24898
|
repoRoot: request.checkout,
|
|
24381
24899
|
planStub: request.planStub,
|
|
24382
24900
|
base: base2,
|
|
24383
24901
|
standing,
|
|
24384
24902
|
anyBranch: args.includes(ANY_BRANCH_FLAG),
|
|
24385
|
-
createBranch
|
|
24903
|
+
createBranch,
|
|
24386
24904
|
branchTemplate: request.branchTemplate
|
|
24387
24905
|
}, seams);
|
|
24388
24906
|
if (outcome.kind === "moved")
|
|
24389
24907
|
return outcome.branch;
|
|
24390
|
-
|
|
24908
|
+
if (noBranch)
|
|
24909
|
+
return null;
|
|
24910
|
+
if (createBranch)
|
|
24911
|
+
refuseStillOnBase(request.planStub, base2, request.branchTemplate);
|
|
24912
|
+
return base2;
|
|
24913
|
+
}
|
|
24914
|
+
function refuseStillOnBase(planStub, base2, branchTemplate) {
|
|
24915
|
+
const way = planStub === null || planStub.trim() === "" ? [
|
|
24916
|
+
`
|
|
24917
|
+
\u274C Refusing ${CREATE_BRANCH_FLAG}: this plan's file names no stub, so no branch was made`,
|
|
24918
|
+
` and the run is still on \`${base2}\`, the base.`,
|
|
24919
|
+
...branchOffer(null, base2, branchTemplate)
|
|
24920
|
+
] : [
|
|
24921
|
+
`
|
|
24922
|
+
\u274C Refusing ${CREATE_BRANCH_FLAG} for \`${planStub}\`: the run is still on \`${base2}\`, the base.`,
|
|
24923
|
+
` ${ANY_BRANCH_FLAG} stood the offer aside, so ${branchNameFor(planStub, branchTemplate)} was not made.`,
|
|
24924
|
+
` Drop ${ANY_BRANCH_FLAG} to make it and run there, or ${CREATE_BRANCH_FLAG} to run on \`${base2}\`.`
|
|
24925
|
+
];
|
|
24926
|
+
throw new CommandExit(1, [...way, NOTHING_DISPATCHED].join(`
|
|
24927
|
+
`));
|
|
24391
24928
|
}
|
|
24392
24929
|
function branchOffer(planStub, base2, branchTemplate) {
|
|
24393
24930
|
if (planStub === null) {
|
|
@@ -24554,7 +25091,7 @@ async function runWorktreeSetup(request, seams = {}) {
|
|
|
24554
25091
|
|
|
24555
25092
|
// packages/rafa-run/src/start/worktree.ts
|
|
24556
25093
|
import { realpathSync as realpathSync5 } from "fs";
|
|
24557
|
-
import { join as
|
|
25094
|
+
import { join as join43, resolve as resolve20 } from "path";
|
|
24558
25095
|
|
|
24559
25096
|
// packages/rafa-run/src/start/claim-catch-up.ts
|
|
24560
25097
|
var OWN_COMMIT_FORMAT = "--format=%H%x09%P%x09%s";
|
|
@@ -24658,7 +25195,7 @@ var INDENT4 = " ";
|
|
|
24658
25195
|
var UNTOUCHED = `${INDENT4}The main checkout's branch and working tree were not touched.`;
|
|
24659
25196
|
var DEFAULT_WORKTREE_SEAMS = Object.freeze({});
|
|
24660
25197
|
function worktreePathFor(projectRoot, worktreeDir, stub) {
|
|
24661
|
-
return
|
|
25198
|
+
return join43(worktreeDirAt(projectRoot, worktreeDir), stub);
|
|
24662
25199
|
}
|
|
24663
25200
|
function addStep(route, plan, path3) {
|
|
24664
25201
|
const label = `add the worktree for ${plan.branch} at ${path3}`;
|
|
@@ -24922,13 +25459,15 @@ async function settleRunCheckout(request, seams = {}) {
|
|
|
24922
25459
|
const startedOn = (seams.checkedOutBranch ?? readCheckedOutBranch)(started.checkout);
|
|
24923
25460
|
const runBase = () => (seams.base ?? readBase2)(projectRoot, request.prBase);
|
|
24924
25461
|
if (!args.includes(AS_WORKTREE_FLAG)) {
|
|
24925
|
-
const
|
|
25462
|
+
const base3 = runBase();
|
|
25463
|
+
const stands = startedOn === null ? { base: base3, standing: "no-branch" } : { base: startedOn };
|
|
24926
25464
|
const branch = await (seams.offer ?? resolveRunBranch)({
|
|
24927
25465
|
checkout: started.checkout,
|
|
24928
25466
|
planStub,
|
|
24929
25467
|
...stands,
|
|
24930
25468
|
args,
|
|
24931
|
-
branchTemplate: request.branchTemplate
|
|
25469
|
+
branchTemplate: request.branchTemplate,
|
|
25470
|
+
runBase: base3
|
|
24932
25471
|
});
|
|
24933
25472
|
return Object.freeze({ projectRoot, checkout: started.checkout, branch });
|
|
24934
25473
|
}
|
|
@@ -24961,14 +25500,14 @@ function haltBeforeSession(options, seams = {}) {
|
|
|
24961
25500
|
return moved;
|
|
24962
25501
|
}
|
|
24963
25502
|
// packages/rafa-run/src/start/stale-docs.ts
|
|
24964
|
-
import { existsSync as
|
|
24965
|
-
import { homedir as
|
|
25503
|
+
import { existsSync as existsSync35, readFileSync as readFileSync32 } from "fs";
|
|
25504
|
+
import { homedir as homedir11 } from "os";
|
|
24966
25505
|
import { resolve as resolvePath } from "path";
|
|
24967
25506
|
var LINE_PREFIX = "Stale docs: ";
|
|
24968
25507
|
var INDENT5 = " ";
|
|
24969
25508
|
function localVersion(checkout, versionFile) {
|
|
24970
25509
|
const path3 = resolvePath(checkout, versionFile);
|
|
24971
|
-
if (!
|
|
25510
|
+
if (!existsSync35(path3))
|
|
24972
25511
|
return null;
|
|
24973
25512
|
try {
|
|
24974
25513
|
return readManifestVersion(readFileSync32(path3, "utf8"));
|
|
@@ -25052,7 +25591,7 @@ function refName(ref3) {
|
|
|
25052
25591
|
}
|
|
25053
25592
|
function createStartStaleDocs(options) {
|
|
25054
25593
|
const secrets = namedSecrets(options.config, options.env ?? process.env);
|
|
25055
|
-
const local = localPathRedactor([options.repoRoot, options.checkout], options.home ??
|
|
25594
|
+
const local = localPathRedactor([options.repoRoot, options.checkout], options.home ?? homedir11());
|
|
25056
25595
|
const redact = (text) => local(redactSecrets(text, secrets));
|
|
25057
25596
|
const kept = new Map;
|
|
25058
25597
|
let version = null;
|
|
@@ -25258,11 +25797,11 @@ function announceRunStepOnly(items) {
|
|
|
25258
25797
|
// packages/rafa-run/src/start/suite-step.ts
|
|
25259
25798
|
import { readFileSync as readFileSync38 } from "fs";
|
|
25260
25799
|
import { constants as constants3 } from "os";
|
|
25261
|
-
import { basename as basename14, join as
|
|
25800
|
+
import { basename as basename14, join as join49 } from "path";
|
|
25262
25801
|
|
|
25263
25802
|
// packages/rafa-run/src/suite/baseline.ts
|
|
25264
|
-
import { existsSync as
|
|
25265
|
-
import { basename as basename12, dirname as dirname16, join as
|
|
25803
|
+
import { existsSync as existsSync36, mkdirSync as mkdirSync6, readFileSync as readFileSync33, renameSync as renameSync2, writeFileSync as writeFileSync11 } from "fs";
|
|
25804
|
+
import { basename as basename12, dirname as dirname16, join as join44 } from "path";
|
|
25266
25805
|
var BASELINE_VERSION = 1;
|
|
25267
25806
|
var BASELINE_FILE_PREFIX = "SUITE_BASELINE";
|
|
25268
25807
|
var PLAN_FILE_NAME2 = /^PLAN(?:_TRACKER)?(-.+)?\.md$/;
|
|
@@ -25272,7 +25811,7 @@ function baselinePathFor(trackerPath) {
|
|
|
25272
25811
|
if (match === null) {
|
|
25273
25812
|
throw new RangeError(`baselinePathFor: ${trackerPath} is not a PLAN or PLAN_TRACKER file`);
|
|
25274
25813
|
}
|
|
25275
|
-
return
|
|
25814
|
+
return join44(dirname16(trackerPath), `${BASELINE_FILE_PREFIX}${match[1] ?? ""}.json`);
|
|
25276
25815
|
}
|
|
25277
25816
|
function copyFailure(failure2) {
|
|
25278
25817
|
return failure2.message === undefined ? { file: failure2.file, name: failure2.name } : { file: failure2.file, name: failure2.name, message: failure2.message };
|
|
@@ -25337,7 +25876,7 @@ function asBaseline(parsed) {
|
|
|
25337
25876
|
return { state: "read", baseline: parsed };
|
|
25338
25877
|
}
|
|
25339
25878
|
function readBaseline(path3) {
|
|
25340
|
-
if (!
|
|
25879
|
+
if (!existsSync36(path3))
|
|
25341
25880
|
return { state: "missing" };
|
|
25342
25881
|
let text;
|
|
25343
25882
|
try {
|
|
@@ -25364,12 +25903,12 @@ function splitFailures(failures, baseline) {
|
|
|
25364
25903
|
}
|
|
25365
25904
|
|
|
25366
25905
|
// packages/rafa-run/src/suite/owns.ts
|
|
25367
|
-
var
|
|
25906
|
+
var ISSUE_NUMBER5 = /^#?(\d+)$/u;
|
|
25368
25907
|
function none(reason, detail) {
|
|
25369
25908
|
return Object.freeze({ owns: null, reason, detail });
|
|
25370
25909
|
}
|
|
25371
25910
|
function issueNumberOf(issue4) {
|
|
25372
|
-
const digits =
|
|
25911
|
+
const digits = ISSUE_NUMBER5.exec(issue4?.trim() ?? "")?.[1];
|
|
25373
25912
|
if (digits === undefined)
|
|
25374
25913
|
return null;
|
|
25375
25914
|
const number = Number(digits);
|
|
@@ -25436,8 +25975,8 @@ async function readPlanOwns(options) {
|
|
|
25436
25975
|
}
|
|
25437
25976
|
|
|
25438
25977
|
// packages/rafa-run/src/suite/scope.ts
|
|
25439
|
-
import { existsSync as
|
|
25440
|
-
import { isAbsolute as isAbsolute13, join as
|
|
25978
|
+
import { existsSync as existsSync37, readdirSync as readdirSync11, readFileSync as readFileSync34 } from "fs";
|
|
25979
|
+
import { isAbsolute as isAbsolute13, join as join45, relative as relative15, sep as sep7 } from "path";
|
|
25441
25980
|
var BUNFIG_FILE = "bunfig.toml";
|
|
25442
25981
|
var TEST_FILE_NAME = /[._](?:test|spec)\.(?:tsx?|jsx?|[cm][jt]s)$/;
|
|
25443
25982
|
var DEPENDENCY_FOLDER = "node_modules";
|
|
@@ -25468,8 +26007,8 @@ function preloadFilesOf(text, root) {
|
|
|
25468
26007
|
return paths.filter((path3) => path3 !== null);
|
|
25469
26008
|
}
|
|
25470
26009
|
function readPreloadFiles(root) {
|
|
25471
|
-
const path3 =
|
|
25472
|
-
if (!
|
|
26010
|
+
const path3 = join45(root, BUNFIG_FILE);
|
|
26011
|
+
if (!existsSync37(path3))
|
|
25473
26012
|
return { state: "missing", files: [] };
|
|
25474
26013
|
try {
|
|
25475
26014
|
return { state: "read", files: preloadFilesOf(readFileSync34(path3, "utf8"), root) };
|
|
@@ -25481,7 +26020,7 @@ function readPreloadFiles(root) {
|
|
|
25481
26020
|
function listTestFiles(root) {
|
|
25482
26021
|
const found = [];
|
|
25483
26022
|
const walk = (folder) => {
|
|
25484
|
-
for (const entry of readdirSync11(
|
|
26023
|
+
for (const entry of readdirSync11(join45(root, folder), { withFileTypes: true })) {
|
|
25485
26024
|
const path3 = folder === "" ? entry.name : `${folder}/${entry.name}`;
|
|
25486
26025
|
if (entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== DEPENDENCY_FOLDER)
|
|
25487
26026
|
walk(path3);
|
|
@@ -25494,8 +26033,8 @@ function listTestFiles(root) {
|
|
|
25494
26033
|
}
|
|
25495
26034
|
|
|
25496
26035
|
// packages/rafa-run/src/start/lint-step.ts
|
|
25497
|
-
import { existsSync as
|
|
25498
|
-
import { join as
|
|
26036
|
+
import { existsSync as existsSync38 } from "fs";
|
|
26037
|
+
import { join as join46, relative as relative16 } from "path";
|
|
25499
26038
|
var LINT_COMMAND = ["bunx", "eslint", "--no-warn-ignored"];
|
|
25500
26039
|
var LINT_REPORT_FLAGS = ["--format", "json"];
|
|
25501
26040
|
var ESLINT_CONFIG_FILES = [
|
|
@@ -25524,7 +26063,7 @@ async function runEslint(options) {
|
|
|
25524
26063
|
return { exitCode, stdout, stderr };
|
|
25525
26064
|
}
|
|
25526
26065
|
function hasEslintConfig(checkout) {
|
|
25527
|
-
return ESLINT_CONFIG_FILES.some((name) =>
|
|
26066
|
+
return ESLINT_CONFIG_FILES.some((name) => existsSync38(join46(checkout, name)));
|
|
25528
26067
|
}
|
|
25529
26068
|
function readLintFiles(git, base2) {
|
|
25530
26069
|
const result = git(["diff", "--name-only", "-z", "--no-renames", "--diff-filter=d", base2, "HEAD"]);
|
|
@@ -25628,11 +26167,11 @@ async function runLintStep(input) {
|
|
|
25628
26167
|
}
|
|
25629
26168
|
|
|
25630
26169
|
// packages/rafa-run/src/start/suite-retake-alone.ts
|
|
25631
|
-
import { join as
|
|
26170
|
+
import { join as join47, relative as relative17 } from "path";
|
|
25632
26171
|
var RETAKE_ALONE_MAX_FILES = 20;
|
|
25633
26172
|
var STEP_ONLY_BEFORE = 5;
|
|
25634
26173
|
function aloneJunitFileFor(repoRoot, sessionId, kind, nth) {
|
|
25635
|
-
return
|
|
26174
|
+
return join47(runsDir(repoRoot), sessionId, "suite", `${kind}-alone-${nth}.junit.xml`);
|
|
25636
26175
|
}
|
|
25637
26176
|
function placeOf(file, orders) {
|
|
25638
26177
|
for (const [run, order] of orders.entries()) {
|
|
@@ -25756,14 +26295,14 @@ function announceStepOnly(context, settling) {
|
|
|
25756
26295
|
}
|
|
25757
26296
|
|
|
25758
26297
|
// packages/rafa-run/src/start/suite-stage-ledger.ts
|
|
25759
|
-
import { existsSync as
|
|
25760
|
-
import { basename as basename13, dirname as dirname17, join as
|
|
26298
|
+
import { existsSync as existsSync39, mkdirSync as mkdirSync7, readFileSync as readFileSync35, renameSync as renameSync3, writeFileSync as writeFileSync12 } from "fs";
|
|
26299
|
+
import { basename as basename13, dirname as dirname17, join as join48 } from "path";
|
|
25761
26300
|
var STAGE_LEDGER_PREFIX = "SUITE_STAGES";
|
|
25762
26301
|
var STAGE_LEDGER_VERSION = 1;
|
|
25763
26302
|
function stageLedgerPathFor(trackerPath) {
|
|
25764
26303
|
const baselinePath = baselinePathFor(trackerPath);
|
|
25765
26304
|
const name = basename13(baselinePath).replace(BASELINE_FILE_PREFIX, STAGE_LEDGER_PREFIX);
|
|
25766
|
-
return
|
|
26305
|
+
return join48(dirname17(baselinePath), name);
|
|
25767
26306
|
}
|
|
25768
26307
|
function isLedgerEntry(value) {
|
|
25769
26308
|
if (typeof value !== "object" || value === null)
|
|
@@ -25787,7 +26326,7 @@ function parseLedger(text) {
|
|
|
25787
26326
|
return stages;
|
|
25788
26327
|
}
|
|
25789
26328
|
function readStageLedger(path3) {
|
|
25790
|
-
if (!
|
|
26329
|
+
if (!existsSync39(path3))
|
|
25791
26330
|
return [];
|
|
25792
26331
|
let parsed;
|
|
25793
26332
|
try {
|
|
@@ -26097,7 +26636,7 @@ async function runDueStageSteps(context, baseline) {
|
|
|
26097
26636
|
}
|
|
26098
26637
|
|
|
26099
26638
|
// packages/rafa-run/src/start/sweep-timing.ts
|
|
26100
|
-
import { existsSync as
|
|
26639
|
+
import { existsSync as existsSync40, readFileSync as readFileSync37 } from "fs";
|
|
26101
26640
|
var SLOW_SWEEP_SECONDS = 10;
|
|
26102
26641
|
var SUITE_TAG = /<(\/?)testsuite\b([^>]*?)(\/?)>/g;
|
|
26103
26642
|
function fileTimeOf(attributes) {
|
|
@@ -26137,7 +26676,7 @@ function slowSweepLine(slow) {
|
|
|
26137
26676
|
return `\uD83D\uDC22 ${slow.length} tests.alwaysRun file(s) took over ${SLOW_SWEEP_SECONDS}s in the task step: ${named}.`;
|
|
26138
26677
|
}
|
|
26139
26678
|
function readFileTimes(path3) {
|
|
26140
|
-
if (!
|
|
26679
|
+
if (!existsSync40(path3))
|
|
26141
26680
|
return [];
|
|
26142
26681
|
try {
|
|
26143
26682
|
return parseJunitFileTimes(readFileSync37(path3, "utf8")) ?? [];
|
|
@@ -26305,10 +26844,10 @@ function seamsOf(context) {
|
|
|
26305
26844
|
};
|
|
26306
26845
|
}
|
|
26307
26846
|
function junitFileFor(repoRoot, sessionId, kind) {
|
|
26308
|
-
return
|
|
26847
|
+
return join49(runsDir(repoRoot), sessionId, "suite", `${kind}.junit.xml`);
|
|
26309
26848
|
}
|
|
26310
26849
|
function alwaysRunJunitFileFor(repoRoot, sessionId, kind = "task") {
|
|
26311
|
-
return
|
|
26850
|
+
return join49(runsDir(repoRoot), sessionId, "suite", `${kind}-always-run.junit.xml`);
|
|
26312
26851
|
}
|
|
26313
26852
|
function readHead(git) {
|
|
26314
26853
|
const result = git(["rev-parse", "--verify", "HEAD^{commit}"]);
|
|
@@ -26686,7 +27225,7 @@ function createRunSuiteSteps(options) {
|
|
|
26686
27225
|
return { beforeSession, afterTask, stoppedOnSignal: () => signalled, lastPreWrapUp: () => lastPreWrapUp };
|
|
26687
27226
|
}
|
|
26688
27227
|
// packages/rafa-run/src/start/triage.ts
|
|
26689
|
-
import { homedir as
|
|
27228
|
+
import { homedir as homedir12 } from "os";
|
|
26690
27229
|
|
|
26691
27230
|
// packages/rafa/src/ports/unresolved-tracker.ts
|
|
26692
27231
|
function unresolvedTracker(kind, reason) {
|
|
@@ -26705,7 +27244,7 @@ function unresolvedTracker(kind, reason) {
|
|
|
26705
27244
|
|
|
26706
27245
|
// packages/rafa/src/effort/store/bug-routes.ts
|
|
26707
27246
|
import { randomUUID as randomUUID12 } from "crypto";
|
|
26708
|
-
import { existsSync as
|
|
27247
|
+
import { existsSync as existsSync41 } from "fs";
|
|
26709
27248
|
var BUG_ROUTES = [
|
|
26710
27249
|
"filed",
|
|
26711
27250
|
"private",
|
|
@@ -26807,7 +27346,7 @@ var SELECT_PLAN_BUG_ROUTES = `
|
|
|
26807
27346
|
`;
|
|
26808
27347
|
function readBugRoutesForPlan(repoRoot, planStub) {
|
|
26809
27348
|
const path3 = sqliteStorePath(repoRoot);
|
|
26810
|
-
if (!
|
|
27349
|
+
if (!existsSync41(path3))
|
|
26811
27350
|
return [];
|
|
26812
27351
|
const rows = withSqliteStore(path3, "read", false, (db) => db.query(SELECT_PLAN_BUG_ROUTES).all(planStub));
|
|
26813
27352
|
return rows.map((row) => ({
|
|
@@ -27077,7 +27616,7 @@ function createStartTriage(options) {
|
|
|
27077
27616
|
const secrets = namedSecrets(options.config, env);
|
|
27078
27617
|
const redact = (text) => redactSecrets(text, secrets);
|
|
27079
27618
|
const checkout = options.checkout ?? options.repoRoot;
|
|
27080
|
-
const local = localPathRedactor([checkout, options.repoRoot],
|
|
27619
|
+
const local = localPathRedactor([checkout, options.repoRoot], homedir12());
|
|
27081
27620
|
const git = options.git ?? createGitRunner(checkout);
|
|
27082
27621
|
const bugRules = bugRulesOf(options.config);
|
|
27083
27622
|
const triage = options.triageReport ?? triageReport;
|
|
@@ -27166,7 +27705,7 @@ function createStartTriage(options) {
|
|
|
27166
27705
|
};
|
|
27167
27706
|
}
|
|
27168
27707
|
// packages/rafa-run/src/start/convention-body.ts
|
|
27169
|
-
import { homedir as
|
|
27708
|
+
import { homedir as homedir13 } from "os";
|
|
27170
27709
|
|
|
27171
27710
|
// packages/rafa-run/src/start/release-body.ts
|
|
27172
27711
|
var RELEASE_BODY_SEAMS = {
|
|
@@ -27325,7 +27864,7 @@ async function writeLines(input, seams, redact) {
|
|
|
27325
27864
|
}
|
|
27326
27865
|
async function writeConventionLines(input, seams = {}) {
|
|
27327
27866
|
const secrets = namedSecrets(input.settings, seams.env ?? process.env);
|
|
27328
|
-
const local = localPathRedactor([input.repoRoot, input.checkout], seams.home ??
|
|
27867
|
+
const local = localPathRedactor([input.repoRoot, input.checkout], seams.home ?? homedir13());
|
|
27329
27868
|
const redact = (text) => local(redactSecrets(text, secrets));
|
|
27330
27869
|
try {
|
|
27331
27870
|
return await writeLines(input, seams, redact);
|
|
@@ -27337,7 +27876,7 @@ async function writeConventionLines(input, seams = {}) {
|
|
|
27337
27876
|
}
|
|
27338
27877
|
|
|
27339
27878
|
// packages/rafa-run/src/start/follow-ups.ts
|
|
27340
|
-
import { homedir as
|
|
27879
|
+
import { homedir as homedir14 } from "os";
|
|
27341
27880
|
var LINE_PREFIX4 = "Follow-ups: ";
|
|
27342
27881
|
var INDENT8 = " ";
|
|
27343
27882
|
var FOLLOW_UPS_OPENING = "What this plan broke or left unfinished in its own work, " + "past its cap on repair tasks. Each line names the kind the loop read and what was reported.";
|
|
@@ -27479,7 +28018,7 @@ async function fileLines2(input, seams, redact) {
|
|
|
27479
28018
|
}
|
|
27480
28019
|
async function fileFollowUps(input, seams = {}) {
|
|
27481
28020
|
const secrets = namedSecrets(input.settings, seams.env ?? process.env);
|
|
27482
|
-
const local = localPathRedactor([input.repoRoot, input.checkout], seams.home ??
|
|
28021
|
+
const local = localPathRedactor([input.repoRoot, input.checkout], seams.home ?? homedir14());
|
|
27483
28022
|
const redact = (text) => local(redactSecrets(text, secrets));
|
|
27484
28023
|
let result;
|
|
27485
28024
|
try {
|
|
@@ -27976,14 +28515,41 @@ function unpromotedLine(check, head) {
|
|
|
27976
28515
|
const named = check.unpromoted.map((lesson) => unpromotedPhrase(lesson, head)).join("; ");
|
|
27977
28516
|
return `Lessons listed for promotion that this pull request does not carry: ${named}.`;
|
|
27978
28517
|
}
|
|
28518
|
+
function refusedLine(member, named, path4, error) {
|
|
28519
|
+
const who = member.id === named.id ? `\`${member.id}\`` : `\`${member.id}\` (same action as \`${named.id}\`)`;
|
|
28520
|
+
return `${who} is in ${path4}, but its promoted_to could not be recorded: ${messageOf(error)}`;
|
|
28521
|
+
}
|
|
28522
|
+
function groupMates(lesson, blessed) {
|
|
28523
|
+
const group = sameActionGroups(blessed).find((each) => each.action_hash === lesson.action_hash);
|
|
28524
|
+
return (group?.members ?? []).filter((member) => member.id !== lesson.id);
|
|
28525
|
+
}
|
|
28526
|
+
async function blessedOrProblem(learning) {
|
|
28527
|
+
try {
|
|
28528
|
+
return { blessed: (await learning.pullBlessed()).instincts, problem: null };
|
|
28529
|
+
} catch (error) {
|
|
28530
|
+
return { blessed: [], problem: messageOf(error) };
|
|
28531
|
+
}
|
|
28532
|
+
}
|
|
27979
28533
|
async function recordPromotions(learning, promoted) {
|
|
27980
28534
|
const problems = [];
|
|
28535
|
+
if (promoted.length === 0)
|
|
28536
|
+
return problems;
|
|
28537
|
+
const { blessed, problem } = await blessedOrProblem(learning);
|
|
28538
|
+
const pushed = new Set;
|
|
27981
28539
|
for (const { lesson, path: path4 } of promoted) {
|
|
27982
|
-
|
|
27983
|
-
|
|
27984
|
-
|
|
27985
|
-
|
|
27986
|
-
|
|
28540
|
+
if (problem !== null) {
|
|
28541
|
+
problems.push(`\`${lesson.id}\` is in ${path4}, but the rest of its same-action group was not recorded, as the blessed set could not be read: ${problem}`);
|
|
28542
|
+
}
|
|
28543
|
+
for (const member of [lesson, ...groupMates(lesson, blessed)]) {
|
|
28544
|
+
if (pushed.has(member.id))
|
|
28545
|
+
continue;
|
|
28546
|
+
pushed.add(member.id);
|
|
28547
|
+
const sourceId = member.sources?.[0] ?? member.id;
|
|
28548
|
+
try {
|
|
28549
|
+
await learning.push({ source_id: sourceId, instincts: [{ ...member, promoted_to: path4 }] });
|
|
28550
|
+
} catch (error) {
|
|
28551
|
+
problems.push(refusedLine(member, lesson, path4, error));
|
|
28552
|
+
}
|
|
27987
28553
|
}
|
|
27988
28554
|
}
|
|
27989
28555
|
return problems;
|
|
@@ -28429,11 +28995,11 @@ async function openByRunner(seams, branch, retriesSpent) {
|
|
|
28429
28995
|
activeOutput().warn(line);
|
|
28430
28996
|
return { kind: "delivered", pull: attempt2.pull, by: "runner", retriesSpent };
|
|
28431
28997
|
}
|
|
28432
|
-
var
|
|
28998
|
+
var ISSUE_NUMBER6 = /^#?(\d+)$/;
|
|
28433
28999
|
var RAFA_ID = /(?:^|\/)rafa-(\d+)(?:-|$)/;
|
|
28434
29000
|
function planIssueNumber(planContent, planStub, branch) {
|
|
28435
29001
|
const declared = parsePlan(planContent).header.issue?.trim() ?? "";
|
|
28436
|
-
const spelled =
|
|
29002
|
+
const spelled = ISSUE_NUMBER6.exec(declared)?.[1] ?? RAFA_ID.exec(planStub ?? "")?.[1] ?? RAFA_ID.exec(branch)?.[1];
|
|
28437
29003
|
return spelled === undefined ? null : Number(spelled);
|
|
28438
29004
|
}
|
|
28439
29005
|
function runnerPrInputFor(source) {
|
|
@@ -28520,13 +29086,13 @@ function registerCoreServices() {
|
|
|
28520
29086
|
}
|
|
28521
29087
|
// src/plan.ts
|
|
28522
29088
|
import fs5 from "fs";
|
|
28523
|
-
import { homedir as
|
|
29089
|
+
import { homedir as homedir16 } from "os";
|
|
28524
29090
|
import path7 from "path";
|
|
28525
29091
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
28526
29092
|
|
|
28527
29093
|
// src/commands/plan/bundled-check.ts
|
|
28528
29094
|
import { readdirSync as readdirSync12, readFileSync as readFileSync40, realpathSync as realpathSync6, statSync as statSync10, writeFileSync as writeFileSync13 } from "fs";
|
|
28529
|
-
import { basename as basename15, isAbsolute as isAbsolute15, join as
|
|
29095
|
+
import { basename as basename15, isAbsolute as isAbsolute15, join as join50, relative as relative19, resolve as resolve21, sep as sep8 } from "path";
|
|
28530
29096
|
var SOURCE_DIR2 = "src";
|
|
28531
29097
|
var CODE_SPAN6 = /`([^`]+)`/gu;
|
|
28532
29098
|
var PATH_LIKE = /^\S+$/u;
|
|
@@ -28551,11 +29117,11 @@ function bundledAgents(root) {
|
|
|
28551
29117
|
function bundledSkills(root) {
|
|
28552
29118
|
if (root === null)
|
|
28553
29119
|
return [];
|
|
28554
|
-
return readdirSync12(root).filter((name) => isFilePath(
|
|
29120
|
+
return readdirSync12(root).filter((name) => isFilePath(join50(root, name, SKILL_FILE2))).sort((a, b) => a.localeCompare(b));
|
|
28555
29121
|
}
|
|
28556
29122
|
function readBundle(repoRoot) {
|
|
28557
|
-
const agentsRoot = realPathOrNull(
|
|
28558
|
-
const skillsRoot = realPathOrNull(
|
|
29123
|
+
const agentsRoot = realPathOrNull(join50(repoRoot, SOURCE_DIR2, BUNDLED_AGENTS_DIR));
|
|
29124
|
+
const skillsRoot = realPathOrNull(join50(repoRoot, SOURCE_DIR2, BUNDLED_SKILLS_DIR));
|
|
28559
29125
|
return { agentsRoot, skillsRoot, agents: bundledAgents(agentsRoot), skills: bundledSkills(skillsRoot) };
|
|
28560
29126
|
}
|
|
28561
29127
|
function skillHolding(bundle, realPath2) {
|
|
@@ -28894,7 +29460,7 @@ function createPlanBlockedOffer(seams = DEFAULT_BLOCKED_SEAMS) {
|
|
|
28894
29460
|
|
|
28895
29461
|
// src/commands/plan/ready-offer.ts
|
|
28896
29462
|
var runIssueReadyLazily = async (options) => {
|
|
28897
|
-
const { runIssueReady: run } = await import("./ready-
|
|
29463
|
+
const { runIssueReady: run } = await import("./ready-cnzcnv4d.js");
|
|
28898
29464
|
return run(options);
|
|
28899
29465
|
};
|
|
28900
29466
|
var DEFAULT_OFFER_SEAMS = Object.freeze({});
|
|
@@ -29112,16 +29678,16 @@ function stretchRulesReader(env, repoRoot) {
|
|
|
29112
29678
|
}
|
|
29113
29679
|
|
|
29114
29680
|
// src/notices/run.ts
|
|
29115
|
-
import { homedir as
|
|
29681
|
+
import { homedir as homedir15 } from "os";
|
|
29116
29682
|
|
|
29117
29683
|
// src/notices/notices.ts
|
|
29118
29684
|
import { mkdirSync as mkdirSync9, readFileSync as readFileSync42, writeFileSync as writeFileSync14 } from "fs";
|
|
29119
|
-
import { dirname as dirname19, join as
|
|
29685
|
+
import { dirname as dirname19, join as join51 } from "path";
|
|
29120
29686
|
var NOTICE_IDS = Object.freeze(["alpha", "danger"]);
|
|
29121
29687
|
var FEEDBACK_URL = "https://github.com/open-tomato/rafa/issues/new/choose";
|
|
29122
29688
|
var ROADMAP_URL = "https://github.com/open-tomato/rafa/issues/31";
|
|
29123
29689
|
function noticesPath(home) {
|
|
29124
|
-
return
|
|
29690
|
+
return join51(home, ".rafa", "notices.json");
|
|
29125
29691
|
}
|
|
29126
29692
|
function isNoticeId(value) {
|
|
29127
29693
|
return typeof value === "string" && NOTICE_IDS.includes(value);
|
|
@@ -29227,7 +29793,7 @@ async function offerNotices(request, seams) {
|
|
|
29227
29793
|
// src/notices/run.ts
|
|
29228
29794
|
var NOTICES_CANCELLED = "\uD83D\uDED1 Cancelled at the notice: nothing was started.";
|
|
29229
29795
|
async function requireNoticesAnswered(settingSources) {
|
|
29230
|
-
const outcome = await offerNotices({ home:
|
|
29796
|
+
const outcome = await offerNotices({ home: homedir15(), version: RAFA_VERSION, settingSources }, {
|
|
29231
29797
|
isTerminal: () => process.stdin.isTTY === true,
|
|
29232
29798
|
openPrompter: () => createLinePrompter(process.stdin, process.stderr),
|
|
29233
29799
|
warn: (line) => {
|
|
@@ -29416,7 +29982,7 @@ async function resolvePlanConfig(repoRoot, home) {
|
|
|
29416
29982
|
}
|
|
29417
29983
|
}
|
|
29418
29984
|
async function plan(args, repoRoot, roster, registry = CORE_ADAPTER_REGISTRY) {
|
|
29419
|
-
const home =
|
|
29985
|
+
const home = homedir16();
|
|
29420
29986
|
const config = await resolvePlanConfig(repoRoot, home);
|
|
29421
29987
|
const {
|
|
29422
29988
|
settingSources,
|
|
@@ -29508,10 +30074,146 @@ async function plan(args, repoRoot, roster, registry = CORE_ADAPTER_REGISTRY) {
|
|
|
29508
30074
|
}
|
|
29509
30075
|
// src/start.ts
|
|
29510
30076
|
import fs6 from "fs";
|
|
29511
|
-
import { homedir as
|
|
30077
|
+
import { homedir as homedir17 } from "os";
|
|
29512
30078
|
import path8 from "path";
|
|
29513
30079
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
29514
30080
|
|
|
30081
|
+
// src/learning/plan-stage-links.ts
|
|
30082
|
+
import { readdir as readdir2, readFile as readFile6 } from "fs/promises";
|
|
30083
|
+
import { join as join52 } from "path";
|
|
30084
|
+
var PLAN_FILE = /^PLAN-.+\.md$/;
|
|
30085
|
+
var FENCE_RUN = /^( {0,3})(`{3,}|~{3,})/;
|
|
30086
|
+
var CLOSING_FENCE = /^ {0,3}(`{3,}|~{3,})[ \t]*$/;
|
|
30087
|
+
function warnPassedOver(message) {
|
|
30088
|
+
activeLogger().child({ module: "learning", action: "plan-stage-links" }).log({ level: "warn", message });
|
|
30089
|
+
}
|
|
30090
|
+
function messageOf11(error) {
|
|
30091
|
+
return error instanceof Error ? error.message : String(error);
|
|
30092
|
+
}
|
|
30093
|
+
function fencedLines(markdown) {
|
|
30094
|
+
const lines = markdown.split(`
|
|
30095
|
+
`).map((line) => line.endsWith("\r") ? line.slice(0, -1) : line);
|
|
30096
|
+
const fenced3 = new Set;
|
|
30097
|
+
let index = 0;
|
|
30098
|
+
while (index < lines.length) {
|
|
30099
|
+
const line = lines[index] ?? "";
|
|
30100
|
+
const match = FENCE_RUN.exec(line);
|
|
30101
|
+
const run = match?.[2];
|
|
30102
|
+
const info = line.slice(match?.[0].length ?? 0);
|
|
30103
|
+
if (run === undefined || run.startsWith("`") && info.includes("`")) {
|
|
30104
|
+
index += 1;
|
|
30105
|
+
continue;
|
|
30106
|
+
}
|
|
30107
|
+
let closing = index + 1;
|
|
30108
|
+
while (closing < lines.length && !closesFence5(lines[closing] ?? "", run))
|
|
30109
|
+
closing += 1;
|
|
30110
|
+
for (let covered = index;covered <= Math.min(closing, lines.length - 1); covered += 1) {
|
|
30111
|
+
fenced3.add(covered);
|
|
30112
|
+
}
|
|
30113
|
+
index = closing + 1;
|
|
30114
|
+
}
|
|
30115
|
+
return fenced3;
|
|
30116
|
+
}
|
|
30117
|
+
function closesFence5(line, opener) {
|
|
30118
|
+
const run = CLOSING_FENCE.exec(line)?.[1];
|
|
30119
|
+
return run !== undefined && run.charAt(0) === opener.charAt(0) && run.length >= opener.length;
|
|
30120
|
+
}
|
|
30121
|
+
function stageLinks(stub, model, fenced3) {
|
|
30122
|
+
return model.stages.map((stage2, index) => ({
|
|
30123
|
+
stub,
|
|
30124
|
+
stage: stage2.name,
|
|
30125
|
+
context: stage2.context,
|
|
30126
|
+
tasks: model.tasks.filter((task) => task.stage === index && !fenced3.has(task.lineNum)).map((task) => task.task)
|
|
30127
|
+
}));
|
|
30128
|
+
}
|
|
30129
|
+
async function readPlanFile(path8, name) {
|
|
30130
|
+
let markdown;
|
|
30131
|
+
try {
|
|
30132
|
+
markdown = await readFile6(path8, "utf8");
|
|
30133
|
+
} catch (error) {
|
|
30134
|
+
return { skipped: `could not be read: ${messageOf11(error)}` };
|
|
30135
|
+
}
|
|
30136
|
+
const model = parsePlan(markdown);
|
|
30137
|
+
const unclosed = model.issues.find((issue4) => issue4.reason === "unclosed-block");
|
|
30138
|
+
if (unclosed !== undefined) {
|
|
30139
|
+
return { skipped: `holds a rafa block never closed, opened at line ${unclosed.line}` };
|
|
30140
|
+
}
|
|
30141
|
+
const stub = model.header.stub ?? planStubFromPath(name);
|
|
30142
|
+
if (stub === null) {
|
|
30143
|
+
return { skipped: "names no stub in its rafa:plan block or its file name" };
|
|
30144
|
+
}
|
|
30145
|
+
return { links: stageLinks(stub, model, fencedLines(markdown)) };
|
|
30146
|
+
}
|
|
30147
|
+
async function planFileNames(plansDir) {
|
|
30148
|
+
try {
|
|
30149
|
+
const names = await readdir2(plansDir);
|
|
30150
|
+
return names.filter((name) => PLAN_FILE.test(name)).sort();
|
|
30151
|
+
} catch (error) {
|
|
30152
|
+
if (error.code === "ENOENT")
|
|
30153
|
+
return [];
|
|
30154
|
+
throw error;
|
|
30155
|
+
}
|
|
30156
|
+
}
|
|
30157
|
+
async function readPlanStageLinks(plansDir, options = {}) {
|
|
30158
|
+
const warn2 = options.warn ?? warnPassedOver;
|
|
30159
|
+
const links = [];
|
|
30160
|
+
for (const name of await planFileNames(plansDir)) {
|
|
30161
|
+
const reading = await readPlanFile(join52(plansDir, name), name);
|
|
30162
|
+
if ("skipped" in reading) {
|
|
30163
|
+
warn2(`Plan file ${name} passed over: it ${reading.skipped}.`);
|
|
30164
|
+
continue;
|
|
30165
|
+
}
|
|
30166
|
+
links.push(...reading.links);
|
|
30167
|
+
}
|
|
30168
|
+
return links;
|
|
30169
|
+
}
|
|
30170
|
+
|
|
30171
|
+
// src/learning/bug-fix-pass.ts
|
|
30172
|
+
var PASS_ADAPTER = "local";
|
|
30173
|
+
var WARNING = "bug-fix pass";
|
|
30174
|
+
var NOTHING = { pushed: 0, skipped: 0, unpaired: 0 };
|
|
30175
|
+
function warnThroughActiveOutput4(message) {
|
|
30176
|
+
activeOutput().warn(message);
|
|
30177
|
+
}
|
|
30178
|
+
async function resolvedConfig(roots) {
|
|
30179
|
+
return (await loadConfig(roots, {}, () => {})).config;
|
|
30180
|
+
}
|
|
30181
|
+
async function pass(roots, seams, warn2) {
|
|
30182
|
+
const config = seams.config ?? await resolvedConfig(roots);
|
|
30183
|
+
if (config.learningAdapter !== PASS_ADAPTER) {
|
|
30184
|
+
throw new Error(`learning.adapter is \`${config.learningAdapter}\`, and the pass pushes through \`${PASS_ADAPTER}\` only`);
|
|
30185
|
+
}
|
|
30186
|
+
const { rows, note } = readBugFixRows(roots.root);
|
|
30187
|
+
if (note !== null)
|
|
30188
|
+
return NOTHING;
|
|
30189
|
+
const links = await readPlanStageLinks(plansDirAt(roots.root, config.planDir).path, { warn: warn2 });
|
|
30190
|
+
const now = (seams.now ?? (() => new Date))();
|
|
30191
|
+
const { pairs, unpaired } = pairBugFixes(rows, links, now);
|
|
30192
|
+
const push = await pushBugFixPairs({
|
|
30193
|
+
instinctsDir: localInstinctsDir(roots.root),
|
|
30194
|
+
home: roots.home,
|
|
30195
|
+
minConfidence: config.learningBlessMinConfidence,
|
|
30196
|
+
warn: warn2
|
|
30197
|
+
}, pairs, now);
|
|
30198
|
+
if (push.problems.length > 0) {
|
|
30199
|
+
warn2([
|
|
30200
|
+
`${WARNING}: ${push.problems.length} of ${pairs.length} pairs were not pushed:`,
|
|
30201
|
+
...push.problems.map((problem) => ` ${problem}`)
|
|
30202
|
+
].join(`
|
|
30203
|
+
`));
|
|
30204
|
+
}
|
|
30205
|
+
return { pushed: push.pushed.length, skipped: push.skipped.length, unpaired: unpaired.length };
|
|
30206
|
+
}
|
|
30207
|
+
async function runBugFixPass(roots, seams = {}) {
|
|
30208
|
+
const warn2 = seams.warn ?? warnThroughActiveOutput4;
|
|
30209
|
+
try {
|
|
30210
|
+
return await pass(roots, seams, warn2);
|
|
30211
|
+
} catch (error) {
|
|
30212
|
+
warn2(`${WARNING}: nothing was pushed: ${messageOf(error)}`);
|
|
30213
|
+
return NOTHING;
|
|
30214
|
+
}
|
|
30215
|
+
}
|
|
30216
|
+
|
|
29515
30217
|
// src/utils/schedule.ts
|
|
29516
30218
|
function msUntil(startAt, now = new Date) {
|
|
29517
30219
|
const match = startAt.match(/^(\d{1,2}):(\d{2})$/);
|
|
@@ -29552,7 +30254,7 @@ async function start(args, repoRoot) {
|
|
|
29552
30254
|
return;
|
|
29553
30255
|
let runConfig;
|
|
29554
30256
|
try {
|
|
29555
|
-
runConfig = await loadRunConfig({ root: repoRoot, home:
|
|
30257
|
+
runConfig = await loadRunConfig({ root: repoRoot, home: homedir17() }, args);
|
|
29556
30258
|
} catch (error) {
|
|
29557
30259
|
if (!(error instanceof ConfigError))
|
|
29558
30260
|
throw error;
|
|
@@ -29589,7 +30291,7 @@ async function start(args, repoRoot) {
|
|
|
29589
30291
|
let expected2 = openCheckoutExpectation({ projectRoot: repoRoot, checkout, branch });
|
|
29590
30292
|
await announceRiskTotal({
|
|
29591
30293
|
repoRoot,
|
|
29592
|
-
home:
|
|
30294
|
+
home: homedir17(),
|
|
29593
30295
|
planPath,
|
|
29594
30296
|
config: runConfig.config,
|
|
29595
30297
|
environment: process.env
|
|
@@ -29619,16 +30321,16 @@ async function start(args, repoRoot) {
|
|
|
29619
30321
|
tiersRafa: runConfig.config.tiersRafa,
|
|
29620
30322
|
tiersSkills: runConfig.config.tiersSkills,
|
|
29621
30323
|
tiersAgents: runConfig.config.tiersAgents,
|
|
29622
|
-
home:
|
|
30324
|
+
home: homedir17()
|
|
29623
30325
|
},
|
|
29624
|
-
sync: { resolved: runConfig, home:
|
|
30326
|
+
sync: { resolved: runConfig, home: homedir17() },
|
|
29625
30327
|
claim: createStartPreflightClaim(repoRoot, runConfig.config),
|
|
29626
30328
|
drift: createStartPreflightDrift(repoRoot, runConfig.config)
|
|
29627
30329
|
});
|
|
29628
|
-
const serving = { root: repoRoot, run: session.id, home:
|
|
30330
|
+
const serving = { root: repoRoot, run: session.id, home: homedir17(), settings: runConfig.config };
|
|
29629
30331
|
const learning = {
|
|
29630
30332
|
kind: runConfig.config.learningAdapter,
|
|
29631
|
-
home:
|
|
30333
|
+
home: homedir17(),
|
|
29632
30334
|
blessMinConfidence: runConfig.config.learningBlessMinConfidence
|
|
29633
30335
|
};
|
|
29634
30336
|
const handout = {
|
|
@@ -29644,7 +30346,7 @@ async function start(args, repoRoot) {
|
|
|
29644
30346
|
};
|
|
29645
30347
|
const hubContact = createHubContact({
|
|
29646
30348
|
root: repoRoot,
|
|
29647
|
-
home:
|
|
30349
|
+
home: homedir17(),
|
|
29648
30350
|
resolved: runConfig,
|
|
29649
30351
|
warn: (message) => activeOutput().warn(message),
|
|
29650
30352
|
sessionId: session.id
|
|
@@ -29756,7 +30458,7 @@ async function start(args, repoRoot) {
|
|
|
29756
30458
|
inject: injectMode,
|
|
29757
30459
|
repoRoot,
|
|
29758
30460
|
checkout,
|
|
29759
|
-
home:
|
|
30461
|
+
home: homedir17(),
|
|
29760
30462
|
settingSources,
|
|
29761
30463
|
knownMissing,
|
|
29762
30464
|
inherited: runStartFailures(trackerPath),
|
|
@@ -29780,6 +30482,7 @@ async function start(args, repoRoot) {
|
|
|
29780
30482
|
await triageTask({ trackerPath, lineNum: taskInfo.lineNum, planStub, dispatch, outcome });
|
|
29781
30483
|
await staleDocs.afterTask({ planStub, dispatch, outcome });
|
|
29782
30484
|
await hubContact.pushThenPull();
|
|
30485
|
+
await runBugFixPass({ root: repoRoot, home: homedir17() }, { config: runConfig.config });
|
|
29783
30486
|
return stored2;
|
|
29784
30487
|
};
|
|
29785
30488
|
if (interrupted2) {
|