@kitman-sh/software-engineering 0.12.12 → 0.12.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +131 -7
- package/dist/declarations.json +2 -2
- package/package.json +3 -3
- package/src/plan.ts +110 -9
- package/src/tidy.ts +1 -1
package/dist/bundle.js
CHANGED
|
@@ -9169,6 +9169,9 @@ var decodeEffect = decodeUnknownEffect;
|
|
|
9169
9169
|
function decodeUnknownExit(schema, options) {
|
|
9170
9170
|
return asExit(decodeUnknownEffect(schema, options));
|
|
9171
9171
|
}
|
|
9172
|
+
function decodeUnknownOption(schema, options) {
|
|
9173
|
+
return asOption(decodeUnknownEffect(schema, options));
|
|
9174
|
+
}
|
|
9172
9175
|
function encodeUnknownEffect(schema, options) {
|
|
9173
9176
|
const parser = run(flip2(schema.ast));
|
|
9174
9177
|
return options === undefined ? parser : (input, overrideOptions) => parser(input, mergeParseOptions(options, overrideOptions));
|
|
@@ -9211,6 +9214,17 @@ function runWithCompiler(compiler, ast) {
|
|
|
9211
9214
|
function asExit(parser) {
|
|
9212
9215
|
return (input, options) => runSyncExit2(parser(input, options));
|
|
9213
9216
|
}
|
|
9217
|
+
function asOption(parser) {
|
|
9218
|
+
const parserExit = asExit(parser);
|
|
9219
|
+
return (input, options) => {
|
|
9220
|
+
const exit = parserExit(input, options);
|
|
9221
|
+
if (isSuccess3(exit)) {
|
|
9222
|
+
return some2(exit.value);
|
|
9223
|
+
}
|
|
9224
|
+
getSchemaIssueOrThrow(exit.cause, "Option adapter can only return none for schema issues");
|
|
9225
|
+
return none2();
|
|
9226
|
+
};
|
|
9227
|
+
}
|
|
9214
9228
|
function runSync3(effect, message) {
|
|
9215
9229
|
const exit = runSyncExit2(effect);
|
|
9216
9230
|
if (isSuccess3(exit)) {
|
|
@@ -11018,6 +11032,7 @@ function decodeUnknownExit2(schema, options) {
|
|
|
11018
11032
|
return fromIssueExit(parser(input, options));
|
|
11019
11033
|
};
|
|
11020
11034
|
}
|
|
11035
|
+
var decodeUnknownOption2 = decodeUnknownOption;
|
|
11021
11036
|
function decodeUnknownSync(schema, options) {
|
|
11022
11037
|
const parser = decodeUnknownEffect2(schema, options);
|
|
11023
11038
|
return (input, options) => {
|
|
@@ -13640,7 +13655,8 @@ var LoopForbiddenDataflowKeyRegExp = new RegExp(LoopForbiddenDataflowKeyPattern)
|
|
|
13640
13655
|
var LoopForbiddenContentRegExp = new RegExp(LoopReferenceAndUrlForbiddenContentPattern);
|
|
13641
13656
|
var LoopSafeReferenceString = String5.check(isMinLength(1), isMaxLength(240), isPattern2(new RegExp(LoopSafeReferencePattern, "u")));
|
|
13642
13657
|
var LoopSafeInternalReferenceString = String5.check(isMinLength(1), isMaxLength(240), isPattern2(new RegExp(LoopSafeInternalReferencePattern, "u")));
|
|
13643
|
-
var
|
|
13658
|
+
var loopSafeTextMaxLength = 4000;
|
|
13659
|
+
var LoopSafeText = String5.check(isMaxLength(loopSafeTextMaxLength), isPattern2(new RegExp(`^(?![\\s\\S]*(?:${LoopCredentialContentPattern}|[A-Za-z][A-Za-z0-9+.-]*://(?:[^\\s/?#]*@|[^\\s?#]*\\?)))[\\s\\S]*$`, "u")));
|
|
13644
13660
|
var recommendedDefault = (recommended) => recommended !== undefined && is2(LoopSafeText)(recommended) ? recommended : undefined;
|
|
13645
13661
|
var unansweredQuestionLead = "Nobody answers in full auto, and the agent's Question has no answer to take";
|
|
13646
13662
|
var isUnansweredQuestion = (reason) => reason.startsWith(unansweredQuestionLead);
|
|
@@ -20991,6 +21007,45 @@ var continuingBrief = (continuing) => [
|
|
|
20991
21007
|
"The ChangeRequest's description lists what was left unsettled; settle those first."
|
|
20992
21008
|
].join(`
|
|
20993
21009
|
`);
|
|
21010
|
+
// ../../packages/core/src/plan-review.ts
|
|
21011
|
+
var PlanApproval = "Approve plan";
|
|
21012
|
+
var Offset = Int.check(isGreaterThanOrEqualTo2(0));
|
|
21013
|
+
var PlanReviewComment = Struct({
|
|
21014
|
+
id: String5,
|
|
21015
|
+
body: String5,
|
|
21016
|
+
quote: optionalKey2(String5),
|
|
21017
|
+
line: optionalKey2(Int.check(isGreaterThanOrEqualTo2(1))),
|
|
21018
|
+
start: optionalKey2(Offset),
|
|
21019
|
+
end: optionalKey2(Offset),
|
|
21020
|
+
from: optionalKey2(Offset),
|
|
21021
|
+
to: optionalKey2(Offset)
|
|
21022
|
+
});
|
|
21023
|
+
var PlanReview = Struct({
|
|
21024
|
+
revision: Int.check(isGreaterThanOrEqualTo2(1)),
|
|
21025
|
+
comments: ArraySchema(PlanReviewComment)
|
|
21026
|
+
});
|
|
21027
|
+
var PlanAddressed = Struct({ comment: String5, how: String5 });
|
|
21028
|
+
var PlanDeclined = Struct({ comment: String5, why: String5 });
|
|
21029
|
+
var lineAt = (text, offset) => text.slice(0, offset).split(`
|
|
21030
|
+
`).length;
|
|
21031
|
+
var PlanReviewAnswer = fromJsonString2(Struct({ planReview: PlanReview }));
|
|
21032
|
+
var decodeAnswer = decodeUnknownOption2(PlanReviewAnswer);
|
|
21033
|
+
var encodeAnswer = encodeSync(PlanReviewAnswer);
|
|
21034
|
+
var isPlanApproval = (answer) => answer.trim().toLowerCase() === PlanApproval.toLowerCase();
|
|
21035
|
+
var placed = (comment, markdown) => {
|
|
21036
|
+
const { from, to } = comment;
|
|
21037
|
+
if (from === undefined || to === undefined || from >= to || to > markdown.length) {
|
|
21038
|
+
const { from: _from, to: _to, ...rest } = comment;
|
|
21039
|
+
return rest;
|
|
21040
|
+
}
|
|
21041
|
+
return { ...comment, quote: markdown.slice(from, to), line: lineAt(markdown, from) };
|
|
21042
|
+
};
|
|
21043
|
+
var readPlanReview = (answer, revision, markdown) => {
|
|
21044
|
+
const decoded = decodeAnswer(answer);
|
|
21045
|
+
if (decoded._tag === "None" || decoded.value.planReview.revision !== revision || decoded.value.planReview.comments.length === 0)
|
|
21046
|
+
return { revision, comments: [{ id: "words", body: answer.trim() }] };
|
|
21047
|
+
return { revision, comments: decoded.value.planReview.comments.map((comment) => placed(comment, markdown)) };
|
|
21048
|
+
};
|
|
20994
21049
|
// src/change-request-body.ts
|
|
20995
21050
|
var scopeFindings = (scope) => (scope?.unmet ?? []).map((item) => ({
|
|
20996
21051
|
id: `scope: ${item}`,
|
|
@@ -24134,6 +24189,11 @@ var Plan = Struct({
|
|
|
24134
24189
|
afterMerge: ArraySchema(String5),
|
|
24135
24190
|
docs: optional2(Struct({ title: String5, summary: String5 }))
|
|
24136
24191
|
});
|
|
24192
|
+
var Revised = Struct({
|
|
24193
|
+
...Plan.fields,
|
|
24194
|
+
addressed: ArraySchema(PlanAddressed),
|
|
24195
|
+
declined: ArraySchema(PlanDeclined)
|
|
24196
|
+
});
|
|
24137
24197
|
var CriteriaCheck = Struct({
|
|
24138
24198
|
alreadyMet: ArraySchema(Struct({ key: String5, criterion: String5 }))
|
|
24139
24199
|
});
|
|
@@ -24216,6 +24276,21 @@ var opinionPrompt = (plan) => [
|
|
|
24216
24276
|
`);
|
|
24217
24277
|
var refinePrompt = (plan, words) => [`Change the plan as the user asks: ${words}`, ticketRules, planText(plan)].join(`
|
|
24218
24278
|
|
|
24279
|
+
`);
|
|
24280
|
+
var commentText = (comment) => {
|
|
24281
|
+
const on = comment.quote === undefined ? "on the whole plan" : `on ${comment.line === undefined ? "" : `line ${comment.line}: `}"${comment.quote}"`;
|
|
24282
|
+
return `${comment.id}, ${on}
|
|
24283
|
+
${comment.body}`;
|
|
24284
|
+
};
|
|
24285
|
+
var revisePrompt = (plan, review) => [
|
|
24286
|
+
`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.`,
|
|
24287
|
+
review.comments.map(commentText).join(`
|
|
24288
|
+
|
|
24289
|
+
`),
|
|
24290
|
+
ticketRules,
|
|
24291
|
+
planText(plan)
|
|
24292
|
+
].join(`
|
|
24293
|
+
|
|
24219
24294
|
`);
|
|
24220
24295
|
var criteriaPrompt2 = (plan) => [
|
|
24221
24296
|
"Check each ticket's acceptance criteria against the base branch as it is now. List under alreadyMet each criterion the code already meets, with its ticket's key and the criterion word for word. Change nothing.",
|
|
@@ -24238,7 +24313,7 @@ var guarded = (plan, check) => {
|
|
|
24238
24313
|
return { plan: { ...plan, tickets }, rejected };
|
|
24239
24314
|
};
|
|
24240
24315
|
var checked = (plan, revision) => map8(agentWork(`criteria-check:${revision}`, { agent: "reviewer", prompt: criteriaPrompt2(plan), output: CriteriaCheck }), (check) => guarded(plan, check));
|
|
24241
|
-
var storePlan = (plan, suffix) => gen2(function* () {
|
|
24316
|
+
var storePlan = (plan, suffix, revision, answered) => gen2(function* () {
|
|
24242
24317
|
yield* artifact(`spec${suffix}`, {
|
|
24243
24318
|
kind: "plan_spec",
|
|
24244
24319
|
title: plan.title,
|
|
@@ -24259,6 +24334,22 @@ var storePlan = (plan, suffix) => gen2(function* () {
|
|
|
24259
24334
|
...outcome === undefined ? undefined : { outcome }
|
|
24260
24335
|
}))
|
|
24261
24336
|
});
|
|
24337
|
+
yield* artifact(`document${suffix}`, {
|
|
24338
|
+
kind: "plan_document",
|
|
24339
|
+
title: plan.title,
|
|
24340
|
+
text: planText(plan),
|
|
24341
|
+
data: {
|
|
24342
|
+
revision,
|
|
24343
|
+
...answered === undefined ? undefined : {
|
|
24344
|
+
review: {
|
|
24345
|
+
revision: answered.review.revision,
|
|
24346
|
+
comments: answered.review.comments.map((comment) => ({ ...comment }))
|
|
24347
|
+
},
|
|
24348
|
+
addressed: answered.addressed.map((entry) => ({ ...entry })),
|
|
24349
|
+
declined: answered.declined.map((entry) => ({ ...entry }))
|
|
24350
|
+
}
|
|
24351
|
+
}
|
|
24352
|
+
});
|
|
24262
24353
|
});
|
|
24263
24354
|
var changelog = (before, after, words) => {
|
|
24264
24355
|
const was = new Map(before.tickets.map((ticket) => [ticket.key, ticketText(ticket)]));
|
|
@@ -24471,7 +24562,7 @@ var implement = (input, plan, revision, filed) => gen2(function* () {
|
|
|
24471
24562
|
});
|
|
24472
24563
|
var plan_default = defineLoop({
|
|
24473
24564
|
id: "plan",
|
|
24474
|
-
version: "2.
|
|
24565
|
+
version: "2.2.0",
|
|
24475
24566
|
title: "Plan",
|
|
24476
24567
|
input: Input7,
|
|
24477
24568
|
output: Output8,
|
|
@@ -24502,7 +24593,7 @@ var plan_default = defineLoop({
|
|
|
24502
24593
|
let { plan, rejected } = yield* checked(drafted, revision);
|
|
24503
24594
|
let filed;
|
|
24504
24595
|
let opinions = 0;
|
|
24505
|
-
yield* storePlan(plan, "");
|
|
24596
|
+
yield* storePlan(plan, "", revision);
|
|
24506
24597
|
const project = input.projectId === undefined ? undefined : { projectId: input.projectId };
|
|
24507
24598
|
const held = new Map;
|
|
24508
24599
|
let implementing = false;
|
|
@@ -24528,6 +24619,37 @@ var plan_default = defineLoop({
|
|
|
24528
24619
|
...docs === undefined ? undefined : { docs },
|
|
24529
24620
|
...rest
|
|
24530
24621
|
});
|
|
24622
|
+
const approve = () => gen2(function* () {
|
|
24623
|
+
for (;; ) {
|
|
24624
|
+
const answer = yield* ask(`review:${revision}`, {
|
|
24625
|
+
prompt: `Review revision ${revision} of the plan "${plan.title}": approve it, or request changes by commenting on what should change.`,
|
|
24626
|
+
freeText: true,
|
|
24627
|
+
recommended: PlanApproval,
|
|
24628
|
+
recommendationReason: "Approve it once the plan reads right; until then the Run waits for you.",
|
|
24629
|
+
...input.implement === true ? { default: PlanApproval, timeout: "1 hour" } : { default: null },
|
|
24630
|
+
unattendedAuto: PlanApproval
|
|
24631
|
+
});
|
|
24632
|
+
if (isPlanApproval(answer))
|
|
24633
|
+
return;
|
|
24634
|
+
const review = readPlanReview(answer, revision, planText(plan));
|
|
24635
|
+
const revised = yield* agentWorkOnce(`revise-plan:${revision}`, {
|
|
24636
|
+
agent: "planner",
|
|
24637
|
+
prompt: revisePrompt(plan, review),
|
|
24638
|
+
output: Revised
|
|
24639
|
+
});
|
|
24640
|
+
const { addressed, declined, ...next } = revised;
|
|
24641
|
+
const before = plan;
|
|
24642
|
+
const count = review.comments.length;
|
|
24643
|
+
revision++;
|
|
24644
|
+
({ plan, rejected } = yield* checked(next, revision));
|
|
24645
|
+
yield* storePlan(plan, `:review-${revision}`, revision, { review, addressed, declined });
|
|
24646
|
+
yield* artifact(`changes:review-${revision}`, {
|
|
24647
|
+
kind: "plan_changes",
|
|
24648
|
+
title: `Revision ${revision} of ${plan.title}`,
|
|
24649
|
+
text: changelog(before, plan, `${count} review comment${count === 1 ? "" : "s"}`)
|
|
24650
|
+
});
|
|
24651
|
+
}
|
|
24652
|
+
});
|
|
24531
24653
|
const decide = gen2(function* () {
|
|
24532
24654
|
for (let round = 1;round <= maxRounds; round++) {
|
|
24533
24655
|
const isFiled = filed?.revision === revision;
|
|
@@ -24586,12 +24708,13 @@ var plan_default = defineLoop({
|
|
|
24586
24708
|
const before = plan;
|
|
24587
24709
|
revision++;
|
|
24588
24710
|
({ plan, rejected } = yield* checked(refined, revision));
|
|
24589
|
-
yield* storePlan(plan, `:${round}
|
|
24711
|
+
yield* storePlan(plan, `:${round}`, revision);
|
|
24590
24712
|
yield* artifact(`changes:${round}`, {
|
|
24591
24713
|
kind: "plan_changes",
|
|
24592
24714
|
title: `Revision ${revision} of ${plan.title}`,
|
|
24593
24715
|
text: changelog(before, plan, words)
|
|
24594
24716
|
});
|
|
24717
|
+
yield* approve();
|
|
24595
24718
|
break;
|
|
24596
24719
|
}
|
|
24597
24720
|
}
|
|
@@ -24604,6 +24727,7 @@ var plan_default = defineLoop({
|
|
|
24604
24727
|
stopped: `No decision after ${maxRounds} rounds, so the tickets are filed as Tasks for a person to pick up`
|
|
24605
24728
|
});
|
|
24606
24729
|
});
|
|
24730
|
+
yield* approve();
|
|
24607
24731
|
return yield* decide.pipe(tapError2(() => implementing ? void_3 : ignore2(release())));
|
|
24608
24732
|
})
|
|
24609
24733
|
});
|
|
@@ -25454,7 +25578,7 @@ var tidy_default = defineLoop({
|
|
|
25454
25578
|
|
|
25455
25579
|
What next?`,
|
|
25456
25580
|
options: [
|
|
25457
|
-
{ value: "Plan it", description: "Plan
|
|
25581
|
+
{ value: "Plan it", description: "Plan plans the candidates for you to review, then files them as Tasks." },
|
|
25458
25582
|
{ value: "Tidy the top one now", description: "An agent makes the top one and opens a ChangeRequest." },
|
|
25459
25583
|
{ value: "Done", description: "Keep the report and stop." }
|
|
25460
25584
|
],
|
|
@@ -31328,4 +31452,4 @@ var runKit = (config, identity, packages) => {
|
|
|
31328
31452
|
runMain2(program.pipe(flatMap3((code) => sync2(() => process.exit(code)))));
|
|
31329
31453
|
};
|
|
31330
31454
|
// .kitman-build-entry.ts
|
|
31331
|
-
runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.12.
|
|
31455
|
+
runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.12.14" }, []);
|
package/dist/declarations.json
CHANGED
|
@@ -1659,7 +1659,7 @@
|
|
|
1659
1659
|
{
|
|
1660
1660
|
"id": "plan",
|
|
1661
1661
|
"title": "Plan",
|
|
1662
|
-
"version": "2.
|
|
1662
|
+
"version": "2.2.0",
|
|
1663
1663
|
"input": {
|
|
1664
1664
|
"type": "object",
|
|
1665
1665
|
"properties": {
|
|
@@ -5522,7 +5522,7 @@
|
|
|
5522
5522
|
"carried": [
|
|
5523
5523
|
{
|
|
5524
5524
|
"name": "@kitman-sh/software-engineering",
|
|
5525
|
-
"version": "0.12.
|
|
5525
|
+
"version": "0.12.14",
|
|
5526
5526
|
"setup": "2a237548a69b0cd53ec3be7f687cfa8c2128335b3a655d34e185f2abce6a3c37",
|
|
5527
5527
|
"loops": [
|
|
5528
5528
|
"build",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitman-sh/software-engineering",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.14",
|
|
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.12.
|
|
20
|
+
"@kitman-sh/sdk": "0.12.14",
|
|
21
21
|
"effect": "^4.1.2"
|
|
22
22
|
},
|
|
23
23
|
"kitman": {
|
|
24
24
|
"bundle": "dist/bundle.js",
|
|
25
|
-
"digest": "
|
|
25
|
+
"digest": "93d7bc5f7542d9c0a2f08fbee759032376ca51da71b9dbf9595f136326d9598f",
|
|
26
26
|
"protocolVersion": 5,
|
|
27
27
|
"declarations": "dist/declarations.json",
|
|
28
28
|
"setup": {
|
package/src/plan.ts
CHANGED
|
@@ -11,8 +11,14 @@ import {
|
|
|
11
11
|
CreateTasksResult,
|
|
12
12
|
defineLoop,
|
|
13
13
|
integrationBranch,
|
|
14
|
+
isPlanApproval,
|
|
14
15
|
mergeChangeRequest,
|
|
16
|
+
PlanAddressed,
|
|
17
|
+
PlanApproval,
|
|
18
|
+
PlanDeclined,
|
|
19
|
+
type PlanReview,
|
|
15
20
|
PlanTickets,
|
|
21
|
+
readPlanReview,
|
|
16
22
|
planWaves,
|
|
17
23
|
type IntegrationBranch,
|
|
18
24
|
type PlanTicket
|
|
@@ -30,7 +36,7 @@ const Input = Schema.Struct({
|
|
|
30
36
|
branch: Schema.optional(Schema.String),
|
|
31
37
|
/** The Project the plan's Tasks land in. */
|
|
32
38
|
projectId: Schema.optional(Schema.String),
|
|
33
|
-
/**
|
|
39
|
+
/** Approves each revision and implements it when nobody answers within an hour; files it as Tasks otherwise. */
|
|
34
40
|
implement: Schema.optional(Schema.Boolean)
|
|
35
41
|
})
|
|
36
42
|
|
|
@@ -49,6 +55,13 @@ const Plan = Schema.Struct({
|
|
|
49
55
|
|
|
50
56
|
type Plan = typeof Plan.Type
|
|
51
57
|
|
|
58
|
+
/** A revision the planner wrote from a review, with the comments it answered and those it did not act on. */
|
|
59
|
+
const Revised = Schema.Struct({
|
|
60
|
+
...Plan.fields,
|
|
61
|
+
addressed: Schema.Array(PlanAddressed),
|
|
62
|
+
declined: Schema.Array(PlanDeclined)
|
|
63
|
+
})
|
|
64
|
+
|
|
52
65
|
/** The criteria a ticket names that the base branch already meets. */
|
|
53
66
|
const CriteriaCheck = Schema.Struct({
|
|
54
67
|
alreadyMet: Schema.Array(Schema.Struct({ key: Schema.String, criterion: Schema.String }))
|
|
@@ -154,6 +167,23 @@ const opinionPrompt = (plan: Plan) =>
|
|
|
154
167
|
const refinePrompt = (plan: Plan, words: string) =>
|
|
155
168
|
[`Change the plan as the user asks: ${words}`, ticketRules, planText(plan)].join('\n\n')
|
|
156
169
|
|
|
170
|
+
const commentText = (comment: PlanReview['comments'][number]) => {
|
|
171
|
+
const on =
|
|
172
|
+
comment.quote === undefined
|
|
173
|
+
? 'on the whole plan'
|
|
174
|
+
: `on ${comment.line === undefined ? '' : `line ${comment.line}: `}"${comment.quote}"`
|
|
175
|
+
|
|
176
|
+
return `${comment.id}, ${on}\n${comment.body}`
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const revisePrompt = (plan: Plan, review: PlanReview) =>
|
|
180
|
+
[
|
|
181
|
+
`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.`,
|
|
182
|
+
review.comments.map(commentText).join('\n\n'),
|
|
183
|
+
ticketRules,
|
|
184
|
+
planText(plan)
|
|
185
|
+
].join('\n\n')
|
|
186
|
+
|
|
157
187
|
const criteriaPrompt = (plan: Plan) =>
|
|
158
188
|
[
|
|
159
189
|
"Check each ticket's acceptance criteria against the base branch as it is now. List under alreadyMet each criterion the code already meets, with its ticket's key and the criterion word for word. Change nothing.",
|
|
@@ -202,8 +232,18 @@ const checked = (plan: Plan, revision: number) =>
|
|
|
202
232
|
check => guarded(plan, check)
|
|
203
233
|
)
|
|
204
234
|
|
|
205
|
-
/**
|
|
206
|
-
|
|
235
|
+
/** The review a revision answers, and which of its comments the planner says it addressed or declined. */
|
|
236
|
+
type Answered = {
|
|
237
|
+
readonly review: PlanReview
|
|
238
|
+
readonly addressed: readonly PlanAddressed[]
|
|
239
|
+
readonly declined: readonly PlanDeclined[]
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* A revision of the plan, as Run artifacts later Runs retrieve, and as the whole document a person reviews with the
|
|
244
|
+
* review it answers.
|
|
245
|
+
*/
|
|
246
|
+
const storePlan = (plan: Plan, suffix: string, revision: number, answered?: Answered) =>
|
|
207
247
|
Effect.gen(function* () {
|
|
208
248
|
yield* artifact(`spec${suffix}`, {
|
|
209
249
|
kind: 'plan_spec',
|
|
@@ -223,6 +263,24 @@ const storePlan = (plan: Plan, suffix: string) =>
|
|
|
223
263
|
...(outcome === undefined ? undefined : { outcome })
|
|
224
264
|
}))
|
|
225
265
|
})
|
|
266
|
+
yield* artifact(`document${suffix}`, {
|
|
267
|
+
kind: 'plan_document',
|
|
268
|
+
title: plan.title,
|
|
269
|
+
text: planText(plan),
|
|
270
|
+
data: {
|
|
271
|
+
revision,
|
|
272
|
+
...(answered === undefined
|
|
273
|
+
? undefined
|
|
274
|
+
: {
|
|
275
|
+
review: {
|
|
276
|
+
revision: answered.review.revision,
|
|
277
|
+
comments: answered.review.comments.map(comment => ({ ...comment }))
|
|
278
|
+
},
|
|
279
|
+
addressed: answered.addressed.map(entry => ({ ...entry })),
|
|
280
|
+
declined: answered.declined.map(entry => ({ ...entry }))
|
|
281
|
+
})
|
|
282
|
+
}
|
|
283
|
+
})
|
|
226
284
|
})
|
|
227
285
|
|
|
228
286
|
/** What a refine changed, ticket by ticket, so the user sees the new revision against the last. */
|
|
@@ -540,13 +598,15 @@ const implement = (input: typeof Input.Type, plan: Plan, revision: number, filed
|
|
|
540
598
|
/**
|
|
541
599
|
* Plans from the goal and the code: the planner runs grill-with-docs, asking only the decisions that change the
|
|
542
600
|
* tickets, and Plan opens a docs ChangeRequest for the ADR and glossary changes it left. Plan checks each ticket's
|
|
543
|
-
* criteria against the base, stores the spec and tickets as Run artifacts, and
|
|
544
|
-
*
|
|
545
|
-
*
|
|
601
|
+
* criteria against the base, stores the spec and tickets as Run artifacts, and waits for a person to approve each
|
|
602
|
+
* revision, the planner revising it from their review until they do. Then it asks what next, at most six times: build
|
|
603
|
+
* the tickets, file them as Tasks, ask another Agent's opinion (twice at most), refine the plan from the user's words,
|
|
604
|
+
* or finish (ADR-0051). Nobody answering the menu files it as Tasks; started with `implement`, nobody answering
|
|
605
|
+
* approves each revision and implements it.
|
|
546
606
|
*/
|
|
547
607
|
export default defineLoop({
|
|
548
608
|
id: 'plan',
|
|
549
|
-
version: '2.
|
|
609
|
+
version: '2.2.0',
|
|
550
610
|
title: 'Plan',
|
|
551
611
|
input: Input,
|
|
552
612
|
output: Output,
|
|
@@ -585,7 +645,7 @@ export default defineLoop({
|
|
|
585
645
|
let filed: Filed | undefined
|
|
586
646
|
let opinions = 0
|
|
587
647
|
|
|
588
|
-
yield* storePlan(plan, '')
|
|
648
|
+
yield* storePlan(plan, '', revision)
|
|
589
649
|
|
|
590
650
|
const project = input.projectId === undefined ? undefined : { projectId: input.projectId }
|
|
591
651
|
|
|
@@ -624,6 +684,44 @@ export default defineLoop({
|
|
|
624
684
|
...rest
|
|
625
685
|
})
|
|
626
686
|
|
|
687
|
+
/** Asks a person to approve the revision, and has the planner revise it from their comments until they do. */
|
|
688
|
+
const approve = () =>
|
|
689
|
+
Effect.gen(function* () {
|
|
690
|
+
for (;;) {
|
|
691
|
+
const answer = yield* ask(`review:${revision}`, {
|
|
692
|
+
prompt: `Review revision ${revision} of the plan "${plan.title}": approve it, or request changes by commenting on what should change.`,
|
|
693
|
+
freeText: true,
|
|
694
|
+
recommended: PlanApproval,
|
|
695
|
+
recommendationReason: 'Approve it once the plan reads right; until then the Run waits for you.',
|
|
696
|
+
...(input.implement === true ? { default: PlanApproval, timeout: '1 hour' } : { default: null }),
|
|
697
|
+
unattendedAuto: PlanApproval
|
|
698
|
+
})
|
|
699
|
+
|
|
700
|
+
if (isPlanApproval(answer)) return
|
|
701
|
+
|
|
702
|
+
const review = readPlanReview(answer, revision, planText(plan))
|
|
703
|
+
|
|
704
|
+
const revised = yield* agentWorkOnce(`revise-plan:${revision}`, {
|
|
705
|
+
agent: 'planner',
|
|
706
|
+
prompt: revisePrompt(plan, review),
|
|
707
|
+
output: Revised
|
|
708
|
+
})
|
|
709
|
+
|
|
710
|
+
const { addressed, declined, ...next } = revised
|
|
711
|
+
const before = plan
|
|
712
|
+
const count = review.comments.length
|
|
713
|
+
|
|
714
|
+
revision++
|
|
715
|
+
;({ plan, rejected } = yield* checked(next, revision))
|
|
716
|
+
yield* storePlan(plan, `:review-${revision}`, revision, { review, addressed, declined })
|
|
717
|
+
yield* artifact(`changes:review-${revision}`, {
|
|
718
|
+
kind: 'plan_changes',
|
|
719
|
+
title: `Revision ${revision} of ${plan.title}`,
|
|
720
|
+
text: changelog(before, plan, `${count} review comment${count === 1 ? '' : 's'}`)
|
|
721
|
+
})
|
|
722
|
+
}
|
|
723
|
+
})
|
|
724
|
+
|
|
627
725
|
const decide = Effect.gen(function* () {
|
|
628
726
|
for (let round = 1; round <= maxRounds; round++) {
|
|
629
727
|
const isFiled = filed?.revision === revision
|
|
@@ -706,12 +804,13 @@ export default defineLoop({
|
|
|
706
804
|
|
|
707
805
|
revision++
|
|
708
806
|
;({ plan, rejected } = yield* checked(refined, revision))
|
|
709
|
-
yield* storePlan(plan, `:${round}
|
|
807
|
+
yield* storePlan(plan, `:${round}`, revision)
|
|
710
808
|
yield* artifact(`changes:${round}`, {
|
|
711
809
|
kind: 'plan_changes',
|
|
712
810
|
title: `Revision ${revision} of ${plan.title}`,
|
|
713
811
|
text: changelog(before, plan, words)
|
|
714
812
|
})
|
|
813
|
+
yield* approve()
|
|
715
814
|
break
|
|
716
815
|
}
|
|
717
816
|
}
|
|
@@ -726,6 +825,8 @@ export default defineLoop({
|
|
|
726
825
|
})
|
|
727
826
|
})
|
|
728
827
|
|
|
828
|
+
yield* approve()
|
|
829
|
+
|
|
729
830
|
return yield* decide.pipe(Effect.tapError(() => (implementing ? Effect.void : Effect.ignore(release()))))
|
|
730
831
|
})
|
|
731
832
|
})
|
package/src/tidy.ts
CHANGED
|
@@ -242,7 +242,7 @@ export default defineLoop({
|
|
|
242
242
|
const answer = yield* ask('next', {
|
|
243
243
|
prompt: `Tidy found ${survey.candidates.length} worth doing, top: ${top.title}. ${top.worth}\n\nWhat next?`,
|
|
244
244
|
options: [
|
|
245
|
-
{ value: 'Plan it', description: 'Plan
|
|
245
|
+
{ value: 'Plan it', description: 'Plan plans the candidates for you to review, then files them as Tasks.' },
|
|
246
246
|
{ value: 'Tidy the top one now', description: 'An agent makes the top one and opens a ChangeRequest.' },
|
|
247
247
|
{ value: 'Done', description: 'Keep the report and stop.' }
|
|
248
248
|
] satisfies { readonly value: (typeof next)[number]; readonly description: string }[],
|