@benchcutlogic/repo-checks 0.0.0-stage → 0.2.2

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/config.js ADDED
@@ -0,0 +1,137 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ export const CORE_CHECKS = [
4
+ 'doc-paths',
5
+ 'agent-contracts',
6
+ 'agents-budget',
7
+ 'lockfile-registry',
8
+ 'unique-error-tags',
9
+ 'effect-boundaries',
10
+ 'svelte-tokens',
11
+ 'storybook-catalog'
12
+ ];
13
+ export const ALL_CHECKS = [...CORE_CHECKS, 'web', 'prose'];
14
+ export const DEFAULT_FORBIDDEN_IMPORTS = [
15
+ 'cloudflare:',
16
+ 'alchemy',
17
+ 'better-auth',
18
+ 'node:fs',
19
+ 'node:http',
20
+ 'node:https',
21
+ 'apps/'
22
+ ];
23
+ export const DEFAULT_ALLOWED_RUNTIME_ENTRIES = [
24
+ '**/runtime.ts',
25
+ '**/client-runtime.ts',
26
+ '**/worker.ts',
27
+ '**/cli.ts',
28
+ '**/main.ts',
29
+ '**/hooks.server.ts',
30
+ '**/*.test.ts',
31
+ '**/*.spec.ts',
32
+ '**/test/**',
33
+ '**/tests/**',
34
+ '**/scripts/**'
35
+ ];
36
+ export const DEFAULT_CONFIG = {
37
+ checks: CORE_CHECKS,
38
+ files: {
39
+ exclude: [],
40
+ respectGitignore: true
41
+ },
42
+ docPaths: {
43
+ files: ['AGENTS.md', 'CLAUDE.md', 'README.md', 'CONTRIBUTING.md', '.agents/skills/*/SKILL.md'],
44
+ ignorePaths: []
45
+ },
46
+ agentContracts: {
47
+ knownRuleIds: []
48
+ },
49
+ agentsBudget: {
50
+ warnBytes: 18_000,
51
+ maxBytes: 20_000
52
+ },
53
+ effectBoundaries: {
54
+ purePackages: ['packages/core'],
55
+ forbiddenImports: DEFAULT_FORBIDDEN_IMPORTS,
56
+ allowedRuntimeEntries: DEFAULT_ALLOWED_RUNTIME_ENTRIES
57
+ },
58
+ svelteTokens: {
59
+ globs: ['**/*.svelte', 'apps/*/src/**/*.css', 'packages/ui/src/**/*.svelte'],
60
+ ignores: ['**/*.stories.svelte', '**/app.css', '**/tokens.css', '**/theme.css']
61
+ },
62
+ storybook: {},
63
+ web: {
64
+ checks: ['sitemap', 'favicon', 'meta-jsonld', 'snippets'],
65
+ snippetFiles: ['README.md', 'AGENTS.md', '.agents/skills/*/SKILL.md', 'docs/**/*.md'],
66
+ unpublishedPackages: [],
67
+ titleMax: 60,
68
+ descriptionMax: 160
69
+ },
70
+ prose: {
71
+ globs: ['docs/**/*.md', 'src/content/**/*.md', 'src/content/**/*.mdx', 'content/**/*.md'],
72
+ titleMax: 60,
73
+ descriptionMax: 160,
74
+ bannedTerms: [],
75
+ slopMode: 'warn'
76
+ }
77
+ };
78
+ export function loadConfig(root) {
79
+ const configPath = join(root, 'bench-check.json');
80
+ if (!existsSync(configPath)) {
81
+ return DEFAULT_CONFIG;
82
+ }
83
+ const raw = JSON.parse(readFileSync(configPath, 'utf8'));
84
+ const unknownChecks = (raw.checks ?? []).filter((name) => !ALL_CHECKS.includes(name));
85
+ if (unknownChecks.length > 0) {
86
+ throw new Error(`${configPath}: unknown check name(s) ${unknownChecks.map((n) => `'${n}'`).join(', ')}. Valid names: ${ALL_CHECKS.join(', ')}.`);
87
+ }
88
+ return {
89
+ checks: raw.checks ?? DEFAULT_CONFIG.checks,
90
+ files: {
91
+ exclude: raw.files?.exclude ?? DEFAULT_CONFIG.files.exclude,
92
+ respectGitignore: raw.files?.respectGitignore ?? DEFAULT_CONFIG.files.respectGitignore
93
+ },
94
+ docPaths: {
95
+ files: raw.docPaths?.files ?? DEFAULT_CONFIG.docPaths.files,
96
+ ignorePaths: raw.docPaths?.ignorePaths ?? DEFAULT_CONFIG.docPaths.ignorePaths
97
+ },
98
+ agentContracts: {
99
+ knownRuleIds: raw.agentContracts?.knownRuleIds ?? DEFAULT_CONFIG.agentContracts.knownRuleIds,
100
+ effectV4: raw.agentContracts?.effectV4
101
+ },
102
+ agentsBudget: {
103
+ warnBytes: raw.agentsBudget?.warnBytes ?? DEFAULT_CONFIG.agentsBudget.warnBytes,
104
+ maxBytes: raw.agentsBudget?.maxBytes ?? DEFAULT_CONFIG.agentsBudget.maxBytes
105
+ },
106
+ effectBoundaries: {
107
+ purePackages: raw.effectBoundaries?.purePackages ?? DEFAULT_CONFIG.effectBoundaries.purePackages,
108
+ forbiddenImports: raw.effectBoundaries?.forbiddenImports ?? DEFAULT_CONFIG.effectBoundaries.forbiddenImports,
109
+ allowedRuntimeEntries: raw.effectBoundaries?.allowedRuntimeEntries ??
110
+ DEFAULT_CONFIG.effectBoundaries.allowedRuntimeEntries
111
+ },
112
+ svelteTokens: {
113
+ globs: raw.svelteTokens?.globs ?? DEFAULT_CONFIG.svelteTokens.globs,
114
+ ignores: raw.svelteTokens?.ignores ?? DEFAULT_CONFIG.svelteTokens.ignores
115
+ },
116
+ storybook: {
117
+ catalogFile: raw.storybook?.catalogFile
118
+ },
119
+ web: {
120
+ buildDir: raw.web?.buildDir,
121
+ baseUrl: raw.web?.baseUrl,
122
+ checks: raw.web?.checks ?? DEFAULT_CONFIG.web.checks,
123
+ snippetFiles: raw.web?.snippetFiles ?? DEFAULT_CONFIG.web.snippetFiles,
124
+ unpublishedPackages: raw.web?.unpublishedPackages ?? DEFAULT_CONFIG.web.unpublishedPackages,
125
+ titleMax: raw.web?.titleMax ?? DEFAULT_CONFIG.web.titleMax,
126
+ descriptionMax: raw.web?.descriptionMax ?? DEFAULT_CONFIG.web.descriptionMax
127
+ },
128
+ prose: {
129
+ globs: raw.prose?.globs ?? DEFAULT_CONFIG.prose.globs,
130
+ titleMax: raw.prose?.titleMax ?? DEFAULT_CONFIG.prose.titleMax,
131
+ descriptionMax: raw.prose?.descriptionMax ?? DEFAULT_CONFIG.prose.descriptionMax,
132
+ allowedTags: raw.prose?.allowedTags,
133
+ bannedTerms: raw.prose?.bannedTerms ?? DEFAULT_CONFIG.prose.bannedTerms,
134
+ slopMode: raw.prose?.slopMode ?? DEFAULT_CONFIG.prose.slopMode
135
+ }
136
+ };
137
+ }
@@ -0,0 +1,32 @@
1
+ export declare function toPosixPath(p: string): string;
2
+ export declare function matchesGlob(relPath: string, glob: string): boolean;
3
+ export declare function matchesAnyGlob(relPath: string, globs: ReadonlyArray<string>): boolean;
4
+ /**
5
+ * True when `files.exclude` removes `relPath` from every check. A directory counts as
6
+ * excluded when the globs match the path itself or anything inside it, so both
7
+ * `.agents/skills` and `.agents/skills/**` exclude the whole tree.
8
+ */
9
+ export declare function isExcludedPath(relPath: string, exclude: ReadonlyArray<string>): boolean;
10
+ export declare function walkFiles(root: string, options?: {
11
+ readonly skipDirs?: ReadonlySet<string>;
12
+ readonly includeHidden?: boolean;
13
+ }): string[];
14
+ export interface RepoFileOptions {
15
+ /** Globs (relative to the root) removed from every check's file list. */
16
+ readonly exclude?: ReadonlyArray<string>;
17
+ /** List files through `git ls-files` so git-ignored paths are skipped. Defaults to true. */
18
+ readonly respectGitignore?: boolean;
19
+ }
20
+ /**
21
+ * Lists tracked and untracked, non-ignored files under `root` with git. Returns null when
22
+ * `root` is not inside a git work tree or git is unavailable, so callers fall back to a
23
+ * directory walk. Returns an empty list when git succeeds and every file is ignored.
24
+ */
25
+ export declare function listGitFiles(root: string): string[] | null;
26
+ export declare function listRepoFiles(root: string, options?: RepoFileOptions & {
27
+ readonly skipDirs?: ReadonlySet<string>;
28
+ }): string[];
29
+ export declare function collectMatchingFiles(root: string, globs: ReadonlyArray<string>, ignores?: ReadonlyArray<string>, options?: RepoFileOptions): string[];
30
+ export declare function readTextSafe(filePath: string): string | null;
31
+ export declare function isDirectory(filePath: string): boolean;
32
+ export declare function lineNumberAt(text: string, index: number): number;
@@ -0,0 +1,198 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
3
+ import { join, relative } from 'node:path';
4
+ const DEFAULT_SKIP_DIRS = new Set([
5
+ '.git',
6
+ 'node_modules',
7
+ 'dist',
8
+ 'build',
9
+ '.svelte-kit',
10
+ '.turbo',
11
+ '.pnpm-store',
12
+ 'coverage',
13
+ 'storybook-static'
14
+ ]);
15
+ export function toPosixPath(p) {
16
+ return p.replace(/\\/g, '/');
17
+ }
18
+ function globToRegExp(glob) {
19
+ const normalized = toPosixPath(glob).replace(/^\.\//, '');
20
+ let regex = '^';
21
+ let i = 0;
22
+ while (i < normalized.length) {
23
+ const ch = normalized[i];
24
+ if (ch === '*') {
25
+ if (normalized[i + 1] === '*') {
26
+ if (normalized[i + 2] === '/') {
27
+ regex += '(?:.*/)?';
28
+ i += 3;
29
+ continue;
30
+ }
31
+ regex += '.*';
32
+ i += 2;
33
+ continue;
34
+ }
35
+ regex += '[^/]*';
36
+ i += 1;
37
+ continue;
38
+ }
39
+ if (ch === '?') {
40
+ regex += '[^/]';
41
+ i += 1;
42
+ continue;
43
+ }
44
+ if (ch === '{') {
45
+ const end = normalized.indexOf('}', i);
46
+ if (end !== -1) {
47
+ const inner = normalized
48
+ .slice(i + 1, end)
49
+ .split(',')
50
+ .map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
51
+ .join('|');
52
+ regex += `(?:${inner})`;
53
+ i = end + 1;
54
+ continue;
55
+ }
56
+ }
57
+ regex += ch.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
58
+ i += 1;
59
+ }
60
+ regex += '$';
61
+ return new RegExp(regex);
62
+ }
63
+ export function matchesGlob(relPath, glob) {
64
+ return globToRegExp(glob).test(toPosixPath(relPath));
65
+ }
66
+ export function matchesAnyGlob(relPath, globs) {
67
+ return globs.some((glob) => matchesGlob(relPath, glob));
68
+ }
69
+ /**
70
+ * True when `files.exclude` removes `relPath` from every check. A directory counts as
71
+ * excluded when the globs match the path itself or anything inside it, so both
72
+ * `.agents/skills` and `.agents/skills/**` exclude the whole tree.
73
+ */
74
+ export function isExcludedPath(relPath, exclude) {
75
+ if (exclude.length === 0)
76
+ return false;
77
+ if (matchesAnyGlob(relPath, exclude) || matchesAnyGlob(`${relPath}/__any__`, exclude))
78
+ return true;
79
+ // A file is also excluded when one of its ancestor directories is.
80
+ const segments = relPath.split('/');
81
+ for (let i = 1; i < segments.length; i += 1) {
82
+ const dir = segments.slice(0, i).join('/');
83
+ if (matchesAnyGlob(dir, exclude) || matchesAnyGlob(`${dir}/__any__`, exclude))
84
+ return true;
85
+ }
86
+ return false;
87
+ }
88
+ export function walkFiles(root, options) {
89
+ const skipDirs = options?.skipDirs ?? DEFAULT_SKIP_DIRS;
90
+ const includeHidden = options?.includeHidden ?? true;
91
+ const out = [];
92
+ if (!existsSync(root)) {
93
+ return out;
94
+ }
95
+ function visit(dir) {
96
+ let entries;
97
+ try {
98
+ entries = readdirSync(dir, { withFileTypes: true });
99
+ }
100
+ catch {
101
+ // directory unreadable or removed during walk
102
+ return;
103
+ }
104
+ for (const entry of entries) {
105
+ if (!includeHidden && entry.name.startsWith('.')) {
106
+ continue;
107
+ }
108
+ const full = join(dir, entry.name);
109
+ if (entry.isDirectory()) {
110
+ if (skipDirs.has(entry.name)) {
111
+ continue;
112
+ }
113
+ visit(full);
114
+ }
115
+ else if (entry.isFile()) {
116
+ out.push(toPosixPath(relative(root, full)));
117
+ }
118
+ }
119
+ }
120
+ visit(root);
121
+ return out.sort();
122
+ }
123
+ function isSkippedPath(relPath, skipDirs) {
124
+ const segments = relPath.split('/');
125
+ segments.pop();
126
+ return segments.some((segment) => skipDirs.has(segment));
127
+ }
128
+ /**
129
+ * Lists tracked and untracked, non-ignored files under `root` with git. Returns null when
130
+ * `root` is not inside a git work tree or git is unavailable, so callers fall back to a
131
+ * directory walk. Returns an empty list when git succeeds and every file is ignored.
132
+ */
133
+ export function listGitFiles(root) {
134
+ const result = spawnSync('git', ['ls-files', '--cached', '--others', '--exclude-standard', '-z'], {
135
+ cwd: root,
136
+ encoding: 'utf8',
137
+ maxBuffer: 256 * 1024 * 1024
138
+ });
139
+ if (result.error || result.status !== 0) {
140
+ // not a git work tree, or git is not installed: the caller walks the directory instead
141
+ return null;
142
+ }
143
+ const files = new Set();
144
+ for (const entry of result.stdout.split('\0')) {
145
+ if (!entry || entry.endsWith('/'))
146
+ continue;
147
+ const rel = toPosixPath(entry);
148
+ try {
149
+ if (statSync(join(root, rel)).isFile())
150
+ files.add(rel);
151
+ }
152
+ catch {
153
+ // tracked file deleted from the working tree
154
+ }
155
+ }
156
+ // An empty list from a successful command is a real answer (everything under the
157
+ // root is ignored); only a failed command falls back to walking the directory.
158
+ return [...files].sort();
159
+ }
160
+ export function listRepoFiles(root, options) {
161
+ const skipDirs = options?.skipDirs ?? DEFAULT_SKIP_DIRS;
162
+ const exclude = options?.exclude ?? [];
163
+ const fromGit = (options?.respectGitignore ?? true) ? listGitFiles(root) : null;
164
+ const all = fromGit
165
+ ? fromGit.filter((rel) => !isSkippedPath(rel, skipDirs))
166
+ : walkFiles(root, { skipDirs });
167
+ return exclude.length > 0 ? all.filter((rel) => !isExcludedPath(rel, exclude)) : all;
168
+ }
169
+ export function collectMatchingFiles(root, globs, ignores = [], options) {
170
+ return listRepoFiles(root, options).filter((rel) => matchesAnyGlob(rel, globs) && !matchesAnyGlob(rel, ignores));
171
+ }
172
+ export function readTextSafe(filePath) {
173
+ try {
174
+ return readFileSync(filePath, 'utf8');
175
+ }
176
+ catch {
177
+ // file missing or unreadable
178
+ return null;
179
+ }
180
+ }
181
+ export function isDirectory(filePath) {
182
+ try {
183
+ return statSync(filePath).isDirectory();
184
+ }
185
+ catch {
186
+ // missing path
187
+ return false;
188
+ }
189
+ }
190
+ export function lineNumberAt(text, index) {
191
+ let line = 1;
192
+ for (let i = 0; i < index && i < text.length; i += 1) {
193
+ if (text.charCodeAt(i) === 10) {
194
+ line += 1;
195
+ }
196
+ }
197
+ return line;
198
+ }
@@ -0,0 +1,25 @@
1
+ import { checkAgentContracts } from './checks/agent-contracts.js';
2
+ import { checkAgentsBudget } from './checks/agents-budget.js';
3
+ import { checkDocPaths } from './checks/doc-paths.js';
4
+ import { checkEffectBoundaries } from './checks/effect-boundaries.js';
5
+ import { checkLockfileRegistry } from './checks/lockfile-registry.js';
6
+ import { checkProse } from './checks/prose.js';
7
+ import { checkStorybookCatalog } from './checks/storybook-catalog.js';
8
+ import { checkSvelteTokens } from './checks/svelte-tokens.js';
9
+ import { checkUniqueErrorTags } from './checks/unique-error-tags.js';
10
+ import { checkWeb } from './checks/web.js';
11
+ import { ALL_CHECKS, CORE_CHECKS, DEFAULT_CONFIG, loadConfig } from './config.js';
12
+ import type { CheckContext, CheckName, CheckResult, FetchLike, ResolvedBenchCheckConfig, RunSummary } from './types.js';
13
+ export type { BannedTermRule, BenchCheckConfig, CheckContext, CheckName, CheckResult, FetchLike, Finding, ResolvedBenchCheckConfig, RunSummary, Severity } from './types.js';
14
+ export { ALL_CHECKS, CORE_CHECKS, DEFAULT_CONFIG, loadConfig, checkAgentContracts, checkAgentsBudget, checkDocPaths, checkEffectBoundaries, checkLockfileRegistry, checkProse, checkStorybookCatalog, checkSvelteTokens, checkUniqueErrorTags, checkWeb };
15
+ export interface RunOptions {
16
+ readonly root: string;
17
+ readonly checks?: ReadonlyArray<CheckName>;
18
+ readonly config?: ResolvedBenchCheckConfig;
19
+ readonly strict?: boolean;
20
+ readonly buildDir?: string;
21
+ readonly fetchFn?: FetchLike;
22
+ }
23
+ export declare function runSingleCheck(name: CheckName, ctx: CheckContext): Promise<CheckResult>;
24
+ export declare function runChecks(options: RunOptions): Promise<RunSummary>;
25
+ export declare function formatSummaryText(summary: RunSummary): string;
package/dist/index.js ADDED
@@ -0,0 +1,97 @@
1
+ import { resolve } from 'node:path';
2
+ import { checkAgentContracts } from './checks/agent-contracts.js';
3
+ import { checkAgentsBudget } from './checks/agents-budget.js';
4
+ import { checkDocPaths } from './checks/doc-paths.js';
5
+ import { checkEffectBoundaries } from './checks/effect-boundaries.js';
6
+ import { checkLockfileRegistry } from './checks/lockfile-registry.js';
7
+ import { checkProse } from './checks/prose.js';
8
+ import { checkStorybookCatalog } from './checks/storybook-catalog.js';
9
+ import { checkSvelteTokens } from './checks/svelte-tokens.js';
10
+ import { checkUniqueErrorTags } from './checks/unique-error-tags.js';
11
+ import { checkWeb } from './checks/web.js';
12
+ import { ALL_CHECKS, CORE_CHECKS, DEFAULT_CONFIG, loadConfig } from './config.js';
13
+ import { isDirectory } from './fs-utils.js';
14
+ export { ALL_CHECKS, CORE_CHECKS, DEFAULT_CONFIG, loadConfig, checkAgentContracts, checkAgentsBudget, checkDocPaths, checkEffectBoundaries, checkLockfileRegistry, checkProse, checkStorybookCatalog, checkSvelteTokens, checkUniqueErrorTags, checkWeb };
15
+ export async function runSingleCheck(name, ctx) {
16
+ switch (name) {
17
+ case 'doc-paths':
18
+ return checkDocPaths(ctx);
19
+ case 'agent-contracts':
20
+ return checkAgentContracts(ctx);
21
+ case 'agents-budget':
22
+ return checkAgentsBudget(ctx);
23
+ case 'lockfile-registry':
24
+ return checkLockfileRegistry(ctx);
25
+ case 'unique-error-tags':
26
+ return checkUniqueErrorTags(ctx);
27
+ case 'effect-boundaries':
28
+ return checkEffectBoundaries(ctx);
29
+ case 'svelte-tokens':
30
+ return checkSvelteTokens(ctx);
31
+ case 'storybook-catalog':
32
+ return checkStorybookCatalog(ctx);
33
+ case 'web':
34
+ return checkWeb(ctx);
35
+ case 'prose':
36
+ return checkProse(ctx);
37
+ }
38
+ }
39
+ function createDefaultFetchFn() {
40
+ return async (url) => {
41
+ const res = await fetch(url, { redirect: 'manual' });
42
+ return {
43
+ status: res.status,
44
+ ok: res.ok,
45
+ headers: { get: (name) => res.headers.get(name) },
46
+ text: () => res.text(),
47
+ arrayBuffer: () => res.arrayBuffer()
48
+ };
49
+ };
50
+ }
51
+ export async function runChecks(options) {
52
+ const root = resolve(options.root);
53
+ if (!isDirectory(root)) {
54
+ throw new Error(`Repository root directory does not exist: ${root}`);
55
+ }
56
+ const config = options.config ?? loadConfig(root);
57
+ const checksToRun = options.checks ?? config.checks;
58
+ const strict = options.strict ?? false;
59
+ const ctx = {
60
+ root,
61
+ config,
62
+ strict,
63
+ buildDirOverride: options.buildDir,
64
+ fetchFn: options.fetchFn ?? (config.web.baseUrl ? createDefaultFetchFn() : undefined)
65
+ };
66
+ const results = [];
67
+ for (const name of checksToRun) {
68
+ results.push(await runSingleCheck(name, ctx));
69
+ }
70
+ const findings = results.flatMap((r) => r.findings);
71
+ const errorCount = findings.filter((f) => f.severity === 'error').length;
72
+ const warningCount = findings.filter((f) => f.severity === 'warning').length;
73
+ return {
74
+ root,
75
+ results,
76
+ findings,
77
+ errorCount,
78
+ warningCount,
79
+ passed: errorCount === 0
80
+ };
81
+ }
82
+ export function formatSummaryText(summary) {
83
+ const lines = [];
84
+ for (const result of summary.results) {
85
+ const errs = result.findings.filter((f) => f.severity === 'error').length;
86
+ const warns = result.findings.filter((f) => f.severity === 'warning').length;
87
+ const badge = errs > 0 ? 'FAIL' : warns > 0 ? 'WARN' : 'PASS';
88
+ lines.push(`[${badge}] ${result.check} (${errs} errors, ${warns} warnings)`);
89
+ for (const f of result.findings) {
90
+ const loc = f.file ? (f.line ? `${f.file}:${f.line}` : f.file) : '<repo>';
91
+ const ruleTag = f.rule ? ` [${f.rule}]` : '';
92
+ lines.push(` ${f.severity.toUpperCase()} ${loc}${ruleTag}: ${f.message}`);
93
+ }
94
+ }
95
+ lines.push(`Summary: ${summary.passed ? 'PASS' : 'FAIL'} — ${summary.errorCount} error(s), ${summary.warningCount} warning(s) across ${summary.results.length} check(s).`);
96
+ return lines.join('\n');
97
+ }
@@ -0,0 +1,142 @@
1
+ export type Severity = 'error' | 'warning';
2
+ export type CheckName = 'doc-paths' | 'agent-contracts' | 'agents-budget' | 'lockfile-registry' | 'unique-error-tags' | 'effect-boundaries' | 'svelte-tokens' | 'storybook-catalog' | 'web' | 'prose';
3
+ export interface Finding {
4
+ readonly check: CheckName;
5
+ readonly severity: Severity;
6
+ readonly file?: string;
7
+ readonly line?: number;
8
+ readonly rule?: string;
9
+ readonly message: string;
10
+ }
11
+ export interface CheckResult {
12
+ readonly check: CheckName;
13
+ readonly findings: ReadonlyArray<Finding>;
14
+ }
15
+ export interface BannedTermRule {
16
+ readonly pattern: string;
17
+ readonly reason: string;
18
+ readonly flags?: string;
19
+ }
20
+ export interface BenchCheckConfig {
21
+ readonly checks?: ReadonlyArray<CheckName>;
22
+ /** Which repository files the checks see. */
23
+ readonly files?: {
24
+ /** Globs relative to the root that no check reads, e.g. `["vendor/**"]`. */
25
+ readonly exclude?: ReadonlyArray<string>;
26
+ /** Skip git-ignored files by listing them with `git ls-files`. Defaults to true. */
27
+ readonly respectGitignore?: boolean;
28
+ };
29
+ readonly docPaths?: {
30
+ readonly files?: ReadonlyArray<string>;
31
+ readonly ignorePaths?: ReadonlyArray<string>;
32
+ };
33
+ readonly agentContracts?: {
34
+ readonly knownRuleIds?: ReadonlyArray<string>;
35
+ readonly effectV4?: boolean;
36
+ };
37
+ readonly agentsBudget?: {
38
+ readonly warnBytes?: number;
39
+ readonly maxBytes?: number;
40
+ };
41
+ readonly effectBoundaries?: {
42
+ readonly purePackages?: ReadonlyArray<string>;
43
+ readonly forbiddenImports?: ReadonlyArray<string>;
44
+ readonly allowedRuntimeEntries?: ReadonlyArray<string>;
45
+ };
46
+ readonly svelteTokens?: {
47
+ readonly globs?: ReadonlyArray<string>;
48
+ readonly ignores?: ReadonlyArray<string>;
49
+ };
50
+ readonly storybook?: {
51
+ readonly catalogFile?: string;
52
+ };
53
+ readonly web?: {
54
+ readonly buildDir?: string;
55
+ readonly baseUrl?: string;
56
+ readonly checks?: ReadonlyArray<'sitemap' | 'favicon' | 'meta-jsonld' | 'snippets'>;
57
+ readonly snippetFiles?: ReadonlyArray<string>;
58
+ readonly unpublishedPackages?: ReadonlyArray<string>;
59
+ readonly titleMax?: number;
60
+ readonly descriptionMax?: number;
61
+ };
62
+ readonly prose?: {
63
+ readonly globs?: ReadonlyArray<string>;
64
+ readonly titleMax?: number;
65
+ readonly descriptionMax?: number;
66
+ readonly allowedTags?: ReadonlyArray<string>;
67
+ readonly bannedTerms?: ReadonlyArray<BannedTermRule>;
68
+ readonly slopMode?: 'warn' | 'error' | 'off';
69
+ };
70
+ }
71
+ export interface ResolvedBenchCheckConfig {
72
+ readonly checks: ReadonlyArray<CheckName>;
73
+ readonly files: {
74
+ readonly exclude: ReadonlyArray<string>;
75
+ readonly respectGitignore: boolean;
76
+ };
77
+ readonly docPaths: {
78
+ readonly files: ReadonlyArray<string>;
79
+ readonly ignorePaths: ReadonlyArray<string>;
80
+ };
81
+ readonly agentContracts: {
82
+ readonly knownRuleIds: ReadonlyArray<string>;
83
+ readonly effectV4?: boolean;
84
+ };
85
+ readonly agentsBudget: {
86
+ readonly warnBytes: number;
87
+ readonly maxBytes: number;
88
+ };
89
+ readonly effectBoundaries: {
90
+ readonly purePackages: ReadonlyArray<string>;
91
+ readonly forbiddenImports: ReadonlyArray<string>;
92
+ readonly allowedRuntimeEntries: ReadonlyArray<string>;
93
+ };
94
+ readonly svelteTokens: {
95
+ readonly globs: ReadonlyArray<string>;
96
+ readonly ignores: ReadonlyArray<string>;
97
+ };
98
+ readonly storybook: {
99
+ readonly catalogFile?: string;
100
+ };
101
+ readonly web: {
102
+ readonly buildDir?: string;
103
+ readonly baseUrl?: string;
104
+ readonly checks: ReadonlyArray<'sitemap' | 'favicon' | 'meta-jsonld' | 'snippets'>;
105
+ readonly snippetFiles: ReadonlyArray<string>;
106
+ readonly unpublishedPackages: ReadonlyArray<string>;
107
+ readonly titleMax: number;
108
+ readonly descriptionMax: number;
109
+ };
110
+ readonly prose: {
111
+ readonly globs: ReadonlyArray<string>;
112
+ readonly titleMax: number;
113
+ readonly descriptionMax: number;
114
+ readonly allowedTags?: ReadonlyArray<string>;
115
+ readonly bannedTerms: ReadonlyArray<BannedTermRule>;
116
+ readonly slopMode: 'warn' | 'error' | 'off';
117
+ };
118
+ }
119
+ export type FetchLike = (input: string) => Promise<{
120
+ readonly status: number;
121
+ readonly ok: boolean;
122
+ readonly headers: {
123
+ get(name: string): string | null;
124
+ };
125
+ readonly text: () => Promise<string>;
126
+ readonly arrayBuffer: () => Promise<ArrayBuffer>;
127
+ }>;
128
+ export interface CheckContext {
129
+ readonly root: string;
130
+ readonly config: ResolvedBenchCheckConfig;
131
+ readonly strict: boolean;
132
+ readonly buildDirOverride?: string;
133
+ readonly fetchFn?: FetchLike;
134
+ }
135
+ export interface RunSummary {
136
+ readonly root: string;
137
+ readonly results: ReadonlyArray<CheckResult>;
138
+ readonly findings: ReadonlyArray<Finding>;
139
+ readonly errorCount: number;
140
+ readonly warningCount: number;
141
+ readonly passed: boolean;
142
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};