@narumitw/pi-plan-mode 0.48.0 → 0.49.2
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 +3 -2
- package/package.json +2 -2
- package/src/interactive-ui.ts +5 -0
- package/src/plan-action-controller.ts +15 -5
- package/src/plan-mode.ts +27 -6
package/README.md
CHANGED
|
@@ -267,8 +267,9 @@ This extension maps Codex's `ModeKind::Plan` behavior onto Pi's extension API:
|
|
|
267
267
|
extensions/pi-plan-mode/
|
|
268
268
|
├── src/
|
|
269
269
|
│ ├── index.ts # Pi package entrypoint
|
|
270
|
-
│ ├── plan-mode.ts
|
|
271
|
-
│
|
|
270
|
+
│ ├── plan-mode.ts # Extension registration, mode state, and UI loading boundary
|
|
271
|
+
│ ├── interactive-ui.ts # Lazily loaded interactive menu surface
|
|
272
|
+
│ └── *.ts # Package-local prompt, policy, question, and message modules
|
|
272
273
|
├── README.md
|
|
273
274
|
├── LICENSE
|
|
274
275
|
├── tsconfig.json
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@narumitw/pi-plan-mode",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.2",
|
|
4
4
|
"description": "Pi extension that adds a Codex-like read-only /plan collaboration mode.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,6 +43,6 @@
|
|
|
43
43
|
"directory": "extensions/pi-plan-mode"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@narumitw/pi-tui-kit": "^0.
|
|
46
|
+
"@narumitw/pi-tui-kit": "^0.49.1"
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { showActiveImplementationMenu } from "./active-implementation-menu.js";
|
|
2
|
+
export { showPlanModeMenu, showReadyPlanMenu } from "./plan-action-menus.js";
|
|
3
|
+
export { showPlanLaunchMenu } from "./plan-launch-menu.js";
|
|
4
|
+
export { showSavedPlanMenu } from "./saved-plan-menu.js";
|
|
5
|
+
export { showPlanModeSettings } from "./settings-menu.js";
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { showPlanModeMenu, showReadyPlanMenu } from "./plan-action-menus.js";
|
|
3
2
|
import type { PlanExportDestination } from "./plan-export.js";
|
|
4
|
-
import { showSavedPlanMenu } from "./saved-plan-menu.js";
|
|
5
3
|
import type { PlanModeState } from "./state.js";
|
|
6
4
|
|
|
5
|
+
type InteractiveUi = typeof import("./interactive-ui.js");
|
|
6
|
+
|
|
7
7
|
interface MenuLifecycle {
|
|
8
8
|
signal: AbortSignal;
|
|
9
9
|
isCurrent(): boolean;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
interface PlanActionControllerOptions {
|
|
13
|
+
loadInteractiveUi(): Promise<InteractiveUi>;
|
|
13
14
|
getState(): PlanModeState;
|
|
14
15
|
captureLifecycle(): MenuLifecycle;
|
|
15
16
|
statusText(): string;
|
|
@@ -39,7 +40,10 @@ export function createPlanActionController(options: PlanActionControllerOptions)
|
|
|
39
40
|
return {
|
|
40
41
|
async showSaved(ctx: ExtensionContext) {
|
|
41
42
|
const lifecycle = options.captureLifecycle();
|
|
42
|
-
|
|
43
|
+
if (!lifecycle.isCurrent() || lifecycle.signal.aborted) return;
|
|
44
|
+
const ui = await options.loadInteractiveUi();
|
|
45
|
+
if (!lifecycle.isCurrent() || lifecycle.signal.aborted) return;
|
|
46
|
+
await ui.showSavedPlanMenu(ctx, {
|
|
43
47
|
statusText: options.statusText(),
|
|
44
48
|
implementationOutcome: options.implementationOutcome,
|
|
45
49
|
getExportDestination: () => options.getExportDestination(ctx),
|
|
@@ -59,7 +63,10 @@ export function createPlanActionController(options: PlanActionControllerOptions)
|
|
|
59
63
|
return;
|
|
60
64
|
}
|
|
61
65
|
const lifecycle = options.captureLifecycle();
|
|
62
|
-
|
|
66
|
+
if (!lifecycle.isCurrent() || lifecycle.signal.aborted) return;
|
|
67
|
+
const ui = await options.loadInteractiveUi();
|
|
68
|
+
if (!lifecycle.isCurrent() || lifecycle.signal.aborted) return;
|
|
69
|
+
await ui.showPlanModeMenu(ctx, {
|
|
63
70
|
statusText: options.statusText(),
|
|
64
71
|
hasReadyPlan: options.getState().latestPlan !== undefined,
|
|
65
72
|
implementationOutcome: options.implementationOutcome,
|
|
@@ -77,7 +84,10 @@ export function createPlanActionController(options: PlanActionControllerOptions)
|
|
|
77
84
|
},
|
|
78
85
|
async showReady(ctx: ExtensionContext) {
|
|
79
86
|
const lifecycle = options.captureLifecycle();
|
|
80
|
-
|
|
87
|
+
if (!lifecycle.isCurrent() || lifecycle.signal.aborted) return;
|
|
88
|
+
const ui = await options.loadInteractiveUi();
|
|
89
|
+
if (!lifecycle.isCurrent() || lifecycle.signal.aborted) return;
|
|
90
|
+
await ui.showReadyPlanMenu(ctx, {
|
|
81
91
|
...lifecycle,
|
|
82
92
|
implementationOutcome: options.implementationOutcome,
|
|
83
93
|
getExportDestination: () => options.getExportDestination(ctx),
|
package/src/plan-mode.ts
CHANGED
|
@@ -4,7 +4,6 @@ import type {
|
|
|
4
4
|
ExtensionCommandContext,
|
|
5
5
|
ExtensionContext,
|
|
6
6
|
} from "@earendil-works/pi-coding-agent";
|
|
7
|
-
import { showActiveImplementationMenu } from "./active-implementation-menu.js";
|
|
8
7
|
import { completePlanArguments } from "./command.js";
|
|
9
8
|
import {
|
|
10
9
|
normalizePlanModeCompletion,
|
|
@@ -29,7 +28,6 @@ import {
|
|
|
29
28
|
import { invalidPlanMessage, latestAssistantText, parseProposedPlan } from "./message-transform.js";
|
|
30
29
|
import { createPlanActionController } from "./plan-action-controller.js";
|
|
31
30
|
import { createPlanExportController } from "./plan-export-controller.js";
|
|
32
|
-
import { showPlanLaunchMenu } from "./plan-launch-menu.js";
|
|
33
31
|
import {
|
|
34
32
|
clearPlanModeUi,
|
|
35
33
|
planModeStatusText as formatPlanModeStatusText,
|
|
@@ -56,7 +54,6 @@ import {
|
|
|
56
54
|
type PlanModeSettings,
|
|
57
55
|
readPlanModeSettings,
|
|
58
56
|
} from "./settings.js";
|
|
59
|
-
import { showPlanModeSettings } from "./settings-menu.js";
|
|
60
57
|
import { type PlanCompletionSource, type PlanModeState, restorePlanModeState } from "./state.js";
|
|
61
58
|
import {
|
|
62
59
|
canSelectToolInPlanMode,
|
|
@@ -81,11 +78,25 @@ interface ReadyPresentationIntent {
|
|
|
81
78
|
plan: string;
|
|
82
79
|
source: PlanCompletionSource;
|
|
83
80
|
}
|
|
81
|
+
type InteractiveUi = typeof import("./interactive-ui.js");
|
|
82
|
+
|
|
84
83
|
interface PlanModeDependencies {
|
|
85
84
|
readSettings?(): ReturnType<typeof readPlanModeSettings>;
|
|
86
85
|
settingsPath?: string;
|
|
86
|
+
loadInteractiveUi?(): Promise<InteractiveUi>;
|
|
87
87
|
}
|
|
88
88
|
export default function planMode(pi: ExtensionAPI, dependencies: PlanModeDependencies = {}) {
|
|
89
|
+
let interactiveUiPromise: Promise<InteractiveUi> | undefined;
|
|
90
|
+
const loadInteractiveUi = () => {
|
|
91
|
+
if (dependencies.loadInteractiveUi) return dependencies.loadInteractiveUi();
|
|
92
|
+
if (!interactiveUiPromise) {
|
|
93
|
+
interactiveUiPromise = import("./interactive-ui.js").catch((error) => {
|
|
94
|
+
interactiveUiPromise = undefined;
|
|
95
|
+
throw error;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return interactiveUiPromise;
|
|
99
|
+
};
|
|
89
100
|
let state: PlanModeState = { enabled: false, awaitingAction: false };
|
|
90
101
|
let settings: PlanModeSettings = { thinkingLevel: "inherit" };
|
|
91
102
|
let previousTools: string[] | undefined;
|
|
@@ -104,6 +115,7 @@ export default function planMode(pi: ExtensionAPI, dependencies: PlanModeDepende
|
|
|
104
115
|
finishReady: (ctx) => exitPlanMode(ctx),
|
|
105
116
|
});
|
|
106
117
|
const planActions = createPlanActionController({
|
|
118
|
+
loadInteractiveUi,
|
|
107
119
|
getState: () => state,
|
|
108
120
|
captureLifecycle: captureMenuLifecycle,
|
|
109
121
|
statusText: planStatusText,
|
|
@@ -721,8 +733,11 @@ export default function planMode(pi: ExtensionAPI, dependencies: PlanModeDepende
|
|
|
721
733
|
|
|
722
734
|
async function showLaunchMenu(ctx: ExtensionContext, initialScreen: "main" | "tools" = "main") {
|
|
723
735
|
const lifecycle = captureMenuLifecycle();
|
|
736
|
+
if (!lifecycle.isCurrent() || lifecycle.signal.aborted) return;
|
|
737
|
+
const ui = await loadInteractiveUi();
|
|
738
|
+
if (!lifecycle.isCurrent() || lifecycle.signal.aborted) return;
|
|
724
739
|
const tools = selectableTools();
|
|
725
|
-
await showPlanLaunchMenu(ctx, {
|
|
740
|
+
await ui.showPlanLaunchMenu(ctx, {
|
|
726
741
|
statusText: "Status: Off — normal tools are active.",
|
|
727
742
|
initialScreen,
|
|
728
743
|
getSelectedNames: () => snapshotPlanModeSelectedNames(tools, toolSelectionSnapshot()),
|
|
@@ -766,7 +781,10 @@ export default function planMode(pi: ExtensionAPI, dependencies: PlanModeDepende
|
|
|
766
781
|
return;
|
|
767
782
|
}
|
|
768
783
|
const lifecycle = captureMenuLifecycle();
|
|
769
|
-
|
|
784
|
+
if (!lifecycle.isCurrent() || lifecycle.signal.aborted) return;
|
|
785
|
+
const ui = await loadInteractiveUi();
|
|
786
|
+
if (!lifecycle.isCurrent() || lifecycle.signal.aborted) return;
|
|
787
|
+
await ui.showActiveImplementationMenu(ctx, {
|
|
770
788
|
statusText: planStatusText(),
|
|
771
789
|
getExportDestination: () => planExports.getDestination(ctx),
|
|
772
790
|
signal: lifecycle.signal,
|
|
@@ -790,7 +808,10 @@ export default function planMode(pi: ExtensionAPI, dependencies: PlanModeDepende
|
|
|
790
808
|
signal: AbortSignal,
|
|
791
809
|
isCurrent: () => boolean,
|
|
792
810
|
) {
|
|
793
|
-
|
|
811
|
+
if (!isCurrent() || signal.aborted) return false;
|
|
812
|
+
const ui = await loadInteractiveUi();
|
|
813
|
+
if (!isCurrent() || signal.aborted) return false;
|
|
814
|
+
const result = await ui.showPlanModeSettings(ctx, {
|
|
794
815
|
tools: selectableTools(),
|
|
795
816
|
signal,
|
|
796
817
|
isCurrent,
|