opencode / packages /web /src /content /docs /ko /commands.mdx
SaylorTwift's picture
SaylorTwift HF Staff
Add files using upload-large-folder tool
0dbc9de verified
Raw
History Blame Contribute Delete
7.14 kB
---
title: ๋ช…๋ น์–ด
description: ๋ฐ˜๋ณต์ ์ธ ์ž‘์—…์„ ์œ„ํ•œ ์ปค์Šคํ…€ ๋ช…๋ น์„ ๋งŒ๋“œ์„ธ์š”.
---
์ปค์Šคํ…€ ๋ช…๋ น์„ ์‚ฌ์šฉํ•˜๋ฉด TUI์—์„œ ํ•ด๋‹น ๋ช…๋ น์ด ์‹คํ–‰๋  ๋•Œ ์‚ฌ์šฉํ•  ํ”„๋กฌํ”„ํŠธ๋ฅผ ๋ฏธ๋ฆฌ ์ •์˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
```bash frame="none"
/my-command
```
---
์ปค์Šคํ…€ ๋ช…๋ น์€ `/init`, `/undo`, `/redo`, `/share`, `/help` ๊ฐ™์€ ๋‚ด์žฅ ๋ช…๋ น๊ณผ ๋ณ„๋„๋กœ ์ถ”๊ฐ€๋ฉ๋‹ˆ๋‹ค. [๋” ์•Œ์•„๋ณด๊ธฐ](/docs/tui#commands).
---
## ๋ช…๋ น ํŒŒ์ผ ๋งŒ๋“ค๊ธฐ
์ปค์Šคํ…€ ๋ช…๋ น์€ `commands/` ๋””๋ ‰ํ„ฐ๋ฆฌ์— Markdown ํŒŒ์ผ์„ ๋งŒ๋“ค์–ด ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.
์˜ˆ: `.opencode/commands/test.md`
```md title=".opencode/commands/test.md"
---
description: Run tests with coverage
agent: build
model: anthropic/claude-3-5-sonnet-20241022
---
Run the full test suite with coverage report and show any failures.
Focus on the failing tests and suggest fixes.
```
ํ”„๋ŸฐํŠธ๋งคํ„ฐ(frontmatter)์—๋Š” ๋ช…๋ น ์†์„ฑ์„ ์ •์˜ํ•˜๊ณ , ๋ณธ๋ฌธ์€ ํ…œํ”Œ๋ฆฟ ํ”„๋กฌํ”„ํŠธ๊ฐ€ ๋ฉ๋‹ˆ๋‹ค.
๋ช…๋ น ์ด๋ฆ„ ์•ž์— `/`๋ฅผ ๋ถ™์—ฌ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
```bash frame="none"
"/test"
```
---
## ๊ตฌ์„ฑ
์ปค์Šคํ…€ ๋ช…๋ น์€ OpenCode ์„ค์ •์œผ๋กœ ์ถ”๊ฐ€ํ•˜๊ฑฐ๋‚˜, `commands/` ๋””๋ ‰ํ„ฐ๋ฆฌ์— Markdown ํŒŒ์ผ์„ ๋งŒ๋“ค์–ด ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
---
### JSON
OpenCode [config](/docs/config)์˜ `command` ์˜ต์…˜์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
```json title="opencode.jsonc" {4-12}
{
"$schema": "https://opencode.ai/config.json",
"command": {
// This becomes the name of the command
"test": {
// This is the prompt that will be sent to the LLM
"template": "Run the full test suite with coverage report and show any failures.\nFocus on the failing tests and suggest fixes.",
// This is shown as the description in the TUI
"description": "Run tests with coverage",
"agent": "build",
"model": "anthropic/claude-3-5-sonnet-20241022"
}
}
}
```
์ด์ œ TUI์—์„œ ๋‹ค์Œ์ฒ˜๋Ÿผ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
```bash frame="none"
/test
```
---
### Markdown
Markdown ํŒŒ์ผ๋กœ๋„ ๋ช…๋ น์„ ์ •์˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์•„๋ž˜ ๊ฒฝ๋กœ ์ค‘ ํ•˜๋‚˜์— ๋‘๋ฉด ๋ฉ๋‹ˆ๋‹ค.
- ์ „์—ญ: `~/.config/opencode/commands/`
- ํ”„๋กœ์ ํŠธ๋ณ„: `.opencode/commands/`
```markdown title="~/.config/opencode/commands/test.md"
---
description: Run tests with coverage
agent: build
model: anthropic/claude-3-5-sonnet-20241022
---
Run the full test suite with coverage report and show any failures.
Focus on the failing tests and suggest fixes.
```
Markdown ํŒŒ์ผ๋ช…์ด ๋ช…๋ น ์ด๋ฆ„์ด ๋ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด `test.md`๋ผ๋ฉด ์•„๋ž˜์ฒ˜๋Ÿผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
```bash frame="none"
/test
```
---
## ํ”„๋กฌํ”„ํŠธ ๊ตฌ์„ฑ
์ปค์Šคํ…€ ๋ช…๋ น ํ”„๋กฌํ”„ํŠธ๋Š” ๋ช‡ ๊ฐ€์ง€ ํŠน์ˆ˜ ํ”Œ๋ ˆ์ด์Šคํ™€๋”(placeholder)์™€ ๋ฌธ๋ฒ•์„ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค.
---
### ์ธ์ˆ˜
`$ARGUMENTS` ํ”Œ๋ ˆ์ด์Šคํ™€๋”๋กœ ๋ช…๋ น ์ธ์ˆ˜๋ฅผ ์ „๋‹ฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
```md title=".opencode/commands/component.md"
---
description: Create a new component
---
Create a new React component named $ARGUMENTS with TypeScript support.
Include proper typing and basic structure.
```
์ธ์ˆ˜๋ฅผ ๋„ฃ์–ด ์‹คํ–‰ํ•˜๋ฉด:
```bash frame="none"
/component Button
```
`$ARGUMENTS`๊ฐ€ `Button`์œผ๋กœ ์น˜ํ™˜๋ฉ๋‹ˆ๋‹ค.
์œ„์น˜ ์ธ์ˆ˜๋„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
- `$1` - ์ฒซ ๋ฒˆ์งธ ์ธ์ˆ˜
- `$2` - ๋‘ ๋ฒˆ์งธ ์ธ์ˆ˜
- `$3` - ์„ธ ๋ฒˆ์งธ ์ธ์ˆ˜
- ์ดํ›„ ๋™์ผ
์˜ˆ์‹œ:
```md title=".opencode/commands/create-file.md"
---
description: Create a new file with content
---
Create a file named $1 in the directory $2
with the following content: $3
```
์‹คํ–‰:
```bash frame="none"
/create-file config.json src "{ \"key\": \"value\" }"
```
์น˜ํ™˜ ๊ฒฐ๊ณผ:
- `$1` -> `config.json`
- `$2` -> `src`
- `$3` -> `{ "key": "value" }`
---
### ์…ธ ์ถœ๋ ฅ
_!`command`_ ๋ฌธ๋ฒ•์œผ๋กœ [bash ๋ช…๋ น](/docs/tui#bash-commands)์˜ ์ถœ๋ ฅ ๊ฒฐ๊ณผ๋ฅผ ํ”„๋กฌํ”„ํŠธ์— ์ฃผ์ž…ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
์˜ˆ๋ฅผ ๋“ค์–ด ํ…Œ์ŠคํŠธ ์ปค๋ฒ„๋ฆฌ์ง€ ๋ถ„์„ ๋ช…๋ น์„ ๋งŒ๋“ค๋ฉด:
```md title=".opencode/commands/analyze-coverage.md"
---
description: Analyze test coverage
---
Here are the current test results:
!`npm test`
Based on these results, suggest improvements to increase coverage.
```
์ตœ๊ทผ ๋ณ€๊ฒฝ ๋ฆฌ๋ทฐ์šฉ์œผ๋กœ๋Š”:
```md title=".opencode/commands/review-changes.md"
---
description: Review recent changes
---
Recent git commits:
!`git log --oneline -10`
Review these changes and suggest any improvements.
```
๋ช…๋ น์€ ํ”„๋กœ์ ํŠธ ๋ฃจํŠธ ๋””๋ ‰ํ„ฐ๋ฆฌ์—์„œ ์‹คํ–‰๋˜๋ฉฐ, ์ถœ๋ ฅ ๊ฒฐ๊ณผ๋Š” ํ”„๋กฌํ”„ํŠธ ๋ณธ๋ฌธ์— ํฌํ•จ๋ฉ๋‹ˆ๋‹ค.
---
### ํŒŒ์ผ ์ฐธ์กฐ
`@` ๋’ค์— ํŒŒ์ผ๋ช…์„ ๋ถ™์—ฌ ๋ช…๋ น์— ํŒŒ์ผ์„ ํฌํ•จํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
```md title=".opencode/commands/review-component.md"
---
description: Review component
---
Review the component in @src/components/Button.tsx.
Check for performance issues and suggest improvements.
```
ํŒŒ์ผ ๋‚ด์šฉ์€ ์ž๋™์œผ๋กœ ํ”„๋กฌํ”„ํŠธ์— ํฌํ•จ๋ฉ๋‹ˆ๋‹ค.
---
## ์˜ต์…˜
๊ตฌ์„ฑ ์˜ต์…˜์„ ์ž์„ธํžˆ ์‚ดํŽด๋ด…๋‹ˆ๋‹ค.
---
### ํ…œํ”Œ๋ฆฟ
`template` ์˜ต์…˜์€ ๋ช…๋ น ์‹คํ–‰ ์‹œ LLM์— ์ „๋‹ฌํ•  ํ”„๋กฌํ”„ํŠธ๋ฅผ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.
```json title="opencode.json"
{
"command": {
"test": {
"template": "Run the full test suite with coverage report and show any failures.\nFocus on the failing tests and suggest fixes."
}
}
}
```
์ด ์˜ต์…˜์€ **ํ•„์ˆ˜**์ž…๋‹ˆ๋‹ค.
---
### ์„ค๋ช…
`description` ์˜ต์…˜์œผ๋กœ ๋ช…๋ น์˜ ์งง์€ ์„ค๋ช…์„ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
```json title="opencode.json"
{
"command": {
"test": {
"description": "Run tests with coverage"
}
}
}
```
์ด ์„ค๋ช…์€ TUI์—์„œ ๋ช…๋ น์„ ์ž…๋ ฅํ•  ๋•Œ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.
---
### ์—์ด์ „ํŠธ
`agent` ์„ค์ •์œผ๋กœ ์ด ๋ช…๋ น์„ ์‹คํ–‰ํ•  [agent](/docs/agents)๋ฅผ ์ง€์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
์ง€์ •ํ•œ ๊ฐ’์ด [subagent](/docs/agents/#subagents)๋ฉด ๊ธฐ๋ณธ์ ์œผ๋กœ subagent ํ˜ธ์ถœ์ด ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค.
์ด ๋™์ž‘์„ ๋„๋ ค๋ฉด `subtask`๋ฅผ `false`๋กœ ์„ค์ •ํ•˜์„ธ์š”.
```json title="opencode.json"
{
"command": {
"review": {
"agent": "plan"
}
}
}
```
์ด ์˜ต์…˜์€ **์„ ํƒ**์ž…๋‹ˆ๋‹ค. ์ง€์ •ํ•˜์ง€ ์•Š์œผ๋ฉด ํ˜„์žฌ ์—์ด์ „ํŠธ๊ฐ€ ๊ธฐ๋ณธ๊ฐ’์œผ๋กœ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.
---
### ์„œ๋ธŒํƒœ์Šคํฌ
`subtask` ๋ถˆ๋ฆฌ์–ธ(boolean)์„ ์‚ฌ์šฉํ•˜๋ฉด ๋ช…๋ น์ด [subagent](/docs/agents/#subagents) ํ˜ธ์ถœ์„ ๊ฐ•์ œ๋กœ ํŠธ๋ฆฌ๊ฑฐํ•ฉ๋‹ˆ๋‹ค.
์ฃผ ์ปจํ…์ŠคํŠธ๋ฅผ ์˜ค์—ผ์‹œํ‚ค๊ณ  ์‹ถ์ง€ ์•Š์„ ๋•Œ ์œ ์šฉํ•˜๋ฉฐ, [agent](/docs/agents) ์„ค์ •์˜ `mode`๊ฐ€ `primary`์—ฌ๋„ subagent๋กœ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
```json title="opencode.json"
{
"command": {
"analyze": {
"subtask": true
}
}
}
```
์ด ์˜ต์…˜์€ **์„ ํƒ**์ž…๋‹ˆ๋‹ค.
---
### ๋ชจ๋ธ
`model` ์„ค์ •์œผ๋กœ ์ด ๋ช…๋ น์˜ ๊ธฐ๋ณธ ๋ชจ๋ธ์„ ์˜ค๋ฒ„๋ผ์ด๋“œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
```json title="opencode.json"
{
"command": {
"analyze": {
"model": "anthropic/claude-3-5-sonnet-20241022"
}
}
}
```
์ด ์˜ต์…˜์€ **์„ ํƒ**์ž…๋‹ˆ๋‹ค.
---
## ๋‚ด์žฅ ๋ช…๋ น
OpenCode๋Š” `/init`, `/undo`, `/redo`, `/share`, `/help` ๋“ฑ ์—ฌ๋Ÿฌ ๋‚ด์žฅ ๋ช…๋ น์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. [๋” ์•Œ์•„๋ณด๊ธฐ](/docs/tui#commands).
:::note
์ปค์Šคํ…€ ๋ช…๋ น์€ ๋‚ด์žฅ ๋ช…๋ น์„ ๋ฎ์–ด์“ธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
:::
๊ฐ™์€ ์ด๋ฆ„์œผ๋กœ ์ปค์Šคํ…€ ๋ช…๋ น์„ ์ •์˜ํ•˜๋ฉด ๋‚ด์žฅ ๋ช…๋ น๋ณด๋‹ค ์ปค์Šคํ…€ ๋ช…๋ น์ด ์šฐ์„ ํ•ฉ๋‹ˆ๋‹ค.