You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Node 20 GitHub Action that reviews pull requests with Z.ai GLM models —
producing structured findings posted as inline review comments + a
walkthrough summary, backed by deterministic scanners. Optionally
answers interactive /zai commands. The runtime entry is the ncc bundle
dist/index.js; the maintained source is under src/.
Design goals: auditable core (~10k LOC), tiny dependency surface
(@actions/core, @actions/github, picomatch), one Z.ai HTTP client,
deterministic-before-generative review, and security enforced in code.
One Z.ai client.src/lib/api.js is the only transport. All callers
receive an injected callApi. Temperature/max_tokens flow through the
adapter → client → request body.
Deterministic before generative. Scanners run before the LLM. Their
findings carry confidence:'high' and rule:'<scanner>:<id>' provenance.
The LLM receives scanner context ("already detected, don't re-report").
Authorization precedes dispatch.authorize() runs before any handler.
A blocked user triggers no callApi, no comment.
Idempotent review.upsertReview dismisses prior bot reviews (referencing
the new SHA) before posting. Re-runs don't pile up duplicates. The marker
<!-- zai-code-review --> + hash block <!-- zai-hashes:... --> coexist.
Never lose a review. If createReview fails (422, API error), the
fallback posts the findings as a sanitized issue comment.
Output safety. Every comment body passes through sanitizeModelOutput.
@mentions are neutralized outside code; GitHub alert banners are defanged.
Repo config narrows only..zai.yml can lower maxFindings, add
excludes, disable scanners — never raise caps, enable scanners the action
disabled, or change auth. Action inputs always win on security/cost knobs.
Dependency injection everywhere. Every module takes collaborators as
parameters. Binary execution (deps.runBinary), fetch (deps.ensureBinary),
and all I/O are injected — fully testable without network or real binaries.
Handlers never throw. A callApi failure becomes a short error comment.
Build & test
Source is ESM. npm run build produces the committed dist/index.js via
@vercel/ncc; runtime is node24.
CI runs vitest on Node 22/24, gates on dist/ drift, and runs
npm audit --audit-level=high.