attocode 0.1.0

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 (488) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/LICENSE +21 -0
  3. package/README.md +164 -0
  4. package/dist/src/adapters.d.ts +83 -0
  5. package/dist/src/adapters.d.ts.map +1 -0
  6. package/dist/src/adapters.js +221 -0
  7. package/dist/src/adapters.js.map +1 -0
  8. package/dist/src/agent-tools/index.d.ts +7 -0
  9. package/dist/src/agent-tools/index.d.ts.map +1 -0
  10. package/dist/src/agent-tools/index.js +8 -0
  11. package/dist/src/agent-tools/index.js.map +1 -0
  12. package/dist/src/agent-tools/lsp-file-tools.d.ts +33 -0
  13. package/dist/src/agent-tools/lsp-file-tools.d.ts.map +1 -0
  14. package/dist/src/agent-tools/lsp-file-tools.js +200 -0
  15. package/dist/src/agent-tools/lsp-file-tools.js.map +1 -0
  16. package/dist/src/agent.d.ts +667 -0
  17. package/dist/src/agent.d.ts.map +1 -0
  18. package/dist/src/agent.js +2824 -0
  19. package/dist/src/agent.js.map +1 -0
  20. package/dist/src/cli.d.ts +36 -0
  21. package/dist/src/cli.d.ts.map +1 -0
  22. package/dist/src/cli.js +176 -0
  23. package/dist/src/cli.js.map +1 -0
  24. package/dist/src/commands/handler.d.ts +22 -0
  25. package/dist/src/commands/handler.d.ts.map +1 -0
  26. package/dist/src/commands/handler.js +1320 -0
  27. package/dist/src/commands/handler.js.map +1 -0
  28. package/dist/src/commands/init.d.ts +7 -0
  29. package/dist/src/commands/init.d.ts.map +1 -0
  30. package/dist/src/commands/init.js +153 -0
  31. package/dist/src/commands/init.js.map +1 -0
  32. package/dist/src/commands/types.d.ts +70 -0
  33. package/dist/src/commands/types.d.ts.map +1 -0
  34. package/dist/src/commands/types.js +8 -0
  35. package/dist/src/commands/types.js.map +1 -0
  36. package/dist/src/config.d.ts +22 -0
  37. package/dist/src/config.d.ts.map +1 -0
  38. package/dist/src/config.js +25 -0
  39. package/dist/src/config.js.map +1 -0
  40. package/dist/src/core/index.d.ts +32 -0
  41. package/dist/src/core/index.d.ts.map +1 -0
  42. package/dist/src/core/index.js +35 -0
  43. package/dist/src/core/index.js.map +1 -0
  44. package/dist/src/core/process-handlers.d.ts +43 -0
  45. package/dist/src/core/process-handlers.d.ts.map +1 -0
  46. package/dist/src/core/process-handlers.js +117 -0
  47. package/dist/src/core/process-handlers.js.map +1 -0
  48. package/dist/src/core/protocol/bridge.d.ts +117 -0
  49. package/dist/src/core/protocol/bridge.d.ts.map +1 -0
  50. package/dist/src/core/protocol/bridge.js +149 -0
  51. package/dist/src/core/protocol/bridge.js.map +1 -0
  52. package/dist/src/core/protocol/index.d.ts +8 -0
  53. package/dist/src/core/protocol/index.d.ts.map +1 -0
  54. package/dist/src/core/protocol/index.js +8 -0
  55. package/dist/src/core/protocol/index.js.map +1 -0
  56. package/dist/src/core/protocol/types.d.ts +539 -0
  57. package/dist/src/core/protocol/types.d.ts.map +1 -0
  58. package/dist/src/core/protocol/types.js +149 -0
  59. package/dist/src/core/protocol/types.js.map +1 -0
  60. package/dist/src/core/queues/atomic-counter.d.ts +36 -0
  61. package/dist/src/core/queues/atomic-counter.d.ts.map +1 -0
  62. package/dist/src/core/queues/atomic-counter.js +46 -0
  63. package/dist/src/core/queues/atomic-counter.js.map +1 -0
  64. package/dist/src/core/queues/event-queue.d.ts +126 -0
  65. package/dist/src/core/queues/event-queue.d.ts.map +1 -0
  66. package/dist/src/core/queues/event-queue.js +208 -0
  67. package/dist/src/core/queues/event-queue.js.map +1 -0
  68. package/dist/src/core/queues/index.d.ts +12 -0
  69. package/dist/src/core/queues/index.d.ts.map +1 -0
  70. package/dist/src/core/queues/index.js +15 -0
  71. package/dist/src/core/queues/index.js.map +1 -0
  72. package/dist/src/core/queues/submission-queue.d.ts +116 -0
  73. package/dist/src/core/queues/submission-queue.d.ts.map +1 -0
  74. package/dist/src/core/queues/submission-queue.js +236 -0
  75. package/dist/src/core/queues/submission-queue.js.map +1 -0
  76. package/dist/src/costs/index.d.ts +22 -0
  77. package/dist/src/costs/index.d.ts.map +1 -0
  78. package/dist/src/costs/index.js +22 -0
  79. package/dist/src/costs/index.js.map +1 -0
  80. package/dist/src/costs/model-registry.d.ts +80 -0
  81. package/dist/src/costs/model-registry.d.ts.map +1 -0
  82. package/dist/src/costs/model-registry.js +237 -0
  83. package/dist/src/costs/model-registry.js.map +1 -0
  84. package/dist/src/costs/types.d.ts +50 -0
  85. package/dist/src/costs/types.d.ts.map +1 -0
  86. package/dist/src/costs/types.js +2 -0
  87. package/dist/src/costs/types.js.map +1 -0
  88. package/dist/src/defaults.d.ts +114 -0
  89. package/dist/src/defaults.d.ts.map +1 -0
  90. package/dist/src/defaults.js +457 -0
  91. package/dist/src/defaults.js.map +1 -0
  92. package/dist/src/first-run.d.ts +35 -0
  93. package/dist/src/first-run.d.ts.map +1 -0
  94. package/dist/src/first-run.js +94 -0
  95. package/dist/src/first-run.js.map +1 -0
  96. package/dist/src/hello.d.ts +2 -0
  97. package/dist/src/hello.d.ts.map +1 -0
  98. package/dist/src/hello.js +4 -0
  99. package/dist/src/hello.js.map +1 -0
  100. package/dist/src/integrations/agent-registry.d.ts +160 -0
  101. package/dist/src/integrations/agent-registry.d.ts.map +1 -0
  102. package/dist/src/integrations/agent-registry.js +446 -0
  103. package/dist/src/integrations/agent-registry.js.map +1 -0
  104. package/dist/src/integrations/auto-compaction.d.ts +177 -0
  105. package/dist/src/integrations/auto-compaction.d.ts.map +1 -0
  106. package/dist/src/integrations/auto-compaction.js +428 -0
  107. package/dist/src/integrations/auto-compaction.js.map +1 -0
  108. package/dist/src/integrations/cancellation.d.ts +162 -0
  109. package/dist/src/integrations/cancellation.d.ts.map +1 -0
  110. package/dist/src/integrations/cancellation.js +339 -0
  111. package/dist/src/integrations/cancellation.js.map +1 -0
  112. package/dist/src/integrations/codebase-context.d.ts +319 -0
  113. package/dist/src/integrations/codebase-context.d.ts.map +1 -0
  114. package/dist/src/integrations/codebase-context.js +816 -0
  115. package/dist/src/integrations/codebase-context.js.map +1 -0
  116. package/dist/src/integrations/compaction.d.ts +192 -0
  117. package/dist/src/integrations/compaction.d.ts.map +1 -0
  118. package/dist/src/integrations/compaction.js +376 -0
  119. package/dist/src/integrations/compaction.js.map +1 -0
  120. package/dist/src/integrations/context-engineering.d.ts +246 -0
  121. package/dist/src/integrations/context-engineering.d.ts.map +1 -0
  122. package/dist/src/integrations/context-engineering.js +394 -0
  123. package/dist/src/integrations/context-engineering.js.map +1 -0
  124. package/dist/src/integrations/diff-utils.d.ts +105 -0
  125. package/dist/src/integrations/diff-utils.d.ts.map +1 -0
  126. package/dist/src/integrations/diff-utils.js +497 -0
  127. package/dist/src/integrations/diff-utils.js.map +1 -0
  128. package/dist/src/integrations/economics.d.ts +192 -0
  129. package/dist/src/integrations/economics.d.ts.map +1 -0
  130. package/dist/src/integrations/economics.js +431 -0
  131. package/dist/src/integrations/economics.js.map +1 -0
  132. package/dist/src/integrations/execution-policy.d.ts +189 -0
  133. package/dist/src/integrations/execution-policy.d.ts.map +1 -0
  134. package/dist/src/integrations/execution-policy.js +352 -0
  135. package/dist/src/integrations/execution-policy.js.map +1 -0
  136. package/dist/src/integrations/file-change-tracker.d.ts +161 -0
  137. package/dist/src/integrations/file-change-tracker.d.ts.map +1 -0
  138. package/dist/src/integrations/file-change-tracker.js +520 -0
  139. package/dist/src/integrations/file-change-tracker.js.map +1 -0
  140. package/dist/src/integrations/hierarchical-config.d.ts +212 -0
  141. package/dist/src/integrations/hierarchical-config.d.ts.map +1 -0
  142. package/dist/src/integrations/hierarchical-config.js +484 -0
  143. package/dist/src/integrations/hierarchical-config.js.map +1 -0
  144. package/dist/src/integrations/hooks.d.ts +114 -0
  145. package/dist/src/integrations/hooks.d.ts.map +1 -0
  146. package/dist/src/integrations/hooks.js +326 -0
  147. package/dist/src/integrations/hooks.js.map +1 -0
  148. package/dist/src/integrations/ignore.d.ts +143 -0
  149. package/dist/src/integrations/ignore.d.ts.map +1 -0
  150. package/dist/src/integrations/ignore.js +417 -0
  151. package/dist/src/integrations/ignore.js.map +1 -0
  152. package/dist/src/integrations/image-renderer.d.ts +119 -0
  153. package/dist/src/integrations/image-renderer.d.ts.map +1 -0
  154. package/dist/src/integrations/image-renderer.js +306 -0
  155. package/dist/src/integrations/image-renderer.js.map +1 -0
  156. package/dist/src/integrations/index.d.ts +42 -0
  157. package/dist/src/integrations/index.d.ts.map +1 -0
  158. package/dist/src/integrations/index.js +73 -0
  159. package/dist/src/integrations/index.js.map +1 -0
  160. package/dist/src/integrations/lsp.d.ts +196 -0
  161. package/dist/src/integrations/lsp.d.ts.map +1 -0
  162. package/dist/src/integrations/lsp.js +582 -0
  163. package/dist/src/integrations/lsp.js.map +1 -0
  164. package/dist/src/integrations/mcp-client.d.ts +270 -0
  165. package/dist/src/integrations/mcp-client.d.ts.map +1 -0
  166. package/dist/src/integrations/mcp-client.js +698 -0
  167. package/dist/src/integrations/mcp-client.js.map +1 -0
  168. package/dist/src/integrations/mcp-tool-search.d.ts +77 -0
  169. package/dist/src/integrations/mcp-tool-search.d.ts.map +1 -0
  170. package/dist/src/integrations/mcp-tool-search.js +220 -0
  171. package/dist/src/integrations/mcp-tool-search.js.map +1 -0
  172. package/dist/src/integrations/memory.d.ts +108 -0
  173. package/dist/src/integrations/memory.d.ts.map +1 -0
  174. package/dist/src/integrations/memory.js +288 -0
  175. package/dist/src/integrations/memory.js.map +1 -0
  176. package/dist/src/integrations/multi-agent.d.ts +150 -0
  177. package/dist/src/integrations/multi-agent.d.ts.map +1 -0
  178. package/dist/src/integrations/multi-agent.js +306 -0
  179. package/dist/src/integrations/multi-agent.js.map +1 -0
  180. package/dist/src/integrations/observability.d.ts +162 -0
  181. package/dist/src/integrations/observability.d.ts.map +1 -0
  182. package/dist/src/integrations/observability.js +406 -0
  183. package/dist/src/integrations/observability.js.map +1 -0
  184. package/dist/src/integrations/openrouter-pricing.d.ts +42 -0
  185. package/dist/src/integrations/openrouter-pricing.d.ts.map +1 -0
  186. package/dist/src/integrations/openrouter-pricing.js +124 -0
  187. package/dist/src/integrations/openrouter-pricing.js.map +1 -0
  188. package/dist/src/integrations/pending-plan.d.ts +171 -0
  189. package/dist/src/integrations/pending-plan.d.ts.map +1 -0
  190. package/dist/src/integrations/pending-plan.js +244 -0
  191. package/dist/src/integrations/pending-plan.js.map +1 -0
  192. package/dist/src/integrations/persistence.d.ts +48 -0
  193. package/dist/src/integrations/persistence.d.ts.map +1 -0
  194. package/dist/src/integrations/persistence.js +196 -0
  195. package/dist/src/integrations/persistence.js.map +1 -0
  196. package/dist/src/integrations/planning.d.ts +96 -0
  197. package/dist/src/integrations/planning.d.ts.map +1 -0
  198. package/dist/src/integrations/planning.js +338 -0
  199. package/dist/src/integrations/planning.js.map +1 -0
  200. package/dist/src/integrations/pty-shell.d.ts +169 -0
  201. package/dist/src/integrations/pty-shell.d.ts.map +1 -0
  202. package/dist/src/integrations/pty-shell.js +367 -0
  203. package/dist/src/integrations/pty-shell.js.map +1 -0
  204. package/dist/src/integrations/react.d.ts +139 -0
  205. package/dist/src/integrations/react.d.ts.map +1 -0
  206. package/dist/src/integrations/react.js +273 -0
  207. package/dist/src/integrations/react.js.map +1 -0
  208. package/dist/src/integrations/resources.d.ts +177 -0
  209. package/dist/src/integrations/resources.d.ts.map +1 -0
  210. package/dist/src/integrations/resources.js +311 -0
  211. package/dist/src/integrations/resources.js.map +1 -0
  212. package/dist/src/integrations/result-synthesizer.d.ts +389 -0
  213. package/dist/src/integrations/result-synthesizer.d.ts.map +1 -0
  214. package/dist/src/integrations/result-synthesizer.js +951 -0
  215. package/dist/src/integrations/result-synthesizer.js.map +1 -0
  216. package/dist/src/integrations/routing.d.ts +117 -0
  217. package/dist/src/integrations/routing.d.ts.map +1 -0
  218. package/dist/src/integrations/routing.js +347 -0
  219. package/dist/src/integrations/routing.js.map +1 -0
  220. package/dist/src/integrations/rules.d.ts +131 -0
  221. package/dist/src/integrations/rules.d.ts.map +1 -0
  222. package/dist/src/integrations/rules.js +284 -0
  223. package/dist/src/integrations/rules.js.map +1 -0
  224. package/dist/src/integrations/safety.d.ts +142 -0
  225. package/dist/src/integrations/safety.d.ts.map +1 -0
  226. package/dist/src/integrations/safety.js +342 -0
  227. package/dist/src/integrations/safety.js.map +1 -0
  228. package/dist/src/integrations/sandbox/basic.d.ts +74 -0
  229. package/dist/src/integrations/sandbox/basic.d.ts.map +1 -0
  230. package/dist/src/integrations/sandbox/basic.js +310 -0
  231. package/dist/src/integrations/sandbox/basic.js.map +1 -0
  232. package/dist/src/integrations/sandbox/docker.d.ts +94 -0
  233. package/dist/src/integrations/sandbox/docker.d.ts.map +1 -0
  234. package/dist/src/integrations/sandbox/docker.js +293 -0
  235. package/dist/src/integrations/sandbox/docker.js.map +1 -0
  236. package/dist/src/integrations/sandbox/index.d.ts +182 -0
  237. package/dist/src/integrations/sandbox/index.d.ts.map +1 -0
  238. package/dist/src/integrations/sandbox/index.js +382 -0
  239. package/dist/src/integrations/sandbox/index.js.map +1 -0
  240. package/dist/src/integrations/sandbox/landlock.d.ts +59 -0
  241. package/dist/src/integrations/sandbox/landlock.d.ts.map +1 -0
  242. package/dist/src/integrations/sandbox/landlock.js +326 -0
  243. package/dist/src/integrations/sandbox/landlock.js.map +1 -0
  244. package/dist/src/integrations/sandbox/seatbelt.d.ts +68 -0
  245. package/dist/src/integrations/sandbox/seatbelt.d.ts.map +1 -0
  246. package/dist/src/integrations/sandbox/seatbelt.js +298 -0
  247. package/dist/src/integrations/sandbox/seatbelt.js.map +1 -0
  248. package/dist/src/integrations/semantic-cache.d.ts +178 -0
  249. package/dist/src/integrations/semantic-cache.d.ts.map +1 -0
  250. package/dist/src/integrations/semantic-cache.js +372 -0
  251. package/dist/src/integrations/semantic-cache.js.map +1 -0
  252. package/dist/src/integrations/session-store.d.ts +183 -0
  253. package/dist/src/integrations/session-store.d.ts.map +1 -0
  254. package/dist/src/integrations/session-store.js +345 -0
  255. package/dist/src/integrations/session-store.js.map +1 -0
  256. package/dist/src/integrations/shared-blackboard.d.ts +403 -0
  257. package/dist/src/integrations/shared-blackboard.d.ts.map +1 -0
  258. package/dist/src/integrations/shared-blackboard.js +710 -0
  259. package/dist/src/integrations/shared-blackboard.js.map +1 -0
  260. package/dist/src/integrations/skills.d.ts +171 -0
  261. package/dist/src/integrations/skills.d.ts.map +1 -0
  262. package/dist/src/integrations/skills.js +403 -0
  263. package/dist/src/integrations/skills.js.map +1 -0
  264. package/dist/src/integrations/smart-decomposer.d.ts +322 -0
  265. package/dist/src/integrations/smart-decomposer.d.ts.map +1 -0
  266. package/dist/src/integrations/smart-decomposer.js +856 -0
  267. package/dist/src/integrations/smart-decomposer.js.map +1 -0
  268. package/dist/src/integrations/sourcegraph.d.ts +169 -0
  269. package/dist/src/integrations/sourcegraph.d.ts.map +1 -0
  270. package/dist/src/integrations/sourcegraph.js +379 -0
  271. package/dist/src/integrations/sourcegraph.js.map +1 -0
  272. package/dist/src/integrations/sqlite-store.d.ts +518 -0
  273. package/dist/src/integrations/sqlite-store.d.ts.map +1 -0
  274. package/dist/src/integrations/sqlite-store.js +1423 -0
  275. package/dist/src/integrations/sqlite-store.js.map +1 -0
  276. package/dist/src/integrations/streaming.d.ts +102 -0
  277. package/dist/src/integrations/streaming.d.ts.map +1 -0
  278. package/dist/src/integrations/streaming.js +362 -0
  279. package/dist/src/integrations/streaming.js.map +1 -0
  280. package/dist/src/integrations/thread-manager.d.ts +199 -0
  281. package/dist/src/integrations/thread-manager.d.ts.map +1 -0
  282. package/dist/src/integrations/thread-manager.js +357 -0
  283. package/dist/src/integrations/thread-manager.js.map +1 -0
  284. package/dist/src/main.d.ts +26 -0
  285. package/dist/src/main.d.ts.map +1 -0
  286. package/dist/src/main.js +170 -0
  287. package/dist/src/main.js.map +1 -0
  288. package/dist/src/modes/index.d.ts +10 -0
  289. package/dist/src/modes/index.d.ts.map +1 -0
  290. package/dist/src/modes/index.js +10 -0
  291. package/dist/src/modes/index.js.map +1 -0
  292. package/dist/src/modes/repl.d.ts +19 -0
  293. package/dist/src/modes/repl.d.ts.map +1 -0
  294. package/dist/src/modes/repl.js +393 -0
  295. package/dist/src/modes/repl.js.map +1 -0
  296. package/dist/src/modes/tui.d.ts +29 -0
  297. package/dist/src/modes/tui.d.ts.map +1 -0
  298. package/dist/src/modes/tui.js +272 -0
  299. package/dist/src/modes/tui.js.map +1 -0
  300. package/dist/src/modes.d.ts +179 -0
  301. package/dist/src/modes.d.ts.map +1 -0
  302. package/dist/src/modes.js +385 -0
  303. package/dist/src/modes.js.map +1 -0
  304. package/dist/src/observability/tracer.d.ts +111 -0
  305. package/dist/src/observability/tracer.d.ts.map +1 -0
  306. package/dist/src/observability/tracer.js +300 -0
  307. package/dist/src/observability/tracer.js.map +1 -0
  308. package/dist/src/observability/types.d.ts +271 -0
  309. package/dist/src/observability/types.d.ts.map +1 -0
  310. package/dist/src/observability/types.js +24 -0
  311. package/dist/src/observability/types.js.map +1 -0
  312. package/dist/src/paths.d.ts +101 -0
  313. package/dist/src/paths.d.ts.map +1 -0
  314. package/dist/src/paths.js +148 -0
  315. package/dist/src/paths.js.map +1 -0
  316. package/dist/src/persistence/index.d.ts +38 -0
  317. package/dist/src/persistence/index.d.ts.map +1 -0
  318. package/dist/src/persistence/index.js +48 -0
  319. package/dist/src/persistence/index.js.map +1 -0
  320. package/dist/src/persistence/migrator.d.ts +135 -0
  321. package/dist/src/persistence/migrator.d.ts.map +1 -0
  322. package/dist/src/persistence/migrator.js +303 -0
  323. package/dist/src/persistence/migrator.js.map +1 -0
  324. package/dist/src/persistence/schema.d.ts +101 -0
  325. package/dist/src/persistence/schema.d.ts.map +1 -0
  326. package/dist/src/persistence/schema.js +395 -0
  327. package/dist/src/persistence/schema.js.map +1 -0
  328. package/dist/src/providers/adapters/anthropic.d.ts +20 -0
  329. package/dist/src/providers/adapters/anthropic.d.ts.map +1 -0
  330. package/dist/src/providers/adapters/anthropic.js +124 -0
  331. package/dist/src/providers/adapters/anthropic.js.map +1 -0
  332. package/dist/src/providers/adapters/mock.d.ts +25 -0
  333. package/dist/src/providers/adapters/mock.d.ts.map +1 -0
  334. package/dist/src/providers/adapters/mock.js +133 -0
  335. package/dist/src/providers/adapters/mock.js.map +1 -0
  336. package/dist/src/providers/adapters/openai.d.ts +21 -0
  337. package/dist/src/providers/adapters/openai.d.ts.map +1 -0
  338. package/dist/src/providers/adapters/openai.js +126 -0
  339. package/dist/src/providers/adapters/openai.js.map +1 -0
  340. package/dist/src/providers/adapters/openrouter.d.ts +49 -0
  341. package/dist/src/providers/adapters/openrouter.d.ts.map +1 -0
  342. package/dist/src/providers/adapters/openrouter.js +363 -0
  343. package/dist/src/providers/adapters/openrouter.js.map +1 -0
  344. package/dist/src/providers/provider.d.ts +54 -0
  345. package/dist/src/providers/provider.d.ts.map +1 -0
  346. package/dist/src/providers/provider.js +111 -0
  347. package/dist/src/providers/provider.js.map +1 -0
  348. package/dist/src/providers/resilient-fetch.d.ts +99 -0
  349. package/dist/src/providers/resilient-fetch.d.ts.map +1 -0
  350. package/dist/src/providers/resilient-fetch.js +208 -0
  351. package/dist/src/providers/resilient-fetch.js.map +1 -0
  352. package/dist/src/providers/types.d.ts +227 -0
  353. package/dist/src/providers/types.d.ts.map +1 -0
  354. package/dist/src/providers/types.js +24 -0
  355. package/dist/src/providers/types.js.map +1 -0
  356. package/dist/src/session-picker.d.ts +28 -0
  357. package/dist/src/session-picker.d.ts.map +1 -0
  358. package/dist/src/session-picker.js +256 -0
  359. package/dist/src/session-picker.js.map +1 -0
  360. package/dist/src/test-sqlite.d.ts +2 -0
  361. package/dist/src/test-sqlite.d.ts.map +1 -0
  362. package/dist/src/test-sqlite.js +114 -0
  363. package/dist/src/test-sqlite.js.map +1 -0
  364. package/dist/src/tools/agent.d.ts +44 -0
  365. package/dist/src/tools/agent.d.ts.map +1 -0
  366. package/dist/src/tools/agent.js +110 -0
  367. package/dist/src/tools/agent.js.map +1 -0
  368. package/dist/src/tools/bash.d.ts +52 -0
  369. package/dist/src/tools/bash.d.ts.map +1 -0
  370. package/dist/src/tools/bash.js +141 -0
  371. package/dist/src/tools/bash.js.map +1 -0
  372. package/dist/src/tools/file.d.ts +47 -0
  373. package/dist/src/tools/file.d.ts.map +1 -0
  374. package/dist/src/tools/file.js +263 -0
  375. package/dist/src/tools/file.js.map +1 -0
  376. package/dist/src/tools/permission.d.ts +43 -0
  377. package/dist/src/tools/permission.d.ts.map +1 -0
  378. package/dist/src/tools/permission.js +216 -0
  379. package/dist/src/tools/permission.js.map +1 -0
  380. package/dist/src/tools/registry.d.ts +63 -0
  381. package/dist/src/tools/registry.d.ts.map +1 -0
  382. package/dist/src/tools/registry.js +250 -0
  383. package/dist/src/tools/registry.js.map +1 -0
  384. package/dist/src/tools/standard.d.ts +57 -0
  385. package/dist/src/tools/standard.d.ts.map +1 -0
  386. package/dist/src/tools/standard.js +113 -0
  387. package/dist/src/tools/standard.js.map +1 -0
  388. package/dist/src/tools/types.d.ts +146 -0
  389. package/dist/src/tools/types.d.ts.map +1 -0
  390. package/dist/src/tools/types.js +28 -0
  391. package/dist/src/tools/types.js.map +1 -0
  392. package/dist/src/tools/undo.d.ts +71 -0
  393. package/dist/src/tools/undo.d.ts.map +1 -0
  394. package/dist/src/tools/undo.js +123 -0
  395. package/dist/src/tools/undo.js.map +1 -0
  396. package/dist/src/tracing/cache-boundary-tracker.d.ts +189 -0
  397. package/dist/src/tracing/cache-boundary-tracker.d.ts.map +1 -0
  398. package/dist/src/tracing/cache-boundary-tracker.js +411 -0
  399. package/dist/src/tracing/cache-boundary-tracker.js.map +1 -0
  400. package/dist/src/tracing/trace-collector.d.ts +274 -0
  401. package/dist/src/tracing/trace-collector.d.ts.map +1 -0
  402. package/dist/src/tracing/trace-collector.js +727 -0
  403. package/dist/src/tracing/trace-collector.js.map +1 -0
  404. package/dist/src/tracing/types.d.ts +657 -0
  405. package/dist/src/tracing/types.d.ts.map +1 -0
  406. package/dist/src/tracing/types.js +39 -0
  407. package/dist/src/tracing/types.js.map +1 -0
  408. package/dist/src/tricks/failure-evidence.d.ts +268 -0
  409. package/dist/src/tricks/failure-evidence.d.ts.map +1 -0
  410. package/dist/src/tricks/failure-evidence.js +544 -0
  411. package/dist/src/tricks/failure-evidence.js.map +1 -0
  412. package/dist/src/tricks/json-utils.d.ts +77 -0
  413. package/dist/src/tricks/json-utils.d.ts.map +1 -0
  414. package/dist/src/tricks/json-utils.js +247 -0
  415. package/dist/src/tricks/json-utils.js.map +1 -0
  416. package/dist/src/tricks/kv-cache-context.d.ts +227 -0
  417. package/dist/src/tricks/kv-cache-context.d.ts.map +1 -0
  418. package/dist/src/tricks/kv-cache-context.js +377 -0
  419. package/dist/src/tricks/kv-cache-context.js.map +1 -0
  420. package/dist/src/tricks/recitation.d.ts +208 -0
  421. package/dist/src/tricks/recitation.d.ts.map +1 -0
  422. package/dist/src/tricks/recitation.js +374 -0
  423. package/dist/src/tricks/recitation.js.map +1 -0
  424. package/dist/src/tricks/reversible-compaction.d.ts +251 -0
  425. package/dist/src/tricks/reversible-compaction.d.ts.map +1 -0
  426. package/dist/src/tricks/reversible-compaction.js +555 -0
  427. package/dist/src/tricks/reversible-compaction.js.map +1 -0
  428. package/dist/src/tricks/serialization-diversity.d.ts +197 -0
  429. package/dist/src/tricks/serialization-diversity.d.ts.map +1 -0
  430. package/dist/src/tricks/serialization-diversity.js +460 -0
  431. package/dist/src/tricks/serialization-diversity.js.map +1 -0
  432. package/dist/src/tui/app.d.ts +42 -0
  433. package/dist/src/tui/app.d.ts.map +1 -0
  434. package/dist/src/tui/app.js +1076 -0
  435. package/dist/src/tui/app.js.map +1 -0
  436. package/dist/src/tui/components/ApprovalDialog.d.ts +28 -0
  437. package/dist/src/tui/components/ApprovalDialog.d.ts.map +1 -0
  438. package/dist/src/tui/components/ApprovalDialog.js +59 -0
  439. package/dist/src/tui/components/ApprovalDialog.js.map +1 -0
  440. package/dist/src/tui/components/InputArea.d.ts +35 -0
  441. package/dist/src/tui/components/InputArea.d.ts.map +1 -0
  442. package/dist/src/tui/components/InputArea.js +144 -0
  443. package/dist/src/tui/components/InputArea.js.map +1 -0
  444. package/dist/src/tui/components/MessageItem.d.ts +28 -0
  445. package/dist/src/tui/components/MessageItem.d.ts.map +1 -0
  446. package/dist/src/tui/components/MessageItem.js +27 -0
  447. package/dist/src/tui/components/MessageItem.js.map +1 -0
  448. package/dist/src/tui/components/ScrollableBox.d.ts +41 -0
  449. package/dist/src/tui/components/ScrollableBox.d.ts.map +1 -0
  450. package/dist/src/tui/components/ScrollableBox.js +101 -0
  451. package/dist/src/tui/components/ScrollableBox.js.map +1 -0
  452. package/dist/src/tui/components/ToolCallItem.d.ts +33 -0
  453. package/dist/src/tui/components/ToolCallItem.d.ts.map +1 -0
  454. package/dist/src/tui/components/ToolCallItem.js +91 -0
  455. package/dist/src/tui/components/ToolCallItem.js.map +1 -0
  456. package/dist/src/tui/components/index.d.ts +13 -0
  457. package/dist/src/tui/components/index.d.ts.map +1 -0
  458. package/dist/src/tui/components/index.js +15 -0
  459. package/dist/src/tui/components/index.js.map +1 -0
  460. package/dist/src/tui/event-display.d.ts +19 -0
  461. package/dist/src/tui/event-display.d.ts.map +1 -0
  462. package/dist/src/tui/event-display.js +178 -0
  463. package/dist/src/tui/event-display.js.map +1 -0
  464. package/dist/src/tui/index.d.ts +105 -0
  465. package/dist/src/tui/index.d.ts.map +1 -0
  466. package/dist/src/tui/index.js +214 -0
  467. package/dist/src/tui/index.js.map +1 -0
  468. package/dist/src/tui/input/CommandPalette.d.ts +55 -0
  469. package/dist/src/tui/input/CommandPalette.d.ts.map +1 -0
  470. package/dist/src/tui/input/CommandPalette.js +135 -0
  471. package/dist/src/tui/input/CommandPalette.js.map +1 -0
  472. package/dist/src/tui/input/index.d.ts +7 -0
  473. package/dist/src/tui/input/index.d.ts.map +1 -0
  474. package/dist/src/tui/input/index.js +7 -0
  475. package/dist/src/tui/input/index.js.map +1 -0
  476. package/dist/src/tui/theme/index.d.ts +45 -0
  477. package/dist/src/tui/theme/index.d.ts.map +1 -0
  478. package/dist/src/tui/theme/index.js +215 -0
  479. package/dist/src/tui/theme/index.js.map +1 -0
  480. package/dist/src/tui/types.d.ts +214 -0
  481. package/dist/src/tui/types.d.ts.map +1 -0
  482. package/dist/src/tui/types.js +27 -0
  483. package/dist/src/tui/types.js.map +1 -0
  484. package/dist/src/types.d.ts +905 -0
  485. package/dist/src/types.d.ts.map +1 -0
  486. package/dist/src/types.js +9 -0
  487. package/dist/src/types.js.map +1 -0
  488. package/package.json +89 -0
@@ -0,0 +1,555 @@
1
+ /**
2
+ * Trick R: Reversible Compaction
3
+ *
4
+ * Preserves "reconstruction recipes" during context compaction.
5
+ * Instead of discarding information, store retrieval keys so the model
6
+ * can fetch details when needed.
7
+ *
8
+ * Problem: Traditional compaction loses important details forever.
9
+ * When a file path or URL is summarized away, the model can't recover it.
10
+ *
11
+ * Solution: Extract and preserve references (URLs, file paths, function names)
12
+ * as "reconstruction recipes" - minimal keys that enable re-retrieval.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { createReversibleCompactor, extractReferences } from './reversible-compaction';
17
+ *
18
+ * const compactor = createReversibleCompactor({
19
+ * preserveTypes: ['file', 'url', 'function', 'error'],
20
+ * maxReferences: 50,
21
+ * });
22
+ *
23
+ * // Compact with reference preservation
24
+ * const result = compactor.compact(messages, {
25
+ * summarize: async (msgs) => summarizeLLM(msgs),
26
+ * });
27
+ *
28
+ * console.log(result.summary); // Condensed summary
29
+ * console.log(result.references); // Preserved references for retrieval
30
+ * ```
31
+ */
32
+ // =============================================================================
33
+ // REFERENCE EXTRACTION
34
+ // =============================================================================
35
+ /**
36
+ * Extract file path references from content.
37
+ */
38
+ export function extractFileReferences(content, sourceIndex) {
39
+ const references = [];
40
+ const timestamp = new Date().toISOString();
41
+ // Unix-style paths
42
+ const unixPaths = content.match(/(?:\/[\w.-]+)+(?:\/[\w.-]*)?/g) || [];
43
+ // Windows-style paths
44
+ const windowsPaths = content.match(/[A-Za-z]:\\(?:[\w.-]+\\)*[\w.-]*/g) || [];
45
+ // Relative paths with extensions
46
+ const relativePaths = content.match(/(?:\.\.?\/)?[\w-]+(?:\/[\w.-]+)*\.\w+/g) || [];
47
+ const allPaths = [...new Set([...unixPaths, ...windowsPaths, ...relativePaths])];
48
+ for (const path of allPaths) {
49
+ // Filter out obvious non-paths
50
+ if (path.length < 3 || path === '/' || path.match(/^\/\d+$/))
51
+ continue;
52
+ references.push({
53
+ id: `file-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
54
+ type: 'file',
55
+ value: path,
56
+ timestamp,
57
+ sourceIndex,
58
+ });
59
+ }
60
+ return references;
61
+ }
62
+ /**
63
+ * Extract URL references from content.
64
+ */
65
+ export function extractUrlReferences(content, sourceIndex) {
66
+ const references = [];
67
+ const timestamp = new Date().toISOString();
68
+ // Full URLs
69
+ const urlPattern = /https?:\/\/[^\s<>"{}|\\^`\[\]]+/g;
70
+ const urls = content.match(urlPattern) || [];
71
+ for (const url of urls) {
72
+ // Clean trailing punctuation
73
+ const cleanUrl = url.replace(/[.,;:!?)]+$/, '');
74
+ // Extract context from URL
75
+ let context;
76
+ if (cleanUrl.includes('github.com')) {
77
+ context = 'GitHub';
78
+ if (cleanUrl.includes('/issues/'))
79
+ context += ' Issue';
80
+ if (cleanUrl.includes('/pull/'))
81
+ context += ' PR';
82
+ }
83
+ else if (cleanUrl.includes('stackoverflow.com')) {
84
+ context = 'Stack Overflow';
85
+ }
86
+ else if (cleanUrl.includes('docs.')) {
87
+ context = 'Documentation';
88
+ }
89
+ references.push({
90
+ id: `url-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
91
+ type: 'url',
92
+ value: cleanUrl,
93
+ context,
94
+ timestamp,
95
+ sourceIndex,
96
+ });
97
+ }
98
+ return references;
99
+ }
100
+ /**
101
+ * Extract function/method references from content.
102
+ */
103
+ export function extractFunctionReferences(content, sourceIndex) {
104
+ const references = [];
105
+ const timestamp = new Date().toISOString();
106
+ // Function definitions
107
+ const funcDefs = content.match(/(?:function|async function|const|let|var)\s+(\w+)\s*(?:=\s*(?:async\s*)?\([^)]*\)\s*=>|\([^)]*\))/g) || [];
108
+ // Method calls with meaningful names
109
+ const methodCalls = content.match(/\b([a-z][a-zA-Z0-9]*(?:[A-Z][a-zA-Z0-9]*)+)\s*\(/g) || [];
110
+ const seen = new Set();
111
+ for (const match of funcDefs) {
112
+ const name = match.match(/(?:function|const|let|var)\s+(\w+)/)?.[1];
113
+ if (name && !seen.has(name) && name.length > 2) {
114
+ seen.add(name);
115
+ references.push({
116
+ id: `func-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
117
+ type: 'function',
118
+ value: name,
119
+ context: 'definition',
120
+ timestamp,
121
+ sourceIndex,
122
+ });
123
+ }
124
+ }
125
+ for (const match of methodCalls) {
126
+ const name = match.replace(/\s*\($/, '');
127
+ if (!seen.has(name) && name.length > 2) {
128
+ seen.add(name);
129
+ references.push({
130
+ id: `func-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
131
+ type: 'function',
132
+ value: name,
133
+ context: 'call',
134
+ timestamp,
135
+ sourceIndex,
136
+ });
137
+ }
138
+ }
139
+ return references;
140
+ }
141
+ /**
142
+ * Extract error references from content.
143
+ */
144
+ export function extractErrorReferences(content, sourceIndex) {
145
+ const references = [];
146
+ const timestamp = new Date().toISOString();
147
+ // Error class names
148
+ const errorClasses = content.match(/\b(\w+Error|\w+Exception)\b/g) || [];
149
+ // Error messages (e.g., "Error: something went wrong")
150
+ const errorMessages = content.match(/(?:Error|Exception|Failed|Failure):\s*[^\n]+/g) || [];
151
+ const seen = new Set();
152
+ for (const errorClass of errorClasses) {
153
+ if (!seen.has(errorClass)) {
154
+ seen.add(errorClass);
155
+ references.push({
156
+ id: `error-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
157
+ type: 'error',
158
+ value: errorClass,
159
+ context: 'error type',
160
+ timestamp,
161
+ sourceIndex,
162
+ });
163
+ }
164
+ }
165
+ for (const errorMsg of errorMessages.slice(0, 3)) { // Limit error messages
166
+ const truncated = errorMsg.slice(0, 100);
167
+ if (!seen.has(truncated)) {
168
+ seen.add(truncated);
169
+ references.push({
170
+ id: `error-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
171
+ type: 'error',
172
+ value: truncated,
173
+ context: 'error message',
174
+ timestamp,
175
+ sourceIndex,
176
+ });
177
+ }
178
+ }
179
+ return references;
180
+ }
181
+ /**
182
+ * Extract command references from content.
183
+ */
184
+ export function extractCommandReferences(content, sourceIndex) {
185
+ const references = [];
186
+ const timestamp = new Date().toISOString();
187
+ // Shell commands (common patterns)
188
+ const shellPatterns = [
189
+ /\$\s*([^\n]+)/g, // $ command
190
+ /```(?:bash|sh|shell)\n([^`]+)```/g, // Code blocks
191
+ /(?:npm|yarn|pnpm|npx|bun)\s+[^\n]+/g, // Package managers
192
+ /(?:git)\s+[^\n]+/g, // Git commands
193
+ /(?:docker|kubectl)\s+[^\n]+/g, // Container commands
194
+ ];
195
+ const seen = new Set();
196
+ for (const pattern of shellPatterns) {
197
+ const matches = content.match(pattern) || [];
198
+ for (const match of matches) {
199
+ const cleaned = match.replace(/^\$\s*/, '').replace(/```(?:bash|sh|shell)?\n?/g, '').trim();
200
+ if (cleaned.length > 3 && !seen.has(cleaned)) {
201
+ seen.add(cleaned);
202
+ references.push({
203
+ id: `cmd-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
204
+ type: 'command',
205
+ value: cleaned.slice(0, 200), // Truncate long commands
206
+ timestamp,
207
+ sourceIndex,
208
+ });
209
+ }
210
+ }
211
+ }
212
+ return references;
213
+ }
214
+ /**
215
+ * Extract all references from content.
216
+ */
217
+ export function extractReferences(content, types, sourceIndex, customExtractors) {
218
+ const references = [];
219
+ for (const type of types) {
220
+ // Check for custom extractor first
221
+ if (customExtractors?.has(type)) {
222
+ const extractor = customExtractors.get(type);
223
+ references.push(...extractor(content, sourceIndex ?? 0));
224
+ continue;
225
+ }
226
+ // Use built-in extractors
227
+ switch (type) {
228
+ case 'file':
229
+ references.push(...extractFileReferences(content, sourceIndex));
230
+ break;
231
+ case 'url':
232
+ references.push(...extractUrlReferences(content, sourceIndex));
233
+ break;
234
+ case 'function':
235
+ references.push(...extractFunctionReferences(content, sourceIndex));
236
+ break;
237
+ case 'error':
238
+ references.push(...extractErrorReferences(content, sourceIndex));
239
+ break;
240
+ case 'command':
241
+ references.push(...extractCommandReferences(content, sourceIndex));
242
+ break;
243
+ // class, snippet, decision, custom require custom extractors
244
+ }
245
+ }
246
+ return references;
247
+ }
248
+ // =============================================================================
249
+ // REVERSIBLE COMPACTOR
250
+ // =============================================================================
251
+ /**
252
+ * Manages reversible context compaction.
253
+ */
254
+ export class ReversibleCompactor {
255
+ config;
256
+ preservedReferences = [];
257
+ listeners = [];
258
+ constructor(config) {
259
+ this.config = {
260
+ preserveTypes: config.preserveTypes,
261
+ maxReferences: config.maxReferences ?? 100,
262
+ deduplicate: config.deduplicate ?? true,
263
+ customExtractors: config.customExtractors ?? new Map(),
264
+ minRelevance: config.minRelevance ?? 0,
265
+ };
266
+ }
267
+ /**
268
+ * Compact messages while preserving references.
269
+ */
270
+ async compact(messages, options) {
271
+ this.emit({ type: 'compaction.started', messageCount: messages.length });
272
+ // Calculate original token estimate
273
+ const originalContent = messages.map(m => m.content).join('\n');
274
+ const originalTokens = Math.ceil(originalContent.length / 4);
275
+ // Extract references from all messages
276
+ const allReferences = [];
277
+ for (let i = 0; i < messages.length; i++) {
278
+ const refs = extractReferences(messages[i].content, this.config.preserveTypes, i, this.config.customExtractors);
279
+ for (const ref of refs) {
280
+ this.emit({ type: 'reference.extracted', reference: ref });
281
+ allReferences.push(ref);
282
+ }
283
+ }
284
+ // Deduplicate if enabled
285
+ let processedReferences = allReferences;
286
+ if (this.config.deduplicate) {
287
+ processedReferences = this.deduplicateReferences(allReferences);
288
+ }
289
+ // Filter by relevance
290
+ if (this.config.minRelevance > 0) {
291
+ processedReferences = processedReferences.filter(r => (r.relevance ?? 1) >= this.config.minRelevance);
292
+ }
293
+ // Limit references
294
+ if (processedReferences.length > this.config.maxReferences) {
295
+ // Sort by relevance, keep most relevant
296
+ processedReferences.sort((a, b) => (b.relevance ?? 0.5) - (a.relevance ?? 0.5));
297
+ processedReferences = processedReferences.slice(0, this.config.maxReferences);
298
+ }
299
+ // Generate summary
300
+ const summary = await options.summarize(messages);
301
+ // Calculate compacted token estimate
302
+ const referenceBlock = this.formatReferencesBlock(processedReferences);
303
+ const compactedContent = summary + '\n\n' + referenceBlock;
304
+ const compactedTokens = Math.ceil(compactedContent.length / 4);
305
+ // Store preserved references
306
+ this.preservedReferences = processedReferences;
307
+ const stats = {
308
+ originalMessages: messages.length,
309
+ originalTokens,
310
+ compactedTokens,
311
+ referencesExtracted: allReferences.length,
312
+ referencesPreserved: processedReferences.length,
313
+ compressionRatio: compactedTokens / originalTokens,
314
+ };
315
+ this.emit({ type: 'compaction.completed', stats });
316
+ return {
317
+ summary,
318
+ references: processedReferences,
319
+ stats,
320
+ };
321
+ }
322
+ /**
323
+ * Format references as a block for inclusion in context.
324
+ */
325
+ formatReferencesBlock(references) {
326
+ if (references.length === 0)
327
+ return '';
328
+ const grouped = new Map();
329
+ for (const ref of references) {
330
+ const group = grouped.get(ref.type) || [];
331
+ group.push(ref);
332
+ grouped.set(ref.type, group);
333
+ }
334
+ const parts = ['[Preserved References]'];
335
+ for (const [type, refs] of grouped) {
336
+ parts.push(`\n${type.toUpperCase()}S:`);
337
+ for (const ref of refs) {
338
+ const contextPart = ref.context ? ` (${ref.context})` : '';
339
+ parts.push(` - ${ref.value}${contextPart}`);
340
+ }
341
+ }
342
+ return parts.join('\n');
343
+ }
344
+ /**
345
+ * Get a reference by ID.
346
+ */
347
+ getReference(id) {
348
+ return this.preservedReferences.find(r => r.id === id);
349
+ }
350
+ /**
351
+ * Get references by type.
352
+ */
353
+ getReferencesByType(type) {
354
+ return this.preservedReferences.filter(r => r.type === type);
355
+ }
356
+ /**
357
+ * Search references by value.
358
+ */
359
+ searchReferences(query) {
360
+ const lowerQuery = query.toLowerCase();
361
+ return this.preservedReferences.filter(r => r.value.toLowerCase().includes(lowerQuery));
362
+ }
363
+ /**
364
+ * Get all preserved references.
365
+ */
366
+ getPreservedReferences() {
367
+ return [...this.preservedReferences];
368
+ }
369
+ /**
370
+ * Clear preserved references.
371
+ */
372
+ clear() {
373
+ this.preservedReferences = [];
374
+ }
375
+ /**
376
+ * Subscribe to events.
377
+ */
378
+ on(listener) {
379
+ this.listeners.push(listener);
380
+ return () => {
381
+ const idx = this.listeners.indexOf(listener);
382
+ if (idx >= 0)
383
+ this.listeners.splice(idx, 1);
384
+ };
385
+ }
386
+ // Internal methods
387
+ deduplicateReferences(references) {
388
+ const seen = new Map();
389
+ let removed = 0;
390
+ for (const ref of references) {
391
+ const key = `${ref.type}:${ref.value}`;
392
+ if (!seen.has(key)) {
393
+ seen.set(key, ref);
394
+ }
395
+ else {
396
+ removed++;
397
+ }
398
+ }
399
+ this.emit({
400
+ type: 'reference.deduplicated',
401
+ kept: seen.size,
402
+ removed,
403
+ });
404
+ return Array.from(seen.values());
405
+ }
406
+ emit(event) {
407
+ for (const listener of this.listeners) {
408
+ try {
409
+ listener(event);
410
+ }
411
+ catch {
412
+ // Ignore listener errors
413
+ }
414
+ }
415
+ }
416
+ }
417
+ // =============================================================================
418
+ // FACTORY FUNCTIONS
419
+ // =============================================================================
420
+ /**
421
+ * Create a reversible compactor.
422
+ *
423
+ * @example
424
+ * ```typescript
425
+ * const compactor = createReversibleCompactor({
426
+ * preserveTypes: ['file', 'url', 'error'],
427
+ * maxReferences: 50,
428
+ * deduplicate: true,
429
+ * });
430
+ *
431
+ * const result = await compactor.compact(messages, {
432
+ * summarize: async (msgs) => {
433
+ * // Use LLM to summarize
434
+ * return await llm.summarize(msgs);
435
+ * },
436
+ * });
437
+ *
438
+ * // Result includes both summary and preserved references
439
+ * console.log(result.summary);
440
+ * console.log(result.references);
441
+ *
442
+ * // Later, search for specific references
443
+ * const fileRefs = compactor.getReferencesByType('file');
444
+ * const errorRefs = compactor.searchReferences('TypeError');
445
+ * ```
446
+ */
447
+ export function createReversibleCompactor(config) {
448
+ return new ReversibleCompactor(config);
449
+ }
450
+ // =============================================================================
451
+ // UTILITIES
452
+ // =============================================================================
453
+ /**
454
+ * Quick helper to extract references without full compaction.
455
+ */
456
+ export function quickExtract(content, types = ['file', 'url', 'function', 'error']) {
457
+ return extractReferences(content, types);
458
+ }
459
+ /**
460
+ * Create a reconstruction prompt for re-fetching details.
461
+ */
462
+ export function createReconstructionPrompt(references) {
463
+ if (references.length === 0) {
464
+ return '';
465
+ }
466
+ const lines = [
467
+ 'The following references were preserved from earlier context.',
468
+ 'Use these to retrieve details if needed:',
469
+ '',
470
+ ];
471
+ const byType = new Map();
472
+ for (const ref of references) {
473
+ const group = byType.get(ref.type) || [];
474
+ group.push(ref);
475
+ byType.set(ref.type, group);
476
+ }
477
+ if (byType.has('file')) {
478
+ lines.push('**Files** (can be read with read_file tool):');
479
+ for (const ref of byType.get('file')) {
480
+ lines.push(` - ${ref.value}`);
481
+ }
482
+ lines.push('');
483
+ }
484
+ if (byType.has('url')) {
485
+ lines.push('**URLs** (can be fetched for details):');
486
+ for (const ref of byType.get('url')) {
487
+ const ctx = ref.context ? ` [${ref.context}]` : '';
488
+ lines.push(` - ${ref.value}${ctx}`);
489
+ }
490
+ lines.push('');
491
+ }
492
+ if (byType.has('function')) {
493
+ lines.push('**Functions** (search codebase if details needed):');
494
+ for (const ref of byType.get('function')) {
495
+ lines.push(` - ${ref.value}`);
496
+ }
497
+ lines.push('');
498
+ }
499
+ if (byType.has('error')) {
500
+ lines.push('**Errors encountered**:');
501
+ for (const ref of byType.get('error')) {
502
+ lines.push(` - ${ref.value}`);
503
+ }
504
+ lines.push('');
505
+ }
506
+ if (byType.has('command')) {
507
+ lines.push('**Commands used**:');
508
+ for (const ref of byType.get('command')) {
509
+ lines.push(` - ${ref.value}`);
510
+ }
511
+ }
512
+ return lines.join('\n');
513
+ }
514
+ /**
515
+ * Calculate relevance score for a reference based on context.
516
+ */
517
+ export function calculateRelevance(reference, context) {
518
+ let score = 0.5; // Base score
519
+ const value = reference.value.toLowerCase();
520
+ // Boost if matches goal
521
+ if (context.goal) {
522
+ const goalWords = context.goal.toLowerCase().split(/\s+/);
523
+ for (const word of goalWords) {
524
+ if (word.length > 3 && value.includes(word)) {
525
+ score += 0.1;
526
+ }
527
+ }
528
+ }
529
+ // Boost if matches recent topics
530
+ if (context.recentTopics) {
531
+ for (const topic of context.recentTopics) {
532
+ if (value.includes(topic.toLowerCase())) {
533
+ score += 0.15;
534
+ }
535
+ }
536
+ }
537
+ // Type-based adjustments
538
+ if (reference.type === 'error')
539
+ score += 0.1; // Errors are usually important
540
+ if (reference.type === 'file')
541
+ score += 0.05; // Files are often needed
542
+ return Math.min(1, score);
543
+ }
544
+ /**
545
+ * Format compaction stats for display.
546
+ */
547
+ export function formatCompactionStats(stats) {
548
+ const compressionPercent = Math.round((1 - stats.compressionRatio) * 100);
549
+ return `Compaction Statistics:
550
+ Original: ${stats.originalMessages} messages, ~${stats.originalTokens.toLocaleString()} tokens
551
+ Compacted: ~${stats.compactedTokens.toLocaleString()} tokens
552
+ Compression: ${compressionPercent}% reduction
553
+ References: ${stats.referencesExtracted} extracted, ${stats.referencesPreserved} preserved`;
554
+ }
555
+ //# sourceMappingURL=reversible-compaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reversible-compaction.js","sourceRoot":"","sources":["../../../src/tricks/reversible-compaction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AA2IH,gFAAgF;AAChF,uBAAuB;AACvB,gFAAgF;AAEhF;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAe,EAAE,WAAoB;IACzE,MAAM,UAAU,GAAgB,EAAE,CAAC;IACnC,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAE3C,mBAAmB;IACnB,M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