@narumitw/pi-plan-mode 0.4.1 → 0.4.2
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 +2 -2
- package/src/plan-mode.ts +10 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@narumitw/pi-plan-mode",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Pi extension that adds a Codex-like read-only /plan collaboration mode.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@biomejs/biome": "2.4.14",
|
|
32
|
-
"@
|
|
32
|
+
"@earendil-works/pi-coding-agent": "0.74.0",
|
|
33
33
|
"typescript": "6.0.3"
|
|
34
34
|
},
|
|
35
35
|
"repository": {
|
package/src/plan-mode.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExtensionAPI, ExtensionContext, ToolInfo } from "@
|
|
1
|
+
import type { ExtensionAPI, ExtensionContext, ToolInfo } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
|
|
3
3
|
const STATE_ENTRY_TYPE = "plan-mode-state";
|
|
4
4
|
const STATUS_KEY = "plan-mode";
|
|
@@ -684,7 +684,7 @@ function isBuiltinTool(tool: ToolInfo) {
|
|
|
684
684
|
return tool.sourceInfo.source === "builtin";
|
|
685
685
|
}
|
|
686
686
|
|
|
687
|
-
function canSelectToolInPlanMode(tool: ToolInfo) {
|
|
687
|
+
export function canSelectToolInPlanMode(tool: ToolInfo) {
|
|
688
688
|
if (isBuiltinTool(tool)) return SAFE_BUILTIN_PLAN_TOOLS.has(tool.name);
|
|
689
689
|
return true;
|
|
690
690
|
}
|
|
@@ -726,11 +726,11 @@ function unique(values: string[]) {
|
|
|
726
726
|
return Array.from(new Set(values));
|
|
727
727
|
}
|
|
728
728
|
|
|
729
|
-
function withRequiredPlanModeTools(toolNames: string[]) {
|
|
729
|
+
export function withRequiredPlanModeTools(toolNames: string[]) {
|
|
730
730
|
return unique([...withoutPlanModeQuestionTool(toolNames), PLAN_MODE_QUESTION_TOOL_NAME]);
|
|
731
731
|
}
|
|
732
732
|
|
|
733
|
-
function withoutPlanModeQuestionTool(toolNames: string[]) {
|
|
733
|
+
export function withoutPlanModeQuestionTool(toolNames: string[]) {
|
|
734
734
|
return toolNames.filter((toolName) => toolName !== PLAN_MODE_QUESTION_TOOL_NAME);
|
|
735
735
|
}
|
|
736
736
|
|
|
@@ -738,7 +738,7 @@ type NormalizePlanModeQuestionParamsResult =
|
|
|
738
738
|
| { ok: true; questions: PlanModeQuestion[] }
|
|
739
739
|
| { ok: false; error: string };
|
|
740
740
|
|
|
741
|
-
function normalizePlanModeQuestionParams(input: unknown): NormalizePlanModeQuestionParamsResult {
|
|
741
|
+
export function normalizePlanModeQuestionParams(input: unknown): NormalizePlanModeQuestionParamsResult {
|
|
742
742
|
if (!isRecord(input) || !Array.isArray(input.questions)) {
|
|
743
743
|
return { ok: false, error: "questions must be an array" };
|
|
744
744
|
}
|
|
@@ -938,19 +938,19 @@ function readCommand(input: unknown) {
|
|
|
938
938
|
return typeof command?.command === "string" ? command.command : "";
|
|
939
939
|
}
|
|
940
940
|
|
|
941
|
-
function isSafeCommand(command: string) {
|
|
941
|
+
export function isSafeCommand(command: string) {
|
|
942
942
|
const trimmed = command.trim();
|
|
943
943
|
if (!trimmed) return false;
|
|
944
944
|
if (MUTATING_BASH_PATTERNS.some((pattern) => pattern.test(trimmed))) return false;
|
|
945
945
|
return SAFE_BASH_PATTERNS.some((pattern) => pattern.test(trimmed));
|
|
946
946
|
}
|
|
947
947
|
|
|
948
|
-
function extractProposedPlan(text: string) {
|
|
948
|
+
export function extractProposedPlan(text: string) {
|
|
949
949
|
const match = PROPOSED_PLAN_PATTERN.exec(text);
|
|
950
950
|
return match?.[1]?.trim();
|
|
951
951
|
}
|
|
952
952
|
|
|
953
|
-
function latestAssistantText(messages: unknown) {
|
|
953
|
+
export function latestAssistantText(messages: unknown) {
|
|
954
954
|
if (!Array.isArray(messages)) return "";
|
|
955
955
|
for (const entry of [...messages].reverse()) {
|
|
956
956
|
const message = (entry as { message?: SessionMessage })?.message ?? (entry as SessionMessage);
|
|
@@ -971,7 +971,7 @@ function messageContainsInactivePlanModeArtifact(message: unknown) {
|
|
|
971
971
|
return candidate.customType === PROPOSED_PLAN_MESSAGE_TYPE;
|
|
972
972
|
}
|
|
973
973
|
|
|
974
|
-
function stripProposedPlanBlocksFromMessage<T>(message: T): T {
|
|
974
|
+
export function stripProposedPlanBlocksFromMessage<T>(message: T): T {
|
|
975
975
|
const candidate = unwrapSessionMessage(message);
|
|
976
976
|
if (candidate.role !== "assistant") return message;
|
|
977
977
|
|
|
@@ -1011,7 +1011,7 @@ function stripProposedPlanBlocksFromContent(content: unknown) {
|
|
|
1011
1011
|
return changed ? nextContent : content;
|
|
1012
1012
|
}
|
|
1013
1013
|
|
|
1014
|
-
function stripProposedPlanBlocks(text: string) {
|
|
1014
|
+
export function stripProposedPlanBlocks(text: string) {
|
|
1015
1015
|
return text.replace(PROPOSED_PLAN_BLOCK_PATTERN, "");
|
|
1016
1016
|
}
|
|
1017
1017
|
|