@herbertgao/pi-extensions 2026.9.6 → 2026.9.8

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 (304) hide show
  1. package/README.md +3 -8
  2. package/THIRD_PARTY_NOTICES.md +0 -4
  3. package/node_modules/@narumitw/pi-btw/README.md +2 -0
  4. package/node_modules/@narumitw/pi-btw/dist/index.ts +284 -365
  5. package/node_modules/@narumitw/pi-btw/dist/index.ts.map +3 -3
  6. package/node_modules/@narumitw/pi-btw/package.json +52 -53
  7. package/node_modules/@narumitw/pi-btw/src/bring-to-main.ts +494 -547
  8. package/node_modules/@narumitw/pi-btw/src/btw.ts +814 -856
  9. package/node_modules/@narumitw/pi-btw/src/fullscreen-ui.ts +673 -674
  10. package/node_modules/@narumitw/pi-btw/src/keybindings.ts +228 -270
  11. package/node_modules/@narumitw/pi-btw/src/main-tree-picker.ts +309 -318
  12. package/node_modules/@narumitw/pi-btw/src/menu.ts +416 -454
  13. package/node_modules/@narumitw/pi-btw/src/settings.ts +203 -219
  14. package/node_modules/@narumitw/pi-btw/src/side-thread.ts +173 -201
  15. package/node_modules/@narumitw/pi-btw/src/text.ts +21 -23
  16. package/node_modules/@narumitw/pi-btw/src/transcript-markdown.ts +65 -0
  17. package/node_modules/@narumitw/pi-btw/src/transcript-pager.ts +611 -662
  18. package/node_modules/grok-mermaid/CHANGELOG.md +46 -0
  19. package/node_modules/grok-mermaid/LICENSE +205 -0
  20. package/node_modules/grok-mermaid/README.md +191 -0
  21. package/node_modules/grok-mermaid/dist/ansi.d.ts +16 -0
  22. package/node_modules/grok-mermaid/dist/ansi.d.ts.map +1 -0
  23. package/node_modules/grok-mermaid/dist/ansi.js +23 -0
  24. package/node_modules/grok-mermaid/dist/ansi.js.map +1 -0
  25. package/node_modules/grok-mermaid/dist/canvas.d.ts +87 -0
  26. package/node_modules/grok-mermaid/dist/canvas.d.ts.map +1 -0
  27. package/node_modules/grok-mermaid/dist/canvas.js +366 -0
  28. package/node_modules/grok-mermaid/dist/canvas.js.map +1 -0
  29. package/node_modules/grok-mermaid/dist/graph.d.ts +74 -0
  30. package/node_modules/grok-mermaid/dist/graph.d.ts.map +1 -0
  31. package/node_modules/grok-mermaid/dist/graph.js +91 -0
  32. package/node_modules/grok-mermaid/dist/graph.js.map +1 -0
  33. package/node_modules/grok-mermaid/dist/index.d.ts +32 -0
  34. package/node_modules/grok-mermaid/dist/index.d.ts.map +1 -0
  35. package/node_modules/grok-mermaid/dist/index.js +100 -0
  36. package/node_modules/grok-mermaid/dist/index.js.map +1 -0
  37. package/node_modules/grok-mermaid/dist/labels.d.ts +62 -0
  38. package/node_modules/grok-mermaid/dist/labels.d.ts.map +1 -0
  39. package/node_modules/grok-mermaid/dist/labels.js +324 -0
  40. package/node_modules/grok-mermaid/dist/labels.js.map +1 -0
  41. package/node_modules/grok-mermaid/dist/layout-seq.d.ts +12 -0
  42. package/node_modules/grok-mermaid/dist/layout-seq.d.ts.map +1 -0
  43. package/node_modules/grok-mermaid/dist/layout-seq.js +194 -0
  44. package/node_modules/grok-mermaid/dist/layout-seq.js.map +1 -0
  45. package/node_modules/grok-mermaid/dist/layout.d.ts +87 -0
  46. package/node_modules/grok-mermaid/dist/layout.d.ts.map +1 -0
  47. package/node_modules/grok-mermaid/dist/layout.js +881 -0
  48. package/node_modules/grok-mermaid/dist/layout.js.map +1 -0
  49. package/node_modules/grok-mermaid/dist/parse.d.ts +83 -0
  50. package/node_modules/grok-mermaid/dist/parse.d.ts.map +1 -0
  51. package/node_modules/grok-mermaid/dist/parse.js +1151 -0
  52. package/node_modules/grok-mermaid/dist/parse.js.map +1 -0
  53. package/node_modules/grok-mermaid/dist/source-box.d.ts +18 -0
  54. package/node_modules/grok-mermaid/dist/source-box.d.ts.map +1 -0
  55. package/node_modules/grok-mermaid/dist/source-box.js +78 -0
  56. package/node_modules/grok-mermaid/dist/source-box.js.map +1 -0
  57. package/node_modules/grok-mermaid/dist/types.d.ts +42 -0
  58. package/node_modules/grok-mermaid/dist/types.d.ts.map +1 -0
  59. package/node_modules/grok-mermaid/dist/types.js +1 -0
  60. package/node_modules/grok-mermaid/dist/types.js.map +1 -0
  61. package/node_modules/grok-mermaid/dist/width-data.d.ts +2 -0
  62. package/node_modules/grok-mermaid/dist/width-data.d.ts.map +1 -0
  63. package/node_modules/grok-mermaid/dist/width-data.js +994 -0
  64. package/node_modules/grok-mermaid/dist/width-data.js.map +1 -0
  65. package/node_modules/grok-mermaid/dist/width.d.ts +18 -0
  66. package/node_modules/grok-mermaid/dist/width.d.ts.map +1 -0
  67. package/node_modules/grok-mermaid/dist/width.js +76 -0
  68. package/node_modules/grok-mermaid/dist/width.js.map +1 -0
  69. package/node_modules/grok-mermaid/package.json +49 -0
  70. package/node_modules/grok-mermaid/src/ansi.ts +34 -0
  71. package/node_modules/grok-mermaid/src/canvas.ts +373 -0
  72. package/node_modules/grok-mermaid/src/graph.ts +142 -0
  73. package/node_modules/grok-mermaid/src/index.ts +104 -0
  74. package/node_modules/grok-mermaid/src/labels.ts +326 -0
  75. package/node_modules/grok-mermaid/src/layout-seq.ts +203 -0
  76. package/node_modules/grok-mermaid/src/layout.ts +1015 -0
  77. package/node_modules/grok-mermaid/src/parse.ts +1189 -0
  78. package/node_modules/grok-mermaid/src/source-box.ts +89 -0
  79. package/node_modules/grok-mermaid/src/types.ts +43 -0
  80. package/node_modules/grok-mermaid/src/width-data.ts +993 -0
  81. package/node_modules/grok-mermaid/src/width.ts +74 -0
  82. package/node_modules/pi-lens/CHANGELOG.md +239 -0
  83. package/node_modules/pi-lens/config/dependency-cruiser-eager-allowlist.json +3 -0
  84. package/node_modules/pi-lens/dist/clients/actionable-warnings.js +30 -4
  85. package/node_modules/pi-lens/dist/clients/agent-behavior-client.js +2 -0
  86. package/node_modules/pi-lens/dist/clients/bash-file-access.js +26 -0
  87. package/node_modules/pi-lens/dist/clients/biome-client.js +1 -1
  88. package/node_modules/pi-lens/dist/clients/blocker-freshness.js +403 -35
  89. package/node_modules/pi-lens/dist/clients/bootstrap.js +6 -1
  90. package/node_modules/pi-lens/dist/clients/cascade-format.js +200 -4
  91. package/node_modules/pi-lens/dist/clients/code-quality-warnings.js +10 -2
  92. package/node_modules/pi-lens/dist/clients/degradation-ledger.js +16 -1
  93. package/node_modules/pi-lens/dist/clients/diagnostic-dispositions.js +12 -1
  94. package/node_modules/pi-lens/dist/clients/dispatch/ast-grep-catalog.js +65 -0
  95. package/node_modules/pi-lens/dist/clients/dispatch/auxiliary-lsp.js +28 -0
  96. package/node_modules/pi-lens/dist/clients/dispatch/dispatcher.js +9 -2
  97. package/node_modules/pi-lens/dist/clients/dispatch/finding-policy.js +222 -0
  98. package/node_modules/pi-lens/dist/clients/dispatch/indent-detect.js +389 -13
  99. package/node_modules/pi-lens/dist/clients/dispatch/integration.js +175 -25
  100. package/node_modules/pi-lens/dist/clients/dispatch/rule-ignores.js +62 -0
  101. package/node_modules/pi-lens/dist/clients/dispatch/runners/ast-grep-napi.js +21 -41
  102. package/node_modules/pi-lens/dist/clients/dispatch/runners/biome-check.js +6 -1
  103. package/node_modules/pi-lens/dist/clients/dispatch/runners/rust-clippy.js +7 -7
  104. package/node_modules/pi-lens/dist/clients/dispatch/runners/shfmt.js +2 -12
  105. package/node_modules/pi-lens/dist/clients/dispatch/runners/tree-sitter.js +2 -21
  106. package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/runner-helpers.js +1 -1
  107. package/node_modules/pi-lens/dist/clients/dispatch/types.js +4 -1
  108. package/node_modules/pi-lens/dist/clients/disposition-publish.js +1 -0
  109. package/node_modules/pi-lens/dist/clients/effective-config.js +1 -1
  110. package/node_modules/pi-lens/dist/clients/file-kinds.js +26 -1
  111. package/node_modules/pi-lens/dist/clients/file-role.js +21 -21
  112. package/node_modules/pi-lens/dist/clients/file-utils.js +156 -10
  113. package/node_modules/pi-lens/dist/clients/finding-delivery-gate.js +56 -9
  114. package/node_modules/pi-lens/dist/clients/format-service.js +39 -21
  115. package/node_modules/pi-lens/dist/clients/formatters.js +60 -13
  116. package/node_modules/pi-lens/dist/clients/generation-guard.js +2 -2
  117. package/node_modules/pi-lens/dist/clients/git-guard.js +11 -3
  118. package/node_modules/pi-lens/dist/clients/indent-retarget.js +78 -8
  119. package/node_modules/pi-lens/dist/clients/installer/index.js +333 -114
  120. package/node_modules/pi-lens/dist/clients/instance-reaper-state.js +7 -0
  121. package/node_modules/pi-lens/dist/clients/instance-reaper.js +20 -10
  122. package/node_modules/pi-lens/dist/clients/language-profile.js +23 -1
  123. package/node_modules/pi-lens/dist/clients/language-registry.js +5 -1
  124. package/node_modules/pi-lens/dist/clients/latency-logger.js +4 -1
  125. package/node_modules/pi-lens/dist/clients/lens-engine.js +12 -3
  126. package/node_modules/pi-lens/dist/clients/lens-events.js +2 -1
  127. package/node_modules/pi-lens/dist/clients/lens-flag-registry.js +79 -0
  128. package/node_modules/pi-lens/dist/clients/live-bus-emitter.js +2 -1
  129. package/node_modules/pi-lens/dist/clients/lsp/client.js +25 -21
  130. package/node_modules/pi-lens/dist/clients/lsp/config.js +2 -2
  131. package/node_modules/pi-lens/dist/clients/lsp/index.js +7 -0
  132. package/node_modules/pi-lens/dist/clients/lsp/launch.js +16 -4
  133. package/node_modules/pi-lens/dist/clients/lsp/server.js +19 -2
  134. package/node_modules/pi-lens/dist/clients/lsp/workspace-diagnostics-cache.js +2 -1
  135. package/node_modules/pi-lens/dist/clients/lsp-mutation.js +5 -3
  136. package/node_modules/pi-lens/dist/clients/map-with-concurrency.js +12 -8
  137. package/node_modules/pi-lens/dist/clients/mcp/session.js +36 -4
  138. package/node_modules/pi-lens/dist/clients/ndjson-logger.js +24 -7
  139. package/node_modules/pi-lens/dist/clients/observed-mutation.js +40 -2
  140. package/node_modules/pi-lens/dist/clients/opaque-mutation-scan.js +23 -3
  141. package/node_modules/pi-lens/dist/clients/opengrep-client.js +110 -15
  142. package/node_modules/pi-lens/dist/clients/path-utils.js +123 -3
  143. package/node_modules/pi-lens/dist/clients/performance-report.js +5 -1
  144. package/node_modules/pi-lens/dist/clients/php-cs-fixer-config.js +1 -1
  145. package/node_modules/pi-lens/dist/clients/pipeline.js +74 -5
  146. package/node_modules/pi-lens/dist/clients/project-diagnostics/cache.js +37 -5
  147. package/node_modules/pi-lens/dist/clients/project-diagnostics/fresh-fetch.js +145 -18
  148. package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/dead-code.js +4 -1
  149. package/node_modules/pi-lens/dist/clients/project-diagnostics/scanner.js +59 -3
  150. package/node_modules/pi-lens/dist/clients/project-lens-config.js +45 -2
  151. package/node_modules/pi-lens/dist/clients/read-guard.js +70 -11
  152. package/node_modules/pi-lens/dist/clients/resource-sampler.js +147 -9
  153. package/node_modules/pi-lens/dist/clients/ruff-client.js +1 -1
  154. package/node_modules/pi-lens/dist/clients/runtime-agent-end.js +33 -5
  155. package/node_modules/pi-lens/dist/clients/runtime-context.js +6 -2
  156. package/node_modules/pi-lens/dist/clients/runtime-coordinator.js +77 -7
  157. package/node_modules/pi-lens/dist/clients/runtime-session.js +21 -2
  158. package/node_modules/pi-lens/dist/clients/runtime-tool-call.js +43 -12
  159. package/node_modules/pi-lens/dist/clients/runtime-tool-result.js +330 -85
  160. package/node_modules/pi-lens/dist/clients/runtime-turn.js +147 -17
  161. package/node_modules/pi-lens/dist/clients/safe-spawn.js +258 -5
  162. package/node_modules/pi-lens/dist/clients/scratch-tree-policy.js +6 -0
  163. package/node_modules/pi-lens/dist/clients/session-event-guard.js +50 -5
  164. package/node_modules/pi-lens/dist/clients/sg-runner.js +23 -11
  165. package/node_modules/pi-lens/dist/clients/sgconfig.js +79 -2
  166. package/node_modules/pi-lens/dist/clients/test-runner-client.js +6 -41
  167. package/node_modules/pi-lens/dist/clients/test-runner-delivery.js +43 -0
  168. package/node_modules/pi-lens/dist/clients/tool-agreement.js +423 -0
  169. package/node_modules/pi-lens/dist/clients/tool-config.js +50 -0
  170. package/node_modules/pi-lens/dist/clients/tool-cwd.js +47 -76
  171. package/node_modules/pi-lens/dist/clients/tool-policy.js +163 -7
  172. package/node_modules/pi-lens/dist/clients/tree-sitter-client.js +120 -0
  173. package/node_modules/pi-lens/dist/clients/tree-sitter-query-loader.js +127 -189
  174. package/node_modules/pi-lens/dist/clients/widget-state.js +98 -0
  175. package/node_modules/pi-lens/dist/clients/word-index.js +5 -2
  176. package/node_modules/pi-lens/dist/clients/write-ordering-guard.js +7 -0
  177. package/node_modules/pi-lens/dist/index.js +27416 -24153
  178. package/node_modules/pi-lens/dist/mcp/server.js +5 -2
  179. package/node_modules/pi-lens/dist/tools/lens-diagnostic-mark.js +7 -1
  180. package/node_modules/pi-lens/dist/tools/lens-diagnostics.js +168 -53
  181. package/node_modules/pi-lens/dist/tools/lsp-diagnostics.js +244 -72
  182. package/node_modules/pi-lens/docs/audit1.md +5 -5
  183. package/node_modules/pi-lens/docs/dependencies.md +11 -0
  184. package/node_modules/pi-lens/docs/dispositions.md +52 -0
  185. package/node_modules/pi-lens/docs/environment-variables.md +2 -2
  186. package/node_modules/pi-lens/docs/features.md +4 -4
  187. package/node_modules/pi-lens/docs/globalconfig.md +3 -1
  188. package/node_modules/pi-lens/docs/language-coverage.md +1 -0
  189. package/node_modules/pi-lens/docs/pi-lens-fixer.md +53 -94
  190. package/node_modules/pi-lens/docs/pi-lens-investigator.md +43 -38
  191. package/node_modules/pi-lens/docs/pi-lens-retro.md +97 -0
  192. package/node_modules/pi-lens/docs/pi-lens-reviewer.md +53 -66
  193. package/node_modules/pi-lens/docs/release-qa-baseline.md +22 -0
  194. package/node_modules/pi-lens/docs/settings.md +7 -4
  195. package/node_modules/pi-lens/docs/tree-sitter_rules_catalog.md +1 -1
  196. package/node_modules/pi-lens/docs/usage.md +2 -0
  197. package/node_modules/pi-lens/package.json +1 -1
  198. package/node_modules/pi-lens/rules/tree-sitter-queries/typescript/sql-injection.yml +24 -12
  199. package/node_modules/pi-lens/scripts/analyze-pi-lens-logs.mjs +40 -0
  200. package/node_modules/pi-lens/skills/pi-lens-ast-grep/SKILL.md +15 -0
  201. package/node_modules/pi-lens/skills/pi-lens-lsp-navigation/SKILL.md +7 -0
  202. package/package.json +6 -11
  203. package/node_modules/@luxusai/pi-hindsight/CHANGELOG.md +0 -376
  204. package/node_modules/@luxusai/pi-hindsight/README.md +0 -92
  205. package/node_modules/@luxusai/pi-hindsight/docs/adr/001-memory-lifecycle-and-scope.md +0 -56
  206. package/node_modules/@luxusai/pi-hindsight/docs/adr/002-explicit-routing-strategy-seam.md +0 -169
  207. package/node_modules/@luxusai/pi-hindsight/docs/adr/003-tui-memory-mode-vocabulary.md +0 -107
  208. package/node_modules/@luxusai/pi-hindsight/docs/adr/004-lifeos-dual-bank-design.md +0 -89
  209. package/node_modules/@luxusai/pi-hindsight/docs/adr/005-domain-banks-and-agent-first-surface.md +0 -189
  210. package/node_modules/@luxusai/pi-hindsight/docs/assets/logos/pi-hindsight-logo-dark.webp +0 -0
  211. package/node_modules/@luxusai/pi-hindsight/docs/assets/logos/pi-hindsight-logo-dark@2x.webp +0 -0
  212. package/node_modules/@luxusai/pi-hindsight/docs/coding-memory-evaluation.md +0 -54
  213. package/node_modules/@luxusai/pi-hindsight/docs/compatibility.md +0 -75
  214. package/node_modules/@luxusai/pi-hindsight/docs/hindsight-core-functions.md +0 -300
  215. package/node_modules/@luxusai/pi-hindsight/docs/mission-and-mental-model-quality.md +0 -158
  216. package/node_modules/@luxusai/pi-hindsight/docs/next-opt-out-design.md +0 -164
  217. package/node_modules/@luxusai/pi-hindsight/docs/risky-memory-modes.md +0 -139
  218. package/node_modules/@luxusai/pi-hindsight/docs/starter-mental-model-suggestions.md +0 -74
  219. package/node_modules/@luxusai/pi-hindsight/docs/surface-reference.md +0 -261
  220. package/node_modules/@luxusai/pi-hindsight/extensions/banks/bank-operations.ts +0 -151
  221. package/node_modules/@luxusai/pi-hindsight/extensions/banks/bank-selection.ts +0 -18
  222. package/node_modules/@luxusai/pi-hindsight/extensions/banks/bank-settings-presenter.ts +0 -46
  223. package/node_modules/@luxusai/pi-hindsight/extensions/banks/bank-templates.ts +0 -383
  224. package/node_modules/@luxusai/pi-hindsight/extensions/banks/banking.ts +0 -240
  225. package/node_modules/@luxusai/pi-hindsight/extensions/banks/knowledge-page-seed.ts +0 -176
  226. package/node_modules/@luxusai/pi-hindsight/extensions/banks/retain-strategies.ts +0 -178
  227. package/node_modules/@luxusai/pi-hindsight/extensions/client/client-retry.ts +0 -41
  228. package/node_modules/@luxusai/pi-hindsight/extensions/client/client.ts +0 -386
  229. package/node_modules/@luxusai/pi-hindsight/extensions/client/fetch-compat.ts +0 -39
  230. package/node_modules/@luxusai/pi-hindsight/extensions/client/timeout.ts +0 -34
  231. package/node_modules/@luxusai/pi-hindsight/extensions/config/config-defaults.ts +0 -140
  232. package/node_modules/@luxusai/pi-hindsight/extensions/config/config-editing-model.ts +0 -61
  233. package/node_modules/@luxusai/pi-hindsight/extensions/config/config-editing-registry.ts +0 -925
  234. package/node_modules/@luxusai/pi-hindsight/extensions/config/config-field-paths.ts +0 -247
  235. package/node_modules/@luxusai/pi-hindsight/extensions/config/config-normalize.ts +0 -547
  236. package/node_modules/@luxusai/pi-hindsight/extensions/config/config-writer.ts +0 -480
  237. package/node_modules/@luxusai/pi-hindsight/extensions/config/config.ts +0 -182
  238. package/node_modules/@luxusai/pi-hindsight/extensions/config/setup-gate.ts +0 -86
  239. package/node_modules/@luxusai/pi-hindsight/extensions/imports/import-execute.ts +0 -1010
  240. package/node_modules/@luxusai/pi-hindsight/extensions/imports/import-parse.ts +0 -175
  241. package/node_modules/@luxusai/pi-hindsight/extensions/imports/import-plan.ts +0 -425
  242. package/node_modules/@luxusai/pi-hindsight/extensions/imports/import-presentation.ts +0 -210
  243. package/node_modules/@luxusai/pi-hindsight/extensions/imports/import-sessions.ts +0 -817
  244. package/node_modules/@luxusai/pi-hindsight/extensions/index.ts +0 -25
  245. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/git-seed.ts +0 -319
  246. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/memory-lifecycle-recall.ts +0 -196
  247. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/memory-lifecycle-retain.ts +0 -189
  248. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/memory-lifecycle-runtime.ts +0 -65
  249. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/memory-lifecycle.ts +0 -260
  250. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/mental-models.ts +0 -244
  251. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/observation-scopes.ts +0 -59
  252. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/recall-cleanup.ts +0 -82
  253. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/recall-visibility.ts +0 -45
  254. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/recall.ts +0 -331
  255. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/retain-cursor.ts +0 -354
  256. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/retain-job-builder.ts +0 -66
  257. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/retain-receipts.ts +0 -132
  258. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/retain.ts +0 -228
  259. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-bank-template-operations.ts +0 -74
  260. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-config-operations.ts +0 -16
  261. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-control-operations.ts +0 -648
  262. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-diagnostics-operations.ts +0 -105
  263. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-identity.ts +0 -68
  264. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-operation-service.ts +0 -71
  265. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-operation-types.ts +0 -13
  266. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-recall-operations.ts +0 -162
  267. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-retain-operations.ts +0 -131
  268. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-scope.ts +0 -104
  269. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-session-operations.ts +0 -37
  270. package/node_modules/@luxusai/pi-hindsight/extensions/operations/operation-catalog.ts +0 -893
  271. package/node_modules/@luxusai/pi-hindsight/extensions/operations/reflect-presenter.ts +0 -35
  272. package/node_modules/@luxusai/pi-hindsight/extensions/operations/scope-migrate.ts +0 -177
  273. package/node_modules/@luxusai/pi-hindsight/extensions/operations/tools.ts +0 -7
  274. package/node_modules/@luxusai/pi-hindsight/extensions/queue/flush-presenter.ts +0 -21
  275. package/node_modules/@luxusai/pi-hindsight/extensions/queue/jsonl-queue-store.ts +0 -112
  276. package/node_modules/@luxusai/pi-hindsight/extensions/queue/queue-delivery.ts +0 -111
  277. package/node_modules/@luxusai/pi-hindsight/extensions/queue/queue-lock.ts +0 -214
  278. package/node_modules/@luxusai/pi-hindsight/extensions/queue/queue-operations.ts +0 -70
  279. package/node_modules/@luxusai/pi-hindsight/extensions/queue/queue.ts +0 -392
  280. package/node_modules/@luxusai/pi-hindsight/extensions/tui/bank-template-presentation.ts +0 -45
  281. package/node_modules/@luxusai/pi-hindsight/extensions/tui/commands.ts +0 -9
  282. package/node_modules/@luxusai/pi-hindsight/extensions/tui/guided-setup.ts +0 -860
  283. package/node_modules/@luxusai/pi-hindsight/extensions/tui/prefill-input.ts +0 -105
  284. package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-flow.ts +0 -189
  285. package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-server-probe.ts +0 -299
  286. package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-tui-actions.ts +0 -201
  287. package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-tui-facts.ts +0 -47
  288. package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-tui-render.ts +0 -239
  289. package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-tui-types.ts +0 -50
  290. package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-tui.ts +0 -259
  291. package/node_modules/@luxusai/pi-hindsight/extensions/tui/tool-presenters.ts +0 -77
  292. package/node_modules/@luxusai/pi-hindsight/extensions/types.ts +0 -534
  293. package/node_modules/@luxusai/pi-hindsight/extensions/utils/diagnostics.ts +0 -319
  294. package/node_modules/@luxusai/pi-hindsight/extensions/utils/messages.ts +0 -325
  295. package/node_modules/@luxusai/pi-hindsight/extensions/utils/sanitize.ts +0 -42
  296. package/node_modules/@luxusai/pi-hindsight/extensions/utils/session-memory-meta.ts +0 -244
  297. package/node_modules/@luxusai/pi-hindsight/extensions/utils/session-operations.ts +0 -56
  298. package/node_modules/@luxusai/pi-hindsight/extensions/utils/session.ts +0 -50
  299. package/node_modules/@luxusai/pi-hindsight/extensions/utils/status-fields.ts +0 -167
  300. package/node_modules/@luxusai/pi-hindsight/extensions/utils/status-health.ts +0 -207
  301. package/node_modules/@luxusai/pi-hindsight/extensions/utils/status.ts +0 -120
  302. package/node_modules/@luxusai/pi-hindsight/extensions/version.ts +0 -8
  303. package/node_modules/@luxusai/pi-hindsight/package.json +0 -118
  304. package/node_modules/@luxusai/pi-hindsight/skills/hindsight-memory-doctor/SKILL.md +0 -75
@@ -0,0 +1,194 @@
1
+ /**
2
+ * Sequence diagram layout.
3
+ *
4
+ * Participants get one column each, with lifelines running the full height and
5
+ * a box repeated at top and bottom. Column gaps are solved from the widest
6
+ * thing that has to fit between any two columns — a message label, a note, a
7
+ * self-message stub — then items stack down the canvas in source order.
8
+ */
9
+ import { Canvas, D, drawTextOverEdges, L, R, U } from './canvas.js';
10
+ import { fitLabel, WRAP_WIDTH } from './labels.js';
11
+ import { drawBox } from './layout.js';
12
+ import { stringWidth } from './width.js';
13
+ const PAD = 1;
14
+ /** Minimum columns between adjacent lifelines. */
15
+ const SEQ_GAP = 5;
16
+ const MAX_CANVAS_CELLS = 1 << 21;
17
+ const sat = (a, b) => Math.max(0, a - b);
18
+ const half = (n) => Math.floor(n / 2);
19
+ /** Where a note box sits, given the lifeline positions. */
20
+ function noteGeometry(xs, anchor, textW) {
21
+ if (anchor.kind === 'over') {
22
+ const center = half(xs[anchor.from] + xs[anchor.to]);
23
+ const w = Math.max(xs[anchor.to] - xs[anchor.from] + 5, textW + 2 * PAD + 2);
24
+ return { x: sat(center, half(w)), w };
25
+ }
26
+ const w = textW + 2 * PAD + 2;
27
+ if (anchor.kind === 'left')
28
+ return { x: sat(xs[anchor.at], 2 + w - 1), w };
29
+ return { x: xs[anchor.at] + 2, w };
30
+ }
31
+ const itemTextW = (text) => (text === null ? 0 : stringWidth(text));
32
+ export function layoutSequence(seq) {
33
+ const n = seq.labels.length;
34
+ const labels = seq.labels.map((l) => fitLabel(l, WRAP_WIDTH));
35
+ const boxW = labels.map((l) => Math.max(1, stringWidth(l)) + 2 * PAD + 2);
36
+ const boxH = 3;
37
+ const gaps = Array.from({ length: sat(n, 1) }, (_, i) => Math.max(SEQ_GAP, Math.ceil(boxW[i] / 2) + Math.ceil(boxW[i + 1] / 2) + 1));
38
+ // Each requirement is "columns l..r together need at least `need` cells".
39
+ const reqs = [];
40
+ for (const item of seq.items) {
41
+ if (item.kind === 'message') {
42
+ const tw = itemTextW(item.text);
43
+ if (item.from !== item.to) {
44
+ reqs.push([Math.min(item.from, item.to), Math.max(item.from, item.to), Math.max(tw + 2, 4)]);
45
+ }
46
+ else if (item.from + 1 < n) {
47
+ reqs.push([item.from, item.from + 1, 5 + tw + 2]);
48
+ }
49
+ }
50
+ else if (item.kind === 'note') {
51
+ const tw = stringWidth(item.text);
52
+ const a = item.anchor;
53
+ if (a.kind === 'over' && a.from < a.to) {
54
+ reqs.push([a.from, a.to, sat(tw, 1)]);
55
+ }
56
+ else if (a.kind === 'over') {
57
+ const need = Math.ceil((tw + 4) / 2) + 2;
58
+ if (a.from > 0)
59
+ reqs.push([a.from - 1, a.from, need]);
60
+ if (a.from + 1 < n)
61
+ reqs.push([a.from, a.from + 1, need]);
62
+ }
63
+ else if (a.kind === 'left' && a.at > 0) {
64
+ reqs.push([a.at - 1, a.at, tw + 7]);
65
+ }
66
+ else if (a.kind === 'right' && a.at + 1 < n) {
67
+ reqs.push([a.at, a.at + 1, tw + 7]);
68
+ }
69
+ }
70
+ }
71
+ // Narrowest spans first, so a wide requirement absorbs what they already gave.
72
+ reqs.sort((a, b) => a[1] - a[0] - (b[1] - b[0]));
73
+ for (const [l, r, need] of reqs) {
74
+ let cur = 0;
75
+ for (let i = l; i < r; i++)
76
+ cur += gaps[i];
77
+ if (cur < need)
78
+ gaps[r - 1] += need - cur;
79
+ }
80
+ const xs = new Array(n);
81
+ xs[0] = half(boxW[0]);
82
+ for (let i = 1; i < n; i++)
83
+ xs[i] = xs[i - 1] + gaps[i - 1];
84
+ let canvasW = xs[n - 1] + Math.ceil(boxW[n - 1] / 2) + 1;
85
+ for (const item of seq.items) {
86
+ if (item.kind === 'message' && item.from === item.to) {
87
+ canvasW = Math.max(canvasW, xs[item.from] + 5 + itemTextW(item.text) + 1);
88
+ }
89
+ else if (item.kind === 'note') {
90
+ const g = noteGeometry(xs, item.anchor, stringWidth(item.text));
91
+ canvasW = Math.max(canvasW, g.x + g.w + 1);
92
+ }
93
+ else if (item.kind === 'divider') {
94
+ canvasW = Math.max(canvasW, stringWidth(item.text) + 4);
95
+ }
96
+ }
97
+ const rows = [];
98
+ let y = boxH + 1;
99
+ for (const item of seq.items) {
100
+ rows.push(y);
101
+ y += rowHeight(item);
102
+ }
103
+ const bottomTop = y;
104
+ const canvasH = bottomTop + boxH;
105
+ if (canvasW * canvasH > MAX_CANVAS_CELLS)
106
+ return null;
107
+ const canvas = new Canvas(canvasW, canvasH);
108
+ for (let i = 0; i < n; i++) {
109
+ for (const by of [0, bottomTop]) {
110
+ drawBox(canvas, box(sat(xs[i], half(boxW[i])), by, boxW[i], boxH), [labels[i]], 'rect');
111
+ }
112
+ }
113
+ seq.items.forEach((item, k) => {
114
+ if (item.kind !== 'note')
115
+ return;
116
+ const g = noteGeometry(xs, item.anchor, stringWidth(item.text));
117
+ drawBox(canvas, box(g.x, rows[k], g.w, 3), [item.text], 'rect');
118
+ });
119
+ for (const x of xs) {
120
+ canvas.junction(x, boxH - 1, D);
121
+ canvas.segV(x, boxH, bottomTop - 1);
122
+ canvas.junction(x, bottomTop, U);
123
+ }
124
+ seq.items.forEach((item, k) => {
125
+ const r = rows[k];
126
+ if (item.kind === 'message')
127
+ drawMessage(canvas, item, xs, r);
128
+ else if (item.kind === 'divider')
129
+ drawDivider(canvas, item.text, r, canvasW);
130
+ });
131
+ canvas.finalizeMask();
132
+ return canvas;
133
+ }
134
+ function rowHeight(item) {
135
+ if (item.kind === 'note')
136
+ return 4;
137
+ if (item.kind === 'divider')
138
+ return 2;
139
+ if (item.from === item.to)
140
+ return 4;
141
+ return item.text !== null ? 3 : 2;
142
+ }
143
+ /** Geometry for a box drawn by position and size; ranks are irrelevant here. */
144
+ const box = (x, y, w, h) => ({
145
+ x,
146
+ y,
147
+ w,
148
+ h,
149
+ cx: x + half(w),
150
+ cy: y + 1,
151
+ rank: 0,
152
+ });
153
+ function drawMessage(canvas, item, xs, r) {
154
+ const lineCh = item.dashed ? '╌' : '─';
155
+ if (item.from === item.to) {
156
+ // A stub that leaves the lifeline and returns two rows down.
157
+ const x = xs[item.from];
158
+ canvas.junction(x, r, R);
159
+ canvas.set(x + 1, r, lineCh, 'edge');
160
+ canvas.set(x + 2, r, lineCh, 'edge');
161
+ canvas.set(x + 3, r, '╮', 'edge');
162
+ canvas.set(x + 3, r + 1, '│', 'edge');
163
+ canvas.set(x + 1, r + 2, item.head === 'cross' ? '×' : '◄', 'edge');
164
+ canvas.set(x + 2, r + 2, lineCh, 'edge');
165
+ canvas.set(x + 3, r + 2, '╯', 'edge');
166
+ if (item.text !== null)
167
+ drawTextOverEdges(canvas, item.text, x + 5, r + 1, 'text');
168
+ return;
169
+ }
170
+ const x0 = xs[item.from];
171
+ const x1 = xs[item.to];
172
+ const rightward = x1 > x0;
173
+ // A labelled message writes its text on `r` and draws the arrow below it.
174
+ const arrowRow = item.text !== null ? r + 1 : r;
175
+ const lo = Math.min(x0, x1);
176
+ const hi = Math.max(x0, x1);
177
+ canvas.junction(x0, arrowRow, rightward ? R : L);
178
+ for (let x = lo + 1; x < hi; x++)
179
+ canvas.set(x, arrowRow, lineCh, 'edge');
180
+ const headCh = item.head === 'cross' ? '×' : rightward ? '▶' : '◄';
181
+ canvas.set(rightward ? x1 - 1 : x1 + 1, arrowRow, headCh, 'edge');
182
+ if (item.text !== null) {
183
+ const span = hi - lo - 1;
184
+ const t = fitLabel(item.text, Math.max(1, span));
185
+ drawTextOverEdges(canvas, t, lo + 1 + half(sat(span, stringWidth(t))), r, 'text');
186
+ }
187
+ }
188
+ /** A full-width rule labelling a `loop` / `alt` / `opt` block boundary. */
189
+ function drawDivider(canvas, text, r, canvasW) {
190
+ for (let x = 0; x < canvasW; x++)
191
+ canvas.set(x, r, '─', 'edge');
192
+ drawTextOverEdges(canvas, ` ${fitLabel(text, sat(canvasW, 4))} `, 2, r, 'edgeLabel');
193
+ }
194
+ //# sourceMappingURL=layout-seq.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout-seq.js","sourceRoot":"","sources":["../src/layout-seq.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,aAAa,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EAAqB,OAAO,EAAe,MAAM,aAAa,CAAA;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,MAAM,GAAG,GAAG,CAAC,CAAA;AACb,kDAAkD;AAClD,MAAM,OAAO,GAAG,CAAC,CAAA;AACjB,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE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EAAE,GAAG,EAAE,MAAM,CAAC,CAAA;IAC/D,iBAAiB,CAAC,MAAM,EAAE,IAAI,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,CAAC,CAAA;AACtF,CAAC"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Graph layout: rank, order, place, route, draw.
3
+ *
4
+ * Follows the Sugiyama outline — assign ranks along the flow axis, reorder
5
+ * within ranks to cut crossings, then relax positions on the cross axis so
6
+ * chains stay straight. Edges between adjacent ranks share horizontal "bus"
7
+ * rows; everything else is routed around the diagram through vertical "lanes".
8
+ *
9
+ * `BT` and `RL` reuse the `TD`/`LR` layouts and flip the finished canvas, so
10
+ * text never ends up mirrored.
11
+ */
12
+ import { Canvas } from './canvas.ts';
13
+ import type { ClassInfo, Edge, Shape } from './graph.ts';
14
+ import { Graph } from './graph.ts';
15
+ /** A laid-out canvas, or `null` when the diagram is empty or over the cell cap. */
16
+ export type CanvasResult = Canvas | null;
17
+ export interface Placed {
18
+ x: number;
19
+ y: number;
20
+ w: number;
21
+ h: number;
22
+ cx: number;
23
+ cy: number;
24
+ rank: number;
25
+ }
26
+ /** What to draw inside a node box. */
27
+ export type NodeExtra = {
28
+ kind: 'plain';
29
+ } | {
30
+ kind: 'frame';
31
+ sub: Canvas;
32
+ } | {
33
+ kind: 'compartments';
34
+ sections: string[][];
35
+ };
36
+ /**
37
+ * Longest-path ranking over the graph's DAG.
38
+ *
39
+ * Back edges (those closing a cycle) are excluded by a DFS colouring pass, so
40
+ * `A --> B --> C --> A` still ranks 0, 1, 2 rather than diverging.
41
+ */
42
+ export declare function computeRanks(graph: Graph): number[];
43
+ /**
44
+ * Reorder nodes within each rank to minimise edge crossings (barycenter
45
+ * sweeps): alternate down/up passes sort each rank by the mean position of its
46
+ * neighbours, keeping whichever ordering crossed least.
47
+ */
48
+ export declare function orderRanks(byRank: number[][], edges: Edge[], ranks: number[]): void;
49
+ export declare function countCrossings(edges: Edge[], ranks: number[], pos: number[]): number;
50
+ /**
51
+ * Assign a cross-axis centre to every node so nodes line up under their
52
+ * neighbours: each node drifts toward the average of its neighbours while
53
+ * ranks keep their order and boxes keep `sep` between them.
54
+ */
55
+ export declare function assignPositions(byRank: number[][], size: number[], sep: number, edges: Edge[], ranks: number[]): number[];
56
+ /** A span competing for a track: `[start, end, from, to, edgeIndex]`. */
57
+ type Span5 = [number, number, number, number, number];
58
+ /**
59
+ * Pack spans into as few parallel tracks as possible.
60
+ *
61
+ * Two spans share a track when they are two cells apart, or when they share an
62
+ * endpoint — edges fanning out of one node deliberately reuse a single row so
63
+ * a merge draws one arrowhead rather than a stack of them.
64
+ */
65
+ export declare function assignTracks(spans: Span5[]): {
66
+ assigned: [number, number][];
67
+ count: number;
68
+ };
69
+ /** Rank, place, draw and route a graph onto a fresh canvas. */
70
+ export declare function layoutCanvas(graph: Graph, extras: NodeExtra[]): CanvasResult;
71
+ /** Apply the direction flip a finished canvas needs for `BT` / `RL`. */
72
+ export declare function orient(canvas: Canvas, graph: Graph): Canvas;
73
+ /** Flowchart and state diagrams: plain boxes, no extra content. */
74
+ export declare function layoutFlowchart(graph: Graph): CanvasResult;
75
+ /** Class and ER diagrams: boxes divided into title / attribute / method rows. */
76
+ export declare function layoutClass(graph: Graph, infos: ClassInfo[]): CanvasResult;
77
+ /**
78
+ * Lay out a flowchart that uses `subgraph`.
79
+ *
80
+ * Each subgraph becomes a framed box holding its own independently laid-out
81
+ * canvas. An edge is drawn in the innermost scope containing both endpoints;
82
+ * one crossing a subgraph boundary attaches to the frame instead of the node.
83
+ */
84
+ export declare function layoutGrouped(graph: Graph): CanvasResult;
85
+ export declare function drawBox(canvas: Canvas, p: Placed, lines: string[], shape: Shape): void;
86
+ export {};
87
+ //# sourceMappingURL=layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../src/layout.ts"],"names":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