@timurproko/a1 0.1.8-dev.21b95d6 → 0.1.8-dev.226

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 (461) hide show
  1. package/README.md +107 -67
  2. package/bin/cli.js +28 -10
  3. package/bin/guardian.js +4 -1
  4. package/bin/module-identity.js +69 -35
  5. package/bin/pi-tui.d.ts +6 -0
  6. package/bin/pi-tui.js +28 -0
  7. package/bin/release-cleanup.js +8 -0
  8. package/bin/supervisor.js +1 -1
  9. package/bin/sync-pi-tui-proxy.js +97 -0
  10. package/bin/ui.js +25 -6
  11. package/bin/warmup.js +18 -0
  12. package/dist/cli/capabilities.d.ts +6 -0
  13. package/dist/{src/cli → cli}/capabilities.js +1 -1
  14. package/dist/{src/cli → cli}/dispatch.d.ts +6 -0
  15. package/dist/cli/dispatch.js +202 -0
  16. package/dist/{src/cli → cli}/packages.d.ts +10 -2
  17. package/dist/{src/cli → cli}/packages.js +24 -20
  18. package/dist/{src/cli → cli}/version-stats.d.ts +6 -0
  19. package/dist/cli/version-stats.js +112 -0
  20. package/dist/composition/agent-engine-bridge.d.ts +3 -0
  21. package/dist/composition/agent-engine-bridge.js +108 -0
  22. package/dist/composition/index.d.ts +3 -0
  23. package/dist/composition/index.js +3 -0
  24. package/dist/composition/owned-ui.d.ts +28 -0
  25. package/dist/composition/owned-ui.js +64 -0
  26. package/dist/composition/process.d.ts +16 -0
  27. package/dist/composition/process.js +45 -0
  28. package/dist/composition/settings-route-host.d.ts +8 -0
  29. package/dist/composition/settings-route-host.js +75 -0
  30. package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/capability-ports.d.ts +2 -2
  31. package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/domain-validation.js +22 -4
  32. package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/domain.d.ts +17 -0
  33. package/dist/{src/foundation/owned-ui-contracts → contracts/owned-ui}/model.d.ts +36 -0
  34. package/dist/{src/foundation/owned-ui-contracts → contracts/owned-ui}/validation.js +25 -0
  35. package/dist/{src/features → features}/launch/development-launch.js +11 -3
  36. package/dist/{src/features → features}/launch/index.d.ts +0 -1
  37. package/dist/{src/features → features}/launch/index.js +0 -1
  38. package/dist/{src/features → features}/launch/intent.d.ts +3 -2
  39. package/dist/features/launch/intent.js +3 -0
  40. package/dist/{src/features → features}/launch/prepare-launch.d.ts +0 -2
  41. package/dist/{src/features → features}/launch/prepare-launch.js +2 -9
  42. package/dist/{src/features → features}/launch/profile-paths.d.ts +1 -2
  43. package/dist/{src/features → features}/launch/profile-paths.js +2 -8
  44. package/dist/{src/features → features}/launch/runtime-selection.d.ts +2 -5
  45. package/dist/{src/features → features}/owned-ui/customization.d.ts +3 -1
  46. package/dist/{src/features → features}/owned-ui/customization.js +3 -1
  47. package/dist/{src/features → features}/owned-ui/diagnostics.d.ts +2 -1
  48. package/dist/{src/features → features}/owned-ui/diagnostics.js +1 -0
  49. package/dist/{src/features → features}/owned-ui/index.d.ts +1 -0
  50. package/dist/{src/features → features}/owned-ui/index.js +1 -0
  51. package/dist/features/owned-ui/project-trust-prompt.d.ts +25 -0
  52. package/dist/features/owned-ui/project-trust-prompt.js +149 -0
  53. package/dist/{src/features → features}/owned-ui/run.d.ts +2 -2
  54. package/dist/{src/features → features}/owned-ui/run.js +2 -0
  55. package/dist/{src/features → features}/owned-ui/settings-app.d.ts +3 -3
  56. package/dist/{src/features → features}/owned-ui/settings-app.js +103 -54
  57. package/dist/{src/features → features}/workspace/capabilities.d.ts +1 -1
  58. package/dist/{src/features → features}/workspace/reducer.d.ts +2 -1
  59. package/dist/{src/features → features}/workspace/reducer.js +2 -1
  60. package/dist/{src/features → features}/workspace/router.d.ts +2 -1
  61. package/dist/{src/features → features}/workspace/router.js +1 -0
  62. package/dist/{src/features → features}/workspace/store.d.ts +2 -1
  63. package/dist/{src/features → features}/workspace/store.js +1 -0
  64. package/dist/{src/foundation → foundation}/launch-guardian/main.js +10 -2
  65. package/dist/{src/foundation → foundation}/lifecycle/model.d.ts +1 -1
  66. package/dist/{src/foundation → foundation}/lifecycle/model.js +1 -1
  67. package/dist/foundation/lifecycle/paths.d.ts +28 -0
  68. package/dist/{src/foundation → foundation}/lifecycle/paths.js +21 -0
  69. package/dist/{src/foundation → foundation}/native-host-protocol/codec.d.ts +2 -0
  70. package/dist/{src/foundation → foundation}/native-host-protocol/codec.js +2 -0
  71. package/dist/{src/foundation → foundation}/native-host-protocol/messages.d.ts +1 -1
  72. package/dist/{src/foundation → foundation}/native-host-protocol/messages.js +1 -1
  73. package/dist/{src/foundation → foundation}/process-containment/linux-process-inspector.d.ts +1 -0
  74. package/dist/{src/foundation → foundation}/process-containment/linux-process-inspector.js +1 -0
  75. package/dist/{src/foundation → foundation}/process-containment/native-guardian-containment.d.ts +1 -0
  76. package/dist/{src/foundation → foundation}/process-containment/native-guardian-containment.js +1 -0
  77. package/dist/{src/foundation → foundation}/process-containment/windows-process-inspector.d.ts +1 -0
  78. package/dist/{src/foundation → foundation}/process-containment/windows-process-inspector.js +1 -0
  79. package/dist/{src/foundation → foundation}/protocol/client.d.ts +1 -0
  80. package/dist/{src/foundation → foundation}/protocol/client.js +1 -0
  81. package/dist/{src/foundation → foundation}/protocol/messages.d.ts +1 -0
  82. package/dist/{src/foundation → foundation}/protocol/messages.js +1 -0
  83. package/dist/{src/foundation → foundation}/release/bootstrap.d.ts +14 -4
  84. package/dist/{src/foundation → foundation}/release/bootstrap.js +66 -13
  85. package/dist/foundation/release/cohort-state.d.ts +156 -0
  86. package/dist/foundation/release/cohort-state.js +471 -0
  87. package/dist/foundation/release/dependency-layer.d.ts +78 -0
  88. package/dist/foundation/release/dependency-layer.js +487 -0
  89. package/dist/foundation/release/endpoints.d.ts +20 -0
  90. package/dist/foundation/release/endpoints.js +50 -0
  91. package/dist/{src/foundation → foundation}/release/index.d.ts +3 -0
  92. package/dist/{src/foundation → foundation}/release/index.js +3 -0
  93. package/dist/foundation/release/release-gc.d.ts +71 -0
  94. package/dist/foundation/release/release-gc.js +734 -0
  95. package/dist/{src/foundation → foundation}/release/release-store.d.ts +3 -1
  96. package/dist/{src/foundation → foundation}/release/release-store.js +60 -10
  97. package/dist/{src/foundation → foundation}/release/release.d.ts +4 -1
  98. package/dist/{src/foundation → foundation}/release/release.js +10 -3
  99. package/dist/{src/foundation → foundation}/release/update-transaction.d.ts +1 -0
  100. package/dist/{src/foundation → foundation}/release/update-transaction.js +1 -0
  101. package/dist/{src/foundation → foundation}/release/update.d.ts +19 -3
  102. package/dist/{src/foundation → foundation}/release/update.js +114 -54
  103. package/dist/foundation/release/warmup.d.ts +3 -0
  104. package/dist/foundation/release/warmup.js +35 -0
  105. package/dist/foundation/startup/index.d.ts +1 -0
  106. package/dist/foundation/startup/index.js +1 -0
  107. package/dist/foundation/startup/startup-runtime.d.ts +36 -0
  108. package/dist/foundation/startup/startup-runtime.js +140 -0
  109. package/dist/{src/foundation → foundation}/storage/control-store.d.ts +2 -1
  110. package/dist/{src/foundation → foundation}/storage/control-store.js +39 -4
  111. package/dist/{src/foundation → foundation}/structured-agent-runtime/backpressure.d.ts +2 -1
  112. package/dist/{src/foundation → foundation}/structured-agent-runtime/backpressure.js +2 -1
  113. package/dist/{src/foundation → foundation}/structured-agent-runtime/commands.d.ts +2 -1
  114. package/dist/{src/foundation → foundation}/structured-agent-runtime/commands.js +2 -1
  115. package/dist/{src/foundation → foundation}/structured-agent-runtime/handshake.d.ts +1 -1
  116. package/dist/{src/foundation → foundation}/structured-agent-runtime/handshake.js +1 -1
  117. package/dist/{src/foundation → foundation}/structured-agent-runtime/reconnection.d.ts +2 -1
  118. package/dist/{src/foundation → foundation}/structured-agent-runtime/reconnection.js +2 -1
  119. package/dist/{src/foundation → foundation}/structured-agent-runtime/state.d.ts +2 -1
  120. package/dist/{src/foundation → foundation}/structured-agent-runtime/state.js +2 -1
  121. package/dist/foundation/supervision/index.d.ts +3 -0
  122. package/dist/foundation/supervision/index.js +3 -0
  123. package/dist/{src/foundation → foundation}/supervision/main.js +11 -5
  124. package/dist/foundation/supervision/paths.d.ts +1 -0
  125. package/dist/foundation/supervision/paths.js +1 -0
  126. package/dist/{src/foundation → foundation}/supervision/server.d.ts +19 -1
  127. package/dist/{src/foundation → foundation}/supervision/server.js +51 -2
  128. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/components.d.ts +1 -1
  129. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/conformance.d.ts +1 -0
  130. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/conformance.js +3 -2
  131. package/dist/integrations/pi/components/owned-editor-ux.d.ts +55 -0
  132. package/dist/integrations/pi/components/owned-editor-ux.js +778 -0
  133. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-components.d.ts +1 -0
  134. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-components.js +1 -0
  135. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-editor-autocomplete.js +54 -6
  136. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-extension-ui.d.ts +1 -1
  137. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-footer-status.d.ts +3 -3
  138. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-footer-status.js +32 -17
  139. package/dist/integrations/pi/components/shell-presenters-info.d.ts +36 -0
  140. package/dist/integrations/pi/components/shell-presenters-info.js +78 -0
  141. package/dist/integrations/pi/components/shell-presenters-transcript.d.ts +25 -0
  142. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-presenters-transcript.js +92 -131
  143. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-selectors-dialogs.d.ts +1 -1
  144. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-shared-facade.d.ts +52 -8
  145. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-shared-facade.js +4 -2
  146. package/dist/integrations/pi/components/submitted-prompt-adapter.d.ts +13 -0
  147. package/dist/integrations/pi/components/submitted-prompt-adapter.js +27 -0
  148. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/adjacent/core/keybindings.d.ts +10 -2
  149. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/adjacent/core/keybindings.js +36 -3
  150. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/session-footer.d.ts +1 -1
  151. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/adapter.d.ts +22 -4
  152. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/adapter.js +289 -68
  153. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/conformance.d.ts +2 -0
  154. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/conformance.js +4 -2
  155. package/dist/integrations/pi/engine/http-dispatcher.d.ts +4 -0
  156. package/dist/integrations/pi/engine/http-dispatcher.js +25 -0
  157. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/index.d.ts +3 -0
  158. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/index.js +3 -0
  159. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/model-auth-integration.d.ts +2 -1
  160. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/model-auth-integration.js +1 -0
  161. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/package-integration.d.ts +1 -1
  162. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/package-integration.js +2 -2
  163. package/dist/integrations/pi/engine/project-trust-preflight.d.ts +22 -0
  164. package/dist/integrations/pi/engine/project-trust-preflight.js +50 -0
  165. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/resource-extension-integration.d.ts +2 -1
  166. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/resource-extension-integration.js +1 -0
  167. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/runtime-integration.d.ts +16 -1
  168. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/runtime-integration.js +39 -4
  169. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/session-integration.d.ts +4 -2
  170. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/session-integration.js +19 -4
  171. package/dist/integrations/pi/engine/settings-effects.d.ts +66 -0
  172. package/dist/integrations/pi/engine/settings-effects.js +249 -0
  173. package/dist/integrations/pi/engine/settings-integration.d.ts +43 -0
  174. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/settings-integration.js +102 -108
  175. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/workflow-controllers.d.ts +3 -2
  176. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/workflow-controllers.js +1 -0
  177. package/dist/integrations/pi/session-ui/clipboard-image.d.ts +11 -0
  178. package/dist/integrations/pi/session-ui/clipboard-image.js +29 -0
  179. package/dist/{src/foundation/pi-owned-ui-integration → integrations/pi/session-ui}/index.d.ts +1 -0
  180. package/dist/{src/foundation/pi-owned-ui-integration → integrations/pi/session-ui}/index.js +1 -0
  181. package/dist/integrations/pi/session-ui/prompt-chips.d.ts +23 -0
  182. package/dist/integrations/pi/session-ui/prompt-chips.js +246 -0
  183. package/dist/integrations/pi/session-ui/route-host.d.ts +5 -0
  184. package/dist/integrations/pi/session-ui/session-shell-root.d.ts +137 -0
  185. package/dist/integrations/pi/session-ui/session-shell-root.js +1106 -0
  186. package/dist/integrations/pi/session-ui/session-shell.d.ts +55 -0
  187. package/dist/{src/foundation/pi-owned-ui-integration → integrations/pi/session-ui}/session-shell.js +415 -775
  188. package/dist/integrations/pi/session-ui/session-viewport-controller.d.ts +44 -0
  189. package/dist/integrations/pi/session-ui/session-viewport-controller.js +434 -0
  190. package/dist/integrations/pi/session-ui/stream-presentation-coalescer.d.ts +29 -0
  191. package/dist/integrations/pi/session-ui/stream-presentation-coalescer.js +79 -0
  192. package/dist/integrations/pi/session-ui/system-clipboard.d.ts +20 -0
  193. package/dist/integrations/pi/session-ui/system-clipboard.js +130 -0
  194. package/dist/{src/foundation/pi-tui-runtime-adapter → integrations/pi/tui-runtime}/adapter.d.ts +8 -1
  195. package/dist/{src/foundation/pi-tui-runtime-adapter → integrations/pi/tui-runtime}/adapter.js +216 -9
  196. package/dist/{src/foundation/pi-tui-runtime-adapter → integrations/pi/tui-runtime}/contracts.d.ts +29 -6
  197. package/dist/integrations/pi/tui-runtime/damage-aware-terminal.d.ts +63 -0
  198. package/dist/integrations/pi/tui-runtime/damage-aware-terminal.js +240 -0
  199. package/dist/{src/foundation/pi-tui-runtime-adapter → integrations/pi/tui-runtime}/index.d.ts +2 -0
  200. package/dist/{src/foundation/pi-tui-runtime-adapter → integrations/pi/tui-runtime}/index.js +2 -0
  201. package/dist/integrations/pi/tui-runtime/input-presentation-coordinator.d.ts +39 -0
  202. package/dist/integrations/pi/tui-runtime/input-presentation-coordinator.js +139 -0
  203. package/dist/{src/foundation/pi-tui-runtime-adapter → integrations/pi/tui-runtime}/presentation-adapter.d.ts +1 -1
  204. package/dist/native/darwin-arm64/manifest.json +1 -1
  205. package/dist/native/linux-x64/manifest.json +3 -3
  206. package/dist/native/linux-x64/process-guardian +0 -0
  207. package/dist/native/win32-x64/manifest.json +3 -3
  208. package/dist/native/win32-x64/process-guardian.exe +0 -0
  209. package/dist/{src/product-identity.d.ts → product-identity.d.ts} +3 -3
  210. package/dist/{src/product-identity.js → product-identity.js} +7 -5
  211. package/dist/{src/product-identity.json → product-identity.json} +11 -6
  212. package/dist/runtime-payload-inventory.json +122328 -0
  213. package/dist/{src/foundation/ui-apps → ui/apps}/contracts.d.ts +23 -1
  214. package/dist/{src/foundation/ui-apps → ui/apps}/host.d.ts +1 -1
  215. package/dist/{src/foundation/ui-apps → ui/apps}/host.js +14 -10
  216. package/dist/{src/foundation/ui-apps → ui/apps}/registry.d.ts +1 -0
  217. package/dist/{src/foundation/ui-apps → ui/apps}/registry.js +1 -0
  218. package/dist/{src/foundation/ui-components → ui/components}/dialog-panel.js +5 -3
  219. package/dist/{src/foundation/ui-components → ui/components}/frame.d.ts +1 -0
  220. package/dist/{src/foundation/ui-components → ui/components}/frame.js +1 -0
  221. package/dist/{src/foundation/ui-components → ui/components}/index.d.ts +4 -0
  222. package/dist/{src/foundation/ui-components → ui/components}/index.js +4 -0
  223. package/dist/{src/foundation/ui-components → ui/components}/line-input.d.ts +1 -6
  224. package/dist/{src/foundation/ui-components → ui/components}/line-input.js +4 -9
  225. package/dist/{src/foundation/ui-components → ui/components}/list-view.d.ts +0 -6
  226. package/dist/{src/foundation/ui-components → ui/components}/list-view.js +14 -7
  227. package/dist/{src/foundation/ui-components → ui/components}/mouse.d.ts +10 -0
  228. package/dist/{src/foundation/ui-components → ui/components}/mouse.js +23 -0
  229. package/dist/ui/components/progress-status.d.ts +2 -0
  230. package/dist/ui/components/progress-status.js +4 -0
  231. package/dist/ui/components/prompt-row.d.ts +14 -0
  232. package/dist/ui/components/prompt-row.js +20 -0
  233. package/dist/{src/foundation/ui-components → ui/components}/scrollbar.d.ts +26 -0
  234. package/dist/{src/foundation/ui-components → ui/components}/scrollbar.js +35 -0
  235. package/dist/{src/foundation/ui-components → ui/components}/shortcuts.d.ts +1 -0
  236. package/dist/{src/foundation/ui-components → ui/components}/shortcuts.js +1 -0
  237. package/dist/ui/components/spans.d.ts +25 -0
  238. package/dist/ui/components/spans.js +257 -0
  239. package/dist/ui/components/submitted-prompt.d.ts +23 -0
  240. package/dist/ui/components/submitted-prompt.js +50 -0
  241. package/dist/{src/foundation/ui-components → ui/components}/surface.d.ts +0 -5
  242. package/dist/{src/foundation/ui-components → ui/components}/surface.js +1 -5
  243. package/dist/ui/components/text-selection.d.ts +62 -0
  244. package/dist/ui/components/text-selection.js +235 -0
  245. package/dist/{src/foundation/ui-components → ui/components}/text.d.ts +14 -0
  246. package/dist/{src/foundation/ui-components → ui/components}/text.js +66 -4
  247. package/dist/ui/components/transcript-viewport.d.ts +146 -0
  248. package/dist/ui/components/transcript-viewport.js +629 -0
  249. package/dist/{src/foundation/owned-ui-settings → ui/settings}/declarations.d.ts +8 -1
  250. package/dist/{src/foundation/owned-ui-settings → ui/settings}/declarations.js +33 -5
  251. package/dist/{src/foundation/owned-ui-settings → ui/settings}/migrations.d.ts +1 -1
  252. package/dist/{src/foundation/owned-ui-settings → ui/settings}/migrations.js +21 -2
  253. package/dist/{src/foundation/owned-ui-settings → ui/settings}/sections.d.ts +6 -19
  254. package/dist/{src/foundation/owned-ui-settings → ui/settings}/sections.js +32 -23
  255. package/dist/{src/foundation/owned-ui-settings → ui/settings}/session.d.ts +9 -17
  256. package/dist/{src/foundation/owned-ui-settings → ui/settings}/session.js +65 -55
  257. package/dist/{src/foundation/owned-ui-settings → ui/settings}/store.d.ts +1 -0
  258. package/dist/{src/foundation/owned-ui-settings → ui/settings}/store.js +2 -1
  259. package/docs/architecture/boundaries.md +9 -9
  260. package/docs/architecture/code-documentation.md +77 -0
  261. package/docs/architecture/project-structure.md +67 -30
  262. package/docs/architecture/resource-and-data-policy.md +1 -1
  263. package/docs/architecture/toolchain.md +10 -10
  264. package/docs/architecture/ui-reference-provenance.md +34 -5
  265. package/docs/ci-release-runbook.md +186 -79
  266. package/docs/features/launch-profiles.md +10 -19
  267. package/docs/manual-launch-instance-acceptance.md +12 -35
  268. package/docs/manual-owned-ui-checkpoint.md +78 -0
  269. package/docs/manual-pi-boundary-candidate.md +4 -5
  270. package/docs/manual-terminal-colour-check.md +4 -3
  271. package/docs/repository-governance-live-acceptance.md +77 -0
  272. package/package.json +37 -27
  273. package/dist/src/cli/capabilities.d.ts +0 -15
  274. package/dist/src/cli/dispatch.js +0 -177
  275. package/dist/src/cli/version-stats.js +0 -72
  276. package/dist/src/composition/index.d.ts +0 -48
  277. package/dist/src/composition/index.js +0 -258
  278. package/dist/src/features/launch/intent.js +0 -4
  279. package/dist/src/features/launch/profiles.d.ts +0 -12
  280. package/dist/src/features/launch/profiles.js +0 -26
  281. package/dist/src/foundation/lifecycle/paths.d.ts +0 -10
  282. package/dist/src/foundation/pi-component-adapter/shell-presenters-transcript.d.ts +0 -57
  283. package/dist/src/foundation/pi-engine-adapter/settings-integration.d.ts +0 -55
  284. package/dist/src/foundation/pi-owned-ui-integration/route-host.d.ts +0 -29
  285. package/dist/src/foundation/pi-owned-ui-integration/session-shell.d.ts +0 -112
  286. package/dist/src/foundation/release/cohort-state.d.ts +0 -70
  287. package/dist/src/foundation/release/cohort-state.js +0 -202
  288. package/dist/src/foundation/release/release-gc.d.ts +0 -5
  289. package/dist/src/foundation/release/release-gc.js +0 -16
  290. package/dist/src/foundation/supervision/index.d.ts +0 -3
  291. package/dist/src/foundation/supervision/index.js +0 -3
  292. package/dist/src/foundation/supervision/paths.d.ts +0 -1
  293. package/dist/src/foundation/supervision/paths.js +0 -1
  294. package/dist/src/foundation/ui-components/spans.d.ts +0 -7
  295. package/dist/src/foundation/ui-components/spans.js +0 -59
  296. package/docs/manual-transparent-checkpoint.md +0 -53
  297. /package/dist/{src/cli → cli}/index.d.ts +0 -0
  298. /package/dist/{src/cli → cli}/index.js +0 -0
  299. /package/dist/{src/cli → cli}/version.d.ts +0 -0
  300. /package/dist/{src/cli → cli}/version.js +0 -0
  301. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/capability-ports.js +0 -0
  302. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/domain-validation.d.ts +0 -0
  303. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/domain.js +0 -0
  304. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/index.d.ts +0 -0
  305. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/index.js +0 -0
  306. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/model.d.ts +0 -0
  307. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/model.js +0 -0
  308. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/package-ports.d.ts +0 -0
  309. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/package-ports.js +0 -0
  310. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/ports.d.ts +0 -0
  311. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/ports.js +0 -0
  312. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/serialization.d.ts +0 -0
  313. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/serialization.js +0 -0
  314. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/validation.d.ts +0 -0
  315. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/validation.js +0 -0
  316. /package/dist/{src/foundation/owned-ui-contracts → contracts/owned-ui}/extension-ui.d.ts +0 -0
  317. /package/dist/{src/foundation/owned-ui-contracts → contracts/owned-ui}/extension-ui.js +0 -0
  318. /package/dist/{src/foundation/owned-ui-contracts → contracts/owned-ui}/index.d.ts +0 -0
  319. /package/dist/{src/foundation/owned-ui-contracts → contracts/owned-ui}/index.js +0 -0
  320. /package/dist/{src/foundation/owned-ui-contracts → contracts/owned-ui}/model.js +0 -0
  321. /package/dist/{src/foundation/owned-ui-contracts → contracts/owned-ui}/validation.d.ts +0 -0
  322. /package/dist/{src/foundation/presentation-contracts → contracts/presentation}/index.d.ts +0 -0
  323. /package/dist/{src/foundation/presentation-contracts → contracts/presentation}/index.js +0 -0
  324. /package/dist/{src/foundation/workspace-contracts → contracts/workspace}/index.d.ts +0 -0
  325. /package/dist/{src/foundation/workspace-contracts → contracts/workspace}/index.js +0 -0
  326. /package/dist/{src/foundation/workspace-contracts → contracts/workspace}/model.d.ts +0 -0
  327. /package/dist/{src/foundation/workspace-contracts → contracts/workspace}/model.js +0 -0
  328. /package/dist/{src/foundation/workspace-contracts → contracts/workspace}/validation.d.ts +0 -0
  329. /package/dist/{src/foundation/workspace-contracts → contracts/workspace}/validation.js +0 -0
  330. /package/dist/{src/features → features}/launch/development-launch.d.ts +0 -0
  331. /package/dist/{src/features → features}/launch/initialize-profile.d.ts +0 -0
  332. /package/dist/{src/features → features}/launch/initialize-profile.js +0 -0
  333. /package/dist/{src/features → features}/launch/runtime-selection.js +0 -0
  334. /package/dist/{src/features → features}/workspace/capabilities.js +0 -0
  335. /package/dist/{src/features → features}/workspace/index.d.ts +0 -0
  336. /package/dist/{src/features → features}/workspace/index.js +0 -0
  337. /package/dist/{src/features → features}/workspace/presentation.d.ts +0 -0
  338. /package/dist/{src/features → features}/workspace/presentation.js +0 -0
  339. /package/dist/{src/features → features}/workspace/reconciliation.d.ts +0 -0
  340. /package/dist/{src/features → features}/workspace/reconciliation.js +0 -0
  341. /package/dist/{src/foundation → foundation}/launch-guardian/index.d.ts +0 -0
  342. /package/dist/{src/foundation → foundation}/launch-guardian/index.js +0 -0
  343. /package/dist/{src/foundation → foundation}/launch-guardian/main.d.ts +0 -0
  344. /package/dist/{src/foundation → foundation}/lifecycle/commands.d.ts +0 -0
  345. /package/dist/{src/foundation → foundation}/lifecycle/commands.js +0 -0
  346. /package/dist/{src/foundation → foundation}/lifecycle/index.d.ts +0 -0
  347. /package/dist/{src/foundation → foundation}/lifecycle/index.js +0 -0
  348. /package/dist/{src/foundation → foundation}/lifecycle/launch-instance.d.ts +0 -0
  349. /package/dist/{src/foundation → foundation}/lifecycle/launch-instance.js +0 -0
  350. /package/dist/{src/foundation → foundation}/native-host-protocol/evidence.d.ts +0 -0
  351. /package/dist/{src/foundation → foundation}/native-host-protocol/evidence.js +0 -0
  352. /package/dist/{src/foundation → foundation}/native-host-protocol/index.d.ts +0 -0
  353. /package/dist/{src/foundation → foundation}/native-host-protocol/index.js +0 -0
  354. /package/dist/{src/foundation → foundation}/native-host-protocol/proof-gate.d.ts +0 -0
  355. /package/dist/{src/foundation → foundation}/native-host-protocol/proof-gate.js +0 -0
  356. /package/dist/{src/foundation → foundation}/process-containment/artifact.d.ts +0 -0
  357. /package/dist/{src/foundation → foundation}/process-containment/artifact.js +0 -0
  358. /package/dist/{src/foundation → foundation}/process-containment/contracts.d.ts +0 -0
  359. /package/dist/{src/foundation → foundation}/process-containment/contracts.js +0 -0
  360. /package/dist/{src/foundation → foundation}/process-containment/index.d.ts +0 -0
  361. /package/dist/{src/foundation → foundation}/process-containment/index.js +0 -0
  362. /package/dist/{src/foundation → foundation}/protocol/index.d.ts +0 -0
  363. /package/dist/{src/foundation → foundation}/protocol/index.js +0 -0
  364. /package/dist/{src/foundation → foundation}/release/cohort-selection.d.ts +0 -0
  365. /package/dist/{src/foundation → foundation}/release/cohort-selection.js +0 -0
  366. /package/dist/{src/foundation → foundation}/release/concurrency.d.ts +0 -0
  367. /package/dist/{src/foundation → foundation}/release/concurrency.js +0 -0
  368. /package/dist/{src/foundation → foundation}/release/process-cleanup.d.ts +0 -0
  369. /package/dist/{src/foundation → foundation}/release/process-cleanup.js +0 -0
  370. /package/dist/{src/foundation → foundation}/release/stable-release.d.ts +0 -0
  371. /package/dist/{src/foundation → foundation}/release/stable-release.js +0 -0
  372. /package/dist/{src/foundation → foundation}/storage/index.d.ts +0 -0
  373. /package/dist/{src/foundation → foundation}/storage/index.js +0 -0
  374. /package/dist/{src/foundation → foundation}/structured-agent-runtime/index.d.ts +0 -0
  375. /package/dist/{src/foundation → foundation}/structured-agent-runtime/index.js +0 -0
  376. /package/dist/{src/foundation → foundation}/supervision/main.d.ts +0 -0
  377. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/components.js +0 -0
  378. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/index.d.ts +0 -0
  379. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/index.js +0 -0
  380. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/resources/builtin-themes.d.ts +0 -0
  381. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/resources/builtin-themes.js +0 -0
  382. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-editor-autocomplete.d.ts +0 -0
  383. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-extension-ui.js +0 -0
  384. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-selectors-dialogs.js +0 -0
  385. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/theme.d.ts +0 -0
  386. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/theme.js +0 -0
  387. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/countdown-timer.d.ts +0 -0
  388. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/countdown-timer.js +0 -0
  389. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/custom-entry.d.ts +0 -0
  390. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/custom-entry.js +0 -0
  391. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/daxnuts.d.ts +0 -0
  392. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/daxnuts.js +0 -0
  393. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/earendil-announcement.d.ts +0 -0
  394. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/earendil-announcement.js +0 -0
  395. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/extension-editor.d.ts +0 -0
  396. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/extension-editor.js +0 -0
  397. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/first-time-setup.d.ts +0 -0
  398. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/first-time-setup.js +0 -0
  399. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/markdown-transform.d.ts +0 -0
  400. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/markdown-transform.js +0 -0
  401. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/mermaid.d.ts +0 -0
  402. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/mermaid.js +0 -0
  403. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/owned-editor.d.ts +0 -0
  404. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/owned-editor.js +0 -0
  405. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/scoped-models-selector.d.ts +0 -0
  406. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/scoped-models-selector.js +0 -0
  407. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/session-footer.js +0 -0
  408. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/session-selector-search.d.ts +0 -0
  409. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/session-selector-search.js +0 -0
  410. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/session-selector.d.ts +0 -0
  411. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/session-selector.js +0 -0
  412. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/skill-invocation-message.d.ts +0 -0
  413. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/skill-invocation-message.js +0 -0
  414. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/status-indicator.d.ts +0 -0
  415. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/status-indicator.js +0 -0
  416. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/tree-selector.d.ts +0 -0
  417. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/tree-selector.js +0 -0
  418. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/trust-selector.d.ts +0 -0
  419. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/trust-selector.js +0 -0
  420. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/external-editor.d.ts +0 -0
  421. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/external-editor.js +0 -0
  422. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/model-search.d.ts +0 -0
  423. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/model-search.js +0 -0
  424. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/theme/theme-controller.d.ts +0 -0
  425. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/theme/theme-controller.js +0 -0
  426. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/theme/theme.d.ts +0 -0
  427. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/theme/theme.js +0 -0
  428. /package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/pi-settings-metadata.json +0 -0
  429. /package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/public-main-entry.d.ts +0 -0
  430. /package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/public-main-entry.js +0 -0
  431. /package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/workflows.d.ts +0 -0
  432. /package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/workflows.js +0 -0
  433. /package/dist/{src/foundation/pi-owned-ui-integration → integrations/pi/session-ui}/route-host.js +0 -0
  434. /package/dist/{src/foundation/pi-tui-runtime-adapter → integrations/pi/tui-runtime}/conformance.d.ts +0 -0
  435. /package/dist/{src/foundation/pi-tui-runtime-adapter → integrations/pi/tui-runtime}/conformance.js +0 -0
  436. /package/dist/{src/foundation/pi-tui-runtime-adapter → integrations/pi/tui-runtime}/contracts.js +0 -0
  437. /package/dist/{src/foundation/pi-tui-runtime-adapter → integrations/pi/tui-runtime}/presentation-adapter.js +0 -0
  438. /package/dist/{src/foundation/ui-apps → ui/apps}/contracts.js +0 -0
  439. /package/dist/{src/foundation/ui-apps → ui/apps}/index.d.ts +0 -0
  440. /package/dist/{src/foundation/ui-apps → ui/apps}/index.js +0 -0
  441. /package/dist/{src/foundation/ui-components → ui/components}/dialog-panel.d.ts +0 -0
  442. /package/dist/{src/foundation/ui-components → ui/components}/label.d.ts +0 -0
  443. /package/dist/{src/foundation/ui-components → ui/components}/label.js +0 -0
  444. /package/dist/{src/foundation/ui-components → ui/components}/list-block.d.ts +0 -0
  445. /package/dist/{src/foundation/ui-components → ui/components}/list-block.js +0 -0
  446. /package/dist/{src/foundation/ui-components → ui/components}/pane.d.ts +0 -0
  447. /package/dist/{src/foundation/ui-components → ui/components}/pane.js +0 -0
  448. /package/dist/{src/foundation/ui-components → ui/components}/revision.d.ts +0 -0
  449. /package/dist/{src/foundation/ui-components → ui/components}/revision.js +0 -0
  450. /package/dist/{src/foundation/ui-components → ui/components}/status-line.d.ts +0 -0
  451. /package/dist/{src/foundation/ui-components → ui/components}/status-line.js +0 -0
  452. /package/dist/{src/foundation/ui-components → ui/components}/stepper.d.ts +0 -0
  453. /package/dist/{src/foundation/ui-components → ui/components}/stepper.js +0 -0
  454. /package/dist/{src/foundation/ui-components → ui/components}/theme.d.ts +0 -0
  455. /package/dist/{src/foundation/ui-components → ui/components}/theme.js +0 -0
  456. /package/dist/{src/foundation/ui-components → ui/components}/value-menu.d.ts +0 -0
  457. /package/dist/{src/foundation/ui-components → ui/components}/value-menu.js +0 -0
  458. /package/dist/{src/foundation/owned-ui-settings → ui/settings}/index.d.ts +0 -0
  459. /package/dist/{src/foundation/owned-ui-settings → ui/settings}/index.js +0 -0
  460. /package/dist/{src/foundation/owned-ui-settings → ui/settings}/resolution.d.ts +0 -0
  461. /package/dist/{src/foundation/owned-ui-settings → ui/settings}/resolution.js +0 -0
@@ -0,0 +1,1106 @@
1
+ import { backgroundSgrSpan, composeSubmittedPromptRows, displayWidth, formatSubmittedPromptTime, heldNativeHyperlinkStyle, hyperlinkSgrSpan, nativeHyperlinkStyle, overlaySpan, progressStatusText, submittedPromptLayout, stripAnsi, } from "../../../ui/components/index.js";
2
+ import { PINNED_PI_HIDDEN_COMMAND_NAMES, PINNED_PI_WORKFLOW_COMMAND_NAMES, } from "../engine/index.js";
3
+ import { createPiExtensionUiBridge, createPiQueuedInputStatus, createPiShellArmin, createPiShellAuthProviderSelector, createPiShellChangelog, createPiShellCollapsedChangelog, createPiShellDaxnuts, createPiShellDialog, createPiShellEarendilAnnouncement, createPiShellEditor, createPiShellExtensionSelector, createPiShellFooter, createPiShellHeader, createPiShellHotkeys, createPiShellLoadedResources, createPiShellLoginDialog, createPiShellModelSelector, createPiShellOperationLoader, createPiShellReloadBox, createPiShellScopedModelsSelector, createPiShellSelector, createPiShellSessionInfo, createPiShellSessionSelector, createPiShellSettingsSelector, createPiShellStatus, createPiShellTranscriptComponent, createPiShellTreeSelector, createPiShellTrustSelector, createPiShellUserMessageSelector, onPiThemeChange, piShellVisibleWidth, piTheme, renderPiShellPackageUpdateNotice, renderPiShellStartupDiagnostic, renderPiShellStatusText, renderPiShellTranscriptBlock, } from "../components/index.js";
4
+ import { PiTuiRuntimeAdapter, classifyPiTuiInput, } from "../tui-runtime/index.js";
5
+ import { PromptChipStore } from "./prompt-chips.js";
6
+ import { SessionViewportController } from "./session-viewport-controller.js";
7
+ /** Composes backend session state into the owned transcript, viewport, editor, and dock presentation. */
8
+ export class OwnedUiSessionShellRoot {
9
+ editor;
10
+ header;
11
+ resources;
12
+ #cwd;
13
+ #transcript = new Map();
14
+ #blocksById = new Map();
15
+ #renderedRows = new Map();
16
+ // Performance: document layouts are shared by wheel, rail, jump, and selection frames.
17
+ #documentLayouts = new Map();
18
+ #themeUnsubscribe;
19
+ #transcriptOrder = [];
20
+ #view;
21
+ #status;
22
+ #footer;
23
+ #queued;
24
+ #extensionRenderers;
25
+ #imageAssets;
26
+ #promptChips = new PromptChipStore();
27
+ #customViewport;
28
+ #submittedPromptComposer;
29
+ #viewportController;
30
+ #viewportTheme;
31
+ #onViewportFrame;
32
+ #componentRuntime;
33
+ #toolsExpanded = false;
34
+ #thinkingVisible = true;
35
+ #mermaidRenderingMode = "off";
36
+ #showImages = true;
37
+ #imageWidthCells = 80;
38
+ #outputPad = 1;
39
+ #workflowTranscriptSequence = 0;
40
+ #workflowStatusAnchors = new Map();
41
+ #workflowStatusMessages = new Map();
42
+ #lastWorkflowStatusId;
43
+ #inputSurface;
44
+ #inputSurfaceCoordination = "editor";
45
+ #dockInputReuseEnabled;
46
+ #dockInputCandidate = false;
47
+ #visibleViewportSnapshot;
48
+ #fullViewportCompositions = 0;
49
+ #dockOnlyViewportCompositions = 0;
50
+ #transcriptBlockRenders = 0;
51
+ #extensionHeader = null;
52
+ #extensionFooter = null;
53
+ #extensionWidgets = new Map();
54
+ #extensionStatuses = new Map();
55
+ #extensionWorkingMessage;
56
+ #extensionWorkingVisible = true;
57
+ constructor(view, cwd, handlers, startup = {}, agentDir, extensionRenderers = {
58
+ getMessageRenderer: () => undefined,
59
+ getToolDefinition: () => undefined,
60
+ }, sessionLayout = "pinned", imageAssets) {
61
+ this.#view = view;
62
+ this.#customViewport = sessionLayout === "custom-viewport";
63
+ this.#submittedPromptComposer = this.#customViewport
64
+ ? {
65
+ layout: submittedPromptLayout,
66
+ compose: (rows, width, source, style) => composeSubmittedPromptRows(rows, width, source, style)
67
+ .map(row => nativeHyperlinkStyle(row, nativeTranscriptLinkColor)),
68
+ }
69
+ : undefined;
70
+ this.#cwd = cwd;
71
+ this.#extensionRenderers = extensionRenderers;
72
+ this.#imageAssets = imageAssets;
73
+ this.#componentRuntime = handlers;
74
+ this.#onViewportFrame = handlers.onViewportFrame;
75
+ this.#dockInputReuseEnabled = handlers.enableDockInputReuse ?? true;
76
+ this.header = createPiShellHeader(startup);
77
+ this.resources = createPiShellLoadedResources(startup.resources ?? [], startup.expanded ?? false);
78
+ this.#status = createPiShellStatus(view, progressStatusText, handlers);
79
+ this.#footer = createPiShellFooter(this.#viewWithExtensionStatuses(view), cwd);
80
+ this.#queued = createPiQueuedInputStatus(view.editor.queuedSubmissions, this.#customViewport ? "custom-viewport" : "pinned");
81
+ this.editor = createPiShellEditor({
82
+ ...handlers,
83
+ keybindingProfile: this.#customViewport ? "a1" : "pi",
84
+ paintEditorSelection: (line, from, to, atomic) => backgroundSgrSpan(line, from, to, atomic ? "\u001b[7m" : "\u001b[27m\u001b[48;2;38;79;120m", atomic ? "\u001b[27m" : "\u001b[49m", piShellVisibleWidth),
85
+ transformPastedContent: content => this.#promptChips.transformPastedContent(content),
86
+ editorAtomicRanges: line => this.#promptChips.atomicRanges(line),
87
+ decorateEditorRow: (row, width) => {
88
+ const plain = stripAnsi(row);
89
+ const ranges = this.#promptChips.hyperlinkRanges(plain);
90
+ if (ranges.length === 0)
91
+ return row;
92
+ const linkResetAndTail = `\u001b]8;;\u001b\\\u001b[24m${" ".repeat(Math.max(0, width - piShellVisibleWidth(row)))}`;
93
+ // Platform: VS15 is zero-column and default-ignorable. It breaks Windows Terminal's
94
+ // plain-text URL detector only in the held-button paint; semantic text stays exact.
95
+ const paintRow = this.#viewportController.editorPointerSelecting
96
+ ? row.replaceAll("https://", "https:\uFE0E//").replaceAll("http://", "http:\uFE0E//")
97
+ : row;
98
+ const decorated = this.#viewportController.editorPointerSelecting
99
+ ? ranges.reduce((result, range) => backgroundSgrSpan(result, piShellVisibleWidth(plain.slice(0, range.start)), piShellVisibleWidth(plain.slice(0, range.end)), "\u001b[4:4m", "\u001b[24m", piShellVisibleWidth), paintRow)
100
+ : ranges.reduce((result, range) => hyperlinkSgrSpan(result, piShellVisibleWidth(plain.slice(0, range.start)), piShellVisibleWidth(plain.slice(0, range.end)), range.target, piShellVisibleWidth), row);
101
+ // Platform: Windows Terminal can retain stale native dotted-link cells when a mutable
102
+ // prompt replaces a longer URL. Explicit non-link spaces overwrite that tail.
103
+ return `${decorated}${linkResetAndTail}`;
104
+ },
105
+ expandCopiedEditorText: text => this.#promptChips.expandCopiedText(text),
106
+ cwd,
107
+ ...(agentDir === undefined ? {} : { agentDir }),
108
+ onToolsExpand: () => this.#setToolsExpanded(!this.#toolsExpanded),
109
+ });
110
+ this.#viewportController = new SessionViewportController({
111
+ enabled: this.#customViewport,
112
+ editor: this.editor,
113
+ requestRender: force => this.#componentRuntime.requestRender(force),
114
+ hasEditorLinks: () => this.#promptChips.hyperlinkRanges(this.editor.getText()).length > 0,
115
+ });
116
+ // Performance: stable painter identities let the neutral viewport retain row-level
117
+ // selection variants while each callback still resolves the live Pi theme.
118
+ this.#viewportTheme = {
119
+ track: text => `${SCROLLBAR_CELL_RESET}${piTheme().fg("dim", text)}`,
120
+ thumb: text => `${SCROLLBAR_CELL_RESET}${piTheme().fg("accent", text)}`,
121
+ sticky: (text, hovered) => piTheme().bg(hovered ? "selectedBg" : "toolPendingBg", piTheme().fg("text", withoutTerminalBackground(text))),
122
+ quietSticky: text => `\u001b[2m${text.replace(/\u001b\[(?:0|22)m/g, "$&\u001b[2m")}\u001b[22m`,
123
+ bottomControl: (text, hovered) => piTheme().bg(hovered ? "selectedBg" : "toolPendingBg", piTheme().fg("text", text)),
124
+ selection: (line, from, to) => backgroundSgrSpan(line, from, to, "\u001b[48;2;38;79;120m", "\u001b[49m"),
125
+ };
126
+ this.editor.setThinkingLevel(view.thinkingLevel);
127
+ this.#inputSurface = this.editor;
128
+ for (const block of view.transcript) {
129
+ if (block.kind === "user")
130
+ this.editor.addToHistory(block.text);
131
+ }
132
+ this.#syncTranscript(view.transcript);
133
+ // Invariant: colours come from the active theme, so rendered rows outlive their revision only
134
+ // until the theme under them changes.
135
+ this.#themeUnsubscribe = onPiThemeChange(() => {
136
+ this.#renderedRows.clear();
137
+ this.#documentLayouts.clear();
138
+ });
139
+ }
140
+ setEditorPaddingX(padding) {
141
+ this.editor.setPaddingX(padding);
142
+ this.#documentLayouts.clear();
143
+ }
144
+ setAutocompleteMaxVisible(maxVisible) {
145
+ this.editor.setAutocompleteMaxVisible(maxVisible);
146
+ }
147
+ setOutputPad(padding) {
148
+ if (this.#outputPad === padding)
149
+ return;
150
+ this.#outputPad = padding;
151
+ this.#status.setOutputPad(padding);
152
+ for (const component of this.#transcript.values())
153
+ component.setOutputPad(padding);
154
+ this.#invalidateTranscriptPresentation();
155
+ }
156
+ setHideThinkingBlock(hidden) {
157
+ if (this.#thinkingVisible === !hidden)
158
+ return;
159
+ this.#thinkingVisible = !hidden;
160
+ for (const component of this.#transcript.values())
161
+ component.setHideThinkingBlock(hidden);
162
+ this.#invalidateTranscriptPresentation();
163
+ }
164
+ setMermaidRenderingMode(mode) {
165
+ if (this.#mermaidRenderingMode === mode)
166
+ return;
167
+ this.#mermaidRenderingMode = mode;
168
+ for (const component of this.#transcript.values())
169
+ component.setMermaidRenderingMode(mode);
170
+ this.#invalidateTranscriptPresentation();
171
+ }
172
+ setImagePresentation(showImages, imageWidthCells) {
173
+ if (this.#showImages === showImages && this.#imageWidthCells === imageWidthCells)
174
+ return;
175
+ this.#showImages = showImages;
176
+ this.#imageWidthCells = imageWidthCells;
177
+ for (const component of this.#transcript.values())
178
+ component.setImagePresentation(showImages, imageWidthCells);
179
+ this.#invalidateTranscriptPresentation();
180
+ }
181
+ preparePromptSubmission(text) {
182
+ return this.#promptChips.prepareSubmission(text);
183
+ }
184
+ update(view) {
185
+ if (view.diagnostics.length !== this.#view.diagnostics.length
186
+ || view.diagnostics.some((diagnostic, index) => diagnostic.sequence !== this.#view.diagnostics[index]?.sequence)) {
187
+ this.#documentLayouts.clear();
188
+ }
189
+ this.#view = view;
190
+ this.#status.update(view);
191
+ this.#footer.update(this.#viewWithExtensionStatuses(view));
192
+ this.#queued.update(view.editor.queuedSubmissions);
193
+ this.#syncTranscript(view.transcript);
194
+ this.editor.setSubmitEnabled(view.lifecycle !== "stopping" && view.lifecycle !== "stopped" && view.lifecycle !== "failed");
195
+ this.editor.setThinkingLevel(view.thinkingLevel);
196
+ this.invalidate();
197
+ }
198
+ /**
199
+ * Applies one block: its component is created or updated in place and the order grows
200
+ * only when the block is new. A streamed chunk costs one component update rather than a
201
+ * walk of the whole transcript.
202
+ */
203
+ applyTranscriptBlock(block) {
204
+ this.#blocksById.set(block.id, block);
205
+ const component = this.#transcript.get(block.id);
206
+ if (component === undefined) {
207
+ const created = createPiShellTranscriptComponent(block, this.#cwd, this.#extensionRenderers, this.#submittedPromptComposer, this.#outputPad, !this.#thinkingVisible, this.#mermaidRenderingMode, this.#showImages, this.#imageWidthCells, this.#imageAssets);
208
+ created.setExpanded(this.#toolsExpanded);
209
+ this.#transcript.set(block.id, created);
210
+ this.#transcriptOrder.push(block.id);
211
+ }
212
+ else if (component.revision !== block.revision) {
213
+ component.update(block);
214
+ }
215
+ // Performance: one chunk touches one block, and the updated component tracks its own dirtiness.
216
+ // Invalidating the whole shell here would re-wrap the entire transcript per chunk.
217
+ this.#renderedRows.delete(block.id);
218
+ this.#documentLayouts.clear();
219
+ }
220
+ render(width) {
221
+ if (!this.#customViewport) {
222
+ this.#viewportController.setEditorPointerFrame(undefined);
223
+ return [...this.#renderDocument(width), ...this.#renderDock(width)];
224
+ }
225
+ const height = Math.max(0, this.#componentRuntime.getRows());
226
+ const dock = this.#renderDockLayout(width);
227
+ // Invariant: ordinary transcript content uses the full terminal width. The rail is an
228
+ // overlay, not a lost wrapping cell. Submitted prompts alone retain the
229
+ // intentional final gutter after their right-aligned timestamp.
230
+ const documentWidth = width;
231
+ const document = this.#renderDocumentLayout(documentWidth);
232
+ // Invariant: prompt-adjacent transient surfaces always belong to the dock.
233
+ // Changing from fitting to overflowing content reallocates transcript rows
234
+ // only; it never moves queued or Working rows into selectable history.
235
+ const dockRows = dock.rows;
236
+ const selectableDocumentRowCount = document.rows.length;
237
+ const dockStartRow = height - dockRows.length + 1;
238
+ const editorOffset = dock.editorOffset;
239
+ this.#viewportController.setEditorPointerFrame(this.usesDefaultInputSurface()
240
+ ? {
241
+ rowStart: dockStartRow + editorOffset,
242
+ rowEnd: dockStartRow + editorOffset + dock.inputRows - 1,
243
+ }
244
+ : undefined);
245
+ const snapshot = this.#visibleViewportSnapshot;
246
+ const dockInputCandidate = this.#dockInputCandidate;
247
+ this.#dockInputCandidate = false;
248
+ let frame = dockInputCandidate
249
+ && snapshot !== undefined
250
+ && snapshot.width === width
251
+ && snapshot.height === height
252
+ && snapshot.documentRows === document.rows
253
+ && snapshot.promptAnchors === document.promptAnchors
254
+ && snapshot.dockLength === dockRows.length
255
+ && snapshot.inputSurface === this.#inputSurface
256
+ && snapshot.viewportRevision === this.#viewportController.presentationRevision
257
+ && snapshot.selectionRevision === this.#viewportController.selectionRevision
258
+ ? this.#viewportController.composeDockOnly(dockRows, width, height)
259
+ : null;
260
+ if (frame === null) {
261
+ frame = this.#viewportController.compose({
262
+ documentRows: document.rows,
263
+ ...(this.#viewportController.transcriptPointerSelecting
264
+ ? { paintDocumentRow: heldNativeHyperlinkStyle }
265
+ : {}),
266
+ // Invariant: selection and copying stop at the real document tail; queued
267
+ // and Working rows remain dock-owned status chrome at every fit boundary.
268
+ selectableDocumentRowCount,
269
+ dockRows,
270
+ promptAnchors: document.promptAnchors,
271
+ width,
272
+ height,
273
+ // Invariant: the control belongs immediately above the complete dock,
274
+ // never on top of a queued or Working row.
275
+ bottomControlRow: Math.max(0, height - Math.min(height, dockRows.length) - 1),
276
+ theme: this.#viewportTheme,
277
+ });
278
+ this.#fullViewportCompositions += 1;
279
+ }
280
+ else
281
+ this.#dockOnlyViewportCompositions += 1;
282
+ this.#visibleViewportSnapshot = {
283
+ width,
284
+ height,
285
+ documentRows: document.rows,
286
+ promptAnchors: document.promptAnchors,
287
+ dockLength: dockRows.length,
288
+ inputSurface: this.#inputSurface,
289
+ viewportRevision: this.#viewportController.presentationRevision,
290
+ selectionRevision: this.#viewportController.selectionRevision,
291
+ };
292
+ this.#onViewportFrame?.(frame);
293
+ return frame.rows;
294
+ }
295
+ viewportFrameDescriptor() {
296
+ return this.#viewportController.frame?.descriptor ?? null;
297
+ }
298
+ hasActiveSelection() {
299
+ return this.#viewportController.hasSelection || this.editor.hasSelection();
300
+ }
301
+ setViewportConfig(config) {
302
+ if (this.#viewportController.setConfig(config))
303
+ this.#documentLayouts.clear();
304
+ }
305
+ resumeViewportFollowing() {
306
+ this.#viewportController.resumeFollowing();
307
+ }
308
+ noteCompletedAssistantMessage() {
309
+ this.#viewportController.noteCompletedAssistantMessage();
310
+ }
311
+ resetViewport() {
312
+ this.#viewportController.reset();
313
+ }
314
+ clearViewportPointerState() {
315
+ this.#viewportController.clearPointerState();
316
+ }
317
+ handleViewportPreInput(data, allowWheel = true, now = Date.now()) {
318
+ return this.#viewportController.handlePreInput(data, allowWheel, now);
319
+ }
320
+ #renderDock(width) {
321
+ return this.#renderDockLayout(width).rows;
322
+ }
323
+ #renderDockLayout(width) {
324
+ const queued = this.#view.editor.queuedSubmissions.length === 0 ? [] : this.#queued.render(width);
325
+ const statusRows = this.#renderStatus(width);
326
+ const transientRows = [...queued, ...statusRows];
327
+ const aboveWidgets = this.#renderWidgets("aboveEditor", width);
328
+ const input = this.#inputSurface.render(width);
329
+ const belowWidgets = this.#renderWidgets("belowEditor", width);
330
+ const footer = this.#renderFooter(width);
331
+ const rowsWithoutTransient = [...aboveWidgets, ...input, ...belowWidgets, ...footer];
332
+ return {
333
+ rows: [...transientRows, ...rowsWithoutTransient],
334
+ editorOffset: transientRows.length + aboveWidgets.length,
335
+ inputRows: input.length,
336
+ };
337
+ }
338
+ layoutRoot() {
339
+ const document = layoutPort(width => this.#renderDocument(width), () => this.invalidate());
340
+ const queued = layoutPort(width => this.#view.editor.queuedSubmissions.length === 0 ? [] : this.#queued.render(width), () => this.#queued.invalidate());
341
+ const aboveWidgets = layoutPort(width => this.#renderWidgets("aboveEditor", width), () => this.#invalidateExtensions());
342
+ const status = layoutPort(width => this.#renderStatus(width), () => this.#status.invalidate());
343
+ const editor = layoutPort(width => this.#inputSurface.render(width), () => this.#inputSurface.invalidate(), data => this.#inputSurface.handleInput?.(data));
344
+ const belowWidgets = layoutPort(width => this.#renderWidgets("belowEditor", width), () => this.#invalidateExtensions());
345
+ const footer = layoutPort(width => this.#renderFooter(width), () => (this.#extensionFooter ?? this.#footer).invalidate());
346
+ return {
347
+ type: "stack",
348
+ direction: "vertical",
349
+ children: [
350
+ {
351
+ basis: 0,
352
+ grow: 1,
353
+ shrink: 1,
354
+ minSize: 1,
355
+ node: {
356
+ type: "scroll",
357
+ id: "transcript",
358
+ follow: "end",
359
+ primary: true,
360
+ overscroll: "chain",
361
+ scrollbar: "auto",
362
+ scrollbarStyle: text => piTheme().bg("scrollbarThumb", text),
363
+ child: { type: "component", component: document },
364
+ },
365
+ },
366
+ {
367
+ basis: "auto",
368
+ grow: 0,
369
+ shrink: 1,
370
+ minSize: 1,
371
+ node: {
372
+ type: "stack",
373
+ direction: "vertical",
374
+ children: [
375
+ { shrink: 1, minSize: 0, node: { type: "component", component: queued } },
376
+ { shrink: 1, minSize: 0, node: { type: "component", component: status } },
377
+ { shrink: 1, minSize: 0, node: { type: "component", component: aboveWidgets } },
378
+ { shrink: 1, minSize: 3, node: { type: "component", component: editor } },
379
+ { shrink: 1, minSize: 0, node: { type: "component", component: belowWidgets } },
380
+ { shrink: 1, minSize: 1, node: { type: "component", component: footer } },
381
+ ],
382
+ },
383
+ },
384
+ ],
385
+ };
386
+ }
387
+ #renderDocument(width) {
388
+ return this.#renderDocumentLayout(width).rows;
389
+ }
390
+ #renderDocumentLayout(width) {
391
+ // Performance: extension headers may animate independently of transcript revisions, so
392
+ // only the stable built-in document participates in this frame cache.
393
+ const cached = this.#extensionHeader === null ? this.#documentLayouts.get(width) : undefined;
394
+ if (cached !== undefined)
395
+ return cached;
396
+ const diagnostics = this.#view.diagnostics;
397
+ const startupRows = diagnostics
398
+ .filter(diagnostic => diagnostic.code === "engine-startup")
399
+ .flatMap(diagnostic => renderPiShellStartupDiagnostic(diagnostic, width));
400
+ const resourceRows = this.#customViewport ? [] : [...this.resources.render(width)];
401
+ if (resourceRows.at(-1) === "")
402
+ resourceRows.pop();
403
+ const headerRows = this.#extensionHeader !== null
404
+ ? this.#extensionHeader.render(width)
405
+ : this.#customViewport ? [] : this.header.render(width);
406
+ const rows = [
407
+ ...startupRows,
408
+ ...headerRows,
409
+ ...resourceRows,
410
+ ];
411
+ const promptAnchors = [];
412
+ for (let index = 0; index < this.#transcriptOrder.length; index += 1) {
413
+ const id = this.#transcriptOrder[index];
414
+ const block = this.#blocksById.get(id);
415
+ if (!this.#thinkingVisible && block?.kind === "thinking")
416
+ continue;
417
+ const blockWidth = this.#customViewport
418
+ && block?.kind === "user"
419
+ && this.#viewportController.config.scrollbarAppearance !== "hidden"
420
+ && width > 1
421
+ ? width - 1
422
+ : width;
423
+ const blockRows = this.#blockRows(id, block, blockWidth);
424
+ if (block?.kind === "user") {
425
+ // Compatibility: the first natural prompt gets one breathing row at the document top.
426
+ // Once scrolling advances, the prompt itself reaches row zero and then
427
+ // becomes sticky there, so the spacer is never pinned with it.
428
+ if (this.#customViewport && index === 0)
429
+ rows.push("");
430
+ else if (index > 0)
431
+ rows.push("");
432
+ }
433
+ const firstRow = rows.length;
434
+ rows.push(...blockRows);
435
+ if (block?.kind === "user" && blockRows[0] !== undefined) {
436
+ promptAnchors.push({
437
+ id: block.id,
438
+ firstRow,
439
+ lastRow: Math.max(firstRow, rows.length - 1),
440
+ sourceRow: pinnedPromptSourceRow(block, blockRows[0], blockWidth),
441
+ });
442
+ }
443
+ }
444
+ rows.push(...diagnostics
445
+ .filter(diagnostic => diagnostic.code === "package-updates")
446
+ .flatMap(diagnostic => renderPiShellPackageUpdateNotice(diagnostic.message.split("\n").filter(line => line.startsWith("- ")).map(line => line.slice(2)), width)));
447
+ rows.push(...diagnostics
448
+ .filter(diagnostic => diagnostic.code === "changelog-collapsed" || diagnostic.code === "changelog-expanded")
449
+ .flatMap(diagnostic => diagnostic.code === "changelog-collapsed"
450
+ ? createPiShellCollapsedChangelog().render(width)
451
+ : createPiShellChangelog(diagnostic.message).render(width)));
452
+ rows.push(...diagnostics
453
+ .filter(diagnostic => diagnostic.code !== "engine-startup" && diagnostic.code !== "package-updates"
454
+ && diagnostic.code !== "changelog-collapsed" && diagnostic.code !== "changelog-expanded")
455
+ .slice(-3)
456
+ .flatMap(diagnostic => renderPiShellTranscriptBlock({
457
+ id: `diagnostic-${diagnostic.sequence}`,
458
+ kind: diagnostic.severity === "error" ? "error" : "system",
459
+ status: "finalized",
460
+ revision: diagnostic.sequence,
461
+ title: diagnostic.code,
462
+ text: diagnostic.message,
463
+ payload: {},
464
+ }, width, this.#cwd)));
465
+ const layout = { rows: Object.freeze(rows), promptAnchors: Object.freeze(promptAnchors) };
466
+ if (this.#extensionHeader === null) {
467
+ this.#documentLayouts.set(width, layout);
468
+ // Performance: the custom viewport commonly probes full width and reserved-rail width.
469
+ while (this.#documentLayouts.size > 2)
470
+ this.#documentLayouts.delete(this.#documentLayouts.keys().next().value);
471
+ }
472
+ return layout;
473
+ }
474
+ // Performance: finalized blocks cache by revision and width; live blocks always render.
475
+ #blockRows(id, block, width) {
476
+ const component = this.#transcript.get(id);
477
+ if (component === undefined)
478
+ return [];
479
+ const render = () => {
480
+ this.#transcriptBlockRenders += 1;
481
+ const rows = component.render(width);
482
+ if (!this.#customViewport || block?.kind === "user")
483
+ return rows;
484
+ return rows.map(row => nativeHyperlinkStyle(row, nativeTranscriptLinkColor));
485
+ };
486
+ if (block === undefined || block.status !== "finalized")
487
+ return render();
488
+ let byWidth = this.#renderedRows.get(id);
489
+ const cached = byWidth?.get(width);
490
+ if (cached?.revision === block.revision)
491
+ return cached.rows;
492
+ const rows = render();
493
+ if (byWidth === undefined) {
494
+ byWidth = new Map();
495
+ this.#renderedRows.set(id, byWidth);
496
+ }
497
+ byWidth.set(width, { revision: block.revision, rows });
498
+ // Invariant: bare A1 probes full width before reserving the overflowing rail column;
499
+ // retain both widths without turning resize history into an unbounded cache.
500
+ while (byWidth.size > 2)
501
+ byWidth.delete(byWidth.keys().next().value);
502
+ return rows;
503
+ }
504
+ transcriptComponent(id) {
505
+ return this.#transcript.get(id);
506
+ }
507
+ exitTranscript(width) {
508
+ const rows = [];
509
+ for (const id of this.#transcriptOrder) {
510
+ const block = this.#blocksById.get(id);
511
+ if (block === undefined || (!this.#thinkingVisible && block.kind === "thinking"))
512
+ continue;
513
+ if (rows.length > 0 && block.kind === "user")
514
+ rows.push("");
515
+ rows.push(...this.#blockRows(id, block, width).map(sanitizeExitTranscriptRow));
516
+ }
517
+ while (rows.at(-1) === "")
518
+ rows.pop();
519
+ return rows.join("\n");
520
+ }
521
+ appendWorkflowStatus(message) {
522
+ const previousId = this.#lastWorkflowStatusId;
523
+ if (previousId !== undefined
524
+ && this.#transcriptOrder.at(-1) === previousId
525
+ && this.#workflowStatusAnchors.get(previousId) === this.#view.transcript.length) {
526
+ this.#workflowStatusMessages.set(previousId, message);
527
+ this.#documentLayouts.clear();
528
+ this.invalidate();
529
+ return;
530
+ }
531
+ const id = this.#appendAnchoredWorkflowComponent(width => [
532
+ "",
533
+ ...renderPiShellStatusText(this.#workflowStatusMessages.get(id) ?? message, width, this.#outputPad),
534
+ ]);
535
+ this.#workflowStatusMessages.set(id, message);
536
+ this.#lastWorkflowStatusId = id;
537
+ }
538
+ appendWorkflowResult(result) {
539
+ if (result.command === "reload" && result.outcome === "completed") {
540
+ this.appendWorkflowStatus(result.message);
541
+ return;
542
+ }
543
+ if (result.command === "session" && result.outcome === "completed" && result.presentation?.kind === "session-info") {
544
+ this.#lastWorkflowStatusId = undefined;
545
+ const sessionInfo = createPiShellSessionInfo(result.presentation);
546
+ this.#appendAnchoredWorkflowComponent(width => sessionInfo.render(width), () => sessionInfo.dispose?.());
547
+ return;
548
+ }
549
+ if (result.command === "hotkeys" && result.outcome === "completed") {
550
+ this.#lastWorkflowStatusId = undefined;
551
+ const hotkeys = createPiShellHotkeys();
552
+ this.#appendAnchoredWorkflowComponent(width => hotkeys.render(width), () => hotkeys.dispose?.());
553
+ return;
554
+ }
555
+ if (result.command === "changelog" && result.outcome === "completed") {
556
+ this.#lastWorkflowStatusId = undefined;
557
+ const changelog = createPiShellChangelog(result.detail ?? "No changelog entries found.");
558
+ this.#appendAnchoredWorkflowComponent(width => changelog.render(width), () => changelog.dispose?.());
559
+ return;
560
+ }
561
+ if (result.outcome === "failed") {
562
+ this.#lastWorkflowStatusId = undefined;
563
+ const warning = (result.command === "name" && result.message.startsWith("Usage:"))
564
+ || (result.command === "reload" && result.message.startsWith("Wait for "));
565
+ const prefix = warning ? "Warning" : "Error";
566
+ const color = warning ? "warning" : "error";
567
+ this.#appendAnchoredWorkflowComponent(() => ["", ` ${piTheme().fg(color, `${prefix}: ${result.message}`)}`]);
568
+ return;
569
+ }
570
+ if (result.outcome === "completed" && (result.command === "quit" || result.command === "compact"))
571
+ return;
572
+ if (result.command === "new" && result.outcome === "completed") {
573
+ this.#lastWorkflowStatusId = undefined;
574
+ this.#appendAnchoredWorkflowComponent(() => ["", ` ${piTheme().fg("accent", result.message)}`]);
575
+ return;
576
+ }
577
+ if (result.command === "name" && result.outcome === "completed") {
578
+ this.#lastWorkflowStatusId = undefined;
579
+ this.#appendAnchoredWorkflowComponent(() => [
580
+ ...(result.detail ? ["", ` ${piTheme().fg("warning", `Warning: ${result.detail}`)}`] : []),
581
+ "",
582
+ ` ${piTheme().fg("dim", result.message)}`,
583
+ ]);
584
+ return;
585
+ }
586
+ if (result.command === "debug" && result.outcome === "completed") {
587
+ this.#lastWorkflowStatusId = undefined;
588
+ this.#appendAnchoredWorkflowComponent(() => [
589
+ "",
590
+ ` ${piTheme().fg("accent", result.message)}`,
591
+ ...(result.detail ? [` ${piTheme().fg("muted", result.detail)}`] : []),
592
+ ]);
593
+ return;
594
+ }
595
+ if (result.command === "arminsayshi" && result.outcome === "completed") {
596
+ this.#lastWorkflowStatusId = undefined;
597
+ const armin = createPiShellArmin(this.#componentRuntime);
598
+ this.#appendAnchoredWorkflowComponent(width => ["", ...armin.render(width)], () => armin.dispose?.());
599
+ return;
600
+ }
601
+ if (result.command === "dementedelves" && result.outcome === "completed") {
602
+ this.#lastWorkflowStatusId = undefined;
603
+ const announcement = createPiShellEarendilAnnouncement();
604
+ this.#appendAnchoredWorkflowComponent(width => ["", ...announcement.render(width)], () => announcement.dispose?.());
605
+ return;
606
+ }
607
+ const message = result.command === "share" && result.detail
608
+ ? `${result.message}\nGist: ${result.detail}`
609
+ : result.message;
610
+ this.appendWorkflowStatus(message);
611
+ }
612
+ appendDaxnuts() {
613
+ this.#lastWorkflowStatusId = undefined;
614
+ const daxnuts = createPiShellDaxnuts(this.#componentRuntime);
615
+ this.#appendAnchoredWorkflowComponent(width => ["", ...daxnuts.render(width)], () => daxnuts.dispose?.());
616
+ }
617
+ toggleThinkingVisibility() {
618
+ this.setHideThinkingBlock(this.#thinkingVisible);
619
+ }
620
+ get toolsExpanded() {
621
+ return this.#toolsExpanded;
622
+ }
623
+ setToolsExpanded(expanded) {
624
+ this.#setToolsExpanded(expanded);
625
+ }
626
+ setExtensionWidget(key, component, placement) {
627
+ const previous = this.#extensionWidgets.get(key)?.component;
628
+ if (component === null)
629
+ this.#extensionWidgets.delete(key);
630
+ else
631
+ this.#extensionWidgets.set(key, { component, placement });
632
+ if (previous !== undefined && previous !== component)
633
+ previous.dispose?.();
634
+ this.invalidate();
635
+ }
636
+ setExtensionHeader(component) {
637
+ if (this.#extensionHeader !== component)
638
+ this.#extensionHeader?.dispose?.();
639
+ this.#extensionHeader = component;
640
+ this.#documentLayouts.clear();
641
+ this.invalidate();
642
+ }
643
+ setExtensionFooter(component) {
644
+ if (this.#extensionFooter !== component)
645
+ this.#extensionFooter?.dispose?.();
646
+ this.#extensionFooter = component;
647
+ this.invalidate();
648
+ }
649
+ setExtensionStatus(key, text) {
650
+ if (text === undefined)
651
+ this.#extensionStatuses.delete(key);
652
+ else
653
+ this.#extensionStatuses.set(key, text);
654
+ this.#footer.update(this.#viewWithExtensionStatuses(this.#view));
655
+ this.invalidate();
656
+ }
657
+ setExtensionWorking(message, visible = this.#extensionWorkingVisible) {
658
+ this.#extensionWorkingMessage = message;
659
+ this.#extensionWorkingVisible = visible;
660
+ this.#status.setWorkingOverride(visible ? message : undefined);
661
+ this.invalidate();
662
+ }
663
+ resetWorkflowPresentation() {
664
+ for (const id of this.#workflowStatusAnchors.keys()) {
665
+ this.#transcript.get(id)?.dispose?.();
666
+ this.#transcript.delete(id);
667
+ }
668
+ this.#workflowStatusAnchors.clear();
669
+ this.#workflowStatusMessages.clear();
670
+ this.#transcriptOrder = this.#transcriptOrder.filter(id => !id.startsWith("workflow-status-"));
671
+ this.#lastWorkflowStatusId = undefined;
672
+ this.#documentLayouts.clear();
673
+ this.invalidate();
674
+ }
675
+ resetExtensionUi() {
676
+ this.#extensionHeader?.dispose?.();
677
+ this.#extensionFooter?.dispose?.();
678
+ for (const { component } of this.#extensionWidgets.values())
679
+ component.dispose?.();
680
+ this.#extensionHeader = null;
681
+ this.#extensionFooter = null;
682
+ this.#extensionWidgets.clear();
683
+ this.#extensionStatuses.clear();
684
+ this.#extensionWorkingMessage = undefined;
685
+ this.#status.setWorkingOverride(undefined);
686
+ this.#footer.update(this.#viewWithExtensionStatuses(this.#view));
687
+ // Invariant: an extension renderer may have drawn transcript blocks that are now unrendered by it.
688
+ this.#renderedRows.clear();
689
+ this.#documentLayouts.clear();
690
+ this.invalidate();
691
+ }
692
+ addExtensionNotification(message, type) {
693
+ if (type === "info") {
694
+ this.appendWorkflowStatus(message);
695
+ return;
696
+ }
697
+ this.#lastWorkflowStatusId = undefined;
698
+ const prefix = type === "warning" ? "Warning" : "Error";
699
+ this.#appendAnchoredWorkflowComponent(() => ["", ` ${piTheme().fg(type, `${prefix}: ${message}`)}`]);
700
+ }
701
+ extensionFooterData() {
702
+ return {
703
+ getGitBranch: () => this.#view.status.footer?.branch ?? null,
704
+ getExtensionStatuses: () => new Map(this.#extensionStatuses),
705
+ getAvailableProviderCount: () => this.#view.status.footer?.availableProviderCount ?? 1,
706
+ onBranchChange: () => () => { },
707
+ };
708
+ }
709
+ usesDefaultInputSurface() {
710
+ return this.#inputSurface === this.editor;
711
+ }
712
+ inputCoordinationSurface() {
713
+ return this.#inputSurfaceCoordination;
714
+ }
715
+ viewportCompositionEvidence() {
716
+ return { full: this.#fullViewportCompositions, dockOnly: this.#dockOnlyViewportCompositions };
717
+ }
718
+ transcriptRenderCount() {
719
+ return this.#transcriptBlockRenders;
720
+ }
721
+ setInputSurface(component, disposePrevious = true, coordination = "owned") {
722
+ const next = component ?? this.editor;
723
+ const nextCoordination = next === this.editor ? "editor" : coordination;
724
+ if (next === this.#inputSurface) {
725
+ this.#inputSurfaceCoordination = nextCoordination;
726
+ return;
727
+ }
728
+ this.#dockInputCandidate = false;
729
+ this.#inputSurface.setFocused?.(false);
730
+ if (disposePrevious && this.#inputSurface !== this.editor)
731
+ this.#inputSurface.dispose?.();
732
+ this.#inputSurface = next;
733
+ this.#inputSurfaceCoordination = nextCoordination;
734
+ this.#inputSurface.setFocused?.(true);
735
+ this.invalidate();
736
+ }
737
+ handleInput(data) {
738
+ this.#dockInputCandidate = this.#customViewport && this.#dockInputReuseEnabled
739
+ && classifyPiTuiInput(data, this.#inputSurfaceCoordination) === "safe";
740
+ try {
741
+ this.#inputSurface.handleInput?.(data);
742
+ }
743
+ catch (error) {
744
+ this.#dockInputCandidate = false;
745
+ throw error;
746
+ }
747
+ }
748
+ invalidate() {
749
+ this.header.invalidate();
750
+ this.resources.invalidate();
751
+ for (const component of this.#transcript.values())
752
+ component.invalidate();
753
+ this.editor.invalidate();
754
+ if (this.#inputSurface !== this.editor)
755
+ this.#inputSurface.invalidate();
756
+ this.#invalidateExtensions();
757
+ this.#status.invalidate();
758
+ this.#footer.invalidate();
759
+ this.#queued.invalidate();
760
+ }
761
+ setFocused(focused) {
762
+ this.#inputSurface.setFocused?.(focused);
763
+ }
764
+ dispose() {
765
+ this.clearViewportPointerState();
766
+ this.#themeUnsubscribe();
767
+ this.header.dispose?.();
768
+ this.resources.dispose?.();
769
+ for (const component of this.#transcript.values())
770
+ component.dispose?.();
771
+ this.#transcript.clear();
772
+ this.#renderedRows.clear();
773
+ this.#documentLayouts.clear();
774
+ this.#visibleViewportSnapshot = undefined;
775
+ this.#dockInputCandidate = false;
776
+ if (this.#inputSurface !== this.editor)
777
+ this.#inputSurface.dispose?.();
778
+ this.#extensionHeader?.dispose?.();
779
+ this.#extensionFooter?.dispose?.();
780
+ for (const { component } of this.#extensionWidgets.values())
781
+ component.dispose?.();
782
+ this.#extensionWidgets.clear();
783
+ this.editor.dispose?.();
784
+ this.#status.dispose?.();
785
+ this.#footer.dispose?.();
786
+ this.#queued.dispose?.();
787
+ }
788
+ #invalidateTranscriptPresentation() {
789
+ this.#renderedRows.clear();
790
+ this.#documentLayouts.clear();
791
+ this.invalidate();
792
+ }
793
+ #syncTranscript(blocks) {
794
+ const previousIds = this.#transcriptOrder.filter(id => !id.startsWith("workflow-status-"));
795
+ const transcriptChanged = previousIds.length !== blocks.length || blocks.some((block, index) => {
796
+ const previous = this.#blocksById.get(block.id);
797
+ return previousIds[index] !== block.id || previous?.revision !== block.revision;
798
+ });
799
+ if (transcriptChanged)
800
+ this.#documentLayouts.clear();
801
+ this.#blocksById.clear();
802
+ for (const block of blocks)
803
+ this.#blocksById.set(block.id, block);
804
+ const nextIds = new Set(blocks.map(block => block.id));
805
+ for (const [id, component] of this.#transcript) {
806
+ if (id.startsWith("workflow-status-") || nextIds.has(id))
807
+ continue;
808
+ component.dispose?.();
809
+ this.#transcript.delete(id);
810
+ this.#renderedRows.delete(id);
811
+ }
812
+ for (const block of blocks) {
813
+ const component = this.#transcript.get(block.id);
814
+ if (component === undefined) {
815
+ const created = createPiShellTranscriptComponent(block, this.#cwd, this.#extensionRenderers, this.#submittedPromptComposer, this.#outputPad, !this.#thinkingVisible, this.#mermaidRenderingMode, this.#showImages, this.#imageWidthCells, this.#imageAssets);
816
+ created.setExpanded(this.#toolsExpanded);
817
+ this.#transcript.set(block.id, created);
818
+ }
819
+ else if (component.revision !== block.revision) {
820
+ component.update(block);
821
+ }
822
+ }
823
+ const statusIds = [...this.#workflowStatusAnchors.keys()];
824
+ const order = [];
825
+ for (let index = 0; index <= blocks.length; index += 1) {
826
+ for (const statusId of statusIds) {
827
+ if (this.#workflowStatusAnchors.get(statusId) === index)
828
+ order.push(statusId);
829
+ }
830
+ const block = blocks[index];
831
+ if (block !== undefined)
832
+ order.push(block.id);
833
+ }
834
+ const placed = new Set(order);
835
+ for (const statusId of statusIds) {
836
+ if (!placed.has(statusId))
837
+ order.push(statusId);
838
+ }
839
+ this.#transcriptOrder = order;
840
+ }
841
+ #appendAnchoredWorkflowComponent(render, dispose) {
842
+ this.#workflowTranscriptSequence += 1;
843
+ const id = `workflow-status-${this.#workflowTranscriptSequence}`;
844
+ const component = {
845
+ id,
846
+ revision: 1,
847
+ render,
848
+ handleInput() { },
849
+ invalidate() { },
850
+ update() { },
851
+ setExpanded() { },
852
+ setOutputPad() { },
853
+ setHideThinkingBlock() { },
854
+ setMermaidRenderingMode() { },
855
+ setImagePresentation() { },
856
+ ...(dispose === undefined ? {} : { dispose }),
857
+ };
858
+ this.#transcript.set(id, component);
859
+ this.#workflowStatusAnchors.set(id, this.#view.transcript.length);
860
+ this.#transcriptOrder.push(id);
861
+ this.#documentLayouts.clear();
862
+ this.invalidate();
863
+ return id;
864
+ }
865
+ #renderWidgets(placement, width) {
866
+ const rows = [...this.#extensionWidgets.values()]
867
+ .filter(widget => widget.placement === placement)
868
+ .flatMap(widget => widget.component.render(width));
869
+ return placement === "aboveEditor" ? ["", ...rows] : rows;
870
+ }
871
+ #renderStatus(width) {
872
+ return this.#status.render(width);
873
+ }
874
+ #renderFooter(width) {
875
+ return (this.#extensionFooter ?? this.#footer).render(width);
876
+ }
877
+ #viewWithExtensionStatuses(view) {
878
+ const footer = view.status.footer;
879
+ const statuses = new Map(footer?.extensionStatuses ?? []);
880
+ for (const [key, text] of this.#extensionStatuses)
881
+ statuses.set(key, text);
882
+ return {
883
+ ...view,
884
+ status: {
885
+ ...view.status,
886
+ footer: {
887
+ branch: footer?.branch ?? null,
888
+ sessionName: footer?.sessionName ?? null,
889
+ availableProviderCount: footer?.availableProviderCount ?? 1,
890
+ extensionStatuses: [...statuses],
891
+ },
892
+ },
893
+ };
894
+ }
895
+ #invalidateExtensions() {
896
+ this.#extensionHeader?.invalidate();
897
+ this.#extensionFooter?.invalidate();
898
+ for (const { component } of this.#extensionWidgets.values())
899
+ component.invalidate();
900
+ }
901
+ #setToolsExpanded(expanded) {
902
+ this.#toolsExpanded = expanded;
903
+ this.header.setExpanded(expanded);
904
+ this.resources.setExpanded(expanded);
905
+ for (const component of this.#transcript.values())
906
+ component.setExpanded(expanded);
907
+ // Invariant: expansion changes what a block draws without changing its revision.
908
+ this.#renderedRows.clear();
909
+ this.#documentLayouts.clear();
910
+ this.invalidate();
911
+ }
912
+ }
913
+ const SCROLLBAR_CELL_RESET = "\u001b[22;23;24;25;27;28;29;39;54;55m";
914
+ const KITTY_IMAGE_CONTROL = /\u001b_G[\s\S]*?\u001b\\/g;
915
+ const ITERM_IMAGE_CONTROL = /\u001b]1337;File=[^\u0007]*(?:\u0007|\u001b\\)/g;
916
+ /** Keep semantic SGR/OSC styling while excluding non-replayable image payloads. */
917
+ function sanitizeExitTranscriptRow(row) {
918
+ return row.replace(KITTY_IMAGE_CONTROL, "").replace(ITERM_IMAGE_CONTROL, "");
919
+ }
920
+ const TERMINAL_BACKGROUND = /\u001b\[(?:4[0-9]|10[0-7]|48(?:[;:][0-9;:]*)?)m/g;
921
+ /** Web URLs use link blue; file targets retain A1's cyan interactive accent. */
922
+ function nativeTranscriptLinkColor(text, target) {
923
+ return piTheme().fg(/^file:/iu.test(target) ? "accent" : "mdLink", text);
924
+ }
925
+ /** Repaint a source prompt with viewport chrome while preserving text, links, and foreground roles. */
926
+ function withoutTerminalBackground(text) {
927
+ return text.replace(TERMINAL_BACKGROUND, "");
928
+ }
929
+ /** A pinned timestamp is content now, not secondary transcript metadata. */
930
+ function pinnedPromptSourceRow(block, sourceRow, width) {
931
+ if (typeof block.payload !== "object" || block.payload === null)
932
+ return sourceRow;
933
+ const value = block.payload.timestamp;
934
+ if (typeof value !== "number" || !Number.isFinite(value))
935
+ return sourceRow;
936
+ const timestamp = formatSubmittedPromptTime(value);
937
+ if (timestamp === null || submittedPromptLayout(width, value).timestamp === null)
938
+ return sourceRow;
939
+ const rowWidth = displayWidth(sourceRow);
940
+ const timestampWidth = displayWidth(timestamp);
941
+ if (rowWidth < timestampWidth)
942
+ return sourceRow;
943
+ return overlaySpan(sourceRow, rowWidth - timestampWidth, rowWidth, piTheme().fg("userMessageText", timestamp));
944
+ }
945
+ function layoutPort(render, invalidate, handleInput) {
946
+ return {
947
+ render,
948
+ invalidate,
949
+ ...(handleInput === undefined ? {} : { handleInput }),
950
+ };
951
+ }
952
+ export function shellResourceEntries(backend) {
953
+ const resources = backend.nonVisualResources().map(resource => ({
954
+ section: resource.kind === "skill"
955
+ ? "Skills"
956
+ : resource.kind === "prompt-template"
957
+ ? "Prompts"
958
+ : resource.kind === "theme"
959
+ ? "Themes"
960
+ : "Context",
961
+ label: resource.kind === "prompt-template"
962
+ ? `/${resource.label}`
963
+ : resource.kind === "agent-context" || resource.kind === "system-prompt"
964
+ ? compactResourceLabel(resource.sourcePath ?? resource.label)
965
+ : resource.label,
966
+ sourcePath: resource.sourcePath,
967
+ diagnostic: resource.diagnostic,
968
+ }));
969
+ const extensions = backend.extensionResources().filter(extension => !extension.hidden);
970
+ const loadedExtensions = extensions.filter(extension => extension.diagnostic === null);
971
+ const extensionLabels = compactExtensionLabels(loadedExtensions);
972
+ for (const extension of extensions) {
973
+ const labelIndex = loadedExtensions.indexOf(extension);
974
+ resources.push({
975
+ section: "Extensions",
976
+ label: extensionLabels[labelIndex] ?? compactResourceLabel(extension.sourcePath ?? extension.resolvedPath ?? "extension"),
977
+ sourcePath: extension.sourcePath ?? extension.resolvedPath,
978
+ diagnostic: extension.diagnostic,
979
+ });
980
+ }
981
+ return resources;
982
+ }
983
+ function compactResourceLabel(path) {
984
+ const segments = compactPathSegments(path);
985
+ const leaf = segments.at(-1) ?? path;
986
+ if ((leaf === "index.ts" || leaf === "index.js") && segments.length > 1)
987
+ return segments.at(-2) ?? leaf;
988
+ return leaf;
989
+ }
990
+ /**
991
+ * Pinned from InteractiveMode's compact extension-label helpers at Pi commit
992
+ * 914cf1472e715297caa30db4b9535d534a9eb718. The source metadata crosses an
993
+ * A1-owned boundary first; the owned shell never inspects Pi's private root.
994
+ */
995
+ function compactExtensionLabels(extensions) {
996
+ const localExtensions = extensions
997
+ .filter(extension => !isPackageExtensionSource(extension.sourceInfo))
998
+ .map(extension => {
999
+ const path = extension.sourcePath ?? extension.resolvedPath ?? "extension";
1000
+ const segments = compactPathSegments(path);
1001
+ if (segments.length > 1 && (segments.at(-1) === "index.ts" || segments.at(-1) === "index.js"))
1002
+ segments.pop();
1003
+ return { extension, segments };
1004
+ });
1005
+ return extensions.map(extension => {
1006
+ const resourcePath = extension.sourcePath ?? extension.resolvedPath ?? "extension";
1007
+ if (isPackageExtensionSource(extension.sourceInfo)) {
1008
+ return compactPackageExtensionLabel(resourcePath, extension.sourceInfo);
1009
+ }
1010
+ const localIndex = localExtensions.findIndex(item => item.extension === extension);
1011
+ const segments = localExtensions[localIndex]?.segments;
1012
+ if (!segments || segments.length === 0)
1013
+ return compactResourceLabel(resourcePath);
1014
+ for (let count = 1; count <= segments.length; count += 1) {
1015
+ const candidate = segments.slice(-count).join("/");
1016
+ if (localExtensions.every((item, itemIndex) => itemIndex === localIndex || item.segments.slice(-count).join("/") !== candidate)) {
1017
+ return candidate;
1018
+ }
1019
+ }
1020
+ return segments.join("/");
1021
+ });
1022
+ }
1023
+ function compactPackageExtensionLabel(resourcePath, sourceInfo) {
1024
+ const sourceLabel = compactPackageSourceLabel(sourceInfo.source);
1025
+ if (!sourceLabel)
1026
+ return compactResourceLabel(resourcePath);
1027
+ const shortPath = shortPackagePath(resourcePath, sourceInfo).replaceAll("\\", "/");
1028
+ const packagePath = shortPath.startsWith("extensions/") ? shortPath.slice("extensions/".length) : shortPath;
1029
+ const slash = packagePath.lastIndexOf("/");
1030
+ const fileName = slash < 0 ? packagePath : packagePath.slice(slash + 1);
1031
+ const directory = slash < 0 ? "" : packagePath.slice(0, slash);
1032
+ const extension = fileName.lastIndexOf(".");
1033
+ const name = extension <= 0 ? fileName : fileName.slice(0, extension);
1034
+ if (name === "index")
1035
+ return !directory || directory === "." ? sourceLabel : `${sourceLabel}:${directory}`;
1036
+ return `${sourceLabel}:${packagePath}`;
1037
+ }
1038
+ function compactPackageSourceLabel(source) {
1039
+ if (source.startsWith("npm:"))
1040
+ return source.slice("npm:".length) || source;
1041
+ if (!source.startsWith("git:"))
1042
+ return source;
1043
+ const gitSource = source.slice("git:".length).trim();
1044
+ let repositoryPath;
1045
+ const scpLike = gitSource.match(/^git@[^:]+:(.+)$/);
1046
+ if (scpLike?.[1]) {
1047
+ repositoryPath = scpLike[1];
1048
+ }
1049
+ else if (/^[a-z]+:\/\//i.test(gitSource)) {
1050
+ try {
1051
+ repositoryPath = new URL(gitSource).pathname.replace(/^\/+/, "");
1052
+ }
1053
+ catch {
1054
+ return source;
1055
+ }
1056
+ }
1057
+ else {
1058
+ const slash = gitSource.indexOf("/");
1059
+ if (slash >= 0)
1060
+ repositoryPath = gitSource.slice(slash + 1);
1061
+ }
1062
+ if (!repositoryPath)
1063
+ return source;
1064
+ const ref = repositoryPath.indexOf("@");
1065
+ const withoutRef = ref < 0 ? repositoryPath : repositoryPath.slice(0, ref);
1066
+ return withoutRef.replace(/\.git$/, "") || source;
1067
+ }
1068
+ function shortPackagePath(resourcePath, sourceInfo) {
1069
+ const fullPath = normalizeResourcePath(resourcePath);
1070
+ const baseDir = sourceInfo.baseDir === null ? undefined : normalizeResourcePath(sourceInfo.baseDir).replace(/\/$/, "");
1071
+ if (baseDir) {
1072
+ const npmRoot = baseDir.match(/^(.*\/node_modules)\/(@?[^/]+(?:\/[^/]+)?)$/);
1073
+ if (npmRoot?.[1] && fullPath.startsWith(`${npmRoot[1]}/`))
1074
+ return relativeResourcePath(baseDir, fullPath);
1075
+ if (fullPath === baseDir)
1076
+ return ".";
1077
+ if (fullPath.startsWith(`${baseDir}/`))
1078
+ return fullPath.slice(baseDir.length + 1);
1079
+ }
1080
+ const npmMatch = fullPath.match(/node_modules\/(@?[^/]+(?:\/[^/]+)?)\/(.*)/);
1081
+ if (npmMatch?.[2] && sourceInfo.source.startsWith("npm:"))
1082
+ return npmMatch[2];
1083
+ const gitMatch = fullPath.match(/git\/[^/]+\/[^/]+\/(.*)/);
1084
+ if (gitMatch?.[1] && sourceInfo.source.startsWith("git:"))
1085
+ return gitMatch[1];
1086
+ return resourcePath;
1087
+ }
1088
+ function relativeResourcePath(from, to) {
1089
+ const fromSegments = from.split("/").filter(Boolean);
1090
+ const toSegments = to.split("/").filter(Boolean);
1091
+ let common = 0;
1092
+ while (common < fromSegments.length && common < toSegments.length
1093
+ && fromSegments[common]?.toLowerCase() === toSegments[common]?.toLowerCase())
1094
+ common += 1;
1095
+ return [...fromSegments.slice(common).map(() => ".."), ...toSegments.slice(common)].join("/") || ".";
1096
+ }
1097
+ function compactPathSegments(path) {
1098
+ return normalizeResourcePath(path).split("/").filter(segment => segment.length > 0 && segment !== "~");
1099
+ }
1100
+ function normalizeResourcePath(path) {
1101
+ return path.replaceAll("\\", "/");
1102
+ }
1103
+ function isPackageExtensionSource(sourceInfo) {
1104
+ const source = sourceInfo?.source ?? "";
1105
+ return source.startsWith("npm:") || source.startsWith("git:");
1106
+ }