@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/config/index.js
CHANGED
|
@@ -13,10 +13,10 @@ import {
|
|
|
13
13
|
openNdjsonStore,
|
|
14
14
|
openSqliteStore,
|
|
15
15
|
selectEffortStore
|
|
16
|
-
} from "../../index-
|
|
16
|
+
} from "../../index-j518r1yt.js";
|
|
17
17
|
import {
|
|
18
18
|
TRUSTED_PERMISSIONS
|
|
19
|
-
} from "../../index-
|
|
19
|
+
} from "../../index-h9vwrj54.js";
|
|
20
20
|
import"../../index-2a7nb3an.js";
|
|
21
21
|
import"../../index-m672ptpg.js";
|
|
22
22
|
import {
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
isRecord,
|
|
21
21
|
normalizeRemote,
|
|
22
22
|
setActiveStoreSettings
|
|
23
|
-
} from "./index-
|
|
23
|
+
} from "./index-h9vwrj54.js";
|
|
24
24
|
import {
|
|
25
25
|
activeOutput,
|
|
26
26
|
activeOutputMode
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
UNKNOWN_FAMILY,
|
|
34
34
|
activeLoggerSettings,
|
|
35
35
|
levelEnabled
|
|
36
|
-
} from "./index-
|
|
36
|
+
} from "./index-jjxnyqvy.js";
|
|
37
37
|
import {
|
|
38
38
|
CONFIG_FILE,
|
|
39
39
|
ConfigError,
|
|
@@ -3135,12 +3135,167 @@ function movePreviousCopy(options) {
|
|
|
3135
3135
|
return moved;
|
|
3136
3136
|
}
|
|
3137
3137
|
|
|
3138
|
+
// packages/rafa-board/src/board/snapshot-change.ts
|
|
3139
|
+
var LOCAL_NOTES_HEADING = "## Local notes";
|
|
3140
|
+
var STRETCH_RULES_HEADING = "## Stretch rules";
|
|
3141
|
+
var RULES_REMOVED_LINE = "stretch rules: the saved copy holds rules, and this run was handed no rules file";
|
|
3142
|
+
function normalise(text) {
|
|
3143
|
+
return text.replace(/\r\n?/gu, `
|
|
3144
|
+
`).replace(/\n+$/u, "");
|
|
3145
|
+
}
|
|
3146
|
+
function localText(text) {
|
|
3147
|
+
return text === null ? "" : normalise(text).trim();
|
|
3148
|
+
}
|
|
3149
|
+
function section(heading, text) {
|
|
3150
|
+
return text === "" ? "" : `${heading}
|
|
3151
|
+
|
|
3152
|
+
${text}`;
|
|
3153
|
+
}
|
|
3154
|
+
function snapshotText(body, notes, rules = null) {
|
|
3155
|
+
const sections2 = [
|
|
3156
|
+
normalise(body),
|
|
3157
|
+
section(LOCAL_NOTES_HEADING, localText(notes)),
|
|
3158
|
+
section(STRETCH_RULES_HEADING, localText(rules))
|
|
3159
|
+
].filter((part) => part !== "");
|
|
3160
|
+
return `${sections2.join(`
|
|
3161
|
+
|
|
3162
|
+
`)}
|
|
3163
|
+
`;
|
|
3164
|
+
}
|
|
3165
|
+
var NOTES_SEPARATOR = `
|
|
3166
|
+
|
|
3167
|
+
${LOCAL_NOTES_HEADING}
|
|
3168
|
+
|
|
3169
|
+
`;
|
|
3170
|
+
var RULES_SEPARATOR = `
|
|
3171
|
+
|
|
3172
|
+
${STRETCH_RULES_HEADING}
|
|
3173
|
+
|
|
3174
|
+
`;
|
|
3175
|
+
var HEADING2 = /^#{1,6}(?:[ \t]|$)/u;
|
|
3176
|
+
var FENCE3 = /^ {0,3}(?:`{3,}|~{3,})/u;
|
|
3177
|
+
function commonLines(before, after) {
|
|
3178
|
+
let previous = new Uint32Array(after.length + 1);
|
|
3179
|
+
for (const line of before) {
|
|
3180
|
+
const row = new Uint32Array(after.length + 1);
|
|
3181
|
+
after.forEach((other, index) => {
|
|
3182
|
+
row[index + 1] = line === other ? (previous[index] ?? 0) + 1 : Math.max(previous[index + 1] ?? 0, row[index] ?? 0);
|
|
3183
|
+
});
|
|
3184
|
+
previous = row;
|
|
3185
|
+
}
|
|
3186
|
+
return previous[after.length] ?? 0;
|
|
3187
|
+
}
|
|
3188
|
+
function headingName(line) {
|
|
3189
|
+
const text = line.replace(/^#+/u, "").replace(/[ \t]+#+[ \t]*$/u, "").trim();
|
|
3190
|
+
return text === "" ? line.trim() : text;
|
|
3191
|
+
}
|
|
3192
|
+
function headingSections(lines) {
|
|
3193
|
+
const sections2 = new Map;
|
|
3194
|
+
let fenced = false;
|
|
3195
|
+
let current = null;
|
|
3196
|
+
const close = () => {
|
|
3197
|
+
if (current === null)
|
|
3198
|
+
return;
|
|
3199
|
+
sections2.set(current.key, [...sections2.get(current.key) ?? [], current.lines.join(`
|
|
3200
|
+
`)]);
|
|
3201
|
+
};
|
|
3202
|
+
for (const line of lines) {
|
|
3203
|
+
if (FENCE3.test(line))
|
|
3204
|
+
fenced = !fenced;
|
|
3205
|
+
if (fenced || !HEADING2.test(line)) {
|
|
3206
|
+
current?.lines.push(line);
|
|
3207
|
+
continue;
|
|
3208
|
+
}
|
|
3209
|
+
close();
|
|
3210
|
+
current = { key: line.trim(), lines: [] };
|
|
3211
|
+
}
|
|
3212
|
+
close();
|
|
3213
|
+
return sections2;
|
|
3214
|
+
}
|
|
3215
|
+
function changedHeadings(before, after) {
|
|
3216
|
+
const old = headingSections(before);
|
|
3217
|
+
const now = headingSections(after);
|
|
3218
|
+
const keys = [...now.keys(), ...[...old.keys()].filter((key) => !now.has(key))];
|
|
3219
|
+
const changed = keys.filter((key) => JSON.stringify(old.get(key) ?? []) !== JSON.stringify(now.get(key) ?? []));
|
|
3220
|
+
return [...new Set(changed.map(headingName))];
|
|
3221
|
+
}
|
|
3222
|
+
function bodyChangeLine(before, after) {
|
|
3223
|
+
const old = before.split(`
|
|
3224
|
+
`);
|
|
3225
|
+
const now = after.split(`
|
|
3226
|
+
`);
|
|
3227
|
+
const common = commonLines(old, now);
|
|
3228
|
+
const headings = changedHeadings(old, now);
|
|
3229
|
+
const clause = headings.length === 0 ? "no heading changed" : `headings changed: ${headings.join(", ")}`;
|
|
3230
|
+
return `issue body: +${String(now.length - common)} -${String(old.length - common)} lines; ${clause}`;
|
|
3231
|
+
}
|
|
3232
|
+
function notesChangeLine(path2) {
|
|
3233
|
+
return `local notes: ${path2} changed since the saved copy`;
|
|
3234
|
+
}
|
|
3235
|
+
function rulesChangeLine(rules) {
|
|
3236
|
+
return rules === null ? RULES_REMOVED_LINE : `stretch rules: ${rules.path} changed since the saved copy`;
|
|
3237
|
+
}
|
|
3238
|
+
function savedParts(saved) {
|
|
3239
|
+
const rulesAt = saved.lastIndexOf(RULES_SEPARATOR);
|
|
3240
|
+
const head = rulesAt === -1 ? saved : saved.slice(0, rulesAt);
|
|
3241
|
+
const rules = rulesAt === -1 ? "" : localText(saved.slice(rulesAt + RULES_SEPARATOR.length));
|
|
3242
|
+
const notesAt = head.lastIndexOf(NOTES_SEPARATOR);
|
|
3243
|
+
return {
|
|
3244
|
+
body: notesAt === -1 ? head : head.slice(0, notesAt),
|
|
3245
|
+
notes: notesAt === -1 ? "" : localText(head.slice(notesAt + NOTES_SEPARATOR.length)),
|
|
3246
|
+
rules
|
|
3247
|
+
};
|
|
3248
|
+
}
|
|
3249
|
+
function tailParts(saved, now) {
|
|
3250
|
+
if (saved === `${now}
|
|
3251
|
+
`)
|
|
3252
|
+
return { notes: "", rules: "" };
|
|
3253
|
+
if (!saved.startsWith(now))
|
|
3254
|
+
return null;
|
|
3255
|
+
const tail = saved.slice(now.length);
|
|
3256
|
+
if (tail.startsWith(RULES_SEPARATOR))
|
|
3257
|
+
return { notes: "", rules: localText(tail.slice(RULES_SEPARATOR.length)) };
|
|
3258
|
+
if (!tail.startsWith(NOTES_SEPARATOR))
|
|
3259
|
+
return null;
|
|
3260
|
+
const rest = tail.slice(NOTES_SEPARATOR.length);
|
|
3261
|
+
const rulesAt = rest.lastIndexOf(RULES_SEPARATOR);
|
|
3262
|
+
return rulesAt === -1 ? { notes: localText(rest), rules: "" } : {
|
|
3263
|
+
notes: localText(rest.slice(0, rulesAt)),
|
|
3264
|
+
rules: localText(rest.slice(rulesAt + RULES_SEPARATOR.length))
|
|
3265
|
+
};
|
|
3266
|
+
}
|
|
3267
|
+
function localChangeLine(old, now, options) {
|
|
3268
|
+
const clauses = [
|
|
3269
|
+
old.notes === now.notes ? null : notesChangeLine(options.notesPath),
|
|
3270
|
+
old.rules === now.rules ? null : rulesChangeLine(options.rules ?? null)
|
|
3271
|
+
].filter((clause) => clause !== null);
|
|
3272
|
+
return clauses.length === 0 ? null : clauses.join("; ");
|
|
3273
|
+
}
|
|
3274
|
+
function readSnapshotChange(options) {
|
|
3275
|
+
const { body, notes } = options;
|
|
3276
|
+
const rules = options.rules ?? null;
|
|
3277
|
+
const saved = readRefsBlock(options.saved).body;
|
|
3278
|
+
if (saved === snapshotText(body, notes, rules?.text ?? null)) {
|
|
3279
|
+
return { kind: "unchanged", bodyLine: null, notesLine: null };
|
|
3280
|
+
}
|
|
3281
|
+
const now = normalise(body);
|
|
3282
|
+
const local = { notes: localText(notes), rules: localText(rules?.text ?? null) };
|
|
3283
|
+
const tail = tailParts(saved, now);
|
|
3284
|
+
if (tail !== null) {
|
|
3285
|
+
const notesLine2 = localChangeLine(tail, local, options) ?? notesChangeLine(options.notesPath);
|
|
3286
|
+
return { kind: "notes", bodyLine: null, notesLine: notesLine2 };
|
|
3287
|
+
}
|
|
3288
|
+
const old = savedParts(saved);
|
|
3289
|
+
const bodyLine = bodyChangeLine(normalise(old.body), now);
|
|
3290
|
+
const notesLine = localChangeLine(old, local, options);
|
|
3291
|
+
return notesLine === null ? { kind: "body", bodyLine, notesLine: null } : { kind: "both", bodyLine, notesLine };
|
|
3292
|
+
}
|
|
3293
|
+
|
|
3138
3294
|
// packages/rafa-board/src/board/issue.ts
|
|
3139
3295
|
var PREFIX7 = "board issue";
|
|
3140
3296
|
var ISSUE_VIEW_FIELDS = "number,title,body,state,labels,author";
|
|
3141
3297
|
var SPEC_LABEL = "type:spec";
|
|
3142
3298
|
var ISSUE_REFUSAL_EXIT = 2;
|
|
3143
|
-
var LOCAL_NOTES_HEADING = "## Local notes";
|
|
3144
3299
|
function detailOf5(result, command) {
|
|
3145
3300
|
const written = result.stderr.trim() || result.stdout.trim();
|
|
3146
3301
|
return written === "" ? `${command} failed and wrote nothing` : `${command} failed: ${written}`;
|
|
@@ -3225,105 +3380,6 @@ function requireSpecIssue(issue) {
|
|
|
3225
3380
|
throw new CommandExit(ISSUE_REFUSAL_EXIT, missingSpecLabelMessage(issue.number));
|
|
3226
3381
|
}
|
|
3227
3382
|
}
|
|
3228
|
-
function normalise(text) {
|
|
3229
|
-
return text.replace(/\r\n?/gu, `
|
|
3230
|
-
`).replace(/\n+$/u, "");
|
|
3231
|
-
}
|
|
3232
|
-
function snapshotText(body, notes) {
|
|
3233
|
-
const local = notes === null ? "" : normalise(notes).trim();
|
|
3234
|
-
const sections2 = [
|
|
3235
|
-
normalise(body),
|
|
3236
|
-
local === "" ? "" : `${LOCAL_NOTES_HEADING}
|
|
3237
|
-
|
|
3238
|
-
${local}`
|
|
3239
|
-
].filter((section) => section !== "");
|
|
3240
|
-
return `${sections2.join(`
|
|
3241
|
-
|
|
3242
|
-
`)}
|
|
3243
|
-
`;
|
|
3244
|
-
}
|
|
3245
|
-
var NOTES_SEPARATOR = `
|
|
3246
|
-
|
|
3247
|
-
${LOCAL_NOTES_HEADING}
|
|
3248
|
-
|
|
3249
|
-
`;
|
|
3250
|
-
var HEADING2 = /^#{1,6}(?:[ \t]|$)/u;
|
|
3251
|
-
var FENCE3 = /^ {0,3}(?:`{3,}|~{3,})/u;
|
|
3252
|
-
function commonLines(before, after) {
|
|
3253
|
-
let previous = new Uint32Array(after.length + 1);
|
|
3254
|
-
for (const line of before) {
|
|
3255
|
-
const row = new Uint32Array(after.length + 1);
|
|
3256
|
-
after.forEach((other, index) => {
|
|
3257
|
-
row[index + 1] = line === other ? (previous[index] ?? 0) + 1 : Math.max(previous[index + 1] ?? 0, row[index] ?? 0);
|
|
3258
|
-
});
|
|
3259
|
-
previous = row;
|
|
3260
|
-
}
|
|
3261
|
-
return previous[after.length] ?? 0;
|
|
3262
|
-
}
|
|
3263
|
-
function headingName(line) {
|
|
3264
|
-
const text = line.replace(/^#+/u, "").replace(/[ \t]+#+[ \t]*$/u, "").trim();
|
|
3265
|
-
return text === "" ? line.trim() : text;
|
|
3266
|
-
}
|
|
3267
|
-
function headingSections(lines) {
|
|
3268
|
-
const sections2 = new Map;
|
|
3269
|
-
let fenced = false;
|
|
3270
|
-
let current = null;
|
|
3271
|
-
const close = () => {
|
|
3272
|
-
if (current === null)
|
|
3273
|
-
return;
|
|
3274
|
-
sections2.set(current.key, [...sections2.get(current.key) ?? [], current.lines.join(`
|
|
3275
|
-
`)]);
|
|
3276
|
-
};
|
|
3277
|
-
for (const line of lines) {
|
|
3278
|
-
if (FENCE3.test(line))
|
|
3279
|
-
fenced = !fenced;
|
|
3280
|
-
if (fenced || !HEADING2.test(line)) {
|
|
3281
|
-
current?.lines.push(line);
|
|
3282
|
-
continue;
|
|
3283
|
-
}
|
|
3284
|
-
close();
|
|
3285
|
-
current = { key: line.trim(), lines: [] };
|
|
3286
|
-
}
|
|
3287
|
-
close();
|
|
3288
|
-
return sections2;
|
|
3289
|
-
}
|
|
3290
|
-
function changedHeadings(before, after) {
|
|
3291
|
-
const old = headingSections(before);
|
|
3292
|
-
const now = headingSections(after);
|
|
3293
|
-
const keys = [...now.keys(), ...[...old.keys()].filter((key) => !now.has(key))];
|
|
3294
|
-
const changed = keys.filter((key) => JSON.stringify(old.get(key) ?? []) !== JSON.stringify(now.get(key) ?? []));
|
|
3295
|
-
return [...new Set(changed.map(headingName))];
|
|
3296
|
-
}
|
|
3297
|
-
function bodyChangeLine(before, after) {
|
|
3298
|
-
const old = before.split(`
|
|
3299
|
-
`);
|
|
3300
|
-
const now = after.split(`
|
|
3301
|
-
`);
|
|
3302
|
-
const common = commonLines(old, now);
|
|
3303
|
-
const headings = changedHeadings(old, now);
|
|
3304
|
-
const clause = headings.length === 0 ? "no heading changed" : `headings changed: ${headings.join(", ")}`;
|
|
3305
|
-
return `issue body: +${String(now.length - common)} -${String(old.length - common)} lines; ${clause}`;
|
|
3306
|
-
}
|
|
3307
|
-
function notesChangeLine(path2) {
|
|
3308
|
-
return `local notes: ${path2} changed since the saved copy`;
|
|
3309
|
-
}
|
|
3310
|
-
function readSnapshotChange(options) {
|
|
3311
|
-
const { body, notes, notesPath: path2 } = options;
|
|
3312
|
-
const saved = readRefsBlock(options.saved).body;
|
|
3313
|
-
if (saved === snapshotText(body, notes))
|
|
3314
|
-
return { kind: "unchanged", bodyLine: null, notesLine: null };
|
|
3315
|
-
const now = normalise(body);
|
|
3316
|
-
if (saved === `${now}
|
|
3317
|
-
` || saved.startsWith(`${now}${NOTES_SEPARATOR}`)) {
|
|
3318
|
-
return { kind: "notes", bodyLine: null, notesLine: notesChangeLine(path2) };
|
|
3319
|
-
}
|
|
3320
|
-
const split = saved.lastIndexOf(NOTES_SEPARATOR);
|
|
3321
|
-
const oldBody = split === -1 ? saved : saved.slice(0, split);
|
|
3322
|
-
const oldNotes = split === -1 ? "" : normalise(saved.slice(split + NOTES_SEPARATOR.length)).trim();
|
|
3323
|
-
const newNotes = notes === null ? "" : normalise(notes).trim();
|
|
3324
|
-
const bodyLine = bodyChangeLine(normalise(oldBody), now);
|
|
3325
|
-
return oldNotes === newNotes ? { kind: "body", bodyLine, notesLine: null } : { kind: "both", bodyLine, notesLine: notesChangeLine(path2) };
|
|
3326
|
-
}
|
|
3327
3383
|
function readIfFile(file, what) {
|
|
3328
3384
|
if (!existsSync2(file))
|
|
3329
3385
|
return null;
|
|
@@ -3347,6 +3403,7 @@ function notesCollisionMessage(path2, issue) {
|
|
|
3347
3403
|
}
|
|
3348
3404
|
function writeSpecSnapshot(options) {
|
|
3349
3405
|
const { repoRoot, specsDir, issue, refresh } = options;
|
|
3406
|
+
const rules = options.rules ?? null;
|
|
3350
3407
|
const path2 = specPath(specsDir, issue.number, issue.title);
|
|
3351
3408
|
const notes = notesPath(specsDir, issue.number);
|
|
3352
3409
|
if (path2 === notes) {
|
|
@@ -3355,16 +3412,17 @@ function writeSpecSnapshot(options) {
|
|
|
3355
3412
|
const local = readLocalNotes(repoRoot, specsDir, issue.number);
|
|
3356
3413
|
const absolute = resolve3(repoRoot, path2);
|
|
3357
3414
|
const existing = readIfFile(absolute, "the spec snapshot");
|
|
3358
|
-
const text = carryRefsBlock(existing, snapshotText(issue.body, local));
|
|
3415
|
+
const text = carryRefsBlock(existing, snapshotText(issue.body, local, rules?.text ?? null));
|
|
3359
3416
|
const written = {
|
|
3360
3417
|
path: path2,
|
|
3361
3418
|
absolute,
|
|
3362
3419
|
action: "created",
|
|
3363
3420
|
notes: local === null ? null : notes,
|
|
3421
|
+
rules: rules?.path ?? null,
|
|
3364
3422
|
previous: null,
|
|
3365
3423
|
text
|
|
3366
3424
|
};
|
|
3367
|
-
const action = rewriteAction(existing, issue.body, local, notes, refresh);
|
|
3425
|
+
const action = rewriteAction(existing, { body: issue.body, notes: local, notesPath: notes, rules }, refresh);
|
|
3368
3426
|
if (action === "unchanged")
|
|
3369
3427
|
return { ...written, action, text: existing ?? text };
|
|
3370
3428
|
if (action === null) {
|
|
@@ -3379,10 +3437,10 @@ function writeSpecSnapshot(options) {
|
|
|
3379
3437
|
}
|
|
3380
3438
|
return { ...written, action, previous };
|
|
3381
3439
|
}
|
|
3382
|
-
function rewriteAction(existing,
|
|
3440
|
+
function rewriteAction(existing, now, refresh) {
|
|
3383
3441
|
if (existing === null)
|
|
3384
3442
|
return "created";
|
|
3385
|
-
const { kind } = readSnapshotChange({ saved: existing
|
|
3443
|
+
const { kind } = readSnapshotChange({ ...now, saved: existing });
|
|
3386
3444
|
if (kind === "unchanged")
|
|
3387
3445
|
return "unchanged";
|
|
3388
3446
|
if (kind === "notes")
|
|
@@ -3847,6 +3905,7 @@ var NEVER_RETRIED = Object.freeze([
|
|
|
3847
3905
|
var RETRIED = Object.freeze([
|
|
3848
3906
|
/operation timed out|i\/o timeout|TLS handshake timeout/u,
|
|
3849
3907
|
/connection reset|\bEOF\b/u,
|
|
3908
|
+
/unexpected end of JSON input/u,
|
|
3850
3909
|
/\bHTTP 50[234]\b/u
|
|
3851
3910
|
]);
|
|
3852
3911
|
var UNKNOWN_REASON = "unknown error";
|
|
@@ -7903,6 +7962,9 @@ function refreshQuestion(issue, savedAt) {
|
|
|
7903
7962
|
function notesRebuiltLine(path2, issue, previous) {
|
|
7904
7963
|
return `local notes changed; rebuilt ${path2} from issue #${String(issue)} and the notes,` + ` the old copy is at ${previous}`;
|
|
7905
7964
|
}
|
|
7965
|
+
function stretchRulesLine(rules, path2) {
|
|
7966
|
+
return `stretch rules: appended ${rules} to ${path2}`;
|
|
7967
|
+
}
|
|
7906
7968
|
function readSavedCopy(absolute, path2) {
|
|
7907
7969
|
if (!existsSync5(absolute))
|
|
7908
7970
|
return null;
|
|
@@ -7922,8 +7984,22 @@ function printChange(change, output) {
|
|
|
7922
7984
|
}
|
|
7923
7985
|
}
|
|
7924
7986
|
async function settleSpecSnapshot(options) {
|
|
7987
|
+
const { output } = options;
|
|
7988
|
+
const rules = options.rules ?? null;
|
|
7989
|
+
const written4 = await settle2(options, rules);
|
|
7990
|
+
if (rules !== null && rules.text.trim() !== "")
|
|
7991
|
+
output.info(stretchRulesLine(rules.path, written4.path));
|
|
7992
|
+
return written4;
|
|
7993
|
+
}
|
|
7994
|
+
async function settle2(options, rules) {
|
|
7925
7995
|
const { repoRoot, specsDir, issue, refresh, output } = options;
|
|
7926
|
-
const write = (rewrite) => writeSpecSnapshot({
|
|
7996
|
+
const write = (rewrite) => writeSpecSnapshot({
|
|
7997
|
+
repoRoot,
|
|
7998
|
+
specsDir,
|
|
7999
|
+
issue,
|
|
8000
|
+
refresh: rewrite,
|
|
8001
|
+
...rules === null ? {} : { rules }
|
|
8002
|
+
});
|
|
7927
8003
|
const path2 = specPath(specsDir, issue.number, issue.title);
|
|
7928
8004
|
const notes = notesPath(specsDir, issue.number);
|
|
7929
8005
|
if (path2 === notes)
|
|
@@ -7935,7 +8011,8 @@ async function settleSpecSnapshot(options) {
|
|
|
7935
8011
|
saved: saved.text,
|
|
7936
8012
|
body: issue.body,
|
|
7937
8013
|
notes: readLocalNotes(repoRoot, specsDir, issue.number),
|
|
7938
|
-
notesPath: notes
|
|
8014
|
+
notesPath: notes,
|
|
8015
|
+
rules
|
|
7939
8016
|
});
|
|
7940
8017
|
if (change.kind === "unchanged")
|
|
7941
8018
|
return write(refresh);
|
|
@@ -8458,8 +8535,9 @@ function readSpecSourceFlags(args) {
|
|
|
8458
8535
|
function describeIssue(issue) {
|
|
8459
8536
|
return `issue #${String(issue.number)} "${issue.title}"`;
|
|
8460
8537
|
}
|
|
8461
|
-
function dryRunLine(what) {
|
|
8462
|
-
|
|
8538
|
+
function dryRunLine(what, rules = null) {
|
|
8539
|
+
const appended = rules === null ? "" : `, appending the stretch rules of ${rules}`;
|
|
8540
|
+
return `\uD83D\uDD0E ${DRY_RUN_FLAG}: would plan from ${what}${appended}. Nothing was written.`;
|
|
8463
8541
|
}
|
|
8464
8542
|
function requireRoadmapSeams(seams) {
|
|
8465
8543
|
if (seams === undefined) {
|
|
@@ -8467,6 +8545,9 @@ function requireRoadmapSeams(seams) {
|
|
|
8467
8545
|
}
|
|
8468
8546
|
return seams;
|
|
8469
8547
|
}
|
|
8548
|
+
function appendedRules(rules) {
|
|
8549
|
+
return rules === null || rules.text.trim() === "" ? null : rules;
|
|
8550
|
+
}
|
|
8470
8551
|
function stopped(reason) {
|
|
8471
8552
|
return Object.freeze({ outcome: "stopped", reason });
|
|
8472
8553
|
}
|
|
@@ -8529,8 +8610,9 @@ async function resolveSpecSource(options) {
|
|
|
8529
8610
|
const read = await issues(number);
|
|
8530
8611
|
requireSpecIssue(read);
|
|
8531
8612
|
await options.inspect?.(read);
|
|
8613
|
+
const rules = options.rules ?? null;
|
|
8532
8614
|
if (dryRun) {
|
|
8533
|
-
output.info(dryRunLine(describeIssue(read)));
|
|
8615
|
+
output.info(dryRunLine(describeIssue(read), appendedRules(rules)?.path ?? null));
|
|
8534
8616
|
return stopped("dry-run");
|
|
8535
8617
|
}
|
|
8536
8618
|
const snapshot = await settleSpecSnapshot({
|
|
@@ -8539,7 +8621,8 @@ async function resolveSpecSource(options) {
|
|
|
8539
8621
|
issue: read,
|
|
8540
8622
|
refresh,
|
|
8541
8623
|
offerRefresh: options.offerRefresh ?? null,
|
|
8542
|
-
output
|
|
8624
|
+
output,
|
|
8625
|
+
...rules === null ? {} : { rules }
|
|
8543
8626
|
});
|
|
8544
8627
|
return Object.freeze({
|
|
8545
8628
|
outcome: "spec",
|
|
@@ -8642,7 +8725,8 @@ async function resolvePlanSpec(options) {
|
|
|
8642
8725
|
...options.passOver === undefined ? {} : { passOver: options.passOver },
|
|
8643
8726
|
...options.branchTemplate === undefined ? {} : { branchTemplate: options.branchTemplate }
|
|
8644
8727
|
},
|
|
8645
|
-
output
|
|
8728
|
+
output,
|
|
8729
|
+
...options.rules === undefined || options.rules === null ? {} : { rules: options.rules }
|
|
8646
8730
|
});
|
|
8647
8731
|
if (resolution.outcome === "stopped") {
|
|
8648
8732
|
return Object.freeze({ outcome: "stopped", reason: resolution.reason });
|
|
@@ -10349,8 +10433,8 @@ function issuesOf(value, spec) {
|
|
|
10349
10433
|
const reading2 = spec.read(at.raw, { label: spec.key, key: spec.key });
|
|
10350
10434
|
return reading2.problems.map((message) => ({ message, path: path2 }));
|
|
10351
10435
|
}
|
|
10352
|
-
function schemaOf(
|
|
10353
|
-
const specs = Object.values(
|
|
10436
|
+
function schemaOf(section2) {
|
|
10437
|
+
const specs = Object.values(section2.settings).filter((spec) => spec !== undefined);
|
|
10354
10438
|
const validate2 = (value) => {
|
|
10355
10439
|
const issues = specs.flatMap((spec) => issuesOf(value, spec));
|
|
10356
10440
|
return issues.length === 0 ? { value } : { issues };
|
|
@@ -10360,7 +10444,7 @@ function schemaOf(section) {
|
|
|
10360
10444
|
});
|
|
10361
10445
|
}
|
|
10362
10446
|
function schemaSectionsOf(sections2) {
|
|
10363
|
-
return Object.freeze(sections2.map((
|
|
10447
|
+
return Object.freeze(sections2.map((section2) => Object.freeze([Object.freeze([]), schemaOf(section2)])));
|
|
10364
10448
|
}
|
|
10365
10449
|
|
|
10366
10450
|
// packages/rafa/src/core/config/config-load.ts
|
|
@@ -10527,8 +10611,8 @@ async function readScope(place) {
|
|
|
10527
10611
|
};
|
|
10528
10612
|
}
|
|
10529
10613
|
function duplicatesLevelIn(mapping) {
|
|
10530
|
-
const
|
|
10531
|
-
const raw = Object.hasOwn(mapping, "merge.duplicates") ? mapping["merge.duplicates"] : isMapping(
|
|
10614
|
+
const section2 = Object.hasOwn(mapping, "merge") ? mapping.merge : undefined;
|
|
10615
|
+
const raw = Object.hasOwn(mapping, "merge.duplicates") ? mapping["merge.duplicates"] : isMapping(section2) && Object.hasOwn(section2, "duplicates") ? section2.duplicates : undefined;
|
|
10532
10616
|
return DUPLICATE_LEVELS.find((level) => level === raw);
|
|
10533
10617
|
}
|
|
10534
10618
|
function duplicateWarnings(readings) {
|
|
@@ -207,6 +207,7 @@ var RAFA_CODES = defineErrorCodes([
|
|
|
207
207
|
{ code: "cli:unknown-module", description: "a module command names a module that is not mounted", hint: "run rafa module list for the modules that are mounted", level: "error", since: SEED, legacy: "unknown_module" },
|
|
208
208
|
{ code: "cli:unexpected-version", description: "--version is typed beside a command, where it is read alone", hint: "run rafa --version alone, with no command beside it", level: "error", since: SEED, legacy: "unexpected_version" },
|
|
209
209
|
{ code: "cli:invalid-spec", description: "a command declares a shape the dispatcher refuses", hint: "fix the command declaration the message names", level: "error", since: SEED, legacy: "invalid_spec" },
|
|
210
|
+
{ code: "cli:unknown-flag", description: "a command line types a flag the command does not declare", hint: "run rafa <command> --help for its flags", level: "error", since: "#1267", legacy: "unknown_flag" },
|
|
210
211
|
{ code: "cli:no-project", description: "a command that needs a project ran outside one", hint: "run it inside a project, or run rafa init", level: "error", since: SEED, legacy: "no_project" },
|
|
211
212
|
{ code: "cli:command-exit", description: "a command refused and set its own exit code", hint: "read the message above it", level: "error", since: SEED, legacy: "command_exit" },
|
|
212
213
|
{ code: "cli:command-error", description: "a command threw an error it did not handle", hint: "file a bug with the stack", level: "error", since: SEED, legacy: "command_error" },
|