@narumitw/pi-plan-mode 0.18.0 → 0.20.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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/plan-mode.ts +19 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narumitw/pi-plan-mode",
3
- "version": "0.18.0",
3
+ "version": "0.20.0",
4
4
  "description": "Pi extension that adds a Codex-like read-only /plan collaboration mode.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -29,8 +29,8 @@
29
29
  },
30
30
  "devDependencies": {
31
31
  "@biomejs/biome": "2.5.3",
32
- "@earendil-works/pi-coding-agent": "0.80.6",
33
- "typescript": "6.0.3"
32
+ "@earendil-works/pi-coding-agent": "0.80.10",
33
+ "typescript": "7.0.2"
34
34
  },
35
35
  "repository": {
36
36
  "type": "git",
package/src/plan-mode.ts CHANGED
@@ -26,6 +26,7 @@ import {
26
26
  import { showPersistentSelector } from "./selector-ui.js";
27
27
  import {
28
28
  configuredThinkingLevel,
29
+ type PlanModeFixedThinkingLevel,
29
30
  type PlanModeSettings,
30
31
  readPlanModeSettings,
31
32
  } from "./settings.js";
@@ -47,6 +48,20 @@ const BLOCKED_BUILTIN_TOOLS = new Set(["edit", "write"]);
47
48
  const DEFAULT_TOOLS = ["read", "bash", "edit", "write"];
48
49
  const TOOL_SELECTOR_PAGE_SIZE = 10;
49
50
 
51
+ type AgentSettledHandler = (event: unknown, ctx: ExtensionContext) => unknown;
52
+
53
+ function onAgentSettled(pi: ExtensionAPI, handler: AgentSettledHandler) {
54
+ (
55
+ pi as unknown as {
56
+ on(event: "agent_settled", callback: AgentSettledHandler): void;
57
+ }
58
+ ).on("agent_settled", handler);
59
+ }
60
+
61
+ function setPlanThinkingLevel(pi: ExtensionAPI, level: PlanModeFixedThinkingLevel) {
62
+ (pi.setThinkingLevel as unknown as (level: PlanModeFixedThinkingLevel) => void)(level);
63
+ }
64
+
50
65
  interface CommandArgumentCompletion {
51
66
  value: string;
52
67
  label: string;
@@ -322,7 +337,7 @@ export default function planMode(pi: ExtensionAPI) {
322
337
  acceptCompletedPlan(parsedPlan.plan, "legacy_proposed_plan", ctx);
323
338
  });
324
339
 
325
- pi.on("agent_settled", async (_event, ctx) => {
340
+ onAgentSettled(pi, async (_event, ctx) => {
326
341
  const intent = readyPresentationIntent;
327
342
  if (!intent || !readyPresentationIsCurrent(intent)) return;
328
343
  if (!ctx.isIdle() || ctx.hasPendingMessages()) return;
@@ -749,7 +764,7 @@ export default function planMode(pi: ExtensionAPI) {
749
764
  function applyPlanThinkingLevel() {
750
765
  if (state.manualThinkingLevel) {
751
766
  if (pi.getThinkingLevel() !== state.manualThinkingLevel) {
752
- pi.setThinkingLevel(state.manualThinkingLevel);
767
+ setPlanThinkingLevel(pi, state.manualThinkingLevel);
753
768
  }
754
769
  return;
755
770
  }
@@ -764,7 +779,7 @@ export default function planMode(pi: ExtensionAPI) {
764
779
  }
765
780
  const current = pi.getThinkingLevel();
766
781
  if (!state.appliedThinkingLevel) state.previousThinkingLevel = current;
767
- if (current !== configured) pi.setThinkingLevel(configured);
782
+ if (current !== configured) setPlanThinkingLevel(pi, configured);
768
783
  state.appliedThinkingLevel = pi.getThinkingLevel();
769
784
  }
770
785
 
@@ -788,7 +803,7 @@ export default function planMode(pi: ExtensionAPI) {
788
803
  previousThinkingLevel &&
789
804
  pi.getThinkingLevel() === appliedThinkingLevel
790
805
  ) {
791
- pi.setThinkingLevel(previousThinkingLevel);
806
+ setPlanThinkingLevel(pi, previousThinkingLevel);
792
807
  }
793
808
  state = { ...state, appliedThinkingLevel: undefined, previousThinkingLevel: undefined };
794
809
  }