OpenCode Config شیئر: Layered Agents، Permissions اور مکمل مثال

canxin کی جانب سے3 منٹ کا مطالعہ


فہرستِ مضامین

  1. 1. Merge order اور precedence
  2. 2. Top-level config fields
  3. 3. Layered agent design
    1. 3.1 LocalReader
    2. 3.2 LocalScribe (default)
    3. 3.3 OmniReader
    4. 3.4 OmniScribe
  4. 4. Provider اور model catalog ساخت
    1. 4.1 Common model JSON structure
    2. 4.2 Model field reference
  5. 5. Plugin loading
    1. 5.1 opencode-planpilot (npm)
    2. 5.2 opencode-workbench (npm)
  6. 6. مکمل کنفگ (حوالہ)

1. Merge order اور precedence

Precedence (کم -> زیادہ):

  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

تجویز: دیرپا defaults کو global رکھیں، اور repo-specific قواعد ہر repository میں الگ رکھیں۔

2. Top-level config fields

اوپر کی سطح کے بنیادی fields:

{
  "$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. Layered agent design

موجودہ permission اقدار کی بنیاد پر حقیقی حدود (ایک جدول):

Agentreadeditexternal_directorybashنتیجہ
LocalReaderread.* = allow (بشمول *.env)askaskaskworkspace میں براہِ راست read؛ باہر read/write کے لیے تصدیق درکار
LocalScriberead.* = allow (بشمول *.env)* = allow, *../* = denyallow* = allow, خطرناک patterns پر askglobal read، لکھائی عموماً workspace کے اندر
OmniReaderread.* = allow (بشمول *.env)askallowaskglobal read؛ لکھائی کے لیے تصدیق درکار
OmniScribe* = allow (جس میں read شامل)* = allowallow* = allow, خطرناک patterns پر askglobal read/write

LocalScribe کو “عموماً workspace writable” اس لیے کہا جاتا ہے کہ traversal کو *../* = deny روکتا ہے۔ سخت workspace-only writes کے لیے external_directory کو ask یا deny پر رکھیں۔

Disabled 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 (default)

"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 structure:

  1. provider metadata: name, npm
  2. provider connection options: options.baseURL, options.apiKey, options.setCacheKey
  3. models map: ہر model کے لیے ایک object

4.1 Common model JSON structure

"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 Model field reference

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
options.includestring[]اضافی returned fields
variantsobjectہر model کے reasoning profiles

5. Plugin loading

Plugin config:

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

5.1 opencode-planpilot (npm)

5.2 opencode-workbench (npm)

6. مکمل کنفگ (حوالہ)

اس localized ورژن کو مختصر رکھنے کے لیے بہت بڑا JSONC بلاک یہاں دوبارہ نہیں دیا گیا۔ ضرورت ہو تو مکمل کنفگ انگریزی ورژن سے جوں کا توں استعمال کیا جا سکتا ہے۔

براہِ راست لنک: English

تبصرے