@kitman-sh/software-engineering 0.13.8 → 0.13.9
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/agents/plan-reviewer.md +30 -0
- package/dist/bundle.js +210 -68
- package/dist/declarations.json +16 -3
- package/kitman.config.ts +5 -0
- package/package.json +3 -3
- package/src/plan-review.ts +155 -0
- package/src/plan.ts +140 -87
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
You are a plan reviewer. You check a plan's tickets before a person is asked to approve them; you report, and the planner revises.
|
|
2
|
+
|
|
3
|
+
## Scope
|
|
4
|
+
|
|
5
|
+
- 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.
|
|
6
|
+
- Judge each ticket as the implementer who gets only that ticket would read it.
|
|
7
|
+
|
|
8
|
+
## Skills
|
|
9
|
+
|
|
10
|
+
- Load `skills({ name: 'scope-tasks' })` from the Kitman MCP and hold each ticket to it.
|
|
11
|
+
|
|
12
|
+
## One pass
|
|
13
|
+
|
|
14
|
+
- Check every ticket for everything the brief lists the first time. The plan is revised only once before the person sees it.
|
|
15
|
+
- 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.
|
|
16
|
+
|
|
17
|
+
## Findings
|
|
18
|
+
|
|
19
|
+
- 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.
|
|
20
|
+
- One concern per problem, in a few sentences, with what would answer it.
|
|
21
|
+
- Finding nothing is a real answer: submit an empty list of concerns.
|
|
22
|
+
|
|
23
|
+
## Rebuttals
|
|
24
|
+
|
|
25
|
+
- Judge each reason the planner gives for not acting on a concern on its merits.
|
|
26
|
+
- 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.
|
|
27
|
+
|
|
28
|
+
## Code comments
|
|
29
|
+
|
|
30
|
+
- A plan has none to check.
|
package/dist/bundle.js
CHANGED
|
@@ -19385,7 +19385,8 @@ var ticketsProblem = (tickets) => {
|
|
|
19385
19385
|
const { blocked } = wavesOf(tickets);
|
|
19386
19386
|
return blocked.length === 0 ? undefined : cycleMessage(blocked);
|
|
19387
19387
|
};
|
|
19388
|
-
var
|
|
19388
|
+
var planTicketsOf = (ticket) => ArraySchema(ticket).check(makeFilter2((tickets) => ticketsProblem(tickets) ?? true));
|
|
19389
|
+
var PlanTickets = planTicketsOf(PlanTicket);
|
|
19389
19390
|
|
|
19390
19391
|
class BlockingCycle extends TaggedError3()("BlockingCycle", {
|
|
19391
19392
|
tickets: ArraySchema(String5)
|
|
@@ -24326,6 +24327,112 @@ Start a Build that fixes it as a bug: ${conclusion.fix}?`,
|
|
|
24326
24327
|
})
|
|
24327
24328
|
});
|
|
24328
24329
|
|
|
24330
|
+
// src/plan-review.ts
|
|
24331
|
+
var Concern = Struct({
|
|
24332
|
+
ticket: optional2(String5),
|
|
24333
|
+
concern: Reason
|
|
24334
|
+
});
|
|
24335
|
+
var Check = Struct({ concerns: ArraySchema(Concern) });
|
|
24336
|
+
var Recheck = Struct({
|
|
24337
|
+
concerns: ArraySchema(Struct({
|
|
24338
|
+
...Concern.fields,
|
|
24339
|
+
earlier: optional2(String5)
|
|
24340
|
+
}))
|
|
24341
|
+
});
|
|
24342
|
+
var DeclinedConcern = Struct({ concern: String5, why: Reason });
|
|
24343
|
+
var outOfScopeText = ({ outOfScope = [] }) => outOfScope.length === 0 ? [] : ["Out of scope:", ...outOfScope.map((item) => `- ${item}`)];
|
|
24344
|
+
var ticketText = (ticket) => [
|
|
24345
|
+
`### ${ticket.key}: ${ticket.title}`,
|
|
24346
|
+
ticket.body,
|
|
24347
|
+
...ticket.promise === undefined ? [] : [`Promise: ${ticket.promise}`],
|
|
24348
|
+
...ticket.acceptanceCriteria.map((criterion) => `- [ ] ${criterion}`),
|
|
24349
|
+
...outOfScopeText(ticket),
|
|
24350
|
+
...ticket.repoBindingId === undefined ? [] : [`Repository (repoBindingId): ${ticket.repoBindingId}`],
|
|
24351
|
+
...ticket.outcome === undefined ? [] : [`Outcome: ${ticket.outcome}`],
|
|
24352
|
+
...ticket.blockedBy.length === 0 ? [] : [`Blocked by: ${ticket.blockedBy.join(", ")}`]
|
|
24353
|
+
].join(`
|
|
24354
|
+
|
|
24355
|
+
`);
|
|
24356
|
+
var checks = [
|
|
24357
|
+
"Load skills({ name: 'scope-tasks' }) from the Kitman MCP, read the code the plan is about, and check every ticket for each of these:",
|
|
24358
|
+
[
|
|
24359
|
+
"- 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.",
|
|
24360
|
+
"- 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.",
|
|
24361
|
+
"- Decisions: no design decision is left to the implementer.",
|
|
24362
|
+
"- Blockers: it is blocked by each ticket whose code it needs, and by no other."
|
|
24363
|
+
].join(`
|
|
24364
|
+
`),
|
|
24365
|
+
"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."
|
|
24366
|
+
].join(`
|
|
24367
|
+
|
|
24368
|
+
`);
|
|
24369
|
+
var askedText = (asked) => `What the person asked for, in turn; where two differ, the later one holds:
|
|
24370
|
+
|
|
24371
|
+
${asked}`;
|
|
24372
|
+
var answeredConcern = (concern, declined = []) => {
|
|
24373
|
+
const why = declined.find((entry) => entry.concern === concern.id)?.why;
|
|
24374
|
+
return [
|
|
24375
|
+
`${concern.id}${concern.ticket === undefined ? "" : `, on ${concern.ticket}`}: ${concern.concern}`,
|
|
24376
|
+
...why === undefined ? [] : [`The planner did not act on it: ${why}`]
|
|
24377
|
+
].join(`
|
|
24378
|
+
`);
|
|
24379
|
+
};
|
|
24380
|
+
var checkPrompt = (asked, text) => ["Review this plan before a person is asked to approve it.", checks, askedText(asked), text].join(`
|
|
24381
|
+
|
|
24382
|
+
`);
|
|
24383
|
+
var revisePrompt = (asked, text, concerns) => [
|
|
24384
|
+
"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.",
|
|
24385
|
+
concerns.map((concern) => answeredConcern(concern)).join(`
|
|
24386
|
+
|
|
24387
|
+
`),
|
|
24388
|
+
askedText(asked),
|
|
24389
|
+
text
|
|
24390
|
+
].join(`
|
|
24391
|
+
|
|
24392
|
+
`);
|
|
24393
|
+
var recheckPrompt = (asked, text, concerns, declined) => [
|
|
24394
|
+
"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.",
|
|
24395
|
+
checks,
|
|
24396
|
+
"Your concerns on the plan before its revision:",
|
|
24397
|
+
concerns.map((concern) => answeredConcern(concern, declined)).join(`
|
|
24398
|
+
|
|
24399
|
+
`),
|
|
24400
|
+
askedText(asked),
|
|
24401
|
+
text
|
|
24402
|
+
].join(`
|
|
24403
|
+
|
|
24404
|
+
`);
|
|
24405
|
+
var reviewPlan = (step, { plan, asked, text, revise }) => gen2(function* () {
|
|
24406
|
+
const first = yield* agentWork(step, {
|
|
24407
|
+
agent: "plan-reviewer",
|
|
24408
|
+
prompt: checkPrompt(asked, text(plan)),
|
|
24409
|
+
output: Check
|
|
24410
|
+
});
|
|
24411
|
+
if (first.concerns.length === 0)
|
|
24412
|
+
return { plan, disputed: [] };
|
|
24413
|
+
const concerns = first.concerns.map((concern, index) => ({ ...concern, id: `c${index + 1}` }));
|
|
24414
|
+
const revised = yield* revise(`${step}:revise`, revisePrompt(asked, text(plan), concerns));
|
|
24415
|
+
const again = yield* agentWork(`${step}:recheck`, {
|
|
24416
|
+
agent: "plan-reviewer",
|
|
24417
|
+
prompt: recheckPrompt(asked, text(revised.plan), concerns, revised.declined),
|
|
24418
|
+
output: Recheck
|
|
24419
|
+
});
|
|
24420
|
+
const disputed = again.concerns.map(({ earlier, ...concern }) => {
|
|
24421
|
+
const declined = revised.declined.find((entry) => entry.concern === earlier)?.why;
|
|
24422
|
+
return declined === undefined ? concern : { ...concern, declined };
|
|
24423
|
+
});
|
|
24424
|
+
return { plan: revised.plan, disputed };
|
|
24425
|
+
});
|
|
24426
|
+
var oneLine = (text) => text.replace(/\s+/gu, " ").trim();
|
|
24427
|
+
var disputedText = (disputed) => disputed.length === 0 ? [] : [
|
|
24428
|
+
"## Still disputed",
|
|
24429
|
+
disputed.flatMap(({ ticket, concern, declined }) => [
|
|
24430
|
+
`- ${ticket === undefined ? "" : `${ticket}: `}${oneLine(concern)}`,
|
|
24431
|
+
...declined === undefined ? [] : [` - The planner did not act on it: ${oneLine(declined)}`]
|
|
24432
|
+
]).join(`
|
|
24433
|
+
`)
|
|
24434
|
+
];
|
|
24435
|
+
|
|
24329
24436
|
// src/plan.ts
|
|
24330
24437
|
var Input7 = Struct({
|
|
24331
24438
|
words: String5,
|
|
@@ -24334,10 +24441,15 @@ var Input7 = Struct({
|
|
|
24334
24441
|
projectId: optional2(String5),
|
|
24335
24442
|
implement: optional2(Boolean3)
|
|
24336
24443
|
});
|
|
24444
|
+
var ScopedTickets = planTicketsOf(Struct({
|
|
24445
|
+
...PlanTicket.fields,
|
|
24446
|
+
promise: String5.check(isPattern2(/\S/)),
|
|
24447
|
+
outOfScope: ArraySchema(String5)
|
|
24448
|
+
}));
|
|
24337
24449
|
var Plan = Struct({
|
|
24338
24450
|
title: String5,
|
|
24339
24451
|
spec: String5,
|
|
24340
|
-
tickets:
|
|
24452
|
+
tickets: ScopedTickets,
|
|
24341
24453
|
outOfScope: ArraySchema(String5),
|
|
24342
24454
|
afterMerge: ArraySchema(String5),
|
|
24343
24455
|
docs: optional2(Struct({ title: String5, summary: String5 }))
|
|
@@ -24347,11 +24459,16 @@ var Revised = Struct({
|
|
|
24347
24459
|
addressed: ArraySchema(PlanAddressed),
|
|
24348
24460
|
declined: ArraySchema(PlanDeclined)
|
|
24349
24461
|
});
|
|
24462
|
+
var { docs: _docs, ...reworkedPlan } = Plan.fields;
|
|
24463
|
+
var Reworked = Struct({ ...reworkedPlan, declined: ArraySchema(DeclinedConcern) });
|
|
24464
|
+
var ReworkedAnswer = Struct({
|
|
24465
|
+
...Reworked.fields,
|
|
24466
|
+
comments: Struct({ addressed: ArraySchema(PlanAddressed), declined: ArraySchema(PlanDeclined) })
|
|
24467
|
+
});
|
|
24350
24468
|
var CriteriaCheck = Struct({
|
|
24351
24469
|
alreadyMet: ArraySchema(Struct({ key: String5, criterion: String5 }))
|
|
24352
24470
|
});
|
|
24353
24471
|
var Rejected = Struct({ key: String5, reason: String5 });
|
|
24354
|
-
var Opinion = Struct({ summary: String5, concerns: ArraySchema(String5) });
|
|
24355
24472
|
var TicketResult = Struct({
|
|
24356
24473
|
key: String5,
|
|
24357
24474
|
title: String5,
|
|
@@ -24372,13 +24489,11 @@ var Output8 = Struct({
|
|
|
24372
24489
|
tasks: optional2(CreateTasksResult.fields.tasks),
|
|
24373
24490
|
docs: optional2(ChangeRequestResult)
|
|
24374
24491
|
});
|
|
24375
|
-
var menu = ["Implement now", "File as Tasks", "
|
|
24492
|
+
var menu = ["Implement now", "File as Tasks", "Refine", "Finish"];
|
|
24376
24493
|
var maxRounds = 6;
|
|
24377
|
-
var maxOpinionsPerPlan = 2;
|
|
24378
24494
|
var menuDescriptions = {
|
|
24379
24495
|
"Implement now": "Builds the tickets in dependency order and delivers them.",
|
|
24380
24496
|
"File as Tasks": "Makes a Task of each ticket, to build later.",
|
|
24381
|
-
"Second opinion": "Another Agent reviews the plan.",
|
|
24382
24497
|
Refine: "You say what to change and the planner rewrites it.",
|
|
24383
24498
|
Finish: "Ends the Run with the plan as it is."
|
|
24384
24499
|
};
|
|
@@ -24387,6 +24502,7 @@ var onHeld = ["Merge again", ...onConflict];
|
|
|
24387
24502
|
var onFailure = ["Retry with a steer", "Skip it and its dependents", "Stop here"];
|
|
24388
24503
|
var ticketRules = [
|
|
24389
24504
|
"Each ticket is one Build: a vertical slice an agent can implement, review and deliver as one ChangeRequest. Give it a short unique key, and list in blockedBy the keys of the tickets whose code it needs; tickets never block each other in a cycle. Set repoBindingId only when it changes another repository than the plan, keep one repository per ticket, and no cycle across repositories. Set outcome to the kind of change: feature, bug, refactor, docs, migration, investigation or performance.",
|
|
24505
|
+
"Give each ticket its promise: one sentence that says what is true once it is done. List in its outOfScope the cases it does not handle. Two promises are two tickets.",
|
|
24390
24506
|
"Each acceptance criterion is something a Build can show before its ChangeRequest: a behaviour a test or a check proves. A text search is never a criterion, nor is something the code already does. Outcomes only visible after merge go under afterMerge, not under a ticket's criteria."
|
|
24391
24507
|
].join(`
|
|
24392
24508
|
|
|
@@ -24413,24 +24529,10 @@ var planText = (plan) => [
|
|
|
24413
24529
|
].join(`
|
|
24414
24530
|
|
|
24415
24531
|
`);
|
|
24416
|
-
var
|
|
24417
|
-
var ticketText = (ticket) => [
|
|
24418
|
-
`### ${ticket.key}: ${ticket.title}`,
|
|
24419
|
-
ticket.body,
|
|
24420
|
-
...ticket.promise === undefined ? [] : [`Promise: ${ticket.promise}`],
|
|
24421
|
-
...ticket.acceptanceCriteria.map((criterion) => `- [ ] ${criterion}`),
|
|
24422
|
-
...outOfScopeText(ticket),
|
|
24423
|
-
...ticket.blockedBy.length === 0 ? [] : [`Blocked by: ${ticket.blockedBy.join(", ")}`]
|
|
24424
|
-
].join(`
|
|
24425
|
-
|
|
24426
|
-
`);
|
|
24427
|
-
var opinionPrompt = (plan) => [
|
|
24428
|
-
"Review this plan as a second opinion. Look for missing scope, tickets too big to review, wrong blockers and risks. Change nothing.",
|
|
24429
|
-
planText(plan)
|
|
24430
|
-
].join(`
|
|
24532
|
+
var documentText = (plan, disputed) => [planText(plan), ...disputedText(disputed)].join(`
|
|
24431
24533
|
|
|
24432
24534
|
`);
|
|
24433
|
-
var refinePrompt = (
|
|
24535
|
+
var refinePrompt = (document, words) => [`Change the plan as the user asks: ${words}`, ticketRules, document].join(`
|
|
24434
24536
|
|
|
24435
24537
|
`);
|
|
24436
24538
|
var commentText = (comment) => {
|
|
@@ -24438,13 +24540,14 @@ var commentText = (comment) => {
|
|
|
24438
24540
|
return `${comment.id}, ${on}
|
|
24439
24541
|
${comment.body}`;
|
|
24440
24542
|
};
|
|
24441
|
-
var
|
|
24442
|
-
`A person reviewed revision ${review.revision} of the plan and requested changes. Each comment names its id, then the text it quotes and the line of the plan's Markdown below it is on, then what the person said. Revise the plan to answer each comment; list in addressed the id of each comment the new revision answers and how, in one sentence. List in declined the id of each comment you did not act on and why, in one sentence; keep that out of the plan itself.`,
|
|
24443
|
-
review.comments.map(commentText).join(`
|
|
24543
|
+
var commentsText = (review) => review.comments.map(commentText).join(`
|
|
24444
24544
|
|
|
24445
|
-
`)
|
|
24545
|
+
`);
|
|
24546
|
+
var revisePrompt2 = (document, review) => [
|
|
24547
|
+
`A person reviewed revision ${review.revision} of the plan and requested changes. Each comment names its id, then the text it quotes and the line of the plan's Markdown below it is on, then what the person said. Revise the plan to answer each comment; list in addressed the id of each comment the new revision answers and how, in one sentence. List in declined the id of each comment you did not act on and why, in one sentence; keep that out of the plan itself.`,
|
|
24548
|
+
commentsText(review),
|
|
24446
24549
|
ticketRules,
|
|
24447
|
-
|
|
24550
|
+
document
|
|
24448
24551
|
].join(`
|
|
24449
24552
|
|
|
24450
24553
|
`);
|
|
@@ -24468,8 +24571,51 @@ var guarded = (plan, check) => {
|
|
|
24468
24571
|
]);
|
|
24469
24572
|
return { plan: { ...plan, tickets }, rejected };
|
|
24470
24573
|
};
|
|
24471
|
-
var
|
|
24472
|
-
|
|
24574
|
+
var answeredText = ({ addressed, declined }) => [
|
|
24575
|
+
"The plan answers a person's review, whose comments are in what the person asked for. This is what the plan above did about each. Give comments the same for your revision: list in its addressed the id of each comment your revision answers and how, and in its declined the id of each it does not act on and why, each in one sentence.",
|
|
24576
|
+
[
|
|
24577
|
+
...addressed.map(({ comment, how }) => `Comment ${comment}, addressed: ${how}`),
|
|
24578
|
+
...declined.map(({ comment, why }) => `Comment ${comment}, declined: ${why}`)
|
|
24579
|
+
].join(`
|
|
24580
|
+
`)
|
|
24581
|
+
].join(`
|
|
24582
|
+
|
|
24583
|
+
`);
|
|
24584
|
+
var rework = (step, prompt, answered) => answered === undefined ? agentWorkOnce(step, { agent: "planner", prompt: [prompt, ticketRules].join(`
|
|
24585
|
+
|
|
24586
|
+
`), output: Reworked }).pipe(map8(({ declined, ...plan }) => ({ plan: { plan }, declined }))) : agentWorkOnce(step, {
|
|
24587
|
+
agent: "planner",
|
|
24588
|
+
prompt: [prompt, ticketRules, answeredText(answered)].join(`
|
|
24589
|
+
|
|
24590
|
+
`),
|
|
24591
|
+
output: ReworkedAnswer
|
|
24592
|
+
}).pipe(map8(({ declined, comments, ...plan }) => ({
|
|
24593
|
+
plan: { plan, answered: { review: answered.review, ...comments } },
|
|
24594
|
+
declined
|
|
24595
|
+
})));
|
|
24596
|
+
var checked = (draft, revision, asked) => gen2(function* () {
|
|
24597
|
+
const reviewed = yield* reviewPlan(`plan-review:${revision}`, {
|
|
24598
|
+
plan: draft,
|
|
24599
|
+
asked: asked.join(`
|
|
24600
|
+
|
|
24601
|
+
`),
|
|
24602
|
+
text: ({ plan }) => planText(plan),
|
|
24603
|
+
revise: (step, prompt) => rework(step, prompt, draft.answered)
|
|
24604
|
+
});
|
|
24605
|
+
const check = yield* agentWork(`criteria-check:${revision}`, {
|
|
24606
|
+
agent: "reviewer",
|
|
24607
|
+
prompt: criteriaPrompt2(reviewed.plan.plan),
|
|
24608
|
+
output: CriteriaCheck
|
|
24609
|
+
});
|
|
24610
|
+
const { plan, rejected } = guarded(reviewed.plan.plan, check);
|
|
24611
|
+
return {
|
|
24612
|
+
plan,
|
|
24613
|
+
rejected,
|
|
24614
|
+
answered: reviewed.plan.answered,
|
|
24615
|
+
disputed: reviewed.disputed.filter((entry) => !rejected.some(({ key }) => key === entry.ticket))
|
|
24616
|
+
};
|
|
24617
|
+
});
|
|
24618
|
+
var storePlan = ({ plan, disputed, answered }, suffix, revision) => gen2(function* () {
|
|
24473
24619
|
yield* artifact(`spec${suffix}`, {
|
|
24474
24620
|
kind: "plan_spec",
|
|
24475
24621
|
title: plan.title,
|
|
@@ -24482,12 +24628,11 @@ var storePlan = (plan, suffix, revision, answered) => gen2(function* () {
|
|
|
24482
24628
|
text: plan.tickets.map(ticketText).join(`
|
|
24483
24629
|
|
|
24484
24630
|
`),
|
|
24485
|
-
data: plan.tickets.map(({ repoBindingId, outcome,
|
|
24631
|
+
data: plan.tickets.map(({ repoBindingId, outcome, ...ticket }) => ({
|
|
24486
24632
|
...ticket,
|
|
24487
24633
|
acceptanceCriteria: [...ticket.acceptanceCriteria],
|
|
24488
24634
|
blockedBy: [...ticket.blockedBy],
|
|
24489
|
-
|
|
24490
|
-
...outOfScope === undefined ? undefined : { outOfScope: [...outOfScope] },
|
|
24635
|
+
outOfScope: [...ticket.outOfScope],
|
|
24491
24636
|
...repoBindingId === undefined ? undefined : { repoBindingId },
|
|
24492
24637
|
...outcome === undefined ? undefined : { outcome }
|
|
24493
24638
|
}))
|
|
@@ -24495,7 +24640,7 @@ var storePlan = (plan, suffix, revision, answered) => gen2(function* () {
|
|
|
24495
24640
|
yield* artifact(`document${suffix}`, {
|
|
24496
24641
|
kind: "plan_document",
|
|
24497
24642
|
title: plan.title,
|
|
24498
|
-
text:
|
|
24643
|
+
text: documentText(plan, disputed),
|
|
24499
24644
|
data: {
|
|
24500
24645
|
revision,
|
|
24501
24646
|
...answered === undefined ? undefined : {
|
|
@@ -24722,11 +24867,11 @@ var implement = (input, plan, revision, filed) => gen2(function* () {
|
|
|
24722
24867
|
});
|
|
24723
24868
|
var plan_default = defineLoop({
|
|
24724
24869
|
id: "plan",
|
|
24725
|
-
version: "
|
|
24870
|
+
version: "3.0.0",
|
|
24726
24871
|
title: "Plan",
|
|
24727
24872
|
input: Input7,
|
|
24728
24873
|
output: Output8,
|
|
24729
|
-
agents: { planner: "planner", reviewer: "reviewer" },
|
|
24874
|
+
agents: { planner: "planner", reviewer: "reviewer", "plan-reviewer": "plan-reviewer" },
|
|
24730
24875
|
checkout: "write",
|
|
24731
24876
|
capabilities: [
|
|
24732
24877
|
"agent_work",
|
|
@@ -24750,10 +24895,10 @@ var plan_default = defineLoop({
|
|
|
24750
24895
|
});
|
|
24751
24896
|
const docs = drafted.docs === undefined ? undefined : yield* changeRequest("docs", { title: drafted.docs.title, body: drafted.docs.summary });
|
|
24752
24897
|
let revision = 1;
|
|
24753
|
-
|
|
24898
|
+
const asked = [input.words];
|
|
24899
|
+
let { plan, rejected, disputed } = yield* checked({ plan: drafted }, revision, asked);
|
|
24754
24900
|
let filed;
|
|
24755
|
-
|
|
24756
|
-
yield* storePlan(plan, "", revision);
|
|
24901
|
+
yield* storePlan({ plan, disputed }, "", revision);
|
|
24757
24902
|
const project = input.projectId === undefined ? undefined : { projectId: input.projectId };
|
|
24758
24903
|
const held = new Map;
|
|
24759
24904
|
let implementing = false;
|
|
@@ -24782,7 +24927,12 @@ var plan_default = defineLoop({
|
|
|
24782
24927
|
const approve = () => gen2(function* () {
|
|
24783
24928
|
for (;; ) {
|
|
24784
24929
|
const answer = yield* ask(`review:${revision}`, {
|
|
24785
|
-
prompt:
|
|
24930
|
+
prompt: [
|
|
24931
|
+
`Review revision ${revision} of the plan "${plan.title}": approve it, or request changes by commenting on what should change.`,
|
|
24932
|
+
...disputed.length === 0 ? [] : [
|
|
24933
|
+
`The plan reviewer still disputes ${disputed.length} point${disputed.length === 1 ? "" : "s"}, listed at the end of the plan.`
|
|
24934
|
+
]
|
|
24935
|
+
].join(" "),
|
|
24786
24936
|
freeText: true,
|
|
24787
24937
|
recommended: PlanApproval,
|
|
24788
24938
|
recommendationReason: "Approve it once the plan reads right; until then the Run waits for you.",
|
|
@@ -24791,18 +24941,20 @@ var plan_default = defineLoop({
|
|
|
24791
24941
|
});
|
|
24792
24942
|
if (isPlanApproval(answer))
|
|
24793
24943
|
return;
|
|
24794
|
-
const review = readPlanReview(answer, revision,
|
|
24944
|
+
const review = readPlanReview(answer, revision, documentText(plan, disputed));
|
|
24795
24945
|
const revised = yield* agentWorkOnce(`revise-plan:${revision}`, {
|
|
24796
24946
|
agent: "planner",
|
|
24797
|
-
prompt:
|
|
24947
|
+
prompt: revisePrompt2(documentText(plan, disputed), review),
|
|
24798
24948
|
output: Revised
|
|
24799
24949
|
});
|
|
24800
24950
|
const { addressed, declined, ...next } = revised;
|
|
24801
24951
|
const before = plan;
|
|
24802
24952
|
const count = review.comments.length;
|
|
24803
24953
|
revision++;
|
|
24804
|
-
(
|
|
24805
|
-
yield*
|
|
24954
|
+
asked.push(commentsText(review));
|
|
24955
|
+
const ready = yield* checked({ plan: next, answered: { review, addressed, declined } }, revision, asked);
|
|
24956
|
+
({ plan, rejected, disputed } = ready);
|
|
24957
|
+
yield* storePlan(ready, `:review-${revision}`, revision);
|
|
24806
24958
|
yield* artifact(`changes:review-${revision}`, {
|
|
24807
24959
|
kind: "plan_changes",
|
|
24808
24960
|
title: `Revision ${revision} of ${plan.title}`,
|
|
@@ -24813,7 +24965,7 @@ var plan_default = defineLoop({
|
|
|
24813
24965
|
const decide = gen2(function* () {
|
|
24814
24966
|
for (let round = 1;round <= maxRounds; round++) {
|
|
24815
24967
|
const isFiled = filed?.revision === revision;
|
|
24816
|
-
const options = menu.filter((option) => !(option === "File as Tasks" && isFiled)
|
|
24968
|
+
const options = menu.filter((option) => !(option === "File as Tasks" && isFiled));
|
|
24817
24969
|
const fallback = input.implement === true ? "Implement now" : isFiled ? "Finish" : "File as Tasks";
|
|
24818
24970
|
const answer = yield* ask(`next:${round}`, {
|
|
24819
24971
|
prompt: `What next for the plan "${plan.title}"?`,
|
|
@@ -24837,22 +24989,6 @@ var plan_default = defineLoop({
|
|
|
24837
24989
|
case "File as Tasks":
|
|
24838
24990
|
yield* file(`file-tasks:${round}`);
|
|
24839
24991
|
break;
|
|
24840
|
-
case "Second opinion": {
|
|
24841
|
-
opinions++;
|
|
24842
|
-
const opinion = yield* agentWork(`second-opinion:${round}`, {
|
|
24843
|
-
agent: "reviewer",
|
|
24844
|
-
prompt: opinionPrompt(plan),
|
|
24845
|
-
output: Opinion
|
|
24846
|
-
});
|
|
24847
|
-
yield* artifact(`opinion:${round}`, {
|
|
24848
|
-
kind: "plan_review",
|
|
24849
|
-
title: `Second opinion on ${plan.title}`,
|
|
24850
|
-
text: [opinion.summary, ...opinion.concerns.map((concern) => `- ${concern}`)].join(`
|
|
24851
|
-
|
|
24852
|
-
`)
|
|
24853
|
-
});
|
|
24854
|
-
break;
|
|
24855
|
-
}
|
|
24856
24992
|
case "Refine": {
|
|
24857
24993
|
const words = yield* ask(`refine:${round}`, {
|
|
24858
24994
|
prompt: "What should change in the plan?",
|
|
@@ -24862,13 +24998,14 @@ var plan_default = defineLoop({
|
|
|
24862
24998
|
});
|
|
24863
24999
|
const refined = yield* agentWorkOnce(`refine-plan:${round}`, {
|
|
24864
25000
|
agent: "planner",
|
|
24865
|
-
prompt: refinePrompt(plan, words),
|
|
25001
|
+
prompt: refinePrompt(documentText(plan, disputed), words),
|
|
24866
25002
|
output: Plan
|
|
24867
25003
|
});
|
|
24868
25004
|
const before = plan;
|
|
24869
25005
|
revision++;
|
|
24870
|
-
(
|
|
24871
|
-
yield*
|
|
25006
|
+
asked.push(words);
|
|
25007
|
+
({ plan, rejected, disputed } = yield* checked({ plan: refined }, revision, asked));
|
|
25008
|
+
yield* storePlan({ plan, disputed }, `:${round}`, revision);
|
|
24872
25009
|
yield* artifact(`changes:${round}`, {
|
|
24873
25010
|
kind: "plan_changes",
|
|
24874
25011
|
title: `Revision ${revision} of ${plan.title}`,
|
|
@@ -25168,7 +25305,7 @@ var Output11 = Struct({
|
|
|
25168
25305
|
improvements: ArraySchema(Struct({ key: String5, loop: Literals(["errand", "build"]), outcome: String5 })),
|
|
25169
25306
|
notStarted: ArraySchema(Struct({ key: String5, reason: Reason }))
|
|
25170
25307
|
});
|
|
25171
|
-
var
|
|
25308
|
+
var oneLine2 = (text) => text.replace(/\s*\n\s*/g, " \u23CE ");
|
|
25172
25309
|
var rootOf = (run) => run.rootRunId ?? run.runId;
|
|
25173
25310
|
var digest = (runs) => runs.flatMap((run) => [
|
|
25174
25311
|
[
|
|
@@ -25178,18 +25315,18 @@ var digest = (runs) => runs.flatMap((run) => [
|
|
|
25178
25315
|
...rootOf(run) === run.runId ? [] : [`part of ${rootOf(run)}`],
|
|
25179
25316
|
...run.teamId === undefined ? [] : [`team ${run.teamId}`],
|
|
25180
25317
|
...run.retried === true ? ["retried"] : [],
|
|
25181
|
-
...run.failure === undefined ? [] : [`failure: ${
|
|
25318
|
+
...run.failure === undefined ? [] : [`failure: ${oneLine2(run.failure)}`],
|
|
25182
25319
|
...run.omitted === undefined ? [] : [`${run.omitted} entries left out`]
|
|
25183
25320
|
].join(" \xB7 "),
|
|
25184
25321
|
...run.entries.flatMap((entry, index) => [
|
|
25185
25322
|
...run.entries[index - 1]?.stepAttemptId === entry.stepAttemptId ? [] : [` attempt ${entry.stepAttemptId}`],
|
|
25186
|
-
` ${entry.sequence} ${entry.kind}: ${
|
|
25323
|
+
` ${entry.sequence} ${entry.kind}: ${oneLine2(entry.text)}`
|
|
25187
25324
|
])
|
|
25188
25325
|
]).join(`
|
|
25189
25326
|
`);
|
|
25190
25327
|
var earlier = (findings) => findings.length === 0 ? "No earlier finding is open." : [
|
|
25191
25328
|
"Earlier findings still open, by key. When a problem is one of these, give it that key exactly; a new key only for a new problem:",
|
|
25192
|
-
...findings.map((found) => `- ${found.key}: ${
|
|
25329
|
+
...findings.map((found) => `- ${found.key}: ${oneLine2(found.title)} (${found.taskKey === undefined ? "proposal waiting for a decision" : `open Task ${found.taskKey}`})`)
|
|
25193
25330
|
].join(`
|
|
25194
25331
|
`);
|
|
25195
25332
|
var prompt4 = (read, days) => [
|
|
@@ -25817,6 +25954,11 @@ var kitman_config_default = defineKit({
|
|
|
25817
25954
|
extends: "reviewer",
|
|
25818
25955
|
skills: ["code-review-and-quality", "security-and-hardening"]
|
|
25819
25956
|
},
|
|
25957
|
+
"plan-reviewer": {
|
|
25958
|
+
extends: "reviewer",
|
|
25959
|
+
fallbacks: [{ harness: "claude", model: "opus", effort: "high" }],
|
|
25960
|
+
instructions: { file: "agents/plan-reviewer.md" }
|
|
25961
|
+
},
|
|
25820
25962
|
planner: {
|
|
25821
25963
|
harness: "claude",
|
|
25822
25964
|
model: "claude-fable-5-2",
|
|
@@ -31618,4 +31760,4 @@ var runKit = (config, identity, packages) => {
|
|
|
31618
31760
|
runMain2(program.pipe(flatMap3((code) => sync2(() => process.exit(code)))));
|
|
31619
31761
|
};
|
|
31620
31762
|
// .kitman-build-entry.ts
|
|
31621
|
-
runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.13.
|
|
31763
|
+
runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.13.9" }, []);
|
package/dist/declarations.json
CHANGED
|
@@ -1832,7 +1832,7 @@
|
|
|
1832
1832
|
{
|
|
1833
1833
|
"id": "plan",
|
|
1834
1834
|
"title": "Plan",
|
|
1835
|
-
"version": "
|
|
1835
|
+
"version": "3.0.0",
|
|
1836
1836
|
"input": {
|
|
1837
1837
|
"type": "object",
|
|
1838
1838
|
"properties": {
|
|
@@ -2102,7 +2102,8 @@
|
|
|
2102
2102
|
},
|
|
2103
2103
|
"agents": {
|
|
2104
2104
|
"planner": "planner",
|
|
2105
|
-
"reviewer": "reviewer"
|
|
2105
|
+
"reviewer": "reviewer",
|
|
2106
|
+
"plan-reviewer": "plan-reviewer"
|
|
2106
2107
|
},
|
|
2107
2108
|
"checkout": "write",
|
|
2108
2109
|
"when": [],
|
|
@@ -5782,6 +5783,17 @@
|
|
|
5782
5783
|
"security-and-hardening"
|
|
5783
5784
|
]
|
|
5784
5785
|
},
|
|
5786
|
+
"plan-reviewer": {
|
|
5787
|
+
"extends": "reviewer",
|
|
5788
|
+
"instructions": "You are a plan reviewer. You check a plan's tickets before a person is asked to approve them; you report, and the planner 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. The plan is revised only once before the person sees it.\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.",
|
|
5789
|
+
"fallbacks": [
|
|
5790
|
+
{
|
|
5791
|
+
"harness": "claude",
|
|
5792
|
+
"model": "opus",
|
|
5793
|
+
"effort": "high"
|
|
5794
|
+
}
|
|
5795
|
+
]
|
|
5796
|
+
},
|
|
5785
5797
|
"planner": {
|
|
5786
5798
|
"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
5799
|
"harness": "claude",
|
|
@@ -5868,7 +5880,7 @@
|
|
|
5868
5880
|
"carried": [
|
|
5869
5881
|
{
|
|
5870
5882
|
"name": "@kitman-sh/software-engineering",
|
|
5871
|
-
"version": "0.13.
|
|
5883
|
+
"version": "0.13.9",
|
|
5872
5884
|
"setup": "2a237548a69b0cd53ec3be7f687cfa8c2128335b3a655d34e185f2abce6a3c37",
|
|
5873
5885
|
"loops": [
|
|
5874
5886
|
"build",
|
|
@@ -5892,6 +5904,7 @@
|
|
|
5892
5904
|
"reviewer",
|
|
5893
5905
|
"code-reviewer",
|
|
5894
5906
|
"quality-reviewer",
|
|
5907
|
+
"plan-reviewer",
|
|
5895
5908
|
"planner",
|
|
5896
5909
|
"releaser",
|
|
5897
5910
|
"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.
|
|
3
|
+
"version": "0.13.9",
|
|
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.
|
|
20
|
+
"@kitman-sh/sdk": "0.13.9",
|
|
21
21
|
"effect": "^4.1.2"
|
|
22
22
|
},
|
|
23
23
|
"kitman": {
|
|
24
24
|
"bundle": "dist/bundle.js",
|
|
25
|
-
"digest": "
|
|
25
|
+
"digest": "7353385c50956862d45b00d01aef6df501970aa4c5a461d851a3a08efbdfbbeb",
|
|
26
26
|
"protocolVersion": 5,
|
|
27
27
|
"declarations": "dist/declarations.json",
|
|
28
28
|
"setup": {
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { agentWork, type PlanTicket } 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
|
+
const Concern = Schema.Struct({
|
|
7
|
+
/** The key of the ticket it is about; the whole plan when left out. */
|
|
8
|
+
ticket: Schema.optional(Schema.String),
|
|
9
|
+
concern: Reason
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
const Check = Schema.Struct({ concerns: Schema.Array(Concern) })
|
|
13
|
+
|
|
14
|
+
const Recheck = Schema.Struct({
|
|
15
|
+
concerns: Schema.Array(
|
|
16
|
+
Schema.Struct({
|
|
17
|
+
...Concern.fields,
|
|
18
|
+
/** The id of the concern of the first check this one still holds; none for a new one. */
|
|
19
|
+
earlier: Schema.optional(Schema.String)
|
|
20
|
+
})
|
|
21
|
+
)
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
/** Why the planner did not act on a concern, by the concern's id. */
|
|
25
|
+
export const DeclinedConcern = Schema.Struct({ concern: Schema.String, why: Reason })
|
|
26
|
+
|
|
27
|
+
export type DeclinedConcern = typeof DeclinedConcern.Type
|
|
28
|
+
|
|
29
|
+
export type PlanConcern = typeof Concern.Type & { readonly id: string }
|
|
30
|
+
|
|
31
|
+
/** A concern the reviewer holds after the revision, and why the planner did not act on it when it said so. */
|
|
32
|
+
export type DisputedConcern = typeof Concern.Type & { readonly declined?: string }
|
|
33
|
+
|
|
34
|
+
type Revision<Plan> = { readonly plan: Plan; readonly declined: readonly DeclinedConcern[] }
|
|
35
|
+
|
|
36
|
+
type PlanUnderReview<Plan, E, R> = {
|
|
37
|
+
readonly plan: Plan
|
|
38
|
+
/** What the person asked for, which neither the review nor the revision may go against. */
|
|
39
|
+
readonly asked: string
|
|
40
|
+
readonly text: (plan: Plan) => string
|
|
41
|
+
/** Revises the plan as the Step it is named, from a prompt that holds the concerns. */
|
|
42
|
+
readonly revise: (step: string, prompt: string) => Effect.Effect<Revision<Plan>, E, R>
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const outOfScopeText = ({ outOfScope = [] }: PlanTicket) =>
|
|
46
|
+
outOfScope.length === 0 ? [] : ['Out of scope:', ...outOfScope.map(item => `- ${item}`)]
|
|
47
|
+
|
|
48
|
+
export const ticketText = (ticket: PlanTicket) =>
|
|
49
|
+
[
|
|
50
|
+
`### ${ticket.key}: ${ticket.title}`,
|
|
51
|
+
ticket.body,
|
|
52
|
+
...(ticket.promise === undefined ? [] : [`Promise: ${ticket.promise}`]),
|
|
53
|
+
...ticket.acceptanceCriteria.map(criterion => `- [ ] ${criterion}`),
|
|
54
|
+
...outOfScopeText(ticket),
|
|
55
|
+
...(ticket.repoBindingId === undefined ? [] : [`Repository (repoBindingId): ${ticket.repoBindingId}`]),
|
|
56
|
+
...(ticket.outcome === undefined ? [] : [`Outcome: ${ticket.outcome}`]),
|
|
57
|
+
...(ticket.blockedBy.length === 0 ? [] : [`Blocked by: ${ticket.blockedBy.join(', ')}`])
|
|
58
|
+
].join('\n\n')
|
|
59
|
+
|
|
60
|
+
const checks = [
|
|
61
|
+
"Load skills({ name: 'scope-tasks' }) from the Kitman MCP, read the code the plan is about, and check every ticket for each of these:",
|
|
62
|
+
[
|
|
63
|
+
'- 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.',
|
|
64
|
+
'- 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.',
|
|
65
|
+
'- Decisions: no design decision is left to the implementer.',
|
|
66
|
+
'- Blockers: it is blocked by each ticket whose code it needs, and by no other.'
|
|
67
|
+
].join('\n'),
|
|
68
|
+
"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."
|
|
69
|
+
].join('\n\n')
|
|
70
|
+
|
|
71
|
+
const askedText = (asked: string) =>
|
|
72
|
+
`What the person asked for, in turn; where two differ, the later one holds:\n\n${asked}`
|
|
73
|
+
|
|
74
|
+
const answeredConcern = (concern: PlanConcern, declined: readonly DeclinedConcern[] = []) => {
|
|
75
|
+
const why = declined.find(entry => entry.concern === concern.id)?.why
|
|
76
|
+
|
|
77
|
+
return [
|
|
78
|
+
`${concern.id}${concern.ticket === undefined ? '' : `, on ${concern.ticket}`}: ${concern.concern}`,
|
|
79
|
+
...(why === undefined ? [] : [`The planner did not act on it: ${why}`])
|
|
80
|
+
].join('\n')
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const checkPrompt = (asked: string, text: string) =>
|
|
84
|
+
['Review this plan before a person is asked to approve it.', checks, askedText(asked), text].join('\n\n')
|
|
85
|
+
|
|
86
|
+
const revisePrompt = (asked: string, text: string, concerns: readonly PlanConcern[]) =>
|
|
87
|
+
[
|
|
88
|
+
'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.',
|
|
89
|
+
concerns.map(concern => answeredConcern(concern)).join('\n\n'),
|
|
90
|
+
askedText(asked),
|
|
91
|
+
text
|
|
92
|
+
].join('\n\n')
|
|
93
|
+
|
|
94
|
+
const recheckPrompt = (
|
|
95
|
+
asked: string,
|
|
96
|
+
text: string,
|
|
97
|
+
concerns: readonly PlanConcern[],
|
|
98
|
+
declined: readonly DeclinedConcern[]
|
|
99
|
+
) =>
|
|
100
|
+
[
|
|
101
|
+
'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.',
|
|
102
|
+
checks,
|
|
103
|
+
'Your concerns on the plan before its revision:',
|
|
104
|
+
concerns.map(concern => answeredConcern(concern, declined)).join('\n\n'),
|
|
105
|
+
askedText(asked),
|
|
106
|
+
text
|
|
107
|
+
].join('\n\n')
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Has the calling Loop's `plan-reviewer` check a plan; when it has concerns, the plan is revised once and checked
|
|
111
|
+
* again. Returns the plan to show a person and what the reviewer still disputes.
|
|
112
|
+
*/
|
|
113
|
+
export const reviewPlan = <Plan, E, R>(step: string, { plan, asked, text, revise }: PlanUnderReview<Plan, E, R>) =>
|
|
114
|
+
Effect.gen(function* () {
|
|
115
|
+
const first = yield* agentWork(step, {
|
|
116
|
+
agent: 'plan-reviewer',
|
|
117
|
+
prompt: checkPrompt(asked, text(plan)),
|
|
118
|
+
output: Check
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
if (first.concerns.length === 0) return { plan, disputed: [] }
|
|
122
|
+
|
|
123
|
+
const concerns = first.concerns.map((concern, index) => ({ ...concern, id: `c${index + 1}` }))
|
|
124
|
+
const revised = yield* revise(`${step}:revise`, revisePrompt(asked, text(plan), concerns))
|
|
125
|
+
|
|
126
|
+
const again = yield* agentWork(`${step}:recheck`, {
|
|
127
|
+
agent: 'plan-reviewer',
|
|
128
|
+
prompt: recheckPrompt(asked, text(revised.plan), concerns, revised.declined),
|
|
129
|
+
output: Recheck
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
const disputed = again.concerns.map(({ earlier, ...concern }): DisputedConcern => {
|
|
133
|
+
const declined = revised.declined.find(entry => entry.concern === earlier)?.why
|
|
134
|
+
|
|
135
|
+
return declined === undefined ? concern : { ...concern, declined }
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
return { plan: revised.plan, disputed }
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
const oneLine = (text: string) => text.replace(/\s+/gu, ' ').trim()
|
|
142
|
+
|
|
143
|
+
/** What is still disputed, as the section of the plan's Markdown a person reads it in. */
|
|
144
|
+
export const disputedText = (disputed: readonly DisputedConcern[]) =>
|
|
145
|
+
disputed.length === 0
|
|
146
|
+
? []
|
|
147
|
+
: [
|
|
148
|
+
'## Still disputed',
|
|
149
|
+
disputed
|
|
150
|
+
.flatMap(({ ticket, concern, declined }) => [
|
|
151
|
+
`- ${ticket === undefined ? '' : `${ticket}: `}${oneLine(concern)}`,
|
|
152
|
+
...(declined === undefined ? [] : [` - The planner did not act on it: ${oneLine(declined)}`])
|
|
153
|
+
])
|
|
154
|
+
.join('\n')
|
|
155
|
+
]
|
package/src/plan.ts
CHANGED
|
@@ -17,15 +17,23 @@ import {
|
|
|
17
17
|
PlanApproval,
|
|
18
18
|
PlanDeclined,
|
|
19
19
|
type PlanReview,
|
|
20
|
-
|
|
20
|
+
PlanTicket,
|
|
21
|
+
planTicketsOf,
|
|
21
22
|
readPlanReview,
|
|
22
23
|
planWaves,
|
|
23
|
-
type IntegrationBranch
|
|
24
|
-
type PlanTicket
|
|
24
|
+
type IntegrationBranch
|
|
25
25
|
} from '@kitman-sh/sdk/loop'
|
|
26
26
|
import * as Effect from 'effect/Effect'
|
|
27
27
|
import * as Schema from 'effect/Schema'
|
|
28
28
|
import build from './build'
|
|
29
|
+
import {
|
|
30
|
+
DeclinedConcern,
|
|
31
|
+
disputedText,
|
|
32
|
+
outOfScopeText,
|
|
33
|
+
reviewPlan,
|
|
34
|
+
ticketText,
|
|
35
|
+
type DisputedConcern
|
|
36
|
+
} from './plan-review'
|
|
29
37
|
|
|
30
38
|
const Input = Schema.Struct({
|
|
31
39
|
/** What to plan. */
|
|
@@ -40,11 +48,19 @@ const Input = Schema.Struct({
|
|
|
40
48
|
implement: Schema.optional(Schema.Boolean)
|
|
41
49
|
})
|
|
42
50
|
|
|
51
|
+
const ScopedTickets = planTicketsOf(
|
|
52
|
+
Schema.Struct({
|
|
53
|
+
...PlanTicket.fields,
|
|
54
|
+
promise: Schema.String.check(Schema.isPattern(/\S/)),
|
|
55
|
+
outOfScope: Schema.Array(Schema.String)
|
|
56
|
+
})
|
|
57
|
+
)
|
|
58
|
+
|
|
43
59
|
const Plan = Schema.Struct({
|
|
44
60
|
title: Schema.String,
|
|
45
61
|
/** The spec, as Markdown. */
|
|
46
62
|
spec: Schema.String,
|
|
47
|
-
tickets:
|
|
63
|
+
tickets: ScopedTickets,
|
|
48
64
|
/** What the plan leaves out; each becomes a constraint on the Builds of its tickets. */
|
|
49
65
|
outOfScope: Schema.Array(Schema.String),
|
|
50
66
|
/** Outcomes only visible after merge (adoption, a metric moving); never a ticket's criterion. */
|
|
@@ -62,6 +78,18 @@ const Revised = Schema.Struct({
|
|
|
62
78
|
declined: Schema.Array(PlanDeclined)
|
|
63
79
|
})
|
|
64
80
|
|
|
81
|
+
const { docs: _docs, ...reworkedPlan } = Plan.fields
|
|
82
|
+
|
|
83
|
+
/** A revision the planner wrote from a plan review. */
|
|
84
|
+
const Reworked = Schema.Struct({ ...reworkedPlan, declined: Schema.Array(DeclinedConcern) })
|
|
85
|
+
|
|
86
|
+
/** A revision the planner wrote from a plan review, of a plan that answers a person's review. */
|
|
87
|
+
const ReworkedAnswer = Schema.Struct({
|
|
88
|
+
...Reworked.fields,
|
|
89
|
+
/** The person's comments this revision answers and those it does not, in place of the earlier ones. */
|
|
90
|
+
comments: Schema.Struct({ addressed: Schema.Array(PlanAddressed), declined: Schema.Array(PlanDeclined) })
|
|
91
|
+
})
|
|
92
|
+
|
|
65
93
|
/** The criteria a ticket names that the base branch already meets. */
|
|
66
94
|
const CriteriaCheck = Schema.Struct({
|
|
67
95
|
alreadyMet: Schema.Array(Schema.Struct({ key: Schema.String, criterion: Schema.String }))
|
|
@@ -69,8 +97,6 @@ const CriteriaCheck = Schema.Struct({
|
|
|
69
97
|
|
|
70
98
|
const Rejected = Schema.Struct({ key: Schema.String, reason: Schema.String })
|
|
71
99
|
|
|
72
|
-
const Opinion = Schema.Struct({ summary: Schema.String, concerns: Schema.Array(Schema.String) })
|
|
73
|
-
|
|
74
100
|
const TicketResult = Schema.Struct({
|
|
75
101
|
key: Schema.String,
|
|
76
102
|
title: Schema.String,
|
|
@@ -100,19 +126,16 @@ const Output = Schema.Struct({
|
|
|
100
126
|
docs: Schema.optional(ChangeRequestResult)
|
|
101
127
|
})
|
|
102
128
|
|
|
103
|
-
const menu = ['Implement now', 'File as Tasks', '
|
|
129
|
+
const menu = ['Implement now', 'File as Tasks', 'Refine', 'Finish'] as const
|
|
104
130
|
|
|
105
131
|
type Choice = (typeof menu)[number]
|
|
106
132
|
|
|
107
133
|
/** Menu rounds before the plan is filed as Tasks for a person to pick up. */
|
|
108
134
|
const maxRounds = 6
|
|
109
135
|
|
|
110
|
-
const maxOpinionsPerPlan = 2
|
|
111
|
-
|
|
112
136
|
const menuDescriptions: Record<Choice, string> = {
|
|
113
137
|
'Implement now': 'Builds the tickets in dependency order and delivers them.',
|
|
114
138
|
'File as Tasks': 'Makes a Task of each ticket, to build later.',
|
|
115
|
-
'Second opinion': 'Another Agent reviews the plan.',
|
|
116
139
|
Refine: 'You say what to change and the planner rewrites it.',
|
|
117
140
|
Finish: 'Ends the Run with the plan as it is.'
|
|
118
141
|
}
|
|
@@ -127,6 +150,7 @@ const onFailure = ['Retry with a steer', 'Skip it and its dependents', 'Stop her
|
|
|
127
150
|
|
|
128
151
|
const ticketRules = [
|
|
129
152
|
'Each ticket is one Build: a vertical slice an agent can implement, review and deliver as one ChangeRequest. Give it a short unique key, and list in blockedBy the keys of the tickets whose code it needs; tickets never block each other in a cycle. Set repoBindingId only when it changes another repository than the plan, keep one repository per ticket, and no cycle across repositories. Set outcome to the kind of change: feature, bug, refactor, docs, migration, investigation or performance.',
|
|
153
|
+
'Give each ticket its promise: one sentence that says what is true once it is done. List in its outOfScope the cases it does not handle. Two promises are two tickets.',
|
|
130
154
|
"Each acceptance criterion is something a Build can show before its ChangeRequest: a behaviour a test or a check proves. A text search is never a criterion, nor is something the code already does. Outcomes only visible after merge go under afterMerge, not under a ticket's criteria."
|
|
131
155
|
].join('\n\n')
|
|
132
156
|
|
|
@@ -150,27 +174,12 @@ const planText = (plan: Plan) =>
|
|
|
150
174
|
...plan.tickets.map(ticketText)
|
|
151
175
|
].join('\n\n')
|
|
152
176
|
|
|
153
|
-
|
|
154
|
-
|
|
177
|
+
/** The plan as a person reads it, with what the plan reviewer still disputes. */
|
|
178
|
+
const documentText = (plan: Plan, disputed: readonly DisputedConcern[]) =>
|
|
179
|
+
[planText(plan), ...disputedText(disputed)].join('\n\n')
|
|
155
180
|
|
|
156
|
-
const
|
|
157
|
-
[
|
|
158
|
-
`### ${ticket.key}: ${ticket.title}`,
|
|
159
|
-
ticket.body,
|
|
160
|
-
...(ticket.promise === undefined ? [] : [`Promise: ${ticket.promise}`]),
|
|
161
|
-
...ticket.acceptanceCriteria.map(criterion => `- [ ] ${criterion}`),
|
|
162
|
-
...outOfScopeText(ticket),
|
|
163
|
-
...(ticket.blockedBy.length === 0 ? [] : [`Blocked by: ${ticket.blockedBy.join(', ')}`])
|
|
164
|
-
].join('\n\n')
|
|
165
|
-
|
|
166
|
-
const opinionPrompt = (plan: Plan) =>
|
|
167
|
-
[
|
|
168
|
-
'Review this plan as a second opinion. Look for missing scope, tickets too big to review, wrong blockers and risks. Change nothing.',
|
|
169
|
-
planText(plan)
|
|
170
|
-
].join('\n\n')
|
|
171
|
-
|
|
172
|
-
const refinePrompt = (plan: Plan, words: string) =>
|
|
173
|
-
[`Change the plan as the user asks: ${words}`, ticketRules, planText(plan)].join('\n\n')
|
|
181
|
+
const refinePrompt = (document: string, words: string) =>
|
|
182
|
+
[`Change the plan as the user asks: ${words}`, ticketRules, document].join('\n\n')
|
|
174
183
|
|
|
175
184
|
const commentText = (comment: PlanReview['comments'][number]) => {
|
|
176
185
|
const on =
|
|
@@ -181,12 +190,14 @@ const commentText = (comment: PlanReview['comments'][number]) => {
|
|
|
181
190
|
return `${comment.id}, ${on}\n${comment.body}`
|
|
182
191
|
}
|
|
183
192
|
|
|
184
|
-
const
|
|
193
|
+
const commentsText = (review: PlanReview) => review.comments.map(commentText).join('\n\n')
|
|
194
|
+
|
|
195
|
+
const revisePrompt = (document: string, review: PlanReview) =>
|
|
185
196
|
[
|
|
186
197
|
`A person reviewed revision ${review.revision} of the plan and requested changes. Each comment names its id, then the text it quotes and the line of the plan's Markdown below it is on, then what the person said. Revise the plan to answer each comment; list in addressed the id of each comment the new revision answers and how, in one sentence. List in declined the id of each comment you did not act on and why, in one sentence; keep that out of the plan itself.`,
|
|
187
|
-
review
|
|
198
|
+
commentsText(review),
|
|
188
199
|
ticketRules,
|
|
189
|
-
|
|
200
|
+
document
|
|
190
201
|
].join('\n\n')
|
|
191
202
|
|
|
192
203
|
const criteriaPrompt = (plan: Plan) =>
|
|
@@ -230,13 +241,6 @@ const guarded = (plan: Plan, check: typeof CriteriaCheck.Type) => {
|
|
|
230
241
|
return { plan: { ...plan, tickets }, rejected }
|
|
231
242
|
}
|
|
232
243
|
|
|
233
|
-
/** A plan revision whose criteria were checked against the base: a ticket with nothing left to do is rejected. */
|
|
234
|
-
const checked = (plan: Plan, revision: number) =>
|
|
235
|
-
Effect.map(
|
|
236
|
-
agentWork(`criteria-check:${revision}`, { agent: 'reviewer', prompt: criteriaPrompt(plan), output: CriteriaCheck }),
|
|
237
|
-
check => guarded(plan, check)
|
|
238
|
-
)
|
|
239
|
-
|
|
240
244
|
/** The review a revision answers, and which of its comments the planner says it addressed or declined. */
|
|
241
245
|
type Answered = {
|
|
242
246
|
readonly review: PlanReview
|
|
@@ -244,11 +248,71 @@ type Answered = {
|
|
|
244
248
|
readonly declined: readonly PlanDeclined[]
|
|
245
249
|
}
|
|
246
250
|
|
|
251
|
+
type Draft = { readonly plan: Plan; readonly answered?: Answered | undefined }
|
|
252
|
+
|
|
253
|
+
const answeredText = ({ addressed, declined }: Answered) =>
|
|
254
|
+
[
|
|
255
|
+
"The plan answers a person's review, whose comments are in what the person asked for. This is what the plan above did about each. Give comments the same for your revision: list in its addressed the id of each comment your revision answers and how, and in its declined the id of each it does not act on and why, each in one sentence.",
|
|
256
|
+
[
|
|
257
|
+
...addressed.map(({ comment, how }) => `Comment ${comment}, addressed: ${how}`),
|
|
258
|
+
...declined.map(({ comment, why }) => `Comment ${comment}, declined: ${why}`)
|
|
259
|
+
].join('\n')
|
|
260
|
+
].join('\n\n')
|
|
261
|
+
|
|
262
|
+
const rework = (step: string, prompt: string, answered: Answered | undefined) =>
|
|
263
|
+
answered === undefined
|
|
264
|
+
? agentWorkOnce(step, { agent: 'planner', prompt: [prompt, ticketRules].join('\n\n'), output: Reworked }).pipe(
|
|
265
|
+
Effect.map(({ declined, ...plan }) => ({ plan: { plan }, declined }))
|
|
266
|
+
)
|
|
267
|
+
: agentWorkOnce(step, {
|
|
268
|
+
agent: 'planner',
|
|
269
|
+
prompt: [prompt, ticketRules, answeredText(answered)].join('\n\n'),
|
|
270
|
+
output: ReworkedAnswer
|
|
271
|
+
}).pipe(
|
|
272
|
+
Effect.map(({ declined, comments, ...plan }) => ({
|
|
273
|
+
plan: { plan, answered: { review: answered.review, ...comments } },
|
|
274
|
+
declined
|
|
275
|
+
}))
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* A plan revision ready for a person: the plan reviewer checked it, the planner answered its concerns, and its criteria
|
|
280
|
+
* were checked against the base, which rejects a ticket with nothing left to do.
|
|
281
|
+
*/
|
|
282
|
+
const checked = (draft: Draft, revision: number, asked: readonly string[]) =>
|
|
283
|
+
Effect.gen(function* () {
|
|
284
|
+
const reviewed = yield* reviewPlan(`plan-review:${revision}`, {
|
|
285
|
+
plan: draft,
|
|
286
|
+
asked: asked.join('\n\n'),
|
|
287
|
+
text: ({ plan }) => planText(plan),
|
|
288
|
+
revise: (step, prompt) => rework(step, prompt, draft.answered)
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
const check = yield* agentWork(`criteria-check:${revision}`, {
|
|
292
|
+
agent: 'reviewer',
|
|
293
|
+
prompt: criteriaPrompt(reviewed.plan.plan),
|
|
294
|
+
output: CriteriaCheck
|
|
295
|
+
})
|
|
296
|
+
|
|
297
|
+
const { plan, rejected } = guarded(reviewed.plan.plan, check)
|
|
298
|
+
|
|
299
|
+
return {
|
|
300
|
+
plan,
|
|
301
|
+
rejected,
|
|
302
|
+
answered: reviewed.plan.answered,
|
|
303
|
+
disputed: reviewed.disputed.filter(entry => !rejected.some(({ key }) => key === entry.ticket))
|
|
304
|
+
}
|
|
305
|
+
})
|
|
306
|
+
|
|
247
307
|
/**
|
|
248
308
|
* A revision of the plan, as Run artifacts later Runs retrieve, and as the whole document a person reviews with the
|
|
249
309
|
* review it answers.
|
|
250
310
|
*/
|
|
251
|
-
const storePlan = (
|
|
311
|
+
const storePlan = (
|
|
312
|
+
{ plan, disputed, answered }: Draft & { readonly disputed: readonly DisputedConcern[] },
|
|
313
|
+
suffix: string,
|
|
314
|
+
revision: number
|
|
315
|
+
) =>
|
|
252
316
|
Effect.gen(function* () {
|
|
253
317
|
yield* artifact(`spec${suffix}`, {
|
|
254
318
|
kind: 'plan_spec',
|
|
@@ -260,12 +324,11 @@ const storePlan = (plan: Plan, suffix: string, revision: number, answered?: Answ
|
|
|
260
324
|
kind: 'plan_tickets',
|
|
261
325
|
title: `Tickets for ${plan.title}`,
|
|
262
326
|
text: plan.tickets.map(ticketText).join('\n\n'),
|
|
263
|
-
data: plan.tickets.map(({ repoBindingId, outcome,
|
|
327
|
+
data: plan.tickets.map(({ repoBindingId, outcome, ...ticket }) => ({
|
|
264
328
|
...ticket,
|
|
265
329
|
acceptanceCriteria: [...ticket.acceptanceCriteria],
|
|
266
330
|
blockedBy: [...ticket.blockedBy],
|
|
267
|
-
|
|
268
|
-
...(outOfScope === undefined ? undefined : { outOfScope: [...outOfScope] }),
|
|
331
|
+
outOfScope: [...ticket.outOfScope],
|
|
269
332
|
...(repoBindingId === undefined ? undefined : { repoBindingId }),
|
|
270
333
|
...(outcome === undefined ? undefined : { outcome })
|
|
271
334
|
}))
|
|
@@ -273,7 +336,7 @@ const storePlan = (plan: Plan, suffix: string, revision: number, answered?: Answ
|
|
|
273
336
|
yield* artifact(`document${suffix}`, {
|
|
274
337
|
kind: 'plan_document',
|
|
275
338
|
title: plan.title,
|
|
276
|
-
text:
|
|
339
|
+
text: documentText(plan, disputed),
|
|
277
340
|
data: {
|
|
278
341
|
revision,
|
|
279
342
|
...(answered === undefined
|
|
@@ -606,20 +669,20 @@ const implement = (input: typeof Input.Type, plan: Plan, revision: number, filed
|
|
|
606
669
|
|
|
607
670
|
/**
|
|
608
671
|
* Plans from the goal and the code: the planner runs grill-with-docs, asking only the decisions that change the
|
|
609
|
-
* tickets, and Plan opens a docs ChangeRequest for the ADR and glossary changes it left.
|
|
610
|
-
*
|
|
611
|
-
*
|
|
612
|
-
*
|
|
613
|
-
* or finish (ADR-0051). Nobody answering the menu files it as Tasks; started with
|
|
614
|
-
* approves each revision and implements it.
|
|
672
|
+
* tickets, and Plan opens a docs ChangeRequest for the ADR and glossary changes it left. A plan reviewer checks each
|
|
673
|
+
* revision, and the planner answers its concerns once. Plan then checks each ticket's criteria against the base, stores
|
|
674
|
+
* the spec and tickets as Run artifacts, and waits for a person to approve the revision, the planner revising it from
|
|
675
|
+
* their review until they do. Then it asks what next, at most six times: build the tickets, file them as Tasks, refine
|
|
676
|
+
* the plan from the user's words, or finish (ADR-0051). Nobody answering the menu files it as Tasks; started with
|
|
677
|
+
* `implement`, nobody answering approves each revision and implements it.
|
|
615
678
|
*/
|
|
616
679
|
export default defineLoop({
|
|
617
680
|
id: 'plan',
|
|
618
|
-
version: '
|
|
681
|
+
version: '3.0.0',
|
|
619
682
|
title: 'Plan',
|
|
620
683
|
input: Input,
|
|
621
684
|
output: Output,
|
|
622
|
-
agents: { planner: 'planner', reviewer: 'reviewer' },
|
|
685
|
+
agents: { planner: 'planner', reviewer: 'reviewer', 'plan-reviewer': 'plan-reviewer' },
|
|
623
686
|
checkout: 'write',
|
|
624
687
|
// A Child Run gets no more than its parent was granted, so this covers what each ticket's Build needs too.
|
|
625
688
|
capabilities: [
|
|
@@ -650,11 +713,11 @@ export default defineLoop({
|
|
|
650
713
|
: yield* changeRequest('docs', { title: drafted.docs.title, body: drafted.docs.summary })
|
|
651
714
|
|
|
652
715
|
let revision = 1
|
|
653
|
-
|
|
716
|
+
const asked = [input.words]
|
|
717
|
+
let { plan, rejected, disputed } = yield* checked({ plan: drafted }, revision, asked)
|
|
654
718
|
let filed: Filed | undefined
|
|
655
|
-
let opinions = 0
|
|
656
719
|
|
|
657
|
-
yield* storePlan(plan, '', revision)
|
|
720
|
+
yield* storePlan({ plan, disputed }, '', revision)
|
|
658
721
|
|
|
659
722
|
const project = input.projectId === undefined ? undefined : { projectId: input.projectId }
|
|
660
723
|
|
|
@@ -698,7 +761,14 @@ export default defineLoop({
|
|
|
698
761
|
Effect.gen(function* () {
|
|
699
762
|
for (;;) {
|
|
700
763
|
const answer = yield* ask(`review:${revision}`, {
|
|
701
|
-
prompt:
|
|
764
|
+
prompt: [
|
|
765
|
+
`Review revision ${revision} of the plan "${plan.title}": approve it, or request changes by commenting on what should change.`,
|
|
766
|
+
...(disputed.length === 0
|
|
767
|
+
? []
|
|
768
|
+
: [
|
|
769
|
+
`The plan reviewer still disputes ${disputed.length} point${disputed.length === 1 ? '' : 's'}, listed at the end of the plan.`
|
|
770
|
+
])
|
|
771
|
+
].join(' '),
|
|
702
772
|
freeText: true,
|
|
703
773
|
recommended: PlanApproval,
|
|
704
774
|
recommendationReason: 'Approve it once the plan reads right; until then the Run waits for you.',
|
|
@@ -708,11 +778,11 @@ export default defineLoop({
|
|
|
708
778
|
|
|
709
779
|
if (isPlanApproval(answer)) return
|
|
710
780
|
|
|
711
|
-
const review = readPlanReview(answer, revision,
|
|
781
|
+
const review = readPlanReview(answer, revision, documentText(plan, disputed))
|
|
712
782
|
|
|
713
783
|
const revised = yield* agentWorkOnce(`revise-plan:${revision}`, {
|
|
714
784
|
agent: 'planner',
|
|
715
|
-
prompt: revisePrompt(plan, review),
|
|
785
|
+
prompt: revisePrompt(documentText(plan, disputed), review),
|
|
716
786
|
output: Revised
|
|
717
787
|
})
|
|
718
788
|
|
|
@@ -721,8 +791,12 @@ export default defineLoop({
|
|
|
721
791
|
const count = review.comments.length
|
|
722
792
|
|
|
723
793
|
revision++
|
|
724
|
-
|
|
725
|
-
|
|
794
|
+
asked.push(commentsText(review))
|
|
795
|
+
|
|
796
|
+
const ready = yield* checked({ plan: next, answered: { review, addressed, declined } }, revision, asked)
|
|
797
|
+
|
|
798
|
+
;({ plan, rejected, disputed } = ready)
|
|
799
|
+
yield* storePlan(ready, `:review-${revision}`, revision)
|
|
726
800
|
yield* artifact(`changes:review-${revision}`, {
|
|
727
801
|
kind: 'plan_changes',
|
|
728
802
|
title: `Revision ${revision} of ${plan.title}`,
|
|
@@ -735,11 +809,7 @@ export default defineLoop({
|
|
|
735
809
|
for (let round = 1; round <= maxRounds; round++) {
|
|
736
810
|
const isFiled = filed?.revision === revision
|
|
737
811
|
|
|
738
|
-
const options = menu.filter(
|
|
739
|
-
option =>
|
|
740
|
-
!(option === 'File as Tasks' && isFiled) &&
|
|
741
|
-
!(option === 'Second opinion' && opinions >= maxOpinionsPerPlan)
|
|
742
|
-
)
|
|
812
|
+
const options = menu.filter(option => !(option === 'File as Tasks' && isFiled))
|
|
743
813
|
|
|
744
814
|
const fallback: Choice = input.implement === true ? 'Implement now' : isFiled ? 'Finish' : 'File as Tasks'
|
|
745
815
|
|
|
@@ -777,24 +847,6 @@ export default defineLoop({
|
|
|
777
847
|
yield* file(`file-tasks:${round}`)
|
|
778
848
|
break
|
|
779
849
|
|
|
780
|
-
case 'Second opinion': {
|
|
781
|
-
opinions++
|
|
782
|
-
|
|
783
|
-
const opinion = yield* agentWork(`second-opinion:${round}`, {
|
|
784
|
-
agent: 'reviewer',
|
|
785
|
-
prompt: opinionPrompt(plan),
|
|
786
|
-
output: Opinion
|
|
787
|
-
})
|
|
788
|
-
|
|
789
|
-
yield* artifact(`opinion:${round}`, {
|
|
790
|
-
kind: 'plan_review',
|
|
791
|
-
title: `Second opinion on ${plan.title}`,
|
|
792
|
-
text: [opinion.summary, ...opinion.concerns.map(concern => `- ${concern}`)].join('\n\n')
|
|
793
|
-
})
|
|
794
|
-
|
|
795
|
-
break
|
|
796
|
-
}
|
|
797
|
-
|
|
798
850
|
case 'Refine': {
|
|
799
851
|
const words = yield* ask(`refine:${round}`, {
|
|
800
852
|
prompt: 'What should change in the plan?',
|
|
@@ -805,15 +857,16 @@ export default defineLoop({
|
|
|
805
857
|
|
|
806
858
|
const refined = yield* agentWorkOnce(`refine-plan:${round}`, {
|
|
807
859
|
agent: 'planner',
|
|
808
|
-
prompt: refinePrompt(plan, words),
|
|
860
|
+
prompt: refinePrompt(documentText(plan, disputed), words),
|
|
809
861
|
output: Plan
|
|
810
862
|
})
|
|
811
863
|
|
|
812
864
|
const before = plan
|
|
813
865
|
|
|
814
866
|
revision++
|
|
815
|
-
|
|
816
|
-
yield*
|
|
867
|
+
asked.push(words)
|
|
868
|
+
;({ plan, rejected, disputed } = yield* checked({ plan: refined }, revision, asked))
|
|
869
|
+
yield* storePlan({ plan, disputed }, `:${round}`, revision)
|
|
817
870
|
yield* artifact(`changes:${round}`, {
|
|
818
871
|
kind: 'plan_changes',
|
|
819
872
|
title: `Revision ${revision} of ${plan.title}`,
|