@veda-hq/niyam 0.7.4 → 0.7.5
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 +18 -8
- package/dist/doctor.js +17 -18
- package/dist/guard-caller.js +0 -10
- package/dist/onboard.js +15 -19
- package/package.json +1 -1
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
|
|
294
|
-
|
|
295
|
-
`onboard` writes it at `niyam.yml`'s release
|
|
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
|
|
456
|
-
|
|
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
|
|
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.
|
|
1730
|
+
pnpm add -g https://github.com/veda-hq/niyam/releases/download/v0.7.5/veda-hq-niyam-0.7.5.tgz
|
|
1730
1731
|
```
|
|
1731
1732
|
|
|
1732
1733
|
The package puts one command on `PATH`, `niyam`. Since P-57 a release
|
|
@@ -1837,6 +1838,15 @@ is a guard change too. A test file needs naming too when a pull request
|
|
|
1837
1838
|
deletes it, leaves it fewer `test(`/`it(` calls than the merge base, or adds
|
|
1838
1839
|
`.skip`, `.only` or `todo`.
|
|
1839
1840
|
|
|
1841
|
+
A repository whose `.github/niyam.json` turns `work-rules` off has no Work
|
|
1842
|
+
items, so no slice to name a change: the shared Guard judges no slice there,
|
|
1843
|
+
and its log lists each change it would have asked one to name. It still
|
|
1844
|
+
refuses what no slice passes: a job added under the name of a check the
|
|
1845
|
+
ruleset requires, a job that could report `niyam-guard / judge` but is not
|
|
1846
|
+
the caller `onboard` writes, and a pull request with more files than GitHub
|
|
1847
|
+
lists. With `work-rules` on, or no `features` listed, it judges every change;
|
|
1848
|
+
a `features` it cannot read refuses.
|
|
1849
|
+
|
|
1840
1850
|
Two changes pass unnamed: an onboard pull request
|
|
1841
1851
|
(`chore(niyam): onboard at vX.Y.Z`) whose every changed line only moves the
|
|
1842
1852
|
niyam version, and a sha256 with it, to that release, tagged on
|
|
@@ -1861,7 +1871,7 @@ from a workflow run by `pull_request_target` alone, whose one job,
|
|
|
1861
1871
|
a full commit sha, never a branch), read-only, with no inputs or secrets; its
|
|
1862
1872
|
check is `niyam-guard / judge`. The default branch is the repository's own,
|
|
1863
1873
|
whatever its name. `niyam onboard` writes that caller,
|
|
1864
|
-
`.github/workflows/niyam-guard.yml`, in
|
|
1874
|
+
`.github/workflows/niyam-guard.yml`, in every repository it onboards,
|
|
1865
1875
|
on pull requests to its default branch and at the release `niyam.yml` pins,
|
|
1866
1876
|
and moves its pin with the rest on every run; `niyam doctor` marks it under
|
|
1867
1877
|
"This repo", ✗ when it is missing or differs from what `onboard` writes in
|
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
|
|
6
|
-
import { callerAt, callerIsOnboards,
|
|
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
|
|
228
|
-
* (
|
|
229
|
-
*
|
|
230
|
-
*
|
|
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)
|
|
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
|
|
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(
|
|
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.
|
package/dist/guard-caller.js
CHANGED
|
@@ -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,
|
|
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';
|
|
@@ -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
|
|
1429
|
-
// onboard did not write is the repository's own: refused
|
|
1430
|
-
|
|
1431
|
-
const callerBefore =
|
|
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
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
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
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
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);
|