feat(opencode): добавлены безопасные агенты и настройки разрешений
- Зачем: - необходим дополнительный уровень безопасности для предотвращения случайных изменений в репозитории - Что: - создан агент safe-plan для безопасного планирования (read-only) - создан агент safe-build с защищенным доступом к shell - установлен default_agent: "safe-plan" - обновлены глобальные permissions: все операции требуют подтверждения, git push запрещен - добавлен share: "manual" - Проверка: - проверка конфигурации через OpenCode UI
This commit is contained in:
1 parent
d357e743fa
commit
82a54d0541
3 files changed
+199
-6
No files matched your search
@@ -0,0 +1,78 @@
|
|||||||
|
---
|
||||||
|
description: Build agent with guarded shell access and no silent git mutations
|
||||||
|
mode: primary
|
||||||
|
|
||||||
|
tools:
|
||||||
|
write: true
|
||||||
|
edit: true
|
||||||
|
patch: true
|
||||||
|
bash: true
|
||||||
|
|
||||||
|
permission:
|
||||||
|
write: allow
|
||||||
|
edit: allow
|
||||||
|
patch: allow
|
||||||
|
webfetch: ask
|
||||||
|
|
||||||
|
task:
|
||||||
|
"*": deny
|
||||||
|
"explore": allow
|
||||||
|
|
||||||
|
bash:
|
||||||
|
"*": ask
|
||||||
|
|
||||||
|
# безопасное чтение
|
||||||
|
"pwd": allow
|
||||||
|
"ls": allow
|
||||||
|
"ls *": allow
|
||||||
|
"cat": allow
|
||||||
|
"cat *": allow
|
||||||
|
"head": allow
|
||||||
|
"head *": allow
|
||||||
|
"tail": allow
|
||||||
|
"tail *": allow
|
||||||
|
"wc -l": allow
|
||||||
|
"wc -l *": allow
|
||||||
|
|
||||||
|
# read-only git
|
||||||
|
"git status": allow
|
||||||
|
"git status *": allow
|
||||||
|
"git diff": allow
|
||||||
|
"git diff *": allow
|
||||||
|
"git log": allow
|
||||||
|
"git log *": allow
|
||||||
|
"git show": allow
|
||||||
|
"git show *": allow
|
||||||
|
"git blame": allow
|
||||||
|
"git blame *": allow
|
||||||
|
"git rev-parse": allow
|
||||||
|
"git rev-parse *": allow
|
||||||
|
"git branch --show-current": allow
|
||||||
|
"git branch --list*": allow
|
||||||
|
"git tag --list*": allow
|
||||||
|
|
||||||
|
# опасные git-операции — только с подтверждением
|
||||||
|
"git add*": ask
|
||||||
|
"git commit*": ask
|
||||||
|
"git switch*": ask
|
||||||
|
"git checkout*": ask
|
||||||
|
"git restore*": ask
|
||||||
|
"git reset*": ask
|
||||||
|
"git clean*": ask
|
||||||
|
"git merge*": ask
|
||||||
|
"git rebase*": ask
|
||||||
|
"git stash*": ask
|
||||||
|
"git fetch*": ask
|
||||||
|
"git pull*": ask
|
||||||
|
|
||||||
|
# push вообще запрещаем
|
||||||
|
"git push*": deny
|
||||||
|
---
|
||||||
|
|
||||||
|
You are a build agent.
|
||||||
|
|
||||||
|
Default to making code changes through native file-editing tools.
|
||||||
|
Use bash when it is the clearest path, but avoid unnecessary shell usage.
|
||||||
|
|
||||||
|
Never run git commit, branch switching, history rewriting, or network git operations without explicit user approval.
|
||||||
|
Prefer built-in tools for reading files and searching code.
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
---
|
||||||
|
description: Safe planning and repository analysis with read-only focus
|
||||||
|
mode: primary
|
||||||
|
|
||||||
|
tools:
|
||||||
|
write: false
|
||||||
|
edit: false
|
||||||
|
patch: false
|
||||||
|
bash: true
|
||||||
|
|
||||||
|
permission:
|
||||||
|
webfetch: ask
|
||||||
|
|
||||||
|
task:
|
||||||
|
"*": deny
|
||||||
|
"explore": allow
|
||||||
|
|
||||||
|
bash:
|
||||||
|
"*": ask
|
||||||
|
|
||||||
|
"pwd": allow
|
||||||
|
|
||||||
|
"ls": allow
|
||||||
|
"ls *": allow
|
||||||
|
|
||||||
|
"find": allow
|
||||||
|
"find *": allow
|
||||||
|
|
||||||
|
"cat": allow
|
||||||
|
"cat *": allow
|
||||||
|
"head": allow
|
||||||
|
"head *": allow
|
||||||
|
"tail": allow
|
||||||
|
"tail *": allow
|
||||||
|
"wc -l": allow
|
||||||
|
"wc -l *": allow
|
||||||
|
|
||||||
|
"rg": allow
|
||||||
|
"rg *": allow
|
||||||
|
|
||||||
|
"git status": allow
|
||||||
|
"git status *": allow
|
||||||
|
"git diff": allow
|
||||||
|
"git diff *": allow
|
||||||
|
"git log": allow
|
||||||
|
"git log *": allow
|
||||||
|
"git show": allow
|
||||||
|
"git show *": allow
|
||||||
|
"git blame": allow
|
||||||
|
"git blame *": allow
|
||||||
|
"git remote -v": allow
|
||||||
|
|
||||||
|
# жёсткий запрет на мутации
|
||||||
|
"git add*": deny
|
||||||
|
"git commit*": deny
|
||||||
|
"git switch*": deny
|
||||||
|
"git checkout*": deny
|
||||||
|
"git restore*": deny
|
||||||
|
"git reset*": deny
|
||||||
|
"git clean*": deny
|
||||||
|
"git merge*": deny
|
||||||
|
"git rebase*": deny
|
||||||
|
"git stash*": deny
|
||||||
|
"git push*": deny
|
||||||
|
"git pull*": deny
|
||||||
|
"git fetch*": deny
|
||||||
|
|
||||||
|
"rm *": deny
|
||||||
|
"mv *": deny
|
||||||
|
"cp *": deny
|
||||||
|
"tee *": deny
|
||||||
|
"chmod *": deny
|
||||||
|
"chown *": deny
|
||||||
|
"sed -i*": deny
|
||||||
|
"perl -pi*": deny
|
||||||
|
"python*": deny
|
||||||
|
"node*": deny
|
||||||
|
"sh -c*": deny
|
||||||
|
"bash -c*": deny
|
||||||
|
"npm *": deny
|
||||||
|
"pnpm *": deny
|
||||||
|
"yarn *": deny
|
||||||
|
"bun *": deny
|
||||||
|
---
|
||||||
|
|
||||||
|
You are a planning and analysis agent.
|
||||||
|
|
||||||
|
For repository briefing:
|
||||||
|
1. First inspect README, root manifests, and top-level directories using built-in tools.
|
||||||
|
2. Use bash only for:
|
||||||
|
- file discovery across the repo
|
||||||
|
- git history and change analysis
|
||||||
|
- quick read-only summaries
|
||||||
|
3. Never use bash for edits or execution of interpreters.
|
||||||
|
|
||||||
|
Prefer:
|
||||||
|
- read/list/glob/grep for content inspection
|
||||||
|
- git log/show/diff/blame for history
|
||||||
|
- find/rg only when built-in tools are inconvenient
|
||||||
@@ -1,14 +1,24 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://opencode.ai/config.json",
|
"$schema": "https://opencode.ai/config.json",
|
||||||
|
|
||||||
|
// По умолчанию всегда стартуем в безопасном режиме
|
||||||
|
"default_agent": "safe-plan",
|
||||||
|
|
||||||
|
// Глобальный baseline: если случайно переключился на встроенный build,
|
||||||
|
// ничего критичного не должно улететь без вопросов.
|
||||||
"permission": {
|
"permission": {
|
||||||
|
"write": "ask",
|
||||||
|
"edit": "ask",
|
||||||
|
"patch": "ask",
|
||||||
|
"webfetch": "ask",
|
||||||
|
"task": "ask",
|
||||||
"bash": {
|
"bash": {
|
||||||
"git commit*": "ask",
|
"*": "ask",
|
||||||
"git commit --amend*": "ask",
|
"git push": "deny",
|
||||||
"git branch*": "ask",
|
"git push *": "deny"
|
||||||
"git switch*": "ask",
|
|
||||||
"git *": "allow"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
"mcp": {
|
"mcp": {
|
||||||
"context7": {
|
"context7": {
|
||||||
"type": "remote",
|
"type": "remote",
|
||||||
@@ -18,6 +28,7 @@
|
|||||||
},
|
},
|
||||||
"enabled": true
|
"enabled": true
|
||||||
},
|
},
|
||||||
|
|
||||||
"web-reader": {
|
"web-reader": {
|
||||||
"type": "remote",
|
"type": "remote",
|
||||||
"url": "https://api.z.ai/api/mcp/web_reader/mcp",
|
"url": "https://api.z.ai/api/mcp/web_reader/mcp",
|
||||||
@@ -26,6 +37,7 @@
|
|||||||
},
|
},
|
||||||
"enabled": false
|
"enabled": false
|
||||||
},
|
},
|
||||||
|
|
||||||
"web-search-prime": {
|
"web-search-prime": {
|
||||||
"type": "remote",
|
"type": "remote",
|
||||||
"url": "https://api.z.ai/api/mcp/web_search_prime/mcp",
|
"url": "https://api.z.ai/api/mcp/web_search_prime/mcp",
|
||||||
@@ -34,6 +46,7 @@
|
|||||||
},
|
},
|
||||||
"enabled": false
|
"enabled": false
|
||||||
},
|
},
|
||||||
|
|
||||||
"zread": {
|
"zread": {
|
||||||
"type": "remote",
|
"type": "remote",
|
||||||
"url": "https://api.z.ai/api/mcp/zread/mcp",
|
"url": "https://api.z.ai/api/mcp/zread/mcp",
|
||||||
@@ -42,10 +55,13 @@
|
|||||||
},
|
},
|
||||||
"enabled": false
|
"enabled": false
|
||||||
},
|
},
|
||||||
|
|
||||||
"playwright": {
|
"playwright": {
|
||||||
"type": "local",
|
"type": "local",
|
||||||
"command": ["npx", "-y", "@playwright/mcp@latest"],
|
"command": ["npx", "-y", "@playwright/mcp@latest"],
|
||||||
"enabled": false
|
"enabled": false
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
|
"share": "manual"
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user