@kitman-sh/software-engineering 0.13.8 → 0.13.10

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.
@@ -1265,7 +1265,7 @@
1265
1265
  {
1266
1266
  "id": "file-tasks",
1267
1267
  "title": "File Tasks",
1268
- "version": "1.0.0",
1268
+ "version": "2.0.0",
1269
1269
  "input": {
1270
1270
  "type": "object",
1271
1271
  "properties": {
@@ -1290,27 +1290,13 @@
1290
1290
  }
1291
1291
  },
1292
1292
  "promise": {
1293
- "anyOf": [
1294
- {
1295
- "type": "string"
1296
- },
1297
- {
1298
- "type": "null"
1299
- }
1300
- ]
1293
+ "type": "string"
1301
1294
  },
1302
1295
  "outOfScope": {
1303
- "anyOf": [
1304
- {
1305
- "type": "array",
1306
- "items": {
1307
- "type": "string"
1308
- }
1309
- },
1310
- {
1311
- "type": "null"
1312
- }
1313
- ]
1296
+ "type": "array",
1297
+ "items": {
1298
+ "type": "string"
1299
+ }
1314
1300
  },
1315
1301
  "repoBindingId": {
1316
1302
  "anyOf": [
@@ -1353,6 +1339,8 @@
1353
1339
  "title",
1354
1340
  "body",
1355
1341
  "acceptanceCriteria",
1342
+ "promise",
1343
+ "outOfScope",
1356
1344
  "blockedBy"
1357
1345
  ],
1358
1346
  "additionalProperties": true
@@ -1367,6 +1355,16 @@
1367
1355
  "type": "null"
1368
1356
  }
1369
1357
  ]
1358
+ },
1359
+ "repoBindingId": {
1360
+ "anyOf": [
1361
+ {
1362
+ "type": "string"
1363
+ },
1364
+ {
1365
+ "type": "null"
1366
+ }
1367
+ ]
1370
1368
  }
1371
1369
  },
1372
1370
  "required": [
@@ -1396,19 +1394,44 @@
1396
1394
  ],
1397
1395
  "additionalProperties": true
1398
1396
  }
1397
+ },
1398
+ "concerns": {
1399
+ "type": "array",
1400
+ "items": {
1401
+ "type": "object",
1402
+ "properties": {
1403
+ "ticket": {
1404
+ "type": "string"
1405
+ },
1406
+ "concern": {
1407
+ "type": "string",
1408
+ "maxLength": 600,
1409
+ "description": "At most 600 characters."
1410
+ }
1411
+ },
1412
+ "required": [
1413
+ "ticket",
1414
+ "concern"
1415
+ ],
1416
+ "additionalProperties": true
1417
+ }
1399
1418
  }
1400
1419
  },
1401
1420
  "required": [
1402
- "tasks"
1421
+ "tasks",
1422
+ "concerns"
1403
1423
  ],
1404
1424
  "additionalProperties": true,
1405
1425
  "$defs": {}
1406
1426
  },
1407
- "agents": {},
1408
- "checkout": "none",
1427
+ "agents": {
1428
+ "plan-reviewer": "plan-reviewer"
1429
+ },
1430
+ "checkout": "read",
1409
1431
  "when": [],
1410
1432
  "offers": [],
1411
1433
  "capabilities": [
1434
+ "agent_work",
1412
1435
  "create_tasks"
1413
1436
  ]
1414
1437
  },
@@ -1832,7 +1855,7 @@
1832
1855
  {
1833
1856
  "id": "plan",
1834
1857
  "title": "Plan",
1835
- "version": "2.2.0",
1858
+ "version": "3.0.0",
1836
1859
  "input": {
1837
1860
  "type": "object",
1838
1861
  "properties": {
@@ -2102,7 +2125,8 @@
2102
2125
  },
2103
2126
  "agents": {
2104
2127
  "planner": "planner",
2105
- "reviewer": "reviewer"
2128
+ "reviewer": "reviewer",
2129
+ "plan-reviewer": "plan-reviewer"
2106
2130
  },
2107
2131
  "checkout": "write",
2108
2132
  "when": [],
@@ -2753,7 +2777,7 @@
2753
2777
  {
2754
2778
  "id": "research",
2755
2779
  "title": "Research",
2756
- "version": "2.0.0",
2780
+ "version": "2.1.0",
2757
2781
  "input": {
2758
2782
  "type": "object",
2759
2783
  "properties": {
@@ -2858,27 +2882,13 @@
2858
2882
  }
2859
2883
  },
2860
2884
  "promise": {
2861
- "anyOf": [
2862
- {
2863
- "type": "string"
2864
- },
2865
- {
2866
- "type": "null"
2867
- }
2868
- ]
2885
+ "type": "string"
2869
2886
  },
2870
2887
  "outOfScope": {
2871
- "anyOf": [
2872
- {
2873
- "type": "array",
2874
- "items": {
2875
- "type": "string"
2876
- }
2877
- },
2878
- {
2879
- "type": "null"
2880
- }
2881
- ]
2888
+ "type": "array",
2889
+ "items": {
2890
+ "type": "string"
2891
+ }
2882
2892
  },
2883
2893
  "repoBindingId": {
2884
2894
  "anyOf": [
@@ -2921,6 +2931,8 @@
2921
2931
  "title",
2922
2932
  "body",
2923
2933
  "acceptanceCriteria",
2934
+ "promise",
2935
+ "outOfScope",
2924
2936
  "blockedBy"
2925
2937
  ],
2926
2938
  "additionalProperties": true
@@ -5782,6 +5794,17 @@
5782
5794
  "security-and-hardening"
5783
5795
  ]
5784
5796
  },
5797
+ "plan-reviewer": {
5798
+ "extends": "reviewer",
5799
+ "instructions": "You are a plan reviewer. You check a plan's tickets before a person is asked to approve them or they are filed as Tasks; you report, and their author revises.\n\n## Scope\n\n- Review only the plan you are given, against the code it is about and what the person asked for. Read that code before judging size and blockers.\n- Judge each ticket as the implementer who gets only that ticket would read it.\n\n## Skills\n\n- Load `skills({ name: 'scope-tasks' })` from the Kitman MCP and hold each ticket to it.\n\n## One pass\n\n- Check every ticket for everything the brief lists the first time. Give every concern now: a plan is revised only once before a person sees it, and tickets are filed only when you have none.\n- For each blocker, name to yourself the code the ticket needs and the ticket that writes it. A missing blocker and a needless one are both wrong.\n\n## Findings\n\n- Raise only a concern you can defend with what would go wrong when the ticket is built. No opinions on style or on what the person decided.\n- One concern per problem, in a few sentences, with what would answer it.\n- Finding nothing is a real answer: submit an empty list of concerns.\n\n## Rebuttals\n\n- Judge each reason the planner gives for not acting on a concern on its merits.\n- Raise that concern again only if you can answer the reason, and answer it when you do. What you raise again goes to the person with the plan.\n\n## Code comments\n\n- A plan has none to check.",
5800
+ "fallbacks": [
5801
+ {
5802
+ "harness": "claude",
5803
+ "model": "opus",
5804
+ "effort": "high"
5805
+ }
5806
+ ]
5807
+ },
5785
5808
  "planner": {
5786
5809
  "instructions": "You are a planner. You turn what someone asked for into a spec and tickets an implementer can build without asking again.\n\n## Questions\n\n- When your Step runs grill-with-docs, interview the person with the Kitman MCP `ask` tool, never in your reply: walk the decisions one at a time, and ask only when the answer changes what gets built. A clear goal needs no interview and no approval of a summary.\n- Ask one question at a time, and give options when the choices are clear, each with its trade-off in a short `description`.\n- Recommend an answer with `recommended` and say why in `recommendationReason`. Keep the prompt to the context and the decision. Only a question that purely asks for information you cannot guess, such as a secret's name, sets `informationOnly` instead, saying why.\n- Respect decisions already made; do not ask for them again.\n- Push back when an approach has a concrete downside: name it, propose an alternative, then accept the decision.\n\n## Tickets\n\n- Before you write tickets, load `skills({ name: 'scope-tasks' })` from the Kitman MCP and scope each ticket as it says.\n- Write vertical slices: each ticket lands on its own as one ChangeRequest and is verifiable on its own.\n- Give every ticket Acceptance Criteria that a reviewer can check against the change.\n- Give the plan an explicit out-of-scope list, so what was left out is a decision and not an omission.\n- Check the documentation when an API detail affects the plan.\n\n## Boundaries\n\n- Write no code; write only ADR and glossary changes. Your Output is the plan, and Kitman stores it.\n- Never `git stash`: the stash stack is shared with every other worktree of the repository.\n- An implementer that asks you a question gets one answer. Never give an answer and a wider version of it elsewhere: a requirement it was not told about is one it will not build.\n\n## Output\n\nSubmit your Output with the Kitman MCP `submit_output` tool, in the shape the brief's Output schema gives.",
5787
5810
  "harness": "claude",
@@ -5868,7 +5891,7 @@
5868
5891
  "carried": [
5869
5892
  {
5870
5893
  "name": "@kitman-sh/software-engineering",
5871
- "version": "0.13.8",
5894
+ "version": "0.13.10",
5872
5895
  "setup": "2a237548a69b0cd53ec3be7f687cfa8c2128335b3a655d34e185f2abce6a3c37",
5873
5896
  "loops": [
5874
5897
  "build",
@@ -5892,6 +5915,7 @@
5892
5915
  "reviewer",
5893
5916
  "code-reviewer",
5894
5917
  "quality-reviewer",
5918
+ "plan-reviewer",
5895
5919
  "planner",
5896
5920
  "releaser",
5897
5921
  "investigator",
package/kitman.config.ts CHANGED
@@ -68,6 +68,11 @@ export default defineKit({
68
68
  extends: 'reviewer',
69
69
  skills: ['code-review-and-quality', 'security-and-hardening']
70
70
  },
71
+ 'plan-reviewer': {
72
+ extends: 'reviewer',
73
+ fallbacks: [{ harness: 'claude', model: 'opus', effort: 'high' }],
74
+ instructions: { file: 'agents/plan-reviewer.md' }
75
+ },
71
76
  planner: {
72
77
  harness: 'claude',
73
78
  model: 'claude-fable-5-2',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitman-sh/software-engineering",
3
- "version": "0.13.8",
3
+ "version": "0.13.10",
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.13.8",
20
+ "@kitman-sh/sdk": "0.13.10",
21
21
  "effect": "^4.1.2"
22
22
  },
23
23
  "kitman": {
24
24
  "bundle": "dist/bundle.js",
25
- "digest": "9bb178d68e39290d2e54022788cbf9da47b0e698384db38121edb0da4ff824cc",
25
+ "digest": "3faba804520385bbca53011d02313670c85fe76668043252207913ce934c2703",
26
26
  "protocolVersion": 5,
27
27
  "declarations": "dist/declarations.json",
28
28
  "setup": {
package/src/file-tasks.ts CHANGED
@@ -1,30 +1,54 @@
1
- import { createTasks, defineLoop, PlanTickets } from '@kitman-sh/sdk/loop'
1
+ import { createTasks, defineLoop } from '@kitman-sh/sdk/loop'
2
2
  import * as Effect from 'effect/Effect'
3
3
  import * as Schema from 'effect/Schema'
4
+ import { reviewTickets, ScopedTickets, TicketConcern } from './plan-review'
4
5
 
5
6
  export const FileTasksInput = Schema.Struct({
6
- tickets: PlanTickets,
7
+ tickets: ScopedTickets,
7
8
  /** The Project the Tasks land in; the Project of the Run's Task when left out. */
8
- projectId: Schema.optional(Schema.String)
9
+ projectId: Schema.optional(Schema.String),
10
+ /** The repository the tickets are checked against, and filed for unless a ticket names its own. */
11
+ repoBindingId: Schema.optional(Schema.String)
9
12
  })
10
13
 
11
14
  const Output = Schema.Struct({
12
- tasks: Schema.Array(Schema.Struct({ key: Schema.String, taskId: Schema.String }))
15
+ /** None when the review has concerns. */
16
+ tasks: Schema.Array(Schema.Struct({ key: Schema.String, taskId: Schema.String })),
17
+ /** What to revise before starting it again, each by its ticket. */
18
+ concerns: Schema.Array(TicketConcern)
13
19
  })
14
20
 
15
- /** Files tickets as Tasks, with their blockers as dependencies: what another Loop's "File as Tasks" offer starts. */
21
+ /**
22
+ * Files tickets as Tasks, with their blockers as dependencies, when the plan reviewer has no concerns about them; with
23
+ * concerns it files none and returns them. Another Loop's "File as Tasks" offer starts it.
24
+ */
16
25
  export default defineLoop({
17
26
  id: 'file-tasks',
18
- version: '1.0.0',
27
+ version: '2.0.0',
19
28
  title: 'File Tasks',
20
29
  input: FileTasksInput,
21
30
  output: Output,
22
- agents: {},
23
- checkout: 'none',
24
- capabilities: ['create_tasks'],
31
+ agents: { 'plan-reviewer': 'plan-reviewer' },
32
+ checkout: 'read',
33
+ capabilities: ['agent_work', 'create_tasks'],
25
34
  run: input =>
26
- createTasks('tasks', {
27
- tickets: input.tickets,
28
- ...(input.projectId === undefined ? undefined : { projectId: input.projectId })
29
- }).pipe(Effect.map(({ tasks }) => ({ tasks })))
35
+ Effect.gen(function* () {
36
+ const { projectId, repoBindingId } = input
37
+
38
+ const tickets =
39
+ repoBindingId === undefined
40
+ ? input.tickets
41
+ : input.tickets.map(ticket => ({ ...ticket, repoBindingId: ticket.repoBindingId ?? repoBindingId }))
42
+
43
+ const concerns = tickets.length === 0 ? [] : yield* reviewTickets('plan-review', tickets)
44
+
45
+ if (concerns.length > 0) return { tasks: [], concerns }
46
+
47
+ const { tasks } = yield* createTasks('tasks', {
48
+ tickets,
49
+ ...(projectId === undefined ? undefined : { projectId })
50
+ })
51
+
52
+ return { tasks, concerns }
53
+ })
30
54
  })
@@ -0,0 +1,185 @@
1
+ import { agentWork, PlanTicket, planTicketsOf } from '@kitman-sh/sdk/loop'
2
+ import * as Effect from 'effect/Effect'
3
+ import * as Schema from 'effect/Schema'
4
+ import { Reason } from './text-limits'
5
+
6
+ /** Tickets that each state their scope, as the plan reviewer checks it. */
7
+ export const ScopedTickets = planTicketsOf(
8
+ Schema.Struct({
9
+ ...PlanTicket.fields,
10
+ promise: Schema.String.check(Schema.isPattern(/\S/)),
11
+ outOfScope: Schema.Array(Schema.String)
12
+ })
13
+ )
14
+
15
+ const Concern = Schema.Struct({
16
+ /** The key of the ticket it is about; the whole plan when left out. */
17
+ ticket: Schema.optional(Schema.String),
18
+ concern: Reason
19
+ })
20
+
21
+ export const TicketConcern = Schema.Struct({ ticket: Schema.String, concern: Reason })
22
+
23
+ const Check = Schema.Struct({ concerns: Schema.Array(Concern) })
24
+
25
+ const Recheck = Schema.Struct({
26
+ concerns: Schema.Array(
27
+ Schema.Struct({
28
+ ...Concern.fields,
29
+ /** The id of the concern of the first check this one still holds; none for a new one. */
30
+ earlier: Schema.optional(Schema.String)
31
+ })
32
+ )
33
+ })
34
+
35
+ /** Why the planner did not act on a concern, by the concern's id. */
36
+ export const DeclinedConcern = Schema.Struct({ concern: Schema.String, why: Reason })
37
+
38
+ export type DeclinedConcern = typeof DeclinedConcern.Type
39
+
40
+ export type PlanConcern = typeof Concern.Type & { readonly id: string }
41
+
42
+ /** A concern the reviewer holds after the revision, and why the planner did not act on it when it said so. */
43
+ export type DisputedConcern = typeof Concern.Type & { readonly declined?: string }
44
+
45
+ type Revision<Plan> = { readonly plan: Plan; readonly declined: readonly DeclinedConcern[] }
46
+
47
+ type PlanUnderReview<Plan, E, R> = {
48
+ readonly plan: Plan
49
+ /** What the person asked for, which neither the review nor the revision may go against. */
50
+ readonly asked: string
51
+ readonly text: (plan: Plan) => string
52
+ /** Revises the plan as the Step it is named, from a prompt that holds the concerns. */
53
+ readonly revise: (step: string, prompt: string) => Effect.Effect<Revision<Plan>, E, R>
54
+ }
55
+
56
+ export const outOfScopeText = ({ outOfScope = [] }: PlanTicket) =>
57
+ outOfScope.length === 0 ? [] : ['Out of scope:', ...outOfScope.map(item => `- ${item}`)]
58
+
59
+ export const ticketText = (ticket: PlanTicket) =>
60
+ [
61
+ `### ${ticket.key}: ${ticket.title}`,
62
+ ticket.body,
63
+ ...(ticket.promise === undefined ? [] : [`Promise: ${ticket.promise}`]),
64
+ ...ticket.acceptanceCriteria.map(criterion => `- [ ] ${criterion}`),
65
+ ...outOfScopeText(ticket),
66
+ ...(ticket.repoBindingId === undefined ? [] : [`Repository (repoBindingId): ${ticket.repoBindingId}`]),
67
+ ...(ticket.outcome === undefined ? [] : [`Outcome: ${ticket.outcome}`]),
68
+ ...(ticket.blockedBy.length === 0 ? [] : [`Blocked by: ${ticket.blockedBy.join(', ')}`])
69
+ ].join('\n\n')
70
+
71
+ const checks = [
72
+ "Load skills({ name: 'scope-tasks' }) from the Kitman MCP, read the code the plan is about, and check every ticket for each of these:",
73
+ [
74
+ '- One Promise: the ticket promises one thing, and its Out of scope list names the cases it does not handle. An open-ended Promise is a concern.',
75
+ '- Size: estimate the context one agent session needs from reading the code to a verified change. 200k tokens or more is a concern; give your estimate.',
76
+ '- Decisions: no design decision is left to the implementer.',
77
+ '- Blockers: it is blocked by each ticket whose code it needs, and by no other.'
78
+ ].join('\n'),
79
+ "Give each concern its ticket's key, and say what would answer it. What the person asked for is not a concern. Submit no concerns when every ticket holds. Change nothing."
80
+ ].join('\n\n')
81
+
82
+ const askedText = (asked: string) =>
83
+ `What the person asked for, in turn; where two differ, the later one holds:\n\n${asked}`
84
+
85
+ const answeredConcern = (concern: PlanConcern, declined: readonly DeclinedConcern[] = []) => {
86
+ const why = declined.find(entry => entry.concern === concern.id)?.why
87
+
88
+ return [
89
+ `${concern.id}${concern.ticket === undefined ? '' : `, on ${concern.ticket}`}: ${concern.concern}`,
90
+ ...(why === undefined ? [] : [`The planner did not act on it: ${why}`])
91
+ ].join('\n')
92
+ }
93
+
94
+ const checkPrompt = (asked: string, text: string) =>
95
+ ['Review this plan before a person is asked to approve it.', checks, askedText(asked), text].join('\n\n')
96
+
97
+ const ticketsPrompt = (tickets: typeof ScopedTickets.Type) =>
98
+ [
99
+ 'Review these tickets before they are filed as Tasks. Every concern names one of them: what concerns them all goes on the ticket that would change. With any concern none is filed, and whoever wrote them gets your concerns to revise them.',
100
+ checks,
101
+ ...tickets.map(ticketText)
102
+ ].join('\n\n')
103
+
104
+ const revisePrompt = (asked: string, text: string, concerns: readonly PlanConcern[]) =>
105
+ [
106
+ 'A reviewer checked the plan before a person is asked to approve it. Revise it to answer each concern, and keep what the person asked for and what no concern is about. Change no files; a decision a concern asks for goes in the plan. List in declined the id of each concern you did not act on and why; keep that out of the plan itself.',
107
+ concerns.map(concern => answeredConcern(concern)).join('\n\n'),
108
+ askedText(asked),
109
+ text
110
+ ].join('\n\n')
111
+
112
+ const recheckPrompt = (
113
+ asked: string,
114
+ text: string,
115
+ concerns: readonly PlanConcern[],
116
+ declined: readonly DeclinedConcern[]
117
+ ) =>
118
+ [
119
+ 'The planner revised this plan after your review. Check it once more. Raise again only a concern the revision does not answer, with its id in earlier; when the planner gave a reason not to act on it, raise it only if you can answer the reason. What you raise is shown to the person with the plan as still disputed.',
120
+ checks,
121
+ 'Your concerns on the plan before its revision:',
122
+ concerns.map(concern => answeredConcern(concern, declined)).join('\n\n'),
123
+ askedText(asked),
124
+ text
125
+ ].join('\n\n')
126
+
127
+ /**
128
+ * Has the calling Loop's `plan-reviewer` check a plan; when it has concerns, the plan is revised once and checked
129
+ * again. Returns the plan to show a person and what the reviewer still disputes.
130
+ */
131
+ export const reviewPlan = <Plan, E, R>(step: string, { plan, asked, text, revise }: PlanUnderReview<Plan, E, R>) =>
132
+ Effect.gen(function* () {
133
+ const first = yield* agentWork(step, {
134
+ agent: 'plan-reviewer',
135
+ prompt: checkPrompt(asked, text(plan)),
136
+ output: Check
137
+ })
138
+
139
+ if (first.concerns.length === 0) return { plan, disputed: [] }
140
+
141
+ const concerns = first.concerns.map((concern, index) => ({ ...concern, id: `c${index + 1}` }))
142
+ const revised = yield* revise(`${step}:revise`, revisePrompt(asked, text(plan), concerns))
143
+
144
+ const again = yield* agentWork(`${step}:recheck`, {
145
+ agent: 'plan-reviewer',
146
+ prompt: recheckPrompt(asked, text(revised.plan), concerns, revised.declined),
147
+ output: Recheck
148
+ })
149
+
150
+ const disputed = again.concerns.map(({ earlier, ...concern }): DisputedConcern => {
151
+ const declined = revised.declined.find(entry => entry.concern === earlier)?.why
152
+
153
+ return declined === undefined ? concern : { ...concern, declined }
154
+ })
155
+
156
+ return { plan: revised.plan, disputed }
157
+ })
158
+
159
+ /** Has the calling Loop's `plan-reviewer` check tickets once, each concern on one of them. */
160
+ export const reviewTickets = (step: string, tickets: typeof ScopedTickets.Type) =>
161
+ agentWork(step, {
162
+ agent: 'plan-reviewer',
163
+ prompt: ticketsPrompt(tickets),
164
+ output: Schema.Struct({
165
+ concerns: Schema.Array(
166
+ Schema.Struct({ ...TicketConcern.fields, ticket: Schema.Literals(tickets.map(({ key }) => key)) })
167
+ )
168
+ })
169
+ }).pipe(Effect.map(({ concerns }) => concerns))
170
+
171
+ const oneLine = (text: string) => text.replace(/\s+/gu, ' ').trim()
172
+
173
+ /** What is still disputed, as the section of the plan's Markdown a person reads it in. */
174
+ export const disputedText = (disputed: readonly DisputedConcern[]) =>
175
+ disputed.length === 0
176
+ ? []
177
+ : [
178
+ '## Still disputed',
179
+ disputed
180
+ .flatMap(({ ticket, concern, declined }) => [
181
+ `- ${ticket === undefined ? '' : `${ticket}: `}${oneLine(concern)}`,
182
+ ...(declined === undefined ? [] : [` - The planner did not act on it: ${oneLine(declined)}`])
183
+ ])
184
+ .join('\n')
185
+ ]