@cchistory/lite 0.4.2

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 (533) hide show
  1. package/INSTALL.md +13 -0
  2. package/LICENSE +21 -0
  3. package/README.md +16 -0
  4. package/apps/lite-cli/dist/bin.d.ts +3 -0
  5. package/apps/lite-cli/dist/bin.d.ts.map +1 -0
  6. package/apps/lite-cli/dist/bin.js +7 -0
  7. package/apps/lite-cli/dist/bin.js.map +1 -0
  8. package/apps/lite-cli/dist/index.d.ts +21 -0
  9. package/apps/lite-cli/dist/index.d.ts.map +1 -0
  10. package/apps/lite-cli/dist/index.js +1812 -0
  11. package/apps/lite-cli/dist/index.js.map +1 -0
  12. package/apps/lite-cli/dist/index.test.d.ts +2 -0
  13. package/apps/lite-cli/dist/index.test.d.ts.map +1 -0
  14. package/apps/lite-cli/dist/index.test.js +1290 -0
  15. package/apps/lite-cli/dist/index.test.js.map +1 -0
  16. package/apps/lite-cli/dist/json-v2.d.ts +17 -0
  17. package/apps/lite-cli/dist/json-v2.d.ts.map +1 -0
  18. package/apps/lite-cli/dist/json-v2.js +352 -0
  19. package/apps/lite-cli/dist/json-v2.js.map +1 -0
  20. package/apps/lite-cli/dist/query.d.ts +50 -0
  21. package/apps/lite-cli/dist/query.d.ts.map +1 -0
  22. package/apps/lite-cli/dist/query.js +297 -0
  23. package/apps/lite-cli/dist/query.js.map +1 -0
  24. package/apps/lite-cli/dist/shell.d.ts +18 -0
  25. package/apps/lite-cli/dist/shell.d.ts.map +1 -0
  26. package/apps/lite-cli/dist/shell.js +276 -0
  27. package/apps/lite-cli/dist/shell.js.map +1 -0
  28. package/apps/lite-tui/dist/bin.d.ts +3 -0
  29. package/apps/lite-tui/dist/bin.d.ts.map +1 -0
  30. package/apps/lite-tui/dist/bin.js +7 -0
  31. package/apps/lite-tui/dist/bin.js.map +1 -0
  32. package/apps/lite-tui/dist/colors.d.ts +49 -0
  33. package/apps/lite-tui/dist/colors.d.ts.map +1 -0
  34. package/apps/lite-tui/dist/colors.js +70 -0
  35. package/apps/lite-tui/dist/colors.js.map +1 -0
  36. package/apps/lite-tui/dist/index.d.ts +23 -0
  37. package/apps/lite-tui/dist/index.d.ts.map +1 -0
  38. package/apps/lite-tui/dist/index.js +519 -0
  39. package/apps/lite-tui/dist/index.js.map +1 -0
  40. package/apps/lite-tui/dist/index.test.d.ts +2 -0
  41. package/apps/lite-tui/dist/index.test.d.ts.map +1 -0
  42. package/apps/lite-tui/dist/index.test.js +487 -0
  43. package/apps/lite-tui/dist/index.test.js.map +1 -0
  44. package/apps/lite-tui/dist/input.d.ts +23 -0
  45. package/apps/lite-tui/dist/input.d.ts.map +1 -0
  46. package/apps/lite-tui/dist/input.js +98 -0
  47. package/apps/lite-tui/dist/input.js.map +1 -0
  48. package/apps/lite-tui/dist/keys.d.ts +32 -0
  49. package/apps/lite-tui/dist/keys.d.ts.map +1 -0
  50. package/apps/lite-tui/dist/keys.js +136 -0
  51. package/apps/lite-tui/dist/keys.js.map +1 -0
  52. package/apps/lite-tui/dist/keys.test.d.ts +2 -0
  53. package/apps/lite-tui/dist/keys.test.d.ts.map +1 -0
  54. package/apps/lite-tui/dist/keys.test.js +67 -0
  55. package/apps/lite-tui/dist/keys.test.js.map +1 -0
  56. package/apps/lite-tui/dist/model.d.ts +88 -0
  57. package/apps/lite-tui/dist/model.d.ts.map +1 -0
  58. package/apps/lite-tui/dist/model.js +146 -0
  59. package/apps/lite-tui/dist/model.js.map +1 -0
  60. package/apps/lite-tui/dist/render.d.ts +46 -0
  61. package/apps/lite-tui/dist/render.d.ts.map +1 -0
  62. package/apps/lite-tui/dist/render.js +706 -0
  63. package/apps/lite-tui/dist/render.js.map +1 -0
  64. package/apps/lite-tui/dist/render.test.d.ts +2 -0
  65. package/apps/lite-tui/dist/render.test.d.ts.map +1 -0
  66. package/apps/lite-tui/dist/render.test.js +594 -0
  67. package/apps/lite-tui/dist/render.test.js.map +1 -0
  68. package/apps/lite-tui/dist/state.d.ts +127 -0
  69. package/apps/lite-tui/dist/state.d.ts.map +1 -0
  70. package/apps/lite-tui/dist/state.js +391 -0
  71. package/apps/lite-tui/dist/state.js.map +1 -0
  72. package/apps/lite-tui/dist/state.test.d.ts +2 -0
  73. package/apps/lite-tui/dist/state.test.d.ts.map +1 -0
  74. package/apps/lite-tui/dist/state.test.js +331 -0
  75. package/apps/lite-tui/dist/state.test.js.map +1 -0
  76. package/apps/lite-tui/dist/text.d.ts +38 -0
  77. package/apps/lite-tui/dist/text.d.ts.map +1 -0
  78. package/apps/lite-tui/dist/text.js +246 -0
  79. package/apps/lite-tui/dist/text.js.map +1 -0
  80. package/apps/lite-tui/dist/version.d.ts +10 -0
  81. package/apps/lite-tui/dist/version.d.ts.map +1 -0
  82. package/apps/lite-tui/dist/version.js +10 -0
  83. package/apps/lite-tui/dist/version.js.map +1 -0
  84. package/apps/lite-tui/dist/view-model.d.ts +26 -0
  85. package/apps/lite-tui/dist/view-model.d.ts.map +1 -0
  86. package/apps/lite-tui/dist/view-model.js +87 -0
  87. package/apps/lite-tui/dist/view-model.js.map +1 -0
  88. package/bin/cchistory-lite +3 -0
  89. package/bin/cchistory-lite-tui +3 -0
  90. package/bin/cchistory-lite-tui.cmd +3 -0
  91. package/bin/cchistory-lite-tui.mjs +7 -0
  92. package/bin/cchistory-lite.cmd +3 -0
  93. package/bin/cchistory-lite.mjs +11 -0
  94. package/node_modules/@cchistory/canonical/dist/directory-scope.d.ts +33 -0
  95. package/node_modules/@cchistory/canonical/dist/directory-scope.d.ts.map +1 -0
  96. package/node_modules/@cchistory/canonical/dist/directory-scope.js +95 -0
  97. package/node_modules/@cchistory/canonical/dist/directory-scope.js.map +1 -0
  98. package/node_modules/@cchistory/canonical/dist/fallback-projects.d.ts +14 -0
  99. package/node_modules/@cchistory/canonical/dist/fallback-projects.d.ts.map +1 -0
  100. package/node_modules/@cchistory/canonical/dist/fallback-projects.js +120 -0
  101. package/node_modules/@cchistory/canonical/dist/fallback-projects.js.map +1 -0
  102. package/node_modules/@cchistory/canonical/dist/index.d.ts +12 -0
  103. package/node_modules/@cchistory/canonical/dist/index.d.ts.map +1 -0
  104. package/node_modules/@cchistory/canonical/dist/index.js +12 -0
  105. package/node_modules/@cchistory/canonical/dist/index.js.map +1 -0
  106. package/node_modules/@cchistory/canonical/dist/index.test.d.ts +2 -0
  107. package/node_modules/@cchistory/canonical/dist/index.test.d.ts.map +1 -0
  108. package/node_modules/@cchistory/canonical/dist/index.test.js +901 -0
  109. package/node_modules/@cchistory/canonical/dist/index.test.js.map +1 -0
  110. package/node_modules/@cchistory/canonical/dist/project-linker.d.ts +30 -0
  111. package/node_modules/@cchistory/canonical/dist/project-linker.d.ts.map +1 -0
  112. package/node_modules/@cchistory/canonical/dist/project-linker.js +720 -0
  113. package/node_modules/@cchistory/canonical/dist/project-linker.js.map +1 -0
  114. package/node_modules/@cchistory/canonical/dist/projection-audit.d.ts +23 -0
  115. package/node_modules/@cchistory/canonical/dist/projection-audit.d.ts.map +1 -0
  116. package/node_modules/@cchistory/canonical/dist/projection-audit.js +192 -0
  117. package/node_modules/@cchistory/canonical/dist/projection-audit.js.map +1 -0
  118. package/node_modules/@cchistory/canonical/dist/read-order.d.ts +19 -0
  119. package/node_modules/@cchistory/canonical/dist/read-order.d.ts.map +1 -0
  120. package/node_modules/@cchistory/canonical/dist/read-order.js +73 -0
  121. package/node_modules/@cchistory/canonical/dist/read-order.js.map +1 -0
  122. package/node_modules/@cchistory/canonical/dist/related-work.d.ts +4 -0
  123. package/node_modules/@cchistory/canonical/dist/related-work.d.ts.map +1 -0
  124. package/node_modules/@cchistory/canonical/dist/related-work.js +232 -0
  125. package/node_modules/@cchistory/canonical/dist/related-work.js.map +1 -0
  126. package/node_modules/@cchistory/canonical/dist/runtime-warning-filter.d.ts +10 -0
  127. package/node_modules/@cchistory/canonical/dist/runtime-warning-filter.d.ts.map +1 -0
  128. package/node_modules/@cchistory/canonical/dist/runtime-warning-filter.js +34 -0
  129. package/node_modules/@cchistory/canonical/dist/runtime-warning-filter.js.map +1 -0
  130. package/node_modules/@cchistory/canonical/dist/search.d.ts +69 -0
  131. package/node_modules/@cchistory/canonical/dist/search.d.ts.map +1 -0
  132. package/node_modules/@cchistory/canonical/dist/search.js +337 -0
  133. package/node_modules/@cchistory/canonical/dist/search.js.map +1 -0
  134. package/node_modules/@cchistory/canonical/dist/session-collections.d.ts +8 -0
  135. package/node_modules/@cchistory/canonical/dist/session-collections.d.ts.map +1 -0
  136. package/node_modules/@cchistory/canonical/dist/session-collections.js +21 -0
  137. package/node_modules/@cchistory/canonical/dist/session-collections.js.map +1 -0
  138. package/node_modules/@cchistory/canonical/dist/session-family.d.ts +23 -0
  139. package/node_modules/@cchistory/canonical/dist/session-family.d.ts.map +1 -0
  140. package/node_modules/@cchistory/canonical/dist/session-family.js +808 -0
  141. package/node_modules/@cchistory/canonical/dist/session-family.js.map +1 -0
  142. package/node_modules/@cchistory/canonical/dist/session-family.test.d.ts +2 -0
  143. package/node_modules/@cchistory/canonical/dist/session-family.test.d.ts.map +1 -0
  144. package/node_modules/@cchistory/canonical/dist/session-family.test.js +650 -0
  145. package/node_modules/@cchistory/canonical/dist/session-family.test.js.map +1 -0
  146. package/node_modules/@cchistory/canonical/dist/usage.d.ts +79 -0
  147. package/node_modules/@cchistory/canonical/dist/usage.d.ts.map +1 -0
  148. package/node_modules/@cchistory/canonical/dist/usage.js +232 -0
  149. package/node_modules/@cchistory/canonical/dist/usage.js.map +1 -0
  150. package/node_modules/@cchistory/canonical/dist/utils.d.ts +5 -0
  151. package/node_modules/@cchistory/canonical/dist/utils.d.ts.map +1 -0
  152. package/node_modules/@cchistory/canonical/dist/utils.js +18 -0
  153. package/node_modules/@cchistory/canonical/dist/utils.js.map +1 -0
  154. package/node_modules/@cchistory/canonical/package.json +14 -0
  155. package/node_modules/@cchistory/domain/dist/index.d.ts +943 -0
  156. package/node_modules/@cchistory/domain/dist/index.d.ts.map +1 -0
  157. package/node_modules/@cchistory/domain/dist/index.js +238 -0
  158. package/node_modules/@cchistory/domain/dist/index.js.map +1 -0
  159. package/node_modules/@cchistory/domain/dist/index.test.d.ts +2 -0
  160. package/node_modules/@cchistory/domain/dist/index.test.d.ts.map +1 -0
  161. package/node_modules/@cchistory/domain/dist/index.test.js +423 -0
  162. package/node_modules/@cchistory/domain/dist/index.test.js.map +1 -0
  163. package/node_modules/@cchistory/domain/package.json +14 -0
  164. package/node_modules/@cchistory/live-runtime/dist/async-pool.d.ts +3 -0
  165. package/node_modules/@cchistory/live-runtime/dist/async-pool.d.ts.map +1 -0
  166. package/node_modules/@cchistory/live-runtime/dist/async-pool.js +19 -0
  167. package/node_modules/@cchistory/live-runtime/dist/async-pool.js.map +1 -0
  168. package/node_modules/@cchistory/live-runtime/dist/bootstrap.d.ts +3 -0
  169. package/node_modules/@cchistory/live-runtime/dist/bootstrap.d.ts.map +1 -0
  170. package/node_modules/@cchistory/live-runtime/dist/bootstrap.js +22 -0
  171. package/node_modules/@cchistory/live-runtime/dist/bootstrap.js.map +1 -0
  172. package/node_modules/@cchistory/live-runtime/dist/index.d.ts +149 -0
  173. package/node_modules/@cchistory/live-runtime/dist/index.d.ts.map +1 -0
  174. package/node_modules/@cchistory/live-runtime/dist/index.js +1180 -0
  175. package/node_modules/@cchistory/live-runtime/dist/index.js.map +1 -0
  176. package/node_modules/@cchistory/live-runtime/dist/index.test.d.ts +2 -0
  177. package/node_modules/@cchistory/live-runtime/dist/index.test.d.ts.map +1 -0
  178. package/node_modules/@cchistory/live-runtime/dist/index.test.js +1819 -0
  179. package/node_modules/@cchistory/live-runtime/dist/index.test.js.map +1 -0
  180. package/node_modules/@cchistory/live-runtime/dist/node-memory.d.ts +5 -0
  181. package/node_modules/@cchistory/live-runtime/dist/node-memory.d.ts.map +1 -0
  182. package/node_modules/@cchistory/live-runtime/dist/node-memory.js +83 -0
  183. package/node_modules/@cchistory/live-runtime/dist/node-memory.js.map +1 -0
  184. package/node_modules/@cchistory/live-runtime/package.json +18 -0
  185. package/node_modules/@cchistory/source-adapters/dist/core/antigravity-logic.d.ts +8 -0
  186. package/node_modules/@cchistory/source-adapters/dist/core/antigravity-logic.d.ts.map +1 -0
  187. package/node_modules/@cchistory/source-adapters/dist/core/antigravity-logic.js +115 -0
  188. package/node_modules/@cchistory/source-adapters/dist/core/antigravity-logic.js.map +1 -0
  189. package/node_modules/@cchistory/source-adapters/dist/core/ask-user-registry.d.ts +9 -0
  190. package/node_modules/@cchistory/source-adapters/dist/core/ask-user-registry.d.ts.map +1 -0
  191. package/node_modules/@cchistory/source-adapters/dist/core/ask-user-registry.js +223 -0
  192. package/node_modules/@cchistory/source-adapters/dist/core/ask-user-registry.js.map +1 -0
  193. package/node_modules/@cchistory/source-adapters/dist/core/ask-user.test.d.ts +2 -0
  194. package/node_modules/@cchistory/source-adapters/dist/core/ask-user.test.d.ts.map +1 -0
  195. package/node_modules/@cchistory/source-adapters/dist/core/ask-user.test.js +318 -0
  196. package/node_modules/@cchistory/source-adapters/dist/core/ask-user.test.js.map +1 -0
  197. package/node_modules/@cchistory/source-adapters/dist/core/atomizer.d.ts +11 -0
  198. package/node_modules/@cchistory/source-adapters/dist/core/atomizer.d.ts.map +1 -0
  199. package/node_modules/@cchistory/source-adapters/dist/core/atomizer.js +206 -0
  200. package/node_modules/@cchistory/source-adapters/dist/core/atomizer.js.map +1 -0
  201. package/node_modules/@cchistory/source-adapters/dist/core/conversation-seeds.d.ts +62 -0
  202. package/node_modules/@cchistory/source-adapters/dist/core/conversation-seeds.d.ts.map +1 -0
  203. package/node_modules/@cchistory/source-adapters/dist/core/conversation-seeds.js +224 -0
  204. package/node_modules/@cchistory/source-adapters/dist/core/conversation-seeds.js.map +1 -0
  205. package/node_modules/@cchistory/source-adapters/dist/core/directory-preview.d.ts +15 -0
  206. package/node_modules/@cchistory/source-adapters/dist/core/directory-preview.d.ts.map +1 -0
  207. package/node_modules/@cchistory/source-adapters/dist/core/directory-preview.js +96 -0
  208. package/node_modules/@cchistory/source-adapters/dist/core/directory-preview.js.map +1 -0
  209. package/node_modules/@cchistory/source-adapters/dist/core/directory-preview.test.d.ts +2 -0
  210. package/node_modules/@cchistory/source-adapters/dist/core/directory-preview.test.d.ts.map +1 -0
  211. package/node_modules/@cchistory/source-adapters/dist/core/directory-preview.test.js +97 -0
  212. package/node_modules/@cchistory/source-adapters/dist/core/directory-preview.test.js.map +1 -0
  213. package/node_modules/@cchistory/source-adapters/dist/core/discovery.d.ts +11 -0
  214. package/node_modules/@cchistory/source-adapters/dist/core/discovery.d.ts.map +1 -0
  215. package/node_modules/@cchistory/source-adapters/dist/core/discovery.js +412 -0
  216. package/node_modules/@cchistory/source-adapters/dist/core/discovery.js.map +1 -0
  217. package/node_modules/@cchistory/source-adapters/dist/core/discovery.test.d.ts +2 -0
  218. package/node_modules/@cchistory/source-adapters/dist/core/discovery.test.d.ts.map +1 -0
  219. package/node_modules/@cchistory/source-adapters/dist/core/discovery.test.js +552 -0
  220. package/node_modules/@cchistory/source-adapters/dist/core/discovery.test.js.map +1 -0
  221. package/node_modules/@cchistory/source-adapters/dist/core/factories.d.ts +10 -0
  222. package/node_modules/@cchistory/source-adapters/dist/core/factories.d.ts.map +1 -0
  223. package/node_modules/@cchistory/source-adapters/dist/core/factories.js +83 -0
  224. package/node_modules/@cchistory/source-adapters/dist/core/factories.js.map +1 -0
  225. package/node_modules/@cchistory/source-adapters/dist/core/git-project.d.ts +5 -0
  226. package/node_modules/@cchistory/source-adapters/dist/core/git-project.d.ts.map +1 -0
  227. package/node_modules/@cchistory/source-adapters/dist/core/git-project.js +86 -0
  228. package/node_modules/@cchistory/source-adapters/dist/core/git-project.js.map +1 -0
  229. package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.d.ts +31 -0
  230. package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.d.ts.map +1 -0
  231. package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.js +216 -0
  232. package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.js.map +1 -0
  233. package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.test.d.ts +2 -0
  234. package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.test.d.ts.map +1 -0
  235. package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.test.js +367 -0
  236. package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.test.js.map +1 -0
  237. package/node_modules/@cchistory/source-adapters/dist/core/legacy.d.ts +10 -0
  238. package/node_modules/@cchistory/source-adapters/dist/core/legacy.d.ts.map +1 -0
  239. package/node_modules/@cchistory/source-adapters/dist/core/legacy.js +10 -0
  240. package/node_modules/@cchistory/source-adapters/dist/core/legacy.js.map +1 -0
  241. package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts +70 -0
  242. package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts.map +1 -0
  243. package/node_modules/@cchistory/source-adapters/dist/core/parser.js +1389 -0
  244. package/node_modules/@cchistory/source-adapters/dist/core/parser.js.map +1 -0
  245. package/node_modules/@cchistory/source-adapters/dist/core/path-utils.d.ts +15 -0
  246. package/node_modules/@cchistory/source-adapters/dist/core/path-utils.d.ts.map +1 -0
  247. package/node_modules/@cchistory/source-adapters/dist/core/path-utils.js +76 -0
  248. package/node_modules/@cchistory/source-adapters/dist/core/path-utils.js.map +1 -0
  249. package/node_modules/@cchistory/source-adapters/dist/core/path-utils.test.d.ts +2 -0
  250. package/node_modules/@cchistory/source-adapters/dist/core/path-utils.test.d.ts.map +1 -0
  251. package/node_modules/@cchistory/source-adapters/dist/core/path-utils.test.js +33 -0
  252. package/node_modules/@cchistory/source-adapters/dist/core/path-utils.test.js.map +1 -0
  253. package/node_modules/@cchistory/source-adapters/dist/core/probe.d.ts +24 -0
  254. package/node_modules/@cchistory/source-adapters/dist/core/probe.d.ts.map +1 -0
  255. package/node_modules/@cchistory/source-adapters/dist/core/probe.js +1829 -0
  256. package/node_modules/@cchistory/source-adapters/dist/core/probe.js.map +1 -0
  257. package/node_modules/@cchistory/source-adapters/dist/core/projections.d.ts +39 -0
  258. package/node_modules/@cchistory/source-adapters/dist/core/projections.d.ts.map +1 -0
  259. package/node_modules/@cchistory/source-adapters/dist/core/projections.js +873 -0
  260. package/node_modules/@cchistory/source-adapters/dist/core/projections.js.map +1 -0
  261. package/node_modules/@cchistory/source-adapters/dist/core/projections.test.d.ts +2 -0
  262. package/node_modules/@cchistory/source-adapters/dist/core/projections.test.d.ts.map +1 -0
  263. package/node_modules/@cchistory/source-adapters/dist/core/projections.test.js +165 -0
  264. package/node_modules/@cchistory/source-adapters/dist/core/projections.test.js.map +1 -0
  265. package/node_modules/@cchistory/source-adapters/dist/core/registry.test.d.ts +2 -0
  266. package/node_modules/@cchistory/source-adapters/dist/core/registry.test.d.ts.map +1 -0
  267. package/node_modules/@cchistory/source-adapters/dist/core/registry.test.js +87 -0
  268. package/node_modules/@cchistory/source-adapters/dist/core/registry.test.js.map +1 -0
  269. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping-worker.d.ts +2 -0
  270. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping-worker.d.ts.map +1 -0
  271. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping-worker.js +10 -0
  272. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping-worker.js.map +1 -0
  273. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.d.ts +29 -0
  274. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.d.ts.map +1 -0
  275. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.js +455 -0
  276. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.js.map +1 -0
  277. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.test.d.ts +2 -0
  278. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.test.d.ts.map +1 -0
  279. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.test.js +357 -0
  280. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.test.js.map +1 -0
  281. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.d.ts +25 -0
  282. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.d.ts.map +1 -0
  283. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js +144 -0
  284. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js.map +1 -0
  285. package/node_modules/@cchistory/source-adapters/dist/core/token-usage.d.ts +14 -0
  286. package/node_modules/@cchistory/source-adapters/dist/core/token-usage.d.ts.map +1 -0
  287. package/node_modules/@cchistory/source-adapters/dist/core/token-usage.js +247 -0
  288. package/node_modules/@cchistory/source-adapters/dist/core/token-usage.js.map +1 -0
  289. package/node_modules/@cchistory/source-adapters/dist/core/tokens.test.d.ts +2 -0
  290. package/node_modules/@cchistory/source-adapters/dist/core/tokens.test.d.ts.map +1 -0
  291. package/node_modules/@cchistory/source-adapters/dist/core/tokens.test.js +323 -0
  292. package/node_modules/@cchistory/source-adapters/dist/core/tokens.test.js.map +1 -0
  293. package/node_modules/@cchistory/source-adapters/dist/core/type-guards.d.ts +26 -0
  294. package/node_modules/@cchistory/source-adapters/dist/core/type-guards.d.ts.map +1 -0
  295. package/node_modules/@cchistory/source-adapters/dist/core/type-guards.js +80 -0
  296. package/node_modules/@cchistory/source-adapters/dist/core/type-guards.js.map +1 -0
  297. package/node_modules/@cchistory/source-adapters/dist/core/types.d.ts +226 -0
  298. package/node_modules/@cchistory/source-adapters/dist/core/types.d.ts.map +1 -0
  299. package/node_modules/@cchistory/source-adapters/dist/core/types.js +2 -0
  300. package/node_modules/@cchistory/source-adapters/dist/core/types.js.map +1 -0
  301. package/node_modules/@cchistory/source-adapters/dist/core/user-text.d.ts +29 -0
  302. package/node_modules/@cchistory/source-adapters/dist/core/user-text.d.ts.map +1 -0
  303. package/node_modules/@cchistory/source-adapters/dist/core/user-text.js +327 -0
  304. package/node_modules/@cchistory/source-adapters/dist/core/user-text.js.map +1 -0
  305. package/node_modules/@cchistory/source-adapters/dist/core/utils.d.ts +11 -0
  306. package/node_modules/@cchistory/source-adapters/dist/core/utils.d.ts.map +1 -0
  307. package/node_modules/@cchistory/source-adapters/dist/core/utils.js +19 -0
  308. package/node_modules/@cchistory/source-adapters/dist/core/utils.js.map +1 -0
  309. package/node_modules/@cchistory/source-adapters/dist/core/utils.test.d.ts +2 -0
  310. package/node_modules/@cchistory/source-adapters/dist/core/utils.test.d.ts.map +1 -0
  311. package/node_modules/@cchistory/source-adapters/dist/core/utils.test.js +289 -0
  312. package/node_modules/@cchistory/source-adapters/dist/core/utils.test.js.map +1 -0
  313. package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.d.ts +43 -0
  314. package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.d.ts.map +1 -0
  315. package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.js +520 -0
  316. package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.js.map +1 -0
  317. package/node_modules/@cchistory/source-adapters/dist/index.d.ts +13 -0
  318. package/node_modules/@cchistory/source-adapters/dist/index.d.ts.map +1 -0
  319. package/node_modules/@cchistory/source-adapters/dist/index.js +8 -0
  320. package/node_modules/@cchistory/source-adapters/dist/index.js.map +1 -0
  321. package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts +31 -0
  322. package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts.map +1 -0
  323. package/node_modules/@cchistory/source-adapters/dist/index.test.js +31 -0
  324. package/node_modules/@cchistory/source-adapters/dist/index.test.js.map +1 -0
  325. package/node_modules/@cchistory/source-adapters/dist/masks.d.ts +31 -0
  326. package/node_modules/@cchistory/source-adapters/dist/masks.d.ts.map +1 -0
  327. package/node_modules/@cchistory/source-adapters/dist/masks.js +342 -0
  328. package/node_modules/@cchistory/source-adapters/dist/masks.js.map +1 -0
  329. package/node_modules/@cchistory/source-adapters/dist/platforms/accio/runtime.d.ts +31 -0
  330. package/node_modules/@cchistory/source-adapters/dist/platforms/accio/runtime.d.ts.map +1 -0
  331. package/node_modules/@cchistory/source-adapters/dist/platforms/accio/runtime.js +161 -0
  332. package/node_modules/@cchistory/source-adapters/dist/platforms/accio/runtime.js.map +1 -0
  333. package/node_modules/@cchistory/source-adapters/dist/platforms/accio.d.ts +3 -0
  334. package/node_modules/@cchistory/source-adapters/dist/platforms/accio.d.ts.map +1 -0
  335. package/node_modules/@cchistory/source-adapters/dist/platforms/accio.js +107 -0
  336. package/node_modules/@cchistory/source-adapters/dist/platforms/accio.js.map +1 -0
  337. package/node_modules/@cchistory/source-adapters/dist/platforms/accio.test.d.ts +2 -0
  338. package/node_modules/@cchistory/source-adapters/dist/platforms/accio.test.d.ts.map +1 -0
  339. package/node_modules/@cchistory/source-adapters/dist/platforms/accio.test.js +202 -0
  340. package/node_modules/@cchistory/source-adapters/dist/platforms/accio.test.js.map +1 -0
  341. package/node_modules/@cchistory/source-adapters/dist/platforms/amp/runtime.d.ts +4 -0
  342. package/node_modules/@cchistory/source-adapters/dist/platforms/amp/runtime.d.ts.map +1 -0
  343. package/node_modules/@cchistory/source-adapters/dist/platforms/amp/runtime.js +85 -0
  344. package/node_modules/@cchistory/source-adapters/dist/platforms/amp/runtime.js.map +1 -0
  345. package/node_modules/@cchistory/source-adapters/dist/platforms/amp.d.ts +3 -0
  346. package/node_modules/@cchistory/source-adapters/dist/platforms/amp.d.ts.map +1 -0
  347. package/node_modules/@cchistory/source-adapters/dist/platforms/amp.js +10 -0
  348. package/node_modules/@cchistory/source-adapters/dist/platforms/amp.js.map +1 -0
  349. package/node_modules/@cchistory/source-adapters/dist/platforms/amp.test.d.ts +2 -0
  350. package/node_modules/@cchistory/source-adapters/dist/platforms/amp.test.d.ts.map +1 -0
  351. package/node_modules/@cchistory/source-adapters/dist/platforms/amp.test.js +105 -0
  352. package/node_modules/@cchistory/source-adapters/dist/platforms/amp.test.js.map +1 -0
  353. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/live.d.ts +45 -0
  354. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/live.d.ts.map +1 -0
  355. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/live.js +609 -0
  356. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/live.js.map +1 -0
  357. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/runtime.d.ts +16 -0
  358. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/runtime.d.ts.map +1 -0
  359. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/runtime.js +534 -0
  360. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/runtime.js.map +1 -0
  361. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.d.ts +12 -0
  362. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.d.ts.map +1 -0
  363. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.js +105 -0
  364. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.js.map +1 -0
  365. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.test.d.ts +2 -0
  366. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.test.d.ts.map +1 -0
  367. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.test.js +820 -0
  368. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.test.js.map +1 -0
  369. package/node_modules/@cchistory/source-adapters/dist/platforms/claude-code/runtime.d.ts +4 -0
  370. package/node_modules/@cchistory/source-adapters/dist/platforms/claude-code/runtime.d.ts.map +1 -0
  371. package/node_modules/@cchistory/source-adapters/dist/platforms/claude-code/runtime.js +130 -0
  372. package/node_modules/@cchistory/source-adapters/dist/platforms/claude-code/runtime.js.map +1 -0
  373. package/node_modules/@cchistory/source-adapters/dist/platforms/claude-code.d.ts +3 -0
  374. package/node_modules/@cchistory/source-adapters/dist/platforms/claude-code.d.ts.map +1 -0
  375. package/node_modules/@cchistory/source-adapters/dist/platforms/claude-code.js +10 -0
  376. package/node_modules/@cchistory/source-adapters/dist/platforms/claude-code.js.map +1 -0
  377. package/node_modules/@cchistory/source-adapters/dist/platforms/claude.test.d.ts +2 -0
  378. package/node_modules/@cchistory/source-adapters/dist/platforms/claude.test.d.ts.map +1 -0
  379. package/node_modules/@cchistory/source-adapters/dist/platforms/claude.test.js +357 -0
  380. package/node_modules/@cchistory/source-adapters/dist/platforms/claude.test.js.map +1 -0
  381. package/node_modules/@cchistory/source-adapters/dist/platforms/codebuddy.d.ts +4 -0
  382. package/node_modules/@cchistory/source-adapters/dist/platforms/codebuddy.d.ts.map +1 -0
  383. package/node_modules/@cchistory/source-adapters/dist/platforms/codebuddy.js +27 -0
  384. package/node_modules/@cchistory/source-adapters/dist/platforms/codebuddy.js.map +1 -0
  385. package/node_modules/@cchistory/source-adapters/dist/platforms/codebuddy.test.d.ts +2 -0
  386. package/node_modules/@cchistory/source-adapters/dist/platforms/codebuddy.test.d.ts.map +1 -0
  387. package/node_modules/@cchistory/source-adapters/dist/platforms/codebuddy.test.js +49 -0
  388. package/node_modules/@cchistory/source-adapters/dist/platforms/codebuddy.test.js.map +1 -0
  389. package/node_modules/@cchistory/source-adapters/dist/platforms/codex/runtime.d.ts +4 -0
  390. package/node_modules/@cchistory/source-adapters/dist/platforms/codex/runtime.d.ts.map +1 -0
  391. package/node_modules/@cchistory/source-adapters/dist/platforms/codex/runtime.js +555 -0
  392. package/node_modules/@cchistory/source-adapters/dist/platforms/codex/runtime.js.map +1 -0
  393. package/node_modules/@cchistory/source-adapters/dist/platforms/codex.d.ts +3 -0
  394. package/node_modules/@cchistory/source-adapters/dist/platforms/codex.d.ts.map +1 -0
  395. package/node_modules/@cchistory/source-adapters/dist/platforms/codex.js +15 -0
  396. package/node_modules/@cchistory/source-adapters/dist/platforms/codex.js.map +1 -0
  397. package/node_modules/@cchistory/source-adapters/dist/platforms/codex.test.d.ts +2 -0
  398. package/node_modules/@cchistory/source-adapters/dist/platforms/codex.test.d.ts.map +1 -0
  399. package/node_modules/@cchistory/source-adapters/dist/platforms/codex.test.js +893 -0
  400. package/node_modules/@cchistory/source-adapters/dist/platforms/codex.test.js.map +1 -0
  401. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.d.ts +70 -0
  402. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.d.ts.map +1 -0
  403. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.js +786 -0
  404. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.js.map +1 -0
  405. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.d.ts +4 -0
  406. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.d.ts.map +1 -0
  407. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.js +14 -0
  408. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.js.map +1 -0
  409. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.test.d.ts +2 -0
  410. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.test.d.ts.map +1 -0
  411. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.test.js +154 -0
  412. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.test.js.map +1 -0
  413. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor.d.ts +4 -0
  414. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor.d.ts.map +1 -0
  415. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor.js +151 -0
  416. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor.js.map +1 -0
  417. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor.test.d.ts +2 -0
  418. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor.test.d.ts.map +1 -0
  419. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor.test.js +1486 -0
  420. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor.test.js.map +1 -0
  421. package/node_modules/@cchistory/source-adapters/dist/platforms/factory-droid/runtime.d.ts +4 -0
  422. package/node_modules/@cchistory/source-adapters/dist/platforms/factory-droid/runtime.d.ts.map +1 -0
  423. package/node_modules/@cchistory/source-adapters/dist/platforms/factory-droid/runtime.js +229 -0
  424. package/node_modules/@cchistory/source-adapters/dist/platforms/factory-droid/runtime.js.map +1 -0
  425. package/node_modules/@cchistory/source-adapters/dist/platforms/factory-droid.d.ts +3 -0
  426. package/node_modules/@cchistory/source-adapters/dist/platforms/factory-droid.d.ts.map +1 -0
  427. package/node_modules/@cchistory/source-adapters/dist/platforms/factory-droid.js +10 -0
  428. package/node_modules/@cchistory/source-adapters/dist/platforms/factory-droid.js.map +1 -0
  429. package/node_modules/@cchistory/source-adapters/dist/platforms/factory-droid.test.d.ts +2 -0
  430. package/node_modules/@cchistory/source-adapters/dist/platforms/factory-droid.test.d.ts.map +1 -0
  431. package/node_modules/@cchistory/source-adapters/dist/platforms/factory-droid.test.js +222 -0
  432. package/node_modules/@cchistory/source-adapters/dist/platforms/factory-droid.test.js.map +1 -0
  433. package/node_modules/@cchistory/source-adapters/dist/platforms/gemini.d.ts +7 -0
  434. package/node_modules/@cchistory/source-adapters/dist/platforms/gemini.d.ts.map +1 -0
  435. package/node_modules/@cchistory/source-adapters/dist/platforms/gemini.js +65 -0
  436. package/node_modules/@cchistory/source-adapters/dist/platforms/gemini.js.map +1 -0
  437. package/node_modules/@cchistory/source-adapters/dist/platforms/gemini.test.d.ts +2 -0
  438. package/node_modules/@cchistory/source-adapters/dist/platforms/gemini.test.d.ts.map +1 -0
  439. package/node_modules/@cchistory/source-adapters/dist/platforms/gemini.test.js +220 -0
  440. package/node_modules/@cchistory/source-adapters/dist/platforms/gemini.test.js.map +1 -0
  441. package/node_modules/@cchistory/source-adapters/dist/platforms/generic/runtime.d.ts +20 -0
  442. package/node_modules/@cchistory/source-adapters/dist/platforms/generic/runtime.d.ts.map +1 -0
  443. package/node_modules/@cchistory/source-adapters/dist/platforms/generic/runtime.js +365 -0
  444. package/node_modules/@cchistory/source-adapters/dist/platforms/generic/runtime.js.map +1 -0
  445. package/node_modules/@cchistory/source-adapters/dist/platforms/grok/runtime.d.ts +17 -0
  446. package/node_modules/@cchistory/source-adapters/dist/platforms/grok/runtime.d.ts.map +1 -0
  447. package/node_modules/@cchistory/source-adapters/dist/platforms/grok/runtime.js +498 -0
  448. package/node_modules/@cchistory/source-adapters/dist/platforms/grok/runtime.js.map +1 -0
  449. package/node_modules/@cchistory/source-adapters/dist/platforms/grok.d.ts +36 -0
  450. package/node_modules/@cchistory/source-adapters/dist/platforms/grok.d.ts.map +1 -0
  451. package/node_modules/@cchistory/source-adapters/dist/platforms/grok.js +261 -0
  452. package/node_modules/@cchistory/source-adapters/dist/platforms/grok.js.map +1 -0
  453. package/node_modules/@cchistory/source-adapters/dist/platforms/grok.test.d.ts +2 -0
  454. package/node_modules/@cchistory/source-adapters/dist/platforms/grok.test.d.ts.map +1 -0
  455. package/node_modules/@cchistory/source-adapters/dist/platforms/grok.test.js +565 -0
  456. package/node_modules/@cchistory/source-adapters/dist/platforms/grok.test.js.map +1 -0
  457. package/node_modules/@cchistory/source-adapters/dist/platforms/kimi/runtime.d.ts +4 -0
  458. package/node_modules/@cchistory/source-adapters/dist/platforms/kimi/runtime.d.ts.map +1 -0
  459. package/node_modules/@cchistory/source-adapters/dist/platforms/kimi/runtime.js +193 -0
  460. package/node_modules/@cchistory/source-adapters/dist/platforms/kimi/runtime.js.map +1 -0
  461. package/node_modules/@cchistory/source-adapters/dist/platforms/kimi.d.ts +7 -0
  462. package/node_modules/@cchistory/source-adapters/dist/platforms/kimi.d.ts.map +1 -0
  463. package/node_modules/@cchistory/source-adapters/dist/platforms/kimi.js +55 -0
  464. package/node_modules/@cchistory/source-adapters/dist/platforms/kimi.js.map +1 -0
  465. package/node_modules/@cchistory/source-adapters/dist/platforms/kimi.test.d.ts +2 -0
  466. package/node_modules/@cchistory/source-adapters/dist/platforms/kimi.test.d.ts.map +1 -0
  467. package/node_modules/@cchistory/source-adapters/dist/platforms/kimi.test.js +163 -0
  468. package/node_modules/@cchistory/source-adapters/dist/platforms/kimi.test.js.map +1 -0
  469. package/node_modules/@cchistory/source-adapters/dist/platforms/lobechat.d.ts +3 -0
  470. package/node_modules/@cchistory/source-adapters/dist/platforms/lobechat.d.ts.map +1 -0
  471. package/node_modules/@cchistory/source-adapters/dist/platforms/lobechat.js +10 -0
  472. package/node_modules/@cchistory/source-adapters/dist/platforms/lobechat.js.map +1 -0
  473. package/node_modules/@cchistory/source-adapters/dist/platforms/lobechat.test.d.ts +2 -0
  474. package/node_modules/@cchistory/source-adapters/dist/platforms/lobechat.test.d.ts.map +1 -0
  475. package/node_modules/@cchistory/source-adapters/dist/platforms/lobechat.test.js +179 -0
  476. package/node_modules/@cchistory/source-adapters/dist/platforms/lobechat.test.js.map +1 -0
  477. package/node_modules/@cchistory/source-adapters/dist/platforms/openclaw/runtime.d.ts +4 -0
  478. package/node_modules/@cchistory/source-adapters/dist/platforms/openclaw/runtime.d.ts.map +1 -0
  479. package/node_modules/@cchistory/source-adapters/dist/platforms/openclaw/runtime.js +44 -0
  480. package/node_modules/@cchistory/source-adapters/dist/platforms/openclaw/runtime.js.map +1 -0
  481. package/node_modules/@cchistory/source-adapters/dist/platforms/openclaw.d.ts +3 -0
  482. package/node_modules/@cchistory/source-adapters/dist/platforms/openclaw.d.ts.map +1 -0
  483. package/node_modules/@cchistory/source-adapters/dist/platforms/openclaw.js +60 -0
  484. package/node_modules/@cchistory/source-adapters/dist/platforms/openclaw.js.map +1 -0
  485. package/node_modules/@cchistory/source-adapters/dist/platforms/openclaw.test.d.ts +2 -0
  486. package/node_modules/@cchistory/source-adapters/dist/platforms/openclaw.test.d.ts.map +1 -0
  487. package/node_modules/@cchistory/source-adapters/dist/platforms/openclaw.test.js +39 -0
  488. package/node_modules/@cchistory/source-adapters/dist/platforms/openclaw.test.js.map +1 -0
  489. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.d.ts +3 -0
  490. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.d.ts.map +1 -0
  491. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.js +45 -0
  492. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.js.map +1 -0
  493. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.test.d.ts +2 -0
  494. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.test.d.ts.map +1 -0
  495. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.test.js +170 -0
  496. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.test.js.map +1 -0
  497. package/node_modules/@cchistory/source-adapters/dist/platforms/registry.d.ts +7 -0
  498. package/node_modules/@cchistory/source-adapters/dist/platforms/registry.d.ts.map +1 -0
  499. package/node_modules/@cchistory/source-adapters/dist/platforms/registry.js +52 -0
  500. package/node_modules/@cchistory/source-adapters/dist/platforms/registry.js.map +1 -0
  501. package/node_modules/@cchistory/source-adapters/dist/platforms/runtime-types.d.ts +104 -0
  502. package/node_modules/@cchistory/source-adapters/dist/platforms/runtime-types.d.ts.map +1 -0
  503. package/node_modules/@cchistory/source-adapters/dist/platforms/runtime-types.js +2 -0
  504. package/node_modules/@cchistory/source-adapters/dist/platforms/runtime-types.js.map +1 -0
  505. package/node_modules/@cchistory/source-adapters/dist/platforms/types.d.ts +38 -0
  506. package/node_modules/@cchistory/source-adapters/dist/platforms/types.d.ts.map +1 -0
  507. package/node_modules/@cchistory/source-adapters/dist/platforms/types.js +19 -0
  508. package/node_modules/@cchistory/source-adapters/dist/platforms/types.js.map +1 -0
  509. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.d.ts +14 -0
  510. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.d.ts.map +1 -0
  511. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.js +283 -0
  512. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.js.map +1 -0
  513. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode.d.ts +3 -0
  514. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode.d.ts.map +1 -0
  515. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode.js +26 -0
  516. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode.js.map +1 -0
  517. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode.test.d.ts +2 -0
  518. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode.test.d.ts.map +1 -0
  519. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode.test.js +411 -0
  520. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode.test.js.map +1 -0
  521. package/node_modules/@cchistory/source-adapters/dist/test-helpers.d.ts +85 -0
  522. package/node_modules/@cchistory/source-adapters/dist/test-helpers.d.ts.map +1 -0
  523. package/node_modules/@cchistory/source-adapters/dist/test-helpers.js +2106 -0
  524. package/node_modules/@cchistory/source-adapters/dist/test-helpers.js.map +1 -0
  525. package/node_modules/@cchistory/source-adapters/package.json +14 -0
  526. package/package.json +38 -0
  527. package/schemas/cchistory-lite-canonical-v1.schema.json +13 -0
  528. package/schemas/cchistory-lite-error-v1.schema.json +30 -0
  529. package/schemas/cchistory-lite-query-result-v1.schema.json +29 -0
  530. package/schemas/cchistory-lite-query-result-v2.schema.json +29 -0
  531. package/schemas/cchistory-lite-query-v1.schema.json +62 -0
  532. package/schemas/cchistory-lite-query-v2.schema.json +82 -0
  533. package/schemas/cchistory-lite-v2.schema.json +176 -0
@@ -0,0 +1,1819 @@
1
+ import assert from "node:assert/strict";
2
+ import { access, appendFile, mkdir, mkdtemp, readFile, rm, stat, symlink, utimes, writeFile } from "node:fs/promises";
3
+ import { DatabaseSync } from "node:sqlite";
4
+ import os from "node:os";
5
+ import path from "node:path";
6
+ import test from "node:test";
7
+ import { fileURLToPath } from "node:url";
8
+ import { buildProjectDisplayList } from "@cchistory/canonical";
9
+ import { listPlatformAdapters, runSourceProbe } from "@cchistory/source-adapters";
10
+ import { assertLiteSourceRoot, buildLiveSnapshot, buildAdaptiveNodeExecArgv, calculateAdaptiveOldSpaceMiB, isAdaptiveNodeMemoryApplied, LiveHistorySnapshot, maskCompactPreview, resolveLiteSources, scanLiteHistory, } from "./index.js";
11
+ import { SAMPLE_RANK_CONCURRENCY, mapPool } from "./async-pool.js";
12
+ import { settleLauncherExit } from "./bootstrap.js";
13
+ const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../..");
14
+ const mockDataRoot = path.join(repoRoot, "mock_data");
15
+ const fixtureRoots = {
16
+ codex: ".codex/sessions",
17
+ claude_code: ".claude/projects",
18
+ factory_droid: ".factory/sessions",
19
+ amp: ".local/share/amp/threads",
20
+ cursor: ".cursor/chats",
21
+ antigravity: ".gemini/antigravity/brain",
22
+ gemini: ".gemini",
23
+ openclaw: ".openclaw/agents",
24
+ opencode: ".local/share/opencode/storage",
25
+ codebuddy: ".codebuddy",
26
+ accio: "fixtures/accio-multi-agent/agents",
27
+ cursor_agent: "fixtures/cursor-agent",
28
+ grok: "fixtures/grok-cli",
29
+ };
30
+ test("mapPool never runs more than the requested number of tasks at once", async () => {
31
+ assert.equal(SAMPLE_RANK_CONCURRENCY, 4);
32
+ const releases = [];
33
+ let inFlight = 0;
34
+ let maxInFlight = 0;
35
+ let launched = 0;
36
+ const waitUntil = async (predicate) => {
37
+ while (!predicate()) {
38
+ await new Promise((resolve) => queueMicrotask(resolve));
39
+ }
40
+ };
41
+ const done = mapPool(Array.from({ length: 6 }, (_, index) => index), 2, async (value) => {
42
+ launched += 1;
43
+ inFlight += 1;
44
+ maxInFlight = Math.max(maxInFlight, inFlight);
45
+ await new Promise((resolve) => {
46
+ releases.push(resolve);
47
+ });
48
+ inFlight -= 1;
49
+ return value * 2;
50
+ });
51
+ await waitUntil(() => launched === 2);
52
+ assert.equal(maxInFlight, 2);
53
+ assert.equal(inFlight, 2);
54
+ for (const release of releases.splice(0))
55
+ release();
56
+ await waitUntil(() => launched === 4);
57
+ assert.equal(maxInFlight, 2);
58
+ for (const release of releases.splice(0))
59
+ release();
60
+ await waitUntil(() => launched === 6);
61
+ assert.equal(maxInFlight, 2);
62
+ for (const release of releases.splice(0))
63
+ release();
64
+ assert.deepEqual(await done, [0, 2, 4, 6, 8, 10]);
65
+ assert.equal(inFlight, 0);
66
+ });
67
+ test("Lite Node heap policy uses half host memory capped at 4 GiB", () => {
68
+ assert.equal(calculateAdaptiveOldSpaceMiB(3 * 1024 ** 3), 1536);
69
+ assert.equal(calculateAdaptiveOldSpaceMiB(8 * 1024 ** 3), 4096);
70
+ assert.equal(calculateAdaptiveOldSpaceMiB(32 * 1024 ** 3), 4096);
71
+ assert.deepEqual(buildAdaptiveNodeExecArgv(["--trace-warnings", "--max-old-space-size=1024", "--max_old_space_size", "768"], 1536), ["--trace-warnings", "--max-old-space-size=1536"]);
72
+ assert.equal(isAdaptiveNodeMemoryApplied([], "1536", 1536), false);
73
+ assert.equal(isAdaptiveNodeMemoryApplied(["--max-old-space-size=1536"], "1536", 1536), true);
74
+ assert.equal(isAdaptiveNodeMemoryApplied(["--max-old-space-size=1024"], "1536", 1536), false);
75
+ });
76
+ test("settleLauncherExit reports rejected launcher failures to stderr", async () => {
77
+ const originalWrite = process.stderr.write.bind(process.stderr);
78
+ const chunks = [];
79
+ process.stderr.write = ((chunk, ...rest) => {
80
+ chunks.push(typeof chunk === "string" ? chunk : Buffer.from(chunk).toString("utf8"));
81
+ void rest;
82
+ return true;
83
+ });
84
+ const previousExitCode = process.exitCode;
85
+ try {
86
+ settleLauncherExit(Promise.reject(new Error("import failed")));
87
+ await new Promise((resolve) => setImmediate(resolve));
88
+ assert.equal(process.exitCode, 1);
89
+ assert.match(chunks.join(""), /import failed/u);
90
+ }
91
+ finally {
92
+ process.stderr.write = originalWrite;
93
+ process.exitCode = previousExitCode;
94
+ }
95
+ });
96
+ test("sample scan promotes a Grok delegated child to its parent", async () => {
97
+ const snapshot = await scanLiteHistory({
98
+ homeDir: path.join(mockDataRoot, "empty-home"),
99
+ hostname: "cchistory-lite-sample-grok-host",
100
+ sourceRefs: ["grok"],
101
+ sourceRoots: [{ sourceRef: "grok", baseDir: path.join(mockDataRoot, fixtureRoots.grok) }],
102
+ safeMode: true,
103
+ contextMode: "none",
104
+ sample: { perSource: 1 },
105
+ });
106
+ const topLevel = snapshot.listTopLevelSessions().filter((session) => session.turn_count > 0);
107
+ assert.equal(topLevel.length, 1);
108
+ assert.equal(topLevel[0]?.source_session_id, "aaaaaaaa-bbbb-4ccc-8ddd-eeeeeeeeeeee");
109
+ assert.equal(topLevel.some((session) => session.source_session_id === "bbbbbbbb-cccc-4ddd-8eee-ffffffffffff"), false);
110
+ });
111
+ test("compact family I/O previews mask secrets before the 240-character cut", () => {
112
+ const secret = `sk-${"A".repeat(24)}`;
113
+ const preview = `${"x".repeat(220)} ${secret} trailing task`;
114
+ const masked = maskCompactPreview(preview, "tool_input");
115
+ assert.ok(masked);
116
+ assert.doesNotMatch(masked, new RegExp(secret, "u"));
117
+ assert.ok(masked.length <= 240);
118
+ assert.match(masked, /trailing task/u);
119
+ });
120
+ test("Lite materializer resolves canonical history across the fixture-backed adapter matrix", async () => {
121
+ const tempStore = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-matrix-"));
122
+ try {
123
+ const sources = await resolveLiteSources({
124
+ homeDir: path.join(tempStore, "empty-home"),
125
+ hostname: "cchistory-lite-matrix-host",
126
+ sourceRefs: Object.keys(fixtureRoots),
127
+ sourceRoots: Object.entries(fixtureRoots).map(([sourceRef, relativePath]) => ({
128
+ sourceRef,
129
+ baseDir: path.join(mockDataRoot, relativePath),
130
+ })),
131
+ });
132
+ const probe = await runSourceProbe({ safe_mode: true }, sources);
133
+ const askPayload = probe.sources.find((payload) => payload.source.platform === "codex");
134
+ const askSession = askPayload?.sessions[0];
135
+ const longTurn = askPayload?.turns.find((turn) => turn.session_id === askSession?.id);
136
+ assert.ok(askPayload && askSession && longTurn);
137
+ longTurn.canonical_text = `${"a".repeat(16 * 1024)} lite-full-tail-only-token`;
138
+ const searchObservation = askPayload.candidates.find((candidate) => candidate.candidate_kind === "project_observation" && candidate.session_ref === askSession.id);
139
+ if (searchObservation) {
140
+ searchObservation.evidence = {
141
+ ...searchObservation.evidence,
142
+ repo_remote: "https://example.test/lite-full-search-parity.git",
143
+ repo_fingerprint: "fingerprint-lite-full-search-parity",
144
+ };
145
+ }
146
+ else {
147
+ askPayload.candidates.push({
148
+ id: "candidate-lite-full-search-parity",
149
+ source_id: askPayload.source.id,
150
+ session_ref: askSession.id,
151
+ candidate_kind: "project_observation",
152
+ input_atom_refs: [],
153
+ started_at: askSession.created_at,
154
+ ended_at: askSession.updated_at,
155
+ rule_version: "test",
156
+ evidence: {
157
+ repo_remote: "https://example.test/lite-full-search-parity.git",
158
+ repo_fingerprint: "fingerprint-lite-full-search-parity",
159
+ confidence: 0.5,
160
+ },
161
+ });
162
+ }
163
+ askPayload.ask_user_question_turns.push({
164
+ id: "ask-user-question-lite-parity",
165
+ source_id: askPayload.source.id,
166
+ session_id: askSession.id,
167
+ source_platform: askPayload.source.platform,
168
+ created_at: askSession.created_at,
169
+ tool_name: "request_user_input",
170
+ call_atom_id: "atom-lite-parity-call",
171
+ result_atom_id: "atom-lite-parity-result",
172
+ questions: [
173
+ {
174
+ id: "scope",
175
+ header: "Scope",
176
+ question: "Which parity scope should run?",
177
+ options: [{ label: "All fixtures", description: "Run the complete registered fixture matrix." }],
178
+ },
179
+ ],
180
+ answers: [{ question_index: 0, selected_label: "All fixtures" }],
181
+ });
182
+ const lite = buildLiveSnapshot(probe);
183
+ assert.deepEqual(lite.projectionIssues, [], "the complete adapter matrix must satisfy the canonical projection contract");
184
+ // Every registered adapter in the matrix materializes into the live snapshot.
185
+ assert.deepEqual(sortById(lite.listSources()).map((source) => source.platform).sort(), Object.keys(fixtureRoots).sort());
186
+ assert.ok(lite.listResolvedSessions().length > 0);
187
+ assert.ok(lite.listResolvedTurns().length > 0);
188
+ let previousMessageAt;
189
+ let reachedTurnlessSessions = false;
190
+ for (const session of lite.listResolvedSessions()) {
191
+ const hasTurns = lite.listSessionTurns(session.id).length > 0;
192
+ if (!hasTurns) {
193
+ reachedTurnlessSessions = true;
194
+ continue;
195
+ }
196
+ assert.equal(reachedTurnlessSessions, false, "turn-less metadata must not displace sessions with real messages");
197
+ const activityAt = lite.getSessionActivityAt(session.id);
198
+ assert.ok(activityAt);
199
+ if (previousMessageAt) {
200
+ assert.ok(previousMessageAt >= activityAt, `${session.id} is out of last-message recency order`);
201
+ }
202
+ previousMessageAt = activityAt;
203
+ }
204
+ // listProjects() already returns canonical display order, so it is idempotent.
205
+ assert.deepEqual(normalizeProjects(lite.listProjects()), normalizeProjects(buildProjectDisplayList(lite.listProjects())));
206
+ // Every resolved turn resolves a context, and every session answers related-work lookups.
207
+ for (const turn of lite.listResolvedTurns()) {
208
+ assert.ok(lite.getTurnContext(turn.id), `missing turn context for ${turn.id}`);
209
+ }
210
+ for (const session of lite.listResolvedSessions()) {
211
+ assert.ok(Array.isArray(jsonNormalize(lite.listSessionRelatedWork(session.id))));
212
+ }
213
+ // The injected AskUserQuestion turn survives materialization intact.
214
+ const askTurns = sortById(lite.listAskUserQuestionTurns());
215
+ const injectedAsk = askTurns.find((turn) => turn.id === "ask-user-question-lite-parity");
216
+ assert.ok(injectedAsk, "injected AskUserQuestion turn was dropped");
217
+ assert.equal(injectedAsk.tool_name, "request_user_input");
218
+ assert.deepEqual(injectedAsk.answers, [{ question_index: 0, selected_label: "All fixtures" }]);
219
+ // Search covers the fixture corpus and honours Lite indexing boundaries.
220
+ const liteSearch = lite.search({ query: "mock", limit: 10_000 });
221
+ assert.ok(liteSearch.total > 0);
222
+ assert.equal(liteSearch.results.length, Math.min(liteSearch.total, 10_000));
223
+ assert.ok(liteSearch.results.every((result) => lite.getTurnContext(result.turn.id)));
224
+ for (const [query, expectedTotal] of [
225
+ // A token that only exists past the indexed head of a long turn stays unsearchable.
226
+ ["lite-full-tail-only-token", 0],
227
+ // A project-observation fingerprint stays searchable.
228
+ ["fingerprint-lite-full-search-parity", undefined],
229
+ ]) {
230
+ const liteBoundarySearch = lite.search({ query, limit: 10_000 });
231
+ if (expectedTotal !== undefined) {
232
+ assert.equal(liteBoundarySearch.total, expectedTotal, `search total for ${query}`);
233
+ }
234
+ else {
235
+ assert.ok(liteBoundarySearch.total > 0, `search total for ${query}`);
236
+ }
237
+ }
238
+ // Usage aggregation is deterministic apart from its generation timestamp.
239
+ assert.deepEqual(withoutGeneratedAt(lite.getUsageOverview()), withoutGeneratedAt(lite.getUsageOverview()));
240
+ for (const dimension of ["source", "project", "model", "day"]) {
241
+ assert.deepEqual(withoutGeneratedAt(lite.getUsageRollup(dimension)), withoutGeneratedAt(lite.getUsageRollup(dimension)));
242
+ }
243
+ // Lite never creates a persistent store while materializing.
244
+ await assert.rejects(access(path.join(tempStore, ".cchistory")));
245
+ }
246
+ finally {
247
+ await rm(tempStore, { recursive: true, force: true });
248
+ }
249
+ });
250
+ test("Lite targeted probes preserve one-session parity across the fixture adapter matrix", async () => {
251
+ for (const [sourceRef, relativePath] of Object.entries(fixtureRoots)) {
252
+ const scanOptions = {
253
+ homeDir: path.join(mockDataRoot, "empty-home"),
254
+ hostname: `cchistory-lite-target-matrix-${sourceRef}`,
255
+ sourceRefs: [sourceRef],
256
+ sourceRoots: [{ sourceRef, baseDir: path.join(mockDataRoot, relativePath) }],
257
+ safeMode: true,
258
+ };
259
+ const full = await scanLiteHistory({ ...scanOptions, contextMode: "full" });
260
+ const target = full.listResolvedSessions().find((session) => session.source_session_id);
261
+ if (!target?.source_session_id)
262
+ continue;
263
+ const targeted = await scanLiteHistory({
264
+ ...scanOptions,
265
+ contextMode: "full",
266
+ sessionRefs: [target.source_session_id],
267
+ });
268
+ const expectedSessionIds = new Set([
269
+ target.id,
270
+ ...full.listDelegatedChildren(target.id)
271
+ .map((child) => child.child_session_ref)
272
+ .filter((id) => id !== undefined),
273
+ ]);
274
+ assert.deepEqual(targeted.listResolvedSessions().map(targetSessionParityFields), full.listResolvedSessions().filter((session) => expectedSessionIds.has(session.id)).map(targetSessionParityFields), `${sourceRef} session parity`);
275
+ assert.equal(targeted.listTopLevelSessions().some((session) => session.id !== target.id && expectedSessionIds.has(session.id)), false, `${sourceRef} delegated children stay out of top-level collections`);
276
+ assert.deepEqual(targeted.listResolvedTurns().map(targetTurnParityFields), full.listResolvedTurns().filter((turn) => expectedSessionIds.has(turn.session_id)).map(targetTurnParityFields), `${sourceRef} turn parity`);
277
+ const targetTurnIds = new Set(full.listResolvedTurns()
278
+ .filter((turn) => expectedSessionIds.has(turn.session_id))
279
+ .map((turn) => turn.id));
280
+ assert.deepEqual(targeted.data.contexts.map(targetContextParityFields), full.data.contexts.filter((context) => targetTurnIds.has(context.turn_id)).map(targetContextParityFields), `${sourceRef} context parity`);
281
+ }
282
+ });
283
+ test("every logical-session projection boundary preserves source-wide canonical parity", async () => {
284
+ const logicalPlatforms = listPlatformAdapters()
285
+ .filter((adapter) => adapter.projectionBoundary === "logical_session")
286
+ .map((adapter) => adapter.platform);
287
+ for (const platform of logicalPlatforms) {
288
+ const relativePath = fixtureRoots[platform];
289
+ assert.ok(relativePath, `missing live-runtime fixture root for ${platform}`);
290
+ const scanOptions = {
291
+ homeDir: path.join(mockDataRoot, "empty-home"),
292
+ hostname: `cchistory-lite-projection-boundary-${platform}`,
293
+ sourceRefs: [platform],
294
+ sourceRoots: [{ sourceRef: platform, baseDir: path.join(mockDataRoot, relativePath) }],
295
+ safeMode: true,
296
+ };
297
+ const sources = await resolveLiteSources(scanOptions);
298
+ const sourceWide = buildLiveSnapshot(await runSourceProbe({ safe_mode: true }, sources));
299
+ const grouped = await scanLiteHistory({ ...scanOptions, contextMode: "full" });
300
+ assert.deepEqual(grouped.listResolvedSessions(), sourceWide.listResolvedSessions(), `${platform} sessions`);
301
+ assert.deepEqual(grouped.listResolvedTurns(), sourceWide.listResolvedTurns(), `${platform} turns`);
302
+ assert.deepEqual(grouped.data.contexts, sourceWide.data.contexts, `${platform} contexts`);
303
+ assert.deepEqual(normalizeProjects(grouped.listProjects()), normalizeProjects(sourceWide.listProjects()), `${platform} projects`);
304
+ assert.deepEqual(grouped.data.related_work, sourceWide.data.related_work, `${platform} related work`);
305
+ assert.deepEqual(grouped.listAskUserQuestionTurns(), sourceWide.listAskUserQuestionTurns(), `${platform} questions`);
306
+ assert.deepEqual(grouped.projectionIssues, sourceWide.projectionIssues, `${platform} projection issues`);
307
+ assert.deepEqual(withoutGeneratedAt(grouped.getUsageOverview({ include_known_zero_token: true })), withoutGeneratedAt(sourceWide.getUsageOverview({ include_known_zero_token: true })), `${platform} usage`);
308
+ assert.deepEqual(grouped.data.session_contributions, sourceWide.data.session_contributions, `${platform} contributions`);
309
+ assert.deepEqual(grouped.data.delegated_children, sourceWide.data.delegated_children, `${platform} delegated children`);
310
+ assert.deepEqual(grouped.listSessionFamilies(), sourceWide.listSessionFamilies(), `${platform} families`);
311
+ }
312
+ });
313
+ test("Lite keeps Codex delegated children addressable but out of top-level projections", async () => {
314
+ const common = {
315
+ homeDir: path.join(mockDataRoot, "empty-home"),
316
+ hostname: "cchistory-lite-codex-delegation-host",
317
+ sourceRefs: ["codex"],
318
+ sourceRoots: [{ sourceRef: "codex", baseDir: path.join(mockDataRoot, fixtureRoots.codex) }],
319
+ safeMode: true,
320
+ contextMode: "full",
321
+ };
322
+ const parentId = "sess:codex:codex-delegation-parent";
323
+ const childId = "sess:codex:codex-delegation-child";
324
+ const full = await scanLiteHistory(common);
325
+ const child = full.getSession(childId);
326
+ assert.ok(full.getSession(parentId));
327
+ assert.ok(child);
328
+ assert.equal(child.title, "Atlas");
329
+ assert.equal(child.turn_count, 0);
330
+ assert.equal(child.resume_command, undefined);
331
+ assert.equal(full.listResolvedSessions().some((session) => session.id === childId), true);
332
+ assert.equal(full.listTopLevelSessions().some((session) => session.id === childId), false);
333
+ const treeSessionIds = full.getProjectsTreeProjection().projects
334
+ .flatMap((node) => node.sessions)
335
+ .concat(full.getProjectsTreeProjection().unlinkedSessions)
336
+ .map((session) => session.id);
337
+ assert.equal(treeSessionIds.includes(childId), false);
338
+ assert.equal(full.search({ query: "Keep this delegated instruction as evidence only." }).total, 0);
339
+ assert.equal(full.getUsageOverview({ include_known_zero_token: true }).total_turns, full.listResolvedTurns().length);
340
+ assert.deepEqual(full.projectionIssues, []);
341
+ const parentRelated = full.listSessionRelatedWork(parentId);
342
+ assert.ok(parentRelated.some((entry) => entry.relation_kind === "delegated_session" &&
343
+ entry.direction === "outbound" &&
344
+ entry.child_session_ref === childId));
345
+ const childRelated = full.listSessionRelatedWork(childId);
346
+ assert.ok(childRelated.some((entry) => entry.relation_kind === "delegated_session" &&
347
+ entry.direction === "inbound" &&
348
+ entry.parent_session_ref === parentId));
349
+ const family = full.getSessionFamily(parentId);
350
+ assert.ok(family);
351
+ assert.equal(family.child_count, 1);
352
+ assert.equal(family.children[0]?.child_session_ref, childId);
353
+ assert.ok((family.combined.storage_bytes ?? 0) >= (family.parent.storage_bytes ?? 0));
354
+ assert.equal(full.listSessionFamilies().filter((entry) => entry.parent_session_ref === parentId).length, 1);
355
+ assert.equal(full.getSessionFamily(childId), undefined);
356
+ const targetedParent = await scanLiteHistory({ ...common, sessionRefs: [parentId] });
357
+ assert.deepEqual(new Set(targetedParent.listResolvedSessions().map((session) => session.id)), new Set([parentId, childId]));
358
+ assert.ok(targetedParent.getSession(childId));
359
+ assert.equal(targetedParent.listTopLevelSessions().some((session) => session.id === childId), false);
360
+ assert.equal(targetedParent.getSessionFamily(parentId)?.children[0]?.child_session_ref, childId);
361
+ assert.equal(targetedParent.getSession(childId)?.title, child.title);
362
+ assert.ok(targetedParent.listSessionRelatedWork(parentId).some((entry) => entry.direction === "outbound" && entry.child_session_ref === childId));
363
+ assert.deepEqual(targetedParent.projectionIssues, []);
364
+ const targetedChild = await scanLiteHistory({ ...common, sessionRefs: [childId] });
365
+ assert.deepEqual(targetedChild.listResolvedSessions().map((session) => session.id), [childId]);
366
+ assert.deepEqual(targetedChild.listTopLevelSessions().map((session) => session.id), [childId]);
367
+ assert.equal(targetedChild.getSession(childId)?.title, "Atlas");
368
+ assert.ok(targetedChild.listSessionRelatedWork(childId).some((entry) => entry.direction === "inbound" && entry.parent_session_ref === parentId));
369
+ assert.deepEqual(targetedChild.projectionIssues, []);
370
+ });
371
+ test("Lite keeps Grok delegated children addressable but out of top-level projections", async () => {
372
+ const common = {
373
+ homeDir: path.join(mockDataRoot, "empty-home"),
374
+ hostname: "cchistory-lite-grok-delegation-host",
375
+ sourceRefs: ["grok"],
376
+ sourceRoots: [{ sourceRef: "grok", baseDir: path.join(mockDataRoot, fixtureRoots.grok) }],
377
+ safeMode: true,
378
+ contextMode: "full",
379
+ };
380
+ const parentId = "sess:grok:aaaaaaaa-bbbb-4ccc-8ddd-eeeeeeeeeeee";
381
+ const childId = "sess:grok:bbbbbbbb-cccc-4ddd-8eee-ffffffffffff";
382
+ const full = await scanLiteHistory(common);
383
+ const child = full.getSession(childId);
384
+ assert.ok(full.getSession(parentId));
385
+ assert.ok(child);
386
+ assert.equal(child.title, "Grok adapter child review");
387
+ assert.equal(child.resume_command, undefined);
388
+ assert.equal(full.listResolvedSessions().some((session) => session.id === childId), true);
389
+ assert.equal(full.listTopLevelSessions().some((session) => session.id === childId), false);
390
+ const tree = full.getProjectsTreeProjection();
391
+ const treeSessionIds = tree.projects
392
+ .flatMap((node) => node.sessions)
393
+ .concat(tree.unlinkedSessions)
394
+ .map((session) => session.id);
395
+ assert.equal(treeSessionIds.includes(childId), false);
396
+ assert.ok(tree.projects.some((node) => node.turns.some((turn) => turn.session_id === childId)), "delegated child turns stay visible in the parent project bucket");
397
+ assert.equal(full.search({ query: "delegated child" }).total, 1);
398
+ assert.deepEqual(full.projectionIssues, []);
399
+ const parentRelated = full.listSessionRelatedWork(parentId);
400
+ assert.ok(parentRelated.some((entry) => entry.relation_kind === "delegated_session" &&
401
+ entry.direction === "outbound" &&
402
+ entry.child_session_ref === childId));
403
+ const childInbound = full.listSessionRelatedWork(childId).filter((entry) => entry.relation_kind === "delegated_session" &&
404
+ entry.direction === "inbound");
405
+ assert.equal(childInbound.length, 1);
406
+ assert.equal(childInbound[0]?.parent_session_ref, parentId);
407
+ const family = full.getSessionFamily(parentId);
408
+ assert.ok(family);
409
+ assert.equal(family.child_count, 1);
410
+ assert.equal(family.children[0]?.child_session_ref, childId);
411
+ assert.ok(family.combined.storage_bytes > family.parent.storage_bytes);
412
+ assert.equal(family.children.filter((entry) => entry.child_session_ref === childId).length, 1);
413
+ assert.equal(full.getSessionFamily(childId), undefined);
414
+ const targetedParent = await scanLiteHistory({ ...common, sessionRefs: [parentId] });
415
+ assert.ok(targetedParent.getSession(childId));
416
+ assert.equal(targetedParent.listTopLevelSessions().some((session) => session.id === childId), false);
417
+ assert.equal(targetedParent.getSessionFamily(parentId)?.children[0]?.child_session_ref, childId);
418
+ assert.equal(targetedParent.getSession(childId)?.title, child.title);
419
+ assert.deepEqual(targetedParent.projectionIssues, []);
420
+ });
421
+ test("Lite inventories Claude sidecar subagent files under the parent session", async () => {
422
+ const snapshot = await scanLiteHistory({
423
+ homeDir: path.join(mockDataRoot, "empty-home"),
424
+ hostname: "cchistory-lite-claude-sidecar-host",
425
+ sourceRefs: ["claude_code"],
426
+ sourceRoots: [{
427
+ sourceRef: "claude_code",
428
+ baseDir: path.join(mockDataRoot, ".claude", "projects", "-Users-mock-user-workspace-chat-ui-kit"),
429
+ }],
430
+ safeMode: true,
431
+ contextMode: "full",
432
+ });
433
+ const parentId = "sess:claude_code:cc1df109-4282-4321-8248-8bbcd471da78";
434
+ const family = snapshot.getSessionFamily(parentId);
435
+ assert.ok(family);
436
+ assert.equal(family.child_count, 1);
437
+ assert.equal(family.children[0]?.identity_kind, "sidecar");
438
+ assert.equal(family.children[0]?.child_session_ref, undefined);
439
+ assert.ok(family.combined.storage_bytes > family.parent.storage_bytes);
440
+ assert.equal(snapshot.listTopLevelSessions().some((session) => session.id === parentId), true);
441
+ const families = snapshot.listSessionFamilies();
442
+ assert.equal(families.filter((entry) => entry.parent_session_ref === parentId).length, 1);
443
+ assert.equal(families.every((entry) => snapshot.getSession(entry.parent_session_ref) !== undefined), true);
444
+ assert.equal(families.some((entry) => entry.children.some((child) => child.child_session_ref === parentId)), false);
445
+ });
446
+ test("Lite does not list Claude message parentUuid ancestry as a session family", async () => {
447
+ const tempRoot = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-claude-parent-uuid-"));
448
+ try {
449
+ const sourceSessionId = "9d77cfc2-1e2e-4fcb-a0f5-0013bd8cf101";
450
+ const projectDir = path.join(tempRoot, ".claude", "projects", "-workspace-claude-parent-uuid");
451
+ await mkdir(projectDir, { recursive: true });
452
+ await writeFile(path.join(projectDir, `${sourceSessionId}.jsonl`), await readFile(path.join(mockDataRoot, "fixtures", "source-shapes", "claude", "ordinary-parent-uuid.jsonl")));
453
+ const snapshot = await scanLiteHistory({
454
+ homeDir: tempRoot,
455
+ hostname: "cchistory-lite-claude-parent-uuid-host",
456
+ sourceRefs: ["claude_code"],
457
+ sourceRoots: [{ sourceRef: "claude_code", baseDir: projectDir }],
458
+ safeMode: true,
459
+ contextMode: "full",
460
+ });
461
+ const sessionId = `sess:claude_code:${sourceSessionId}`;
462
+ assert.ok(snapshot.getSession(sessionId));
463
+ assert.equal(snapshot.listSessionFamilies().length, 0);
464
+ assert.equal(snapshot.getSessionFamily(sessionId), undefined);
465
+ assert.equal(snapshot.data.delegated_children.some((child) => child.child_session_ref === sessionId), false);
466
+ }
467
+ finally {
468
+ await rm(tempRoot, { recursive: true, force: true });
469
+ }
470
+ });
471
+ test("Lite path-links Cursor nested subagent transcripts out of top-level collections", async () => {
472
+ const tempRoot = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-cursor-family-"));
473
+ try {
474
+ const parentId = "aaaaaaaa-bbbb-4ccc-8ddd-eeeeeeeeee01";
475
+ const childId = "agent-aaaa";
476
+ const transcriptDir = path.join(tempRoot, ".cursor", "projects", "workspace-a", "agent-transcripts", parentId);
477
+ await mkdir(path.join(transcriptDir, "subagents"), { recursive: true });
478
+ await writeFile(path.join(transcriptDir, `${parentId}.jsonl`), `${JSON.stringify({ role: "user", message: { content: [{ type: "text", text: "Parent ask." }] } })}\n`, "utf8");
479
+ await writeFile(path.join(transcriptDir, "subagents", `${childId}.jsonl`), `${JSON.stringify({ role: "user", message: { content: [{ type: "text", text: "Child ask." }] } })}\n`, "utf8");
480
+ const snapshot = await scanLiteHistory({
481
+ homeDir: tempRoot,
482
+ hostname: "cchistory-lite-cursor-family-host",
483
+ sourceRefs: ["cursor_agent"],
484
+ sourceRoots: [{ sourceRef: "cursor_agent", baseDir: path.join(tempRoot, ".cursor", "projects") }],
485
+ safeMode: true,
486
+ contextMode: "full",
487
+ });
488
+ const parentRef = `sess:cursor_agent:${parentId}`;
489
+ const childRef = `sess:cursor_agent:${childId}`;
490
+ assert.ok(snapshot.getSession(parentRef));
491
+ assert.ok(snapshot.getSession(childRef));
492
+ const family = snapshot.getSessionFamily(parentRef);
493
+ assert.ok(family);
494
+ assert.equal(family.child_count, 1);
495
+ assert.equal(family.children[0]?.identity_kind, "session");
496
+ assert.equal(family.children[0]?.child_session_ref, childRef);
497
+ assert.equal(snapshot.listTopLevelSessions().some((session) => session.id === childRef), false);
498
+ assert.equal(snapshot.listTopLevelSessions().some((session) => session.id === parentRef), true);
499
+ assert.equal(snapshot.getSessionFamily(childRef), undefined);
500
+ }
501
+ finally {
502
+ await rm(tempRoot, { recursive: true, force: true });
503
+ }
504
+ });
505
+ test("Lite scans explicit roots without creating or reading a Full store", async () => {
506
+ const tempHome = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-no-store-"));
507
+ try {
508
+ const resolved = await resolveLiteSources({
509
+ homeDir: tempHome,
510
+ sourceRoots: [
511
+ { sourceRef: "codex", baseDir: path.join(mockDataRoot, ".codex", "sessions") },
512
+ ],
513
+ });
514
+ assert.deepEqual(resolved.map((source) => source.platform), ["codex"]);
515
+ const snapshot = await scanLiteHistory({
516
+ homeDir: tempHome,
517
+ safeMode: true,
518
+ sourceRoots: [
519
+ { sourceRef: "codex", baseDir: path.join(mockDataRoot, ".codex", "sessions") },
520
+ ],
521
+ });
522
+ assert.ok(snapshot.listResolvedTurns().length > 0);
523
+ await assert.rejects(access(path.join(tempHome, ".cchistory")));
524
+ await assert.rejects(scanLiteHistory({
525
+ homeDir: tempHome,
526
+ sourceRoots: [{ sourceRef: "codex", baseDir: path.join(tempHome, ".cchistory") }],
527
+ }), /Full store paths are not Lite sources/);
528
+ const fullStoreRoot = path.join(tempHome, "full-store");
529
+ await mkdir(fullStoreRoot);
530
+ await writeFile(path.join(fullStoreRoot, "cchistory.sqlite"), "not opened by Lite");
531
+ await assert.rejects(assertLiteSourceRoot(fullStoreRoot), /Full store paths are not Lite sources/);
532
+ // Case variants resolve to the Full store on case-insensitive filesystems
533
+ // (macOS/Windows), so the guard rejects them everywhere.
534
+ const caseVariantStoreRoot = path.join(tempHome, ".CCHistory");
535
+ await mkdir(caseVariantStoreRoot);
536
+ await assert.rejects(assertLiteSourceRoot(caseVariantStoreRoot), /Full store paths are not Lite sources/);
537
+ const caseVariantStoreFile = path.join(tempHome, "CCHistory.sqlite");
538
+ await writeFile(caseVariantStoreFile, "not opened by Lite");
539
+ await assert.rejects(assertLiteSourceRoot(caseVariantStoreFile), /Full store paths are not Lite sources/);
540
+ const fullBundleRoot = path.join(tempHome, "full-bundle");
541
+ await mkdir(path.join(fullBundleRoot, "payloads"), { recursive: true });
542
+ await writeFile(path.join(fullBundleRoot, "manifest.json"), "{}");
543
+ await assert.rejects(assertLiteSourceRoot(fullBundleRoot), /Full bundle paths are not Lite sources/);
544
+ // `recursive` because the ".CCHistory" probe above already created this exact
545
+ // directory on case-insensitive filesystems (macOS/Windows).
546
+ const canonicalFullRoot = path.join(tempHome, ".cchistory");
547
+ await mkdir(canonicalFullRoot, { recursive: true });
548
+ await writeFile(path.join(canonicalFullRoot, "cchistory.sqlite"), "not opened by Lite");
549
+ await assert.rejects(assertLiteSourceRoot(tempHome, { homeDir: tempHome }), /overlapping the Full store are not allowed in Lite/);
550
+ }
551
+ finally {
552
+ await rm(tempHome, { recursive: true, force: true });
553
+ }
554
+ });
555
+ test("Lite rebuilds native inventory for appended, added, and deleted sessions", async () => {
556
+ const tempHome = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-live-inventory-"));
557
+ const sourceRoot = path.join(tempHome, "sessions");
558
+ const firstPath = path.join(sourceRoot, "rollout-2026-08-12T00-00-00-live-first.jsonl");
559
+ const secondPath = path.join(sourceRoot, "rollout-2026-08-12T00-01-00-live-second.jsonl");
560
+ const common = {
561
+ homeDir: tempHome,
562
+ hostname: "cchistory-lite-live-inventory-host",
563
+ sourceRefs: ["codex"],
564
+ sourceRoots: [{ sourceRef: "codex", baseDir: sourceRoot }],
565
+ safeMode: true,
566
+ contextMode: "none",
567
+ };
568
+ try {
569
+ await mkdir(sourceRoot, { recursive: true });
570
+ await writeFile(firstPath, codexSessionJsonl("live-first", "First live inventory turn.", "00:00"), "utf8");
571
+ const initial = await scanLiteHistory(common);
572
+ assert.deepEqual(initial.listResolvedSessions().map((session) => session.source_session_id), ["live-first"]);
573
+ assert.equal(initial.listResolvedTurns().length, 1);
574
+ await appendFile(firstPath, `\n${codexTurnJsonl("live-first", "Appended live inventory turn.", "00:02")}`, "utf8");
575
+ const advancedMtime = new Date("2030-01-01T00:00:00.000Z");
576
+ await utimes(firstPath, advancedMtime, advancedMtime);
577
+ const appended = await scanLiteHistory(common);
578
+ assert.equal(appended.listResolvedTurns().length, 2);
579
+ assert.equal(appended.search({ query: "Appended live inventory" }).total, 1);
580
+ await writeFile(secondPath, codexSessionJsonl("live-second", "Second live inventory session.", "00:01"), "utf8");
581
+ const added = await scanLiteHistory(common);
582
+ assert.deepEqual(added.listResolvedSessions().map((session) => session.source_session_id).sort(), ["live-first", "live-second"]);
583
+ await rm(firstPath);
584
+ const deleted = await scanLiteHistory(common);
585
+ assert.deepEqual(deleted.listResolvedSessions().map((session) => session.source_session_id), ["live-second"]);
586
+ assert.equal(deleted.search({ query: "Appended live inventory" }).total, 0);
587
+ await assert.rejects(access(path.join(tempHome, ".cchistory")));
588
+ }
589
+ finally {
590
+ await rm(tempHome, { recursive: true, force: true });
591
+ }
592
+ });
593
+ test("Lite context-light Codex scanning preserves canonical turns while releasing contexts", async () => {
594
+ const tempHome = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-codex-stream-"));
595
+ try {
596
+ const sourceRoots = [
597
+ { sourceRef: "codex", baseDir: path.join(mockDataRoot, fixtureRoots.codex) },
598
+ ];
599
+ const sources = await resolveLiteSources({
600
+ homeDir: tempHome,
601
+ hostname: "cchistory-lite-codex-stream-host",
602
+ sourceRefs: ["codex"],
603
+ sourceRoots,
604
+ });
605
+ const expectedProbe = await runSourceProbe({ safe_mode: true }, sources);
606
+ const expected = buildLiveSnapshot(expectedProbe);
607
+ const actual = await scanLiteHistory({
608
+ homeDir: tempHome,
609
+ hostname: "cchistory-lite-codex-stream-host",
610
+ sourceRefs: ["codex"],
611
+ sourceRoots,
612
+ safeMode: true,
613
+ contextMode: "none",
614
+ });
615
+ assert.deepEqual(actual.listResolvedSessions(), expected.listResolvedSessions());
616
+ assert.deepEqual(actual.listResolvedTurns(), expected.listResolvedTurns());
617
+ assert.deepEqual(normalizeProjects(actual.listProjects()), normalizeProjects(expected.listProjects()));
618
+ assert.deepEqual(actual.listAskUserQuestionTurns(), expected.listAskUserQuestionTurns());
619
+ assert.deepEqual(actual.listSources().map(withoutRunTimestamp), expected.listSources().map(withoutRunTimestamp));
620
+ assert.equal(actual.data.contexts.length, 0);
621
+ assert.ok(expected.data.contexts.length > 0);
622
+ }
623
+ finally {
624
+ await rm(tempHome, { recursive: true, force: true });
625
+ }
626
+ });
627
+ test("Lite targeted full-context scan materializes only the requested logical session", async () => {
628
+ const base = await scanLiteHistory({
629
+ homeDir: path.join(mockDataRoot, "empty-home"),
630
+ hostname: "cchistory-lite-targeted-context-host",
631
+ sourceRefs: ["codex"],
632
+ sourceRoots: [{ sourceRef: "codex", baseDir: path.join(mockDataRoot, fixtureRoots.codex) }],
633
+ safeMode: true,
634
+ contextMode: "none",
635
+ });
636
+ const target = base.listResolvedSessions()[0];
637
+ assert.ok(target?.source_session_id);
638
+ const detailed = await scanLiteHistory({
639
+ homeDir: path.join(mockDataRoot, "empty-home"),
640
+ hostname: "cchistory-lite-targeted-context-host",
641
+ sourceRefs: ["codex"],
642
+ sourceRoots: [{ sourceRef: "codex", baseDir: path.join(mockDataRoot, fixtureRoots.codex) }],
643
+ safeMode: true,
644
+ contextMode: "full",
645
+ sessionRefs: [target.source_session_id],
646
+ });
647
+ assert.deepEqual(new Set(detailed.listResolvedSessions().map((session) => session.id)), new Set([
648
+ target.id,
649
+ ...base.listDelegatedChildren(target.id)
650
+ .map((child) => child.child_session_ref)
651
+ .filter((id) => id !== undefined),
652
+ ]));
653
+ const turn = detailed.listResolvedTurns()[0];
654
+ assert.ok(turn);
655
+ assert.ok(detailed.getTurnContext(turn.id));
656
+ });
657
+ test("Lite directory scope is consistent across sessions, turns, projects, search, and usage", async () => {
658
+ const snapshot = await scanLiteHistory({
659
+ homeDir: path.join(mockDataRoot, "empty-home"),
660
+ hostname: "cchistory-lite-directory-scope-host",
661
+ sourceRefs: ["codex"],
662
+ sourceRoots: [{ sourceRef: "codex", baseDir: path.join(mockDataRoot, fixtureRoots.codex) }],
663
+ safeMode: true,
664
+ contextMode: "none",
665
+ });
666
+ const targetSession = snapshot.listResolvedSessions().find((session) => session.working_directory);
667
+ assert.ok(targetSession?.working_directory);
668
+ const directoryScope = targetSession.working_directory;
669
+ const sessions = snapshot.listResolvedSessions({ directoryScope });
670
+ const sessionIds = new Set(sessions.map((session) => session.id));
671
+ const turns = snapshot.listResolvedTurns({ directoryScope });
672
+ assert.ok(sessions.length > 0);
673
+ assert.ok(sessions.every((session) => session.working_directory?.startsWith(directoryScope)));
674
+ assert.ok(turns.every((turn) => sessionIds.has(turn.session_id)));
675
+ assert.ok(snapshot.listProjects({ directoryScope }).length > 0);
676
+ const query = turns[0]?.canonical_text.split(/\s+/u).find((part) => part.length >= 4);
677
+ assert.ok(query);
678
+ const search = snapshot.search({ query, directoryScope, limit: 100 });
679
+ assert.ok(search.total > 0);
680
+ assert.ok(search.results.every((result) => sessionIds.has(result.turn.session_id)));
681
+ assert.equal(snapshot.getUsageOverview({ directory_scope: directoryScope }).total_turns, turns.length);
682
+ assert.equal(snapshot.getUsageRollup("source", { directory_scope: directoryScope }).rows.reduce((total, row) => total + row.turn_count, 0), turns.length);
683
+ });
684
+ test("Lite --dir uses Codex first-line cwd and still probes split-file sessions together", async () => {
685
+ const tempHome = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-directory-pushdown-"));
686
+ const codexRoot = path.join(tempHome, "codex-sessions");
687
+ try {
688
+ await mkdir(codexRoot, { recursive: true });
689
+ const writeSession = async (fileName, sessionId, initialDirectory, finalDirectory, day = "01") => {
690
+ await writeFile(path.join(codexRoot, fileName), [
691
+ {
692
+ timestamp: `2026-07-${day}T00:00:00.000Z`,
693
+ type: "session_meta",
694
+ payload: { id: sessionId, cwd: initialDirectory },
695
+ },
696
+ {
697
+ timestamp: `2026-07-${day}T00:00:01.000Z`,
698
+ type: "turn_context",
699
+ payload: { cwd: finalDirectory, model: "gpt-5" },
700
+ },
701
+ {
702
+ timestamp: `2026-07-${day}T00:00:02.000Z`,
703
+ type: "response_item",
704
+ payload: {
705
+ type: "message",
706
+ role: "user",
707
+ content: [{ type: "input_text", text: `Question for ${sessionId}` }],
708
+ },
709
+ },
710
+ {
711
+ timestamp: `2026-07-${day}T00:00:03.000Z`,
712
+ type: "response_item",
713
+ payload: {
714
+ type: "message",
715
+ role: "assistant",
716
+ content: [{ type: "output_text", text: `Answer for ${sessionId}` }],
717
+ },
718
+ },
719
+ ].map((row) => JSON.stringify(row)).join("\n"), "utf8");
720
+ };
721
+ await writeSession("target.jsonl", "directory-target", "/workspace/app/subdir", "/workspace/app/subdir");
722
+ await writeSession("outside.jsonl", "directory-outside", "/workspace/application", "/workspace/application");
723
+ await writeSession("changed.jsonl", "directory-changed", "/workspace/elsewhere", "/workspace/app/moved");
724
+ await writeSession("split-a.jsonl", "directory-split", "/workspace/elsewhere", "/workspace/elsewhere");
725
+ await writeSession("split-b.jsonl", "directory-split", "/workspace/app/resumed", "/workspace/app/resumed", "02");
726
+ const common = {
727
+ homeDir: tempHome,
728
+ hostname: "cchistory-lite-directory-pushdown-host",
729
+ sourceRefs: ["codex"],
730
+ sourceRoots: [{ sourceRef: "codex", baseDir: codexRoot }],
731
+ safeMode: true,
732
+ contextMode: "none",
733
+ };
734
+ const full = await scanLiteHistory(common);
735
+ const fullyParsedFiles = [];
736
+ const scoped = await scanLiteHistory({
737
+ ...common,
738
+ directoryScope: "/workspace/app",
739
+ onProgress: (event) => {
740
+ if (event.stage === "file_start" && event.file_path)
741
+ fullyParsedFiles.push(path.basename(event.file_path));
742
+ },
743
+ });
744
+ const scopedIds = scoped.listResolvedSessions({ directoryScope: "/workspace/app" }).map((session) => session.source_session_id);
745
+ assert.ok(scopedIds.includes("directory-target"));
746
+ assert.equal(scopedIds.includes("directory-outside"), false);
747
+ assert.equal(scopedIds.includes("directory-changed"), false);
748
+ assert.ok(fullyParsedFiles.includes("target.jsonl"));
749
+ assert.equal(fullyParsedFiles.includes("outside.jsonl"), false);
750
+ assert.equal(fullyParsedFiles.includes("changed.jsonl"), false);
751
+ assert.ok(full.listResolvedSessions({ directoryScope: "/workspace/app" }).some((session) => session.source_session_id === "directory-changed"));
752
+ }
753
+ finally {
754
+ await rm(tempHome, { recursive: true, force: true });
755
+ }
756
+ });
757
+ test("Lite sample --dir keeps older Codex sessions inside the scope instead of the newest files", async () => {
758
+ const tempHome = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-sample-dir-"));
759
+ const codexRoot = path.join(tempHome, "codex-sessions");
760
+ try {
761
+ await mkdir(codexRoot, { recursive: true });
762
+ const writeSession = async (fileName, sessionId, cwd, mtime) => {
763
+ const filePath = path.join(codexRoot, fileName);
764
+ await writeFile(filePath, [
765
+ {
766
+ timestamp: "2026-07-01T00:00:00.000Z",
767
+ type: "session_meta",
768
+ payload: { id: sessionId, cwd },
769
+ },
770
+ {
771
+ timestamp: "2026-07-01T00:00:02.000Z",
772
+ type: "response_item",
773
+ payload: {
774
+ type: "message",
775
+ role: "user",
776
+ content: [{ type: "input_text", text: `Question for ${sessionId}` }],
777
+ },
778
+ },
779
+ {
780
+ timestamp: "2026-07-01T00:00:03.000Z",
781
+ type: "response_item",
782
+ payload: {
783
+ type: "message",
784
+ role: "assistant",
785
+ content: [{ type: "output_text", text: `Answer for ${sessionId}` }],
786
+ },
787
+ },
788
+ ].map((row) => JSON.stringify(row)).join("\n"), "utf8");
789
+ await utimes(filePath, mtime, mtime);
790
+ };
791
+ await writeSession("inside-old.jsonl", "sample-inside", "/workspace/app", new Date("2020-01-01T00:00:00.000Z"));
792
+ await writeSession("outside-new.jsonl", "sample-outside-new", "/workspace/other", new Date("2026-01-01T00:00:00.000Z"));
793
+ await writeSession("outside-newer.jsonl", "sample-outside-newer", "/workspace/other", new Date("2026-06-01T00:00:00.000Z"));
794
+ const parsedFiles = [];
795
+ const sampled = await scanLiteHistory({
796
+ homeDir: tempHome,
797
+ hostname: "cchistory-lite-sample-dir-host",
798
+ sourceRefs: ["codex"],
799
+ sourceRoots: [{ sourceRef: "codex", baseDir: codexRoot }],
800
+ safeMode: true,
801
+ contextMode: "none",
802
+ directoryScope: "/workspace/app",
803
+ sample: { perSource: 1 },
804
+ onProgress: (event) => {
805
+ if (event.stage === "file_start" && event.file_path)
806
+ parsedFiles.push(path.basename(event.file_path));
807
+ },
808
+ });
809
+ const sampledIds = sampled.listTopLevelSessions({ directoryScope: "/workspace/app" })
810
+ .filter((session) => session.turn_count > 0)
811
+ .map((session) => session.source_session_id);
812
+ assert.deepEqual(sampledIds, ["sample-inside"]);
813
+ assert.ok(parsedFiles.includes("inside-old.jsonl"));
814
+ assert.equal(parsedFiles.includes("outside-new.jsonl"), false);
815
+ assert.equal(parsedFiles.includes("outside-newer.jsonl"), false);
816
+ }
817
+ finally {
818
+ await rm(tempHome, { recursive: true, force: true });
819
+ }
820
+ });
821
+ test("Lite sample perSource below 1 selects no files", async () => {
822
+ const tempHome = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-sample-zero-"));
823
+ const codexRoot = path.join(tempHome, "codex-sessions");
824
+ try {
825
+ await mkdir(codexRoot, { recursive: true });
826
+ await writeFile(path.join(codexRoot, "keep.jsonl"), [
827
+ {
828
+ timestamp: "2026-07-01T00:00:00.000Z",
829
+ type: "session_meta",
830
+ payload: { id: "sample-zero", cwd: "/workspace/app" },
831
+ },
832
+ {
833
+ timestamp: "2026-07-01T00:00:02.000Z",
834
+ type: "response_item",
835
+ payload: {
836
+ type: "message",
837
+ role: "user",
838
+ content: [{ type: "input_text", text: "Should not be sampled." }],
839
+ },
840
+ },
841
+ ].map((row) => JSON.stringify(row)).join("\n"), "utf8");
842
+ const parsedFiles = [];
843
+ const sampled = await scanLiteHistory({
844
+ homeDir: tempHome,
845
+ hostname: "cchistory-lite-sample-zero-host",
846
+ sourceRefs: ["codex"],
847
+ sourceRoots: [{ sourceRef: "codex", baseDir: codexRoot }],
848
+ safeMode: true,
849
+ contextMode: "none",
850
+ sample: { perSource: 0 },
851
+ onProgress: (event) => {
852
+ if (event.stage === "file_start" && event.file_path)
853
+ parsedFiles.push(path.basename(event.file_path));
854
+ },
855
+ });
856
+ assert.equal(sampled.listTopLevelSessions().length, 0);
857
+ assert.deepEqual(parsedFiles, []);
858
+ }
859
+ finally {
860
+ await rm(tempHome, { recursive: true, force: true });
861
+ }
862
+ });
863
+ test("Lite matching-context scans retain only contexts needed by the requested ref", async () => {
864
+ const scanOptions = {
865
+ homeDir: path.join(mockDataRoot, "empty-home"),
866
+ hostname: "cchistory-lite-matching-context-host",
867
+ sourceRefs: ["codex"],
868
+ sourceRoots: [{ sourceRef: "codex", baseDir: path.join(mockDataRoot, fixtureRoots.codex) }],
869
+ safeMode: true,
870
+ };
871
+ const full = await scanLiteHistory({ ...scanOptions, contextMode: "full" });
872
+ const targetSession = full.listResolvedSessions().find((session) => session.source_session_id);
873
+ assert.ok(targetSession);
874
+ const sessionRef = full.getSessionDisplayRef(targetSession.id);
875
+ assert.ok(sessionRef);
876
+ const bySession = await scanLiteHistory({
877
+ ...scanOptions,
878
+ contextMode: "matching",
879
+ contextTarget: { kind: "session", ref: sessionRef },
880
+ });
881
+ const targetTurnIds = new Set(full.listSessionTurns(targetSession.id).map((turn) => turn.id));
882
+ assert.ok(bySession.data.contexts.length > 0);
883
+ assert.ok(bySession.data.contexts.every((context) => targetTurnIds.has(context.turn_id)));
884
+ assert.deepEqual(bySession.listResolvedSessions(), full.listResolvedSessions());
885
+ assert.deepEqual(bySession.listResolvedTurns(), full.listResolvedTurns());
886
+ const targetTurn = full.listSessionTurns(targetSession.id)[0];
887
+ assert.ok(targetTurn);
888
+ const turnRef = full.getTurnDisplayRef(targetTurn.id);
889
+ assert.ok(turnRef);
890
+ const byTurn = await scanLiteHistory({
891
+ ...scanOptions,
892
+ contextMode: "matching",
893
+ contextTarget: { kind: "turn", ref: turnRef },
894
+ });
895
+ assert.deepEqual(byTurn.data.contexts.map((context) => context.turn_id), [targetTurn.id]);
896
+ const targetTurns = full.listResolvedTurns().slice(0, 2);
897
+ const byTurns = await scanLiteHistory({
898
+ ...scanOptions,
899
+ contextMode: "matching",
900
+ contextTargets: targetTurns.map((turn) => ({ kind: "turn", ref: turn.id.slice(0, 12) })),
901
+ });
902
+ assert.deepEqual(new Set(byTurns.data.contexts.map((context) => context.turn_id)), new Set(targetTurns.map((turn) => turn.id)));
903
+ });
904
+ test("Lite display refs extend through collisions and remain actionable", () => {
905
+ const host = {
906
+ id: "host-display-ref",
907
+ hostname: "display-ref",
908
+ first_seen: "2026-01-01T00:00:00.000Z",
909
+ last_seen: "2026-01-01T00:00:00.000Z",
910
+ };
911
+ const baseSession = {
912
+ id: "sess:codex:abcdefgh-one",
913
+ source_id: "source-display-ref",
914
+ source_platform: "codex",
915
+ source_session_id: "abcdefgh-one",
916
+ host_id: host.id,
917
+ created_at: "2026-01-01T00:00:00.000Z",
918
+ updated_at: "2026-01-01T00:00:00.000Z",
919
+ turn_count: 1,
920
+ sync_axis: "current",
921
+ };
922
+ const sessions = [
923
+ baseSession,
924
+ { ...baseSession, id: "sess:codex:abcdefgh-two", source_session_id: "abcdefgh-two" },
925
+ ];
926
+ const turns = [
927
+ { ...createBlankRefTurn(sessions[0]), id: "12345678aaaa", turn_id: "12345678aaaa" },
928
+ { ...createBlankRefTurn(sessions[1]), id: "12345678bbbb", turn_id: "12345678bbbb" },
929
+ ];
930
+ const snapshot = new LiveHistorySnapshot({
931
+ host,
932
+ sources: [],
933
+ projects: [],
934
+ sessions,
935
+ turns,
936
+ contexts: [],
937
+ ask_user_question_turns: [],
938
+ loss_audits: [],
939
+ });
940
+ const sessionRef = snapshot.getSessionDisplayRef(sessions[0].id);
941
+ const turnRef = snapshot.getTurnDisplayRef(turns[0].id);
942
+ assert.equal(sessionRef, "abcdefgh-o");
943
+ assert.equal(turnRef, "12345678a");
944
+ assert.equal(snapshot.getSession(sessionRef)?.id, sessions[0].id);
945
+ assert.equal(snapshot.getTurn(turnRef)?.id, turns[0].id);
946
+ });
947
+ test("Lite direct canonical targeting narrows the source platform and fails loudly on misses", async () => {
948
+ const common = {
949
+ homeDir: path.join(mockDataRoot, "empty-home"),
950
+ hostname: "cchistory-lite-canonical-target-host",
951
+ sourceRefs: ["codex", "claude_code"],
952
+ sourceRoots: [
953
+ { sourceRef: "codex", baseDir: path.join(mockDataRoot, fixtureRoots.codex) },
954
+ { sourceRef: "claude_code", baseDir: path.join(mockDataRoot, fixtureRoots.claude_code) },
955
+ ],
956
+ safeMode: true,
957
+ };
958
+ const base = await scanLiteHistory({ ...common, contextMode: "none" });
959
+ const target = base.listResolvedSessions().find((session) => session.source_platform === "codex");
960
+ assert.ok(target);
961
+ const targeted = await scanLiteHistory({
962
+ ...common,
963
+ contextMode: "full",
964
+ sessionRefs: [target.id],
965
+ });
966
+ assert.deepEqual(targeted.listSources().map((source) => source.platform), ["codex"]);
967
+ assert.deepEqual(new Set(targeted.listResolvedSessions().map((session) => session.id)), new Set([
968
+ target.id,
969
+ ...base.listDelegatedChildren(target.id)
970
+ .map((child) => child.child_session_ref)
971
+ .filter((id) => id !== undefined),
972
+ ]));
973
+ const nativeTargeted = await scanLiteHistory({
974
+ ...common,
975
+ contextMode: "full",
976
+ sessionRefs: [target.source_session_id],
977
+ });
978
+ assert.deepEqual(new Set(nativeTargeted.listResolvedSessions().map((session) => session.id)), new Set([
979
+ target.id,
980
+ ...base.listDelegatedChildren(target.id)
981
+ .map((child) => child.child_session_ref)
982
+ .filter((id) => id !== undefined),
983
+ ]));
984
+ const codexTargets = base.listResolvedSessions()
985
+ .filter((session) => session.source_platform === "codex" && session.source_session_id)
986
+ .slice(0, 2);
987
+ assert.equal(codexTargets.length, 2);
988
+ const multiTargeted = await scanLiteHistory({
989
+ ...common,
990
+ contextMode: "full",
991
+ sessionRefs: codexTargets.map((session) => session.source_session_id),
992
+ });
993
+ assert.deepEqual(new Set(multiTargeted.listResolvedSessions().map((session) => session.id)), new Set([
994
+ ...codexTargets.map((session) => session.id),
995
+ ...codexTargets.flatMap((session) => base.listDelegatedChildren(session.id)
996
+ .map((child) => child.child_session_ref)
997
+ .filter((id) => id !== undefined)),
998
+ ]));
999
+ await assert.rejects(scanLiteHistory({
1000
+ ...common,
1001
+ contextMode: "full",
1002
+ sessionRefs: ["sess:codex:does-not-exist"],
1003
+ }), /requested session/);
1004
+ const uniquePrefix = uniqueCanonicalSessionPrefix(target.id, base.listResolvedSessions().map((session) => session.id));
1005
+ const prefixTargeted = await scanLiteHistory({
1006
+ ...common,
1007
+ contextMode: "full",
1008
+ sessionRefs: [uniquePrefix],
1009
+ });
1010
+ assert.equal(prefixTargeted.getSession(uniquePrefix)?.id, target.id);
1011
+ assert.deepEqual(new Set(prefixTargeted.listResolvedSessions().map((session) => session.id)), new Set(targeted.listResolvedSessions().map((session) => session.id)));
1012
+ });
1013
+ test("Lite targeted scans resolve unique OpenClaw prefixes with related work", async () => {
1014
+ const common = {
1015
+ homeDir: path.join(mockDataRoot, "empty-home"),
1016
+ hostname: "cchistory-lite-openclaw-prefix-host",
1017
+ sourceRefs: ["openclaw"],
1018
+ sourceRoots: [{ sourceRef: "openclaw", baseDir: path.join(mockDataRoot, fixtureRoots.openclaw) }],
1019
+ safeMode: true,
1020
+ contextMode: "full",
1021
+ };
1022
+ const ownerId = "sess:openclaw:11111111-2222-4333-8444-555555555555";
1023
+ const prefix = "sess:openclaw:11111111";
1024
+ const targeted = await scanLiteHistory({ ...common, sessionRefs: [prefix] });
1025
+ assert.equal(targeted.getSession(prefix)?.id, ownerId);
1026
+ assert.ok(targeted.listSessionRelatedWork(ownerId).some((entry) => entry.relation_kind === "automation_run" && entry.direction === "outbound"));
1027
+ assert.deepEqual(targeted.projectionIssues, []);
1028
+ });
1029
+ test("Lite context-light Claude scanning assembles parent and subagent files before projection", async () => {
1030
+ const tempHome = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-claude-stream-"));
1031
+ try {
1032
+ const sourceRoots = [
1033
+ { sourceRef: "claude_code", baseDir: path.join(mockDataRoot, fixtureRoots.claude_code) },
1034
+ ];
1035
+ const sources = await resolveLiteSources({
1036
+ homeDir: tempHome,
1037
+ hostname: "cchistory-lite-claude-stream-host",
1038
+ sourceRefs: ["claude_code"],
1039
+ sourceRoots,
1040
+ });
1041
+ const expectedProbe = await runSourceProbe({ safe_mode: true }, sources);
1042
+ const expected = buildLiveSnapshot(expectedProbe);
1043
+ const actual = await scanLiteHistory({
1044
+ homeDir: tempHome,
1045
+ hostname: "cchistory-lite-claude-stream-host",
1046
+ sourceRefs: ["claude_code"],
1047
+ sourceRoots,
1048
+ safeMode: true,
1049
+ contextMode: "none",
1050
+ });
1051
+ assert.deepEqual(actual.listResolvedSessions(), expected.listResolvedSessions());
1052
+ assert.deepEqual(actual.listResolvedTurns(), expected.listResolvedTurns());
1053
+ assert.deepEqual(normalizeProjects(actual.listProjects()), normalizeProjects(expected.listProjects()));
1054
+ assert.deepEqual(actual.listAskUserQuestionTurns(), expected.listAskUserQuestionTurns());
1055
+ assert.deepEqual(actual.listSources().map(withoutRunTimestamp), expected.listSources().map(withoutRunTimestamp));
1056
+ assert.equal(actual.data.contexts.length, 0);
1057
+ assert.ok(expected.data.contexts.length > 0);
1058
+ assert.ok(actual.listResolvedSessions().some((session) => session.source_session_id === "cc1df109-4282-4321-8248-8bbcd471da78"));
1059
+ }
1060
+ finally {
1061
+ await rm(tempHome, { recursive: true, force: true });
1062
+ }
1063
+ });
1064
+ test("Lite groups Claude files by content session id across different project paths", async () => {
1065
+ const tempHome = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-claude-cross-path-"));
1066
+ const claudeRoot = path.join(tempHome, "claude-projects");
1067
+ try {
1068
+ const sharedSessionId = "shared-claude-session";
1069
+ const firstDir = path.join(claudeRoot, "project-a");
1070
+ const secondDir = path.join(claudeRoot, "project-b");
1071
+ await mkdir(firstDir, { recursive: true });
1072
+ await mkdir(secondDir, { recursive: true });
1073
+ await writeFile(path.join(firstDir, "first-file.jsonl"), [
1074
+ JSON.stringify({
1075
+ type: "user",
1076
+ sessionId: sharedSessionId,
1077
+ cwd: "/workspace/shared",
1078
+ timestamp: "2026-07-01T00:00:00.000Z",
1079
+ message: { role: "user", content: "First cross-path question" },
1080
+ }),
1081
+ JSON.stringify({
1082
+ type: "assistant",
1083
+ sessionId: sharedSessionId,
1084
+ cwd: "/workspace/shared",
1085
+ timestamp: "2026-07-01T00:00:01.000Z",
1086
+ message: { role: "assistant", content: [{ type: "text", text: "First answer" }] },
1087
+ }),
1088
+ ].join("\n"), "utf8");
1089
+ await writeFile(path.join(secondDir, "second-file.jsonl"), [
1090
+ JSON.stringify({
1091
+ type: "user",
1092
+ sessionId: sharedSessionId,
1093
+ cwd: "/workspace/shared",
1094
+ timestamp: "2026-07-01T00:01:00.000Z",
1095
+ message: { role: "user", content: "Second cross-path question" },
1096
+ }),
1097
+ JSON.stringify({
1098
+ type: "assistant",
1099
+ sessionId: sharedSessionId,
1100
+ cwd: "/workspace/shared",
1101
+ timestamp: "2026-07-01T00:01:01.000Z",
1102
+ message: { role: "assistant", content: [{ type: "text", text: "Second answer" }] },
1103
+ }),
1104
+ ].join("\n"), "utf8");
1105
+ const sourceRoots = [{ sourceRef: "claude_code", baseDir: claudeRoot }];
1106
+ const sources = await resolveLiteSources({
1107
+ homeDir: tempHome,
1108
+ hostname: "cchistory-lite-claude-cross-path-host",
1109
+ sourceRefs: ["claude_code"],
1110
+ sourceRoots,
1111
+ });
1112
+ const expected = buildLiveSnapshot(await runSourceProbe({ safe_mode: true }, sources));
1113
+ let sourceStarts = 0;
1114
+ const actual = await scanLiteHistory({
1115
+ homeDir: tempHome,
1116
+ hostname: "cchistory-lite-claude-cross-path-host",
1117
+ sourceRefs: ["claude_code"],
1118
+ sourceRoots,
1119
+ safeMode: true,
1120
+ contextMode: "none",
1121
+ onProgress: (event) => {
1122
+ if (event.stage === "source_start")
1123
+ sourceStarts += 1;
1124
+ },
1125
+ });
1126
+ assert.equal(sourceStarts, 1);
1127
+ assert.equal(actual.listResolvedSessions().length, 1);
1128
+ assert.deepEqual(actual.listResolvedSessions(), expected.listResolvedSessions());
1129
+ assert.deepEqual(actual.listResolvedTurns(), expected.listResolvedTurns());
1130
+ }
1131
+ finally {
1132
+ await rm(tempHome, { recursive: true, force: true });
1133
+ }
1134
+ });
1135
+ test("Lite rejects ancestors and descendants of a symlink-relocated Full store", async () => {
1136
+ const tempHome = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-symlink-home-"));
1137
+ const relocatedParent = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-relocated-store-"));
1138
+ try {
1139
+ const fullStoreRoot = path.join(relocatedParent, "full-store");
1140
+ const fullStoreChild = path.join(fullStoreRoot, "source-shaped-child");
1141
+ await mkdir(fullStoreChild, { recursive: true });
1142
+ await writeFile(path.join(fullStoreRoot, "cchistory.sqlite"), "not opened by Lite");
1143
+ await symlink(fullStoreRoot, path.join(tempHome, ".cchistory"), "dir");
1144
+ for (const sourceRoot of [tempHome, relocatedParent, fullStoreChild]) {
1145
+ await assert.rejects(assertLiteSourceRoot(sourceRoot, { homeDir: tempHome }), /overlapping the Full store are not allowed in Lite/);
1146
+ }
1147
+ }
1148
+ finally {
1149
+ await rm(tempHome, { recursive: true, force: true });
1150
+ await rm(relocatedParent, { recursive: true, force: true });
1151
+ }
1152
+ });
1153
+ test("Lite exposes the shared project visibility and display order", () => {
1154
+ const projects = [
1155
+ createProject("empty", 0, 3),
1156
+ createProject("small", 1, 1),
1157
+ createProject("large", 5, 2),
1158
+ ];
1159
+ const snapshot = new LiveHistorySnapshot({
1160
+ host: {
1161
+ id: "host-lite-project-list",
1162
+ hostname: "lite-project-list",
1163
+ first_seen: "2026-01-01T00:00:00.000Z",
1164
+ last_seen: "2026-01-01T00:00:00.000Z",
1165
+ },
1166
+ sources: [],
1167
+ projects,
1168
+ sessions: [],
1169
+ turns: [],
1170
+ contexts: [],
1171
+ ask_user_question_turns: [],
1172
+ loss_audits: [],
1173
+ });
1174
+ assert.deepEqual(snapshot.listProjects().map((project) => project.project_id), ["project-large", "project-small"]);
1175
+ assert.equal(snapshot.getProject("project-empty")?.project_id, "project-empty");
1176
+ });
1177
+ test("explicit roots replace one adapter without adding the missing adapter roster", async () => {
1178
+ const codexRoot = path.join(mockDataRoot, fixtureRoots.codex);
1179
+ const resolved = await resolveLiteSources({
1180
+ homeDir: mockDataRoot,
1181
+ hostname: "cchistory-lite-roster-host",
1182
+ sourceRoots: [{ sourceRef: "codex", baseDir: codexRoot }],
1183
+ });
1184
+ const platforms = resolved.map((source) => source.platform);
1185
+ assert.ok(platforms.includes("codex"));
1186
+ assert.ok(platforms.includes("claude_code"));
1187
+ assert.equal(platforms.includes("lobechat"), false);
1188
+ assert.equal(platforms.includes("zcode"), false);
1189
+ assert.equal(platforms.includes("accio"), false);
1190
+ assert.equal(platforms.includes("cursor_agent"), false);
1191
+ assert.equal(platforms.includes("grok"), false);
1192
+ assert.equal(resolved.find((source) => source.platform === "codex")?.base_dir, codexRoot);
1193
+ });
1194
+ test("Lite opens upstream native SQLite fixture data read-only", async () => {
1195
+ const tempHome = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-native-sqlite-"));
1196
+ const cursorRoot = path.join(mockDataRoot, fixtureRoots.cursor);
1197
+ const cursorDb = path.join(cursorRoot, "7ff8eb6283576301c3822ea828f4a8f4", "975b36d6-f001-4ce9-b64f-5ccd19e111a6", "store.db");
1198
+ const walPath = `${cursorDb}-wal`;
1199
+ const shmPath = `${cursorDb}-shm`;
1200
+ const before = await stat(cursorDb);
1201
+ await assert.rejects(access(walPath));
1202
+ await assert.rejects(access(shmPath));
1203
+ try {
1204
+ const snapshot = await scanLiteHistory({
1205
+ homeDir: tempHome,
1206
+ hostname: "cchistory-lite-native-sqlite-host",
1207
+ sourceRefs: ["cursor"],
1208
+ sourceRoots: [{ sourceRef: "cursor", baseDir: cursorRoot }],
1209
+ safeMode: true,
1210
+ });
1211
+ assert.ok(snapshot.listResolvedTurns().length > 0);
1212
+ const after = await stat(cursorDb);
1213
+ assert.equal(after.size, before.size);
1214
+ assert.equal(after.mtimeMs, before.mtimeMs);
1215
+ await assert.rejects(access(walPath));
1216
+ await assert.rejects(access(shmPath));
1217
+ }
1218
+ finally {
1219
+ await rm(tempHome, { recursive: true, force: true });
1220
+ }
1221
+ });
1222
+ test("Lite Cursor composer-plus-transcript merge satisfies the projection contract", async () => {
1223
+ const tempRoot = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-cursor-overlap-"));
1224
+ try {
1225
+ const composerId = "composer-lite-overlap";
1226
+ const projectsRoot = path.join(tempRoot, ".cursor", "projects");
1227
+ const transcriptDir = path.join(projectsRoot, "Users-test-my-app", "agent-transcripts", composerId);
1228
+ const userDir = path.join(tempRoot, "Library", "Application Support", "Cursor", "User");
1229
+ await mkdir(transcriptDir, { recursive: true });
1230
+ await mkdir(path.join(userDir, "globalStorage"), { recursive: true });
1231
+ await mkdir(path.join(userDir, "workspaceStorage", "ws-overlap"), { recursive: true });
1232
+ await writeFile(path.join(transcriptDir, `${composerId}.jsonl`), [
1233
+ {
1234
+ role: "user",
1235
+ message: { content: [{ type: "text", text: "Inspect from transcript." }] },
1236
+ createdAt: "2026-03-10T03:30:00.000Z",
1237
+ },
1238
+ {
1239
+ role: "assistant",
1240
+ message: { content: [{ type: "text", text: "Transcript reply." }] },
1241
+ createdAt: "2026-03-10T03:30:01.000Z",
1242
+ },
1243
+ {
1244
+ role: "user",
1245
+ message: { content: [{ type: "text", text: "Follow up from transcript." }] },
1246
+ createdAt: "2026-03-10T03:31:00.000Z",
1247
+ },
1248
+ {
1249
+ role: "assistant",
1250
+ message: { content: [{ type: "text", text: "Second transcript reply." }] },
1251
+ createdAt: "2026-03-10T03:31:01.000Z",
1252
+ },
1253
+ ]
1254
+ .map((line) => JSON.stringify(line))
1255
+ .join("\n"), "utf8");
1256
+ await writeFile(path.join(userDir, "workspaceStorage", "ws-overlap", "workspace.json"), JSON.stringify({ folder: "file:///Users/test/my_app" }), "utf8");
1257
+ seedCursorComposerDb(path.join(userDir, "globalStorage", "state.vscdb"), composerId);
1258
+ const probe = await runSourceProbe({}, [
1259
+ {
1260
+ id: "src-cursor-lite-overlap",
1261
+ slot_id: "cursor",
1262
+ family: "local_coding_agent",
1263
+ platform: "cursor",
1264
+ display_name: "Cursor",
1265
+ base_dir: projectsRoot,
1266
+ },
1267
+ ]);
1268
+ const lite = buildLiveSnapshot(probe);
1269
+ assert.deepEqual(lite.projectionIssues, []);
1270
+ assert.equal(lite.listResolvedSessions().length, 1);
1271
+ assert.equal(lite.listResolvedTurns().length, 2);
1272
+ assert.equal(lite.listResolvedSessions()[0]?.working_directory, "/Users/test/my_app");
1273
+ assert.equal(lite.listResolvedTurns().some((turn) => turn.canonical_text === "Follow up from transcript."), true);
1274
+ }
1275
+ finally {
1276
+ await rm(tempRoot, { recursive: true, force: true });
1277
+ }
1278
+ });
1279
+ test("Lite Cursor composer key-format and storage-root overlap satisfies the projection contract", async () => {
1280
+ const tempRoot = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-cursor-composer-overlap-"));
1281
+ try {
1282
+ const composerId = "composer-lite-both-stores";
1283
+ const userDir = path.join(tempRoot, "Cursor", "User");
1284
+ const workspaceDir = path.join(userDir, "workspaceStorage", "ws-both-stores");
1285
+ await mkdir(path.join(userDir, "globalStorage"), { recursive: true });
1286
+ await mkdir(workspaceDir, { recursive: true });
1287
+ seedCursorComposerDb(path.join(userDir, "globalStorage", "state.vscdb"), composerId, {
1288
+ title: "Cursor global composer",
1289
+ userText: "Inspect from global composer.",
1290
+ includeAllComposers: true,
1291
+ });
1292
+ seedCursorComposerDb(path.join(workspaceDir, "state.vscdb"), composerId, {
1293
+ title: "Cursor workspace composer",
1294
+ userText: "Inspect from workspace composer.",
1295
+ workspacePath: "/Users/test/workspace_app",
1296
+ });
1297
+ await writeFile(path.join(workspaceDir, "workspace.json"), JSON.stringify({ folder: "file:///Users/test/workspace_app" }), "utf8");
1298
+ const probe = await runSourceProbe({}, [
1299
+ {
1300
+ id: "src-cursor-lite-composer-overlap",
1301
+ slot_id: "cursor",
1302
+ family: "local_coding_agent",
1303
+ platform: "cursor",
1304
+ display_name: "Cursor",
1305
+ base_dir: userDir,
1306
+ },
1307
+ ]);
1308
+ const lite = buildLiveSnapshot(probe);
1309
+ assert.deepEqual(lite.projectionIssues, []);
1310
+ assert.equal(lite.listResolvedSessions().length, 1);
1311
+ assert.equal(lite.listResolvedTurns().length, 1);
1312
+ assert.equal(lite.listResolvedTurns()[0]?.canonical_text, "Inspect from workspace composer.");
1313
+ assert.equal(lite.listResolvedSessions()[0]?.working_directory, "/Users/test/workspace_app");
1314
+ }
1315
+ finally {
1316
+ await rm(tempRoot, { recursive: true, force: true });
1317
+ }
1318
+ });
1319
+ test("Lite and Full agree on a synthetic Kimi source through the shared probe pipeline", async () => {
1320
+ const tempRoot = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-kimi-parity-"));
1321
+ try {
1322
+ const kimiRoot = path.join(tempRoot, ".kimi-code");
1323
+ const sessionId = "session_lite-parity";
1324
+ const sessionDir = path.join(kimiRoot, "sessions", "wd_lite-parity", sessionId);
1325
+ const mainAgentDir = path.join(sessionDir, "agents", "main");
1326
+ await mkdir(mainAgentDir, { recursive: true });
1327
+ const wireLines = [
1328
+ { type: "metadata", protocol_version: "1", created_at: 1_773_000_000_000 },
1329
+ { type: "config.update", modelAlias: "kimi-code/k3", time: 1_773_000_000_100 },
1330
+ {
1331
+ type: "turn.prompt",
1332
+ input: [{ type: "text", text: "Review the Kimi parity boundary." }],
1333
+ origin: { kind: "user" },
1334
+ time: 1_773_000_001_000,
1335
+ },
1336
+ {
1337
+ type: "context.append_loop_event",
1338
+ event: { type: "content.part", uuid: "text-1", part: { type: "text", text: "The shared pipeline answered." } },
1339
+ time: 1_773_000_002_000,
1340
+ },
1341
+ {
1342
+ type: "usage.record",
1343
+ model: "kimi-code/k3",
1344
+ usageScope: "turn",
1345
+ usage: { inputOther: 100, inputCacheRead: 20, inputCacheCreation: 5, output: 30 },
1346
+ time: 1_773_000_003_000,
1347
+ },
1348
+ {
1349
+ type: "turn.prompt",
1350
+ input: [{ type: "text", text: "Now confirm the Lite parity coverage." }],
1351
+ origin: { kind: "user" },
1352
+ time: 1_773_000_004_000,
1353
+ },
1354
+ {
1355
+ type: "context.append_loop_event",
1356
+ event: { type: "content.part", uuid: "text-2", part: { type: "text", text: "Parity coverage confirmed." } },
1357
+ time: 1_773_000_005_000,
1358
+ },
1359
+ ];
1360
+ await writeFile(path.join(mainAgentDir, "wire.jsonl"), wireLines.map((line) => JSON.stringify(line)).join("\n"), "utf8");
1361
+ await writeFile(path.join(sessionDir, "state.json"), JSON.stringify({
1362
+ createdAt: "2026-03-09T06:00:00.000Z",
1363
+ updatedAt: "2026-03-09T06:10:00.000Z",
1364
+ title: "Kimi Lite parity",
1365
+ workDir: "/workspace/kimi-lite-parity",
1366
+ lastPrompt: "Now confirm the Lite parity coverage.",
1367
+ agents: { main: { type: "main", parentAgentId: null, homedir: "/tmp/main" } },
1368
+ custom: {},
1369
+ }), "utf8");
1370
+ await writeFile(path.join(kimiRoot, "session_index.jsonl"), JSON.stringify({ sessionId, sessionDir, workDir: "/workspace/kimi-lite-parity" }), "utf8");
1371
+ await writeFile(path.join(kimiRoot, "workspaces.json"), JSON.stringify({}), "utf8");
1372
+ // End-to-end Lite: discovery, source-root guard, probe, and snapshot.
1373
+ const lite = await scanLiteHistory({
1374
+ homeDir: tempRoot,
1375
+ hostname: "cchistory-lite-kimi-parity-host",
1376
+ sourceRefs: ["kimi"],
1377
+ sourceRoots: [{ sourceRef: "kimi", baseDir: kimiRoot }],
1378
+ safeMode: true,
1379
+ });
1380
+ assert.deepEqual(lite.listSources().map((source) => source.platform), ["kimi"]);
1381
+ assert.equal(lite.listResolvedSessions().length, 1);
1382
+ assert.equal(lite.listResolvedSessions()[0]?.source_session_id, sessionId);
1383
+ assert.equal(lite.listResolvedTurns().length, 2);
1384
+ await assert.rejects(access(path.join(tempRoot, ".cchistory")));
1385
+ // The two Lite entry points agree: scanLiteHistory() and buildLiveSnapshot(probe).
1386
+ const sources = await resolveLiteSources({
1387
+ homeDir: tempRoot,
1388
+ hostname: "cchistory-lite-kimi-parity-host",
1389
+ sourceRefs: ["kimi"],
1390
+ sourceRoots: [{ sourceRef: "kimi", baseDir: kimiRoot }],
1391
+ });
1392
+ const probe = await runSourceProbe({ safe_mode: true }, sources);
1393
+ const liteFromProbe = buildLiveSnapshot(probe);
1394
+ assert.deepEqual(jsonNormalize(liteFromProbe.listResolvedSessions()), jsonNormalize(lite.listResolvedSessions()));
1395
+ assert.deepEqual(jsonNormalize(liteFromProbe.listResolvedTurns()), jsonNormalize(lite.listResolvedTurns()));
1396
+ for (const turn of liteFromProbe.listResolvedTurns()) {
1397
+ assert.deepEqual(jsonNormalize(liteFromProbe.getTurnContext(turn.id)), jsonNormalize(lite.getTurnContext(turn.id)));
1398
+ }
1399
+ const liteSearch = liteFromProbe.search({ query: "parity", limit: 100 });
1400
+ assert.equal(liteSearch.total, 2);
1401
+ assert.deepEqual(liteSearch.results.map((result) => result.turn.id), lite.search({ query: "parity", limit: 100 }).results.map((result) => result.turn.id));
1402
+ assert.deepEqual(withoutGeneratedAt(liteFromProbe.getUsageOverview()), withoutGeneratedAt(lite.getUsageOverview()));
1403
+ }
1404
+ finally {
1405
+ await rm(tempRoot, { recursive: true, force: true });
1406
+ }
1407
+ });
1408
+ test("Lite and Full agree on a synthetic Grok source through the shared probe pipeline", async () => {
1409
+ const tempRoot = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-grok-parity-"));
1410
+ try {
1411
+ const grokRoot = path.join(tempRoot, ".grok");
1412
+ const sessionId = "aaaaaaaa-bbbb-4ccc-8ddd-eeeeeeeeee02";
1413
+ const sessionDir = path.join(grokRoot, "sessions", "%2Fworkspace%2Fgrok-lite-parity", sessionId);
1414
+ await mkdir(sessionDir, { recursive: true });
1415
+ await writeFile(path.join(sessionDir, "chat_history.jsonl"), [
1416
+ { type: "user", content: [{ type: "text", text: "Review the Grok parity boundary." }], timestamp: "2026-03-09T06:01:00.000Z" },
1417
+ { type: "assistant", content: "The shared pipeline answered.", model_id: "grok-4.6", timestamp: "2026-03-09T06:02:00.000Z" },
1418
+ { type: "user", content: [{ type: "text", text: "Now confirm the Lite parity coverage." }], timestamp: "2026-03-09T06:03:00.000Z" },
1419
+ { type: "assistant", content: "Parity coverage confirmed.", model_id: "grok-4.6", timestamp: "2026-03-09T06:04:00.000Z" },
1420
+ ]
1421
+ .map((line) => JSON.stringify(line))
1422
+ .join("\n"), "utf8");
1423
+ await writeFile(path.join(sessionDir, "summary.json"), JSON.stringify({
1424
+ info: { id: sessionId, cwd: "/workspace/grok-lite-parity" },
1425
+ generated_title: "Grok Lite parity",
1426
+ created_at: "2026-03-09T06:00:00.000Z",
1427
+ updated_at: "2026-03-09T06:10:00.000Z",
1428
+ current_model_id: "grok-4.6",
1429
+ }), "utf8");
1430
+ const lite = await scanLiteHistory({
1431
+ homeDir: tempRoot,
1432
+ hostname: "cchistory-lite-grok-parity-host",
1433
+ sourceRefs: ["grok"],
1434
+ sourceRoots: [{ sourceRef: "grok", baseDir: grokRoot }],
1435
+ safeMode: true,
1436
+ });
1437
+ assert.deepEqual(lite.listSources().map((source) => source.platform), ["grok"]);
1438
+ assert.equal(lite.listResolvedSessions().length, 1);
1439
+ assert.equal(lite.listResolvedSessions()[0]?.source_session_id, sessionId);
1440
+ assert.equal(lite.listResolvedTurns().length, 2);
1441
+ await assert.rejects(access(path.join(tempRoot, ".cchistory")));
1442
+ const sources = await resolveLiteSources({
1443
+ homeDir: tempRoot,
1444
+ hostname: "cchistory-lite-grok-parity-host",
1445
+ sourceRefs: ["grok"],
1446
+ sourceRoots: [{ sourceRef: "grok", baseDir: grokRoot }],
1447
+ });
1448
+ const probe = await runSourceProbe({ safe_mode: true }, sources);
1449
+ const liteFromProbe = buildLiveSnapshot(probe);
1450
+ assert.deepEqual(jsonNormalize(liteFromProbe.listResolvedSessions()), jsonNormalize(lite.listResolvedSessions()));
1451
+ assert.deepEqual(jsonNormalize(liteFromProbe.listResolvedTurns()), jsonNormalize(lite.listResolvedTurns()));
1452
+ const liteSearch = liteFromProbe.search({ query: "parity", limit: 100 });
1453
+ assert.equal(liteSearch.total, 2);
1454
+ const sessionSearch = lite.searchSessions({ query: "Grok Lite parity", limit: 10 });
1455
+ assert.equal(sessionSearch.total, 1);
1456
+ assert.equal(sessionSearch.results[0]?.session.source_session_id, sessionId);
1457
+ assert.equal(sessionSearch.results[0]?.match_field, "title");
1458
+ assert.deepEqual(lite.projectionIssues, []);
1459
+ assert.deepEqual(liteFromProbe.projectionIssues, []);
1460
+ }
1461
+ finally {
1462
+ await rm(tempRoot, { recursive: true, force: true });
1463
+ }
1464
+ });
1465
+ test("Lite directory scope skips Grok sessions whose encoded cwd is known not to match", async () => {
1466
+ const tempRoot = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-grok-dir-"));
1467
+ try {
1468
+ const grokRoot = path.join(tempRoot, ".grok");
1469
+ const keepId = "aaaaaaaa-bbbb-4ccc-8ddd-eeeeeeeeee10";
1470
+ const skipId = "aaaaaaaa-bbbb-4ccc-8ddd-eeeeeeeeee11";
1471
+ const keepDir = path.join(grokRoot, "sessions", "%2Fworkspace%2Fkeep", keepId);
1472
+ const skipDir = path.join(grokRoot, "sessions", "%2Fworkspace%2Fskip", skipId);
1473
+ await mkdir(keepDir, { recursive: true });
1474
+ await mkdir(skipDir, { recursive: true });
1475
+ for (const [sessionDir, sessionId, cwd, prompt] of [
1476
+ [keepDir, keepId, "/workspace/keep", "Keep this Grok session visible."],
1477
+ [skipDir, skipId, "/workspace/skip", "Skip this Grok session entirely."],
1478
+ ]) {
1479
+ await writeFile(path.join(sessionDir, "chat_history.jsonl"), `${JSON.stringify({ type: "user", content: [{ type: "text", text: prompt }], timestamp: "2026-03-09T06:01:00.000Z" })}\n`, "utf8");
1480
+ await writeFile(path.join(sessionDir, "summary.json"), JSON.stringify({
1481
+ info: { id: sessionId, cwd },
1482
+ generated_title: prompt,
1483
+ created_at: "2026-03-09T06:00:00.000Z",
1484
+ updated_at: "2026-03-09T06:10:00.000Z",
1485
+ }), "utf8");
1486
+ }
1487
+ const scoped = await scanLiteHistory({
1488
+ homeDir: tempRoot,
1489
+ hostname: "cchistory-lite-grok-dir-host",
1490
+ sourceRefs: ["grok"],
1491
+ sourceRoots: [{ sourceRef: "grok", baseDir: grokRoot }],
1492
+ directoryScope: "/workspace/keep",
1493
+ safeMode: true,
1494
+ });
1495
+ assert.deepEqual(scoped.listResolvedSessions().map((session) => session.source_session_id), [keepId]);
1496
+ assert.equal(scoped.search({ query: "Skip this Grok" }).total, 0);
1497
+ assert.equal(scoped.searchSessions({ query: "Keep this Grok" }).total, 1);
1498
+ }
1499
+ finally {
1500
+ await rm(tempRoot, { recursive: true, force: true });
1501
+ }
1502
+ });
1503
+ test("Lite targeted Grok show probes only the matching session file", async () => {
1504
+ const tempRoot = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-grok-show-"));
1505
+ try {
1506
+ const grokRoot = path.join(tempRoot, ".grok");
1507
+ const keepId = "aaaaaaaa-bbbb-4ccc-8ddd-eeeeeeeeee20";
1508
+ const skipId = "aaaaaaaa-bbbb-4ccc-8ddd-eeeeeeeeee21";
1509
+ const keepDir = path.join(grokRoot, "sessions", "%2Fworkspace%2Fkeep", keepId);
1510
+ const skipDir = path.join(grokRoot, "sessions", "%2Fworkspace%2Fskip", skipId);
1511
+ await mkdir(keepDir, { recursive: true });
1512
+ await mkdir(skipDir, { recursive: true });
1513
+ for (const [sessionDir, sessionId, cwd, prompt] of [
1514
+ [keepDir, keepId, "/workspace/keep", "Keep this Grok session for show."],
1515
+ [skipDir, skipId, "/workspace/skip", "Do not open this Grok session."],
1516
+ ]) {
1517
+ await writeFile(path.join(sessionDir, "chat_history.jsonl"), `${JSON.stringify({ type: "user", content: [{ type: "text", text: prompt }], timestamp: "2026-03-09T06:01:00.000Z" })}\n`, "utf8");
1518
+ await writeFile(path.join(sessionDir, "summary.json"), JSON.stringify({
1519
+ info: { id: sessionId, cwd },
1520
+ generated_title: prompt,
1521
+ created_at: "2026-03-09T06:00:00.000Z",
1522
+ updated_at: "2026-03-09T06:10:00.000Z",
1523
+ }), "utf8");
1524
+ }
1525
+ const parsedFiles = [];
1526
+ const targeted = await scanLiteHistory({
1527
+ homeDir: tempRoot,
1528
+ hostname: "cchistory-lite-grok-show-host",
1529
+ sourceRefs: ["grok"],
1530
+ sourceRoots: [{ sourceRef: "grok", baseDir: grokRoot }],
1531
+ safeMode: true,
1532
+ contextMode: "full",
1533
+ sessionRefs: [`sess:grok:${keepId}`],
1534
+ onProgress: (event) => {
1535
+ if (event.stage === "file_start" && event.file_path)
1536
+ parsedFiles.push(event.file_path);
1537
+ },
1538
+ });
1539
+ assert.equal(targeted.getSession(`sess:grok:${keepId}`)?.source_session_id, keepId);
1540
+ assert.equal(targeted.listResolvedSessions().some((session) => session.source_session_id === skipId), false);
1541
+ assert.ok(parsedFiles.some((filePath) => filePath.includes(keepId) && filePath.endsWith("chat_history.jsonl")));
1542
+ assert.equal(parsedFiles.some((filePath) => filePath.includes(skipId)), false);
1543
+ }
1544
+ finally {
1545
+ await rm(tempRoot, { recursive: true, force: true });
1546
+ }
1547
+ });
1548
+ test("LiveHistorySnapshot treats blank lookup refs as not found instead of matching everything", () => {
1549
+ const host = {
1550
+ id: "host-blank-ref",
1551
+ hostname: "blank-ref",
1552
+ first_seen: "2026-01-01T00:00:00.000Z",
1553
+ last_seen: "2026-01-01T00:00:00.000Z",
1554
+ };
1555
+ const session = {
1556
+ id: "session-blank-ref",
1557
+ source_id: "source-blank-ref",
1558
+ source_platform: "codex",
1559
+ host_id: host.id,
1560
+ created_at: "2026-01-01T00:00:00.000Z",
1561
+ updated_at: "2026-01-01T00:00:00.000Z",
1562
+ turn_count: 1,
1563
+ sync_axis: "current",
1564
+ };
1565
+ const snapshot = new LiveHistorySnapshot({
1566
+ host,
1567
+ sources: [],
1568
+ projects: [],
1569
+ sessions: [session],
1570
+ turns: [createBlankRefTurn(session)],
1571
+ contexts: [],
1572
+ ask_user_question_turns: [],
1573
+ loss_audits: [],
1574
+ });
1575
+ assert.equal(snapshot.getSession(""), undefined);
1576
+ assert.equal(snapshot.getSession(" "), undefined);
1577
+ assert.equal(snapshot.getTurn(""), undefined);
1578
+ assert.equal(snapshot.getTurn(" "), undefined);
1579
+ assert.equal(snapshot.getSource(""), undefined);
1580
+ assert.equal(snapshot.getProject(""), undefined);
1581
+ assert.equal(snapshot.getSession("session-blank-ref")?.id, "session-blank-ref");
1582
+ });
1583
+ function createBlankRefTurn(session) {
1584
+ return {
1585
+ id: "turn-blank-ref",
1586
+ revision_id: "turn-blank-ref:r1",
1587
+ turn_id: "turn-blank-ref",
1588
+ turn_revision_id: "turn-blank-ref:r1",
1589
+ user_messages: [
1590
+ {
1591
+ id: "message-blank-ref",
1592
+ raw_text: "Blank ref fixture",
1593
+ canonical_text: "Blank ref fixture",
1594
+ display_segments: [{ type: "text", content: "Blank ref fixture" }],
1595
+ sequence: 0,
1596
+ is_injected: false,
1597
+ created_at: "2026-01-01T00:00:00.000Z",
1598
+ atom_refs: ["atom-blank-ref"],
1599
+ },
1600
+ ],
1601
+ raw_text: "Blank ref fixture",
1602
+ canonical_text: "Blank ref fixture",
1603
+ display_segments: [{ type: "text", content: "Blank ref fixture" }],
1604
+ created_at: "2026-01-01T00:00:00.000Z",
1605
+ submission_started_at: "2026-01-01T00:00:00.000Z",
1606
+ last_context_activity_at: "2026-01-01T00:01:00.000Z",
1607
+ session_id: session.id,
1608
+ source_id: session.source_id,
1609
+ link_state: "unlinked",
1610
+ sync_axis: "current",
1611
+ value_axis: "active",
1612
+ retention_axis: "keep_raw_and_derived",
1613
+ context_ref: "context-blank-ref",
1614
+ context_summary: {
1615
+ assistant_reply_count: 1,
1616
+ tool_call_count: 0,
1617
+ token_usage: { input_tokens: 1, output_tokens: 1, total_tokens: 2 },
1618
+ total_tokens: 2,
1619
+ primary_model: "gpt-5",
1620
+ has_errors: false,
1621
+ },
1622
+ lineage: {
1623
+ atom_refs: ["atom-blank-ref"],
1624
+ candidate_refs: [],
1625
+ fragment_refs: [],
1626
+ record_refs: [],
1627
+ blob_refs: [],
1628
+ },
1629
+ };
1630
+ }
1631
+ function uniqueCanonicalSessionPrefix(sessionId, allIds) {
1632
+ const platformPrefix = sessionId.match(/^sess:[^:]+:/u)?.[0];
1633
+ assert.ok(platformPrefix);
1634
+ const native = sessionId.slice(platformPrefix.length);
1635
+ for (let length = Math.min(8, native.length); length <= native.length; length += 1) {
1636
+ const candidate = `${platformPrefix}${native.slice(0, length)}`;
1637
+ if (allIds.filter((id) => id.startsWith(candidate)).length === 1)
1638
+ return candidate;
1639
+ }
1640
+ return sessionId;
1641
+ }
1642
+ function sortById(values) {
1643
+ return jsonNormalize(values).sort((left, right) => left.id.localeCompare(right.id));
1644
+ }
1645
+ function targetTurnParityFields(turn) {
1646
+ return {
1647
+ id: turn.id,
1648
+ session_id: turn.session_id,
1649
+ raw_text: turn.raw_text,
1650
+ canonical_text: turn.canonical_text,
1651
+ context_ref: turn.context_ref,
1652
+ context_summary: turn.context_summary,
1653
+ };
1654
+ }
1655
+ function targetContextParityFields(context) {
1656
+ return {
1657
+ turn_id: context.turn_id,
1658
+ system_messages: context.system_messages.map((message) => ({
1659
+ id: message.id,
1660
+ content: message.content,
1661
+ position: message.position,
1662
+ sequence: message.sequence,
1663
+ })),
1664
+ assistant_replies: context.assistant_replies.map((reply) => ({
1665
+ id: reply.id,
1666
+ content: reply.content,
1667
+ content_preview: reply.content_preview,
1668
+ token_usage: reply.token_usage,
1669
+ token_count: reply.token_count,
1670
+ model: reply.model,
1671
+ tool_call_ids: reply.tool_call_ids,
1672
+ stop_reason: reply.stop_reason,
1673
+ })),
1674
+ tool_calls: context.tool_calls.map((tool) => ({
1675
+ id: tool.id,
1676
+ tool_name: tool.tool_name,
1677
+ input: tool.input,
1678
+ input_summary: tool.input_summary,
1679
+ output: tool.output,
1680
+ output_preview: tool.output_preview,
1681
+ status: tool.status,
1682
+ error_message: tool.error_message,
1683
+ reply_id: tool.reply_id,
1684
+ sequence: tool.sequence,
1685
+ })),
1686
+ };
1687
+ }
1688
+ function targetSessionParityFields(session) {
1689
+ return {
1690
+ id: session.id,
1691
+ source_id: session.source_id,
1692
+ source_platform: session.source_platform,
1693
+ host_id: session.host_id,
1694
+ title: session.title,
1695
+ turn_count: session.turn_count,
1696
+ model: session.model,
1697
+ working_directory: session.working_directory,
1698
+ source_session_id: session.source_session_id,
1699
+ primary_project_id: session.primary_project_id,
1700
+ sync_axis: session.sync_axis,
1701
+ };
1702
+ }
1703
+ function createProject(name, turns, sessions) {
1704
+ return {
1705
+ project_id: `project-${name}`,
1706
+ project_revision_id: `project-${name}:r1`,
1707
+ display_name: name,
1708
+ slug: name,
1709
+ linkage_state: "committed",
1710
+ confidence: 1,
1711
+ link_reason: "manual_override",
1712
+ manual_override_status: "applied",
1713
+ source_platforms: ["codex"],
1714
+ host_ids: ["host-lite-project-list"],
1715
+ committed_turn_count: turns,
1716
+ candidate_turn_count: 0,
1717
+ session_count: sessions,
1718
+ project_last_activity_at: "2026-01-01T00:00:00.000Z",
1719
+ created_at: "2026-01-01T00:00:00.000Z",
1720
+ updated_at: "2026-01-01T00:00:00.000Z",
1721
+ };
1722
+ }
1723
+ function normalizeProjects(values) {
1724
+ return jsonNormalize(values)
1725
+ .map(({ project_revision_id: _revisionId, created_at: _createdAt, ...project }) => project)
1726
+ .sort((left, right) => left.project_id.localeCompare(right.project_id));
1727
+ }
1728
+ function withoutGeneratedAt(value) {
1729
+ const normalized = jsonNormalize(value);
1730
+ const { generated_at: _generatedAt, ...rest } = normalized;
1731
+ return rest;
1732
+ }
1733
+ function withoutRunTimestamp(value) {
1734
+ const { last_sync: _lastSync, ...rest } = value;
1735
+ return rest;
1736
+ }
1737
+ function codexSessionJsonl(sessionId, userText, minute) {
1738
+ return [
1739
+ JSON.stringify({
1740
+ timestamp: `2026-08-12T${minute}:00.000Z`,
1741
+ type: "session_meta",
1742
+ payload: { id: sessionId, cwd: "/workspace/live-inventory", model: "gpt-5" },
1743
+ }),
1744
+ codexTurnJsonl(sessionId, userText, minute),
1745
+ ].join("\n");
1746
+ }
1747
+ function codexTurnJsonl(_sessionId, userText, minute) {
1748
+ return [
1749
+ JSON.stringify({
1750
+ timestamp: `2026-08-12T${minute}:01.000Z`,
1751
+ type: "turn_context",
1752
+ payload: { cwd: "/workspace/live-inventory", model: "gpt-5" },
1753
+ }),
1754
+ JSON.stringify({
1755
+ timestamp: `2026-08-12T${minute}:02.000Z`,
1756
+ type: "response_item",
1757
+ payload: {
1758
+ type: "message",
1759
+ role: "user",
1760
+ content: [{ type: "input_text", text: userText }],
1761
+ },
1762
+ }),
1763
+ JSON.stringify({
1764
+ timestamp: `2026-08-12T${minute}:03.000Z`,
1765
+ type: "response_item",
1766
+ payload: {
1767
+ type: "message",
1768
+ role: "assistant",
1769
+ content: [{ type: "output_text", text: `Acknowledged: ${userText}` }],
1770
+ },
1771
+ }),
1772
+ ].join("\n");
1773
+ }
1774
+ function seedCursorComposerDb(dbPath, composerId, options = {}) {
1775
+ const title = options.title ?? "Cursor shared composer";
1776
+ const userText = options.userText ?? "Inspect from composer.";
1777
+ const workspacePath = options.workspacePath ?? "/Users/test/my_app";
1778
+ const db = new DatabaseSync(dbPath);
1779
+ try {
1780
+ db.exec("CREATE TABLE cursorDiskKV (key TEXT PRIMARY KEY, value BLOB NOT NULL)");
1781
+ const insert = db.prepare("INSERT INTO cursorDiskKV (key, value) VALUES (?, ?)");
1782
+ const composer = {
1783
+ composerId,
1784
+ name: title,
1785
+ modelConfig: { maxMode: false, modelName: "composer-2" },
1786
+ workspaceIdentifier: {
1787
+ id: "ws-overlap",
1788
+ uri: { fsPath: workspacePath, path: workspacePath, scheme: "file" },
1789
+ },
1790
+ fullConversationHeadersOnly: [
1791
+ { bubbleId: "bubble-user", type: 1 },
1792
+ { bubbleId: "bubble-assistant", type: 2 },
1793
+ ],
1794
+ };
1795
+ insert.run(`composerData:${composerId}`, JSON.stringify(composer));
1796
+ if (options.includeAllComposers) {
1797
+ insert.run("composer.composerData", JSON.stringify({ allComposers: [composer] }));
1798
+ }
1799
+ insert.run(`bubbleId:${composerId}:bubble-user`, JSON.stringify({
1800
+ bubbleId: "bubble-user",
1801
+ type: 1,
1802
+ createdAt: "2026-03-10T03:30:00.000Z",
1803
+ text: userText,
1804
+ }));
1805
+ insert.run(`bubbleId:${composerId}:bubble-assistant`, JSON.stringify({
1806
+ bubbleId: "bubble-assistant",
1807
+ type: 2,
1808
+ createdAt: "2026-03-10T03:30:01.000Z",
1809
+ text: "Composer reply.",
1810
+ }));
1811
+ }
1812
+ finally {
1813
+ db.close();
1814
+ }
1815
+ }
1816
+ function jsonNormalize(value) {
1817
+ return JSON.parse(JSON.stringify(value));
1818
+ }
1819
+ //# sourceMappingURL=index.test.js.map