diff --git a/.codacy.yml b/.codacy.yml new file mode 100644 index 0000000..c439e7d --- /dev/null +++ b/.codacy.yml @@ -0,0 +1,5 @@ +# Codacy: paths that don't ship to users. Test fixtures are broken or insecure on purpose: +# they're what agent-ready's checks are tested against. +exclude_paths: + - "test/fixtures/**" + - "scripts/demo-gif.mjs" diff --git a/README.md b/README.md index a2aba2f..9ffaf82 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ **Lighthouse for AI coding agents.** Score how well Claude Code, Codex and Cursor can work in your repo — then auto-fix the gaps. -[![CI](https://github.com/mintwork/agent-ready/actions/workflows/ci.yml/badge.svg)](https://github.com/mintwork/agent-ready/actions/workflows/ci.yml) [![npm](https://img.shields.io/npm/v/@mintwork/agent-ready?color=cb3837&logo=npm&label=npm)](https://www.npmjs.com/package/@mintwork/agent-ready) [![npm downloads](https://img.shields.io/npm/dm/@mintwork/agent-ready?color=cb3837&logo=npm&label=downloads)](https://www.npmjs.com/package/@mintwork/agent-ready) [![npm provenance](https://img.shields.io/badge/provenance-signed-7EE2B8?labelColor=0D1714&logo=sigstore&logoColor=white)](https://www.npmjs.com/package/@mintwork/agent-ready#provenance) [![Node 22+](https://img.shields.io/badge/node-%E2%89%A522-339933?logo=nodedotjs&logoColor=white)](package.json) [![license: MIT](https://img.shields.io/badge/license-MIT-blue)](LICENSE) [![agent-ready: 100/100](https://img.shields.io/badge/agent--ready-100%2F100-brightgreen)](https://github.com/mintwork/agent-ready) [![zero runtime dependencies](https://img.shields.io/badge/runtime%20deps-0-7EE2B8?labelColor=0D1714)](package.json) [![GitHub stars](https://img.shields.io/github/stars/mintwork/agent-ready?style=social)](https://github.com/mintwork/agent-ready/stargazers) +[![CI](https://github.com/mintwork/agent-ready/actions/workflows/ci.yml/badge.svg)](https://github.com/mintwork/agent-ready/actions/workflows/ci.yml) [![Codacy grade](https://app.codacy.com/project/badge/Grade/f727918f28954b8d984d25352a6d9be9)](https://app.codacy.com/gh/mintwork/agent-ready/dashboard) [![npm](https://img.shields.io/npm/v/@mintwork/agent-ready?color=cb3837&logo=npm&label=npm)](https://www.npmjs.com/package/@mintwork/agent-ready) [![npm downloads](https://img.shields.io/npm/dm/@mintwork/agent-ready?color=cb3837&logo=npm&label=downloads)](https://www.npmjs.com/package/@mintwork/agent-ready) [![npm provenance](https://img.shields.io/badge/provenance-signed-7EE2B8?labelColor=0D1714&logo=sigstore&logoColor=white)](https://www.npmjs.com/package/@mintwork/agent-ready#provenance) [![Node 22+](https://img.shields.io/badge/node-%E2%89%A522-339933?logo=nodedotjs&logoColor=white)](package.json) [![license: MIT](https://img.shields.io/badge/license-MIT-blue)](LICENSE) [![agent-ready: 100/100](https://img.shields.io/badge/agent--ready-100%2F100-brightgreen)](https://github.com/mintwork/agent-ready) [![zero runtime dependencies](https://img.shields.io/badge/runtime%20deps-0-7EE2B8?labelColor=0D1714)](package.json) [![GitHub stars](https://img.shields.io/github/stars/mintwork/agent-ready?style=social)](https://github.com/mintwork/agent-ready/stargazers) agent-ready scoring a repo at 59/100, running --fix to reach 78/100, then printing a README badge diff --git a/src/bin.ts b/src/bin.ts index b908ed0..fd0197e 100644 --- a/src/bin.ts +++ b/src/bin.ts @@ -3,8 +3,8 @@ import { main } from './cli.js'; // `agent-ready | head` closes stdout early; exit quietly instead of crashing on EPIPE. process.stdout.on('error', (err: NodeJS.ErrnoException) => { - if (err.code === 'EPIPE') process.exit(0); - throw err; + if (err.code !== 'EPIPE') process.stderr.write(`agent-ready: ${err.message}\n`); + process.exit(err.code === 'EPIPE' ? 0 : 1); }); main(process.argv.slice(2)).then( diff --git a/src/context.ts b/src/context.ts index 7d75a6d..491da46 100644 --- a/src/context.ts +++ b/src/context.ts @@ -410,9 +410,9 @@ interface ContextParts { files: string[]; trackedHeavy: string[]; truncated: boolean; - isIgnored(rel: string): boolean; - isIgnoredMany(rels: string[]): Map; - hasTracked(relDir: string): boolean; + isIgnored: (rel: string) => boolean; + isIgnoredMany: (rels: string[]) => Map; + hasTracked: (relDir: string) => boolean; /** Repo-relative name -> absolute path, for files inherited from a parent directory. */ overlay: Map; /** Root package.json scripts / dependencies a workspace package can use (hoisted tooling). */ diff --git a/src/scan.ts b/src/scan.ts index 63acf71..e339b51 100644 --- a/src/scan.ts +++ b/src/scan.ts @@ -105,7 +105,7 @@ async function runChecks( title: check.title, weight: check.weight * Math.max(0.05, Math.min(1, result.weightScale ?? 1)), // A score held back only by an unedited generated doc isn't something --fix can improve. - fixable: Boolean(check.fix) && score !== null && (potential ?? score) < 1, + fixable: check.fix !== undefined && score !== null && (potential ?? score) < 1, durationMs: Date.now() - t0, }); } diff --git a/src/util/color.ts b/src/util/color.ts index 86994c5..549916e 100644 --- a/src/util/color.ts +++ b/src/util/color.ts @@ -15,15 +15,13 @@ export type ColorName = keyof typeof codes; export interface Colors { enabled: boolean; - c(name: ColorName, s: string): string; + c: (name: ColorName, s: string) => string; } export function makeColors(enabled: boolean): Colors { return { enabled, - c(name, s) { - return enabled ? `\x1b[${codes[name]}m${s}\x1b[0m` : s; - }, + c: (name, s) => (enabled ? `\x1b[${codes[name]}m${s}\x1b[0m` : s), }; } diff --git a/src/util/run.ts b/src/util/run.ts index 53b7cc8..97c74dc 100644 --- a/src/util/run.ts +++ b/src/util/run.ts @@ -32,6 +32,8 @@ export function runCommand(cmd: string, opts: RunCommandOptions): Promise { expect(r.checks.find((c) => c.id === 'nav.large-files')?.summary).not.toMatch(/node_modules/); }); + // AWS's documented example key, assembled so this file contains no key-shaped literal. + const AWS_DOCS_EXAMPLE_KEY = ['AKIA', 'IOSFODNN7', 'EXAMPLE'].join(''); it('ignores placeholder secrets and suppressed lines', async () => { const dir = fixture('good-ts', { git: true, files: { - 'src/example.ts': `export const k = 'AKIAIOSFODNN7EXAMPLE';\nexport const j = '${FAKE_AWS_KEY}'; // agent-ready-ignore\n`, + 'src/example.ts': `export const k = '${AWS_DOCS_EXAMPLE_KEY}';\nexport const j = '${FAKE_AWS_KEY}'; // agent-ready-ignore\n`, '.env.example': 'API_KEY=\n', }, });