rulereceipt 0.1.56 → 0.1.57

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.
@@ -0,0 +1,28 @@
1
+ import type { Rule } from "./types.js";
2
+ /**
3
+ * A rules-only health score — how much of a rules file can actually be checked,
4
+ * with NO session needed.
5
+ *
6
+ * The recurring day-one gap: a first `check` with no session is empty, and a
7
+ * real CLAUDE.md is mostly a handbook — measured across the public corpus, ~38%
8
+ * of items are rules and ~56% of those need judgment. `audit` answers "is your
9
+ * rules file enforceable?" on any format (CLAUDE.md, AGENTS.md, Cursor, Copilot,
10
+ * Windsurf, Gemini) instantly, and points at `rules --advise` for the fixes.
11
+ *
12
+ * Buckets, by how classifyRule routes each item:
13
+ * - checkable : any structured/deterministic kind — a session can be checked
14
+ * against it without a human or an LLM
15
+ * - judgment : needs a person (or `--llm`)
16
+ * - skipped : not a rule (docs, directory maps, glossary rows)
17
+ */
18
+ export interface RulesAudit {
19
+ total: number;
20
+ checkable: number;
21
+ judgment: number;
22
+ skipped: number;
23
+ /** checkable / (checkable + judgment), whole %, 0 when there are no rules. */
24
+ percentCheckable: number;
25
+ }
26
+ export declare function auditRules(rules: Rule[]): RulesAudit;
27
+ /** A short, readable audit. Never says "compliant" — it measures the file, not a session. */
28
+ export declare function renderAudit(a: RulesAudit, md?: boolean): string;
package/dist/audit.js ADDED
@@ -0,0 +1,44 @@
1
+ import { classifyRules } from "./checks/classify.js";
2
+ export function auditRules(rules) {
3
+ let checkable = 0;
4
+ let judgment = 0;
5
+ let skipped = 0;
6
+ for (const c of classifyRules(rules)) {
7
+ if (c.kind === "notARule")
8
+ skipped++;
9
+ else if (c.kind === "judgment")
10
+ judgment++;
11
+ else
12
+ checkable++;
13
+ }
14
+ const decided = checkable + judgment;
15
+ return {
16
+ total: checkable + judgment + skipped,
17
+ checkable,
18
+ judgment,
19
+ skipped,
20
+ percentCheckable: decided > 0 ? Math.round((checkable / decided) * 100) : 0,
21
+ };
22
+ }
23
+ /** A short, readable audit. Never says "compliant" — it measures the file, not a session. */
24
+ export function renderAudit(a, md = false) {
25
+ if (a.checkable + a.judgment === 0) {
26
+ return md
27
+ ? "**No rules found** in this project's rules files. Is there a `CLAUDE.md`, `AGENTS.md` or similar here?"
28
+ : "No rules found in this project's rules files.\nIs there a CLAUDE.md / AGENTS.md (or Cursor/Copilot/Windsurf rules) here?";
29
+ }
30
+ const H = (s) => (md ? `## ${s}` : s);
31
+ const out = [];
32
+ out.push(md ? "# RuleReceipt — rules audit" : "RuleReceipt · rules audit (no session needed)");
33
+ out.push("");
34
+ out.push(`${a.checkable + a.judgment} rules read (plus ${a.skipped} documentation item${a.skipped === 1 ? "" : "s"} not scored).`);
35
+ out.push("");
36
+ out.push(H("Can this session be checked against them?"));
37
+ out.push(` ${String(a.checkable).padStart(4)} checkable — verifiable from a session, no human needed`);
38
+ out.push(` ${String(a.judgment).padStart(4)} need judgment — a person (or \`--llm\`) decides these`);
39
+ out.push(` ${String(a.skipped).padStart(4)} documentation — structure/notes, not scored as rules`);
40
+ out.push("");
41
+ out.push(`${a.percentCheckable}% of your rules can be checked mechanically.`);
42
+ out.push("See which can't, and the smallest edit that would fix each: rulereceipt rules --advise");
43
+ return out.join("\n");
44
+ }
package/dist/cli.js CHANGED
@@ -13,6 +13,7 @@ import { adviseRules } from "./checkability.js";
13
13
  import { shadowedAgentsMd } from "./shadowedAgents.js";
14
14
  import { partitionByAge, futureResult } from "./ruleAge.js";
15
15
  import { auditSessions, renderComplianceReport } from "./report/complianceReport.js";
16
+ import { auditRules, renderAudit } from "./audit.js";
16
17
  import { classifyRules } from "./checks/classify.js";
17
18
  import { loadOverrides, saveOverride, clearOverride, staleOverrides, ruleFingerprint, OVERRIDES_PATH } from "./overrides.js";
18
19
  import { runDeterministicChecks } from "./checks/deterministicChecks.js";
@@ -891,6 +892,19 @@ program
891
892
  const r = await auditSessions(process.cwd(), Number.isFinite(n) ? n : 25);
892
893
  console.log(renderComplianceReport(r, Boolean(opts.markdown)));
893
894
  });
895
+ program
896
+ .command("audit")
897
+ .description("Score your rules files for checkability — NO session needed. How much can be checked mechanically vs needs a human vs is documentation. Works on CLAUDE.md, AGENTS.md, Cursor, Copilot, Windsurf and Gemini rules.")
898
+ .option("--markdown", "output as markdown, for a report you can send")
899
+ .option("--json", "output machine-readable JSON (counts and the checkable %)")
900
+ .action((opts) => {
901
+ const a = auditRules(loadRules(process.cwd()));
902
+ if (opts.json) {
903
+ console.log(JSON.stringify(a, null, 2));
904
+ return;
905
+ }
906
+ console.log(renderAudit(a, Boolean(opts.markdown)));
907
+ });
894
908
  program
895
909
  .command("digest")
896
910
  .description("A non-technical summary of recent check runs (counts only, no rule text) — for a manager who doesn't have time to read 30 individual reports.")
package/dist/rules.js CHANGED
@@ -62,8 +62,12 @@ function ruleFilesAtLevel(dir) {
62
62
  for (const rel of RULE_DIRS)
63
63
  found.push(...markdownFilesIn(join(dir, rel)));
64
64
  push("CLAUDE.md");
65
- if (!has("CLAUDE.md"))
65
+ // AGENTS.md (and the singular AGENT.md some tools use) are read only when
66
+ // there's no CLAUDE.md at this level, mirroring Claude Code's shadow rule.
67
+ if (!has("CLAUDE.md")) {
66
68
  push("AGENTS.md");
69
+ push("AGENT.md");
70
+ }
67
71
  // .local variants: their precedence relative to the base files is not
68
72
  // documented, so both are kept rather than guessing at a shadow rule.
69
73
  push("CLAUDE.local.md");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rulereceipt",
3
- "version": "0.1.56",
3
+ "version": "0.1.57",
4
4
  "description": "Checks whether your AI coding agent followed your rules, with evidence. Works with Claude Code (Codex in testing); reads CLAUDE.md, AGENTS.md, Cursor, Copilot and Windsurf rules.",
5
5
  "repository": {
6
6
  "type": "git",