rulesync 8.10.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.
@@ -1039,10 +1039,6 @@ var JsonLogger = class extends BaseLogger {
1039
1039
  }
1040
1040
  };
1041
1041
 
1042
- // src/lib/generate.ts
1043
- import { join as join145 } from "path";
1044
- import { intersection } from "es-toolkit";
1045
-
1046
1042
  // src/features/commands/commands-processor.ts
1047
1043
  import { basename as basename2, join as join22, relative as relative3 } from "path";
1048
1044
  import { z as z16 } from "zod/mini";
@@ -19229,9 +19225,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
19229
19225
  }
19230
19226
  toRulesyncRule() {
19231
19227
  let globs;
19232
- if (this.isRoot()) {
19233
- globs = ["**/*"];
19234
- } else if (this.frontmatter.applyTo) {
19228
+ if (this.frontmatter.applyTo) {
19235
19229
  globs = this.frontmatter.applyTo.split(",").map((g) => g.trim());
19236
19230
  }
19237
19231
  const rulesyncFrontmatter = {
@@ -22301,7 +22295,239 @@ ${toonContent}`;
22301
22295
  }
22302
22296
  };
22303
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
+
22304
22528
  // src/lib/generate.ts
22529
+ import { join as join145 } from "path";
22530
+ import { intersection } from "es-toolkit";
22305
22531
  async function processFeatureGeneration(params) {
22306
22532
  const { config, processor, toolFiles } = params;
22307
22533
  let totalCount = 0;
@@ -23054,7 +23280,6 @@ export {
23054
23280
  CLIError,
23055
23281
  ConsoleLogger,
23056
23282
  JsonLogger,
23057
- PermissionsProcessor,
23058
23283
  SKILL_FILE_NAME,
23059
23284
  RulesyncSkillFrontmatterSchema,
23060
23285
  RulesyncSkill,
@@ -23066,6 +23291,7 @@ export {
23066
23291
  RulesyncRuleFrontmatterSchema,
23067
23292
  RulesyncRule,
23068
23293
  RulesProcessor,
23294
+ convertFromTool,
23069
23295
  checkRulesyncDirExists,
23070
23296
  generate,
23071
23297
  importFromTool