@kitman-sh/software-engineering 0.10.105 → 0.11.0-rc.4
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 +58 -10
- package/dist/declarations.json +4 -3
- package/package.json +3 -3
- package/src/release.ts +69 -9
- package/src/shepherd.ts +3 -2
package/dist/bundle.js
CHANGED
|
@@ -13919,7 +13919,8 @@ var RunWaiting = Union2([
|
|
|
13919
13919
|
workUnitId: Id,
|
|
13920
13920
|
rank: Literals(ClaimRanks),
|
|
13921
13921
|
position: Int.check(isGreaterThanOrEqualTo2(1)),
|
|
13922
|
-
reason: String5
|
|
13922
|
+
reason: String5,
|
|
13923
|
+
movesUpAt: optionalKey2(String5)
|
|
13923
13924
|
})
|
|
13924
13925
|
]);
|
|
13925
13926
|
var RunEvidence = Struct({
|
|
@@ -14371,6 +14372,7 @@ var RunStartPreview = Struct({
|
|
|
14371
14372
|
missing: ArraySchema(String5),
|
|
14372
14373
|
message: optionalKey2(String5),
|
|
14373
14374
|
waitingOn: optionalKey2(WaitingOn),
|
|
14375
|
+
unreachable: optionalKey2(Struct({ repoBindingId: Id, message: String5 })),
|
|
14374
14376
|
teamId: optionalKey2(Id),
|
|
14375
14377
|
inferred: Struct({
|
|
14376
14378
|
repoBindingId: optionalKey2(Id),
|
|
@@ -19854,7 +19856,8 @@ var claim = (name, request) => gen2(function* () {
|
|
|
19854
19856
|
return first;
|
|
19855
19857
|
const { holder } = first;
|
|
19856
19858
|
const fallback = holder.sameLoop ? takeOver : "Leave it";
|
|
19857
|
-
const
|
|
19859
|
+
const askFirst = !(holder.sameLoop && request.takeOverOwnLoop === true);
|
|
19860
|
+
const answer = askFirst && (yield* LoopRun).granted.has("ask") ? yield* ask(`${name}-offer`, {
|
|
19858
19861
|
prompt: `${request.resource} is still held by ${holderName(holder)}${holder.status === undefined ? "" : `, which ${holder.status}`}${holder.reason === undefined ? "" : `: ${holder.reason}`}. Take it over?`,
|
|
19859
19862
|
options: [takeOver, "Leave it"],
|
|
19860
19863
|
recommended: fallback,
|
|
@@ -21228,6 +21231,10 @@ var Drafted = Struct({
|
|
|
21228
21231
|
notes: String5,
|
|
21229
21232
|
changeRequests: ArraySchema(String5)
|
|
21230
21233
|
});
|
|
21234
|
+
var Picked = Struct({
|
|
21235
|
+
...Drafted.fields,
|
|
21236
|
+
releasedIn: optional2(String5)
|
|
21237
|
+
});
|
|
21231
21238
|
var Deployed = Struct({
|
|
21232
21239
|
status: Literals(["deployed", "failed", "rolled_back", "rollback_failed", "none"]),
|
|
21233
21240
|
detail: FindingDetail
|
|
@@ -21252,7 +21259,8 @@ var Output2 = Struct({
|
|
|
21252
21259
|
"rollback_failed",
|
|
21253
21260
|
"timed_out",
|
|
21254
21261
|
"not_due",
|
|
21255
|
-
"no_version"
|
|
21262
|
+
"no_version",
|
|
21263
|
+
"nothing_to_release"
|
|
21256
21264
|
]),
|
|
21257
21265
|
reason: String5,
|
|
21258
21266
|
tag: optional2(String5),
|
|
@@ -21297,6 +21305,19 @@ var redraftPrompt = (drafted, edit) => [
|
|
|
21297
21305
|
].join(`
|
|
21298
21306
|
|
|
21299
21307
|
`);
|
|
21308
|
+
var pickPrompt = (drafted, revision, givenTag) => {
|
|
21309
|
+
const ownTag = givenTag ?? drafted.tag;
|
|
21310
|
+
return [
|
|
21311
|
+
"This Release now holds the deploy target, so no other Release tags until it settles. Another Release may have tagged since these notes were drafted: pick their version again.",
|
|
21312
|
+
`Fetch the tags (\`git fetch origin --tags\`) and list the release tags that contain ${revision} (\`git tag --contains ${revision}\`). ${ownTag} at ${revision} itself, as \`git rev-list -n 1 ${ownTag}\` tells, is this Release tagged on an earlier attempt: ignore it. Any other, ${ownTag} at another commit included, means ${revision} is released already: give that tag as releasedIn and the draft unchanged.`,
|
|
21313
|
+
givenTag === undefined ? `Otherwise, when ${drafted.tag} is still free and the latest release tag is still ${drafted.previousTag ?? "none"}, give the draft unchanged. When not, give the next version tag after the latest release tag, that latest tag as previousTag, and drop from the notes and changeRequests what it already released.` : `Otherwise give the draft unchanged. The release is tagged ${givenTag}.`,
|
|
21314
|
+
"```json",
|
|
21315
|
+
JSON.stringify(drafted, null, 2),
|
|
21316
|
+
"```"
|
|
21317
|
+
].join(`
|
|
21318
|
+
|
|
21319
|
+
`);
|
|
21320
|
+
};
|
|
21300
21321
|
var readyToMerge = (changeRequestId, round = 1) => gen2(function* () {
|
|
21301
21322
|
for (let pass = 1;; pass++) {
|
|
21302
21323
|
const at = (name) => {
|
|
@@ -21356,7 +21377,7 @@ var readyToMerge = (changeRequestId, round = 1) => gen2(function* () {
|
|
|
21356
21377
|
var recovery = (previous) => previous === undefined ? ["Retry the deploy", "Leave it"] : ["Retry the deploy", `Roll back to ${previous}`, "Leave it"];
|
|
21357
21378
|
var release_default = defineLoop({
|
|
21358
21379
|
id: "release",
|
|
21359
|
-
version: "2.
|
|
21380
|
+
version: "2.2.0",
|
|
21360
21381
|
title: "Release",
|
|
21361
21382
|
input: Input2,
|
|
21362
21383
|
output: Output2,
|
|
@@ -21446,7 +21467,7 @@ var release_default = defineLoop({
|
|
|
21446
21467
|
prompt: draftPrompt(input.tag, changeRequestId, input.releaseScope),
|
|
21447
21468
|
output: Drafted
|
|
21448
21469
|
});
|
|
21449
|
-
|
|
21470
|
+
let tag = input.tag ?? drafted.tag;
|
|
21450
21471
|
for (let round = 1;; round++) {
|
|
21451
21472
|
const answer = yield* ask(round === 1 ? "approve" : `approve:${round}`, {
|
|
21452
21473
|
prompt: `Release ${tag} with these notes?
|
|
@@ -21501,7 +21522,7 @@ ${drafted.notes}`,
|
|
|
21501
21522
|
output: Drafted
|
|
21502
21523
|
});
|
|
21503
21524
|
}
|
|
21504
|
-
|
|
21525
|
+
let notes = yield* artifact("notes", {
|
|
21505
21526
|
kind: "release_notes",
|
|
21506
21527
|
title: drafted.title,
|
|
21507
21528
|
text: drafted.notes,
|
|
@@ -21543,7 +21564,35 @@ ${drafted.notes}`,
|
|
|
21543
21564
|
}
|
|
21544
21565
|
}
|
|
21545
21566
|
const deployEvent = input.deployEvent ?? "deploy";
|
|
21546
|
-
yield* claim("deploy-target", { resource: `deploy:${input.deployTarget ?? deployEvent}
|
|
21567
|
+
yield* claim("deploy-target", { resource: `deploy:${input.deployTarget ?? deployEvent}`, takeOverOwnLoop: true });
|
|
21568
|
+
const { releasedIn, ...picked } = yield* agentWork("pick-version", {
|
|
21569
|
+
agent: "releaser",
|
|
21570
|
+
prompt: pickPrompt({ ...drafted, tag }, revision, input.tag),
|
|
21571
|
+
output: Picked
|
|
21572
|
+
});
|
|
21573
|
+
if (releasedIn !== undefined)
|
|
21574
|
+
return {
|
|
21575
|
+
status: "nothing_to_release",
|
|
21576
|
+
reason: `${revision} is already released in ${releasedIn}`,
|
|
21577
|
+
tag: releasedIn,
|
|
21578
|
+
notesArtifactId: notes.artifactId,
|
|
21579
|
+
revision
|
|
21580
|
+
};
|
|
21581
|
+
const pickedTag = input.tag ?? picked.tag;
|
|
21582
|
+
if (pickedTag !== tag || picked.notes !== drafted.notes || picked.title !== drafted.title) {
|
|
21583
|
+
notes = yield* artifact("notes:picked", {
|
|
21584
|
+
kind: "release_notes",
|
|
21585
|
+
title: picked.title,
|
|
21586
|
+
text: picked.notes,
|
|
21587
|
+
data: {
|
|
21588
|
+
tag: pickedTag,
|
|
21589
|
+
changeRequests: picked.changeRequests,
|
|
21590
|
+
...input.releaseScope === undefined ? undefined : { shipped: shippedScope(input.releaseScope) }
|
|
21591
|
+
}
|
|
21592
|
+
});
|
|
21593
|
+
}
|
|
21594
|
+
drafted = picked;
|
|
21595
|
+
tag = pickedTag;
|
|
21547
21596
|
const released = yield* release2("tag", {
|
|
21548
21597
|
tag,
|
|
21549
21598
|
revision,
|
|
@@ -22414,7 +22463,7 @@ Merge now?`,
|
|
|
22414
22463
|
...done("merged", `Merged at ${merged.revision}; its Release gate failed, so the next Release ships it`),
|
|
22415
22464
|
release: { runStatus: released.status, reason: released.reason }
|
|
22416
22465
|
};
|
|
22417
|
-
if (released.status !== "deployed" && released.status !== "rejected" && released.status !== "gate_failed" && released.status !== "not_due")
|
|
22466
|
+
if (released.status !== "deployed" && released.status !== "rejected" && released.status !== "gate_failed" && released.status !== "not_due" && released.status !== "nothing_to_release")
|
|
22418
22467
|
yield* ask("release-failed", {
|
|
22419
22468
|
prompt: `Merged at ${merged.revision}, but its Release ended ${released.status}: ${released.reason}`,
|
|
22420
22469
|
options: [{ value: "Taken over", description: "A person looks at the release and production from here." }],
|
|
@@ -27298,7 +27347,6 @@ var make34 = (options) => ({
|
|
|
27298
27347
|
// ../../packages/live/src/rpc/runner-group.ts
|
|
27299
27348
|
var RunnerHeaders = { runnerId: "x-kitman-runner-id", protocolVersion: "x-kitman-rpc-protocol" };
|
|
27300
27349
|
var RunnerRpcProtocolVersion = 5;
|
|
27301
|
-
|
|
27302
27350
|
class RunnerRpcError extends TaggedError3()("RunnerRpcError", {
|
|
27303
27351
|
code: String5,
|
|
27304
27352
|
message: String5,
|
|
@@ -30557,4 +30605,4 @@ var runKit = (config, identity, packages) => {
|
|
|
30557
30605
|
runMain2(program.pipe(flatMap3((code) => sync2(() => process.exit(code)))));
|
|
30558
30606
|
};
|
|
30559
30607
|
// .kitman-build-entry.ts
|
|
30560
|
-
runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.
|
|
30608
|
+
runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.11.0-rc.4" }, []);
|
package/dist/declarations.json
CHANGED
|
@@ -1629,7 +1629,7 @@
|
|
|
1629
1629
|
{
|
|
1630
1630
|
"id": "release",
|
|
1631
1631
|
"title": "Release",
|
|
1632
|
-
"version": "2.
|
|
1632
|
+
"version": "2.2.0",
|
|
1633
1633
|
"input": {
|
|
1634
1634
|
"type": "object",
|
|
1635
1635
|
"properties": {
|
|
@@ -1833,7 +1833,8 @@
|
|
|
1833
1833
|
"rollback_failed",
|
|
1834
1834
|
"timed_out",
|
|
1835
1835
|
"not_due",
|
|
1836
|
-
"no_version"
|
|
1836
|
+
"no_version",
|
|
1837
|
+
"nothing_to_release"
|
|
1837
1838
|
]
|
|
1838
1839
|
},
|
|
1839
1840
|
"reason": {
|
|
@@ -3847,7 +3848,7 @@
|
|
|
3847
3848
|
"carried": [
|
|
3848
3849
|
{
|
|
3849
3850
|
"name": "@kitman-sh/software-engineering",
|
|
3850
|
-
"version": "0.
|
|
3851
|
+
"version": "0.11.0-rc.4",
|
|
3851
3852
|
"setup": "2a237548a69b0cd53ec3be7f687cfa8c2128335b3a655d34e185f2abce6a3c37",
|
|
3852
3853
|
"loops": [
|
|
3853
3854
|
"build",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitman-sh/software-engineering",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0-rc.4",
|
|
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.
|
|
20
|
+
"@kitman-sh/sdk": "0.11.0-rc.4",
|
|
21
21
|
"effect": "^4.1.2"
|
|
22
22
|
},
|
|
23
23
|
"kitman": {
|
|
24
24
|
"bundle": "dist/bundle.js",
|
|
25
|
-
"digest": "
|
|
25
|
+
"digest": "d713cfbe9591fc3dd1f1d37c34d2b856d528c800271787c73b0204e9efb40489",
|
|
26
26
|
"protocolVersion": 5,
|
|
27
27
|
"declarations": "dist/declarations.json",
|
|
28
28
|
"setup": {
|
package/src/release.ts
CHANGED
|
@@ -57,6 +57,13 @@ const Drafted = Schema.Struct({
|
|
|
57
57
|
|
|
58
58
|
type Drafted = typeof Drafted.Type
|
|
59
59
|
|
|
60
|
+
/** The draft, its version picked again once the Release holds the deploy target. */
|
|
61
|
+
const Picked = Schema.Struct({
|
|
62
|
+
...Drafted.fields,
|
|
63
|
+
/** A release tag that already contains the revision and is not this Release's own tag at it, which leaves nothing to release. */
|
|
64
|
+
releasedIn: Schema.optional(Schema.String)
|
|
65
|
+
})
|
|
66
|
+
|
|
60
67
|
/** What the repository's own deploy script did, as the releaser read it from its last line and exit code. */
|
|
61
68
|
const Deployed = Schema.Struct({
|
|
62
69
|
/** none: the repository has no `.kitman/deploy`, so the deploy is left to whatever sends the deploy Event. */
|
|
@@ -87,7 +94,9 @@ const Output = Schema.Struct({
|
|
|
87
94
|
/** Its trigger is a Milestone or Project being done, and this Run was not started by one nor told to release now. */
|
|
88
95
|
'not_due',
|
|
89
96
|
/** A Milestone or Project started it without the version to cut, which a Release never picks for itself. */
|
|
90
|
-
'no_version'
|
|
97
|
+
'no_version',
|
|
98
|
+
/** An existing tag already contains the revision, as when another Release tagged it first. */
|
|
99
|
+
'nothing_to_release'
|
|
91
100
|
]),
|
|
92
101
|
/** Why it stopped, or what happened, in a line. */
|
|
93
102
|
reason: Schema.String,
|
|
@@ -151,6 +160,21 @@ const redraftPrompt = (drafted: Drafted, edit: string) =>
|
|
|
151
160
|
'```'
|
|
152
161
|
].join('\n\n')
|
|
153
162
|
|
|
163
|
+
const pickPrompt = (drafted: Drafted, revision: string, givenTag: string | undefined) => {
|
|
164
|
+
const ownTag = givenTag ?? drafted.tag
|
|
165
|
+
|
|
166
|
+
return [
|
|
167
|
+
'This Release now holds the deploy target, so no other Release tags until it settles. Another Release may have tagged since these notes were drafted: pick their version again.',
|
|
168
|
+
`Fetch the tags (\`git fetch origin --tags\`) and list the release tags that contain ${revision} (\`git tag --contains ${revision}\`). ${ownTag} at ${revision} itself, as \`git rev-list -n 1 ${ownTag}\` tells, is this Release tagged on an earlier attempt: ignore it. Any other, ${ownTag} at another commit included, means ${revision} is released already: give that tag as releasedIn and the draft unchanged.`,
|
|
169
|
+
givenTag === undefined
|
|
170
|
+
? `Otherwise, when ${drafted.tag} is still free and the latest release tag is still ${drafted.previousTag ?? 'none'}, give the draft unchanged. When not, give the next version tag after the latest release tag, that latest tag as previousTag, and drop from the notes and changeRequests what it already released.`
|
|
171
|
+
: `Otherwise give the draft unchanged. The release is tagged ${givenTag}.`,
|
|
172
|
+
'```json',
|
|
173
|
+
JSON.stringify(drafted, null, 2),
|
|
174
|
+
'```'
|
|
175
|
+
].join('\n\n')
|
|
176
|
+
}
|
|
177
|
+
|
|
154
178
|
const approval = ['Approve', 'Edit notes', 'Reject'] as const
|
|
155
179
|
|
|
156
180
|
/**
|
|
@@ -246,9 +270,11 @@ const recovery = (previous: string | undefined) =>
|
|
|
246
270
|
* Proves the release before anyone is asked: the approved checks pass on the revision to tag, or a release
|
|
247
271
|
* ChangeRequest is green, approved and mergeable. A failed check runs once more in a fresh checkout; one that passes
|
|
248
272
|
* there is recorded as an environment failure. It then asks once, with no default, whether to release the drafted
|
|
249
|
-
* notes, which can be edited in place. On approval it merges the ChangeRequest when there is one,
|
|
250
|
-
*
|
|
251
|
-
*
|
|
273
|
+
* notes, which can be edited in place. On approval it merges the ChangeRequest when there is one, holds the deploy
|
|
274
|
+
* target so two Releases never tag or deploy over each other, taking it over from a Release that failed holding it,
|
|
275
|
+
* and picks the version again under it: a revision an existing tag already contains ends as nothing to release. It
|
|
276
|
+
* then tags and publishes once (a tag already released at the same revision counts as done; one at another is never
|
|
277
|
+
* moved) and waits for the deploy. A failed or late deploy asks whether
|
|
252
278
|
* to retry (it runs the tag's failed pipeline again and waits), roll back to the previous tag (it runs that
|
|
253
279
|
* tag's pipeline again in full and waits for its deploy), or leave it, which it does by default.
|
|
254
280
|
*
|
|
@@ -258,7 +284,7 @@ const recovery = (previous: string | undefined) =>
|
|
|
258
284
|
*/
|
|
259
285
|
export default defineLoop({
|
|
260
286
|
id: 'release',
|
|
261
|
-
version: '2.
|
|
287
|
+
version: '2.2.0',
|
|
262
288
|
title: 'Release',
|
|
263
289
|
input: Input,
|
|
264
290
|
output: Output,
|
|
@@ -372,7 +398,7 @@ export default defineLoop({
|
|
|
372
398
|
output: Drafted
|
|
373
399
|
})
|
|
374
400
|
|
|
375
|
-
|
|
401
|
+
let tag = input.tag ?? drafted.tag
|
|
376
402
|
|
|
377
403
|
// The question has no default: a release goes out only when someone says so.
|
|
378
404
|
for (let round = 1; ; round++) {
|
|
@@ -435,7 +461,7 @@ export default defineLoop({
|
|
|
435
461
|
})
|
|
436
462
|
}
|
|
437
463
|
|
|
438
|
-
|
|
464
|
+
let notes = yield* artifact('notes', {
|
|
439
465
|
kind: 'release_notes',
|
|
440
466
|
title: drafted.title,
|
|
441
467
|
text: drafted.notes,
|
|
@@ -486,8 +512,42 @@ export default defineLoop({
|
|
|
486
512
|
|
|
487
513
|
const deployEvent = input.deployEvent ?? 'deploy'
|
|
488
514
|
|
|
489
|
-
// Held until the Run completes, so the next Release deploys after this one is settled.
|
|
490
|
-
|
|
515
|
+
// Held until the Run completes, so the next Release deploys after this one is settled. One a failed Release kept
|
|
516
|
+
// is taken over, since a Release always deploys what is newest.
|
|
517
|
+
yield* claim('deploy-target', { resource: `deploy:${input.deployTarget ?? deployEvent}`, takeOverOwnLoop: true })
|
|
518
|
+
|
|
519
|
+
const { releasedIn, ...picked } = yield* agentWork('pick-version', {
|
|
520
|
+
agent: 'releaser',
|
|
521
|
+
prompt: pickPrompt({ ...drafted, tag }, revision, input.tag),
|
|
522
|
+
output: Picked
|
|
523
|
+
})
|
|
524
|
+
|
|
525
|
+
if (releasedIn !== undefined)
|
|
526
|
+
return {
|
|
527
|
+
status: 'nothing_to_release',
|
|
528
|
+
reason: `${revision} is already released in ${releasedIn}`,
|
|
529
|
+
tag: releasedIn,
|
|
530
|
+
notesArtifactId: notes.artifactId,
|
|
531
|
+
revision
|
|
532
|
+
} satisfies Output
|
|
533
|
+
|
|
534
|
+
const pickedTag = input.tag ?? picked.tag
|
|
535
|
+
|
|
536
|
+
if (pickedTag !== tag || picked.notes !== drafted.notes || picked.title !== drafted.title) {
|
|
537
|
+
notes = yield* artifact('notes:picked', {
|
|
538
|
+
kind: 'release_notes',
|
|
539
|
+
title: picked.title,
|
|
540
|
+
text: picked.notes,
|
|
541
|
+
data: {
|
|
542
|
+
tag: pickedTag,
|
|
543
|
+
changeRequests: picked.changeRequests,
|
|
544
|
+
...(input.releaseScope === undefined ? undefined : { shipped: shippedScope(input.releaseScope) })
|
|
545
|
+
}
|
|
546
|
+
})
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
drafted = picked
|
|
550
|
+
tag = pickedTag
|
|
491
551
|
|
|
492
552
|
const released = yield* release('tag', {
|
|
493
553
|
tag,
|
package/src/shepherd.ts
CHANGED
|
@@ -1316,12 +1316,13 @@ export default defineLoop({
|
|
|
1316
1316
|
release: { runStatus: released.status, reason: released.reason }
|
|
1317
1317
|
}
|
|
1318
1318
|
|
|
1319
|
-
// It merged either way; a Release that did not deploy, other than one a person rejected, needs a person.
|
|
1319
|
+
// It merged either way; a Release that did not deploy, other than one a person rejected or one that found it released, needs a person.
|
|
1320
1320
|
if (
|
|
1321
1321
|
released.status !== 'deployed' &&
|
|
1322
1322
|
released.status !== 'rejected' &&
|
|
1323
1323
|
released.status !== 'gate_failed' &&
|
|
1324
|
-
released.status !== 'not_due'
|
|
1324
|
+
released.status !== 'not_due' &&
|
|
1325
|
+
released.status !== 'nothing_to_release'
|
|
1325
1326
|
)
|
|
1326
1327
|
yield* ask('release-failed', {
|
|
1327
1328
|
prompt: `Merged at ${merged.revision}, but its Release ended ${released.status}: ${released.reason}`,
|