{"record":{"id":"b97178392a80360a","repo":"can1357/oh-my-pi","slug":"rule-file-not-found-resolved","errorCode":null,"errorMessage":"Rule file not found: ${resolved}","messagePattern":"Rule file not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/cli/ttsr-cli.ts","lineNumber":303,"sourceCode":"async function loadProjectScanRules(cwd: string): Promise<Rule[]> {\n\tconst settingsInstance = await Settings.init({ cwd });\n\tinitializeWithSettings(settingsInstance);\n\tconst ttsrSettings = settingsInstance.getGroup(\"ttsr\");\n\tif (!ttsrSettings.enabled) {\n\t\treturn [];\n\t}\n\tconst result = await loadCapability<Rule>(ruleCapability.id, { cwd });\n\treturn filterTtsrRulesForScan(result.items, {\n\t\tbuiltinRules: ttsrSettings.builtinRules,\n\t\tdisabledRules: ttsrSettings.disabledRules,\n\t});\n}\n\nasync function readIsolatedRule(rulePath: string): Promise<Rule> {\n\tconst resolved = path.resolve(rulePath);\n\tconst file = Bun.file(resolved);\n\tif (!(await file.exists())) {\n\t\tthrow new Error(`Rule file not found: ${resolved}`);\n\t}\n\tconst content = await file.text();\n\tconst name = path.basename(resolved).replace(/\\.(md|mdc)$/, \"\");\n\treturn buildRuleFromMarkdown(name, content, resolved, createSourceMeta(\"ttsr-cli\", resolved, \"project\"), {\n\t\truleName: name,\n\t});\n}\n\nasync function loadIsolatedRule(rulePath: string): Promise<{ rules: Rule[]; manager: TtsrManager }> {\n\tconst rule = await readIsolatedRule(rulePath);\n\tconst manager = await createTtsrManager({\n\t\tenabled: true,\n\t\tcontextMode: \"discard\",\n\t\tinterruptMode: \"always\",\n\t\trepeatMode: \"once\",\n\t\trepeatGap: 10,\n\t\tbuiltinRules: true,\n\t\tdisabledRules: [],","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/cli/ttsr-cli.ts#L285-L321","documentation":"`omp ttsr test --rule <path>` (and scan --rule) loads a standalone rule markdown file. readIsolatedRule resolves the path and verifies existence before parsing; a missing file throws this error with the absolute path. The rule is intentionally bypassed from project discovery, so the CLI has no other way to find it.","triggerScenarios":"Running `omp ttsr test --rule <path>` where the markdown file does not exist at the resolved path — typo, wrong cwd, file deleted/renamed, or passing a directory instead of the .md/.mdc file.","commonSituations":"Testing a rule from a different repo whose path was copied incorrectly; rule files moved during a reorganization; shell glob not matching so a literal `rules/*.md` string was passed; relative path resolved against an unexpected cwd in scripts.","solutions":["Fix the path in --rule to point at the actual .md/.mdc file (the error prints the resolved absolute path to compare against).","Run `ls` on the rules directory to confirm the filename and extension (.md or .mdc).","Re-run from the project root if you used a relative path.","If the rule was renamed, update the path or use `omp ttsr list` to find rules already registered in project/user config."],"exampleFix":"// before\nomp ttsr test --snippet \"...\" --rule rule/no-secrets.md\n// after\nomp ttsr test --snippet \"...\" --rule rules/no-secrets.md","handlingStrategy":"validation","validationCode":"import * as fs from \"node:fs\";\nconst resolved = path.resolve(rulePath);\nif (!fs.existsSync(resolved) || !fs.statSync(resolved).isFile()) {\n  throw new Error(`Rule file missing: ${resolved}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await runTest(args, json, cwd);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith(\"Rule file not found:\")) {\n    console.error(`${err.message}\\n(cwd=${process.cwd()})`);\n  }\n  throw err;\n}","preventionTips":["Keep rule files under a stable rules/ directory with committed paths.","Use paths relative to the repo root and run CLI commands from the root.","Tab-complete rule paths instead of typing them.","If a rule moved, update references or use `omp ttsr list` for registered rules."],"tags":["cli","file-not-found","path","rules"],"backgroundTag":"file-not-found","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}