@intellectronica/ruler 0.3.4 → 0.3.5
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/dist/agents/CodexCliAgent.js +17 -11
- package/dist/core/GitignoreUtils.js +11 -2
- package/dist/core/apply-engine.js +3 -5
- package/dist/lib.js +1 -1
- package/package.json +1 -1
|
@@ -44,26 +44,26 @@ const constants_1 = require("../constants");
|
|
|
44
44
|
/**
|
|
45
45
|
* OpenAI Codex CLI agent adapter.
|
|
46
46
|
*/
|
|
47
|
-
class CodexCliAgent
|
|
47
|
+
class CodexCliAgent {
|
|
48
|
+
constructor() {
|
|
49
|
+
this.agentsMdAgent = new AgentsMdAgent_1.AgentsMdAgent();
|
|
50
|
+
}
|
|
48
51
|
getIdentifier() {
|
|
49
52
|
return 'codex';
|
|
50
53
|
}
|
|
51
54
|
getName() {
|
|
52
55
|
return 'OpenAI Codex CLI';
|
|
53
56
|
}
|
|
54
|
-
async applyRulerConfig(concatenatedRules, projectRoot, rulerMcpJson, agentConfig) {
|
|
55
|
-
// First perform idempotent AGENTS.md write via
|
|
56
|
-
await
|
|
57
|
+
async applyRulerConfig(concatenatedRules, projectRoot, rulerMcpJson, agentConfig, backup = true) {
|
|
58
|
+
// First perform idempotent AGENTS.md write via composed AgentsMdAgent
|
|
59
|
+
await this.agentsMdAgent.applyRulerConfig(concatenatedRules, projectRoot, null, {
|
|
57
60
|
// Preserve explicit outputPath precedence semantics if provided.
|
|
58
61
|
outputPath: agentConfig?.outputPath ||
|
|
59
62
|
agentConfig?.outputPathInstructions ||
|
|
60
63
|
undefined,
|
|
61
|
-
});
|
|
62
|
-
//
|
|
63
|
-
const defaults =
|
|
64
|
-
instructions: path.join(projectRoot, constants_1.DEFAULT_RULES_FILENAME),
|
|
65
|
-
config: path.join(projectRoot, '.codex', 'config.toml'),
|
|
66
|
-
};
|
|
64
|
+
}, backup);
|
|
65
|
+
// Use proper path resolution from getDefaultOutputPath and agentConfig
|
|
66
|
+
const defaults = this.getDefaultOutputPath(projectRoot);
|
|
67
67
|
const mcpEnabled = agentConfig?.mcp?.enabled ?? true;
|
|
68
68
|
if (mcpEnabled && rulerMcpJson) {
|
|
69
69
|
// Apply MCP server filtering and transformation
|
|
@@ -73,7 +73,7 @@ class CodexCliAgent extends AgentsMdAgent_1.AgentsMdAgent {
|
|
|
73
73
|
return; // No compatible servers found
|
|
74
74
|
}
|
|
75
75
|
const filteredRulerMcpJson = filteredMcpConfig;
|
|
76
|
-
// Determine the config file path
|
|
76
|
+
// Determine the config file path using proper precedence
|
|
77
77
|
const configPath = agentConfig?.outputPathConfig ?? defaults.config;
|
|
78
78
|
// Ensure the parent directory exists
|
|
79
79
|
await fs_1.promises.mkdir(path.dirname(configPath), { recursive: true });
|
|
@@ -177,6 +177,12 @@ class CodexCliAgent extends AgentsMdAgent_1.AgentsMdAgent {
|
|
|
177
177
|
await (0, FileSystemUtils_1.writeGeneratedFile)(configPath, tomlContent);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
+
getDefaultOutputPath(projectRoot) {
|
|
181
|
+
return {
|
|
182
|
+
instructions: path.join(projectRoot, constants_1.DEFAULT_RULES_FILENAME),
|
|
183
|
+
config: path.join(projectRoot, '.codex', 'config.toml'),
|
|
184
|
+
};
|
|
185
|
+
}
|
|
180
186
|
supportsMcpStdio() {
|
|
181
187
|
return true;
|
|
182
188
|
}
|
|
@@ -57,8 +57,9 @@ async function updateGitignore(projectRoot, paths) {
|
|
|
57
57
|
throw err;
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
// Convert paths to relative POSIX format
|
|
61
|
-
const relativePaths = paths
|
|
60
|
+
// Convert paths to repo-relative POSIX format with leading /
|
|
61
|
+
const relativePaths = paths
|
|
62
|
+
.map((p) => {
|
|
62
63
|
let relative;
|
|
63
64
|
if (path.isAbsolute(p)) {
|
|
64
65
|
relative = path.relative(projectRoot, p);
|
|
@@ -78,6 +79,14 @@ async function updateGitignore(projectRoot, paths) {
|
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
return relative.replace(/\\/g, '/'); // Convert to POSIX format
|
|
82
|
+
})
|
|
83
|
+
.filter((p) => {
|
|
84
|
+
// Never include any path that resides inside a .ruler directory (inputs, not outputs)
|
|
85
|
+
return !p.includes('/.ruler/') && !p.startsWith('.ruler/');
|
|
86
|
+
})
|
|
87
|
+
.map((p) => {
|
|
88
|
+
// Always write full repository-relative paths (prefix with leading /)
|
|
89
|
+
return p.startsWith('/') ? p : `/${p}`;
|
|
81
90
|
});
|
|
82
91
|
// Get all existing paths from .gitignore (excluding Ruler block)
|
|
83
92
|
const existingPaths = getExistingPathsExcludingRulerBlock(existingContent);
|
|
@@ -402,7 +402,7 @@ async function applyStandardMcpConfiguration(agent, filteredMcpJson, dest, agent
|
|
|
402
402
|
* @param cliGitignoreEnabled CLI gitignore setting
|
|
403
403
|
* @param dryRun Whether to perform a dry run
|
|
404
404
|
*/
|
|
405
|
-
async function updateGitignore(projectRoot, generatedPaths, config, cliGitignoreEnabled, dryRun
|
|
405
|
+
async function updateGitignore(projectRoot, generatedPaths, config, cliGitignoreEnabled, dryRun) {
|
|
406
406
|
// Configuration precedence: CLI > TOML > Default (enabled)
|
|
407
407
|
let gitignoreEnabled;
|
|
408
408
|
if (cliGitignoreEnabled !== undefined) {
|
|
@@ -416,10 +416,8 @@ async function updateGitignore(projectRoot, generatedPaths, config, cliGitignore
|
|
|
416
416
|
}
|
|
417
417
|
if (gitignoreEnabled && generatedPaths.length > 0) {
|
|
418
418
|
const uniquePaths = [...new Set(generatedPaths)];
|
|
419
|
-
//
|
|
420
|
-
|
|
421
|
-
uniquePaths.push('*.bak');
|
|
422
|
-
}
|
|
419
|
+
// Note: Individual backup patterns are added per-file in the collection phase
|
|
420
|
+
// No need to add a broad *.bak pattern here
|
|
423
421
|
if (uniquePaths.length > 0) {
|
|
424
422
|
const prefix = (0, constants_1.actionPrefix)(dryRun);
|
|
425
423
|
if (dryRun) {
|
package/dist/lib.js
CHANGED
|
@@ -53,7 +53,7 @@ async function applyAllAgentConfigs(projectRoot, includedAgents, configPath, cli
|
|
|
53
53
|
(0, constants_1.logVerbose)(`Selected ${selectedAgents.length} agents: ${selectedAgents.map((a) => a.getName()).join(', ')}`, verbose);
|
|
54
54
|
generatedPaths = await (0, apply_engine_1.processSingleConfiguration)(selectedAgents, singleConfig, projectRoot, verbose, dryRun, cliMcpEnabled, cliMcpStrategy, backup);
|
|
55
55
|
}
|
|
56
|
-
await (0, apply_engine_1.updateGitignore)(projectRoot, generatedPaths, loadedConfig, cliGitignoreEnabled, dryRun
|
|
56
|
+
await (0, apply_engine_1.updateGitignore)(projectRoot, generatedPaths, loadedConfig, cliGitignoreEnabled, dryRun);
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* Normalizes per-agent config keys to agent identifiers for consistent lookup.
|