@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.
@@ -0,0 +1,30 @@
1
+ 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.
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. Give every concern now: a plan is revised only once before a person sees it, and tickets are filed only when you have none.
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 PlanTickets = ArraySchema(PlanTicket).check(makeFilter2((tickets) => ticketsProblem(tickets) ?? true));
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)
@@ -23821,27 +23822,163 @@ What next?`,
23821
23822
  })
23822
23823
  });
23823
23824
 
23825
+ // src/plan-review.ts
23826
+ var ScopedTickets = planTicketsOf(Struct({
23827
+ ...PlanTicket.fields,
23828
+ promise: String5.check(isPattern2(/\S/)),
23829
+ outOfScope: ArraySchema(String5)
23830
+ }));
23831
+ var Concern = Struct({
23832
+ ticket: optional2(String5),
23833
+ concern: Reason
23834
+ });
23835
+ var TicketConcern = Struct({ ticket: String5, concern: Reason });
23836
+ var Check = Struct({ concerns: ArraySchema(Concern) });
23837
+ var Recheck = Struct({
23838
+ concerns: ArraySchema(Struct({
23839
+ ...Concern.fields,
23840
+ earlier: optional2(String5)
23841
+ }))
23842
+ });
23843
+ var DeclinedConcern = Struct({ concern: String5, why: Reason });
23844
+ var outOfScopeText = ({ outOfScope = [] }) => outOfScope.length === 0 ? [] : ["Out of scope:", ...outOfScope.map((item) => `- ${item}`)];
23845
+ var ticketText = (ticket) => [
23846
+ `### ${ticket.key}: ${ticket.title}`,
23847
+ ticket.body,
23848
+ ...ticket.promise === undefined ? [] : [`Promise: ${ticket.promise}`],
23849
+ ...ticket.acceptanceCriteria.map((criterion) => `- [ ] ${criterion}`),
23850
+ ...outOfScopeText(ticket),
23851
+ ...ticket.repoBindingId === undefined ? [] : [`Repository (repoBindingId): ${ticket.repoBindingId}`],
23852
+ ...ticket.outcome === undefined ? [] : [`Outcome: ${ticket.outcome}`],
23853
+ ...ticket.blockedBy.length === 0 ? [] : [`Blocked by: ${ticket.blockedBy.join(", ")}`]
23854
+ ].join(`
23855
+
23856
+ `);
23857
+ var checks = [
23858
+ "Load skills({ name: 'scope-tasks' }) from the Kitman MCP, read the code the plan is about, and check every ticket for each of these:",
23859
+ [
23860
+ "- 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.",
23861
+ "- 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.",
23862
+ "- Decisions: no design decision is left to the implementer.",
23863
+ "- Blockers: it is blocked by each ticket whose code it needs, and by no other."
23864
+ ].join(`
23865
+ `),
23866
+ "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."
23867
+ ].join(`
23868
+
23869
+ `);
23870
+ var askedText = (asked) => `What the person asked for, in turn; where two differ, the later one holds:
23871
+
23872
+ ${asked}`;
23873
+ var answeredConcern = (concern, declined = []) => {
23874
+ const why = declined.find((entry) => entry.concern === concern.id)?.why;
23875
+ return [
23876
+ `${concern.id}${concern.ticket === undefined ? "" : `, on ${concern.ticket}`}: ${concern.concern}`,
23877
+ ...why === undefined ? [] : [`The planner did not act on it: ${why}`]
23878
+ ].join(`
23879
+ `);
23880
+ };
23881
+ var checkPrompt = (asked, text) => ["Review this plan before a person is asked to approve it.", checks, askedText(asked), text].join(`
23882
+
23883
+ `);
23884
+ var ticketsPrompt = (tickets) => [
23885
+ "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.",
23886
+ checks,
23887
+ ...tickets.map(ticketText)
23888
+ ].join(`
23889
+
23890
+ `);
23891
+ var revisePrompt = (asked, text, concerns) => [
23892
+ "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.",
23893
+ concerns.map((concern) => answeredConcern(concern)).join(`
23894
+
23895
+ `),
23896
+ askedText(asked),
23897
+ text
23898
+ ].join(`
23899
+
23900
+ `);
23901
+ var recheckPrompt = (asked, text, concerns, declined) => [
23902
+ "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.",
23903
+ checks,
23904
+ "Your concerns on the plan before its revision:",
23905
+ concerns.map((concern) => answeredConcern(concern, declined)).join(`
23906
+
23907
+ `),
23908
+ askedText(asked),
23909
+ text
23910
+ ].join(`
23911
+
23912
+ `);
23913
+ var reviewPlan = (step, { plan, asked, text, revise }) => gen2(function* () {
23914
+ const first = yield* agentWork(step, {
23915
+ agent: "plan-reviewer",
23916
+ prompt: checkPrompt(asked, text(plan)),
23917
+ output: Check
23918
+ });
23919
+ if (first.concerns.length === 0)
23920
+ return { plan, disputed: [] };
23921
+ const concerns = first.concerns.map((concern, index) => ({ ...concern, id: `c${index + 1}` }));
23922
+ const revised = yield* revise(`${step}:revise`, revisePrompt(asked, text(plan), concerns));
23923
+ const again = yield* agentWork(`${step}:recheck`, {
23924
+ agent: "plan-reviewer",
23925
+ prompt: recheckPrompt(asked, text(revised.plan), concerns, revised.declined),
23926
+ output: Recheck
23927
+ });
23928
+ const disputed = again.concerns.map(({ earlier, ...concern }) => {
23929
+ const declined = revised.declined.find((entry) => entry.concern === earlier)?.why;
23930
+ return declined === undefined ? concern : { ...concern, declined };
23931
+ });
23932
+ return { plan: revised.plan, disputed };
23933
+ });
23934
+ var reviewTickets = (step, tickets) => agentWork(step, {
23935
+ agent: "plan-reviewer",
23936
+ prompt: ticketsPrompt(tickets),
23937
+ output: Struct({
23938
+ concerns: ArraySchema(Struct({ ...TicketConcern.fields, ticket: Literals(tickets.map(({ key }) => key)) }))
23939
+ })
23940
+ }).pipe(map8(({ concerns }) => concerns));
23941
+ var oneLine = (text) => text.replace(/\s+/gu, " ").trim();
23942
+ var disputedText = (disputed) => disputed.length === 0 ? [] : [
23943
+ "## Still disputed",
23944
+ disputed.flatMap(({ ticket, concern, declined }) => [
23945
+ `- ${ticket === undefined ? "" : `${ticket}: `}${oneLine(concern)}`,
23946
+ ...declined === undefined ? [] : [` - The planner did not act on it: ${oneLine(declined)}`]
23947
+ ]).join(`
23948
+ `)
23949
+ ];
23950
+
23824
23951
  // src/file-tasks.ts
23825
23952
  var FileTasksInput = Struct({
23826
- tickets: PlanTickets,
23827
- projectId: optional2(String5)
23953
+ tickets: ScopedTickets,
23954
+ projectId: optional2(String5),
23955
+ repoBindingId: optional2(String5)
23828
23956
  });
23829
23957
  var Output5 = Struct({
23830
- tasks: ArraySchema(Struct({ key: String5, taskId: String5 }))
23958
+ tasks: ArraySchema(Struct({ key: String5, taskId: String5 })),
23959
+ concerns: ArraySchema(TicketConcern)
23831
23960
  });
23832
23961
  var file_tasks_default = defineLoop({
23833
23962
  id: "file-tasks",
23834
- version: "1.0.0",
23963
+ version: "2.0.0",
23835
23964
  title: "File Tasks",
23836
23965
  input: FileTasksInput,
23837
23966
  output: Output5,
23838
- agents: {},
23839
- checkout: "none",
23840
- capabilities: ["create_tasks"],
23841
- run: (input) => createTasks("tasks", {
23842
- tickets: input.tickets,
23843
- ...input.projectId === undefined ? undefined : { projectId: input.projectId }
23844
- }).pipe(map8(({ tasks }) => ({ tasks })))
23967
+ agents: { "plan-reviewer": "plan-reviewer" },
23968
+ checkout: "read",
23969
+ capabilities: ["agent_work", "create_tasks"],
23970
+ run: (input) => gen2(function* () {
23971
+ const { projectId, repoBindingId } = input;
23972
+ const tickets = repoBindingId === undefined ? input.tickets : input.tickets.map((ticket) => ({ ...ticket, repoBindingId: ticket.repoBindingId ?? repoBindingId }));
23973
+ const concerns = tickets.length === 0 ? [] : yield* reviewTickets("plan-review", tickets);
23974
+ if (concerns.length > 0)
23975
+ return { tasks: [], concerns };
23976
+ const { tasks } = yield* createTasks("tasks", {
23977
+ tickets,
23978
+ ...projectId === undefined ? undefined : { projectId }
23979
+ });
23980
+ return { tasks, concerns };
23981
+ })
23845
23982
  });
23846
23983
 
23847
23984
  // src/hillclimb.ts
@@ -24337,7 +24474,7 @@ var Input7 = Struct({
24337
24474
  var Plan = Struct({
24338
24475
  title: String5,
24339
24476
  spec: String5,
24340
- tickets: PlanTickets,
24477
+ tickets: ScopedTickets,
24341
24478
  outOfScope: ArraySchema(String5),
24342
24479
  afterMerge: ArraySchema(String5),
24343
24480
  docs: optional2(Struct({ title: String5, summary: String5 }))
@@ -24347,11 +24484,16 @@ var Revised = Struct({
24347
24484
  addressed: ArraySchema(PlanAddressed),
24348
24485
  declined: ArraySchema(PlanDeclined)
24349
24486
  });
24487
+ var { docs: _docs, ...reworkedPlan } = Plan.fields;
24488
+ var Reworked = Struct({ ...reworkedPlan, declined: ArraySchema(DeclinedConcern) });
24489
+ var ReworkedAnswer = Struct({
24490
+ ...Reworked.fields,
24491
+ comments: Struct({ addressed: ArraySchema(PlanAddressed), declined: ArraySchema(PlanDeclined) })
24492
+ });
24350
24493
  var CriteriaCheck = Struct({
24351
24494
  alreadyMet: ArraySchema(Struct({ key: String5, criterion: String5 }))
24352
24495
  });
24353
24496
  var Rejected = Struct({ key: String5, reason: String5 });
24354
- var Opinion = Struct({ summary: String5, concerns: ArraySchema(String5) });
24355
24497
  var TicketResult = Struct({
24356
24498
  key: String5,
24357
24499
  title: String5,
@@ -24372,13 +24514,11 @@ var Output8 = Struct({
24372
24514
  tasks: optional2(CreateTasksResult.fields.tasks),
24373
24515
  docs: optional2(ChangeRequestResult)
24374
24516
  });
24375
- var menu = ["Implement now", "File as Tasks", "Second opinion", "Refine", "Finish"];
24517
+ var menu = ["Implement now", "File as Tasks", "Refine", "Finish"];
24376
24518
  var maxRounds = 6;
24377
- var maxOpinionsPerPlan = 2;
24378
24519
  var menuDescriptions = {
24379
24520
  "Implement now": "Builds the tickets in dependency order and delivers them.",
24380
24521
  "File as Tasks": "Makes a Task of each ticket, to build later.",
24381
- "Second opinion": "Another Agent reviews the plan.",
24382
24522
  Refine: "You say what to change and the planner rewrites it.",
24383
24523
  Finish: "Ends the Run with the plan as it is."
24384
24524
  };
@@ -24387,6 +24527,7 @@ var onHeld = ["Merge again", ...onConflict];
24387
24527
  var onFailure = ["Retry with a steer", "Skip it and its dependents", "Stop here"];
24388
24528
  var ticketRules = [
24389
24529
  "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.",
24530
+ "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
24531
  "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
24532
  ].join(`
24392
24533
 
@@ -24413,24 +24554,10 @@ var planText = (plan) => [
24413
24554
  ].join(`
24414
24555
 
24415
24556
  `);
24416
- var outOfScopeText = ({ outOfScope = [] }) => outOfScope.length === 0 ? [] : ["Out of scope:", ...outOfScope.map((item) => `- ${item}`)];
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(`
24557
+ var documentText = (plan, disputed) => [planText(plan), ...disputedText(disputed)].join(`
24431
24558
 
24432
24559
  `);
24433
- var refinePrompt = (plan, words) => [`Change the plan as the user asks: ${words}`, ticketRules, planText(plan)].join(`
24560
+ var refinePrompt = (document, words) => [`Change the plan as the user asks: ${words}`, ticketRules, document].join(`
24434
24561
 
24435
24562
  `);
24436
24563
  var commentText = (comment) => {
@@ -24438,13 +24565,14 @@ var commentText = (comment) => {
24438
24565
  return `${comment.id}, ${on}
24439
24566
  ${comment.body}`;
24440
24567
  };
24441
- var revisePrompt = (plan, review) => [
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(`
24568
+ var commentsText = (review) => review.comments.map(commentText).join(`
24444
24569
 
24445
- `),
24570
+ `);
24571
+ var revisePrompt2 = (document, review) => [
24572
+ `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.`,
24573
+ commentsText(review),
24446
24574
  ticketRules,
24447
- planText(plan)
24575
+ document
24448
24576
  ].join(`
24449
24577
 
24450
24578
  `);
@@ -24468,8 +24596,51 @@ var guarded = (plan, check) => {
24468
24596
  ]);
24469
24597
  return { plan: { ...plan, tickets }, rejected };
24470
24598
  };
24471
- var checked = (plan, revision) => map8(agentWork(`criteria-check:${revision}`, { agent: "reviewer", prompt: criteriaPrompt2(plan), output: CriteriaCheck }), (check) => guarded(plan, check));
24472
- var storePlan = (plan, suffix, revision, answered) => gen2(function* () {
24599
+ var answeredText = ({ addressed, declined }) => [
24600
+ "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.",
24601
+ [
24602
+ ...addressed.map(({ comment, how }) => `Comment ${comment}, addressed: ${how}`),
24603
+ ...declined.map(({ comment, why }) => `Comment ${comment}, declined: ${why}`)
24604
+ ].join(`
24605
+ `)
24606
+ ].join(`
24607
+
24608
+ `);
24609
+ var rework = (step, prompt, answered) => answered === undefined ? agentWorkOnce(step, { agent: "planner", prompt: [prompt, ticketRules].join(`
24610
+
24611
+ `), output: Reworked }).pipe(map8(({ declined, ...plan }) => ({ plan: { plan }, declined }))) : agentWorkOnce(step, {
24612
+ agent: "planner",
24613
+ prompt: [prompt, ticketRules, answeredText(answered)].join(`
24614
+
24615
+ `),
24616
+ output: ReworkedAnswer
24617
+ }).pipe(map8(({ declined, comments, ...plan }) => ({
24618
+ plan: { plan, answered: { review: answered.review, ...comments } },
24619
+ declined
24620
+ })));
24621
+ var checked = (draft, revision, asked) => gen2(function* () {
24622
+ const reviewed = yield* reviewPlan(`plan-review:${revision}`, {
24623
+ plan: draft,
24624
+ asked: asked.join(`
24625
+
24626
+ `),
24627
+ text: ({ plan }) => planText(plan),
24628
+ revise: (step, prompt) => rework(step, prompt, draft.answered)
24629
+ });
24630
+ const check = yield* agentWork(`criteria-check:${revision}`, {
24631
+ agent: "reviewer",
24632
+ prompt: criteriaPrompt2(reviewed.plan.plan),
24633
+ output: CriteriaCheck
24634
+ });
24635
+ const { plan, rejected } = guarded(reviewed.plan.plan, check);
24636
+ return {
24637
+ plan,
24638
+ rejected,
24639
+ answered: reviewed.plan.answered,
24640
+ disputed: reviewed.disputed.filter((entry) => !rejected.some(({ key }) => key === entry.ticket))
24641
+ };
24642
+ });
24643
+ var storePlan = ({ plan, disputed, answered }, suffix, revision) => gen2(function* () {
24473
24644
  yield* artifact(`spec${suffix}`, {
24474
24645
  kind: "plan_spec",
24475
24646
  title: plan.title,
@@ -24482,12 +24653,11 @@ var storePlan = (plan, suffix, revision, answered) => gen2(function* () {
24482
24653
  text: plan.tickets.map(ticketText).join(`
24483
24654
 
24484
24655
  `),
24485
- data: plan.tickets.map(({ repoBindingId, outcome, promise, outOfScope, ...ticket }) => ({
24656
+ data: plan.tickets.map(({ repoBindingId, outcome, ...ticket }) => ({
24486
24657
  ...ticket,
24487
24658
  acceptanceCriteria: [...ticket.acceptanceCriteria],
24488
24659
  blockedBy: [...ticket.blockedBy],
24489
- ...promise === undefined ? undefined : { promise },
24490
- ...outOfScope === undefined ? undefined : { outOfScope: [...outOfScope] },
24660
+ outOfScope: [...ticket.outOfScope],
24491
24661
  ...repoBindingId === undefined ? undefined : { repoBindingId },
24492
24662
  ...outcome === undefined ? undefined : { outcome }
24493
24663
  }))
@@ -24495,7 +24665,7 @@ var storePlan = (plan, suffix, revision, answered) => gen2(function* () {
24495
24665
  yield* artifact(`document${suffix}`, {
24496
24666
  kind: "plan_document",
24497
24667
  title: plan.title,
24498
- text: planText(plan),
24668
+ text: documentText(plan, disputed),
24499
24669
  data: {
24500
24670
  revision,
24501
24671
  ...answered === undefined ? undefined : {
@@ -24722,11 +24892,11 @@ var implement = (input, plan, revision, filed) => gen2(function* () {
24722
24892
  });
24723
24893
  var plan_default = defineLoop({
24724
24894
  id: "plan",
24725
- version: "2.2.0",
24895
+ version: "3.0.0",
24726
24896
  title: "Plan",
24727
24897
  input: Input7,
24728
24898
  output: Output8,
24729
- agents: { planner: "planner", reviewer: "reviewer" },
24899
+ agents: { planner: "planner", reviewer: "reviewer", "plan-reviewer": "plan-reviewer" },
24730
24900
  checkout: "write",
24731
24901
  capabilities: [
24732
24902
  "agent_work",
@@ -24750,10 +24920,10 @@ var plan_default = defineLoop({
24750
24920
  });
24751
24921
  const docs = drafted.docs === undefined ? undefined : yield* changeRequest("docs", { title: drafted.docs.title, body: drafted.docs.summary });
24752
24922
  let revision = 1;
24753
- let { plan, rejected } = yield* checked(drafted, revision);
24923
+ const asked = [input.words];
24924
+ let { plan, rejected, disputed } = yield* checked({ plan: drafted }, revision, asked);
24754
24925
  let filed;
24755
- let opinions = 0;
24756
- yield* storePlan(plan, "", revision);
24926
+ yield* storePlan({ plan, disputed }, "", revision);
24757
24927
  const project = input.projectId === undefined ? undefined : { projectId: input.projectId };
24758
24928
  const held = new Map;
24759
24929
  let implementing = false;
@@ -24782,7 +24952,12 @@ var plan_default = defineLoop({
24782
24952
  const approve = () => gen2(function* () {
24783
24953
  for (;; ) {
24784
24954
  const answer = yield* ask(`review:${revision}`, {
24785
- prompt: `Review revision ${revision} of the plan "${plan.title}": approve it, or request changes by commenting on what should change.`,
24955
+ prompt: [
24956
+ `Review revision ${revision} of the plan "${plan.title}": approve it, or request changes by commenting on what should change.`,
24957
+ ...disputed.length === 0 ? [] : [
24958
+ `The plan reviewer still disputes ${disputed.length} point${disputed.length === 1 ? "" : "s"}, listed at the end of the plan.`
24959
+ ]
24960
+ ].join(" "),
24786
24961
  freeText: true,
24787
24962
  recommended: PlanApproval,
24788
24963
  recommendationReason: "Approve it once the plan reads right; until then the Run waits for you.",
@@ -24791,18 +24966,20 @@ var plan_default = defineLoop({
24791
24966
  });
24792
24967
  if (isPlanApproval(answer))
24793
24968
  return;
24794
- const review = readPlanReview(answer, revision, planText(plan));
24969
+ const review = readPlanReview(answer, revision, documentText(plan, disputed));
24795
24970
  const revised = yield* agentWorkOnce(`revise-plan:${revision}`, {
24796
24971
  agent: "planner",
24797
- prompt: revisePrompt(plan, review),
24972
+ prompt: revisePrompt2(documentText(plan, disputed), review),
24798
24973
  output: Revised
24799
24974
  });
24800
24975
  const { addressed, declined, ...next } = revised;
24801
24976
  const before = plan;
24802
24977
  const count = review.comments.length;
24803
24978
  revision++;
24804
- ({ plan, rejected } = yield* checked(next, revision));
24805
- yield* storePlan(plan, `:review-${revision}`, revision, { review, addressed, declined });
24979
+ asked.push(commentsText(review));
24980
+ const ready = yield* checked({ plan: next, answered: { review, addressed, declined } }, revision, asked);
24981
+ ({ plan, rejected, disputed } = ready);
24982
+ yield* storePlan(ready, `:review-${revision}`, revision);
24806
24983
  yield* artifact(`changes:review-${revision}`, {
24807
24984
  kind: "plan_changes",
24808
24985
  title: `Revision ${revision} of ${plan.title}`,
@@ -24813,7 +24990,7 @@ var plan_default = defineLoop({
24813
24990
  const decide = gen2(function* () {
24814
24991
  for (let round = 1;round <= maxRounds; round++) {
24815
24992
  const isFiled = filed?.revision === revision;
24816
- const options = menu.filter((option) => !(option === "File as Tasks" && isFiled) && !(option === "Second opinion" && opinions >= maxOpinionsPerPlan));
24993
+ const options = menu.filter((option) => !(option === "File as Tasks" && isFiled));
24817
24994
  const fallback = input.implement === true ? "Implement now" : isFiled ? "Finish" : "File as Tasks";
24818
24995
  const answer = yield* ask(`next:${round}`, {
24819
24996
  prompt: `What next for the plan "${plan.title}"?`,
@@ -24837,22 +25014,6 @@ var plan_default = defineLoop({
24837
25014
  case "File as Tasks":
24838
25015
  yield* file(`file-tasks:${round}`);
24839
25016
  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
25017
  case "Refine": {
24857
25018
  const words = yield* ask(`refine:${round}`, {
24858
25019
  prompt: "What should change in the plan?",
@@ -24862,13 +25023,14 @@ var plan_default = defineLoop({
24862
25023
  });
24863
25024
  const refined = yield* agentWorkOnce(`refine-plan:${round}`, {
24864
25025
  agent: "planner",
24865
- prompt: refinePrompt(plan, words),
25026
+ prompt: refinePrompt(documentText(plan, disputed), words),
24866
25027
  output: Plan
24867
25028
  });
24868
25029
  const before = plan;
24869
25030
  revision++;
24870
- ({ plan, rejected } = yield* checked(refined, revision));
24871
- yield* storePlan(plan, `:${round}`, revision);
25031
+ asked.push(words);
25032
+ ({ plan, rejected, disputed } = yield* checked({ plan: refined }, revision, asked));
25033
+ yield* storePlan({ plan, disputed }, `:${round}`, revision);
24872
25034
  yield* artifact(`changes:${round}`, {
24873
25035
  kind: "plan_changes",
24874
25036
  title: `Revision ${revision} of ${plan.title}`,
@@ -24969,7 +25131,7 @@ var Fix = Struct({
24969
25131
  words: String5,
24970
25132
  outcome: LoopOutcome
24971
25133
  });
24972
- var NextSteps = Struct({ tickets: PlanTickets });
25134
+ var NextSteps = Struct({ tickets: ScopedTickets });
24973
25135
  var Report = Struct({
24974
25136
  title: String5,
24975
25137
  summary: OneSentence,
@@ -25001,7 +25163,7 @@ var researchPrompt = (words) => [
25001
25163
  "If your context has an earlier research report on this, extend it: keep what still holds, check what may have changed, and answer what it left open. Do not start over.",
25002
25164
  "Cite primary sources for every finding: the code, official documentation, specifications and first-party APIs. You may run things to reproduce behaviour; change nothing in the repository. Mark each finding observed (you ran it and saw it), read (a source says so) or inferred (you concluded it).",
25003
25165
  "List every source you needed and could not reach under `unreached`, with what you tried, and lower your conclusions to what the sources you did reach show.",
25004
- "If the question turns out to be a bug report, say so in the summary and give `fix` with outcome bug. If the report proposes any other change, give `fix` with its outcome. Give next steps worth doing as `nextStepTasks` tickets too.",
25166
+ "If the question turns out to be a bug report, say so in the summary and give `fix` with outcome bug. If the report proposes any other change, give `fix` with its outcome. Give next steps worth doing as `nextStepTasks` tickets too, each scoped as skills({ name: 'scope-tasks' }) from the Kitman MCP says: its `promise` is one sentence that says what is true once it is done, and its `outOfScope` lists the cases it does not handle.",
25005
25167
  "Return the report as your Output. Do not write it into the repository."
25006
25168
  ].join(`
25007
25169
 
@@ -25067,7 +25229,7 @@ var sample = {
25067
25229
  };
25068
25230
  var research_default = defineLoop({
25069
25231
  id: "research",
25070
- version: "2.0.0",
25232
+ version: "2.1.0",
25071
25233
  title: "Research",
25072
25234
  input: Input9,
25073
25235
  output: Output10,
@@ -25168,7 +25330,7 @@ var Output11 = Struct({
25168
25330
  improvements: ArraySchema(Struct({ key: String5, loop: Literals(["errand", "build"]), outcome: String5 })),
25169
25331
  notStarted: ArraySchema(Struct({ key: String5, reason: Reason }))
25170
25332
  });
25171
- var oneLine = (text) => text.replace(/\s*\n\s*/g, " \u23CE ");
25333
+ var oneLine2 = (text) => text.replace(/\s*\n\s*/g, " \u23CE ");
25172
25334
  var rootOf = (run) => run.rootRunId ?? run.runId;
25173
25335
  var digest = (runs) => runs.flatMap((run) => [
25174
25336
  [
@@ -25178,18 +25340,18 @@ var digest = (runs) => runs.flatMap((run) => [
25178
25340
  ...rootOf(run) === run.runId ? [] : [`part of ${rootOf(run)}`],
25179
25341
  ...run.teamId === undefined ? [] : [`team ${run.teamId}`],
25180
25342
  ...run.retried === true ? ["retried"] : [],
25181
- ...run.failure === undefined ? [] : [`failure: ${oneLine(run.failure)}`],
25343
+ ...run.failure === undefined ? [] : [`failure: ${oneLine2(run.failure)}`],
25182
25344
  ...run.omitted === undefined ? [] : [`${run.omitted} entries left out`]
25183
25345
  ].join(" \xB7 "),
25184
25346
  ...run.entries.flatMap((entry, index) => [
25185
25347
  ...run.entries[index - 1]?.stepAttemptId === entry.stepAttemptId ? [] : [` attempt ${entry.stepAttemptId}`],
25186
- ` ${entry.sequence} ${entry.kind}: ${oneLine(entry.text)}`
25348
+ ` ${entry.sequence} ${entry.kind}: ${oneLine2(entry.text)}`
25187
25349
  ])
25188
25350
  ]).join(`
25189
25351
  `);
25190
25352
  var earlier = (findings) => findings.length === 0 ? "No earlier finding is open." : [
25191
25353
  "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}: ${oneLine(found.title)} (${found.taskKey === undefined ? "proposal waiting for a decision" : `open Task ${found.taskKey}`})`)
25354
+ ...findings.map((found) => `- ${found.key}: ${oneLine2(found.title)} (${found.taskKey === undefined ? "proposal waiting for a decision" : `open Task ${found.taskKey}`})`)
25193
25355
  ].join(`
25194
25356
  `);
25195
25357
  var prompt4 = (read, days) => [
@@ -25817,6 +25979,11 @@ var kitman_config_default = defineKit({
25817
25979
  extends: "reviewer",
25818
25980
  skills: ["code-review-and-quality", "security-and-hardening"]
25819
25981
  },
25982
+ "plan-reviewer": {
25983
+ extends: "reviewer",
25984
+ fallbacks: [{ harness: "claude", model: "opus", effort: "high" }],
25985
+ instructions: { file: "agents/plan-reviewer.md" }
25986
+ },
25820
25987
  planner: {
25821
25988
  harness: "claude",
25822
25989
  model: "claude-fable-5-2",
@@ -31618,4 +31785,4 @@ var runKit = (config, identity, packages) => {
31618
31785
  runMain2(program.pipe(flatMap3((code) => sync2(() => process.exit(code)))));
31619
31786
  };
31620
31787
  // .kitman-build-entry.ts
31621
- runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.13.8" }, []);
31788
+ runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.13.10" }, []);