Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(cli): doctor --scope and models doctor --skip read the separate-value form (#7624)
garrytan9a6e8beeaad4
diff --git a/src/cli/flag-equals.ts b/src/cli/flag-equals.tsindex d1dfbaa3b4..b533f42f7a 100644--- a/src/cli/flag-equals.ts+++ b/src/cli/flag-equals.ts@@ -91,7 +91,7 @@ export const EQUALS_READERS: Readonly<Record<string, readonly string[]>> = {'compile-context': ['--target', '--budget', '--include', '--out', '--source'],// core/consent.ts:123 parseConsentFlags via enableConsent (decide.ts:348, effects paid); decide reads no --max-* itself.'decide enable': ['--max-usd', '--max-cost'],- // doctor.ts:417 --scope=brain only (=-only); doctor/budget.ts:68 --tier/--budget-ms; cli/commands/doctor.ts:27 --tier (thin client);+ // doctor/budget.ts parseDoctorScope --scope (both forms, #7624); doctor/budget.ts:68 --tier/--budget-ms; cli/commands/doctor.ts:27 --tier (thin client);// doctor/registry.ts:332 --only; check-resolvable.ts:120 --skills-dir via doctor.ts:460; core/consent.ts:130 --expect (remediate-consent.ts:133).doctor: ['--scope', '--tier', '--budget-ms', '--only', '--skills-dir', '--expect'],// edge-proposals.ts:81 flag() used only by list (:91,:93); other subs take the first numeric token as the id (:86).@@ -136,7 +136,7 @@ export const EQUALS_READERS: Readonly<Record<string, readonly string[]>> = {lint: ['--exclude'],// migrate-graduation.ts:97 flagValue (parseGraduationArgs :121-151); graduation-only flags, the legacy copier (migrate-engine.ts) never reads them.migrate: ['--url-env', '--trigger-bypass', '--drain-timeout', '--batch-size', '--expect'],- // models.ts:853 doctor mode only (sub selection :818), repeated --skip=<provider>, =-only.+ // models.ts parseSkipProviders, doctor mode only, repeated --skip <provider> or --skip=<provider> (#7624).'models doctor': ['--skip'],// core/bounded-listing-cli.ts:15 parseListingFlags via orphans.ts:353.orphans: ['--limit', '--cursor'],diff --git a/src/commands/doctor.ts b/src/commands/doctor.tsindex 55607d634e..8b8013469b 100644--- a/src/commands/doctor.ts+++ b/src/commands/doctor.ts@@ -136,7 +136,7 @@ export {buildRetrievalReflexCheck,} from './doctor/checks/verbs-reflex.ts';import type { DoctorContext, DoctorTier } from './doctor/context.ts';-import { doctorRunSummary, parseDoctorTier, scoredChecks, startDoctorDeadline, tierFields, type DoctorDeadline, type DoctorRunSummary, type ScoreCategory } from './doctor/budget.ts';+import { doctorRunSummary, parseDoctorScope, parseDoctorTier, scoredChecks, startDoctorDeadline, tierFields, type DoctorDeadline, type DoctorRunSummary, type ScoreCategory } from './doctor/budget.ts';export { doctorRunSummary, type DoctorRunSummary } from './doctor/budget.ts';import { runDoctorRegistry, parseOnlyChecks, doctorRefreshRegistry } from './doctor/registry.ts';import { finalizeCheckFixes, fixLine, unknownScoreCategories, type CheckAgentFields } from './doctor/check-fix.ts';@@ -414,7 +414,7 @@ export async function buildChecks(// `runResolverChecks`-equivalent invocations are gated below; the same gate// covers `whoknows_health` (the one DB-dependent skill check) where it's// invoked later in the function.- const scope: 'all' | 'brain' = args.includes('--scope=brain') ? 'brain' : 'all';+ const scope = parseDoctorScope(args);// v0.41.29.0: explicit `--source <id>` scopes the `orphan_ratio` check to one// source. EXPLICIT-ONLY by design — a raw flag parse, NOT resolveSourceWithTier.diff --git a/src/commands/doctor/budget.ts b/src/commands/doctor/budget.tsindex 944febba74..aec22d9253 100644--- a/src/commands/doctor/budget.ts+++ b/src/commands/doctor/budget.ts@@ -83,6 +83,15 @@ export function parseDoctorTier(args: readonly string[]): DoctorTier {why: 'The ops tier answers the operational questions (capacity, failures, embedding, sync, compaction, serve build) in seconds.' } });}+/** `--scope <all|brain>` or `--scope=<all|brain>` (default `all`); any other value is `invalid_params` (#7624: the separate form was ignored). */+export function parseDoctorScope(args: readonly string[]): 'all' | 'brain' {+ const raw = flagValue(args, '--scope') ?? 'all';+ if (raw === 'all' || raw === 'brain') return raw;+ throw opError('invalid_params', `Unknown doctor scope: ${raw}`, 'Valid scopes: all (default), brain (skips the skill-file check group).',+ { fix: { argv: ['gbrain', 'doctor', '--scope', 'brain', '--json'], consent: [], actor: 'agent', requires_exclusive: false,+ why: 'The brain scope runs every check except the skill-file group.' } });+}+/** `--budget-ms <n>` (a non-negative integer; 0: no overall budget), else the tier default. */export function parseBudgetMs(args: readonly string[], tier: DoctorTier): number | null {const raw = flagValue(args, '--budget-ms');diff --git a/src/commands/models.ts b/src/commands/models.tsindex 2b6a7273c3..cba4634cf4 100644--- a/src/commands/models.ts+++ b/src/commands/models.ts@@ -22,7 +22,7 @@** Flags:* --json — JSON output (both modes)- * --skip=<provider> — narrow `doctor` probe to skip a provider+ * --skip <provider> — narrow `doctor` probe to skip a provider* (e.g. cost-sensitive operators with rate limits)** Per Codex F11 in plan review: no specific dollar cost claim. Probe uses@@ -793,6 +793,12 @@ export async function probeModel(modelStr: string, touchpoint: 'chat' | 'expansi}}+/** `--skip <provider>` and `--skip=<provider>`, repeatable (#7624: the separate form was ignored, so the skipped provider was probed). */+export function parseSkipProviders(args: readonly string[]): string[] {+ return args.flatMap((a, i) => a.startsWith('--skip=') ? [a.slice('--skip='.length)] : a === '--skip' && args[i + 1] !== undefined && !args[i + 1]!.startsWith('-') ? [args[i + 1]!] : [])+ .map(s => s.toLowerCase()).filter(Boolean);+}+function shouldSkipProvider(modelStr: string, skip: string[]): boolean {if (skip.length === 0) return false;const colon = modelStr.indexOf(':');@@ -825,8 +831,8 @@ export async function runModels(engine: BrainEngine, args: string[]): Promise<vogbrain models --json Machine-readable outputFlags (doctor only):- --skip=<provider> Skip a provider (e.g. --skip=openai)- Repeatable: --skip=openai --skip=google+ --skip <provider> Skip a provider (e.g. --skip openai or --skip=openai)+ Repeatable: --skip openai --skip google--json JSON outputConfigure routing:@@ -850,8 +856,7 @@ Tiers: utility (haiku-class) | reasoning (sonnet) | deep (opus) | subagent (Anth}// doctor mode- const skipArgs = args.filter(a => a.startsWith('--skip='));- const skip = skipArgs.map(a => a.slice('--skip='.length).toLowerCase()).filter(Boolean);+ const skip = parseSkipProviders(args);const { getChatModel, getExpansionModel } = await import('../core/ai/gateway.ts');const chatModel = getChatModel();diff --git a/test/doctor-scope-filter.test.ts b/test/doctor-scope-filter.test.tsindex ff5244e6bc..5f8f0ae3b4 100644--- a/test/doctor-scope-filter.test.ts+++ b/test/doctor-scope-filter.test.ts@@ -92,3 +92,18 @@ describe('buildChecks --scope=brain skip-computation contract', () => {});});});++// Value: protects=doctor --scope brain (separate value) skips the skill group like --scope=brain, and an unknown scope refuses; fails_when=the separate form runs the full skill group (and --fix can edit SKILL.md files the operator asked to skip); why_new=#7624; seam=none; no_claim=thin-client doctor+describe('#7624 doctor --scope reads both forms', () => {+ test('--scope brain skips the SKILL group; an unknown scope is invalid_params', async () => {+ const skillsDir = makeSkillsTree();+ await withEnv({ GBRAIN_SKILLS_DIR: skillsDir, GBRAIN_NO_BANNER: '1' }, async () => {+ const checks = await buildChecks(null, ['--scope', 'brain', '--fast']);+ expect(checks.filter(c => ['resolver_health', 'skill_conformance', 'skill_brain_first', 'whoknows_health'].includes(c.name))).toEqual([]);+ });+ const { parseDoctorScope } = await import('../src/commands/doctor/budget.ts');+ expect(parseDoctorScope([])).toBe('all');+ expect(parseDoctorScope(['--scope=all'])).toBe('all');+ expect(() => parseDoctorScope(['--scope', 'brains'])).toThrow('Unknown doctor scope: brains');+ });+});diff --git a/test/models-doctor-reranker.test.ts b/test/models-doctor-reranker.test.tsindex e3e67aa74f..3f59e2aa08 100644--- a/test/models-doctor-reranker.test.ts+++ b/test/models-doctor-reranker.test.ts@@ -14,7 +14,7 @@*/import { describe, test, expect, afterEach } from 'bun:test';-import { probeRerankerReachability, resolveLiveRerankerModel } from '../src/commands/models.ts';+import { parseSkipProviders, probeRerankerReachability, resolveLiveRerankerModel } from '../src/commands/models.ts';import { configureGateway, resetGateway } from '../src/core/ai/gateway.ts';/**@@ -128,3 +128,12 @@ describe('probeRerankerReachability — discrimination (#6381)', () => {expect(missing?.message).toContain('did not return a score for both');});});++// Value: protects=models doctor skips a provider named with the separate form; fails_when=--skip openai is ignored, so the provider the operator skipped is probed (tokens spent, exit 1 on a broken key); why_new=#7624; seam=none; no_claim=the probes themselves+describe('#7624 models doctor --skip', () => {+ test('reads --skip <provider> and --skip=<provider>, repeatable', () => {+ expect(parseSkipProviders(['doctor', '--skip', 'openai'])).toEqual(['openai']);+ expect(parseSkipProviders(['doctor', '--skip=Google', '--skip', 'openai', '--json'])).toEqual(['google', 'openai']);+ expect(parseSkipProviders(['doctor', '--skip', '--json'])).toEqual([]);+ });+});