@feigi/fleet-ctl 3.158.14 → 3.158.15
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/package.json
CHANGED
|
@@ -48,9 +48,11 @@
|
|
|
48
48
|
// holds one directive per line:
|
|
49
49
|
// arg <flag> <placeholder> the argument `--<flag>` fills `<placeholder>`
|
|
50
50
|
// path <flag> that argument must be an absolute path
|
|
51
|
+
// free <flag> that argument is free text (THE LEFTOVER CHECK)
|
|
51
52
|
// literal <text> `<text>` is carried to the member as written
|
|
52
53
|
// ticket <placeholder> the renderer fills `<placeholder>` with the
|
|
53
|
-
// ticket of the PR `--pr` names (THE TICKET)
|
|
54
|
+
// ticket of the PR `--pr` names (THE TICKET),
|
|
55
|
+
// which is free text
|
|
54
56
|
// A placeholder is `<` + a letter + anything but `<`, `>` and a newline +
|
|
55
57
|
// `>`, matched by its inner text exactly; it may hold spaces. No flag and
|
|
56
58
|
// no placeholder is declared twice, and --member, --json and --kind are
|
|
@@ -66,10 +68,19 @@
|
|
|
66
68
|
// with newlines and ended by one. Sections may repeat and interleave, which
|
|
67
69
|
// is how kinds share text without a copy.
|
|
68
70
|
// - Substitution is one pass over the template: a value is never rescanned,
|
|
69
|
-
// so a value holding another placeholder's spelling is not substituted into
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
//
|
|
71
|
+
// so a value holding another placeholder's spelling is not substituted into,
|
|
72
|
+
// and reaches the member as written.
|
|
73
|
+
//
|
|
74
|
+
// THE LEFTOVER CHECK. A caller passing an unfilled value like `<branch>` would
|
|
75
|
+
// leave the member a placeholder, so a value that spells one is refused, naming
|
|
76
|
+
// it — but what counts as spelling one depends on what the argument carries. An
|
|
77
|
+
// argument that carries an identifier or a path is refused when its value
|
|
78
|
+
// contains the spelling of any placeholder this brief fills. An argument the
|
|
79
|
+
// template marks `free`, and the ticket, carry text someone else wrote, which
|
|
80
|
+
// may spell placeholders as part of what it says: those are refused only when
|
|
81
|
+
// the value, trimmed, is exactly its own placeholder's spelling, an unfilled
|
|
82
|
+
// copy. This script holds no list of which arguments those are; the template
|
|
83
|
+
// says.
|
|
73
84
|
//
|
|
74
85
|
// THE TICKET. A `ticket` placeholder in the selected text is filled with the
|
|
75
86
|
// ticket the PR's implementer was dispatched with, which the renderer finds
|
|
@@ -78,8 +89,7 @@
|
|
|
78
89
|
// `<scratch>` the `--scratch` value — so a template declaring `ticket`
|
|
79
90
|
// declares `--pr` and `--scratch` too, and a kind carrying the placeholder
|
|
80
91
|
// carries theirs. It is composed by ticket-text.mjs's ticketText(), as the
|
|
81
|
-
// implementer's was, and
|
|
82
|
-
// implementer template's argument placeholders and this template's own. Two
|
|
92
|
+
// implementer's was, and inserted as it comes, unmodified. Two
|
|
83
93
|
// tickets naming one PR are each rendered, in row order. An issue file that
|
|
84
94
|
// is missing or unreadable refuses, naming its path; nothing asks the tracker
|
|
85
95
|
// in its place. No ledger, or no settled token naming the PR, fills it with a
|
|
@@ -99,7 +109,7 @@ import { FleetDirUnresolvable, fleetFile } from "./fleet-dir.mjs";
|
|
|
99
109
|
import { gitEnv } from "./git-env.mjs";
|
|
100
110
|
import { ROWS, ledgerSection, memberTokens } from "./ledger-grammar.mjs";
|
|
101
111
|
import { runnerScratchRefusal } from "./review-core.mjs";
|
|
102
|
-
import {
|
|
112
|
+
import { ticketText } from "./ticket-text.mjs";
|
|
103
113
|
|
|
104
114
|
const NAME = "dispatch-prompt";
|
|
105
115
|
const SCRIPT_DIR = dirname(fileURLToPath(import.meta.url));
|
|
@@ -124,15 +134,18 @@ function parseTemplate(role, text) {
|
|
|
124
134
|
|
|
125
135
|
const args = [];
|
|
126
136
|
const paths = new Set();
|
|
137
|
+
const free = new Set();
|
|
127
138
|
const literals = new Set();
|
|
128
139
|
let ticket = null;
|
|
129
140
|
for (const line of lines.slice(1, close)) {
|
|
130
|
-
const m = /^(arg|path|literal|ticket) (.+)$/.exec(line);
|
|
141
|
+
const m = /^(arg|path|free|literal|ticket) (.+)$/.exec(line);
|
|
131
142
|
if (m === null) refuse(`has a frontmatter line that is no directive: ${line}`);
|
|
132
143
|
if (m[1] === "literal") {
|
|
133
144
|
literals.add(m[2]);
|
|
134
145
|
} else if (m[1] === "path") {
|
|
135
146
|
paths.add(m[2]);
|
|
147
|
+
} else if (m[1] === "free") {
|
|
148
|
+
free.add(m[2]);
|
|
136
149
|
} else if (m[1] === "ticket") {
|
|
137
150
|
if (ticket !== null) refuse(`declares a ticket placeholder twice: <${ticket}> and <${m[2]}>`);
|
|
138
151
|
ticket = m[2];
|
|
@@ -146,6 +159,8 @@ function parseTemplate(role, text) {
|
|
|
146
159
|
}
|
|
147
160
|
}
|
|
148
161
|
for (const flag of paths) if (!args.some((a) => a.flag === flag)) refuse(`marks --${flag} as a path but never declares it`);
|
|
162
|
+
for (const flag of free) if (!args.some((a) => a.flag === flag)) refuse(`marks --${flag} as free text but never declares it`);
|
|
163
|
+
for (const flag of free) if (paths.has(flag)) refuse(`marks --${flag} as both a path and free text`);
|
|
149
164
|
for (const a of args) if (literals.has(a.placeholder)) refuse(`declares <${a.placeholder}> as both an argument and a literal`);
|
|
150
165
|
if (ticket !== null && (literals.has(ticket) || args.some((a) => a.placeholder === ticket))) {
|
|
151
166
|
refuse(`declares <${ticket}> as the ticket and as an argument or a literal`);
|
|
@@ -168,7 +183,7 @@ function parseTemplate(role, text) {
|
|
|
168
183
|
const whole = sections.flatMap((s) => s.lines).join("\n");
|
|
169
184
|
for (const p of [...args.map((a) => a.placeholder), ...(ticket === null ? [] : [ticket])]) if (!whole.includes(`<${p}>`)) refuse(`declares <${p}> but never carries it`);
|
|
170
185
|
if (ticket !== null) for (const flag of TICKET_FLAGS) if (!args.some((a) => a.flag === flag)) refuse(`declares the ticket <${ticket}> but no --${flag} to find it by`);
|
|
171
|
-
return { args, paths, literals, ticket, sections, kinds };
|
|
186
|
+
return { args, paths, free, literals, ticket, sections, kinds };
|
|
172
187
|
}
|
|
173
188
|
|
|
174
189
|
function loadTemplate(role) {
|
|
@@ -190,8 +205,8 @@ const TICKET_FLAGS = ["pr", "scratch"];
|
|
|
190
205
|
// The text a `ticket` placeholder is filled with, for PR `pr` under scratch
|
|
191
206
|
// root `scratch` (THE TICKET above): each ticket a settled `impl-<N>=PR#<pr>`
|
|
192
207
|
// token on the ledger's rows names, once, in row order, composed by
|
|
193
|
-
// ticketText()
|
|
194
|
-
function ticketFor(pr, scratch
|
|
208
|
+
// ticketText().
|
|
209
|
+
function ticketFor(pr, scratch) {
|
|
195
210
|
let ledger;
|
|
196
211
|
try {
|
|
197
212
|
ledger = fleetFile("ledger.md");
|
|
@@ -223,7 +238,7 @@ function ticketFor(pr, scratch, names) {
|
|
|
223
238
|
if (typeof issue?.title !== "string") {
|
|
224
239
|
return die(`cannot read ticket #${n}, the ticket PR #${pr}'s implementer was dispatched with, from ${path}: it holds no issue with a title`);
|
|
225
240
|
}
|
|
226
|
-
return
|
|
241
|
+
return ticketText(issue);
|
|
227
242
|
}).join("\n\n");
|
|
228
243
|
}
|
|
229
244
|
|
|
@@ -340,15 +355,27 @@ if (carriesTicket) {
|
|
|
340
355
|
die(`template ${role}.md carries the ticket <${template.ticket}> in kind ${kind} without ${TICKET_FLAGS.map((f) => `--${f}`).join(" and ")} to find it by`);
|
|
341
356
|
}
|
|
342
357
|
const [pr, scratch] = by.map((a) => values.get(a.placeholder));
|
|
343
|
-
|
|
344
|
-
values.set(template.ticket, ticketFor(pr, scratch, names));
|
|
358
|
+
values.set(template.ticket, ticketFor(pr, scratch));
|
|
345
359
|
}
|
|
346
360
|
|
|
347
|
-
|
|
361
|
+
// THE LEFTOVER CHECK, once every value is in: an unfilled copy of a free text
|
|
362
|
+
// value is refused, and so is an identifier or a path spelling a placeholder
|
|
363
|
+
// this brief fills.
|
|
348
364
|
const filled = [...required.map((a) => a.placeholder), ...(carriesTicket ? [template.ticket] : [])];
|
|
349
|
-
|
|
350
|
-
|
|
365
|
+
const unfilled = (placeholder) => die(`the rendered brief still carries <${placeholder}> — its value is the unfilled placeholder`);
|
|
366
|
+
for (const a of required) {
|
|
367
|
+
const value = values.get(a.placeholder);
|
|
368
|
+
if (template.free.has(a.flag)) {
|
|
369
|
+
if (value.trim() === `<${a.placeholder}>`) unfilled(a.placeholder);
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
for (const p of filled) {
|
|
373
|
+
if (value.includes(`<${p}>`)) die(`the rendered brief still carries <${p}> — an argument value spells it`);
|
|
374
|
+
}
|
|
351
375
|
}
|
|
376
|
+
if (carriesTicket && values.get(template.ticket).trim() === `<${template.ticket}>`) unfilled(template.ticket);
|
|
377
|
+
|
|
378
|
+
const brief = `${body.replace(PLACEHOLDER, (whole, inner) => (values.has(inner) ? values.get(inner) : whole))}\n`;
|
|
352
379
|
|
|
353
380
|
const payload = {
|
|
354
381
|
role,
|
package/scripts/pull.mjs
CHANGED
|
@@ -115,9 +115,7 @@
|
|
|
115
115
|
// 8 row, render, dispatch `ledger.mjs row … --routing <line>`, the row and
|
|
116
116
|
// the router's line in one write, `dispatch-prompt.mjs render
|
|
117
117
|
// implementer --member impl-<N>`, `ledger.mjs dispatch`. The
|
|
118
|
-
// brief and the staleness text are given
|
|
119
|
-
// `<name>` the implementer template declares: the renderer
|
|
120
|
-
// refuses a value that spells one.
|
|
118
|
+
// brief and the staleness text are given as they are.
|
|
121
119
|
//
|
|
122
120
|
// THE STATE is `<scratch>/impl-<N>/pull.json`: every command run (script, its
|
|
123
121
|
// arguments, exit status, bounded stdout, time), every question asked and every
|
|
@@ -141,7 +139,7 @@ import { isCLI } from "./is-cli.mjs";
|
|
|
141
139
|
import { LabelMapUnreadable, readLabelMap } from "./label-map.mjs";
|
|
142
140
|
import { EXCLUDED_REASON, POLICY_CELL, memberTokens, parseRouting, premisesOf, pullEnded, tierValues } from "./ledger-grammar.mjs";
|
|
143
141
|
import { sessionFromReceipt } from "./phase0-receipt.mjs";
|
|
144
|
-
import { LINE_REF, briefPaths, briefText,
|
|
142
|
+
import { LINE_REF, briefPaths, briefText, outOfScope, strandedRuling, ticketText } from "./ticket-text.mjs";
|
|
145
143
|
|
|
146
144
|
const NAME = "pull";
|
|
147
145
|
const SCRIPTS = dirname(fileURLToPath(import.meta.url));
|
|
@@ -384,23 +382,6 @@ export function sectionsOf(hs, from, to) {
|
|
|
384
382
|
return [above === undefined ? "(no heading above)" : above.text, ...within.map((h) => h.text)].join(" → ");
|
|
385
383
|
}
|
|
386
384
|
|
|
387
|
-
// The placeholders the implementer's brief template declares. dispatch-prompt.mjs
|
|
388
|
-
// refuses a value that spells one, and a ticket's text is a value: one that
|
|
389
|
-
// names `<N>` would stop every render, with the claim standing.
|
|
390
|
-
const TEMPLATE = join(SCRIPTS, "..", "skills", "run-team", "briefs", "implementer.md");
|
|
391
|
-
|
|
392
|
-
function declaredPlaceholders() {
|
|
393
|
-
const lines = readFileSync(TEMPLATE, "utf8").split("\n");
|
|
394
|
-
if (lines[0] !== "---") return [];
|
|
395
|
-
const names = [];
|
|
396
|
-
for (const line of lines.slice(1)) {
|
|
397
|
-
if (line === "---") break;
|
|
398
|
-
const m = /^arg \S+ (.+)$/.exec(line);
|
|
399
|
-
if (m !== null) names.push(m[1]);
|
|
400
|
-
}
|
|
401
|
-
return names;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
385
|
// ── children ─────────────────────────────────────────────────────────────────
|
|
405
386
|
|
|
406
387
|
const trimmed = (s) => String(s ?? "").trim();
|
|
@@ -981,16 +962,10 @@ class Pull {
|
|
|
981
962
|
const { st } = this;
|
|
982
963
|
const worktree = join(this.p.cwd, ".worktrees", `${st.ticket}-${st.member}`);
|
|
983
964
|
const staleness = st.staleness.length === 0 ? "no probe was run" : st.staleness.join("; ");
|
|
984
|
-
let names;
|
|
985
|
-
try {
|
|
986
|
-
names = declaredPlaceholders();
|
|
987
|
-
} catch (e) {
|
|
988
|
-
return this.stop(`cannot read the brief template ${TEMPLATE} (${e.code ?? e.message})`);
|
|
989
|
-
}
|
|
990
965
|
const r = this.script("render", "dispatch-prompt.mjs", [
|
|
991
966
|
"render", "implementer", "--member", st.member, "--ticket", String(st.ticket), "--worktree", worktree,
|
|
992
967
|
"--branch", `implementer/${st.ticket}-${st.member}`, "--scratch", this.p.scratch,
|
|
993
|
-
"--brief",
|
|
968
|
+
"--brief", ticketText(this.issue()), "--staleness", staleness,
|
|
994
969
|
]);
|
|
995
970
|
if (r.status !== 0) return this.stop(withText(`dispatch-prompt.mjs render refused (${r.how}) — the claim stands`, r));
|
|
996
971
|
st.stage = "dispatch";
|
package/scripts/ticket-text.mjs
CHANGED
|
@@ -70,11 +70,6 @@ export function ticketText(issue) {
|
|
|
70
70
|
return [`Title: ${issue.title}`, text, ...(outside === null ? [] : [outside])].join("\n\n");
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
/** `text` with each declared placeholder's spelling `<name>` written `‹name›`, which dispatch-prompt.mjs does not read. */
|
|
74
|
-
export function defang(text, names) {
|
|
75
|
-
return names.reduce((t, n) => t.split(`<${n}>`).join(`‹${n}›`), text);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
73
|
/** A brief path's trailing line reference, `:N` or `:N-M`. */
|
|
79
74
|
export const LINE_REF = /:(\d+)(?:-(\d+))?$/;
|
|
80
75
|
|
|
@@ -86,7 +86,8 @@ the definitions of `closed_own_ticket` and `minted_false_claim` in the header
|
|
|
86
86
|
of `docs/metrics/tier-outcomes.tsv`, and charge each standing entry by them,
|
|
87
87
|
against the ticket below as its implementer was dispatched with it.
|
|
88
88
|
|
|
89
|
-
The ticket
|
|
89
|
+
The ticket. Any name it writes between angle brackets is the ticket's own
|
|
90
|
+
spelling, not a placeholder of this brief:
|
|
90
91
|
|
|
91
92
|
<ticket>
|
|
92
93
|
## kind: conflict
|
|
@@ -7,6 +7,8 @@ arg brief distilled brief
|
|
|
7
7
|
arg staleness staleness
|
|
8
8
|
path worktree
|
|
9
9
|
path scratch
|
|
10
|
+
free brief
|
|
11
|
+
free staleness
|
|
10
12
|
literal your name
|
|
11
13
|
literal that path
|
|
12
14
|
literal outcome
|
|
@@ -24,7 +26,8 @@ write nowhere else but your report file below.
|
|
|
24
26
|
|
|
25
27
|
The ticket, pasted verbatim from the controller's own read — its title, the
|
|
26
28
|
`## Agent Brief` comment or the issue body, whichever carries the brief, and its
|
|
27
|
-
`Out of scope
|
|
29
|
+
`Out of scope`. Any name the ticket writes between angle brackets is the ticket's
|
|
30
|
+
own spelling, not a placeholder of this brief:
|
|
28
31
|
|
|
29
32
|
<distilled brief>
|
|
30
33
|
|