@narumitw/pi-plan-mode 0.57.0 → 0.57.1

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.
@@ -17,8 +17,7 @@ Persistent defaults belong in [Settings](./settings.md).
17
17
  The TUI selector supports fuzzy search and paging; RPC shows the unfiltered list.
18
18
  Blocked, inactive, or not-yet-registered tools remain distinguishable, and selected names awaiting metadata stay selected for first-request resolution.
19
19
  Reopen the selector to refresh newly registered tools.
20
- Active and ready workflows lock planning tools and persistent settings; exit and start a new workflow to change the allowlist.
21
- Ready and saved plans expose **Implementation options…**, which stages model/thinking for that menu's implementation actions without changing the planner or saved defaults.
20
+ Active and ready workflows lock tools and settings; exit and start a new workflow to change the allowlist.
22
21
  See [Planning and implementation](../README.md#-planning-and-implementation) for the first-request policy boundary, completion, and same-session versus fresh-session handoff.
23
22
 
24
23
  ## Busy transitions and recovery
@@ -29,9 +28,6 @@ An ordinary follow-up or `/plan finalize` can still run while Plan mode is activ
29
28
 
30
29
  `show`, `save`, `export`, and `implement` require an applicable stored plan; `finalize` requires active Plan mode.
31
30
  Cancellation and failed implementation preflight leave the stored plan intact.
32
- `/plan implement` applies saved implementation preferences; menu actions additionally accept the current menu's draft overrides.
33
- After kickoff, settlement, abort, and clearing an active plan do not restore model/thinking.
34
- See [implementation preferences](./settings.md#implementation-model-and-thinking) for inheritance, provider-transfer effects, and partial fresh-session recovery.
35
31
  For finalization retries, fresh-session recovery, and non-interactive limitations, see [Planning and implementation](../README.md#-planning-and-implementation).
36
32
 
37
33
  ## Export Markdown
package/docs/settings.md CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  [Back to README](../README.md)
4
4
 
5
- - [Implementation model and thinking](#implementation-model-and-thinking)
6
5
  - [Default Plan policy tools](#default-plan-policy-tools)
7
6
  - [Plan reinjection](#plan-reinjection)
8
7
  - [Export destination](#export-destination)
@@ -12,7 +11,7 @@
12
11
 
13
12
  ## ⚙️ Settings
14
13
 
15
- Open **Settings** from an inactive `/plan` menu to edit planning defaults, implementation model/thinking, reinjection, export destination, and the shortcut.
14
+ Open **Settings** from an inactive `/plan` menu to edit **Plan thinking**, **Plan policy tools**, **Plan reinjection**, **Export destination**, and **Plan mode shortcut**.
16
15
  You can also edit `$PI_CODING_AGENT_DIR/pi-plan-mode.json` (normally `~/.pi/agent/pi-plan-mode.json`) manually.
17
16
  `safeSubcommands` is JSON-only.
18
17
  The optional file is read at session start, watched for changes, and created only by an explicit Settings save or manual edit.
@@ -33,27 +32,6 @@ The shortcut is disabled when `toggleShortcut` is omitted.
33
32
  }
34
33
  ```
35
34
 
36
- ### Implementation model and thinking
37
-
38
- `implementationModel` is an optional object with exact, case-sensitive `provider` and `id` strings. Both must be non-blank and at most 4,096 characters; IDs are opaque, so slashes and colons are not parsed. Omit this field or choose **Use current** to make no model change. For fresh implementation, that means the destination's normal startup model, not a forced copy of the source model.
39
-
40
- `implementationThinkingLevel` accepts `inherit` (the default), `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. `inherit` preserves normal behavior: same-session handoff restores a temporary Plan thinking override when appropriate, a model switch uses Pi's model/default thinking policy, and a fresh session uses its normal startup thinking. It does not promise to retain the planner's temporary thinking level. Explicit implementation thinking applies after model selection; Pi clamps it to the target's supported levels, and Plan mode reports an adjustment.
41
-
42
- ```json
43
- {
44
- "implementationModel": { "provider": "openai", "id": "your-registered-model-id" },
45
- "implementationThinkingLevel": "high"
46
- }
47
- ```
48
-
49
- Settings saves immediately but does not switch the running session. Each implementation menu snapshots those defaults when opened. **Implementation options…** edits a draft shared by both implementation actions in that menu; backing out of a nested picker leaves its previous choice, while closing the owning menu discards all its overrides. Reopen `/plan` to use updated defaults. `/plan implement` uses current saved defaults without a selector. Precedence is built-in behavior, user defaults, then the current menu's override; **Use current** and `inherit` can explicitly override fixed defaults.
50
-
51
- The model picker uses Pi's scoped models when configured, otherwise its available catalogue. It does not refresh providers or resolve auth merely to display choices; close and reopen the owning menu after refreshing Pi's catalogue. Display labels are sanitized without changing raw model identity. No registered match or failed authentication blocks an explicit target rather than silently selecting a fallback.
52
-
53
- Before kickoff, failed or cancelled preparation retains the ready/saved plan. Same-session recovery restores only still-owned runtime changes and does not overwrite a later manual choice. Pi owns authentication and model-selection operations, which have no public cancellation signal; the extension waits for them to settle and rejects stale continuations. After a fresh replacement commits, a preference failure leaves the request in the destination editor instead of starting with a fallback. If kickoff then fails, the destination retains its selected model/thinking and existing editor or active-plan recovery; the source remains resumable. Reload/resume never replays a pending preference request.
54
-
55
- After successful kickoff there is **no automatic restoration** on `agent_end`, `agent_settled`, user abort, or active-plan clearing. A settled run is not proof that the implementation task is complete. Later manual model/thinking changes are preserved. These preferences never write Pi's global model or thinking defaults, and existing plan-retention cleanup is unchanged.
56
-
57
35
  ### Plan helper tools
58
36
 
59
37
  Plan helper schemas are stable from extension registration onward, and Plan mode does not call `setActiveTools()`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narumitw/pi-plan-mode",
3
- "version": "0.57.0",
3
+ "version": "0.57.1",
4
4
  "description": "Pi extension that adds a Codex-like read-only /plan collaboration mode.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,24 +1,14 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import type { ExtensionCommandContext, ExtensionContext } from "@earendil-works/pi-coding-agent";
3
- import {
4
- FRESH_PREFERENCES_ENTRY,
5
- freshPreferencesApplied,
6
- } from "./fresh-implementation-preferences.js";
7
- import {
8
- hasImplementationPreferences,
9
- preflightImplementationPreferences,
10
- sameModel,
11
- } from "./implementation-preferences.js";
12
3
  import { PLAN_HISTORY_IMPLEMENTATION_PROMPT } from "./message-transform.js";
13
4
  import { createModeContractMessage } from "./mode-contract.js";
14
- import type { ImplementationPlanRetention, ImplementationPreferences } from "./settings.js";
5
+ import type { ImplementationPlanRetention } from "./settings.js";
15
6
  import type { PlanCompletionSource, PlanModeState } from "./state.js";
16
7
 
17
8
  type NewSessionOptions = Exclude<Parameters<ExtensionCommandContext["newSession"]>[0], undefined>;
18
9
  type ReplacementContext = Parameters<NonNullable<NewSessionOptions["withSession"]>>[0];
19
10
 
20
11
  export interface FreshImplementationRequest {
21
- preferences?: ImplementationPreferences;
22
12
  plan: string;
23
13
  source: PlanCompletionSource;
24
14
  retention: ImplementationPlanRetention;
@@ -27,7 +17,6 @@ export interface FreshImplementationRequest {
27
17
  }
28
18
 
29
19
  interface FreshImplementationFromStateOptions {
30
- preferences?: ImplementationPreferences;
31
20
  getState(): PlanModeState;
32
21
  menuIsCurrent(): boolean;
33
22
  retention: ImplementationPlanRetention;
@@ -87,7 +76,6 @@ export async function startFreshImplementationFromState(
87
76
  return startFreshImplementationSession(ctx, {
88
77
  plan,
89
78
  source,
90
- preferences: options.preferences,
91
79
  retention: options.retention,
92
80
  stateEntryType: options.stateEntryType,
93
81
  isCurrent,
@@ -104,25 +92,8 @@ export async function startFreshImplementationSession(
104
92
 
105
93
  await ctx.waitForIdle();
106
94
  if (!request.isCurrent()) return { kind: "stale" };
107
- const preferences = request.preferences ?? {};
108
- const originalModel = ctx.model;
109
- const originalThinking = ctx.thinkingLevel;
110
- const preflightCurrent = () =>
111
- request.isCurrent() &&
112
- sameModel(ctx.model, originalModel) &&
113
- ctx.thinkingLevel === originalThinking;
114
- const preferencesId = hasImplementationPreferences(preferences) ? randomUUID() : undefined;
115
- if (preferencesId) {
116
- try {
117
- if (!(await preflightImplementationPreferences(ctx, preferences, preflightCurrent)))
118
- return { kind: "stale" };
119
- } catch (error) {
120
- if (preflightCurrent())
121
- safeNotify(ctx, `Unable to implement the plan: ${safeErrorDetail(error)}`, "error");
122
- return { kind: "rejected" };
123
- }
124
- } else if (!(await preflightModel(ctx, preflightCurrent))) return { kind: "rejected" };
125
- if (!preflightCurrent() || !ctx.isIdle()) return { kind: "stale" };
95
+ if (!(await preflightModel(ctx, request.isCurrent))) return { kind: "rejected" };
96
+ if (!request.isCurrent()) return { kind: "stale" };
126
97
 
127
98
  const usesConversationHistory = request.retention === "clear-on-start";
128
99
  const destinationState: PlanModeState | undefined = usesConversationHistory
@@ -153,12 +124,6 @@ export async function startFreshImplementationSession(
153
124
  ...(parentSession ? { parentSession } : {}),
154
125
  setup: async (sessionManager) => {
155
126
  try {
156
- if (preferencesId)
157
- sessionManager.appendCustomEntry(FRESH_PREFERENCES_ENTRY, {
158
- id: preferencesId,
159
- status: "pending",
160
- preferences,
161
- });
162
127
  const contract = createModeContractMessage("normal");
163
128
  sessionManager.appendCustomMessageEntry(
164
129
  contract.customType,
@@ -174,14 +139,6 @@ export async function startFreshImplementationSession(
174
139
  }
175
140
  },
176
141
  withSession: async (replacementCtx) => {
177
- if (
178
- !setupError &&
179
- preferencesId &&
180
- !freshPreferencesApplied(replacementCtx, preferencesId)
181
- ) {
182
- setupError =
183
- "Implementation model/thinking could not be applied or changed before kickoff";
184
- }
185
142
  if (setupError) {
186
143
  recoverSetupFailure(replacementCtx, handoff, setupError);
187
144
  return;
@@ -1,6 +1,5 @@
1
1
  import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
2
  import type { PlanExportDestination } from "./plan-export.js";
3
- import type { ImplementationPreferences } from "./settings.js";
4
3
  import type { PlanModeState } from "./state.js";
5
4
 
6
5
  type InteractiveUi = typeof import("./interactive-ui.js");
@@ -19,17 +18,8 @@ interface PlanActionControllerOptions {
19
18
  getExportDestination(ctx: ExtensionContext): PlanExportDestination;
20
19
  show(ctx: ExtensionContext): void;
21
20
  finalize(ctx: ExtensionContext): void;
22
- getImplementationPreferences?(): ImplementationPreferences;
23
- implementHere(
24
- ctx: ExtensionContext,
25
- preferences?: ImplementationPreferences,
26
- isCurrent?: () => boolean,
27
- ): void | Promise<void>;
28
- implementFresh(
29
- ctx: ExtensionContext,
30
- isCurrent: () => boolean,
31
- preferences?: ImplementationPreferences,
32
- ): void | Promise<void>;
21
+ implementHere(ctx: ExtensionContext): void | Promise<void>;
22
+ implementFresh(ctx: ExtensionContext, isCurrent: () => boolean): void | Promise<void>;
33
23
  exportPlan(
34
24
  ctx: ExtensionContext,
35
25
  path: string,
@@ -44,17 +34,8 @@ interface PlanActionControllerOptions {
44
34
  }
45
35
 
46
36
  export function createPlanActionController(options: PlanActionControllerOptions) {
47
- const implementationActions = (ctx: ExtensionContext, lifecycle: MenuLifecycle) => ({
48
- implementationPreferences: options.getImplementationPreferences?.(),
49
- implementHere: (preferences?: ImplementationPreferences, signal?: AbortSignal) =>
50
- options.implementHere(
51
- ctx,
52
- preferences,
53
- () => lifecycle.isCurrent() && !lifecycle.signal.aborted && !signal?.aborted,
54
- ),
55
- implementFresh: (signal: AbortSignal, preferences?: ImplementationPreferences) =>
56
- options.implementFresh(ctx, () => lifecycle.isCurrent() && !signal.aborted, preferences),
57
- });
37
+ const freshAction = (ctx: ExtensionContext, lifecycle: MenuLifecycle, signal: AbortSignal) =>
38
+ options.implementFresh(ctx, () => lifecycle.isCurrent() && !signal.aborted);
58
39
 
59
40
  return {
60
41
  async showSaved(ctx: ExtensionContext) {
@@ -69,7 +50,8 @@ export function createPlanActionController(options: PlanActionControllerOptions)
69
50
  signal: lifecycle.signal,
70
51
  isCurrent: lifecycle.isCurrent,
71
52
  show: () => options.show(ctx),
72
- ...implementationActions(ctx, lifecycle),
53
+ implementHere: () => options.implementHere(ctx),
54
+ implementFresh: (signal) => freshAction(ctx, lifecycle, signal),
73
55
  exportPlan: (path, signal) => options.exportPlan(ctx, path, signal, lifecycle.isCurrent),
74
56
  settings: (signal) => options.settings(ctx, signal, lifecycle.isCurrent),
75
57
  clear: () => options.clearSaved(ctx),
@@ -92,7 +74,8 @@ export function createPlanActionController(options: PlanActionControllerOptions)
92
74
  ...lifecycle,
93
75
  show: () => options.show(ctx),
94
76
  finalize: () => options.finalize(ctx),
95
- ...implementationActions(ctx, lifecycle),
77
+ implementHere: () => options.implementHere(ctx),
78
+ implementFresh: (signal) => freshAction(ctx, lifecycle, signal),
96
79
  exportPlan: (path, signal) => options.exportPlan(ctx, path, signal, lifecycle.isCurrent),
97
80
  save: () => options.save(ctx),
98
81
  stay: () => options.stay(ctx),
@@ -108,7 +91,8 @@ export function createPlanActionController(options: PlanActionControllerOptions)
108
91
  ...lifecycle,
109
92
  implementationOutcome: options.implementationOutcome,
110
93
  getExportDestination: () => options.getExportDestination(ctx),
111
- ...implementationActions(ctx, lifecycle),
94
+ implementHere: () => options.implementHere(ctx),
95
+ implementFresh: (signal) => freshAction(ctx, lifecycle, signal),
112
96
  exportPlan: (path, signal) => options.exportPlan(ctx, path, signal, lifecycle.isCurrent),
113
97
  save: () => options.save(ctx),
114
98
  stay: () => undefined,
@@ -1,57 +1,35 @@
1
1
  import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
2
  import { defineMenu, runMenu } from "@narumitw/pi-tui-kit";
3
- import {
4
- createImplementationOptions,
5
- type ImplementationOptionAction,
6
- } from "./implementation-options.js";
7
3
  import { type PlanExportDestinationProvider, planExportInputScreen } from "./plan-export-screen.js";
8
- import type { ImplementationPreferences } from "./settings.js";
9
4
 
10
- interface ReadyPlanMenuOptions {
5
+ interface MenuLifecycle {
11
6
  signal: AbortSignal;
12
7
  isCurrent(): boolean;
13
- implementationPreferences?: ImplementationPreferences;
14
- implementationOutcome(): string;
15
- getExportDestination: PlanExportDestinationProvider;
16
- implementHere(
17
- preferences?: ImplementationPreferences,
18
- signal?: AbortSignal,
19
- ): void | Promise<void>;
20
- implementFresh(
21
- signal: AbortSignal,
22
- preferences?: ImplementationPreferences,
23
- ): void | Promise<void>;
24
- exportPlan(path: string, signal: AbortSignal): Promise<boolean>;
25
- save(): void;
26
- stay(): void;
27
- exit(): void;
28
8
  }
29
9
 
30
- interface PlanMenuOptions extends ReadyPlanMenuOptions {
10
+ const IMPLEMENTATION_CONTEXT_LINES = [
11
+ "Implement here keeps this planning conversation.",
12
+ "Start fresh transfers only the approved plan to a new session.",
13
+ ] as const;
14
+
15
+ interface PlanMenuOptions extends MenuLifecycle {
31
16
  statusText: string;
32
17
  hasReadyPlan: boolean;
18
+ implementationOutcome(): string;
19
+ getExportDestination: PlanExportDestinationProvider;
33
20
  show(): void;
34
21
  finalize(): void;
22
+ implementHere(): void | Promise<void>;
23
+ implementFresh(signal: AbortSignal): void | Promise<void>;
24
+ exportPlan(path: string, signal: AbortSignal): Promise<boolean>;
25
+ save(): void;
26
+ stay(): void;
27
+ exit(): void;
35
28
  }
36
29
 
37
- export function showPlanModeMenu(ctx: ExtensionContext, options: PlanMenuOptions) {
38
- return showActions(ctx, options, options);
39
- }
40
-
41
- export function showReadyPlanMenu(ctx: ExtensionContext, options: ReadyPlanMenuOptions) {
42
- return showActions(ctx, options);
43
- }
44
-
45
- async function showActions(
46
- ctx: ExtensionContext,
47
- options: ReadyPlanMenuOptions,
48
- current?: PlanMenuOptions,
49
- ) {
50
- const implementation = createImplementationOptions(ctx, options.implementationPreferences);
51
- const ready = current?.hasReadyPlan ?? true;
52
- type Screen = "main" | "export" | "implementation-options" | "implementation-model";
30
+ export async function showPlanModeMenu(ctx: ExtensionContext, options: PlanMenuOptions) {
31
+ type Screen = "main" | "export";
53
32
  type Action =
54
- | ImplementationOptionAction
55
33
  | "show"
56
34
  | "finalize"
57
35
  | "implement-here"
@@ -63,32 +41,23 @@ async function showActions(
63
41
  const menu = defineMenu<undefined, Screen, Action, ExtensionContext>({
64
42
  start: "main",
65
43
  screens: {
66
- ...implementation.screens,
67
44
  main: () => ({
68
45
  kind: "actions",
69
- title: current ? "Plan mode" : "Proposed plan ready. What next?",
46
+ title: "Plan mode",
70
47
  lines: [
71
- ...(current ? [current.statusText] : []),
72
- ...(ready
73
- ? [
74
- "Implement here keeps this planning conversation.",
75
- "Start fresh transfers only the approved plan to a new session.",
76
- options.implementationOutcome(),
77
- implementation.summary(),
78
- ]
48
+ options.statusText,
49
+ ...(options.hasReadyPlan
50
+ ? [...IMPLEMENTATION_CONTEXT_LINES, options.implementationOutcome()]
79
51
  : []),
80
52
  ],
81
- items: ready
53
+ items: options.hasReadyPlan
82
54
  ? [
83
- ...(current
84
- ? [{ id: "show", label: "Show latest proposed plan", action: "show" as const }]
85
- : []),
55
+ { id: "show", label: "Show latest proposed plan", action: "show" },
86
56
  {
87
57
  id: "implement-here",
88
58
  label: "Implement here",
89
59
  description: "Continue in this session with the planning conversation.",
90
60
  action: "implement-here",
91
- busyLabel: "Preparing implementation…",
92
61
  },
93
62
  {
94
63
  id: "implement-fresh",
@@ -97,11 +66,6 @@ async function showActions(
97
66
  action: "implement-fresh",
98
67
  busyLabel: "Starting fresh implementation session…",
99
68
  },
100
- {
101
- id: "implementation-options",
102
- label: "Implementation options…",
103
- to: "implementation-options",
104
- },
105
69
  { id: "export", label: "Export plan…", to: "export" },
106
70
  { id: "save", label: "Save for later", action: "save" },
107
71
  { id: "stay", label: "Stay in Plan mode", action: "stay" },
@@ -117,21 +81,96 @@ async function showActions(
117
81
  export: () => planExportInputScreen(options.getExportDestination),
118
82
  },
119
83
  actions: {
120
- ...implementation.actions,
121
84
  show: async () => {
122
- current?.show();
85
+ options.show();
123
86
  return { kind: "close" };
124
87
  },
125
88
  finalize: async () => {
126
- current?.finalize();
89
+ options.finalize();
90
+ return { kind: "close" };
91
+ },
92
+ "implement-here": async () => {
93
+ await options.implementHere();
94
+ return { kind: "close" };
95
+ },
96
+ "implement-fresh": async ({ signal }) => {
97
+ await options.implementFresh(signal);
98
+ return { kind: "close" };
99
+ },
100
+ export: async ({ value, signal }) =>
101
+ (await options.exportPlan(value ?? "", signal)) ? { kind: "close" } : { kind: "rejected" },
102
+ save: async () => {
103
+ options.save();
104
+ return { kind: "close" };
105
+ },
106
+ stay: async () => {
107
+ options.stay();
108
+ return { kind: "close" };
109
+ },
110
+ exit: async () => {
111
+ options.exit();
127
112
  return { kind: "close" };
128
113
  },
129
- "implement-here": async ({ signal }) => {
130
- await options.implementHere(implementation.get(), signal);
114
+ },
115
+ });
116
+ await runMenu(ctx, menu, {
117
+ getState: () => undefined,
118
+ signal: options.signal,
119
+ isCurrent: options.isCurrent,
120
+ });
121
+ }
122
+
123
+ interface ReadyPlanMenuOptions extends MenuLifecycle {
124
+ implementationOutcome(): string;
125
+ getExportDestination: PlanExportDestinationProvider;
126
+ implementHere(): void | Promise<void>;
127
+ implementFresh(signal: AbortSignal): void | Promise<void>;
128
+ exportPlan(path: string, signal: AbortSignal): Promise<boolean>;
129
+ save(): void;
130
+ stay(): void;
131
+ exit(): void;
132
+ }
133
+
134
+ export async function showReadyPlanMenu(ctx: ExtensionContext, options: ReadyPlanMenuOptions) {
135
+ type Screen = "ready" | "export";
136
+ type Action = "implement-here" | "implement-fresh" | "export" | "save" | "stay" | "exit";
137
+ const menu = defineMenu<undefined, Screen, Action, ExtensionContext>({
138
+ start: "ready",
139
+ screens: {
140
+ ready: () => ({
141
+ kind: "actions",
142
+ title: "Proposed plan ready. What next?",
143
+ lines: [...IMPLEMENTATION_CONTEXT_LINES, options.implementationOutcome()],
144
+ items: [
145
+ {
146
+ id: "implement-here",
147
+ label: "Implement here",
148
+ description: "Continue in this session with the planning conversation.",
149
+ action: "implement-here",
150
+ },
151
+ {
152
+ id: "implement-fresh",
153
+ label: "Start fresh and implement",
154
+ description: "Open a new linked session; transfer only the approved plan.",
155
+ action: "implement-fresh",
156
+ busyLabel: "Starting fresh implementation session…",
157
+ },
158
+ { id: "export", label: "Export plan…", to: "export" },
159
+ { id: "save", label: "Save for later", action: "save" },
160
+ { id: "stay", label: "Stay in Plan mode", action: "stay" },
161
+ { id: "exit", label: "Discard plan and exit", action: "exit" },
162
+ ],
163
+ hint: "close",
164
+ }),
165
+ export: () => planExportInputScreen(options.getExportDestination),
166
+ },
167
+ actions: {
168
+ "implement-here": async () => {
169
+ await options.implementHere();
131
170
  return { kind: "close" };
132
171
  },
133
172
  "implement-fresh": async ({ signal }) => {
134
- await options.implementFresh(signal, implementation.get());
173
+ await options.implementFresh(signal);
135
174
  return { kind: "close" };
136
175
  },
137
176
  export: async ({ value, signal }) =>
package/src/plan-mode.ts CHANGED
@@ -27,15 +27,6 @@ import {
27
27
  formatTransferredPlanPrompt,
28
28
  startFreshImplementationFromState,
29
29
  } from "./fresh-implementation.js";
30
- import { applyFreshImplementationPreferences } from "./fresh-implementation-preferences.js";
31
- import {
32
- createImplementationPreferenceChange,
33
- hasImplementationPreferences,
34
- observeImplementationModelSelections,
35
- preferenceError,
36
- preflightImplementationPreferences,
37
- sameModel,
38
- } from "./implementation-preferences.js";
39
30
  import {
40
31
  createImplementationRetentionCoordinator,
41
32
  implementationRetentionPreview,
@@ -83,7 +74,6 @@ import {
83
74
  configuredImplementationPlanRetention,
84
75
  configuredPlanModeToggleShortcut,
85
76
  configuredThinkingLevel,
86
- type ImplementationPreferences,
87
77
  type PlanModeSettings,
88
78
  type PlanModeSettingsPatch,
89
79
  planModeSettingsPath,
@@ -135,7 +125,6 @@ interface PlanModeDependencies {
135
125
  // Keep session state, persistence, tool, thinking, and mutex commits in this one closure so an
136
126
  // activation path cannot bypass the same atomic transition by crossing module-owned state.
137
127
  export default function planMode(pi: ExtensionAPI, dependencies: PlanModeDependencies = {}) {
138
- const selectionSnapshot = observeImplementationModelSelections(pi);
139
128
  const workflowMutex = new WorkflowMutex(pi);
140
129
  let workflowOwner: WorkflowMutexOwner | undefined;
141
130
  let currentSession: object | undefined;
@@ -164,8 +153,6 @@ export default function planMode(pi: ExtensionAPI, dependencies: PlanModeDepende
164
153
  let latestCommandContext: ExtensionCommandContext | undefined;
165
154
  let nextReadyPresentationNonce = 0;
166
155
  let menuGeneration = 0;
167
- let implementationInFlight = false;
168
- let applyingImplementationPreferences = false;
169
156
  let workflowGeneration = 0;
170
157
  let refreshStateBeforeFirstAgentStart = false;
171
158
  let menuController = new AbortController();
@@ -190,10 +177,6 @@ export default function planMode(pi: ExtensionAPI, dependencies: PlanModeDepende
190
177
  getExportDestination: (ctx) => planExports.getDestination(ctx),
191
178
  show: (ctx) => showStoredPlan(pi, ctx, state),
192
179
  finalize: requestFinalPlan,
193
- getImplementationPreferences: () => ({
194
- implementationModel: settings.implementationModel,
195
- implementationThinkingLevel: settings.implementationThinkingLevel,
196
- }),
197
180
  implementHere: startImplementation,
198
181
  implementFresh: startFreshImplementation,
199
182
  exportPlan: exportPlan,
@@ -484,13 +467,6 @@ export default function planMode(pi: ExtensionAPI, dependencies: PlanModeDepende
484
467
  if (!installRestoredState(restoredState, ctx)) return;
485
468
  implementationRetention.restore(state.activeImplementation);
486
469
  updateUi(ctx);
487
- if (event.reason === "new")
488
- await applyFreshImplementationPreferences(
489
- pi,
490
- ctx,
491
- () => generation === menuGeneration && !menuController.signal.aborted,
492
- selectionSnapshot,
493
- );
494
470
  });
495
471
 
496
472
  pi.on("session_before_tree", (event, ctx) => {
@@ -525,7 +501,7 @@ export default function planMode(pi: ExtensionAPI, dependencies: PlanModeDepende
525
501
  });
526
502
 
527
503
  pi.on("thinking_level_select", (event) => {
528
- if (applyingImplementationPreferences || !state.enabled || !state.appliedThinkingLevel) return;
504
+ if (!state.enabled || !state.appliedThinkingLevel) return;
529
505
  if (event.level !== state.appliedThinkingLevel) {
530
506
  state = {
531
507
  ...state,
@@ -1006,13 +982,8 @@ export default function planMode(pi: ExtensionAPI, dependencies: PlanModeDepende
1006
982
  ctx.ui.notify("Plan saved for later. Plan mode disabled.", "info");
1007
983
  }
1008
984
 
1009
- async function startFreshImplementation(
1010
- ctx: ExtensionContext,
1011
- menuIsCurrent: () => boolean,
1012
- preferences: ImplementationPreferences = settings,
1013
- ) {
985
+ async function startFreshImplementation(ctx: ExtensionContext, menuIsCurrent: () => boolean) {
1014
986
  await startFreshImplementationFromState(ctx, {
1015
- preferences,
1016
987
  getState: () => state,
1017
988
  menuIsCurrent,
1018
989
  retention: configuredImplementationPlanRetention(settings),
@@ -1020,77 +991,7 @@ export default function planMode(pi: ExtensionAPI, dependencies: PlanModeDepende
1020
991
  });
1021
992
  }
1022
993
 
1023
- async function startImplementation(
1024
- ctx: ExtensionContext,
1025
- preferences: ImplementationPreferences = settings,
1026
- menuIsCurrent: () => boolean = () => true,
1027
- ) {
1028
- if (implementationInFlight || !menuIsCurrent()) return;
1029
- if (!hasImplementationPreferences(preferences)) {
1030
- await startImplementationCore(ctx);
1031
- return;
1032
- }
1033
- if (!allowModeTransition(ctx, "start plan implementation")) return;
1034
- if (ctx.mode === "print" || ctx.mode === "json")
1035
- throw new Error("Implementation model options require TUI or RPC mode.");
1036
- const previousState = state;
1037
- if (!(state.enabled ? state.latestPlan : state.savedPlan?.plan)) return;
1038
- const generation = menuGeneration;
1039
- const workflow = workflowGeneration;
1040
- const original = { model: ctx.model, thinking: pi.getThinkingLevel() };
1041
- const sessionCurrent = () => generation === menuGeneration && !menuController.signal.aborted;
1042
- let expectedState = state;
1043
- const current = () =>
1044
- sessionCurrent() &&
1045
- workflow === workflowGeneration &&
1046
- state === expectedState &&
1047
- menuIsCurrent() &&
1048
- ctx.isIdle();
1049
- const change = createImplementationPreferenceChange(
1050
- pi,
1051
- ctx,
1052
- sessionCurrent,
1053
- original,
1054
- selectionSnapshot,
1055
- );
1056
- implementationInFlight = true;
1057
- let started = false;
1058
- try {
1059
- const model = await preflightImplementationPreferences(
1060
- ctx,
1061
- preferences,
1062
- () =>
1063
- current() &&
1064
- sameModel(ctx.model, original.model) &&
1065
- pi.getThinkingLevel() === original.thinking,
1066
- );
1067
- if (!model || !current()) return;
1068
- applyingImplementationPreferences = true;
1069
- if (state.enabled) restoreThinkingLevel();
1070
- expectedState = state;
1071
- if (!(await change.apply(model, preferences, current)) || !current()) return;
1072
- started = (await startImplementationCore(ctx, true)) === true;
1073
- } catch (error) {
1074
- if (sessionCurrent())
1075
- ctx.ui.notify(`Unable to start implementation: ${preferenceError(error)}`, "error");
1076
- } finally {
1077
- if (!started && sessionCurrent()) {
1078
- await change.rollback().catch((error) => {
1079
- if (sessionCurrent()) ctx.ui.notify(preferenceError(error), "error");
1080
- });
1081
- if (sessionCurrent() && state === expectedState) {
1082
- state = previousState;
1083
- captureManualThinkingLevel();
1084
- persistState();
1085
- updateUi(ctx);
1086
- }
1087
- }
1088
- applyingImplementationPreferences = false;
1089
- implementationInFlight = false;
1090
- }
1091
- }
1092
-
1093
- async function startImplementationCore(ctx: ExtensionContext, preferencesApplied = false) {
994
+ async function startImplementation(ctx: ExtensionContext) {
1094
995
  const savedPlan = state.enabled ? undefined : state.savedPlan;
1095
996
  const initialPlan = (state.enabled ? state.latestPlan : savedPlan?.plan)?.trim();
1096
997
  if (!initialPlan) {
@@ -1098,7 +999,7 @@ export default function planMode(pi: ExtensionAPI, dependencies: PlanModeDepende
1098
999
  return;
1099
1000
  }
1100
1001
  if (!allowModeTransition(ctx, "start plan implementation")) return;
1101
- if (savedPlan && !preferencesApplied) {
1002
+ if (savedPlan) {
1102
1003
  const sessionGeneration = menuGeneration;
1103
1004
  const planWorkflowGeneration = workflowGeneration;
1104
1005
  const isCurrent = () =>
@@ -1143,7 +1044,7 @@ export default function planMode(pi: ExtensionAPI, dependencies: PlanModeDepende
1143
1044
  workflowToolPolicy: undefined,
1144
1045
  manualThinkingLevel: undefined,
1145
1046
  };
1146
- if (wasEnabled && !preferencesApplied) {
1047
+ if (wasEnabled) {
1147
1048
  restoreThinkingLevel();
1148
1049
  state = { ...state, manualThinkingLevel: undefined };
1149
1050
  }
@@ -1162,14 +1063,13 @@ export default function planMode(pi: ExtensionAPI, dependencies: PlanModeDepende
1162
1063
  if (wasEnabled) {
1163
1064
  restoreWorkflowToolPolicy(state.workflowToolPolicy);
1164
1065
  publishModeContract("plan", ctx);
1165
- if (!preferencesApplied) applyPlanThinkingLevel();
1066
+ applyPlanThinkingLevel();
1166
1067
  }
1167
1068
  persistState();
1168
1069
  updateUi(ctx);
1169
1070
  return;
1170
1071
  }
1171
1072
  if (wasEnabled) releaseWorkflowOwner();
1172
- return true;
1173
1073
  }
1174
1074
 
1175
1075
  function clearActiveImplementation(id: string, ctx: ExtensionContext) {