@llm4ts/flow 0.1.3 → 0.1.4

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/Flow.d.ts CHANGED
@@ -14,6 +14,13 @@ export interface ImplementPlanOptions {
14
14
  readonly planPath: string;
15
15
  readonly plan: Effect.Effect<Plan, FlowError>;
16
16
  readonly system?: string;
17
+ /**
18
+ * When true, each task gets a fresh Chat (system prompt plus the plan's
19
+ * current render, showing prior tasks' completion status); that task's
20
+ * review-fix rounds share the same Chat. When false or omitted (default),
21
+ * one Chat is shared across every task in the plan.
22
+ */
23
+ readonly chatPerTask?: boolean;
17
24
  readonly reviewers?: ReadonlyArray<Reviewer>;
18
25
  readonly commitMessage?: (plan: Plan, task: Task) => string;
19
26
  readonly checkoutBranch?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"Flow.d.ts","sourceRoot":"","sources":["../src/Flow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAG9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1E,OAAO,EAA0B,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAC9E,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEtD,OAAO,EAAsC,KAAK,YAAY,EAAE,MAAM,aAAa,CAAA;AACnF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE7C,eAAO,MAAM,YAAY,GAAI,SAAS,gBAAgB,KAAG,eACd,CAAA;AAE3C,eAAO,MAAM,kBAAkB,mHAU7B,CAA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E,MAAM,kBAAkB,CAAA;AAEtD,OAAO,EAAsC,KAAK,YAAY,EAAE,MAAM,aAAa,CAAA;AACnF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE7C,eAAO,MAAM,YAAY,GAAI,SAAS,gBAAgB,KAAG,eACd,CAAA;AAE3C,eAAO,MAAM,kBAAkB,mHAU7B,CAAA;AAEF,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAA;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;IAC7C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAA;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAA;IAC5C,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,KAAK,MAAM,CAAA;IAC3D,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAA;IACjC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC,CAAA;IACtD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;CACjD;AAOD,eAAO,MAAM,iBAAiB,2gBAgG5B,CAAA"}
package/dist/Flow.js CHANGED
@@ -12,22 +12,60 @@ export const completeAndPublish = Effect.fn("@llm4ts/flow/Flow.completeAndPublis
12
12
  return response.content;
13
13
  });
14
14
  const defaultCommitMessage = (plan, task) => `${plan.epicId}: ${task.title}`;
15
+ const composeSystem = (base, note) => [base, note].filter((part) => part !== undefined && part.length > 0).join("\n\n");
15
16
  export const implementPlanFlow = Effect.fn("@llm4ts/flow/Flow.implementPlan")(function* (context, options) {
16
17
  const plan = yield* options.store.recoverOrCreate(options.planPath, options.plan);
17
18
  if (options.checkoutBranch !== false) {
18
19
  yield* stage(context.events, "branch", context.git.checkoutOrCreate(plan.epicId));
19
20
  }
20
- const coder = yield* makeChat(context.coder, {
21
- ...(options.system === undefined ? {} : { system: options.system })
22
- });
23
- return yield* implementTaskLoop(options.store, context.events, options.planPath, plan, (task) => Effect.gen(function* () {
21
+ let sharedCoder;
22
+ if (options.chatPerTask !== true) {
23
+ sharedCoder = yield* makeChat(context.coder, {
24
+ ...(options.system === undefined ? {} : { system: options.system })
25
+ });
26
+ }
27
+ return yield* implementTaskLoop(options.store, context.events, options.planPath, plan, (task, planSoFar) => Effect.gen(function* () {
28
+ // `sharedCoder`'s definedness mirrors `options.chatPerTask !== true`
29
+ // above: when it's set, every task reuses it; when it's undefined,
30
+ // chatPerTask is active and each task builds its own fresh Chat.
31
+ let coder;
32
+ if (sharedCoder !== undefined) {
33
+ coder = sharedCoder;
34
+ }
35
+ else {
36
+ coder = yield* makeChat(context.coder, {
37
+ system: composeSystem(options.system, planSoFar.render)
38
+ });
39
+ }
40
+ // `plan.taskPrompt` deliberately reads the frozen `plan` captured at
41
+ // the top of this function: a task prompt only needs that task's own
42
+ // details. `planSoFar`, threaded through by implementTaskLoop, is the
43
+ // single source of truth for completion progress instead.
24
44
  yield* coder.ask(plan.taskPrompt(task));
25
45
  const produced = yield* context.git.diffAll;
26
46
  if (produced.trim().length === 0) {
27
- yield* context.events.publish(Info.make({
28
- message: `task "${task.title}" produced no changes (already satisfied); skipping review and commit`
29
- }));
30
- return;
47
+ // An empty diff is ambiguous: the task may be genuinely satisfied
48
+ // already, or the coder may simply have produced nothing. Ask
49
+ // explicitly instead of inferring from absence; a task that
50
+ // produces no changes and no confirmation fails rather than being
51
+ // silently marked complete.
52
+ const confirmation = yield* coder.ask([
53
+ "Your previous turn produced no file changes.",
54
+ `If the task "${task.title}" is already fully satisfied by the current state of the repository, reply with exactly TASK_ALREADY_SATISFIED and nothing else.`,
55
+ "Otherwise, implement the task now."
56
+ ].join("\n"));
57
+ const afterConfirmation = yield* context.git.diffAll;
58
+ if (afterConfirmation.trim().length === 0) {
59
+ if (confirmation.includes("TASK_ALREADY_SATISFIED")) {
60
+ yield* context.events.publish(Info.make({
61
+ message: `task "${task.title}" confirmed already satisfied; skipping review and commit`
62
+ }));
63
+ return;
64
+ }
65
+ return yield* FlowAborted.make({
66
+ message: `task "${task.title}" produced no changes and did not confirm TASK_ALREADY_SATISFIED; failing instead of marking it complete`
67
+ });
68
+ }
31
69
  }
32
70
  yield* reviewAndFixLoop({
33
71
  reviewers: options.reviewers ?? minimalReviewers,
@@ -46,7 +84,10 @@ export const implementPlanFlow = Effect.fn("@llm4ts/flow/Flow.implementPlan")(fu
46
84
  return yield* FlowAborted.make({
47
85
  message: [
48
86
  `task "${task.title}": the lint gate is still failing after review settled; refusing to commit`,
49
- ...gate.issues.map((issue) => `- [${issue.severity}] ${issue.title}`)
87
+ ...gate.issues.map((issue) => {
88
+ const detail = issue.description.length === 0 ? "" : `\n${issue.description.slice(-2000)}`;
89
+ return `- [${issue.severity}] ${issue.title}${detail}`;
90
+ })
50
91
  ].join("\n")
51
92
  });
52
93
  }
package/dist/Flow.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Flow.js","sourceRoot":"","sources":["../src/Flow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAA;AAC1E,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAwB,MAAM,iBAA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AAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;4BAC3B,MAAM,MAAM,GACV,KAAK,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,CAAA;4BAC7E,OAAO,MAAM,KAAK,CAAC,QAAQ,KAAK,KAAK,CAAC,KAAK,GAAG,MAAM,EAAE,CAAA;wBACxD,CAAC,CAAC;qBACH,CAAC,IAAI,CAAC,IAAI,CAAC;iBACb,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;QACD,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,aAAa,IAAI,oBAAoB,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;IAC3F,CAAC,CAAC,CACL,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -3,5 +3,5 @@ import { type FlowEventsShape } from "./FlowEvents.ts";
3
3
  import type { Plan, Task } from "./Plan.ts";
4
4
  import type { PlanStoreShape } from "./Persistence.ts";
5
5
  export declare const stage: <A, E, R>(events: FlowEventsShape, name: string, effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
6
- export declare const implementTaskLoop: <E, R>(store: PlanStoreShape, events: FlowEventsShape, planPath: string, plan: Plan, perTask: (task: Task) => Effect.Effect<void, E, R>) => Effect.Effect<Plan, import("./FlowError.ts").PersistenceError | import("./FlowError.ts").PlanParseError | import("./FlowError.ts").UnsupportedSchemaVersion | import("./FlowError.ts").WorkspacePathError | import("./FlowError.ts").WorkspaceLimitError | import("./FlowError.ts").WorkspaceIoError | import("./FlowError.ts").FlowAborted | import("./FlowError.ts").ProcessError | import("./FlowError.ts").FlowLlmError | import("./FlowError.ts").FlowCapabilityDenied | import("./FlowError.ts").BudgetExceeded | E, R>;
6
+ export declare const implementTaskLoop: <E, R>(store: PlanStoreShape, events: FlowEventsShape, planPath: string, plan: Plan, perTask: (task: Task, planSoFar: Plan) => Effect.Effect<void, E, R>) => Effect.Effect<Plan, import("./FlowError.ts").PersistenceError | import("./FlowError.ts").PlanParseError | import("./FlowError.ts").UnsupportedSchemaVersion | import("./FlowError.ts").WorkspacePathError | import("./FlowError.ts").WorkspaceLimitError | import("./FlowError.ts").WorkspaceIoError | import("./FlowError.ts").FlowAborted | import("./FlowError.ts").ProcessError | import("./FlowError.ts").FlowLlmError | import("./FlowError.ts").FlowCapabilityDenied | import("./FlowError.ts").BudgetExceeded | E, R>;
7
7
  //# sourceMappingURL=PlanExecution.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlanExecution.d.ts","sourceRoot":"","sources":["../src/PlanExecution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAA6C,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjG,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAKtD,eAAO,MAAM,KAAK,GAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAC3B,QAAQ,eAAe,EACvB,MAAM,MAAM,EACZ,QAAQ,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAC7B,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAYrB,CAAA;AAEH,eAAO,MAAM,iBAAiB,GACjB,CAAC,EAAE,CAAC,gGAKG,IAAI,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,kgBAYrD,CAAA"}
1
+ {"version":3,"file":"PlanExecution.d.ts","sourceRoot":"","sources":["../src/PlanExecution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAA6C,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjG,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAKtD,eAAO,MAAM,KAAK,GAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAC3B,QAAQ,eAAe,EACvB,MAAM,MAAM,EACZ,QAAQ,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAC7B,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAYrB,CAAA;AAEH,eAAO,MAAM,iBAAiB,GACjB,CAAC,EAAE,CAAC,gGAKG,IAAI,aAAa,IAAI,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,kgBAYtE,CAAA"}
@@ -9,7 +9,7 @@ export const implementTaskLoop = Effect.fn("@llm4ts/flow/PlanExecution.implement
9
9
  let current = plan;
10
10
  for (const task of plan.tasks) {
11
11
  if (!task.completed) {
12
- yield* stage(events, task.title, perTask(task));
12
+ yield* stage(events, task.title, perTask(task, current));
13
13
  current = current.complete(task.title);
14
14
  yield* store.save(planPath, current);
15
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PlanExecution.js","sourceRoot":"","sources":["../src/PlanExecution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAwB,MAAM,iBAAiB,CAAA;AAKjG,MAAM,YAAY,GAAG,CAAC,KAAc,EAAU,EAAE,CAC9C,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,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,KAAK,EAAE,CAAC;QAC9B,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAA;YACxD,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YACtC,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QACtC,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CACF,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llm4ts/flow",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Effect-native LLM workflow, persistence, review, and repository automation",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -76,7 +76,7 @@
76
76
  "typescript"
77
77
  ],
78
78
  "dependencies": {
79
- "@llm4ts/core": "0.1.3"
79
+ "@llm4ts/core": "0.1.4"
80
80
  },
81
81
  "peerDependencies": {
82
82
  "effect": "^4.0.0-beta.102"
package/src/Flow.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as Effect from "effect/Effect"
2
2
  import type { LlmServiceShape } from "@llm4ts/core/LlmService"
3
3
  import { collect } from "@llm4ts/core/Streaming"
4
- import { makeChat } from "./Chat.ts"
4
+ import { makeChat, type Chat } from "./Chat.ts"
5
5
  import type { FlowContextShape } from "./FlowContext.ts"
6
6
  import { FlowAborted, FlowLlmError, type FlowError } from "./FlowError.ts"
7
7
  import { AssistantMessage, Info, type FlowEventsShape } from "./FlowEvents.ts"
@@ -31,6 +31,13 @@ export interface ImplementPlanOptions {
31
31
  readonly planPath: string
32
32
  readonly plan: Effect.Effect<Plan, FlowError>
33
33
  readonly system?: string
34
+ /**
35
+ * When true, each task gets a fresh Chat (system prompt plus the plan's
36
+ * current render, showing prior tasks' completion status); that task's
37
+ * review-fix rounds share the same Chat. When false or omitted (default),
38
+ * one Chat is shared across every task in the plan.
39
+ */
40
+ readonly chatPerTask?: boolean
34
41
  readonly reviewers?: ReadonlyArray<Reviewer>
35
42
  readonly commitMessage?: (plan: Plan, task: Task) => string
36
43
  readonly checkoutBranch?: boolean
@@ -41,6 +48,9 @@ export interface ImplementPlanOptions {
41
48
 
42
49
  const defaultCommitMessage = (plan: Plan, task: Task): string => `${plan.epicId}: ${task.title}`
43
50
 
51
+ const composeSystem = (base: string | undefined, note: string): string =>
52
+ [base, note].filter((part): part is string => part !== undefined && part.length > 0).join("\n\n")
53
+
44
54
  export const implementPlanFlow = Effect.fn("@llm4ts/flow/Flow.implementPlan")(function* (
45
55
  context: FlowContextShape,
46
56
  options: ImplementPlanOptions
@@ -49,44 +59,92 @@ export const implementPlanFlow = Effect.fn("@llm4ts/flow/Flow.implementPlan")(fu
49
59
  if (options.checkoutBranch !== false) {
50
60
  yield* stage(context.events, "branch", context.git.checkoutOrCreate(plan.epicId))
51
61
  }
52
- const coder = yield* makeChat(context.coder, {
53
- ...(options.system === undefined ? {} : { system: options.system })
54
- })
55
- return yield* implementTaskLoop(options.store, context.events, options.planPath, plan, (task) =>
56
- Effect.gen(function* () {
57
- yield* coder.ask(plan.taskPrompt(task))
58
- const produced = yield* context.git.diffAll
59
- if (produced.trim().length === 0) {
60
- yield* context.events.publish(
61
- Info.make({
62
- message: `task "${task.title}" produced no changes (already satisfied); skipping review and commit`
62
+ let sharedCoder: Chat | undefined
63
+ if (options.chatPerTask !== true) {
64
+ sharedCoder = yield* makeChat(context.coder, {
65
+ ...(options.system === undefined ? {} : { system: options.system })
66
+ })
67
+ }
68
+
69
+ return yield* implementTaskLoop(
70
+ options.store,
71
+ context.events,
72
+ options.planPath,
73
+ plan,
74
+ (task, planSoFar) =>
75
+ Effect.gen(function* () {
76
+ // `sharedCoder`'s definedness mirrors `options.chatPerTask !== true`
77
+ // above: when it's set, every task reuses it; when it's undefined,
78
+ // chatPerTask is active and each task builds its own fresh Chat.
79
+ let coder: Chat
80
+ if (sharedCoder !== undefined) {
81
+ coder = sharedCoder
82
+ } else {
83
+ coder = yield* makeChat(context.coder, {
84
+ system: composeSystem(options.system, planSoFar.render)
63
85
  })
64
- )
65
- return
66
- }
67
- yield* reviewAndFixLoop({
68
- reviewers: options.reviewers ?? minimalReviewers,
69
- reviewerService: flowReviewer(context),
70
- coder,
71
- taskTitle: task.title,
72
- currentDiff: context.git.diffAll,
73
- events: context.events,
74
- ...(options.maxRounds === undefined ? {} : { maxRounds: options.maxRounds }),
75
- ...(options.lint === undefined ? {} : { lint: options.lint }),
76
- ...(options.format === undefined ? {} : { format: options.format })
77
- })
78
- if (options.lint !== undefined) {
79
- const gate = yield* options.lint
80
- if (!gate.isClean) {
81
- return yield* FlowAborted.make({
82
- message: [
83
- `task "${task.title}": the lint gate is still failing after review settled; refusing to commit`,
84
- ...gate.issues.map((issue) => `- [${issue.severity}] ${issue.title}`)
86
+ }
87
+ // `plan.taskPrompt` deliberately reads the frozen `plan` captured at
88
+ // the top of this function: a task prompt only needs that task's own
89
+ // details. `planSoFar`, threaded through by implementTaskLoop, is the
90
+ // single source of truth for completion progress instead.
91
+ yield* coder.ask(plan.taskPrompt(task))
92
+ const produced = yield* context.git.diffAll
93
+ if (produced.trim().length === 0) {
94
+ // An empty diff is ambiguous: the task may be genuinely satisfied
95
+ // already, or the coder may simply have produced nothing. Ask
96
+ // explicitly instead of inferring from absence; a task that
97
+ // produces no changes and no confirmation fails rather than being
98
+ // silently marked complete.
99
+ const confirmation = yield* coder.ask(
100
+ [
101
+ "Your previous turn produced no file changes.",
102
+ `If the task "${task.title}" is already fully satisfied by the current state of the repository, reply with exactly TASK_ALREADY_SATISFIED and nothing else.`,
103
+ "Otherwise, implement the task now."
85
104
  ].join("\n")
86
- })
105
+ )
106
+ const afterConfirmation = yield* context.git.diffAll
107
+ if (afterConfirmation.trim().length === 0) {
108
+ if (confirmation.includes("TASK_ALREADY_SATISFIED")) {
109
+ yield* context.events.publish(
110
+ Info.make({
111
+ message: `task "${task.title}" confirmed already satisfied; skipping review and commit`
112
+ })
113
+ )
114
+ return
115
+ }
116
+ return yield* FlowAborted.make({
117
+ message: `task "${task.title}" produced no changes and did not confirm TASK_ALREADY_SATISFIED; failing instead of marking it complete`
118
+ })
119
+ }
87
120
  }
88
- }
89
- yield* context.git.commitAll((options.commitMessage ?? defaultCommitMessage)(plan, task))
90
- })
121
+ yield* reviewAndFixLoop({
122
+ reviewers: options.reviewers ?? minimalReviewers,
123
+ reviewerService: flowReviewer(context),
124
+ coder,
125
+ taskTitle: task.title,
126
+ currentDiff: context.git.diffAll,
127
+ events: context.events,
128
+ ...(options.maxRounds === undefined ? {} : { maxRounds: options.maxRounds }),
129
+ ...(options.lint === undefined ? {} : { lint: options.lint }),
130
+ ...(options.format === undefined ? {} : { format: options.format })
131
+ })
132
+ if (options.lint !== undefined) {
133
+ const gate = yield* options.lint
134
+ if (!gate.isClean) {
135
+ return yield* FlowAborted.make({
136
+ message: [
137
+ `task "${task.title}": the lint gate is still failing after review settled; refusing to commit`,
138
+ ...gate.issues.map((issue) => {
139
+ const detail =
140
+ issue.description.length === 0 ? "" : `\n${issue.description.slice(-2000)}`
141
+ return `- [${issue.severity}] ${issue.title}${detail}`
142
+ })
143
+ ].join("\n")
144
+ })
145
+ }
146
+ }
147
+ yield* context.git.commitAll((options.commitMessage ?? defaultCommitMessage)(plan, task))
148
+ })
91
149
  )
92
150
  })
@@ -31,12 +31,12 @@ export const implementTaskLoop = Effect.fn("@llm4ts/flow/PlanExecution.implement
31
31
  events: FlowEventsShape,
32
32
  planPath: string,
33
33
  plan: Plan,
34
- perTask: (task: Task) => Effect.Effect<void, E, R>
34
+ perTask: (task: Task, planSoFar: Plan) => Effect.Effect<void, E, R>
35
35
  ): Effect.fn.Return<Plan, E | FlowError, R> {
36
36
  let current = plan
37
37
  for (const task of plan.tasks) {
38
38
  if (!task.completed) {
39
- yield* stage(events, task.title, perTask(task))
39
+ yield* stage(events, task.title, perTask(task, current))
40
40
  current = current.complete(task.title)
41
41
  yield* store.save(planPath, current)
42
42
  }