Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

tests: #7962-1 codex moved-target opt-out, #7962-2 project-scope rule

garrytancd9820118d4b
diff --git a/test/turn-hook-install-paths.test.ts b/test/turn-hook-install-paths.test.ts
index cd8c93ea90..6ae4c93a8b 100644
--- a/test/turn-hook-install-paths.test.ts
+++ b/test/turn-hook-install-paths.test.ts
@@ -18,6 +18,7 @@ import { withEnv } from './helpers/with-env.ts';
import { installerTurnHook, verifyTurnHook } from '../src/core/setup/turn-hook-check.ts';
import { TURN_RULE_LANE_TOKEN, TURN_RULE_MARKER } from '../src/core/setup/turn-hook.ts';
import { syncHermesTurnHook } from '../src/core/setup/hermes-turn-hook.ts';
+import { BRAIN_FIRST_BEGIN, brainFirstTurnRule } from '../src/core/setup/brain-first.ts';
import { openclawTurnPluginDir, openclawTurnPluginFiles } from '../src/core/setup/openclaw-turn-plugin.ts';
const CLI = resolve(import.meta.dir, '..', 'src', 'cli.ts');
@@ -116,6 +117,33 @@ describe('setup --instructions-only after a plain mcp add', () => {
});
});
+describe('the rule follows the recorded decision (#7962)', () => {
+ test('codex: --no-instructions after an AGENTS.override.md appears also strips the AGENTS.md block, so the rule stops', async () => {
+ const b = box();
+ const agents = join(b.home, '.codex', 'AGENTS.md');
+ mkdirSync(join(b.home, '.codex'), { recursive: true });
+ writeFileSync(agents, '# Codex house rules\n');
+ expect((await setup(b, ['codex', '--instructions-only', '--gbrain-bin', b.bin, '--json'])).exitCode).toBe(0);
+ expect(readFileSync(agents, 'utf8')).toContain(BRAIN_FIRST_BEGIN);
+ writeFileSync(join(b.home, '.codex', 'AGENTS.override.md'), '# my override\n');
+ expect((await setup(b, ['codex', '--instructions-only', '--no-instructions', '--json'])).exitCode).toBe(0);
+ expect(readFileSync(agents, 'utf8')).toBe('# Codex house rules\n');
+ await withEnv(b.env, async () => { expect(brainFirstTurnRule('codex', b.project)).toBeNull(); });
+ });
+
+ test('claude-code: a project-scope install rules only inside its project once the user scope declines', async () => {
+ const b = box();
+ expect((await setup(b, ['claude-code', '--instructions-only', '--scope', 'project', '--gbrain-bin', b.bin, '--json'])).exitCode).toBe(0);
+ expect((await setup(b, ['claude-code', '--instructions-only', '--no-instructions', '--json'])).exitCode).toBe(0);
+ const elsewhere = join(b.root, 'elsewhere');
+ mkdirSync(elsewhere);
+ await withEnv(b.env, async () => {
+ expect(brainFirstTurnRule('claude-code', join(b.project, 'src'))).toContain('GBrain: before answering this turn');
+ expect(brainFirstTurnRule('claude-code', elsewhere)).toBeNull();
+ });
+ });
+});
+
describe('installer lanes (connect --install, hosted harness install, bootstrap harness)', () => {
test('installerTurnHook writes the hook beside a pointed-at config, removes it on decline, and never fails a print', async () => {
const b = box();