Files
gstack/test/regression-3799-sync-gbrain-artifacts-source.test.ts
T
46c9f612c0 fix(sync-gbrain): point curated-memory search at gstack-artifacts-<user> (#3810)
* fix(sync-gbrain): name the curated-memory source gstack-artifacts-<user> (#3799)

The GBrain Search Guidance block /sync-gbrain writes into CLAUDE.md told
agents to search --source gstack-brain-<user>, but since the v1.27.0.0
rename bin/gstack-artifacts-init registers gstack-artifacts-<user>, so every
agent following the block got unknown_source. The template, the generated
skill, this repo's CLAUDE.md copy and the write-surfaces checklist now name
gstack-artifacts-<user>, and a regression test pins the block to the id
gstack-artifacts-init registers.

Co-authored-by: Alex Nelson <2460114+extremenelson@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* fix: pre-landing review fixes (say the source is named after the repo gstack-artifacts-init creates)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* docs(changelog): #3799 sync-gbrain artifacts source fragment

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

---------

Co-authored-by: Alex Nelson <2460114+extremenelson@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
2026-11-04 03:15:35 +00:00

44 lines
1.9 KiB
TypeScript

/**
* Regression for #3799: the GBrain Search Guidance block /sync-gbrain writes
* into CLAUDE.md named the curated-memory source `gstack-brain-<user>`, but
* the v1.27.0.0 rename made bin/gstack-artifacts-init register
* `gstack-artifacts-<user>`. Every agent following the block ran
* `gbrain search ... --source gstack-brain-<user>` and got unknown_source.
* Pins the block's source name to the one gstack-artifacts-init registers, in
* the template, the generated skill and this repo's own CLAUDE.md copy.
*/
import { describe, test, expect } from 'bun:test';
import * as fs from 'fs';
import * as path from 'path';
const ROOT = path.resolve(import.meta.dir, '..');
const read = (rel: string) => fs.readFileSync(path.join(ROOT, rel), 'utf-8');
const START = '<!-- gstack-gbrain-search-guidance:start -->';
const END = '<!-- gstack-gbrain-search-guidance:end -->';
function guidanceBlock(rel: string): string {
const text = read(rel);
const start = text.indexOf(START);
const end = text.indexOf(END, start);
if (start < 0 || end < 0) throw new Error(`${rel}: GBrain Search Guidance markers not found`);
return text.slice(start, end + END.length);
}
const registered = read('bin/gstack-artifacts-init').match(/^SOURCE_ID="([a-z0-9-]+-)\$\{USER:-\$\(whoami\)\}"$/m)?.[1];
describe('#3799 /sync-gbrain guidance names the source gstack-artifacts-init registers', () => {
test('gstack-artifacts-init registers a per-user source id', () => {
expect(registered).toBe('gstack-artifacts-');
});
for (const rel of ['sync-gbrain/SKILL.md.tmpl', 'sync-gbrain/SKILL.md', 'CLAUDE.md']) {
test(`${rel}: curated-memory search uses ${registered}<user>`, () => {
const block = guidanceBlock(rel);
expect(block).toContain(`--source ${registered}<user>`);
expect(block).not.toContain('gstack-brain-<user>');
for (const m of block.matchAll(/--source ([a-z-]+)<user>/g)) expect(m[1]).toBe(registered!);
});
}
});