Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(setup): connect and bootstrap harness print a paired skills removal too (one shared predicate)

garrytan45e0f69b2a55
diff --git a/src/commands/connect.ts b/src/commands/connect.ts
index c843cae201..dedec75ec3 100644
--- a/src/commands/connect.ts
+++ b/src/commands/connect.ts
@@ -48,7 +48,7 @@ import { brainFirstTarget, describeBrainFirstOutcome, installerBrainFirst, isBra
import { describeTurnHookOutcome } from '../core/setup/turn-hook.ts';
import { installerTurnHook, TURN_HOOK_NATIVE_INSPECT, turnHookFix } from '../core/setup/turn-hook-check.ts';
import { resolveGbrainBin } from '../core/gbrain-bin.ts';
-import { describeSkillsBlockOutcome, indexLauncher, installerSkillsBlock, isSkillLoading, skillsOutcomeFailed, type SkillLoading } from '../core/setup/skills-block.ts';
+import { describeSkillsBlockOutcome, indexLauncher, installerSkillsBlock, isSkillLoading, skillsOutcomeFailed, skillsOutcomeShown, type SkillLoading } from '../core/setup/skills-block.ts';
import { setCliExitVerdict } from '../core/cli-force-exit.ts';
import {
GBRAIN_REMOTE_TOKEN_ENV,
@@ -517,7 +517,7 @@ const defaultDeps: ConnectDeps = {
const o = installerBrainFirst({ target, access: { kind: 'mcp', server: name }, writer, instructions: optOut ? false : undefined });
const skills = installerSkillsBlock({ target, launcher: gbrainBin ?? indexLauncher() ?? 'gbrain', writer, brainFirstDeclined: o.decision.value === 'declined', skillLoading, audience: 'downstream' });
const lines = [`${describeBrainFirstOutcome(o, false).trim()}${o.decision.value === 'accepted' ? ' (opt out with --no-instructions)' : ''}`];
- if (skills.decision.value === 'spring' || skills.action !== 'skip') lines.push(describeSkillsBlockOutcome(skills, false).trim());
+ if (skillsOutcomeShown(skills)) lines.push(describeSkillsBlockOutcome(skills, false).trim());
if (skillsOutcomeFailed(skills)) setCliExitVerdict(1);
return lines.join('\n');
},
diff --git a/src/commands/setup.ts b/src/commands/setup.ts
index 1c358afb8b..acbed945e0 100644
--- a/src/commands/setup.ts
+++ b/src/commands/setup.ts
@@ -81,6 +81,7 @@ import {
import type { CodexSetupEvent } from '../core/bootstrap/codex-hooks.ts';
import {
describeSkillsBlockOutcome,
+ skillsOutcomeShown,
InvalidSkillLoadingEnv,
isSkillLoading,
indexLauncher,
@@ -856,7 +857,7 @@ async function runInstructionsOnly(flags: SetupFlags, out: Out): Promise<number>
if (instructions) say(out, flags.remove ? describeBrainFirstOutcome(instructions, flags.dryRun) : describeInstructions(instructions, flags.dryRun));
if (turnHook) say(out, ` ${(flags.dryRun && (turnHook.action === 'write' || turnHook.action === 'remove') ? `would ${turnHook.action}` : turnHook.action).padEnd(8)} ${'turn hook'.padEnd(7)} ${turnHook.detail}${'snippet' in turnHook && turnHook.snippet ? `:\n${turnHook.snippet.replace(/^/gm, ' ')}` : ''}${'commands' in turnHook && turnHook.commands ? `:\n${turnHook.commands.map((c) => ` ${c}`).join('\n')}` : ''}${'next' in turnHook && turnHook.next ? `; wire it with: ${turnHook.next}` : ''}`);
else if (!off && placed) say(out, ` note ${'turn hook'.padEnd(7)} ${adapter.label} has no per-turn hook gbrain can install; the rule reaches it through ${target.path} only.`);
- if (skills && (skills.decision.value === 'spring' || skills.action !== 'skip' || skills.paired)) say(out, describeSkillsBlockOutcome(skills, flags.dryRun));
+ if (skills && skillsOutcomeShown(skills)) say(out, describeSkillsBlockOutcome(skills, flags.dryRun));
if (check?.ok) say(out, ` verify ${'turn hook'.padEnd(7)} ${check.message}`);
if (mcp.setup === 'manual' && !flags.remove) say(out, `MCP: setup does not register ${adapter.label}'s MCP server. Follow ${adapter.guide} (one command), then start a new session.`);
if (!flags.remove && instructions?.decision.value === 'accepted') say(out, 'Next: start a new session; the harness reads its instruction file at session start.');
@@ -922,7 +923,7 @@ async function finish(out: Out, doc: {
return code;
}
if (doc.instructions) say(out, doc.remove ? describeBrainFirstOutcome(doc.instructions, doc.dryRun) : describeInstructions(doc.instructions, doc.dryRun));
- if (doc.skills && (doc.skills.decision.value === 'spring' || doc.skills.action !== 'skip' || doc.skills.paired)) say(out, describeSkillsBlockOutcome(doc.skills, doc.dryRun));
+ if (doc.skills && skillsOutcomeShown(doc.skills)) say(out, describeSkillsBlockOutcome(doc.skills, doc.dryRun));
if (doc.verify) say(out, `Verify: ${doc.verify.ok ? 'ok' : 'not verified'} (${doc.verify.reason}): ${doc.verify.message}`);
if (doc.turnHook?.ok) say(out, `Turn hook: ok (${doc.turnHook.reason}): ${doc.turnHook.message}`);
if (state) say(out, `State: ${state} (${doc.states.join(' -> ')}).${state === 'native-verified' ? '' : ' Native push is not claimed until an observed event reaches a fresh session.'}`);
diff --git a/src/core/bootstrap/harness-skills-index.ts b/src/core/bootstrap/harness-skills-index.ts
index 6f6c122974..bd3c6d35db 100644
--- a/src/core/bootstrap/harness-skills-index.ts
+++ b/src/core/bootstrap/harness-skills-index.ts
@@ -8,7 +8,7 @@
* leaves one whose file still holds another connection's brain-first block.
*/
import { brainFirstTargetAt, codexInstructionFile, readBrainFirstLedger } from '../setup/brain-first.ts';
-import { describeSkillsBlockOutcome, installerSkillsBlock, removeSkillsBlocksBy, type SkillLoading, type SkillsBlockOutcome } from '../setup/skills-block.ts';
+import { describeSkillsBlockOutcome, installerSkillsBlock, removeSkillsBlocksBy, skillsOutcomeShown, type SkillLoading, type SkillsBlockOutcome } from '../setup/skills-block.ts';
import type { BrainFirstHost, HarnessInstructionPaths } from './harness-brain-first.ts';
const WRITER = 'gbrain bootstrap harness';
@@ -21,7 +21,7 @@ export function writeHarnessSkillsIndex(opts: { hosts: readonly BrainFirstHost[]
: paths.opencodeAgentsPath;
const declined = opts.optOut || readBrainFirstLedger().find((e) => e.harness === host && e.path === path)?.status === 'declined';
const o = installerSkillsBlock({ target: brainFirstTargetAt(host, path), launcher: opts.launcher, writer: WRITER, brainFirstDeclined: declined, skillLoading: opts.skillLoading, audience: 'owner', settingsPath: opts.settingsPath });
- if (o.decision.value === 'spring' || o.action !== 'skip') opts.log(describeSkillsBlockOutcome(o, false).trim());
+ if (skillsOutcomeShown(o)) opts.log(describeSkillsBlockOutcome(o, false).trim());
return o;
});
}
diff --git a/src/core/setup/skills-block.ts b/src/core/setup/skills-block.ts
index 82f60a8ded..d1b4d376de 100644
--- a/src/core/setup/skills-block.ts
+++ b/src/core/setup/skills-block.ts
@@ -660,6 +660,10 @@ function removeSkillsBlockLocked(opts: { harness: string; path: string; dryRun:
}
/** One human line per outcome, matching setup's step lines. */
+export function skillsOutcomeShown(o: SkillsBlockOutcome): boolean {
+ return o.decision.value === 'spring' || o.action !== 'skip' || o.paired !== undefined;
+}
+
export function describeSkillsBlockOutcome(o: SkillsBlockOutcome, dryRun: boolean): string {
const how = o.decision.value === 'spring' ? 'turn off with --skill-loading off' : 'turn on with --skill-loading spring';
const tag = o.decision.source === 'unresolved' ? '' : ` [${o.decision.source}; ${how}]`;
diff --git a/test/skill-loading-lanes.test.ts b/test/skill-loading-lanes.test.ts
index 012305e2df..972ea2f843 100644
--- a/test/skill-loading-lanes.test.ts
+++ b/test/skill-loading-lanes.test.ts
@@ -165,6 +165,22 @@ describe('bootstrap harness', () => {
});
});
+ test('an opt-out that strips only the Codex AGENTS.md index the override replaced still logs that removal', async () => {
+ const b = box();
+ await withEnv(b.env, async () => {
+ const paths = { claudeMemoryPath: join(b.home, '.claude', 'CLAUDE.md'), codexAgentsPath: join(b.home, '.codex', 'AGENTS.md'),
+ codexAgentsOverride: join(b.home, '.codex', 'AGENTS.override.md'), opencodeAgentsPath: join(b.home, '.config', 'opencode', 'AGENTS.md') };
+ const settingsPath = join(b.home, '.claude', 'settings.json');
+ writeHarnessSkillsIndex({ hosts: ['codex'], launcher: LAUNCHER, optOut: false, skillLoading: 'spring', paths, settingsPath, log: () => {} });
+ writeFileSync(paths.codexAgentsOverride, '# Override rules\n');
+ const log: string[] = [];
+ const [o] = writeHarnessSkillsIndex({ hosts: ['codex'], launcher: LAUNCHER, optOut: false, skillLoading: 'off', paths, settingsPath, log: (l) => log.push(l) });
+ expect(o.action).toBe('skip');
+ expect(o.paired).toMatchObject({ path: paths.codexAgentsPath, action: 'remove' });
+ expect(log.join('\n')).toContain(`skills index from ${paths.codexAgentsPath}`);
+ });
+ });
+
test('removing one connection leaves the index in a file whose brain-first block belongs to another connection', async () => {
const b = box();
await withEnv(b.env, async () => {