@narumitw/pi-plan-mode 0.50.0 → 0.50.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/README.md +10 -1
- package/dist/chunks/chunk-6SDTCIHD.ts +1490 -0
- package/dist/chunks/chunk-6SDTCIHD.ts.map +7 -0
- package/dist/chunks/interactive-ui-JBSBPK6S.ts +715 -0
- package/dist/chunks/interactive-ui-JBSBPK6S.ts.map +7 -0
- package/dist/index.ts +1497 -0
- package/dist/index.ts.map +7 -0
- package/package.json +8 -4
|
@@ -0,0 +1,715 @@
|
|
|
1
|
+
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
|
+
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
|
+
import {
|
|
4
|
+
IMPLEMENTATION_PLAN_RETENTIONS,
|
|
5
|
+
PLAN_MODE_COMPLETE_TOOL_NAME,
|
|
6
|
+
PLAN_MODE_QUESTION_TOOL_NAME,
|
|
7
|
+
PLAN_MODE_THINKING_LEVELS,
|
|
8
|
+
canSelectToolInPlanMode,
|
|
9
|
+
configuredImplementationPlanRetention,
|
|
10
|
+
configuredPlanExportPath,
|
|
11
|
+
configuredPlanModeToggleShortcut,
|
|
12
|
+
defaultPlanModeToolNames,
|
|
13
|
+
normalizeKeyId,
|
|
14
|
+
planExportDestination,
|
|
15
|
+
planModeSettingsPath,
|
|
16
|
+
readPlanModeSettings,
|
|
17
|
+
retentionLabel,
|
|
18
|
+
toolPolicyLabel,
|
|
19
|
+
updatePlanModeSettings
|
|
20
|
+
} from "./chunk-6SDTCIHD.js";
|
|
21
|
+
|
|
22
|
+
// src/active-implementation-menu.ts
|
|
23
|
+
import { defineMenu, runMenu } from "@narumitw/pi-tui-kit";
|
|
24
|
+
|
|
25
|
+
// src/plan-export-screen.ts
|
|
26
|
+
function planExportInputScreen(getDestination) {
|
|
27
|
+
const destination = getDestination();
|
|
28
|
+
return {
|
|
29
|
+
kind: "input",
|
|
30
|
+
title: "Export plan",
|
|
31
|
+
lines: [
|
|
32
|
+
"Existing paths are never overwritten.",
|
|
33
|
+
`Default: ${destination.configuredPath}`,
|
|
34
|
+
`Resolves to: ${destination.resolvedPath}`
|
|
35
|
+
],
|
|
36
|
+
placeholder: destination.configuredPath,
|
|
37
|
+
action: "export",
|
|
38
|
+
hint: "back"
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// src/active-implementation-menu.ts
|
|
43
|
+
async function showActiveImplementationMenu(ctx, options) {
|
|
44
|
+
const menu = defineMenu({
|
|
45
|
+
start: "active",
|
|
46
|
+
screens: {
|
|
47
|
+
active: () => ({
|
|
48
|
+
kind: "actions",
|
|
49
|
+
title: "Active implementation plan",
|
|
50
|
+
lines: [options.statusText],
|
|
51
|
+
items: [
|
|
52
|
+
{ id: "show", label: "Show active implementation plan", action: "show" },
|
|
53
|
+
{ id: "export", label: "Export plan\u2026", to: "export" },
|
|
54
|
+
{ id: "settings", label: "Settings", action: "settings" },
|
|
55
|
+
{ id: "start-new", label: "Start a new plan", action: "start-new" },
|
|
56
|
+
{ id: "clear", label: "Clear active implementation plan", action: "clear" }
|
|
57
|
+
],
|
|
58
|
+
hint: "close"
|
|
59
|
+
}),
|
|
60
|
+
export: () => planExportInputScreen(options.getExportDestination)
|
|
61
|
+
},
|
|
62
|
+
actions: {
|
|
63
|
+
show: async () => {
|
|
64
|
+
options.show();
|
|
65
|
+
return { kind: "close" };
|
|
66
|
+
},
|
|
67
|
+
export: async ({ value, signal }) => await options.exportPlan(value ?? "", signal) ? { kind: "close" } : { kind: "rejected" },
|
|
68
|
+
settings: async ({ signal }) => {
|
|
69
|
+
const close = await options.settings(signal);
|
|
70
|
+
if (signal.aborted || !options.isCurrent()) return { kind: "rejected" };
|
|
71
|
+
return close ? { kind: "close" } : { kind: "stay" };
|
|
72
|
+
},
|
|
73
|
+
"start-new": async () => {
|
|
74
|
+
options.startNew();
|
|
75
|
+
return { kind: "close" };
|
|
76
|
+
},
|
|
77
|
+
clear: async () => {
|
|
78
|
+
options.clear();
|
|
79
|
+
return { kind: "close" };
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
await runMenu(ctx, menu, {
|
|
84
|
+
getState: () => void 0,
|
|
85
|
+
signal: options.signal,
|
|
86
|
+
isCurrent: options.isCurrent
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// src/plan-action-menus.ts
|
|
91
|
+
import { defineMenu as defineMenu2, runMenu as runMenu2 } from "@narumitw/pi-tui-kit";
|
|
92
|
+
var IMPLEMENTATION_CONTEXT_LINES = [
|
|
93
|
+
"Implement here keeps this planning conversation.",
|
|
94
|
+
"Start fresh transfers only the approved plan to a new session."
|
|
95
|
+
];
|
|
96
|
+
async function showPlanModeMenu(ctx, options) {
|
|
97
|
+
const menu = defineMenu2({
|
|
98
|
+
start: "main",
|
|
99
|
+
screens: {
|
|
100
|
+
main: () => ({
|
|
101
|
+
kind: "actions",
|
|
102
|
+
title: "Plan mode",
|
|
103
|
+
lines: [
|
|
104
|
+
options.statusText,
|
|
105
|
+
...options.hasReadyPlan ? [...IMPLEMENTATION_CONTEXT_LINES, options.implementationOutcome()] : []
|
|
106
|
+
],
|
|
107
|
+
items: options.hasReadyPlan ? [
|
|
108
|
+
{ id: "show", label: "Show latest proposed plan", action: "show" },
|
|
109
|
+
{
|
|
110
|
+
id: "implement-here",
|
|
111
|
+
label: "Implement here",
|
|
112
|
+
description: "Continue in this session with the planning conversation.",
|
|
113
|
+
action: "implement-here"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
id: "implement-fresh",
|
|
117
|
+
label: "Start fresh and implement",
|
|
118
|
+
description: "Open a new linked session; transfer only the approved plan.",
|
|
119
|
+
action: "implement-fresh",
|
|
120
|
+
busyLabel: "Starting fresh implementation session\u2026"
|
|
121
|
+
},
|
|
122
|
+
{ id: "export", label: "Export plan\u2026", to: "export" },
|
|
123
|
+
{ id: "save", label: "Save for later", action: "save" },
|
|
124
|
+
{ id: "stay", label: "Stay in Plan mode", action: "stay" },
|
|
125
|
+
{ id: "exit", label: "Discard plan and exit", action: "exit" }
|
|
126
|
+
] : [
|
|
127
|
+
{ id: "finalize", label: "Request final plan", action: "finalize" },
|
|
128
|
+
{ id: "stay", label: "Stay in Plan mode", action: "stay" },
|
|
129
|
+
{ id: "exit", label: "Exit Plan mode", action: "exit" }
|
|
130
|
+
],
|
|
131
|
+
hint: "close"
|
|
132
|
+
}),
|
|
133
|
+
export: () => planExportInputScreen(options.getExportDestination)
|
|
134
|
+
},
|
|
135
|
+
actions: {
|
|
136
|
+
show: async () => {
|
|
137
|
+
options.show();
|
|
138
|
+
return { kind: "close" };
|
|
139
|
+
},
|
|
140
|
+
finalize: async () => {
|
|
141
|
+
options.finalize();
|
|
142
|
+
return { kind: "close" };
|
|
143
|
+
},
|
|
144
|
+
"implement-here": async () => {
|
|
145
|
+
await options.implementHere();
|
|
146
|
+
return { kind: "close" };
|
|
147
|
+
},
|
|
148
|
+
"implement-fresh": async ({ signal }) => {
|
|
149
|
+
await options.implementFresh(signal);
|
|
150
|
+
return { kind: "close" };
|
|
151
|
+
},
|
|
152
|
+
export: async ({ value, signal }) => await options.exportPlan(value ?? "", signal) ? { kind: "close" } : { kind: "rejected" },
|
|
153
|
+
save: async () => {
|
|
154
|
+
options.save();
|
|
155
|
+
return { kind: "close" };
|
|
156
|
+
},
|
|
157
|
+
stay: async () => {
|
|
158
|
+
options.stay();
|
|
159
|
+
return { kind: "close" };
|
|
160
|
+
},
|
|
161
|
+
exit: async () => {
|
|
162
|
+
options.exit();
|
|
163
|
+
return { kind: "close" };
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
await runMenu2(ctx, menu, {
|
|
168
|
+
getState: () => void 0,
|
|
169
|
+
signal: options.signal,
|
|
170
|
+
isCurrent: options.isCurrent
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
async function showReadyPlanMenu(ctx, options) {
|
|
174
|
+
const menu = defineMenu2({
|
|
175
|
+
start: "ready",
|
|
176
|
+
screens: {
|
|
177
|
+
ready: () => ({
|
|
178
|
+
kind: "actions",
|
|
179
|
+
title: "Proposed plan ready. What next?",
|
|
180
|
+
lines: [...IMPLEMENTATION_CONTEXT_LINES, options.implementationOutcome()],
|
|
181
|
+
items: [
|
|
182
|
+
{
|
|
183
|
+
id: "implement-here",
|
|
184
|
+
label: "Implement here",
|
|
185
|
+
description: "Continue in this session with the planning conversation.",
|
|
186
|
+
action: "implement-here"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
id: "implement-fresh",
|
|
190
|
+
label: "Start fresh and implement",
|
|
191
|
+
description: "Open a new linked session; transfer only the approved plan.",
|
|
192
|
+
action: "implement-fresh",
|
|
193
|
+
busyLabel: "Starting fresh implementation session\u2026"
|
|
194
|
+
},
|
|
195
|
+
{ id: "export", label: "Export plan\u2026", to: "export" },
|
|
196
|
+
{ id: "save", label: "Save for later", action: "save" },
|
|
197
|
+
{ id: "stay", label: "Stay in Plan mode", action: "stay" },
|
|
198
|
+
{ id: "exit", label: "Discard plan and exit", action: "exit" }
|
|
199
|
+
],
|
|
200
|
+
hint: "close"
|
|
201
|
+
}),
|
|
202
|
+
export: () => planExportInputScreen(options.getExportDestination)
|
|
203
|
+
},
|
|
204
|
+
actions: {
|
|
205
|
+
"implement-here": async () => {
|
|
206
|
+
await options.implementHere();
|
|
207
|
+
return { kind: "close" };
|
|
208
|
+
},
|
|
209
|
+
"implement-fresh": async ({ signal }) => {
|
|
210
|
+
await options.implementFresh(signal);
|
|
211
|
+
return { kind: "close" };
|
|
212
|
+
},
|
|
213
|
+
export: async ({ value, signal }) => await options.exportPlan(value ?? "", signal) ? { kind: "close" } : { kind: "rejected" },
|
|
214
|
+
save: async () => {
|
|
215
|
+
options.save();
|
|
216
|
+
return { kind: "close" };
|
|
217
|
+
},
|
|
218
|
+
stay: async () => {
|
|
219
|
+
options.stay();
|
|
220
|
+
return { kind: "close" };
|
|
221
|
+
},
|
|
222
|
+
exit: async () => {
|
|
223
|
+
options.exit();
|
|
224
|
+
return { kind: "close" };
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
await runMenu2(ctx, menu, {
|
|
229
|
+
getState: () => void 0,
|
|
230
|
+
signal: options.signal,
|
|
231
|
+
isCurrent: options.isCurrent
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// src/plan-launch-menu.ts
|
|
236
|
+
import { defineMenu as defineMenu3, runMenu as runMenu3 } from "@narumitw/pi-tui-kit";
|
|
237
|
+
async function showPlanLaunchMenu(ctx, options) {
|
|
238
|
+
const selectedNames = new Set(options.getSelectedNames());
|
|
239
|
+
let draftChanged = false;
|
|
240
|
+
const menu = defineMenu3({
|
|
241
|
+
start: options.initialScreen ?? "main",
|
|
242
|
+
screens: {
|
|
243
|
+
main: () => ({
|
|
244
|
+
kind: "actions",
|
|
245
|
+
title: "Plan mode",
|
|
246
|
+
lines: [options.statusText, options.toolSummary(selectedNames)],
|
|
247
|
+
items: [
|
|
248
|
+
{ id: "start", label: "Start Plan mode", action: "start" },
|
|
249
|
+
{ id: "tools", label: "Choose tools, then start\u2026", to: "tools" },
|
|
250
|
+
{ id: "settings", label: "Settings", action: "settings" },
|
|
251
|
+
{ id: "help", label: "How Plan mode works", to: "help" }
|
|
252
|
+
],
|
|
253
|
+
hint: "close"
|
|
254
|
+
}),
|
|
255
|
+
tools: () => ({
|
|
256
|
+
kind: "multiSelect",
|
|
257
|
+
title: "Choose Plan-mode tools",
|
|
258
|
+
lines: [
|
|
259
|
+
"Changes apply only when you start Plan mode.",
|
|
260
|
+
"Non-built-in tools run at user risk."
|
|
261
|
+
],
|
|
262
|
+
enableSearch: true,
|
|
263
|
+
viewportSize: 10,
|
|
264
|
+
items: options.tools.map((tool) => ({
|
|
265
|
+
id: tool.name,
|
|
266
|
+
label: tool.name,
|
|
267
|
+
description: tool.description,
|
|
268
|
+
searchText: tool.searchText,
|
|
269
|
+
selected: selectedNames.has(tool.name),
|
|
270
|
+
disabled: tool.disabled,
|
|
271
|
+
disabledReason: tool.disabledReason
|
|
272
|
+
})),
|
|
273
|
+
action: "toggle-tool",
|
|
274
|
+
actions: [
|
|
275
|
+
{
|
|
276
|
+
id: "start-with-tools",
|
|
277
|
+
label: "Done \u2014 start Plan mode",
|
|
278
|
+
action: "start-with-tools"
|
|
279
|
+
}
|
|
280
|
+
],
|
|
281
|
+
hint: "back"
|
|
282
|
+
}),
|
|
283
|
+
help: () => ({
|
|
284
|
+
kind: "detail",
|
|
285
|
+
title: "How Plan mode works",
|
|
286
|
+
lines: [
|
|
287
|
+
"Plan mode uses read-only exploration to understand the project before implementation.",
|
|
288
|
+
"The agent can ask important decision questions, then returns a complete implementation-ready plan.",
|
|
289
|
+
"File mutation stays blocked until you explicitly choose to implement the completed plan."
|
|
290
|
+
],
|
|
291
|
+
hint: "back"
|
|
292
|
+
})
|
|
293
|
+
},
|
|
294
|
+
actions: {
|
|
295
|
+
start: async ({ signal }) => {
|
|
296
|
+
if (signal.aborted || !options.isCurrent()) return { kind: "rejected" };
|
|
297
|
+
options.start(signal);
|
|
298
|
+
return { kind: "close" };
|
|
299
|
+
},
|
|
300
|
+
"toggle-tool": async ({ itemId, selected, signal }) => {
|
|
301
|
+
if (signal.aborted || !options.isCurrent()) return { kind: "rejected" };
|
|
302
|
+
const tool = options.tools.find((candidate) => candidate.name === itemId);
|
|
303
|
+
if (!tool || tool.disabled) return { kind: "rejected" };
|
|
304
|
+
if (selected) selectedNames.add(tool.name);
|
|
305
|
+
else selectedNames.delete(tool.name);
|
|
306
|
+
draftChanged = true;
|
|
307
|
+
return { kind: "stay" };
|
|
308
|
+
},
|
|
309
|
+
"start-with-tools": async ({ signal }) => {
|
|
310
|
+
if (signal.aborted || !options.isCurrent()) return { kind: "rejected" };
|
|
311
|
+
options.startWithTools(Array.from(selectedNames), signal);
|
|
312
|
+
return { kind: "close" };
|
|
313
|
+
},
|
|
314
|
+
settings: async ({ signal }) => {
|
|
315
|
+
if (signal.aborted || !options.isCurrent()) return { kind: "rejected" };
|
|
316
|
+
const close = await options.settings(signal);
|
|
317
|
+
if (signal.aborted || !options.isCurrent()) return { kind: "rejected" };
|
|
318
|
+
if (close) return { kind: "close" };
|
|
319
|
+
if (!draftChanged) {
|
|
320
|
+
selectedNames.clear();
|
|
321
|
+
for (const name of options.getSelectedNames()) selectedNames.add(name);
|
|
322
|
+
}
|
|
323
|
+
return { kind: "stay" };
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
await runMenu3(ctx, menu, {
|
|
328
|
+
getState: () => void 0,
|
|
329
|
+
signal: options.signal,
|
|
330
|
+
isCurrent: options.isCurrent
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// src/saved-plan-menu.ts
|
|
335
|
+
import { defineMenu as defineMenu4, runMenu as runMenu4 } from "@narumitw/pi-tui-kit";
|
|
336
|
+
async function showSavedPlanMenu(ctx, options) {
|
|
337
|
+
if (!ctx.hasUI) {
|
|
338
|
+
throw new Error(
|
|
339
|
+
`${options.statusText} Use /plan show, /plan implement, /plan export, or /plan exit.`
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
const menu = defineMenu4({
|
|
343
|
+
start: "saved",
|
|
344
|
+
screens: {
|
|
345
|
+
saved: () => ({
|
|
346
|
+
kind: "actions",
|
|
347
|
+
title: "Saved plan",
|
|
348
|
+
lines: [
|
|
349
|
+
options.statusText,
|
|
350
|
+
"Implement here keeps this planning conversation.",
|
|
351
|
+
"Start fresh transfers only the approved plan to a new session.",
|
|
352
|
+
options.implementationOutcome()
|
|
353
|
+
],
|
|
354
|
+
items: [
|
|
355
|
+
{ id: "show", label: "Show saved plan", action: "show" },
|
|
356
|
+
{
|
|
357
|
+
id: "implement-here",
|
|
358
|
+
label: "Implement here",
|
|
359
|
+
description: "Continue in this session with the planning conversation.",
|
|
360
|
+
action: "implement-here"
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
id: "implement-fresh",
|
|
364
|
+
label: "Start fresh and implement",
|
|
365
|
+
description: "Open a new linked session; transfer only the approved plan.",
|
|
366
|
+
action: "implement-fresh",
|
|
367
|
+
busyLabel: "Starting fresh implementation session\u2026"
|
|
368
|
+
},
|
|
369
|
+
{ id: "export", label: "Export plan\u2026", to: "export" },
|
|
370
|
+
{ id: "settings", label: "Settings", action: "settings" },
|
|
371
|
+
{ id: "clear", label: "Clear saved plan", action: "clear" }
|
|
372
|
+
],
|
|
373
|
+
hint: "close"
|
|
374
|
+
}),
|
|
375
|
+
export: () => planExportInputScreen(options.getExportDestination)
|
|
376
|
+
},
|
|
377
|
+
actions: {
|
|
378
|
+
show: async () => {
|
|
379
|
+
options.show();
|
|
380
|
+
return { kind: "close" };
|
|
381
|
+
},
|
|
382
|
+
"implement-here": async () => {
|
|
383
|
+
await options.implementHere();
|
|
384
|
+
return { kind: "close" };
|
|
385
|
+
},
|
|
386
|
+
"implement-fresh": async ({ signal }) => {
|
|
387
|
+
await options.implementFresh(signal);
|
|
388
|
+
return { kind: "close" };
|
|
389
|
+
},
|
|
390
|
+
export: async ({ value, signal }) => await options.exportPlan(value ?? "", signal) ? { kind: "close" } : { kind: "rejected" },
|
|
391
|
+
settings: async ({ signal }) => {
|
|
392
|
+
const close = await options.settings(signal);
|
|
393
|
+
if (signal.aborted || !options.isCurrent()) return { kind: "rejected" };
|
|
394
|
+
return close ? { kind: "close" } : { kind: "stay" };
|
|
395
|
+
},
|
|
396
|
+
clear: async () => {
|
|
397
|
+
options.clear();
|
|
398
|
+
return { kind: "close" };
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
await runMenu4(ctx, menu, {
|
|
403
|
+
getState: () => void 0,
|
|
404
|
+
signal: options.signal,
|
|
405
|
+
isCurrent: options.isCurrent
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// src/settings-menu.ts
|
|
410
|
+
import { defineMenu as defineMenu5, runMenu as runMenu5 } from "@narumitw/pi-tui-kit";
|
|
411
|
+
async function showPlanModeSettings(ctx, options) {
|
|
412
|
+
const settingsPath = options.settingsPath ?? planModeSettingsPath();
|
|
413
|
+
const readSettings = options.readSettings ?? readPlanModeSettings;
|
|
414
|
+
const updateSettings = options.updateSettings ?? updatePlanModeSettings;
|
|
415
|
+
const tools = options.tools.filter(
|
|
416
|
+
(tool) => tool.name !== PLAN_MODE_QUESTION_TOOL_NAME && tool.name !== PLAN_MODE_COMPLETE_TOOL_NAME
|
|
417
|
+
);
|
|
418
|
+
const loadState = async () => {
|
|
419
|
+
const loaded = await readSettings(options.settingsPath);
|
|
420
|
+
if (loaded.kind === "invalid") {
|
|
421
|
+
return {
|
|
422
|
+
kind: "invalid",
|
|
423
|
+
settings: { thinkingLevel: "inherit" },
|
|
424
|
+
notice: loaded.notice,
|
|
425
|
+
reason: loaded.reason
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
return {
|
|
429
|
+
kind: "valid",
|
|
430
|
+
settings: loaded.kind === "loaded" ? loaded.settings : { thinkingLevel: "inherit" },
|
|
431
|
+
notice: loaded.notice
|
|
432
|
+
};
|
|
433
|
+
};
|
|
434
|
+
const menu = defineMenu5({
|
|
435
|
+
start: "settings",
|
|
436
|
+
screens: {
|
|
437
|
+
settings: ({ state }) => state.kind === "invalid" ? invalidScreen(settingsPath, state) : {
|
|
438
|
+
kind: "settings",
|
|
439
|
+
title: "Plan Mode Settings",
|
|
440
|
+
lines: settingsLines(settingsPath, state.notice),
|
|
441
|
+
items: [
|
|
442
|
+
{
|
|
443
|
+
id: "thinkingLevel",
|
|
444
|
+
label: "Plan thinking",
|
|
445
|
+
description: "Set the thinking level when the next Plan workflow starts.",
|
|
446
|
+
currentValue: state.settings.thinkingLevel,
|
|
447
|
+
values: PLAN_MODE_THINKING_LEVELS,
|
|
448
|
+
action: "set-thinking"
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
id: "defaultPlanTools",
|
|
452
|
+
label: "Plan tools",
|
|
453
|
+
description: "Choose persistent defaults; a launch-time selection still overrides them for that session.",
|
|
454
|
+
currentValue: defaultToolsValue(state.settings.defaultPlanTools),
|
|
455
|
+
action: "open-tools"
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
id: "implementationPlanRetention",
|
|
459
|
+
label: "After Implement",
|
|
460
|
+
description: "Choose how long the accepted plan keeps guiding implementation.",
|
|
461
|
+
currentValue: retentionLabel(
|
|
462
|
+
configuredImplementationPlanRetention(state.settings)
|
|
463
|
+
),
|
|
464
|
+
values: IMPLEMENTATION_PLAN_RETENTIONS.map(retentionLabel),
|
|
465
|
+
action: "set-retention"
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
id: "defaultPlanExportPath",
|
|
469
|
+
label: "Export destination",
|
|
470
|
+
description: "Set the destination used when an export omits its path.",
|
|
471
|
+
currentValue: safeTerminalText(configuredPlanExportPath(state.settings)),
|
|
472
|
+
action: "open-export"
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
id: "toggleShortcut",
|
|
476
|
+
label: "Plan mode shortcut",
|
|
477
|
+
description: "Set the global shortcut used to toggle Plan mode.",
|
|
478
|
+
currentValue: configuredPlanModeToggleShortcut(state.settings) ?? "none",
|
|
479
|
+
action: "open-shortcut"
|
|
480
|
+
}
|
|
481
|
+
]
|
|
482
|
+
},
|
|
483
|
+
tools: ({ state }) => ({
|
|
484
|
+
kind: "multiSelect",
|
|
485
|
+
title: "Default Plan-mode tools",
|
|
486
|
+
lines: [
|
|
487
|
+
"Changes apply when a later Plan workflow starts; required Plan tools stay enabled.",
|
|
488
|
+
"Non-built-in tools run at user risk."
|
|
489
|
+
],
|
|
490
|
+
enableSearch: true,
|
|
491
|
+
viewportSize: 10,
|
|
492
|
+
items: defaultToolItems(tools, state.settings.defaultPlanTools),
|
|
493
|
+
action: "toggle-tool",
|
|
494
|
+
actions: [
|
|
495
|
+
{
|
|
496
|
+
id: "reset-tools",
|
|
497
|
+
label: "Use automatic safe built-ins",
|
|
498
|
+
action: "reset-tools"
|
|
499
|
+
}
|
|
500
|
+
],
|
|
501
|
+
hint: "back"
|
|
502
|
+
}),
|
|
503
|
+
export: ({ state }) => {
|
|
504
|
+
const configured = configuredPlanExportPath(state.settings);
|
|
505
|
+
const destination = planExportDestination(configured, ctx.cwd);
|
|
506
|
+
return {
|
|
507
|
+
kind: "input",
|
|
508
|
+
title: "Export destination",
|
|
509
|
+
lines: [
|
|
510
|
+
`Configured: ${destination.configuredPath}`,
|
|
511
|
+
`Resolves here to: ${destination.resolvedPath}`,
|
|
512
|
+
"Submit an empty value to reset to PLAN.md. Changes affect the next export."
|
|
513
|
+
],
|
|
514
|
+
placeholder: configured,
|
|
515
|
+
action: "set-export",
|
|
516
|
+
hint: "back"
|
|
517
|
+
};
|
|
518
|
+
},
|
|
519
|
+
shortcut: ({ state }) => ({
|
|
520
|
+
kind: "input",
|
|
521
|
+
title: "Plan mode shortcut",
|
|
522
|
+
lines: [
|
|
523
|
+
`Configured: ${configuredPlanModeToggleShortcut(state.settings) ?? "none"}`,
|
|
524
|
+
"Use Pi key identifiers.",
|
|
525
|
+
"Submit an empty value to clear the shortcut.",
|
|
526
|
+
"When unset, Plan mode has no global shortcut."
|
|
527
|
+
],
|
|
528
|
+
placeholder: configuredPlanModeToggleShortcut(state.settings) ?? "",
|
|
529
|
+
action: "set-shortcut",
|
|
530
|
+
hint: "back"
|
|
531
|
+
})
|
|
532
|
+
},
|
|
533
|
+
actions: {
|
|
534
|
+
"set-thinking": async ({ ctx: actionCtx, value, signal }) => {
|
|
535
|
+
if (!PLAN_MODE_THINKING_LEVELS.includes(value)) {
|
|
536
|
+
return { kind: "rejected" };
|
|
537
|
+
}
|
|
538
|
+
return savePatch(
|
|
539
|
+
actionCtx,
|
|
540
|
+
{ thinkingLevel: value },
|
|
541
|
+
signal,
|
|
542
|
+
`Plan mode thinking level: ${value}. Applies to the next Plan workflow.`
|
|
543
|
+
);
|
|
544
|
+
},
|
|
545
|
+
"open-tools": async () => ({ kind: "to", screen: "tools" }),
|
|
546
|
+
"set-retention": async ({ ctx: actionCtx, value, signal }) => {
|
|
547
|
+
const implementationPlanRetention = retentionFromLabel(value);
|
|
548
|
+
if (!implementationPlanRetention) return { kind: "rejected" };
|
|
549
|
+
return savePatch(
|
|
550
|
+
actionCtx,
|
|
551
|
+
{ implementationPlanRetention },
|
|
552
|
+
signal,
|
|
553
|
+
`After Implement: ${retentionLabel(implementationPlanRetention)}. Applies to the next Implement action.`
|
|
554
|
+
);
|
|
555
|
+
},
|
|
556
|
+
"open-export": async () => ({ kind: "to", screen: "export" }),
|
|
557
|
+
"set-export": async ({ ctx: actionCtx, value, signal }) => {
|
|
558
|
+
const defaultPlanExportPath = value?.trim() || null;
|
|
559
|
+
const result = await savePatch(
|
|
560
|
+
actionCtx,
|
|
561
|
+
{ defaultPlanExportPath },
|
|
562
|
+
signal,
|
|
563
|
+
defaultPlanExportPath ? `Default Plan export destination: ${safeTerminalText(defaultPlanExportPath)}.` : "Default Plan export destination reset to PLAN.md."
|
|
564
|
+
);
|
|
565
|
+
return result.kind === "stay" ? { kind: "to", screen: "settings" } : result;
|
|
566
|
+
},
|
|
567
|
+
"open-shortcut": async () => ({ kind: "to", screen: "shortcut" }),
|
|
568
|
+
"set-shortcut": async ({ ctx: actionCtx, value, signal }) => {
|
|
569
|
+
const raw = value?.trim() || null;
|
|
570
|
+
if (raw && !normalizeKeyId(raw)) {
|
|
571
|
+
actionCtx.ui.notify(
|
|
572
|
+
`Invalid key identifier: ${safeTerminalText(raw)}. Use Pi key identifiers like ctrl+alt+p.`,
|
|
573
|
+
"warning"
|
|
574
|
+
);
|
|
575
|
+
return { kind: "stay" };
|
|
576
|
+
}
|
|
577
|
+
const toggleShortcut = raw;
|
|
578
|
+
const result = await savePatch(
|
|
579
|
+
actionCtx,
|
|
580
|
+
{ toggleShortcut },
|
|
581
|
+
signal,
|
|
582
|
+
toggleShortcut ? `Plan mode shortcut: ${safeTerminalText(toggleShortcut)}.` : "Plan mode shortcut cleared (no global shortcut)."
|
|
583
|
+
);
|
|
584
|
+
return result.kind === "stay" ? { kind: "to", screen: "settings" } : result;
|
|
585
|
+
},
|
|
586
|
+
"toggle-tool": async ({ ctx: actionCtx, state, itemId, selected, signal }) => {
|
|
587
|
+
const tool = tools.find((candidate) => candidate.name === itemId);
|
|
588
|
+
if (!tool || !canSelectToolInPlanMode(tool)) return { kind: "rejected" };
|
|
589
|
+
const names = explicitToolNames(tools, state.settings.defaultPlanTools);
|
|
590
|
+
const next = selected ? Array.from(/* @__PURE__ */ new Set([...names, tool.name])) : names.filter((name) => name !== tool.name);
|
|
591
|
+
return savePatch(
|
|
592
|
+
actionCtx,
|
|
593
|
+
{ defaultPlanTools: next },
|
|
594
|
+
signal,
|
|
595
|
+
`Default Plan-mode tools: ${next.length === 0 ? "required tools only" : `${next.length} selected`}.`
|
|
596
|
+
);
|
|
597
|
+
},
|
|
598
|
+
"reset-tools": async ({ ctx: actionCtx, state, signal }) => {
|
|
599
|
+
if (state.settings.defaultPlanTools === void 0) return { kind: "stay" };
|
|
600
|
+
return savePatch(
|
|
601
|
+
actionCtx,
|
|
602
|
+
{ defaultPlanTools: null },
|
|
603
|
+
signal,
|
|
604
|
+
"Default Plan-mode tools: automatic safe built-ins."
|
|
605
|
+
);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
});
|
|
609
|
+
return runMenu5(ctx, menu, {
|
|
610
|
+
getState: loadState,
|
|
611
|
+
signal: options.signal,
|
|
612
|
+
isCurrent: options.isCurrent
|
|
613
|
+
});
|
|
614
|
+
async function savePatch(actionCtx, patch, signal, successMessage) {
|
|
615
|
+
if (signal.aborted || !options.isCurrent()) return { kind: "rejected" };
|
|
616
|
+
try {
|
|
617
|
+
const saved = await updateSettings(patch, {
|
|
618
|
+
settingsPath: options.settingsPath,
|
|
619
|
+
legacySettingsPath: options.legacySettingsPath,
|
|
620
|
+
signal
|
|
621
|
+
});
|
|
622
|
+
if (options.isCurrent()) options.onSaved(saved);
|
|
623
|
+
if (signal.aborted || !options.isCurrent()) return { kind: "rejected" };
|
|
624
|
+
actionCtx.ui.notify(successMessage, "info");
|
|
625
|
+
return { kind: "stay" };
|
|
626
|
+
} catch (error) {
|
|
627
|
+
if (!signal.aborted && options.isCurrent()) {
|
|
628
|
+
actionCtx.ui.notify(
|
|
629
|
+
`Could not save Plan mode settings; the previous value remains: ${safeTerminalText(formatError(error))}`,
|
|
630
|
+
"error"
|
|
631
|
+
);
|
|
632
|
+
}
|
|
633
|
+
return { kind: "rejected" };
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
function settingsLines(settingsPath, notice) {
|
|
638
|
+
return [
|
|
639
|
+
`User settings \xB7 ${safeTerminalText(settingsPath)}`,
|
|
640
|
+
"Plan defaults apply to the next workflow; handoff and export choices apply to their next action.",
|
|
641
|
+
...notice ? [safeTerminalText(notice)] : []
|
|
642
|
+
];
|
|
643
|
+
}
|
|
644
|
+
function invalidScreen(settingsPath, state) {
|
|
645
|
+
return {
|
|
646
|
+
kind: "detail",
|
|
647
|
+
title: "Plan Mode Settings \xB7 Read only",
|
|
648
|
+
lines: [
|
|
649
|
+
`Invalid settings file. Fix ${safeTerminalText(settingsPath)} before saving.`,
|
|
650
|
+
safeTerminalText(state.reason ?? "The settings file is invalid."),
|
|
651
|
+
...state.notice ? [safeTerminalText(state.notice)] : []
|
|
652
|
+
],
|
|
653
|
+
hint: "back"
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
function retentionFromLabel(value) {
|
|
657
|
+
return IMPLEMENTATION_PLAN_RETENTIONS.find((retention) => retentionLabel(retention) === value);
|
|
658
|
+
}
|
|
659
|
+
function defaultToolsValue(configured) {
|
|
660
|
+
if (configured === void 0) return "Automatic safe built-ins";
|
|
661
|
+
if (configured.length === 0) return "Required tools only";
|
|
662
|
+
return `${configured.length} selected`;
|
|
663
|
+
}
|
|
664
|
+
function defaultToolItems(tools, configured) {
|
|
665
|
+
const selected = new Set(explicitToolNames(tools, configured));
|
|
666
|
+
const availableNames = new Set(tools.map((tool) => tool.name));
|
|
667
|
+
const items = tools.map((tool) => {
|
|
668
|
+
const selectable = canSelectToolInPlanMode(tool);
|
|
669
|
+
const policy = toolPolicyLabel(tool);
|
|
670
|
+
const description = tool.description ?? "No description available";
|
|
671
|
+
return {
|
|
672
|
+
id: tool.name,
|
|
673
|
+
label: tool.name,
|
|
674
|
+
description: `${policy} \xB7 ${description}`,
|
|
675
|
+
searchText: `${policy} ${description}`,
|
|
676
|
+
selected: selected.has(tool.name),
|
|
677
|
+
disabled: !selectable,
|
|
678
|
+
disabledReason: selectable ? void 0 : "Blocked by Plan-mode policy"
|
|
679
|
+
};
|
|
680
|
+
});
|
|
681
|
+
for (const name of configured ?? []) {
|
|
682
|
+
if (availableNames.has(name)) continue;
|
|
683
|
+
items.push({
|
|
684
|
+
id: name,
|
|
685
|
+
label: name,
|
|
686
|
+
description: "unavailable \xB7 Retained in settings but unavailable in this session",
|
|
687
|
+
searchText: "unavailable retained settings",
|
|
688
|
+
selected: true,
|
|
689
|
+
disabled: true,
|
|
690
|
+
disabledReason: "Unavailable in this session; reset defaults to remove unavailable names"
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
return items;
|
|
694
|
+
}
|
|
695
|
+
function explicitToolNames(tools, configured) {
|
|
696
|
+
return configured === void 0 ? defaultPlanModeToolNames([...tools], void 0) : [...configured];
|
|
697
|
+
}
|
|
698
|
+
function safeTerminalText(value) {
|
|
699
|
+
return [...value].map((character) => {
|
|
700
|
+
const codePoint = character.codePointAt(0) ?? 0;
|
|
701
|
+
return codePoint <= 31 || codePoint >= 127 && codePoint <= 159 ? " " : character;
|
|
702
|
+
}).join("").trim();
|
|
703
|
+
}
|
|
704
|
+
function formatError(error) {
|
|
705
|
+
return error instanceof Error ? error.message : String(error);
|
|
706
|
+
}
|
|
707
|
+
export {
|
|
708
|
+
showActiveImplementationMenu,
|
|
709
|
+
showPlanLaunchMenu,
|
|
710
|
+
showPlanModeMenu,
|
|
711
|
+
showPlanModeSettings,
|
|
712
|
+
showReadyPlanMenu,
|
|
713
|
+
showSavedPlanMenu
|
|
714
|
+
};
|
|
715
|
+
//# sourceMappingURL=interactive-ui-JBSBPK6S.ts.map
|