@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.
- package/README.md +40 -28
- package/dist/agents/AbstractAgent.d.ts +53 -0
- package/dist/agents/AgentsMdAgent.d.ts +14 -0
- package/dist/agents/AiderAgent.d.ts +14 -0
- package/dist/agents/AiderAgent.js +3 -1
- package/dist/agents/AmazonQCliAgent.d.ts +13 -0
- package/dist/agents/AmpAgent.d.ts +6 -0
- package/dist/agents/AntigravityAgent.d.ts +10 -0
- package/dist/agents/AugmentCodeAgent.d.ts +13 -0
- package/dist/agents/ClaudeAgent.d.ts +13 -0
- package/dist/agents/ClineAgent.d.ts +9 -0
- package/dist/agents/CodexCliAgent.d.ts +31 -0
- package/dist/agents/CopilotAgent.d.ts +20 -0
- package/dist/agents/CrushAgent.d.ts +14 -0
- package/dist/agents/CrushAgent.js +5 -2
- package/dist/agents/CursorAgent.d.ts +17 -0
- package/dist/agents/FactoryDroidAgent.d.ts +13 -0
- package/dist/agents/FirebaseAgent.d.ts +11 -0
- package/dist/agents/FirebenderAgent.d.ts +36 -0
- package/dist/agents/GeminiCliAgent.d.ts +11 -0
- package/dist/agents/GeminiCliAgent.js +2 -2
- package/dist/agents/GooseAgent.d.ts +12 -0
- package/dist/agents/IAgent.d.ts +72 -0
- package/dist/agents/JetBrainsAiAssistantAgent.d.ts +10 -0
- package/dist/agents/JulesAgent.d.ts +5 -0
- package/dist/agents/JunieAgent.d.ts +12 -0
- package/dist/agents/KiloCodeAgent.d.ts +14 -0
- package/dist/agents/KiroAgent.d.ts +8 -0
- package/dist/agents/MistralVibeAgent.d.ts +31 -0
- package/dist/agents/OpenCodeAgent.d.ts +11 -0
- package/dist/agents/OpenCodeAgent.js +14 -9
- package/dist/agents/OpenHandsAgent.d.ts +8 -0
- package/dist/agents/PiAgent.d.ts +9 -0
- package/dist/agents/QwenCodeAgent.d.ts +10 -0
- package/dist/agents/QwenCodeAgent.js +2 -2
- package/dist/agents/RooCodeAgent.d.ts +16 -0
- package/dist/agents/TraeAgent.d.ts +10 -0
- package/dist/agents/WarpAgent.d.ts +12 -0
- package/dist/agents/WindsurfAgent.d.ts +13 -0
- package/dist/agents/ZedAgent.d.ts +21 -0
- package/dist/agents/ZedAgent.js +5 -2
- package/dist/agents/agent-utils.d.ts +5 -0
- package/dist/agents/agent-utils.js +8 -5
- package/dist/agents/index.d.ts +9 -0
- package/dist/cli/commands.d.ts +4 -0
- package/dist/cli/commands.js +1 -2
- package/dist/cli/handlers.d.ts +41 -0
- package/dist/cli/handlers.js +75 -59
- package/dist/cli/index.d.ts +2 -0
- package/dist/constants.d.ts +35 -0
- package/dist/core/ConfigLoader.d.ts +57 -0
- package/dist/core/ConfigLoader.js +106 -39
- package/dist/core/FileSystemUtils.d.ts +51 -0
- package/dist/core/FileSystemUtils.js +37 -17
- package/dist/core/GitignoreUtils.d.ts +15 -0
- package/dist/core/GitignoreUtils.js +32 -1
- package/dist/core/RuleProcessor.d.ts +8 -0
- package/dist/core/SkillsProcessor.d.ts +127 -0
- package/dist/core/SkillsProcessor.js +104 -218
- package/dist/core/SkillsUtils.d.ts +26 -0
- package/dist/core/SubagentsProcessor.d.ts +38 -0
- package/dist/core/SubagentsUtils.d.ts +34 -0
- package/dist/core/UnifiedConfigLoader.d.ts +10 -0
- package/dist/core/UnifiedConfigLoader.js +61 -31
- package/dist/core/UnifiedConfigTypes.d.ts +95 -0
- package/dist/core/agent-selection.d.ts +12 -0
- package/dist/core/agent-selection.js +11 -3
- package/dist/core/apply-engine.d.ts +69 -0
- package/dist/core/apply-engine.js +57 -50
- package/dist/core/config-utils.d.ts +14 -0
- package/dist/core/config-utils.js +9 -3
- package/dist/core/hash.d.ts +2 -0
- package/dist/core/path-utils.d.ts +1 -0
- package/dist/core/path-utils.js +42 -0
- package/dist/core/revert-engine.d.ts +36 -0
- package/dist/core/revert-engine.js +70 -9
- package/dist/lib.d.ts +13 -0
- package/dist/lib.js +16 -3
- package/dist/mcp/capabilities.d.ts +20 -0
- package/dist/mcp/merge.d.ts +10 -0
- package/dist/mcp/merge.js +19 -1
- package/dist/mcp/propagateOpenCodeMcp.d.ts +2 -0
- package/dist/mcp/propagateOpenCodeMcp.js +21 -9
- package/dist/mcp/propagateOpenHandsMcp.d.ts +2 -0
- package/dist/mcp/propagateOpenHandsMcp.js +31 -15
- package/dist/mcp/validate.d.ts +7 -0
- package/dist/mcp/validate.js +6 -1
- package/dist/paths/mcp.d.ts +8 -0
- package/dist/paths/mcp.js +33 -4
- package/dist/revert.d.ts +6 -0
- package/dist/revert.js +39 -27
- package/dist/types.d.ts +87 -0
- package/dist/vscode/settings.d.ts +40 -0
- 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?.
|
|
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
|
|
80
|
+
else {
|
|
75
81
|
finalMcpConfig = {
|
|
76
82
|
$schema: 'https://opencode.ai/config.json',
|
|
77
|
-
mcp: (rulerMcpJson
|
|
83
|
+
mcp: (rulerMcpJson.mcpServers ?? {}),
|
|
78
84
|
};
|
|
79
85
|
}
|
|
80
86
|
}
|
|
81
87
|
catch {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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,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
|
+
}
|
package/dist/agents/ZedAgent.js
CHANGED
|
@@ -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.
|
|
@@ -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?.
|
|
20
|
+
const instructionsPath = agentConfig?.outputPath ??
|
|
21
|
+
agentConfig?.outputPathInstructions ??
|
|
22
|
+
defaultPaths.instructions;
|
|
21
23
|
paths.push(instructionsPath);
|
|
22
24
|
}
|
|
23
|
-
// Handle config path
|
|
24
|
-
|
|
25
|
-
|
|
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 !==
|
|
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;
|
package/dist/cli/commands.js
CHANGED
|
@@ -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>;
|
package/dist/cli/handlers.js
CHANGED
|
@@ -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(
|
|
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
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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
|
-
|
|
215
|
-
|
|
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(
|
|
253
|
+
console.error(formatCliError(message));
|
|
238
254
|
process.exit(1);
|
|
239
255
|
}
|
|
240
256
|
}
|
|
@@ -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";
|