mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-06 08:21:50 +00:00
docs: remove deprecated modes.mdx pages (#25227)
This commit is contained in:
parent
3615d8e226
commit
c68c33d4fe
18 changed files with 0 additions and 5890 deletions
|
|
@ -1,329 +0,0 @@
|
|||
---
|
||||
title: الأوضاع
|
||||
description: أوضاع مختلفة لحالات استخدام مختلفة.
|
||||
---
|
||||
|
||||
:::caution
|
||||
يتم الآن ضبط الأوضاع عبر خيار `agent` في إعدادات opencode. أصبح خيار
|
||||
`mode` مُهمَلًا الآن. [اعرف المزيد](/docs/agents).
|
||||
:::
|
||||
|
||||
تتيح لك الأوضاع في opencode تخصيص السلوك والأدوات والمطالبات لحالات استخدام مختلفة.
|
||||
|
||||
يأتي مع وضعين مدمجين: **build** و **plan**. يمكنك تخصيصهما أو إعداد
|
||||
أوضاعك الخاصة عبر إعدادات opencode.
|
||||
|
||||
يمكنك التبديل بين الأوضاع أثناء الجلسة أو إعدادها في ملف الإعدادات لديك.
|
||||
|
||||
---
|
||||
|
||||
## الأوضاع المدمجة
|
||||
|
||||
يأتي opencode مع وضعين مدمجين.
|
||||
|
||||
---
|
||||
|
||||
### Build
|
||||
|
||||
وضع Build هو الوضع **الافتراضي** مع تفعيل جميع الأدوات. هذا هو الوضع القياسي لأعمال التطوير عندما تحتاج إلى وصول كامل لعمليات الملفات وأوامر النظام.
|
||||
|
||||
---
|
||||
|
||||
### Plan
|
||||
|
||||
وضع مقيَّد مُصمَّم للتخطيط والتحليل. في وضع plan، تكون الأدوات التالية مُعطَّلة افتراضيًا:
|
||||
|
||||
- `write` - لا يمكن إنشاء ملفات جديدة
|
||||
- `edit` - لا يمكن تعديل الملفات الموجودة، باستثناء الملفات الموجودة في `.opencode/plans/*.md` لتفصيل الخطة نفسها
|
||||
- `patch` - لا يمكن تطبيق التصحيحات
|
||||
- `bash` - لا يمكن تنفيذ أوامر shell
|
||||
|
||||
يكون هذا الوضع مفيدًا عندما تريد من الذكاء الاصطناعي تحليل الشيفرة، أو اقتراح تغييرات، أو إنشاء خطط دون إجراء أي تعديلات فعلية على قاعدة الشيفرة لديك.
|
||||
|
||||
---
|
||||
|
||||
## التبديل
|
||||
|
||||
يمكنك التبديل بين الأوضاع أثناء الجلسة باستخدام مفتاح _Tab_، أو اختصار `switch_mode` الذي قمت بإعداده.
|
||||
|
||||
انظر أيضًا: [Formatters](/docs/formatters) لمعلومات حول إعدادات تنسيق الشيفرة.
|
||||
|
||||
---
|
||||
|
||||
## الإعداد
|
||||
|
||||
يمكنك تخصيص الأوضاع المدمجة أو إنشاء أوضاعك الخاصة عبر الإعدادات. يمكن إعداد الأوضاع بطريقتين:
|
||||
|
||||
### إعدادات JSON
|
||||
|
||||
قم بإعداد الأوضاع في ملف الإعدادات `opencode.json` لديك:
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"build": {
|
||||
"model": "anthropic/claude-sonnet-4-20250514",
|
||||
"prompt": "{file:./prompts/build.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": true
|
||||
}
|
||||
},
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514",
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### إعدادات Markdown
|
||||
|
||||
يمكنك أيضًا تعريف الأوضاع باستخدام ملفات markdown. ضعها في:
|
||||
|
||||
- عالمي: `~/.config/opencode/modes/`
|
||||
- للمشروع: `.opencode/modes/`
|
||||
|
||||
```markdown title="~/.config/opencode/modes/review.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.1
|
||||
tools:
|
||||
write: false
|
||||
edit: false
|
||||
bash: false
|
||||
---
|
||||
|
||||
You are in code review mode. Focus on:
|
||||
|
||||
- Code quality and best practices
|
||||
- Potential bugs and edge cases
|
||||
- Performance implications
|
||||
- Security considerations
|
||||
|
||||
Provide constructive feedback without making direct changes.
|
||||
```
|
||||
|
||||
يصبح اسم ملف markdown هو اسم الوضع (على سبيل المثال، `review.md` ينشئ وضعًا باسم `review`).
|
||||
|
||||
لنلقِ نظرة على خيارات الإعداد هذه بمزيد من التفصيل.
|
||||
|
||||
---
|
||||
|
||||
### النموذج
|
||||
|
||||
استخدم إعداد `model` لتجاوز النموذج الافتراضي لهذا الوضع. يفيد ذلك عند استخدام نماذج مختلفة مُحسَّنة لمهام مختلفة؛ مثل نموذج أسرع للتخطيط ونموذج أكثر قدرة للتنفيذ.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### درجة الحرارة
|
||||
|
||||
تحكَّم في العشوائية والإبداع في ردود الذكاء الاصطناعي عبر إعداد `temperature`. القيم الأقل تجعل الردود أكثر تركيزًا وحتمية، بينما تزيد القيم الأعلى الإبداع والتنوّع.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"temperature": 0.1
|
||||
},
|
||||
"creative": {
|
||||
"temperature": 0.8
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
تتراوح قيم درجة الحرارة عادةً بين 0.0 و 1.0:
|
||||
|
||||
- **0.0-0.2**: ردود شديدة التركيز وحتمية، مثالية لتحليل الشيفرة والتخطيط
|
||||
- **0.3-0.5**: ردود متوازنة مع قدر من الإبداع، مناسبة لمهام التطوير العامة
|
||||
- **0.6-1.0**: ردود أكثر إبداعًا وتنوّعًا، مفيدة للعصف الذهني والاستكشاف
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"analyze": {
|
||||
"temperature": 0.1,
|
||||
"prompt": "{file:./prompts/analysis.txt}"
|
||||
},
|
||||
"build": {
|
||||
"temperature": 0.3
|
||||
},
|
||||
"brainstorm": {
|
||||
"temperature": 0.7,
|
||||
"prompt": "{file:./prompts/creative.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
إذا لم يتم تحديد درجة الحرارة، يستخدم opencode القيم الافتراضية الخاصة بكل نموذج (عادةً 0 لمعظم النماذج و 0.55 لنماذج Qwen).
|
||||
|
||||
---
|
||||
|
||||
### الموجّه
|
||||
|
||||
حدِّد ملف موجّه نظام (system prompt) مخصص لهذا الوضع عبر إعداد `prompt`. ينبغي أن يحتوي ملف الموجّه على تعليمات مرتبطة بهدف هذا الوضع.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"review": {
|
||||
"prompt": "{file:./prompts/code-review.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
هذا المسار نسبي بالنسبة لموقع ملف الإعدادات. لذلك يعمل مع
|
||||
إعدادات opencode العالمية وكذلك إعدادات المشروع.
|
||||
|
||||
---
|
||||
|
||||
### الأدوات
|
||||
|
||||
تحكَّم في الأدوات المتاحة في هذا الوضع عبر إعداد `tools`. يمكنك تفعيل أدوات محددة أو تعطيلها بضبطها على `true` أو `false`.
|
||||
|
||||
```json
|
||||
{
|
||||
"mode": {
|
||||
"readonly": {
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
إذا لم يتم تحديد أدوات، فستكون جميع الأدوات مفعّلة افتراضيًا.
|
||||
|
||||
---
|
||||
|
||||
#### الأدوات المتاحة
|
||||
|
||||
فيما يلي جميع الأدوات التي يمكن التحكم بها عبر إعدادات الوضع.
|
||||
|
||||
| الأداة | الوصف |
|
||||
| ----------- | -------------------------- |
|
||||
| `bash` | تنفيذ أوامر shell |
|
||||
| `edit` | تعديل الملفات الموجودة |
|
||||
| `write` | إنشاء ملفات جديدة |
|
||||
| `read` | قراءة محتويات الملفات |
|
||||
| `grep` | البحث في محتويات الملفات |
|
||||
| `glob` | العثور على الملفات حسب نمط |
|
||||
| `patch` | تطبيق تصحيحات على الملفات |
|
||||
| `todowrite` | إدارة قوائم المهام |
|
||||
| `webfetch` | جلب محتوى الويب |
|
||||
|
||||
---
|
||||
|
||||
## أوضاع مخصصة
|
||||
|
||||
يمكنك إنشاء أوضاعك المخصصة بإضافتها إلى الإعدادات. فيما يلي أمثلة باستخدام كلا الأسلوبين:
|
||||
|
||||
### باستخدام إعدادات JSON
|
||||
|
||||
```json title="opencode.json" {4-14}
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"docs": {
|
||||
"prompt": "{file:./prompts/documentation.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### باستخدام ملفات markdown
|
||||
|
||||
أنشئ ملفات الأوضاع في `.opencode/modes/` لأوضاع خاصة بالمشروع أو في `~/.config/opencode/modes/` لأوضاع عالمية:
|
||||
|
||||
```markdown title=".opencode/modes/debug.md"
|
||||
---
|
||||
temperature: 0.1
|
||||
tools:
|
||||
bash: true
|
||||
read: true
|
||||
grep: true
|
||||
write: false
|
||||
edit: false
|
||||
---
|
||||
|
||||
You are in debug mode. Your primary goal is to help investigate and diagnose issues.
|
||||
|
||||
Focus on:
|
||||
|
||||
- Understanding the problem through careful analysis
|
||||
- Using bash commands to inspect system state
|
||||
- Reading relevant files and logs
|
||||
- Searching for patterns and anomalies
|
||||
- Providing clear explanations of findings
|
||||
|
||||
Do not make any changes to files. Only investigate and report.
|
||||
```
|
||||
|
||||
```markdown title="~/.config/opencode/modes/refactor.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.2
|
||||
tools:
|
||||
edit: true
|
||||
read: true
|
||||
grep: true
|
||||
glob: true
|
||||
---
|
||||
|
||||
You are in refactoring mode. Focus on improving code quality without changing functionality.
|
||||
|
||||
Priorities:
|
||||
|
||||
- Improve code readability and maintainability
|
||||
- Apply consistent naming conventions
|
||||
- Reduce code duplication
|
||||
- Optimize performance where appropriate
|
||||
- Ensure all tests continue to pass
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### حالات الاستخدام
|
||||
|
||||
فيما يلي بعض حالات الاستخدام الشائعة لأوضاع مختلفة.
|
||||
|
||||
- **Build mode**: أعمال تطوير كاملة مع تفعيل جميع الأدوات
|
||||
- **Plan mode**: التحليل والتخطيط دون إجراء تغييرات
|
||||
- **Review mode**: مراجعة الشيفرة مع وصول للقراءة فقط بالإضافة إلى أدوات التوثيق
|
||||
- **Debug mode**: تركيز على الاستقصاء مع تفعيل أدوات `bash` و `read`
|
||||
- **Docs mode**: كتابة التوثيق مع عمليات الملفات لكن دون أوامر النظام
|
||||
|
||||
قد تجد أيضًا أن نماذج مختلفة تكون أنسب لحالات استخدام مختلفة.
|
||||
|
|
@ -1,314 +0,0 @@
|
|||
---
|
||||
title: Načini rada
|
||||
description: Različiti načini za različite slučajeve upotrebe.
|
||||
---
|
||||
|
||||
:::caution
|
||||
Načini se sada konfiguriraju preko opcije `agent` u konfiguraciji otvorenog koda. The
|
||||
`mode` opcija je sada zastarjela. [Saznajte više](/docs/agents).
|
||||
:::
|
||||
|
||||
Režimi u otvorenom kodu omogućavaju vam da prilagodite ponašanje, alate i upite za različite slučajeve upotrebe.
|
||||
Dolazi sa dva ugrađena načina rada: **build** i **plan**. Možete prilagoditi
|
||||
ove ili konfigurirajte svoje putem opencode config.
|
||||
Možete se prebacivati između režima tokom sesije ili ih konfigurisati u svom konfiguracionom fajlu.
|
||||
|
||||
---
|
||||
|
||||
## Ugrađeni
|
||||
|
||||
opencode dolazi sa dva ugrađena načina rada.
|
||||
|
||||
### Build
|
||||
|
||||
Build je **podrazumijevani** režim sa svim omogućenim alatima. Ovo je standardni način rada za razvoj kada vam treba pun pristup fajlovima i sistemskim komandama.
|
||||
|
||||
### Plan
|
||||
|
||||
Ograničeni način rada dizajniran za planiranje i analizu. U načinu plana, sljedeći alati su onemogućeni prema zadanim postavkama:
|
||||
|
||||
- `write` - Ne mogu kreirati nove fajlove
|
||||
- `edit` - Ne mogu modificirati postojeće fajlove, osim fajlova koji se nalaze na `.opencode/plans/*.md` radi detaljiziranja samog plana
|
||||
- `patch` - Ne mogu primijeniti zakrpe
|
||||
- `bash` - Ne mogu izvršiti naredbe ljuske
|
||||
Ovaj način rada je koristan kada želite da AI analizira kod, predlaže promjene ili kreira planove bez ikakvih stvarnih modifikacija u vašoj bazi kodova.
|
||||
|
||||
---
|
||||
|
||||
## Prebacivanje
|
||||
|
||||
Možete se prebacivati između načina rada tokom sesije pomoću tipke _Tab_. Ili vaše konfigurirano `switch_mode` spajanje tipki.
|
||||
Vidi također: [Formatters](/docs/formatters) za informacije o konfiguraciji formatiranja koda.
|
||||
|
||||
---
|
||||
|
||||
## Konfiguracija
|
||||
|
||||
Možete prilagoditi ugrađene načine rada ili kreirati vlastite kroz konfiguraciju. Modovi se mogu konfigurirati na dva načina:
|
||||
|
||||
### JSON konfiguracija
|
||||
|
||||
Konfigurirajte načine rada u svom `opencode.json` konfiguracijskom fajlu:
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"build": {
|
||||
"model": "anthropic/claude-sonnet-4-20250514",
|
||||
"prompt": "{file:./prompts/build.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": true
|
||||
}
|
||||
},
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514",
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Markdown konfiguracija
|
||||
|
||||
Također možete definirati načine rada koristeći markdown datoteke. Postavite ih u:
|
||||
|
||||
- Globalno: `~/.config/opencode/modes/`
|
||||
- Projekat: `.opencode/modes/`
|
||||
|
||||
```markdown title="~/.config/opencode/modes/review.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.1
|
||||
tools:
|
||||
write: false
|
||||
edit: false
|
||||
bash: false
|
||||
---
|
||||
|
||||
You are in code review mode. Focus on:
|
||||
|
||||
- Code quality and best practices
|
||||
- Potential bugs and edge cases
|
||||
- Performance implications
|
||||
- Security considerations
|
||||
|
||||
Provide constructive feedback without making direct changes.
|
||||
```
|
||||
|
||||
Naziv datoteke s uštedom postaje naziv načina (npr. `review.md` kreira `review` način rada).
|
||||
Pogledajmo ove opcije konfiguracije detaljno.
|
||||
|
||||
---
|
||||
|
||||
### Model
|
||||
|
||||
Koristite `model` konfiguraciju da nadjačate zadani model za ovaj način rada. Korisno za korištenje različitih modela optimiziranih za različite zadatke. Na primjer, brži model za planiranje, sposobniji model za implementaciju.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Temperatura
|
||||
|
||||
Kontrolišite slučajnost i kreativnost odgovora AI pomoću `temperature` konfiguracije. Niže vrijednosti čine odgovore fokusiranijim i determinističkim, dok veće vrijednosti povećavaju kreativnost i varijabilnost.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"temperature": 0.1
|
||||
},
|
||||
"creative": {
|
||||
"temperature": 0.8
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Vrijednosti temperature obično se kreću od 0,0 do 1,0:
|
||||
|
||||
- **0,0-0,2**: Vrlo fokusirani i deterministički odgovori, idealni za analizu i planiranje koda
|
||||
- **0,3-0,5**: Uravnoteženi odgovori sa malo kreativnosti, dobro za opšte razvojne zadatke
|
||||
- **0,6-1,0**: kreativniji i raznovrsniji odgovori, korisni za razmišljanje i istraživanje
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"analyze": {
|
||||
"temperature": 0.1,
|
||||
"prompt": "{file:./prompts/analysis.txt}"
|
||||
},
|
||||
"build": {
|
||||
"temperature": 0.3
|
||||
},
|
||||
"brainstorm": {
|
||||
"temperature": 0.7,
|
||||
"prompt": "{file:./prompts/creative.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Ako temperatura nije navedena, opencode koristi podrazumijevane postavke specifične za model (obično 0 za većinu modela i 0.55 za Qwen modele).
|
||||
|
||||
### Upit
|
||||
|
||||
Navedite prilagođenu sistemsku datoteku prompta za ovaj način rada s konfiguracijom `prompt`. Datoteka s promptom treba da sadrži upute specifične za svrhu načina rada.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"review": {
|
||||
"prompt": "{file:./prompts/code-review.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Ova putanja je relativna u odnosu na mjesto gdje se nalazi konfiguracijski fajl. Dakle, ovo radi za
|
||||
i globalnu konfiguraciju otvorenog koda i konfiguraciju specifične za projekat.
|
||||
|
||||
---
|
||||
|
||||
### Alati
|
||||
|
||||
Kontrolirajte koji su alati dostupni u ovom načinu rada pomoću `tools` konfiguracije. Možete omogućiti ili onemogućiti određene alate tako što ćete ih postaviti na `true` ili `false`.
|
||||
|
||||
```json
|
||||
{
|
||||
"mode": {
|
||||
"readonly": {
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Ako nijedan alat nije specificiran, svi alati su omogućeni po defaultu.
|
||||
|
||||
#### Dostupni alati
|
||||
|
||||
Ovdje su svi alati koji se mogu kontrolirati kroz konfiguraciju načina rada.
|
||||
| Alat | Opis
|
||||
|----------- | ----------------------- |
|
||||
| `bash` | Izvrši naredbe ljuske |
|
||||
| `edit` | Izmijenite postojeće datoteke |
|
||||
| `write` | Kreirajte nove fajlove |
|
||||
| `read` | Pročitajte sadržaj datoteke |
|
||||
| `grep` | Pretraži sadržaj datoteke |
|
||||
| `glob` | Pronađite datoteke po uzorku |
|
||||
| `patch` | Primijenite zakrpe na datoteke |
|
||||
| `todowrite` | Upravljanje listama zadataka |
|
||||
| `webfetch` | Dohvati web sadržaj |
|
||||
|
||||
---
|
||||
|
||||
## Prilagođeni načini rada
|
||||
|
||||
Možete kreirati vlastite prilagođene modove tako što ćete ih dodati u konfiguraciju. Evo primjera koji koriste oba pristupa:
|
||||
|
||||
### Korištenje JSON konfiguracije
|
||||
|
||||
```json title="opencode.json" {4-14}
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"docs": {
|
||||
"prompt": "{file:./prompts/documentation.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Korištenje markdown fajlova
|
||||
|
||||
Kreirajte fajlove načina u `.opencode/modes/` za specifične načine rada ili `~/.config/opencode/modes/` za globalne načine:
|
||||
|
||||
```markdown title=".opencode/modes/debug.md"
|
||||
---
|
||||
temperature: 0.1
|
||||
tools:
|
||||
bash: true
|
||||
read: true
|
||||
grep: true
|
||||
write: false
|
||||
edit: false
|
||||
---
|
||||
|
||||
You are in debug mode. Your primary goal is to help investigate and diagnose issues.
|
||||
|
||||
Focus on:
|
||||
|
||||
- Understanding the problem through careful analysis
|
||||
- Using bash commands to inspect system state
|
||||
- Reading relevant files and logs
|
||||
- Searching for patterns and anomalies
|
||||
- Providing clear explanations of findings
|
||||
|
||||
Do not make any changes to files. Only investigate and report.
|
||||
```
|
||||
|
||||
```markdown title="~/.config/opencode/modes/refactor.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.2
|
||||
tools:
|
||||
edit: true
|
||||
read: true
|
||||
grep: true
|
||||
glob: true
|
||||
---
|
||||
|
||||
You are in refactoring mode. Focus on improving code quality without changing functionality.
|
||||
|
||||
Priorities:
|
||||
|
||||
- Improve code readability and maintainability
|
||||
- Apply consistent naming conventions
|
||||
- Reduce code duplication
|
||||
- Optimize performance where appropriate
|
||||
- Ensure all tests continue to pass
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Slučajevi upotrebe
|
||||
|
||||
Evo nekoliko uobičajenih slučajeva upotrebe za različite načine rada.
|
||||
|
||||
- **Build mode**: Potpuni razvojni rad sa svim omogućenim alatima
|
||||
- **Plan mode**: Analiza i planiranje bez izmjena
|
||||
- **Review mode**: Pregled koda sa pristupom samo za čitanje plus alati za dokumentaciju
|
||||
- **Debug mode**: Fokusiran na istragu sa omogućenim bash i alatima za čitanje
|
||||
- **Docs mode**: Pisanje dokumentacije sa operacijama datoteka, ali bez sistemskih naredbi
|
||||
Možda ćete također otkriti da su različiti modeli dobri za različite slučajeve upotrebe.
|
||||
|
|
@ -1,329 +0,0 @@
|
|||
---
|
||||
title: Tilstande
|
||||
description: Forskellige tilstande til forskellige anvendelsestilfælde.
|
||||
---
|
||||
|
||||
:::caution
|
||||
Tilstande er nu konfigureret gennem indstillingen `agent` i opencode-konfigurationen. De
|
||||
`mode` mulighed er nu forældet. [Learn more](/docs/agents).
|
||||
:::
|
||||
|
||||
Tilstande i opencode giver dig mulighed for at tilpasse adfærd, værktøjer og prompter til forskellige brugstilfælde.
|
||||
|
||||
Den kommer med to indbyggede tilstande: **build** og **plan**. Du kan tilpasse
|
||||
disse eller konfigurer dine egne gennem opencode-konfigurationen.
|
||||
|
||||
Du kan skifte mellem tilstande under en session eller konfigurere dem i din konfigurationsfil.
|
||||
|
||||
---
|
||||
|
||||
## Indbyggede
|
||||
|
||||
opencode leveres med to indbyggede tilstande.
|
||||
|
||||
---
|
||||
|
||||
### Byg
|
||||
|
||||
Byg er **standard**-tilstanden med alle værktøjer aktiveret. Dette er standardtilstanden for udviklingsarbejde, hvor du har brug for fuld adgang til filhandlinger og systemkommandoer.
|
||||
|
||||
---
|
||||
|
||||
### Plan
|
||||
|
||||
En begrænset tilstand designet til planlægning og analyse. I plantilstand er følgende værktøjer deaktiveret som standard:
|
||||
|
||||
- `write` - Kan ikke oprette nye filer
|
||||
- `edit` - Kan ikke ændre eksisterende filer, undtagen filer placeret på `.opencode/plans/*.md` for at detaljere selve planen
|
||||
- `patch` - Kan ikke anvende patches
|
||||
- `bash` - Kan ikke udføre shell-kommandoer
|
||||
|
||||
Denne tilstand er nyttig, når du vil have AI til at analysere kode, foreslå ændringer eller oprette planer uden at foretage egentlige ændringer af din kodebase.
|
||||
|
||||
---
|
||||
|
||||
## Skift
|
||||
|
||||
Du kan skifte mellem tilstande under en session ved at bruge _Tab_-tasten. Eller din konfigurerede `switch_mode` nøglebinding.
|
||||
|
||||
Se også: [Formatters](/docs/formatters) for information om konfiguration af kodeformatering.
|
||||
|
||||
---
|
||||
|
||||
## Konfiguration
|
||||
|
||||
Du kan tilpasse de indbyggede tilstande eller oprette dine egne gennem konfiguration. Tilstande kan konfigureres på to måder:
|
||||
|
||||
### JSON-konfiguration
|
||||
|
||||
Konfigurer tilstande i din `opencode.json`-konfigurationsfil:
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"build": {
|
||||
"model": "anthropic/claude-sonnet-4-20250514",
|
||||
"prompt": "{file:./prompts/build.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": true
|
||||
}
|
||||
},
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514",
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Markdown-konfiguration
|
||||
|
||||
Du kan også definere tilstande ved hjælp af markdown-filer. Placer dem i:
|
||||
|
||||
- Globalt: `~/.config/opencode/modes/`
|
||||
- Projekt: `.opencode/modes/`
|
||||
|
||||
```markdown title="~/.config/opencode/modes/review.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.1
|
||||
tools:
|
||||
write: false
|
||||
edit: false
|
||||
bash: false
|
||||
---
|
||||
|
||||
You are in code review mode. Focus on:
|
||||
|
||||
- Code quality and best practices
|
||||
- Potential bugs and edge cases
|
||||
- Performance implications
|
||||
- Security considerations
|
||||
|
||||
Provide constructive feedback without making direct changes.
|
||||
```
|
||||
|
||||
Markdown-filnavnet bliver tilstandsnavnet (f.eks. opretter `review.md` en `review`-tilstand).
|
||||
|
||||
Lad os se nærmere på disse konfigurationsmuligheder.
|
||||
|
||||
---
|
||||
|
||||
### Model
|
||||
|
||||
Brug `model`-konfigurationen til at tilsidesætte standardmodellen for denne tilstand. Nyttigt til brug af forskellige modeller optimeret til forskellige opgaver. For eksempel en hurtigere model til planlægning, en mere dygtig model til implementering.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Temperatur
|
||||
|
||||
Styr tilfældigheden og kreativiteten af AI's svar med `temperature`-konfigurationen. Lavere værdier gør svar mere fokuserede og deterministiske, mens højere værdier øger kreativitet og variabilitet.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"temperature": 0.1
|
||||
},
|
||||
"creative": {
|
||||
"temperature": 0.8
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Temperaturværdier varierer typisk fra 0,0 til 1,0:
|
||||
|
||||
- **0.0-0.2**: Meget fokuserede og deterministiske svar, ideel til kodeanalyse og planlægning
|
||||
- **0,3-0,5**: Afbalancerede svar med en vis kreativitet, god til generelle udviklingsopgaver
|
||||
- **0.6-1.0**: Mere kreative og varierede svar, nyttige til brainstorming og udforskning
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"analyze": {
|
||||
"temperature": 0.1,
|
||||
"prompt": "{file:./prompts/analysis.txt}"
|
||||
},
|
||||
"build": {
|
||||
"temperature": 0.3
|
||||
},
|
||||
"brainstorm": {
|
||||
"temperature": 0.7,
|
||||
"prompt": "{file:./prompts/creative.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Hvis der ikke er angivet nogen temperatur, bruger opencode modelspecifikke standarder (typisk 0 for de fleste modeller, 0,55 for Qwen-modeller).
|
||||
|
||||
---
|
||||
|
||||
### Prompt
|
||||
|
||||
Angiv en brugerdefineret systempromptfil for denne tilstand med `prompt`-konfigurationen. Promptfilen skal indeholde instruktioner, der er specifikke for tilstandens formål.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"review": {
|
||||
"prompt": "{file:./prompts/code-review.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Denne sti er i forhold til, hvor konfigurationsfilen er placeret. Så dette virker for
|
||||
både den globale opencode-konfiguration og den projektspecifikke konfiguration.
|
||||
|
||||
---
|
||||
|
||||
### Værktøjer
|
||||
|
||||
Kontroller, hvilke værktøjer der er tilgængelige i denne tilstand med `tools`-konfigurationen. Du kan aktivere eller deaktivere specifikke værktøjer ved at indstille dem til `true` eller `false`.
|
||||
|
||||
```json
|
||||
{
|
||||
"mode": {
|
||||
"readonly": {
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Hvis der ikke er angivet nogen værktøjer, er alle værktøjer aktiveret som standard.
|
||||
|
||||
---
|
||||
|
||||
#### Tilgængelige værktøjer
|
||||
|
||||
Her er alle de værktøjer, der kan styres gennem tilstandskonfigurationen.
|
||||
|
||||
| Værktøj | Beskrivelse |
|
||||
| ----------- | -------------------------- |
|
||||
| `bash` | Udfør shell-kommandoer |
|
||||
| `edit` | Rediger eksisterende filer |
|
||||
| `write` | Opret nye filer |
|
||||
| `read` | Læs filindhold |
|
||||
| `grep` | Søg filindhold |
|
||||
| `glob` | Find filer efter mønster |
|
||||
| `patch` | Anvend patches til filer |
|
||||
| `todowrite` | Administrer todo-lister |
|
||||
| `webfetch` | Hent webindhold |
|
||||
|
||||
---
|
||||
|
||||
## Brugerdefinerede tilstande
|
||||
|
||||
Du kan oprette dine egne brugerdefinerede tilstande ved at tilføje dem til konfigurationen. Her er eksempler, der bruger begge tilgange:
|
||||
|
||||
### Brug af JSON-konfiguration
|
||||
|
||||
```json title="opencode.json" {4-14}
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"docs": {
|
||||
"prompt": "{file:./prompts/documentation.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Brug af markdown-filer
|
||||
|
||||
Opret tilstandsfiler i `.opencode/modes/` for projektspecifikke tilstande eller `~/.config/opencode/modes/` for globale tilstande:
|
||||
|
||||
```markdown title=".opencode/modes/debug.md"
|
||||
---
|
||||
temperature: 0.1
|
||||
tools:
|
||||
bash: true
|
||||
read: true
|
||||
grep: true
|
||||
write: false
|
||||
edit: false
|
||||
---
|
||||
|
||||
You are in debug mode. Your primary goal is to help investigate and diagnose issues.
|
||||
|
||||
Focus on:
|
||||
|
||||
- Understanding the problem through careful analysis
|
||||
- Using bash commands to inspect system state
|
||||
- Reading relevant files and logs
|
||||
- Searching for patterns and anomalies
|
||||
- Providing clear explanations of findings
|
||||
|
||||
Do not make any changes to files. Only investigate and report.
|
||||
```
|
||||
|
||||
```markdown title="~/.config/opencode/modes/refactor.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.2
|
||||
tools:
|
||||
edit: true
|
||||
read: true
|
||||
grep: true
|
||||
glob: true
|
||||
---
|
||||
|
||||
You are in refactoring mode. Focus on improving code quality without changing functionality.
|
||||
|
||||
Priorities:
|
||||
|
||||
- Improve code readability and maintainability
|
||||
- Apply consistent naming conventions
|
||||
- Reduce code duplication
|
||||
- Optimize performance where appropriate
|
||||
- Ensure all tests continue to pass
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Brugsscenarier
|
||||
|
||||
Her er nogle almindelige brugstilfælde for forskellige tilstande.
|
||||
|
||||
- **Build mode**: Fuldt udviklingsarbejde med alle værktøjer aktiveret
|
||||
- **Plantilstand**: Analyse og planlægning uden at foretage ændringer
|
||||
- **Anmeldelsestilstand**: Kodegennemgang med skrivebeskyttet adgang plus dokumentationsværktøjer
|
||||
- **Fejlretningstilstand**: Fokuseret på undersøgelse med bash og læseværktøjer aktiveret
|
||||
- **Docs-tilstand**: Dokumentationsskrivning med filhandlinger, men ingen systemkommandoer
|
||||
|
||||
Du kan også finde ud af, at forskellige modeller er gode til forskellige brugssituationer.
|
||||
|
|
@ -1,329 +0,0 @@
|
|||
---
|
||||
title: Modi
|
||||
description: Verschiedene Modi für unterschiedliche Anwendungsfälle.
|
||||
---
|
||||
|
||||
:::caution
|
||||
Modi werden jetzt über die Option `agent` in der OpenCode-Konfiguration konfiguriert. Der
|
||||
Die Option `mode` ist jetzt veraltet. [Learn more](/docs/agents).
|
||||
:::
|
||||
|
||||
Mit den Modi in OpenCode können Sie das Verhalten, die Tools und die Eingabeaufforderungen für verschiedene Anwendungsfälle anpassen.
|
||||
|
||||
Es verfügt über zwei integrierte Modi: **Build** und **Plan**. Sie können anpassen
|
||||
diese oder konfigurieren Sie Ihre eigenen über die OpenCode-Konfiguration.
|
||||
|
||||
Sie können während einer Sitzung zwischen den Modi wechseln oder diese in Ihrer Konfigurationsdatei konfigurieren.
|
||||
|
||||
---
|
||||
|
||||
## Integriert
|
||||
|
||||
OpenCode verfügt über zwei integrierte Modi.
|
||||
|
||||
---
|
||||
|
||||
### Build
|
||||
|
||||
Build ist der **Standardmodus**, bei dem alle Tools aktiviert sind. Dies ist der Standardmodus für Entwicklungsarbeiten, bei dem Sie vollen Zugriff auf Dateioperationen und Systembefehle benötigen.
|
||||
|
||||
---
|
||||
|
||||
### Plan
|
||||
|
||||
Ein eingeschränkter Modus für Planung und Analyse. Im Planmodus sind die folgenden Tools standardmäßig deaktiviert:
|
||||
|
||||
- `write` – Es können keine neuen Dateien erstellt werden
|
||||
- `edit` – Vorhandene Dateien können nicht geändert werden, mit Ausnahme der Dateien unter `.opencode/plans/*.md`, um den Plan selbst detailliert darzustellen
|
||||
- `patch` – Patches können nicht angewendet werden
|
||||
- `bash` – Shell-Befehle können nicht ausgeführt werden
|
||||
|
||||
Dieser Modus ist nützlich, wenn Sie möchten, dass AI Code analysiert, Änderungen vorschlägt oder Pläne erstellt, ohne tatsächliche Änderungen an Ihrer Codebasis vorzunehmen.
|
||||
|
||||
---
|
||||
|
||||
## Wechseln
|
||||
|
||||
Sie können während einer Sitzung mit der _Tab_-Taste zwischen den Modi wechseln. Oder Ihre konfigurierte `switch_mode`-Tastenkombination.
|
||||
|
||||
Siehe auch: [Formatters](/docs/formatters) für Informationen zur Codeformatierungskonfiguration.
|
||||
|
||||
---
|
||||
|
||||
## Konfiguration
|
||||
|
||||
Sie können die integrierten Modi anpassen oder über die Konfiguration eigene erstellen. Modi können auf zwei Arten konfiguriert werden:
|
||||
|
||||
### JSON-Konfiguration
|
||||
|
||||
Konfigurieren Sie Modi in Ihrer `opencode.json`-Konfigurationsdatei:
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"build": {
|
||||
"model": "anthropic/claude-sonnet-4-20250514",
|
||||
"prompt": "{file:./prompts/build.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": true
|
||||
}
|
||||
},
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514",
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Markdown-Konfiguration
|
||||
|
||||
Sie können Modi auch mithilfe von Markdown-Dateien definieren. Platzieren Sie sie in:
|
||||
|
||||
- Global: `~/.config/opencode/modes/`
|
||||
- Projekt: `.opencode/modes/`
|
||||
|
||||
```markdown title="~/.config/opencode/modes/review.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.1
|
||||
tools:
|
||||
write: false
|
||||
edit: false
|
||||
bash: false
|
||||
---
|
||||
|
||||
You are in code review mode. Focus on:
|
||||
|
||||
- Code quality and best practices
|
||||
- Potential bugs and edge cases
|
||||
- Performance implications
|
||||
- Security considerations
|
||||
|
||||
Provide constructive feedback without making direct changes.
|
||||
```
|
||||
|
||||
Der Name der Markdown-Datei wird zum Modusnamen (e.g., `review.md` erstellt einen `review`-Modus).
|
||||
|
||||
Schauen wir uns diese Konfigurationsmöglichkeiten im Detail an.
|
||||
|
||||
---
|
||||
|
||||
### Model
|
||||
|
||||
Verwenden Sie die `model`-Konfiguration, um das Standardmodell für diesen Modus zu überschreiben. Nützlich für die Verwendung verschiedener Modelle, die für verschiedene Aufgaben optimiert sind. Zum Beispiel ein schnelleres Modell für die Planung, ein leistungsfähigeres Modell für die Umsetzung.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Temperatur
|
||||
|
||||
Steuern Sie die Zufälligkeit und Kreativität der Antworten von AI mit der `temperature`-Konfiguration. Niedrigere Werte machen die Antworten fokussierter und deterministischer, während höhere Werte die Kreativität und Variabilität steigern.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"temperature": 0.1
|
||||
},
|
||||
"creative": {
|
||||
"temperature": 0.8
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Temperaturwerte liegen typischerweise zwischen 0.0 und 1.0:
|
||||
|
||||
- **0.0-0.2**: Sehr fokussierte und deterministische Antworten, ideal für Code-Analyse und Planung
|
||||
- **0.3-0.5**: Ausgewogene Antworten mit etwas Kreativität, gut für allgemeine Entwicklungsaufgaben
|
||||
- **0.6-1.0**: Kreativere und vielfältigere Antworten, nützlich für Brainstorming und Erkundung
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"analyze": {
|
||||
"temperature": 0.1,
|
||||
"prompt": "{file:./prompts/analysis.txt}"
|
||||
},
|
||||
"build": {
|
||||
"temperature": 0.3
|
||||
},
|
||||
"brainstorm": {
|
||||
"temperature": 0.7,
|
||||
"prompt": "{file:./prompts/creative.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Wenn keine Temperatur angegeben ist, verwendet OpenCode modellspezifische Standardwerte (normalerweise 0 für die meisten Modelle, 0.55 für Qwen-Modelle).
|
||||
|
||||
---
|
||||
|
||||
### Prompt
|
||||
|
||||
Geben Sie mit der `prompt`-Konfiguration eine benutzerdefinierte Systemaufforderungsdatei für diesen Modus an. Die Eingabeaufforderungsdatei sollte spezifische Anweisungen für den Zweck des Modus enthalten.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"review": {
|
||||
"prompt": "{file:./prompts/code-review.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Dieser Pfad ist relativ zum Speicherort der Konfigurationsdatei. Das funktioniert also
|
||||
sowohl die globale OpenCode-Konfiguration als auch die projektspezifische Konfiguration.
|
||||
|
||||
---
|
||||
|
||||
### Werkzeuge
|
||||
|
||||
Steuern Sie mit der `tools`-Konfiguration, welche Tools in diesem Modus verfügbar sind. Sie können bestimmte Tools aktivieren oder deaktivieren, indem Sie sie auf `true` oder `false` setzen.
|
||||
|
||||
```json
|
||||
{
|
||||
"mode": {
|
||||
"readonly": {
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Wenn keine Tools angegeben sind, sind alle Tools standardmäßig aktiviert.
|
||||
|
||||
---
|
||||
|
||||
#### Verfügbare Tools
|
||||
|
||||
Hier sind alle Tools aufgeführt, die über den Konfigurationsmodus gesteuert werden können.
|
||||
|
||||
| Werkzeug | Beschreibung |
|
||||
| ----------- | ---------------------------- |
|
||||
| `bash` | Shell-Befehle ausführen |
|
||||
| `edit` | Vorhandene Dateien ändern |
|
||||
| `write` | Neue Dateien erstellen |
|
||||
| `read` | Dateiinhalt lesen |
|
||||
| `grep` | Dateiinhalte durchsuchen |
|
||||
| `glob` | Dateien nach Muster suchen |
|
||||
| `patch` | Patches auf Dateien anwenden |
|
||||
| `todowrite` | Aufgabenlisten verwalten |
|
||||
| `webfetch` | Webinhalte abrufen |
|
||||
|
||||
---
|
||||
|
||||
## Benutzerdefinierte Modi
|
||||
|
||||
Sie können Ihre eigenen benutzerdefinierten Modi erstellen, indem Sie diese zur Konfiguration hinzufügen. Hier sind Beispiele für beide Ansätze:
|
||||
|
||||
### Verwenden der JSON-Konfiguration
|
||||
|
||||
```json title="opencode.json" {4-14}
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"docs": {
|
||||
"prompt": "{file:./prompts/documentation.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Verwendung von Markdown-Dateien
|
||||
|
||||
Erstellen Sie Modusdateien in `.opencode/modes/` für projektspezifische Modi oder `~/.config/opencode/modes/` für globale Modi:
|
||||
|
||||
```markdown title=".opencode/modes/debug.md"
|
||||
---
|
||||
temperature: 0.1
|
||||
tools:
|
||||
bash: true
|
||||
read: true
|
||||
grep: true
|
||||
write: false
|
||||
edit: false
|
||||
---
|
||||
|
||||
You are in debug mode. Your primary goal is to help investigate and diagnose issues.
|
||||
|
||||
Focus on:
|
||||
|
||||
- Understanding the problem through careful analysis
|
||||
- Using bash commands to inspect system state
|
||||
- Reading relevant files and logs
|
||||
- Searching for patterns and anomalies
|
||||
- Providing clear explanations of findings
|
||||
|
||||
Do not make any changes to files. Only investigate and report.
|
||||
```
|
||||
|
||||
```markdown title="~/.config/opencode/modes/refactor.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.2
|
||||
tools:
|
||||
edit: true
|
||||
read: true
|
||||
grep: true
|
||||
glob: true
|
||||
---
|
||||
|
||||
You are in refactoring mode. Focus on improving code quality without changing functionality.
|
||||
|
||||
Priorities:
|
||||
|
||||
- Improve code readability and maintainability
|
||||
- Apply consistent naming conventions
|
||||
- Reduce code duplication
|
||||
- Optimize performance where appropriate
|
||||
- Ensure all tests continue to pass
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Anwendungsfälle
|
||||
|
||||
Hier sind einige häufige Anwendungsfälle für verschiedene Modi.
|
||||
|
||||
- **Build-Modus**: Vollständige Entwicklungsarbeit mit allen aktivierten Tools
|
||||
- **Planmodus**: Analyse und Planung ohne Änderungen
|
||||
- **Überprüfungsmodus**: Codeüberprüfung mit schreibgeschütztem Zugriff plus Dokumentationstools
|
||||
- **Debug-Modus**: Konzentriert sich auf die Untersuchung mit aktivierten Bash- und Lesetools
|
||||
- **Docs-Modus**: Dokumentationsschreiben mit Dateioperationen, aber ohne Systembefehle
|
||||
|
||||
Möglicherweise stellen Sie auch fest, dass unterschiedliche Modelle für unterschiedliche Anwendungsfälle geeignet sind.
|
||||
|
|
@ -1,329 +0,0 @@
|
|||
---
|
||||
title: Modos
|
||||
description: Diferentes modos para diferentes casos de uso.
|
||||
---
|
||||
|
||||
:::caution
|
||||
Los modos ahora se configuran a través de la opción `agent` en la configuración opencode. El
|
||||
La opción `mode` ahora está en desuso. [Más información](/docs/agents).
|
||||
:::
|
||||
|
||||
Los modos en opencode le permiten personalizar el comportamiento, las herramientas y las indicaciones para diferentes casos de uso.
|
||||
|
||||
Viene con dos modos integrados: **construir** y **planificar**. Puedes personalizar
|
||||
estos o configure el suyo propio a través de la configuración opencode.
|
||||
|
||||
Puede cambiar entre modos durante una sesión o configurarlos en su archivo de configuración.
|
||||
|
||||
---
|
||||
|
||||
## Integrados
|
||||
|
||||
opencode viene con dos modos integrados.
|
||||
|
||||
---
|
||||
|
||||
### Modo Build
|
||||
|
||||
Build es el modo **predeterminado** con todas las herramientas habilitadas. Este es el modo estándar para el trabajo de desarrollo en el que necesita acceso completo a las operaciones de archivos y a los comandos del sistema.
|
||||
|
||||
---
|
||||
|
||||
### Modo Plan
|
||||
|
||||
Un modo restringido diseñado para la planificación y el análisis. En el modo de plan, las siguientes herramientas están deshabilitadas de forma predeterminada:
|
||||
|
||||
- `write` - No se pueden crear archivos nuevos
|
||||
- `edit` - No se pueden modificar archivos existentes, excepto los archivos ubicados en `.opencode/plans/*.md` para detallar el plan en sí.
|
||||
- `patch` - No se pueden aplicar parches
|
||||
- `bash` - No se pueden ejecutar comandos de shell
|
||||
|
||||
Este modo es útil cuando desea que la IA analice código, sugiera cambios o cree planes sin realizar modificaciones reales en su base de código.
|
||||
|
||||
---
|
||||
|
||||
## Cambiar de modo
|
||||
|
||||
Puede cambiar entre modos durante una sesión usando la tecla _Tab_. O su combinación de teclas `switch_mode` configurada.
|
||||
|
||||
Consulte también: [Formateadores](/docs/formatters) para obtener información sobre la configuración de formato de código.
|
||||
|
||||
---
|
||||
|
||||
## Configuración
|
||||
|
||||
Puede personalizar los modos integrados o crear los suyos propios mediante la configuración. Los modos se pueden configurar de dos maneras:
|
||||
|
||||
### Configuración JSON
|
||||
|
||||
Configure los modos en su archivo de configuración `opencode.json`:
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"build": {
|
||||
"model": "anthropic/claude-sonnet-4-20250514",
|
||||
"prompt": "{file:./prompts/build.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": true
|
||||
}
|
||||
},
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514",
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Configuración de Markdown
|
||||
|
||||
También puede definir modos utilizando archivos de Markdown. Colócalos en:
|
||||
|
||||
- Global: `~/.config/opencode/modes/`
|
||||
- Proyecto: `.opencode/modes/`
|
||||
|
||||
```markdown title="~/.config/opencode/modes/review.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.1
|
||||
tools:
|
||||
write: false
|
||||
edit: false
|
||||
bash: false
|
||||
---
|
||||
|
||||
You are in code review mode. Focus on:
|
||||
|
||||
- Code quality and best practices
|
||||
- Potential bugs and edge cases
|
||||
- Performance implications
|
||||
- Security considerations
|
||||
|
||||
Provide constructive feedback without making direct changes.
|
||||
```
|
||||
|
||||
El nombre del archivo de Markdown se convierte en el nombre del modo (por ejemplo, `review.md` crea un modo `review`).
|
||||
|
||||
Veamos estas opciones de configuración en detalle.
|
||||
|
||||
---
|
||||
|
||||
### Modelo
|
||||
|
||||
Utilice la configuración `model` para anular el modelo predeterminado para este modo. Útil para utilizar diferentes modelos optimizados para diferentes tareas. Por ejemplo, un modelo más rápido de planificación, un modelo más capaz de implementación.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Temperatura
|
||||
|
||||
Controle la aleatoriedad y la creatividad de las respuestas de la IA con la configuración `temperature`. Los valores más bajos hacen que las respuestas sean más centradas y deterministas, mientras que los valores más altos aumentan la creatividad y la variabilidad.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"temperature": 0.1
|
||||
},
|
||||
"creative": {
|
||||
"temperature": 0.8
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Los valores de temperatura suelen oscilar entre 0,0 y 1,0:
|
||||
|
||||
- **0.0-0.2**: Respuestas muy enfocadas y deterministas, ideales para análisis y planificación de código.
|
||||
- **0,3-0,5**: respuestas equilibradas con algo de creatividad, buenas para tareas de desarrollo general.
|
||||
- **0.6-1.0**: respuestas más creativas y variadas, útiles para la lluvia de ideas y la exploración.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"analyze": {
|
||||
"temperature": 0.1,
|
||||
"prompt": "{file:./prompts/analysis.txt}"
|
||||
},
|
||||
"build": {
|
||||
"temperature": 0.3
|
||||
},
|
||||
"brainstorm": {
|
||||
"temperature": 0.7,
|
||||
"prompt": "{file:./prompts/creative.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Si no se especifica ninguna temperatura, opencode utiliza valores predeterminados específicos del modelo (normalmente 0 para la mayoría de los modelos, 0,55 para los modelos Qwen).
|
||||
|
||||
---
|
||||
|
||||
### Indicación
|
||||
|
||||
Especifique un archivo de aviso del sistema personalizado para este modo con la configuración `prompt`. El archivo de aviso debe contener instrucciones específicas para el propósito del modo.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"review": {
|
||||
"prompt": "{file:./prompts/code-review.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Esta ruta es relativa a donde se encuentra el archivo de configuración. Entonces esto funciona para
|
||||
tanto la configuración global opencode como la configuración específica del proyecto.
|
||||
|
||||
---
|
||||
|
||||
### Herramientas
|
||||
|
||||
Controle qué herramientas están disponibles en este modo con la configuración `tools`. Puede habilitar o deshabilitar herramientas específicas configurándolas en `true` o `false`.
|
||||
|
||||
```json
|
||||
{
|
||||
"mode": {
|
||||
"readonly": {
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Si no se especifica ninguna herramienta, todas las herramientas están habilitadas de forma predeterminada.
|
||||
|
||||
---
|
||||
|
||||
#### Herramientas disponibles
|
||||
|
||||
Aquí están todas las herramientas que se pueden controlar a través del modo de configuración.
|
||||
|
||||
| Herramienta | Descripción |
|
||||
| ----------- | --------------------------------------- |
|
||||
| `bash` | Ejecutar comandos de shell |
|
||||
| `edit` | Modificar archivos existentes |
|
||||
| `write` | Crear nuevos archivos |
|
||||
| `read` | Leer el contenido del archivo |
|
||||
| `grep` | Buscar contenido del archivo |
|
||||
| `glob` | Buscar archivos por patrón |
|
||||
| `patch` | Aplicar parches a archivos |
|
||||
| `todowrite` | Administrar listas de tareas pendientes |
|
||||
| `webfetch` | Obtener contenido web |
|
||||
|
||||
---
|
||||
|
||||
## Modos personalizados
|
||||
|
||||
Puede crear sus propios modos personalizados agregándolos a la configuración. A continuación se muestran ejemplos que utilizan ambos enfoques:
|
||||
|
||||
### Usando la configuración JSON
|
||||
|
||||
```json title="opencode.json" {4-14}
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"docs": {
|
||||
"prompt": "{file:./prompts/documentation.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Usando archivos de Markdown
|
||||
|
||||
Cree archivos de modo en `.opencode/modes/` para modos específicos del proyecto o `~/.config/opencode/modes/` para modos globales:
|
||||
|
||||
```markdown title=".opencode/modes/debug.md"
|
||||
---
|
||||
temperature: 0.1
|
||||
tools:
|
||||
bash: true
|
||||
read: true
|
||||
grep: true
|
||||
write: false
|
||||
edit: false
|
||||
---
|
||||
|
||||
You are in debug mode. Your primary goal is to help investigate and diagnose issues.
|
||||
|
||||
Focus on:
|
||||
|
||||
- Understanding the problem through careful analysis
|
||||
- Using bash commands to inspect system state
|
||||
- Reading relevant files and logs
|
||||
- Searching for patterns and anomalies
|
||||
- Providing clear explanations of findings
|
||||
|
||||
Do not make any changes to files. Only investigate and report.
|
||||
```
|
||||
|
||||
```markdown title="~/.config/opencode/modes/refactor.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.2
|
||||
tools:
|
||||
edit: true
|
||||
read: true
|
||||
grep: true
|
||||
glob: true
|
||||
---
|
||||
|
||||
You are in refactoring mode. Focus on improving code quality without changing functionality.
|
||||
|
||||
Priorities:
|
||||
|
||||
- Improve code readability and maintainability
|
||||
- Apply consistent naming conventions
|
||||
- Reduce code duplication
|
||||
- Optimize performance where appropriate
|
||||
- Ensure all tests continue to pass
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Casos de uso
|
||||
|
||||
A continuación se muestran algunos casos de uso comunes para diferentes modos.
|
||||
|
||||
- **Modo Build**: trabajo de desarrollo completo con todas las herramientas habilitadas
|
||||
- **Modo Plan**: Análisis y planificación sin realizar cambios
|
||||
- **Modo Review**: revisión de código con acceso de solo lectura más herramientas de documentación
|
||||
- **Modo Debug**: centrado en la investigación con bash y herramientas de lectura habilitadas
|
||||
- **Modo Docs**: escritura de documentacion con operaciones de archivos pero sin comandos del sistema
|
||||
|
||||
También puede encontrar que diferentes modelos son buenos para diferentes casos de uso.
|
||||
|
|
@ -1,327 +0,0 @@
|
|||
---
|
||||
title: Modes
|
||||
description: Différents modes pour différents cas d'utilisation.
|
||||
---
|
||||
|
||||
:::caution
|
||||
Les modes sont désormais configurés via l'option `agent` dans la configuration opencode.
|
||||
L’option `mode` est désormais obsolète. [En savoir plus](/docs/agents).
|
||||
:::
|
||||
|
||||
Les modes dans opencode vous permettent de personnaliser le comportement, les outils et les prompts pour différents cas d'utilisation.
|
||||
|
||||
Il est livré avec deux modes intégrés : **build** et **plan**. Vous pouvez personnaliser ceux-ci ou configurez les vôtres via la configuration opencode.
|
||||
|
||||
Vous pouvez basculer entre les modes au cours d'une session ou les configurer dans votre fichier de configuration.
|
||||
|
||||
---
|
||||
|
||||
## Modes intégrés
|
||||
|
||||
opencode est livré avec deux modes intégrés.
|
||||
|
||||
---
|
||||
|
||||
### Build
|
||||
|
||||
Build est le mode **par défaut** avec tous les outils activés. Il s'agit du mode standard pour le travail de développement dans lequel vous avez besoin d'un accès complet aux opérations sur les fichiers et aux commandes système.
|
||||
|
||||
---
|
||||
|
||||
### Plan
|
||||
|
||||
Un mode restreint conçu pour la planification et l’analyse. En mode plan, les outils suivants sont désactivés par défaut :
|
||||
|
||||
- `write` - Impossible de créer de nouveaux fichiers
|
||||
- `edit` - Impossible de modifier les fichiers existants, à l'exception des fichiers situés à `.opencode/plans/*.md` pour détailler le plan lui-même
|
||||
- `patch` - Impossible d'appliquer les correctifs
|
||||
- `bash` - Impossible d'exécuter les commandes shell
|
||||
|
||||
Ce mode est utile lorsque vous souhaitez que l'IA analyse le code, suggère des modifications ou crée des plans sans apporter de modifications réelles à votre base de code.
|
||||
|
||||
---
|
||||
|
||||
## Changement de mode
|
||||
|
||||
Vous pouvez basculer entre les modes au cours d'une session à l'aide de la touche _Tab_. Ou votre raccourci clavier `switch_mode` configuré.
|
||||
|
||||
Voir également : [Formatters](/docs/formatters) pour plus d'informations sur la configuration du formatage du code.
|
||||
|
||||
---
|
||||
|
||||
## Configuration
|
||||
|
||||
Vous pouvez personnaliser les modes intégrés ou créer les vôtres via la configuration. Les modes peuvent être configurés de deux manières :
|
||||
|
||||
### Configuration JSON
|
||||
|
||||
Configurez les modes dans votre fichier de configuration `opencode.json` :
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"build": {
|
||||
"model": "anthropic/claude-sonnet-4-20250514",
|
||||
"prompt": "{file:./prompts/build.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": true
|
||||
}
|
||||
},
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514",
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Configuration Markdown
|
||||
|
||||
Vous pouvez également définir des modes à l'aide de fichiers markdown. Placez-les dans :
|
||||
|
||||
- Global : `~/.config/opencode/modes/`
|
||||
- Projet : `.opencode/modes/`
|
||||
|
||||
```markdown title="~/.config/opencode/modes/review.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.1
|
||||
tools:
|
||||
write: false
|
||||
edit: false
|
||||
bash: false
|
||||
---
|
||||
|
||||
You are in code review mode. Focus on:
|
||||
|
||||
- Code quality and best practices
|
||||
- Potential bugs and edge cases
|
||||
- Performance implications
|
||||
- Security considerations
|
||||
|
||||
Provide constructive feedback without making direct changes.
|
||||
```
|
||||
|
||||
Le nom du fichier markdown devient le nom du mode (par exemple, `review.md` crée un mode `review`).
|
||||
|
||||
Examinons ces options de configuration en détail.
|
||||
|
||||
---
|
||||
|
||||
### Modèle
|
||||
|
||||
Utilisez la configuration `model` pour remplacer le modèle par défaut pour ce mode. Utile pour utiliser différents modèles optimisés pour différentes tâches. Par exemple, un modèle de planification plus rapide, un modèle de mise en œuvre plus performant.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Température
|
||||
|
||||
Contrôlez le caractère aléatoire et la créativité des réponses de l'IA avec la configuration `temperature`. Des valeurs faibles rendent les réponses plus ciblées et déterministes, tandis que des valeurs plus élevées augmentent la créativité et la variabilité.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"temperature": 0.1
|
||||
},
|
||||
"creative": {
|
||||
"temperature": 0.8
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Les valeurs de température varient généralement de 0,0 à 1,0 :
|
||||
|
||||
- **0,0-0,2** : réponses très ciblées et déterministes, idéales pour l'analyse et la planification du code
|
||||
- **0,3-0,5** : réponses équilibrées avec une certaine créativité, idéales pour les tâches de développement générales
|
||||
- **0,6-1,0** : réponses plus créatives et variées, utiles pour le brainstorming et l'exploration
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"analyze": {
|
||||
"temperature": 0.1,
|
||||
"prompt": "{file:./prompts/analysis.txt}"
|
||||
},
|
||||
"build": {
|
||||
"temperature": 0.3
|
||||
},
|
||||
"brainstorm": {
|
||||
"temperature": 0.7,
|
||||
"prompt": "{file:./prompts/creative.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Si aucune température n'est spécifiée, opencode utilise les valeurs par défaut spécifiques au modèle (généralement 0 pour la plupart des modèles, 0,55 pour les modèles Qwen).
|
||||
|
||||
---
|
||||
|
||||
### Invite
|
||||
|
||||
Spécifiez un fichier de prompt système personnalisé pour ce mode avec la configuration `prompt`. Le fichier de prompt doit contenir des instructions spécifiques à l'objectif du mode.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"review": {
|
||||
"prompt": "{file:./prompts/code-review.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Ce chemin est relatif à l'emplacement du fichier de configuration. Donc ça marche pour à la fois la configuration globale opencode et la configuration spécifique au projet.
|
||||
|
||||
---
|
||||
|
||||
### Outils
|
||||
|
||||
Contrôlez quels outils sont disponibles dans ce mode avec la configuration `tools`. Vous pouvez activer ou désactiver des outils spécifiques en les définissant sur `true` ou `false`.
|
||||
|
||||
```json
|
||||
{
|
||||
"mode": {
|
||||
"readonly": {
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Si aucun outil n'est spécifié, tous les outils sont activés par défaut.
|
||||
|
||||
---
|
||||
|
||||
#### Outils disponibles
|
||||
|
||||
Voici tous les outils pouvant être contrôlés via le mode config.
|
||||
|
||||
| Outil | Description |
|
||||
| ----------- | ------------------------------------- |
|
||||
| `bash` | Exécuter des commandes shell |
|
||||
| `edit` | Modifier des fichiers existants |
|
||||
| `write` | Créer de nouveaux fichiers |
|
||||
| `read` | Lire le contenu du fichier |
|
||||
| `grep` | Rechercher le contenu du fichier |
|
||||
| `glob` | Rechercher des fichiers par modèle |
|
||||
| `patch` | Appliquer des correctifs aux fichiers |
|
||||
| `todowrite` | Gérer les listes de tâches |
|
||||
| `webfetch` | Récupérer du contenu Web |
|
||||
|
||||
---
|
||||
|
||||
## Modes personnalisés
|
||||
|
||||
Vous pouvez créer vos propres modes personnalisés en les ajoutant à la configuration. Voici des exemples utilisant les deux approches :
|
||||
|
||||
### Utilisation de la configuration JSON
|
||||
|
||||
```json title="opencode.json" {4-14}
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"docs": {
|
||||
"prompt": "{file:./prompts/documentation.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Utiliser des fichiers Markdown
|
||||
|
||||
Créez des fichiers de mode dans `.opencode/modes/` pour les modes spécifiques au projet ou `~/.config/opencode/modes/` pour les modes globaux :
|
||||
|
||||
```markdown title=".opencode/modes/debug.md"
|
||||
---
|
||||
temperature: 0.1
|
||||
tools:
|
||||
bash: true
|
||||
read: true
|
||||
grep: true
|
||||
write: false
|
||||
edit: false
|
||||
---
|
||||
|
||||
You are in debug mode. Your primary goal is to help investigate and diagnose issues.
|
||||
|
||||
Focus on:
|
||||
|
||||
- Understanding the problem through careful analysis
|
||||
- Using bash commands to inspect system state
|
||||
- Reading relevant files and logs
|
||||
- Searching for patterns and anomalies
|
||||
- Providing clear explanations of findings
|
||||
|
||||
Do not make any changes to files. Only investigate and report.
|
||||
```
|
||||
|
||||
```markdown title="~/.config/opencode/modes/refactor.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.2
|
||||
tools:
|
||||
edit: true
|
||||
read: true
|
||||
grep: true
|
||||
glob: true
|
||||
---
|
||||
|
||||
You are in refactoring mode. Focus on improving code quality without changing functionality.
|
||||
|
||||
Priorities:
|
||||
|
||||
- Improve code readability and maintainability
|
||||
- Apply consistent naming conventions
|
||||
- Reduce code duplication
|
||||
- Optimize performance where appropriate
|
||||
- Ensure all tests continue to pass
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Cas d'utilisation
|
||||
|
||||
Voici quelques cas d’utilisation courants pour différents modes.
|
||||
|
||||
- **Mode Build** : travail de développement complet avec tous les outils activés
|
||||
- **Mode Plan** : Analyse et planification sans apporter de modifications
|
||||
- **Mode Review** : révision du code avec accès en lecture seule et outils de documentation
|
||||
- **Mode Debug** : axé sur l'investigation avec les outils bash et read activés
|
||||
- **Mode Docs** : écriture de documentation avec des opérations sur les fichiers mais pas de commandes système
|
||||
|
||||
Vous constaterez peut-être également que différents modèles conviennent à différents cas d’utilisation.
|
||||
|
|
@ -1,328 +0,0 @@
|
|||
---
|
||||
title: Modalità
|
||||
description: Modalita diverse per casi d'uso diversi.
|
||||
---
|
||||
|
||||
:::caution
|
||||
Le modalita ora si configurano tramite l'opzione `agent` nella configurazione di opencode. L'opzione
|
||||
`mode` e ora deprecata. [Scopri di piu](/docs/agents).
|
||||
:::
|
||||
|
||||
Le modalita in opencode ti permettono di personalizzare comportamento, strumenti e prompt per casi d'uso diversi.
|
||||
|
||||
Include due modalita integrate: **build** e **plan**. Puoi personalizzarle oppure configurarne di tue tramite la configurazione di opencode.
|
||||
|
||||
Puoi passare da una modalita all'altra durante una sessione oppure configurarle nel file di configurazione.
|
||||
|
||||
---
|
||||
|
||||
## Integrate
|
||||
|
||||
opencode include due modalita integrate.
|
||||
|
||||
---
|
||||
|
||||
### Build
|
||||
|
||||
Build e la modalita **predefinita** con tutti gli strumenti abilitati. E la modalita standard per il lavoro di sviluppo quando ti serve accesso completo alle operazioni sui file e ai comandi di sistema.
|
||||
|
||||
---
|
||||
|
||||
### Plan
|
||||
|
||||
Una modalita limitata pensata per pianificazione e analisi. In modalita plan, i seguenti strumenti sono disabilitati per impostazione predefinita:
|
||||
|
||||
- `write` - Non puo creare nuovi file
|
||||
- `edit` - Non puo modificare file esistenti, tranne i file in `.opencode/plans/*.md` per dettagliare il piano
|
||||
- `patch` - Non puo applicare patch
|
||||
- `bash` - Non puo eseguire comandi shell
|
||||
|
||||
Questa modalita e utile quando vuoi che l'AI analizzi il codice, suggerisca modifiche o crei piani senza apportare modifiche effettive alla codebase.
|
||||
|
||||
---
|
||||
|
||||
## Cambiare modalità
|
||||
|
||||
Puoi cambiare modalita durante una sessione usando il tasto _Tab_. In alternativa, puoi usare il keybind `switch_mode` che hai configurato.
|
||||
|
||||
Vedi anche: [Formatter](/docs/formatters) per informazioni sulla configurazione della formattazione del codice.
|
||||
|
||||
---
|
||||
|
||||
## Configurazione
|
||||
|
||||
Puoi personalizzare le modalita integrate o crearne di tue tramite configurazione. Le modalita si possono configurare in due modi:
|
||||
|
||||
### Configurazione JSON
|
||||
|
||||
Configura le modalita nel file di configurazione `opencode.json`:
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"build": {
|
||||
"model": "anthropic/claude-sonnet-4-20250514",
|
||||
"prompt": "{file:./prompts/build.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": true
|
||||
}
|
||||
},
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514",
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Configurazione Markdown
|
||||
|
||||
Puoi anche definire modalita usando file markdown. Mettili in:
|
||||
|
||||
- Globale: `~/.config/opencode/modes/`
|
||||
- Progetto: `.opencode/modes/`
|
||||
|
||||
```markdown title="~/.config/opencode/modes/review.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.1
|
||||
tools:
|
||||
write: false
|
||||
edit: false
|
||||
bash: false
|
||||
---
|
||||
|
||||
You are in code review mode. Focus on:
|
||||
|
||||
- Code quality and best practices
|
||||
- Potential bugs and edge cases
|
||||
- Performance implications
|
||||
- Security considerations
|
||||
|
||||
Provide constructive feedback without making direct changes.
|
||||
```
|
||||
|
||||
Il nome del file markdown diventa il nome della modalita (ad es. `review.md` crea una modalita `review`).
|
||||
|
||||
Vediamo queste opzioni di configurazione nel dettaglio.
|
||||
|
||||
---
|
||||
|
||||
### Modello
|
||||
|
||||
Usa la configurazione `model` per sovrascrivere il modello predefinito per questa modalita. E utile per usare modelli diversi ottimizzati per task diversi: per esempio, un modello piu veloce per la pianificazione e uno piu capace per l'implementazione.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Temperatura
|
||||
|
||||
Controlla casualita e creativita delle risposte dell'AI con la configurazione `temperature`. Valori piu bassi rendono le risposte piu focalizzate e deterministiche, mentre valori piu alti aumentano creativita e variabilita.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"temperature": 0.1
|
||||
},
|
||||
"creative": {
|
||||
"temperature": 0.8
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
I valori di temperatura di solito vanno da 0.0 a 1.0:
|
||||
|
||||
- **0.0-0.2**: risposte molto focalizzate e deterministiche, ideali per analisi del codice e pianificazione
|
||||
- **0.3-0.5**: risposte bilanciate con un po' di creativita, buone per task di sviluppo generici
|
||||
- **0.6-1.0**: risposte piu creative e variabili, utili per brainstorming ed esplorazione
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"analyze": {
|
||||
"temperature": 0.1,
|
||||
"prompt": "{file:./prompts/analysis.txt}"
|
||||
},
|
||||
"build": {
|
||||
"temperature": 0.3
|
||||
},
|
||||
"brainstorm": {
|
||||
"temperature": 0.7,
|
||||
"prompt": "{file:./prompts/creative.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Se non viene specificata alcuna temperatura, opencode usa i default specifici del modello (tipicamente 0 per la maggior parte dei modelli, 0.55 per i modelli Qwen).
|
||||
|
||||
---
|
||||
|
||||
### Prompt
|
||||
|
||||
Specifica un file di prompt di sistema personalizzato per questa modalita con la configurazione `prompt`. Il file dovrebbe contenere istruzioni specifiche per lo scopo della modalita.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"review": {
|
||||
"prompt": "{file:./prompts/code-review.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Questo percorso e relativo a dove si trova il file di configurazione. Quindi funziona
|
||||
sia per la configurazione globale di opencode sia per quella specifica del progetto.
|
||||
|
||||
---
|
||||
|
||||
### Strumenti
|
||||
|
||||
Controlla quali strumenti sono disponibili in questa modalita con la configurazione `tools`. Puoi abilitare o disabilitare strumenti specifici impostandoli a `true` o `false`.
|
||||
|
||||
```json
|
||||
{
|
||||
"mode": {
|
||||
"readonly": {
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Se non specifichi gli strumenti, tutti gli strumenti sono abilitati per impostazione predefinita.
|
||||
|
||||
---
|
||||
|
||||
#### Strumenti disponibili
|
||||
|
||||
Ecco tutti gli strumenti che possono essere controllati tramite la configurazione della modalita.
|
||||
|
||||
| Strumento | Descrizione |
|
||||
| ----------- | ---------------------------- |
|
||||
| `bash` | Esegue comandi shell |
|
||||
| `edit` | Modifica file esistenti |
|
||||
| `write` | Crea nuovi file |
|
||||
| `read` | Legge contenuti dei file |
|
||||
| `grep` | Cerca nei contenuti dei file |
|
||||
| `glob` | Trova file per pattern |
|
||||
| `patch` | Applica patch ai file |
|
||||
| `todowrite` | Gestisce liste todo |
|
||||
| `webfetch` | Recupera contenuti web |
|
||||
|
||||
---
|
||||
|
||||
## Modalità personalizzate
|
||||
|
||||
Puoi creare modalita personalizzate aggiungendole alla configurazione. Ecco esempi con entrambi gli approcci:
|
||||
|
||||
### Usando la configurazione JSON
|
||||
|
||||
```json title="opencode.json" {4-14}
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"docs": {
|
||||
"prompt": "{file:./prompts/documentation.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Usando file markdown
|
||||
|
||||
Crea file di modalita in `.opencode/modes/` per modalita specifiche del progetto oppure in `~/.config/opencode/modes/` per modalita globali:
|
||||
|
||||
```markdown title=".opencode/modes/debug.md"
|
||||
---
|
||||
temperature: 0.1
|
||||
tools:
|
||||
bash: true
|
||||
read: true
|
||||
grep: true
|
||||
write: false
|
||||
edit: false
|
||||
---
|
||||
|
||||
You are in debug mode. Your primary goal is to help investigate and diagnose issues.
|
||||
|
||||
Focus on:
|
||||
|
||||
- Understanding the problem through careful analysis
|
||||
- Using bash commands to inspect system state
|
||||
- Reading relevant files and logs
|
||||
- Searching for patterns and anomalies
|
||||
- Providing clear explanations of findings
|
||||
|
||||
Do not make any changes to files. Only investigate and report.
|
||||
```
|
||||
|
||||
```markdown title="~/.config/opencode/modes/refactor.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.2
|
||||
tools:
|
||||
edit: true
|
||||
read: true
|
||||
grep: true
|
||||
glob: true
|
||||
---
|
||||
|
||||
You are in refactoring mode. Focus on improving code quality without changing functionality.
|
||||
|
||||
Priorities:
|
||||
|
||||
- Improve code readability and maintainability
|
||||
- Apply consistent naming conventions
|
||||
- Reduce code duplication
|
||||
- Optimize performance where appropriate
|
||||
- Ensure all tests continue to pass
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Casi d'uso
|
||||
|
||||
Ecco alcuni casi d'uso comuni per le diverse modalita.
|
||||
|
||||
- **Modalita Build**: sviluppo completo con tutti gli strumenti abilitati
|
||||
- **Modalita Plan**: analisi e pianificazione senza apportare modifiche
|
||||
- **Modalita Review**: code review con accesso in sola lettura piu strumenti di documentazione
|
||||
- **Modalita Debug**: focalizzata sull'investigazione con strumenti bash e read abilitati
|
||||
- **Modalita Docs**: scrittura di documentazione con operazioni sui file ma senza comandi di sistema
|
||||
|
||||
Potresti anche trovare che modelli diversi funzionano meglio per casi d'uso diversi.
|
||||
|
|
@ -1,327 +0,0 @@
|
|||
---
|
||||
title: モード
|
||||
description: さまざまなユースケースに応じたさまざまなモード。
|
||||
---
|
||||
|
||||
:::caution
|
||||
モードは、OpenCode 設定の `agent` オプションを通じて設定されるようになりました。
|
||||
`mode` オプションは非推奨になりました。 [詳細はこちら](/docs/agents)。
|
||||
:::
|
||||
モードを使用すると、さまざまなユースケースに合わせて動作、ツール、プロンプトをカスタマイズできます。
|
||||
|
||||
**Build** と **Plan** という 2 つの組み込みモードが付属しています。カスタマイズできます
|
||||
これらを使用するか、OpenCode 設定を通じて独自の設定を行います。
|
||||
|
||||
セッション中にモードを切り替えることも、設定ファイルでモードを構成することもできます。
|
||||
|
||||
---
|
||||
|
||||
## 組み込み
|
||||
|
||||
OpenCode には 2 つの組み込みモードが付属しています。
|
||||
|
||||
---
|
||||
|
||||
### Build
|
||||
|
||||
Build は、すべてのツールが有効になっている **デフォルト** モードです。これは、ファイル操作やシステムコマンドへのフルアクセスが必要な開発作業の標準モードです。
|
||||
|
||||
---
|
||||
|
||||
### Plan
|
||||
|
||||
計画と分析のために設計された制限付きモード。Plan モードでは、次のツールはデフォルトで無効になっています。
|
||||
|
||||
- `write` - 新しいファイルを作成できません
|
||||
- `edit` - 計画自体の詳細を示す `.opencode/plans/*.md` にあるファイルを除き、既存のファイルを変更できません
|
||||
- `patch` - パッチを適用できません
|
||||
- `bash` - シェルコマンドを実行できません
|
||||
|
||||
このモードは、コードベースに実際の変更を加えずに、AI にコードを分析させたり、変更を提案したり、計画を作成させたい場合に便利です。
|
||||
|
||||
---
|
||||
|
||||
## 切り替え
|
||||
|
||||
セッション中に _Tab_ キーを使用してモードを切り替えることができます。または、設定された `switch_mode` キーバインド。
|
||||
|
||||
参照: [コードのフォーマット設定については、Formatters](/docs/formatters)。
|
||||
|
||||
---
|
||||
|
||||
## 設定
|
||||
|
||||
組み込みモードをカスタマイズしたり、構成を通じて独自のモードを作成したりできます。モードは次の 2 つの方法で設定できます。
|
||||
|
||||
### JSON 設定
|
||||
|
||||
`opencode.json` 設定ファイルでモードを構成します。
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"build": {
|
||||
"model": "anthropic/claude-sonnet-4-20250514",
|
||||
"prompt": "{file:./prompts/build.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": true
|
||||
}
|
||||
},
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514",
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Markdown 設定
|
||||
|
||||
Markdown ファイルを使用してモードを定義することもできます。それらを次の場所に置きます。
|
||||
|
||||
- グローバル: `~/.config/opencode/modes/`
|
||||
- プロジェクト: `.opencode/modes/`
|
||||
|
||||
```markdown title="~/.config/opencode/modes/review.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.1
|
||||
tools:
|
||||
write: false
|
||||
edit: false
|
||||
bash: false
|
||||
---
|
||||
|
||||
You are in code review mode. Focus on:
|
||||
|
||||
- Code quality and best practices
|
||||
- Potential bugs and edge cases
|
||||
- Performance implications
|
||||
- Security considerations
|
||||
|
||||
Provide constructive feedback without making direct changes.
|
||||
```
|
||||
|
||||
Markdown ファイル名はモード名になります (例: `review.md` は `review` モードを作成します)。
|
||||
|
||||
これらの設定オプションを詳しく見てみましょう。
|
||||
|
||||
---
|
||||
|
||||
### モデル
|
||||
|
||||
`model` 設定を使用して、このモードのデフォルトモデルをオーバーライドします。さまざまなタスクに最適化されたさまざまなモデルを使用する場合に役立ちます。たとえば、計画にはより高速なモデルを、実装にはより有能なモデルを使用します。
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 温度
|
||||
|
||||
`temperature` 設定を使用して、AI の応答のランダム性と創造性を制御します。値が低いほど、応答はより集中的かつ決定的になりますが、値が高いほど、創造性と変動性が高まります。
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"temperature": 0.1
|
||||
},
|
||||
"creative": {
|
||||
"temperature": 0.8
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
通常、温度値の範囲は 0.0 ~ 1.0 です。
|
||||
|
||||
- **0.0-0.2**: 非常に焦点が絞られた決定的な応答。コード分析と計画に最適です。
|
||||
- **0.3-0.5**: 創造性を備えたバランスの取れた応答。一般的な開発タスクに適しています。
|
||||
- **0.6-1.0**: より創造的で多様な応答。ブレーンストーミングや探索に役立ちます。
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"analyze": {
|
||||
"temperature": 0.1,
|
||||
"prompt": "{file:./prompts/analysis.txt}"
|
||||
},
|
||||
"build": {
|
||||
"temperature": 0.3
|
||||
},
|
||||
"brainstorm": {
|
||||
"temperature": 0.7,
|
||||
"prompt": "{file:./prompts/creative.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
温度が指定されていない場合、OpenCode はモデル固有のデフォルトを使用します (通常、ほとんどのモデルでは 0、Qwen モデルでは 0.55)。
|
||||
|
||||
---
|
||||
|
||||
### プロンプト
|
||||
|
||||
`prompt` 設定を使用して、このモードのカスタムシステムプロンプトファイルを指定します。プロンプトファイルには、モードの目的に固有の指示が含まれている必要があります。
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"review": {
|
||||
"prompt": "{file:./prompts/code-review.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
このパスは、設定ファイルが配置されている場所に対する相対パスです。したがって、これはグローバルな OpenCode 設定とプロジェクト固有の設定の両方で機能します。
|
||||
|
||||
---
|
||||
|
||||
### ツール
|
||||
|
||||
`tools` 設定を使用して、このモードでどのツールを使用できるかを制御します。特定のツールを `true` または `false` に設定することで、有効または無効にすることができます。
|
||||
|
||||
```json
|
||||
{
|
||||
"mode": {
|
||||
"readonly": {
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
ツールが指定されていない場合は、すべてのツールがデフォルトで有効になります。
|
||||
|
||||
---
|
||||
|
||||
#### 利用可能なツール
|
||||
|
||||
ここでは、モード設定を通じて制御できるすべてのツールを示します。
|
||||
|
||||
| ツール | 説明 |
|
||||
| ----------- | -------------------------- |
|
||||
| `bash` | シェルコマンドを実行する |
|
||||
| `edit` | 既存のファイルを変更する |
|
||||
| `write` | 新しいファイルを作成する |
|
||||
| `read` | ファイルの内容を読み取る |
|
||||
| `grep` | ファイルの内容を検索 |
|
||||
| `glob` | パターンでファイルを検索 |
|
||||
| `patch` | ファイルにパッチを適用する |
|
||||
| `todowrite` | ToDo リストを管理する |
|
||||
| `webfetch` | Web コンテンツを取得する |
|
||||
|
||||
---
|
||||
|
||||
## カスタムモード
|
||||
|
||||
構成に追加することで、独自のカスタムモードを作成できます。両方のアプローチを使用した例を次に示します。
|
||||
|
||||
### JSON 設定の使用
|
||||
|
||||
```json title="opencode.json" {4-14}
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"docs": {
|
||||
"prompt": "{file:./prompts/documentation.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Markdown ファイルの使用
|
||||
|
||||
モードファイルをプロジェクト固有モードの場合は `.opencode/modes/` に、グローバルモードの場合は `~/.config/opencode/modes/` に作成します。
|
||||
|
||||
```markdown title=".opencode/modes/debug.md"
|
||||
---
|
||||
temperature: 0.1
|
||||
tools:
|
||||
bash: true
|
||||
read: true
|
||||
grep: true
|
||||
write: false
|
||||
edit: false
|
||||
---
|
||||
|
||||
You are in debug mode. Your primary goal is to help investigate and diagnose issues.
|
||||
|
||||
Focus on:
|
||||
|
||||
- Understanding the problem through careful analysis
|
||||
- Using bash commands to inspect system state
|
||||
- Reading relevant files and logs
|
||||
- Searching for patterns and anomalies
|
||||
- Providing clear explanations of findings
|
||||
|
||||
Do not make any changes to files. Only investigate and report.
|
||||
```
|
||||
|
||||
```markdown title="~/.config/opencode/modes/refactor.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.2
|
||||
tools:
|
||||
edit: true
|
||||
read: true
|
||||
grep: true
|
||||
glob: true
|
||||
---
|
||||
|
||||
You are in refactoring mode. Focus on improving code quality without changing functionality.
|
||||
|
||||
Priorities:
|
||||
|
||||
- Improve code readability and maintainability
|
||||
- Apply consistent naming conventions
|
||||
- Reduce code duplication
|
||||
- Optimize performance where appropriate
|
||||
- Ensure all tests continue to pass
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### ユースケース
|
||||
|
||||
さまざまなモードの一般的な使用例をいくつか示します。
|
||||
|
||||
- **ビルドモード**: すべてのツールを有効にした完全な開発作業
|
||||
- **計画モード**: 変更を加えずに分析および計画を立てる
|
||||
- **レビューモード**: 読み取り専用アクセスとドキュメントツールによるコードレビュー
|
||||
- **デバッグモード**: bash および読み取りツールを有効にして調査に重点を置きます
|
||||
- **ドキュメントモード**: ファイル操作を使用してドキュメントを作成しますが、システムコマンドは使用しません
|
||||
|
||||
また、さまざまなユースケースにさまざまなモデルが適していることがわかるかもしれません。
|
||||
|
|
@ -1,327 +0,0 @@
|
|||
---
|
||||
title: 모드
|
||||
description: 다양한 사용 사례를 위한 다양한 모드.
|
||||
---
|
||||
|
||||
:::caution
|
||||
모드는 opencode 설정에서 `agent` 옵션을 통해 구성되어 있습니다. 더 보기
|
||||
`mode` 옵션이 이제 비활성화되었습니다. [더 알아보기](/docs/agents).
|
||||
:::
|
||||
|
||||
opencode의 모드는 다른 사용 사례에 대한 행동, 도구 및 프롬프트를 사용자 정의 할 수 있습니다.
|
||||
|
||||
그것은 두 개의 내장 모드와 함께 제공됩니다 : ** 빌드 ** 및 ** 계획 **. 사용자 정의 할 수 있습니다.
|
||||
opencode config를 통해 자체를 구성합니다.
|
||||
|
||||
세션 중에 모드를 전환하거나 구성 파일에서 구성할 수 있습니다.
|
||||
|
||||
---
|
||||
|
||||
## 내장
|
||||
|
||||
opencode는 2개의 붙박이 형태로 옵니다.
|
||||
|
||||
---
|
||||
|
||||
### 빌드
|
||||
|
||||
빌드는 **default** 모드로 모든 도구가 활성화됩니다. 이것은 파일 운영 및 시스템 명령에 대한 전체 액세스가 필요한 개발 작업을위한 표준 모드입니다.
|
||||
|
||||
---
|
||||
|
||||
## 계획
|
||||
|
||||
계획 및 분석을 위해 설계된 제한 모드. 계획 모드에서 다음 도구는 기본적으로 비활성화됩니다:
|
||||
|
||||
- `write` - 새로운 파일을 만들 수 없습니다
|
||||
- `edit` - `.opencode/plans/*.md`에 위치한 파일을 제외하고 기존 파일을 수정할 수 없습니다.
|
||||
- `patch` - 패치 적용
|
||||
- `bash` - shell 명령을 실행할 수 없습니다
|
||||
|
||||
이 모드는 코드를 분석하기 위해 AI를 원할 때 유용합니다. 변경 사항을 제안하거나 코드베이스에 실제 수정없이 계획을 만들 수 있습니다.
|
||||
|
||||
---
|
||||
|
||||
## 전환
|
||||
|
||||
Tab 키를 사용하여 세션 중에 모드를 전환할 수 있습니다. 또는 당신의 형성된 `switch_mode` keybind.
|
||||
|
||||
참조 : [Formatters](/docs/formatters) 코드 형식 설정에 대한 정보.
|
||||
|
||||
---
|
||||
|
||||
## 구성
|
||||
|
||||
내장 모드를 사용자 정의하거나 구성을 통해 자신의 만들 수 있습니다. 형태는 2가지 방법으로 형성될 수 있습니다:
|
||||
|
||||
### JSON 구성
|
||||
|
||||
`opencode.json` 설정 파일에서 모드 구성:
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"build": {
|
||||
"model": "anthropic/claude-sonnet-4-20250514",
|
||||
"prompt": "{file:./prompts/build.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": true
|
||||
}
|
||||
},
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514",
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Markdown 구성
|
||||
|
||||
Markdown 파일을 사용하여 모드를 정의할 수 있습니다. 그들에 게:
|
||||
|
||||
- 글로벌: `~/.config/opencode/modes/`
|
||||
- 프로젝트: `.opencode/modes/`
|
||||
|
||||
```markdown title="~/.config/opencode/modes/review.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.1
|
||||
tools:
|
||||
write: false
|
||||
edit: false
|
||||
bash: false
|
||||
---
|
||||
|
||||
You are in code review mode. Focus on:
|
||||
|
||||
- Code quality and best practices
|
||||
- Potential bugs and edge cases
|
||||
- Performance implications
|
||||
- Security considerations
|
||||
|
||||
Provide constructive feedback without making direct changes.
|
||||
```
|
||||
|
||||
Markdown 파일 이름은 모드 이름 (예 : `review.md`는 `review` 모드를 만듭니다)이됩니다.
|
||||
|
||||
이 구성 옵션을 자세히 살펴봅시다.
|
||||
|
||||
---
|
||||
|
||||
### 모델
|
||||
|
||||
`model` config를 사용하여 이 모드의 기본 모델을 무시합니다. 다른 작업에 최적화 된 다른 모델을 사용하는 데 유용합니다. 예를 들어, 계획을위한 빠른 모델, 구현을위한 더 많은 모델.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 온도
|
||||
|
||||
`temperature` config와 AI의 응답의 임의성과 창의성을 제어합니다. 더 낮은 값은 더 집중하고 세심한 응답을 만듭니다. 더 높은 값은 창의력과 가변성을 증가하면서.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"temperature": 0.1
|
||||
},
|
||||
"creative": {
|
||||
"temperature": 0.8
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
온도 값은 일반적으로 0.0에서 1.0에 배열합니다:
|
||||
|
||||
- **0.0-0.2**: 매우 집중하고 신중한 응답, 코드 분석 및 계획에 이상 -**0.3-0.5**: 일부 창의력과 균형 잡힌 응답, 일반 개발 작업에 좋은
|
||||
- **0.6-1.0**: 더 창조적이고 다양한 응답, 브레인스토밍 및 탐험에 유용한
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"analyze": {
|
||||
"temperature": 0.1,
|
||||
"prompt": "{file:./prompts/analysis.txt}"
|
||||
},
|
||||
"build": {
|
||||
"temperature": 0.3
|
||||
},
|
||||
"brainstorm": {
|
||||
"temperature": 0.7,
|
||||
"prompt": "{file:./prompts/creative.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
온도가 지정되지 않은 경우, opencode는 모델별 기본 (일반적으로 0 대부분의 모델에 대한, 0.55 Qwen 모델)을 사용합니다.
|
||||
|
||||
---
|
||||
|
||||
#### 프롬프트
|
||||
|
||||
`prompt` config를 가진 이 형태를 위한 주문 체계 prompt 파일을 지정하십시오. prompt 파일은 모드의 목적에 특정한 지시를 포함해야 합니다.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"review": {
|
||||
"prompt": "{file:./prompts/code-review.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
이 경로는 config 파일이 있는 곳에 관계됩니다. 그래서이 작품
|
||||
글로벌 opencode config 및 프로젝트 특정 구성 모두.
|
||||
|
||||
---
|
||||
|
||||
## 도구
|
||||
|
||||
이 모드에서는 `tools` config를 사용할 수 있습니다. `true` 또는 `false`로 설정하여 특정 도구를 활성화하거나 비활성화 할 수 있습니다.
|
||||
|
||||
```json
|
||||
{
|
||||
"mode": {
|
||||
"readonly": {
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
도구가 지정되지 않은 경우, 모든 도구는 기본적으로 활성화됩니다.
|
||||
|
||||
---
|
||||
|
||||
### 유효한 도구
|
||||
|
||||
여기에 모든 도구는 모드 구성을 통해 제어 할 수 있습니다.
|
||||
|
||||
| 도구 | 설명 |
|
||||
| ----------- | --------------------- |
|
||||
| `bash` | shell 명령 실행 |
|
||||
| `edit` | 기존 파일 수정 |
|
||||
| `write` | 새 파일 만들기 |
|
||||
| `read` | 읽는 파일 내용 |
|
||||
| `grep` | 파일 검색 |
|
||||
| `glob` | 패턴으로 찾기 |
|
||||
| `patch` | 파일에 패치 적용 |
|
||||
| `todowrite` | 할 일(Todo) 목록 관리 |
|
||||
| `webfetch` | 웹사이트 가져오기 |
|
||||
|
||||
---
|
||||
|
||||
## 사용자 정의 모드
|
||||
|
||||
구성에 추가하여 사용자 정의 모드를 만들 수 있습니다. 여기에는 두 가지 접근법이 있습니다.
|
||||
|
||||
### JSON 구성 사용
|
||||
|
||||
```json title="opencode.json" {4-14}
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"docs": {
|
||||
"prompt": "{file:./prompts/documentation.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### markdown 파일 사용
|
||||
|
||||
프로젝트 별 모드 또는 `~/.config/opencode/modes/`의 모드 파일을 만들 수 있습니다.
|
||||
|
||||
```markdown title=".opencode/modes/debug.md"
|
||||
---
|
||||
temperature: 0.1
|
||||
tools:
|
||||
bash: true
|
||||
read: true
|
||||
grep: true
|
||||
write: false
|
||||
edit: false
|
||||
---
|
||||
|
||||
You are in debug mode. Your primary goal is to help investigate and diagnose issues.
|
||||
|
||||
Focus on:
|
||||
|
||||
- Understanding the problem through careful analysis
|
||||
- Using bash commands to inspect system state
|
||||
- Reading relevant files and logs
|
||||
- Searching for patterns and anomalies
|
||||
- Providing clear explanations of findings
|
||||
|
||||
Do not make any changes to files. Only investigate and report.
|
||||
```
|
||||
|
||||
```markdown title="~/.config/opencode/modes/refactor.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.2
|
||||
tools:
|
||||
edit: true
|
||||
read: true
|
||||
grep: true
|
||||
glob: true
|
||||
---
|
||||
|
||||
You are in refactoring mode. Focus on improving code quality without changing functionality.
|
||||
|
||||
Priorities:
|
||||
|
||||
- Improve code readability and maintainability
|
||||
- Apply consistent naming conventions
|
||||
- Reduce code duplication
|
||||
- Optimize performance where appropriate
|
||||
- Ensure all tests continue to pass
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 사용 사례
|
||||
|
||||
다음은 다른 모드에 대한 일반적인 사용 사례입니다.
|
||||
|
||||
- **Build 모드**: 모든 도구와 함께 전체 개발 작업
|
||||
- **Plan 모드**: 변화없이 분석 및 계획 -**Review 모드**: Code review with read-only access plus 문서 도구
|
||||
- **Debug 모드**: bash 및 읽기 도구와 함께 조사에 집중
|
||||
- **Docs 모드**: 파일 작업과 문서 작성하지만 시스템 명령 없음
|
||||
|
||||
다른 모델을 찾을 수 있습니다 다른 사용 케이스에 대 한 좋은.
|
||||
|
|
@ -1,329 +0,0 @@
|
|||
---
|
||||
title: Modes
|
||||
description: Different modes for different use cases.
|
||||
---
|
||||
|
||||
:::caution
|
||||
Modes are now configured through the `agent` option in the opencode config. The
|
||||
`mode` option is now deprecated. [Learn more](/docs/agents).
|
||||
:::
|
||||
|
||||
Modes in opencode allow you to customize the behavior, tools, and prompts for different use cases.
|
||||
|
||||
It comes with two built-in modes: **build** and **plan**. You can customize
|
||||
these or configure your own through the opencode config.
|
||||
|
||||
You can switch between modes during a session or configure them in your config file.
|
||||
|
||||
---
|
||||
|
||||
## Built-in
|
||||
|
||||
opencode comes with two built-in modes.
|
||||
|
||||
---
|
||||
|
||||
### Build
|
||||
|
||||
Build is the **default** mode with all tools enabled. This is the standard mode for development work where you need full access to file operations and system commands.
|
||||
|
||||
---
|
||||
|
||||
### Plan
|
||||
|
||||
A restricted mode designed for planning and analysis. In plan mode, the following tools are disabled by default:
|
||||
|
||||
- `write` - Cannot create new files
|
||||
- `edit` - Cannot modify existing files, except for files located at `.opencode/plans/*.md` to detail the plan itself
|
||||
- `patch` - Cannot apply patches
|
||||
- `bash` - Cannot execute shell commands
|
||||
|
||||
This mode is useful when you want the AI to analyze code, suggest changes, or create plans without making any actual modifications to your codebase.
|
||||
|
||||
---
|
||||
|
||||
## Switching
|
||||
|
||||
You can switch between modes during a session using the _Tab_ key. Or your configured `switch_mode` keybind.
|
||||
|
||||
See also: [Formatters](/docs/formatters) for information about code formatting configuration.
|
||||
|
||||
---
|
||||
|
||||
## Configure
|
||||
|
||||
You can customize the built-in modes or create your own through configuration. Modes can be configured in two ways:
|
||||
|
||||
### JSON Configuration
|
||||
|
||||
Configure modes in your `opencode.json` config file:
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"build": {
|
||||
"model": "anthropic/claude-sonnet-4-20250514",
|
||||
"prompt": "{file:./prompts/build.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": true
|
||||
}
|
||||
},
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514",
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Markdown Configuration
|
||||
|
||||
You can also define modes using markdown files. Place them in:
|
||||
|
||||
- Global: `~/.config/opencode/modes/`
|
||||
- Project: `.opencode/modes/`
|
||||
|
||||
```markdown title="~/.config/opencode/modes/review.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.1
|
||||
tools:
|
||||
write: false
|
||||
edit: false
|
||||
bash: false
|
||||
---
|
||||
|
||||
You are in code review mode. Focus on:
|
||||
|
||||
- Code quality and best practices
|
||||
- Potential bugs and edge cases
|
||||
- Performance implications
|
||||
- Security considerations
|
||||
|
||||
Provide constructive feedback without making direct changes.
|
||||
```
|
||||
|
||||
The markdown file name becomes the mode name (e.g., `review.md` creates a `review` mode).
|
||||
|
||||
Let's look at these configuration options in detail.
|
||||
|
||||
---
|
||||
|
||||
### Model
|
||||
|
||||
Use the `model` config to override the default model for this mode. Useful for using different models optimized for different tasks. For example, a faster model for planning, a more capable model for implementation.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Temperature
|
||||
|
||||
Control the randomness and creativity of the AI's responses with the `temperature` config. Lower values make responses more focused and deterministic, while higher values increase creativity and variability.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"temperature": 0.1
|
||||
},
|
||||
"creative": {
|
||||
"temperature": 0.8
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Temperature values typically range from 0.0 to 1.0:
|
||||
|
||||
- **0.0-0.2**: Very focused and deterministic responses, ideal for code analysis and planning
|
||||
- **0.3-0.5**: Balanced responses with some creativity, good for general development tasks
|
||||
- **0.6-1.0**: More creative and varied responses, useful for brainstorming and exploration
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"analyze": {
|
||||
"temperature": 0.1,
|
||||
"prompt": "{file:./prompts/analysis.txt}"
|
||||
},
|
||||
"build": {
|
||||
"temperature": 0.3
|
||||
},
|
||||
"brainstorm": {
|
||||
"temperature": 0.7,
|
||||
"prompt": "{file:./prompts/creative.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If no temperature is specified, opencode uses model-specific defaults (typically 0 for most models, 0.55 for Qwen models).
|
||||
|
||||
---
|
||||
|
||||
### Prompt
|
||||
|
||||
Specify a custom system prompt file for this mode with the `prompt` config. The prompt file should contain instructions specific to the mode's purpose.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"review": {
|
||||
"prompt": "{file:./prompts/code-review.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This path is relative to where the config file is located. So this works for
|
||||
both the global opencode config and the project specific config.
|
||||
|
||||
---
|
||||
|
||||
### Tools
|
||||
|
||||
Control which tools are available in this mode with the `tools` config. You can enable or disable specific tools by setting them to `true` or `false`.
|
||||
|
||||
```json
|
||||
{
|
||||
"mode": {
|
||||
"readonly": {
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If no tools are specified, all tools are enabled by default.
|
||||
|
||||
---
|
||||
|
||||
#### Available tools
|
||||
|
||||
Here are all the tools can be controlled through the mode config.
|
||||
|
||||
| Tool | Description |
|
||||
| ----------- | ---------------------- |
|
||||
| `bash` | Execute shell commands |
|
||||
| `edit` | Modify existing files |
|
||||
| `write` | Create new files |
|
||||
| `read` | Read file contents |
|
||||
| `grep` | Search file contents |
|
||||
| `glob` | Find files by pattern |
|
||||
| `patch` | Apply patches to files |
|
||||
| `todowrite` | Manage todo lists |
|
||||
| `webfetch` | Fetch web content |
|
||||
|
||||
---
|
||||
|
||||
## Custom modes
|
||||
|
||||
You can create your own custom modes by adding them to the configuration. Here are examples using both approaches:
|
||||
|
||||
### Using JSON configuration
|
||||
|
||||
```json title="opencode.json" {4-14}
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"docs": {
|
||||
"prompt": "{file:./prompts/documentation.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Using markdown files
|
||||
|
||||
Create mode files in `.opencode/modes/` for project-specific modes or `~/.config/opencode/modes/` for global modes:
|
||||
|
||||
```markdown title=".opencode/modes/debug.md"
|
||||
---
|
||||
temperature: 0.1
|
||||
tools:
|
||||
bash: true
|
||||
read: true
|
||||
grep: true
|
||||
write: false
|
||||
edit: false
|
||||
---
|
||||
|
||||
You are in debug mode. Your primary goal is to help investigate and diagnose issues.
|
||||
|
||||
Focus on:
|
||||
|
||||
- Understanding the problem through careful analysis
|
||||
- Using bash commands to inspect system state
|
||||
- Reading relevant files and logs
|
||||
- Searching for patterns and anomalies
|
||||
- Providing clear explanations of findings
|
||||
|
||||
Do not make any changes to files. Only investigate and report.
|
||||
```
|
||||
|
||||
```markdown title="~/.config/opencode/modes/refactor.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.2
|
||||
tools:
|
||||
edit: true
|
||||
read: true
|
||||
grep: true
|
||||
glob: true
|
||||
---
|
||||
|
||||
You are in refactoring mode. Focus on improving code quality without changing functionality.
|
||||
|
||||
Priorities:
|
||||
|
||||
- Improve code readability and maintainability
|
||||
- Apply consistent naming conventions
|
||||
- Reduce code duplication
|
||||
- Optimize performance where appropriate
|
||||
- Ensure all tests continue to pass
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Use cases
|
||||
|
||||
Here are some common use cases for different modes.
|
||||
|
||||
- **Build mode**: Full development work with all tools enabled
|
||||
- **Plan mode**: Analysis and planning without making changes
|
||||
- **Review mode**: Code review with read-only access plus documentation tools
|
||||
- **Debug mode**: Focused on investigation with bash and read tools enabled
|
||||
- **Docs mode**: Documentation writing with file operations but no system commands
|
||||
|
||||
You might also find different models are good for different use cases.
|
||||
|
|
@ -1,328 +0,0 @@
|
|||
---
|
||||
title: Moduser
|
||||
description: Ulike moduser for forskjellige brukstilfeller.
|
||||
---
|
||||
|
||||
:::caution
|
||||
Moduser konfigureres nå gjennom alternativet `agent` i OpenCode-konfigurasjonen.
|
||||
Alternativet `mode` er nå utdatert. [Finn ut mer](/docs/agents).
|
||||
:::
|
||||
|
||||
Moduser i OpenCode lar deg tilpasse oppførselen, verktøyene og prompter for ulike brukstilfeller.
|
||||
|
||||
Den kommer med to innebygde moduser: **bygg** og **plan**. Du kan tilpasse
|
||||
disse eller konfigurer din egen gjennom OpenCode-konfigurasjonen.
|
||||
|
||||
Du kan bytte mellom moduser under en økt eller konfigurere dem i konfigurasjonsfilen din.
|
||||
|
||||
---
|
||||
|
||||
## Innebygd
|
||||
|
||||
OpenCode kommer med to innebygde moduser.
|
||||
|
||||
---
|
||||
|
||||
### Bygg
|
||||
|
||||
Bygg er **standard**-modusen med alle verktøy aktivert. Dette er standardmodusen for utviklingsarbeid der du trenger full tilgang til filoperasjoner og systemkommandoer.
|
||||
|
||||
---
|
||||
|
||||
### Plan
|
||||
|
||||
En begrenset modus designet for planlegging og analyse. I planmodus er følgende verktøy deaktivert som standard:
|
||||
|
||||
- `write` - Kan ikke opprette nye filer
|
||||
- `edit` - Kan ikke endre eksisterende filer, bortsett fra filer som ligger på `.opencode/plans/*.md` for å detaljere selve planen
|
||||
- `patch` - Kan ikke bruke patcher
|
||||
- `bash` - Kan ikke utføre shell-kommandoer
|
||||
|
||||
Denne modusen er nyttig når du vil at AI skal analysere kode, foreslå endringer eller lage planer uten å gjøre noen faktiske endringer i kodebasen.
|
||||
|
||||
---
|
||||
|
||||
## Bytte
|
||||
|
||||
Du kan bytte mellom moduser under en økt ved å bruke _Tab_-tasten. Eller din konfigurerte `switch_mode` hurtigtast.
|
||||
|
||||
Se også: [Formatters](/docs/formatters) for informasjon om kodeformateringskonfigurasjon.
|
||||
|
||||
---
|
||||
|
||||
## Konfigurer
|
||||
|
||||
Du kan tilpasse de innebygde modusene eller opprette din egen gjennom konfigurasjon. Moduser kan konfigureres på to måter:
|
||||
|
||||
### JSON-konfigurasjon
|
||||
|
||||
Konfigurer moduser i din `opencode.json` konfigurasjonsfil:
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"build": {
|
||||
"model": "anthropic/claude-sonnet-4-20250514",
|
||||
"prompt": "{file:./prompts/build.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": true
|
||||
}
|
||||
},
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514",
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Markdown-konfigurasjon
|
||||
|
||||
Du kan også definere moduser ved hjelp av markdown-filer. Plasser dem i:
|
||||
|
||||
- Globalt: `~/.config/opencode/modes/`
|
||||
- Prosjekt: `.opencode/modes/`
|
||||
|
||||
```markdown title="~/.config/opencode/modes/review.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.1
|
||||
tools:
|
||||
write: false
|
||||
edit: false
|
||||
bash: false
|
||||
---
|
||||
|
||||
You are in code review mode. Focus on:
|
||||
|
||||
- Code quality and best practices
|
||||
- Potential bugs and edge cases
|
||||
- Performance implications
|
||||
- Security considerations
|
||||
|
||||
Provide constructive feedback without making direct changes.
|
||||
```
|
||||
|
||||
Filnavnet til markdown-filen blir modusnavnet (f.eks. `review.md` oppretter en `review`-modus).
|
||||
|
||||
La oss se på disse konfigurasjonsalternativene i detalj.
|
||||
|
||||
---
|
||||
|
||||
### Modell
|
||||
|
||||
Bruk `model`-konfigurasjonen for å overstyre standardmodellen for denne modusen. Nyttig for å bruke forskjellige modeller optimalisert for forskjellige oppgaver. For eksempel en raskere modell for planlegging, en mer kapabel modell for implementering.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Temperatur
|
||||
|
||||
Kontroller tilfeldigheten og kreativiteten til AI-ens svar med `temperature`-konfigurasjonen. Lavere verdier gjør svarene mer fokuserte og deterministiske, mens høyere verdier øker kreativiteten og variasjonen.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"temperature": 0.1
|
||||
},
|
||||
"creative": {
|
||||
"temperature": 0.8
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Temperaturverdier varierer vanligvis fra 0,0 til 1,0:
|
||||
|
||||
- **0.0-0.2**: Veldig fokuserte og deterministiske svar, ideelt for kodeanalyse og planlegging
|
||||
- **0.3-0.5**: Balanserte svar med litt kreativitet, bra for generelle utviklingsoppgaver
|
||||
- **0.6-1.0**: Mer kreative og varierte svar, nyttig for idédugnad og utforskning
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"analyze": {
|
||||
"temperature": 0.1,
|
||||
"prompt": "{file:./prompts/analysis.txt}"
|
||||
},
|
||||
"build": {
|
||||
"temperature": 0.3
|
||||
},
|
||||
"brainstorm": {
|
||||
"temperature": 0.7,
|
||||
"prompt": "{file:./prompts/creative.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Hvis ingen temperatur er spesifisert, bruker OpenCode modellspesifikke standardinnstillinger (vanligvis 0 for de fleste modeller, 0,55 for Qwen-modeller).
|
||||
|
||||
---
|
||||
|
||||
### Prompt
|
||||
|
||||
Angi en tilpasset systemprompt-fil for denne modusen med `prompt`-konfigurasjonen. Prompt-filen skal inneholde instruksjoner som er spesifikke for modusens formål.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"review": {
|
||||
"prompt": "{file:./prompts/code-review.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Denne banen er relativ til der konfigurasjonsfilen er plassert. Så dette fungerer for både den globale OpenCode-konfigurasjonen og den prosjektspesifikke konfigurasjonen.
|
||||
|
||||
---
|
||||
|
||||
### Verktøy
|
||||
|
||||
Kontroller hvilke verktøy som er tilgjengelige i denne modusen med `tools`-konfigurasjonen. Du kan aktivere eller deaktivere spesifikke verktøy ved å sette dem til `true` eller `false`.
|
||||
|
||||
```json
|
||||
{
|
||||
"mode": {
|
||||
"readonly": {
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Hvis ingen verktøy er spesifisert, er alle verktøy aktivert som standard.
|
||||
|
||||
---
|
||||
|
||||
#### Tilgjengelige verktøy
|
||||
|
||||
Her er alle verktøyene som kan kontrolleres gjennom moduskonfigurasjonen.
|
||||
|
||||
| Verktøy | Beskrivelse |
|
||||
| ----------- | --------------------------- |
|
||||
| `bash` | Utfør shell-kommandoer |
|
||||
| `edit` | Endre eksisterende filer |
|
||||
| `write` | Opprett nye filer |
|
||||
| `read` | Les filinnhold |
|
||||
| `grep` | Søk i filinnhold |
|
||||
| `glob` | Finn filer etter mønster |
|
||||
| `patch` | Bruk patcher på filer |
|
||||
| `todowrite` | Administrer gjøremålslister |
|
||||
| `webfetch` | Hent webinnhold |
|
||||
|
||||
---
|
||||
|
||||
## Egendefinerte moduser
|
||||
|
||||
Du kan opprette dine egne tilpassede moduser ved å legge dem til i konfigurasjonen. Her er eksempler på bruk av begge metodene:
|
||||
|
||||
### Bruke JSON-konfigurasjon
|
||||
|
||||
```json title="opencode.json" {4-14}
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"docs": {
|
||||
"prompt": "{file:./prompts/documentation.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Bruke markdown-filer
|
||||
|
||||
Opprett modusfiler i `.opencode/modes/` for prosjektspesifikke moduser eller `~/.config/opencode/modes/` for globale moduser:
|
||||
|
||||
```markdown title=".opencode/modes/debug.md"
|
||||
---
|
||||
temperature: 0.1
|
||||
tools:
|
||||
bash: true
|
||||
read: true
|
||||
grep: true
|
||||
write: false
|
||||
edit: false
|
||||
---
|
||||
|
||||
You are in debug mode. Your primary goal is to help investigate and diagnose issues.
|
||||
|
||||
Focus on:
|
||||
|
||||
- Understanding the problem through careful analysis
|
||||
- Using bash commands to inspect system state
|
||||
- Reading relevant files and logs
|
||||
- Searching for patterns and anomalies
|
||||
- Providing clear explanations of findings
|
||||
|
||||
Do not make any changes to files. Only investigate and report.
|
||||
```
|
||||
|
||||
```markdown title="~/.config/opencode/modes/refactor.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.2
|
||||
tools:
|
||||
edit: true
|
||||
read: true
|
||||
grep: true
|
||||
glob: true
|
||||
---
|
||||
|
||||
You are in refactoring mode. Focus on improving code quality without changing functionality.
|
||||
|
||||
Priorities:
|
||||
|
||||
- Improve code readability and maintainability
|
||||
- Apply consistent naming conventions
|
||||
- Reduce code duplication
|
||||
- Optimize performance where appropriate
|
||||
- Ensure all tests continue to pass
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Bruksområder
|
||||
|
||||
Her er noen vanlige bruksområder for forskjellige moduser.
|
||||
|
||||
- **Bygg-modus**: Fullt utviklingsarbeid med alle verktøy aktivert
|
||||
- **Plan-modus**: Analyse og planlegging uten å gjøre endringer
|
||||
- **Review-modus**: Kodegjennomgang med skrivebeskyttet tilgang pluss dokumentasjonsverktøy
|
||||
- **Debug-modus**: Fokusert på etterforskning med bash- og leseverktøy aktivert
|
||||
- **Docs-modus**: Dokumentasjonsskriving med filoperasjoner, men ingen systemkommandoer
|
||||
|
||||
Du kan også finne at forskjellige modeller er gode for forskjellige bruksområder.
|
||||
|
|
@ -1,329 +0,0 @@
|
|||
---
|
||||
title: Tryby
|
||||
description: Różne tryby dla różnych zastosowań.
|
||||
---
|
||||
|
||||
:::caution
|
||||
Tryby są teraz konfigurowane za pomocą opcji `agent` w konfiguracji opencode.
|
||||
Opcja `mode` jest obecnie przestarzała. [Dowiedz się więcej](/docs/agents).
|
||||
:::
|
||||
|
||||
Tryb udostępniania możliwości stosowania, narzędzie i podpowiedzi do różnych zastosowań.
|
||||
|
||||
Posiadanie dwa tryby: **Build** i **Plan**. Można dostosować
|
||||
te lub skonfiguruj własne za pomocą konfiguracji opencode.
|
||||
|
||||
Można przełączać się między trybami podczas sesji lub konfigurować je w pliku konfiguracyjnym.
|
||||
|
||||
---
|
||||
|
||||
## Wbudowane
|
||||
|
||||
opencode ma dwa puste tryby.
|
||||
|
||||
---
|
||||
|
||||
### Build
|
||||
|
||||
Build jest trybem **domyślnym** z dostępnymi narzędziami. Jest to standardowy tryb pracy programistycznej, który jest dostępny z pełnym dostępem do operacji na plikach i oryginalnych systemach systemowych.
|
||||
|
||||
---
|
||||
|
||||
### Plan
|
||||
|
||||
Tryb ograniczony do analizy. W urządzeniu planowym narzędzia są przydatne:
|
||||
|
||||
- `write` - Nie można stworzyć nowych plików
|
||||
- `edit` — Nie można zastosować naruszenia plików, z naruszeniem praw autorskich w `.opencode/plans/*.md` w celu uszczegółowienia samego planu
|
||||
- `patch` - Nie można zastosować poprawek
|
||||
- `bash` - Nie można wykonać poleceń shell
|
||||
|
||||
Ten tryb jest alternatywny, gdy chcesz, aby sztuczna inteligencja analizowała kod, sugerowała zmianę lub tworzyła projekty bez źródła zewnętrznego, które stanowi bazę kodu.
|
||||
|
||||
---
|
||||
|
||||
## Przełączanie
|
||||
|
||||
Możesz przełączać się między trybami podczas sesji za pomocą klawisza _Tab_. Lub skrót klawiszowy `switch_mode`.
|
||||
|
||||
Zobacz także: [Formaterzy](/docs/formatters), aby uzyskać informacje na temat konfiguracji formatowania kodu.
|
||||
|
||||
---
|
||||
|
||||
## Skonfiguruj
|
||||
|
||||
Możliwość dostosowania alternatywnego trybu lub konfiguracji poprzez własną konfigurację. Tryb można skonfigurować na dwa systemy:
|
||||
|
||||
### Konfiguracja JSON
|
||||
|
||||
Skonfiguruj tryb w pliku konfiguracyjnym `opencode.json`:
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"build": {
|
||||
"model": "anthropic/claude-sonnet-4-20250514",
|
||||
"prompt": "{file:./prompts/build.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": true
|
||||
}
|
||||
},
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514",
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Konfiguracja Markdown
|
||||
|
||||
Można także definiować tryby za pomocą plików przecen. Trzymaj je w:
|
||||
|
||||
- Globalnie: `~/.config/opencode/modes/`
|
||||
- Projekt: `.opencode/modes/`
|
||||
|
||||
```markdown title="~/.config/opencode/modes/review.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.1
|
||||
tools:
|
||||
write: false
|
||||
edit: false
|
||||
bash: false
|
||||
---
|
||||
|
||||
You are in code review mode. Focus on:
|
||||
|
||||
- Code quality and best practices
|
||||
- Potential bugs and edge cases
|
||||
- Performance implications
|
||||
- Security considerations
|
||||
|
||||
Provide constructive feedback without making direct changes.
|
||||
```
|
||||
|
||||
Nazwa pliku przecen staje się kluczem trybu (np. `review.md` tworzy tryb `review`).
|
||||
|
||||
Przyjrzyjmy się szczegółowo tym opcjom konfiguracji.
|
||||
|
||||
---
|
||||
|
||||
### Model
|
||||
|
||||
Zastosowanie konstrukcji `model`, aby zastosować domyślny model dla tego trybu. Przydatne przy wykorzystaniu różnych modeli dostępnych w różnych zadaniach. Na przykład zastosowanie modelu, skuteczniejsze wykonanie modelu.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Temperatura
|
||||
|
||||
Kontroluj losowość i kreatywność reakcji AI za pomocą konstrukcji `temperature`. Niższe wartości, że odpowiedzi są bardziej skupione i deterministyczne, podczas gdy najwyższa wartość jest innowacyjna i złożona.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"temperature": 0.1
|
||||
},
|
||||
"creative": {
|
||||
"temperature": 0.8
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Wartości temperatury zazwyczaj wahają się od 0,0 do 1,0:
|
||||
|
||||
- **0,0-0,2**: Bardzo skoncentrowane i deterministyczne odpowiedzi, idealne do analizy i kodu źródłowego
|
||||
- **0,3-0,5**: Zrównoważona odpowiedź z chwilą powstania, dobre do ogólnych zadań rozwojowych
|
||||
- **0,6–1,0**: Bardziej kreatywne i odpowiedzi, rozstrzygnięte podczas burzy mózgów i eksploracji
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"analyze": {
|
||||
"temperature": 0.1,
|
||||
"prompt": "{file:./prompts/analysis.txt}"
|
||||
},
|
||||
"build": {
|
||||
"temperature": 0.3
|
||||
},
|
||||
"brainstorm": {
|
||||
"temperature": 0.7,
|
||||
"prompt": "{file:./prompts/creative.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Jeśli nie ma wpływu na temperaturę, opencode stosuje się narzędzia badawcze dla modelu (zwykle 0 dla największych modeli, 0,55 dla modeli Qwen).
|
||||
|
||||
---
|
||||
|
||||
### Prompt (Monit)
|
||||
|
||||
niestandardowy plik podpowiedzi systemowych dla tej procedury za pomocą konfiguracji `prompt`. Plik informacyjny powinien zawierać instrukcje dotyczące przeznaczenia trybu.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"review": {
|
||||
"prompt": "{file:./prompts/code-review.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Ścieżka ta zależy od miejsca, w którym znajduje się plik konfiguracyjny. Więc to dla działa
|
||||
zarówno globalna opencode, jak i specjalna dla projektu.
|
||||
|
||||
---
|
||||
|
||||
### Narzędzia
|
||||
|
||||
Kontroluj, które narzędzia są dostępne w tym urządzeniu, za pomocą konfiguracji `tools`. Można włączyć lub dostępne narzędzie, ustawiając je na `true` lub `false`.
|
||||
|
||||
```json
|
||||
{
|
||||
"mode": {
|
||||
"readonly": {
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Jeśli nie ma żadnych narzędzi, wszystkie narzędzia są wyłączone.
|
||||
|
||||
---
|
||||
|
||||
#### Dostępne narzędzia
|
||||
|
||||
Oto wszystkie narzędzia, które można sterować za pomocą konfiguracji trybów.
|
||||
|
||||
| Narzędzie | Opis |
|
||||
| ----------- | ------------------------------------- |
|
||||
| `bash` | Wykonaj polecenia shell |
|
||||
| `edit` | Modyfikuj istniejące pliki |
|
||||
| `write` | Utwórz nowe pliki |
|
||||
| `read` | Przeczytaj zawartość pliku |
|
||||
| `grep` | Wyszukaj zawartość pliku |
|
||||
| `glob` | Znajdź pliki według wzorca |
|
||||
| `patch` | Zastosuj poprawki do plików |
|
||||
| `todowrite` | Zarządzaj listami rzeczy do wykonania |
|
||||
| `webfetch` | Pobierz zawartość internetową |
|
||||
|
||||
---
|
||||
|
||||
## Tryby niestandardowe
|
||||
|
||||
Możesz stworzyć własny tryb prywatny, dodając je do konfiguracji. Oto zastosowanie obu rozwiązań:
|
||||
|
||||
### Korzystanie z konfiguracji JSON
|
||||
|
||||
```json title="opencode.json" {4-14}
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"docs": {
|
||||
"prompt": "{file:./prompts/documentation.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Korzystanie z plików Markdown
|
||||
|
||||
Utwórz pliki trybów w `.opencode/modes/` dla trybów zapisanych dla projektu lub `~/.config/opencode/modes/` dla trybów globalnych:
|
||||
|
||||
```markdown title=".opencode/modes/debug.md"
|
||||
---
|
||||
temperature: 0.1
|
||||
tools:
|
||||
bash: true
|
||||
read: true
|
||||
grep: true
|
||||
write: false
|
||||
edit: false
|
||||
---
|
||||
|
||||
You are in debug mode. Your primary goal is to help investigate and diagnose issues.
|
||||
|
||||
Focus on:
|
||||
|
||||
- Understanding the problem through careful analysis
|
||||
- Using bash commands to inspect system state
|
||||
- Reading relevant files and logs
|
||||
- Searching for patterns and anomalies
|
||||
- Providing clear explanations of findings
|
||||
|
||||
Do not make any changes to files. Only investigate and report.
|
||||
```
|
||||
|
||||
```markdown title="~/.config/opencode/modes/refactor.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.2
|
||||
tools:
|
||||
edit: true
|
||||
read: true
|
||||
grep: true
|
||||
glob: true
|
||||
---
|
||||
|
||||
You are in refactoring mode. Focus on improving code quality without changing functionality.
|
||||
|
||||
Priorities:
|
||||
|
||||
- Improve code readability and maintainability
|
||||
- Apply consistent naming conventions
|
||||
- Reduce code duplication
|
||||
- Optimize performance where appropriate
|
||||
- Ensure all tests continue to pass
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Przypadki użycia
|
||||
|
||||
Oto kilka typowych zastosowań dla różnych trybów.
|
||||
|
||||
- **Build mode**: Pełne prace programistyczne z dostępnymi narzędziami
|
||||
- **Plan mode**: Analiza i planowanie bez zmian
|
||||
- **Review mode**: Przegląd kodu z możliwością odczytu i narzędzi do dokumentacji
|
||||
- **Debug mode**: Koncentruje się na urządzeniu z dostępnymi narzędziami bash i odczytu
|
||||
- **Docs mode**: Zapisywanie dokumentacji przy użyciu operacji na plikach, ale bez oryginalnych systemów systemowych
|
||||
|
||||
Może się również zdarzyć, że różne modele są dobre w różnych wersjach użycia.
|
||||
|
|
@ -1,326 +0,0 @@
|
|||
---
|
||||
title: Modos
|
||||
description: Modos diferentes para diferentes casos de uso.
|
||||
---
|
||||
|
||||
:::caution
|
||||
Os modos agora são configurados através da opção `agent` na configuração do opencode. A opção `mode` agora está obsoleta. [Saiba mais](/docs/agents).
|
||||
:::
|
||||
|
||||
Os modos no opencode permitem que você personalize o comportamento, as ferramentas e os prompts para diferentes casos de uso.
|
||||
|
||||
Ele vem com dois modos integrados: **build** e **plan**. Você pode personalizar esses ou configurar os seus próprios através da configuração do opencode.
|
||||
|
||||
Você pode alternar entre os modos durante uma sessão ou configurá-los no seu arquivo de configuração.
|
||||
|
||||
---
|
||||
|
||||
## Integrados
|
||||
|
||||
O opencode vem com dois modos integrados.
|
||||
|
||||
---
|
||||
|
||||
### build
|
||||
|
||||
Build é o modo **padrão** com todas as ferramentas habilitadas. Este é o modo padrão para trabalho de desenvolvimento onde você precisa de acesso total a operações de arquivos e comandos do sistema.
|
||||
|
||||
---
|
||||
|
||||
### plan
|
||||
|
||||
Um modo restrito projetado para planejamento e análise. No modo plan, as seguintes ferramentas estão desativadas por padrão:
|
||||
|
||||
- `write` - Não pode criar novos arquivos
|
||||
- `edit` - Não pode modificar arquivos existentes, exceto para arquivos localizados em `.opencode/plans/*.md` para detalhar o plano em si
|
||||
- `patch` - Não pode aplicar patches
|
||||
- `bash` - Não pode executar comandos de shell
|
||||
|
||||
Este modo é útil quando você deseja que a IA analise o código, sugira alterações ou crie planos sem fazer modificações reais em sua base de código.
|
||||
|
||||
---
|
||||
|
||||
## Alternando
|
||||
|
||||
Você pode alternar entre modos durante uma sessão usando a tecla _Tab_. Ou sua tecla de atalho configurada `switch_mode`.
|
||||
|
||||
Veja também: [Formatadores](/docs/formatters) para informações sobre configuração de formatação de código.
|
||||
|
||||
---
|
||||
|
||||
## Configuração
|
||||
|
||||
Você pode personalizar os modos integrados ou criar os seus próprios através da configuração. Os modos podem ser configurados de duas maneiras:
|
||||
|
||||
### Configuração JSON
|
||||
|
||||
Configure os modos no seu arquivo de configuração `opencode.json`:
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"build": {
|
||||
"model": "anthropic/claude-sonnet-4-20250514",
|
||||
"prompt": "{file:./prompts/build.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": true
|
||||
}
|
||||
},
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514",
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Configuração Markdown
|
||||
|
||||
Você também pode definir modos usando arquivos markdown. Coloque-os em:
|
||||
|
||||
- Global: `~/.config/opencode/modes/`
|
||||
- Projeto: `.opencode/modes/`
|
||||
|
||||
```markdown title="~/.config/opencode/modes/review.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.1
|
||||
tools:
|
||||
write: false
|
||||
edit: false
|
||||
bash: false
|
||||
---
|
||||
|
||||
You are in code review mode. Focus on:
|
||||
|
||||
- Code quality and best practices
|
||||
- Potential bugs and edge cases
|
||||
- Performance implications
|
||||
- Security considerations
|
||||
|
||||
Provide constructive feedback without making direct changes.
|
||||
```
|
||||
|
||||
O nome do arquivo markdown se torna o nome do modo (por exemplo, `review.md` cria um modo `review`).
|
||||
|
||||
Vamos analisar essas opções de configuração em detalhes.
|
||||
|
||||
---
|
||||
|
||||
### Modelo
|
||||
|
||||
Use a configuração `model` para substituir o modelo padrão para este modo. Útil para usar diferentes modelos otimizados para diferentes tarefas. Por exemplo, um modelo mais rápido para planejamento, um modelo mais capaz para implementação.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Temperatura
|
||||
|
||||
Controle a aleatoriedade e a criatividade das respostas da IA com a configuração `temperature`. Valores mais baixos tornam as respostas mais focadas e determinísticas, enquanto valores mais altos aumentam a criatividade e a variabilidade.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"temperature": 0.1
|
||||
},
|
||||
"creative": {
|
||||
"temperature": 0.8
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Os valores de temperatura geralmente variam de 0.0 a 1.0:
|
||||
|
||||
- **0.0-0.2**: Respostas muito focadas e determinísticas, ideais para análise de código e planejamento
|
||||
- **0.3-0.5**: Respostas equilibradas com alguma criatividade, boas para tarefas de desenvolvimento geral
|
||||
- **0.6-1.0**: Respostas mais criativas e variadas, úteis para brainstorming e exploração
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"analyze": {
|
||||
"temperature": 0.1,
|
||||
"prompt": "{file:./prompts/analysis.txt}"
|
||||
},
|
||||
"build": {
|
||||
"temperature": 0.3
|
||||
},
|
||||
"brainstorm": {
|
||||
"temperature": 0.7,
|
||||
"prompt": "{file:./prompts/creative.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Se nenhuma temperatura for especificada, o opencode usa padrões específicos do modelo (geralmente 0 para a maioria dos modelos, 0.55 para modelos Qwen).
|
||||
|
||||
---
|
||||
|
||||
### Prompt
|
||||
|
||||
Especifique um arquivo de prompt do sistema personalizado para este modo com a configuração `prompt`. O arquivo de prompt deve conter instruções específicas para o propósito do modo.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"review": {
|
||||
"prompt": "{file:./prompts/code-review.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Este caminho é relativo a onde o arquivo de configuração está localizado. Portanto, isso funciona tanto para a configuração global do opencode quanto para a configuração específica do projeto.
|
||||
|
||||
---
|
||||
|
||||
### Ferramentas
|
||||
|
||||
Controle quais ferramentas estão disponíveis neste modo com a configuração `tools`. Você pode habilitar ou desabilitar ferramentas específicas definindo-as como `true` ou `false`.
|
||||
|
||||
```json
|
||||
{
|
||||
"mode": {
|
||||
"readonly": {
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Se nenhuma ferramenta for especificada, todas as ferramentas estão habilitadas por padrão.
|
||||
|
||||
---
|
||||
|
||||
#### Ferramentas disponíveis
|
||||
|
||||
Aqui estão todas as ferramentas que podem ser controladas através da configuração do modo.
|
||||
|
||||
| Ferramenta | Descrição |
|
||||
| ----------- | ------------------------------- |
|
||||
| `bash` | Executar comandos de shell |
|
||||
| `edit` | Modificar arquivos existentes |
|
||||
| `write` | Criar novos arquivos |
|
||||
| `read` | Ler conteúdos de arquivos |
|
||||
| `grep` | Pesquisar conteúdos de arquivos |
|
||||
| `glob` | Encontrar arquivos por padrão |
|
||||
| `patch` | Aplicar patches a arquivos |
|
||||
| `todowrite` | Gerenciar listas de tarefas |
|
||||
| `webfetch` | Buscar conteúdo da web |
|
||||
|
||||
---
|
||||
|
||||
## Modos personalizados
|
||||
|
||||
Você pode criar seus próprios modos personalizados adicionando-os à configuração. Aqui estão exemplos usando ambas as abordagens:
|
||||
|
||||
### Usando configuração JSON
|
||||
|
||||
```json title="opencode.json" {4-14}
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"docs": {
|
||||
"prompt": "{file:./prompts/documentation.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Usando arquivos markdown
|
||||
|
||||
Crie arquivos de modo em `.opencode/modes/` para modos específicos do projeto ou `~/.config/opencode/modes/` para modos globais:
|
||||
|
||||
```markdown title=".opencode/modes/debug.md"
|
||||
---
|
||||
temperature: 0.1
|
||||
tools:
|
||||
bash: true
|
||||
read: true
|
||||
grep: true
|
||||
write: false
|
||||
edit: false
|
||||
---
|
||||
|
||||
You are in debug mode. Your primary goal is to help investigate and diagnose issues.
|
||||
|
||||
Focus on:
|
||||
|
||||
- Understanding the problem through careful analysis
|
||||
- Using bash commands to inspect system state
|
||||
- Reading relevant files and logs
|
||||
- Searching for patterns and anomalies
|
||||
- Providing clear explanations of findings
|
||||
|
||||
Do not make any changes to files. Only investigate and report.
|
||||
```
|
||||
|
||||
```markdown title="~/.config/opencode/modes/refactor.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.2
|
||||
tools:
|
||||
edit: true
|
||||
read: true
|
||||
grep: true
|
||||
glob: true
|
||||
---
|
||||
|
||||
You are in refactoring mode. Focus on improving code quality without changing functionality.
|
||||
|
||||
Priorities:
|
||||
|
||||
- Improve code readability and maintainability
|
||||
- Apply consistent naming conventions
|
||||
- Reduce code duplication
|
||||
- Optimize performance where appropriate
|
||||
- Ensure all tests continue to pass
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Casos de uso
|
||||
|
||||
Aqui estão alguns casos de uso comuns para diferentes modos.
|
||||
|
||||
- **Modo Build**: Trabalho de desenvolvimento completo com todas as ferramentas habilitadas
|
||||
- **Modo Plan**: Análise e planejamento sem fazer alterações
|
||||
- **Modo Review**: Revisão de código com acesso somente leitura e ferramentas de documentação
|
||||
- **Modo Debug**: Focado em investigação com ferramentas bash e de leitura habilitadas
|
||||
- **Modo Docs**: Redação de documentação com operações de arquivo, mas sem comandos do sistema
|
||||
|
||||
Você também pode descobrir que diferentes modelos são bons para diferentes casos de uso.
|
||||
|
|
@ -1,329 +0,0 @@
|
|||
---
|
||||
title: Режимы
|
||||
description: Различные режимы для разных случаев использования.
|
||||
---
|
||||
|
||||
:::caution
|
||||
Режимы теперь настраиваются с помощью опции `agent` в конфигурации opencode.
|
||||
Опция `mode` устарела. [Подробнее ](/docs/agents).
|
||||
:::
|
||||
|
||||
Режимы в opencode позволяют настраивать поведение, инструменты и подсказки для различных вариантов использования.
|
||||
|
||||
Он имеет два встроенных режима: **сборка** и **планирование**. Вы можете настроить
|
||||
эти или настройте свои собственные через конфигурацию opencode.
|
||||
|
||||
Вы можете переключаться между режимами во время сеанса или настраивать их в своем файле конфигурации.
|
||||
|
||||
---
|
||||
|
||||
## Встроенный
|
||||
|
||||
opencode имеет два встроенных режима.
|
||||
|
||||
---
|
||||
|
||||
### Build
|
||||
|
||||
Build — это режим **по умолчанию** со всеми включенными инструментами. Это стандартный режим разработки, в котором вам необходим полный доступ к файловым операциям и системным командам.
|
||||
|
||||
---
|
||||
|
||||
### Plan
|
||||
|
||||
Ограниченный режим, предназначенный для планирования и анализа. В режиме Plan по умолчанию отключены следующие инструменты:
|
||||
|
||||
- `write` – невозможно создавать новые файлы.
|
||||
- `edit` – невозможно изменить существующие файлы, за исключением файлов, расположенных по адресу `.opencode/plans/*.md`, для детализации самого плана.
|
||||
- `patch` – невозможно применить исправления.
|
||||
- `bash` — невозможно выполнить shell-команды.
|
||||
|
||||
Этот режим полезен, если вы хотите, чтобы ИИ анализировал код, предлагал изменения или создавал планы без внесения каких-либо фактических изменений в вашу кодовую базу.
|
||||
|
||||
---
|
||||
|
||||
## Переключение
|
||||
|
||||
Переключаться между режимами можно во время сеанса с помощью клавиши _Tab_. Или настроенную вами привязку клавиш `switch_mode`.
|
||||
|
||||
См. также: [Formatters](/docs/formatters) для получения информации о конфигурации форматирования кода.
|
||||
|
||||
---
|
||||
|
||||
## Настроить
|
||||
|
||||
Вы можете настроить встроенные режимы или создать свои собственные посредством настройки. Режимы можно настроить двумя способами:
|
||||
|
||||
### Конфигурация JSON
|
||||
|
||||
Настройте режимы в файле конфигурации `opencode.json`:
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"build": {
|
||||
"model": "anthropic/claude-sonnet-4-20250514",
|
||||
"prompt": "{file:./prompts/build.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": true
|
||||
}
|
||||
},
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514",
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Конфигурация Markdown
|
||||
|
||||
Вы также можете определить режимы, используя файлы Markdown. Поместите их в:
|
||||
|
||||
- Глобальный: `~/.config/opencode/modes/`
|
||||
- Проект: `.opencode/modes/`
|
||||
|
||||
```markdown title="~/.config/opencode/modes/review.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.1
|
||||
tools:
|
||||
write: false
|
||||
edit: false
|
||||
bash: false
|
||||
---
|
||||
|
||||
You are in code review mode. Focus on:
|
||||
|
||||
- Code quality and best practices
|
||||
- Potential bugs and edge cases
|
||||
- Performance implications
|
||||
- Security considerations
|
||||
|
||||
Provide constructive feedback without making direct changes.
|
||||
```
|
||||
|
||||
Имя Markdown файла становится именем режима (например, `review.md` создает режим `review`).
|
||||
|
||||
Давайте рассмотрим эти параметры конфигурации подробно.
|
||||
|
||||
---
|
||||
|
||||
### Модель
|
||||
|
||||
Используйте конфигурацию `model`, чтобы переопределить модель по умолчанию для этого режима. Полезно для использования разных моделей, оптимизированных под разные задачи. Например, более быстрая модель планирования и более эффективная модель реализации.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Температура
|
||||
|
||||
Управляйте случайностью и креативностью ответов ИИ с помощью конфигурации `temperature`. Более низкие значения делают ответы более целенаправленными и детерминированными, а более высокие значения повышают креативность и вариативность.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"temperature": 0.1
|
||||
},
|
||||
"creative": {
|
||||
"temperature": 0.8
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Значения температуры обычно находятся в диапазоне от 0,0 до 1,0:
|
||||
|
||||
- **0,0–0,2**: очень целенаправленные и детерминированные ответы, идеальные для анализа кода и планирования.
|
||||
- **0,3–0,5**: сбалансированные ответы с некоторой креативностью, подходят для общих задач развития.
|
||||
- **0,6–1,0**: более творческие и разнообразные ответы, полезные для мозгового штурма и исследования.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"analyze": {
|
||||
"temperature": 0.1,
|
||||
"prompt": "{file:./prompts/analysis.txt}"
|
||||
},
|
||||
"build": {
|
||||
"temperature": 0.3
|
||||
},
|
||||
"brainstorm": {
|
||||
"temperature": 0.7,
|
||||
"prompt": "{file:./prompts/creative.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Если температура не указана, opencode использует значения по умолчанию для конкретной модели (обычно 0 для большинства моделей, 0,55 для моделей Qwen).
|
||||
|
||||
---
|
||||
|
||||
### Промпт
|
||||
|
||||
Укажите собственный файл системных подсказок для этого режима с помощью конфигурации `prompt`. Файл подсказки должен содержать инструкции, специфичные для целей режима.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"review": {
|
||||
"prompt": "{file:./prompts/code-review.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Этот путь указан относительно того, где находится файл конфигурации. Так что это работает для
|
||||
как глобальная конфигурация opencode, так и конфигурация конкретного проекта.
|
||||
|
||||
---
|
||||
|
||||
### Инструменты
|
||||
|
||||
Контролируйте, какие инструменты доступны в этом режиме, с помощью конфигурации `tools`. Вы можете включить или отключить определенные инструменты, установив для них значение `true` или `false`.
|
||||
|
||||
```json
|
||||
{
|
||||
"mode": {
|
||||
"readonly": {
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Если инструменты не указаны, все инструменты включены по умолчанию.
|
||||
|
||||
---
|
||||
|
||||
#### Доступные инструменты
|
||||
|
||||
Вот всеми инструментами можно управлять через конфигурацию режима.
|
||||
|
||||
| Инструмент | Описание |
|
||||
| ----------- | ---------------------- |
|
||||
| `bash` | Execute shell commands |
|
||||
| `edit` | Modify existing files |
|
||||
| `write` | Create new files |
|
||||
| `read` | Read file contents |
|
||||
| `grep` | Search file contents |
|
||||
| `glob` | Find files by pattern |
|
||||
| `patch` | Apply patches to files |
|
||||
| `todowrite` | Manage todo lists |
|
||||
| `webfetch` | Fetch web content |
|
||||
|
||||
---
|
||||
|
||||
## Пользовательские режимы
|
||||
|
||||
Вы можете создавать свои собственные режимы, добавляя их в конфигурацию. Вот примеры использования обоих подходов:
|
||||
|
||||
### Использование конфигурации JSON
|
||||
|
||||
```json title="opencode.json" {4-14}
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"docs": {
|
||||
"prompt": "{file:./prompts/documentation.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Использование файлов Markdown
|
||||
|
||||
Создайте файлы режимов в `.opencode/modes/` для режимов, специфичных для проекта, или в `~/.config/opencode/modes/` для глобальных режимов:
|
||||
|
||||
```markdown title=".opencode/modes/debug.md"
|
||||
---
|
||||
temperature: 0.1
|
||||
tools:
|
||||
bash: true
|
||||
read: true
|
||||
grep: true
|
||||
write: false
|
||||
edit: false
|
||||
---
|
||||
|
||||
You are in debug mode. Your primary goal is to help investigate and diagnose issues.
|
||||
|
||||
Focus on:
|
||||
|
||||
- Understanding the problem through careful analysis
|
||||
- Using bash commands to inspect system state
|
||||
- Reading relevant files and logs
|
||||
- Searching for patterns and anomalies
|
||||
- Providing clear explanations of findings
|
||||
|
||||
Do not make any changes to files. Only investigate and report.
|
||||
```
|
||||
|
||||
```markdown title="~/.config/opencode/modes/refactor.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.2
|
||||
tools:
|
||||
edit: true
|
||||
read: true
|
||||
grep: true
|
||||
glob: true
|
||||
---
|
||||
|
||||
You are in refactoring mode. Focus on improving code quality without changing functionality.
|
||||
|
||||
Priorities:
|
||||
|
||||
- Improve code readability and maintainability
|
||||
- Apply consistent naming conventions
|
||||
- Reduce code duplication
|
||||
- Optimize performance where appropriate
|
||||
- Ensure all tests continue to pass
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Варианты использования
|
||||
|
||||
Вот несколько распространенных случаев использования различных режимов.
|
||||
|
||||
- **Режим сборки**: полная работа по разработке со всеми включенными инструментами.
|
||||
- **Режим планирования**: анализ и планирование без внесения изменений.
|
||||
- **Режим проверки**: проверка кода с доступом только для чтения и инструментами документирования.
|
||||
- **Режим отладки**: сосредоточен на исследовании с включенными инструментами bash и чтения.
|
||||
- **Режим документации**: запись документации с использованием файловых операций, но без системных команд.
|
||||
|
||||
Вы также можете обнаружить, что разные модели подходят для разных случаев использования.
|
||||
|
|
@ -1,329 +0,0 @@
|
|||
---
|
||||
title: โหมด
|
||||
description: โหมดที่แตกต่างกันสำหรับกรณีการใช้งานที่แตกต่างกัน
|
||||
---
|
||||
|
||||
:::caution
|
||||
ขณะนี้โหมดได้รับการกำหนดค่าผ่านตัวเลือก `agent` ในการกำหนดค่า opencode ที่
|
||||
ตัวเลือก `mode` เลิกใช้แล้ว [เรียนรู้เพิ่มเติม](/docs/agents)
|
||||
:::
|
||||
|
||||
โหมดใน opencode ช่วยให้คุณปรับแต่งพฤติกรรม เครื่องมือ และพร้อมท์สำหรับกรณีการใช้งานที่แตกต่างกันได้
|
||||
|
||||
มาพร้อมกับโหมดในตัวสองโหมด: **สร้าง** และ **วางแผน** คุณสามารถปรับแต่งได้
|
||||
สิ่งเหล่านี้หรือกำหนดค่าของคุณเองผ่านการกำหนดค่า opencode
|
||||
|
||||
คุณสามารถสลับระหว่างโหมดระหว่างเซสชันหรือกำหนดค่าในไฟล์กำหนดค่าของคุณ
|
||||
|
||||
---
|
||||
|
||||
## บิวท์อิน
|
||||
|
||||
opencode มาพร้อมกับโหมดในตัวสองโหมด
|
||||
|
||||
---
|
||||
|
||||
### Build
|
||||
|
||||
Build เป็นโหมด **ค่าเริ่มต้น** โดยที่เครื่องมือทั้งหมดเปิดใช้งานอยู่ นี่คือโหมดมาตรฐานสำหรับงานพัฒนาที่คุณต้องการสิทธิ์เข้าถึงการทำงานของไฟล์และคำสั่งระบบโดยสมบูรณ์
|
||||
|
||||
---
|
||||
|
||||
### Plan
|
||||
|
||||
โหมดจำกัดที่ออกแบบมาเพื่อการวางแผนและการวิเคราะห์ ในโหมดแผน เครื่องมือต่อไปนี้จะถูกปิดใช้งานตามค่าเริ่มต้น:
|
||||
|
||||
- `write` - ไม่สามารถสร้างไฟล์ใหม่ได้
|
||||
- `edit` - ไม่สามารถแก้ไขไฟล์ที่มีอยู่ได้ ยกเว้นไฟล์ที่อยู่ใน `.opencode/plans/*.md` เพื่อดูรายละเอียดแผนงาน
|
||||
- `patch` - ไม่สามารถใช้แพตช์ได้
|
||||
- `bash` - ไม่สามารถรันคำสั่ง shell ได้
|
||||
|
||||
โหมดนี้มีประโยชน์เมื่อคุณต้องการให้ AI วิเคราะห์โค้ด แนะนำการเปลี่ยนแปลง หรือสร้างแผนโดยไม่ต้องทำการแก้ไขโค้ดเบสของคุณจริง ๆ
|
||||
|
||||
---
|
||||
|
||||
## การสลับ
|
||||
|
||||
คุณสามารถสลับระหว่างโหมดระหว่างเซสชันได้โดยใช้ปุ่ม _Tab_ หรือการเชื่อมโยงคีย์ `switch_mode` ที่คุณกำหนดค่าไว้
|
||||
|
||||
ดูเพิ่มเติมที่: [Formatters](/docs/formatters) สำหรับข้อมูลเกี่ยวกับการกำหนดค่าการจัดรูปแบบโค้ด
|
||||
|
||||
---
|
||||
|
||||
## กำหนดค่า
|
||||
|
||||
คุณสามารถปรับแต่งโหมดในตัวหรือสร้างโหมดของคุณเองผ่านการกำหนดค่าได้ โหมดสามารถกำหนดค่าได้สองวิธี:
|
||||
|
||||
### การกำหนดค่าด้วย JSON
|
||||
|
||||
กำหนดค่าโหมดในไฟล์กำหนดค่า `opencode.json` ของคุณ:
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"build": {
|
||||
"model": "anthropic/claude-sonnet-4-20250514",
|
||||
"prompt": "{file:./prompts/build.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": true
|
||||
}
|
||||
},
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514",
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### การกำหนดค่า Markdown
|
||||
|
||||
คุณยังสามารถกำหนดโหมดโดยใช้ไฟล์ Markdown ได้ วางไว้ใน:
|
||||
|
||||
- ทั่วโลก: `~/.config/opencode/modes/`
|
||||
- โครงการ: `.opencode/modes/`
|
||||
|
||||
```markdown title="~/.config/opencode/modes/review.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.1
|
||||
tools:
|
||||
write: false
|
||||
edit: false
|
||||
bash: false
|
||||
---
|
||||
|
||||
You are in code review mode. Focus on:
|
||||
|
||||
- Code quality and best practices
|
||||
- Potential bugs and edge cases
|
||||
- Performance implications
|
||||
- Security considerations
|
||||
|
||||
Provide constructive feedback without making direct changes.
|
||||
```
|
||||
|
||||
ชื่อไฟล์ Markdown จะกลายเป็นชื่อโหมด (เช่น `review.md` สร้างโหมด `review`)
|
||||
|
||||
มาดูรายละเอียดตัวเลือกการกำหนดค่าเหล่านี้กัน
|
||||
|
||||
---
|
||||
|
||||
### Model (โมเดล)
|
||||
|
||||
ใช้การกำหนดค่า `model` เพื่อแทนที่โมเดลเริ่มต้นสำหรับโหมดนี้ มีประโยชน์สำหรับการใช้โมเดลที่แตกต่างกันซึ่งปรับให้เหมาะกับงานที่แตกต่างกัน ตัวอย่างเช่น โมเดลสำหรับการวางแผนที่เร็วขึ้น โมเดลที่มีความสามารถมากขึ้นสำหรับการนำไปปฏิบัติ
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Temperature (อุณหภูมิ)
|
||||
|
||||
ควบคุมการสุ่มและความคิดสร้างสรรค์ของการตอบสนองของ AI ด้วยการกำหนดค่า `temperature` ค่าที่ต่ำกว่าจะทำให้คำตอบมีจุดมุ่งหมายและกำหนดได้มากขึ้น ในขณะที่ค่าที่สูงกว่าจะเพิ่มความคิดสร้างสรรค์และความแปรปรวน
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"temperature": 0.1
|
||||
},
|
||||
"creative": {
|
||||
"temperature": 0.8
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
โดยทั่วไปค่าอุณหภูมิจะอยู่ในช่วงตั้งแต่ 0.0 ถึง 1.0:
|
||||
|
||||
- **0.0-0.2**: การตอบสนองที่มุ่งเน้นและกำหนดไว้อย่างมาก เหมาะสำหรับการวิเคราะห์และวางแผนโค้ด
|
||||
- **0.3-0.5**: การตอบสนองที่สมดุลและความคิดสร้างสรรค์บางส่วน เหมาะสำหรับงานพัฒนาทั่วไป
|
||||
- **0.6-1.0**: คำตอบที่สร้างสรรค์และหลากหลายยิ่งขึ้น ซึ่งมีประโยชน์สำหรับการระดมความคิดและการสำรวจ
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"analyze": {
|
||||
"temperature": 0.1,
|
||||
"prompt": "{file:./prompts/analysis.txt}"
|
||||
},
|
||||
"build": {
|
||||
"temperature": 0.3
|
||||
},
|
||||
"brainstorm": {
|
||||
"temperature": 0.7,
|
||||
"prompt": "{file:./prompts/creative.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
หากไม่มีการระบุอุณหภูมิ opencode จะใช้ค่าเริ่มต้นเฉพาะรุ่น (โดยทั่วไปจะเป็น 0 สำหรับรุ่นส่วนใหญ่ และ 0.55 สำหรับรุ่น Qwen)
|
||||
|
||||
---
|
||||
|
||||
### พรอมต์
|
||||
|
||||
ระบุไฟล์พรอมต์ระบบที่กำหนดเองสำหรับโหมดนี้ด้วยการกำหนดค่า `prompt` ไฟล์พร้อมท์ควรมีคำแนะนำเฉพาะสำหรับวัตถุประสงค์ของโหมด
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"review": {
|
||||
"prompt": "{file:./prompts/code-review.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
เส้นทางนี้สัมพันธ์กับตำแหน่งของไฟล์กำหนดค่า ดังนั้นสิ่งนี้จึงใช้ได้กับ
|
||||
ทั้งการกำหนดค่า opencode ส่วนกลางและการกำหนดค่าเฉพาะโครงการ
|
||||
|
||||
---
|
||||
|
||||
### เครื่องมือ
|
||||
|
||||
ควบคุมว่าเครื่องมือใดบ้างที่พร้อมใช้งานในโหมดนี้ด้วยการกำหนดค่า `tools` คุณสามารถเปิดหรือปิดใช้งานเครื่องมือเฉพาะได้โดยตั้งค่าเป็น `true` หรือ `false`
|
||||
|
||||
```json
|
||||
{
|
||||
"mode": {
|
||||
"readonly": {
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
หากไม่มีการระบุเครื่องมือ เครื่องมือทั้งหมดจะถูกเปิดใช้งานตามค่าเริ่มต้น
|
||||
|
||||
---
|
||||
|
||||
#### เครื่องมือที่มีอยู่
|
||||
|
||||
นี่คือเครื่องมือทั้งหมดที่สามารถควบคุมได้ผ่านการกำหนดค่าโหมด
|
||||
|
||||
| เครื่องมือ | คำอธิบาย |
|
||||
| ----------- | ------------------------- |
|
||||
| `bash` | ดำเนินการคำสั่ง shell |
|
||||
| `edit` | แก้ไขไฟล์ที่มีอยู่ |
|
||||
| `write` | สร้างไฟล์ใหม่ |
|
||||
| `read` | อ่านเนื้อหาไฟล์ |
|
||||
| `grep` | ค้นหาเนื้อหาไฟล์ |
|
||||
| `glob` | ค้นหาไฟล์ตามรูปแบบ |
|
||||
| `patch` | ใช้แพทช์กับไฟล์ |
|
||||
| `todowrite` | จัดการรายการสิ่งที่ต้องทำ |
|
||||
| `webfetch` | ดึงเนื้อหาเว็บ |
|
||||
|
||||
---
|
||||
|
||||
## โหมดกำหนดเอง
|
||||
|
||||
คุณสามารถสร้างโหมดที่คุณกำหนดเองได้โดยเพิ่มเข้าไปในการกำหนดค่า นี่คือตัวอย่างที่ใช้ทั้งสองวิธี:
|
||||
|
||||
### ใช้การกำหนดค่า JSON
|
||||
|
||||
```json title="opencode.json" {4-14}
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"docs": {
|
||||
"prompt": "{file:./prompts/documentation.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### การใช้ไฟล์ Markdown
|
||||
|
||||
สร้างไฟล์โหมดใน `.opencode/modes/` สำหรับโหมดเฉพาะโครงการหรือ `~/.config/opencode/modes/` สำหรับโหมดทั่วโลก:
|
||||
|
||||
```markdown title=".opencode/modes/debug.md"
|
||||
---
|
||||
temperature: 0.1
|
||||
tools:
|
||||
bash: true
|
||||
read: true
|
||||
grep: true
|
||||
write: false
|
||||
edit: false
|
||||
---
|
||||
|
||||
You are in debug mode. Your primary goal is to help investigate and diagnose issues.
|
||||
|
||||
Focus on:
|
||||
|
||||
- Understanding the problem through careful analysis
|
||||
- Using bash commands to inspect system state
|
||||
- Reading relevant files and logs
|
||||
- Searching for patterns and anomalies
|
||||
- Providing clear explanations of findings
|
||||
|
||||
Do not make any changes to files. Only investigate and report.
|
||||
```
|
||||
|
||||
```markdown title="~/.config/opencode/modes/refactor.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.2
|
||||
tools:
|
||||
edit: true
|
||||
read: true
|
||||
grep: true
|
||||
glob: true
|
||||
---
|
||||
|
||||
You are in refactoring mode. Focus on improving code quality without changing functionality.
|
||||
|
||||
Priorities:
|
||||
|
||||
- Improve code readability and maintainability
|
||||
- Apply consistent naming conventions
|
||||
- Reduce code duplication
|
||||
- Optimize performance where appropriate
|
||||
- Ensure all tests continue to pass
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### กรณีการใช้งาน
|
||||
|
||||
ต่อไปนี้เป็นกรณีการใช้งานทั่วไปสำหรับโหมดต่างๆ
|
||||
|
||||
- **Build mode**: งานพัฒนาเต็มรูปแบบโดยเปิดใช้งานเครื่องมือทั้งหมด
|
||||
- **Plan mode**: วิเคราะห์และวางแผนโดยไม่ทำการเปลี่ยนแปลง
|
||||
- **Review mode**: การตรวจสอบโค้ดพร้อมการเข้าถึงแบบอ่านอย่างเดียวพร้อมเครื่องมือเอกสารประกอบ
|
||||
- **Debug mode**: มุ่งเน้นไปที่การตรวจสอบโดยเปิดใช้งานเครื่องมือ bash และอ่าน
|
||||
- **Docs mode**: การเขียนเอกสารด้วยการทำงานของไฟล์ แต่ไม่มีคำสั่งระบบ
|
||||
|
||||
คุณอาจพบว่ารุ่นต่างๆ นั้นดีสำหรับกรณีการใช้งานที่แตกต่างกัน
|
||||
|
|
@ -1,329 +0,0 @@
|
|||
---
|
||||
title: Modlar
|
||||
description: farklı kullanım durumları için farklı modlar.
|
||||
---
|
||||
|
||||
:::caution
|
||||
Modlar artık opencode yapılandırmasındaki `agent` seçeneği aracılığıyla yapılandırılıyor.
|
||||
`mode` seçeneği artık kullanımdan kaldırıldı. [Daha fazla bilgi](/docs/agents).
|
||||
:::
|
||||
|
||||
opencode'daki modlar, farklı kullanım durumları için davranışı, araçları ve istemleri özelleştirmenize olanak tanır.
|
||||
|
||||
İki yerleşik modla birlikte gelir: **build** ve **plan**. Kişiselleştirebilirsiniz
|
||||
bunları veya opencode yapılandırması aracılığıyla kendinizinkini yapılandırın.
|
||||
|
||||
Bir oturum sırasında modlar arasında geçiş yapabilir veya bunları yapılandırma dosyanızda yapılandırabilirsiniz.
|
||||
|
||||
---
|
||||
|
||||
## Yerleşik
|
||||
|
||||
opencode iki yerleşik modla birlikte gelir.
|
||||
|
||||
---
|
||||
|
||||
### Build
|
||||
|
||||
Derleme, tüm araçların etkin olduğu **varsayılan** moddur. Bu, dosya işlemlerine ve sistem komutlarına tam erişime ihtiyaç duyduğunuz geliştirme çalışmaları için standart moddur.
|
||||
|
||||
---
|
||||
|
||||
### Plan
|
||||
|
||||
Planlama ve analiz için tasarlanmış sınırlı bir mod. Plan modunda aşağıdaki araçlar varsayılan olarak devre dışıdır:
|
||||
|
||||
- `write` - Yeni dosyalar oluşturulamıyor
|
||||
- `edit` - Planın kendisini detaylandırmak için `.opencode/plans/*.md` adresinde bulunan dosyalar dışında mevcut dosyalar değiştirilemez
|
||||
- `patch` - Yamalar uygulanamaz
|
||||
- `bash` - Kabuk komutları yürütülemiyor
|
||||
|
||||
Bu mod, yapay zekanın kod tabanınızda herhangi bir gerçek değişiklik yapmadan kodu analiz etmesini, değişiklik önermesini veya plan oluşturmasını istediğinizde kullanışlıdır.
|
||||
|
||||
---
|
||||
|
||||
## Geçiş
|
||||
|
||||
Bir oturum sırasında _Tab_ tuşunu kullanarak modlar arasında geçiş yapabilirsiniz. Veya yapılandırılmış `switch_mode` tuş bağlantınız.
|
||||
|
||||
Ayrıca bkz.: Kod biçimlendirme yapılandırması hakkında bilgi için [Formatters](/docs/formatters).
|
||||
|
||||
---
|
||||
|
||||
## Yapılandırma
|
||||
|
||||
Yerleşik modları özelleştirebilir veya yapılandırma aracılığıyla kendinizinkini oluşturabilirsiniz. Modlar iki şekilde yapılandırılabilir:
|
||||
|
||||
### JSON Yapılandırması
|
||||
|
||||
`opencode.json` yapılandırma dosyanızdaki modları yapılandırın:
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"build": {
|
||||
"model": "anthropic/claude-sonnet-4-20250514",
|
||||
"prompt": "{file:./prompts/build.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": true
|
||||
}
|
||||
},
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514",
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Markdown Yapılandırması
|
||||
|
||||
Markdown dosyalarını kullanarak modları da tanımlayabilirsiniz. Bunları şuraya yerleştirin:
|
||||
|
||||
- Global: `~/.config/opencode/modes/`
|
||||
- Project: `.opencode/modes/`
|
||||
|
||||
```markdown title="~/.config/opencode/modes/review.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.1
|
||||
tools:
|
||||
write: false
|
||||
edit: false
|
||||
bash: false
|
||||
---
|
||||
|
||||
You are in code review mode. Focus on:
|
||||
|
||||
- Code quality and best practices
|
||||
- Potential bugs and edge cases
|
||||
- Performance implications
|
||||
- Security considerations
|
||||
|
||||
Provide constructive feedback without making direct changes.
|
||||
```
|
||||
|
||||
Markdown dosyası adı mod adı olur (örneğin, `review.md` bir `review` modu oluşturur).
|
||||
|
||||
Bu yapılandırma seçeneklerine ayrıntılı olarak bakalım.
|
||||
|
||||
---
|
||||
|
||||
### Model
|
||||
|
||||
Bu modun varsayılan modelini geçersiz kılmak için `model` ayarını kullanın. Farklı bölümler için optimize edilmiş farklı modelleri kullanmak için kullanışlıdır. Örneğin planlama için daha hızlı bir model, uygulama için daha yetenekli bir model.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Sıcaklık
|
||||
|
||||
`temperature` yapılandırmasıyla yapay zekanın yanıtlarının rastgeleliğini ve yaratıcılığını kontrol edin. Düşük değerler yanıtları daha odaklı ve belirleyici hale getirirken, yüksek değerler yaratıcılığı ve değişkenliği artırır.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"temperature": 0.1
|
||||
},
|
||||
"creative": {
|
||||
"temperature": 0.8
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Sıcaklık değerleri tipik olarak 0,0 ila 1,0 arasındadır:
|
||||
|
||||
- **0,0-0,2**: Çok odaklı ve belirleyici yanıtlar, kod analizi ve planlaması için idealdir
|
||||
- **0,3-0,5**: Biraz yaratıcılık içeren dengeli yanıtlar, genel gelişim görevleri için iyi
|
||||
- **0,6-1,0**: Daha yaratıcı ve çeşitli yanıtlar, beyin fırtınası ve keşif için yararlı
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"analyze": {
|
||||
"temperature": 0.1,
|
||||
"prompt": "{file:./prompts/analysis.txt}"
|
||||
},
|
||||
"build": {
|
||||
"temperature": 0.3
|
||||
},
|
||||
"brainstorm": {
|
||||
"temperature": 0.7,
|
||||
"prompt": "{file:./prompts/creative.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Sıcaklık belirtilmezse, opencode modele özgü varsayılanları kullanır (çoğu model için genellikle 0, Qwen modelleri için 0,55).
|
||||
|
||||
---
|
||||
|
||||
### İstem
|
||||
|
||||
`prompt` yapılandırmasıyla bu mod için özel bir sistem bilgi istemi dosyası belirtin. Bilgi istemi dosyası, modun amacına özel talimatlar içermelidir.
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"review": {
|
||||
"prompt": "{file:./prompts/code-review.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Bu yol, yapılandırma dosyasının bulunduğu yere göredir. Yani bu işe yarıyor
|
||||
hem global opencode yapılandırması hem de projeye özel yapılandırma.
|
||||
|
||||
---
|
||||
|
||||
### Araçlar
|
||||
|
||||
`tools` yapılandırmasıyla bu modda hangi araçların kullanılabileceğini kontrol edin. Belirli araçları `true` veya `false` olarak ayarlayarak etkinleştirebilir veya devre dışı bırakabilirsiniz.
|
||||
|
||||
```json
|
||||
{
|
||||
"mode": {
|
||||
"readonly": {
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Hiçbir araç belirtilmezse tüm araçlar varsayılan olarak etkindir.
|
||||
|
||||
---
|
||||
|
||||
#### Mevcut araçlar
|
||||
|
||||
İşte mod yapılandırması aracılığıyla kontrol edilebilecek tüm araçlar.
|
||||
|
||||
| Araç | Açıklama |
|
||||
| ----------- | ------------------------------ |
|
||||
| `bash` | Kabuk komutlarını yürütün |
|
||||
| `edit` | Mevcut dosyaları değiştirin |
|
||||
| `write` | Yeni dosyalar oluştur |
|
||||
| `read` | Dosya içeriğini oku |
|
||||
| `grep` | Dosya içeriğini ara |
|
||||
| `glob` | Dosyaları desene göre bul |
|
||||
| `patch` | Dosyalara yama uygula |
|
||||
| `todowrite` | Yapılacaklar listelerini yönet |
|
||||
| `webfetch` | Web içeriğini getir |
|
||||
|
||||
---
|
||||
|
||||
## Özel modlar
|
||||
|
||||
Yapılandırmaya ekleyerek kendi özel modlarınızı oluşturabilirsiniz. Her iki yaklaşımın kullanıldığı örnekler aşağıda verilmiştir:
|
||||
|
||||
### JSON yapılandırması kullanma
|
||||
|
||||
```json title="opencode.json" {4-14}
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"docs": {
|
||||
"prompt": "{file:./prompts/documentation.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Markdown dosyaları kullanma
|
||||
|
||||
Projeye özel modlar için `.opencode/modes/` veya genel modlar için `~/.config/opencode/modes/`'de mod dosyaları oluşturun:
|
||||
|
||||
```markdown title=".opencode/modes/debug.md"
|
||||
---
|
||||
temperature: 0.1
|
||||
tools:
|
||||
bash: true
|
||||
read: true
|
||||
grep: true
|
||||
write: false
|
||||
edit: false
|
||||
---
|
||||
|
||||
You are in debug mode. Your primary goal is to help investigate and diagnose issues.
|
||||
|
||||
Focus on:
|
||||
|
||||
- Understanding the problem through careful analysis
|
||||
- Using bash commands to inspect system state
|
||||
- Reading relevant files and logs
|
||||
- Searching for patterns and anomalies
|
||||
- Providing clear explanations of findings
|
||||
|
||||
Do not make any changes to files. Only investigate and report.
|
||||
```
|
||||
|
||||
```markdown title="~/.config/opencode/modes/refactor.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.2
|
||||
tools:
|
||||
edit: true
|
||||
read: true
|
||||
grep: true
|
||||
glob: true
|
||||
---
|
||||
|
||||
You are in refactoring mode. Focus on improving code quality without changing functionality.
|
||||
|
||||
Priorities:
|
||||
|
||||
- Improve code readability and maintainability
|
||||
- Apply consistent naming conventions
|
||||
- Reduce code duplication
|
||||
- Optimize performance where appropriate
|
||||
- Ensure all tests continue to pass
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Kullanım Senaryoları
|
||||
|
||||
Farklı modlar için bazı yaygın kullanım senaryoları aşağıda verilmiştir.
|
||||
|
||||
- **Derleme modu**: Tüm araçların etkinleştirildiği tam geliştirme çalışması
|
||||
- **Plan modu**: Değişiklik yapmadan analiz ve planlama
|
||||
- **İnceleme modu**: Salt okunur erişim ve belgeleme araçlarıyla kod incelemesi
|
||||
- **Hata ayıklama modu**: Bash ve okuma araçları etkinken araştırmaya odaklanıldı
|
||||
- **Belgeler modu**: Dosya işlemleriyle ancak sistem komutları olmadan belge yazma
|
||||
|
||||
Ayrıca farklı modellerin farklı kullanım durumları için iyi olduğunu da görebilirsiniz.
|
||||
|
|
@ -1,326 +0,0 @@
|
|||
---
|
||||
title: 模式
|
||||
description: 不同模式适用于不同的使用场景。
|
||||
---
|
||||
|
||||
:::caution
|
||||
模式现在通过 opencode 配置中的 `agent` 选项进行配置。`mode` 选项已废弃。[了解更多](/docs/agents)。
|
||||
:::
|
||||
|
||||
opencode 中的模式允许你为不同的使用场景自定义行为、工具和提示词。
|
||||
|
||||
opencode 自带两种内置模式:**build** 和 **plan**。你可以自定义这些模式,也可以通过 opencode 配置创建自己的模式。
|
||||
|
||||
你可以在会话中切换模式,也可以在配置文件中进行配置。
|
||||
|
||||
---
|
||||
|
||||
## 内置模式
|
||||
|
||||
opencode 自带两种内置模式。
|
||||
|
||||
---
|
||||
|
||||
### Build
|
||||
|
||||
Build 是启用了所有工具的**默认**模式。这是进行开发工作的标准模式,你可以完全访问文件操作和系统命令。
|
||||
|
||||
---
|
||||
|
||||
### Plan
|
||||
|
||||
Plan 是一种为规划和分析设计的受限模式。在 plan 模式下,以下工具默认被禁用:
|
||||
|
||||
- `write` - 无法创建新文件
|
||||
- `edit` - 无法修改现有文件,但位于 `.opencode/plans/*.md` 的文件除外,用于详细说明计划本身
|
||||
- `patch` - 无法应用补丁
|
||||
- `bash` - 无法执行 shell 命令
|
||||
|
||||
当你希望 AI 分析代码、提出修改建议或制定计划,而不对代码库进行任何实际更改时,此模式非常有用。
|
||||
|
||||
---
|
||||
|
||||
## 切换
|
||||
|
||||
你可以在会话中使用 _Tab_ 键切换模式,或者使用你配置的 `switch_mode` 快捷键。
|
||||
|
||||
另请参阅:[格式化工具](/docs/formatters)了解代码格式化配置的相关信息。
|
||||
|
||||
---
|
||||
|
||||
## 配置
|
||||
|
||||
你可以自定义内置模式或通过配置创建自己的模式。模式可以通过两种方式进行配置:
|
||||
|
||||
### JSON 配置
|
||||
|
||||
在 `opencode.json` 配置文件中配置模式:
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"build": {
|
||||
"model": "anthropic/claude-sonnet-4-20250514",
|
||||
"prompt": "{file:./prompts/build.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": true
|
||||
}
|
||||
},
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514",
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Markdown 配置
|
||||
|
||||
你还可以使用 Markdown 文件定义模式。将文件放置在以下位置:
|
||||
|
||||
- 全局:`~/.config/opencode/modes/`
|
||||
- 项目:`.opencode/modes/`
|
||||
|
||||
```markdown title="~/.config/opencode/modes/review.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.1
|
||||
tools:
|
||||
write: false
|
||||
edit: false
|
||||
bash: false
|
||||
---
|
||||
|
||||
You are in code review mode. Focus on:
|
||||
|
||||
- Code quality and best practices
|
||||
- Potential bugs and edge cases
|
||||
- Performance implications
|
||||
- Security considerations
|
||||
|
||||
Provide constructive feedback without making direct changes.
|
||||
```
|
||||
|
||||
Markdown 文件名即为模式名称(例如,`review.md` 创建一个名为 `review` 的模式)。
|
||||
|
||||
下面让我们详细了解这些配置选项。
|
||||
|
||||
---
|
||||
|
||||
### 模型
|
||||
|
||||
使用 `model` 配置可以覆盖该模式的默认模型。这对于针对不同任务使用不同模型非常有用。例如,规划时使用更快的模型,实现时使用更强大的模型。
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 温度
|
||||
|
||||
使用 `temperature` 配置控制 AI 响应的随机性和创造性。较低的值使响应更加集中和确定性,较高的值则增加创造性和多样性。
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"temperature": 0.1
|
||||
},
|
||||
"creative": {
|
||||
"temperature": 0.8
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
温度值的范围通常为 0.0 到 1.0:
|
||||
|
||||
- **0.0-0.2**:非常集中且确定性高的响应,适合代码分析和规划
|
||||
- **0.3-0.5**:兼顾稳定性与创造力的平衡型响应,适合一般开发任务
|
||||
- **0.6-1.0**:更具创造性和多样性的响应,适合头脑风暴和探索性工作
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"analyze": {
|
||||
"temperature": 0.1,
|
||||
"prompt": "{file:./prompts/analysis.txt}"
|
||||
},
|
||||
"build": {
|
||||
"temperature": 0.3
|
||||
},
|
||||
"brainstorm": {
|
||||
"temperature": 0.7,
|
||||
"prompt": "{file:./prompts/creative.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
如果未指定温度,opencode 将使用模型特定的默认值(大多数模型通常为 0,Qwen 模型为 0.55)。
|
||||
|
||||
---
|
||||
|
||||
### 提示词
|
||||
|
||||
使用 `prompt` 配置为模式指定自定义系统提示词文件。提示词文件应包含针对该模式用途的具体指令。
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"review": {
|
||||
"prompt": "{file:./prompts/code-review.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
此路径相对于配置文件所在位置。因此,全局 opencode 配置和项目特定配置均可使用。
|
||||
|
||||
---
|
||||
|
||||
### 工具
|
||||
|
||||
使用 `tools` 配置控制该模式下可用的工具。你可以将特定工具设置为 `true` 或 `false` 来启用或禁用它们。
|
||||
|
||||
```json
|
||||
{
|
||||
"mode": {
|
||||
"readonly": {
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
如果未指定任何工具,则默认启用所有工具。
|
||||
|
||||
---
|
||||
|
||||
#### 可用工具
|
||||
|
||||
以下是所有可通过模式配置控制的工具。
|
||||
|
||||
| 工具 | 描述 |
|
||||
| ----------- | ---------------- |
|
||||
| `bash` | 执行 shell 命令 |
|
||||
| `edit` | 修改现有文件 |
|
||||
| `write` | 创建新文件 |
|
||||
| `read` | 读取文件内容 |
|
||||
| `grep` | 搜索文件内容 |
|
||||
| `glob` | 按模式查找文件 |
|
||||
| `patch` | 对文件应用补丁 |
|
||||
| `todowrite` | 管理待办事项列表 |
|
||||
| `webfetch` | 获取网页内容 |
|
||||
|
||||
---
|
||||
|
||||
## 自定义模式
|
||||
|
||||
你可以通过在配置中添加自定义模式来创建自己的模式。以下是两种方式的示例:
|
||||
|
||||
### 使用 JSON 配置
|
||||
|
||||
```json title="opencode.json" {4-14}
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"docs": {
|
||||
"prompt": "{file:./prompts/documentation.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 使用 Markdown 文件
|
||||
|
||||
在 `.opencode/modes/` 中创建项目特定的模式文件,或在 `~/.config/opencode/modes/` 中创建全局模式文件:
|
||||
|
||||
```markdown title=".opencode/modes/debug.md"
|
||||
---
|
||||
temperature: 0.1
|
||||
tools:
|
||||
bash: true
|
||||
read: true
|
||||
grep: true
|
||||
write: false
|
||||
edit: false
|
||||
---
|
||||
|
||||
You are in debug mode. Your primary goal is to help investigate and diagnose issues.
|
||||
|
||||
Focus on:
|
||||
|
||||
- Understanding the problem through careful analysis
|
||||
- Using bash commands to inspect system state
|
||||
- Reading relevant files and logs
|
||||
- Searching for patterns and anomalies
|
||||
- Providing clear explanations of findings
|
||||
|
||||
Do not make any changes to files. Only investigate and report.
|
||||
```
|
||||
|
||||
```markdown title="~/.config/opencode/modes/refactor.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.2
|
||||
tools:
|
||||
edit: true
|
||||
read: true
|
||||
grep: true
|
||||
glob: true
|
||||
---
|
||||
|
||||
You are in refactoring mode. Focus on improving code quality without changing functionality.
|
||||
|
||||
Priorities:
|
||||
|
||||
- Improve code readability and maintainability
|
||||
- Apply consistent naming conventions
|
||||
- Reduce code duplication
|
||||
- Optimize performance where appropriate
|
||||
- Ensure all tests continue to pass
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 使用场景
|
||||
|
||||
以下是不同模式的一些常见使用场景。
|
||||
|
||||
- **Build 模式**:启用所有工具的完整开发工作
|
||||
- **Plan 模式**:分析和规划,不做任何更改
|
||||
- **Review 模式**:使用只读访问权限加文档工具进行代码审查
|
||||
- **Debug 模式**:启用 bash 和读取工具,专注于问题排查
|
||||
- **Docs 模式**:支持文件操作但不支持系统命令的文档编写
|
||||
|
||||
你可能还会发现不同的模型适用于不同的使用场景。
|
||||
|
|
@ -1,326 +0,0 @@
|
|||
---
|
||||
title: 模式
|
||||
description: 不同模式適用於不同的使用情境。
|
||||
---
|
||||
|
||||
:::caution
|
||||
模式現在透過 opencode 設定中的 `agent` 選項進行設定。`mode` 選項已廢棄。[了解更多](/docs/agents)。
|
||||
:::
|
||||
|
||||
opencode 中的模式允許您為不同的使用情境自訂行為、工具和提示詞。
|
||||
|
||||
opencode 自帶兩種內建模式:**build** 和 **plan**。您可以自訂這些模式,也可以透過 opencode 設定建立自己的模式。
|
||||
|
||||
您可以在工作階段中切換模式,也可以在設定檔中進行設定。
|
||||
|
||||
---
|
||||
|
||||
## 內建模式
|
||||
|
||||
opencode 自帶兩種內建模式。
|
||||
|
||||
---
|
||||
|
||||
### Build
|
||||
|
||||
Build 是啟用了所有工具的**預設**模式。這是進行開發工作的標準模式,您可以完全存取檔案操作和系統指令。
|
||||
|
||||
---
|
||||
|
||||
### Plan
|
||||
|
||||
Plan 是一種為規劃和分析設計的受限模式。在 plan 模式下,以下工具預設被停用:
|
||||
|
||||
- `write` - 無法建立新檔案
|
||||
- `edit` - 無法修改現有檔案,但位於 `.opencode/plans/*.md` 的檔案除外,用於詳細說明計畫本身
|
||||
- `patch` - 無法套用補丁
|
||||
- `bash` - 無法執行 shell 指令
|
||||
|
||||
當您希望 AI 分析程式碼、提出修改建議或制定計畫,而不對程式碼庫進行任何實際更改時,此模式非常有用。
|
||||
|
||||
---
|
||||
|
||||
## 切換
|
||||
|
||||
您可以在工作階段中使用 _Tab_ 鍵切換模式,或者使用您設定的 `switch_mode` 快捷鍵。
|
||||
|
||||
另請參閱:[格式化工具](/docs/formatters)了解程式碼格式化設定的相關資訊。
|
||||
|
||||
---
|
||||
|
||||
## 設定
|
||||
|
||||
您可以自訂內建模式或透過設定建立自己的模式。模式可以透過兩種方式進行設定:
|
||||
|
||||
### JSON 設定
|
||||
|
||||
在 `opencode.json` 設定檔中設定模式:
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"build": {
|
||||
"model": "anthropic/claude-sonnet-4-20250514",
|
||||
"prompt": "{file:./prompts/build.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": true
|
||||
}
|
||||
},
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514",
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Markdown 設定
|
||||
|
||||
您還可以使用 Markdown 檔案定義模式。將檔案放置在以下位置:
|
||||
|
||||
- 全域:`~/.config/opencode/modes/`
|
||||
- 專案:`.opencode/modes/`
|
||||
|
||||
```markdown title="~/.config/opencode/modes/review.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.1
|
||||
tools:
|
||||
write: false
|
||||
edit: false
|
||||
bash: false
|
||||
---
|
||||
|
||||
You are in code review mode. Focus on:
|
||||
|
||||
- Code quality and best practices
|
||||
- Potential bugs and edge cases
|
||||
- Performance implications
|
||||
- Security considerations
|
||||
|
||||
Provide constructive feedback without making direct changes.
|
||||
```
|
||||
|
||||
Markdown 檔案名稱即為模式名稱(例如,`review.md` 建立一個名為 `review` 的模式)。
|
||||
|
||||
下面讓我們詳細了解這些設定選項。
|
||||
|
||||
---
|
||||
|
||||
### 模型
|
||||
|
||||
使用 `model` 設定可以覆寫該模式的預設模型。這對於針對不同任務使用不同模型非常有用。例如,規劃時使用更快的模型,實作時使用更強大的模型。
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"model": "anthropic/claude-haiku-4-20250514"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 溫度
|
||||
|
||||
使用 `temperature` 設定控制 AI 回應的隨機性和創造性。較低的值使回應更加集中和確定性,較高的值則增加創造性和多樣性。
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"plan": {
|
||||
"temperature": 0.1
|
||||
},
|
||||
"creative": {
|
||||
"temperature": 0.8
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
溫度值的範圍通常為 0.0 到 1.0:
|
||||
|
||||
- **0.0-0.2**:非常集中且確定性高的回應,適合程式碼分析和規劃
|
||||
- **0.3-0.5**:兼顧穩定性與創造力的平衡型回應,適合一般開發任務
|
||||
- **0.6-1.0**:更具創造性和多樣性的回應,適合腦力激盪和探索性工作
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"analyze": {
|
||||
"temperature": 0.1,
|
||||
"prompt": "{file:./prompts/analysis.txt}"
|
||||
},
|
||||
"build": {
|
||||
"temperature": 0.3
|
||||
},
|
||||
"brainstorm": {
|
||||
"temperature": 0.7,
|
||||
"prompt": "{file:./prompts/creative.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
如果未指定溫度,opencode 將使用模型特定的預設值(大多數模型通常為 0,Qwen 模型為 0.55)。
|
||||
|
||||
---
|
||||
|
||||
### 提示詞
|
||||
|
||||
使用 `prompt` 設定為模式指定自訂系統提示詞檔案。提示詞檔案應包含針對該模式用途的具體指令。
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"mode": {
|
||||
"review": {
|
||||
"prompt": "{file:./prompts/code-review.txt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
此路徑相對於設定檔所在位置。因此,全域 opencode 設定和專案特定設定均可使用。
|
||||
|
||||
---
|
||||
|
||||
### 工具
|
||||
|
||||
使用 `tools` 設定控制該模式下可用的工具。您可以將特定工具設定為 `true` 或 `false` 來啟用或停用它們。
|
||||
|
||||
```json
|
||||
{
|
||||
"mode": {
|
||||
"readonly": {
|
||||
"tools": {
|
||||
"write": false,
|
||||
"edit": false,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
如果未指定任何工具,則預設啟用所有工具。
|
||||
|
||||
---
|
||||
|
||||
#### 可用工具
|
||||
|
||||
以下是所有可透過模式設定控制的工具。
|
||||
|
||||
| 工具 | 描述 |
|
||||
| ----------- | ---------------- |
|
||||
| `bash` | 執行 shell 指令 |
|
||||
| `edit` | 修改現有檔案 |
|
||||
| `write` | 建立新檔案 |
|
||||
| `read` | 讀取檔案內容 |
|
||||
| `grep` | 搜尋檔案內容 |
|
||||
| `glob` | 按模式尋找檔案 |
|
||||
| `patch` | 對檔案套用補丁 |
|
||||
| `todowrite` | 管理待辦事項清單 |
|
||||
| `webfetch` | 擷取網頁內容 |
|
||||
|
||||
---
|
||||
|
||||
## 自訂模式
|
||||
|
||||
您可以透過在設定中新增自訂模式來建立自己的模式。以下是兩種方式的範例:
|
||||
|
||||
### 使用 JSON 設定
|
||||
|
||||
```json title="opencode.json" {4-14}
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mode": {
|
||||
"docs": {
|
||||
"prompt": "{file:./prompts/documentation.txt}",
|
||||
"tools": {
|
||||
"write": true,
|
||||
"edit": true,
|
||||
"bash": false,
|
||||
"read": true,
|
||||
"grep": true,
|
||||
"glob": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 使用 Markdown 檔案
|
||||
|
||||
在 `.opencode/modes/` 中建立專案特定的模式檔案,或在 `~/.config/opencode/modes/` 中建立全域模式檔案:
|
||||
|
||||
```markdown title=".opencode/modes/debug.md"
|
||||
---
|
||||
temperature: 0.1
|
||||
tools:
|
||||
bash: true
|
||||
read: true
|
||||
grep: true
|
||||
write: false
|
||||
edit: false
|
||||
---
|
||||
|
||||
You are in debug mode. Your primary goal is to help investigate and diagnose issues.
|
||||
|
||||
Focus on:
|
||||
|
||||
- Understanding the problem through careful analysis
|
||||
- Using bash commands to inspect system state
|
||||
- Reading relevant files and logs
|
||||
- Searching for patterns and anomalies
|
||||
- Providing clear explanations of findings
|
||||
|
||||
Do not make any changes to files. Only investigate and report.
|
||||
```
|
||||
|
||||
```markdown title="~/.config/opencode/modes/refactor.md"
|
||||
---
|
||||
model: anthropic/claude-sonnet-4-20250514
|
||||
temperature: 0.2
|
||||
tools:
|
||||
edit: true
|
||||
read: true
|
||||
grep: true
|
||||
glob: true
|
||||
---
|
||||
|
||||
You are in refactoring mode. Focus on improving code quality without changing functionality.
|
||||
|
||||
Priorities:
|
||||
|
||||
- Improve code readability and maintainability
|
||||
- Apply consistent naming conventions
|
||||
- Reduce code duplication
|
||||
- Optimize performance where appropriate
|
||||
- Ensure all tests continue to pass
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 使用情境
|
||||
|
||||
以下是不同模式的一些常見使用情境。
|
||||
|
||||
- **Build 模式**:啟用所有工具的完整開發工作
|
||||
- **Plan 模式**:分析和規劃,不做任何更改
|
||||
- **Review 模式**:使用唯讀存取權限加文件工具進行程式碼審查
|
||||
- **Debug 模式**:啟用 bash 和讀取工具,專注於問題排查
|
||||
- **Docs 模式**:支援檔案操作但不支援系統指令的文件編寫
|
||||
|
||||
您可能還會發現不同的模型適用於不同的使用情境。
|
||||
Loading…
Add table
Add a link
Reference in a new issue