@kitman-sh/software-engineering 0.10.77 → 0.10.79
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 +37 -8
- package/dist/declarations.json +2 -2
- package/package.json +3 -3
- package/src/shepherd.ts +64 -14
package/dist/bundle.js
CHANGED
|
@@ -13478,6 +13478,8 @@ var LoopSafeReferenceString = String5.check(isMinLength(1), isMaxLength(240), is
|
|
|
13478
13478
|
var LoopSafeInternalReferenceString = String5.check(isMinLength(1), isMaxLength(240), isPattern2(new RegExp(LoopSafeInternalReferencePattern, "u")));
|
|
13479
13479
|
var LoopSafeText = String5.check(isMaxLength(4000), isPattern2(new RegExp(`^(?![\\s\\S]*(?:${LoopCredentialContentPattern}|[A-Za-z][A-Za-z0-9+.-]*://(?:[^\\s/?#]*@|[^\\s?#]*\\?)))[\\s\\S]*$`, "u")));
|
|
13480
13480
|
var recommendedDefault = (recommended) => recommended !== undefined && is2(LoopSafeText)(recommended) ? recommended : undefined;
|
|
13481
|
+
var unansweredQuestionLead = "Nobody answers in full auto, and the agent's Question has no answer to take";
|
|
13482
|
+
var isUnansweredQuestion = (reason) => reason.startsWith(unansweredQuestionLead);
|
|
13481
13483
|
var QuestionText = String5;
|
|
13482
13484
|
var LoopSafeOutputDataString = String5.check(isMaxLength(4000), isPattern2(new RegExp(LoopSafeInternalReferencePattern, "u")));
|
|
13483
13485
|
var LoopSafePackageName = String5.check(isMinLength(1), isMaxLength(200), isPattern2(new RegExp(LoopSafeReferencePattern, "u")));
|
|
@@ -19291,6 +19293,8 @@ var PipelineStatus = Struct({
|
|
|
19291
19293
|
runnerChecks: optionalKey2(ArraySchema(String5)),
|
|
19292
19294
|
approved: optionalKey2(String5),
|
|
19293
19295
|
repository: optionalKey2(String5),
|
|
19296
|
+
conflicts: optionalKey2(Boolean3),
|
|
19297
|
+
needsRebase: optionalKey2(Boolean3),
|
|
19294
19298
|
target: optionalKey2(Struct({ branch: String5, head: String5, jobs: ArraySchema(PipelineJob) }))
|
|
19295
19299
|
});
|
|
19296
19300
|
var ReviewThread = Struct({
|
|
@@ -21450,7 +21454,7 @@ var repliesPrompt = (threads) => [
|
|
|
21450
21454
|
var threadKey = (thread) => `${thread.id}:${thread.comments.length}`;
|
|
21451
21455
|
var shepherd_default = defineLoop({
|
|
21452
21456
|
id: "shepherd",
|
|
21453
|
-
version: "1.
|
|
21457
|
+
version: "1.5.0",
|
|
21454
21458
|
title: "Shepherd",
|
|
21455
21459
|
input: Input3,
|
|
21456
21460
|
output: Output3,
|
|
@@ -21489,6 +21493,9 @@ var shepherd_default = defineLoop({
|
|
|
21489
21493
|
let behind = false;
|
|
21490
21494
|
let pushed;
|
|
21491
21495
|
let fixedFrom;
|
|
21496
|
+
const syncedFor = new Set;
|
|
21497
|
+
const syncedKey = (head, targetHead) => `${head}@${targetHead}`;
|
|
21498
|
+
const blockerSynced = new Set;
|
|
21492
21499
|
let turn;
|
|
21493
21500
|
let turns = 0;
|
|
21494
21501
|
let passes = 0;
|
|
@@ -21618,13 +21625,14 @@ ${open}`,
|
|
|
21618
21625
|
redTarget = { head: pipeline.head, targetHead: pipeline.target?.head, moved: woke !== undefined };
|
|
21619
21626
|
return;
|
|
21620
21627
|
});
|
|
21621
|
-
const catchUp = (cycle) => gen2(function* () {
|
|
21628
|
+
const catchUp = (cycle, targetHead, forBlocker = false) => gen2(function* () {
|
|
21622
21629
|
const refused = yield* takeTurn();
|
|
21623
21630
|
if (refused !== undefined)
|
|
21624
21631
|
return done("needs_you", `The turn to merge into ${target} was refused: ${refused}`);
|
|
21625
21632
|
const synced = yield* syncBase(`sync:${cycle}`, { agent: "implementer", target });
|
|
21626
21633
|
if (synced.status === "conflict")
|
|
21627
|
-
return
|
|
21634
|
+
return handBack(`Merging ${target} in conflicts on ${synced.files.join(", ")}: ${synced.reason}`, synced.files.map((file) => `- ${file}`).join(`
|
|
21635
|
+
`));
|
|
21628
21636
|
if (synced.status !== "merged")
|
|
21629
21637
|
return;
|
|
21630
21638
|
const caught = synced.catchUp;
|
|
@@ -21651,6 +21659,10 @@ ${open}`,
|
|
|
21651
21659
|
}
|
|
21652
21660
|
if (caught !== undefined) {
|
|
21653
21661
|
pushed = { head: caught.head, stale: 0, by: "the catch-up" };
|
|
21662
|
+
if (targetHead !== undefined)
|
|
21663
|
+
syncedFor.add(syncedKey(caught.head, targetHead));
|
|
21664
|
+
if (forBlocker)
|
|
21665
|
+
blockerSynced.add(caught.head);
|
|
21654
21666
|
yield* waitFor(`pushed:${cycle}`, {
|
|
21655
21667
|
event: "change_request.mergeable",
|
|
21656
21668
|
filter: { changeRequestId, head: caught.head },
|
|
@@ -21703,6 +21715,21 @@ ${open}`,
|
|
|
21703
21715
|
else
|
|
21704
21716
|
return found;
|
|
21705
21717
|
}
|
|
21718
|
+
if (pipeline.conflicts === true || pipeline.needsRebase === true) {
|
|
21719
|
+
const blocker = pipeline.conflicts === true ? `conflicts with ${target}` : `needs ${target} merged in`;
|
|
21720
|
+
const targetHead = pipeline.target?.head;
|
|
21721
|
+
const syncedAlready = targetHead === undefined ? blockerSynced.has(pipeline.head) : syncedFor.has(syncedKey(pipeline.head, targetHead));
|
|
21722
|
+
if (syncedAlready)
|
|
21723
|
+
return handBack(`The forge still says ${pipeline.head} ${blocker} after merging it in`, `Merge ${target} into the branch and settle what conflicts.`);
|
|
21724
|
+
if (targetHead !== undefined)
|
|
21725
|
+
syncedFor.add(syncedKey(pipeline.head, targetHead));
|
|
21726
|
+
blockerSynced.add(pipeline.head);
|
|
21727
|
+
behind = false;
|
|
21728
|
+
const stopped = yield* catchUp(cycle, targetHead, true);
|
|
21729
|
+
if (stopped !== undefined)
|
|
21730
|
+
return stopped;
|
|
21731
|
+
continue;
|
|
21732
|
+
}
|
|
21706
21733
|
if (pipeline.status === "none" && pipeline.runnerChecks !== undefined) {
|
|
21707
21734
|
if (ranOnRunner.has(pipeline.head))
|
|
21708
21735
|
return done("needs_you", `The pipeline ran on the Runner at ${pipeline.head}, but no result was recorded`);
|
|
@@ -21720,7 +21747,7 @@ ${open}`,
|
|
|
21720
21747
|
const targetMoved = redTarget?.head === pipeline.head && (redTarget.targetHead !== undefined && pipeline.target !== undefined ? pipeline.target.head !== redTarget.targetHead : redTarget.moved);
|
|
21721
21748
|
if (targetMoved) {
|
|
21722
21749
|
redTarget = undefined;
|
|
21723
|
-
const stopped = yield* catchUp(cycle);
|
|
21750
|
+
const stopped = yield* catchUp(cycle, pipeline.target?.head);
|
|
21724
21751
|
if (stopped !== undefined)
|
|
21725
21752
|
return stopped;
|
|
21726
21753
|
continue;
|
|
@@ -21735,7 +21762,7 @@ ${open}`,
|
|
|
21735
21762
|
}
|
|
21736
21763
|
if (onTarget.passed.length > 0 && redTarget?.head === pipeline.head) {
|
|
21737
21764
|
redTarget = undefined;
|
|
21738
|
-
const stopped = yield* catchUp(cycle);
|
|
21765
|
+
const stopped = yield* catchUp(cycle, pipeline.target?.head);
|
|
21739
21766
|
if (stopped !== undefined)
|
|
21740
21767
|
return stopped;
|
|
21741
21768
|
continue;
|
|
@@ -21832,7 +21859,7 @@ ${open}`,
|
|
|
21832
21859
|
continue;
|
|
21833
21860
|
if (mergeable.payload.mergeable === false || behind) {
|
|
21834
21861
|
behind = false;
|
|
21835
|
-
const stopped = yield* catchUp(cycle);
|
|
21862
|
+
const stopped = yield* catchUp(cycle, pipeline.target?.head);
|
|
21836
21863
|
if (stopped !== undefined)
|
|
21837
21864
|
return stopped;
|
|
21838
21865
|
continue;
|
|
@@ -22058,7 +22085,7 @@ Merge now?`,
|
|
|
22058
22085
|
}
|
|
22059
22086
|
};
|
|
22060
22087
|
}
|
|
22061
|
-
}).pipe(catchIf2((error) => error._tag === "StepFailed" && error.reason.includes("time budget"), (error) => succeed7(done("needs_you", `Step "${error.step}" ran past its ${stepBudget} budget`))), catchTags2({
|
|
22088
|
+
}).pipe(catchIf2((error) => error._tag === "StepFailed" && (isUnansweredQuestion(error.reason) || error.reason.includes("time budget")), (error) => succeed7(isUnansweredQuestion(error.reason) ? handBack(`Step "${error.step}" stopped on a Question nobody answers in full auto`, error.reason) : done("needs_you", `Step "${error.step}" ran past its ${stepBudget} budget`))), catchTags2({
|
|
22062
22089
|
WaitTimedOut: (timedOut) => succeed7(done("needs_you", timedOut.event === "change_request.approval" && notCarried !== undefined ? `Nobody approved the head after ${notCarried}` : `Nothing happened on the ChangeRequest while waiting for ${timedOut.event}`)),
|
|
22063
22090
|
ChangeRequestClosed: (ended) => succeed7(ended.merged ? done("merged", "Someone else merged the ChangeRequest") : done("needs_you", "The ChangeRequest was closed"))
|
|
22064
22091
|
}));
|
|
@@ -27184,6 +27211,8 @@ class RunnerCapabilityRpcs extends make30(make29("PutQuestion", {
|
|
|
27184
27211
|
runnerChecks: optionalKey2(ArraySchema(String5)),
|
|
27185
27212
|
approved: optionalKey2(String5),
|
|
27186
27213
|
repository: optionalKey2(String5),
|
|
27214
|
+
conflicts: optionalKey2(Boolean3),
|
|
27215
|
+
needsRebase: optionalKey2(Boolean3),
|
|
27187
27216
|
target: optionalKey2(Struct({
|
|
27188
27217
|
branch: String5,
|
|
27189
27218
|
head: String5,
|
|
@@ -30067,4 +30096,4 @@ var runKit = (config, identity, packages) => {
|
|
|
30067
30096
|
runMain2(program.pipe(flatMap3((code) => sync2(() => process.exit(code)))));
|
|
30068
30097
|
};
|
|
30069
30098
|
// .kitman-build-entry.ts
|
|
30070
|
-
runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.10.
|
|
30099
|
+
runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.10.79" }, []);
|
package/dist/declarations.json
CHANGED
|
@@ -2600,7 +2600,7 @@
|
|
|
2600
2600
|
{
|
|
2601
2601
|
"id": "shepherd",
|
|
2602
2602
|
"title": "Shepherd",
|
|
2603
|
-
"version": "1.
|
|
2603
|
+
"version": "1.5.0",
|
|
2604
2604
|
"input": {
|
|
2605
2605
|
"type": "object",
|
|
2606
2606
|
"properties": {
|
|
@@ -3383,7 +3383,7 @@
|
|
|
3383
3383
|
"carried": [
|
|
3384
3384
|
{
|
|
3385
3385
|
"name": "@kitman-sh/software-engineering",
|
|
3386
|
-
"version": "0.10.
|
|
3386
|
+
"version": "0.10.79",
|
|
3387
3387
|
"setup": "2a237548a69b0cd53ec3be7f687cfa8c2128335b3a655d34e185f2abce6a3c37",
|
|
3388
3388
|
"loops": [
|
|
3389
3389
|
"build",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitman-sh/software-engineering",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.79",
|
|
4
4
|
"description": "Everything for building software: Loops, their Agents, the skills they use and the Ponytail plugin.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"tsconfig.json"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@kitman-sh/sdk": "0.10.
|
|
20
|
+
"@kitman-sh/sdk": "0.10.79",
|
|
21
21
|
"effect": "4.1.2"
|
|
22
22
|
},
|
|
23
23
|
"kitman": {
|
|
24
24
|
"bundle": "dist/bundle.js",
|
|
25
|
-
"digest": "
|
|
25
|
+
"digest": "ae3d7067a071697886e9c7a674187f055dcdacaa49baea8b70a8701de8fb4bf5",
|
|
26
26
|
"protocolVersion": 5,
|
|
27
27
|
"declarations": "dist/declarations.json",
|
|
28
28
|
"setup": {
|
package/src/shepherd.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
waitFor,
|
|
23
23
|
writeBack,
|
|
24
24
|
isBlocking,
|
|
25
|
+
isUnansweredQuestion,
|
|
25
26
|
type BaseSync,
|
|
26
27
|
type MergedFinding,
|
|
27
28
|
type PipelineStatus,
|
|
@@ -191,15 +192,16 @@ const threadKey = (thread: ReviewThreads['threads'][number]) => `${thread.id}:${
|
|
|
191
192
|
* Takes an open ChangeRequest to merge: it waits on its Events with no model time between them, fixes a pipeline the
|
|
192
193
|
* branch broke (after ruling out a flake and a target branch that fails the same check, which it waits out), answers
|
|
193
194
|
* each new review thread on the thread, merges the target branch in when it is behind, and merges once approved, green
|
|
194
|
-
* and mergeable when told to or when a person says so.
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
195
|
+
* and mergeable when told to or when a person says so. A branch the forge says conflicts or is behind merges its target
|
|
196
|
+
* in before any pipeline is run or fixed, and one whose merge Shepherd cannot settle goes back to Build. It merges the
|
|
197
|
+
* target in and merges only while it holds the target's turn, so ChangeRequests for one target land one at a time, in
|
|
198
|
+
* order. A head nobody approved gets a review of what changed since the last approved head. It runs one ci-fix and two
|
|
199
|
+
* head-fix rounds, each judged by the pipeline at the head the last fix pushed, then hands the ChangeRequest back to
|
|
200
|
+
* Build, and stops as needs you, with why, instead of spinning.
|
|
199
201
|
*/
|
|
200
202
|
export default defineLoop({
|
|
201
203
|
id: 'shepherd',
|
|
202
|
-
version: '1.
|
|
204
|
+
version: '1.5.0',
|
|
203
205
|
title: 'Shepherd',
|
|
204
206
|
input: Input,
|
|
205
207
|
output: Output,
|
|
@@ -263,6 +265,15 @@ export default defineLoop({
|
|
|
263
265
|
*/
|
|
264
266
|
let fixedFrom: { readonly head: string; readonly changed: boolean; looks: number } | undefined
|
|
265
267
|
|
|
268
|
+
/**
|
|
269
|
+
* Each head a sync pushed or a sync for the forge's conflict or needed rebase started from, with the target's head
|
|
270
|
+
* it took in, where the forge gave it; a blocker the forge shows again at both means the sync could not settle it.
|
|
271
|
+
*/
|
|
272
|
+
const syncedFor = new Set<string>()
|
|
273
|
+
const syncedKey = (head: string, targetHead: string) => `${head}@${targetHead}`
|
|
274
|
+
/** The heads a sync for the forge's blocker started from or pushed, judged by when the target's head is unknown. */
|
|
275
|
+
const blockerSynced = new Set<string>()
|
|
276
|
+
|
|
266
277
|
/** The target's turn: held from the sync before the merge until the merge, so one ChangeRequest merges at a time. */
|
|
267
278
|
let turn: Claim | undefined
|
|
268
279
|
let turns = 0
|
|
@@ -474,7 +485,7 @@ export default defineLoop({
|
|
|
474
485
|
* Merges the target branch in while holding its turn, and carries the approval to the head it pushes when the merge
|
|
475
486
|
* left the branch's own change as it was; the Output to stop with, when it cannot.
|
|
476
487
|
*/
|
|
477
|
-
const catchUp = (cycle: number) =>
|
|
488
|
+
const catchUp = (cycle: number, targetHead: string | undefined, forBlocker = false) =>
|
|
478
489
|
Effect.gen(function* () {
|
|
479
490
|
const refused = yield* takeTurn()
|
|
480
491
|
|
|
@@ -483,7 +494,10 @@ export default defineLoop({
|
|
|
483
494
|
const synced = yield* syncBase(`sync:${cycle}`, { agent: 'implementer', target })
|
|
484
495
|
|
|
485
496
|
if (synced.status === 'conflict')
|
|
486
|
-
return
|
|
497
|
+
return handBack(
|
|
498
|
+
`Merging ${target} in conflicts on ${synced.files.join(', ')}: ${synced.reason}`,
|
|
499
|
+
synced.files.map(file => `- ${file}`).join('\n')
|
|
500
|
+
)
|
|
487
501
|
|
|
488
502
|
if (synced.status !== 'merged') return undefined
|
|
489
503
|
const caught = synced.catchUp
|
|
@@ -525,6 +539,10 @@ export default defineLoop({
|
|
|
525
539
|
if (caught !== undefined) {
|
|
526
540
|
pushed = { head: caught.head, stale: 0, by: 'the catch-up' }
|
|
527
541
|
|
|
542
|
+
if (targetHead !== undefined) syncedFor.add(syncedKey(caught.head, targetHead))
|
|
543
|
+
|
|
544
|
+
if (forBlocker) blockerSynced.add(caught.head)
|
|
545
|
+
|
|
528
546
|
yield* waitFor(`pushed:${cycle}`, {
|
|
529
547
|
event: 'change_request.mergeable',
|
|
530
548
|
filter: { changeRequestId, head: caught.head },
|
|
@@ -596,6 +614,32 @@ export default defineLoop({
|
|
|
596
614
|
else return found
|
|
597
615
|
}
|
|
598
616
|
|
|
617
|
+
if (pipeline.conflicts === true || pipeline.needsRebase === true) {
|
|
618
|
+
const blocker = pipeline.conflicts === true ? `conflicts with ${target}` : `needs ${target} merged in`
|
|
619
|
+
const targetHead = pipeline.target?.head
|
|
620
|
+
|
|
621
|
+
const syncedAlready =
|
|
622
|
+
targetHead === undefined
|
|
623
|
+
? blockerSynced.has(pipeline.head)
|
|
624
|
+
: syncedFor.has(syncedKey(pipeline.head, targetHead))
|
|
625
|
+
|
|
626
|
+
if (syncedAlready)
|
|
627
|
+
return handBack(
|
|
628
|
+
`The forge still says ${pipeline.head} ${blocker} after merging it in`,
|
|
629
|
+
`Merge ${target} into the branch and settle what conflicts.`
|
|
630
|
+
)
|
|
631
|
+
|
|
632
|
+
if (targetHead !== undefined) syncedFor.add(syncedKey(pipeline.head, targetHead))
|
|
633
|
+
blockerSynced.add(pipeline.head)
|
|
634
|
+
behind = false
|
|
635
|
+
|
|
636
|
+
const stopped = yield* catchUp(cycle, targetHead, true)
|
|
637
|
+
|
|
638
|
+
if (stopped !== undefined) return stopped
|
|
639
|
+
|
|
640
|
+
continue
|
|
641
|
+
}
|
|
642
|
+
|
|
599
643
|
// The forge runs no pipeline for this repository: its pipeline runs on a Runner and is reported to Kitman.
|
|
600
644
|
if (pipeline.status === 'none' && pipeline.runnerChecks !== undefined) {
|
|
601
645
|
if (ranOnRunner.has(pipeline.head))
|
|
@@ -627,7 +671,7 @@ export default defineLoop({
|
|
|
627
671
|
if (targetMoved) {
|
|
628
672
|
redTarget = undefined
|
|
629
673
|
|
|
630
|
-
const stopped = yield* catchUp(cycle)
|
|
674
|
+
const stopped = yield* catchUp(cycle, pipeline.target?.head)
|
|
631
675
|
|
|
632
676
|
if (stopped !== undefined) return stopped
|
|
633
677
|
|
|
@@ -653,7 +697,7 @@ export default defineLoop({
|
|
|
653
697
|
if (onTarget.passed.length > 0 && redTarget?.head === pipeline.head) {
|
|
654
698
|
redTarget = undefined
|
|
655
699
|
|
|
656
|
-
const stopped = yield* catchUp(cycle)
|
|
700
|
+
const stopped = yield* catchUp(cycle, pipeline.target?.head)
|
|
657
701
|
|
|
658
702
|
if (stopped !== undefined) return stopped
|
|
659
703
|
|
|
@@ -787,7 +831,7 @@ export default defineLoop({
|
|
|
787
831
|
if (mergeable.payload.mergeable === false || behind) {
|
|
788
832
|
behind = false
|
|
789
833
|
|
|
790
|
-
const stopped = yield* catchUp(cycle)
|
|
834
|
+
const stopped = yield* catchUp(cycle, pipeline.target?.head)
|
|
791
835
|
|
|
792
836
|
if (stopped !== undefined) return stopped
|
|
793
837
|
|
|
@@ -1128,10 +1172,16 @@ export default defineLoop({
|
|
|
1128
1172
|
}
|
|
1129
1173
|
}
|
|
1130
1174
|
}).pipe(
|
|
1131
|
-
// Kitman fails a Step that runs past its time budget with this reason.
|
|
1132
1175
|
Effect.catchIf(
|
|
1133
|
-
error
|
|
1134
|
-
|
|
1176
|
+
(error): error is Extract<typeof error, { readonly _tag: 'StepFailed' }> =>
|
|
1177
|
+
error._tag === 'StepFailed' && (isUnansweredQuestion(error.reason) || error.reason.includes('time budget')),
|
|
1178
|
+
error =>
|
|
1179
|
+
Effect.succeed(
|
|
1180
|
+
// An unanswered Question's reason carries the agent's own words, which may mention a time budget.
|
|
1181
|
+
isUnansweredQuestion(error.reason)
|
|
1182
|
+
? handBack(`Step "${error.step}" stopped on a Question nobody answers in full auto`, error.reason)
|
|
1183
|
+
: done('needs_you', `Step "${error.step}" ran past its ${stepBudget} budget`)
|
|
1184
|
+
)
|
|
1135
1185
|
),
|
|
1136
1186
|
Effect.catchTags({
|
|
1137
1187
|
WaitTimedOut: timedOut =>
|