refactor(rules-engine): centralize rule constants and AGENTS.md walk-up
Promote the project-rule constants (PROJECT_MARKERS, PROJECT_RULE_SUBDIRS, PROJECT_RULE_FILES, OPENCODE_USER_RULE_DIRS, USER_RULE_DIR, GITHUB_INSTRUCTIONS_PATTERN, RULE_EXTENSIONS, AGENTS_FILENAME, etc.) and the findAgentsMdUp walk-up helper out of the agents-md-core and rules-injector adapters and into @oh-my-opencode/rules-engine, the single owner of rule discovery. - packages/agents-md-core/ drops the findAgentsMdUp/AgentsMdDiscoveryInput wrappers (now sourced directly from rules-engine) and its constants module re-exports AGENTS_FILENAME from rules-engine instead of duplicating it. - src/hooks/directory-agents-injector/finder.ts pulls findAgentsMdUp from rules-engine directly while still re-exporting resolveFilePath from agents-md-core. - src/hooks/rules-injector/constants.ts becomes a pure re-export shim over the rules-engine constants. Add packages/agents-md-core/src/injector.test.ts to lock the root-skipping AGENTS.md injection order so future changes to findAgentsMdUp cannot silently regress the [Directory Context: ...] block format the injector emits. Tests: bun test packages/agents-md-core packages/rules-engine src/hooks/directory-agents-injector src/hooks/rules-injector
This commit is contained in:
@@ -1,4 +1,2 @@
|
||||
export {
|
||||
findAgentsMdUp,
|
||||
resolveFilePath,
|
||||
} from "@oh-my-opencode/agents-md-core";
|
||||
export { resolveFilePath } from "@oh-my-opencode/agents-md-core";
|
||||
export { findAgentsMdUp } from "@oh-my-opencode/rules-engine";
|
||||
|
||||
@@ -2,30 +2,12 @@ import { join } from "node:path";
|
||||
import { OPENCODE_STORAGE } from "../../shared";
|
||||
export const RULES_INJECTOR_STORAGE = join(OPENCODE_STORAGE, "rules-injector");
|
||||
|
||||
export const PROJECT_MARKERS = [
|
||||
".git",
|
||||
"pyproject.toml",
|
||||
"package.json",
|
||||
"Cargo.toml",
|
||||
"go.mod",
|
||||
".venv",
|
||||
];
|
||||
|
||||
export const PROJECT_RULE_SUBDIRS: [string, string][] = [
|
||||
[".github", "instructions"],
|
||||
[".cursor", "rules"],
|
||||
[".claude", "rules"],
|
||||
[".omo", "rules"],
|
||||
];
|
||||
|
||||
export const PROJECT_RULE_FILES: string[] = [
|
||||
".github/copilot-instructions.md",
|
||||
];
|
||||
|
||||
export const GITHUB_INSTRUCTIONS_PATTERN = /\.instructions\.md$/;
|
||||
|
||||
export const USER_RULE_DIR = ".claude/rules";
|
||||
|
||||
export const OPENCODE_USER_RULE_DIRS = [".omo/rules", ".opencode/rules"];
|
||||
|
||||
export const RULE_EXTENSIONS = [".md", ".mdc"];
|
||||
export {
|
||||
GITHUB_INSTRUCTIONS_PATTERN,
|
||||
OPENCODE_USER_RULE_DIRS,
|
||||
PROJECT_MARKERS,
|
||||
PROJECT_RULE_FILES,
|
||||
PROJECT_RULE_SUBDIRS,
|
||||
RULE_EXTENSIONS,
|
||||
USER_RULE_DIR,
|
||||
} from "@oh-my-opencode/rules-engine";
|
||||
|
||||
Reference in New Issue
Block a user