@open-tomato/rafa 0.52.0 → 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 +2552 -1407
- 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-hyp1sraj.js → index-anvmm83x.js} +108 -42
- package/dist/{index-m672ptpg.js → index-dj8en7fg.js} +1 -1
- package/dist/{index-mbxgc1zv.js → index-kqz8x8g9.js} +3 -3
- package/dist/{index-91cag9fr.js → index-rkrsdes6.js} +2 -2
- package/dist/index.js +1166 -462
- 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-3ccr65a2.js → ready-cnzcnv4d.js} +3 -3
- package/package.json +5 -14
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
|
}
|
|
@@ -13257,7 +13748,8 @@ function forecastLine(read) {
|
|
|
13257
13748
|
return `Release forecast: none computed, because ${read.problem}`;
|
|
13258
13749
|
const strategy = strategyOf3(read.forecast);
|
|
13259
13750
|
const by = strategy === null ? "" : `${strategy}, `;
|
|
13260
|
-
|
|
13751
|
+
const merged = read.mergedVersion === undefined ? "" : `, ${read.mergedVersion} once this branch's version file merges`;
|
|
13752
|
+
return `Release forecast: this branch ${read.forecast.sentence}` + ` (${by}${read.ref} at ${read.baseVersion}${merged}, ${waitingClause(read.waiting.length)})`;
|
|
13261
13753
|
}
|
|
13262
13754
|
function blockOpen(forecast) {
|
|
13263
13755
|
if (forecast === null || !forecast.ok)
|
|
@@ -13314,13 +13806,13 @@ function isRegularFile(full) {
|
|
|
13314
13806
|
return false;
|
|
13315
13807
|
}
|
|
13316
13808
|
}
|
|
13317
|
-
function
|
|
13809
|
+
function readFile5(repoRoot, path2) {
|
|
13318
13810
|
const resolved = resolve10(repoRoot, path2);
|
|
13319
13811
|
return { path: path2, resolved, present: isRegularFile(resolved) };
|
|
13320
13812
|
}
|
|
13321
13813
|
function resolveReleaseEnabled(settings, repoRoot) {
|
|
13322
|
-
const versionFile =
|
|
13323
|
-
const changelog =
|
|
13814
|
+
const versionFile = readFile5(repoRoot, settings.releaseVersionFile);
|
|
13815
|
+
const changelog = readFile5(repoRoot, settings.releaseChangelog);
|
|
13324
13816
|
if (settings.releaseEnabled === RELEASE_AUTO) {
|
|
13325
13817
|
return {
|
|
13326
13818
|
enabled: versionFile.present && changelog.present,
|
|
@@ -13333,7 +13825,7 @@ function resolveReleaseEnabled(settings, repoRoot) {
|
|
|
13333
13825
|
}
|
|
13334
13826
|
// packages/rafa/src/effort/store/changes.ts
|
|
13335
13827
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
13336
|
-
import { existsSync as
|
|
13828
|
+
import { existsSync as existsSync17 } from "fs";
|
|
13337
13829
|
var INSERT_CHANGE = `
|
|
13338
13830
|
INSERT INTO changes (
|
|
13339
13831
|
id, session_id, plan_stub, task_line,
|
|
@@ -13413,7 +13905,7 @@ var SELECT_PLAN_CHANGES = `
|
|
|
13413
13905
|
`;
|
|
13414
13906
|
function readPlanChanges(repoRoot, planStub) {
|
|
13415
13907
|
const path2 = sqliteStorePath(repoRoot);
|
|
13416
|
-
if (!
|
|
13908
|
+
if (!existsSync17(path2))
|
|
13417
13909
|
return [];
|
|
13418
13910
|
const rows = withSqliteStore(path2, "read", false, (db) => db.query(SELECT_PLAN_CHANGES).all(planStub));
|
|
13419
13911
|
return rows.map((row) => ({
|
|
@@ -13445,7 +13937,7 @@ function mergeGuardSettings(config) {
|
|
|
13445
13937
|
}
|
|
13446
13938
|
// packages/rafa-release/src/release/prepare.ts
|
|
13447
13939
|
import { mkdirSync as mkdirSync3, readFileSync as readFileSync17, writeFileSync as writeFileSync5 } from "fs";
|
|
13448
|
-
import { dirname as dirname11, join as
|
|
13940
|
+
import { dirname as dirname11, join as join27, posix as posix4 } from "path";
|
|
13449
13941
|
var NO_FRAGMENT = "no release fragment";
|
|
13450
13942
|
var WHITESPACE3 = /\s+/g;
|
|
13451
13943
|
function levelFields(reading) {
|
|
@@ -13538,7 +14030,7 @@ function prepareRelease(input) {
|
|
|
13538
14030
|
const fragment = { plan: input.plan, title, level, package: null, notes: lines.notes };
|
|
13539
14031
|
const name = allocateFragmentName(input.plan, read.base.waiting.map((waiting) => nameOf2(waiting.path)));
|
|
13540
14032
|
const path2 = posix4.join(input.settings.releaseFragments.replace(/\\/g, "/"), name);
|
|
13541
|
-
const resolved =
|
|
14033
|
+
const resolved = join27(input.repoRoot, path2);
|
|
13542
14034
|
const before = textOf2(resolved);
|
|
13543
14035
|
const after = serializeFragment(fragment);
|
|
13544
14036
|
const problems = lines.problem === null ? read.problems : [...read.problems, lines.problem];
|
|
@@ -13692,11 +14184,11 @@ var DEFAULT_RELEASE_PATHS = Object.freeze({
|
|
|
13692
14184
|
});
|
|
13693
14185
|
var MS_PER_DAY2 = 24 * 60 * 60 * 1000;
|
|
13694
14186
|
// packages/rafa-pr/src/cleanup/worktrees.ts
|
|
13695
|
-
import { join as
|
|
14187
|
+
import { join as join29, sep as sep2 } from "path";
|
|
13696
14188
|
|
|
13697
14189
|
// packages/rafa/src/start/worktree-dir.ts
|
|
13698
|
-
import { join as
|
|
13699
|
-
var WORKTREES_SUBDIR =
|
|
14190
|
+
import { join as join28, resolve as resolve11 } from "path";
|
|
14191
|
+
var WORKTREES_SUBDIR = join28(".rafa", "worktrees");
|
|
13700
14192
|
function worktreeDirAt(projectRoot, worktreeDir) {
|
|
13701
14193
|
return resolve11(projectRoot, worktreeDir);
|
|
13702
14194
|
}
|
|
@@ -13838,7 +14330,7 @@ function parseWorktrees(stdout) {
|
|
|
13838
14330
|
}
|
|
13839
14331
|
|
|
13840
14332
|
// packages/rafa-pr/src/cleanup/worktrees.ts
|
|
13841
|
-
var CLAUDE_WORKTREES_SUBDIR =
|
|
14333
|
+
var CLAUDE_WORKTREES_SUBDIR = join29(".claude", "worktrees");
|
|
13842
14334
|
var WORKTREE_LIST = Object.freeze(["worktree", "list", "--porcelain"]);
|
|
13843
14335
|
var GIT_DIR = Object.freeze(["rev-parse", "--absolute-git-dir"]);
|
|
13844
14336
|
var WORKTREE_STATUS = Object.freeze([
|
|
@@ -13847,7 +14339,7 @@ var WORKTREE_STATUS = Object.freeze([
|
|
|
13847
14339
|
"--porcelain=v1",
|
|
13848
14340
|
"--untracked-files=all"
|
|
13849
14341
|
]);
|
|
13850
|
-
var ADMIN_FILES = Object.freeze(["HEAD",
|
|
14342
|
+
var ADMIN_FILES = Object.freeze(["HEAD", join29("logs", "HEAD"), "index"]);
|
|
13851
14343
|
var MS_PER_DAY3 = 24 * 60 * 60 * 1000;
|
|
13852
14344
|
var LIVE_STATES = new Set(["running", "paused"]);
|
|
13853
14345
|
// packages/rafa-pr/src/commands/pr/declarations.ts
|
|
@@ -14819,11 +15311,11 @@ var DEFAULT_PR_SEAMS = Object.freeze({});
|
|
|
14819
15311
|
// packages/rafa-pr/src/commands/pr/open-pull.ts
|
|
14820
15312
|
var USAGE = PR_USAGE.open;
|
|
14821
15313
|
// packages/rafa-pr/src/docs/task-reading.ts
|
|
14822
|
-
import { homedir as
|
|
15314
|
+
import { homedir as homedir7 } from "os";
|
|
14823
15315
|
|
|
14824
15316
|
// packages/rafa/src/effort/store/stale-docs.ts
|
|
14825
15317
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
14826
|
-
import { existsSync as
|
|
15318
|
+
import { existsSync as existsSync18 } from "fs";
|
|
14827
15319
|
var STALE_DOC_KINDS = ["sighting", "unsettled"];
|
|
14828
15320
|
var INSERT_STALE_DOC = `
|
|
14829
15321
|
INSERT INTO stale_docs (
|
|
@@ -14908,7 +15400,7 @@ var SELECT_PLAN_STALE_DOCS = `
|
|
|
14908
15400
|
`;
|
|
14909
15401
|
function readStaleDocsForPlan(repoRoot, planStub) {
|
|
14910
15402
|
const path2 = sqliteStorePath(repoRoot);
|
|
14911
|
-
if (!
|
|
15403
|
+
if (!existsSync18(path2))
|
|
14912
15404
|
return [];
|
|
14913
15405
|
const rows = withSqliteStore(path2, "read", false, (db) => db.query(SELECT_PLAN_STALE_DOCS).all(planStub));
|
|
14914
15406
|
return rows.map((row) => ({
|
|
@@ -15054,7 +15546,7 @@ function fileLines(input) {
|
|
|
15054
15546
|
const more = rest > 0 ? [`- ...and ${rest} more.`] : [];
|
|
15055
15547
|
return [`The plan's commits touched these files since it left \`${base2}\`:`, ...listed2, ...more];
|
|
15056
15548
|
}
|
|
15057
|
-
function renderDocTaskSection(input, repoRoot, home =
|
|
15549
|
+
function renderDocTaskSection(input, repoRoot, home = homedir7()) {
|
|
15058
15550
|
const redact = localPathRedactor(repoRoot, home);
|
|
15059
15551
|
const lines = [DOC_TASK_HEADING, DOC_TASK_SENTENCE, ...sightingLines(input), ...fileLines(input)];
|
|
15060
15552
|
return redact(lines.join(`
|
|
@@ -15062,7 +15554,7 @@ function renderDocTaskSection(input, repoRoot, home = homedir6()) {
|
|
|
15062
15554
|
}
|
|
15063
15555
|
// packages/rafa-pr/src/plan/risk.ts
|
|
15064
15556
|
import { readFileSync as readFileSync19 } from "fs";
|
|
15065
|
-
import { isAbsolute as isAbsolute5, join as
|
|
15557
|
+
import { isAbsolute as isAbsolute5, join as join30, relative as relative8 } from "path";
|
|
15066
15558
|
|
|
15067
15559
|
// packages/rafa/src/plan/risk/secrets.ts
|
|
15068
15560
|
var SECRET_NAME_SHAPES = [
|
|
@@ -15173,8 +15665,8 @@ async function viewRepo(gh, target) {
|
|
|
15173
15665
|
}
|
|
15174
15666
|
return {
|
|
15175
15667
|
ok: true,
|
|
15176
|
-
name:
|
|
15177
|
-
visibility:
|
|
15668
|
+
name: stringField2(parsed, "nameWithOwner"),
|
|
15669
|
+
visibility: stringField2(parsed, "visibility")?.toLowerCase() ?? null
|
|
15178
15670
|
};
|
|
15179
15671
|
}
|
|
15180
15672
|
function parseJsonObject(text) {
|
|
@@ -15185,7 +15677,7 @@ function parseJsonObject(text) {
|
|
|
15185
15677
|
return null;
|
|
15186
15678
|
}
|
|
15187
15679
|
}
|
|
15188
|
-
function
|
|
15680
|
+
function stringField2(object, key) {
|
|
15189
15681
|
const value = object[key];
|
|
15190
15682
|
return typeof value === "string" && value !== "" ? value : null;
|
|
15191
15683
|
}
|
|
@@ -15254,7 +15746,7 @@ function toolsFinding(task, plan, seams) {
|
|
|
15254
15746
|
return null;
|
|
15255
15747
|
}
|
|
15256
15748
|
function displayPath(path2, seams) {
|
|
15257
|
-
const absolute = isAbsolute5(path2) ? path2 :
|
|
15749
|
+
const absolute = isAbsolute5(path2) ? path2 : join30(seams.repoRoot, path2);
|
|
15258
15750
|
const within = (root) => {
|
|
15259
15751
|
const step = relative8(root, absolute);
|
|
15260
15752
|
return step === "" || step.startsWith("..") || isAbsolute5(step) ? null : step;
|
|
@@ -15279,7 +15771,7 @@ function readText5(path2) {
|
|
|
15279
15771
|
function findSkillFile(name, seams) {
|
|
15280
15772
|
const tiers = resolveSkillTiers({ home: seams.home, projectRoot: seams.repoRoot, entry: seams.entry });
|
|
15281
15773
|
for (const { dir } of tiers) {
|
|
15282
|
-
const path2 =
|
|
15774
|
+
const path2 = join30(dir, name, "SKILL.md");
|
|
15283
15775
|
if (readText5(path2) !== null)
|
|
15284
15776
|
return path2;
|
|
15285
15777
|
}
|
|
@@ -15546,13 +16038,13 @@ async function retargetPullRequest(pull, base2, seams) {
|
|
|
15546
16038
|
return { kind: "retargeted", from, to: base2 };
|
|
15547
16039
|
}
|
|
15548
16040
|
// packages/rafa-pr/src/triage/base-run.ts
|
|
15549
|
-
import { existsSync as
|
|
16041
|
+
import { existsSync as existsSync20, mkdtempSync, readFileSync as readFileSync21, rmSync as rmSync3, symlinkSync } from "fs";
|
|
15550
16042
|
import { tmpdir } from "os";
|
|
15551
|
-
import { isAbsolute as isAbsolute7, join as
|
|
16043
|
+
import { isAbsolute as isAbsolute7, join as join32, normalize, relative as relative9, sep as sep3 } from "path";
|
|
15552
16044
|
|
|
15553
16045
|
// packages/rafa/src/suite/run.ts
|
|
15554
|
-
import { existsSync as
|
|
15555
|
-
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";
|
|
15556
16048
|
|
|
15557
16049
|
// packages/rafa/src/suite/unhandled.ts
|
|
15558
16050
|
var UNHANDLED_HEADING = "# Unhandled error between tests";
|
|
@@ -15764,7 +16256,7 @@ var OUTPUT_SUFFIX = ".output.txt";
|
|
|
15764
16256
|
function outputFileFor(junitFile) {
|
|
15765
16257
|
const name = basename5(junitFile);
|
|
15766
16258
|
const stem = name.endsWith(JUNIT_SUFFIX) ? name.slice(0, -JUNIT_SUFFIX.length) : name.slice(0, name.length - extname(name).length);
|
|
15767
|
-
return
|
|
16259
|
+
return join31(dirname12(junitFile), `${stem}${OUTPUT_SUFFIX}`);
|
|
15768
16260
|
}
|
|
15769
16261
|
function suiteEnv(base2) {
|
|
15770
16262
|
return Object.fromEntries(Object.entries(base2).filter(([key]) => !SUITE_ENV_REMOVED.includes(key)));
|
|
@@ -15891,7 +16383,7 @@ function walkJunit(xml) {
|
|
|
15891
16383
|
return walk;
|
|
15892
16384
|
}
|
|
15893
16385
|
function readJunit(path2) {
|
|
15894
|
-
if (!
|
|
16386
|
+
if (!existsSync19(path2))
|
|
15895
16387
|
return { junit: "missing", failures: [], files: [], cases: [] };
|
|
15896
16388
|
let text;
|
|
15897
16389
|
try {
|
|
@@ -15974,13 +16466,13 @@ async function runInTree(tree, file, junitFile, commit, options) {
|
|
|
15974
16466
|
}
|
|
15975
16467
|
async function checkOutAndRun(tree, file, junitFile, commit, options) {
|
|
15976
16468
|
const short = shortCommit(commit);
|
|
15977
|
-
const modules =
|
|
15978
|
-
if (!
|
|
16469
|
+
const modules = join32(options.checkout, NODE_MODULES);
|
|
16470
|
+
if (!existsSync20(modules))
|
|
15979
16471
|
return failedRun(`The run checkout holds no ${NODE_MODULES} to link into the worktree at ${short}.`);
|
|
15980
|
-
if (!
|
|
16472
|
+
if (!existsSync20(join32(tree, file)))
|
|
15981
16473
|
return failedRun(`${file} does not exist at ${short}.`);
|
|
15982
16474
|
try {
|
|
15983
|
-
symlinkSync(modules,
|
|
16475
|
+
symlinkSync(modules, join32(tree, NODE_MODULES), "dir");
|
|
15984
16476
|
} catch (error) {
|
|
15985
16477
|
return failedRun(`Could not link ${NODE_MODULES} into the worktree at ${short}: ${messageOf(error)}`);
|
|
15986
16478
|
}
|
|
@@ -15998,18 +16490,18 @@ async function runFileAt(commit, file, options) {
|
|
|
15998
16490
|
const git = options.git ?? createGitRunner(options.checkout);
|
|
15999
16491
|
let scratch;
|
|
16000
16492
|
try {
|
|
16001
|
-
scratch = mkdtempSync(
|
|
16493
|
+
scratch = mkdtempSync(join32(options.tempRoot ?? tmpdir(), SCRATCH_PREFIX));
|
|
16002
16494
|
} catch (error) {
|
|
16003
16495
|
return failedRun(`Could not make a temporary folder for the worktree: ${messageOf(error)}`);
|
|
16004
16496
|
}
|
|
16005
|
-
const tree =
|
|
16497
|
+
const tree = join32(scratch, "worktree");
|
|
16006
16498
|
let added = false;
|
|
16007
16499
|
try {
|
|
16008
16500
|
const add = git(["worktree", "add", "--detach", "--quiet", tree, commit]);
|
|
16009
16501
|
if (!add.ok)
|
|
16010
16502
|
return failedRun(`Could not check out ${shortCommit(commit)} in a temporary worktree: ${gitSaid(add) || "git said nothing"}`);
|
|
16011
16503
|
added = true;
|
|
16012
|
-
return await checkOutAndRun(tree, file,
|
|
16504
|
+
return await checkOutAndRun(tree, file, join32(scratch, "base.junit.xml"), commit, options);
|
|
16013
16505
|
} catch (error) {
|
|
16014
16506
|
return failedRun(`Could not run ${file} at ${shortCommit(commit)}: ${messageOf(error)}`);
|
|
16015
16507
|
} finally {
|
|
@@ -16141,17 +16633,17 @@ function strippedText(text) {
|
|
|
16141
16633
|
const taken = text.replace(COMMIT_HASH, "").replace(FOLDER_PREFIX, "").replace(NUMBER, "");
|
|
16142
16634
|
return oneLine7(taken);
|
|
16143
16635
|
}
|
|
16144
|
-
function
|
|
16636
|
+
function keyText2(text) {
|
|
16145
16637
|
const stripped = strippedText(text);
|
|
16146
16638
|
return stripped.length > 0 ? stripped : oneLine7(text);
|
|
16147
16639
|
}
|
|
16148
16640
|
function testFailureKeyOf(failure2) {
|
|
16149
16641
|
const test = failure2.file === null ? oneLine7(failure2.name) : `${basename6(failure2.file)}${CASE_SEPARATOR}${oneLine7(failure2.name)}`;
|
|
16150
|
-
return failure2.evidence === null ? test : `${test}${KEY_SEPARATOR}${
|
|
16642
|
+
return failure2.evidence === null ? test : `${test}${KEY_SEPARATOR}${keyText2(failure2.evidence)}`;
|
|
16151
16643
|
}
|
|
16152
16644
|
function bugKeyOf(trackerPath, artifact, what = null) {
|
|
16153
16645
|
const failure2 = testFailureOf({ what, artifact });
|
|
16154
|
-
return failure2 === null ? `${basename6(trackerPath)}${KEY_SEPARATOR}${
|
|
16646
|
+
return failure2 === null ? `${basename6(trackerPath)}${KEY_SEPARATOR}${keyText2(artifact)}` : testFailureKeyOf(failure2);
|
|
16155
16647
|
}
|
|
16156
16648
|
function legacyBugKeyOf(trackerPath, artifact) {
|
|
16157
16649
|
return `${basename6(trackerPath)}${KEY_SEPARATOR}${oneLine7(artifact)}`;
|
|
@@ -16170,7 +16662,7 @@ function sameFailure(failure2, baseline) {
|
|
|
16170
16662
|
const message = baseline.message ?? null;
|
|
16171
16663
|
if (!sameTest || !hasText(message))
|
|
16172
16664
|
return sameTest;
|
|
16173
|
-
return evidence !== null &&
|
|
16665
|
+
return evidence !== null && keyText2(evidence).includes(keyText2(message));
|
|
16174
16666
|
}
|
|
16175
16667
|
function inheritedFailureOf(bug, failures) {
|
|
16176
16668
|
const failure2 = testFailureOf(bug);
|
|
@@ -16899,8 +17391,8 @@ function rankedCandidates(report2, record, openBugs, weights) {
|
|
|
16899
17391
|
return [...ranked].sort((a, b) => b.score - a.score);
|
|
16900
17392
|
}
|
|
16901
17393
|
// packages/rafa-pr/src/triage/triage.ts
|
|
16902
|
-
import { homedir as
|
|
16903
|
-
import { join as
|
|
17394
|
+
import { homedir as homedir8 } from "os";
|
|
17395
|
+
import { join as join34 } from "path";
|
|
16904
17396
|
|
|
16905
17397
|
// packages/rafa/src/effort/store/machine-fault.ts
|
|
16906
17398
|
var BUILD_FAILURE = /\b(?:abort(?:ed|s)?|broke|broken|crash(?:ed|es)?|error|errors|fail(?:ed|ing|s|ure|ures)?|unusable)\b/iu;
|
|
@@ -16966,7 +17458,7 @@ function machineFaultSentence(fault) {
|
|
|
16966
17458
|
|
|
16967
17459
|
// packages/rafa/src/effort/store/tracker-refs.ts
|
|
16968
17460
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
16969
|
-
import { existsSync as
|
|
17461
|
+
import { existsSync as existsSync21 } from "fs";
|
|
16970
17462
|
var SELECT_HELD2 = `
|
|
16971
17463
|
SELECT seq, tracker_ref FROM findings
|
|
16972
17464
|
WHERE session_id = ? AND artifact = ?
|
|
@@ -17115,7 +17607,7 @@ function writeTrackerRef(repoRoot, write, seams = {}) {
|
|
|
17115
17607
|
wanted.json,
|
|
17116
17608
|
collectedAt
|
|
17117
17609
|
];
|
|
17118
|
-
const [action, stored] = withSqliteStore(path2, "write", !
|
|
17610
|
+
const [action, stored] = withSqliteStore(path2, "write", !existsSync21(path2), (db) => {
|
|
17119
17611
|
const place = db.transaction(() => placeRef(db, path2, write, wanted, superseded, insertValues));
|
|
17120
17612
|
return place.immediate();
|
|
17121
17613
|
});
|
|
@@ -17124,7 +17616,7 @@ function writeTrackerRef(repoRoot, write, seams = {}) {
|
|
|
17124
17616
|
function readTrackerRef(repoRoot, artifact) {
|
|
17125
17617
|
checkArtifact2("read", artifact);
|
|
17126
17618
|
const path2 = sqliteStorePath(repoRoot);
|
|
17127
|
-
if (!
|
|
17619
|
+
if (!existsSync21(path2))
|
|
17128
17620
|
return null;
|
|
17129
17621
|
const newest = withSqliteStore(path2, "read", false, (db) => db.query(SELECT_NEWEST).get(artifact));
|
|
17130
17622
|
return newest === null ? null : heldRefOf(path2, newest.seq, newest.tracker_ref).ref;
|
|
@@ -17134,10 +17626,10 @@ function readTrackerRef(repoRoot, artifact) {
|
|
|
17134
17626
|
import { relative as relative11, resolve as resolve14, sep as sep4 } from "path";
|
|
17135
17627
|
|
|
17136
17628
|
// packages/rafa/src/project/package-of.ts
|
|
17137
|
-
import { existsSync as
|
|
17138
|
-
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";
|
|
17139
17631
|
var DISK_PACKAGE_FILE_SYSTEM = Object.freeze({
|
|
17140
|
-
exists: (path2) =>
|
|
17632
|
+
exists: (path2) => existsSync22(path2),
|
|
17141
17633
|
readFile: (path2) => readFileSync23(path2, "utf8")
|
|
17142
17634
|
});
|
|
17143
17635
|
var PACKAGE_MANIFESTS = Object.freeze(["package.json"]);
|
|
@@ -17149,7 +17641,7 @@ function textOrNull2(value) {
|
|
|
17149
17641
|
return typeof value === "string" && value.trim() !== "" ? value : null;
|
|
17150
17642
|
}
|
|
17151
17643
|
function ownerAt(dir, root, fs2) {
|
|
17152
|
-
const file = PACKAGE_MANIFESTS.map((name) =>
|
|
17644
|
+
const file = PACKAGE_MANIFESTS.map((name) => join33(dir, name)).find((path2) => fs2.exists(path2));
|
|
17153
17645
|
if (file === undefined)
|
|
17154
17646
|
return null;
|
|
17155
17647
|
try {
|
|
@@ -17411,10 +17903,10 @@ function triageStaleDocs(staleDocs, redact) {
|
|
|
17411
17903
|
}
|
|
17412
17904
|
|
|
17413
17905
|
// packages/rafa-pr/src/triage/triage.ts
|
|
17414
|
-
var PRIVATE_TRIAGE_DIR =
|
|
17906
|
+
var PRIVATE_TRIAGE_DIR = join34(".rafa", "triage", "private");
|
|
17415
17907
|
var BLOCKER_SEPARATOR = "; ";
|
|
17416
17908
|
function privateTriageDir(repoRoot) {
|
|
17417
|
-
return
|
|
17909
|
+
return join34(repoRoot, PRIVATE_TRIAGE_DIR);
|
|
17418
17910
|
}
|
|
17419
17911
|
function createPrivateTriageTracker(repoRoot, options = {}) {
|
|
17420
17912
|
return createLocalTracker({
|
|
@@ -17660,7 +18152,7 @@ async function triageReport(options) {
|
|
|
17660
18152
|
checkPrivateTracker(options.tracker, privateTracker);
|
|
17661
18153
|
const blocker = triageBlockers(options);
|
|
17662
18154
|
const checkout = options.checkout ?? repoRoot;
|
|
17663
|
-
const local = localPathRedactor([checkout, repoRoot], options.home ??
|
|
18155
|
+
const local = localPathRedactor([checkout, repoRoot], options.home ?? homedir8());
|
|
17664
18156
|
const redact = (text) => redactSecrets(local(text), options.secrets);
|
|
17665
18157
|
const verifyRefs = options.verifyRefs ?? createArtifactRefsVerifier(checkout, options.env);
|
|
17666
18158
|
const routes = {
|
|
@@ -17716,7 +18208,7 @@ async function triageReport(options) {
|
|
|
17716
18208
|
return { blocker, bugs, staleDocs: triageStaleDocs(options.report.staleDocs, redact) };
|
|
17717
18209
|
}
|
|
17718
18210
|
// packages/rafa-run/src/claims/device.ts
|
|
17719
|
-
import { existsSync as
|
|
18211
|
+
import { existsSync as existsSync23 } from "fs";
|
|
17720
18212
|
var NO_CLAIMANT = "no claim can name this device";
|
|
17721
18213
|
function ndjsonReason() {
|
|
17722
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}`;
|
|
@@ -17731,7 +18223,7 @@ function readDeviceStoreId(repoRoot, config) {
|
|
|
17731
18223
|
if (config.store === "ndjson")
|
|
17732
18224
|
return { ok: false, cause: "ndjson", reason: ndjsonReason() };
|
|
17733
18225
|
const path2 = sqliteStorePath(repoRoot);
|
|
17734
|
-
if (!
|
|
18226
|
+
if (!existsSync23(path2))
|
|
17735
18227
|
return { ok: false, cause: "absent", reason: absentReason(path2) };
|
|
17736
18228
|
const ids = withSqliteStore(path2, "read", false, (db) => {
|
|
17737
18229
|
const meta = readStoreMeta(db);
|
|
@@ -18121,7 +18613,7 @@ var REMOTE_BRANCH_FORMAT = [
|
|
|
18121
18613
|
|
|
18122
18614
|
// packages/rafa-run/src/start/loop-events.ts
|
|
18123
18615
|
import { appendFileSync, mkdirSync as mkdirSync5 } from "fs";
|
|
18124
|
-
import { join as
|
|
18616
|
+
import { join as join35 } from "path";
|
|
18125
18617
|
|
|
18126
18618
|
// packages/rafa-run/src/start/suite-blocker.ts
|
|
18127
18619
|
import { readFileSync as readFileSync24, writeFileSync as writeFileSync8 } from "fs";
|
|
@@ -18442,7 +18934,7 @@ function eventsFilePath(root, sessionId) {
|
|
|
18442
18934
|
if (!isSessionId(sessionId)) {
|
|
18443
18935
|
throw new Error(`events file: unusable session id ${JSON.stringify(sessionId)}`);
|
|
18444
18936
|
}
|
|
18445
|
-
return
|
|
18937
|
+
return join35(runsDir(root), `${sessionId}${EVENTS_EXTENSION}`);
|
|
18446
18938
|
}
|
|
18447
18939
|
function bindEventsFile(root, sessionId, warn2 = (line) => {
|
|
18448
18940
|
process.stderr.write(line);
|
|
@@ -18493,7 +18985,7 @@ function injectionPlace(trackerContent, taskInfo) {
|
|
|
18493
18985
|
}
|
|
18494
18986
|
async function taskTokens(checkout, sessionId, home) {
|
|
18495
18987
|
try {
|
|
18496
|
-
const { usage } = await readSessionLog(
|
|
18988
|
+
const { usage } = await readSessionLog(join35(sessionLogDir(checkout, home), `${sessionId}.jsonl`));
|
|
18497
18989
|
return usage.inputTokens + usage.cacheCreationInputTokens + usage.outputTokens;
|
|
18498
18990
|
} catch {
|
|
18499
18991
|
return null;
|
|
@@ -18746,7 +19238,7 @@ var USAGE2 = "rafa switch <n | -> [--no-rehome]";
|
|
|
18746
19238
|
var SWITCH_REFUSAL_EXIT = 2;
|
|
18747
19239
|
var BACK = "-";
|
|
18748
19240
|
var REHOME_FLAG = "rehome";
|
|
18749
|
-
var
|
|
19241
|
+
var ISSUE_NUMBER4 = /^[1-9]\d*$/u;
|
|
18750
19242
|
function refusal3(message) {
|
|
18751
19243
|
return new CommandExit(SWITCH_REFUSAL_EXIT, `\u274C ${message}`);
|
|
18752
19244
|
}
|
|
@@ -18761,7 +19253,7 @@ function readSwitchTarget(args) {
|
|
|
18761
19253
|
throw lineRefusal(`Expected one target, got ${String(args.length)}: ${args.join(" ")}`, USAGE2);
|
|
18762
19254
|
if (word === BACK)
|
|
18763
19255
|
return { kind: "back" };
|
|
18764
|
-
if (!
|
|
19256
|
+
if (!ISSUE_NUMBER4.test(word)) {
|
|
18765
19257
|
throw lineRefusal(`"${word}" is no issue number, which is a whole number from 1, nor - for the previous place`, USAGE2);
|
|
18766
19258
|
}
|
|
18767
19259
|
return { kind: "number", number: Number(word) };
|
|
@@ -19112,11 +19604,11 @@ function parseArgs(argv, spec = {}) {
|
|
|
19112
19604
|
import { rmSync as rmSync5 } from "fs";
|
|
19113
19605
|
|
|
19114
19606
|
// packages/rafa-run/src/plan/list.ts
|
|
19115
|
-
import { existsSync as
|
|
19116
|
-
import { join as
|
|
19607
|
+
import { existsSync as existsSync24, readdirSync as readdirSync8, readFileSync as readFileSync25 } from "fs";
|
|
19608
|
+
import { join as join36 } from "path";
|
|
19117
19609
|
function listing(dir, stub) {
|
|
19118
|
-
const plan =
|
|
19119
|
-
const trackerPath =
|
|
19610
|
+
const plan = join36(dir, planFileName(stub, false));
|
|
19611
|
+
const trackerPath = join36(dir, planFileName(stub, true));
|
|
19120
19612
|
const tracker = isFile(trackerPath) ? trackerPath : null;
|
|
19121
19613
|
const planModel = parsePlan(readFileSync25(plan, "utf8"));
|
|
19122
19614
|
const counted4 = tracker === null ? planModel : parsePlan(readFileSync25(tracker, "utf8"));
|
|
@@ -19124,9 +19616,9 @@ function listing(dir, stub) {
|
|
|
19124
19616
|
}
|
|
19125
19617
|
function listPlans(plans) {
|
|
19126
19618
|
const dir = plans.path;
|
|
19127
|
-
if (!
|
|
19619
|
+
if (!existsSync24(dir))
|
|
19128
19620
|
return { dir, plans: [] };
|
|
19129
|
-
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));
|
|
19130
19622
|
return { dir, plans: stubs.map((stub) => listing(dir, stub)) };
|
|
19131
19623
|
}
|
|
19132
19624
|
|
|
@@ -19275,6 +19767,22 @@ function hasStartedBranch(sources, remote, refs, stub, note) {
|
|
|
19275
19767
|
return messages === null || !claimsOnly(messages);
|
|
19276
19768
|
});
|
|
19277
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
|
+
}
|
|
19278
19786
|
function openWorld(sources) {
|
|
19279
19787
|
let problems = [];
|
|
19280
19788
|
const note = (problem) => {
|
|
@@ -19291,6 +19799,9 @@ function openWorld(sources) {
|
|
|
19291
19799
|
return reading;
|
|
19292
19800
|
});
|
|
19293
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));
|
|
19294
19805
|
return {
|
|
19295
19806
|
sources,
|
|
19296
19807
|
remote,
|
|
@@ -19301,7 +19812,13 @@ function openWorld(sources) {
|
|
|
19301
19812
|
tracked: once(() => readTracked(sources, note)),
|
|
19302
19813
|
checkout,
|
|
19303
19814
|
branchPlan: once(() => readBranchPlan(branch(), plans(), sources.branchTemplate)),
|
|
19304
|
-
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
|
+
}),
|
|
19305
19822
|
openPull: once(() => readOpenPull(sources, branch(), note)),
|
|
19306
19823
|
roadmap,
|
|
19307
19824
|
picked: once(async () => {
|
|
@@ -20115,10 +20632,10 @@ async function readPrGreen(world) {
|
|
|
20115
20632
|
pullRequest: open.summary.number
|
|
20116
20633
|
};
|
|
20117
20634
|
}
|
|
20118
|
-
function readPlanUnstarted(world) {
|
|
20635
|
+
async function readPlanUnstarted(world) {
|
|
20119
20636
|
if (!onBase(world))
|
|
20120
20637
|
return null;
|
|
20121
|
-
const plan = world.
|
|
20638
|
+
const plan = await world.unmergedPlan();
|
|
20122
20639
|
if (plan === null)
|
|
20123
20640
|
return null;
|
|
20124
20641
|
return {
|
|
@@ -20482,14 +20999,14 @@ function isFirstDispatch(planPath) {
|
|
|
20482
20999
|
return tracker === null || !hasTickedTask(tracker);
|
|
20483
21000
|
}
|
|
20484
21001
|
// packages/rafa/src/project/bin-path.ts
|
|
20485
|
-
import { delimiter as delimiter2, isAbsolute as isAbsolute10, join as
|
|
20486
|
-
var RAFA_BIN_DIR =
|
|
20487
|
-
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");
|
|
20488
21005
|
|
|
20489
21006
|
// packages/rafa-run/src/start/runtime.ts
|
|
20490
|
-
import { existsSync as
|
|
20491
|
-
import { homedir as
|
|
20492
|
-
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";
|
|
20493
21010
|
|
|
20494
21011
|
// packages/rafa-run/src/start/session.ts
|
|
20495
21012
|
import { randomUUID as randomUUID6 } from "crypto";
|
|
@@ -20735,7 +21252,7 @@ function resolveRuntime(value, places) {
|
|
|
20735
21252
|
throw refusal4([`\u274C Refusing to start: \`--runtime\` names no runtime. Spell it ${SPELLING}.`]);
|
|
20736
21253
|
}
|
|
20737
21254
|
const isVersion = VERSION_SHAPE2.test(value);
|
|
20738
|
-
const named = isVersion ?
|
|
21255
|
+
const named = isVersion ? join38(places.home, RUNTIME_SUBDIR, value, RUNTIME_ENTRY) : resolve16(places.cwd, value);
|
|
20739
21256
|
refuseInsideSource(value, named, places);
|
|
20740
21257
|
const entry = entryOf2(value, named, isVersion, places.home);
|
|
20741
21258
|
const real = realpathSync2(entry);
|
|
@@ -20746,7 +21263,7 @@ function entryOf2(value, named, isVersion, home) {
|
|
|
20746
21263
|
if (isVersion) {
|
|
20747
21264
|
if (isFile4(named))
|
|
20748
21265
|
return named;
|
|
20749
|
-
const root =
|
|
21266
|
+
const root = join38(home, RUNTIME_SUBDIR);
|
|
20750
21267
|
const installed = installedVersions(root);
|
|
20751
21268
|
throw refusal4([
|
|
20752
21269
|
`\u274C Refusing to start: \`--runtime=${value}\` names no installed runtime: ${named} is no file.`,
|
|
@@ -20755,7 +21272,7 @@ function entryOf2(value, named, isVersion, home) {
|
|
|
20755
21272
|
}
|
|
20756
21273
|
if (isFile4(named))
|
|
20757
21274
|
return named;
|
|
20758
|
-
const inside =
|
|
21275
|
+
const inside = join38(named, RUNTIME_ENTRY);
|
|
20759
21276
|
if (isDirectory(named) && isFile4(inside))
|
|
20760
21277
|
return inside;
|
|
20761
21278
|
throw refusal4([
|
|
@@ -20773,8 +21290,8 @@ function refuseInsideSource(value, path3, places) {
|
|
|
20773
21290
|
]);
|
|
20774
21291
|
}
|
|
20775
21292
|
function sourceDirs({ cwd, root }) {
|
|
20776
|
-
const dirs = [
|
|
20777
|
-
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));
|
|
20778
21295
|
return [...new Set([...dirs, ...real])];
|
|
20779
21296
|
}
|
|
20780
21297
|
function isInside3(path3, dir) {
|
|
@@ -20783,7 +21300,7 @@ function isInside3(path3, dir) {
|
|
|
20783
21300
|
}
|
|
20784
21301
|
function installedVersions(root) {
|
|
20785
21302
|
try {
|
|
20786
|
-
return readdirSync9(root).filter((name) => isFile4(
|
|
21303
|
+
return readdirSync9(root).filter((name) => isFile4(join38(root, name, RUNTIME_ENTRY))).sort((a, b) => a.localeCompare(b));
|
|
20787
21304
|
} catch {
|
|
20788
21305
|
return [];
|
|
20789
21306
|
}
|
|
@@ -20811,7 +21328,7 @@ async function runFromSelectedRuntime(seams) {
|
|
|
20811
21328
|
if (value === undefined)
|
|
20812
21329
|
return false;
|
|
20813
21330
|
const cwd = seams.cwd ?? process.cwd();
|
|
20814
|
-
const entry = resolveRuntime(value, { cwd, root: seams.root, home: seams.home ??
|
|
21331
|
+
const entry = resolveRuntime(value, { cwd, root: seams.root, home: seams.home ?? homedir9() });
|
|
20815
21332
|
if (realOrResolved(seams.currentEntry ?? Bun.main) === entry)
|
|
20816
21333
|
return false;
|
|
20817
21334
|
const mode = activeOutputMode();
|
|
@@ -20943,12 +21460,12 @@ function markBudgetExit(options) {
|
|
|
20943
21460
|
activeOutput().error(" Raise its budget= or split it, then run again to retry.");
|
|
20944
21461
|
}
|
|
20945
21462
|
// packages/rafa-run/src/start/checkout-guard.ts
|
|
20946
|
-
import { existsSync as
|
|
21463
|
+
import { existsSync as existsSync26, realpathSync as realpathSync3 } from "fs";
|
|
20947
21464
|
var CHECKOUT_MOVED = "checkout moved";
|
|
20948
21465
|
var INDENT = " ";
|
|
20949
21466
|
var SHORT_COMMIT2 = 12;
|
|
20950
21467
|
function realDirOf(path3) {
|
|
20951
|
-
if (!
|
|
21468
|
+
if (!existsSync26(path3))
|
|
20952
21469
|
return null;
|
|
20953
21470
|
try {
|
|
20954
21471
|
return realpathSync3(path3);
|
|
@@ -21413,8 +21930,8 @@ function parseDecision(output) {
|
|
|
21413
21930
|
}
|
|
21414
21931
|
|
|
21415
21932
|
// packages/rafa-run/src/start/decision-prompt.ts
|
|
21416
|
-
import { existsSync as
|
|
21417
|
-
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";
|
|
21418
21935
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
21419
21936
|
var MODULE_DIR4 = dirname14(fileURLToPath4(import.meta.url));
|
|
21420
21937
|
var DECISION_PROMPT_FILE = "continue-decision-prompt.md";
|
|
@@ -21438,18 +21955,18 @@ function chooseRetrySections(template, retriesLeft) {
|
|
|
21438
21955
|
var NO_HOLDS = "(no reason was recorded)";
|
|
21439
21956
|
var NO_OPEN_TASKS = "(no open task is left)";
|
|
21440
21957
|
function bundledCandidates(file, moduleDir = MODULE_DIR4) {
|
|
21441
|
-
return [
|
|
21958
|
+
return [join39(moduleDir, file), join39(moduleDir, "..", "..", "..", "..", "src", file)];
|
|
21442
21959
|
}
|
|
21443
21960
|
function readBundledFile(file, moduleDir = MODULE_DIR4) {
|
|
21444
21961
|
const candidates = bundledCandidates(file, moduleDir);
|
|
21445
|
-
const found = candidates.find((candidate) =>
|
|
21962
|
+
const found = candidates.find((candidate) => existsSync27(candidate));
|
|
21446
21963
|
if (found === undefined) {
|
|
21447
21964
|
throw new Error(`loop continue: ${file} is missing: no file at ${candidates.join(" or ")}`);
|
|
21448
21965
|
}
|
|
21449
21966
|
return readFileSync28(found, "utf8");
|
|
21450
21967
|
}
|
|
21451
21968
|
function readProjectFile(path3) {
|
|
21452
|
-
if (!
|
|
21969
|
+
if (!existsSync27(path3))
|
|
21453
21970
|
return { text: null };
|
|
21454
21971
|
try {
|
|
21455
21972
|
return { text: readFileSync28(path3, "utf8") };
|
|
@@ -21640,7 +22157,7 @@ class LoopEnd extends CommandExit {
|
|
|
21640
22157
|
}
|
|
21641
22158
|
}
|
|
21642
22159
|
// packages/rafa-run/src/start/continue-run.ts
|
|
21643
|
-
import { existsSync as
|
|
22160
|
+
import { existsSync as existsSync28, readFileSync as readFileSync29 } from "fs";
|
|
21644
22161
|
|
|
21645
22162
|
// packages/rafa-run/src/start/decision-session.ts
|
|
21646
22163
|
import { randomUUID as randomUUID7 } from "crypto";
|
|
@@ -21833,7 +22350,7 @@ function whenOf(stop) {
|
|
|
21833
22350
|
function openingList(seed, trackerPath) {
|
|
21834
22351
|
if (seed.length === 0)
|
|
21835
22352
|
return seed;
|
|
21836
|
-
const kept =
|
|
22353
|
+
const kept = existsSync28(trackerPath) ? seedFrom(seed, readFileSync29(trackerPath, "utf8")) : [];
|
|
21837
22354
|
const back = seed.length - kept.length;
|
|
21838
22355
|
if (back > 0) {
|
|
21839
22356
|
activeOutput().info(`\u21A9\uFE0F ${back} task(s) the last --continue run passed over no longer read [BLOCKED], so this run takes them again.`);
|
|
@@ -22130,7 +22647,7 @@ import { randomUUID as randomUUID11 } from "crypto";
|
|
|
22130
22647
|
|
|
22131
22648
|
// packages/rafa/src/effort/store/absences.ts
|
|
22132
22649
|
import { randomUUID as randomUUID8 } from "crypto";
|
|
22133
|
-
import { existsSync as
|
|
22650
|
+
import { existsSync as existsSync29 } from "fs";
|
|
22134
22651
|
var ABSENCE_REASONS = {
|
|
22135
22652
|
"no-block": true,
|
|
22136
22653
|
"unclosed-block": true,
|
|
@@ -22190,7 +22707,7 @@ function writeReportAbsence(repoRoot, write, seams = {}) {
|
|
|
22190
22707
|
write.outcome,
|
|
22191
22708
|
collectedAt
|
|
22192
22709
|
];
|
|
22193
|
-
const appended2 = withSqliteStore(path3, "write", !
|
|
22710
|
+
const appended2 = withSqliteStore(path3, "write", !existsSync29(path3), (db) => db.query(INSERT_ABSENCE).run(...values).changes);
|
|
22194
22711
|
return { path: path3, appended: appended2, skipped: 1 - appended2 };
|
|
22195
22712
|
}
|
|
22196
22713
|
|
|
@@ -22355,8 +22872,8 @@ function describeTaskReportRecord(record) {
|
|
|
22355
22872
|
}
|
|
22356
22873
|
|
|
22357
22874
|
// packages/rafa/src/utils/progress.ts
|
|
22358
|
-
import { existsSync as
|
|
22359
|
-
import { join as
|
|
22875
|
+
import { existsSync as existsSync30, writeFileSync as writeFileSync9 } from "fs";
|
|
22876
|
+
import { join as join40 } from "path";
|
|
22360
22877
|
var PROGRESS_FILE_NAME = "progress.txt";
|
|
22361
22878
|
var PROGRESS_CAP_BYTES = 16000;
|
|
22362
22879
|
var LISTED_FIELDS = [
|
|
@@ -22398,7 +22915,7 @@ var ESCAPED_CODE_POINTS = new Set([
|
|
|
22398
22915
|
8233
|
|
22399
22916
|
]);
|
|
22400
22917
|
function progressFilePath(repoRoot) {
|
|
22401
|
-
return
|
|
22918
|
+
return join40(repoRoot, PROGRESS_FILE_NAME);
|
|
22402
22919
|
}
|
|
22403
22920
|
function escapeValue(value) {
|
|
22404
22921
|
let escaped = "";
|
|
@@ -22459,7 +22976,7 @@ function renderProgressText(findings, capBytes = PROGRESS_CAP_BYTES) {
|
|
|
22459
22976
|
}
|
|
22460
22977
|
function readProgressFindings(repoRoot, planStub) {
|
|
22461
22978
|
const path3 = sqliteStorePath(repoRoot);
|
|
22462
|
-
if (!
|
|
22979
|
+
if (!existsSync30(path3))
|
|
22463
22980
|
return [];
|
|
22464
22981
|
const rows = withSqliteStore(path3, "read", false, (db) => {
|
|
22465
22982
|
const query = db.query(SELECT_FINDINGS2);
|
|
@@ -22580,17 +23097,17 @@ function renderInheritedSection(failures) {
|
|
|
22580
23097
|
|
|
22581
23098
|
// packages/rafa-run/src/start/preflight.ts
|
|
22582
23099
|
import { randomUUID as randomUUID10 } from "crypto";
|
|
22583
|
-
import { existsSync as
|
|
22584
|
-
import { homedir as
|
|
22585
|
-
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";
|
|
22586
23103
|
|
|
22587
23104
|
// packages/rafa/src/effort/store/schema-report.ts
|
|
22588
|
-
import { existsSync as
|
|
23105
|
+
import { existsSync as existsSync31 } from "fs";
|
|
22589
23106
|
import { Database } from "bun:sqlite";
|
|
22590
23107
|
var NO_NEXT_STEP = "none";
|
|
22591
23108
|
function readSchemaReport(path3, options = {}) {
|
|
22592
23109
|
guardTestProcess(path3);
|
|
22593
|
-
if (!
|
|
23110
|
+
if (!existsSync31(path3))
|
|
22594
23111
|
return absentReport(path3);
|
|
22595
23112
|
const catalogue = sqliteCatalogue(options.migrations ?? SQLITE_MIGRATIONS);
|
|
22596
23113
|
const store = readReadOnly(path3);
|
|
@@ -22980,7 +23497,7 @@ function knownMissingNotice(lines) {
|
|
|
22980
23497
|
}
|
|
22981
23498
|
function agentSourcePath(planPath) {
|
|
22982
23499
|
const tracker = trackerPathFor(planPath);
|
|
22983
|
-
return
|
|
23500
|
+
return existsSync32(tracker) ? tracker : planPath;
|
|
22984
23501
|
}
|
|
22985
23502
|
function readIfReadable2(path3) {
|
|
22986
23503
|
try {
|
|
@@ -23012,7 +23529,7 @@ function refuseUnresolvableAgents(options) {
|
|
|
23012
23529
|
};
|
|
23013
23530
|
const roots = {
|
|
23014
23531
|
repoRoot: options.repoRoot,
|
|
23015
|
-
home: agents.home ??
|
|
23532
|
+
home: agents.home ?? homedir10(),
|
|
23016
23533
|
...agents.entry === undefined ? {} : { entry: agents.entry }
|
|
23017
23534
|
};
|
|
23018
23535
|
const roster = resolveAgentRoster(roots, settings);
|
|
@@ -23136,7 +23653,7 @@ function announceReminders(planPath, reminders) {
|
|
|
23136
23653
|
function announceUnknownMigrations(repoRoot) {
|
|
23137
23654
|
const output = activeOutput();
|
|
23138
23655
|
try {
|
|
23139
|
-
const report2 = readSchemaReport(
|
|
23656
|
+
const report2 = readSchemaReport(join41(effortStoreDir(repoRoot), SQLITE_STORE_FILE_NAME));
|
|
23140
23657
|
for (const migration of unknownAdditive(report2))
|
|
23141
23658
|
output.warn(unknownAdditiveWarning(migration));
|
|
23142
23659
|
} catch (error) {
|
|
@@ -23208,9 +23725,9 @@ async function runStartPreflight(options) {
|
|
|
23208
23725
|
}
|
|
23209
23726
|
|
|
23210
23727
|
// packages/rafa-run/src/start/type-step.ts
|
|
23211
|
-
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";
|
|
23212
23729
|
import { tmpdir as tmpdir2 } from "os";
|
|
23213
|
-
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";
|
|
23214
23731
|
var TEST_FILE_SUFFIX = ".test.ts";
|
|
23215
23732
|
var TSC_FLAGS = ["--noEmit", "--pretty", "false"];
|
|
23216
23733
|
var CANNOT_START_CODES = [126, 127];
|
|
@@ -23284,8 +23801,8 @@ function findNodeModules(checkout, git) {
|
|
|
23284
23801
|
const stop = walkStop(git);
|
|
23285
23802
|
const top = stop !== null && isUnder(start, stop) ? stop : start;
|
|
23286
23803
|
for (let dir = start;; dir = dirname15(dir)) {
|
|
23287
|
-
const modules =
|
|
23288
|
-
if (
|
|
23804
|
+
const modules = join42(dir, NODE_MODULES2);
|
|
23805
|
+
if (existsSync33(join42(modules, ...TSC_BIN)))
|
|
23289
23806
|
return modules;
|
|
23290
23807
|
if (dir === top || dirname15(dir) === dir)
|
|
23291
23808
|
return null;
|
|
@@ -23294,9 +23811,9 @@ function findNodeModules(checkout, git) {
|
|
|
23294
23811
|
function scratchTsconfigFields(tree, files, modules) {
|
|
23295
23812
|
const root = resolve18(tree);
|
|
23296
23813
|
return {
|
|
23297
|
-
extends:
|
|
23298
|
-
compilerOptions: { typeRoots: [
|
|
23299
|
-
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)),
|
|
23300
23817
|
include: []
|
|
23301
23818
|
};
|
|
23302
23819
|
}
|
|
@@ -23305,13 +23822,13 @@ function scratchTsconfig(tree, files, modules) {
|
|
|
23305
23822
|
`;
|
|
23306
23823
|
}
|
|
23307
23824
|
function tscArgv(modules, scratch) {
|
|
23308
|
-
return [
|
|
23825
|
+
return [join42(modules, ...TSC_BIN), "-p", scratch, ...TSC_FLAGS];
|
|
23309
23826
|
}
|
|
23310
23827
|
function modulesFor(checkout, git) {
|
|
23311
|
-
return findNodeModules(checkout, git) ??
|
|
23828
|
+
return findNodeModules(checkout, git) ?? join42(resolve18(checkout), NODE_MODULES2);
|
|
23312
23829
|
}
|
|
23313
23830
|
function readTypeCheckRecipe(checkout, git) {
|
|
23314
|
-
if (!
|
|
23831
|
+
if (!existsSync33(join42(checkout, "tsconfig.json")))
|
|
23315
23832
|
return null;
|
|
23316
23833
|
const modules = findNodeModules(checkout, git);
|
|
23317
23834
|
return modules === null ? null : { checkout, modules };
|
|
@@ -23406,8 +23923,8 @@ ${run.stderr}`.split(`
|
|
|
23406
23923
|
`).map((line) => line.trim()).find((line) => line !== "");
|
|
23407
23924
|
}
|
|
23408
23925
|
async function checkTree(input, modules, tree, files) {
|
|
23409
|
-
const scratchDir = mkdtempSync2(
|
|
23410
|
-
const scratch =
|
|
23926
|
+
const scratchDir = mkdtempSync2(join42(tmpdir2(), "rafa-type-step-"));
|
|
23927
|
+
const scratch = join42(scratchDir, SCRATCH_NAME);
|
|
23411
23928
|
try {
|
|
23412
23929
|
writeFileSync10(scratch, scratchTsconfig(tree, files, modules), "utf8");
|
|
23413
23930
|
let run;
|
|
@@ -23434,21 +23951,21 @@ async function checkTree(input, modules, tree, files) {
|
|
|
23434
23951
|
}
|
|
23435
23952
|
}
|
|
23436
23953
|
async function inBaseTree(input, label, modules, check) {
|
|
23437
|
-
const parent = mkdtempSync2(
|
|
23438
|
-
const tree =
|
|
23954
|
+
const parent = mkdtempSync2(join42(tmpdir2(), "rafa-type-base-"));
|
|
23955
|
+
const tree = join42(parent, "tree");
|
|
23439
23956
|
try {
|
|
23440
23957
|
const added = input.git(["worktree", "add", "--detach", tree, input.base]);
|
|
23441
23958
|
if (!added.ok) {
|
|
23442
23959
|
activeOutput().warn(`\u26A0\uFE0F The ${label} could not check out ${input.base} (${gitSaid(added) || "nothing said"}); it reads no error as new.`);
|
|
23443
23960
|
return null;
|
|
23444
23961
|
}
|
|
23445
|
-
if (
|
|
23446
|
-
symlinkSync2(modules,
|
|
23447
|
-
if (!
|
|
23962
|
+
if (existsSync33(modules) && !existsSync33(join42(tree, NODE_MODULES2)))
|
|
23963
|
+
symlinkSync2(modules, join42(tree, NODE_MODULES2));
|
|
23964
|
+
if (!existsSync33(join42(tree, "tsconfig.json")))
|
|
23448
23965
|
return { kind: "read", errors: [] };
|
|
23449
23966
|
return await check(tree);
|
|
23450
23967
|
} finally {
|
|
23451
|
-
if (
|
|
23968
|
+
if (existsSync33(tree)) {
|
|
23452
23969
|
const removed = input.git(["worktree", "remove", "--force", tree]);
|
|
23453
23970
|
if (!removed.ok)
|
|
23454
23971
|
activeOutput().warn(`\u26A0\uFE0F The ${label} could not remove its worktree ${tree} (${gitSaid(removed) || "nothing said"}).`);
|
|
@@ -23480,13 +23997,13 @@ function interrupted(label) {
|
|
|
23480
23997
|
return INTERRUPTED2;
|
|
23481
23998
|
}
|
|
23482
23999
|
function cannotStart(label, modules, run) {
|
|
23483
|
-
const tsc =
|
|
24000
|
+
const tsc = join42(modules, ...TSC_BIN);
|
|
23484
24001
|
const blocker = cannotStartBlockerText(label, tsc, run.run, run.said, scriptInterpreter(tsc));
|
|
23485
24002
|
activeOutput().warn(`\u26A0\uFE0F ${blocker}`);
|
|
23486
24003
|
return { ran: false, red: false, interrupted: false, cannotStart: true, blocker };
|
|
23487
24004
|
}
|
|
23488
24005
|
function filesToCheck(input, label) {
|
|
23489
|
-
if (!
|
|
24006
|
+
if (!existsSync33(join42(input.checkout, "tsconfig.json"))) {
|
|
23490
24007
|
activeOutput().info(`\uD83D\uDD0E ${label}: no tsconfig.json at the checkout root; nothing to type-check.`);
|
|
23491
24008
|
return null;
|
|
23492
24009
|
}
|
|
@@ -23826,14 +24343,14 @@ async function holdWhilePaused(options) {
|
|
|
23826
24343
|
}
|
|
23827
24344
|
}
|
|
23828
24345
|
// packages/rafa-run/src/start/plan-path.ts
|
|
23829
|
-
import { existsSync as
|
|
24346
|
+
import { existsSync as existsSync34 } from "fs";
|
|
23830
24347
|
import { resolve as resolve19 } from "path";
|
|
23831
24348
|
var DEFAULT_PLAN_FILE = "PLAN.md";
|
|
23832
24349
|
function resolvePlanPath(repoRoot, planDir, planArg) {
|
|
23833
24350
|
if (planArg)
|
|
23834
24351
|
return resolve19(repoRoot, planArg);
|
|
23835
24352
|
const inPlanDir = resolve19(repoRoot, planDir, DEFAULT_PLAN_FILE);
|
|
23836
|
-
return
|
|
24353
|
+
return existsSync34(inPlanDir) ? inPlanDir : resolve19(repoRoot, DEFAULT_PLAN_FILE);
|
|
23837
24354
|
}
|
|
23838
24355
|
// packages/rafa/src/pr/ci-poll.ts
|
|
23839
24356
|
var CI_POLL_INTERVAL_MS = 20000;
|
|
@@ -24373,20 +24890,41 @@ function refuseWorktreeWhileTracking(args, config) {
|
|
|
24373
24890
|
async function resolveRunBranch(request, seams = DEFAULT_BRANCH_SEAMS) {
|
|
24374
24891
|
const { args, base: base2, standing } = request;
|
|
24375
24892
|
const noBranch = standing === "no-branch";
|
|
24376
|
-
|
|
24893
|
+
const onBase2 = DEFAULT_BRANCHES.includes(base2) || base2 === request.runBase;
|
|
24894
|
+
if (!noBranch && !onBase2)
|
|
24377
24895
|
return base2;
|
|
24896
|
+
const createBranch = args.includes(CREATE_BRANCH_FLAG);
|
|
24378
24897
|
const outcome = await offerRunBranch({
|
|
24379
24898
|
repoRoot: request.checkout,
|
|
24380
24899
|
planStub: request.planStub,
|
|
24381
24900
|
base: base2,
|
|
24382
24901
|
standing,
|
|
24383
24902
|
anyBranch: args.includes(ANY_BRANCH_FLAG),
|
|
24384
|
-
createBranch
|
|
24903
|
+
createBranch,
|
|
24385
24904
|
branchTemplate: request.branchTemplate
|
|
24386
24905
|
}, seams);
|
|
24387
24906
|
if (outcome.kind === "moved")
|
|
24388
24907
|
return outcome.branch;
|
|
24389
|
-
|
|
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
|
+
`));
|
|
24390
24928
|
}
|
|
24391
24929
|
function branchOffer(planStub, base2, branchTemplate) {
|
|
24392
24930
|
if (planStub === null) {
|
|
@@ -24553,7 +25091,7 @@ async function runWorktreeSetup(request, seams = {}) {
|
|
|
24553
25091
|
|
|
24554
25092
|
// packages/rafa-run/src/start/worktree.ts
|
|
24555
25093
|
import { realpathSync as realpathSync5 } from "fs";
|
|
24556
|
-
import { join as
|
|
25094
|
+
import { join as join43, resolve as resolve20 } from "path";
|
|
24557
25095
|
|
|
24558
25096
|
// packages/rafa-run/src/start/claim-catch-up.ts
|
|
24559
25097
|
var OWN_COMMIT_FORMAT = "--format=%H%x09%P%x09%s";
|
|
@@ -24657,7 +25195,7 @@ var INDENT4 = " ";
|
|
|
24657
25195
|
var UNTOUCHED = `${INDENT4}The main checkout's branch and working tree were not touched.`;
|
|
24658
25196
|
var DEFAULT_WORKTREE_SEAMS = Object.freeze({});
|
|
24659
25197
|
function worktreePathFor(projectRoot, worktreeDir, stub) {
|
|
24660
|
-
return
|
|
25198
|
+
return join43(worktreeDirAt(projectRoot, worktreeDir), stub);
|
|
24661
25199
|
}
|
|
24662
25200
|
function addStep(route, plan, path3) {
|
|
24663
25201
|
const label = `add the worktree for ${plan.branch} at ${path3}`;
|
|
@@ -24921,13 +25459,15 @@ async function settleRunCheckout(request, seams = {}) {
|
|
|
24921
25459
|
const startedOn = (seams.checkedOutBranch ?? readCheckedOutBranch)(started.checkout);
|
|
24922
25460
|
const runBase = () => (seams.base ?? readBase2)(projectRoot, request.prBase);
|
|
24923
25461
|
if (!args.includes(AS_WORKTREE_FLAG)) {
|
|
24924
|
-
const
|
|
25462
|
+
const base3 = runBase();
|
|
25463
|
+
const stands = startedOn === null ? { base: base3, standing: "no-branch" } : { base: startedOn };
|
|
24925
25464
|
const branch = await (seams.offer ?? resolveRunBranch)({
|
|
24926
25465
|
checkout: started.checkout,
|
|
24927
25466
|
planStub,
|
|
24928
25467
|
...stands,
|
|
24929
25468
|
args,
|
|
24930
|
-
branchTemplate: request.branchTemplate
|
|
25469
|
+
branchTemplate: request.branchTemplate,
|
|
25470
|
+
runBase: base3
|
|
24931
25471
|
});
|
|
24932
25472
|
return Object.freeze({ projectRoot, checkout: started.checkout, branch });
|
|
24933
25473
|
}
|
|
@@ -24960,14 +25500,14 @@ function haltBeforeSession(options, seams = {}) {
|
|
|
24960
25500
|
return moved;
|
|
24961
25501
|
}
|
|
24962
25502
|
// packages/rafa-run/src/start/stale-docs.ts
|
|
24963
|
-
import { existsSync as
|
|
24964
|
-
import { homedir as
|
|
25503
|
+
import { existsSync as existsSync35, readFileSync as readFileSync32 } from "fs";
|
|
25504
|
+
import { homedir as homedir11 } from "os";
|
|
24965
25505
|
import { resolve as resolvePath } from "path";
|
|
24966
25506
|
var LINE_PREFIX = "Stale docs: ";
|
|
24967
25507
|
var INDENT5 = " ";
|
|
24968
25508
|
function localVersion(checkout, versionFile) {
|
|
24969
25509
|
const path3 = resolvePath(checkout, versionFile);
|
|
24970
|
-
if (!
|
|
25510
|
+
if (!existsSync35(path3))
|
|
24971
25511
|
return null;
|
|
24972
25512
|
try {
|
|
24973
25513
|
return readManifestVersion(readFileSync32(path3, "utf8"));
|
|
@@ -25051,7 +25591,7 @@ function refName(ref3) {
|
|
|
25051
25591
|
}
|
|
25052
25592
|
function createStartStaleDocs(options) {
|
|
25053
25593
|
const secrets = namedSecrets(options.config, options.env ?? process.env);
|
|
25054
|
-
const local = localPathRedactor([options.repoRoot, options.checkout], options.home ??
|
|
25594
|
+
const local = localPathRedactor([options.repoRoot, options.checkout], options.home ?? homedir11());
|
|
25055
25595
|
const redact = (text) => local(redactSecrets(text, secrets));
|
|
25056
25596
|
const kept = new Map;
|
|
25057
25597
|
let version = null;
|
|
@@ -25257,11 +25797,11 @@ function announceRunStepOnly(items) {
|
|
|
25257
25797
|
// packages/rafa-run/src/start/suite-step.ts
|
|
25258
25798
|
import { readFileSync as readFileSync38 } from "fs";
|
|
25259
25799
|
import { constants as constants3 } from "os";
|
|
25260
|
-
import { basename as basename14, join as
|
|
25800
|
+
import { basename as basename14, join as join49 } from "path";
|
|
25261
25801
|
|
|
25262
25802
|
// packages/rafa-run/src/suite/baseline.ts
|
|
25263
|
-
import { existsSync as
|
|
25264
|
-
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";
|
|
25265
25805
|
var BASELINE_VERSION = 1;
|
|
25266
25806
|
var BASELINE_FILE_PREFIX = "SUITE_BASELINE";
|
|
25267
25807
|
var PLAN_FILE_NAME2 = /^PLAN(?:_TRACKER)?(-.+)?\.md$/;
|
|
@@ -25271,7 +25811,7 @@ function baselinePathFor(trackerPath) {
|
|
|
25271
25811
|
if (match === null) {
|
|
25272
25812
|
throw new RangeError(`baselinePathFor: ${trackerPath} is not a PLAN or PLAN_TRACKER file`);
|
|
25273
25813
|
}
|
|
25274
|
-
return
|
|
25814
|
+
return join44(dirname16(trackerPath), `${BASELINE_FILE_PREFIX}${match[1] ?? ""}.json`);
|
|
25275
25815
|
}
|
|
25276
25816
|
function copyFailure(failure2) {
|
|
25277
25817
|
return failure2.message === undefined ? { file: failure2.file, name: failure2.name } : { file: failure2.file, name: failure2.name, message: failure2.message };
|
|
@@ -25336,7 +25876,7 @@ function asBaseline(parsed) {
|
|
|
25336
25876
|
return { state: "read", baseline: parsed };
|
|
25337
25877
|
}
|
|
25338
25878
|
function readBaseline(path3) {
|
|
25339
|
-
if (!
|
|
25879
|
+
if (!existsSync36(path3))
|
|
25340
25880
|
return { state: "missing" };
|
|
25341
25881
|
let text;
|
|
25342
25882
|
try {
|
|
@@ -25363,12 +25903,12 @@ function splitFailures(failures, baseline) {
|
|
|
25363
25903
|
}
|
|
25364
25904
|
|
|
25365
25905
|
// packages/rafa-run/src/suite/owns.ts
|
|
25366
|
-
var
|
|
25906
|
+
var ISSUE_NUMBER5 = /^#?(\d+)$/u;
|
|
25367
25907
|
function none(reason, detail) {
|
|
25368
25908
|
return Object.freeze({ owns: null, reason, detail });
|
|
25369
25909
|
}
|
|
25370
25910
|
function issueNumberOf(issue4) {
|
|
25371
|
-
const digits =
|
|
25911
|
+
const digits = ISSUE_NUMBER5.exec(issue4?.trim() ?? "")?.[1];
|
|
25372
25912
|
if (digits === undefined)
|
|
25373
25913
|
return null;
|
|
25374
25914
|
const number = Number(digits);
|
|
@@ -25435,8 +25975,8 @@ async function readPlanOwns(options) {
|
|
|
25435
25975
|
}
|
|
25436
25976
|
|
|
25437
25977
|
// packages/rafa-run/src/suite/scope.ts
|
|
25438
|
-
import { existsSync as
|
|
25439
|
-
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";
|
|
25440
25980
|
var BUNFIG_FILE = "bunfig.toml";
|
|
25441
25981
|
var TEST_FILE_NAME = /[._](?:test|spec)\.(?:tsx?|jsx?|[cm][jt]s)$/;
|
|
25442
25982
|
var DEPENDENCY_FOLDER = "node_modules";
|
|
@@ -25467,8 +26007,8 @@ function preloadFilesOf(text, root) {
|
|
|
25467
26007
|
return paths.filter((path3) => path3 !== null);
|
|
25468
26008
|
}
|
|
25469
26009
|
function readPreloadFiles(root) {
|
|
25470
|
-
const path3 =
|
|
25471
|
-
if (!
|
|
26010
|
+
const path3 = join45(root, BUNFIG_FILE);
|
|
26011
|
+
if (!existsSync37(path3))
|
|
25472
26012
|
return { state: "missing", files: [] };
|
|
25473
26013
|
try {
|
|
25474
26014
|
return { state: "read", files: preloadFilesOf(readFileSync34(path3, "utf8"), root) };
|
|
@@ -25480,7 +26020,7 @@ function readPreloadFiles(root) {
|
|
|
25480
26020
|
function listTestFiles(root) {
|
|
25481
26021
|
const found = [];
|
|
25482
26022
|
const walk = (folder) => {
|
|
25483
|
-
for (const entry of readdirSync11(
|
|
26023
|
+
for (const entry of readdirSync11(join45(root, folder), { withFileTypes: true })) {
|
|
25484
26024
|
const path3 = folder === "" ? entry.name : `${folder}/${entry.name}`;
|
|
25485
26025
|
if (entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== DEPENDENCY_FOLDER)
|
|
25486
26026
|
walk(path3);
|
|
@@ -25493,8 +26033,8 @@ function listTestFiles(root) {
|
|
|
25493
26033
|
}
|
|
25494
26034
|
|
|
25495
26035
|
// packages/rafa-run/src/start/lint-step.ts
|
|
25496
|
-
import { existsSync as
|
|
25497
|
-
import { join as
|
|
26036
|
+
import { existsSync as existsSync38 } from "fs";
|
|
26037
|
+
import { join as join46, relative as relative16 } from "path";
|
|
25498
26038
|
var LINT_COMMAND = ["bunx", "eslint", "--no-warn-ignored"];
|
|
25499
26039
|
var LINT_REPORT_FLAGS = ["--format", "json"];
|
|
25500
26040
|
var ESLINT_CONFIG_FILES = [
|
|
@@ -25523,7 +26063,7 @@ async function runEslint(options) {
|
|
|
25523
26063
|
return { exitCode, stdout, stderr };
|
|
25524
26064
|
}
|
|
25525
26065
|
function hasEslintConfig(checkout) {
|
|
25526
|
-
return ESLINT_CONFIG_FILES.some((name) =>
|
|
26066
|
+
return ESLINT_CONFIG_FILES.some((name) => existsSync38(join46(checkout, name)));
|
|
25527
26067
|
}
|
|
25528
26068
|
function readLintFiles(git, base2) {
|
|
25529
26069
|
const result = git(["diff", "--name-only", "-z", "--no-renames", "--diff-filter=d", base2, "HEAD"]);
|
|
@@ -25627,11 +26167,11 @@ async function runLintStep(input) {
|
|
|
25627
26167
|
}
|
|
25628
26168
|
|
|
25629
26169
|
// packages/rafa-run/src/start/suite-retake-alone.ts
|
|
25630
|
-
import { join as
|
|
26170
|
+
import { join as join47, relative as relative17 } from "path";
|
|
25631
26171
|
var RETAKE_ALONE_MAX_FILES = 20;
|
|
25632
26172
|
var STEP_ONLY_BEFORE = 5;
|
|
25633
26173
|
function aloneJunitFileFor(repoRoot, sessionId, kind, nth) {
|
|
25634
|
-
return
|
|
26174
|
+
return join47(runsDir(repoRoot), sessionId, "suite", `${kind}-alone-${nth}.junit.xml`);
|
|
25635
26175
|
}
|
|
25636
26176
|
function placeOf(file, orders) {
|
|
25637
26177
|
for (const [run, order] of orders.entries()) {
|
|
@@ -25755,14 +26295,14 @@ function announceStepOnly(context, settling) {
|
|
|
25755
26295
|
}
|
|
25756
26296
|
|
|
25757
26297
|
// packages/rafa-run/src/start/suite-stage-ledger.ts
|
|
25758
|
-
import { existsSync as
|
|
25759
|
-
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";
|
|
25760
26300
|
var STAGE_LEDGER_PREFIX = "SUITE_STAGES";
|
|
25761
26301
|
var STAGE_LEDGER_VERSION = 1;
|
|
25762
26302
|
function stageLedgerPathFor(trackerPath) {
|
|
25763
26303
|
const baselinePath = baselinePathFor(trackerPath);
|
|
25764
26304
|
const name = basename13(baselinePath).replace(BASELINE_FILE_PREFIX, STAGE_LEDGER_PREFIX);
|
|
25765
|
-
return
|
|
26305
|
+
return join48(dirname17(baselinePath), name);
|
|
25766
26306
|
}
|
|
25767
26307
|
function isLedgerEntry(value) {
|
|
25768
26308
|
if (typeof value !== "object" || value === null)
|
|
@@ -25786,7 +26326,7 @@ function parseLedger(text) {
|
|
|
25786
26326
|
return stages;
|
|
25787
26327
|
}
|
|
25788
26328
|
function readStageLedger(path3) {
|
|
25789
|
-
if (!
|
|
26329
|
+
if (!existsSync39(path3))
|
|
25790
26330
|
return [];
|
|
25791
26331
|
let parsed;
|
|
25792
26332
|
try {
|
|
@@ -26096,7 +26636,7 @@ async function runDueStageSteps(context, baseline) {
|
|
|
26096
26636
|
}
|
|
26097
26637
|
|
|
26098
26638
|
// packages/rafa-run/src/start/sweep-timing.ts
|
|
26099
|
-
import { existsSync as
|
|
26639
|
+
import { existsSync as existsSync40, readFileSync as readFileSync37 } from "fs";
|
|
26100
26640
|
var SLOW_SWEEP_SECONDS = 10;
|
|
26101
26641
|
var SUITE_TAG = /<(\/?)testsuite\b([^>]*?)(\/?)>/g;
|
|
26102
26642
|
function fileTimeOf(attributes) {
|
|
@@ -26136,7 +26676,7 @@ function slowSweepLine(slow) {
|
|
|
26136
26676
|
return `\uD83D\uDC22 ${slow.length} tests.alwaysRun file(s) took over ${SLOW_SWEEP_SECONDS}s in the task step: ${named}.`;
|
|
26137
26677
|
}
|
|
26138
26678
|
function readFileTimes(path3) {
|
|
26139
|
-
if (!
|
|
26679
|
+
if (!existsSync40(path3))
|
|
26140
26680
|
return [];
|
|
26141
26681
|
try {
|
|
26142
26682
|
return parseJunitFileTimes(readFileSync37(path3, "utf8")) ?? [];
|
|
@@ -26304,10 +26844,10 @@ function seamsOf(context) {
|
|
|
26304
26844
|
};
|
|
26305
26845
|
}
|
|
26306
26846
|
function junitFileFor(repoRoot, sessionId, kind) {
|
|
26307
|
-
return
|
|
26847
|
+
return join49(runsDir(repoRoot), sessionId, "suite", `${kind}.junit.xml`);
|
|
26308
26848
|
}
|
|
26309
26849
|
function alwaysRunJunitFileFor(repoRoot, sessionId, kind = "task") {
|
|
26310
|
-
return
|
|
26850
|
+
return join49(runsDir(repoRoot), sessionId, "suite", `${kind}-always-run.junit.xml`);
|
|
26311
26851
|
}
|
|
26312
26852
|
function readHead(git) {
|
|
26313
26853
|
const result = git(["rev-parse", "--verify", "HEAD^{commit}"]);
|
|
@@ -26685,7 +27225,7 @@ function createRunSuiteSteps(options) {
|
|
|
26685
27225
|
return { beforeSession, afterTask, stoppedOnSignal: () => signalled, lastPreWrapUp: () => lastPreWrapUp };
|
|
26686
27226
|
}
|
|
26687
27227
|
// packages/rafa-run/src/start/triage.ts
|
|
26688
|
-
import { homedir as
|
|
27228
|
+
import { homedir as homedir12 } from "os";
|
|
26689
27229
|
|
|
26690
27230
|
// packages/rafa/src/ports/unresolved-tracker.ts
|
|
26691
27231
|
function unresolvedTracker(kind, reason) {
|
|
@@ -26704,7 +27244,7 @@ function unresolvedTracker(kind, reason) {
|
|
|
26704
27244
|
|
|
26705
27245
|
// packages/rafa/src/effort/store/bug-routes.ts
|
|
26706
27246
|
import { randomUUID as randomUUID12 } from "crypto";
|
|
26707
|
-
import { existsSync as
|
|
27247
|
+
import { existsSync as existsSync41 } from "fs";
|
|
26708
27248
|
var BUG_ROUTES = [
|
|
26709
27249
|
"filed",
|
|
26710
27250
|
"private",
|
|
@@ -26806,7 +27346,7 @@ var SELECT_PLAN_BUG_ROUTES = `
|
|
|
26806
27346
|
`;
|
|
26807
27347
|
function readBugRoutesForPlan(repoRoot, planStub) {
|
|
26808
27348
|
const path3 = sqliteStorePath(repoRoot);
|
|
26809
|
-
if (!
|
|
27349
|
+
if (!existsSync41(path3))
|
|
26810
27350
|
return [];
|
|
26811
27351
|
const rows = withSqliteStore(path3, "read", false, (db) => db.query(SELECT_PLAN_BUG_ROUTES).all(planStub));
|
|
26812
27352
|
return rows.map((row) => ({
|
|
@@ -27076,7 +27616,7 @@ function createStartTriage(options) {
|
|
|
27076
27616
|
const secrets = namedSecrets(options.config, env);
|
|
27077
27617
|
const redact = (text) => redactSecrets(text, secrets);
|
|
27078
27618
|
const checkout = options.checkout ?? options.repoRoot;
|
|
27079
|
-
const local = localPathRedactor([checkout, options.repoRoot],
|
|
27619
|
+
const local = localPathRedactor([checkout, options.repoRoot], homedir12());
|
|
27080
27620
|
const git = options.git ?? createGitRunner(checkout);
|
|
27081
27621
|
const bugRules = bugRulesOf(options.config);
|
|
27082
27622
|
const triage = options.triageReport ?? triageReport;
|
|
@@ -27165,7 +27705,7 @@ function createStartTriage(options) {
|
|
|
27165
27705
|
};
|
|
27166
27706
|
}
|
|
27167
27707
|
// packages/rafa-run/src/start/convention-body.ts
|
|
27168
|
-
import { homedir as
|
|
27708
|
+
import { homedir as homedir13 } from "os";
|
|
27169
27709
|
|
|
27170
27710
|
// packages/rafa-run/src/start/release-body.ts
|
|
27171
27711
|
var RELEASE_BODY_SEAMS = {
|
|
@@ -27324,7 +27864,7 @@ async function writeLines(input, seams, redact) {
|
|
|
27324
27864
|
}
|
|
27325
27865
|
async function writeConventionLines(input, seams = {}) {
|
|
27326
27866
|
const secrets = namedSecrets(input.settings, seams.env ?? process.env);
|
|
27327
|
-
const local = localPathRedactor([input.repoRoot, input.checkout], seams.home ??
|
|
27867
|
+
const local = localPathRedactor([input.repoRoot, input.checkout], seams.home ?? homedir13());
|
|
27328
27868
|
const redact = (text) => local(redactSecrets(text, secrets));
|
|
27329
27869
|
try {
|
|
27330
27870
|
return await writeLines(input, seams, redact);
|
|
@@ -27336,7 +27876,7 @@ async function writeConventionLines(input, seams = {}) {
|
|
|
27336
27876
|
}
|
|
27337
27877
|
|
|
27338
27878
|
// packages/rafa-run/src/start/follow-ups.ts
|
|
27339
|
-
import { homedir as
|
|
27879
|
+
import { homedir as homedir14 } from "os";
|
|
27340
27880
|
var LINE_PREFIX4 = "Follow-ups: ";
|
|
27341
27881
|
var INDENT8 = " ";
|
|
27342
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.";
|
|
@@ -27478,7 +28018,7 @@ async function fileLines2(input, seams, redact) {
|
|
|
27478
28018
|
}
|
|
27479
28019
|
async function fileFollowUps(input, seams = {}) {
|
|
27480
28020
|
const secrets = namedSecrets(input.settings, seams.env ?? process.env);
|
|
27481
|
-
const local = localPathRedactor([input.repoRoot, input.checkout], seams.home ??
|
|
28021
|
+
const local = localPathRedactor([input.repoRoot, input.checkout], seams.home ?? homedir14());
|
|
27482
28022
|
const redact = (text) => local(redactSecrets(text, secrets));
|
|
27483
28023
|
let result;
|
|
27484
28024
|
try {
|
|
@@ -27975,14 +28515,41 @@ function unpromotedLine(check, head) {
|
|
|
27975
28515
|
const named = check.unpromoted.map((lesson) => unpromotedPhrase(lesson, head)).join("; ");
|
|
27976
28516
|
return `Lessons listed for promotion that this pull request does not carry: ${named}.`;
|
|
27977
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
|
+
}
|
|
27978
28533
|
async function recordPromotions(learning, promoted) {
|
|
27979
28534
|
const problems = [];
|
|
28535
|
+
if (promoted.length === 0)
|
|
28536
|
+
return problems;
|
|
28537
|
+
const { blessed, problem } = await blessedOrProblem(learning);
|
|
28538
|
+
const pushed = new Set;
|
|
27980
28539
|
for (const { lesson, path: path4 } of promoted) {
|
|
27981
|
-
|
|
27982
|
-
|
|
27983
|
-
|
|
27984
|
-
|
|
27985
|
-
|
|
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
|
+
}
|
|
27986
28553
|
}
|
|
27987
28554
|
}
|
|
27988
28555
|
return problems;
|
|
@@ -28428,11 +28995,11 @@ async function openByRunner(seams, branch, retriesSpent) {
|
|
|
28428
28995
|
activeOutput().warn(line);
|
|
28429
28996
|
return { kind: "delivered", pull: attempt2.pull, by: "runner", retriesSpent };
|
|
28430
28997
|
}
|
|
28431
|
-
var
|
|
28998
|
+
var ISSUE_NUMBER6 = /^#?(\d+)$/;
|
|
28432
28999
|
var RAFA_ID = /(?:^|\/)rafa-(\d+)(?:-|$)/;
|
|
28433
29000
|
function planIssueNumber(planContent, planStub, branch) {
|
|
28434
29001
|
const declared = parsePlan(planContent).header.issue?.trim() ?? "";
|
|
28435
|
-
const spelled =
|
|
29002
|
+
const spelled = ISSUE_NUMBER6.exec(declared)?.[1] ?? RAFA_ID.exec(planStub ?? "")?.[1] ?? RAFA_ID.exec(branch)?.[1];
|
|
28436
29003
|
return spelled === undefined ? null : Number(spelled);
|
|
28437
29004
|
}
|
|
28438
29005
|
function runnerPrInputFor(source) {
|
|
@@ -28519,13 +29086,13 @@ function registerCoreServices() {
|
|
|
28519
29086
|
}
|
|
28520
29087
|
// src/plan.ts
|
|
28521
29088
|
import fs5 from "fs";
|
|
28522
|
-
import { homedir as
|
|
29089
|
+
import { homedir as homedir16 } from "os";
|
|
28523
29090
|
import path7 from "path";
|
|
28524
29091
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
28525
29092
|
|
|
28526
29093
|
// src/commands/plan/bundled-check.ts
|
|
28527
29094
|
import { readdirSync as readdirSync12, readFileSync as readFileSync40, realpathSync as realpathSync6, statSync as statSync10, writeFileSync as writeFileSync13 } from "fs";
|
|
28528
|
-
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";
|
|
28529
29096
|
var SOURCE_DIR2 = "src";
|
|
28530
29097
|
var CODE_SPAN6 = /`([^`]+)`/gu;
|
|
28531
29098
|
var PATH_LIKE = /^\S+$/u;
|
|
@@ -28550,11 +29117,11 @@ function bundledAgents(root) {
|
|
|
28550
29117
|
function bundledSkills(root) {
|
|
28551
29118
|
if (root === null)
|
|
28552
29119
|
return [];
|
|
28553
|
-
return readdirSync12(root).filter((name) => isFilePath(
|
|
29120
|
+
return readdirSync12(root).filter((name) => isFilePath(join50(root, name, SKILL_FILE2))).sort((a, b) => a.localeCompare(b));
|
|
28554
29121
|
}
|
|
28555
29122
|
function readBundle(repoRoot) {
|
|
28556
|
-
const agentsRoot = realPathOrNull(
|
|
28557
|
-
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));
|
|
28558
29125
|
return { agentsRoot, skillsRoot, agents: bundledAgents(agentsRoot), skills: bundledSkills(skillsRoot) };
|
|
28559
29126
|
}
|
|
28560
29127
|
function skillHolding(bundle, realPath2) {
|
|
@@ -28893,7 +29460,7 @@ function createPlanBlockedOffer(seams = DEFAULT_BLOCKED_SEAMS) {
|
|
|
28893
29460
|
|
|
28894
29461
|
// src/commands/plan/ready-offer.ts
|
|
28895
29462
|
var runIssueReadyLazily = async (options) => {
|
|
28896
|
-
const { runIssueReady: run } = await import("./ready-
|
|
29463
|
+
const { runIssueReady: run } = await import("./ready-cnzcnv4d.js");
|
|
28897
29464
|
return run(options);
|
|
28898
29465
|
};
|
|
28899
29466
|
var DEFAULT_OFFER_SEAMS = Object.freeze({});
|
|
@@ -29111,16 +29678,16 @@ function stretchRulesReader(env, repoRoot) {
|
|
|
29111
29678
|
}
|
|
29112
29679
|
|
|
29113
29680
|
// src/notices/run.ts
|
|
29114
|
-
import { homedir as
|
|
29681
|
+
import { homedir as homedir15 } from "os";
|
|
29115
29682
|
|
|
29116
29683
|
// src/notices/notices.ts
|
|
29117
29684
|
import { mkdirSync as mkdirSync9, readFileSync as readFileSync42, writeFileSync as writeFileSync14 } from "fs";
|
|
29118
|
-
import { dirname as dirname19, join as
|
|
29685
|
+
import { dirname as dirname19, join as join51 } from "path";
|
|
29119
29686
|
var NOTICE_IDS = Object.freeze(["alpha", "danger"]);
|
|
29120
29687
|
var FEEDBACK_URL = "https://github.com/open-tomato/rafa/issues/new/choose";
|
|
29121
29688
|
var ROADMAP_URL = "https://github.com/open-tomato/rafa/issues/31";
|
|
29122
29689
|
function noticesPath(home) {
|
|
29123
|
-
return
|
|
29690
|
+
return join51(home, ".rafa", "notices.json");
|
|
29124
29691
|
}
|
|
29125
29692
|
function isNoticeId(value) {
|
|
29126
29693
|
return typeof value === "string" && NOTICE_IDS.includes(value);
|
|
@@ -29226,7 +29793,7 @@ async function offerNotices(request, seams) {
|
|
|
29226
29793
|
// src/notices/run.ts
|
|
29227
29794
|
var NOTICES_CANCELLED = "\uD83D\uDED1 Cancelled at the notice: nothing was started.";
|
|
29228
29795
|
async function requireNoticesAnswered(settingSources) {
|
|
29229
|
-
const outcome = await offerNotices({ home:
|
|
29796
|
+
const outcome = await offerNotices({ home: homedir15(), version: RAFA_VERSION, settingSources }, {
|
|
29230
29797
|
isTerminal: () => process.stdin.isTTY === true,
|
|
29231
29798
|
openPrompter: () => createLinePrompter(process.stdin, process.stderr),
|
|
29232
29799
|
warn: (line) => {
|
|
@@ -29415,7 +29982,7 @@ async function resolvePlanConfig(repoRoot, home) {
|
|
|
29415
29982
|
}
|
|
29416
29983
|
}
|
|
29417
29984
|
async function plan(args, repoRoot, roster, registry = CORE_ADAPTER_REGISTRY) {
|
|
29418
|
-
const home =
|
|
29985
|
+
const home = homedir16();
|
|
29419
29986
|
const config = await resolvePlanConfig(repoRoot, home);
|
|
29420
29987
|
const {
|
|
29421
29988
|
settingSources,
|
|
@@ -29507,10 +30074,146 @@ async function plan(args, repoRoot, roster, registry = CORE_ADAPTER_REGISTRY) {
|
|
|
29507
30074
|
}
|
|
29508
30075
|
// src/start.ts
|
|
29509
30076
|
import fs6 from "fs";
|
|
29510
|
-
import { homedir as
|
|
30077
|
+
import { homedir as homedir17 } from "os";
|
|
29511
30078
|
import path8 from "path";
|
|
29512
30079
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
29513
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
|
+
|
|
29514
30217
|
// src/utils/schedule.ts
|
|
29515
30218
|
function msUntil(startAt, now = new Date) {
|
|
29516
30219
|
const match = startAt.match(/^(\d{1,2}):(\d{2})$/);
|
|
@@ -29551,7 +30254,7 @@ async function start(args, repoRoot) {
|
|
|
29551
30254
|
return;
|
|
29552
30255
|
let runConfig;
|
|
29553
30256
|
try {
|
|
29554
|
-
runConfig = await loadRunConfig({ root: repoRoot, home:
|
|
30257
|
+
runConfig = await loadRunConfig({ root: repoRoot, home: homedir17() }, args);
|
|
29555
30258
|
} catch (error) {
|
|
29556
30259
|
if (!(error instanceof ConfigError))
|
|
29557
30260
|
throw error;
|
|
@@ -29588,7 +30291,7 @@ async function start(args, repoRoot) {
|
|
|
29588
30291
|
let expected2 = openCheckoutExpectation({ projectRoot: repoRoot, checkout, branch });
|
|
29589
30292
|
await announceRiskTotal({
|
|
29590
30293
|
repoRoot,
|
|
29591
|
-
home:
|
|
30294
|
+
home: homedir17(),
|
|
29592
30295
|
planPath,
|
|
29593
30296
|
config: runConfig.config,
|
|
29594
30297
|
environment: process.env
|
|
@@ -29618,16 +30321,16 @@ async function start(args, repoRoot) {
|
|
|
29618
30321
|
tiersRafa: runConfig.config.tiersRafa,
|
|
29619
30322
|
tiersSkills: runConfig.config.tiersSkills,
|
|
29620
30323
|
tiersAgents: runConfig.config.tiersAgents,
|
|
29621
|
-
home:
|
|
30324
|
+
home: homedir17()
|
|
29622
30325
|
},
|
|
29623
|
-
sync: { resolved: runConfig, home:
|
|
30326
|
+
sync: { resolved: runConfig, home: homedir17() },
|
|
29624
30327
|
claim: createStartPreflightClaim(repoRoot, runConfig.config),
|
|
29625
30328
|
drift: createStartPreflightDrift(repoRoot, runConfig.config)
|
|
29626
30329
|
});
|
|
29627
|
-
const serving = { root: repoRoot, run: session.id, home:
|
|
30330
|
+
const serving = { root: repoRoot, run: session.id, home: homedir17(), settings: runConfig.config };
|
|
29628
30331
|
const learning = {
|
|
29629
30332
|
kind: runConfig.config.learningAdapter,
|
|
29630
|
-
home:
|
|
30333
|
+
home: homedir17(),
|
|
29631
30334
|
blessMinConfidence: runConfig.config.learningBlessMinConfidence
|
|
29632
30335
|
};
|
|
29633
30336
|
const handout = {
|
|
@@ -29643,7 +30346,7 @@ async function start(args, repoRoot) {
|
|
|
29643
30346
|
};
|
|
29644
30347
|
const hubContact = createHubContact({
|
|
29645
30348
|
root: repoRoot,
|
|
29646
|
-
home:
|
|
30349
|
+
home: homedir17(),
|
|
29647
30350
|
resolved: runConfig,
|
|
29648
30351
|
warn: (message) => activeOutput().warn(message),
|
|
29649
30352
|
sessionId: session.id
|
|
@@ -29755,7 +30458,7 @@ async function start(args, repoRoot) {
|
|
|
29755
30458
|
inject: injectMode,
|
|
29756
30459
|
repoRoot,
|
|
29757
30460
|
checkout,
|
|
29758
|
-
home:
|
|
30461
|
+
home: homedir17(),
|
|
29759
30462
|
settingSources,
|
|
29760
30463
|
knownMissing,
|
|
29761
30464
|
inherited: runStartFailures(trackerPath),
|
|
@@ -29779,6 +30482,7 @@ async function start(args, repoRoot) {
|
|
|
29779
30482
|
await triageTask({ trackerPath, lineNum: taskInfo.lineNum, planStub, dispatch, outcome });
|
|
29780
30483
|
await staleDocs.afterTask({ planStub, dispatch, outcome });
|
|
29781
30484
|
await hubContact.pushThenPull();
|
|
30485
|
+
await runBugFixPass({ root: repoRoot, home: homedir17() }, { config: runConfig.config });
|
|
29782
30486
|
return stored2;
|
|
29783
30487
|
};
|
|
29784
30488
|
if (interrupted2) {
|