@@ -50,6 +50,7 @@ export interface PluginConfig {
5050 debug : boolean
5151 pruneNotification : "off" | "minimal" | "detailed"
5252 turnProtection : TurnProtection
53+ protectedFilePatterns : string [ ]
5354 tools : Tools
5455 strategies : {
5556 deduplication : Deduplication
@@ -79,6 +80,7 @@ export const VALID_CONFIG_KEYS = new Set([
7980 "turnProtection" ,
8081 "turnProtection.enabled" ,
8182 "turnProtection.turns" ,
83+ "protectedFilePatterns" ,
8284 "tools" ,
8385 "tools.settings" ,
8486 "tools.settings.nudgeEnabled" ,
@@ -151,6 +153,22 @@ function validateConfigTypes(config: Record<string, any>): ValidationError[] {
151153 }
152154 }
153155
156+ if ( config . protectedFilePatterns !== undefined ) {
157+ if ( ! Array . isArray ( config . protectedFilePatterns ) ) {
158+ errors . push ( {
159+ key : "protectedFilePatterns" ,
160+ expected : "string[]" ,
161+ actual : typeof config . protectedFilePatterns ,
162+ } )
163+ } else if ( ! config . protectedFilePatterns . every ( ( v ) => typeof v === "string" ) ) {
164+ errors . push ( {
165+ key : "protectedFilePatterns" ,
166+ expected : "string[]" ,
167+ actual : "non-string entries" ,
168+ } )
169+ }
170+ }
171+
154172 // Top-level turnProtection validator
155173 if ( config . turnProtection ) {
156174 if (
@@ -371,6 +389,7 @@ const defaultConfig: PluginConfig = {
371389 enabled : false ,
372390 turns : 4 ,
373391 } ,
392+ protectedFilePatterns : [ ] ,
374393 tools : {
375394 settings : {
376395 nudgeEnabled : true ,
@@ -480,6 +499,9 @@ function createDefaultConfig(): void {
480499 "enabled": false,
481500 "turns": 4
482501 },
502+ // Protect file operations from pruning via glob patterns
503+ // Patterns match tool parameters.filePath (e.g. read/write/edit)
504+ "protectedFilePatterns": [],
483505 // LLM-driven context pruning tools
484506 "tools": {
485507 // Shared settings for all prune tools
@@ -615,6 +637,7 @@ function deepCloneConfig(config: PluginConfig): PluginConfig {
615637 return {
616638 ...config ,
617639 turnProtection : { ...config . turnProtection } ,
640+ protectedFilePatterns : [ ...config . protectedFilePatterns ] ,
618641 tools : {
619642 settings : {
620643 ...config . tools . settings ,
@@ -670,6 +693,12 @@ export function getConfig(ctx: PluginInput): PluginConfig {
670693 enabled : result . data . turnProtection ?. enabled ?? config . turnProtection . enabled ,
671694 turns : result . data . turnProtection ?. turns ?? config . turnProtection . turns ,
672695 } ,
696+ protectedFilePatterns : [
697+ ...new Set ( [
698+ ...config . protectedFilePatterns ,
699+ ...( result . data . protectedFilePatterns ?? [ ] ) ,
700+ ] ) ,
701+ ] ,
673702 tools : mergeTools ( config . tools , result . data . tools as any ) ,
674703 strategies : mergeStrategies ( config . strategies , result . data . strategies as any ) ,
675704 }
@@ -706,6 +735,12 @@ export function getConfig(ctx: PluginInput): PluginConfig {
706735 enabled : result . data . turnProtection ?. enabled ?? config . turnProtection . enabled ,
707736 turns : result . data . turnProtection ?. turns ?? config . turnProtection . turns ,
708737 } ,
738+ protectedFilePatterns : [
739+ ...new Set ( [
740+ ...config . protectedFilePatterns ,
741+ ...( result . data . protectedFilePatterns ?? [ ] ) ,
742+ ] ) ,
743+ ] ,
709744 tools : mergeTools ( config . tools , result . data . tools as any ) ,
710745 strategies : mergeStrategies ( config . strategies , result . data . strategies as any ) ,
711746 }
@@ -739,6 +774,12 @@ export function getConfig(ctx: PluginInput): PluginConfig {
739774 enabled : result . data . turnProtection ?. enabled ?? config . turnProtection . enabled ,
740775 turns : result . data . turnProtection ?. turns ?? config . turnProtection . turns ,
741776 } ,
777+ protectedFilePatterns : [
778+ ...new Set ( [
779+ ...config . protectedFilePatterns ,
780+ ...( result . data . protectedFilePatterns ?? [ ] ) ,
781+ ] ) ,
782+ ] ,
742783 tools : mergeTools ( config . tools , result . data . tools as any ) ,
743784 strategies : mergeStrategies ( config . strategies , result . data . strategies as any ) ,
744785 }
0 commit comments