@cchistory/lite 0.9.0 → 0.9.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 (228) 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/index.d.ts.map +1 -1
  34. package/apps/lite-tui/dist/index.js +40 -9
  35. package/apps/lite-tui/dist/index.js.map +1 -1
  36. package/apps/lite-tui/dist/input.js +2 -2
  37. package/apps/lite-tui/dist/input.js.map +1 -1
  38. package/apps/lite-tui/dist/keys.d.ts.map +1 -1
  39. package/apps/lite-tui/dist/keys.js +52 -14
  40. package/apps/lite-tui/dist/keys.js.map +1 -1
  41. package/apps/lite-tui/dist/keys.test.js +29 -0
  42. package/apps/lite-tui/dist/keys.test.js.map +1 -1
  43. package/apps/lite-tui/dist/model.d.ts +2 -0
  44. package/apps/lite-tui/dist/model.d.ts.map +1 -1
  45. package/apps/lite-tui/dist/model.js +59 -9
  46. package/apps/lite-tui/dist/model.js.map +1 -1
  47. package/apps/lite-tui/dist/render.d.ts +1 -1
  48. package/apps/lite-tui/dist/render.d.ts.map +1 -1
  49. package/apps/lite-tui/dist/render.js +10 -4
  50. package/apps/lite-tui/dist/render.js.map +1 -1
  51. package/apps/lite-tui/dist/render.test.js +31 -0
  52. package/apps/lite-tui/dist/render.test.js.map +1 -1
  53. package/apps/lite-tui/dist/state.js +1 -1
  54. package/apps/lite-tui/dist/state.js.map +1 -1
  55. package/apps/lite-tui/dist/state.test.js +54 -0
  56. package/apps/lite-tui/dist/state.test.js.map +1 -1
  57. package/apps/lite-tui/dist/stats-dashboard.test.js +130 -0
  58. package/apps/lite-tui/dist/stats-dashboard.test.js.map +1 -1
  59. package/apps/lite-tui/dist/stats-render.d.ts +1 -1
  60. package/apps/lite-tui/dist/stats-render.d.ts.map +1 -1
  61. package/apps/lite-tui/dist/stats-render.js +3 -0
  62. package/apps/lite-tui/dist/stats-render.js.map +1 -1
  63. package/apps/lite-tui/dist/stats-visuals.d.ts.map +1 -1
  64. package/apps/lite-tui/dist/stats-visuals.js +3 -1
  65. package/apps/lite-tui/dist/stats-visuals.js.map +1 -1
  66. package/apps/lite-tui/dist/version.d.ts +1 -1
  67. package/apps/lite-tui/dist/version.js +1 -1
  68. package/docs/guide/for-agents.md +14 -0
  69. package/docs/guide/lite.md +53 -2
  70. package/node_modules/@cchistory/canonical/dist/agent-inventory.d.ts +25 -0
  71. package/node_modules/@cchistory/canonical/dist/agent-inventory.d.ts.map +1 -0
  72. package/node_modules/@cchistory/canonical/dist/agent-inventory.js +345 -0
  73. package/node_modules/@cchistory/canonical/dist/agent-inventory.js.map +1 -0
  74. package/node_modules/@cchistory/canonical/dist/agent-inventory.test.d.ts +7 -0
  75. package/node_modules/@cchistory/canonical/dist/agent-inventory.test.d.ts.map +1 -0
  76. package/node_modules/@cchistory/canonical/dist/agent-inventory.test.js +231 -0
  77. package/node_modules/@cchistory/canonical/dist/agent-inventory.test.js.map +1 -0
  78. package/node_modules/@cchistory/canonical/dist/directory-scope.d.ts.map +1 -1
  79. package/node_modules/@cchistory/canonical/dist/directory-scope.js +4 -1
  80. package/node_modules/@cchistory/canonical/dist/directory-scope.js.map +1 -1
  81. package/node_modules/@cchistory/canonical/dist/fallback-projects.d.ts.map +1 -1
  82. package/node_modules/@cchistory/canonical/dist/fallback-projects.js +5 -2
  83. package/node_modules/@cchistory/canonical/dist/fallback-projects.js.map +1 -1
  84. package/node_modules/@cchistory/canonical/dist/index.d.ts +3 -1
  85. package/node_modules/@cchistory/canonical/dist/index.d.ts.map +1 -1
  86. package/node_modules/@cchistory/canonical/dist/index.js +3 -1
  87. package/node_modules/@cchistory/canonical/dist/index.js.map +1 -1
  88. package/node_modules/@cchistory/canonical/dist/index.test.js +215 -1
  89. package/node_modules/@cchistory/canonical/dist/index.test.js.map +1 -1
  90. package/node_modules/@cchistory/canonical/dist/project-linker.d.ts +2 -1
  91. package/node_modules/@cchistory/canonical/dist/project-linker.d.ts.map +1 -1
  92. package/node_modules/@cchistory/canonical/dist/project-linker.js +113 -6
  93. package/node_modules/@cchistory/canonical/dist/project-linker.js.map +1 -1
  94. package/node_modules/@cchistory/canonical/dist/project-merge.d.ts +42 -0
  95. package/node_modules/@cchistory/canonical/dist/project-merge.d.ts.map +1 -0
  96. package/node_modules/@cchistory/canonical/dist/project-merge.js +396 -0
  97. package/node_modules/@cchistory/canonical/dist/project-merge.js.map +1 -0
  98. package/node_modules/@cchistory/canonical/dist/project-merge.test.d.ts +7 -0
  99. package/node_modules/@cchistory/canonical/dist/project-merge.test.d.ts.map +1 -0
  100. package/node_modules/@cchistory/canonical/dist/project-merge.test.js +319 -0
  101. package/node_modules/@cchistory/canonical/dist/project-merge.test.js.map +1 -0
  102. package/node_modules/@cchistory/canonical/dist/session-interpreter.d.ts.map +1 -1
  103. package/node_modules/@cchistory/canonical/dist/session-interpreter.js +38 -0
  104. package/node_modules/@cchistory/canonical/dist/session-interpreter.js.map +1 -1
  105. package/node_modules/@cchistory/canonical/dist/tool-call-summary.d.ts.map +1 -1
  106. package/node_modules/@cchistory/canonical/dist/tool-call-summary.js +8 -0
  107. package/node_modules/@cchistory/canonical/dist/tool-call-summary.js.map +1 -1
  108. package/node_modules/@cchistory/canonical/dist/usage-call-evaluation.d.ts.map +1 -1
  109. package/node_modules/@cchistory/canonical/dist/usage-call-evaluation.js +5 -1
  110. package/node_modules/@cchistory/canonical/dist/usage-call-evaluation.js.map +1 -1
  111. package/node_modules/@cchistory/canonical/dist/usage-trace.d.ts.map +1 -1
  112. package/node_modules/@cchistory/canonical/dist/usage-trace.js +10 -4
  113. package/node_modules/@cchistory/canonical/dist/usage-trace.js.map +1 -1
  114. package/node_modules/@cchistory/canonical/dist/usage.d.ts +2 -0
  115. package/node_modules/@cchistory/canonical/dist/usage.d.ts.map +1 -1
  116. package/node_modules/@cchistory/canonical/dist/usage.js +44 -6
  117. package/node_modules/@cchistory/canonical/dist/usage.js.map +1 -1
  118. package/node_modules/@cchistory/canonical/package.json +1 -1
  119. package/node_modules/@cchistory/domain/dist/agent-inventory.d.ts +146 -0
  120. package/node_modules/@cchistory/domain/dist/agent-inventory.d.ts.map +1 -0
  121. package/node_modules/@cchistory/domain/dist/agent-inventory.js +9 -0
  122. package/node_modules/@cchistory/domain/dist/agent-inventory.js.map +1 -0
  123. package/node_modules/@cchistory/domain/dist/agent-startup.d.ts +362 -0
  124. package/node_modules/@cchistory/domain/dist/agent-startup.d.ts.map +1 -0
  125. package/node_modules/@cchistory/domain/dist/agent-startup.js +8 -0
  126. package/node_modules/@cchistory/domain/dist/agent-startup.js.map +1 -0
  127. package/node_modules/@cchistory/domain/dist/index.d.ts +5 -0
  128. package/node_modules/@cchistory/domain/dist/index.d.ts.map +1 -1
  129. package/node_modules/@cchistory/domain/dist/index.js +3 -0
  130. package/node_modules/@cchistory/domain/dist/index.js.map +1 -1
  131. package/node_modules/@cchistory/domain/dist/index.test.js +18 -1
  132. package/node_modules/@cchistory/domain/dist/index.test.js.map +1 -1
  133. package/node_modules/@cchistory/domain/dist/project-git.d.ts +121 -0
  134. package/node_modules/@cchistory/domain/dist/project-git.d.ts.map +1 -0
  135. package/node_modules/@cchistory/domain/dist/project-git.js +93 -0
  136. package/node_modules/@cchistory/domain/dist/project-git.js.map +1 -0
  137. package/node_modules/@cchistory/domain/package.json +1 -1
  138. package/node_modules/@cchistory/live-runtime/dist/antigravity.test.js +15 -1
  139. package/node_modules/@cchistory/live-runtime/dist/antigravity.test.js.map +1 -1
  140. package/node_modules/@cchistory/live-runtime/dist/index.d.ts +3 -1
  141. package/node_modules/@cchistory/live-runtime/dist/index.d.ts.map +1 -1
  142. package/node_modules/@cchistory/live-runtime/dist/index.js +14 -8
  143. package/node_modules/@cchistory/live-runtime/dist/index.js.map +1 -1
  144. package/node_modules/@cchistory/live-runtime/dist/inventory-and-git.d.ts +35 -0
  145. package/node_modules/@cchistory/live-runtime/dist/inventory-and-git.d.ts.map +1 -0
  146. package/node_modules/@cchistory/live-runtime/dist/inventory-and-git.js +68 -0
  147. package/node_modules/@cchistory/live-runtime/dist/inventory-and-git.js.map +1 -0
  148. package/node_modules/@cchistory/live-runtime/package.json +1 -1
  149. package/node_modules/@cchistory/source-adapters/dist/core/git-project.d.ts +9 -0
  150. package/node_modules/@cchistory/source-adapters/dist/core/git-project.d.ts.map +1 -1
  151. package/node_modules/@cchistory/source-adapters/dist/core/git-project.js +130 -7
  152. package/node_modules/@cchistory/source-adapters/dist/core/git-project.js.map +1 -1
  153. package/node_modules/@cchistory/source-adapters/dist/index.d.ts +5 -0
  154. package/node_modules/@cchistory/source-adapters/dist/index.d.ts.map +1 -1
  155. package/node_modules/@cchistory/source-adapters/dist/index.js +5 -0
  156. package/node_modules/@cchistory/source-adapters/dist/index.js.map +1 -1
  157. package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts +2 -0
  158. package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts.map +1 -1
  159. package/node_modules/@cchistory/source-adapters/dist/index.test.js +2 -0
  160. package/node_modules/@cchistory/source-adapters/dist/index.test.js.map +1 -1
  161. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.d.ts +14 -0
  162. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.d.ts.map +1 -0
  163. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.js +397 -0
  164. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.js.map +1 -0
  165. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.test.d.ts +6 -0
  166. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.test.d.ts.map +1 -0
  167. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.test.js +106 -0
  168. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.test.js.map +1 -0
  169. package/node_modules/@cchistory/source-adapters/dist/inventory/config-io.d.ts +42 -0
  170. package/node_modules/@cchistory/source-adapters/dist/inventory/config-io.d.ts.map +1 -0
  171. package/node_modules/@cchistory/source-adapters/dist/inventory/config-io.js +368 -0
  172. package/node_modules/@cchistory/source-adapters/dist/inventory/config-io.js.map +1 -0
  173. package/node_modules/@cchistory/source-adapters/dist/inventory/redaction.d.ts +22 -0
  174. package/node_modules/@cchistory/source-adapters/dist/inventory/redaction.d.ts.map +1 -0
  175. package/node_modules/@cchistory/source-adapters/dist/inventory/redaction.js +195 -0
  176. package/node_modules/@cchistory/source-adapters/dist/inventory/redaction.js.map +1 -0
  177. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity-helpers.d.ts +23 -0
  178. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity-helpers.d.ts.map +1 -0
  179. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity-helpers.js +147 -0
  180. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity-helpers.js.map +1 -0
  181. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity.d.ts +11 -0
  182. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity.d.ts.map +1 -0
  183. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity.js +339 -0
  184. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity.js.map +1 -0
  185. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code-helpers.d.ts +70 -0
  186. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code-helpers.d.ts.map +1 -0
  187. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code-helpers.js +257 -0
  188. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code-helpers.js.map +1 -0
  189. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code.d.ts +11 -0
  190. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code.d.ts.map +1 -0
  191. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code.js +321 -0
  192. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code.js.map +1 -0
  193. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/codex.d.ts +12 -0
  194. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/codex.d.ts.map +1 -0
  195. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/codex.js +363 -0
  196. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/codex.js.map +1 -0
  197. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/deepseek-harness.d.ts +20 -0
  198. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/deepseek-harness.d.ts.map +1 -0
  199. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/deepseek-harness.js +408 -0
  200. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/deepseek-harness.js.map +1 -0
  201. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/index.d.ts +24 -0
  202. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/index.d.ts.map +1 -0
  203. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/index.js +225 -0
  204. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/index.js.map +1 -0
  205. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/opencode.d.ts +12 -0
  206. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/opencode.d.ts.map +1 -0
  207. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/opencode.js +372 -0
  208. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/opencode.js.map +1 -0
  209. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/shared.d.ts +62 -0
  210. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/shared.d.ts.map +1 -0
  211. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/shared.js +428 -0
  212. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/shared.js.map +1 -0
  213. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/startup.test.d.ts +7 -0
  214. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/startup.test.d.ts.map +1 -0
  215. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/startup.test.js +399 -0
  216. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/startup.test.js.map +1 -0
  217. package/node_modules/@cchistory/source-adapters/dist/inventory/toml.d.ts +16 -0
  218. package/node_modules/@cchistory/source-adapters/dist/inventory/toml.d.ts.map +1 -0
  219. package/node_modules/@cchistory/source-adapters/dist/inventory/toml.js +478 -0
  220. package/node_modules/@cchistory/source-adapters/dist/inventory/toml.js.map +1 -0
  221. package/node_modules/@cchistory/source-adapters/package.json +1 -1
  222. package/package.json +5 -5
  223. package/schemas/cchistory-lite-agent-v1.schema.json +3 -1
  224. package/schemas/cchistory-lite-envelope-v1.schema.json +33 -0
  225. package/schemas/cchistory-lite-inventory-v1.schema.json +94 -0
  226. package/schemas/cchistory-lite-merged-projects-v1.schema.json +44 -0
  227. package/schemas/cchistory-lite-v2.schema.json +22 -1
  228. package/skills/using-cchistory-lite/SKILL.md +17 -0
@@ -1434,7 +1434,7 @@ test("Lite CLI agent prints the machine-readable contract without scanning", asy
1434
1434
  assert.equal(contract.kind, "agent_contract");
1435
1435
  assert.equal(contract.cli.name, "cchistory-lite");
1436
1436
  assert.match(contract.cli.version, /^\d+\.\d+\.\d+/u);
1437
- const commandNames = ["sources", "ls", "latest", "sample", "tree", "search", "show", "stats", "trace", "query", "shell", "export", "tui", "help", "agent"];
1437
+ const commandNames = ["sources", "ls", "latest", "sample", "tree", "search", "show", "stats", "trace", "inventory", "merge-projects", "query", "shell", "export", "tui", "help", "agent"];
1438
1438
  assert.deepEqual(Object.keys(contract.commands).sort(), [...commandNames].sort());
1439
1439
  for (const name of commandNames) {
1440
1440
  const command = contract.commands[name];
@@ -1543,107 +1543,126 @@ test("Lite CLI agent contract flags match the parser in both directions", async
1543
1543
  "--model", "--from", "--to", "--since", "--tz", "--week-mode", "--sort",
1544
1544
  "--pricing", "--alias", "--multiplier", "--cache-read-multiplier", "--cache-write-multiplier",
1545
1545
  "--quota", "--export-pricing", "--explain-pricing",
1546
- "--format", "--out", "--dir", "--request", "--safe", "--json", "--all", "--no-dir",
1546
+ "--format", "--out", "--dir", "--home", "--agent", "--host-id", "--no-activity", "--envelope", "--with-git",
1547
+ "--request", "--safe", "--json", "--all", "--no-dir",
1547
1548
  "--help", "--version", "--sql", "--sql-file", "--params", "--complete", "--idle-timeout", "--diagnostics",
1548
1549
  ];
1549
1550
  assert.deepEqual([...universe].sort(), [...parserFlags].sort());
1550
- const tails = {
1551
- sources: [],
1552
- ls: ["sessions"],
1553
- latest: ["sessions", "1"],
1554
- sample: ["1"],
1555
- tree: ["projects"],
1556
- search: ["mock"],
1557
- show: ["session", session.id],
1558
- stats: [],
1559
- trace: [session.id],
1560
- query: ["--request", "-"],
1561
- shell: [],
1562
- export: ["--format", "jsonl", "--out", "-"],
1563
- tui: [],
1564
- help: [],
1565
- agent: [],
1566
- };
1567
- const flagArgs = (name) => {
1568
- switch (name) {
1569
- case "--source-root": return [name, `codex=${codexRoot}`];
1570
- case "--source": return [name, "codex"];
1571
- case "--limit-files": return [name, "4"];
1572
- case "--limit": return [name, "1"];
1573
- case "--offset": return [name, "0"];
1574
- case "--project": return [name, project.project_id];
1575
- case "--session": return [name, session.id];
1576
- case "--turn": return [name, snapshot.listResolvedTurns()[0].id];
1577
- case "--search": return [name, "mock"];
1578
- case "--content": return [name, "conversation"];
1579
- case "--group-by": return [name, "session"];
1580
- case "--by": return [name, "source"];
1581
- case "--model": return [name, "gpt"];
1582
- case "--from": return [name, "2026-01-01"];
1583
- case "--to": return [name, "2026-12-31"];
1584
- case "--since": return [name, "all"];
1585
- case "--tz": return [name, "UTC"];
1586
- case "--week-mode": return [name, "rolling_7d"];
1587
- case "--sort": return [name, "adjusted_cost"];
1588
- case "--pricing": return [name, path.join(repoRoot, "docs/guide/pricing.example.json")];
1589
- case "--alias": return [name, "gemini-pro=gemini-4-carbon"];
1590
- case "--multiplier": return [name, "gpt-5=1"];
1591
- case "--cache-read-multiplier": return [name, "gpt-5=1"];
1592
- case "--cache-write-multiplier": return [name, "gpt-5=1"];
1593
- case "--quota": return [name, "100"];
1594
- case "--export-pricing": return [name, "-"];
1595
- case "--format": return [name, "jsonl"];
1596
- case "--out": return [name, "-"];
1597
- case "--dir": return [name, repoRoot];
1598
- case "--request": return [name, "-"];
1599
- case "--sql": return [name, "SELECT id FROM sessions LIMIT 1"];
1600
- case "--sql-file": return [name, path.join(repoRoot, "docs/guide/queries/latest-turns.sql")];
1601
- case "--params": return [name, "[]"];
1602
- case "--idle-timeout": return [name, "0"];
1603
- default: return [name];
1604
- }
1605
- };
1606
- const run = async (argv) => {
1607
- const captured = captureIo(repoRoot, async () => 0, {
1608
- scan: async () => snapshot,
1609
- readStdin: async () => `${JSON.stringify({
1610
- schema: "cchistory-lite-query/v2",
1611
- operations: [{ id: "s", kind: "list", collection: "sessions", limit: 1 }],
1612
- })}\n`,
1613
- readLine: async () => null,
1614
- });
1615
- return runLiteCli(argv, captured.io);
1616
- };
1617
- for (const [name, command] of Object.entries(contract.commands)) {
1618
- const tail = tails[name];
1619
- if (name === "help") {
1620
- // help renders before option validation, so every known flag is accepted
1621
- // and ignored; the rejection direction does not apply to it.
1622
- for (const flag of universe) {
1623
- assert.equal(await run([name, ...tail, ...flagArgs(flag)]), 0, `help must accept ${flag}`);
1624
- }
1625
- assert.equal(await run([name, ...tail, "--json=canonical"]), 0, "help must accept --json=canonical");
1626
- continue;
1627
- }
1628
- const accepted = new Set([...globalFlags, ...command.flags.map((flag) => flag.name)]);
1629
- for (const flag of universe) {
1630
- let argv = tail.includes(flag) ? [name, ...tail] : [name, ...tail, ...flagArgs(flag)];
1631
- if (name === "query" && ["--sql", "--sql-file", "--params", "--complete"].includes(flag)) {
1632
- argv = [name, ...(["--sql", "--sql-file"].includes(flag) ? [] : ["--sql", "SELECT id FROM sessions LIMIT 1"]), ...flagArgs(flag)];
1551
+ const tempMergeDir = await mkdtemp(path.join(os.tmpdir(), "cchistory-contract-merge-"));
1552
+ const tempMergeFile = path.join(tempMergeDir, "host-a.json");
1553
+ await writeFile(tempMergeFile, JSON.stringify({ host_id: "host-a", projects: [] }), "utf8");
1554
+ const emptyHomeDir = path.join(tempMergeDir, "empty-home");
1555
+ await mkdir(emptyHomeDir, { recursive: true });
1556
+ try {
1557
+ const tails = {
1558
+ sources: [],
1559
+ ls: ["sessions"],
1560
+ latest: ["sessions", "1"],
1561
+ sample: ["1"],
1562
+ tree: ["projects"],
1563
+ search: ["mock"],
1564
+ show: ["session", session.id],
1565
+ stats: [],
1566
+ trace: [session.id],
1567
+ inventory: ["--home", emptyHomeDir],
1568
+ "merge-projects": [tempMergeFile],
1569
+ query: ["--request", "-"],
1570
+ shell: [],
1571
+ export: ["--format", "jsonl", "--out", "-"],
1572
+ tui: [],
1573
+ help: [],
1574
+ agent: [],
1575
+ };
1576
+ const flagArgs = (name) => {
1577
+ switch (name) {
1578
+ case "--source-root": return [name, `codex=${codexRoot}`];
1579
+ case "--source": return [name, "codex"];
1580
+ case "--limit-files": return [name, "4"];
1581
+ case "--limit": return [name, "1"];
1582
+ case "--offset": return [name, "0"];
1583
+ case "--project": return [name, project.project_id];
1584
+ case "--session": return [name, session.id];
1585
+ case "--turn": return [name, snapshot.listResolvedTurns()[0].id];
1586
+ case "--search": return [name, "mock"];
1587
+ case "--content": return [name, "conversation"];
1588
+ case "--group-by": return [name, "session"];
1589
+ case "--by": return [name, "source"];
1590
+ case "--model": return [name, "gpt"];
1591
+ case "--from": return [name, "2026-01-01"];
1592
+ case "--to": return [name, "2026-12-31"];
1593
+ case "--since": return [name, "all"];
1594
+ case "--tz": return [name, "UTC"];
1595
+ case "--week-mode": return [name, "rolling_7d"];
1596
+ case "--sort": return [name, "adjusted_cost"];
1597
+ case "--pricing": return [name, path.join(repoRoot, "docs/guide/pricing.example.json")];
1598
+ case "--alias": return [name, "gemini-pro=gemini-4-carbon"];
1599
+ case "--multiplier": return [name, "gpt-5=1"];
1600
+ case "--cache-read-multiplier": return [name, "gpt-5=1"];
1601
+ case "--cache-write-multiplier": return [name, "gpt-5=1"];
1602
+ case "--quota": return [name, "100"];
1603
+ case "--export-pricing": return [name, "-"];
1604
+ case "--format": return [name, "jsonl"];
1605
+ case "--out": return [name, "-"];
1606
+ case "--dir": return [name, repoRoot];
1607
+ case "--home": return [name, emptyHomeDir];
1608
+ case "--agent": return [name, "codex"];
1609
+ case "--host-id": return [name, "test-host"];
1610
+ case "--request": return [name, "-"];
1611
+ case "--sql": return [name, "SELECT id FROM sessions LIMIT 1"];
1612
+ case "--sql-file": return [name, path.join(repoRoot, "docs/guide/queries/latest-turns.sql")];
1613
+ case "--params": return [name, "[]"];
1614
+ case "--idle-timeout": return [name, "0"];
1615
+ default: return [name];
1633
1616
  }
1634
- if (name === "ls" && flag === "--complete")
1635
- argv = ["ls", "sources", "--complete"];
1636
- const code = await run(argv);
1637
- if (accepted.has(flag)) {
1638
- assert.equal(code, 0, `${name} must accept ${flag} (argv: ${argv.join(" ")})`);
1617
+ };
1618
+ const run = async (argv) => {
1619
+ const captured = captureIo(repoRoot, async () => 0, {
1620
+ scan: async () => snapshot,
1621
+ readStdin: async () => `${JSON.stringify({
1622
+ schema: "cchistory-lite-query/v2",
1623
+ operations: [{ id: "s", kind: "list", collection: "sessions", limit: 1 }],
1624
+ })}\n`,
1625
+ readLine: async () => null,
1626
+ });
1627
+ return runLiteCli(argv, captured.io);
1628
+ };
1629
+ for (const [name, command] of Object.entries(contract.commands)) {
1630
+ const tail = tails[name];
1631
+ if (name === "help") {
1632
+ // help renders before option validation, so every known flag is accepted
1633
+ // and ignored; the rejection direction does not apply to it.
1634
+ for (const flag of universe) {
1635
+ assert.equal(await run([name, ...tail, ...flagArgs(flag)]), 0, `help must accept ${flag}`);
1636
+ }
1637
+ assert.equal(await run([name, ...tail, "--json=canonical"]), 0, "help must accept --json=canonical");
1638
+ continue;
1639
1639
  }
1640
- else {
1641
- assert.equal(code, 2, `${name} must reject ${flag} (argv: ${argv.join(" ")})`);
1640
+ const accepted = new Set([...globalFlags, ...command.flags.map((flag) => flag.name)]);
1641
+ for (const flag of universe) {
1642
+ let argv = tail.includes(flag) ? [name, ...tail] : [name, ...tail, ...flagArgs(flag)];
1643
+ if (name === "query" && ["--sql", "--sql-file", "--params", "--complete"].includes(flag)) {
1644
+ argv = [name, ...(["--sql", "--sql-file"].includes(flag) ? [] : ["--sql", "SELECT id FROM sessions LIMIT 1"]), ...flagArgs(flag)];
1645
+ }
1646
+ if (name === "ls" && flag === "--complete")
1647
+ argv = ["ls", "sources", "--complete"];
1648
+ if (name === "ls" && ["--with-git", "--envelope", "--host-id"].includes(flag)) {
1649
+ argv = ["ls", "projects", ...flagArgs(flag)];
1650
+ }
1651
+ const code = await run(argv);
1652
+ if (accepted.has(flag)) {
1653
+ assert.equal(code, 0, `${name} must accept ${flag} (argv: ${argv.join(" ")})`);
1654
+ }
1655
+ else {
1656
+ assert.equal(code, 2, `${name} must reject ${flag} (argv: ${argv.join(" ")})`);
1657
+ }
1642
1658
  }
1659
+ const canonicalAccepted = command.flags.some((flag) => flag.name === "--json" && flag.values?.includes("canonical"));
1660
+ const canonicalArgv = [name, ...tail, "--json=canonical"];
1661
+ assert.equal(await run(canonicalArgv), canonicalAccepted ? 0 : 2, `${name} ${canonicalAccepted ? "must accept" : "must reject"} --json=canonical`);
1643
1662
  }
1644
- const canonicalAccepted = command.flags.some((flag) => flag.name === "--json" && flag.values?.includes("canonical"));
1645
- const canonicalArgv = [name, ...tail, "--json=canonical"];
1646
- assert.equal(await run(canonicalArgv), canonicalAccepted ? 0 : 2, `${name} ${canonicalAccepted ? "must accept" : "must reject"} --json=canonical`);
1663
+ }
1664
+ finally {
1665
+ await rm(tempMergeDir, { recursive: true, force: true });
1647
1666
  }
1648
1667
  });
1649
1668
  test("Lite CLI agent skill and guide print the shipped docs", async () => {