@cchistory/lite 0.8.3 → 0.9.1

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 (297) hide show
  1. package/INSTALL.md +1 -1
  2. package/apps/lite-cli/dist/agent-contract.d.ts.map +1 -1
  3. package/apps/lite-cli/dist/agent-contract.js +41 -2
  4. package/apps/lite-cli/dist/agent-contract.js.map +1 -1
  5. package/apps/lite-cli/dist/help.js +5 -5
  6. package/apps/lite-cli/dist/index.d.ts.map +1 -1
  7. package/apps/lite-cli/dist/index.js +148 -17
  8. package/apps/lite-cli/dist/index.js.map +1 -1
  9. package/apps/lite-cli/dist/index.test.js +114 -95
  10. package/apps/lite-cli/dist/index.test.js.map +1 -1
  11. package/apps/lite-cli/dist/inventory-and-git.test.d.ts +7 -0
  12. package/apps/lite-cli/dist/inventory-and-git.test.d.ts.map +1 -0
  13. package/apps/lite-cli/dist/inventory-and-git.test.js +776 -0
  14. package/apps/lite-cli/dist/inventory-and-git.test.js.map +1 -0
  15. package/apps/lite-cli/dist/inventory-command.d.ts +30 -0
  16. package/apps/lite-cli/dist/inventory-command.d.ts.map +1 -0
  17. package/apps/lite-cli/dist/inventory-command.js +265 -0
  18. package/apps/lite-cli/dist/inventory-command.js.map +1 -0
  19. package/apps/lite-cli/dist/json-v2.d.ts +2 -2
  20. package/apps/lite-cli/dist/json-v2.d.ts.map +1 -1
  21. package/apps/lite-cli/dist/json-v2.js +9 -3
  22. package/apps/lite-cli/dist/json-v2.js.map +1 -1
  23. package/apps/lite-cli/dist/project-git-command.d.ts +28 -0
  24. package/apps/lite-cli/dist/project-git-command.d.ts.map +1 -0
  25. package/apps/lite-cli/dist/project-git-command.js +288 -0
  26. package/apps/lite-cli/dist/project-git-command.js.map +1 -0
  27. package/apps/lite-cli/dist/startup-render.d.ts +10 -0
  28. package/apps/lite-cli/dist/startup-render.d.ts.map +1 -0
  29. package/apps/lite-cli/dist/startup-render.js +335 -0
  30. package/apps/lite-cli/dist/startup-render.js.map +1 -0
  31. package/apps/lite-cli/dist/version.d.ts +1 -1
  32. package/apps/lite-cli/dist/version.js +1 -1
  33. package/apps/lite-tui/dist/render.d.ts +1 -1
  34. package/apps/lite-tui/dist/version.d.ts +1 -1
  35. package/apps/lite-tui/dist/version.js +1 -1
  36. package/docs/guide/for-agents.md +14 -0
  37. package/docs/guide/lite.md +53 -2
  38. package/node_modules/@cchistory/canonical/dist/agent-inventory.d.ts +25 -0
  39. package/node_modules/@cchistory/canonical/dist/agent-inventory.d.ts.map +1 -0
  40. package/node_modules/@cchistory/canonical/dist/agent-inventory.js +345 -0
  41. package/node_modules/@cchistory/canonical/dist/agent-inventory.js.map +1 -0
  42. package/node_modules/@cchistory/canonical/dist/agent-inventory.test.d.ts +7 -0
  43. package/node_modules/@cchistory/canonical/dist/agent-inventory.test.d.ts.map +1 -0
  44. package/node_modules/@cchistory/canonical/dist/agent-inventory.test.js +231 -0
  45. package/node_modules/@cchistory/canonical/dist/agent-inventory.test.js.map +1 -0
  46. package/node_modules/@cchistory/canonical/dist/directory-scope.d.ts.map +1 -1
  47. package/node_modules/@cchistory/canonical/dist/directory-scope.js +4 -1
  48. package/node_modules/@cchistory/canonical/dist/directory-scope.js.map +1 -1
  49. package/node_modules/@cchistory/canonical/dist/index.d.ts +2 -0
  50. package/node_modules/@cchistory/canonical/dist/index.d.ts.map +1 -1
  51. package/node_modules/@cchistory/canonical/dist/index.js +2 -0
  52. package/node_modules/@cchistory/canonical/dist/index.js.map +1 -1
  53. package/node_modules/@cchistory/canonical/dist/project-merge.d.ts +42 -0
  54. package/node_modules/@cchistory/canonical/dist/project-merge.d.ts.map +1 -0
  55. package/node_modules/@cchistory/canonical/dist/project-merge.js +396 -0
  56. package/node_modules/@cchistory/canonical/dist/project-merge.js.map +1 -0
  57. package/node_modules/@cchistory/canonical/dist/project-merge.test.d.ts +7 -0
  58. package/node_modules/@cchistory/canonical/dist/project-merge.test.d.ts.map +1 -0
  59. package/node_modules/@cchistory/canonical/dist/project-merge.test.js +319 -0
  60. package/node_modules/@cchistory/canonical/dist/project-merge.test.js.map +1 -0
  61. package/node_modules/@cchistory/canonical/dist/query.js +1 -1
  62. package/node_modules/@cchistory/canonical/dist/query.js.map +1 -1
  63. package/node_modules/@cchistory/canonical/dist/session-interpreter.d.ts.map +1 -1
  64. package/node_modules/@cchistory/canonical/dist/session-interpreter.js +38 -0
  65. package/node_modules/@cchistory/canonical/dist/session-interpreter.js.map +1 -1
  66. package/node_modules/@cchistory/canonical/dist/tool-call-summary.d.ts.map +1 -1
  67. package/node_modules/@cchistory/canonical/dist/tool-call-summary.js +18 -2
  68. package/node_modules/@cchistory/canonical/dist/tool-call-summary.js.map +1 -1
  69. package/node_modules/@cchistory/canonical/dist/usage-anomalies.d.ts.map +1 -1
  70. package/node_modules/@cchistory/canonical/dist/usage-anomalies.js +2 -0
  71. package/node_modules/@cchistory/canonical/dist/usage-anomalies.js.map +1 -1
  72. package/node_modules/@cchistory/canonical/dist/usage-call-evaluation.d.ts.map +1 -1
  73. package/node_modules/@cchistory/canonical/dist/usage-call-evaluation.js +4 -1
  74. package/node_modules/@cchistory/canonical/dist/usage-call-evaluation.js.map +1 -1
  75. package/node_modules/@cchistory/canonical/dist/usage-trace.d.ts.map +1 -1
  76. package/node_modules/@cchistory/canonical/dist/usage-trace.js +3 -1
  77. package/node_modules/@cchistory/canonical/dist/usage-trace.js.map +1 -1
  78. package/node_modules/@cchistory/canonical/dist/usage-trace.test.js +73 -0
  79. package/node_modules/@cchistory/canonical/dist/usage-trace.test.js.map +1 -1
  80. package/node_modules/@cchistory/canonical/dist/usage.d.ts +1 -0
  81. package/node_modules/@cchistory/canonical/dist/usage.d.ts.map +1 -1
  82. package/node_modules/@cchistory/canonical/dist/usage.js +23 -17
  83. package/node_modules/@cchistory/canonical/dist/usage.js.map +1 -1
  84. package/node_modules/@cchistory/canonical/package.json +1 -1
  85. package/node_modules/@cchistory/domain/dist/agent-inventory.d.ts +146 -0
  86. package/node_modules/@cchistory/domain/dist/agent-inventory.d.ts.map +1 -0
  87. package/node_modules/@cchistory/domain/dist/agent-inventory.js +9 -0
  88. package/node_modules/@cchistory/domain/dist/agent-inventory.js.map +1 -0
  89. package/node_modules/@cchistory/domain/dist/agent-startup.d.ts +362 -0
  90. package/node_modules/@cchistory/domain/dist/agent-startup.d.ts.map +1 -0
  91. package/node_modules/@cchistory/domain/dist/agent-startup.js +8 -0
  92. package/node_modules/@cchistory/domain/dist/agent-startup.js.map +1 -0
  93. package/node_modules/@cchistory/domain/dist/index.d.ts +8 -1
  94. package/node_modules/@cchistory/domain/dist/index.d.ts.map +1 -1
  95. package/node_modules/@cchistory/domain/dist/index.js +3 -0
  96. package/node_modules/@cchistory/domain/dist/index.js.map +1 -1
  97. package/node_modules/@cchistory/domain/dist/index.test.js +27 -1
  98. package/node_modules/@cchistory/domain/dist/index.test.js.map +1 -1
  99. package/node_modules/@cchistory/domain/dist/project-git.d.ts +121 -0
  100. package/node_modules/@cchistory/domain/dist/project-git.d.ts.map +1 -0
  101. package/node_modules/@cchistory/domain/dist/project-git.js +93 -0
  102. package/node_modules/@cchistory/domain/dist/project-git.js.map +1 -0
  103. package/node_modules/@cchistory/domain/dist/token-evidence.d.ts.map +1 -1
  104. package/node_modules/@cchistory/domain/dist/token-evidence.js +3 -1
  105. package/node_modules/@cchistory/domain/dist/token-evidence.js.map +1 -1
  106. package/node_modules/@cchistory/domain/package.json +1 -1
  107. package/node_modules/@cchistory/live-runtime/dist/index.d.ts +4 -1
  108. package/node_modules/@cchistory/live-runtime/dist/index.d.ts.map +1 -1
  109. package/node_modules/@cchistory/live-runtime/dist/index.js +3 -1
  110. package/node_modules/@cchistory/live-runtime/dist/index.js.map +1 -1
  111. package/node_modules/@cchistory/live-runtime/dist/index.test.js +266 -38
  112. package/node_modules/@cchistory/live-runtime/dist/index.test.js.map +1 -1
  113. package/node_modules/@cchistory/live-runtime/dist/inventory-and-git.d.ts +35 -0
  114. package/node_modules/@cchistory/live-runtime/dist/inventory-and-git.d.ts.map +1 -0
  115. package/node_modules/@cchistory/live-runtime/dist/inventory-and-git.js +68 -0
  116. package/node_modules/@cchistory/live-runtime/dist/inventory-and-git.js.map +1 -0
  117. package/node_modules/@cchistory/live-runtime/package.json +1 -1
  118. package/node_modules/@cchistory/source-adapters/dist/core/conversation-seeds.d.ts +3 -0
  119. package/node_modules/@cchistory/source-adapters/dist/core/conversation-seeds.d.ts.map +1 -1
  120. package/node_modules/@cchistory/source-adapters/dist/core/conversation-seeds.js.map +1 -1
  121. package/node_modules/@cchistory/source-adapters/dist/core/discovery.d.ts.map +1 -1
  122. package/node_modules/@cchistory/source-adapters/dist/core/discovery.js +60 -4
  123. package/node_modules/@cchistory/source-adapters/dist/core/discovery.js.map +1 -1
  124. package/node_modules/@cchistory/source-adapters/dist/core/git-project.d.ts +9 -0
  125. package/node_modules/@cchistory/source-adapters/dist/core/git-project.d.ts.map +1 -1
  126. package/node_modules/@cchistory/source-adapters/dist/core/git-project.js +130 -7
  127. package/node_modules/@cchistory/source-adapters/dist/core/git-project.js.map +1 -1
  128. package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts +1 -1
  129. package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts.map +1 -1
  130. package/node_modules/@cchistory/source-adapters/dist/core/parser.js +198 -1
  131. package/node_modules/@cchistory/source-adapters/dist/core/parser.js.map +1 -1
  132. package/node_modules/@cchistory/source-adapters/dist/core/probe.d.ts.map +1 -1
  133. package/node_modules/@cchistory/source-adapters/dist/core/probe.js +85 -5
  134. package/node_modules/@cchistory/source-adapters/dist/core/probe.js.map +1 -1
  135. package/node_modules/@cchistory/source-adapters/dist/core/registry.test.js +17 -1
  136. package/node_modules/@cchistory/source-adapters/dist/core/registry.test.js.map +1 -1
  137. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.d.ts.map +1 -1
  138. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.js +44 -0
  139. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.js.map +1 -1
  140. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.d.ts.map +1 -1
  141. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js +12 -0
  142. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js.map +1 -1
  143. package/node_modules/@cchistory/source-adapters/dist/index.d.ts +5 -0
  144. package/node_modules/@cchistory/source-adapters/dist/index.d.ts.map +1 -1
  145. package/node_modules/@cchistory/source-adapters/dist/index.js +5 -0
  146. package/node_modules/@cchistory/source-adapters/dist/index.js.map +1 -1
  147. package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts +6 -0
  148. package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts.map +1 -1
  149. package/node_modules/@cchistory/source-adapters/dist/index.test.js +6 -0
  150. package/node_modules/@cchistory/source-adapters/dist/index.test.js.map +1 -1
  151. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.d.ts +14 -0
  152. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.d.ts.map +1 -0
  153. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.js +397 -0
  154. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.js.map +1 -0
  155. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.test.d.ts +6 -0
  156. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.test.d.ts.map +1 -0
  157. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.test.js +106 -0
  158. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.test.js.map +1 -0
  159. package/node_modules/@cchistory/source-adapters/dist/inventory/config-io.d.ts +42 -0
  160. package/node_modules/@cchistory/source-adapters/dist/inventory/config-io.d.ts.map +1 -0
  161. package/node_modules/@cchistory/source-adapters/dist/inventory/config-io.js +368 -0
  162. package/node_modules/@cchistory/source-adapters/dist/inventory/config-io.js.map +1 -0
  163. package/node_modules/@cchistory/source-adapters/dist/inventory/redaction.d.ts +22 -0
  164. package/node_modules/@cchistory/source-adapters/dist/inventory/redaction.d.ts.map +1 -0
  165. package/node_modules/@cchistory/source-adapters/dist/inventory/redaction.js +195 -0
  166. package/node_modules/@cchistory/source-adapters/dist/inventory/redaction.js.map +1 -0
  167. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity-helpers.d.ts +23 -0
  168. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity-helpers.d.ts.map +1 -0
  169. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity-helpers.js +147 -0
  170. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity-helpers.js.map +1 -0
  171. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity.d.ts +11 -0
  172. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity.d.ts.map +1 -0
  173. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity.js +339 -0
  174. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity.js.map +1 -0
  175. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code-helpers.d.ts +70 -0
  176. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code-helpers.d.ts.map +1 -0
  177. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code-helpers.js +257 -0
  178. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code-helpers.js.map +1 -0
  179. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code.d.ts +11 -0
  180. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code.d.ts.map +1 -0
  181. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code.js +321 -0
  182. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code.js.map +1 -0
  183. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/codex.d.ts +12 -0
  184. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/codex.d.ts.map +1 -0
  185. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/codex.js +363 -0
  186. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/codex.js.map +1 -0
  187. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/deepseek-harness.d.ts +20 -0
  188. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/deepseek-harness.d.ts.map +1 -0
  189. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/deepseek-harness.js +408 -0
  190. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/deepseek-harness.js.map +1 -0
  191. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/index.d.ts +24 -0
  192. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/index.d.ts.map +1 -0
  193. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/index.js +225 -0
  194. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/index.js.map +1 -0
  195. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/opencode.d.ts +12 -0
  196. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/opencode.d.ts.map +1 -0
  197. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/opencode.js +372 -0
  198. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/opencode.js.map +1 -0
  199. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/shared.d.ts +62 -0
  200. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/shared.d.ts.map +1 -0
  201. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/shared.js +428 -0
  202. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/shared.js.map +1 -0
  203. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/startup.test.d.ts +7 -0
  204. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/startup.test.d.ts.map +1 -0
  205. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/startup.test.js +399 -0
  206. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/startup.test.js.map +1 -0
  207. package/node_modules/@cchistory/source-adapters/dist/inventory/toml.d.ts +16 -0
  208. package/node_modules/@cchistory/source-adapters/dist/inventory/toml.d.ts.map +1 -0
  209. package/node_modules/@cchistory/source-adapters/dist/inventory/toml.js +478 -0
  210. package/node_modules/@cchistory/source-adapters/dist/inventory/toml.js.map +1 -0
  211. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.test.js +2 -0
  212. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.test.js.map +1 -1
  213. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness/reader.d.ts +28 -0
  214. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness/reader.d.ts.map +1 -0
  215. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness/reader.js +443 -0
  216. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness/reader.js.map +1 -0
  217. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness/runtime.d.ts +4 -0
  218. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness/runtime.d.ts.map +1 -0
  219. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness/runtime.js +370 -0
  220. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness/runtime.js.map +1 -0
  221. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness.d.ts +3 -0
  222. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness.d.ts.map +1 -0
  223. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness.js +78 -0
  224. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness.js.map +1 -0
  225. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness.test.d.ts +2 -0
  226. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness.test.d.ts.map +1 -0
  227. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness.test.js +313 -0
  228. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness.test.js.map +1 -0
  229. package/node_modules/@cchistory/source-adapters/dist/platforms/generic/runtime.d.ts.map +1 -1
  230. package/node_modules/@cchistory/source-adapters/dist/platforms/generic/runtime.js +14 -0
  231. package/node_modules/@cchistory/source-adapters/dist/platforms/generic/runtime.js.map +1 -1
  232. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes/runtime.d.ts +4 -0
  233. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes/runtime.d.ts.map +1 -0
  234. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes/runtime.js +306 -0
  235. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes/runtime.js.map +1 -0
  236. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes/sqlite.d.ts +8 -0
  237. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes/sqlite.d.ts.map +1 -0
  238. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes/sqlite.js +499 -0
  239. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes/sqlite.js.map +1 -0
  240. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes.d.ts +9 -0
  241. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes.d.ts.map +1 -0
  242. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes.js +53 -0
  243. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes.js.map +1 -0
  244. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes.test.d.ts +2 -0
  245. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes.test.d.ts.map +1 -0
  246. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes.test.js +314 -0
  247. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes.test.js.map +1 -0
  248. package/node_modules/@cchistory/source-adapters/dist/platforms/oh-my-pi.d.ts +9 -0
  249. package/node_modules/@cchistory/source-adapters/dist/platforms/oh-my-pi.d.ts.map +1 -0
  250. package/node_modules/@cchistory/source-adapters/dist/platforms/oh-my-pi.js +84 -0
  251. package/node_modules/@cchistory/source-adapters/dist/platforms/oh-my-pi.js.map +1 -0
  252. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode/sqlite-records.d.ts +50 -0
  253. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode/sqlite-records.d.ts.map +1 -0
  254. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode/sqlite-records.js +291 -0
  255. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode/sqlite-records.js.map +1 -0
  256. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode/sqlite.d.ts +8 -0
  257. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode/sqlite.d.ts.map +1 -0
  258. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode/sqlite.js +321 -0
  259. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode/sqlite.js.map +1 -0
  260. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode-sqlite.test.d.ts +2 -0
  261. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode-sqlite.test.d.ts.map +1 -0
  262. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode-sqlite.test.js +245 -0
  263. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode-sqlite.test.js.map +1 -0
  264. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.d.ts.map +1 -1
  265. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.js +30 -7
  266. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.js.map +1 -1
  267. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family/reader.d.ts +44 -0
  268. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family/reader.d.ts.map +1 -0
  269. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family/reader.js +533 -0
  270. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family/reader.js.map +1 -0
  271. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family/runtime.d.ts +4 -0
  272. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family/runtime.d.ts.map +1 -0
  273. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family/runtime.js +375 -0
  274. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family/runtime.js.map +1 -0
  275. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family.test.d.ts +2 -0
  276. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family.test.d.ts.map +1 -0
  277. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family.test.js +346 -0
  278. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family.test.js.map +1 -0
  279. package/node_modules/@cchistory/source-adapters/dist/platforms/pi.d.ts +8 -0
  280. package/node_modules/@cchistory/source-adapters/dist/platforms/pi.d.ts.map +1 -0
  281. package/node_modules/@cchistory/source-adapters/dist/platforms/pi.js +60 -0
  282. package/node_modules/@cchistory/source-adapters/dist/platforms/pi.js.map +1 -0
  283. package/node_modules/@cchistory/source-adapters/dist/platforms/registry.d.ts.map +1 -1
  284. package/node_modules/@cchistory/source-adapters/dist/platforms/registry.js +8 -0
  285. package/node_modules/@cchistory/source-adapters/dist/platforms/registry.js.map +1 -1
  286. package/node_modules/@cchistory/source-adapters/dist/platforms/types.d.ts +3 -1
  287. package/node_modules/@cchistory/source-adapters/dist/platforms/types.d.ts.map +1 -1
  288. package/node_modules/@cchistory/source-adapters/dist/platforms/types.js +5 -1
  289. package/node_modules/@cchistory/source-adapters/dist/platforms/types.js.map +1 -1
  290. package/node_modules/@cchistory/source-adapters/package.json +1 -1
  291. package/package.json +5 -5
  292. package/schemas/cchistory-lite-agent-v1.schema.json +3 -1
  293. package/schemas/cchistory-lite-envelope-v1.schema.json +33 -0
  294. package/schemas/cchistory-lite-inventory-v1.schema.json +94 -0
  295. package/schemas/cchistory-lite-merged-projects-v1.schema.json +44 -0
  296. package/schemas/cchistory-lite-v2.schema.json +22 -1
  297. package/skills/using-cchistory-lite/SKILL.md +17 -0
@@ -0,0 +1,776 @@
1
+ /**
2
+ * Role: Integration tests for CLI `inventory`, `ls projects --with-git`, and
3
+ * `merge-projects` covering sanitized mock_data fixtures, adversarial secret redaction,
4
+ * real local Git metadata inspection, and v1 envelope output contracts.
5
+ */
6
+ import assert from "node:assert/strict";
7
+ import { execFile as execFileCallback } from "node:child_process";
8
+ import fs from "node:fs/promises";
9
+ import os from "node:os";
10
+ import path from "node:path";
11
+ import test from "node:test";
12
+ import { fileURLToPath } from "node:url";
13
+ import { promisify } from "node:util";
14
+ import { LiveHistorySnapshot } from "@cchistory/live-runtime";
15
+ import { runLiteCli } from "./index.js";
16
+ const execFile = promisify(execFileCallback);
17
+ const REPO_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..", "..");
18
+ const FIXTURE_ROOT = path.join(REPO_ROOT, "mock_data", "fixtures", "agent-inventory");
19
+ const FIXTURE_HOME = path.join(FIXTURE_ROOT, "home");
20
+ const FIXTURE_PROJECT = path.join(FIXTURE_ROOT, "project");
21
+ function createCaptureIo(overrides = {}) {
22
+ let stdout = "";
23
+ let stderr = "";
24
+ const io = {
25
+ cwd: REPO_ROOT,
26
+ homeDir: FIXTURE_HOME,
27
+ hostname: "test-host",
28
+ isTTY: false,
29
+ stdout: (chunk) => {
30
+ stdout += chunk;
31
+ },
32
+ stderr: (chunk) => {
33
+ stderr += chunk;
34
+ },
35
+ now: () => Date.parse("2026-11-25T12:00:00.000Z"),
36
+ ...overrides,
37
+ };
38
+ return {
39
+ io,
40
+ get stdout() {
41
+ return stdout;
42
+ },
43
+ get stderr() {
44
+ return stderr;
45
+ },
46
+ };
47
+ }
48
+ function createFixtureActivitySnapshot() {
49
+ return new LiveHistorySnapshot({
50
+ host: {
51
+ id: "test-host",
52
+ hostname: "test-host",
53
+ first_seen: "2026-11-24T09:00:00.000Z",
54
+ last_seen: "2026-11-25T10:00:00.000Z",
55
+ },
56
+ sources: [
57
+ {
58
+ id: "src:codex",
59
+ slot_id: "codex",
60
+ family: "local_coding_agent",
61
+ platform: "codex",
62
+ display_name: "Codex",
63
+ base_dir: path.join(FIXTURE_HOME, ".codex", "sessions"),
64
+ host_id: "test-host",
65
+ last_sync: "2026-11-25T10:00:00.000Z",
66
+ sync_status: "healthy",
67
+ total_blobs: 1,
68
+ total_records: 1,
69
+ total_fragments: 1,
70
+ total_atoms: 1,
71
+ total_sessions: 1,
72
+ total_turns: 1,
73
+ },
74
+ {
75
+ id: "src:claude_code",
76
+ slot_id: "claude_code",
77
+ family: "local_coding_agent",
78
+ platform: "claude_code",
79
+ display_name: "Claude Code",
80
+ base_dir: path.join(FIXTURE_HOME, ".claude", "projects"),
81
+ host_id: "test-host",
82
+ last_sync: "2026-11-25T10:00:00.000Z",
83
+ sync_status: "healthy",
84
+ total_blobs: 1,
85
+ total_records: 1,
86
+ total_fragments: 1,
87
+ total_atoms: 1,
88
+ total_sessions: 1,
89
+ total_turns: 1,
90
+ },
91
+ ],
92
+ projects: [],
93
+ sessions: [
94
+ {
95
+ id: "sess:codex:fixture-1",
96
+ source_id: "src:codex",
97
+ host_id: "test-host",
98
+ source_platform: "codex",
99
+ title: "Check containers",
100
+ canonical_title: "Check containers",
101
+ created_at: "2026-11-24T09:00:00.000Z",
102
+ updated_at: "2026-11-24T09:10:00.000Z",
103
+ turn_count: 1,
104
+ sync_axis: "current",
105
+ working_directory: FIXTURE_PROJECT,
106
+ usage_events: [
107
+ {
108
+ id: "ev-codex-1",
109
+ turn_id: "turn:codex:1",
110
+ created_at: "2026-11-24T09:05:00.000Z",
111
+ token_usage: { input_tokens: 100, output_tokens: 50, total_tokens: 150 },
112
+ emitted_tool_calls: [{ tool_name: "mcp__portainer_ro__list_containers", status: "success" }],
113
+ },
114
+ ],
115
+ },
116
+ {
117
+ id: "sess:claude_code:fixture-1",
118
+ source_id: "src:claude_code",
119
+ host_id: "test-host",
120
+ source_platform: "claude_code",
121
+ title: "Read repo",
122
+ canonical_title: "Read repo",
123
+ created_at: "2026-11-24T11:00:00.000Z",
124
+ updated_at: "2026-11-24T11:10:00.000Z",
125
+ turn_count: 1,
126
+ sync_axis: "current",
127
+ working_directory: FIXTURE_PROJECT,
128
+ tool_usage_summary: [
129
+ { tool_name: "mcp__filesystem__read_file", call_count: 4, last_used_at: "2026-11-24T11:08:00.000Z" },
130
+ ],
131
+ },
132
+ ],
133
+ turns: [
134
+ {
135
+ id: "turn:codex:1",
136
+ revision_id: "turn:codex:1:r1",
137
+ turn_id: "turn:codex:1",
138
+ turn_revision_id: "turn:codex:1:r1",
139
+ user_messages: [],
140
+ raw_text: "check containers",
141
+ canonical_text: "check containers",
142
+ display_segments: [],
143
+ created_at: "2026-11-24T09:00:00.000Z",
144
+ submission_started_at: "2026-11-24T09:00:00.000Z",
145
+ last_context_activity_at: "2026-11-24T09:10:00.000Z",
146
+ session_id: "sess:codex:fixture-1",
147
+ source_id: "src:codex",
148
+ link_state: "unlinked",
149
+ sync_axis: "current",
150
+ value_axis: "active",
151
+ retention_axis: "keep_raw_and_derived",
152
+ context_ref: "ctx:1",
153
+ context_summary: { assistant_reply_count: 1, tool_call_count: 1, total_tokens: 150, has_errors: false },
154
+ lineage: { atom_refs: [], candidate_refs: [], fragment_refs: [], record_refs: [], blob_refs: [] },
155
+ },
156
+ {
157
+ id: "turn:claude:1",
158
+ revision_id: "turn:claude:1:r1",
159
+ turn_id: "turn:claude:1",
160
+ turn_revision_id: "turn:claude:1:r1",
161
+ user_messages: [],
162
+ raw_text: "read files",
163
+ canonical_text: "read files",
164
+ display_segments: [],
165
+ created_at: "2026-11-24T11:00:00.000Z",
166
+ submission_started_at: "2026-11-24T11:00:00.000Z",
167
+ last_context_activity_at: "2026-11-24T11:10:00.000Z",
168
+ session_id: "sess:claude_code:fixture-1",
169
+ source_id: "src:claude_code",
170
+ link_state: "unlinked",
171
+ sync_axis: "current",
172
+ value_axis: "active",
173
+ retention_axis: "keep_raw_and_derived",
174
+ context_ref: "ctx:2",
175
+ context_summary: { assistant_reply_count: 1, tool_call_count: 4, has_errors: false },
176
+ lineage: { atom_refs: [], candidate_refs: [], fragment_refs: [], record_refs: [], blob_refs: [] },
177
+ },
178
+ ],
179
+ contexts: [],
180
+ ask_user_question_turns: [],
181
+ loss_audits: [],
182
+ });
183
+ }
184
+ test("CLI inventory scans mock_data fixtures, correlates 30d activity, emits envelope, and leaks zero secrets", async () => {
185
+ const fixtureSecrets = [
186
+ "mock_cli_arg_secret",
187
+ "mock_env_secret_portainer",
188
+ "mockpass",
189
+ "mock_query_secret",
190
+ "mock_header_secret_kuma",
191
+ "mock_env_secret_fs",
192
+ "mock_db_query_secret",
193
+ "mock_header_secret_db",
194
+ "mock_grok_query_secret",
195
+ "mock_env_secret_grok",
196
+ "agypass",
197
+ "mock_agy_query_secret",
198
+ "mock_header_secret_agy",
199
+ "mock_env_secret_unused",
200
+ "mock_oc_query_secret",
201
+ "mock_header_secret_oc",
202
+ "mock_env_secret_oc",
203
+ "mock_env_secret_dsh",
204
+ "mock_project_cli_secret",
205
+ "mock_env_secret_project",
206
+ ];
207
+ const mockScan = async (_options) => createFixtureActivitySnapshot();
208
+ // 1. Standard JSON output
209
+ const jsonRun = createCaptureIo({ scan: mockScan });
210
+ const jsonExit = await runLiteCli(["inventory", "--home", FIXTURE_HOME, "--dir", FIXTURE_PROJECT, "--since", "30d", "--json"], jsonRun.io);
211
+ assert.equal(jsonExit, 0, jsonRun.stderr);
212
+ for (const secret of fixtureSecrets) {
213
+ assert.equal(jsonRun.stdout.includes(secret), false, `Secret leaked in --json output: ${secret}`);
214
+ }
215
+ const parsed = JSON.parse(jsonRun.stdout);
216
+ assert.equal(parsed.schema, "cchistory-lite-inventory/v1");
217
+ assert.equal(parsed.summary.configured_agent_count, 6);
218
+ assert.equal(parsed.summary.mcp_server_count, 11);
219
+ assert.equal(parsed.summary.used_mcp_server_count, 2);
220
+ assert.equal(parsed.summary.unused_mcp_server_count, 9);
221
+ assert.ok(parsed.summary.skill_count >= 4);
222
+ assert.ok(parsed.summary.subagent_count >= 4);
223
+ assert.ok(parsed.summary.plugin_count >= 4);
224
+ assert.ok(parsed.summary.hook_count >= 2);
225
+ assert.ok(parsed.summary.rule_count >= 1);
226
+ const byKey = new Map(parsed.mcp_servers.map((s) => [`${s.client}:${s.server_id}`, s]));
227
+ const codexPortainer = byKey.get("codex:portainer_ro");
228
+ assert.equal(codexPortainer.used_in_window, true);
229
+ assert.equal(codexPortainer.call_count, 1);
230
+ assert.deepEqual(codexPortainer.env_keys, ["PORTAINER_TOKEN", "PORTAINER_URL"]);
231
+ assert.equal(String(codexPortainer.command).includes("--token=<redacted>"), true);
232
+ const codexKuma = byKey.get("codex:uptime_kuma");
233
+ assert.equal(codexKuma.used_in_window, false);
234
+ assert.equal(codexKuma.url, "https://kuma-local:3001/sse?api_key=<redacted>&mode=<redacted>");
235
+ assert.deepEqual(codexKuma.header_keys, ["Authorization"]);
236
+ // 2. Shared read-only v1 JSON envelope
237
+ const envRun = createCaptureIo({ scan: mockScan });
238
+ const envExit = await runLiteCli(["inventory", "--home", FIXTURE_HOME, "--dir", FIXTURE_PROJECT, "--envelope", "--host-id", "mac-mini-lab"], envRun.io);
239
+ assert.equal(envExit, 0, envRun.stderr);
240
+ for (const secret of fixtureSecrets) {
241
+ assert.equal(envRun.stdout.includes(secret), false, `Secret leaked in --envelope output: ${secret}`);
242
+ }
243
+ const envelope = JSON.parse(envRun.stdout);
244
+ assert.equal(envelope.schema_version, 1);
245
+ assert.equal(envelope.domain, "ai_agents");
246
+ assert.equal(envelope.owner, "cchistory-lite");
247
+ assert.equal(envelope.host_id, "mac-mini-lab");
248
+ assert.equal(envelope.stale_after_seconds, 86400);
249
+ assert.equal(envelope.status, "ok");
250
+ assert.equal(envelope.error, null);
251
+ assert.equal(envelope.delta, null);
252
+ assert.ok(Array.isArray(envelope.items) && envelope.items.length > 15);
253
+ // 3. Human-readable output with --no-activity (must not invoke scan!)
254
+ let scanCalled = false;
255
+ const textRun = createCaptureIo({
256
+ scan: async () => {
257
+ scanCalled = true;
258
+ return createFixtureActivitySnapshot();
259
+ },
260
+ });
261
+ const textExit = await runLiteCli(["inventory", "--home", FIXTURE_HOME, "--no-activity"], textRun.io);
262
+ assert.equal(textExit, 0, textRun.stderr);
263
+ assert.equal(scanCalled, false);
264
+ assert.match(textRun.stdout, /Agent Inventory/u);
265
+ assert.match(textRun.stdout, /MCP Servers/u);
266
+ assert.match(textRun.stdout, /Subagents/u);
267
+ assert.match(textRun.stdout, /Plugins/u);
268
+ for (const secret of fixtureSecrets) {
269
+ assert.equal(textRun.stdout.includes(secret), false, `Secret leaked in human text output: ${secret}`);
270
+ }
271
+ });
272
+ test("CLI inventory redacts adversarial real-shaped tokens and reports corrupt config diagnostics", async () => {
273
+ const tmpRoot = await fs.mkdtemp(path.join(os.tmpdir(), "cchistory-inv-redaction-"));
274
+ try {
275
+ const fakeJwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.signatureVal1234";
276
+ const fakeOpenAiKey = "sk-proj-TestRedactionSecretValue1234567890";
277
+ const fakeGhPat = "ghp_TestRedactionSecretValue1234567890";
278
+ await fs.mkdir(path.join(tmpRoot, ".codex"), { recursive: true });
279
+ await fs.mkdir(path.join(tmpRoot, ".grok"), { recursive: true });
280
+ await fs.writeFile(path.join(tmpRoot, ".codex", "config.toml"), [
281
+ "[mcp_servers.adv_stdio]",
282
+ 'command = "mcp-runner"',
283
+ `args = ["-H", "Authorization: Bearer ${fakeJwt}", "--api-key", "${fakeOpenAiKey}", "SECRET_ENV=${fakeGhPat}", "https://admin:topSecret99@api.example.test/mcp?token=querySecret42"]`,
284
+ `env = { OPENAI_API_KEY = "${fakeOpenAiKey}", GH_TOKEN = "${fakeGhPat}" }`,
285
+ ].join("\n"), "utf8");
286
+ await fs.writeFile(path.join(tmpRoot, ".grok", "config.toml"), "[mcp_servers.broken\nnot valid toml", "utf8");
287
+ const run = createCaptureIo({ homeDir: tmpRoot });
288
+ const exit = await runLiteCli(["inventory", "--home", tmpRoot, "--no-activity", "--envelope", "--host-id", "audit-host"], run.io);
289
+ assert.equal(exit, 0, run.stderr);
290
+ for (const secret of [fakeJwt, fakeOpenAiKey, fakeGhPat, "topSecret99", "querySecret42"]) {
291
+ assert.equal(run.stdout.includes(secret), false, `Adversarial secret leaked: ${secret}`);
292
+ }
293
+ const env = JSON.parse(run.stdout);
294
+ assert.equal(env.status, "partial");
295
+ assert.equal(env.summary.diagnostic_count, 1);
296
+ const server = env.items.find((i) => i.item_type === "mcp_server");
297
+ assert.deepEqual(server.env_keys, ["GH_TOKEN", "OPENAI_API_KEY"]);
298
+ }
299
+ finally {
300
+ await fs.rm(tmpRoot, { recursive: true, force: true });
301
+ }
302
+ });
303
+ test("CLI ls projects --with-git and merge-projects reconcile real local Git repos and non-Git fallback", async () => {
304
+ const tmpRoot = await fs.mkdtemp(path.join(os.tmpdir(), "cchistory-git-meta-"));
305
+ try {
306
+ const bareRemote = path.join(tmpRoot, "remote.git");
307
+ const repoHostA = path.join(tmpRoot, "host-a", "demo-app");
308
+ const repoHostB = path.join(tmpRoot, "host-b", "demo-app");
309
+ const nonGitA = path.join(tmpRoot, "host-a", "scratch-notes");
310
+ const nonGitB = path.join(tmpRoot, "host-b", "scratch-notes");
311
+ await fs.mkdir(path.dirname(repoHostA), { recursive: true });
312
+ await fs.mkdir(path.dirname(repoHostB), { recursive: true });
313
+ await fs.mkdir(nonGitA, { recursive: true });
314
+ await fs.mkdir(nonGitB, { recursive: true });
315
+ const gitEnv = {
316
+ ...process.env,
317
+ GIT_AUTHOR_NAME: "Mock Dev",
318
+ GIT_AUTHOR_EMAIL: "mock@example.test",
319
+ GIT_COMMITTER_NAME: "Mock Dev",
320
+ GIT_COMMITTER_EMAIL: "mock@example.test",
321
+ };
322
+ await execFile("git", ["init", "--bare", bareRemote], { env: gitEnv });
323
+ await execFile("git", ["clone", bareRemote, repoHostA], { env: gitEnv });
324
+ await execFile("git", ["-C", repoHostA, "checkout", "-b", "main"], { env: gitEnv });
325
+ await fs.writeFile(path.join(repoHostA, "README.md"), "# Demo\n", "utf8");
326
+ await execFile("git", ["-C", repoHostA, "add", "README.md"], { env: gitEnv });
327
+ await execFile("git", ["-C", repoHostA, "commit", "-m", "init"], {
328
+ env: { ...gitEnv, GIT_AUTHOR_DATE: "2026-11-20T10:00:00Z", GIT_COMMITTER_DATE: "2026-11-20T10:00:00Z" },
329
+ });
330
+ await execFile("git", ["-C", repoHostA, "push", "-u", "origin", "main"], { env: gitEnv });
331
+ // Clone Host B on main, then switch to feature branch so branches diverge
332
+ await execFile("git", ["clone", bareRemote, repoHostB], { env: gitEnv });
333
+ await execFile("git", ["-C", repoHostB, "checkout", "-b", "feat/remote-branch"], { env: gitEnv });
334
+ // Advance Host A with an unpushed commit and a dirty untracked file
335
+ await fs.writeFile(path.join(repoHostA, "README.md"), "# Demo updated\n", "utf8");
336
+ await execFile("git", ["-C", repoHostA, "commit", "-am", "ahead commit"], {
337
+ env: { ...gitEnv, GIT_AUTHOR_DATE: "2026-11-24T12:00:00Z", GIT_COMMITTER_DATE: "2026-11-24T12:00:00Z" },
338
+ });
339
+ await fs.writeFile(path.join(repoHostA, "dirty.txt"), "uncommitted\n", "utf8");
340
+ // Set distinct URL formats on origin so canonical remote matching is exercised end-to-end
341
+ await execFile("git", ["-C", repoHostA, "remote", "set-url", "origin", "https://tokUser:tokPass@github.com/ExampleOrg/Demo-App.git"], { env: gitEnv });
342
+ await execFile("git", ["-C", repoHostB, "remote", "set-url", "origin", "git@github.com:exampleorg/demo-app.git"], { env: gitEnv });
343
+ const makeSnapshot = (hostId, repoPath, nonGitPath, lastActivity) => new LiveHistorySnapshot({
344
+ host: {
345
+ id: hostId,
346
+ hostname: hostId,
347
+ first_seen: "2026-11-20T10:00:00.000Z",
348
+ last_seen: lastActivity,
349
+ },
350
+ sources: [
351
+ {
352
+ id: `src:${hostId}:codex`,
353
+ slot_id: "codex",
354
+ family: "local_coding_agent",
355
+ platform: "codex",
356
+ display_name: "Codex",
357
+ base_dir: path.join(tmpRoot, hostId, ".codex"),
358
+ host_id: hostId,
359
+ last_sync: lastActivity,
360
+ sync_status: "healthy",
361
+ total_blobs: 2,
362
+ total_records: 2,
363
+ total_fragments: 2,
364
+ total_atoms: 2,
365
+ total_sessions: 2,
366
+ total_turns: 2,
367
+ },
368
+ ],
369
+ projects: [
370
+ {
371
+ project_id: `proj:${hostId}:demo`,
372
+ project_revision_id: `proj:${hostId}:demo:r1`,
373
+ display_name: "demo-app",
374
+ slug: "demo-app",
375
+ linkage_state: "committed",
376
+ confidence: 0.9,
377
+ link_reason: "repo_root_match",
378
+ manual_override_status: "none",
379
+ primary_workspace_path: repoPath,
380
+ repo_root: repoPath,
381
+ source_platforms: ["codex"],
382
+ host_ids: [hostId],
383
+ committed_turn_count: 1,
384
+ candidate_turn_count: 0,
385
+ session_count: 1,
386
+ project_last_activity_at: lastActivity,
387
+ created_at: "2026-11-20T10:00:00.000Z",
388
+ updated_at: lastActivity,
389
+ },
390
+ {
391
+ project_id: `proj:${hostId}:scratch`,
392
+ project_revision_id: `proj:${hostId}:scratch:r1`,
393
+ display_name: "scratch-notes",
394
+ slug: "scratch-notes",
395
+ linkage_state: "candidate",
396
+ confidence: 0.6,
397
+ link_reason: "workspace_path_continuity",
398
+ manual_override_status: "none",
399
+ primary_workspace_path: nonGitPath,
400
+ source_platforms: ["codex"],
401
+ host_ids: [hostId],
402
+ committed_turn_count: 0,
403
+ candidate_turn_count: 1,
404
+ session_count: 1,
405
+ project_last_activity_at: "2026-11-22T08:00:00.000Z",
406
+ created_at: "2026-11-20T10:00:00.000Z",
407
+ updated_at: "2026-11-22T08:00:00.000Z",
408
+ },
409
+ ],
410
+ sessions: [
411
+ {
412
+ id: `sess:${hostId}:demo`,
413
+ source_id: `src:${hostId}:codex`,
414
+ host_id: hostId,
415
+ source_platform: "codex",
416
+ title: "Demo work",
417
+ canonical_title: "Demo work",
418
+ created_at: lastActivity,
419
+ updated_at: lastActivity,
420
+ turn_count: 1,
421
+ working_directory: repoPath,
422
+ primary_project_id: `proj:${hostId}:demo`,
423
+ sync_axis: "current",
424
+ },
425
+ {
426
+ id: `sess:${hostId}:scratch`,
427
+ source_id: `src:${hostId}:codex`,
428
+ host_id: hostId,
429
+ source_platform: "codex",
430
+ title: "Scratch notes",
431
+ canonical_title: "Scratch notes",
432
+ created_at: "2026-11-22T08:00:00.000Z",
433
+ updated_at: "2026-11-22T08:00:00.000Z",
434
+ turn_count: 1,
435
+ working_directory: nonGitPath,
436
+ primary_project_id: `proj:${hostId}:scratch`,
437
+ sync_axis: "current",
438
+ },
439
+ ],
440
+ turns: [
441
+ {
442
+ id: `turn:${hostId}:demo`,
443
+ revision_id: `turn:${hostId}:demo:r1`,
444
+ turn_id: `turn:${hostId}:demo`,
445
+ turn_revision_id: `turn:${hostId}:demo:r1`,
446
+ user_messages: [],
447
+ raw_text: "update demo",
448
+ canonical_text: "update demo",
449
+ display_segments: [],
450
+ created_at: lastActivity,
451
+ submission_started_at: lastActivity,
452
+ last_context_activity_at: lastActivity,
453
+ session_id: `sess:${hostId}:demo`,
454
+ source_id: `src:${hostId}:codex`,
455
+ project_id: `proj:${hostId}:demo`,
456
+ link_state: "committed",
457
+ sync_axis: "current",
458
+ value_axis: "active",
459
+ retention_axis: "keep_raw_and_derived",
460
+ context_ref: `ctx:${hostId}:demo`,
461
+ context_summary: { assistant_reply_count: 1, tool_call_count: 0, has_errors: false },
462
+ lineage: { atom_refs: [], candidate_refs: [], fragment_refs: [], record_refs: [], blob_refs: [] },
463
+ },
464
+ {
465
+ id: `turn:${hostId}:scratch`,
466
+ revision_id: `turn:${hostId}:scratch:r1`,
467
+ turn_id: `turn:${hostId}:scratch`,
468
+ turn_revision_id: `turn:${hostId}:scratch:r1`,
469
+ user_messages: [],
470
+ raw_text: "jot note",
471
+ canonical_text: "jot note",
472
+ display_segments: [],
473
+ created_at: "2026-11-22T08:00:00.000Z",
474
+ submission_started_at: "2026-11-22T08:00:00.000Z",
475
+ last_context_activity_at: "2026-11-22T08:00:00.000Z",
476
+ session_id: `sess:${hostId}:scratch`,
477
+ source_id: `src:${hostId}:codex`,
478
+ project_id: `proj:${hostId}:scratch`,
479
+ link_state: "candidate",
480
+ sync_axis: "current",
481
+ value_axis: "active",
482
+ retention_axis: "keep_raw_and_derived",
483
+ context_ref: `ctx:${hostId}:scratch`,
484
+ context_summary: { assistant_reply_count: 1, tool_call_count: 0, has_errors: false },
485
+ lineage: { atom_refs: [], candidate_refs: [], fragment_refs: [], record_refs: [], blob_refs: [] },
486
+ },
487
+ ],
488
+ contexts: [],
489
+ ask_user_question_turns: [],
490
+ loss_audits: [],
491
+ });
492
+ // Without --with-git: must NOT attach git metadata
493
+ const plainRun = createCaptureIo({
494
+ hostname: "host-a",
495
+ scan: async () => makeSnapshot("host-a", repoHostA, nonGitA, "2026-11-25T08:00:00.000Z"),
496
+ });
497
+ assert.equal(await runLiteCli(["ls", "projects", "--no-dir", "--json"], plainRun.io), 0, plainRun.stderr);
498
+ const plainJson = JSON.parse(plainRun.stdout);
499
+ assert.equal(plainJson.projects[0].git, undefined);
500
+ // Host A with --with-git --json
501
+ const runA = createCaptureIo({
502
+ hostname: "host-a",
503
+ scan: async () => makeSnapshot("host-a", repoHostA, nonGitA, "2026-11-25T08:00:00.000Z"),
504
+ });
505
+ assert.equal(await runLiteCli(["ls", "projects", "--no-dir", "--with-git", "--host-id", "host-a", "--json"], runA.io), 0, runA.stderr);
506
+ assert.equal(runA.stdout.includes("tokPass"), false, "Embedded git remote password leaked!");
507
+ const jsonA = JSON.parse(runA.stdout);
508
+ assert.equal(jsonA.host_id, "host-a");
509
+ const demoA = jsonA.projects.find((p) => p.display_name === "demo-app");
510
+ assert.equal(demoA.git.status, "ok");
511
+ assert.equal(demoA.git.repo_remote, "github.com/exampleorg/demo-app");
512
+ assert.equal(demoA.git.branch, "main");
513
+ assert.equal(demoA.git.dirty_files, 1);
514
+ assert.equal(demoA.git.ahead, 1);
515
+ assert.equal(demoA.git.behind, 0);
516
+ // Host B with --with-git --envelope
517
+ const runB = createCaptureIo({
518
+ hostname: "host-b",
519
+ scan: async () => makeSnapshot("host-b", repoHostB, nonGitB, "2026-11-24T09:00:00.000Z"),
520
+ });
521
+ assert.equal(await runLiteCli(["ls", "projects", "--no-dir", "--with-git", "--envelope", "--host-id", "host-b"], runB.io), 0, runB.stderr);
522
+ const envB = JSON.parse(runB.stdout);
523
+ assert.equal(envB.schema_version, 1);
524
+ assert.equal(envB.domain, "projects");
525
+ assert.equal(envB.delta, null);
526
+ // Write both files and merge them via `merge-projects` (proving mixed v2 + envelope input compatibility!)
527
+ const fileA = path.join(tmpRoot, "host-a.json");
528
+ const fileB = path.join(tmpRoot, "host-b.json");
529
+ await fs.writeFile(fileA, runA.stdout, "utf8");
530
+ await fs.writeFile(fileB, runB.stdout, "utf8");
531
+ const mergeRun = createCaptureIo({ cwd: tmpRoot });
532
+ assert.equal(await runLiteCli(["merge-projects", "host-a.json", "host-b.json", "--json"], mergeRun.io), 0, mergeRun.stderr);
533
+ const merged = JSON.parse(mergeRun.stdout);
534
+ assert.equal(merged.schema, "cchistory-lite-merged-projects/v1");
535
+ assert.deepEqual(merged.hosts, ["host-a", "host-b"]);
536
+ assert.equal(merged.summary.project_count, 2);
537
+ assert.equal(merged.summary.repo_remote_matched_count, 1);
538
+ assert.equal(merged.summary.directory_fallback_count, 1);
539
+ assert.equal(merged.summary.diverged_project_count, 1);
540
+ const demoMerged = merged.projects.find((p) => p.match_kind === "repo_remote");
541
+ assert.equal(demoMerged.repo_remote, "github.com/exampleorg/demo-app");
542
+ assert.equal(demoMerged.latest_commit_host, "host-a");
543
+ assert.equal(demoMerged.branch_diverged, true);
544
+ assert.deepEqual(demoMerged.dirty_hosts, ["host-a"]);
545
+ assert.deepEqual(demoMerged.unpushed_hosts, ["host-a"]);
546
+ const scratchMerged = merged.projects.find((p) => p.match_kind === "directory_fallback");
547
+ assert.deepEqual(scratchMerged.host_ids, ["host-a", "host-b"]);
548
+ assert.equal(scratchMerged.sync_state, "non_git");
549
+ // Human-readable merge-projects output
550
+ const mergeTextRun = createCaptureIo({ cwd: tmpRoot });
551
+ assert.equal(await runLiteCli(["merge-projects", "host-a.json", "host-b.json"], mergeTextRun.io), 0, mergeTextRun.stderr);
552
+ assert.match(mergeTextRun.stdout, /Merged Projects/u);
553
+ assert.match(mergeTextRun.stdout, /branch diverged/u);
554
+ }
555
+ finally {
556
+ await fs.rm(tmpRoot, { recursive: true, force: true });
557
+ }
558
+ });
559
+ test("CLI rejects invalid Slice A/B option combinations with exit code 2", async () => {
560
+ const r1 = createCaptureIo();
561
+ assert.equal(await runLiteCli(["ls", "sessions", "--with-git"], r1.io), 2);
562
+ const r2 = createCaptureIo();
563
+ assert.equal(await runLiteCli(["stats", "--no-activity"], r2.io), 2);
564
+ const r3 = createCaptureIo();
565
+ assert.equal(await runLiteCli(["inventory", "--json=canonical"], r3.io), 2);
566
+ const r4 = createCaptureIo();
567
+ assert.equal(await runLiteCli(["merge-projects"], r4.io), 2);
568
+ const r5 = createCaptureIo();
569
+ assert.equal(await runLiteCli(["merge-projects", "a.json", "--safe"], r5.io), 2);
570
+ const r6 = createCaptureIo();
571
+ assert.equal(await runLiteCli(["stats", "--agent", "codex"], r6.io), 2);
572
+ });
573
+ test("CLI inventory --agent and --dir resolve native per-tool pre-launch startup contexts in JSON and human output", async () => {
574
+ const jsonRun = createCaptureIo();
575
+ const jsonExit = await runLiteCli([
576
+ "inventory",
577
+ "--home",
578
+ FIXTURE_HOME,
579
+ "--dir",
580
+ FIXTURE_PROJECT,
581
+ "--agent",
582
+ "claude_code",
583
+ "--agent",
584
+ "codex",
585
+ "--agent",
586
+ "lobechat",
587
+ "--no-activity",
588
+ "--json",
589
+ ], jsonRun.io);
590
+ assert.equal(jsonExit, 0, jsonRun.stderr);
591
+ const parsed = JSON.parse(jsonRun.stdout);
592
+ assert.ok(Array.isArray(parsed.startup_contexts));
593
+ assert.equal(parsed.startup_contexts.length, 3);
594
+ assert.equal(parsed.startup_contexts[0].client, "claude_code");
595
+ assert.equal(parsed.startup_contexts[0].resolution_tier, "native");
596
+ assert.equal(parsed.startup_contexts[1].client, "codex");
597
+ assert.equal(parsed.startup_contexts[1].resolution_tier, "native");
598
+ assert.equal(parsed.startup_contexts[2].client, "lobechat");
599
+ assert.equal(parsed.startup_contexts[2].resolution_tier, "unsupported");
600
+ // Human rendering preserves each tool's native headings & budget/chain labels
601
+ const textRun = createCaptureIo();
602
+ const textExit = await runLiteCli([
603
+ "inventory",
604
+ "--home",
605
+ FIXTURE_HOME,
606
+ "--dir",
607
+ FIXTURE_PROJECT,
608
+ "--agent",
609
+ "claude_code",
610
+ "--agent",
611
+ "codex",
612
+ "--no-activity",
613
+ ], textRun.io);
614
+ assert.equal(textExit, 0, textRun.stderr);
615
+ assert.match(textRun.stdout, /Pre-Launch Startup Contexts/u);
616
+ assert.match(textRun.stdout, /Claude Code \[claude_code\]/u);
617
+ assert.match(textRun.stdout, /Codex \[codex\] · doc budget/u);
618
+ // Focused --agent mode must NOT dump unrelated full-machine sections
619
+ assert.equal(textRun.stdout.includes("\nAgents\n"), false);
620
+ assert.equal(textRun.stdout.includes("mock_project_cli_secret"), false);
621
+ assert.equal(textRun.stdout.includes("mock_env_secret_portainer"), false);
622
+ });
623
+ test("CLI enforces P0/P1 UX invariants: --agent cwd default, unknown --agent exit 2, invariant MCP counts, envelope all-rows & error format, duplicate host_id exit 2", async () => {
624
+ // 1. Unknown --agent and nonexistent --dir must exit 2
625
+ const badAgent = createCaptureIo();
626
+ assert.equal(await runLiteCli(["inventory", "--home", FIXTURE_HOME, "--agent", "definitely_unknown", "--no-activity"], badAgent.io), 2);
627
+ assert.match(badAgent.stderr, /Unknown --agent/u);
628
+ const badDir = createCaptureIo();
629
+ assert.equal(await runLiteCli(["inventory", "--home", FIXTURE_HOME, "--dir", "/tmp/nonexistent-dir-xyz-987654", "--no-activity"], badDir.io), 2);
630
+ // 2. --agent without --dir defaults to io.cwd; --no-dir switches to global scope
631
+ const cwdDefaultRun = createCaptureIo({ cwd: FIXTURE_PROJECT });
632
+ assert.equal(await runLiteCli(["inventory", "--home", FIXTURE_HOME, "--agent", "claude", "--no-activity", "--json"], cwdDefaultRun.io), 0, cwdDefaultRun.stderr);
633
+ const cwdDefaultJson = JSON.parse(cwdDefaultRun.stdout);
634
+ assert.equal(cwdDefaultJson.project_dir, FIXTURE_PROJECT);
635
+ assert.equal(cwdDefaultJson.startup_contexts[0].client, "claude_code");
636
+ const globalOnlyRun = createCaptureIo({ cwd: FIXTURE_PROJECT });
637
+ assert.equal(await runLiteCli(["inventory", "--home", FIXTURE_HOME, "--agent", "codex", "--no-dir", "--no-activity", "--json"], globalOnlyRun.io), 0, globalOnlyRun.stderr);
638
+ const globalOnlyJson = JSON.parse(globalOnlyRun.stdout);
639
+ assert.equal(globalOnlyJson.project_dir, null);
640
+ // 3. Static summary.mcp_server_count must stay invariant regardless of --agent filter
641
+ const allAgentsRun = createCaptureIo();
642
+ assert.equal(await runLiteCli(["inventory", "--home", FIXTURE_HOME, "--dir", FIXTURE_PROJECT, "--no-activity", "--json"], allAgentsRun.io), 0);
643
+ const codexOnlyRun = createCaptureIo();
644
+ assert.equal(await runLiteCli(["inventory", "--home", FIXTURE_HOME, "--dir", FIXTURE_PROJECT, "--agent", "codex", "--no-activity", "--json"], codexOnlyRun.io), 0);
645
+ assert.equal(JSON.parse(allAgentsRun.stdout).summary.mcp_server_count, JSON.parse(codexOnlyRun.stdout).summary.mcp_server_count);
646
+ // 4. --envelope errors emit v1 ReadOnlyEnvelopeV1 with status="error"
647
+ const envErrRun = createCaptureIo();
648
+ assert.equal(await runLiteCli(["merge-projects", "does-not-exist-file.json", "--envelope", "--host-id", "err-host"], envErrRun.io), 2);
649
+ assert.equal(envErrRun.stdout, "");
650
+ const errEnv = JSON.parse(envErrRun.stderr);
651
+ assert.equal(errEnv.schema_version, 1);
652
+ assert.equal(errEnv.domain, "projects");
653
+ assert.equal(errEnv.host_id, "err-host");
654
+ assert.equal(errEnv.status, "error");
655
+ assert.equal(errEnv.delta, null);
656
+ assert.ok(typeof errEnv.error === "string" && errEnv.error.length > 0);
657
+ // 5. merge-projects rejects duplicate host_id (exit 2) and warns on truncated / non-git snapshots
658
+ const tmp = await fs.mkdtemp(path.join(os.tmpdir(), "cchistory-merge-ux-"));
659
+ try {
660
+ const dupA = path.join(tmp, "dup-a.json");
661
+ const dupB = path.join(tmp, "dup-b.json");
662
+ await fs.writeFile(dupA, JSON.stringify({ host_id: "same-host", projects: [] }), "utf8");
663
+ await fs.writeFile(dupB, JSON.stringify({ host_id: "same-host", projects: [] }), "utf8");
664
+ const dupRun = createCaptureIo({ cwd: tmp });
665
+ assert.equal(await runLiteCli(["merge-projects", "dup-a.json", "dup-b.json"], dupRun.io), 2);
666
+ assert.match(dupRun.stderr, /Duplicate host_id/u);
667
+ const noGitA = path.join(tmp, "nogit-a.json");
668
+ const noGitB = path.join(tmp, "nogit-b.json");
669
+ await fs.writeFile(noGitA, JSON.stringify({ host_id: "h-a", total: 25, shown: 1, projects: [{ display_name: "beta", primary_workspace_path: "/work/a/beta" }] }), "utf8");
670
+ await fs.writeFile(noGitB, JSON.stringify({ host_id: "h-b", total: 1, shown: 1, projects: [{ display_name: "beta", primary_workspace_path: "/work/b/beta" }] }), "utf8");
671
+ const warnRun = createCaptureIo({ cwd: tmp });
672
+ assert.equal(await runLiteCli(["merge-projects", "nogit-a.json", "nogit-b.json"], warnRun.io), 0, warnRun.stderr);
673
+ assert.match(warnRun.stdout, /Warnings \(/u);
674
+ assert.match(warnRun.stdout, /truncated \(1\/25/u);
675
+ assert.match(warnRun.stdout, /git: unavailable/u);
676
+ assert.match(warnRun.stdout, /\[git_not_collected\]/u);
677
+ assert.match(warnRun.stdout, /\/work\/a\/beta/u);
678
+ // 6. ls projects --no-dir --envelope exports ALL 25 projects (not truncated at 20)
679
+ const manyProjects = Array.from({ length: 25 }, (_, i) => ({
680
+ project_id: `proj:many:${i}`,
681
+ project_revision_id: `proj:many:${i}:r1`,
682
+ display_name: `proj-${i}`,
683
+ slug: `proj-${i}`,
684
+ linkage_state: "committed",
685
+ confidence: 0.9,
686
+ link_reason: "repo_root_match",
687
+ manual_override_status: "none",
688
+ primary_workspace_path: path.join(tmp, `p-${i}`),
689
+ source_platforms: ["codex"],
690
+ host_ids: ["many-host"],
691
+ committed_turn_count: 1,
692
+ candidate_turn_count: 0,
693
+ session_count: 1,
694
+ project_last_activity_at: `2026-11-${String(1 + (i % 20)).padStart(2, "0")}T10:00:00.000Z`,
695
+ created_at: "2026-11-01T10:00:00.000Z",
696
+ updated_at: "2026-11-20T10:00:00.000Z",
697
+ }));
698
+ const manySessions = manyProjects.map((p, i) => ({
699
+ id: `sess:many:${i}`,
700
+ source_id: "src:many:codex",
701
+ host_id: "many-host",
702
+ source_platform: "codex",
703
+ title: `Session ${i}`,
704
+ canonical_title: `Session ${i}`,
705
+ created_at: p.updated_at,
706
+ updated_at: p.updated_at,
707
+ turn_count: 1,
708
+ working_directory: p.primary_workspace_path,
709
+ primary_project_id: p.project_id,
710
+ sync_axis: "current",
711
+ }));
712
+ const manyTurns = manyProjects.map((p, i) => ({
713
+ id: `turn:many:${i}`,
714
+ revision_id: `turn:many:${i}:r1`,
715
+ turn_id: `turn:many:${i}`,
716
+ turn_revision_id: `turn:many:${i}:r1`,
717
+ user_messages: [],
718
+ raw_text: `work ${i}`,
719
+ canonical_text: `work ${i}`,
720
+ display_segments: [],
721
+ created_at: p.updated_at,
722
+ submission_started_at: p.updated_at,
723
+ last_context_activity_at: p.updated_at,
724
+ session_id: `sess:many:${i}`,
725
+ source_id: "src:many:codex",
726
+ project_id: p.project_id,
727
+ link_state: "committed",
728
+ sync_axis: "current",
729
+ value_axis: "active",
730
+ retention_axis: "keep_raw_and_derived",
731
+ context_ref: `ctx:many:${i}`,
732
+ context_summary: { assistant_reply_count: 1, tool_call_count: 0, has_errors: false },
733
+ lineage: { atom_refs: [], candidate_refs: [], fragment_refs: [], record_refs: [], blob_refs: [] },
734
+ }));
735
+ const manySnapshot = new LiveHistorySnapshot({
736
+ host: { id: "many-host", hostname: "many-host", first_seen: "2026-11-01T10:00:00.000Z", last_seen: "2026-11-20T10:00:00.000Z" },
737
+ sources: [
738
+ {
739
+ id: "src:many:codex",
740
+ slot_id: "codex",
741
+ family: "local_coding_agent",
742
+ platform: "codex",
743
+ display_name: "Codex",
744
+ base_dir: path.join(tmp, ".codex"),
745
+ host_id: "many-host",
746
+ last_sync: "2026-11-20T10:00:00.000Z",
747
+ sync_status: "healthy",
748
+ total_blobs: 25,
749
+ total_records: 25,
750
+ total_fragments: 25,
751
+ total_atoms: 25,
752
+ total_sessions: 25,
753
+ total_turns: 25,
754
+ },
755
+ ],
756
+ projects: manyProjects,
757
+ sessions: manySessions,
758
+ turns: manyTurns,
759
+ contexts: [],
760
+ ask_user_question_turns: [],
761
+ loss_audits: [],
762
+ });
763
+ const envAllRun = createCaptureIo({ scan: async () => manySnapshot });
764
+ assert.equal(await runLiteCli(["ls", "projects", "--no-dir", "--envelope", "--host-id", "many-host"], envAllRun.io), 0, envAllRun.stderr);
765
+ const envAll = JSON.parse(envAllRun.stdout);
766
+ assert.equal(envAll.items.length, 25);
767
+ assert.equal(envAll.summary.total_project_count, 25);
768
+ assert.equal(envAll.summary.truncated, false);
769
+ assert.equal(envAll.summary.git_inspected, false);
770
+ assert.equal(envAll.summary.git_dirty_count, null);
771
+ }
772
+ finally {
773
+ await fs.rm(tmp, { recursive: true, force: true });
774
+ }
775
+ });
776
+ //# sourceMappingURL=inventory-and-git.test.js.map