Skip to content

Commit 5701c4e

Browse files
cdervclaude
andcommitted
Add tests for AI config file exclusion
Add smoke tests to verify CLAUDE.md and AGENTS.md are excluded from: - Project input files (project-ai-config.test.ts) - Extension templates (template-ai-config.test.ts) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent cd38a6e commit 5701c4e

7 files changed

Lines changed: 120 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.quarto/
2+
**/*.quarto_ipynb
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: "Agents Configuration"
3+
---
4+
5+
This is an agents.md configuration file that should be ignored during project scanning.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: "Claude Configuration"
3+
---
4+
5+
This is an AI assistant configuration file that should be ignored during project scanning.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
project:
2+
type: website
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: "Home"
3+
---
4+
5+
This is the home page that should be rendered.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* project-ai-config.test.ts
3+
*
4+
* Verifies that AI assistant configuration files (CLAUDE.md, AGENTS.md)
5+
* are properly excluded from project file discovery and rendering.
6+
*
7+
* Copyright (C) 2020-2025 Posit Software, PBC
8+
*/
9+
10+
import { docs } from "../../utils.ts";
11+
import { join } from "../../../src/deno_ral/path.ts";
12+
import { existsSync } from "../../../src/deno_ral/fs.ts";
13+
import { testQuartoCmd } from "../../test.ts";
14+
import { fileExists, pathDoNotExists, noErrors } from "../../verify.ts";
15+
16+
const projectDir = docs("project/ai-config-files");
17+
const outputDir = join(projectDir, "_site");
18+
19+
// Test that AI assistant config files are properly excluded
20+
testQuartoCmd(
21+
"render",
22+
[projectDir],
23+
[
24+
noErrors,
25+
fileExists(join(outputDir, "index.html")), // Control: regular file should be rendered
26+
pathDoNotExists(join(outputDir, "CLAUDE.html")), // CLAUDE.md should be ignored
27+
pathDoNotExists(join(outputDir, "AGENTS.html")), // AGENTS.md should be ignored
28+
],
29+
{
30+
teardown: async () => {
31+
// Clean up _site directory
32+
if (existsSync(outputDir)) {
33+
await Deno.remove(outputDir, { recursive: true });
34+
}
35+
},
36+
},
37+
);
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* template-ai-config.test.ts
3+
*
4+
* Verifies that AI assistant configuration files (CLAUDE.md, AGENTS.md)
5+
* are properly excluded from extension templates when using "quarto use template".
6+
*
7+
* Copyright (C) 2020-2025 Posit Software, PBC
8+
*/
9+
10+
import { testQuartoCmd } from "../../test.ts";
11+
import { fileExists, noErrorsOrWarnings, pathDoNotExists } from "../../verify.ts";
12+
import { join } from "../../../src/deno_ral/path.ts";
13+
import { ensureDirSync } from "../../../src/deno_ral/fs.ts";
14+
15+
const tempDir = Deno.makeTempDirSync();
16+
17+
// Create a mock template source with AI config files
18+
const templateSourceDir = join(tempDir, "template-source");
19+
ensureDirSync(templateSourceDir);
20+
Deno.writeTextFileSync(
21+
join(templateSourceDir, "template.qmd"),
22+
"---\ntitle: Template Document\n---\n\nThis is a template document."
23+
);
24+
Deno.writeTextFileSync(
25+
join(templateSourceDir, "CLAUDE.md"),
26+
"# Claude Configuration\n\nThis should be excluded."
27+
);
28+
Deno.writeTextFileSync(
29+
join(templateSourceDir, "AGENTS.md"),
30+
"# Agents Configuration\n\nThis should be excluded."
31+
);
32+
Deno.writeTextFileSync(
33+
join(templateSourceDir, "README.md"),
34+
"# Template README\n\nThis should also be excluded."
35+
);
36+
37+
const templateFolder = "test-ai-config-template";
38+
const workingDir = join(tempDir, templateFolder);
39+
ensureDirSync(workingDir);
40+
41+
testQuartoCmd(
42+
"use",
43+
["template", templateSourceDir, "--no-prompt"],
44+
[
45+
noErrorsOrWarnings,
46+
fileExists(`${templateFolder}.qmd`), // Template file should be copied and renamed
47+
pathDoNotExists(join(workingDir, "CLAUDE.md")), // CLAUDE.md should be excluded
48+
pathDoNotExists(join(workingDir, "AGENTS.md")), // AGENTS.md should be excluded
49+
pathDoNotExists(join(workingDir, "README.md")), // README.md should also be excluded (sanity check)
50+
],
51+
{
52+
cwd: () => {
53+
return workingDir;
54+
},
55+
teardown: () => {
56+
try {
57+
Deno.removeSync(tempDir, { recursive: true });
58+
} catch {
59+
// Ignore cleanup errors
60+
}
61+
return Promise.resolve();
62+
}
63+
}
64+
);

0 commit comments

Comments
 (0)