@narumitw/pi-plan-mode 0.6.1 → 0.7.0
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/package.json +1 -1
- package/src/plan-mode.ts +22 -0
package/package.json
CHANGED
package/src/plan-mode.ts
CHANGED
|
@@ -14,6 +14,12 @@ const TOOL_SELECTOR_PAGE_SIZE = 10;
|
|
|
14
14
|
const PROPOSED_PLAN_PATTERN = /<proposed_plan>\s*([\s\S]*?)\s*<\/proposed_plan>/i;
|
|
15
15
|
const PROPOSED_PLAN_BLOCK_PATTERN = /<proposed_plan>\s*[\s\S]*?\s*<\/proposed_plan>/gi;
|
|
16
16
|
|
|
17
|
+
interface CommandArgumentCompletion {
|
|
18
|
+
value: string;
|
|
19
|
+
label: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
17
23
|
interface PlanModeState {
|
|
18
24
|
enabled: boolean;
|
|
19
25
|
latestPlan?: string;
|
|
@@ -73,6 +79,12 @@ type PlanModeQuestionDetails = {
|
|
|
73
79
|
answers?: PlanModeQuestionAnswer[];
|
|
74
80
|
};
|
|
75
81
|
|
|
82
|
+
const PLAN_COMMAND_COMPLETIONS: readonly CommandArgumentCompletion[] = [
|
|
83
|
+
{ value: "exit", label: "exit", description: "Leave Plan mode" },
|
|
84
|
+
{ value: "off", label: "off", description: "Leave Plan mode" },
|
|
85
|
+
{ value: "tools", label: "tools", description: "Select tools allowed in Plan mode" },
|
|
86
|
+
];
|
|
87
|
+
|
|
76
88
|
const PLAN_MODE_QUESTION_PARAMS = {
|
|
77
89
|
type: "object",
|
|
78
90
|
additionalProperties: false,
|
|
@@ -228,6 +240,7 @@ export default function planMode(pi: ExtensionAPI) {
|
|
|
228
240
|
|
|
229
241
|
pi.registerCommand("plan", {
|
|
230
242
|
description: "Enter or manage Codex-like Plan mode",
|
|
243
|
+
getArgumentCompletions: completePlanArguments,
|
|
231
244
|
handler: async (args, ctx) => {
|
|
232
245
|
const prompt = args.trim();
|
|
233
246
|
const command = prompt.toLowerCase();
|
|
@@ -684,6 +697,15 @@ function isBuiltinTool(tool: ToolInfo) {
|
|
|
684
697
|
return tool.sourceInfo.source === "builtin";
|
|
685
698
|
}
|
|
686
699
|
|
|
700
|
+
export function completePlanArguments(argumentPrefix: string): CommandArgumentCompletion[] | null {
|
|
701
|
+
const prefix = argumentPrefix.trimStart().toLowerCase();
|
|
702
|
+
if (prefix === "") return [...PLAN_COMMAND_COMPLETIONS];
|
|
703
|
+
if (/\s/.test(prefix)) return null;
|
|
704
|
+
|
|
705
|
+
const matches = PLAN_COMMAND_COMPLETIONS.filter((item) => item.value.startsWith(prefix));
|
|
706
|
+
return matches.length > 0 ? [...matches] : null;
|
|
707
|
+
}
|
|
708
|
+
|
|
687
709
|
export function canSelectToolInPlanMode(tool: ToolInfo) {
|
|
688
710
|
if (isBuiltinTool(tool)) return SAFE_BUILTIN_PLAN_TOOLS.has(tool.name);
|
|
689
711
|
return true;
|