@kitman-sh/software-engineering 0.11.0-rc.5 → 0.11.0
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 +595 -158
- package/dist/declarations.json +1294 -84
- 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 +239 -95
- 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/kitman.config.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
release,
|
|
11
11
|
research,
|
|
12
12
|
hindsight,
|
|
13
|
+
landEpic,
|
|
13
14
|
review,
|
|
14
15
|
shepherd,
|
|
15
16
|
sweep,
|
|
@@ -46,6 +47,7 @@ export default defineKit({
|
|
|
46
47
|
release,
|
|
47
48
|
research,
|
|
48
49
|
hindsight,
|
|
50
|
+
landEpic,
|
|
49
51
|
review,
|
|
50
52
|
shepherd,
|
|
51
53
|
sweep,
|
|
@@ -78,11 +80,6 @@ export default defineKit({
|
|
|
78
80
|
skills: ['git-workflow-and-versioning', 'shipping-and-launch'],
|
|
79
81
|
instructions: { file: 'agents/releaser.md' }
|
|
80
82
|
},
|
|
81
|
-
deployer: {
|
|
82
|
-
effort: 'low',
|
|
83
|
-
fallbacks,
|
|
84
|
-
instructions: { file: 'agents/deployer.md' }
|
|
85
|
-
},
|
|
86
83
|
investigator: {
|
|
87
84
|
effort: 'high',
|
|
88
85
|
fallbacks,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitman-sh/software-engineering",
|
|
3
|
-
"version": "0.11.0
|
|
3
|
+
"version": "0.11.0",
|
|
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.11.0
|
|
20
|
+
"@kitman-sh/sdk": "0.11.0",
|
|
21
21
|
"effect": "^4.1.2"
|
|
22
22
|
},
|
|
23
23
|
"kitman": {
|
|
24
24
|
"bundle": "dist/bundle.js",
|
|
25
|
-
"digest": "
|
|
25
|
+
"digest": "edfa485ed3955a1883d1d79d79610ed02ffb4c608ff5d3347aa2a9ea17646230",
|
|
26
26
|
"protocolVersion": 5,
|
|
27
27
|
"declarations": "dist/declarations.json",
|
|
28
28
|
"setup": {
|
package/src/build.ts
CHANGED
|
@@ -8,6 +8,8 @@ import {
|
|
|
8
8
|
CheckName,
|
|
9
9
|
Continuing,
|
|
10
10
|
continuingBrief,
|
|
11
|
+
deliveryBase,
|
|
12
|
+
ResolvedDeliveryTarget,
|
|
11
13
|
syncBase,
|
|
12
14
|
changeRequest,
|
|
13
15
|
ChangeRequestResult,
|
|
@@ -45,6 +47,7 @@ import {
|
|
|
45
47
|
import review from './review'
|
|
46
48
|
import shepherd from './shepherd'
|
|
47
49
|
import { ShepherdOutput } from './shepherd-output'
|
|
50
|
+
import { DeliveryFields, epicOf, ownDeliveryTarget } from './delivery'
|
|
48
51
|
import { ChangeRequestSummary, Reason, ShortStatement } from './text-limits'
|
|
49
52
|
|
|
50
53
|
export const BuildInput = Schema.Struct({
|
|
@@ -72,7 +75,8 @@ export const BuildInput = Schema.Struct({
|
|
|
72
75
|
* How many more Builds an unattended full-auto Run starts on its ChangeRequest while review findings still stand,
|
|
73
76
|
* before it fails with them; 1 when left out.
|
|
74
77
|
*/
|
|
75
|
-
maxRebuilds: Schema.optional(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)))
|
|
78
|
+
maxRebuilds: Schema.optional(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))),
|
|
79
|
+
...DeliveryFields
|
|
76
80
|
})
|
|
77
81
|
|
|
78
82
|
/** The implementer's answer to one acceptance criterion of the Task. */
|
|
@@ -145,7 +149,9 @@ export const BuildOutput = Schema.Struct({
|
|
|
145
149
|
/** What Shepherd did with the ChangeRequest, when the Build was told to land it. */
|
|
146
150
|
landed: Schema.optional(ShepherdOutput),
|
|
147
151
|
/** The input its Shepherd and Review offers start from. */
|
|
148
|
-
next: Schema.Struct({ changeRequestId: Schema.String })
|
|
152
|
+
next: Schema.Struct({ changeRequestId: Schema.String }),
|
|
153
|
+
/** Where the Run's delivery landed and the layer it came from. */
|
|
154
|
+
deliversTo: Schema.optional(ResolvedDeliveryTarget)
|
|
149
155
|
})
|
|
150
156
|
|
|
151
157
|
/** Build was marked blocked on findings that still stand, so the Task waits on its owner. */
|
|
@@ -410,7 +416,7 @@ const rally = (input: {
|
|
|
410
416
|
*/
|
|
411
417
|
const build = defineLoop({
|
|
412
418
|
id: 'build',
|
|
413
|
-
version: '2.
|
|
419
|
+
version: '2.7.0',
|
|
414
420
|
title: 'Build',
|
|
415
421
|
input: BuildInput,
|
|
416
422
|
output: BuildOutput,
|
|
@@ -441,7 +447,12 @@ const build = defineLoop({
|
|
|
441
447
|
const outcome = input.outcome
|
|
442
448
|
// A retry carries the earlier Run's branch as `branch`, or the branch that Run started from when it never pushed;
|
|
443
449
|
// the ChangeRequest it continues says what it merges into.
|
|
444
|
-
const
|
|
450
|
+
const epic = epicOf(input)
|
|
451
|
+
const target = input.continuing?.targetBranch ?? input.branch ?? epic?.branch
|
|
452
|
+
|
|
453
|
+
// Under epic delivery a sub-task branches from its epic's branch, which the first sub-task's Build makes.
|
|
454
|
+
if (epic !== undefined && input.continuing === undefined && input.branch === undefined)
|
|
455
|
+
yield* deliveryBase('epic-branch')
|
|
445
456
|
|
|
446
457
|
if (input.changeRequestId !== undefined && input.continuing?.changeRequestId !== input.changeRequestId)
|
|
447
458
|
return yield* new BuildTargetMissing({
|
|
@@ -639,7 +650,8 @@ const build = defineLoop({
|
|
|
639
650
|
...(input.outcome === undefined ? undefined : { outcome: input.outcome }),
|
|
640
651
|
...(input.maxRounds === undefined ? undefined : { maxRounds: input.maxRounds }),
|
|
641
652
|
changeRequestId: opened.id,
|
|
642
|
-
land: false
|
|
653
|
+
land: false,
|
|
654
|
+
...ownDeliveryTarget(input)
|
|
643
655
|
},
|
|
644
656
|
{ constraints: standing.map(standingConstraint) }
|
|
645
657
|
)
|
|
@@ -653,7 +665,8 @@ const build = defineLoop({
|
|
|
653
665
|
changeRequestId: opened.id,
|
|
654
666
|
...(settledAs.notRun === undefined ? undefined : { notRun: settledAs.notRun }),
|
|
655
667
|
...(input.taskId === undefined ? undefined : { taskId: input.taskId }),
|
|
656
|
-
...(input.branch === undefined ? undefined : { branch: input.branch })
|
|
668
|
+
...(input.branch === undefined ? undefined : { branch: input.branch }),
|
|
669
|
+
...ownDeliveryTarget(input)
|
|
657
670
|
})
|
|
658
671
|
: undefined
|
|
659
672
|
|
|
@@ -661,7 +674,8 @@ const build = defineLoop({
|
|
|
661
674
|
changeRequest: opened,
|
|
662
675
|
...settledAs,
|
|
663
676
|
...(landed === undefined ? undefined : { landed }),
|
|
664
|
-
next: { changeRequestId: opened.id }
|
|
677
|
+
next: { changeRequestId: opened.id },
|
|
678
|
+
...(input.deliversTo === undefined ? undefined : { deliversTo: input.deliversTo })
|
|
665
679
|
}
|
|
666
680
|
}).pipe(
|
|
667
681
|
Effect.tapError(error =>
|
package/src/delivery.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { DeliveryTarget, EpicDelivery, ResolvedDeliveryTarget } from '@kitman-sh/sdk/loop'
|
|
2
|
+
import * as Schema from 'effect/Schema'
|
|
3
|
+
|
|
4
|
+
/** The Input fields of a Loop that delivers by the Workspace's, Team's and Project's delivery target. */
|
|
5
|
+
export const DeliveryFields = {
|
|
6
|
+
/** This Run's own delivery target, over its Project's, Team's and Workspace's; `default_branch` ships a hotfix. */
|
|
7
|
+
deliveryTarget: Schema.optional(DeliveryTarget),
|
|
8
|
+
/** Where the Run's delivery lands and the layer it came from; Kitman sets it when the Run starts. */
|
|
9
|
+
deliversTo: Schema.optional(ResolvedDeliveryTarget),
|
|
10
|
+
/** The epic the Run's Task delivers through under epic delivery; Kitman sets it when the Run starts. */
|
|
11
|
+
epic: Schema.optional(EpicDelivery)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type Delivering = { readonly deliversTo?: ResolvedDeliveryTarget | undefined }
|
|
15
|
+
|
|
16
|
+
/** Passes a Run's own delivery target on to the Runs it calls; they resolve the same layers for the same Task. */
|
|
17
|
+
export const ownDeliveryTarget = (input: Delivering) =>
|
|
18
|
+
input.deliversTo?.layer === 'run' ? { deliveryTarget: input.deliversTo.target } : undefined
|
|
19
|
+
|
|
20
|
+
/** The epic a Run delivers through, when its delivery lands on the epic branch. */
|
|
21
|
+
export const epicOf = (input: Delivering & { readonly epic?: EpicDelivery | undefined }) =>
|
|
22
|
+
input.deliversTo?.target === 'epic_branch' ? input.epic : undefined
|
|
23
|
+
|
|
24
|
+
export const deliveryLayerWords = {
|
|
25
|
+
run: 'this Run',
|
|
26
|
+
project: 'its Project',
|
|
27
|
+
team: 'its Team',
|
|
28
|
+
workspace: 'the Workspace'
|
|
29
|
+
} as const
|
package/src/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ import projectUpdate from './project-update'
|
|
|
8
8
|
import release from './release'
|
|
9
9
|
import research from './research'
|
|
10
10
|
import hindsight from './hindsight'
|
|
11
|
+
import landEpic from './land-epic'
|
|
11
12
|
import review from './review'
|
|
12
13
|
import shepherd from './shepherd'
|
|
13
14
|
import sweep from './sweep'
|
|
@@ -25,6 +26,7 @@ export const loops = {
|
|
|
25
26
|
release,
|
|
26
27
|
research,
|
|
27
28
|
hindsight,
|
|
29
|
+
'land-epic': landEpic,
|
|
28
30
|
review,
|
|
29
31
|
shepherd,
|
|
30
32
|
sweep,
|
|
@@ -42,6 +44,7 @@ export {
|
|
|
42
44
|
release,
|
|
43
45
|
research,
|
|
44
46
|
hindsight,
|
|
47
|
+
landEpic,
|
|
45
48
|
review,
|
|
46
49
|
shepherd,
|
|
47
50
|
sweep,
|
package/src/land-epic.ts
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import {
|
|
2
|
+
call,
|
|
3
|
+
type CalledLoop,
|
|
4
|
+
changeRequest,
|
|
5
|
+
ChangeRequestResult,
|
|
6
|
+
Continuing,
|
|
7
|
+
defineLoop,
|
|
8
|
+
ResolvedDeliveryTarget,
|
|
9
|
+
syncBase,
|
|
10
|
+
writeBack
|
|
11
|
+
} from '@kitman-sh/sdk/loop'
|
|
12
|
+
import * as Effect from 'effect/Effect'
|
|
13
|
+
import * as Schema from 'effect/Schema'
|
|
14
|
+
import { DeliveryFields, deliveryLayerWords, epicOf, ownDeliveryTarget } from './delivery'
|
|
15
|
+
import shepherd from './shepherd'
|
|
16
|
+
import { ShepherdOutput } from './shepherd-output'
|
|
17
|
+
|
|
18
|
+
export const LandEpicInput = Schema.Struct({
|
|
19
|
+
/** The epic: a Task with sub-tasks. */
|
|
20
|
+
taskId: Schema.String,
|
|
21
|
+
/** Marks the Loop that works on the epic's own branch: Kitman puts the Run there, never force-pushing it. */
|
|
22
|
+
landsEpic: Schema.optional(Schema.Boolean),
|
|
23
|
+
/** Merges the epic's ChangeRequest once it is approved, green and mergeable, without asking. */
|
|
24
|
+
merge: Schema.optional(Schema.Boolean),
|
|
25
|
+
/** The epic's open ChangeRequest an earlier Run opened, as Kitman puts the Run on it. */
|
|
26
|
+
continuing: Schema.optional(Continuing),
|
|
27
|
+
...DeliveryFields
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
export const LandEpicOutput = Schema.Struct({
|
|
31
|
+
status: Schema.Literals([
|
|
32
|
+
/** The Task delivers to the default branch, or has no epic: there is no epic branch to land. */
|
|
33
|
+
'not_epic',
|
|
34
|
+
/** The epic branch took in the default branch; its sub-tasks are not all done, so it waits. */
|
|
35
|
+
'synced',
|
|
36
|
+
/** The epic is done already: its ChangeRequest to the default branch merged. */
|
|
37
|
+
'landed',
|
|
38
|
+
/** The default branch conflicts with the epic branch in files the agent could not settle. */
|
|
39
|
+
'conflict',
|
|
40
|
+
/** Every sub-task is done: the epic's ChangeRequest is open, and Shepherd saw it as far as `landed` says. */
|
|
41
|
+
'opened'
|
|
42
|
+
]),
|
|
43
|
+
reason: Schema.String,
|
|
44
|
+
changeRequest: Schema.optional(ChangeRequestResult),
|
|
45
|
+
landed: Schema.optional(ShepherdOutput),
|
|
46
|
+
deliversTo: Schema.optional(ResolvedDeliveryTarget)
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
type Output = typeof LandEpicOutput.Type
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Lands an epic under epic delivery, on the epic's own branch: it merges the default branch in, so the epic branch keeps
|
|
53
|
+
* up with it, and once every sub-task is done opens the epic's ChangeRequest to the default branch and calls Shepherd,
|
|
54
|
+
* which merges it and starts Release. Shepherd calls it after each sub-task's ChangeRequest merges into the epic branch,
|
|
55
|
+
* and epic.ready starts it once the last sub-task closes, however it closed.
|
|
56
|
+
*/
|
|
57
|
+
const landEpic = defineLoop({
|
|
58
|
+
id: 'land-epic',
|
|
59
|
+
version: '1.0.0',
|
|
60
|
+
title: 'Land epic',
|
|
61
|
+
input: LandEpicInput,
|
|
62
|
+
output: LandEpicOutput,
|
|
63
|
+
agents: { implementer: 'implementer' },
|
|
64
|
+
checkout: 'write',
|
|
65
|
+
capabilities: ['agent_work', 'change_request', 'write_back', 'call'],
|
|
66
|
+
calls: (): readonly CalledLoop[] => [shepherd],
|
|
67
|
+
when: [{ event: 'epic.ready', input: { taskId: 'taskId' } }],
|
|
68
|
+
run: input =>
|
|
69
|
+
Effect.gen(function* () {
|
|
70
|
+
const epic = epicOf(input)
|
|
71
|
+
const recorded = input.deliversTo === undefined ? undefined : { deliversTo: input.deliversTo }
|
|
72
|
+
|
|
73
|
+
if (epic === undefined)
|
|
74
|
+
return {
|
|
75
|
+
status: 'not_epic',
|
|
76
|
+
reason:
|
|
77
|
+
input.deliversTo === undefined
|
|
78
|
+
? 'The Task delivers to no epic branch'
|
|
79
|
+
: `The Task lands ${input.deliversTo.target === 'epic_branch' ? 'on no epic' : 'on the default branch'}, as ${deliveryLayerWords[input.deliversTo.layer]} says`,
|
|
80
|
+
...recorded
|
|
81
|
+
} satisfies Output
|
|
82
|
+
|
|
83
|
+
if (epic.done)
|
|
84
|
+
return {
|
|
85
|
+
status: 'landed',
|
|
86
|
+
reason: `Epic ${epic.key} is done: its ChangeRequest merged into ${epic.defaultBranch}`,
|
|
87
|
+
...recorded
|
|
88
|
+
} satisfies Output
|
|
89
|
+
|
|
90
|
+
const synced = yield* syncBase('sync-default', { agent: 'implementer', target: epic.defaultBranch })
|
|
91
|
+
|
|
92
|
+
if (synced.status === 'conflict')
|
|
93
|
+
return {
|
|
94
|
+
status: 'conflict',
|
|
95
|
+
reason: `${epic.defaultBranch} conflicts with ${epic.branch} in ${synced.files.join(', ')}: ${synced.reason}`,
|
|
96
|
+
...recorded
|
|
97
|
+
} satisfies Output
|
|
98
|
+
|
|
99
|
+
if (!epic.subTasksDone && input.continuing === undefined)
|
|
100
|
+
return {
|
|
101
|
+
status: 'synced',
|
|
102
|
+
reason: `${epic.branch} is up to date with ${epic.defaultBranch}; ${epic.key} lands once every sub-task is done`,
|
|
103
|
+
...recorded
|
|
104
|
+
} satisfies Output
|
|
105
|
+
|
|
106
|
+
const opened =
|
|
107
|
+
input.continuing === undefined
|
|
108
|
+
? yield* changeRequest('epic-change-request', {
|
|
109
|
+
title: `${epic.key} Land the epic`,
|
|
110
|
+
body: [
|
|
111
|
+
`Lands epic ${epic.key} on ${epic.defaultBranch}: every sub-task is done, and each merged into ${epic.branch} through its own ChangeRequest.`,
|
|
112
|
+
`${epic.branch} took in ${epic.defaultBranch} before this opened.`
|
|
113
|
+
].join('\n\n')
|
|
114
|
+
})
|
|
115
|
+
: { id: input.continuing.changeRequestId, number: input.continuing.number, url: input.continuing.url }
|
|
116
|
+
|
|
117
|
+
if (input.continuing === undefined)
|
|
118
|
+
yield* writeBack('write-back', { milestone: 'change_request_opened', changeRequestUrl: opened.url })
|
|
119
|
+
|
|
120
|
+
const landed = yield* call('shepherd', shepherd, {
|
|
121
|
+
changeRequestId: opened.id,
|
|
122
|
+
taskId: epic.taskId,
|
|
123
|
+
...(input.merge === undefined ? undefined : { merge: input.merge }),
|
|
124
|
+
...ownDeliveryTarget(input)
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
status: 'opened',
|
|
129
|
+
reason: `${opened.url} lands ${epic.key}; Shepherd ended ${landed.status}: ${landed.reason}`,
|
|
130
|
+
changeRequest: opened,
|
|
131
|
+
landed,
|
|
132
|
+
...recorded
|
|
133
|
+
} satisfies Output
|
|
134
|
+
})
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
export default landEpic
|