@veda-hq/niyam 0.0.0-stage → 0.6.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,1288 @@
1
- # Temporary Holding Version
1
+ # niyam
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ niyam (नियम, rule) was named process-rules until 0.6.3. Its repository moved
4
+ from athya-hq/process-rules to veda-hq/niyam, and GitHub forwards the old
5
+ address. Since P-57 no release reads or writes the old names: see
6
+ [Renamed from process-rules](#renamed-from-process-rules).
7
+
8
+ Work rules for a repository that tracks its work in GitHub Issues and a GitHub
9
+ Project, with an owner account that approves and an agent account that builds.
10
+
11
+ Any repository can adopt it. No server, database or dashboard: a CLI, git
12
+ hooks and a shared GitHub Actions workflow.
13
+
14
+ ## Status
15
+
16
+ Early. The CLI runs `machine`, `doctor`, `session-start`, `guard`, `onboard`, `propose`, `upgrade` and `owner-step`. What comes next, and in what
17
+ order: the Slice issues under
18
+ [niyam roadmap v1](https://github.com/veda-hq/niyam/issues/22),
19
+ on the Project [process-rules work](https://github.com/orgs/athya-hq/projects/2) (its title from before the rename);
20
+ [docs/roadmap.md](docs/roadmap.md) keeps version v1 as approved. Decisions:
21
+ [docs/decisions.md](docs/decisions.md). Traps learned while building it:
22
+ [docs/lessons.md](docs/lessons.md).
23
+
24
+ GitHub means github.com: it is the only supported host. GitHub Enterprise
25
+ Server and GitHub Enterprise Cloud with data residency (GHE.com) are not
26
+ supported yet; every GitHub address in the CLI comes from one host constant,
27
+ so a host setting can be added later.
28
+
29
+ Claude Code is the only supported agent runner. The agent identity and the
30
+ GitHub lock reach a session through Claude Code's SessionStart hook and
31
+ `CLAUDE_ENV_FILE`, so an agent run from another tool (Codex, Cursor,
32
+ Copilot's agent, Aider, a plain script) gets neither, and only the pull
33
+ request's PR identity check catches its work, after the push. Other runners
34
+ wait for adoption outside Athya (#50).
35
+
36
+ ## Agent identity on a Mac
37
+
38
+ macOS is the supported platform: the agent's token lives in the macOS
39
+ keychain. On any other platform `machine` and `doctor` refuse, and
40
+ `session-start` keeps GitHub locked out of the session; Claude cloud sessions
41
+ need no keychain and work as before, and `doctor` runs its cloud checks there
42
+ (see Claude cloud sessions below). The token is read and stored through
43
+ one token-store interface (`src/token-store.ts`), so a Linux or Windows store
44
+ can be added there when an adopter needs one.
45
+
46
+ The adopting repo names its accounts in `.github/niyam.json`:
47
+
48
+ ```json
49
+ { "owner": "example-owner", "agent": "ExampleBot" }
50
+ ```
51
+
52
+ Each of `"owner"` and `"agent"` is a login or a non-empty list of logins,
53
+ such as `"owner": ["example-owner", "second-owner"]`; no account may be both.
54
+ Every check accepts anyone in a list: an approval, a 👍 or a `Decision:`
55
+ comment from any owner counts, and proposals, commits, pushes and pull
56
+ requests from any agent count as agent work. A Mac's agent sessions work as
57
+ one agent: the only one listed, or else the one listed that `machine` set up
58
+ on that Mac; with none of them set up there, or more than one, session-start
59
+ keeps GitHub locked out rather than guess. Messages that send someone to fix
60
+ a setup name the first owner. `onboard` writes the one-login form, and on a
61
+ repo whose settings list several it works as the owner named, else the
62
+ one the run's browser sign-in is, which must be listed, and the agent named,
63
+ else the one set up on the Mac; it leaves the lists as they are.
64
+
65
+ `niyam machine ExampleBot`, run once per Mac and agent account (inside
66
+ an adopting repo the name can be left out), needs no client repo. It makes the
67
+ agent's signing key (`~/.ssh/<agent, lowercased>_signing`), opens GitHub's
68
+ classic-token page with the scopes filled in (`repo`, `workflow`, `read:org`,
69
+ `project`, `write:ssh_signing_key`) and reads the token through a hidden prompt
70
+ into the keychain (service `niyam`), refusing a fine-grained token,
71
+ missing scopes or no expiry. It then registers the key as the agent's signing key, writes
72
+ `~/.config/niyam/<agent, lowercased>/session.sh`, and writes the
73
+ launcher `~/.config/niyam/bin/niyam`, which the Claude Code
74
+ hooks and the pre-push git hook run. Releases before P-55 wrote both under
75
+ `~/.config/process-rules/`, which nothing reads since P-57: `machine` removes
76
+ that folder, whole, once it has written the new one, and deletes the keychain
77
+ entry under the service `process-rules` once the `niyam` one holds the same
78
+ token (see Renamed from process-rules). The launcher names the node that ran `machine` by its real path (not a version
79
+ manager's per-shell one, which the Claude app's hooks may not have), so the
80
+ hooks need no node on their `PATH`. Why a classic token: [docs/decisions.md](docs/decisions.md).
81
+
82
+ `machine` first works out what it would change, changing nothing, and shows
83
+ one plan, in the same layout as `onboard`, listing only what changes. Then it
84
+ asks once:
85
+
86
+ ```
87
+ ◆ niyam machine AGENT
88
+ │
89
+ ◇ This Mac
90
+ │ signing key ~/.ssh/agent_signing (new)
91
+ │ token classic, in the keychain (new)
92
+ │ session file new
93
+ │ launcher ~/.config/niyam/bin/niyam
94
+ │
95
+ ◇ GitHub — as AGENT
96
+ │ signing key register
97
+ │
98
+ ◆ Go ahead? ● Yes ○ No
99
+ ```
100
+
101
+ No changes nothing. `--yes` goes ahead without asking, and `--dry-run` shows
102
+ the plan and stops. When nothing would change, it asks nothing and says
103
+ `◇ This Mac is set up for AGENT`, with or without a terminal. Otherwise,
104
+ with no terminal it refuses in one line unless given `--yes` or `--dry-run`.
105
+ A stored token GitHub refuses, or one that ends within 14 days, shows in the
106
+ plan as replaced. After the yes, each step shows as one `◇` line, or `■`
107
+ with why when it fails. The token's step opens GitHub's page, says in a few
108
+ short lines what to do there, and asks for the paste, hidden. A failed key,
109
+ token or key registration stops the run there, and nothing after it changes.
110
+ A failed lockout step stops nothing and goes under "Worth fixing". A run
111
+ that finishes ends with that group of `▲` lines, each with its one-line fix,
112
+ and `└ AGENT is ready on this Mac`. The SessionStart hook sources the
113
+ session file, so nothing is left to do by hand.
114
+
115
+ The trade-off, for adopters: the agent account holds one classic token, and
116
+ its `repo` scope reaches every repository the agent account can access, not
117
+ only the adopting one. Invite a dedicated agent account to the repositories
118
+ it works in and nothing else; the expiry bounds the rest. It is classic for
119
+ now because a fine-grained token waits on an organisation owner's approval
120
+ wherever the organisation requires it, reaches no repository where the agent
121
+ is only an outside collaborator, takes one token per organisation, and
122
+ cannot register the agent's signing key when an organisation owns it. An organisation or
123
+ enterprise that blocks classic tokens cannot adopt niyam yet:
124
+ `onboard` names the block and that an organisation owner can allow classic
125
+ tokens under Settings → Personal access tokens. A fine-grained token or a
126
+ GitHub App waits for adoption outside Athya.
127
+
128
+ A client's `.claude/settings.json` locks GitHub out of every session before
129
+ any hook runs: its `env` holds the lock's variables (a `GH_TOKEN` GitHub
130
+ refuses, no credential helper, GitHub's SSH remotes on HTTPS and every other
131
+ SSH remote refused), so a session whose hook never ran or failed reaches
132
+ GitHub as nobody, never as the owner. In a Claude cloud session the
133
+ SessionStart hook lifts it only once GitHub says the session is the agent
134
+ (see Claude cloud sessions below).
135
+
136
+ In Claude Code, the client's SessionStart hook runs `niyam
137
+ session-start`. It appends a lock to `CLAUDE_ENV_FILE`: a token GitHub refuses,
138
+ no credential helper, nothing inherited that could bring one back (`git -c`
139
+ injection, `GIT_CONFIG`, askpass), GitHub's SSH remotes on HTTPS and every
140
+ other SSH remote refused. Then, when this Mac has the session file `machine`
141
+ wrote for the agent the repo's settings name, exactly as `machine` writes it,
142
+ it appends that file, which replaces the lock with the agent's identity. Any
143
+ other outcome leaves GitHub locked out and says why, so a session never falls
144
+ back to the owner's login. When the CLI is missing or fails, the hook still
145
+ tells the session to stop, with what the CLI printed.
146
+
147
+ The line that tells a local session it works as the agent also tells it to
148
+ turn Auto-fix on for each pull request it opens. The Claude desktop app's
149
+ Auto-fix wakes a session on CI failures, merge conflicts and review comments,
150
+ and the app turns it on for a new pull request by itself only while that
151
+ session is open on screen, so a session started in the background (as a
152
+ coordinator starts its slice sessions) opens its pull request with Auto-fix
153
+ off. So after `gh pr create`, when the app's `ccd_pr` tools are there and
154
+ `get_status` shows `auto_fix` off, the session turns it on with
155
+ `set_monitor`. The app checks that the session opened the pull request and
156
+ that its `gh` login wrote it, which holds for the agent's own pull requests.
157
+ In auto mode the classifier refuses those calls unless the repo's
158
+ `.claude/settings.json` allows them, so `onboard` adds `mcp__ccd_pr__bind_pr`,
159
+ `mcp__ccd_pr__get_status` and `mcp__ccd_pr__set_monitor` to its
160
+ `permissions.allow`, and `doctor` warns under "This repo" (`▲`) about each
161
+ one an onboarded repo's file lacks. They reach the app only, not GitHub.
162
+
163
+ Before each Bash command, the client's PreToolUse hook runs `niyam
164
+ guard`: a command running `gh` or a git command that reaches a remote (push,
165
+ fetch, pull, clone, ls-remote, submodule, and `remote` update, prune, show (not `-n`),
166
+ `add -f`/`--fetch` (unless a later `--no-fetch`) and `set-head -a`/`--auto`;
167
+ not `remote get-url` and the other local `remote` subcommands) is refused,
168
+ with the reason,
169
+ unless session-start gave this session the agent identity. Hooks cannot see
170
+ the variables session-start gives the session's shells, so session-start
171
+ records how it left each session in
172
+ `~/.config/niyam/sessions/<session id>.json` and the guard reads that.
173
+ A command not naming `gh` or `git` as a word goes ahead without starting the CLI;
174
+ when the CLI cannot run, every command naming either is refused.
175
+
176
+ The guard also reads each comment an agent session posts or edits through
177
+ `gh`: `gh issue comment`, `gh pr comment`, and `gh api` on a comments
178
+ endpoint or in a GraphQL comment mutation, its body inline, in a heredoc, in
179
+ `$(cat file)`, or from `--body-file`, `-F body=@file` or `--input`. A
180
+ comment that asks the owner (it opens with `Needs you:` or `Proposal:`, past
181
+ any Markdown emphasis, or names an owner login, with or without `@`) must
182
+ link a published page (`https://claude.ai/artifact/…` or
183
+ `https://claude.ai/code/artifact/…`) and fit 500 characters; otherwise it is
184
+ refused, naming the rule and the fix: publish the page, then post the
185
+ question, the link and how to answer. A body the guard cannot read in full
186
+ (a variable, a command substitution other than `cat`) is judged by what it
187
+ spells out; where that asks the owner, or the body opens with the unknown
188
+ part, it is refused with how to write it so the guard can read it; so is a comment with no body in the command, which gh would take from an editor, a prompt or the browser. Commands inside `$(…)`, backquotes and `sh -c` are read too. `propose`
189
+ posts through GitHub's API, not through `gh`, so this check does not see
190
+ it; `propose` holds its own comments to the same rule before posting them.
191
+
192
+ The session file holds no secret: `GH_TOKEN` is read from the keychain on each
193
+ use, and is a value GitHub refuses when the keychain has none. Git gets a
194
+ credential helper that drops every earlier one and hands the agent's token to
195
+ github.com only, commits as the agent's no-reply address and signs with its
196
+ key.
197
+
198
+ The lock lives in the session's environment, which a session that ignores it
199
+ could change. So `machine` also locks the owner away, as optional hardening
200
+ for a machine that runs agents. Its plan lists signing `gh` out of every
201
+ account other than the agent's, active or not, and removing a git password
202
+ for github.com saved in the macOS keychain. The one yes covers them, and a no
203
+ leaves them in place with everything else. On a laptop you also use for your
204
+ own work, saying yes signs you out of your own GitHub tooling. The stronger
205
+ alternative is a separate macOS user that runs only the agent sessions: none
206
+ of your logins, keychain or SSH keys are in it, and nothing of yours is signed
207
+ out. A sign-out that fails stops nothing; it goes under "Worth fixing". So
208
+ does each SSH key in `~/.ssh` with no passphrase, with
209
+ `ssh-keygen -p -f <key>` to add one; agents' signing keys are left out,
210
+ since sessions sign with them and they have no passphrase on purpose. The owner's SSH access is left alone,
211
+ since it is the owner's own way to GitHub (docs/decisions.md). Agent sessions
212
+ send GitHub over HTTPS and refuse SSH, and the pre-push hook refuses their
213
+ pushes over SSH. `doctor` names the account SSH reaches GitHub as without
214
+ asking (a key in the SSH agent or the keychain), as fine.
215
+
216
+ Releases before 0.5.21 asked about each lockout step on its own, and recorded
217
+ what was declined in
218
+ `~/.config/niyam/<agent, lowercased>/lockout-declined.json` (under
219
+ `~/.config/process-rules/` before P-55, which nothing reads since P-57).
220
+ `doctor` reports a login or password in that record as your choice instead of
221
+ warning, and an account signed in later is still a warning. Once a `machine`
222
+ run locks them away, the record goes.
223
+
224
+ When `machine` signs an account out of `gh`, "Worth fixing" ends with two
225
+ steps only you can take. Restart the Claude desktop app: it keeps the `gh`
226
+ token it read before the move until it restarts, so until then its own
227
+ GitHub actions (Auto-fix, the PR bar) run as you, and Auto-fix refuses the
228
+ agent's pull requests. And revoke the old token on GitHub (Settings →
229
+ Applications → Authorized OAuth Apps → GitHub CLI): `gh auth logout` deletes
230
+ it from the Mac but does not revoke it. `machine` records the move in
231
+ `~/.config/niyam/<agent, lowercased>/gh-moved.json`, and `doctor`
232
+ repeats both steps while the desktop app was started before it. `doctor`
233
+ cannot see whether the token was revoked, so once the app has restarted it
234
+ no longer reminds you to revoke it.
235
+
236
+ The owner is never signed in to `gh`, and needs no sign-in kept anywhere on
237
+ the Mac. When a run of `onboard` (or `onboard --add`) reaches a step that
238
+ acts as the owner (giving the agent access, setting up the board, or
239
+ setting the `FIGMA_LIBRARY` secret from an older setting), it
240
+ asks for one browser approval, which serves the rest of that run; a run
241
+ with no such step asks for none. That approval comes after the plan's yes,
242
+ unless only it can tell what the plan is: which of several owners the
243
+ settings list ran it, or, on a first run with no owner named, whom to
244
+ suggest; the pull request then says so. It runs `gh auth login --web` into a
245
+ fresh temporary `gh` folder, asking for gh's own scopes (`repo`,
246
+ `read:org`, `gist`) plus only those the run's features add (`project` for
247
+ the board, and `admin:org` in an organisation), reads the token from
248
+ there, refuses it unless it is the owner's, and deletes the folder
249
+ whatever happens. Its line names the account to sign in as (each owner the
250
+ settings list, while the run has not chosen one). `onboard` reads `gh`'s
251
+ output rather than showing it: it shows the one-time code and opens the
252
+ link in the browser, drops `gh`'s tips and its notes about setting up that
253
+ temporary folder, and shows any other line, an error included, as `gh`
254
+ wrote it. The
255
+ token lives in the command's memory for that run; the owner's own `gh`
256
+ config and keychain are never read or written, so there is nothing to sign
257
+ out of afterwards.
258
+
259
+ A request to GitHub or Figma that gets no answer at all stops the command
260
+ with which request it was and why, such as `GET
261
+ api.github.com/repos/…/actions/secrets/public-key could not be made:
262
+ ECONNRESET (other side closed)`, never its query or token. A GET, PUT or
263
+ DELETE, which can be repeated safely, is tried once more a second later
264
+ first; a POST or PATCH never is. A call with a time limit keeps it for
265
+ both tries, and one that runs out of time stops with that, not tried
266
+ again.
267
+
268
+ `niyam doctor` only reads. It re-checks the key, the token and its
269
+ scopes, the key's registration, the session file, that the launcher runs,
270
+ that the CLI is the newest release (`▲` when a newer one is out, fixed by
271
+ `niyam upgrade`) and the only `niyam` on `PATH` (`✗`
272
+ otherwise, naming each copy and its version), anything left from before
273
+ niyam (`~/.config/process-rules/`, or a keychain entry under the service
274
+ `process-rules`: `▲`, which `niyam machine` removes), and
275
+ what of the owner's an agent session could reach, any `owner-step` folder
276
+ left behind (`▲`, saying whether it still holds a token; see Owner steps), and, in a repository with
277
+ the board on, the organisation's issue types (see Issue types). It shows them grouped as
278
+ This Mac, GitHub and This repo, one line each: `✓` fine, `▲` worth fixing,
279
+ `✗` broken. Each problem line ends with its fix:
280
+
281
+ ```
282
+ ◆ niyam doctor AGENT
283
+ │
284
+ ◇ This Mac
285
+ ✓ signing key ~/.ssh/agent_signing
286
+ ✓ session file
287
+ ✗ launcher missing, so hooks need node on PATH → niyam machine
288
+ ▲ niyam 0.5.20 runs here; 0.5.30 is out → niyam upgrade
289
+ │
290
+ ◇ GitHub — as AGENT
291
+ ▲ token ends in 11 days → niyam machine
292
+ ✓ signing key registered
293
+ │
294
+ └ 3 to fix
295
+ ```
296
+
297
+ It closes with `└ All good` or `└ N to fix`, and exits 1 when anything is
298
+ `✗`. A token that ends within 14 days is `▲`, and still exits 0. It needs no
299
+ terminal. In a Claude cloud session it runs the cloud checks instead (see
300
+ Claude cloud sessions below).
301
+
302
+ ## Adopting
303
+
304
+ 1. On each Mac that runs agent sessions: `niyam machine <agent>`.
305
+ Only you can run it: it asks for the agent's token and makes its signing
306
+ key. `onboard` refuses on a Mac it has not set up, naming what is missing.
307
+ 2. In the client repository, as its owner: `niyam onboard`. It
308
+ suggests the owner from the run's browser sign-in (below) and the agent from the accounts
309
+ `machine` set up on this Mac, for you to confirm (or name them:
310
+ `niyam onboard <owner> <agent>`). It first works out everything
311
+ it would change, changing nothing, and prints that as one plan, then asks
312
+ once:
313
+
314
+ ```
315
+ ◆ niyam onboard v0.5.17 → v0.5.20
316
+ │ owner/repo · owner OWNER · agent AGENT
317
+ │
318
+ ◇ Pull request
319
+ │ workflow pins → v0.5.20
320
+ │ cloud-setup.sh new, installs v0.5.20
321
+ │ auto-merge when checks pass
322
+ │
323
+ ◇ GitHub — one sign-in as OWNER
324
+ │ board set up or check
325
+ │ issue types org-wide: retype 1, disable 3
326
+ │ example-app#12 Task → Brief
327
+ │ disable Task, Bug, Feature
328
+ │
329
+ ◇ This Mac
330
+ │ pre-push hook new
331
+ │
332
+ ◇ Claude cloud — by hand, once
333
+ │ Setup script niyam cloud-setup, first
334
+ │ claude.ai's GitHub as AGENT
335
+ │
336
+ ◇ Check
337
+ │ one signed test commit by AGENT, deleted after
338
+ │
339
+ ◆ Go ahead? ● Yes ○ No
340
+ ```
341
+
342
+ It shows only what changes, in a few words each; the pull request's
343
+ description holds each change in full. No changes nothing and opens no
344
+ pull request. `--yes` goes ahead without asking, and `--dry-run` prints
345
+ the plan and stops, changing nothing and signing in to nothing, so where
346
+ only a sign-in could tell which of the settings' owners runs it, a dry
347
+ run asks you to name the owner. Without a terminal, `onboard` refuses
348
+ unless given `--yes` or `--dry-run`. After the yes it shows one line per step, a
349
+ spinner while it works, and ends with the pull request and a short "By
350
+ hand:" list of what GitHub's API cannot do.
351
+
352
+ It writes `.github/niyam.json`, adds to `.claude/settings.json`
353
+ the lock in `env`, a SessionStart hook running `niyam session-start`, a
354
+ PreToolUse hook running `niyam guard` (each through the launcher `machine`
355
+ writes, else `niyam` on PATH; hooks an older release wrote are replaced
356
+ in place, 0.6.10's too), and `permissions.allow` rules
357
+ for `niyam review-thread` (replacing the rule under the old command) and for
358
+ the app's `mcp__ccd_pr__bind_pr`, `mcp__ccd_pr__get_status` and
359
+ `mcp__ccd_pr__set_monitor`, which turn Auto-fix on (a rerun adds only
360
+ the ones missing), and
361
+ writes `.github/workflows/niyam.yml`, which calls this repository's
362
+ shared checks (`.github/workflows/checks.yml`) from two jobs: `niyam`
363
+ on pull requests and pushes, read-only, and `niyam-weekly` on the
364
+ weekly run, the only one that writes to issues. Each job carries a
365
+ `name:` (`niyam`, `niyam-weekly`, …), so its checks read
366
+ `niyam / Work rules`. With identity alone `onboard` writes no workflow. It writes
367
+ `.github/niyam/cloud-setup.sh`, which installs the CLI in Claude
368
+ cloud sessions at the version the workflow pins, and writes it again on
369
+ every run (see Claude cloud sessions below); the first time, the plan
370
+ lists the one paste into the cloud environment's Setup script. Where the
371
+ repo still has `.github/process-rules/cloud-setup.sh`, which releases up
372
+ to 0.6.10 wrote beside it, the pull request deletes it, but only where it
373
+ leaves `.github/niyam/cloud-setup.sh` (one the run could not write, as
374
+ when GitHub names no sha256 for the release, keeps the old file too), and
375
+ the description says to paste the new snippet once if the Setup script
376
+ was pasted before 0.6.10. It checks the agent can
377
+ push. With no access, or read access only (a public repo, or an
378
+ organisation's base permission), the plan gives it write access as you
379
+ and accepts the invitation as the agent; and `onboard` names
380
+ an organisation that
381
+ requires SAML authorisation or blocks classic tokens. As the owner (with
382
+ the `project` scope, and `admin:org` in an organisation), it sets up the
383
+ work board: the organisation's issue types
384
+ (Work item, Slice, State, Decision, Brief; see Issue types below), the repo's labels (`approved`,
385
+ `needs-owner`, `mechanical`, `veto`, `expiring`, `cannot-run-here`), and a
386
+ Project "<repo> work" linked to the repo. It makes that Project by copying
387
+ the product's public [niyam template](https://github.com/orgs/athya-hq/projects/4),
388
+ which holds the fields Step (Frame, Specify, Slice, Build, Done), Decision
389
+ and Review date and the views Needs
390
+ you (`label:needs-owner is:open`), Board (`type:Slice,Brief`, by Status,
391
+ showing linked pull requests), Work items (`type:"Work item"`, grouped by Step), Decisions
392
+ (`type:Decision`, grouped by Decision) and Reviews due (`"Review
393
+ date":<=@today`), with its workflows; so the board needs nothing done by
394
+ hand. What the board lacks is known only once you have signed in, so the
395
+ plan says "set up or check"; issue types are an organisation-wide
396
+ setting, so the plan says "org-wide" and lists what it would change. If
397
+ a copy's workflows arrive off, "By hand:" links where to turn them on. A
398
+ Project of that title made before the template is left as it is: the plan's
399
+ yes does not replace it. When GitHub refuses the copy, or for such an
400
+ older Project, `onboard` adds the fields and makes or updates the views
401
+ itself, and "By hand:" links the Project for the three things GitHub's API
402
+ cannot set: the Type column on Needs you (`+` at the right of the
403
+ headers → Type, then Save), the grouping, and the auto-archive workflow.
404
+ GitHub's API cannot even see a Type column, so `onboard` sends a view's
405
+ columns only when they differ from what it asks for: a rerun keeps Type.
406
+ When it does set Needs you's columns, it says Type may be gone and how to
407
+ add it again. On any Project it
408
+ adds an option a field lacks, such as Step's Done on one made before it,
409
+ sending each option it keeps with its id, so no item loses its value. The Board keeps a
410
+ closed slice or brief in Done until that workflow archives it, with the
411
+ filter `is:closed updated:<@today-7d`: a week. A view's filter cannot do
412
+ this, since GitHub's Project filters join different fields with AND alone
413
+ and have no closed date, and GitHub's API can neither read nor set a
414
+ workflow's filter. Last, it pushes
415
+ one signed test commit as the agent to a throwaway branch, checks GitHub
416
+ shows it Verified by the agent (asking again when the network or GitHub
417
+ fails for a moment), and deletes the branch. The steps that act as you
418
+ (giving the agent access, the board, the `FIGMA_LIBRARY` secret) share one browser approval, for
419
+ that run only. The files git tracks in your checkout are never changed: once every step has run,
420
+ `onboard` commits the files it changes as the agent, signed, on the
421
+ branch `niyam/onboard` from the default branch's tip, in a
422
+ temporary repository it deletes afterwards, pushes it as the agent and
423
+ opens the agent's pull request (or updates the one an earlier run opened),
424
+ titled `chore(niyam): onboard at v<version>`, as Conventional
425
+ Commits reads it, and its commit the same. Where most of the default
426
+ branch's latest 20 commit subjects, merge commits aside, lead with an
427
+ emoji or a gitmoji shortcode, so does the title: the one an earlier
428
+ onboard commit had, else the one the repo puts most on chores, else `🔧`
429
+ (`:wrench:` where shortcodes are the style). Where the default branch's
430
+ Mergify configuration (the first of `.mergify.yml`, `.mergify/config.yml`
431
+ and `.github/mergify.yml`) has a queue rule and queues pull requests by
432
+ itself, through a rule whose actions hold `queue` and whose conditions
433
+ ask for no label, or merge protections' `auto_merge_conditions` set to
434
+ `true` or to conditions that ask for no label, the merge queue merges the pull
435
+ request, and the run ends "<url> the merge queue merges it when checks
436
+ pass". Otherwise it turns on GitHub's
437
+ auto-merge for that pull request as the agent, squashing where the repo
438
+ allows it (else rebasing, else merging), so it merges itself once its
439
+ checks pass, and any review the repo's rules require is given. Where the
440
+ repo does not allow auto-merge, or GitHub refuses it (as it does for a
441
+ pull request already clean to merge), the run still succeeds: it ends
442
+ "Merge <url>", and "By hand:" says why. A run
443
+ that changes no file, or that stops, opens none. A file the default branch has otherwise than your
444
+ checkout is refused, so bring the checkout up to date first. The pre-push
445
+ git hook, which git does not track, is written in place. The work rules
446
+ pass that pull request without a `Slice:` line while it changes only the
447
+ files `onboard` writes. `onboard` leaves the repo's CODEOWNERS as it is:
448
+ when a rule there names you, GitHub asks you to review the agent's pull
449
+ requests that change the files it matches, and the repo's own rules
450
+ decide whether that review is required. An existing `.claude/settings.json`
451
+ keeps its layout: `onboard` adds only its entries, and replaces the hook
452
+ entries an older release wrote where they stand. The repository needs at
453
+ least one commit. The pull request checks read the settings from the base
454
+ branch, so a pull request cannot rename the agent it is checked against.
455
+ The pull request that first commits them, `onboard`'s, passes PR identity, Work rules
456
+ and Design frames, saying the repo is not adopted on its base yet, as for
457
+ a feature that is off; they apply from the next pull request.
458
+
459
+ The shared checks run five jobs. **Settings** validates
460
+ `.github/niyam.json`, and fails when a job's `niyam-ref`
461
+ names another release than the `checks.yml@` line it calls (see Releases and
462
+ upgrading). **PR identity** runs on pull requests: every
463
+ commit that claims the agent (its login or its no-reply address) must be
464
+ Verified as the agent, and agent commits must be pushed by the agent, so agent
465
+ work pushed with the owner's login fails. Who pushed comes only from GitHub's
466
+ record of the pushes to the pull request's branch (the fork's, for a fork),
467
+ never from whoever started the run, so an edit, a reopen or a re-run by anyone
468
+ gives the result the push gave. A push GitHub has not recorded yet is waited
469
+ for about a minute, then fails until a re-run finds it. A merge queue's test runs
470
+ pass with nothing to check, since each queued pull request was checked on its own:
471
+ a `merge_group` run, and a pull request `mergify[bot]` opened from a
472
+ `mergify/merge-queue/` branch of the repository itself (anyone else's pull request
473
+ on such a branch is checked). **Work rules** runs on the agent's
474
+ pull requests: each names exactly one slice, as a line `Slice: #N`, and that
475
+ slice may be built:
476
+
477
+ - it is a Slice issue under a Work item the owner labeled `approved`;
478
+ - if it was added to the work item after the approval, the owner approved
479
+ it: a 👍 on the agent's proposal for it, made after it was added, a
480
+ comment starting `Decision:` naming it, or the owner's own request: a
481
+ comment they wrote on the work item before the slice was last added,
482
+ which the slice's body links (`…/issues/<work item>#issuecomment-<id>`)
483
+ and they have not edited since. Which comment asked for the slice is the
484
+ agent's claim, shown in the slice's body: the comment came first, so it
485
+ cannot name the slice;
486
+ - each of its State sub-issues closed as not planned after the approval
487
+ carries the owner's approval: a 👍 on the agent's proposal for it, or a
488
+ `Decision:` comment;
489
+ - no other open pull request names it;
490
+ - each State it names with a line `State: #N` is a State sub-issue of the
491
+ slice, and when the slice is closed already, so the pull request is a fix,
492
+ it names at least one open State: the one the fix is filed as.
493
+
494
+ **One comment answers a batch.** Settings that name the repository's standing
495
+ Approvals issue (`"approvals": N`) let the owner answer many asks at once:
496
+ an owner's comment there whose first line opens `Decision: approve`, then
497
+ `#N` for each issue it approves (`Decision: approve #31 #12 #40`). Only that
498
+ line approves; the lines under it are reasons, so `Not #44 yet` approves
499
+ nothing. The work rules take it for a slice added after the approval when it
500
+ names the slice and was made after the slice was last added, and for a
501
+ dropped State when it names the State and was made after the State was
502
+ closed. They read the Approvals issue's comments once a check, only when a
503
+ decision is owed. If GitHub cannot find the Approvals issue, it answers
504
+ nothing and the check goes on.
505
+
506
+ A `Decision:` comment, a batch answer included, counts only while it says
507
+ what owners wrote: unedited, or edited by owners alone. Repo writers, agents included, can edit anyone's
508
+ comment, and only GitHub's GraphQL API (`userContentEdits`) names who made
509
+ each edit, so the work rules read it for an owner's edited `Decision:` alone;
510
+ an unedited one is read through REST, as before. Where GraphQL is refused, as
511
+ in a Claude cloud session, an edited `Decision:` does not count, and the
512
+ refusal says why.
513
+
514
+ **The board follows the work.** When an agent session's push names a slice
515
+ the work rules let it build, pre-push moves the board on, as the agent, on
516
+ every open Project of the repository's owner that holds the issues: the
517
+ slice's Status to In Progress; its work item's Step to Build, since its first
518
+ slice has started; and every other Work item of the repository to the Step
519
+ GitHub's facts give it. A closed work item is at Done; an open one is at
520
+ least Frame, where a new one starts, at least Slice once it has sub-issues,
521
+ and at least Build once one of them is closed. Nothing on GitHub marks
522
+ Specify, so the owner sets it by hand and it stays. A Step moves only
523
+ forward, except that a reopened work item leaves Done, and an option the
524
+ owner added to Step is left alone. So once Step has Done, the Work items
525
+ view groups no closed work item under Frame, Specify, Slice or Build, and
526
+ none under "No Step", but for one the owner put at an option of their own. The items it reads
527
+ hold their issues, so this reads no issue on its own. A Project whose Step
528
+ has no Done, made before it, gets one line saying so, and `onboard` adds the
529
+ option, keeping every item's Step. A workflow's `GITHUB_TOKEN` cannot write to a Project, so the
530
+ agent's push does this, with the agent token's `project` scope, with `board`
531
+ on. It uses GitHub's REST API for Projects alone, so it works through a
532
+ Claude cloud session's GitHub proxy, which refuses GraphQL.
533
+ A board it cannot read, or a move GitHub refuses, is said and does not stop
534
+ the push; a push for a closed slice, such as a fix, moves nothing. When a pull request naming a slice merges into the default branch,
535
+ the shared workflow comments on the slice, linking the pull request, and
536
+ closes it, and the Project's Item closed workflow moves it to Done: a
537
+ `Slice: #N` line is not one of GitHub's closing keywords, so GitHub does not
538
+ close it. Each State under that slice the pull request names with a line
539
+ `State: #N` gets the same comment and is closed as completed too; a State
540
+ named only in prose stays open, a State closed as not planned is left as it
541
+ is, and so is one under a slice the pull request does not name. A slice or
542
+ State GitHub closed already, through a closing keyword such as "Closes #N"
543
+ beside it, still gets the comment; one that has it gets no second one. That job alone of a pull request's runs writes to issues. It runs only for
544
+ pull requests from the repository itself: a fork's run gets a read-only token, so
545
+ a slice a fork's pull request builds is closed by hand.
546
+
547
+ **What needs the owner.** A request the owner made on the work item is its
548
+ own approval, linked as above. A fix needs none: it restores what the owner
549
+ approved and changes nothing they would see beyond it, so it is filed as a
550
+ State under the slice it fixes and its pull request names that slice, with
551
+ `Slice: #N`, and the State, with `State: #N`, which closes the State on merge. The
552
+ State needs no approval, though that slice's own approval rules still apply,
553
+ as for any pull request naming it. A request made in chat is filed as a slice quoting the
554
+ owner's words and proposed once. Anything else the agent adds, a fix filed
555
+ as its own slice included, waits for the owner's 👍.
556
+
557
+ **Approving with one tap.** In an agent session, `niyam propose
558
+ <issue> --page <url>` asks the owner for what a slice owes: given the slice, it comments
559
+ on it as the agent, one `Proposal:` comment for its addition after the
560
+ approval and one for each State dropped after it (given a State, for that
561
+ state alone), mentioning the owner, and labels the slice `needs-owner`, so it
562
+ shows in the owner's Needs you view and their GitHub notifications. Each
563
+ proposal is a pointer, as every ask to the owner is: one line naming what it
564
+ proposes, `Page: <url>` and how to answer, in at most 500 characters. The
565
+ page, which the agent publishes first and names with `--page <url>` (one page
566
+ for the whole run), argues it: what changes and why, from the slice's
567
+ `**You will see:**` and `**Why:**` sections (a dropped State's own
568
+ `**Why:**`), what it costs and what happens if the owner declines. Without
569
+ `--page`, a proposal still to be posted is refused, posting nothing, with
570
+ the command to run; a `--page` that is no published page is refused before
571
+ GitHub is asked anything. It also refuses, posting nothing, while a
572
+ body lacks those sections, naming them, and when a comment would break the
573
+ guard's rule (a title so long the comment runs over 500 characters). The owner
574
+ approves a proposal by reacting 👍 to it, from the phone or the web; a typed
575
+ `Decision:` comment still works. A 👍 counts only from the owner, only on the
576
+ agent's comment starting `Proposal:` whose first `#N` is the slice or state
577
+ it approves, and only when made after the proposal's last edit (and, for a
578
+ slice, after it was last added). Run again, `propose` posts nothing twice, and
579
+ once the owner has approved everything it takes `needs-owner` off. Each run
580
+ prints, for each decision still waiting, the link GitHub gives its newest
581
+ proposal, posted now or before: the comment's own `#issuecomment-` address,
582
+ where the owner reacts, never the slice's top or the `needs-owner` list. A
583
+ waiting decision with no proposal yet gets the command that posts one,
584
+ `niyam propose <issue> --page <page url>` with its number. A
585
+ reaction does not re-run a pull request's checks: the agent proposes before
586
+ it starts, and pre-push or a re-run of Work rules sees the 👍.
587
+
588
+ **Many at once.** `propose` takes several issues, `niyam propose 12
589
+ 30 41 --page <url>`, and asks for each in turn, each comment linking that page. Where the settings name an Approvals issue
590
+ (`"approvals": N`), each proposal also says it can be answered in the batch
591
+ on Approvals, and the run ends with that issue's link and the first line of
592
+ the owner's answer there, ready to paste: `Decision: approve #12 #30 #41`,
593
+ one number per proposal still waiting (a slice for its addition, a State for
594
+ its drop). The owner pastes it as a comment on Approvals, deleting any number
595
+ they refuse. The agent hands the line over and never posts it: only the
596
+ owner's own comment approves anything. The Needs you job reads each
597
+ proposal by its own number, so a slice whose only waiting proposal is a
598
+ State's leaves Needs you as soon as the batch names the State.
599
+
600
+ **The Needs you list keeps itself.** With `board` on, the client workflow's
601
+ `niyam-asks` job runs `niyam needs-owner`. An agent's comment
602
+ opening with `Needs you:` or `Proposal:`, on an issue, a pull request or a review thread, labels its issue or pull request
603
+ `needs-owner`, so it shows in the owner's Needs you view. On an issue, the
604
+ owner's `approved` label or `Decision:` comment takes the label off at once;
605
+ on a pull request, where a label approves nothing (approvals are given on
606
+ issues only), the owner answers with a `Decision:` comment, which takes it
607
+ off at once, or a 👍 on the ask, which the hourly sweep counts. The sweep
608
+ reads an issue's or pull request's own comments, not review threads, so an
609
+ ask in a review thread is answered with a `Decision:` reply there. Hourly
610
+ (cron `41 * * * *`), on a run by hand, and at once when the owner posts a
611
+ batch answer on the Approvals issue, a sweep takes it off each open issue
612
+ whose every agent ask the owner has answered. Each `Proposal:` is an ask of
613
+ its own, for the issue its first line names first (a slice for its addition,
614
+ a State for its drop; the issue itself when it names none); a `Needs you:` is
615
+ one when it is the latest agent ask there. An ask is answered by a 👍 on it
616
+ after its last edit, a `Decision:` comment after it on the issue, or a batch
617
+ answer after it on the Approvals issue whose first line names its issue,
618
+ that no one but owners edited. So a batch naming one proposal on a slice
619
+ leaves the slice on Needs you while another there waits. A proposal for the
620
+ slice's own addition counts only answers after the slice was last added to
621
+ its work item, so a slice taken out and added again waits on the owner
622
+ again. The sweep reads that from the slice's own timeline; unlike the work
623
+ rules, it misses an addition GitHub records only on the work item's. An issue labelled
624
+ with no agent ask on it, such as the weekly job's undo issues, is left as it
625
+ is, unless the owner's batch answer names it. Only comments
626
+ that may ask or decide, from the owner, a member or a collaborator, the
627
+ `approved` label and the hourly cron start the job, so other comments, and an
628
+ outsider's, run nothing.
629
+
630
+ **Answering review threads.** In an agent session, `niyam
631
+ review-thread <thread-id> --reply <text> --resolve` replies on a review
632
+ thread (`PRRT_…`), resolves it, or both, as the agent. It refuses unless the
633
+ session's token is the agent's and the thread is on a pull request the agent
634
+ opened in the repository here. `onboard` allows exactly this command in
635
+ `.claude/settings.json` (`Bash(niyam review-thread *)`), so answering
636
+ review findings on its own pull requests needs no prompt, even in Claude
637
+ Code's auto mode, where an allow rule settles a command without the
638
+ classifier. It allows the command, not `gh api`: a rule cannot hold `gh
639
+ api`'s arguments to one endpoint, since its `*` matches anything after it.
640
+
641
+ The reply can come from a file, `--body-file <path>`, since replies hold
642
+ backticks and braces that a shell guard may refuse in an argument. The file
643
+ must be in the repository, such as under `.tmp/`, since the allow rule runs
644
+ the command without a prompt. A reply from a file resolves the thread unless
645
+ `--no-resolve` is given. `--reaction
646
+ +1` or `-1` with `--comment-id <id>` reacts on one of the thread's comments;
647
+ a reaction that fails is a warning, and the thread is still resolved. A
648
+ reply already on the thread, compared without surrounding space, is not
649
+ posted again, so a rerun is safe.
650
+
651
+ On a machine it uses GitHub's GraphQL API, and a thread is named by its node
652
+ id (`PRRT_…`). In a Claude cloud session, whose proxy refuses GraphQL, it uses
653
+ the proxy's own REST routes (`pulls/{n}/ccr/review_threads` and
654
+ `pulls/{n}/ccr/comments/{id}/resolve`), and a thread is named by its first
655
+ comment's number, the one in its `#discussion_r` link. The proxy appends a
656
+ Claude Code footer to what it posts, so a reply there is compared without it.
657
+ An id in the other form is refused before any request.
658
+
659
+ **Reading a pull request's signals.** `niyam pr-signals <pr> [--ci-only]`
660
+ prints one JSON object: the pull request's open review threads, its failing
661
+ checks and the local review's findings, as one list of signals with
662
+ duplicates folded together, and its resolved threads, to tell a new finding
663
+ from one already answered. Each thread's signal carries the ids
664
+ `review-thread` takes there (`thread`, and `comment` for a reaction). A
665
+ failing check run from GitHub Actions brings the error lines of its job's
666
+ log, 40 at most; another check brings its name, conclusion and summary.
667
+ Every page of every list is read to its end, and a page that says more follow
668
+ without a cursor stops the run: a short list never reads as the whole one. A
669
+ pull request that is merged or closed is refused (exit 3 or 4, and
670
+ `"ok": false` on standard output) before anything is read, and again before
671
+ printing, as one can merge while its signals are read. `--ci-only` reads the
672
+ checks alone.
673
+
674
+ A repository with a local review, one that runs before a push and writes its
675
+ findings to a file, names it in `.github/niyam.json`, with the logins of its
676
+ review bots:
677
+
678
+ ```json
679
+ { "signals": { "bots": ["review-bot"], "findings": ".tmp/review/findings.json" } }
680
+ ```
681
+
682
+ The file holds `{"issues": [{"title", "description", "file", "line",
683
+ "priority"}], "metadata": {"status"}}`. A finding citing a file the pull
684
+ request does not change is dropped, as another branch's. A file whose
685
+ `metadata.status` is `failed` is reported as a failed review, never a clean
686
+ one. A bot's thread and the local finding at the same file and line are one
687
+ signal: the same review, posted twice.
688
+
689
+ **Design frames** is the `figma` feature, an optional extension for clients
690
+ that design in Figma: with it on and two Actions secrets, `FIGMA_LIBRARY`
691
+ (the design library's file key) and `FIGMA_TOKEN`, each State of the slice
692
+ an agent pull request builds, other than one closed as not planned, must link
693
+ a Figma frame (`figma.com/design/...?node-id=...`) that holds at least one
694
+ component published by that library and is not a captured image (an image
695
+ covering half the frame or more). Frames are for Experience work: a slice
696
+ whose parent Work item names any other kind in a `Kind:` line (`**Kind:** Process.`,
697
+ or plain `Kind: Process`) passes without a Figma call; one whose Work item
698
+ names no kind, or whose parent is not a Work item, is checked. Without `FIGMA_TOKEN`, or without a
699
+ library (from `FIGMA_LIBRARY`, or an older committed key, below), the job says
700
+ the check is off and passes. The library key is a secret, not a committed setting,
701
+ so a public repository does not publish its design file, and the workflow
702
+ `onboard` writes passes the Figma secrets only while `figma` is on. Settings
703
+ an older release wrote still work: a `design` feature is read as `figma`, and
704
+ a `"figma": { "library": ... }` setting is read when `FIGMA_LIBRARY` is not
705
+ set, each with a warning; `onboard` renames the feature, takes the key out
706
+ and sets it as the `FIGMA_LIBRARY` secret itself, as you, with the run's one
707
+ browser approval: it seals the key with the repository's Actions public key
708
+ (a libsodium sealed box, as GitHub requires) and stores it through GitHub's
709
+ API, never printing it.
710
+
711
+ **Decisions, weekly** runs on Mondays at 06:17 UTC (and by hand), or on the
712
+ `schedule` the settings set. A Decision issue carries
713
+ its fields one per line: `Kind:` (Override, Risk or Bet), `Review:`,
714
+ `Expires:`, `Check:` (a command in backticks; exit 0 means the decision still
715
+ holds) and `Undo:`. For each open Decision issue, a check that reads laptop
716
+ files (`~/`, `$HOME`, `/Users/`, `/home/`) is labeled `cannot-run-here`; any
717
+ other check runs in the checkout with only `PATH` and `HOME` set, for at most
718
+ two minutes and five more seconds to end it (a check that runs out of time is
719
+ not counted as tripped), and
720
+ when it fails the decision gets a comment and one undo issue labeled
721
+ `needs-owner`. Runs do not overlap, and after 45 minutes of checks the rest
722
+ wait for next week. An Override whose expiry is within 30 days is labeled
723
+ `expiring`; one whose expiry has passed is named in the run's log. A check runs
724
+ only when the owner or the agent wrote the issue and was the last to edit it.
725
+
726
+ The **review routine** is a weekly scheduled agent session in the client
727
+ repository, working as the agent; its prompt is
728
+ [routines/review.md](routines/review.md). It runs `niyam reviews-due`
729
+ for the open decisions whose `Review:` date has come, then for each one either
730
+ keeps it (comment `Kept:` with reasoning and a new review date) or settles it
731
+ (comment `Settled:` with reasoning, and closes it), labeling both `veto` so
732
+ the owner has a week to reverse it. A decision touching secrets, money or
733
+ production is held for the owner with a suggestion and `needs-owner`. The
734
+ weekly job removes `veto` once the week has passed.
735
+
736
+ `reviews-due` lists only a decision the owner or the agent wrote and last
737
+ edited, so no one else's text reaches the routine. It reads only GitHub's REST
738
+ API, which a cloud session's GitHub proxy allows, and REST does not say who
739
+ last edited an issue's body, so the weekly job, whose token reads GraphQL,
740
+ vets the text for it: on each open decision with a `Review:` date that the
741
+ owner or the agent wrote and last edited, it keeps one comment naming the
742
+ text's SHA-256, and updates it after their edits. `reviews-due` lists a
743
+ decision only while its text has the hash in the workflow's latest such
744
+ comment. Any other text is left out, and `reviews-due` says so: a decision
745
+ the owner or the agent wrote or edited since the job last ran comes up after
746
+ its next run.
747
+
748
+ The weekly job also watches the routine: an open decision the routine reviews
749
+ whose `Review:` date is over a week past, with no `Kept:` or `Settled:` from
750
+ the agent since, is labeled `needs-owner` with a comment, so a routine that
751
+ was never created, or has stopped, shows up. Only the agent's comments count
752
+ as verdicts: anyone can write `Kept:`. `reviews-due` still lists a decision
753
+ the job labeled so, until the agent comments on it, and the job takes the
754
+ label off once the agent's verdict follows it; a `needs-owner` the routine or
755
+ the owner added stays. `onboard`, with `review` on, lists the routine under
756
+ "By hand:", and its pull request says how to create it: a weekly Claude routine on the repository (claude.ai/code/routines,
757
+ or `/schedule`), with claude.ai's GitHub connected as the agent, and the
758
+ prompt from `routines/review.md` at the release in use. It cannot create the
759
+ routine itself: Claude's routines API answers only a Claude Code session's own
760
+ sign-in, not a command, and a routine works as claude.ai's GitHub connection,
761
+ which no API names.
762
+
763
+ `onboard` also writes a pre-push git hook running `niyam pre-push`,
764
+ for every adopter. In a local agent session (one session-start set up, or
765
+ any shell Claude Code runs on the Mac, which sets `CLAUDECODE`, so it holds
766
+ where the Claude Code hooks never ran) it is the pre-push identity guard: a
767
+ push over SSH is refused, whatever the host, since it would use this Mac's
768
+ SSH keys, the owner's; over HTTPS to GitHub, git is asked for the
769
+ credentials it would push with (one in the URL included) and GitHub for
770
+ whose they are, and only the agent's push goes ahead; in a Claude cloud
771
+ session, GitHub is asked through its proxy whose account the session is. The
772
+ owner's pushes from their own terminal are not checked. With `work-rules` on, it then applies the same rules before an
773
+ agent session pushes: all the commits
774
+ one push brings, on one branch, name one slice between them as a
775
+ `Slice: #N` trailer. Commits a remote already has are not the push's own,
776
+ and neither are the default branch's commits the clone can find: those its
777
+ tip as GitHub names it reaches, when the clone has that commit, and those
778
+ its remote-tracking ref reaches. Where those are behind, as in a
779
+ single-branch clone that merged the default branch from `FETCH_HEAD`, and the
780
+ push would be refused, GitHub is asked which commits the push's merges
781
+ brought are on the default branch, and those are left out too. So a merge of
782
+ the default branch brings none of the slices its commits name. A push whose
783
+ own commits name no slice, such as a merge or a commit with no trailer, is
784
+ judged by the branch's own commits, those not on the default branch: it
785
+ passes when they name exactly one slice. Where the clone cannot find the
786
+ default branch at all, a push of only merges is judged by the commits the
787
+ merges did not bring, as before. In an agent session, a push is refused when the CLI is
788
+ missing, or, with `work-rules` on, the session has no token. When the repository already has its own
789
+ pre-push hook, or git runs hooks from a folder outside the repository (a
790
+ global `core.hooksPath`), `onboard` leaves it alone and lists the line to add
791
+ under "By hand:": `niyam pre-push "$@"`. The client workflow re-runs the checks when a
792
+ pull request's description is edited. After upgrading niyam, run
793
+ `onboard` again: it upgrades the hook entries in `.claude/settings.json` and
794
+ the workflow. An older release's workflow, one job that let every run write
795
+ to issues, is replaced; a workflow split into `niyam` and
796
+ `niyam-weekly` alone gets the `niyam-merged` job, which
797
+ closes a merged pull request's slice, and runs on closed pull requests; a
798
+ workflow with those three jobs alone gets the `niyam-asks` job, with
799
+ the comment and label triggers and the hourly cron it runs on, and the weekly
800
+ job leaves that cron alone; a 0.5.28 asks job, which any
801
+ commenter's ask started, starts on an owner's, member's or collaborator's alone;
802
+ a 0.6.3 one, which the approved label alone of the issue events started, starts
803
+ on an issue opened or reopened too (see Issue types), unless the client changed
804
+ its `issues:` trigger; a
805
+ workflow already split into its jobs keeps everything but its version pins, which move to the
806
+ new release, the one branch pushes run on, which follows a changed default
807
+ branch, and the one cron the weekly job runs on, which follows a changed
808
+ `schedule` (a schedule with more crons, or a comment on its cron line, is the
809
+ client's own and stays as it is); any other workflow is offered a replacement. Make the checks of the
810
+ features a client has turned on required on its default branch, such as
811
+ `niyam / PR identity` with `pr-identity` and `niyam / Work rules` with
812
+ `work-rules`; a check of a feature that is off still runs and passes, but with
813
+ identity alone there is no workflow at all, so require none.
814
+
815
+ ### One feature at a time
816
+
817
+ A client can turn features on one at a time. `identity` is always on: the
818
+ settings, the session-start hook, the agent's access and its Verified commit.
819
+ The others are `pr-identity`, `board`, `work-rules`, `figma`, `decisions` and
820
+ `review`. The settings list the ones a client has turned on:
821
+
822
+ ```json
823
+ { "owner": "example-owner", "agent": "ExampleBot", "features": ["identity"], "project": "Example work" }
824
+ ```
825
+
826
+ `niyam onboard <owner> <agent> --features identity` sets up identity
827
+ alone; later, `niyam onboard --add board` turns one more on and sets
828
+ it up. Settings with no `features` key keep every feature on, as before;
829
+ `"features": []` means identity alone. The shared checks,
830
+ the weekly job, `reviews-due` and the pre-push hook each pass, saying so, when
831
+ their feature is off; `onboard` writes the workflow only once a check needs it. `project` names the board's
832
+ Project (by default `<repo> work`). `schedule` sets when the weekly job runs,
833
+ as a five-field cron in UTC (by default `"17 6 * * 1"`, Mondays at 06:17);
834
+ `onboard` refuses one that is not a cron, or that is `41 * * * *`, the hourly needs-owner sweep's, and writes it into the workflow, so
835
+ run `onboard` again after changing it. `approvals` names the repository's
836
+ standing Approvals issue, where one owner comment answers a batch of asks
837
+ (see the work rules); without it, there are no batch answers on an
838
+ Approvals issue.
839
+
840
+ GitHub has issue types for organisations only, so on a repository a personal
841
+ account owns, `work-rules`, `decisions` and `figma` cannot run: the work rules
842
+ need a Slice under a Work item, the weekly job and `reviews-due` list
843
+ Decision issues, and the design check reads a slice's State sub-issues.
844
+ `onboard` refuses to turn them on there, with `--features` or `--add`, saying
845
+ why; with no `--features`, it turns on the rest and names the ones it left
846
+ off. Should the settings list them anyway, `pr-work-rules`, `pr-design`, the
847
+ weekly job, `reviews-due` and the pre-push hook's work rules pass, saying the
848
+ feature is off on a personal account's repository and why, rather than
849
+ failing every pull request. They ask GitHub whose the repository is once per
850
+ run.
851
+
852
+ ### Issue types
853
+
854
+ The work model has five issue types, Work item, Slice, State, Decision and
855
+ Brief, and `onboard` makes the organisation's enabled types exactly these.
856
+ Issue types are an organisation-wide setting, so this reaches every
857
+ repository in the organisation, onboarded or not, and the plan says
858
+ "org-wide". `onboard` adds a work model type the organisation lacks and
859
+ enables one it has disabled. Every other type, GitHub's default Task, Bug
860
+ and Feature or one of the organisation's own, it disables, after giving each
861
+ issue that holds one, open or closed, in any of the organisation's
862
+ repositories, a work model type from GitHub's facts about it:
863
+
864
+ - a sub-issue of a Work item becomes a Slice;
865
+ - a sub-issue of a Slice becomes a State, an experience state of that slice;
866
+ - an issue with sub-issues becomes a Work item;
867
+ - any other becomes a Brief.
868
+
869
+ Each open issue with no type at all, in any of the organisation's
870
+ repositories, gets one by the same rule, under the same yes. A repository's
871
+ Approvals issue, the one its settings (`.github/niyam.json` on its default
872
+ branch) name as `"approvals": N`, is left with no type, and the plan says so: it is a standing record the
873
+ owner answers batches on, never closed, which none of the five fits, and the
874
+ work rules find it by its number, not its type. A closed issue with no type
875
+ is left as it is, and the plan says that too. No rule reads a title or a
876
+ label: the CLI writes neither for a Decision, so a Decision is typed by hand.
877
+
878
+ An issue whose parent is being retyped is read as the parent's new type, so
879
+ a Task with Task sub-issues becomes a Work item with Slices. The plan names
880
+ every issue it types, a run of consecutive ones in a repository that one
881
+ rule types alike on one row (the question names the first ten), and each
882
+ type it disables, and the one yes covers them. The agent
883
+ reads the organisation's types, but only the repositories it can see, so
884
+ where an enabled type outside the work model exists, or an issue to type, `onboard`
885
+ signs you in before the
886
+ plan and reads every repository as you: the plan shows what the yes
887
+ approves. The run reads again and changes nothing beyond it: an issue found
888
+ only after the plan keeps its type, or its lack of one, that type stays
889
+ enabled, and "By hand:" says to run `onboard` again. A dry run signs in to
890
+ nothing, so it lists what
891
+ the agent can see. It retypes every issue first and disables a type only then, so no
892
+ issue is left holding a disabled type: GitHub hides a disabled type on the
893
+ issues that hold it and shows it again if it is enabled. `onboard` disables
894
+ rather than deletes, so a type can come back; GitHub does not say what
895
+ deleting one does to its issues. A rerun cannot check a type that is
896
+ disabled: GitHub refuses to list issues by one (HTTP 422), for the owner
897
+ too, so the plan names each such type on a `disabled` row (as `disabled
898
+ Task, Bug, Feature: GitHub lists no issues by a disabled type, so onboard
899
+ cannot tell whether any holds one`), never saying none holds it, and the
900
+ type stays disabled; enabled again, `onboard` retypes what holds it and
901
+ disables it once more. Any other 422, one for an enabled type included,
902
+ still fails the read, as does any other refusal but the 410 of a repository
903
+ with issues turned off.
904
+ An issue in an archived repository cannot be
905
+ changed, so it keeps its type, that type stays enabled, and "By hand:" says
906
+ to unarchive the repository and run `onboard` again. A repository with issues
907
+ turned off, as a fork usually is, has none to read. A rerun changes
908
+ nothing when all is in order, and catches a type someone enabled again or a
909
+ default GitHub adds later. Disabling a type needs an organisation owner
910
+ (`admin:org`); retyping an issue needs write access to its repository. Both
911
+ come from the owner's sign-in for the run.
912
+
913
+ **New issues get a type as they open.** With `board` on, `onboard` writes
914
+ the client workflow (for `board` alone too), whose `niyam-asks` job
915
+ also starts when an issue is opened or reopened, and runs `niyam
916
+ issue-type`, which gives an issue with no type one by the same rule, read
917
+ from GitHub when the job runs, so a parent set as the issue was made counts.
918
+ GitHub starts no run for an issue a workflow's own `GITHUB_TOKEN` opens, such
919
+ as a monthly reminder a client's workflow files, so the job also runs on the
920
+ asks job's hourly cron and types every open issue in the repository with
921
+ none: such an issue has its type within the hour. An issue opened with a
922
+ type, one closed since, the Approvals issue, and a repository a personal
923
+ account owns are left alone. A workflow whose `issues:` trigger the client
924
+ changed keeps it, so there the job starts hourly alone. The job's
925
+ `issues: write` sets the type: GitHub's `type` on an issue takes write access
926
+ to issues, as the weekly job's undo issues, opened as Briefs by that token,
927
+ show. Issue events never come from a fork, and the job reads its settings
928
+ from the default branch and runs the CLI from the release the workflow pins,
929
+ so an issue's author, whoever opens it, changes nothing but that issue's
930
+ type. An issue made as a Brief and only
931
+ later made a sub-issue keeps Brief: no event starts the job then, so retype
932
+ it by hand.
933
+
934
+ `doctor` on a Mac, in a repository whose settings turn the board on, warns (`▲`)
935
+ when the organisation has an enabled type outside the work model or lacks
936
+ one of the work model's, naming the issues in this repository that hold
937
+ another type, and when an open issue here has no type, but the Approvals
938
+ issue; the fix is the owner running `onboard` again.
939
+
940
+ ### Hooks that call GitHub
941
+
942
+ The lock in the settings' `env` reaches every hook, and session-start lifts
943
+ it only for the session's shells, through `CLAUDE_ENV_FILE`, which Claude
944
+ Code gives the SessionStart, Setup, CwdChanged and FileChanged hooks alone.
945
+ So a client's own hook that runs `gh` or git's remote commands, a
946
+ PreToolUse or Stop hook say, presents the lock's token, and GitHub answers
947
+ `HTTP 401: Bad credentials`; in a cloud session too. Run each such command
948
+ through `as-agent`, with the `session_id` Claude Code puts in every hook's
949
+ JSON input:
950
+
951
+ ```sh
952
+ input=$(cat)
953
+ sid=$(printf '%s' "$input" | jq -r .session_id)
954
+ cli="$HOME/.config/niyam/bin/niyam"; [ -x "$cli" ] || cli=niyam
955
+ printf '%s' "$input" | "$cli" as-agent --session "$sid" -- gh pr view --json state
956
+ status=$?
957
+ [ "$status" -eq 77 ] && exit 0 # locked: this session does not work as the agent
958
+ exit "$status"
959
+ ```
960
+
961
+ `niyam as-agent --session <session_id> -- <command> [args...]` runs
962
+ the command only when session-start recorded, for that session id, that the
963
+ session works as one of the agents the settings file names, the
964
+ record the guard reads. On a Mac the command gets what the session file
965
+ gives a shell: the agent's identity, the lock's variables removed, and
966
+ `GH_TOKEN` read from the keychain as it starts. In a cloud session it gets
967
+ the proxy's placeholder token, which the proxy swaps for the connected
968
+ account's. Its standard input, output and error are the hook's, and its exit
969
+ code is `as-agent`'s. Otherwise nothing runs: one line on standard error says
970
+ why, in the guard's words, and `as-agent` exits **77**, a code
971
+ `gh`, git and the shell do not use, so a hook can tell "locked" from
972
+ the command's own failure. A missing `--` or command is bad usage, exit 2. The token is
973
+ only ever in the command's environment, never on a command line, in output
974
+ or in a file, and it never falls back to the owner's `gh` logins, git
975
+ password or SSH. Use the launcher line above, as the hooks `onboard` writes do:
976
+ the app's hooks may have no node on their `PATH`. `niyam doctor`,
977
+ run in the client repo, warns under "This repo" about each hook in `.claude/settings.json` or
978
+ `.claude/settings.local.json` whose command, or the repo script it runs,
979
+ calls `gh` or git's remote commands outside `as-agent`. A script that
980
+ imports a Python module tracked in the repo whose code runs `as-agent` (a
981
+ helper wrapping each `gh` call) counts as routed through it; the hook's
982
+ command is still judged. Outside a cloud session, a script is read only up
983
+ to a line, at column 0, that exits there,
984
+ `[ "${CLAUDE_CODE_REMOTE:-}" = true ] || exit 0` or
985
+ `[ "$CLAUDE_CODE_REMOTE" != true ] && exit`, when only blank lines, `set`,
986
+ `export` and the like, `.` or `source`, and assignments come before it: bash
987
+ runs nothing after it on a Mac. Both are read as text, so a routed script
988
+ that also calls `gh` on its own is not told apart.
989
+
990
+ ### Claude cloud sessions
991
+
992
+ A Claude cloud session has no keychain and no session file: it reaches
993
+ GitHub through Claude's GitHub proxy, as the account connected to claude.ai.
994
+ So for agent sessions there, that connection is the agent account. Its
995
+ `session-start` asks GitHub, through the proxy, which account the session
996
+ is. When it is the agent, it writes the pre-push git hook (a fresh clone
997
+ has none), lifts the lock and records the session for the guard; `gh` gets
998
+ the proxy's placeholder token (`proxy-injected`), which the proxy swaps for
999
+ the connected account's. As anyone else, GitHub stays locked out and the
1000
+ session is told to stop. The pre-push hook asks GitHub the same through
1001
+ the proxy before each push. `session-start` runs only as the SessionStart
1002
+ hook: Claude Code sets `CLAUDE_ENV_FILE` for its hooks, never in the
1003
+ session's shell, so run by hand there it always says STOP, which says
1004
+ nothing about the session.
1005
+ The hook's own line at session start is what counts.
1006
+
1007
+ A cloud session's git commits are authored and committed as Claude's own
1008
+ account, `Claude <noreply@anthropic.com>`, and signed by it (Verified),
1009
+ while the push is the agent's. PR identity checks only commits that claim
1010
+ an agent, so these pass, and GitHub records the agent as having pushed
1011
+ them.
1012
+
1013
+ The proxy refuses GitHub's GraphQL API, so the work rules and `reviews-due`
1014
+ read only its REST API, here and everywhere else. The one exception is who
1015
+ edited an owner's edited `Decision:` comment, which only GraphQL names; here
1016
+ such a comment does not count.
1017
+
1018
+ The cloud environment's Setup script, which runs as root once the repo is
1019
+ cloned and before Claude Code starts, installs the CLI. Claude Code has no
1020
+ API or CLI for that field, so you paste it once, by hand, and it names no
1021
+ version: `niyam cloud-setup` prints a short snippet that finds the
1022
+ clone and runs its `.github/niyam/cloud-setup.sh`, with `NIYAM_SETUP` set.
1023
+ `onboard` writes that file in its pull request at the version
1024
+ `.github/workflows/niyam.yml` pins, and writes it again on every
1025
+ run, so the pin bump that upgrades the checks upgrades cloud sessions too,
1026
+ with no new paste. A snippet pasted before 0.6.10 runs
1027
+ `.github/process-rules/cloud-setup.sh` alone, which `onboard` deletes since
1028
+ P-57: paste the new snippet over it, once. The Setup script runs from the folder that holds the
1029
+ clone (the VM's home, the clone one folder down), so the snippet looks there
1030
+ and in each home. The file unpacks Node and the CLI under
1031
+ `/opt/niyam`, each once it matches the sha256 the file pins (Node's
1032
+ from this release, the CLI's from GitHub's record of the release archive),
1033
+ and puts `niyam` on `PATH`, leaving the image's own Node alone. The
1034
+ environment needs the network to reach nodejs.org and GitHub's release
1035
+ downloads.
1036
+
1037
+ The Setup field holds one script, so the snippet runs in a shell of its
1038
+ own (`bash <<'NIYAM' … NIYAM`): a failed download, or a
1039
+ clone with no such file, says so on standard error and the commands after
1040
+ it still run. If the repo has its own Setup script, put this first, then
1041
+ the repo's own: a repo's script may end with `exit`, and nothing after that
1042
+ runs.
1043
+
1044
+ Claude keeps a snapshot of the environment once its Setup script has run,
1045
+ and builds it again only when the Setup script changes or after about a
1046
+ week. So after a pin bump, a cloud session's `session-start` finds its CLI
1047
+ is not the release `cloud-setup.sh` installs, runs that file itself, and
1048
+ says so in one line; the session goes on with the new CLI, and the snapshot
1049
+ catches up on its next build. When the repo has no `cloud-setup.sh` while
1050
+ the workflow pins another release, or the file is not at the workflow's
1051
+ pin, the line says to run `onboard` again. When the Setup script still
1052
+ installs a release of its own (an older paste), the line also says to paste
1053
+ the snippet over it, once. It only warns: the session works on.
1054
+
1055
+ claude.ai has one GitHub connection per account, so it is the agent's for
1056
+ every cloud session that account starts.
1057
+
1058
+ `niyam doctor` in a cloud session (`CLAUDE_CODE_REMOTE=true`) only
1059
+ reads, in the same layout and with the same exit codes as on a Mac:
1060
+
1061
+ ```
1062
+ ◆ niyam doctor AGENT
1063
+ │
1064
+ ◇ This cloud session
1065
+ ✗ .github/niyam/cloud-setup.sh installs 0.5.24, but .github/workflows/niyam.yml pins v0.5.25 → niyam onboard again
1066
+ ✓ niyam 0.5.24 runs here
1067
+ ▲ /opt/niyam/from-setup missing, so the cloud environment's Setup script does not run .github/niyam/cloud-setup.sh → paste what niyam cloud-setup prints into the cloud environment's Setup script, once
1068
+ │
1069
+ ◇ GitHub — as AGENT
1070
+ ✓ the proxy acts as AGENT, an agent the repo's settings name
1071
+ ✓ session-start gave this session AGENT's identity
1072
+ │
1073
+ └ 2 to fix
1074
+ ```
1075
+
1076
+ This cloud session checks that `cloud-setup.sh` opens with the comment
1077
+ `onboard` writes, naming the release it installs, and that this release is
1078
+ the workflow's pin (`✗`, fixed by running `onboard` again; a workflow that pins no one version is `▲`), that the CLI running is that
1079
+ release (`▲`: `session-start` installs it, or `bash
1080
+ .github/niyam/cloud-setup.sh` does), and that the Setup script
1081
+ runs the repo's file (`▲` without `/opt/niyam/from-setup`),
1082
+ naming the file it ran: the mark holds its path. GitHub
1083
+ checks that the account the proxy acts as is one of the settings' agents,
1084
+ and that `session-start` gave the session that identity (`✗` otherwise:
1085
+ `gh` and git stay locked out). This repo lists hooks that reach GitHub
1086
+ outside `as-agent` and the Auto-fix rules missing, as on a Mac. It installs nothing; on Linux outside a
1087
+ cloud session, `doctor` still refuses.
1088
+
1089
+ ### Owner steps
1090
+
1091
+ Some GitHub changes only the owner's account can make: an organisation's
1092
+ issue types, the `approved` and `do-not-merge` labels (the auto-mode
1093
+ classifier keeps agents from changing them), and a ruleset's required checks.
1094
+ An agent that needs one asks the owner to run one command in their own
1095
+ terminal, never a script or a settings page:
1096
+
1097
+ ```bash
1098
+ niyam owner-step issue-types <org>
1099
+ niyam owner-step label <owner/repo> <number> <add|remove> <approved|do-not-merge>
1100
+ niyam owner-step required-checks <owner/repo> <ruleset id or name> [--check <name>]…
1101
+ ```
1102
+
1103
+ - `issue-types` adds the work model's issue types the organisation lacks and
1104
+ enables any that are disabled. It changes no other type and no issue; `onboard`
1105
+ does that.
1106
+ - `label` adds or removes `approved` or `do-not-merge` on an issue or pull
1107
+ request. It refuses a label the repository does not have.
1108
+ - `required-checks` makes the ruleset also require the checks of the features
1109
+ the repository's settings turn on, read from its default branch
1110
+ (`.github/niyam.json`): `niyam / PR identity` for `pr-identity`,
1111
+ `niyam / Work rules` for `work-rules` and `niyam / Design frames` for
1112
+ `figma`. It adds a check only when the repository's
1113
+ `.github/workflows/niyam.yml` has a `niyam` job, named `niyam`, calling
1114
+ shared checks that run that job, at the version it pins. A required check
1115
+ that never reports would hold every pull request, so any other check is a
1116
+ `✗` saying why. It keeps every other check and rule, removes none, and
1117
+ shows the before and after.
1118
+ - `required-checks --check <name>`, repeatable, also requires a check the
1119
+ repository runs itself, such as a job of its own CI. It adds one only
1120
+ when it reported `success` on the head commit of the last pull request
1121
+ merged into the default branch, from one app alone, and requires it from
1122
+ that app. That shows pull requests run it and it passes. One that never
1123
+ ran there, did not pass, or that two apps reported is a `✗`. A check a
1124
+ workflow runs only for some paths can pass there and then never report
1125
+ on a pull request that skips them, holding it: name only checks that run
1126
+ on every pull request.
1127
+
1128
+ It refuses in an agent session (`NIYAM_AGENT` set, or `CLAUDECODE=1`)
1129
+ and without a terminal. It makes a new folder in the user's temporary folder
1130
+ (`niyam-owner-step-…`; on macOS, `getconf DARWIN_USER_TEMP_DIR`) and runs gh
1131
+ with that folder as `GH_CONFIG_DIR`, `GH_PAGER=cat`, no `GH_TOKEN`, and
1132
+ git's global config pointed inside the folder. It then signs in with one
1133
+ browser approval of gh's device code: `gh auth login -h github.com -p https
1134
+ --skip-ssh-key -w -s <scope> --insecure-storage`. The scope is `admin:org`
1135
+ for issue types and `repo` for the others; gh always adds `repo`, `read:org`
1136
+ and `gist`. The token stays in that folder: never in the keychain, the
1137
+ owner's gh config, git's or SSH's settings, a command's arguments or the
1138
+ output. Every call goes through `gh api` there, and none is made unless the
1139
+ folder holds the token, so gh can never fall back to another login.
1140
+
1141
+ It checks that the signed-in login owns the organisation, or the repository
1142
+ (the user who owns it, or an owner of its organisation), and reads what is
1143
+ there. Then it prints exactly what it will change and asks for a yes; the
1144
+ sign-in and the reads change nothing. It makes each change, reads it back,
1145
+ and marks it `✓` or `✗`. Whatever happens, an error or Ctrl-C included, it
1146
+ tries to delete the folder, which holds the token's only copy, and marks that
1147
+ `✗`, with the `rm -rf` to run, when the delete fails. It does not run
1148
+ `gh auth logout`, which deletes gh's keychain entries for the host whatever
1149
+ `GH_CONFIG_DIR` says, and which cannot revoke the token anyway. The token
1150
+ stays valid on GitHub until it is revoked, so the command ends with the link
1151
+ to do that: https://github.com/settings/applications. Exit 0 when every change was made, or none
1152
+ was needed or wanted, and no check was skipped; 1 otherwise, a `required-checks`
1153
+ run that skipped a check included, even after a no; 130 after a Ctrl-C.
1154
+ `doctor` marks `▲` any owner-step folder left behind, which a killed run or a
1155
+ failed delete leaves, and says whether it still holds a token. A run going on
1156
+ now has one too, so delete it only when no owner-step is running. Each step lives here with tests; a new step
1157
+ is a slice the owner approves.
1158
+
1159
+ ### Releases and upgrading
1160
+
1161
+ Each release is a tag `vX.Y.Z` on `main`, matching `package.json`; the
1162
+ Release workflow checks both, runs `pnpm check` and publishes the GitHub
1163
+ release, attaching the CLI package it built and tested. From 0.6.16 the same
1164
+ package is on npm as `@veda-hq/niyam`, with provenance, for a repository that
1165
+ pins it as an exact version. Install the attached package on each machine with
1166
+ pnpm, once; nothing is built on install:
1167
+
1168
+ ```bash
1169
+ pnpm add -g https://github.com/veda-hq/niyam/releases/download/v0.6.16/veda-hq-niyam-0.6.16.tgz
1170
+ ```
1171
+
1172
+ The package puts one command on `PATH`, `niyam`. Since P-57 a release
1173
+ attaches nothing under the name before niyam, so a Mac that still has the
1174
+ package `@athya-hq/process-rules` (0.6.x) takes the line above. Remove the
1175
+ old package first, with `pnpm remove -g @athya-hq/process-rules`, so only
1176
+ one package puts commands on `PATH`.
1177
+
1178
+ After that, update it with one command on each machine:
1179
+
1180
+ ```bash
1181
+ niyam upgrade
1182
+ ```
1183
+
1184
+ `upgrade` asks GitHub's public releases API for the newest release, with no
1185
+ token and no sign-in, and when it is newer than the CLI running, installs it
1186
+ with the same `pnpm add -g`, printing old → new and the version the shell then
1187
+ runs. On the newest release it says so and installs nothing; it never moves
1188
+ back to an older one. When GitHub cannot be reached, or a newer release has no
1189
+ package attached yet, or pnpm fails, it says which and exits 1, checking
1190
+ nothing more. After an install, or when there was nothing to install, it walks
1191
+ `PATH`, as `type -a niyam` does, reading an empty or relative entry
1192
+ against the current folder as the shell does. It exits 0 when exactly one
1193
+ `niyam` is there and it is the newest release. When more than one is
1194
+ there, or the first is not that release, it lists each path and its version,
1195
+ marks pnpm's own copy to keep, names the others to remove, and exits 1, since
1196
+ an older copy the shell finds first is how a Mac keeps running an old release
1197
+ after an upgrade. It works in an agent session on a Mac too; in a Claude cloud
1198
+ session it refuses, because there the repo's `cloud-setup.sh` installs the
1199
+ release the workflow pins. A CLI from before `upgrade` has none: install the
1200
+ newest release with the line above. `onboard`, when the repo pins a newer release than the
1201
+ CLI running, refuses and says to run `niyam upgrade` first.
1202
+
1203
+ `onboard` pins the client's workflow to one version, the release of the CLI
1204
+ that ran it. Each job writes the pin twice, `checks.yml@vX.Y.Z` and, two lines
1205
+ below it under `with:`, `niyam-ref: vX.Y.Z`, the one input `checks.yml`
1206
+ declares; GitHub refuses a caller that passes an input the called workflow
1207
+ does not declare, `process-rules-ref` too since P-57. Every job of
1208
+ `checks.yml` runs the CLI from the commit it was called at (GitHub's
1209
+ `job.workflow_sha`), so the checks and the CLI are always one release; on
1210
+ GitHub Enterprise Server, which has no `job.workflow_sha`, the CLI comes from
1211
+ `niyam-ref`. Settings fails a run whose `niyam-ref` names
1212
+ another release, saying which and how to fix it: Dependabot and Renovate move
1213
+ a job's `uses:` line and nothing else, so their bump of niyam leaves
1214
+ the pair apart, and it also leaves out the cloud setup file's pin and any job a
1215
+ newer release adds. So leave `veda-hq/niyam` out of their updates (a
1216
+ Dependabot `ignore` entry, a Renovate `packageRules` entry with `enabled:
1217
+ false`). Upgrading is two steps: `niyam upgrade`, then `onboard` again,
1218
+ which moves every pin together. Editing the version by hand means changing
1219
+ every line that names it, two per job. A split workflow needs v0.5.4 or later: GitHub refuses a whole run, before
1220
+ any job's `if:`, when the called workflow asks for more than the calling job
1221
+ grants, and before v0.5.4 `checks.yml` asked for `issues: write` itself. The hooks run the
1222
+ launcher `machine` writes, else `niyam` from the `PATH`; without
1223
+ either the session-start hook tells the session to stop, and the guard refuses
1224
+ `gh` and `git`. Run `machine` again after removing the node it names.
1225
+
1226
+ ## Developing
1227
+
1228
+ Node 24 (`.nvmrc`) and pnpm.
1229
+
1230
+ ```bash
1231
+ pnpm install
1232
+ pnpm check
1233
+ ```
1234
+
1235
+ `pnpm check` typechecks, runs the tests with a coverage floor (95% lines and
1236
+ functions, 90% branches), builds `dist/` and runs it. `pnpm scan:secrets` runs
1237
+ Gitleaks and TruffleHog over the working tree; CI runs both over the whole
1238
+ history.
1239
+
1240
+ ## License
1241
+
1242
+ MIT
1243
+
1244
+ ## Renamed from process-rules
1245
+
1246
+ process-rules became niyam in the release after 0.6.3, in steps (docs/decisions.md,
1247
+ P-49, P-50 and P-53 to P-57). P-49 renamed the repository, the package, the command and
1248
+ the messages; P-50 the keychain service and the settings file; P-53 the hooks and
1249
+ the checks; P-54 dropped the `process-rules` command; P-55 moved this Mac's files to
1250
+ `~/.config/niyam/` and the agent variable to `NIYAM_AGENT`; P-56 renamed what
1251
+ `onboard` writes in a repository (the workflow, its job ids, `niyam-ref`, the cloud
1252
+ setup file and the onboard branch). Each of those still read the old names beside
1253
+ the new ones. P-57, for a release cut once every repository and this Mac have
1254
+ moved, ends that: no release uses a `process-rules` name to read settings,
1255
+ tokens, files or checks, or writes one; what is left is in the table below.
1256
+
1257
+ What P-57 removed for good, by hand where it is on a machine:
1258
+
1259
+ - `niyam machine` removes `~/.config/process-rules/`, launcher and all, once the
1260
+ new folder is written, and deletes the keychain entry under the service
1261
+ `process-rules` once it has read back that the `niyam` entry holds the same
1262
+ token; when they differ, or the read fails, it leaves the entry and says why,
1263
+ with the `security delete-generic-password` line to run once nothing needs it.
1264
+ `doctor` marks either one still there ▲.
1265
+ - `niyam onboard` deletes `.github/process-rules/cloud-setup.sh` wherever it
1266
+ leaves `.github/niyam/cloud-setup.sh`, and writes and runs none under that
1267
+ name; a Setup snippet pasted before 0.6.10 needs the new one pasted once.
1268
+ - `niyam owner-step required-checks` takes each `process-rules / …` check out of
1269
+ a ruleset: no workflow reports one since P-53, so it would hold every pull
1270
+ request. The `niyam / …` check of the same job takes its place where the
1271
+ workflow runs that job.
1272
+ - Releases no longer attach the bridge archive `athya-hq-process-rules-<version>.tgz`,
1273
+ and `upgrade` asks veda-hq/niyam alone: a Mac still on `@athya-hq/process-rules`
1274
+ installs niyam with the `pnpm add -g` line in Releases and upgrading.
1275
+
1276
+ What still says process-rules, and why:
1277
+
1278
+ | What | Why it stays |
1279
+ | ---- | ------------ |
1280
+ | The reviews' reader for `<!-- process-rules vetted sha256:… -->` marks | data in decisions already vetted: dropping it would un-vet them |
1281
+ | The hook texts of releases before P-57, in `onboard`'s `OLDER_` lists | data compared against, so `onboard` replaces an older hook in place; nothing runs them |
1282
+ | 0.6.10's session file, which `sessionFileIs` still takes as an older one | `session-start` and `as-agent` use it, so a session started before `machine` runs again is not locked out, until `machine` rewrites it; its token read falls back to the keychain service `process-rules`, and it sets `PROCESS_RULES_AGENT`, which `as-agent` keeps from the commands it runs |
1283
+ | `~/.config/process-rules/` and the keychain service `process-rules` | `machine` removes them; `doctor` reports them while they are there |
1284
+ | `.github/process-rules/cloud-setup.sh` | `onboard` deletes it wherever it leaves `.github/niyam/cloud-setup.sh` |
1285
+ | `/usr/local/bin/process-rules` in a cloud environment, a launcher that runs `process-rules`, a required `process-rules / …` check | named only to remove them: the cloud setup file removes the first, `doctor` marks the second ✗ (fixed by `niyam machine`), `owner-step required-checks` takes the third out |
1286
+ | GitHub's redirect from athya-hq/process-rules | GitHub's, not niyam's |
1287
+ | The titles of tokens and signing keys made before P-56 | on GitHub already; nothing reads them (the closed Projects once titled "process-rules work" are now "niyam work (old)") |
1288
+ | The history in docs/decisions.md and docs/roadmap.md | a record of what was decided then |