@intellectronica/ruler 0.3.29 → 0.3.30

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.
@@ -102,9 +102,13 @@ class CodexCliAgent {
102
102
  // Add the ruler servers
103
103
  for (const [serverName, serverConfig] of Object.entries(rulerServers)) {
104
104
  // Create a properly formatted MCP server entry
105
- const mcpServer = {
106
- command: serverConfig.command,
107
- };
105
+ const mcpServer = {};
106
+ if (serverConfig.command) {
107
+ mcpServer.command = serverConfig.command;
108
+ }
109
+ if (serverConfig.url) {
110
+ mcpServer.url = serverConfig.url;
111
+ }
108
112
  if (serverConfig.args) {
109
113
  mcpServer.args = serverConfig.args;
110
114
  }
@@ -133,11 +137,14 @@ class CodexCliAgent {
133
137
  config: path.join(projectRoot, '.codex', 'config.toml'),
134
138
  };
135
139
  }
140
+ getMcpServerKey() {
141
+ return 'mcp_servers';
142
+ }
136
143
  supportsMcpStdio() {
137
144
  return true;
138
145
  }
139
146
  supportsMcpRemote() {
140
- return false; // Codex CLI only supports STDIO based on PR description
147
+ return true;
141
148
  }
142
149
  supportsNativeSkills() {
143
150
  return true;
@@ -41,6 +41,7 @@ exports.applyConfigurationsToAgents = applyConfigurationsToAgents;
41
41
  exports.updateGitignore = updateGitignore;
42
42
  const path = __importStar(require("path"));
43
43
  const fs_1 = require("fs");
44
+ const toml_1 = require("@iarna/toml");
44
45
  const FileSystemUtils = __importStar(require("./FileSystemUtils"));
45
46
  const RuleProcessor_1 = require("./RuleProcessor");
46
47
  const ConfigLoader_1 = require("./ConfigLoader");
@@ -544,8 +545,28 @@ async function applyStandardMcpConfiguration(agent, filteredMcpJson, dest, agent
544
545
  else if (agent.getIdentifier() === 'factory') {
545
546
  mcpToMerge = transformMcpForFactoryDroid(filteredMcpJson);
546
547
  }
547
- const existing = await (0, mcp_1.readNativeMcp)(dest);
548
- const merged = (0, merge_1.mergeMcp)(existing, mcpToMerge, strategy, serverKey);
548
+ const CODEX_AGENT_ID = 'codex';
549
+ const isCodexToml = agent.getIdentifier() === CODEX_AGENT_ID && dest.endsWith('.toml');
550
+ let existing = await (0, mcp_1.readNativeMcp)(dest);
551
+ if (isCodexToml) {
552
+ try {
553
+ const tomlContent = await fs_1.promises.readFile(dest, 'utf8');
554
+ existing = (0, toml_1.parse)(tomlContent);
555
+ }
556
+ catch (error) {
557
+ (0, constants_1.logVerbose)(`Failed to read Codex MCP TOML at ${dest}: ${error.message}`, verbose);
558
+ // ignore missing or invalid TOML, fall back to previously read value
559
+ }
560
+ }
561
+ let merged = (0, merge_1.mergeMcp)(existing, mcpToMerge, strategy, serverKey);
562
+ if (isCodexToml) {
563
+ const { [serverKey]: servers, ...rest } = merged;
564
+ merged = {
565
+ ...rest,
566
+ // Codex CLI expects MCP servers under mcp_servers in config.toml.
567
+ mcp_servers: servers ?? {},
568
+ };
569
+ }
549
570
  // Firebase Studio (IDX) expects no "type" fields in .idx/mcp.json server entries.
550
571
  // Sanitize merged config by stripping 'type' from each server when targeting Firebase.
551
572
  const sanitizeForFirebase = (obj) => {
@@ -593,14 +614,23 @@ async function applyStandardMcpConfiguration(agent, filteredMcpJson, dest, agent
593
614
  let toWrite = sanitizeForFirebase(merged);
594
615
  toWrite = sanitizeForGemini(toWrite);
595
616
  // Only backup and write if content would actually change (idempotent)
596
- const currentContent = JSON.stringify(existing, null, 2);
597
- const newContent = JSON.stringify(toWrite, null, 2);
617
+ const currentContent = isCodexToml
618
+ ? (0, toml_1.stringify)(existing)
619
+ : JSON.stringify(existing, null, 2);
620
+ const newContent = isCodexToml
621
+ ? (0, toml_1.stringify)(toWrite)
622
+ : JSON.stringify(toWrite, null, 2);
598
623
  if (currentContent !== newContent) {
599
624
  if (backup) {
600
625
  const { backupFile } = await Promise.resolve().then(() => __importStar(require('../core/FileSystemUtils')));
601
626
  await backupFile(dest);
602
627
  }
603
- await (0, mcp_1.writeNativeMcp)(dest, toWrite);
628
+ if (isCodexToml) {
629
+ await FileSystemUtils.writeGeneratedFile(dest, (0, toml_1.stringify)(toWrite));
630
+ }
631
+ else {
632
+ await (0, mcp_1.writeNativeMcp)(dest, toWrite);
633
+ }
604
634
  }
605
635
  else {
606
636
  (0, constants_1.logVerbose)(`MCP config for ${agent.getName()} is already up to date - skipping backup and write`, verbose);
package/dist/paths/mcp.js CHANGED
@@ -59,7 +59,7 @@ async function getNativeMcpPath(adapterName, projectRoot) {
59
59
  candidates.push(path.join(projectRoot, '.mcp.json'));
60
60
  break;
61
61
  case 'OpenAI Codex CLI':
62
- candidates.push(path.join(projectRoot, '.codex', 'config.json'));
62
+ candidates.push(path.join(projectRoot, '.codex', 'config.toml'));
63
63
  break;
64
64
  case 'Aider':
65
65
  candidates.push(path.join(projectRoot, '.mcp.json'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intellectronica/ruler",
3
- "version": "0.3.29",
3
+ "version": "0.3.30",
4
4
  "description": "Ruler — apply the same rules to all coding agents",
5
5
  "main": "dist/lib.js",
6
6
  "scripts": {