slicekit 0.1.1 → 0.2.0
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 +15 -13
- package/package.json +3 -2
- package/src/adapters/githost/fixture.js +24 -1
- package/src/adapters/githost/gh-json.js +69 -2
- package/src/adapters/githost/github.js +16 -1
- package/src/build/commit.js +152 -26
- package/src/build/config.js +50 -0
- package/src/build/pr.js +30 -15
- package/src/build/record.js +8 -2
- package/src/build/red.js +4 -3
- package/src/build/render.js +155 -0
- package/src/build/verdict.js +29 -0
- package/src/build/worktree.js +26 -5
- package/src/check/ci-event.js +17 -0
- package/src/check/rules/citations.js +53 -2
- package/src/check/rules/commands.js +32 -4
- package/src/check/rules/trailer.js +5 -16
- package/src/check/rules/workspace.js +86 -0
- package/src/cli/build.js +34 -8
- package/src/cli/ci.js +150 -0
- package/src/cli/decide.js +4 -3
- package/src/cli/gaps.js +6 -5
- package/src/cli/graph.js +79 -0
- package/src/cli/history.js +17 -0
- package/src/cli/hook.js +1 -1
- package/src/cli/impact.js +17 -0
- package/src/cli/index.js +28 -3
- package/src/cli/instructions.js +1 -1
- package/src/cli/intake.js +3 -3
- package/src/cli/query.js +39 -0
- package/src/cli/shipped.js +32 -0
- package/src/cli/state.js +42 -2
- package/src/cli/trace.js +21 -0
- package/src/cli/uncovered.js +32 -0
- package/src/cli/visualize.js +88 -0
- package/src/cli/workflow.js +6 -2
- package/src/config.js +85 -0
- package/src/graph/build.js +312 -0
- package/src/graph/docs.js +241 -0
- package/src/graph/git-walk.js +91 -0
- package/src/graph/history.js +60 -0
- package/src/graph/impact.js +143 -0
- package/src/graph/kitfiles.js +60 -0
- package/src/graph/load.js +93 -0
- package/src/graph/prs.js +136 -0
- package/src/graph/render.js +28 -0
- package/src/graph/schema.js +108 -0
- package/src/graph/shipped.js +32 -0
- package/src/graph/tests.js +45 -0
- package/src/graph/trace.js +83 -0
- package/src/graph/uncovered.js +16 -0
- package/src/graph/workspace.js +188 -0
- package/src/hook-cli.js +1 -1
- package/src/init.js +8 -1
- package/src/instructions.js +26 -8
- package/src/state/index.js +35 -4
- package/src/verdict.js +14 -2
- package/src/visualize/client.js +489 -0
- package/src/visualize/page.js +100 -0
- package/src/visualize/server.js +46 -0
- package/src/workflow.js +87 -9
- package/templates/githooks/pre-commit +24 -4
- package/templates/githooks/pre-merge-commit +24 -4
- package/templates/githooks/prepare-commit-msg +41 -5
- package/templates/instructions/agents/reviewer.md +7 -7
- package/templates/instructions/commands/build.md +34 -4
- package/templates/workflow/pins.json +2 -1
- package/templates/workflow/slicekit.yml +32 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// history (REQ-4.5): newest first, the slices whose commits touched a path (a directory matches every
|
|
2
|
+
// file under it), each with its pull request, its last verdict and its release. Commits in no slice
|
|
3
|
+
// are not listed. Reads the index only.
|
|
4
|
+
import { normalisePath } from './load.js';
|
|
5
|
+
import { GraphError, cmp, keyOf, kindOf } from './schema.js';
|
|
6
|
+
import { timeOf } from './trace.js';
|
|
7
|
+
|
|
8
|
+
// The file nodes a path names: the file itself and every file under it as a directory.
|
|
9
|
+
function matching(index, p) {
|
|
10
|
+
const want = normalisePath(p);
|
|
11
|
+
if (want === '' || want === '.') return index.byKind('file');
|
|
12
|
+
const dir = `${want}/`;
|
|
13
|
+
return index.byKind('file').filter((f) => {
|
|
14
|
+
const k = keyOf(f.id);
|
|
15
|
+
return k === want || k.startsWith(dir);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const newer = (c, cur) => !cur || timeOf(c.date) > timeOf(cur.date) || (timeOf(c.date) === timeOf(cur.date) && cmp(c.id, cur.id) < 0);
|
|
20
|
+
|
|
21
|
+
export function history(index, paths) {
|
|
22
|
+
const commits = new Set();
|
|
23
|
+
for (const p of paths) {
|
|
24
|
+
const files = matching(index, p);
|
|
25
|
+
if (files.length === 0) throw new GraphError(2, `${p} is not in the graph`);
|
|
26
|
+
for (const f of files) for (const e of index.in(f.id, 'touched')) commits.add(e.from);
|
|
27
|
+
}
|
|
28
|
+
const newest = new Map();
|
|
29
|
+
for (const cid of commits) {
|
|
30
|
+
const c = index.node(cid);
|
|
31
|
+
if (!c) continue;
|
|
32
|
+
for (const e of index.out(cid, 'in')) {
|
|
33
|
+
if (kindOf(e.to) === 'slice' && index.node(e.to) && newer(c, newest.get(e.to))) newest.set(e.to, c);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const out = [];
|
|
37
|
+
for (const [sid, c] of newest) {
|
|
38
|
+
const ins = index.in(sid, 'in');
|
|
39
|
+
const from = (kind) => ins.filter((e) => kindOf(e.from) === kind).map((e) => index.node(e.from)).filter(Boolean);
|
|
40
|
+
const pr = from('pull-request').sort((a, b) => (b.number ?? 0) - (a.number ?? 0) || cmp(a.id, b.id))[0] ?? null;
|
|
41
|
+
const verdict = from('verdict').sort((a, b) => (b.round ?? 0) - (a.round ?? 0) || cmp(a.id, b.id))[0] ?? null;
|
|
42
|
+
const rel = pr ? index.out(pr.id, 'released-in').find((e) => kindOf(e.to) === 'release') : null;
|
|
43
|
+
out.push({
|
|
44
|
+
slice: keyOf(sid),
|
|
45
|
+
pr: pr ? (pr.number ?? Number(keyOf(pr.id))) : null,
|
|
46
|
+
// A workspace repository's pull request carries its repository (S-20 review H-4).
|
|
47
|
+
...(pr?.repo ? { prRepo: pr.repo } : {}),
|
|
48
|
+
verdict: verdict?.verdict ?? null,
|
|
49
|
+
release: rel ? keyOf(rel.to) : null,
|
|
50
|
+
sha: keyOf(c.id),
|
|
51
|
+
date: c.date ?? null,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
// A tie on one newest commit falls back to the slice ID, so the order never depends on the order of
|
|
55
|
+
// the index's edges (P3/S-34, issue #48).
|
|
56
|
+
return out.sort((a, b) => timeOf(b.date) - timeOf(a.date) || cmp(a.sha, b.sha) || cmp(a.slice, b.slice));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const historyLine = (e) =>
|
|
60
|
+
[e.slice, e.pr === null ? 'no pull request' : `PR ${e.prRepo ?? ''}#${e.pr}`, e.verdict ?? 'no verdict', e.release ? `released ${e.release}` : 'unreleased'].join(' ');
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// impact (REQ-4.5, REQ-4.6): the files, slices and contracts that share files or contracts with a
|
|
2
|
+
// requirement, a contract, a slice or a path, across the repositories of a workspace. Reads the
|
|
3
|
+
// index only; no git, no host.
|
|
4
|
+
//
|
|
5
|
+
// The start set: for a requirement, the slices that implement it; for a contract, the contract; for a
|
|
6
|
+
// slice, the slice; for a path, its file nodes (a directory matches every file under it) and the
|
|
7
|
+
// slices whose commits touched them. The start files are the start set's files; the start contracts
|
|
8
|
+
// the contracts its slices produce or consume, or the contract itself. The kit's own bookkeeping
|
|
9
|
+
// (the queue file and the state, reviews, journal and graph directories) is never a start file: every
|
|
10
|
+
// slice touches it, so it would relate every slice to every other (S-20 review B-2).
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import { kitPaths } from '../paths.js';
|
|
13
|
+
import { normalisePath } from './load.js';
|
|
14
|
+
import { GraphError, cmp, keyOf, kindOf } from './schema.js';
|
|
15
|
+
|
|
16
|
+
const TARGETS = new Set(['requirement', 'contract', 'slice', 'file', 'test']);
|
|
17
|
+
|
|
18
|
+
// bookkeeping(root, cfg) -> (file id) -> true for a file of the program repository that is the
|
|
19
|
+
// kit's bookkeeping, from kitPaths.
|
|
20
|
+
export function bookkeeping(root, cfg) {
|
|
21
|
+
const kp = kitPaths(root, cfg);
|
|
22
|
+
const rel = (abs) => path.relative(root, abs).split(path.sep).join('/');
|
|
23
|
+
const files = new Set([rel(kp.build)]);
|
|
24
|
+
const dirs = [kp.state, path.join(kp.kit, 'reviews'), kp.journalDir, kp.graph].map((d) => `${rel(d)}/`);
|
|
25
|
+
return (id) => {
|
|
26
|
+
const p = keyOf(id);
|
|
27
|
+
return files.has(p) || dirs.some((d) => p.startsWith(d));
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const repoOf = (slice) => (typeof slice.repo === 'string' && slice.repo !== '' ? slice.repo : '.');
|
|
32
|
+
|
|
33
|
+
// The file ids touched by a slice's commits.
|
|
34
|
+
function filesOf(index, sliceId) {
|
|
35
|
+
const out = new Set();
|
|
36
|
+
for (const e of index.in(sliceId, 'in')) {
|
|
37
|
+
if (kindOf(e.from) !== 'commit') continue;
|
|
38
|
+
for (const t of index.out(e.from, 'touched')) out.add(t.to);
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// The slice ids whose commits touched a file.
|
|
44
|
+
function slicesTouching(index, fileId) {
|
|
45
|
+
const out = new Set();
|
|
46
|
+
for (const e of index.in(fileId, 'touched')) {
|
|
47
|
+
for (const s of index.out(e.from, 'in')) if (kindOf(s.to) === 'slice') out.add(s.to);
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// The file node ids a path names: the file itself, else every file under it as a directory.
|
|
53
|
+
function filesAt(index, text) {
|
|
54
|
+
const p = normalisePath(text);
|
|
55
|
+
if (p === '') return [];
|
|
56
|
+
if (index.node(`file:${p}`)) return [`file:${p}`];
|
|
57
|
+
const under = `${p}/`;
|
|
58
|
+
return index.byKind('file').filter((n) => keyOf(n.id).startsWith(under)).map((n) => n.id);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// The start set of a target -> {target, slices: Set, files: Set, contracts: Set}, or null when the
|
|
62
|
+
// target is nothing in the graph. `target` is the node id, or the path itself for a directory. A node
|
|
63
|
+
// of another kind is refused with its kind (S-20 review H-3).
|
|
64
|
+
function start(index, text, skip) {
|
|
65
|
+
const id = index.find(text);
|
|
66
|
+
const kind = id ? kindOf(id) : null;
|
|
67
|
+
if (kind !== null && !TARGETS.has(kind)) {
|
|
68
|
+
throw new GraphError(2, `impact takes a requirement, contract, slice or path; ${text} is a ${kind}`);
|
|
69
|
+
}
|
|
70
|
+
const s = { target: id, slices: new Set(), files: new Set(), contracts: new Set() };
|
|
71
|
+
if (kind === 'requirement') {
|
|
72
|
+
for (const e of index.in(id, 'implements')) if (index.node(e.from)) s.slices.add(e.from);
|
|
73
|
+
} else if (kind === 'contract') {
|
|
74
|
+
s.contracts.add(id);
|
|
75
|
+
} else if (kind === 'slice') {
|
|
76
|
+
s.slices.add(id);
|
|
77
|
+
} else if (kind === null || kind === 'file' || kind === 'test') {
|
|
78
|
+
const named = filesAt(index, text);
|
|
79
|
+
if (named.length === 0) return null;
|
|
80
|
+
if (kind !== 'file') s.target = normalisePath(text);
|
|
81
|
+
for (const f of named.filter((x) => !skip(x))) {
|
|
82
|
+
s.files.add(f);
|
|
83
|
+
for (const slice of slicesTouching(index, f)) s.slices.add(slice);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
for (const slice of s.slices) {
|
|
87
|
+
if (kind === 'requirement' || kind === 'slice') for (const f of filesOf(index, slice)) if (!skip(f)) s.files.add(f);
|
|
88
|
+
for (const k of ['produces', 'consumes']) for (const e of index.out(slice, k)) s.contracts.add(e.to);
|
|
89
|
+
}
|
|
90
|
+
return s;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// impact(index, target) -> {target, contracts: [{id, label}], slices: [{id, name, repo, relations}],
|
|
94
|
+
// files: [path], repos: [name]}. Nothing found -> GraphError(2, `<target> is not in the graph`).
|
|
95
|
+
// `skip(file id)` is true for a file never counted as shared, e.g. bookkeeping(root, cfg).
|
|
96
|
+
export function impact(index, target, { skip = () => false } = {}) {
|
|
97
|
+
const s = start(index, target, skip);
|
|
98
|
+
if (!s) throw new GraphError(2, `${target} is not in the graph`);
|
|
99
|
+
const implementing = new Set(kindOf(s.target) === 'requirement' ? index.in(s.target, 'implements').map((e) => e.from) : []);
|
|
100
|
+
|
|
101
|
+
// Every listed slice and how it relates: implements, touched <k> shared files, produces or
|
|
102
|
+
// consumes a start contract.
|
|
103
|
+
const shared = new Map();
|
|
104
|
+
for (const f of s.files) {
|
|
105
|
+
for (const slice of slicesTouching(index, f)) shared.set(slice, (shared.get(slice) ?? 0) + 1);
|
|
106
|
+
}
|
|
107
|
+
const parties = new Map();
|
|
108
|
+
for (const c of [...s.contracts].sort(cmp)) {
|
|
109
|
+
for (const kind of ['produces', 'consumes']) {
|
|
110
|
+
for (const e of index.in(c, kind)) {
|
|
111
|
+
if (!parties.has(e.from)) parties.set(e.from, []);
|
|
112
|
+
const rel = `${kind} ${keyOf(c)}`;
|
|
113
|
+
if (!parties.get(e.from).includes(rel)) parties.get(e.from).push(rel);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const ids = [...new Set([...implementing, ...shared.keys(), ...parties.keys()])].filter((id) => index.node(id)).sort(cmp);
|
|
118
|
+
const slices = ids.map((id) => {
|
|
119
|
+
const node = index.node(id);
|
|
120
|
+
const relations = [];
|
|
121
|
+
if (implementing.has(id)) relations.push('implements');
|
|
122
|
+
if (shared.has(id)) relations.push(`touched ${shared.get(id)} shared files`);
|
|
123
|
+
relations.push(...(parties.get(id) ?? []));
|
|
124
|
+
return { id: keyOf(id), name: node.name ?? node.label ?? keyOf(id), repo: repoOf(node), relations };
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const files = [...s.files].map(keyOf).sort(cmp);
|
|
128
|
+
const repos = new Set(slices.map((x) => x.repo));
|
|
129
|
+
for (const f of s.files) for (const e of index.out(f, 'in')) if (kindOf(e.to) === 'repo') repos.add(keyOf(e.to));
|
|
130
|
+
const contracts = [...s.contracts].sort(cmp).map((c) => ({ id: keyOf(c), label: index.node(c)?.label ?? '' }));
|
|
131
|
+
return { target: s.target, contracts, slices, files, repos: [...repos].sort(cmp) };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// The text answer: four headed sections; an empty one says none.
|
|
135
|
+
export function impactLines(r) {
|
|
136
|
+
const section = (head, items) => [head, ...(items.length === 0 ? [' none'] : items.map((x) => ` ${x}`))];
|
|
137
|
+
return [
|
|
138
|
+
...section('contracts:', r.contracts.map((c) => `${c.id}${c.label ? ` ${c.label}` : ''}`)),
|
|
139
|
+
...section('slices:', r.slices.map((x) => `${x.id} repo ${x.repo} ${x.relations.join(', ')}`)),
|
|
140
|
+
...section('files:', r.files),
|
|
141
|
+
`repos: ${r.repos.length === 0 ? 'none' : r.repos.join(', ')}`,
|
|
142
|
+
];
|
|
143
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// Nodes and edges from the kit's own files (REQ-4.2): state files, verdict files and the journal.
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { parseLine } from '../journal.js';
|
|
4
|
+
import { re } from '../ids.js';
|
|
5
|
+
import { parseVerdict } from '../verdict.js';
|
|
6
|
+
import { nodeId } from './schema.js';
|
|
7
|
+
|
|
8
|
+
const lineOf = (text, needle) => {
|
|
9
|
+
const i = String(text).replace(/\r\n/g, '\n').split('\n').findIndex((l) => l.includes(needle));
|
|
10
|
+
return i === -1 ? 1 : i + 1;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// A state file: a patch on its slice (state, mergedAt, history), and the slice's pull request as a
|
|
14
|
+
// reference. A file that is not JSON gives a warning.
|
|
15
|
+
export function stateFragment(rel, text) {
|
|
16
|
+
let s;
|
|
17
|
+
try {
|
|
18
|
+
s = JSON.parse(text);
|
|
19
|
+
} catch {
|
|
20
|
+
return { nodes: [], edges: [], warnings: [`graph: ${rel} is not valid JSON`] };
|
|
21
|
+
}
|
|
22
|
+
if (!s || typeof s.slice !== 'string' || !re('sliceAddr').test(s.slice)) return { nodes: [], edges: [] };
|
|
23
|
+
const id = nodeId('slice', s.slice);
|
|
24
|
+
const history = (Array.isArray(s.history) ? s.history : []).map((h) => ({ to: h?.to ?? null, at: h?.at ?? null }));
|
|
25
|
+
const out = { nodes: [{ id, patch: true, state: s.state ?? null, mergedAt: s.mergedAt ?? null, history }], edges: [], prRefs: [] };
|
|
26
|
+
const n = s.pr?.number;
|
|
27
|
+
if (Number.isInteger(n) && n > 0) {
|
|
28
|
+
out.prRefs.push({ number: n, at: `${rel}:${lineOf(text, '"number"')}`, slice: id });
|
|
29
|
+
}
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const VERDICT_NAME = /^(P\d+)-(S-\d{2})(i?)-r([1-9]\d*)\.md$/;
|
|
34
|
+
|
|
35
|
+
// A verdict file `P<n>-S-<nn>[i]-r<k>.md`: a verdict node and its `in` edge to the slice.
|
|
36
|
+
export function verdictFragment(rel, text) {
|
|
37
|
+
const m = VERDICT_NAME.exec(path.posix.basename(rel));
|
|
38
|
+
if (!m) return { nodes: [], edges: [] };
|
|
39
|
+
const stem = path.posix.basename(rel, '.md');
|
|
40
|
+
const v = parseVerdict(text, rel);
|
|
41
|
+
const id = nodeId('verdict', stem);
|
|
42
|
+
const at = `${rel}:1`;
|
|
43
|
+
return {
|
|
44
|
+
nodes: [{ id, kind: 'verdict', label: v.verdict ?? 'unreadable', from: at, verdict: v.verdict, head: v.head, independent: m[3] === 'i', round: Number(m[4]) }],
|
|
45
|
+
edges: [{ kind: 'in', from: id, to: nodeId('slice', `${m[1]}/${m[2]}`), at }],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// A journal file: each line's decisions cited by its slice, at that line.
|
|
50
|
+
export function journalFragment(rel, text) {
|
|
51
|
+
const out = { nodes: [], edges: [] };
|
|
52
|
+
String(text).split('\n').forEach((line, i) => {
|
|
53
|
+
const p = parseLine(line);
|
|
54
|
+
if (!p || !re('sliceAddr').test(p.slice)) return;
|
|
55
|
+
for (const d of new Set(p.decisions)) {
|
|
56
|
+
if (new RegExp(`^${re('decision').source}$`).test(d)) out.edges.push({ kind: 'cites', from: nodeId('slice', p.slice), to: nodeId('decision', d), at: `${rel}:${i + 1}` });
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// Reading the graph (S-18, S-19, S-20): queries and visualize never run git or call the host; they
|
|
2
|
+
// load graph.json and work on an in-memory index by id, by kind and by edge direction.
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { kitPaths } from '../paths.js';
|
|
6
|
+
import { GraphError, SCHEMA_VERSION } from './schema.js';
|
|
7
|
+
|
|
8
|
+
const posix = (p) => p.split(path.sep).join('/');
|
|
9
|
+
|
|
10
|
+
export const graphFile = (root, cfg) => path.join(kitPaths(root, cfg).graph, 'graph.json');
|
|
11
|
+
|
|
12
|
+
export function loadGraph(root, cfg) {
|
|
13
|
+
const file = graphFile(root, cfg);
|
|
14
|
+
const rel = posix(path.relative(root, file));
|
|
15
|
+
let text;
|
|
16
|
+
try {
|
|
17
|
+
text = fs.readFileSync(file, 'utf8');
|
|
18
|
+
} catch (e) {
|
|
19
|
+
if (e.code === 'ENOENT') throw new GraphError(1, `no graph at ${rel}; run slicekit graph`);
|
|
20
|
+
throw e;
|
|
21
|
+
}
|
|
22
|
+
let graph;
|
|
23
|
+
try {
|
|
24
|
+
graph = JSON.parse(text);
|
|
25
|
+
} catch {
|
|
26
|
+
throw new GraphError(1, `${rel} is not valid JSON; run slicekit graph --full`);
|
|
27
|
+
}
|
|
28
|
+
if (graph?.schemaVersion !== SCHEMA_VERSION) {
|
|
29
|
+
throw new GraphError(1, `${rel} is schema ${graph?.schemaVersion}; this kit reads ${SCHEMA_VERSION}; run slicekit graph --full`);
|
|
30
|
+
}
|
|
31
|
+
return graph;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// What a user types for a path: backslashes to /, a leading ./ and a trailing / removed.
|
|
35
|
+
export const normalisePath = (p) => String(p).replace(/\\/g, '/').replace(/^(\.\/)+/, '').replace(/\/+$/, '');
|
|
36
|
+
|
|
37
|
+
const ID_FORMS = [
|
|
38
|
+
[/^REQ-\d+\.\d+$/, 'requirement'],
|
|
39
|
+
[/^D-\d+$/, 'decision'],
|
|
40
|
+
[/^G-\d+$/, 'gap'],
|
|
41
|
+
[/^C-\d+$/, 'contract'],
|
|
42
|
+
[/^P\d+\/S-\d{2}$/, 'slice'],
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
export function indexGraph(graph) {
|
|
46
|
+
const byId = new Map();
|
|
47
|
+
const kinds = new Map();
|
|
48
|
+
const outs = new Map();
|
|
49
|
+
const ins = new Map();
|
|
50
|
+
for (const n of graph.nodes ?? []) {
|
|
51
|
+
byId.set(n.id, n);
|
|
52
|
+
if (!kinds.has(n.kind)) kinds.set(n.kind, []);
|
|
53
|
+
kinds.get(n.kind).push(n);
|
|
54
|
+
}
|
|
55
|
+
for (const e of graph.edges ?? []) {
|
|
56
|
+
if (!outs.has(e.from)) outs.set(e.from, []);
|
|
57
|
+
outs.get(e.from).push(e);
|
|
58
|
+
if (!ins.has(e.to)) ins.set(e.to, []);
|
|
59
|
+
ins.get(e.to).push(e);
|
|
60
|
+
}
|
|
61
|
+
const pick = (map, id, kind) => (map.get(id) ?? []).filter((e) => kind === undefined || e.kind === kind);
|
|
62
|
+
const commits = kinds.get('commit') ?? [];
|
|
63
|
+
|
|
64
|
+
function find(text) {
|
|
65
|
+
const t = String(text ?? '').trim();
|
|
66
|
+
if (t === '') return null;
|
|
67
|
+
for (const [form, kind] of ID_FORMS) if (form.test(t)) return byId.has(`${kind}:${t}`) ? `${kind}:${t}` : null;
|
|
68
|
+
if (/^P\d+$/.test(t)) return byId.has(`phase:${t}`) ? `phase:${t}` : byId.has(`release:${t}`) ? `release:${t}` : null;
|
|
69
|
+
const pr = /^#(\d+)$/.exec(t);
|
|
70
|
+
if (pr) return byId.has(`pull-request:${pr[1]}`) ? `pull-request:${pr[1]}` : null;
|
|
71
|
+
// A workspace repository's pull request, <name>#<n> (S-20).
|
|
72
|
+
if (/^[A-Za-z0-9._-]+#\d+$/.test(t)) return byId.has(`pull-request:${t}`) ? `pull-request:${t}` : null;
|
|
73
|
+
if (/^[0-9a-f]{7,40}$/i.test(t)) {
|
|
74
|
+
const lower = t.toLowerCase();
|
|
75
|
+
const hits = commits.filter((c) => c.id.slice('commit:'.length).startsWith(lower));
|
|
76
|
+
if (hits.length === 1) return hits[0].id;
|
|
77
|
+
if (hits.length > 1) return null;
|
|
78
|
+
}
|
|
79
|
+
if (byId.has(t)) return t;
|
|
80
|
+
const p = normalisePath(t);
|
|
81
|
+
for (const kind of ['file', 'test']) if (byId.has(`${kind}:${p}`)) return `${kind}:${p}`;
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
graph,
|
|
87
|
+
node: (id) => byId.get(id) ?? null,
|
|
88
|
+
byKind: (kind) => kinds.get(kind) ?? [],
|
|
89
|
+
out: (id, kind) => pick(outs, id, kind),
|
|
90
|
+
in: (id, kind) => pick(ins, id, kind),
|
|
91
|
+
find,
|
|
92
|
+
};
|
|
93
|
+
}
|
package/src/graph/prs.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// Pull requests in the graph (REQ-4.2, C-1): their numbers come from the local files and commit
|
|
2
|
+
// subjects; each answer is cached under the graph directory as {pr}, the host's answer alone. A
|
|
3
|
+
// merged answer is never fetched again; an open or closed one is fetched again whenever the host can
|
|
4
|
+
// be reached (a closed pull request can be reopened and merged, D-52), and the cached answer is used,
|
|
5
|
+
// marked stale, only when it cannot. An entry written by an
|
|
6
|
+
// earlier kit with a `key` still reads; the key is ignored (P3/S-34, issue #38).
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import { GitHostError, GitHostNotFound } from '../adapters/githost/errors.js';
|
|
10
|
+
import { GH_NOT_FOUND } from '../adapters/githost/github.js';
|
|
11
|
+
import { cmp, nodeId } from './schema.js';
|
|
12
|
+
|
|
13
|
+
const MERGE = /^Merge pull request #(\d+) from /;
|
|
14
|
+
const SQUASH = /\(#(\d+)\)\s*$/;
|
|
15
|
+
// Only a merge is final: GitHub lets a closed pull request be reopened (P3/S-34 review H-1, D-52).
|
|
16
|
+
const FINAL = new Set(['MERGED']);
|
|
17
|
+
|
|
18
|
+
// number -> {at, slice, sliceAt, releases: [{id, at}]}; the state file's place first, then a commit's.
|
|
19
|
+
export function prNumbers(fragments, commits) {
|
|
20
|
+
const refs = new Map();
|
|
21
|
+
const get = (n) => {
|
|
22
|
+
if (!refs.has(n)) refs.set(n, { at: null, slice: null, sliceAt: null, releases: [] });
|
|
23
|
+
return refs.get(n);
|
|
24
|
+
};
|
|
25
|
+
const prRefs = fragments.flatMap((f) => f.prRefs ?? []).sort((a, b) => cmp(a.at, b.at));
|
|
26
|
+
for (const r of prRefs.filter((x) => x.slice)) {
|
|
27
|
+
const e = get(r.number);
|
|
28
|
+
if (e.slice === null) Object.assign(e, { at: r.at, slice: r.slice, sliceAt: r.at });
|
|
29
|
+
}
|
|
30
|
+
for (const c of [...commits].sort((a, b) => cmp(a.sha, b.sha))) {
|
|
31
|
+
const m = MERGE.exec(c.subject) ?? SQUASH.exec(c.subject);
|
|
32
|
+
if (!m) continue;
|
|
33
|
+
const e = get(Number(m[1]));
|
|
34
|
+
if (e.at === null) e.at = c.sha;
|
|
35
|
+
}
|
|
36
|
+
for (const r of prRefs.filter((x) => x.release)) {
|
|
37
|
+
const e = get(r.number);
|
|
38
|
+
if (e.at === null) e.at = r.at;
|
|
39
|
+
if (!e.releases.some((x) => x.id === r.release)) e.releases.push({ id: r.release, at: r.at });
|
|
40
|
+
}
|
|
41
|
+
return new Map([...refs].sort(([a], [b]) => a - b));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// A workspace repository's pull requests are cached apart from the program repository's (S-20).
|
|
45
|
+
const cacheFile = (dir, n, repo) => path.join(dir, repo ? `pr-${repo}-${n}.json` : `pr-${n}.json`);
|
|
46
|
+
|
|
47
|
+
function readCache(dir, n, repo) {
|
|
48
|
+
try {
|
|
49
|
+
const c = JSON.parse(fs.readFileSync(cacheFile(dir, n, repo), 'utf8'));
|
|
50
|
+
return c && typeof c === 'object' && c.pr ? c : null;
|
|
51
|
+
} catch {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function writeCache(dir, n, repo, entry) {
|
|
57
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
58
|
+
const file = cacheFile(dir, n, repo);
|
|
59
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
60
|
+
fs.writeFileSync(tmp, `${JSON.stringify(entry, null, 2)}\n`);
|
|
61
|
+
fs.renameSync(tmp, file);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const TITLE_SLICE = /\[(P\d+\/S-\d{2})\]/;
|
|
65
|
+
|
|
66
|
+
// A pull request of the program repository is pull-request:<n>; one of workspace repository <repo> is
|
|
67
|
+
// pull-request:<repo>#<n> and carries `repo` (S-20).
|
|
68
|
+
function prNode(n, ref, pr, stale, verdicts, repo) {
|
|
69
|
+
const key = repo ? `${repo}#${n}` : `#${n}`;
|
|
70
|
+
const id = nodeId('pull-request', repo ? key : n);
|
|
71
|
+
const node = { id, kind: 'pull-request', label: pr.title ?? '', from: key, number: n, url: pr.url ?? null, state: pr.state ?? null, mergedAt: pr.mergedAt ?? null, headSha: pr.headSha ?? null };
|
|
72
|
+
if (repo) node.repo = repo;
|
|
73
|
+
if (stale) node.stale = true;
|
|
74
|
+
const edges = [];
|
|
75
|
+
const fromTitle = TITLE_SLICE.exec(pr.title ?? '')?.[1];
|
|
76
|
+
const slice = fromTitle ? nodeId('slice', fromTitle) : ref.slice;
|
|
77
|
+
const at = ref.at ?? key;
|
|
78
|
+
if (slice) {
|
|
79
|
+
edges.push({ kind: 'in', from: id, to: slice, at: ref.slice === slice && ref.sliceAt ? ref.sliceAt : at });
|
|
80
|
+
for (const v of verdicts.get(slice) ?? []) edges.push({ kind: 'reviewed-by', from: id, to: v.id, at: v.from });
|
|
81
|
+
}
|
|
82
|
+
for (const r of ref.releases) edges.push({ kind: 'released-in', from: id, to: r.id, at: r.at });
|
|
83
|
+
return { node, edges };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// refs from prNumbers -> {nodes, edges, notes, fetched, cached}. `host` null means no host could be
|
|
87
|
+
// made; `verdicts` maps a slice node id to its verdict nodes, for the reviewed-by edges; `repo` names
|
|
88
|
+
// the workspace repository the numbers belong to, null for the program repository.
|
|
89
|
+
export function pullRequestNodes(refs, { host, cacheDir, verdicts = new Map(), skipped = null, repo = null } = {}) {
|
|
90
|
+
const nodes = [];
|
|
91
|
+
const edges = [];
|
|
92
|
+
const notes = [];
|
|
93
|
+
let fetched = 0;
|
|
94
|
+
let cached = 0;
|
|
95
|
+
let stopped = host == null;
|
|
96
|
+
if (skipped) notes.push(skipped);
|
|
97
|
+
const add = (n, ref, pr, stale) => {
|
|
98
|
+
const r = prNode(n, ref, pr, stale, verdicts, repo);
|
|
99
|
+
nodes.push(r.node);
|
|
100
|
+
edges.push(...r.edges);
|
|
101
|
+
};
|
|
102
|
+
for (const [n, ref] of refs) {
|
|
103
|
+
const hit = readCache(cacheDir, n, repo);
|
|
104
|
+
// A merged answer is final. An open or closed one is asked again whenever the host can be reached:
|
|
105
|
+
// a merge does not move the recorded head, so no key would say it changed (S-17 review H-1), and a
|
|
106
|
+
// closed pull request can be reopened (P3/S-34 review H-1).
|
|
107
|
+
if (hit && FINAL.has(hit.pr.state)) {
|
|
108
|
+
cached++;
|
|
109
|
+
add(n, ref, hit.pr, false);
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
if (!stopped) {
|
|
113
|
+
try {
|
|
114
|
+
const { body: _body, ...pr } = host.getPullRequest(n);
|
|
115
|
+
writeCache(cacheDir, n, repo, { pr });
|
|
116
|
+
fetched++;
|
|
117
|
+
add(n, ref, pr, false);
|
|
118
|
+
continue;
|
|
119
|
+
} catch (e) {
|
|
120
|
+
if (e instanceof GitHostNotFound) {
|
|
121
|
+
notes.push(`pull request ${repo ?? ''}#${n} is not on the host`);
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (!(e instanceof GitHostError)) throw e;
|
|
125
|
+
stopped = true;
|
|
126
|
+
const whose = repo ? ` of ${repo}` : '';
|
|
127
|
+
notes.push(e.message === GH_NOT_FOUND ? `pull requests${whose} skipped: gh not found` : `pull requests${whose} from the cache: ${e.message}`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (hit) {
|
|
131
|
+
cached++;
|
|
132
|
+
add(n, ref, hit.pr, true);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return { nodes, edges, notes, fetched, cached };
|
|
136
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// One line per node, and a tree of them, for the query commands (S-18, S-20).
|
|
2
|
+
import { keyOf } from './schema.js';
|
|
3
|
+
|
|
4
|
+
const join = (...parts) => parts.filter((p) => p !== undefined && p !== null && p !== '').join(' ');
|
|
5
|
+
|
|
6
|
+
export function nodeLine(node) {
|
|
7
|
+
const key = keyOf(node.id);
|
|
8
|
+
switch (node.kind) {
|
|
9
|
+
case 'requirement': return join('requirement', key, node.label);
|
|
10
|
+
case 'slice': return join('slice', key, node.name ?? node.label, node.state ? `(${node.state})` : undefined);
|
|
11
|
+
case 'test': return join('test', key);
|
|
12
|
+
case 'commit': return join('commit', key.slice(0, 7), node.subject ?? node.label);
|
|
13
|
+
case 'pull-request': return `${join('pull request', node.repo ? key : `#${node.number ?? key}`, node.url)}${node.stale ? ', stale' : ''}`;
|
|
14
|
+
case 'file': return join('file', key);
|
|
15
|
+
case 'release': return join('release', key);
|
|
16
|
+
case 'contract': return join('contract', key, node.label);
|
|
17
|
+
case 'decision': return join('decision', key);
|
|
18
|
+
case 'verdict': return join('verdict', key, node.verdict ?? node.label);
|
|
19
|
+
default: return join(node.kind, key, node.label);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// {node, children} -> lines, two spaces per level, children in the order given.
|
|
24
|
+
export function renderTree(tree, depth = 0) {
|
|
25
|
+
const out = [`${' '.repeat(depth)}${nodeLine(tree.node)}`];
|
|
26
|
+
for (const c of tree.children ?? []) out.push(...renderTree(c, depth + 1));
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// The traceability graph's schema (REQ-4.1, D-13, D-45): the node kinds, the edge kinds with the
|
|
2
|
+
// (from kind, to kind) pairs each admits, node ids, validation and the one byte-stable serialisation.
|
|
3
|
+
export const SCHEMA_VERSION = 1;
|
|
4
|
+
|
|
5
|
+
export const NODE_KINDS = Object.freeze([
|
|
6
|
+
'intake', 'decision', 'requirement', 'gap', 'contract', 'phase', 'slice', 'test', 'commit',
|
|
7
|
+
'pull-request', 'file', 'release', 'runbook-section', 'repo', 'verdict',
|
|
8
|
+
]);
|
|
9
|
+
|
|
10
|
+
const pairs = (...list) => Object.freeze(list.map((p) => Object.freeze(p.split('>'))));
|
|
11
|
+
export const EDGE_KINDS = Object.freeze({
|
|
12
|
+
cites: pairs(
|
|
13
|
+
'requirement>decision', 'requirement>intake', 'slice>decision', 'gap>decision', 'gap>requirement',
|
|
14
|
+
'decision>decision', 'runbook-section>slice', 'runbook-section>requirement', 'runbook-section>decision',
|
|
15
|
+
),
|
|
16
|
+
covers: pairs('test>requirement'),
|
|
17
|
+
implements: pairs('slice>requirement'),
|
|
18
|
+
touched: pairs('commit>file'),
|
|
19
|
+
in: pairs('commit>slice', 'slice>phase', 'file>repo', 'test>repo', 'pull-request>slice', 'verdict>slice'),
|
|
20
|
+
'reviewed-by': pairs('pull-request>verdict'),
|
|
21
|
+
'released-in': pairs('pull-request>release'),
|
|
22
|
+
produces: pairs('slice>contract'),
|
|
23
|
+
consumes: pairs('slice>contract'),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const nodeId = (kind, key) => `${kind}:${key}`;
|
|
27
|
+
export const kindOf = (id) => {
|
|
28
|
+
const i = String(id).indexOf(':');
|
|
29
|
+
return i === -1 ? null : id.slice(0, i);
|
|
30
|
+
};
|
|
31
|
+
export const keyOf = (id) => String(id).slice(String(id).indexOf(':') + 1);
|
|
32
|
+
|
|
33
|
+
// code 1: refused (no graph, a bad graph); code 2: usage or an unknown id.
|
|
34
|
+
export class GraphError extends Error {
|
|
35
|
+
constructor(code, message) {
|
|
36
|
+
super(message);
|
|
37
|
+
this.name = 'GraphError';
|
|
38
|
+
this.code = code;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const NODE_SET = new Set(NODE_KINDS);
|
|
43
|
+
const hasOwn = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
|
|
44
|
+
|
|
45
|
+
// Every problem, in a stable order: the version, then each node in the order given, then each edge.
|
|
46
|
+
export function validateGraph(graph) {
|
|
47
|
+
const out = [];
|
|
48
|
+
if (graph?.schemaVersion !== SCHEMA_VERSION) out.push(`schemaVersion is ${graph?.schemaVersion}, not ${SCHEMA_VERSION}`);
|
|
49
|
+
const kinds = new Map();
|
|
50
|
+
for (const n of graph?.nodes ?? []) {
|
|
51
|
+
if (!NODE_SET.has(n.kind)) out.push(`node ${n.id} has kind ${n.kind}, which is not a node kind`);
|
|
52
|
+
else if (!String(n.id).startsWith(`${n.kind}:`)) out.push(`node ${n.id} does not start with ${n.kind}:`);
|
|
53
|
+
if (typeof n.from !== 'string' || n.from === '') out.push(`node ${n.id} has no from`);
|
|
54
|
+
if (kinds.has(n.id)) out.push(`duplicate node ${n.id}`);
|
|
55
|
+
else kinds.set(n.id, n.kind);
|
|
56
|
+
}
|
|
57
|
+
for (const e of graph?.edges ?? []) {
|
|
58
|
+
if (typeof e.at !== 'string' || e.at === '') out.push(`edge ${e.kind} from ${e.from} to ${e.to} has no at`);
|
|
59
|
+
if (!hasOwn(EDGE_KINDS, e.kind)) {
|
|
60
|
+
out.push(`edge kind ${e.kind} is not an edge kind`);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const a = kinds.get(e.from) ?? kindOf(e.from);
|
|
64
|
+
const b = kinds.get(e.to) ?? kindOf(e.to);
|
|
65
|
+
if (!EDGE_KINDS[e.kind].some(([x, y]) => x === a && y === b)) {
|
|
66
|
+
out.push(`edge ${e.kind} runs from ${a} to ${b}, which ${e.kind} does not allow`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Code-unit order, never the locale.
|
|
73
|
+
export const cmp = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
74
|
+
const edgeCmp = (x, y) => cmp(x.from, y.from) || cmp(x.kind, y.kind) || cmp(x.to, y.to) || cmp(x.at, y.at);
|
|
75
|
+
|
|
76
|
+
// Keys first in `head`, then the rest sorted; nested values written with sorted keys too.
|
|
77
|
+
function ordered(value, head = []) {
|
|
78
|
+
if (Array.isArray(value)) return value.map((v) => ordered(v));
|
|
79
|
+
if (value === null || typeof value !== 'object') return value;
|
|
80
|
+
const out = {};
|
|
81
|
+
for (const k of head) if (hasOwn(value, k) && value[k] !== undefined) out[k] = ordered(value[k]);
|
|
82
|
+
for (const k of Object.keys(value).filter((k) => !head.includes(k)).sort(cmp)) {
|
|
83
|
+
if (value[k] !== undefined) out[k] = ordered(value[k]);
|
|
84
|
+
}
|
|
85
|
+
return out;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const NODE_HEAD = ['id', 'kind', 'label', 'from'];
|
|
89
|
+
const EDGE_HEAD = ['kind', 'from', 'to', 'at'];
|
|
90
|
+
|
|
91
|
+
// The graph file's text: one node or edge per line, sorted, keys in a fixed order, ending in a newline.
|
|
92
|
+
export function serializeGraph(graph) {
|
|
93
|
+
const nodes = [...(graph.nodes ?? [])].sort((a, b) => cmp(a.id, b.id));
|
|
94
|
+
const edges = [...(graph.edges ?? [])].sort(edgeCmp);
|
|
95
|
+
const list = (items, head) => (items.length === 0 ? '[]' : `[\n${items.map((x) => JSON.stringify(ordered(x, head))).join(',\n')}\n]`);
|
|
96
|
+
const top = [
|
|
97
|
+
`"schemaVersion":${JSON.stringify(graph.schemaVersion)}`,
|
|
98
|
+
`"builtAt":${JSON.stringify(graph.builtAt ?? null)}`,
|
|
99
|
+
`"defaultBranch":${JSON.stringify(graph.defaultBranch ?? null)}`,
|
|
100
|
+
`"sha":${JSON.stringify(graph.sha ?? null)}`,
|
|
101
|
+
`"repos":${JSON.stringify((graph.repos ?? []).map((r) => ordered(r, ['name', 'sha'])))}`,
|
|
102
|
+
`"nodes":${list(nodes, NODE_HEAD)}`,
|
|
103
|
+
`"edges":${list(edges, EDGE_HEAD)}`,
|
|
104
|
+
];
|
|
105
|
+
return `{\n${top.join(',\n')}\n}\n`;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export const sortEdges = (edges) => [...edges].sort(edgeCmp);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// shipped (REQ-4.5): a release record's pull requests and the requirements their slices implement.
|
|
2
|
+
// Reads the index only.
|
|
3
|
+
import { GraphError, cmp, kindOf } from './schema.js';
|
|
4
|
+
|
|
5
|
+
const PHASE = /^P\d+$/;
|
|
6
|
+
|
|
7
|
+
export function shipped(index, phase) {
|
|
8
|
+
const p = String(phase ?? '').trim();
|
|
9
|
+
const release = PHASE.test(p) ? index.node(`release:${p}`) : null;
|
|
10
|
+
if (!release) {
|
|
11
|
+
if (PHASE.test(p) && index.node(`phase:${p}`)) throw new GraphError(1, `${p} has no release record`);
|
|
12
|
+
throw new GraphError(2, `${p} is not in the graph`);
|
|
13
|
+
}
|
|
14
|
+
const pullRequests = index
|
|
15
|
+
.in(release.id, 'released-in')
|
|
16
|
+
.filter((e) => kindOf(e.from) === 'pull-request')
|
|
17
|
+
.map((e) => index.node(e.from))
|
|
18
|
+
.filter(Boolean)
|
|
19
|
+
.sort((a, b) => (a.number ?? 0) - (b.number ?? 0) || cmp(a.id, b.id));
|
|
20
|
+
const reqs = new Map();
|
|
21
|
+
for (const pr of pullRequests) {
|
|
22
|
+
for (const s of index.out(pr.id, 'in')) {
|
|
23
|
+
if (kindOf(s.to) !== 'slice') continue;
|
|
24
|
+
for (const e of index.out(s.to, 'implements')) {
|
|
25
|
+
const r = index.node(e.to);
|
|
26
|
+
if (r?.kind === 'requirement') reqs.set(r.id, r);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const requirements = [...reqs.values()].sort((a, b) => cmp(a.id, b.id));
|
|
31
|
+
return { release, path: String(release.from ?? '').replace(/:\d+$/, ''), requirements, pullRequests };
|
|
32
|
+
}
|