@open-tomato/rafa 0.50.0 → 0.52.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/bugs/record.d.ts +8 -3
- package/dist/bundled/agents/doc-updater.md +4 -0
- package/dist/bundled/agents/loop-implementer.md +4 -0
- package/dist/bundled/agents/qa-bug-reporter.md +6 -3
- package/dist/bundled/operators/agents/rafa-stretch-engineer.md +10 -2
- package/dist/bundled/operators/skills/rafa-stretch-pit-stop/SKILL.md +37 -11
- package/dist/bundled/operators/skills/rafa-stretch-sweep/SKILL.md +10 -3
- package/dist/bundled/skills/dev-planner/SKILL.md +20 -5
- package/dist/cli.js +2073 -1197
- package/dist/config/index.js +2 -2
- package/dist/effort/store/index.js +2 -2
- package/dist/{index-7rg3jbsz.js → index-91cag9fr.js} +1 -1
- package/dist/{index-w5qbpdtp.js → index-amevawhe.js} +1 -1
- package/dist/{index-kcbs6fp9.js → index-hyp1sraj.js} +1 -1
- package/dist/{index-g91ys6kw.js → index-jjxnyqvy.js} +1 -0
- package/dist/{index-q1tkqxnh.js → index-mbxgc1zv.js} +203 -120
- package/dist/{index-ajv88fkm.js → index-n2r3wf2z.js} +31 -2
- package/dist/{index-zsak0jy6.js → index-nqaqh4zz.js} +1 -1
- package/dist/index.js +349 -99
- package/dist/plan/index.js +2 -2
- package/dist/plan-prompt.md +1 -0
- package/dist/{ready-stwsr9ws.js → ready-3ccr65a2.js} +4 -4
- package/dist/report/parse.d.ts +3 -1
- package/package.json +5 -4
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-hyp1sraj.js";
|
|
17
17
|
import {
|
|
18
18
|
TRUSTED_PERMISSIONS
|
|
19
|
-
} from "../../index-
|
|
19
|
+
} from "../../index-91cag9fr.js";
|
|
20
20
|
import"../../index-2a7nb3an.js";
|
|
21
21
|
import"../../index-m672ptpg.js";
|
|
22
22
|
import {
|
|
@@ -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" },
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
parsePlan,
|
|
8
8
|
readRafaBlocks,
|
|
9
9
|
rejectedPath
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-n2r3wf2z.js";
|
|
11
11
|
import {
|
|
12
12
|
CORE_ADAPTER_REGISTRY,
|
|
13
13
|
CommandExit,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
isRecord,
|
|
21
21
|
normalizeRemote,
|
|
22
22
|
setActiveStoreSettings
|
|
23
|
-
} from "./index-
|
|
23
|
+
} from "./index-91cag9fr.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")
|
|
@@ -7904,6 +7962,9 @@ function refreshQuestion(issue, savedAt) {
|
|
|
7904
7962
|
function notesRebuiltLine(path2, issue, previous) {
|
|
7905
7963
|
return `local notes changed; rebuilt ${path2} from issue #${String(issue)} and the notes,` + ` the old copy is at ${previous}`;
|
|
7906
7964
|
}
|
|
7965
|
+
function stretchRulesLine(rules, path2) {
|
|
7966
|
+
return `stretch rules: appended ${rules} to ${path2}`;
|
|
7967
|
+
}
|
|
7907
7968
|
function readSavedCopy(absolute, path2) {
|
|
7908
7969
|
if (!existsSync5(absolute))
|
|
7909
7970
|
return null;
|
|
@@ -7923,8 +7984,22 @@ function printChange(change, output) {
|
|
|
7923
7984
|
}
|
|
7924
7985
|
}
|
|
7925
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) {
|
|
7926
7995
|
const { repoRoot, specsDir, issue, refresh, output } = options;
|
|
7927
|
-
const write = (rewrite) => writeSpecSnapshot({
|
|
7996
|
+
const write = (rewrite) => writeSpecSnapshot({
|
|
7997
|
+
repoRoot,
|
|
7998
|
+
specsDir,
|
|
7999
|
+
issue,
|
|
8000
|
+
refresh: rewrite,
|
|
8001
|
+
...rules === null ? {} : { rules }
|
|
8002
|
+
});
|
|
7928
8003
|
const path2 = specPath(specsDir, issue.number, issue.title);
|
|
7929
8004
|
const notes = notesPath(specsDir, issue.number);
|
|
7930
8005
|
if (path2 === notes)
|
|
@@ -7936,7 +8011,8 @@ async function settleSpecSnapshot(options) {
|
|
|
7936
8011
|
saved: saved.text,
|
|
7937
8012
|
body: issue.body,
|
|
7938
8013
|
notes: readLocalNotes(repoRoot, specsDir, issue.number),
|
|
7939
|
-
notesPath: notes
|
|
8014
|
+
notesPath: notes,
|
|
8015
|
+
rules
|
|
7940
8016
|
});
|
|
7941
8017
|
if (change.kind === "unchanged")
|
|
7942
8018
|
return write(refresh);
|
|
@@ -8459,8 +8535,9 @@ function readSpecSourceFlags(args) {
|
|
|
8459
8535
|
function describeIssue(issue) {
|
|
8460
8536
|
return `issue #${String(issue.number)} "${issue.title}"`;
|
|
8461
8537
|
}
|
|
8462
|
-
function dryRunLine(what) {
|
|
8463
|
-
|
|
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.`;
|
|
8464
8541
|
}
|
|
8465
8542
|
function requireRoadmapSeams(seams) {
|
|
8466
8543
|
if (seams === undefined) {
|
|
@@ -8468,6 +8545,9 @@ function requireRoadmapSeams(seams) {
|
|
|
8468
8545
|
}
|
|
8469
8546
|
return seams;
|
|
8470
8547
|
}
|
|
8548
|
+
function appendedRules(rules) {
|
|
8549
|
+
return rules === null || rules.text.trim() === "" ? null : rules;
|
|
8550
|
+
}
|
|
8471
8551
|
function stopped(reason) {
|
|
8472
8552
|
return Object.freeze({ outcome: "stopped", reason });
|
|
8473
8553
|
}
|
|
@@ -8530,8 +8610,9 @@ async function resolveSpecSource(options) {
|
|
|
8530
8610
|
const read = await issues(number);
|
|
8531
8611
|
requireSpecIssue(read);
|
|
8532
8612
|
await options.inspect?.(read);
|
|
8613
|
+
const rules = options.rules ?? null;
|
|
8533
8614
|
if (dryRun) {
|
|
8534
|
-
output.info(dryRunLine(describeIssue(read)));
|
|
8615
|
+
output.info(dryRunLine(describeIssue(read), appendedRules(rules)?.path ?? null));
|
|
8535
8616
|
return stopped("dry-run");
|
|
8536
8617
|
}
|
|
8537
8618
|
const snapshot = await settleSpecSnapshot({
|
|
@@ -8540,7 +8621,8 @@ async function resolveSpecSource(options) {
|
|
|
8540
8621
|
issue: read,
|
|
8541
8622
|
refresh,
|
|
8542
8623
|
offerRefresh: options.offerRefresh ?? null,
|
|
8543
|
-
output
|
|
8624
|
+
output,
|
|
8625
|
+
...rules === null ? {} : { rules }
|
|
8544
8626
|
});
|
|
8545
8627
|
return Object.freeze({
|
|
8546
8628
|
outcome: "spec",
|
|
@@ -8643,7 +8725,8 @@ async function resolvePlanSpec(options) {
|
|
|
8643
8725
|
...options.passOver === undefined ? {} : { passOver: options.passOver },
|
|
8644
8726
|
...options.branchTemplate === undefined ? {} : { branchTemplate: options.branchTemplate }
|
|
8645
8727
|
},
|
|
8646
|
-
output
|
|
8728
|
+
output,
|
|
8729
|
+
...options.rules === undefined || options.rules === null ? {} : { rules: options.rules }
|
|
8647
8730
|
});
|
|
8648
8731
|
if (resolution.outcome === "stopped") {
|
|
8649
8732
|
return Object.freeze({ outcome: "stopped", reason: resolution.reason });
|
|
@@ -8888,7 +8971,7 @@ var ISSUE_CREATE_DECLARATION = Object.freeze({
|
|
|
8888
8971
|
},
|
|
8889
8972
|
{
|
|
8890
8973
|
name: "reproduce",
|
|
8891
|
-
description: "A bug: the
|
|
8974
|
+
description: "A bug: one command run from the checkout root whose output or exit code shows it; the condition only when no command can. Never unknown.",
|
|
8892
8975
|
type: "string"
|
|
8893
8976
|
},
|
|
8894
8977
|
{
|
|
@@ -10350,8 +10433,8 @@ function issuesOf(value, spec) {
|
|
|
10350
10433
|
const reading2 = spec.read(at.raw, { label: spec.key, key: spec.key });
|
|
10351
10434
|
return reading2.problems.map((message) => ({ message, path: path2 }));
|
|
10352
10435
|
}
|
|
10353
|
-
function schemaOf(
|
|
10354
|
-
const specs = Object.values(
|
|
10436
|
+
function schemaOf(section2) {
|
|
10437
|
+
const specs = Object.values(section2.settings).filter((spec) => spec !== undefined);
|
|
10355
10438
|
const validate2 = (value) => {
|
|
10356
10439
|
const issues = specs.flatMap((spec) => issuesOf(value, spec));
|
|
10357
10440
|
return issues.length === 0 ? { value } : { issues };
|
|
@@ -10361,7 +10444,7 @@ function schemaOf(section) {
|
|
|
10361
10444
|
});
|
|
10362
10445
|
}
|
|
10363
10446
|
function schemaSectionsOf(sections2) {
|
|
10364
|
-
return Object.freeze(sections2.map((
|
|
10447
|
+
return Object.freeze(sections2.map((section2) => Object.freeze([Object.freeze([]), schemaOf(section2)])));
|
|
10365
10448
|
}
|
|
10366
10449
|
|
|
10367
10450
|
// packages/rafa/src/core/config/config-load.ts
|
|
@@ -10528,8 +10611,8 @@ async function readScope(place) {
|
|
|
10528
10611
|
};
|
|
10529
10612
|
}
|
|
10530
10613
|
function duplicatesLevelIn(mapping) {
|
|
10531
|
-
const
|
|
10532
|
-
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;
|
|
10533
10616
|
return DUPLICATE_LEVELS.find((level) => level === raw);
|
|
10534
10617
|
}
|
|
10535
10618
|
function duplicateWarnings(readings) {
|
|
@@ -167,7 +167,7 @@ function splitBlockerComment(taskText) {
|
|
|
167
167
|
|
|
168
168
|
// packages/rafa/src/core/plan/parse.ts
|
|
169
169
|
var PLAN_BLOCK_KINDS = ["plan", "context", "stage-context"];
|
|
170
|
-
var PLAN_HEADER_FIELDS = ["stub", "issue", "spec", "release"];
|
|
170
|
+
var PLAN_HEADER_FIELDS = ["stub", "issue", "spec", "release", "closes"];
|
|
171
171
|
var PLAN_RELEASE_LEVELS = ["patch", "minor", "major", "none"];
|
|
172
172
|
var TASK_LINES = [
|
|
173
173
|
["unchecked", /^- \[ \] (.+)/],
|
|
@@ -205,7 +205,7 @@ function planIssue(reason, line, text) {
|
|
|
205
205
|
return { reason, line, text };
|
|
206
206
|
}
|
|
207
207
|
function emptyHeader() {
|
|
208
|
-
return { stub: null, issue: null, spec: null, release: null, extras: [] };
|
|
208
|
+
return { stub: null, issue: null, spec: null, release: null, closes: [], extras: [] };
|
|
209
209
|
}
|
|
210
210
|
function readTaskLine(line) {
|
|
211
211
|
for (const [status, pattern] of TASK_LINES) {
|
|
@@ -324,11 +324,30 @@ function usableField(field, value) {
|
|
|
324
324
|
return null;
|
|
325
325
|
return value;
|
|
326
326
|
}
|
|
327
|
+
function isIssueNumber(entry) {
|
|
328
|
+
return typeof entry === "number" && Number.isSafeInteger(entry) && entry > 0;
|
|
329
|
+
}
|
|
330
|
+
function usableClosesField(value) {
|
|
331
|
+
if (!Array.isArray(value))
|
|
332
|
+
return null;
|
|
333
|
+
const entries = value;
|
|
334
|
+
return entries.every(isIssueNumber) ? [...entries] : null;
|
|
335
|
+
}
|
|
336
|
+
function closesText(subject, value) {
|
|
337
|
+
const wanted = "a list of whole positive issue numbers, such as [12, 13]";
|
|
338
|
+
if (!Array.isArray(value))
|
|
339
|
+
return `${subject} is ${describeValue(value)}, not ${wanted}`;
|
|
340
|
+
const entries = value;
|
|
341
|
+
const refused = entries.find((entry) => !isIssueNumber(entry));
|
|
342
|
+
return `${subject} holds ${describeValue(refused)}, so the whole list is unread; write ${wanted}`;
|
|
343
|
+
}
|
|
327
344
|
function unusableText(field, value) {
|
|
328
345
|
const subject = `rafa:plan ${field}`;
|
|
329
346
|
if (value === null) {
|
|
330
347
|
return `${subject} is empty; a value opening with # after a space is a YAML comment unless quoted`;
|
|
331
348
|
}
|
|
349
|
+
if (field === "closes")
|
|
350
|
+
return closesText(subject, value);
|
|
332
351
|
if (field === "release") {
|
|
333
352
|
return `${subject} is ${describeValue(value)}, not one of ${PLAN_RELEASE_LEVELS.join(", ")}`;
|
|
334
353
|
}
|
|
@@ -349,11 +368,20 @@ function readFields(document, line) {
|
|
|
349
368
|
const values = new Map;
|
|
350
369
|
const extras = [];
|
|
351
370
|
const issues = [];
|
|
371
|
+
let closes2 = [];
|
|
352
372
|
for (const [key, value] of Object.entries(document)) {
|
|
353
373
|
if (!isHeaderField(key)) {
|
|
354
374
|
extras.push({ key, value });
|
|
355
375
|
continue;
|
|
356
376
|
}
|
|
377
|
+
if (key === "closes") {
|
|
378
|
+
const list = usableClosesField(value);
|
|
379
|
+
if (list === null)
|
|
380
|
+
issues.push(planIssue("unusable-field", line, unusableText(key, value)));
|
|
381
|
+
else
|
|
382
|
+
closes2 = list;
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
357
385
|
const usable = usableField(key, value);
|
|
358
386
|
if (usable === null)
|
|
359
387
|
issues.push(planIssue("unusable-field", line, unusableText(key, value)));
|
|
@@ -365,6 +393,7 @@ function readFields(document, line) {
|
|
|
365
393
|
issue: values.get("issue") ?? null,
|
|
366
394
|
spec: values.get("spec") ?? null,
|
|
367
395
|
release: releaseOf(values),
|
|
396
|
+
closes: closes2,
|
|
368
397
|
extras
|
|
369
398
|
};
|
|
370
399
|
return { header, issues };
|