Files
oh-my-opencode/packages/omo-codex/plugin/components/rules/src/rules-engine-factory.ts
T
2026-05-30 19:12:20 +09:00

25 lines
651 B
TypeScript

import { readFileSync } from "node:fs";
import { configFromEnvironment } from "./config.js";
import { createEngine } from "./rules/engine.js";
import { findRuleCandidates } from "./rules/finder.js";
import { findProjectRoot } from "./rules/project-root.js";
interface RulesEngineFactoryOptions {
env?: NodeJS.ProcessEnv;
}
export function createRulesEngine(options: RulesEngineFactoryOptions, config = configFromEnvironment(options.env)) {
return createEngine(config, {
findCandidates: findRuleCandidates,
findProjectRoot,
readFile: (path) => {
try {
return readFileSync(path, "utf8");
} catch {
return null;
}
},
});
}