mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-05-01 06:23:28 +08:00
fix: namespace cursor agent installs
This commit is contained in:
committed by
Affaan Mustafa
parent
5881554a1c
commit
e1d6d853f7
26
scripts/lib/cursor-agent-names.js
Normal file
26
scripts/lib/cursor-agent-names.js
Normal file
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
|
||||
function toCursorAgentFileName(fileName) {
|
||||
if (!fileName || fileName.startsWith('ecc-')) {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
return `ecc-${fileName}`;
|
||||
}
|
||||
|
||||
function toCursorAgentRelativePath(relativePath) {
|
||||
const segments = String(relativePath || '').split(/[\\/]+/).filter(Boolean);
|
||||
if (segments.length === 0) {
|
||||
return relativePath;
|
||||
}
|
||||
|
||||
const fileName = segments.pop();
|
||||
return path.join(...segments, toCursorAgentFileName(fileName));
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
toCursorAgentFileName,
|
||||
toCursorAgentRelativePath,
|
||||
};
|
||||
@@ -3,6 +3,7 @@ const os = require('os');
|
||||
const path = require('path');
|
||||
const { execFileSync } = require('child_process');
|
||||
|
||||
const { toCursorAgentRelativePath } = require('./cursor-agent-names');
|
||||
const { LEGACY_INSTALL_TARGETS, parseInstallArgs } = require('./install/request');
|
||||
const {
|
||||
SUPPORTED_INSTALL_TARGETS,
|
||||
@@ -154,7 +155,13 @@ function addRecursiveCopyOperations(operations, options) {
|
||||
for (const relativeFile of relativeFiles) {
|
||||
const sourceRelativePath = path.join(options.sourceRelativeDir, relativeFile);
|
||||
const sourcePath = path.join(options.sourceRoot, sourceRelativePath);
|
||||
const destinationPath = path.join(options.destinationDir, relativeFile);
|
||||
const destinationRelativePath = typeof options.destinationRelativePathTransform === 'function'
|
||||
? options.destinationRelativePathTransform(relativeFile, sourceRelativePath)
|
||||
: relativeFile;
|
||||
if (!destinationRelativePath) {
|
||||
continue;
|
||||
}
|
||||
const destinationPath = path.join(options.destinationDir, destinationRelativePath);
|
||||
operations.push(buildCopyFileOperation({
|
||||
moduleId: options.moduleId,
|
||||
sourcePath,
|
||||
@@ -351,6 +358,7 @@ function planCursorLegacyInstall(context) {
|
||||
sourceRoot: context.sourceRoot,
|
||||
sourceRelativeDir: path.join('.cursor', 'agents'),
|
||||
destinationDir: path.join(targetRoot, 'agents'),
|
||||
destinationRelativePathTransform: toCursorAgentRelativePath,
|
||||
});
|
||||
addRecursiveCopyOperations(operations, {
|
||||
moduleId: 'legacy-cursor-install',
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const { toCursorAgentFileName } = require('../cursor-agent-names');
|
||||
const {
|
||||
createFlatFileOperations,
|
||||
createFlatRuleOperations,
|
||||
createInstallTargetAdapter,
|
||||
createManagedOperation,
|
||||
@@ -149,6 +151,16 @@ module.exports = createInstallTargetAdapter({
|
||||
}));
|
||||
}
|
||||
|
||||
if (sourceRelativePath === 'agents') {
|
||||
return takeUniqueOperations(createFlatFileOperations({
|
||||
moduleId: module.id,
|
||||
repoRoot,
|
||||
sourceRelativePath,
|
||||
destinationDir: path.join(targetRoot, 'agents'),
|
||||
destinationNameTransform: toCursorAgentFileName,
|
||||
}));
|
||||
}
|
||||
|
||||
if (sourceRelativePath === '.cursor') {
|
||||
const cursorRoot = path.join(repoRoot, '.cursor');
|
||||
if (!fs.existsSync(cursorRoot) || !fs.statSync(cursorRoot).isDirectory()) {
|
||||
|
||||
@@ -181,7 +181,7 @@ function createNamespacedFlatRuleOperations(adapter, moduleId, sourceRelativePat
|
||||
return operations;
|
||||
}
|
||||
|
||||
function createFlatRuleOperations({
|
||||
function createFlatFileOperations({
|
||||
moduleId,
|
||||
repoRoot,
|
||||
sourceRelativePath,
|
||||
@@ -242,6 +242,10 @@ function createFlatRuleOperations({
|
||||
return operations;
|
||||
}
|
||||
|
||||
function createFlatRuleOperations(options) {
|
||||
return createFlatFileOperations(options);
|
||||
}
|
||||
|
||||
function createInstallTargetAdapter(config) {
|
||||
const adapter = {
|
||||
id: config.id,
|
||||
@@ -342,6 +346,7 @@ function createInstallTargetAdapter(config) {
|
||||
|
||||
module.exports = {
|
||||
buildValidationIssue,
|
||||
createFlatFileOperations,
|
||||
createFlatRuleOperations,
|
||||
createInstallTargetAdapter,
|
||||
createManagedOperation,
|
||||
|
||||
Reference in New Issue
Block a user