@narumitw/pi-plan-mode 0.60.0 → 0.60.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.
- package/CHANGELOG.md +10 -0
- package/README.md +1 -0
- package/dist/index.ts +55 -24
- package/dist/index.ts.map +2 -2
- package/package.json +2 -2
- package/src/plan-mode.ts +11 -1
- package/src/presentation.ts +61 -25
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@narumitw/pi-plan-mode",
|
|
3
|
-
"version": "0.60.
|
|
3
|
+
"version": "0.60.1",
|
|
4
4
|
"description": "Pi extension that adds a Codex-like read-only /plan collaboration mode.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,6 +48,6 @@
|
|
|
48
48
|
"directory": "packages/pi-plan-mode"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@narumitw/pi-tui-kit": "^0.
|
|
51
|
+
"@narumitw/pi-tui-kit": "^0.70.0"
|
|
52
52
|
}
|
|
53
53
|
}
|
package/src/plan-mode.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
InputEvent,
|
|
10
10
|
InputSource,
|
|
11
11
|
} from "@earendil-works/pi-coding-agent";
|
|
12
|
+
import type { EditorStatusWidgetState } from "@narumitw/pi-tui-kit/editor-status-widget";
|
|
12
13
|
import { completePlanArguments } from "./command.js";
|
|
13
14
|
import {
|
|
14
15
|
normalizePlanModeCompletion,
|
|
@@ -167,6 +168,7 @@ export default function planMode(pi: ExtensionAPI, dependencies: PlanModeDepende
|
|
|
167
168
|
let workflowOwner: WorkflowMutexOwner | undefined;
|
|
168
169
|
let currentSession: object | undefined;
|
|
169
170
|
let currentSessionContext: ExtensionContext | undefined;
|
|
171
|
+
let widgetState: EditorStatusWidgetState = { collapsed: false };
|
|
170
172
|
let interactiveUiPromise: Promise<InteractiveUi> | undefined;
|
|
171
173
|
const loadInteractiveUi = () => {
|
|
172
174
|
if (dependencies.loadInteractiveUi) return dependencies.loadInteractiveUi();
|
|
@@ -409,6 +411,11 @@ export default function planMode(pi: ExtensionAPI, dependencies: PlanModeDepende
|
|
|
409
411
|
"The interactive /plan menu is unavailable in print and JSON modes. Use /plan start or /plan <prompt>.",
|
|
410
412
|
);
|
|
411
413
|
}
|
|
414
|
+
// Opening the existing manager restores the summary without changing Plan mode.
|
|
415
|
+
if (ctx.mode === "tui" && widgetState.collapsed) {
|
|
416
|
+
widgetState.collapsed = false;
|
|
417
|
+
updateUi(ctx);
|
|
418
|
+
}
|
|
412
419
|
if (!state.enabled) {
|
|
413
420
|
if (state.activeImplementation && ctx.hasUI) {
|
|
414
421
|
await showActivePlanMenu(ctx);
|
|
@@ -515,6 +522,7 @@ export default function planMode(pi: ExtensionAPI, dependencies: PlanModeDepende
|
|
|
515
522
|
cancelDeferredFreshImplementation();
|
|
516
523
|
const generation = ++menuGeneration;
|
|
517
524
|
finalizationRequest.reset();
|
|
525
|
+
widgetState = { collapsed: false };
|
|
518
526
|
currentSession = ctx.sessionManager;
|
|
519
527
|
currentSessionContext = ctx;
|
|
520
528
|
workflowOwner = undefined;
|
|
@@ -665,6 +673,7 @@ export default function planMode(pi: ExtensionAPI, dependencies: PlanModeDepende
|
|
|
665
673
|
if (currentSession === ctx.sessionManager) {
|
|
666
674
|
currentSession = undefined;
|
|
667
675
|
currentSessionContext = undefined;
|
|
676
|
+
widgetState = { collapsed: false };
|
|
668
677
|
}
|
|
669
678
|
});
|
|
670
679
|
|
|
@@ -2065,6 +2074,7 @@ export default function planMode(pi: ExtensionAPI, dependencies: PlanModeDepende
|
|
|
2065
2074
|
|
|
2066
2075
|
function bindWorkflowSessionIfNeeded(ctx: ExtensionContext) {
|
|
2067
2076
|
if (currentSession === ctx.sessionManager) return;
|
|
2077
|
+
widgetState = { collapsed: false };
|
|
2068
2078
|
currentSession = ctx.sessionManager;
|
|
2069
2079
|
workflowOwner = undefined;
|
|
2070
2080
|
workflowMutex.bindSession(ctx.sessionManager);
|
|
@@ -2108,7 +2118,7 @@ export default function planMode(pi: ExtensionAPI, dependencies: PlanModeDepende
|
|
|
2108
2118
|
}
|
|
2109
2119
|
|
|
2110
2120
|
function updateUi(ctx: ExtensionContext) {
|
|
2111
|
-
updatePlanModeUi(ctx, state, formatToolSummary, interaction.shortcutLabel(ctx));
|
|
2121
|
+
updatePlanModeUi(ctx, state, formatToolSummary, interaction.shortcutLabel(ctx), widgetState);
|
|
2112
2122
|
}
|
|
2113
2123
|
|
|
2114
2124
|
function clearUi(ctx: ExtensionContext) {
|
package/src/presentation.ts
CHANGED
|
@@ -1,55 +1,85 @@
|
|
|
1
1
|
import type { ExtensionAPI, ExtensionContext, Theme } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { stripTerminalSequences } from "@earendil-works/pi-tui";
|
|
3
|
-
import { EditorStatusWidget } from "@narumitw/pi-tui-kit/editor-status-widget";
|
|
3
|
+
import { EditorStatusWidget, type EditorStatusWidgetState } from "@narumitw/pi-tui-kit/editor-status-widget";
|
|
4
4
|
import type { PlanModeState } from "./state.js";
|
|
5
5
|
|
|
6
6
|
const STATUS_KEY = "plan-mode";
|
|
7
7
|
const PLAN_WIDGET_KEY = "plan-mode-plan";
|
|
8
8
|
const BIDI_CONTROLS = /[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/gu;
|
|
9
9
|
|
|
10
|
+
interface PlanModeWidgetPresentation {
|
|
11
|
+
summary: string;
|
|
12
|
+
body: readonly string[];
|
|
13
|
+
fallback: readonly string[];
|
|
14
|
+
}
|
|
15
|
+
|
|
10
16
|
export function updatePlanModeUi(
|
|
11
17
|
ctx: ExtensionContext,
|
|
12
18
|
state: PlanModeState,
|
|
13
19
|
toolSummary: () => string,
|
|
14
20
|
interactionShortcut?: string,
|
|
21
|
+
widgetState?: EditorStatusWidgetState,
|
|
15
22
|
) {
|
|
16
23
|
ctx.ui.setStatus(STATUS_KEY, formatStatus(state));
|
|
17
24
|
const discussion = state.interactionMode === "discussion";
|
|
18
25
|
const interactionHint = formatInteractionHint(state, ctx.mode === "tui" ? interactionShortcut : undefined);
|
|
19
|
-
let
|
|
26
|
+
let presentation: PlanModeWidgetPresentation | undefined;
|
|
20
27
|
if (state.enabled && state.latestPlan) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
const actions = "Use /plan to implement, save, revise, or exit Plan mode.";
|
|
29
|
+
presentation = {
|
|
30
|
+
summary: discussion ? "Ready · Free discussion" : "Ready",
|
|
31
|
+
body: ["File edits remain blocked.", actions, interactionHint],
|
|
32
|
+
fallback: [
|
|
33
|
+
"Proposed plan ready",
|
|
34
|
+
...(discussion ? ["Plan mode: free discussion"] : []),
|
|
35
|
+
actions,
|
|
36
|
+
interactionHint,
|
|
37
|
+
],
|
|
38
|
+
};
|
|
27
39
|
} else if (state.enabled) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
discussion
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
40
|
+
const tools = toolSummary();
|
|
41
|
+
const discussionHint = "Plain-text questions are allowed; questionnaires are paused.";
|
|
42
|
+
presentation = {
|
|
43
|
+
summary: discussion ? "Free discussion" : "Planning",
|
|
44
|
+
body: ["File edits remain blocked.", tools, ...(discussion ? [discussionHint] : []), interactionHint],
|
|
45
|
+
fallback: [
|
|
46
|
+
discussion ? "Plan mode: free discussion" : "Plan mode: planning",
|
|
47
|
+
tools,
|
|
48
|
+
discussion ? discussionHint : "Finish with plan_mode_complete when decision-ready.",
|
|
49
|
+
interactionHint,
|
|
50
|
+
],
|
|
51
|
+
};
|
|
36
52
|
} else if (state.savedPlan) {
|
|
37
|
-
|
|
53
|
+
const actions = "Use /plan to show, implement, or clear it.";
|
|
54
|
+
presentation = { summary: "Saved", body: [actions], fallback: ["Plan saved for later", actions] };
|
|
38
55
|
} else if (state.activeImplementation) {
|
|
39
|
-
|
|
56
|
+
const actions = "Use /plan to show, replace, or clear it.";
|
|
57
|
+
presentation = {
|
|
58
|
+
summary: "Implementation active",
|
|
59
|
+
body: [actions],
|
|
60
|
+
fallback: ["Implementation plan active", actions],
|
|
61
|
+
};
|
|
40
62
|
}
|
|
41
63
|
|
|
42
|
-
publishPlanModeWidget(ctx,
|
|
64
|
+
publishPlanModeWidget(ctx, presentation, widgetState);
|
|
43
65
|
}
|
|
44
66
|
|
|
45
67
|
export function renderPlanModeWidget(lines: readonly string[], theme: Theme, width: number): string[] {
|
|
46
68
|
return createPlanModeWidget(lines, theme).render(width);
|
|
47
69
|
}
|
|
48
70
|
|
|
49
|
-
function createPlanModeWidget(
|
|
71
|
+
function createPlanModeWidget(
|
|
72
|
+
lines: readonly string[],
|
|
73
|
+
theme: Theme,
|
|
74
|
+
state?: EditorStatusWidgetState,
|
|
75
|
+
summary?: string,
|
|
76
|
+
): EditorStatusWidget {
|
|
50
77
|
// Kit normalizes fractional and invalid widths before clipping sanitized body rows.
|
|
51
78
|
return new EditorStatusWidget({
|
|
52
79
|
theme,
|
|
80
|
+
name: "Plan mode",
|
|
81
|
+
summary,
|
|
82
|
+
state,
|
|
53
83
|
renderBody: () =>
|
|
54
84
|
lines.map((line, index) => {
|
|
55
85
|
const text = sanitizePlanModeWidgetLine(line);
|
|
@@ -119,18 +149,24 @@ export function planModeStatusText(state: PlanModeState, toolSummary: () => stri
|
|
|
119
149
|
return "Plan mode is off.";
|
|
120
150
|
}
|
|
121
151
|
|
|
122
|
-
function publishPlanModeWidget(
|
|
123
|
-
|
|
152
|
+
function publishPlanModeWidget(
|
|
153
|
+
ctx: ExtensionContext,
|
|
154
|
+
presentation: PlanModeWidgetPresentation | undefined,
|
|
155
|
+
widgetState?: EditorStatusWidgetState,
|
|
156
|
+
) {
|
|
157
|
+
if (!presentation) {
|
|
124
158
|
ctx.ui.setWidget(PLAN_WIDGET_KEY, undefined);
|
|
125
159
|
return;
|
|
126
160
|
}
|
|
127
161
|
if (ctx.mode !== "tui") {
|
|
128
|
-
ctx.ui.setWidget(PLAN_WIDGET_KEY, [...
|
|
162
|
+
ctx.ui.setWidget(PLAN_WIDGET_KEY, [...presentation.fallback]);
|
|
129
163
|
return;
|
|
130
164
|
}
|
|
131
165
|
|
|
132
|
-
const snapshot = [...
|
|
133
|
-
ctx.ui.setWidget(PLAN_WIDGET_KEY, (_tui, theme) =>
|
|
166
|
+
const snapshot = [...presentation.body];
|
|
167
|
+
ctx.ui.setWidget(PLAN_WIDGET_KEY, (_tui, theme) =>
|
|
168
|
+
createPlanModeWidget(snapshot, theme, widgetState, presentation.summary),
|
|
169
|
+
);
|
|
134
170
|
}
|
|
135
171
|
|
|
136
172
|
function formatInteractionHint(state: PlanModeState, interactionShortcut?: string) {
|