Skip to content

armgit / ECC

Public Imported from GitHub
0

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

fix(install): preserve native Claude names through repair receipts

haelyrabb15240c9c01
diff --git a/scripts/lib/install/apply.js b/scripts/lib/install/apply.js
index 2fa320cfe..ce06bacb1 100644
--- a/scripts/lib/install/apply.js
+++ b/scripts/lib/install/apply.js
@@ -52,10 +52,6 @@ const {
} = require('./excluded-paths-reconciliation');
const { buildInstallIndex, rewriteRelativeLinks } = require('./link-rewrite');
const { transformInstallContent } = require('./content-transform');
-const { stripPluginNamespace } = require('./plugin-namespace');
-
-// Manual Claude targets expose bare component names.
-const MANUAL_CLAUDE_TARGETS = new Set(['claude', 'claude-project']);
function isMarkdownPath(filePath) {
return /\.(md|mdx|markdown)$/i.test(String(filePath || ''));
@@ -862,20 +858,17 @@ function applyInstallPlanLocked(plan, dependencies = {}, settingsLockHeld = fals
&& operation.sourceRelativePath
&& isMarkdownPath(operation.destinationPath)
);
- const stripNamespace = MANUAL_CLAUDE_TARGETS.has(plan.adapter?.target)
- && isMarkdownPath(operation.destinationPath);
- if (operation.kind === 'copy-file' && (operation.contentTransform || needsLinkRewrite || stripNamespace)) {
+ if (operation.kind === 'copy-file' && (operation.contentTransform || needsLinkRewrite)) {
const transformed = transformInstallContent(
operation,
fs.readFileSync(operation.sourcePath, 'utf8')
);
- const namespaced = stripNamespace ? stripPluginNamespace(transformed) : transformed;
const installedContent = needsLinkRewrite
- ? rewriteRelativeLinks(namespaced, {
+ ? rewriteRelativeLinks(transformed, {
sourceRel: operation.sourceRelativePath,
index: linkIndex,
})
- : namespaced;
+ : transformed;
const writeOptions = getOpenCodeActivationWriteOptions(operation, activationSnapshot);
if (writeOptions.expectedContent) {
writeFileNoFollow(operation.destinationPath, installedContent, {
diff --git a/scripts/lib/install/content-transform.js b/scripts/lib/install/content-transform.js
index d27e54c02..a2c48a883 100644
--- a/scripts/lib/install/content-transform.js
+++ b/scripts/lib/install/content-transform.js
@@ -1,5 +1,6 @@
'use strict';
+const { stripPluginNamespace } = require('./plugin-namespace');
const { adaptAntigravityAgent } = require('./antigravity-agent');
const { adaptCopilotAgent } = require('./copilot-agent');
const { disableOpenCodeHookPluginRegistration, getDisabledOpenCodePluginContent } = require('./hook-consent');
@@ -16,6 +17,9 @@ function transformInstallContent(operation, content) {
if (!operation.contentTransform) {
return content;
}
+ if (operation.contentTransform === 'claude-manual-plugin-namespace') {
+ return stripPluginNamespace(content);
+ }
if (operation.contentTransform === 'antigravity-agent-frontmatter') {
return adaptAntigravityAgent(content, operation.sourceRelativePath);
}
diff --git a/scripts/lib/install/plan.js b/scripts/lib/install/plan.js
index ca3ba47b6..d8a8e93ff 100644
--- a/scripts/lib/install/plan.js
+++ b/scripts/lib/install/plan.js
@@ -287,7 +287,17 @@ function createManifestInstallPlan(options = {}) {
const adapter = getInstallTargetAdapter(target);
const materializedOperations = plan.operations.flatMap(operation => (
materializeScaffoldOperation(sourceRoot, operation)
- ));
+ )).map(operation => {
+ // Persist this projection so install, doctor and repair compare the same
+ // native component names rather than restoring plugin-only references.
+ if (['claude', 'claude-project'].includes(target)
+ && operation.kind === 'copy-file'
+ && /\.(md|mdx|markdown)$/i.test(operation.destinationPath)
+ && !operation.contentTransform) {
+ return { ...operation, contentTransform: 'claude-manual-plugin-namespace' };
+ }
+ return operation;
+ });
const ruleLanguages = Array.isArray(options.ruleLanguages) ? [...options.ruleLanguages] : [];
const operations = dedupeCopyFileOperations(
options.legacyMode && target === 'antigravity'
diff --git a/tests/scripts/manual-claude-namespace.test.js b/tests/scripts/manual-claude-namespace.test.js
new file mode 100644
index 000000000..5ec2101bd
--- /dev/null
+++ b/tests/scripts/manual-claude-namespace.test.js
@@ -0,0 +1,77 @@
+'use strict';
+
+const assert = require('assert');
+const fs = require('fs');
+const os = require('os');
+const path = require('path');
+const { spawnSync } = require('child_process');
+
+const cli = path.resolve(__dirname, '../../scripts/ecc.js');
+let passed = 0;
+let failed = 0;
+
+for (const target of ['claude', 'claude-project']) {
+ const root = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-native-names-')));
+ const home = path.join(root, 'home');
+ const project = path.join(root, 'project');
+ fs.mkdirSync(home);
+ fs.mkdirSync(project);
+ const env = {
+ ...process.env,
+ HOME: home,
+ USERPROFILE: home,
+ CLAUDE_CONFIG_DIR: path.join(home, '.claude'),
+ ECC_AGENT_DATA_HOME: path.join(home, '.claude'),
+ XDG_CONFIG_HOME: path.join(home, '.config'),
+ OPENCODE_CONFIG_DIR: path.join(home, '.config/opencode'),
+ CODEX_HOME: path.join(home, '.codex'),
+ ECC_DRY_RUN: '0',
+ };
+ const installRoot = path.join(target === 'claude' ? home : project, '.claude');
+ const rule = path.join(installRoot, 'rules/ecc/common/agents.md');
+ const run = args => {
+ const result = spawnSync(process.execPath, [cli, ...args], {
+ cwd: project, env, encoding: 'utf8', timeout: 45000,
+ });
+ assert.ifError(result.error);
+ assert.strictEqual(result.status, 0, result.stderr || result.stdout);
+ return result;
+ };
+ const assertNativeNames = () => {
+ assert.match(fs.readFileSync(rule, 'utf8'), /Agent\(subagent_type: "planner"/);
+ assert.doesNotMatch(fs.readFileSync(rule, 'utf8'), /Agent\(subagent_type: "ecc:planner"/);
+ assert.ok(fs.existsSync(path.join(installRoot, 'agents/planner.md')));
+ assert.ok(fs.existsSync(path.join(installRoot, 'skills/tdd-workflow/SKILL.md')));
+ };
+ try {
+ const installArgs = ['install', '--target', target, '--modules', 'rules-core',
+ '--with', 'agent:planner', '--with', 'skill:tdd-workflow', '--no-hooks'];
+ run(installArgs);
+ assertNativeNames();
+ const report = JSON.parse(run(['doctor', '--target', target, '--json']).stdout);
+ assert.strictEqual(report.summary.errorCount, 0);
+ assert.strictEqual(report.summary.warningCount, 0);
+ fs.appendFileSync(rule, '\nlocal drift\n');
+ run(['repair', '--target', target, '--json']);
+ assertNativeNames();
+ assert.doesNotMatch(fs.readFileSync(rule, 'utf8'), /local drift/);
+ run(installArgs);
+ assertNativeNames();
+ const userFile = path.join(installRoot, 'user-note.txt');
+ fs.writeFileSync(userFile, 'keep this user file\n');
+ run(['uninstall', '--target', target, '--json']);
+ assert.ok(!fs.existsSync(rule));
+ assert.strictEqual(fs.readFileSync(userFile, 'utf8'), 'keep this user file\n');
+ passed++;
+ console.log(` PASS ${target} install, doctor, repair, reinstall and uninstall preserve native names`);
+ } catch (error) {
+ failed++;
+ console.error(` FAIL ${target}: ${error.stack}`);
+ } finally {
+ fs.rmSync(root, { recursive: true, force: true });
+ }
+}
+
+console.log(`Passed: ${passed}`);
+console.log(`Failed: ${failed}`);
+process.exitCode = failed ? 1 : 0;