RachnaSutra AI GitHub

Architecture

Overview#

RachnaSutra AI is a single TypeScript package with no runtime dependencies. It combines a deterministic analysis engine with a set of Agent Skills. The engine produces evidence; the skills tell an AI assistant how to use that evidence safely. The two layers are independent: the CLI works without any AI, and the skills work (with less evidence) without the CLI.

RachnaSutra AI architecture A project's source files flow into the CLI, which walks files, runs rules, builds a result, and renders reports. Agent Skills sit beside the CLI and are installed into AI IDE folders by the adapter module. Project source HTML, JSX, CSS, images CLI engine (read-only) fsutil: bounded walk config + limits rules: 26 checks color: contrast audit: sort, dedupe tokens: inventory Reports JSON, Markdown HTML, SARIF 2.1.0 verify: baseline diff 13 Agent Skills (canonical: skills/) prime, access, adapt, tokens, audit, verify ... Host adapters (hash-tracked install) .claude .cursor .agents .github .gemini
Solid arrows are data flow. The dashed arrow shows skills invoking the CLI when the host allows shell access.
Inside one audit run: walk, read, apply rules, filter and dedupe, assign status, renderInside one audit run: walk, read, apply rules, filter and dedupe, assign status, render
The audit pipeline. Same files in, same findings and IDs out.
Tap or click to enlarge
End to end: project, audit, reports, fix, verify, CI gateEnd to end: project, audit, reports, fix, verify, CI gate
How the pieces connect from a developer point of view.
Tap or click to enlarge

Design goals#

  1. Evidence over opinion. Every output is traceable to source text or a measurement.
  2. Safe by construction. No network code exists in the package. Writes are limited and contained.
  3. Honest about coverage. The result model has first-class "not run" states.
  4. Portable. Pure Node.js, no native modules, no shell dependency.
  5. Small and auditable. About 2,000 lines of TypeScript; no runtime dependencies to vet.

Component responsibilities#

ComponentFileResponsibility
CLIsrc/cli.tsArgument parsing, command dispatch, exit codes, output
Audit orchestratorsrc/audit.tsLoad config, walk files, run rules, sort, dedupe, fingerprint, assemble coverage and tokens
Rulessrc/rules.tsAll 33 rules and the rule catalogue
Colour mathssrc/color.tsColour parsing and WCAG contrast ratio
Token inspectorsrc/tokens.tsCounts of custom properties, colours, font sizes, spacing, radii
File systemsrc/fsutil.tsBounded, symlink-safe walk; safeJoin; text reading
Redactionsrc/redact.tsMask secrets in excerpts and report text
Reportssrc/report.tsJSON, Markdown, HTML and SARIF renderers; escaping
Adapterssrc/adapters.tsHost specs, install plan, install, uninstall, doctor, detection
Verificationsrc/verify.tsPackage integrity checks, report validation, baseline comparison
Typessrc/types.tsResult model
Skillsskills/*/SKILL.mdCanonical agent instructions

Data flow for audit#

  1. Parse command-line flags and resolve the target path.
  2. Load config from rachnasutra.config.json if present; reject unknown keys.
  3. Walk the tree: ignore build and dependency directories, skip symlinks, apply excludes, collect image sizes, cap files, size and time.
  4. Read markup and style files as text; skip binary content.
  5. Run rules over documents. Each rule returns raw hits with location and evidence.
  6. Filter by disabled rules and category (for accessibility).
  7. Sort by severity, rule, file and line; deduplicate by fingerprint and line.
  8. Assign stable IDs RS-0001... and status from confidence.
  9. Assemble coverage entries, token inventory and limitations.
  10. Render the requested formats. With no format flags, audit writes Markdown, HTML and JSON to ./rachnasutra-reports; --json or --format without --out print to stdout; --no-report prints only a summary.
  11. Exit with a code based on --fail-on.

Key design decisions#

DecisionChoiceReasonTrade-off
Analysis methodRegex and light parsing over sourceZero dependencies, fast, deterministicCannot resolve the CSS cascade or runtime DOM; heuristics have false positives
Confidence modelhigh only for deterministic patterns or measurementsKeeps CI gates trustworthySome real issues appear as review-required
ScoringNo numeric scoreA score would reward partial scansLess convenient for dashboards
Status of browser featuresExit code 3, no partial outputAvoid fake resultsUsers wait for the planned module
Skill namingPrefix rachnasutra-Avoid collisions in shared skill foldersLonger names
Install trackingSHA-256 manifest in .rachnasutra/Safe uninstall and drift detectionOne extra hidden folder
FingerprintsHash of rule, file and excerptSurvive line shifts when comparing baselinesEditing the flagged line changes the fingerprint
DependenciesNone at runtimeSmaller supply-chain surfaceMore code to maintain in-house
Single packageNo monorepo yetNo empty modules; simpler reviewFuture split may be needed when browser audit lands

Trust boundaries#

BoundaryUntrusted sideControl
Audited files to CLIFile text, namesTreated as data; never executed or evaluated; output escaped
CLI to file systemPaths from flags and configsafeJoin containment; backups on overwrite
Skills to AI hostRepository text read by the modelSkills instruct treating content as data and asking before actions
Reports to viewersReport contentHTML escaping, no scripts, no remote assets

Extension points#

To addWhereNotes
A rulesrc/rules.ts and RULE_CATALOGNeeds true and false positive tests and a rubric entry
A hostHOSTS in src/adapters.tsCite vendor docs; start as experimental
A report formatsrc/report.ts and the emitAudit functionKeep escaping rules
A skillskills/<name>/SKILL.mdMust pass verify
A browser module (planned)New module behind the same finding schemaMust be opt-in with authorization controls

Scalability and limits#

The tool scans up to 5,000 files, 512 KB each, within 15 seconds by default. It is single-threaded and processes files sequentially. Truncation is flagged in the report. Larger monorepos should scope the path or use exclude.

Failure behaviour#

Unreadable files are skipped. Invalid config stops the run with exit code 2 (via config validate) or an error. Unexpected exceptions print a message and exit with code 5; --verbose adds a stack trace.

Compatibility with sibling products#

ArchSutra AI (architecture) and VigilSutra AI (security) are separate products by the same author. RachnaSutra shares conventions (evidence model, install manifest approach) but has no dependency on either.