@kitman-sh/software-engineering 0.10.67 → 0.10.68
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 +69 -10
- package/dist/declarations.json +1 -1
- package/package.json +3 -3
- package/src/shepherd.ts +100 -11
package/dist/bundle.js
CHANGED
|
@@ -5680,6 +5680,7 @@ var succeedSome2 = succeedSome;
|
|
|
5680
5680
|
var suspend2 = suspend;
|
|
5681
5681
|
var sync2 = sync;
|
|
5682
5682
|
var void_3 = void_;
|
|
5683
|
+
var undefined_2 = undefined_;
|
|
5683
5684
|
var callback2 = callback;
|
|
5684
5685
|
var never2 = never;
|
|
5685
5686
|
var gen2 = gen;
|
|
@@ -7162,7 +7163,7 @@ var Undefined = class extends ASTNodeImpl {
|
|
|
7162
7163
|
var undefinedToNull = /* @__PURE__ */ new Link(null_, /* @__PURE__ */ new Transformation(/* @__PURE__ */ transform(() => {
|
|
7163
7164
|
return;
|
|
7164
7165
|
}), /* @__PURE__ */ transform(() => null)));
|
|
7165
|
-
var
|
|
7166
|
+
var undefined_3 = /* @__PURE__ */ new Undefined;
|
|
7166
7167
|
var Void = class extends ASTNodeImpl {
|
|
7167
7168
|
_tag = "Void";
|
|
7168
7169
|
getParser() {
|
|
@@ -8504,7 +8505,7 @@ var optionalKey = /* @__PURE__ */ memoizeIdempotent((ast) => {
|
|
|
8504
8505
|
return optionalKeyLastLink(replaceContext(ast, context));
|
|
8505
8506
|
});
|
|
8506
8507
|
var optionalKeyLastLink = /* @__PURE__ */ applyToLastLink(optionalKey);
|
|
8507
|
-
var optional = /* @__PURE__ */ memoize((ast) => optionalKey(new Union([ast,
|
|
8508
|
+
var optional = /* @__PURE__ */ memoize((ast) => optionalKey(new Union([ast, undefined_3])));
|
|
8508
8509
|
function withConstructorDefault(ast, defaultValue) {
|
|
8509
8510
|
const context = ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, defaultValue, ast.context.annotations) : new Context(false, false, defaultValue);
|
|
8510
8511
|
return replaceContext(ast, context);
|
|
@@ -11071,7 +11072,7 @@ function Literal2(literal) {
|
|
|
11071
11072
|
var Never2 = /* @__PURE__ */ make12(never3);
|
|
11072
11073
|
var Unknown2 = /* @__PURE__ */ make12(unknown);
|
|
11073
11074
|
var Null2 = /* @__PURE__ */ make12(null_);
|
|
11074
|
-
var Undefined2 = /* @__PURE__ */ make12(
|
|
11075
|
+
var Undefined2 = /* @__PURE__ */ make12(undefined_3);
|
|
11075
11076
|
var String5 = /* @__PURE__ */ make12(string2);
|
|
11076
11077
|
var Number5 = /* @__PURE__ */ make12(number2);
|
|
11077
11078
|
var Boolean3 = /* @__PURE__ */ make12(boolean);
|
|
@@ -21221,8 +21222,8 @@ var threadLine = (thread) => [
|
|
|
21221
21222
|
].join(`
|
|
21222
21223
|
`);
|
|
21223
21224
|
var ReviewFix = Struct({ summary: String5 });
|
|
21224
|
-
var reviewFixPrompt = (findings) => [
|
|
21225
|
-
|
|
21225
|
+
var reviewFixPrompt = (reviewed, findings) => [
|
|
21226
|
+
`A review of ${reviewed} found these. Fix each blocker and major finding, with a test that shows it where one can. Kitman pushes what you leave.`,
|
|
21226
21227
|
...findings.map((finding) => `- ${finding.id} (${finding.severity}): ${finding.detail}`)
|
|
21227
21228
|
].join(`
|
|
21228
21229
|
`);
|
|
@@ -21269,6 +21270,8 @@ var shepherd_default = defineLoop({
|
|
|
21269
21270
|
const answered = new Set;
|
|
21270
21271
|
const reranHeads = new Set;
|
|
21271
21272
|
const ranOnRunner = new Set;
|
|
21273
|
+
const leftToPerson = new Set;
|
|
21274
|
+
let headFindings = [];
|
|
21272
21275
|
let fixRounds = 0;
|
|
21273
21276
|
let replies = 0;
|
|
21274
21277
|
let stalledAt;
|
|
@@ -21458,7 +21461,7 @@ var shepherd_default = defineLoop({
|
|
|
21458
21461
|
fixRounds++;
|
|
21459
21462
|
yield* agentWork(`review-fix:${cycle}`, {
|
|
21460
21463
|
agent: "implementer",
|
|
21461
|
-
prompt: reviewFixPrompt(blocking),
|
|
21464
|
+
prompt: reviewFixPrompt("the files the catch-up merge changed", blocking),
|
|
21462
21465
|
output: ReviewFix,
|
|
21463
21466
|
timeout: stepBudget
|
|
21464
21467
|
});
|
|
@@ -21488,12 +21491,68 @@ var shepherd_default = defineLoop({
|
|
|
21488
21491
|
}
|
|
21489
21492
|
] : []
|
|
21490
21493
|
];
|
|
21491
|
-
const
|
|
21494
|
+
const approval = {
|
|
21492
21495
|
event: "change_request.approval",
|
|
21493
21496
|
filter: { changeRequestId, approved: true, head: pipeline.head },
|
|
21494
|
-
timeout: "7 days",
|
|
21495
21497
|
or: [commented, ...moved]
|
|
21496
|
-
}
|
|
21498
|
+
};
|
|
21499
|
+
const byKitman = (wait) => wait.event === "change_request.approval" ? { ...wait, filter: { ...wait.filter, source: "kitman" } } : wait;
|
|
21500
|
+
let approved = reviewedHere || leftToPerson.has(pipeline.head) ? undefined : yield* waitFor(`approved:${cycle}`, {
|
|
21501
|
+
...byKitman(approval),
|
|
21502
|
+
or: approval.or.map(byKitman),
|
|
21503
|
+
timeout: "1 minute"
|
|
21504
|
+
}).pipe(map8((woke) => woke.type === "change_request.approval" && woke.payload.source !== "kitman" ? undefined : woke), catchTag2("WaitTimedOut", () => undefined_2));
|
|
21505
|
+
if (!reviewedHere && approved === undefined) {
|
|
21506
|
+
const head = pipeline.head;
|
|
21507
|
+
const reviewIt = leftToPerson.has(head) ? "Wait" : yield* ask(`unapproved:${cycle}`, {
|
|
21508
|
+
prompt: `Nobody has approved ${head}, the head whose pipeline passed. Have Kitman review it?`,
|
|
21509
|
+
options: [
|
|
21510
|
+
{
|
|
21511
|
+
value: "Review",
|
|
21512
|
+
description: "Kitman's Review reads the whole change at this head and approves it if nothing blocks."
|
|
21513
|
+
},
|
|
21514
|
+
{ value: "Wait", description: "Waits for a person to approve this head." }
|
|
21515
|
+
],
|
|
21516
|
+
recommended: "Review",
|
|
21517
|
+
recommendationReason: "A passing Review of the whole change is what approved the head Build shipped.",
|
|
21518
|
+
default: "Wait",
|
|
21519
|
+
auto: "Review",
|
|
21520
|
+
timeout: "1 hour"
|
|
21521
|
+
});
|
|
21522
|
+
if (reviewIt === "Wait") {
|
|
21523
|
+
leftToPerson.add(head);
|
|
21524
|
+
approved = yield* waitFor(`approval:${cycle}`, { ...approval, timeout: "7 days" });
|
|
21525
|
+
} else {
|
|
21526
|
+
const reviewed = yield* call(`head-review:${cycle}`, reviewLoop(), {
|
|
21527
|
+
base: `origin/${target}`,
|
|
21528
|
+
head,
|
|
21529
|
+
...headFindings.length === 0 ? undefined : { earlier: headFindings }
|
|
21530
|
+
});
|
|
21531
|
+
if (reviewed.blocking) {
|
|
21532
|
+
const blocking = reviewed.findings.filter(isBlocking);
|
|
21533
|
+
if (fixRounds >= (input.maxFixRounds ?? 3))
|
|
21534
|
+
return done("needs_you", `The review of ${head} still finds ${blocking.map((finding) => finding.id).join(", ")} after ${fixRounds} fix rounds`);
|
|
21535
|
+
fixRounds++;
|
|
21536
|
+
yield* agentWork(`head-fix:${cycle}`, {
|
|
21537
|
+
agent: "implementer",
|
|
21538
|
+
prompt: reviewFixPrompt(`the change at ${head}`, blocking),
|
|
21539
|
+
output: ReviewFix,
|
|
21540
|
+
timeout: stepBudget
|
|
21541
|
+
});
|
|
21542
|
+
headFindings = reviewed.findings;
|
|
21543
|
+
continue;
|
|
21544
|
+
}
|
|
21545
|
+
const recorded = yield* approveChangeRequest(`head-approve:${cycle}`, {
|
|
21546
|
+
changeRequestId,
|
|
21547
|
+
head,
|
|
21548
|
+
summary: `A review of the whole change at ${head} passed with nothing blocking.`,
|
|
21549
|
+
review: `head-review:${cycle}`
|
|
21550
|
+
}).pipe(catchTag2("StepFailed", (error) => succeed7({ approved: false, reason: error.reason })));
|
|
21551
|
+
if (!recorded.approved)
|
|
21552
|
+
return done("needs_you", `The review of ${head} passed, but did not approve it: ${recorded.reason}`);
|
|
21553
|
+
headFindings = [];
|
|
21554
|
+
}
|
|
21555
|
+
}
|
|
21497
21556
|
if (approved !== undefined && approved.type !== "change_request.approval")
|
|
21498
21557
|
continue;
|
|
21499
21558
|
if (pipeline.source === "reported" && approved !== undefined && approved.payload.head !== pipeline.head)
|
|
@@ -29421,4 +29480,4 @@ var runKit = (config, identity, packages) => {
|
|
|
29421
29480
|
runMain2(program.pipe(flatMap3((code) => sync2(() => process.exit(code)))));
|
|
29422
29481
|
};
|
|
29423
29482
|
// .kitman-build-entry.ts
|
|
29424
|
-
runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.10.
|
|
29483
|
+
runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.10.68" }, []);
|
package/dist/declarations.json
CHANGED
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.68",
|
|
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.68",
|
|
21
21
|
"effect": "4.1.2"
|
|
22
22
|
},
|
|
23
23
|
"kitman": {
|
|
24
24
|
"bundle": "dist/bundle.js",
|
|
25
|
-
"digest": "
|
|
25
|
+
"digest": "083a5bb10db9a060c498a798c31bedd029f001bd27e587a42720f16ca6d4a4fa",
|
|
26
26
|
"protocolVersion": 5,
|
|
27
27
|
"declarations": "dist/declarations.json",
|
|
28
28
|
"setup": {
|
package/src/shepherd.ts
CHANGED
|
@@ -99,9 +99,9 @@ const threadLine = (thread: ReviewThreads['threads'][number]) =>
|
|
|
99
99
|
|
|
100
100
|
const ReviewFix = Schema.Struct({ summary: Schema.String })
|
|
101
101
|
|
|
102
|
-
const reviewFixPrompt = (findings: readonly MergedFinding[]) =>
|
|
102
|
+
const reviewFixPrompt = (reviewed: string, findings: readonly MergedFinding[]) =>
|
|
103
103
|
[
|
|
104
|
-
|
|
104
|
+
`A review of ${reviewed} found these. Fix each blocker and major finding, with a test that shows it where one can. Kitman pushes what you leave.`,
|
|
105
105
|
...findings.map(finding => `- ${finding.id} (${finding.severity}): ${finding.detail}`)
|
|
106
106
|
].join('\n')
|
|
107
107
|
|
|
@@ -169,6 +169,10 @@ export default defineLoop({
|
|
|
169
169
|
const answered = new Set<string>()
|
|
170
170
|
const reranHeads = new Set<string>()
|
|
171
171
|
const ranOnRunner = new Set<string>()
|
|
172
|
+
/** Heads nobody approved whose approval was left to a person, so they are not asked about again. */
|
|
173
|
+
const leftToPerson = new Set<string>()
|
|
174
|
+
/** The last review of an unapproved head's open findings, for the review of the head that fixes them. */
|
|
175
|
+
let headFindings: readonly MergedFinding[] = []
|
|
172
176
|
let fixRounds = 0
|
|
173
177
|
let replies = 0
|
|
174
178
|
let stalledAt: string | undefined
|
|
@@ -454,7 +458,7 @@ export default defineLoop({
|
|
|
454
458
|
|
|
455
459
|
yield* agentWork(`review-fix:${cycle}`, {
|
|
456
460
|
agent: 'implementer',
|
|
457
|
-
prompt: reviewFixPrompt(blocking),
|
|
461
|
+
prompt: reviewFixPrompt('the files the catch-up merge changed', blocking),
|
|
458
462
|
output: ReviewFix,
|
|
459
463
|
timeout: stepBudget
|
|
460
464
|
})
|
|
@@ -498,16 +502,101 @@ export default defineLoop({
|
|
|
498
502
|
: [])
|
|
499
503
|
]
|
|
500
504
|
|
|
501
|
-
const
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
505
|
+
const approval = {
|
|
506
|
+
event: 'change_request.approval',
|
|
507
|
+
// An approval of an earlier commit does not approve the one whose pipeline passed.
|
|
508
|
+
filter: { changeRequestId, approved: true, head: pipeline.head },
|
|
509
|
+
or: [commented, ...moved]
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
// Kitman's approval of the head settles this at once, as Build's of the head it shipped does. A forge approval
|
|
513
|
+
// is no Kitman review, so it waits behind the question below, which a full-auto Team answers with a Review.
|
|
514
|
+
const byKitman = <Wait extends { readonly event: string; readonly filter: object }>(wait: Wait) =>
|
|
515
|
+
wait.event === 'change_request.approval' ? { ...wait, filter: { ...wait.filter, source: 'kitman' } } : wait
|
|
516
|
+
|
|
517
|
+
let approved =
|
|
518
|
+
reviewedHere || leftToPerson.has(pipeline.head)
|
|
519
|
+
? undefined
|
|
520
|
+
: yield* waitFor(`approved:${cycle}`, {
|
|
521
|
+
...byKitman(approval),
|
|
522
|
+
or: approval.or.map(byKitman),
|
|
523
|
+
timeout: '1 minute'
|
|
524
|
+
}).pipe(
|
|
525
|
+
Effect.map(woke =>
|
|
526
|
+
woke.type === 'change_request.approval' && woke.payload.source !== 'kitman' ? undefined : woke
|
|
527
|
+
),
|
|
528
|
+
Effect.catchTag('WaitTimedOut', () => Effect.undefined)
|
|
529
|
+
)
|
|
530
|
+
|
|
531
|
+
if (!reviewedHere && approved === undefined) {
|
|
532
|
+
const head = pipeline.head
|
|
533
|
+
|
|
534
|
+
const reviewIt = leftToPerson.has(head)
|
|
535
|
+
? 'Wait'
|
|
536
|
+
: yield* ask(`unapproved:${cycle}`, {
|
|
537
|
+
prompt: `Nobody has approved ${head}, the head whose pipeline passed. Have Kitman review it?`,
|
|
538
|
+
options: [
|
|
539
|
+
{
|
|
540
|
+
value: 'Review',
|
|
541
|
+
description:
|
|
542
|
+
"Kitman's Review reads the whole change at this head and approves it if nothing blocks."
|
|
543
|
+
},
|
|
544
|
+
{ value: 'Wait', description: 'Waits for a person to approve this head.' }
|
|
545
|
+
],
|
|
546
|
+
recommended: 'Review',
|
|
547
|
+
recommendationReason: 'A passing Review of the whole change is what approved the head Build shipped.',
|
|
548
|
+
default: 'Wait',
|
|
549
|
+
// A full-auto Team merges what its Review approved, including heads Shepherd pushed itself.
|
|
550
|
+
auto: 'Review',
|
|
551
|
+
timeout: '1 hour'
|
|
552
|
+
})
|
|
553
|
+
|
|
554
|
+
if (reviewIt === 'Wait') {
|
|
555
|
+
leftToPerson.add(head)
|
|
556
|
+
approved = yield* waitFor(`approval:${cycle}`, { ...approval, timeout: '7 days' })
|
|
557
|
+
} else {
|
|
558
|
+
const reviewed = yield* call(`head-review:${cycle}`, reviewLoop(), {
|
|
559
|
+
base: `origin/${target}`,
|
|
560
|
+
head,
|
|
561
|
+
...(headFindings.length === 0 ? undefined : { earlier: headFindings })
|
|
509
562
|
})
|
|
510
563
|
|
|
564
|
+
if (reviewed.blocking) {
|
|
565
|
+
const blocking = reviewed.findings.filter(isBlocking)
|
|
566
|
+
|
|
567
|
+
if (fixRounds >= (input.maxFixRounds ?? 3))
|
|
568
|
+
return done(
|
|
569
|
+
'needs_you',
|
|
570
|
+
`The review of ${head} still finds ${blocking.map(finding => finding.id).join(', ')} after ${fixRounds} fix rounds`
|
|
571
|
+
)
|
|
572
|
+
fixRounds++
|
|
573
|
+
|
|
574
|
+
yield* agentWork(`head-fix:${cycle}`, {
|
|
575
|
+
agent: 'implementer',
|
|
576
|
+
prompt: reviewFixPrompt(`the change at ${head}`, blocking),
|
|
577
|
+
output: ReviewFix,
|
|
578
|
+
timeout: stepBudget
|
|
579
|
+
})
|
|
580
|
+
headFindings = reviewed.findings
|
|
581
|
+
|
|
582
|
+
continue
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
const recorded = yield* approveChangeRequest(`head-approve:${cycle}`, {
|
|
586
|
+
changeRequestId,
|
|
587
|
+
head,
|
|
588
|
+
summary: `A review of the whole change at ${head} passed with nothing blocking.`,
|
|
589
|
+
review: `head-review:${cycle}`
|
|
590
|
+
}).pipe(
|
|
591
|
+
Effect.catchTag('StepFailed', error => Effect.succeed({ approved: false as const, reason: error.reason }))
|
|
592
|
+
)
|
|
593
|
+
|
|
594
|
+
if (!recorded.approved)
|
|
595
|
+
return done('needs_you', `The review of ${head} passed, but did not approve it: ${recorded.reason}`)
|
|
596
|
+
headFindings = []
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
|
|
511
600
|
if (approved !== undefined && approved.type !== 'change_request.approval') continue
|
|
512
601
|
|
|
513
602
|
// The approval of a newer head woke a wait on a reported pipeline: that head needs its own pipeline first.
|