@intellectronica/ruler 0.2.19 → 0.3.0
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 +190 -31
- package/dist/agents/AbstractAgent.js +82 -0
- package/dist/agents/AgentsMdAgent.js +82 -0
- package/dist/agents/AiderAgent.js +29 -9
- package/dist/agents/AmpAgent.js +2 -44
- package/dist/agents/AugmentCodeAgent.js +10 -12
- package/dist/agents/ClaudeAgent.js +9 -9
- package/dist/agents/ClineAgent.js +3 -9
- package/dist/agents/CodexCliAgent.js +27 -21
- package/dist/agents/CopilotAgent.js +9 -10
- package/dist/agents/CrushAgent.js +6 -0
- package/dist/agents/CursorAgent.js +13 -5
- package/dist/agents/FirebaseAgent.js +2 -8
- package/dist/agents/GeminiCliAgent.js +31 -22
- package/dist/agents/GooseAgent.js +2 -10
- package/dist/agents/JulesAgent.js +3 -44
- package/dist/agents/JunieAgent.js +2 -9
- package/dist/agents/KiloCodeAgent.js +8 -9
- package/dist/agents/KiroAgent.js +50 -0
- package/dist/agents/OpenCodeAgent.js +50 -11
- package/dist/agents/OpenHandsAgent.js +8 -9
- package/dist/agents/QwenCodeAgent.js +83 -0
- package/dist/agents/WarpAgent.js +61 -0
- package/dist/agents/WindsurfAgent.js +9 -10
- package/dist/agents/ZedAgent.js +132 -0
- package/dist/agents/agent-utils.js +37 -0
- package/dist/agents/index.js +53 -0
- package/dist/cli/commands.js +48 -242
- package/dist/cli/handlers.js +176 -0
- package/dist/constants.js +9 -2
- package/dist/core/ConfigLoader.js +1 -1
- package/dist/core/FileSystemUtils.js +51 -4
- package/dist/core/RuleProcessor.js +15 -3
- package/dist/core/UnifiedConfigLoader.js +357 -0
- package/dist/core/UnifiedConfigTypes.js +2 -0
- package/dist/core/agent-selection.js +52 -0
- package/dist/core/apply-engine.js +302 -0
- package/dist/core/config-utils.js +30 -0
- package/dist/core/hash.js +24 -0
- package/dist/core/revert-engine.js +413 -0
- package/dist/lib.js +20 -330
- package/dist/mcp/capabilities.js +51 -0
- package/dist/mcp/propagateOpenCodeMcp.js +30 -31
- package/dist/mcp/propagateOpenHandsMcp.js +101 -17
- package/dist/paths/mcp.js +7 -3
- package/dist/revert.js +96 -481
- package/package.json +2 -1
|
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.OpenCodeAgent = void 0;
|
|
37
|
-
const
|
|
37
|
+
const fs = __importStar(require("fs/promises"));
|
|
38
38
|
const path = __importStar(require("path"));
|
|
39
39
|
class OpenCodeAgent {
|
|
40
40
|
getIdentifier() {
|
|
@@ -43,18 +43,57 @@ class OpenCodeAgent {
|
|
|
43
43
|
getName() {
|
|
44
44
|
return 'OpenCode';
|
|
45
45
|
}
|
|
46
|
-
async applyRulerConfig(concatenatedRules, projectRoot, rulerMcpJson, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
47
|
-
agentConfig) {
|
|
48
|
-
const outputPath = agentConfig?.outputPath ?? this.getDefaultOutputPath(projectRoot);
|
|
49
|
-
const absolutePath = path.resolve(projectRoot, outputPath);
|
|
50
|
-
await (0, FileSystemUtils_1.backupFile)(absolutePath);
|
|
51
|
-
await (0, FileSystemUtils_1.writeGeneratedFile)(absolutePath, concatenatedRules);
|
|
52
|
-
}
|
|
53
46
|
getDefaultOutputPath(projectRoot) {
|
|
54
|
-
return
|
|
47
|
+
return {
|
|
48
|
+
instructions: path.join(projectRoot, 'AGENTS.md'),
|
|
49
|
+
mcp: path.join(projectRoot, 'opencode.json'),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
async applyRulerConfig(concatenatedRules, projectRoot, rulerMcpJson, agentConfig) {
|
|
53
|
+
const outputPaths = this.getDefaultOutputPath(projectRoot);
|
|
54
|
+
const instructionsPath = path.resolve(projectRoot, agentConfig?.outputPathInstructions ?? outputPaths['instructions']);
|
|
55
|
+
const mcpPath = path.resolve(projectRoot, agentConfig?.outputPathConfig ?? outputPaths['mcp']);
|
|
56
|
+
await fs.writeFile(instructionsPath, concatenatedRules);
|
|
57
|
+
// Create OpenCode config with schema and MCP configuration
|
|
58
|
+
let finalMcpConfig = {
|
|
59
|
+
$schema: 'https://opencode.ai/config.json',
|
|
60
|
+
mcp: {},
|
|
61
|
+
};
|
|
62
|
+
try {
|
|
63
|
+
const existingMcpConfig = JSON.parse(await fs.readFile(mcpPath, 'utf-8'));
|
|
64
|
+
if (existingMcpConfig && typeof existingMcpConfig === 'object') {
|
|
65
|
+
finalMcpConfig = {
|
|
66
|
+
$schema: 'https://opencode.ai/config.json',
|
|
67
|
+
...existingMcpConfig,
|
|
68
|
+
mcp: {
|
|
69
|
+
...(existingMcpConfig.mcp || {}),
|
|
70
|
+
...(rulerMcpJson?.mcpServers ?? {}),
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
else if (rulerMcpJson) {
|
|
75
|
+
finalMcpConfig = {
|
|
76
|
+
$schema: 'https://opencode.ai/config.json',
|
|
77
|
+
mcp: (rulerMcpJson?.mcpServers ?? {}),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
if (rulerMcpJson) {
|
|
83
|
+
finalMcpConfig = {
|
|
84
|
+
$schema: 'https://opencode.ai/config.json',
|
|
85
|
+
mcp: (rulerMcpJson?.mcpServers ?? {}),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Always write the config file, even if MCP is empty
|
|
90
|
+
await fs.writeFile(mcpPath, JSON.stringify(finalMcpConfig, null, 2));
|
|
91
|
+
}
|
|
92
|
+
supportsMcpStdio() {
|
|
93
|
+
return true;
|
|
55
94
|
}
|
|
56
|
-
|
|
57
|
-
return
|
|
95
|
+
supportsMcpRemote() {
|
|
96
|
+
return true;
|
|
58
97
|
}
|
|
59
98
|
}
|
|
60
99
|
exports.OpenCodeAgent = OpenCodeAgent;
|
|
@@ -35,23 +35,22 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.OpenHandsAgent = void 0;
|
|
37
37
|
const path = __importStar(require("path"));
|
|
38
|
-
const
|
|
39
|
-
class OpenHandsAgent {
|
|
38
|
+
const AbstractAgent_1 = require("./AbstractAgent");
|
|
39
|
+
class OpenHandsAgent extends AbstractAgent_1.AbstractAgent {
|
|
40
40
|
getIdentifier() {
|
|
41
41
|
return 'openhands';
|
|
42
42
|
}
|
|
43
43
|
getName() {
|
|
44
44
|
return 'Open Hands';
|
|
45
45
|
}
|
|
46
|
-
async applyRulerConfig(concatenatedRules, projectRoot, rulerMcpJson, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
47
|
-
agentConfig) {
|
|
48
|
-
const output = agentConfig?.outputPath ?? this.getDefaultOutputPath(projectRoot);
|
|
49
|
-
await (0, FileSystemUtils_1.ensureDirExists)(path.dirname(output));
|
|
50
|
-
await (0, FileSystemUtils_1.backupFile)(output);
|
|
51
|
-
await (0, FileSystemUtils_1.writeGeneratedFile)(output, concatenatedRules);
|
|
52
|
-
}
|
|
53
46
|
getDefaultOutputPath(projectRoot) {
|
|
54
47
|
return path.join(projectRoot, '.openhands', 'microagents', 'repo.md');
|
|
55
48
|
}
|
|
49
|
+
supportsMcpStdio() {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
supportsMcpRemote() {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
56
55
|
}
|
|
57
56
|
exports.OpenHandsAgent = OpenHandsAgent;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.QwenCodeAgent = void 0;
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
const fs_1 = require("fs");
|
|
39
|
+
const AgentsMdAgent_1 = require("./AgentsMdAgent");
|
|
40
|
+
class QwenCodeAgent extends AgentsMdAgent_1.AgentsMdAgent {
|
|
41
|
+
getIdentifier() {
|
|
42
|
+
return 'qwen';
|
|
43
|
+
}
|
|
44
|
+
getName() {
|
|
45
|
+
return 'Qwen Code';
|
|
46
|
+
}
|
|
47
|
+
async applyRulerConfig(concatenatedRules, projectRoot, rulerMcpJson, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
48
|
+
agentConfig) {
|
|
49
|
+
// First, perform idempotent write of AGENTS.md via base class
|
|
50
|
+
await super.applyRulerConfig(concatenatedRules, projectRoot, null, {
|
|
51
|
+
outputPath: agentConfig?.outputPath,
|
|
52
|
+
});
|
|
53
|
+
// Ensure .qwen/settings.json has contextFileName set to AGENTS.md
|
|
54
|
+
const settingsPath = path.join(projectRoot, '.qwen', 'settings.json');
|
|
55
|
+
let existingSettings = {};
|
|
56
|
+
try {
|
|
57
|
+
const raw = await fs_1.promises.readFile(settingsPath, 'utf8');
|
|
58
|
+
existingSettings = JSON.parse(raw);
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
if (err.code !== 'ENOENT') {
|
|
62
|
+
throw err;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const updated = {
|
|
66
|
+
...existingSettings,
|
|
67
|
+
contextFileName: 'AGENTS.md',
|
|
68
|
+
};
|
|
69
|
+
await fs_1.promises.mkdir(path.dirname(settingsPath), { recursive: true });
|
|
70
|
+
await fs_1.promises.writeFile(settingsPath, JSON.stringify(updated, null, 2));
|
|
71
|
+
}
|
|
72
|
+
// Ensure MCP merging uses the correct key for Qwen Code (.qwen/settings.json)
|
|
73
|
+
getMcpServerKey() {
|
|
74
|
+
return 'mcpServers';
|
|
75
|
+
}
|
|
76
|
+
supportsMcpStdio() {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
supportsMcpRemote() {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.QwenCodeAgent = QwenCodeAgent;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.WarpAgent = void 0;
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
const AbstractAgent_1 = require("./AbstractAgent");
|
|
39
|
+
/**
|
|
40
|
+
* Warp Agent Mode adapter.
|
|
41
|
+
* Generates WARP.md configuration file in the project root.
|
|
42
|
+
*/
|
|
43
|
+
class WarpAgent extends AbstractAgent_1.AbstractAgent {
|
|
44
|
+
getIdentifier() {
|
|
45
|
+
return 'warp';
|
|
46
|
+
}
|
|
47
|
+
getName() {
|
|
48
|
+
return 'Warp';
|
|
49
|
+
}
|
|
50
|
+
getDefaultOutputPath(projectRoot) {
|
|
51
|
+
return path.join(projectRoot, 'WARP.md');
|
|
52
|
+
}
|
|
53
|
+
// Warp does not support MCP servers
|
|
54
|
+
supportsMcpStdio() {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
supportsMcpRemote() {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.WarpAgent = WarpAgent;
|
|
@@ -35,26 +35,25 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.WindsurfAgent = void 0;
|
|
37
37
|
const path = __importStar(require("path"));
|
|
38
|
-
const
|
|
38
|
+
const AbstractAgent_1 = require("./AbstractAgent");
|
|
39
39
|
/**
|
|
40
|
-
* Windsurf agent adapter
|
|
40
|
+
* Windsurf agent adapter.
|
|
41
41
|
*/
|
|
42
|
-
class WindsurfAgent {
|
|
42
|
+
class WindsurfAgent extends AbstractAgent_1.AbstractAgent {
|
|
43
43
|
getIdentifier() {
|
|
44
44
|
return 'windsurf';
|
|
45
45
|
}
|
|
46
46
|
getName() {
|
|
47
47
|
return 'Windsurf';
|
|
48
48
|
}
|
|
49
|
-
async applyRulerConfig(concatenatedRules, projectRoot, rulerMcpJson, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
50
|
-
agentConfig) {
|
|
51
|
-
const output = agentConfig?.outputPath ?? this.getDefaultOutputPath(projectRoot);
|
|
52
|
-
await (0, FileSystemUtils_1.ensureDirExists)(path.dirname(output));
|
|
53
|
-
await (0, FileSystemUtils_1.backupFile)(output);
|
|
54
|
-
await (0, FileSystemUtils_1.writeGeneratedFile)(output, concatenatedRules);
|
|
55
|
-
}
|
|
56
49
|
getDefaultOutputPath(projectRoot) {
|
|
57
50
|
return path.join(projectRoot, '.windsurf', 'rules', 'ruler_windsurf_instructions.md');
|
|
58
51
|
}
|
|
52
|
+
supportsMcpStdio() {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
supportsMcpRemote() {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
59
58
|
}
|
|
60
59
|
exports.WindsurfAgent = WindsurfAgent;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ZedAgent = void 0;
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
const fs_1 = require("fs");
|
|
39
|
+
const AgentsMdAgent_1 = require("./AgentsMdAgent");
|
|
40
|
+
/**
|
|
41
|
+
* Zed editor agent adapter.
|
|
42
|
+
* Inherits from AgentsMdAgent to write instructions to AGENTS.md and handles
|
|
43
|
+
* MCP server configuration in .zed/settings.json at the project root.
|
|
44
|
+
*/
|
|
45
|
+
class ZedAgent extends AgentsMdAgent_1.AgentsMdAgent {
|
|
46
|
+
getIdentifier() {
|
|
47
|
+
return 'zed';
|
|
48
|
+
}
|
|
49
|
+
getName() {
|
|
50
|
+
return 'Zed';
|
|
51
|
+
}
|
|
52
|
+
async applyRulerConfig(concatenatedRules, projectRoot, rulerMcpJson, agentConfig) {
|
|
53
|
+
// First, perform idempotent AGENTS.md write via base class
|
|
54
|
+
await super.applyRulerConfig(concatenatedRules, projectRoot, null, {
|
|
55
|
+
outputPath: agentConfig?.outputPath,
|
|
56
|
+
});
|
|
57
|
+
// Handle MCP server configuration if enabled and provided
|
|
58
|
+
const mcpEnabled = agentConfig?.mcp?.enabled ?? true;
|
|
59
|
+
if (mcpEnabled && rulerMcpJson) {
|
|
60
|
+
const zedSettingsPath = path.join(projectRoot, '.zed', 'settings.json');
|
|
61
|
+
// Read existing settings
|
|
62
|
+
let existingSettings = {};
|
|
63
|
+
try {
|
|
64
|
+
const content = await fs_1.promises.readFile(zedSettingsPath, 'utf8');
|
|
65
|
+
existingSettings = JSON.parse(content);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (error.code !== 'ENOENT') {
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
// File doesn't exist, use empty settings
|
|
72
|
+
}
|
|
73
|
+
// Get the merge strategy
|
|
74
|
+
const strategy = agentConfig?.mcp?.strategy ?? 'merge';
|
|
75
|
+
// Handle merging based on strategy
|
|
76
|
+
let mergedSettings;
|
|
77
|
+
if (strategy === 'overwrite') {
|
|
78
|
+
// For overwrite, preserve all existing settings except MCP servers
|
|
79
|
+
mergedSettings = { ...existingSettings };
|
|
80
|
+
// Extract incoming MCP servers and transform them for Zed format
|
|
81
|
+
const incomingServers = rulerMcpJson.mcpServers || {};
|
|
82
|
+
const transformedServers = {};
|
|
83
|
+
for (const [serverName, serverConfig] of Object.entries(incomingServers)) {
|
|
84
|
+
transformedServers[serverName] = this.transformMcpServerForZed(serverConfig);
|
|
85
|
+
}
|
|
86
|
+
// Replace MCP servers completely
|
|
87
|
+
mergedSettings[this.getMcpServerKey()] = transformedServers;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
// For merge strategy, preserve all existing settings
|
|
91
|
+
const baseServers = existingSettings[this.getMcpServerKey()] || {};
|
|
92
|
+
const incomingServers = rulerMcpJson.mcpServers || {};
|
|
93
|
+
// Transform incoming servers for Zed format
|
|
94
|
+
const transformedIncomingServers = {};
|
|
95
|
+
for (const [serverName, serverConfig] of Object.entries(incomingServers)) {
|
|
96
|
+
transformedIncomingServers[serverName] =
|
|
97
|
+
this.transformMcpServerForZed(serverConfig);
|
|
98
|
+
}
|
|
99
|
+
const mergedServers = { ...baseServers, ...transformedIncomingServers };
|
|
100
|
+
mergedSettings = {
|
|
101
|
+
...existingSettings,
|
|
102
|
+
[this.getMcpServerKey()]: mergedServers,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
// 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));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
getMcpServerKey() {
|
|
111
|
+
return 'context_servers';
|
|
112
|
+
}
|
|
113
|
+
supportsMcpStdio() {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
supportsMcpRemote() {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Transform MCP server configuration from ruler format to Zed format.
|
|
121
|
+
* Converts "type": "stdio" to "source": "custom" and preserves other fields.
|
|
122
|
+
*/
|
|
123
|
+
transformMcpServerForZed(rulerServer) {
|
|
124
|
+
const transformedServer = { ...rulerServer };
|
|
125
|
+
// Remove "type" field if present
|
|
126
|
+
delete transformedServer.type;
|
|
127
|
+
// Add "source": "custom" as required by Zed
|
|
128
|
+
transformedServer.source = 'custom';
|
|
129
|
+
return transformedServer;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
exports.ZedAgent = ZedAgent;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAgentOutputPaths = getAgentOutputPaths;
|
|
4
|
+
/**
|
|
5
|
+
* Gets all output paths for an agent, taking into account any config overrides.
|
|
6
|
+
*/
|
|
7
|
+
function getAgentOutputPaths(agent, projectRoot, agentConfig) {
|
|
8
|
+
const paths = [];
|
|
9
|
+
const defaults = agent.getDefaultOutputPath(projectRoot);
|
|
10
|
+
if (typeof defaults === 'string') {
|
|
11
|
+
// Single output path (most agents)
|
|
12
|
+
const actualPath = agentConfig?.outputPath ?? defaults;
|
|
13
|
+
paths.push(actualPath);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
// Multiple output paths (e.g., AiderAgent)
|
|
17
|
+
const defaultPaths = defaults;
|
|
18
|
+
// Handle instructions path
|
|
19
|
+
if ('instructions' in defaultPaths) {
|
|
20
|
+
const instructionsPath = agentConfig?.outputPathInstructions ?? defaultPaths.instructions;
|
|
21
|
+
paths.push(instructionsPath);
|
|
22
|
+
}
|
|
23
|
+
// Handle config path
|
|
24
|
+
if ('config' in defaultPaths) {
|
|
25
|
+
const configPath = agentConfig?.outputPathConfig ?? defaultPaths.config;
|
|
26
|
+
paths.push(configPath);
|
|
27
|
+
}
|
|
28
|
+
// Handle any other paths in the default paths record
|
|
29
|
+
for (const [key, defaultPath] of Object.entries(defaultPaths)) {
|
|
30
|
+
if (key !== 'instructions' && key !== 'config') {
|
|
31
|
+
// For unknown path types, use the default since we don't have specific config overrides
|
|
32
|
+
paths.push(defaultPath);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return paths;
|
|
37
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.allAgents = exports.AbstractAgent = void 0;
|
|
4
|
+
const AbstractAgent_1 = require("./AbstractAgent");
|
|
5
|
+
Object.defineProperty(exports, "AbstractAgent", { enumerable: true, get: function () { return AbstractAgent_1.AbstractAgent; } });
|
|
6
|
+
const CopilotAgent_1 = require("./CopilotAgent");
|
|
7
|
+
const ClaudeAgent_1 = require("./ClaudeAgent");
|
|
8
|
+
const CodexCliAgent_1 = require("./CodexCliAgent");
|
|
9
|
+
const CursorAgent_1 = require("./CursorAgent");
|
|
10
|
+
const WindsurfAgent_1 = require("./WindsurfAgent");
|
|
11
|
+
const ClineAgent_1 = require("./ClineAgent");
|
|
12
|
+
const AiderAgent_1 = require("./AiderAgent");
|
|
13
|
+
const FirebaseAgent_1 = require("./FirebaseAgent");
|
|
14
|
+
const OpenHandsAgent_1 = require("./OpenHandsAgent");
|
|
15
|
+
const GeminiCliAgent_1 = require("./GeminiCliAgent");
|
|
16
|
+
const JulesAgent_1 = require("./JulesAgent");
|
|
17
|
+
const JunieAgent_1 = require("./JunieAgent");
|
|
18
|
+
const AugmentCodeAgent_1 = require("./AugmentCodeAgent");
|
|
19
|
+
const KiloCodeAgent_1 = require("./KiloCodeAgent");
|
|
20
|
+
const OpenCodeAgent_1 = require("./OpenCodeAgent");
|
|
21
|
+
const CrushAgent_1 = require("./CrushAgent");
|
|
22
|
+
const GooseAgent_1 = require("./GooseAgent");
|
|
23
|
+
const AmpAgent_1 = require("./AmpAgent");
|
|
24
|
+
const ZedAgent_1 = require("./ZedAgent");
|
|
25
|
+
const AgentsMdAgent_1 = require("./AgentsMdAgent");
|
|
26
|
+
const QwenCodeAgent_1 = require("./QwenCodeAgent");
|
|
27
|
+
const KiroAgent_1 = require("./KiroAgent");
|
|
28
|
+
const WarpAgent_1 = require("./WarpAgent");
|
|
29
|
+
exports.allAgents = [
|
|
30
|
+
new CopilotAgent_1.CopilotAgent(),
|
|
31
|
+
new ClaudeAgent_1.ClaudeAgent(),
|
|
32
|
+
new CodexCliAgent_1.CodexCliAgent(),
|
|
33
|
+
new CursorAgent_1.CursorAgent(),
|
|
34
|
+
new WindsurfAgent_1.WindsurfAgent(),
|
|
35
|
+
new ClineAgent_1.ClineAgent(),
|
|
36
|
+
new AiderAgent_1.AiderAgent(),
|
|
37
|
+
new FirebaseAgent_1.FirebaseAgent(),
|
|
38
|
+
new OpenHandsAgent_1.OpenHandsAgent(),
|
|
39
|
+
new GeminiCliAgent_1.GeminiCliAgent(),
|
|
40
|
+
new JulesAgent_1.JulesAgent(),
|
|
41
|
+
new JunieAgent_1.JunieAgent(),
|
|
42
|
+
new AugmentCodeAgent_1.AugmentCodeAgent(),
|
|
43
|
+
new KiloCodeAgent_1.KiloCodeAgent(),
|
|
44
|
+
new OpenCodeAgent_1.OpenCodeAgent(),
|
|
45
|
+
new GooseAgent_1.GooseAgent(),
|
|
46
|
+
new CrushAgent_1.CrushAgent(),
|
|
47
|
+
new AmpAgent_1.AmpAgent(),
|
|
48
|
+
new ZedAgent_1.ZedAgent(),
|
|
49
|
+
new QwenCodeAgent_1.QwenCodeAgent(),
|
|
50
|
+
new AgentsMdAgent_1.AgentsMdAgent(),
|
|
51
|
+
new KiroAgent_1.KiroAgent(),
|
|
52
|
+
new WarpAgent_1.WarpAgent(),
|
|
53
|
+
];
|