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

Function call

src/commands/advisor.ts:16–94  ·  view source on GitHub ↗
(args, context)

Source from the content-addressed store, hash-verified

14import { updateSettingsForSource } from '../utils/settings/settings.js'
15
16const call: LocalCommandCall = async (args, context) => {
17 const arg = args.trim().toLowerCase()
18 const baseModel = parseUserSpecifiedModel(
19 context.getAppState().mainLoopModel ?? getDefaultMainLoopModelSetting(),
20 )
21
22 if (!arg) {
23 const current = context.getAppState().advisorModel
24 if (!current) {
25 return {
26 type: 'text',
27 value:
28 'Advisor: not set\nUse "/advisor <model>" to enable (e.g. "/advisor opus").',
29 }
30 }
31 if (!modelSupportsAdvisor(baseModel)) {
32 return {
33 type: 'text',
34 value: `Advisor: ${current} (inactive)\nThe current model (${baseModel}) does not support advisors.`,
35 }
36 }
37 return {
38 type: 'text',
39 value: `Advisor: ${current}\nUse "/advisor unset" to disable or "/advisor <model>" to change.`,
40 }
41 }
42
43 if (arg === 'unset' || arg === 'off') {
44 const prev = context.getAppState().advisorModel
45 context.setAppState(s => {
46 if (s.advisorModel === undefined) return s
47 return { ...s, advisorModel: undefined }
48 })
49 updateSettingsForSource('userSettings', { advisorModel: undefined })
50 return {
51 type: 'text',
52 value: prev
53 ? `Advisor disabled (was ${prev}).`
54 : 'Advisor already unset.',
55 }
56 }
57
58 const normalizedModel = normalizeModelStringForAPI(arg)
59 const resolvedModel = parseUserSpecifiedModel(arg)
60 const { valid, error } = await validateModel(resolvedModel)
61 if (!valid) {
62 return {
63 type: 'text',
64 value: error
65 ? `Invalid advisor model: ${error}`
66 : `Unknown model: ${arg} (${resolvedModel})`,
67 }
68 }
69
70 if (!isValidAdvisorModel(resolvedModel)) {
71 return {
72 type: 'text',
73 value: `The model ${arg} (${resolvedModel}) cannot be used as an advisor`,

Callers

nothing calls this directly

Calls 7

parseUserSpecifiedModelFunction · 0.85
modelSupportsAdvisorFunction · 0.85
updateSettingsForSourceFunction · 0.85
validateModelFunction · 0.85
isValidAdvisorModelFunction · 0.85

Tested by

no test coverage detected