dfcode 1.0.0 → 1.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 (345) hide show
  1. package/bin/dfcode +13 -0
  2. package/bin/dfcode-bin +0 -0
  3. package/package.json +24 -101
  4. package/LICENSE +0 -21
  5. package/packages/dfcode/README.md +0 -15
  6. package/packages/dfcode/bin/dfcode +0 -84
  7. package/packages/dfcode/package.json +0 -115
  8. package/packages/dfcode/src/acp/README.md +0 -164
  9. package/packages/dfcode/src/acp/agent.ts +0 -1437
  10. package/packages/dfcode/src/acp/session.ts +0 -105
  11. package/packages/dfcode/src/acp/types.ts +0 -22
  12. package/packages/dfcode/src/agent/agent.ts +0 -332
  13. package/packages/dfcode/src/agent/generate.txt +0 -75
  14. package/packages/dfcode/src/agent/prompt/compaction.txt +0 -12
  15. package/packages/dfcode/src/agent/prompt/explore.txt +0 -18
  16. package/packages/dfcode/src/agent/prompt/summary.txt +0 -11
  17. package/packages/dfcode/src/agent/prompt/title.txt +0 -44
  18. package/packages/dfcode/src/auth/index.ts +0 -73
  19. package/packages/dfcode/src/bun/index.ts +0 -134
  20. package/packages/dfcode/src/bus/bus-event.ts +0 -43
  21. package/packages/dfcode/src/bus/global.ts +0 -10
  22. package/packages/dfcode/src/bus/index.ts +0 -105
  23. package/packages/dfcode/src/cli/bootstrap.ts +0 -17
  24. package/packages/dfcode/src/cli/cmd/acp.ts +0 -69
  25. package/packages/dfcode/src/cli/cmd/agent.ts +0 -257
  26. package/packages/dfcode/src/cli/cmd/auth.ts +0 -400
  27. package/packages/dfcode/src/cli/cmd/cmd.ts +0 -7
  28. package/packages/dfcode/src/cli/cmd/debug/agent.ts +0 -166
  29. package/packages/dfcode/src/cli/cmd/debug/config.ts +0 -16
  30. package/packages/dfcode/src/cli/cmd/debug/file.ts +0 -97
  31. package/packages/dfcode/src/cli/cmd/debug/index.ts +0 -48
  32. package/packages/dfcode/src/cli/cmd/debug/lsp.ts +0 -52
  33. package/packages/dfcode/src/cli/cmd/debug/ripgrep.ts +0 -87
  34. package/packages/dfcode/src/cli/cmd/debug/scrap.ts +0 -16
  35. package/packages/dfcode/src/cli/cmd/debug/skill.ts +0 -16
  36. package/packages/dfcode/src/cli/cmd/debug/snapshot.ts +0 -52
  37. package/packages/dfcode/src/cli/cmd/export.ts +0 -88
  38. package/packages/dfcode/src/cli/cmd/generate.ts +0 -38
  39. package/packages/dfcode/src/cli/cmd/github.ts +0 -1548
  40. package/packages/dfcode/src/cli/cmd/import.ts +0 -98
  41. package/packages/dfcode/src/cli/cmd/mcp.ts +0 -755
  42. package/packages/dfcode/src/cli/cmd/models.ts +0 -77
  43. package/packages/dfcode/src/cli/cmd/pr.ts +0 -112
  44. package/packages/dfcode/src/cli/cmd/run.ts +0 -395
  45. package/packages/dfcode/src/cli/cmd/serve.ts +0 -20
  46. package/packages/dfcode/src/cli/cmd/session.ts +0 -135
  47. package/packages/dfcode/src/cli/cmd/stats.ts +0 -402
  48. package/packages/dfcode/src/cli/cmd/tui/app.tsx +0 -750
  49. package/packages/dfcode/src/cli/cmd/tui/attach.ts +0 -39
  50. package/packages/dfcode/src/cli/cmd/tui/component/border.tsx +0 -21
  51. package/packages/dfcode/src/cli/cmd/tui/component/dialog-agent.tsx +0 -31
  52. package/packages/dfcode/src/cli/cmd/tui/component/dialog-command.tsx +0 -148
  53. package/packages/dfcode/src/cli/cmd/tui/component/dialog-mcp.tsx +0 -86
  54. package/packages/dfcode/src/cli/cmd/tui/component/dialog-model.tsx +0 -234
  55. package/packages/dfcode/src/cli/cmd/tui/component/dialog-provider.tsx +0 -256
  56. package/packages/dfcode/src/cli/cmd/tui/component/dialog-session-list.tsx +0 -114
  57. package/packages/dfcode/src/cli/cmd/tui/component/dialog-session-rename.tsx +0 -31
  58. package/packages/dfcode/src/cli/cmd/tui/component/dialog-stash.tsx +0 -87
  59. package/packages/dfcode/src/cli/cmd/tui/component/dialog-status.tsx +0 -164
  60. package/packages/dfcode/src/cli/cmd/tui/component/dialog-tag.tsx +0 -44
  61. package/packages/dfcode/src/cli/cmd/tui/component/dialog-theme-list.tsx +0 -50
  62. package/packages/dfcode/src/cli/cmd/tui/component/logo.tsx +0 -88
  63. package/packages/dfcode/src/cli/cmd/tui/component/prompt/autocomplete.tsx +0 -653
  64. package/packages/dfcode/src/cli/cmd/tui/component/prompt/frecency.tsx +0 -89
  65. package/packages/dfcode/src/cli/cmd/tui/component/prompt/history.tsx +0 -108
  66. package/packages/dfcode/src/cli/cmd/tui/component/prompt/index.tsx +0 -1102
  67. package/packages/dfcode/src/cli/cmd/tui/component/prompt/stash.tsx +0 -101
  68. package/packages/dfcode/src/cli/cmd/tui/component/textarea-keybindings.ts +0 -73
  69. package/packages/dfcode/src/cli/cmd/tui/component/tips.tsx +0 -153
  70. package/packages/dfcode/src/cli/cmd/tui/component/todo-item.tsx +0 -32
  71. package/packages/dfcode/src/cli/cmd/tui/context/args.tsx +0 -14
  72. package/packages/dfcode/src/cli/cmd/tui/context/directory.ts +0 -13
  73. package/packages/dfcode/src/cli/cmd/tui/context/exit.tsx +0 -23
  74. package/packages/dfcode/src/cli/cmd/tui/context/helper.tsx +0 -25
  75. package/packages/dfcode/src/cli/cmd/tui/context/keybind.tsx +0 -101
  76. package/packages/dfcode/src/cli/cmd/tui/context/kv.tsx +0 -52
  77. package/packages/dfcode/src/cli/cmd/tui/context/local.tsx +0 -402
  78. package/packages/dfcode/src/cli/cmd/tui/context/prompt.tsx +0 -18
  79. package/packages/dfcode/src/cli/cmd/tui/context/route.tsx +0 -46
  80. package/packages/dfcode/src/cli/cmd/tui/context/sdk.tsx +0 -94
  81. package/packages/dfcode/src/cli/cmd/tui/context/sync.tsx +0 -445
  82. package/packages/dfcode/src/cli/cmd/tui/context/theme/aura.json +0 -69
  83. package/packages/dfcode/src/cli/cmd/tui/context/theme/ayu.json +0 -80
  84. package/packages/dfcode/src/cli/cmd/tui/context/theme/carbonfox.json +0 -248
  85. package/packages/dfcode/src/cli/cmd/tui/context/theme/catppuccin-frappe.json +0 -233
  86. package/packages/dfcode/src/cli/cmd/tui/context/theme/catppuccin-macchiato.json +0 -233
  87. package/packages/dfcode/src/cli/cmd/tui/context/theme/catppuccin.json +0 -112
  88. package/packages/dfcode/src/cli/cmd/tui/context/theme/cobalt2.json +0 -228
  89. package/packages/dfcode/src/cli/cmd/tui/context/theme/cursor.json +0 -249
  90. package/packages/dfcode/src/cli/cmd/tui/context/theme/dfcode.json +0 -245
  91. package/packages/dfcode/src/cli/cmd/tui/context/theme/dracula.json +0 -219
  92. package/packages/dfcode/src/cli/cmd/tui/context/theme/everforest.json +0 -241
  93. package/packages/dfcode/src/cli/cmd/tui/context/theme/flexoki.json +0 -237
  94. package/packages/dfcode/src/cli/cmd/tui/context/theme/github.json +0 -233
  95. package/packages/dfcode/src/cli/cmd/tui/context/theme/gruvbox.json +0 -242
  96. package/packages/dfcode/src/cli/cmd/tui/context/theme/kanagawa.json +0 -77
  97. package/packages/dfcode/src/cli/cmd/tui/context/theme/lucent-orng.json +0 -237
  98. package/packages/dfcode/src/cli/cmd/tui/context/theme/material.json +0 -235
  99. package/packages/dfcode/src/cli/cmd/tui/context/theme/matrix.json +0 -77
  100. package/packages/dfcode/src/cli/cmd/tui/context/theme/mercury.json +0 -252
  101. package/packages/dfcode/src/cli/cmd/tui/context/theme/monokai.json +0 -221
  102. package/packages/dfcode/src/cli/cmd/tui/context/theme/nightowl.json +0 -221
  103. package/packages/dfcode/src/cli/cmd/tui/context/theme/nord.json +0 -223
  104. package/packages/dfcode/src/cli/cmd/tui/context/theme/one-dark.json +0 -84
  105. package/packages/dfcode/src/cli/cmd/tui/context/theme/orng.json +0 -249
  106. package/packages/dfcode/src/cli/cmd/tui/context/theme/osaka-jade.json +0 -93
  107. package/packages/dfcode/src/cli/cmd/tui/context/theme/palenight.json +0 -222
  108. package/packages/dfcode/src/cli/cmd/tui/context/theme/rosepine.json +0 -234
  109. package/packages/dfcode/src/cli/cmd/tui/context/theme/solarized.json +0 -223
  110. package/packages/dfcode/src/cli/cmd/tui/context/theme/synthwave84.json +0 -226
  111. package/packages/dfcode/src/cli/cmd/tui/context/theme/tokyonight.json +0 -243
  112. package/packages/dfcode/src/cli/cmd/tui/context/theme/vercel.json +0 -245
  113. package/packages/dfcode/src/cli/cmd/tui/context/theme/vesper.json +0 -218
  114. package/packages/dfcode/src/cli/cmd/tui/context/theme/zenburn.json +0 -223
  115. package/packages/dfcode/src/cli/cmd/tui/context/theme.tsx +0 -1152
  116. package/packages/dfcode/src/cli/cmd/tui/event.ts +0 -48
  117. package/packages/dfcode/src/cli/cmd/tui/routes/home.tsx +0 -140
  118. package/packages/dfcode/src/cli/cmd/tui/routes/session/dialog-fork-from-timeline.tsx +0 -64
  119. package/packages/dfcode/src/cli/cmd/tui/routes/session/dialog-message.tsx +0 -109
  120. package/packages/dfcode/src/cli/cmd/tui/routes/session/dialog-subagent.tsx +0 -26
  121. package/packages/dfcode/src/cli/cmd/tui/routes/session/dialog-timeline.tsx +0 -47
  122. package/packages/dfcode/src/cli/cmd/tui/routes/session/footer.tsx +0 -91
  123. package/packages/dfcode/src/cli/cmd/tui/routes/session/header.tsx +0 -142
  124. package/packages/dfcode/src/cli/cmd/tui/routes/session/index.tsx +0 -2050
  125. package/packages/dfcode/src/cli/cmd/tui/routes/session/permission.tsx +0 -508
  126. package/packages/dfcode/src/cli/cmd/tui/routes/session/question.tsx +0 -453
  127. package/packages/dfcode/src/cli/cmd/tui/routes/session/sidebar.tsx +0 -313
  128. package/packages/dfcode/src/cli/cmd/tui/thread.ts +0 -165
  129. package/packages/dfcode/src/cli/cmd/tui/ui/dialog-alert.tsx +0 -57
  130. package/packages/dfcode/src/cli/cmd/tui/ui/dialog-confirm.tsx +0 -83
  131. package/packages/dfcode/src/cli/cmd/tui/ui/dialog-export-options.tsx +0 -204
  132. package/packages/dfcode/src/cli/cmd/tui/ui/dialog-help.tsx +0 -43
  133. package/packages/dfcode/src/cli/cmd/tui/ui/dialog-prompt.tsx +0 -77
  134. package/packages/dfcode/src/cli/cmd/tui/ui/dialog-select.tsx +0 -384
  135. package/packages/dfcode/src/cli/cmd/tui/ui/dialog.tsx +0 -167
  136. package/packages/dfcode/src/cli/cmd/tui/ui/link.tsx +0 -28
  137. package/packages/dfcode/src/cli/cmd/tui/ui/spinner.ts +0 -368
  138. package/packages/dfcode/src/cli/cmd/tui/ui/toast.tsx +0 -100
  139. package/packages/dfcode/src/cli/cmd/tui/util/clipboard.ts +0 -160
  140. package/packages/dfcode/src/cli/cmd/tui/util/editor.ts +0 -32
  141. package/packages/dfcode/src/cli/cmd/tui/util/signal.ts +0 -7
  142. package/packages/dfcode/src/cli/cmd/tui/util/terminal.ts +0 -114
  143. package/packages/dfcode/src/cli/cmd/tui/util/transcript.ts +0 -98
  144. package/packages/dfcode/src/cli/cmd/tui/worker.ts +0 -152
  145. package/packages/dfcode/src/cli/cmd/uninstall.ts +0 -357
  146. package/packages/dfcode/src/cli/cmd/upgrade.ts +0 -73
  147. package/packages/dfcode/src/cli/cmd/web.ts +0 -81
  148. package/packages/dfcode/src/cli/error.ts +0 -57
  149. package/packages/dfcode/src/cli/network.ts +0 -53
  150. package/packages/dfcode/src/cli/ui.ts +0 -83
  151. package/packages/dfcode/src/cli/upgrade.ts +0 -25
  152. package/packages/dfcode/src/command/index.ts +0 -131
  153. package/packages/dfcode/src/command/template/initialize.txt +0 -10
  154. package/packages/dfcode/src/command/template/review.txt +0 -99
  155. package/packages/dfcode/src/config/config.ts +0 -1367
  156. package/packages/dfcode/src/config/markdown.ts +0 -93
  157. package/packages/dfcode/src/env/index.ts +0 -26
  158. package/packages/dfcode/src/file/ignore.ts +0 -83
  159. package/packages/dfcode/src/file/index.ts +0 -411
  160. package/packages/dfcode/src/file/ripgrep.ts +0 -407
  161. package/packages/dfcode/src/file/time.ts +0 -69
  162. package/packages/dfcode/src/file/watcher.ts +0 -127
  163. package/packages/dfcode/src/flag/flag.ts +0 -79
  164. package/packages/dfcode/src/format/formatter.ts +0 -357
  165. package/packages/dfcode/src/format/index.ts +0 -137
  166. package/packages/dfcode/src/global/index.ts +0 -55
  167. package/packages/dfcode/src/id/id.ts +0 -83
  168. package/packages/dfcode/src/ide/index.ts +0 -76
  169. package/packages/dfcode/src/index.ts +0 -159
  170. package/packages/dfcode/src/installation/index.ts +0 -246
  171. package/packages/dfcode/src/lsp/client.ts +0 -252
  172. package/packages/dfcode/src/lsp/index.ts +0 -485
  173. package/packages/dfcode/src/lsp/language.ts +0 -119
  174. package/packages/dfcode/src/lsp/server.ts +0 -2046
  175. package/packages/dfcode/src/mcp/auth.ts +0 -135
  176. package/packages/dfcode/src/mcp/index.ts +0 -934
  177. package/packages/dfcode/src/mcp/oauth-callback.ts +0 -200
  178. package/packages/dfcode/src/mcp/oauth-provider.ts +0 -154
  179. package/packages/dfcode/src/patch/index.ts +0 -680
  180. package/packages/dfcode/src/permission/arity.ts +0 -163
  181. package/packages/dfcode/src/permission/index.ts +0 -210
  182. package/packages/dfcode/src/permission/next.ts +0 -280
  183. package/packages/dfcode/src/plugin/codex.ts +0 -506
  184. package/packages/dfcode/src/plugin/copilot.ts +0 -283
  185. package/packages/dfcode/src/plugin/index.ts +0 -135
  186. package/packages/dfcode/src/project/bootstrap.ts +0 -35
  187. package/packages/dfcode/src/project/instance.ts +0 -91
  188. package/packages/dfcode/src/project/project.ts +0 -371
  189. package/packages/dfcode/src/project/state.ts +0 -66
  190. package/packages/dfcode/src/project/vcs.ts +0 -76
  191. package/packages/dfcode/src/provider/auth.ts +0 -147
  192. package/packages/dfcode/src/provider/models.ts +0 -136
  193. package/packages/dfcode/src/provider/provider.ts +0 -1219
  194. package/packages/dfcode/src/provider/sdk/openai-compatible/src/README.md +0 -5
  195. package/packages/dfcode/src/provider/sdk/openai-compatible/src/index.ts +0 -2
  196. package/packages/dfcode/src/provider/sdk/openai-compatible/src/openai-compatible-provider.ts +0 -100
  197. package/packages/dfcode/src/provider/sdk/openai-compatible/src/responses/convert-to-openai-responses-input.ts +0 -303
  198. package/packages/dfcode/src/provider/sdk/openai-compatible/src/responses/map-openai-responses-finish-reason.ts +0 -22
  199. package/packages/dfcode/src/provider/sdk/openai-compatible/src/responses/openai-config.ts +0 -18
  200. package/packages/dfcode/src/provider/sdk/openai-compatible/src/responses/openai-error.ts +0 -22
  201. package/packages/dfcode/src/provider/sdk/openai-compatible/src/responses/openai-responses-api-types.ts +0 -207
  202. package/packages/dfcode/src/provider/sdk/openai-compatible/src/responses/openai-responses-language-model.ts +0 -1732
  203. package/packages/dfcode/src/provider/sdk/openai-compatible/src/responses/openai-responses-prepare-tools.ts +0 -177
  204. package/packages/dfcode/src/provider/sdk/openai-compatible/src/responses/openai-responses-settings.ts +0 -1
  205. package/packages/dfcode/src/provider/sdk/openai-compatible/src/responses/tool/code-interpreter.ts +0 -88
  206. package/packages/dfcode/src/provider/sdk/openai-compatible/src/responses/tool/file-search.ts +0 -128
  207. package/packages/dfcode/src/provider/sdk/openai-compatible/src/responses/tool/image-generation.ts +0 -115
  208. package/packages/dfcode/src/provider/sdk/openai-compatible/src/responses/tool/local-shell.ts +0 -65
  209. package/packages/dfcode/src/provider/sdk/openai-compatible/src/responses/tool/web-search-preview.ts +0 -104
  210. package/packages/dfcode/src/provider/sdk/openai-compatible/src/responses/tool/web-search.ts +0 -103
  211. package/packages/dfcode/src/provider/transform.ts +0 -741
  212. package/packages/dfcode/src/pty/index.ts +0 -241
  213. package/packages/dfcode/src/question/index.ts +0 -171
  214. package/packages/dfcode/src/scheduler/index.ts +0 -61
  215. package/packages/dfcode/src/server/error.ts +0 -36
  216. package/packages/dfcode/src/server/event.ts +0 -7
  217. package/packages/dfcode/src/server/mdns.ts +0 -59
  218. package/packages/dfcode/src/server/routes/config.ts +0 -92
  219. package/packages/dfcode/src/server/routes/experimental.ts +0 -208
  220. package/packages/dfcode/src/server/routes/file.ts +0 -197
  221. package/packages/dfcode/src/server/routes/global.ts +0 -135
  222. package/packages/dfcode/src/server/routes/mcp.ts +0 -225
  223. package/packages/dfcode/src/server/routes/permission.ts +0 -68
  224. package/packages/dfcode/src/server/routes/project.ts +0 -82
  225. package/packages/dfcode/src/server/routes/provider.ts +0 -165
  226. package/packages/dfcode/src/server/routes/pty.ts +0 -169
  227. package/packages/dfcode/src/server/routes/question.ts +0 -98
  228. package/packages/dfcode/src/server/routes/session.ts +0 -939
  229. package/packages/dfcode/src/server/routes/tui.ts +0 -379
  230. package/packages/dfcode/src/server/server.ts +0 -574
  231. package/packages/dfcode/src/session/compaction.ts +0 -225
  232. package/packages/dfcode/src/session/index.ts +0 -498
  233. package/packages/dfcode/src/session/llm.ts +0 -288
  234. package/packages/dfcode/src/session/message-v2.ts +0 -740
  235. package/packages/dfcode/src/session/message.ts +0 -189
  236. package/packages/dfcode/src/session/processor.ts +0 -406
  237. package/packages/dfcode/src/session/prompt/anthropic-20250930.txt +0 -164
  238. package/packages/dfcode/src/session/prompt/anthropic.txt +0 -102
  239. package/packages/dfcode/src/session/prompt/anthropic_spoof.txt +0 -1
  240. package/packages/dfcode/src/session/prompt/beast.txt +0 -147
  241. package/packages/dfcode/src/session/prompt/build-switch.txt +0 -5
  242. package/packages/dfcode/src/session/prompt/codex_header.txt +0 -79
  243. package/packages/dfcode/src/session/prompt/copilot-gpt-5.txt +0 -143
  244. package/packages/dfcode/src/session/prompt/gemini.txt +0 -155
  245. package/packages/dfcode/src/session/prompt/max-steps.txt +0 -16
  246. package/packages/dfcode/src/session/prompt/plan-reminder-anthropic.txt +0 -67
  247. package/packages/dfcode/src/session/prompt/plan.txt +0 -26
  248. package/packages/dfcode/src/session/prompt/qwen.txt +0 -107
  249. package/packages/dfcode/src/session/prompt.ts +0 -1815
  250. package/packages/dfcode/src/session/retry.ts +0 -90
  251. package/packages/dfcode/src/session/revert.ts +0 -121
  252. package/packages/dfcode/src/session/status.ts +0 -76
  253. package/packages/dfcode/src/session/summary.ts +0 -150
  254. package/packages/dfcode/src/session/system.ts +0 -157
  255. package/packages/dfcode/src/session/todo.ts +0 -37
  256. package/packages/dfcode/src/share/share-next.ts +0 -200
  257. package/packages/dfcode/src/share/share.ts +0 -92
  258. package/packages/dfcode/src/shell/shell.ts +0 -67
  259. package/packages/dfcode/src/skill/index.ts +0 -1
  260. package/packages/dfcode/src/skill/skill.ts +0 -135
  261. package/packages/dfcode/src/snapshot/index.ts +0 -236
  262. package/packages/dfcode/src/storage/storage.ts +0 -227
  263. package/packages/dfcode/src/tool/apply_patch.ts +0 -280
  264. package/packages/dfcode/src/tool/apply_patch.txt +0 -33
  265. package/packages/dfcode/src/tool/bash.ts +0 -258
  266. package/packages/dfcode/src/tool/bash.txt +0 -115
  267. package/packages/dfcode/src/tool/batch.ts +0 -175
  268. package/packages/dfcode/src/tool/batch.txt +0 -24
  269. package/packages/dfcode/src/tool/codesearch.ts +0 -132
  270. package/packages/dfcode/src/tool/codesearch.txt +0 -12
  271. package/packages/dfcode/src/tool/edit.ts +0 -645
  272. package/packages/dfcode/src/tool/edit.txt +0 -10
  273. package/packages/dfcode/src/tool/external-directory.ts +0 -32
  274. package/packages/dfcode/src/tool/glob.ts +0 -77
  275. package/packages/dfcode/src/tool/glob.txt +0 -6
  276. package/packages/dfcode/src/tool/grep.ts +0 -154
  277. package/packages/dfcode/src/tool/grep.txt +0 -8
  278. package/packages/dfcode/src/tool/invalid.ts +0 -17
  279. package/packages/dfcode/src/tool/ls.ts +0 -121
  280. package/packages/dfcode/src/tool/ls.txt +0 -1
  281. package/packages/dfcode/src/tool/lsp.ts +0 -96
  282. package/packages/dfcode/src/tool/lsp.txt +0 -19
  283. package/packages/dfcode/src/tool/multiedit.ts +0 -46
  284. package/packages/dfcode/src/tool/multiedit.txt +0 -41
  285. package/packages/dfcode/src/tool/plan-enter.txt +0 -14
  286. package/packages/dfcode/src/tool/plan-exit.txt +0 -13
  287. package/packages/dfcode/src/tool/plan.ts +0 -130
  288. package/packages/dfcode/src/tool/question.ts +0 -33
  289. package/packages/dfcode/src/tool/question.txt +0 -10
  290. package/packages/dfcode/src/tool/read.ts +0 -202
  291. package/packages/dfcode/src/tool/read.txt +0 -12
  292. package/packages/dfcode/src/tool/registry.ts +0 -158
  293. package/packages/dfcode/src/tool/skill.ts +0 -82
  294. package/packages/dfcode/src/tool/task.ts +0 -191
  295. package/packages/dfcode/src/tool/task.txt +0 -60
  296. package/packages/dfcode/src/tool/todo.ts +0 -53
  297. package/packages/dfcode/src/tool/todoread.txt +0 -14
  298. package/packages/dfcode/src/tool/todowrite.txt +0 -167
  299. package/packages/dfcode/src/tool/tool.ts +0 -88
  300. package/packages/dfcode/src/tool/truncation.ts +0 -106
  301. package/packages/dfcode/src/tool/webfetch.ts +0 -188
  302. package/packages/dfcode/src/tool/webfetch.txt +0 -13
  303. package/packages/dfcode/src/tool/websearch.ts +0 -150
  304. package/packages/dfcode/src/tool/websearch.txt +0 -14
  305. package/packages/dfcode/src/tool/write.ts +0 -80
  306. package/packages/dfcode/src/tool/write.txt +0 -8
  307. package/packages/dfcode/src/util/archive.ts +0 -16
  308. package/packages/dfcode/src/util/color.ts +0 -19
  309. package/packages/dfcode/src/util/context.ts +0 -25
  310. package/packages/dfcode/src/util/defer.ts +0 -12
  311. package/packages/dfcode/src/util/eventloop.ts +0 -20
  312. package/packages/dfcode/src/util/filesystem.ts +0 -93
  313. package/packages/dfcode/src/util/fn.ts +0 -11
  314. package/packages/dfcode/src/util/format.ts +0 -20
  315. package/packages/dfcode/src/util/iife.ts +0 -3
  316. package/packages/dfcode/src/util/keybind.ts +0 -103
  317. package/packages/dfcode/src/util/lazy.ts +0 -18
  318. package/packages/dfcode/src/util/locale.ts +0 -81
  319. package/packages/dfcode/src/util/lock.ts +0 -98
  320. package/packages/dfcode/src/util/log.ts +0 -180
  321. package/packages/dfcode/src/util/queue.ts +0 -32
  322. package/packages/dfcode/src/util/rpc.ts +0 -66
  323. package/packages/dfcode/src/util/scrap.ts +0 -10
  324. package/packages/dfcode/src/util/signal.ts +0 -12
  325. package/packages/dfcode/src/util/timeout.ts +0 -14
  326. package/packages/dfcode/src/util/token.ts +0 -7
  327. package/packages/dfcode/src/util/wildcard.ts +0 -56
  328. package/packages/dfcode/src/worktree/index.ts +0 -524
  329. package/packages/plugin/package.json +0 -28
  330. package/packages/plugin/src/example.ts +0 -18
  331. package/packages/plugin/src/index.ts +0 -226
  332. package/packages/plugin/src/shell.ts +0 -136
  333. package/packages/plugin/src/tool.ts +0 -28
  334. package/packages/util/package.json +0 -20
  335. package/packages/util/src/array.ts +0 -10
  336. package/packages/util/src/binary.ts +0 -41
  337. package/packages/util/src/encode.ts +0 -30
  338. package/packages/util/src/error.ts +0 -54
  339. package/packages/util/src/fn.ts +0 -11
  340. package/packages/util/src/identifier.ts +0 -48
  341. package/packages/util/src/iife.ts +0 -3
  342. package/packages/util/src/lazy.ts +0 -11
  343. package/packages/util/src/path.ts +0 -37
  344. package/packages/util/src/retry.ts +0 -41
  345. package/packages/util/src/slug.ts +0 -74
@@ -1,368 +0,0 @@
1
- import type { ColorInput } from "@opentui/core"
2
- import { RGBA } from "@opentui/core"
3
- import type { ColorGenerator } from "opentui-spinner"
4
-
5
- interface AdvancedGradientOptions {
6
- colors: ColorInput[]
7
- trailLength: number
8
- defaultColor?: ColorInput
9
- direction?: "forward" | "backward" | "bidirectional"
10
- holdFrames?: { start?: number; end?: number }
11
- enableFading?: boolean
12
- minAlpha?: number
13
- }
14
-
15
- interface ScannerState {
16
- activePosition: number
17
- isHolding: boolean
18
- holdProgress: number
19
- holdTotal: number
20
- movementProgress: number
21
- movementTotal: number
22
- isMovingForward: boolean
23
- }
24
-
25
- function getScannerState(
26
- frameIndex: number,
27
- totalChars: number,
28
- options: Pick<AdvancedGradientOptions, "direction" | "holdFrames">,
29
- ): ScannerState {
30
- const { direction = "forward", holdFrames = {} } = options
31
-
32
- if (direction === "bidirectional") {
33
- const forwardFrames = totalChars
34
- const holdEndFrames = holdFrames.end ?? 0
35
- const backwardFrames = totalChars - 1
36
-
37
- if (frameIndex < forwardFrames) {
38
- // Moving forward
39
- return {
40
- activePosition: frameIndex,
41
- isHolding: false,
42
- holdProgress: 0,
43
- holdTotal: 0,
44
- movementProgress: frameIndex,
45
- movementTotal: forwardFrames,
46
- isMovingForward: true,
47
- }
48
- } else if (frameIndex < forwardFrames + holdEndFrames) {
49
- // Holding at end
50
- return {
51
- activePosition: totalChars - 1,
52
- isHolding: true,
53
- holdProgress: frameIndex - forwardFrames,
54
- holdTotal: holdEndFrames,
55
- movementProgress: 0,
56
- movementTotal: 0,
57
- isMovingForward: true,
58
- }
59
- } else if (frameIndex < forwardFrames + holdEndFrames + backwardFrames) {
60
- // Moving backward
61
- const backwardIndex = frameIndex - forwardFrames - holdEndFrames
62
- return {
63
- activePosition: totalChars - 2 - backwardIndex,
64
- isHolding: false,
65
- holdProgress: 0,
66
- holdTotal: 0,
67
- movementProgress: backwardIndex,
68
- movementTotal: backwardFrames,
69
- isMovingForward: false,
70
- }
71
- } else {
72
- // Holding at start
73
- return {
74
- activePosition: 0,
75
- isHolding: true,
76
- holdProgress: frameIndex - forwardFrames - holdEndFrames - backwardFrames,
77
- holdTotal: holdFrames.start ?? 0,
78
- movementProgress: 0,
79
- movementTotal: 0,
80
- isMovingForward: false,
81
- }
82
- }
83
- } else if (direction === "backward") {
84
- return {
85
- activePosition: totalChars - 1 - (frameIndex % totalChars),
86
- isHolding: false,
87
- holdProgress: 0,
88
- holdTotal: 0,
89
- movementProgress: frameIndex % totalChars,
90
- movementTotal: totalChars,
91
- isMovingForward: false,
92
- }
93
- } else {
94
- return {
95
- activePosition: frameIndex % totalChars,
96
- isHolding: false,
97
- holdProgress: 0,
98
- holdTotal: 0,
99
- movementProgress: frameIndex % totalChars,
100
- movementTotal: totalChars,
101
- isMovingForward: true,
102
- }
103
- }
104
- }
105
-
106
- function calculateColorIndex(
107
- frameIndex: number,
108
- charIndex: number,
109
- totalChars: number,
110
- options: Pick<AdvancedGradientOptions, "direction" | "holdFrames" | "trailLength">,
111
- state?: ScannerState,
112
- ): number {
113
- const { trailLength } = options
114
- const { activePosition, isHolding, holdProgress, isMovingForward } =
115
- state ?? getScannerState(frameIndex, totalChars, options)
116
-
117
- // Calculate directional distance (positive means trailing behind)
118
- const directionalDistance = isMovingForward
119
- ? activePosition - charIndex // For forward: trail is to the left (lower indices)
120
- : charIndex - activePosition // For backward: trail is to the right (higher indices)
121
-
122
- // Handle hold frame fading: keep the lead bright, fade the trail
123
- if (isHolding) {
124
- // Shift the color index by how long we've been holding
125
- return directionalDistance + holdProgress
126
- }
127
-
128
- // Normal movement - show gradient trail only behind the movement direction
129
- if (directionalDistance > 0 && directionalDistance < trailLength) {
130
- return directionalDistance
131
- }
132
-
133
- // At the active position, show the brightest color
134
- if (directionalDistance === 0) {
135
- return 0
136
- }
137
-
138
- return -1
139
- }
140
-
141
- function createKnightRiderTrail(options: AdvancedGradientOptions): ColorGenerator {
142
- const { colors, defaultColor, enableFading = true, minAlpha = 0 } = options
143
-
144
- // Use the provided defaultColor if it's an RGBA instance, otherwise convert/default
145
- // We use RGBA.fromHex for the fallback to ensure we have an RGBA object.
146
- // Note: If defaultColor is a string, we convert it once here.
147
- const defaultRgba = defaultColor instanceof RGBA ? defaultColor : RGBA.fromHex((defaultColor as string) || "#000000")
148
-
149
- // Store the base alpha from the inactive factor
150
- const baseInactiveAlpha = defaultRgba.a
151
-
152
- let cachedFrameIndex = -1
153
- let cachedState: ScannerState | null = null
154
-
155
- return (frameIndex: number, charIndex: number, _totalFrames: number, totalChars: number) => {
156
- if (frameIndex !== cachedFrameIndex) {
157
- cachedFrameIndex = frameIndex
158
- cachedState = getScannerState(frameIndex, totalChars, options)
159
- }
160
-
161
- const state = cachedState!
162
-
163
- const index = calculateColorIndex(frameIndex, charIndex, totalChars, options, state)
164
-
165
- // Calculate global fade for inactive dots during hold or movement
166
- const { isHolding, holdProgress, holdTotal, movementProgress, movementTotal } = state
167
-
168
- let fadeFactor = 1.0
169
- if (enableFading) {
170
- if (isHolding && holdTotal > 0) {
171
- // Fade out linearly to minAlpha
172
- const progress = Math.min(holdProgress / holdTotal, 1)
173
- fadeFactor = Math.max(minAlpha, 1 - progress * (1 - minAlpha))
174
- } else if (!isHolding && movementTotal > 0) {
175
- // Fade in linearly from minAlpha during movement
176
- const progress = Math.min(movementProgress / Math.max(1, movementTotal - 1), 1)
177
- fadeFactor = minAlpha + progress * (1 - minAlpha)
178
- }
179
- }
180
-
181
- // Combine base inactive alpha with the fade factor
182
- // This ensures inactiveFactor is respected while still allowing fading animation
183
- defaultRgba.a = baseInactiveAlpha * fadeFactor
184
-
185
- if (index === -1) {
186
- return defaultRgba
187
- }
188
-
189
- return colors[index] ?? defaultRgba
190
- }
191
- }
192
-
193
- /**
194
- * Derives a gradient of tail colors from a single bright color using alpha falloff
195
- * @param brightColor The brightest color (center/head of the scanner)
196
- * @param steps Number of gradient steps (default: 6)
197
- * @returns Array of RGBA colors with alpha-based trail fade (background-independent)
198
- */
199
- export function deriveTrailColors(brightColor: ColorInput, steps: number = 6): RGBA[] {
200
- const baseRgba = brightColor instanceof RGBA ? brightColor : RGBA.fromHex(brightColor as string)
201
-
202
- const colors: RGBA[] = []
203
-
204
- for (let i = 0; i < steps; i++) {
205
- // Alpha-based falloff with optional bloom effect
206
- let alpha: number
207
- let brightnessFactor: number
208
-
209
- if (i === 0) {
210
- // Lead position: full brightness and opacity
211
- alpha = 1.0
212
- brightnessFactor = 1.0
213
- } else if (i === 1) {
214
- // Slight bloom/glare effect: brighten color but reduce opacity slightly
215
- alpha = 0.9
216
- brightnessFactor = 1.15
217
- } else {
218
- // Exponential alpha decay for natural-looking trail fade
219
- alpha = Math.pow(0.65, i - 1)
220
- brightnessFactor = 1.0
221
- }
222
-
223
- const r = Math.min(1.0, baseRgba.r * brightnessFactor)
224
- const g = Math.min(1.0, baseRgba.g * brightnessFactor)
225
- const b = Math.min(1.0, baseRgba.b * brightnessFactor)
226
-
227
- colors.push(RGBA.fromValues(r, g, b, alpha))
228
- }
229
-
230
- return colors
231
- }
232
-
233
- /**
234
- * Derives the inactive/default color from a bright color using alpha
235
- * @param brightColor The brightest color (center/head of the scanner)
236
- * @param factor Alpha factor for inactive color (default: 0.2, range: 0-1)
237
- * @returns The same color with reduced alpha for background-independent dimming
238
- */
239
- export function deriveInactiveColor(brightColor: ColorInput, factor: number = 0.2): RGBA {
240
- const baseRgba = brightColor instanceof RGBA ? brightColor : RGBA.fromHex(brightColor as string)
241
-
242
- // Use the full color brightness but adjust alpha for background-independent dimming
243
- return RGBA.fromValues(baseRgba.r, baseRgba.g, baseRgba.b, factor)
244
- }
245
-
246
- export type KnightRiderStyle = "blocks" | "diamonds"
247
-
248
- export interface KnightRiderOptions {
249
- width?: number
250
- style?: KnightRiderStyle
251
- holdStart?: number
252
- holdEnd?: number
253
- colors?: ColorInput[]
254
- /** Single color to derive trail from (alternative to providing colors array) */
255
- color?: ColorInput
256
- /** Number of trail steps when using single color (default: 6) */
257
- trailSteps?: number
258
- defaultColor?: ColorInput
259
- /** Alpha factor for inactive color when using single color (default: 0.2, range: 0-1) */
260
- inactiveFactor?: number
261
- /** Enable fading of inactive dots during hold and movement (default: true) */
262
- enableFading?: boolean
263
- /** Minimum alpha value when fading (default: 0, range: 0-1) */
264
- minAlpha?: number
265
- }
266
-
267
- /**
268
- * Creates frame strings for a Knight Rider style scanner animation
269
- * @param options Configuration options for the Knight Rider effect
270
- * @returns Array of frame strings
271
- */
272
- export function createFrames(options: KnightRiderOptions = {}): string[] {
273
- const width = options.width ?? 8
274
- const style = options.style ?? "diamonds"
275
- const holdStart = options.holdStart ?? 30
276
- const holdEnd = options.holdEnd ?? 9
277
-
278
- const colors =
279
- options.colors ??
280
- (options.color
281
- ? deriveTrailColors(options.color, options.trailSteps)
282
- : [
283
- RGBA.fromHex("#ff0000"), // Brightest Red (Center)
284
- RGBA.fromHex("#ff5555"), // Glare/Bloom
285
- RGBA.fromHex("#dd0000"), // Trail 1
286
- RGBA.fromHex("#aa0000"), // Trail 2
287
- RGBA.fromHex("#770000"), // Trail 3
288
- RGBA.fromHex("#440000"), // Trail 4
289
- ])
290
-
291
- const defaultColor =
292
- options.defaultColor ??
293
- (options.color ? deriveInactiveColor(options.color, options.inactiveFactor) : RGBA.fromHex("#330000"))
294
-
295
- const trailOptions = {
296
- colors,
297
- trailLength: colors.length,
298
- defaultColor,
299
- direction: "bidirectional" as const,
300
- holdFrames: { start: holdStart, end: holdEnd },
301
- enableFading: options.enableFading,
302
- minAlpha: options.minAlpha,
303
- }
304
-
305
- // Bidirectional cycle: Forward (width) + Hold End + Backward (width-1) + Hold Start
306
- const totalFrames = width + holdEnd + (width - 1) + holdStart
307
-
308
- // Generate dynamic frames where inactive pixels are dots and active ones are blocks
309
- const frames = Array.from({ length: totalFrames }, (_, frameIndex) => {
310
- return Array.from({ length: width }, (_, charIndex) => {
311
- const index = calculateColorIndex(frameIndex, charIndex, width, trailOptions)
312
-
313
- if (style === "diamonds") {
314
- const shapes = ["⬥", "◆", "⬩", "⬪"]
315
- if (index >= 0 && index < trailOptions.colors.length) {
316
- return shapes[Math.min(index, shapes.length - 1)]
317
- }
318
- return "·"
319
- }
320
-
321
- // Default to blocks
322
- // It's active if we have a valid color index that is within our colors array
323
- const isActive = index >= 0 && index < trailOptions.colors.length
324
- return isActive ? "■" : "⬝"
325
- }).join("")
326
- })
327
-
328
- return frames
329
- }
330
-
331
- /**
332
- * Creates a color generator function for Knight Rider style scanner animation
333
- * @param options Configuration options for the Knight Rider effect
334
- * @returns ColorGenerator function
335
- */
336
- export function createColors(options: KnightRiderOptions = {}): ColorGenerator {
337
- const holdStart = options.holdStart ?? 30
338
- const holdEnd = options.holdEnd ?? 9
339
-
340
- const colors =
341
- options.colors ??
342
- (options.color
343
- ? deriveTrailColors(options.color, options.trailSteps)
344
- : [
345
- RGBA.fromHex("#ff0000"), // Brightest Red (Center)
346
- RGBA.fromHex("#ff5555"), // Glare/Bloom
347
- RGBA.fromHex("#dd0000"), // Trail 1
348
- RGBA.fromHex("#aa0000"), // Trail 2
349
- RGBA.fromHex("#770000"), // Trail 3
350
- RGBA.fromHex("#440000"), // Trail 4
351
- ])
352
-
353
- const defaultColor =
354
- options.defaultColor ??
355
- (options.color ? deriveInactiveColor(options.color, options.inactiveFactor) : RGBA.fromHex("#330000"))
356
-
357
- const trailOptions = {
358
- colors,
359
- trailLength: colors.length,
360
- defaultColor,
361
- direction: "bidirectional" as const,
362
- holdFrames: { start: holdStart, end: holdEnd },
363
- enableFading: options.enableFading,
364
- minAlpha: options.minAlpha,
365
- }
366
-
367
- return createKnightRiderTrail(trailOptions)
368
- }
@@ -1,100 +0,0 @@
1
- import { createContext, useContext, type ParentProps, Show } from "solid-js"
2
- import { createStore } from "solid-js/store"
3
- import { useTheme } from "@tui/context/theme"
4
- import { useTerminalDimensions } from "@opentui/solid"
5
- import { SplitBorder } from "../component/border"
6
- import { TextAttributes } from "@opentui/core"
7
- import z from "zod"
8
- import { TuiEvent } from "../event"
9
-
10
- export type ToastOptions = z.infer<typeof TuiEvent.ToastShow.properties>
11
-
12
- export function Toast() {
13
- const toast = useToast()
14
- const { theme } = useTheme()
15
- const dimensions = useTerminalDimensions()
16
-
17
- return (
18
- <Show when={toast.currentToast}>
19
- {(current) => (
20
- <box
21
- position="absolute"
22
- justifyContent="center"
23
- alignItems="flex-start"
24
- top={2}
25
- right={2}
26
- maxWidth={Math.min(60, dimensions().width - 6)}
27
- paddingLeft={2}
28
- paddingRight={2}
29
- paddingTop={1}
30
- paddingBottom={1}
31
- backgroundColor={theme.backgroundPanel}
32
- borderColor={theme[current().variant]}
33
- border={["left", "right"]}
34
- customBorderChars={SplitBorder.customBorderChars}
35
- >
36
- <Show when={current().title}>
37
- <text attributes={TextAttributes.BOLD} marginBottom={1} fg={theme.text}>
38
- {current().title}
39
- </text>
40
- </Show>
41
- <text fg={theme.text} wrapMode="word" width="100%">
42
- {current().message}
43
- </text>
44
- </box>
45
- )}
46
- </Show>
47
- )
48
- }
49
-
50
- function init() {
51
- const [store, setStore] = createStore({
52
- currentToast: null as ToastOptions | null,
53
- })
54
-
55
- let timeoutHandle: NodeJS.Timeout | null = null
56
-
57
- const toast = {
58
- show(options: ToastOptions) {
59
- const parsedOptions = TuiEvent.ToastShow.properties.parse(options)
60
- const { duration, ...currentToast } = parsedOptions
61
- setStore("currentToast", currentToast)
62
- if (timeoutHandle) clearTimeout(timeoutHandle)
63
- timeoutHandle = setTimeout(() => {
64
- setStore("currentToast", null)
65
- }, duration).unref()
66
- },
67
- error: (err: any) => {
68
- if (err instanceof Error)
69
- return toast.show({
70
- variant: "error",
71
- message: err.message,
72
- })
73
- toast.show({
74
- variant: "error",
75
- message: "An unknown error has occurred",
76
- })
77
- },
78
- get currentToast(): ToastOptions | null {
79
- return store.currentToast
80
- },
81
- }
82
- return toast
83
- }
84
-
85
- export type ToastContext = ReturnType<typeof init>
86
-
87
- const ctx = createContext<ToastContext>()
88
-
89
- export function ToastProvider(props: ParentProps) {
90
- const value = init()
91
- return <ctx.Provider value={value}>{props.children}</ctx.Provider>
92
- }
93
-
94
- export function useToast() {
95
- const value = useContext(ctx)
96
- if (!value) {
97
- throw new Error("useToast must be used within a ToastProvider")
98
- }
99
- return value
100
- }
@@ -1,160 +0,0 @@
1
- import { $ } from "bun"
2
- import { platform, release } from "os"
3
- import clipboardy from "clipboardy"
4
- import { lazy } from "../../../../util/lazy.js"
5
- import { tmpdir } from "os"
6
- import path from "path"
7
-
8
- /**
9
- * Writes text to clipboard via OSC 52 escape sequence.
10
- * This allows clipboard operations to work over SSH by having
11
- * the terminal emulator handle the clipboard locally.
12
- */
13
- function writeOsc52(text: string): void {
14
- if (!process.stdout.isTTY) return
15
- const base64 = Buffer.from(text).toString("base64")
16
- const osc52 = `\x1b]52;c;${base64}\x07`
17
- // tmux and screen require DCS passthrough wrapping
18
- const passthrough = process.env["TMUX"] || process.env["STY"]
19
- const sequence = passthrough ? `\x1bPtmux;\x1b${osc52}\x1b\\` : osc52
20
- process.stdout.write(sequence)
21
- }
22
-
23
- export namespace Clipboard {
24
- export interface Content {
25
- data: string
26
- mime: string
27
- }
28
-
29
- export async function read(): Promise<Content | undefined> {
30
- const os = platform()
31
-
32
- if (os === "darwin") {
33
- const tmpfile = path.join(tmpdir(), "dfcode-clipboard.png")
34
- try {
35
- await $`osascript -e 'set imageData to the clipboard as "PNGf"' -e 'set fileRef to open for access POSIX file "${tmpfile}" with write permission' -e 'set eof fileRef to 0' -e 'write imageData to fileRef' -e 'close access fileRef'`
36
- .nothrow()
37
- .quiet()
38
- const file = Bun.file(tmpfile)
39
- const buffer = await file.arrayBuffer()
40
- return { data: Buffer.from(buffer).toString("base64"), mime: "image/png" }
41
- } catch {
42
- } finally {
43
- await $`rm -f "${tmpfile}"`.nothrow().quiet()
44
- }
45
- }
46
-
47
- if (os === "win32" || release().includes("WSL")) {
48
- const script =
49
- "Add-Type -AssemblyName System.Windows.Forms; $img = [System.Windows.Forms.Clipboard]::GetImage(); if ($img) { $ms = New-Object System.IO.MemoryStream; $img.Save($ms, [System.Drawing.Imaging.ImageFormat]::Png); [System.Convert]::ToBase64String($ms.ToArray()) }"
50
- const base64 = await $`powershell.exe -NonInteractive -NoProfile -command "${script}"`.nothrow().text()
51
- if (base64) {
52
- const imageBuffer = Buffer.from(base64.trim(), "base64")
53
- if (imageBuffer.length > 0) {
54
- return { data: imageBuffer.toString("base64"), mime: "image/png" }
55
- }
56
- }
57
- }
58
-
59
- if (os === "linux") {
60
- const wayland = await $`wl-paste -t image/png`.nothrow().arrayBuffer()
61
- if (wayland && wayland.byteLength > 0) {
62
- return { data: Buffer.from(wayland).toString("base64"), mime: "image/png" }
63
- }
64
- const x11 = await $`xclip -selection clipboard -t image/png -o`.nothrow().arrayBuffer()
65
- if (x11 && x11.byteLength > 0) {
66
- return { data: Buffer.from(x11).toString("base64"), mime: "image/png" }
67
- }
68
- }
69
-
70
- const text = await clipboardy.read().catch(() => {})
71
- if (text) {
72
- return { data: text, mime: "text/plain" }
73
- }
74
- }
75
-
76
- const getCopyMethod = lazy(() => {
77
- const os = platform()
78
-
79
- if (os === "darwin" && Bun.which("osascript")) {
80
- console.log("clipboard: using osascript")
81
- return async (text: string) => {
82
- const escaped = text.replace(/\\/g, "\\\\").replace(/"/g, '\\"')
83
- await $`osascript -e 'set the clipboard to "${escaped}"'`.nothrow().quiet()
84
- }
85
- }
86
-
87
- if (os === "linux") {
88
- if (process.env["WAYLAND_DISPLAY"] && Bun.which("wl-copy")) {
89
- console.log("clipboard: using wl-copy")
90
- return async (text: string) => {
91
- const proc = Bun.spawn(["wl-copy"], { stdin: "pipe", stdout: "ignore", stderr: "ignore" })
92
- proc.stdin.write(text)
93
- proc.stdin.end()
94
- await proc.exited.catch(() => {})
95
- }
96
- }
97
- if (Bun.which("xclip")) {
98
- console.log("clipboard: using xclip")
99
- return async (text: string) => {
100
- const proc = Bun.spawn(["xclip", "-selection", "clipboard"], {
101
- stdin: "pipe",
102
- stdout: "ignore",
103
- stderr: "ignore",
104
- })
105
- proc.stdin.write(text)
106
- proc.stdin.end()
107
- await proc.exited.catch(() => {})
108
- }
109
- }
110
- if (Bun.which("xsel")) {
111
- console.log("clipboard: using xsel")
112
- return async (text: string) => {
113
- const proc = Bun.spawn(["xsel", "--clipboard", "--input"], {
114
- stdin: "pipe",
115
- stdout: "ignore",
116
- stderr: "ignore",
117
- })
118
- proc.stdin.write(text)
119
- proc.stdin.end()
120
- await proc.exited.catch(() => {})
121
- }
122
- }
123
- }
124
-
125
- if (os === "win32") {
126
- console.log("clipboard: using powershell")
127
- return async (text: string) => {
128
- // Pipe via stdin to avoid PowerShell string interpolation ($env:FOO, $(), etc.)
129
- const proc = Bun.spawn(
130
- [
131
- "powershell.exe",
132
- "-NonInteractive",
133
- "-NoProfile",
134
- "-Command",
135
- "[Console]::InputEncoding = [System.Text.Encoding]::UTF8; Set-Clipboard -Value ([Console]::In.ReadToEnd())",
136
- ],
137
- {
138
- stdin: "pipe",
139
- stdout: "ignore",
140
- stderr: "ignore",
141
- },
142
- )
143
-
144
- proc.stdin.write(text)
145
- proc.stdin.end()
146
- await proc.exited.catch(() => {})
147
- }
148
- }
149
-
150
- console.log("clipboard: no native support")
151
- return async (text: string) => {
152
- await clipboardy.write(text).catch(() => {})
153
- }
154
- })
155
-
156
- export async function copy(text: string): Promise<void> {
157
- writeOsc52(text)
158
- await getCopyMethod()(text)
159
- }
160
- }
@@ -1,32 +0,0 @@
1
- import { defer } from "@/util/defer"
2
- import { rm } from "node:fs/promises"
3
- import { tmpdir } from "node:os"
4
- import { join } from "node:path"
5
- import { CliRenderer } from "@opentui/core"
6
-
7
- export namespace Editor {
8
- export async function open(opts: { value: string; renderer: CliRenderer }): Promise<string | undefined> {
9
- const editor = process.env["VISUAL"] || process.env["EDITOR"]
10
- if (!editor) return
11
-
12
- const filepath = join(tmpdir(), `${Date.now()}.md`)
13
- await using _ = defer(async () => rm(filepath, { force: true }))
14
-
15
- await Bun.write(filepath, opts.value)
16
- opts.renderer.suspend()
17
- opts.renderer.currentRenderBuffer.clear()
18
- const parts = editor.split(" ")
19
- const proc = Bun.spawn({
20
- cmd: [...parts, filepath],
21
- stdin: "inherit",
22
- stdout: "inherit",
23
- stderr: "inherit",
24
- })
25
- await proc.exited
26
- const content = await Bun.file(filepath).text()
27
- opts.renderer.currentRenderBuffer.clear()
28
- opts.renderer.resume()
29
- opts.renderer.requestRender()
30
- return content || undefined
31
- }
32
- }
@@ -1,7 +0,0 @@
1
- import { createSignal, type Accessor } from "solid-js"
2
- import { debounce, type Scheduled } from "@solid-primitives/scheduled"
3
-
4
- export function createDebouncedSignal<T>(value: T, ms: number): [Accessor<T>, Scheduled<[value: T]>] {
5
- const [get, set] = createSignal(value)
6
- return [get, debounce((v: T) => set(() => v), ms)]
7
- }