formatting

This commit is contained in:
km-anthropic
2025-08-14 15:30:29 -07:00
parent 632f04bbcf
commit 30530c9829
2 changed files with 8 additions and 12 deletions

View File

@@ -90,20 +90,16 @@ export async function setupClaudeCodeSettings(
await $`test -d ${projectAgentsDir}`.quiet(); await $`test -d ${projectAgentsDir}`.quiet();
console.log(`Found project agents directory at ${projectAgentsDir}`); console.log(`Found project agents directory at ${projectAgentsDir}`);
// Ensure target agents directory exists
await $`mkdir -p ${claudeAgentsDir}`.quiet(); await $`mkdir -p ${claudeAgentsDir}`.quiet();
// Copy all .md files from project agents to Claude's agents directory
await $`cp ${projectAgentsDir}/*.md ${claudeAgentsDir}/ 2>/dev/null || true`.quiet(); await $`cp ${projectAgentsDir}/*.md ${claudeAgentsDir}/ 2>/dev/null || true`.quiet();
// Count copied agents for logging
const agentFiles = await $`ls ${claudeAgentsDir}/*.md 2>/dev/null | wc -l` const agentFiles = await $`ls ${claudeAgentsDir}/*.md 2>/dev/null | wc -l`
.quiet() .quiet()
.text(); .text();
const agentCount = parseInt(agentFiles.trim()) || 0; const agentCount = parseInt(agentFiles.trim()) || 0;
console.log(`Copied ${agentCount} agent(s) to ${claudeAgentsDir}`); console.log(`Copied ${agentCount} agent(s) to ${claudeAgentsDir}`);
} catch (e) { } catch (e) {
// Directory doesn't exist or no agents to copy - this is expected in most cases
console.log(`No project agents directory found at ${projectAgentsDir}`); console.log(`No project agents directory found at ${projectAgentsDir}`);
} }
} }

View File

@@ -221,7 +221,7 @@ describe("setupClaudeCodeSettings", () => {
const projectDir = join(testHomeDir, "test-project"); const projectDir = join(testHomeDir, "test-project");
const projectAgentsDir = join(projectDir, ".claude", "agents"); const projectAgentsDir = join(projectDir, ".claude", "agents");
await mkdir(projectAgentsDir, { recursive: true }); await mkdir(projectAgentsDir, { recursive: true });
// Create test agent files // Create test agent files
await writeFile( await writeFile(
join(projectAgentsDir, "test-agent.md"), join(projectAgentsDir, "test-agent.md"),
@@ -231,20 +231,20 @@ describe("setupClaudeCodeSettings", () => {
join(projectAgentsDir, "another-agent.md"), join(projectAgentsDir, "another-agent.md"),
"---\nname: another-agent\n---\nAnother agent", "---\nname: another-agent\n---\nAnother agent",
); );
// Set GITHUB_WORKSPACE to the test project directory // Set GITHUB_WORKSPACE to the test project directory
const originalWorkspace = process.env.GITHUB_WORKSPACE; const originalWorkspace = process.env.GITHUB_WORKSPACE;
process.env.GITHUB_WORKSPACE = projectDir; process.env.GITHUB_WORKSPACE = projectDir;
try { try {
await setupClaudeCodeSettings(undefined, testHomeDir); await setupClaudeCodeSettings(undefined, testHomeDir);
// Check that agents were copied // Check that agents were copied
const agentsDir = join(testHomeDir, ".claude", "agents"); const agentsDir = join(testHomeDir, ".claude", "agents");
const files = await readdir(agentsDir); const files = await readdir(agentsDir);
expect(files).toContain("test-agent.md"); expect(files).toContain("test-agent.md");
expect(files).toContain("another-agent.md"); expect(files).toContain("another-agent.md");
// Verify content was copied correctly // Verify content was copied correctly
const content = await readFile(join(agentsDir, "test-agent.md"), "utf-8"); const content = await readFile(join(agentsDir, "test-agent.md"), "utf-8");
expect(content).toContain("Test agent content"); expect(content).toContain("Test agent content");
@@ -262,13 +262,13 @@ describe("setupClaudeCodeSettings", () => {
// Set GITHUB_WORKSPACE to a directory without .claude/agents // Set GITHUB_WORKSPACE to a directory without .claude/agents
const projectDir = join(testHomeDir, "project-without-agents"); const projectDir = join(testHomeDir, "project-without-agents");
await mkdir(projectDir, { recursive: true }); await mkdir(projectDir, { recursive: true });
const originalWorkspace = process.env.GITHUB_WORKSPACE; const originalWorkspace = process.env.GITHUB_WORKSPACE;
process.env.GITHUB_WORKSPACE = projectDir; process.env.GITHUB_WORKSPACE = projectDir;
try { try {
await setupClaudeCodeSettings(undefined, testHomeDir); await setupClaudeCodeSettings(undefined, testHomeDir);
// Should complete without errors // Should complete without errors
const settingsContent = await readFile(settingsPath, "utf-8"); const settingsContent = await readFile(settingsPath, "utf-8");
const settings = JSON.parse(settingsContent); const settings = JSON.parse(settingsContent);