cerebras-cli 1.0.0 → 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 (314) hide show
  1. package/bin/{opencode → opencode.cjs} +4 -4
  2. package/cerebras-cli-1.0.0.tgz +0 -0
  3. package/package.json +8 -89
  4. package/AGENTS.md +0 -27
  5. package/Dockerfile +0 -10
  6. package/bunfig.toml +0 -4
  7. package/parsers-config.ts +0 -239
  8. package/script/build.ts +0 -151
  9. package/script/postinstall.mjs +0 -122
  10. package/script/publish.ts +0 -256
  11. package/script/schema.ts +0 -47
  12. package/src/acp/README.md +0 -164
  13. package/src/acp/agent.ts +0 -812
  14. package/src/acp/session.ts +0 -70
  15. package/src/acp/types.ts +0 -22
  16. package/src/agent/agent.ts +0 -310
  17. package/src/agent/generate.txt +0 -75
  18. package/src/auth/index.ts +0 -70
  19. package/src/bun/index.ts +0 -152
  20. package/src/bus/global.ts +0 -10
  21. package/src/bus/index.ts +0 -142
  22. package/src/cli/bootstrap.ts +0 -17
  23. package/src/cli/cmd/acp.ts +0 -88
  24. package/src/cli/cmd/agent.ts +0 -165
  25. package/src/cli/cmd/auth.ts +0 -369
  26. package/src/cli/cmd/cmd.ts +0 -7
  27. package/src/cli/cmd/debug/config.ts +0 -15
  28. package/src/cli/cmd/debug/file.ts +0 -91
  29. package/src/cli/cmd/debug/index.ts +0 -41
  30. package/src/cli/cmd/debug/lsp.ts +0 -47
  31. package/src/cli/cmd/debug/ripgrep.ts +0 -83
  32. package/src/cli/cmd/debug/scrap.ts +0 -15
  33. package/src/cli/cmd/debug/snapshot.ts +0 -48
  34. package/src/cli/cmd/export.ts +0 -88
  35. package/src/cli/cmd/generate.ts +0 -38
  36. package/src/cli/cmd/github.ts +0 -1200
  37. package/src/cli/cmd/import.ts +0 -98
  38. package/src/cli/cmd/mcp.ts +0 -400
  39. package/src/cli/cmd/models.ts +0 -77
  40. package/src/cli/cmd/pr.ts +0 -112
  41. package/src/cli/cmd/run.ts +0 -342
  42. package/src/cli/cmd/serve.ts +0 -31
  43. package/src/cli/cmd/session.ts +0 -106
  44. package/src/cli/cmd/stats.ts +0 -298
  45. package/src/cli/cmd/tui/app.tsx +0 -732
  46. package/src/cli/cmd/tui/attach.ts +0 -25
  47. package/src/cli/cmd/tui/component/border.tsx +0 -21
  48. package/src/cli/cmd/tui/component/dialog-agent.tsx +0 -31
  49. package/src/cli/cmd/tui/component/dialog-command.tsx +0 -124
  50. package/src/cli/cmd/tui/component/dialog-feedback.tsx +0 -160
  51. package/src/cli/cmd/tui/component/dialog-mcp.tsx +0 -86
  52. package/src/cli/cmd/tui/component/dialog-model.tsx +0 -223
  53. package/src/cli/cmd/tui/component/dialog-notification.tsx +0 -78
  54. package/src/cli/cmd/tui/component/dialog-provider.tsx +0 -222
  55. package/src/cli/cmd/tui/component/dialog-session-list.tsx +0 -97
  56. package/src/cli/cmd/tui/component/dialog-session-rename.tsx +0 -31
  57. package/src/cli/cmd/tui/component/dialog-status.tsx +0 -114
  58. package/src/cli/cmd/tui/component/dialog-tag.tsx +0 -44
  59. package/src/cli/cmd/tui/component/dialog-theme-list.tsx +0 -50
  60. package/src/cli/cmd/tui/component/logo.tsx +0 -37
  61. package/src/cli/cmd/tui/component/notification-banner.tsx +0 -58
  62. package/src/cli/cmd/tui/component/prompt/autocomplete.tsx +0 -530
  63. package/src/cli/cmd/tui/component/prompt/history.tsx +0 -107
  64. package/src/cli/cmd/tui/component/prompt/index.tsx +0 -931
  65. package/src/cli/cmd/tui/context/args.tsx +0 -14
  66. package/src/cli/cmd/tui/context/directory.ts +0 -12
  67. package/src/cli/cmd/tui/context/exit.tsx +0 -23
  68. package/src/cli/cmd/tui/context/helper.tsx +0 -25
  69. package/src/cli/cmd/tui/context/keybind.tsx +0 -111
  70. package/src/cli/cmd/tui/context/kv.tsx +0 -49
  71. package/src/cli/cmd/tui/context/local.tsx +0 -339
  72. package/src/cli/cmd/tui/context/prompt.tsx +0 -18
  73. package/src/cli/cmd/tui/context/route.tsx +0 -45
  74. package/src/cli/cmd/tui/context/sdk.tsx +0 -75
  75. package/src/cli/cmd/tui/context/sync.tsx +0 -374
  76. package/src/cli/cmd/tui/context/theme/aura.json +0 -69
  77. package/src/cli/cmd/tui/context/theme/ayu.json +0 -80
  78. package/src/cli/cmd/tui/context/theme/catppuccin-macchiato.json +0 -233
  79. package/src/cli/cmd/tui/context/theme/catppuccin.json +0 -112
  80. package/src/cli/cmd/tui/context/theme/cobalt2.json +0 -228
  81. package/src/cli/cmd/tui/context/theme/dracula.json +0 -219
  82. package/src/cli/cmd/tui/context/theme/everforest.json +0 -241
  83. package/src/cli/cmd/tui/context/theme/flexoki.json +0 -237
  84. package/src/cli/cmd/tui/context/theme/github.json +0 -233
  85. package/src/cli/cmd/tui/context/theme/gruvbox.json +0 -95
  86. package/src/cli/cmd/tui/context/theme/kanagawa.json +0 -77
  87. package/src/cli/cmd/tui/context/theme/material.json +0 -235
  88. package/src/cli/cmd/tui/context/theme/matrix.json +0 -77
  89. package/src/cli/cmd/tui/context/theme/mercury.json +0 -252
  90. package/src/cli/cmd/tui/context/theme/monokai.json +0 -221
  91. package/src/cli/cmd/tui/context/theme/nightowl.json +0 -221
  92. package/src/cli/cmd/tui/context/theme/nord.json +0 -223
  93. package/src/cli/cmd/tui/context/theme/one-dark.json +0 -84
  94. package/src/cli/cmd/tui/context/theme/orng.json +0 -245
  95. package/src/cli/cmd/tui/context/theme/palenight.json +0 -222
  96. package/src/cli/cmd/tui/context/theme/rosepine.json +0 -234
  97. package/src/cli/cmd/tui/context/theme/solarized.json +0 -223
  98. package/src/cli/cmd/tui/context/theme/synthwave84.json +0 -226
  99. package/src/cli/cmd/tui/context/theme/tokyonight.json +0 -243
  100. package/src/cli/cmd/tui/context/theme/vercel.json +0 -245
  101. package/src/cli/cmd/tui/context/theme/vesper.json +0 -218
  102. package/src/cli/cmd/tui/context/theme/zenburn.json +0 -223
  103. package/src/cli/cmd/tui/context/theme.tsx +0 -1077
  104. package/src/cli/cmd/tui/event.ts +0 -39
  105. package/src/cli/cmd/tui/routes/home.tsx +0 -104
  106. package/src/cli/cmd/tui/routes/session/dialog-message.tsx +0 -93
  107. package/src/cli/cmd/tui/routes/session/dialog-timeline.tsx +0 -37
  108. package/src/cli/cmd/tui/routes/session/footer.tsx +0 -76
  109. package/src/cli/cmd/tui/routes/session/header.tsx +0 -183
  110. package/src/cli/cmd/tui/routes/session/index.tsx +0 -1703
  111. package/src/cli/cmd/tui/routes/session/sidebar.tsx +0 -586
  112. package/src/cli/cmd/tui/spawn.ts +0 -60
  113. package/src/cli/cmd/tui/thread.ts +0 -120
  114. package/src/cli/cmd/tui/ui/dialog-alert.tsx +0 -55
  115. package/src/cli/cmd/tui/ui/dialog-confirm.tsx +0 -81
  116. package/src/cli/cmd/tui/ui/dialog-help.tsx +0 -36
  117. package/src/cli/cmd/tui/ui/dialog-prompt.tsx +0 -75
  118. package/src/cli/cmd/tui/ui/dialog-select.tsx +0 -317
  119. package/src/cli/cmd/tui/ui/dialog.tsx +0 -170
  120. package/src/cli/cmd/tui/ui/spinner.ts +0 -368
  121. package/src/cli/cmd/tui/ui/toast.tsx +0 -100
  122. package/src/cli/cmd/tui/util/clipboard.ts +0 -127
  123. package/src/cli/cmd/tui/util/editor.ts +0 -32
  124. package/src/cli/cmd/tui/util/terminal.ts +0 -114
  125. package/src/cli/cmd/tui/worker.ts +0 -63
  126. package/src/cli/cmd/uninstall.ts +0 -344
  127. package/src/cli/cmd/upgrade.ts +0 -67
  128. package/src/cli/cmd/web.ts +0 -84
  129. package/src/cli/error.ts +0 -55
  130. package/src/cli/ui.ts +0 -84
  131. package/src/cli/upgrade.ts +0 -25
  132. package/src/command/index.ts +0 -79
  133. package/src/command/template/initialize.txt +0 -10
  134. package/src/command/template/review.txt +0 -73
  135. package/src/config/config.ts +0 -886
  136. package/src/config/markdown.ts +0 -41
  137. package/src/env/index.ts +0 -26
  138. package/src/file/fzf.ts +0 -124
  139. package/src/file/ignore.ts +0 -83
  140. package/src/file/index.ts +0 -326
  141. package/src/file/ripgrep.ts +0 -391
  142. package/src/file/time.ts +0 -38
  143. package/src/file/watcher.ts +0 -89
  144. package/src/flag/flag.ts +0 -28
  145. package/src/format/formatter.ts +0 -277
  146. package/src/format/index.ts +0 -137
  147. package/src/global/index.ts +0 -52
  148. package/src/id/id.ts +0 -73
  149. package/src/ide/index.ts +0 -75
  150. package/src/index.ts +0 -158
  151. package/src/installation/index.ts +0 -194
  152. package/src/lsp/client.ts +0 -215
  153. package/src/lsp/index.ts +0 -370
  154. package/src/lsp/language.ts +0 -111
  155. package/src/lsp/server.ts +0 -1327
  156. package/src/mcp/auth.ts +0 -82
  157. package/src/mcp/index.ts +0 -576
  158. package/src/mcp/oauth-callback.ts +0 -203
  159. package/src/mcp/oauth-provider.ts +0 -132
  160. package/src/notification/index.ts +0 -101
  161. package/src/patch/index.ts +0 -622
  162. package/src/permission/index.ts +0 -198
  163. package/src/plugin/index.ts +0 -95
  164. package/src/project/bootstrap.ts +0 -31
  165. package/src/project/instance.ts +0 -68
  166. package/src/project/project.ts +0 -133
  167. package/src/project/state.ts +0 -65
  168. package/src/project/vcs.ts +0 -77
  169. package/src/provider/auth.ts +0 -143
  170. package/src/provider/models-macro.ts +0 -11
  171. package/src/provider/models.ts +0 -93
  172. package/src/provider/provider.ts +0 -996
  173. package/src/provider/sdk/openai-compatible/src/README.md +0 -5
  174. package/src/provider/sdk/openai-compatible/src/index.ts +0 -2
  175. package/src/provider/sdk/openai-compatible/src/openai-compatible-provider.ts +0 -100
  176. package/src/provider/sdk/openai-compatible/src/responses/convert-to-openai-responses-input.ts +0 -303
  177. package/src/provider/sdk/openai-compatible/src/responses/map-openai-responses-finish-reason.ts +0 -27
  178. package/src/provider/sdk/openai-compatible/src/responses/openai-config.ts +0 -18
  179. package/src/provider/sdk/openai-compatible/src/responses/openai-error.ts +0 -22
  180. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-api-types.ts +0 -207
  181. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-language-model.ts +0 -1713
  182. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-prepare-tools.ts +0 -177
  183. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-settings.ts +0 -1
  184. package/src/provider/sdk/openai-compatible/src/responses/tool/code-interpreter.ts +0 -88
  185. package/src/provider/sdk/openai-compatible/src/responses/tool/file-search.ts +0 -128
  186. package/src/provider/sdk/openai-compatible/src/responses/tool/image-generation.ts +0 -115
  187. package/src/provider/sdk/openai-compatible/src/responses/tool/local-shell.ts +0 -65
  188. package/src/provider/sdk/openai-compatible/src/responses/tool/web-search-preview.ts +0 -104
  189. package/src/provider/sdk/openai-compatible/src/responses/tool/web-search.ts +0 -103
  190. package/src/provider/transform.ts +0 -406
  191. package/src/pty/index.ts +0 -226
  192. package/src/ratelimit/index.ts +0 -185
  193. package/src/server/error.ts +0 -36
  194. package/src/server/project.ts +0 -50
  195. package/src/server/server.ts +0 -2463
  196. package/src/server/tui.ts +0 -71
  197. package/src/session/compaction.ts +0 -257
  198. package/src/session/index.ts +0 -470
  199. package/src/session/message-v2.ts +0 -641
  200. package/src/session/message.ts +0 -189
  201. package/src/session/processor.ts +0 -443
  202. package/src/session/prompt/anthropic-20250930.txt +0 -166
  203. package/src/session/prompt/anthropic.txt +0 -105
  204. package/src/session/prompt/anthropic_spoof.txt +0 -1
  205. package/src/session/prompt/beast.txt +0 -147
  206. package/src/session/prompt/build-switch.txt +0 -5
  207. package/src/session/prompt/codex.txt +0 -318
  208. package/src/session/prompt/compaction.txt +0 -12
  209. package/src/session/prompt/copilot-gpt-5.txt +0 -143
  210. package/src/session/prompt/gemini.txt +0 -155
  211. package/src/session/prompt/max-steps.txt +0 -16
  212. package/src/session/prompt/plan-reminder-anthropic.txt +0 -67
  213. package/src/session/prompt/plan.txt +0 -26
  214. package/src/session/prompt/polaris.txt +0 -107
  215. package/src/session/prompt/qwen.txt +0 -109
  216. package/src/session/prompt/summarize.txt +0 -4
  217. package/src/session/prompt/title.txt +0 -36
  218. package/src/session/prompt.ts +0 -1541
  219. package/src/session/retry.ts +0 -82
  220. package/src/session/revert.ts +0 -108
  221. package/src/session/status.ts +0 -75
  222. package/src/session/summary.ts +0 -203
  223. package/src/session/system.ts +0 -148
  224. package/src/session/todo.ts +0 -36
  225. package/src/share/share-next.ts +0 -195
  226. package/src/share/share.ts +0 -87
  227. package/src/snapshot/index.ts +0 -197
  228. package/src/storage/storage.ts +0 -226
  229. package/src/telemetry/index.ts +0 -232
  230. package/src/tool/bash.ts +0 -365
  231. package/src/tool/bash.txt +0 -128
  232. package/src/tool/batch.ts +0 -173
  233. package/src/tool/batch.txt +0 -28
  234. package/src/tool/codesearch.ts +0 -138
  235. package/src/tool/codesearch.txt +0 -12
  236. package/src/tool/edit.ts +0 -674
  237. package/src/tool/edit.txt +0 -10
  238. package/src/tool/glob.ts +0 -65
  239. package/src/tool/glob.txt +0 -6
  240. package/src/tool/grep.ts +0 -120
  241. package/src/tool/grep.txt +0 -8
  242. package/src/tool/invalid.ts +0 -17
  243. package/src/tool/ls.ts +0 -110
  244. package/src/tool/ls.txt +0 -1
  245. package/src/tool/lsp-diagnostics.ts +0 -26
  246. package/src/tool/lsp-diagnostics.txt +0 -1
  247. package/src/tool/lsp-hover.ts +0 -31
  248. package/src/tool/lsp-hover.txt +0 -1
  249. package/src/tool/multiedit.ts +0 -46
  250. package/src/tool/multiedit.txt +0 -41
  251. package/src/tool/patch.ts +0 -233
  252. package/src/tool/patch.txt +0 -1
  253. package/src/tool/read.ts +0 -217
  254. package/src/tool/read.txt +0 -12
  255. package/src/tool/registry.ts +0 -148
  256. package/src/tool/task.ts +0 -135
  257. package/src/tool/task.txt +0 -60
  258. package/src/tool/todo.ts +0 -39
  259. package/src/tool/todoread.txt +0 -14
  260. package/src/tool/todowrite.txt +0 -167
  261. package/src/tool/tool.ts +0 -66
  262. package/src/tool/webfetch.ts +0 -187
  263. package/src/tool/webfetch.txt +0 -14
  264. package/src/tool/websearch.ts +0 -150
  265. package/src/tool/websearch.txt +0 -11
  266. package/src/tool/write.ts +0 -99
  267. package/src/tool/write.txt +0 -8
  268. package/src/types/shims.d.ts +0 -3
  269. package/src/util/color.ts +0 -19
  270. package/src/util/context.ts +0 -25
  271. package/src/util/defer.ts +0 -12
  272. package/src/util/eventloop.ts +0 -20
  273. package/src/util/filesystem.ts +0 -69
  274. package/src/util/fn.ts +0 -11
  275. package/src/util/iife.ts +0 -3
  276. package/src/util/keybind.ts +0 -79
  277. package/src/util/lazy.ts +0 -11
  278. package/src/util/locale.ts +0 -81
  279. package/src/util/lock.ts +0 -98
  280. package/src/util/log.ts +0 -177
  281. package/src/util/queue.ts +0 -32
  282. package/src/util/rpc.ts +0 -42
  283. package/src/util/scrap.ts +0 -10
  284. package/src/util/signal.ts +0 -12
  285. package/src/util/timeout.ts +0 -14
  286. package/src/util/token.ts +0 -7
  287. package/src/util/wildcard.ts +0 -54
  288. package/sst-env.d.ts +0 -9
  289. package/test/bun.test.ts +0 -53
  290. package/test/config/agent-color.test.ts +0 -66
  291. package/test/config/config.test.ts +0 -503
  292. package/test/config/markdown.test.ts +0 -89
  293. package/test/file/ignore.test.ts +0 -10
  294. package/test/fixture/fixture.ts +0 -28
  295. package/test/fixture/lsp/fake-lsp-server.js +0 -77
  296. package/test/ide/ide.test.ts +0 -82
  297. package/test/keybind.test.ts +0 -317
  298. package/test/lsp/client.test.ts +0 -95
  299. package/test/patch/patch.test.ts +0 -348
  300. package/test/preload.ts +0 -38
  301. package/test/project/project.test.ts +0 -42
  302. package/test/provider/provider.test.ts +0 -1809
  303. package/test/provider/transform.test.ts +0 -305
  304. package/test/session/retry.test.ts +0 -61
  305. package/test/session/session.test.ts +0 -71
  306. package/test/snapshot/snapshot.test.ts +0 -939
  307. package/test/tool/__snapshots__/tool.test.ts.snap +0 -9
  308. package/test/tool/bash.test.ts +0 -55
  309. package/test/tool/patch.test.ts +0 -259
  310. package/test/util/iife.test.ts +0 -36
  311. package/test/util/lazy.test.ts +0 -50
  312. package/test/util/timeout.test.ts +0 -21
  313. package/test/util/wildcard.test.ts +0 -55
  314. package/tsconfig.json +0 -17
@@ -1,70 +0,0 @@
1
- import { RequestError, type McpServer } from "@agentclientprotocol/sdk"
2
- import type { ACPSessionState } from "./types"
3
- import { Log } from "@/util/log"
4
- import type { OpencodeClient } from "@opencode-ai/sdk/v2"
5
-
6
- const log = Log.create({ service: "acp-session-manager" })
7
-
8
- export class ACPSessionManager {
9
- private sessions = new Map<string, ACPSessionState>()
10
- private sdk: OpencodeClient
11
-
12
- constructor(sdk: OpencodeClient) {
13
- this.sdk = sdk
14
- }
15
-
16
- async create(cwd: string, mcpServers: McpServer[], model?: ACPSessionState["model"]): Promise<ACPSessionState> {
17
- const session = await this.sdk.session
18
- .create(
19
- {
20
- title: `ACP Session ${crypto.randomUUID()}`,
21
- directory: cwd,
22
- },
23
- { throwOnError: true },
24
- )
25
- .then((x) => x.data!)
26
-
27
- const sessionId = session.id
28
- const resolvedModel = model
29
-
30
- const state: ACPSessionState = {
31
- id: sessionId,
32
- cwd,
33
- mcpServers,
34
- createdAt: new Date(),
35
- model: resolvedModel,
36
- }
37
- log.info("creating_session", { state })
38
-
39
- this.sessions.set(sessionId, state)
40
- return state
41
- }
42
-
43
- get(sessionId: string): ACPSessionState {
44
- const session = this.sessions.get(sessionId)
45
- if (!session) {
46
- log.error("session not found", { sessionId })
47
- throw RequestError.invalidParams(JSON.stringify({ error: `Session not found: ${sessionId}` }))
48
- }
49
- return session
50
- }
51
-
52
- getModel(sessionId: string) {
53
- const session = this.get(sessionId)
54
- return session.model
55
- }
56
-
57
- setModel(sessionId: string, model: ACPSessionState["model"]) {
58
- const session = this.get(sessionId)
59
- session.model = model
60
- this.sessions.set(sessionId, session)
61
- return session
62
- }
63
-
64
- setMode(sessionId: string, modeId: string) {
65
- const session = this.get(sessionId)
66
- session.modeId = modeId
67
- this.sessions.set(sessionId, session)
68
- return session
69
- }
70
- }
package/src/acp/types.ts DELETED
@@ -1,22 +0,0 @@
1
- import type { McpServer } from "@agentclientprotocol/sdk"
2
- import type { OpencodeClient } from "@opencode-ai/sdk/v2"
3
-
4
- export interface ACPSessionState {
5
- id: string
6
- cwd: string
7
- mcpServers: McpServer[]
8
- createdAt: Date
9
- model?: {
10
- providerID: string
11
- modelID: string
12
- }
13
- modeId?: string
14
- }
15
-
16
- export interface ACPConfig {
17
- sdk: OpencodeClient
18
- defaultModel?: {
19
- providerID: string
20
- modelID: string
21
- }
22
- }
@@ -1,310 +0,0 @@
1
- import { Config } from "../config/config"
2
- import z from "zod"
3
- import { Provider } from "../provider/provider"
4
- import { generateObject, type ModelMessage } from "ai"
5
- import PROMPT_GENERATE from "./generate.txt"
6
- import { SystemPrompt } from "../session/system"
7
- import { Instance } from "../project/instance"
8
- import { mergeDeep } from "remeda"
9
-
10
- export namespace Agent {
11
- export const Info = z
12
- .object({
13
- name: z.string(),
14
- description: z.string().optional(),
15
- mode: z.enum(["subagent", "primary", "all"]),
16
- builtIn: z.boolean(),
17
- topP: z.number().optional(),
18
- temperature: z.number().optional(),
19
- color: z.string().optional(),
20
- permission: z.object({
21
- edit: Config.Permission,
22
- bash: z.record(z.string(), Config.Permission),
23
- webfetch: Config.Permission.optional(),
24
- doom_loop: Config.Permission.optional(),
25
- external_directory: Config.Permission.optional(),
26
- }),
27
- model: z
28
- .object({
29
- modelID: z.string(),
30
- providerID: z.string(),
31
- })
32
- .optional(),
33
- prompt: z.string().optional(),
34
- tools: z.record(z.string(), z.boolean()),
35
- options: z.record(z.string(), z.any()),
36
- maxSteps: z.number().int().positive().optional(),
37
- })
38
- .meta({
39
- ref: "Agent",
40
- })
41
- export type Info = z.infer<typeof Info>
42
-
43
- const state = Instance.state(async () => {
44
- const cfg = await Config.get()
45
- const defaultTools = cfg.tools ?? {}
46
- const defaultPermission: Info["permission"] = {
47
- edit: "allow",
48
- bash: {
49
- "*": "allow",
50
- },
51
- webfetch: "allow",
52
- doom_loop: "ask",
53
- external_directory: "ask",
54
- }
55
- const agentPermission = mergeAgentPermissions(defaultPermission, cfg.permission ?? {})
56
-
57
- const planPermission = mergeAgentPermissions(
58
- {
59
- edit: "deny",
60
- bash: {
61
- "cut*": "allow",
62
- "diff*": "allow",
63
- "du*": "allow",
64
- "file *": "allow",
65
- "find * -delete*": "ask",
66
- "find * -exec*": "ask",
67
- "find * -fprint*": "ask",
68
- "find * -fls*": "ask",
69
- "find * -fprintf*": "ask",
70
- "find * -ok*": "ask",
71
- "find *": "allow",
72
- "git diff*": "allow",
73
- "git log*": "allow",
74
- "git show*": "allow",
75
- "git status*": "allow",
76
- "git branch": "allow",
77
- "git branch -v": "allow",
78
- "grep*": "allow",
79
- "head*": "allow",
80
- "less*": "allow",
81
- "ls*": "allow",
82
- "more*": "allow",
83
- "pwd*": "allow",
84
- "rg*": "allow",
85
- "sort --output=*": "ask",
86
- "sort -o *": "ask",
87
- "sort*": "allow",
88
- "stat*": "allow",
89
- "tail*": "allow",
90
- "tree -o *": "ask",
91
- "tree*": "allow",
92
- "uniq*": "allow",
93
- "wc*": "allow",
94
- "whereis*": "allow",
95
- "which*": "allow",
96
- "*": "ask",
97
- },
98
- webfetch: "allow",
99
- },
100
- cfg.permission ?? {},
101
- )
102
-
103
- const result: Record<string, Info> = {
104
- general: {
105
- name: "general",
106
- description: `General-purpose agent for researching complex questions and executing multi-step tasks. Use this agent to execute multiple units of work in parallel.`,
107
- tools: {
108
- todoread: false,
109
- todowrite: false,
110
- ...defaultTools,
111
- },
112
- options: {},
113
- permission: agentPermission,
114
- mode: "subagent",
115
- builtIn: true,
116
- },
117
- explore: {
118
- name: "explore",
119
- tools: {
120
- todoread: false,
121
- todowrite: false,
122
- edit: false,
123
- write: false,
124
- ...defaultTools,
125
- },
126
- description: `Fast agent specialized for exploring codebases. Use this when you need to quickly find files by patterns (eg. "src/components/**/*.tsx"), search code for keywords (eg. "API endpoints"), or answer questions about the codebase (eg. "how do API endpoints work?"). When calling this agent, specify the desired thoroughness level: "quick" for basic searches, "medium" for moderate exploration, or "very thorough" for comprehensive analysis across multiple locations and naming conventions.`,
127
- prompt: [
128
- `You are a file search specialist. You excel at thoroughly navigating and exploring codebases.`,
129
- ``,
130
- `Your strengths:`,
131
- `- Rapidly finding files using glob patterns`,
132
- `- Searching code and text with powerful regex patterns`,
133
- `- Reading and analyzing file contents`,
134
- ``,
135
- `Guidelines:`,
136
- `- Use Glob for broad file pattern matching`,
137
- `- Use Grep for searching file contents with regex`,
138
- `- Use Read when you know the specific file path you need to read`,
139
- `- Use Bash for file operations like copying, moving, or listing directory contents`,
140
- `- Adapt your search approach based on the thoroughness level specified by the caller`,
141
- `- Return file paths as absolute paths in your final response`,
142
- `- For clear communication, avoid using emojis`,
143
- `- Do not create any files, or run bash commands that modify the user's system state in any way`,
144
- ``,
145
- `Complete the user's search request efficiently and report your findings clearly.`,
146
- ].join("\n"),
147
- options: {},
148
- permission: agentPermission,
149
- mode: "subagent",
150
- builtIn: true,
151
- },
152
- build: {
153
- name: "build",
154
- tools: { ...defaultTools },
155
- options: {},
156
- permission: agentPermission,
157
- mode: "primary",
158
- builtIn: true,
159
- },
160
- plan: {
161
- name: "plan",
162
- options: {},
163
- permission: planPermission,
164
- tools: {
165
- ...defaultTools,
166
- },
167
- mode: "primary",
168
- builtIn: true,
169
- },
170
- }
171
- for (const [key, value] of Object.entries(cfg.agent ?? {})) {
172
- if (value.disable) {
173
- delete result[key]
174
- continue
175
- }
176
- let item = result[key]
177
- if (!item)
178
- item = result[key] = {
179
- name: key,
180
- mode: "all",
181
- permission: agentPermission,
182
- options: {},
183
- tools: {},
184
- builtIn: false,
185
- }
186
- const {
187
- name,
188
- model,
189
- prompt,
190
- tools,
191
- description,
192
- temperature,
193
- top_p,
194
- mode,
195
- permission,
196
- color,
197
- maxSteps,
198
- ...extra
199
- } = value
200
- item.options = {
201
- ...item.options,
202
- ...extra,
203
- }
204
- if (model) item.model = Provider.parseModel(model)
205
- if (prompt) item.prompt = prompt
206
- if (tools)
207
- item.tools = {
208
- ...item.tools,
209
- ...tools,
210
- }
211
- item.tools = {
212
- ...defaultTools,
213
- ...item.tools,
214
- }
215
- if (description) item.description = description
216
- if (temperature != undefined) item.temperature = temperature
217
- if (top_p != undefined) item.topP = top_p
218
- if (mode) item.mode = mode
219
- if (color) item.color = color
220
- // just here for consistency & to prevent it from being added as an option
221
- if (name) item.name = name
222
- if (maxSteps != undefined) item.maxSteps = maxSteps
223
-
224
- if (permission ?? cfg.permission) {
225
- item.permission = mergeAgentPermissions(cfg.permission ?? {}, permission ?? {})
226
- }
227
- }
228
- return result
229
- })
230
-
231
- export async function get(agent: string) {
232
- return state().then((x) => x[agent])
233
- }
234
-
235
- export async function list() {
236
- return state().then((x) => Object.values(x))
237
- }
238
-
239
- export async function generate(input: { description: string }) {
240
- const cfg = await Config.get()
241
- const defaultModel = await Provider.defaultModel()
242
- const model = await Provider.getModel(defaultModel.providerID, defaultModel.modelID)
243
- const language = await Provider.getLanguage(model)
244
- const system = SystemPrompt.header(defaultModel.providerID)
245
- system.push(PROMPT_GENERATE)
246
- const existing = await list()
247
- const result = await generateObject({
248
- experimental_telemetry: { isEnabled: cfg.experimental?.openTelemetry },
249
- temperature: 0.3,
250
- prompt: [
251
- ...system.map(
252
- (item): ModelMessage => ({
253
- role: "system",
254
- content: item,
255
- }),
256
- ),
257
- {
258
- role: "user",
259
- content: `Create an agent configuration based on this request: \"${input.description}\".\n\nIMPORTANT: The following identifiers already exist and must NOT be used: ${existing.map((i) => i.name).join(", ")}\n Return ONLY the JSON object, no other text, do not wrap in backticks`,
260
- },
261
- ],
262
- model: language,
263
- schema: z.object({
264
- identifier: z.string(),
265
- whenToUse: z.string(),
266
- systemPrompt: z.string(),
267
- }),
268
- })
269
- return result.object
270
- }
271
- }
272
-
273
- function mergeAgentPermissions(basePermission: any, overridePermission: any): Agent.Info["permission"] {
274
- if (typeof basePermission.bash === "string") {
275
- basePermission.bash = {
276
- "*": basePermission.bash,
277
- }
278
- }
279
- if (typeof overridePermission.bash === "string") {
280
- overridePermission.bash = {
281
- "*": overridePermission.bash,
282
- }
283
- }
284
- const merged = mergeDeep(basePermission ?? {}, overridePermission ?? {}) as any
285
- let mergedBash
286
- if (merged.bash) {
287
- if (typeof merged.bash === "string") {
288
- mergedBash = {
289
- "*": merged.bash,
290
- }
291
- } else if (typeof merged.bash === "object") {
292
- mergedBash = mergeDeep(
293
- {
294
- "*": "allow",
295
- },
296
- merged.bash,
297
- )
298
- }
299
- }
300
-
301
- const result: Agent.Info["permission"] = {
302
- edit: merged.edit ?? "allow",
303
- webfetch: merged.webfetch ?? "allow",
304
- bash: mergedBash ?? { "*": "allow" },
305
- doom_loop: merged.doom_loop,
306
- external_directory: merged.external_directory,
307
- }
308
-
309
- return result
310
- }
@@ -1,75 +0,0 @@
1
- You are an elite AI agent architect specializing in crafting high-performance agent configurations. Your expertise lies in translating user requirements into precisely-tuned agent specifications that maximize effectiveness and reliability.
2
-
3
- **Important Context**: You may have access to project-specific instructions from CLAUDE.md files and other context that may include coding standards, project structure, and custom requirements. Consider this context when creating agents to ensure they align with the project's established patterns and practices.
4
-
5
- When a user describes what they want an agent to do, you will:
6
-
7
- 1. **Extract Core Intent**: Identify the fundamental purpose, key responsibilities, and success criteria for the agent. Look for both explicit requirements and implicit needs. Consider any project-specific context from CLAUDE.md files. For agents that are meant to review code, you should assume that the user is asking to review recently written code and not the whole codebase, unless the user has explicitly instructed you otherwise.
8
-
9
- 2. **Design Expert Persona**: Create a compelling expert identity that embodies deep domain knowledge relevant to the task. The persona should inspire confidence and guide the agent's decision-making approach.
10
-
11
- 3. **Architect Comprehensive Instructions**: Develop a system prompt that:
12
-
13
- - Establishes clear behavioral boundaries and operational parameters
14
- - Provides specific methodologies and best practices for task execution
15
- - Anticipates edge cases and provides guidance for handling them
16
- - Incorporates any specific requirements or preferences mentioned by the user
17
- - Defines output format expectations when relevant
18
- - Aligns with project-specific coding standards and patterns from CLAUDE.md
19
-
20
- 4. **Optimize for Performance**: Include:
21
-
22
- - Decision-making frameworks appropriate to the domain
23
- - Quality control mechanisms and self-verification steps
24
- - Efficient workflow patterns
25
- - Clear escalation or fallback strategies
26
-
27
- 5. **Create Identifier**: Design a concise, descriptive identifier that:
28
- - Uses lowercase letters, numbers, and hyphens only
29
- - Is typically 2-4 words joined by hyphens
30
- - Clearly indicates the agent's primary function
31
- - Is memorable and easy to type
32
- - Avoids generic terms like "helper" or "assistant"
33
-
34
- 6 **Example agent descriptions**:
35
-
36
- - in the 'whenToUse' field of the JSON object, you should include examples of when this agent should be used.
37
- - examples should be of the form:
38
- - <example>
39
- Context: The user is creating a code-review agent that should be called after a logical chunk of code is written.
40
- user: "Please write a function that checks if a number is prime"
41
- assistant: "Here is the relevant function: "
42
- <function call omitted for brevity only for this example>
43
- <commentary>
44
- Since the user is greeting, use the Task tool to launch the greeting-responder agent to respond with a friendly joke.
45
- </commentary>
46
- assistant: "Now let me use the code-reviewer agent to review the code"
47
- </example>
48
- - <example>
49
- Context: User is creating an agent to respond to the word "hello" with a friendly jok.
50
- user: "Hello"
51
- assistant: "I'm going to use the Task tool to launch the greeting-responder agent to respond with a friendly joke"
52
- <commentary>
53
- Since the user is greeting, use the greeting-responder agent to respond with a friendly joke.
54
- </commentary>
55
- </example>
56
- - If the user mentioned or implied that the agent should be used proactively, you should include examples of this.
57
- - NOTE: Ensure that in the examples, you are making the assistant use the Agent tool and not simply respond directly to the task.
58
-
59
- Your output must be a valid JSON object with exactly these fields:
60
- {
61
- "identifier": "A unique, descriptive identifier using lowercase letters, numbers, and hyphens (e.g., 'code-reviewer', 'api-docs-writer', 'test-generator')",
62
- "whenToUse": "A precise, actionable description starting with 'Use this agent when...' that clearly defines the triggering conditions and use cases. Ensure you include examples as described above.",
63
- "systemPrompt": "The complete system prompt that will govern the agent's behavior, written in second person ('You are...', 'You will...') and structured for maximum clarity and effectiveness"
64
- }
65
-
66
- Key principles for your system prompts:
67
-
68
- - Be specific rather than generic - avoid vague instructions
69
- - Include concrete examples when they would clarify behavior
70
- - Balance comprehensiveness with clarity - every instruction should add value
71
- - Ensure the agent has enough context to handle variations of the core task
72
- - Make the agent proactive in seeking clarification when needed
73
- - Build in quality assurance and self-correction mechanisms
74
-
75
- Remember: The agents you create should be autonomous experts capable of handling their designated tasks with minimal additional guidance. Your system prompts are their complete operational manual.
package/src/auth/index.ts DELETED
@@ -1,70 +0,0 @@
1
- import path from "path"
2
- import { Global } from "../global"
3
- import fs from "fs/promises"
4
- import z from "zod"
5
-
6
- export namespace Auth {
7
- export const Oauth = z
8
- .object({
9
- type: z.literal("oauth"),
10
- refresh: z.string(),
11
- access: z.string(),
12
- expires: z.number(),
13
- enterpriseUrl: z.string().optional(),
14
- })
15
- .meta({ ref: "OAuth" })
16
-
17
- export const Api = z
18
- .object({
19
- type: z.literal("api"),
20
- key: z.string(),
21
- })
22
- .meta({ ref: "ApiAuth" })
23
-
24
- export const WellKnown = z
25
- .object({
26
- type: z.literal("wellknown"),
27
- key: z.string(),
28
- token: z.string(),
29
- })
30
- .meta({ ref: "WellKnownAuth" })
31
-
32
- export const Info = z.discriminatedUnion("type", [Oauth, Api, WellKnown]).meta({ ref: "Auth" })
33
- export type Info = z.infer<typeof Info>
34
-
35
- const filepath = path.join(Global.Path.data, "auth.json")
36
-
37
- export async function get(providerID: string) {
38
- const auth = await all()
39
- return auth[providerID]
40
- }
41
-
42
- export async function all(): Promise<Record<string, Info>> {
43
- const file = Bun.file(filepath)
44
- const data = await file.json().catch(() => ({}) as Record<string, unknown>)
45
- return Object.entries(data).reduce(
46
- (acc, [key, value]) => {
47
- const parsed = Info.safeParse(value)
48
- if (!parsed.success) return acc
49
- acc[key] = parsed.data
50
- return acc
51
- },
52
- {} as Record<string, Info>,
53
- )
54
- }
55
-
56
- export async function set(key: string, info: Info) {
57
- const file = Bun.file(filepath)
58
- const data = await all()
59
- await Bun.write(file, JSON.stringify({ ...data, [key]: info }, null, 2))
60
- await fs.chmod(file.name!, 0o600)
61
- }
62
-
63
- export async function remove(key: string) {
64
- const file = Bun.file(filepath)
65
- const data = await all()
66
- delete data[key]
67
- await Bun.write(file, JSON.stringify(data, null, 2))
68
- await fs.chmod(file.name!, 0o600)
69
- }
70
- }
package/src/bun/index.ts DELETED
@@ -1,152 +0,0 @@
1
- import z from "zod"
2
- import { Global } from "../global"
3
- import { Log } from "../util/log"
4
- import path from "path"
5
- import { NamedError } from "@opencode-ai/util/error"
6
- import { readableStreamToText } from "bun"
7
- import { createRequire } from "module"
8
- import { Lock } from "../util/lock"
9
-
10
- export namespace BunProc {
11
- const log = Log.create({ service: "bun" })
12
- const req = createRequire(import.meta.url)
13
-
14
- export async function run(cmd: string[], options?: Bun.SpawnOptions.OptionsObject<any, any, any>) {
15
- log.info("running", {
16
- cmd: [which(), ...cmd],
17
- ...options,
18
- })
19
- const result = Bun.spawn([which(), ...cmd], {
20
- ...options,
21
- stdout: "pipe",
22
- stderr: "pipe",
23
- env: {
24
- ...process.env,
25
- ...options?.env,
26
- BUN_BE_BUN: "1",
27
- },
28
- })
29
- const code = await result.exited
30
- const stdout = result.stdout
31
- ? typeof result.stdout === "number"
32
- ? result.stdout
33
- : await readableStreamToText(result.stdout)
34
- : undefined
35
- const stderr = result.stderr
36
- ? typeof result.stderr === "number"
37
- ? result.stderr
38
- : await readableStreamToText(result.stderr)
39
- : undefined
40
- log.info("done", {
41
- code,
42
- stdout,
43
- stderr,
44
- })
45
- if (code !== 0) {
46
- throw new Error(`Command failed with exit code ${result.exitCode}`)
47
- }
48
- return result
49
- }
50
-
51
- export function which() {
52
- return process.execPath
53
- }
54
-
55
- export const InstallFailedError = NamedError.create(
56
- "BunInstallFailedError",
57
- z.object({
58
- pkg: z.string(),
59
- version: z.string(),
60
- }),
61
- )
62
-
63
- export async function install(pkg: string, version = "latest") {
64
- // Use lock to ensure only one install at a time
65
- using _ = await Lock.write("bun-install")
66
-
67
- const mod = path.join(Global.Path.cache, "node_modules", pkg)
68
- const pkgjson = Bun.file(path.join(Global.Path.cache, "package.json"))
69
- const parsed = await pkgjson.json().catch(async () => {
70
- const result = { dependencies: {} }
71
- await Bun.write(pkgjson.name!, JSON.stringify(result, null, 2))
72
- return result
73
- })
74
- if (parsed.dependencies[pkg] === version) return mod
75
-
76
- // Build command arguments
77
- const args = ["add", "--force", "--exact", "--cwd", Global.Path.cache, pkg + "@" + version]
78
-
79
- // Let Bun handle registry resolution:
80
- // - If .npmrc files exist, Bun will use them automatically
81
- // - If no .npmrc files exist, Bun will default to https://registry.npmjs.org
82
- // - No need to pass --registry flag
83
- log.info("installing package using Bun's default registry resolution", {
84
- pkg,
85
- version,
86
- })
87
-
88
- const total = 3
89
- const wait = 500
90
-
91
- const runInstall = async (count: number = 1): Promise<void> => {
92
- log.info("bun install attempt", {
93
- pkg,
94
- version,
95
- attempt: count,
96
- total,
97
- })
98
- await BunProc.run(args, {
99
- cwd: Global.Path.cache,
100
- }).catch(async (error) => {
101
- log.warn("bun install failed", {
102
- pkg,
103
- version,
104
- attempt: count,
105
- total,
106
- error,
107
- })
108
- if (count >= total) {
109
- throw new InstallFailedError(
110
- { pkg, version },
111
- {
112
- cause: error,
113
- },
114
- )
115
- }
116
- const delay = wait * count
117
- log.info("bun install retrying", {
118
- pkg,
119
- version,
120
- next: count + 1,
121
- delay,
122
- })
123
- await Bun.sleep(delay)
124
- return runInstall(count + 1)
125
- })
126
- }
127
-
128
- await runInstall()
129
-
130
- parsed.dependencies[pkg] = version
131
- await Bun.write(pkgjson.name!, JSON.stringify(parsed, null, 2))
132
- return mod
133
- }
134
-
135
- export async function resolve(pkg: string) {
136
- const local = workspace(pkg)
137
- if (local) return local
138
- const dir = path.join(Global.Path.cache, "node_modules", pkg)
139
- const pkgjson = Bun.file(path.join(dir, "package.json"))
140
- const exists = await pkgjson.exists()
141
- if (exists) return dir
142
- }
143
-
144
- function workspace(pkg: string) {
145
- try {
146
- const target = req.resolve(`${pkg}/package.json`)
147
- return path.dirname(target)
148
- } catch {
149
- return
150
- }
151
- }
152
- }