chad-code 1.3.1 → 1.3.3

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 (338) hide show
  1. package/README.md +55 -6
  2. package/chad-code-0.0.0-main-202601090906.tgz +0 -0
  3. package/package.json +35 -97
  4. package/AGENTS.md +0 -27
  5. package/Dockerfile +0 -18
  6. package/README.npm.md +0 -64
  7. package/bunfig.toml +0 -7
  8. package/eslint.config.js +0 -29
  9. package/parsers-config.ts +0 -253
  10. package/script/build.ts +0 -167
  11. package/script/publish-registries.ts +0 -187
  12. package/script/publish.ts +0 -93
  13. package/script/schema.ts +0 -47
  14. package/src/acp/README.md +0 -164
  15. package/src/acp/agent.ts +0 -1086
  16. package/src/acp/session.ts +0 -101
  17. package/src/acp/types.ts +0 -22
  18. package/src/agent/agent.ts +0 -253
  19. package/src/agent/generate.txt +0 -75
  20. package/src/agent/prompt/compaction.txt +0 -12
  21. package/src/agent/prompt/explore.txt +0 -18
  22. package/src/agent/prompt/summary.txt +0 -11
  23. package/src/agent/prompt/title.txt +0 -36
  24. package/src/auth/index.ts +0 -70
  25. package/src/bun/index.ts +0 -130
  26. package/src/bus/bus-event.ts +0 -43
  27. package/src/bus/global.ts +0 -10
  28. package/src/bus/index.ts +0 -105
  29. package/src/cli/bootstrap.ts +0 -17
  30. package/src/cli/cmd/acp.ts +0 -69
  31. package/src/cli/cmd/agent.ts +0 -257
  32. package/src/cli/cmd/auth.ts +0 -132
  33. package/src/cli/cmd/cmd.ts +0 -7
  34. package/src/cli/cmd/debug/agent.ts +0 -28
  35. package/src/cli/cmd/debug/config.ts +0 -15
  36. package/src/cli/cmd/debug/file.ts +0 -91
  37. package/src/cli/cmd/debug/index.ts +0 -45
  38. package/src/cli/cmd/debug/lsp.ts +0 -48
  39. package/src/cli/cmd/debug/ripgrep.ts +0 -83
  40. package/src/cli/cmd/debug/scrap.ts +0 -15
  41. package/src/cli/cmd/debug/skill.ts +0 -15
  42. package/src/cli/cmd/debug/snapshot.ts +0 -48
  43. package/src/cli/cmd/export.ts +0 -88
  44. package/src/cli/cmd/generate.ts +0 -38
  45. package/src/cli/cmd/github.ts +0 -32
  46. package/src/cli/cmd/import.ts +0 -98
  47. package/src/cli/cmd/mcp.ts +0 -670
  48. package/src/cli/cmd/models.ts +0 -42
  49. package/src/cli/cmd/pr.ts +0 -112
  50. package/src/cli/cmd/run.ts +0 -374
  51. package/src/cli/cmd/serve.ts +0 -16
  52. package/src/cli/cmd/session.ts +0 -135
  53. package/src/cli/cmd/stats.ts +0 -402
  54. package/src/cli/cmd/tui/app.tsx +0 -705
  55. package/src/cli/cmd/tui/attach.ts +0 -32
  56. package/src/cli/cmd/tui/component/border.tsx +0 -21
  57. package/src/cli/cmd/tui/component/dialog-agent.tsx +0 -31
  58. package/src/cli/cmd/tui/component/dialog-command.tsx +0 -124
  59. package/src/cli/cmd/tui/component/dialog-mcp.tsx +0 -86
  60. package/src/cli/cmd/tui/component/dialog-model.tsx +0 -232
  61. package/src/cli/cmd/tui/component/dialog-provider.tsx +0 -228
  62. package/src/cli/cmd/tui/component/dialog-session-list.tsx +0 -115
  63. package/src/cli/cmd/tui/component/dialog-session-rename.tsx +0 -31
  64. package/src/cli/cmd/tui/component/dialog-stash.tsx +0 -86
  65. package/src/cli/cmd/tui/component/dialog-status.tsx +0 -162
  66. package/src/cli/cmd/tui/component/dialog-tag.tsx +0 -44
  67. package/src/cli/cmd/tui/component/dialog-theme-list.tsx +0 -50
  68. package/src/cli/cmd/tui/component/did-you-know.tsx +0 -85
  69. package/src/cli/cmd/tui/component/logo.tsx +0 -43
  70. package/src/cli/cmd/tui/component/prompt/autocomplete.tsx +0 -654
  71. package/src/cli/cmd/tui/component/prompt/history.tsx +0 -108
  72. package/src/cli/cmd/tui/component/prompt/index.tsx +0 -1078
  73. package/src/cli/cmd/tui/component/prompt/stash.tsx +0 -101
  74. package/src/cli/cmd/tui/component/textarea-keybindings.ts +0 -73
  75. package/src/cli/cmd/tui/component/tips.ts +0 -92
  76. package/src/cli/cmd/tui/component/todo-item.tsx +0 -32
  77. package/src/cli/cmd/tui/context/args.tsx +0 -14
  78. package/src/cli/cmd/tui/context/directory.ts +0 -13
  79. package/src/cli/cmd/tui/context/exit.tsx +0 -23
  80. package/src/cli/cmd/tui/context/helper.tsx +0 -25
  81. package/src/cli/cmd/tui/context/keybind.tsx +0 -101
  82. package/src/cli/cmd/tui/context/kv.tsx +0 -49
  83. package/src/cli/cmd/tui/context/local.tsx +0 -392
  84. package/src/cli/cmd/tui/context/prompt.tsx +0 -18
  85. package/src/cli/cmd/tui/context/route.tsx +0 -46
  86. package/src/cli/cmd/tui/context/sdk.tsx +0 -75
  87. package/src/cli/cmd/tui/context/sync.tsx +0 -384
  88. package/src/cli/cmd/tui/context/theme/aura.json +0 -69
  89. package/src/cli/cmd/tui/context/theme/ayu.json +0 -80
  90. package/src/cli/cmd/tui/context/theme/catppuccin-frappe.json +0 -233
  91. package/src/cli/cmd/tui/context/theme/catppuccin-macchiato.json +0 -233
  92. package/src/cli/cmd/tui/context/theme/catppuccin.json +0 -112
  93. package/src/cli/cmd/tui/context/theme/chad.json +0 -245
  94. package/src/cli/cmd/tui/context/theme/cobalt2.json +0 -228
  95. package/src/cli/cmd/tui/context/theme/cursor.json +0 -249
  96. package/src/cli/cmd/tui/context/theme/dracula.json +0 -219
  97. package/src/cli/cmd/tui/context/theme/everforest.json +0 -241
  98. package/src/cli/cmd/tui/context/theme/flexoki.json +0 -237
  99. package/src/cli/cmd/tui/context/theme/github.json +0 -233
  100. package/src/cli/cmd/tui/context/theme/gruvbox.json +0 -95
  101. package/src/cli/cmd/tui/context/theme/kanagawa.json +0 -77
  102. package/src/cli/cmd/tui/context/theme/lucent-orng.json +0 -227
  103. package/src/cli/cmd/tui/context/theme/material.json +0 -235
  104. package/src/cli/cmd/tui/context/theme/matrix.json +0 -77
  105. package/src/cli/cmd/tui/context/theme/mercury.json +0 -252
  106. package/src/cli/cmd/tui/context/theme/monokai.json +0 -221
  107. package/src/cli/cmd/tui/context/theme/nightowl.json +0 -221
  108. package/src/cli/cmd/tui/context/theme/nord.json +0 -223
  109. package/src/cli/cmd/tui/context/theme/one-dark.json +0 -84
  110. package/src/cli/cmd/tui/context/theme/orng.json +0 -245
  111. package/src/cli/cmd/tui/context/theme/osaka-jade.json +0 -93
  112. package/src/cli/cmd/tui/context/theme/palenight.json +0 -222
  113. package/src/cli/cmd/tui/context/theme/rosepine.json +0 -234
  114. package/src/cli/cmd/tui/context/theme/solarized.json +0 -223
  115. package/src/cli/cmd/tui/context/theme/synthwave84.json +0 -226
  116. package/src/cli/cmd/tui/context/theme/tokyonight.json +0 -243
  117. package/src/cli/cmd/tui/context/theme/vercel.json +0 -245
  118. package/src/cli/cmd/tui/context/theme/vesper.json +0 -218
  119. package/src/cli/cmd/tui/context/theme/zenburn.json +0 -223
  120. package/src/cli/cmd/tui/context/theme.tsx +0 -1137
  121. package/src/cli/cmd/tui/event.ts +0 -46
  122. package/src/cli/cmd/tui/routes/home.tsx +0 -138
  123. package/src/cli/cmd/tui/routes/session/dialog-fork-from-timeline.tsx +0 -64
  124. package/src/cli/cmd/tui/routes/session/dialog-message.tsx +0 -109
  125. package/src/cli/cmd/tui/routes/session/dialog-subagent.tsx +0 -26
  126. package/src/cli/cmd/tui/routes/session/dialog-timeline.tsx +0 -47
  127. package/src/cli/cmd/tui/routes/session/footer.tsx +0 -88
  128. package/src/cli/cmd/tui/routes/session/header.tsx +0 -125
  129. package/src/cli/cmd/tui/routes/session/index.tsx +0 -1814
  130. package/src/cli/cmd/tui/routes/session/permission.tsx +0 -416
  131. package/src/cli/cmd/tui/routes/session/sidebar.tsx +0 -318
  132. package/src/cli/cmd/tui/spawn.ts +0 -48
  133. package/src/cli/cmd/tui/thread.ts +0 -111
  134. package/src/cli/cmd/tui/ui/dialog-alert.tsx +0 -57
  135. package/src/cli/cmd/tui/ui/dialog-confirm.tsx +0 -83
  136. package/src/cli/cmd/tui/ui/dialog-export-options.tsx +0 -204
  137. package/src/cli/cmd/tui/ui/dialog-help.tsx +0 -38
  138. package/src/cli/cmd/tui/ui/dialog-prompt.tsx +0 -77
  139. package/src/cli/cmd/tui/ui/dialog-select.tsx +0 -345
  140. package/src/cli/cmd/tui/ui/dialog.tsx +0 -171
  141. package/src/cli/cmd/tui/ui/link.tsx +0 -28
  142. package/src/cli/cmd/tui/ui/spinner.ts +0 -368
  143. package/src/cli/cmd/tui/ui/toast.tsx +0 -100
  144. package/src/cli/cmd/tui/util/clipboard.ts +0 -127
  145. package/src/cli/cmd/tui/util/editor.ts +0 -32
  146. package/src/cli/cmd/tui/util/signal.ts +0 -7
  147. package/src/cli/cmd/tui/util/terminal.ts +0 -114
  148. package/src/cli/cmd/tui/util/transcript.ts +0 -98
  149. package/src/cli/cmd/tui/worker.ts +0 -68
  150. package/src/cli/cmd/uninstall.ts +0 -344
  151. package/src/cli/cmd/upgrade.ts +0 -67
  152. package/src/cli/cmd/web.ts +0 -73
  153. package/src/cli/error.ts +0 -56
  154. package/src/cli/network.ts +0 -53
  155. package/src/cli/ui.ts +0 -87
  156. package/src/cli/upgrade.ts +0 -25
  157. package/src/command/index.ts +0 -131
  158. package/src/command/template/initialize.txt +0 -10
  159. package/src/command/template/review.txt +0 -97
  160. package/src/config/config.ts +0 -1124
  161. package/src/config/markdown.ts +0 -41
  162. package/src/env/index.ts +0 -26
  163. package/src/file/ignore.ts +0 -83
  164. package/src/file/index.ts +0 -411
  165. package/src/file/ripgrep.ts +0 -402
  166. package/src/file/time.ts +0 -64
  167. package/src/file/watcher.ts +0 -117
  168. package/src/flag/flag.ts +0 -52
  169. package/src/format/formatter.ts +0 -359
  170. package/src/format/index.ts +0 -137
  171. package/src/global/index.ts +0 -55
  172. package/src/id/id.ts +0 -73
  173. package/src/ide/index.ts +0 -77
  174. package/src/index.ts +0 -159
  175. package/src/installation/index.ts +0 -198
  176. package/src/lsp/client.ts +0 -252
  177. package/src/lsp/index.ts +0 -485
  178. package/src/lsp/language.ts +0 -119
  179. package/src/lsp/server.ts +0 -2023
  180. package/src/mcp/auth.ts +0 -135
  181. package/src/mcp/index.ts +0 -874
  182. package/src/mcp/oauth-callback.ts +0 -200
  183. package/src/mcp/oauth-provider.ts +0 -154
  184. package/src/patch/index.ts +0 -622
  185. package/src/permission/arity.ts +0 -163
  186. package/src/permission/index.ts +0 -210
  187. package/src/permission/next.ts +0 -268
  188. package/src/plugin/index.ts +0 -106
  189. package/src/project/bootstrap.ts +0 -31
  190. package/src/project/instance.ts +0 -78
  191. package/src/project/project.ts +0 -263
  192. package/src/project/state.ts +0 -65
  193. package/src/project/vcs.ts +0 -76
  194. package/src/provider/auth.ts +0 -143
  195. package/src/provider/models-macro.ts +0 -4
  196. package/src/provider/models.ts +0 -77
  197. package/src/provider/provider.ts +0 -516
  198. package/src/provider/transform.ts +0 -114
  199. package/src/pty/index.ts +0 -212
  200. package/src/server/error.ts +0 -36
  201. package/src/server/mdns.ts +0 -57
  202. package/src/server/project.ts +0 -79
  203. package/src/server/server.ts +0 -2866
  204. package/src/server/tui.ts +0 -71
  205. package/src/session/compaction.ts +0 -225
  206. package/src/session/index.ts +0 -469
  207. package/src/session/llm.ts +0 -213
  208. package/src/session/message-v2.ts +0 -742
  209. package/src/session/message.ts +0 -189
  210. package/src/session/processor.ts +0 -402
  211. package/src/session/prompt/anthropic-20250930.txt +0 -166
  212. package/src/session/prompt/anthropic.txt +0 -105
  213. package/src/session/prompt/anthropic_spoof.txt +0 -1
  214. package/src/session/prompt/beast.txt +0 -147
  215. package/src/session/prompt/build-switch.txt +0 -5
  216. package/src/session/prompt/codex.txt +0 -318
  217. package/src/session/prompt/copilot-gpt-5.txt +0 -143
  218. package/src/session/prompt/gemini.txt +0 -155
  219. package/src/session/prompt/max-steps.txt +0 -16
  220. package/src/session/prompt/plan-reminder-anthropic.txt +0 -67
  221. package/src/session/prompt/plan.txt +0 -26
  222. package/src/session/prompt/qwen.txt +0 -109
  223. package/src/session/prompt.ts +0 -1621
  224. package/src/session/retry.ts +0 -90
  225. package/src/session/revert.ts +0 -108
  226. package/src/session/status.ts +0 -76
  227. package/src/session/summary.ts +0 -194
  228. package/src/session/system.ts +0 -108
  229. package/src/session/todo.ts +0 -37
  230. package/src/share/share-next.ts +0 -194
  231. package/src/share/share.ts +0 -23
  232. package/src/shell/shell.ts +0 -67
  233. package/src/skill/index.ts +0 -1
  234. package/src/skill/skill.ts +0 -124
  235. package/src/snapshot/index.ts +0 -197
  236. package/src/storage/storage.ts +0 -226
  237. package/src/tool/bash.ts +0 -262
  238. package/src/tool/bash.txt +0 -116
  239. package/src/tool/batch.ts +0 -175
  240. package/src/tool/batch.txt +0 -24
  241. package/src/tool/codesearch.ts +0 -132
  242. package/src/tool/codesearch.txt +0 -12
  243. package/src/tool/edit.ts +0 -655
  244. package/src/tool/edit.txt +0 -10
  245. package/src/tool/glob.ts +0 -75
  246. package/src/tool/glob.txt +0 -6
  247. package/src/tool/grep.ts +0 -132
  248. package/src/tool/grep.txt +0 -8
  249. package/src/tool/invalid.ts +0 -17
  250. package/src/tool/ls.ts +0 -119
  251. package/src/tool/ls.txt +0 -1
  252. package/src/tool/lsp.ts +0 -94
  253. package/src/tool/lsp.txt +0 -19
  254. package/src/tool/multiedit.ts +0 -46
  255. package/src/tool/multiedit.txt +0 -41
  256. package/src/tool/patch.ts +0 -210
  257. package/src/tool/patch.txt +0 -1
  258. package/src/tool/read.ts +0 -191
  259. package/src/tool/read.txt +0 -12
  260. package/src/tool/registry.ts +0 -137
  261. package/src/tool/skill.ts +0 -77
  262. package/src/tool/task.ts +0 -167
  263. package/src/tool/task.txt +0 -60
  264. package/src/tool/todo.ts +0 -53
  265. package/src/tool/todoread.txt +0 -14
  266. package/src/tool/todowrite.txt +0 -167
  267. package/src/tool/tool.ts +0 -73
  268. package/src/tool/webfetch.ts +0 -182
  269. package/src/tool/webfetch.txt +0 -13
  270. package/src/tool/websearch.ts +0 -144
  271. package/src/tool/websearch.txt +0 -11
  272. package/src/tool/write.ts +0 -84
  273. package/src/tool/write.txt +0 -8
  274. package/src/util/archive.ts +0 -16
  275. package/src/util/color.ts +0 -19
  276. package/src/util/context.ts +0 -25
  277. package/src/util/defer.ts +0 -12
  278. package/src/util/eventloop.ts +0 -20
  279. package/src/util/filesystem.ts +0 -83
  280. package/src/util/fn.ts +0 -11
  281. package/src/util/iife.ts +0 -3
  282. package/src/util/keybind.ts +0 -102
  283. package/src/util/lazy.ts +0 -18
  284. package/src/util/locale.ts +0 -81
  285. package/src/util/lock.ts +0 -98
  286. package/src/util/log.ts +0 -180
  287. package/src/util/queue.ts +0 -32
  288. package/src/util/rpc.ts +0 -42
  289. package/src/util/scrap.ts +0 -10
  290. package/src/util/signal.ts +0 -12
  291. package/src/util/timeout.ts +0 -14
  292. package/src/util/token.ts +0 -7
  293. package/src/util/wildcard.ts +0 -54
  294. package/src/worktree/index.ts +0 -217
  295. package/sst-env.d.ts +0 -9
  296. package/test/agent/agent.test.ts +0 -448
  297. package/test/bun.test.ts +0 -53
  298. package/test/cli/github-action.test.ts +0 -129
  299. package/test/cli/github-remote.test.ts +0 -80
  300. package/test/cli/tui/transcript.test.ts +0 -297
  301. package/test/config/agent-color.test.ts +0 -66
  302. package/test/config/config.test.ts +0 -870
  303. package/test/config/markdown.test.ts +0 -89
  304. package/test/file/ignore.test.ts +0 -10
  305. package/test/file/path-traversal.test.ts +0 -115
  306. package/test/fixture/fixture.ts +0 -45
  307. package/test/fixture/lsp/fake-lsp-server.js +0 -77
  308. package/test/ide/ide.test.ts +0 -82
  309. package/test/keybind.test.ts +0 -421
  310. package/test/lsp/client.test.ts +0 -95
  311. package/test/mcp/headers.test.ts +0 -153
  312. package/test/patch/patch.test.ts +0 -348
  313. package/test/permission/arity.test.ts +0 -33
  314. package/test/permission/next.test.ts +0 -652
  315. package/test/preload.ts +0 -63
  316. package/test/project/project.test.ts +0 -120
  317. package/test/provider/amazon-bedrock.test.ts +0 -236
  318. package/test/provider/provider.test.ts +0 -2127
  319. package/test/provider/transform.test.ts +0 -980
  320. package/test/server/session-select.test.ts +0 -78
  321. package/test/session/compaction.test.ts +0 -251
  322. package/test/session/message-v2.test.ts +0 -570
  323. package/test/session/retry.test.ts +0 -131
  324. package/test/session/revert-compact.test.ts +0 -285
  325. package/test/session/session.test.ts +0 -71
  326. package/test/skill/skill.test.ts +0 -185
  327. package/test/snapshot/snapshot.test.ts +0 -939
  328. package/test/tool/__snapshots__/tool.test.ts.snap +0 -9
  329. package/test/tool/bash.test.ts +0 -232
  330. package/test/tool/grep.test.ts +0 -109
  331. package/test/tool/patch.test.ts +0 -261
  332. package/test/tool/read.test.ts +0 -167
  333. package/test/util/iife.test.ts +0 -36
  334. package/test/util/lazy.test.ts +0 -50
  335. package/test/util/timeout.test.ts +0 -21
  336. package/test/util/wildcard.test.ts +0 -55
  337. package/tsconfig.json +0 -16
  338. /package/{script/postinstall.mjs → postinstall.mjs} +0 -0
@@ -1,182 +0,0 @@
1
- import z from "zod"
2
- import { Tool } from "./tool"
3
- import TurndownService from "turndown"
4
- import DESCRIPTION from "./webfetch.txt"
5
-
6
- const MAX_RESPONSE_SIZE = 5 * 1024 * 1024 // 5MB
7
- const DEFAULT_TIMEOUT = 30 * 1000 // 30 seconds
8
- const MAX_TIMEOUT = 120 * 1000 // 2 minutes
9
-
10
- export const WebFetchTool = Tool.define("webfetch", {
11
- description: DESCRIPTION,
12
- parameters: z.object({
13
- url: z.string().describe("The URL to fetch content from"),
14
- format: z
15
- .enum(["text", "markdown", "html"])
16
- .default("markdown")
17
- .describe("The format to return the content in (text, markdown, or html). Defaults to markdown."),
18
- timeout: z.number().describe("Optional timeout in seconds (max 120)").optional(),
19
- }),
20
- async execute(params, ctx) {
21
- // Validate URL
22
- if (!params.url.startsWith("http://") && !params.url.startsWith("https://")) {
23
- throw new Error("URL must start with http:// or https://")
24
- }
25
-
26
- await ctx.ask({
27
- permission: "webfetch",
28
- patterns: [params.url],
29
- always: ["*"],
30
- metadata: {
31
- url: params.url,
32
- format: params.format,
33
- timeout: params.timeout,
34
- },
35
- })
36
-
37
- const timeout = Math.min((params.timeout ?? DEFAULT_TIMEOUT / 1000) * 1000, MAX_TIMEOUT)
38
-
39
- const controller = new AbortController()
40
- const timeoutId = setTimeout(() => controller.abort(), timeout)
41
-
42
- // Build Accept header based on requested format with q parameters for fallbacks
43
- let acceptHeader = "*/*"
44
- switch (params.format) {
45
- case "markdown":
46
- acceptHeader = "text/markdown;q=1.0, text/x-markdown;q=0.9, text/plain;q=0.8, text/html;q=0.7, */*;q=0.1"
47
- break
48
- case "text":
49
- acceptHeader = "text/plain;q=1.0, text/markdown;q=0.9, text/html;q=0.8, */*;q=0.1"
50
- break
51
- case "html":
52
- acceptHeader = "text/html;q=1.0, application/xhtml+xml;q=0.9, text/plain;q=0.8, text/markdown;q=0.7, */*;q=0.1"
53
- break
54
- default:
55
- acceptHeader =
56
- "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8"
57
- }
58
-
59
- const response = await fetch(params.url, {
60
- signal: AbortSignal.any([controller.signal, ctx.abort]),
61
- headers: {
62
- "User-Agent":
63
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
64
- Accept: acceptHeader,
65
- "Accept-Language": "en-US,en;q=0.9",
66
- },
67
- })
68
-
69
- clearTimeout(timeoutId)
70
-
71
- if (!response.ok) {
72
- throw new Error(`Request failed with status code: ${response.status}`)
73
- }
74
-
75
- // Check content length
76
- const contentLength = response.headers.get("content-length")
77
- if (contentLength && parseInt(contentLength) > MAX_RESPONSE_SIZE) {
78
- throw new Error("Response too large (exceeds 5MB limit)")
79
- }
80
-
81
- const arrayBuffer = await response.arrayBuffer()
82
- if (arrayBuffer.byteLength > MAX_RESPONSE_SIZE) {
83
- throw new Error("Response too large (exceeds 5MB limit)")
84
- }
85
-
86
- const content = new TextDecoder().decode(arrayBuffer)
87
- const contentType = response.headers.get("content-type") || ""
88
-
89
- const title = `${params.url} (${contentType})`
90
-
91
- // Handle content based on requested format and actual content type
92
- switch (params.format) {
93
- case "markdown":
94
- if (contentType.includes("text/html")) {
95
- const markdown = convertHTMLToMarkdown(content)
96
- return {
97
- output: markdown,
98
- title,
99
- metadata: {},
100
- }
101
- }
102
- return {
103
- output: content,
104
- title,
105
- metadata: {},
106
- }
107
-
108
- case "text":
109
- if (contentType.includes("text/html")) {
110
- const text = await extractTextFromHTML(content)
111
- return {
112
- output: text,
113
- title,
114
- metadata: {},
115
- }
116
- }
117
- return {
118
- output: content,
119
- title,
120
- metadata: {},
121
- }
122
-
123
- case "html":
124
- return {
125
- output: content,
126
- title,
127
- metadata: {},
128
- }
129
-
130
- default:
131
- return {
132
- output: content,
133
- title,
134
- metadata: {},
135
- }
136
- }
137
- },
138
- })
139
-
140
- async function extractTextFromHTML(html: string) {
141
- let text = ""
142
- let skipContent = false
143
-
144
- const rewriter = new HTMLRewriter()
145
- .on("script, style, noscript, iframe, object, embed", {
146
- element() {
147
- skipContent = true
148
- },
149
- text() {
150
- // Skip text content inside these elements
151
- },
152
- })
153
- .on("*", {
154
- element(element) {
155
- // Reset skip flag when entering other elements
156
- if (!["script", "style", "noscript", "iframe", "object", "embed"].includes(element.tagName)) {
157
- skipContent = false
158
- }
159
- },
160
- text(input) {
161
- if (!skipContent) {
162
- text += input.text
163
- }
164
- },
165
- })
166
- .transform(new Response(html))
167
-
168
- await rewriter.text()
169
- return text.trim()
170
- }
171
-
172
- function convertHTMLToMarkdown(html: string): string {
173
- const turndownService = new TurndownService({
174
- headingStyle: "atx",
175
- hr: "---",
176
- bulletListMarker: "-",
177
- codeBlockStyle: "fenced",
178
- emDelimiter: "*",
179
- })
180
- turndownService.remove(["script", "style", "meta", "link"])
181
- return turndownService.turndown(html)
182
- }
@@ -1,13 +0,0 @@
1
- - Fetches content from a specified URL
2
- - Takes a URL and optional format as input
3
- - Fetches the URL content, converts to requested format (markdown by default)
4
- - Returns the content in the specified format
5
- - Use this tool when you need to retrieve and analyze web content
6
-
7
- Usage notes:
8
- - IMPORTANT: if another tool is present that offers better web fetching capabilities, is more targeted to the task, or has fewer restrictions, prefer using that tool instead of this one.
9
- - The URL must be a fully-formed valid URL
10
- - HTTP URLs will be automatically upgraded to HTTPS
11
- - Format options: "markdown" (default), "text", or "html"
12
- - This tool is read-only and does not modify any files
13
- - Results may be summarized if the content is very large
@@ -1,144 +0,0 @@
1
- import z from "zod"
2
- import { Tool } from "./tool"
3
- import DESCRIPTION from "./websearch.txt"
4
-
5
- const API_CONFIG = {
6
- BASE_URL: "https://mcp.exa.ai",
7
- ENDPOINTS: {
8
- SEARCH: "/mcp",
9
- },
10
- DEFAULT_NUM_RESULTS: 8,
11
- } as const
12
-
13
- interface McpSearchRequest {
14
- jsonrpc: string
15
- id: number
16
- method: string
17
- params: {
18
- name: string
19
- arguments: {
20
- query: string
21
- numResults?: number
22
- livecrawl?: "fallback" | "preferred"
23
- type?: "auto" | "fast" | "deep"
24
- contextMaxCharacters?: number
25
- }
26
- }
27
- }
28
-
29
- interface McpSearchResponse {
30
- jsonrpc: string
31
- result: {
32
- content: Array<{
33
- type: string
34
- text: string
35
- }>
36
- }
37
- }
38
-
39
- export const WebSearchTool = Tool.define("websearch", {
40
- description: DESCRIPTION,
41
- parameters: z.object({
42
- query: z.string().describe("Websearch query"),
43
- numResults: z.number().optional().describe("Number of search results to return (default: 8)"),
44
- livecrawl: z
45
- .enum(["fallback", "preferred"])
46
- .optional()
47
- .describe(
48
- "Live crawl mode - 'fallback': use live crawling as backup if cached content unavailable, 'preferred': prioritize live crawling (default: 'fallback')",
49
- ),
50
- type: z
51
- .enum(["auto", "fast", "deep"])
52
- .optional()
53
- .describe("Search type - 'auto': balanced search (default), 'fast': quick results, 'deep': comprehensive search"),
54
- contextMaxCharacters: z
55
- .number()
56
- .optional()
57
- .describe("Maximum characters for context string optimized for LLMs (default: 10000)"),
58
- }),
59
- async execute(params, ctx) {
60
- await ctx.ask({
61
- permission: "websearch",
62
- patterns: [params.query],
63
- always: ["*"],
64
- metadata: {
65
- query: params.query,
66
- numResults: params.numResults,
67
- livecrawl: params.livecrawl,
68
- type: params.type,
69
- contextMaxCharacters: params.contextMaxCharacters,
70
- },
71
- })
72
-
73
- const searchRequest: McpSearchRequest = {
74
- jsonrpc: "2.0",
75
- id: 1,
76
- method: "tools/call",
77
- params: {
78
- name: "web_search_exa",
79
- arguments: {
80
- query: params.query,
81
- type: params.type || "auto",
82
- numResults: params.numResults || API_CONFIG.DEFAULT_NUM_RESULTS,
83
- livecrawl: params.livecrawl || "fallback",
84
- contextMaxCharacters: params.contextMaxCharacters,
85
- },
86
- },
87
- }
88
-
89
- const controller = new AbortController()
90
- const timeoutId = setTimeout(() => controller.abort(), 25000)
91
-
92
- try {
93
- const headers: Record<string, string> = {
94
- accept: "application/json, text/event-stream",
95
- "content-type": "application/json",
96
- }
97
-
98
- const response = await fetch(`${API_CONFIG.BASE_URL}${API_CONFIG.ENDPOINTS.SEARCH}`, {
99
- method: "POST",
100
- headers,
101
- body: JSON.stringify(searchRequest),
102
- signal: AbortSignal.any([controller.signal, ctx.abort]),
103
- })
104
-
105
- clearTimeout(timeoutId)
106
-
107
- if (!response.ok) {
108
- const errorText = await response.text()
109
- throw new Error(`Search error (${response.status}): ${errorText}`)
110
- }
111
-
112
- const responseText = await response.text()
113
-
114
- // Parse SSE response
115
- const lines = responseText.split("\n")
116
- for (const line of lines) {
117
- if (line.startsWith("data: ")) {
118
- const data: McpSearchResponse = JSON.parse(line.substring(6))
119
- if (data.result && data.result.content && data.result.content.length > 0) {
120
- return {
121
- output: data.result.content[0].text,
122
- title: `Web search: ${params.query}`,
123
- metadata: {},
124
- }
125
- }
126
- }
127
- }
128
-
129
- return {
130
- output: "No search results found. Please try a different query.",
131
- title: `Web search: ${params.query}`,
132
- metadata: {},
133
- }
134
- } catch (error) {
135
- clearTimeout(timeoutId)
136
-
137
- if (error instanceof Error && error.name === "AbortError") {
138
- throw new Error("Search request timed out")
139
- }
140
-
141
- throw error
142
- }
143
- },
144
- })
@@ -1,11 +0,0 @@
1
- - Search the web using Exa AI - performs real-time web searches and can scrape content from specific URLs
2
- - Provides up-to-date information for current events and recent data
3
- - Supports configurable result counts and returns the content from the most relevant websites
4
- - Use this tool for accessing information beyond knowledge cutoff
5
- - Searches are performed automatically within a single API call
6
-
7
- Usage notes:
8
- - Supports live crawling modes: 'fallback' (backup if cached unavailable) or 'preferred' (prioritize live crawling)
9
- - Search types: 'auto' (balanced), 'fast' (quick results), 'deep' (comprehensive search)
10
- - Configurable context length for optimal LLM integration
11
- - Domain filtering and advanced search options available
package/src/tool/write.ts DELETED
@@ -1,84 +0,0 @@
1
- import z from "zod"
2
- import * as path from "path"
3
- import { Tool } from "./tool"
4
- import { LSP } from "../lsp"
5
- import { createTwoFilesPatch } from "diff"
6
- import DESCRIPTION from "./write.txt"
7
- import { Bus } from "../bus"
8
- import { File } from "../file"
9
- import { FileTime } from "../file/time"
10
- import { Filesystem } from "../util/filesystem"
11
- import { Instance } from "../project/instance"
12
- import { trimDiff } from "./edit"
13
-
14
- const MAX_DIAGNOSTICS_PER_FILE = 20
15
- const MAX_PROJECT_DIAGNOSTICS_FILES = 5
16
-
17
- export const WriteTool = Tool.define("write", {
18
- description: DESCRIPTION,
19
- parameters: z.object({
20
- content: z.string().describe("The content to write to the file"),
21
- filePath: z.string().describe("The absolute path to the file to write (must be absolute, not relative)"),
22
- }),
23
- async execute(params, ctx) {
24
- const filepath = path.isAbsolute(params.filePath) ? params.filePath : path.join(Instance.directory, params.filePath)
25
- /* TODO
26
- if (!Filesystem.contains(Instance.directory, filepath)) {
27
- const parentDir = path.dirname(filepath)
28
- ...
29
- }
30
- */
31
-
32
- const file = Bun.file(filepath)
33
- const exists = await file.exists()
34
- const contentOld = exists ? await file.text() : ""
35
- if (exists) await FileTime.assert(ctx.sessionID, filepath)
36
-
37
- const diff = trimDiff(createTwoFilesPatch(filepath, filepath, contentOld, params.content))
38
- await ctx.ask({
39
- permission: "edit",
40
- patterns: [path.relative(Instance.worktree, filepath)],
41
- always: ["*"],
42
- metadata: {
43
- filepath,
44
- diff,
45
- },
46
- })
47
-
48
- await Bun.write(filepath, params.content)
49
- await Bus.publish(File.Event.Edited, {
50
- file: filepath,
51
- })
52
- FileTime.read(ctx.sessionID, filepath)
53
-
54
- let output = ""
55
- await LSP.touchFile(filepath, true)
56
- const diagnostics = await LSP.diagnostics()
57
- const normalizedFilepath = Filesystem.normalizePath(filepath)
58
- let projectDiagnosticsCount = 0
59
- for (const [file, issues] of Object.entries(diagnostics)) {
60
- const errors = issues.filter((item) => item.severity === 1)
61
- if (errors.length === 0) continue
62
- const limited = errors.slice(0, MAX_DIAGNOSTICS_PER_FILE)
63
- const suffix =
64
- errors.length > MAX_DIAGNOSTICS_PER_FILE ? `\n... and ${errors.length - MAX_DIAGNOSTICS_PER_FILE} more` : ""
65
- if (file === normalizedFilepath) {
66
- output += `\nThis file has errors, please fix\n<file_diagnostics>\n${limited.map(LSP.Diagnostic.pretty).join("\n")}${suffix}\n</file_diagnostics>\n`
67
- continue
68
- }
69
- if (projectDiagnosticsCount >= MAX_PROJECT_DIAGNOSTICS_FILES) continue
70
- projectDiagnosticsCount++
71
- output += `\n<project_diagnostics>\n${file}\n${limited.map(LSP.Diagnostic.pretty).join("\n")}${suffix}\n</project_diagnostics>\n`
72
- }
73
-
74
- return {
75
- title: path.relative(Instance.worktree, filepath),
76
- metadata: {
77
- diagnostics,
78
- filepath,
79
- exists: exists,
80
- },
81
- output,
82
- }
83
- },
84
- })
@@ -1,8 +0,0 @@
1
- Writes a file to the local filesystem.
2
-
3
- Usage:
4
- - This tool will overwrite the existing file if there is one at the provided path.
5
- - If this is an existing file, you MUST use the Read tool first to read the file's contents. This tool will fail if you did not read the file first.
6
- - ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required.
7
- - NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested by the User.
8
- - Only use emojis if the user explicitly requests it. Avoid writing emojis to files unless asked.
@@ -1,16 +0,0 @@
1
- import { $ } from "bun"
2
- import path from "path"
3
-
4
- export namespace Archive {
5
- export async function extractZip(zipPath: string, destDir: string) {
6
- if (process.platform === "win32") {
7
- const winZipPath = path.resolve(zipPath)
8
- const winDestDir = path.resolve(destDir)
9
- // $global:ProgressPreference suppresses PowerShell's blue progress bar popup
10
- const cmd = `$global:ProgressPreference = 'SilentlyContinue'; Expand-Archive -Path '${winZipPath}' -DestinationPath '${winDestDir}' -Force`
11
- await $`powershell -NoProfile -NonInteractive -Command ${cmd}`.quiet()
12
- } else {
13
- await $`unzip -o -q ${zipPath} -d ${destDir}`.quiet()
14
- }
15
- }
16
- }
package/src/util/color.ts DELETED
@@ -1,19 +0,0 @@
1
- export namespace Color {
2
- export function isValidHex(hex?: string): hex is string {
3
- if (!hex) return false
4
- return /^#[0-9a-fA-F]{6}$/.test(hex)
5
- }
6
-
7
- export function hexToRgb(hex: string): { r: number; g: number; b: number } {
8
- const r = parseInt(hex.slice(1, 3), 16)
9
- const g = parseInt(hex.slice(3, 5), 16)
10
- const b = parseInt(hex.slice(5, 7), 16)
11
- return { r, g, b }
12
- }
13
-
14
- export function hexToAnsiBold(hex?: string): string | undefined {
15
- if (!isValidHex(hex)) return undefined
16
- const { r, g, b } = hexToRgb(hex)
17
- return `\x1b[38;2;${r};${g};${b}m\x1b[1m`
18
- }
19
- }
@@ -1,25 +0,0 @@
1
- import { AsyncLocalStorage } from "async_hooks"
2
-
3
- export namespace Context {
4
- export class NotFound extends Error {
5
- constructor(public override readonly name: string) {
6
- super(`No context found for ${name}`)
7
- }
8
- }
9
-
10
- export function create<T>(name: string) {
11
- const storage = new AsyncLocalStorage<T>()
12
- return {
13
- use() {
14
- const result = storage.getStore()
15
- if (!result) {
16
- throw new NotFound(name)
17
- }
18
- return result
19
- },
20
- provide<R>(value: T, fn: () => R) {
21
- return storage.run(value, fn)
22
- },
23
- }
24
- }
25
- }
package/src/util/defer.ts DELETED
@@ -1,12 +0,0 @@
1
- export function defer<T extends () => void | Promise<void>>(
2
- fn: T,
3
- ): T extends () => Promise<void> ? { [Symbol.asyncDispose]: () => Promise<void> } : { [Symbol.dispose]: () => void } {
4
- return {
5
- [Symbol.dispose]() {
6
- fn()
7
- },
8
- [Symbol.asyncDispose]() {
9
- return Promise.resolve(fn())
10
- },
11
- } as any
12
- }
@@ -1,20 +0,0 @@
1
- import { Log } from "./log"
2
-
3
- export namespace EventLoop {
4
- export async function wait() {
5
- return new Promise<void>((resolve) => {
6
- const check = () => {
7
- const active = [...(process as any)._getActiveHandles(), ...(process as any)._getActiveRequests()]
8
- Log.Default.info("eventloop", {
9
- active,
10
- })
11
- if ((process as any)._getActiveHandles().length === 0 && (process as any)._getActiveRequests().length === 0) {
12
- resolve()
13
- } else {
14
- setImmediate(check)
15
- }
16
- }
17
- check()
18
- })
19
- }
20
- }
@@ -1,83 +0,0 @@
1
- import { realpathSync } from "fs"
2
- import { exists } from "fs/promises"
3
- import { dirname, join, relative } from "path"
4
-
5
- export namespace Filesystem {
6
- /**
7
- * On Windows, normalize a path to its canonical casing using the filesystem.
8
- * This is needed because Windows paths are case-insensitive but LSP servers
9
- * may return paths with different casing than what we send them.
10
- */
11
- export function normalizePath(p: string): string {
12
- if (process.platform !== "win32") return p
13
- try {
14
- return realpathSync.native(p)
15
- } catch {
16
- return p
17
- }
18
- }
19
- export function overlaps(a: string, b: string) {
20
- const relA = relative(a, b)
21
- const relB = relative(b, a)
22
- return !relA || !relA.startsWith("..") || !relB || !relB.startsWith("..")
23
- }
24
-
25
- export function contains(parent: string, child: string) {
26
- return !relative(parent, child).startsWith("..")
27
- }
28
-
29
- export async function findUp(target: string, start: string, stop?: string) {
30
- let current = start
31
- const result = []
32
- while (true) {
33
- const search = join(current, target)
34
- if (await exists(search)) result.push(search)
35
- if (stop === current) break
36
- const parent = dirname(current)
37
- if (parent === current) break
38
- current = parent
39
- }
40
- return result
41
- }
42
-
43
- export async function* up(options: { targets: string[]; start: string; stop?: string }) {
44
- const { targets, start, stop } = options
45
- let current = start
46
- while (true) {
47
- for (const target of targets) {
48
- const search = join(current, target)
49
- if (await exists(search)) yield search
50
- }
51
- if (stop === current) break
52
- const parent = dirname(current)
53
- if (parent === current) break
54
- current = parent
55
- }
56
- }
57
-
58
- export async function globUp(pattern: string, start: string, stop?: string) {
59
- let current = start
60
- const result = []
61
- while (true) {
62
- try {
63
- const glob = new Bun.Glob(pattern)
64
- for await (const match of glob.scan({
65
- cwd: current,
66
- absolute: true,
67
- onlyFiles: true,
68
- followSymlinks: true,
69
- dot: true,
70
- })) {
71
- result.push(match)
72
- }
73
- } catch {
74
- // Skip invalid glob patterns
75
- }
76
- if (stop === current) break
77
- const parent = dirname(current)
78
- if (parent === current) break
79
- current = parent
80
- }
81
- return result
82
- }
83
- }
package/src/util/fn.ts DELETED
@@ -1,11 +0,0 @@
1
- import { z } from "zod"
2
-
3
- export function fn<T extends z.ZodType, Result>(schema: T, cb: (input: z.infer<T>) => Result) {
4
- const result = (input: z.infer<T>) => {
5
- const parsed = schema.parse(input)
6
- return cb(parsed)
7
- }
8
- result.force = (input: z.infer<T>) => cb(input)
9
- result.schema = schema
10
- return result
11
- }
package/src/util/iife.ts DELETED
@@ -1,3 +0,0 @@
1
- export function iife<T>(fn: () => T) {
2
- return fn()
3
- }