@kitman-sh/software-engineering 0.49.0 → 0.50.1

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
@@ -13902,6 +13902,15 @@ var AttemptTokens = Union2([TokenUsage, Literal2("none")]);
13902
13902
  var TokenTotalCount = String5.check(isPattern2(/^(?:0|[1-9][0-9]*)$/));
13903
13903
  var TokenTotal = Struct({ input: TokenTotalCount, output: TokenTotalCount, cached: TokenTotalCount });
13904
13904
 
13905
+ // ../../packages/core/src/json.ts
13906
+ var JsonFromString = fromJsonString2(Json2);
13907
+ var decodeJsonString = decodeUnknownEffect2(JsonFromString);
13908
+ var decodeJsonStringOption = decodeUnknownOption2(JsonFromString);
13909
+ var encodeJsonStringSync = encodeSync(JsonFromString);
13910
+ var encodePrettyJsonString = encodeEffect(fromJsonString2(Json2, { space: 2 }));
13911
+ var decodeJsonStringSync = decodeUnknownSync(JsonFromString);
13912
+ var encodeUnknownJsonStringSync = encodeSync(fromJsonString2(Unknown2));
13913
+
13905
13914
  // ../../packages/core/src/loop-outline.ts
13906
13915
  var at = String5;
13907
13916
  var Nodes = ArraySchema(suspend3(() => OutlineNode));
@@ -14105,15 +14114,6 @@ var failedFileLine = new RegExp(`^${failedFileStart}((?:${failedFilePaths.join("
14105
14114
  var attempt = String.raw`(?:\d+ times in )?(?:initial run|\d+[a-z]{2} (?:retry(?: of \d+[a-z]{2} repeat)?|repeat))`;
14106
14115
  var vitestAttempts = new RegExp(String.raw` \(${attempt}(?:, ${attempt})*\)$`, "u");
14107
14116
 
14108
- // ../../packages/core/src/json.ts
14109
- var JsonFromString = fromJsonString2(Json2);
14110
- var decodeJsonString = decodeUnknownEffect2(JsonFromString);
14111
- var decodeJsonStringOption = decodeUnknownOption2(JsonFromString);
14112
- var encodeJsonStringSync = encodeSync(JsonFromString);
14113
- var encodePrettyJsonString = encodeEffect(fromJsonString2(Json2, { space: 2 }));
14114
- var decodeJsonStringSync = decodeUnknownSync(JsonFromString);
14115
- var encodeUnknownJsonStringSync = encodeSync(fromJsonString2(Unknown2));
14116
-
14117
14117
  // ../../packages/core/src/question-answer.ts
14118
14118
  var AnswerSchemaJson = Record(String5, Json2);
14119
14119
  var description = optionalKey2(String5);
@@ -20259,6 +20259,7 @@ var EvidenceCheck = Struct({
20259
20259
  outputTail: optionalKey2(String5),
20260
20260
  failedTests: optionalKey2(ArraySchema(String5)),
20261
20261
  suggested: optionalKey2(Boolean3),
20262
+ notStarted: optionalKey2(Boolean3),
20262
20263
  skippedSinceBaseline: optionalKey2(ArraySchema(String5)),
20263
20264
  newNotRun: optionalKey2(ArraySchema(String5)),
20264
20265
  environmentFailure: optionalKey2(Struct({
@@ -20273,7 +20274,12 @@ var VerifyResult = Struct({
20273
20274
  tree: String5,
20274
20275
  passed: Boolean3,
20275
20276
  unchanged: optionalKey2(Boolean3),
20276
- checks: ArraySchema(EvidenceCheck)
20277
+ checks: ArraySchema(EvidenceCheck),
20278
+ runnable: optionalKey2(ArraySchema(Struct({
20279
+ name: String5,
20280
+ command: String5,
20281
+ workingDirectory: optionalKey2(String5)
20282
+ })))
20277
20283
  });
20278
20284
  var verdict = (reasons) => reasons.length === 0 ? { settled: true } : { settled: false, reasons };
20279
20285
  var missing2 = (side) => `No verification evidence for the ${side}`;
@@ -23077,10 +23083,16 @@ var WorkUnitHeartbeatResult = Struct({
23077
23083
  questionOpen: optionalKey2(Boolean3),
23078
23084
  revokedSecrets: optionalKey2(ArraySchema(SecretName))
23079
23085
  });
23086
+ var programCrashOutputChars = 4000;
23087
+ var ProgramCrash = Struct({
23088
+ reason: String5.check(isMinLength(1), isMaxLength(500)),
23089
+ output: optionalKey2(String5.check(isMinLength(1), isMaxLength(programCrashOutputChars))),
23090
+ outputCut: optionalKey2(Boolean3)
23091
+ });
23080
23092
  var WorkUnitReleaseInput = Struct({
23081
23093
  workUnitId: Id,
23082
23094
  lease: WorkUnitLeaseInput,
23083
- crashed: optionalKey2(Struct({ reason: String5.check(isMinLength(1), isMaxLength(500)) })),
23095
+ crashed: optionalKey2(ProgramCrash),
23084
23096
  tokens: optionalKey2(AttemptTokens),
23085
23097
  ranModel: optionalKey2(String5.check(isMinLength(1), isMaxLength(200)))
23086
23098
  });
@@ -23560,6 +23572,7 @@ var scriptedHost = (script, engine, agentLaunches, childLaunches, waits, verifyL
23560
23572
  step: launch.step,
23561
23573
  ...launch.revision === undefined ? undefined : { revision: launch.revision },
23562
23574
  ...launch.checks === undefined ? undefined : { checks: launch.checks },
23575
+ ...launch.suggested === undefined ? undefined : { suggested: launch.suggested },
23563
23576
  ...launch.extra === undefined ? undefined : { extra: launch.extra },
23564
23577
  ...launch.rerunFailed === undefined ? undefined : { rerunFailed: launch.rerunFailed }
23565
23578
  });
@@ -23568,7 +23581,11 @@ var scriptedHost = (script, engine, agentLaunches, childLaunches, waits, verifyL
23568
23581
  const flat = Array.from({ length: launch.measure.samples }, () => Object.fromEntries(launch.measure?.plan.metrics.map((metric) => [metric.name, 100]) ?? []));
23569
23582
  return resolve(measureDeferred(launch.step), launch.token, measured instanceof ScriptedFailure ? fail5(new StepFailed({ step: launch.step, reason: measured.reason })) : succeed4(measured ?? { base: flat, head: flat, ...launch.measure.calibrate ? { baseAgain: flat } : undefined }));
23570
23583
  }
23571
- return resolve(verifyDeferred(launch.step), launch.token, scripted instanceof ScriptedFailure ? fail5(new StepFailed({ step: launch.step, reason: scripted.reason })) : succeed4(scripted ?? {
23584
+ return resolve(verifyDeferred(launch.step), launch.token, scripted instanceof ScriptedFailure ? fail5(new StepFailed({
23585
+ step: launch.step,
23586
+ reason: scripted.reason,
23587
+ ...scripted.code === undefined ? undefined : { code: scripted.code }
23588
+ })) : succeed4(scripted ?? {
23572
23589
  revision: launch.revision ?? "head",
23573
23590
  tree: launch.revision ?? "head",
23574
23591
  passed: true,
@@ -24712,9 +24729,62 @@ var reviewer = agent("reviewer");
24712
24729
 
24713
24730
  // src/suggested-check.ts
24714
24731
  var SuggestedCheck = Struct({
24715
- name: CheckName,
24716
- command: String5,
24717
- workingDirectory: optionalKey2(String5)
24732
+ name: ApprovedCheck.fields.name,
24733
+ command: ApprovedCheck.fields.command,
24734
+ workingDirectory: ApprovedCheck.fields.workingDirectory
24735
+ });
24736
+ var checkRefusals = ["Already a check of this repository with another command", "Two checks named", "Could not start"];
24737
+ var refusedCheck = (error) => error.code === "step_refused" && checkRefusals.some((refusal) => error.reason.startsWith(refusal));
24738
+ var sameCommand = (one, other) => one.command === other.command && one.workingDirectory === other.workingDirectory;
24739
+ var clashingChecks = (step, checks) => {
24740
+ const twice = [
24741
+ ...new Set(checks.flatMap((check, index) => checks.slice(0, index).some((other) => other.name === check.name && !sameCommand(other, check)) ? [check.name] : []))
24742
+ ];
24743
+ return twice.length === 0 ? undefined : new StepFailed({
24744
+ step,
24745
+ code: "step_refused",
24746
+ reason: `Two checks named with different commands: ${twice.join(", ")}; give each check its own name`
24747
+ });
24748
+ };
24749
+ var unstartedChecks = (result, named) => result.checks.filter((check) => check.notStarted === true && named.some((one) => one.name === check.name && one.command === check.command));
24750
+ var unstartedRefusal = (step, result, named) => {
24751
+ const unstarted = unstartedChecks(result, named);
24752
+ return unstarted.length === 0 ? undefined : new StepFailed({
24753
+ step,
24754
+ code: "step_refused",
24755
+ reason: [
24756
+ `Could not start: ${unstarted.map((check) => `${check.name}: \`${check.command}\` printed ${JSON.stringify(check.outputTail ?? "")}`).join("; ")}`,
24757
+ (result.runnable ?? []).length === 0 ? "The repository approves no checks" : `Its checks are ${(result.runnable ?? []).map(shownCheck).join("; ")}`
24758
+ ].join(". ")
24759
+ });
24760
+ };
24761
+ var Renamed = Struct({
24762
+ renamed: Record(String5, CheckName),
24763
+ commands: optional2(Record(String5, Struct({
24764
+ command: SuggestedCheck.fields.command,
24765
+ workingDirectory: SuggestedCheck.fields.workingDirectory
24766
+ })))
24767
+ });
24768
+ var shownCheck = (check) => `${check.name}: \`${check.command}\`${check.workingDirectory === undefined ? "" : ` in ${check.workingDirectory}`}`;
24769
+ var numbered = (check, index) => `${index + 1}. ${shownCheck(check)}`;
24770
+ var renamePrompt = (reason, named, kept = []) => [
24771
+ `Kitman will not run the checks you named: ${reason}`,
24772
+ ["You named:", ...named.map(numbered)].join(`
24773
+ `),
24774
+ ...kept.length === 0 ? [] : [["These keep their names:", ...kept.map((check) => `- ${shownCheck(check)}`)].join(`
24775
+ `)],
24776
+ "Give in `renamed`, keyed by each one's number, a new name of letters, digits, `.`, `_`, `:` and `-` that no other check has, for each you rename. Kitman keeps each command and runs it under its new name, except one that could not start: give it, in `commands` under its number, a command that runs in this repository, or one of its checks exactly with that check's name. Change nothing in the workspace."
24777
+ ].join(`
24778
+
24779
+ `);
24780
+ var renamedChecks = (named, renamed) => named.map((check, index) => {
24781
+ const key = String(index + 1);
24782
+ const run = renamed.commands?.[key] ?? check;
24783
+ return {
24784
+ name: renamed.renamed[key] ?? check.name,
24785
+ command: run.command,
24786
+ ...run.workingDirectory === undefined ? undefined : { workingDirectory: run.workingDirectory }
24787
+ };
24718
24788
  });
24719
24789
 
24720
24790
  // src/implemented.ts
@@ -24722,19 +24792,20 @@ var Change = Struct({
24722
24792
  title: String5,
24723
24793
  summary: ChangeRequestSummary,
24724
24794
  claims: ArraySchema(ShortStatement),
24725
- documented: optional2(ArraySchema(String5)),
24726
- rollback: optional2(String5),
24795
+ documented: optional2(ArraySchema(SuggestedCheck)),
24796
+ rollback: optional2(SuggestedCheck),
24727
24797
  criteria: optional2(ArraySchema(CriterionAnswer)),
24728
24798
  checks: optional2(ArraySchema(SuggestedCheck))
24729
24799
  });
24730
24800
  var Criteria = Struct({ criteria: ArraySchema(CriterionAnswer) });
24801
+ var proofGuidance = "Give each the command itself, with a `name` of letters, digits, `.`, `_`, `:` and `-` that no check of the repository has, unless it is exactly an approved check's name, command and directory. Kitman runs them on every head; a narrower command than an approved check is its own check.";
24731
24802
  var outcomeGuidance = {
24732
24803
  feature: "Deliver the whole scope; review checks it was met.",
24733
24804
  bug: "Your failing test is already in place: make it pass.",
24734
24805
  refactor: "Keep behaviour exactly as it is; the approved verifications must pass before and after.",
24735
24806
  investigation: "Investigate and report what you found, with its sources.",
24736
- docs: "Name, in `documented`, the approved checks that run the commands you documented.",
24737
- migration: "Name, in `rollback`, the approved check that rolls the migration back.",
24807
+ docs: `Name, in \`documented\`, a check for each command you documented that runs exactly it. ${proofGuidance}`,
24808
+ migration: `Name, in \`rollback\`, the check that rolls the migration back. ${proofGuidance}`,
24738
24809
  performance: "Make it faster without changing behaviour."
24739
24810
  };
24740
24811
  var criteriaGuidance = "If your brief has a Task, answer each of its acceptance criteria in `criteria`: met, with the test or file that shows it; after_merge, with why it can only be seen once merged; or not_met, with why. Give an empty `criteria` when the Task has none.";
@@ -24768,6 +24839,40 @@ var criteriaPrompt = (unanswered, unmet, cases) => [
24768
24839
  ].join(`
24769
24840
 
24770
24841
  `);
24842
+ var proofsOf = (outcome, change) => {
24843
+ if (outcome === "docs")
24844
+ return change.documented ?? [];
24845
+ return outcome === "migration" && change.rollback !== undefined ? [change.rollback] : [];
24846
+ };
24847
+ var runnableProofs = (outcome, change, reproducing) => gen2(function* () {
24848
+ const kept = reproducing === undefined ? [] : [reproducing];
24849
+ const checked = ({
24850
+ checks,
24851
+ proofs
24852
+ }, verified) => proofs.length === 0 ? suspend2(() => {
24853
+ const clash = clashingChecks("implemented", [...kept, ...checks]);
24854
+ return clash === undefined ? void_3 : fail7(clash);
24855
+ }) : verified({ checks: [], ...checks.length === 0 ? undefined : { suggested: checks }, extra: proofs }).pipe(flatMap3((result) => {
24856
+ const refusal = unstartedRefusal("implemented", result, proofs);
24857
+ return refusal === undefined ? void_3 : fail7(refusal);
24858
+ }));
24859
+ const named = { checks: change.checks ?? [], proofs: proofsOf(outcome, change) };
24860
+ const { checks, proofs } = yield* checked(named, (launch) => verify("proofs", launch)).pipe(as2(named), catchTag2("StepFailed", (error) => refusedCheck(error) ? gen2(function* () {
24861
+ const all = [...named.checks, ...named.proofs];
24862
+ const renamed = renamedChecks(all, yield* implementer("rename", { prompt: renamePrompt(error.reason, all, kept), output: Renamed }));
24863
+ const again = {
24864
+ checks: renamed.slice(0, named.checks.length),
24865
+ proofs: renamed.slice(named.checks.length)
24866
+ };
24867
+ yield* checked(again, (launch) => verify("proofs-renamed", launch));
24868
+ return again;
24869
+ }) : fail7(error)));
24870
+ return {
24871
+ ...change.checks === undefined ? undefined : { checks },
24872
+ ...outcome === "docs" && change.documented !== undefined ? { documented: proofs } : undefined,
24873
+ ...outcome === "migration" && change.rollback !== undefined ? { rollback: proofs[0] } : undefined
24874
+ };
24875
+ });
24771
24876
 
24772
24877
  class Implemented extends TaggedClass2()("Implemented", {
24773
24878
  ...Change.fields,
@@ -24787,12 +24892,15 @@ var implemented = step2("implemented", {
24787
24892
  cases: optional2(ArraySchema(String5)).annotate({
24788
24893
  description: "The Task's Out of scope list, which the implementer does not build."
24789
24894
  }),
24895
+ reproducing: optional2(SuggestedCheck).annotate({
24896
+ description: "The bug's reproducing check, whose name the implementer's checks may not take for another command."
24897
+ }),
24790
24898
  planReviewed: optional2(Boolean3).annotate({
24791
24899
  description: "Plan review passed the Task and this is its first implementation: the `planned-implementer` makes it."
24792
24900
  })
24793
24901
  },
24794
24902
  success: Implemented,
24795
- run: ({ words, taskId, outcome, continuing, cases = [], planReviewed }) => gen2(function* () {
24903
+ run: ({ words, taskId, outcome, continuing, cases = [], reproducing, planReviewed }) => gen2(function* () {
24796
24904
  const work = {
24797
24905
  skill: "implement",
24798
24906
  prompt: implementPrompt(taskOf(words), outcome, continuing, cases),
@@ -24801,13 +24909,8 @@ var implemented = step2("implemented", {
24801
24909
  const change = yield* planReviewed === true ? plannedImplementer("implement", work) : implementer("implement", work);
24802
24910
  const unanswered = taskId !== undefined && change.criteria === undefined;
24803
24911
  const unmet = (change.criteria ?? []).filter((answer) => answer.status === "not_met" && caseOf(cases, answer) === undefined);
24804
- if (!unanswered && unmet.length === 0)
24805
- return new Implemented({ ...change, criteria: change.criteria ?? [] });
24806
- const { criteria } = yield* implementer("criteria", {
24807
- prompt: criteriaPrompt(unanswered, unmet, cases),
24808
- output: Criteria
24809
- });
24810
- return new Implemented({ ...change, criteria });
24912
+ const { criteria } = !unanswered && unmet.length === 0 ? { criteria: change.criteria ?? [] } : yield* implementer("criteria", { prompt: criteriaPrompt(unanswered, unmet, cases), output: Criteria });
24913
+ return new Implemented({ ...change, ...yield* runnableProofs(outcome, change, reproducing), criteria });
24811
24914
  })
24812
24915
  });
24813
24916
 
@@ -28963,8 +29066,18 @@ var reproduced = step2("reproduced", {
28963
29066
  prompt: continuing === undefined ? reproducePrompt(task) : reproducedOnBranchPrompt(task),
28964
29067
  output: ReproducingTest
28965
29068
  });
28966
- const base = yield* verify("verify", { ...revision === undefined ? undefined : { revision }, extra: [check] });
28967
- return new Reproduced({ check, base: withoutOutput(base) });
29069
+ const verifyAt = (name, reproducing) => verify(name, { ...revision === undefined ? undefined : { revision }, extra: [reproducing] }).pipe(flatMap3((base) => {
29070
+ const refusal = unstartedRefusal(name, base, [reproducing]);
29071
+ return refusal === undefined ? succeed7(new Reproduced({ check: reproducing, base: withoutOutput(base) })) : fail7(refusal);
29072
+ }));
29073
+ return yield* verifyAt("verify", check).pipe(catchTag2("StepFailed", (error) => refusedCheck(error) ? gen2(function* () {
29074
+ const renamed = yield* implementer("rename", {
29075
+ prompt: renamePrompt(error.reason, [check]),
29076
+ output: Renamed
29077
+ });
29078
+ const [reproducing = check] = renamedChecks([check], renamed);
29079
+ return yield* verifyAt("verify-renamed", reproducing);
29080
+ }) : fail7(error)));
28968
29081
  })
28969
29082
  });
28970
29083
 
@@ -29157,8 +29270,8 @@ var gated = ({
29157
29270
  ...before._tag === "NotNeeded" ? undefined : { base: before.base },
29158
29271
  ...last.scope === undefined ? undefined : { review: last.scope },
29159
29272
  ...before._tag === "Reproduced" ? { reproducing: before.check.name } : undefined,
29160
- ...change.documented === undefined ? undefined : { documented: change.documented },
29161
- ...change.rollback === undefined ? undefined : { rollback: change.rollback }
29273
+ ...change.documented === undefined ? undefined : { documented: change.documented.map((check) => check.name) },
29274
+ ...change.rollback === undefined ? undefined : { rollback: change.rollback.name }
29162
29275
  });
29163
29276
  const stopped = stoppedAs[last._tag];
29164
29277
  const findings = codeFindings(last.settled);
@@ -29247,8 +29360,10 @@ var build2 = defineLoop({
29247
29360
  outcome,
29248
29361
  continuing,
29249
29362
  ...cases.length === 0 ? undefined : { cases },
29363
+ ...before._tag === "Reproduced" ? { reproducing: before.check } : undefined,
29250
29364
  ...input.planReviewed === true ? { planReviewed: true } : undefined
29251
29365
  });
29366
+ const proven = [...before._tag === "Reproduced" ? [before.check] : [], ...proofsOf(outcome, change)];
29252
29367
  const last = yield* rallied({
29253
29368
  fixer: "implementer",
29254
29369
  maxRounds: input.maxRounds ?? 3,
@@ -29256,7 +29371,7 @@ var build2 = defineLoop({
29256
29371
  outcome,
29257
29372
  claims: [...change.claims, ...change.criteria.map((answer) => `Criterion ${answerLine(answer, cases)}`)],
29258
29373
  suggested: change.checks ?? [],
29259
- extra: before._tag === "Reproduced" ? [before.check] : undefined,
29374
+ extra: proven.length === 0 ? undefined : proven,
29260
29375
  reviewed: input.reviewed,
29261
29376
  earlier: input.earlier,
29262
29377
  deliveredBy: input.changeRequestId,
@@ -40090,4 +40205,4 @@ var runKit = (config, identity, packages) => {
40090
40205
  runMain2(program.pipe(flatMap3((code) => sync2(() => process.exit(code)))));
40091
40206
  };
40092
40207
  // .kitman-build-entry.ts
40093
- runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.49.0" }, []);
40208
+ runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.50.1" }, []);