MCPcopy
hub / github.com/codeaashu/claude-code / autoModeCritiqueHandler

Function autoModeCritiqueHandler

src/cli/handlers/autoMode.ts:73–149  ·  view source on GitHub ↗
(options: {
  model?: string
})

Source from the content-addressed store, hash-verified

71 'If all rules look good, say so.'
72
73export async function autoModeCritiqueHandler(options: {
74 model?: string
75}): Promise<void> {
76 const config = getAutoModeConfig()
77 const hasCustomRules =
78 (config?.allow?.length ?? 0) > 0 ||
79 (config?.soft_deny?.length ?? 0) > 0 ||
80 (config?.environment?.length ?? 0) > 0
81
82 if (!hasCustomRules) {
83 process.stdout.write(
84 'No custom auto mode rules found.\n\n' +
85 'Add rules to your settings file under autoMode.{allow, soft_deny, environment}.\n' +
86 'Run `claude auto-mode defaults` to see the default rules for reference.\n',
87 )
88 return
89 }
90
91 const model = options.model
92 ? parseUserSpecifiedModel(options.model)
93 : getMainLoopModel()
94
95 const defaults = getDefaultExternalAutoModeRules()
96 const classifierPrompt = buildDefaultExternalSystemPrompt()
97
98 const userRulesSummary =
99 formatRulesForCritique('allow', config?.allow ?? [], defaults.allow) +
100 formatRulesForCritique(
101 'soft_deny',
102 config?.soft_deny ?? [],
103 defaults.soft_deny,
104 ) +
105 formatRulesForCritique(
106 'environment',
107 config?.environment ?? [],
108 defaults.environment,
109 )
110
111 process.stdout.write('Analyzing your auto mode rules…\n\n')
112
113 let response
114 try {
115 response = await sideQuery({
116 querySource: 'auto_mode_critique',
117 model,
118 system: CRITIQUE_SYSTEM_PROMPT,
119 skipSystemPromptPrefix: true,
120 max_tokens: 4096,
121 messages: [
122 {
123 role: 'user',
124 content:
125 'Here is the full classifier system prompt that the auto mode classifier receives:\n\n' +
126 '<classifier_system_prompt>\n' +
127 classifierPrompt +
128 '\n</classifier_system_prompt>\n\n' +
129 "Here are the user's custom rules that REPLACE the corresponding default sections:\n\n" +
130 userRulesSummary +

Callers 1

runFunction · 0.85

Calls 9

getAutoModeConfigFunction · 0.85
parseUserSpecifiedModelFunction · 0.85
getMainLoopModelFunction · 0.85
formatRulesForCritiqueFunction · 0.85
sideQueryFunction · 0.85
errorMessageFunction · 0.50
writeMethod · 0.45

Tested by

no test coverage detected