@herbertgao/pi-extensions 2026.8.8 → 2026.8.10

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 (266) hide show
  1. package/README.md +6 -3
  2. package/node_modules/@czottmann/pi-automode/CHANGELOG.md +24 -0
  3. package/node_modules/@czottmann/pi-automode/README.md +78 -112
  4. package/node_modules/@czottmann/pi-automode/docs/GLOSSARY.md +18 -14
  5. package/node_modules/@czottmann/pi-automode/docs/adr/ADR-001-permission-precedence-and-trust-boundaries.md +44 -0
  6. package/node_modules/@czottmann/pi-automode/docs/adr/INDEX.md +5 -0
  7. package/node_modules/@czottmann/pi-automode/docs/automode-classifier-flow.md +198 -104
  8. package/node_modules/@czottmann/pi-automode/docs/configuration.md +155 -0
  9. package/node_modules/@czottmann/pi-automode/docs/defaults.md +55 -14
  10. package/node_modules/@czottmann/pi-automode/docs/diagnostics.md +90 -0
  11. package/node_modules/@czottmann/pi-automode/docs/observability-logging.md +61 -26
  12. package/node_modules/@czottmann/pi-automode/examples/automode.local.json +5 -0
  13. package/node_modules/@czottmann/pi-automode/extensions/auto-mode/classifier.ts +172 -18
  14. package/node_modules/@czottmann/pi-automode/extensions/auto-mode/config.ts +127 -30
  15. package/node_modules/@czottmann/pi-automode/extensions/auto-mode/constants.ts +3 -0
  16. package/node_modules/@czottmann/pi-automode/extensions/auto-mode/extension.ts +273 -31
  17. package/node_modules/@czottmann/pi-automode/extensions/auto-mode/log.ts +60 -5
  18. package/node_modules/@czottmann/pi-automode/extensions/auto-mode/paths.ts +92 -8
  19. package/node_modules/@czottmann/pi-automode/extensions/auto-mode/permissions.ts +203 -13
  20. package/node_modules/@czottmann/pi-automode/extensions/auto-mode/state.ts +1 -0
  21. package/node_modules/@czottmann/pi-automode/extensions/auto-mode/types.ts +11 -0
  22. package/node_modules/@czottmann/pi-automode/extensions/auto-mode/utils.ts +9 -1
  23. package/node_modules/@czottmann/pi-automode/package.json +9 -2
  24. package/node_modules/@czottmann/pi-automode/skills/automode-diagnostics/SKILL.md +63 -0
  25. package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +3 -3
  26. package/node_modules/@herbertgao/pi-cc-extensions/README.md +3 -3
  27. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +8 -3
  28. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/context.ts +56 -29
  29. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/message-display.ts +1 -1
  30. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/interaction.ts +15 -13
  31. package/node_modules/@herbertgao/pi-cc-extensions/package.json +3 -3
  32. package/node_modules/@herbertgao/pi-handoff/CHANGELOG.md +29 -0
  33. package/node_modules/@herbertgao/pi-handoff/README.md +15 -18
  34. package/node_modules/@herbertgao/pi-handoff/package.json +11 -4
  35. package/node_modules/@herbertgao/pi-handoff/src/complete-text.ts +33 -0
  36. package/node_modules/@herbertgao/pi-handoff/src/index.ts +127 -232
  37. package/node_modules/@herbertgao/pi-handoff/src/session-query.ts +15 -30
  38. package/node_modules/@herbertgao/pi-mermaid-open/CHANGELOG.md +14 -0
  39. package/node_modules/@herbertgao/pi-mermaid-open/README.md +21 -4
  40. package/node_modules/@herbertgao/pi-mermaid-open/herdr-plugin/herdr-plugin.toml +11 -0
  41. package/node_modules/@herbertgao/pi-mermaid-open/herdr-plugin/viewer.mjs +305 -0
  42. package/node_modules/@herbertgao/pi-mermaid-open/package.json +15 -4
  43. package/node_modules/@herbertgao/pi-mermaid-open/src/index.ts +351 -101
  44. package/node_modules/@herbertgao/pi-preferred-thinking/CHANGELOG.md +12 -0
  45. package/node_modules/@herbertgao/pi-preferred-thinking/README.md +30 -14
  46. package/node_modules/@herbertgao/pi-preferred-thinking/package.json +7 -4
  47. package/node_modules/@herbertgao/pi-preferred-thinking/src/index.ts +140 -85
  48. package/node_modules/@herbertgao/pi-recap/CHANGELOG.md +12 -0
  49. package/node_modules/@herbertgao/pi-recap/README.md +5 -3
  50. package/node_modules/@herbertgao/pi-recap/package.json +9 -3
  51. package/node_modules/@herbertgao/pi-recap/src/index.ts +3 -7
  52. package/node_modules/@herbertgao/pi-recap/src/model-picker.ts +6 -19
  53. package/node_modules/@herbertgao/pi-recap/src/models.ts +9 -21
  54. package/node_modules/@herbertgao/pi-recap/src/tui.ts +1 -1
  55. package/node_modules/@herbertgao/pi-rename/CHANGELOG.md +49 -0
  56. package/node_modules/@herbertgao/pi-rename/README.md +13 -11
  57. package/node_modules/@herbertgao/pi-rename/package.json +13 -3
  58. package/node_modules/@herbertgao/pi-rename/src/index.ts +135 -59
  59. package/node_modules/@herbertgao/pi-rename/src/models.ts +5 -13
  60. package/node_modules/@herbertgao/pi-rename/src/naming.ts +2 -6
  61. package/node_modules/@herbertgao/pi-stash/package.json +3 -3
  62. package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +8 -0
  63. package/node_modules/@herbertgao/pi-subagents/README.md +16 -3
  64. package/node_modules/@herbertgao/pi-subagents/package.json +1 -1
  65. package/node_modules/@herbertgao/pi-subagents/src/cross-extension-rpc.ts +15 -4
  66. package/node_modules/@herbertgao/pi-subagents/src/index.ts +16 -0
  67. package/node_modules/@herbertgao/pi-subagents/src/ui/conversation-viewer.ts +5 -1
  68. package/node_modules/pi-web-access/CHANGELOG.md +13 -0
  69. package/node_modules/pi-web-access/README.md +2 -2
  70. package/node_modules/pi-web-access/chrome-cookies.ts +12 -7
  71. package/node_modules/pi-web-access/gemini-search.ts +28 -10
  72. package/node_modules/pi-web-access/index.ts +24 -10
  73. package/node_modules/pi-web-access/package.json +1 -1
  74. package/node_modules/resume-from/LICENSE +21 -0
  75. package/node_modules/resume-from/README.md +161 -0
  76. package/node_modules/resume-from/dist/adapters/claude-code/adapter.d.ts +25 -0
  77. package/node_modules/resume-from/dist/adapters/claude-code/adapter.js +60 -0
  78. package/node_modules/resume-from/dist/adapters/claude-code/contract.d.ts +8 -0
  79. package/node_modules/resume-from/dist/adapters/claude-code/contract.js +4 -0
  80. package/node_modules/resume-from/dist/adapters/claude-code/entries.d.ts +30 -0
  81. package/node_modules/resume-from/dist/adapters/claude-code/entries.js +107 -0
  82. package/node_modules/resume-from/dist/adapters/claude-code/index.d.ts +3 -0
  83. package/node_modules/resume-from/dist/adapters/claude-code/index.js +2 -0
  84. package/node_modules/resume-from/dist/adapters/claude-code/layout.d.ts +29 -0
  85. package/node_modules/resume-from/dist/adapters/claude-code/layout.js +80 -0
  86. package/node_modules/resume-from/dist/adapters/claude-code/readback.d.ts +9 -0
  87. package/node_modules/resume-from/dist/adapters/claude-code/readback.js +39 -0
  88. package/node_modules/resume-from/dist/adapters/claude-code/reader.d.ts +37 -0
  89. package/node_modules/resume-from/dist/adapters/claude-code/reader.js +415 -0
  90. package/node_modules/resume-from/dist/adapters/claude-code/redaction.d.ts +26 -0
  91. package/node_modules/resume-from/dist/adapters/claude-code/redaction.js +132 -0
  92. package/node_modules/resume-from/dist/adapters/claude-code/validation.d.ts +4 -0
  93. package/node_modules/resume-from/dist/adapters/claude-code/validation.js +39 -0
  94. package/node_modules/resume-from/dist/adapters/claude-code/writer.d.ts +23 -0
  95. package/node_modules/resume-from/dist/adapters/claude-code/writer.js +306 -0
  96. package/node_modules/resume-from/dist/adapters/codex/contract.d.ts +15 -0
  97. package/node_modules/resume-from/dist/adapters/codex/contract.js +4 -0
  98. package/node_modules/resume-from/dist/adapters/codex/index.d.ts +6 -0
  99. package/node_modules/resume-from/dist/adapters/codex/index.js +44 -0
  100. package/node_modules/resume-from/dist/adapters/codex/read.d.ts +28 -0
  101. package/node_modules/resume-from/dist/adapters/codex/read.js +270 -0
  102. package/node_modules/resume-from/dist/adapters/codex/readback.d.ts +9 -0
  103. package/node_modules/resume-from/dist/adapters/codex/readback.js +47 -0
  104. package/node_modules/resume-from/dist/adapters/codex/redaction.d.ts +26 -0
  105. package/node_modules/resume-from/dist/adapters/codex/redaction.js +132 -0
  106. package/node_modules/resume-from/dist/adapters/codex/rollout.d.ts +75 -0
  107. package/node_modules/resume-from/dist/adapters/codex/rollout.js +185 -0
  108. package/node_modules/resume-from/dist/adapters/codex/validation.d.ts +7 -0
  109. package/node_modules/resume-from/dist/adapters/codex/validation.js +78 -0
  110. package/node_modules/resume-from/dist/adapters/codex/write.d.ts +17 -0
  111. package/node_modules/resume-from/dist/adapters/codex/write.js +141 -0
  112. package/node_modules/resume-from/dist/adapters/contract.d.ts +74 -0
  113. package/node_modules/resume-from/dist/adapters/contract.js +4 -0
  114. package/node_modules/resume-from/dist/adapters/pi/adapter.d.ts +15 -0
  115. package/node_modules/resume-from/dist/adapters/pi/adapter.js +209 -0
  116. package/node_modules/resume-from/dist/adapters/pi/contract.d.ts +24 -0
  117. package/node_modules/resume-from/dist/adapters/pi/contract.js +4 -0
  118. package/node_modules/resume-from/dist/adapters/pi/format.d.ts +162 -0
  119. package/node_modules/resume-from/dist/adapters/pi/format.js +223 -0
  120. package/node_modules/resume-from/dist/adapters/pi/index.d.ts +7 -0
  121. package/node_modules/resume-from/dist/adapters/pi/index.js +10 -0
  122. package/node_modules/resume-from/dist/adapters/pi/parse.d.ts +41 -0
  123. package/node_modules/resume-from/dist/adapters/pi/parse.js +371 -0
  124. package/node_modules/resume-from/dist/adapters/pi/redaction.d.ts +26 -0
  125. package/node_modules/resume-from/dist/adapters/pi/redaction.js +132 -0
  126. package/node_modules/resume-from/dist/adapters/pi/serialize.d.ts +22 -0
  127. package/node_modules/resume-from/dist/adapters/pi/serialize.js +87 -0
  128. package/node_modules/resume-from/dist/adapters/pi/validate.d.ts +14 -0
  129. package/node_modules/resume-from/dist/adapters/pi/validate.js +134 -0
  130. package/node_modules/resume-from/dist/bin.d.ts +35 -0
  131. package/node_modules/resume-from/dist/bin.js +135 -0
  132. package/node_modules/resume-from/dist/contract.d.ts +10 -0
  133. package/node_modules/resume-from/dist/contract.js +4 -0
  134. package/node_modules/resume-from/dist/host/agents.d.ts +29 -0
  135. package/node_modules/resume-from/dist/host/agents.js +20 -0
  136. package/node_modules/resume-from/dist/host/cli/args.d.ts +21 -0
  137. package/node_modules/resume-from/dist/host/cli/args.js +187 -0
  138. package/node_modules/resume-from/dist/host/cli/contract.d.ts +27 -0
  139. package/node_modules/resume-from/dist/host/cli/contract.js +4 -0
  140. package/node_modules/resume-from/dist/host/cli/index.d.ts +2 -0
  141. package/node_modules/resume-from/dist/host/cli/index.js +1 -0
  142. package/node_modules/resume-from/dist/host/cli/presentation.d.ts +2 -0
  143. package/node_modules/resume-from/dist/host/cli/presentation.js +11 -0
  144. package/node_modules/resume-from/dist/host/cli/render.d.ts +3 -0
  145. package/node_modules/resume-from/dist/host/cli/render.js +70 -0
  146. package/node_modules/resume-from/dist/host/cli/runner.d.ts +8 -0
  147. package/node_modules/resume-from/dist/host/cli/runner.js +125 -0
  148. package/node_modules/resume-from/dist/host/contract.d.ts +42 -0
  149. package/node_modules/resume-from/dist/host/contract.js +4 -0
  150. package/node_modules/resume-from/dist/host/entry.d.ts +52 -0
  151. package/node_modules/resume-from/dist/host/entry.js +91 -0
  152. package/node_modules/resume-from/dist/host/index.d.ts +11 -0
  153. package/node_modules/resume-from/dist/host/index.js +10 -0
  154. package/node_modules/resume-from/dist/host/pi-extension/command.d.ts +18 -0
  155. package/node_modules/resume-from/dist/host/pi-extension/command.js +103 -0
  156. package/node_modules/resume-from/dist/host/pi-extension/contract.d.ts +34 -0
  157. package/node_modules/resume-from/dist/host/pi-extension/contract.js +4 -0
  158. package/node_modules/resume-from/dist/host/pi-extension/index.d.ts +6 -0
  159. package/node_modules/resume-from/dist/host/pi-extension/index.js +4 -0
  160. package/node_modules/resume-from/dist/host/pi-extension/picker.d.ts +16 -0
  161. package/node_modules/resume-from/dist/host/pi-extension/picker.js +35 -0
  162. package/node_modules/resume-from/dist/host/pi-extension/presentation.d.ts +2 -0
  163. package/node_modules/resume-from/dist/host/pi-extension/presentation.js +11 -0
  164. package/node_modules/resume-from/dist/host/pi-extension/register.d.ts +25 -0
  165. package/node_modules/resume-from/dist/host/pi-extension/register.js +11 -0
  166. package/node_modules/resume-from/dist/host/pi-extension/ui.d.ts +20 -0
  167. package/node_modules/resume-from/dist/host/pi-extension/ui.js +1 -0
  168. package/node_modules/resume-from/dist/host/profile.d.ts +8 -0
  169. package/node_modules/resume-from/dist/host/profile.js +31 -0
  170. package/node_modules/resume-from/dist/host/registry.d.ts +8 -0
  171. package/node_modules/resume-from/dist/host/registry.js +33 -0
  172. package/node_modules/resume-from/dist/host/wiring.d.ts +41 -0
  173. package/node_modules/resume-from/dist/host/wiring.js +67 -0
  174. package/node_modules/resume-from/dist/import/confirmation.d.ts +6 -0
  175. package/node_modules/resume-from/dist/import/confirmation.js +27 -0
  176. package/node_modules/resume-from/dist/import/contract.d.ts +41 -0
  177. package/node_modules/resume-from/dist/import/contract.js +4 -0
  178. package/node_modules/resume-from/dist/import/discovery/contract.d.ts +58 -0
  179. package/node_modules/resume-from/dist/import/discovery/contract.js +4 -0
  180. package/node_modules/resume-from/dist/import/discovery/errors.d.ts +9 -0
  181. package/node_modules/resume-from/dist/import/discovery/errors.js +12 -0
  182. package/node_modules/resume-from/dist/import/discovery/finder.d.ts +10 -0
  183. package/node_modules/resume-from/dist/import/discovery/finder.js +129 -0
  184. package/node_modules/resume-from/dist/import/discovery/homes.d.ts +23 -0
  185. package/node_modules/resume-from/dist/import/discovery/homes.js +83 -0
  186. package/node_modules/resume-from/dist/import/discovery/index.d.ts +2 -0
  187. package/node_modules/resume-from/dist/import/discovery/index.js +2 -0
  188. package/node_modules/resume-from/dist/import/discovery/ordering.d.ts +3 -0
  189. package/node_modules/resume-from/dist/import/discovery/ordering.js +21 -0
  190. package/node_modules/resume-from/dist/import/errors.d.ts +22 -0
  191. package/node_modules/resume-from/dist/import/errors.js +20 -0
  192. package/node_modules/resume-from/dist/import/index.d.ts +3 -0
  193. package/node_modules/resume-from/dist/import/index.js +5 -0
  194. package/node_modules/resume-from/dist/import/landing/contract.d.ts +44 -0
  195. package/node_modules/resume-from/dist/import/landing/contract.js +4 -0
  196. package/node_modules/resume-from/dist/import/landing/errors.d.ts +15 -0
  197. package/node_modules/resume-from/dist/import/landing/errors.js +15 -0
  198. package/node_modules/resume-from/dist/import/landing/handover.d.ts +5 -0
  199. package/node_modules/resume-from/dist/import/landing/handover.js +12 -0
  200. package/node_modules/resume-from/dist/import/landing/index.d.ts +4 -0
  201. package/node_modules/resume-from/dist/import/landing/index.js +4 -0
  202. package/node_modules/resume-from/dist/import/landing/lander.d.ts +7 -0
  203. package/node_modules/resume-from/dist/import/landing/lander.js +133 -0
  204. package/node_modules/resume-from/dist/import/landing/marker.d.ts +9 -0
  205. package/node_modules/resume-from/dist/import/landing/marker.js +46 -0
  206. package/node_modules/resume-from/dist/import/pipeline.d.ts +17 -0
  207. package/node_modules/resume-from/dist/import/pipeline.js +134 -0
  208. package/node_modules/resume-from/dist/import/preview/builder.d.ts +6 -0
  209. package/node_modules/resume-from/dist/import/preview/builder.js +76 -0
  210. package/node_modules/resume-from/dist/import/preview/contract.d.ts +39 -0
  211. package/node_modules/resume-from/dist/import/preview/contract.js +4 -0
  212. package/node_modules/resume-from/dist/import/preview/format.d.ts +19 -0
  213. package/node_modules/resume-from/dist/import/preview/format.js +45 -0
  214. package/node_modules/resume-from/dist/import/preview/index.d.ts +2 -0
  215. package/node_modules/resume-from/dist/import/preview/index.js +1 -0
  216. package/node_modules/resume-from/dist/import/preview/warnings.d.ts +11 -0
  217. package/node_modules/resume-from/dist/import/preview/warnings.js +80 -0
  218. package/node_modules/resume-from/dist/import/transfer/contract.d.ts +48 -0
  219. package/node_modules/resume-from/dist/import/transfer/contract.js +4 -0
  220. package/node_modules/resume-from/dist/import/transfer/index.d.ts +2 -0
  221. package/node_modules/resume-from/dist/import/transfer/index.js +1 -0
  222. package/node_modules/resume-from/dist/import/transfer/rules.d.ts +3 -0
  223. package/node_modules/resume-from/dist/import/transfer/rules.js +228 -0
  224. package/node_modules/resume-from/dist/import/wiring.d.ts +24 -0
  225. package/node_modules/resume-from/dist/import/wiring.js +27 -0
  226. package/node_modules/resume-from/dist/index.d.ts +36 -0
  227. package/node_modules/resume-from/dist/index.js +36 -0
  228. package/node_modules/resume-from/dist/platform/config/contract.d.ts +35 -0
  229. package/node_modules/resume-from/dist/platform/config/contract.js +4 -0
  230. package/node_modules/resume-from/dist/platform/config/defaults.d.ts +16 -0
  231. package/node_modules/resume-from/dist/platform/config/defaults.js +22 -0
  232. package/node_modules/resume-from/dist/platform/config/errors.d.ts +9 -0
  233. package/node_modules/resume-from/dist/platform/config/errors.js +12 -0
  234. package/node_modules/resume-from/dist/platform/config/index.d.ts +5 -0
  235. package/node_modules/resume-from/dist/platform/config/index.js +6 -0
  236. package/node_modules/resume-from/dist/platform/config/loader.d.ts +10 -0
  237. package/node_modules/resume-from/dist/platform/config/loader.js +47 -0
  238. package/node_modules/resume-from/dist/platform/config/paths.d.ts +13 -0
  239. package/node_modules/resume-from/dist/platform/config/paths.js +37 -0
  240. package/node_modules/resume-from/dist/platform/config/validate.d.ts +9 -0
  241. package/node_modules/resume-from/dist/platform/config/validate.js +117 -0
  242. package/node_modules/resume-from/dist/platform/repo/contract.d.ts +30 -0
  243. package/node_modules/resume-from/dist/platform/repo/contract.js +4 -0
  244. package/node_modules/resume-from/dist/platform/repo/git.d.ts +21 -0
  245. package/node_modules/resume-from/dist/platform/repo/git.js +74 -0
  246. package/node_modules/resume-from/dist/platform/repo/index.d.ts +2 -0
  247. package/node_modules/resume-from/dist/platform/repo/index.js +1 -0
  248. package/node_modules/resume-from/dist/platform/repo/reader.d.ts +8 -0
  249. package/node_modules/resume-from/dist/platform/repo/reader.js +130 -0
  250. package/node_modules/resume-from/dist/platform/store/contract.d.ts +31 -0
  251. package/node_modules/resume-from/dist/platform/store/contract.js +4 -0
  252. package/node_modules/resume-from/dist/platform/store/file-committer.d.ts +3 -0
  253. package/node_modules/resume-from/dist/platform/store/file-committer.js +391 -0
  254. package/node_modules/resume-from/dist/platform/store/index.d.ts +2 -0
  255. package/node_modules/resume-from/dist/platform/store/index.js +2 -0
  256. package/node_modules/resume-from/dist/platform/tokens/contract.d.ts +12 -0
  257. package/node_modules/resume-from/dist/platform/tokens/contract.js +4 -0
  258. package/node_modules/resume-from/dist/platform/tokens/estimator.d.ts +12 -0
  259. package/node_modules/resume-from/dist/platform/tokens/estimator.js +111 -0
  260. package/node_modules/resume-from/dist/platform/tokens/index.d.ts +2 -0
  261. package/node_modules/resume-from/dist/platform/tokens/index.js +1 -0
  262. package/node_modules/resume-from/dist/session/contract.d.ts +109 -0
  263. package/node_modules/resume-from/dist/session/contract.js +4 -0
  264. package/node_modules/resume-from/package.json +80 -0
  265. package/node_modules/resume-from/shims/pi/extensions/resume-from.js +118 -0
  266. package/package.json +19 -14
@@ -0,0 +1,107 @@
1
+ /**
2
+ * The Claude Code session file: one JSON object per line.
3
+ *
4
+ * The store holds ten entry types (C-3). This module reads the few that carry turns and writes
5
+ * exactly two, `user` and `assistant` (C-9) — fewer types, fewer ways to corrupt the store.
6
+ */
7
+ export const ENTRY_TYPE_USER = "user";
8
+ export const ENTRY_TYPE_ASSISTANT = "assistant";
9
+ export const ENTRY_TYPE_SUMMARY = "summary";
10
+ /** The only entry types `serialize` writes (C-9). */
11
+ export const WRITTEN_ENTRY_TYPES = [ENTRY_TYPE_USER, ENTRY_TYPE_ASSISTANT];
12
+ /** Parse a session file. A line that is not a complete entry makes the whole file unreadable. */
13
+ export function parseJsonl(text) {
14
+ const entries = [];
15
+ const lines = text.split("\n");
16
+ for (let i = 0; i < lines.length; i++) {
17
+ const line = lines[i] ?? "";
18
+ if (line.trim() === "")
19
+ continue;
20
+ let value;
21
+ try {
22
+ value = JSON.parse(line);
23
+ }
24
+ catch {
25
+ return { entries, unreadable: `line ${i + 1} is not a complete entry` };
26
+ }
27
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
28
+ return { entries, unreadable: `line ${i + 1} is not an entry object` };
29
+ }
30
+ entries.push(value);
31
+ }
32
+ return { entries, unreadable: null };
33
+ }
34
+ /** Follow the last non-sidechain UUID record to the root of Claude's active transcript. */
35
+ export function resolveActiveEntryPath(entries) {
36
+ const byUuid = new Map();
37
+ const mainEntries = [];
38
+ for (const entry of entries) {
39
+ if (entry.isSidechain === true || entry.uuid === undefined)
40
+ continue;
41
+ const uuid = asString(entry.uuid);
42
+ if (uuid === null)
43
+ return { entries: [], unreadable: "entry has a malformed uuid" };
44
+ if (byUuid.has(uuid)) {
45
+ return { entries: [], unreadable: `duplicate entry uuid ${uuid}` };
46
+ }
47
+ if (entry.parentUuid !== null && typeof entry.parentUuid !== "string") {
48
+ return {
49
+ entries: [],
50
+ unreadable: `entry ${uuid} has a malformed parentUuid`,
51
+ };
52
+ }
53
+ byUuid.set(uuid, entry);
54
+ mainEntries.push(entry);
55
+ }
56
+ const leaf = mainEntries[mainEntries.length - 1];
57
+ if (leaf === undefined)
58
+ return { entries: [], unreadable: null };
59
+ const reversed = [];
60
+ const visited = new Set();
61
+ let current = leaf;
62
+ while (current !== undefined) {
63
+ const uuid = asString(current.uuid);
64
+ if (uuid === null)
65
+ return { entries: [], unreadable: "active entry has no uuid" };
66
+ if (visited.has(uuid)) {
67
+ return {
68
+ entries: [],
69
+ unreadable: `entry graph contains a cycle at ${uuid}`,
70
+ };
71
+ }
72
+ visited.add(uuid);
73
+ reversed.push(current);
74
+ if (current.parentUuid === null)
75
+ break;
76
+ const parent = byUuid.get(current.parentUuid);
77
+ if (parent === undefined) {
78
+ return {
79
+ entries: [],
80
+ unreadable: `entry ${uuid} refers to missing parent ${String(current.parentUuid)}`,
81
+ };
82
+ }
83
+ current = parent;
84
+ }
85
+ return { entries: reversed.reverse(), unreadable: null };
86
+ }
87
+ export function asString(value) {
88
+ return typeof value === "string" && value !== "" ? value : null;
89
+ }
90
+ export function asObject(value) {
91
+ if (typeof value !== "object" || value === null || Array.isArray(value))
92
+ return null;
93
+ return value;
94
+ }
95
+ export function asArray(value) {
96
+ return Array.isArray(value) ? value : null;
97
+ }
98
+ /** ISO-8601 UTC, the vocabulary every timestamp of the canonical model uses. */
99
+ export function toIsoUtc(value) {
100
+ const text = asString(value);
101
+ if (text === null)
102
+ return null;
103
+ const parsed = Date.parse(text);
104
+ if (!Number.isFinite(parsed))
105
+ return null;
106
+ return new Date(parsed).toISOString();
107
+ }
@@ -0,0 +1,3 @@
1
+ /** The Claude Code adapter. Building it is the only thing this module offers (FR-57). */
2
+ export { claudeCodeAdapter } from "./adapter.js";
3
+ export type { ClaudeCodeAdapterFactory } from "./contract.js";
@@ -0,0 +1,2 @@
1
+ /** The Claude Code adapter. Building it is the only thing this module offers (FR-57). */
2
+ export { claudeCodeAdapter } from "./adapter.js";
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Where Claude Code keeps its sessions inside a home.
3
+ *
4
+ * A home holds `projects/<encoded repository path>/<session id>.jsonl`. The encoding and the
5
+ * default home are facts about the installed version, not assumptions: the live boundary test
6
+ * T-CC-16 lands a real session and compares it with what this file computes.
7
+ */
8
+ import type { HomePath, SessionId } from "./contract.js";
9
+ /** Session files live one directory per repository, under this directory of the home. */
10
+ export declare const PROJECTS_DIR = "projects";
11
+ export declare const SESSION_FILE_SUFFIX = ".jsonl";
12
+ /** Claude Code reads this before falling back to ~/.claude. It is how `~/.claude-team` is named. */
13
+ export declare const CONFIG_DIR_ENV = "CLAUDE_CONFIG_DIR";
14
+ export declare const DEFAULT_HOME_BASENAME = ".claude";
15
+ /** The home used when the user names none (FR-3). Absolute, resolved. */
16
+ export declare function resolveDefaultHome(env?: Record<string, string | undefined>, userHome?: string): HomePath;
17
+ /**
18
+ * The project directory name of a repository: the absolute path with every character that is
19
+ * not a letter or a digit replaced by a dash.
20
+ */
21
+ export declare function encodeProjectPath(repoPath: string): string;
22
+ export declare function projectsDir(home: HomePath): string;
23
+ export declare function projectDir(home: HomePath, repoPath: string): string;
24
+ export declare function sessionFilePath(home: HomePath, repoPath: string, id: SessionId): string;
25
+ export declare function sessionIdOf(filePath: string): SessionId;
26
+ /** Every session file of a home, across all of its project directories. */
27
+ export declare function listSessionFiles(home: HomePath): Promise<string[]>;
28
+ /** The file of one session id, or null when the home does not hold it. */
29
+ export declare function findSessionFile(home: HomePath, id: SessionId): Promise<string | null>;
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Where Claude Code keeps its sessions inside a home.
3
+ *
4
+ * A home holds `projects/<encoded repository path>/<session id>.jsonl`. The encoding and the
5
+ * default home are facts about the installed version, not assumptions: the live boundary test
6
+ * T-CC-16 lands a real session and compares it with what this file computes.
7
+ */
8
+ import { readdir } from "node:fs/promises";
9
+ import { homedir } from "node:os";
10
+ import path from "node:path";
11
+ /** Session files live one directory per repository, under this directory of the home. */
12
+ export const PROJECTS_DIR = "projects";
13
+ export const SESSION_FILE_SUFFIX = ".jsonl";
14
+ /** Claude Code reads this before falling back to ~/.claude. It is how `~/.claude-team` is named. */
15
+ export const CONFIG_DIR_ENV = "CLAUDE_CONFIG_DIR";
16
+ export const DEFAULT_HOME_BASENAME = ".claude";
17
+ /** The home used when the user names none (FR-3). Absolute, resolved. */
18
+ export function resolveDefaultHome(env = process.env, userHome = homedir()) {
19
+ const configured = env[CONFIG_DIR_ENV];
20
+ if (configured !== undefined && configured !== "" && path.isAbsolute(configured)) {
21
+ return path.resolve(configured);
22
+ }
23
+ return path.join(path.resolve(userHome), DEFAULT_HOME_BASENAME);
24
+ }
25
+ /**
26
+ * The project directory name of a repository: the absolute path with every character that is
27
+ * not a letter or a digit replaced by a dash.
28
+ */
29
+ export function encodeProjectPath(repoPath) {
30
+ return path.resolve(repoPath).replace(/[^a-zA-Z0-9]/g, "-");
31
+ }
32
+ export function projectsDir(home) {
33
+ return path.join(home, PROJECTS_DIR);
34
+ }
35
+ export function projectDir(home, repoPath) {
36
+ return path.join(projectsDir(home), encodeProjectPath(repoPath));
37
+ }
38
+ export function sessionFilePath(home, repoPath, id) {
39
+ return path.join(projectDir(home, repoPath), `${id}${SESSION_FILE_SUFFIX}`);
40
+ }
41
+ export function sessionIdOf(filePath) {
42
+ return path.basename(filePath, SESSION_FILE_SUFFIX);
43
+ }
44
+ /** Every session file of a home, across all of its project directories. */
45
+ export async function listSessionFiles(home) {
46
+ const root = projectsDir(home);
47
+ let projects;
48
+ try {
49
+ projects = (await readdir(root, { withFileTypes: true }))
50
+ .filter((item) => item.isDirectory())
51
+ .map((item) => item.name);
52
+ }
53
+ catch {
54
+ return [];
55
+ }
56
+ const files = [];
57
+ for (const project of projects) {
58
+ const dir = path.join(root, project);
59
+ try {
60
+ for (const item of await readdir(dir, { withFileTypes: true })) {
61
+ if (item.isFile() && item.name.endsWith(SESSION_FILE_SUFFIX)) {
62
+ files.push(path.join(dir, item.name));
63
+ }
64
+ }
65
+ }
66
+ catch {
67
+ // A project directory that cannot be read holds no session this tool can offer.
68
+ }
69
+ }
70
+ return files;
71
+ }
72
+ /** The file of one session id, or null when the home does not hold it. */
73
+ export async function findSessionFile(home, id) {
74
+ const wanted = `${id}${SESSION_FILE_SUFFIX}`;
75
+ for (const file of await listSessionFiles(home)) {
76
+ if (path.basename(file) === wanted)
77
+ return file;
78
+ }
79
+ return null;
80
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Reading a committed session back.
3
+ *
4
+ * C-9's own caution is why this is not optional: a throwaway directory holding one session does
5
+ * not prove a real store is safe, so the import compares what it wrote with what the store holds
6
+ * (FR-52) and whether the native resume list can open it (FR-51).
7
+ */
8
+ import type { HomePath, SessionId, StoredSessionFacts } from "./contract.js";
9
+ export declare function readBack(home: HomePath, sessionId: SessionId): Promise<StoredSessionFacts>;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Reading a committed session back.
3
+ *
4
+ * C-9's own caution is why this is not optional: a throwaway directory holding one session does
5
+ * not prove a real store is safe, so the import compares what it wrote with what the store holds
6
+ * (FR-52) and whether the native resume list can open it (FR-51).
7
+ */
8
+ import { readFile } from "node:fs/promises";
9
+ import { parseJsonl } from "./entries.js";
10
+ import { findSessionFile } from "./layout.js";
11
+ import { readSessionText } from "./reader.js";
12
+ import { isStructurallyOpenable } from "./validation.js";
13
+ export async function readBack(home, sessionId) {
14
+ const absent = {
15
+ sessionId,
16
+ itemCount: 0,
17
+ openable: false,
18
+ };
19
+ const file = await findSessionFile(home, sessionId);
20
+ if (file === null)
21
+ return absent;
22
+ let text;
23
+ try {
24
+ text = await readFile(file, "utf8");
25
+ }
26
+ catch {
27
+ return absent;
28
+ }
29
+ const { entries, unreadable } = parseJsonl(text);
30
+ const read = unreadable === null ? readSessionText(text) : null;
31
+ return {
32
+ sessionId,
33
+ itemCount: entries.length,
34
+ openable: unreadable === null &&
35
+ read?.unreadable === null &&
36
+ read.turns.length > 0 &&
37
+ isStructurallyOpenable(entries, sessionId),
38
+ };
39
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Reading a Claude Code session into the neutral vocabulary.
3
+ *
4
+ * Two rules shape everything here: no result body crosses (FR-24) and no system prompt,
5
+ * environment value, token or hidden reasoning crosses (FR-28, NG-7). Both are enforced by
6
+ * what this file builds, not by what a caller does with it.
7
+ */
8
+ import type { CanonicalSession, CanonicalTurn, HomePath, SessionDescriptor } from "./contract.js";
9
+ /** FR-25: every dropped body is marked in text the model can read. */
10
+ export declare const DROPPED_MARKER = "(content dropped: imported session, may be stale)";
11
+ export declare const UNREADABLE_TITLE = "(unreadable session file)";
12
+ export declare const UNTITLED = "(no user message)";
13
+ export interface SessionReadResult {
14
+ turns: CanonicalTurn[];
15
+ /**
16
+ * Entries this adapter does not read: the other entry types of C-3, hidden reasoning, and
17
+ * everything FR-28 excludes. `AgentAdapter` has no field for this count, so it is reported
18
+ * here and asserted by T-CC-15.
19
+ */
20
+ skipped: number;
21
+ /** Set when the file is cut mid-entry. Then the session is not readable at all. */
22
+ unreadable: string | null;
23
+ title: string;
24
+ startedAt: string | null;
25
+ updatedAt: string | null;
26
+ repoPath: string | null;
27
+ branch: string | null;
28
+ changedPaths: string[];
29
+ }
30
+ /** The redacted source arguments, shortened so one call stays one line. */
31
+ export declare function renderArguments(input: unknown): string;
32
+ /** Read a whole session file into canonical turns. Pure: it takes the text, not a path. */
33
+ export declare function readSessionText(text: string): SessionReadResult;
34
+ /** One row per session file of the home, newest first (FR-11, FR-14). */
35
+ export declare function listSessions(home: HomePath): Promise<SessionDescriptor[]>;
36
+ /** One session in the neutral vocabulary. A file cut mid-entry is reported, never guessed at. */
37
+ export declare function loadSession(descriptor: SessionDescriptor): Promise<CanonicalSession>;