Files
gbrain/test/cli-args.test.ts
T
Garry Tanandhnshah 08ba386d02 fix(query): honor source_id with no-expand for cross-source search
Two related corrections:

1. `gbrain query --no-expand` parsed `--no-expand` as the literal key
   `no_expand` instead of negating the boolean `expand` param. Result:
   the flag was silently ignored and expansion always ran. Now any
   `--no-<key>` where `<key>` is a boolean param flips it false.

2. The `query` op's source-id resolution treated `ctx.sourceId` as
   authoritative, so an explicit per-call `source_id` was overridden by
   the federated read scope. Now per-call `source_id` wins;
   `source_id=__all__` is an explicit opt-out for local cross-source
   search.

Cherry-picked from PR #1124.

Co-Authored-By: hnshah <hnshah@users.noreply.github.com>
2026-05-18 13:38:06 -07:00

25 lines
665 B
TypeScript

import { describe, expect, test } from 'bun:test';
import { parseOpArgs } from '../src/cli.ts';
import { operationsByName } from '../src/core/operations.ts';
describe('parseOpArgs', () => {
test('--no-<boolean> maps to false without consuming the next flag', () => {
const params = parseOpArgs(operationsByName.query, [
'freshEmbedSourceScope code source',
'--limit',
'8',
'--no-expand',
'--source-id',
'gstack-code-repo-0e4763c9',
]);
expect(params).toEqual({
query: 'freshEmbedSourceScope code source',
limit: 8,
expand: false,
source_id: 'gstack-code-repo-0e4763c9',
});
});
});