@veda-hq/niyam 0.7.4 → 0.7.6

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
@@ -290,9 +290,10 @@ niyam (`~/.config/process-rules/`, or a keychain entry under the service
290
290
  `process-rules`: `▲`, which `niyam machine` removes), and
291
291
  what of the owner's an agent session could reach, any `owner-step` folder
292
292
  left behind (`▲`, saying whether it still holds a token; see Owner steps), and, in a repository with
293
- the board on, the organisation's issue types (see Issue types), and, in one with
294
- `work-rules` on, the shared Guard's caller (`✗` when it is missing or not as
295
- `onboard` writes it at `niyam.yml`'s release; see The shared Guard). It shows them grouped as
293
+ the board on, the organisation's issue types (see Issue types), and, in every
294
+ onboarded repository, the shared Guard's caller (`✗` when it is missing or not
295
+ as `onboard` writes it at `niyam.yml`'s release, or, with identity alone and so
296
+ no `niyam.yml`, at any release; see The shared Guard). It shows them grouped as
296
297
  This Mac, GitHub and This repo, one line each: `✓` fine, `▲` worth fixing,
297
298
  `✗` broken. Each problem line ends with its fix:
298
299
 
@@ -452,8 +453,8 @@ on any platform without a token store, `niyam env` prints the lock alone.
452
453
  on pull requests and pushes, read-only, and `niyam-weekly` on the
453
454
  weekly run, the only one that writes to issues. Each job carries a
454
455
  `name:` (`niyam`, `niyam-weekly`, …), so its checks read
455
- `niyam / Work rules`. With identity alone `onboard` writes no workflow.
456
- With `work-rules` on it also writes `.github/workflows/niyam-guard.yml`,
456
+ `niyam / Work rules`. With identity alone `onboard` writes no `niyam.yml`.
457
+ Whatever the features, it also writes `.github/workflows/niyam-guard.yml`,
457
458
  the shared Guard's caller (see The shared Guard below): run by
458
459
  `pull_request_target` on pull requests to the default branch, read-only,
459
460
  its one job `niyam-guard` only calling
@@ -1214,7 +1215,7 @@ client's own and stays as it is); any other workflow is offered a replacement. M
1214
1215
  features a client has turned on required on its default branch, such as
1215
1216
  `niyam / PR identity` with `pr-identity` and `niyam / Work rules` with
1216
1217
  `work-rules`; a check of a feature that is off still runs and passes, but with
1217
- identity alone there is no workflow at all, so require none.
1218
+ identity alone there is no `niyam.yml`, so require none of its checks.
1218
1219
 
1219
1220
  ### One feature at a time
1220
1221
 
@@ -1726,7 +1727,7 @@ tag and the commit. Install the attached package on each machine with pnpm,
1726
1727
  once; nothing is built on install:
1727
1728
 
1728
1729
  ```bash
1729
- pnpm add -g https://github.com/veda-hq/niyam/releases/download/v0.7.4/veda-hq-niyam-0.7.4.tgz
1730
+ pnpm add -g https://github.com/veda-hq/niyam/releases/download/v0.7.6/veda-hq-niyam-0.7.6.tgz
1730
1731
  ```
1731
1732
 
1732
1733
  The package puts one command on `PATH`, `niyam`. Since P-57 a release
@@ -1812,11 +1813,14 @@ which fails the lint until `pnpm lint --prune-suppressions` drops it.
1812
1813
 
1813
1814
  ### Guard
1814
1815
 
1815
- The `guard` workflow (`.github/workflows/guard.yml`) runs on
1816
- `pull_request_target`, so GitHub runs it from `main`'s copy, never the pull
1817
- request's. Its job, `Guard`, checks out `main` alone, reads the pull
1818
- request's changed files from GitHub's API as data, and runs
1819
- `scripts/guard.mjs` (tested in `scripts/guard.test.mjs`). A change to a guard
1816
+ niyam runs the shared Guard (below) as every client does, through the caller
1817
+ `onboard` writes, `.github/workflows/niyam-guard.yml`, at the release
1818
+ `niyam.yml` pins; its check is `niyam-guard / judge` (#472). It runs on
1819
+ `pull_request_target`, so GitHub runs `main`'s copy of the caller, never the
1820
+ pull request's, and the Guard it calls runs from that release: a fix to
1821
+ `scripts/guard.mjs` (tested in `scripts/guard.test.mjs`) holds niyam's own
1822
+ pull requests once it is released. It reads the pull request's changed files
1823
+ from GitHub's API as data and never checks out its code. A change to a guard
1820
1824
  file passes only when the pull request's slice names it in a `**Guards:**`
1821
1825
  section, one already in the slice when the owner put `approved` on its Work
1822
1826
  item (for a slice added later, when the owner's `Decision:` settled it):
@@ -1837,13 +1841,22 @@ is a guard change too. A test file needs naming too when a pull request
1837
1841
  deletes it, leaves it fewer `test(`/`it(` calls than the merge base, or adds
1838
1842
  `.skip`, `.only` or `todo`.
1839
1843
 
1844
+ A repository whose `.github/niyam.json` turns `work-rules` off has no Work
1845
+ items, so no slice to name a change: the shared Guard judges no slice there,
1846
+ and its log lists each change it would have asked one to name. It still
1847
+ refuses what no slice passes: a job added under the name of a check the
1848
+ ruleset requires, a job that could report `niyam-guard / judge` but is not
1849
+ the caller `onboard` writes, and a pull request with more files than GitHub
1850
+ lists. With `work-rules` on, or no `features` listed, it judges every change;
1851
+ a `features` it cannot read refuses.
1852
+
1840
1853
  Two changes pass unnamed: an onboard pull request
1841
1854
  (`chore(niyam): onboard at vX.Y.Z`) whose every changed line only moves the
1842
1855
  niyam version, and a sha256 with it, to that release, tagged on
1843
1856
  `veda-hq/niyam`'s `main`; and a Dependabot pull request whose every changed
1844
1857
  line only moves a `uses:` to another full commit sha with its version
1845
1858
  comment. Whatever the slice says, Guard refuses a pull request that adds a
1846
- job reporting a check the default branch's ruleset requires, or `Guard`, and any job
1859
+ job reporting a check the default branch's ruleset requires, and any job
1847
1860
  that could report the shared Guard's check, `niyam-guard / judge`, other than
1848
1861
  its caller as `onboard` writes it. It fails closed: a truncated file list,
1849
1862
  settings it cannot read, any read GitHub does not answer, or an event other
@@ -1861,7 +1874,7 @@ from a workflow run by `pull_request_target` alone, whose one job,
1861
1874
  a full commit sha, never a branch), read-only, with no inputs or secrets; its
1862
1875
  check is `niyam-guard / judge`. The default branch is the repository's own,
1863
1876
  whatever its name. `niyam onboard` writes that caller,
1864
- `.github/workflows/niyam-guard.yml`, in a repository with `work-rules` on,
1877
+ `.github/workflows/niyam-guard.yml`, in every repository it onboards,
1865
1878
  on pull requests to its default branch and at the release `niyam.yml` pins,
1866
1879
  and moves its pin with the rest on every run; `niyam doctor` marks it under
1867
1880
  "This repo", ✗ when it is missing or differs from what `onboard` writes in
@@ -1871,7 +1884,7 @@ Actions, Policies allows it for that workflow, so `onboard` names that step
1871
1884
  there.
1872
1885
 
1873
1886
  Guard cannot judge a change to its own rules, so `.github/CODEOWNERS` names
1874
- `@AlokBansal8` for the guard's files alone: `.github/workflows/guard.yml`,
1887
+ `@AlokBansal8` for the guard's files alone: the caller `.github/workflows/niyam-guard.yml`,
1875
1888
  `.github/workflows/shared-guard.yml`, `scripts/guard.mjs`, `scripts/guard.test.mjs` and `.github/CODEOWNERS`
1876
1889
  itself. With "Require review from Code Owners" on in the `main` ruleset, a
1877
1890
  pull request that changes one of them waits for his approval. Every other
package/dist/doctor.js CHANGED
@@ -2,8 +2,8 @@ import { EXPIRY_WARNING_DAYS, SETTINGS_PATH, account, agentFrom, agentIn, anyLog
2
2
  import { LOCKED, clientHooks, hooksHittingLock } from './as-agent.js';
3
3
  import { FROM_SETUP, SIGNING_KEY_VAR, cloudLogin, fileFromSetup, ranFromSetup, repoReleases } from './cloud.js';
4
4
  import { GITHUB_NOREPLY } from './host.js';
5
- import { featuresIn, isOn } from './features.js';
6
- import { callerAt, callerIsOnboards, callerWanted, pushBranch } from './guard-caller.js';
5
+ import { featuresIn } from './features.js';
6
+ import { callerAt, callerIsOnboards, pushBranch } from './guard-caller.js';
7
7
  import { typesDrift } from './issue-types.js';
8
8
  import { closing, findingLines, heading, painter, tilde } from './layout.js';
9
9
  import { exposure, exposureFindings, movedFindings, readDeclined, setAside } from './lockout.js';
@@ -224,51 +224,50 @@ async function repoFindings(sys) {
224
224
  }
225
225
  /**
226
226
  * Whether the shared Guard's caller is as onboard writes it, pinned with the
227
- * rest: checked in an onboarded repo whose settings have onboard write it
228
- * (`callerWanted`) and whose niyam.yml is there. Offline, so the caller's
229
- * branch is checked against the one niyam.yml's pushes run on, which onboard
230
- * keeps at the default branch; its release against the one niyam.yml pins.
227
+ * rest: checked in every onboarded repo, since onboard writes it in every one
228
+ * (#485). Offline, so the caller's branch is checked against the one
229
+ * niyam.yml's pushes run on, which onboard keeps at the default branch; its
230
+ * release against the one niyam.yml pins. A repo with no niyam.yml has
231
+ * neither to check against, so only the caller's shape is checked there.
231
232
  */
232
233
  async function callerFindings(sys) {
233
234
  let root;
234
- let wanted;
235
235
  try {
236
236
  root = repoRoot(sys);
237
- if (!hasSettings(sys, root) || !sys.exists(`${root}/${WORKFLOW_PATH}`))
237
+ if (!hasSettings(sys, root))
238
238
  return [];
239
- const here = root;
240
- wanted = callerWanted((feature) => isOn(sys, here, feature));
241
239
  }
242
240
  catch {
243
241
  // fail-open: outside a clone, or settings doctor cannot read, there is no caller to check; onboard says what is wrong with them.
244
242
  return [];
245
243
  }
246
- if (!wanted)
247
- return [];
248
244
  const file = `${root}/${GUARD_CALLER_PATH}`;
249
245
  if (!sys.exists(file))
250
246
  return [{ mark: '✗', text: `${GUARD_CALLER_PATH} missing, so the shared Guard does not run here`, fix: ONBOARD }];
251
- const { pinned } = repoReleases(sys, root);
252
- if (pinned === undefined) {
253
- return [{ mark: '▲', text: `${WORKFLOW_PATH} pins no one version, so ${GUARD_CALLER_PATH} is not checked against it`, fix: ONBOARD }];
254
- }
247
+ const workflowFile = `${root}/${WORKFLOW_PATH}`;
255
248
  let workflow;
256
249
  let text;
257
250
  try {
258
- workflow = sys.read(`${root}/${WORKFLOW_PATH}`);
251
+ workflow = sys.exists(workflowFile) ? sys.read(workflowFile) : undefined;
259
252
  text = sys.read(file);
260
253
  }
261
254
  catch (error) {
262
255
  // fail-open: a file doctor cannot read is marked ✗, naming why, and the rest of the report still runs.
263
256
  return [{ mark: '✗', text: `${GUARD_CALLER_PATH} not checked: ${message(error)}`, fix: 'make the workflow and its caller readable' }];
264
257
  }
265
- const branch = await pushBranch(workflow);
266
258
  const at = await callerAt(text);
267
259
  if (at === undefined) {
268
260
  // onboard writes its own file again, but leaves one it did not write to the repository.
269
261
  const fix = (await callerIsOnboards(text)) ? ONBOARD : `rename or delete it, then ${ONBOARD}`;
270
262
  return [{ mark: '✗', text: `${GUARD_CALLER_PATH} is not the caller onboard writes: another trigger, branch, permission, job, with:, secrets: or steps`, fix }];
271
263
  }
264
+ if (workflow === undefined)
265
+ return [{ mark: '✓', text: `${GUARD_CALLER_PATH} calls the shared Guard at v${at.version}, as onboard writes it` }];
266
+ const { pinned } = repoReleases(sys, root);
267
+ if (pinned === undefined) {
268
+ return [{ mark: '▲', text: `${WORKFLOW_PATH} pins no one version, so ${GUARD_CALLER_PATH} is not checked against it`, fix: ONBOARD }];
269
+ }
270
+ const branch = await pushBranch(workflow);
272
271
  if (at.version !== pinned)
273
272
  return [{ mark: '✗', text: `${GUARD_CALLER_PATH} calls the shared Guard at v${at.version}, but ${WORKFLOW_PATH} pins v${pinned}`, fix: ONBOARD }];
274
273
  // A push trigger of several branches, which onboard leaves as the client has it, says no one branch: the rest is still checked.
@@ -13,16 +13,6 @@ export const SHARED_GUARD = `${PRODUCT}/.github/workflows/shared-guard.yml`;
13
13
  export const CALLER_JOB = `${CLI}-guard`;
14
14
  /** The check the caller reports, the same in every client and in niyam. */
15
15
  export const CALLER_CHECK = `${CALLER_JOB} / judge`;
16
- /**
17
- * Whether onboard writes the caller, and doctor checks it, for a repository
18
- * whose settings turn on what `on` says: with work rules alone, since the
19
- * Guard refuses a change to a guard file, this one included, that no
20
- * approved Work item's slice names, and only a repository with work rules
21
- * has those. The one place that decides it (docs/decisions.md, 2026-11-19).
22
- */
23
- export function callerWanted(on) {
24
- return on('work-rules');
25
- }
26
16
  /** How the caller's header starts: a file that starts so is onboard's, which onboard writes again whatever it holds. */
27
17
  const CALLER_MARK = `# Written by ${CLI} onboard: the shared Guard's caller.`;
28
18
  /**
package/dist/onboard.js CHANGED
@@ -11,7 +11,7 @@ import { routineTrace } from './reviews.js';
11
11
  import { DEFAULT_SCHEDULE, FEATURES, FIGMA_FILE_KEY, NEEDS_ISSUE_TYPES, featuresIn, parseFeatures, renamedLines, scheduleIn } from './features.js';
12
12
  import { CLOUD_SETUP_PATH, HOOKS_PATH, LEFTOVER_CLOUD_SETUP_PATH, ONBOARD_BRANCH, SARATHI_PATH, WORKFLOW_PATH, autoMerge, mergeQueue, openPull, remoteFile, } from './onboard-pull.js';
13
13
  import { SIGNING_KEY_VAR, cloudRepoScript, cloudScriptVersion, releaseSha256 } from './cloud.js';
14
- import { GUARD_CALLER_PATH, callerAt, callerIsOnboards, callerPins, callerDetail, callerUpdate, callerWanted, callerWhat, policySteps } from './guard-caller.js';
14
+ import { GUARD_CALLER_PATH, callerAt, callerIsOnboards, callerPins, callerDetail, callerUpdate, callerWhat, policySteps } from './guard-caller.js';
15
15
  import { CLOUD_KEY_TITLE, cloudKeyRefusal, listedKeys, makeCloudKey, pasteLines } from './cloud-key.js';
16
16
  import { newKey, publicLine } from './sshsig.js';
17
17
  import { detail } from './doc-numbers.js';
@@ -1178,8 +1178,8 @@ function planHead(paint, head) {
1178
1178
  * Sets up the client repository the working directory is in, run by its
1179
1179
  * owner on a Mac `machine` has set up for the agent. It first works out
1180
1180
  * everything it would change, changing nothing: the settings file, the
1181
- * Claude Code settings, the workflow, the shared Guard's caller (with work
1182
- * rules on) and the cloud setup file, opened as the agent's pull request
1181
+ * Claude Code settings, the workflow, the shared Guard's caller and the
1182
+ * cloud setup file, opened as the agent's pull request
1183
1183
  * so the owner's checkout is never modified; the agent's push access; the
1184
1184
  * work board (issue types, labels, Project, fields and views); the pre-push
1185
1185
  * hook; and one signed test commit GitHub must show as Verified by the
@@ -1425,10 +1425,10 @@ export async function onboard(sys, io, args = []) {
1425
1425
  }
1426
1426
  const on = (feature) => features.includes(feature);
1427
1427
  const workflowNeeded = on('pr-identity') || on('board') || on('work-rules') || on('figma') || on('decisions') || on('review');
1428
- // The shared Guard's caller (#470). onboard's own, edited by hand or not, is written again; a file of that name
1429
- // onboard did not write is the repository's own: refused before any plan, so nothing changes.
1430
- const callerNeeded = callerWanted(on);
1431
- const callerBefore = callerNeeded ? fileAt(GUARD_CALLER_PATH) : undefined;
1428
+ // The shared Guard's caller (#470), in every repository whatever its features (#485). onboard's own, edited by
1429
+ // hand or not, is written again; a file of that name onboard did not write is the repository's own: refused
1430
+ // before any plan, so nothing changes.
1431
+ const callerBefore = fileAt(GUARD_CALLER_PATH);
1432
1432
  const callerHad = callerBefore === undefined ? undefined : await callerAt(callerBefore);
1433
1433
  if (callerBefore !== undefined && !(await callerIsOnboards(callerBefore))) {
1434
1434
  io.err(`onboard: ${GUARD_CALLER_PATH} is not the shared Guard's caller as onboard writes it, and onboard does not overwrite a workflow of the repository's own; nothing changed. Rename or delete it, then run onboard again.`);
@@ -1569,12 +1569,10 @@ export async function onboard(sys, io, args = []) {
1569
1569
  if (update.kind !== 'same')
1570
1570
  change(GUARD_CALLER_PATH, update.text, callerWhat(update, version, branch));
1571
1571
  };
1572
- if (callerNeeded) {
1573
- const update = planned === undefined ? undefined : callerUpdate(callerBefore, callerHad, planned, version);
1574
- const detail = update === undefined ? (callerBefore === undefined ? `new, the shared Guard at v${version}` : 'write or update') : update.kind === 'same' ? undefined : callerDetail(update, version);
1575
- if (detail !== undefined)
1576
- pull.push({ label: 'guard caller', detail });
1577
- }
1572
+ const callerUpdated = planned === undefined ? undefined : callerUpdate(callerBefore, callerHad, planned, version);
1573
+ const callerPlan = callerUpdated === undefined ? (callerBefore === undefined ? `new, the shared Guard at v${version}` : 'write or update') : callerUpdated.kind === 'same' ? undefined : callerDetail(callerUpdated, version);
1574
+ if (callerPlan !== undefined)
1575
+ pull.push({ label: 'guard caller', detail: callerPlan });
1578
1576
  if (on('board')) {
1579
1577
  github.push({ label: 'board', detail: 'set up or check' });
1580
1578
  let approved;
@@ -1747,14 +1745,12 @@ export async function onboard(sys, io, args = []) {
1747
1745
  return false;
1748
1746
  if (workflowNeeded)
1749
1747
  workflowFor(reach.branch);
1750
- if (callerNeeded) {
1751
- callerFor(reach.branch);
1752
- // From 2026-12-02 GitHub runs pull_request_target in a public repository only where a policy allows it.
1753
- if (reach.public) {
1754
- const policy = policySteps(slug);
1755
- byHand.push(policy.byHand);
1756
- later.push(policy.later);
1757
- }
1748
+ callerFor(reach.branch);
1749
+ // From 2026-12-02 GitHub runs pull_request_target in a public repository only where a policy allows it.
1750
+ if (reach.public) {
1751
+ const policy = policySteps(slug);
1752
+ byHand.push(policy.byHand);
1753
+ later.push(policy.later);
1758
1754
  }
1759
1755
  // From the workflow the pull request leaves, worked out only now that GitHub has said the branch.
1760
1756
  const text = fileAt(WORKFLOW_PATH);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veda-hq/niyam",
3
- "version": "0.7.4",
3
+ "version": "0.7.6",
4
4
  "description": "Work rules for repos that track work in GitHub Issues: setup, agent identity, push and PR checks.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -28,7 +28,7 @@
28
28
  "@types/node": "24.19.2",
29
29
  "@veda-hq/dvara": "0.5.16",
30
30
  "@veda-hq/pariksha": "0.5.20",
31
- "@veda-hq/sarathi": "0.7.1",
31
+ "@veda-hq/sarathi": "0.7.8",
32
32
  "typescript": "7.0.2"
33
33
  },
34
34
  "dependencies": {