Path: blob/main/tests/smoke/project/project-ai-config.test.ts
12925 views
/*1* project-ai-config.test.ts2*3* Verifies that AI assistant configuration files (CLAUDE.md, AGENTS.md)4* are properly excluded from project file discovery and rendering.5*6* Copyright (C) 2020-2025 Posit Software, PBC7*/89import { docs } from "../../utils.ts";10import { join } from "../../../src/deno_ral/path.ts";11import { existsSync } from "../../../src/deno_ral/fs.ts";12import { removeIfExists } from "../../../src/core/path.ts";13import { testQuartoCmd } from "../../test.ts";14import { fileExists, pathDoNotExists, noErrors } from "../../verify.ts";1516const projectDir = docs("project/ai-config-files");17const outputDir = join(projectDir, "_site");1819// .local.md fixture files are created at runtime to avoid .gitignore conflicts20const localFiles = ["CLAUDE.local.md", "AGENTS.local.md"];2122// Test that AI assistant config files are properly excluded23testQuartoCmd(24"render",25[projectDir],26[27noErrors,28fileExists(join(outputDir, "index.html")), // Control: regular file should be rendered29pathDoNotExists(join(outputDir, "CLAUDE.html")), // CLAUDE.md should be ignored30pathDoNotExists(join(outputDir, "AGENTS.html")), // AGENTS.md should be ignored31pathDoNotExists(join(outputDir, "CLAUDE.local.html")), // CLAUDE.local.md should be ignored32pathDoNotExists(join(outputDir, "AGENTS.local.html")), // AGENTS.local.md should be ignored33],34{35setup: async () => {36for (const file of localFiles) {37await Deno.writeTextFile(38join(projectDir, file),39"This is a local AI config file that should be ignored during project scanning.\n",40);41}42},43teardown: async () => {44for (const file of localFiles) {45removeIfExists(join(projectDir, file));46}47if (existsSync(outputDir)) {48await Deno.remove(outputDir, { recursive: true });49}50},51},52);535455