@kitman-sh/software-engineering 0.12.0-rc.1 → 0.12.0-rc.3

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/bundle.js CHANGED
@@ -12605,8 +12605,23 @@ var LOCAL_PATH_KEYS = new Set([
12605
12605
  "docker_socket",
12606
12606
  "ssh_agent_socket"
12607
12607
  ]);
12608
- var wrappedValue = String.raw`<[A-Za-z][A-Za-z0-9 _.-]*>|\$\{[^{}\s]*\}|\{\{[^{}]*\}\}|proxy-ep=[A-Za-z0-9.-]+;kitmanref(?:[0-9a-f]{2})+(?![A-Za-z0-9._~+/-])`;
12608
+ var wrappedValue = String.raw`<[A-Za-z][A-Za-z0-9 _.|-]*>|\$\{[^{}\s]*\}|\{\{[^{}]*\}\}|proxy-ep=[A-Za-z0-9.-]+;kitmanref(?:[0-9a-f]{2})+(?![A-Za-z0-9._~+/-])`;
12609
+ var placeholderWord = "(?:[A-Z]?[a-z]+|[A-Z]+)";
12610
+ var placeholderNamePart = `(?:[A-Z]?[a-z]+|[A-Z]+)(?:[A-Z][a-z]+)*[0-9]{0,4}`;
12611
+ var anglePlaceholder = `<${placeholderWord}[0-9]{0,2}(?:[ _.|-]${placeholderWord}[0-9]{0,2})*>`;
12612
+ var secretReferencePart = String.raw`(?:[A-Za-z0-9_.-]+|${anglePlaceholder}|\$\{[A-Za-z_][A-Za-z0-9_]*\}|\{\{\s*[A-Za-z_][A-Za-z0-9_.]*\s*\}\}|\*|\u2026)`;
12613
+ var describedSecretReference = new RegExp(`^secret://${secretReferencePart}/(?:${secretReferencePart})?$`, "u");
12609
12614
  var secretReferenceTail = String.raw`(?<=secret:)\/\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+(?![^\s,;}"')\]\x60])`;
12615
+ var referenceInText = new RegExp(String.raw`secret:\/\/${secretReferencePart}\/${secretReferencePart}(?![^\s,;}"')\]\x60])`, "gu");
12616
+ function inSecretReference(text, start, end) {
12617
+ for (const reference of text.matchAll(referenceInText)) {
12618
+ const referenceEnd = reference.index + reference[0].length;
12619
+ if (reference.index <= start && end <= referenceEnd)
12620
+ return isPlaceholder(unwrapped(reference[0]));
12621
+ }
12622
+ return false;
12623
+ }
12624
+ var placeholderTokenName = new RegExp(`^<?(?:ghp_|github_pat_|glpat-|ksa1\\.|sk-|xox[baprs]-)${placeholderNamePart}(?:[_.-]${placeholderNamePart})*>?$`, "u");
12610
12625
  var bearerValue = /[0-9]|[._~+/:-][A-Za-z0-9]|[<{]/u;
12611
12626
  var VALUE_RULES = [
12612
12627
  { classification: "secret", name: "private-key", pattern: /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/u },
@@ -12620,7 +12635,7 @@ var VALUE_RULES = [
12620
12635
  classification: "credential",
12621
12636
  name: "provider-token",
12622
12637
  pattern: /(?:^|[^A-Za-z0-9])(?<value><?(?:ghp_|github_pat_|glpat-|ksa1\.|sk-[A-Za-z0-9_-]{8,}|xox[baprs]-)[A-Za-z0-9._*-]*[A-Za-z0-9_*-]>?)/u,
12623
- holds: (value) => !isPlaceholder(value)
12638
+ holds: (value, _matched, text, start) => !isPlaceholder(value) && !(placeholderTokenName.test(value) && inSecretReference(text, start, start + value.length))
12624
12639
  },
12625
12640
  {
12626
12641
  classification: "credential",
@@ -12651,10 +12666,10 @@ var VALUE_RULES = [
12651
12666
  { classification: "transcript", name: "transcript-content", pattern: /(?:^|\n)\s*(?:user|assistant|system)\s*:/iu }
12652
12667
  ];
12653
12668
  var maskedToken = /^(?:ghp_|github_pat_|glpat-|ksa1\.|xox[baprs]-|sk-(?:ant-(?:[a-z]+[0-9]*-)?|proj-|or-v[0-9]+-)?)(?:x{4,}|X{4,}|\*{4,})$/u;
12654
- var placeholderWord = "(?:[A-Z]?[a-z]+|[A-Z]+)";
12655
12669
  var placeholders = [
12656
12670
  maskedToken,
12657
- new RegExp(`^<${placeholderWord}[0-9]{0,2}(?:[ _.-]${placeholderWord}[0-9]{0,2})*>$`, "u"),
12671
+ new RegExp(`^${anglePlaceholder}$`, "u"),
12672
+ describedSecretReference,
12658
12673
  /^\$\{[A-Za-z_][A-Za-z0-9_]*\}$/u,
12659
12674
  /^\$[A-Za-z_][A-Za-z0-9_]*$/u,
12660
12675
  /^\{\{\s*[A-Za-z_][A-Za-z0-9_.]*\s*\}\}$/u,
@@ -12670,6 +12685,8 @@ function looksLikeCredential(raw, matched) {
12670
12685
  const value = unwrapped(raw);
12671
12686
  if (isPlaceholder(raw) || isPlaceholder(value))
12672
12687
  return false;
12688
+ if (matched === `secret:${raw}` && isPlaceholder(`secret:${value}`))
12689
+ return false;
12673
12690
  return /^[^\s:=]+=\S/u.test(matched) || value.length >= 6 && /[0-9]/u.test(value) || value.length >= 20 && /[a-z]/u.test(value) && /[A-Z]/u.test(value);
12674
12691
  }
12675
12692
  var globalPatterns = new WeakMap;
@@ -13947,7 +13964,8 @@ var RunWaiting = Union2([
13947
13964
  rank: Literals(ClaimRanks),
13948
13965
  position: Int.check(isGreaterThanOrEqualTo2(1)),
13949
13966
  reason: String5,
13950
- movesUpAt: optionalKey2(String5)
13967
+ movesUpAt: optionalKey2(String5),
13968
+ unrunnable: optionalKey2(String5)
13951
13969
  })
13952
13970
  ]);
13953
13971
  var RunEvidence = Struct({
@@ -19400,7 +19418,9 @@ var NoteRequest = Struct({
19400
19418
  });
19401
19419
  var CreateTasksRequest = Struct({
19402
19420
  tickets: ArraySchema(PlanTicket),
19403
- projectId: optionalKey2(String5)
19421
+ projectId: optionalKey2(String5),
19422
+ builds: optionalKey2(Boolean3),
19423
+ releases: optionalKey2(Boolean3)
19404
19424
  });
19405
19425
  var CreateTasksResult = Struct({
19406
19426
  tasks: ArraySchema(Struct({ key: String5, taskId: String5 }))
@@ -19445,7 +19465,8 @@ var ApproveChangeRequestRequest = Struct({
19445
19465
  head: String5,
19446
19466
  summary: String5,
19447
19467
  review: optionalKey2(String5),
19448
- carries: optionalKey2(String5)
19468
+ carries: optionalKey2(String5),
19469
+ reuses: optionalKey2(String5)
19449
19470
  });
19450
19471
  var ApproveChangeRequestResult = Union2([
19451
19472
  Struct({ approved: Literal2(true), reviewId: String5 }),
@@ -19504,6 +19525,7 @@ var PipelineStatus = Struct({
19504
19525
  runnerChecks: optionalKey2(ArraySchema(String5)),
19505
19526
  targetChecks: optionalKey2(ArraySchema(String5)),
19506
19527
  approved: optionalKey2(String5),
19528
+ reviewed: optionalKey2(Struct({ review: String5, notRun: optionalKey2(ArraySchema(String5)) })),
19507
19529
  repository: optionalKey2(String5),
19508
19530
  sourceBranch: optionalKey2(String5),
19509
19531
  targetBranch: optionalKey2(String5),
@@ -21096,6 +21118,7 @@ var Input = Struct({
21096
21118
  outcome: optional2(LoopOutcome),
21097
21119
  claims: optional2(ArraySchema(String5)),
21098
21120
  earlier: optional2(ArraySchema(MergedFinding)),
21121
+ reviewed: optional2(String5),
21099
21122
  failing: optional2(ArraySchema(String5)),
21100
21123
  notRun: optional2(ArraySchema(String5)),
21101
21124
  next: optional2(Literals(choices)),
@@ -21106,13 +21129,21 @@ var FollowUp = Struct({ id: String5, status: FollowUpStatus });
21106
21129
  var SeatFinding = Struct({
21107
21130
  ...Finding.fields,
21108
21131
  detail: FindingDetail,
21109
- approvedCode: optional2(Boolean3)
21132
+ approvedCode: optional2(Boolean3),
21133
+ rule: optional2(OneSentence),
21134
+ checked: optional2(ArraySchema(ShortStatement)),
21135
+ outsideFix: optional2(Boolean3)
21110
21136
  });
21137
+ var ReviewedScope = Struct({
21138
+ ...ScopeJudgement.fields,
21139
+ reported: optional2(ArraySchema(String5))
21140
+ });
21141
+ var agreedScope = (scope) => scope.unmet.length === 0 && (scope.reported ?? []).length > 0 ? { ...scope, met: true } : scope;
21111
21142
  var SeatOutput = Struct({
21112
21143
  summary: OneSentence,
21113
21144
  findings: ArraySchema(SeatFinding),
21114
21145
  verdicts: optional2(ArraySchema(RebuttalVerdict)),
21115
- scope: optional2(ScopeJudgement),
21146
+ scope: optional2(ReviewedScope),
21116
21147
  followUps: optional2(ArraySchema(FollowUp))
21117
21148
  });
21118
21149
  var Output = Struct({
@@ -21123,7 +21154,8 @@ var Output = Struct({
21123
21154
  verdicts: ArraySchema(RebuttalVerdict),
21124
21155
  blocking: Boolean3,
21125
21156
  artifactId: String5,
21126
- scope: optional2(ScopeJudgement),
21157
+ scope: optional2(ReviewedScope),
21158
+ failing: optional2(ArraySchema(String5)),
21127
21159
  approval: optional2(Struct({ head: String5, approved: Boolean3, reason: optional2(String5) })),
21128
21160
  next: optional2(Struct({ choice: Literals(choices), detail: optional2(String5) })),
21129
21161
  deliversTo: optional2(ResolvedDeliveryTarget)
@@ -21184,7 +21216,7 @@ var pinnedRange = (input) => gen2(function* () {
21184
21216
  });
21185
21217
  var wholeChange = (input) => input.files === undefined && input.approved === undefined;
21186
21218
  var scopePrompt = (input) => [
21187
- "If your brief has a Task, judge its scope and give it as `scope`: does the change do what the Task's description and each of its Acceptance Criteria ask? Set `met` to true only if it does all of it, and list in `unmet` one line for each criterion or part of the description that is not done. If your brief has no Task, leave `scope` out.",
21219
+ "If your brief has a Task, judge its scope and give it as `scope`: does the change do what the Task's description and each of its Acceptance Criteria ask? Judge it against what is still agreed: a criterion or part an answer under your brief's Answers so far put out of scope is reported, not unmet; list each in `reported`, one line each, and leave it out of `unmet`. Set `met` to true only if the change does all the rest, and list in `unmet` one line for each other criterion or part of the description that is not done. If your brief has no Task, leave `scope` out.",
21188
21220
  ...input.outcome === undefined ? [] : [`The Outcome to prove is ${input.outcome}.`],
21189
21221
  ...input.claims === undefined || input.claims.length === 0 ? [] : [
21190
21222
  "The implementer claims it built these. Check them against the code rather than taking them on trust:",
@@ -21193,19 +21225,29 @@ var scopePrompt = (input) => [
21193
21225
  ].join(`
21194
21226
 
21195
21227
  `);
21228
+ var exhaustivePrompt = [
21229
+ "Review exhaustively, in this one pass. For each rule or check the change adds or alters, such as who may read or change what, a validation, a limit or a state transition, trace it through every caller and every input it can get before you report: each kind of actor, each visibility, Team and Project scope, and ids the caller gives.",
21230
+ "Report every finding of every severity in this one pass, grouped by the rule it breaks: do not stop at the first serious one in an area, and hold none back for a later round. Give each its `rule`, worded alike for every finding that breaks the same rule, and its `checked`: the sibling cases of that rule you checked and found fine, so the next round need not explore them again."
21231
+ ].join(" ");
21196
21232
  var earlierPrompt = (earlier) => [
21197
- "An earlier review found these. Give each as a `followUps` entry with its id: fixed, changed (the code moved but the problem stands) or still_there. Do not report them again as findings; review only what changed since, for new problems.",
21233
+ "An earlier review found these. Give each as a `followUps` entry with its id: fixed, changed (the code moved but the problem stands) or still_there. Do not report them again as findings.",
21198
21234
  ...earlier.map((finding) => `- ${finding.id} (${finding.severity}): ${finding.detail}`)
21199
21235
  ].join(`
21200
21236
  `);
21201
- var promptFor = (seat, target, input, failing, notRun) => [
21237
+ var fixRound = (input) => (input.earlier?.length ?? 0) > 0 || input.reviewed !== undefined;
21238
+ var fixPrompt = (fix) => `This round reviews ${fix} and the code it touches, exhaustively as above. Raise a new problem outside the fix and the code it touches only if it is a blocker; report one that is not as a minor with \`outsideFix\` set to true, which does not block landing.`;
21239
+ var fixOf = (input, head) => input.reviewed === undefined ? "the fix since the earlier review" : `the fix, \`git diff ${input.reviewed}..${head}\` (the target branch merged into it is not the fix),`;
21240
+ var promptFor = (seat, target, head, input, failing, notRun) => [
21202
21241
  `You are one of two reviewers. Follow your \`${seats[seat].skill}\` skill; if you do not have it: ${seats[seat].focus}`,
21203
21242
  `Review ${target}`,
21204
21243
  "Give `summary`: one sentence on whether it can merge and what matters most.",
21205
21244
  "Report each problem as a finding: severity blocker (must not ship), major (fix before merge) or minor (optional); the file path from the repository root; the line; and the detail. When it is one instance of a class of bug, name every other instance in the diff in its detail. Report nothing you have not checked in the code.",
21245
+ exhaustivePrompt,
21246
+ "What an answer under your brief's Answers so far put out of scope is reported, not missing: do not report it as a finding.",
21206
21247
  "If the diff is too big to review in one go, review it directory by directory and say so in a finding on the first file you skipped.",
21207
21248
  ...seat === scopeSeat && wholeChange(input) ? [scopePrompt(input)] : [],
21208
21249
  ...input.earlier === undefined || input.earlier.length === 0 ? [] : [earlierPrompt(input.earlier)],
21250
+ ...fixRound(input) ? [fixPrompt(fixOf(input, head))] : [],
21209
21251
  ...failing.length === 0 ? [] : [
21210
21252
  `These checks fail on this head and pass on the base: ${failing.join(", ")}. The implementer has their output, so do not report them as findings, and do not say it can merge while they fail.`
21211
21253
  ],
@@ -21224,6 +21266,35 @@ var promptFor = (seat, target, input, failing, notRun) => [
21224
21266
 
21225
21267
  `);
21226
21268
  var rank2 = { still_there: 0, changed: 1, fixed: 2 };
21269
+ var outsideFixAsMinor = (finding) => finding.outsideFix === true && finding.severity === "major" ? { ...finding, severity: "minor" } : finding;
21270
+ var detailOf = (detail, rule, checked) => [
21271
+ ...rule === undefined ? [] : [`[${rule}]`],
21272
+ detail,
21273
+ ...checked.length === 0 ? [] : [`Checked and fine: ${checked.join("; ")}.`]
21274
+ ].join(" ");
21275
+ var idOf = (finding) => `${finding.file}:${finding.line}`;
21276
+ var groupedByRule = (bySeat) => {
21277
+ const rules = new Map;
21278
+ const checked = new Map;
21279
+ for (const finding of Object.values(bySeat).flat()) {
21280
+ const id = idOf(finding);
21281
+ if (finding.rule !== undefined && !rules.has(id))
21282
+ rules.set(id, finding.rule);
21283
+ checked.set(id, new Set([...checked.get(id) ?? [], ...finding.checked ?? []]));
21284
+ }
21285
+ const findings = mergeFindings(Object.fromEntries(Object.entries(bySeat).map(([seat, seatFindings]) => [
21286
+ seat,
21287
+ seatFindings.map((finding) => ({
21288
+ severity: finding.severity,
21289
+ file: finding.file,
21290
+ line: finding.line,
21291
+ detail: detailOf(finding.detail, rules.get(idOf(finding)), [...checked.get(idOf(finding)) ?? []])
21292
+ }))
21293
+ ])));
21294
+ const groupOf = (finding) => rules.get(finding.id) ?? finding.id;
21295
+ const order = [...new Set(findings.map(groupOf))];
21296
+ return findings.toSorted((left, right) => order.indexOf(groupOf(left)) - order.indexOf(groupOf(right)));
21297
+ };
21227
21298
  var followUpsOf = (earlier, answers) => earlier.map((finding) => {
21228
21299
  const statuses = answers.flatMap((answer) => answer.id === finding.id ? [answer.status] : []);
21229
21300
  return {
@@ -21233,8 +21304,11 @@ var followUpsOf = (earlier, answers) => earlier.map((finding) => {
21233
21304
  });
21234
21305
  var findingLines = (findings) => findings.map((finding) => `- **${finding.severity}** \`${finding.id}\` ${finding.detail} _(${finding.seats.join(", ")})_`).join(`
21235
21306
  `);
21236
- var reviewText = (summary, findings, followUps, approvedFindings, notRun) => [
21307
+ var reviewText = (summary, findings, followUps, approvedFindings, notRun, reported) => [
21237
21308
  `**Kitman review.** ${summary}`,
21309
+ ...reported.length === 0 ? [] : [`Out of scope by an answer, so reported, not blocking:
21310
+ ${reported.map((item) => `- ${item}`).join(`
21311
+ `)}`],
21238
21312
  ...notRun.length === 0 ? [] : [`Verify never ran these tests, so they are unverified:
21239
21313
  ${notRun.map((item) => `- ${item}`).join(`
21240
21314
  `)}`],
@@ -21256,7 +21330,7 @@ var fixBrief = (changeRequestId, findings) => [
21256
21330
  `);
21257
21331
  var review_default = defineLoop({
21258
21332
  id: "review",
21259
- version: "3.8.0",
21333
+ version: "3.9.0",
21260
21334
  title: "Review",
21261
21335
  input: Input,
21262
21336
  output: Output,
@@ -21292,7 +21366,7 @@ var review_default = defineLoop({
21292
21366
  const notRun = [...new Set([...input.notRun ?? [], ...verified.notRun])];
21293
21367
  const outputs = yield* forEach2(seatNames, (seat) => agentWork(`review:${seat}`, {
21294
21368
  agent: seat,
21295
- prompt: promptFor(seat, target, input, failing, notRun),
21369
+ prompt: promptFor(seat, target, range.head, input, failing, notRun),
21296
21370
  output: SeatOutput
21297
21371
  }).pipe(map8((output) => [seat, output])), { concurrency: "unbounded" });
21298
21372
  const earlier = input.earlier ?? [];
@@ -21305,18 +21379,19 @@ var review_default = defineLoop({
21305
21379
  const carried = earlier.filter((finding) => standing.has(finding.id) && !withdrawn.has(finding.id));
21306
21380
  const followUps = answered.filter((entry) => !withdrawn.has(entry.id));
21307
21381
  const sinceApproval = input.approved !== undefined && input.files === undefined;
21308
- const merged = (approvedCode) => mergeFindings(Object.fromEntries(outputs.map(([seat, output]) => [
21382
+ const merged = (approvedCode) => groupedByRule(Object.fromEntries(outputs.map(([seat, output]) => [
21309
21383
  seat,
21310
- output.findings.filter((finding) => !earlierIds.has(`${finding.file}:${finding.line}`) && (sinceApproval && finding.approvedCode === true) === approvedCode)
21384
+ output.findings.filter((finding) => !earlierIds.has(`${finding.file}:${finding.line}`) && (sinceApproval && finding.approvedCode === true) === approvedCode).map((finding) => fixRound(input) ? outsideFixAsMinor(finding) : finding)
21311
21385
  ])));
21312
21386
  const fresh = merged(false);
21313
21387
  const approvedFindings = sinceApproval ? merged(true) : [];
21314
21388
  const findings = [...carried, ...fresh];
21315
21389
  const blockers = findings.filter(isBlocking);
21316
- const scope = wholeChange(input) ? outputs.find(([seat]) => seat === scopeSeat)?.[1].scope : undefined;
21390
+ const judged = wholeChange(input) ? outputs.find(([seat]) => seat === scopeSeat)?.[1].scope : undefined;
21391
+ const scope = judged === undefined ? undefined : agreedScope(judged);
21317
21392
  const summary = blockers.length > 0 ? `Blocking: fix ${blockers.map((finding) => finding.id).join(", ")} before merging.` : scope?.met === false ? "Not ready: the change does not yet do what was asked." : failing.length > 0 ? `Not ready: ${failing.join(", ")} fails on this head.` : notRun.length > 0 ? "Not ready: verify never ran some of its tests, so they are unverified." : findings.length === 0 ? sinceApproval ? `No findings in what changed since ${input.approved}: nothing stands in the way of merging.` : "No findings: nothing stands in the way of merging." : ["Can merge: nothing blocks it.", ...outputs.map(([, output]) => output.summary)].join(" ");
21318
21393
  const freshIds = new Set(fresh.map((finding) => finding.id));
21319
- const text = reviewText(summary, findings, followUps, approvedFindings, notRun);
21394
+ const text = reviewText(summary, findings, followUps, approvedFindings, notRun, scope?.reported ?? []);
21320
21395
  const stored = yield* artifact("findings", {
21321
21396
  kind: "review-findings",
21322
21397
  title: "Review findings",
@@ -21332,6 +21407,7 @@ var review_default = defineLoop({
21332
21407
  artifactId: stored.artifactId,
21333
21408
  ...approvedFindings.length === 0 ? undefined : { approvedFindings },
21334
21409
  ...scope === undefined ? undefined : { scope },
21410
+ ...failing.length === 0 ? undefined : { failing },
21335
21411
  ...input.deliversTo === undefined ? undefined : { deliversTo: input.deliversTo }
21336
21412
  };
21337
21413
  const changeRequestId = input.changeRequestId;
@@ -21367,6 +21443,8 @@ What next?`,
21367
21443
  words: fixBrief(changeRequestId, findings),
21368
21444
  changeRequestId,
21369
21445
  maxRounds: 2,
21446
+ reviewed: range.head,
21447
+ ...findings.length === 0 ? undefined : { earlier: findings },
21370
21448
  ...ownDeliveryTarget(input)
21371
21449
  });
21372
21450
  return { choice, detail: fixed.settled ? "Fixed and pushed" : `Pushed; left: ${fixed.unsettled.join("; ")}` };
@@ -21915,6 +21993,7 @@ var ShepherdOutput = Struct({
21915
21993
  reason: String5,
21916
21994
  fixRounds: Int,
21917
21995
  replies: Int,
21996
+ reused: optional2(ArraySchema(Struct({ review: String5, head: String5 }))),
21918
21997
  unsettled: optional2(ArraySchema(String5)),
21919
21998
  release: optional2(Struct({ runStatus: String5, reason: String5, tag: optional2(String5) })),
21920
21999
  releaseWhen: optional2(ResolvedReleaseTrigger),
@@ -21924,7 +22003,9 @@ var ShepherdOutput = Struct({
21924
22003
  changeRequestId: String5,
21925
22004
  words: String5,
21926
22005
  taskId: optional2(String5),
21927
- branch: optional2(String5)
22006
+ branch: optional2(String5),
22007
+ reviewed: optional2(String5),
22008
+ earlier: optional2(ArraySchema(MergedFinding))
21928
22009
  }))
21929
22010
  });
21930
22011
 
@@ -22114,7 +22195,7 @@ var repliesPrompt = (threads) => [
22114
22195
  var threadKey = (thread) => `${thread.id}:${thread.comments.length}`;
22115
22196
  var shepherd_default = defineLoop({
22116
22197
  id: "shepherd",
22117
- version: "1.8.0",
22198
+ version: "1.9.0",
22118
22199
  title: "Shepherd",
22119
22200
  input: Input3,
22120
22201
  output: Output3,
@@ -22150,6 +22231,7 @@ var shepherd_default = defineLoop({
22150
22231
  const ranOnRunner = new Set;
22151
22232
  const leftToPerson = new Set;
22152
22233
  let headFindings = [];
22234
+ let headFindingsAt;
22153
22235
  const unranAt = new Map;
22154
22236
  const rounds = { "ci-fix": 0, "head-fix": 0 };
22155
22237
  const allowed = { "ci-fix": 0, "head-fix": 0 };
@@ -22160,6 +22242,8 @@ var shepherd_default = defineLoop({
22160
22242
  let reviewOnceShown;
22161
22243
  let pipelineFirst;
22162
22244
  const reviewedHeads = new Set;
22245
+ const reused = [];
22246
+ const reuseTried = new Set;
22163
22247
  const approvalOf = new Map;
22164
22248
  let notCarried;
22165
22249
  let behind = false;
@@ -22182,6 +22266,7 @@ var shepherd_default = defineLoop({
22182
22266
  reason,
22183
22267
  fixRounds: fixRounds(),
22184
22268
  replies,
22269
+ ...reused.length === 0 ? undefined : { reused },
22185
22270
  ...input.releaseWhen === undefined ? undefined : { releaseWhen: input.releaseWhen },
22186
22271
  ...input.deliversTo === undefined ? undefined : { deliversTo: input.deliversTo },
22187
22272
  ...status === "needs_you" || status === "handed_back" ? { unsettled: [reason] } : undefined
@@ -22213,14 +22298,15 @@ var shepherd_default = defineLoop({
22213
22298
  }).pipe(catchTag2("WaitTimedOut", () => void_3));
22214
22299
  }
22215
22300
  });
22216
- const handBack = (reason, open) => ({
22301
+ const handBack = (reason, open, review) => ({
22217
22302
  ...done("handed_back", reason),
22218
22303
  handBack: {
22219
22304
  changeRequestId,
22220
22305
  words: `Shepherd handed ChangeRequest ${changeRequestId} back: ${reason}. Fix it forward on its branch:
22221
22306
  ${open}`,
22222
22307
  ...input.taskId === undefined ? undefined : { taskId: input.taskId },
22223
- ...target === "HEAD" ? undefined : { branch: target }
22308
+ ...target === "HEAD" ? undefined : { branch: target },
22309
+ ...review
22224
22310
  }
22225
22311
  });
22226
22312
  const takeTurn = () => gen2(function* () {
@@ -22449,12 +22535,13 @@ ${open}`,
22449
22535
  head,
22450
22536
  files: files.files,
22451
22537
  ...head === files.synced ? undefined : { since: files.synced },
22452
- ...files.earlier.length === 0 ? undefined : { earlier: files.earlier }
22538
+ ...files.earlier.length === 0 ? undefined : { earlier: files.earlier },
22539
+ ...files.reviewed === undefined ? undefined : { reviewed: files.reviewed }
22453
22540
  });
22454
22541
  if (reviewed.blocking) {
22455
22542
  const blocking = reviewed.findings.filter(isBlocking);
22456
22543
  if (!(yield* mayFix("head-fix", cycle, blocking.map((finding) => finding.id).join(", "))))
22457
- return stop(handBack(`The review of the catch-up merge's files still finds ${blocking.map((finding) => finding.id).join(", ")} after ${rounds["head-fix"]} head-fix rounds`, findingLines2(blocking)));
22544
+ return stop(handBack(`The review of the catch-up merge's files still finds ${blocking.map((finding) => finding.id).join(", ")} after ${rounds["head-fix"]} head-fix rounds`, findingLines2(blocking), { reviewed: head, earlier: reviewed.findings }));
22458
22545
  rounds["head-fix"]++;
22459
22546
  const fix = yield* agentWork(`review-fix:${cycle}`, {
22460
22547
  agent: "implementer",
@@ -22462,7 +22549,7 @@ ${open}`,
22462
22549
  output: ReviewFix,
22463
22550
  timeout: stepBudget
22464
22551
  });
22465
- unreviewed = { ...files, earlier: reviewed.findings };
22552
+ unreviewed = { ...files, earlier: reviewed.findings, reviewed: head };
22466
22553
  fixedFrom = { head, changed: fix.changed, looks: 0 };
22467
22554
  return { kind: "fixing" };
22468
22555
  }
@@ -22513,12 +22600,13 @@ ${open}`,
22513
22600
  head,
22514
22601
  ...notRun.length === 0 ? undefined : { notRun },
22515
22602
  ...since === undefined ? undefined : { approved: since },
22516
- ...headFindings.length === 0 ? undefined : { earlier: headFindings }
22603
+ ...headFindings.length === 0 ? undefined : { earlier: headFindings },
22604
+ ...headFindingsAt === undefined ? undefined : { reviewed: headFindingsAt }
22517
22605
  });
22518
22606
  if (reviewed.blocking) {
22519
22607
  const blocking = reviewed.findings.filter(isBlocking);
22520
22608
  if (!(yield* mayFix("head-fix", cycle, blocking.map((finding) => finding.id).join(", "))))
22521
- return stop(handBack(`The review of ${head} still finds ${blocking.map((finding) => finding.id).join(", ")} after ${rounds["head-fix"]} head-fix rounds`, findingLines2(blocking)));
22609
+ return stop(handBack(`The review of ${head} still finds ${blocking.map((finding) => finding.id).join(", ")} after ${rounds["head-fix"]} head-fix rounds`, findingLines2(blocking), { reviewed: head, earlier: reviewed.findings }));
22522
22610
  rounds["head-fix"]++;
22523
22611
  const fix = yield* agentWork(`head-fix:${cycle}`, {
22524
22612
  agent: "implementer",
@@ -22527,10 +22615,12 @@ ${open}`,
22527
22615
  timeout: stepBudget
22528
22616
  });
22529
22617
  headFindings = reviewed.findings;
22618
+ headFindingsAt = head;
22530
22619
  fixedFrom = { head, changed: fix.changed, looks: 0 };
22531
22620
  return { kind: "fixing" };
22532
22621
  }
22533
22622
  headFindings = [];
22623
+ headFindingsAt = undefined;
22534
22624
  if (notRun.length > 0)
22535
22625
  unranAt.set(head, { notRun, review: `head-review:${cycle}` });
22536
22626
  else {
@@ -22547,6 +22637,29 @@ ${open}`,
22547
22637
  reviewedHeads.add(head);
22548
22638
  return { kind: "reviewed" };
22549
22639
  });
22640
+ const reuseReview = (cycle, pipeline, reviewed) => gen2(function* () {
22641
+ const { head } = pipeline;
22642
+ reuseTried.add(head);
22643
+ const notRun = [...new Set([...input.notRun ?? [], ...reviewed.notRun ?? []])];
22644
+ if (notRun.length > 0) {
22645
+ unranAt.set(head, { notRun, reuses: reviewed.review });
22646
+ reviewedHeads.add(head);
22647
+ reused.push({ review: reviewed.review, head });
22648
+ return true;
22649
+ }
22650
+ const recorded = yield* approveChangeRequest(`reuse:${cycle}`, {
22651
+ changeRequestId,
22652
+ head,
22653
+ summary: `Review ${reviewed.review} passed the whole change at ${head}, so Shepherd approves it without reviewing it again.`,
22654
+ reuses: reviewed.review
22655
+ }).pipe(catchTag2("StepFailed", (error) => succeed7({ approved: false, reason: error.reason })));
22656
+ if (!recorded.approved)
22657
+ return false;
22658
+ approvalOf.set(head, recorded.reviewId);
22659
+ reviewedHeads.add(head);
22660
+ reused.push({ review: reviewed.review, head });
22661
+ return true;
22662
+ });
22550
22663
  const reviewCaughtUp = (cycle, pipeline) => gen2(function* () {
22551
22664
  const head = reviewOnceShown;
22552
22665
  reviewOnceShown = undefined;
@@ -22602,6 +22715,9 @@ ${open}`,
22602
22715
  else
22603
22716
  return found;
22604
22717
  }
22718
+ const reviewedElsewhere = pipeline.approved === pipeline.head || reviewedHeads.has(pipeline.head) || reuseTried.has(pipeline.head) ? undefined : pipeline.reviewed;
22719
+ if (reviewedElsewhere !== undefined && (yield* reuseReview(cycle, pipeline, reviewedElsewhere)))
22720
+ continue;
22605
22721
  const pipelineFailed = pipeline.status === "failed" || pipeline.status === "canceled";
22606
22722
  const blocked = pipeline.conflicts === true || pipeline.needsRebase === true && pipelineFailed;
22607
22723
  const caughtUpHead = pipeline.head === pipelineFirst;
@@ -22851,7 +22967,7 @@ Merge now?`,
22851
22967
  changeRequestId,
22852
22968
  head: pipeline.head,
22853
22969
  summary: `A review of ${pipeline.head} passed with nothing blocking; a person chose to merge it though verify never ran some of its tests.`,
22854
- review: unapproved.review
22970
+ ..."reuses" in unapproved ? { reuses: unapproved.reuses } : { review: unapproved.review }
22855
22971
  }).pipe(catchTag2("StepFailed", (error) => succeed7({ approved: false, reason: error.reason })));
22856
22972
  if (!recorded.approved)
22857
22973
  return done("needs_you", `The review of ${pipeline.head} passed, but did not approve it: ${recorded.reason}`);
@@ -22960,6 +23076,8 @@ var BuildInput = Struct({
22960
23076
  land: optional2(Boolean3),
22961
23077
  changeRequestId: optional2(String5),
22962
23078
  maxRebuilds: optional2(Int.check(isGreaterThanOrEqualTo2(0))),
23079
+ reviewed: optional2(String5),
23080
+ earlier: optional2(ArraySchema(MergedFinding)),
22963
23081
  ...DeliveryFields
22964
23082
  });
22965
23083
  var CriterionAnswer = Struct({
@@ -23006,6 +23124,7 @@ var BuildOutput = Struct({
23006
23124
  stopped: Literals(["settled", "dispute_stands", "findings_returned", "round_cap"]),
23007
23125
  criteria: ArraySchema(CriterionAnswer),
23008
23126
  notRun: optional2(ArraySchema(String5)),
23127
+ findings: optional2(ArraySchema(MergedFinding)),
23009
23128
  approval: optional2(ApproveChangeRequestResult),
23010
23129
  landed: optional2(ShepherdOutput),
23011
23130
  next: Struct({ changeRequestId: String5 }),
@@ -23055,7 +23174,7 @@ var implementPrompt = (task, outcome, continuing) => [
23055
23174
 
23056
23175
  `);
23057
23176
  var criteriaPrompt = (unanswered, unmet) => [
23058
- unanswered ? "You did not answer the Task's acceptance criteria. Answer each one before anyone reviews the change." : "These acceptance criteria are not met yet. Meet them, or say why they cannot be met here:",
23177
+ unanswered ? "You did not answer the Task's acceptance criteria. Answer each one before anyone reviews the change." : "These acceptance criteria are not met yet. Meet them, or say why they cannot be met here, such as an answer under Answers so far that put them out of scope; do not ask that Question again:",
23059
23178
  ...unmet.map((answer) => `- ${answer.criterion}: ${answer.detail}`),
23060
23179
  criteriaGuidance
23061
23180
  ].join(`
@@ -23078,7 +23197,7 @@ var reproducedOnBranchPrompt = (task) => [
23078
23197
  var findingLine = (finding) => `- **${finding.severity}** \`${finding.id}\` ${finding.detail}`;
23079
23198
  var disputeLine = ({ finding, rebuttal }) => `${findingLine(finding)}
23080
23199
  You rebutted: ${rebuttal.reason}`;
23081
- var fixPrompt = (settled) => {
23200
+ var fixPrompt2 = (settled) => {
23082
23201
  const checks = settled.open.filter((finding) => isCheckFinding(finding.id));
23083
23202
  const findings = settled.open.filter((finding) => !isCheckFinding(finding.id));
23084
23203
  return [
@@ -23107,7 +23226,7 @@ var rally = (input) => gen2(function* () {
23107
23226
  const claims = [...input.claims];
23108
23227
  const conflicts = [];
23109
23228
  let rebuttals = [];
23110
- let earlier = [];
23229
+ let earlier = input.earlier;
23111
23230
  let previous;
23112
23231
  let last;
23113
23232
  const shown = new Set;
@@ -23133,7 +23252,8 @@ var rally = (input) => gen2(function* () {
23133
23252
  head,
23134
23253
  decision: { stop: true, reason: "findings_returned", unsettled: blockingIds(last.settled) },
23135
23254
  claims,
23136
- conflicts
23255
+ conflicts,
23256
+ earlier
23137
23257
  };
23138
23258
  const failing = brokenChecks(head).map((check) => check.name);
23139
23259
  const notRun = testsNotRunReasons(head);
@@ -23142,6 +23262,7 @@ var rally = (input) => gen2(function* () {
23142
23262
  head: head.revision,
23143
23263
  ...rebuttals.length === 0 ? undefined : { rebuttals },
23144
23264
  ...earlier.length === 0 ? undefined : { earlier },
23265
+ ...last === undefined ? input.reviewed === undefined ? undefined : { reviewed: input.reviewed } : { reviewed: last.head.revision },
23145
23266
  ...input.outcome === undefined ? undefined : { outcome: input.outcome },
23146
23267
  ...failing.length === 0 ? undefined : { failing },
23147
23268
  ...notRun.length === 0 ? undefined : { notRun },
@@ -23162,12 +23283,12 @@ var rally = (input) => gen2(function* () {
23162
23283
  ...previous === undefined || unseen ? undefined : { previous }
23163
23284
  });
23164
23285
  if (decision.stop && (!unseen || round >= input.maxRounds))
23165
- return { round, head, settled, decision, claims, scope: reviewed.scope, conflicts };
23286
+ return { round, head, settled, decision, claims, scope: reviewed.scope, conflicts, earlier };
23166
23287
  for (const finding of checks)
23167
23288
  shown.add(finding.detail);
23168
23289
  const fixed = yield* agentWork(`fix:${round}`, {
23169
23290
  agent: "implementer",
23170
- prompt: fixPrompt(settled),
23291
+ prompt: fixPrompt2(settled),
23171
23292
  output: Fixed
23172
23293
  });
23173
23294
  claims.push(...fixed.claims, ...fixed.rebuttals.flatMap((rebuttal) => isCheckFinding(rebuttal.findingId) ? [`Rebutted ${rebuttal.findingId}: ${rebuttal.reason}`] : []));
@@ -23182,7 +23303,7 @@ var rally = (input) => gen2(function* () {
23182
23303
  });
23183
23304
  var build2 = defineLoop({
23184
23305
  id: "build",
23185
- version: "2.7.0",
23306
+ version: "2.8.0",
23186
23307
  title: "Build",
23187
23308
  input: BuildInput,
23188
23309
  output: BuildOutput,
@@ -23238,7 +23359,9 @@ var build2 = defineLoop({
23238
23359
  target,
23239
23360
  outcome,
23240
23361
  claims: [...implemented.claims, ...criteria.map((answer) => `Criterion ${answerLine(answer)}`)],
23241
- suggested: implemented.checks ?? []
23362
+ suggested: implemented.checks ?? [],
23363
+ reviewed: input.reviewed,
23364
+ earlier: input.earlier ?? []
23242
23365
  });
23243
23366
  const verdict = evidenceGate({
23244
23367
  ...outcome === undefined ? undefined : { outcome },
@@ -23288,6 +23411,7 @@ var build2 = defineLoop({
23288
23411
  stopped: last.decision.reason,
23289
23412
  criteria,
23290
23413
  ...lastNotRun.length === 0 ? undefined : { notRun: lastNotRun },
23414
+ ...last.earlier.length === 0 ? undefined : { findings: last.earlier },
23291
23415
  ...approval === undefined ? undefined : { approval }
23292
23416
  };
23293
23417
  const maxRebuilds = input.maxRebuilds ?? 1;
@@ -23343,6 +23467,8 @@ var build2 = defineLoop({
23343
23467
  ...input.maxRounds === undefined ? undefined : { maxRounds: input.maxRounds },
23344
23468
  changeRequestId: opened.id,
23345
23469
  land: false,
23470
+ reviewed: settledAs.revision,
23471
+ ...settledAs.findings === undefined ? undefined : { earlier: settledAs.findings },
23346
23472
  ...ownDeliveryTarget(input)
23347
23473
  }, { constraints: standing.map(standingConstraint) });
23348
23474
  settledAs = rebuilt;
@@ -23557,7 +23683,7 @@ var changePrompt = (discovery, plan, tried, cycle) => [
23557
23683
 
23558
23684
  `);
23559
23685
  var revertPrompt = (start, cycle) => `Cycle ${cycle}'s change did not prove faster. Revert its commits, and only those: run \`git revert --no-edit ${start}..HEAD\`. Touch no commit at or before ${start}, never reset or force-push, and change nothing else.`;
23560
- var fixPrompt2 = (findings) => [
23686
+ var fixPrompt3 = (findings) => [
23561
23687
  "The review of the climb found these. Fix each, keep behaviour exactly as it is and keep the gain, and commit. Kitman verifies and measures again; a fix that costs the gain ends the climb.",
23562
23688
  ...findings.map((finding) => `- ${finding.id}: ${finding.detail}`)
23563
23689
  ].join(`
@@ -23620,7 +23746,7 @@ var steadier = (plan) => {
23620
23746
  };
23621
23747
  var hillclimb_default = defineLoop({
23622
23748
  id: "hillclimb",
23623
- version: "1.3.0",
23749
+ version: "1.4.0",
23624
23750
  title: "Hillclimb",
23625
23751
  outcome: "performance",
23626
23752
  input: Input5,
@@ -23754,7 +23880,7 @@ var hillclimb_default = defineLoop({
23754
23880
  const blocking = reviewed.findings.filter(isBlocking);
23755
23881
  yield* agentWork(`fix:${round}`, {
23756
23882
  agent: "implementer",
23757
- prompt: fixPrompt2(blocking),
23883
+ prompt: fixPrompt3(blocking),
23758
23884
  output: Struct({ summary: OneSentence })
23759
23885
  });
23760
23886
  const fixed = yield* verify(`verify:fix:${round}`, {});
@@ -23765,6 +23891,7 @@ var hillclimb_default = defineLoop({
23765
23891
  final = yield* measure(`measure:fix:${round}`, { plan, base: baseline, head: fixed.revision, ...limits });
23766
23892
  if (final.verdict !== "gain")
23767
23893
  return yield* ending("gain_gone", `The review's fixes cost the gain: ${final.reason}`, final);
23894
+ const fixedFrom = head.revision;
23768
23895
  head = fixed;
23769
23896
  reviewed = yield* call(`review:${round + 1}`, review_default, {
23770
23897
  base: baseline,
@@ -23772,7 +23899,8 @@ var hillclimb_default = defineLoop({
23772
23899
  outcome: "performance",
23773
23900
  ...notRunOf(fixed),
23774
23901
  claims,
23775
- earlier: blocking
23902
+ earlier: blocking,
23903
+ reviewed: fixedFrom
23776
23904
  });
23777
23905
  }
23778
23906
  const notRun = testsNotRunReasons(head);
@@ -24152,7 +24280,10 @@ An earlier Build of this failed. ${retry.steer}` };
24152
24280
  branch: head.branch,
24153
24281
  revision: head.revision,
24154
24282
  land: false
24155
- }).pipe(catchTag2("ChildFailed", (failure) => succeed7(failure)));
24283
+ }).pipe(catchTags2({
24284
+ ChildFailed: (failure) => succeed7(failure),
24285
+ StepFailed: (refused) => refused.code === "task_run_unsettled" ? succeed7(new ChildFailed({ step: refused.step, loop: build_default.id, reason: refused.reason })) : fail7(refused)
24286
+ }));
24156
24287
  if (built instanceof ChildFailed)
24157
24288
  return settled(ticket, { status: "failed", repoBindingId: head.repoBindingId, reason: built.reason });
24158
24289
  const delivered = { repoBindingId: head.repoBindingId, changeRequest: built.changeRequest };
@@ -24248,6 +24379,7 @@ var deliveryBody = (plan, results) => {
24248
24379
  var implement = (input, plan, revision, filed) => gen2(function* () {
24249
24380
  const tasks = filed?.revision === revision ? filed.tasks : (yield* createTasks("tasks", {
24250
24381
  tickets: plan.tickets,
24382
+ builds: true,
24251
24383
  ...input.projectId === undefined ? undefined : { projectId: input.projectId }
24252
24384
  })).tasks;
24253
24385
  const taskOf = new Map(tasks.map((task) => [task.key, task.taskId]));
@@ -24352,6 +24484,19 @@ var plan_default = defineLoop({
24352
24484
  let opinions = 0;
24353
24485
  yield* storePlan(plan, "");
24354
24486
  const project = input.projectId === undefined ? undefined : { projectId: input.projectId };
24487
+ const held = new Map;
24488
+ let implementing = false;
24489
+ const file = (step) => gen2(function* () {
24490
+ const made = yield* createTasks(step, { tickets: plan.tickets, builds: true, ...project });
24491
+ for (const ticket of plan.tickets)
24492
+ held.set(ticket.key, ticket);
24493
+ filed = { revision, tasks: made.tasks };
24494
+ });
24495
+ const release = (building = []) => {
24496
+ const tickets = [...held.values()].filter((ticket) => !building.some((built) => built.key === ticket.key));
24497
+ held.clear();
24498
+ return tickets.length === 0 ? void_3 : asVoid2(createTasks("release-tasks", { tickets, releases: true, ...project }));
24499
+ };
24355
24500
  const ended = (rest) => ({
24356
24501
  title: plan.title,
24357
24502
  outOfScope: plan.outOfScope,
@@ -24363,81 +24508,83 @@ var plan_default = defineLoop({
24363
24508
  ...docs === undefined ? undefined : { docs },
24364
24509
  ...rest
24365
24510
  });
24366
- for (let round = 1;round <= maxRounds; round++) {
24367
- const isFiled = filed?.revision === revision;
24368
- const options = menu.filter((option) => !(option === "File as Tasks" && isFiled) && !(option === "Second opinion" && opinions >= maxOpinionsPerPlan));
24369
- const fallback = input.implement === true ? "Implement now" : isFiled ? "Finish" : "File as Tasks";
24370
- const answer = yield* ask(`next:${round}`, {
24371
- prompt: `What next for the plan "${plan.title}"?`,
24372
- options: options.map((option) => ({ value: option, description: menuDescriptions[option] })),
24373
- recommended: fallback,
24374
- recommendationReason: fallback === "Implement now" ? "You asked for the plan to be implemented." : fallback === "Finish" ? "The plan is filed as Tasks, so nothing is lost by finishing." : "Filing keeps the plan as Tasks a person or a Build can pick up later.",
24375
- default: fallback,
24376
- timeout: "1 hour"
24377
- });
24378
- const choice = menu.find((option) => option === answer) ?? fallback;
24379
- switch (choice) {
24380
- case "Finish":
24381
- return ended({ implemented: false });
24382
- case "Implement now": {
24383
- const delivered = yield* implement(input, plan, revision, filed);
24384
- return { ...ended({ implemented: true }), ...delivered };
24385
- }
24386
- case "File as Tasks": {
24387
- const made = yield* createTasks(`file-tasks:${round}`, { tickets: plan.tickets, ...project });
24388
- filed = { revision, tasks: made.tasks };
24389
- break;
24390
- }
24391
- case "Second opinion": {
24392
- opinions++;
24393
- const opinion = yield* agentWork(`second-opinion:${round}`, {
24394
- agent: "reviewer",
24395
- prompt: opinionPrompt(plan),
24396
- output: Opinion
24397
- });
24398
- yield* artifact(`opinion:${round}`, {
24399
- kind: "plan_review",
24400
- title: `Second opinion on ${plan.title}`,
24401
- text: [opinion.summary, ...opinion.concerns.map((concern) => `- ${concern}`)].join(`
24511
+ const decide = gen2(function* () {
24512
+ for (let round = 1;round <= maxRounds; round++) {
24513
+ const isFiled = filed?.revision === revision;
24514
+ const options = menu.filter((option) => !(option === "File as Tasks" && isFiled) && !(option === "Second opinion" && opinions >= maxOpinionsPerPlan));
24515
+ const fallback = input.implement === true ? "Implement now" : isFiled ? "Finish" : "File as Tasks";
24516
+ const answer = yield* ask(`next:${round}`, {
24517
+ prompt: `What next for the plan "${plan.title}"?`,
24518
+ options: options.map((option) => ({ value: option, description: menuDescriptions[option] })),
24519
+ recommended: fallback,
24520
+ recommendationReason: fallback === "Implement now" ? "You asked for the plan to be implemented." : fallback === "Finish" ? "The plan is filed as Tasks, so nothing is lost by finishing." : "Filing keeps the plan as Tasks a person or a Build can pick up later.",
24521
+ default: fallback,
24522
+ timeout: "1 hour"
24523
+ });
24524
+ const choice = menu.find((option) => option === answer) ?? fallback;
24525
+ switch (choice) {
24526
+ case "Finish":
24527
+ yield* release();
24528
+ return ended({ implemented: false });
24529
+ case "Implement now": {
24530
+ implementing = true;
24531
+ yield* release(plan.tickets);
24532
+ const delivered = yield* implement(input, plan, revision, filed);
24533
+ return { ...ended({ implemented: true }), ...delivered };
24534
+ }
24535
+ case "File as Tasks":
24536
+ yield* file(`file-tasks:${round}`);
24537
+ break;
24538
+ case "Second opinion": {
24539
+ opinions++;
24540
+ const opinion = yield* agentWork(`second-opinion:${round}`, {
24541
+ agent: "reviewer",
24542
+ prompt: opinionPrompt(plan),
24543
+ output: Opinion
24544
+ });
24545
+ yield* artifact(`opinion:${round}`, {
24546
+ kind: "plan_review",
24547
+ title: `Second opinion on ${plan.title}`,
24548
+ text: [opinion.summary, ...opinion.concerns.map((concern) => `- ${concern}`)].join(`
24402
24549
 
24403
24550
  `)
24404
- });
24405
- break;
24406
- }
24407
- case "Refine": {
24408
- const words = yield* ask(`refine:${round}`, {
24409
- prompt: "What should change in the plan?",
24410
- freeText: true,
24411
- informationOnly: true,
24412
- recommendationReason: "You chose to refine it, so only you know what should change."
24413
- });
24414
- const refined = yield* agentWorkOnce(`refine-plan:${round}`, {
24415
- agent: "planner",
24416
- prompt: refinePrompt(plan, words),
24417
- output: Plan
24418
- });
24419
- const before = plan;
24420
- revision++;
24421
- ({ plan, rejected } = yield* checked(refined, revision));
24422
- yield* storePlan(plan, `:${round}`);
24423
- yield* artifact(`changes:${round}`, {
24424
- kind: "plan_changes",
24425
- title: `Revision ${revision} of ${plan.title}`,
24426
- text: changelog(before, plan, words)
24427
- });
24428
- break;
24551
+ });
24552
+ break;
24553
+ }
24554
+ case "Refine": {
24555
+ const words = yield* ask(`refine:${round}`, {
24556
+ prompt: "What should change in the plan?",
24557
+ freeText: true,
24558
+ informationOnly: true,
24559
+ recommendationReason: "You chose to refine it, so only you know what should change."
24560
+ });
24561
+ const refined = yield* agentWorkOnce(`refine-plan:${round}`, {
24562
+ agent: "planner",
24563
+ prompt: refinePrompt(plan, words),
24564
+ output: Plan
24565
+ });
24566
+ const before = plan;
24567
+ revision++;
24568
+ ({ plan, rejected } = yield* checked(refined, revision));
24569
+ yield* storePlan(plan, `:${round}`);
24570
+ yield* artifact(`changes:${round}`, {
24571
+ kind: "plan_changes",
24572
+ title: `Revision ${revision} of ${plan.title}`,
24573
+ text: changelog(before, plan, words)
24574
+ });
24575
+ break;
24576
+ }
24429
24577
  }
24430
24578
  }
24431
- }
24432
- if (filed?.revision !== revision)
24433
- filed = {
24434
- revision,
24435
- tasks: (yield* createTasks("file-tasks:last", { tickets: plan.tickets, ...project })).tasks
24436
- };
24437
- return ended({
24438
- implemented: false,
24439
- stopped: `No decision after ${maxRounds} rounds, so the tickets are filed as Tasks for a person to pick up`
24579
+ if (filed?.revision !== revision)
24580
+ yield* file("file-tasks:last");
24581
+ yield* release();
24582
+ return ended({
24583
+ implemented: false,
24584
+ stopped: `No decision after ${maxRounds} rounds, so the tickets are filed as Tasks for a person to pick up`
24585
+ });
24440
24586
  });
24587
+ return yield* decide.pipe(tapError2(() => implementing ? void_3 : ignore2(release())));
24441
24588
  })
24442
24589
  });
24443
24590
 
@@ -24924,7 +25071,7 @@ var batchPrompt = (requests, target) => [
24924
25071
  ].join(`
24925
25072
 
24926
25073
  `);
24927
- var fixPrompt3 = (failed, applied) => [
25074
+ var fixPrompt4 = (failed, applied) => [
24928
25075
  `The batch of ${applied.map((number) => `!${number}`).join(", ")} fails these checks:`,
24929
25076
  ...failed.checks.filter((check) => check.status === "failed").map((check) => `- ${check.name}: \`${check.command}\``),
24930
25077
  "Fix what an update broke, the way its changelog says to. If an update cannot be fixed in a small change, take it back out and drop it with the reason. Commit nothing yourself."
@@ -25057,7 +25204,7 @@ var sweep_default = defineLoop({
25057
25204
  for (let round = 1;!checked.passed && round <= maxFixRounds && batched.applied.length > 0; round++) {
25058
25205
  batched = yield* agentWork(`fix:${round}`, {
25059
25206
  agent: "implementer",
25060
- prompt: fixPrompt3(checked, batched.applied),
25207
+ prompt: fixPrompt4(checked, batched.applied),
25061
25208
  output: Batched
25062
25209
  });
25063
25210
  for (const drop of batched.dropped)
@@ -28202,6 +28349,7 @@ class RunnerCapabilityRpcs extends make31(make30("PutQuestion", {
28202
28349
  runnerChecks: optionalKey2(ArraySchema(String5)),
28203
28350
  targetChecks: optionalKey2(ArraySchema(String5)),
28204
28351
  approved: optionalKey2(String5),
28352
+ reviewed: optionalKey2(Struct({ review: String5, notRun: optionalKey2(ArraySchema(String5)) })),
28205
28353
  repository: optionalKey2(String5),
28206
28354
  sourceBranch: optionalKey2(String5),
28207
28355
  targetBranch: optionalKey2(String5),
@@ -28333,13 +28481,16 @@ class RunnerCapabilityRpcs extends make31(make30("PutQuestion", {
28333
28481
  payload: {
28334
28482
  lease: ProgramLease,
28335
28483
  projectId: optionalKey2(String5),
28484
+ builds: optionalKey2(Boolean3),
28485
+ releases: optionalKey2(Boolean3),
28336
28486
  tickets: ArraySchema(Struct({
28337
28487
  key: String5,
28338
28488
  title: String5,
28339
28489
  body: String5,
28340
28490
  acceptanceCriteria: ArraySchema(String5),
28341
28491
  blockedBy: ArraySchema(String5),
28342
- outcome: optionalKey2(Literals(["feature", "bug", "refactor", "investigation", "docs", "migration", "performance"]))
28492
+ outcome: optionalKey2(Literals(["feature", "bug", "refactor", "investigation", "docs", "migration", "performance"])),
28493
+ repoBindingId: optionalKey2(String5)
28343
28494
  }))
28344
28495
  },
28345
28496
  success: ArraySchema(Struct({ key: String5, taskId: String5 })),
@@ -28378,7 +28529,8 @@ class RunnerCapabilityRpcs extends make31(make30("PutQuestion", {
28378
28529
  head: String5,
28379
28530
  summary: String5,
28380
28531
  review: optionalKey2(String5),
28381
- carries: optionalKey2(String5)
28532
+ carries: optionalKey2(String5),
28533
+ reuses: optionalKey2(String5)
28382
28534
  },
28383
28535
  success: Union2([
28384
28536
  Struct({ approved: Literal2(true), reviewId: String5 }),
@@ -28732,7 +28884,10 @@ var runnerActivities = (capabilities, services) => ({
28732
28884
  file: { run: (request, step) => keepFile(capabilities, step, request).pipe(provideContext2(services)) },
28733
28885
  note: { run: (request, step) => requested(step, capabilities.recordNote({ step, ...request })) },
28734
28886
  createTasks: {
28735
- run: (request, step) => requested(step, map8(capabilities.createPlanTasks(request.tickets, request.projectId), (tasks) => ({ tasks })))
28887
+ run: (request, step) => requested(step, map8(capabilities.createPlanTasks(request.tickets, request.projectId, {
28888
+ ...request.builds === undefined ? undefined : { builds: request.builds },
28889
+ ...request.releases === undefined ? undefined : { releases: request.releases }
28890
+ }), (tasks) => ({ tasks })))
28736
28891
  },
28737
28892
  alertTask: { run: (request, step) => requested(step, capabilities.alertTask({ step, ...request })) },
28738
28893
  integrationBranch: {
@@ -28864,16 +29019,18 @@ var rpcProgramPorts = (rpc, work) => {
28864
29019
  ...rpcRunFiles(rpc, lease),
28865
29020
  recordNote: (note) => rpc.recordNote({ lease, ...note }),
28866
29021
  performHostEffect: (request) => rpc.performHostEffect({ lease, ...request, waitsWhenUnconfirmed: true }),
28867
- createPlanTasks: (tickets, projectId) => rpc.createPlanTasks({
29022
+ createPlanTasks: (tickets, projectId, pickup) => rpc.createPlanTasks({
28868
29023
  lease,
28869
29024
  ...projectId === undefined ? undefined : { projectId },
29025
+ ...pickup,
28870
29026
  tickets: tickets.map((ticket) => ({
28871
29027
  key: ticket.key,
28872
29028
  title: ticket.title,
28873
29029
  body: ticket.body,
28874
29030
  acceptanceCriteria: ticket.acceptanceCriteria,
28875
29031
  blockedBy: ticket.blockedBy,
28876
- ...ticket.outcome === undefined ? undefined : { outcome: ticket.outcome }
29032
+ ...ticket.outcome === undefined ? undefined : { outcome: ticket.outcome },
29033
+ ...ticket.repoBindingId === undefined ? undefined : { repoBindingId: ticket.repoBindingId }
28877
29034
  }))
28878
29035
  }),
28879
29036
  integrationBranch: (repoBindingId, base) => base === true ? rpc.deliveryBase({ lease }) : rpc.integrationBranch({ lease, ...repoBindingId === undefined ? undefined : { repoBindingId } }),
@@ -31148,4 +31305,4 @@ var runKit = (config, identity, packages) => {
31148
31305
  runMain2(program.pipe(flatMap3((code) => sync2(() => process.exit(code)))));
31149
31306
  };
31150
31307
  // .kitman-build-entry.ts
31151
- runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.12.0-rc.1" }, []);
31308
+ runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.12.0-rc.3" }, []);