@venizia/vulcan-okf 0.4.8 → 0.4.9-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/package.json +3 -4
- package/src/check/changelogs.ts +74 -74
- package/src/check/command.ts +14 -12
- package/src/check/house.ts +116 -108
- package/src/cli.ts +3 -1
- package/src/common/record.ts +6 -0
- package/src/coverage-report/axes.ts +72 -66
- package/src/coverage-report/command.ts +14 -12
- package/src/generate/command.ts +15 -13
- package/src/generate/contents-files.ts +34 -30
- package/src/generate/contents.ts +27 -22
- package/src/generate/define.ts +25 -23
- package/src/generate/pages.ts +39 -37
- package/src/generate/regions.ts +51 -53
- package/src/generate/registry.ts +56 -51
- package/src/generate/renderers.ts +7 -10
- package/src/lib.ts +84 -82
- package/src/project/reader.ts +74 -71
- package/src/source/collectors.ts +190 -182
- package/src/source/scanner.ts +65 -61
- package/src/spec/conformance.ts +28 -27
- package/src/spec/frontmatter.ts +26 -27
- package/src/viz/builder.ts +93 -93
- package/src/viz/client/explorer.ts +25 -25
- package/src/viz/client/frame.ts +14 -12
- package/src/viz/client/html.ts +8 -4
- package/src/viz/client/main.ts +2 -2
- package/src/viz/client/markdown.ts +96 -94
- package/src/viz/client/strings.ts +12 -10
- package/src/viz/client/theme.ts +3 -3
- package/src/viz/common/constants.ts +0 -1
- package/src/viz/copy.ts +17 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venizia/vulcan-okf",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.9-1",
|
|
4
4
|
"description": "VULCAN knowledge tooling: OKF v0.2 conformance check (plus --strict house rules), gen, coverage and the offline graph explorer for a project's .agents/knowledge bundle. Bun-only.",
|
|
5
5
|
"homepage": "https://github.com/VENIZIA-AI/vulcan/tree/main/packages/okf",
|
|
6
6
|
"bugs": {
|
|
@@ -47,11 +47,10 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/bun": "1.4.3",
|
|
49
49
|
"@types/cytoscape-fcose": "2.2.5",
|
|
50
|
-
"@venizia/dev-configs": "0.4.
|
|
50
|
+
"@venizia/dev-configs": "0.4.7-0",
|
|
51
51
|
"eslint": "10.13.0",
|
|
52
52
|
"oxlint": "1.89.0",
|
|
53
|
-
"oxlint-tsgolint": "7.0.2004"
|
|
54
|
-
"typescript": "^6.0.3"
|
|
53
|
+
"oxlint-tsgolint": "7.0.2004"
|
|
55
54
|
},
|
|
56
55
|
"engines": {
|
|
57
56
|
"bun": ">=1.4.4"
|
package/src/check/changelogs.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
2
|
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
3
3
|
import { join, relative } from 'node:path';
|
|
4
|
-
import {
|
|
4
|
+
import { RecordValue } from '../common/record.ts';
|
|
5
|
+
import { OkfProject } from '../project/index.ts';
|
|
5
6
|
|
|
6
7
|
const DATED_ENTRY = /^\d{4}-\d{2}-\d{2}-.*\.md$/;
|
|
7
8
|
const FRONTMATTER = /^---\r?\n([\s\S]*?)\r?\n---/;
|
|
@@ -10,14 +11,11 @@ const RELEASE_OVERRIDE = /^(.+)@([^@]+)$/;
|
|
|
10
11
|
|
|
11
12
|
type TRecord = Record<string, unknown>;
|
|
12
13
|
|
|
13
|
-
const isRecord = (opts: { value: unknown }): opts is { value: TRecord } =>
|
|
14
|
-
typeof opts.value === 'object' && opts.value !== null && !Array.isArray(opts.value);
|
|
15
|
-
|
|
16
14
|
const frontmatterOf = (opts: { text: string }): TRecord => {
|
|
17
15
|
const block = FRONTMATTER.exec(opts.text)?.[1];
|
|
18
16
|
const parsed = { value: block === undefined ? undefined : Bun.YAML.parse(block) };
|
|
19
17
|
|
|
20
|
-
return isRecord(parsed) ? parsed.value : {};
|
|
18
|
+
return RecordValue.isRecord(parsed) ? parsed.value : {};
|
|
21
19
|
};
|
|
22
20
|
|
|
23
21
|
/** The tag a release override names, by one template of the project; a `<date>` part matches any date. */
|
|
@@ -41,89 +39,91 @@ const tagsOf = (opts: { root: string }): string[] => {
|
|
|
41
39
|
: [];
|
|
42
40
|
};
|
|
43
41
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const names = new Map(project.packages.map((entry) => [entry.name, entry.dir]));
|
|
58
|
-
const problems: string[] = [];
|
|
59
|
-
let tags: string[] | undefined;
|
|
60
|
-
|
|
61
|
-
for (const file of readdirSync(directory)
|
|
62
|
-
.filter((name) => DATED_ENTRY.test(name))
|
|
63
|
-
.sort()) {
|
|
64
|
-
const path = relative(project.root, join(directory, file));
|
|
65
|
-
let frontmatter: TRecord;
|
|
66
|
-
|
|
67
|
-
// One broken entry is one problem; the rest of the directory is still checked.
|
|
68
|
-
try {
|
|
69
|
-
frontmatter = frontmatterOf({ text: readFileSync(join(directory, file), 'utf8') });
|
|
70
|
-
} catch (error) {
|
|
71
|
-
problems.push(
|
|
72
|
-
`changelog: ${path}: the frontmatter is not valid YAML (${error instanceof Error ? error.message : String(error)})`,
|
|
73
|
-
);
|
|
74
|
-
continue;
|
|
42
|
+
export class ChangelogCheck {
|
|
43
|
+
/**
|
|
44
|
+
* Project Contract v1, C3: every dated changelog entry declares the packages it covers by npm name -
|
|
45
|
+
* atlas reads that list and never the prose. An optional `release: '<npm name>@<version>'` places an
|
|
46
|
+
* entry git would place wrong (a backfill); it must name a tag that exists.
|
|
47
|
+
*/
|
|
48
|
+
static collectProblems(): string[] {
|
|
49
|
+
const project = OkfProject.read();
|
|
50
|
+
const directory = project.changelogs;
|
|
51
|
+
|
|
52
|
+
if (directory === undefined || !existsSync(directory)) {
|
|
53
|
+
return [];
|
|
75
54
|
}
|
|
76
55
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
problems.push(
|
|
81
|
-
`changelog: ${path} declares no packages - add \`packages: [<npm name>, ...]\` (\`vulcan x atlas changelogs migrate\` fills it)`,
|
|
82
|
-
);
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
56
|
+
const names = new Map(project.packages.map((entry) => [entry.name, entry.dir]));
|
|
57
|
+
const problems: string[] = [];
|
|
58
|
+
let tags: string[] | undefined;
|
|
85
59
|
|
|
86
|
-
const
|
|
60
|
+
for (const file of readdirSync(directory)
|
|
61
|
+
.filter((name) => DATED_ENTRY.test(name))
|
|
62
|
+
.sort()) {
|
|
63
|
+
const path = relative(project.root, join(directory, file));
|
|
64
|
+
let frontmatter: TRecord;
|
|
87
65
|
|
|
88
|
-
|
|
89
|
-
|
|
66
|
+
// One broken entry is one problem; the rest of the directory is still checked.
|
|
67
|
+
try {
|
|
68
|
+
frontmatter = frontmatterOf({ text: readFileSync(join(directory, file), 'utf8') });
|
|
69
|
+
} catch (error) {
|
|
90
70
|
problems.push(
|
|
91
|
-
`changelog: ${path}
|
|
71
|
+
`changelog: ${path}: the frontmatter is not valid YAML (${error instanceof Error ? error.message : String(error)})`,
|
|
92
72
|
);
|
|
73
|
+
continue;
|
|
93
74
|
}
|
|
94
|
-
}
|
|
95
75
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
76
|
+
// `packages: []` is a decision - an entry about no package, such as repository tooling. Only a
|
|
77
|
+
// missing list is undecided.
|
|
78
|
+
if (!Array.isArray(frontmatter.packages)) {
|
|
79
|
+
problems.push(
|
|
80
|
+
`changelog: ${path} declares no packages - add \`packages: [<npm name>, ...]\` (\`vulcan x atlas changelogs migrate\` fills it)`,
|
|
81
|
+
);
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
99
84
|
|
|
100
|
-
|
|
101
|
-
const dir = override === null ? undefined : names.get(override[1]);
|
|
85
|
+
const declared: unknown[] = frontmatter.packages;
|
|
102
86
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
87
|
+
for (const name of declared) {
|
|
88
|
+
if (typeof name !== 'string' || !names.has(name)) {
|
|
89
|
+
problems.push(
|
|
90
|
+
`changelog: ${path} names '${String(name)}', not a declared package's npm name`,
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
109
94
|
|
|
110
|
-
|
|
95
|
+
if (typeof frontmatter.release !== 'string') {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
111
98
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
);
|
|
99
|
+
const override = RELEASE_OVERRIDE.exec(frontmatter.release);
|
|
100
|
+
const dir = override === null ? undefined : names.get(override[1]);
|
|
115
101
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
102
|
+
if (override === null || dir === undefined) {
|
|
103
|
+
problems.push(
|
|
104
|
+
`changelog: ${path}: release '${frontmatter.release}' is not '<declared npm name>@<version>'`,
|
|
105
|
+
);
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
121
108
|
|
|
122
|
-
|
|
123
|
-
|
|
109
|
+
tags ??= tagsOf({ root: project.root });
|
|
110
|
+
|
|
111
|
+
const patterns = [project.tagPattern, ...project.legacyTagPatterns].map((template) =>
|
|
112
|
+
tagPatternOf({ template, dir, version: override[2] }),
|
|
124
113
|
);
|
|
114
|
+
|
|
115
|
+
if (!tags.some((tag) => patterns.some((pattern) => pattern.test(tag)))) {
|
|
116
|
+
const expected = project.tagPattern
|
|
117
|
+
.replace(/<(?:dir|package)>/g, dir)
|
|
118
|
+
.replace(/<version>/g, override[2])
|
|
119
|
+
.replace(/<date>/g, 'YYYY-MM-DD');
|
|
120
|
+
|
|
121
|
+
problems.push(
|
|
122
|
+
`changelog: ${path}: release '${frontmatter.release}' names no tag (${expected})`,
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
125
|
}
|
|
126
|
-
}
|
|
127
126
|
|
|
128
|
-
|
|
129
|
-
}
|
|
127
|
+
return problems;
|
|
128
|
+
}
|
|
129
|
+
}
|
package/src/check/command.ts
CHANGED
|
@@ -1,36 +1,38 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import { join, relative } from 'node:path';
|
|
3
3
|
import { RESERVED_FILES } from '../config.ts';
|
|
4
|
-
import {
|
|
5
|
-
import { IssueSeverities, OkfVersions,
|
|
4
|
+
import { OkfProject } from '../project/index.ts';
|
|
5
|
+
import { IssueSeverities, OkfVersions, BundleConformance } from '../spec/index.ts';
|
|
6
6
|
import type { IBundleFile, IConformanceIssue } from '../spec/index.ts';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { GenerationRegistry } from '../generate/index.ts';
|
|
8
|
+
import { HouseCheck } from './house.ts';
|
|
9
|
+
import { SourceScanner } from '../source/index.ts';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
walkFiles({ dir:
|
|
11
|
+
const readBundleFiles = (): IBundleFile[] =>
|
|
12
|
+
SourceScanner.walkFiles({ dir: OkfProject.read().bundle })
|
|
13
13
|
.filter((file) => file.endsWith('.md'))
|
|
14
14
|
.map((file) => ({
|
|
15
|
-
path: relative(
|
|
15
|
+
path: relative(OkfProject.read().bundle, file),
|
|
16
16
|
text: readFileSync(file, 'utf8'),
|
|
17
17
|
}));
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
`${repoRelative({ path: join(
|
|
19
|
+
const formatIssue = (opts: { issue: IConformanceIssue }): string =>
|
|
20
|
+
`${SourceScanner.repoRelative({ path: join(OkfProject.read().bundle, opts.issue.file) })}: ${opts.issue.rule} ${opts.issue.message}`;
|
|
21
21
|
|
|
22
22
|
/** The house rules on top of OKF conformance: links resolve, docs style, structural coverage, freshness. */
|
|
23
23
|
|
|
24
24
|
export const check = async (opts: { strict: boolean }): Promise<void> => {
|
|
25
25
|
const files = readBundleFiles();
|
|
26
|
-
const issues =
|
|
26
|
+
const issues = BundleConformance.check({ files });
|
|
27
27
|
const warnings = issues.filter((issue) => issue.severity === IssueSeverities.WARNING);
|
|
28
28
|
const problems = issues
|
|
29
29
|
.filter((issue) => issue.severity === IssueSeverities.ERROR)
|
|
30
30
|
.map((issue) => formatIssue({ issue }));
|
|
31
31
|
|
|
32
32
|
if (opts.strict) {
|
|
33
|
-
|
|
33
|
+
const generation = await GenerationRegistry.load();
|
|
34
|
+
|
|
35
|
+
problems.push(...HouseCheck.collectProblems({ files, ...generation }));
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
if (warnings.length) {
|
package/src/check/house.ts
CHANGED
|
@@ -1,43 +1,21 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { REGENERATE_HINT } from '../config.ts';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { OkfProject } from '../project/index.ts';
|
|
5
|
+
import { ConceptLoader, MarkdownText } from '../lib.ts';
|
|
6
6
|
import type { Concept } from '../lib.ts';
|
|
7
7
|
import type { IBundleFile } from '../spec/index.ts';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
8
|
+
import { CoverageAxes } from '../coverage-report/axes.ts';
|
|
9
|
+
import { ContentsFiles } from '../generate/contents-files.ts';
|
|
10
|
+
import { ChangelogCheck } from './changelogs.ts';
|
|
11
|
+
import { GeneratedPages, ManagedRegion } from '../generate/index.ts';
|
|
12
12
|
import type { ILoadedRegion, ILoadedRenderer } from '../generate/index.ts';
|
|
13
|
-
import {
|
|
13
|
+
import { SourceCollector, SourceScanner } from '../source/index.ts';
|
|
14
14
|
|
|
15
15
|
// --- docs style ---
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* Repo docs rules, enforced on prose (see check step 3). To write a forbidden literal - as the
|
|
19
|
-
* concept defining these rules must - put it in a code span; `stripCode` removes those first.
|
|
20
|
-
*/
|
|
21
|
-
export const styleRules = (opts: { brand: string }): { pattern: RegExp; message: string }[] => {
|
|
22
|
-
const spelling = brandSpelling({ brand: opts.brand });
|
|
23
|
-
|
|
24
|
-
return [
|
|
25
|
-
{ pattern: /[—–]/, message: 'use a hyphen, not an em-dash or en-dash' },
|
|
26
|
-
...(spelling === undefined
|
|
27
|
-
? []
|
|
28
|
-
: [
|
|
29
|
-
{
|
|
30
|
-
pattern: new RegExp(spelling.source),
|
|
31
|
-
message: `the brand is always written ${opts.brand}`,
|
|
32
|
-
},
|
|
33
|
-
]),
|
|
34
|
-
];
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
// --- freshness ---
|
|
38
|
-
|
|
39
17
|
/** Compare generated content ignoring trailing whitespace, so an editor's final newline is not "stale". */
|
|
40
|
-
|
|
18
|
+
const sameContent = (opts: { left: string; right: string }): boolean => {
|
|
41
19
|
const normalize = (value: string) =>
|
|
42
20
|
value
|
|
43
21
|
.split('\n')
|
|
@@ -48,112 +26,142 @@ export const sameContent = (opts: { left: string; right: string }): boolean => {
|
|
|
48
26
|
return normalize(opts.left) === normalize(opts.right);
|
|
49
27
|
};
|
|
50
28
|
|
|
51
|
-
export
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
29
|
+
export class HouseCheck {
|
|
30
|
+
/**
|
|
31
|
+
* Repo docs rules, enforced on prose (see check step 3). To write a forbidden literal - as the
|
|
32
|
+
* concept defining these rules must - put it in a code span; `MarkdownText.stripCode` removes those first.
|
|
33
|
+
*/
|
|
34
|
+
static styleRules(opts: { brand: string }): { pattern: RegExp; message: string }[] {
|
|
35
|
+
const spelling = SourceCollector.brandSpelling({ brand: opts.brand });
|
|
36
|
+
|
|
37
|
+
return [
|
|
38
|
+
{ pattern: /[—–]/, message: 'use a hyphen, not an em-dash or en-dash' },
|
|
39
|
+
...(spelling === undefined
|
|
40
|
+
? []
|
|
41
|
+
: [
|
|
42
|
+
{
|
|
43
|
+
pattern: new RegExp(spelling.source),
|
|
44
|
+
message: `the brand is always written ${opts.brand}`,
|
|
45
|
+
},
|
|
46
|
+
]),
|
|
47
|
+
];
|
|
67
48
|
}
|
|
68
49
|
|
|
69
|
-
|
|
50
|
+
static collectProblems(opts: {
|
|
51
|
+
files: IBundleFile[];
|
|
52
|
+
renderers: ILoadedRenderer[];
|
|
53
|
+
regions: ILoadedRegion[];
|
|
54
|
+
}): string[] {
|
|
55
|
+
const problems: string[] = [];
|
|
56
|
+
|
|
57
|
+
// A concept that fails to load is already reported by the spec layer; links need the loaded set.
|
|
58
|
+
let concepts: Concept[] = [];
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
concepts = ConceptLoader.load();
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error(
|
|
64
|
+
`check: links skipped - ${error instanceof Error ? error.message : String(error)}`,
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const ids = new Set(concepts.map((concept) => concept.id));
|
|
70
69
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
for (const concept of concepts) {
|
|
71
|
+
for (const target of concept.links) {
|
|
72
|
+
if (!ids.has(target)) {
|
|
73
|
+
problems.push(
|
|
74
|
+
`${SourceScanner.repoRelative({ path: concept.file })}: broken link -> ${target}.md`,
|
|
75
|
+
);
|
|
76
|
+
}
|
|
75
77
|
}
|
|
76
78
|
}
|
|
77
|
-
}
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
// Prose only: code is stripped, so the concept that defines a style rule can still quote what it forbids.
|
|
81
|
+
for (const file of opts.files) {
|
|
82
|
+
const prose = MarkdownText.stripCode({ text: file.text });
|
|
82
83
|
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
for (const rule of HouseCheck.styleRules({ brand: OkfProject.read().viz.brand })) {
|
|
85
|
+
const match = prose.match(rule.pattern);
|
|
85
86
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
if (match) {
|
|
88
|
+
problems.push(
|
|
89
|
+
`${SourceScanner.repoRelative({ path: join(OkfProject.read().bundle, file.path) })}: ${rule.message} (found "${match[0]}")`,
|
|
90
|
+
);
|
|
91
|
+
}
|
|
90
92
|
}
|
|
91
93
|
}
|
|
92
|
-
}
|
|
93
94
|
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
const filePaths = new Set(opts.files.map((file) => `/${file.path.replace(/\.md$/, '')}`));
|
|
96
|
+
const resources = CoverageAxes.resourceKeysOf({ concepts });
|
|
96
97
|
|
|
97
|
-
|
|
98
|
+
const { axes, problems: axisProblems } = CoverageAxes.collect();
|
|
98
99
|
|
|
99
|
-
|
|
100
|
+
problems.push(...axisProblems);
|
|
100
101
|
|
|
101
|
-
|
|
102
|
-
|
|
102
|
+
for (const axis of axes) {
|
|
103
|
+
const section = axis.name;
|
|
103
104
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
for (const name of axis.items) {
|
|
106
|
+
if (!CoverageAxes.isItemCovered({ axis, item: name, ids: filePaths, resources })) {
|
|
107
|
+
problems.push(`coverage: ${section}/${name} has no concept (${section}/${name}.md)`);
|
|
108
|
+
}
|
|
107
109
|
}
|
|
108
110
|
}
|
|
109
|
-
}
|
|
110
111
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
112
|
+
for (const region of opts.regions) {
|
|
113
|
+
if (!existsSync(region.file)) {
|
|
114
|
+
problems.push(
|
|
115
|
+
`freshness: region '${region.id}' host file missing (${SourceScanner.repoRelative({ path: region.file })})`,
|
|
116
|
+
);
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
118
119
|
|
|
119
|
-
|
|
120
|
+
let actual: string;
|
|
120
121
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
122
|
+
// Broken markers are the person's to fix by hand - gen refuses them, so never call them stale.
|
|
123
|
+
try {
|
|
124
|
+
actual = ManagedRegion.extract({
|
|
125
|
+
text: readFileSync(region.file, 'utf8'),
|
|
126
|
+
id: region.id,
|
|
127
|
+
file: SourceScanner.repoRelative({ path: region.file }),
|
|
128
|
+
});
|
|
129
|
+
} catch (error) {
|
|
130
|
+
problems.push(
|
|
131
|
+
`freshness: ${(error instanceof Error ? error.message : String(error)).replace(/^okf: /, '')}`,
|
|
132
|
+
);
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
134
135
|
|
|
135
|
-
|
|
136
|
-
|
|
136
|
+
if (!sameContent({ left: actual, right: region.render() })) {
|
|
137
|
+
problems.push(`freshness: region '${region.id}' is stale - ${REGENERATE_HINT}`);
|
|
138
|
+
}
|
|
137
139
|
}
|
|
138
|
-
}
|
|
139
140
|
|
|
140
|
-
|
|
141
|
+
const pages = GeneratedPages.render({ renderers: opts.renderers });
|
|
141
142
|
|
|
142
|
-
|
|
143
|
-
|
|
143
|
+
for (const { path, content } of pages) {
|
|
144
|
+
const current = existsSync(path) ? readFileSync(path, 'utf8') : '';
|
|
144
145
|
|
|
145
|
-
|
|
146
|
-
|
|
146
|
+
if (!sameContent({ left: current, right: content })) {
|
|
147
|
+
problems.push(
|
|
148
|
+
`freshness: ${SourceScanner.repoRelative({ path })} is stale - ${REGENERATE_HINT}`,
|
|
149
|
+
);
|
|
150
|
+
}
|
|
147
151
|
}
|
|
148
|
-
}
|
|
149
152
|
|
|
150
|
-
|
|
151
|
-
|
|
153
|
+
// C3: every dated changelog entry declares its packages by npm name.
|
|
154
|
+
problems.push(...ChangelogCheck.collectProblems());
|
|
152
155
|
|
|
153
|
-
|
|
154
|
-
|
|
156
|
+
// A long agent-read file opens with its contents - an agent may read its first lines only.
|
|
157
|
+
problems.push(
|
|
158
|
+
...ContentsFiles.collectProblems({ skip: new Set(pages.map((page) => page.path)) }),
|
|
159
|
+
);
|
|
155
160
|
|
|
156
|
-
|
|
157
|
-
}
|
|
161
|
+
return problems;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// --- freshness ---
|
|
158
166
|
|
|
159
167
|
/** OKF conformance (errors fail, warnings print); `strict` adds the house rules. */
|
package/src/cli.ts
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** The one answer to "is this parsed YAML or JSON a plain object": a mapping, not an array, not null. */
|
|
2
|
+
export class RecordValue {
|
|
3
|
+
static isRecord(opts: { value: unknown }): opts is { value: Record<string, unknown> } {
|
|
4
|
+
return typeof opts.value === 'object' && opts.value !== null && !Array.isArray(opts.value);
|
|
5
|
+
}
|
|
6
|
+
}
|