@open-tomato/rafa 0.47.0 → 0.49.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/README.md +5 -2
- package/dist/bugs/places.d.ts +1 -1
- package/dist/bundled/skills/dev-planner/SKILL.md +1 -1
- package/dist/cli.js +58774 -58722
- package/dist/config/index.js +4 -5
- package/dist/config/shape.d.ts +13 -11
- package/dist/config-schema-board-project.d.ts +3 -3
- package/dist/config-schema-checks.d.ts +3 -3
- package/dist/config-schema-hub.d.ts +3 -3
- package/dist/config-schema-issues.d.ts +4 -4
- package/dist/config-schema-loop-continue.d.ts +3 -3
- package/dist/config-schema-loop-retries.d.ts +4 -4
- package/dist/config-schema-release.d.ts +13 -13
- package/dist/config-schema-tests.d.ts +3 -3
- package/dist/config-schema-triage.d.ts +3 -3
- package/dist/config-schema-wrap-up.d.ts +4 -4
- package/dist/core/command/global-flags.d.ts +25 -0
- package/dist/core/command/index.d.ts +31 -25
- package/dist/core/command/registry-types.d.ts +4 -4
- package/dist/core/command/shared-flags.d.ts +6 -6
- package/dist/core/command/types.d.ts +3 -2
- package/dist/core/config/branch-template.d.ts +2 -0
- package/dist/core/config/config-items.d.ts +1 -1
- package/dist/core/config/config-schema.d.ts +6 -0
- package/dist/core/config/config-sections.d.ts +15 -14
- package/dist/core/config/config.d.ts +1 -1
- package/dist/core/config/core-section.d.ts +1 -1
- package/dist/core/config/default-routing.d.ts +1 -1
- package/dist/core/config/index.d.ts +4 -4
- package/dist/core/config/merge-method.d.ts +4 -4
- package/dist/core/config/sections.d.ts +6 -3
- package/dist/core/git/gh-runner.d.ts +1 -1
- package/dist/core/git/git.d.ts +34 -0
- package/dist/core/git/index.d.ts +13 -8
- package/dist/core/loop/claude.d.ts +11 -5
- package/dist/core/loop/index.d.ts +3 -2
- package/dist/core/loop/sessions.d.ts +1 -1
- package/dist/core/loop/suite-failure.d.ts +8 -6
- package/dist/core/output/active.d.ts +1 -1
- package/dist/core/runtime/identity.d.ts +13 -0
- package/dist/core/runtime/index.d.ts +12 -6
- package/dist/effort/store/check-rows.d.ts +1 -1
- package/dist/effort/store/commit-stats.d.ts +1 -1
- package/dist/effort/store/index.js +8 -9
- package/dist/effort/store/merge-commit-gaps.d.ts +1 -1
- package/dist/effort/store/plan-stubs.d.ts +1 -1
- package/dist/effort/store/session-row-types.d.ts +2 -2
- package/dist/{index-f1y86zbb.js → index-2a7nb3an.js} +31 -31
- package/dist/index-ajv88fkm.js +448 -0
- package/dist/{index-r5q2pdky.js → index-fpgmdmww.js} +4 -1
- package/dist/{index-pzpb1rf7.js → index-g91ys6kw.js} +97 -1
- package/dist/{index-7dgc5g1t.js → index-j154qpbj.js} +8696 -11193
- package/dist/{index-cbqvgda6.js → index-m672ptpg.js} +3 -1
- package/dist/index-thqpre1b.js +670 -0
- package/dist/{index-eay1bd2w.js → index-vfny3ryr.js} +1090 -652
- package/dist/{index-nwzx41g1.js → index-w5qbpdtp.js} +416 -843
- package/dist/{index-n3e31fmw.js → index-zsak0jy6.js} +172 -254
- package/dist/index.js +24867 -18958
- package/dist/learning/index.js +221 -12
- package/dist/plan/index.js +11 -10
- package/dist/ports/index.d.ts +6 -6
- package/dist/ports/learning.d.ts +5 -4
- package/dist/ports/spec-review.d.ts +1 -1
- package/dist/ready-mh5wdzq5.js +241 -0
- package/dist/release-templates/release-bot-fragment.yml +6 -6
- package/dist/release-templates/release-publish.yml +8 -8
- package/dist/release-templates/release-settle.yml +8 -7
- package/dist/release-templates/release-tag.yml +8 -7
- package/package.json +32 -2
- package/dist/index-38ktnyvz.js +0 -223
- package/dist/index-3mwsr6wg.js +0 -1070
- package/dist/index-z1w83f81.js +0 -4
- package/dist/ready-6p40c3gw.js +0 -2007
package/dist/learning/index.js
CHANGED
|
@@ -1,16 +1,225 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
// packages/rafa-inventory/src/learning/bless.ts
|
|
3
|
+
import { createHash } from "crypto";
|
|
4
|
+
var HUNDREDTHS = 100;
|
|
5
|
+
function hundredths(confidence) {
|
|
6
|
+
return Math.round(confidence * HUNDREDTHS);
|
|
7
|
+
}
|
|
8
|
+
function compareText(left, right) {
|
|
9
|
+
if (left < right) {
|
|
10
|
+
return -1;
|
|
11
|
+
}
|
|
12
|
+
if (left > right) {
|
|
13
|
+
return 1;
|
|
14
|
+
}
|
|
15
|
+
return 0;
|
|
16
|
+
}
|
|
17
|
+
function byTrust(left, right) {
|
|
18
|
+
return hundredths(right.confidence) - hundredths(left.confidence) || right.usage_count - left.usage_count || compareText(left.id, right.id);
|
|
19
|
+
}
|
|
20
|
+
function blessedRecords(held, minConfidence) {
|
|
21
|
+
const floor = hundredths(minConfidence);
|
|
22
|
+
return held.filter((each) => each.status === "active" && each.promoted_to === undefined && hundredths(each.confidence) >= floor).sort(byTrust);
|
|
23
|
+
}
|
|
24
|
+
function versionOf(instincts) {
|
|
25
|
+
return createHash("sha256").update(JSON.stringify(instincts)).digest("hex");
|
|
26
|
+
}
|
|
27
|
+
function bless(held, options) {
|
|
28
|
+
const instincts = blessedRecords(held, options.minConfidence);
|
|
29
|
+
return { version: versionOf(instincts), instincts };
|
|
30
|
+
}
|
|
31
|
+
function promotable(held, options) {
|
|
32
|
+
return blessedRecords(held, options.minConfidence).filter((each) => each.usage_count >= options.after);
|
|
33
|
+
}
|
|
34
|
+
// packages/rafa-inventory/src/learning/identity.ts
|
|
35
|
+
import { createHash as createHash2 } from "crypto";
|
|
36
|
+
var GAP = 0.1;
|
|
37
|
+
var SOURCE_STEP = 0.05;
|
|
38
|
+
var CONFIDENCE_MIN = 0.3;
|
|
39
|
+
var CONFIDENCE_MAX = 0.9;
|
|
40
|
+
var WHITESPACE_RUN = /\s+/g;
|
|
41
|
+
function actionHash(action) {
|
|
42
|
+
return createHash2("sha256").update(action.trim().toLowerCase()).digest("hex");
|
|
43
|
+
}
|
|
44
|
+
function triggerKey(trigger) {
|
|
45
|
+
return trigger.trim().toLowerCase().replace(WHITESPACE_RUN, " ");
|
|
46
|
+
}
|
|
47
|
+
// packages/rafa-inventory/src/learning/merge.ts
|
|
48
|
+
var HUNDREDTHS2 = 100;
|
|
49
|
+
var GAP_H = Math.round(GAP * HUNDREDTHS2);
|
|
50
|
+
var STEP_H = Math.round(SOURCE_STEP * HUNDREDTHS2);
|
|
51
|
+
var MIN_H = Math.round(CONFIDENCE_MIN * HUNDREDTHS2);
|
|
52
|
+
var MAX_H = Math.round(CONFIDENCE_MAX * HUNDREDTHS2);
|
|
53
|
+
function hundredths2(confidence) {
|
|
54
|
+
return Math.round(confidence * HUNDREDTHS2);
|
|
55
|
+
}
|
|
56
|
+
function compareText2(left, right) {
|
|
57
|
+
if (left < right) {
|
|
58
|
+
return -1;
|
|
59
|
+
}
|
|
60
|
+
if (left > right) {
|
|
61
|
+
return 1;
|
|
62
|
+
}
|
|
63
|
+
return 0;
|
|
64
|
+
}
|
|
65
|
+
function byAge(left, right) {
|
|
66
|
+
return compareText2(left.created_at, right.created_at) || compareText2(left.id, right.id);
|
|
67
|
+
}
|
|
68
|
+
function byConfidence(left, right) {
|
|
69
|
+
return hundredths2(right.confidence) - hundredths2(left.confidence) || compareText2(left.id, right.id);
|
|
70
|
+
}
|
|
71
|
+
function sourcesOf(record) {
|
|
72
|
+
return record.sources !== undefined && record.sources.length > 0 ? [...new Set(record.sources)] : [record.id];
|
|
73
|
+
}
|
|
74
|
+
function withSource(record, sourceId) {
|
|
75
|
+
const sources = [...new Set([...record.sources ?? [], sourceId])].sort();
|
|
76
|
+
return { ...record, sources, usage_count: sources.length };
|
|
77
|
+
}
|
|
78
|
+
function firstOptional(ordered, key) {
|
|
79
|
+
const found = ordered.find((record) => record[key] !== undefined);
|
|
80
|
+
return found === undefined ? {} : { [key]: found[key] };
|
|
81
|
+
}
|
|
82
|
+
function collapse(group) {
|
|
83
|
+
const ordered = [...[...group.held].sort(byAge), ...[...group.incoming].sort(byAge)];
|
|
84
|
+
if (ordered.length === 1) {
|
|
85
|
+
return ordered[0];
|
|
86
|
+
}
|
|
87
|
+
const seen = new Set;
|
|
88
|
+
let weighted = 0;
|
|
89
|
+
for (const member of ordered) {
|
|
90
|
+
const own = sourcesOf(member);
|
|
91
|
+
const fresh = own.filter((source) => !seen.has(source));
|
|
92
|
+
const base = hundredths2(member.confidence) - STEP_H * (own.length - 1);
|
|
93
|
+
weighted += base * fresh.length;
|
|
94
|
+
for (const source of fresh) {
|
|
95
|
+
seen.add(source);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const sources = [...seen].sort();
|
|
99
|
+
const stepped = Math.round(weighted / sources.length + STEP_H * (sources.length - 1));
|
|
100
|
+
const confidence = Math.min(MAX_H, Math.max(MIN_H, stepped)) / HUNDREDTHS2;
|
|
101
|
+
const byAgeAll = [...ordered].sort(byAge);
|
|
102
|
+
const lead = byAgeAll[0];
|
|
103
|
+
const rest = {};
|
|
104
|
+
for (const [key, value] of Object.entries(lead)) {
|
|
105
|
+
if (key !== "artifact" && key !== "promoted_to") {
|
|
106
|
+
Object.assign(rest, { [key]: value });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
...rest,
|
|
111
|
+
...firstOptional(byAgeAll, "artifact"),
|
|
112
|
+
...firstOptional(byAgeAll, "promoted_to"),
|
|
113
|
+
confidence,
|
|
114
|
+
usage_count: sources.length,
|
|
115
|
+
sources
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function sameButStamp(left, right) {
|
|
119
|
+
const keys = new Set([...Object.keys(left), ...Object.keys(right)]);
|
|
120
|
+
keys.delete("updated_at");
|
|
121
|
+
return [...keys].every((key) => {
|
|
122
|
+
const field = key;
|
|
123
|
+
return JSON.stringify(left[field]) === JSON.stringify(right[field]);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
function stamp(record, held, now) {
|
|
127
|
+
const before = held.find((candidate) => candidate.id === record.id);
|
|
128
|
+
if (before !== undefined && sameButStamp(before, record)) {
|
|
129
|
+
return before;
|
|
130
|
+
}
|
|
131
|
+
return { ...record, updated_at: now };
|
|
132
|
+
}
|
|
133
|
+
function withStatus(record, status) {
|
|
134
|
+
return record.status === status ? record : { ...record, status };
|
|
135
|
+
}
|
|
136
|
+
function groupByAction(held, incoming) {
|
|
137
|
+
const groups = new Map;
|
|
138
|
+
const groupOf = (hash) => {
|
|
139
|
+
const found = groups.get(hash);
|
|
140
|
+
if (found !== undefined) {
|
|
141
|
+
return found;
|
|
142
|
+
}
|
|
143
|
+
const made = { held: [], incoming: [] };
|
|
144
|
+
groups.set(hash, made);
|
|
145
|
+
return made;
|
|
146
|
+
};
|
|
147
|
+
for (const record of held) {
|
|
148
|
+
groupOf(record.action_hash).held.push(record);
|
|
149
|
+
}
|
|
150
|
+
for (const record of incoming) {
|
|
151
|
+
groupOf(record.action_hash).incoming.push(record);
|
|
152
|
+
}
|
|
153
|
+
return groups;
|
|
154
|
+
}
|
|
155
|
+
function settleOne(hash, group, held, now) {
|
|
156
|
+
if (group.held.length === 0 && group.incoming.length === 1) {
|
|
157
|
+
return {
|
|
158
|
+
produced: [group.incoming[0]],
|
|
159
|
+
discarded: [],
|
|
160
|
+
rules: new Map([[hash, "new-trigger"]])
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
const record = stamp(withStatus(collapse(group), "active"), held, now);
|
|
164
|
+
return { produced: [record], discarded: [], rules: new Map([[hash, "same-action"]]) };
|
|
165
|
+
}
|
|
166
|
+
function settleMany(collapsed, held, now) {
|
|
167
|
+
const leaderH = Math.max(...[...collapsed.values()].map((record) => hundredths2(record.confidence)));
|
|
168
|
+
const kept = new Map;
|
|
169
|
+
const discarded = [];
|
|
170
|
+
for (const [hash, record] of collapsed) {
|
|
171
|
+
if (leaderH - hundredths2(record.confidence) > GAP_H) {
|
|
172
|
+
discarded.push(record);
|
|
173
|
+
} else {
|
|
174
|
+
kept.set(hash, record);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const status = kept.size > 1 ? "flagged" : "active";
|
|
178
|
+
const rule = kept.size > 1 ? "flagged" : "higher-confidence";
|
|
179
|
+
const rules = new Map;
|
|
180
|
+
for (const hash of collapsed.keys()) {
|
|
181
|
+
rules.set(hash, kept.has(hash) ? rule : "higher-confidence");
|
|
182
|
+
}
|
|
183
|
+
const produced = [...kept.values()].map((record) => stamp(withStatus(record, status), held, now));
|
|
184
|
+
return {
|
|
185
|
+
produced: produced.sort(byConfidence),
|
|
186
|
+
discarded: discarded.sort(byConfidence),
|
|
187
|
+
rules
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function settleTrigger(held, incoming, now) {
|
|
191
|
+
const groups = groupByAction(held, incoming);
|
|
192
|
+
if (groups.size === 1) {
|
|
193
|
+
const [hash, group] = [...groups.entries()][0];
|
|
194
|
+
return settleOne(hash, group, held, now);
|
|
195
|
+
}
|
|
196
|
+
const collapsed = new Map;
|
|
197
|
+
for (const [hash, group] of groups) {
|
|
198
|
+
collapsed.set(hash, collapse(group));
|
|
199
|
+
}
|
|
200
|
+
return settleMany(collapsed, held, now);
|
|
201
|
+
}
|
|
202
|
+
function merge(held, payload, now) {
|
|
203
|
+
const incoming = payload.instincts.map((record) => withSource(record, payload.source_id));
|
|
204
|
+
const keys = [...new Set(incoming.map((record) => triggerKey(record.trigger)))];
|
|
205
|
+
const outcomes = new Map;
|
|
206
|
+
for (const key of keys) {
|
|
207
|
+
const onKey = (record) => triggerKey(record.trigger) === key;
|
|
208
|
+
outcomes.set(key, settleTrigger(held.filter(onKey), incoming.filter(onKey), now));
|
|
209
|
+
}
|
|
210
|
+
const decisions = payload.instincts.map((record) => {
|
|
211
|
+
const outcome = outcomes.get(triggerKey(record.trigger));
|
|
212
|
+
return {
|
|
213
|
+
incoming: record,
|
|
214
|
+
rule: outcome.rules.get(record.action_hash),
|
|
215
|
+
produced: [...outcome.produced]
|
|
216
|
+
};
|
|
217
|
+
});
|
|
218
|
+
return {
|
|
219
|
+
decisions,
|
|
220
|
+
discarded: keys.flatMap((key) => outcomes.get(key).discarded)
|
|
221
|
+
};
|
|
222
|
+
}
|
|
14
223
|
export {
|
|
15
224
|
triggerKey,
|
|
16
225
|
promotable,
|
package/dist/plan/index.js
CHANGED
|
@@ -2,29 +2,30 @@
|
|
|
2
2
|
import {
|
|
3
3
|
FINDING_KINDS,
|
|
4
4
|
FINDING_SIGNALS,
|
|
5
|
-
PLAN_BLOCK_KINDS,
|
|
6
|
-
PLAN_HEADER_FIELDS,
|
|
7
5
|
PROBE_TIMEOUT_MS,
|
|
8
|
-
RAFA_BLOCK_KINDS,
|
|
9
6
|
REPORT_STATUSES,
|
|
10
|
-
isRafaBlockKind,
|
|
11
7
|
loadPlanPrerequisites,
|
|
12
8
|
mergePlanPrerequisites,
|
|
13
|
-
parsePlan,
|
|
14
9
|
parsePrerequisites,
|
|
15
10
|
parseReport,
|
|
16
11
|
planPrerequisites,
|
|
17
12
|
prerequisitesPathForPlan,
|
|
18
|
-
readRafaBlocks,
|
|
19
13
|
renderInjection,
|
|
20
14
|
runPreflight,
|
|
21
15
|
runShellProbe
|
|
22
|
-
} from "../index-
|
|
23
|
-
import
|
|
16
|
+
} from "../index-w5qbpdtp.js";
|
|
17
|
+
import {
|
|
18
|
+
PLAN_BLOCK_KINDS,
|
|
19
|
+
PLAN_HEADER_FIELDS,
|
|
20
|
+
RAFA_BLOCK_KINDS,
|
|
21
|
+
isRafaBlockKind,
|
|
22
|
+
parsePlan,
|
|
23
|
+
readRafaBlocks
|
|
24
|
+
} from "../index-ajv88fkm.js";
|
|
25
|
+
import"../index-2a7nb3an.js";
|
|
24
26
|
import {
|
|
25
27
|
INJECT_MODES
|
|
26
|
-
} from "../index-
|
|
27
|
-
import"../index-z1w83f81.js";
|
|
28
|
+
} from "../index-fpgmdmww.js";
|
|
28
29
|
export {
|
|
29
30
|
runShellProbe,
|
|
30
31
|
runPreflight,
|
package/dist/ports/index.d.ts
CHANGED
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
* out: `BOARD_COLUMNS`, `CLOSED_STATES` and `GITHUB_ISSUE_TYPES`,
|
|
55
55
|
* which are values and the GitHub adapter's projections, and
|
|
56
56
|
* `LedgerEntry`, the local ledger's line. rafa ports no OPT ledger,
|
|
57
|
-
* so the degradation chain (`src/adapters/tracker/resolve.ts`)
|
|
57
|
+
* so the degradation chain (`packages/rafa-board/src/adapters/tracker/resolve.ts`)
|
|
58
58
|
* arrived without it, and the `local` adapter records the reason the
|
|
59
59
|
* chain hands it in each issue file instead.
|
|
60
60
|
* - {@link Store}: the effort store port phase 0 already built, in
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
* {@link BlessedBundle}, {@link MergeRule}, {@link MergeDecision} and
|
|
68
68
|
* {@link MergeResult} are declared in `./learning.ts` and re-exported
|
|
69
69
|
* here under the same names. The learning library declares its own
|
|
70
|
-
* six in `src/learning/types.ts`, since neither side may import the
|
|
70
|
+
* six in `packages/rafa-inventory/src/learning/types.ts`, since neither side may import the
|
|
71
71
|
* other, and `src/tests/learning-contract.test.ts` holds each pair
|
|
72
72
|
* mutually assignable.
|
|
73
73
|
* - {@link Output}: open-tomato's `packages/shared/cli-core`, the
|
|
@@ -231,7 +231,7 @@ export interface IssueDraft {
|
|
|
231
231
|
* rafa's own field, absent from the source: true when the issue waits
|
|
232
232
|
* on other issues of the board, which the `github` adapter files as
|
|
233
233
|
* the board's `spec:blocked` label (`SPEC_BLOCKED_LABEL` in
|
|
234
|
-
* `src/board/blocked.ts`) and the `local` adapter records in the issue
|
|
234
|
+
* `packages/rafa-board/src/board/blocked.ts`) and the `local` adapter records in the issue
|
|
235
235
|
* file. Absent or false files no such mark. Not {@link blockedBy},
|
|
236
236
|
* which names OPT ledger numbers.
|
|
237
237
|
*/
|
|
@@ -625,7 +625,7 @@ export interface GeneratedPlan {
|
|
|
625
625
|
* What the planner's own session said about the spec BEFORE it
|
|
626
626
|
* planned, read out of that session's output: the `rafa:spec-review`
|
|
627
627
|
* block of the readiness gate's check 3
|
|
628
|
-
* (`src/board/spec-review.ts`).
|
|
628
|
+
* (`packages/rafa-board/src/board/spec-review.ts`).
|
|
629
629
|
*
|
|
630
630
|
* Optional, because a planner that reads no session output has judged
|
|
631
631
|
* nothing and must still satisfy this port — the fixture planners the
|
|
@@ -715,8 +715,8 @@ export type SyncPullResult =
|
|
|
715
715
|
* How a project's effort store travels between devices: the strategy
|
|
716
716
|
* `effort.sync` selects. `local` and `file` are core's strategies and
|
|
717
717
|
* `git`, `service` and `p2p` modules'; the adapter registry holds core's
|
|
718
|
-
* as `sync/local` (`src/effort/sync/select.ts`) and `sync/file`
|
|
719
|
-
* (`src/effort/sync/file.ts`). Push and pull are directions,
|
|
718
|
+
* as `sync/local` (`packages/rafa-effort/src/effort/sync/select.ts`) and `sync/file`
|
|
719
|
+
* (`packages/rafa-effort/src/effort/sync/file.ts`). Push and pull are directions,
|
|
720
720
|
* not strategies: in every strategy a device pushes the rows it wrote
|
|
721
721
|
* and pulls the rows others wrote.
|
|
722
722
|
*/
|
package/dist/ports/learning.d.ts
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
* The records the Learning port passes, and the answers it gives: core's
|
|
3
3
|
* declaration of the six types `packages/rafa/src/ports/index.ts` names for it.
|
|
4
4
|
*
|
|
5
|
-
* The learning library declares the same six in
|
|
6
|
-
* and keeps them there.
|
|
7
|
-
*
|
|
8
|
-
* the other's declaration: each declares its own,
|
|
5
|
+
* The learning library declares the same six in
|
|
6
|
+
* `packages/rafa-inventory/src/learning/types.ts` and keeps them there. That
|
|
7
|
+
* folder imports nothing outside itself, and core imports nothing above it,
|
|
8
|
+
* so neither side can take the other's declaration: each declares its own,
|
|
9
|
+
* and
|
|
9
10
|
* `src/tests/learning-contract.test.ts` holds every pair mutually
|
|
10
11
|
* assignable, so a field added, dropped or retyped on one side alone
|
|
11
12
|
* fails to compile there.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The shapes a spec review is read into: the verdicts and readings a
|
|
3
3
|
* `rafa:spec-review` block answers, the gaps it names and the issues it
|
|
4
4
|
* reports. Core's `Planner` port names {@link SpecReviewReading}, so they
|
|
5
|
-
* sit here, below the board; `src/board/spec-review.ts` reads the block
|
|
5
|
+
* sit here, below the board; `packages/rafa-board/src/board/spec-review.ts` reads the block
|
|
6
6
|
* into them, re-exports them under the same names, and keeps the parser,
|
|
7
7
|
* the headings and the two fallback gaps.
|
|
8
8
|
*/
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
ISSUE_READY_DECLARATION,
|
|
4
|
+
READINESS_REFUSAL_EXIT,
|
|
5
|
+
READY_DRY_RUN_FLAG,
|
|
6
|
+
READY_YES_FLAG,
|
|
7
|
+
SPEC_NEEDS_WORK_LABEL,
|
|
8
|
+
SPEC_READY_LABEL,
|
|
9
|
+
activeServices,
|
|
10
|
+
boardRepoLabel,
|
|
11
|
+
createGhIssueBoard,
|
|
12
|
+
createGhRunner,
|
|
13
|
+
createGhSpecIssueReader,
|
|
14
|
+
createRefreshingGhIssueBoard,
|
|
15
|
+
epicProblemMessage,
|
|
16
|
+
ghBoardTrust,
|
|
17
|
+
hasSpecReadyLabel,
|
|
18
|
+
issueProject,
|
|
19
|
+
issueSource,
|
|
20
|
+
issueSubjectConfig,
|
|
21
|
+
lineRefusal,
|
|
22
|
+
moduleOfLabels,
|
|
23
|
+
readEpicProblems,
|
|
24
|
+
requireCompleteSpec,
|
|
25
|
+
requireTrustedBoardAuthor,
|
|
26
|
+
typeOfLabels
|
|
27
|
+
} from "./index-j154qpbj.js";
|
|
28
|
+
import"./index-ajv88fkm.js";
|
|
29
|
+
import {
|
|
30
|
+
CommandExit,
|
|
31
|
+
createGitRunner,
|
|
32
|
+
createLinePrompter,
|
|
33
|
+
lazyPrompter
|
|
34
|
+
} from "./index-thqpre1b.js";
|
|
35
|
+
import"./index-2a7nb3an.js";
|
|
36
|
+
import"./index-g91ys6kw.js";
|
|
37
|
+
import"./index-m672ptpg.js";
|
|
38
|
+
import {
|
|
39
|
+
messageOf
|
|
40
|
+
} from "./index-fpgmdmww.js";
|
|
41
|
+
|
|
42
|
+
// packages/rafa-board/src/commands/issue/ready.ts
|
|
43
|
+
var READY_USAGE = "rafa issue ready <n> [--yes | --dry-run]";
|
|
44
|
+
var READY_WRITE_EXIT = 1;
|
|
45
|
+
var ISSUE_NUMBER = /^[1-9]\d*$/u;
|
|
46
|
+
function readyQuestion(issue) {
|
|
47
|
+
return `Mark #${String(issue)} ${SPEC_READY_LABEL}? [y/N] `;
|
|
48
|
+
}
|
|
49
|
+
function trustPassLine(issue, repo, reading) {
|
|
50
|
+
if (!reading.trusted) {
|
|
51
|
+
throw new TypeError(`issue ready: ${reading.login} is not trusted, and has no pass to name`);
|
|
52
|
+
}
|
|
53
|
+
const because = reading.source === "allow-list" ? "listed in board.trustedAuthors" : `who has write access to ${repo}`;
|
|
54
|
+
return `#${String(issue)} was opened by ${reading.login}, ${because}`;
|
|
55
|
+
}
|
|
56
|
+
function completeLine(issue) {
|
|
57
|
+
return `#${String(issue)} fills every heading the spec template asks for, with no placeholder left`;
|
|
58
|
+
}
|
|
59
|
+
function unaskedMessage(issue) {
|
|
60
|
+
const number = String(issue);
|
|
61
|
+
return `#${number} is ready to mark; there is no terminal to ask on, so ${SPEC_READY_LABEL} was not added.` + ` Run rafa issue ready ${number} where an answer can be typed`;
|
|
62
|
+
}
|
|
63
|
+
function requireOneEpic(found) {
|
|
64
|
+
const listed = {
|
|
65
|
+
number: found.number,
|
|
66
|
+
title: found.title,
|
|
67
|
+
body: found.body,
|
|
68
|
+
state: found.state,
|
|
69
|
+
stateReason: null,
|
|
70
|
+
labels: found.labels,
|
|
71
|
+
type: typeOfLabels(found.labels),
|
|
72
|
+
module: moduleOfLabels(found.labels)
|
|
73
|
+
};
|
|
74
|
+
const several = readEpicProblems([listed]).find((problem) => problem.kind === "several-epic-labels");
|
|
75
|
+
if (several === undefined)
|
|
76
|
+
return;
|
|
77
|
+
throw new CommandExit(READINESS_REFUSAL_EXIT, `issue #${String(found.number)} cannot be marked ${SPEC_READY_LABEL}: ${epicProblemMessage(several)}`);
|
|
78
|
+
}
|
|
79
|
+
function readyReport(issue, status, reading, lines) {
|
|
80
|
+
return Object.freeze({
|
|
81
|
+
issue,
|
|
82
|
+
status,
|
|
83
|
+
author: reading.login,
|
|
84
|
+
trustedBy: reading.source,
|
|
85
|
+
trust: lines.trust,
|
|
86
|
+
checked: lines.checked,
|
|
87
|
+
message: lines.message
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
async function runIssueReady(options) {
|
|
91
|
+
const { gh, issue, trust, ask } = options;
|
|
92
|
+
const board = options.board ?? createGhIssueBoard({ gh });
|
|
93
|
+
const readIssue = options.readIssue ?? createGhSpecIssueReader({ gh });
|
|
94
|
+
const found = await readIssue(issue);
|
|
95
|
+
const reading = await requireTrustedBoardAuthor({ kind: "issue", number: issue }, trust, found.author);
|
|
96
|
+
requireCompleteSpec(issueSource(issue), found.body);
|
|
97
|
+
if ((options.relationships ?? "labels") === "labels")
|
|
98
|
+
requireOneEpic(found);
|
|
99
|
+
const lines = { trust: trustPassLine(issue, trust.repo, reading), checked: completeLine(issue) };
|
|
100
|
+
if (hasSpecReadyLabel(found.labels)) {
|
|
101
|
+
return readyReport(issue, "already", reading, {
|
|
102
|
+
...lines,
|
|
103
|
+
message: `#${String(issue)} is already marked ${SPEC_READY_LABEL}`
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
if (options.dryRun === true) {
|
|
107
|
+
return readyReport(issue, "checked", reading, {
|
|
108
|
+
...lines,
|
|
109
|
+
message: `#${String(issue)} is ready to mark; --${READY_DRY_RUN_FLAG} wrote nothing.`
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
if (options.yes !== true) {
|
|
113
|
+
if (ask === null) {
|
|
114
|
+
return readyReport(issue, "unasked", reading, { ...lines, message: unaskedMessage(issue) });
|
|
115
|
+
}
|
|
116
|
+
if (!await ask(readyQuestion(issue))) {
|
|
117
|
+
return readyReport(issue, "declined", reading, {
|
|
118
|
+
...lines,
|
|
119
|
+
message: `#${String(issue)} was left unmarked`
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
try {
|
|
124
|
+
await board.swapLabels(issue, SPEC_NEEDS_WORK_LABEL, SPEC_READY_LABEL);
|
|
125
|
+
} catch (error) {
|
|
126
|
+
throw new CommandExit(READY_WRITE_EXIT, `\u274C ${SPEC_READY_LABEL} could not be put on #${String(issue)}: ${messageOf(error)}`);
|
|
127
|
+
}
|
|
128
|
+
return readyReport(issue, "marked", reading, {
|
|
129
|
+
...lines,
|
|
130
|
+
message: `Marked #${String(issue)} ${SPEC_READY_LABEL}, and took ${SPEC_NEEDS_WORK_LABEL} off it`
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
function readReadyIssue(context) {
|
|
134
|
+
const { args } = context;
|
|
135
|
+
if (args.length > 1) {
|
|
136
|
+
throw lineRefusal(`Expected one issue number, got ${String(args.length)}: ${args.join(" ")}`, READY_USAGE);
|
|
137
|
+
}
|
|
138
|
+
const word = args[0];
|
|
139
|
+
if (word === undefined) {
|
|
140
|
+
throw lineRefusal("Name the issue number to mark ready", READY_USAGE);
|
|
141
|
+
}
|
|
142
|
+
if (!ISSUE_NUMBER.test(word)) {
|
|
143
|
+
throw lineRefusal(`"${word}" is no issue number, which is a whole number from 1`, READY_USAGE);
|
|
144
|
+
}
|
|
145
|
+
return Number(word);
|
|
146
|
+
}
|
|
147
|
+
function readReadySwitch(context, name) {
|
|
148
|
+
const value = context.flags[name];
|
|
149
|
+
if (value === undefined)
|
|
150
|
+
return false;
|
|
151
|
+
if (typeof value === "boolean")
|
|
152
|
+
return value;
|
|
153
|
+
if (value === "true" || value === "false")
|
|
154
|
+
return value === "true";
|
|
155
|
+
throw lineRefusal(`--${name} takes no value, and read "${value}" as one`, READY_USAGE);
|
|
156
|
+
}
|
|
157
|
+
function readReadyYes(context) {
|
|
158
|
+
return readReadySwitch(context, READY_YES_FLAG);
|
|
159
|
+
}
|
|
160
|
+
function readReadyDryRun(context) {
|
|
161
|
+
return readReadySwitch(context, READY_DRY_RUN_FLAG);
|
|
162
|
+
}
|
|
163
|
+
var DEFAULT_READY_SEAMS = Object.freeze({});
|
|
164
|
+
async function markIssueReady(context, seams) {
|
|
165
|
+
const issue = readReadyIssue(context);
|
|
166
|
+
const yes = readReadyYes(context);
|
|
167
|
+
const dryRun = readReadyDryRun(context);
|
|
168
|
+
if (yes && dryRun) {
|
|
169
|
+
throw lineRefusal(`--${READY_YES_FLAG} and --${READY_DRY_RUN_FLAG} cannot be used together: one asks for the write and the other for none`, READY_USAGE);
|
|
170
|
+
}
|
|
171
|
+
const project = issueProject(context);
|
|
172
|
+
const config = await issueSubjectConfig(project, (message) => {
|
|
173
|
+
context.output.warn(message);
|
|
174
|
+
});
|
|
175
|
+
const openGh = seams.openGh ?? ((dir) => createGhRunner({ cwd: dir }));
|
|
176
|
+
const openGit = seams.openGit ?? createGitRunner;
|
|
177
|
+
const isTerminal = seams.isTerminal ?? (() => process.stdin.isTTY === true);
|
|
178
|
+
const openPrompter = seams.openPrompter ?? (() => createLinePrompter(process.stdin, process.stderr));
|
|
179
|
+
const gh = openGh(project.root);
|
|
180
|
+
const trust = ghBoardTrust({
|
|
181
|
+
gh,
|
|
182
|
+
trustedAuthors: config.boardTrustedAuthors,
|
|
183
|
+
repo: boardRepoLabel(openGit(project.root))
|
|
184
|
+
});
|
|
185
|
+
const prompter = lazyPrompter(openPrompter);
|
|
186
|
+
try {
|
|
187
|
+
return await runIssueReady({
|
|
188
|
+
gh,
|
|
189
|
+
issue,
|
|
190
|
+
trust,
|
|
191
|
+
board: createRefreshingGhIssueBoard({ gh, config, warn: (line) => {
|
|
192
|
+
context.output.warn(line);
|
|
193
|
+
} }),
|
|
194
|
+
relationships: config.boardRelationships,
|
|
195
|
+
yes,
|
|
196
|
+
dryRun,
|
|
197
|
+
ask: isTerminal() ? prompter.ask : null
|
|
198
|
+
});
|
|
199
|
+
} finally {
|
|
200
|
+
prompter.close();
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
function writeReport(context, report) {
|
|
204
|
+
context.output.info(report.trust);
|
|
205
|
+
context.output.info(report.checked);
|
|
206
|
+
context.output.info(report.message);
|
|
207
|
+
}
|
|
208
|
+
function createIssueReadyCommand(seams = DEFAULT_READY_SEAMS) {
|
|
209
|
+
const command = {
|
|
210
|
+
...ISSUE_READY_DECLARATION,
|
|
211
|
+
run: async (context) => {
|
|
212
|
+
const made = await markIssueReady(context, seams);
|
|
213
|
+
if (context.outputMode === "json")
|
|
214
|
+
context.output.result(made);
|
|
215
|
+
else
|
|
216
|
+
writeReport(context, made);
|
|
217
|
+
if ((made.status === "marked" || made.status === "already") && !readReadyDryRun(context)) {
|
|
218
|
+
await activeServices().endWithNextStep(context, seams.ending);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
return Object.freeze(command);
|
|
223
|
+
}
|
|
224
|
+
var command = createIssueReadyCommand();
|
|
225
|
+
var ready_default = command;
|
|
226
|
+
export {
|
|
227
|
+
trustPassLine,
|
|
228
|
+
runIssueReady,
|
|
229
|
+
requireOneEpic,
|
|
230
|
+
readyQuestion,
|
|
231
|
+
readReadyYes,
|
|
232
|
+
readReadyIssue,
|
|
233
|
+
readReadyDryRun,
|
|
234
|
+
markIssueReady,
|
|
235
|
+
ready_default as default,
|
|
236
|
+
createIssueReadyCommand,
|
|
237
|
+
completeLine,
|
|
238
|
+
READY_WRITE_EXIT,
|
|
239
|
+
READY_USAGE,
|
|
240
|
+
DEFAULT_READY_SEAMS
|
|
241
|
+
};
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
# pull request, for levels 3 and 4 of the release ladder.
|
|
3
3
|
#
|
|
4
4
|
# Written into a project's `.github/workflows/` by `writeReleaseWorkflow`
|
|
5
|
-
# (`src/release/templates.ts`) at levels 3 and 4
|
|
6
|
-
# `.github/dependabot.yml` exists. A bot pull request has no
|
|
7
|
-
# write its fragment, so this workflow writes one with
|
|
5
|
+
# (`packages/rafa-release/src/release/templates.ts`) at levels 3 and 4
|
|
6
|
+
# while `.github/dependabot.yml` exists. A bot pull request has no
|
|
7
|
+
# wrap-up to write its fragment, so this workflow writes one with
|
|
8
8
|
# `rafa release fragment --plan=dependabot-<number>`, at `patch` when
|
|
9
9
|
# `dependabot/fetch-metadata` reads the update as `direct:production` and
|
|
10
10
|
# at `none` otherwise, commits it as `chore: release fragment
|
|
@@ -61,17 +61,17 @@ jobs:
|
|
|
61
61
|
steps:
|
|
62
62
|
- name: Fetch metadata
|
|
63
63
|
id: metadata
|
|
64
|
-
uses: dependabot/fetch-metadata@
|
|
64
|
+
uses: dependabot/fetch-metadata@v3
|
|
65
65
|
|
|
66
66
|
- name: Checkout the base
|
|
67
|
-
uses: actions/checkout@
|
|
67
|
+
uses: actions/checkout@v7
|
|
68
68
|
with:
|
|
69
69
|
ref: ${{ github.event.pull_request.base.ref }}
|
|
70
70
|
path: base
|
|
71
71
|
fetch-depth: 0
|
|
72
72
|
|
|
73
73
|
- name: Checkout the head
|
|
74
|
-
uses: actions/checkout@
|
|
74
|
+
uses: actions/checkout@v7
|
|
75
75
|
with:
|
|
76
76
|
ref: ${{ github.event.pull_request.head.ref }}
|
|
77
77
|
path: head
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# The rafa release publish workflow: level 2 of the release ladder.
|
|
2
2
|
#
|
|
3
3
|
# Written into a project's `.github/workflows/` by `writeReleaseWorkflow`
|
|
4
|
-
# (`src/release/templates.ts`) for
|
|
5
|
-
# or a workflow that tags in its own
|
|
6
|
-
# as `ref`, checks the tag out, runs
|
|
7
|
-
# `rafa release publish`, which publishes every
|
|
8
|
-
# points at the checked-out commit and skips a
|
|
9
|
-
# already holds.
|
|
4
|
+
# (`packages/rafa-release/src/release/templates.ts`) for
|
|
5
|
+
# `release.publish: ci`. A pushed tag, or a workflow that tags in its own
|
|
6
|
+
# run and calls this one with the tag as `ref`, checks the tag out, runs
|
|
7
|
+
# the gates and then `rafa release publish`, which publishes every
|
|
8
|
+
# release unit whose tag points at the checked-out commit and skips a
|
|
9
|
+
# version the registry already holds.
|
|
10
10
|
#
|
|
11
11
|
# npm trusted publishing needs npm 11.5.1 or newer, `id-token: write` on
|
|
12
12
|
# the job, and a trusted publisher configured on npmjs.com for each
|
|
@@ -55,7 +55,7 @@ jobs:
|
|
|
55
55
|
timeout-minutes: 30
|
|
56
56
|
steps:
|
|
57
57
|
- name: Checkout
|
|
58
|
-
uses: actions/checkout@
|
|
58
|
+
uses: actions/checkout@v7
|
|
59
59
|
with:
|
|
60
60
|
ref: ${{ inputs.ref || github.ref }}
|
|
61
61
|
fetch-depth: 0
|
|
@@ -66,7 +66,7 @@ jobs:
|
|
|
66
66
|
bun-version-file: package.json
|
|
67
67
|
|
|
68
68
|
- name: Set up node
|
|
69
|
-
uses: actions/setup-node@
|
|
69
|
+
uses: actions/setup-node@v7
|
|
70
70
|
with:
|
|
71
71
|
node-version: 24
|
|
72
72
|
registry-url: https://registry.npmjs.org
|