@kitman-sh/software-engineering 0.50.1 → 0.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bundle.js CHANGED
@@ -24673,7 +24673,7 @@ var CriterionAnswer = Struct({
24673
24673
  detail: ShortStatement,
24674
24674
  ...outOfScopeCase
24675
24675
  });
24676
- var BuildOutput = Struct({
24676
+ var ChangeBuilt = Struct({
24677
24677
  changeRequest: ChangeRequestResult.annotate({ description: "The ChangeRequest the Build opened or fixed forward." }),
24678
24678
  revision: String5.annotate({ description: "The head commit the Build pushed." }),
24679
24679
  tree: String5.annotate({
@@ -24718,7 +24718,31 @@ var BuildOutput = Struct({
24718
24718
  description: "Where the Run's delivery landed and the layer it came from."
24719
24719
  })
24720
24720
  });
24721
- var Built = Struct(omit3(BuildOutput.fields, ["changeRequest", "landed", "next"]));
24721
+ var NothingToDo = Struct({
24722
+ status: Literal2("nothing_to_do").annotate({
24723
+ description: "Nothing needed changing: the implementer changed nothing, a fix reverted the change, or a rebuild found the ChangeRequest's change already on its target."
24724
+ }),
24725
+ summary: String5.annotate({
24726
+ description: "The implementer's summary, the evidence that nothing needed changing."
24727
+ }),
24728
+ claims: ArraySchema(String5).annotate({
24729
+ description: "The implementer's claims, which Kitman has not checked."
24730
+ }),
24731
+ criteria: ArraySchema(CriterionAnswer).annotate({
24732
+ description: "The implementer's answer to each Acceptance Criterion."
24733
+ }),
24734
+ revision: String5.annotate({ description: "The head, which is the base." }),
24735
+ tree: String5.annotate({ description: "The tree of that head." }),
24736
+ reverted: optionalKey2(Boolean3).annotate({
24737
+ description: "True when a fix after a review returned the head to the base, reverting the implementer's change."
24738
+ }),
24739
+ changeRequest: optionalKey2(ChangeRequestResult).annotate({
24740
+ description: "The open ChangeRequest a rebuild found with nothing left on it, for a person to close."
24741
+ })
24742
+ });
24743
+ var BuildOutput = Union2([ChangeBuilt, NothingToDo]);
24744
+ var isNothingToDo = (output) => ("status" in output);
24745
+ var Built = Struct(omit3(ChangeBuilt.fields, ["changeRequest", "landed", "next"]));
24722
24746
  var taskOf = (words) => words === undefined ? "the Task your brief describes." : `this: ${words}`;
24723
24747
 
24724
24748
  // src/agents.ts
@@ -28784,6 +28808,12 @@ class Reviewed extends TaggedClass2()("Reviewed", {
28784
28808
  }) {
28785
28809
  }
28786
28810
 
28811
+ class Unchanged extends TaggedClass2()("Unchanged", {
28812
+ head: VerifyResult,
28813
+ reverted: Boolean3
28814
+ }) {
28815
+ }
28816
+
28787
28817
  class SameEvidence extends TaggedClass2()("SameEvidence", headRead) {
28788
28818
  }
28789
28819
  var ShownFailure = Struct({ id: String5, detail: String5 });
@@ -28805,7 +28835,7 @@ var reviewed = step2("reviewed", {
28805
28835
  description: "A head already reviewed, and what the fixer was told of its failing checks; a head with its tree and evidence, and no failure the fixer was not told of, is not reviewed again."
28806
28836
  })
28807
28837
  },
28808
- success: Union2([Reviewed, SameEvidence]),
28838
+ success: Union2([Reviewed, SameEvidence, Unchanged]),
28809
28839
  error: BaseUnpinned,
28810
28840
  run: (payload) => gen2(function* () {
28811
28841
  const {
@@ -28833,6 +28863,8 @@ var reviewed = step2("reviewed", {
28833
28863
  message: verified === undefined ? `The Runner did not report which commit of ${target ?? "the default branch"} it merged in round ${payload.round}, so there is no base to review against; update the Runner` : "A head the caller verified is reviewed with no target merged in, so it needs a base to review against"
28834
28864
  });
28835
28865
  const head = verified ?? (yield* verify("verify", { suggested, ...extra === undefined ? undefined : { extra } }));
28866
+ if (head.revision === reviewBase)
28867
+ return new Unchanged({ head, reverted: payload.round > 1 });
28836
28868
  const found = {
28837
28869
  head,
28838
28870
  ...synced?.status === "conflict" ? { conflict: { files: synced.files, reason: synced.reason } } : undefined
@@ -28912,7 +28944,7 @@ var rallied = step2("rallied", {
28912
28944
  description: "An Effect to run after each fix, before the round that reviews it. A head it gives, having verified it, is reviewed as `verified` is. Failing with `Halted` ends the rally. The journal holds null for it."
28913
28945
  })
28914
28946
  },
28915
- success: Union2([Settled, DisputeStands, FindingsReturned, RoundCap]),
28947
+ success: Union2([Settled, DisputeStands, FindingsReturned, RoundCap, Unchanged]),
28916
28948
  error: Union2([BaseUnpinned, Halted]),
28917
28949
  run: ({ maxRounds, guidance, fixes = "open", afterFix, ...payload }) => gen2(function* () {
28918
28950
  const fixesOpen = fixes === "open";
@@ -28939,6 +28971,8 @@ var rallied = step2("rallied", {
28939
28971
  scope: last === undefined ? payload.scope : last.scope,
28940
28972
  known: fixesOpen && last !== undefined && rebuttals.length === 0 && onlyChecksBlock(last.settled) ? { head: last.head, shown: [...shown] } : undefined
28941
28973
  });
28974
+ if (found._tag === "Unchanged")
28975
+ return new Unchanged({ head: withoutOutput(found.head), reverted: found.reverted });
28942
28976
  const { head, conflict } = found;
28943
28977
  if (conflict !== undefined)
28944
28978
  conflicts.push(`Could not merge the target branch in round ${round}: ${conflict.files.join(", ")} (${conflict.reason})`);
@@ -29102,6 +29136,11 @@ class TakenOver extends TaggedClass2()("TakenOver", {}) {
29102
29136
  class Rebuilt extends TaggedClass2()("Rebuilt", { built: Built }) {
29103
29137
  }
29104
29138
 
29139
+ class RebuildUnchanged extends TaggedClass2()("RebuildUnchanged", {
29140
+ built: NothingToDo
29141
+ }) {
29142
+ }
29143
+
29105
29144
  class BuildBlocked extends TaggedError3()("BuildBlocked", {
29106
29145
  message: String5
29107
29146
  }) {
@@ -29126,7 +29165,7 @@ var standing = step2("standing", {
29126
29165
  }),
29127
29166
  build: Struct(pick(BuildInput.fields, ["words", "taskId", "repoBindingId", "outcome", "maxRounds", "deliversTo"])).annotate({ description: "The Build's own Input, which a rebuild is given too." })
29128
29167
  },
29129
- success: Union2([TakenOver, Rebuilt]),
29168
+ success: Union2([TakenOver, Rebuilt, RebuildUnchanged]),
29130
29169
  error: BuildBlocked,
29131
29170
  run: ({
29132
29171
  changeRequest,
@@ -29194,6 +29233,8 @@ var standing = step2("standing", {
29194
29233
  ...scope === undefined ? undefined : { scope },
29195
29234
  ...ownDeliveryTarget(build)
29196
29235
  }, { constraints: unsettled.map(standingConstraint) });
29236
+ if (isNothingToDo(rebuilt))
29237
+ return new RebuildUnchanged({ built: { ...rebuilt, changeRequest } });
29197
29238
  return new Rebuilt({ built: omit3(rebuilt, ["changeRequest", "landed", "next"]) });
29198
29239
  })
29199
29240
  });
@@ -29327,7 +29368,7 @@ var outputOf2 = (input, changeRequest, built) => ({
29327
29368
  });
29328
29369
  var build2 = defineLoop({
29329
29370
  id: "build",
29330
- version: "3.1.0",
29371
+ version: "4.0.0",
29331
29372
  title: "Build",
29332
29373
  description: "Implements a Task or words, reviews and fixes the change, and opens a ChangeRequest with its evidence.",
29333
29374
  input: BuildInput,
@@ -29381,6 +29422,22 @@ var build2 = defineLoop({
29381
29422
  afterMergeCriteria: answeredAs(change.criteria, cases, "after_merge"),
29382
29423
  scope: input.scope
29383
29424
  });
29425
+ if (last._tag === "Unchanged") {
29426
+ const { summary, claims, criteria } = change;
29427
+ const { revision, tree } = last.head;
29428
+ return {
29429
+ status: "nothing_to_do",
29430
+ output: {
29431
+ status: "nothing_to_do",
29432
+ summary,
29433
+ claims,
29434
+ criteria,
29435
+ revision,
29436
+ tree,
29437
+ ...last.reverted ? { reverted: true } : undefined
29438
+ }
29439
+ };
29440
+ }
29384
29441
  const gate = gated({ outcome, before, change, last, cases });
29385
29442
  const { changeRequest, approval } = yield* opened({
29386
29443
  title: change.title,
@@ -29406,6 +29463,8 @@ var build2 = defineLoop({
29406
29463
  });
29407
29464
  if (decided._tag === "TakenOver")
29408
29465
  return { status: "taken_over", output: outputOf2(input, changeRequest, built) };
29466
+ if (decided._tag === "RebuildUnchanged")
29467
+ return { status: "nothing_to_do", output: decided.built };
29409
29468
  built = decided.built;
29410
29469
  }
29411
29470
  const shepherded = yield* landed3({
@@ -30142,6 +30201,7 @@ ${followUps.map((entry) => `- \`${entry.id}\` ${entry.status.replace("_", " ")}`
30142
30201
 
30143
30202
  `);
30144
30203
  };
30204
+ var nothingNeeded = (built) => built.changeRequest === undefined ? `Nothing needed changing: ${built.summary}` : `Nothing needed changing, so close ${built.changeRequest.url}: ${built.summary}`;
30145
30205
  var fixBrief = (changeRequestId, findings, unmet) => [
30146
30206
  `Fix what a review of ChangeRequest ${changeRequestId} found, on its branch:`,
30147
30207
  ...findings.map((finding) => `- ${finding.id} (${finding.severity}): ${finding.detail}`),
@@ -30370,7 +30430,7 @@ What next?`,
30370
30430
  ...outOfScopeFindings.length === 0 ? undefined : { outOfScopeFindings },
30371
30431
  ...scope === undefined ? undefined : { scope },
30372
30432
  ...ownDeliveryTarget(input)
30373
- }).pipe(map8((fixed) => new Fixed2({
30433
+ }).pipe(map8((fixed) => isNothingToDo(fixed) ? new Done3({ choice, detail: nothingNeeded(fixed) }) : new Fixed2({
30374
30434
  choice,
30375
30435
  detail: fixed.settled ? "Fixed and pushed" : `Pushed; left: ${fixed.unsettled.join("; ")}`
30376
30436
  })), catchTag2("ChildFailed", (failed) => succeed7(new Done3({ choice, detail: failed.reason }))));
@@ -30378,7 +30438,7 @@ What next?`,
30378
30438
  return yield* call("build", buildLoop(), {
30379
30439
  words: fixBrief(changeRequestId, findings, scope?.unmet ?? []),
30380
30440
  ...ownDeliveryTarget(input)
30381
- }).pipe(map8((built) => new Built2({ choice, detail: built.changeRequest.url })), catchTag2("ChildFailed", (failed) => succeed7(new Done3({ choice, detail: failed.reason }))));
30441
+ }).pipe(map8((built) => isNothingToDo(built) ? new Done3({ choice, detail: nothingNeeded(built) }) : new Built2({ choice, detail: built.changeRequest.url })), catchTag2("ChildFailed", (failed) => succeed7(new Done3({ choice, detail: failed.reason }))));
30382
30442
  return new Done3({ choice, detail: "The review is kept as an artifact" });
30383
30443
  })
30384
30444
  });
@@ -30639,7 +30699,7 @@ var Output4 = Struct({
30639
30699
  }),
30640
30700
  summary: String5.annotate({ description: "What the Errand did, in a line." }),
30641
30701
  changeRequest: optional2(ChangeRequestResult).annotate({
30642
- description: "The ChangeRequest it opened, when it opened one."
30702
+ description: "The ChangeRequest it opened, or one a Build found nothing left on, for a person to close."
30643
30703
  })
30644
30704
  });
30645
30705
  var prompt3 = (words) => [
@@ -30746,6 +30806,12 @@ var errand_default = defineLoop({
30746
30806
  ...input.taskId === undefined ? undefined : { taskId: input.taskId },
30747
30807
  ...input.branch === undefined ? undefined : { branch: input.branch }
30748
30808
  });
30809
+ if (isNothingToDo(built))
30810
+ return {
30811
+ status: "done",
30812
+ summary: built.summary,
30813
+ ...built.changeRequest === undefined ? undefined : { changeRequest: built.changeRequest }
30814
+ };
30749
30815
  return { status: "handed_to_build", summary: errand.summary, changeRequest: built.changeRequest };
30750
30816
  }
30751
30817
  const { changeRequest } = yield* opened({
@@ -31462,6 +31528,8 @@ var hillclimb_default = defineLoop({
31462
31528
  }).pipe(catchTag2("Halted", (halt) => succeed7(halt)));
31463
31529
  if (rally._tag === "Halted")
31464
31530
  return yield* halted(rally, findings);
31531
+ if (rally._tag === "Unchanged")
31532
+ return yield* ending2("no_gain", "The reviewed head is the base, so it changes nothing", findings);
31465
31533
  const shipped = provenAt(rally.head, improvements) ?? (yield* measured({ ...gain, revision: rally.head.revision }));
31466
31534
  if (shipped._tag !== "Improved")
31467
31535
  return yield* unproven(shipped, findings);
@@ -31513,11 +31581,11 @@ var Output7 = Struct({
31513
31581
  description: "The Artifact holding the investigation's conclusion."
31514
31582
  }),
31515
31583
  resolvedDuring: Boolean3.annotate({ description: "It resolved on its own while it was being investigated." }),
31516
- fix: Literals(["none", "declined", "started", "failed"]).annotate({
31517
- description: "Whether a fix was started: none was offered, a person declined it, it started, or starting it failed."
31584
+ fix: Literals(["none", "declined", "started", "failed", "unneeded"]).annotate({
31585
+ description: "Whether a fix was started: none was offered, a person declined it, it started, starting it failed, or its Build found nothing needed changing."
31518
31586
  }),
31519
31587
  changeRequestUrl: optional2(String5).annotate({
31520
- description: "The fix's ChangeRequest, when a fix opened one."
31588
+ description: "The fix's ChangeRequest, when a fix opened one; with an unneeded fix, the one left open for a person to close."
31521
31589
  }),
31522
31590
  fixRequest: optional2(FixRequest).annotate({
31523
31591
  description: "The fix a person can still start from the Run's offer."
@@ -31637,6 +31705,11 @@ class FixStarted extends TaggedClass2()("FixStarted", { changeRequestUrl: String
31637
31705
 
31638
31706
  class FixFailed extends TaggedClass2()("FixFailed", {}) {
31639
31707
  }
31708
+
31709
+ class FixUnneeded extends TaggedClass2()("FixUnneeded", {
31710
+ changeRequestUrl: optionalKey2(String5)
31711
+ }) {
31712
+ }
31640
31713
  var fixOffered = step2("fixOffered", {
31641
31714
  payload: {
31642
31715
  summary: String5,
@@ -31648,7 +31721,7 @@ var fixOffered = step2("fixOffered", {
31648
31721
  taskId: optional2(String5),
31649
31722
  repoBindingId: optional2(String5)
31650
31723
  },
31651
- success: Union2([FixDeclined, FixStarted, FixFailed]),
31724
+ success: Union2([FixDeclined, FixStarted, FixFailed, FixUnneeded]),
31652
31725
  run: ({ summary, fix, fixRequest, confident, resolvedDuring, autoFix, taskId, repoBindingId }) => gen2(function* () {
31653
31726
  const answer = yield* ask("start-fix", {
31654
31727
  prompt: `${summary}
@@ -31669,12 +31742,12 @@ Start a Build that fixes it as a bug: ${fix}?`,
31669
31742
  ...fixRequest,
31670
31743
  ...taskId === undefined ? undefined : { taskId },
31671
31744
  ...repoBindingId === undefined ? undefined : { repoBindingId }
31672
- }).pipe(map8((fixed) => new FixStarted({ changeRequestUrl: fixed.changeRequest.url })), catchTag2("ChildFailed", () => succeed7(new FixFailed)));
31745
+ }).pipe(map8((fixed) => isNothingToDo(fixed) ? new FixUnneeded(fixed.changeRequest === undefined ? {} : { changeRequestUrl: fixed.changeRequest.url }) : new FixStarted({ changeRequestUrl: fixed.changeRequest.url })), catchTag2("ChildFailed", () => succeed7(new FixFailed)));
31673
31746
  })
31674
31747
  });
31675
31748
  var firewatch_default = defineLoop({
31676
31749
  id: "firewatch",
31677
- version: "2.0.0",
31750
+ version: "2.1.0",
31678
31751
  title: "Firewatch",
31679
31752
  description: "Investigates an alert and writes its cited cause on a Bug Task, offering a fix.",
31680
31753
  input: Input7,
@@ -31735,6 +31808,12 @@ ${conclusionText(conclusion, resolvedDuring)}`,
31735
31808
  return { ...ended, fix: "started", changeRequestUrl: offered.changeRequestUrl };
31736
31809
  if (offered._tag === "FixFailed")
31737
31810
  return { ...ended, fix: "failed", fixRequest };
31811
+ if (offered._tag === "FixUnneeded")
31812
+ return {
31813
+ ...ended,
31814
+ fix: "unneeded",
31815
+ ...offered.changeRequestUrl === undefined ? undefined : { changeRequestUrl: offered.changeRequestUrl }
31816
+ };
31738
31817
  return { ...ended, fix: "declined", fixRequest };
31739
31818
  })
31740
31819
  });
@@ -32189,7 +32268,8 @@ var unmerged = {
32189
32268
 
32190
32269
  class Merged2 extends TaggedClass2()("Merged", {
32191
32270
  repoBindingId: String5,
32192
- changeRequest: ChangeRequestResult
32271
+ changeRequest: optionalKey2(ChangeRequestResult),
32272
+ reason: optionalKey2(String5)
32193
32273
  }) {
32194
32274
  }
32195
32275
 
@@ -32222,7 +32302,8 @@ var resultOf = ({ key, title }, outcome) => {
32222
32302
  title,
32223
32303
  status: "merged",
32224
32304
  repoBindingId: outcome.repoBindingId,
32225
- changeRequest: outcome.changeRequest
32305
+ ...outcome.changeRequest === undefined ? undefined : { changeRequest: outcome.changeRequest },
32306
+ ...outcome.reason === undefined ? undefined : { reason: outcome.reason }
32226
32307
  };
32227
32308
  return {
32228
32309
  key,
@@ -32247,7 +32328,7 @@ var buildOf = {
32247
32328
  };
32248
32329
  var buildTried = step2("buildTried", {
32249
32330
  payload: buildOf,
32250
- success: Union2([Built3, Failed, Skipped]),
32331
+ success: Union2([Built3, Merged2, Failed, Skipped]),
32251
32332
  run: ({ ticket, head, taskId, steer }) => gen2(function* () {
32252
32333
  const words = steer === undefined ? taskId === undefined ? { words: buildWords(ticket) } : undefined : { words: `${buildWords(ticket)}
32253
32334
 
@@ -32265,6 +32346,8 @@ An earlier Build of this failed. ${steer}` };
32265
32346
  }));
32266
32347
  if (built instanceof ChildFailed)
32267
32348
  return new Failed({ repoBindingId: head.repoBindingId, reason: built.reason });
32349
+ if (isNothingToDo(built))
32350
+ return new Merged2({ repoBindingId: head.repoBindingId, reason: `Nothing needed changing: ${built.summary}` });
32268
32351
  if (built.notRun !== undefined && built.notRun.length > 0) {
32269
32352
  const unverified = yield* ask("unverified", {
32270
32353
  prompt: `Verify never ran some tests of the ChangeRequest for ${ticket.key} (${built.changeRequest.url}):
@@ -33335,7 +33418,7 @@ var improved = step2("improved", {
33335
33418
  key: ({ key }) => key,
33336
33419
  run: ({ key, size, words, taskId }) => {
33337
33420
  const on = { words, taskId };
33338
- const started = size === "errand" ? map8(call("improve", errand_default, on), (done) => done.status) : map8(call("improve", build_default, on), (built) => built.stopped);
33421
+ const started = size === "errand" ? map8(call("improve", errand_default, on), (done) => done.status) : map8(call("improve", build_default, on), (built) => isNothingToDo(built) ? built.changeRequest === undefined ? built.status : `${built.status}: close ${built.changeRequest.url}` : built.stopped);
33339
33422
  return started.pipe(catchTag2("ChildFailed", (failed) => succeed7(`failed: ${failed.reason}`)), map8((outcome) => ({ key, loop: size, outcome })));
33340
33423
  }
33341
33424
  });
@@ -40205,4 +40288,4 @@ var runKit = (config, identity, packages) => {
40205
40288
  runMain2(program.pipe(flatMap3((code) => sync2(() => process.exit(code)))));
40206
40289
  };
40207
40290
  // .kitman-build-entry.ts
40208
- runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.50.1" }, []);
40291
+ runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.51.0" }, []);