@roackb2/heddle 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (370) hide show
  1. package/README.md +273 -0
  2. package/dist/examples/conversation.d.ts +2 -0
  3. package/dist/examples/conversation.d.ts.map +1 -0
  4. package/dist/examples/conversation.js +3 -0
  5. package/dist/examples/conversation.js.map +1 -0
  6. package/dist/examples/repo-investigator.d.ts +2 -0
  7. package/dist/examples/repo-investigator.d.ts.map +1 -0
  8. package/dist/examples/repo-investigator.js +57 -0
  9. package/dist/examples/repo-investigator.js.map +1 -0
  10. package/dist/src/__tests__/chat-activity-format.test.d.ts +2 -0
  11. package/dist/src/__tests__/chat-activity-format.test.d.ts.map +1 -0
  12. package/dist/src/__tests__/chat-activity-format.test.js +41 -0
  13. package/dist/src/__tests__/chat-activity-format.test.js.map +1 -0
  14. package/dist/src/__tests__/chat-compaction.test.d.ts +2 -0
  15. package/dist/src/__tests__/chat-compaction.test.d.ts.map +1 -0
  16. package/dist/src/__tests__/chat-compaction.test.js +24 -0
  17. package/dist/src/__tests__/chat-compaction.test.js.map +1 -0
  18. package/dist/src/__tests__/chat-format.test.d.ts +2 -0
  19. package/dist/src/__tests__/chat-format.test.d.ts.map +1 -0
  20. package/dist/src/__tests__/chat-format.test.js +124 -0
  21. package/dist/src/__tests__/chat-format.test.js.map +1 -0
  22. package/dist/src/__tests__/chat-runtime.test.d.ts +2 -0
  23. package/dist/src/__tests__/chat-runtime.test.d.ts.map +1 -0
  24. package/dist/src/__tests__/chat-runtime.test.js +39 -0
  25. package/dist/src/__tests__/chat-runtime.test.js.map +1 -0
  26. package/dist/src/__tests__/core-utils.test.d.ts +2 -0
  27. package/dist/src/__tests__/core-utils.test.d.ts.map +1 -0
  28. package/dist/src/__tests__/core-utils.test.js +87 -0
  29. package/dist/src/__tests__/core-utils.test.js.map +1 -0
  30. package/dist/src/__tests__/llm-factory.test.d.ts +2 -0
  31. package/dist/src/__tests__/llm-factory.test.d.ts.map +1 -0
  32. package/dist/src/__tests__/llm-factory.test.js +45 -0
  33. package/dist/src/__tests__/llm-factory.test.js.map +1 -0
  34. package/dist/src/__tests__/local-commands.test.d.ts +2 -0
  35. package/dist/src/__tests__/local-commands.test.d.ts.map +1 -0
  36. package/dist/src/__tests__/local-commands.test.js +163 -0
  37. package/dist/src/__tests__/local-commands.test.js.map +1 -0
  38. package/dist/src/__tests__/project-approval-rules.test.d.ts +2 -0
  39. package/dist/src/__tests__/project-approval-rules.test.d.ts.map +1 -0
  40. package/dist/src/__tests__/project-approval-rules.test.js +135 -0
  41. package/dist/src/__tests__/project-approval-rules.test.js.map +1 -0
  42. package/dist/src/__tests__/prompts.test.d.ts +2 -0
  43. package/dist/src/__tests__/prompts.test.d.ts.map +1 -0
  44. package/dist/src/__tests__/prompts.test.js +43 -0
  45. package/dist/src/__tests__/prompts.test.js.map +1 -0
  46. package/dist/src/__tests__/run-agent.test.d.ts +2 -0
  47. package/dist/src/__tests__/run-agent.test.d.ts.map +1 -0
  48. package/dist/src/__tests__/run-agent.test.js +1276 -0
  49. package/dist/src/__tests__/run-agent.test.js.map +1 -0
  50. package/dist/src/__tests__/run-shell.command.test.d.ts +2 -0
  51. package/dist/src/__tests__/run-shell.command.test.d.ts.map +1 -0
  52. package/dist/src/__tests__/run-shell.command.test.js +188 -0
  53. package/dist/src/__tests__/run-shell.command.test.js.map +1 -0
  54. package/dist/src/__tests__/smoke.test.d.ts +2 -0
  55. package/dist/src/__tests__/smoke.test.d.ts.map +1 -0
  56. package/dist/src/__tests__/smoke.test.js +314 -0
  57. package/dist/src/__tests__/smoke.test.js.map +1 -0
  58. package/dist/src/__tests__/tools.test.d.ts +2 -0
  59. package/dist/src/__tests__/tools.test.d.ts.map +1 -0
  60. package/dist/src/__tests__/tools.test.js +557 -0
  61. package/dist/src/__tests__/tools.test.js.map +1 -0
  62. package/dist/src/__tests__/trace-format.test.d.ts +2 -0
  63. package/dist/src/__tests__/trace-format.test.d.ts.map +1 -0
  64. package/dist/src/__tests__/trace-format.test.js +148 -0
  65. package/dist/src/__tests__/trace-format.test.js.map +1 -0
  66. package/dist/src/cli/ask.d.ts +11 -0
  67. package/dist/src/cli/ask.d.ts.map +1 -0
  68. package/dist/src/cli/ask.js +59 -0
  69. package/dist/src/cli/ask.js.map +1 -0
  70. package/dist/src/cli/chat/App.d.ts +5 -0
  71. package/dist/src/cli/chat/App.d.ts.map +1 -0
  72. package/dist/src/cli/chat/App.js +348 -0
  73. package/dist/src/cli/chat/App.js.map +1 -0
  74. package/dist/src/cli/chat/actions.d.ts +47 -0
  75. package/dist/src/cli/chat/actions.d.ts.map +1 -0
  76. package/dist/src/cli/chat/actions.js +215 -0
  77. package/dist/src/cli/chat/actions.js.map +1 -0
  78. package/dist/src/cli/chat/components/ActivityPanel.d.ts +11 -0
  79. package/dist/src/cli/chat/components/ActivityPanel.d.ts.map +1 -0
  80. package/dist/src/cli/chat/components/ActivityPanel.js +20 -0
  81. package/dist/src/cli/chat/components/ActivityPanel.js.map +1 -0
  82. package/dist/src/cli/chat/components/ApprovalComposer.d.ts +6 -0
  83. package/dist/src/cli/chat/components/ApprovalComposer.d.ts.map +1 -0
  84. package/dist/src/cli/chat/components/ApprovalComposer.js +30 -0
  85. package/dist/src/cli/chat/components/ApprovalComposer.js.map +1 -0
  86. package/dist/src/cli/chat/components/CommandHintPanel.d.ts +5 -0
  87. package/dist/src/cli/chat/components/CommandHintPanel.d.ts.map +1 -0
  88. package/dist/src/cli/chat/components/CommandHintPanel.js +13 -0
  89. package/dist/src/cli/chat/components/CommandHintPanel.js.map +1 -0
  90. package/dist/src/cli/chat/components/ConversationPanel.d.ts +16 -0
  91. package/dist/src/cli/chat/components/ConversationPanel.d.ts.map +1 -0
  92. package/dist/src/cli/chat/components/ConversationPanel.js +218 -0
  93. package/dist/src/cli/chat/components/ConversationPanel.js.map +1 -0
  94. package/dist/src/cli/chat/components/ModelPickerPanel.d.ts +7 -0
  95. package/dist/src/cli/chat/components/ModelPickerPanel.d.ts.map +1 -0
  96. package/dist/src/cli/chat/components/ModelPickerPanel.js +32 -0
  97. package/dist/src/cli/chat/components/ModelPickerPanel.js.map +1 -0
  98. package/dist/src/cli/chat/components/PromptInput.d.ts +29 -0
  99. package/dist/src/cli/chat/components/PromptInput.d.ts.map +1 -0
  100. package/dist/src/cli/chat/components/PromptInput.js +132 -0
  101. package/dist/src/cli/chat/components/PromptInput.js.map +1 -0
  102. package/dist/src/cli/chat/components/RecentTurnsPanel.d.ts +5 -0
  103. package/dist/src/cli/chat/components/RecentTurnsPanel.d.ts.map +1 -0
  104. package/dist/src/cli/chat/components/RecentTurnsPanel.js +10 -0
  105. package/dist/src/cli/chat/components/RecentTurnsPanel.js.map +1 -0
  106. package/dist/src/cli/chat/components/SessionPickerPanel.d.ts +12 -0
  107. package/dist/src/cli/chat/components/SessionPickerPanel.d.ts.map +1 -0
  108. package/dist/src/cli/chat/components/SessionPickerPanel.js +32 -0
  109. package/dist/src/cli/chat/components/SessionPickerPanel.js.map +1 -0
  110. package/dist/src/cli/chat/components/SlashHintPanel.d.ts +8 -0
  111. package/dist/src/cli/chat/components/SlashHintPanel.d.ts.map +1 -0
  112. package/dist/src/cli/chat/components/SlashHintPanel.js +38 -0
  113. package/dist/src/cli/chat/components/SlashHintPanel.js.map +1 -0
  114. package/dist/src/cli/chat/components/index.d.ts +10 -0
  115. package/dist/src/cli/chat/components/index.d.ts.map +1 -0
  116. package/dist/src/cli/chat/components/index.js +10 -0
  117. package/dist/src/cli/chat/components/index.js.map +1 -0
  118. package/dist/src/cli/chat/format.d.ts +23 -0
  119. package/dist/src/cli/chat/format.d.ts.map +1 -0
  120. package/dist/src/cli/chat/format.js +243 -0
  121. package/dist/src/cli/chat/format.js.map +1 -0
  122. package/dist/src/cli/chat/hooks/useAgentRun.d.ts +61 -0
  123. package/dist/src/cli/chat/hooks/useAgentRun.d.ts.map +1 -0
  124. package/dist/src/cli/chat/hooks/useAgentRun.js +463 -0
  125. package/dist/src/cli/chat/hooks/useAgentRun.js.map +1 -0
  126. package/dist/src/cli/chat/hooks/useApprovalFlow.d.ts +31 -0
  127. package/dist/src/cli/chat/hooks/useApprovalFlow.d.ts.map +1 -0
  128. package/dist/src/cli/chat/hooks/useApprovalFlow.js +145 -0
  129. package/dist/src/cli/chat/hooks/useApprovalFlow.js.map +1 -0
  130. package/dist/src/cli/chat/hooks/useChatSessions.d.ts +23 -0
  131. package/dist/src/cli/chat/hooks/useChatSessions.d.ts.map +1 -0
  132. package/dist/src/cli/chat/hooks/useChatSessions.js +124 -0
  133. package/dist/src/cli/chat/hooks/useChatSessions.js.map +1 -0
  134. package/dist/src/cli/chat/hooks/useProjectApprovals.d.ts +8 -0
  135. package/dist/src/cli/chat/hooks/useProjectApprovals.d.ts.map +1 -0
  136. package/dist/src/cli/chat/hooks/useProjectApprovals.js +33 -0
  137. package/dist/src/cli/chat/hooks/useProjectApprovals.js.map +1 -0
  138. package/dist/src/cli/chat/index.d.ts +4 -0
  139. package/dist/src/cli/chat/index.d.ts.map +1 -0
  140. package/dist/src/cli/chat/index.js +9 -0
  141. package/dist/src/cli/chat/index.js.map +1 -0
  142. package/dist/src/cli/chat/local-commands.d.ts +17 -0
  143. package/dist/src/cli/chat/local-commands.d.ts.map +1 -0
  144. package/dist/src/cli/chat/local-commands.js +180 -0
  145. package/dist/src/cli/chat/local-commands.js.map +1 -0
  146. package/dist/src/cli/chat/panels.d.ts +37 -0
  147. package/dist/src/cli/chat/panels.d.ts.map +1 -0
  148. package/dist/src/cli/chat/panels.js +142 -0
  149. package/dist/src/cli/chat/panels.js.map +1 -0
  150. package/dist/src/cli/chat/runtime.d.ts +26 -0
  151. package/dist/src/cli/chat/runtime.d.ts.map +1 -0
  152. package/dist/src/cli/chat/runtime.js +28 -0
  153. package/dist/src/cli/chat/runtime.js.map +1 -0
  154. package/dist/src/cli/chat/state/approval-rules.d.ts +21 -0
  155. package/dist/src/cli/chat/state/approval-rules.d.ts.map +1 -0
  156. package/dist/src/cli/chat/state/approval-rules.js +196 -0
  157. package/dist/src/cli/chat/state/approval-rules.js.map +1 -0
  158. package/dist/src/cli/chat/state/compaction.d.ts +13 -0
  159. package/dist/src/cli/chat/state/compaction.d.ts.map +1 -0
  160. package/dist/src/cli/chat/state/compaction.js +143 -0
  161. package/dist/src/cli/chat/state/compaction.js.map +1 -0
  162. package/dist/src/cli/chat/state/local-commands.d.ts +17 -0
  163. package/dist/src/cli/chat/state/local-commands.d.ts.map +1 -0
  164. package/dist/src/cli/chat/state/local-commands.js +169 -0
  165. package/dist/src/cli/chat/state/local-commands.js.map +1 -0
  166. package/dist/src/cli/chat/state/storage.d.ts +14 -0
  167. package/dist/src/cli/chat/state/storage.d.ts.map +1 -0
  168. package/dist/src/cli/chat/state/storage.js +144 -0
  169. package/dist/src/cli/chat/state/storage.js.map +1 -0
  170. package/dist/src/cli/chat/state/types.d.ts +69 -0
  171. package/dist/src/cli/chat/state/types.d.ts.map +1 -0
  172. package/dist/src/cli/chat/state/types.js +2 -0
  173. package/dist/src/cli/chat/state/types.js.map +1 -0
  174. package/dist/src/cli/chat/storage.d.ts +13 -0
  175. package/dist/src/cli/chat/storage.d.ts.map +1 -0
  176. package/dist/src/cli/chat/storage.js +126 -0
  177. package/dist/src/cli/chat/storage.js.map +1 -0
  178. package/dist/src/cli/chat/submit.d.ts +28 -0
  179. package/dist/src/cli/chat/submit.d.ts.map +1 -0
  180. package/dist/src/cli/chat/submit.js +90 -0
  181. package/dist/src/cli/chat/submit.js.map +1 -0
  182. package/dist/src/cli/chat/types.d.ts +51 -0
  183. package/dist/src/cli/chat/types.d.ts.map +1 -0
  184. package/dist/src/cli/chat/types.js +2 -0
  185. package/dist/src/cli/chat/types.js.map +1 -0
  186. package/dist/src/cli/chat/use-run-state.d.ts +23 -0
  187. package/dist/src/cli/chat/use-run-state.d.ts.map +1 -0
  188. package/dist/src/cli/chat/use-run-state.js +118 -0
  189. package/dist/src/cli/chat/use-run-state.js.map +1 -0
  190. package/dist/src/cli/chat/use-sessions.d.ts +21 -0
  191. package/dist/src/cli/chat/use-sessions.d.ts.map +1 -0
  192. package/dist/src/cli/chat/use-sessions.js +111 -0
  193. package/dist/src/cli/chat/use-sessions.js.map +1 -0
  194. package/dist/src/cli/chat/utils/format.d.ts +41 -0
  195. package/dist/src/cli/chat/utils/format.d.ts.map +1 -0
  196. package/dist/src/cli/chat/utils/format.js +578 -0
  197. package/dist/src/cli/chat/utils/format.js.map +1 -0
  198. package/dist/src/cli/chat/utils/runtime.d.ts +31 -0
  199. package/dist/src/cli/chat/utils/runtime.d.ts.map +1 -0
  200. package/dist/src/cli/chat/utils/runtime.js +56 -0
  201. package/dist/src/cli/chat/utils/runtime.js.map +1 -0
  202. package/dist/src/cli/chat-actions.d.ts +47 -0
  203. package/dist/src/cli/chat-actions.d.ts.map +1 -0
  204. package/dist/src/cli/chat-actions.js +215 -0
  205. package/dist/src/cli/chat-actions.js.map +1 -0
  206. package/dist/src/cli/chat-format.d.ts +23 -0
  207. package/dist/src/cli/chat-format.d.ts.map +1 -0
  208. package/dist/src/cli/chat-format.js +243 -0
  209. package/dist/src/cli/chat-format.js.map +1 -0
  210. package/dist/src/cli/chat-local-commands.d.ts +17 -0
  211. package/dist/src/cli/chat-local-commands.d.ts.map +1 -0
  212. package/dist/src/cli/chat-local-commands.js +180 -0
  213. package/dist/src/cli/chat-local-commands.js.map +1 -0
  214. package/dist/src/cli/chat-panels.d.ts +37 -0
  215. package/dist/src/cli/chat-panels.d.ts.map +1 -0
  216. package/dist/src/cli/chat-panels.js +142 -0
  217. package/dist/src/cli/chat-panels.js.map +1 -0
  218. package/dist/src/cli/chat-runtime.d.ts +26 -0
  219. package/dist/src/cli/chat-runtime.d.ts.map +1 -0
  220. package/dist/src/cli/chat-runtime.js +28 -0
  221. package/dist/src/cli/chat-runtime.js.map +1 -0
  222. package/dist/src/cli/chat-storage.d.ts +13 -0
  223. package/dist/src/cli/chat-storage.d.ts.map +1 -0
  224. package/dist/src/cli/chat-storage.js +126 -0
  225. package/dist/src/cli/chat-storage.js.map +1 -0
  226. package/dist/src/cli/chat-submit.d.ts +28 -0
  227. package/dist/src/cli/chat-submit.d.ts.map +1 -0
  228. package/dist/src/cli/chat-submit.js +90 -0
  229. package/dist/src/cli/chat-submit.js.map +1 -0
  230. package/dist/src/cli/chat-types.d.ts +51 -0
  231. package/dist/src/cli/chat-types.d.ts.map +1 -0
  232. package/dist/src/cli/chat-types.js +2 -0
  233. package/dist/src/cli/chat-types.js.map +1 -0
  234. package/dist/src/cli/chat.d.ts +4 -0
  235. package/dist/src/cli/chat.d.ts.map +1 -0
  236. package/dist/src/cli/chat.js +153 -0
  237. package/dist/src/cli/chat.js.map +1 -0
  238. package/dist/src/cli/main.d.ts +3 -0
  239. package/dist/src/cli/main.d.ts.map +1 -0
  240. package/dist/src/cli/main.js +190 -0
  241. package/dist/src/cli/main.js.map +1 -0
  242. package/dist/src/cli/useChatRunState.d.ts +23 -0
  243. package/dist/src/cli/useChatRunState.d.ts.map +1 -0
  244. package/dist/src/cli/useChatRunState.js +118 -0
  245. package/dist/src/cli/useChatRunState.js.map +1 -0
  246. package/dist/src/cli/useChatSessions.d.ts +21 -0
  247. package/dist/src/cli/useChatSessions.d.ts.map +1 -0
  248. package/dist/src/cli/useChatSessions.js +111 -0
  249. package/dist/src/cli/useChatSessions.js.map +1 -0
  250. package/dist/src/config.d.ts +4 -0
  251. package/dist/src/config.d.ts.map +1 -0
  252. package/dist/src/config.js +7 -0
  253. package/dist/src/config.js.map +1 -0
  254. package/dist/src/index.d.ts +36 -0
  255. package/dist/src/index.d.ts.map +1 -0
  256. package/dist/src/index.js +31 -0
  257. package/dist/src/index.js.map +1 -0
  258. package/dist/src/llm/anthropic.d.ts +7 -0
  259. package/dist/src/llm/anthropic.d.ts.map +1 -0
  260. package/dist/src/llm/anthropic.js +115 -0
  261. package/dist/src/llm/anthropic.js.map +1 -0
  262. package/dist/src/llm/factory.d.ts +10 -0
  263. package/dist/src/llm/factory.d.ts.map +1 -0
  264. package/dist/src/llm/factory.js +53 -0
  265. package/dist/src/llm/factory.js.map +1 -0
  266. package/dist/src/llm/openai-models.d.ts +15 -0
  267. package/dist/src/llm/openai-models.d.ts.map +1 -0
  268. package/dist/src/llm/openai-models.js +97 -0
  269. package/dist/src/llm/openai-models.js.map +1 -0
  270. package/dist/src/llm/openai.d.ts +10 -0
  271. package/dist/src/llm/openai.d.ts.map +1 -0
  272. package/dist/src/llm/openai.js +170 -0
  273. package/dist/src/llm/openai.js.map +1 -0
  274. package/dist/src/llm/types.d.ts +64 -0
  275. package/dist/src/llm/types.d.ts.map +1 -0
  276. package/dist/src/llm/types.js +5 -0
  277. package/dist/src/llm/types.js.map +1 -0
  278. package/dist/src/prompts/system-prompt.d.ts +6 -0
  279. package/dist/src/prompts/system-prompt.d.ts.map +1 -0
  280. package/dist/src/prompts/system-prompt.js +117 -0
  281. package/dist/src/prompts/system-prompt.js.map +1 -0
  282. package/dist/src/run-agent/history.d.ts +3 -0
  283. package/dist/src/run-agent/history.d.ts.map +1 -0
  284. package/dist/src/run-agent/history.js +36 -0
  285. package/dist/src/run-agent/history.js.map +1 -0
  286. package/dist/src/run-agent/mutation-tracking.d.ts +22 -0
  287. package/dist/src/run-agent/mutation-tracking.d.ts.map +1 -0
  288. package/dist/src/run-agent/mutation-tracking.js +116 -0
  289. package/dist/src/run-agent/mutation-tracking.js.map +1 -0
  290. package/dist/src/run-agent/post-mutation.d.ts +23 -0
  291. package/dist/src/run-agent/post-mutation.d.ts.map +1 -0
  292. package/dist/src/run-agent/post-mutation.js +106 -0
  293. package/dist/src/run-agent/post-mutation.js.map +1 -0
  294. package/dist/src/run-agent/progress-reminders.d.ts +13 -0
  295. package/dist/src/run-agent/progress-reminders.d.ts.map +1 -0
  296. package/dist/src/run-agent/progress-reminders.js +65 -0
  297. package/dist/src/run-agent/progress-reminders.js.map +1 -0
  298. package/dist/src/run-agent/tool-dispatch.d.ts +31 -0
  299. package/dist/src/run-agent/tool-dispatch.d.ts.map +1 -0
  300. package/dist/src/run-agent/tool-dispatch.js +114 -0
  301. package/dist/src/run-agent/tool-dispatch.js.map +1 -0
  302. package/dist/src/run-agent/util.d.ts +10 -0
  303. package/dist/src/run-agent/util.d.ts.map +1 -0
  304. package/dist/src/run-agent/util.js +64 -0
  305. package/dist/src/run-agent/util.js.map +1 -0
  306. package/dist/src/run-agent.d.ts +36 -0
  307. package/dist/src/run-agent.d.ts.map +1 -0
  308. package/dist/src/run-agent.js +477 -0
  309. package/dist/src/run-agent.js.map +1 -0
  310. package/dist/src/tools/edit-file.d.ts +10 -0
  311. package/dist/src/tools/edit-file.d.ts.map +1 -0
  312. package/dist/src/tools/edit-file.js +268 -0
  313. package/dist/src/tools/edit-file.js.map +1 -0
  314. package/dist/src/tools/execute-tool.d.ts +8 -0
  315. package/dist/src/tools/execute-tool.d.ts.map +1 -0
  316. package/dist/src/tools/execute-tool.js +31 -0
  317. package/dist/src/tools/execute-tool.js.map +1 -0
  318. package/dist/src/tools/list-files.d.ts +3 -0
  319. package/dist/src/tools/list-files.d.ts.map +1 -0
  320. package/dist/src/tools/list-files.js +49 -0
  321. package/dist/src/tools/list-files.js.map +1 -0
  322. package/dist/src/tools/read-file.d.ts +3 -0
  323. package/dist/src/tools/read-file.d.ts.map +1 -0
  324. package/dist/src/tools/read-file.js +73 -0
  325. package/dist/src/tools/read-file.js.map +1 -0
  326. package/dist/src/tools/registry.d.ts +11 -0
  327. package/dist/src/tools/registry.d.ts.map +1 -0
  328. package/dist/src/tools/registry.js +27 -0
  329. package/dist/src/tools/registry.js.map +1 -0
  330. package/dist/src/tools/report-state.d.ts +3 -0
  331. package/dist/src/tools/report-state.d.ts.map +1 -0
  332. package/dist/src/tools/report-state.js +63 -0
  333. package/dist/src/tools/report-state.js.map +1 -0
  334. package/dist/src/tools/run-shell.d.ts +41 -0
  335. package/dist/src/tools/run-shell.d.ts.map +1 -0
  336. package/dist/src/tools/run-shell.js +407 -0
  337. package/dist/src/tools/run-shell.js.map +1 -0
  338. package/dist/src/tools/search-files.d.ts +8 -0
  339. package/dist/src/tools/search-files.d.ts.map +1 -0
  340. package/dist/src/tools/search-files.js +86 -0
  341. package/dist/src/tools/search-files.js.map +1 -0
  342. package/dist/src/tools/update-plan.d.ts +8 -0
  343. package/dist/src/tools/update-plan.d.ts.map +1 -0
  344. package/dist/src/tools/update-plan.js +85 -0
  345. package/dist/src/tools/update-plan.js.map +1 -0
  346. package/dist/src/trace/format.d.ts +6 -0
  347. package/dist/src/trace/format.d.ts.map +1 -0
  348. package/dist/src/trace/format.js +94 -0
  349. package/dist/src/trace/format.js.map +1 -0
  350. package/dist/src/trace/recorder.d.ts +11 -0
  351. package/dist/src/trace/recorder.d.ts.map +1 -0
  352. package/dist/src/trace/recorder.js +21 -0
  353. package/dist/src/trace/recorder.js.map +1 -0
  354. package/dist/src/types.d.ts +110 -0
  355. package/dist/src/types.d.ts.map +1 -0
  356. package/dist/src/types.js +6 -0
  357. package/dist/src/types.js.map +1 -0
  358. package/dist/src/utils/budget.d.ts +13 -0
  359. package/dist/src/utils/budget.d.ts.map +1 -0
  360. package/dist/src/utils/budget.js +22 -0
  361. package/dist/src/utils/budget.js.map +1 -0
  362. package/dist/src/utils/errors.d.ts +14 -0
  363. package/dist/src/utils/errors.d.ts.map +1 -0
  364. package/dist/src/utils/errors.js +31 -0
  365. package/dist/src/utils/errors.js.map +1 -0
  366. package/dist/src/utils/logger.d.ts +17 -0
  367. package/dist/src/utils/logger.d.ts.map +1 -0
  368. package/dist/src/utils/logger.js +50 -0
  369. package/dist/src/utils/logger.js.map +1 -0
  370. package/package.json +57 -0
@@ -0,0 +1,97 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Built-in model shortlist used by Heddle's current UI and local commands.
3
+ // Keep this curated rather than mirroring the entire provider catalog.
4
+ // ---------------------------------------------------------------------------
5
+ export const BUILT_IN_MODEL_GROUPS = [
6
+ {
7
+ label: 'OpenAI · GPT-5.4',
8
+ models: ['gpt-5.4', 'gpt-5.4-pro', 'gpt-5.4-mini', 'gpt-5.4-nano'],
9
+ },
10
+ {
11
+ label: 'OpenAI · GPT-5 family',
12
+ models: ['gpt-5', 'gpt-5-pro', 'gpt-5-mini', 'gpt-5-nano'],
13
+ },
14
+ {
15
+ label: 'OpenAI · Earlier GPT-5 releases',
16
+ models: ['gpt-5.2', 'gpt-5.2-pro', 'gpt-5.1'],
17
+ },
18
+ {
19
+ label: 'OpenAI · GPT-4.1',
20
+ models: ['gpt-4.1', 'gpt-4.1-mini', 'gpt-4.1-nano'],
21
+ },
22
+ {
23
+ label: 'OpenAI · Reasoning series',
24
+ models: ['o3-pro', 'o3', 'o3-mini', 'o4-mini'],
25
+ },
26
+ {
27
+ label: 'OpenAI · Coding-optimized',
28
+ models: ['gpt-5.1-codex', 'gpt-5.1-codex-max', 'gpt-5.1-codex-mini'],
29
+ },
30
+ {
31
+ label: 'Anthropic · Claude 4',
32
+ models: ['claude-opus-4-6', 'claude-sonnet-4-6', 'claude-haiku-4-5'],
33
+ },
34
+ {
35
+ label: 'Anthropic · Earlier Claude 4',
36
+ models: ['claude-opus-4-1', 'claude-opus-4-0', 'claude-sonnet-4-0'],
37
+ },
38
+ {
39
+ label: 'Anthropic · Claude 3.7',
40
+ models: ['claude-3-7-sonnet-latest'],
41
+ },
42
+ {
43
+ label: 'Anthropic · Claude 3.5',
44
+ models: ['claude-3-5-sonnet-latest', 'claude-3-5-haiku-latest'],
45
+ },
46
+ ];
47
+ export const OPENAI_MODEL_GROUPS = BUILT_IN_MODEL_GROUPS.filter((group) => group.label.startsWith('OpenAI · '));
48
+ export const COMMON_BUILT_IN_MODELS = BUILT_IN_MODEL_GROUPS.flatMap((group) => group.models);
49
+ export const COMMON_OPENAI_MODELS = OPENAI_MODEL_GROUPS.flatMap((group) => group.models);
50
+ const BUILT_IN_CONTEXT_WINDOW_ESTIMATES = new Map(COMMON_BUILT_IN_MODELS.map((model) => [model, inferContextWindowEstimate(model)]));
51
+ export function formatOpenAiModelGroups() {
52
+ return OPENAI_MODEL_GROUPS
53
+ .map((group) => [
54
+ group.label.replace(/^OpenAI · /, ''),
55
+ ...group.models.map((model) => ` - ${model}`),
56
+ ].join('\n'))
57
+ .join('\n\n');
58
+ }
59
+ export function formatBuiltInModelGroups() {
60
+ return BUILT_IN_MODEL_GROUPS
61
+ .map((group) => [
62
+ `${group.label}`,
63
+ ...group.models.map((model) => ` - ${model}`),
64
+ ].join('\n'))
65
+ .join('\n\n');
66
+ }
67
+ export function filterOpenAiModels(query) {
68
+ const normalized = query.trim().toLowerCase();
69
+ if (!normalized) {
70
+ return COMMON_OPENAI_MODELS;
71
+ }
72
+ return COMMON_OPENAI_MODELS.filter((model) => model.toLowerCase().includes(normalized));
73
+ }
74
+ export function filterBuiltInModels(query) {
75
+ const normalized = query.trim().toLowerCase();
76
+ if (!normalized) {
77
+ return COMMON_BUILT_IN_MODELS;
78
+ }
79
+ return COMMON_BUILT_IN_MODELS.filter((model) => model.toLowerCase().includes(normalized));
80
+ }
81
+ export function estimateOpenAiContextWindow(model) {
82
+ return estimateBuiltInContextWindow(model);
83
+ }
84
+ export function estimateBuiltInContextWindow(model) {
85
+ const normalized = model.trim();
86
+ if (!normalized) {
87
+ return undefined;
88
+ }
89
+ return BUILT_IN_CONTEXT_WINDOW_ESTIMATES.get(normalized) ?? inferContextWindowEstimate(normalized);
90
+ }
91
+ function inferContextWindowEstimate(model) {
92
+ if (model.startsWith('gpt-4.1')) {
93
+ return 128_000;
94
+ }
95
+ return 200_000;
96
+ }
97
+ //# sourceMappingURL=openai-models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-models.js","sourceRoot":"","sources":["../../../src/llm/openai-models.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,2EAA2E;AAC3E,uEAAuE;AACvE,8EAA8E;AAO9E,MAAM,CAAC,MAAM,qBAAqB,GAAwB;IACxD;QACE,KAAK,EAAE,kBAAkB;QACzB,MAAM,EAAE,CAAC,SAAS,E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K,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;AAC1F,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAC/C,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9C,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,sBAAsB,CAAC;IAChC,CAAC;IAED,OAAO,sBAAsB,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;AAC5F,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,KAAa;IACvD,OAAO,4BAA4B,CAAC,KAAK,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,KAAa;IACxD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAChC,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,iCAAiC,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,0BAA0B,CAAC,UAAU,CAAC,CAAC;AACrG,CAAC;AAED,SAAS,0BAA0B,CAAC,KAAa;IAC/C,IAAI,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAChC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { LlmAdapter } from './types.js';
2
+ export type OpenAiAdapterOptions = {
3
+ apiKey?: string;
4
+ model?: string;
5
+ };
6
+ /**
7
+ * Create an LLM adapter backed by the OpenAI chat completions API.
8
+ */
9
+ export declare function createOpenAiAdapter(options?: OpenAiAdapterOptions): LlmAdapter;
10
+ //# sourceMappingURL=openai.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../src/llm/openai.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,UAAU,EAA8E,MAAM,YAAY,CAAC;AAIzH,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,oBAAyB,GAAG,UAAU,CAgFlF"}
@@ -0,0 +1,170 @@
1
+ // ---------------------------------------------------------------------------
2
+ // LLM Adapter — OpenAI implementation
3
+ // ---------------------------------------------------------------------------
4
+ import OpenAI from 'openai';
5
+ import { DEFAULT_OPENAI_MODEL } from '../config.js';
6
+ /**
7
+ * Create an LLM adapter backed by the OpenAI chat completions API.
8
+ */
9
+ export function createOpenAiAdapter(options = {}) {
10
+ const client = new OpenAI({
11
+ apiKey: firstDefinedNonEmpty(options.apiKey, process.env.OPENAI_API_KEY, process.env.PERSONAL_OPENAI_API_KEY),
12
+ });
13
+ const model = options.model ?? DEFAULT_OPENAI_MODEL;
14
+ const capabilities = {
15
+ toolCalls: true,
16
+ systemMessages: true,
17
+ reasoningSummaries: true,
18
+ parallelToolCalls: true,
19
+ };
20
+ return {
21
+ info: {
22
+ provider: 'openai',
23
+ model,
24
+ capabilities,
25
+ },
26
+ async chat(messages, tools, signal, onStreamEvent) {
27
+ const stream = await client.responses.stream({
28
+ model,
29
+ input: toResponseInput(messages),
30
+ tools: tools.length > 0 ? tools.map(toResponseTool) : undefined,
31
+ reasoning: {
32
+ summary: 'detailed',
33
+ },
34
+ }, { signal });
35
+ let streamedContent = '';
36
+ for await (const event of stream) {
37
+ if (event.type === 'response.output_text.delta' && event.delta) {
38
+ streamedContent += event.delta;
39
+ onStreamEvent?.({ type: 'content.delta', delta: event.delta });
40
+ continue;
41
+ }
42
+ if (event.type === 'response.output_text.done') {
43
+ streamedContent = event.text;
44
+ onStreamEvent?.({ type: 'content.done', content: event.text });
45
+ }
46
+ }
47
+ const response = await stream.finalResponse();
48
+ const toolCalls = response.output.flatMap((item) => {
49
+ if (item.type !== 'function_call'
50
+ || typeof item.call_id !== 'string'
51
+ || typeof item.name !== 'string'
52
+ || typeof item.arguments !== 'string') {
53
+ return [];
54
+ }
55
+ return [{
56
+ id: item.call_id,
57
+ tool: item.name,
58
+ input: JSON.parse(item.arguments),
59
+ }];
60
+ });
61
+ const diagnostics = extractAssistantDiagnostics(response, toolCalls.length > 0);
62
+ const content = streamedContent || (diagnostics?.rationale ?? extractAssistantContent(response, toolCalls.length > 0));
63
+ if (!streamedContent && content) {
64
+ onStreamEvent?.({ type: 'content.delta', delta: content });
65
+ onStreamEvent?.({ type: 'content.done', content });
66
+ }
67
+ return {
68
+ content,
69
+ diagnostics,
70
+ toolCalls: toolCalls.length > 0 ? toolCalls : undefined,
71
+ usage: extractUsage(response),
72
+ };
73
+ },
74
+ };
75
+ }
76
+ function firstDefinedNonEmpty(...values) {
77
+ return values.find((value) => typeof value === 'string' && value.trim().length > 0);
78
+ }
79
+ // ---------------------------------------------------------------------------
80
+ // Internal converters
81
+ // ---------------------------------------------------------------------------
82
+ function extractAssistantContent(response, hasToolCalls) {
83
+ if (response.output_text) {
84
+ return response.output_text;
85
+ }
86
+ if (!hasToolCalls) {
87
+ return undefined;
88
+ }
89
+ const reasoningSummary = response.output
90
+ .filter((item) => item.type === 'reasoning')
91
+ .flatMap((item) => item.summary)
92
+ .map((summary) => summary.text.trim())
93
+ .filter(Boolean)
94
+ .join(' ');
95
+ return reasoningSummary || undefined;
96
+ }
97
+ function extractAssistantDiagnostics(response, hasToolCalls) {
98
+ if (!hasToolCalls) {
99
+ return undefined;
100
+ }
101
+ const rationale = response.output
102
+ .filter((item) => item.type === 'reasoning')
103
+ .flatMap((item) => item.summary)
104
+ .map((summary) => summary.text.trim())
105
+ .filter(Boolean)
106
+ .join(' ');
107
+ if (!rationale) {
108
+ return undefined;
109
+ }
110
+ return { rationale };
111
+ }
112
+ function extractUsage(response) {
113
+ if (!response.usage) {
114
+ return undefined;
115
+ }
116
+ return {
117
+ inputTokens: response.usage.input_tokens,
118
+ outputTokens: response.usage.output_tokens,
119
+ totalTokens: response.usage.total_tokens,
120
+ cachedInputTokens: response.usage.input_tokens_details.cached_tokens || undefined,
121
+ reasoningTokens: response.usage.output_tokens_details.reasoning_tokens || undefined,
122
+ requests: 1,
123
+ };
124
+ }
125
+ function toResponseInput(messages) {
126
+ return messages.flatMap((message) => toResponseInputItems(message));
127
+ }
128
+ function toResponseInputItems(msg) {
129
+ switch (msg.role) {
130
+ case 'system':
131
+ return [{ type: 'message', role: 'system', content: msg.content }];
132
+ case 'user':
133
+ return [{ type: 'message', role: 'user', content: msg.content }];
134
+ case 'assistant': {
135
+ const items = [];
136
+ if (msg.content) {
137
+ items.push({ type: 'message', role: 'assistant', content: msg.content });
138
+ }
139
+ if (msg.toolCalls) {
140
+ for (const call of msg.toolCalls) {
141
+ items.push({
142
+ type: 'function_call',
143
+ call_id: call.id,
144
+ name: call.tool,
145
+ arguments: JSON.stringify(call.input),
146
+ });
147
+ }
148
+ }
149
+ return items;
150
+ }
151
+ case 'tool':
152
+ return [
153
+ {
154
+ type: 'function_call_output',
155
+ call_id: msg.toolCallId,
156
+ output: msg.content,
157
+ },
158
+ ];
159
+ }
160
+ }
161
+ function toResponseTool(tool) {
162
+ return {
163
+ type: 'function',
164
+ name: tool.name,
165
+ description: tool.description,
166
+ parameters: tool.parameters,
167
+ strict: false,
168
+ };
169
+ }
170
+ //# sourceMappingURL=openai.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai.js","sourceRoot":"","sources":["../../../src/llm/openai.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,sCAAsC;AACtC,8EAA8E;AAE9E,OAAO,MAAM,MAAM,QAAQ,CAAC;AAU5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAOpD;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,UAAgC,EA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QAC7B,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,MAAM,EAAE,KAAK;KACd,CAAC;AACJ,CAAC"}
@@ -0,0 +1,64 @@
1
+ import type { AssistantDiagnostics, ToolCall, ToolDefinition } from '../types.js';
2
+ export type LlmStreamEvent = {
3
+ type: 'content.delta';
4
+ delta: string;
5
+ } | {
6
+ type: 'content.done';
7
+ content: string;
8
+ };
9
+ export type LlmProvider = 'openai' | 'anthropic' | 'google';
10
+ export type LlmAdapterCapabilities = {
11
+ toolCalls: boolean;
12
+ systemMessages: boolean;
13
+ reasoningSummaries: boolean;
14
+ parallelToolCalls: boolean;
15
+ };
16
+ export type LlmAdapterInfo = {
17
+ provider: LlmProvider;
18
+ model: string;
19
+ capabilities: LlmAdapterCapabilities;
20
+ };
21
+ export type LlmUsage = {
22
+ inputTokens: number;
23
+ outputTokens: number;
24
+ totalTokens: number;
25
+ cachedInputTokens?: number;
26
+ reasoningTokens?: number;
27
+ requests?: number;
28
+ };
29
+ /**
30
+ * A message in the chat transcript.
31
+ */
32
+ export type ChatMessage = {
33
+ role: 'system';
34
+ content: string;
35
+ } | {
36
+ role: 'user';
37
+ content: string;
38
+ } | {
39
+ role: 'assistant';
40
+ content: string;
41
+ toolCalls?: ToolCall[];
42
+ } | {
43
+ role: 'tool';
44
+ content: string;
45
+ toolCallId: string;
46
+ };
47
+ /**
48
+ * What the LLM returns after a chat turn.
49
+ */
50
+ export type LlmResponse = {
51
+ content?: string;
52
+ diagnostics?: AssistantDiagnostics;
53
+ toolCalls?: ToolCall[];
54
+ usage?: LlmUsage;
55
+ };
56
+ /**
57
+ * Adapter interface — the loop talks to the LLM through this.
58
+ * Swap implementations to change providers.
59
+ */
60
+ export interface LlmAdapter {
61
+ info?: LlmAdapterInfo;
62
+ chat(messages: ChatMessage[], tools: ToolDefinition[], signal?: AbortSignal, onStreamEvent?: (event: LlmStreamEvent) => void): Promise<LlmResponse>;
63
+ }
64
+ //# sourceMappingURL=types.d.ts.map
@@ -0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AE,QAAQ,EAAE,CAAA;CAAE,GAC9D;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,oBAAoB,CAAC;IACnC,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,QAAQ,CAAC;CAClB,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,IAAI,CACF,QAAQ,EAAE,WAAW,EAAE,EACvB,KAAK,EAAE,cAAc,EAAE,EACvB,MAAM,CAAC,EAAE,WAAW,EACpB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,GAC9C,OAAO,CAAC,WAAW,CAAC,CAAC;CACzB"}
@@ -0,0 +1,5 @@
1
+ // ---------------------------------------------------------------------------
2
+ // LLM Adapter — interface types
3
+ // ---------------------------------------------------------------------------
4
+ export {};
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/llm/types.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,gCAAgC;AAChC,8EAA8E"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Build the system prompt for the agent.
3
+ * Encourages purposeful tool use and a clear execution workflow.
4
+ */
5
+ export declare function buildSystemPrompt(goal: string, toolNames: string[], projectContext?: string): string;
6
+ //# sourceMappingURL=system-prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../../src/prompts/system-prompt.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CA2GpG"}
@@ -0,0 +1,117 @@
1
+ // ---------------------------------------------------------------------------
2
+ // System Prompt Builder
3
+ // Soft guidance, not runtime ontology.
4
+ // ---------------------------------------------------------------------------
5
+ /**
6
+ * Build the system prompt for the agent.
7
+ * Encourages purposeful tool use and a clear execution workflow.
8
+ */
9
+ export function buildSystemPrompt(goal, toolNames, projectContext) {
10
+ return `You are Heddle, a conversational coding and workspace agent.
11
+
12
+ You help a user understand, inspect, change, verify, and explain work in the current project using the tools the host gives you.
13
+
14
+ You are not a generic chatbot. You are an operator-facing agent working in a real workspace with traces, approvals, and tool execution.
15
+
16
+ ## Your Goal
17
+
18
+ ${goal}
19
+
20
+ ## What Heddle Is
21
+
22
+ - Heddle helps with repository inspection, bounded coding work, verification, and shell-assisted workflows.
23
+ - Heddle should be honest about what it can and cannot do in the current environment.
24
+ - When the user asks what Heddle can do, how it works, or what changed recently, answer from current tool/runtime behavior and direct evidence rather than marketing language.
25
+ - When describing capabilities to the user, start with user-facing outcomes such as inspect, explain, change, verify, or run commands. Do not lead with internal tool names or implementation details unless the user explicitly asks for technical detail.
26
+ - If the user asks what Heddle itself is, explain it as a coding/workspace agent runtime that is still evolving, not a finished general intelligence system.
27
+
28
+ ## Available Tools
29
+
30
+ You have access to these tools: ${toolNames.join(', ')}
31
+
32
+ ${projectContext ? `## Project Context\n\n${projectContext}\n\n` : ''}## Operating Principles
33
+
34
+ - Be direct, calm, and practical.
35
+ - Prefer short progress-oriented explanations over long preambles.
36
+ - Gather evidence before concluding.
37
+ - Do not pretend you ran a command, read a file, or observed a result if you did not.
38
+ - If the user already gave you direct shell output or other concrete evidence in the conversation, you may use it.
39
+ - Do not ask unnecessary questions when the answer can be discovered from the workspace, tools, docs, traces, or repo state.
40
+
41
+ ## Default Workflow
42
+
43
+ Follow this default workflow unless the user clearly wants something narrower:
44
+
45
+ 1. Clarify the real task.
46
+ Decide whether the user wants inspection, explanation, implementation, verification, comparison, or a proposed next step.
47
+
48
+ 2. Gather the minimum relevant evidence first.
49
+ Start from the current workspace and nearby context before exploring broader parts of the environment.
50
+ If the goal clearly points to an obvious file or folder from the workspace structure, inspect that directly before using broad text search.
51
+ When the user asks whether something passed, failed, changed, or exists, prefer direct evidence such as command output, file contents, diffs, or test results.
52
+
53
+ 3. Form a grounded conclusion or proposal.
54
+ Do not jump from one narrow local detail to a project-level recommendation without checking the docs, roadmap, or implementation context that defines the broader goal.
55
+ If the user asks for the next step, propose a concrete high-leverage next step based on the project goal and current state, not just the nearest incidental task you last touched.
56
+ When proposing next steps, include why that step matters and what concrete work it would involve.
57
+ For substantial open-ended or multi-step work, record a short plan with update_plan before or as you begin execution, then keep it updated as items move from pending to in_progress to completed.
58
+
59
+ 4. Carry the task through when action is needed.
60
+ If the user asks for a real repository change such as fixing a bug, improving tests, increasing coverage, or updating docs, prefer carrying the task through implementation and verification instead of stopping at analysis or a plan unless you are blocked.
61
+ If you identify a reasonable bounded change that directly serves the user goal, make it and verify it instead of only describing it.
62
+ Once you choose a concrete next step, execute that step instead of repeatedly restating the plan in slightly different words.
63
+ Do not spend multiple turns narrating the same intent without either gathering new evidence or making progress on the implementation.
64
+ If you recorded a plan, do not stop after only one small slice unless the remaining items are explicitly blocked or no longer needed. Update the plan to show what completed and what remains, then continue toward the planned outcome.
65
+
66
+ 5. Finish with a useful operator answer.
67
+ Summarize what you found or did in a readable form.
68
+ If the task involved changes or verification, prefer a short summary followed by high-level bullets over a vague “done”.
69
+
70
+ ## Tool Use Rules
71
+
72
+ - Use tools purposefully. Each tool call should have a clear reason.
73
+ - Use only the parameters that a tool actually documents. Do not invent extra fields.
74
+ - Prefer the most direct tool for the job: inspect directories with directory-oriented tools, read known files with file-reading tools, and broaden scope only when the goal requires it.
75
+ - Prefer the first-class file editing tool for creating or changing file contents instead of shell redirection, heredocs, or other shell-based file-writing workarounds.
76
+ - Use update_plan for substantial tasks that have multiple meaningful steps. Keep plans short, concrete, and progress-oriented rather than aspirational.
77
+ - Treat mutate-oriented tools as higher-risk than inspection tools, but do not treat them as forbidden.
78
+ - Use run_shell_inspect for bounded read-oriented commands the host is likely to allow directly.
79
+ - If a shell command is arbitrary, uses inline scripts, needs redirects/heredocs, or inspect rejects it, switch to run_shell_mutate and continue through approval instead of concluding the command cannot be run.
80
+ - If run_shell_inspect fails with a policy restriction, do not stop at "inspect is blocked." Either rely on the host's mutate fallback or explicitly retry with run_shell_mutate when the command is still needed.
81
+ - If a tool reports invalid input or suggests a better tool, correct the call immediately instead of exploring unrelated paths.
82
+ - Avoid repeating the same action if it already gave you the answer.
83
+
84
+ ## Reasoning About Scope
85
+
86
+ - Distinguish broader project questions from narrow local questions.
87
+ - If the user asks about the end goal, roadmap, architecture, or next major step, prefer primary sources such as roadmap docs, framework docs, system behavior, and implementation state over the most recently edited test or file.
88
+ - Do not anchor on the most recent diff or failing test unless the user is explicitly asking about that local workstream.
89
+ - When the goal asks about capabilities, behavior, limits, or safety rules, prefer primary sources such as implementation artifacts, tool definitions, or direct system evidence over higher-level summaries.
90
+
91
+ ## Verification And Reporting
92
+
93
+ - After edits or mutation-oriented commands, prefer verifying and summarizing concrete outcomes over giving a vague response.
94
+ - After workspace-changing actions, prefer explicit repo review evidence such as git status --short or git diff --stat, and mention the exact review and verification commands you used in the final summary.
95
+ - If the user asks to improve tests or coverage, use existing coverage evidence or generate it when possible, identify a bounded gap, add or adjust tests, then verify the result.
96
+ - Before calling tools, briefly state what you are about to check when that would help a human follow your process.
97
+ - If you cannot find sufficient information, say so honestly rather than guessing.
98
+ - When you have enough information, provide a clear, concise answer with evidence from what you found and distinguish observed facts from inference.
99
+
100
+ ## Help And Product Questions
101
+
102
+ - If the user asks for help using Heddle itself, explain the relevant commands, shell behavior, sessions, approvals, or current limitations based on the runtime behavior you can observe.
103
+ - If the user asks what you can help with, prefer plain-language descriptions over enumerating internal tool names.
104
+ - If the user asks how to use Heddle, include the most relevant commands or interaction patterns.
105
+ - For conversational usage, prefer examples like normal questions, slash commands, and direct shell commands.
106
+ - If the user asks about sessions, explain session listing, switching, continuation, and any important limits you can infer from the environment.
107
+ - If the user asks what changed in the current repo, prefer repo evidence over abstract summaries.
108
+
109
+ ## Blocked State
110
+
111
+ - You MUST call report_state before continuing if a tool fails, if you are blocked or uncertain about the next step, or if progress is limited by missing information, missing tool support, or missing inputs.
112
+
113
+ ## When to Stop
114
+
115
+ When you have gathered enough information to fully answer the goal, provide your final answer as a normal message without calling any more tools. Your final message should directly answer the goal and should be useful to an operator, not just technically correct.`;
116
+ }
117
+ //# sourceMappingURL=system-prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../../src/prompts/system-prompt.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,wBAAwB;AACxB,uCAAuC;AACvC,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,SAAmB,EAAE,cAAuB;IAC1F,OAAO;;;;;;;;EAQP,IAAI;;;;;;;;;;;;kCAY4B,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;;EAEpD,cAAc,CAAC,CAAC,CAAC,yBAAyB,cAAc,MAAM,CAAC,CAAC,CAAC,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wQAmFmM,CAAC;AACzQ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ChatMessage } from '../llm/types.js';
2
+ export declare function sanitizeHistory(history: ChatMessage[]): ChatMessage[];
3
+ //# sourceMappingURL=history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../../src/run-agent/history.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAMnD,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,WAAW,EAAE,CAGrE"}
@@ -0,0 +1,36 @@
1
+ // ---------------------------------------------------------------------------
2
+ // History sanitization for the agent loop.
3
+ // Ensures interrupted or incomplete tool-call history does not poison later turns.
4
+ // ---------------------------------------------------------------------------
5
+ export function sanitizeHistory(history) {
6
+ const { introduced, resolved } = indexToolCallIds(history);
7
+ return history.flatMap((message) => sanitizeMessage(message, introduced, resolved));
8
+ }
9
+ function indexToolCallIds(history) {
10
+ const introduced = new Set(history
11
+ .filter((m) => m.role === 'assistant' && !!m.toolCalls)
12
+ .flatMap((m) => m.toolCalls.map((c) => c.id)));
13
+ const resolved = new Set(history
14
+ .filter((m) => m.role === 'tool')
15
+ .map((m) => m.toolCallId));
16
+ return { introduced, resolved };
17
+ }
18
+ function sanitizeMessage(message, introduced, resolved) {
19
+ if (message.role === 'assistant' && message.toolCalls) {
20
+ return sanitizeAssistantWithToolCalls(message, resolved);
21
+ }
22
+ if (message.role === 'tool' && !introduced.has(message.toolCallId)) {
23
+ return [];
24
+ }
25
+ return [message];
26
+ }
27
+ function sanitizeAssistantWithToolCalls(message, resolved) {
28
+ const resolvedCalls = message.toolCalls.filter((call) => resolved.has(call.id));
29
+ if (resolvedCalls.length > 0) {
30
+ return [{ ...message, toolCalls: resolvedCalls }];
31
+ }
32
+ return message.content.trim()
33
+ ? [{ role: 'assistant', content: message.content }]
34
+ : [];
35
+ }
36
+ //# sourceMappingURL=history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.js","sourceRoot":"","sources":["../../../src/run-agent/history.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,2CAA2C;AAC3C,mFAAmF;AACnF,8EAA8E;AAQ9E,MAAM,UAAU,eAAe,CAAC,OAAsB;IACpD,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC3D,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,e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AI,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAEhF,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,OAAO,CAAC,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC;IACpD,CAAC;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE;QAC3B,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;QACnD,CAAC,CAAC,EAAE,CAAC;AACT,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { ToolCall } from '../types.js';
2
+ export type MutationState = {
3
+ pendingVerification: boolean;
4
+ pendingChangeReview: boolean;
5
+ requiresStructuredChangeSummary: boolean;
6
+ needsImmediateReviewReminder: boolean;
7
+ needsImmediateVerificationReminder: boolean;
8
+ executedMutationCommands: string[];
9
+ executedReviewCommands: string[];
10
+ executedVerificationCommands: string[];
11
+ executedReviewEvidence: string[];
12
+ executedVerificationEvidence: string[];
13
+ };
14
+ export declare function createMutationState(): MutationState;
15
+ export declare function trackToolResult(state: MutationState, effectiveCall: ToolCall, result: {
16
+ ok: boolean;
17
+ output?: unknown;
18
+ }): void;
19
+ export declare function isWorkspaceChangeMutateCommand(command: string): boolean;
20
+ export declare function isVerificationMutateCommand(command: string): boolean;
21
+ export declare function isRepoReviewCommand(command: string): boolean;
22
+ //# sourceMappingURL=mutation-tracking.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mutation-tracking.d.ts","sourceRoot":"","sources":["../../../src/run-agent/mutation-tracking.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C,MAAM,MAAM,aAAa,GAAG;IAC1B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,+BAA+B,EAAE,OAAO,CAAC;IACzC,4BAA4B,EAAE,OAAO,CAAC;IACtC,kCAAkC,EAAE,OAAO,CAAC;IAC5C,wBAAwB,EAAE,MAAM,EAAE,CAAC;IACnC,sBAAsB,EAAE,MAAM,EAAE,CAAC;IACjC,4BAA4B,EAAE,MAAM,EAAE,CAAC;IACvC,sBAAsB,EAAE,MAAM,EAAE,CAAC;IACjC,4BAA4B,EAAE,MAAM,EAAE,CAAC;CACxC,CAAC;AAEF,wBAAgB,mBAAmB,IAAI,aAAa,CAanD;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,aAAa,EACpB,aAAa,EAAE,QAAQ,EACvB,MAAM,EAAE;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GACxC,IAAI,CAwCN;AAED,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAmBvE;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CASpE;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAO5D"}