rulesync 9.4.0 → 9.5.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.
@@ -852,7 +852,7 @@ const SourceEntrySchema = z.object({
852
852
  scope: optional(z.enum(["project", "user"]))
853
853
  });
854
854
  const ConfigParamsSchema = z.object({
855
- outputRoots: z.array(z.string()),
855
+ outputRoots: z.union([z.array(z.string()), z.record(z.string(), z.union([z.string(), z.array(z.string())]))]),
856
856
  targets: RulesyncConfigTargetsSchema,
857
857
  features: RulesyncFeaturesSchema,
858
858
  verbose: z.boolean(),
@@ -957,6 +957,7 @@ var Config = class Config {
957
957
  const resolvedTargets = targets ?? [];
958
958
  const resolvedFeatures = features ?? [];
959
959
  this.validateObjectFormTargetKeys(resolvedTargets);
960
+ this.validateObjectFormOutputRootKeys(outputRoots);
960
961
  this.validateConflictingTargets(resolvedTargets);
961
962
  if (dryRun && check) throw new Error("--dry-run and --check cannot be used together");
962
963
  this.outputRoots = outputRoots;
@@ -994,6 +995,11 @@ var Config = class Config {
994
995
  if (!validTargets.has(key)) throw new Error(`Unknown target '${key}'. Valid targets: ${ALL_TOOL_TARGETS.join(", ")}.`);
995
996
  }
996
997
  }
998
+ validateObjectFormOutputRootKeys(outputRoots) {
999
+ if (Array.isArray(outputRoots)) return;
1000
+ const validTargets = new Set(ALL_TOOL_TARGETS);
1001
+ for (const key of Object.keys(outputRoots)) if (!validTargets.has(key)) throw new Error(`Unknown outputRoots target '${key}'. Valid targets: ${ALL_TOOL_TARGETS.join(", ")}.`);
1002
+ }
997
1003
  validateConflictingTargets(targets) {
998
1004
  const has = (target) => {
999
1005
  if (Array.isArray(targets)) return targets.includes(target);
@@ -1001,8 +1007,19 @@ var Config = class Config {
1001
1007
  };
1002
1008
  for (const [target1, target2] of CONFLICTING_TARGET_PAIRS) if (has(target1) && has(target2)) throw new Error(`Conflicting targets: '${target1}' and '${target2}' cannot be used together. Please choose one.`);
1003
1009
  }
1004
- getOutputRoots() {
1005
- return this.outputRoots;
1010
+ getOutputRoots(target) {
1011
+ if (Array.isArray(this.outputRoots)) return this.outputRoots;
1012
+ if (target) {
1013
+ const targetOutputRoots = this.outputRoots[target];
1014
+ if (targetOutputRoots === void 0) return [];
1015
+ return Array.isArray(targetOutputRoots) ? targetOutputRoots : [targetOutputRoots];
1016
+ }
1017
+ const allRoots = [];
1018
+ for (const value of Object.values(this.outputRoots)) {
1019
+ if (value === void 0) continue;
1020
+ allRoots.push(...Array.isArray(value) ? value : [value]);
1021
+ }
1022
+ return [...new Set(allRoots)];
1006
1023
  }
1007
1024
  /**
1008
1025
  * Filter an arbitrary string-key list down to the known `ToolTarget` set,
@@ -1364,10 +1381,21 @@ var ConfigResolver = class {
1364
1381
  };
1365
1382
  function getOutputRootsInLightOfGlobal({ outputRoots, global }) {
1366
1383
  if (global) return [getHomeDirectory()];
1367
- outputRoots.forEach((outputRoot) => {
1368
- validateOutputRoot(outputRoot);
1369
- });
1370
- return outputRoots.map((outputRoot) => resolve(outputRoot));
1384
+ if (Array.isArray(outputRoots)) {
1385
+ outputRoots.forEach((outputRoot) => {
1386
+ validateOutputRoot(outputRoot);
1387
+ });
1388
+ return outputRoots.map((outputRoot) => resolve(outputRoot));
1389
+ }
1390
+ const resolvedOutputRoots = {};
1391
+ for (const [target, targetOutputRoots] of Object.entries(outputRoots)) {
1392
+ const roots = Array.isArray(targetOutputRoots) ? targetOutputRoots : [targetOutputRoots];
1393
+ roots.forEach((outputRoot) => {
1394
+ validateOutputRoot(outputRoot);
1395
+ });
1396
+ resolvedOutputRoots[target] = Array.isArray(targetOutputRoots) ? roots.map((outputRoot) => resolve(outputRoot)) : resolve(targetOutputRoots);
1397
+ }
1398
+ return resolvedOutputRoots;
1371
1399
  }
1372
1400
  function extractConfigFileTargets(targets) {
1373
1401
  if (targets === void 0) return void 0;
@@ -37818,7 +37846,7 @@ async function generateRulesCore(params) {
37818
37846
  targets: config.getConfigFileTargets(),
37819
37847
  global: config.getGlobal()
37820
37848
  }) : /* @__PURE__ */ new Map();
37821
- for (const outputRoot of config.getOutputRoots()) for (const toolTarget of toolTargets) {
37849
+ for (const toolTarget of toolTargets) for (const outputRoot of config.getOutputRoots(toolTarget)) {
37822
37850
  if (!config.getFeatures(toolTarget).includes("rules")) continue;
37823
37851
  const processor = new RulesProcessor({
37824
37852
  outputRoot,
@@ -37873,7 +37901,7 @@ async function generateIgnoreCore(params) {
37873
37901
  let hasDiff = false;
37874
37902
  for (const toolTarget of intersection(config.getTargets(), supportedIgnoreTargets)) {
37875
37903
  if (!config.getFeatures(toolTarget).includes("ignore")) continue;
37876
- for (const outputRoot of config.getOutputRoots()) try {
37904
+ for (const outputRoot of config.getOutputRoots(toolTarget)) try {
37877
37905
  const processor = new IgnoreProcessor({
37878
37906
  outputRoot,
37879
37907
  inputRoot: config.getInputRoot(),
@@ -37914,7 +37942,7 @@ async function generateMcpCore(params) {
37914
37942
  featureName: "mcp",
37915
37943
  logger
37916
37944
  });
37917
- for (const outputRoot of config.getOutputRoots()) for (const toolTarget of toolTargets) {
37945
+ for (const toolTarget of toolTargets) for (const outputRoot of config.getOutputRoots(toolTarget)) {
37918
37946
  if (!config.getFeatures(toolTarget).includes("mcp")) continue;
37919
37947
  const processor = new McpProcessor({
37920
37948
  outputRoot,
@@ -37956,7 +37984,7 @@ async function generateCommandsCore(params) {
37956
37984
  featureName: "commands",
37957
37985
  logger
37958
37986
  });
37959
- for (const outputRoot of config.getOutputRoots()) for (const toolTarget of toolTargets) {
37987
+ for (const toolTarget of toolTargets) for (const outputRoot of config.getOutputRoots(toolTarget)) {
37960
37988
  if (!config.getFeatures(toolTarget).includes("commands")) continue;
37961
37989
  const processor = new CommandsProcessor({
37962
37990
  outputRoot,
@@ -37998,7 +38026,7 @@ async function generateSubagentsCore(params) {
37998
38026
  featureName: "subagents",
37999
38027
  logger
38000
38028
  });
38001
- for (const outputRoot of config.getOutputRoots()) for (const toolTarget of toolTargets) {
38029
+ for (const toolTarget of toolTargets) for (const outputRoot of config.getOutputRoots(toolTarget)) {
38002
38030
  if (!config.getFeatures(toolTarget).includes("subagents")) continue;
38003
38031
  const processor = new SubagentsProcessor({
38004
38032
  outputRoot,
@@ -38041,7 +38069,7 @@ async function generateSkillsCore(params) {
38041
38069
  featureName: "skills",
38042
38070
  logger
38043
38071
  });
38044
- for (const outputRoot of config.getOutputRoots()) for (const toolTarget of toolTargets) {
38072
+ for (const toolTarget of toolTargets) for (const outputRoot of config.getOutputRoots(toolTarget)) {
38045
38073
  if (!config.getFeatures(toolTarget).includes("skills")) continue;
38046
38074
  const processor = new SkillsProcessor({
38047
38075
  outputRoot,
@@ -38082,7 +38110,7 @@ async function generateHooksCore(params) {
38082
38110
  featureName: "hooks",
38083
38111
  logger
38084
38112
  });
38085
- for (const outputRoot of config.getOutputRoots()) for (const toolTarget of toolTargets) {
38113
+ for (const toolTarget of toolTargets) for (const outputRoot of config.getOutputRoots(toolTarget)) {
38086
38114
  if (!config.getFeatures(toolTarget).includes("hooks")) continue;
38087
38115
  const processor = new HooksProcessor({
38088
38116
  outputRoot,
@@ -38119,7 +38147,7 @@ async function generatePermissionsCore(params) {
38119
38147
  let totalCount = 0;
38120
38148
  const allPaths = [];
38121
38149
  let hasDiff = false;
38122
- for (const outputRoot of config.getOutputRoots()) for (const toolTarget of intersection(config.getTargets(), supportedPermissionsTargets)) {
38150
+ for (const toolTarget of intersection(config.getTargets(), supportedPermissionsTargets)) for (const outputRoot of config.getOutputRoots(toolTarget)) {
38123
38151
  if (!config.getFeatures(toolTarget).includes("permissions")) continue;
38124
38152
  try {
38125
38153
  const processor = new PermissionsProcessor({
@@ -38397,4 +38425,4 @@ async function importPermissionsCore(params) {
38397
38425
  //#endregion
38398
38426
  export { toPosixPath as $, RulesyncCommand as A, createTempDirectory as B, RulesyncHooks as C, RULESYNC_SKILLS_RELATIVE_DIR_PATH as Ct, CLAUDECODE_MEMORIES_DIR_NAME as D, ALL_FEATURES as Dt, CLAUDECODE_LOCAL_RULE_FILE_NAME as E, formatError as Et, ConsoleLogger as F, getFileSize as G, ensureDir as H, JsonLogger as I, listDirectoryFiles as J, getHomeDirectory as K, CLIError as L, stringifyFrontmatter as M, ConfigResolver as N, CLAUDECODE_SETTINGS_LOCAL_FILE_NAME as O, ALL_FEATURES_WITH_WILDCARD as Ot, findControlCharacter as P, removeTempDirectory as Q, ErrorCodes as R, HooksProcessor as S, RULESYNC_RULES_RELATIVE_DIR_PATH as St, CLAUDECODE_DIR as T, RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH as Tt, fileExists as U, directoryExists as V, findFilesByGlobs as W, removeDirectory as X, readFileContent as Y, removeFile as Z, RulesyncPermissions as _, RULESYNC_MCP_SCHEMA_URL as _t, convertFromTool as a, RULESYNC_AIIGNORE_FILE_NAME as at, IgnoreProcessor as b, RULESYNC_PERMISSIONS_RELATIVE_FILE_PATH as bt, RulesyncRuleFrontmatterSchema as c, RULESYNC_CONFIG_RELATIVE_FILE_PATH as ct, RulesyncSubagentFrontmatterSchema as d, RULESYNC_HOOKS_FILE_NAME as dt, writeFileContent as et, SkillsProcessor as f, RULESYNC_HOOKS_RELATIVE_FILE_PATH as ft, SKILL_FILE_NAME as g, RULESYNC_MCP_RELATIVE_FILE_PATH as gt, RulesyncSkillFrontmatterSchema as h, RULESYNC_MCP_FILE_NAME as ht, getProcessorRegistryEntry as i, MAX_FILE_SIZE as it, RulesyncCommandFrontmatterSchema as j, CLAUDECODE_SKILLS_DIR_PATH as k, SubagentsProcessor as l, RULESYNC_CONFIG_SCHEMA_URL as lt, RulesyncSkill as m, RULESYNC_LOCAL_CONFIG_RELATIVE_FILE_PATH as mt, checkRulesyncDirExists as n, ALL_TOOL_TARGETS_WITH_WILDCARD as nt, RulesProcessor as o, RULESYNC_AIIGNORE_RELATIVE_FILE_PATH as ot, getLocalSkillDirNames as p, RULESYNC_IGNORE_RELATIVE_FILE_PATH as pt, isSymlink as q, generate as r, ToolTargetSchema as rt, RulesyncRule as s, RULESYNC_COMMANDS_RELATIVE_DIR_PATH as st, importFromTool as t, ALL_TOOL_TARGETS as tt, RulesyncSubagent as u, RULESYNC_CURATED_SKILLS_RELATIVE_DIR_PATH as ut, McpProcessor as v, RULESYNC_OVERVIEW_FILE_NAME as vt, CommandsProcessor as w, RULESYNC_SOURCES_LOCK_RELATIVE_FILE_PATH as wt, RulesyncIgnore as x, RULESYNC_RELATIVE_DIR_PATH as xt, RulesyncMcp as y, RULESYNC_PERMISSIONS_FILE_NAME as yt, checkPathTraversal as z };
38399
38427
 
38400
- //# sourceMappingURL=import-BxqZVTKb.js.map
38428
+ //# sourceMappingURL=import-BdJG1fyb.js.map