Skip to content

Commit ac3950a

Browse files
committed
feat(rules): load omo rule directories
1 parent b28202f commit ac3950a

13 files changed

Lines changed: 49 additions & 49 deletions

NOTICE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ codex-rules
33
This package implements rule/context loading for Codex plugins.
44
Its behavior is ported from pi-rules in the pi coding-agent extension ecosystem
55
and inspired by oh-my-openagent (omo) at https://github.com/code-yeongyu/oh-my-openagent,
6-
including omo's `.sisyphus/rules/` workflow and rules-injector hook architecture.
6+
including omo's `.omo/rules/` workflow and rules-injector hook architecture.
77
omo is originally licensed under the Sustainable Use License 1.0.
88

99
Yeongyu Kim (https://github.com/code-yeongyu), author of omo, pi-rules, and this

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Project-level sources:
2020
- `AGENTS.md`
2121
- `CLAUDE.md`
2222
- `CONTEXT.md`
23-
- `.sisyphus/rules/**/*.md`
23+
- `.omo/rules/**/*.md`
2424
- `.claude/rules/**/*.md`
2525
- `.cursor/rules/**/*.md`
2626
- `.github/instructions/**/*.md`

dist/rules/constants.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const PROJECT_MARKERS = [
1616
* the project root, second is the subdir scanned recursively.
1717
*/
1818
export const PROJECT_RULE_SUBDIRS = [
19-
[".sisyphus", "rules"],
19+
[".omo", "rules"],
2020
[".claude", "rules"],
2121
[".cursor", "rules"],
2222
[".github", "instructions"],
@@ -33,7 +33,7 @@ export const PROJECT_SINGLE_FILES = [
3333
/**
3434
* User-home rule directories.
3535
*/
36-
export const USER_HOME_RULE_SUBDIRS = [".sisyphus/rules", ".opencode/rules", ".claude/rules"];
36+
export const USER_HOME_RULE_SUBDIRS = [".omo/rules", ".opencode/rules", ".claude/rules"];
3737
/**
3838
* User-home single-file rules. The first one to exist wins per "first-match" semantics.
3939
*/
@@ -46,15 +46,15 @@ export const RULE_FILE_EXTENSIONS = [".md", ".mdc"];
4646
* Per-rule source priority for deterministic ordering. Lower = earlier.
4747
*/
4848
export const SOURCE_PRIORITY = new Map([
49-
[".sisyphus/rules", 0],
49+
[".omo/rules", 0],
5050
[".claude/rules", 1],
5151
[".cursor/rules", 2],
5252
[".github/instructions", 3],
5353
[".github/copilot-instructions.md", 4],
5454
["AGENTS.md", 5],
5555
["CLAUDE.md", 6],
5656
["CONTEXT.md", 7],
57-
["~/.sisyphus/rules", 100],
57+
["~/.omo/rules", 100],
5858
["~/.opencode/rules", 101],
5959
["~/.claude/rules", 102],
6060
["~/.config/opencode/AGENTS.md", 103],

dist/rules/finder.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ function toRelativePath(rootDirectory, filePath) {
194194
function toProjectRuleSource(parentDirectory, subDirectory) {
195195
const source = `${parentDirectory}/${subDirectory}`;
196196
switch (source) {
197-
case ".sisyphus/rules":
197+
case ".omo/rules":
198198
case ".claude/rules":
199199
case ".cursor/rules":
200200
case ".github/instructions":
@@ -217,7 +217,7 @@ function toProjectSingleFileSource(ruleFile) {
217217
function toUserHomeRuleSource(ruleSubdir) {
218218
const source = `~/${ruleSubdir}`;
219219
switch (source) {
220-
case "~/.sisyphus/rules":
220+
case "~/.omo/rules":
221221
case "~/.opencode/rules":
222222
case "~/.claude/rules":
223223
return source;

dist/rules/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export interface LoadedRule extends RuleCandidate {
7070
/**
7171
* Source identifier for rule files. Used for deterministic ordering and display.
7272
*/
73-
export type RuleSource = ".sisyphus/rules" | ".claude/rules" | ".cursor/rules" | ".github/instructions" | ".github/copilot-instructions.md" | "AGENTS.md" | "CLAUDE.md" | "CONTEXT.md" | "~/.sisyphus/rules" | "~/.opencode/rules" | "~/.claude/rules" | "~/.config/opencode/AGENTS.md" | "~/.claude/CLAUDE.md";
73+
export type RuleSource = ".omo/rules" | ".claude/rules" | ".cursor/rules" | ".github/instructions" | ".github/copilot-instructions.md" | "AGENTS.md" | "CLAUDE.md" | "CONTEXT.md" | "~/.omo/rules" | "~/.opencode/rules" | "~/.claude/rules" | "~/.config/opencode/AGENTS.md" | "~/.claude/CLAUDE.md";
7474
/**
7575
* Why a candidate matched the target file. Surfaced in the injection block so
7676
* the model can attribute its behavior to a specific rule.

scripts/bench-codex-rules.mjs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ async function measureHookFastPathRun() {
8989
const pluginData = mkdtempSync(join(tmpdir(), "codex-rules-hook-data-"));
9090
try {
9191
mkdirSync(join(projectRoot, "src"), { recursive: true });
92-
mkdirSync(join(projectRoot, ".sisyphus", "rules"), { recursive: true });
92+
mkdirSync(join(projectRoot, ".omo", "rules"), { recursive: true });
9393
writeFileSync(join(projectRoot, "package.json"), JSON.stringify({ name: "bench" }));
9494
writeFileSync(join(projectRoot, "src", "app.ts"), "export const app = true;\n");
9595
for (let index = 0; index < RULE_COUNT; index += 1) {
96-
writeFileSync(join(projectRoot, ".sisyphus", "rules", `rule-${index}.md`), ruleContent(`rule-${index}`));
96+
writeFileSync(join(projectRoot, ".omo", "rules", `rule-${index}.md`), ruleContent(`rule-${index}`));
9797
}
9898

9999
const input = {
@@ -112,12 +112,12 @@ async function measureHookFastPathRun() {
112112

113113
await runPostToolUseHook(input, {
114114
pluginDataRoot: pluginData,
115-
env: { CODEX_RULES_ENABLED_SOURCES: ".sisyphus/rules" },
115+
env: { CODEX_RULES_ENABLED_SOURCES: ".omo/rules" },
116116
});
117117
const start = process.hrtime.bigint();
118118
const repeatOutput = await runPostToolUseHook(input, {
119119
pluginDataRoot: pluginData,
120-
env: { CODEX_RULES_ENABLED_SOURCES: ".sisyphus/rules" },
120+
env: { CODEX_RULES_ENABLED_SOURCES: ".omo/rules" },
121121
});
122122
return {
123123
repeatDurationMs: Number(process.hrtime.bigint() - start) / 1_000_000,
@@ -155,7 +155,7 @@ function measureRun(targetPaths) {
155155
const projectRoot = mkdtempSync(join(tmpdir(), "codex-rules-bench-"));
156156
try {
157157
const candidates = makeCandidates(projectRoot);
158-
mkdirSync(join(projectRoot, ".sisyphus", "rules"), { recursive: true });
158+
mkdirSync(join(projectRoot, ".omo", "rules"), { recursive: true });
159159
for (const candidate of candidates) {
160160
writeFileSync(candidate.path, "");
161161
}
@@ -195,13 +195,13 @@ function distinctTargets(projectRoot) {
195195

196196
function makeCandidates(projectRoot) {
197197
return Array.from({ length: RULE_COUNT }, (_, index) => ({
198-
path: join(projectRoot, ".sisyphus", "rules", `rule-${index}.md`),
199-
realPath: join(projectRoot, ".sisyphus", "rules", `rule-${index}.md`),
200-
source: ".sisyphus/rules",
198+
path: join(projectRoot, ".omo", "rules", `rule-${index}.md`),
199+
realPath: join(projectRoot, ".omo", "rules", `rule-${index}.md`),
200+
source: ".omo/rules",
201201
distance: 0,
202202
isGlobal: false,
203203
isSingleFile: false,
204-
relativePath: `.sisyphus/rules/rule-${index}.md`,
204+
relativePath: `.omo/rules/rule-${index}.md`,
205205
}));
206206
}
207207

src/rules/constants.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const PROJECT_MARKERS: readonly string[] = [
1919
* the project root, second is the subdir scanned recursively.
2020
*/
2121
export const PROJECT_RULE_SUBDIRS: ReadonlyArray<readonly [string, string]> = [
22-
[".sisyphus", "rules"],
22+
[".omo", "rules"],
2323
[".claude", "rules"],
2424
[".cursor", "rules"],
2525
[".github", "instructions"],
@@ -38,7 +38,7 @@ export const PROJECT_SINGLE_FILES: readonly string[] = [
3838
/**
3939
* User-home rule directories.
4040
*/
41-
export const USER_HOME_RULE_SUBDIRS: readonly string[] = [".sisyphus/rules", ".opencode/rules", ".claude/rules"];
41+
export const USER_HOME_RULE_SUBDIRS: readonly string[] = [".omo/rules", ".opencode/rules", ".claude/rules"];
4242

4343
/**
4444
* User-home single-file rules. The first one to exist wins per "first-match" semantics.
@@ -54,15 +54,15 @@ export const RULE_FILE_EXTENSIONS: readonly string[] = [".md", ".mdc"];
5454
* Per-rule source priority for deterministic ordering. Lower = earlier.
5555
*/
5656
export const SOURCE_PRIORITY: ReadonlyMap<RuleSource, number> = new Map([
57-
[".sisyphus/rules", 0],
57+
[".omo/rules", 0],
5858
[".claude/rules", 1],
5959
[".cursor/rules", 2],
6060
[".github/instructions", 3],
6161
[".github/copilot-instructions.md", 4],
6262
["AGENTS.md", 5],
6363
["CLAUDE.md", 6],
6464
["CONTEXT.md", 7],
65-
["~/.sisyphus/rules", 100],
65+
["~/.omo/rules", 100],
6666
["~/.opencode/rules", 101],
6767
["~/.claude/rules", 102],
6868
["~/.config/opencode/AGENTS.md", 103],

src/rules/finder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ function toRelativePath(rootDirectory: string, filePath: string): string {
280280
function toProjectRuleSource(parentDirectory: string, subDirectory: string): RuleSource {
281281
const source = `${parentDirectory}/${subDirectory}`;
282282
switch (source) {
283-
case ".sisyphus/rules":
283+
case ".omo/rules":
284284
case ".claude/rules":
285285
case ".cursor/rules":
286286
case ".github/instructions":
@@ -305,7 +305,7 @@ function toProjectSingleFileSource(ruleFile: string): RuleSource {
305305
function toUserHomeRuleSource(ruleSubdir: string): RuleSource {
306306
const source = `~/${ruleSubdir}`;
307307
switch (source) {
308-
case "~/.sisyphus/rules":
308+
case "~/.omo/rules":
309309
case "~/.opencode/rules":
310310
case "~/.claude/rules":
311311
return source;

src/rules/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ export interface LoadedRule extends RuleCandidate {
7676
* Source identifier for rule files. Used for deterministic ordering and display.
7777
*/
7878
export type RuleSource =
79-
| ".sisyphus/rules"
79+
| ".omo/rules"
8080
| ".claude/rules"
8181
| ".cursor/rules"
8282
| ".github/instructions"
8383
| ".github/copilot-instructions.md"
8484
| "AGENTS.md"
8585
| "CLAUDE.md"
8686
| "CONTEXT.md"
87-
| "~/.sisyphus/rules"
87+
| "~/.omo/rules"
8888
| "~/.opencode/rules"
8989
| "~/.claude/rules"
9090
| "~/.config/opencode/AGENTS.md"

test/codex-hook-performance.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ function makeTempProject(ruleCount: number): { root: string; pluginData: string;
2121
tempDirectories.push(root, pluginData);
2222

2323
fs.writeFileSync(path.join(root, "package.json"), JSON.stringify({ name: "fixture" }));
24-
fs.mkdirSync(path.join(root, ".sisyphus", "rules"), { recursive: true });
24+
fs.mkdirSync(path.join(root, ".omo", "rules"), { recursive: true });
2525
fs.mkdirSync(path.join(root, "src"), { recursive: true });
2626
const targetPath = path.join(root, "src", "app.ts");
2727
fs.writeFileSync(targetPath, "export const app = true;\n");
2828

2929
for (let index = 0; index < ruleCount; index += 1) {
3030
fs.writeFileSync(
31-
path.join(root, ".sisyphus", "rules", `rule-${index}.md`),
31+
path.join(root, ".omo", "rules", `rule-${index}.md`),
3232
["---", 'globs: "**/*.ts"', "---", "", `Rule ${index}`].join("\n"),
3333
);
3434
}
@@ -53,7 +53,7 @@ function postToolUseInput(root: string, filePath: string): CodexPostToolUseInput
5353
}
5454

5555
function isProjectRuleRead(filePath: unknown): boolean {
56-
return String(filePath).includes(`${path.sep}.sisyphus${path.sep}rules${path.sep}`);
56+
return String(filePath).includes(`${path.sep}.omo${path.sep}rules${path.sep}`);
5757
}
5858

5959
describe("codex rules hook performance", () => {
@@ -77,13 +77,13 @@ describe("codex rules hook performance", () => {
7777
// when
7878
const firstOutput = await runPostToolUseHook(postToolUseInput(root, targetPath), {
7979
pluginDataRoot: pluginData,
80-
env: { CODEX_RULES_ENABLED_SOURCES: ".sisyphus/rules" },
80+
env: { CODEX_RULES_ENABLED_SOURCES: ".omo/rules" },
8181
});
8282
const firstRunRuleFileReads = ruleFileReads;
8383
ruleFileReads = 0;
8484
const secondOutput = await runPostToolUseHook(postToolUseInput(root, targetPath), {
8585
pluginDataRoot: pluginData,
86-
env: { CODEX_RULES_ENABLED_SOURCES: ".sisyphus/rules" },
86+
env: { CODEX_RULES_ENABLED_SOURCES: ".omo/rules" },
8787
});
8888

8989
// then

0 commit comments

Comments
 (0)