rachnasutra 0.5.2 → 0.6.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/CHANGELOG.md +32 -1
- package/CITATION.cff +2 -2
- package/README.md +4 -4
- package/dist/audit.js +117 -18
- package/dist/baseline.js +52 -0
- package/dist/browser.js +35 -5
- package/dist/cli.js +140 -27
- package/dist/fsutil.js +11 -4
- package/dist/redact.js +17 -7
- package/dist/report.js +51 -17
- package/dist/rules.js +70 -19
- package/dist/verify.js +35 -7
- package/docs/cli-reference.md +16 -3
- package/docs/status.md +2 -2
- package/documents/rachnasutra/00-overview.md +13 -2
- package/documents/rachnasutra/01-executive-summary.md +3 -1
- package/documents/rachnasutra/02-functional-specification.md +1 -1
- package/documents/rachnasutra/03-architecture.md +4 -0
- package/documents/rachnasutra/04-technical-reference.md +12 -7
- package/documents/rachnasutra/05-user-guide.md +53 -3
- package/documents/rachnasutra/07-skills-and-agents.md +2 -0
- package/documents/rachnasutra/08-security-and-privacy.md +2 -1
- package/documents/rachnasutra/10-testing-and-evidence.md +9 -5
- package/documents/rachnasutra/11-deployment-and-ci.md +2 -0
- package/documents/rachnasutra/12-roadmap-and-status.md +2 -2
- package/documents/rachnasutra/13-maintainer-handbook.md +4 -0
- package/documents/rachnasutra/16-validation-and-benchmarks.md +12 -2
- package/documents/rachnasutra/18-quick-tour.md +120 -0
- package/documents/rachnasutra/19-real-world-scenarios.md +251 -0
- package/llms.txt +2 -0
- package/package.json +4 -2
- package/samples/broken-ui/latest.html +96 -73
- package/samples/broken-ui/latest.json +236 -25
- package/samples/broken-ui/latest.md +2 -2
- package/samples/broken-ui/latest.sarif +1 -1
- package/samples/good-ui/latest.html +27 -7
- package/samples/good-ui/latest.json +4 -3
- package/samples/good-ui/latest.md +2 -2
package/dist/rules.js
CHANGED
|
@@ -1,18 +1,50 @@
|
|
|
1
1
|
import { contrastRatio, parseColor } from './color.js';
|
|
2
2
|
import { TW_COLOR } from './tw-color.js';
|
|
3
3
|
import { excerpt } from './redact.js';
|
|
4
|
-
export const MARKUP_EXT = new Set(['.html', '.htm', '.jsx', '.tsx', '.vue', '.svelte', '.astro']);
|
|
5
|
-
export const STYLE_EXT = new Set(['.css', '.scss', '.less']);
|
|
4
|
+
export const MARKUP_EXT = new Set(['.html', '.htm', '.jsx', '.tsx', '.vue', '.svelte', '.astro', '.ejs', '.hbs', '.handlebars', '.njk', '.liquid', '.twig', '.erb', '.cshtml', '.php']);
|
|
5
|
+
export const STYLE_EXT = new Set(['.css', '.scss', '.less', '.pcss', '.postcss']);
|
|
6
6
|
const MAX_HITS_PER_RULE_PER_FILE = 15;
|
|
7
|
+
/** Per-file lookups, built once. Without them every hit rescans the file and large files take quadratic time. */
|
|
8
|
+
let memoText;
|
|
9
|
+
const memo = new Map();
|
|
10
|
+
let lineMemo;
|
|
11
|
+
/** Sorted start offsets of every match of a global regex in the text. */
|
|
12
|
+
function positions(text, re) {
|
|
13
|
+
if (text !== memoText) {
|
|
14
|
+
memo.clear();
|
|
15
|
+
memoText = text;
|
|
16
|
+
}
|
|
17
|
+
const key = `${re.source}/${re.flags}`;
|
|
18
|
+
let at = memo.get(key);
|
|
19
|
+
if (!at)
|
|
20
|
+
memo.set(key, (at = Array.from(text.matchAll(re), (m) => m.index)));
|
|
21
|
+
return at;
|
|
22
|
+
}
|
|
23
|
+
/** How many sorted offsets are below the index. */
|
|
24
|
+
function countBelow(at, index) {
|
|
25
|
+
let lo = 0;
|
|
26
|
+
let hi = at.length;
|
|
27
|
+
while (lo < hi) {
|
|
28
|
+
const mid = (lo + hi) >> 1;
|
|
29
|
+
if (at[mid] < index)
|
|
30
|
+
lo = mid + 1;
|
|
31
|
+
else
|
|
32
|
+
hi = mid;
|
|
33
|
+
}
|
|
34
|
+
return lo;
|
|
35
|
+
}
|
|
36
|
+
/** Offset of the last match before the index, or -1. */
|
|
37
|
+
const lastBefore = (text, re, index) => {
|
|
38
|
+
const at = positions(text, re);
|
|
39
|
+
return at[countBelow(at, index) - 1] ?? -1;
|
|
40
|
+
};
|
|
7
41
|
export function lineAt(text, index) {
|
|
8
|
-
|
|
9
|
-
for (let i = 0; i < index && i < text.length; i++)
|
|
10
|
-
if (text.charCodeAt(i) === 10)
|
|
11
|
-
n++;
|
|
12
|
-
return n;
|
|
42
|
+
return countBelow(positions(text, /\n/g), index) + 1;
|
|
13
43
|
}
|
|
14
44
|
function lineText(text, line) {
|
|
15
|
-
|
|
45
|
+
if (lineMemo?.text !== text)
|
|
46
|
+
lineMemo = { text, lines: text.split(/\r?\n/) };
|
|
47
|
+
return lineMemo.lines[line - 1] ?? '';
|
|
16
48
|
}
|
|
17
49
|
/** Attribute-aware tag matcher: tolerates `>` inside quoted values and JSX braces. */
|
|
18
50
|
const ATTRS = `((?:"[^"]*"|'[^']*'|\\{[^{}]*\\}|[^>"'{}])*)`;
|
|
@@ -31,8 +63,7 @@ const nonEmptyAttr = (attrs, name) => {
|
|
|
31
63
|
};
|
|
32
64
|
/** True when the index sits inside <pre>, <code>, a Jekyll highlight block or a Markdown fence (a code sample, not a document). */
|
|
33
65
|
function insideCode(t, index) {
|
|
34
|
-
const
|
|
35
|
-
const count = (re) => (before.match(re) ?? []).length;
|
|
66
|
+
const count = (re) => countBelow(positions(t, re), index);
|
|
36
67
|
return count(/<(pre|code)\b/gi) > count(/<\/(pre|code)>/gi) || count(/\{%\s*highlight/g) > count(/\{%\s*endhighlight/g) || count(/```/g) % 2 === 1;
|
|
37
68
|
}
|
|
38
69
|
/** Template or runtime-localisation syntax means the final text or markup is not visible to a static scan. */
|
|
@@ -63,9 +94,26 @@ function contentName(inner) {
|
|
|
63
94
|
return 'named';
|
|
64
95
|
return /<[a-z]/i.test(inner) ? 'no-text' : 'empty';
|
|
65
96
|
}
|
|
97
|
+
const DIRECTIVE = /(?:<!--|\/\*|\/\/|\{#|\{\{!-{0,2}|<%#|^[ \t]*#)[ \t]*rachnasutra-disable-(next-line|line|file)[ \t]+((?:RS-[A-Z0-9]+-\d{3}[ \t,]*)+)/gm;
|
|
98
|
+
/** Removed from excerpts, so adding the comment does not change a finding's fingerprint. */
|
|
99
|
+
const SAME_LINE_DIRECTIVE = /[ \t]*(?:\{\/\*|<!--|\/\*|\/\/|\{#|\{\{!-{0,2}|<%#|#)[ \t]*rachnasutra-disable-line\b.*?(?:--\}\}|-->|\*\/\}?|#\}|%>|$)/g;
|
|
100
|
+
/** `file|rule|line` keys silenced by comments. Line 0 means the whole file. A rule ID is always required. */
|
|
101
|
+
function suppressions(docs) {
|
|
102
|
+
const out = new Set();
|
|
103
|
+
for (const d of docs) {
|
|
104
|
+
const text = d.source ?? d.text;
|
|
105
|
+
for (const m of text.matchAll(DIRECTIVE)) {
|
|
106
|
+
const at = lineAt(text, m.index);
|
|
107
|
+
const line = m[1] === 'file' ? 0 : m[1] === 'line' ? at : at + 1;
|
|
108
|
+
for (const rule of m[2].match(/RS-[A-Z0-9]+-\d{3}/g) ?? [])
|
|
109
|
+
out.add(`${d.file.rel}|${rule}|${line}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return out;
|
|
113
|
+
}
|
|
66
114
|
function mk(doc, index, base) {
|
|
67
115
|
const line = lineAt(doc.text, index);
|
|
68
|
-
return { ...base, file: doc.file.rel, line, evidence: [{ path: doc.file.rel, line, excerpt: excerpt(lineText(doc.text, line)) }] };
|
|
116
|
+
return { ...base, file: doc.file.rel, line, evidence: [{ path: doc.file.rel, line, excerpt: excerpt(lineText(doc.source ?? doc.text, line).replace(SAME_LINE_DIRECTIVE, '')) }] };
|
|
69
117
|
}
|
|
70
118
|
/** Tailwind arbitrary hex utilities and JSX style objects. Named palettes and the cascade are not resolved. */
|
|
71
119
|
function reportUtilityContrast(d, t, push) {
|
|
@@ -113,11 +161,16 @@ function reportUtilityContrast(d, t, push) {
|
|
|
113
161
|
export function runRules(ctx) {
|
|
114
162
|
const hits = [];
|
|
115
163
|
const counts = new Map();
|
|
164
|
+
const silenced = suppressions(ctx.docs);
|
|
116
165
|
const push = (h) => {
|
|
166
|
+
if (silenced.has(`${h.file}|${h.rule}|0`) || silenced.has(`${h.file}|${h.rule}|${h.line}`)) {
|
|
167
|
+
ctx.suppressed?.push(h);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
117
170
|
const key = `${h.rule}|${h.file}`;
|
|
118
171
|
const c = (counts.get(key) ?? 0) + 1;
|
|
119
172
|
counts.set(key, c);
|
|
120
|
-
if (c <= MAX_HITS_PER_RULE_PER_FILE)
|
|
173
|
+
if (c <= (ctx.maxPerRule ?? MAX_HITS_PER_RULE_PER_FILE))
|
|
121
174
|
hits.push(h);
|
|
122
175
|
};
|
|
123
176
|
const markup = ctx.docs.filter((d) => d.kind === 'markup');
|
|
@@ -395,6 +448,7 @@ export function runRules(ctx) {
|
|
|
395
448
|
}
|
|
396
449
|
}
|
|
397
450
|
// form controls without labels
|
|
451
|
+
const hasHtmlFor = /htmlFor/.test(t);
|
|
398
452
|
const labelFor = new Set([...t.matchAll(/<label\b[^>]*\bfor\s*=\s*["']([^"']+)["']/gi)].map((m) => m[1]));
|
|
399
453
|
for (const m of t.matchAll(tagRe('input|select|textarea'))) {
|
|
400
454
|
const a = m[2];
|
|
@@ -406,15 +460,12 @@ export function runRules(ctx) {
|
|
|
406
460
|
const id = attrVal(a, 'id');
|
|
407
461
|
if (id && labelFor.has(id))
|
|
408
462
|
continue;
|
|
409
|
-
if (
|
|
463
|
+
if (id && hasHtmlFor)
|
|
410
464
|
continue;
|
|
411
|
-
|
|
412
|
-
const lastOpen = Math.max(before.lastIndexOf('<label'), before.lastIndexOf('<Label'));
|
|
413
|
-
const lastClose = Math.max(before.lastIndexOf('</label'), before.lastIndexOf('</Label'));
|
|
414
|
-
if (lastOpen > lastClose)
|
|
465
|
+
if (lastBefore(t, /<[Ll]abel/g, m.index) > lastBefore(t, /<\/[Ll]abel/g, m.index))
|
|
415
466
|
continue;
|
|
416
467
|
// a control nested in a button or summary is named by that element's content
|
|
417
|
-
if (
|
|
468
|
+
if (lastBefore(t, /<(?:button|summary)/g, m.index) > lastBefore(t, /<\/(?:button|summary)/g, m.index))
|
|
418
469
|
continue;
|
|
419
470
|
push(mk(d, m.index, {
|
|
420
471
|
rule: 'RS-A11Y-005', category: 'accessibility', title: 'Form control has no programmatic label', severity: 'high', confidence: 'medium',
|
|
@@ -520,7 +571,7 @@ export function runRules(ctx) {
|
|
|
520
571
|
colors.set(k, (colors.get(k) ?? 0) + 1);
|
|
521
572
|
}
|
|
522
573
|
// SCSS interpolation (#{...}) contains braces; blank it out with same-length filler so offsets stay valid
|
|
523
|
-
for (const m of b.text.replace(/#\{[^{}]*\}/g, (x) => 'X'.repeat(x.length)).matchAll(/([^{}]+)\{([^{}]*)\}/g)) {
|
|
574
|
+
for (const m of b.text.replace(/#\{[^{}]*\}/g, (x) => 'X'.repeat(x.length)).matchAll(/(?<![^{}])([^{}]+)\{([^{}]*)\}/g)) {
|
|
524
575
|
const selector = cleanSelector(m[1]);
|
|
525
576
|
const body = m[2];
|
|
526
577
|
const bodyAt = m.index + m[0].indexOf('{') + 1;
|
package/dist/verify.js
CHANGED
|
@@ -117,19 +117,47 @@ export async function compareToReport(reportPath, root) {
|
|
|
117
117
|
const errors = validateReport(baseline);
|
|
118
118
|
if (errors.length)
|
|
119
119
|
return { errors };
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
const
|
|
120
|
+
// re-run with the baseline's scope; browser (axe) results cannot be re-checked statically
|
|
121
|
+
const current = await runAudit(root, { categories: baseline.categories });
|
|
122
|
+
// a finding silenced by a comment is still there, so it must not count as resolved
|
|
123
|
+
const present = [...current.findings, ...(current.suppressed ?? [])];
|
|
124
|
+
const checkable = baseline.findings.filter((f) => !f.rule.startsWith('axe/'));
|
|
125
|
+
const { matched: remaining, unmatched: resolved } = matchByFingerprint(checkable, present);
|
|
124
126
|
return {
|
|
125
127
|
errors: [],
|
|
126
128
|
current,
|
|
127
129
|
comparison: {
|
|
128
130
|
baselineTotal: baseline.findings.length,
|
|
129
131
|
currentTotal: current.findings.length,
|
|
130
|
-
resolved
|
|
131
|
-
remaining
|
|
132
|
-
introduced: current.findings
|
|
132
|
+
resolved,
|
|
133
|
+
remaining,
|
|
134
|
+
introduced: matchByFingerprint(current.findings, checkable).unmatched,
|
|
135
|
+
notRechecked: baseline.findings.length - checkable.length,
|
|
133
136
|
},
|
|
134
137
|
};
|
|
135
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Pair findings one to one. Two identical lines share a fingerprint, so a count matters:
|
|
141
|
+
* fixing one of two copies must show one resolved. Exact line matches pair first.
|
|
142
|
+
*/
|
|
143
|
+
export function matchByFingerprint(from, against) {
|
|
144
|
+
const pool = new Map();
|
|
145
|
+
for (const f of against)
|
|
146
|
+
pool.set(f.fingerprint, [...(pool.get(f.fingerprint) ?? []), f.line ?? null]);
|
|
147
|
+
const taken = new Set();
|
|
148
|
+
const take = (f, sameLine) => {
|
|
149
|
+
const lines = pool.get(f.fingerprint);
|
|
150
|
+
if (!lines?.length || taken.has(f))
|
|
151
|
+
return;
|
|
152
|
+
const i = sameLine ? lines.indexOf(f.line ?? null) : 0;
|
|
153
|
+
if (i < 0)
|
|
154
|
+
return;
|
|
155
|
+
lines.splice(i, 1);
|
|
156
|
+
taken.add(f);
|
|
157
|
+
};
|
|
158
|
+
for (const f of from)
|
|
159
|
+
take(f, true);
|
|
160
|
+
for (const f of from)
|
|
161
|
+
take(f, false);
|
|
162
|
+
return { matched: from.filter((f) => taken.has(f)), unmatched: from.filter((f) => !taken.has(f)) };
|
|
163
|
+
}
|
package/docs/cli-reference.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
| `skills list` | list bundled skills | no |
|
|
11
11
|
| `skills install --host <id> [--target dir] [--dry-run] [--force]` | install skills; conflicting files block unless `--force` (backup kept) | yes, inside target |
|
|
12
12
|
| `skills uninstall --host <id>` | remove only unmodified files it installed | yes |
|
|
13
|
-
| `audit` | static audit; writes `latest.md`, `latest.html`, `latest.json` to `./rachnasutra-reports` by default; `--no-report`, `--format json,md,html,sarif`, `--out dir`, `--json`, `--fail-on <sev
|
|
13
|
+
| `audit` | static audit; writes `latest.md`, `latest.html`, `latest.json` to `./rachnasutra-reports` by default; `--no-report`, `--format json,md,html,sarif`, `--out dir`, `--json`, `--fail-on <sev>`, `--no-excerpts`, `--allow-empty` | yes, report files (skip with `--no-report`, `--json` or `--format` without `--out`) |
|
|
14
14
|
| `accessibility` | audit limited to the accessibility category; same report files as `audit` | yes (same options) |
|
|
15
15
|
| `design-system inspect` | token inventory; writes `tokens.md` and `tokens.html` to `./rachnasutra-reports` (`--out`, `--no-report`, `--json`) | yes, unless `--no-report` or `--json` |
|
|
16
16
|
| `plan-fixes --report file` | ordered fix proposal; writes `fix-plan.md` and `fix-plan.html` next to the JSON report (`--out`, `--no-report`) | yes, unless `--no-report` or `--json` |
|
|
@@ -19,12 +19,25 @@
|
|
|
19
19
|
| `export --format sarif` | SARIF 2.1.0 to stdout | no |
|
|
20
20
|
| `ci` | audit with JSON default, default gate `confirmed-critical` | no |
|
|
21
21
|
| `config validate` | validate `rachnasutra.config.json` | no |
|
|
22
|
+
| `baseline [path]` | accept current findings; a second run only removes fixed ones (`--force` accepts new ones, `--baseline file`, `--dry-run`) | yes, `rachnasutra.baseline.json` |
|
|
22
23
|
|
|
23
24
|
`audit --mode browser` and `visual baseline` / `visual compare` launch Playwright when it is installed. Exit 3 when Playwright or a browser binary is missing, or when the folder has no `index.html`. No result is invented.
|
|
24
25
|
|
|
26
|
+
## Options
|
|
27
|
+
|
|
28
|
+
Write a value as `--key value` or `--key=value`. An unknown flag, a missing value or a bad value exits 2 before any work starts.
|
|
29
|
+
|
|
30
|
+
- `--out dir` without `--format` writes `md`, `html` and `json`. Several formats need `--out`.
|
|
31
|
+
- `--no-excerpts` replaces source excerpts with `[omitted]` and records only the project folder name. Titles can still quote short source text, such as link wording.
|
|
32
|
+
- `--allow-empty` lets a gate pass when no supported file was found.
|
|
33
|
+
- `--baseline file` (or the `baseline` config key) makes `audit`, `accessibility` and `ci` gate on new findings only. A missing baseline file exits 2.
|
|
34
|
+
- `rachnasutra-disable-next-line`, `-line` and `-file` comments with a rule ID silence a finding. See the user guide.
|
|
35
|
+
|
|
25
36
|
## Exit codes
|
|
26
37
|
|
|
27
|
-
`0` ok, `1` findings at or above `--fail-on` (or install conflict), `2` usage or invalid config, `3` capability not available, `4` verification failed, `5` error.
|
|
38
|
+
`0` ok, `1` findings at or above `--fail-on` (or install conflict), `2` usage or invalid config, `3` capability not available, `4` verification failed, `5` error, or a gate that could not see the whole project (file or time limit reached, unreadable files, or no supported file).
|
|
39
|
+
|
|
40
|
+
A path that does not exist or is not a directory exits 2.
|
|
28
41
|
|
|
29
42
|
`--fail-on` accepts `critical|high|medium|low|info` or `confirmed-critical` (any confirmed finding with severity critical or high).
|
|
30
43
|
|
|
@@ -34,4 +47,4 @@
|
|
|
34
47
|
{ "exclude": ["vendor", "public/legacy"], "disableRules": ["RS-TOK-001"], "failOn": "high", "maxFiles": 5000, "imageBudgetKb": 500 }
|
|
35
48
|
```
|
|
36
49
|
|
|
37
|
-
Unknown keys and unknown rule IDs are rejected by `config validate`.
|
|
50
|
+
`baseline` names a baseline file relative to the scan root. Unknown keys and unknown rule IDs are rejected by `config validate`.
|
package/docs/status.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Implementation status
|
|
2
2
|
|
|
3
|
-
Last updated for 0.
|
|
3
|
+
Last updated for 0.6.0. Statuses: **implemented** (code + test), **adapter** (files follow documented layout, not smoke-tested in the live host), **planned** (no code), **not-available** (CLI reports it honestly).
|
|
4
4
|
|
|
5
5
|
| Area | Status | Notes |
|
|
6
6
|
|---|---|---|
|
|
7
|
-
| Static audit CLI, 33 rules | implemented |
|
|
7
|
+
| Static audit CLI, 33 rules | implemented | 158 tests; failing and passing case per rule in `fixtures/rule-cases.mjs` |
|
|
8
8
|
| Validation: ACT, axe-core, 12 real repositories, case study | implemented | `benchmarks/`, `documents/rachnasutra/16-validation-and-benchmarks.md` |
|
|
9
9
|
| Live host smoke tests | not done | `documents/rachnasutra/17-host-smoke-tests.md` |
|
|
10
10
|
| Measured contrast (literal CSS pairs, inline styles) | implemented | cascade, gradients, images not resolved |
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
RachnaSutra AI is an open-source UI/UX design engineering and auditing agent. It ships 13 portable Agent Skills, led by **RachnaSutra Prime**, and a keyless command-line tool that audits front-end source code for accessibility, responsive design, design-system, content and performance risks. This documentation set is written for four audiences: decision makers, product and design leads, engineers, and open-source contributors.
|
|
4
4
|
|
|
5
|
-
> **Note:** This documentation describes version 0.
|
|
5
|
+
> **Note:** This documentation describes version 0.6.0. The same pages are live at <https://shahvatsalofficial.github.io/rachnasutra/>. Every capability is labelled **implemented**, **adapter**, **planned** or **not-available**. Nothing planned is described as shipped. Browser mode runs when Playwright is installed. Live-host checks are not shipped.
|
|
6
6
|
|
|
7
7
|
## Start here
|
|
8
8
|
|
|
@@ -17,6 +17,15 @@ RachnaSutra AI is an open-source UI/UX design engineering and auditing agent. It
|
|
|
17
17
|
| Asking "can I trust the results?" | [Validation and benchmarks](16-validation-and-benchmarks.md) |
|
|
18
18
|
| Looking for something specific | [FAQ and glossary](14-faq-and-glossary.md) |
|
|
19
19
|
|
|
20
|
+
## New here? Start with these two
|
|
21
|
+
|
|
22
|
+
| | |
|
|
23
|
+
|---|---|
|
|
24
|
+
| [Five-minute tour](18-quick-tour.md) | Run the audit, read the report, fix, verify. Every command and output is real. |
|
|
25
|
+
| [Real-world scenarios](19-real-world-scenarios.md) | Seven situations (launch week, pull-request gate, client report, legacy site, design system, AI IDE, browser sign-off) with the exact commands for each. |
|
|
26
|
+
|
|
27
|
+

|
|
28
|
+
|
|
20
29
|
## The documentation set
|
|
21
30
|
|
|
22
31
|
| # | Document | Purpose |
|
|
@@ -38,6 +47,8 @@ RachnaSutra AI is an open-source UI/UX design engineering and auditing agent. It
|
|
|
38
47
|
| 15 | [Rule examples](15-rule-examples.md) | A failing and a passing input for every rule, generated by running the audit |
|
|
39
48
|
| 16 | [Validation and benchmarks](16-validation-and-benchmarks.md) | ACT test cases, axe-core comparison, real-world audit, case study |
|
|
40
49
|
| 17 | [Host smoke tests](17-host-smoke-tests.md) | What is and is not verified in live AI IDEs, and how to check |
|
|
50
|
+
| 18 | [Five-minute tour](18-quick-tour.md) | Hands-on walkthrough with real output and screenshots |
|
|
51
|
+
| 19 | [Real-world scenarios](19-real-world-scenarios.md) | Seven realistic situations with exact commands |
|
|
41
52
|
|
|
42
53
|
## At a glance
|
|
43
54
|
|
|
@@ -45,7 +56,7 @@ RachnaSutra AI is an open-source UI/UX design engineering and auditing agent. It
|
|
|
45
56
|
<div class="card"><b>13</b><span>Agent Skills, led by RachnaSutra Prime</span></div>
|
|
46
57
|
<div class="card"><b>33</b><span>deterministic static audit rules</span></div>
|
|
47
58
|
<div class="card"><b>4</b><span>report formats: JSON, Markdown, HTML, SARIF 2.1.0</span></div>
|
|
48
|
-
<div class="card"><b>
|
|
59
|
+
<div class="card"><b>158/158</b><span>automated tests passing (see evidence)</span></div>
|
|
49
60
|
<div class="card"><b>154</b><span>W3C ACT test cases benchmarked, results published including weaknesses</span></div>
|
|
50
61
|
<div class="card"><b>1,360</b><span>files from 12 public repositories audited as real-world evidence</span></div>
|
|
51
62
|
<div class="card"><b>0</b><span>runtime dependencies, no network, no telemetry</span></div>
|
|
@@ -9,6 +9,8 @@ RachnaSutra AI helps teams find, fix and verify user-interface quality problems.
|
|
|
9
9
|
|
|
10
10
|
Tagline: **Design Beautifully. Audit Precisely. Deliver Delight.**
|
|
11
11
|
|
|
12
|
+

|
|
13
|
+
|
|
12
14
|
## The problem
|
|
13
15
|
|
|
14
16
|
- Accessibility and responsive defects are common, costly to fix late, and carry legal and reputational risk.
|
|
@@ -32,7 +34,7 @@ All items below are backed by automated tests or captured output. See [Testing a
|
|
|
32
34
|
|
|
33
35
|
| Claim | Evidence |
|
|
34
36
|
|---|---|
|
|
35
|
-
| The audit finds
|
|
37
|
+
| The audit finds 22 distinct issues in an intentionally flawed fixture, each with file and line | Test "broken fixture yields deterministic, evidenced findings"; sample report |
|
|
36
38
|
| The audit reports zero findings on a correct fixture and on correct inline snippets | Tests "good fixture has zero findings", "rules do not fire on correct inline snippets" |
|
|
37
39
|
| Contrast is measured, not guessed, and matches WCAG reference ratios | Test "contrast math matches WCAG reference values" (21:1 and 4.54:1) |
|
|
38
40
|
| Reports are escaped against markup injection | Test "malicious content is escaped in HTML and Markdown reports" |
|
|
@@ -107,7 +107,7 @@ Each finding has: ID (`RS-0001` style), rule ID, category, title, severity, conf
|
|
|
107
107
|
| JSON, Markdown, HTML reports validate and show coverage | Met: JSON validated against the contract in tests; coverage in every format |
|
|
108
108
|
| Generated skill files are valid | Met: 13 of 13 pass `verify` |
|
|
109
109
|
| No source changes or network use in default mode | Met: test asserts files unchanged and no reports directory created |
|
|
110
|
-
| Unit, integration and security tests pass | Met:
|
|
110
|
+
| Unit, integration and security tests pass | Met: 158 of 158 on the recorded run |
|
|
111
111
|
| README, contributor docs, security policy, licence present | Met |
|
|
112
112
|
| Accurate creator attribution, no fake endorsements | Met |
|
|
113
113
|
| One example reproduces a finding and its fix verification | Met: fix verification test and user guide journey 2 |
|
|
@@ -36,6 +36,10 @@ RachnaSutra AI is a single TypeScript package with no runtime dependencies. It c
|
|
|
36
36
|
<figcaption>Solid arrows are data flow. The dashed arrow shows skills invoking the CLI when the host allows shell access.</figcaption>
|
|
37
37
|
</figure>
|
|
38
38
|
|
|
39
|
+

|
|
40
|
+
|
|
41
|
+

|
|
42
|
+
|
|
39
43
|
## Design goals
|
|
40
44
|
|
|
41
45
|
1. **Evidence over opinion.** Every output is traceable to source text or a measurement.
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
| Runtime dependencies | None |
|
|
10
10
|
| Dev dependencies | `typescript`, `@types/node`, and optional browser tools `playwright`, `@axe-core/playwright`, `lighthouse` |
|
|
11
11
|
| Entry point | `dist/cli.js` (bin `rachnasutra`) |
|
|
12
|
-
| Tests | `node --test` (runs `test/*.test.mjs`);
|
|
12
|
+
| Tests | `node --test` (runs `test/*.test.mjs`); 158 tests |
|
|
13
13
|
| Build | `npm run build` (`tsc`) |
|
|
14
14
|
|
|
15
15
|
## Result model
|
|
@@ -43,7 +43,9 @@ Defined in `src/types.ts`.
|
|
|
43
43
|
|
|
44
44
|
## File walking (`src/fsutil.ts`)
|
|
45
45
|
|
|
46
|
-
-
|
|
46
|
+
- Always ignores: `node_modules`, `.git`, `.venv`, `venv`, `__pycache__`, `.next`, `.nuxt`, `.svelte-kit`, `.idea`, `.vscode`, `.rachnasutra`, `rachnasutra-reports`, `graphify-out`.
|
|
47
|
+
- Ignores `dist`, `build`, `out`, `target`, `vendor`, `coverage` and `reports` only at the scan root or beside a project file (`package.json`, `pom.xml`, `Cargo.toml`, `composer.json`, `go.mod`, `build.gradle`). Elsewhere, such as `src/reports`, they are source folders.
|
|
48
|
+
- Markup files: `.html`, `.htm`, `.jsx`, `.tsx`, `.vue`, `.svelte`, `.astro`, `.ejs`, `.hbs`, `.handlebars`, `.njk`, `.liquid`, `.twig`, `.erb`, `.cshtml`, `.php`. Style files: `.css`, `.scss`, `.less`, `.pcss`, `.postcss`.
|
|
47
49
|
- Symlinks are counted and skipped.
|
|
48
50
|
- User `exclude` entries match a path or a path prefix.
|
|
49
51
|
- Image files (png, jpg, gif, webp, avif, svg) are measured for size; raster images are not read as text.
|
|
@@ -76,6 +78,8 @@ Threshold is 4.5:1, or 3:1 for large text (font size 24px or more, or 18.66px or
|
|
|
76
78
|
|
|
77
79
|
### Confidence assignment
|
|
78
80
|
|
|
81
|
+

|
|
82
|
+
|
|
79
83
|
| Confidence | Meaning | Example |
|
|
80
84
|
|---|---|---|
|
|
81
85
|
| high | Deterministic pattern or measurement | `<img>` with no `alt` |
|
|
@@ -96,7 +100,7 @@ Patterns mask AWS access keys, GitHub tokens (`ghp_`, `gho_`, ...), fine-grained
|
|
|
96
100
|
|---|---|
|
|
97
101
|
| JSON | Whole result plus summary |
|
|
98
102
|
| Markdown | Table cells escape `|`, backticks and newlines |
|
|
99
|
-
| HTML | Self-contained; all dynamic values pass through `escHtml`; no scripts;
|
|
103
|
+
| HTML | Self-contained; all dynamic values pass through `escHtml`; no scripts; Auto, Light, Dark and Mix themes; severity and status filters (CSS `:has`); code context with two lines either side; print styles; semantic tables with captions and scoped headers |
|
|
100
104
|
| SARIF | Version 2.1.0; rules from the catalogue; severity mapped to `error`, `warning`, `note`; `partialFingerprints.rachnasutra` carries the fingerprint |
|
|
101
105
|
|
|
102
106
|
## Adapters (`src/adapters.ts`)
|
|
@@ -107,7 +111,7 @@ Patterns mask AWS access keys, GitHub tokens (`ghp_`, `gho_`, ...), fine-grained
|
|
|
107
111
|
|
|
108
112
|
- `verifyPackage()` checks that all 13 skills exist, each has valid frontmatter (name equal to the directory, valid characters, description under 1,024 characters), required sections, fewer than 500 lines, required root files, and that relative README links resolve.
|
|
109
113
|
- `validateReport()` checks the report contract.
|
|
110
|
-
- `compareToReport()` re-audits and
|
|
114
|
+
- `compareToReport()` re-audits with the baseline's category scope and pairs findings one to one by fingerprint: resolved (in baseline, not now), remaining (in both), introduced (now only). Two identical lines count twice. Browser (`axe/`) findings are counted as not re-checked.
|
|
111
115
|
|
|
112
116
|
## Exit codes
|
|
113
117
|
|
|
@@ -115,10 +119,10 @@ Patterns mask AWS access keys, GitHub tokens (`ghp_`, `gho_`, ...), fine-grained
|
|
|
115
119
|
|---|---|---|
|
|
116
120
|
| 0 | ok | Success, or no finding at or above the threshold |
|
|
117
121
|
| 1 | findings | Threshold reached; install conflict; `doctor` check failed |
|
|
118
|
-
| 2 | usage | Bad command, flag or config |
|
|
122
|
+
| 2 | usage | Bad command, flag, value, path or config |
|
|
119
123
|
| 3 | notAvailable | Browser or visual audit requested |
|
|
120
124
|
| 4 | verifyFailed | Package check failed; new findings introduced; report invalid |
|
|
121
|
-
| 5 | error | Unexpected error |
|
|
125
|
+
| 5 | error | Unexpected error, or a gate over a partial or empty scan |
|
|
122
126
|
|
|
123
127
|
## Configuration schema
|
|
124
128
|
|
|
@@ -128,7 +132,8 @@ Patterns mask AWS access keys, GitHub tokens (`ghp_`, `gho_`, ...), fine-grained
|
|
|
128
132
|
"disableRules": ["RS-TOK-001"],
|
|
129
133
|
"failOn": "high",
|
|
130
134
|
"maxFiles": 5000,
|
|
131
|
-
"imageBudgetKb": 500
|
|
135
|
+
"imageBudgetKb": 500,
|
|
136
|
+
"baseline": "rachnasutra.baseline.json"
|
|
132
137
|
}
|
|
133
138
|
```
|
|
134
139
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# User guide
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+
|
|
3
5
|
## Requirements
|
|
4
6
|
|
|
5
7
|
- Node.js 20 or newer (`node --version`).
|
|
@@ -48,6 +50,18 @@ By default this writes **Markdown, HTML and JSON** reports to `./rachnasutra-rep
|
|
|
48
50
|
| Machine-readable output on stdout | `--json` |
|
|
49
51
|
| A different folder or formats | `--out <dir> --format json,md,html,sarif` |
|
|
50
52
|
| SARIF for code scanning | `rachnasutra export --format sarif .` |
|
|
53
|
+
| A report without source text or local paths | `--no-excerpts` |
|
|
54
|
+
|
|
55
|
+

|
|
56
|
+
|
|
57
|
+

|
|
58
|
+
|
|
59
|
+
In the HTML report:
|
|
60
|
+
|
|
61
|
+
- **Theme:** Auto follows your system. Mix uses a dark header over a light page. The choice resets when the page reloads, because reports contain no script.
|
|
62
|
+
- **Filters:** untick a severity or status to hide those findings. Counts and printouts still include everything. Filters need a browser that supports CSS `:has`; older browsers show every finding.
|
|
63
|
+
- **Code context:** each finding shows up to two lines before and after, with the finding line highlighted. Secrets are redacted. `--no-excerpts` removes it. A file containing a private key block gets no context.
|
|
64
|
+
- **Print:** prints in the light theme with all findings.
|
|
51
65
|
|
|
52
66
|
### Reading a finding
|
|
53
67
|
|
|
@@ -61,8 +75,12 @@ By default this writes **Markdown, HTML and JSON** reports to `./rachnasutra-rep
|
|
|
61
75
|
| Verification | How to prove it is fixed |
|
|
62
76
|
| Limitations | Why it might be a false positive |
|
|
63
77
|
|
|
78
|
+
|
|
79
|
+
|
|
64
80
|
## Fix and verify
|
|
65
81
|
|
|
82
|
+

|
|
83
|
+
|
|
66
84
|
```bash
|
|
67
85
|
rachnasutra audit . # baseline: latest.md, latest.html, latest.json
|
|
68
86
|
rachnasutra plan-fixes --report rachnasutra-reports/latest.json # writes fix-plan.md and fix-plan.html; changes no source
|
|
@@ -153,16 +171,48 @@ A report with zero findings means the static rules found nothing. It does **not*
|
|
|
153
171
|
|
|
154
172
|
The WCAG checklist is in `skills/rachnasutra-access/references/wcag-22-aa-checklist.md`.
|
|
155
173
|
|
|
174
|
+
## Adopt on an existing project: baseline
|
|
175
|
+
|
|
176
|
+
A first audit of an old project can report hundreds of findings. A baseline accepts today's findings so the gate fails only on new ones.
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
rachnasutra baseline . # writes rachnasutra.baseline.json
|
|
180
|
+
rachnasutra ci . --baseline rachnasutra.baseline.json # fails on new findings only
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Commit the baseline file, or set `"baseline": "rachnasutra.baseline.json"` in `rachnasutra.config.json`. The file holds rule IDs, file paths, line numbers and fingerprints, with no source text.
|
|
184
|
+
|
|
185
|
+
Running `rachnasutra baseline .` again is a ratchet: it removes fixed findings and never adds new ones. `--force` rewrites the file and accepts everything found now. With a baseline, the 15 findings per rule and file limit does not apply.
|
|
186
|
+
|
|
187
|
+
A finding is matched by rule, file and line text. Renaming a file, or editing the offending line, makes it new again.
|
|
188
|
+
|
|
189
|
+
## Silence one finding: comments
|
|
190
|
+
|
|
191
|
+
Name the rule ID. A directive without a rule ID does nothing.
|
|
192
|
+
|
|
193
|
+
```html
|
|
194
|
+
<!-- rachnasutra-disable-next-line RS-A11Y-001 -- decorative, reviewed -->
|
|
195
|
+
<img src="swirl.png">
|
|
196
|
+
<img src="dot.png"> <!-- rachnasutra-disable-line RS-A11Y-001 -->
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
```css
|
|
200
|
+
/* rachnasutra-disable-file RS-VIS-001 -- legal small print, approved */
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
`next-line` and `line` refer to the line the finding reports, which is where the tag or declaration starts. Silenced findings do not fail a gate. They are counted in every report and listed under `suppressed` in the JSON report.
|
|
204
|
+
|
|
156
205
|
## Troubleshooting
|
|
157
206
|
|
|
158
207
|
| Symptom | Cause and fix |
|
|
159
208
|
|---|---|
|
|
160
209
|
| `Scanned 0 file(s)` | The path has no supported files, or they are in an ignored folder. Check the path and `exclude` |
|
|
161
|
-
| `truncated` is true | A limit was hit. Narrow the path or raise `maxFiles
|
|
210
|
+
| `truncated` is true | A limit was hit. Narrow the path or raise `maxFiles`. A gate exits 5 |
|
|
211
|
+
| `gate not passed` (exit 5) | The scan was partial or empty. Check the path; use `--allow-empty` only when no UI files is expected |
|
|
162
212
|
| Many `RS-A11Y-005` hits in a component library project | Labels are supplied by wrappers. Treat as review-required |
|
|
163
213
|
| `Blocked: N conflicting file(s)` | You edited installed skills. Use `--dry-run` to inspect, `--force` to overwrite |
|
|
164
|
-
| Exit code 3 |
|
|
165
|
-
| Exit code 2
|
|
214
|
+
| Exit code 3 | Browser mode could not start: Playwright, a browser or `index.html` is missing |
|
|
215
|
+
| Exit code 2 | Unknown flag, bad value, missing folder, or invalid config |
|
|
166
216
|
| `npx github:...` fails | The repository may be private or Node is below 20 |
|
|
167
217
|
|
|
168
218
|
## Getting help
|
|
@@ -30,6 +30,8 @@ The format follows the open Agent Skills specification (https://agentskills.io/s
|
|
|
30
30
|
|
|
31
31
|
## How Prime orchestrates
|
|
32
32
|
|
|
33
|
+

|
|
34
|
+
|
|
33
35
|
1. **Understand** the request and the repository.
|
|
34
36
|
2. **Detect capabilities:** file access, shell, the RachnaSutra CLI, browser, screenshots, vision model, network. Missing ones are labelled `not tested`.
|
|
35
37
|
3. **Set scope:** read-only by default; state exclusions.
|
|
@@ -55,7 +55,8 @@ Not implemented. When added it must require explicit authorization, an origin al
|
|
|
55
55
|
| Redaction is pattern-based | Unusual secret formats can pass through. Do not publish reports without review |
|
|
56
56
|
| Regex parsing | Crafted input could cause slow matching; time and file limits bound this |
|
|
57
57
|
| AI host behaviour | Skills reduce but cannot eliminate prompt-injection risk in a model |
|
|
58
|
-
|
|
|
58
|
+
| HTML and JSON reports include two source lines either side of each finding | Redacted by the same patterns; omitted with `--no-excerpts` |
|
|
59
|
+
| Report files contain code excerpts | Treat reports as sensitive as source, or run with `--no-excerpts` (titles can still quote short source text) |
|
|
59
60
|
|
|
60
61
|
## Responsible disclosure
|
|
61
62
|
|
|
@@ -9,19 +9,21 @@ This page contains the recorded results of the automated test suite and sample r
|
|
|
9
9
|
| Command | `npm test` (build, then `node --test test/`) |
|
|
10
10
|
| Node.js | v24 on this machine. CI also runs Node 20, 22, 24 and 26 |
|
|
11
11
|
| Operating system | Windows 11 (Git Bash) |
|
|
12
|
-
| Tests |
|
|
13
|
-
| Passed |
|
|
12
|
+
| Tests | 158 |
|
|
13
|
+
| Passed | 158 |
|
|
14
14
|
| Failed | 0 |
|
|
15
15
|
| Skipped | 0 |
|
|
16
16
|
| Duration | about 34 seconds |
|
|
17
17
|
| Raw output | [test-results.txt](evidence/test-results.txt) |
|
|
18
18
|
|
|
19
|
-
Typecheck (`npm run typecheck`) and package verification (`node dist/cli.js verify`,
|
|
19
|
+
Typecheck (`npm run typecheck`) and package verification (`node dist/cli.js verify`, 29 PASS lines, 0 FAIL) were also run clean on the same commit.
|
|
20
20
|
|
|
21
|
-
> **Note:**
|
|
21
|
+
> **Note:** The recorded run used Node 24 on Windows. The blocking CI matrix is Windows and Linux on Node 20, 22, 24 and 26. macOS is not in CI. GitHub queued `macos-15` for 15 minutes on run 42096695892, then cancelled both jobs before any step. That is a missing runner, not a failed test. No macOS result is claimed.
|
|
22
22
|
|
|
23
23
|
## What each test proves
|
|
24
24
|
|
|
25
|
+
Regression tests for flags, gates, redaction, verification, CSS-in-JS lines, the scanner, speed and the browser-mode server are in `test/hardening.test.mjs`. Baseline and disable-comment tests are in `test/baseline.test.mjs`. HTML report tests are in `test/report-html.test.mjs`.
|
|
26
|
+
|
|
25
27
|
| # | Test | Proves |
|
|
26
28
|
|---|---|---|
|
|
27
29
|
| 1 | contrast math matches WCAG reference values | Black on white is 21:1; `#767676` on white is 4.54:1; `#999` on white is below 3:1 |
|
|
@@ -53,6 +55,8 @@ The rule tests come from `fixtures/rule-cases.mjs`: for each of the 33 rules a f
|
|
|
53
55
|
|
|
54
56
|
## Sample run 1: intentionally broken fixture
|
|
55
57
|
|
|
58
|
+

|
|
59
|
+
|
|
56
60
|
Command: `node dist/cli.js audit fixtures/intentionally-broken-ui`
|
|
57
61
|
|
|
58
62
|
Result: **22 findings** (8 high, 8 medium, 5 low, 1 info) in 2 files.
|
|
@@ -113,7 +117,7 @@ node dist/cli.js verify
|
|
|
113
117
|
node dist/cli.js audit fixtures/intentionally-broken-ui --format json,md,html,sarif --out reports
|
|
114
118
|
```
|
|
115
119
|
|
|
116
|
-
Expected:
|
|
120
|
+
Expected: 158 tests pass; `verify` prints only PASS lines; four report files are written.
|
|
117
121
|
|
|
118
122
|
## Coverage of the test suite
|
|
119
123
|
|
|
@@ -41,6 +41,8 @@ The first step fails the job (exit 1) when a confirmed high or critical finding
|
|
|
41
41
|
|
|
42
42
|
## Choosing a gate
|
|
43
43
|
|
|
44
|
+

|
|
45
|
+
|
|
44
46
|
| Gate | Command | Use when |
|
|
45
47
|
|---|---|---|
|
|
46
48
|
| Confirmed critical or high | `rachnasutra ci .` | Default; low risk of false-positive blocks |
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
| planned | No code yet |
|
|
11
11
|
| not-available | The CLI states it is unavailable and exits with code 3 |
|
|
12
12
|
|
|
13
|
-
## Capability status (0.
|
|
13
|
+
## Capability status (0.6.0)
|
|
14
14
|
|
|
15
15
|
| Area | Status | Notes |
|
|
16
16
|
|---|---|---|
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
| Container image | implemented | `Dockerfile`, static CLI, no browser. Built on GitHub Actions Ubuntu. Not built on the maintainer PC |
|
|
33
33
|
| API or local-model provider modes | planned | Skills use the host model today |
|
|
34
34
|
| Report viewer dashboard | partial | One HTML report per run, plus `history` counts |
|
|
35
|
-
| Rule examples and per-rule tests | implemented | 33 rules,
|
|
35
|
+
| Rule examples and per-rule tests | implemented | 33 rules, 158 tests |
|
|
36
36
|
| `history` command | implemented | Markdown and HTML counts of saved JSON reports |
|
|
37
37
|
| Dockerfile | implemented | Static CLI only |
|
|
38
38
|
| Gujarati README | implemented | `README.gu.md` |
|
|
@@ -70,6 +70,10 @@ GitHub Pages publishes `documents/rachnasutra/html/` on every push to `main` tha
|
|
|
70
70
|
|
|
71
71
|
Scripts live in `benchmarks/` and are opt-in (network or third-party tools). Run `node benchmarks/act.mjs` after any rule change and compare with the published numbers in [Validation and benchmarks](16-validation-and-benchmarks.md). When a rule is changed because of a benchmark finding, add a regression case so the fix is permanent, and say in the changelog that the benchmark is no longer blind for that rule.
|
|
72
72
|
|
|
73
|
+
## Diagrams, charts and screenshots
|
|
74
|
+
|
|
75
|
+
Diagrams and charts are generated SVGs in `documents/rachnasutra/diagrams/`. Run `npm run diagrams` to regenerate them: flow charts are laid out in `scripts/gen-diagrams.mjs`, and the charts read the real data in `benchmarks/results/` and `samples/`, so they update when the data does. SVGs follow the reader's light or dark preference and need no scripts. Report screenshots in `documents/rachnasutra/images/` come from `npm run images` (needs Playwright and a browser). Reference an image from Markdown as ``. The home page is the hand-written `documents/rachnasutra/home.html`; the numbers it quotes (rules, tests, skills, version) are filled in from the repository when you run `npm run docs`.
|
|
76
|
+
|
|
73
77
|
## Refreshing evidence
|
|
74
78
|
|
|
75
79
|
```bash
|