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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ Keep HTTP work in the API or a Server Action. Next permits `src/app/health/route

API tests, test utilities and fixtures may use `fetch` when the same file starts a local server with `.listen(<numeric port>)`, including `.listen(0)`. MSW's `.listen({ ... })` still requires `onUnhandledRequest: "error"` (or `onUnhandledFrame: "error"` in MSW 3). Use `testClient()` for `/api` paths; direct `app.request(...)` or `createApp().request(...)` is allowed for literal paths outside `/api`, including static template literals.

## Monorepo READMEs

A repository with app workspaces under `apps/` can use up to 60 prose lines in its root README and 40 in each app README. Each file has one `#` title. Use headings that fit the project. Blank lines, fenced examples, and generated blocks are excluded from the count.

Use the root README for the project's purpose, local setup, checks, and how to navigate or operate the repo. Use app READMEs for app-specific instructions and lasting operating decisions.

## AGENTS.md

An `AGENTS.md` holds only what the code, the config and lint messages can't tell an agent. `pnpm lint` checks its shape:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mapringg/standard",
"version": "1.2.8",
"version": "1.3.0",
"description": "One oxlint config and plugin for every repository.",
"license": "MIT",
"repository": "github:mapringg/standard",
Expand Down
23 changes: 18 additions & 5 deletions src/plugin/agent-docs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { anchorFor, listFiles, locate } from "./paths.mjs";

const SECTIONS = ["Rules", "Words", "Copy", "Decisions", "Traps", "Operations", "Sources"];
const MAX_LINES = 50;
const ROOT_README_LINES = 60;
const APP_README_LINES = 40;
const CODE = /\.[cm]?[jt]sx?$/;
const BEGIN = /^<!-- BEGIN:([\w-]+) -->\s*$/;
const FENCE_OPEN = /^ {0,3}(?:(`{3,})[^`]*|(~{3,}).*)$/;
Expand Down Expand Up @@ -149,6 +151,16 @@ function shapeProblems(prose) {
return found;
}

function readmeProblems(prose, maxLines) {
const found = [];
const lines = prose.map(({ line }) => line).filter((line) => line.trim());
const titles = lines.map(headingOf).filter((heading) => heading?.level === 1 && heading.title);
if (titles.length !== 1) found.push("Use one # title naming the project.");
if (lines.length > maxLines)
found.push(`Cut it to ${maxLines} prose lines; keep setup, checks, and operational decisions.`);
return found;
}

function contentProblems(prose) {
const found = [];
const spans = [...joined(prose).matchAll(SPAN)].flatMap((match) => match[2].split(/\s+/));
Expand Down Expand Up @@ -197,6 +209,7 @@ function sharedSkillProblems(root, documentOf) {
function scan(root) {
const files = listFiles(root);
const lintable = files.filter((rel) => CODE.test(rel));
const monorepo = files.some((rel) => /^apps\/[^/]+\/package\.json$/.test(rel));
const documents = new Map();
const documentOf = (rel) => {
if (!documents.has(rel)) {
Expand All @@ -211,10 +224,10 @@ function scan(root) {
for (const rel of files.filter((file) => file.endsWith(".md"))) {
const { prose } = documentOf(rel);
const name = rel.slice(rel.lastIndexOf("/") + 1);
const problems = [
...(name === "AGENTS.md" ? [...shapeProblems(prose), ...contentProblems(prose)] : []),
...linkProblems(root, rel, prose, documentOf),
];
const problems = linkProblems(root, rel, prose, documentOf);
if (name === "AGENTS.md") problems.push(...shapeProblems(prose), ...contentProblems(prose));
if (monorepo && rel === "README.md") problems.push(...readmeProblems(prose, ROOT_README_LINES));
if (/^apps\/[^/]+\/README\.md$/.test(rel)) problems.push(...readmeProblems(prose, APP_README_LINES));
const anchor = anchorFor(rel.includes("/") ? rel.slice(0, rel.lastIndexOf("/")) : "", lintable);
if (!anchor || problems.length === 0) continue;
findings.set(anchor, [...(findings.get(anchor) ?? []), ...problems.map((message) => `${rel}: ${message}`)]);
Expand All @@ -235,7 +248,7 @@ export default {
type: "problem",
docs: {
description:
"AGENTS.md files share one shape and hold only what the code cannot show; Markdown links resolve. Findings report on the nearest linted file.",
"AGENTS.md and monorepo READMEs stay short; Markdown links resolve. Findings report on the nearest linted file.",
},
},
create(context) {
Expand Down
32 changes: 32 additions & 0 deletions test/agent-docs.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,35 @@ test("adopters link the installed skills without local copies", (t) => {
],
);
});

test("monorepo READMEs accept 60 root and 40 app prose lines with flexible headings", (t) => {
const example = "```sh\n" + "pnpm test\n".repeat(70) + "```\n";
deepEqual(
findings(t, {
"README.md": `# Repo\n\n## Getting started\n\n${"Run the app.\n\n".repeat(58)}${example}`,
"apps/web/README.md": `# Web\n\n### Run locally\n\n${"Open the app.\n".repeat(38)}${example}`,
}),
[],
);
});

test("monorepo READMEs report prose over budget and missing or duplicate titles", (t) => {
deepEqual(
findings(t, {
"README.md": `## Read this\n${"Run the app.\n".repeat(60)}`,
"apps/web/README.md": `# Web\n# Another title\n${"Open the app.\n".repeat(39)}`,
}),
[
"README.md: Cut it to 60 prose lines; keep setup, checks, and operational decisions.",
"README.md: Use one # title naming the project.",
"apps/web/README.md: Cut it to 40 prose lines; keep setup, checks, and operational decisions.",
"apps/web/README.md: Use one # title naming the project.",
],
);
});

test("standalone package and skill READMEs have no monorepo prose budget", (t) => {
const long = "Extended reference.\n".repeat(80);
deepEqual(only(lint(t, { "src/index.ts": code, "README.md": long }), "agent-docs"), []);
deepEqual(findings(t, { ".claude/skills/verify/README.md": long, "packages/tokens/README.md": long }), []);
});
Loading