Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix: doctor keeps an earlier warning's code and fix, with the launcher fix in details (#8424)

garrytan8a7f20972aa6
diff --git a/docs/guides/repair.md b/docs/guides/repair.md
index 4fd4df68d1..a2564378fd 100644
--- a/docs/guides/repair.md
+++ b/docs/guides/repair.md
@@ -4369,7 +4369,7 @@ install is refreshed from its project directory. A setup hook you edited after
setup wrote it (`edited: true`) is never rewritten, so the fix is a
`user_message`: remove or rewrite that entry, then run setup. When the check
already carried another warning with its own fix, that code and fix stay, and
-the launcher fix is in `details.hook_launcher_fix`. Check with
+the launcher fix is in `details.hook_launcher_fix`; run it after the first fix. Check with
`gbrain doctor --only harness_wiring`.
## Connection notices
diff --git a/src/commands/doctor/checks/harness-wiring.ts b/src/commands/doctor/checks/harness-wiring.ts
index 7966216762..4c75feb9bd 100644
--- a/src/commands/doctor/checks/harness-wiring.ts
+++ b/src/commands/doctor/checks/harness-wiring.ts
@@ -530,15 +530,15 @@ export function hookLauncherFix(p: HookLauncherProblem): Action {
/**
* A hook that lets the session directory's bunfig.toml or .env load turns an ok
- * check into a warn (code hook_session_cwd). A warn keeps its own code and fix
- * unless the launcher fix is one the agent can run.
+ * check into a warn (code hook_session_cwd). A warn or fail keeps its own code
+ * and fix, with the launcher fix in details.hook_launcher_fix.
*/
export function withHookLaunchers(check: Check, problem: HookLauncherProblem | null): Check {
if (!problem) return check;
const message = `${check.message} Hook launcher: ${problem.detail}.`;
const details = { ...(check.details ?? {}), hook_launcher: problem };
const fix = hookLauncherFix(problem);
- if (check.status === 'fail' || (check.status === 'warn' && check.fix && fix.actor !== 'agent')) return { ...check, message, details: { ...details, hook_launcher_fix: fix } };
+ if (check.status === 'fail' || (check.status === 'warn' && check.fix)) return { ...check, message, details: { ...details, hook_launcher_fix: fix } };
return { name: NAME, status: 'warn', message, details: { ...details, code: 'hook_session_cwd', hook_launcher_reason: problem.reason }, fix };
}
diff --git a/test/hook-launcher-bunfig.test.ts b/test/hook-launcher-bunfig.test.ts
index 848a00af42..e15709118d 100644
--- a/test/hook-launcher-bunfig.test.ts
+++ b/test/hook-launcher-bunfig.test.ts
@@ -294,7 +294,7 @@ describe('doctor: the hook_session_cwd fix and how it joins the harness_wiring c
});
});
- test('withHookLaunchers: ok becomes a warn; a fail stays a fail; a warn keeps its own fix unless the agent can run the launcher fix', async () => {
+ test('withHookLaunchers: ok becomes a warn; a fail or a warn keeps its own code and fix, with the launcher fix in details', async () => {
const b = box();
await withEnv({ HOME: b.home, GBRAIN_HOME: b.home, CLAUDE_CONFIG_DIR: undefined }, async () => {
const ok = { name: 'harness_wiring', status: 'ok', message: 'Registered.' } as any;
@@ -307,7 +307,7 @@ describe('doctor: the hook_session_cwd fix and how it joins the harness_wiring c
const kept = withHookLaunchers(prior, problem(b, { reason: 'foreign' }));
expect(kept).toMatchObject({ status: 'warn', details: { code: 'turn_hook_not_loaded', hook_launcher_fix: { actor: 'user' } }, fix: prior.fix });
expect(kept.message).toContain('Hook launcher: old hook.');
- expect(withHookLaunchers(prior, problem(b))).toMatchObject({ details: { code: 'hook_session_cwd' }, fix: { actor: 'agent', argv: ['gbrain', 'setup', 'claude-code'] } });
+ expect(withHookLaunchers(prior, problem(b))).toMatchObject({ details: { code: 'turn_hook_not_loaded', hook_launcher_fix: { actor: 'agent', argv: ['gbrain', 'setup', 'claude-code'] } }, fix: prior.fix });
});
});
});