@cleocode/adapters 2026.3.68 → 2026.3.70

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 (232) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +0 -0
  3. package/dist/index.d.ts +0 -0
  4. package/dist/index.d.ts.map +0 -0
  5. package/dist/index.js +0 -0
  6. package/dist/index.js.map +2 -2
  7. package/dist/providers/claude-code/adapter.d.ts +0 -0
  8. package/dist/providers/claude-code/adapter.d.ts.map +0 -0
  9. package/dist/providers/claude-code/adapter.js +0 -0
  10. package/dist/providers/claude-code/adapter.js.map +0 -0
  11. package/dist/providers/claude-code/context-monitor.d.ts +0 -0
  12. package/dist/providers/claude-code/context-monitor.d.ts.map +0 -0
  13. package/dist/providers/claude-code/context-monitor.js +0 -0
  14. package/dist/providers/claude-code/context-monitor.js.map +0 -0
  15. package/dist/providers/claude-code/hooks.d.ts +16 -0
  16. package/dist/providers/claude-code/hooks.d.ts.map +1 -1
  17. package/dist/providers/claude-code/hooks.js +0 -0
  18. package/dist/providers/claude-code/hooks.js.map +0 -0
  19. package/dist/providers/claude-code/index.d.ts +0 -0
  20. package/dist/providers/claude-code/index.d.ts.map +0 -0
  21. package/dist/providers/claude-code/index.js +0 -0
  22. package/dist/providers/claude-code/index.js.map +0 -0
  23. package/dist/providers/claude-code/install.d.ts +0 -0
  24. package/dist/providers/claude-code/install.d.ts.map +0 -0
  25. package/dist/providers/claude-code/install.js +0 -0
  26. package/dist/providers/claude-code/install.js.map +0 -0
  27. package/dist/providers/claude-code/paths.d.ts +0 -0
  28. package/dist/providers/claude-code/paths.d.ts.map +0 -0
  29. package/dist/providers/claude-code/paths.js +0 -0
  30. package/dist/providers/claude-code/paths.js.map +0 -0
  31. package/dist/providers/claude-code/spawn.d.ts +0 -0
  32. package/dist/providers/claude-code/spawn.d.ts.map +0 -0
  33. package/dist/providers/claude-code/spawn.js +0 -0
  34. package/dist/providers/claude-code/spawn.js.map +0 -0
  35. package/dist/providers/claude-code/statusline.d.ts +0 -0
  36. package/dist/providers/claude-code/statusline.d.ts.map +0 -0
  37. package/dist/providers/claude-code/statusline.js +0 -0
  38. package/dist/providers/claude-code/statusline.js.map +0 -0
  39. package/dist/providers/claude-code/task-sync.d.ts +0 -0
  40. package/dist/providers/claude-code/task-sync.d.ts.map +0 -0
  41. package/dist/providers/claude-code/task-sync.js +0 -0
  42. package/dist/providers/claude-code/task-sync.js.map +0 -0
  43. package/dist/providers/claude-code/transport.d.ts +0 -0
  44. package/dist/providers/claude-code/transport.d.ts.map +0 -0
  45. package/dist/providers/claude-code/transport.js +0 -0
  46. package/dist/providers/claude-code/transport.js.map +0 -0
  47. package/dist/providers/cursor/adapter.d.ts +0 -0
  48. package/dist/providers/cursor/adapter.d.ts.map +0 -0
  49. package/dist/providers/cursor/adapter.js +0 -0
  50. package/dist/providers/cursor/adapter.js.map +0 -0
  51. package/dist/providers/cursor/hooks.d.ts +0 -0
  52. package/dist/providers/cursor/hooks.d.ts.map +0 -0
  53. package/dist/providers/cursor/hooks.js +0 -0
  54. package/dist/providers/cursor/hooks.js.map +0 -0
  55. package/dist/providers/cursor/index.d.ts +0 -0
  56. package/dist/providers/cursor/index.d.ts.map +0 -0
  57. package/dist/providers/cursor/index.js +0 -0
  58. package/dist/providers/cursor/index.js.map +0 -0
  59. package/dist/providers/cursor/install.d.ts +0 -0
  60. package/dist/providers/cursor/install.d.ts.map +0 -0
  61. package/dist/providers/cursor/install.js +0 -0
  62. package/dist/providers/cursor/install.js.map +0 -0
  63. package/dist/providers/cursor/spawn.d.ts +0 -0
  64. package/dist/providers/cursor/spawn.d.ts.map +0 -0
  65. package/dist/providers/cursor/spawn.js +0 -0
  66. package/dist/providers/cursor/spawn.js.map +0 -0
  67. package/dist/providers/opencode/adapter.d.ts +0 -0
  68. package/dist/providers/opencode/adapter.d.ts.map +0 -0
  69. package/dist/providers/opencode/adapter.js +0 -0
  70. package/dist/providers/opencode/adapter.js.map +0 -0
  71. package/dist/providers/opencode/hooks.d.ts +0 -0
  72. package/dist/providers/opencode/hooks.d.ts.map +0 -0
  73. package/dist/providers/opencode/hooks.js +0 -0
  74. package/dist/providers/opencode/hooks.js.map +0 -0
  75. package/dist/providers/opencode/index.d.ts +0 -0
  76. package/dist/providers/opencode/index.d.ts.map +0 -0
  77. package/dist/providers/opencode/index.js +0 -0
  78. package/dist/providers/opencode/index.js.map +0 -0
  79. package/dist/providers/opencode/install.d.ts +0 -0
  80. package/dist/providers/opencode/install.d.ts.map +0 -0
  81. package/dist/providers/opencode/install.js +0 -0
  82. package/dist/providers/opencode/install.js.map +0 -0
  83. package/dist/providers/opencode/spawn.d.ts +0 -0
  84. package/dist/providers/opencode/spawn.d.ts.map +0 -0
  85. package/dist/providers/opencode/spawn.js +0 -0
  86. package/dist/providers/opencode/spawn.js.map +0 -0
  87. package/dist/registry.d.ts +0 -0
  88. package/dist/registry.d.ts.map +0 -0
  89. package/dist/registry.js +0 -0
  90. package/dist/registry.js.map +0 -0
  91. package/package.json +7 -7
  92. package/src/__tests__/claude-code-adapter.test.d.ts +0 -0
  93. package/src/__tests__/claude-code-adapter.test.d.ts.map +0 -0
  94. package/src/__tests__/claude-code-adapter.test.js +0 -0
  95. package/src/__tests__/claude-code-adapter.test.js.map +0 -0
  96. package/src/__tests__/claude-code-adapter.test.ts +0 -0
  97. package/src/__tests__/cursor-adapter.test.d.ts +0 -0
  98. package/src/__tests__/cursor-adapter.test.d.ts.map +0 -0
  99. package/src/__tests__/cursor-adapter.test.js +0 -0
  100. package/src/__tests__/cursor-adapter.test.js.map +0 -0
  101. package/src/__tests__/cursor-adapter.test.ts +0 -0
  102. package/src/__tests__/opencode-adapter.test.d.ts +0 -0
  103. package/src/__tests__/opencode-adapter.test.d.ts.map +0 -0
  104. package/src/__tests__/opencode-adapter.test.js +0 -0
  105. package/src/__tests__/opencode-adapter.test.js.map +0 -0
  106. package/src/__tests__/opencode-adapter.test.ts +0 -0
  107. package/src/index.d.ts +0 -0
  108. package/src/index.d.ts.map +0 -0
  109. package/src/index.js +0 -0
  110. package/src/index.js.map +0 -0
  111. package/src/index.ts +0 -0
  112. package/src/providers/claude-code/__tests__/adapter.test.d.ts +0 -0
  113. package/src/providers/claude-code/__tests__/adapter.test.d.ts.map +0 -0
  114. package/src/providers/claude-code/__tests__/adapter.test.js +0 -0
  115. package/src/providers/claude-code/__tests__/adapter.test.js.map +0 -0
  116. package/src/providers/claude-code/__tests__/adapter.test.ts +0 -0
  117. package/src/providers/claude-code/adapter.d.ts +0 -0
  118. package/src/providers/claude-code/adapter.d.ts.map +0 -0
  119. package/src/providers/claude-code/adapter.js +0 -0
  120. package/src/providers/claude-code/adapter.js.map +0 -0
  121. package/src/providers/claude-code/adapter.ts +0 -0
  122. package/src/providers/claude-code/context-monitor.d.ts +0 -0
  123. package/src/providers/claude-code/context-monitor.d.ts.map +0 -0
  124. package/src/providers/claude-code/context-monitor.js +0 -0
  125. package/src/providers/claude-code/context-monitor.js.map +0 -0
  126. package/src/providers/claude-code/context-monitor.ts +0 -0
  127. package/src/providers/claude-code/hooks.d.ts +0 -0
  128. package/src/providers/claude-code/hooks.d.ts.map +0 -0
  129. package/src/providers/claude-code/hooks.js +0 -0
  130. package/src/providers/claude-code/hooks.js.map +0 -0
  131. package/src/providers/claude-code/hooks.ts +77 -0
  132. package/src/providers/claude-code/index.d.ts +0 -0
  133. package/src/providers/claude-code/index.d.ts.map +0 -0
  134. package/src/providers/claude-code/index.js +0 -0
  135. package/src/providers/claude-code/index.js.map +0 -0
  136. package/src/providers/claude-code/index.ts +0 -0
  137. package/src/providers/claude-code/install.d.ts +0 -0
  138. package/src/providers/claude-code/install.d.ts.map +0 -0
  139. package/src/providers/claude-code/install.js +0 -0
  140. package/src/providers/claude-code/install.js.map +0 -0
  141. package/src/providers/claude-code/install.ts +0 -0
  142. package/src/providers/claude-code/manifest.json +0 -0
  143. package/src/providers/claude-code/paths.d.ts +0 -0
  144. package/src/providers/claude-code/paths.d.ts.map +0 -0
  145. package/src/providers/claude-code/paths.js +0 -0
  146. package/src/providers/claude-code/paths.js.map +0 -0
  147. package/src/providers/claude-code/paths.ts +0 -0
  148. package/src/providers/claude-code/spawn.d.ts +0 -0
  149. package/src/providers/claude-code/spawn.d.ts.map +0 -0
  150. package/src/providers/claude-code/spawn.js +0 -0
  151. package/src/providers/claude-code/spawn.js.map +0 -0
  152. package/src/providers/claude-code/spawn.ts +0 -0
  153. package/src/providers/claude-code/statusline.d.ts +0 -0
  154. package/src/providers/claude-code/statusline.d.ts.map +0 -0
  155. package/src/providers/claude-code/statusline.js +0 -0
  156. package/src/providers/claude-code/statusline.js.map +0 -0
  157. package/src/providers/claude-code/statusline.ts +0 -0
  158. package/src/providers/claude-code/task-sync.js +0 -0
  159. package/src/providers/claude-code/task-sync.js.map +0 -0
  160. package/src/providers/claude-code/task-sync.ts +0 -0
  161. package/src/providers/claude-code/transport.d.ts +0 -0
  162. package/src/providers/claude-code/transport.d.ts.map +0 -0
  163. package/src/providers/claude-code/transport.js +0 -0
  164. package/src/providers/claude-code/transport.js.map +0 -0
  165. package/src/providers/claude-code/transport.ts +0 -0
  166. package/src/providers/cursor/__tests__/adapter.test.d.ts +0 -0
  167. package/src/providers/cursor/__tests__/adapter.test.d.ts.map +0 -0
  168. package/src/providers/cursor/__tests__/adapter.test.js +0 -0
  169. package/src/providers/cursor/__tests__/adapter.test.js.map +0 -0
  170. package/src/providers/cursor/__tests__/adapter.test.ts +0 -0
  171. package/src/providers/cursor/adapter.d.ts +0 -0
  172. package/src/providers/cursor/adapter.d.ts.map +0 -0
  173. package/src/providers/cursor/adapter.js +0 -0
  174. package/src/providers/cursor/adapter.js.map +0 -0
  175. package/src/providers/cursor/adapter.ts +0 -0
  176. package/src/providers/cursor/hooks.d.ts +0 -0
  177. package/src/providers/cursor/hooks.d.ts.map +0 -0
  178. package/src/providers/cursor/hooks.js +0 -0
  179. package/src/providers/cursor/hooks.js.map +0 -0
  180. package/src/providers/cursor/hooks.ts +0 -0
  181. package/src/providers/cursor/index.d.ts +0 -0
  182. package/src/providers/cursor/index.d.ts.map +0 -0
  183. package/src/providers/cursor/index.js +0 -0
  184. package/src/providers/cursor/index.js.map +0 -0
  185. package/src/providers/cursor/index.ts +0 -0
  186. package/src/providers/cursor/install.d.ts +0 -0
  187. package/src/providers/cursor/install.d.ts.map +0 -0
  188. package/src/providers/cursor/install.js +0 -0
  189. package/src/providers/cursor/install.js.map +0 -0
  190. package/src/providers/cursor/install.ts +0 -0
  191. package/src/providers/cursor/manifest.json +0 -0
  192. package/src/providers/cursor/spawn.d.ts +0 -0
  193. package/src/providers/cursor/spawn.d.ts.map +0 -0
  194. package/src/providers/cursor/spawn.js +0 -0
  195. package/src/providers/cursor/spawn.js.map +0 -0
  196. package/src/providers/cursor/spawn.ts +0 -0
  197. package/src/providers/opencode/__tests__/adapter.test.d.ts +0 -0
  198. package/src/providers/opencode/__tests__/adapter.test.d.ts.map +0 -0
  199. package/src/providers/opencode/__tests__/adapter.test.js +0 -0
  200. package/src/providers/opencode/__tests__/adapter.test.js.map +0 -0
  201. package/src/providers/opencode/__tests__/adapter.test.ts +0 -0
  202. package/src/providers/opencode/adapter.d.ts +0 -0
  203. package/src/providers/opencode/adapter.d.ts.map +0 -0
  204. package/src/providers/opencode/adapter.js +0 -0
  205. package/src/providers/opencode/adapter.js.map +0 -0
  206. package/src/providers/opencode/adapter.ts +0 -0
  207. package/src/providers/opencode/hooks.d.ts +0 -0
  208. package/src/providers/opencode/hooks.d.ts.map +0 -0
  209. package/src/providers/opencode/hooks.js +0 -0
  210. package/src/providers/opencode/hooks.js.map +0 -0
  211. package/src/providers/opencode/hooks.ts +0 -0
  212. package/src/providers/opencode/index.d.ts +0 -0
  213. package/src/providers/opencode/index.d.ts.map +0 -0
  214. package/src/providers/opencode/index.js +0 -0
  215. package/src/providers/opencode/index.js.map +0 -0
  216. package/src/providers/opencode/index.ts +0 -0
  217. package/src/providers/opencode/install.d.ts +0 -0
  218. package/src/providers/opencode/install.d.ts.map +0 -0
  219. package/src/providers/opencode/install.js +0 -0
  220. package/src/providers/opencode/install.js.map +0 -0
  221. package/src/providers/opencode/install.ts +0 -0
  222. package/src/providers/opencode/manifest.json +0 -0
  223. package/src/providers/opencode/spawn.d.ts +0 -0
  224. package/src/providers/opencode/spawn.d.ts.map +0 -0
  225. package/src/providers/opencode/spawn.js +0 -0
  226. package/src/providers/opencode/spawn.js.map +0 -0
  227. package/src/providers/opencode/spawn.ts +0 -0
  228. package/src/registry.d.ts +0 -0
  229. package/src/registry.d.ts.map +0 -0
  230. package/src/registry.js +0 -0
  231. package/src/registry.js.map +0 -0
  232. package/src/registry.ts +0 -0
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -6,6 +6,8 @@
6
6
  * CAAMP defines: onSessionStart, onToolComplete, onPromptSubmit, onSessionEnd
7
7
  *
8
8
  * @task T5240
9
+ * @task T144
10
+ * @epic T134
9
11
  */
10
12
  import type { AdapterHookProvider } from '@cleocode/contracts';
11
13
  /**
@@ -55,5 +57,19 @@ export declare class ClaudeCodeHookProvider implements AdapterHookProvider {
55
57
  * Get the full event mapping for introspection/debugging.
56
58
  */
57
59
  getEventMap(): Readonly<Record<string, string>>;
60
+ /**
61
+ * Extract a plain-text transcript from Claude Code session JSONL files.
62
+ *
63
+ * Reads the most recent .jsonl file under ~/.claude/projects/ and
64
+ * extracts user/assistant turn text into a flat string for brain
65
+ * observation extraction.
66
+ *
67
+ * Returns null when no session data is found or on any read error.
68
+ *
69
+ * @param _sessionId - CLEO session ID (unused; reads the most recent file)
70
+ * @param _projectDir - Project directory (unused; Claude Code uses global paths)
71
+ * @task T144 @epic T134
72
+ */
73
+ getTranscript(_sessionId: string, _projectDir: string): Promise<string | null>;
58
74
  }
59
75
  //# sourceMappingURL=hooks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/providers/claude-code/hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAY/D;;;;;;;;;;GAUG;AACH,qBAAa,sBAAuB,YAAW,mBAAmB;IAChE,OAAO,CAAC,UAAU,CAAS;IAE3B;;;;;OAKG;IACH,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAItD;;;;;;;;;OASG;IACG,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7D;;;;;;OAMG;IACG,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5C;;OAEG;IACH,YAAY,IAAI,OAAO;IAIvB;;OAEG;IACH,WAAW,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAGhD"}
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/providers/claude-code/hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAY/D;;;;;;;;;;GAUG;AACH,qBAAa,sBAAuB,YAAW,mBAAmB;IAChE,OAAO,CAAC,UAAU,CAAS;IAE3B;;;;;OAKG;IACH,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAItD;;;;;;;;;OASG;IACG,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7D;;;;;;OAMG;IACG,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5C;;OAEG;IACH,YAAY,IAAI,OAAO;IAIvB;;OAEG;IACH,WAAW,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAI/C;;;;;;;;;;;;OAYG;IACG,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CA2DrF"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/dist/registry.js CHANGED
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cleocode/adapters",
3
- "version": "2026.3.68",
3
+ "version": "2026.3.70",
4
4
  "description": "Unified provider adapters for CLEO (Claude Code, OpenCode, Cursor)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -11,12 +11,8 @@
11
11
  "import": "./dist/index.js"
12
12
  }
13
13
  },
14
- "scripts": {
15
- "build": "tsc",
16
- "build:check": "tsc --noEmit"
17
- },
18
14
  "dependencies": {
19
- "@cleocode/contracts": "workspace:*"
15
+ "@cleocode/contracts": "2026.3.70"
20
16
  },
21
17
  "license": "MIT",
22
18
  "engines": {
@@ -33,5 +29,9 @@
33
29
  "type": "git",
34
30
  "url": "https://github.com/kryptobaseddev/cleo",
35
31
  "directory": "packages/adapters"
32
+ },
33
+ "scripts": {
34
+ "build": "tsc",
35
+ "build:check": "tsc --noEmit"
36
36
  }
37
- }
37
+ }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/src/index.d.ts CHANGED
File without changes
File without changes
package/src/index.js CHANGED
File without changes
package/src/index.js.map CHANGED
File without changes
package/src/index.ts CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -6,8 +6,12 @@
6
6
  * CAAMP defines: onSessionStart, onToolComplete, onPromptSubmit, onSessionEnd
7
7
  *
8
8
  * @task T5240
9
+ * @task T144
10
+ * @epic T134
9
11
  */
10
12
 
13
+ import { readdir, readFile } from 'node:fs/promises';
14
+ import { join } from 'node:path';
11
15
  import type { AdapterHookProvider } from '@cleocode/contracts';
12
16
 
13
17
  /**
@@ -82,4 +86,77 @@ export class ClaudeCodeHookProvider implements AdapterHookProvider {
82
86
  getEventMap(): Readonly<Record<string, string>> {
83
87
  return { ...CLAUDE_CODE_EVENT_MAP };
84
88
  }
89
+
90
+ /**
91
+ * Extract a plain-text transcript from Claude Code session JSONL files.
92
+ *
93
+ * Reads the most recent .jsonl file under ~/.claude/projects/ and
94
+ * extracts user/assistant turn text into a flat string for brain
95
+ * observation extraction.
96
+ *
97
+ * Returns null when no session data is found or on any read error.
98
+ *
99
+ * @param _sessionId - CLEO session ID (unused; reads the most recent file)
100
+ * @param _projectDir - Project directory (unused; Claude Code uses global paths)
101
+ * @task T144 @epic T134
102
+ */
103
+ async getTranscript(_sessionId: string, _projectDir: string): Promise<string | null> {
104
+ try {
105
+ const homeDir = process.env.HOME ?? process.env.USERPROFILE ?? '/root';
106
+ const projectsDir = join(homeDir, '.claude', 'projects');
107
+
108
+ // Find all JSONL files across project subdirectories
109
+ let allFiles: Array<{ path: string; mtime: number }> = [];
110
+ try {
111
+ const projectDirs = await readdir(projectsDir, { withFileTypes: true });
112
+ for (const entry of projectDirs) {
113
+ if (!entry.isDirectory()) continue;
114
+ const subDir = join(projectsDir, entry.name);
115
+ try {
116
+ const files = await readdir(subDir);
117
+ for (const file of files) {
118
+ if (!file.endsWith('.jsonl')) continue;
119
+ const filePath = join(subDir, file);
120
+ // Use file path modification heuristic (filename usually includes timestamp)
121
+ allFiles.push({ path: filePath, mtime: 0 });
122
+ }
123
+ } catch {
124
+ // Skip unreadable subdirectories
125
+ }
126
+ }
127
+ } catch {
128
+ return null;
129
+ }
130
+
131
+ if (allFiles.length === 0) return null;
132
+
133
+ // Sort by path descending (timestamps in filenames sort naturally)
134
+ allFiles = allFiles.sort((a, b) => b.path.localeCompare(a.path));
135
+ const mostRecent = allFiles[0];
136
+ if (!mostRecent) return null;
137
+
138
+ const raw = await readFile(mostRecent.path, 'utf-8');
139
+ const lines = raw.split('\n').filter((l) => l.trim());
140
+
141
+ const turns: string[] = [];
142
+ for (const line of lines) {
143
+ try {
144
+ const entry = JSON.parse(line) as Record<string, unknown>;
145
+ const role = entry.role as string | undefined;
146
+ const content = entry.content;
147
+ if (role === 'assistant' && typeof content === 'string') {
148
+ turns.push(`assistant: ${content}`);
149
+ } else if (role === 'user' && typeof content === 'string') {
150
+ turns.push(`user: ${content}`);
151
+ }
152
+ } catch {
153
+ // Skip malformed lines
154
+ }
155
+ }
156
+
157
+ return turns.length > 0 ? turns.join('\n') : null;
158
+ } catch {
159
+ return null;
160
+ }
161
+ }
85
162
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes