Skip to content

Commit 7971886

Browse files
Replace compress enabled with permission enum (ask/allow/deny)
1 parent 9f3903f commit 7971886

6 files changed

Lines changed: 32 additions & 32 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ DCP uses its own config file:
117117
> },
118118
> // Collapses a range of conversation content into a single summary
119119
> "compress": {
120-
> "enabled": true,
120+
> // Permission mode: "ask" (prompt), "allow" (no prompt), "deny" (tool not registered)
121+
> "permission": "ask",
121122
> // Show summary content as an ignored message notification
122123
> "showCompression": false,
123124
> },

dcp.schema.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,11 @@
146146
"description": "Configuration for the compress tool",
147147
"additionalProperties": false,
148148
"properties": {
149-
"enabled": {
150-
"type": "boolean",
151-
"default": true,
152-
"description": "Enable the compress tool"
149+
"permission": {
150+
"type": "string",
151+
"enum": ["ask", "allow", "deny"],
152+
"default": "ask",
153+
"description": "Permission mode (deny disables the tool)"
153154
},
154155
"showCompression": {
155156
"type": "boolean",

index.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const plugin: Plugin = (async (ctx) => {
7070
workingDirectory: ctx.directory,
7171
}),
7272
}),
73-
...(config.tools.compress.enabled && {
73+
...(config.tools.compress.permission !== "deny" && {
7474
compress: createCompressTool({
7575
client: ctx.client,
7676
state,
@@ -100,7 +100,7 @@ const plugin: Plugin = (async (ctx) => {
100100

101101
const toolsToAdd: string[] = []
102102
if (config.tools.distill.enabled) toolsToAdd.push("distill")
103-
if (config.tools.compress.enabled) toolsToAdd.push("compress")
103+
if (config.tools.compress.permission !== "deny") toolsToAdd.push("compress")
104104
if (config.tools.prune.enabled) toolsToAdd.push("prune")
105105

106106
if (toolsToAdd.length > 0) {
@@ -113,15 +113,13 @@ const plugin: Plugin = (async (ctx) => {
113113
`Added ${toolsToAdd.map((t) => `'${t}'`).join(" and ")} to experimental.primary_tools via config mutation`,
114114
)
115115

116-
// Set compress permission to ask (only if not already configured)
117-
if (config.tools.compress.enabled) {
116+
// Set compress permission from DCP config
117+
if (config.tools.compress.permission !== "deny") {
118118
const permission = opencodeConfig.permission ?? {}
119-
if (!("compress" in permission)) {
120-
opencodeConfig.permission = {
121-
...permission,
122-
compress: "ask",
123-
} as typeof permission
124-
}
119+
opencodeConfig.permission = {
120+
...permission,
121+
compress: config.tools.compress.permission,
122+
} as typeof permission
125123
}
126124
}
127125
},

lib/config.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export interface DistillTool {
1919
}
2020

2121
export interface CompressTool {
22-
enabled: boolean
22+
permission: "ask" | "allow" | "deny"
2323
showCompression: boolean
2424
}
2525

@@ -111,7 +111,7 @@ export const VALID_CONFIG_KEYS = new Set([
111111
"tools.distill.enabled",
112112
"tools.distill.showDistillation",
113113
"tools.compress",
114-
"tools.compress.enabled",
114+
"tools.compress.permission",
115115
"tools.compress.showCompression",
116116
"tools.prune",
117117
"tools.prune.enabled",
@@ -322,15 +322,15 @@ function validateConfigTypes(config: Record<string, any>): ValidationError[] {
322322
}
323323
}
324324
if (tools.compress) {
325-
if (
326-
tools.compress.enabled !== undefined &&
327-
typeof tools.compress.enabled !== "boolean"
328-
) {
329-
errors.push({
330-
key: "tools.compress.enabled",
331-
expected: "boolean",
332-
actual: typeof tools.compress.enabled,
333-
})
325+
if (tools.compress.permission !== undefined) {
326+
const validValues = ["ask", "allow", "deny"]
327+
if (!validValues.includes(tools.compress.permission)) {
328+
errors.push({
329+
key: "tools.compress.permission",
330+
expected: '"ask" | "allow" | "deny"',
331+
actual: JSON.stringify(tools.compress.permission),
332+
})
333+
}
334334
}
335335
if (
336336
tools.compress.showCompression !== undefined &&
@@ -503,7 +503,7 @@ const defaultConfig: PluginConfig = {
503503
showDistillation: false,
504504
},
505505
compress: {
506-
enabled: true,
506+
permission: "ask",
507507
showCompression: false,
508508
},
509509
prune: {
@@ -680,7 +680,7 @@ function mergeTools(
680680
showDistillation: override.distill?.showDistillation ?? base.distill.showDistillation,
681681
},
682682
compress: {
683-
enabled: override.compress?.enabled ?? base.compress.enabled,
683+
permission: override.compress?.permission ?? base.compress.permission,
684684
showCompression: override.compress?.showCompression ?? base.compress.showCompression,
685685
},
686686
prune: {

lib/hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function createSystemPromptHandler(
4545
const flags = {
4646
prune: config.tools.prune.enabled,
4747
distill: config.tools.distill.enabled,
48-
compress: config.tools.compress.enabled,
48+
compress: config.tools.compress.permission !== "deny",
4949
}
5050

5151
if (!flags.prune && !flags.distill && !flags.compress) {

lib/messages/inject.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const getNudgeString = (config: PluginConfig): string => {
5959
const flags = {
6060
prune: config.tools.prune.enabled,
6161
distill: config.tools.distill.enabled,
62-
compress: config.tools.compress.enabled,
62+
compress: config.tools.compress.permission !== "deny",
6363
}
6464

6565
if (!flags.prune && !flags.distill && !flags.compress) {
@@ -73,7 +73,7 @@ const getCooldownMessage = (config: PluginConfig): string => {
7373
return wrapCooldownMessage({
7474
prune: config.tools.prune.enabled,
7575
distill: config.tools.distill.enabled,
76-
compress: config.tools.compress.enabled,
76+
compress: config.tools.compress.permission !== "deny",
7777
})
7878
}
7979

@@ -159,7 +159,7 @@ export const insertPruneToolContext = (
159159
): void => {
160160
const pruneEnabled = config.tools.prune.enabled
161161
const distillEnabled = config.tools.distill.enabled
162-
const compressEnabled = config.tools.compress.enabled
162+
const compressEnabled = config.tools.compress.permission !== "deny"
163163

164164
if (!pruneEnabled && !distillEnabled && !compressEnabled) {
165165
return

0 commit comments

Comments
 (0)