@stonerzju/opencode 1.2.17 → 1.2.18
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.
- package/bin/opencode +29 -157
- package/package.json +29 -29
- package/src/acp/agent.ts +4 -4
- package/src/acp/session.ts +1 -1
- package/src/agent/agent.ts +3 -3
- package/src/bun/index.ts +2 -2
- package/src/cli/cmd/acp.ts +3 -3
- package/src/cli/cmd/debug/file.ts +1 -1
- package/src/cli/cmd/github.ts +2 -2
- package/src/cli/cmd/pr.ts +1 -1
- package/src/cli/cmd/tui/app.tsx +24 -24
- package/src/cli/cmd/tui/attach.ts +3 -3
- package/src/cli/cmd/tui/component/dialog-agent.tsx +3 -3
- package/src/cli/cmd/tui/component/dialog-command.tsx +3 -3
- package/src/cli/cmd/tui/component/dialog-mcp.tsx +5 -5
- package/src/cli/cmd/tui/component/dialog-model.tsx +4 -4
- package/src/cli/cmd/tui/component/dialog-provider.tsx +4 -4
- package/src/cli/cmd/tui/component/dialog-session-list.tsx +5 -5
- package/src/cli/cmd/tui/component/dialog-session-rename.tsx +3 -3
- package/src/cli/cmd/tui/component/dialog-skill.tsx +3 -3
- package/src/cli/cmd/tui/component/dialog-stash.tsx +3 -3
- package/src/cli/cmd/tui/component/dialog-status.tsx +2 -2
- package/src/cli/cmd/tui/component/dialog-tag.tsx +3 -3
- package/src/cli/cmd/tui/component/logo.tsx +2 -2
- package/src/cli/cmd/tui/component/prompt/autocomplete.tsx +6 -6
- package/src/cli/cmd/tui/component/prompt/frecency.tsx +2 -2
- package/src/cli/cmd/tui/component/prompt/history.tsx +2 -2
- package/src/cli/cmd/tui/component/prompt/index.tsx +14 -14
- package/src/cli/cmd/tui/component/prompt/stash.tsx +2 -2
- package/src/cli/cmd/tui/component/textarea-keybindings.ts +1 -1
- package/src/cli/cmd/tui/component/tips.tsx +1 -1
- package/src/cli/cmd/tui/context/directory.ts +1 -1
- package/src/cli/cmd/tui/context/exit.tsx +1 -1
- package/src/cli/cmd/tui/context/keybind.tsx +2 -2
- package/src/cli/cmd/tui/context/kv.tsx +2 -2
- package/src/cli/cmd/tui/context/local.tsx +6 -6
- package/src/cli/cmd/tui/context/sync.tsx +4 -4
- package/src/cli/cmd/tui/context/theme/opencode.json +245 -0
- package/src/cli/cmd/tui/context/theme.tsx +2 -2
- package/src/cli/cmd/tui/context/tui-config.tsx +1 -1
- package/src/cli/cmd/tui/event.ts +2 -2
- package/src/cli/cmd/tui/routes/home.tsx +6 -6
- package/src/cli/cmd/tui/routes/session/dialog-fork-from-timeline.tsx +6 -6
- package/src/cli/cmd/tui/routes/session/dialog-message.tsx +6 -6
- package/src/cli/cmd/tui/routes/session/dialog-subagent.tsx +2 -2
- package/src/cli/cmd/tui/routes/session/dialog-timeline.tsx +3 -3
- package/src/cli/cmd/tui/routes/session/header.tsx +5 -5
- package/src/cli/cmd/tui/routes/session/index.tsx +32 -32
- package/src/cli/cmd/tui/routes/session/permission.tsx +4 -4
- package/src/cli/cmd/tui/routes/session/sidebar.tsx +4 -4
- package/src/cli/cmd/tui/thread.ts +9 -9
- package/src/cli/cmd/tui/ui/dialog-confirm.tsx +1 -1
- package/src/cli/cmd/tui/ui/dialog-help.tsx +2 -2
- package/src/cli/cmd/tui/ui/dialog-select.tsx +5 -5
- package/src/cli/cmd/tui/ui/dialog.tsx +3 -3
- package/src/cli/cmd/tui/ui/toast.tsx +1 -1
- package/src/cli/cmd/tui/util/editor.ts +3 -3
- package/src/cli/cmd/tui/util/transcript.ts +1 -1
- package/src/cli/cmd/tui/worker.ts +10 -10
- package/src/cli/error.ts +1 -1
- package/src/cli/ui.ts +1 -1
- package/src/cli/upgrade.ts +4 -4
- package/src/command/index.ts +1 -1
- package/src/config/config.ts +10 -10
- package/src/config/markdown.ts +1 -1
- package/src/config/migrate-tui-config.ts +5 -5
- package/src/config/paths.ts +4 -4
- package/src/config/tui.ts +4 -4
- package/src/control/control.sql.ts +1 -1
- package/src/control/index.ts +1 -1
- package/src/control-plane/adaptors/worktree.ts +1 -1
- package/src/control-plane/session-proxy-middleware.ts +1 -1
- package/src/control-plane/workspace.sql.ts +1 -1
- package/src/control-plane/workspace.ts +7 -7
- package/src/file/index.ts +1 -1
- package/src/file/ripgrep.ts +2 -2
- package/src/file/watcher.ts +5 -5
- package/src/format/formatter.ts +1 -1
- package/src/ide/index.ts +3 -3
- package/src/index.ts +1 -1
- package/src/installation/index.ts +3 -3
- package/src/lsp/client.ts +3 -3
- package/src/lsp/index.ts +3 -3
- package/src/mcp/index.ts +4 -4
- package/src/permission/index.ts +2 -2
- package/src/permission/next.ts +10 -10
- package/src/plugin/codex.ts +1 -1
- package/src/plugin/copilot.ts +2 -2
- package/src/plugin/index.ts +1 -1
- package/src/project/bootstrap.ts +2 -2
- package/src/project/instance.ts +4 -4
- package/src/project/project.sql.ts +1 -1
- package/src/project/project.ts +5 -5
- package/src/project/state.ts +1 -1
- package/src/project/vcs.ts +4 -4
- package/src/provider/auth.ts +4 -4
- package/src/provider/error.ts +1 -1
- package/src/provider/models-snapshot.ts +2 -0
- package/src/provider/models.ts +1 -1
- package/src/provider/provider.ts +2 -2
- package/src/provider/transform.ts +2 -2
- package/src/pty/index.ts +5 -5
- package/src/question/index.ts +5 -5
- package/src/server/event.ts +1 -1
- package/src/server/mdns.ts +1 -1
- package/src/server/routes/global.ts +3 -3
- package/src/server/routes/permission.ts +1 -1
- package/src/server/routes/pty.ts +1 -1
- package/src/server/routes/session.ts +4 -4
- package/src/server/routes/tui.ts +1 -1
- package/src/server/server.ts +3 -3
- package/src/session/compaction.ts +7 -7
- package/src/session/index.ts +10 -10
- package/src/session/instruction.ts +1 -1
- package/src/session/llm.ts +11 -11
- package/src/session/message-v2.ts +10 -10
- package/src/session/message.ts +1 -1
- package/src/session/processor.ts +10 -10
- package/src/session/prompt.ts +8 -8
- package/src/session/retry.ts +2 -2
- package/src/session/revert.ts +1 -1
- package/src/session/session.sql.ts +3 -3
- package/src/session/status.ts +3 -3
- package/src/session/summary.ts +5 -5
- package/src/session/system.ts +1 -1
- package/src/session/todo.ts +2 -2
- package/src/share/share-next.ts +7 -7
- package/src/share/share.sql.ts +1 -1
- package/src/shell/shell.ts +3 -3
- package/src/skill/skill.ts +6 -6
- package/src/storage/db.ts +1 -1
- package/src/storage/storage.ts +1 -1
- package/src/tool/bash.ts +6 -6
- package/src/tool/edit.ts +1 -1
- package/src/tool/registry.ts +2 -2
- package/src/tool/skill.ts +1 -1
- package/src/tool/task.ts +3 -3
- package/src/util/array.ts +10 -0
- package/src/util/binary.ts +41 -0
- package/src/util/encode.ts +51 -0
- package/src/util/error.ts +54 -0
- package/src/util/identifier.ts +48 -0
- package/src/util/lazy.ts +4 -16
- package/src/util/path.ts +37 -0
- package/src/util/retry.ts +41 -0
- package/src/util/slug.ts +74 -0
- package/src/worktree/index.ts +3 -3
- package/AGENTS.md +0 -10
- package/BUN_SHELL_MIGRATION_PLAN.md +0 -136
- package/Dockerfile +0 -18
- package/README.md +0 -15
- package/bunfig.toml +0 -7
- package/drizzle.config.ts +0 -10
- package/script/build.ts +0 -224
- package/script/check-migrations.ts +0 -16
- package/script/postinstall.mjs +0 -131
- package/script/publish.ts +0 -181
- package/script/schema.ts +0 -63
- package/script/seed-e2e.ts +0 -50
- package/sst-env.d.ts +0 -10
- package/test/AGENTS.md +0 -81
- package/test/acp/agent-interface.test.ts +0 -51
- package/test/acp/event-subscription.test.ts +0 -683
- package/test/agent/agent.test.ts +0 -689
- package/test/bun.test.ts +0 -53
- package/test/cli/github-action.test.ts +0 -197
- package/test/cli/github-remote.test.ts +0 -80
- package/test/cli/import.test.ts +0 -38
- package/test/cli/plugin-auth-picker.test.ts +0 -120
- package/test/cli/tui/transcript.test.ts +0 -322
- package/test/config/agent-color.test.ts +0 -71
- package/test/config/config.test.ts +0 -1886
- package/test/config/fixtures/empty-frontmatter.md +0 -4
- package/test/config/fixtures/frontmatter.md +0 -28
- package/test/config/fixtures/markdown-header.md +0 -11
- package/test/config/fixtures/no-frontmatter.md +0 -1
- package/test/config/fixtures/weird-model-id.md +0 -13
- package/test/config/markdown.test.ts +0 -228
- package/test/config/tui.test.ts +0 -510
- package/test/control-plane/session-proxy-middleware.test.ts +0 -147
- package/test/control-plane/sse.test.ts +0 -56
- package/test/control-plane/workspace-server-sse.test.ts +0 -65
- package/test/control-plane/workspace-sync.test.ts +0 -97
- package/test/file/ignore.test.ts +0 -10
- package/test/file/index.test.ts +0 -394
- package/test/file/path-traversal.test.ts +0 -198
- package/test/file/ripgrep.test.ts +0 -39
- package/test/file/time.test.ts +0 -361
- package/test/fixture/db.ts +0 -11
- package/test/fixture/fixture.ts +0 -45
- package/test/fixture/lsp/fake-lsp-server.js +0 -77
- package/test/fixture/skills/agents-sdk/SKILL.md +0 -152
- package/test/fixture/skills/agents-sdk/references/callable.md +0 -92
- package/test/fixture/skills/cloudflare/SKILL.md +0 -211
- package/test/fixture/skills/index.json +0 -6
- package/test/ide/ide.test.ts +0 -82
- package/test/keybind.test.ts +0 -421
- package/test/lsp/client.test.ts +0 -95
- package/test/mcp/headers.test.ts +0 -153
- package/test/mcp/oauth-browser.test.ts +0 -249
- package/test/memory/abort-leak.test.ts +0 -136
- package/test/patch/patch.test.ts +0 -348
- package/test/permission/arity.test.ts +0 -33
- package/test/permission/next.test.ts +0 -689
- package/test/permission-task.test.ts +0 -319
- package/test/plugin/auth-override.test.ts +0 -44
- package/test/plugin/codex.test.ts +0 -123
- package/test/preload.ts +0 -80
- package/test/project/project.test.ts +0 -348
- package/test/project/worktree-remove.test.ts +0 -65
- package/test/provider/amazon-bedrock.test.ts +0 -446
- package/test/provider/copilot/convert-to-copilot-messages.test.ts +0 -523
- package/test/provider/copilot/copilot-chat-model.test.ts +0 -592
- package/test/provider/gitlab-duo.test.ts +0 -262
- package/test/provider/provider.test.ts +0 -2220
- package/test/provider/transform.test.ts +0 -2353
- package/test/pty/pty-output-isolation.test.ts +0 -140
- package/test/question/question.test.ts +0 -300
- package/test/scheduler.test.ts +0 -73
- package/test/server/global-session-list.test.ts +0 -89
- package/test/server/session-list.test.ts +0 -90
- package/test/server/session-select.test.ts +0 -78
- package/test/session/compaction.test.ts +0 -423
- package/test/session/instruction.test.ts +0 -170
- package/test/session/llm.test.ts +0 -667
- package/test/session/message-v2.test.ts +0 -924
- package/test/session/prompt.test.ts +0 -211
- package/test/session/retry.test.ts +0 -188
- package/test/session/revert-compact.test.ts +0 -285
- package/test/session/session.test.ts +0 -71
- package/test/session/structured-output-integration.test.ts +0 -233
- package/test/session/structured-output.test.ts +0 -385
- package/test/skill/discovery.test.ts +0 -110
- package/test/skill/skill.test.ts +0 -388
- package/test/snapshot/snapshot.test.ts +0 -1180
- package/test/storage/json-migration.test.ts +0 -846
- package/test/tool/__snapshots__/tool.test.ts.snap +0 -9
- package/test/tool/apply_patch.test.ts +0 -566
- package/test/tool/bash.test.ts +0 -402
- package/test/tool/edit.test.ts +0 -496
- package/test/tool/external-directory.test.ts +0 -127
- package/test/tool/fixtures/large-image.png +0 -0
- package/test/tool/fixtures/models-api.json +0 -38413
- package/test/tool/grep.test.ts +0 -110
- package/test/tool/question.test.ts +0 -107
- package/test/tool/read.test.ts +0 -504
- package/test/tool/registry.test.ts +0 -122
- package/test/tool/skill.test.ts +0 -112
- package/test/tool/truncation.test.ts +0 -160
- package/test/tool/webfetch.test.ts +0 -100
- package/test/tool/write.test.ts +0 -348
- package/test/util/filesystem.test.ts +0 -443
- package/test/util/format.test.ts +0 -59
- package/test/util/glob.test.ts +0 -164
- package/test/util/iife.test.ts +0 -36
- package/test/util/lazy.test.ts +0 -50
- package/test/util/lock.test.ts +0 -72
- package/test/util/process.test.ts +0 -59
- package/test/util/timeout.test.ts +0 -21
- package/test/util/wildcard.test.ts +0 -90
- package/tsconfig.json +0 -16
package/test/bun.test.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import fs from "fs/promises"
|
|
3
|
-
import path from "path"
|
|
4
|
-
|
|
5
|
-
describe("BunProc registry configuration", () => {
|
|
6
|
-
test("should not contain hardcoded registry parameters", async () => {
|
|
7
|
-
// Read the bun/index.ts file
|
|
8
|
-
const bunIndexPath = path.join(__dirname, "../src/bun/index.ts")
|
|
9
|
-
const content = await fs.readFile(bunIndexPath, "utf-8")
|
|
10
|
-
|
|
11
|
-
// Verify that no hardcoded registry is present
|
|
12
|
-
expect(content).not.toContain("--registry=")
|
|
13
|
-
expect(content).not.toContain("hasNpmRcConfig")
|
|
14
|
-
expect(content).not.toContain("NpmRc")
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
test("should use Bun's default registry resolution", async () => {
|
|
18
|
-
// Read the bun/index.ts file
|
|
19
|
-
const bunIndexPath = path.join(__dirname, "../src/bun/index.ts")
|
|
20
|
-
const content = await fs.readFile(bunIndexPath, "utf-8")
|
|
21
|
-
|
|
22
|
-
// Verify that it uses Bun's default resolution
|
|
23
|
-
expect(content).toContain("Bun's default registry resolution")
|
|
24
|
-
expect(content).toContain("Bun will use them automatically")
|
|
25
|
-
expect(content).toContain("No need to pass --registry flag")
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
test("should have correct command structure without registry", async () => {
|
|
29
|
-
// Read the bun/index.ts file
|
|
30
|
-
const bunIndexPath = path.join(__dirname, "../src/bun/index.ts")
|
|
31
|
-
const content = await fs.readFile(bunIndexPath, "utf-8")
|
|
32
|
-
|
|
33
|
-
// Extract the install function
|
|
34
|
-
const installFunctionMatch = content.match(/export async function install[\s\S]*?^ }/m)
|
|
35
|
-
expect(installFunctionMatch).toBeTruthy()
|
|
36
|
-
|
|
37
|
-
if (installFunctionMatch) {
|
|
38
|
-
const installFunction = installFunctionMatch[0]
|
|
39
|
-
|
|
40
|
-
// Verify expected arguments are present
|
|
41
|
-
expect(installFunction).toContain('"add"')
|
|
42
|
-
expect(installFunction).toContain('"--force"')
|
|
43
|
-
expect(installFunction).toContain('"--exact"')
|
|
44
|
-
expect(installFunction).toContain('"--cwd"')
|
|
45
|
-
expect(installFunction).toContain("Global.Path.cache")
|
|
46
|
-
expect(installFunction).toContain('pkg + "@" + version')
|
|
47
|
-
|
|
48
|
-
// Verify no registry argument is added
|
|
49
|
-
expect(installFunction).not.toContain('"--registry"')
|
|
50
|
-
expect(installFunction).not.toContain('args.push("--registry')
|
|
51
|
-
}
|
|
52
|
-
})
|
|
53
|
-
})
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import { test, expect, describe } from "bun:test"
|
|
2
|
-
import { extractResponseText, formatPromptTooLargeError } from "../../src/cli/cmd/github"
|
|
3
|
-
import type { MessageV2 } from "../../src/session/message-v2"
|
|
4
|
-
|
|
5
|
-
// Helper to create minimal valid parts
|
|
6
|
-
function createTextPart(text: string): MessageV2.Part {
|
|
7
|
-
return {
|
|
8
|
-
id: "1",
|
|
9
|
-
sessionID: "s",
|
|
10
|
-
messageID: "m",
|
|
11
|
-
type: "text" as const,
|
|
12
|
-
text,
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function createReasoningPart(text: string): MessageV2.Part {
|
|
17
|
-
return {
|
|
18
|
-
id: "1",
|
|
19
|
-
sessionID: "s",
|
|
20
|
-
messageID: "m",
|
|
21
|
-
type: "reasoning" as const,
|
|
22
|
-
text,
|
|
23
|
-
time: { start: 0 },
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function createToolPart(tool: string, title: string, status: "completed" | "running" = "completed"): MessageV2.Part {
|
|
28
|
-
if (status === "completed") {
|
|
29
|
-
return {
|
|
30
|
-
id: "1",
|
|
31
|
-
sessionID: "s",
|
|
32
|
-
messageID: "m",
|
|
33
|
-
type: "tool" as const,
|
|
34
|
-
callID: "c1",
|
|
35
|
-
tool,
|
|
36
|
-
state: {
|
|
37
|
-
status: "completed",
|
|
38
|
-
input: {},
|
|
39
|
-
output: "",
|
|
40
|
-
title,
|
|
41
|
-
metadata: {},
|
|
42
|
-
time: { start: 0, end: 1 },
|
|
43
|
-
},
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
id: "1",
|
|
48
|
-
sessionID: "s",
|
|
49
|
-
messageID: "m",
|
|
50
|
-
type: "tool" as const,
|
|
51
|
-
callID: "c1",
|
|
52
|
-
tool,
|
|
53
|
-
state: {
|
|
54
|
-
status: "running",
|
|
55
|
-
input: {},
|
|
56
|
-
time: { start: 0 },
|
|
57
|
-
},
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function createStepStartPart(): MessageV2.Part {
|
|
62
|
-
return {
|
|
63
|
-
id: "1",
|
|
64
|
-
sessionID: "s",
|
|
65
|
-
messageID: "m",
|
|
66
|
-
type: "step-start" as const,
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function createStepFinishPart(): MessageV2.Part {
|
|
71
|
-
return {
|
|
72
|
-
id: "1",
|
|
73
|
-
sessionID: "s",
|
|
74
|
-
messageID: "m",
|
|
75
|
-
type: "step-finish" as const,
|
|
76
|
-
reason: "done",
|
|
77
|
-
cost: 0,
|
|
78
|
-
tokens: { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } },
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
describe("extractResponseText", () => {
|
|
83
|
-
test("returns text from text part", () => {
|
|
84
|
-
const parts = [createTextPart("Hello world")]
|
|
85
|
-
expect(extractResponseText(parts)).toBe("Hello world")
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
test("returns last text part when multiple exist", () => {
|
|
89
|
-
const parts = [createTextPart("First"), createTextPart("Last")]
|
|
90
|
-
expect(extractResponseText(parts)).toBe("Last")
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
test("returns text even when tool parts follow", () => {
|
|
94
|
-
const parts = [createTextPart("I'll help with that."), createToolPart("todowrite", "3 todos")]
|
|
95
|
-
expect(extractResponseText(parts)).toBe("I'll help with that.")
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
test("returns null for reasoning-only response (signals summary needed)", () => {
|
|
99
|
-
const parts = [createReasoningPart("Let me think about this...")]
|
|
100
|
-
expect(extractResponseText(parts)).toBeNull()
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
test("returns null for tool-only response (signals summary needed)", () => {
|
|
104
|
-
// This is the exact scenario from the bug report - todowrite with no text
|
|
105
|
-
const parts = [createToolPart("todowrite", "8 todos")]
|
|
106
|
-
expect(extractResponseText(parts)).toBeNull()
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
test("returns null for multiple completed tools", () => {
|
|
110
|
-
const parts = [
|
|
111
|
-
createToolPart("read", "src/file.ts"),
|
|
112
|
-
createToolPart("edit", "src/file.ts"),
|
|
113
|
-
createToolPart("bash", "bun test"),
|
|
114
|
-
]
|
|
115
|
-
expect(extractResponseText(parts)).toBeNull()
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
test("returns null for running tool parts (signals summary needed)", () => {
|
|
119
|
-
const parts = [createToolPart("bash", "", "running")]
|
|
120
|
-
expect(extractResponseText(parts)).toBeNull()
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
test("throws on empty array", () => {
|
|
124
|
-
expect(() => extractResponseText([])).toThrow("no parts returned")
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
test("returns null for step-start only", () => {
|
|
128
|
-
const parts = [createStepStartPart()]
|
|
129
|
-
expect(extractResponseText(parts)).toBeNull()
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
test("returns null for step-finish only", () => {
|
|
133
|
-
const parts = [createStepFinishPart()]
|
|
134
|
-
expect(extractResponseText(parts)).toBeNull()
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
test("returns null for step-start and step-finish", () => {
|
|
138
|
-
const parts = [createStepStartPart(), createStepFinishPart()]
|
|
139
|
-
expect(extractResponseText(parts)).toBeNull()
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
test("returns text from multi-step response", () => {
|
|
143
|
-
const parts = [
|
|
144
|
-
createStepStartPart(),
|
|
145
|
-
createToolPart("read", "src/file.ts"),
|
|
146
|
-
createTextPart("Done"),
|
|
147
|
-
createStepFinishPart(),
|
|
148
|
-
]
|
|
149
|
-
expect(extractResponseText(parts)).toBe("Done")
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
test("prefers text over reasoning when both present", () => {
|
|
153
|
-
const parts = [createReasoningPart("Internal thinking..."), createTextPart("Final answer")]
|
|
154
|
-
expect(extractResponseText(parts)).toBe("Final answer")
|
|
155
|
-
})
|
|
156
|
-
|
|
157
|
-
test("prefers text over tools when both present", () => {
|
|
158
|
-
const parts = [createToolPart("read", "src/file.ts"), createTextPart("Here's what I found")]
|
|
159
|
-
expect(extractResponseText(parts)).toBe("Here's what I found")
|
|
160
|
-
})
|
|
161
|
-
})
|
|
162
|
-
|
|
163
|
-
describe("formatPromptTooLargeError", () => {
|
|
164
|
-
test("formats error without files", () => {
|
|
165
|
-
const result = formatPromptTooLargeError([])
|
|
166
|
-
expect(result).toBe("PROMPT_TOO_LARGE: The prompt exceeds the model's context limit.")
|
|
167
|
-
})
|
|
168
|
-
|
|
169
|
-
test("formats error with files (base64 content)", () => {
|
|
170
|
-
// Base64 is ~33% larger than original, so we multiply by 0.75 to get original size
|
|
171
|
-
// 400 KB base64 = 300 KB original, 200 KB base64 = 150 KB original
|
|
172
|
-
const files = [
|
|
173
|
-
{ filename: "screenshot.png", content: "a".repeat(400 * 1024) },
|
|
174
|
-
{ filename: "diagram.png", content: "b".repeat(200 * 1024) },
|
|
175
|
-
]
|
|
176
|
-
const result = formatPromptTooLargeError(files)
|
|
177
|
-
|
|
178
|
-
expect(result).toStartWith("PROMPT_TOO_LARGE: The prompt exceeds the model's context limit.")
|
|
179
|
-
expect(result).toInclude("Files in prompt:")
|
|
180
|
-
expect(result).toInclude("screenshot.png (300 KB)")
|
|
181
|
-
expect(result).toInclude("diagram.png (150 KB)")
|
|
182
|
-
})
|
|
183
|
-
|
|
184
|
-
test("lists all files when multiple present", () => {
|
|
185
|
-
// Base64 sizes: 4KB -> 3KB, 8KB -> 6KB, 12KB -> 9KB
|
|
186
|
-
const files = [
|
|
187
|
-
{ filename: "img1.png", content: "x".repeat(4 * 1024) },
|
|
188
|
-
{ filename: "img2.jpg", content: "y".repeat(8 * 1024) },
|
|
189
|
-
{ filename: "img3.gif", content: "z".repeat(12 * 1024) },
|
|
190
|
-
]
|
|
191
|
-
const result = formatPromptTooLargeError(files)
|
|
192
|
-
|
|
193
|
-
expect(result).toInclude("img1.png (3 KB)")
|
|
194
|
-
expect(result).toInclude("img2.jpg (6 KB)")
|
|
195
|
-
expect(result).toInclude("img3.gif (9 KB)")
|
|
196
|
-
})
|
|
197
|
-
})
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "bun:test"
|
|
2
|
-
import { parseGitHubRemote } from "../../src/cli/cmd/github"
|
|
3
|
-
|
|
4
|
-
test("parses https URL with .git suffix", () => {
|
|
5
|
-
expect(parseGitHubRemote("https://github.com/sst/opencode.git")).toEqual({ owner: "sst", repo: "opencode" })
|
|
6
|
-
})
|
|
7
|
-
|
|
8
|
-
test("parses https URL without .git suffix", () => {
|
|
9
|
-
expect(parseGitHubRemote("https://github.com/sst/opencode")).toEqual({ owner: "sst", repo: "opencode" })
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
test("parses git@ URL with .git suffix", () => {
|
|
13
|
-
expect(parseGitHubRemote("git@github.com:sst/opencode.git")).toEqual({ owner: "sst", repo: "opencode" })
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
test("parses git@ URL without .git suffix", () => {
|
|
17
|
-
expect(parseGitHubRemote("git@github.com:sst/opencode")).toEqual({ owner: "sst", repo: "opencode" })
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
test("parses ssh:// URL with .git suffix", () => {
|
|
21
|
-
expect(parseGitHubRemote("ssh://git@github.com/sst/opencode.git")).toEqual({ owner: "sst", repo: "opencode" })
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
test("parses ssh:// URL without .git suffix", () => {
|
|
25
|
-
expect(parseGitHubRemote("ssh://git@github.com/sst/opencode")).toEqual({ owner: "sst", repo: "opencode" })
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
test("parses http URL", () => {
|
|
29
|
-
expect(parseGitHubRemote("http://github.com/owner/repo")).toEqual({ owner: "owner", repo: "repo" })
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
test("parses URL with hyphenated owner and repo names", () => {
|
|
33
|
-
expect(parseGitHubRemote("https://github.com/my-org/my-repo.git")).toEqual({ owner: "my-org", repo: "my-repo" })
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
test("parses URL with underscores in names", () => {
|
|
37
|
-
expect(parseGitHubRemote("git@github.com:my_org/my_repo.git")).toEqual({ owner: "my_org", repo: "my_repo" })
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
test("parses URL with numbers in names", () => {
|
|
41
|
-
expect(parseGitHubRemote("https://github.com/org123/repo456")).toEqual({ owner: "org123", repo: "repo456" })
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
test("parses repos with dots in the name", () => {
|
|
45
|
-
expect(parseGitHubRemote("https://github.com/socketio/socket.io.git")).toEqual({
|
|
46
|
-
owner: "socketio",
|
|
47
|
-
repo: "socket.io",
|
|
48
|
-
})
|
|
49
|
-
expect(parseGitHubRemote("https://github.com/vuejs/vue.js")).toEqual({
|
|
50
|
-
owner: "vuejs",
|
|
51
|
-
repo: "vue.js",
|
|
52
|
-
})
|
|
53
|
-
expect(parseGitHubRemote("git@github.com:mrdoob/three.js.git")).toEqual({
|
|
54
|
-
owner: "mrdoob",
|
|
55
|
-
repo: "three.js",
|
|
56
|
-
})
|
|
57
|
-
expect(parseGitHubRemote("https://github.com/jashkenas/backbone.git")).toEqual({
|
|
58
|
-
owner: "jashkenas",
|
|
59
|
-
repo: "backbone",
|
|
60
|
-
})
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
test("returns null for non-github URLs", () => {
|
|
64
|
-
expect(parseGitHubRemote("https://gitlab.com/owner/repo.git")).toBeNull()
|
|
65
|
-
expect(parseGitHubRemote("git@gitlab.com:owner/repo.git")).toBeNull()
|
|
66
|
-
expect(parseGitHubRemote("https://bitbucket.org/owner/repo")).toBeNull()
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
test("returns null for invalid URLs", () => {
|
|
70
|
-
expect(parseGitHubRemote("not-a-url")).toBeNull()
|
|
71
|
-
expect(parseGitHubRemote("")).toBeNull()
|
|
72
|
-
expect(parseGitHubRemote("github.com")).toBeNull()
|
|
73
|
-
expect(parseGitHubRemote("https://github.com/")).toBeNull()
|
|
74
|
-
expect(parseGitHubRemote("https://github.com/owner")).toBeNull()
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
test("returns null for URLs with extra path segments", () => {
|
|
78
|
-
expect(parseGitHubRemote("https://github.com/owner/repo/tree/main")).toBeNull()
|
|
79
|
-
expect(parseGitHubRemote("https://github.com/owner/repo/blob/main/file.ts")).toBeNull()
|
|
80
|
-
})
|
package/test/cli/import.test.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "bun:test"
|
|
2
|
-
import { parseShareUrl, transformShareData, type ShareData } from "../../src/cli/cmd/import"
|
|
3
|
-
|
|
4
|
-
// parseShareUrl tests
|
|
5
|
-
test("parses valid share URLs", () => {
|
|
6
|
-
expect(parseShareUrl("https://opncd.ai/share/Jsj3hNIW")).toBe("Jsj3hNIW")
|
|
7
|
-
expect(parseShareUrl("https://custom.example.com/share/abc123")).toBe("abc123")
|
|
8
|
-
expect(parseShareUrl("http://localhost:3000/share/test_id-123")).toBe("test_id-123")
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
test("rejects invalid URLs", () => {
|
|
12
|
-
expect(parseShareUrl("https://opncd.ai/s/Jsj3hNIW")).toBeNull() // legacy format
|
|
13
|
-
expect(parseShareUrl("https://opncd.ai/share/")).toBeNull()
|
|
14
|
-
expect(parseShareUrl("https://opncd.ai/share/id/extra")).toBeNull()
|
|
15
|
-
expect(parseShareUrl("not-a-url")).toBeNull()
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
// transformShareData tests
|
|
19
|
-
test("transforms share data to storage format", () => {
|
|
20
|
-
const data: ShareData[] = [
|
|
21
|
-
{ type: "session", data: { id: "sess-1", title: "Test" } as any },
|
|
22
|
-
{ type: "message", data: { id: "msg-1", sessionID: "sess-1" } as any },
|
|
23
|
-
{ type: "part", data: { id: "part-1", messageID: "msg-1" } as any },
|
|
24
|
-
{ type: "part", data: { id: "part-2", messageID: "msg-1" } as any },
|
|
25
|
-
]
|
|
26
|
-
|
|
27
|
-
const result = transformShareData(data)!
|
|
28
|
-
|
|
29
|
-
expect(result.info.id).toBe("sess-1")
|
|
30
|
-
expect(result.messages).toHaveLength(1)
|
|
31
|
-
expect(result.messages[0].parts).toHaveLength(2)
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
test("returns null for invalid share data", () => {
|
|
35
|
-
expect(transformShareData([])).toBeNull()
|
|
36
|
-
expect(transformShareData([{ type: "message", data: {} as any }])).toBeNull()
|
|
37
|
-
expect(transformShareData([{ type: "session", data: { id: "s" } as any }])).toBeNull() // no messages
|
|
38
|
-
})
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { test, expect, describe } from "bun:test"
|
|
2
|
-
import { resolvePluginProviders } from "../../src/cli/cmd/auth"
|
|
3
|
-
import type { Hooks } from "@opencode-ai/plugin"
|
|
4
|
-
|
|
5
|
-
function hookWithAuth(provider: string): Hooks {
|
|
6
|
-
return {
|
|
7
|
-
auth: {
|
|
8
|
-
provider,
|
|
9
|
-
methods: [],
|
|
10
|
-
},
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function hookWithoutAuth(): Hooks {
|
|
15
|
-
return {}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
describe("resolvePluginProviders", () => {
|
|
19
|
-
test("returns plugin providers not in models.dev", () => {
|
|
20
|
-
const result = resolvePluginProviders({
|
|
21
|
-
hooks: [hookWithAuth("portkey")],
|
|
22
|
-
existingProviders: {},
|
|
23
|
-
disabled: new Set(),
|
|
24
|
-
providerNames: {},
|
|
25
|
-
})
|
|
26
|
-
expect(result).toEqual([{ id: "portkey", name: "portkey" }])
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
test("skips providers already in models.dev", () => {
|
|
30
|
-
const result = resolvePluginProviders({
|
|
31
|
-
hooks: [hookWithAuth("anthropic")],
|
|
32
|
-
existingProviders: { anthropic: {} },
|
|
33
|
-
disabled: new Set(),
|
|
34
|
-
providerNames: {},
|
|
35
|
-
})
|
|
36
|
-
expect(result).toEqual([])
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
test("deduplicates across plugins", () => {
|
|
40
|
-
const result = resolvePluginProviders({
|
|
41
|
-
hooks: [hookWithAuth("portkey"), hookWithAuth("portkey")],
|
|
42
|
-
existingProviders: {},
|
|
43
|
-
disabled: new Set(),
|
|
44
|
-
providerNames: {},
|
|
45
|
-
})
|
|
46
|
-
expect(result).toEqual([{ id: "portkey", name: "portkey" }])
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
test("respects disabled_providers", () => {
|
|
50
|
-
const result = resolvePluginProviders({
|
|
51
|
-
hooks: [hookWithAuth("portkey")],
|
|
52
|
-
existingProviders: {},
|
|
53
|
-
disabled: new Set(["portkey"]),
|
|
54
|
-
providerNames: {},
|
|
55
|
-
})
|
|
56
|
-
expect(result).toEqual([])
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
test("respects enabled_providers when provider is absent", () => {
|
|
60
|
-
const result = resolvePluginProviders({
|
|
61
|
-
hooks: [hookWithAuth("portkey")],
|
|
62
|
-
existingProviders: {},
|
|
63
|
-
disabled: new Set(),
|
|
64
|
-
enabled: new Set(["anthropic"]),
|
|
65
|
-
providerNames: {},
|
|
66
|
-
})
|
|
67
|
-
expect(result).toEqual([])
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
test("includes provider when in enabled set", () => {
|
|
71
|
-
const result = resolvePluginProviders({
|
|
72
|
-
hooks: [hookWithAuth("portkey")],
|
|
73
|
-
existingProviders: {},
|
|
74
|
-
disabled: new Set(),
|
|
75
|
-
enabled: new Set(["portkey"]),
|
|
76
|
-
providerNames: {},
|
|
77
|
-
})
|
|
78
|
-
expect(result).toEqual([{ id: "portkey", name: "portkey" }])
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
test("resolves name from providerNames", () => {
|
|
82
|
-
const result = resolvePluginProviders({
|
|
83
|
-
hooks: [hookWithAuth("portkey")],
|
|
84
|
-
existingProviders: {},
|
|
85
|
-
disabled: new Set(),
|
|
86
|
-
providerNames: { portkey: "Portkey AI" },
|
|
87
|
-
})
|
|
88
|
-
expect(result).toEqual([{ id: "portkey", name: "Portkey AI" }])
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
test("falls back to id when no name configured", () => {
|
|
92
|
-
const result = resolvePluginProviders({
|
|
93
|
-
hooks: [hookWithAuth("portkey")],
|
|
94
|
-
existingProviders: {},
|
|
95
|
-
disabled: new Set(),
|
|
96
|
-
providerNames: {},
|
|
97
|
-
})
|
|
98
|
-
expect(result).toEqual([{ id: "portkey", name: "portkey" }])
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
test("skips hooks without auth", () => {
|
|
102
|
-
const result = resolvePluginProviders({
|
|
103
|
-
hooks: [hookWithoutAuth(), hookWithAuth("portkey"), hookWithoutAuth()],
|
|
104
|
-
existingProviders: {},
|
|
105
|
-
disabled: new Set(),
|
|
106
|
-
providerNames: {},
|
|
107
|
-
})
|
|
108
|
-
expect(result).toEqual([{ id: "portkey", name: "portkey" }])
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
test("returns empty for no hooks", () => {
|
|
112
|
-
const result = resolvePluginProviders({
|
|
113
|
-
hooks: [],
|
|
114
|
-
existingProviders: {},
|
|
115
|
-
disabled: new Set(),
|
|
116
|
-
providerNames: {},
|
|
117
|
-
})
|
|
118
|
-
expect(result).toEqual([])
|
|
119
|
-
})
|
|
120
|
-
})
|