@intellectronica/ruler 0.3.41 → 0.3.42

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 (94) hide show
  1. package/README.md +40 -28
  2. package/dist/agents/AbstractAgent.d.ts +53 -0
  3. package/dist/agents/AgentsMdAgent.d.ts +14 -0
  4. package/dist/agents/AiderAgent.d.ts +14 -0
  5. package/dist/agents/AiderAgent.js +3 -1
  6. package/dist/agents/AmazonQCliAgent.d.ts +13 -0
  7. package/dist/agents/AmpAgent.d.ts +6 -0
  8. package/dist/agents/AntigravityAgent.d.ts +10 -0
  9. package/dist/agents/AugmentCodeAgent.d.ts +13 -0
  10. package/dist/agents/ClaudeAgent.d.ts +13 -0
  11. package/dist/agents/ClineAgent.d.ts +9 -0
  12. package/dist/agents/CodexCliAgent.d.ts +31 -0
  13. package/dist/agents/CopilotAgent.d.ts +20 -0
  14. package/dist/agents/CrushAgent.d.ts +14 -0
  15. package/dist/agents/CrushAgent.js +5 -2
  16. package/dist/agents/CursorAgent.d.ts +17 -0
  17. package/dist/agents/FactoryDroidAgent.d.ts +13 -0
  18. package/dist/agents/FirebaseAgent.d.ts +11 -0
  19. package/dist/agents/FirebenderAgent.d.ts +36 -0
  20. package/dist/agents/GeminiCliAgent.d.ts +11 -0
  21. package/dist/agents/GeminiCliAgent.js +2 -2
  22. package/dist/agents/GooseAgent.d.ts +12 -0
  23. package/dist/agents/IAgent.d.ts +72 -0
  24. package/dist/agents/JetBrainsAiAssistantAgent.d.ts +10 -0
  25. package/dist/agents/JulesAgent.d.ts +5 -0
  26. package/dist/agents/JunieAgent.d.ts +12 -0
  27. package/dist/agents/KiloCodeAgent.d.ts +14 -0
  28. package/dist/agents/KiroAgent.d.ts +8 -0
  29. package/dist/agents/MistralVibeAgent.d.ts +31 -0
  30. package/dist/agents/OpenCodeAgent.d.ts +11 -0
  31. package/dist/agents/OpenCodeAgent.js +14 -9
  32. package/dist/agents/OpenHandsAgent.d.ts +8 -0
  33. package/dist/agents/PiAgent.d.ts +9 -0
  34. package/dist/agents/QwenCodeAgent.d.ts +10 -0
  35. package/dist/agents/QwenCodeAgent.js +2 -2
  36. package/dist/agents/RooCodeAgent.d.ts +16 -0
  37. package/dist/agents/TraeAgent.d.ts +10 -0
  38. package/dist/agents/WarpAgent.d.ts +12 -0
  39. package/dist/agents/WindsurfAgent.d.ts +13 -0
  40. package/dist/agents/ZedAgent.d.ts +21 -0
  41. package/dist/agents/ZedAgent.js +5 -2
  42. package/dist/agents/agent-utils.d.ts +5 -0
  43. package/dist/agents/agent-utils.js +8 -5
  44. package/dist/agents/index.d.ts +9 -0
  45. package/dist/cli/commands.d.ts +4 -0
  46. package/dist/cli/commands.js +1 -2
  47. package/dist/cli/handlers.d.ts +41 -0
  48. package/dist/cli/handlers.js +75 -59
  49. package/dist/cli/index.d.ts +2 -0
  50. package/dist/constants.d.ts +35 -0
  51. package/dist/core/ConfigLoader.d.ts +57 -0
  52. package/dist/core/ConfigLoader.js +106 -39
  53. package/dist/core/FileSystemUtils.d.ts +51 -0
  54. package/dist/core/FileSystemUtils.js +37 -17
  55. package/dist/core/GitignoreUtils.d.ts +15 -0
  56. package/dist/core/GitignoreUtils.js +32 -1
  57. package/dist/core/RuleProcessor.d.ts +8 -0
  58. package/dist/core/SkillsProcessor.d.ts +127 -0
  59. package/dist/core/SkillsProcessor.js +104 -218
  60. package/dist/core/SkillsUtils.d.ts +26 -0
  61. package/dist/core/SubagentsProcessor.d.ts +38 -0
  62. package/dist/core/SubagentsUtils.d.ts +34 -0
  63. package/dist/core/UnifiedConfigLoader.d.ts +10 -0
  64. package/dist/core/UnifiedConfigLoader.js +61 -31
  65. package/dist/core/UnifiedConfigTypes.d.ts +95 -0
  66. package/dist/core/agent-selection.d.ts +12 -0
  67. package/dist/core/agent-selection.js +11 -3
  68. package/dist/core/apply-engine.d.ts +69 -0
  69. package/dist/core/apply-engine.js +57 -50
  70. package/dist/core/config-utils.d.ts +14 -0
  71. package/dist/core/config-utils.js +9 -3
  72. package/dist/core/hash.d.ts +2 -0
  73. package/dist/core/path-utils.d.ts +1 -0
  74. package/dist/core/path-utils.js +42 -0
  75. package/dist/core/revert-engine.d.ts +36 -0
  76. package/dist/core/revert-engine.js +70 -9
  77. package/dist/lib.d.ts +13 -0
  78. package/dist/lib.js +16 -3
  79. package/dist/mcp/capabilities.d.ts +20 -0
  80. package/dist/mcp/merge.d.ts +10 -0
  81. package/dist/mcp/merge.js +19 -1
  82. package/dist/mcp/propagateOpenCodeMcp.d.ts +2 -0
  83. package/dist/mcp/propagateOpenCodeMcp.js +21 -9
  84. package/dist/mcp/propagateOpenHandsMcp.d.ts +2 -0
  85. package/dist/mcp/propagateOpenHandsMcp.js +31 -15
  86. package/dist/mcp/validate.d.ts +7 -0
  87. package/dist/mcp/validate.js +6 -1
  88. package/dist/paths/mcp.d.ts +8 -0
  89. package/dist/paths/mcp.js +33 -4
  90. package/dist/revert.d.ts +6 -0
  91. package/dist/revert.js +39 -27
  92. package/dist/types.d.ts +87 -0
  93. package/dist/vscode/settings.d.ts +40 -0
  94. package/package.json +6 -4
@@ -0,0 +1,8 @@
1
+ import { AbstractAgent } from './AbstractAgent';
2
+ export declare class KiroAgent extends AbstractAgent {
3
+ getIdentifier(): string;
4
+ getName(): string;
5
+ getDefaultOutputPath(projectRoot: string): string;
6
+ supportsMcpStdio(): boolean;
7
+ supportsMcpRemote(): boolean;
8
+ }
@@ -0,0 +1,31 @@
1
+ import { IAgent, IAgentConfig } from './IAgent';
2
+ interface RulerMcpServer {
3
+ command?: string;
4
+ args?: string[];
5
+ url?: string;
6
+ headers?: Record<string, string>;
7
+ env?: Record<string, string>;
8
+ timeout?: number;
9
+ }
10
+ interface RulerMcp {
11
+ mcpServers?: Record<string, RulerMcpServer>;
12
+ }
13
+ /**
14
+ * Mistral Vibe CLI agent adapter.
15
+ * Propagates rules to AGENTS.md and MCP servers to .vibe/config.toml.
16
+ */
17
+ export declare class MistralVibeAgent implements IAgent {
18
+ private agentsMdAgent;
19
+ getIdentifier(): string;
20
+ getName(): string;
21
+ applyRulerConfig(concatenatedRules: string, projectRoot: string, rulerMcpJson: RulerMcp | null, agentConfig?: IAgentConfig, backup?: boolean): Promise<void>;
22
+ /**
23
+ * Determines the transport type based on server configuration.
24
+ */
25
+ private determineTransport;
26
+ getDefaultOutputPath(projectRoot: string): Record<string, string>;
27
+ supportsMcpStdio(): boolean;
28
+ supportsMcpRemote(): boolean;
29
+ supportsNativeSkills(): boolean;
30
+ }
31
+ export {};
@@ -0,0 +1,11 @@
1
+ import { IAgent, IAgentConfig } from './IAgent';
2
+ export declare class OpenCodeAgent implements IAgent {
3
+ getIdentifier(): string;
4
+ getName(): string;
5
+ getDefaultOutputPath(projectRoot: string): Record<string, string>;
6
+ applyRulerConfig(concatenatedRules: string, projectRoot: string, rulerMcpJson: Record<string, unknown> | null, agentConfig?: IAgentConfig): Promise<void>;
7
+ supportsMcpStdio(): boolean;
8
+ supportsMcpRemote(): boolean;
9
+ supportsMcpTimeout(): boolean;
10
+ supportsNativeSkills(): boolean;
11
+ }
@@ -51,9 +51,15 @@ class OpenCodeAgent {
51
51
  }
52
52
  async applyRulerConfig(concatenatedRules, projectRoot, rulerMcpJson, agentConfig) {
53
53
  const outputPaths = this.getDefaultOutputPath(projectRoot);
54
- const instructionsPath = path.resolve(projectRoot, agentConfig?.outputPathInstructions ?? outputPaths['instructions']);
54
+ const instructionsPath = path.resolve(projectRoot, agentConfig?.outputPath ??
55
+ agentConfig?.outputPathInstructions ??
56
+ outputPaths['instructions']);
55
57
  const mcpPath = path.resolve(projectRoot, agentConfig?.outputPathConfig ?? outputPaths['mcp']);
58
+ await fs.mkdir(path.dirname(instructionsPath), { recursive: true });
56
59
  await fs.writeFile(instructionsPath, concatenatedRules);
60
+ if (!rulerMcpJson) {
61
+ return;
62
+ }
57
63
  // Create OpenCode config with schema and MCP configuration
58
64
  let finalMcpConfig = {
59
65
  $schema: 'https://opencode.ai/config.json',
@@ -71,22 +77,21 @@ class OpenCodeAgent {
71
77
  },
72
78
  };
73
79
  }
74
- else if (rulerMcpJson) {
80
+ else {
75
81
  finalMcpConfig = {
76
82
  $schema: 'https://opencode.ai/config.json',
77
- mcp: (rulerMcpJson?.mcpServers ?? {}),
83
+ mcp: (rulerMcpJson.mcpServers ?? {}),
78
84
  };
79
85
  }
80
86
  }
81
87
  catch {
82
- if (rulerMcpJson) {
83
- finalMcpConfig = {
84
- $schema: 'https://opencode.ai/config.json',
85
- mcp: (rulerMcpJson?.mcpServers ?? {}),
86
- };
87
- }
88
+ finalMcpConfig = {
89
+ $schema: 'https://opencode.ai/config.json',
90
+ mcp: (rulerMcpJson.mcpServers ?? {}),
91
+ };
88
92
  }
89
93
  // Always write the config file, even if MCP is empty
94
+ await fs.mkdir(path.dirname(mcpPath), { recursive: true });
90
95
  await fs.writeFile(mcpPath, JSON.stringify(finalMcpConfig, null, 2));
91
96
  }
92
97
  supportsMcpStdio() {
@@ -0,0 +1,8 @@
1
+ import { AbstractAgent } from './AbstractAgent';
2
+ export declare class OpenHandsAgent extends AbstractAgent {
3
+ getIdentifier(): string;
4
+ getName(): string;
5
+ getDefaultOutputPath(projectRoot: string): string;
6
+ supportsMcpStdio(): boolean;
7
+ supportsMcpRemote(): boolean;
8
+ }
@@ -0,0 +1,9 @@
1
+ import { AgentsMdAgent } from './AgentsMdAgent';
2
+ /**
3
+ * Pi Coding Agent adapter.
4
+ */
5
+ export declare class PiAgent extends AgentsMdAgent {
6
+ getIdentifier(): string;
7
+ getName(): string;
8
+ supportsNativeSkills(): boolean;
9
+ }
@@ -0,0 +1,10 @@
1
+ import { IAgentConfig } from './IAgent';
2
+ import { AgentsMdAgent } from './AgentsMdAgent';
3
+ export declare class QwenCodeAgent extends AgentsMdAgent {
4
+ getIdentifier(): string;
5
+ getName(): string;
6
+ applyRulerConfig(concatenatedRules: string, projectRoot: string, _rulerMcpJson: Record<string, unknown> | null, agentConfig?: IAgentConfig, backup?: boolean): Promise<void>;
7
+ getMcpServerKey(): string;
8
+ supportsMcpStdio(): boolean;
9
+ supportsMcpRemote(): boolean;
10
+ }
@@ -44,11 +44,11 @@ class QwenCodeAgent extends AgentsMdAgent_1.AgentsMdAgent {
44
44
  getName() {
45
45
  return 'Qwen Code';
46
46
  }
47
- async applyRulerConfig(concatenatedRules, projectRoot, _rulerMcpJson, agentConfig) {
47
+ async applyRulerConfig(concatenatedRules, projectRoot, _rulerMcpJson, agentConfig, backup = true) {
48
48
  // First, perform idempotent write of AGENTS.md via base class
49
49
  await super.applyRulerConfig(concatenatedRules, projectRoot, null, {
50
50
  outputPath: agentConfig?.outputPath,
51
- });
51
+ }, backup);
52
52
  // Ensure .qwen/settings.json has contextFileName set to AGENTS.md
53
53
  const settingsPath = path.join(projectRoot, '.qwen', 'settings.json');
54
54
  let existingSettings = {};
@@ -0,0 +1,16 @@
1
+ import { IAgent, IAgentConfig } from './IAgent';
2
+ /**
3
+ * Agent for RooCode that writes to AGENTS.md and generates .roo/mcp.json
4
+ * with project-level MCP server configuration.
5
+ */
6
+ export declare class RooCodeAgent implements IAgent {
7
+ private agentsMdAgent;
8
+ getIdentifier(): string;
9
+ getName(): string;
10
+ getDefaultOutputPath(projectRoot: string): Record<string, string>;
11
+ applyRulerConfig(concatenatedRules: string, projectRoot: string, rulerMcpJson: Record<string, unknown> | null, agentConfig?: IAgentConfig, backup?: boolean): Promise<void>;
12
+ supportsMcpStdio(): boolean;
13
+ supportsMcpRemote(): boolean;
14
+ getMcpServerKey(): string;
15
+ supportsNativeSkills(): boolean;
16
+ }
@@ -0,0 +1,10 @@
1
+ import { AbstractAgent } from './AbstractAgent';
2
+ /**
3
+ * Trae AI agent adapter.
4
+ * Generates project_rules.md configuration file.
5
+ */
6
+ export declare class TraeAgent extends AbstractAgent {
7
+ getIdentifier(): string;
8
+ getName(): string;
9
+ getDefaultOutputPath(projectRoot: string): string;
10
+ }
@@ -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
+ }
@@ -49,11 +49,11 @@ class ZedAgent extends AgentsMdAgent_1.AgentsMdAgent {
49
49
  getName() {
50
50
  return 'Zed';
51
51
  }
52
- async applyRulerConfig(concatenatedRules, projectRoot, rulerMcpJson, agentConfig) {
52
+ async applyRulerConfig(concatenatedRules, projectRoot, rulerMcpJson, agentConfig, backup = true) {
53
53
  // First, perform idempotent AGENTS.md write via base class
54
54
  await super.applyRulerConfig(concatenatedRules, projectRoot, null, {
55
55
  outputPath: agentConfig?.outputPath,
56
- });
56
+ }, backup);
57
57
  // Handle MCP server configuration if enabled and provided
58
58
  const mcpEnabled = agentConfig?.mcp?.enabled ?? true;
59
59
  if (mcpEnabled && rulerMcpJson) {
@@ -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 = ".codex/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";