@narumitw/pi-plan-mode 0.31.0 → 0.34.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narumitw/pi-plan-mode",
3
- "version": "0.31.0",
3
+ "version": "0.34.0",
4
4
  "description": "Pi extension that adds a Codex-like read-only /plan collaboration mode.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -27,9 +27,14 @@
27
27
  "format": "biome check --write .",
28
28
  "typecheck": "tsc --noEmit"
29
29
  },
30
+ "peerDependencies": {
31
+ "@earendil-works/pi-coding-agent": "*",
32
+ "@earendil-works/pi-tui": "*"
33
+ },
30
34
  "devDependencies": {
31
35
  "@biomejs/biome": "2.5.5",
32
36
  "@earendil-works/pi-coding-agent": "0.82.1",
37
+ "@earendil-works/pi-tui": "0.82.1",
33
38
  "typescript": "7.0.2"
34
39
  },
35
40
  "repository": {
@@ -1,3 +1,6 @@
1
+ import { getMarkdownTheme } from "@earendil-works/pi-coding-agent";
2
+ import { Markdown } from "@earendil-works/pi-tui";
3
+
1
4
  export const PLAN_MODE_COMPLETE_TOOL_NAME = "plan_mode_complete";
2
5
  export const PLAN_MODE_COMPLETE_VERSION = 1;
3
6
  export const PLAN_MODE_MAX_CHARS = 50_000;
@@ -63,6 +66,26 @@ export function planModeCompleted(plan: string) {
63
66
  };
64
67
  }
65
68
 
69
+ type PlanModeCompletionRenderResult = {
70
+ content: Array<{ type: string; text?: string }>;
71
+ details?: unknown;
72
+ };
73
+
74
+ export function planModeCompletionMarkdown(result: PlanModeCompletionRenderResult) {
75
+ const content = result.content
76
+ .filter((block) => block.type === "text" && typeof block.text === "string")
77
+ .map((block) => block.text)
78
+ .join("\n")
79
+ .trim();
80
+ if (content) return content;
81
+ const plan = planFromCompletionDetails(result.details);
82
+ return plan ? `**Proposed Plan**\n\n${plan}` : "";
83
+ }
84
+
85
+ export function renderPlanModeCompletion(result: PlanModeCompletionRenderResult) {
86
+ return new Markdown(planModeCompletionMarkdown(result), 0, 0, getMarkdownTheme());
87
+ }
88
+
66
89
  function isRecord(value: unknown): value is Record<string, unknown> {
67
90
  return typeof value === "object" && value !== null && !Array.isArray(value);
68
91
  }
package/src/plan-mode.ts CHANGED
@@ -4,6 +4,7 @@ import {
4
4
  PLAN_MODE_COMPLETE_PARAMS,
5
5
  PLAN_MODE_COMPLETE_TOOL_NAME,
6
6
  planModeCompleted,
7
+ renderPlanModeCompletion,
7
8
  } from "./completion-tool.js";
8
9
  import {
9
10
  isEmptyAssistantMessage,
@@ -157,6 +158,7 @@ export default function planMode(pi: ExtensionAPI) {
157
158
  "Call plan_mode_complete alone as the final action only after the implementation plan is decision-complete.",
158
159
  ],
159
160
  parameters: PLAN_MODE_COMPLETE_PARAMS,
161
+ renderResult: renderPlanModeCompletion,
160
162
  async execute(_toolCallId, params: unknown, _signal, _onUpdate, ctx) {
161
163
  if (!state.enabled) {
162
164
  throw new Error("plan_mode_complete is only available while Plan mode is active");