Merge pull request #2230 from Chocothin/fix/respect-config-question-permission

fix(tool-config): respect question permission from OPENCODE_CONFIG_CONTENT
This commit is contained in:
acamq
2026-03-07 14:02:47 -07:00
committed by GitHub
2 changed files with 120 additions and 2 deletions
+16 -1
View File
@@ -3,6 +3,17 @@ import { getAgentDisplayName } from "../shared/agent-display-names";
type AgentWithPermission = { permission?: Record<string, unknown> };
function getConfigQuestionPermission(): string | null {
const configContent = process.env.OPENCODE_CONFIG_CONTENT;
if (!configContent) return null;
try {
const parsed = JSON.parse(configContent);
return parsed?.permission?.question ?? null;
} catch {
return null;
}
}
function agentByKey(agentResult: Record<string, unknown>, key: string): AgentWithPermission | undefined {
return (agentResult[key] ?? agentResult[getAgentDisplayName(key)]) as
| AgentWithPermission
@@ -32,7 +43,11 @@ export function applyToolConfig(params: {
};
const isCliRunMode = process.env.OPENCODE_CLI_RUN_MODE === "true";
const questionPermission = isCliRunMode ? "deny" : "allow";
const configQuestionPermission = getConfigQuestionPermission();
const questionPermission =
configQuestionPermission === "deny" ? "deny" :
isCliRunMode ? "deny" :
"allow";
const librarian = agentByKey(params.agentResult, "librarian");
if (librarian) {