@bastani/atomic 0.9.27 → 0.9.28-alpha.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 (226) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +6 -0
  3. package/dist/builtin/intercom/broker/broker.ts +13 -1
  4. package/dist/builtin/intercom/package.json +2 -2
  5. package/dist/builtin/mcp/CHANGELOG.md +6 -0
  6. package/dist/builtin/mcp/package.json +1 -1
  7. package/dist/builtin/subagents/package.json +3 -3
  8. package/dist/builtin/web-access/index.bundle.mjs +194 -44
  9. package/dist/builtin/web-access/package.json +3 -3
  10. package/dist/builtin/workflows/CHANGELOG.md +8 -0
  11. package/dist/builtin/workflows/builtin/{chunk-gts8wgjr.js → chunk-f61w0hpm.js} +1 -1
  12. package/dist/builtin/workflows/builtin/{chunk-9bhs02gm.js → chunk-tecnpe8j.js} +1 -1
  13. package/dist/builtin/workflows/builtin/{chunk-gw7rghda.js → chunk-wz8v67bn.js} +1 -1
  14. package/dist/builtin/workflows/builtin/goal.js +2 -2
  15. package/dist/builtin/workflows/builtin/index.js +3 -3
  16. package/dist/builtin/workflows/builtin/ralph.js +2 -2
  17. package/dist/builtin/workflows/package.json +2 -2
  18. package/dist/builtin/workflows/src/extension/index.bundle.mjs +7958 -7904
  19. package/dist/builtin/workflows/src/index.js +11210 -11204
  20. package/dist/cli/args.d.ts +1 -0
  21. package/dist/cli/args.d.ts.map +1 -1
  22. package/dist/cli/args.js +12 -5
  23. package/dist/cli/args.js.map +1 -1
  24. package/dist/codemode-worker.js +99 -3
  25. package/dist/core/agent-session-events.js +1 -1
  26. package/dist/core/agent-session-events.js.map +1 -1
  27. package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
  28. package/dist/core/agent-session-extension-bindings.js +9 -5
  29. package/dist/core/agent-session-extension-bindings.js.map +1 -1
  30. package/dist/core/agent-session-methods.d.ts +2 -0
  31. package/dist/core/agent-session-methods.d.ts.map +1 -1
  32. package/dist/core/agent-session-methods.js.map +1 -1
  33. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  34. package/dist/core/agent-session-prompt.js +5 -2
  35. package/dist/core/agent-session-prompt.js.map +1 -1
  36. package/dist/core/agent-session-services.d.ts +1 -0
  37. package/dist/core/agent-session-services.d.ts.map +1 -1
  38. package/dist/core/agent-session-services.js +1 -0
  39. package/dist/core/agent-session-services.js.map +1 -1
  40. package/dist/core/agent-session-state.d.ts.map +1 -1
  41. package/dist/core/agent-session-state.js +3 -2
  42. package/dist/core/agent-session-state.js.map +1 -1
  43. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  44. package/dist/core/agent-session-tool-registry.js +10 -16
  45. package/dist/core/agent-session-tool-registry.js.map +1 -1
  46. package/dist/core/agent-session.d.ts +2 -0
  47. package/dist/core/agent-session.d.ts.map +1 -1
  48. package/dist/core/agent-session.js +5 -0
  49. package/dist/core/agent-session.js.map +1 -1
  50. package/dist/core/auth-storage-backends.d.ts.map +1 -1
  51. package/dist/core/auth-storage-backends.js +2 -1
  52. package/dist/core/auth-storage-backends.js.map +1 -1
  53. package/dist/core/auth-storage.d.ts +1 -1
  54. package/dist/core/auth-storage.d.ts.map +1 -1
  55. package/dist/core/auth-storage.js +15 -7
  56. package/dist/core/auth-storage.js.map +1 -1
  57. package/dist/core/azure-provider-compat.d.ts +8 -0
  58. package/dist/core/azure-provider-compat.d.ts.map +1 -0
  59. package/dist/core/azure-provider-compat.js +65 -0
  60. package/dist/core/azure-provider-compat.js.map +1 -0
  61. package/dist/core/child-session-options.d.ts +1 -1
  62. package/dist/core/child-session-options.d.ts.map +1 -1
  63. package/dist/core/child-session-options.js +11 -2
  64. package/dist/core/child-session-options.js.map +1 -1
  65. package/dist/core/extensions/api-types.d.ts +1 -0
  66. package/dist/core/extensions/api-types.d.ts.map +1 -1
  67. package/dist/core/extensions/api-types.js.map +1 -1
  68. package/dist/core/extensions/loader-api.d.ts.map +1 -1
  69. package/dist/core/extensions/loader-api.js +5 -0
  70. package/dist/core/extensions/loader-api.js.map +1 -1
  71. package/dist/core/extensions/loader-host-modules.d.ts +1 -0
  72. package/dist/core/extensions/loader-host-modules.d.ts.map +1 -1
  73. package/dist/core/extensions/loader-host-modules.js +12 -0
  74. package/dist/core/extensions/loader-host-modules.js.map +1 -1
  75. package/dist/core/extensions/runner.d.ts +1 -1
  76. package/dist/core/extensions/runner.d.ts.map +1 -1
  77. package/dist/core/extensions/runner.js +7 -2
  78. package/dist/core/extensions/runner.js.map +1 -1
  79. package/dist/core/extensions/tool-types.d.ts +2 -0
  80. package/dist/core/extensions/tool-types.d.ts.map +1 -1
  81. package/dist/core/extensions/tool-types.js.map +1 -1
  82. package/dist/core/fast-model-variants.d.ts +1 -1
  83. package/dist/core/fast-model-variants.js +1 -1
  84. package/dist/core/fast-model-variants.js.map +1 -1
  85. package/dist/core/keybindings.d.ts +4 -4
  86. package/dist/core/model-config.d.ts.map +1 -1
  87. package/dist/core/model-config.js +2 -1
  88. package/dist/core/model-config.js.map +1 -1
  89. package/dist/core/model-fallback-failures.d.ts.map +1 -1
  90. package/dist/core/model-fallback-failures.js +5 -1
  91. package/dist/core/model-fallback-failures.js.map +1 -1
  92. package/dist/core/model-resolver-cli.d.ts.map +1 -1
  93. package/dist/core/model-resolver-cli.js +5 -1
  94. package/dist/core/model-resolver-cli.js.map +1 -1
  95. package/dist/core/model-resolver-defaults.js +1 -1
  96. package/dist/core/model-resolver-defaults.js.map +1 -1
  97. package/dist/core/model-resolver-initial.d.ts.map +1 -1
  98. package/dist/core/model-resolver-initial.js +6 -1
  99. package/dist/core/model-resolver-initial.js.map +1 -1
  100. package/dist/core/model-resolver-patterns.d.ts.map +1 -1
  101. package/dist/core/model-resolver-patterns.js +2 -1
  102. package/dist/core/model-resolver-patterns.js.map +1 -1
  103. package/dist/core/model-resolver-scope.d.ts.map +1 -1
  104. package/dist/core/model-resolver-scope.js +3 -1
  105. package/dist/core/model-resolver-scope.js.map +1 -1
  106. package/dist/core/model-runtime-streaming.d.ts.map +1 -1
  107. package/dist/core/model-runtime-streaming.js +2 -0
  108. package/dist/core/model-runtime-streaming.js.map +1 -1
  109. package/dist/core/model-runtime.d.ts.map +1 -1
  110. package/dist/core/model-runtime.js +48 -22
  111. package/dist/core/model-runtime.js.map +1 -1
  112. package/dist/core/provider-composer-internal.d.ts.map +1 -1
  113. package/dist/core/provider-composer-internal.js +4 -1
  114. package/dist/core/provider-composer-internal.js.map +1 -1
  115. package/dist/core/provider-display-names.js +1 -1
  116. package/dist/core/provider-display-names.js.map +1 -1
  117. package/dist/core/resource-loader-core.d.ts +1 -0
  118. package/dist/core/resource-loader-core.d.ts.map +1 -1
  119. package/dist/core/resource-loader-core.js +4 -0
  120. package/dist/core/resource-loader-core.js.map +1 -1
  121. package/dist/core/resource-loader-internals.d.ts +1 -0
  122. package/dist/core/resource-loader-internals.d.ts.map +1 -1
  123. package/dist/core/resource-loader-internals.js.map +1 -1
  124. package/dist/core/resource-loader-reload.d.ts.map +1 -1
  125. package/dist/core/resource-loader-reload.js +28 -5
  126. package/dist/core/resource-loader-reload.js.map +1 -1
  127. package/dist/core/resource-loader-types.d.ts +2 -0
  128. package/dist/core/resource-loader-types.d.ts.map +1 -1
  129. package/dist/core/resource-loader-types.js.map +1 -1
  130. package/dist/core/sdk-types.d.ts +6 -4
  131. package/dist/core/sdk-types.d.ts.map +1 -1
  132. package/dist/core/sdk-types.js.map +1 -1
  133. package/dist/core/sdk.d.ts.map +1 -1
  134. package/dist/core/sdk.js +5 -3
  135. package/dist/core/sdk.js.map +1 -1
  136. package/dist/core/session-lifecycle-work.d.ts +2 -1
  137. package/dist/core/session-lifecycle-work.d.ts.map +1 -1
  138. package/dist/core/session-lifecycle-work.js +15 -1
  139. package/dist/core/session-lifecycle-work.js.map +1 -1
  140. package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
  141. package/dist/core/settings-manager-basic-accessors.js +4 -4
  142. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  143. package/dist/core/settings-manager-core.d.ts.map +1 -1
  144. package/dist/core/settings-manager-core.js +2 -0
  145. package/dist/core/settings-manager-core.js.map +1 -1
  146. package/dist/core/settings-storage.d.ts.map +1 -1
  147. package/dist/core/settings-storage.js +2 -1
  148. package/dist/core/settings-storage.js.map +1 -1
  149. package/dist/core/skills.d.ts +1 -1
  150. package/dist/core/skills.d.ts.map +1 -1
  151. package/dist/core/skills.js +3 -1
  152. package/dist/core/skills.js.map +1 -1
  153. package/dist/core/system-prompt.d.ts +3 -0
  154. package/dist/core/system-prompt.d.ts.map +1 -1
  155. package/dist/core/system-prompt.js +7 -3
  156. package/dist/core/system-prompt.js.map +1 -1
  157. package/dist/core/tool-loadout.d.ts.map +1 -1
  158. package/dist/core/tool-loadout.js +8 -1
  159. package/dist/core/tool-loadout.js.map +1 -1
  160. package/dist/core/tool-selection.d.ts +13 -0
  161. package/dist/core/tool-selection.d.ts.map +1 -0
  162. package/dist/core/tool-selection.js +43 -0
  163. package/dist/core/tool-selection.js.map +1 -0
  164. package/dist/core/tools/read.d.ts +7 -0
  165. package/dist/core/tools/read.d.ts.map +1 -1
  166. package/dist/core/tools/read.js +11 -1
  167. package/dist/core/tools/read.js.map +1 -1
  168. package/dist/extensions/codemode/execute.d.ts.map +1 -1
  169. package/dist/extensions/codemode/execute.js +2 -1
  170. package/dist/extensions/codemode/execute.js.map +1 -1
  171. package/dist/extensions/codemode/index.d.ts.map +1 -1
  172. package/dist/extensions/codemode/index.js +1 -0
  173. package/dist/extensions/codemode/index.js.map +1 -1
  174. package/dist/extensions/codemode/tool.d.ts +4 -1
  175. package/dist/extensions/codemode/tool.d.ts.map +1 -1
  176. package/dist/extensions/codemode/tool.js +6 -3
  177. package/dist/extensions/codemode/tool.js.map +1 -1
  178. package/dist/extensions/mcp/client/oauth/flow.d.ts.map +1 -1
  179. package/dist/extensions/mcp/client/oauth/flow.js +14 -1
  180. package/dist/extensions/mcp/client/oauth/flow.js.map +1 -1
  181. package/dist/extensions/mcp/client/oauth/types.d.ts +1 -0
  182. package/dist/extensions/mcp/client/oauth/types.d.ts.map +1 -1
  183. package/dist/extensions/mcp/client/oauth/types.js.map +1 -1
  184. package/dist/extensions/mcp/index.js.map +1 -1
  185. package/dist/extensions/mcp/runtime.d.ts +5 -2
  186. package/dist/extensions/mcp/runtime.d.ts.map +1 -1
  187. package/dist/extensions/mcp/runtime.js +18 -4
  188. package/dist/extensions/mcp/runtime.js.map +1 -1
  189. package/dist/main.d.ts.map +1 -1
  190. package/dist/main.js +2 -0
  191. package/dist/main.js.map +1 -1
  192. package/dist/migrations-azure.d.ts +4 -0
  193. package/dist/migrations-azure.d.ts.map +1 -0
  194. package/dist/migrations-azure.js +41 -0
  195. package/dist/migrations-azure.js.map +1 -0
  196. package/dist/migrations.d.ts.map +1 -1
  197. package/dist/migrations.js +2 -0
  198. package/dist/migrations.js.map +1 -1
  199. package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
  200. package/dist/modes/interactive/components/chat-session-host-state.js +2 -1
  201. package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
  202. package/dist/modes/interactive/components/chat-transcript.d.ts +2 -0
  203. package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
  204. package/dist/modes/interactive/components/chat-transcript.js +9 -3
  205. package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
  206. package/dist/modes/interactive/theme/tui-theme.d.ts.map +1 -1
  207. package/dist/modes/interactive/theme/tui-theme.js +1 -0
  208. package/dist/modes/interactive/theme/tui-theme.js.map +1 -1
  209. package/dist/modes/interactive-engine/engine-args.d.ts.map +1 -1
  210. package/dist/modes/interactive-engine/engine-args.js +1 -0
  211. package/dist/modes/interactive-engine/engine-args.js.map +1 -1
  212. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  213. package/dist/utils/syntax-highlight.js +6 -1
  214. package/dist/utils/syntax-highlight.js.map +1 -1
  215. package/docs/codemode.md +3 -2
  216. package/docs/extensions/api-reference.md +14 -0
  217. package/docs/extensions/authoring.md +1 -1
  218. package/docs/extensions.md +2 -0
  219. package/docs/keybindings.md +9 -9
  220. package/docs/mcp-servers.md +4 -0
  221. package/docs/providers.md +21 -2
  222. package/docs/reference/cli.md +10 -3
  223. package/docs/workflows/api-reference.md +3 -1
  224. package/docs/workflows/authoring.md +6 -2
  225. package/npm-shrinkwrap.json +78 -74
  226. package/package.json +9 -9
@@ -1 +1 @@
1
- {"version":3,"file":"chat-session-host-state.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-session-host-state.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAOvE,OAAO,EACN,uBAAuB,EAEvB,2BAA2B,GAC3B,MAAM,sBAAsB,CAAC;AAY9B,MAAM,OAAO,oBAAoB;IACvB,KAAK,CAAuB;IAC5B,QAAQ,CAA0B;IAClC,aAAa,CAA2B;IACxC,eAAe,CAA+C;IAC9D,mBAAmB,CAA8B;IACjD,QAAQ,CAA8B;IACtC,UAAU,CAA8B;IACxC,qBAAqB,CAA8B;IACnD,WAAW,CAA0C;IACrD,UAAU,CAA0C;IACpD,OAAO,CAAyD;IAChE,mBAAmB,CAA2C;IAC9D,gBAAgB,CAAoC;IACpD,qBAAqB,CAA4D;IACjF,MAAM,CAA6B;IACnC,UAAU,CAAyC;IACnD,gBAAgB,CAAkD;IAClE,GAAG,CAAkB;IAE9B,MAAM,CAA8B;IACpC,sBAAsB,GAAG,KAAK,CAAC;IAC/B,WAAW,GAAG,EAAE,CAAC;IACjB,UAAU,GAAwC,EAAE,CAAC;IACrD,YAAY,GAAkB,EAAE,CAAC;IACjC,aAAa,GAAG,EAAE,CAAC;IACnB,+FAA+F;IAC/F,kBAAkB,CAAqB;IACvC,UAAU,GAAG,KAAK,CAAC;IACnB,gBAAgB,GAAG,KAAK,CAAC;IACzB,OAAO,GAAG,KAAK,CAAC;IAChB,yEAAyE;IACzE,mBAAmB,CAA4B;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,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,aAAa,CAAC;QAChD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACpC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,CAAC;QACpD,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAC9C,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,qBAAqB,CAAC;QACxD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAC9C,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACpB,IAAI,CAAC,QAAQ,GAAG,IAAI,yBAAyB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC/D,IAAI,CAAC,mBAAmB,GAAG,IAAI,uBAAuB,CACrD,IAAI,CAAC,UAAU,EACf,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,EAC7C,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,kBAAkB,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAClE,CAAC;IACH,CAAC;CACD","sourcesContent":["import type { Component, EditorComponent, MarkdownTheme, TUI } from \"@earendil-works/pi-tui\";\nimport type { AgentSession } from \"../../../core/agent-session.js\";\nimport type { ReadonlyFooterDataProvider } from \"../../../core/footer-data-provider.ts\";\nimport { LiveChatEntriesController } from \"./chat-message-renderer.ts\";\nimport type {\n\tChatSessionHostCommands,\n\tChatSessionHostEntry,\n\tChatSessionHostOpts,\n\tChatSessionHostStyle,\n} from \"./chat-session-host-types.ts\";\nimport {\n\tChatTranscriptComponent,\n\ttype ChatTranscriptEntryLike,\n\tScrollableComponentViewport,\n} from \"./chat-transcript.js\";\nimport type { FooterComponent } from \"./footer.ts\";\n\nexport interface ChatSessionHostStateCallbacks<TExtraEntry extends ChatTranscriptEntryLike> {\n\trenderEntry: (state: ChatSessionHostState<TExtraEntry>, entry: ChatSessionHostEntry<TExtraEntry>) => Component;\n\ttranscriptCacheKey: (\n\t\tstate: ChatSessionHostState<TExtraEntry>,\n\t\tentry: ChatSessionHostEntry<TExtraEntry>,\n\t\tindex: number,\n\t) => string;\n}\n\nexport class ChatSessionHostState<TExtraEntry extends ChatTranscriptEntryLike = never> {\n\treadonly style: ChatSessionHostStyle;\n\treadonly commands: ChatSessionHostCommands;\n\treadonly requestRender: (() => void) | undefined;\n\treadonly getAgentSession: (() => AgentSession | undefined) | undefined;\n\treadonly isStreamingOverride: (() => boolean) | undefined;\n\treadonly isPaused: (() => boolean) | undefined;\n\treadonly isDisabled: (() => boolean) | undefined;\n\treadonly isBashRunningOverride: (() => boolean) | undefined;\n\treadonly showWarning: ((message: string) => void) | undefined;\n\treadonly showStatus: ((message: string) => void) | undefined;\n\treadonly actions: Record<string, () => void | Promise<void>> | undefined;\n\treadonly getActionKeyDisplay: ((action: string) => string) | undefined;\n\treadonly getMarkdownTheme: (() => MarkdownTheme) | undefined;\n\treadonly getChatRenderSettings: ChatSessionHostOpts<TExtraEntry>[\"getChatRenderSettings\"];\n\treadonly getCwd: (() => string) | undefined;\n\treadonly footerData: ReadonlyFooterDataProvider | undefined;\n\treadonly renderExtraEntry: ((entry: TExtraEntry) => Component) | undefined;\n\treadonly tui: TUI | undefined;\n\n\tfooter: FooterComponent | undefined;\n\tfooterNavigationActive = false;\n\tinputBuffer = \"\";\n\ttranscript: ChatSessionHostEntry<TExtraEntry>[] = [];\n\textraEntries: TExtraEntry[] = [];\n\tstatusMessage = \"\";\n\t/** Explicit diagnostics survive busy-state cleanup, but are not restored after later input. */\n\tlastWarningMessage: string | undefined;\n\tisBashMode = false;\n\tlocalBashRunning = false;\n\tsdkBusy = false;\n\t/** Escape interrupt plus asynchronous workflow pause acknowledgement. */\n\tinterruptSettlement: Promise<void> | undefined;\n\t/** Recorded pause failure consumed by the first submit after settlement. */\n\tinterruptFailureMessage: string | undefined;\n\tworkingMessage: string | undefined;\n\tworkingFrame = 0;\n\tworkingLifecycleActive: boolean;\n\tworkingLifecycleGeneration = 0;\n\timmediateEventRenderPending = false;\n\tdisposed = false;\n\tpendingSteeringMessages: readonly string[] = [];\n\tpendingFollowUpMessages: readonly string[] = [];\n\tcompactionQueuedMessages: readonly string[] = [];\n\tcompacting = false;\n\t/** Keeps input queued while automatic compaction hands off to a manual request. */\n\tmanualCompactionTakeoverPending = false;\n\tanimationTimer: ReturnType<typeof setInterval> | undefined;\n\trenderThrottleTimer: ReturnType<typeof setTimeout> | undefined;\n\tbodyViewport = new ScrollableComponentViewport();\n\ttranscriptComponent: ChatTranscriptComponent<ChatSessionHostEntry<TExtraEntry>>;\n\ttranscriptRenderSettingsKey = \"\";\n\trenderIdentityIds = new WeakMap<object, number>();\n\tnextRenderIdentityId = 1;\n\tliveChat: LiveChatEntriesController;\n\teditor: EditorComponent | undefined;\n\toptimisticUserSignatureCounts = new Map<string, number>();\n\t/**\n\t * Whether an assistant entry still streaming into a sticky-bottom body is\n\t * rendered as its tail alone.\n\t *\n\t * On by default: while the reader is following a live stream, the rows far\n\t * above the cursor cost layout work nobody is reading.\n\t */\n\tstreamingTailWindowEnabled = true;\n\n\tconstructor(opts: ChatSessionHostOpts<TExtraEntry>, callbacks: ChatSessionHostStateCallbacks<TExtraEntry>) {\n\t\tthis.style = opts.style;\n\t\tthis.commands = opts.commands ?? {};\n\t\tthis.requestRender = opts.requestRender;\n\t\tthis.getAgentSession = opts.getAgentSession;\n\t\tthis.isStreamingOverride = opts.isStreaming;\n\t\tthis.workingLifecycleActive = opts.isStreaming?.() === true;\n\t\tthis.isPaused = opts.isPaused;\n\t\tthis.isDisabled = opts.isDisabled;\n\t\tthis.isBashRunningOverride = opts.isBashRunning;\n\t\tthis.showWarning = opts.showWarning;\n\t\tthis.showStatus = opts.showStatus;\n\t\tthis.actions = opts.actions;\n\t\tthis.getActionKeyDisplay = opts.getActionKeyDisplay;\n\t\tthis.getMarkdownTheme = opts.getMarkdownTheme;\n\t\tthis.getChatRenderSettings = opts.getChatRenderSettings;\n\t\tthis.getCwd = opts.getCwd;\n\t\tthis.footerData = opts.footerData;\n\t\tthis.renderExtraEntry = opts.renderExtraEntry;\n\t\tthis.tui = opts.tui;\n\t\tthis.liveChat = new LiveChatEntriesController(this.transcript);\n\t\tthis.transcriptComponent = new ChatTranscriptComponent(\n\t\t\tthis.transcript,\n\t\t\t(entry) => callbacks.renderEntry(this, entry),\n\t\t\t(entry, index) => callbacks.transcriptCacheKey(this, entry, index),\n\t\t);\n\t}\n}\n"]}
1
+ {"version":3,"file":"chat-session-host-state.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-session-host-state.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAOvE,OAAO,EACN,uBAAuB,EAEvB,2BAA2B,GAC3B,MAAM,sBAAsB,CAAC;AAY9B,MAAM,OAAO,oBAAoB;IACvB,KAAK,CAAuB;IAC5B,QAAQ,CAA0B;IAClC,aAAa,CAA2B;IACxC,eAAe,CAA+C;IAC9D,mBAAmB,CAA8B;IACjD,QAAQ,CAA8B;IACtC,UAAU,CAA8B;IACxC,qBAAqB,CAA8B;IACnD,WAAW,CAA0C;IACrD,UAAU,CAA0C;IACpD,OAAO,CAAyD;IAChE,mBAAmB,CAA2C;IAC9D,gBAAgB,CAAoC;IACpD,qBAAqB,CAA4D;IACjF,MAAM,CAA6B;IACnC,UAAU,CAAyC;IACnD,gBAAgB,CAAkD;IAClE,GAAG,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AAE,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,EAC7C,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,kBAAkB,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAClE,CAAC;IACH,CAAC;CACD","sourcesContent":["import type { Component, EditorComponent, MarkdownTheme, TUI } from \"@earendil-works/pi-tui\";\nimport type { AgentSession } from \"../../../core/agent-session.js\";\nimport type { ReadonlyFooterDataProvider } from \"../../../core/footer-data-provider.ts\";\nimport { LiveChatEntriesController } from \"./chat-message-renderer.ts\";\nimport type {\n\tChatSessionHostCommands,\n\tChatSessionHostEntry,\n\tChatSessionHostOpts,\n\tChatSessionHostStyle,\n} from \"./chat-session-host-types.ts\";\nimport {\n\tChatTranscriptComponent,\n\ttype ChatTranscriptEntryLike,\n\tScrollableComponentViewport,\n} from \"./chat-transcript.js\";\nimport type { FooterComponent } from \"./footer.ts\";\n\nexport interface ChatSessionHostStateCallbacks<TExtraEntry extends ChatTranscriptEntryLike> {\n\trenderEntry: (state: ChatSessionHostState<TExtraEntry>, entry: ChatSessionHostEntry<TExtraEntry>) => Component;\n\ttranscriptCacheKey: (\n\t\tstate: ChatSessionHostState<TExtraEntry>,\n\t\tentry: ChatSessionHostEntry<TExtraEntry>,\n\t\tindex: number,\n\t) => string;\n}\n\nexport class ChatSessionHostState<TExtraEntry extends ChatTranscriptEntryLike = never> {\n\treadonly style: ChatSessionHostStyle;\n\treadonly commands: ChatSessionHostCommands;\n\treadonly requestRender: (() => void) | undefined;\n\treadonly getAgentSession: (() => AgentSession | undefined) | undefined;\n\treadonly isStreamingOverride: (() => boolean) | undefined;\n\treadonly isPaused: (() => boolean) | undefined;\n\treadonly isDisabled: (() => boolean) | undefined;\n\treadonly isBashRunningOverride: (() => boolean) | undefined;\n\treadonly showWarning: ((message: string) => void) | undefined;\n\treadonly showStatus: ((message: string) => void) | undefined;\n\treadonly actions: Record<string, () => void | Promise<void>> | undefined;\n\treadonly getActionKeyDisplay: ((action: string) => string) | undefined;\n\treadonly getMarkdownTheme: (() => MarkdownTheme) | undefined;\n\treadonly getChatRenderSettings: ChatSessionHostOpts<TExtraEntry>[\"getChatRenderSettings\"];\n\treadonly getCwd: (() => string) | undefined;\n\treadonly footerData: ReadonlyFooterDataProvider | undefined;\n\treadonly renderExtraEntry: ((entry: TExtraEntry) => Component) | undefined;\n\treadonly tui: TUI | undefined;\n\n\tfooter: FooterComponent | undefined;\n\tfooterNavigationActive = false;\n\tinputBuffer = \"\";\n\ttranscript: ChatSessionHostEntry<TExtraEntry>[] = [];\n\textraEntries: TExtraEntry[] = [];\n\tstatusMessage = \"\";\n\t/** Explicit diagnostics survive busy-state cleanup, but are not restored after later input. */\n\tlastWarningMessage: string | undefined;\n\tisBashMode = false;\n\tlocalBashRunning = false;\n\tsdkBusy = false;\n\t/** Escape interrupt plus asynchronous workflow pause acknowledgement. */\n\tinterruptSettlement: Promise<void> | undefined;\n\t/** Recorded pause failure consumed by the first submit after settlement. */\n\tinterruptFailureMessage: string | undefined;\n\tworkingMessage: string | undefined;\n\tworkingFrame = 0;\n\tworkingLifecycleActive: boolean;\n\tworkingLifecycleGeneration = 0;\n\timmediateEventRenderPending = false;\n\tdisposed = false;\n\tpendingSteeringMessages: readonly string[] = [];\n\tpendingFollowUpMessages: readonly string[] = [];\n\tcompactionQueuedMessages: readonly string[] = [];\n\tcompacting = false;\n\t/** Keeps input queued while automatic compaction hands off to a manual request. */\n\tmanualCompactionTakeoverPending = false;\n\tanimationTimer: ReturnType<typeof setInterval> | undefined;\n\trenderThrottleTimer: ReturnType<typeof setTimeout> | undefined;\n\tbodyViewport: ScrollableComponentViewport;\n\ttranscriptComponent: ChatTranscriptComponent<ChatSessionHostEntry<TExtraEntry>>;\n\ttranscriptRenderSettingsKey = \"\";\n\trenderIdentityIds = new WeakMap<object, number>();\n\tnextRenderIdentityId = 1;\n\tliveChat: LiveChatEntriesController;\n\teditor: EditorComponent | undefined;\n\toptimisticUserSignatureCounts = new Map<string, number>();\n\t/**\n\t * Whether an assistant entry still streaming into a sticky-bottom body is\n\t * rendered as its tail alone.\n\t *\n\t * On by default: while the reader is following a live stream, the rows far\n\t * above the cursor cost layout work nobody is reading.\n\t */\n\tstreamingTailWindowEnabled = true;\n\n\tconstructor(opts: ChatSessionHostOpts<TExtraEntry>, callbacks: ChatSessionHostStateCallbacks<TExtraEntry>) {\n\t\tthis.style = opts.style;\n\t\tthis.commands = opts.commands ?? {};\n\t\tthis.bodyViewport = new ScrollableComponentViewport(opts.keybindings);\n\t\tthis.requestRender = opts.requestRender;\n\t\tthis.getAgentSession = opts.getAgentSession;\n\t\tthis.isStreamingOverride = opts.isStreaming;\n\t\tthis.workingLifecycleActive = opts.isStreaming?.() === true;\n\t\tthis.isPaused = opts.isPaused;\n\t\tthis.isDisabled = opts.isDisabled;\n\t\tthis.isBashRunningOverride = opts.isBashRunning;\n\t\tthis.showWarning = opts.showWarning;\n\t\tthis.showStatus = opts.showStatus;\n\t\tthis.actions = opts.actions;\n\t\tthis.getActionKeyDisplay = opts.getActionKeyDisplay;\n\t\tthis.getMarkdownTheme = opts.getMarkdownTheme;\n\t\tthis.getChatRenderSettings = opts.getChatRenderSettings;\n\t\tthis.getCwd = opts.getCwd;\n\t\tthis.footerData = opts.footerData;\n\t\tthis.renderExtraEntry = opts.renderExtraEntry;\n\t\tthis.tui = opts.tui;\n\t\tthis.liveChat = new LiveChatEntriesController(this.transcript);\n\t\tthis.transcriptComponent = new ChatTranscriptComponent(\n\t\t\tthis.transcript,\n\t\t\t(entry) => callbacks.renderEntry(this, entry),\n\t\t\t(entry, index) => callbacks.transcriptCacheKey(this, entry, index),\n\t\t);\n\t}\n}\n"]}
@@ -87,6 +87,8 @@ export declare class ScrollableComponentViewport implements Component {
87
87
  * honour it. See `scrollTo` for why the request has to outlive the call.
88
88
  */
89
89
  private pendingScrollRow;
90
+ private readonly keybindings;
91
+ constructor(keybindings?: unknown);
90
92
  setComponents(components: readonly Component[]): void;
91
93
  setVisibleRows(rows: number): void;
92
94
  getScrollFromBottom(): number;
@@ -1 +1 @@
1
- {"version":3,"file":"chat-transcript.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-transcript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAsB,MAAM,wBAAwB,CAAC;AAE5F;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAC3B,WAAW,GACX,UAAU,GACV,MAAM,GACN,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,SAAS,CAAC;AAEb,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;CAClC;AAED,MAAM,MAAM,sBAAsB,CAAC,MAAM,SAAS,uBAAuB,IAAI,CAAC,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC;AAE1G,MAAM,MAAM,sBAAsB,CAAC,MAAM,SAAS,uBAAuB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;AAYtH;;;;;;;;GAQG;AACH,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB;AAmCD,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAKjH;AAMD;;;;;;;GAOG;AACH,qBAAa,uBAAuB,CAAC,MAAM,SAAS,uBAAuB,CAAE,YAAW,SAAS;IAChG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;IAC5C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAiC;IAC7D,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;IAEpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6C;IACtE,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AI,MAAM,CAErB;IAED,cAAc,IAAI,IAAI,CAErB;CACD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOxD"}
@@ -1,4 +1,4 @@
1
- import { matchesKey, Spacer } from "@earendil-works/pi-tui";
1
+ import { getKeybindings, matchesKey, Spacer, } from "@earendil-works/pi-tui";
2
2
  export function addChatTranscriptEntry(container, component, role) {
3
3
  if (needsLeadingSpacer(role) && container.children.length > 0) {
4
4
  container.addChild(new Spacer(1));
@@ -185,6 +185,12 @@ export class ScrollableComponentViewport {
185
185
  * honour it. See `scrollTo` for why the request has to outlive the call.
186
186
  */
187
187
  pendingScrollRow;
188
+ keybindings;
189
+ constructor(keybindings) {
190
+ const candidate = keybindings;
191
+ this.keybindings =
192
+ typeof candidate?.matches === "function" ? candidate : undefined;
193
+ }
188
194
  setComponents(components) {
189
195
  this.components = components;
190
196
  }
@@ -272,11 +278,11 @@ export class ScrollableComponentViewport {
272
278
  this.scrollBy(this.pageSize());
273
279
  return true;
274
280
  }
275
- if (matchesKey(data, "home")) {
281
+ if ((this.keybindings ?? getKeybindings()).matches(data, "tui.altScreen.top")) {
276
282
  this.scrollToTop();
277
283
  return true;
278
284
  }
279
- if (matchesKey(data, "end")) {
285
+ if ((this.keybindings ?? getKeybindings()).matches(data, "tui.altScreen.bottom")) {
280
286
  this.scrollToBottom();
281
287
  return true;
282
288
  }
@@ -1 +1 @@
1
- {"version":3,"file":"chat-transcript.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-transcript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,UAAU,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAoF5F,MAAM,UAAU,sBAAsB,CAAC,SAAoB,EAAE,SAAoB,EAAE,IAAwB;IAC1G,IAAI,kBAAkB,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/D,SAAS,CAAC,QAAQ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,CAAC,IAAY;IAC5C,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAChC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC;IAC3B,IAAI,SAAS,KAAK,CAAC;QAAE,OAAO,CAAC,wBAAwB,CAAC;IACtD,IAAI,SAAS,KAAK,CAAC;QAAE,OAAO,wBAAwB,CAAC;IACrD,OAAO,CAAC,CAAC;AACV,CAAC;AAED,SAAS,eAAe,CAAC,IAAY;IACpC,OAAO,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AAC3E,CAAC","sourcesContent":["import { type Component, type Container, matchesKey, Spacer } from \"@earendil-works/pi-tui\";\n\n/**\n * Roles that participate in pi's chat spacing contract.\n *\n * Assistant turns own their leading whitespace internally, and tool rows attach\n * directly under the assistant/tool-call row they belong to. User-like rows get\n * one blank line when they are not the first row in the transcript.\n */\nexport type ChatTranscriptRole =\n\t| \"assistant\"\n\t| \"thinking\"\n\t| \"tool\"\n\t| \"user\"\n\t| \"custom\"\n\t| \"notice\"\n\t| \"system\"\n\t| \"summary\";\n\nexport interface ChatTranscriptEntryLike {\n\treadonly role: ChatTranscriptRole;\n}\n\nexport type ChatTranscriptRenderer<TEntry extends ChatTranscriptEntryLike> = (entry: TEntry) => Component;\n\nexport type ChatTranscriptCacheKey<TEntry extends ChatTranscriptEntryLike> = (entry: TEntry, index: number) => string;\n\ninterface CachedChatTranscriptBlock<TEntry extends ChatTranscriptEntryLike> {\n\treadonly entry: TEntry;\n\treadonly key: string;\n\treadonly width: number;\n\treadonly component: Component;\n\treadonly lines: readonly string[];\n}\n\ntype DisposableComponent = Component & { dispose?: () => void };\n\n/**\n * A run of rows inside a windowed component, tagged with the identity of the\n * thing that produced them.\n *\n * `id` is compared with `===` only, and is never rendered. Entry *objects* are\n * the natural id for a transcript: cache keys carry the entry's index and so\n * change for every survivor of a splice, while the entry objects themselves are\n * moved, not rebuilt.\n */\nexport interface RowWindowSegment {\n\treadonly id: unknown;\n\treadonly rows: number;\n}\n\ninterface RowWindowComponent extends Component {\n\treadonly supportsRowWindow: true;\n\trowCount(width: number): number;\n\trenderRows(width: number, startRow: number, endRow: number): string[];\n\t/**\n\t * Optional row map, letting the viewport keep a scroll anchor that sits\n\t * *inside* this component when its interior changes height.\n\t */\n\trowSegments?(width: number): readonly RowWindowSegment[];\n}\n\ninterface WindowedComponentRows {\n\treadonly kind: \"windowed\";\n\treadonly component: RowWindowComponent;\n\treadonly rowCount: number;\n\treadonly segments: readonly RowWindowSegment[] | undefined;\n}\n\ninterface StaticComponentRows {\n\treadonly kind: \"static\";\n\treadonly lines: readonly string[];\n\treadonly rowCount: number;\n\t/**\n\t * Present when a static component can still identify its own rows. A\n\t * transcript built without a cache key renders every row each frame rather\n\t * than windowing, but it knows just as well which entry produced which rows,\n\t * and the anchor needs that whenever it is the component spanning the anchor.\n\t */\n\treadonly segments?: readonly RowWindowSegment[] | undefined;\n}\n\ntype ComponentRows = WindowedComponentRows | StaticComponentRows;\n\nexport function addChatTranscriptEntry(container: Container, component: Component, role: ChatTranscriptRole): void {\n\tif (needsLeadingSpacer(role) && container.children.length > 0) {\n\t\tcontainer.addChild(new Spacer(1));\n\t}\n\tcontainer.addChild(component);\n}\n\nfunction needsLeadingSpacer(role: ChatTranscriptRole): boolean {\n\treturn role === \"user\" || role === \"custom\" || role === \"notice\" || role === \"system\" || role === \"summary\";\n}\n\n/**\n * Reusable pi chat transcript scaffold for extension surfaces.\n *\n * This intentionally mirrors InteractiveMode.addMessageToChat spacing without\n * coupling consumers to a full AgentSession. Extension UIs can bring their own\n * message model while still rendering inside the same Container/Spacer rhythm\n * as the main chat.\n */\nexport class ChatTranscriptComponent<TEntry extends ChatTranscriptEntryLike> implements Component {\n\tprivate readonly entries: readonly TEntry[];\n\tprivate readonly renderEntry: ChatTranscriptRenderer<TEntry>;\n\treadonly supportsRowWindow: boolean;\n\n\tprivate readonly cacheKey: ChatTranscriptCacheKey<TEntry> | undefined;\n\tprivate blockCache: Array<CachedChatTranscriptBlock<TEntry> | undefined> = [];\n\t/** Per-entry heights recorded by the most recent `renderAllRows`. */\n\tprivate staticSegments: readonly RowWindowSegment[] = [];\n\t/** Width those heights were measured at; they mean nothing at another width. */\n\tprivate staticSegmentsWidth: number | undefined;\n\n\tconstructor(\n\t\tentries: readonly TEntry[],\n\t\trenderEntry: ChatTranscriptRenderer<TEntry>,\n\t\tcacheKey?: ChatTranscriptCacheKey<TEntry>,\n\t) {\n\t\tthis.entries = entries;\n\t\tthis.renderEntry = renderEntry;\n\t\tthis.cacheKey = cacheKey;\n\t\tthis.supportsRowWindow = cacheKey !== undefined;\n\t}\n\n\trender(width: number): string[] {\n\t\tif (!this.supportsRowWindow) return this.renderAllRows(width);\n\t\treturn this.renderRows(width, 0, this.rowCount(width));\n\t}\n\n\trowCount(width: number): number {\n\t\tif (!this.supportsRowWindow) return this.renderAllRows(width).length;\n\t\tthis.ensureBlockCache(width);\n\t\tlet count = 0;\n\t\tfor (const block of this.blockCache) {\n\t\t\tif (block !== undefined) count += block.lines.length;\n\t\t}\n\t\treturn count;\n\t}\n\n\t/**\n\t * One segment per cached entry block, identified by the entry object itself.\n\t */\n\trowSegments(width: number): readonly RowWindowSegment[] {\n\t\tif (!this.supportsRowWindow) {\n\t\t\t// Recorded by the last renderAllRows. The viewport measures a static\n\t\t\t// component by rendering it and only then reads its segments, so this\n\t\t\t// is populated for the frame being measured. A width mismatch means the\n\t\t\t// heights describe a different layout, and reporting them would move the\n\t\t\t// anchor by a stale delta; the caller falls back to whole-component\n\t\t\t// accounting instead.\n\t\t\treturn this.staticSegmentsWidth === width ? this.staticSegments : [];\n\t\t}\n\t\tthis.ensureBlockCache(width);\n\t\tconst segments: RowWindowSegment[] = [];\n\t\tfor (const block of this.blockCache) {\n\t\t\tif (block !== undefined) segments.push({ id: block.entry, rows: block.lines.length });\n\t\t}\n\t\treturn segments;\n\t}\n\n\trenderRows(width: number, startRow: number, endRow: number): string[] {\n\t\tconst start = Math.max(0, Math.floor(startRow));\n\t\tconst end = Math.max(start, Math.floor(endRow));\n\t\tif (end <= start) return [];\n\t\tif (!this.supportsRowWindow) return this.renderAllRows(width).slice(start, end);\n\n\t\tthis.ensureBlockCache(width);\n\t\tconst lines: string[] = [];\n\t\tlet cursor = 0;\n\t\tfor (let index = 0; index < this.entries.length; index += 1) {\n\t\t\tconst block = this.blockCache[index];\n\t\t\tif (block === undefined) continue;\n\t\t\tconst blockStart = cursor;\n\t\t\tconst blockEnd = blockStart + block.lines.length;\n\t\t\tif (blockEnd > start && blockStart < end) {\n\t\t\t\tconst localStart = Math.max(0, start - blockStart);\n\t\t\t\tconst localEnd = Math.min(block.lines.length, end - blockStart);\n\t\t\t\tlines.push(...block.lines.slice(localStart, localEnd));\n\t\t\t}\n\t\t\tcursor = blockEnd;\n\t\t\tif (cursor >= end) break;\n\t\t}\n\t\treturn lines;\n\t}\n\n\tinvalidate(): void {\n\t\tfor (const block of this.blockCache) disposeComponent(block?.component);\n\t\tthis.blockCache = [];\n\t}\n\n\tprivate ensureBlockCache(width: number): void {\n\t\tif (this.blockCache.length > this.entries.length) {\n\t\t\tfor (let index = this.entries.length; index < this.blockCache.length; index += 1) {\n\t\t\t\tdisposeComponent(this.blockCache[index]?.component);\n\t\t\t}\n\t\t\tthis.blockCache.length = this.entries.length;\n\t\t}\n\t\tfor (let index = 0; index < this.entries.length; index += 1) {\n\t\t\tconst entry = this.entries[index];\n\t\t\tif (entry === undefined) continue;\n\t\t\tconst key = this.cacheKey?.(entry, index) ?? `${index}:${entry.role}`;\n\t\t\tconst cached = this.blockCache[index];\n\t\t\tif (cached !== undefined && cached.entry === entry && cached.key === key && cached.width === width) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tdisposeComponent(cached?.component);\n\t\t\tconst component = this.renderEntry(entry);\n\t\t\tthis.blockCache[index] = {\n\t\t\t\tentry,\n\t\t\t\tkey,\n\t\t\t\twidth,\n\t\t\t\tcomponent,\n\t\t\t\tlines: this.renderEntryBlock(component, entry, index, width),\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * Render every entry, recording each one's height as it goes.\n\t *\n\t * The heights are what `rowSegments` reports on this path. They are a\n\t * by-product of work this method already does, so identifying rows costs\n\t * nothing extra and, unlike a cache key, cannot miss an entry mutated in\n\t * place -- which is the behaviour a transcript without a cache key exists to\n\t * provide.\n\t */\n\tprivate renderAllRows(width: number): string[] {\n\t\tconst lines: string[] = [];\n\t\tconst segments: RowWindowSegment[] = [];\n\t\tfor (let index = 0; index < this.entries.length; index += 1) {\n\t\t\tconst entry = this.entries[index];\n\t\t\tif (entry === undefined) continue;\n\t\t\tconst block = this.renderEntryBlock(this.renderEntry(entry), entry, index, width);\n\t\t\tsegments.push({ id: entry, rows: block.length });\n\t\t\tlines.push(...block);\n\t\t}\n\t\tthis.staticSegments = segments;\n\t\tthis.staticSegmentsWidth = width;\n\t\treturn lines;\n\t}\n\n\tprivate renderEntryBlock(component: Component, entry: TEntry, index: number, width: number): string[] {\n\t\tconst lines: string[] = [];\n\t\tif (index > 0 && needsLeadingSpacer(entry.role)) lines.push(\"\");\n\t\tlines.push(...component.render(width));\n\t\treturn lines;\n\t}\n}\n\nfunction disposeComponent(component: Component | undefined): void {\n\t(component as DisposableComponent | undefined)?.dispose?.();\n}\n\nconst DEFAULT_SCROLL_STEP_ROWS = 4;\n\n/**\n * Sticky-bottom, scrollable viewport for chat-like component stacks.\n *\n * Pi's main interactive chat gets terminal scrollback for free. Extension\n * overlays render into a fixed rectangle, so they need an explicit viewport\n * with the same sticky-bottom default plus keyboard and mouse history controls.\n */\nexport class ScrollableComponentViewport implements Component {\n\tprivate components: readonly Component[] = [];\n\tprivate visibleRows = 1;\n\tprivate scrollFromBottom = 0;\n\tprivate lastLineCount = 0;\n\tprivate lastComponentSegments: readonly (readonly RowWindowSegment[] | undefined)[] = [];\n\tprivate lastComponentRowCounts: readonly number[] = [];\n\tprivate lastWidth = 0;\n\tprivate maxScroll = 0;\n\t/**\n\t * Absolute row `scrollTo` asked for, still waiting for the render that can\n\t * honour it. See `scrollTo` for why the request has to outlive the call.\n\t */\n\tprivate pendingScrollRow: number | undefined;\n\n\tsetComponents(components: readonly Component[]): void {\n\t\tthis.components = components;\n\t}\n\n\tsetVisibleRows(rows: number): void {\n\t\tthis.visibleRows = Math.max(1, Math.floor(rows));\n\t\tthis.clampScroll();\n\t}\n\n\tgetScrollFromBottom(): number {\n\t\treturn this.scrollFromBottom;\n\t}\n\n\tgetMaxScroll(): number {\n\t\treturn this.maxScroll;\n\t}\n\n\tscrollToBottom(): void {\n\t\tthis.pendingScrollRow = undefined;\n\t\tthis.scrollFromBottom = 0;\n\t}\n\n\tscrollToTop(): void {\n\t\tthis.pendingScrollRow = undefined;\n\t\tthis.scrollFromBottom = this.maxScroll;\n\t}\n\n\tscrollBy(deltaRows: number): void {\n\t\t// Positive deltas move toward newer content; negative deltas move up\n\t\t// into older history. Store the offset from the sticky bottom so new\n\t\t// streaming output can keep following when the offset is zero.\n\t\tthis.pendingScrollRow = undefined;\n\t\tthis.scrollFromBottom -= deltaRows;\n\t\tthis.clampScroll();\n\t}\n\n\t/**\n\t * Park the viewport with `row` as its first visible row.\n\t *\n\t * The absolute counterpart of `scrollBy`, for a caller that already knows\n\t * which row it wants on screen.\n\t *\n\t * The request is *also* recorded for the next render, and that is the half\n\t * that matters. `scrollFromBottom` is a distance from the bottom, so the\n\t * row it names moves whenever the stack grows; and the render that follows\n\t * re-derives the offset from the previous frame's layout to hold a\n\t * scrolled-up reader's content still, which would drag this request back\n\t * with it. A caller who has just measured rows the last render never saw\n\t * would otherwise be answered with the old layout's clamp and the old\n\t * frame's anchor. The next render resolves the row against the layout it\n\t * actually paints; any other scroll before then withdraws the request.\n\t */\n\tscrollTo(row: number): void {\n\t\tconst requestedRow = Number.isNaN(row) ? 0 : Math.max(0, Math.floor(row));\n\t\tthis.pendingScrollRow = requestedRow;\n\t\tconst target = Math.min(this.maxScroll, requestedRow);\n\t\tthis.scrollFromBottom = this.maxScroll - target;\n\t\tthis.clampScroll();\n\t}\n\n\t/**\n\t * Total rows the component stack occupies at `width`, on and off screen.\n\t *\n\t * This measures rather than paints: it is what lets a search read the whole\n\t * transcript instead of the window the reader happens to be parked on.\n\t */\n\trowCount(width: number): number {\n\t\treturn this.measureComponentRows(width).reduce((sum, rows) => sum + rows.rowCount, 0);\n\t}\n\n\t/**\n\t * Rows `startRow` (inclusive) through `endRow` (exclusive) of the whole\n\t * stack, independent of the current scroll offset. Deliberately not paired\n\t * with `supportsRowWindow`: a viewport is a scroll container rather than a\n\t * windowed component, and an enclosing viewport must keep measuring it by\n\t * its visible height.\n\t */\n\trenderRows(width: number, startRow: number, endRow: number): string[] {\n\t\treturn this.renderVisibleRows(this.measureComponentRows(width), width, startRow, endRow);\n\t}\n\n\thandleInput(data: string): boolean {\n\t\tconst wheelDeltaRows = mouseWheelDeltaRows(data);\n\t\tif (wheelDeltaRows !== 0) {\n\t\t\tthis.scrollBy(wheelDeltaRows);\n\t\t\treturn true;\n\t\t}\n\t\tif (isMouseSequence(data)) return true;\n\t\tif (matchesKey(data, \"pageUp\")) {\n\t\t\tthis.scrollBy(-this.pageSize());\n\t\t\treturn true;\n\t\t}\n\t\tif (matchesKey(data, \"pageDown\")) {\n\t\t\tthis.scrollBy(this.pageSize());\n\t\t\treturn true;\n\t\t}\n\t\tif (matchesKey(data, \"home\")) {\n\t\t\tthis.scrollToTop();\n\t\t\treturn true;\n\t\t}\n\t\tif (matchesKey(data, \"end\")) {\n\t\t\tthis.scrollToBottom();\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\trender(width: number): string[] {\n\t\tconst componentRows = this.measureComponentRows(width);\n\t\tconst rowCounts = componentRows.map((rows) => rows.rowCount);\n\t\tconst lineCount = rowCounts.reduce((sum, count) => sum + count, 0);\n\t\tconst maxScroll = Math.max(0, lineCount - this.visibleRows);\n\t\t// The offset is a distance from the bottom, so the first visible row is\n\t\t// `maxScroll - scrollFromBottom`. Rows appearing or disappearing move the\n\t\t// content a scrolled-up viewer is reading unless the offset moves with\n\t\t// them -- a live subagent widget does exactly that every time it gains or\n\t\t// drops its current-tool row.\n\t\t//\n\t\t// Which way the offset must move depends on where the rows changed, so a\n\t\t// plain `scrollFromBottom += lineCount - lastLineCount` is wrong half the\n\t\t// time. Rows changing *below* the anchor need the offset adjusted by that\n\t\t// delta; rows changing *above* it need the offset left alone, because the\n\t\t// bottom-relative distance to the anchored content did not change. Anchor\n\t\t// on the row the viewer is actually reading and re-derive the offset from\n\t\t// it. A viewer already at the bottom keeps scrollFromBottom === 0 and is\n\t\t// skipped entirely, so sticky-bottom following is untouched.\n\t\t//\n\t\t// Per-component row counts alone cannot place a change that happens\n\t\t// inside the component holding the anchor -- and in the chat host the\n\t\t// whole transcript is one component, so that is the normal case. A\n\t\t// component that can hand over a row map turns the \"where\" question into\n\t\t// \"where did the anchored segment go\". Both kinds may supply one: a\n\t\t// transcript built without a cache key is not windowed, but it is still\n\t\t// one component spanning the anchor and still knows its own rows.\n\t\tconst segments = componentRows.map((rows) => rows.segments);\n\t\tconst pendingScrollRow = this.pendingScrollRow;\n\t\tthis.pendingScrollRow = undefined;\n\t\tif (pendingScrollRow !== undefined) {\n\t\t\t// An absolute request outranks the anchor: the caller measured this\n\t\t\t// frame's rows and named one of them. Re-deriving the anchor here\n\t\t\t// would answer with the previous frame's layout instead.\n\t\t\tthis.scrollFromBottom = maxScroll - Math.min(maxScroll, pendingScrollRow);\n\t\t} else if (this.scrollFromBottom > 0 && this.lastWidth === width) {\n\t\t\tconst previousMaxScroll = Math.max(0, this.lastLineCount - this.visibleRows);\n\t\t\tconst anchorRow = Math.max(0, previousMaxScroll - this.scrollFromBottom);\n\t\t\tconst shift = rowsShiftedAboveAnchor(\n\t\t\t\t{ rowCounts: this.lastComponentRowCounts, segments: this.lastComponentSegments },\n\t\t\t\t{ rowCounts, segments },\n\t\t\t\tanchorRow,\n\t\t\t);\n\t\t\tconst nextAnchorRow = Math.max(0, Math.min(maxScroll, anchorRow + shift));\n\t\t\tthis.scrollFromBottom = maxScroll - nextAnchorRow;\n\t\t}\n\t\tthis.lastLineCount = lineCount;\n\t\tthis.lastComponentRowCounts = rowCounts;\n\t\tthis.lastComponentSegments = segments;\n\t\tthis.lastWidth = width;\n\t\tthis.maxScroll = maxScroll;\n\t\tthis.clampScroll();\n\n\t\tconst start = Math.max(0, maxScroll - this.scrollFromBottom);\n\t\tconst visible = this.renderVisibleRows(componentRows, width, start, start + this.visibleRows);\n\t\twhile (visible.length < this.visibleRows) visible.push(\" \".repeat(width));\n\t\treturn visible;\n\t}\n\n\tinvalidate(): void {\n\t\tfor (const component of this.components) component.invalidate();\n\t}\n\n\tprivate measureComponentRows(width: number): ComponentRows[] {\n\t\treturn this.components.map((component) => {\n\t\t\tif (isRowWindowComponent(component)) {\n\t\t\t\treturn {\n\t\t\t\t\tkind: \"windowed\",\n\t\t\t\t\tcomponent,\n\t\t\t\t\trowCount: component.rowCount(width),\n\t\t\t\t\tsegments: component.rowSegments?.(width),\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst lines = component.render(width);\n\t\t\t// Read segments only after rendering: a static transcript records its\n\t\t\t// per-entry heights as a by-product of that render, so asking first\n\t\t\t// would return the previous frame's layout.\n\t\t\tconst segments = segmentReporter(component)?.rowSegments(width);\n\t\t\treturn {\n\t\t\t\tkind: \"static\",\n\t\t\t\tlines,\n\t\t\t\trowCount: lines.length,\n\t\t\t\tsegments: segments !== undefined && segments.length > 0 ? segments : undefined,\n\t\t\t};\n\t\t});\n\t}\n\n\tprivate renderVisibleRows(\n\t\tcomponentRows: readonly ComponentRows[],\n\t\twidth: number,\n\t\tstartRow: number,\n\t\tendRow: number,\n\t): string[] {\n\t\tconst lines: string[] = [];\n\t\tlet cursor = 0;\n\t\tfor (const rows of componentRows) {\n\t\t\tconst componentStart = cursor;\n\t\t\tconst componentEnd = componentStart + rows.rowCount;\n\t\t\tif (componentEnd > startRow && componentStart < endRow) {\n\t\t\t\tconst localStart = Math.max(0, startRow - componentStart);\n\t\t\t\tconst localEnd = Math.min(rows.rowCount, endRow - componentStart);\n\t\t\t\tif (rows.kind === \"windowed\") {\n\t\t\t\t\tlines.push(...rows.component.renderRows(width, localStart, localEnd));\n\t\t\t\t} else {\n\t\t\t\t\tlines.push(...rows.lines.slice(localStart, localEnd));\n\t\t\t\t}\n\t\t\t}\n\t\t\tcursor = componentEnd;\n\t\t\tif (cursor >= endRow) break;\n\t\t}\n\t\treturn lines;\n\t}\n\n\tprivate pageSize(): number {\n\t\treturn Math.max(4, this.visibleRows - 2);\n\t}\n\n\tprivate clampScroll(): void {\n\t\tthis.scrollFromBottom = Math.max(0, Math.min(this.maxScroll, this.scrollFromBottom));\n\t}\n}\n\n/** One rendered frame's row layout, as the viewport measured it. */\ninterface ComponentRowLayout {\n\treadonly rowCounts: readonly number[];\n\treadonly segments: readonly (readonly RowWindowSegment[] | undefined)[];\n}\n\n/**\n * Rows gained or lost above `anchorRow`, measured in the previous frame's rows.\n *\n * The anchored row moves down by exactly this many rows, so adding it to the\n * anchor keeps the same content under the viewer.\n *\n * Components entirely above the anchor contribute their whole height delta.\n * The component that *spans* the anchor contributes only what changed above the\n * anchored row, which needs its row map (`rowSegments`); without one it\n * contributes nothing, which is the old behaviour and is right for the\n * append-and-mutate-at-the-tail widgets that have no interior.\n *\n * Row counts are compared positionally over the shared prefix, which is what the\n * chat stacks this viewport drives actually do — they append and mutate at the\n * tail. A component inserted or removed *ahead* of the anchor would be\n * misattributed; the anchor then lands one component off rather than drifting on\n * every frame, and the next user scroll re-establishes it.\n */\nfunction rowsShiftedAboveAnchor(previous: ComponentRowLayout, next: ComponentRowLayout, anchorRow: number): number {\n\tlet cursor = 0;\n\tlet shift = 0;\n\tconst shared = Math.min(previous.rowCounts.length, next.rowCounts.length);\n\tfor (let index = 0; index < shared; index += 1) {\n\t\tconst previousRows = previous.rowCounts[index] ?? 0;\n\t\tconst componentEnd = cursor + previousRows;\n\t\tif (componentEnd > anchorRow) {\n\t\t\treturn shift + rowsShiftedInsideComponent(previous.segments[index], next.segments[index], anchorRow - cursor);\n\t\t}\n\t\tshift += (next.rowCounts[index] ?? 0) - previousRows;\n\t\tcursor = componentEnd;\n\t}\n\treturn shift;\n}\n\n/**\n * Rows gained or lost above `anchorRow` *within* one windowed component.\n *\n * Rather than diffing heights, this finds the segment the viewer is parked on\n * and reports how far that same segment moved. Segments are matched by `===` on\n * their id, so a transcript splice that renumbers every cache key still lines\n * up: the entry objects survive it. If the anchored segment itself is gone\n * (the viewer was reading rows that were compacted away) the nearest surviving\n * neighbour above it — then below it — stands in, so the viewer lands on the\n * closest content that still exists instead of drifting by the whole delta.\n */\nfunction rowsShiftedInsideComponent(\n\tpreviousSegments: readonly RowWindowSegment[] | undefined,\n\tnextSegments: readonly RowWindowSegment[] | undefined,\n\tanchorRow: number,\n): number {\n\tif (previousSegments === undefined || nextSegments === undefined) return 0;\n\tconst nextStarts = new Map<unknown, number>();\n\tlet cursor = 0;\n\tfor (const segment of nextSegments) {\n\t\tif (!nextStarts.has(segment.id)) nextStarts.set(segment.id, cursor);\n\t\tcursor += segment.rows;\n\t}\n\tconst previousStarts: number[] = [];\n\tlet anchorIndex = -1;\n\tcursor = 0;\n\tfor (let index = 0; index < previousSegments.length; index += 1) {\n\t\tpreviousStarts.push(cursor);\n\t\tcursor += previousSegments[index]?.rows ?? 0;\n\t\tif (anchorIndex < 0 && cursor > anchorRow) anchorIndex = index;\n\t}\n\tif (anchorIndex < 0) return 0;\n\tfor (let index = anchorIndex; index >= 0; index -= 1) {\n\t\tconst nextStart = nextStarts.get(previousSegments[index]?.id);\n\t\tif (nextStart !== undefined) return nextStart - (previousStarts[index] ?? 0);\n\t}\n\tfor (let index = anchorIndex + 1; index < previousSegments.length; index += 1) {\n\t\tconst nextStart = nextStarts.get(previousSegments[index]?.id);\n\t\tif (nextStart !== undefined) return nextStart - (previousStarts[index] ?? 0);\n\t}\n\treturn 0;\n}\n\nfunction isRowWindowComponent(component: Component): component is RowWindowComponent {\n\tconst candidate = component as Partial<RowWindowComponent>;\n\treturn (\n\t\tcandidate.supportsRowWindow === true &&\n\t\ttypeof candidate.rowCount === \"function\" &&\n\t\ttypeof candidate.renderRows === \"function\"\n\t);\n}\n\n/**\n * A component that can identify its own rows without being windowed.\n *\n * `ScrollableChatTranscriptComponent` builds its transcript without a cache key\n * — deliberately, because that is what lets it reflect entries mutated in place\n * — so it is not a `RowWindowComponent` and renders every row each frame. It\n * still knows which entry produced which rows, and it is still the component\n * spanning the anchor, so the anchor needs to ask.\n */\nfunction segmentReporter(\n\tcomponent: Component,\n): { rowSegments(width: number): readonly RowWindowSegment[] } | undefined {\n\tconst candidate = component as Partial<RowWindowComponent>;\n\treturn typeof candidate.rowSegments === \"function\"\n\t\t? (candidate as { rowSegments(width: number): readonly RowWindowSegment[] })\n\t\t: undefined;\n}\n\nexport class ScrollableChatTranscriptComponent<TEntry extends ChatTranscriptEntryLike> implements Component {\n\tprivate readonly viewport = new ScrollableComponentViewport();\n\tprivate readonly transcript: ChatTranscriptComponent<TEntry>;\n\n\tconstructor(entries: readonly TEntry[], renderEntry: ChatTranscriptRenderer<TEntry>) {\n\t\tthis.transcript = new ChatTranscriptComponent(entries, renderEntry);\n\t\tthis.viewport.setComponents([this.transcript]);\n\t}\n\n\tsetVisibleRows(rows: number): void {\n\t\tthis.viewport.setVisibleRows(rows);\n\t}\n\n\thandleInput(data: string): boolean {\n\t\treturn this.viewport.handleInput(data);\n\t}\n\n\trender(width: number): string[] {\n\t\treturn this.viewport.render(width);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.viewport.invalidate();\n\t}\n\n\tgetScrollFromBottom(): number {\n\t\treturn this.viewport.getScrollFromBottom();\n\t}\n\n\tgetMaxScroll(): number {\n\t\treturn this.viewport.getMaxScroll();\n\t}\n\n\tscrollToBottom(): void {\n\t\tthis.viewport.scrollToBottom();\n\t}\n}\n\nexport function mouseWheelDeltaRows(data: string): number {\n\tconst sgr = data.match(/^\\x1b\\[<(\\d+);\\d+;\\d+M$/);\n\tif (sgr) return wheelDeltaForButtonCode(Number.parseInt(sgr[1]!, 10));\n\tif (data.startsWith(\"\\x1b[M\") && data.length >= 6) {\n\t\treturn wheelDeltaForButtonCode(data.charCodeAt(3) - 32);\n\t}\n\treturn 0;\n}\n\nfunction wheelDeltaForButtonCode(code: number): number {\n\tif ((code & 64) === 0) return 0;\n\tconst direction = code & 3;\n\tif (direction === 0) return -DEFAULT_SCROLL_STEP_ROWS;\n\tif (direction === 1) return DEFAULT_SCROLL_STEP_ROWS;\n\treturn 0;\n}\n\nfunction isMouseSequence(data: string): boolean {\n\treturn /^\\x1b\\[<\\d+;\\d+;\\d+[mM]$/.test(data) || data.startsWith(\"\\x1b[M\");\n}\n"]}
1
+ {"version":3,"file":"chat-transcript.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-transcript.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,cAAc,EAEd,UAAU,EACV,MAAM,GACN,MAAM,wBAAwB,CAAC;AAoFhC,MAAM,UAAU,sBAAsB,CAAC,SAAoB,EAAE,SAAoB,EAAE,IAAwB;IAC1G,IAAI,kBAAkB,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/D,SAAS,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC;IACD,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,kBAAkB,CAAC,IAAwB;IACnD,OAAO,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,SAAS,CAAC;AAC7G,CAAC;AAED;;;;;;;GAOG;AACH,MAA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AY;IAC5C,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAChC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC;IAC3B,IAAI,SAAS,KAAK,CAAC;QAAE,OAAO,CAAC,wBAAwB,CAAC;IACtD,IAAI,SAAS,KAAK,CAAC;QAAE,OAAO,wBAAwB,CAAC;IACrD,OAAO,CAAC,CAAC;AACV,CAAC;AAED,SAAS,eAAe,CAAC,IAAY;IACpC,OAAO,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AAC3E,CAAC","sourcesContent":["import {\n\ttype Component,\n\ttype Container,\n\tgetKeybindings,\n\ttype KeybindingsManager,\n\tmatchesKey,\n\tSpacer,\n} from \"@earendil-works/pi-tui\";\n\n/**\n * Roles that participate in pi's chat spacing contract.\n *\n * Assistant turns own their leading whitespace internally, and tool rows attach\n * directly under the assistant/tool-call row they belong to. User-like rows get\n * one blank line when they are not the first row in the transcript.\n */\nexport type ChatTranscriptRole =\n\t| \"assistant\"\n\t| \"thinking\"\n\t| \"tool\"\n\t| \"user\"\n\t| \"custom\"\n\t| \"notice\"\n\t| \"system\"\n\t| \"summary\";\n\nexport interface ChatTranscriptEntryLike {\n\treadonly role: ChatTranscriptRole;\n}\n\nexport type ChatTranscriptRenderer<TEntry extends ChatTranscriptEntryLike> = (entry: TEntry) => Component;\n\nexport type ChatTranscriptCacheKey<TEntry extends ChatTranscriptEntryLike> = (entry: TEntry, index: number) => string;\n\ninterface CachedChatTranscriptBlock<TEntry extends ChatTranscriptEntryLike> {\n\treadonly entry: TEntry;\n\treadonly key: string;\n\treadonly width: number;\n\treadonly component: Component;\n\treadonly lines: readonly string[];\n}\n\ntype DisposableComponent = Component & { dispose?: () => void };\n\n/**\n * A run of rows inside a windowed component, tagged with the identity of the\n * thing that produced them.\n *\n * `id` is compared with `===` only, and is never rendered. Entry *objects* are\n * the natural id for a transcript: cache keys carry the entry's index and so\n * change for every survivor of a splice, while the entry objects themselves are\n * moved, not rebuilt.\n */\nexport interface RowWindowSegment {\n\treadonly id: unknown;\n\treadonly rows: number;\n}\n\ninterface RowWindowComponent extends Component {\n\treadonly supportsRowWindow: true;\n\trowCount(width: number): number;\n\trenderRows(width: number, startRow: number, endRow: number): string[];\n\t/**\n\t * Optional row map, letting the viewport keep a scroll anchor that sits\n\t * *inside* this component when its interior changes height.\n\t */\n\trowSegments?(width: number): readonly RowWindowSegment[];\n}\n\ninterface WindowedComponentRows {\n\treadonly kind: \"windowed\";\n\treadonly component: RowWindowComponent;\n\treadonly rowCount: number;\n\treadonly segments: readonly RowWindowSegment[] | undefined;\n}\n\ninterface StaticComponentRows {\n\treadonly kind: \"static\";\n\treadonly lines: readonly string[];\n\treadonly rowCount: number;\n\t/**\n\t * Present when a static component can still identify its own rows. A\n\t * transcript built without a cache key renders every row each frame rather\n\t * than windowing, but it knows just as well which entry produced which rows,\n\t * and the anchor needs that whenever it is the component spanning the anchor.\n\t */\n\treadonly segments?: readonly RowWindowSegment[] | undefined;\n}\n\ntype ComponentRows = WindowedComponentRows | StaticComponentRows;\n\nexport function addChatTranscriptEntry(container: Container, component: Component, role: ChatTranscriptRole): void {\n\tif (needsLeadingSpacer(role) && container.children.length > 0) {\n\t\tcontainer.addChild(new Spacer(1));\n\t}\n\tcontainer.addChild(component);\n}\n\nfunction needsLeadingSpacer(role: ChatTranscriptRole): boolean {\n\treturn role === \"user\" || role === \"custom\" || role === \"notice\" || role === \"system\" || role === \"summary\";\n}\n\n/**\n * Reusable pi chat transcript scaffold for extension surfaces.\n *\n * This intentionally mirrors InteractiveMode.addMessageToChat spacing without\n * coupling consumers to a full AgentSession. Extension UIs can bring their own\n * message model while still rendering inside the same Container/Spacer rhythm\n * as the main chat.\n */\nexport class ChatTranscriptComponent<TEntry extends ChatTranscriptEntryLike> implements Component {\n\tprivate readonly entries: readonly TEntry[];\n\tprivate readonly renderEntry: ChatTranscriptRenderer<TEntry>;\n\treadonly supportsRowWindow: boolean;\n\n\tprivate readonly cacheKey: ChatTranscriptCacheKey<TEntry> | undefined;\n\tprivate blockCache: Array<CachedChatTranscriptBlock<TEntry> | undefined> = [];\n\t/** Per-entry heights recorded by the most recent `renderAllRows`. */\n\tprivate staticSegments: readonly RowWindowSegment[] = [];\n\t/** Width those heights were measured at; they mean nothing at another width. */\n\tprivate staticSegmentsWidth: number | undefined;\n\n\tconstructor(\n\t\tentries: readonly TEntry[],\n\t\trenderEntry: ChatTranscriptRenderer<TEntry>,\n\t\tcacheKey?: ChatTranscriptCacheKey<TEntry>,\n\t) {\n\t\tthis.entries = entries;\n\t\tthis.renderEntry = renderEntry;\n\t\tthis.cacheKey = cacheKey;\n\t\tthis.supportsRowWindow = cacheKey !== undefined;\n\t}\n\n\trender(width: number): string[] {\n\t\tif (!this.supportsRowWindow) return this.renderAllRows(width);\n\t\treturn this.renderRows(width, 0, this.rowCount(width));\n\t}\n\n\trowCount(width: number): number {\n\t\tif (!this.supportsRowWindow) return this.renderAllRows(width).length;\n\t\tthis.ensureBlockCache(width);\n\t\tlet count = 0;\n\t\tfor (const block of this.blockCache) {\n\t\t\tif (block !== undefined) count += block.lines.length;\n\t\t}\n\t\treturn count;\n\t}\n\n\t/**\n\t * One segment per cached entry block, identified by the entry object itself.\n\t */\n\trowSegments(width: number): readonly RowWindowSegment[] {\n\t\tif (!this.supportsRowWindow) {\n\t\t\t// Recorded by the last renderAllRows. The viewport measures a static\n\t\t\t// component by rendering it and only then reads its segments, so this\n\t\t\t// is populated for the frame being measured. A width mismatch means the\n\t\t\t// heights describe a different layout, and reporting them would move the\n\t\t\t// anchor by a stale delta; the caller falls back to whole-component\n\t\t\t// accounting instead.\n\t\t\treturn this.staticSegmentsWidth === width ? this.staticSegments : [];\n\t\t}\n\t\tthis.ensureBlockCache(width);\n\t\tconst segments: RowWindowSegment[] = [];\n\t\tfor (const block of this.blockCache) {\n\t\t\tif (block !== undefined) segments.push({ id: block.entry, rows: block.lines.length });\n\t\t}\n\t\treturn segments;\n\t}\n\n\trenderRows(width: number, startRow: number, endRow: number): string[] {\n\t\tconst start = Math.max(0, Math.floor(startRow));\n\t\tconst end = Math.max(start, Math.floor(endRow));\n\t\tif (end <= start) return [];\n\t\tif (!this.supportsRowWindow) return this.renderAllRows(width).slice(start, end);\n\n\t\tthis.ensureBlockCache(width);\n\t\tconst lines: string[] = [];\n\t\tlet cursor = 0;\n\t\tfor (let index = 0; index < this.entries.length; index += 1) {\n\t\t\tconst block = this.blockCache[index];\n\t\t\tif (block === undefined) continue;\n\t\t\tconst blockStart = cursor;\n\t\t\tconst blockEnd = blockStart + block.lines.length;\n\t\t\tif (blockEnd > start && blockStart < end) {\n\t\t\t\tconst localStart = Math.max(0, start - blockStart);\n\t\t\t\tconst localEnd = Math.min(block.lines.length, end - blockStart);\n\t\t\t\tlines.push(...block.lines.slice(localStart, localEnd));\n\t\t\t}\n\t\t\tcursor = blockEnd;\n\t\t\tif (cursor >= end) break;\n\t\t}\n\t\treturn lines;\n\t}\n\n\tinvalidate(): void {\n\t\tfor (const block of this.blockCache) disposeComponent(block?.component);\n\t\tthis.blockCache = [];\n\t}\n\n\tprivate ensureBlockCache(width: number): void {\n\t\tif (this.blockCache.length > this.entries.length) {\n\t\t\tfor (let index = this.entries.length; index < this.blockCache.length; index += 1) {\n\t\t\t\tdisposeComponent(this.blockCache[index]?.component);\n\t\t\t}\n\t\t\tthis.blockCache.length = this.entries.length;\n\t\t}\n\t\tfor (let index = 0; index < this.entries.length; index += 1) {\n\t\t\tconst entry = this.entries[index];\n\t\t\tif (entry === undefined) continue;\n\t\t\tconst key = this.cacheKey?.(entry, index) ?? `${index}:${entry.role}`;\n\t\t\tconst cached = this.blockCache[index];\n\t\t\tif (cached !== undefined && cached.entry === entry && cached.key === key && cached.width === width) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tdisposeComponent(cached?.component);\n\t\t\tconst component = this.renderEntry(entry);\n\t\t\tthis.blockCache[index] = {\n\t\t\t\tentry,\n\t\t\t\tkey,\n\t\t\t\twidth,\n\t\t\t\tcomponent,\n\t\t\t\tlines: this.renderEntryBlock(component, entry, index, width),\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * Render every entry, recording each one's height as it goes.\n\t *\n\t * The heights are what `rowSegments` reports on this path. They are a\n\t * by-product of work this method already does, so identifying rows costs\n\t * nothing extra and, unlike a cache key, cannot miss an entry mutated in\n\t * place -- which is the behaviour a transcript without a cache key exists to\n\t * provide.\n\t */\n\tprivate renderAllRows(width: number): string[] {\n\t\tconst lines: string[] = [];\n\t\tconst segments: RowWindowSegment[] = [];\n\t\tfor (let index = 0; index < this.entries.length; index += 1) {\n\t\t\tconst entry = this.entries[index];\n\t\t\tif (entry === undefined) continue;\n\t\t\tconst block = this.renderEntryBlock(this.renderEntry(entry), entry, index, width);\n\t\t\tsegments.push({ id: entry, rows: block.length });\n\t\t\tlines.push(...block);\n\t\t}\n\t\tthis.staticSegments = segments;\n\t\tthis.staticSegmentsWidth = width;\n\t\treturn lines;\n\t}\n\n\tprivate renderEntryBlock(component: Component, entry: TEntry, index: number, width: number): string[] {\n\t\tconst lines: string[] = [];\n\t\tif (index > 0 && needsLeadingSpacer(entry.role)) lines.push(\"\");\n\t\tlines.push(...component.render(width));\n\t\treturn lines;\n\t}\n}\n\nfunction disposeComponent(component: Component | undefined): void {\n\t(component as DisposableComponent | undefined)?.dispose?.();\n}\n\nconst DEFAULT_SCROLL_STEP_ROWS = 4;\n\n/**\n * Sticky-bottom, scrollable viewport for chat-like component stacks.\n *\n * Pi's main interactive chat gets terminal scrollback for free. Extension\n * overlays render into a fixed rectangle, so they need an explicit viewport\n * with the same sticky-bottom default plus keyboard and mouse history controls.\n */\nexport class ScrollableComponentViewport implements Component {\n\tprivate components: readonly Component[] = [];\n\tprivate visibleRows = 1;\n\tprivate scrollFromBottom = 0;\n\tprivate lastLineCount = 0;\n\tprivate lastComponentSegments: readonly (readonly RowWindowSegment[] | undefined)[] = [];\n\tprivate lastComponentRowCounts: readonly number[] = [];\n\tprivate lastWidth = 0;\n\tprivate maxScroll = 0;\n\t/**\n\t * Absolute row `scrollTo` asked for, still waiting for the render that can\n\t * honour it. See `scrollTo` for why the request has to outlive the call.\n\t */\n\tprivate pendingScrollRow: number | undefined;\n\tprivate readonly keybindings: Pick<KeybindingsManager, \"matches\"> | undefined;\n\n\tconstructor(keybindings?: unknown) {\n\t\tconst candidate = keybindings as Partial<Pick<KeybindingsManager, \"matches\">> | undefined;\n\t\tthis.keybindings =\n\t\t\ttypeof candidate?.matches === \"function\" ? (candidate as Pick<KeybindingsManager, \"matches\">) : undefined;\n\t}\n\n\tsetComponents(components: readonly Component[]): void {\n\t\tthis.components = components;\n\t}\n\n\tsetVisibleRows(rows: number): void {\n\t\tthis.visibleRows = Math.max(1, Math.floor(rows));\n\t\tthis.clampScroll();\n\t}\n\n\tgetScrollFromBottom(): number {\n\t\treturn this.scrollFromBottom;\n\t}\n\n\tgetMaxScroll(): number {\n\t\treturn this.maxScroll;\n\t}\n\n\tscrollToBottom(): void {\n\t\tthis.pendingScrollRow = undefined;\n\t\tthis.scrollFromBottom = 0;\n\t}\n\n\tscrollToTop(): void {\n\t\tthis.pendingScrollRow = undefined;\n\t\tthis.scrollFromBottom = this.maxScroll;\n\t}\n\n\tscrollBy(deltaRows: number): void {\n\t\t// Positive deltas move toward newer content; negative deltas move up\n\t\t// into older history. Store the offset from the sticky bottom so new\n\t\t// streaming output can keep following when the offset is zero.\n\t\tthis.pendingScrollRow = undefined;\n\t\tthis.scrollFromBottom -= deltaRows;\n\t\tthis.clampScroll();\n\t}\n\n\t/**\n\t * Park the viewport with `row` as its first visible row.\n\t *\n\t * The absolute counterpart of `scrollBy`, for a caller that already knows\n\t * which row it wants on screen.\n\t *\n\t * The request is *also* recorded for the next render, and that is the half\n\t * that matters. `scrollFromBottom` is a distance from the bottom, so the\n\t * row it names moves whenever the stack grows; and the render that follows\n\t * re-derives the offset from the previous frame's layout to hold a\n\t * scrolled-up reader's content still, which would drag this request back\n\t * with it. A caller who has just measured rows the last render never saw\n\t * would otherwise be answered with the old layout's clamp and the old\n\t * frame's anchor. The next render resolves the row against the layout it\n\t * actually paints; any other scroll before then withdraws the request.\n\t */\n\tscrollTo(row: number): void {\n\t\tconst requestedRow = Number.isNaN(row) ? 0 : Math.max(0, Math.floor(row));\n\t\tthis.pendingScrollRow = requestedRow;\n\t\tconst target = Math.min(this.maxScroll, requestedRow);\n\t\tthis.scrollFromBottom = this.maxScroll - target;\n\t\tthis.clampScroll();\n\t}\n\n\t/**\n\t * Total rows the component stack occupies at `width`, on and off screen.\n\t *\n\t * This measures rather than paints: it is what lets a search read the whole\n\t * transcript instead of the window the reader happens to be parked on.\n\t */\n\trowCount(width: number): number {\n\t\treturn this.measureComponentRows(width).reduce((sum, rows) => sum + rows.rowCount, 0);\n\t}\n\n\t/**\n\t * Rows `startRow` (inclusive) through `endRow` (exclusive) of the whole\n\t * stack, independent of the current scroll offset. Deliberately not paired\n\t * with `supportsRowWindow`: a viewport is a scroll container rather than a\n\t * windowed component, and an enclosing viewport must keep measuring it by\n\t * its visible height.\n\t */\n\trenderRows(width: number, startRow: number, endRow: number): string[] {\n\t\treturn this.renderVisibleRows(this.measureComponentRows(width), width, startRow, endRow);\n\t}\n\n\thandleInput(data: string): boolean {\n\t\tconst wheelDeltaRows = mouseWheelDeltaRows(data);\n\t\tif (wheelDeltaRows !== 0) {\n\t\t\tthis.scrollBy(wheelDeltaRows);\n\t\t\treturn true;\n\t\t}\n\t\tif (isMouseSequence(data)) return true;\n\t\tif (matchesKey(data, \"pageUp\")) {\n\t\t\tthis.scrollBy(-this.pageSize());\n\t\t\treturn true;\n\t\t}\n\t\tif (matchesKey(data, \"pageDown\")) {\n\t\t\tthis.scrollBy(this.pageSize());\n\t\t\treturn true;\n\t\t}\n\t\tif ((this.keybindings ?? getKeybindings()).matches(data, \"tui.altScreen.top\")) {\n\t\t\tthis.scrollToTop();\n\t\t\treturn true;\n\t\t}\n\t\tif ((this.keybindings ?? getKeybindings()).matches(data, \"tui.altScreen.bottom\")) {\n\t\t\tthis.scrollToBottom();\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\trender(width: number): string[] {\n\t\tconst componentRows = this.measureComponentRows(width);\n\t\tconst rowCounts = componentRows.map((rows) => rows.rowCount);\n\t\tconst lineCount = rowCounts.reduce((sum, count) => sum + count, 0);\n\t\tconst maxScroll = Math.max(0, lineCount - this.visibleRows);\n\t\t// The offset is a distance from the bottom, so the first visible row is\n\t\t// `maxScroll - scrollFromBottom`. Rows appearing or disappearing move the\n\t\t// content a scrolled-up viewer is reading unless the offset moves with\n\t\t// them -- a live subagent widget does exactly that every time it gains or\n\t\t// drops its current-tool row.\n\t\t//\n\t\t// Which way the offset must move depends on where the rows changed, so a\n\t\t// plain `scrollFromBottom += lineCount - lastLineCount` is wrong half the\n\t\t// time. Rows changing *below* the anchor need the offset adjusted by that\n\t\t// delta; rows changing *above* it need the offset left alone, because the\n\t\t// bottom-relative distance to the anchored content did not change. Anchor\n\t\t// on the row the viewer is actually reading and re-derive the offset from\n\t\t// it. A viewer already at the bottom keeps scrollFromBottom === 0 and is\n\t\t// skipped entirely, so sticky-bottom following is untouched.\n\t\t//\n\t\t// Per-component row counts alone cannot place a change that happens\n\t\t// inside the component holding the anchor -- and in the chat host the\n\t\t// whole transcript is one component, so that is the normal case. A\n\t\t// component that can hand over a row map turns the \"where\" question into\n\t\t// \"where did the anchored segment go\". Both kinds may supply one: a\n\t\t// transcript built without a cache key is not windowed, but it is still\n\t\t// one component spanning the anchor and still knows its own rows.\n\t\tconst segments = componentRows.map((rows) => rows.segments);\n\t\tconst pendingScrollRow = this.pendingScrollRow;\n\t\tthis.pendingScrollRow = undefined;\n\t\tif (pendingScrollRow !== undefined) {\n\t\t\t// An absolute request outranks the anchor: the caller measured this\n\t\t\t// frame's rows and named one of them. Re-deriving the anchor here\n\t\t\t// would answer with the previous frame's layout instead.\n\t\t\tthis.scrollFromBottom = maxScroll - Math.min(maxScroll, pendingScrollRow);\n\t\t} else if (this.scrollFromBottom > 0 && this.lastWidth === width) {\n\t\t\tconst previousMaxScroll = Math.max(0, this.lastLineCount - this.visibleRows);\n\t\t\tconst anchorRow = Math.max(0, previousMaxScroll - this.scrollFromBottom);\n\t\t\tconst shift = rowsShiftedAboveAnchor(\n\t\t\t\t{ rowCounts: this.lastComponentRowCounts, segments: this.lastComponentSegments },\n\t\t\t\t{ rowCounts, segments },\n\t\t\t\tanchorRow,\n\t\t\t);\n\t\t\tconst nextAnchorRow = Math.max(0, Math.min(maxScroll, anchorRow + shift));\n\t\t\tthis.scrollFromBottom = maxScroll - nextAnchorRow;\n\t\t}\n\t\tthis.lastLineCount = lineCount;\n\t\tthis.lastComponentRowCounts = rowCounts;\n\t\tthis.lastComponentSegments = segments;\n\t\tthis.lastWidth = width;\n\t\tthis.maxScroll = maxScroll;\n\t\tthis.clampScroll();\n\n\t\tconst start = Math.max(0, maxScroll - this.scrollFromBottom);\n\t\tconst visible = this.renderVisibleRows(componentRows, width, start, start + this.visibleRows);\n\t\twhile (visible.length < this.visibleRows) visible.push(\" \".repeat(width));\n\t\treturn visible;\n\t}\n\n\tinvalidate(): void {\n\t\tfor (const component of this.components) component.invalidate();\n\t}\n\n\tprivate measureComponentRows(width: number): ComponentRows[] {\n\t\treturn this.components.map((component) => {\n\t\t\tif (isRowWindowComponent(component)) {\n\t\t\t\treturn {\n\t\t\t\t\tkind: \"windowed\",\n\t\t\t\t\tcomponent,\n\t\t\t\t\trowCount: component.rowCount(width),\n\t\t\t\t\tsegments: component.rowSegments?.(width),\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst lines = component.render(width);\n\t\t\t// Read segments only after rendering: a static transcript records its\n\t\t\t// per-entry heights as a by-product of that render, so asking first\n\t\t\t// would return the previous frame's layout.\n\t\t\tconst segments = segmentReporter(component)?.rowSegments(width);\n\t\t\treturn {\n\t\t\t\tkind: \"static\",\n\t\t\t\tlines,\n\t\t\t\trowCount: lines.length,\n\t\t\t\tsegments: segments !== undefined && segments.length > 0 ? segments : undefined,\n\t\t\t};\n\t\t});\n\t}\n\n\tprivate renderVisibleRows(\n\t\tcomponentRows: readonly ComponentRows[],\n\t\twidth: number,\n\t\tstartRow: number,\n\t\tendRow: number,\n\t): string[] {\n\t\tconst lines: string[] = [];\n\t\tlet cursor = 0;\n\t\tfor (const rows of componentRows) {\n\t\t\tconst componentStart = cursor;\n\t\t\tconst componentEnd = componentStart + rows.rowCount;\n\t\t\tif (componentEnd > startRow && componentStart < endRow) {\n\t\t\t\tconst localStart = Math.max(0, startRow - componentStart);\n\t\t\t\tconst localEnd = Math.min(rows.rowCount, endRow - componentStart);\n\t\t\t\tif (rows.kind === \"windowed\") {\n\t\t\t\t\tlines.push(...rows.component.renderRows(width, localStart, localEnd));\n\t\t\t\t} else {\n\t\t\t\t\tlines.push(...rows.lines.slice(localStart, localEnd));\n\t\t\t\t}\n\t\t\t}\n\t\t\tcursor = componentEnd;\n\t\t\tif (cursor >= endRow) break;\n\t\t}\n\t\treturn lines;\n\t}\n\n\tprivate pageSize(): number {\n\t\treturn Math.max(4, this.visibleRows - 2);\n\t}\n\n\tprivate clampScroll(): void {\n\t\tthis.scrollFromBottom = Math.max(0, Math.min(this.maxScroll, this.scrollFromBottom));\n\t}\n}\n\n/** One rendered frame's row layout, as the viewport measured it. */\ninterface ComponentRowLayout {\n\treadonly rowCounts: readonly number[];\n\treadonly segments: readonly (readonly RowWindowSegment[] | undefined)[];\n}\n\n/**\n * Rows gained or lost above `anchorRow`, measured in the previous frame's rows.\n *\n * The anchored row moves down by exactly this many rows, so adding it to the\n * anchor keeps the same content under the viewer.\n *\n * Components entirely above the anchor contribute their whole height delta.\n * The component that *spans* the anchor contributes only what changed above the\n * anchored row, which needs its row map (`rowSegments`); without one it\n * contributes nothing, which is the old behaviour and is right for the\n * append-and-mutate-at-the-tail widgets that have no interior.\n *\n * Row counts are compared positionally over the shared prefix, which is what the\n * chat stacks this viewport drives actually do — they append and mutate at the\n * tail. A component inserted or removed *ahead* of the anchor would be\n * misattributed; the anchor then lands one component off rather than drifting on\n * every frame, and the next user scroll re-establishes it.\n */\nfunction rowsShiftedAboveAnchor(previous: ComponentRowLayout, next: ComponentRowLayout, anchorRow: number): number {\n\tlet cursor = 0;\n\tlet shift = 0;\n\tconst shared = Math.min(previous.rowCounts.length, next.rowCounts.length);\n\tfor (let index = 0; index < shared; index += 1) {\n\t\tconst previousRows = previous.rowCounts[index] ?? 0;\n\t\tconst componentEnd = cursor + previousRows;\n\t\tif (componentEnd > anchorRow) {\n\t\t\treturn shift + rowsShiftedInsideComponent(previous.segments[index], next.segments[index], anchorRow - cursor);\n\t\t}\n\t\tshift += (next.rowCounts[index] ?? 0) - previousRows;\n\t\tcursor = componentEnd;\n\t}\n\treturn shift;\n}\n\n/**\n * Rows gained or lost above `anchorRow` *within* one windowed component.\n *\n * Rather than diffing heights, this finds the segment the viewer is parked on\n * and reports how far that same segment moved. Segments are matched by `===` on\n * their id, so a transcript splice that renumbers every cache key still lines\n * up: the entry objects survive it. If the anchored segment itself is gone\n * (the viewer was reading rows that were compacted away) the nearest surviving\n * neighbour above it — then below it — stands in, so the viewer lands on the\n * closest content that still exists instead of drifting by the whole delta.\n */\nfunction rowsShiftedInsideComponent(\n\tpreviousSegments: readonly RowWindowSegment[] | undefined,\n\tnextSegments: readonly RowWindowSegment[] | undefined,\n\tanchorRow: number,\n): number {\n\tif (previousSegments === undefined || nextSegments === undefined) return 0;\n\tconst nextStarts = new Map<unknown, number>();\n\tlet cursor = 0;\n\tfor (const segment of nextSegments) {\n\t\tif (!nextStarts.has(segment.id)) nextStarts.set(segment.id, cursor);\n\t\tcursor += segment.rows;\n\t}\n\tconst previousStarts: number[] = [];\n\tlet anchorIndex = -1;\n\tcursor = 0;\n\tfor (let index = 0; index < previousSegments.length; index += 1) {\n\t\tpreviousStarts.push(cursor);\n\t\tcursor += previousSegments[index]?.rows ?? 0;\n\t\tif (anchorIndex < 0 && cursor > anchorRow) anchorIndex = index;\n\t}\n\tif (anchorIndex < 0) return 0;\n\tfor (let index = anchorIndex; index >= 0; index -= 1) {\n\t\tconst nextStart = nextStarts.get(previousSegments[index]?.id);\n\t\tif (nextStart !== undefined) return nextStart - (previousStarts[index] ?? 0);\n\t}\n\tfor (let index = anchorIndex + 1; index < previousSegments.length; index += 1) {\n\t\tconst nextStart = nextStarts.get(previousSegments[index]?.id);\n\t\tif (nextStart !== undefined) return nextStart - (previousStarts[index] ?? 0);\n\t}\n\treturn 0;\n}\n\nfunction isRowWindowComponent(component: Component): component is RowWindowComponent {\n\tconst candidate = component as Partial<RowWindowComponent>;\n\treturn (\n\t\tcandidate.supportsRowWindow === true &&\n\t\ttypeof candidate.rowCount === \"function\" &&\n\t\ttypeof candidate.renderRows === \"function\"\n\t);\n}\n\n/**\n * A component that can identify its own rows without being windowed.\n *\n * `ScrollableChatTranscriptComponent` builds its transcript without a cache key\n * — deliberately, because that is what lets it reflect entries mutated in place\n * — so it is not a `RowWindowComponent` and renders every row each frame. It\n * still knows which entry produced which rows, and it is still the component\n * spanning the anchor, so the anchor needs to ask.\n */\nfunction segmentReporter(\n\tcomponent: Component,\n): { rowSegments(width: number): readonly RowWindowSegment[] } | undefined {\n\tconst candidate = component as Partial<RowWindowComponent>;\n\treturn typeof candidate.rowSegments === \"function\"\n\t\t? (candidate as { rowSegments(width: number): readonly RowWindowSegment[] })\n\t\t: undefined;\n}\n\nexport class ScrollableChatTranscriptComponent<TEntry extends ChatTranscriptEntryLike> implements Component {\n\tprivate readonly viewport = new ScrollableComponentViewport();\n\tprivate readonly transcript: ChatTranscriptComponent<TEntry>;\n\n\tconstructor(entries: readonly TEntry[], renderEntry: ChatTranscriptRenderer<TEntry>) {\n\t\tthis.transcript = new ChatTranscriptComponent(entries, renderEntry);\n\t\tthis.viewport.setComponents([this.transcript]);\n\t}\n\n\tsetVisibleRows(rows: number): void {\n\t\tthis.viewport.setVisibleRows(rows);\n\t}\n\n\thandleInput(data: string): boolean {\n\t\treturn this.viewport.handleInput(data);\n\t}\n\n\trender(width: number): string[] {\n\t\treturn this.viewport.render(width);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.viewport.invalidate();\n\t}\n\n\tgetScrollFromBottom(): number {\n\t\treturn this.viewport.getScrollFromBottom();\n\t}\n\n\tgetMaxScroll(): number {\n\t\treturn this.viewport.getMaxScroll();\n\t}\n\n\tscrollToBottom(): void {\n\t\tthis.viewport.scrollToBottom();\n\t}\n}\n\nexport function mouseWheelDeltaRows(data: string): number {\n\tconst sgr = data.match(/^\\x1b\\[<(\\d+);\\d+;\\d+M$/);\n\tif (sgr) return wheelDeltaForButtonCode(Number.parseInt(sgr[1]!, 10));\n\tif (data.startsWith(\"\\x1b[M\") && data.length >= 6) {\n\t\treturn wheelDeltaForButtonCode(data.charCodeAt(3) - 32);\n\t}\n\treturn 0;\n}\n\nfunction wheelDeltaForButtonCode(code: number): number {\n\tif ((code & 64) === 0) return 0;\n\tconst direction = code & 3;\n\tif (direction === 0) return -DEFAULT_SCROLL_STEP_ROWS;\n\tif (direction === 1) return DEFAULT_SCROLL_STEP_ROWS;\n\treturn 0;\n}\n\nfunction isMouseSequence(data: string): boolean {\n\treturn /^\\x1b\\[<\\d+;\\d+;\\d+[mM]$/.test(data) || data.startsWith(\"\\x1b[M\");\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"tui-theme.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/tui-theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAiD1F;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAmBnE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAkExE;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAqChD;AAED,wBAAgB,kBAAkB,IAAI,eAAe,CAQpD;AAED,wBAAgB,cAAc,IAAI,WAAW,CAK5C;AAED,wBAAgB,oBAAoB,IAAI,OAAO,wBAAwB,EAAE,iBAAiB,CAQzF"}
1
+ {"version":3,"file":"tui-theme.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/tui-theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAkD1F;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAmBnE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAkExE;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAqChD;AAED,wBAAgB,kBAAkB,IAAI,eAAe,CAQpD;AAED,wBAAgB,cAAc,IAAI,WAAW,CAK5C;AAED,wBAAgB,oBAAoB,IAAI,OAAO,wBAAwB,EAAE,iBAAiB,CAQzF"}
@@ -11,6 +11,7 @@ function buildCliHighlightTheme(t) {
11
11
  number: (s) => t.fg("syntaxNumber", s),
12
12
  regexp: (s) => t.fg("syntaxString", s),
13
13
  string: (s) => t.fg("syntaxString", s),
14
+ subst: (s) => t.fg("text", s),
14
15
  comment: (s) => t.fg("syntaxComment", s),
15
16
  doctag: (s) => t.fg("syntaxComment", s),
16
17
  meta: (s) => t.fg("muted", s),
@@ -1 +1 @@
1
- {"version":3,"file":"tui-theme.js","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/tui-theme.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,oCAAoC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CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC3G,WAAW,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC;QACpD,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC;QAChC,IAAI,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC;KAC7C,CAAC;AACH,CAAC","sourcesContent":["import type { EditorTheme, MarkdownTheme, SelectListTheme } from \"@earendil-works/pi-tui\";\nimport chalk from \"chalk\";\nimport { highlight, supportsLanguage } from \"../../../utils/syntax-highlight.ts\";\nimport { theme } from \"./global-theme.ts\";\nimport type { Theme } from \"./theme-class.ts\";\n\ntype CliHighlightTheme = Record<string, (s: string) => string>;\n\nlet cachedHighlightThemeFor: Theme | undefined;\nlet cachedCliHighlightTheme: CliHighlightTheme | undefined;\n\nfunction buildCliHighlightTheme(t: Theme): CliHighlightTheme {\n\treturn {\n\t\tkeyword: (s: string) => t.fg(\"syntaxKeyword\", s),\n\t\tbuilt_in: (s: string) => t.fg(\"syntaxType\", s),\n\t\tliteral: (s: string) => t.fg(\"syntaxNumber\", s),\n\t\tnumber: (s: string) => t.fg(\"syntaxNumber\", s),\n\t\tregexp: (s: string) => t.fg(\"syntaxString\", s),\n\t\tstring: (s: string) => t.fg(\"syntaxString\", s),\n\t\tcomment: (s: string) => t.fg(\"syntaxComment\", s),\n\t\tdoctag: (s: string) => t.fg(\"syntaxComment\", s),\n\t\tmeta: (s: string) => t.fg(\"muted\", s),\n\t\tfunction: (s: string) => t.fg(\"syntaxFunction\", s),\n\t\ttitle: (s: string) => t.fg(\"syntaxFunction\", s),\n\t\tclass: (s: string) => t.fg(\"syntaxType\", s),\n\t\ttype: (s: string) => t.fg(\"syntaxType\", s),\n\t\ttag: (s: string) => t.fg(\"syntaxPunctuation\", s),\n\t\tname: (s: string) => t.fg(\"syntaxKeyword\", s),\n\t\tattr: (s: string) => t.fg(\"syntaxVariable\", s),\n\t\tvariable: (s: string) => t.fg(\"syntaxVariable\", s),\n\t\tparams: (s: string) => t.fg(\"syntaxVariable\", s),\n\t\toperator: (s: string) => t.fg(\"syntaxOperator\", s),\n\t\tpunctuation: (s: string) => t.fg(\"syntaxPunctuation\", s),\n\t\temphasis: (s: string) => t.italic(s),\n\t\tstrong: (s: string) => t.bold(s),\n\t\tlink: (s: string) => t.underline(s),\n\t\taddition: (s: string) => t.fg(\"toolDiffAdded\", s),\n\t\tdeletion: (s: string) => t.fg(\"toolDiffRemoved\", s),\n\t};\n}\n\nfunction getCliHighlightTheme(t: Theme): CliHighlightTheme {\n\tif (cachedHighlightThemeFor !== t || !cachedCliHighlightTheme) {\n\t\tcachedHighlightThemeFor = t;\n\t\tcachedCliHighlightTheme = buildCliHighlightTheme(t);\n\t}\n\treturn cachedCliHighlightTheme;\n}\n\n/**\n * Highlight code with syntax coloring based on file extension or language.\n * Returns array of highlighted lines.\n */\nexport function highlightCode(code: string, lang?: string): string[] {\n\t// Validate language before highlighting to avoid stderr spam from cli-highlight\n\tconst validLang = lang && supportsLanguage(lang) ? lang : undefined;\n\t// Skip highlighting when no valid language is specified. cli-highlight's\n\t// auto-detection is unreliable and can misidentify prose as AppleScript,\n\t// LiveCodeServer, etc., coloring random English words as keywords.\n\tif (!validLang) {\n\t\treturn code.split(\"\\n\").map((line) => theme.fg(\"mdCodeBlock\", line));\n\t}\n\tconst opts = {\n\t\tlanguage: validLang,\n\t\tignoreIllegals: true,\n\t\ttheme: getCliHighlightTheme(theme),\n\t};\n\ttry {\n\t\treturn highlight(code, opts).split(\"\\n\");\n\t} catch {\n\t\treturn code.split(\"\\n\");\n\t}\n}\n\n/**\n * Get language identifier from file path extension.\n */\nexport function getLanguageFromPath(filePath: string): string | undefined {\n\tconst ext = filePath.split(\".\").pop()?.toLowerCase();\n\tif (!ext) return undefined;\n\n\tconst extToLang: Record<string, string> = {\n\t\tts: \"typescript\",\n\t\ttsx: \"typescript\",\n\t\tjs: \"javascript\",\n\t\tjsx: \"javascript\",\n\t\tmjs: \"javascript\",\n\t\tcjs: \"javascript\",\n\t\tpy: \"python\",\n\t\trb: \"ruby\",\n\t\trs: \"rust\",\n\t\tgo: \"go\",\n\t\tjava: \"java\",\n\t\tkt: \"kotlin\",\n\t\tswift: \"swift\",\n\t\tc: \"c\",\n\t\th: \"c\",\n\t\tcpp: \"cpp\",\n\t\tcc: \"cpp\",\n\t\tcxx: \"cpp\",\n\t\thpp: \"cpp\",\n\t\tcs: \"csharp\",\n\t\tphp: \"php\",\n\t\tsh: \"bash\",\n\t\tbash: \"bash\",\n\t\tzsh: \"bash\",\n\t\tfish: \"fish\",\n\t\tps1: \"powershell\",\n\t\tsql: \"sql\",\n\t\thtml: \"html\",\n\t\thtm: \"html\",\n\t\tcss: \"css\",\n\t\tscss: \"scss\",\n\t\tsass: \"sass\",\n\t\tless: \"less\",\n\t\tjson: \"json\",\n\t\tyaml: \"yaml\",\n\t\tyml: \"yaml\",\n\t\ttoml: \"toml\",\n\t\txml: \"xml\",\n\t\tmd: \"markdown\",\n\t\tmarkdown: \"markdown\",\n\t\tdockerfile: \"dockerfile\",\n\t\tmakefile: \"makefile\",\n\t\tcmake: \"cmake\",\n\t\tlua: \"lua\",\n\t\tperl: \"perl\",\n\t\tr: \"r\",\n\t\tscala: \"scala\",\n\t\tclj: \"clojure\",\n\t\tex: \"elixir\",\n\t\texs: \"elixir\",\n\t\terl: \"erlang\",\n\t\ths: \"haskell\",\n\t\tml: \"ocaml\",\n\t\tvim: \"vim\",\n\t\tgraphql: \"graphql\",\n\t\tproto: \"protobuf\",\n\t\ttf: \"hcl\",\n\t\thcl: \"hcl\",\n\t};\n\n\treturn extToLang[ext];\n}\n\nexport function getMarkdownTheme(): MarkdownTheme {\n\treturn {\n\t\theading: (text: string) => theme.fg(\"mdHeading\", text),\n\t\tlink: (text: string) => theme.fg(\"mdLink\", text),\n\t\tlinkUrl: (text: string) => theme.fg(\"mdLinkUrl\", text),\n\t\tcode: (text: string) => theme.fg(\"mdCode\", text),\n\t\tcodeBlock: (text: string) => theme.fg(\"mdCodeBlock\", text),\n\t\tcodeBlockBorder: (text: string) => theme.fg(\"mdCodeBlockBorder\", text),\n\t\tquote: (text: string) => theme.fg(\"mdQuote\", text),\n\t\tquoteBorder: (text: string) => theme.fg(\"mdQuoteBorder\", text),\n\t\thr: (text: string) => theme.fg(\"mdHr\", text),\n\t\tlistBullet: (text: string) => theme.fg(\"mdListBullet\", text),\n\t\tbold: (text: string) => theme.bold(text),\n\t\titalic: (text: string) => theme.italic(text),\n\t\tunderline: (text: string) => theme.underline(text),\n\t\tstrikethrough: (text: string) => chalk.strikethrough(text),\n\t\thighlightCode: (code: string, lang?: string): string[] => {\n\t\t\t// Validate language before highlighting to avoid stderr spam from cli-highlight\n\t\t\tconst validLang = lang && supportsLanguage(lang) ? lang : undefined;\n\t\t\t// Skip highlighting when no valid language is specified. cli-highlight's\n\t\t\t// auto-detection is unreliable and can misidentify prose as AppleScript,\n\t\t\t// LiveCodeServer, etc., coloring random English words as keywords.\n\t\t\tif (!validLang) {\n\t\t\t\treturn code.split(\"\\n\").map((line) => theme.fg(\"mdCodeBlock\", line));\n\t\t\t}\n\t\t\tconst opts = {\n\t\t\t\tlanguage: validLang,\n\t\t\t\tignoreIllegals: true,\n\t\t\t\ttheme: getCliHighlightTheme(theme),\n\t\t\t};\n\t\t\ttry {\n\t\t\t\treturn highlight(code, opts).split(\"\\n\");\n\t\t\t} catch {\n\t\t\t\treturn code.split(\"\\n\").map((line) => theme.fg(\"mdCodeBlock\", line));\n\t\t\t}\n\t\t},\n\t};\n}\n\nexport function getSelectListTheme(): SelectListTheme {\n\treturn {\n\t\tselectedPrefix: (text: string) => theme.fg(\"accent\", text),\n\t\tselectedText: (text: string) => theme.fg(\"accent\", text),\n\t\tdescription: (text: string) => theme.fg(\"muted\", text),\n\t\tscrollInfo: (text: string) => theme.fg(\"muted\", text),\n\t\tnoMatch: (text: string) => theme.fg(\"muted\", text),\n\t};\n}\n\nexport function getEditorTheme(): EditorTheme {\n\treturn {\n\t\tborderColor: (text: string) => theme.fg(\"borderMuted\", text),\n\t\tselectList: getSelectListTheme(),\n\t};\n}\n\nexport function getSettingsListTheme(): import(\"@earendil-works/pi-tui\").SettingsListTheme {\n\treturn {\n\t\tlabel: (text: string, selected: boolean) => (selected ? theme.fg(\"accent\", text) : text),\n\t\tvalue: (text: string, selected: boolean) => (selected ? theme.fg(\"accent\", text) : theme.fg(\"muted\", text)),\n\t\tdescription: (text: string) => theme.fg(\"dim\", text),\n\t\tcursor: theme.fg(\"accent\", \"→ \"),\n\t\thint: (text: string) => theme.fg(\"dim\", text),\n\t};\n}\n"]}
1
+ {"version":3,"file":"tui-theme.js","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/tui-theme.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAK1C,IAAI,uBAA0C,CAAC;AAC/C,IAAI,uBAAsD,CAAC;AAE3D,SAAS,sBAAsB,CAAC,CAAQ;IACvC,OAAO;QACN,OAAO,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,eAAe,EAAE,CAAC,CAAC;QAChD,QAAQ,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC,CAAC;QAC9C,OAAO,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC,CAAC;QAC/C,MAAM,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC,CAAC;QAC9C,MA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UAAU,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC;QACrD,OAAO,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC;KAClD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,cAAc;IAC7B,OAAO;QACN,WAAW,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,aAAa,EAAE,IAAI,CAAC;QAC5D,UAAU,EAAE,kBAAkB,EAAE;KAChC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB;IACnC,OAAO;QACN,KAAK,EAAE,CAAC,IAAY,EAAE,QAAiB,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACxF,KAAK,EAAE,CAAC,IAAY,EAAE,QAAiB,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC3G,WAAW,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC;QACpD,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC;QAChC,IAAI,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC;KAC7C,CAAC;AACH,CAAC","sourcesContent":["import type { EditorTheme, MarkdownTheme, SelectListTheme } from \"@earendil-works/pi-tui\";\nimport chalk from \"chalk\";\nimport { highlight, supportsLanguage } from \"../../../utils/syntax-highlight.ts\";\nimport { theme } from \"./global-theme.ts\";\nimport type { Theme } from \"./theme-class.ts\";\n\ntype CliHighlightTheme = Record<string, (s: string) => string>;\n\nlet cachedHighlightThemeFor: Theme | undefined;\nlet cachedCliHighlightTheme: CliHighlightTheme | undefined;\n\nfunction buildCliHighlightTheme(t: Theme): CliHighlightTheme {\n\treturn {\n\t\tkeyword: (s: string) => t.fg(\"syntaxKeyword\", s),\n\t\tbuilt_in: (s: string) => t.fg(\"syntaxType\", s),\n\t\tliteral: (s: string) => t.fg(\"syntaxNumber\", s),\n\t\tnumber: (s: string) => t.fg(\"syntaxNumber\", s),\n\t\tregexp: (s: string) => t.fg(\"syntaxString\", s),\n\t\tstring: (s: string) => t.fg(\"syntaxString\", s),\n\t\tsubst: (s: string) => t.fg(\"text\", s),\n\t\tcomment: (s: string) => t.fg(\"syntaxComment\", s),\n\t\tdoctag: (s: string) => t.fg(\"syntaxComment\", s),\n\t\tmeta: (s: string) => t.fg(\"muted\", s),\n\t\tfunction: (s: string) => t.fg(\"syntaxFunction\", s),\n\t\ttitle: (s: string) => t.fg(\"syntaxFunction\", s),\n\t\tclass: (s: string) => t.fg(\"syntaxType\", s),\n\t\ttype: (s: string) => t.fg(\"syntaxType\", s),\n\t\ttag: (s: string) => t.fg(\"syntaxPunctuation\", s),\n\t\tname: (s: string) => t.fg(\"syntaxKeyword\", s),\n\t\tattr: (s: string) => t.fg(\"syntaxVariable\", s),\n\t\tvariable: (s: string) => t.fg(\"syntaxVariable\", s),\n\t\tparams: (s: string) => t.fg(\"syntaxVariable\", s),\n\t\toperator: (s: string) => t.fg(\"syntaxOperator\", s),\n\t\tpunctuation: (s: string) => t.fg(\"syntaxPunctuation\", s),\n\t\temphasis: (s: string) => t.italic(s),\n\t\tstrong: (s: string) => t.bold(s),\n\t\tlink: (s: string) => t.underline(s),\n\t\taddition: (s: string) => t.fg(\"toolDiffAdded\", s),\n\t\tdeletion: (s: string) => t.fg(\"toolDiffRemoved\", s),\n\t};\n}\n\nfunction getCliHighlightTheme(t: Theme): CliHighlightTheme {\n\tif (cachedHighlightThemeFor !== t || !cachedCliHighlightTheme) {\n\t\tcachedHighlightThemeFor = t;\n\t\tcachedCliHighlightTheme = buildCliHighlightTheme(t);\n\t}\n\treturn cachedCliHighlightTheme;\n}\n\n/**\n * Highlight code with syntax coloring based on file extension or language.\n * Returns array of highlighted lines.\n */\nexport function highlightCode(code: string, lang?: string): string[] {\n\t// Validate language before highlighting to avoid stderr spam from cli-highlight\n\tconst validLang = lang && supportsLanguage(lang) ? lang : undefined;\n\t// Skip highlighting when no valid language is specified. cli-highlight's\n\t// auto-detection is unreliable and can misidentify prose as AppleScript,\n\t// LiveCodeServer, etc., coloring random English words as keywords.\n\tif (!validLang) {\n\t\treturn code.split(\"\\n\").map((line) => theme.fg(\"mdCodeBlock\", line));\n\t}\n\tconst opts = {\n\t\tlanguage: validLang,\n\t\tignoreIllegals: true,\n\t\ttheme: getCliHighlightTheme(theme),\n\t};\n\ttry {\n\t\treturn highlight(code, opts).split(\"\\n\");\n\t} catch {\n\t\treturn code.split(\"\\n\");\n\t}\n}\n\n/**\n * Get language identifier from file path extension.\n */\nexport function getLanguageFromPath(filePath: string): string | undefined {\n\tconst ext = filePath.split(\".\").pop()?.toLowerCase();\n\tif (!ext) return undefined;\n\n\tconst extToLang: Record<string, string> = {\n\t\tts: \"typescript\",\n\t\ttsx: \"typescript\",\n\t\tjs: \"javascript\",\n\t\tjsx: \"javascript\",\n\t\tmjs: \"javascript\",\n\t\tcjs: \"javascript\",\n\t\tpy: \"python\",\n\t\trb: \"ruby\",\n\t\trs: \"rust\",\n\t\tgo: \"go\",\n\t\tjava: \"java\",\n\t\tkt: \"kotlin\",\n\t\tswift: \"swift\",\n\t\tc: \"c\",\n\t\th: \"c\",\n\t\tcpp: \"cpp\",\n\t\tcc: \"cpp\",\n\t\tcxx: \"cpp\",\n\t\thpp: \"cpp\",\n\t\tcs: \"csharp\",\n\t\tphp: \"php\",\n\t\tsh: \"bash\",\n\t\tbash: \"bash\",\n\t\tzsh: \"bash\",\n\t\tfish: \"fish\",\n\t\tps1: \"powershell\",\n\t\tsql: \"sql\",\n\t\thtml: \"html\",\n\t\thtm: \"html\",\n\t\tcss: \"css\",\n\t\tscss: \"scss\",\n\t\tsass: \"sass\",\n\t\tless: \"less\",\n\t\tjson: \"json\",\n\t\tyaml: \"yaml\",\n\t\tyml: \"yaml\",\n\t\ttoml: \"toml\",\n\t\txml: \"xml\",\n\t\tmd: \"markdown\",\n\t\tmarkdown: \"markdown\",\n\t\tdockerfile: \"dockerfile\",\n\t\tmakefile: \"makefile\",\n\t\tcmake: \"cmake\",\n\t\tlua: \"lua\",\n\t\tperl: \"perl\",\n\t\tr: \"r\",\n\t\tscala: \"scala\",\n\t\tclj: \"clojure\",\n\t\tex: \"elixir\",\n\t\texs: \"elixir\",\n\t\terl: \"erlang\",\n\t\ths: \"haskell\",\n\t\tml: \"ocaml\",\n\t\tvim: \"vim\",\n\t\tgraphql: \"graphql\",\n\t\tproto: \"protobuf\",\n\t\ttf: \"hcl\",\n\t\thcl: \"hcl\",\n\t};\n\n\treturn extToLang[ext];\n}\n\nexport function getMarkdownTheme(): MarkdownTheme {\n\treturn {\n\t\theading: (text: string) => theme.fg(\"mdHeading\", text),\n\t\tlink: (text: string) => theme.fg(\"mdLink\", text),\n\t\tlinkUrl: (text: string) => theme.fg(\"mdLinkUrl\", text),\n\t\tcode: (text: string) => theme.fg(\"mdCode\", text),\n\t\tcodeBlock: (text: string) => theme.fg(\"mdCodeBlock\", text),\n\t\tcodeBlockBorder: (text: string) => theme.fg(\"mdCodeBlockBorder\", text),\n\t\tquote: (text: string) => theme.fg(\"mdQuote\", text),\n\t\tquoteBorder: (text: string) => theme.fg(\"mdQuoteBorder\", text),\n\t\thr: (text: string) => theme.fg(\"mdHr\", text),\n\t\tlistBullet: (text: string) => theme.fg(\"mdListBullet\", text),\n\t\tbold: (text: string) => theme.bold(text),\n\t\titalic: (text: string) => theme.italic(text),\n\t\tunderline: (text: string) => theme.underline(text),\n\t\tstrikethrough: (text: string) => chalk.strikethrough(text),\n\t\thighlightCode: (code: string, lang?: string): string[] => {\n\t\t\t// Validate language before highlighting to avoid stderr spam from cli-highlight\n\t\t\tconst validLang = lang && supportsLanguage(lang) ? lang : undefined;\n\t\t\t// Skip highlighting when no valid language is specified. cli-highlight's\n\t\t\t// auto-detection is unreliable and can misidentify prose as AppleScript,\n\t\t\t// LiveCodeServer, etc., coloring random English words as keywords.\n\t\t\tif (!validLang) {\n\t\t\t\treturn code.split(\"\\n\").map((line) => theme.fg(\"mdCodeBlock\", line));\n\t\t\t}\n\t\t\tconst opts = {\n\t\t\t\tlanguage: validLang,\n\t\t\t\tignoreIllegals: true,\n\t\t\t\ttheme: getCliHighlightTheme(theme),\n\t\t\t};\n\t\t\ttry {\n\t\t\t\treturn highlight(code, opts).split(\"\\n\");\n\t\t\t} catch {\n\t\t\t\treturn code.split(\"\\n\").map((line) => theme.fg(\"mdCodeBlock\", line));\n\t\t\t}\n\t\t},\n\t};\n}\n\nexport function getSelectListTheme(): SelectListTheme {\n\treturn {\n\t\tselectedPrefix: (text: string) => theme.fg(\"accent\", text),\n\t\tselectedText: (text: string) => theme.fg(\"accent\", text),\n\t\tdescription: (text: string) => theme.fg(\"muted\", text),\n\t\tscrollInfo: (text: string) => theme.fg(\"muted\", text),\n\t\tnoMatch: (text: string) => theme.fg(\"muted\", text),\n\t};\n}\n\nexport function getEditorTheme(): EditorTheme {\n\treturn {\n\t\tborderColor: (text: string) => theme.fg(\"borderMuted\", text),\n\t\tselectList: getSelectListTheme(),\n\t};\n}\n\nexport function getSettingsListTheme(): import(\"@earendil-works/pi-tui\").SettingsListTheme {\n\treturn {\n\t\tlabel: (text: string, selected: boolean) => (selected ? theme.fg(\"accent\", text) : text),\n\t\tvalue: (text: string, selected: boolean) => (selected ? theme.fg(\"accent\", text) : theme.fg(\"muted\", text)),\n\t\tdescription: (text: string) => theme.fg(\"dim\", text),\n\t\tcursor: theme.fg(\"accent\", \"→ \"),\n\t\thint: (text: string) => theme.fg(\"dim\", text),\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"engine-args.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive-engine/engine-args.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAEpE,MAAM,WAAW,8BAA8B;IAC9C,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B;AAYD,wBAAgB,0BAA0B,CACzC,MAAM,EAAE,IAAI,EACZ,cAAc,EAAE,cAAc,EAC9B,SAAS,EAAE,8BAA8B,GACvC,MAAM,EAAE,CAmCV"}
1
+ {"version":3,"file":"engine-args.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive-engine/engine-args.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAEpE,MAAM,WAAW,8BAA8B;IAC9C,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B;AAYD,wBAAgB,0BAA0B,CACzC,MAAM,EAAE,IAAI,EACZ,cAAc,EAAE,cAAc,EAC9B,SAAS,EAAE,8BAA8B,GACvC,MAAM,EAAE,CAoCV"}
@@ -32,6 +32,7 @@ export function buildInteractiveEngineArgs(parsed, sessionManager, resources) {
32
32
  appendValue(args, "--no-builtin-tools", parsed.noBuiltinTools);
33
33
  appendValues(args, "--extension", resources.extensions);
34
34
  appendValue(args, "--no-extensions", parsed.noExtensions);
35
+ appendValue(args, "--no-mcp", parsed.noMcp);
35
36
  appendValues(args, "--skill", resources.skills);
36
37
  appendValue(args, "--no-skills", parsed.noSkills);
37
38
  appendValues(args, "--prompt-template", resources.promptTemplates);
@@ -1 +1 @@
1
- {"version":3,"file":"engine-args.js","sourceRoot":"","sources":["../../../src/modes/interactive-engine/engine-args.ts"],"names":[],"mappings":"AAUA,SAAS,WAAW,CAAC,IAAc,EAAE,IAAY,EAAE,KAA4C;IAC9F,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,KAAK;QAAE,OAAO;IACnD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChB,IAAI,KAAK,KAAK,IAAI;QAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,YAAY,CAAC,IAAc,EAAE,IAAY,EAAE,MAAqC;IACxF,KAAK,MAAM,KAAK,IAAI,MAAM,IAAI,EAAE;QAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,0BAA0B,CACzC,MAAY,EACZ,cAA8B,EAC9B,SAAyC;IAEzC,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,MAAM,WAAW,GAAG,cAAc,CAAC,cAAc,EAAE,CAAC;IACpD,IAAI,MAAM,CAAC,SAAS,IAAI,CAAC,WAAW;QAAE,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;;QAC3D,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IACzC,WAAW,CAAC,IAAI,EAAE,eAAe,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;IACtD,WAAW,CAAC,IAA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,EAAE,SAAS,CAAC,eAAe,CAAC,CAAC;IACnE,WAAW,CAAC,IAAI,EAAE,uBAAuB,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC;IACrE,YAAY,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAChD,WAAW,CAAC,IAAI,EAAE,aAAa,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IAClD,WAAW,CAAC,IAAI,EAAE,oBAAoB,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC;IAC/D,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAC/C,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAC/C,IAAI,MAAM,CAAC,oBAAoB,KAAK,SAAS,EAAE,CAAC;QAC/C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC;IACvE,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;QACjD,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;QACvB,IAAI,KAAK,KAAK,IAAI;YAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["import type { Args } from \"../../cli/args.ts\";\nimport type { SessionManager } from \"../../core/session-manager.ts\";\n\nexport interface InteractiveEngineResourcePaths {\n\textensions?: readonly string[];\n\tpromptTemplates?: readonly string[];\n\tskills?: readonly string[];\n\tthemes?: readonly string[];\n}\n\nfunction appendValue(args: string[], flag: string, value: boolean | number | string | undefined): void {\n\tif (value === undefined || value === false) return;\n\targs.push(flag);\n\tif (value !== true) args.push(String(value));\n}\n\nfunction appendValues(args: string[], flag: string, values: readonly string[] | undefined): void {\n\tfor (const value of values ?? []) args.push(flag, value);\n}\n\nexport function buildInteractiveEngineArgs(\n\tparsed: Args,\n\tsessionManager: SessionManager,\n\tresources: InteractiveEngineResourcePaths,\n): string[] {\n\tconst args: string[] = [];\n\tconst sessionFile = sessionManager.getSessionFile();\n\tif (parsed.noSession || !sessionFile) args.push(\"--no-session\");\n\telse args.push(\"--session\", sessionFile);\n\tappendValue(args, \"--session-dir\", parsed.sessionDir);\n\tappendValue(args, \"--provider\", parsed.provider);\n\tappendValue(args, \"--model\", parsed.model);\n\tappendValue(args, \"--thinking\", parsed.thinking);\n\tappendValue(args, \"--system-prompt\", parsed.systemPrompt);\n\tappendValues(args, \"--append-system-prompt\", parsed.appendSystemPrompt);\n\tif (parsed.models) appendValue(args, \"--models\", parsed.models.join(\",\"));\n\tif (parsed.tools) appendValue(args, \"--tools\", parsed.tools.join(\",\"));\n\tif (parsed.excludeTools) appendValue(args, \"--exclude-tools\", parsed.excludeTools.join(\",\"));\n\tappendValue(args, \"--no-tools\", parsed.noTools);\n\tappendValue(args, \"--no-builtin-tools\", parsed.noBuiltinTools);\n\tappendValues(args, \"--extension\", resources.extensions);\n\tappendValue(args, \"--no-extensions\", parsed.noExtensions);\n\tappendValues(args, \"--skill\", resources.skills);\n\tappendValue(args, \"--no-skills\", parsed.noSkills);\n\tappendValues(args, \"--prompt-template\", resources.promptTemplates);\n\tappendValue(args, \"--no-prompt-templates\", parsed.noPromptTemplates);\n\tappendValues(args, \"--theme\", resources.themes);\n\tappendValue(args, \"--no-themes\", parsed.noThemes);\n\tappendValue(args, \"--no-context-files\", parsed.noContextFiles);\n\tappendValue(args, \"--offline\", parsed.offline);\n\tappendValue(args, \"--verbose\", parsed.verbose);\n\tif (parsed.projectTrustOverride !== undefined) {\n\t\targs.push(parsed.projectTrustOverride ? \"--approve\" : \"--no-approve\");\n\t}\n\tfor (const [name, value] of parsed.unknownFlags) {\n\t\targs.push(`--${name}`);\n\t\tif (value !== true) args.push(String(value));\n\t}\n\treturn args;\n}\n"]}
1
+ {"version":3,"file":"engine-args.js","sourceRoot":"","sources":["../../../src/modes/interactive-engine/engine-args.ts"],"names":[],"mappings":"AAUA,SAAS,WAAW,CAAC,IAAc,EAAE,IAAY,EAAE,KAA4C;IAC9F,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,KAAK;QAAE,OAAO;IACnD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChB,IAAI,KAAK,KAAK,IAAI;QAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,YAAY,CAAC,IAAc,EAAE,IAAY,EAAE,MAAqC;IACxF,KAAK,MAAM,KAAK,IAAI,MAAM,IAAI,EAAE;QAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,0BAA0B,CACzC,MAAY,EACZ,cAA8B,EAC9B,SAAyC;IAEzC,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,MAAM,WAAW,GAAG,cAAc,CAAC,cAAc,EAAE,CAAC;IACpD,IAAI,MAAM,CAAC,SAAS,IAAI,CAAC,WAAW;QAAE,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;;QAC3D,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IACzC,WAAW,CAAC,IAAI,EAAE,eAAe,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;IACtD,WAAW,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IACjD,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3C,WAAW,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IACjD,WAAW,CAAC,IAAI,E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EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAChD,WAAW,CAAC,IAAI,EAAE,aAAa,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IAClD,WAAW,CAAC,IAAI,EAAE,oBAAoB,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC;IAC/D,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAC/C,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAC/C,IAAI,MAAM,CAAC,oBAAoB,KAAK,SAAS,EAAE,CAAC;QAC/C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC;IACvE,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;QACjD,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;QACvB,IAAI,KAAK,KAAK,IAAI;YAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["import type { Args } from \"../../cli/args.ts\";\nimport type { SessionManager } from \"../../core/session-manager.ts\";\n\nexport interface InteractiveEngineResourcePaths {\n\textensions?: readonly string[];\n\tpromptTemplates?: readonly string[];\n\tskills?: readonly string[];\n\tthemes?: readonly string[];\n}\n\nfunction appendValue(args: string[], flag: string, value: boolean | number | string | undefined): void {\n\tif (value === undefined || value === false) return;\n\targs.push(flag);\n\tif (value !== true) args.push(String(value));\n}\n\nfunction appendValues(args: string[], flag: string, values: readonly string[] | undefined): void {\n\tfor (const value of values ?? []) args.push(flag, value);\n}\n\nexport function buildInteractiveEngineArgs(\n\tparsed: Args,\n\tsessionManager: SessionManager,\n\tresources: InteractiveEngineResourcePaths,\n): string[] {\n\tconst args: string[] = [];\n\tconst sessionFile = sessionManager.getSessionFile();\n\tif (parsed.noSession || !sessionFile) args.push(\"--no-session\");\n\telse args.push(\"--session\", sessionFile);\n\tappendValue(args, \"--session-dir\", parsed.sessionDir);\n\tappendValue(args, \"--provider\", parsed.provider);\n\tappendValue(args, \"--model\", parsed.model);\n\tappendValue(args, \"--thinking\", parsed.thinking);\n\tappendValue(args, \"--system-prompt\", parsed.systemPrompt);\n\tappendValues(args, \"--append-system-prompt\", parsed.appendSystemPrompt);\n\tif (parsed.models) appendValue(args, \"--models\", parsed.models.join(\",\"));\n\tif (parsed.tools) appendValue(args, \"--tools\", parsed.tools.join(\",\"));\n\tif (parsed.excludeTools) appendValue(args, \"--exclude-tools\", parsed.excludeTools.join(\",\"));\n\tappendValue(args, \"--no-tools\", parsed.noTools);\n\tappendValue(args, \"--no-builtin-tools\", parsed.noBuiltinTools);\n\tappendValues(args, \"--extension\", resources.extensions);\n\tappendValue(args, \"--no-extensions\", parsed.noExtensions);\n\tappendValue(args, \"--no-mcp\", parsed.noMcp);\n\tappendValues(args, \"--skill\", resources.skills);\n\tappendValue(args, \"--no-skills\", parsed.noSkills);\n\tappendValues(args, \"--prompt-template\", resources.promptTemplates);\n\tappendValue(args, \"--no-prompt-templates\", parsed.noPromptTemplates);\n\tappendValues(args, \"--theme\", resources.themes);\n\tappendValue(args, \"--no-themes\", parsed.noThemes);\n\tappendValue(args, \"--no-context-files\", parsed.noContextFiles);\n\tappendValue(args, \"--offline\", parsed.offline);\n\tappendValue(args, \"--verbose\", parsed.verbose);\n\tif (parsed.projectTrustOverride !== undefined) {\n\t\targs.push(parsed.projectTrustOverride ? \"--approve\" : \"--no-approve\");\n\t}\n\tfor (const [name, value] of parsed.unknownFlags) {\n\t\targs.push(`--${name}`);\n\t\tif (value !== true) args.push(String(value));\n\t}\n\treturn args;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"syntax-highlight.d.ts","sourceRoot":"","sources":["../../src/utils/syntax-highlight.ts"],"names":[],"mappings":"AAqDA,wBAAgB,yBAAyB,IAAI,OAAO,CAAC,IAAI,CAAC,CAezD;AAED,MAAM,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;AAC1D,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC;AAEzE,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,cAAc,CAAC;CACvB;AAoED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,GAAE,cAAmB,GAAG,MAAM,CAoDtF;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM,CAQ9E;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEtD"}
1
+ {"version":3,"file":"syntax-highlight.d.ts","sourceRoot":"","sources":["../../src/utils/syntax-highlight.ts"],"names":[],"mappings":"AAqDA,wBAAgB,yBAAyB,IAAI,OAAO,CAAC,IAAI,CAAC,CAezD;AAED,MAAM,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;AAC1D,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC;AAEzE,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,cAAc,CAAC;CACvB;AAoED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,GAAE,cAAmB,GAAG,MAAM,CAyDtF;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM,CAQ9E;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEtD"}
@@ -125,7 +125,12 @@ export function renderHighlightedHtml(html, theme = {}) {
125
125
  return;
126
126
  }
127
127
  const formatter = getActiveFormatter(scopes, theme);
128
- output += formatter ? formatter(textBuffer) : textBuffer;
128
+ output += formatter
129
+ ? textBuffer
130
+ .split("\n")
131
+ .map((line) => (line ? formatter(line) : line))
132
+ .join("\n")
133
+ : textBuffer;
129
134
  textBuffer = "";
130
135
  };
131
136
  let index = 0;
@@ -1 +1 @@
1
- {"version":3,"file":"syntax-highlight.js","sourceRoot":"","sources":["../../src/utils/syntax-highlight.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,OAAO,IAAI,MAAM,0BAA0B,CAAC;AAC5C,OAAO,IAAI,MAAM,oCAAoC,CAAC;AACtD,OAAO,CAAC,MAAM,iCAAiC,CAAC;AAChD,OAAO,GAAG,MAAM,mCAAmC,CAAC;AACpD,OAAO,MAAM,MAAM,sCAAsC,CAAC;AAC1D,OAAO,IAAI,MAAM,oCAAoC,CAAC;AACtD,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAClD,OAAO,MAAM,MAAM,sCAAsC,CAAC;AAC1D,OAAO,IAAI,MAAM,oCAAoC,CAAC;AACtD,OAAO,UAAU,MAAM,0CAA0C,CAAC;AAClE,OAAO,MAAM,MAAM,sCAAsC,CAAC;AAC1D,OAAO,GAAG,MAAM,mCAAmC,CAAC;AACpD,OAAO,GAAG,MAAM,mCAAmC,CAAC;AACpD,OAAO,IAAI,MAAM,oCAAoC,CAAC;AACtD,OAAO,GAAG,MAAM,mCAAmC,CAAC;AACpD,OAAO,MAAM,MAAM,sCAAsC,CAAC;AAC1D,OAAO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OAAO,CAAC,MAAM,CAAC;gBACxB,SAAS;YACV,CAAC;QACF,CAAC;QAED,UAAU,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1B,KAAK,EAAE,CAAC;IACT,CAAC;IAED,SAAS,EAAE,CAAC;IACZ,OAAO,MAAM,CAAC;AACf,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,OAAO,GAAqB,EAAE;IACrE,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ;QAC5B,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;YACrB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,cAAc,EAAE,OAAO,CAAC,cAAc;SACtC,CAAC,CAAC,KAAK;QACT,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC;IAC1D,OAAO,qBAAqB,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC5C,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC;AAC7C,CAAC","sourcesContent":["/// <reference path=\"./highlight-js.d.ts\" />\nimport hljs from \"highlight.js/lib/core.js\";\nimport bash from \"highlight.js/lib/languages/bash.js\";\nimport c from \"highlight.js/lib/languages/c.js\";\nimport cpp from \"highlight.js/lib/languages/cpp.js\";\nimport csharp from \"highlight.js/lib/languages/csharp.js\";\nimport dart from \"highlight.js/lib/languages/dart.js\";\nimport go from \"highlight.js/lib/languages/go.js\";\nimport groovy from \"highlight.js/lib/languages/groovy.js\";\nimport java from \"highlight.js/lib/languages/java.js\";\nimport javascript from \"highlight.js/lib/languages/javascript.js\";\nimport kotlin from \"highlight.js/lib/languages/kotlin.js\";\nimport lua from \"highlight.js/lib/languages/lua.js\";\nimport nix from \"highlight.js/lib/languages/nix.js\";\nimport perl from \"highlight.js/lib/languages/perl.js\";\nimport php from \"highlight.js/lib/languages/php.js\";\nimport python from \"highlight.js/lib/languages/python.js\";\nimport ruby from \"highlight.js/lib/languages/ruby.js\";\nimport rust from \"highlight.js/lib/languages/rust.js\";\nimport scala from \"highlight.js/lib/languages/scala.js\";\nimport swift from \"highlight.js/lib/languages/swift.js\";\nimport typescript from \"highlight.js/lib/languages/typescript.js\";\nimport { decodeHtmlEntityAt } from \"./html.ts\";\n\nconst eagerLanguages = {\n\tpython,\n\tjava,\n\tgo,\n\tjavascript,\n\tcpp,\n\ttypescript,\n\tphp,\n\truby,\n\tc,\n\tcsharp,\n\tnix,\n\tbash,\n\trust,\n\tscala,\n\tkotlin,\n\tswift,\n\tdart,\n\tgroovy,\n\tperl,\n\tlua,\n};\n\nfor (const [name, language] of Object.entries(eagerLanguages)) {\n\thljs.registerLanguage(name, language);\n}\n\nlet allLanguagesPromise: Promise<void> | undefined;\n\nexport function loadAllHighlightLanguages(): Promise<void> {\n\tif (!allLanguagesPromise) {\n\t\tallLanguagesPromise = new Promise((resolve) => {\n\t\t\tsetImmediate(() => {\n\t\t\t\tvoid import(\"highlight.js/lib/index.js\").then(\n\t\t\t\t\t() => resolve(),\n\t\t\t\t\t() => {\n\t\t\t\t\t\t// Eager languages and plaintext fallback remain available.\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t});\n\t\t});\n\t}\n\treturn allLanguagesPromise;\n}\n\nexport type HighlightFormatter = (text: string) => string;\nexport type HighlightTheme = Partial<Record<string, HighlightFormatter>>;\n\nexport interface HighlightOptions {\n\tlanguage?: string;\n\tignoreIllegals?: boolean;\n\tlanguageSubset?: string[];\n\ttheme?: HighlightTheme;\n}\n\nconst SPAN_CLOSE = \"</span>\";\nconst HIGHLIGHT_CLASS_PREFIX = \"hljs-\";\n\nfunction getScopeFromSpanTag(tag: string): string | undefined {\n\tconst match = /\\sclass\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)')/.exec(tag);\n\tconst classValue = match?.[1] ?? match?.[2];\n\tif (!classValue) {\n\t\treturn undefined;\n\t}\n\n\tfor (const className of classValue.split(/\\s+/)) {\n\t\tif (className.startsWith(HIGHLIGHT_CLASS_PREFIX)) {\n\t\t\treturn className.slice(HIGHLIGHT_CLASS_PREFIX.length);\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction getScopeFormatter(scope: string, theme: HighlightTheme): HighlightFormatter | undefined {\n\tconst exact = theme[scope];\n\tif (exact) {\n\t\treturn exact;\n\t}\n\n\tconst dotIndex = scope.indexOf(\".\");\n\tif (dotIndex !== -1) {\n\t\tconst prefixFormatter = theme[scope.slice(0, dotIndex)];\n\t\tif (prefixFormatter) {\n\t\t\treturn prefixFormatter;\n\t\t}\n\t}\n\n\tconst dashIndex = scope.indexOf(\"-\");\n\tif (dashIndex !== -1) {\n\t\tconst prefixFormatter = theme[scope.slice(0, dashIndex)];\n\t\tif (prefixFormatter) {\n\t\t\treturn prefixFormatter;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction getActiveFormatter(scopes: Array<string | undefined>, theme: HighlightTheme): HighlightFormatter | undefined {\n\tfor (let i = scopes.length - 1; i >= 0; i--) {\n\t\tconst scope = scopes[i];\n\t\tif (!scope) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst formatter = getScopeFormatter(scope, theme);\n\t\tif (formatter) {\n\t\t\treturn formatter;\n\t\t}\n\t}\n\treturn theme.default;\n}\n\nfunction isSpanOpenTagStart(html: string, index: number): boolean {\n\tif (!html.startsWith(\"<span\", index)) {\n\t\treturn false;\n\t}\n\tconst nextChar = html[index + \"<span\".length];\n\treturn nextChar === \">\" || nextChar === \" \" || nextChar === \"\\t\" || nextChar === \"\\n\" || nextChar === \"\\r\";\n}\n\nexport function renderHighlightedHtml(html: string, theme: HighlightTheme = {}): string {\n\tlet output = \"\";\n\tlet textBuffer = \"\";\n\tconst scopes: Array<string | undefined> = [];\n\n\tconst flushText = () => {\n\t\tif (!textBuffer) {\n\t\t\treturn;\n\t\t}\n\t\tconst formatter = getActiveFormatter(scopes, theme);\n\t\toutput += formatter ? formatter(textBuffer) : textBuffer;\n\t\ttextBuffer = \"\";\n\t};\n\n\tlet index = 0;\n\twhile (index < html.length) {\n\t\tif (isSpanOpenTagStart(html, index)) {\n\t\t\tconst tagEndIndex = html.indexOf(\">\", index + 5);\n\t\t\tif (tagEndIndex !== -1) {\n\t\t\t\tflushText();\n\t\t\t\tconst tag = html.slice(index, tagEndIndex + 1);\n\t\t\t\tconst scope = getScopeFromSpanTag(tag);\n\t\t\t\tscopes.push(scope);\n\t\t\t\tindex = tagEndIndex + 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\tif (html.startsWith(SPAN_CLOSE, index)) {\n\t\t\tflushText();\n\t\t\tif (scopes.length > 0) {\n\t\t\t\tscopes.pop();\n\t\t\t}\n\t\t\tindex += SPAN_CLOSE.length;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (html[index] === \"&\") {\n\t\t\tconst decoded = decodeHtmlEntityAt(html, index);\n\t\t\tif (decoded) {\n\t\t\t\ttextBuffer += decoded.text;\n\t\t\t\tindex += decoded.length;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\ttextBuffer += html[index];\n\t\tindex++;\n\t}\n\n\tflushText();\n\treturn output;\n}\n\nexport function highlight(code: string, options: HighlightOptions = {}): string {\n\tconst html = options.language\n\t\t? hljs.highlight(code, {\n\t\t\t\tlanguage: options.language,\n\t\t\t\tignoreIllegals: options.ignoreIllegals,\n\t\t\t}).value\n\t\t: hljs.highlightAuto(code, options.languageSubset).value;\n\treturn renderHighlightedHtml(html, options.theme);\n}\n\nexport function supportsLanguage(name: string): boolean {\n\treturn hljs.getLanguage(name) !== undefined;\n}\n"]}
1
+ {"version":3,"file":"syntax-highlight.js","sourceRoot":"","sources":["../../src/utils/syntax-highlight.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,OAAO,IAAI,MAAM,0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C,CAAC,KAAK;QACT,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC;IAC1D,OAAO,qBAAqB,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC5C,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC;AAC7C,CAAC","sourcesContent":["/// <reference path=\"./highlight-js.d.ts\" />\nimport hljs from \"highlight.js/lib/core.js\";\nimport bash from \"highlight.js/lib/languages/bash.js\";\nimport c from \"highlight.js/lib/languages/c.js\";\nimport cpp from \"highlight.js/lib/languages/cpp.js\";\nimport csharp from \"highlight.js/lib/languages/csharp.js\";\nimport dart from \"highlight.js/lib/languages/dart.js\";\nimport go from \"highlight.js/lib/languages/go.js\";\nimport groovy from \"highlight.js/lib/languages/groovy.js\";\nimport java from \"highlight.js/lib/languages/java.js\";\nimport javascript from \"highlight.js/lib/languages/javascript.js\";\nimport kotlin from \"highlight.js/lib/languages/kotlin.js\";\nimport lua from \"highlight.js/lib/languages/lua.js\";\nimport nix from \"highlight.js/lib/languages/nix.js\";\nimport perl from \"highlight.js/lib/languages/perl.js\";\nimport php from \"highlight.js/lib/languages/php.js\";\nimport python from \"highlight.js/lib/languages/python.js\";\nimport ruby from \"highlight.js/lib/languages/ruby.js\";\nimport rust from \"highlight.js/lib/languages/rust.js\";\nimport scala from \"highlight.js/lib/languages/scala.js\";\nimport swift from \"highlight.js/lib/languages/swift.js\";\nimport typescript from \"highlight.js/lib/languages/typescript.js\";\nimport { decodeHtmlEntityAt } from \"./html.ts\";\n\nconst eagerLanguages = {\n\tpython,\n\tjava,\n\tgo,\n\tjavascript,\n\tcpp,\n\ttypescript,\n\tphp,\n\truby,\n\tc,\n\tcsharp,\n\tnix,\n\tbash,\n\trust,\n\tscala,\n\tkotlin,\n\tswift,\n\tdart,\n\tgroovy,\n\tperl,\n\tlua,\n};\n\nfor (const [name, language] of Object.entries(eagerLanguages)) {\n\thljs.registerLanguage(name, language);\n}\n\nlet allLanguagesPromise: Promise<void> | undefined;\n\nexport function loadAllHighlightLanguages(): Promise<void> {\n\tif (!allLanguagesPromise) {\n\t\tallLanguagesPromise = new Promise((resolve) => {\n\t\t\tsetImmediate(() => {\n\t\t\t\tvoid import(\"highlight.js/lib/index.js\").then(\n\t\t\t\t\t() => resolve(),\n\t\t\t\t\t() => {\n\t\t\t\t\t\t// Eager languages and plaintext fallback remain available.\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t});\n\t\t});\n\t}\n\treturn allLanguagesPromise;\n}\n\nexport type HighlightFormatter = (text: string) => string;\nexport type HighlightTheme = Partial<Record<string, HighlightFormatter>>;\n\nexport interface HighlightOptions {\n\tlanguage?: string;\n\tignoreIllegals?: boolean;\n\tlanguageSubset?: string[];\n\ttheme?: HighlightTheme;\n}\n\nconst SPAN_CLOSE = \"</span>\";\nconst HIGHLIGHT_CLASS_PREFIX = \"hljs-\";\n\nfunction getScopeFromSpanTag(tag: string): string | undefined {\n\tconst match = /\\sclass\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)')/.exec(tag);\n\tconst classValue = match?.[1] ?? match?.[2];\n\tif (!classValue) {\n\t\treturn undefined;\n\t}\n\n\tfor (const className of classValue.split(/\\s+/)) {\n\t\tif (className.startsWith(HIGHLIGHT_CLASS_PREFIX)) {\n\t\t\treturn className.slice(HIGHLIGHT_CLASS_PREFIX.length);\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction getScopeFormatter(scope: string, theme: HighlightTheme): HighlightFormatter | undefined {\n\tconst exact = theme[scope];\n\tif (exact) {\n\t\treturn exact;\n\t}\n\n\tconst dotIndex = scope.indexOf(\".\");\n\tif (dotIndex !== -1) {\n\t\tconst prefixFormatter = theme[scope.slice(0, dotIndex)];\n\t\tif (prefixFormatter) {\n\t\t\treturn prefixFormatter;\n\t\t}\n\t}\n\n\tconst dashIndex = scope.indexOf(\"-\");\n\tif (dashIndex !== -1) {\n\t\tconst prefixFormatter = theme[scope.slice(0, dashIndex)];\n\t\tif (prefixFormatter) {\n\t\t\treturn prefixFormatter;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction getActiveFormatter(scopes: Array<string | undefined>, theme: HighlightTheme): HighlightFormatter | undefined {\n\tfor (let i = scopes.length - 1; i >= 0; i--) {\n\t\tconst scope = scopes[i];\n\t\tif (!scope) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst formatter = getScopeFormatter(scope, theme);\n\t\tif (formatter) {\n\t\t\treturn formatter;\n\t\t}\n\t}\n\treturn theme.default;\n}\n\nfunction isSpanOpenTagStart(html: string, index: number): boolean {\n\tif (!html.startsWith(\"<span\", index)) {\n\t\treturn false;\n\t}\n\tconst nextChar = html[index + \"<span\".length];\n\treturn nextChar === \">\" || nextChar === \" \" || nextChar === \"\\t\" || nextChar === \"\\n\" || nextChar === \"\\r\";\n}\n\nexport function renderHighlightedHtml(html: string, theme: HighlightTheme = {}): string {\n\tlet output = \"\";\n\tlet textBuffer = \"\";\n\tconst scopes: Array<string | undefined> = [];\n\n\tconst flushText = () => {\n\t\tif (!textBuffer) {\n\t\t\treturn;\n\t\t}\n\t\tconst formatter = getActiveFormatter(scopes, theme);\n\t\toutput += formatter\n\t\t\t? textBuffer\n\t\t\t\t\t.split(\"\\n\")\n\t\t\t\t\t.map((line) => (line ? formatter(line) : line))\n\t\t\t\t\t.join(\"\\n\")\n\t\t\t: textBuffer;\n\t\ttextBuffer = \"\";\n\t};\n\n\tlet index = 0;\n\twhile (index < html.length) {\n\t\tif (isSpanOpenTagStart(html, index)) {\n\t\t\tconst tagEndIndex = html.indexOf(\">\", index + 5);\n\t\t\tif (tagEndIndex !== -1) {\n\t\t\t\tflushText();\n\t\t\t\tconst tag = html.slice(index, tagEndIndex + 1);\n\t\t\t\tconst scope = getScopeFromSpanTag(tag);\n\t\t\t\tscopes.push(scope);\n\t\t\t\tindex = tagEndIndex + 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\tif (html.startsWith(SPAN_CLOSE, index)) {\n\t\t\tflushText();\n\t\t\tif (scopes.length > 0) {\n\t\t\t\tscopes.pop();\n\t\t\t}\n\t\t\tindex += SPAN_CLOSE.length;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (html[index] === \"&\") {\n\t\t\tconst decoded = decodeHtmlEntityAt(html, index);\n\t\t\tif (decoded) {\n\t\t\t\ttextBuffer += decoded.text;\n\t\t\t\tindex += decoded.length;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\ttextBuffer += html[index];\n\t\tindex++;\n\t}\n\n\tflushText();\n\treturn output;\n}\n\nexport function highlight(code: string, options: HighlightOptions = {}): string {\n\tconst html = options.language\n\t\t? hljs.highlight(code, {\n\t\t\t\tlanguage: options.language,\n\t\t\t\tignoreIllegals: options.ignoreIllegals,\n\t\t\t}).value\n\t\t: hljs.highlightAuto(code, options.languageSubset).value;\n\treturn renderHighlightedHtml(html, options.theme);\n}\n\nexport function supportsLanguage(name: string): boolean {\n\treturn hljs.getLanguage(name) !== undefined;\n}\n"]}
package/docs/codemode.md CHANGED
@@ -47,13 +47,14 @@ What a call resolves to depends on the tool:
47
47
 
48
48
  - Tools with an output schema resolve to a structured value. `bash` resolves to `{ output, truncated, full_output_path?, exit_code, wall_time_seconds }`, also for non-zero exit codes. Its `output` is not limited to what the model sees directly: it holds up to 1 MiB, and longer output keeps its first and last 512 KiB around an omission marker, with `truncated` set and the full output in `full_output_path`.
49
49
  - MCP tools resolve to their `CallToolResult`, including `isError` and `structuredContent`.
50
- - Other tools, such as `read`, `edit`, and `write`, resolve to their text output.
50
+ - `read` resolves to the returned text (including path headers and line numbers unless `:raw` is used), or for an image to an image block `{ type: "image", data, mimeType, note }` that `image()` shows. `data` is the base64 image the model would see and `note` the accompanying text, such as resize hints.
51
+ - Other tools, such as `edit` and `write`, resolve to their text output.
51
52
 
52
53
  A call that fails, is blocked, or gets invalid arguments rejects with an `Error` that carries the tool's error text. Use `Promise.allSettled()` to keep the results of the calls that succeed. Reading a tool that does not exist throws an error that names the close matches, so `tools.Bash` suggests `tools.bash`; check for a tool with `"name" in tools`.
53
54
 
54
55
  The `codemode` description lists tools with their TypeScript declarations, grouped by namespace (for example one MCP server). Tools with `deferred` exposure are not listed, so the description stays the same while they register. Listed declarations share a budget of 3000 estimated tokens (`codemode.inlineBudget` in [settings](/settings#tools)). Scripts find the other tools with `searchTools()`, `describeTool()`, `describeNamespace()`, or by filtering `ALL_TOOLS`.
55
56
 
56
- While `codemode` is active, `codemode.mode` in [settings](/settings#tools) decides how the other tools are presented. With `on` (default) declared tools stay declared, and their descriptions say in one line how scripts call them and what the call resolves to. With `only` they are hidden from the model and listed in the `codemode` description instead, so the model calls them through scripts.
57
+ While `codemode` is active, `codemode.mode` in [settings](/settings#tools) decides how the other tools are presented. With `on` (default) declared tools stay declared, and their descriptions say in one line how scripts call them and what the call resolves to. With `only` they are hidden from the model and listed in the `codemode` description instead, so the model calls them through scripts. Tool declarations in the `codemode` description, `describeTool()`, and `ALL_TOOLS` carry the tools' prompt guidelines, since the system prompt rules only cover declared tools.
57
58
 
58
59
  ## Store values
59
60
 
@@ -819,6 +819,20 @@ if (pi.getFlag("plan")) {
819
819
  }
820
820
  ```
821
821
 
822
+ ### pi.getWorkflowHostModules()
823
+
824
+ Returns a promise for the running host's in-memory module namespaces. The workflows adapter uses this capability to avoid re-evaluating the host's package graphs for each workflow file.
825
+
826
+ The returned object has exactly these keys:
827
+
828
+ - `@bastani/atomic`
829
+ - `@bastani/pi-ai`, backed by the host's compatibility API
830
+ - `@bastani/pi-ai/providers/all`
831
+
832
+ These are shared host instances, not isolated copies. Workflow imports use the host's versions rather than project-local copies of these exact specifiers, preserving identity for exports such as `AuthStorage` and sharing module state. This also supports standalone-binary projects without those packages in `node_modules`. Other deep subpaths and third-party dependencies still resolve from disk. Workflow files and their relative imports are evaluated fresh on `/workflow reload`.
833
+
834
+ `getWorkflowHostModules()` is required on the current Atomic `ExtensionAPI`. It is optional on the workflows adapter's host interface so older or alternative hosts can omit it. Integrations that support those hosts should check for the method before calling it, for example `await pi.getWorkflowHostModules?.()`. Without it, the workflows adapter retains filesystem package resolution and needs resolvable packages for these imports.
835
+
822
836
  ### pi.exec(command, args, options?)
823
837
 
824
838
  Execute a shell command.