@intellectronica/ruler 0.3.41 → 0.3.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/README.md +135 -36
  2. package/dist/agents/AbstractAgent.d.ts +53 -0
  3. package/dist/agents/AbstractAgent.js +3 -2
  4. package/dist/agents/AgentsMdAgent.d.ts +14 -0
  5. package/dist/agents/AgentsMdAgent.js +3 -2
  6. package/dist/agents/AiderAgent.d.ts +14 -0
  7. package/dist/agents/AiderAgent.js +7 -4
  8. package/dist/agents/AmazonQCliAgent.d.ts +13 -0
  9. package/dist/agents/AmazonQCliAgent.js +6 -4
  10. package/dist/agents/AmpAgent.d.ts +6 -0
  11. package/dist/agents/AntigravityAgent.d.ts +10 -0
  12. package/dist/agents/AugmentCodeAgent.d.ts +13 -0
  13. package/dist/agents/AugmentCodeAgent.js +3 -2
  14. package/dist/agents/ClaudeAgent.d.ts +13 -0
  15. package/dist/agents/ClineAgent.d.ts +9 -0
  16. package/dist/agents/CodexCliAgent.d.ts +31 -0
  17. package/dist/agents/CodexCliAgent.js +1 -1
  18. package/dist/agents/CopilotAgent.d.ts +20 -0
  19. package/dist/agents/CrushAgent.d.ts +14 -0
  20. package/dist/agents/CrushAgent.js +18 -6
  21. package/dist/agents/CursorAgent.d.ts +17 -0
  22. package/dist/agents/FactoryDroidAgent.d.ts +13 -0
  23. package/dist/agents/FirebaseAgent.d.ts +11 -0
  24. package/dist/agents/FirebenderAgent.d.ts +36 -0
  25. package/dist/agents/FirebenderAgent.js +5 -4
  26. package/dist/agents/GeminiCliAgent.d.ts +12 -0
  27. package/dist/agents/GeminiCliAgent.js +13 -7
  28. package/dist/agents/GooseAgent.d.ts +12 -0
  29. package/dist/agents/IAgent.d.ts +74 -0
  30. package/dist/agents/JetBrainsAiAssistantAgent.d.ts +10 -0
  31. package/dist/agents/JulesAgent.d.ts +5 -0
  32. package/dist/agents/JunieAgent.d.ts +12 -0
  33. package/dist/agents/KiloCodeAgent.d.ts +14 -0
  34. package/dist/agents/KiroAgent.d.ts +8 -0
  35. package/dist/agents/MistralVibeAgent.d.ts +31 -0
  36. package/dist/agents/MistralVibeAgent.js +14 -3
  37. package/dist/agents/OpenCodeAgent.d.ts +11 -0
  38. package/dist/agents/OpenCodeAgent.js +24 -12
  39. package/dist/agents/OpenHandsAgent.d.ts +8 -0
  40. package/dist/agents/PiAgent.d.ts +9 -0
  41. package/dist/agents/QwenCodeAgent.d.ts +11 -0
  42. package/dist/agents/QwenCodeAgent.js +11 -5
  43. package/dist/agents/RooCodeAgent.d.ts +16 -0
  44. package/dist/agents/RooCodeAgent.js +3 -2
  45. package/dist/agents/TraeAgent.d.ts +10 -0
  46. package/dist/agents/WarpAgent.d.ts +12 -0
  47. package/dist/agents/WindsurfAgent.d.ts +13 -0
  48. package/dist/agents/ZedAgent.d.ts +21 -0
  49. package/dist/agents/ZedAgent.js +8 -5
  50. package/dist/agents/agent-utils.d.ts +5 -0
  51. package/dist/agents/agent-utils.js +8 -5
  52. package/dist/agents/index.d.ts +9 -0
  53. package/dist/cli/commands.d.ts +4 -0
  54. package/dist/cli/commands.js +1 -2
  55. package/dist/cli/handlers.d.ts +41 -0
  56. package/dist/cli/handlers.js +75 -59
  57. package/dist/cli/index.d.ts +2 -0
  58. package/dist/constants.d.ts +35 -0
  59. package/dist/constants.js +1 -1
  60. package/dist/core/ConfigLoader.d.ts +59 -0
  61. package/dist/core/ConfigLoader.js +178 -44
  62. package/dist/core/FileSystemUtils.d.ts +53 -0
  63. package/dist/core/FileSystemUtils.js +157 -20
  64. package/dist/core/GitignoreUtils.d.ts +25 -0
  65. package/dist/core/GitignoreUtils.js +94 -32
  66. package/dist/core/RuleProcessor.d.ts +8 -0
  67. package/dist/core/SkillsProcessor.d.ts +127 -0
  68. package/dist/core/SkillsProcessor.js +118 -223
  69. package/dist/core/SkillsUtils.d.ts +26 -0
  70. package/dist/core/SubagentsProcessor.d.ts +38 -0
  71. package/dist/core/SubagentsProcessor.js +8 -5
  72. package/dist/core/SubagentsUtils.d.ts +34 -0
  73. package/dist/core/UnifiedConfigLoader.d.ts +10 -0
  74. package/dist/core/UnifiedConfigLoader.js +115 -33
  75. package/dist/core/UnifiedConfigTypes.d.ts +97 -0
  76. package/dist/core/agent-selection.d.ts +12 -0
  77. package/dist/core/agent-selection.js +17 -7
  78. package/dist/core/apply-engine.d.ts +70 -0
  79. package/dist/core/apply-engine.js +88 -58
  80. package/dist/core/config-utils.d.ts +14 -0
  81. package/dist/core/config-utils.js +9 -3
  82. package/dist/core/hash.d.ts +2 -0
  83. package/dist/core/path-utils.d.ts +1 -0
  84. package/dist/core/path-utils.js +42 -0
  85. package/dist/core/revert-engine.d.ts +37 -0
  86. package/dist/core/revert-engine.js +142 -34
  87. package/dist/lib.d.ts +13 -0
  88. package/dist/lib.js +24 -8
  89. package/dist/mcp/capabilities.d.ts +20 -0
  90. package/dist/mcp/merge.d.ts +10 -0
  91. package/dist/mcp/merge.js +36 -16
  92. package/dist/mcp/propagateOpenCodeMcp.d.ts +2 -0
  93. package/dist/mcp/propagateOpenCodeMcp.js +30 -11
  94. package/dist/mcp/propagateOpenHandsMcp.d.ts +2 -0
  95. package/dist/mcp/propagateOpenHandsMcp.js +48 -21
  96. package/dist/mcp/validate.d.ts +7 -0
  97. package/dist/mcp/validate.js +6 -1
  98. package/dist/paths/mcp.d.ts +8 -0
  99. package/dist/paths/mcp.js +44 -8
  100. package/dist/revert.d.ts +6 -0
  101. package/dist/revert.js +58 -46
  102. package/dist/types.d.ts +87 -0
  103. package/dist/vscode/settings.d.ts +40 -0
  104. package/dist/vscode/settings.js +3 -3
  105. package/package.json +8 -5
@@ -0,0 +1,12 @@
1
+ import { AbstractAgent } from './AbstractAgent';
2
+ /**
3
+ * Warp Agent Mode adapter.
4
+ * Generates WARP.md configuration file in the project root.
5
+ */
6
+ export declare class WarpAgent extends AbstractAgent {
7
+ getIdentifier(): string;
8
+ getName(): string;
9
+ getDefaultOutputPath(projectRoot: string): string;
10
+ supportsMcpStdio(): boolean;
11
+ supportsMcpRemote(): boolean;
12
+ }
@@ -0,0 +1,13 @@
1
+ import { AgentsMdAgent } from './AgentsMdAgent';
2
+ /**
3
+ * Windsurf agent adapter.
4
+ * Now uses AGENTS.md format like other agents.
5
+ */
6
+ export declare class WindsurfAgent extends AgentsMdAgent {
7
+ getIdentifier(): string;
8
+ getName(): string;
9
+ getMcpServerKey(): string;
10
+ supportsMcpStdio(): boolean;
11
+ supportsMcpRemote(): boolean;
12
+ supportsNativeSkills(): boolean;
13
+ }
@@ -0,0 +1,21 @@
1
+ import { AgentsMdAgent } from './AgentsMdAgent';
2
+ import { IAgentConfig } from './IAgent';
3
+ /**
4
+ * Zed editor agent adapter.
5
+ * Inherits from AgentsMdAgent to write instructions to AGENTS.md and handles
6
+ * MCP server configuration in .zed/settings.json at the project root.
7
+ */
8
+ export declare class ZedAgent extends AgentsMdAgent {
9
+ getIdentifier(): string;
10
+ getName(): string;
11
+ applyRulerConfig(concatenatedRules: string, projectRoot: string, rulerMcpJson: Record<string, unknown> | null, agentConfig?: IAgentConfig, backup?: boolean): Promise<void>;
12
+ getMcpServerKey(): string;
13
+ supportsMcpStdio(): boolean;
14
+ supportsMcpRemote(): boolean;
15
+ supportsNativeSkills(): boolean;
16
+ /**
17
+ * Transform MCP server configuration from ruler format to Zed format.
18
+ * Converts "type": "stdio" to "source": "custom" and preserves other fields.
19
+ */
20
+ private transformMcpServerForZed;
21
+ }
@@ -37,6 +37,7 @@ exports.ZedAgent = void 0;
37
37
  const path = __importStar(require("path"));
38
38
  const fs_1 = require("fs");
39
39
  const AgentsMdAgent_1 = require("./AgentsMdAgent");
40
+ const FileSystemUtils_1 = require("../core/FileSystemUtils");
40
41
  /**
41
42
  * Zed editor agent adapter.
42
43
  * Inherits from AgentsMdAgent to write instructions to AGENTS.md and handles
@@ -49,15 +50,15 @@ class ZedAgent extends AgentsMdAgent_1.AgentsMdAgent {
49
50
  getName() {
50
51
  return 'Zed';
51
52
  }
52
- async applyRulerConfig(concatenatedRules, projectRoot, rulerMcpJson, agentConfig) {
53
+ async applyRulerConfig(concatenatedRules, projectRoot, rulerMcpJson, agentConfig, backup = true) {
53
54
  // First, perform idempotent AGENTS.md write via base class
54
55
  await super.applyRulerConfig(concatenatedRules, projectRoot, null, {
55
56
  outputPath: agentConfig?.outputPath,
56
- });
57
+ }, backup);
57
58
  // Handle MCP server configuration if enabled and provided
58
59
  const mcpEnabled = agentConfig?.mcp?.enabled ?? true;
59
60
  if (mcpEnabled && rulerMcpJson) {
60
- const zedSettingsPath = path.join(projectRoot, '.zed', 'settings.json');
61
+ const zedSettingsPath = path.resolve(projectRoot, agentConfig?.outputPathConfig ?? path.join('.zed', 'settings.json'));
61
62
  // Read existing settings
62
63
  let existingSettings = {};
63
64
  try {
@@ -103,8 +104,7 @@ class ZedAgent extends AgentsMdAgent_1.AgentsMdAgent {
103
104
  };
104
105
  }
105
106
  // Write updated settings
106
- await fs_1.promises.mkdir(path.dirname(zedSettingsPath), { recursive: true });
107
- await fs_1.promises.writeFile(zedSettingsPath, JSON.stringify(mergedSettings, null, 2));
107
+ await (0, FileSystemUtils_1.writeGeneratedFile)(zedSettingsPath, JSON.stringify(mergedSettings, null, 2), projectRoot);
108
108
  }
109
109
  }
110
110
  getMcpServerKey() {
@@ -116,6 +116,9 @@ class ZedAgent extends AgentsMdAgent_1.AgentsMdAgent {
116
116
  supportsMcpRemote() {
117
117
  return true;
118
118
  }
119
+ supportsNativeSkills() {
120
+ return true;
121
+ }
119
122
  /**
120
123
  * Transform MCP server configuration from ruler format to Zed format.
121
124
  * Converts "type": "stdio" to "source": "custom" and preserves other fields.
@@ -0,0 +1,5 @@
1
+ import { IAgent, IAgentConfig } from './IAgent';
2
+ /**
3
+ * Gets all output paths for an agent, taking into account any config overrides.
4
+ */
5
+ export declare function getAgentOutputPaths(agent: IAgent, projectRoot: string, agentConfig?: IAgentConfig): string[];
@@ -17,17 +17,20 @@ function getAgentOutputPaths(agent, projectRoot, agentConfig) {
17
17
  const defaultPaths = defaults;
18
18
  // Handle instructions path
19
19
  if ('instructions' in defaultPaths) {
20
- const instructionsPath = agentConfig?.outputPathInstructions ?? defaultPaths.instructions;
20
+ const instructionsPath = agentConfig?.outputPath ??
21
+ agentConfig?.outputPathInstructions ??
22
+ defaultPaths.instructions;
21
23
  paths.push(instructionsPath);
22
24
  }
23
- // Handle config path
24
- if ('config' in defaultPaths) {
25
- const configPath = agentConfig?.outputPathConfig ?? defaultPaths.config;
25
+ // Handle config/MCP path
26
+ const configKey = 'config' in defaultPaths ? 'config' : 'mcp';
27
+ if (configKey in defaultPaths) {
28
+ const configPath = agentConfig?.outputPathConfig ?? defaultPaths[configKey];
26
29
  paths.push(configPath);
27
30
  }
28
31
  // Handle any other paths in the default paths record
29
32
  for (const [key, defaultPath] of Object.entries(defaultPaths)) {
30
- if (key !== 'instructions' && key !== 'config') {
33
+ if (key !== 'instructions' && key !== configKey) {
31
34
  // For unknown path types, use the default since we don't have specific config overrides
32
35
  paths.push(defaultPath);
33
36
  }
@@ -0,0 +1,9 @@
1
+ import { IAgent } from './IAgent';
2
+ import { AbstractAgent } from './AbstractAgent';
3
+ export { AbstractAgent };
4
+ export declare const allAgents: IAgent[];
5
+ /**
6
+ * Generates a comma-separated list of agent identifiers for CLI help text.
7
+ * Returns identifiers in alphabetical order, with 'agentsmd' always first.
8
+ */
9
+ export declare function getAgentIdentifiersForCliHelp(): string;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Sets up and parses CLI commands.
3
+ */
4
+ export declare function run(): void;
@@ -71,8 +71,7 @@ function run() {
71
71
  })
72
72
  .option('backup', {
73
73
  type: 'boolean',
74
- description: 'Enable/disable creation of .bak backup files (default: enabled)',
75
- default: true,
74
+ description: 'Enable/disable creation of .bak backup files (default: from config or enabled)',
76
75
  })
77
76
  .option('skills', {
78
77
  type: 'boolean',
@@ -0,0 +1,41 @@
1
+ export interface ApplyArgs {
2
+ 'project-root': string;
3
+ agents?: string;
4
+ config?: string;
5
+ mcp: boolean;
6
+ 'mcp-overwrite': boolean;
7
+ gitignore?: boolean;
8
+ 'gitignore-local'?: boolean;
9
+ verbose: boolean;
10
+ 'dry-run': boolean;
11
+ 'local-only': boolean;
12
+ nested?: boolean;
13
+ backup?: boolean;
14
+ skills?: boolean;
15
+ subagents?: boolean;
16
+ }
17
+ export interface InitArgs {
18
+ 'project-root': string;
19
+ global: boolean;
20
+ }
21
+ export interface RevertArgs {
22
+ 'project-root': string;
23
+ agents?: string;
24
+ config?: string;
25
+ 'keep-backups': boolean;
26
+ verbose: boolean;
27
+ 'dry-run': boolean;
28
+ 'local-only': boolean;
29
+ }
30
+ /**
31
+ * Handler for the 'apply' command.
32
+ */
33
+ export declare function applyHandler(argv: ApplyArgs): Promise<void>;
34
+ /**
35
+ * Handler for the 'init' command.
36
+ */
37
+ export declare function initHandler(argv: InitArgs): Promise<void>;
38
+ /**
39
+ * Handler for the 'revert' command.
40
+ */
41
+ export declare function revertHandler(argv: RevertArgs): Promise<void>;
@@ -51,15 +51,41 @@ function assertNotInsideRulerDir(projectRoot) {
51
51
  process.exit(1);
52
52
  }
53
53
  }
54
+ function formatCliError(message) {
55
+ return message.startsWith(constants_1.ERROR_PREFIX)
56
+ ? message
57
+ : `${constants_1.ERROR_PREFIX} ${message}`;
58
+ }
59
+ function parseCliAgents(agents) {
60
+ if (agents === undefined) {
61
+ return undefined;
62
+ }
63
+ const parsedAgents = agents.split(',').map((agent) => agent.trim());
64
+ if (parsedAgents.some((agent) => agent.length === 0)) {
65
+ throw new Error('Empty agent token in --agents. Remove extra commas or provide an agent name.');
66
+ }
67
+ return parsedAgents;
68
+ }
69
+ async function resolveNestedPreference(argv, projectRoot, configPath, localOnly) {
70
+ if (argv.nested !== undefined) {
71
+ // CLI explicitly set nested (either --nested or --no-nested)
72
+ return argv.nested;
73
+ }
74
+ // CLI didn't set nested, check TOML configuration
75
+ const config = await (0, ConfigLoader_1.loadConfig)({
76
+ projectRoot,
77
+ configPath,
78
+ checkGlobal: !localOnly,
79
+ });
80
+ // Use TOML setting if available, otherwise default to false
81
+ return config.nested ?? false;
82
+ }
54
83
  /**
55
84
  * Handler for the 'apply' command.
56
85
  */
57
86
  async function applyHandler(argv) {
58
87
  const projectRoot = argv['project-root'];
59
88
  assertNotInsideRulerDir(projectRoot);
60
- const agents = argv.agents
61
- ? argv.agents.split(',').map((a) => a.trim())
62
- : undefined;
63
89
  const configPath = argv.config;
64
90
  const mcpEnabled = argv.mcp;
65
91
  const mcpStrategy = argv['mcp-overwrite']
@@ -85,27 +111,6 @@ async function applyHandler(argv) {
85
111
  else {
86
112
  gitignoreLocalPreference = undefined; // Let TOML/default decide
87
113
  }
88
- // Determine nested preference: CLI > TOML > Default (false)
89
- let nested;
90
- if (argv.nested !== undefined) {
91
- // CLI explicitly set nested (either --nested or --no-nested)
92
- nested = argv.nested;
93
- }
94
- else {
95
- // CLI didn't set nested, check TOML configuration
96
- try {
97
- const config = await (0, ConfigLoader_1.loadConfig)({
98
- projectRoot,
99
- configPath,
100
- });
101
- // Use TOML setting if available, otherwise default to false
102
- nested = config.nested ?? false;
103
- }
104
- catch {
105
- // If config loading fails, use default (false)
106
- nested = false;
107
- }
108
- }
109
114
  // Determine skills preference: CLI > TOML > Default (enabled)
110
115
  let skillsEnabled;
111
116
  if (argv.skills !== undefined) {
@@ -123,12 +128,15 @@ async function applyHandler(argv) {
123
128
  subagentsEnabled = undefined; // Let config/default decide
124
129
  }
125
130
  try {
131
+ const agents = parseCliAgents(argv.agents);
132
+ // Determine nested preference: CLI > TOML > Default (false)
133
+ const nested = await resolveNestedPreference(argv, projectRoot, configPath, localOnly);
126
134
  await (0, lib_1.applyAllAgentConfigs)(projectRoot, agents, configPath, mcpEnabled, mcpStrategy, gitignorePreference, verbose, dryRun, localOnly, nested, backup, skillsEnabled, gitignoreLocalPreference, subagentsEnabled);
127
135
  console.log('Ruler apply completed successfully.');
128
136
  }
129
137
  catch (err) {
130
138
  const message = err instanceof Error ? err.message : String(err);
131
- console.error(`${constants_1.ERROR_PREFIX} ${message}`);
139
+ console.error(formatCliError(message));
132
140
  process.exit(1);
133
141
  }
134
142
  }
@@ -138,23 +146,24 @@ async function applyHandler(argv) {
138
146
  async function initHandler(argv) {
139
147
  const projectRoot = argv['project-root'];
140
148
  const isGlobal = argv['global'];
141
- const rulerDir = isGlobal
142
- ? path.join(process.env.XDG_CONFIG_HOME || path.join(os.homedir(), '.config'), 'ruler')
143
- : path.join(projectRoot, '.ruler');
144
- await fs.mkdir(rulerDir, { recursive: true });
145
- const instructionsPath = path.join(rulerDir, constants_1.DEFAULT_RULES_FILENAME); // .ruler/AGENTS.md
146
- const tomlPath = path.join(rulerDir, 'ruler.toml');
147
- const exists = async (p) => {
148
- try {
149
- await fs.access(p);
150
- return true;
151
- }
152
- catch {
153
- return false;
154
- }
155
- };
156
- const DEFAULT_INSTRUCTIONS = `# AGENTS.md\n\nCentralised AI agent instructions. Add coding guidelines, style guides, and project context here.\n\nRuler concatenates all .md files in this directory (and subdirectories), starting with AGENTS.md (if present), then remaining files in sorted order.\n`;
157
- const DEFAULT_TOML = `# Ruler Configuration File
149
+ try {
150
+ const rulerDir = isGlobal
151
+ ? path.join(process.env.XDG_CONFIG_HOME || path.join(os.homedir(), '.config'), 'ruler')
152
+ : path.join(projectRoot, '.ruler');
153
+ await fs.mkdir(rulerDir, { recursive: true });
154
+ const instructionsPath = path.join(rulerDir, constants_1.DEFAULT_RULES_FILENAME); // .ruler/AGENTS.md
155
+ const tomlPath = path.join(rulerDir, 'ruler.toml');
156
+ const exists = async (p) => {
157
+ try {
158
+ await fs.access(p);
159
+ return true;
160
+ }
161
+ catch {
162
+ return false;
163
+ }
164
+ };
165
+ const DEFAULT_INSTRUCTIONS = `# AGENTS.md\n\nCentralised AI agent instructions. Add coding guidelines, style guides, and project context here.\n\nRuler concatenates all .md files in this directory (and subdirectories), starting with AGENTS.md (if present), then remaining files in sorted order.\n`;
166
+ const DEFAULT_TOML = `# Ruler Configuration File
158
167
  # See https://ai.intellectronica.net/ruler for documentation.
159
168
 
160
169
  # To specify which agents are active by default when --agents is not used,
@@ -169,6 +178,9 @@ async function initHandler(argv) {
169
178
  # enabled = true
170
179
  # local = false # set true to write generated ignores to .git/info/exclude instead
171
180
 
181
+ # [backup]
182
+ # enabled = true # set false to disable .bak backup files
183
+
172
184
  # --- Agent Specific Configurations ---
173
185
  # You can enable/disable agents and override their default output paths here.
174
186
  # Use lowercase agent identifiers: aider, amp, claude, cline, codex, copilot, cursor, jetbrains-ai, kilocode, pi, windsurf
@@ -199,20 +211,26 @@ async function initHandler(argv) {
199
211
  # url = "https://api.example.com/mcp"
200
212
  # headers = { Authorization = "Bearer REPLACE_ME" }
201
213
  `;
202
- if (!(await exists(instructionsPath))) {
203
- // Create new AGENTS.md regardless of legacy presence.
204
- await fs.writeFile(instructionsPath, DEFAULT_INSTRUCTIONS);
205
- console.log(`[ruler] Created ${instructionsPath}`);
206
- }
207
- else {
208
- console.log(`[ruler] ${constants_1.DEFAULT_RULES_FILENAME} already exists, skipping`);
209
- }
210
- if (!(await exists(tomlPath))) {
211
- await fs.writeFile(tomlPath, DEFAULT_TOML);
212
- console.log(`[ruler] Created ${tomlPath}`);
214
+ if (!(await exists(instructionsPath))) {
215
+ // Create new AGENTS.md regardless of legacy presence.
216
+ await fs.writeFile(instructionsPath, DEFAULT_INSTRUCTIONS);
217
+ console.log(`[ruler] Created ${instructionsPath}`);
218
+ }
219
+ else {
220
+ console.log(`[ruler] ${constants_1.DEFAULT_RULES_FILENAME} already exists, skipping`);
221
+ }
222
+ if (!(await exists(tomlPath))) {
223
+ await fs.writeFile(tomlPath, DEFAULT_TOML);
224
+ console.log(`[ruler] Created ${tomlPath}`);
225
+ }
226
+ else {
227
+ console.log(`[ruler] ruler.toml already exists, skipping`);
228
+ }
213
229
  }
214
- else {
215
- console.log(`[ruler] ruler.toml already exists, skipping`);
230
+ catch (err) {
231
+ const message = err instanceof Error ? err.message : String(err);
232
+ console.error(formatCliError(message));
233
+ process.exit(1);
216
234
  }
217
235
  }
218
236
  /**
@@ -221,20 +239,18 @@ async function initHandler(argv) {
221
239
  async function revertHandler(argv) {
222
240
  const projectRoot = argv['project-root'];
223
241
  assertNotInsideRulerDir(projectRoot);
224
- const agents = argv.agents
225
- ? argv.agents.split(',').map((a) => a.trim())
226
- : undefined;
227
242
  const configPath = argv.config;
228
243
  const keepBackups = argv['keep-backups'];
229
244
  const verbose = argv.verbose;
230
245
  const dryRun = argv['dry-run'];
231
246
  const localOnly = argv['local-only'];
232
247
  try {
248
+ const agents = parseCliAgents(argv.agents);
233
249
  await (0, revert_1.revertAllAgentConfigs)(projectRoot, agents, configPath, keepBackups, verbose, dryRun, localOnly);
234
250
  }
235
251
  catch (err) {
236
252
  const message = err instanceof Error ? err.message : String(err);
237
- console.error(`${constants_1.ERROR_PREFIX} ${message}`);
253
+ console.error(formatCliError(message));
238
254
  process.exit(1);
239
255
  }
240
256
  }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,35 @@
1
+ export declare const ERROR_PREFIX = "[ruler]";
2
+ export declare const DEFAULT_RULES_FILENAME = "AGENTS.md";
3
+ export declare function actionPrefix(dry: boolean): string;
4
+ export declare function createRulerError(message: string, context?: string): Error;
5
+ export declare function logVerbose(message: string, isVerbose: boolean): void;
6
+ /**
7
+ * Centralized logging functions with consistent output streams and prefixing.
8
+ * - info/verbose go to stdout (user-visible progress)
9
+ * - warn/error go to stderr (problems)
10
+ */
11
+ export declare function logInfo(message: string, dryRun?: boolean): void;
12
+ export declare function logWarn(message: string, dryRun?: boolean): void;
13
+ export declare function logError(message: string, dryRun?: boolean): void;
14
+ export declare function logVerboseInfo(message: string, isVerbose: boolean, dryRun?: boolean): void;
15
+ export declare const SKILLS_DIR = "skills";
16
+ export declare const RULER_SKILLS_PATH = ".ruler/skills";
17
+ export declare const CLAUDE_SKILLS_PATH = ".claude/skills";
18
+ export declare const CODEX_SKILLS_PATH = ".agents/skills";
19
+ export declare const OPENCODE_SKILLS_PATH = ".opencode/skills";
20
+ export declare const PI_SKILLS_PATH = ".pi/skills";
21
+ export declare const GOOSE_SKILLS_PATH = ".agents/skills";
22
+ export declare const VIBE_SKILLS_PATH = ".vibe/skills";
23
+ export declare const ROO_SKILLS_PATH = ".roo/skills";
24
+ export declare const GEMINI_SKILLS_PATH = ".gemini/skills";
25
+ export declare const JUNIE_SKILLS_PATH = ".junie/skills";
26
+ export declare const CURSOR_SKILLS_PATH = ".cursor/skills";
27
+ export declare const WINDSURF_SKILLS_PATH = ".windsurf/skills";
28
+ export declare const FACTORY_SKILLS_PATH = ".factory/skills";
29
+ export declare const ANTIGRAVITY_SKILLS_PATH = ".agent/skills";
30
+ export declare const SKILL_MD_FILENAME = "SKILL.md";
31
+ export declare const RULER_SUBAGENTS_PATH = ".ruler/agents";
32
+ export declare const CLAUDE_SUBAGENTS_PATH = ".claude/agents";
33
+ export declare const CURSOR_SUBAGENTS_PATH = ".cursor/agents";
34
+ export declare const CODEX_SUBAGENTS_PATH = ".codex/agents";
35
+ export declare const COPILOT_SUBAGENTS_PATH = ".github/agents";
package/dist/constants.js CHANGED
@@ -53,7 +53,7 @@ function logVerboseInfo(message, isVerbose, dryRun = false) {
53
53
  exports.SKILLS_DIR = 'skills';
54
54
  exports.RULER_SKILLS_PATH = '.ruler/skills';
55
55
  exports.CLAUDE_SKILLS_PATH = '.claude/skills';
56
- exports.CODEX_SKILLS_PATH = '.codex/skills';
56
+ exports.CODEX_SKILLS_PATH = '.agents/skills';
57
57
  exports.OPENCODE_SKILLS_PATH = '.opencode/skills';
58
58
  exports.PI_SKILLS_PATH = '.pi/skills';
59
59
  exports.GOOSE_SKILLS_PATH = '.agents/skills';
@@ -0,0 +1,59 @@
1
+ import { McpConfig, GlobalMcpConfig, GitignoreConfig, BackupConfig, SkillsConfig, SubagentsConfig } from '../types';
2
+ /** Test helper — re-arms the deprecation guard so suites can assert it fires. */
3
+ export declare function _resetLegacySubagentsWarningForTests(): void;
4
+ /**
5
+ * Configuration for a specific agent as defined in ruler.toml.
6
+ */
7
+ export interface IAgentConfig {
8
+ enabled?: boolean;
9
+ outputPath?: string;
10
+ outputPathInstructions?: string;
11
+ outputPathConfig?: string;
12
+ /** MCP propagation config for this agent. */
13
+ mcp?: McpConfig;
14
+ /** Agent-scoped MCP server definitions. */
15
+ mcpServers?: Record<string, Record<string, unknown>>;
16
+ }
17
+ /**
18
+ * Parsed ruler configuration values.
19
+ */
20
+ export interface LoadedConfig {
21
+ /** Agents to run by default, as specified by default_agents. */
22
+ defaultAgents?: string[];
23
+ /** Per-agent configuration overrides. */
24
+ agentConfigs: Record<string, IAgentConfig>;
25
+ /** Command-line agent filters (--agents), if provided. */
26
+ cliAgents?: string[];
27
+ /** Global MCP servers configuration section. */
28
+ mcp?: GlobalMcpConfig;
29
+ /** Gitignore configuration section. */
30
+ gitignore?: GitignoreConfig;
31
+ /** Backup configuration section. */
32
+ backup?: BackupConfig;
33
+ /** Skills configuration section. */
34
+ skills?: SkillsConfig;
35
+ /** Subagents configuration section. */
36
+ subagents?: SubagentsConfig;
37
+ /** Whether to enable nested rule loading from nested .ruler directories. */
38
+ nested?: boolean;
39
+ /** Whether the nested option was explicitly provided in the config. */
40
+ nestedDefined?: boolean;
41
+ }
42
+ /**
43
+ * Options for loading the ruler configuration.
44
+ */
45
+ export interface ConfigOptions {
46
+ projectRoot: string;
47
+ /** Path to a custom TOML config file. */
48
+ configPath?: string;
49
+ /** CLI filters from --agents option. */
50
+ cliAgents?: string[];
51
+ /** Whether implicit config discovery may fall back to XDG_CONFIG_HOME/ruler. */
52
+ checkGlobal?: boolean;
53
+ }
54
+ /**
55
+ * Loads and parses the ruler TOML configuration file, applying defaults.
56
+ * Missing implicit configs return defaults. Explicit configs and existing
57
+ * implicit configs fail fast when missing, unreadable, or invalid.
58
+ */
59
+ export declare function loadConfig(options: ConfigOptions): Promise<LoadedConfig>;