cerebras-cli 1.0.1 → 1.0.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 (313) hide show
  1. package/cerebras-cli-1.0.0.tgz +0 -0
  2. package/package.json +7 -88
  3. package/AGENTS.md +0 -27
  4. package/Dockerfile +0 -10
  5. package/bunfig.toml +0 -4
  6. package/parsers-config.ts +0 -239
  7. package/script/build.ts +0 -151
  8. package/script/postinstall.mjs +0 -122
  9. package/script/publish.ts +0 -256
  10. package/script/schema.ts +0 -47
  11. package/src/acp/README.md +0 -164
  12. package/src/acp/agent.ts +0 -812
  13. package/src/acp/session.ts +0 -70
  14. package/src/acp/types.ts +0 -22
  15. package/src/agent/agent.ts +0 -310
  16. package/src/agent/generate.txt +0 -75
  17. package/src/auth/index.ts +0 -70
  18. package/src/bun/index.ts +0 -152
  19. package/src/bus/global.ts +0 -10
  20. package/src/bus/index.ts +0 -142
  21. package/src/cli/bootstrap.ts +0 -17
  22. package/src/cli/cmd/acp.ts +0 -88
  23. package/src/cli/cmd/agent.ts +0 -165
  24. package/src/cli/cmd/auth.ts +0 -369
  25. package/src/cli/cmd/cmd.ts +0 -7
  26. package/src/cli/cmd/debug/config.ts +0 -15
  27. package/src/cli/cmd/debug/file.ts +0 -91
  28. package/src/cli/cmd/debug/index.ts +0 -41
  29. package/src/cli/cmd/debug/lsp.ts +0 -47
  30. package/src/cli/cmd/debug/ripgrep.ts +0 -83
  31. package/src/cli/cmd/debug/scrap.ts +0 -15
  32. package/src/cli/cmd/debug/snapshot.ts +0 -48
  33. package/src/cli/cmd/export.ts +0 -88
  34. package/src/cli/cmd/generate.ts +0 -38
  35. package/src/cli/cmd/github.ts +0 -1200
  36. package/src/cli/cmd/import.ts +0 -98
  37. package/src/cli/cmd/mcp.ts +0 -400
  38. package/src/cli/cmd/models.ts +0 -77
  39. package/src/cli/cmd/pr.ts +0 -112
  40. package/src/cli/cmd/run.ts +0 -342
  41. package/src/cli/cmd/serve.ts +0 -31
  42. package/src/cli/cmd/session.ts +0 -106
  43. package/src/cli/cmd/stats.ts +0 -298
  44. package/src/cli/cmd/tui/app.tsx +0 -732
  45. package/src/cli/cmd/tui/attach.ts +0 -25
  46. package/src/cli/cmd/tui/component/border.tsx +0 -21
  47. package/src/cli/cmd/tui/component/dialog-agent.tsx +0 -31
  48. package/src/cli/cmd/tui/component/dialog-command.tsx +0 -124
  49. package/src/cli/cmd/tui/component/dialog-feedback.tsx +0 -160
  50. package/src/cli/cmd/tui/component/dialog-mcp.tsx +0 -86
  51. package/src/cli/cmd/tui/component/dialog-model.tsx +0 -223
  52. package/src/cli/cmd/tui/component/dialog-notification.tsx +0 -78
  53. package/src/cli/cmd/tui/component/dialog-provider.tsx +0 -222
  54. package/src/cli/cmd/tui/component/dialog-session-list.tsx +0 -97
  55. package/src/cli/cmd/tui/component/dialog-session-rename.tsx +0 -31
  56. package/src/cli/cmd/tui/component/dialog-status.tsx +0 -114
  57. package/src/cli/cmd/tui/component/dialog-tag.tsx +0 -44
  58. package/src/cli/cmd/tui/component/dialog-theme-list.tsx +0 -50
  59. package/src/cli/cmd/tui/component/logo.tsx +0 -37
  60. package/src/cli/cmd/tui/component/notification-banner.tsx +0 -58
  61. package/src/cli/cmd/tui/component/prompt/autocomplete.tsx +0 -530
  62. package/src/cli/cmd/tui/component/prompt/history.tsx +0 -107
  63. package/src/cli/cmd/tui/component/prompt/index.tsx +0 -931
  64. package/src/cli/cmd/tui/context/args.tsx +0 -14
  65. package/src/cli/cmd/tui/context/directory.ts +0 -12
  66. package/src/cli/cmd/tui/context/exit.tsx +0 -23
  67. package/src/cli/cmd/tui/context/helper.tsx +0 -25
  68. package/src/cli/cmd/tui/context/keybind.tsx +0 -111
  69. package/src/cli/cmd/tui/context/kv.tsx +0 -49
  70. package/src/cli/cmd/tui/context/local.tsx +0 -339
  71. package/src/cli/cmd/tui/context/prompt.tsx +0 -18
  72. package/src/cli/cmd/tui/context/route.tsx +0 -45
  73. package/src/cli/cmd/tui/context/sdk.tsx +0 -75
  74. package/src/cli/cmd/tui/context/sync.tsx +0 -374
  75. package/src/cli/cmd/tui/context/theme/aura.json +0 -69
  76. package/src/cli/cmd/tui/context/theme/ayu.json +0 -80
  77. package/src/cli/cmd/tui/context/theme/catppuccin-macchiato.json +0 -233
  78. package/src/cli/cmd/tui/context/theme/catppuccin.json +0 -112
  79. package/src/cli/cmd/tui/context/theme/cobalt2.json +0 -228
  80. package/src/cli/cmd/tui/context/theme/dracula.json +0 -219
  81. package/src/cli/cmd/tui/context/theme/everforest.json +0 -241
  82. package/src/cli/cmd/tui/context/theme/flexoki.json +0 -237
  83. package/src/cli/cmd/tui/context/theme/github.json +0 -233
  84. package/src/cli/cmd/tui/context/theme/gruvbox.json +0 -95
  85. package/src/cli/cmd/tui/context/theme/kanagawa.json +0 -77
  86. package/src/cli/cmd/tui/context/theme/material.json +0 -235
  87. package/src/cli/cmd/tui/context/theme/matrix.json +0 -77
  88. package/src/cli/cmd/tui/context/theme/mercury.json +0 -252
  89. package/src/cli/cmd/tui/context/theme/monokai.json +0 -221
  90. package/src/cli/cmd/tui/context/theme/nightowl.json +0 -221
  91. package/src/cli/cmd/tui/context/theme/nord.json +0 -223
  92. package/src/cli/cmd/tui/context/theme/one-dark.json +0 -84
  93. package/src/cli/cmd/tui/context/theme/orng.json +0 -245
  94. package/src/cli/cmd/tui/context/theme/palenight.json +0 -222
  95. package/src/cli/cmd/tui/context/theme/rosepine.json +0 -234
  96. package/src/cli/cmd/tui/context/theme/solarized.json +0 -223
  97. package/src/cli/cmd/tui/context/theme/synthwave84.json +0 -226
  98. package/src/cli/cmd/tui/context/theme/tokyonight.json +0 -243
  99. package/src/cli/cmd/tui/context/theme/vercel.json +0 -245
  100. package/src/cli/cmd/tui/context/theme/vesper.json +0 -218
  101. package/src/cli/cmd/tui/context/theme/zenburn.json +0 -223
  102. package/src/cli/cmd/tui/context/theme.tsx +0 -1077
  103. package/src/cli/cmd/tui/event.ts +0 -39
  104. package/src/cli/cmd/tui/routes/home.tsx +0 -104
  105. package/src/cli/cmd/tui/routes/session/dialog-message.tsx +0 -93
  106. package/src/cli/cmd/tui/routes/session/dialog-timeline.tsx +0 -37
  107. package/src/cli/cmd/tui/routes/session/footer.tsx +0 -76
  108. package/src/cli/cmd/tui/routes/session/header.tsx +0 -183
  109. package/src/cli/cmd/tui/routes/session/index.tsx +0 -1703
  110. package/src/cli/cmd/tui/routes/session/sidebar.tsx +0 -586
  111. package/src/cli/cmd/tui/spawn.ts +0 -60
  112. package/src/cli/cmd/tui/thread.ts +0 -120
  113. package/src/cli/cmd/tui/ui/dialog-alert.tsx +0 -55
  114. package/src/cli/cmd/tui/ui/dialog-confirm.tsx +0 -81
  115. package/src/cli/cmd/tui/ui/dialog-help.tsx +0 -36
  116. package/src/cli/cmd/tui/ui/dialog-prompt.tsx +0 -75
  117. package/src/cli/cmd/tui/ui/dialog-select.tsx +0 -317
  118. package/src/cli/cmd/tui/ui/dialog.tsx +0 -170
  119. package/src/cli/cmd/tui/ui/spinner.ts +0 -368
  120. package/src/cli/cmd/tui/ui/toast.tsx +0 -100
  121. package/src/cli/cmd/tui/util/clipboard.ts +0 -127
  122. package/src/cli/cmd/tui/util/editor.ts +0 -32
  123. package/src/cli/cmd/tui/util/terminal.ts +0 -114
  124. package/src/cli/cmd/tui/worker.ts +0 -63
  125. package/src/cli/cmd/uninstall.ts +0 -344
  126. package/src/cli/cmd/upgrade.ts +0 -67
  127. package/src/cli/cmd/web.ts +0 -84
  128. package/src/cli/error.ts +0 -55
  129. package/src/cli/ui.ts +0 -84
  130. package/src/cli/upgrade.ts +0 -25
  131. package/src/command/index.ts +0 -79
  132. package/src/command/template/initialize.txt +0 -10
  133. package/src/command/template/review.txt +0 -73
  134. package/src/config/config.ts +0 -886
  135. package/src/config/markdown.ts +0 -41
  136. package/src/env/index.ts +0 -26
  137. package/src/file/fzf.ts +0 -124
  138. package/src/file/ignore.ts +0 -83
  139. package/src/file/index.ts +0 -326
  140. package/src/file/ripgrep.ts +0 -391
  141. package/src/file/time.ts +0 -38
  142. package/src/file/watcher.ts +0 -89
  143. package/src/flag/flag.ts +0 -28
  144. package/src/format/formatter.ts +0 -277
  145. package/src/format/index.ts +0 -137
  146. package/src/global/index.ts +0 -52
  147. package/src/id/id.ts +0 -73
  148. package/src/ide/index.ts +0 -75
  149. package/src/index.ts +0 -158
  150. package/src/installation/index.ts +0 -194
  151. package/src/lsp/client.ts +0 -215
  152. package/src/lsp/index.ts +0 -370
  153. package/src/lsp/language.ts +0 -111
  154. package/src/lsp/server.ts +0 -1327
  155. package/src/mcp/auth.ts +0 -82
  156. package/src/mcp/index.ts +0 -576
  157. package/src/mcp/oauth-callback.ts +0 -203
  158. package/src/mcp/oauth-provider.ts +0 -132
  159. package/src/notification/index.ts +0 -101
  160. package/src/patch/index.ts +0 -622
  161. package/src/permission/index.ts +0 -198
  162. package/src/plugin/index.ts +0 -95
  163. package/src/project/bootstrap.ts +0 -31
  164. package/src/project/instance.ts +0 -68
  165. package/src/project/project.ts +0 -133
  166. package/src/project/state.ts +0 -65
  167. package/src/project/vcs.ts +0 -77
  168. package/src/provider/auth.ts +0 -143
  169. package/src/provider/models-macro.ts +0 -11
  170. package/src/provider/models.ts +0 -93
  171. package/src/provider/provider.ts +0 -996
  172. package/src/provider/sdk/openai-compatible/src/README.md +0 -5
  173. package/src/provider/sdk/openai-compatible/src/index.ts +0 -2
  174. package/src/provider/sdk/openai-compatible/src/openai-compatible-provider.ts +0 -100
  175. package/src/provider/sdk/openai-compatible/src/responses/convert-to-openai-responses-input.ts +0 -303
  176. package/src/provider/sdk/openai-compatible/src/responses/map-openai-responses-finish-reason.ts +0 -27
  177. package/src/provider/sdk/openai-compatible/src/responses/openai-config.ts +0 -18
  178. package/src/provider/sdk/openai-compatible/src/responses/openai-error.ts +0 -22
  179. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-api-types.ts +0 -207
  180. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-language-model.ts +0 -1713
  181. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-prepare-tools.ts +0 -177
  182. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-settings.ts +0 -1
  183. package/src/provider/sdk/openai-compatible/src/responses/tool/code-interpreter.ts +0 -88
  184. package/src/provider/sdk/openai-compatible/src/responses/tool/file-search.ts +0 -128
  185. package/src/provider/sdk/openai-compatible/src/responses/tool/image-generation.ts +0 -115
  186. package/src/provider/sdk/openai-compatible/src/responses/tool/local-shell.ts +0 -65
  187. package/src/provider/sdk/openai-compatible/src/responses/tool/web-search-preview.ts +0 -104
  188. package/src/provider/sdk/openai-compatible/src/responses/tool/web-search.ts +0 -103
  189. package/src/provider/transform.ts +0 -406
  190. package/src/pty/index.ts +0 -226
  191. package/src/ratelimit/index.ts +0 -185
  192. package/src/server/error.ts +0 -36
  193. package/src/server/project.ts +0 -50
  194. package/src/server/server.ts +0 -2463
  195. package/src/server/tui.ts +0 -71
  196. package/src/session/compaction.ts +0 -257
  197. package/src/session/index.ts +0 -470
  198. package/src/session/message-v2.ts +0 -641
  199. package/src/session/message.ts +0 -189
  200. package/src/session/processor.ts +0 -443
  201. package/src/session/prompt/anthropic-20250930.txt +0 -166
  202. package/src/session/prompt/anthropic.txt +0 -105
  203. package/src/session/prompt/anthropic_spoof.txt +0 -1
  204. package/src/session/prompt/beast.txt +0 -147
  205. package/src/session/prompt/build-switch.txt +0 -5
  206. package/src/session/prompt/codex.txt +0 -318
  207. package/src/session/prompt/compaction.txt +0 -12
  208. package/src/session/prompt/copilot-gpt-5.txt +0 -143
  209. package/src/session/prompt/gemini.txt +0 -155
  210. package/src/session/prompt/max-steps.txt +0 -16
  211. package/src/session/prompt/plan-reminder-anthropic.txt +0 -67
  212. package/src/session/prompt/plan.txt +0 -26
  213. package/src/session/prompt/polaris.txt +0 -107
  214. package/src/session/prompt/qwen.txt +0 -109
  215. package/src/session/prompt/summarize.txt +0 -4
  216. package/src/session/prompt/title.txt +0 -36
  217. package/src/session/prompt.ts +0 -1541
  218. package/src/session/retry.ts +0 -82
  219. package/src/session/revert.ts +0 -108
  220. package/src/session/status.ts +0 -75
  221. package/src/session/summary.ts +0 -203
  222. package/src/session/system.ts +0 -148
  223. package/src/session/todo.ts +0 -36
  224. package/src/share/share-next.ts +0 -195
  225. package/src/share/share.ts +0 -87
  226. package/src/snapshot/index.ts +0 -197
  227. package/src/storage/storage.ts +0 -226
  228. package/src/telemetry/index.ts +0 -232
  229. package/src/tool/bash.ts +0 -365
  230. package/src/tool/bash.txt +0 -128
  231. package/src/tool/batch.ts +0 -173
  232. package/src/tool/batch.txt +0 -28
  233. package/src/tool/codesearch.ts +0 -138
  234. package/src/tool/codesearch.txt +0 -12
  235. package/src/tool/edit.ts +0 -674
  236. package/src/tool/edit.txt +0 -10
  237. package/src/tool/glob.ts +0 -65
  238. package/src/tool/glob.txt +0 -6
  239. package/src/tool/grep.ts +0 -120
  240. package/src/tool/grep.txt +0 -8
  241. package/src/tool/invalid.ts +0 -17
  242. package/src/tool/ls.ts +0 -110
  243. package/src/tool/ls.txt +0 -1
  244. package/src/tool/lsp-diagnostics.ts +0 -26
  245. package/src/tool/lsp-diagnostics.txt +0 -1
  246. package/src/tool/lsp-hover.ts +0 -31
  247. package/src/tool/lsp-hover.txt +0 -1
  248. package/src/tool/multiedit.ts +0 -46
  249. package/src/tool/multiedit.txt +0 -41
  250. package/src/tool/patch.ts +0 -233
  251. package/src/tool/patch.txt +0 -1
  252. package/src/tool/read.ts +0 -217
  253. package/src/tool/read.txt +0 -12
  254. package/src/tool/registry.ts +0 -148
  255. package/src/tool/task.ts +0 -135
  256. package/src/tool/task.txt +0 -60
  257. package/src/tool/todo.ts +0 -39
  258. package/src/tool/todoread.txt +0 -14
  259. package/src/tool/todowrite.txt +0 -167
  260. package/src/tool/tool.ts +0 -66
  261. package/src/tool/webfetch.ts +0 -187
  262. package/src/tool/webfetch.txt +0 -14
  263. package/src/tool/websearch.ts +0 -150
  264. package/src/tool/websearch.txt +0 -11
  265. package/src/tool/write.ts +0 -99
  266. package/src/tool/write.txt +0 -8
  267. package/src/types/shims.d.ts +0 -3
  268. package/src/util/color.ts +0 -19
  269. package/src/util/context.ts +0 -25
  270. package/src/util/defer.ts +0 -12
  271. package/src/util/eventloop.ts +0 -20
  272. package/src/util/filesystem.ts +0 -69
  273. package/src/util/fn.ts +0 -11
  274. package/src/util/iife.ts +0 -3
  275. package/src/util/keybind.ts +0 -79
  276. package/src/util/lazy.ts +0 -11
  277. package/src/util/locale.ts +0 -81
  278. package/src/util/lock.ts +0 -98
  279. package/src/util/log.ts +0 -177
  280. package/src/util/queue.ts +0 -32
  281. package/src/util/rpc.ts +0 -42
  282. package/src/util/scrap.ts +0 -10
  283. package/src/util/signal.ts +0 -12
  284. package/src/util/timeout.ts +0 -14
  285. package/src/util/token.ts +0 -7
  286. package/src/util/wildcard.ts +0 -54
  287. package/sst-env.d.ts +0 -9
  288. package/test/bun.test.ts +0 -53
  289. package/test/config/agent-color.test.ts +0 -66
  290. package/test/config/config.test.ts +0 -503
  291. package/test/config/markdown.test.ts +0 -89
  292. package/test/file/ignore.test.ts +0 -10
  293. package/test/fixture/fixture.ts +0 -28
  294. package/test/fixture/lsp/fake-lsp-server.js +0 -77
  295. package/test/ide/ide.test.ts +0 -82
  296. package/test/keybind.test.ts +0 -317
  297. package/test/lsp/client.test.ts +0 -95
  298. package/test/patch/patch.test.ts +0 -348
  299. package/test/preload.ts +0 -38
  300. package/test/project/project.test.ts +0 -42
  301. package/test/provider/provider.test.ts +0 -1809
  302. package/test/provider/transform.test.ts +0 -305
  303. package/test/session/retry.test.ts +0 -61
  304. package/test/session/session.test.ts +0 -71
  305. package/test/snapshot/snapshot.test.ts +0 -939
  306. package/test/tool/__snapshots__/tool.test.ts.snap +0 -9
  307. package/test/tool/bash.test.ts +0 -55
  308. package/test/tool/patch.test.ts +0 -259
  309. package/test/util/iife.test.ts +0 -36
  310. package/test/util/lazy.test.ts +0 -50
  311. package/test/util/timeout.test.ts +0 -21
  312. package/test/util/wildcard.test.ts +0 -55
  313. package/tsconfig.json +0 -17
@@ -1,98 +0,0 @@
1
- import type { Argv } from "yargs"
2
- import { Session } from "../../session"
3
- import { cmd } from "./cmd"
4
- import { bootstrap } from "../bootstrap"
5
- import { Storage } from "../../storage/storage"
6
- import { Instance } from "../../project/instance"
7
- import { EOL } from "os"
8
-
9
- export const ImportCommand = cmd({
10
- command: "import <file>",
11
- describe: "import session data from JSON file or URL",
12
- builder: (yargs: Argv) => {
13
- return yargs.positional("file", {
14
- describe: "path to JSON file or opencode.ai share URL",
15
- type: "string",
16
- demandOption: true,
17
- })
18
- },
19
- handler: async (args) => {
20
- await bootstrap(process.cwd(), async () => {
21
- let exportData:
22
- | {
23
- info: Session.Info
24
- messages: Array<{
25
- info: any
26
- parts: any[]
27
- }>
28
- }
29
- | undefined
30
-
31
- const isUrl = args.file.startsWith("http://") || args.file.startsWith("https://")
32
-
33
- if (isUrl) {
34
- const urlMatch = args.file.match(/https?:\/\/opencode\.ai\/s\/([a-zA-Z0-9_-]+)/)
35
- if (!urlMatch) {
36
- process.stdout.write(`Invalid URL format. Expected: https://opencode.ai/s/<slug>`)
37
- process.stdout.write(EOL)
38
- return
39
- }
40
-
41
- const slug = urlMatch[1]
42
- const response = await fetch(`https://api.opencode.ai/share_data?id=${slug}`)
43
-
44
- if (!response.ok) {
45
- process.stdout.write(`Failed to fetch share data: ${response.statusText}`)
46
- process.stdout.write(EOL)
47
- return
48
- }
49
-
50
- const data = await response.json()
51
-
52
- if (!data.info || !data.messages || Object.keys(data.messages).length === 0) {
53
- process.stdout.write(`Share not found: ${slug}`)
54
- process.stdout.write(EOL)
55
- return
56
- }
57
-
58
- exportData = {
59
- info: data.info,
60
- messages: Object.values(data.messages).map((msg: any) => {
61
- const { parts, ...info } = msg
62
- return {
63
- info,
64
- parts,
65
- }
66
- }),
67
- }
68
- } else {
69
- const file = Bun.file(args.file)
70
- exportData = await file.json().catch(() => {})
71
- if (!exportData) {
72
- process.stdout.write(`File not found: ${args.file}`)
73
- process.stdout.write(EOL)
74
- return
75
- }
76
- }
77
-
78
- if (!exportData) {
79
- process.stdout.write(`Failed to read session data`)
80
- process.stdout.write(EOL)
81
- return
82
- }
83
-
84
- await Storage.write(["session", Instance.project.id, exportData.info.id], exportData.info)
85
-
86
- for (const msg of exportData.messages) {
87
- await Storage.write(["message", exportData.info.id, msg.info.id], msg.info)
88
-
89
- for (const part of msg.parts) {
90
- await Storage.write(["part", msg.info.id, part.id], part)
91
- }
92
- }
93
-
94
- process.stdout.write(`Imported session: ${exportData.info.id}`)
95
- process.stdout.write(EOL)
96
- })
97
- },
98
- })
@@ -1,400 +0,0 @@
1
- import { cmd } from "./cmd"
2
- import { Client } from "@modelcontextprotocol/sdk/client/index.js"
3
- import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
4
- import * as prompts from "@clack/prompts"
5
- import { UI } from "../ui"
6
- import { MCP } from "../../mcp"
7
- import { McpAuth } from "../../mcp/auth"
8
- import { Config } from "../../config/config"
9
- import { Instance } from "../../project/instance"
10
- import path from "path"
11
- import os from "os"
12
- import { Global } from "../../global"
13
-
14
- export const McpCommand = cmd({
15
- command: "mcp",
16
- builder: (yargs) =>
17
- yargs
18
- .command(McpAddCommand)
19
- .command(McpListCommand)
20
- .command(McpAuthCommand)
21
- .command(McpLogoutCommand)
22
- .demandCommand(),
23
- async handler() {},
24
- })
25
-
26
- export const McpListCommand = cmd({
27
- command: "list",
28
- aliases: ["ls"],
29
- describe: "list MCP servers and their status",
30
- async handler() {
31
- await Instance.provide({
32
- directory: process.cwd(),
33
- async fn() {
34
- UI.empty()
35
- prompts.intro("MCP Servers")
36
-
37
- const config = await Config.get()
38
- const mcpServers = config.mcp ?? {}
39
- const statuses = await MCP.status()
40
-
41
- if (Object.keys(mcpServers).length === 0) {
42
- prompts.log.warn("No MCP servers configured")
43
- prompts.outro("Add servers with: opencode mcp add")
44
- return
45
- }
46
-
47
- for (const [name, serverConfig] of Object.entries(mcpServers)) {
48
- const status = statuses[name]
49
- const hasOAuth = serverConfig.type === "remote" && !!serverConfig.oauth
50
- const hasStoredTokens = await MCP.hasStoredTokens(name)
51
-
52
- let statusIcon: string
53
- let statusText: string
54
- let hint = ""
55
-
56
- if (!status) {
57
- statusIcon = "○"
58
- statusText = "not initialized"
59
- } else if (status.status === "connected") {
60
- statusIcon = "✓"
61
- statusText = "connected"
62
- if (hasOAuth && hasStoredTokens) {
63
- hint = " (OAuth)"
64
- }
65
- } else if (status.status === "disabled") {
66
- statusIcon = "○"
67
- statusText = "disabled"
68
- } else if (status.status === "needs_auth") {
69
- statusIcon = "⚠"
70
- statusText = "needs authentication"
71
- } else if (status.status === "needs_client_registration") {
72
- statusIcon = "✗"
73
- statusText = "needs client registration"
74
- hint = "\n " + status.error
75
- } else {
76
- statusIcon = "✗"
77
- statusText = "failed"
78
- hint = "\n " + status.error
79
- }
80
-
81
- const typeHint = serverConfig.type === "remote" ? serverConfig.url : serverConfig.command.join(" ")
82
- prompts.log.info(
83
- `${statusIcon} ${name} ${UI.Style.TEXT_DIM}${statusText}${hint}\n ${UI.Style.TEXT_DIM}${typeHint}`,
84
- )
85
- }
86
-
87
- prompts.outro(`${Object.keys(mcpServers).length} server(s)`)
88
- },
89
- })
90
- },
91
- })
92
-
93
- export const McpAuthCommand = cmd({
94
- command: "auth [name]",
95
- describe: "authenticate with an OAuth-enabled MCP server",
96
- builder: (yargs) =>
97
- yargs.positional("name", {
98
- describe: "name of the MCP server",
99
- type: "string",
100
- }),
101
- async handler(args) {
102
- await Instance.provide({
103
- directory: process.cwd(),
104
- async fn() {
105
- UI.empty()
106
- prompts.intro("MCP OAuth Authentication")
107
-
108
- const config = await Config.get()
109
- const mcpServers = config.mcp ?? {}
110
-
111
- // Get OAuth-enabled servers
112
- const oauthServers = Object.entries(mcpServers).filter(([_, cfg]) => cfg.type === "remote" && !!cfg.oauth)
113
-
114
- if (oauthServers.length === 0) {
115
- prompts.log.warn("No OAuth-enabled MCP servers configured")
116
- prompts.log.info("Add OAuth config to a remote MCP server in opencode.json:")
117
- prompts.log.info(`
118
- "mcp": {
119
- "my-server": {
120
- "type": "remote",
121
- "url": "https://example.com/mcp",
122
- "oauth": {
123
- "scope": "tools:read"
124
- }
125
- }
126
- }`)
127
- prompts.outro("Done")
128
- return
129
- }
130
-
131
- let serverName = args.name
132
- if (!serverName) {
133
- const selected = await prompts.select({
134
- message: "Select MCP server to authenticate",
135
- options: oauthServers.map(([name, cfg]) => ({
136
- label: name,
137
- value: name,
138
- hint: cfg.type === "remote" ? cfg.url : undefined,
139
- })),
140
- })
141
- if (prompts.isCancel(selected)) throw new UI.CancelledError()
142
- serverName = selected
143
- }
144
-
145
- const serverConfig = mcpServers[serverName]
146
- if (!serverConfig) {
147
- prompts.log.error(`MCP server not found: ${serverName}`)
148
- prompts.outro("Done")
149
- return
150
- }
151
-
152
- if (serverConfig.type !== "remote" || !serverConfig.oauth) {
153
- prompts.log.error(`MCP server ${serverName} does not have OAuth configured`)
154
- prompts.outro("Done")
155
- return
156
- }
157
-
158
- // Check if already authenticated
159
- const hasTokens = await MCP.hasStoredTokens(serverName)
160
- if (hasTokens) {
161
- const confirm = await prompts.confirm({
162
- message: `${serverName} already has stored credentials. Re-authenticate?`,
163
- })
164
- if (prompts.isCancel(confirm) || !confirm) {
165
- prompts.outro("Cancelled")
166
- return
167
- }
168
- }
169
-
170
- const spinner = prompts.spinner()
171
- spinner.start("Starting OAuth flow...")
172
-
173
- try {
174
- const status = await MCP.authenticate(serverName)
175
-
176
- if (status.status === "connected") {
177
- spinner.stop("Authentication successful!")
178
- } else if (status.status === "needs_client_registration") {
179
- spinner.stop("Authentication failed", 1)
180
- prompts.log.error(status.error)
181
- prompts.log.info("Add clientId to your MCP server config:")
182
- prompts.log.info(`
183
- "mcp": {
184
- "${serverName}": {
185
- "type": "remote",
186
- "url": "${serverConfig.url}",
187
- "oauth": {
188
- "clientId": "your-client-id",
189
- "clientSecret": "your-client-secret"
190
- }
191
- }
192
- }`)
193
- } else if (status.status === "failed") {
194
- spinner.stop("Authentication failed", 1)
195
- prompts.log.error(status.error)
196
- } else {
197
- spinner.stop("Unexpected status: " + status.status, 1)
198
- }
199
- } catch (error) {
200
- spinner.stop("Authentication failed", 1)
201
- prompts.log.error(error instanceof Error ? error.message : String(error))
202
- }
203
-
204
- prompts.outro("Done")
205
- },
206
- })
207
- },
208
- })
209
-
210
- export const McpLogoutCommand = cmd({
211
- command: "logout [name]",
212
- describe: "remove OAuth credentials for an MCP server",
213
- builder: (yargs) =>
214
- yargs.positional("name", {
215
- describe: "name of the MCP server",
216
- type: "string",
217
- }),
218
- async handler(args) {
219
- await Instance.provide({
220
- directory: process.cwd(),
221
- async fn() {
222
- UI.empty()
223
- prompts.intro("MCP OAuth Logout")
224
-
225
- const authPath = path.join(Global.Path.data, "mcp-auth.json")
226
- const credentials = await McpAuth.all()
227
- const serverNames = Object.keys(credentials)
228
-
229
- if (serverNames.length === 0) {
230
- prompts.log.warn("No MCP OAuth credentials stored")
231
- prompts.outro("Done")
232
- return
233
- }
234
-
235
- let serverName = args.name
236
- if (!serverName) {
237
- const selected = await prompts.select({
238
- message: "Select MCP server to logout",
239
- options: serverNames.map((name) => {
240
- const entry = credentials[name]
241
- const hasTokens = !!entry.tokens
242
- const hasClient = !!entry.clientInfo
243
- let hint = ""
244
- if (hasTokens && hasClient) hint = "tokens + client"
245
- else if (hasTokens) hint = "tokens"
246
- else if (hasClient) hint = "client registration"
247
- return {
248
- label: name,
249
- value: name,
250
- hint,
251
- }
252
- }),
253
- })
254
- if (prompts.isCancel(selected)) throw new UI.CancelledError()
255
- serverName = selected
256
- }
257
-
258
- if (!credentials[serverName]) {
259
- prompts.log.error(`No credentials found for: ${serverName}`)
260
- prompts.outro("Done")
261
- return
262
- }
263
-
264
- await MCP.removeAuth(serverName)
265
- prompts.log.success(`Removed OAuth credentials for ${serverName}`)
266
- prompts.outro("Done")
267
- },
268
- })
269
- },
270
- })
271
-
272
- export const McpAddCommand = cmd({
273
- command: "add",
274
- describe: "add an MCP server",
275
- async handler() {
276
- UI.empty()
277
- prompts.intro("Add MCP server")
278
-
279
- const name = await prompts.text({
280
- message: "Enter MCP server name",
281
- validate: (x) => (x && x.length > 0 ? undefined : "Required"),
282
- })
283
- if (prompts.isCancel(name)) throw new UI.CancelledError()
284
-
285
- const type = await prompts.select({
286
- message: "Select MCP server type",
287
- options: [
288
- {
289
- label: "Local",
290
- value: "local",
291
- hint: "Run a local command",
292
- },
293
- {
294
- label: "Remote",
295
- value: "remote",
296
- hint: "Connect to a remote URL",
297
- },
298
- ],
299
- })
300
- if (prompts.isCancel(type)) throw new UI.CancelledError()
301
-
302
- if (type === "local") {
303
- const command = await prompts.text({
304
- message: "Enter command to run",
305
- placeholder: "e.g., opencode x @modelcontextprotocol/server-filesystem",
306
- validate: (x) => (x && x.length > 0 ? undefined : "Required"),
307
- })
308
- if (prompts.isCancel(command)) throw new UI.CancelledError()
309
-
310
- prompts.log.info(`Local MCP server "${name}" configured with command: ${command}`)
311
- prompts.outro("MCP server added successfully")
312
- return
313
- }
314
-
315
- if (type === "remote") {
316
- const url = await prompts.text({
317
- message: "Enter MCP server URL",
318
- placeholder: "e.g., https://example.com/mcp",
319
- validate: (x) => {
320
- if (!x) return "Required"
321
- if (x.length === 0) return "Required"
322
- const isValid = URL.canParse(x)
323
- return isValid ? undefined : "Invalid URL"
324
- },
325
- })
326
- if (prompts.isCancel(url)) throw new UI.CancelledError()
327
-
328
- const useOAuth = await prompts.confirm({
329
- message: "Does this server require OAuth authentication?",
330
- initialValue: false,
331
- })
332
- if (prompts.isCancel(useOAuth)) throw new UI.CancelledError()
333
-
334
- if (useOAuth) {
335
- const hasClientId = await prompts.confirm({
336
- message: "Do you have a pre-registered client ID?",
337
- initialValue: false,
338
- })
339
- if (prompts.isCancel(hasClientId)) throw new UI.CancelledError()
340
-
341
- if (hasClientId) {
342
- const clientId = await prompts.text({
343
- message: "Enter client ID",
344
- validate: (x) => (x && x.length > 0 ? undefined : "Required"),
345
- })
346
- if (prompts.isCancel(clientId)) throw new UI.CancelledError()
347
-
348
- const hasSecret = await prompts.confirm({
349
- message: "Do you have a client secret?",
350
- initialValue: false,
351
- })
352
- if (prompts.isCancel(hasSecret)) throw new UI.CancelledError()
353
-
354
- let clientSecret: string | undefined
355
- if (hasSecret) {
356
- const secret = await prompts.password({
357
- message: "Enter client secret",
358
- })
359
- if (prompts.isCancel(secret)) throw new UI.CancelledError()
360
- clientSecret = secret
361
- }
362
-
363
- prompts.log.info(`Remote MCP server "${name}" configured with OAuth (client ID: ${clientId})`)
364
- prompts.log.info("Add this to your opencode.json:")
365
- prompts.log.info(`
366
- "mcp": {
367
- "${name}": {
368
- "type": "remote",
369
- "url": "${url}",
370
- "oauth": {
371
- "clientId": "${clientId}"${clientSecret ? `,\n "clientSecret": "${clientSecret}"` : ""}
372
- }
373
- }
374
- }`)
375
- } else {
376
- prompts.log.info(`Remote MCP server "${name}" configured with OAuth (dynamic registration)`)
377
- prompts.log.info("Add this to your opencode.json:")
378
- prompts.log.info(`
379
- "mcp": {
380
- "${name}": {
381
- "type": "remote",
382
- "url": "${url}",
383
- "oauth": {}
384
- }
385
- }`)
386
- }
387
- } else {
388
- const client = new Client({
389
- name: "opencode",
390
- version: "1.0.0",
391
- })
392
- const transport = new StreamableHTTPClientTransport(new URL(url))
393
- await client.connect(transport)
394
- prompts.log.info(`Remote MCP server "${name}" configured with URL: ${url}`)
395
- }
396
- }
397
-
398
- prompts.outro("MCP server added successfully")
399
- },
400
- })
@@ -1,77 +0,0 @@
1
- import type { Argv } from "yargs"
2
- import { Instance } from "../../project/instance"
3
- import { Provider } from "../../provider/provider"
4
- import { ModelsDev } from "../../provider/models"
5
- import { cmd } from "./cmd"
6
- import { UI } from "../ui"
7
- import { EOL } from "os"
8
-
9
- export const ModelsCommand = cmd({
10
- command: "models [provider]",
11
- describe: "list all available models",
12
- builder: (yargs: Argv) => {
13
- return yargs
14
- .positional("provider", {
15
- describe: "provider ID to filter models by",
16
- type: "string",
17
- array: false,
18
- })
19
- .option("verbose", {
20
- describe: "use more verbose model output (includes metadata like costs)",
21
- type: "boolean",
22
- })
23
- .option("refresh", {
24
- describe: "refresh the models cache from models.dev",
25
- type: "boolean",
26
- })
27
- },
28
- handler: async (args) => {
29
- if (args.refresh) {
30
- await ModelsDev.refresh()
31
- UI.println(UI.Style.TEXT_SUCCESS_BOLD + "Models cache refreshed" + UI.Style.TEXT_NORMAL)
32
- }
33
-
34
- await Instance.provide({
35
- directory: process.cwd(),
36
- async fn() {
37
- const providers = await Provider.list()
38
-
39
- function printModels(providerID: string, verbose?: boolean) {
40
- const provider = providers[providerID]
41
- const sortedModels = Object.entries(provider.models).sort(([a], [b]) => a.localeCompare(b))
42
- for (const [modelID, model] of sortedModels) {
43
- process.stdout.write(`${providerID}/${modelID}`)
44
- process.stdout.write(EOL)
45
- if (verbose) {
46
- process.stdout.write(JSON.stringify(model, null, 2))
47
- process.stdout.write(EOL)
48
- }
49
- }
50
- }
51
-
52
- if (args.provider) {
53
- const provider = providers[args.provider]
54
- if (!provider) {
55
- UI.error(`Provider not found: ${args.provider}`)
56
- return
57
- }
58
-
59
- printModels(args.provider, args.verbose)
60
- return
61
- }
62
-
63
- const providerIDs = Object.keys(providers).sort((a, b) => {
64
- const aIsOpencode = a.startsWith("opencode")
65
- const bIsOpencode = b.startsWith("opencode")
66
- if (aIsOpencode && !bIsOpencode) return -1
67
- if (!aIsOpencode && bIsOpencode) return 1
68
- return a.localeCompare(b)
69
- })
70
-
71
- for (const providerID of providerIDs) {
72
- printModels(providerID, args.verbose)
73
- }
74
- },
75
- })
76
- },
77
- })
package/src/cli/cmd/pr.ts DELETED
@@ -1,112 +0,0 @@
1
- import { UI } from "../ui"
2
- import { cmd } from "./cmd"
3
- import { Instance } from "@/project/instance"
4
- import { $ } from "bun"
5
-
6
- export const PrCommand = cmd({
7
- command: "pr <number>",
8
- describe: "fetch and checkout a GitHub PR branch, then run opencode",
9
- builder: (yargs) =>
10
- yargs.positional("number", {
11
- type: "number",
12
- describe: "PR number to checkout",
13
- demandOption: true,
14
- }),
15
- async handler(args) {
16
- await Instance.provide({
17
- directory: process.cwd(),
18
- async fn() {
19
- const project = Instance.project
20
- if (project.vcs !== "git") {
21
- UI.error("Could not find git repository. Please run this command from a git repository.")
22
- process.exit(1)
23
- }
24
-
25
- const prNumber = args.number
26
- const localBranchName = `pr/${prNumber}`
27
- UI.println(`Fetching and checking out PR #${prNumber}...`)
28
-
29
- // Use gh pr checkout with custom branch name
30
- const result = await $`gh pr checkout ${prNumber} --branch ${localBranchName} --force`.nothrow()
31
-
32
- if (result.exitCode !== 0) {
33
- UI.error(`Failed to checkout PR #${prNumber}. Make sure you have gh CLI installed and authenticated.`)
34
- process.exit(1)
35
- }
36
-
37
- // Fetch PR info for fork handling and session link detection
38
- const prInfoResult =
39
- await $`gh pr view ${prNumber} --json headRepository,headRepositoryOwner,isCrossRepository,headRefName,body`.nothrow()
40
-
41
- let sessionId: string | undefined
42
-
43
- if (prInfoResult.exitCode === 0) {
44
- const prInfoText = prInfoResult.text()
45
- if (prInfoText.trim()) {
46
- const prInfo = JSON.parse(prInfoText)
47
-
48
- // Handle fork PRs
49
- if (prInfo && prInfo.isCrossRepository && prInfo.headRepository && prInfo.headRepositoryOwner) {
50
- const forkOwner = prInfo.headRepositoryOwner.login
51
- const forkName = prInfo.headRepository.name
52
- const remoteName = forkOwner
53
-
54
- // Check if remote already exists
55
- const remotes = (await $`git remote`.nothrow().text()).trim()
56
- if (!remotes.split("\n").includes(remoteName)) {
57
- await $`git remote add ${remoteName} https://github.com/${forkOwner}/${forkName}.git`.nothrow()
58
- UI.println(`Added fork remote: ${remoteName}`)
59
- }
60
-
61
- // Set upstream to the fork so pushes go there
62
- const headRefName = prInfo.headRefName
63
- await $`git branch --set-upstream-to=${remoteName}/${headRefName} ${localBranchName}`.nothrow()
64
- }
65
-
66
- // Check for opencode session link in PR body
67
- if (prInfo && prInfo.body) {
68
- const sessionMatch = prInfo.body.match(/https:\/\/opencode\.ai\/s\/([a-zA-Z0-9_-]+)/)
69
- if (sessionMatch) {
70
- const sessionUrl = sessionMatch[0]
71
- UI.println(`Found opencode session: ${sessionUrl}`)
72
- UI.println(`Importing session...`)
73
-
74
- const importResult = await $`opencode import ${sessionUrl}`.nothrow()
75
- if (importResult.exitCode === 0) {
76
- const importOutput = importResult.text().trim()
77
- // Extract session ID from the output (format: "Imported session: <session-id>")
78
- const sessionIdMatch = importOutput.match(/Imported session: ([a-zA-Z0-9_-]+)/)
79
- if (sessionIdMatch) {
80
- sessionId = sessionIdMatch[1]
81
- UI.println(`Session imported: ${sessionId}`)
82
- }
83
- }
84
- }
85
- }
86
- }
87
- }
88
-
89
- UI.println(`Successfully checked out PR #${prNumber} as branch '${localBranchName}'`)
90
- UI.println()
91
- UI.println("Starting opencode...")
92
- UI.println()
93
-
94
- // Launch opencode TUI with session ID if available
95
- const { spawn } = await import("child_process")
96
- const opencodeArgs = sessionId ? ["-s", sessionId] : []
97
- const opencodeProcess = spawn("opencode", opencodeArgs, {
98
- stdio: "inherit",
99
- cwd: process.cwd(),
100
- })
101
-
102
- await new Promise<void>((resolve, reject) => {
103
- opencodeProcess.on("exit", (code) => {
104
- if (code === 0) resolve()
105
- else reject(new Error(`opencode exited with code ${code}`))
106
- })
107
- opencodeProcess.on("error", reject)
108
- })
109
- },
110
- })
111
- },
112
- })