rulesync 8.9.0 → 8.11.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/README.md CHANGED
@@ -58,6 +58,14 @@ rulesync import --targets cursor # From .cursorrules
58
58
  rulesync import --targets copilot # From .github/copilot-instructions.md
59
59
  ```
60
60
 
61
+ Want to convert configuration from one AI tool to another directly, without
62
+ adopting the `.rulesync/` source-of-truth workflow?
63
+
64
+ ```bash
65
+ # Convert Cursor rules to Copilot and Claude Code in one shot (no .rulesync/ files written)
66
+ rulesync convert --from cursor --to copilot,claudecode
67
+ ```
68
+
61
69
  See [Quick Start guide](https://dyoshikawa.github.io/rulesync/getting-started/quick-start) for more details.
62
70
 
63
71
  ## Supported Tools and Features
@@ -878,6 +878,7 @@ var ErrorCodes = {
878
878
  VALIDATION_FAILED: "VALIDATION_FAILED",
879
879
  GENERATION_FAILED: "GENERATION_FAILED",
880
880
  IMPORT_FAILED: "IMPORT_FAILED",
881
+ CONVERT_FAILED: "CONVERT_FAILED",
881
882
  INSTALL_FAILED: "INSTALL_FAILED",
882
883
  UPDATE_FAILED: "UPDATE_FAILED",
883
884
  GITIGNORE_FAILED: "GITIGNORE_FAILED",
@@ -1038,10 +1039,6 @@ var JsonLogger = class extends BaseLogger {
1038
1039
  }
1039
1040
  };
1040
1041
 
1041
- // src/lib/generate.ts
1042
- import { join as join145 } from "path";
1043
- import { intersection } from "es-toolkit";
1044
-
1045
1042
  // src/features/commands/commands-processor.ts
1046
1043
  import { basename as basename2, join as join22, relative as relative3 } from "path";
1047
1044
  import { z as z16 } from "zod/mini";
@@ -19228,9 +19225,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
19228
19225
  }
19229
19226
  toRulesyncRule() {
19230
19227
  let globs;
19231
- if (this.isRoot()) {
19232
- globs = ["**/*"];
19233
- } else if (this.frontmatter.applyTo) {
19228
+ if (this.frontmatter.applyTo) {
19234
19229
  globs = this.frontmatter.applyTo.split(",").map((g) => g.trim());
19235
19230
  }
19236
19231
  const rulesyncFrontmatter = {
@@ -22300,7 +22295,239 @@ ${toonContent}`;
22300
22295
  }
22301
22296
  };
22302
22297
 
22298
+ // src/lib/convert.ts
22299
+ async function convertFromTool(params) {
22300
+ const ctx = params;
22301
+ const [
22302
+ rulesCount,
22303
+ ignoreCount,
22304
+ mcpCount,
22305
+ commandsCount,
22306
+ subagentsCount,
22307
+ skillsCount,
22308
+ hooksCount,
22309
+ permissionsCount
22310
+ ] = [
22311
+ await runFeatureConvert(ctx, buildRulesStrategy(ctx)),
22312
+ await runFeatureConvert(ctx, buildIgnoreStrategy(ctx)),
22313
+ await runFeatureConvert(ctx, buildMcpStrategy(ctx)),
22314
+ await runFeatureConvert(ctx, buildCommandsStrategy(ctx)),
22315
+ await runFeatureConvert(ctx, buildSubagentsStrategy(ctx)),
22316
+ await runFeatureConvert(ctx, buildSkillsStrategy(ctx)),
22317
+ await runFeatureConvert(ctx, buildHooksStrategy(ctx)),
22318
+ await runFeatureConvert(ctx, buildPermissionsStrategy(ctx))
22319
+ ];
22320
+ return {
22321
+ rulesCount,
22322
+ ignoreCount,
22323
+ mcpCount,
22324
+ commandsCount,
22325
+ subagentsCount,
22326
+ skillsCount,
22327
+ hooksCount,
22328
+ permissionsCount
22329
+ };
22330
+ }
22331
+ async function runFeatureConvert(ctx, strategy) {
22332
+ if (!strategy) return 0;
22333
+ const { config, fromTool, toTools, logger } = ctx;
22334
+ const {
22335
+ feature,
22336
+ itemLabel,
22337
+ allTargets,
22338
+ importableTargets = allTargets,
22339
+ createProcessor,
22340
+ loadSource,
22341
+ toRulesync,
22342
+ fromRulesync,
22343
+ write
22344
+ } = strategy;
22345
+ if (!config.getFeatures(fromTool).includes(feature)) {
22346
+ return 0;
22347
+ }
22348
+ if (!allTargets.includes(fromTool)) {
22349
+ logger.warn(`Source tool '${fromTool}' does not support feature '${feature}'. Skipping.`);
22350
+ return 0;
22351
+ }
22352
+ if (!importableTargets.includes(fromTool)) {
22353
+ logger.warn(`Conversion from ${fromTool} ${feature} is not supported. Skipping.`);
22354
+ return 0;
22355
+ }
22356
+ const sourceProcessor = createProcessor({ toolTarget: fromTool, dryRun: false });
22357
+ const sourceItems = await loadSource(sourceProcessor);
22358
+ if (sourceItems.length === 0) {
22359
+ logger.warn(`No ${feature} files found for ${fromTool}. Skipping ${feature} conversion.`);
22360
+ return 0;
22361
+ }
22362
+ const rulesyncItems = await toRulesync(sourceProcessor, sourceItems);
22363
+ let totalCount = 0;
22364
+ for (const toTool of toTools) {
22365
+ if (!allTargets.includes(toTool)) {
22366
+ logger.warn(`Destination tool '${toTool}' does not support feature '${feature}'. Skipping.`);
22367
+ continue;
22368
+ }
22369
+ const destProcessor = createProcessor({
22370
+ toolTarget: toTool,
22371
+ dryRun: config.isPreviewMode()
22372
+ });
22373
+ const destItems = await fromRulesync(destProcessor, rulesyncItems);
22374
+ const { count } = await write(destProcessor, destItems);
22375
+ totalCount += count;
22376
+ if (config.getVerbose() && count > 0) {
22377
+ const verb = config.isPreviewMode() ? "Would convert" : "Converted";
22378
+ logger.success(`${verb} ${count} ${itemLabel} for ${toTool}`);
22379
+ }
22380
+ }
22381
+ return totalCount;
22382
+ }
22383
+ function getBaseDir(config) {
22384
+ return config.getBaseDirs()[0] ?? ".";
22385
+ }
22386
+ function buildRulesStrategy(ctx) {
22387
+ const { config, logger } = ctx;
22388
+ const global = config.getGlobal();
22389
+ const baseDir = getBaseDir(config);
22390
+ const allTargets = RulesProcessor.getToolTargets({ global });
22391
+ return {
22392
+ feature: "rules",
22393
+ itemLabel: "rule file(s)",
22394
+ allTargets,
22395
+ createProcessor: ({ toolTarget, dryRun }) => new RulesProcessor({ baseDir, toolTarget, global, dryRun, logger }),
22396
+ loadSource: (p) => p.loadToolFiles(),
22397
+ toRulesync: (p, files) => p.convertToolFilesToRulesyncFiles(files),
22398
+ fromRulesync: (p, files) => p.convertRulesyncFilesToToolFiles(files),
22399
+ write: (p, files) => p.writeAiFiles(files)
22400
+ };
22401
+ }
22402
+ function buildIgnoreStrategy(ctx) {
22403
+ const { config, logger } = ctx;
22404
+ if (config.getGlobal()) {
22405
+ logger.debug("Skipping ignore conversion (not supported in global mode)");
22406
+ return null;
22407
+ }
22408
+ const baseDir = getBaseDir(config);
22409
+ const allTargets = IgnoreProcessor.getToolTargets();
22410
+ return {
22411
+ feature: "ignore",
22412
+ itemLabel: "ignore file(s)",
22413
+ allTargets,
22414
+ createProcessor: ({ toolTarget, dryRun }) => new IgnoreProcessor({
22415
+ baseDir,
22416
+ toolTarget,
22417
+ dryRun,
22418
+ logger,
22419
+ featureOptions: config.getFeatureOptions(toolTarget, "ignore")
22420
+ }),
22421
+ loadSource: (p) => p.loadToolFiles(),
22422
+ toRulesync: (p, files) => p.convertToolFilesToRulesyncFiles(files),
22423
+ fromRulesync: (p, files) => p.convertRulesyncFilesToToolFiles(files),
22424
+ write: (p, files) => p.writeAiFiles(files)
22425
+ };
22426
+ }
22427
+ function buildMcpStrategy(ctx) {
22428
+ const { config, logger } = ctx;
22429
+ const global = config.getGlobal();
22430
+ const baseDir = getBaseDir(config);
22431
+ const allTargets = McpProcessor.getToolTargets({ global });
22432
+ return {
22433
+ feature: "mcp",
22434
+ itemLabel: "MCP file(s)",
22435
+ allTargets,
22436
+ createProcessor: ({ toolTarget, dryRun }) => new McpProcessor({ baseDir, toolTarget, global, dryRun, logger }),
22437
+ loadSource: (p) => p.loadToolFiles(),
22438
+ toRulesync: (p, files) => p.convertToolFilesToRulesyncFiles(files),
22439
+ fromRulesync: (p, files) => p.convertRulesyncFilesToToolFiles(files),
22440
+ write: (p, files) => p.writeAiFiles(files)
22441
+ };
22442
+ }
22443
+ function buildCommandsStrategy(ctx) {
22444
+ const { config, logger } = ctx;
22445
+ const global = config.getGlobal();
22446
+ const baseDir = getBaseDir(config);
22447
+ const allTargets = CommandsProcessor.getToolTargets({ global, includeSimulated: false });
22448
+ return {
22449
+ feature: "commands",
22450
+ itemLabel: "command file(s)",
22451
+ allTargets,
22452
+ createProcessor: ({ toolTarget, dryRun }) => new CommandsProcessor({ baseDir, toolTarget, global, dryRun, logger }),
22453
+ loadSource: (p) => p.loadToolFiles(),
22454
+ toRulesync: (p, files) => p.convertToolFilesToRulesyncFiles(files),
22455
+ fromRulesync: (p, files) => p.convertRulesyncFilesToToolFiles(files),
22456
+ write: (p, files) => p.writeAiFiles(files)
22457
+ };
22458
+ }
22459
+ function buildSubagentsStrategy(ctx) {
22460
+ const { config, logger } = ctx;
22461
+ const global = config.getGlobal();
22462
+ const baseDir = getBaseDir(config);
22463
+ const allTargets = SubagentsProcessor.getToolTargets({ global, includeSimulated: false });
22464
+ return {
22465
+ feature: "subagents",
22466
+ itemLabel: "subagent file(s)",
22467
+ allTargets,
22468
+ createProcessor: ({ toolTarget, dryRun }) => new SubagentsProcessor({ baseDir, toolTarget, global, dryRun, logger }),
22469
+ loadSource: (p) => p.loadToolFiles(),
22470
+ toRulesync: (p, files) => p.convertToolFilesToRulesyncFiles(files),
22471
+ fromRulesync: (p, files) => p.convertRulesyncFilesToToolFiles(files),
22472
+ write: (p, files) => p.writeAiFiles(files)
22473
+ };
22474
+ }
22475
+ function buildSkillsStrategy(ctx) {
22476
+ const { config, logger } = ctx;
22477
+ const global = config.getGlobal();
22478
+ const baseDir = getBaseDir(config);
22479
+ const allTargets = SkillsProcessor.getToolTargets({ global });
22480
+ return {
22481
+ feature: "skills",
22482
+ itemLabel: "skill(s)",
22483
+ allTargets,
22484
+ createProcessor: ({ toolTarget, dryRun }) => new SkillsProcessor({ baseDir, toolTarget, global, dryRun, logger }),
22485
+ loadSource: (p) => p.loadToolDirs(),
22486
+ toRulesync: (p, dirs) => p.convertToolDirsToRulesyncDirs(dirs),
22487
+ fromRulesync: (p, dirs) => p.convertRulesyncDirsToToolDirs(dirs),
22488
+ write: (p, dirs) => p.writeAiDirs(dirs)
22489
+ };
22490
+ }
22491
+ function buildHooksStrategy(ctx) {
22492
+ const { config, logger } = ctx;
22493
+ const global = config.getGlobal();
22494
+ const baseDir = getBaseDir(config);
22495
+ const allTargets = HooksProcessor.getToolTargets({ global });
22496
+ const importableTargets = HooksProcessor.getToolTargets({ global, importOnly: true });
22497
+ return {
22498
+ feature: "hooks",
22499
+ itemLabel: "hooks file(s)",
22500
+ allTargets,
22501
+ importableTargets,
22502
+ createProcessor: ({ toolTarget, dryRun }) => new HooksProcessor({ baseDir, toolTarget, global, dryRun, logger }),
22503
+ loadSource: (p) => p.loadToolFiles(),
22504
+ toRulesync: (p, files) => p.convertToolFilesToRulesyncFiles(files),
22505
+ fromRulesync: (p, files) => p.convertRulesyncFilesToToolFiles(files),
22506
+ write: (p, files) => p.writeAiFiles(files)
22507
+ };
22508
+ }
22509
+ function buildPermissionsStrategy(ctx) {
22510
+ const { config, logger } = ctx;
22511
+ const global = config.getGlobal();
22512
+ const baseDir = getBaseDir(config);
22513
+ const allTargets = PermissionsProcessor.getToolTargets({ global });
22514
+ const importableTargets = PermissionsProcessor.getToolTargets({ global, importOnly: true });
22515
+ return {
22516
+ feature: "permissions",
22517
+ itemLabel: "permissions file(s)",
22518
+ allTargets,
22519
+ importableTargets,
22520
+ createProcessor: ({ toolTarget, dryRun }) => new PermissionsProcessor({ baseDir, toolTarget, global, dryRun, logger }),
22521
+ loadSource: (p) => p.loadToolFiles(),
22522
+ toRulesync: (p, files) => p.convertToolFilesToRulesyncFiles(files),
22523
+ fromRulesync: (p, files) => p.convertRulesyncFilesToToolFiles(files),
22524
+ write: (p, files) => p.writeAiFiles(files)
22525
+ };
22526
+ }
22527
+
22303
22528
  // src/lib/generate.ts
22529
+ import { join as join145 } from "path";
22530
+ import { intersection } from "es-toolkit";
22304
22531
  async function processFeatureGeneration(params) {
22305
22532
  const { config, processor, toolFiles } = params;
22306
22533
  let totalCount = 0;
@@ -23034,6 +23261,7 @@ export {
23034
23261
  isFeatureValueEnabled,
23035
23262
  ALL_TOOL_TARGETS,
23036
23263
  ALL_TOOL_TARGETS_WITH_WILDCARD,
23264
+ ToolTargetSchema,
23037
23265
  findControlCharacter,
23038
23266
  GITIGNORE_DESTINATION_KEY,
23039
23267
  ConfigResolver,
@@ -23063,6 +23291,7 @@ export {
23063
23291
  RulesyncRuleFrontmatterSchema,
23064
23292
  RulesyncRule,
23065
23293
  RulesProcessor,
23294
+ convertFromTool,
23066
23295
  checkRulesyncDirExists,
23067
23296
  generate,
23068
23297
  importFromTool