@veda-hq/niyam 0.7.1 → 0.7.3
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 +21 -6
- package/dist/board.js +10 -5
- package/dist/onboard.js +12 -3
- package/dist/reviews.js +48 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -420,7 +420,8 @@ on any platform without a token store, `niyam env` prints the lock alone.
|
|
|
420
420
|
│ 1. Once for owner/repo: in Claude Code, run /schedule and create a
|
|
421
421
|
│ weekly routine on it, with claude.ai's GitHub connected as AGENT and
|
|
422
422
|
│ the prompt below the line in
|
|
423
|
-
│ https://github.com/veda-hq/niyam/blob/v0.6.15/routines/review.md
|
|
423
|
+
│ https://github.com/veda-hq/niyam/blob/v0.6.15/routines/review.md; skip
|
|
424
|
+
│ it if done.
|
|
424
425
|
│
|
|
425
426
|
│ 2. Once per claude.ai account: sign in at https://claude.ai/code and
|
|
426
427
|
│ connect GitHub as AGENT (or change it at
|
|
@@ -659,9 +660,16 @@ A board it cannot read, or a move GitHub refuses, is said and does not stop
|
|
|
659
660
|
the push; a push for a closed slice, such as a fix, moves nothing. A Claude
|
|
660
661
|
cloud session's GitHub proxy lets through only `repos/{owner}/{repo}/…`, so
|
|
661
662
|
its push never reaches an organization's Projects and says only that the
|
|
662
|
-
workflow moves the slice.
|
|
663
|
-
|
|
664
|
-
the same conditions, with a token from the board GitHub App.
|
|
663
|
+
workflow moves the slice. Once Work rules passes for a pull request from the
|
|
664
|
+
repository, the shared workflow's Slice started job makes the same moves,
|
|
665
|
+
under the same conditions, with a token from the board GitHub App. It runs
|
|
666
|
+
after Work rules on every event Work rules runs on (the pull request opening
|
|
667
|
+
or reopening, a push to it, an edit of it) and again when a failed Work rules
|
|
668
|
+
is re-run, so a slice that could not be built when its pull request opened
|
|
669
|
+
moves once it can. A slice and work item already where they belong are not
|
|
670
|
+
written again. A slice no open Project holds gets a line saying it is not
|
|
671
|
+
on the board, and one on a Project whose Status has no In Progress option
|
|
672
|
+
gets a line naming that Project. The client's
|
|
665
673
|
workflow passes it the app's client id and private key as the
|
|
666
674
|
`NIYAM_BOARD_APP_ID` and `NIYAM_BOARD_APP_KEY` secrets. With `board` on,
|
|
667
675
|
onboard writes them under the `niyam` job's secrets, the pull request job
|
|
@@ -1130,7 +1138,14 @@ or `/schedule`), with claude.ai's GitHub connected as the agent, and the
|
|
|
1130
1138
|
prompt from `routines/review.md` at the release in use. It cannot create the
|
|
1131
1139
|
routine itself: Claude's routines API answers only a Claude Code session's own
|
|
1132
1140
|
sign-in, not a command, and a routine works as claude.ai's GitHub connection,
|
|
1133
|
-
which no API names.
|
|
1141
|
+
which no API names. It takes the routine's trace as evidence it runs instead:
|
|
1142
|
+
once the agent has commented `Kept:`, `Settled:` or `Held for` on any issue of
|
|
1143
|
+
the repository in the last three weeks (onboard reads up to 1,000 of its
|
|
1144
|
+
newest comments, as the agent), the routine leaves "By hand" and the pull
|
|
1145
|
+
request names the verdict it found under "Done at the terminal". Any such
|
|
1146
|
+
comment by the agent counts, one from a session run by hand included. Where no
|
|
1147
|
+
verdict is found in those three weeks, or GitHub does not list the comments,
|
|
1148
|
+
the step stays, ending "skip it if done".
|
|
1134
1149
|
|
|
1135
1150
|
`onboard` also writes a pre-push git hook running `niyam pre-push`,
|
|
1136
1151
|
for every adopter. In a local agent session (one session-start set up, or
|
|
@@ -1663,7 +1678,7 @@ tag and the commit. Install the attached package on each machine with pnpm,
|
|
|
1663
1678
|
once; nothing is built on install:
|
|
1664
1679
|
|
|
1665
1680
|
```bash
|
|
1666
|
-
pnpm add -g https://github.com/veda-hq/niyam/releases/download/v0.7.
|
|
1681
|
+
pnpm add -g https://github.com/veda-hq/niyam/releases/download/v0.7.3/veda-hq-niyam-0.7.3.tgz
|
|
1667
1682
|
```
|
|
1668
1683
|
|
|
1669
1684
|
The package puts one command on `PATH`, `niyam`. Since P-57 a release
|
package/dist/board.js
CHANGED
|
@@ -631,11 +631,16 @@ export async function boardStarted(sys, token, slug, slice) {
|
|
|
631
631
|
const parent = status === 200 && json?.type?.name === 'Work item' ? json.number : undefined;
|
|
632
632
|
const items = await projectItems(sys, token, slug);
|
|
633
633
|
const steps = stepMoves(items.step, parent);
|
|
634
|
-
const
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
634
|
+
const held = items.status.filter((item) => item.number === slice);
|
|
635
|
+
const movable = held.filter((item) => optionOf(item.field, 'In Progress'));
|
|
636
|
+
const moved = await move(sys, token, [...movable.map((item) => ({ item, option: 'In Progress', name: `slice #${slice}`, what: `slice #${slice} is In Progress` })), ...steps.moves]);
|
|
637
|
+
// A slice on no Project, or on one whose Status cannot take it, has nothing to move: say so, rather than let "nothing moved" read as "in place".
|
|
638
|
+
const missing = held.length === 0
|
|
639
|
+
? [`! board: slice #${slice} is not on the board: no open Project of ${slug.split('/')[0]} with a Status field holds it unarchived, so it did not move to In Progress`]
|
|
640
|
+
: held
|
|
641
|
+
.filter((item) => !movable.includes(item))
|
|
642
|
+
.map((item) => `! board: Status in "${item.project}" has no option In Progress, so slice #${slice} stays where it is; add the option to the Project's Status field`);
|
|
643
|
+
return [...moved, ...missing, ...steps.lacking];
|
|
639
644
|
}
|
|
640
645
|
function stopped(io, step) {
|
|
641
646
|
io.err(`onboard: stopped at "${step}"; nothing after it was changed, and no pull request was opened`);
|
package/dist/onboard.js
CHANGED
|
@@ -7,6 +7,7 @@ import { typesDetail, typesLines, typesPlan } from './issue-types.js';
|
|
|
7
7
|
import { asOwner, isOrganisation, ownerScopes, signInOnce } from './owner-login.js';
|
|
8
8
|
import { appendToArray, removeElements, replaceValues, setMember } from './jsonedit.js';
|
|
9
9
|
import { HOURLY } from './asks.js';
|
|
10
|
+
import { routineTrace } from './reviews.js';
|
|
10
11
|
import { DEFAULT_SCHEDULE, FEATURES, FIGMA_FILE_KEY, NEEDS_ISSUE_TYPES, featuresIn, parseFeatures, renamedLines, scheduleIn } from './features.js';
|
|
11
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';
|
|
12
13
|
import { SIGNING_KEY_VAR, cloudRepoScript, cloudScriptVersion, releaseSha256 } from './cloud.js';
|
|
@@ -1605,11 +1606,19 @@ export async function onboard(sys, io, args = []) {
|
|
|
1605
1606
|
},
|
|
1606
1607
|
});
|
|
1607
1608
|
// Claude's routines API answers only a Claude Code session's own sign-in, and a routine works as claude.ai's GitHub
|
|
1608
|
-
// connection, so onboard cannot create one or check it.
|
|
1609
|
+
// connection, so onboard cannot create one or check it; it sees one runs by the agent's verdicts on the repository.
|
|
1609
1610
|
if (on('review')) {
|
|
1610
1611
|
const routine = `${GITHUB_WEB}/${PRODUCT}/blob/v${version}/routines/review.md`;
|
|
1611
|
-
|
|
1612
|
-
|
|
1612
|
+
const seen = await routineTrace(sys, slug, agent, token).catch(() => {
|
|
1613
|
+
// fail-open: comments GitHub does not give leave the routine by hand, which the owner skips if done.
|
|
1614
|
+
return undefined;
|
|
1615
|
+
});
|
|
1616
|
+
if (seen)
|
|
1617
|
+
notes.push(`- review routine: ${agent} gave a verdict on #${seen.number} on ${seen.date}, so it runs`);
|
|
1618
|
+
else {
|
|
1619
|
+
byHand.push(`Once for ${slug}: in Claude Code, run /schedule and create a weekly routine on it, with claude.ai's GitHub connected as ${agent} and the prompt below the line in ${routine}; skip it if done.`);
|
|
1620
|
+
later.push(`The review routine: create a weekly Claude routine on ${slug} (claude.ai/code/routines, or /schedule in Claude Code), with claude.ai's GitHub connected as ${agent}, and give it the prompt below the line in ${routine}. Until it gives its verdicts, the weekly job labels needs-owner each decision over a week past its review date.`);
|
|
1621
|
+
}
|
|
1613
1622
|
}
|
|
1614
1623
|
// Claude cloud sessions. Claude Code has no API for a cloud environment's Setup script, so the version lives in a
|
|
1615
1624
|
// file the repo owns, written at the pin on every run, and the SessionStart hook runs it when a session has no CLI.
|
package/dist/reviews.js
CHANGED
|
@@ -236,6 +236,54 @@ export async function watchReviews(sys, io, slug, token, settings) {
|
|
|
236
236
|
io.out(`#${issue.number}: its review, ${review}, is over a week past with no verdict from the agent; labeled needs-owner`);
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
+
/** The verdicts in routines/review.md, holds included: a comment by the agent starting with one is the review routine's trace. */
|
|
240
|
+
const ROUTINE_VERDICT = /^\s*(?:Kept:|Settled:|Held for )/;
|
|
241
|
+
/** How far back onboard looks for the routine's trace: three of its weekly runs. */
|
|
242
|
+
export const TRACE_DAYS = 21;
|
|
243
|
+
/** The pages of 100 comments onboard reads at most, newest first. */
|
|
244
|
+
const TRACE_PAGES = 10;
|
|
245
|
+
/** GitHub's timestamps: UTC, to the second or finer. */
|
|
246
|
+
const INSTANT = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?Z$/;
|
|
247
|
+
/** A GitHub timestamp in milliseconds, or undefined for one that is not such a time, or names no real date. */
|
|
248
|
+
function instant(text) {
|
|
249
|
+
const parts = INSTANT.exec(text ?? '');
|
|
250
|
+
if (!parts)
|
|
251
|
+
return undefined;
|
|
252
|
+
// Milliseconds count, so a verdict a moment after the cutoff, in its second, is not taken for one before it.
|
|
253
|
+
const milliseconds = (parts[7] ?? '').padEnd(3, '0').slice(0, 3);
|
|
254
|
+
const [year, month, day, hour, minute, second, ms] = [...parts.slice(1, 7), milliseconds].map(Number);
|
|
255
|
+
const time = Date.UTC(year, month - 1, day, hour, minute, second, ms);
|
|
256
|
+
// Date.UTC rolls 30 February into March: a time that does not read back the same was never a date.
|
|
257
|
+
return new Date(time).toISOString().slice(0, 19) === text.slice(0, 19) ? time : undefined;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* The review routine's newest verdict on `slug` in the last three weeks, as
|
|
261
|
+
* the issue it is on and its date, or undefined when there is none: onboard
|
|
262
|
+
* cannot read Claude's routines, so a verdict by the agent is how it sees the
|
|
263
|
+
* routine runs. Reads at most ten pages of the repository's issue comments,
|
|
264
|
+
* newest first; throws where GitHub refuses them.
|
|
265
|
+
*/
|
|
266
|
+
export async function routineTrace(sys, slug, agent, token) {
|
|
267
|
+
const cutoff = sys.now().getTime() - TRACE_DAYS * DAY_MS;
|
|
268
|
+
const since = new Date(cutoff).toISOString();
|
|
269
|
+
for (let page = 1; page <= TRACE_PAGES; page++) {
|
|
270
|
+
const { status, json } = await sys.http(`${API}/repos/${slug}/issues/comments?since=${since}&sort=created&direction=desc&per_page=100&page=${page}`, { token });
|
|
271
|
+
if (status !== 200 || !Array.isArray(json))
|
|
272
|
+
throw new Error(`cannot list ${slug}'s issue comments (HTTP ${status})`);
|
|
273
|
+
for (const comment of json) {
|
|
274
|
+
// `since` is by last update: an older verdict edited lately is not a recent run.
|
|
275
|
+
const created = instant(comment.created_at);
|
|
276
|
+
const number = Number(/\/issues\/(\d+)$/.exec(comment.issue_url ?? '')?.[1]);
|
|
277
|
+
if (created === undefined || created < cutoff || !Number.isInteger(number))
|
|
278
|
+
continue;
|
|
279
|
+
if (anyLogin([agent], comment.user?.login ?? undefined) && ROUTINE_VERDICT.test(comment.body ?? ''))
|
|
280
|
+
return { number, date: comment.created_at.slice(0, 10) };
|
|
281
|
+
}
|
|
282
|
+
if (json.length < 100)
|
|
283
|
+
return undefined;
|
|
284
|
+
}
|
|
285
|
+
return undefined;
|
|
286
|
+
}
|
|
239
287
|
/**
|
|
240
288
|
* Removes `veto` labels the routine added more than a week ago: the owner's
|
|
241
289
|
* window to reverse that decision has closed. Part of the weekly job.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veda-hq/niyam",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
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.
|
|
31
|
+
"@veda-hq/sarathi": "0.7.1",
|
|
32
32
|
"typescript": "7.0.2"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|