@narumitw/pi-plan-mode 0.57.1 → 0.58.0
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/README.md +68 -4
- package/dist/chunks/{chunk-57OBPS7P.js → chunk-QHHHBTDO.js} +170 -83
- package/dist/chunks/chunk-QHHHBTDO.js.map +7 -0
- package/dist/chunks/{interactive-ui-N2ZKBVNE.js → interactive-ui-UNJGC2RQ.js} +322 -14
- package/dist/chunks/interactive-ui-UNJGC2RQ.js.map +7 -0
- package/dist/index.ts +667 -152
- package/dist/index.ts.map +4 -4
- package/docs/settings.md +26 -2
- package/package.json +1 -1
- package/src/command.ts +1 -0
- package/src/fresh-handoff-coordinator.ts +55 -0
- package/src/fresh-implementation.ts +153 -29
- package/src/implementation-models.ts +48 -0
- package/src/plan-action-controller.ts +78 -7
- package/src/plan-action-menus.ts +272 -17
- package/src/plan-mode.ts +454 -21
- package/src/settings-menu.ts +157 -2
- package/src/settings.ts +81 -1
- package/src/state.ts +62 -0
- package/dist/chunks/chunk-57OBPS7P.js.map +0 -7
- package/dist/chunks/interactive-ui-N2ZKBVNE.js.map +0 -7
package/README.md
CHANGED
|
@@ -11,6 +11,7 @@ Use a Codex-like `/plan` mode to explore a codebase, resolve important questions
|
|
|
11
11
|
- Uses structured questions for important ambiguity and explicit completion for a decision-ready plan.
|
|
12
12
|
- Reviews the complete plan before implementation, export, save, further planning, or discard.
|
|
13
13
|
- Implements in the planning session or a fresh linked session with the approved plan.
|
|
14
|
+
- Configures persistent or one-shot destination model and thinking choices for fresh implementation.
|
|
14
15
|
- Restores Plan state and one saved plan across resume and compaction.
|
|
15
16
|
- Configures the Plan tool allowlist, reviewed shell commands, user-trusted subcommands, export path, plan reinjection, shortcut, and thinking level.
|
|
16
17
|
- Publishes statusline state and cooperates anonymously with Workflow Mutex Protocol v1 participants.
|
|
@@ -45,6 +46,45 @@ Install only from sources you trust because Pi extensions run with Pi's permissi
|
|
|
45
46
|
Run `/plan` to open the state-aware menu, then start Plan mode and ask the agent to inspect and design the change.
|
|
46
47
|
Run `/plan <prompt>` when the first planning request is already known.
|
|
47
48
|
|
|
49
|
+
## 🗺️ How it works
|
|
50
|
+
|
|
51
|
+
Plan mode keeps exploration and implementation on opposite sides of an explicit review boundary:
|
|
52
|
+
|
|
53
|
+
```mermaid
|
|
54
|
+
flowchart LR
|
|
55
|
+
start["Start: /plan or /plan with a prompt"]
|
|
56
|
+
start --> explore["Explore safely: inspect and clarify"]
|
|
57
|
+
explore --> complete["Complete the plan with plan_mode_complete"]
|
|
58
|
+
complete --> review["Review the ready plan"]
|
|
59
|
+
review -->|Revise| explore
|
|
60
|
+
review -->|Implement here| current["Current session: planning context retained"]
|
|
61
|
+
review -->|Start fresh| fresh["Fresh session: approved plan transferred"]
|
|
62
|
+
review -->|Save| saved["Saved for later"]
|
|
63
|
+
review -->|Export| exported["Markdown file"]
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
During planning, the agent can inspect the project and ask material questions, but Plan mode blocks editing tools and unsafe shell forms. Implementation starts only after the plan is complete and you choose a handoff:
|
|
67
|
+
|
|
68
|
+
```mermaid
|
|
69
|
+
sequenceDiagram
|
|
70
|
+
actor User
|
|
71
|
+
participant Pi
|
|
72
|
+
participant Plan as Plan mode
|
|
73
|
+
participant Work as Implementation
|
|
74
|
+
|
|
75
|
+
User->>Pi: Start planning
|
|
76
|
+
Pi->>Plan: Apply the configured Plan tool policy
|
|
77
|
+
Plan->>User: Ask material questions when needed
|
|
78
|
+
User-->>Plan: Answer or refine the request
|
|
79
|
+
Plan->>Pi: Submit the complete plan
|
|
80
|
+
Pi-->>User: Show the ready-plan review
|
|
81
|
+
alt Implement here
|
|
82
|
+
Pi->>Work: Restore Normal mode in the current session
|
|
83
|
+
else Start fresh and implement
|
|
84
|
+
Pi->>Work: Create a fresh session with the approved plan
|
|
85
|
+
end
|
|
86
|
+
```
|
|
87
|
+
|
|
48
88
|
## 💬 Commands
|
|
49
89
|
|
|
50
90
|
| Command | Purpose |
|
|
@@ -57,11 +97,12 @@ Run `/plan <prompt>` when the first planning request is already known.
|
|
|
57
97
|
| `/plan finalize` | Ask the active planner to finish or ask one remaining material question. |
|
|
58
98
|
| `/plan implement` | Implement a completed or saved plan in this session, without a selector. |
|
|
59
99
|
| `/plan save` | Save a ready plan in this Pi session and leave Plan mode. |
|
|
100
|
+
| `/plan settings` | Open the same Plan Settings screen available from the menus. |
|
|
60
101
|
| `/plan export [path]` | Write a ready, saved, or active implementation plan to Markdown. |
|
|
61
102
|
| `/plan exit` (alias: `off`) | Leave Plan mode and discard its ready plan, or clear a saved/active plan. |
|
|
62
103
|
|
|
63
104
|
All routes support TUI and RPC.
|
|
64
|
-
Print and JSON modes reject the menu and `
|
|
105
|
+
Print and JSON modes reject the menu, `tools`, and `settings`; stored-plan display and implementation have [additional mode restrictions](#-planning-and-implementation).
|
|
65
106
|
Exact subcommand words select routes; other text is a planning prompt, so `/plan start a migration` sends a prompt rather than rejecting trailing text.
|
|
66
107
|
There is no startup flag.
|
|
67
108
|
|
|
@@ -151,7 +192,23 @@ Empty, malformed, unclosed, or multiple legacy blocks keep Plan mode active and
|
|
|
151
192
|
After completion, `/plan` opens the ready actions when interactive UI is available.
|
|
152
193
|
The same flat menu shows **Implement here** and **Start fresh and implement**, explains which conversation context each choice uses, and previews the selected **Plan reinjection** policy.
|
|
153
194
|
**Implement here**—and the compatibility route `/plan implement`—appends the Normal contract, lifts the Plan runtime policy, captures the reinjection setting, and starts implementation in the current session with its complete planning conversation and tool calls.
|
|
154
|
-
**Start fresh and implement**
|
|
195
|
+
**Start fresh and implement** opens a settings page before replacement.
|
|
196
|
+
Its searchable model list snapshots the session's scoped models when configured, otherwise Pi's currently available models, and shows each provider, model ID, and friendly name.
|
|
197
|
+
Pi 0.80.6–0.82.1 does not expose session model scopes to extensions, so the list uses all currently available models on those releases.
|
|
198
|
+
One-shot provider and model identifiers are limited to 512 characters each; longer custom identifiers are rejected before the source session is replaced.
|
|
199
|
+
The model and thinking rows start from the persistent **Fresh model** and **Fresh thinking** defaults; when either setting is omitted, they show the planning session's current value with **same as plan** and carry it into the fresh session independently.
|
|
200
|
+
The fixed thinking choices are `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`.
|
|
201
|
+
Back navigation preserves this menu-local draft, while closing and reopening the menu restores both persistent defaults.
|
|
202
|
+
If the configured model is outside the current scope or no longer available, the row reports the fallback and uses **same as plan** without deleting the stored preference.
|
|
203
|
+
The saved-plan menu keeps its direct fresh-session action without optional rows and applies the same persistent defaults and fallback.
|
|
204
|
+
|
|
205
|
+
Starting from that settings page waits for the source session to become idle, re-resolves and authenticates an explicit model, creates a new session linked to the persisted source as its parent, and transfers the exact approved plan without copying planning messages, tool results, or compaction/branch summaries.
|
|
206
|
+
The destination consumes the one-shot choices before its first provider request, applies an explicit model first, and then applies explicit thinking.
|
|
207
|
+
Concurrent prompts that arrive while those choices are being applied are queued as follow-ups behind the kickoff prompt.
|
|
208
|
+
If durable consumption blocks the kickoff, the handoff reports a partial start and restores a conversation-history prompt to the editor instead of reporting success.
|
|
209
|
+
Changing only the model keeps the planning thinking level; changing only the thinking level keeps the planning model.
|
|
210
|
+
If Pi clamps an unsupported thinking level, the extension reports the effective level.
|
|
211
|
+
If the chosen model disappears or loses authentication after source preflight, the destination reports the race, consumes the intent without retrying it later, and continues with its default model.
|
|
155
212
|
The destination still loads its normal `AGENTS.md`, skills, project resources, and extensions.
|
|
156
213
|
Choosing **Export plan…** asks for a destination, writes the plan, appends the Normal contract, restores inherited thinking, and leaves Plan mode without starting a model turn or changing active tools.
|
|
157
214
|
Choosing **Save for later**—or running `/plan save`—instead stores one plan in the current Pi session before leaving Plan mode.
|
|
@@ -162,6 +219,8 @@ Resume it later to inspect or hand off the ready/saved plan again; this delibera
|
|
|
162
219
|
In-memory sessions create an unlinked fresh session because no parent file exists.
|
|
163
220
|
Escape, Ctrl+C, menu disposal, source replacement/shutdown, model/auth failure, or cancellation by another extension before replacement leaves the source plan unchanged.
|
|
164
221
|
Under **Off — conversation history only**, the destination receives the complete plan in its initial user prompt and does not persist active-plan state.
|
|
222
|
+
When a one-shot runtime choice exists, only that temporary non-model state is persisted and it is removed before the first request.
|
|
223
|
+
If that removal cannot be persisted, the request is not sent and can be retried after session persistence is available.
|
|
165
224
|
If that kickoff fails, the complete request remains in the destination editor and the source remains resumable.
|
|
166
225
|
Under either guaranteed-plan policy, the destination persists active-plan state before kickoff.
|
|
167
226
|
If guaranteed-plan persistence fails, the complete request is placed in the destination editor and the source remains resumable.
|
|
@@ -282,18 +341,23 @@ Guaranteed coexistence with Goal requires `@narumitw/pi-goal` `0.53.0` or newer
|
|
|
282
341
|
|
|
283
342
|
## ⚙️ Settings
|
|
284
343
|
|
|
285
|
-
|
|
344
|
+
Run `/plan settings`, open **Settings** from an inactive `/plan` menu, or edit `<getAgentDir()>/pi-plan-mode.json` (normally `~/.pi/agent/pi-plan-mode.json`).
|
|
286
345
|
The optional file is read at session start and watched for changes; only an explicit save creates it.
|
|
287
346
|
|
|
288
347
|
```json
|
|
289
348
|
{
|
|
290
349
|
"thinkingLevel": "inherit",
|
|
291
350
|
"implementationPlanRetention": "clear-on-start",
|
|
351
|
+
"defaultImplementationModel": {
|
|
352
|
+
"provider": "anthropic",
|
|
353
|
+
"modelId": "claude-sonnet-4-5"
|
|
354
|
+
},
|
|
355
|
+
"defaultImplementationThinkingLevel": "high",
|
|
292
356
|
"defaultPlanExportPath": "PLAN.md"
|
|
293
357
|
}
|
|
294
358
|
```
|
|
295
359
|
|
|
296
|
-
By default, Plan mode inherits thinking, allows active safe built-ins, exports to `PLAN.md`, and relies on ordinary conversation history after implementation starts.
|
|
360
|
+
By default, Plan mode inherits thinking, allows active safe built-ins, uses the planning model and thinking level for fresh implementation, exports to `PLAN.md`, and relies on ordinary conversation history after implementation starts.
|
|
297
361
|
The shortcut is disabled unless configured.
|
|
298
362
|
Settings saves apply to later workflows; an active implementation keeps its captured reinjection policy.
|
|
299
363
|
The export destination affects the next export immediately.
|
|
@@ -304,86 +304,28 @@ function contentText(content) {
|
|
|
304
304
|
}).filter(Boolean).join("\n");
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
-
// src/implementation-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
return
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
307
|
+
// src/implementation-models.ts
|
|
308
|
+
var MAX_PENDING_IMPLEMENTATION_MODEL_IDENTIFIER_LENGTH = 512;
|
|
309
|
+
function isPendingImplementationModelIdentifier(value) {
|
|
310
|
+
return typeof value === "string" && value.trim().length > 0 && value.length <= MAX_PENDING_IMPLEMENTATION_MODEL_IDENTIFIER_LENGTH;
|
|
311
|
+
}
|
|
312
|
+
function snapshotAvailableImplementationModels(ctx) {
|
|
313
|
+
const getAvailable = ctx.modelRegistry.getAvailable;
|
|
314
|
+
const availableModels = typeof getAvailable === "function" ? getAvailable.call(ctx.modelRegistry) : [];
|
|
315
|
+
const scopedModels = ctx.scopedModels ?? [];
|
|
316
|
+
if (scopedModels.length === 0) return availableModels;
|
|
317
|
+
return scopedModels.flatMap((entry) => {
|
|
318
|
+
const availableModel = availableModels.find(
|
|
319
|
+
(model) => model.provider === entry.model.provider && model.id === entry.model.id
|
|
320
|
+
);
|
|
321
|
+
return availableModel ? [availableModel] : [];
|
|
322
|
+
});
|
|
321
323
|
}
|
|
322
|
-
function
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
restoredImplementationAwaitingContext = activeImplementation && activeImplementation.retention !== "keep" ? activeImplementation.id : void 0;
|
|
328
|
-
},
|
|
329
|
-
transformContext(messages, state) {
|
|
330
|
-
const messagesWithoutLegacyContext = messages.filter(
|
|
331
|
-
(message) => !messageContainsLegacyPlanModeContextArtifact(message)
|
|
332
|
-
);
|
|
333
|
-
if (state.enabled) {
|
|
334
|
-
return {
|
|
335
|
-
messages: messagesWithoutLegacyContext.filter(
|
|
336
|
-
(message) => !messageContainsPlanModeImplementationContextArtifact(message) && !messageContainsPlanModeImplementationHandoff(message)
|
|
337
|
-
)
|
|
338
|
-
};
|
|
339
|
-
}
|
|
340
|
-
const activeImplementation = state.activeImplementation;
|
|
341
|
-
const inactiveMessages = activeImplementation ? messagesWithoutLegacyContext : messagesWithoutLegacyContext.filter(
|
|
342
|
-
(message) => !messageContainsPlanModeImplementationContextArtifact(message) && !messageContainsPlanModeImplementationHandoff(message)
|
|
343
|
-
);
|
|
344
|
-
const historyArtifact = activeImplementation ? void 0 : findHistoryImplementationArtifact(inactiveMessages);
|
|
345
|
-
const historyArtifactMessage = historyArtifact ? inactiveMessages[historyArtifact.messageIndex] : void 0;
|
|
346
|
-
const historyToolCallMessage = historyArtifact?.toolCallMessageIndex !== void 0 ? inactiveMessages[historyArtifact.toolCallMessageIndex] : void 0;
|
|
347
|
-
const filteredMessages = inactiveMessages.filter(
|
|
348
|
-
(message) => message === historyArtifactMessage || !messageContainsInactivePlanModeArtifact(message)
|
|
349
|
-
).map(
|
|
350
|
-
(message) => message === historyArtifactMessage && historyArtifact?.kind === "legacy" ? message : stripProposedPlanBlocksFromMessage(message)
|
|
351
|
-
).map(
|
|
352
|
-
(message) => stripPlanModeCompletionCallsFromMessage(
|
|
353
|
-
message,
|
|
354
|
-
message === historyToolCallMessage ? historyArtifact?.toolCallId : void 0
|
|
355
|
-
)
|
|
356
|
-
).filter((message) => !isEmptyAssistantMessage(message));
|
|
357
|
-
if (!activeImplementation) return { messages: filteredMessages };
|
|
358
|
-
const contextualMessages = injectActiveImplementationContext(
|
|
359
|
-
filteredMessages,
|
|
360
|
-
activeImplementation
|
|
361
|
-
);
|
|
362
|
-
const deliveredCurrentHandoff = restoredImplementationAwaitingContext === activeImplementation.id || filteredMessages.some(
|
|
363
|
-
(message) => messageContainsExactPlanModeImplementationHandoff(message, activeImplementation.plan)
|
|
364
|
-
);
|
|
365
|
-
if (!deliveredCurrentHandoff) return { messages: contextualMessages };
|
|
366
|
-
restoredImplementationAwaitingContext = void 0;
|
|
367
|
-
if (activeImplementation.retention === "clear-after-first-run") {
|
|
368
|
-
implementationWithDeliveredContext = activeImplementation.id;
|
|
369
|
-
}
|
|
370
|
-
return {
|
|
371
|
-
messages: contextualMessages,
|
|
372
|
-
clearActiveImplementationId: activeImplementation.retention === "clear-on-start" ? activeImplementation.id : void 0
|
|
373
|
-
};
|
|
374
|
-
},
|
|
375
|
-
implementationSettled(activeImplementation) {
|
|
376
|
-
if (activeImplementation?.retention !== "clear-after-first-run" || implementationWithDeliveredContext !== activeImplementation.id) {
|
|
377
|
-
return void 0;
|
|
378
|
-
}
|
|
379
|
-
implementationWithDeliveredContext = void 0;
|
|
380
|
-
return activeImplementation.id;
|
|
381
|
-
},
|
|
382
|
-
reset() {
|
|
383
|
-
implementationWithDeliveredContext = void 0;
|
|
384
|
-
restoredImplementationAwaitingContext = void 0;
|
|
385
|
-
}
|
|
386
|
-
};
|
|
324
|
+
function findAvailableImplementationModel(models, configured) {
|
|
325
|
+
if (!configured) return void 0;
|
|
326
|
+
return models.find(
|
|
327
|
+
(model) => model.provider === configured.provider && model.id === configured.modelId
|
|
328
|
+
);
|
|
387
329
|
}
|
|
388
330
|
|
|
389
331
|
// src/settings.ts
|
|
@@ -405,6 +347,15 @@ var PLAN_MODE_THINKING_LEVELS = [
|
|
|
405
347
|
"xhigh",
|
|
406
348
|
"max"
|
|
407
349
|
];
|
|
350
|
+
var IMPLEMENTATION_THINKING_LEVELS = [
|
|
351
|
+
"off",
|
|
352
|
+
"minimal",
|
|
353
|
+
"low",
|
|
354
|
+
"medium",
|
|
355
|
+
"high",
|
|
356
|
+
"xhigh",
|
|
357
|
+
"max"
|
|
358
|
+
];
|
|
408
359
|
var IMPLEMENTATION_PLAN_RETENTIONS = [
|
|
409
360
|
"clear-on-start",
|
|
410
361
|
"clear-after-first-run",
|
|
@@ -496,6 +447,25 @@ function normalizePlanModeSettings(value) {
|
|
|
496
447
|
}
|
|
497
448
|
settings.implementationPlanRetention = implementationPlanRetention;
|
|
498
449
|
}
|
|
450
|
+
if (Object.hasOwn(value, "defaultImplementationModel")) {
|
|
451
|
+
const defaultImplementationModel = normalizeImplementationModel(
|
|
452
|
+
Reflect.get(value, "defaultImplementationModel")
|
|
453
|
+
);
|
|
454
|
+
if (!defaultImplementationModel) return void 0;
|
|
455
|
+
settings.defaultImplementationModel = defaultImplementationModel;
|
|
456
|
+
}
|
|
457
|
+
if (Object.hasOwn(value, "defaultImplementationThinkingLevel")) {
|
|
458
|
+
const defaultImplementationThinkingLevel = Reflect.get(
|
|
459
|
+
value,
|
|
460
|
+
"defaultImplementationThinkingLevel"
|
|
461
|
+
);
|
|
462
|
+
if (!IMPLEMENTATION_THINKING_LEVELS.includes(
|
|
463
|
+
defaultImplementationThinkingLevel
|
|
464
|
+
)) {
|
|
465
|
+
return void 0;
|
|
466
|
+
}
|
|
467
|
+
settings.defaultImplementationThinkingLevel = defaultImplementationThinkingLevel;
|
|
468
|
+
}
|
|
499
469
|
if (Object.hasOwn(value, "defaultPlanExportPath")) {
|
|
500
470
|
const defaultPlanExportPath = normalizePlanExportPath(
|
|
501
471
|
Reflect.get(value, "defaultPlanExportPath")
|
|
@@ -515,6 +485,17 @@ function normalizePlanModeSettings(value) {
|
|
|
515
485
|
}
|
|
516
486
|
return settings;
|
|
517
487
|
}
|
|
488
|
+
function normalizeImplementationModel(value) {
|
|
489
|
+
if (!isSettingsDocument(value) || Object.keys(value).some((key) => key !== "provider" && key !== "modelId")) {
|
|
490
|
+
return void 0;
|
|
491
|
+
}
|
|
492
|
+
const provider = typeof value.provider === "string" ? value.provider.trim() : value.provider;
|
|
493
|
+
const modelId = typeof value.modelId === "string" ? value.modelId.trim() : value.modelId;
|
|
494
|
+
if (!isPendingImplementationModelIdentifier(provider) || !isPendingImplementationModelIdentifier(modelId)) {
|
|
495
|
+
return void 0;
|
|
496
|
+
}
|
|
497
|
+
return { provider, modelId };
|
|
498
|
+
}
|
|
518
499
|
function normalizeToolNames(value) {
|
|
519
500
|
if (!Array.isArray(value) || !value.every((item) => typeof item === "string" && item.trim().length > 0)) {
|
|
520
501
|
return void 0;
|
|
@@ -603,6 +584,17 @@ function updatePlanModeSettings(patch, options = {}) {
|
|
|
603
584
|
if (patch.implementationPlanRetention !== void 0) {
|
|
604
585
|
updated.implementationPlanRetention = patch.implementationPlanRetention;
|
|
605
586
|
}
|
|
587
|
+
if (patch.defaultImplementationModel === null) delete updated.defaultImplementationModel;
|
|
588
|
+
else if (patch.defaultImplementationModel !== void 0) {
|
|
589
|
+
const model = normalizeImplementationModel(patch.defaultImplementationModel);
|
|
590
|
+
if (!model) throw invalidSettingsError(settingsPath, "invalid implementation model");
|
|
591
|
+
updated.defaultImplementationModel = model;
|
|
592
|
+
}
|
|
593
|
+
if (patch.defaultImplementationThinkingLevel === null) {
|
|
594
|
+
delete updated.defaultImplementationThinkingLevel;
|
|
595
|
+
} else if (patch.defaultImplementationThinkingLevel !== void 0) {
|
|
596
|
+
updated.defaultImplementationThinkingLevel = patch.defaultImplementationThinkingLevel;
|
|
597
|
+
}
|
|
606
598
|
if (patch.defaultPlanExportPath === null) delete updated.defaultPlanExportPath;
|
|
607
599
|
else if (patch.defaultPlanExportPath !== void 0) {
|
|
608
600
|
updated.defaultPlanExportPath = patch.defaultPlanExportPath;
|
|
@@ -757,6 +749,12 @@ function configuredThinkingLevel(settings) {
|
|
|
757
749
|
function configuredImplementationPlanRetention(settings) {
|
|
758
750
|
return settings.implementationPlanRetention ?? "clear-on-start";
|
|
759
751
|
}
|
|
752
|
+
function configuredImplementationModel(settings) {
|
|
753
|
+
return settings.defaultImplementationModel;
|
|
754
|
+
}
|
|
755
|
+
function configuredImplementationThinkingLevel(settings) {
|
|
756
|
+
return settings.defaultImplementationThinkingLevel;
|
|
757
|
+
}
|
|
760
758
|
function configuredPlanExportPath(settings) {
|
|
761
759
|
return settings.defaultPlanExportPath ?? DEFAULT_PLAN_EXPORT_PATH;
|
|
762
760
|
}
|
|
@@ -764,6 +762,88 @@ function configuredPlanModeToggleShortcut(settings) {
|
|
|
764
762
|
return settings.toggleShortcut;
|
|
765
763
|
}
|
|
766
764
|
|
|
765
|
+
// src/implementation-retention.ts
|
|
766
|
+
function retentionLabel(retention) {
|
|
767
|
+
return {
|
|
768
|
+
"clear-on-start": "Off \u2014 conversation history only",
|
|
769
|
+
"clear-after-first-run": "Through first implementation run",
|
|
770
|
+
keep: "Until manually cleared"
|
|
771
|
+
}[retention];
|
|
772
|
+
}
|
|
773
|
+
function implementationRetentionPreview(retention) {
|
|
774
|
+
return {
|
|
775
|
+
"clear-on-start": "Plan reinjection: Off; use conversation history only.",
|
|
776
|
+
"clear-after-first-run": "Plan reinjection: Through the first implementation run.",
|
|
777
|
+
keep: "Plan reinjection: Until /plan exit."
|
|
778
|
+
}[retention];
|
|
779
|
+
}
|
|
780
|
+
function createImplementationRetentionCoordinator() {
|
|
781
|
+
let implementationWithDeliveredContext;
|
|
782
|
+
let restoredImplementationAwaitingContext;
|
|
783
|
+
return {
|
|
784
|
+
restore(activeImplementation) {
|
|
785
|
+
restoredImplementationAwaitingContext = activeImplementation && activeImplementation.retention !== "keep" ? activeImplementation.id : void 0;
|
|
786
|
+
},
|
|
787
|
+
transformContext(messages, state) {
|
|
788
|
+
const messagesWithoutLegacyContext = messages.filter(
|
|
789
|
+
(message) => !messageContainsLegacyPlanModeContextArtifact(message)
|
|
790
|
+
);
|
|
791
|
+
if (state.enabled) {
|
|
792
|
+
return {
|
|
793
|
+
messages: messagesWithoutLegacyContext.filter(
|
|
794
|
+
(message) => !messageContainsPlanModeImplementationContextArtifact(message) && !messageContainsPlanModeImplementationHandoff(message)
|
|
795
|
+
)
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
const activeImplementation = state.activeImplementation;
|
|
799
|
+
const inactiveMessages = activeImplementation ? messagesWithoutLegacyContext : messagesWithoutLegacyContext.filter(
|
|
800
|
+
(message) => !messageContainsPlanModeImplementationContextArtifact(message) && !messageContainsPlanModeImplementationHandoff(message)
|
|
801
|
+
);
|
|
802
|
+
const historyArtifact = activeImplementation ? void 0 : findHistoryImplementationArtifact(inactiveMessages);
|
|
803
|
+
const historyArtifactMessage = historyArtifact ? inactiveMessages[historyArtifact.messageIndex] : void 0;
|
|
804
|
+
const historyToolCallMessage = historyArtifact?.toolCallMessageIndex !== void 0 ? inactiveMessages[historyArtifact.toolCallMessageIndex] : void 0;
|
|
805
|
+
const filteredMessages = inactiveMessages.filter(
|
|
806
|
+
(message) => message === historyArtifactMessage || !messageContainsInactivePlanModeArtifact(message)
|
|
807
|
+
).map(
|
|
808
|
+
(message) => message === historyArtifactMessage && historyArtifact?.kind === "legacy" ? message : stripProposedPlanBlocksFromMessage(message)
|
|
809
|
+
).map(
|
|
810
|
+
(message) => stripPlanModeCompletionCallsFromMessage(
|
|
811
|
+
message,
|
|
812
|
+
message === historyToolCallMessage ? historyArtifact?.toolCallId : void 0
|
|
813
|
+
)
|
|
814
|
+
).filter((message) => !isEmptyAssistantMessage(message));
|
|
815
|
+
if (!activeImplementation) return { messages: filteredMessages };
|
|
816
|
+
const contextualMessages = injectActiveImplementationContext(
|
|
817
|
+
filteredMessages,
|
|
818
|
+
activeImplementation
|
|
819
|
+
);
|
|
820
|
+
const deliveredCurrentHandoff = restoredImplementationAwaitingContext === activeImplementation.id || filteredMessages.some(
|
|
821
|
+
(message) => messageContainsExactPlanModeImplementationHandoff(message, activeImplementation.plan)
|
|
822
|
+
);
|
|
823
|
+
if (!deliveredCurrentHandoff) return { messages: contextualMessages };
|
|
824
|
+
restoredImplementationAwaitingContext = void 0;
|
|
825
|
+
if (activeImplementation.retention === "clear-after-first-run") {
|
|
826
|
+
implementationWithDeliveredContext = activeImplementation.id;
|
|
827
|
+
}
|
|
828
|
+
return {
|
|
829
|
+
messages: contextualMessages,
|
|
830
|
+
clearActiveImplementationId: activeImplementation.retention === "clear-on-start" ? activeImplementation.id : void 0
|
|
831
|
+
};
|
|
832
|
+
},
|
|
833
|
+
implementationSettled(activeImplementation) {
|
|
834
|
+
if (activeImplementation?.retention !== "clear-after-first-run" || implementationWithDeliveredContext !== activeImplementation.id) {
|
|
835
|
+
return void 0;
|
|
836
|
+
}
|
|
837
|
+
implementationWithDeliveredContext = void 0;
|
|
838
|
+
return activeImplementation.id;
|
|
839
|
+
},
|
|
840
|
+
reset() {
|
|
841
|
+
implementationWithDeliveredContext = void 0;
|
|
842
|
+
restoredImplementationAwaitingContext = void 0;
|
|
843
|
+
}
|
|
844
|
+
};
|
|
845
|
+
}
|
|
846
|
+
|
|
767
847
|
// src/plan-export.ts
|
|
768
848
|
import { mkdir as mkdir2, writeFile as writeFile2 } from "node:fs/promises";
|
|
769
849
|
import { dirname as dirname2, resolve } from "node:path";
|
|
@@ -1771,10 +1851,12 @@ export {
|
|
|
1771
1851
|
latestAssistantText,
|
|
1772
1852
|
latestAssistantStopReason,
|
|
1773
1853
|
messageTextContent,
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1854
|
+
MAX_PENDING_IMPLEMENTATION_MODEL_IDENTIFIER_LENGTH,
|
|
1855
|
+
isPendingImplementationModelIdentifier,
|
|
1856
|
+
snapshotAvailableImplementationModels,
|
|
1857
|
+
findAvailableImplementationModel,
|
|
1777
1858
|
PLAN_MODE_THINKING_LEVELS,
|
|
1859
|
+
IMPLEMENTATION_THINKING_LEVELS,
|
|
1778
1860
|
IMPLEMENTATION_PLAN_RETENTIONS,
|
|
1779
1861
|
planModeSettingsPath,
|
|
1780
1862
|
normalizeKeyId,
|
|
@@ -1783,8 +1865,13 @@ export {
|
|
|
1783
1865
|
awaitPlanModeSettingsWrites,
|
|
1784
1866
|
configuredThinkingLevel,
|
|
1785
1867
|
configuredImplementationPlanRetention,
|
|
1868
|
+
configuredImplementationModel,
|
|
1869
|
+
configuredImplementationThinkingLevel,
|
|
1786
1870
|
configuredPlanExportPath,
|
|
1787
1871
|
configuredPlanModeToggleShortcut,
|
|
1872
|
+
retentionLabel,
|
|
1873
|
+
implementationRetentionPreview,
|
|
1874
|
+
createImplementationRetentionCoordinator,
|
|
1788
1875
|
exportStoredPlan,
|
|
1789
1876
|
planExportDestination,
|
|
1790
1877
|
PLAN_MODE_QUESTION_TOOL_NAME,
|
|
@@ -1802,4 +1889,4 @@ export {
|
|
|
1802
1889
|
defaultPlanModeToolNames,
|
|
1803
1890
|
snapshotPlanModeSelectedNames
|
|
1804
1891
|
};
|
|
1805
|
-
//# sourceMappingURL=chunk-
|
|
1892
|
+
//# sourceMappingURL=chunk-QHHHBTDO.js.map
|