mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-05-20 19:29:58 +08:00
feat(install-targets): add claude-project (per-project Claude Code) adapter
Completes the install-target matrix for Claude Code. Until now, ECC's Claude support was home-scope only (~/.claude/) via the `claude` target. This adds a project-scope counterpart (./.claude/) via a new `claude-project` target so teams can install ECC per-repo without contaminating ~/.claude/ — matching the existing project-scope adapters for Cursor, Antigravity, Gemini, CodeBuddy, Joycode, and Zed. Symmetric with `claude`: - Same namespace under rules/ecc and skills/ecc - Same docs/<locale> handling for --locale - Same hooks placeholder substitution for hooks.json - Reuses claude-home's destination-mapping logic 1:1 Use cases: - Monorepos with multiple Flow-managed projects - Teams that want ECC scoped per-project without touching ~/.claude/ - Per-project skill/rule isolation when global install isn't desirable No breaking change: existing --target claude continues to route to claude-home (user-scope) unchanged. New target is opt-in. Tests ----- - 4 new tests in tests/lib/install-targets.test.js (root resolution, lookup-by-id, plan parity with claude, foreign-path filtering) - All install-target regression guards (schema enum / SUPPORTED_INSTALL_TARGETS) still pass - End-to-end smoke: `--target claude-project --profile minimal --dry-run` emits 359 ops with destinations rooted at <projectRoot>/.claude/ (parity with --target claude which emits 359 ops rooted at ~/.claude/)
This commit is contained in:
committed by
Affaan Mustafa
parent
27e4036075
commit
7004a66243
@@ -27,11 +27,12 @@ Usage: install.sh [--target <${LEGACY_INSTALL_TARGETS.join('|')}>] [--dry-run] [
|
||||
install.sh [--target <${SUPPORTED_INSTALL_TARGETS.join('|')}>] [--dry-run] [--json] --profile <name> [--with <component>]... [--without <component>]...
|
||||
install.sh [--target <${SUPPORTED_INSTALL_TARGETS.join('|')}>] [--dry-run] [--json] --modules <id,id,...> [--with <component>]... [--without <component>]...
|
||||
install.sh [--target <${SUPPORTED_INSTALL_TARGETS.join('|')}>] [--dry-run] [--json] --skills <skill-id[,skill-id...]>
|
||||
install.sh [--target claude] [--dry-run] [--json] --locale <locale-code>
|
||||
install.sh [--target claude|claude-project] [--dry-run] [--json] --locale <locale-code>
|
||||
install.sh [--dry-run] [--json] --config <path>
|
||||
|
||||
Targets:
|
||||
claude (default) - Install ECC into ~/.claude/ with managed rules/skills under rules/ecc and skills/ecc
|
||||
claude-project - Install ECC into ./.claude/ (per-project) with managed rules/skills under rules/ecc and skills/ecc
|
||||
cursor - Install rules, hooks, and bundled Cursor configs to ./.cursor/
|
||||
antigravity - Install rules, workflows, skills, and agents to ./.agent/
|
||||
codex - Install shared agents/config into ~/.codex/
|
||||
@@ -49,8 +50,8 @@ Options:
|
||||
--skills <ids> Install one or more skill directories by ID, e.g. continuous-learning-v2
|
||||
--without <component>
|
||||
Exclude a user-facing install component
|
||||
--locale <code> Install translated docs to ~/.claude/docs/<locale>/
|
||||
(claude target only; can be combined with --profile or --with)
|
||||
--locale <code> Install translated docs to ~/.claude/docs/<locale>/ (or ./.claude/docs/<locale>/ for claude-project)
|
||||
(claude or claude-project target only; can be combined with --profile or --with)
|
||||
--config <path> Load install intent from ecc-install.json
|
||||
--dry-run Show the install plan without copying files
|
||||
--json Emit machine-readable plan/result JSON
|
||||
|
||||
@@ -4,7 +4,7 @@ const path = require('path');
|
||||
const { getInstallTargetAdapter, planInstallTargetScaffold } = require('./install-targets/registry');
|
||||
|
||||
const DEFAULT_REPO_ROOT = path.join(__dirname, '../..');
|
||||
const SUPPORTED_INSTALL_TARGETS = ['claude', 'cursor', 'antigravity', 'codex', 'gemini', 'opencode', 'codebuddy', 'joycode', 'qwen', 'zed'];
|
||||
const SUPPORTED_INSTALL_TARGETS = ['claude', 'claude-project', 'cursor', 'antigravity', 'codex', 'gemini', 'opencode', 'codebuddy', 'joycode', 'qwen', 'zed'];
|
||||
const COMPONENT_FAMILY_PREFIXES = {
|
||||
baseline: 'baseline:',
|
||||
language: 'lang:',
|
||||
@@ -43,6 +43,14 @@ const LEGACY_COMPAT_BASE_MODULE_IDS_BY_TARGET = Object.freeze({
|
||||
'platform-configs',
|
||||
'workflow-quality',
|
||||
],
|
||||
'claude-project': [
|
||||
'rules-core',
|
||||
'agents-core',
|
||||
'commands-core',
|
||||
'hooks-runtime',
|
||||
'platform-configs',
|
||||
'workflow-quality',
|
||||
],
|
||||
cursor: [
|
||||
'rules-core',
|
||||
'agents-core',
|
||||
|
||||
91
scripts/lib/install-targets/claude-project.js
Normal file
91
scripts/lib/install-targets/claude-project.js
Normal file
@@ -0,0 +1,91 @@
|
||||
const path = require('path');
|
||||
|
||||
const {
|
||||
createInstallTargetAdapter,
|
||||
createRemappedOperation,
|
||||
isForeignPlatformPath,
|
||||
normalizeRelativePath,
|
||||
} = require('./helpers');
|
||||
|
||||
const CLAUDE_ECC_NAMESPACE = 'ecc';
|
||||
|
||||
function getClaudeManagedDestinationPath(adapter, sourceRelativePath, input) {
|
||||
const normalizedSourcePath = normalizeRelativePath(sourceRelativePath);
|
||||
const targetRoot = adapter.resolveRoot(input);
|
||||
|
||||
if (normalizedSourcePath === 'rules') {
|
||||
return path.join(targetRoot, 'rules', CLAUDE_ECC_NAMESPACE);
|
||||
}
|
||||
|
||||
if (normalizedSourcePath.startsWith('rules/')) {
|
||||
return path.join(
|
||||
targetRoot,
|
||||
'rules',
|
||||
CLAUDE_ECC_NAMESPACE,
|
||||
normalizedSourcePath.slice('rules/'.length)
|
||||
);
|
||||
}
|
||||
|
||||
if (normalizedSourcePath === 'skills') {
|
||||
return path.join(targetRoot, 'skills', CLAUDE_ECC_NAMESPACE);
|
||||
}
|
||||
|
||||
if (normalizedSourcePath.startsWith('skills/')) {
|
||||
return path.join(
|
||||
targetRoot,
|
||||
'skills',
|
||||
CLAUDE_ECC_NAMESPACE,
|
||||
normalizedSourcePath.slice('skills/'.length)
|
||||
);
|
||||
}
|
||||
|
||||
if (normalizedSourcePath === 'docs' || normalizedSourcePath.startsWith('docs/')) {
|
||||
return path.join(targetRoot, normalizedSourcePath);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
module.exports = createInstallTargetAdapter({
|
||||
id: 'claude-project',
|
||||
target: 'claude-project',
|
||||
kind: 'project',
|
||||
rootSegments: ['.claude'],
|
||||
installStatePathSegments: ['ecc', 'install-state.json'],
|
||||
nativeRootRelativePath: '.claude-plugin',
|
||||
planOperations(input, adapter) {
|
||||
const modules = Array.isArray(input.modules)
|
||||
? input.modules
|
||||
: (input.module ? [input.module] : []);
|
||||
const planningInput = {
|
||||
repoRoot: input.repoRoot,
|
||||
projectRoot: input.projectRoot,
|
||||
homeDir: input.homeDir,
|
||||
};
|
||||
|
||||
return modules.flatMap(module => {
|
||||
const paths = Array.isArray(module.paths) ? module.paths : [];
|
||||
return paths
|
||||
.filter(p => !isForeignPlatformPath(p, 'claude'))
|
||||
.map(sourceRelativePath => {
|
||||
const managedDestinationPath = getClaudeManagedDestinationPath(
|
||||
adapter,
|
||||
sourceRelativePath,
|
||||
planningInput
|
||||
);
|
||||
|
||||
if (managedDestinationPath) {
|
||||
return createRemappedOperation(
|
||||
adapter,
|
||||
module.id,
|
||||
sourceRelativePath,
|
||||
managedDestinationPath,
|
||||
{ strategy: 'preserve-relative-path' }
|
||||
);
|
||||
}
|
||||
|
||||
return adapter.createScaffoldOperation(module.id, sourceRelativePath, planningInput);
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -1,5 +1,6 @@
|
||||
const antigravityProject = require('./antigravity-project');
|
||||
const claudeHome = require('./claude-home');
|
||||
const claudeProject = require('./claude-project');
|
||||
const codebuddyProject = require('./codebuddy-project');
|
||||
const codexHome = require('./codex-home');
|
||||
const cursorProject = require('./cursor-project');
|
||||
@@ -11,6 +12,7 @@ const zedProject = require('./zed-project');
|
||||
|
||||
const ADAPTERS = Object.freeze([
|
||||
claudeHome,
|
||||
claudeProject,
|
||||
cursorProject,
|
||||
antigravityProject,
|
||||
codexHome,
|
||||
|
||||
@@ -89,7 +89,7 @@ function isMcpConfigPath(filePath) {
|
||||
}
|
||||
|
||||
function buildResolvedClaudeHooks(plan) {
|
||||
if (!plan.adapter || plan.adapter.target !== 'claude') {
|
||||
if (!plan.adapter || (plan.adapter.target !== 'claude' && plan.adapter.target !== 'claude-project')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,8 +100,8 @@ function normalizeInstallRequest(options = {}) {
|
||||
`Unsupported locale: "${locale}". Supported locales: ${listSupportedLocales().join(', ')}`
|
||||
);
|
||||
}
|
||||
if (locale && target !== 'claude') {
|
||||
throw new Error('--locale can only be used with --target claude');
|
||||
if (locale && target !== 'claude' && target !== 'claude-project') {
|
||||
throw new Error('--locale can only be used with --target claude or --target claude-project');
|
||||
}
|
||||
const requestedIncludeComponentIds = dedupeStrings([
|
||||
...(config?.includeComponentIds || []),
|
||||
|
||||
Reference in New Issue
Block a user