@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
@@ -1,893 +0,0 @@
1
- import { Type } from "typebox";
2
- import {
3
- defineTool,
4
- type ExtensionAPI,
5
- type ToolDefinition,
6
- } from "@earendil-works/pi-coding-agent";
7
- import type { MemoryOperationsDeps } from "./memory-operation-service.js";
8
- import { createMemoryOperations } from "./memory-operation-service.js";
9
- import { formatReflectResult } from "./reflect-presenter.js";
10
- import { runHindsightSetupTui } from "../tui/setup-tui.js";
11
- import { renderMemoryToolTextResult, retainToolResponse } from "../tui/tool-presenters.js";
12
- import { getSessionFile } from "../utils/session.js";
13
-
14
- export const HINDSIGHT_DISABLED_TOOL_MESSAGE =
15
- "Hindsight is disabled for this repository (enabled=false). Open /hindsight and set enabled=true (and restore status.style if desired), or edit .pi/hindsight.json.";
16
-
17
- export type ToolOperation = Parameters<ExtensionAPI["registerTool"]>[0];
18
-
19
- const tagMatchSchema = Type.Union(
20
- [
21
- Type.Literal("any"),
22
- Type.Literal("all"),
23
- Type.Literal("any_strict"),
24
- Type.Literal("all_strict"),
25
- Type.Literal("exact"),
26
- ],
27
- {
28
- description:
29
- "How to match tags. Always enforced together with the automatic Pi project/user scope tag filter. 'exact' folds the automatic scope tags into the exact-match set (memory tags must equal scope tags plus these tags, no more, no less) instead of AND-ing a separate scope group, since scope tags must still be present. To also include Hindsight shared/untagged observations (exact empty tags), set includeSharedObservations=true or config.scope.includeSharedObservations.",
30
- },
31
- );
32
-
33
- const budgetSchema = Type.Union([Type.Literal("low"), Type.Literal("mid"), Type.Literal("high")]);
34
-
35
- const recallTypeSchema = Type.Union([
36
- Type.Literal("world"),
37
- Type.Literal("experience"),
38
- Type.Literal("observation"),
39
- ]);
40
-
41
- const tagGroupJsonSchema = {
42
- type: "object",
43
- required: ["tags"],
44
- properties: {
45
- tags: { type: "array", items: { type: "string" } },
46
- match: { type: "string", enum: ["any", "all", "any_strict", "all_strict"] },
47
- },
48
- additionalProperties: false,
49
- };
50
-
51
- const tagGroupSchema = Type.Unsafe<import("../types.js").HindsightTagGroup>(tagGroupJsonSchema);
52
-
53
- function tagGroupsSchema(description: string) {
54
- return Type.Optional(Type.Array(tagGroupSchema, { description }));
55
- }
56
-
57
- const retainEntitySchema = Type.Object({
58
- text: Type.String({ description: "Entity text to associate with the retained content." }),
59
- type: Type.Optional(Type.String({ description: "Optional entity type." })),
60
- });
61
-
62
- const retainUpdateModeSchema = Type.Union([Type.Literal("append"), Type.Literal("replace")], {
63
- description: "Optional Hindsight update mode for this explicit retain call.",
64
- });
65
-
66
- const observationScopesSchema = Type.Unsafe<import("../types.js").HindsightObservationScopes>({
67
- ...Type.Union([
68
- Type.Literal("per_tag"),
69
- Type.Literal("combined"),
70
- Type.Literal("all_combinations"),
71
- Type.Literal("shared"),
72
- Type.Array(Type.Array(Type.String())),
73
- ]),
74
- description:
75
- "Optional Hindsight observation scopes. Use per_tag, combined, all_combinations, shared, or explicit string groups. When provided, overrides configured default observation scopes for this retain call.",
76
- });
77
-
78
- function explicitRetainOptionParameters() {
79
- return {
80
- documentId: Type.Optional(
81
- Type.String({
82
- description:
83
- "Optional Hindsight document ID. Defaults to the existing deterministic explicit retain document ID.",
84
- }),
85
- ),
86
- timestamp: Type.Optional(
87
- Type.String({
88
- description:
89
- "Optional Hindsight timestamp string, including ISO-ish strings or literal unset, passed through as provided.",
90
- }),
91
- ),
92
- metadata: Type.Optional(
93
- Type.Record(Type.String(), Type.String(), {
94
- description:
95
- "Optional caller metadata string map. Reserved provenance keys such as cwd, pi_session_file, source, and retainSource are set by pi-hindsight and cannot be overridden.",
96
- }),
97
- ),
98
- updateMode: Type.Optional(retainUpdateModeSchema),
99
- observationScopes: Type.Optional(observationScopesSchema),
100
- documentTags: Type.Optional(
101
- Type.Array(Type.String(), {
102
- description: "Optional Hindsight document_tags for this retained document when supported.",
103
- }),
104
- ),
105
- async: Type.Optional(
106
- Type.Boolean({
107
- description:
108
- "Optional Hindsight async extraction flag for this retain call. Defaults to configured retain.async.",
109
- }),
110
- ),
111
- };
112
- }
113
-
114
- type ExplicitRetainOptionParams = {
115
- documentId?: string;
116
- timestamp?: string;
117
- metadata?: Record<string, string>;
118
- updateMode?: import("../types.js").UpdateMode;
119
- observationScopes?: import("../types.js").HindsightObservationScopes;
120
- documentTags?: string[];
121
- async?: boolean;
122
- };
123
-
124
- function explicitRetainOptions(params: ExplicitRetainOptionParams) {
125
- return {
126
- ...(params.documentId !== undefined ? { documentId: params.documentId } : {}),
127
- ...(params.timestamp !== undefined ? { timestamp: params.timestamp } : {}),
128
- ...(params.metadata !== undefined ? { metadata: params.metadata } : {}),
129
- ...(params.updateMode !== undefined ? { updateMode: params.updateMode } : {}),
130
- ...(params.observationScopes !== undefined
131
- ? { observationScopes: params.observationScopes }
132
- : {}),
133
- ...(params.documentTags !== undefined ? { documentTags: params.documentTags } : {}),
134
- ...(params.async !== undefined ? { async: params.async } : {}),
135
- };
136
- }
137
-
138
- export type CommandOperation = {
139
- name: string;
140
- spec: Parameters<ExtensionAPI["registerCommand"]>[1];
141
- };
142
-
143
- export interface OperationCatalog {
144
- tools: ToolOperation[];
145
- commands: CommandOperation[];
146
- }
147
-
148
- export function createOperationCatalog(deps: MemoryOperationsDeps): OperationCatalog {
149
- const operations = createMemoryOperations(deps);
150
- const useCwd = (cwd: string) => deps.reloadConfig?.(cwd);
151
-
152
- function defineCatalogTool<TParams extends ToolDefinition["parameters"], TDetails = unknown>(
153
- tool: ToolDefinition<TParams, TDetails>,
154
- ): ToolOperation {
155
- const defined = defineTool(tool);
156
- const execute = defined.execute.bind(defined);
157
- return {
158
- ...defined,
159
- async execute(id, params, signal, onUpdate, ctx) {
160
- useCwd(ctx.cwd);
161
- if (!deps.getConfig().enabled) {
162
- return {
163
- content: [{ type: "text" as const, text: HINDSIGHT_DISABLED_TOOL_MESSAGE }],
164
- details: { disabled: true as const },
165
- };
166
- }
167
- return execute(id, params, signal, onUpdate, ctx);
168
- },
169
- };
170
- }
171
-
172
- const tools: ToolOperation[] = [
173
- defineCatalogTool({
174
- name: "hindsight_recall",
175
- label: "Hindsight Recall",
176
- description: "Recall raw memories from Hindsight for this project.",
177
- parameters: Type.Object({
178
- query: Type.String({ description: "Natural language memory query" }),
179
- bank: Type.Optional(
180
- Type.String({ description: "Optional bank id. Defaults to project bank." }),
181
- ),
182
- types: Type.Optional(
183
- Type.Array(recallTypeSchema, {
184
- description: "Optional Hindsight fact types to retrieve.",
185
- }),
186
- ),
187
- preferObservations: Type.Optional(
188
- Type.Boolean({
189
- description:
190
- "When recalling raw facts ('world'/'experience') together with 'observation', drop raw facts superseded by a returned observation. Defaults to the configured recall.preferObservations.",
191
- }),
192
- ),
193
- minScores: Type.Optional(
194
- Type.Unsafe<import("@vectorize-io/hindsight-client").MinScores>({
195
- ...Type.Object({
196
- semantic: Type.Optional(
197
- Type.Number({
198
- minimum: 0,
199
- maximum: 1,
200
- description: "Minimum vector similarity (0-1).",
201
- }),
202
- ),
203
- keyword: Type.Optional(Type.Number({ description: "Minimum keyword/BM25 score." })),
204
- reranker: Type.Optional(
205
- Type.Number({
206
- minimum: 0,
207
- maximum: 1,
208
- description: "Minimum normalized reranker score (0-1).",
209
- }),
210
- ),
211
- final: Type.Optional(Type.Number({ description: "Minimum final ranking score." })),
212
- }),
213
- description:
214
- "Optional per-stage score floors. Omitted stages impose no floor. No floor by default.",
215
- }),
216
- ),
217
- budget: Type.Optional(
218
- Type.Unsafe<import("../types.js").Budget>({
219
- ...budgetSchema,
220
- description: "Optional Hindsight recall budget override for this tool call.",
221
- }),
222
- ),
223
- maxTokens: Type.Optional(
224
- Type.Integer({
225
- minimum: 0,
226
- description:
227
- "Optional Hindsight recall token cap override for this tool call. Use 0 for metadata/source-only recall when supported by Hindsight.",
228
- }),
229
- ),
230
- queryTimestamp: Type.Optional(
231
- Type.String({ description: "Optional ISO timestamp for time-scoped recall." }),
232
- ),
233
- includeChunks: Type.Optional(
234
- Type.Boolean({ description: "Ask Hindsight to include source chunks when supported." }),
235
- ),
236
- recallChunksMaxTokens: Type.Optional(
237
- Type.Integer({
238
- minimum: 0,
239
- description: "Optional token cap for included recall chunks.",
240
- }),
241
- ),
242
- includeSourceFacts: Type.Optional(
243
- Type.Boolean({ description: "Ask Hindsight to include source facts when supported." }),
244
- ),
245
- maxSourceFactsTokens: Type.Optional(
246
- Type.Integer({
247
- minimum: 0,
248
- description: "Optional token cap for included source facts.",
249
- }),
250
- ),
251
- includeEntities: Type.Optional(
252
- Type.Boolean({ description: "Ask Hindsight to include entities when supported." }),
253
- ),
254
- trace: Type.Optional(
255
- Type.Boolean({ description: "Ask Hindsight to include recall trace/debug data." }),
256
- ),
257
- tags: Type.Optional(Type.Array(Type.String(), { description: "Additional tag filter." })),
258
- tagsMatch: Type.Optional(tagMatchSchema),
259
- tagGroups: tagGroupsSchema(
260
- "Compound Hindsight tag_groups filter. AND-ed with the automatic Pi project/user scope filter.",
261
- ),
262
- includeSharedObservations: Type.Optional(
263
- Type.Boolean({
264
- description:
265
- "When true, also match exact-empty (shared/untagged) observations inside the bank via tag_groups OR. Defaults to config.scope.includeSharedObservations (false). Not cross-bank.",
266
- }),
267
- ),
268
- }),
269
- async execute(_id, params, signal, _onUpdate, ctx) {
270
- useCwd(ctx.cwd);
271
- const sessionFile = ctx.sessionManager.getSessionFile?.();
272
- const { bankId, result } = await operations.recall(
273
- ctx.cwd,
274
- params.query,
275
- params.bank,
276
- sessionFile,
277
- {
278
- ...(params.types ? { types: params.types } : {}),
279
- ...(params.preferObservations !== undefined
280
- ? { preferObservations: params.preferObservations }
281
- : {}),
282
- ...(params.minScores !== undefined ? { minScores: params.minScores } : {}),
283
- ...(params.budget ? { budget: params.budget } : {}),
284
- ...(params.maxTokens !== undefined ? { maxTokens: params.maxTokens } : {}),
285
- ...(params.queryTimestamp ? { queryTimestamp: params.queryTimestamp } : {}),
286
- ...(params.includeChunks !== undefined ? { includeChunks: params.includeChunks } : {}),
287
- ...(params.recallChunksMaxTokens !== undefined
288
- ? { maxChunkTokens: params.recallChunksMaxTokens }
289
- : {}),
290
- ...(params.includeSourceFacts !== undefined
291
- ? { includeSourceFacts: params.includeSourceFacts }
292
- : {}),
293
- ...(params.maxSourceFactsTokens !== undefined
294
- ? { maxSourceFactsTokens: params.maxSourceFactsTokens }
295
- : {}),
296
- ...(params.includeEntities !== undefined
297
- ? { includeEntities: params.includeEntities }
298
- : {}),
299
- ...(params.trace !== undefined ? { trace: params.trace } : {}),
300
- ...(params.tags ? { tags: params.tags } : {}),
301
- ...(params.tagsMatch ? { tagsMatch: params.tagsMatch } : {}),
302
- ...(params.tagGroups
303
- ? { tagGroups: params.tagGroups as import("../types.js").HindsightTagGroup[] }
304
- : {}),
305
- ...(params.includeSharedObservations !== undefined
306
- ? { includeSharedObservations: params.includeSharedObservations }
307
- : {}),
308
- ...(signal ? { signal } : {}),
309
- },
310
- );
311
- return {
312
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
313
- details: { bankId },
314
- };
315
- },
316
- renderResult: renderMemoryToolTextResult,
317
- }),
318
- defineCatalogTool({
319
- name: "hindsight_retain",
320
- label: "Hindsight Retain",
321
- description: "Retain explicit raw content in Hindsight. Use for durable facts or decisions.",
322
- parameters: Type.Object({
323
- content: Type.String({
324
- description: "Raw content to retain, not summary if source content is available.",
325
- }),
326
- context: Type.String({ description: "Source context for this memory." }),
327
- bank: Type.Optional(
328
- Type.String({ description: "Optional bank id. Defaults to project bank." }),
329
- ),
330
- tags: Type.Optional(Type.Array(Type.String())),
331
- entities: Type.Optional(
332
- Type.Array(retainEntitySchema, {
333
- description: "Optional Hindsight entities to associate with this retained content.",
334
- }),
335
- ),
336
- ...explicitRetainOptionParameters(),
337
- }),
338
- async execute(_id, params, signal, _onUpdate, ctx) {
339
- useCwd(ctx.cwd);
340
- const sessionFile = ctx.sessionManager.getSessionFile?.();
341
- const result = await operations.retainExplicit({
342
- cwd: ctx.cwd,
343
- content: params.content,
344
- context: params.context,
345
- ...(sessionFile ? { sessionFile } : {}),
346
- ...(params.bank ? { bank: params.bank } : {}),
347
- ...(params.tags ? { tags: params.tags } : {}),
348
- ...(params.entities ? { entities: params.entities } : {}),
349
- ...explicitRetainOptions(params),
350
- });
351
- return retainToolResponse(result);
352
- },
353
- renderResult: renderMemoryToolTextResult,
354
- }),
355
- defineCatalogTool({
356
- name: "hindsight_retain_global",
357
- label: "Hindsight Retain User",
358
- description:
359
- "Retain explicit durable user memory in the configured user bank. Use for stable user identity, preferences, and cross-project workflows only.",
360
- parameters: Type.Object({
361
- content: Type.String({ description: "Raw memory content to retain." }),
362
- context: Type.String({ description: "Why this memory is durable user context." }),
363
- tags: Type.Optional(Type.Array(Type.String())),
364
- entities: Type.Optional(
365
- Type.Array(retainEntitySchema, {
366
- description: "Optional Hindsight entities to associate with this retained content.",
367
- }),
368
- ),
369
- ...explicitRetainOptionParameters(),
370
- }),
371
- async execute(_id, params, _signal, _onUpdate, ctx) {
372
- useCwd(ctx.cwd);
373
- const sessionFile = ctx.sessionManager.getSessionFile?.();
374
- const result = await operations.retainExplicit({
375
- cwd: ctx.cwd,
376
- content: params.content,
377
- context: params.context,
378
- bank: "global",
379
- ...(sessionFile ? { sessionFile } : {}),
380
- ...(params.tags ? { tags: params.tags } : {}),
381
- ...(params.entities ? { entities: params.entities } : {}),
382
- ...explicitRetainOptions(params),
383
- });
384
- return retainToolResponse(result);
385
- },
386
- renderResult: renderMemoryToolTextResult,
387
- }),
388
- defineCatalogTool({
389
- name: "hindsight_reflect",
390
- label: "Hindsight Reflect",
391
- description:
392
- "Ask Hindsight to synthesize an answer from memory. Use explicitly, not for default recall.",
393
- parameters: Type.Object({
394
- query: Type.String(),
395
- context: Type.Optional(Type.String()),
396
- bank: Type.Optional(Type.String()),
397
- budget: Type.Optional(
398
- Type.Unsafe<import("../types.js").Budget>({
399
- ...budgetSchema,
400
- description: "Optional Hindsight reflect budget override for this tool call.",
401
- }),
402
- ),
403
- maxTokens: Type.Optional(
404
- Type.Integer({
405
- minimum: 0,
406
- description: "Optional Hindsight reflect token cap override for this tool call.",
407
- }),
408
- ),
409
- responseSchema: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
410
- includeFacts: Type.Optional(
411
- Type.Boolean({ description: "Ask Hindsight reflect to include facts when supported." }),
412
- ),
413
- includeToolCalls: Type.Optional(
414
- Type.Boolean({
415
- description: "Ask Hindsight reflect to include tool-call trace data when supported.",
416
- }),
417
- ),
418
- includeToolCallOutput: Type.Optional(
419
- Type.Boolean({
420
- description:
421
- "When includeToolCalls is set, include tool-call outputs (default true); set false for an inputs-only trace.",
422
- }),
423
- ),
424
- factTypes: Type.Optional(
425
- Type.Array(recallTypeSchema, {
426
- description: "Restrict reflection to these Hindsight fact types.",
427
- }),
428
- ),
429
- excludeMentalModels: Type.Optional(
430
- Type.Boolean({ description: "Exclude all mental models from reflection." }),
431
- ),
432
- excludeMentalModelIds: Type.Optional(
433
- Type.Array(Type.String(), {
434
- description: "Exclude specific mental models by id from reflection.",
435
- }),
436
- ),
437
- tags: Type.Optional(Type.Array(Type.String(), { description: "Additional tag filter." })),
438
- tagsMatch: Type.Optional(tagMatchSchema),
439
- tagGroups: tagGroupsSchema(
440
- "Compound Hindsight tag_groups filter. AND-ed with the automatic Pi project/user scope filter.",
441
- ),
442
- includeSharedObservations: Type.Optional(
443
- Type.Boolean({
444
- description:
445
- "When true, also match exact-empty (shared/untagged) observations inside the bank via tag_groups OR. Defaults to config.scope.includeSharedObservations (false). Not cross-bank.",
446
- }),
447
- ),
448
- }),
449
- async execute(_id, params, signal, _onUpdate, ctx) {
450
- useCwd(ctx.cwd);
451
- const { bankId, result } = await operations.reflect(
452
- ctx.cwd,
453
- params.query,
454
- params.context,
455
- params.bank,
456
- params.responseSchema,
457
- {
458
- ...(params.budget ? { budget: params.budget } : {}),
459
- ...(params.maxTokens !== undefined ? { maxTokens: params.maxTokens } : {}),
460
- ...(params.includeFacts !== undefined ? { includeFacts: params.includeFacts } : {}),
461
- ...(params.includeToolCalls !== undefined
462
- ? { includeToolCalls: params.includeToolCalls }
463
- : {}),
464
- ...(params.includeToolCallOutput !== undefined
465
- ? { includeToolCallOutput: params.includeToolCallOutput }
466
- : {}),
467
- ...(params.factTypes ? { factTypes: params.factTypes } : {}),
468
- ...(params.excludeMentalModels !== undefined
469
- ? { excludeMentalModels: params.excludeMentalModels }
470
- : {}),
471
- ...(params.excludeMentalModelIds
472
- ? { excludeMentalModelIds: params.excludeMentalModelIds }
473
- : {}),
474
- ...(params.tags ? { tags: params.tags } : {}),
475
- ...(params.tagsMatch ? { tagsMatch: params.tagsMatch } : {}),
476
- ...(params.tagGroups
477
- ? { tagGroups: params.tagGroups as import("../types.js").HindsightTagGroup[] }
478
- : {}),
479
- ...(params.includeSharedObservations !== undefined
480
- ? { includeSharedObservations: params.includeSharedObservations }
481
- : {}),
482
- ...(signal ? { signal } : {}),
483
- },
484
- );
485
- return {
486
- content: [{ type: "text", text: formatReflectResult(result) }],
487
- details: { bankId },
488
- };
489
- },
490
- renderResult: renderMemoryToolTextResult,
491
- }),
492
- defineCatalogTool({
493
- name: "hindsight_status",
494
- label: "Hindsight Status",
495
- description:
496
- "Inspect Pi Hindsight status: setup gate, coding/life banks, project scope tags (basis), recall/retain flags, queue, and sync readiness (queue depth, git seed receipt, knowledge-page capability). Use before changing memory config. Read-only.",
497
- parameters: Type.Object({}),
498
- async execute(_id, _params, signal, _onUpdate, ctx) {
499
- useCwd(ctx.cwd);
500
- if (signal?.aborted) throw new Error("Aborted");
501
- const result = await operations.status(ctx.cwd);
502
- return {
503
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
504
- details: result,
505
- };
506
- },
507
- renderResult: renderMemoryToolTextResult,
508
- }),
509
- defineCatalogTool({
510
- name: "hindsight_seed_git",
511
- label: "Hindsight Seed Git",
512
- description:
513
- "Opt-in cold-repo seed: retain recent git commit messages (strategy gitlog) into the project bank. Not automatic — conversation retain remains primary. dryRun defaults true; set dryRun=false to enqueue (and flush by default).",
514
- parameters: Type.Object({
515
- limit: Type.Optional(
516
- Type.Integer({
517
- minimum: 1,
518
- maximum: 2000,
519
- description: "Max commits to include (default 300).",
520
- }),
521
- ),
522
- dryRun: Type.Optional(
523
- Type.Boolean({
524
- description: "Default true (preview). Set false to enqueue retain.",
525
- }),
526
- ),
527
- flush: Type.Optional(
528
- Type.Boolean({
529
- description: "When dryRun=false, flush the queue after enqueue (default true).",
530
- }),
531
- ),
532
- }),
533
- async execute(_id, params, signal, _onUpdate, ctx) {
534
- useCwd(ctx.cwd);
535
- if (signal?.aborted) throw new Error("Aborted");
536
- const result = await operations.seedGitLog({
537
- cwd: ctx.cwd,
538
- ...(params.limit !== undefined ? { limit: params.limit } : {}),
539
- dryRun: params.dryRun ?? true,
540
- ...(params.flush !== undefined ? { flush: params.flush } : {}),
541
- });
542
- return {
543
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
544
- details: result,
545
- };
546
- },
547
- renderResult: renderMemoryToolTextResult,
548
- }),
549
- defineCatalogTool({
550
- name: "hindsight_scope",
551
- label: "Hindsight Scope",
552
- description:
553
- "Show active project identity: project:<id> tag, derivation (pin/remote/basename), scope.mode (domain-tagged vs isolated-bank), coding/life bank ids. Read-only.",
554
- parameters: Type.Object({}),
555
- async execute(_id, _params, signal, _onUpdate, ctx) {
556
- useCwd(ctx.cwd);
557
- if (signal?.aborted) throw new Error("Aborted");
558
- const result = operations.scopeInfo(ctx.cwd);
559
- return {
560
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
561
- details: result,
562
- };
563
- },
564
- renderResult: renderMemoryToolTextResult,
565
- }),
566
- defineCatalogTool({
567
- name: "hindsight_config",
568
- label: "Hindsight Config",
569
- description:
570
- "Get or patch allowlisted Pi Hindsight config (project or global file). action=get returns effective values (no secrets) and the allowlist. action=patch updates only typed allowlisted keys (setupComplete, scopeMode, projectId, projectIdStrategy, includeSharedObservations, projectBankId, enableGlobalBank, globalBankId, agentUse, mentalModelsInject, memoryProfile, recall/retain knobs, baseUrl, apiKeyEnvVar, timeoutMs). dryRun defaults true for patch. Domain-tagged setupComplete requires projectBankId. Never pass raw API keys — use apiKeyEnvVar.",
571
- parameters: Type.Object({
572
- action: Type.Union([Type.Literal("get"), Type.Literal("patch")]),
573
- patch: Type.Optional(
574
- Type.Object(
575
- {
576
- setupComplete: Type.Optional(Type.Boolean()),
577
- scopeMode: Type.Optional(
578
- Type.Union([Type.Literal("domain-tagged"), Type.Literal("isolated-bank")]),
579
- ),
580
- projectId: Type.Optional(Type.String({ minLength: 1 })),
581
- projectIdStrategy: Type.Optional(
582
- Type.Union([Type.Literal("remote"), Type.Literal("basename")]),
583
- ),
584
- includeSharedObservations: Type.Optional(Type.Boolean()),
585
- projectBankId: Type.Optional(Type.String({ minLength: 1 })),
586
- enableGlobalBank: Type.Optional(Type.Boolean()),
587
- globalBankId: Type.Optional(Type.String({ minLength: 1 })),
588
- agentUse: Type.Optional(
589
- Type.Union([Type.Literal("coding"), Type.Literal("conversation")]),
590
- ),
591
- mentalModelsInject: Type.Optional(Type.Boolean()),
592
- memoryProfile: Type.Optional(
593
- Type.Union([
594
- Type.Literal("project-only"),
595
- Type.Literal("project+global"),
596
- Type.Literal("global-only"),
597
- Type.Literal("recall-only"),
598
- ]),
599
- ),
600
- recallEnabled: Type.Optional(Type.Boolean()),
601
- recallBudget: Type.Optional(
602
- Type.Union([Type.Literal("low"), Type.Literal("mid"), Type.Literal("high")]),
603
- ),
604
- recallMaxTokens: Type.Optional(Type.Number({ minimum: 0 })),
605
- retainEnabled: Type.Optional(Type.Boolean()),
606
- baseUrl: Type.Optional(Type.String({ minLength: 1 })),
607
- apiKeyEnvVar: Type.Optional(Type.String({ minLength: 1 })),
608
- timeoutMs: Type.Optional(Type.Number({ minimum: 0 })),
609
- },
610
- {
611
- additionalProperties: false,
612
- description: "Typed allowlisted config fields only (no free-form keys).",
613
- },
614
- ),
615
- ),
616
- scope: Type.Optional(
617
- Type.Union([Type.Literal("project"), Type.Literal("global")], {
618
- description: "Which config file to write (default project .pi/hindsight.json).",
619
- }),
620
- ),
621
- dryRun: Type.Optional(
622
- Type.Boolean({
623
- description: "When true (default for patch), preview only; set false to write.",
624
- }),
625
- ),
626
- }),
627
- async execute(_id, params, signal, _onUpdate, ctx) {
628
- useCwd(ctx.cwd);
629
- if (signal?.aborted) throw new Error("Aborted");
630
- const result = await operations.config({
631
- action: params.action,
632
- cwd: ctx.cwd,
633
- ...(params.patch ? { patch: params.patch as Record<string, unknown> } : {}),
634
- ...(params.scope ? { scope: params.scope } : {}),
635
- ...(params.dryRun !== undefined ? { dryRun: params.dryRun } : {}),
636
- });
637
- return {
638
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
639
- details: result,
640
- };
641
- },
642
- renderResult: renderMemoryToolTextResult,
643
- }),
644
- defineCatalogTool({
645
- name: "hindsight_bank",
646
- label: "Hindsight Bank",
647
- description:
648
- "Inspect or update the selected coding/life bank. action=get returns profile/stats/config. action=update_mission patches retain/reflect/observations mission (dryRun default true for safety).",
649
- parameters: Type.Object({
650
- action: Type.Union([Type.Literal("get"), Type.Literal("update_mission")]),
651
- bank: Type.Optional(
652
- Type.String({
653
- description: "Bank id or alias project|global|user. Defaults to coding/project bank.",
654
- }),
655
- ),
656
- retainMission: Type.Optional(Type.String()),
657
- reflectMission: Type.Optional(Type.String()),
658
- observationsMission: Type.Optional(Type.String()),
659
- dryRun: Type.Optional(
660
- Type.Boolean({ description: "When true (default for update_mission), preview only." }),
661
- ),
662
- }),
663
- async execute(_id, params, signal, _onUpdate, ctx) {
664
- useCwd(ctx.cwd);
665
- if (signal?.aborted) throw new Error("Aborted");
666
- if (params.action === "get") {
667
- const result = await operations.bankGet({
668
- ...(params.bank ? { bank: params.bank } : {}),
669
- });
670
- return {
671
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
672
- details: result,
673
- };
674
- }
675
- const result = await operations.bankUpdateMission({
676
- ...(params.bank ? { bank: params.bank } : {}),
677
- ...(params.retainMission !== undefined ? { retainMission: params.retainMission } : {}),
678
- ...(params.reflectMission !== undefined ? { reflectMission: params.reflectMission } : {}),
679
- ...(params.observationsMission !== undefined
680
- ? { observationsMission: params.observationsMission }
681
- : {}),
682
- dryRun: params.dryRun ?? true,
683
- });
684
- return {
685
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
686
- details: result,
687
- };
688
- },
689
- renderResult: renderMemoryToolTextResult,
690
- }),
691
- defineCatalogTool({
692
- name: "hindsight_mental_model",
693
- label: "Hindsight Mental Model",
694
- description:
695
- "Agent control plane for mental models on the selected bank. Actions: list|get|create|update|refresh|delete. list returns metadata only (id, name, tags, max_tokens, last_refreshed_at); use get for full content/reflect_response. Project-tier create defaults tags to source:pi + project:<activeId>. Optional tagsMatch sets refresh tag matching on create/update trigger. Mutating actions default dryRun=true; set dryRun=false to apply.",
696
- parameters: Type.Object({
697
- action: Type.Union([
698
- Type.Literal("list"),
699
- Type.Literal("get"),
700
- Type.Literal("create"),
701
- Type.Literal("update"),
702
- Type.Literal("refresh"),
703
- Type.Literal("delete"),
704
- ]),
705
- bank: Type.Optional(Type.String({ description: "Bank id or alias project|global|user." })),
706
- id: Type.Optional(
707
- Type.String({ description: "Mental model id for get/update/refresh/delete." }),
708
- ),
709
- name: Type.Optional(Type.String()),
710
- sourceQuery: Type.Optional(Type.String()),
711
- tags: Type.Optional(Type.Array(Type.String())),
712
- maxTokens: Type.Optional(Type.Integer({ minimum: 1 })),
713
- tagsMatch: Type.Optional(tagMatchSchema),
714
- dryRun: Type.Optional(
715
- Type.Boolean({
716
- description: "Mutating actions default true (preview). Set false to apply.",
717
- }),
718
- ),
719
- }),
720
- async execute(_id, params, signal, _onUpdate, ctx) {
721
- useCwd(ctx.cwd);
722
- if (signal?.aborted) throw new Error("Aborted");
723
- const mutating =
724
- params.action === "create" ||
725
- params.action === "update" ||
726
- params.action === "refresh" ||
727
- params.action === "delete";
728
- const result = await operations.mentalModel({
729
- action: params.action,
730
- cwd: ctx.cwd,
731
- ...(params.bank ? { bank: params.bank } : {}),
732
- ...(params.id ? { id: params.id } : {}),
733
- ...(params.name ? { name: params.name } : {}),
734
- ...(params.sourceQuery ? { sourceQuery: params.sourceQuery } : {}),
735
- ...(params.tags ? { tags: params.tags } : {}),
736
- ...(params.maxTokens !== undefined ? { maxTokens: params.maxTokens } : {}),
737
- ...(params.tagsMatch ? { tagsMatch: params.tagsMatch } : {}),
738
- ...(mutating
739
- ? { dryRun: params.dryRun ?? true }
740
- : params.dryRun !== undefined
741
- ? { dryRun: params.dryRun }
742
- : {}),
743
- });
744
- return {
745
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
746
- details: result,
747
- };
748
- },
749
- renderResult: renderMemoryToolTextResult,
750
- }),
751
- defineCatalogTool({
752
- name: "hindsight_knowledge",
753
- label: "Hindsight Knowledge Pages",
754
- description:
755
- "Agent control plane for knowledge pages (living docs over bank observations). Actions: tree|search|get|export|seed_taxonomy|create_page|create_folder|update|delete. Prefer search then get for routine Q&A (pages are not auto-injected). seed_taxonomy creates the fixed five-page coding taxonomy (idempotent; degrades when pages unavailable). Use export only for a portable full-bank markdown bundle. Project-tier create_page defaults tags to source:pi + project:<activeId>. Mutating actions default dryRun=true. Requires Hindsight client/server knowledge-base support.",
756
- parameters: Type.Object({
757
- action: Type.Union([
758
- Type.Literal("tree"),
759
- Type.Literal("search"),
760
- Type.Literal("get"),
761
- Type.Literal("export"),
762
- Type.Literal("seed_taxonomy"),
763
- Type.Literal("create_page"),
764
- Type.Literal("create_folder"),
765
- Type.Literal("update"),
766
- Type.Literal("delete"),
767
- ]),
768
- bank: Type.Optional(Type.String({ description: "Bank id or alias project|global|user." })),
769
- id: Type.Optional(Type.String({ description: "Page or folder id for get/update/delete." })),
770
- query: Type.Optional(
771
- Type.String({ description: "Search query for action=search (hybrid page search)." }),
772
- ),
773
- limit: Type.Optional(
774
- Type.Integer({ minimum: 1, maximum: 50, description: "Search result limit (1–50)." }),
775
- ),
776
- name: Type.Optional(Type.String()),
777
- sourceQuery: Type.Optional(
778
- Type.String({ description: "Page question for create_page / update." }),
779
- ),
780
- parentId: Type.Optional(
781
- Type.Union([Type.String(), Type.Null()], {
782
- description:
783
- "Folder parent. Omit for root create; pass null on update to move to root.",
784
- }),
785
- ),
786
- tags: Type.Optional(Type.Array(Type.String())),
787
- maxTokens: Type.Optional(Type.Integer({ minimum: 1 })),
788
- tagsMatch: Type.Optional(tagMatchSchema),
789
- dryRun: Type.Optional(
790
- Type.Boolean({
791
- description:
792
- "Mutating actions (seed_taxonomy|create_page|create_folder|update|delete) default true (preview). Set false to apply.",
793
- }),
794
- ),
795
- }),
796
- async execute(_id, params, signal, _onUpdate, ctx) {
797
- useCwd(ctx.cwd);
798
- if (signal?.aborted) throw new Error("Aborted");
799
- const mutating =
800
- params.action === "create_page" ||
801
- params.action === "create_folder" ||
802
- params.action === "update" ||
803
- params.action === "delete" ||
804
- params.action === "seed_taxonomy";
805
- const result = await operations.knowledge({
806
- action: params.action,
807
- cwd: ctx.cwd,
808
- ...(params.bank ? { bank: params.bank } : {}),
809
- ...(params.id ? { id: params.id } : {}),
810
- ...(params.query ? { query: params.query } : {}),
811
- ...(params.limit !== undefined ? { limit: params.limit } : {}),
812
- ...(params.name ? { name: params.name } : {}),
813
- ...(params.sourceQuery ? { sourceQuery: params.sourceQuery } : {}),
814
- ...(params.parentId !== undefined ? { parentId: params.parentId } : {}),
815
- ...(params.tags ? { tags: params.tags } : {}),
816
- ...(params.maxTokens !== undefined ? { maxTokens: params.maxTokens } : {}),
817
- ...(params.tagsMatch ? { tagsMatch: params.tagsMatch } : {}),
818
- ...(mutating
819
- ? { dryRun: params.dryRun ?? true }
820
- : params.dryRun !== undefined
821
- ? { dryRun: params.dryRun }
822
- : {}),
823
- });
824
- return {
825
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
826
- details: result,
827
- };
828
- },
829
- renderResult: renderMemoryToolTextResult,
830
- }),
831
- defineCatalogTool({
832
- name: "hindsight_scope_migrate",
833
- label: "Hindsight Scope Migrate Dry-Run",
834
- description:
835
- "Dry-run only: plan dual-tag / legacy repo:<path-hash> → project:<id> migration. Writes a local receipt under .pi/hindsight/. Never rewrites Hindsight tags or documents. Prefer Hindsight export/import or Pi transcript reimport for actual rebuilds.",
836
- parameters: Type.Object({
837
- bankTags: Type.Optional(
838
- Type.Array(Type.String(), {
839
- description:
840
- "Optional tag inventory sample from the coding bank (e.g. listTags). Used only for counts in the plan.",
841
- }),
842
- ),
843
- writeReceipt: Type.Optional(
844
- Type.Boolean({
845
- description: "Write .pi/hindsight/scope-migrate-receipt.json (default true).",
846
- }),
847
- ),
848
- }),
849
- async execute(_id, params, _signal, _onUpdate, ctx) {
850
- useCwd(ctx.cwd);
851
- const result = await operations.scopeMigrateDryRun(ctx.cwd, {
852
- ...(params.bankTags ? { bankTags: params.bankTags } : {}),
853
- ...(params.writeReceipt !== undefined ? { writeReceipt: params.writeReceipt } : {}),
854
- });
855
- return {
856
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
857
- details: { dryRun: true, rewrite: "none" },
858
- };
859
- },
860
- renderResult: renderMemoryToolTextResult,
861
- }),
862
- ];
863
-
864
- // Human surface is TUI-first: `/hindsight` hub plus a few deliberate slash commands.
865
- // Day-to-day ops (mode, import, mental models, flush, doctor, init) live in the hub.
866
- const commands: CommandOperation[] = [
867
- {
868
- name: "hindsight",
869
- spec: {
870
- description:
871
- "Open Hindsight memory hub (status, mode, next-opt-out, mental models, import, flush, doctor, setup).",
872
- handler: async (_args, ctx) => {
873
- await runHindsightSetupTui(ctx, deps);
874
- },
875
- },
876
- },
877
- {
878
- name: "hindsight:next-opt-out",
879
- spec: {
880
- description: "Skip automatic retain for the next agent run in this session.",
881
- handler: async (_args, ctx) => {
882
- const result = await operations.setNextRetainOff(ctx.cwd, getSessionFile(ctx));
883
- ctx.ui.notify(
884
- `Hindsight will skip automatic retain for the next agent run in this session. nextRetain=${result.meta.nextRetainMode}`,
885
- "info",
886
- );
887
- },
888
- },
889
- },
890
- ];
891
-
892
- return { tools, commands };
893
- }