knitmd 0.0.0-stage → 0.1.1

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/dist/git.js ADDED
@@ -0,0 +1,65 @@
1
+ import { execFileSync } from 'node:child_process';
2
+ export class GitError extends Error {
3
+ args;
4
+ stderr;
5
+ status;
6
+ constructor(args, stderr, status) {
7
+ super(`git ${args.join(' ')} failed: ${stderr.trim() || `exit ${status}`}`);
8
+ this.args = args;
9
+ this.stderr = stderr;
10
+ this.status = status;
11
+ }
12
+ }
13
+ /** Runs git in `cwd` and returns stdout without the trailing newline. Throws GitError. */
14
+ export function git(cwd, args, opts = {}) {
15
+ try {
16
+ const out = execFileSync('git', args, {
17
+ cwd,
18
+ encoding: 'utf8',
19
+ stdio: ['pipe', 'pipe', 'pipe'],
20
+ maxBuffer: 256 * 1024 * 1024,
21
+ ...(opts.input !== undefined ? { input: opts.input } : {}),
22
+ env: { ...process.env, ...(opts.env ?? {}) },
23
+ });
24
+ return out.replace(/\n$/, '');
25
+ }
26
+ catch (e) {
27
+ const err = e;
28
+ throw new GitError(args, String(err.stderr ?? ''), err.status ?? null);
29
+ }
30
+ }
31
+ /** Like `git`, but returns undefined instead of throwing. */
32
+ export function tryGit(cwd, args, opts = {}) {
33
+ try {
34
+ return git(cwd, args, opts);
35
+ }
36
+ catch (e) {
37
+ if (e instanceof GitError)
38
+ return undefined;
39
+ throw e;
40
+ }
41
+ }
42
+ export function repoRoot(cwd) {
43
+ return tryGit(cwd, ['rev-parse', '--show-toplevel']);
44
+ }
45
+ export function currentBranch(cwd) {
46
+ const b = tryGit(cwd, ['symbolic-ref', '--quiet', '--short', 'HEAD']);
47
+ return b || undefined;
48
+ }
49
+ export function hasRemote(cwd, remote) {
50
+ return (tryGit(cwd, ['remote']) ?? '').split('\n').includes(remote);
51
+ }
52
+ export function refExists(cwd, ref) {
53
+ return tryGit(cwd, ['rev-parse', '--verify', '--quiet', `${ref}^{commit}`]) !== undefined;
54
+ }
55
+ /** Files under `dir` (repository-relative, forward slashes) in `ref`. */
56
+ export function listFiles(cwd, ref, dir) {
57
+ const out = tryGit(cwd, ['ls-tree', '-r', '--name-only', ref, '--', dir]);
58
+ return out ? out.split('\n').filter(Boolean) : [];
59
+ }
60
+ export function showFile(cwd, ref, path) {
61
+ return tryGit(cwd, ['show', `${ref}:${path}`]);
62
+ }
63
+ export function isDirty(cwd, paths = []) {
64
+ return (tryGit(cwd, ['status', '--porcelain', '--', ...paths]) ?? '') !== '';
65
+ }
package/dist/inbox.js ADDED
@@ -0,0 +1,15 @@
1
+ import { repoPath } from '@knitmd/core';
2
+ import { tryGit } from './git.js';
3
+ /**
4
+ * When each wait began, from the Git history of the ticket file: the last commit that changed its
5
+ * status line, or the commit that added a question. Undefined for uncommitted changes.
6
+ */
7
+ export function waitingSince(t) {
8
+ return (doc, q) => {
9
+ const path = repoPath(t, doc.path);
10
+ const args = q
11
+ ? ['log', '-1', '--format=%cs', `-S${q.text}`, '--', path]
12
+ : ['log', '-1', '--format=%cs', '-G^status: ', '--', path];
13
+ return tryGit(t.root, args) || undefined;
14
+ };
15
+ }
package/dist/linked.js ADDED
@@ -0,0 +1,58 @@
1
+ import { branchFor, confirmLinked, idPatterns, mergeLinked, syncedCommits, ticketIds, workRoot, } from '@knitmd/core';
2
+ import { git, refExists, tryGit } from './git.js';
3
+ /** Hash, committer date, subject, author, message. */
4
+ const FORMAT = '--format=%H%x1f%cs%x1f%s%x1f%an%x1f%B%x1e';
5
+ function parse(text) {
6
+ const out = [];
7
+ for (const rec of (text ?? '').split('\x1e')) {
8
+ const parts = rec.replace(/^\n/, '').split('\x1f');
9
+ if (parts.length < 5)
10
+ continue;
11
+ const [hash, date, subject, author, ...message] = parts;
12
+ out.push({ hash, date, subject, author, message: message.join('\x1f') });
13
+ }
14
+ return out;
15
+ }
16
+ /** The first existing ref of the candidates. */
17
+ function firstRef(root, refs) {
18
+ return refs.find((r) => refExists(root, r));
19
+ }
20
+ /** Commits of one repository that refer to the ticket, on its main branch and on the claim branch. */
21
+ function fromRepo(t, root, ids, repo) {
22
+ const cfg = t.config;
23
+ const remote = cfg.git.remote;
24
+ const main = firstRef(root, [`refs/remotes/${remote}/${cfg.git.main}`, `refs/heads/${cfg.git.main}`]);
25
+ const branch = branchFor(cfg, ids[0]);
26
+ const claim = firstRef(root, [`refs/heads/${branch}`, `refs/remotes/${remote}/${branch}`]);
27
+ const grep = idPatterns(ids).map((p) => `--grep=${p}`);
28
+ const log = (args) => parse(tryGit(root, ['log', '--extended-regexp', '--regexp-ignore-case', FORMAT, ...grep, ...args]));
29
+ // Unmerged commits first: they are the newest work.
30
+ const onBranch = claim ? confirmLinked(t, ids, log([claim, ...(main ? ['--not', main] : [])]), 'branch', repo) : [];
31
+ const onMain = main ? confirmLinked(t, ids, log([main]), 'main', repo) : [];
32
+ return [...onBranch, ...onMain];
33
+ }
34
+ /**
35
+ * Commits that refer to a ticket (or its former IDs), newest first. They are read from Git (and,
36
+ * in the central mode, from the lines `sync` wrote), never stored in the ticket.
37
+ */
38
+ export function linkedCommits(t, doc) {
39
+ const ids = ticketIds(doc);
40
+ if (t.code !== undefined || t.config.mode === 'central') {
41
+ return mergeLinked(syncedCommits(doc), t.code ? fromRepo(t, t.code.root, ids, t.code.repo) : []);
42
+ }
43
+ return mergeLinked(fromRepo(t, t.root, ids));
44
+ }
45
+ /**
46
+ * The tickets the commits of a range refer to, each with its commits of the range (newest first).
47
+ * The range is any `git log` range, such as `v1.3..v1.4`; it is read in the repository one works in.
48
+ */
49
+ export function ticketsInRange(t, range) {
50
+ const commits = parse(git(workRoot(t), ['log', FORMAT, range]));
51
+ const out = new Map();
52
+ for (const doc of t.tickets) {
53
+ const linked = confirmLinked(t, ticketIds(doc), commits, 'main', t.code?.repo);
54
+ if (linked.length > 0)
55
+ out.set(doc, linked);
56
+ }
57
+ return out;
58
+ }
package/dist/person.js ADDED
@@ -0,0 +1,32 @@
1
+ import { UserError, authorPerson } from '@knitmd/core';
2
+ import { tryGit } from './git.js';
3
+ /**
4
+ * The person running the command: `$NIT_USER`, then `git config nit.user`, then the Git user
5
+ * (e-mail or name) matched against the `git` aliases, keys and names of `people`.
6
+ */
7
+ export function currentPerson(ctx, cfg, cwd) {
8
+ const explicit = ctx.env.NIT_USER || tryGit(cwd, ['config', 'nit.user']) || tryGit(cwd, ['config', 'mdproj.user']); // mdproj.user: before Knit
9
+ if (explicit) {
10
+ if (!cfg.people[explicit]) {
11
+ throw new UserError(`person '${explicit}' is not in people of proj.yml; add it, or fix $NIT_USER / nit.user`);
12
+ }
13
+ return explicit;
14
+ }
15
+ const name = tryGit(cwd, ['config', 'user.name']);
16
+ const email = tryGit(cwd, ['config', 'user.email']);
17
+ if (name || email) {
18
+ const found = authorPerson(cfg, name ?? '', email ?? '');
19
+ if (found)
20
+ return found;
21
+ }
22
+ throw new UserError(`cannot tell who you are: set $NIT_USER or \`git config nit.user <key>\` to a key of people in proj.yml${name ? ` (Git user '${name}' matches none)` : ''}`);
23
+ }
24
+ /** The key `init` suggests for a Git user name: the first name in lower case. */
25
+ export function personKey(name) {
26
+ return (name
27
+ .split(/\s+/)[0]
28
+ .normalize('NFKD')
29
+ .replace(/[̀-ͯ]/g, '')
30
+ .toLowerCase()
31
+ .replace(/[^a-z0-9-]/g, '') || 'me');
32
+ }
@@ -0,0 +1,95 @@
1
+ import { idNumber, ticketId, UserError } from '@knitmd/core';
2
+ import { currentBranch, git, GitError, hasRemote, isDirty, listFiles, tryGit } from './git.js';
3
+ /** The next free ticket number: after the largest in the working tree and in every local and remote branch. */
4
+ export function nextNumber(t) {
5
+ let max = 0;
6
+ const idRe = new RegExp(`(?:^|/)${t.config.key}-(\\d+)(?:-[^/]*)?\\.md$`);
7
+ for (const d of t.tickets) {
8
+ const n = idNumber(ticketId(d));
9
+ if (n > max)
10
+ max = n;
11
+ }
12
+ const refs = tryGit(t.root, ['for-each-ref', '--format=%(refname)', 'refs/heads', 'refs/remotes']);
13
+ for (const ref of (refs ?? '').split('\n').filter(Boolean)) {
14
+ if (ref.endsWith('/HEAD'))
15
+ continue;
16
+ for (const f of listFiles(t.root, ref, `${t.rel ? `${t.rel}/` : ''}tickets`)) {
17
+ const m = idRe.exec(f);
18
+ if (m && Number(m[1]) > max)
19
+ max = Number(m[1]);
20
+ }
21
+ }
22
+ return max + 1;
23
+ }
24
+ /** Whether commands commit their changes to the tracker repository themselves (central mode). */
25
+ export function autoCommit(t, opts) {
26
+ return opts.commit ?? t.config.mode === 'central';
27
+ }
28
+ /** Whether pushing is allowed and possible. */
29
+ export function canPush(t, root, opts) {
30
+ const want = opts.push ?? t.config.git.push;
31
+ return want && hasRemote(root, t.config.git.remote);
32
+ }
33
+ /**
34
+ * Brings the tracker repository up to date before a change (central mode), so that the change is
35
+ * made on top of the latest state. Skipped when the tracker has no remote or local changes.
36
+ */
37
+ export function refreshTracker(t, ctx) {
38
+ if (t.config.mode !== 'central' || !hasRemote(t.root, t.config.git.remote))
39
+ return false;
40
+ if (currentBranch(t.root) !== t.config.git.main)
41
+ return false;
42
+ if (isDirty(t.root, [t.rel || '.'])) {
43
+ ctx.err(`warning: ${t.rel || 'the tracker'} has uncommitted changes; not pulling the latest tickets`);
44
+ return false;
45
+ }
46
+ try {
47
+ git(t.root, ['pull', '--rebase', '--quiet', t.config.git.remote, t.config.git.main]);
48
+ return true;
49
+ }
50
+ catch (e) {
51
+ ctx.err(`warning: could not update the tracker: ${e.message}`);
52
+ return false;
53
+ }
54
+ }
55
+ /**
56
+ * Commits the given tracker files and, when allowed, pushes them to the main branch, rebasing on a
57
+ * rejected push. Used by the commands that change the tracker in the central mode.
58
+ */
59
+ export function publish(t, ctx, paths, message, opts = {}) {
60
+ if (!autoCommit(t, opts))
61
+ return;
62
+ git(t.root, ['add', '--', ...paths]);
63
+ if ((tryGit(t.root, ['diff', '--cached', '--name-only', '--', ...paths]) ?? '') === '')
64
+ return;
65
+ git(t.root, ['commit', '--quiet', '--no-verify', '-m', message, '--', ...paths]);
66
+ ctx.out(`committed: ${message.split('\n')[0]}`);
67
+ if (!canPush(t, t.root, opts))
68
+ return;
69
+ const remote = t.config.git.remote;
70
+ const main = t.config.git.main;
71
+ if (currentBranch(t.root) !== main) {
72
+ ctx.err(`warning: the tracker is not on ${main}; not pushing`);
73
+ return;
74
+ }
75
+ for (let attempt = 0; attempt < 5; attempt++) {
76
+ try {
77
+ git(t.root, ['push', '--quiet', remote, `HEAD:${main}`]);
78
+ ctx.out(`pushed to ${remote}/${main}`);
79
+ return;
80
+ }
81
+ catch (e) {
82
+ if (!(e instanceof GitError))
83
+ throw e;
84
+ try {
85
+ git(t.root, ['pull', '--rebase', '--quiet', remote, main]);
86
+ }
87
+ catch (re) {
88
+ tryGit(t.root, ['rebase', '--abort']);
89
+ throw new UserError(`someone changed the same ticket at the same time; your commit is kept locally. Details: ${re.message}`, 1);
90
+ }
91
+ opts.afterRebase?.();
92
+ }
93
+ }
94
+ throw new UserError('could not push the tracker after 5 attempts; your commit is kept locally', 1);
95
+ }
@@ -0,0 +1,146 @@
1
+ import { existsSync, readdirSync, readFileSync, realpathSync, statSync, writeFileSync } from 'node:fs';
2
+ import { dirname, join, relative, resolve, sep } from 'node:path';
3
+ import { LEGACY_POINTER_FILE, POINTER_FILE, TRACKER_DIR, UserError, buildTracker, parseConfig, changed, findTicket, idFromBranch, serialize, workRoot, } from '@knitmd/core';
4
+ import { parse as parseYaml } from 'yaml';
5
+ import { currentBranch, repoRoot, tryGit } from './git.js';
6
+ /** Reads `.nit.yml` (or `.mdproj.yml` of earlier versions) from the root of the repository containing `cwd`. */
7
+ export function readPointer(cwd) {
8
+ let dir = resolve(cwd);
9
+ const top = repoRoot(cwd);
10
+ for (;;) {
11
+ const p = [POINTER_FILE, LEGACY_POINTER_FILE].map((f) => join(dir, f)).find(existsSync);
12
+ if (p) {
13
+ const raw = (parseYaml(readFileSync(p, 'utf8')) ?? {});
14
+ if (typeof raw.tracker !== 'string')
15
+ throw new UserError(`${p}: 'tracker' is missing`);
16
+ return {
17
+ root: dir,
18
+ pointer: { tracker: resolve(dir, raw.tracker), repo: String(raw.repo ?? '') },
19
+ };
20
+ }
21
+ const parent = dirname(dir);
22
+ if (parent === dir || (top && resolve(dir) === resolve(top)))
23
+ return undefined;
24
+ dir = parent;
25
+ }
26
+ }
27
+ function trackerDirIn(path) {
28
+ if (existsSync(join(path, 'proj.yml')))
29
+ return path;
30
+ if (existsSync(join(path, TRACKER_DIR, 'proj.yml')))
31
+ return join(path, TRACKER_DIR);
32
+ return undefined;
33
+ }
34
+ /** Finds the tracker folder for a command run in `ctx.cwd` (section 3 of DESIGN.md). */
35
+ export function findTrackerDir(ctx, explicit) {
36
+ if (explicit) {
37
+ const d = trackerDirIn(resolve(ctx.cwd, explicit));
38
+ if (!d)
39
+ throw new UserError(`no proj.yml in ${explicit}`);
40
+ return { dir: d };
41
+ }
42
+ if (ctx.env.NIT_DIR) {
43
+ const d = trackerDirIn(resolve(ctx.cwd, ctx.env.NIT_DIR));
44
+ if (!d)
45
+ throw new UserError(`no proj.yml in $NIT_DIR (${ctx.env.NIT_DIR})`);
46
+ return { dir: d };
47
+ }
48
+ const ptr = readPointer(ctx.cwd);
49
+ const trackerPath = ctx.env.NIT_TRACKER ? resolve(ctx.cwd, ctx.env.NIT_TRACKER) : ptr?.pointer.tracker;
50
+ if (trackerPath) {
51
+ const d = trackerDirIn(trackerPath);
52
+ if (!d) {
53
+ throw new UserError(`the tracker is not at ${trackerPath}: clone the tracker repository there or set $NIT_TRACKER`);
54
+ }
55
+ const code = ptr ? { root: ptr.root, repo: ptr.pointer.repo } : undefined;
56
+ return code && resolve(code.root) !== resolve(repoRoot(d) ?? d) ? { dir: d, code } : { dir: d };
57
+ }
58
+ let dir = resolve(ctx.cwd);
59
+ const top = repoRoot(ctx.cwd);
60
+ for (;;) {
61
+ const d = trackerDirIn(dir) === join(dir, TRACKER_DIR) ? join(dir, TRACKER_DIR) : undefined;
62
+ if (d)
63
+ return { dir: d };
64
+ const parent = dirname(dir);
65
+ if (parent === dir || (top && resolve(dir) === resolve(top)))
66
+ break;
67
+ dir = parent;
68
+ }
69
+ throw new UserError('no tracker found: run `nit init`, or `nit link <tracker>` in a code repository');
70
+ }
71
+ /** The tracker files on disk; Git LFS attributes come from `git check-attr`. */
72
+ export function fsFiles(root) {
73
+ const stat = (p) => {
74
+ try {
75
+ return statSync(p);
76
+ }
77
+ catch {
78
+ return undefined;
79
+ }
80
+ };
81
+ return {
82
+ read: (p) => (stat(p)?.isFile() ? readFileSync(p, 'utf8') : undefined),
83
+ list: (d) => (stat(d)?.isDirectory() ? readdirSync(d).sort() : []),
84
+ isDir: (p) => stat(p)?.isDirectory() === true,
85
+ size: (p) => {
86
+ const s = stat(p);
87
+ return s?.isFile() ? s.size : undefined;
88
+ },
89
+ lfs: (paths) => lfsPaths(root, paths),
90
+ };
91
+ }
92
+ /** Repository-relative paths that Git LFS handles (by `.gitattributes`), from `git check-attr filter`. */
93
+ export function lfsPaths(root, paths) {
94
+ if (paths.length === 0)
95
+ return new Set();
96
+ const out = tryGit(root, ['check-attr', '--stdin', 'filter'], { input: `${paths.join('\n')}\n` });
97
+ const result = new Set();
98
+ for (const line of (out ?? '').split('\n')) {
99
+ const m = /^(.*): filter: lfs$/.exec(line);
100
+ if (m)
101
+ result.add(m[1]);
102
+ }
103
+ return result;
104
+ }
105
+ export function loadTracker(ctx, explicit) {
106
+ const found = findTrackerDir(ctx, explicit);
107
+ // Real paths, so that paths from Git (which resolves symbolic links) and ours compare equal.
108
+ const dir = realpathSync(found.dir);
109
+ const code = found.code ? { ...found.code, root: realpathSync(found.code.root) } : undefined;
110
+ const root = repoRoot(dir) ?? dir;
111
+ return buildTracker({ dir, root, files: fsFiles(root), ...(code ? { code } : {}) });
112
+ }
113
+ /** Writes a document if its serialization changed. Returns whether it wrote. */
114
+ export function save(doc) {
115
+ if (!changed(doc))
116
+ return false;
117
+ const text = serialize(doc);
118
+ writeFileSync(doc.path, text);
119
+ doc.original = text;
120
+ return true;
121
+ }
122
+ /** A path relative to the current directory, for messages. */
123
+ export function displayPath(ctx, path) {
124
+ let cwd = ctx.cwd;
125
+ try {
126
+ cwd = realpathSync(cwd);
127
+ }
128
+ catch { }
129
+ const r = relative(cwd, path);
130
+ return r.startsWith('..') && r.split(sep).filter((x) => x === '..').length > 2 ? path : r || '.';
131
+ }
132
+ /** The ticket named on the command line, or the ticket of the current branch. */
133
+ export function resolveTicketArg(t, id) {
134
+ if (id)
135
+ return findTicket(t, id);
136
+ const branch = currentBranch(workRoot(t));
137
+ const fromBranch = idFromBranch(t.config, branch);
138
+ if (!fromBranch) {
139
+ throw new UserError(`give a ticket ID: the current branch${branch ? ` '${branch}'` : ''} is not a ticket branch (${t.config.git.branch})`);
140
+ }
141
+ return findTicket(t, fromBranch);
142
+ }
143
+ /** Reads and validates a `proj.yml` file. */
144
+ export function loadConfig(path) {
145
+ return parseConfig(readFileSync(path, 'utf8'), path);
146
+ }
package/package.json CHANGED
@@ -1,6 +1,39 @@
1
1
  {
2
2
  "name": "knitmd",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "Git-based, agent-friendly issue tracking: tickets are Markdown files in the repository.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "bin": {
8
+ "nit": "dist/cli.js",
9
+ "git-nit": "dist/cli.js"
10
+ },
11
+ "engines": {
12
+ "node": ">=22.18"
13
+ },
14
+ "dependencies": {
15
+ "@knitmd/core": "0.1.1",
16
+ "yaml": "^2.8.0"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/knitmd/knit.git",
21
+ "directory": "packages/cli"
22
+ },
23
+ "homepage": "https://github.com/knitmd/knit#readme",
24
+ "bugs": {
25
+ "url": "https://github.com/knitmd/knit/issues"
26
+ },
27
+ "peerDependencies": {
28
+ "@knitmd/mcp": "0.1.1"
29
+ },
30
+ "peerDependenciesMeta": {
31
+ "@knitmd/mcp": {
32
+ "optional": true
33
+ }
34
+ },
35
+ "files": [
36
+ "dist",
37
+ "templates"
38
+ ]
39
+ }
@@ -0,0 +1,41 @@
1
+ # Knit (central mode, code repository): checks ticket references in pull requests and
2
+ # asks the tracker to sync after a merge.
3
+ name: Tickets
4
+
5
+ on:
6
+ pull_request:
7
+ push:
8
+ branches: [{{main}}]
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ jobs:
14
+ check-commits:
15
+ if: github.event_name == 'pull_request'
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ - uses: actions/checkout@v5
19
+ with:
20
+ fetch-depth: 0
21
+ - uses: actions/checkout@v5
22
+ with:
23
+ repository: {{trackerRepo}}
24
+ path: .nit-tracker
25
+ token: ${{ secrets.NIT_TRACKER_TOKEN }}
26
+ - uses: actions/setup-node@v5
27
+ with:
28
+ node-version: 24
29
+ - run: {{install}}
30
+ - run: nit check-commits "origin/${{ github.base_ref }}..HEAD"
31
+ env:
32
+ NIT_TRACKER: .nit-tracker
33
+
34
+ sync:
35
+ if: github.event_name == 'push'
36
+ runs-on: ubuntu-latest
37
+ steps:
38
+ - name: Ask the tracker to sync
39
+ env:
40
+ GH_TOKEN: ${{ secrets.NIT_TRACKER_TOKEN }}
41
+ run: gh api "repos/{{trackerRepo}}/dispatches" -f event_type=nit-sync
@@ -0,0 +1,38 @@
1
+ # Knit (central mode): records commits of the code repositories in the tickets and closes
2
+ # finished tickets. Triggered by the code repositories after a merge, nightly, and by hand.
3
+ name: Project sync
4
+
5
+ on:
6
+ repository_dispatch:
7
+ types: [nit-sync]
8
+ schedule:
9
+ - cron: "41 2 * * *"
10
+ workflow_dispatch:
11
+
12
+ permissions:
13
+ contents: write
14
+
15
+ concurrency:
16
+ group: nit-sync
17
+ cancel-in-progress: false
18
+
19
+ jobs:
20
+ sync:
21
+ runs-on: ubuntu-latest
22
+ steps:
23
+ - uses: actions/checkout@v5
24
+ with:
25
+ fetch-depth: 0
26
+ - uses: actions/setup-node@v5
27
+ with:
28
+ node-version: 24
29
+ - run: {{install}}
30
+ - name: Allow reading the code repositories
31
+ env:
32
+ TOKEN: ${{ secrets.NIT_REPOS_TOKEN }}
33
+ run: |
34
+ git config --global url."https://x-access-token:${TOKEN}@github.com/".insteadOf "git@github.com:"
35
+ git config --global user.name "nit"
36
+ git config --global user.email "nit@users.noreply.github.com"
37
+ - run: nit sync --commit --push
38
+ - run: nit report --commit --push
@@ -0,0 +1,50 @@
1
+ # Knit: checks tickets in pull requests and keeps the reports branch up to date.
2
+ name: Project
3
+
4
+ on:
5
+ pull_request:
6
+ push:
7
+ branches: [{{main}}, "{{branchGlob}}"]
8
+ delete:
9
+ schedule:
10
+ - cron: "17 5 * * *" # daily, for date-relative views (overdue, due soon)
11
+ workflow_dispatch:
12
+
13
+ permissions:
14
+ contents: write
15
+
16
+ concurrency:
17
+ group: nit-${{ github.event_name == 'pull_request' && github.ref || 'reports' }}
18
+ cancel-in-progress: false
19
+
20
+ jobs:
21
+ check:
22
+ if: github.event_name == 'pull_request'
23
+ runs-on: ubuntu-latest
24
+ steps:
25
+ - uses: actions/checkout@v5
26
+ with:
27
+ fetch-depth: 0
28
+ - uses: actions/setup-node@v5
29
+ with:
30
+ node-version: 24
31
+ - run: {{install}}
32
+ - run: nit check
33
+ - run: nit check-commits "origin/${{ github.base_ref }}..HEAD"
34
+
35
+ reports:
36
+ if: github.event_name != 'pull_request'
37
+ runs-on: ubuntu-latest
38
+ steps:
39
+ - uses: actions/checkout@v5
40
+ with:
41
+ ref: {{main}}
42
+ fetch-depth: 0
43
+ - uses: actions/setup-node@v5
44
+ with:
45
+ node-version: 24
46
+ - run: {{install}}
47
+ - run: |
48
+ git config --global user.name "nit"
49
+ git config --global user.email "nit@users.noreply.github.com"
50
+ - run: nit report --commit --push