@herbertgao/pi-extensions 2026.9.6 → 2026.9.7

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 (240) 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/pi-lens/CHANGELOG.md +239 -0
  19. package/node_modules/pi-lens/config/dependency-cruiser-eager-allowlist.json +3 -0
  20. package/node_modules/pi-lens/dist/clients/actionable-warnings.js +30 -4
  21. package/node_modules/pi-lens/dist/clients/agent-behavior-client.js +2 -0
  22. package/node_modules/pi-lens/dist/clients/bash-file-access.js +26 -0
  23. package/node_modules/pi-lens/dist/clients/biome-client.js +1 -1
  24. package/node_modules/pi-lens/dist/clients/blocker-freshness.js +403 -35
  25. package/node_modules/pi-lens/dist/clients/bootstrap.js +6 -1
  26. package/node_modules/pi-lens/dist/clients/cascade-format.js +200 -4
  27. package/node_modules/pi-lens/dist/clients/code-quality-warnings.js +10 -2
  28. package/node_modules/pi-lens/dist/clients/degradation-ledger.js +16 -1
  29. package/node_modules/pi-lens/dist/clients/diagnostic-dispositions.js +12 -1
  30. package/node_modules/pi-lens/dist/clients/dispatch/ast-grep-catalog.js +65 -0
  31. package/node_modules/pi-lens/dist/clients/dispatch/auxiliary-lsp.js +28 -0
  32. package/node_modules/pi-lens/dist/clients/dispatch/dispatcher.js +9 -2
  33. package/node_modules/pi-lens/dist/clients/dispatch/finding-policy.js +222 -0
  34. package/node_modules/pi-lens/dist/clients/dispatch/indent-detect.js +389 -13
  35. package/node_modules/pi-lens/dist/clients/dispatch/integration.js +175 -25
  36. package/node_modules/pi-lens/dist/clients/dispatch/rule-ignores.js +62 -0
  37. package/node_modules/pi-lens/dist/clients/dispatch/runners/ast-grep-napi.js +21 -41
  38. package/node_modules/pi-lens/dist/clients/dispatch/runners/biome-check.js +6 -1
  39. package/node_modules/pi-lens/dist/clients/dispatch/runners/rust-clippy.js +7 -7
  40. package/node_modules/pi-lens/dist/clients/dispatch/runners/shfmt.js +2 -12
  41. package/node_modules/pi-lens/dist/clients/dispatch/runners/tree-sitter.js +2 -21
  42. package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/runner-helpers.js +1 -1
  43. package/node_modules/pi-lens/dist/clients/dispatch/types.js +4 -1
  44. package/node_modules/pi-lens/dist/clients/disposition-publish.js +1 -0
  45. package/node_modules/pi-lens/dist/clients/effective-config.js +1 -1
  46. package/node_modules/pi-lens/dist/clients/file-kinds.js +26 -1
  47. package/node_modules/pi-lens/dist/clients/file-role.js +21 -21
  48. package/node_modules/pi-lens/dist/clients/file-utils.js +156 -10
  49. package/node_modules/pi-lens/dist/clients/finding-delivery-gate.js +56 -9
  50. package/node_modules/pi-lens/dist/clients/format-service.js +39 -21
  51. package/node_modules/pi-lens/dist/clients/formatters.js +60 -13
  52. package/node_modules/pi-lens/dist/clients/generation-guard.js +2 -2
  53. package/node_modules/pi-lens/dist/clients/git-guard.js +11 -3
  54. package/node_modules/pi-lens/dist/clients/indent-retarget.js +78 -8
  55. package/node_modules/pi-lens/dist/clients/installer/index.js +333 -114
  56. package/node_modules/pi-lens/dist/clients/instance-reaper-state.js +7 -0
  57. package/node_modules/pi-lens/dist/clients/instance-reaper.js +20 -10
  58. package/node_modules/pi-lens/dist/clients/language-profile.js +23 -1
  59. package/node_modules/pi-lens/dist/clients/language-registry.js +5 -1
  60. package/node_modules/pi-lens/dist/clients/latency-logger.js +4 -1
  61. package/node_modules/pi-lens/dist/clients/lens-engine.js +12 -3
  62. package/node_modules/pi-lens/dist/clients/lens-events.js +2 -1
  63. package/node_modules/pi-lens/dist/clients/lens-flag-registry.js +79 -0
  64. package/node_modules/pi-lens/dist/clients/live-bus-emitter.js +2 -1
  65. package/node_modules/pi-lens/dist/clients/lsp/client.js +25 -21
  66. package/node_modules/pi-lens/dist/clients/lsp/config.js +2 -2
  67. package/node_modules/pi-lens/dist/clients/lsp/index.js +7 -0
  68. package/node_modules/pi-lens/dist/clients/lsp/launch.js +16 -4
  69. package/node_modules/pi-lens/dist/clients/lsp/server.js +19 -2
  70. package/node_modules/pi-lens/dist/clients/lsp/workspace-diagnostics-cache.js +2 -1
  71. package/node_modules/pi-lens/dist/clients/lsp-mutation.js +5 -3
  72. package/node_modules/pi-lens/dist/clients/map-with-concurrency.js +12 -8
  73. package/node_modules/pi-lens/dist/clients/mcp/session.js +36 -4
  74. package/node_modules/pi-lens/dist/clients/ndjson-logger.js +24 -7
  75. package/node_modules/pi-lens/dist/clients/observed-mutation.js +40 -2
  76. package/node_modules/pi-lens/dist/clients/opaque-mutation-scan.js +23 -3
  77. package/node_modules/pi-lens/dist/clients/opengrep-client.js +110 -15
  78. package/node_modules/pi-lens/dist/clients/path-utils.js +123 -3
  79. package/node_modules/pi-lens/dist/clients/performance-report.js +5 -1
  80. package/node_modules/pi-lens/dist/clients/php-cs-fixer-config.js +1 -1
  81. package/node_modules/pi-lens/dist/clients/pipeline.js +74 -5
  82. package/node_modules/pi-lens/dist/clients/project-diagnostics/cache.js +37 -5
  83. package/node_modules/pi-lens/dist/clients/project-diagnostics/fresh-fetch.js +145 -18
  84. package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/dead-code.js +4 -1
  85. package/node_modules/pi-lens/dist/clients/project-diagnostics/scanner.js +59 -3
  86. package/node_modules/pi-lens/dist/clients/project-lens-config.js +45 -2
  87. package/node_modules/pi-lens/dist/clients/read-guard.js +70 -11
  88. package/node_modules/pi-lens/dist/clients/resource-sampler.js +147 -9
  89. package/node_modules/pi-lens/dist/clients/ruff-client.js +1 -1
  90. package/node_modules/pi-lens/dist/clients/runtime-agent-end.js +33 -5
  91. package/node_modules/pi-lens/dist/clients/runtime-context.js +6 -2
  92. package/node_modules/pi-lens/dist/clients/runtime-coordinator.js +77 -7
  93. package/node_modules/pi-lens/dist/clients/runtime-session.js +21 -2
  94. package/node_modules/pi-lens/dist/clients/runtime-tool-call.js +43 -12
  95. package/node_modules/pi-lens/dist/clients/runtime-tool-result.js +330 -85
  96. package/node_modules/pi-lens/dist/clients/runtime-turn.js +147 -17
  97. package/node_modules/pi-lens/dist/clients/safe-spawn.js +258 -5
  98. package/node_modules/pi-lens/dist/clients/scratch-tree-policy.js +6 -0
  99. package/node_modules/pi-lens/dist/clients/session-event-guard.js +50 -5
  100. package/node_modules/pi-lens/dist/clients/sg-runner.js +23 -11
  101. package/node_modules/pi-lens/dist/clients/sgconfig.js +79 -2
  102. package/node_modules/pi-lens/dist/clients/test-runner-client.js +6 -41
  103. package/node_modules/pi-lens/dist/clients/test-runner-delivery.js +43 -0
  104. package/node_modules/pi-lens/dist/clients/tool-agreement.js +423 -0
  105. package/node_modules/pi-lens/dist/clients/tool-config.js +50 -0
  106. package/node_modules/pi-lens/dist/clients/tool-cwd.js +47 -76
  107. package/node_modules/pi-lens/dist/clients/tool-policy.js +163 -7
  108. package/node_modules/pi-lens/dist/clients/tree-sitter-client.js +120 -0
  109. package/node_modules/pi-lens/dist/clients/tree-sitter-query-loader.js +127 -189
  110. package/node_modules/pi-lens/dist/clients/widget-state.js +98 -0
  111. package/node_modules/pi-lens/dist/clients/word-index.js +5 -2
  112. package/node_modules/pi-lens/dist/clients/write-ordering-guard.js +7 -0
  113. package/node_modules/pi-lens/dist/index.js +27416 -24153
  114. package/node_modules/pi-lens/dist/mcp/server.js +5 -2
  115. package/node_modules/pi-lens/dist/tools/lens-diagnostic-mark.js +7 -1
  116. package/node_modules/pi-lens/dist/tools/lens-diagnostics.js +168 -53
  117. package/node_modules/pi-lens/dist/tools/lsp-diagnostics.js +244 -72
  118. package/node_modules/pi-lens/docs/audit1.md +5 -5
  119. package/node_modules/pi-lens/docs/dependencies.md +11 -0
  120. package/node_modules/pi-lens/docs/dispositions.md +52 -0
  121. package/node_modules/pi-lens/docs/environment-variables.md +2 -2
  122. package/node_modules/pi-lens/docs/features.md +4 -4
  123. package/node_modules/pi-lens/docs/globalconfig.md +3 -1
  124. package/node_modules/pi-lens/docs/language-coverage.md +1 -0
  125. package/node_modules/pi-lens/docs/pi-lens-fixer.md +53 -94
  126. package/node_modules/pi-lens/docs/pi-lens-investigator.md +43 -38
  127. package/node_modules/pi-lens/docs/pi-lens-retro.md +97 -0
  128. package/node_modules/pi-lens/docs/pi-lens-reviewer.md +53 -66
  129. package/node_modules/pi-lens/docs/release-qa-baseline.md +22 -0
  130. package/node_modules/pi-lens/docs/settings.md +7 -4
  131. package/node_modules/pi-lens/docs/tree-sitter_rules_catalog.md +1 -1
  132. package/node_modules/pi-lens/docs/usage.md +2 -0
  133. package/node_modules/pi-lens/package.json +1 -1
  134. package/node_modules/pi-lens/rules/tree-sitter-queries/typescript/sql-injection.yml +24 -12
  135. package/node_modules/pi-lens/scripts/analyze-pi-lens-logs.mjs +40 -0
  136. package/node_modules/pi-lens/skills/pi-lens-ast-grep/SKILL.md +15 -0
  137. package/node_modules/pi-lens/skills/pi-lens-lsp-navigation/SKILL.md +7 -0
  138. package/package.json +5 -11
  139. package/node_modules/@luxusai/pi-hindsight/CHANGELOG.md +0 -376
  140. package/node_modules/@luxusai/pi-hindsight/README.md +0 -92
  141. package/node_modules/@luxusai/pi-hindsight/docs/adr/001-memory-lifecycle-and-scope.md +0 -56
  142. package/node_modules/@luxusai/pi-hindsight/docs/adr/002-explicit-routing-strategy-seam.md +0 -169
  143. package/node_modules/@luxusai/pi-hindsight/docs/adr/003-tui-memory-mode-vocabulary.md +0 -107
  144. package/node_modules/@luxusai/pi-hindsight/docs/adr/004-lifeos-dual-bank-design.md +0 -89
  145. package/node_modules/@luxusai/pi-hindsight/docs/adr/005-domain-banks-and-agent-first-surface.md +0 -189
  146. package/node_modules/@luxusai/pi-hindsight/docs/assets/logos/pi-hindsight-logo-dark.webp +0 -0
  147. package/node_modules/@luxusai/pi-hindsight/docs/assets/logos/pi-hindsight-logo-dark@2x.webp +0 -0
  148. package/node_modules/@luxusai/pi-hindsight/docs/coding-memory-evaluation.md +0 -54
  149. package/node_modules/@luxusai/pi-hindsight/docs/compatibility.md +0 -75
  150. package/node_modules/@luxusai/pi-hindsight/docs/hindsight-core-functions.md +0 -300
  151. package/node_modules/@luxusai/pi-hindsight/docs/mission-and-mental-model-quality.md +0 -158
  152. package/node_modules/@luxusai/pi-hindsight/docs/next-opt-out-design.md +0 -164
  153. package/node_modules/@luxusai/pi-hindsight/docs/risky-memory-modes.md +0 -139
  154. package/node_modules/@luxusai/pi-hindsight/docs/starter-mental-model-suggestions.md +0 -74
  155. package/node_modules/@luxusai/pi-hindsight/docs/surface-reference.md +0 -261
  156. package/node_modules/@luxusai/pi-hindsight/extensions/banks/bank-operations.ts +0 -151
  157. package/node_modules/@luxusai/pi-hindsight/extensions/banks/bank-selection.ts +0 -18
  158. package/node_modules/@luxusai/pi-hindsight/extensions/banks/bank-settings-presenter.ts +0 -46
  159. package/node_modules/@luxusai/pi-hindsight/extensions/banks/bank-templates.ts +0 -383
  160. package/node_modules/@luxusai/pi-hindsight/extensions/banks/banking.ts +0 -240
  161. package/node_modules/@luxusai/pi-hindsight/extensions/banks/knowledge-page-seed.ts +0 -176
  162. package/node_modules/@luxusai/pi-hindsight/extensions/banks/retain-strategies.ts +0 -178
  163. package/node_modules/@luxusai/pi-hindsight/extensions/client/client-retry.ts +0 -41
  164. package/node_modules/@luxusai/pi-hindsight/extensions/client/client.ts +0 -386
  165. package/node_modules/@luxusai/pi-hindsight/extensions/client/fetch-compat.ts +0 -39
  166. package/node_modules/@luxusai/pi-hindsight/extensions/client/timeout.ts +0 -34
  167. package/node_modules/@luxusai/pi-hindsight/extensions/config/config-defaults.ts +0 -140
  168. package/node_modules/@luxusai/pi-hindsight/extensions/config/config-editing-model.ts +0 -61
  169. package/node_modules/@luxusai/pi-hindsight/extensions/config/config-editing-registry.ts +0 -925
  170. package/node_modules/@luxusai/pi-hindsight/extensions/config/config-field-paths.ts +0 -247
  171. package/node_modules/@luxusai/pi-hindsight/extensions/config/config-normalize.ts +0 -547
  172. package/node_modules/@luxusai/pi-hindsight/extensions/config/config-writer.ts +0 -480
  173. package/node_modules/@luxusai/pi-hindsight/extensions/config/config.ts +0 -182
  174. package/node_modules/@luxusai/pi-hindsight/extensions/config/setup-gate.ts +0 -86
  175. package/node_modules/@luxusai/pi-hindsight/extensions/imports/import-execute.ts +0 -1010
  176. package/node_modules/@luxusai/pi-hindsight/extensions/imports/import-parse.ts +0 -175
  177. package/node_modules/@luxusai/pi-hindsight/extensions/imports/import-plan.ts +0 -425
  178. package/node_modules/@luxusai/pi-hindsight/extensions/imports/import-presentation.ts +0 -210
  179. package/node_modules/@luxusai/pi-hindsight/extensions/imports/import-sessions.ts +0 -817
  180. package/node_modules/@luxusai/pi-hindsight/extensions/index.ts +0 -25
  181. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/git-seed.ts +0 -319
  182. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/memory-lifecycle-recall.ts +0 -196
  183. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/memory-lifecycle-retain.ts +0 -189
  184. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/memory-lifecycle-runtime.ts +0 -65
  185. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/memory-lifecycle.ts +0 -260
  186. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/mental-models.ts +0 -244
  187. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/observation-scopes.ts +0 -59
  188. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/recall-cleanup.ts +0 -82
  189. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/recall-visibility.ts +0 -45
  190. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/recall.ts +0 -331
  191. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/retain-cursor.ts +0 -354
  192. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/retain-job-builder.ts +0 -66
  193. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/retain-receipts.ts +0 -132
  194. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/retain.ts +0 -228
  195. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-bank-template-operations.ts +0 -74
  196. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-config-operations.ts +0 -16
  197. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-control-operations.ts +0 -648
  198. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-diagnostics-operations.ts +0 -105
  199. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-identity.ts +0 -68
  200. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-operation-service.ts +0 -71
  201. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-operation-types.ts +0 -13
  202. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-recall-operations.ts +0 -162
  203. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-retain-operations.ts +0 -131
  204. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-scope.ts +0 -104
  205. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-session-operations.ts +0 -37
  206. package/node_modules/@luxusai/pi-hindsight/extensions/operations/operation-catalog.ts +0 -893
  207. package/node_modules/@luxusai/pi-hindsight/extensions/operations/reflect-presenter.ts +0 -35
  208. package/node_modules/@luxusai/pi-hindsight/extensions/operations/scope-migrate.ts +0 -177
  209. package/node_modules/@luxusai/pi-hindsight/extensions/operations/tools.ts +0 -7
  210. package/node_modules/@luxusai/pi-hindsight/extensions/queue/flush-presenter.ts +0 -21
  211. package/node_modules/@luxusai/pi-hindsight/extensions/queue/jsonl-queue-store.ts +0 -112
  212. package/node_modules/@luxusai/pi-hindsight/extensions/queue/queue-delivery.ts +0 -111
  213. package/node_modules/@luxusai/pi-hindsight/extensions/queue/queue-lock.ts +0 -214
  214. package/node_modules/@luxusai/pi-hindsight/extensions/queue/queue-operations.ts +0 -70
  215. package/node_modules/@luxusai/pi-hindsight/extensions/queue/queue.ts +0 -392
  216. package/node_modules/@luxusai/pi-hindsight/extensions/tui/bank-template-presentation.ts +0 -45
  217. package/node_modules/@luxusai/pi-hindsight/extensions/tui/commands.ts +0 -9
  218. package/node_modules/@luxusai/pi-hindsight/extensions/tui/guided-setup.ts +0 -860
  219. package/node_modules/@luxusai/pi-hindsight/extensions/tui/prefill-input.ts +0 -105
  220. package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-flow.ts +0 -189
  221. package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-server-probe.ts +0 -299
  222. package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-tui-actions.ts +0 -201
  223. package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-tui-facts.ts +0 -47
  224. package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-tui-render.ts +0 -239
  225. package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-tui-types.ts +0 -50
  226. package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-tui.ts +0 -259
  227. package/node_modules/@luxusai/pi-hindsight/extensions/tui/tool-presenters.ts +0 -77
  228. package/node_modules/@luxusai/pi-hindsight/extensions/types.ts +0 -534
  229. package/node_modules/@luxusai/pi-hindsight/extensions/utils/diagnostics.ts +0 -319
  230. package/node_modules/@luxusai/pi-hindsight/extensions/utils/messages.ts +0 -325
  231. package/node_modules/@luxusai/pi-hindsight/extensions/utils/sanitize.ts +0 -42
  232. package/node_modules/@luxusai/pi-hindsight/extensions/utils/session-memory-meta.ts +0 -244
  233. package/node_modules/@luxusai/pi-hindsight/extensions/utils/session-operations.ts +0 -56
  234. package/node_modules/@luxusai/pi-hindsight/extensions/utils/session.ts +0 -50
  235. package/node_modules/@luxusai/pi-hindsight/extensions/utils/status-fields.ts +0 -167
  236. package/node_modules/@luxusai/pi-hindsight/extensions/utils/status-health.ts +0 -207
  237. package/node_modules/@luxusai/pi-hindsight/extensions/utils/status.ts +0 -120
  238. package/node_modules/@luxusai/pi-hindsight/extensions/version.ts +0 -8
  239. package/node_modules/@luxusai/pi-hindsight/package.json +0 -118
  240. package/node_modules/@luxusai/pi-hindsight/skills/hindsight-memory-doctor/SKILL.md +0 -75
@@ -1,176 +0,0 @@
1
- /**
2
- * Idempotent knowledge-page taxonomy seeding for coding banks.
3
- *
4
- * Pages are created via the knowledge-base API (not bare mental_models in the bank template).
5
- * When the client/server lacks knowledge-page methods, seeding degrades cleanly.
6
- */
7
- import type { HindsightLikeClient } from "../types.js";
8
- import {
9
- KNOWLEDGE_PAGE_MAX_TOKENS,
10
- KNOWLEDGE_PAGE_SEEDS,
11
- KNOWLEDGE_PAGE_TRIGGER,
12
- type KnowledgePageSeed,
13
- } from "./retain-strategies.js";
14
-
15
- export const KNOWLEDGE_PAGES_UNAVAILABLE = "knowledge_pages_unavailable" as const;
16
-
17
- export class KnowledgePagesUnavailableError extends Error {
18
- readonly code = KNOWLEDGE_PAGES_UNAVAILABLE;
19
- constructor(message = "Hindsight server does not support knowledge pages") {
20
- super(message);
21
- this.name = "KnowledgePagesUnavailableError";
22
- }
23
- }
24
-
25
- export interface SeedKnowledgePagesArgs {
26
- client: HindsightLikeClient;
27
- bankId: string;
28
- /** Extra tags merged onto each page (e.g. source:pi, project:<id>). */
29
- baseTags?: string[];
30
- dryRun?: boolean;
31
- /** Override seed list (tests). */
32
- seeds?: readonly KnowledgePageSeed[];
33
- }
34
-
35
- export interface SeedKnowledgePagesResult {
36
- bankId: string;
37
- dryRun: boolean;
38
- available: boolean;
39
- reason?: typeof KNOWLEDGE_PAGES_UNAVAILABLE | "no_create_method";
40
- wouldCreate?: Array<{ name: string; tags: string[] }>;
41
- created: Array<{ name: string; result?: unknown }>;
42
- skippedExisting: string[];
43
- errors: Array<{ name: string; error: string }>;
44
- }
45
-
46
- function isNotFoundOrUnavailable(error: unknown): boolean {
47
- if (error instanceof KnowledgePagesUnavailableError) return true;
48
- if (typeof error !== "object" || !error) return false;
49
- const fields = error as {
50
- status?: unknown;
51
- statusCode?: unknown;
52
- code?: unknown;
53
- message?: unknown;
54
- };
55
- const status = fields.status ?? fields.statusCode;
56
- if (status === 404 || status === 405 || status === 501) return true;
57
- if (fields.code === KNOWLEDGE_PAGES_UNAVAILABLE) return true;
58
- const msg = typeof fields.message === "string" ? fields.message : "";
59
- return /\b404\b|\b405\b|\b501\b|not found|knowledge.?pages?.*(unavail|not support)/i.test(msg);
60
- }
61
-
62
- function collectPageNames(tree: unknown, out = new Set<string>()): Set<string> {
63
- if (!tree) return out;
64
- const nodes = Array.isArray(tree)
65
- ? tree
66
- : typeof tree === "object" && tree !== null
67
- ? ((tree as { roots?: unknown[]; children?: unknown[] }).roots ??
68
- (tree as { children?: unknown[] }).children ??
69
- [])
70
- : [];
71
- for (const node of nodes) {
72
- if (!node || typeof node !== "object") continue;
73
- const rec = node as { kind?: string; name?: string; children?: unknown[] };
74
- if (rec.kind === "page" && typeof rec.name === "string") out.add(rec.name);
75
- if (Array.isArray(rec.children)) collectPageNames(rec.children, out);
76
- }
77
- return out;
78
- }
79
-
80
- /**
81
- * Seed the fixed five-page knowledge taxonomy. Idempotent by page name (skips existing).
82
- * Never throws for capability gaps — returns available:false instead.
83
- */
84
- export async function seedKnowledgePages(
85
- args: SeedKnowledgePagesArgs,
86
- ): Promise<SeedKnowledgePagesResult> {
87
- const dryRun = args.dryRun ?? false;
88
- const seeds = args.seeds ?? KNOWLEDGE_PAGE_SEEDS;
89
- const baseTags = args.baseTags ?? ["source:pi"];
90
- const empty: SeedKnowledgePagesResult = {
91
- bankId: args.bankId,
92
- dryRun,
93
- available: false,
94
- created: [],
95
- skippedExisting: [],
96
- errors: [],
97
- };
98
-
99
- if (!args.client.createKnowledgePage) {
100
- return { ...empty, reason: "no_create_method" };
101
- }
102
-
103
- let existing = new Set<string>();
104
- if (args.client.getKnowledgeBaseTree) {
105
- try {
106
- const tree = await args.client.getKnowledgeBaseTree(args.bankId);
107
- existing = collectPageNames(tree);
108
- } catch (error) {
109
- if (isNotFoundOrUnavailable(error)) {
110
- return { ...empty, reason: KNOWLEDGE_PAGES_UNAVAILABLE };
111
- }
112
- // Tree probe failed for another reason — still try create (best effort).
113
- }
114
- }
115
-
116
- const wouldCreate: Array<{ name: string; tags: string[] }> = [];
117
- const created: Array<{ name: string; result?: unknown }> = [];
118
- const skippedExisting: string[] = [];
119
- const errors: Array<{ name: string; error: string }> = [];
120
-
121
- for (const seed of seeds) {
122
- if (existing.has(seed.name)) {
123
- skippedExisting.push(seed.name);
124
- continue;
125
- }
126
- const tags = [...new Set([...seed.tags, ...baseTags])];
127
- wouldCreate.push({ name: seed.name, tags });
128
- if (dryRun) continue;
129
- try {
130
- const result = await args.client.createKnowledgePage!(
131
- args.bankId,
132
- seed.name,
133
- seed.source_query,
134
- {
135
- tags,
136
- maxTokens: KNOWLEDGE_PAGE_MAX_TOKENS,
137
- trigger: {
138
- mode: "delta",
139
- refreshAfterConsolidation: KNOWLEDGE_PAGE_TRIGGER.refresh_after_consolidation,
140
- factTypes: [...KNOWLEDGE_PAGE_TRIGGER.fact_types],
141
- excludeMentalModels: true,
142
- },
143
- },
144
- );
145
- created.push({ name: seed.name, result });
146
- existing.add(seed.name);
147
- } catch (error) {
148
- if (isNotFoundOrUnavailable(error)) {
149
- return {
150
- bankId: args.bankId,
151
- dryRun,
152
- available: false,
153
- reason: KNOWLEDGE_PAGES_UNAVAILABLE,
154
- wouldCreate,
155
- created,
156
- skippedExisting,
157
- errors,
158
- };
159
- }
160
- errors.push({
161
- name: seed.name,
162
- error: error instanceof Error ? error.message : String(error),
163
- });
164
- }
165
- }
166
-
167
- return {
168
- bankId: args.bankId,
169
- dryRun,
170
- available: true,
171
- ...(dryRun ? { wouldCreate } : {}),
172
- created,
173
- skippedExisting,
174
- errors,
175
- };
176
- }
@@ -1,178 +0,0 @@
1
- /**
2
- * Named retain strategies and knowledge entity-label taxonomy.
3
- *
4
- * Aligned with @vectorize-io/hindsight-coding-agents bank-template practices, adapted for Pi:
5
- * default strategy is conversation (live Pi sessions), not git.
6
- * Pages are seeded separately (knowledge-base API) — not as bare mental_models in the template.
7
- */
8
-
9
- /** Per-strategy retain config accepted by BankTemplateConfig.retain_strategies. */
10
- export type RetainStrategyConfig = {
11
- retain_mission?: string;
12
- retain_extraction_mode?: string;
13
- retain_chunk_size?: number;
14
- retain_custom_instructions?: string;
15
- };
16
-
17
- export const GIT_RETAIN_MISSION =
18
- "You are ingesting a single git commit: its message and its full diff. Extract the concrete " +
19
- "technical DECISION and the CAUSE/INVARIANT it encodes, bound to the specific code entities " +
20
- "(functions, methods, files) and behaviors it changes. Preserve exact identifiers, paths, and " +
21
- "literal values verbatim. Capture both WHAT changed and WHY. Issue/PR references (#123, GH-123) " +
22
- "are load-bearing: keep them VERBATIM in the fact text and emit each as an ENTITY.";
23
-
24
- export const GITLOG_RETAIN_MISSION =
25
- "You are ingesting an aggregated block of git commit MESSAGES ONLY (no diffs) — the project's " +
26
- "recent commit-message history, newest first. Extract the project's INITIATIVES, FEATURES, " +
27
- "ENHANCEMENTS, and notable themes over time. Do NOT extract per-line code detail. Group related " +
28
- "commits into a coherent initiative/theme where messages make that clear; preserve exact " +
29
- "identifiers and issue/PR references VERBATIM and emit each as an ENTITY.";
30
-
31
- export const CONVERSATION_RETAIN_MISSION =
32
- "You are ingesting a developer conversation as a JSONL transcript (one {role, content} turn per line): the " +
33
- "user's requests, the assistant's narration, and compact tool-action turns (name + target only). " +
34
- "It may be a SHORT decision chat or a LONG working session — scale facts to the substance, never " +
35
- "to the message count. Extract the FEWEST facts that capture the OUTCOME: settled DECISIONS and " +
36
- "their exact rules/values (quote literals VERBATIM); concrete CHANGES to specific code entities; " +
37
- "problems and how they were resolved; conventions or invariants established; at most one fact for " +
38
- "a notable REJECTED alternative. CRITICAL: a conversation REVISES itself — record ONLY the FINAL " +
39
- "state as what is in effect; a superseded proposal appears ONLY inside the rejected fact, NEVER as " +
40
- "its own 'decided' fact; if the same setting changes several times keep only the LAST. Do NOT emit " +
41
- "one fact per message or per intermediate proposal. Keep issue/PR references VERBATIM and emit each " +
42
- "as an ENTITY. Do not invent; capture only what was actually settled.";
43
-
44
- export const DOCUMENT_RETAIN_MISSION =
45
- "You are ingesting a standalone document (notes, docs, or structural findings). Extract the " +
46
- "concrete facts, concepts, and structure it describes. Preserve identifiers and paths verbatim.";
47
-
48
- export const PI_RETAIN_STRATEGIES: Record<string, RetainStrategyConfig> = {
49
- git: {
50
- retain_mission: GIT_RETAIN_MISSION,
51
- retain_extraction_mode: "verbose",
52
- },
53
- gitlog: {
54
- retain_mission: GITLOG_RETAIN_MISSION,
55
- retain_extraction_mode: "verbose",
56
- retain_chunk_size: 12_000,
57
- },
58
- conversation: {
59
- retain_mission: CONVERSATION_RETAIN_MISSION,
60
- retain_extraction_mode: "verbose",
61
- retain_chunk_size: 12_000,
62
- },
63
- document: {
64
- retain_mission: DOCUMENT_RETAIN_MISSION,
65
- retain_extraction_mode: "verbose",
66
- retain_chunk_size: 12_000,
67
- },
68
- survey: {
69
- retain_extraction_mode: "custom",
70
- retain_custom_instructions:
71
- "This document belongs to a Hindsight codebase-survey lifecycle. Apply ONE of two rules: " +
72
- "(1) If the content is an internal status marker — it says it is an internal marker, or " +
73
- "merely announces that a survey started/completed — extract NOTHING: return an empty list of facts. " +
74
- "(2) Otherwise the content is survey FINDINGS: extract concrete structural facts (components, " +
75
- "responsibilities, conventions, tech stack), preserving identifiers verbatim.",
76
- retain_chunk_size: 12_000,
77
- },
78
- };
79
-
80
- /** Fixed knowledge-tier entity labels (tag: true → knowledge:<value> on facts). */
81
- export const KNOWLEDGE_ENTITY_LABELS: {
82
- key: string;
83
- type: "multi-values";
84
- optional: boolean;
85
- tag: boolean;
86
- description: string;
87
- values: Array<{ value: string; description: string }>;
88
- } = {
89
- key: "knowledge",
90
- type: "multi-values",
91
- optional: true,
92
- tag: true,
93
- description:
94
- "Routing labels for this project's Hindsight KNOWLEDGE PAGES — curated summaries of durable " +
95
- "engineering knowledge. Mark a fact only when it is durable, reusable knowledge a developer " +
96
- "would still want in future sessions. Leave EMPTY for routine or transient facts. MOST facts " +
97
- "should get no label here.",
98
- values: [
99
- {
100
- value: "feature-work",
101
- description:
102
- "A new feature, initiative, or enhancement being planned or built — not routine bug-fixes.",
103
- },
104
- {
105
- value: "decision",
106
- description: "A technical decision that will constrain future work, with its rationale.",
107
- },
108
- {
109
- value: "convention",
110
- description:
111
- "An established way this project does things — naming, structure, testing, or patterns.",
112
- },
113
- {
114
- value: "component",
115
- description:
116
- "What a module, file, service, or subsystem is responsible for, or how components relate.",
117
- },
118
- {
119
- value: "concept",
120
- description:
121
- "A domain concept, key abstraction, or project vocabulary a contributor must understand.",
122
- },
123
- ],
124
- };
125
-
126
- /** Seed taxonomy for knowledge pages (used by knowledge seed path; not bare mental models). */
127
- export interface KnowledgePageSeed {
128
- name: string;
129
- source_query: string;
130
- tags: string[];
131
- }
132
-
133
- export const KNOWLEDGE_PAGE_SEEDS: readonly KnowledgePageSeed[] = [
134
- {
135
- name: "Component map",
136
- source_query:
137
- "From this project's commit history and past discussions, what are the main " +
138
- "components/modules/subsystems, what is each responsible for, and how do they relate?",
139
- tags: ["knowledge:component"],
140
- },
141
- {
142
- name: "Core concepts",
143
- source_query:
144
- "What are the core concepts, domain abstractions, and key entities in this project — " +
145
- "the vocabulary a developer must understand?",
146
- tags: ["knowledge:concept"],
147
- },
148
- {
149
- name: "Conventions and patterns",
150
- source_query:
151
- "What conventions, idioms, and recurring patterns does this project follow — testing, " +
152
- "error handling, naming, structure, and how changes are typically made?",
153
- tags: ["knowledge:convention"],
154
- },
155
- {
156
- name: "Key decisions and rationale",
157
- source_query:
158
- "What are the significant technical decisions made in this project and the rationale " +
159
- "behind them — the durable 'why we do it this way' a developer should know?",
160
- tags: ["knowledge:decision"],
161
- },
162
- {
163
- name: "Initiatives and enhancements",
164
- source_query:
165
- "Based on this repository's history and discussions, what are the major initiatives, " +
166
- "features, and enhancements the project has worked on? Summarize themes over time.",
167
- tags: ["knowledge:feature-work"],
168
- },
169
- ] as const;
170
-
171
- export const KNOWLEDGE_PAGE_MAX_TOKENS = 4096;
172
- export const KNOWLEDGE_PAGE_TRIGGER = {
173
- fact_types: ["world", "experience", "observation"] as const,
174
- refresh_after_consolidation: true,
175
- };
176
-
177
- /** Default strategy for live Pi session retains. */
178
- export const LIVE_SESSION_RETAIN_STRATEGY = "conversation" as const;
@@ -1,41 +0,0 @@
1
- export interface HindsightRestError extends Error {
2
- status?: number;
3
- body?: unknown;
4
- }
5
-
6
- export function isRetryableError(error: unknown): boolean {
7
- if (!(error instanceof Error)) return false;
8
- const status =
9
- (error as HindsightRestError).status ?? (error as { statusCode?: number }).statusCode;
10
- if (typeof status === "number" && status >= 500) return true;
11
- if (error.message.includes("timed out")) return true;
12
- if (error.message.includes("fetch failed")) return true;
13
- if (error.message.includes("ECONNREFUSED")) return true;
14
- if (error.message.includes("ENOTFOUND")) return true;
15
- if (error.message.includes("ETIMEDOUT")) return true;
16
- if (error.message.includes("ECONNRESET")) return true;
17
- return false;
18
- }
19
-
20
- export async function withRetry<T>(
21
- operation: string,
22
- fn: () => Promise<T>,
23
- maxRetries = 3,
24
- baseDelayMs = 1000,
25
- ): Promise<T> {
26
- let lastError: Error | undefined;
27
- for (let attempt = 0; attempt <= maxRetries; attempt++) {
28
- if (attempt > 0) {
29
- const jitter = Math.random() * baseDelayMs * 0.5;
30
- const delay = baseDelayMs * 2 ** (attempt - 1) + jitter;
31
- await new Promise((resolve) => setTimeout(resolve, delay));
32
- }
33
- try {
34
- return await fn();
35
- } catch (error) {
36
- if (!isRetryableError(error)) throw error;
37
- lastError = error as Error;
38
- }
39
- }
40
- throw lastError ?? new Error(`${operation} failed after retries`);
41
- }