@open-tomato/rafa 0.49.0 → 0.51.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/agents/rafa-stretch-engineer.md +5 -3
- package/dist/cli.js +2105 -1174
- package/dist/config/index.js +2 -2
- package/dist/effort/store/index.js +2 -2
- package/dist/{index-j154qpbj.js → index-chm1d3xn.js} +202 -118
- package/dist/{index-thqpre1b.js → index-h9vwrj54.js} +1 -1
- package/dist/{index-vfny3ryr.js → index-j518r1yt.js} +1 -1
- package/dist/{index-g91ys6kw.js → index-jjxnyqvy.js} +1 -0
- package/dist/{index-zsak0jy6.js → index-nqaqh4zz.js} +1 -1
- package/dist/index.js +356 -99
- package/dist/{ready-mh5wdzq5.js → ready-dph3z1nz.js} +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -82,7 +82,7 @@ import {
|
|
|
82
82
|
withSqliteStore,
|
|
83
83
|
writeNames,
|
|
84
84
|
writeSqliteStore
|
|
85
|
-
} from "./index-
|
|
85
|
+
} from "./index-j518r1yt.js";
|
|
86
86
|
import {
|
|
87
87
|
ACTION_SHAPE,
|
|
88
88
|
CONFIG_DEFAULTS,
|
|
@@ -98,7 +98,7 @@ import {
|
|
|
98
98
|
renderTitle,
|
|
99
99
|
suggestedEnvironment,
|
|
100
100
|
titleRoundTrips
|
|
101
|
-
} from "./index-
|
|
101
|
+
} from "./index-nqaqh4zz.js";
|
|
102
102
|
import {
|
|
103
103
|
ABSENT,
|
|
104
104
|
ACCEPT_REFS_FLAG,
|
|
@@ -269,7 +269,7 @@ import {
|
|
|
269
269
|
writeHopRecord,
|
|
270
270
|
writePositionFile,
|
|
271
271
|
writeRefsBlock
|
|
272
|
-
} from "./index-
|
|
272
|
+
} from "./index-chm1d3xn.js";
|
|
273
273
|
import {
|
|
274
274
|
BLOCKER_GAP,
|
|
275
275
|
PLAN_BLOCK_KINDS,
|
|
@@ -321,7 +321,7 @@ import {
|
|
|
321
321
|
parseWorkingTree,
|
|
322
322
|
registerAdapters,
|
|
323
323
|
restoreAdapters
|
|
324
|
-
} from "./index-
|
|
324
|
+
} from "./index-h9vwrj54.js";
|
|
325
325
|
import {
|
|
326
326
|
activeOutput,
|
|
327
327
|
activeOutputMode,
|
|
@@ -340,7 +340,7 @@ import {
|
|
|
340
340
|
codeProblem,
|
|
341
341
|
familyOf,
|
|
342
342
|
isKnownCode
|
|
343
|
-
} from "./index-
|
|
343
|
+
} from "./index-jjxnyqvy.js";
|
|
344
344
|
import {
|
|
345
345
|
CONFIG_FILE,
|
|
346
346
|
CORE_SECTION,
|
|
@@ -8274,6 +8274,7 @@ function renderLessonsSection(lessons) {
|
|
|
8274
8274
|
}
|
|
8275
8275
|
// packages/rafa-inventory/src/task/select-lessons.ts
|
|
8276
8276
|
var LESSON_LIMIT = 5;
|
|
8277
|
+
var TRIGGER_WORD_FLOOR = 2;
|
|
8277
8278
|
function isArtifactPath(artifact) {
|
|
8278
8279
|
return artifact !== "" && !/\s/.test(artifact) && /[/.]/.test(artifact);
|
|
8279
8280
|
}
|
|
@@ -8308,7 +8309,7 @@ function triggerCandidate(lesson) {
|
|
|
8308
8309
|
return { record, description: null, body: "" };
|
|
8309
8310
|
}
|
|
8310
8311
|
function triggerMatches(lesson, words) {
|
|
8311
|
-
return
|
|
8312
|
+
return scoreCandidate(triggerCandidate(lesson), words).words.length >= TRIGGER_WORD_FLOOR;
|
|
8312
8313
|
}
|
|
8313
8314
|
function selectLessons(task, bundle) {
|
|
8314
8315
|
const words = questionWords(task.text);
|
|
@@ -8316,7 +8317,9 @@ function selectLessons(task, bundle) {
|
|
|
8316
8317
|
return [...kept].sort((a, b) => b.confidence - a.confidence).slice(0, LESSON_LIMIT);
|
|
8317
8318
|
}
|
|
8318
8319
|
// packages/rafa-effort/src/effort/skill-use.ts
|
|
8319
|
-
var
|
|
8320
|
+
var SKILL_USE_CLI_FLOOR = "2.1.280";
|
|
8321
|
+
var SKILL_USE_FIXTURE_VERSION = "2.1.280";
|
|
8322
|
+
var CLI_VERSION_SHAPE = /^(\d+)\.(\d+)\.(\d+)$/u;
|
|
8320
8323
|
var SKILL_TOOL = "Skill";
|
|
8321
8324
|
var SUBAGENT_LOG_NAME = /^agent-.+\.jsonl$/;
|
|
8322
8325
|
function asObject3(value) {
|
|
@@ -8335,14 +8338,35 @@ function subagentLogPaths(sessionLogPath) {
|
|
|
8335
8338
|
return [];
|
|
8336
8339
|
return readdirSync5(dir, { withFileTypes: true }).filter((entry) => entry.isFile() && SUBAGENT_LOG_NAME.test(entry.name)).map((entry) => join21(dir, entry.name)).sort((a, b) => a.localeCompare(b));
|
|
8337
8340
|
}
|
|
8338
|
-
function
|
|
8341
|
+
function versionFields(version) {
|
|
8342
|
+
if (typeof version !== "string")
|
|
8343
|
+
return null;
|
|
8344
|
+
const match = CLI_VERSION_SHAPE.exec(version);
|
|
8345
|
+
return match === null ? null : match.slice(1).map(Number);
|
|
8346
|
+
}
|
|
8347
|
+
function compareCliVersions(a, b) {
|
|
8348
|
+
const left = versionFields(a);
|
|
8349
|
+
const right = versionFields(b);
|
|
8350
|
+
if (left === null || right === null) {
|
|
8351
|
+
if (left !== right) {
|
|
8352
|
+
return left === null ? -1 : 1;
|
|
8353
|
+
}
|
|
8354
|
+
return a.localeCompare(b);
|
|
8355
|
+
}
|
|
8356
|
+
const differing = left.findIndex((field3, index) => field3 !== right[index]);
|
|
8357
|
+
return differing === -1 ? 0 : (left[differing] ?? 0) - (right[differing] ?? 0);
|
|
8358
|
+
}
|
|
8359
|
+
function applyVersion(tally, record, floor) {
|
|
8339
8360
|
const version = record["version"];
|
|
8340
8361
|
if (version === undefined)
|
|
8341
8362
|
return;
|
|
8342
|
-
|
|
8343
|
-
|
|
8344
|
-
|
|
8345
|
-
tally.
|
|
8363
|
+
const text = String(version);
|
|
8364
|
+
tally.versions.add(text);
|
|
8365
|
+
if (typeof version === "string" && compareCliVersions(version, floor) >= 0) {
|
|
8366
|
+
tally.atOrAbove += 1;
|
|
8367
|
+
} else {
|
|
8368
|
+
tally.belowFloor += 1;
|
|
8369
|
+
}
|
|
8346
8370
|
}
|
|
8347
8371
|
function applyCalls(tally, record, sidechain) {
|
|
8348
8372
|
if (record["type"] !== "assistant")
|
|
@@ -8363,7 +8387,7 @@ function applyCalls(tally, record, sidechain) {
|
|
|
8363
8387
|
tally.counts.set(key, (tally.counts.get(key) ?? 0) + 1);
|
|
8364
8388
|
}
|
|
8365
8389
|
}
|
|
8366
|
-
async function applySource(tally, source,
|
|
8390
|
+
async function applySource(tally, source, floor) {
|
|
8367
8391
|
for await (const rawLine of source.lines) {
|
|
8368
8392
|
const line = rawLine.trim();
|
|
8369
8393
|
if (line.length === 0)
|
|
@@ -8373,7 +8397,7 @@ async function applySource(tally, source, cliVersion) {
|
|
|
8373
8397
|
tally.unreadable += 1;
|
|
8374
8398
|
continue;
|
|
8375
8399
|
}
|
|
8376
|
-
applyVersion(tally, record,
|
|
8400
|
+
applyVersion(tally, record, floor);
|
|
8377
8401
|
applyCalls(tally, record, source.subagent || record["isSidechain"] === true);
|
|
8378
8402
|
}
|
|
8379
8403
|
}
|
|
@@ -8384,27 +8408,36 @@ function usesOf(counts) {
|
|
|
8384
8408
|
});
|
|
8385
8409
|
return uses.sort((a, b) => a.name.localeCompare(b.name) || Number(a.sidechain) - Number(b.sidechain));
|
|
8386
8410
|
}
|
|
8387
|
-
async function collectSkillUse(sessionId, sources,
|
|
8388
|
-
|
|
8411
|
+
async function collectSkillUse(sessionId, sources, floor = SKILL_USE_CLI_FLOOR) {
|
|
8412
|
+
if (versionFields(floor) === null)
|
|
8413
|
+
throw new TypeError(`skill-use floor ${JSON.stringify(floor)} is not an X.Y.Z version`);
|
|
8414
|
+
const tally = { counts: new Map, belowFloor: 0, atOrAbove: 0, versions: new Set, unreadable: 0 };
|
|
8389
8415
|
for (const source of sources)
|
|
8390
|
-
await applySource(tally, source,
|
|
8391
|
-
|
|
8392
|
-
|
|
8416
|
+
await applySource(tally, source, floor);
|
|
8417
|
+
const versions = [...tally.versions].sort(compareCliVersions);
|
|
8418
|
+
if (tally.belowFloor > 0 || tally.atOrAbove === 0 || tally.unreadable > 0) {
|
|
8419
|
+
return { sessionId, uses: UNKNOWN_SKILL_COUNT, vouched: false, versions };
|
|
8393
8420
|
}
|
|
8394
|
-
|
|
8421
|
+
const vouched = versions.length === 1 && versions[0] === SKILL_USE_FIXTURE_VERSION;
|
|
8422
|
+
return { sessionId, uses: usesOf(tally.counts), vouched, versions };
|
|
8395
8423
|
}
|
|
8396
|
-
async function readSkillUse(sessionLogPath,
|
|
8424
|
+
async function readSkillUse(sessionLogPath, floor = SKILL_USE_CLI_FLOOR) {
|
|
8397
8425
|
const sources = [
|
|
8398
8426
|
{ lines: readLines(sessionLogPath), subagent: false },
|
|
8399
8427
|
...subagentLogPaths(sessionLogPath).map((path2) => ({ lines: readLines(path2), subagent: true }))
|
|
8400
8428
|
];
|
|
8401
|
-
return collectSkillUse(sessionIdFromPath(sessionLogPath), sources,
|
|
8429
|
+
return collectSkillUse(sessionIdFromPath(sessionLogPath), sources, floor);
|
|
8402
8430
|
}
|
|
8403
8431
|
|
|
8404
8432
|
// packages/rafa-effort/src/effort/collect-skills.ts
|
|
8405
8433
|
function messageOf3(error) {
|
|
8406
8434
|
return error instanceof Error ? error.message : String(error);
|
|
8407
8435
|
}
|
|
8436
|
+
function readingNote(reading) {
|
|
8437
|
+
const versions = reading.versions.length === 0 ? "no version" : reading.versions.join(", ");
|
|
8438
|
+
const standing = reading.uses === UNKNOWN_SKILL_COUNT ? "unknown" : reading.vouched ? "vouched" : "unvouched";
|
|
8439
|
+
return `skills: read ${reading.sessionId} (${versions}, ${standing})`;
|
|
8440
|
+
}
|
|
8408
8441
|
function countedSessions(repoRoot) {
|
|
8409
8442
|
return new Set(readSkillInvocations(repoRoot).map((row) => row.sessionId));
|
|
8410
8443
|
}
|
|
@@ -8415,8 +8448,9 @@ async function collectSkillHalf(input) {
|
|
|
8415
8448
|
let failed2 = 0;
|
|
8416
8449
|
for (const log of pending) {
|
|
8417
8450
|
try {
|
|
8418
|
-
|
|
8419
|
-
|
|
8451
|
+
const reading = await readSkillUse(log.path);
|
|
8452
|
+
readings.push(reading);
|
|
8453
|
+
input.note(readingNote(reading));
|
|
8420
8454
|
} catch (error) {
|
|
8421
8455
|
failed2 += 1;
|
|
8422
8456
|
input.log(`skills: FAILED ${log.path}: ${messageOf3(error)}`);
|
|
@@ -8429,6 +8463,7 @@ async function collectSkillHalf(input) {
|
|
|
8429
8463
|
candidates: input.logs.length,
|
|
8430
8464
|
alreadyCounted: input.logs.length - pending.length,
|
|
8431
8465
|
read: readings.length,
|
|
8466
|
+
unvouched: readings.filter((reading) => reading.uses !== UNKNOWN_SKILL_COUNT && !reading.vouched).length,
|
|
8432
8467
|
unknown: readings.filter((reading) => reading.uses === UNKNOWN_SKILL_COUNT).length,
|
|
8433
8468
|
failed: failed2,
|
|
8434
8469
|
appended: written.appended,
|
|
@@ -8439,7 +8474,7 @@ function formatSkillSummary(skills) {
|
|
|
8439
8474
|
if (skills === null)
|
|
8440
8475
|
return " skills skipped (--no-sessions)";
|
|
8441
8476
|
const scope = skills.scope === "held" ? "stored" : "appended";
|
|
8442
|
-
return ` skills ${skills.candidates} ${scope} sessions` + `, ${skills.alreadyCounted} already counted` + `, ${skills.read} read` + `, ${skills.unknown} unknown` + `, ${skills.failed} failed` + `, +${skills.appended} rows`;
|
|
8477
|
+
return ` skills ${skills.candidates} ${scope} sessions` + `, ${skills.alreadyCounted} already counted` + `, ${skills.read} read` + `, ${skills.unvouched} unvouched` + `, ${skills.unknown} unknown` + `, ${skills.failed} failed` + `, +${skills.appended} rows`;
|
|
8443
8478
|
}
|
|
8444
8479
|
|
|
8445
8480
|
// packages/rafa-effort/src/effort/commits.ts
|
|
@@ -11946,6 +11981,12 @@ function readTags(git) {
|
|
|
11946
11981
|
const tags = releaseTagsOf(result.stdout);
|
|
11947
11982
|
return { tags, latest: tags.find((tag) => tag.package === null) ?? null, problem: null };
|
|
11948
11983
|
}
|
|
11984
|
+
function newestRootRelease(git) {
|
|
11985
|
+
const reading = readTags(git);
|
|
11986
|
+
if (reading.problem !== null)
|
|
11987
|
+
return;
|
|
11988
|
+
return reading.latest?.version ?? null;
|
|
11989
|
+
}
|
|
11949
11990
|
function readUntagged(root, configured, tags) {
|
|
11950
11991
|
const resolved = join25(root, configured);
|
|
11951
11992
|
const text = textOf(resolved);
|
|
@@ -12932,6 +12973,21 @@ var DOC_UPDATE_TASK_PREFIX = "Repair the stale doc line at ";
|
|
|
12932
12973
|
function staleDocsTitle(version) {
|
|
12933
12974
|
return `Release ${version}: update stale docs`;
|
|
12934
12975
|
}
|
|
12976
|
+
var STALE_DOCS_TITLE = /^Release (\S+): update stale docs$/;
|
|
12977
|
+
function staleDocsTitleVersion(title) {
|
|
12978
|
+
return STALE_DOCS_TITLE.exec(title)?.[1] ?? null;
|
|
12979
|
+
}
|
|
12980
|
+
function isUnreleasedVersion(version, newestRelease) {
|
|
12981
|
+
if (version === NEXT_VERSION)
|
|
12982
|
+
return true;
|
|
12983
|
+
const parsed = parseSemanticVersion(version);
|
|
12984
|
+
if (parsed === null)
|
|
12985
|
+
return false;
|
|
12986
|
+
if (newestRelease === null)
|
|
12987
|
+
return true;
|
|
12988
|
+
const newest = parseSemanticVersion(newestRelease);
|
|
12989
|
+
return newest !== null && compareVersions(parsed, newest) > 0;
|
|
12990
|
+
}
|
|
12935
12991
|
function staleDocsVersion(input) {
|
|
12936
12992
|
if (!input.releaseEnabled)
|
|
12937
12993
|
return NEXT_VERSION;
|
|
@@ -12986,8 +13042,81 @@ async function call(step, action) {
|
|
|
12986
13042
|
return { ok: false, problem: oneLine5(`${step} failed: ${messageOf(error)}`) };
|
|
12987
13043
|
}
|
|
12988
13044
|
}
|
|
12989
|
-
function
|
|
12990
|
-
|
|
13045
|
+
function createdMs(issue4) {
|
|
13046
|
+
if (issue4.createdAt === null)
|
|
13047
|
+
return null;
|
|
13048
|
+
const ms = Date.parse(issue4.createdAt);
|
|
13049
|
+
return Number.isNaN(ms) ? null : ms;
|
|
13050
|
+
}
|
|
13051
|
+
function idOrder(left, right) {
|
|
13052
|
+
const [a, b] = [Number(left), Number(right)];
|
|
13053
|
+
if (Number.isSafeInteger(a) && Number.isSafeInteger(b))
|
|
13054
|
+
return a - b;
|
|
13055
|
+
return left.localeCompare(right);
|
|
13056
|
+
}
|
|
13057
|
+
function olderFirst(left, right) {
|
|
13058
|
+
const [a, b] = [createdMs(left), createdMs(right)];
|
|
13059
|
+
if (a !== null && b !== null && a !== b)
|
|
13060
|
+
return a - b;
|
|
13061
|
+
return idOrder(left.ref.externalId, right.ref.externalId);
|
|
13062
|
+
}
|
|
13063
|
+
function releaseReading(newestRelease) {
|
|
13064
|
+
return typeof newestRelease === "string" && parseSemanticVersion(newestRelease) === null ? undefined : newestRelease;
|
|
13065
|
+
}
|
|
13066
|
+
function mayTake(issue4, choice) {
|
|
13067
|
+
if (!issue4.body.includes(STALE_DOCS_MARKER))
|
|
13068
|
+
return false;
|
|
13069
|
+
if (choice.newestRelease === undefined)
|
|
13070
|
+
return issue4.title === choice.title;
|
|
13071
|
+
const version = staleDocsTitleVersion(issue4.title);
|
|
13072
|
+
return version !== null && isUnreleasedVersion(version, choice.newestRelease);
|
|
13073
|
+
}
|
|
13074
|
+
function chooseIssue(open, choice) {
|
|
13075
|
+
const candidates = open.filter((issue4) => mayTake(issue4, choice)).sort(olderFirst);
|
|
13076
|
+
return candidates.find((issue4) => issue4.title === choice.title) ?? candidates[0];
|
|
13077
|
+
}
|
|
13078
|
+
function issueChange(found, title, line, held) {
|
|
13079
|
+
if (held)
|
|
13080
|
+
return { title };
|
|
13081
|
+
const body = appendItem(found.body, line.item);
|
|
13082
|
+
return found.title === title ? { body } : { title, body };
|
|
13083
|
+
}
|
|
13084
|
+
async function addToIssue(tracker, found, title, line) {
|
|
13085
|
+
const held = bodyHoldsLine(found.body, line.text);
|
|
13086
|
+
const action = held ? "held" : "appended";
|
|
13087
|
+
if (held && found.title === title)
|
|
13088
|
+
return { action, title, ref: found.ref };
|
|
13089
|
+
const change = issueChange(found, title, line, held);
|
|
13090
|
+
const edited = await call("editing the stale-docs issue", () => tracker.edit(found.ref, change));
|
|
13091
|
+
if (!edited.ok)
|
|
13092
|
+
return { action: "failed", title, problem: edited.problem };
|
|
13093
|
+
return found.title === title ? { action, title, ref: found.ref } : { action, title, ref: found.ref, retitledFrom: found.title };
|
|
13094
|
+
}
|
|
13095
|
+
async function closeDuplicate(tracker, duplicate, older) {
|
|
13096
|
+
const id = duplicate.externalId;
|
|
13097
|
+
const commented = await call(`commenting on the duplicate issue ${id}`, () => tracker.comment(duplicate, `Duplicate of #${older.externalId}`));
|
|
13098
|
+
if (!commented.ok)
|
|
13099
|
+
return commented;
|
|
13100
|
+
return call(`closing the duplicate issue ${id}`, () => tracker.transition(duplicate, "cancelled"));
|
|
13101
|
+
}
|
|
13102
|
+
async function createAndConverge(tracker, choice, line) {
|
|
13103
|
+
const { title } = choice;
|
|
13104
|
+
const created = await call("creating the stale-docs issue", () => tracker.create(issueDraft(title, line.item)));
|
|
13105
|
+
if (!created.ok)
|
|
13106
|
+
return { action: "failed", title, problem: created.problem };
|
|
13107
|
+
const ref = created.value;
|
|
13108
|
+
const relisted = await call(`listing the open chore issues after creating issue ${ref.externalId}`, () => tracker.openIssues("chore"));
|
|
13109
|
+
if (!relisted.ok)
|
|
13110
|
+
return { action: "failed", title, problem: relisted.problem };
|
|
13111
|
+
const own = relisted.value.find((issue4) => issue4.ref.externalId === ref.externalId) ?? { ref, title, body: "", createdAt: null };
|
|
13112
|
+
const older = chooseIssue(relisted.value.filter((issue4) => issue4.ref.externalId !== ref.externalId && olderFirst(issue4, own) < 0), choice);
|
|
13113
|
+
if (older === undefined)
|
|
13114
|
+
return { action: "created", title, ref };
|
|
13115
|
+
const added = await addToIssue(tracker, older, title, line);
|
|
13116
|
+
if (added.action !== "appended" && added.action !== "held")
|
|
13117
|
+
return added;
|
|
13118
|
+
const closed = await closeDuplicate(tracker, ref, older.ref);
|
|
13119
|
+
return closed.ok ? { ...added, duplicate: ref } : { action: "failed", title, problem: closed.problem };
|
|
12991
13120
|
}
|
|
12992
13121
|
async function addStaleDocLine(options) {
|
|
12993
13122
|
const { tracker, version, entry } = options;
|
|
@@ -12995,20 +13124,13 @@ async function addStaleDocLine(options) {
|
|
|
12995
13124
|
if (!canHoldIssue(tracker))
|
|
12996
13125
|
return { action: "kept", title, reason: NO_EDITABLE_TRACKER };
|
|
12997
13126
|
const text = staleDocLineText(entry);
|
|
12998
|
-
const
|
|
13127
|
+
const line = { text, item: `${UNTICKED}${text}` };
|
|
13128
|
+
const choice = { title, newestRelease: releaseReading(options.newestRelease) };
|
|
12999
13129
|
const listed2 = await call("listing the open chore issues", () => tracker.openIssues("chore"));
|
|
13000
13130
|
if (!listed2.ok)
|
|
13001
13131
|
return { action: "failed", title, problem: listed2.problem };
|
|
13002
|
-
const found =
|
|
13003
|
-
|
|
13004
|
-
const created = await call("creating the stale-docs issue", () => tracker.create(issueDraft(title, item)));
|
|
13005
|
-
return created.ok ? { action: "created", title, ref: created.value } : { action: "failed", title, problem: created.problem };
|
|
13006
|
-
}
|
|
13007
|
-
if (bodyHoldsLine(found.body, text))
|
|
13008
|
-
return { action: "held", title, ref: found.ref };
|
|
13009
|
-
const body = appendItem(found.body, item);
|
|
13010
|
-
const edited = await call("editing the stale-docs issue", () => tracker.edit(found.ref, { body }));
|
|
13011
|
-
return edited.ok ? { action: "appended", title, ref: found.ref } : { action: "failed", title, problem: edited.problem };
|
|
13132
|
+
const found = chooseIssue(listed2.value, choice);
|
|
13133
|
+
return found === undefined ? createAndConverge(tracker, choice, line) : addToIssue(tracker, found, title, line);
|
|
13012
13134
|
}
|
|
13013
13135
|
function docUpdateLineText(taskText) {
|
|
13014
13136
|
if (!taskText.startsWith(DOC_UPDATE_TASK_PREFIX))
|
|
@@ -23081,20 +23203,22 @@ async function runStartPreflight(options) {
|
|
|
23081
23203
|
}
|
|
23082
23204
|
|
|
23083
23205
|
// packages/rafa-run/src/start/type-step.ts
|
|
23084
|
-
import { existsSync as existsSync32, mkdtempSync as mkdtempSync2, realpathSync as realpathSync4, rmSync as rmSync6, symlinkSync as symlinkSync2, writeFileSync as writeFileSync10 } from "fs";
|
|
23206
|
+
import { closeSync as closeSync2, existsSync as existsSync32, mkdtempSync as mkdtempSync2, openSync as openSync2, readSync as readSync2, realpathSync as realpathSync4, rmSync as rmSync6, symlinkSync as symlinkSync2, writeFileSync as writeFileSync10 } from "fs";
|
|
23085
23207
|
import { tmpdir as tmpdir2 } from "os";
|
|
23086
|
-
import { dirname as dirname15, join as join41, relative as relative14, resolve as resolve18, sep as sep6 } from "path";
|
|
23208
|
+
import { basename as basename11, dirname as dirname15, join as join41, relative as relative14, resolve as resolve18, sep as sep6 } from "path";
|
|
23087
23209
|
var TEST_FILE_SUFFIX = ".test.ts";
|
|
23088
23210
|
var TSC_FLAGS = ["--noEmit", "--pretty", "false"];
|
|
23211
|
+
var CANNOT_START_CODES = [126, 127];
|
|
23212
|
+
var SHEBANG_BYTES = 256;
|
|
23089
23213
|
var ERRORS_LISTED = 10;
|
|
23090
23214
|
var NODE_MODULES2 = "node_modules";
|
|
23091
23215
|
var TSC_BIN = [".bin", "tsc"];
|
|
23092
23216
|
var SCRATCH_NAME = "tsconfig.json";
|
|
23093
23217
|
var FILE_ERROR = /^(.+)\((\d+),(\d+)\): error (TS\d+): (.*)$/;
|
|
23094
23218
|
var GLOBAL_ERROR = /^error (TS\d+): (.*)$/;
|
|
23095
|
-
var NOTHING_RAN = { ran: false, red: false, interrupted: false, blocker: null };
|
|
23096
|
-
var GREEN = { ran: true, red: false, interrupted: false, blocker: null };
|
|
23097
|
-
var INTERRUPTED2 = { ran: true, red: false, interrupted: true, blocker: null };
|
|
23219
|
+
var NOTHING_RAN = { ran: false, red: false, interrupted: false, cannotStart: false, blocker: null };
|
|
23220
|
+
var GREEN = { ran: true, red: false, interrupted: false, cannotStart: false, blocker: null };
|
|
23221
|
+
var INTERRUPTED2 = { ran: true, red: false, interrupted: true, cannotStart: false, blocker: null };
|
|
23098
23222
|
async function runTsc(options) {
|
|
23099
23223
|
const proc = Bun.spawn([...options.argv], {
|
|
23100
23224
|
cwd: options.cwd,
|
|
@@ -23241,6 +23365,32 @@ function typeBlockerText(label, base2, errors) {
|
|
|
23241
23365
|
function brokenBlockerText(label, run, said) {
|
|
23242
23366
|
return `The runner's ${label} could not type-check the task's test files: tsc exited ${run.exitCode}${said === undefined ? " and printed no error." : `: ${said}`}`;
|
|
23243
23367
|
}
|
|
23368
|
+
function scriptInterpreter(path3) {
|
|
23369
|
+
let head;
|
|
23370
|
+
try {
|
|
23371
|
+
const fd = openSync2(path3, "r");
|
|
23372
|
+
try {
|
|
23373
|
+
const buffer = Buffer.alloc(SHEBANG_BYTES);
|
|
23374
|
+
head = buffer.toString("utf8", 0, readSync2(fd, buffer, 0, SHEBANG_BYTES, 0));
|
|
23375
|
+
} finally {
|
|
23376
|
+
closeSync2(fd);
|
|
23377
|
+
}
|
|
23378
|
+
} catch {
|
|
23379
|
+
return null;
|
|
23380
|
+
}
|
|
23381
|
+
const first = head.split(`
|
|
23382
|
+
`)[0] ?? "";
|
|
23383
|
+
if (!first.startsWith("#!"))
|
|
23384
|
+
return null;
|
|
23385
|
+
const [program = "", ...rest] = first.slice(2).trim().split(/\s+/u);
|
|
23386
|
+
const named = basename11(program) === "env" ? rest.find((word) => !word.startsWith("-") && !word.includes("=")) : program;
|
|
23387
|
+
return named === undefined || named === "" ? null : basename11(named);
|
|
23388
|
+
}
|
|
23389
|
+
function cannotStartBlockerText(label, tsc, run, said, interpreter) {
|
|
23390
|
+
const heard = said === undefined ? "" : ` (${said})`;
|
|
23391
|
+
const fix = interpreter === null ? `Its first line names no interpreter, so make ${tsc} runnable from the PATH the loop runs under` : `tsc runs under ${interpreter}, which its first line names: put ${interpreter} on the PATH the loop runs under`;
|
|
23392
|
+
return `The runner's ${label} could not start tsc: ${tsc} exited ${run.exitCode}${heard}. ` + `${fix}, then run the task again. This is no type error of the task's, and no change to its files fixes it.`;
|
|
23393
|
+
}
|
|
23244
23394
|
function configError(errors, scratch, cwd) {
|
|
23245
23395
|
const config = relative14(cwd, scratch);
|
|
23246
23396
|
return errors.find((error) => error.file === null || error.file === config);
|
|
@@ -23263,6 +23413,8 @@ async function checkTree(input, modules, tree, files) {
|
|
|
23263
23413
|
}
|
|
23264
23414
|
if (run.exitCode === input.stopCode || input.isInterrupted?.() === true)
|
|
23265
23415
|
return { kind: "interrupted" };
|
|
23416
|
+
if (CANNOT_START_CODES.includes(run.exitCode))
|
|
23417
|
+
return { kind: "cannot-start", run, said: firstLine7(run) };
|
|
23266
23418
|
const errors = parseTscOutput(run.stdout, tree);
|
|
23267
23419
|
const config = configError(errors, scratch, tree);
|
|
23268
23420
|
if (config !== undefined)
|
|
@@ -23308,6 +23460,8 @@ async function baseErrors(input, label, modules, files) {
|
|
|
23308
23460
|
return { outcome: GREEN };
|
|
23309
23461
|
if (run.kind === "interrupted")
|
|
23310
23462
|
return { outcome: interrupted(label) };
|
|
23463
|
+
if (run.kind === "cannot-start")
|
|
23464
|
+
return { outcome: cannotStart(label, modules, run) };
|
|
23311
23465
|
if (run.kind !== "read") {
|
|
23312
23466
|
const why = run.kind === "threw" ? run.why : brokenBlockerText(label, run.run, run.said);
|
|
23313
23467
|
activeOutput().warn(`\u26A0\uFE0F The ${label} could not check the files at ${input.base} (${why}); it reads no error as new.`);
|
|
@@ -23320,6 +23474,12 @@ function interrupted(label) {
|
|
|
23320
23474
|
activeOutput().info(`\u23F9 The ${label} was interrupted by SIGINT: read as a stop, not as errors.`);
|
|
23321
23475
|
return INTERRUPTED2;
|
|
23322
23476
|
}
|
|
23477
|
+
function cannotStart(label, modules, run) {
|
|
23478
|
+
const tsc = join41(modules, ...TSC_BIN);
|
|
23479
|
+
const blocker = cannotStartBlockerText(label, tsc, run.run, run.said, scriptInterpreter(tsc));
|
|
23480
|
+
activeOutput().warn(`\u26A0\uFE0F ${blocker}`);
|
|
23481
|
+
return { ran: false, red: false, interrupted: false, cannotStart: true, blocker };
|
|
23482
|
+
}
|
|
23323
23483
|
function filesToCheck(input, label) {
|
|
23324
23484
|
if (!existsSync32(join41(input.checkout, "tsconfig.json"))) {
|
|
23325
23485
|
activeOutput().info(`\uD83D\uDD0E ${label}: no tsconfig.json at the checkout root; nothing to type-check.`);
|
|
@@ -23346,10 +23506,12 @@ async function runTypeStep(input) {
|
|
|
23346
23506
|
}
|
|
23347
23507
|
if (head.kind === "interrupted")
|
|
23348
23508
|
return interrupted(label);
|
|
23509
|
+
if (head.kind === "cannot-start")
|
|
23510
|
+
return cannotStart(label, modules, head);
|
|
23349
23511
|
if (head.kind === "broken") {
|
|
23350
23512
|
const blocker = brokenBlockerText(label, head.run, head.said);
|
|
23351
23513
|
activeOutput().info(`\uD83D\uDD0E ${label}: ${blocker}`);
|
|
23352
|
-
return { ran: true, red: true, interrupted: false, blocker };
|
|
23514
|
+
return { ran: true, red: true, interrupted: false, cannotStart: false, blocker };
|
|
23353
23515
|
}
|
|
23354
23516
|
const ran = `\uD83D\uDD0E ${label}: tsc over ${files.length} test file(s)`;
|
|
23355
23517
|
if (head.errors.length === 0) {
|
|
@@ -23365,7 +23527,7 @@ async function runTypeStep(input) {
|
|
|
23365
23527
|
activeOutput().info(` ${line}`);
|
|
23366
23528
|
if (added.length === 0)
|
|
23367
23529
|
return GREEN;
|
|
23368
|
-
return { ran: true, red: true, interrupted: false, blocker: typeBlockerText(label, input.base, added) };
|
|
23530
|
+
return { ran: true, red: true, interrupted: false, cannotStart: false, blocker: typeBlockerText(label, input.base, added) };
|
|
23369
23531
|
}
|
|
23370
23532
|
|
|
23371
23533
|
// packages/rafa-run/src/start/task-gate-lines.ts
|
|
@@ -24871,12 +25033,19 @@ function createStartStaleDocs(options) {
|
|
|
24871
25033
|
const redact = (text) => local(redactSecrets(text, secrets));
|
|
24872
25034
|
const kept = new Map;
|
|
24873
25035
|
let version = null;
|
|
25036
|
+
let newestRelease = null;
|
|
24874
25037
|
let tracker = null;
|
|
24875
25038
|
let docUpdatePlan;
|
|
24876
25039
|
const versionOnce = () => {
|
|
24877
25040
|
version ??= (options.readVersion ?? (() => readStaleDocsVersion(options)))();
|
|
24878
25041
|
return version;
|
|
24879
25042
|
};
|
|
25043
|
+
const newestReleaseOnce = () => {
|
|
25044
|
+
newestRelease ??= {
|
|
25045
|
+
value: (options.readNewestRelease ?? (() => newestRootRelease(createGitRunner(options.checkout))))()
|
|
25046
|
+
};
|
|
25047
|
+
return newestRelease.value;
|
|
25048
|
+
};
|
|
24880
25049
|
const resolveOnce = () => {
|
|
24881
25050
|
tracker ??= (options.resolve ?? resolveTracker)({
|
|
24882
25051
|
config: options.config,
|
|
@@ -24904,7 +25073,12 @@ function createStartStaleDocs(options) {
|
|
|
24904
25073
|
}
|
|
24905
25074
|
};
|
|
24906
25075
|
const addLine = async (entry) => {
|
|
24907
|
-
const result = await addStaleDocLine({
|
|
25076
|
+
const result = await addStaleDocLine({
|
|
25077
|
+
tracker: await resolveOnce(),
|
|
25078
|
+
version: versionOnce(),
|
|
25079
|
+
entry,
|
|
25080
|
+
newestRelease: newestReleaseOnce()
|
|
25081
|
+
});
|
|
24908
25082
|
const text = staleDocLineText(entry);
|
|
24909
25083
|
if (result.action === "kept")
|
|
24910
25084
|
kept.set(text, result.title);
|
|
@@ -25061,17 +25235,17 @@ function announceRunStepOnly(items) {
|
|
|
25061
25235
|
// packages/rafa-run/src/start/suite-step.ts
|
|
25062
25236
|
import { readFileSync as readFileSync38 } from "fs";
|
|
25063
25237
|
import { constants as constants3 } from "os";
|
|
25064
|
-
import { basename as
|
|
25238
|
+
import { basename as basename14, join as join48 } from "path";
|
|
25065
25239
|
|
|
25066
25240
|
// packages/rafa-run/src/suite/baseline.ts
|
|
25067
25241
|
import { existsSync as existsSync35, mkdirSync as mkdirSync6, readFileSync as readFileSync33, renameSync as renameSync2, writeFileSync as writeFileSync11 } from "fs";
|
|
25068
|
-
import { basename as
|
|
25242
|
+
import { basename as basename12, dirname as dirname16, join as join43 } from "path";
|
|
25069
25243
|
var BASELINE_VERSION = 1;
|
|
25070
25244
|
var BASELINE_FILE_PREFIX = "SUITE_BASELINE";
|
|
25071
25245
|
var PLAN_FILE_NAME2 = /^PLAN(?:_TRACKER)?(-.+)?\.md$/;
|
|
25072
25246
|
var JUNIT_READINGS = ["read", "missing", "unreadable"];
|
|
25073
25247
|
function baselinePathFor(trackerPath) {
|
|
25074
|
-
const match = PLAN_FILE_NAME2.exec(
|
|
25248
|
+
const match = PLAN_FILE_NAME2.exec(basename12(trackerPath));
|
|
25075
25249
|
if (match === null) {
|
|
25076
25250
|
throw new RangeError(`baselinePathFor: ${trackerPath} is not a PLAN or PLAN_TRACKER file`);
|
|
25077
25251
|
}
|
|
@@ -25560,12 +25734,12 @@ function announceStepOnly(context, settling) {
|
|
|
25560
25734
|
|
|
25561
25735
|
// packages/rafa-run/src/start/suite-stage-ledger.ts
|
|
25562
25736
|
import { existsSync as existsSync38, mkdirSync as mkdirSync7, readFileSync as readFileSync35, renameSync as renameSync3, writeFileSync as writeFileSync12 } from "fs";
|
|
25563
|
-
import { basename as
|
|
25737
|
+
import { basename as basename13, dirname as dirname17, join as join47 } from "path";
|
|
25564
25738
|
var STAGE_LEDGER_PREFIX = "SUITE_STAGES";
|
|
25565
25739
|
var STAGE_LEDGER_VERSION = 1;
|
|
25566
25740
|
function stageLedgerPathFor(trackerPath) {
|
|
25567
25741
|
const baselinePath = baselinePathFor(trackerPath);
|
|
25568
|
-
const name =
|
|
25742
|
+
const name = basename13(baselinePath).replace(BASELINE_FILE_PREFIX, STAGE_LEDGER_PREFIX);
|
|
25569
25743
|
return join47(dirname17(baselinePath), name);
|
|
25570
25744
|
}
|
|
25571
25745
|
function isLedgerEntry(value) {
|
|
@@ -25600,7 +25774,7 @@ function readStageLedger(path3) {
|
|
|
25600
25774
|
}
|
|
25601
25775
|
if (typeof parsed !== "string")
|
|
25602
25776
|
return parsed;
|
|
25603
|
-
activeOutput().warn(`\u26A0\uFE0F ${
|
|
25777
|
+
activeOutput().warn(`\u26A0\uFE0F ${basename13(path3)} does not read (${parsed}); every finished stage's step is taken again.`);
|
|
25604
25778
|
return [];
|
|
25605
25779
|
}
|
|
25606
25780
|
function writeStageLedger(path3, entries) {
|
|
@@ -25619,7 +25793,7 @@ function addToLedger(trackerPath, added) {
|
|
|
25619
25793
|
try {
|
|
25620
25794
|
writeStageLedger(path3, [...entries, ...fresh]);
|
|
25621
25795
|
} catch (error) {
|
|
25622
|
-
activeOutput().warn(`\u26A0\uFE0F Could not write ${
|
|
25796
|
+
activeOutput().warn(`\u26A0\uFE0F Could not write ${basename13(path3)} (${messageOf(error)}); the next run takes these stage steps again.`);
|
|
25623
25797
|
}
|
|
25624
25798
|
}
|
|
25625
25799
|
function sameStage(a, b) {
|
|
@@ -25966,6 +26140,9 @@ function typeCheckTask(context, seams, input) {
|
|
|
25966
26140
|
const isInterrupted = context.isInterrupted ?? (() => false);
|
|
25967
26141
|
return runTypeStep({ checkout: context.checkout, base: input.base, task: input.task, git: seams.git, runTypes: seams.runTypes, stopCode: SIGINT_EXIT_CODE, isInterrupted });
|
|
25968
26142
|
}
|
|
26143
|
+
function isCheckUnstartable(settling) {
|
|
26144
|
+
return settling.types?.cannotStart === true;
|
|
26145
|
+
}
|
|
25969
26146
|
async function taskDiffChecks(context, seams, input, result) {
|
|
25970
26147
|
if (isStepInterrupted(context, result))
|
|
25971
26148
|
return {};
|
|
@@ -26211,7 +26388,7 @@ function settleStep(context, seams, settling) {
|
|
|
26211
26388
|
const tested = isRed(verdict) ? [blockerText(label, result, verdict, alone)] : [];
|
|
26212
26389
|
const blocker = [...tested, ...checked].join(" ");
|
|
26213
26390
|
activeOutput().error(`\u274C ${blocker}`);
|
|
26214
|
-
const written = settling.repair === null ? null : writeRepairTask(context.trackerPath, blocker, { ...settling.repair, commit: readHead(seams.git) });
|
|
26391
|
+
const written = settling.repair === null || isCheckUnstartable(settling) ? null : writeRepairTask(context.trackerPath, blocker, { ...settling.repair, commit: readHead(seams.git) });
|
|
26215
26392
|
if (written !== null)
|
|
26216
26393
|
activeOutput().error(written.inserted ? ` A repair task (line ${written.line + 1}) is inserted, blocked on it.` : ` The repair task (line ${written.line + 1}) is marked blocked on it again.`);
|
|
26217
26394
|
return { kind, step: step2, red: true, interrupted: false, blocker, blockedLine: written?.line ?? null, repairInserted: written?.inserted ?? false };
|
|
@@ -26255,13 +26432,13 @@ async function ensureBaseline(context) {
|
|
|
26255
26432
|
const reading = readBaseline(path3);
|
|
26256
26433
|
if (reading.state === "read" && !failedOutsideAnyCase(reading.baseline)) {
|
|
26257
26434
|
const known = reading.baseline.failures.length;
|
|
26258
|
-
activeOutput().info(`\uD83D\uDCCF Suite baseline reused from ${
|
|
26435
|
+
activeOutput().info(`\uD83D\uDCCF Suite baseline reused from ${basename14(path3)} (${reading.baseline.recordedAt}): ${known} known failure(s).`);
|
|
26259
26436
|
return { baseline: reading.baseline, step: null, interrupted: false, halted: false };
|
|
26260
26437
|
}
|
|
26261
26438
|
if (reading.state === "unreadable")
|
|
26262
|
-
activeOutput().warn(`\u26A0\uFE0F ${
|
|
26439
|
+
activeOutput().warn(`\u26A0\uFE0F ${basename14(path3)} does not read (${reading.reason}); recording the baseline again.`);
|
|
26263
26440
|
if (reading.state === "read")
|
|
26264
|
-
activeOutput().warn(storedOutsideCaseLine(
|
|
26441
|
+
activeOutput().warn(storedOutsideCaseLine(basename14(path3), reading.baseline));
|
|
26265
26442
|
const commit = readHead(seams.git);
|
|
26266
26443
|
const result = await runOne(context, seams, "baseline", {});
|
|
26267
26444
|
const baseline = baselineOf(result, seams.now(), commit);
|
|
@@ -26277,7 +26454,7 @@ async function ensureBaseline(context) {
|
|
|
26277
26454
|
try {
|
|
26278
26455
|
writeBaseline(path3, baseline);
|
|
26279
26456
|
} catch (error) {
|
|
26280
|
-
activeOutput().warn(`\u26A0\uFE0F Could not write ${
|
|
26457
|
+
activeOutput().warn(`\u26A0\uFE0F Could not write ${basename14(path3)} (${messageOf(error)}); the next run records the baseline again.`);
|
|
26281
26458
|
}
|
|
26282
26459
|
const outcome = settleStep(context, seams, settling);
|
|
26283
26460
|
const covered = completeStages(readFileSync38(context.trackerPath, "utf8"));
|
|
@@ -27197,7 +27374,7 @@ function issueDraft2(stub, lines) {
|
|
|
27197
27374
|
function canHoldIssue2(tracker) {
|
|
27198
27375
|
return tracker !== null && tracker.openIssues !== undefined && tracker.edit !== undefined;
|
|
27199
27376
|
}
|
|
27200
|
-
function
|
|
27377
|
+
function findIssue(open, stub) {
|
|
27201
27378
|
const marker = followUpsMarker(stub);
|
|
27202
27379
|
const title = followUpsTitle(stub);
|
|
27203
27380
|
return open.find((issue4) => issue4.body.includes(marker) && issue4.title === title);
|
|
@@ -27214,7 +27391,7 @@ async function fileOn(tracker, stub, lines) {
|
|
|
27214
27391
|
const listed3 = await call2("listing the open bug issues", () => tracker.openIssues("bug"));
|
|
27215
27392
|
if ("problem" in listed3)
|
|
27216
27393
|
return { action: "failed", problem: listed3.problem };
|
|
27217
|
-
const found =
|
|
27394
|
+
const found = findIssue(listed3.value, stub);
|
|
27218
27395
|
if (found === undefined) {
|
|
27219
27396
|
const created = await call2("creating the follow-up issue", () => tracker.create(issueDraft2(stub, lines)));
|
|
27220
27397
|
return "problem" in created ? { action: "failed", problem: created.problem } : { action: "created", title, ref: created.value, lines };
|
|
@@ -28284,8 +28461,24 @@ function deliverySeamsIn(context) {
|
|
|
28284
28461
|
};
|
|
28285
28462
|
}
|
|
28286
28463
|
// src/service-registry.ts
|
|
28464
|
+
function newestReleaseHere() {
|
|
28465
|
+
return newestRootRelease(createGitRunner(process.cwd()));
|
|
28466
|
+
}
|
|
28467
|
+
function addStaleDocLineWithRelease(readNewestRelease = newestReleaseHere) {
|
|
28468
|
+
return (options) => {
|
|
28469
|
+
if (options.newestRelease !== undefined)
|
|
28470
|
+
return addStaleDocLine(options);
|
|
28471
|
+
let newestRelease;
|
|
28472
|
+
try {
|
|
28473
|
+
newestRelease = readNewestRelease();
|
|
28474
|
+
} catch {
|
|
28475
|
+
newestRelease = undefined;
|
|
28476
|
+
}
|
|
28477
|
+
return addStaleDocLine({ ...options, newestRelease });
|
|
28478
|
+
};
|
|
28479
|
+
}
|
|
28287
28480
|
var CORE_SERVICES = Object.freeze({
|
|
28288
|
-
addStaleDocLine,
|
|
28481
|
+
addStaleDocLine: addStaleDocLineWithRelease(),
|
|
28289
28482
|
endWithNextStep,
|
|
28290
28483
|
pullRequestsIn: ghPullRequestsIn,
|
|
28291
28484
|
readStaleDocsVersion,
|
|
@@ -28298,14 +28491,14 @@ function registerCoreServices() {
|
|
|
28298
28491
|
return activeServices();
|
|
28299
28492
|
}
|
|
28300
28493
|
// src/plan.ts
|
|
28301
|
-
import
|
|
28494
|
+
import fs5 from "fs";
|
|
28302
28495
|
import { homedir as homedir15 } from "os";
|
|
28303
|
-
import
|
|
28496
|
+
import path7 from "path";
|
|
28304
28497
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
28305
28498
|
|
|
28306
28499
|
// src/commands/plan/bundled-check.ts
|
|
28307
28500
|
import { readdirSync as readdirSync12, readFileSync as readFileSync40, realpathSync as realpathSync6, statSync as statSync10, writeFileSync as writeFileSync13 } from "fs";
|
|
28308
|
-
import { basename as
|
|
28501
|
+
import { basename as basename15, isAbsolute as isAbsolute14, join as join49, relative as relative19, resolve as resolve21, sep as sep8 } from "path";
|
|
28309
28502
|
var SOURCE_DIR2 = "src";
|
|
28310
28503
|
var CODE_SPAN6 = /`([^`]+)`/gu;
|
|
28311
28504
|
var PATH_LIKE = /^\S+$/u;
|
|
@@ -28461,7 +28654,7 @@ function notePlanBundledEdits(repoRoot, generated, output = activeOutput()) {
|
|
|
28461
28654
|
let written = [];
|
|
28462
28655
|
if (file !== null) {
|
|
28463
28656
|
try {
|
|
28464
|
-
written = writeTierPins(resolve21(repoRoot, file),
|
|
28657
|
+
written = writeTierPins(resolve21(repoRoot, file), basename15(generated.planPath), edits);
|
|
28465
28658
|
} catch (error) {
|
|
28466
28659
|
output.warn(`${file}: the tier pins could not be written: ${messageOf(error)}`);
|
|
28467
28660
|
written = null;
|
|
@@ -28673,7 +28866,7 @@ function createPlanBlockedOffer(seams = DEFAULT_BLOCKED_SEAMS) {
|
|
|
28673
28866
|
|
|
28674
28867
|
// src/commands/plan/ready-offer.ts
|
|
28675
28868
|
var runIssueReadyLazily = async (options) => {
|
|
28676
|
-
const { runIssueReady: run } = await import("./ready-
|
|
28869
|
+
const { runIssueReady: run } = await import("./ready-dph3z1nz.js");
|
|
28677
28870
|
return run(options);
|
|
28678
28871
|
};
|
|
28679
28872
|
var DEFAULT_OFFER_SEAMS = Object.freeze({});
|
|
@@ -28763,6 +28956,7 @@ async function resolveCreateSpec(options, seams = DEFAULT_ROUTE_SEAMS) {
|
|
|
28763
28956
|
const makeReadyOffer = seams.makeReadyOffer ?? createPlanReadyOffer;
|
|
28764
28957
|
const makeAlternativeOffer = seams.makeAlternativeOffer ?? createPlanBlockedOffer;
|
|
28765
28958
|
const makeRefreshOffer = seams.makeRefreshOffer ?? createPlanRefreshOffer;
|
|
28959
|
+
const rules = source.request.kind === "spec" ? null : options.readRules?.() ?? null;
|
|
28766
28960
|
return await resolve22({
|
|
28767
28961
|
request: source.request,
|
|
28768
28962
|
refresh: source.refresh,
|
|
@@ -28778,13 +28972,14 @@ async function resolveCreateSpec(options, seams = DEFAULT_ROUTE_SEAMS) {
|
|
|
28778
28972
|
offerRefresh: makeRefreshOffer(),
|
|
28779
28973
|
...options.passOver === undefined ? {} : { passOver: options.passOver },
|
|
28780
28974
|
...options.branchTemplate === undefined ? {} : { branchTemplate: options.branchTemplate },
|
|
28781
|
-
...options.projectConfig === undefined ? {} : { projectConfig: options.projectConfig }
|
|
28975
|
+
...options.projectConfig === undefined ? {} : { projectConfig: options.projectConfig },
|
|
28976
|
+
...rules === null ? {} : { rules }
|
|
28782
28977
|
});
|
|
28783
28978
|
}
|
|
28784
28979
|
|
|
28785
28980
|
// src/commands/plan/store-check.ts
|
|
28786
28981
|
import { mkdirSync as mkdirSync8, readFileSync as readFileSync41, renameSync as renameSync4 } from "fs";
|
|
28787
|
-
import { basename as
|
|
28982
|
+
import { basename as basename16, dirname as dirname18, resolve as resolve22 } from "path";
|
|
28788
28983
|
function readFileOrNull(path6) {
|
|
28789
28984
|
return path6 !== null && isFile(path6) ? readFileSync41(path6, "utf8") : null;
|
|
28790
28985
|
}
|
|
@@ -28793,7 +28988,7 @@ function checkStoreRules(file, markdown) {
|
|
|
28793
28988
|
return findStoreRuleProblems({
|
|
28794
28989
|
plan: markdown,
|
|
28795
28990
|
prerequisites: readFileOrNull(prerequisitesPath),
|
|
28796
|
-
prerequisitesName:
|
|
28991
|
+
prerequisitesName: basename16(prerequisitesPath ?? "PREREQUISITES-<stub>.md")
|
|
28797
28992
|
});
|
|
28798
28993
|
}
|
|
28799
28994
|
function moveRejected(repoRoot, path6, output) {
|
|
@@ -28828,6 +29023,66 @@ function enforceStoreRules(repoRoot, generated, output = activeOutput()) {
|
|
|
28828
29023
|
`));
|
|
28829
29024
|
}
|
|
28830
29025
|
|
|
29026
|
+
// src/commands/plan/stretch-rules.ts
|
|
29027
|
+
import fs4 from "fs";
|
|
29028
|
+
import path6 from "path";
|
|
29029
|
+
var STRETCH_RULES_ENV = "RAFA_STRETCH_RULES";
|
|
29030
|
+
var STRETCH_RULES_REFUSAL_EXIT = 1;
|
|
29031
|
+
function missingRulesMessage(value) {
|
|
29032
|
+
return `${STRETCH_RULES_ENV}=${value} names no file; a stretch's rules are read from its rules.md,` + ` so write that file or unset ${STRETCH_RULES_ENV}`;
|
|
29033
|
+
}
|
|
29034
|
+
function notRulesFileMessage(value, what) {
|
|
29035
|
+
return `${STRETCH_RULES_ENV}=${value} names ${what}, not a file; point it at the stretch's rules.md`;
|
|
29036
|
+
}
|
|
29037
|
+
function unreadableRulesMessage(value, reason) {
|
|
29038
|
+
return `${STRETCH_RULES_ENV}=${value} could not be read: ${reason}`;
|
|
29039
|
+
}
|
|
29040
|
+
function describeEntry(stat) {
|
|
29041
|
+
return stat.isDirectory() ? "a directory" : "something other than a file";
|
|
29042
|
+
}
|
|
29043
|
+
function displayPath2(repoRoot, absolute) {
|
|
29044
|
+
const relative20 = path6.relative(repoRoot, absolute);
|
|
29045
|
+
return relative20 === "" || relative20.startsWith("..") || path6.isAbsolute(relative20) ? absolute : relative20;
|
|
29046
|
+
}
|
|
29047
|
+
function readStretchRules(env, repoRoot) {
|
|
29048
|
+
const value = env[STRETCH_RULES_ENV];
|
|
29049
|
+
if (value === undefined || value.trim() === "")
|
|
29050
|
+
return null;
|
|
29051
|
+
const absolute = path6.resolve(repoRoot, value);
|
|
29052
|
+
let stat;
|
|
29053
|
+
try {
|
|
29054
|
+
stat = fs4.statSync(absolute);
|
|
29055
|
+
} catch (error) {
|
|
29056
|
+
if (errorCode(error) === "ENOENT") {
|
|
29057
|
+
throw new CommandExit(STRETCH_RULES_REFUSAL_EXIT, missingRulesMessage(value));
|
|
29058
|
+
}
|
|
29059
|
+
throw new CommandExit(STRETCH_RULES_REFUSAL_EXIT, unreadableRulesMessage(value, messageOf(error)));
|
|
29060
|
+
}
|
|
29061
|
+
if (!stat.isFile()) {
|
|
29062
|
+
throw new CommandExit(STRETCH_RULES_REFUSAL_EXIT, notRulesFileMessage(value, describeEntry(stat)));
|
|
29063
|
+
}
|
|
29064
|
+
try {
|
|
29065
|
+
return Object.freeze({ path: displayPath2(repoRoot, absolute), text: fs4.readFileSync(absolute, "utf8") });
|
|
29066
|
+
} catch (error) {
|
|
29067
|
+
throw new CommandExit(STRETCH_RULES_REFUSAL_EXIT, unreadableRulesMessage(value, messageOf(error)));
|
|
29068
|
+
}
|
|
29069
|
+
}
|
|
29070
|
+
function stretchRulesReader(env, repoRoot) {
|
|
29071
|
+
let reading = null;
|
|
29072
|
+
return () => {
|
|
29073
|
+
if (reading === null) {
|
|
29074
|
+
try {
|
|
29075
|
+
reading = { ok: true, rules: readStretchRules(env, repoRoot) };
|
|
29076
|
+
} catch (error) {
|
|
29077
|
+
reading = { ok: false, error };
|
|
29078
|
+
}
|
|
29079
|
+
}
|
|
29080
|
+
if (reading.ok)
|
|
29081
|
+
return reading.rules;
|
|
29082
|
+
throw reading.error;
|
|
29083
|
+
};
|
|
29084
|
+
}
|
|
29085
|
+
|
|
28831
29086
|
// src/notices/run.ts
|
|
28832
29087
|
import { homedir as homedir14 } from "os";
|
|
28833
29088
|
|
|
@@ -28864,9 +29119,9 @@ function readDismissed(home) {
|
|
|
28864
29119
|
}
|
|
28865
29120
|
function writeDismissed(home, ids) {
|
|
28866
29121
|
const all = NOTICE_IDS.filter((id2) => ids.includes(id2) || readDismissed(home).includes(id2));
|
|
28867
|
-
const
|
|
28868
|
-
mkdirSync9(dirname19(
|
|
28869
|
-
writeFileSync14(
|
|
29122
|
+
const path7 = noticesPath(home);
|
|
29123
|
+
mkdirSync9(dirname19(path7), { recursive: true });
|
|
29124
|
+
writeFileSync14(path7, `${JSON.stringify({ dismissed: all }, null, 2)}
|
|
28870
29125
|
`);
|
|
28871
29126
|
}
|
|
28872
29127
|
function pendingNotices(dismissed) {
|
|
@@ -28956,7 +29211,7 @@ async function requireNoticesAnswered(settingSources) {
|
|
|
28956
29211
|
}
|
|
28957
29212
|
|
|
28958
29213
|
// src/plan.ts
|
|
28959
|
-
var __dirname2 =
|
|
29214
|
+
var __dirname2 = path7.dirname(fileURLToPath5(import.meta.url));
|
|
28960
29215
|
function argValue2(args, flag) {
|
|
28961
29216
|
const hit = args.find((a) => a.startsWith(`${flag}=`));
|
|
28962
29217
|
return hit?.slice(flag.length + 1);
|
|
@@ -28982,16 +29237,16 @@ ${trimmed.slice(-PROGRESS_CAP_CHARS)}` : trimmed;
|
|
|
28982
29237
|
].join(`
|
|
28983
29238
|
`);
|
|
28984
29239
|
}
|
|
28985
|
-
var PLAN_FORMAT_SKILL =
|
|
29240
|
+
var PLAN_FORMAT_SKILL = path7.join(BUNDLED_SKILLS_DIR, "dev-planner", "SKILL.md");
|
|
28986
29241
|
function planFormatPath(moduleDir) {
|
|
28987
|
-
return
|
|
29242
|
+
return path7.join(moduleDir, PLAN_FORMAT_SKILL);
|
|
28988
29243
|
}
|
|
28989
29244
|
function readPlanFormat(moduleDir) {
|
|
28990
29245
|
const skill = planFormatPath(moduleDir);
|
|
28991
|
-
if (!
|
|
29246
|
+
if (!fs5.existsSync(skill)) {
|
|
28992
29247
|
throw new Error(`The plan format is missing: no dev-planner SKILL.md at ${skill}`);
|
|
28993
29248
|
}
|
|
28994
|
-
return
|
|
29249
|
+
return fs5.readFileSync(skill, "utf8");
|
|
28995
29250
|
}
|
|
28996
29251
|
var FRONTMATTER2 = /^---\r?\n[\s\S]*?\r?\n---\r?\n(?:\r?\n)*/;
|
|
28997
29252
|
function planFormatBody(skill) {
|
|
@@ -29115,7 +29370,7 @@ function buildPlanPrompt(template, planFormat, specContent, stub, planDir, progr
|
|
|
29115
29370
|
return template.replace(SLOT_PATTERN3, (_slot, name) => values[name]);
|
|
29116
29371
|
}
|
|
29117
29372
|
function stubFromSpecPath(specPath) {
|
|
29118
|
-
return
|
|
29373
|
+
return path7.basename(specPath).replace(/\.md$/, "");
|
|
29119
29374
|
}
|
|
29120
29375
|
function runBranchLine(planPath) {
|
|
29121
29376
|
const stub = planStubFromPath(planPath);
|
|
@@ -29147,6 +29402,7 @@ async function plan(args, repoRoot, roster, registry = CORE_ADAPTER_REGISTRY) {
|
|
|
29147
29402
|
dangerousAcceptStaleRefs
|
|
29148
29403
|
} = config;
|
|
29149
29404
|
const flags = readGateFlags(args);
|
|
29405
|
+
const readRules = stretchRulesReader(process.env, repoRoot);
|
|
29150
29406
|
const resolved = await resolveAndClaim({
|
|
29151
29407
|
resolve: (passOver) => resolveCreateSpec({
|
|
29152
29408
|
args,
|
|
@@ -29157,12 +29413,13 @@ async function plan(args, repoRoot, roster, registry = CORE_ADAPTER_REGISTRY) {
|
|
|
29157
29413
|
relationships: boardRelationships,
|
|
29158
29414
|
passOver,
|
|
29159
29415
|
branchTemplate: namingBranch,
|
|
29160
|
-
projectConfig: config
|
|
29416
|
+
projectConfig: config,
|
|
29417
|
+
readRules
|
|
29161
29418
|
}),
|
|
29162
29419
|
prepare: async (spec) => {
|
|
29163
|
-
const stub2 = argValue2(args, "--stub") ?? stubFromSpecPath(
|
|
29420
|
+
const stub2 = argValue2(args, "--stub") ?? stubFromSpecPath(path7.resolve(repoRoot, spec.path));
|
|
29164
29421
|
const planFile2 = planFilePath(planDir, `PLAN-${stub2}.md`);
|
|
29165
|
-
if (
|
|
29422
|
+
if (fs5.existsSync(path7.resolve(repoRoot, planFile2))) {
|
|
29166
29423
|
throw new CommandExit(1, `\u274C ${planFile2} already exists \u2014 remove it or pass a different --stub.`);
|
|
29167
29424
|
}
|
|
29168
29425
|
await checkCreateRefs({ spec, repoRoot, args, acceptStaleRefs: dangerousAcceptStaleRefs, roster });
|
|
@@ -29176,15 +29433,15 @@ async function plan(args, repoRoot, roster, registry = CORE_ADAPTER_REGISTRY) {
|
|
|
29176
29433
|
return;
|
|
29177
29434
|
const { stub } = resolved;
|
|
29178
29435
|
const specRequest = resolved.spec.path;
|
|
29179
|
-
const specPath =
|
|
29436
|
+
const specPath = path7.resolve(repoRoot, specRequest);
|
|
29180
29437
|
const planFile = planFilePath(planDir, `PLAN-${stub}.md`);
|
|
29181
|
-
const progressPath =
|
|
29182
|
-
const progressContent = !args.includes("--no-progress") &&
|
|
29438
|
+
const progressPath = path7.join(repoRoot, "progress.txt");
|
|
29439
|
+
const progressContent = !args.includes("--no-progress") && fs5.existsSync(progressPath) ? fs5.readFileSync(progressPath, "utf8") : undefined;
|
|
29183
29440
|
if (progressContent?.trim()) {
|
|
29184
29441
|
activeOutput().info("\uD83D\uDCCE Including findings from progress.txt (disable with --no-progress).");
|
|
29185
29442
|
}
|
|
29186
29443
|
const epic = await readPlanEpicContext(resolved.spec, createGhRunner({ cwd: repoRoot }));
|
|
29187
|
-
const template =
|
|
29444
|
+
const template = fs5.readFileSync(path7.join(__dirname2, "plan-prompt.md"), "utf8");
|
|
29188
29445
|
const planFormat = readPlanFormat(__dirname2);
|
|
29189
29446
|
const skillIndex = readPlanSkillIndex(repoRoot, home, config, fileURLToPath5(import.meta.url));
|
|
29190
29447
|
const planner = registry.resolve("planner", "claude").create({
|
|
@@ -29202,7 +29459,7 @@ async function plan(args, repoRoot, roster, registry = CORE_ADAPTER_REGISTRY) {
|
|
|
29202
29459
|
comment: flags.comment
|
|
29203
29460
|
};
|
|
29204
29461
|
await requireNoticesAnswered(settingSources);
|
|
29205
|
-
activeOutput().info(`\uD83D\uDCDD Generating ${planFile} from ${
|
|
29462
|
+
activeOutput().info(`\uD83D\uDCDD Generating ${planFile} from ${path7.basename(specPath)}...`);
|
|
29206
29463
|
const answered = await generateOrExit(planner, { specPath: specRequest, stub }, gate, flags.skipReview);
|
|
29207
29464
|
enforceStoreRules(repoRoot, answered);
|
|
29208
29465
|
const generated = notePlanBundledEdits(repoRoot, answered);
|
|
@@ -29222,9 +29479,9 @@ async function plan(args, repoRoot, roster, registry = CORE_ADAPTER_REGISTRY) {
|
|
|
29222
29479
|
}
|
|
29223
29480
|
}
|
|
29224
29481
|
// src/start.ts
|
|
29225
|
-
import
|
|
29482
|
+
import fs6 from "fs";
|
|
29226
29483
|
import { homedir as homedir16 } from "os";
|
|
29227
|
-
import
|
|
29484
|
+
import path8 from "path";
|
|
29228
29485
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
29229
29486
|
|
|
29230
29487
|
// src/utils/schedule.ts
|
|
@@ -29257,7 +29514,7 @@ async function deferUntil(startAt, now = new Date, sleep = sleepFor) {
|
|
|
29257
29514
|
}
|
|
29258
29515
|
|
|
29259
29516
|
// src/start.ts
|
|
29260
|
-
var __dirname3 =
|
|
29517
|
+
var __dirname3 = path8.dirname(fileURLToPath6(import.meta.url));
|
|
29261
29518
|
var interrupted2 = false;
|
|
29262
29519
|
async function start(args, repoRoot) {
|
|
29263
29520
|
refuseDetachedRun(args);
|
|
@@ -29284,10 +29541,10 @@ async function start(args, repoRoot) {
|
|
|
29284
29541
|
if (startAt)
|
|
29285
29542
|
await deferUntil(startAt);
|
|
29286
29543
|
const planPath = resolvePlanPath(repoRoot, runConfig.config.planDir, plan2);
|
|
29287
|
-
const rootPromptPath =
|
|
29288
|
-
const promptPath =
|
|
29544
|
+
const rootPromptPath = path8.join(repoRoot, "PROMPT.md");
|
|
29545
|
+
const promptPath = fs6.existsSync(rootPromptPath) ? rootPromptPath : path8.join(__dirname3, "PROMPT.md");
|
|
29289
29546
|
const trackerPath = trackerPathFor(planPath);
|
|
29290
|
-
if (!
|
|
29547
|
+
if (!fs6.existsSync(planPath)) {
|
|
29291
29548
|
throw new CommandExit(1, `\u274C Plan file not found: ${planPath}`);
|
|
29292
29549
|
}
|
|
29293
29550
|
const planStub = planStubFromPath(planPath);
|
|
@@ -29318,8 +29575,8 @@ async function start(args, repoRoot) {
|
|
|
29318
29575
|
return;
|
|
29319
29576
|
};
|
|
29320
29577
|
try {
|
|
29321
|
-
const planContent =
|
|
29322
|
-
const promptContent =
|
|
29578
|
+
const planContent = fs6.readFileSync(planPath, "utf8");
|
|
29579
|
+
const promptContent = fs6.readFileSync(promptPath, "utf8");
|
|
29323
29580
|
const injectSource = injectSourceLabel(runConfig);
|
|
29324
29581
|
announceRunDirs({ projectRoot: repoRoot, checkout });
|
|
29325
29582
|
activeOutput().info(`\uD83E\uDDED Task sessions are handed the plan as \`${injectMode}\` (${injectSource}); the wrap-up is handed all of it.`);
|
|
@@ -29395,11 +29652,11 @@ async function start(args, repoRoot) {
|
|
|
29395
29652
|
previousNeeded: continueRun.directive === null ? null : readPreviousDecisionNeeded(repoRoot, runPlace)
|
|
29396
29653
|
});
|
|
29397
29654
|
decisionsAtEnd = decisions.atRunEnd;
|
|
29398
|
-
if (!
|
|
29399
|
-
activeOutput().info(`\uD83D\uDCCB Creating new plan tracker at ${
|
|
29400
|
-
|
|
29655
|
+
if (!fs6.existsSync(trackerPath)) {
|
|
29656
|
+
activeOutput().info(`\uD83D\uDCCB Creating new plan tracker at ${path8.basename(trackerPath)}...`);
|
|
29657
|
+
fs6.copyFileSync(planPath, trackerPath);
|
|
29401
29658
|
} else {
|
|
29402
|
-
activeOutput().info(`\uD83D\uDCCB Resuming from existing ${
|
|
29659
|
+
activeOutput().info(`\uD83D\uDCCB Resuming from existing ${path8.basename(trackerPath)}...`);
|
|
29403
29660
|
}
|
|
29404
29661
|
process.on("SIGINT", () => {
|
|
29405
29662
|
interrupted2 = true;
|
|
@@ -29411,7 +29668,7 @@ async function start(args, repoRoot) {
|
|
|
29411
29668
|
await holdWhilePaused({ repoRoot, sessionId: session.id, isInterrupted: () => interrupted2 });
|
|
29412
29669
|
if (interrupted2)
|
|
29413
29670
|
break;
|
|
29414
|
-
const trackerContent =
|
|
29671
|
+
const trackerContent = fs6.readFileSync(trackerPath, "utf8");
|
|
29415
29672
|
const taskInfo = findNextTask(trackerContent, { skipLines: decisions.skipLines(trackerContent) });
|
|
29416
29673
|
const passedOver = taskInfo ? [] : decisions.atPlanEnd(trackerContent);
|
|
29417
29674
|
if (await decisions.atFirstTask(taskInfo, trackerContent))
|