@cchistory/lite 0.8.2 → 0.9.0

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 (296) hide show
  1. package/INSTALL.md +1 -1
  2. package/apps/lite-cli/dist/agent-contract.d.ts.map +1 -1
  3. package/apps/lite-cli/dist/agent-contract.js +28 -7
  4. package/apps/lite-cli/dist/agent-contract.js.map +1 -1
  5. package/apps/lite-cli/dist/help.d.ts.map +1 -1
  6. package/apps/lite-cli/dist/help.js +4 -2
  7. package/apps/lite-cli/dist/help.js.map +1 -1
  8. package/apps/lite-cli/dist/index.d.ts.map +1 -1
  9. package/apps/lite-cli/dist/index.js +76 -3
  10. package/apps/lite-cli/dist/index.js.map +1 -1
  11. package/apps/lite-cli/dist/index.test.js +3 -2
  12. package/apps/lite-cli/dist/index.test.js.map +1 -1
  13. package/apps/lite-cli/dist/json-v2.d.ts.map +1 -1
  14. package/apps/lite-cli/dist/json-v2.js +25 -0
  15. package/apps/lite-cli/dist/json-v2.js.map +1 -1
  16. package/apps/lite-cli/dist/query.d.ts +24 -2
  17. package/apps/lite-cli/dist/query.d.ts.map +1 -1
  18. package/apps/lite-cli/dist/query.js +204 -7
  19. package/apps/lite-cli/dist/query.js.map +1 -1
  20. package/apps/lite-cli/dist/shell.js +24 -1
  21. package/apps/lite-cli/dist/shell.js.map +1 -1
  22. package/apps/lite-cli/dist/stats-command.d.ts +7 -1
  23. package/apps/lite-cli/dist/stats-command.d.ts.map +1 -1
  24. package/apps/lite-cli/dist/stats-command.js +77 -13
  25. package/apps/lite-cli/dist/stats-command.js.map +1 -1
  26. package/apps/lite-cli/dist/stats-diagnostics-render.d.ts +21 -0
  27. package/apps/lite-cli/dist/stats-diagnostics-render.d.ts.map +1 -0
  28. package/apps/lite-cli/dist/stats-diagnostics-render.js +245 -0
  29. package/apps/lite-cli/dist/stats-diagnostics-render.js.map +1 -0
  30. package/apps/lite-cli/dist/stats-render.d.ts +8 -1
  31. package/apps/lite-cli/dist/stats-render.d.ts.map +1 -1
  32. package/apps/lite-cli/dist/stats-render.js +39 -5
  33. package/apps/lite-cli/dist/stats-render.js.map +1 -1
  34. package/apps/lite-cli/dist/stats-visuals.d.ts +11 -0
  35. package/apps/lite-cli/dist/stats-visuals.d.ts.map +1 -1
  36. package/apps/lite-cli/dist/stats-visuals.js +94 -0
  37. package/apps/lite-cli/dist/stats-visuals.js.map +1 -1
  38. package/apps/lite-cli/dist/trace-command.d.ts +28 -0
  39. package/apps/lite-cli/dist/trace-command.d.ts.map +1 -0
  40. package/apps/lite-cli/dist/trace-command.js +394 -0
  41. package/apps/lite-cli/dist/trace-command.js.map +1 -0
  42. package/apps/lite-cli/dist/trace-command.test.d.ts +2 -0
  43. package/apps/lite-cli/dist/trace-command.test.d.ts.map +1 -0
  44. package/apps/lite-cli/dist/trace-command.test.js +374 -0
  45. package/apps/lite-cli/dist/trace-command.test.js.map +1 -0
  46. package/apps/lite-cli/dist/version.d.ts +1 -1
  47. package/apps/lite-cli/dist/version.js +1 -1
  48. package/apps/lite-tui/dist/input.d.ts.map +1 -1
  49. package/apps/lite-tui/dist/input.js +37 -2
  50. package/apps/lite-tui/dist/input.js.map +1 -1
  51. package/apps/lite-tui/dist/model.d.ts +11 -1
  52. package/apps/lite-tui/dist/model.d.ts.map +1 -1
  53. package/apps/lite-tui/dist/model.js +27 -0
  54. package/apps/lite-tui/dist/model.js.map +1 -1
  55. package/apps/lite-tui/dist/render.d.ts +1 -1
  56. package/apps/lite-tui/dist/render.d.ts.map +1 -1
  57. package/apps/lite-tui/dist/render.js +9 -4
  58. package/apps/lite-tui/dist/render.js.map +1 -1
  59. package/apps/lite-tui/dist/state.d.ts +4 -0
  60. package/apps/lite-tui/dist/state.d.ts.map +1 -1
  61. package/apps/lite-tui/dist/state.js +75 -3
  62. package/apps/lite-tui/dist/state.js.map +1 -1
  63. package/apps/lite-tui/dist/stats-anomalies-render.d.ts +11 -0
  64. package/apps/lite-tui/dist/stats-anomalies-render.d.ts.map +1 -0
  65. package/apps/lite-tui/dist/stats-anomalies-render.js +231 -0
  66. package/apps/lite-tui/dist/stats-anomalies-render.js.map +1 -0
  67. package/apps/lite-tui/dist/stats-dashboard.test.js +124 -0
  68. package/apps/lite-tui/dist/stats-dashboard.test.js.map +1 -1
  69. package/apps/lite-tui/dist/stats-matrix-render.js +1 -1
  70. package/apps/lite-tui/dist/stats-matrix-render.js.map +1 -1
  71. package/apps/lite-tui/dist/stats-query.d.ts.map +1 -1
  72. package/apps/lite-tui/dist/stats-query.js +16 -0
  73. package/apps/lite-tui/dist/stats-query.js.map +1 -1
  74. package/apps/lite-tui/dist/stats-render.d.ts.map +1 -1
  75. package/apps/lite-tui/dist/stats-render.js +48 -15
  76. package/apps/lite-tui/dist/stats-render.js.map +1 -1
  77. package/apps/lite-tui/dist/stats-state.d.ts +34 -3
  78. package/apps/lite-tui/dist/stats-state.d.ts.map +1 -1
  79. package/apps/lite-tui/dist/stats-state.js +78 -1
  80. package/apps/lite-tui/dist/stats-state.js.map +1 -1
  81. package/apps/lite-tui/dist/stats-trace-render.d.ts +9 -0
  82. package/apps/lite-tui/dist/stats-trace-render.d.ts.map +1 -0
  83. package/apps/lite-tui/dist/stats-trace-render.js +213 -0
  84. package/apps/lite-tui/dist/stats-trace-render.js.map +1 -0
  85. package/apps/lite-tui/dist/stats-visuals.d.ts.map +1 -1
  86. package/apps/lite-tui/dist/stats-visuals.js +9 -3
  87. package/apps/lite-tui/dist/stats-visuals.js.map +1 -1
  88. package/apps/lite-tui/dist/version.d.ts +1 -1
  89. package/apps/lite-tui/dist/version.js +1 -1
  90. package/docs/guide/for-agents.md +6 -1
  91. package/docs/guide/lite.md +8 -2
  92. package/docs/guide/queries/anomaly-calls.sql +18 -0
  93. package/docs/guide/query.md +9 -4
  94. package/node_modules/@cchistory/canonical/dist/index.d.ts +3 -0
  95. package/node_modules/@cchistory/canonical/dist/index.d.ts.map +1 -1
  96. package/node_modules/@cchistory/canonical/dist/index.js +3 -0
  97. package/node_modules/@cchistory/canonical/dist/index.js.map +1 -1
  98. package/node_modules/@cchistory/canonical/dist/model-pricing-catalog.d.ts +2 -2
  99. package/node_modules/@cchistory/canonical/dist/model-pricing-catalog.d.ts.map +1 -1
  100. package/node_modules/@cchistory/canonical/dist/model-pricing-catalog.js +3 -3
  101. package/node_modules/@cchistory/canonical/dist/model-pricing-catalog.js.map +1 -1
  102. package/node_modules/@cchistory/canonical/dist/query.d.ts +4 -1
  103. package/node_modules/@cchistory/canonical/dist/query.d.ts.map +1 -1
  104. package/node_modules/@cchistory/canonical/dist/query.js +130 -1
  105. package/node_modules/@cchistory/canonical/dist/query.js.map +1 -1
  106. package/node_modules/@cchistory/canonical/dist/session-interpreter.d.ts.map +1 -1
  107. package/node_modules/@cchistory/canonical/dist/session-interpreter.js +21 -13
  108. package/node_modules/@cchistory/canonical/dist/session-interpreter.js.map +1 -1
  109. package/node_modules/@cchistory/canonical/dist/tool-call-summary.d.ts +32 -0
  110. package/node_modules/@cchistory/canonical/dist/tool-call-summary.d.ts.map +1 -0
  111. package/node_modules/@cchistory/canonical/dist/tool-call-summary.js +507 -0
  112. package/node_modules/@cchistory/canonical/dist/tool-call-summary.js.map +1 -0
  113. package/node_modules/@cchistory/canonical/dist/usage-anomalies.d.ts +27 -0
  114. package/node_modules/@cchistory/canonical/dist/usage-anomalies.d.ts.map +1 -0
  115. package/node_modules/@cchistory/canonical/dist/usage-anomalies.js +385 -0
  116. package/node_modules/@cchistory/canonical/dist/usage-anomalies.js.map +1 -0
  117. package/node_modules/@cchistory/canonical/dist/usage-breakdown.d.ts.map +1 -1
  118. package/node_modules/@cchistory/canonical/dist/usage-breakdown.js +10 -2
  119. package/node_modules/@cchistory/canonical/dist/usage-breakdown.js.map +1 -1
  120. package/node_modules/@cchistory/canonical/dist/usage-call-evaluation.d.ts +41 -0
  121. package/node_modules/@cchistory/canonical/dist/usage-call-evaluation.d.ts.map +1 -0
  122. package/node_modules/@cchistory/canonical/dist/usage-call-evaluation.js +333 -0
  123. package/node_modules/@cchistory/canonical/dist/usage-call-evaluation.js.map +1 -0
  124. package/node_modules/@cchistory/canonical/dist/usage-diagnostics.d.ts +2 -2
  125. package/node_modules/@cchistory/canonical/dist/usage-diagnostics.d.ts.map +1 -1
  126. package/node_modules/@cchistory/canonical/dist/usage-diagnostics.js +46 -2
  127. package/node_modules/@cchistory/canonical/dist/usage-diagnostics.js.map +1 -1
  128. package/node_modules/@cchistory/canonical/dist/usage-pricing.test.js +76 -0
  129. package/node_modules/@cchistory/canonical/dist/usage-pricing.test.js.map +1 -1
  130. package/node_modules/@cchistory/canonical/dist/usage-tool-patterns.d.ts +14 -0
  131. package/node_modules/@cchistory/canonical/dist/usage-tool-patterns.d.ts.map +1 -0
  132. package/node_modules/@cchistory/canonical/dist/usage-tool-patterns.js +243 -0
  133. package/node_modules/@cchistory/canonical/dist/usage-tool-patterns.js.map +1 -0
  134. package/node_modules/@cchistory/canonical/dist/usage-trace.d.ts +18 -0
  135. package/node_modules/@cchistory/canonical/dist/usage-trace.d.ts.map +1 -0
  136. package/node_modules/@cchistory/canonical/dist/usage-trace.js +407 -0
  137. package/node_modules/@cchistory/canonical/dist/usage-trace.js.map +1 -0
  138. package/node_modules/@cchistory/canonical/dist/usage-trace.test.d.ts +2 -0
  139. package/node_modules/@cchistory/canonical/dist/usage-trace.test.d.ts.map +1 -0
  140. package/node_modules/@cchistory/canonical/dist/usage-trace.test.js +419 -0
  141. package/node_modules/@cchistory/canonical/dist/usage-trace.test.js.map +1 -0
  142. package/node_modules/@cchistory/canonical/dist/usage.d.ts +13 -1
  143. package/node_modules/@cchistory/canonical/dist/usage.d.ts.map +1 -1
  144. package/node_modules/@cchistory/canonical/dist/usage.js +36 -3
  145. package/node_modules/@cchistory/canonical/dist/usage.js.map +1 -1
  146. package/node_modules/@cchistory/canonical/package.json +1 -1
  147. package/node_modules/@cchistory/domain/dist/index.d.ts +17 -1
  148. package/node_modules/@cchistory/domain/dist/index.d.ts.map +1 -1
  149. package/node_modules/@cchistory/domain/dist/index.js +1 -0
  150. package/node_modules/@cchistory/domain/dist/index.js.map +1 -1
  151. package/node_modules/@cchistory/domain/dist/index.test.js +10 -1
  152. package/node_modules/@cchistory/domain/dist/index.test.js.map +1 -1
  153. package/node_modules/@cchistory/domain/dist/query.d.ts +1 -1
  154. package/node_modules/@cchistory/domain/dist/query.d.ts.map +1 -1
  155. package/node_modules/@cchistory/domain/dist/token-evidence.d.ts.map +1 -1
  156. package/node_modules/@cchistory/domain/dist/token-evidence.js +3 -1
  157. package/node_modules/@cchistory/domain/dist/token-evidence.js.map +1 -1
  158. package/node_modules/@cchistory/domain/dist/usage-pricing.d.ts +9 -0
  159. package/node_modules/@cchistory/domain/dist/usage-pricing.d.ts.map +1 -1
  160. package/node_modules/@cchistory/domain/dist/usage-trace.d.ts +245 -0
  161. package/node_modules/@cchistory/domain/dist/usage-trace.d.ts.map +1 -0
  162. package/node_modules/@cchistory/domain/dist/usage-trace.js +8 -0
  163. package/node_modules/@cchistory/domain/dist/usage-trace.js.map +1 -0
  164. package/node_modules/@cchistory/domain/package.json +1 -1
  165. package/node_modules/@cchistory/live-runtime/dist/index.d.ts +13 -4
  166. package/node_modules/@cchistory/live-runtime/dist/index.d.ts.map +1 -1
  167. package/node_modules/@cchistory/live-runtime/dist/index.js +78 -3
  168. package/node_modules/@cchistory/live-runtime/dist/index.js.map +1 -1
  169. package/node_modules/@cchistory/live-runtime/dist/index.test.js +274 -44
  170. package/node_modules/@cchistory/live-runtime/dist/index.test.js.map +1 -1
  171. package/node_modules/@cchistory/live-runtime/dist/sql-query.d.ts.map +1 -1
  172. package/node_modules/@cchistory/live-runtime/dist/sql-query.js +3 -2
  173. package/node_modules/@cchistory/live-runtime/dist/sql-query.js.map +1 -1
  174. package/node_modules/@cchistory/live-runtime/dist/sql-query.test.js +46 -2
  175. package/node_modules/@cchistory/live-runtime/dist/sql-query.test.js.map +1 -1
  176. package/node_modules/@cchistory/live-runtime/package.json +1 -1
  177. package/node_modules/@cchistory/source-adapters/dist/core/conversation-seeds.d.ts +3 -0
  178. package/node_modules/@cchistory/source-adapters/dist/core/conversation-seeds.d.ts.map +1 -1
  179. package/node_modules/@cchistory/source-adapters/dist/core/conversation-seeds.js.map +1 -1
  180. package/node_modules/@cchistory/source-adapters/dist/core/discovery.d.ts.map +1 -1
  181. package/node_modules/@cchistory/source-adapters/dist/core/discovery.js +60 -4
  182. package/node_modules/@cchistory/source-adapters/dist/core/discovery.js.map +1 -1
  183. package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts +1 -1
  184. package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts.map +1 -1
  185. package/node_modules/@cchistory/source-adapters/dist/core/parser.js +201 -3
  186. package/node_modules/@cchistory/source-adapters/dist/core/parser.js.map +1 -1
  187. package/node_modules/@cchistory/source-adapters/dist/core/probe.d.ts.map +1 -1
  188. package/node_modules/@cchistory/source-adapters/dist/core/probe.js +85 -5
  189. package/node_modules/@cchistory/source-adapters/dist/core/probe.js.map +1 -1
  190. package/node_modules/@cchistory/source-adapters/dist/core/registry.test.js +17 -1
  191. package/node_modules/@cchistory/source-adapters/dist/core/registry.test.js.map +1 -1
  192. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.d.ts.map +1 -1
  193. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.js +44 -0
  194. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.js.map +1 -1
  195. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.d.ts.map +1 -1
  196. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js +12 -0
  197. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js.map +1 -1
  198. package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts +4 -0
  199. package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts.map +1 -1
  200. package/node_modules/@cchistory/source-adapters/dist/index.test.js +4 -0
  201. package/node_modules/@cchistory/source-adapters/dist/index.test.js.map +1 -1
  202. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/sqlite.d.ts.map +1 -1
  203. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/sqlite.js +21 -7
  204. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/sqlite.js.map +1 -1
  205. package/node_modules/@cchistory/source-adapters/dist/platforms/claude-code/runtime.d.ts.map +1 -1
  206. package/node_modules/@cchistory/source-adapters/dist/platforms/claude-code/runtime.js +18 -2
  207. package/node_modules/@cchistory/source-adapters/dist/platforms/claude-code/runtime.js.map +1 -1
  208. package/node_modules/@cchistory/source-adapters/dist/platforms/codex/runtime.d.ts.map +1 -1
  209. package/node_modules/@cchistory/source-adapters/dist/platforms/codex/runtime.js +22 -1
  210. package/node_modules/@cchistory/source-adapters/dist/platforms/codex/runtime.js.map +1 -1
  211. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.test.js +2 -0
  212. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.test.js.map +1 -1
  213. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness/reader.d.ts +28 -0
  214. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness/reader.d.ts.map +1 -0
  215. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness/reader.js +443 -0
  216. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness/reader.js.map +1 -0
  217. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness/runtime.d.ts +4 -0
  218. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness/runtime.d.ts.map +1 -0
  219. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness/runtime.js +370 -0
  220. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness/runtime.js.map +1 -0
  221. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness.d.ts +3 -0
  222. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness.d.ts.map +1 -0
  223. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness.js +78 -0
  224. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness.js.map +1 -0
  225. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness.test.d.ts +2 -0
  226. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness.test.d.ts.map +1 -0
  227. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness.test.js +313 -0
  228. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness.test.js.map +1 -0
  229. package/node_modules/@cchistory/source-adapters/dist/platforms/generic/runtime.d.ts.map +1 -1
  230. package/node_modules/@cchistory/source-adapters/dist/platforms/generic/runtime.js +26 -1
  231. package/node_modules/@cchistory/source-adapters/dist/platforms/generic/runtime.js.map +1 -1
  232. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes/runtime.d.ts +4 -0
  233. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes/runtime.d.ts.map +1 -0
  234. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes/runtime.js +306 -0
  235. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes/runtime.js.map +1 -0
  236. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes/sqlite.d.ts +8 -0
  237. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes/sqlite.d.ts.map +1 -0
  238. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes/sqlite.js +499 -0
  239. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes/sqlite.js.map +1 -0
  240. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes.d.ts +9 -0
  241. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes.d.ts.map +1 -0
  242. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes.js +53 -0
  243. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes.js.map +1 -0
  244. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes.test.d.ts +2 -0
  245. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes.test.d.ts.map +1 -0
  246. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes.test.js +314 -0
  247. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes.test.js.map +1 -0
  248. package/node_modules/@cchistory/source-adapters/dist/platforms/oh-my-pi.d.ts +9 -0
  249. package/node_modules/@cchistory/source-adapters/dist/platforms/oh-my-pi.d.ts.map +1 -0
  250. package/node_modules/@cchistory/source-adapters/dist/platforms/oh-my-pi.js +84 -0
  251. package/node_modules/@cchistory/source-adapters/dist/platforms/oh-my-pi.js.map +1 -0
  252. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode/sqlite-records.d.ts +50 -0
  253. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode/sqlite-records.d.ts.map +1 -0
  254. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode/sqlite-records.js +291 -0
  255. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode/sqlite-records.js.map +1 -0
  256. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode/sqlite.d.ts +8 -0
  257. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode/sqlite.d.ts.map +1 -0
  258. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode/sqlite.js +321 -0
  259. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode/sqlite.js.map +1 -0
  260. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode-sqlite.test.d.ts +2 -0
  261. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode-sqlite.test.d.ts.map +1 -0
  262. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode-sqlite.test.js +245 -0
  263. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode-sqlite.test.js.map +1 -0
  264. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.d.ts.map +1 -1
  265. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.js +30 -7
  266. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.js.map +1 -1
  267. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family/reader.d.ts +44 -0
  268. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family/reader.d.ts.map +1 -0
  269. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family/reader.js +533 -0
  270. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family/reader.js.map +1 -0
  271. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family/runtime.d.ts +4 -0
  272. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family/runtime.d.ts.map +1 -0
  273. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family/runtime.js +375 -0
  274. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family/runtime.js.map +1 -0
  275. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family.test.d.ts +2 -0
  276. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family.test.d.ts.map +1 -0
  277. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family.test.js +346 -0
  278. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family.test.js.map +1 -0
  279. package/node_modules/@cchistory/source-adapters/dist/platforms/pi.d.ts +8 -0
  280. package/node_modules/@cchistory/source-adapters/dist/platforms/pi.d.ts.map +1 -0
  281. package/node_modules/@cchistory/source-adapters/dist/platforms/pi.js +60 -0
  282. package/node_modules/@cchistory/source-adapters/dist/platforms/pi.js.map +1 -0
  283. package/node_modules/@cchistory/source-adapters/dist/platforms/registry.d.ts.map +1 -1
  284. package/node_modules/@cchistory/source-adapters/dist/platforms/registry.js +8 -0
  285. package/node_modules/@cchistory/source-adapters/dist/platforms/registry.js.map +1 -1
  286. package/node_modules/@cchistory/source-adapters/dist/platforms/types.d.ts +3 -1
  287. package/node_modules/@cchistory/source-adapters/dist/platforms/types.d.ts.map +1 -1
  288. package/node_modules/@cchistory/source-adapters/dist/platforms/types.js +5 -1
  289. package/node_modules/@cchistory/source-adapters/dist/platforms/types.js.map +1 -1
  290. package/node_modules/@cchistory/source-adapters/package.json +1 -1
  291. package/package.json +5 -5
  292. package/schemas/cchistory-lite-agent-v1.schema.json +2 -1
  293. package/schemas/cchistory-lite-query-result-v2.schema.json +3 -1
  294. package/schemas/cchistory-lite-query-v2.schema.json +41 -1
  295. package/schemas/cchistory-lite-v2.schema.json +1 -1
  296. package/skills/using-cchistory-lite/SKILL.md +17 -0
@@ -1,4 +1,4 @@
1
- import { buildConversationEvidence, interpretSessionEvidence } from "@cchistory/canonical";
1
+ import { buildConversationEvidence, executeCanonicalQuery, interpretSessionEvidence } from "@cchistory/canonical";
2
2
  import assert from "node:assert/strict";
3
3
  import { access, appendFile, copyFile, mkdir, mkdtemp, readFile, rm, stat, symlink, utimes, writeFile } from "node:fs/promises";
4
4
  import { DatabaseSync } from "node:sqlite";
@@ -8,7 +8,7 @@ import test from "node:test";
8
8
  import { fileURLToPath } from "node:url";
9
9
  import { buildProjectDisplayList } from "@cchistory/canonical";
10
10
  import { listPlatformAdapters, runSourceProbe } from "@cchistory/source-adapters";
11
- import { assertLiteSourceRoot, buildLiveSnapshot, LiveHistorySnapshot, maskCompactPreview, resolveLiteSources, scanLiteHistory, } from "./index.js";
11
+ import { assertLiteSourceRoot, buildLiveSnapshot, compileSql, LiveHistorySnapshot, maskCompactPreview, resolveLiteSources, scanLiteHistory, } from "./index.js";
12
12
  import { SAMPLE_RANK_CONCURRENCY, mapPool } from "./async-pool.js";
13
13
  import { settleLauncherExit } from "./bootstrap.js";
14
14
  const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../..");
@@ -28,6 +28,10 @@ const fixtureRoots = {
28
28
  cursor_agent: "fixtures/cursor-agent",
29
29
  grok: "fixtures/grok-cli",
30
30
  grok_bot: "fixtures/grok-bot",
31
+ deepseek_harness: ".deepseek-harness/sessions",
32
+ hermes: "fixtures/hermes",
33
+ pi: ".pi/agent/sessions",
34
+ oh_my_pi: ".omp/agent/sessions",
31
35
  };
32
36
  test("Codex accounting keeps text-less calls, compactions and call timestamps in every stats dimension", async () => {
33
37
  const snapshot = await scanLiteHistory({
@@ -152,14 +156,14 @@ test("compact family I/O previews mask secrets before the 240-character cut", ()
152
156
  test("Lite materializer resolves canonical history across the fixture-backed adapter matrix", async () => {
153
157
  const tempStore = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-matrix-"));
154
158
  try {
159
+ // SQL-backed sources (Hermes/ZCode) and profile trees need materialized
160
+ // roots; this matrix covers every registered adapter, not just file fixtures.
161
+ const matrixRoots = await prepareContextFixtureRoots(tempStore);
155
162
  const sources = await resolveLiteSources({
156
163
  homeDir: path.join(tempStore, "empty-home"),
157
164
  hostname: "cchistory-lite-matrix-host",
158
- sourceRefs: Object.keys(fixtureRoots),
159
- sourceRoots: Object.entries(fixtureRoots).map(([sourceRef, relativePath]) => ({
160
- sourceRef,
161
- baseDir: path.join(mockDataRoot, relativePath),
162
- })),
165
+ sourceRefs: Object.keys(matrixRoots),
166
+ sourceRoots: Object.entries(matrixRoots).map(([sourceRef, baseDir]) => ({ sourceRef, baseDir })),
163
167
  });
164
168
  const probe = await runSourceProbe(interpretSessionEvidence, { safe_mode: true }, sources);
165
169
  const askPayload = probe.sources.find((payload) => payload.source.platform === "codex");
@@ -214,9 +218,12 @@ test("Lite materializer resolves canonical history across the fixture-backed ada
214
218
  const lite = buildLiveSnapshot(probe);
215
219
  assert.deepEqual(lite.projectionIssues, [], "the complete adapter matrix must satisfy the canonical projection contract");
216
220
  // Every registered adapter in the matrix materializes into the live snapshot.
217
- assert.deepEqual(sortById(lite.listSources()).map((source) => source.platform).sort(), Object.keys(fixtureRoots).sort());
221
+ assert.deepEqual(sortById(lite.listSources()).map((source) => source.platform).sort(), Object.keys(matrixRoots).sort());
218
222
  assert.ok(lite.listResolvedSessions().length > 0);
219
223
  assert.ok(lite.listResolvedTurns().length > 0);
224
+ for (const sourceRef of Object.keys(matrixRoots)) {
225
+ assert.ok(lite.listResolvedSessions().some((session) => session.source_platform === sourceRef), `${sourceRef} must contribute a nonempty session to the fixture matrix`);
226
+ }
220
227
  let previousMessageAt;
221
228
  let reachedTurnlessSessions = false;
222
229
  for (const session of lite.listResolvedSessions()) {
@@ -280,36 +287,42 @@ test("Lite materializer resolves canonical history across the fixture-backed ada
280
287
  }
281
288
  });
282
289
  test("Lite targeted probes preserve one-session parity across the fixture adapter matrix", async () => {
283
- for (const [sourceRef, relativePath] of Object.entries(fixtureRoots)) {
284
- const scanOptions = {
285
- homeDir: path.join(mockDataRoot, "empty-home"),
286
- hostname: `cchistory-lite-target-matrix-${sourceRef}`,
287
- sourceRefs: [sourceRef],
288
- sourceRoots: [{ sourceRef, baseDir: path.join(mockDataRoot, relativePath) }],
289
- safeMode: true,
290
- };
291
- const full = await scanLiteHistory({ ...scanOptions, contextMode: "full" });
292
- const target = full.listResolvedSessions().find((session) => session.source_session_id);
293
- if (!target?.source_session_id)
294
- continue;
295
- const targeted = await scanLiteHistory({
296
- ...scanOptions,
297
- contextMode: "full",
298
- sessionRefs: [target.source_session_id],
299
- });
300
- const expectedSessionIds = new Set([
301
- target.id,
302
- ...full.listDelegatedChildren(target.id)
303
- .map((child) => child.child_session_ref)
304
- .filter((id) => id !== undefined),
305
- ]);
306
- assert.deepEqual(targeted.listResolvedSessions().map(targetSessionParityFields), full.listResolvedSessions().filter((session) => expectedSessionIds.has(session.id)).map(targetSessionParityFields), `${sourceRef} session parity`);
307
- assert.equal(targeted.listTopLevelSessions().some((session) => session.id !== target.id && expectedSessionIds.has(session.id)), false, `${sourceRef} delegated children stay out of top-level collections`);
308
- assert.deepEqual(targeted.listResolvedTurns().map(targetTurnParityFields), full.listResolvedTurns().filter((turn) => expectedSessionIds.has(turn.session_id)).map(targetTurnParityFields), `${sourceRef} turn parity`);
309
- const targetTurnIds = new Set(full.listResolvedTurns()
310
- .filter((turn) => expectedSessionIds.has(turn.session_id))
311
- .map((turn) => turn.id));
312
- assert.deepEqual(targeted.data.contexts.map(targetContextParityFields), full.data.contexts.filter((context) => targetTurnIds.has(context.turn_id)).map(targetContextParityFields), `${sourceRef} context parity`);
290
+ const targetMatrixScratch = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-target-matrix-"));
291
+ try {
292
+ const targetRoots = await prepareContextFixtureRoots(targetMatrixScratch);
293
+ for (const [sourceRef, baseDir] of Object.entries(targetRoots)) {
294
+ const scanOptions = {
295
+ homeDir: path.join(mockDataRoot, "empty-home"),
296
+ hostname: `cchistory-lite-target-matrix-${sourceRef}`,
297
+ sourceRefs: [sourceRef],
298
+ sourceRoots: [{ sourceRef, baseDir }],
299
+ safeMode: true,
300
+ };
301
+ const full = await scanLiteHistory({ ...scanOptions, contextMode: "full" });
302
+ const target = full.listResolvedSessions().find((session) => session.source_session_id);
303
+ assert.ok(target?.source_session_id, `${sourceRef} needs an addressable session for targeted parity`);
304
+ const targeted = await scanLiteHistory({
305
+ ...scanOptions,
306
+ contextMode: "full",
307
+ sessionRefs: [target.source_session_id],
308
+ });
309
+ const expectedSessionIds = new Set([
310
+ target.id,
311
+ ...full.listDelegatedChildren(target.id)
312
+ .map((child) => child.child_session_ref)
313
+ .filter((id) => id !== undefined),
314
+ ]);
315
+ assert.deepEqual(targeted.listResolvedSessions().map(targetSessionParityFields), full.listResolvedSessions().filter((session) => expectedSessionIds.has(session.id)).map(targetSessionParityFields), `${sourceRef} session parity`);
316
+ assert.equal(targeted.listTopLevelSessions().some((session) => session.id !== target.id && expectedSessionIds.has(session.id)), false, `${sourceRef} delegated children stay out of top-level collections`);
317
+ assert.deepEqual(targeted.listResolvedTurns().map(targetTurnParityFields), full.listResolvedTurns().filter((turn) => expectedSessionIds.has(turn.session_id)).map(targetTurnParityFields), `${sourceRef} turn parity`);
318
+ const targetTurnIds = new Set(full.listResolvedTurns()
319
+ .filter((turn) => expectedSessionIds.has(turn.session_id))
320
+ .map((turn) => turn.id));
321
+ assert.deepEqual(targeted.data.contexts.map(targetContextParityFields), full.data.contexts.filter((context) => targetTurnIds.has(context.turn_id)).map(targetContextParityFields), `${sourceRef} context parity`);
322
+ }
323
+ }
324
+ finally {
325
+ await rm(targetMatrixScratch, { recursive: true, force: true });
313
326
  }
314
327
  });
315
328
  test("every logical-session projection boundary preserves source-wide canonical parity", async () => {
@@ -547,6 +560,7 @@ test("Lite scans explicit roots without creating or reading a Full store", async
547
560
  }), /not a single project folder/);
548
561
  const resolved = await resolveLiteSources({
549
562
  homeDir: tempHome,
563
+ env: {},
550
564
  sourceRoots: [
551
565
  { sourceRef: "codex", baseDir: path.join(mockDataRoot, ".codex", "sessions") },
552
566
  ],
@@ -992,6 +1006,15 @@ async function prepareContextFixtureRoots(scratch) {
992
1006
  const kimiMain = path.join(kimiSession, "agents", "main");
993
1007
  const zcode = path.join(scratch, ".zcode");
994
1008
  const zcodeDb = path.join(zcode, "cli", "db");
1009
+ const hermes = path.join(scratch, "hermes");
1010
+ await mkdir(hermes, { recursive: true });
1011
+ const hermesDb = new DatabaseSync(path.join(hermes, "state.db"));
1012
+ try {
1013
+ hermesDb.exec(await readFile(path.join(mockDataRoot, "fixtures/hermes/state.sql"), "utf8"));
1014
+ }
1015
+ finally {
1016
+ hermesDb.close();
1017
+ }
995
1018
  await mkdir(geminiChats, { recursive: true });
996
1019
  await mkdir(kimiMain, { recursive: true });
997
1020
  await mkdir(zcodeDb, { recursive: true });
@@ -1013,6 +1036,7 @@ async function prepareContextFixtureRoots(scratch) {
1013
1036
  lobechat: path.join(fixtures, "lobechat"),
1014
1037
  kimi,
1015
1038
  zcode,
1039
+ hermes,
1016
1040
  };
1017
1041
  }
1018
1042
  test("compact queries retain assistant usage and errors without expanding body search", async (t) => {
@@ -1047,17 +1071,19 @@ test("compact queries retain assistant usage and errors without expanding body s
1047
1071
  assert.equal(toolOnly.context_summary.assistant_reply_count, 0);
1048
1072
  assert.equal(toolOnly.context_summary.tool_call_count, 1);
1049
1073
  assert.equal(toolOnly.context_summary.zero_token_reason, "no_assistant_reply");
1050
- // Preserve this known limitation during structural changes. Correcting unanchored
1051
- // token signals is a separate usage-semantics change, not a detail optimization.
1052
- assert.equal(toolOnly.context_summary.total_tokens, undefined);
1074
+ // Claude Code now emits independent per-call usage events, so tool-only turns
1075
+ // preserve their native API call tokens instead of dropping them.
1076
+ assert.equal(toolOnly.context_summary.total_tokens, 8);
1077
+ assert.equal(session.usage_events?.length, 5);
1053
1078
  assert.equal(unanswered.context_summary.zero_token_reason, "no_assistant_reply");
1054
1079
  assert.equal(unanswered.context_summary.tool_call_count, 0);
1055
1080
  assert.notEqual(unanswered.project_id, answered.project_id);
1056
1081
  assert.equal(compact.getSession(unanswered.session_id)?.title, session.title);
1057
- // The current Claude parser omits the native is_error flag from tool-result
1058
- // atoms. Assistant stop errors must not silently become family tool errors.
1059
- assert.equal(compact.getSessionContribution(session.id)?.stats.tool_error_count, 0);
1082
+ // The Claude parser preserves native tool_result.is_error (1 error on call-1),
1083
+ // while assistant stop_reason: "error" stays separate and does not inflate tool_error_count.
1084
+ assert.equal(compact.getSessionContribution(session.id)?.stats.tool_error_count, 1);
1060
1085
  assert.equal(compact.getTurnUsage(answered.id)?.total_tokens, 32);
1086
+ assert.equal(compact.getTurnUsage(toolOnly.id)?.total_tokens, 8);
1061
1087
  assert.equal(compact.getTurnContext(unanswered.id), undefined);
1062
1088
  assert.deepEqual(full.getTurnContext(unanswered.id)?.assistant_replies, []);
1063
1089
  for (const target of [answered, unanswered]) {
@@ -2098,5 +2124,209 @@ test("Codex inherited embedded usage stays on the parent while child calls remai
2098
2124
  const child = snapshot.listResolvedSessions().find(session => session.source_session_id === "codex-delegation-child");
2099
2125
  assert.equal(child.turn_count, 0);
2100
2126
  assert.deepEqual(child.usage_events.map(event => [event.turn_id, event.token_usage.total_tokens]), [[null, 11]]);
2127
+ assert.equal(snapshot.getSessionTrace({ sessionRef: child.id, filters: { timezone: "UTC" } })?.usage_granularity, "call", "turn-less per-call delegated children must keep call granularity");
2128
+ });
2129
+ test("OpenCode SQLite stores project v1 and v2 sessions without projection issues", async () => {
2130
+ const root = await mkdtemp(path.join(os.tmpdir(), "cchistory-opencode-sqlite-"));
2131
+ try {
2132
+ const fixtureSql = await readFile(path.join(mockDataRoot, "fixtures/opencode-sqlite/v2.sql"), "utf8");
2133
+ const db = new DatabaseSync(path.join(root, "opencode.db"));
2134
+ try {
2135
+ db.exec(fixtureSql);
2136
+ }
2137
+ finally {
2138
+ db.close();
2139
+ }
2140
+ const snapshot = await scanLiteHistory({
2141
+ homeDir: path.join(mockDataRoot, "empty-home"),
2142
+ sourceRefs: ["opencode"],
2143
+ sourceRoots: [{ sourceRef: "opencode", baseDir: root }],
2144
+ contextMode: "none",
2145
+ });
2146
+ assert.deepEqual(snapshot.projectionIssues, []);
2147
+ assert.equal(snapshot.listResolvedSessions().length, 1);
2148
+ const turns = snapshot.listResolvedTurns();
2149
+ assert.equal(turns.length, 1);
2150
+ assert.equal(turns[0]?.canonical_text, "Compare the two OpenCode storage generations.");
2151
+ const overview = snapshot.getUsageOverview({ timezone: "UTC" });
2152
+ assert.equal(overview.total_tokens, 1_778);
2153
+ assert.equal(overview.usage_event_count, 2);
2154
+ const breakdown = snapshot.getUsageBreakdown({
2155
+ filters: { timezone: "UTC" },
2156
+ time_dimension: "day",
2157
+ matrix_dimensions: ["model", "day"],
2158
+ });
2159
+ assert.deepEqual(breakdown.by_model.rows.map((row) => [row.key, row.total_tokens]), [["mock-opencode-v2", 1_778]], "OpenCode SQLite usage_only events must retain their model rather than falling into unknown");
2160
+ const trace = snapshot.getSessionTrace({
2161
+ sessionRef: snapshot.listResolvedSessions()[0].id,
2162
+ filters: { timezone: "UTC" },
2163
+ });
2164
+ assert.equal(trace?.usage_granularity, "call");
2165
+ assert.equal(trace?.total_calls, 2);
2166
+ }
2167
+ finally {
2168
+ await rm(root, { recursive: true, force: true });
2169
+ }
2170
+ });
2171
+ test("Hermes delegated children stay in the parent family while compression continuations remain top-level", async () => {
2172
+ const root = await mkdtemp(path.join(os.tmpdir(), "cchistory-hermes-family-"));
2173
+ try {
2174
+ const db = new DatabaseSync(path.join(root, "state.db"));
2175
+ try {
2176
+ db.exec(await readFile(path.join(mockDataRoot, "fixtures/hermes/state.sql"), "utf8"));
2177
+ }
2178
+ finally {
2179
+ db.close();
2180
+ }
2181
+ const snapshot = await scanLiteHistory({
2182
+ homeDir: path.join(mockDataRoot, "empty-home"),
2183
+ sourceRefs: ["hermes"],
2184
+ sourceRoots: [{ sourceRef: "hermes", baseDir: root }],
2185
+ contextMode: "none",
2186
+ });
2187
+ assert.deepEqual(snapshot.projectionIssues, []);
2188
+ assert.deepEqual(snapshot.listTopLevelSessions().map((session) => session.source_session_id).sort(), ["sess_fixture_hermes_main", "sess_fixture_hermes_reset"], "the delegated child is addressable through its parent, not as a top-level session");
2189
+ const parent = snapshot.listResolvedSessions().find((session) => session.source_session_id === "sess_fixture_hermes_main");
2190
+ assert.ok(snapshot.listSessionRelatedWork(parent.id).some((entry) => entry.relation_kind === "delegated_session" && entry.child_session_ref?.includes("sess_fixture_hermes_child")));
2191
+ assert.equal(snapshot.getUsageOverview({ timezone: "UTC" }).total_tokens, 3_828);
2192
+ const breakdown = snapshot.getUsageBreakdown({
2193
+ filters: { timezone: "UTC" },
2194
+ time_dimension: "day",
2195
+ matrix_dimensions: ["model", "day"],
2196
+ });
2197
+ assert.deepEqual(breakdown.by_model.rows.map((row) => row.key).sort(), ["mock-hermes-1", "mock-hermes-2", "mock-hermes-mini"], "per-model session usage keeps every model row");
2198
+ const trace = snapshot.getSessionTrace({ sessionRef: parent.id, filters: { timezone: "UTC" } });
2199
+ assert.equal(trace?.usage_granularity, "session", "Hermes exposes session/model aggregates, not calls");
2200
+ assert.equal(snapshot.getReadStatus().loss_warning_count, 0);
2201
+ }
2202
+ finally {
2203
+ await rm(root, { recursive: true, force: true });
2204
+ }
2205
+ });
2206
+ test("OpenCode v1 and pre-split SQLite stores project without issues and keep delegated children resolvable", async () => {
2207
+ for (const fixture of ["v1.sql", "v2-presplit.sql"]) {
2208
+ const root = await mkdtemp(path.join(os.tmpdir(), `cchistory-opencode-${fixture}-`));
2209
+ try {
2210
+ const db = new DatabaseSync(path.join(root, "opencode.db"));
2211
+ try {
2212
+ db.exec(await readFile(path.join(mockDataRoot, "fixtures/opencode-sqlite", fixture), "utf8"));
2213
+ }
2214
+ finally {
2215
+ db.close();
2216
+ }
2217
+ const snapshot = await scanLiteHistory({
2218
+ homeDir: path.join(mockDataRoot, "empty-home"),
2219
+ sourceRefs: ["opencode"],
2220
+ sourceRoots: [{ sourceRef: "opencode", baseDir: root }],
2221
+ contextMode: "none",
2222
+ });
2223
+ assert.deepEqual(snapshot.projectionIssues, [], fixture);
2224
+ if (fixture === "v1.sql") {
2225
+ assert.equal(snapshot.listTopLevelSessions().length, 1, fixture);
2226
+ assert.equal(snapshot.listResolvedSessions().length, 2, fixture);
2227
+ assert.equal(snapshot.listResolvedTurns().length, 2, fixture);
2228
+ assert.equal(snapshot.getUsageOverview({ timezone: "UTC" }).total_tokens, 1_423, fixture);
2229
+ assert.deepEqual(snapshot.getUsageBreakdown({ filters: { timezone: "UTC" }, time_dimension: "day", matrix_dimensions: ["model", "day"] })
2230
+ .by_model.rows.map((row) => [row.key, row.total_tokens]), [["mock-opencode-v1", 1_423]], fixture);
2231
+ const parent = snapshot.listTopLevelSessions()[0];
2232
+ assert.ok(snapshot.listSessionRelatedWork(parent.id).some((entry) => entry.relation_kind === "delegated_session" && entry.child_session_ref?.includes("ses_fixture_v1_child")), fixture);
2233
+ }
2234
+ else {
2235
+ assert.equal(snapshot.listResolvedSessions().length, 1, fixture);
2236
+ assert.equal(snapshot.listResolvedTurns().length, 1, fixture);
2237
+ assert.equal(snapshot.getUsageOverview({ timezone: "UTC" }).total_tokens, 840, fixture);
2238
+ assert.deepEqual(snapshot.getUsageBreakdown({ filters: { timezone: "UTC" }, time_dimension: "day", matrix_dimensions: ["model", "day"] })
2239
+ .by_model.rows.map((row) => [row.key, row.total_tokens]), [["mock-opencode-presplit", 840]], fixture);
2240
+ assert.equal(snapshot.getReadStatus().loss_warning_count, 0, fixture);
2241
+ }
2242
+ }
2243
+ finally {
2244
+ await rm(root, { recursive: true, force: true });
2245
+ }
2246
+ }
2247
+ });
2248
+ test("Hermes per-model usage survives a final turn with no text reply", async () => {
2249
+ const root = await mkdtemp(path.join(os.tmpdir(), "cchistory-hermes-toolonly-"));
2250
+ try {
2251
+ const db = new DatabaseSync(path.join(root, "state.db"));
2252
+ try {
2253
+ db.exec(`
2254
+ CREATE TABLE sessions (id TEXT PRIMARY KEY, source TEXT NOT NULL, model TEXT, started_at REAL NOT NULL,
2255
+ input_tokens INTEGER DEFAULT 0, output_tokens INTEGER DEFAULT 0, cache_read_tokens INTEGER DEFAULT 0,
2256
+ cache_write_tokens INTEGER DEFAULT 0, reasoning_tokens INTEGER DEFAULT 0);
2257
+ CREATE TABLE messages (id INTEGER PRIMARY KEY AUTOINCREMENT, session_id TEXT NOT NULL, role TEXT NOT NULL,
2258
+ content TEXT, tool_calls TEXT, tool_call_id TEXT, tool_name TEXT, timestamp REAL NOT NULL,
2259
+ active INTEGER NOT NULL DEFAULT 1, display_kind TEXT, _compressed_summary INTEGER NOT NULL DEFAULT 0);
2260
+ CREATE TABLE session_model_usage (session_id TEXT NOT NULL, model TEXT NOT NULL,
2261
+ billing_provider TEXT NOT NULL DEFAULT '', task TEXT NOT NULL DEFAULT '', api_call_count INTEGER DEFAULT 0,
2262
+ input_tokens INTEGER DEFAULT 0, output_tokens INTEGER DEFAULT 0, cache_read_tokens INTEGER DEFAULT 0,
2263
+ cache_write_tokens INTEGER DEFAULT 0, reasoning_tokens INTEGER DEFAULT 0,
2264
+ estimated_cost_usd REAL DEFAULT 0, actual_cost_usd REAL DEFAULT 0);
2265
+ INSERT INTO sessions VALUES ('sess_tool_only', 'cli', 'hermes-model', 1771000000.0, 0, 0, 0, 0, 0);
2266
+ INSERT INTO messages (session_id, role, content, timestamp) VALUES
2267
+ ('sess_tool_only', 'user', 'Run the audit tool.', 1771000001.0);
2268
+ INSERT INTO messages (session_id, role, content, tool_calls, timestamp) VALUES
2269
+ ('sess_tool_only', 'assistant', NULL,
2270
+ '[{"id":"call_1","type":"function","function":{"name":"audit","arguments":"{}"}}]', 1771000002.0);
2271
+ INSERT INTO messages (session_id, role, content, tool_call_id, tool_name, timestamp) VALUES
2272
+ ('sess_tool_only', 'tool', 'audit complete', 'call_1', 'audit', 1771000003.0);
2273
+ INSERT INTO session_model_usage VALUES ('sess_tool_only', 'hermes-model', 'mock', '', 1,
2274
+ 100, 20, 0, 0, 5, 0, 0);
2275
+ `);
2276
+ }
2277
+ finally {
2278
+ db.close();
2279
+ }
2280
+ const snapshot = await scanLiteHistory({
2281
+ homeDir: path.join(mockDataRoot, "empty-home"),
2282
+ sourceRefs: ["hermes"],
2283
+ sourceRoots: [{ sourceRef: "hermes", baseDir: root }],
2284
+ contextMode: "none",
2285
+ });
2286
+ assert.deepEqual(snapshot.projectionIssues, []);
2287
+ assert.equal(snapshot.getUsageOverview({ timezone: "UTC" }).total_tokens, 120);
2288
+ assert.deepEqual(snapshot.getUsageBreakdown({ filters: { timezone: "UTC" }, time_dimension: "day", matrix_dimensions: ["model", "day"] })
2289
+ .by_model.rows.map((row) => row.key), ["hermes-model"]);
2290
+ const sqlQuery = await compileSql("SELECT granularity, high_context_tier, total_tokens FROM calls WHERE total_tokens > 0 LIMIT 10");
2291
+ const sqlResult = executeCanonicalQuery(snapshot.data, sqlQuery);
2292
+ assert.deepEqual(sqlResult.rows, [{ granularity: "session", high_context_tier: false, total_tokens: 120 }]);
2293
+ }
2294
+ finally {
2295
+ await rm(root, { recursive: true, force: true });
2296
+ }
2297
+ });
2298
+ test("Pi family projection keeps call-granularity usage and task-child lineage", async () => {
2299
+ const piSnapshot = await scanLiteHistory({
2300
+ homeDir: path.join(mockDataRoot, "empty-home"),
2301
+ sourceRefs: ["pi"],
2302
+ sourceRoots: [{ sourceRef: "pi", baseDir: path.join(mockDataRoot, ".pi/agent/sessions") }],
2303
+ contextMode: "none",
2304
+ });
2305
+ assert.deepEqual(piSnapshot.projectionIssues, []);
2306
+ assert.equal(piSnapshot.getUsageOverview({ timezone: "UTC" }).total_tokens, 4_466);
2307
+ const piSession = piSnapshot.listResolvedSessions()[0];
2308
+ assert.equal(piSnapshot.getSessionTrace({ sessionRef: piSession.id, filters: { timezone: "UTC" } })?.usage_granularity, "call");
2309
+ assert.ok(piSnapshot.listSessionTurns(piSession.id).every((turn) => !turn.canonical_text.includes("Abandoned branch")));
2310
+ const ompSnapshot = await scanLiteHistory({
2311
+ homeDir: path.join(mockDataRoot, "empty-home"),
2312
+ sourceRefs: ["oh_my_pi"],
2313
+ sourceRoots: [{ sourceRef: "oh_my_pi", baseDir: path.join(mockDataRoot, ".omp/agent/sessions") }],
2314
+ contextMode: "none",
2315
+ });
2316
+ assert.deepEqual(ompSnapshot.projectionIssues, []);
2317
+ assert.equal(ompSnapshot.getUsageOverview({ timezone: "UTC" }).total_tokens, 1_794);
2318
+ assert.deepEqual(ompSnapshot.listTopLevelSessions().map((session) => session.source_session_id).sort(), ["omp-fixture-fork", "omp-fixture-main"], "the task child is delegated; the ordinary fork stays top-level");
2319
+ const main = ompSnapshot.listTopLevelSessions().find((session) => session.source_session_id === "omp-fixture-main");
2320
+ assert.ok(ompSnapshot.listSessionRelatedWork(main.id).some((entry) => entry.relation_kind === "delegated_session" && entry.child_session_ref?.includes("omp-fixture-task")));
2321
+ // Targeted parent read must also include the delegated task child and related work.
2322
+ const ompTargeted = await scanLiteHistory({
2323
+ homeDir: path.join(mockDataRoot, "empty-home"),
2324
+ sourceRefs: ["oh_my_pi"],
2325
+ sourceRoots: [{ sourceRef: "oh_my_pi", baseDir: path.join(mockDataRoot, ".omp/agent/sessions") }],
2326
+ sessionRefs: [main.id],
2327
+ contextMode: "none",
2328
+ });
2329
+ assert.deepEqual(ompTargeted.projectionIssues, []);
2330
+ assert.ok(ompTargeted.listSessionRelatedWork(main.id).some((entry) => entry.relation_kind === "delegated_session" && entry.child_session_ref?.includes("omp-fixture-task")), "targeted OMP parent read keeps delegated task child resolvable");
2101
2331
  });
2102
2332
  //# sourceMappingURL=index.test.js.map