Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions scripts/install-apply.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,16 @@

const {
SUPPORTED_INSTALL_TARGETS,
listAvailableLanguages,
} = require('./lib/install-executor');
listLegacyCompatibilityLanguages,
} = require('./lib/install-manifests');
const {
LEGACY_INSTALL_TARGETS,
normalizeInstallRequest,
parseInstallArgs,
} = require('./lib/install/request');
const { loadInstallConfig } = require('./lib/install/config');
const { applyInstallPlan } = require('./lib/install/apply');
const { createInstallPlanFromRequest } = require('./lib/install/runtime');

function showHelp(exitCode = 0) {
const languages = listAvailableLanguages();
const languages = listLegacyCompatibilityLanguages();

console.log(`
Usage: install.sh [--target <${LEGACY_INSTALL_TARGETS.join('|')}>] [--dry-run] [--json] <language> [<language> ...]
Expand Down Expand Up @@ -61,6 +58,9 @@ function printHumanPlan(plan, dryRun) {
if (plan.mode === 'legacy') {
console.log(`Languages: ${plan.languages.join(', ')}`);
} else {
if (plan.mode === 'legacy-compat') {
console.log(`Legacy languages: ${plan.legacyLanguages.join(', ')}`);
}
console.log(`Profile: ${plan.profileId || '(custom modules)'}`);
console.log(`Included components: ${plan.includedComponentIds.join(', ') || '(none)'}`);
console.log(`Excluded components: ${plan.excludedComponentIds.join(', ') || '(none)'}`);
Expand Down Expand Up @@ -100,6 +100,9 @@ function main() {
showHelp(0);
}

const { loadInstallConfig } = require('./lib/install/config');
const { applyInstallPlan } = require('./lib/install-executor');
const { createInstallPlanFromRequest } = require('./lib/install/runtime');
const config = options.configPath
? loadInstallConfig(options.configPath, { cwd: process.cwd() })
: null;
Expand Down
96 changes: 77 additions & 19 deletions scripts/lib/install-executor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ const fs = require('fs');
const path = require('path');
const { execFileSync } = require('child_process');

const { applyInstallPlan } = require('./install/apply');
const { LEGACY_INSTALL_TARGETS, parseInstallArgs } = require('./install/request');
const {
SUPPORTED_INSTALL_TARGETS,
listLegacyCompatibilityLanguages,
resolveLegacyCompatibilitySelection,
resolveInstallPlan,
} = require('./install-manifests');
const { getInstallTargetAdapter } = require('./install-targets/registry');
const { createInstallState } = require('./install-state');

const LANGUAGE_NAME_PATTERN = /^[a-zA-Z0-9_-]+$/;
const EXCLUDED_GENERATED_SOURCE_SUFFIXES = [
Expand Down Expand Up @@ -68,8 +68,11 @@ function readDirectoryNames(dirPath) {
}

function listAvailableLanguages(sourceRoot = getSourceRoot()) {
return readDirectoryNames(path.join(sourceRoot, 'rules'))
.filter(name => name !== 'common');
return [...new Set([
...listLegacyCompatibilityLanguages(),
...readDirectoryNames(path.join(sourceRoot, 'rules'))
.filter(name => name !== 'common'),
])].sort();
}

function validateLegacyTarget(target) {
Expand Down Expand Up @@ -108,6 +111,16 @@ function isGeneratedRuntimeSourcePath(sourceRelativePath) {
return EXCLUDED_GENERATED_SOURCE_SUFFIXES.some(suffix => normalizedPath.endsWith(suffix));
}

function createStatePreview(options) {
const { createInstallState } = require('./install-state');
return createInstallState(options);
}

function applyInstallPlan(plan) {
const { applyInstallPlan: applyPlan } = require('./install/apply');
return applyPlan(plan);
}

function buildCopyFileOperation({ moduleId, sourcePath, sourceRelativePath, destinationPath, strategy }) {
return {
kind: 'copy-file',
Expand Down Expand Up @@ -449,7 +462,7 @@ function createLegacyInstallPlan(options = {}) {
manifestVersion: getManifestVersion(sourceRoot),
};

const statePreview = createInstallState({
const statePreview = createStatePreview({
adapter: plan.adapter,
targetRoot: plan.targetRoot,
installStatePath: plan.installStatePath,
Expand Down Expand Up @@ -485,6 +498,38 @@ function createLegacyInstallPlan(options = {}) {
};
}

function createLegacyCompatInstallPlan(options = {}) {
const sourceRoot = options.sourceRoot || getSourceRoot();
const projectRoot = options.projectRoot || process.cwd();
const target = options.target || 'claude';

validateLegacyTarget(target);

const selection = resolveLegacyCompatibilitySelection({
repoRoot: sourceRoot,
target,
legacyLanguages: options.legacyLanguages || [],
});

return createManifestInstallPlan({
sourceRoot,
projectRoot,
homeDir: options.homeDir,
target,
profileId: null,
moduleIds: selection.moduleIds,
includeComponentIds: [],
excludeComponentIds: [],
legacyLanguages: selection.legacyLanguages,
legacyMode: true,
requestProfileId: null,
requestModuleIds: [],
requestIncludeComponentIds: [],
requestExcludeComponentIds: [],
mode: 'legacy-compat',
});
}
Comment on lines +501 to +531

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

claudeRulesDir option is accepted but not forwarded to createManifestInstallPlan.

The function accepts options.claudeRulesDir (documented by the caller in runtime.js) but does not pass it to createManifestInstallPlan. If a user sets CLAUDE_RULES_DIR expecting custom rules directory support, the legacy-compat path will silently ignore it.

🔧 Proposed fix to forward claudeRulesDir
   return createManifestInstallPlan({
     sourceRoot,
     projectRoot,
     homeDir: options.homeDir,
+    claudeRulesDir: options.claudeRulesDir,
     target,
     profileId: null,
     moduleIds: selection.moduleIds,
#!/bin/bash
# Check if createManifestInstallPlan accepts claudeRulesDir
rg -n 'claudeRulesDir' scripts/lib/install-executor.js
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/lib/install-executor.js` around lines 501 - 531, The
createLegacyCompatInstallPlan function accepts options.claudeRulesDir but does
not forward it to createManifestInstallPlan; update the
createManifestInstallPlan call inside createLegacyCompatInstallPlan to include
claudeRulesDir: options.claudeRulesDir (or options.claudeRulesDir || undefined)
so the provided CLAUDE_RULES_DIR is honored when building the legacy-compat
install plan; reference createLegacyCompatInstallPlan and
createManifestInstallPlan when making this change.


function materializeScaffoldOperation(sourceRoot, operation) {
const sourcePath = path.join(sourceRoot, operation.sourceRelativePath);
if (!fs.existsSync(sourcePath)) {
Expand Down Expand Up @@ -526,6 +571,21 @@ function createManifestInstallPlan(options = {}) {
const sourceRoot = options.sourceRoot || getSourceRoot();
const projectRoot = options.projectRoot || process.cwd();
const target = options.target || 'claude';
const legacyLanguages = Array.isArray(options.legacyLanguages)
? [...options.legacyLanguages]
: [];
const requestProfileId = Object.hasOwn(options, 'requestProfileId')
? options.requestProfileId
: (options.profileId || null);
const requestModuleIds = Object.hasOwn(options, 'requestModuleIds')
? [...options.requestModuleIds]
: (Array.isArray(options.moduleIds) ? [...options.moduleIds] : []);
const requestIncludeComponentIds = Object.hasOwn(options, 'requestIncludeComponentIds')
? [...options.requestIncludeComponentIds]
: (Array.isArray(options.includeComponentIds) ? [...options.includeComponentIds] : []);
const requestExcludeComponentIds = Object.hasOwn(options, 'requestExcludeComponentIds')
? [...options.requestExcludeComponentIds]
: (Array.isArray(options.excludeComponentIds) ? [...options.excludeComponentIds] : []);
const plan = resolveInstallPlan({
repoRoot: sourceRoot,
projectRoot,
Expand All @@ -543,21 +603,17 @@ function createManifestInstallPlan(options = {}) {
repoCommit: getRepoCommit(sourceRoot),
manifestVersion: getManifestVersion(sourceRoot),
};
const statePreview = createInstallState({
const statePreview = createStatePreview({
adapter,
targetRoot: plan.targetRoot,
installStatePath: plan.installStatePath,
request: {
profile: plan.profileId,
modules: Array.isArray(options.moduleIds) ? [...options.moduleIds] : [],
includeComponents: Array.isArray(options.includeComponentIds)
? [...options.includeComponentIds]
: [],
excludeComponents: Array.isArray(options.excludeComponentIds)
? [...options.excludeComponentIds]
: [],
legacyLanguages: [],
legacyMode: false,
profile: requestProfileId,
modules: requestModuleIds,
includeComponents: requestIncludeComponentIds,
excludeComponents: requestExcludeComponentIds,
legacyLanguages,
legacyMode: Boolean(options.legacyMode),
},
resolution: {
selectedModules: plan.selectedModuleIds,
Expand All @@ -568,7 +624,7 @@ function createManifestInstallPlan(options = {}) {
});

return {
mode: 'manifest',
mode: options.mode || 'manifest',
target,
adapter: {
id: adapter.id,
Expand All @@ -578,8 +634,9 @@ function createManifestInstallPlan(options = {}) {
targetRoot: plan.targetRoot,
installRoot: plan.targetRoot,
installStatePath: plan.installStatePath,
warnings: [],
languages: [],
warnings: Array.isArray(options.warnings) ? [...options.warnings] : [],
languages: legacyLanguages,
legacyLanguages,
profileId: plan.profileId,
requestedModuleIds: plan.requestedModuleIds,
explicitModuleIds: plan.explicitModuleIds,
Expand All @@ -597,6 +654,7 @@ module.exports = {
SUPPORTED_INSTALL_TARGETS,
LEGACY_INSTALL_TARGETS,
applyInstallPlan,
createLegacyCompatInstallPlan,
createManifestInstallPlan,
createLegacyInstallPlan,
getSourceRoot,
Expand Down
Loading
Loading