Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(schema): honor --source in schema show
garrytanbb1e1ee5c33e
diff --git a/src/commands/schema.ts b/src/commands/schema.tsindex 0cf730727d..b50746bd96 100644--- a/src/commands/schema.ts+++ b/src/commands/schema.ts@@ -30,6 +30,7 @@ import {addTypeToPack,invalidatePackCache,loadActivePack,+ loadActivePackForEngine,loadResolvedPackByName,removeAliasFromType,removeLinkTypeFromPack,@@ -120,7 +121,8 @@ function printHelp(): void {Inspection:active Show resolved pack + which tier provided itlist List installed packs (bundled + ~/.gbrain/schema-packs/)- show [<pack>] Pretty-print a manifest (default: active pack)+ show [<pack>] [--source <id>]+ Pretty-print a manifest (default: active pack, or that source's)validate [<pack>] Validate manifest shape against the v1 schemagraph Show type/primitive graph with link-verb edgeslint [<pack>] Lint a pack for duplicates, dangling refs, etc.@@ -244,9 +246,9 @@ async function runShow(args: string[]): Promise<void> {// consumer migration + deletion deferred to v0.39.1 to avoid breaking// synthesize/patterns/filing-audit/check-resolvable mid-wave.const asFilingRules = args.includes('--as-filing-rules');- const jsonFlag = args.includes('--json') || asFilingRules;- const packArg = args.find((a) => !a.startsWith('--'));- const packName = packArg;+ const { json, source, positional } = parseFlags(args);+ const jsonFlag = json || asFilingRules;+ const packName = positional.find((a) => !a.startsWith('--'));let manifest;if (packName) {const path = packPathByName(packName);@@ -258,7 +260,9 @@ async function runShow(args: string[]): Promise<void> {manifest = loadPackFromFile(path);} else {const cfg = loadConfig();- const pack = await loadActivePack({ cfg, remote: false, dbConfig: await readDbSchemaPackConfig(cfg) });+ const pack = source && cfg+ ? await withConnectedEngine((engine) => loadActivePackForEngine(engine, { remote: false, sourceId: source }))+ : await loadActivePack({ cfg, remote: false, dbConfig: await readDbSchemaPackConfig(cfg), sourceId: source });manifest = pack.manifest;}if (asFilingRules) {diff --git a/test/schema-cli-db-config.test.ts b/test/schema-cli-db-config.test.tsindex f19e213efc..376eb04958 100644--- a/test/schema-cli-db-config.test.ts+++ b/test/schema-cli-db-config.test.ts@@ -43,6 +43,8 @@ beforeAll(async () => {await engine.initSchema();// Tier 4 only: no env var, no config.json schema_pack.await engine.setConfig('schema_pack', 'gbrain-base-v2');+ // Tier 3 for one source (#8899): a different pack than the brain-wide one.+ await engine.setConfig('schema_pack.source.source-a', 'gbrain-base');} finally {await engine.disconnect();}@@ -71,6 +73,17 @@ describe('#4653 schema inspection verbs honor DB-config schema_pack (tier 4)', (expect(JSON.parse(r.stdout ?? '').pack).toBe('gbrain-base-v2');}, 90_000);+ test('schema show --source <id> reads that source\'s pack; a named pack still wins (#8899)', () => {+ const scoped = runSchema('show', '--source', 'source-a', '--json');+ expect(scoped.stderr ?? '').not.toContain('Unknown pack');+ expect(scoped.status).toBe(0);+ expect(JSON.parse(scoped.stdout ?? '').name).toBe('gbrain-base');+ const named = runSchema('show', 'gbrain-base-v2', '--source', 'source-a', '--json');+ expect(named.status).toBe(0);+ expect(JSON.parse(named.stdout ?? '').name).toBe('gbrain-base-v2');+ expect(JSON.parse(runSchema('show', '--json').stdout ?? '').name).toBe('gbrain-base-v2');+ }, 120_000);+test('schema graph --json and schema lint --json report the DB-configured pack', () => {const graph = runSchema('graph', '--json');expect(graph.status).toBe(0);