fix(rules-core): restore .sisyphus/rules discovery with deprecation warning (planned removal v4.3.0)
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -5,6 +5,11 @@ import { GLOBAL_DISTANCE, OPENCODE_USER_RULE_DIRS, PROJECT_RULE_FILES, PROJECT_R
|
||||
import { sortCandidates } from "./ordering";
|
||||
import { findRuleFilesRecursive, safeRealpathSync } from "./scanner";
|
||||
import type { DirectoryScanEntry, FindRuleFilesOptions, RuleFileCandidate, RuleScanCache, RuleSource } from "./types";
|
||||
import { log } from "../../../src/shared/logger";
|
||||
|
||||
const SISYPHUS_DEPRECATION_MESSAGE = "[rules] .sisyphus/rules is deprecated and will be removed in v4.3.0; migrate to .omo/rules";
|
||||
const SISYPHUS_LEGACY_RULE_SOURCES: ReadonlySet<RuleSource> = new Set([".sisyphus/rules", "~/.sisyphus/rules"]);
|
||||
const warnedSisyphusRuleDirectories = new Set<string>();
|
||||
|
||||
export function findRuleFiles(
|
||||
projectRoot: string | null,
|
||||
@@ -62,6 +67,7 @@ function addProjectRuleCandidates(
|
||||
for (const entry of scanDirectoryWithCache(ruleDir, cache)) {
|
||||
if (seenRealPaths.has(entry.realPath)) continue;
|
||||
seenRealPaths.add(entry.realPath);
|
||||
warnSisyphusRuleDeprecation(source, entry.path);
|
||||
candidates.push({
|
||||
path: entry.path,
|
||||
realPath: entry.realPath,
|
||||
@@ -115,6 +121,7 @@ function addUserRuleCandidates(
|
||||
for (const entry of scanDirectoryWithCache(userRuleDir, cache)) {
|
||||
if (seenRealPaths.has(entry.realPath)) continue;
|
||||
seenRealPaths.add(entry.realPath);
|
||||
warnSisyphusRuleDeprecation(source, entry.path);
|
||||
candidates.push({
|
||||
path: entry.path,
|
||||
realPath: entry.realPath,
|
||||
@@ -136,6 +143,17 @@ function scanDirectoryWithCache(dir: string, cache: RuleScanCache | undefined):
|
||||
return entries;
|
||||
}
|
||||
|
||||
function warnSisyphusRuleDeprecation(source: RuleSource, path: string): void {
|
||||
if (!SISYPHUS_LEGACY_RULE_SOURCES.has(source)) return;
|
||||
const warningKey = dirname(path);
|
||||
if (warnedSisyphusRuleDirectories.has(warningKey)) return;
|
||||
warnedSisyphusRuleDirectories.add(warningKey);
|
||||
log(SISYPHUS_DEPRECATION_MESSAGE, {
|
||||
event: "rules-sisyphus-deprecated",
|
||||
path,
|
||||
});
|
||||
}
|
||||
|
||||
function validFileRealPath(filePath: string): string | null {
|
||||
if (!existsSync(filePath)) return null;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user