@narumitw/pi-plan-mode 0.1.25 → 0.1.26
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 +1 -1
- package/package.json +1 -1
- package/src/plan-mode.ts +30 -5
package/README.md
CHANGED
|
@@ -44,7 +44,7 @@ pi -e ./extensions/pi-plan-mode
|
|
|
44
44
|
/plan tools
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
Use `/plan` to enter Plan mode before writing your planning prompt. Use `/plan <prompt>` to enter Plan mode and immediately submit `<prompt>` as the first Plan-mode user message. Use `/plan tools` to choose which tools are active while Plan mode is enabled.
|
|
47
|
+
Use `/plan` to enter Plan mode before writing your planning prompt. Use `/plan <prompt>` to enter Plan mode and immediately submit `<prompt>` as the first Plan-mode user message. Use `/plan tools` to choose which tools are active while Plan mode is enabled; the selector is paginated at 10 tools per page.
|
|
48
48
|
|
|
49
49
|
When Plan mode is active, ask the agent to design the change. The agent may inspect files and run read-only commands, but it should not edit files or execute the implementation.
|
|
50
50
|
|
package/package.json
CHANGED
package/src/plan-mode.ts
CHANGED
|
@@ -7,6 +7,7 @@ const PLAN_CONTEXT_MARKER = "[CODEX-LIKE PLAN MODE ACTIVE]";
|
|
|
7
7
|
const SAFE_BUILTIN_PLAN_TOOLS = new Set(["read", "bash", "grep", "find", "ls"]);
|
|
8
8
|
const BLOCKED_BUILTIN_TOOLS = new Set(["edit", "write"]);
|
|
9
9
|
const DEFAULT_TOOLS = ["read", "bash", "edit", "write"];
|
|
10
|
+
const TOOL_SELECTOR_PAGE_SIZE = 10;
|
|
10
11
|
const PROPOSED_PLAN_PATTERN = /<proposed_plan>\s*([\s\S]*?)\s*<\/proposed_plan>/i;
|
|
11
12
|
|
|
12
13
|
interface PlanModeState {
|
|
@@ -298,21 +299,41 @@ export default function planMode(pi: ExtensionAPI) {
|
|
|
298
299
|
return;
|
|
299
300
|
}
|
|
300
301
|
|
|
302
|
+
let pageIndex = 0;
|
|
301
303
|
while (true) {
|
|
302
304
|
const tools = selectableTools();
|
|
305
|
+
const pageCount = toolSelectorPageCount(tools);
|
|
306
|
+
pageIndex = Math.min(pageIndex, pageCount - 1);
|
|
307
|
+
const pageStart = pageIndex * TOOL_SELECTOR_PAGE_SIZE;
|
|
308
|
+
const pageTools = tools.slice(pageStart, pageStart + TOOL_SELECTOR_PAGE_SIZE);
|
|
303
309
|
const selectedNames = planModeSelectedNames(tools);
|
|
304
|
-
const choices =
|
|
305
|
-
formatToolChoice(tool, selectedNames.has(tool.name), index),
|
|
310
|
+
const choices = pageTools.map((tool, index) =>
|
|
311
|
+
formatToolChoice(tool, selectedNames.has(tool.name), pageStart + index),
|
|
306
312
|
);
|
|
313
|
+
const previousChoice = "Previous page";
|
|
314
|
+
const nextChoice = "Next page";
|
|
307
315
|
const doneChoice = "Done";
|
|
316
|
+
const navigationChoices = [
|
|
317
|
+
...(pageIndex > 0 ? [previousChoice] : []),
|
|
318
|
+
...(pageIndex < pageCount - 1 ? [nextChoice] : []),
|
|
319
|
+
doneChoice,
|
|
320
|
+
];
|
|
308
321
|
const choice = await ctx.ui.select(
|
|
309
|
-
|
|
310
|
-
[...choices,
|
|
322
|
+
`Plan-mode tools (${pageIndex + 1}/${pageCount}). Non-built-in tools run at user risk.`,
|
|
323
|
+
[...choices, ...navigationChoices],
|
|
311
324
|
);
|
|
312
325
|
if (!choice || choice === doneChoice) break;
|
|
326
|
+
if (choice === previousChoice) {
|
|
327
|
+
pageIndex = Math.max(0, pageIndex - 1);
|
|
328
|
+
continue;
|
|
329
|
+
}
|
|
330
|
+
if (choice === nextChoice) {
|
|
331
|
+
pageIndex = Math.min(pageCount - 1, pageIndex + 1);
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
313
334
|
|
|
314
335
|
const selectedIndex = choices.indexOf(choice);
|
|
315
|
-
const tool =
|
|
336
|
+
const tool = pageTools[selectedIndex];
|
|
316
337
|
if (!tool) continue;
|
|
317
338
|
if (!canSelectToolInPlanMode(tool)) {
|
|
318
339
|
ctx.ui.notify(`${tool.name} is blocked in Plan mode.`, "warning");
|
|
@@ -390,6 +411,10 @@ export default function planMode(pi: ExtensionAPI) {
|
|
|
390
411
|
return safeGetAllTools().sort(compareTools);
|
|
391
412
|
}
|
|
392
413
|
|
|
414
|
+
function toolSelectorPageCount(tools: ToolInfo[]) {
|
|
415
|
+
return Math.max(1, Math.ceil(tools.length / TOOL_SELECTOR_PAGE_SIZE));
|
|
416
|
+
}
|
|
417
|
+
|
|
393
418
|
function safeGetAllTools() {
|
|
394
419
|
try {
|
|
395
420
|
return pi.getAllTools();
|