š fix(doctor): take a hook that sets its gh to as-agent and runs "$@" as routed (#537)
niyam doctor no longer warns about a hook that builds its gh in the positional parameters and runs it as "$@". Such a hook runs set -- gh, then, where niyam's launcher is, set -- "$agent" as-agent --session "$session" -- gh. Its plain set -- gh is the cloud's fallback, which the proxy authenticates, so it is not counted. Every other gh is still named, and so is set -- gh with no as-agent form beside it.
Why. On 2026-11-21, doctor 0.7.12 in athya_mono warned that .claude/hooks/sarathi-install.sh "reaches GitHub outside as-agent, so gets 401". The script does route its gh through as-agent on the Mac:
hooksHittingLockdrops each command namingas-agent, and that dropped the reassignment.- It kept
set -- gh, whichGHmatches. "$@" apinames no gh.
This is a fix under P-43 (#116), as #211 was for the same check, so the slice's approval carries it (P-40).
Shape:
withoutRoutedSetGhinsrc/as-agent.tsdropsset -- ghcommands only when the same judged text hasset -- ⦠as-agent ⦠-- gh.- It runs after the cloud-only cut, so on a Mac an
as-agentform past a cloud-only exit excuses nothing. - Rejected: taking the whole script as routed, as
routedByHelperdoes. That would pass a plainghbeside it.
Tests:
src/as-agent.test.ts, the athya_mono shape: not named. With a plaingh apiadded: named. Also named:set -- ghalone;set -- gh; gh api xon one line; an as-agent form only past a cloud-only exit (on a Mac). Thethen ⦠else set -- ghform: not named.src/doctor.test.ts, on a Mac and in a cloud session: no Ⲡfor the routed hook, and a Ⲡonce a plaingh apiis beside it.
README ("Hooks that call GitHub") and a Record in docs/decisions.md say so.
Evidence:
- Replayed
hooksHittingLockon athya_mono's own.claude/settings.json,.claude/sarathi.jsonand the scripts they run, read from GitHub at main on 2026-11-21.- On a Mac, before:
['.claude/settings.json SessionStart hook .claude/hooks/sarathi-install.sh']. - On a Mac, after:
[]. - In a cloud session,
scripts/cloud/session-start.shis still named, as before; that is a separate, unchanged verdict.
- On a Mac, before:
pnpm check: exit 0.src/as-agent.test.tsandsrc/doctor.test.tsgave 125 pass, 0 fail.test:scriptsgave 133 pass, 0 fail, with coverage 100% lines and 97.24% branches. Typecheck, lint, pins, pariksha, hooks:check, build and smoke all passed.
After merge: a release (0.7.13). Then niyam doctor in athya_mono drops the ā². Nothing in athya_mono changes.
š¤ Generated with Claude Code
Summary by cubic
niyam doctor no longer warns about a hook that builds its gh in the positional parameters and runs it as "$@", when the hook also routes through as-agent via niyam's launcher. Such a hook runs set -- gh, then set -- "$agent" as-agent --session "$session" -- gh; its plain set -- gh is the cloud's fallback, which the proxy authenticates, so it is not counted.
- Runs
withoutRoutedSetGh, which dropsset -- ghonly when the same judged text has anas-agentform, looked for after the cloud-only cut so a form past that exit on a Mac excuses nothing. - Keeps every other
gh,set -- ghalone, and aset -- ghthat runs a command substitution likeset -- gh "$(gh api x)", whose nested gh stays named. - Rejected taking the whole script as routed, as
routedByHelperdoes; that would pass a plainghbeside it.