Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .codacy.yml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

<img src="docs/demo.gif" alt="agent-ready scoring a repo at 59/100, running --fix to reach 78/100, then printing a README badge" width="900">

Expand Down
4 changes: 2 additions & 2 deletions src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

For non-EPIPE errors, wait for the stderr write to complete before exiting so redirected output is not lost. Preserve the existing successful EPIPE behavior.

TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.

});

main(process.argv.slice(2)).then(
Expand Down
6 changes: 3 additions & 3 deletions src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,9 @@ interface ContextParts {
files: string[];
trackedHeavy: string[];
truncated: boolean;
isIgnored(rel: string): boolean;
isIgnoredMany(rels: string[]): Map<string, boolean>;
hasTracked(relDir: string): boolean;
isIgnored: (rel: string) => boolean;
isIgnoredMany: (rels: string[]) => Map<string, boolean>;
hasTracked: (relDir: string) => boolean;
/** Repo-relative name -> absolute path, for files inherited from a parent directory. */
overlay: Map<string, string>;
/** Root package.json scripts / dependencies a workspace package can use (hoisted tooling). */
Expand Down
2 changes: 1 addition & 1 deletion src/scan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
}
Expand Down
6 changes: 2 additions & 4 deletions src/util/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};
}

Expand Down
2 changes: 2 additions & 0 deletions src/util/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export function runCommand(cmd: string, opts: RunCommandOptions): Promise<RunRes
let output = '';
let timedOut = false;
let settled = false;
// The project's own commands (package.json scripts, Makefile targets) are shell strings.
// nosemgrep: javascript.lang.security.audit.spawn-shell-true.spawn-shell-true
const child = spawn(cmd, {
cwd: opts.cwd,
shell: true,
Expand Down
4 changes: 3 additions & 1 deletion test/scoring.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@ describe('fixture scoring', () => {
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',
},
});
Expand Down
Loading