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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user