Merge branch 'fix/perf-d07' into fix/perf-omo-in-tree
This commit is contained in:
@@ -326,4 +326,40 @@ describe("non-directory commands path", () => {
|
||||
expect(testCmd).toBeDefined()
|
||||
expect(testCmd?.content).toContain("Test command content.")
|
||||
})
|
||||
|
||||
it("#given excluded subdirectories under .claude/commands #when discoverCommandsSync runs #then prunes commands beneath them", () => {
|
||||
// given
|
||||
const projectDir = join(testDir, "project")
|
||||
const commandsDir = join(projectDir, ".claude", "commands")
|
||||
|
||||
mkdirSync(join(commandsDir, "node_modules", "fake-pkg"), { recursive: true })
|
||||
mkdirSync(join(commandsDir, ".git", "branches"), { recursive: true })
|
||||
mkdirSync(join(commandsDir, "dist"), { recursive: true })
|
||||
writeFileSync(
|
||||
join(commandsDir, "real-cmd.md"),
|
||||
"---\ndescription: Real command\n---\nRun real command.\n",
|
||||
)
|
||||
writeFileSync(
|
||||
join(commandsDir, "node_modules", "fake-pkg", "cmd.md"),
|
||||
"---\ndescription: Nested command\n---\nRun nested command.\n",
|
||||
)
|
||||
writeFileSync(
|
||||
join(commandsDir, ".git", "branches", "cmd.md"),
|
||||
"---\ndescription: Git command\n---\nRun git command.\n",
|
||||
)
|
||||
writeFileSync(
|
||||
join(commandsDir, "dist", "bundled-cmd.md"),
|
||||
"---\ndescription: Bundled command\n---\nRun bundled command.\n",
|
||||
)
|
||||
|
||||
// when
|
||||
const commands = discoverCommandsSync(projectDir)
|
||||
const names = commands.map((command) => command.name)
|
||||
|
||||
// then
|
||||
expect(names).toContain("real-cmd")
|
||||
expect(names).not.toContain("node_modules/fake-pkg/cmd")
|
||||
expect(names).not.toContain(".git/branches/cmd")
|
||||
expect(names).not.toContain("dist/bundled-cmd")
|
||||
})
|
||||
})
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
findProjectOpencodeCommandDirs,
|
||||
getOpenCodeCommandDirs,
|
||||
discoverPluginCommandDefinitions,
|
||||
EXCLUDED_DIRS,
|
||||
} from "../../shared"
|
||||
import type { CommandFrontmatter } from "../../features/claude-code-command-loader/types"
|
||||
import { isMarkdownFile } from "../../shared/file-utils"
|
||||
@@ -36,6 +37,7 @@ function discoverCommandsFromDir(
|
||||
|
||||
for (const entry of entries) {
|
||||
if (entry.isDirectory()) {
|
||||
if (EXCLUDED_DIRS.has(entry.name)) continue
|
||||
if (entry.name.startsWith(".")) continue
|
||||
const nestedPrefix = prefix
|
||||
? `${prefix}${NESTED_COMMAND_SEPARATOR}${entry.name}`
|
||||
|
||||
Reference in New Issue
Block a user