vibe-rules
Version:
A utility for managing Cursor rules, Windsurf rules, and other AI prompts
39 lines • 1.93 kB
JavaScript
import { RuleType } from "../types.js";
import { saveInternalRule, loadInternalRule, listInternalRules } from "../utils/rule-storage.js";
import { createTaggedRuleBlock } from "../utils/rule-formatter.js";
import { appendOrUpdateTaggedBlock } from "../utils/single-file-helpers.js";
import { getDefaultTargetPath } from "../utils/path.js";
export class ZedRuleProvider {
async saveRule(config) {
return saveInternalRule(RuleType.ZED, config);
}
async loadRule(name) {
return loadInternalRule(RuleType.ZED, name);
}
async listRules() {
return listInternalRules(RuleType.ZED);
}
generateRuleContent(config, options) {
// Zed .rules files are expected to be plain text or use a format
// compatible with simple tagged blocks if we are managing multiple rules within it.
// For consistency with Windsurf and other single-file providers, we use tagged blocks.
return createTaggedRuleBlock(config, options);
}
async appendRule(name, targetPath, isGlobal, // isGlobal is not typically used for Zed's .rules
options) {
const ruleConfig = await this.loadRule(name);
if (!ruleConfig) {
console.error(`Rule "${name}" not found in internal ZED storage.`);
return false;
}
const finalTargetPath = targetPath || getDefaultTargetPath(RuleType.ZED, isGlobal);
return this.appendFormattedRule(ruleConfig, finalTargetPath, isGlobal, options);
}
async appendFormattedRule(config, targetPath, isGlobal, // isGlobal is not typically used for Zed's .rules
options) {
// Zed .rules files are at the root of the worktree, so isGlobal is likely false.
// We don't append inside a specific <vibe-rules Integration> block by default for .rules
return appendOrUpdateTaggedBlock(targetPath, config, options, false);
}
}
//# sourceMappingURL=zed-provider.js.map