rulesync 8.10.0 → 8.12.0
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/{chunk-RMITDFVW.js → chunk-643VJ2QM.js} +245 -15
- package/dist/cli/index.cjs +208 -95
- package/dist/cli/index.js +198 -317
- package/dist/index.cjs +270 -14
- package/dist/index.d.cts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +27 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -32,6 +32,7 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
ALL_FEATURES: () => ALL_FEATURES,
|
|
34
34
|
ALL_TOOL_TARGETS: () => ALL_TOOL_TARGETS,
|
|
35
|
+
convertFromTool: () => convertFromTool2,
|
|
35
36
|
generate: () => generate2,
|
|
36
37
|
importFromTool: () => importFromTool2
|
|
37
38
|
});
|
|
@@ -876,10 +877,6 @@ function getBaseDirsInLightOfGlobal({
|
|
|
876
877
|
return resolvedBaseDirs;
|
|
877
878
|
}
|
|
878
879
|
|
|
879
|
-
// src/lib/generate.ts
|
|
880
|
-
var import_node_path148 = require("path");
|
|
881
|
-
var import_es_toolkit5 = require("es-toolkit");
|
|
882
|
-
|
|
883
880
|
// src/features/commands/commands-processor.ts
|
|
884
881
|
var import_node_path25 = require("path");
|
|
885
882
|
var import_mini16 = require("zod/mini");
|
|
@@ -4037,7 +4034,8 @@ var CODEXCLI_HOOK_EVENTS = [
|
|
|
4037
4034
|
"preToolUse",
|
|
4038
4035
|
"postToolUse",
|
|
4039
4036
|
"beforeSubmitPrompt",
|
|
4040
|
-
"stop"
|
|
4037
|
+
"stop",
|
|
4038
|
+
"permissionRequest"
|
|
4041
4039
|
];
|
|
4042
4040
|
var hooksRecordSchema = import_mini17.z.record(import_mini17.z.string(), import_mini17.z.array(HookDefinitionSchema));
|
|
4043
4041
|
var HooksConfigSchema = import_mini17.z.looseObject({
|
|
@@ -4154,7 +4152,8 @@ var CANONICAL_TO_CODEXCLI_EVENT_NAMES = {
|
|
|
4154
4152
|
preToolUse: "PreToolUse",
|
|
4155
4153
|
postToolUse: "PostToolUse",
|
|
4156
4154
|
beforeSubmitPrompt: "UserPromptSubmit",
|
|
4157
|
-
stop: "Stop"
|
|
4155
|
+
stop: "Stop",
|
|
4156
|
+
permissionRequest: "PermissionRequest"
|
|
4158
4157
|
};
|
|
4159
4158
|
var CODEXCLI_TO_CANONICAL_EVENT_NAMES = Object.fromEntries(
|
|
4160
4159
|
Object.entries(CANONICAL_TO_CODEXCLI_EVENT_NAMES).map(([k, v]) => [v, k])
|
|
@@ -19134,9 +19133,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
19134
19133
|
}
|
|
19135
19134
|
toRulesyncRule() {
|
|
19136
19135
|
let globs;
|
|
19137
|
-
if (this.
|
|
19138
|
-
globs = ["**/*"];
|
|
19139
|
-
} else if (this.frontmatter.applyTo) {
|
|
19136
|
+
if (this.frontmatter.applyTo) {
|
|
19140
19137
|
globs = this.frontmatter.applyTo.split(",").map((g) => g.trim());
|
|
19141
19138
|
}
|
|
19142
19139
|
const rulesyncFrontmatter = {
|
|
@@ -19177,7 +19174,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
19177
19174
|
if (root) {
|
|
19178
19175
|
return new _CopilotRule({
|
|
19179
19176
|
baseDir,
|
|
19180
|
-
frontmatter:
|
|
19177
|
+
frontmatter: {},
|
|
19181
19178
|
body,
|
|
19182
19179
|
relativeDirPath: paths.root.relativeDirPath,
|
|
19183
19180
|
relativeFilePath: paths.root.relativeFilePath,
|
|
@@ -19203,12 +19200,14 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
19203
19200
|
}
|
|
19204
19201
|
static async fromFile({
|
|
19205
19202
|
baseDir = process.cwd(),
|
|
19203
|
+
relativeDirPath,
|
|
19206
19204
|
relativeFilePath,
|
|
19207
19205
|
validate = true,
|
|
19208
19206
|
global = false
|
|
19209
19207
|
}) {
|
|
19210
19208
|
const paths = this.getSettablePaths({ global });
|
|
19211
|
-
const isRoot = relativeFilePath === paths.root.relativeFilePath;
|
|
19209
|
+
const isRoot = relativeDirPath ? (0, import_node_path129.join)(relativeDirPath, relativeFilePath) === (0, import_node_path129.join)(paths.root.relativeDirPath, paths.root.relativeFilePath) : relativeFilePath === paths.root.relativeFilePath;
|
|
19210
|
+
const resolvedRelativeDirPath = relativeDirPath ?? (isRoot ? paths.root.relativeDirPath : paths.nonRoot?.relativeDirPath ?? paths.root.relativeDirPath);
|
|
19212
19211
|
if (isRoot) {
|
|
19213
19212
|
const relativePath2 = (0, import_node_path129.join)(paths.root.relativeDirPath, paths.root.relativeFilePath);
|
|
19214
19213
|
const filePath2 = (0, import_node_path129.join)(baseDir, relativePath2);
|
|
@@ -19226,7 +19225,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
19226
19225
|
if (!paths.nonRoot) {
|
|
19227
19226
|
throw new Error(`nonRoot path is not set for ${relativeFilePath}`);
|
|
19228
19227
|
}
|
|
19229
|
-
const relativePath = (0, import_node_path129.join)(
|
|
19228
|
+
const relativePath = (0, import_node_path129.join)(resolvedRelativeDirPath, relativeFilePath);
|
|
19230
19229
|
const filePath = (0, import_node_path129.join)(baseDir, relativePath);
|
|
19231
19230
|
const fileContent = await readFileContent(filePath);
|
|
19232
19231
|
const { frontmatter, body: content } = parseFrontmatter(fileContent, filePath);
|
|
@@ -19236,7 +19235,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
19236
19235
|
}
|
|
19237
19236
|
return new _CopilotRule({
|
|
19238
19237
|
baseDir,
|
|
19239
|
-
relativeDirPath:
|
|
19238
|
+
relativeDirPath: resolvedRelativeDirPath,
|
|
19240
19239
|
relativeFilePath: relativeFilePath.endsWith(".instructions.md") ? relativeFilePath : relativeFilePath.replace(/\.md$/, ".instructions.md"),
|
|
19241
19240
|
frontmatter: result.data,
|
|
19242
19241
|
body: content.trim(),
|
|
@@ -19251,7 +19250,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
19251
19250
|
global = false
|
|
19252
19251
|
}) {
|
|
19253
19252
|
const paths = this.getSettablePaths({ global });
|
|
19254
|
-
const isRoot = relativeFilePath === paths.root.relativeFilePath;
|
|
19253
|
+
const isRoot = (0, import_node_path129.join)(relativeDirPath, relativeFilePath) === (0, import_node_path129.join)(paths.root.relativeDirPath, paths.root.relativeFilePath);
|
|
19255
19254
|
return new _CopilotRule({
|
|
19256
19255
|
baseDir,
|
|
19257
19256
|
relativeDirPath,
|
|
@@ -22206,7 +22205,239 @@ ${toonContent}`;
|
|
|
22206
22205
|
}
|
|
22207
22206
|
};
|
|
22208
22207
|
|
|
22208
|
+
// src/lib/convert.ts
|
|
22209
|
+
async function convertFromTool(params) {
|
|
22210
|
+
const ctx = params;
|
|
22211
|
+
const [
|
|
22212
|
+
rulesCount,
|
|
22213
|
+
ignoreCount,
|
|
22214
|
+
mcpCount,
|
|
22215
|
+
commandsCount,
|
|
22216
|
+
subagentsCount,
|
|
22217
|
+
skillsCount,
|
|
22218
|
+
hooksCount,
|
|
22219
|
+
permissionsCount
|
|
22220
|
+
] = [
|
|
22221
|
+
await runFeatureConvert(ctx, buildRulesStrategy(ctx)),
|
|
22222
|
+
await runFeatureConvert(ctx, buildIgnoreStrategy(ctx)),
|
|
22223
|
+
await runFeatureConvert(ctx, buildMcpStrategy(ctx)),
|
|
22224
|
+
await runFeatureConvert(ctx, buildCommandsStrategy(ctx)),
|
|
22225
|
+
await runFeatureConvert(ctx, buildSubagentsStrategy(ctx)),
|
|
22226
|
+
await runFeatureConvert(ctx, buildSkillsStrategy(ctx)),
|
|
22227
|
+
await runFeatureConvert(ctx, buildHooksStrategy(ctx)),
|
|
22228
|
+
await runFeatureConvert(ctx, buildPermissionsStrategy(ctx))
|
|
22229
|
+
];
|
|
22230
|
+
return {
|
|
22231
|
+
rulesCount,
|
|
22232
|
+
ignoreCount,
|
|
22233
|
+
mcpCount,
|
|
22234
|
+
commandsCount,
|
|
22235
|
+
subagentsCount,
|
|
22236
|
+
skillsCount,
|
|
22237
|
+
hooksCount,
|
|
22238
|
+
permissionsCount
|
|
22239
|
+
};
|
|
22240
|
+
}
|
|
22241
|
+
async function runFeatureConvert(ctx, strategy) {
|
|
22242
|
+
if (!strategy) return 0;
|
|
22243
|
+
const { config, fromTool, toTools, logger } = ctx;
|
|
22244
|
+
const {
|
|
22245
|
+
feature,
|
|
22246
|
+
itemLabel,
|
|
22247
|
+
allTargets,
|
|
22248
|
+
importableTargets = allTargets,
|
|
22249
|
+
createProcessor,
|
|
22250
|
+
loadSource,
|
|
22251
|
+
toRulesync,
|
|
22252
|
+
fromRulesync,
|
|
22253
|
+
write
|
|
22254
|
+
} = strategy;
|
|
22255
|
+
if (!config.getFeatures(fromTool).includes(feature)) {
|
|
22256
|
+
return 0;
|
|
22257
|
+
}
|
|
22258
|
+
if (!allTargets.includes(fromTool)) {
|
|
22259
|
+
logger.warn(`Source tool '${fromTool}' does not support feature '${feature}'. Skipping.`);
|
|
22260
|
+
return 0;
|
|
22261
|
+
}
|
|
22262
|
+
if (!importableTargets.includes(fromTool)) {
|
|
22263
|
+
logger.warn(`Conversion from ${fromTool} ${feature} is not supported. Skipping.`);
|
|
22264
|
+
return 0;
|
|
22265
|
+
}
|
|
22266
|
+
const sourceProcessor = createProcessor({ toolTarget: fromTool, dryRun: false });
|
|
22267
|
+
const sourceItems = await loadSource(sourceProcessor);
|
|
22268
|
+
if (sourceItems.length === 0) {
|
|
22269
|
+
logger.warn(`No ${feature} files found for ${fromTool}. Skipping ${feature} conversion.`);
|
|
22270
|
+
return 0;
|
|
22271
|
+
}
|
|
22272
|
+
const rulesyncItems = await toRulesync(sourceProcessor, sourceItems);
|
|
22273
|
+
let totalCount = 0;
|
|
22274
|
+
for (const toTool of toTools) {
|
|
22275
|
+
if (!allTargets.includes(toTool)) {
|
|
22276
|
+
logger.warn(`Destination tool '${toTool}' does not support feature '${feature}'. Skipping.`);
|
|
22277
|
+
continue;
|
|
22278
|
+
}
|
|
22279
|
+
const destProcessor = createProcessor({
|
|
22280
|
+
toolTarget: toTool,
|
|
22281
|
+
dryRun: config.isPreviewMode()
|
|
22282
|
+
});
|
|
22283
|
+
const destItems = await fromRulesync(destProcessor, rulesyncItems);
|
|
22284
|
+
const { count } = await write(destProcessor, destItems);
|
|
22285
|
+
totalCount += count;
|
|
22286
|
+
if (config.getVerbose() && count > 0) {
|
|
22287
|
+
const verb = config.isPreviewMode() ? "Would convert" : "Converted";
|
|
22288
|
+
logger.success(`${verb} ${count} ${itemLabel} for ${toTool}`);
|
|
22289
|
+
}
|
|
22290
|
+
}
|
|
22291
|
+
return totalCount;
|
|
22292
|
+
}
|
|
22293
|
+
function getBaseDir(config) {
|
|
22294
|
+
return config.getBaseDirs()[0] ?? ".";
|
|
22295
|
+
}
|
|
22296
|
+
function buildRulesStrategy(ctx) {
|
|
22297
|
+
const { config, logger } = ctx;
|
|
22298
|
+
const global = config.getGlobal();
|
|
22299
|
+
const baseDir = getBaseDir(config);
|
|
22300
|
+
const allTargets = RulesProcessor.getToolTargets({ global });
|
|
22301
|
+
return {
|
|
22302
|
+
feature: "rules",
|
|
22303
|
+
itemLabel: "rule file(s)",
|
|
22304
|
+
allTargets,
|
|
22305
|
+
createProcessor: ({ toolTarget, dryRun }) => new RulesProcessor({ baseDir, toolTarget, global, dryRun, logger }),
|
|
22306
|
+
loadSource: (p) => p.loadToolFiles(),
|
|
22307
|
+
toRulesync: (p, files) => p.convertToolFilesToRulesyncFiles(files),
|
|
22308
|
+
fromRulesync: (p, files) => p.convertRulesyncFilesToToolFiles(files),
|
|
22309
|
+
write: (p, files) => p.writeAiFiles(files)
|
|
22310
|
+
};
|
|
22311
|
+
}
|
|
22312
|
+
function buildIgnoreStrategy(ctx) {
|
|
22313
|
+
const { config, logger } = ctx;
|
|
22314
|
+
if (config.getGlobal()) {
|
|
22315
|
+
logger.debug("Skipping ignore conversion (not supported in global mode)");
|
|
22316
|
+
return null;
|
|
22317
|
+
}
|
|
22318
|
+
const baseDir = getBaseDir(config);
|
|
22319
|
+
const allTargets = IgnoreProcessor.getToolTargets();
|
|
22320
|
+
return {
|
|
22321
|
+
feature: "ignore",
|
|
22322
|
+
itemLabel: "ignore file(s)",
|
|
22323
|
+
allTargets,
|
|
22324
|
+
createProcessor: ({ toolTarget, dryRun }) => new IgnoreProcessor({
|
|
22325
|
+
baseDir,
|
|
22326
|
+
toolTarget,
|
|
22327
|
+
dryRun,
|
|
22328
|
+
logger,
|
|
22329
|
+
featureOptions: config.getFeatureOptions(toolTarget, "ignore")
|
|
22330
|
+
}),
|
|
22331
|
+
loadSource: (p) => p.loadToolFiles(),
|
|
22332
|
+
toRulesync: (p, files) => p.convertToolFilesToRulesyncFiles(files),
|
|
22333
|
+
fromRulesync: (p, files) => p.convertRulesyncFilesToToolFiles(files),
|
|
22334
|
+
write: (p, files) => p.writeAiFiles(files)
|
|
22335
|
+
};
|
|
22336
|
+
}
|
|
22337
|
+
function buildMcpStrategy(ctx) {
|
|
22338
|
+
const { config, logger } = ctx;
|
|
22339
|
+
const global = config.getGlobal();
|
|
22340
|
+
const baseDir = getBaseDir(config);
|
|
22341
|
+
const allTargets = McpProcessor.getToolTargets({ global });
|
|
22342
|
+
return {
|
|
22343
|
+
feature: "mcp",
|
|
22344
|
+
itemLabel: "MCP file(s)",
|
|
22345
|
+
allTargets,
|
|
22346
|
+
createProcessor: ({ toolTarget, dryRun }) => new McpProcessor({ baseDir, toolTarget, global, dryRun, logger }),
|
|
22347
|
+
loadSource: (p) => p.loadToolFiles(),
|
|
22348
|
+
toRulesync: (p, files) => p.convertToolFilesToRulesyncFiles(files),
|
|
22349
|
+
fromRulesync: (p, files) => p.convertRulesyncFilesToToolFiles(files),
|
|
22350
|
+
write: (p, files) => p.writeAiFiles(files)
|
|
22351
|
+
};
|
|
22352
|
+
}
|
|
22353
|
+
function buildCommandsStrategy(ctx) {
|
|
22354
|
+
const { config, logger } = ctx;
|
|
22355
|
+
const global = config.getGlobal();
|
|
22356
|
+
const baseDir = getBaseDir(config);
|
|
22357
|
+
const allTargets = CommandsProcessor.getToolTargets({ global, includeSimulated: false });
|
|
22358
|
+
return {
|
|
22359
|
+
feature: "commands",
|
|
22360
|
+
itemLabel: "command file(s)",
|
|
22361
|
+
allTargets,
|
|
22362
|
+
createProcessor: ({ toolTarget, dryRun }) => new CommandsProcessor({ baseDir, toolTarget, global, dryRun, logger }),
|
|
22363
|
+
loadSource: (p) => p.loadToolFiles(),
|
|
22364
|
+
toRulesync: (p, files) => p.convertToolFilesToRulesyncFiles(files),
|
|
22365
|
+
fromRulesync: (p, files) => p.convertRulesyncFilesToToolFiles(files),
|
|
22366
|
+
write: (p, files) => p.writeAiFiles(files)
|
|
22367
|
+
};
|
|
22368
|
+
}
|
|
22369
|
+
function buildSubagentsStrategy(ctx) {
|
|
22370
|
+
const { config, logger } = ctx;
|
|
22371
|
+
const global = config.getGlobal();
|
|
22372
|
+
const baseDir = getBaseDir(config);
|
|
22373
|
+
const allTargets = SubagentsProcessor.getToolTargets({ global, includeSimulated: false });
|
|
22374
|
+
return {
|
|
22375
|
+
feature: "subagents",
|
|
22376
|
+
itemLabel: "subagent file(s)",
|
|
22377
|
+
allTargets,
|
|
22378
|
+
createProcessor: ({ toolTarget, dryRun }) => new SubagentsProcessor({ baseDir, toolTarget, global, dryRun, logger }),
|
|
22379
|
+
loadSource: (p) => p.loadToolFiles(),
|
|
22380
|
+
toRulesync: (p, files) => p.convertToolFilesToRulesyncFiles(files),
|
|
22381
|
+
fromRulesync: (p, files) => p.convertRulesyncFilesToToolFiles(files),
|
|
22382
|
+
write: (p, files) => p.writeAiFiles(files)
|
|
22383
|
+
};
|
|
22384
|
+
}
|
|
22385
|
+
function buildSkillsStrategy(ctx) {
|
|
22386
|
+
const { config, logger } = ctx;
|
|
22387
|
+
const global = config.getGlobal();
|
|
22388
|
+
const baseDir = getBaseDir(config);
|
|
22389
|
+
const allTargets = SkillsProcessor.getToolTargets({ global });
|
|
22390
|
+
return {
|
|
22391
|
+
feature: "skills",
|
|
22392
|
+
itemLabel: "skill(s)",
|
|
22393
|
+
allTargets,
|
|
22394
|
+
createProcessor: ({ toolTarget, dryRun }) => new SkillsProcessor({ baseDir, toolTarget, global, dryRun, logger }),
|
|
22395
|
+
loadSource: (p) => p.loadToolDirs(),
|
|
22396
|
+
toRulesync: (p, dirs) => p.convertToolDirsToRulesyncDirs(dirs),
|
|
22397
|
+
fromRulesync: (p, dirs) => p.convertRulesyncDirsToToolDirs(dirs),
|
|
22398
|
+
write: (p, dirs) => p.writeAiDirs(dirs)
|
|
22399
|
+
};
|
|
22400
|
+
}
|
|
22401
|
+
function buildHooksStrategy(ctx) {
|
|
22402
|
+
const { config, logger } = ctx;
|
|
22403
|
+
const global = config.getGlobal();
|
|
22404
|
+
const baseDir = getBaseDir(config);
|
|
22405
|
+
const allTargets = HooksProcessor.getToolTargets({ global });
|
|
22406
|
+
const importableTargets = HooksProcessor.getToolTargets({ global, importOnly: true });
|
|
22407
|
+
return {
|
|
22408
|
+
feature: "hooks",
|
|
22409
|
+
itemLabel: "hooks file(s)",
|
|
22410
|
+
allTargets,
|
|
22411
|
+
importableTargets,
|
|
22412
|
+
createProcessor: ({ toolTarget, dryRun }) => new HooksProcessor({ baseDir, toolTarget, global, dryRun, logger }),
|
|
22413
|
+
loadSource: (p) => p.loadToolFiles(),
|
|
22414
|
+
toRulesync: (p, files) => p.convertToolFilesToRulesyncFiles(files),
|
|
22415
|
+
fromRulesync: (p, files) => p.convertRulesyncFilesToToolFiles(files),
|
|
22416
|
+
write: (p, files) => p.writeAiFiles(files)
|
|
22417
|
+
};
|
|
22418
|
+
}
|
|
22419
|
+
function buildPermissionsStrategy(ctx) {
|
|
22420
|
+
const { config, logger } = ctx;
|
|
22421
|
+
const global = config.getGlobal();
|
|
22422
|
+
const baseDir = getBaseDir(config);
|
|
22423
|
+
const allTargets = PermissionsProcessor.getToolTargets({ global });
|
|
22424
|
+
const importableTargets = PermissionsProcessor.getToolTargets({ global, importOnly: true });
|
|
22425
|
+
return {
|
|
22426
|
+
feature: "permissions",
|
|
22427
|
+
itemLabel: "permissions file(s)",
|
|
22428
|
+
allTargets,
|
|
22429
|
+
importableTargets,
|
|
22430
|
+
createProcessor: ({ toolTarget, dryRun }) => new PermissionsProcessor({ baseDir, toolTarget, global, dryRun, logger }),
|
|
22431
|
+
loadSource: (p) => p.loadToolFiles(),
|
|
22432
|
+
toRulesync: (p, files) => p.convertToolFilesToRulesyncFiles(files),
|
|
22433
|
+
fromRulesync: (p, files) => p.convertRulesyncFilesToToolFiles(files),
|
|
22434
|
+
write: (p, files) => p.writeAiFiles(files)
|
|
22435
|
+
};
|
|
22436
|
+
}
|
|
22437
|
+
|
|
22209
22438
|
// src/lib/generate.ts
|
|
22439
|
+
var import_node_path148 = require("path");
|
|
22440
|
+
var import_es_toolkit5 = require("es-toolkit");
|
|
22210
22441
|
async function processFeatureGeneration(params) {
|
|
22211
22442
|
const { config, processor, toolFiles } = params;
|
|
22212
22443
|
let totalCount = 0;
|
|
@@ -22922,10 +23153,35 @@ async function importFromTool2(options) {
|
|
|
22922
23153
|
});
|
|
22923
23154
|
return importFromTool({ config, tool: target, logger });
|
|
22924
23155
|
}
|
|
23156
|
+
async function convertFromTool2(options) {
|
|
23157
|
+
const { from, to, features, silent = true, verbose = false, ...rest } = options;
|
|
23158
|
+
if (!from) {
|
|
23159
|
+
throw new Error("from is required. Please specify a source tool to convert from.");
|
|
23160
|
+
}
|
|
23161
|
+
if (!to || to.length === 0) {
|
|
23162
|
+
throw new Error("to is required and must not be empty. Please specify destination tools.");
|
|
23163
|
+
}
|
|
23164
|
+
const toTools = Array.from(new Set(to));
|
|
23165
|
+
if (toTools.includes(from)) {
|
|
23166
|
+
throw new Error(
|
|
23167
|
+
`Destination tools must not include the source tool '${from}'. Converting a tool onto itself is likely a mistake and may cause lossy round-trips.`
|
|
23168
|
+
);
|
|
23169
|
+
}
|
|
23170
|
+
const logger = new ConsoleLogger({ verbose, silent });
|
|
23171
|
+
const config = await ConfigResolver.resolve({
|
|
23172
|
+
...rest,
|
|
23173
|
+
targets: [from],
|
|
23174
|
+
features: features ?? ["*"],
|
|
23175
|
+
verbose,
|
|
23176
|
+
silent
|
|
23177
|
+
});
|
|
23178
|
+
return convertFromTool({ config, fromTool: from, toTools, logger });
|
|
23179
|
+
}
|
|
22925
23180
|
// Annotate the CommonJS export names for ESM import in node:
|
|
22926
23181
|
0 && (module.exports = {
|
|
22927
23182
|
ALL_FEATURES,
|
|
22928
23183
|
ALL_TOOL_TARGETS,
|
|
23184
|
+
convertFromTool,
|
|
22929
23185
|
generate,
|
|
22930
23186
|
importFromTool
|
|
22931
23187
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -47,6 +47,17 @@ declare const FeatureSchema: z.ZodMiniEnum<{
|
|
|
47
47
|
}>;
|
|
48
48
|
type Feature = z.infer<typeof FeatureSchema>;
|
|
49
49
|
|
|
50
|
+
type ConvertResult = {
|
|
51
|
+
rulesCount: number;
|
|
52
|
+
ignoreCount: number;
|
|
53
|
+
mcpCount: number;
|
|
54
|
+
commandsCount: number;
|
|
55
|
+
subagentsCount: number;
|
|
56
|
+
skillsCount: number;
|
|
57
|
+
hooksCount: number;
|
|
58
|
+
permissionsCount: number;
|
|
59
|
+
};
|
|
60
|
+
|
|
50
61
|
type ValidationResult = {
|
|
51
62
|
success: true;
|
|
52
63
|
error: undefined | null;
|
|
@@ -309,7 +320,14 @@ type ImportOptions = BaseOptions & {
|
|
|
309
320
|
target: ToolTarget;
|
|
310
321
|
features?: Feature[];
|
|
311
322
|
};
|
|
323
|
+
type ConvertOptions = BaseOptions & {
|
|
324
|
+
from: ToolTarget;
|
|
325
|
+
to: ToolTarget[];
|
|
326
|
+
features?: Feature[];
|
|
327
|
+
dryRun?: boolean;
|
|
328
|
+
};
|
|
312
329
|
declare function generate(options?: GenerateOptions): Promise<GenerateResult>;
|
|
313
330
|
declare function importFromTool(options: ImportOptions): Promise<ImportResult>;
|
|
331
|
+
declare function convertFromTool(options: ConvertOptions): Promise<ConvertResult>;
|
|
314
332
|
|
|
315
|
-
export { ALL_FEATURES, ALL_TOOL_TARGETS, type Feature, type GenerateOptions, type GenerateResult, type ImportOptions, type ImportResult, type ToolTarget, generate, importFromTool };
|
|
333
|
+
export { ALL_FEATURES, ALL_TOOL_TARGETS, type ConvertOptions, type ConvertResult, type Feature, type GenerateOptions, type GenerateResult, type ImportOptions, type ImportResult, type ToolTarget, convertFromTool, generate, importFromTool };
|
package/dist/index.d.ts
CHANGED
|
@@ -47,6 +47,17 @@ declare const FeatureSchema: z.ZodMiniEnum<{
|
|
|
47
47
|
}>;
|
|
48
48
|
type Feature = z.infer<typeof FeatureSchema>;
|
|
49
49
|
|
|
50
|
+
type ConvertResult = {
|
|
51
|
+
rulesCount: number;
|
|
52
|
+
ignoreCount: number;
|
|
53
|
+
mcpCount: number;
|
|
54
|
+
commandsCount: number;
|
|
55
|
+
subagentsCount: number;
|
|
56
|
+
skillsCount: number;
|
|
57
|
+
hooksCount: number;
|
|
58
|
+
permissionsCount: number;
|
|
59
|
+
};
|
|
60
|
+
|
|
50
61
|
type ValidationResult = {
|
|
51
62
|
success: true;
|
|
52
63
|
error: undefined | null;
|
|
@@ -309,7 +320,14 @@ type ImportOptions = BaseOptions & {
|
|
|
309
320
|
target: ToolTarget;
|
|
310
321
|
features?: Feature[];
|
|
311
322
|
};
|
|
323
|
+
type ConvertOptions = BaseOptions & {
|
|
324
|
+
from: ToolTarget;
|
|
325
|
+
to: ToolTarget[];
|
|
326
|
+
features?: Feature[];
|
|
327
|
+
dryRun?: boolean;
|
|
328
|
+
};
|
|
312
329
|
declare function generate(options?: GenerateOptions): Promise<GenerateResult>;
|
|
313
330
|
declare function importFromTool(options: ImportOptions): Promise<ImportResult>;
|
|
331
|
+
declare function convertFromTool(options: ConvertOptions): Promise<ConvertResult>;
|
|
314
332
|
|
|
315
|
-
export { ALL_FEATURES, ALL_TOOL_TARGETS, type Feature, type GenerateOptions, type GenerateResult, type ImportOptions, type ImportResult, type ToolTarget, generate, importFromTool };
|
|
333
|
+
export { ALL_FEATURES, ALL_TOOL_TARGETS, type ConvertOptions, type ConvertResult, type Feature, type GenerateOptions, type GenerateResult, type ImportOptions, type ImportResult, type ToolTarget, convertFromTool, generate, importFromTool };
|
package/dist/index.js
CHANGED
|
@@ -4,9 +4,10 @@ import {
|
|
|
4
4
|
ConfigResolver,
|
|
5
5
|
ConsoleLogger,
|
|
6
6
|
checkRulesyncDirExists,
|
|
7
|
+
convertFromTool,
|
|
7
8
|
generate,
|
|
8
9
|
importFromTool
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-643VJ2QM.js";
|
|
10
11
|
|
|
11
12
|
// src/index.ts
|
|
12
13
|
async function generate2(options = {}) {
|
|
@@ -36,9 +37,34 @@ async function importFromTool2(options) {
|
|
|
36
37
|
});
|
|
37
38
|
return importFromTool({ config, tool: target, logger });
|
|
38
39
|
}
|
|
40
|
+
async function convertFromTool2(options) {
|
|
41
|
+
const { from, to, features, silent = true, verbose = false, ...rest } = options;
|
|
42
|
+
if (!from) {
|
|
43
|
+
throw new Error("from is required. Please specify a source tool to convert from.");
|
|
44
|
+
}
|
|
45
|
+
if (!to || to.length === 0) {
|
|
46
|
+
throw new Error("to is required and must not be empty. Please specify destination tools.");
|
|
47
|
+
}
|
|
48
|
+
const toTools = Array.from(new Set(to));
|
|
49
|
+
if (toTools.includes(from)) {
|
|
50
|
+
throw new Error(
|
|
51
|
+
`Destination tools must not include the source tool '${from}'. Converting a tool onto itself is likely a mistake and may cause lossy round-trips.`
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
const logger = new ConsoleLogger({ verbose, silent });
|
|
55
|
+
const config = await ConfigResolver.resolve({
|
|
56
|
+
...rest,
|
|
57
|
+
targets: [from],
|
|
58
|
+
features: features ?? ["*"],
|
|
59
|
+
verbose,
|
|
60
|
+
silent
|
|
61
|
+
});
|
|
62
|
+
return convertFromTool({ config, fromTool: from, toTools, logger });
|
|
63
|
+
}
|
|
39
64
|
export {
|
|
40
65
|
ALL_FEATURES,
|
|
41
66
|
ALL_TOOL_TARGETS,
|
|
67
|
+
convertFromTool2 as convertFromTool,
|
|
42
68
|
generate2 as generate,
|
|
43
69
|
importFromTool2 as importFromTool
|
|
44
70
|
};
|