MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / getRuleDirectories

Function getRuleDirectories

src/services/rules/rules.ts:150–172  ·  view source on GitHub ↗
(cwd: string, modes: readonly RulesMode[] = DEFAULT_MODES)

Source from the content-addressed store, hash-verified

148}
149
150function getRuleDirectories(cwd: string, modes: readonly RulesMode[] = DEFAULT_MODES): RuleDirectoryInfo[] {
151 const globalRooDirectory = getGlobalRooDirectory()
152 const projectRooDirectory = getProjectRooDirectoryForCwd(cwd)
153 const bases: Array<{ scope: RuleScope; basePath: string }> = [{ scope: "global", basePath: globalRooDirectory }]
154 if (cwd) {
155 bases.push({ scope: "project", basePath: projectRooDirectory })
156 }
157
158 return bases.flatMap(({ scope, basePath }) => [
159 {
160 scope,
161 kind: "generic" as const,
162 directoryPath: path.join(basePath, "rules"),
163 },
164 ...modes.map((mode) => ({
165 scope,
166 kind: "mode" as const,
167 modeSlug: mode.slug,
168 modeName: mode.name,
169 directoryPath: path.join(basePath, `rules-${mode.slug}`),
170 })),
171 ])
172}
173
174async function scanRuleDirectory(directory: RuleDirectoryInfo): Promise<RuleMetadata[]> {
175 try {

Callers 1

getRulesFunction · 0.85

Calls 2

getGlobalRooDirectoryFunction · 0.90

Tested by

no test coverage detected