Spaces:
Running
Running
OpenCode vs opencode-api ๊ธฐ๋ฅ ๋น๊ต ๋ถ์
๋ถ์์ผ: 2026-01-28
์๋ณธ TypeScript OpenCode์ Python opencode-api์ ๊ธฐ๋ฅ ๋น๊ต ๋ฐ ํด๋ก ๊ณํ
๊ฐ์
| ํญ๋ชฉ | ์๋ณธ TypeScript OpenCode | Python opencode-api |
|---|---|---|
| ์ฉ๋ | ๊ฐ๋ฐ์์ฉ AI ์ฝ๋ฉ ์์ด์ ํธ CLI | ๊ต์ก ํ๋ซํผ์ฉ ์น API |
| ๋ฐํ์ | Bun | Python 3.11+ / FastAPI |
| ์ํคํ ์ฒ | Namespace ํจํด, ์ด๋ฒคํธ ๊ธฐ๋ฐ | ํด๋์ค ๊ธฐ๋ฐ, ์ง์ ํธ์ถ |
| ๊ฒฝ๋ก | /packages/opencode/src/ |
/opencode-api/src/opencode_api/ |
ํ์ฌ ๊ตฌํ ์ํ (์ฝ 20-25%)
| ์์ญ | ์๋ณธ ๊ธฐ๋ฅ ์ | Python ๊ตฌํ | ๋น์จ |
|---|---|---|---|
| Session | 13 ๊ธฐ๋ฅ | 4 ๊ธฐ๋ฅ | 31% |
| Provider | 21 ํ๋ก๋ฐ์ด๋ | 4 ํ๋ก๋ฐ์ด๋ | 19% |
| Tool | 24 ๋๊ตฌ | 5 ๋๊ตฌ | 21% |
| Server | 15 ๋ผ์ฐํธ ๊ทธ๋ฃน | 5 ๋ผ์ฐํธ ๋ชจ๋ | 33% |
| ๊ธฐํ (MCP, LSP, Permission, Snapshot, Plugin) | 5 ์์คํ | 0 ์์คํ | 0% |
1. Session ๊ด๋ฆฌ
๊ตฌํ ์ํ
| ๊ธฐ๋ฅ | ์๋ณธ ํ์ผ | Python ํ์ผ | ์ํ |
|---|---|---|---|
| ์ธ์ ์์ฑ/์กฐํ/์์ /์ญ์ | session/index.ts |
session/session.py |
โ ๊ตฌํ๋จ |
| ๋ฉ์์ง ํํธ ์์คํ | message-v2.ts |
message.py |
โ ๏ธ ๊ฐ์ํ๋จ |
| ๋ฉ์์ง ์คํธ๋ฆฌ๋ฐ | processor.ts + llm.ts |
prompt.py |
โ ๊ตฌํ๋จ |
| ์ธ์ ์์ถ (Compaction) | compaction.ts |
- | โ ๋ฏธ๊ตฌํ |
| ์ค๋ ์ท/๋๋๋ฆฌ๊ธฐ | revert.ts + Snapshot |
- | โ ๋ฏธ๊ตฌํ |
| ์ธ์ ์์ฝ | summary.ts |
- | โ ๋ฏธ๊ตฌํ |
| ์ธ์ ๊ณต์ | share/share-next.ts |
- | โ ๋ฏธ๊ตฌํ |
| ์ธ์ ํฌํฌ | Session.fork() |
- | โ ๋ฏธ๊ตฌํ |
| ๋น์ฉ ๊ณ์ฐ | Session.getUsage() |
๊ธฐ๋ณธ ํ ํฐ๋ง | โ ๏ธ ๊ฐ์ํ๋จ |
| ์ธ์ ์ํ | status.ts |
- | โ ๋ฏธ๊ตฌํ |
| ์ฌ์๋ ๋ก์ง | retry.ts |
- | โ ๋ฏธ๊ตฌํ |
๋ฏธ๊ตฌํ ๊ธฐ๋ฅ ์์ธ
์ธ์ ์์ถ (Compaction)
- ์๋ณธ ์์น:
session/compaction.ts - ๊ธฐ๋ฅ: ๋ํ๊ฐ ๊ธธ์ด์ง๋ฉด ์ด์ ๋ฉ์์ง๋ฅผ ์์ฝํ์ฌ ์ปจํ ์คํธ ์๋์ฐ ๊ด๋ฆฌ
- ์ค์๋: ๐ด ๋์ (๊ธด ๋ํ ์ ํ์)
์ธ์ ์์ฝ (Summary)
- ์๋ณธ ์์น:
session/summary.ts - ๊ธฐ๋ฅ: ํ์ผ ๋ณ๊ฒฝ ํต๊ณ ๊ณ์ฐ (additions, deletions, files)
- ์ค์๋: ๐ก ์ค๊ฐ
์ค๋ ์ท/๋๋๋ฆฌ๊ธฐ
- ์๋ณธ ์์น:
session/revert.ts,snapshot/index.ts - ๊ธฐ๋ฅ: Git ๊ธฐ๋ฐ ์ค๋ ์ท์ผ๋ก ์ธ์ ์ํ ๋๋๋ฆฌ๊ธฐ
- ์ค์๋: ๐ก ์ค๊ฐ (๊ต์ก ํ๋ซํผ์์๋ ๋ฎ์)
2. Provider (LLM ํตํฉ)
๊ตฌํ ์ํ
| ํ๋ก๋ฐ์ด๋ | ์๋ณธ | Python | ์ํ |
|---|---|---|---|
| Anthropic Claude | โ | โ
anthropic.py |
โ ๊ตฌํ๋จ |
| OpenAI | โ | โ
openai.py |
โ ๊ตฌํ๋จ |
| Google Gemini | โ | โ
gemini.py |
โ ๊ตฌํ๋จ |
| LiteLLM | โ | โ
litellm.py |
โ Python ์ ์ฉ |
| Amazon Bedrock | โ | โ | โ ๋ฏธ๊ตฌํ |
| Azure OpenAI | โ | โ | โ ๋ฏธ๊ตฌํ |
| Google Vertex | โ | โ | โ ๋ฏธ๊ตฌํ |
| OpenRouter | โ | โ | โ ๋ฏธ๊ตฌํ |
| GitHub Copilot | โ | โ | โ ๋ฏธ๊ตฌํ |
| xAI/Grok | โ | โ | โ ๋ฏธ๊ตฌํ |
| Mistral | โ | โ | โ ๋ฏธ๊ตฌํ |
| Groq | โ | โ | โ ๋ฏธ๊ตฌํ |
| DeepInfra | โ | โ | โ ๋ฏธ๊ตฌํ |
| Cerebras | โ | โ | โ ๋ฏธ๊ตฌํ |
| Cohere | โ | โ | โ ๋ฏธ๊ตฌํ |
| Together AI | โ | โ | โ ๋ฏธ๊ตฌํ |
| Perplexity | โ | โ | โ ๋ฏธ๊ตฌํ |
| GitLab | โ | โ | โ ๋ฏธ๊ตฌํ |
| Cloudflare | โ | โ | โ ๋ฏธ๊ตฌํ |
| SAP AI Core | โ | โ | โ ๋ฏธ๊ตฌํ |
์ถ๊ฐ ํ๋ก๋ฐ์ด๋ ๊ตฌํ ๋ฐฉ๋ฒ
- LiteLLM์ ํตํด ๋๋ถ๋ถ์ ํ๋ก๋ฐ์ด๋๋ฅผ ์ฝ๊ฒ ์ถ๊ฐ ๊ฐ๋ฅ
provider/litellm.pyํ์ฅ์ผ๋ก OpenRouter, Groq, Mistral ๋ฑ ์ง์
3. Tool System
๊ตฌํ ์ํ
| ๋๊ตฌ | ์๋ณธ ํ์ผ | Python ํ์ผ | ์ํ |
|---|---|---|---|
| Tool ์ถ์ํ | tool/tool.ts |
tool/tool.py |
โ ๊ตฌํ๋จ |
| Tool ๋ ์ง์คํธ๋ฆฌ | registry.ts |
__init__.py |
โ ๏ธ ๊ฐ์ํ๋จ |
| Question | question.ts |
question.py |
โ ๊ตฌํ๋จ |
| WebSearch | websearch.ts (Exa) |
websearch.py (DuckDuckGo) |
โ ๏ธ ๋ค๋ฅธ ๋ฐฑ์๋ |
| WebFetch | webfetch.ts |
webfetch.py |
โ ๊ตฌํ๋จ |
| Todo | todo.ts |
todo.py |
โ ๊ตฌํ๋จ |
| Skill | skill.ts |
skill.py |
โ ๏ธ ๊ธฐ๋ณธ ๊ตฌํ |
| Bash | bash.ts |
- | โ ๋ฏธ๊ตฌํ |
| Edit | edit.ts |
- | โ ๋ฏธ๊ตฌํ |
| Write | write.ts |
- | โ ๋ฏธ๊ตฌํ |
| Read | read.ts |
- | โ ๋ฏธ๊ตฌํ |
| Glob | glob.ts |
- | โ ๋ฏธ๊ตฌํ |
| Grep | grep.ts |
- | โ ๋ฏธ๊ตฌํ |
| Ls | ls.ts |
- | โ ๋ฏธ๊ตฌํ |
| Task | task.ts |
- | โ ๋ฏธ๊ตฌํ |
| Batch | batch.ts |
- | โ ๋ฏธ๊ตฌํ |
| CodeSearch | codesearch.ts |
- | โ ๋ฏธ๊ตฌํ |
| LSP | lsp.ts |
- | โ ๋ฏธ๊ตฌํ |
| Plan | plan.ts |
- | โ ๋ฏธ๊ตฌํ |
| Apply Patch | apply_patch.ts |
- | โ ๋ฏธ๊ตฌํ |
| MultiEdit | multiedit.ts |
- | โ ๋ฏธ๊ตฌํ |
๋ฏธ๊ตฌํ ํต์ฌ ๋๊ตฌ ์์ธ
Bash ๋๊ตฌ
- ๊ธฐ๋ฅ: ์ ธ ๋ช ๋ น ์คํ, ํ์์์, ๊ถํ ๊ฒ์ฌ
- ๋ณด์ ๊ณ ๋ ค: ๊ต์ก ํ๋ซํผ์์๋ E2B ์๋๋ฐ์ค ๋๋ ์ฝ๋ ์ธํฐํ๋ฆฌํฐ ๋์ ํ์
- ์ค์๋: ๐ด ๋์ (์ฝ๋ ์คํ ํ์ ์)
Edit/Write ๋๊ตฌ
- ๊ธฐ๋ฅ: ํ์ผ ํธ์ง/์์ฑ, ํผ์ง ๋งค์นญ, LSP ์ง๋จ
- ๊ตฌํ ๋ฐฉ์: Supabase Storage ๋๋ E2B ์๋๋ฐ์ค ํ์ฉ
- ์ค์๋: ๐ด ๋์ (์ฝ๋ ์์ฑ ๊ธฐ๋ฅ ํ์ ์)
Read/Glob/Grep ๋๊ตฌ
- ๊ธฐ๋ฅ: ํ์ผ ์ฝ๊ธฐ, ํจํด ๊ฒ์, ๋ด์ฉ ๊ฒ์
- ๊ตฌํ ๋ฐฉ์: ์ ํ๋ ํ์ผ ์์คํ ๋๋ ๊ฐ์ ํ๊ฒฝ
- ์ค์๋: ๐ก ์ค๊ฐ
Task ๋๊ตฌ
- ๊ธฐ๋ฅ: ์๋ธ์์ด์ ํธ ์์
- ์ค์๋: ๐ก ์ค๊ฐ (๋ณต์กํ ์์ ๋ถํ ์)
4. Server/API
๊ตฌํ ์ํ
| ์๋ํฌ์ธํธ | ์๋ณธ | Python | ์ํ |
|---|---|---|---|
/session |
routes/session.ts |
routes/session.py |
โ ๊ตฌํ๋จ |
/session/{id}/message (SSE) |
ํตํฉ | routes/session.py |
โ ๊ตฌํ๋จ |
/session/{id}/abort |
ํตํฉ | routes/session.py |
โ ๊ตฌํ๋จ |
/provider |
routes/provider.ts |
routes/provider.py |
โ ๊ตฌํ๋จ |
/event (SSE) |
server.ts |
routes/event.py |
โ ๏ธ ๊ธฐ๋ณธ ๊ตฌํ |
/question |
routes/question.ts |
routes/question.py |
โ ๊ตฌํ๋จ |
/agent |
- | routes/agent.py |
โ Python ์ ์ฉ |
/project |
routes/project.ts |
- | โ ๋ฏธ๊ตฌํ |
/config |
routes/config.ts |
- | โ ๋ฏธ๊ตฌํ |
/mcp |
routes/mcp.ts |
- | โ ๋ฏธ๊ตฌํ |
/permission |
routes/permission.ts |
- | โ ๋ฏธ๊ตฌํ |
/file |
routes/file.ts |
- | โ ๋ฏธ๊ตฌํ |
/pty |
routes/pty.ts |
- | โ ๋ฏธ๊ตฌํ |
/tui |
routes/tui.ts |
- | โ ๋ฏธ๊ตฌํ |
/experimental |
routes/experimental.ts |
- | โ ๋ฏธ๊ตฌํ |
/global |
routes/global.ts |
- | โ ๋ฏธ๊ตฌํ |
5. ๊ธฐํ ์ฃผ์ ์์คํ
| ์์คํ | ์๋ณธ ์์น | Python | ์ํ |
|---|---|---|---|
| MCP | mcp/index.ts |
- | โ ๋ฏธ๊ตฌํ |
| LSP | lsp/index.ts |
- | โ ๋ฏธ๊ตฌํ |
| Plugin | plugin/index.ts |
- | โ ๋ฏธ๊ตฌํ |
| Permission | permission/index.ts |
- | โ ๋ฏธ๊ตฌํ |
| Snapshot | snapshot/index.ts |
- | โ ๋ฏธ๊ตฌํ |
| ACP | acp/ |
- | โ ๋ฏธ๊ตฌํ |
| Worktree | worktree/index.ts |
- | โ ๋ฏธ๊ตฌํ |
| Scheduler | scheduler/index.ts |
- | โ ๋ฏธ๊ตฌํ |
๊ตฌํ ์ฐ์ ์์
๐ข ๋ฐ๋ก ๊ตฌํ ๊ฐ๋ฅ (๋์ด๋: ๋ฎ์)
| ์์ | ๊ธฐ๋ฅ | ์ค๋ช | ์์ ์์ ๋ |
|---|---|---|---|
| 1 | ์ถ๊ฐ LLM ํ๋ก๋ฐ์ด๋ | LiteLLM ํ์ฅ (OpenRouter, Groq ๋ฑ) | 1-2์๊ฐ |
| 2 | ์ธ์ ์ ๋ชฉ ์๋ ์์ฑ | ์ฒซ ๋ฉ์์ง๋ก ์ ๋ชฉ ์์ฑ | 1์๊ฐ |
| 3 | ์น ๊ฒ์ ๊ฐ์ | Exa API๋ก ์ ํ | 2์๊ฐ |
| 4 | ๋น์ฉ ๊ณ์ฐ | models.dev ์ฐ๋ | 2-3์๊ฐ |
๐ก ์ค๊ฐ ๋์ด๋
| ์์ | ๊ธฐ๋ฅ | ์ค๋ช | ์์ ์์ ๋ |
|---|---|---|---|
| 5 | ์ธ์ ์์ถ (Compaction) | ์ปจํ ์คํธ ๊ด๋ฆฌ | 4-6์๊ฐ |
| 6 | ์ธ์ ํฌํฌ | ๋ํ ๋ถ๊ธฐ | 2-3์๊ฐ |
| 7 | Read ๋๊ตฌ | ํ์ผ ์ฝ๊ธฐ (Storage) | 3-4์๊ฐ |
| 8 | Glob/Grep ๋๊ตฌ | ํ์ผ ๊ฒ์ | 4-5์๊ฐ |
๐ด ๊ณ ๋์ด๋ (์ค๊ณ ๋ณ๊ฒฝ ํ์)
| ์์ | ๊ธฐ๋ฅ | ์ค๋ช | ์์ ์์ ๋ |
|---|---|---|---|
| 9 | Edit/Write ๋๊ตฌ | ํ์ผ ์์ (์๋๋ฐ์ค) | 1-2์ผ |
| 10 | Bash ๋๊ตฌ | ์ฝ๋ ์คํ (๋ณด์) | 1-2์ผ |
| 11 | MCP ํตํฉ | ์ธ๋ถ ์๋ฒ ์ฐ๊ฒฐ | 2-3์ผ |
| 12 | Snapshot/Revert | ๋๋๋ฆฌ๊ธฐ | 1-2์ผ |
โ ๊ต์ก ํ๋ซํผ์ ๋ถ์ ํฉ
- CLI/TUI ์ธํฐํ์ด์ค
- ๋ก์ปฌ ํ์ผ ์์คํ ์ง์ ์ ๊ทผ
- PTY (ํฐ๋ฏธ๋) ๊ธฐ๋ฅ
- Git Worktree ๊ด๋ฆฌ
๊ตฌํ ์ฒดํฌ๋ฆฌ์คํธ
Phase 1: ๊ธฐ๋ณธ ๊ฐ์
- ์ถ๊ฐ LLM ํ๋ก๋ฐ์ด๋ (LiteLLM ํ์ฅ)
- ์ธ์ ์ ๋ชฉ ์๋ ์์ฑ
- ์น ๊ฒ์ ๊ฐ์ (Exa API)
- ๋น์ฉ ๊ณ์ฐ (models.dev)
Phase 2: ์ธ์ ๊ณ ๊ธ ๊ธฐ๋ฅ
- ์ธ์ ์์ถ (Compaction)
- ์ธ์ ํฌํฌ
- ์ธ์ ์ํ ๊ด๋ฆฌ
Phase 3: ๋๊ตฌ ํ์ฅ
- Read ๋๊ตฌ
- Glob ๋๊ตฌ
- Grep ๋๊ตฌ
- Ls ๋๊ตฌ
Phase 4: ๊ณ ๊ธ ๊ธฐ๋ฅ (์ ํ์ )
- Edit/Write ๋๊ตฌ (์๋๋ฐ์ค ํ๊ฒฝ)
- Bash ๋๊ตฌ (์ฝ๋ ์ธํฐํ๋ฆฌํฐ)
- MCP ๊ธฐ๋ณธ ์ง์
- Task ๋๊ตฌ (์๋ธ์์ด์ ํธ)
์ฐธ๊ณ ์๋ฃ
์๋ณธ OpenCode ์ฃผ์ ํ์ผ
- Session:
/packages/opencode/src/session/ - Provider:
/packages/opencode/src/provider/ - Tool:
/packages/opencode/src/tool/ - Server:
/packages/opencode/src/server/
Python API ์ฃผ์ ํ์ผ
- Session:
/opencode-api/src/opencode_api/session/ - Provider:
/opencode-api/src/opencode_api/provider/ - Tool:
/opencode-api/src/opencode_api/tool/ - Routes:
/opencode-api/src/opencode_api/routes/