Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix: pre-landing review fixes (thin-client setup indexes only the skills its loader serves; connect refuses an unknown --skill-loading)
garrytan953a71870a6c
diff --git a/src/commands/setup.ts b/src/commands/setup.tsindex 8e56346ae1..9668cebf1f 100644--- a/src/commands/setup.ts+++ b/src/commands/setup.ts@@ -34,7 +34,7 @@ import { writeCliNotices } from '../core/interop-notices.ts';import { setupFirstRunNotices } from './init-first-run.ts';import { hostedOptionMuted, hostedOptionNotice, writeHostedOption } from '../core/onboard/hosted-option.ts';import { writeJsonDocument } from '../core/cli-force-exit.ts';-import { configDir, gbrainPath, loadConfig, type GBrainConfig } from '../core/config.ts';+import { configDir, gbrainPath, isThinClient, loadConfig, type GBrainConfig } from '../core/config.ts';import { resolveGbrainBin } from '../core/gbrain-bin.ts';import { isRegistrationSurface, isValidName, REGISTRATION_SURFACE, registrationAdvertise, stdioServeArgv } from '../core/mcp-registration.ts';import { hookLauncherPath } from '../core/setup/hook-launcher.ts';@@ -770,7 +770,7 @@ function removeBrainFirstFor(harness: BrainFirstHarness, where: { scope?: Wiringfunction skillsFor(harness: BrainFirstHarness, flags: SetupFlags, launcher: string, where: { scope?: WiringScope; projectDir?: string }, brainFirst: BrainFirstOutcome | null): SkillsBlockOutcome | null {const target = brainFirstTarget(harness, { ...where, workspace: flags.workspace });if ('error' in target) return null;- return installerSkillsBlock({ target, launcher, writer: `gbrain setup ${harness}`, brainFirstDeclined: brainFirst?.decision.value === 'declined', skillLoading: flags.skillLoading, dryRun: flags.dryRun });+ return installerSkillsBlock({ target, launcher, writer: `gbrain setup ${harness}`, brainFirstDeclined: brainFirst?.decision.value === 'declined', skillLoading: flags.skillLoading, audience: isThinClient(loadConfig()) ? 'downstream' : 'owner', dryRun: flags.dryRun });}function removeSkillsFor(harness: BrainFirstHarness, where: { scope?: WiringScope; projectDir?: string }, flags: SetupFlags): SkillsBlockOutcome | null {diff --git a/test/connect.test.ts b/test/connect.test.tsindex 0f37349070..1618a89b8b 100644--- a/test/connect.test.ts+++ b/test/connect.test.ts@@ -536,6 +536,17 @@ describe('runConnect --install', () => {expect(seen).toEqual([['spring', '/opt/alice-example/gbrain']]);});+ test('an unknown --skill-loading value is refused before anything is installed', async () => {+ const seen: unknown[] = [];+ const r = await runWithExitCapture(+ ['https://brain.example.com/mcp', '--token', 'gbrain_tok', '--install', '--yes', '--skill-loading', 'always'],+ installDeps({ writeInstructions: (...a) => { seen.push(a); return null; } }),+ );+ expect(r.exitCode).not.toBe(0);+ expect(r.err.join('\n')).toContain("Unknown --skill-loading 'always'");+ expect(seen).toEqual([]);+ });+test('probe failure warns + exits 1 + never echoes the token', async () => {const r = await runWithExitCapture(['https://brain.example.com/mcp', '--token', 'gbrain_secret', '--install', '--yes'],diff --git a/test/setup-skill-loading.test.ts b/test/setup-skill-loading.test.tsindex c8e21296ed..d7e7d0e9a9 100644--- a/test/setup-skill-loading.test.ts+++ b/test/setup-skill-loading.test.ts@@ -23,7 +23,7 @@ import { runCli } from './helpers/cli-spawn.ts';import { withEnv } from './helpers/with-env.ts';import { BRAIN_FIRST_BEGIN, BRAIN_FIRST_END } from '../src/core/setup/brain-first.ts';import { inspectSkillsBlock, loaderAllowRule, renderSkillsBlock, SKILLS_BLOCK_BEGIN, SKILLS_BLOCK_END } from '../src/core/setup/skills-block.ts';-import { bundledCatalogId } from '../src/core/skills/bundled.ts';+import { bundledCatalogId, bundledSkills } from '../src/core/skills/bundled.ts';const CLI = join(import.meta.dir, '..', 'src', 'cli.ts');const BIN_DIR = mkdtempSync(join(tmpdir(), 'gbrain-skill-bin-'));@@ -175,6 +175,21 @@ describe('skill loading: selection', () => {expect(ledger.entries[0]).toMatchObject({ harness: 'claude-code', mode: 'spring', launcher: LAUNCHER, audience: 'owner', catalog: bundledCatalogId() });});+ test('on a thin-client install the index lists only the skills the loader serves there', async () => {+ const b = box();+ mkdirSync(join(b.home, '.gbrain'), { recursive: true });+ writeFileSync(join(b.home, '.gbrain', 'config.json'), JSON.stringify({ remote_mcp: { mcp_url: 'https://brain.example.test/mcp' } }));+ const r = await setup(b, ['codex', '--instructions-only', '--gbrain-bin', LAUNCHER, '--skill-loading', 'spring']);+ expect(r.exitCode).toBe(0);+ const text = read(join(b.home, '.codex', 'AGENTS.md'));+ const hostOnly = bundledSkills('owner').filter((s) => s.audience === 'owner');+ expect(hostOnly.length).toBeGreaterThan(0);+ for (const s of hostOnly) expect(text).not.toContain('- ' + s.name + ':');+ for (const s of bundledSkills('downstream')) expect(text).toContain('- ' + s.name + ':');+ const ledger = JSON.parse(read(join(b.home, '.gbrain', 'skill-loading.json')));+ expect(ledger.entries[0]).toMatchObject({ harness: 'codex', mode: 'spring', audience: 'downstream' });+ });+test('an index an upgrade left behind (older catalog) is reported stale and a bare re-run refreshes it', async () => {const b = box();const file = join(b.home, '.claude', 'CLAUDE.md');