@oh-my-pi/pi-coding-agent 15.0.0 → 15.0.1

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 (140) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/examples/extensions/plan-mode.ts +0 -1
  3. package/package.json +9 -9
  4. package/scripts/build-binary.ts +5 -0
  5. package/src/autoresearch/helpers.ts +17 -0
  6. package/src/autoresearch/tools/log-experiment.ts +9 -17
  7. package/src/autoresearch/tools/run-experiment.ts +2 -17
  8. package/src/capability/skill.ts +7 -0
  9. package/src/cli/list-models.ts +1 -1
  10. package/src/cli/shell-cli.ts +3 -13
  11. package/src/cli/update-cli.ts +1 -1
  12. package/src/cli.ts +10 -29
  13. package/src/commit/agentic/tools/propose-changelog.ts +8 -1
  14. package/src/commit/analysis/conventional.ts +8 -66
  15. package/src/commit/map-reduce/reduce-phase.ts +6 -65
  16. package/src/commit/pipeline.ts +2 -2
  17. package/src/commit/shared-llm.ts +89 -0
  18. package/src/config/config-file.ts +210 -0
  19. package/src/config/model-equivalence.ts +8 -11
  20. package/src/config/model-registry.ts +13 -2
  21. package/src/config/model-resolver.ts +1 -4
  22. package/src/config/settings-schema.ts +71 -1
  23. package/src/config/settings.ts +1 -1
  24. package/src/config.ts +3 -219
  25. package/src/edit/renderer.ts +7 -1
  26. package/src/eval/js/executor.ts +3 -0
  27. package/src/eval/js/shared/rewrite-imports.ts +2 -2
  28. package/src/eval/py/executor.ts +5 -0
  29. package/src/exa/factory.ts +2 -2
  30. package/src/exa/mcp-client.ts +74 -1
  31. package/src/exec/bash-executor.ts +5 -1
  32. package/src/export/html/template.generated.ts +1 -1
  33. package/src/export/html/template.js +0 -11
  34. package/src/extensibility/extensions/runner.ts +1 -1
  35. package/src/extensibility/extensions/types.ts +89 -223
  36. package/src/extensibility/hooks/types.ts +89 -314
  37. package/src/extensibility/shared-events.ts +343 -0
  38. package/src/extensibility/skills.ts +9 -0
  39. package/src/goals/index.ts +3 -0
  40. package/src/goals/runtime.ts +500 -0
  41. package/src/goals/state.ts +37 -0
  42. package/src/goals/tools/goal-tool.ts +237 -0
  43. package/src/hashline/anchors.ts +2 -2
  44. package/src/hindsight/mental-models.ts +1 -1
  45. package/src/internal-urls/agent-protocol.ts +1 -20
  46. package/src/internal-urls/artifact-protocol.ts +1 -19
  47. package/src/internal-urls/docs-index.generated.ts +5 -6
  48. package/src/internal-urls/registry-helpers.ts +25 -0
  49. package/src/main.ts +11 -2
  50. package/src/mcp/oauth-flow.ts +20 -0
  51. package/src/modes/acp/acp-agent.ts +79 -45
  52. package/src/modes/components/assistant-message.ts +14 -8
  53. package/src/modes/components/bash-execution.ts +24 -63
  54. package/src/modes/components/custom-message.ts +14 -40
  55. package/src/modes/components/eval-execution.ts +27 -57
  56. package/src/modes/components/execution-shared.ts +102 -0
  57. package/src/modes/components/hook-message.ts +17 -49
  58. package/src/modes/components/mcp-add-wizard.ts +26 -5
  59. package/src/modes/components/message-frame.ts +88 -0
  60. package/src/modes/components/model-selector.ts +1 -1
  61. package/src/modes/components/session-observer-overlay.ts +6 -2
  62. package/src/modes/components/session-selector.ts +1 -1
  63. package/src/modes/components/status-line/segments.ts +55 -4
  64. package/src/modes/components/status-line/types.ts +4 -0
  65. package/src/modes/components/status-line.ts +28 -10
  66. package/src/modes/components/tool-execution.ts +7 -8
  67. package/src/modes/controllers/command-controller-shared.ts +108 -0
  68. package/src/modes/controllers/command-controller.ts +13 -4
  69. package/src/modes/controllers/event-controller.ts +36 -7
  70. package/src/modes/controllers/input-controller.ts +13 -0
  71. package/src/modes/controllers/mcp-command-controller.ts +56 -61
  72. package/src/modes/controllers/ssh-command-controller.ts +18 -57
  73. package/src/modes/interactive-mode.ts +624 -52
  74. package/src/modes/print-mode.ts +16 -86
  75. package/src/modes/rpc/rpc-mode.ts +14 -87
  76. package/src/modes/runtime-init.ts +115 -0
  77. package/src/modes/theme/defaults/dark-poimandres.json +2 -0
  78. package/src/modes/theme/defaults/light-poimandres.json +2 -0
  79. package/src/modes/theme/theme.ts +18 -6
  80. package/src/modes/types.ts +14 -3
  81. package/src/modes/utils/context-usage.ts +13 -13
  82. package/src/modes/utils/ui-helpers.ts +10 -3
  83. package/src/plan-mode/approved-plan.ts +35 -1
  84. package/src/prompts/goals/goal-budget-limit.md +16 -0
  85. package/src/prompts/goals/goal-continuation.md +28 -0
  86. package/src/prompts/goals/goal-mode-active.md +23 -0
  87. package/src/prompts/system/plan-mode-active.md +5 -5
  88. package/src/prompts/system/plan-mode-tool-decision-reminder.md +1 -1
  89. package/src/prompts/tools/bash.md +6 -0
  90. package/src/prompts/tools/goal.md +13 -0
  91. package/src/prompts/tools/hashline.md +102 -114
  92. package/src/prompts/tools/read.md +1 -0
  93. package/src/prompts/tools/resolve.md +6 -5
  94. package/src/sdk.ts +12 -5
  95. package/src/session/agent-session.ts +428 -106
  96. package/src/session/blob-store.ts +36 -3
  97. package/src/session/messages.ts +67 -2
  98. package/src/session/session-manager.ts +131 -12
  99. package/src/session/session-storage.ts +33 -15
  100. package/src/session/streaming-output.ts +309 -13
  101. package/src/slash-commands/builtin-registry.ts +18 -0
  102. package/src/ssh/ssh-executor.ts +5 -0
  103. package/src/system-prompt.ts +4 -2
  104. package/src/task/executor.ts +17 -7
  105. package/src/task/index.ts +3 -0
  106. package/src/task/render.ts +21 -15
  107. package/src/task/types.ts +4 -0
  108. package/src/tools/ast-edit.ts +21 -120
  109. package/src/tools/ast-grep.ts +21 -119
  110. package/src/tools/bash-interactive.ts +9 -1
  111. package/src/tools/bash.ts +27 -4
  112. package/src/tools/browser/attach.ts +3 -3
  113. package/src/tools/browser/launch.ts +81 -18
  114. package/src/tools/browser/registry.ts +1 -5
  115. package/src/tools/browser/tab-supervisor.ts +51 -14
  116. package/src/tools/conflict-detect.ts +15 -4
  117. package/src/tools/eval.ts +3 -1
  118. package/src/tools/find.ts +20 -38
  119. package/src/tools/gh.ts +7 -6
  120. package/src/tools/index.ts +22 -11
  121. package/src/tools/inspect-image.ts +3 -10
  122. package/src/tools/output-meta.ts +176 -37
  123. package/src/tools/path-utils.ts +125 -2
  124. package/src/tools/read.ts +516 -233
  125. package/src/tools/render-utils.ts +92 -0
  126. package/src/tools/renderers.ts +2 -0
  127. package/src/tools/resolve.ts +72 -44
  128. package/src/tools/search.ts +120 -186
  129. package/src/tools/write.ts +44 -9
  130. package/src/utils/file-mentions.ts +1 -1
  131. package/src/utils/image-loading.ts +7 -3
  132. package/src/utils/image-resize.ts +32 -43
  133. package/src/vim/parser.ts +0 -17
  134. package/src/vim/render.ts +1 -1
  135. package/src/vim/types.ts +1 -1
  136. package/src/web/search/providers/gemini.ts +35 -95
  137. package/src/prompts/tools/exit-plan-mode.md +0 -6
  138. package/src/tools/exit-plan-mode.ts +0 -97
  139. package/src/utils/fuzzy.ts +0 -108
  140. package/src/utils/image-convert.ts +0 -27
@@ -1,28 +1,44 @@
1
- /**
2
- * Hook system types.
3
- *
4
- * Hooks are TypeScript modules that can subscribe to agent lifecycle events
5
- * and interact with the user via UI primitives.
6
- */
7
- import type { AgentMessage } from "@oh-my-pi/pi-agent-core";
8
- import type { ImageContent, Message, Model, TextContent, ToolResultMessage } from "@oh-my-pi/pi-ai";
1
+ import type { ImageContent, Message, Model, TextContent } from "@oh-my-pi/pi-ai";
9
2
  import type { Component, TUI } from "@oh-my-pi/pi-tui";
10
- import type { Rule } from "../../capability/rule";
11
3
  import type { ModelRegistry } from "../../config/model-registry";
12
4
  import type { EditToolDetails } from "../../edit";
13
5
  import type { ExecOptions, ExecResult } from "../../exec/exec";
14
6
  import type { Theme } from "../../modes/theme/theme";
15
- import type { CompactionPreparation, CompactionResult } from "../../session/compaction";
16
7
  import type { HookMessage } from "../../session/messages";
17
- import type {
18
- BranchSummaryEntry,
19
- CompactionEntry,
20
- ReadonlySessionManager,
21
- SessionEntry,
22
- SessionManager,
23
- } from "../../session/session-manager";
8
+ import type { ReadonlySessionManager, SessionManager } from "../../session/session-manager";
24
9
  import type { BashToolDetails, FindToolDetails, ReadToolDetails, SearchToolDetails } from "../../tools";
25
- import type { TodoItem } from "../../tools/todo-write";
10
+ import type {
11
+ AgentEndEvent,
12
+ AgentStartEvent,
13
+ AutoCompactionEndEvent,
14
+ AutoCompactionStartEvent,
15
+ AutoRetryEndEvent,
16
+ AutoRetryStartEvent,
17
+ ContextEvent,
18
+ SessionBeforeBranchEvent,
19
+ SessionBeforeBranchResult,
20
+ SessionBeforeCompactEvent,
21
+ SessionBeforeCompactResult,
22
+ SessionBeforeSwitchEvent,
23
+ SessionBeforeSwitchResult,
24
+ SessionBeforeTreeEvent,
25
+ SessionBeforeTreeResult,
26
+ SessionBranchEvent,
27
+ SessionCompactEvent,
28
+ SessionCompactingEvent,
29
+ SessionCompactingResult,
30
+ SessionEvent,
31
+ SessionShutdownEvent,
32
+ SessionStartEvent,
33
+ SessionSwitchEvent,
34
+ SessionTreeEvent,
35
+ TodoReminderEvent,
36
+ ToolCallEventResult,
37
+ ToolResultEventResult,
38
+ TtsrTriggeredEvent,
39
+ TurnEndEvent,
40
+ TurnStartEvent,
41
+ } from "../shared-events";
26
42
 
27
43
  // Re-export for backward compatibility
28
44
  export type { ExecOptions, ExecResult } from "../../exec/exec";
@@ -31,6 +47,11 @@ export type { ExecOptions, ExecResult } from "../../exec/exec";
31
47
  * UI context for hooks to request interactive UI from the harness.
32
48
  * Each mode (interactive, RPC, print) provides its own implementation.
33
49
  */
50
+ // fallow-ignore-next-line code-duplication
51
+ // Parallel to ExtensionUIContext: hooks expose a deliberately narrower UI
52
+ // surface — no terminal-input listener, no editor component override, no
53
+ // theme management — because hooks are invoked from inside the agent loop
54
+ // and must not be able to seize ownership of the editor.
34
55
  export interface HookUIContext {
35
56
  /**
36
57
  * Show a selector and return the user's choice.
@@ -137,6 +158,11 @@ export interface HookUIContext {
137
158
  * Context passed to hook event handlers.
138
159
  * For command handlers, see HookCommandContext which extends this with session control methods.
139
160
  */
161
+ // fallow-ignore-next-line code-duplication
162
+ // Parallel to ExtensionContext: hooks see a narrower runtime context (no
163
+ // model registry mutation, no system prompt access, no shutdown). The
164
+ // overlap in field names is intentional API symmetry; widening hooks to
165
+ // match extensions would let hooks call methods that deadlock the agent.
140
166
  export interface HookContext {
141
167
  /** UI methods for user interaction */
142
168
  ui: HookUIContext;
@@ -165,6 +191,11 @@ export interface HookContext {
165
191
  * These methods are not available in event handlers because they can cause
166
192
  * deadlocks when called from within the agent loop (e.g., tool_call, context events).
167
193
  */
194
+ // fallow-ignore-next-line code-duplication
195
+ // Parallel to ExtensionCommandContext: hooks intentionally omit
196
+ // `switchSession`, `reload`, `compact`, and `getContextUsage` — those are
197
+ // safe only from extension command handlers, not from the hook execution
198
+ // context.
168
199
  export interface HookCommandContext extends HookContext {
169
200
  /** Wait for the agent to finish streaming */
170
201
  waitForIdle(): Promise<void>;
@@ -210,138 +241,25 @@ export interface HookCommandContext extends HookContext {
210
241
  }
211
242
 
212
243
  // ============================================================================
213
- // Session Events
244
+ // Session Events (shared with extensions subsystem)
214
245
  // ============================================================================
215
246
 
216
- /** Fired on initial session load */
217
- export interface SessionStartEvent {
218
- type: "session_start";
219
- }
220
-
221
- /** Fired before switching to another session (can be cancelled) */
222
- export interface SessionBeforeSwitchEvent {
223
- type: "session_before_switch";
224
- /** Reason for the switch */
225
- reason: "new" | "resume" | "fork";
226
- /** Session file we're switching to (only for "resume") */
227
- targetSessionFile?: string;
228
- }
229
-
230
- /** Fired after switching to another session */
231
- export interface SessionSwitchEvent {
232
- type: "session_switch";
233
- /** Reason for the switch */
234
- reason: "new" | "resume" | "fork";
235
- /** Session file we came from */
236
- previousSessionFile: string | undefined;
237
- }
238
-
239
- /** Fired before branching a session (can be cancelled) */
240
- export interface SessionBeforeBranchEvent {
241
- type: "session_before_branch";
242
- /** ID of the entry to branch from */
243
- entryId: string;
244
- }
245
-
246
- /** Fired after branching a session */
247
- export interface SessionBranchEvent {
248
- type: "session_branch";
249
- previousSessionFile: string | undefined;
250
- }
251
-
252
- /** Fired before context compaction (can be cancelled) */
253
- export interface SessionBeforeCompactEvent {
254
- type: "session_before_compact";
255
- /** Compaction preparation with messages to summarize, file ops, previous summary, etc. */
256
- preparation: CompactionPreparation;
257
- /** Branch entries (root to current leaf). Use to inspect custom state or previous compactions. */
258
- branchEntries: SessionEntry[];
259
- /** Optional user-provided instructions for the summary */
260
- customInstructions?: string;
261
- /** Abort signal - hooks should pass this to LLM calls and check it periodically */
262
- signal: AbortSignal;
263
- }
264
-
265
- /** Fired before compaction summarization to customize prompts/context */
266
- export interface SessionCompactingEvent {
267
- type: "session.compacting";
268
- sessionId: string;
269
- messages: AgentMessage[];
270
- }
271
-
272
- /** Fired after context compaction */
273
- export interface SessionCompactEvent {
274
- type: "session_compact";
275
- compactionEntry: CompactionEntry;
276
- /** Whether the compaction entry was provided by a hook */
277
- fromExtension: boolean;
278
- }
279
-
280
- /** Fired on process exit (SIGINT/SIGTERM) */
281
- export interface SessionShutdownEvent {
282
- type: "session_shutdown";
283
- }
284
-
285
- /** Preparation data for tree navigation (used by session_before_tree event) */
286
- export interface TreePreparation {
287
- /** Node being switched to */
288
- targetId: string;
289
- /** Current active leaf (being abandoned), null if no current position */
290
- oldLeafId: string | null;
291
- /** Common ancestor of target and old leaf, null if no common ancestor */
292
- commonAncestorId: string | null;
293
- /** Entries to summarize (old leaf back to common ancestor or compaction) */
294
- entriesToSummarize: SessionEntry[];
295
- /** Whether user chose to summarize */
296
- userWantsSummary: boolean;
297
- }
298
-
299
- /** Fired before navigating to a different node in the session tree (can be cancelled) */
300
- export interface SessionBeforeTreeEvent {
301
- type: "session_before_tree";
302
- /** Preparation data for the navigation */
303
- preparation: TreePreparation;
304
- /** Abort signal - honors Escape during summarization (model available via ctx.model) */
305
- signal: AbortSignal;
306
- }
307
-
308
- /** Fired after navigating to a different node in the session tree */
309
- export interface SessionTreeEvent {
310
- type: "session_tree";
311
- /** The new active leaf, null if navigated to before first entry */
312
- newLeafId: string | null;
313
- /** Previous active leaf, null if there was no position */
314
- oldLeafId: string | null;
315
- /** Branch summary entry if one was created */
316
- summaryEntry?: BranchSummaryEntry;
317
- /** Whether summary came from hook */
318
- fromExtension?: boolean;
319
- }
320
-
321
- /** Union of all session event types */
322
- export type SessionEvent =
323
- | SessionStartEvent
324
- | SessionBeforeSwitchEvent
325
- | SessionSwitchEvent
326
- | SessionBeforeBranchEvent
327
- | SessionBranchEvent
328
- | SessionBeforeCompactEvent
329
- | SessionCompactingEvent
330
- | SessionCompactEvent
331
- | SessionShutdownEvent
332
- | SessionBeforeTreeEvent
333
- | SessionTreeEvent;
334
-
335
- /**
336
- * Event data for context event.
337
- * Fired before each LLM call, allowing hooks to modify context non-destructively.
338
- * Original session messages are NOT modified - only the messages sent to the LLM are affected.
339
- */
340
- export interface ContextEvent {
341
- type: "context";
342
- /** Messages about to be sent to the LLM (deep copy, safe to modify) */
343
- messages: AgentMessage[];
344
- }
247
+ export type {
248
+ ContextEvent,
249
+ SessionBeforeBranchEvent,
250
+ SessionBeforeCompactEvent,
251
+ SessionBeforeSwitchEvent,
252
+ SessionBeforeTreeEvent,
253
+ SessionBranchEvent,
254
+ SessionCompactEvent,
255
+ SessionCompactingEvent,
256
+ SessionEvent,
257
+ SessionShutdownEvent,
258
+ SessionStartEvent,
259
+ SessionSwitchEvent,
260
+ SessionTreeEvent,
261
+ TreePreparation,
262
+ } from "../shared-events";
345
263
 
346
264
  /**
347
265
  * Event data for before_agent_start event.
@@ -356,90 +274,18 @@ export interface BeforeAgentStartEvent {
356
274
  images?: ImageContent[];
357
275
  }
358
276
 
359
- /**
360
- * Event data for agent_start event.
361
- * Fired when an agent loop starts (once per user prompt).
362
- */
363
- export interface AgentStartEvent {
364
- type: "agent_start";
365
- }
366
-
367
- /**
368
- * Event data for agent_end event.
369
- */
370
- export interface AgentEndEvent {
371
- type: "agent_end";
372
- messages: AgentMessage[];
373
- }
374
-
375
- /**
376
- * Event data for turn_start event.
377
- */
378
- export interface TurnStartEvent {
379
- type: "turn_start";
380
- turnIndex: number;
381
- timestamp: number;
382
- }
383
-
384
- /**
385
- * Event data for turn_end event.
386
- */
387
- export interface TurnEndEvent {
388
- type: "turn_end";
389
- turnIndex: number;
390
- message: AgentMessage;
391
- toolResults: ToolResultMessage[];
392
- }
393
-
394
- /** Event data for auto_compaction_start event. */
395
- export interface AutoCompactionStartEvent {
396
- type: "auto_compaction_start";
397
- reason: "threshold" | "overflow" | "idle";
398
- action: "context-full" | "handoff";
399
- }
400
-
401
- /** Event data for auto_compaction_end event. */
402
- export interface AutoCompactionEndEvent {
403
- type: "auto_compaction_end";
404
- action: "context-full" | "handoff";
405
- result: CompactionResult | undefined;
406
- aborted: boolean;
407
- willRetry: boolean;
408
- errorMessage?: string;
409
- /** True when compaction was skipped for a benign reason (no model, no candidates, nothing to compact). */
410
- skipped?: boolean;
411
- }
412
-
413
- /** Event data for auto_retry_start event. */
414
- export interface AutoRetryStartEvent {
415
- type: "auto_retry_start";
416
- attempt: number;
417
- maxAttempts: number;
418
- delayMs: number;
419
- errorMessage: string;
420
- }
421
-
422
- /** Event data for auto_retry_end event. */
423
- export interface AutoRetryEndEvent {
424
- type: "auto_retry_end";
425
- success: boolean;
426
- attempt: number;
427
- finalError?: string;
428
- }
429
-
430
- /** Event data for ttsr_triggered event. */
431
- export interface TtsrTriggeredEvent {
432
- type: "ttsr_triggered";
433
- rules: Rule[];
434
- }
435
-
436
- /** Event data for todo_reminder event. */
437
- export interface TodoReminderEvent {
438
- type: "todo_reminder";
439
- todos: TodoItem[];
440
- attempt: number;
441
- maxAttempts: number;
442
- }
277
+ export type {
278
+ AgentEndEvent,
279
+ AgentStartEvent,
280
+ AutoCompactionEndEvent,
281
+ AutoCompactionStartEvent,
282
+ AutoRetryEndEvent,
283
+ AutoRetryStartEvent,
284
+ TodoReminderEvent,
285
+ TtsrTriggeredEvent,
286
+ TurnEndEvent,
287
+ TurnStartEvent,
288
+ } from "../shared-events";
443
289
 
444
290
  /**
445
291
  * Event data for tool_call event.
@@ -559,29 +405,7 @@ export interface ContextEventResult {
559
405
  messages?: Message[];
560
406
  }
561
407
 
562
- /**
563
- * Return type for tool_call event handlers.
564
- * Allows hooks to block tool execution.
565
- */
566
- export interface ToolCallEventResult {
567
- /** If true, block the tool from executing */
568
- block?: boolean;
569
- /** Reason for blocking (returned to LLM as error) */
570
- reason?: string;
571
- }
572
-
573
- /**
574
- * Return type for tool_result event handlers.
575
- * Allows hooks to modify tool results.
576
- */
577
- export interface ToolResultEventResult {
578
- /** Replacement content array (text and images) */
579
- content?: (TextContent | ImageContent)[];
580
- /** Replacement details */
581
- details?: unknown;
582
- /** Override isError flag */
583
- isError?: boolean;
584
- }
408
+ export type { ToolCallEventResult, ToolResultEventResult } from "../shared-events";
585
409
 
586
410
  /**
587
411
  * Return type for before_agent_start event handlers.
@@ -592,65 +416,13 @@ export interface BeforeAgentStartEventResult {
592
416
  message?: Pick<HookMessage, "customType" | "content" | "display" | "details" | "attribution">;
593
417
  }
594
418
 
595
- /** Return type for session_before_switch handlers */
596
- export interface SessionBeforeSwitchResult {
597
- /** If true, cancel the switch */
598
- cancel?: boolean;
599
- }
600
-
601
- /** Return type for session_before_branch handlers */
602
- export interface SessionBeforeBranchResult {
603
- /**
604
- * If true, abort the branch entirely. No new session file is created,
605
- * conversation stays unchanged.
606
- */
607
- cancel?: boolean;
608
- /**
609
- * If true, the branch proceeds (new session file created, session state updated)
610
- * but the in-memory conversation is NOT rewound to the branch point.
611
- *
612
- * Use case: git-checkpoint hook that restores code state separately.
613
- * The hook handles state restoration itself, so it doesn't want the
614
- * agent's conversation to be rewound (which would lose recent context).
615
- *
616
- * - `cancel: true` → nothing happens, user stays in current session
617
- * - `skipConversationRestore: true` → branch happens, but messages stay as-is
618
- * - neither → branch happens AND messages rewind to branch point (default)
619
- */
620
- skipConversationRestore?: boolean;
621
- }
622
-
623
- /** Return type for session_before_compact handlers */
624
- export interface SessionBeforeCompactResult {
625
- /** If true, cancel the compaction */
626
- cancel?: boolean;
627
- /** Custom compaction result - SessionManager adds id/parentId */
628
- compaction?: CompactionResult;
629
- }
630
-
631
- /** Return type for session.compacting handlers */
632
- export interface SessionCompactingResult {
633
- /** Additional context lines to include in summary */
634
- context?: string[];
635
- /** Override the default compaction prompt */
636
- prompt?: string;
637
- /** Custom data to store in compaction entry */
638
- preserveData?: Record<string, unknown>;
639
- }
640
-
641
- /** Return type for session_before_tree handlers */
642
- export interface SessionBeforeTreeResult {
643
- /** If true, cancel the navigation entirely */
644
- cancel?: boolean;
645
- /**
646
- * Custom summary (skips default summarizer).
647
- * Only used if preparation.userWantsSummary is true.
648
- */
649
- summary?: {
650
- summary: string;
651
- details?: unknown;
652
- };
653
- }
419
+ export type {
420
+ SessionBeforeBranchResult,
421
+ SessionBeforeCompactResult,
422
+ SessionBeforeSwitchResult,
423
+ SessionBeforeTreeResult,
424
+ SessionCompactingResult,
425
+ } from "../shared-events";
654
426
 
655
427
  // ============================================================================
656
428
  // Hook API
@@ -681,6 +453,9 @@ export type HookMessageRenderer<T = unknown> = (
681
453
  /**
682
454
  * Command registration options.
683
455
  */
456
+ // fallow-ignore-next-line code-duplication
457
+ // Parallel to extensions' RegisteredCommand: hooks bind to
458
+ // HookCommandContext and have no argument-completion hook.
684
459
  export interface RegisteredCommand {
685
460
  name: string;
686
461
  description?: string;