@narumitw/pi-plan-mode 0.58.2 → 0.58.3
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 +2 -1
- package/dist/chunks/{interactive-ui-VHZ5GODE.ts → interactive-ui-OZA4BHGS.ts} +7 -6
- package/dist/chunks/{interactive-ui-VHZ5GODE.ts.map → interactive-ui-OZA4BHGS.ts.map} +2 -2
- package/dist/index.ts +14 -22
- package/dist/index.ts.map +2 -2
- package/docs/settings.md +9 -4
- package/package.json +1 -1
- package/src/plan-mode.ts +15 -20
- package/src/settings-menu.ts +9 -6
package/docs/settings.md
CHANGED
|
@@ -117,10 +117,15 @@ Long previews wrap or truncate to the available terminal width without changing
|
|
|
117
117
|
|
|
118
118
|
### Toggle shortcut
|
|
119
119
|
|
|
120
|
-
`toggleShortcut`
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
120
|
+
`toggleShortcut` configures the Plan-mode toggle in TUI mode; it is disabled by default.
|
|
121
|
+
Set it to a Pi key identifier, or omit it to disable the shortcut on the next load.
|
|
122
|
+
Enabling, changing, or removing the shortcut requires `/reload` or restarting Pi, whether saved through Settings or edited in JSON.
|
|
123
|
+
The current binding stays unchanged until then; Settings shows the configured value separately from the value loaded at startup.
|
|
124
|
+
Pi snapshots shortcut registrations when binding the editor, so Plan mode registers once per extension runtime rather than attempting live rebinding.
|
|
125
|
+
Other settings retain their existing watched reload behavior, and `/plan` commands are unchanged.
|
|
126
|
+
|
|
127
|
+
Avoid conflicts with Pi or other extension shortcuts; the startup value is a registration preference, not a guarantee that Pi accepts it or the terminal sends that key combination.
|
|
128
|
+
Tree navigation and compaction do not apply pending shortcut changes.
|
|
124
129
|
|
|
125
130
|
### Safe shell subcommands
|
|
126
131
|
|
package/package.json
CHANGED
package/src/plan-mode.ts
CHANGED
|
@@ -171,8 +171,8 @@ export default function planMode(pi: ExtensionAPI, dependencies: PlanModeDepende
|
|
|
171
171
|
const explicitPlanModeSettingsPath = dependencies.settingsPath;
|
|
172
172
|
let state: PlanModeState = { enabled: false, awaitingAction: false };
|
|
173
173
|
let settings: PlanModeSettings = { thinkingLevel: "inherit" };
|
|
174
|
-
let
|
|
175
|
-
|
|
174
|
+
let startupToggleShortcut: ReturnType<typeof configuredPlanModeToggleShortcut>;
|
|
175
|
+
let shortcutInitialized = false;
|
|
176
176
|
let workflowAllowedToolNames: string[] | undefined;
|
|
177
177
|
let pendingWorkflowToolPolicy: PendingWorkflowToolPolicy | undefined;
|
|
178
178
|
let publishedContractMode: PlanModeContract | undefined;
|
|
@@ -389,24 +389,19 @@ export default function planMode(pi: ExtensionAPI, dependencies: PlanModeDepende
|
|
|
389
389
|
},
|
|
390
390
|
});
|
|
391
391
|
|
|
392
|
-
const
|
|
393
|
-
if (
|
|
394
|
-
|
|
395
|
-
|
|
392
|
+
const initializePlanModeShortcut = () => {
|
|
393
|
+
if (shortcutInitialized) return;
|
|
394
|
+
// Pi snapshots registrations when binding the editor. Keep even an unset shortcut stable
|
|
395
|
+
// for this runtime; settings saves and file watches take effect after /reload or restart.
|
|
396
|
+
const shortcut = configuredPlanModeToggleShortcut(settings);
|
|
397
|
+
if (shortcut) {
|
|
398
|
+
pi.registerShortcut(shortcut, {
|
|
399
|
+
description: "Toggle Plan mode",
|
|
400
|
+
handler: (ctx) => togglePlanMode(ctx),
|
|
396
401
|
});
|
|
397
402
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
return;
|
|
401
|
-
}
|
|
402
|
-
if (toggleShortcut === nextShortcut) return;
|
|
403
|
-
pi.registerShortcut(nextShortcut, {
|
|
404
|
-
description: "Toggle Plan mode",
|
|
405
|
-
handler: (ctx) => {
|
|
406
|
-
togglePlanMode(ctx);
|
|
407
|
-
},
|
|
408
|
-
});
|
|
409
|
-
toggleShortcut = nextShortcut;
|
|
403
|
+
startupToggleShortcut = shortcut;
|
|
404
|
+
shortcutInitialized = true;
|
|
410
405
|
};
|
|
411
406
|
|
|
412
407
|
const readPlanModeRuntimeSettings = async () => {
|
|
@@ -426,7 +421,6 @@ export default function planMode(pi: ExtensionAPI, dependencies: PlanModeDepende
|
|
|
426
421
|
loadedSettings.kind === "loaded"
|
|
427
422
|
? loadedSettings.settings
|
|
428
423
|
: ({ thinkingLevel: "inherit" } satisfies PlanModeSettings);
|
|
429
|
-
applyPlanModeShortcut(configuredPlanModeToggleShortcut(settings));
|
|
430
424
|
if (!ctx || !showWarnings) return loadedSettings;
|
|
431
425
|
if (loadedSettings.kind === "invalid") {
|
|
432
426
|
ctx.ui.notify(`pi-plan-mode settings ignored: ${loadedSettings.reason}`, "warning");
|
|
@@ -503,6 +497,7 @@ export default function planMode(pi: ExtensionAPI, dependencies: PlanModeDepende
|
|
|
503
497
|
state = { enabled: false, awaitingAction: false };
|
|
504
498
|
await applyPlanModeSettings(generation, ctx, true);
|
|
505
499
|
if (generation !== menuGeneration || menuController.signal.aborted) return;
|
|
500
|
+
initializePlanModeShortcut();
|
|
506
501
|
startPlanModeSettingsWatch(generation);
|
|
507
502
|
if (!installRestoredState(restoredState, ctx)) return;
|
|
508
503
|
implementationRetention.restore(state.activeImplementation);
|
|
@@ -1418,10 +1413,10 @@ export default function planMode(pi: ExtensionAPI, dependencies: PlanModeDepende
|
|
|
1418
1413
|
isCurrent,
|
|
1419
1414
|
settingsPath: dependencies.settingsPath,
|
|
1420
1415
|
updateSettings: dependencies.updateSettings ?? updatePlanModeSettings,
|
|
1416
|
+
startupToggleShortcut,
|
|
1421
1417
|
onSaved: (saved) => {
|
|
1422
1418
|
if (!isCurrent()) return;
|
|
1423
1419
|
settings = saved;
|
|
1424
|
-
applyPlanModeShortcut(configuredPlanModeToggleShortcut(saved));
|
|
1425
1420
|
},
|
|
1426
1421
|
...(dependencies.readSettings
|
|
1427
1422
|
? { readSettings: async () => dependencies.readSettings?.() ?? { kind: "missing" } }
|
package/src/settings-menu.ts
CHANGED
|
@@ -45,6 +45,7 @@ export interface PlanModeSettingsMenuOptions {
|
|
|
45
45
|
isCurrent(): boolean;
|
|
46
46
|
settingsPath?: string;
|
|
47
47
|
legacySettingsPath?: string;
|
|
48
|
+
startupToggleShortcut?: PlanModeSettings["toggleShortcut"];
|
|
48
49
|
readSettings?: (settingsPath?: string) => Promise<PlanModeSettingsLoadResult>;
|
|
49
50
|
updateSettings?: (patch: PlanModeSettingsPatch, options?: UpdatePlanModeSettingsOptions) => Promise<PlanModeSettings>;
|
|
50
51
|
onSaved(settings: PlanModeSettings): void;
|
|
@@ -159,7 +160,8 @@ export async function showPlanModeSettings(
|
|
|
159
160
|
{
|
|
160
161
|
id: "toggleShortcut",
|
|
161
162
|
label: "Plan mode shortcut",
|
|
162
|
-
description:
|
|
163
|
+
description:
|
|
164
|
+
"Saved TUI shortcut. Changes require /reload or restarting Pi; the current binding stays unchanged.",
|
|
163
165
|
currentValue: configuredPlanModeToggleShortcut(state.settings) ?? "none",
|
|
164
166
|
action: "open-shortcut",
|
|
165
167
|
},
|
|
@@ -222,9 +224,10 @@ export async function showPlanModeSettings(
|
|
|
222
224
|
title: "Plan mode shortcut",
|
|
223
225
|
lines: [
|
|
224
226
|
`Configured: ${configuredPlanModeToggleShortcut(state.settings) ?? "none"}`,
|
|
225
|
-
|
|
226
|
-
"
|
|
227
|
-
"
|
|
227
|
+
`Loaded at startup: ${safeTerminalText(options.startupToggleShortcut ?? "none")}`,
|
|
228
|
+
"TUI only. Use Pi key identifiers; Pi may reject conflicting shortcuts.",
|
|
229
|
+
"Submit an empty value to remove the saved shortcut.",
|
|
230
|
+
"Run /reload or restart Pi to apply changes; the current binding stays unchanged until then.",
|
|
228
231
|
],
|
|
229
232
|
placeholder: configuredPlanModeToggleShortcut(state.settings) ?? "",
|
|
230
233
|
action: "set-shortcut",
|
|
@@ -322,8 +325,8 @@ export async function showPlanModeSettings(
|
|
|
322
325
|
{ toggleShortcut },
|
|
323
326
|
signal,
|
|
324
327
|
toggleShortcut
|
|
325
|
-
? `Plan mode shortcut: ${safeTerminalText(toggleShortcut)}.`
|
|
326
|
-
: "Plan mode shortcut
|
|
328
|
+
? `Plan mode shortcut saved: ${safeTerminalText(toggleShortcut)}. Run /reload or restart Pi to apply; the current binding is unchanged.`
|
|
329
|
+
: "Plan mode shortcut removal saved. Run /reload or restart Pi to apply; the current binding is unchanged.",
|
|
327
330
|
);
|
|
328
331
|
return result.kind === "stay" ? { kind: "to", screen: "settings" } : result;
|
|
329
332
|
},
|