OpenCode कॉन्फिग शेयर: लेयर्ड एजेंट्स, परमिशन और पूरा उदाहरण

canxin द्वारा3 मिनट पढ़ने का समय


विषय सूची

  1. 1. मर्ज क्रम और प्राथमिकता
  2. 2. टॉप-लेवल कॉन्फिग फील्ड्स
  3. 3. लेयर्ड एजेंट डिज़ाइन
    1. 3.1 LocalReader
    2. 3.2 LocalScribe (डिफॉल्ट)
    3. 3.3 OmniReader
    4. 3.4 OmniScribe
  4. 4. Provider और model catalog संरचना
    1. 4.1 सामान्य model JSON संरचना
    2. 4.2 मॉडल फील्ड संदर्भ
    3. 4.3 provider के अनुसार variants पैटर्न
    4. 4.4 provider-स्तरीय option फील्ड्स
  5. 5. प्लगइन लोडिंग
    1. 5.1 opencode-planpilot (npm)
    2. 5.2 opencode-workbench (npm)
  6. 6. पूर्ण कॉन्फिग उदाहरण

1. मर्ज क्रम और प्राथमिकता

प्राथमिकता (निम्न -> उच्च):

  1. Remote .well-known/opencode
  2. Global ~/.config/opencode/opencode.json
  3. OPENCODE_CONFIG
  4. Project opencode.json
  5. .opencode directories
  6. OPENCODE_CONFIG_CONTENT

सिफारिश: टिकाऊ डिफॉल्ट्स को global रखें; repo-विशिष्ट नियम प्रत्येक repository में रखें।

2. टॉप-लेवल कॉन्फिग फील्ड्स

टॉप-लेवल मुख्य फील्ड्स:

{
  "$schema": "https://opencode.ai/config.json",
  "default_agent": "LocalScribe",
  "model": "my_oai/gpt-5.3-codex",
  "small_model": "my_oai/gpt-5.3-codex",
  "autoupdate": false,
  "compaction": {
    "auto": true,
    "prune": true
  },
  "agent": { ... },
  "plugin": [ ... ],
  "provider": { ... }
}

फील्ड नोट्स:

3. लेयर्ड एजेंट डिज़ाइन

वर्तमान permission मानों से वास्तविक सीमाएं (एकल तालिका):

Agentreadeditexternal_directorybashनिष्कर्ष
LocalReaderread.* = allow (जिसमें *.env)askaskaskवर्कस्पेस को सीधे पढ़ सकता है; वर्कस्पेस के बाहर पहुंच के लिए पुष्टि चाहिए
LocalScriberead.* = allow (जिसमें *.env)* = allow, *../* = denyallow* = allow, खतरनाक पैटर्न askवैश्विक पढ़ने की अनुमति; सामान्यतः वर्कस्पेस में लिखने योग्य
OmniReaderread.* = allow (जिसमें *.env)askallowaskवैश्विक पढ़ाई; लिखने के लिए पुष्टि चाहिए
OmniScribe* = allow (जिसमें read)* = allowallow* = allow, खतरनाक पैटर्न askवैश्विक पढ़ना/लिखना

LocalScribe को “आमतौर पर वर्कस्पेस में writable” कहा जाता है क्योंकि path traversal *../* = deny से अवरुद्ध है। यदि सख्त workspace-only writes चाहिए, तो external_directory को ask या deny पर सेट करें।

निष्क्रिय built-ins:

"agent": {
  "build": { "disable": true },
  "docs": { "disable": true },
  "plan": { "disable": true }
}

3.1 LocalReader

"LocalReader": {
  "description": "Read-first agent; asks for non-read actions",
  "mode": "all",
  "permission": {
    "*": "ask",
    "bash": "ask",
    "edit": "ask",
    "glob": "allow",
    "grep": "allow",
    "list": "allow",
    "read": {
      "*": "allow",
      "*.env": "allow",
      "*.env.*": "allow"
    },
    "plan_enter": "deny",
    "plan_exit": "deny",
    "todoread": "deny",
    "todowrite": "deny"
  }
}

3.2 LocalScribe (डिफॉल्ट)

"LocalScribe": {
  "description": "Reads any path; writes only inside workspace",
  "mode": "all",
  "permission": {
    "*": "allow",
    "bash": {
      "*": "allow",
      "sudo *": "ask",
      "su *": "ask",
      "rm -rf *": "ask",
      "rm -fr *": "ask",
      "mkfs* *": "ask",
      "reboot *": "ask",
      "shutdown *": "ask",
      "dd *": "ask"
    },
    "edit": {
      "*": "allow",
      "*../*": "deny"
    },
    "external_directory": "allow",
    "plan_enter": "deny",
    "plan_exit": "deny",
    "todoread": "deny",
    "todowrite": "deny"
  }
}

3.3 OmniReader

"OmniReader": {
  "description": "Read-first agent for all paths; asks for non-read actions",
  "mode": "all",
  "permission": {
    "*": "ask",
    "external_directory": "allow",
    "read": {
      "*": "allow",
      "*.env": "allow",
      "*.env.*": "allow"
    },
    "bash": "ask",
    "edit": "ask"
  }
}

3.4 OmniScribe

"OmniScribe": {
  "description": "Dangerous full access read/write anywhere",
  "mode": "all",
  "permission": {
    "*": "allow",
    "bash": {
      "*": "allow",
      "sudo *": "ask",
      "rm -rf *": "ask",
      "mkfs* *": "ask"
    },
    "external_directory": "allow",
    "plan_enter": "deny",
    "plan_exit": "deny"
  }
}

4. Provider और model catalog संरचना

तीन providers:

Provider संरचना:

  1. provider metadata: name, npm
  2. provider connection options: options.baseURL, options.apiKey, options.setCacheKey (आमतौर पर OpenAI-compatible providers में)
  3. models map: प्रत्येक मॉडल के लिए एक ऑब्जेक्ट

4.1 सामान्य model JSON संरचना

"provider": {
  "my_oai": {
    "name": "my_oai",
    "npm": "@ai-sdk/openai",
    "options": {
      "apiKey": "{env:OAI_API_KEY}",
      "baseURL": "https://your-gateway.example/v1",
      "setCacheKey": true
    },
    "models": {
      "gpt-5.3-codex": {
        "name": "gpt-5.3-codex",
        "attachment": true,
        "limit": {
          "context": 400000,
          "output": 128000
        },
        "modalities": {
          "input": ["text", "image", "pdf"],
          "output": ["text"]
        },
        "options": {
          "store": false,
          "include": ["reasoning.encrypted_content"]
        },
        "variants": {
          "high": { "reasoningEffort": "high", "reasoningSummary": "auto", "textVerbosity": "medium" },
          "medium": { "reasoningEffort": "medium", "reasoningSummary": "auto", "textVerbosity": "medium" },
          "low": { "reasoningEffort": "low", "reasoningSummary": "auto", "textVerbosity": "medium" },
          "xhigh": { "reasoningEffort": "xhigh", "reasoningSummary": "auto", "textVerbosity": "medium" }
        }
      }
    }
  }
}

4.2 मॉडल फील्ड संदर्भ

FieldTypeअर्थ
namestringप्रदर्शन नाम
attachmentbooleanattachments सक्षम हैं या नहीं
limit.contextnumberकुल context window
limit.outputnumberअधिकतम output tokens
modalities.inputstring[]input modalities, जैसे text/image/pdf
modalities.outputstring[]output modalities, आमतौर पर text
options.storebooleanrequest storage toggle (वर्तमान में OAI-family के लिए false)
options.includestring[]अतिरिक्त return fields (जैसे reasoning.encrypted_content)
variantsobjectप्रति-मॉडल reasoning profiles

4.3 provider के अनुसार variants पैटर्न

my_claude:

"variants": {
  "off": { "thinking": { "type": "disabled" } },
  "high": { "thinking": { "type": "enabled", "budgetTokens": 16000 } },
  "max": { "thinking": { "type": "enabled", "budgetTokens": 128000 } }
}

my_gemini:

"variants": {
  "off": { "thinkingConfig": { "thinkingBudget": 0 } },
  "high": { "thinkingConfig": { "includeThoughts": true, "thinkingBudget": 16000 } },
  "max": { "thinkingConfig": { "includeThoughts": true, "thinkingBudget": 24576 } }
}

my_oai:

"variants": {
  "low": { "reasoningEffort": "low", "reasoningSummary": "auto", "textVerbosity": "medium" },
  "medium": { "reasoningEffort": "medium", "reasoningSummary": "auto", "textVerbosity": "medium" },
  "high": { "reasoningEffort": "high", "reasoningSummary": "auto", "textVerbosity": "medium" },
  "minimal": { "reasoningEffort": "minimal", "reasoningSummary": "auto", "textVerbosity": "low" }
}

4.4 provider-स्तरीय option फील्ड्स

सामान्य provider.<id>.options फील्ड्स:

FieldTypeअर्थ
apiKeystringprovider API key
baseURLstringprovider gateway URL
setCacheKeybooleanOpenAI-compatible providers के लिए cache-key व्यवहार

5. प्लगइन लोडिंग

Plugin कॉन्फिग:

"plugin": [
  "opencode-planpilot",
  "opencode-workbench"
]

5.1 opencode-planpilot (npm)

5.2 opencode-workbench (npm)

6. पूर्ण कॉन्फिग उदाहरण

नीचे production शैली का एक व्यावहारिक पूर्ण उदाहरण दिया गया है (JSONC):

{
  "$schema": "https://opencode.ai/config.json",
  "default_agent": "LocalScribe",
  "model": "my_oai/gpt-5.3-codex",
  "small_model": "my_oai/gpt-5.3-codex",
  "autoupdate": false,
  "compaction": {
    "auto": true,
    "prune": true
  },
  "plugin": [
    "opencode-planpilot",
    "opencode-workbench"
  ],
  "provider": {
    "my_oai": {
      "name": "my_oai",
      "npm": "@ai-sdk/openai",
      "options": {
        "apiKey": "{env:OAI_API_KEY}",
        "baseURL": "https://your-gateway.example/v1",
        "setCacheKey": true
      },
      "models": {
        "gpt-5.3-codex": {
          "name": "gpt-5.3-codex",
          "attachment": true,
          "limit": {
            "context": 400000,
            "output": 128000
          },
          "modalities": {
            "input": ["text", "image", "pdf"],
            "output": ["text"]
          },
          "options": {
            "store": false,
            "include": ["reasoning.encrypted_content"]
          },
          "variants": {
            "low": { "reasoningEffort": "low", "reasoningSummary": "auto", "textVerbosity": "medium" },
            "medium": { "reasoningEffort": "medium", "reasoningSummary": "auto", "textVerbosity": "medium" },
            "high": { "reasoningEffort": "high", "reasoningSummary": "auto", "textVerbosity": "medium" }
          }
        }
      }
    }
  }
}

यह सेटअप टीम और व्यक्तिगत दोनों परिदृश्यों में अच्छा काम करता है: पढ़ने/लिखने की सीमाएं स्पष्ट रहती हैं, मॉडल व्यवहार सुसंगत रहता है, और प्लगइन-आधारित workflow विस्तार करना आसान होता है।

टिप्पणियां