šŸ› fix(onboard): follow a pre-push hook's dvara hand-off (#540)

Merged
AT
4d ago
+247-7

Slice: #540

niyam onboard 0.7.12 in athya_mono (athya-hq/athya_mono#3852, 2026-11-21) ended with "add the line niyam pre-push "$@" to the pre-push git hook .husky/pre-push, which is your own". That step was already done. Since W-61 (athya-hq/athya_mono#3814), .husky/pre-push runs exec node_modules/.bin/dvara run "$B" "$@", and athya-rules' body runs "$cli" pre-push "$@". prePushHook read only the hook.

What changes

  • prePushHook (src/onboard.ts) has a new state, body. When the hook doesn't itself run niyam, it follows one uncommented [exec] [<dir>/]dvara run <file> "$@" line and applies the same line test ours uses to that file.
    • The file is a literal path, or one variable set exactly once, plainly, before the hand-off. Every line that sets the variable counts: export B=, B+=, x && B=, B="$(…)", B=x # note.
    • The file must be inside the repository (read lexically, so pnpm's links work) and exist.
  • Any miss stays own, so the By hand step shows as before. A comment saying the line is elsewhere counts for nothing.
  • onboard treats body as ours.
  • Cloud session-start says the hand-off "was not checked for a cloud session", because athya-rules' body skips niyam when CLAUDE_CODE_REMOTE=true.
  • README's pre-push paragraph and docs/decisions.md describe the change. Alok approved #540 with a šŸ‘ on its proposal (18:12:41Z), after the slice's last edit.

Checked

  • Real files: prePushHook on athya_mono's own .husky/pre-push reads body with athya-rules 0.5.7 (installed) and with 0.5.10 (pinned).
    athya-rules 0.5.7 (installed): {"path":".husky/pre-push",…,"state":"body","body":"node_modules/@athya-hq/rules/dvara/hooks/pre-push"}
    athya-rules 0.5.10 (pinned):   {"path":".husky/pre-push",…,"state":"body","body":"node_modules/@athya-hq/rules/dvara/hooks/pre-push"}
    
  • dvara 0.6.18's run (dist/supervisor.js) is spawn("bash", [hook, ...args]) with stdin inherited, so the body is what the push runs.
  • New tests:
    • athya's hook and body read body, and onboard lists no pre-push step in the terminal or the PR.
    • These forms are followed: a literal path, ${B}, a quoted absolute path, and a path through ./...
    • 17 misses stay own: body missing, body without the line, commented hand-off, variable unset, variable set twice, set from another variable, set again by a comment, export, a command, a condition or +=, set after the hand-off, set only with a trailing comment, path outside the repository, no "$@", two hand-offs, marker comment alone.
    • Cloud session-start prints its line for body.
  • pnpm check exit 0 (rebased on main 35b77ea):
    pnpm test:         tests 2129, pass 2129, fail 0
    pnpm test:scripts: tests 133,  pass 133,  fail 0
      onboard.ts       | line 99.58 | branch 96.93 | funcs 98.72
      session-start.ts | line 100.00 | branch 99.02 | funcs 100.00
    

After merge: a niyam release. athya_mono's next onboard then lists no pre-push step.

Guards: none; no guard file changes.

šŸ¤– Generated with Claude Code


Summary by cubic

Fixes niyam onboard so a pre-push hook that hands off to a body file via dvara no longer gets a needless "By hand" step.

  • prePushHook now follows one uncommented dvara run <file> "$@" line to the body and reports it as body when the body runs niyam pre-push; any miss keeps the hook own.
  • The hand-off line, and the variable's assignment if it names one, must sit outside any if, case, loop, or { } block, and the body must be readable; anything else keeps the hook own.
  • onboard treats body like ours, listing no pre-push step; cloud session-start reads body as unchecked, since a body may skip niyam there.
  • Requires a niyam release after merge, so the next onboard in athya_mono lists no pre-push step.