@kitman-sh/software-engineering 0.11.0-rc.6 → 0.11.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 +496 -94
- package/dist/declarations.json +1208 -19
- package/kitman.config.ts +2 -5
- package/package.json +3 -3
- package/src/build.ts +21 -7
- package/src/delivery.ts +29 -0
- package/src/index.ts +3 -0
- package/src/land-epic.ts +137 -0
- package/src/release.ts +83 -32
- package/src/review.ts +27 -16
- package/src/shepherd-output.ts +5 -1
- package/src/shepherd.ts +240 -15
- package/src/sweep.ts +15 -2
- package/agents/deployer.md +0 -11
package/dist/bundle.js
CHANGED
|
@@ -12323,6 +12323,27 @@ var shippedScope = (scope) => ({
|
|
|
12323
12323
|
taskIds: scope.tasks.map((task) => task.id)
|
|
12324
12324
|
});
|
|
12325
12325
|
|
|
12326
|
+
// ../../packages/core/src/delivery-target.ts
|
|
12327
|
+
var DeliveryTarget = Literals(["default_branch", "epic_branch"]);
|
|
12328
|
+
var DeliveryTargetLayer = Literals(["run", "project", "team", "workspace"]);
|
|
12329
|
+
var ResolvedDeliveryTarget = Struct({ target: DeliveryTarget, layer: DeliveryTargetLayer });
|
|
12330
|
+
var DeliveryTargetSetting = Struct({
|
|
12331
|
+
target: NullOr(DeliveryTarget),
|
|
12332
|
+
resolved: optionalKey2(ResolvedDeliveryTarget)
|
|
12333
|
+
});
|
|
12334
|
+
var DeliveryTargetUpdate = Struct({
|
|
12335
|
+
target: NullOr(DeliveryTarget)
|
|
12336
|
+
});
|
|
12337
|
+
var EpicDelivery = Struct({
|
|
12338
|
+
taskId: String5,
|
|
12339
|
+
key: String5,
|
|
12340
|
+
branch: String5,
|
|
12341
|
+
defaultBranch: String5,
|
|
12342
|
+
subTasksDone: Boolean3,
|
|
12343
|
+
done: Boolean3,
|
|
12344
|
+
own: optional2(Boolean3)
|
|
12345
|
+
});
|
|
12346
|
+
|
|
12326
12347
|
// ../../packages/core/src/context-pack.ts
|
|
12327
12348
|
var ContextPackIndexEntryKinds = [
|
|
12328
12349
|
"task",
|
|
@@ -13946,6 +13967,7 @@ var ApprovedVerification = Struct({
|
|
|
13946
13967
|
command: String5,
|
|
13947
13968
|
workingDirectory: optionalKey2(String5),
|
|
13948
13969
|
pipeline: optionalKey2(Boolean3),
|
|
13970
|
+
readsTarget: optionalKey2(Boolean3),
|
|
13949
13971
|
approvedByUserId: String5,
|
|
13950
13972
|
createdAt: Timestamp
|
|
13951
13973
|
});
|
|
@@ -14160,10 +14182,17 @@ var QuestionResponderPolicy = Struct({
|
|
|
14160
14182
|
eligibleMemberIds: ArraySchema(Id).check(isMaxLength(100), isUnique()),
|
|
14161
14183
|
allowWorkspaceAdmins: Boolean3
|
|
14162
14184
|
}).check(makeFilter2((policy) => policy.eligibleMemberIds.length > 0 || policy.allowWorkspaceAdmins || "someone who may answer"));
|
|
14185
|
+
var EvidenceRef2 = String5.check(isMinLength(1), isMaxLength(240));
|
|
14186
|
+
var QuestionEvidence = Struct({
|
|
14187
|
+
review: optionalKey2(EvidenceRef2),
|
|
14188
|
+
head: optionalKey2(EvidenceRef2)
|
|
14189
|
+
});
|
|
14163
14190
|
var QuestionAnswer = Struct({
|
|
14164
14191
|
value: LoopSafeText,
|
|
14165
14192
|
answeredByUserId: optionalKey2(Id),
|
|
14166
14193
|
byDefault: optionalKey2(Boolean3),
|
|
14194
|
+
byAuto: optionalKey2(Boolean3),
|
|
14195
|
+
evidence: optionalKey2(QuestionEvidence),
|
|
14167
14196
|
answeredAt: Timestamp,
|
|
14168
14197
|
idempotencyKey: String5.check(isMinLength(1), isMaxLength(240))
|
|
14169
14198
|
});
|
|
@@ -14335,7 +14364,9 @@ var RunHeader = Struct({
|
|
|
14335
14364
|
Struct({ kind: Literal2("event"), event: String5 })
|
|
14336
14365
|
])),
|
|
14337
14366
|
releaseWhen: optionalKey2(ResolvedReleaseTrigger),
|
|
14338
|
-
releaseScope: optionalKey2(ReleaseScope)
|
|
14367
|
+
releaseScope: optionalKey2(ReleaseScope),
|
|
14368
|
+
deliversTo: optionalKey2(ResolvedDeliveryTarget),
|
|
14369
|
+
epic: optionalKey2(EpicDelivery)
|
|
14339
14370
|
});
|
|
14340
14371
|
var RunShow = Struct({
|
|
14341
14372
|
run: Run,
|
|
@@ -14578,6 +14609,14 @@ var LoopCapabilities = [
|
|
|
14578
14609
|
var JsonObject2 = Record(String5, Json2);
|
|
14579
14610
|
var SecretName2 = String5.check(isPattern2(/^[A-Za-z_][A-Za-z0-9_]{0,127}$/));
|
|
14580
14611
|
var EventFilterValue = Union2([String5, Finite, Boolean3, Null2]);
|
|
14612
|
+
var WhenClause = Struct({
|
|
14613
|
+
event: String5,
|
|
14614
|
+
filter: optionalKey2(Record(String5, Union2([EventFilterValue, ArraySchema(EventFilterValue)]))),
|
|
14615
|
+
input: Record(String5, String5),
|
|
14616
|
+
values: optionalKey2(JsonObject2),
|
|
14617
|
+
optIn: optionalKey2(Boolean3),
|
|
14618
|
+
description: optionalKey2(String5)
|
|
14619
|
+
});
|
|
14581
14620
|
var LoopManifest = Struct({
|
|
14582
14621
|
id: String5,
|
|
14583
14622
|
title: String5,
|
|
@@ -14587,12 +14626,7 @@ var LoopManifest = Struct({
|
|
|
14587
14626
|
outcome: optionalKey2(Literals(["feature", "bug", "refactor", "investigation", "docs", "migration", "performance"])),
|
|
14588
14627
|
agents: Record(String5, String5),
|
|
14589
14628
|
checkout: Literals(["none", "read", "write"]),
|
|
14590
|
-
when: ArraySchema(
|
|
14591
|
-
event: String5,
|
|
14592
|
-
filter: optionalKey2(Record(String5, Union2([EventFilterValue, ArraySchema(EventFilterValue)]))),
|
|
14593
|
-
input: Record(String5, String5),
|
|
14594
|
-
values: optionalKey2(JsonObject2)
|
|
14595
|
-
})),
|
|
14629
|
+
when: ArraySchema(WhenClause),
|
|
14596
14630
|
offers: ArraySchema(Struct({
|
|
14597
14631
|
id: String5,
|
|
14598
14632
|
title: String5,
|
|
@@ -14610,7 +14644,7 @@ var LoopDetail = Struct({
|
|
|
14610
14644
|
resolved: optionalKey2(Struct({
|
|
14611
14645
|
...ProgramLoop.fields,
|
|
14612
14646
|
agents: LoopManifest.fields.agents,
|
|
14613
|
-
when:
|
|
14647
|
+
when: ArraySchema(Struct({ ...WhenClause.fields, on: optionalKey2(Boolean3) })),
|
|
14614
14648
|
schedule: optionalKey2(Struct({
|
|
14615
14649
|
rule: ScheduleRule,
|
|
14616
14650
|
timezone: String5,
|
|
@@ -19010,7 +19044,8 @@ var outcomeGate = (input) => {
|
|
|
19010
19044
|
// ../../packages/sdk/src/loop/steps.ts
|
|
19011
19045
|
class StepFailed extends TaggedError3()("StepFailed", {
|
|
19012
19046
|
step: String5,
|
|
19013
|
-
reason: String5
|
|
19047
|
+
reason: String5,
|
|
19048
|
+
code: optional2(String5)
|
|
19014
19049
|
}) {
|
|
19015
19050
|
get message() {
|
|
19016
19051
|
return `Step "${this.step}" failed: ${this.reason}`;
|
|
@@ -19177,6 +19212,7 @@ var ask = (name, question) => takeStep(name, "ask", "ask", gen2(function* () {
|
|
|
19177
19212
|
...fallback === undefined ? undefined : { default: fallback },
|
|
19178
19213
|
...question.auto === undefined ? undefined : { auto: question.auto },
|
|
19179
19214
|
...question.unattendedAuto === undefined ? undefined : { unattendedAuto: question.unattendedAuto },
|
|
19215
|
+
...question.evidence === undefined ? undefined : { evidence: question.evidence },
|
|
19180
19216
|
...question.timeout === undefined ? undefined : { timeoutMillis: toMillis(fromInputUnsafe2(question.timeout)) },
|
|
19181
19217
|
token: token2
|
|
19182
19218
|
}));
|
|
@@ -19340,7 +19376,10 @@ var AlertTaskResult = Struct({
|
|
|
19340
19376
|
resolved: optionalKey2(Boolean3),
|
|
19341
19377
|
joined: optionalKey2(Struct({ kind: Literals(["run", "recent"]), runId: String5 }))
|
|
19342
19378
|
});
|
|
19343
|
-
var IntegrationBranchRequest = Struct({
|
|
19379
|
+
var IntegrationBranchRequest = Struct({
|
|
19380
|
+
repoBindingId: optional2(String5),
|
|
19381
|
+
base: optional2(Boolean3)
|
|
19382
|
+
});
|
|
19344
19383
|
var IntegrationBranch = Struct({
|
|
19345
19384
|
repoBindingId: String5,
|
|
19346
19385
|
branch: String5,
|
|
@@ -19421,6 +19460,7 @@ var PipelineStatus = Struct({
|
|
|
19421
19460
|
jobs: ArraySchema(PipelineJob),
|
|
19422
19461
|
readAt: optionalKey2(String5),
|
|
19423
19462
|
runnerChecks: optionalKey2(ArraySchema(String5)),
|
|
19463
|
+
targetChecks: optionalKey2(ArraySchema(String5)),
|
|
19424
19464
|
approved: optionalKey2(String5),
|
|
19425
19465
|
repository: optionalKey2(String5),
|
|
19426
19466
|
sourceBranch: optionalKey2(String5),
|
|
@@ -19610,6 +19650,9 @@ var alertTask = (name, request) => hostActivity(name, "create_tasks", "create_ta
|
|
|
19610
19650
|
var integrationBranch = (name, request) => hostActivity(name, "integration_branch", "merge_change_request", IntegrationBranch, gen2(function* () {
|
|
19611
19651
|
return yield* (yield* IntegrationBranchActivity).run(request, name);
|
|
19612
19652
|
}));
|
|
19653
|
+
var deliveryBase = (name) => hostActivity(name, "integration_branch", "change_request", IntegrationBranch, gen2(function* () {
|
|
19654
|
+
return yield* (yield* IntegrationBranchActivity).run({ base: true }, name);
|
|
19655
|
+
}));
|
|
19613
19656
|
var mergeChangeRequest = (name, request) => hostActivity(name, "merge_change_request", "merge_change_request", MergeResult, gen2(function* () {
|
|
19614
19657
|
return yield* (yield* MergeChangeRequestActivity).run(request, name);
|
|
19615
19658
|
}));
|
|
@@ -20099,7 +20142,8 @@ var ApprovedCheck = Struct({
|
|
|
20099
20142
|
});
|
|
20100
20143
|
var RepositoryCheck = Struct({
|
|
20101
20144
|
...ApprovedCheck.fields,
|
|
20102
|
-
pipeline: optionalKey2(Boolean3)
|
|
20145
|
+
pipeline: optionalKey2(Boolean3),
|
|
20146
|
+
readsTarget: optionalKey2(Boolean3)
|
|
20103
20147
|
});
|
|
20104
20148
|
var MetricName = String5.check(isMinLength(1), isMaxLength(80), isPattern2(new RegExp("^[A-Za-z0-9][A-Za-z0-9._:-]*$", "u")));
|
|
20105
20149
|
var MeasurePlan = Struct({
|
|
@@ -20133,6 +20177,20 @@ var ResolveSpec = Struct({
|
|
|
20133
20177
|
var ResolvedRevisions = Struct({
|
|
20134
20178
|
commits: ArraySchema(String5.check(isPattern2(new RegExp("^[0-9a-f]{40}([0-9a-f]{24})?$", "u"))))
|
|
20135
20179
|
});
|
|
20180
|
+
var ReleaseTag = String5.check(isMinLength(1), isMaxLength(240));
|
|
20181
|
+
var DeploySpec = Struct({
|
|
20182
|
+
tag: ReleaseTag,
|
|
20183
|
+
previousTag: optionalKey2(ReleaseTag)
|
|
20184
|
+
});
|
|
20185
|
+
var DeployWork = Struct({
|
|
20186
|
+
...DeploySpec.fields,
|
|
20187
|
+
runsScript: optionalKey2(Literal2(true))
|
|
20188
|
+
});
|
|
20189
|
+
var DeployOutcome = Struct({
|
|
20190
|
+
status: Literals(["deployed", "failed", "rolled_back", "rollback_failed", "none"]),
|
|
20191
|
+
exitCode: optionalKey2(Int),
|
|
20192
|
+
detail: String5.check(isMaxLength(1200))
|
|
20193
|
+
});
|
|
20136
20194
|
var VerificationWorkUnit = Struct({
|
|
20137
20195
|
kind: Literal2("verification"),
|
|
20138
20196
|
id: Id,
|
|
@@ -20146,6 +20204,7 @@ var VerificationWorkUnit = Struct({
|
|
|
20146
20204
|
checks: ArraySchema(RepositoryCheck).check(isMaxLength(50)),
|
|
20147
20205
|
measure: optionalKey2(MeasureSpec),
|
|
20148
20206
|
resolve: optionalKey2(ResolveSpec),
|
|
20207
|
+
deploy: optionalKey2(DeployWork),
|
|
20149
20208
|
hosts: optionalKey2(ArraySchema(NetworkHost)),
|
|
20150
20209
|
storageOrigin: StorageOrigin
|
|
20151
20210
|
});
|
|
@@ -20195,7 +20254,9 @@ var VerificationEvidence = Struct({
|
|
|
20195
20254
|
head: TreeEvidence,
|
|
20196
20255
|
baseline: optionalKey2(TreeEvidence),
|
|
20197
20256
|
measurement: optionalKey2(MeasureEvidence),
|
|
20198
|
-
resolved: optionalKey2(ResolvedRevisions)
|
|
20257
|
+
resolved: optionalKey2(ResolvedRevisions),
|
|
20258
|
+
deployed: optionalKey2(DeployOutcome),
|
|
20259
|
+
deployScriptFound: optionalKey2(Literal2(true))
|
|
20199
20260
|
});
|
|
20200
20261
|
var BoundaryChange = Struct({
|
|
20201
20262
|
kind: Literal2("change"),
|
|
@@ -20378,6 +20439,21 @@ var resolveRevisions = (name, revisions) => takeStep(name, "verify", "verify", g
|
|
|
20378
20439
|
return (yield* await_2(deferred)).commits;
|
|
20379
20440
|
}));
|
|
20380
20441
|
|
|
20442
|
+
// ../../packages/sdk/src/loop/deploy.ts
|
|
20443
|
+
var deployDeferred = (step) => make14(`deploy/${step}`, { success: DeployOutcome, error: StepFailed });
|
|
20444
|
+
var runDeploy = (name, request) => takeStep(name, "verify", "publish_release", gen2(function* () {
|
|
20445
|
+
const deferred = deployDeferred(name);
|
|
20446
|
+
yield* launch(deferred, (host, token) => host.startVerification({
|
|
20447
|
+
step: name,
|
|
20448
|
+
deploy: {
|
|
20449
|
+
tag: request.tag,
|
|
20450
|
+
...request.previousTag === undefined ? undefined : { previousTag: request.previousTag }
|
|
20451
|
+
},
|
|
20452
|
+
token
|
|
20453
|
+
}));
|
|
20454
|
+
return yield* await_2(deferred);
|
|
20455
|
+
}));
|
|
20456
|
+
|
|
20381
20457
|
// ../../packages/sdk/src/loop/test-loop.ts
|
|
20382
20458
|
var LoopJournal = Struct({
|
|
20383
20459
|
activities: Record(String5, Json2),
|
|
@@ -20469,7 +20545,7 @@ var journaled = (engine, journal, ran) => ({
|
|
|
20469
20545
|
})
|
|
20470
20546
|
});
|
|
20471
20547
|
var scriptedExit = (scripted, failure) => scripted === undefined ? fail5(failure("nothing was scripted for this Step")) : scripted instanceof ScriptedFailure ? fail5(failure(scripted.reason)) : succeed4(scripted);
|
|
20472
|
-
var scriptedHost = (script, engine, agentLaunches, childLaunches, waits, verifyLaunches) => {
|
|
20548
|
+
var scriptedHost = (script, engine, agentLaunches, childLaunches, waits, verifyLaunches, deployLaunches, questions, answers) => {
|
|
20473
20549
|
const resolve = (deferred, token, exit) => done4(deferred, { token, exit }).pipe(provideService2(WorkflowEngine, engine));
|
|
20474
20550
|
return {
|
|
20475
20551
|
startAgentWork: (launch) => andThen2(sync2(() => agentLaunches.push({
|
|
@@ -20484,15 +20560,25 @@ var scriptedHost = (script, engine, agentLaunches, childLaunches, waits, verifyL
|
|
|
20484
20560
|
putQuestion: (launch) => {
|
|
20485
20561
|
const attended = script.attended === true;
|
|
20486
20562
|
const auto = script.fullAuto === true ? launch.auto ?? (attended ? undefined : launch.unattendedAuto) : undefined;
|
|
20487
|
-
const
|
|
20488
|
-
|
|
20563
|
+
const scripted = script.answers?.[launch.step];
|
|
20564
|
+
const answer = scripted ?? auto ?? (attended ? undefined : launch.default);
|
|
20565
|
+
if (answer !== undefined)
|
|
20566
|
+
answers.push({
|
|
20567
|
+
step: launch.step,
|
|
20568
|
+
value: answer,
|
|
20569
|
+
...scripted === undefined && auto !== undefined ? { byAuto: true, ...launch.evidence === undefined ? undefined : { evidence: launch.evidence } } : undefined
|
|
20570
|
+
});
|
|
20571
|
+
return andThen2(sync2(() => questions.push({ step: launch.step, prompt: launch.prompt })), resolve(answerDeferred(launch.step), launch.token, answer === undefined ? fail5(new StepFailed({ step: launch.step, reason: "no answer was scripted" })) : succeed4(answer)));
|
|
20572
|
+
},
|
|
20573
|
+
admitChild: (launch) => {
|
|
20574
|
+
const refused = script.refusedChildren?.[launch.step];
|
|
20575
|
+
return refused !== undefined ? fail7(new StepFailed(isString2(refused) ? { step: launch.step, reason: refused } : { step: launch.step, ...refused })) : andThen2(sync2(() => childLaunches.push({
|
|
20576
|
+
step: launch.step,
|
|
20577
|
+
loop: launch.loop,
|
|
20578
|
+
input: launch.input,
|
|
20579
|
+
...launch.constraints === undefined ? undefined : { constraints: launch.constraints }
|
|
20580
|
+
})), resolve(childDeferred(launch.step), launch.token, scriptedExit(script.children?.[launch.step], (reason) => new ChildFailed({ step: launch.step, loop: launch.loop, reason }))));
|
|
20489
20581
|
},
|
|
20490
|
-
admitChild: (launch) => andThen2(sync2(() => childLaunches.push({
|
|
20491
|
-
step: launch.step,
|
|
20492
|
-
loop: launch.loop,
|
|
20493
|
-
input: launch.input,
|
|
20494
|
-
...launch.constraints === undefined ? undefined : { constraints: launch.constraints }
|
|
20495
|
-
})), resolve(childDeferred(launch.step), launch.token, scriptedExit(script.children?.[launch.step], (reason) => new ChildFailed({ step: launch.step, loop: launch.loop, reason })))),
|
|
20496
20582
|
awaitEvent: (launch) => {
|
|
20497
20583
|
const event = script.events?.[launch.step];
|
|
20498
20584
|
waits.push({
|
|
@@ -20508,6 +20594,11 @@ var scriptedHost = (script, engine, agentLaunches, childLaunches, waits, verifyL
|
|
|
20508
20594
|
claimResource: (launch) => flatMap3(script.claimed?.({ step: launch.step, resource: launch.resource, action: launch.action }) ?? undefined_2, (settled) => launch.action === "let_go" ? resolve(letGoDeferred(launch.step), launch.token, succeed4(null)) : resolve(claimDeferred(launch.step), launch.token, succeed4(settled ?? script.claims?.[launch.step] ?? { status: "granted", resource: launch.resource }))),
|
|
20509
20595
|
startVerification: (launch) => {
|
|
20510
20596
|
const scripted = script.verifications?.[launch.step];
|
|
20597
|
+
if (launch.deploy !== undefined) {
|
|
20598
|
+
const deployed = script.deploys?.[launch.step];
|
|
20599
|
+
deployLaunches.push({ step: launch.step, ...launch.deploy });
|
|
20600
|
+
return resolve(deployDeferred(launch.step), launch.token, deployed instanceof ScriptedFailure ? fail5(new StepFailed({ step: launch.step, reason: deployed.reason })) : succeed4(deployed ?? { status: "none", detail: "The repository has no .kitman/deploy" }));
|
|
20601
|
+
}
|
|
20511
20602
|
if (launch.resolve !== undefined) {
|
|
20512
20603
|
const commits = launch.resolve.revisions.map((revision) => {
|
|
20513
20604
|
const scriptedCommit = script.commits?.[revision];
|
|
@@ -20586,6 +20677,9 @@ var testLoop = (loop, script) => {
|
|
|
20586
20677
|
const childLaunches = [];
|
|
20587
20678
|
const waits = [];
|
|
20588
20679
|
const verifyLaunches = [];
|
|
20680
|
+
const deployLaunches = [];
|
|
20681
|
+
const questions = [];
|
|
20682
|
+
const answers = [];
|
|
20589
20683
|
let latestSteps = [];
|
|
20590
20684
|
const declared = capabilitiesOf(loop);
|
|
20591
20685
|
const granted = new Set((script.grant ?? declared).filter((capability) => declared.includes(capability)));
|
|
@@ -20598,7 +20692,7 @@ var testLoop = (loop, script) => {
|
|
|
20598
20692
|
const execute = (payload) => gen2(function* () {
|
|
20599
20693
|
const engine = yield* WorkflowEngine;
|
|
20600
20694
|
return yield* executeLoop(loop, {
|
|
20601
|
-
host: scriptedHost(script, engine, agentLaunches, childLaunches, waits, verifyLaunches),
|
|
20695
|
+
host: scriptedHost(script, engine, agentLaunches, childLaunches, waits, verifyLaunches, deployLaunches, questions, answers),
|
|
20602
20696
|
activities,
|
|
20603
20697
|
granted,
|
|
20604
20698
|
onRun: (run) => {
|
|
@@ -20608,7 +20702,19 @@ var testLoop = (loop, script) => {
|
|
|
20608
20702
|
});
|
|
20609
20703
|
return gen2(function* () {
|
|
20610
20704
|
const result = yield* exit2(workflow.execute({ input: script.input }).pipe(provideService2(ConfigProvider, fromUnknown(script.secrets ?? {}))));
|
|
20611
|
-
return {
|
|
20705
|
+
return {
|
|
20706
|
+
result,
|
|
20707
|
+
steps: latestSteps,
|
|
20708
|
+
journal,
|
|
20709
|
+
activities: ran,
|
|
20710
|
+
agentLaunches,
|
|
20711
|
+
childLaunches,
|
|
20712
|
+
waits,
|
|
20713
|
+
verifyLaunches,
|
|
20714
|
+
deployLaunches,
|
|
20715
|
+
questions,
|
|
20716
|
+
answers
|
|
20717
|
+
};
|
|
20612
20718
|
}).pipe(provide4(workflow.toLayer(execute).pipe(provideMerge(layerMemory))));
|
|
20613
20719
|
};
|
|
20614
20720
|
// ../../packages/sdk/src/loop/review.ts
|
|
@@ -20893,6 +20999,21 @@ var changeRequestBody = (build) => [
|
|
|
20893
20999
|
|
|
20894
21000
|
`);
|
|
20895
21001
|
|
|
21002
|
+
// src/delivery.ts
|
|
21003
|
+
var DeliveryFields = {
|
|
21004
|
+
deliveryTarget: optional2(DeliveryTarget),
|
|
21005
|
+
deliversTo: optional2(ResolvedDeliveryTarget),
|
|
21006
|
+
epic: optional2(EpicDelivery)
|
|
21007
|
+
};
|
|
21008
|
+
var ownDeliveryTarget = (input) => input.deliversTo?.layer === "run" ? { deliveryTarget: input.deliversTo.target } : undefined;
|
|
21009
|
+
var epicOf = (input) => input.deliversTo?.target === "epic_branch" ? input.epic : undefined;
|
|
21010
|
+
var deliveryLayerWords = {
|
|
21011
|
+
run: "this Run",
|
|
21012
|
+
project: "its Project",
|
|
21013
|
+
team: "its Team",
|
|
21014
|
+
workspace: "the Workspace"
|
|
21015
|
+
};
|
|
21016
|
+
|
|
20896
21017
|
// src/text-limits.ts
|
|
20897
21018
|
var bounded2 = (maxLength, description) => String5.check(isMaxLength(maxLength)).annotate({ description });
|
|
20898
21019
|
var OneSentence = bounded2(300, "One sentence, at most 300 characters.");
|
|
@@ -20929,7 +21050,8 @@ var Input = Struct({
|
|
|
20929
21050
|
earlier: optional2(ArraySchema(MergedFinding)),
|
|
20930
21051
|
failing: optional2(ArraySchema(String5)),
|
|
20931
21052
|
notRun: optional2(ArraySchema(String5)),
|
|
20932
|
-
next: optional2(Literals(choices))
|
|
21053
|
+
next: optional2(Literals(choices)),
|
|
21054
|
+
...DeliveryFields
|
|
20933
21055
|
});
|
|
20934
21056
|
var FollowUpStatus = Literals(["fixed", "changed", "still_there"]);
|
|
20935
21057
|
var FollowUp = Struct({ id: String5, status: FollowUpStatus });
|
|
@@ -20955,7 +21077,8 @@ var Output = Struct({
|
|
|
20955
21077
|
artifactId: String5,
|
|
20956
21078
|
scope: optional2(ScopeJudgement),
|
|
20957
21079
|
approval: optional2(Struct({ head: String5, approved: Boolean3, reason: optional2(String5) })),
|
|
20958
|
-
next: optional2(Struct({ choice: Literals(choices), detail: optional2(String5) }))
|
|
21080
|
+
next: optional2(Struct({ choice: Literals(choices), detail: optional2(String5) })),
|
|
21081
|
+
deliversTo: optional2(ResolvedDeliveryTarget)
|
|
20959
21082
|
});
|
|
20960
21083
|
|
|
20961
21084
|
class ReviewTargetMissing extends TaggedError3()("ReviewTargetMissing", {
|
|
@@ -21085,7 +21208,7 @@ var fixBrief = (changeRequestId, findings) => [
|
|
|
21085
21208
|
`);
|
|
21086
21209
|
var review_default = defineLoop({
|
|
21087
21210
|
id: "review",
|
|
21088
|
-
version: "3.
|
|
21211
|
+
version: "3.8.0",
|
|
21089
21212
|
title: "Review",
|
|
21090
21213
|
input: Input,
|
|
21091
21214
|
output: Output,
|
|
@@ -21129,13 +21252,10 @@ var review_default = defineLoop({
|
|
|
21129
21252
|
const answered = followUpsOf(earlier, outputs.flatMap(([, output]) => output.followUps ?? []));
|
|
21130
21253
|
const standing = new Set(answered.flatMap((entry) => entry.status === "fixed" ? [] : [entry.id]));
|
|
21131
21254
|
const verdicts = outputs.flatMap(([, output]) => output.verdicts ?? []);
|
|
21132
|
-
const
|
|
21133
|
-
const withdrawn = (
|
|
21134
|
-
|
|
21135
|
-
|
|
21136
|
-
};
|
|
21137
|
-
const carried = earlier.filter((finding) => standing.has(finding.id) && !withdrawn(finding.id));
|
|
21138
|
-
const followUps = answered.filter((entry) => !withdrawn(entry.id));
|
|
21255
|
+
const settled = settleRound({ findings: earlier, rebuttals: input.rebuttals ?? [], verdicts });
|
|
21256
|
+
const withdrawn = new Set(settled.withdrawn.map((entry) => entry.finding.id));
|
|
21257
|
+
const carried = earlier.filter((finding) => standing.has(finding.id) && !withdrawn.has(finding.id));
|
|
21258
|
+
const followUps = answered.filter((entry) => !withdrawn.has(entry.id));
|
|
21139
21259
|
const sinceApproval = input.approved !== undefined && input.files === undefined;
|
|
21140
21260
|
const merged = (approvedCode) => mergeFindings(Object.fromEntries(outputs.map(([seat, output]) => [
|
|
21141
21261
|
seat,
|
|
@@ -21163,7 +21283,8 @@ var review_default = defineLoop({
|
|
|
21163
21283
|
blocking: findings.some(isBlocking),
|
|
21164
21284
|
artifactId: stored.artifactId,
|
|
21165
21285
|
...approvedFindings.length === 0 ? undefined : { approvedFindings },
|
|
21166
|
-
...scope === undefined ? undefined : { scope }
|
|
21286
|
+
...scope === undefined ? undefined : { scope },
|
|
21287
|
+
...input.deliversTo === undefined ? undefined : { deliversTo: input.deliversTo }
|
|
21167
21288
|
};
|
|
21168
21289
|
const changeRequestId = input.changeRequestId;
|
|
21169
21290
|
if (changeRequestId === undefined || head === undefined)
|
|
@@ -21197,25 +21318,37 @@ What next?`,
|
|
|
21197
21318
|
const fixed = yield* call("fix", buildLoop(), {
|
|
21198
21319
|
words: fixBrief(changeRequestId, findings),
|
|
21199
21320
|
changeRequestId,
|
|
21200
|
-
maxRounds: 2
|
|
21321
|
+
maxRounds: 2,
|
|
21322
|
+
...ownDeliveryTarget(input)
|
|
21201
21323
|
});
|
|
21202
21324
|
return { choice, detail: fixed.settled ? "Fixed and pushed" : `Pushed; left: ${fixed.unsettled.join("; ")}` };
|
|
21203
21325
|
}
|
|
21204
21326
|
if (choice === "Build from it") {
|
|
21205
|
-
const built = yield* call("build", buildLoop(), {
|
|
21327
|
+
const built = yield* call("build", buildLoop(), {
|
|
21328
|
+
words: fixBrief(changeRequestId, findings),
|
|
21329
|
+
...ownDeliveryTarget(input)
|
|
21330
|
+
});
|
|
21206
21331
|
return { choice, detail: built.changeRequest.url };
|
|
21207
21332
|
}
|
|
21208
21333
|
return { choice, detail: "The review is kept as an artifact" };
|
|
21209
21334
|
}).pipe(catchTag2("ChildFailed", (failed) => succeed7({ choice, detail: failed.reason })));
|
|
21210
|
-
return {
|
|
21335
|
+
return {
|
|
21336
|
+
...reviewed,
|
|
21337
|
+
...approval === undefined ? undefined : { approval },
|
|
21338
|
+
next
|
|
21339
|
+
};
|
|
21211
21340
|
})
|
|
21212
21341
|
});
|
|
21213
21342
|
|
|
21214
21343
|
// src/release.ts
|
|
21344
|
+
var ApprovalRef = String5.check(isMinLength(1), isMaxLength(240));
|
|
21345
|
+
var approvalRef = (event) => [event?.payload.reviewId, event?.payload.approvalId].find(is2(ApprovalRef));
|
|
21215
21346
|
var Input2 = Struct({
|
|
21216
21347
|
tag: optional2(String5),
|
|
21217
21348
|
revision: optional2(String5),
|
|
21349
|
+
review: optional2(ApprovalRef),
|
|
21218
21350
|
changeRequestId: optional2(String5),
|
|
21351
|
+
taskId: optional2(String5),
|
|
21219
21352
|
deployTarget: optional2(String5),
|
|
21220
21353
|
deployEvent: optional2(String5),
|
|
21221
21354
|
deployTimeoutMinutes: optional2(Int),
|
|
@@ -21224,7 +21357,8 @@ var Input2 = Struct({
|
|
|
21224
21357
|
releaseWhen: optional2(ResolvedReleaseTrigger),
|
|
21225
21358
|
releaseScope: optional2(ReleaseScope),
|
|
21226
21359
|
version: optional2(String5),
|
|
21227
|
-
candidate: optional2(Boolean3)
|
|
21360
|
+
candidate: optional2(Boolean3),
|
|
21361
|
+
...DeliveryFields
|
|
21228
21362
|
});
|
|
21229
21363
|
var Drafted = Struct({
|
|
21230
21364
|
tag: String5,
|
|
@@ -21237,19 +21371,6 @@ var Picked = Struct({
|
|
|
21237
21371
|
...Drafted.fields,
|
|
21238
21372
|
releasedIn: optional2(String5)
|
|
21239
21373
|
});
|
|
21240
|
-
var Deployed = Struct({
|
|
21241
|
-
status: Literals(["deployed", "failed", "rolled_back", "rollback_failed", "none"]),
|
|
21242
|
-
detail: FindingDetail
|
|
21243
|
-
});
|
|
21244
|
-
var deployPrompt = (tag, previousTag) => [
|
|
21245
|
-
`Deploy the release ${tag}, which Kitman has just tagged and pushed.`,
|
|
21246
|
-
`Fetch the base branch and tags (\`git fetch origin --tags\`). If neither the base branch head nor ${tag} has an executable \`.kitman/deploy\`, change nothing and answer status none.`,
|
|
21247
|
-
`Otherwise run \`.kitman/deploy ${tag}${previousTag === undefined ? "" : ` ${previousTag}`}\` from a checkout of the base branch head when it has the script, so a rerun of an older tag gets the script's later fixes, or else from the checkout of ${tag}, and do nothing else: it deploys the tag it is given, backs up, publishes, verifies and rolls back by itself, and may take an hour. Run it in the background with its output in a log file, and wait for it to exit, checking every few minutes; never start it twice.`,
|
|
21248
|
-
"Answer with the status its last line `kitman-deploy: <status> <detail>` names, and that detail. If it exited without that line, answer failed with its exit code and the end of its log.",
|
|
21249
|
-
"Never print, copy or summarise the variables or secrets it pulls."
|
|
21250
|
-
].join(`
|
|
21251
|
-
|
|
21252
|
-
`);
|
|
21253
21374
|
var Output2 = Struct({
|
|
21254
21375
|
status: Literals([
|
|
21255
21376
|
"gate_failed",
|
|
@@ -21267,9 +21388,11 @@ var Output2 = Struct({
|
|
|
21267
21388
|
reason: String5,
|
|
21268
21389
|
tag: optional2(String5),
|
|
21269
21390
|
notesArtifactId: optional2(String5),
|
|
21391
|
+
leftUndeployed: optional2(Boolean3),
|
|
21270
21392
|
revision: optional2(String5),
|
|
21271
21393
|
url: optional2(String5),
|
|
21272
21394
|
releaseWhen: optional2(ResolvedReleaseTrigger),
|
|
21395
|
+
deliversTo: optional2(ResolvedDeliveryTarget),
|
|
21273
21396
|
shipped: optional2(ShippedScope)
|
|
21274
21397
|
});
|
|
21275
21398
|
var triggerWords = {
|
|
@@ -21388,7 +21511,8 @@ var readyToMerge = (changeRequestId, round = 1) => gen2(function* () {
|
|
|
21388
21511
|
status: "not_mergeable",
|
|
21389
21512
|
reason: `ChangeRequest ${changeRequestId} does not merge cleanly; bring it up to date first`
|
|
21390
21513
|
};
|
|
21391
|
-
|
|
21514
|
+
const review = approvalRef(approved);
|
|
21515
|
+
return { passed: read.head, ...review === undefined ? undefined : { review } };
|
|
21392
21516
|
}
|
|
21393
21517
|
}).pipe(catchTags2({
|
|
21394
21518
|
WaitTimedOut: (timedOut) => succeed7({
|
|
@@ -21403,11 +21527,11 @@ var readyToMerge = (changeRequestId, round = 1) => gen2(function* () {
|
|
|
21403
21527
|
var recovery = (previous) => previous === undefined ? ["Retry the deploy", "Leave it"] : ["Retry the deploy", `Roll back to ${previous}`, "Leave it"];
|
|
21404
21528
|
var release_default = defineLoop({
|
|
21405
21529
|
id: "release",
|
|
21406
|
-
version: "2.
|
|
21530
|
+
version: "2.4.0",
|
|
21407
21531
|
title: "Release",
|
|
21408
21532
|
input: Input2,
|
|
21409
21533
|
output: Output2,
|
|
21410
|
-
agents: { releaser: "releaser"
|
|
21534
|
+
agents: { releaser: "releaser" },
|
|
21411
21535
|
checkout: "read",
|
|
21412
21536
|
when: [
|
|
21413
21537
|
{
|
|
@@ -21419,6 +21543,13 @@ var release_default = defineLoop({
|
|
|
21419
21543
|
releaseWhen: "releaseWhen",
|
|
21420
21544
|
repoBindingId: "repoBindingId"
|
|
21421
21545
|
}
|
|
21546
|
+
},
|
|
21547
|
+
{
|
|
21548
|
+
event: "change_request.ready",
|
|
21549
|
+
filter: { busy: false },
|
|
21550
|
+
input: { changeRequestId: "changeRequestId", taskId: "taskId" },
|
|
21551
|
+
optIn: true,
|
|
21552
|
+
description: "Releases a ChangeRequest delivering a Task once it is approved and green and no Run works it, only under a merge release trigger; under a Milestone or Project trigger each such Run ends not_due."
|
|
21422
21553
|
}
|
|
21423
21554
|
],
|
|
21424
21555
|
capabilities: [
|
|
@@ -21437,6 +21568,12 @@ var release_default = defineLoop({
|
|
|
21437
21568
|
status: "not_due",
|
|
21438
21569
|
reason: `Release runs when ${triggerWords[when.trigger]}, as ${layerWords[when.layer]} says; this Run did not override that`
|
|
21439
21570
|
};
|
|
21571
|
+
const epic = epicOf(input);
|
|
21572
|
+
if (epic !== undefined && !epic.done)
|
|
21573
|
+
return {
|
|
21574
|
+
status: "not_due",
|
|
21575
|
+
reason: `Its Task lands on ${epic.branch}, as ${deliveryLayerWords[input.deliversTo?.layer ?? "workspace"]} says; Release runs once epic ${epic.key} merges into ${epic.defaultBranch}`
|
|
21576
|
+
};
|
|
21440
21577
|
if (input.releaseScope !== undefined && input.tag === undefined && input.version === undefined)
|
|
21441
21578
|
return {
|
|
21442
21579
|
status: "no_version",
|
|
@@ -21445,6 +21582,7 @@ var release_default = defineLoop({
|
|
|
21445
21582
|
};
|
|
21446
21583
|
const changeRequestId = input.changeRequestId;
|
|
21447
21584
|
let gated;
|
|
21585
|
+
let review = input.review;
|
|
21448
21586
|
if (changeRequestId === undefined) {
|
|
21449
21587
|
const gate = yield* verify("gate", {
|
|
21450
21588
|
...input.revision === undefined ? undefined : { revision: input.revision },
|
|
@@ -21488,6 +21626,7 @@ var release_default = defineLoop({
|
|
|
21488
21626
|
if (!("passed" in ready))
|
|
21489
21627
|
return ready;
|
|
21490
21628
|
gated = ready.passed;
|
|
21629
|
+
review = ready.review;
|
|
21491
21630
|
}
|
|
21492
21631
|
const cut = input.tag === undefined && input.version !== undefined ? { version: input.version, candidate: input.candidate === true } : undefined;
|
|
21493
21632
|
const tagOf = (proposed, fallback) => {
|
|
@@ -21526,7 +21665,8 @@ ${drafted.notes}`,
|
|
|
21526
21665
|
recommended: "Approve",
|
|
21527
21666
|
recommendationReason: "The release is proved: its checks pass, or its ChangeRequest is green, approved and mergeable.",
|
|
21528
21667
|
default: null,
|
|
21529
|
-
auto: "Approve"
|
|
21668
|
+
auto: "Approve",
|
|
21669
|
+
evidence: { ...review === undefined ? undefined : { review }, head: gated }
|
|
21530
21670
|
});
|
|
21531
21671
|
if (answer === "Approve")
|
|
21532
21672
|
break;
|
|
@@ -21588,6 +21728,26 @@ ${drafted.notes}`,
|
|
|
21588
21728
|
if (!("passed" in ready))
|
|
21589
21729
|
return { ...ready, tag, notesArtifactId: notes.artifactId };
|
|
21590
21730
|
gated = ready.passed;
|
|
21731
|
+
review = ready.review;
|
|
21732
|
+
const again = yield* ask(`approve:merge:${round + 1}`, {
|
|
21733
|
+
prompt: `ChangeRequest ${changeRequestId} moved to ${gated} after ${tag} was approved; its pipeline passed and it is approved again. Release ${tag} from it?`,
|
|
21734
|
+
options: [
|
|
21735
|
+
{ value: "Approve", description: "Merges this head, then tags, publishes and deploys it." },
|
|
21736
|
+
{ value: "Reject", description: "Keeps the draft and releases nothing." }
|
|
21737
|
+
],
|
|
21738
|
+
recommended: "Approve",
|
|
21739
|
+
recommendationReason: "This head is green, approved and mergeable, like the one you approved.",
|
|
21740
|
+
default: null,
|
|
21741
|
+
auto: "Approve",
|
|
21742
|
+
evidence: { ...review === undefined ? undefined : { review }, head: gated }
|
|
21743
|
+
});
|
|
21744
|
+
if (again !== "Approve")
|
|
21745
|
+
return {
|
|
21746
|
+
status: "rejected",
|
|
21747
|
+
reason: `Not released from ${gated}, the head ChangeRequest ${changeRequestId} moved to`,
|
|
21748
|
+
tag,
|
|
21749
|
+
notesArtifactId: notes.artifactId
|
|
21750
|
+
};
|
|
21591
21751
|
}
|
|
21592
21752
|
}
|
|
21593
21753
|
const deployEvent = input.deployEvent ?? "deploy";
|
|
@@ -21640,12 +21800,7 @@ ${drafted.notes}`,
|
|
|
21640
21800
|
timeout: `${input.deployTimeoutMinutes ?? 60} minutes`
|
|
21641
21801
|
}).pipe(map8((deploy) => deploy.payload.status === "failed" ? "deploy_failed" : "deployed"), catchTag2("WaitTimedOut", () => succeed7("timed_out")));
|
|
21642
21802
|
const settled = { tag, notesArtifactId: notes.artifactId, revision: released.revision, url: released.url };
|
|
21643
|
-
const ran = yield*
|
|
21644
|
-
agent: "deployer",
|
|
21645
|
-
prompt: deployPrompt(tag, drafted.previousTag),
|
|
21646
|
-
output: Deployed,
|
|
21647
|
-
timeout: "3 hours"
|
|
21648
|
-
});
|
|
21803
|
+
const ran = yield* runDeploy("run-deploy", { tag, previousTag: drafted.previousTag });
|
|
21649
21804
|
if (ran.status !== "none") {
|
|
21650
21805
|
const status = ran.status === "failed" ? "deploy_failed" : ran.status;
|
|
21651
21806
|
const outcome = {
|
|
@@ -21670,11 +21825,15 @@ ${drafted.notes}`,
|
|
|
21670
21825
|
options,
|
|
21671
21826
|
recommended: "Retry the deploy",
|
|
21672
21827
|
recommendationReason: "A failed or late deploy is often passing, and a retry runs only the failed jobs of the same tag.",
|
|
21673
|
-
default:
|
|
21674
|
-
timeout: "1 hour"
|
|
21828
|
+
default: null
|
|
21675
21829
|
});
|
|
21676
21830
|
if (answer === "Leave it")
|
|
21677
|
-
return {
|
|
21831
|
+
return {
|
|
21832
|
+
status,
|
|
21833
|
+
reason: `${tag} at ${released.revision} was left undeployed`,
|
|
21834
|
+
leftUndeployed: true,
|
|
21835
|
+
...settled
|
|
21836
|
+
};
|
|
21678
21837
|
if (answer === "Retry the deploy") {
|
|
21679
21838
|
yield* rerunPipeline(`deploy:rerun-${round}`, { ref: tag });
|
|
21680
21839
|
status = yield* deployed(`deploy:retry-${round}`, tag);
|
|
@@ -21697,6 +21856,7 @@ ${drafted.notes}`,
|
|
|
21697
21856
|
}).pipe(map8((output) => ({
|
|
21698
21857
|
...output,
|
|
21699
21858
|
...input.releaseWhen === undefined ? undefined : { releaseWhen: input.releaseWhen },
|
|
21859
|
+
...input.deliversTo === undefined ? undefined : { deliversTo: input.deliversTo },
|
|
21700
21860
|
...input.releaseScope === undefined ? undefined : { shipped: shippedScope(input.releaseScope) }
|
|
21701
21861
|
})))
|
|
21702
21862
|
});
|
|
@@ -21710,6 +21870,8 @@ var ShepherdOutput = Struct({
|
|
|
21710
21870
|
unsettled: optional2(ArraySchema(String5)),
|
|
21711
21871
|
release: optional2(Struct({ runStatus: String5, reason: String5, tag: optional2(String5) })),
|
|
21712
21872
|
releaseWhen: optional2(ResolvedReleaseTrigger),
|
|
21873
|
+
deliversTo: optional2(ResolvedDeliveryTarget),
|
|
21874
|
+
epicLanding: optional2(Struct({ status: String5, reason: String5 })),
|
|
21713
21875
|
handBack: optional2(Struct({
|
|
21714
21876
|
changeRequestId: String5,
|
|
21715
21877
|
words: String5,
|
|
@@ -21718,11 +21880,105 @@ var ShepherdOutput = Struct({
|
|
|
21718
21880
|
}))
|
|
21719
21881
|
});
|
|
21720
21882
|
|
|
21883
|
+
// src/land-epic.ts
|
|
21884
|
+
var LandEpicInput = Struct({
|
|
21885
|
+
taskId: String5,
|
|
21886
|
+
landsEpic: optional2(Boolean3),
|
|
21887
|
+
merge: optional2(Boolean3),
|
|
21888
|
+
continuing: optional2(Continuing),
|
|
21889
|
+
...DeliveryFields
|
|
21890
|
+
});
|
|
21891
|
+
var LandEpicOutput = Struct({
|
|
21892
|
+
status: Literals([
|
|
21893
|
+
"not_epic",
|
|
21894
|
+
"synced",
|
|
21895
|
+
"landed",
|
|
21896
|
+
"conflict",
|
|
21897
|
+
"opened"
|
|
21898
|
+
]),
|
|
21899
|
+
reason: String5,
|
|
21900
|
+
changeRequest: optional2(ChangeRequestResult),
|
|
21901
|
+
landed: optional2(ShepherdOutput),
|
|
21902
|
+
deliversTo: optional2(ResolvedDeliveryTarget)
|
|
21903
|
+
});
|
|
21904
|
+
var landEpic = defineLoop({
|
|
21905
|
+
id: "land-epic",
|
|
21906
|
+
version: "1.0.0",
|
|
21907
|
+
title: "Land epic",
|
|
21908
|
+
input: LandEpicInput,
|
|
21909
|
+
output: LandEpicOutput,
|
|
21910
|
+
agents: { implementer: "implementer" },
|
|
21911
|
+
checkout: "write",
|
|
21912
|
+
capabilities: ["agent_work", "change_request", "write_back", "call"],
|
|
21913
|
+
calls: () => [shepherd_default],
|
|
21914
|
+
when: [{ event: "epic.ready", input: { taskId: "taskId" } }],
|
|
21915
|
+
run: (input) => gen2(function* () {
|
|
21916
|
+
const epic = epicOf(input);
|
|
21917
|
+
const recorded = input.deliversTo === undefined ? undefined : { deliversTo: input.deliversTo };
|
|
21918
|
+
if (epic === undefined)
|
|
21919
|
+
return {
|
|
21920
|
+
status: "not_epic",
|
|
21921
|
+
reason: input.deliversTo === undefined ? "The Task delivers to no epic branch" : `The Task lands ${input.deliversTo.target === "epic_branch" ? "on no epic" : "on the default branch"}, as ${deliveryLayerWords[input.deliversTo.layer]} says`,
|
|
21922
|
+
...recorded
|
|
21923
|
+
};
|
|
21924
|
+
if (epic.done)
|
|
21925
|
+
return {
|
|
21926
|
+
status: "landed",
|
|
21927
|
+
reason: `Epic ${epic.key} is done: its ChangeRequest merged into ${epic.defaultBranch}`,
|
|
21928
|
+
...recorded
|
|
21929
|
+
};
|
|
21930
|
+
const synced = yield* syncBase("sync-default", { agent: "implementer", target: epic.defaultBranch });
|
|
21931
|
+
if (synced.status === "conflict")
|
|
21932
|
+
return {
|
|
21933
|
+
status: "conflict",
|
|
21934
|
+
reason: `${epic.defaultBranch} conflicts with ${epic.branch} in ${synced.files.join(", ")}: ${synced.reason}`,
|
|
21935
|
+
...recorded
|
|
21936
|
+
};
|
|
21937
|
+
if (!epic.subTasksDone && input.continuing === undefined)
|
|
21938
|
+
return {
|
|
21939
|
+
status: "synced",
|
|
21940
|
+
reason: `${epic.branch} is up to date with ${epic.defaultBranch}; ${epic.key} lands once every sub-task is done`,
|
|
21941
|
+
...recorded
|
|
21942
|
+
};
|
|
21943
|
+
const opened = input.continuing === undefined ? yield* changeRequest("epic-change-request", {
|
|
21944
|
+
title: `${epic.key} Land the epic`,
|
|
21945
|
+
body: [
|
|
21946
|
+
`Lands epic ${epic.key} on ${epic.defaultBranch}: every sub-task is done, and each merged into ${epic.branch} through its own ChangeRequest.`,
|
|
21947
|
+
`${epic.branch} took in ${epic.defaultBranch} before this opened.`
|
|
21948
|
+
].join(`
|
|
21949
|
+
|
|
21950
|
+
`)
|
|
21951
|
+
}) : { id: input.continuing.changeRequestId, number: input.continuing.number, url: input.continuing.url };
|
|
21952
|
+
if (input.continuing === undefined)
|
|
21953
|
+
yield* writeBack("write-back", { milestone: "change_request_opened", changeRequestUrl: opened.url });
|
|
21954
|
+
const landed = yield* call("shepherd", shepherd_default, {
|
|
21955
|
+
changeRequestId: opened.id,
|
|
21956
|
+
taskId: epic.taskId,
|
|
21957
|
+
...input.merge === undefined ? undefined : { merge: input.merge },
|
|
21958
|
+
...ownDeliveryTarget(input)
|
|
21959
|
+
});
|
|
21960
|
+
return {
|
|
21961
|
+
status: "opened",
|
|
21962
|
+
reason: `${opened.url} lands ${epic.key}; Shepherd ended ${landed.status}: ${landed.reason}`,
|
|
21963
|
+
changeRequest: opened,
|
|
21964
|
+
landed,
|
|
21965
|
+
...recorded
|
|
21966
|
+
};
|
|
21967
|
+
})
|
|
21968
|
+
});
|
|
21969
|
+
var land_epic_default = landEpic;
|
|
21970
|
+
|
|
21721
21971
|
// src/shepherd.ts
|
|
21722
21972
|
var reviewLoop = () => ({ id: "review", input: Input, output: Output });
|
|
21973
|
+
var landEpicLoop = () => ({ id: "land-epic", input: LandEpicInput, output: LandEpicOutput });
|
|
21974
|
+
var landingCalls = 6;
|
|
21975
|
+
var landingRetry = "10 minutes";
|
|
21976
|
+
var landingStatus = (code) => code === "epic_landing" ? "landing" : code === "task_branch_busy" ? "busy" : "refused";
|
|
21723
21977
|
var stepBudget = "45 minutes";
|
|
21724
21978
|
var pipelineRun = "10 minutes";
|
|
21725
21979
|
var targetLooks = 6;
|
|
21980
|
+
var watchLook = "6 hours";
|
|
21981
|
+
var watchLooks = 28;
|
|
21726
21982
|
var roundLimits = { "ci-fix": 1, "head-fix": 2 };
|
|
21727
21983
|
var handBackAnswer = "Hand back to Build";
|
|
21728
21984
|
var Input3 = Struct({
|
|
@@ -21734,7 +21990,8 @@ var Input3 = Struct({
|
|
|
21734
21990
|
continuing: optional2(Continuing),
|
|
21735
21991
|
maxCycles: optional2(Int),
|
|
21736
21992
|
releaseTrigger: optional2(ReleaseTrigger),
|
|
21737
|
-
releaseWhen: optional2(ResolvedReleaseTrigger)
|
|
21993
|
+
releaseWhen: optional2(ResolvedReleaseTrigger),
|
|
21994
|
+
...DeliveryFields
|
|
21738
21995
|
});
|
|
21739
21996
|
var layerWords2 = { run: "this Run", project: "its Project", team: "its Team", workspace: "the Workspace" };
|
|
21740
21997
|
var Output3 = ShepherdOutput;
|
|
@@ -21809,12 +22066,20 @@ var repliesPrompt = (threads) => [
|
|
|
21809
22066
|
var threadKey = (thread) => `${thread.id}:${thread.comments.length}`;
|
|
21810
22067
|
var shepherd_default = defineLoop({
|
|
21811
22068
|
id: "shepherd",
|
|
21812
|
-
version: "1.
|
|
22069
|
+
version: "1.8.0",
|
|
21813
22070
|
title: "Shepherd",
|
|
21814
22071
|
input: Input3,
|
|
21815
22072
|
output: Output3,
|
|
21816
22073
|
agents: { implementer: "implementer" },
|
|
21817
22074
|
checkout: "write",
|
|
22075
|
+
when: [
|
|
22076
|
+
{
|
|
22077
|
+
event: "change_request.pipeline",
|
|
22078
|
+
filter: { status: "failed", source: "forge", linked: true },
|
|
22079
|
+
input: { changeRequestId: "changeRequestId", taskId: "taskId" },
|
|
22080
|
+
optIn: true
|
|
22081
|
+
}
|
|
22082
|
+
],
|
|
21818
22083
|
capabilities: [
|
|
21819
22084
|
"agent_work",
|
|
21820
22085
|
"read_change_request",
|
|
@@ -21827,7 +22092,7 @@ var shepherd_default = defineLoop({
|
|
|
21827
22092
|
"verify",
|
|
21828
22093
|
"claim"
|
|
21829
22094
|
],
|
|
21830
|
-
calls: () => [review_default, release_default],
|
|
22095
|
+
calls: () => [review_default, release_default, land_epic_default],
|
|
21831
22096
|
offers: [{ id: "build", title: "Hand back to Build", loop: "build", from: "handBack" }],
|
|
21832
22097
|
run: (input) => {
|
|
21833
22098
|
const changeRequestId = input.changeRequestId;
|
|
@@ -21847,6 +22112,7 @@ var shepherd_default = defineLoop({
|
|
|
21847
22112
|
let reviewOnceShown;
|
|
21848
22113
|
let pipelineFirst;
|
|
21849
22114
|
const reviewedHeads = new Set;
|
|
22115
|
+
const approvalOf = new Map;
|
|
21850
22116
|
let notCarried;
|
|
21851
22117
|
let behind = false;
|
|
21852
22118
|
let pushed;
|
|
@@ -21855,6 +22121,8 @@ var shepherd_default = defineLoop({
|
|
|
21855
22121
|
const syncedKey = (head, targetHead) => `${head}@${targetHead}`;
|
|
21856
22122
|
const blockerSynced = new Set;
|
|
21857
22123
|
const blockerRechecks = new Map;
|
|
22124
|
+
let lastSync;
|
|
22125
|
+
let targetChecked;
|
|
21858
22126
|
let turn;
|
|
21859
22127
|
let turns = 0;
|
|
21860
22128
|
let passes = 0;
|
|
@@ -21867,9 +22135,36 @@ var shepherd_default = defineLoop({
|
|
|
21867
22135
|
fixRounds: fixRounds(),
|
|
21868
22136
|
replies,
|
|
21869
22137
|
...input.releaseWhen === undefined ? undefined : { releaseWhen: input.releaseWhen },
|
|
22138
|
+
...input.deliversTo === undefined ? undefined : { deliversTo: input.deliversTo },
|
|
21870
22139
|
...status === "needs_you" || status === "handed_back" ? { unsettled: [reason] } : undefined
|
|
21871
22140
|
});
|
|
21872
22141
|
const releaseWhen = input.releaseWhen;
|
|
22142
|
+
const epic = epicOf(input);
|
|
22143
|
+
const landEpicAfter = (landing) => gen2(function* () {
|
|
22144
|
+
for (let attempt = 1;; attempt++) {
|
|
22145
|
+
const step = attempt === 1 ? "land-epic" : `land-epic:${attempt}`;
|
|
22146
|
+
const called = yield* call(step, landEpicLoop(), {
|
|
22147
|
+
taskId: landing.taskId,
|
|
22148
|
+
...ownDeliveryTarget(input)
|
|
22149
|
+
}).pipe(map8((landed) => ({ status: landed.status, reason: landed.reason })), catchTags2({
|
|
22150
|
+
ChildFailed: (failed) => succeed7({ status: "failed", reason: failed.reason }),
|
|
22151
|
+
StepFailed: (refused) => succeed7({ status: landingStatus(refused.code), reason: refused.reason })
|
|
22152
|
+
}));
|
|
22153
|
+
if (called.status !== "busy")
|
|
22154
|
+
return called;
|
|
22155
|
+
if (attempt === landingCalls)
|
|
22156
|
+
return { status: "refused", reason: called.reason };
|
|
22157
|
+
yield* waitFor(`land-epic-busy:${attempt}`, {
|
|
22158
|
+
event: "change_request.closed",
|
|
22159
|
+
filter: {
|
|
22160
|
+
merged: true,
|
|
22161
|
+
targetBranch: landing.branch,
|
|
22162
|
+
...repository === undefined ? undefined : { repository }
|
|
22163
|
+
},
|
|
22164
|
+
timeout: landingRetry
|
|
22165
|
+
}).pipe(catchTag2("WaitTimedOut", () => void_3));
|
|
22166
|
+
}
|
|
22167
|
+
});
|
|
21873
22168
|
const handBack = (reason, open) => ({
|
|
21874
22169
|
...done("handed_back", reason),
|
|
21875
22170
|
handBack: {
|
|
@@ -22000,6 +22295,7 @@ ${open}`,
|
|
|
22000
22295
|
if (refused !== undefined)
|
|
22001
22296
|
return done("needs_you", `The turn to merge into ${target} was refused: ${refused}`);
|
|
22002
22297
|
const synced = yield* syncBase(`sync:${cycle}`, { agent: "implementer", target });
|
|
22298
|
+
lastSync = synced.status;
|
|
22003
22299
|
if (synced.status === "conflict")
|
|
22004
22300
|
return handBack(`Merging ${target} in conflicts on ${synced.files.join(", ")}: ${synced.reason}`, synced.files.map((file) => `- ${file}`).join(`
|
|
22005
22301
|
`));
|
|
@@ -22044,6 +22340,60 @@ ${open}`,
|
|
|
22044
22340
|
return;
|
|
22045
22341
|
});
|
|
22046
22342
|
const stop = (output) => ({ kind: "stop", output });
|
|
22343
|
+
const watchTarget = (cycle, pipeline, ready) => gen2(function* () {
|
|
22344
|
+
const checks = pipeline.targetChecks ?? [];
|
|
22345
|
+
if (checks.length === 0)
|
|
22346
|
+
return stop(ready);
|
|
22347
|
+
yield* passTurn();
|
|
22348
|
+
const runChecks = (step, targetHead) => gen2(function* () {
|
|
22349
|
+
const checked = yield* verify(step, { revision: pipeline.head, checks }).pipe(catchTag2("StepFailed", (error) => succeed7({ failed: error.reason })));
|
|
22350
|
+
if ("failed" in checked)
|
|
22351
|
+
return stop(done("needs_you", `${checks.join(", ")} could not run against ${target} as it moved: ${checked.failed}`));
|
|
22352
|
+
if (targetHead !== undefined)
|
|
22353
|
+
targetChecked = { head: pipeline.head, targetHead };
|
|
22354
|
+
if (checked.passed)
|
|
22355
|
+
return;
|
|
22356
|
+
const stopped = yield* catchUp(cycle, targetHead);
|
|
22357
|
+
if (stopped !== undefined)
|
|
22358
|
+
return stop(stopped);
|
|
22359
|
+
if (lastSync === "up_to_date")
|
|
22360
|
+
return stop(done("needs_you", `${checks.join(", ")} failed at ${pipeline.head} against ${target}, which has nothing new to merge in`));
|
|
22361
|
+
return { kind: "again" };
|
|
22362
|
+
});
|
|
22363
|
+
const isChecked = (targetHead) => targetHead !== undefined && targetChecked?.head === pipeline.head && targetChecked.targetHead === targetHead;
|
|
22364
|
+
if (!isChecked(pipeline.target?.head)) {
|
|
22365
|
+
const first = yield* runChecks(`target-verify:${cycle}:0`, pipeline.target?.head);
|
|
22366
|
+
if (first !== undefined)
|
|
22367
|
+
return first;
|
|
22368
|
+
}
|
|
22369
|
+
let since = pipeline.readAt;
|
|
22370
|
+
for (let look = 1;look <= watchLooks; look++) {
|
|
22371
|
+
const woke = yield* waitFor(`watch:${cycle}:${look}`, {
|
|
22372
|
+
event: "change_request.closed",
|
|
22373
|
+
filter: {
|
|
22374
|
+
merged: true,
|
|
22375
|
+
...target === "HEAD" ? undefined : { targetBranch: target },
|
|
22376
|
+
...repository === undefined ? undefined : { repository }
|
|
22377
|
+
},
|
|
22378
|
+
or: [{ event: "change_request.closed", filter: { changeRequestId } }],
|
|
22379
|
+
timeout: watchLook,
|
|
22380
|
+
...since === undefined ? undefined : { since }
|
|
22381
|
+
}).pipe(catchTag2("WaitTimedOut", () => undefined_2));
|
|
22382
|
+
if (woke?.payload.changeRequestId === changeRequestId)
|
|
22383
|
+
return stop(woke.payload.merged === true ? done("merged", "A person merged the ChangeRequest") : done("needs_you", "The ChangeRequest was closed"));
|
|
22384
|
+
const again = yield* pipelineStatus(`watch-read:${cycle}:${look}`, { changeRequestId });
|
|
22385
|
+
since = again.readAt ?? since;
|
|
22386
|
+
if (again.head !== pipeline.head)
|
|
22387
|
+
return { kind: "again" };
|
|
22388
|
+
const targetHead = again.target?.head;
|
|
22389
|
+
if (woke === undefined && (targetHead === undefined || isChecked(targetHead)))
|
|
22390
|
+
continue;
|
|
22391
|
+
const ran = yield* runChecks(`target-verify:${cycle}:${look}`, targetHead);
|
|
22392
|
+
if (ran !== undefined)
|
|
22393
|
+
return ran;
|
|
22394
|
+
}
|
|
22395
|
+
return stop(ready);
|
|
22396
|
+
});
|
|
22047
22397
|
const reviewMergedFiles = (cycle, head, files) => gen2(function* () {
|
|
22048
22398
|
yield* passTurn();
|
|
22049
22399
|
const reviewed = yield* call(`review:${cycle}`, reviewLoop(), {
|
|
@@ -22080,6 +22430,7 @@ ${open}`,
|
|
|
22080
22430
|
notCarried = `merging ${target} in, whose files' review passed but did not approve it: ${approval.reason}`;
|
|
22081
22431
|
return { kind: "unapproved" };
|
|
22082
22432
|
}
|
|
22433
|
+
approvalOf.set(head, approval.reviewId);
|
|
22083
22434
|
reviewedHeads.add(head);
|
|
22084
22435
|
return { kind: "approved" };
|
|
22085
22436
|
});
|
|
@@ -22099,6 +22450,7 @@ ${open}`,
|
|
|
22099
22450
|
recommendationReason: "A passing Review of the change is what approved the head Build shipped.",
|
|
22100
22451
|
default: "Wait",
|
|
22101
22452
|
auto: "Review",
|
|
22453
|
+
evidence: { head },
|
|
22102
22454
|
timeout: "1 hour"
|
|
22103
22455
|
});
|
|
22104
22456
|
yield* passTurn();
|
|
@@ -22142,6 +22494,7 @@ ${open}`,
|
|
|
22142
22494
|
}).pipe(catchTag2("StepFailed", (error) => succeed7({ approved: false, reason: error.reason })));
|
|
22143
22495
|
if (!recorded.approved)
|
|
22144
22496
|
return stop(done("needs_you", `The review of ${head} passed, but did not approve it: ${recorded.reason}`));
|
|
22497
|
+
approvalOf.set(head, recorded.reviewId);
|
|
22145
22498
|
}
|
|
22146
22499
|
reviewedHeads.add(head);
|
|
22147
22500
|
return { kind: "reviewed" };
|
|
@@ -22418,6 +22771,11 @@ ${open}`,
|
|
|
22418
22771
|
continue;
|
|
22419
22772
|
const unapproved = unranAt.get(pipeline.head);
|
|
22420
22773
|
const notRun = unapproved?.notRun ?? input.notRun ?? [];
|
|
22774
|
+
const approvedBy = () => approvalOf.get(pipeline.head) ?? approvalRef(approved);
|
|
22775
|
+
const evidenceAt = (head) => {
|
|
22776
|
+
const review = approvedBy();
|
|
22777
|
+
return { ...review === undefined ? undefined : { review }, head };
|
|
22778
|
+
};
|
|
22421
22779
|
const merge = input.merge === true && notRun.length === 0 ? "Merge" : yield* ask(`merge:${cycle}`, {
|
|
22422
22780
|
prompt: notRun.length === 0 ? "The ChangeRequest is approved, green and mergeable. Merge now?" : `The ChangeRequest is ${unapproved === undefined ? "approved" : "reviewed with nothing blocking but not approved"}, green and mergeable, but verify never ran some of its tests:
|
|
22423
22781
|
${notRun.map((item) => `- ${item}`).join(`
|
|
@@ -22431,11 +22789,15 @@ Merge now?`,
|
|
|
22431
22789
|
recommended: notRun.length === 0 ? "Merge" : "Wait",
|
|
22432
22790
|
recommendationReason: notRun.length === 0 ? "It is approved, green and mergeable, which is everything a merge waits for." : "Nobody has seen those tests pass, so run them by hand before it lands.",
|
|
22433
22791
|
default: "Wait",
|
|
22434
|
-
...notRun.length === 0 ? { auto: "Merge" } : undefined,
|
|
22792
|
+
...notRun.length === 0 ? { auto: "Merge", evidence: evidenceAt(pipeline.head) } : undefined,
|
|
22435
22793
|
timeout: "1 hour"
|
|
22436
22794
|
});
|
|
22437
|
-
if (merge === "Wait")
|
|
22438
|
-
|
|
22795
|
+
if (merge === "Wait") {
|
|
22796
|
+
const watched = yield* watchTarget(cycle, pipeline, done("ready", unapproved === undefined ? "Approved, green and mergeable; left for a person to merge" : "Reviewed, green and mergeable, but verify never ran some of its tests; left for a person to merge"));
|
|
22797
|
+
if (watched.kind === "stop")
|
|
22798
|
+
return watched.output;
|
|
22799
|
+
continue;
|
|
22800
|
+
}
|
|
22439
22801
|
if (unapproved !== undefined) {
|
|
22440
22802
|
const recorded = yield* approveChangeRequest(`head-approve:${cycle}`, {
|
|
22441
22803
|
changeRequestId,
|
|
@@ -22445,6 +22807,7 @@ Merge now?`,
|
|
|
22445
22807
|
}).pipe(catchTag2("StepFailed", (error) => succeed7({ approved: false, reason: error.reason })));
|
|
22446
22808
|
if (!recorded.approved)
|
|
22447
22809
|
return done("needs_you", `The review of ${pipeline.head} passed, but did not approve it: ${recorded.reason}`);
|
|
22810
|
+
approvalOf.set(pipeline.head, recorded.reviewId);
|
|
22448
22811
|
}
|
|
22449
22812
|
const refused = yield* takeTurn();
|
|
22450
22813
|
if (refused !== undefined)
|
|
@@ -22459,6 +22822,13 @@ Merge now?`,
|
|
|
22459
22822
|
continue;
|
|
22460
22823
|
yield* passTurn();
|
|
22461
22824
|
yield* writeBack("write-back", { milestone: "merged" });
|
|
22825
|
+
if (epic !== undefined && target === epic.branch) {
|
|
22826
|
+
const landing = yield* landEpicAfter(epic);
|
|
22827
|
+
return {
|
|
22828
|
+
...done("merged", `Merged into ${epic.branch} at ${merged.revision}; Release waits for epic ${epic.key} to land on ${epic.defaultBranch}`),
|
|
22829
|
+
epicLanding: landing
|
|
22830
|
+
};
|
|
22831
|
+
}
|
|
22462
22832
|
if (releaseWhen !== undefined && releaseWhen.trigger !== "merge")
|
|
22463
22833
|
return done("merged", `Merged at ${merged.revision}; Release runs when its ${releaseWhen.trigger === "milestone" ? "Milestone" : "Project"} is done, as ${layerWords2[releaseWhen.layer]} says`);
|
|
22464
22834
|
const ship = yield* ask("ship", {
|
|
@@ -22471,13 +22841,17 @@ Merge now?`,
|
|
|
22471
22841
|
recommendationReason: "The merge is approved and green, so it is ready to ship.",
|
|
22472
22842
|
default: "Not now",
|
|
22473
22843
|
auto: "Release",
|
|
22844
|
+
evidence: evidenceAt(merged.revision),
|
|
22474
22845
|
timeout: "1 hour"
|
|
22475
22846
|
});
|
|
22476
22847
|
if (ship === "Not now")
|
|
22477
22848
|
return done("merged", `Merged at ${merged.revision}`);
|
|
22849
|
+
const review = approvedBy();
|
|
22478
22850
|
const released = yield* call("release", release_default, {
|
|
22479
22851
|
revision: merged.revision,
|
|
22480
|
-
...
|
|
22852
|
+
...review === undefined ? undefined : { review },
|
|
22853
|
+
...releaseWhen?.layer === "run" ? { releaseTrigger: releaseWhen.trigger } : undefined,
|
|
22854
|
+
...epic !== undefined && epic.own !== true ? { deliveryTarget: "default_branch" } : ownDeliveryTarget(input)
|
|
22481
22855
|
});
|
|
22482
22856
|
const handedOn = released.status === "gate_failed" && (yield* ask("release-gate-failed", {
|
|
22483
22857
|
prompt: `Merged at ${merged.revision}, but its Release gate failed: ${released.reason}`,
|
|
@@ -22498,7 +22872,7 @@ Merge now?`,
|
|
|
22498
22872
|
...done("merged", `Merged at ${merged.revision}; its Release gate failed, so the next Release ships it`),
|
|
22499
22873
|
release: { runStatus: released.status, reason: released.reason }
|
|
22500
22874
|
};
|
|
22501
|
-
if (released.status !== "deployed" && released.status !== "rejected" && released.status !== "gate_failed" && released.status !== "not_due" && released.status !== "nothing_to_release")
|
|
22875
|
+
if (released.leftUndeployed !== true && released.status !== "deployed" && released.status !== "rejected" && released.status !== "gate_failed" && released.status !== "not_due" && released.status !== "nothing_to_release")
|
|
22502
22876
|
yield* ask("release-failed", {
|
|
22503
22877
|
prompt: `Merged at ${merged.revision}, but its Release ended ${released.status}: ${released.reason}`,
|
|
22504
22878
|
options: [{ value: "Taken over", description: "A person looks at the release and production from here." }],
|
|
@@ -22534,7 +22908,8 @@ var BuildInput = Struct({
|
|
|
22534
22908
|
continuing: optional2(Continuing),
|
|
22535
22909
|
land: optional2(Boolean3),
|
|
22536
22910
|
changeRequestId: optional2(String5),
|
|
22537
|
-
maxRebuilds: optional2(Int.check(isGreaterThanOrEqualTo2(0)))
|
|
22911
|
+
maxRebuilds: optional2(Int.check(isGreaterThanOrEqualTo2(0))),
|
|
22912
|
+
...DeliveryFields
|
|
22538
22913
|
});
|
|
22539
22914
|
var CriterionAnswer = Struct({
|
|
22540
22915
|
criterion: String5,
|
|
@@ -22582,7 +22957,8 @@ var BuildOutput = Struct({
|
|
|
22582
22957
|
notRun: optional2(ArraySchema(String5)),
|
|
22583
22958
|
approval: optional2(ApproveChangeRequestResult),
|
|
22584
22959
|
landed: optional2(ShepherdOutput),
|
|
22585
|
-
next: Struct({ changeRequestId: String5 })
|
|
22960
|
+
next: Struct({ changeRequestId: String5 }),
|
|
22961
|
+
deliversTo: optional2(ResolvedDeliveryTarget)
|
|
22586
22962
|
});
|
|
22587
22963
|
|
|
22588
22964
|
class BuildBlocked extends TaggedError3()("BuildBlocked", {
|
|
@@ -22755,7 +23131,7 @@ var rally = (input) => gen2(function* () {
|
|
|
22755
23131
|
});
|
|
22756
23132
|
var build2 = defineLoop({
|
|
22757
23133
|
id: "build",
|
|
22758
|
-
version: "2.
|
|
23134
|
+
version: "2.7.0",
|
|
22759
23135
|
title: "Build",
|
|
22760
23136
|
input: BuildInput,
|
|
22761
23137
|
output: BuildOutput,
|
|
@@ -22779,7 +23155,10 @@ var build2 = defineLoop({
|
|
|
22779
23155
|
yield* writeBack("write-back:started", { milestone: "started" });
|
|
22780
23156
|
const task = input.words === undefined ? "the Task your brief describes." : `this: ${input.words}`;
|
|
22781
23157
|
const outcome = input.outcome;
|
|
22782
|
-
const
|
|
23158
|
+
const epic = epicOf(input);
|
|
23159
|
+
const target = input.continuing?.targetBranch ?? input.branch ?? epic?.branch;
|
|
23160
|
+
if (epic !== undefined && input.continuing === undefined && input.branch === undefined)
|
|
23161
|
+
yield* deliveryBase("epic-branch");
|
|
22783
23162
|
if (input.changeRequestId !== undefined && input.continuing?.changeRequestId !== input.changeRequestId)
|
|
22784
23163
|
return yield* new BuildTargetMissing({
|
|
22785
23164
|
message: `Kitman did not put this Run on ChangeRequest ${input.changeRequestId}'s branch`
|
|
@@ -22912,7 +23291,8 @@ var build2 = defineLoop({
|
|
|
22912
23291
|
...input.outcome === undefined ? undefined : { outcome: input.outcome },
|
|
22913
23292
|
...input.maxRounds === undefined ? undefined : { maxRounds: input.maxRounds },
|
|
22914
23293
|
changeRequestId: opened.id,
|
|
22915
|
-
land: false
|
|
23294
|
+
land: false,
|
|
23295
|
+
...ownDeliveryTarget(input)
|
|
22916
23296
|
}, { constraints: standing.map(standingConstraint) });
|
|
22917
23297
|
settledAs = rebuilt;
|
|
22918
23298
|
}
|
|
@@ -22920,13 +23300,15 @@ var build2 = defineLoop({
|
|
|
22920
23300
|
changeRequestId: opened.id,
|
|
22921
23301
|
...settledAs.notRun === undefined ? undefined : { notRun: settledAs.notRun },
|
|
22922
23302
|
...input.taskId === undefined ? undefined : { taskId: input.taskId },
|
|
22923
|
-
...input.branch === undefined ? undefined : { branch: input.branch }
|
|
23303
|
+
...input.branch === undefined ? undefined : { branch: input.branch },
|
|
23304
|
+
...ownDeliveryTarget(input)
|
|
22924
23305
|
}) : undefined;
|
|
22925
23306
|
return {
|
|
22926
23307
|
changeRequest: opened,
|
|
22927
23308
|
...settledAs,
|
|
22928
23309
|
...landed === undefined ? undefined : { landed },
|
|
22929
|
-
next: { changeRequestId: opened.id }
|
|
23310
|
+
next: { changeRequestId: opened.id },
|
|
23311
|
+
...input.deliversTo === undefined ? undefined : { deliversTo: input.deliversTo }
|
|
22930
23312
|
};
|
|
22931
23313
|
}).pipe(tapError2((error) => error instanceof BuildBlocked ? void_3 : ignore2(writeBack("write-back:failed", { milestone: "failed" }))))
|
|
22932
23314
|
});
|
|
@@ -24525,7 +24907,7 @@ var reportText = (landing, left, heading) => [
|
|
|
24525
24907
|
`);
|
|
24526
24908
|
var sweep_default = defineLoop({
|
|
24527
24909
|
id: "sweep",
|
|
24528
|
-
version: "1.
|
|
24910
|
+
version: "1.2.0",
|
|
24529
24911
|
title: "Sweep",
|
|
24530
24912
|
input: Input11,
|
|
24531
24913
|
output: Output12,
|
|
@@ -24545,7 +24927,15 @@ var sweep_default = defineLoop({
|
|
|
24545
24927
|
merge: notRun.length === 0,
|
|
24546
24928
|
...notRun.length === 0 ? undefined : { notRun },
|
|
24547
24929
|
...input.branch === undefined ? undefined : { branch: input.branch }
|
|
24548
|
-
});
|
|
24930
|
+
}).pipe(catchTag2("StepFailed", (refused) => refused.code === "task_branch_busy" ? succeed7({ held: refused.reason }) : fail7(refused)));
|
|
24931
|
+
if ("held" in landed)
|
|
24932
|
+
return {
|
|
24933
|
+
status: "opened",
|
|
24934
|
+
summary: `${earlier.url}, from an earlier Sweep, is still open, and another Run works its branch, so Sweep left it to that Run: ${landed.held}`,
|
|
24935
|
+
landed: [],
|
|
24936
|
+
left: [],
|
|
24937
|
+
changeRequest: { id: earlier.id, number: earlier.number, url: earlier.url }
|
|
24938
|
+
};
|
|
24549
24939
|
const summary = `${earlier.url}, from an earlier Sweep, is still open; Sweep took it on instead of batching again: ${landed.status}. ${landed.reason}`;
|
|
24550
24940
|
const landing = supersededIn(earlier.body);
|
|
24551
24941
|
const settled = afterClosing(landing, [], landed.status === "merged" ? yield* closeSuperseded(landing, earlier.url) : []);
|
|
@@ -24897,6 +25287,7 @@ var kitman_config_default = defineKit({
|
|
|
24897
25287
|
release_default,
|
|
24898
25288
|
research_default,
|
|
24899
25289
|
hindsight_default,
|
|
25290
|
+
land_epic_default,
|
|
24900
25291
|
review_default,
|
|
24901
25292
|
shepherd_default,
|
|
24902
25293
|
sweep_default,
|
|
@@ -24927,11 +25318,6 @@ var kitman_config_default = defineKit({
|
|
|
24927
25318
|
skills: ["git-workflow-and-versioning", "shipping-and-launch"],
|
|
24928
25319
|
instructions: { file: "agents/releaser.md" }
|
|
24929
25320
|
},
|
|
24930
|
-
deployer: {
|
|
24931
|
-
effort: "low",
|
|
24932
|
-
fallbacks,
|
|
24933
|
-
instructions: { file: "agents/deployer.md" }
|
|
24934
|
-
},
|
|
24935
25321
|
investigator: {
|
|
24936
25322
|
effort: "high",
|
|
24937
25323
|
fallbacks,
|
|
@@ -27560,6 +27946,7 @@ class RunnerCapabilityRpcs extends make30(make29("PutQuestion", {
|
|
|
27560
27946
|
default: optional2(String5),
|
|
27561
27947
|
auto: optional2(String5),
|
|
27562
27948
|
unattendedAuto: optional2(String5),
|
|
27949
|
+
evidence: optional2(QuestionEvidence),
|
|
27563
27950
|
timeoutMillis: optional2(Finite),
|
|
27564
27951
|
deferredName: String5
|
|
27565
27952
|
},
|
|
@@ -27596,7 +27983,8 @@ class RunnerCapabilityRpcs extends make30(make29("PutQuestion", {
|
|
|
27596
27983
|
samples: Int,
|
|
27597
27984
|
calibrate: Boolean3
|
|
27598
27985
|
})),
|
|
27599
|
-
resolve: optionalKey2(ResolveSpec)
|
|
27986
|
+
resolve: optionalKey2(ResolveSpec),
|
|
27987
|
+
deploy: optionalKey2(DeploySpec)
|
|
27600
27988
|
},
|
|
27601
27989
|
success: Struct({ verificationId: String5 }),
|
|
27602
27990
|
error: RunnerRpcError
|
|
@@ -27744,6 +28132,7 @@ class RunnerCapabilityRpcs extends make30(make29("PutQuestion", {
|
|
|
27744
28132
|
})),
|
|
27745
28133
|
readAt: optionalKey2(String5),
|
|
27746
28134
|
runnerChecks: optionalKey2(ArraySchema(String5)),
|
|
28135
|
+
targetChecks: optionalKey2(ArraySchema(String5)),
|
|
27747
28136
|
approved: optionalKey2(String5),
|
|
27748
28137
|
repository: optionalKey2(String5),
|
|
27749
28138
|
sourceBranch: optionalKey2(String5),
|
|
@@ -27890,6 +28279,10 @@ class RunnerCapabilityRpcs extends make30(make29("PutQuestion", {
|
|
|
27890
28279
|
payload: { lease: ProgramLease, repoBindingId: optionalKey2(String5) },
|
|
27891
28280
|
success: Struct({ repoBindingId: String5, branch: String5, revision: String5 }),
|
|
27892
28281
|
error: RunnerRpcError
|
|
28282
|
+
}), make29("DeliveryBase", {
|
|
28283
|
+
payload: { lease: ProgramLease },
|
|
28284
|
+
success: Struct({ repoBindingId: String5, branch: String5, revision: String5 }),
|
|
28285
|
+
error: RunnerRpcError
|
|
27893
28286
|
}), make29("MergeChangeRequest", {
|
|
27894
28287
|
payload: {
|
|
27895
28288
|
lease: ProgramLease,
|
|
@@ -28092,7 +28485,11 @@ var refusedStep = (cause) => {
|
|
|
28092
28485
|
return true;
|
|
28093
28486
|
return isRunnerRpcError(cause) && cause.status >= 400 && cause.status < 500 && !replayStatuses.has(cause.status);
|
|
28094
28487
|
};
|
|
28095
|
-
var requested = (step, request) => request.pipe(catch_2((cause) => refusedStep(cause) ? fail7(new StepFailed({
|
|
28488
|
+
var requested = (step, request) => request.pipe(catch_2((cause) => refusedStep(cause) ? fail7(new StepFailed({
|
|
28489
|
+
step,
|
|
28490
|
+
reason: cause.message,
|
|
28491
|
+
...isRunnerRpcError(cause) ? { code: cause.code } : undefined
|
|
28492
|
+
})) : die4(new JournalWriteFailed({ cause }))), catchDefect2((defect) => defect instanceof Error && isIssue(defect.cause) ? fail7(new StepFailed({
|
|
28096
28493
|
step,
|
|
28097
28494
|
reason: `Kitman cannot take this Step's request: invalid ${refusedFields(defect.cause)}`
|
|
28098
28495
|
})) : die4(defect)));
|
|
@@ -28107,17 +28504,19 @@ var runnerHost = (capabilities) => ({
|
|
|
28107
28504
|
...launch.default === undefined ? undefined : { default: launch.default },
|
|
28108
28505
|
...launch.auto === undefined ? undefined : { auto: launch.auto },
|
|
28109
28506
|
...launch.unattendedAuto === undefined ? undefined : { unattendedAuto: launch.unattendedAuto },
|
|
28507
|
+
...launch.evidence === undefined ? undefined : { evidence: launch.evidence },
|
|
28110
28508
|
...launch.timeoutMillis === undefined ? undefined : { timeoutMillis: launch.timeoutMillis }
|
|
28111
28509
|
})).pipe(asVoid2),
|
|
28112
28510
|
startVerification: (launch) => requested(launch.step, capabilities.startVerification({
|
|
28113
28511
|
step: launch.step,
|
|
28114
|
-
deferredName: (launch.resolve !== undefined ? resolveDeferred : launch.measure === undefined ? verifyDeferred : measureDeferred)(launch.step).name,
|
|
28512
|
+
deferredName: (launch.deploy !== undefined ? deployDeferred : launch.resolve !== undefined ? resolveDeferred : launch.measure === undefined ? verifyDeferred : measureDeferred)(launch.step).name,
|
|
28115
28513
|
...launch.revision === undefined ? undefined : { revision: launch.revision },
|
|
28116
28514
|
...launch.checks === undefined ? undefined : { checks: launch.checks },
|
|
28117
28515
|
...launch.suggested === undefined ? undefined : { suggested: launch.suggested },
|
|
28118
28516
|
...launch.rerunFailed === undefined ? undefined : { rerunFailed: launch.rerunFailed },
|
|
28119
28517
|
...launch.measure === undefined ? undefined : { measure: launch.measure },
|
|
28120
|
-
...launch.resolve === undefined ? undefined : { resolve: launch.resolve }
|
|
28518
|
+
...launch.resolve === undefined ? undefined : { resolve: launch.resolve },
|
|
28519
|
+
...launch.deploy === undefined ? undefined : { deploy: launch.deploy }
|
|
28121
28520
|
})).pipe(asVoid2),
|
|
28122
28521
|
startAgentWork: (launch) => requested(launch.step, capabilities.startAgentStep({
|
|
28123
28522
|
step: launch.step,
|
|
@@ -28232,7 +28631,7 @@ var runnerActivities = (capabilities, services) => ({
|
|
|
28232
28631
|
},
|
|
28233
28632
|
alertTask: { run: (request, step) => requested(step, capabilities.alertTask({ step, ...request })) },
|
|
28234
28633
|
integrationBranch: {
|
|
28235
|
-
run: (request, step) => requested(step, capabilities.integrationBranch(request.repoBindingId))
|
|
28634
|
+
run: (request, step) => requested(step, capabilities.integrationBranch(request.repoBindingId, request.base))
|
|
28236
28635
|
},
|
|
28237
28636
|
transcripts: { run: (request, step) => requested(step, capabilities.readTranscripts({ step, ...request })) },
|
|
28238
28637
|
changeRequestRead: {
|
|
@@ -28333,6 +28732,7 @@ var rpcProgramPorts = (rpc, work) => {
|
|
|
28333
28732
|
...question.default === undefined ? undefined : { default: question.default },
|
|
28334
28733
|
...question.auto === undefined ? undefined : { auto: question.auto },
|
|
28335
28734
|
...question.unattendedAuto === undefined ? undefined : { unattendedAuto: question.unattendedAuto },
|
|
28735
|
+
...question.evidence === undefined ? undefined : { evidence: question.evidence },
|
|
28336
28736
|
...question.timeoutMillis === undefined ? undefined : { timeoutMillis: question.timeoutMillis }
|
|
28337
28737
|
}),
|
|
28338
28738
|
startVerification: (verification) => rpc.startVerification({
|
|
@@ -28344,7 +28744,8 @@ var rpcProgramPorts = (rpc, work) => {
|
|
|
28344
28744
|
...verification.suggested === undefined ? undefined : { suggested: [...verification.suggested] },
|
|
28345
28745
|
...verification.rerunFailed === undefined ? undefined : { rerunFailed: verification.rerunFailed },
|
|
28346
28746
|
...verification.measure === undefined ? undefined : { measure: verification.measure },
|
|
28347
|
-
...verification.resolve === undefined ? undefined : { resolve: { revisions: [...verification.resolve.revisions] } }
|
|
28747
|
+
...verification.resolve === undefined ? undefined : { resolve: { revisions: [...verification.resolve.revisions] } },
|
|
28748
|
+
...verification.deploy === undefined ? undefined : { deploy: verification.deploy }
|
|
28348
28749
|
}),
|
|
28349
28750
|
startAgentStep: ({ secrets, ...step }) => rpc.startAgentStep({ lease, ...step, ...secrets === undefined ? undefined : { secrets: [...secrets] } }),
|
|
28350
28751
|
awaitEvent: (wait) => rpc.awaitEvent({ lease, ...wait }),
|
|
@@ -28370,7 +28771,7 @@ var rpcProgramPorts = (rpc, work) => {
|
|
|
28370
28771
|
...ticket.outcome === undefined ? undefined : { outcome: ticket.outcome }
|
|
28371
28772
|
}))
|
|
28372
28773
|
}),
|
|
28373
|
-
integrationBranch: (repoBindingId) => rpc.integrationBranch({ lease, ...repoBindingId === undefined ? undefined : { repoBindingId } }),
|
|
28774
|
+
integrationBranch: (repoBindingId, base) => base === true ? rpc.deliveryBase({ lease }) : rpc.integrationBranch({ lease, ...repoBindingId === undefined ? undefined : { repoBindingId } }),
|
|
28374
28775
|
alertTask: (request) => rpc.alertTask({ lease, ...request }),
|
|
28375
28776
|
readTranscripts: (request) => rpc.readTranscripts({ lease, ...request }),
|
|
28376
28777
|
pipelineStatus: (request) => rpc.pipelineStatus({ lease, ...request }),
|
|
@@ -28460,6 +28861,7 @@ var makeProgramRpcClient = (options) => gen2(function* () {
|
|
|
28460
28861
|
readProject: (input) => authorized(client.ReadProject(input)),
|
|
28461
28862
|
draftUpdate: (input) => authorized(client.DraftUpdate(input)),
|
|
28462
28863
|
integrationBranch: (input) => authorized(client.IntegrationBranch(input)),
|
|
28864
|
+
deliveryBase: (input) => authorized(client.DeliveryBase(input)),
|
|
28463
28865
|
mergeChangeRequest: (input) => authorized(client.MergeChangeRequest(input)),
|
|
28464
28866
|
closeChangeRequest: (input) => authorized(client.CloseChangeRequest(input)),
|
|
28465
28867
|
approveChangeRequest: (input) => authorized(client.ApproveChangeRequest(input)),
|
|
@@ -30640,4 +31042,4 @@ var runKit = (config, identity, packages) => {
|
|
|
30640
31042
|
runMain2(program.pipe(flatMap3((code) => sync2(() => process.exit(code)))));
|
|
30641
31043
|
};
|
|
30642
31044
|
// .kitman-build-entry.ts
|
|
30643
|
-
runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.11.
|
|
31045
|
+
runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.11.1" }, []);
|