@narumitw/pi-plan-mode 0.58.0 → 0.58.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/dist/chunks/{chunk-QHHHBTDO.js → chunk-HF7ZEYIC.js} +29 -111
- package/dist/chunks/chunk-HF7ZEYIC.js.map +7 -0
- package/dist/chunks/{interactive-ui-UNJGC2RQ.js → interactive-ui-UK7IGPOE.js} +13 -41
- package/dist/chunks/interactive-ui-UK7IGPOE.js.map +7 -0
- package/dist/index.ts +25 -82
- package/dist/index.ts.map +2 -2
- package/package.json +50 -51
- package/src/active-implementation-menu.ts +57 -60
- package/src/command.ts +22 -22
- package/src/completion-tool.ts +53 -56
- package/src/extension-runtime.ts +5 -5
- package/src/finalization-request.ts +40 -44
- package/src/fresh-handoff-coordinator.ts +38 -41
- package/src/fresh-implementation.ts +293 -310
- package/src/implementation-models.ts +25 -30
- package/src/implementation-retention.ts +109 -123
- package/src/message-transform.ts +218 -252
- package/src/mode-contract.ts +46 -49
- package/src/plan-action-controller.ts +134 -155
- package/src/plan-action-menus.ts +390 -408
- package/src/plan-export-controller.ts +23 -28
- package/src/plan-export-screen.ts +13 -13
- package/src/plan-export.ts +85 -102
- package/src/plan-launch-menu.ts +119 -119
- package/src/plan-mode.ts +2017 -2098
- package/src/presentation.ts +84 -108
- package/src/prompt.ts +1 -1
- package/src/question-tool.ts +239 -267
- package/src/required-tools.ts +15 -19
- package/src/saved-plan-menu.ts +82 -84
- package/src/saved-plan-preflight.ts +29 -33
- package/src/settings-menu.ts +470 -513
- package/src/settings.ts +393 -452
- package/src/state.ts +167 -198
- package/src/tool-policy.ts +634 -699
- package/src/tool-selection.ts +39 -44
- package/src/workflow-mutex.ts +66 -66
- package/dist/chunks/chunk-QHHHBTDO.js.map +0 -7
- package/dist/chunks/interactive-ui-UNJGC2RQ.js.map +0 -7
package/src/presentation.ts
CHANGED
|
@@ -6,136 +6,112 @@ const STATUS_KEY = "plan-mode";
|
|
|
6
6
|
const PLAN_WIDGET_KEY = "plan-mode-plan";
|
|
7
7
|
const BIDI_CONTROLS = /[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/gu;
|
|
8
8
|
|
|
9
|
-
export function updatePlanModeUi(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
toolSummary(),
|
|
22
|
-
"Finish with plan_mode_complete when decision-ready.",
|
|
23
|
-
];
|
|
24
|
-
} else if (state.savedPlan) {
|
|
25
|
-
lines = ["Plan saved for later", "Use /plan to show, implement, or clear it."];
|
|
26
|
-
} else if (state.activeImplementation) {
|
|
27
|
-
lines = ["Implementation plan active", "Use /plan to show, replace, or clear it."];
|
|
28
|
-
}
|
|
9
|
+
export function updatePlanModeUi(ctx: ExtensionContext, state: PlanModeState, toolSummary: () => string) {
|
|
10
|
+
ctx.ui.setStatus(STATUS_KEY, formatStatus(state));
|
|
11
|
+
let lines: string[] | undefined;
|
|
12
|
+
if (state.enabled && state.latestPlan) {
|
|
13
|
+
lines = ["Proposed plan ready", "Use /plan to implement, save, revise, or exit Plan mode."];
|
|
14
|
+
} else if (state.enabled) {
|
|
15
|
+
lines = ["Plan mode: planning", toolSummary(), "Finish with plan_mode_complete when decision-ready."];
|
|
16
|
+
} else if (state.savedPlan) {
|
|
17
|
+
lines = ["Plan saved for later", "Use /plan to show, implement, or clear it."];
|
|
18
|
+
} else if (state.activeImplementation) {
|
|
19
|
+
lines = ["Implementation plan active", "Use /plan to show, replace, or clear it."];
|
|
20
|
+
}
|
|
29
21
|
|
|
30
|
-
|
|
22
|
+
publishPlanModeWidget(ctx, lines);
|
|
31
23
|
}
|
|
32
24
|
|
|
33
|
-
export function renderPlanModeWidget(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
return [
|
|
40
|
-
theme.fg("borderMuted", "─".repeat(renderWidth)),
|
|
41
|
-
...lines.map((line) => truncateToWidth(sanitizePlanModeWidgetLine(line), renderWidth, "")),
|
|
42
|
-
];
|
|
25
|
+
export function renderPlanModeWidget(lines: readonly string[], theme: Theme, width: number): string[] {
|
|
26
|
+
const renderWidth = Math.max(0, width);
|
|
27
|
+
return [
|
|
28
|
+
theme.fg("borderMuted", "─".repeat(renderWidth)),
|
|
29
|
+
...lines.map((line) => truncateToWidth(sanitizePlanModeWidgetLine(line), renderWidth, "")),
|
|
30
|
+
];
|
|
43
31
|
}
|
|
44
32
|
|
|
45
33
|
export function sanitizePlanModeWidgetLine(value: string): string {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
34
|
+
let text = "";
|
|
35
|
+
for (const character of stripTerminalSequences(value).replace(BIDI_CONTROLS, "")) {
|
|
36
|
+
const codePoint = character.codePointAt(0) ?? 0;
|
|
37
|
+
const isControl = codePoint <= 0x1f || (codePoint >= 0x7f && codePoint <= 0x9f);
|
|
38
|
+
text += isControl ? " " : character;
|
|
39
|
+
}
|
|
40
|
+
return text;
|
|
53
41
|
}
|
|
54
42
|
|
|
55
43
|
export function clearPlanModeUi(ctx: ExtensionContext) {
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
ctx.ui.setStatus(STATUS_KEY, undefined);
|
|
45
|
+
ctx.ui.setWidget(PLAN_WIDGET_KEY, undefined);
|
|
58
46
|
}
|
|
59
47
|
|
|
60
48
|
export function showStoredPlan(pi: ExtensionAPI, ctx: ExtensionContext, state: PlanModeState) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
const title = readyPlan
|
|
76
|
-
? "Proposed Plan"
|
|
77
|
-
: savedPlan
|
|
78
|
-
? "Saved Plan"
|
|
79
|
-
: "Active Implementation Plan";
|
|
80
|
-
showPlanModePlan(pi, ctx, title, plan);
|
|
49
|
+
const readyPlan = state.enabled ? state.latestPlan?.trim() : undefined;
|
|
50
|
+
const savedPlan = state.savedPlan?.plan.trim();
|
|
51
|
+
if (savedPlan && (ctx.mode === "print" || ctx.mode === "json")) {
|
|
52
|
+
throw new Error("Saved plan display is unavailable in print/JSON mode. Use TUI or RPC.");
|
|
53
|
+
}
|
|
54
|
+
const activePlan = state.activeImplementation?.plan.trim();
|
|
55
|
+
const plan = readyPlan ?? savedPlan ?? activePlan;
|
|
56
|
+
if (!plan) {
|
|
57
|
+
ctx.ui.notify("No completed plan is available. Use /plan finalize when planning is complete.", "info");
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const title = readyPlan ? "Proposed Plan" : savedPlan ? "Saved Plan" : "Active Implementation Plan";
|
|
61
|
+
showPlanModePlan(pi, ctx, title, plan);
|
|
81
62
|
}
|
|
82
63
|
|
|
83
|
-
export function showPlanModePlan(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
);
|
|
98
|
-
} catch (error: unknown) {
|
|
99
|
-
const detail = error instanceof Error ? error.message : String(error);
|
|
100
|
-
ctx.ui.notify(`Unable to show completed plan: ${detail}`, "error");
|
|
101
|
-
}
|
|
64
|
+
export function showPlanModePlan(pi: ExtensionAPI, ctx: ExtensionContext, title: string, plan: string) {
|
|
65
|
+
try {
|
|
66
|
+
pi.sendMessage(
|
|
67
|
+
{
|
|
68
|
+
customType: "proposed-plan",
|
|
69
|
+
content: `**${title}**\n\n${plan}`,
|
|
70
|
+
display: true,
|
|
71
|
+
},
|
|
72
|
+
{ triggerTurn: false },
|
|
73
|
+
);
|
|
74
|
+
} catch (error: unknown) {
|
|
75
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
76
|
+
ctx.ui.notify(`Unable to show completed plan: ${detail}`, "error");
|
|
77
|
+
}
|
|
102
78
|
}
|
|
103
79
|
|
|
104
80
|
export function planModeStatusText(state: PlanModeState, toolSummary: () => string) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
81
|
+
if (state.enabled) {
|
|
82
|
+
if (state.latestPlan) {
|
|
83
|
+
return `Plan mode is active and a proposed plan is ready. ${toolSummary()}`;
|
|
84
|
+
}
|
|
85
|
+
return `Plan mode is active. ${toolSummary()} Explore, ask, and finish with plan_mode_complete when decision-ready.`;
|
|
86
|
+
}
|
|
87
|
+
if (state.savedPlan) return "A plan is saved for later.";
|
|
88
|
+
if (state.activeImplementation) return "An implementation plan is active.";
|
|
89
|
+
return "Plan mode is off.";
|
|
114
90
|
}
|
|
115
91
|
|
|
116
92
|
function publishPlanModeWidget(ctx: ExtensionContext, lines: readonly string[] | undefined) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
93
|
+
if (!lines) {
|
|
94
|
+
ctx.ui.setWidget(PLAN_WIDGET_KEY, undefined);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (ctx.mode !== "tui") {
|
|
98
|
+
ctx.ui.setWidget(PLAN_WIDGET_KEY, [...lines]);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
125
101
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
102
|
+
const snapshot = [...lines];
|
|
103
|
+
ctx.ui.setWidget(PLAN_WIDGET_KEY, (_tui, theme) => ({
|
|
104
|
+
render: (width) => renderPlanModeWidget(snapshot, theme, width),
|
|
105
|
+
invalidate: () => {},
|
|
106
|
+
}));
|
|
131
107
|
}
|
|
132
108
|
|
|
133
109
|
function formatStatus(state: PlanModeState) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
110
|
+
if (state.enabled) {
|
|
111
|
+
if (state.awaitingAction || state.latestPlan) return "plan ready";
|
|
112
|
+
return "plan active";
|
|
113
|
+
}
|
|
114
|
+
if (state.savedPlan) return "plan saved";
|
|
115
|
+
if (state.activeImplementation) return "plan implementing";
|
|
116
|
+
return undefined;
|
|
141
117
|
}
|
package/src/prompt.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const PLAN_CONTEXT_MARKER = "[CODEX-LIKE PLAN MODE ACTIVE]";
|
|
2
2
|
|
|
3
3
|
export function buildPlanModePrompt() {
|
|
4
|
-
|
|
4
|
+
return `${PLAN_CONTEXT_MARKER}
|
|
5
5
|
# Plan Mode (Conversational)
|
|
6
6
|
|
|
7
7
|
You are in Plan Mode, a Codex-like collaboration mode for producing a decision-complete implementation plan. Chat your way to the plan before finalizing it. A final plan must leave no implementation decisions unresolved.
|