pi-ui-extend 0.1.55 → 0.1.57

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 (29) hide show
  1. package/README.md +206 -259
  2. package/dist/app/constants.d.ts +2 -2
  3. package/dist/app/constants.js +2 -2
  4. package/dist/app/popup/menu-items-controller.js +3 -0
  5. package/dist/app/rendering/status-line-renderer.js +1 -0
  6. package/dist/app/session/session-event-controller.js +4 -0
  7. package/dist/app/session/tabs-controller.js +3 -0
  8. package/dist/config.d.ts +1 -1
  9. package/dist/config.js +1 -1
  10. package/dist/default-pix-config.js +1 -1
  11. package/dist/schemas/pix-schema.js +1 -1
  12. package/dist/theme.d.ts +1 -0
  13. package/dist/theme.js +2 -0
  14. package/external/pi-tools-suite/README.md +5 -5
  15. package/external/pi-tools-suite/package.json +3 -3
  16. package/external/pi-tools-suite/src/async-subagents/async-subagents.sample.jsonc +18 -18
  17. package/external/pi-tools-suite/src/async-subagents/core/config.ts +5 -5
  18. package/external/pi-tools-suite/src/async-subagents/core/spawn.ts +53 -19
  19. package/external/pi-tools-suite/src/async-subagents/tools/spawn.ts +2 -2
  20. package/external/pi-tools-suite/src/async-subagents/tools/subagents.ts +2 -2
  21. package/external/pi-tools-suite/src/codex-reasoning-fix/index.ts +12 -13
  22. package/external/pi-tools-suite/src/dcp/index.ts +11 -0
  23. package/external/pi-tools-suite/src/default-pi-tools-suite-config.ts +15 -15
  24. package/external/pi-tools-suite/src/index.ts +4 -2
  25. package/external/pi-tools-suite/src/todo/index.ts +24 -28
  26. package/external/pi-tools-suite/src/todo/state/state-reducer.ts +1 -1
  27. package/external/pi-tools-suite/src/todo/tool/types.ts +2 -2
  28. package/package.json +5 -4
  29. package/schemas/pix.json +4 -0
@@ -9,8 +9,7 @@ type ExtensionModule = {
9
9
  default: ExtensionFactory;
10
10
  };
11
11
 
12
- const MODULES: Array<{ name: string; load: () => Promise<ExtensionModule> }> = [
13
- { name: "codex-reasoning-fix", load: () => import("./codex-reasoning-fix/index") },
12
+ export const MODULES: Array<{ name: string; load: () => Promise<ExtensionModule> }> = [
14
13
  { name: "coding-discipline", load: () => import("./coding-discipline/index") },
15
14
  { name: "ast-grep", load: () => import("./ast-grep/index") },
16
15
  { name: "async-subagents", load: () => import("./async-subagents/index") },
@@ -28,6 +27,9 @@ const MODULES: Array<{ name: string; load: () => Promise<ExtensionModule> }> = [
28
27
  { name: "prompt-commands", load: () => import("./prompt-commands/index") },
29
28
  { name: "skill-installer", load: () => import("./skill-installer/index") },
30
29
  { name: "telegram-mirror", load: () => import("./telegram-mirror/index") },
30
+ // Keep this last: its before_provider_request handler is the final payload
31
+ // sanitizer after DCP and any other provider-payload modifiers.
32
+ { name: "codex-reasoning-fix", load: () => import("./codex-reasoning-fix/index") },
31
33
  ];
32
34
 
33
35
  export default async function piToolsSuite(pi: ExtensionAPI) {
@@ -10,16 +10,6 @@ import { getState, replaceState } from "./state/store.js";
10
10
  import { activateTodoStateScope, DEFAULT_PROMPT_GUIDELINES, DEFAULT_PROMPT_SNIPPET, publishTodoState, registerTodosCommand, registerTodoTool } from "./todo.js";
11
11
  import type { Task, TaskMutationParams } from "./tool/types.js";
12
12
 
13
- /**
14
- * Renderer-relayed signal that the session is in an auto-retry cycle.
15
- * Payload: `{ active: boolean }`. The SDK does not forward retry state to
16
- * extensions, so the renderer emits this on the extension event bus. We use it
17
- * to suppress the auto-nudge on intermediate retry agent_end events: nudging
18
- * then races the pending retry continuation and surfaces a benign
19
- * "Agent is already processing" extension error in other tabs.
20
- */
21
- const RETRY_ACTIVE_EVENT = "pix:retry-active";
22
-
23
13
  type AgentMessageLike = { role?: unknown; stopReason?: unknown; content?: unknown };
24
14
 
25
15
  const TODO_NUDGE_LIMIT = 8;
@@ -27,7 +17,7 @@ const TODO_NUDGE_INITIAL_DELAY_MS = 0;
27
17
  const TODO_NUDGE_IDLE_RETRY_DELAY_MS = 100;
28
18
  const TODO_NUDGE_MAX_IDLE_ATTEMPTS = 40;
29
19
  const ASK_USER_TOOL_NAMES = new Set(["ask_user", "ask_user_question", "question"]);
30
- const TODO_THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh"] as const;
20
+ const TODO_THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"] as const;
31
21
  const TODO_THINKING_RESTORE_METADATA_KEY = "__piTodoRestoreThinking";
32
22
 
33
23
  function isStaleExtensionContextError(error: unknown): boolean {
@@ -144,10 +134,10 @@ export default function (pi: ExtensionAPI) {
144
134
  const pendingAskUserToolCallIds = new Set<string>();
145
135
  let suppressNextNudgeForThinkingSwitch = false;
146
136
  let inProgressAtAgentStart = new Set<number>();
147
- // True while the session is in an auto-retry cycle (relayed via the
148
- // extension event bus). Suppresses the auto-nudge on intermediate retry
149
- // agent_end events so it doesn't race the pending retry continuation.
150
- let retryActive = false;
137
+ // agent_end may be followed by an automatic retry, compaction, or queued
138
+ // continuation. Remember only whether its terminal assistant reply was a
139
+ // successful visible response; schedule a nudge later on agent_settled.
140
+ let settledNudgeEligible = false;
151
141
 
152
142
  function registerTodoToolWithCurrentPrompt(): void {
153
143
  const thinkingPrompt = todoThinkingEnabled ? buildThinkingPromptParts(currentModel) : {};
@@ -336,9 +326,6 @@ export default function (pi: ExtensionAPI) {
336
326
  const delayMs = attempt === 0 ? TODO_NUDGE_INITIAL_DELAY_MS : TODO_NUDGE_IDLE_RETRY_DELAY_MS;
337
327
  nudgeTimer = setTimeout(() => {
338
328
  nudgeTimer = undefined;
339
- // A retry-start signal may have arrived after the agent_end that
340
- // scheduled this nudge. Bail out so we don't nudge mid-retry.
341
- if (retryActive) return;
342
329
  try {
343
330
  activateTodoStateScope(ctx);
344
331
  if (!ctx.isIdle()) {
@@ -358,9 +345,8 @@ export default function (pi: ExtensionAPI) {
358
345
  if (nudge.signature === lastNudgedSignature) return;
359
346
  lastNudgedSignature = nudge.signature;
360
347
 
361
- // agent_end fires before Pi is fully back in idle dispatch. Sending as a
362
- // normal user message on the next idle tick reliably starts a fresh turn;
363
- // queueing followUp from inside agent_end can be too late to be drained.
348
+ // agent_settled means retries, compaction, and queued continuations are
349
+ // finished. Send on the next idle tick as a fresh turn.
364
350
  pi.sendUserMessage(nudge.message);
365
351
  } catch (err) {
366
352
  if (isAgentBusyRaceError(err)) {
@@ -413,12 +399,6 @@ export default function (pi: ExtensionAPI) {
413
399
  clearNudgeTimer();
414
400
  });
415
401
 
416
- pi.events.on(RETRY_ACTIVE_EVENT, (data: unknown) => {
417
- const active = data != null && typeof data === "object" && (data as { active?: unknown }).active === true;
418
- retryActive = active;
419
- if (active) clearNudgeTimer();
420
- });
421
-
422
402
  pi.on("model_select", async (event) => {
423
403
  currentModel = event.model;
424
404
  if (todoThinkingEnabled) registerTodoToolWithCurrentPrompt();
@@ -439,7 +419,7 @@ export default function (pi: ExtensionAPI) {
439
419
  pi.on("agent_start", async (_event, ctx) => {
440
420
  activateTodoStateScope(ctx);
441
421
  pendingAskUserToolCallIds.clear();
442
- retryActive = false;
422
+ settledNudgeEligible = false;
443
423
  inProgressAtAgentStart = new Set(selectVisibleTasks(getState()).filter((task) => task.status === "in_progress").map((task) => task.id));
444
424
  });
445
425
 
@@ -455,26 +435,42 @@ export default function (pi: ExtensionAPI) {
455
435
  pi.on("agent_end", async (event, ctx) => {
456
436
  activateTodoStateScope(ctx);
457
437
  const completedAssistantReply = hasCompletedAssistantReply((event as { messages?: readonly unknown[] } | undefined)?.messages);
438
+ settledNudgeEligible = completedAssistantReply;
458
439
 
459
440
  if (suppressNextNudgeForThinkingSwitch) {
460
441
  suppressNextNudgeForThinkingSwitch = false;
461
442
  if (!completedAssistantReply) {
443
+ settledNudgeEligible = false;
462
444
  clearNudgeTimer();
463
445
  return;
464
446
  }
465
447
  }
466
448
 
467
449
  if (pendingAskUserToolCallIds.size > 0) {
450
+ settledNudgeEligible = false;
468
451
  clearNudgeTimer();
469
452
  return;
470
453
  }
471
454
 
472
455
  if (completedAssistantReply && maybeRecoverCompletedCurrentTask((event as { messages?: readonly unknown[] } | undefined)?.messages, ctx)) {
456
+ settledNudgeEligible = false;
473
457
  lastNudgedSignature = undefined;
474
458
  clearNudgeTimer();
475
459
  return;
476
460
  }
461
+ });
477
462
 
463
+ pi.on("agent_settled", async (_event, ctx) => {
464
+ activateTodoStateScope(ctx);
465
+ if (!settledNudgeEligible) {
466
+ clearNudgeTimer();
467
+ return;
468
+ }
469
+ settledNudgeEligible = false;
470
+ if (pendingAskUserToolCallIds.size > 0) {
471
+ clearNudgeTimer();
472
+ return;
473
+ }
478
474
  const nudge = getUnfinishedTodoNudge();
479
475
  if (!nudge) {
480
476
  lastNudgedSignature = undefined;
@@ -30,7 +30,7 @@ function uniqueNumbers(values: number[] | undefined): number[] {
30
30
  }
31
31
 
32
32
  function isTodoThinkingLevel(value: unknown): value is TodoThinkingLevel {
33
- return value === "off" || value === "minimal" || value === "low" || value === "medium" || value === "high" || value === "xhigh";
33
+ return value === "off" || value === "minimal" || value === "low" || value === "medium" || value === "high" || value === "xhigh" || value === "max";
34
34
  }
35
35
 
36
36
  function findTask(state: TaskState, id: number): Task | undefined {
@@ -24,7 +24,7 @@ export const MSG_NO_TODOS = "No todos yet. Ask the agent to add some!";
24
24
  // ---------------------------------------------------------------------------
25
25
 
26
26
  export type TaskStatus = "pending" | "in_progress" | "deferred" | "completed" | "deleted";
27
- export type TodoThinkingLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh";
27
+ export type TodoThinkingLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
28
28
 
29
29
  export type TaskAction = "create" | "update" | "batch_create" | "batch_update" | "list" | "get" | "delete" | "clear" | "export" | "import";
30
30
 
@@ -104,7 +104,7 @@ export const TodoParamsSchema = Type.Object({
104
104
  }),
105
105
  ),
106
106
  thinking: Type.Optional(
107
- StringEnum(["off", "minimal", "low", "medium", "high", "xhigh"] as const, {
107
+ StringEnum(["off", "minimal", "low", "medium", "high", "xhigh", "max"] as const, {
108
108
  description: "Per-task thinking level used when todoThinking is enabled and this task is in_progress",
109
109
  }),
110
110
  ),
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "pi-ui-extend",
3
- "version": "0.1.55",
3
+ "version": "0.1.57",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "bin": {
7
+ "pi-ui-extend": "./bin/pix.mjs",
7
8
  "pix": "./bin/pix.mjs"
8
9
  },
9
10
  "exports": {
@@ -64,9 +65,9 @@
64
65
  "prepublishOnly": "npm run check && npm run build:pix && npm run generate-schemas"
65
66
  },
66
67
  "dependencies": {
67
- "@earendil-works/pi-ai": "0.80.3",
68
- "@earendil-works/pi-coding-agent": "0.80.3",
69
- "@earendil-works/pi-tui": "0.80.3",
68
+ "@earendil-works/pi-ai": "0.80.6",
69
+ "@earendil-works/pi-coding-agent": "0.80.6",
70
+ "@earendil-works/pi-tui": "0.80.6",
70
71
  "@mariozechner/clipboard": "^0.3.9",
71
72
  "jsonc-parser": "3.3.1",
72
73
  "typebox": "1.1.38",
package/schemas/pix.json CHANGED
@@ -46,6 +46,10 @@
46
46
  {
47
47
  "type": "string",
48
48
  "const": "xhigh"
49
+ },
50
+ {
51
+ "type": "string",
52
+ "const": "max"
49
53
  }
50
54
  ],
51
55
  "description": "Default model thinking budget level."