rulesync 7.3.0 → 7.4.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.
@@ -12440,14 +12440,22 @@ var CopilotRuleFrontmatterSchema = z47.object({
12440
12440
  var CopilotRule = class _CopilotRule extends ToolRule {
12441
12441
  frontmatter;
12442
12442
  body;
12443
- static getSettablePaths(_options = {}) {
12443
+ static getSettablePaths(options = {}) {
12444
+ if (options.global) {
12445
+ return {
12446
+ root: {
12447
+ relativeDirPath: buildToolPath(".copilot", ".", options.excludeToolDir),
12448
+ relativeFilePath: "copilot-instructions.md"
12449
+ }
12450
+ };
12451
+ }
12444
12452
  return {
12445
12453
  root: {
12446
- relativeDirPath: buildToolPath(".github", ".", _options.excludeToolDir),
12454
+ relativeDirPath: buildToolPath(".github", ".", options.excludeToolDir),
12447
12455
  relativeFilePath: "copilot-instructions.md"
12448
12456
  },
12449
12457
  nonRoot: {
12450
- relativeDirPath: buildToolPath(".github", "instructions", _options.excludeToolDir)
12458
+ relativeDirPath: buildToolPath(".github", "instructions", options.excludeToolDir)
12451
12459
  }
12452
12460
  };
12453
12461
  }
@@ -12498,10 +12506,12 @@ var CopilotRule = class _CopilotRule extends ToolRule {
12498
12506
  static fromRulesyncRule({
12499
12507
  baseDir = process.cwd(),
12500
12508
  rulesyncRule,
12501
- validate = true
12509
+ validate = true,
12510
+ global = false
12502
12511
  }) {
12503
12512
  const rulesyncFrontmatter = rulesyncRule.getFrontmatter();
12504
12513
  const root = rulesyncFrontmatter.root;
12514
+ const paths = this.getSettablePaths({ global });
12505
12515
  const copilotFrontmatter = {
12506
12516
  description: rulesyncFrontmatter.description,
12507
12517
  applyTo: rulesyncFrontmatter.globs?.length ? rulesyncFrontmatter.globs.join(",") : void 0,
@@ -12513,12 +12523,15 @@ var CopilotRule = class _CopilotRule extends ToolRule {
12513
12523
  baseDir,
12514
12524
  frontmatter: copilotFrontmatter,
12515
12525
  body,
12516
- relativeDirPath: this.getSettablePaths().root.relativeDirPath,
12517
- relativeFilePath: this.getSettablePaths().root.relativeFilePath,
12526
+ relativeDirPath: paths.root.relativeDirPath,
12527
+ relativeFilePath: paths.root.relativeFilePath,
12518
12528
  validate,
12519
12529
  root
12520
12530
  });
12521
12531
  }
12532
+ if (!paths.nonRoot) {
12533
+ throw new Error(`nonRoot path is not set for ${rulesyncRule.getRelativeFilePath()}`);
12534
+ }
12522
12535
  const originalFileName = rulesyncRule.getRelativeFilePath();
12523
12536
  const nameWithoutExt = originalFileName.replace(/\.md$/, "");
12524
12537
  const newFileName = `${nameWithoutExt}.instructions.md`;
@@ -12526,7 +12539,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
12526
12539
  baseDir,
12527
12540
  frontmatter: copilotFrontmatter,
12528
12541
  body,
12529
- relativeDirPath: this.getSettablePaths().nonRoot.relativeDirPath,
12542
+ relativeDirPath: paths.nonRoot.relativeDirPath,
12530
12543
  relativeFilePath: newFileName,
12531
12544
  validate,
12532
12545
  root
@@ -12535,25 +12548,29 @@ var CopilotRule = class _CopilotRule extends ToolRule {
12535
12548
  static async fromFile({
12536
12549
  baseDir = process.cwd(),
12537
12550
  relativeFilePath,
12538
- validate = true
12551
+ validate = true,
12552
+ global = false
12539
12553
  }) {
12540
- const isRoot = relativeFilePath === "copilot-instructions.md";
12541
- const relativePath = isRoot ? join95(
12542
- this.getSettablePaths().root.relativeDirPath,
12543
- this.getSettablePaths().root.relativeFilePath
12544
- ) : join95(this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath);
12545
- const fileContent = await readFileContent(join95(baseDir, relativePath));
12554
+ const paths = this.getSettablePaths({ global });
12555
+ const isRoot = relativeFilePath === paths.root.relativeFilePath;
12546
12556
  if (isRoot) {
12557
+ const relativePath2 = join95(paths.root.relativeDirPath, paths.root.relativeFilePath);
12558
+ const fileContent2 = await readFileContent(join95(baseDir, relativePath2));
12547
12559
  return new _CopilotRule({
12548
12560
  baseDir,
12549
- relativeDirPath: this.getSettablePaths().root.relativeDirPath,
12550
- relativeFilePath: this.getSettablePaths().root.relativeFilePath,
12561
+ relativeDirPath: paths.root.relativeDirPath,
12562
+ relativeFilePath: paths.root.relativeFilePath,
12551
12563
  frontmatter: {},
12552
- body: fileContent.trim(),
12564
+ body: fileContent2.trim(),
12553
12565
  validate,
12554
12566
  root: isRoot
12555
12567
  });
12556
12568
  }
12569
+ if (!paths.nonRoot) {
12570
+ throw new Error(`nonRoot path is not set for ${relativeFilePath}`);
12571
+ }
12572
+ const relativePath = join95(paths.nonRoot.relativeDirPath, relativeFilePath);
12573
+ const fileContent = await readFileContent(join95(baseDir, relativePath));
12557
12574
  const { frontmatter, body: content } = parseFrontmatter(fileContent);
12558
12575
  const result = CopilotRuleFrontmatterSchema.safeParse(frontmatter);
12559
12576
  if (!result.success) {
@@ -12563,7 +12580,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
12563
12580
  }
12564
12581
  return new _CopilotRule({
12565
12582
  baseDir,
12566
- relativeDirPath: this.getSettablePaths().nonRoot.relativeDirPath,
12583
+ relativeDirPath: paths.nonRoot.relativeDirPath,
12567
12584
  relativeFilePath: relativeFilePath.endsWith(".instructions.md") ? relativeFilePath : relativeFilePath.replace(/\.md$/, ".instructions.md"),
12568
12585
  frontmatter: result.data,
12569
12586
  body: content.trim(),
@@ -12574,9 +12591,11 @@ var CopilotRule = class _CopilotRule extends ToolRule {
12574
12591
  static forDeletion({
12575
12592
  baseDir = process.cwd(),
12576
12593
  relativeDirPath,
12577
- relativeFilePath
12594
+ relativeFilePath,
12595
+ global = false
12578
12596
  }) {
12579
- const isRoot = relativeFilePath === this.getSettablePaths().root.relativeFilePath;
12597
+ const paths = this.getSettablePaths({ global });
12598
+ const isRoot = relativeFilePath === paths.root.relativeFilePath;
12580
12599
  return new _CopilotRule({
12581
12600
  baseDir,
12582
12601
  relativeDirPath,
@@ -13256,46 +13275,78 @@ var KiroRule = class _KiroRule extends ToolRule {
13256
13275
  // src/features/rules/opencode-rule.ts
13257
13276
  import { join as join102 } from "path";
13258
13277
  var OpenCodeRule = class _OpenCodeRule extends ToolRule {
13259
- static getSettablePaths(_options = {}) {
13278
+ static getSettablePaths({
13279
+ global,
13280
+ excludeToolDir
13281
+ } = {}) {
13282
+ if (global) {
13283
+ return {
13284
+ root: {
13285
+ relativeDirPath: buildToolPath(".config/opencode", ".", excludeToolDir),
13286
+ relativeFilePath: "AGENTS.md"
13287
+ }
13288
+ };
13289
+ }
13260
13290
  return {
13261
13291
  root: {
13262
13292
  relativeDirPath: ".",
13263
13293
  relativeFilePath: "AGENTS.md"
13264
13294
  },
13265
13295
  nonRoot: {
13266
- relativeDirPath: buildToolPath(".opencode", "memories", _options.excludeToolDir)
13296
+ relativeDirPath: buildToolPath(".opencode", "memories", excludeToolDir)
13267
13297
  }
13268
13298
  };
13269
13299
  }
13270
13300
  static async fromFile({
13271
13301
  baseDir = process.cwd(),
13272
13302
  relativeFilePath,
13273
- validate = true
13303
+ validate = true,
13304
+ global = false
13274
13305
  }) {
13275
- const isRoot = relativeFilePath === "AGENTS.md";
13276
- const relativePath = isRoot ? "AGENTS.md" : join102(".opencode", "memories", relativeFilePath);
13306
+ const paths = this.getSettablePaths({ global });
13307
+ const isRoot = relativeFilePath === paths.root.relativeFilePath;
13308
+ if (isRoot) {
13309
+ const relativePath2 = paths.root.relativeFilePath;
13310
+ const fileContent2 = await readFileContent(
13311
+ join102(baseDir, paths.root.relativeDirPath, relativePath2)
13312
+ );
13313
+ return new _OpenCodeRule({
13314
+ baseDir,
13315
+ relativeDirPath: paths.root.relativeDirPath,
13316
+ relativeFilePath: paths.root.relativeFilePath,
13317
+ fileContent: fileContent2,
13318
+ validate,
13319
+ root: true
13320
+ });
13321
+ }
13322
+ if (!paths.nonRoot) {
13323
+ throw new Error(`nonRoot path is not set for ${relativeFilePath}`);
13324
+ }
13325
+ const relativePath = join102(paths.nonRoot.relativeDirPath, relativeFilePath);
13277
13326
  const fileContent = await readFileContent(join102(baseDir, relativePath));
13278
13327
  return new _OpenCodeRule({
13279
13328
  baseDir,
13280
- relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
13281
- relativeFilePath: isRoot ? "AGENTS.md" : relativeFilePath,
13329
+ relativeDirPath: paths.nonRoot.relativeDirPath,
13330
+ relativeFilePath,
13331
+ fileContent,
13282
13332
  validate,
13283
- root: isRoot,
13284
- fileContent
13333
+ root: false
13285
13334
  });
13286
13335
  }
13287
13336
  static fromRulesyncRule({
13288
13337
  baseDir = process.cwd(),
13289
13338
  rulesyncRule,
13290
- validate = true
13339
+ validate = true,
13340
+ global = false
13291
13341
  }) {
13342
+ const paths = this.getSettablePaths({ global });
13292
13343
  return new _OpenCodeRule(
13293
13344
  this.buildToolRuleParamsDefault({
13294
13345
  baseDir,
13295
13346
  rulesyncRule,
13296
13347
  validate,
13297
- rootPath: this.getSettablePaths().root,
13298
- nonRootPath: this.getSettablePaths().nonRoot
13348
+ rootPath: paths.root,
13349
+ nonRootPath: paths.nonRoot
13299
13350
  })
13300
13351
  );
13301
13352
  }
@@ -13308,9 +13359,11 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
13308
13359
  static forDeletion({
13309
13360
  baseDir = process.cwd(),
13310
13361
  relativeDirPath,
13311
- relativeFilePath
13362
+ relativeFilePath,
13363
+ global = false
13312
13364
  }) {
13313
- const isRoot = relativeFilePath === "AGENTS.md" && relativeDirPath === ".";
13365
+ const paths = this.getSettablePaths({ global });
13366
+ const isRoot = relativeFilePath === paths.root.relativeFilePath;
13314
13367
  return new _OpenCodeRule({
13315
13368
  baseDir,
13316
13369
  relativeDirPath,
@@ -13768,42 +13821,66 @@ var toolRuleFactories = /* @__PURE__ */ new Map([
13768
13821
  "antigravity",
13769
13822
  {
13770
13823
  class: AntigravityRule,
13771
- meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "auto" }
13824
+ meta: {
13825
+ extension: "md",
13826
+ supportsGlobal: false,
13827
+ ruleDiscoveryMode: "auto"
13828
+ }
13772
13829
  }
13773
13830
  ],
13774
13831
  [
13775
13832
  "augmentcode",
13776
13833
  {
13777
13834
  class: AugmentcodeRule,
13778
- meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "auto" }
13835
+ meta: {
13836
+ extension: "md",
13837
+ supportsGlobal: false,
13838
+ ruleDiscoveryMode: "auto"
13839
+ }
13779
13840
  }
13780
13841
  ],
13781
13842
  [
13782
13843
  "augmentcode-legacy",
13783
13844
  {
13784
13845
  class: AugmentcodeLegacyRule,
13785
- meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "toon" }
13846
+ meta: {
13847
+ extension: "md",
13848
+ supportsGlobal: false,
13849
+ ruleDiscoveryMode: "toon"
13850
+ }
13786
13851
  }
13787
13852
  ],
13788
13853
  [
13789
13854
  "claudecode",
13790
13855
  {
13791
13856
  class: ClaudecodeRule,
13792
- meta: { extension: "md", supportsGlobal: true, ruleDiscoveryMode: "auto" }
13857
+ meta: {
13858
+ extension: "md",
13859
+ supportsGlobal: true,
13860
+ ruleDiscoveryMode: "auto"
13861
+ }
13793
13862
  }
13794
13863
  ],
13795
13864
  [
13796
13865
  "claudecode-legacy",
13797
13866
  {
13798
13867
  class: ClaudecodeLegacyRule,
13799
- meta: { extension: "md", supportsGlobal: true, ruleDiscoveryMode: "claudecode-legacy" }
13868
+ meta: {
13869
+ extension: "md",
13870
+ supportsGlobal: true,
13871
+ ruleDiscoveryMode: "claudecode-legacy"
13872
+ }
13800
13873
  }
13801
13874
  ],
13802
13875
  [
13803
13876
  "cline",
13804
13877
  {
13805
13878
  class: ClineRule,
13806
- meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "auto" }
13879
+ meta: {
13880
+ extension: "md",
13881
+ supportsGlobal: false,
13882
+ ruleDiscoveryMode: "auto"
13883
+ }
13807
13884
  }
13808
13885
  ],
13809
13886
  [
@@ -13826,7 +13903,7 @@ var toolRuleFactories = /* @__PURE__ */ new Map([
13826
13903
  class: CopilotRule,
13827
13904
  meta: {
13828
13905
  extension: "md",
13829
- supportsGlobal: false,
13906
+ supportsGlobal: true,
13830
13907
  ruleDiscoveryMode: "auto"
13831
13908
  }
13832
13909
  }
@@ -13876,42 +13953,66 @@ var toolRuleFactories = /* @__PURE__ */ new Map([
13876
13953
  "junie",
13877
13954
  {
13878
13955
  class: JunieRule,
13879
- meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "toon" }
13956
+ meta: {
13957
+ extension: "md",
13958
+ supportsGlobal: false,
13959
+ ruleDiscoveryMode: "toon"
13960
+ }
13880
13961
  }
13881
13962
  ],
13882
13963
  [
13883
13964
  "kilo",
13884
13965
  {
13885
13966
  class: KiloRule,
13886
- meta: { extension: "md", supportsGlobal: true, ruleDiscoveryMode: "auto" }
13967
+ meta: {
13968
+ extension: "md",
13969
+ supportsGlobal: true,
13970
+ ruleDiscoveryMode: "auto"
13971
+ }
13887
13972
  }
13888
13973
  ],
13889
13974
  [
13890
13975
  "kiro",
13891
13976
  {
13892
13977
  class: KiroRule,
13893
- meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "toon" }
13978
+ meta: {
13979
+ extension: "md",
13980
+ supportsGlobal: false,
13981
+ ruleDiscoveryMode: "toon"
13982
+ }
13894
13983
  }
13895
13984
  ],
13896
13985
  [
13897
13986
  "opencode",
13898
13987
  {
13899
13988
  class: OpenCodeRule,
13900
- meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "toon" }
13989
+ meta: {
13990
+ extension: "md",
13991
+ supportsGlobal: true,
13992
+ ruleDiscoveryMode: "toon"
13993
+ }
13901
13994
  }
13902
13995
  ],
13903
13996
  [
13904
13997
  "qwencode",
13905
13998
  {
13906
13999
  class: QwencodeRule,
13907
- meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "toon" }
14000
+ meta: {
14001
+ extension: "md",
14002
+ supportsGlobal: false,
14003
+ ruleDiscoveryMode: "toon"
14004
+ }
13908
14005
  }
13909
14006
  ],
13910
14007
  [
13911
14008
  "replit",
13912
14009
  {
13913
14010
  class: ReplitRule,
13914
- meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "auto" }
14011
+ meta: {
14012
+ extension: "md",
14013
+ supportsGlobal: false,
14014
+ ruleDiscoveryMode: "auto"
14015
+ }
13915
14016
  }
13916
14017
  ],
13917
14018
  [
@@ -13933,14 +14034,22 @@ var toolRuleFactories = /* @__PURE__ */ new Map([
13933
14034
  "warp",
13934
14035
  {
13935
14036
  class: WarpRule,
13936
- meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "toon" }
14037
+ meta: {
14038
+ extension: "md",
14039
+ supportsGlobal: false,
14040
+ ruleDiscoveryMode: "toon"
14041
+ }
13937
14042
  }
13938
14043
  ],
13939
14044
  [
13940
14045
  "windsurf",
13941
14046
  {
13942
14047
  class: WindsurfRule,
13943
- meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "auto" }
14048
+ meta: {
14049
+ extension: "md",
14050
+ supportsGlobal: false,
14051
+ ruleDiscoveryMode: "auto"
14052
+ }
13944
14053
  }
13945
14054
  ]
13946
14055
  ]);
@@ -14088,7 +14197,9 @@ var RulesProcessor = class extends FeatureProcessor {
14088
14197
  })
14089
14198
  );
14090
14199
  } else if (this.toolTarget === "claudecode-legacy") {
14091
- const paths = ClaudecodeLegacyRule.getSettablePaths({ global: this.global });
14200
+ const paths = ClaudecodeLegacyRule.getSettablePaths({
14201
+ global: this.global
14202
+ });
14092
14203
  toolRules.push(
14093
14204
  new ClaudecodeLegacyRule({
14094
14205
  baseDir: this.baseDir,
@@ -14174,7 +14285,10 @@ var RulesProcessor = class extends FeatureProcessor {
14174
14285
  const rulesyncRules = await Promise.all(
14175
14286
  files.map((file) => {
14176
14287
  const relativeFilePath = relative4(rulesyncBaseDir, file);
14177
- checkPathTraversal({ relativePath: relativeFilePath, intendedRootDir: rulesyncBaseDir });
14288
+ checkPathTraversal({
14289
+ relativePath: relativeFilePath,
14290
+ intendedRootDir: rulesyncBaseDir
14291
+ });
14178
14292
  return RulesyncRule.fromFile({
14179
14293
  relativeFilePath
14180
14294
  });
@@ -14225,7 +14339,9 @@ var RulesProcessor = class extends FeatureProcessor {
14225
14339
  } = {}) {
14226
14340
  try {
14227
14341
  const factory = this.getFactory(this.toolTarget);
14228
- const settablePaths = factory.class.getSettablePaths({ global: this.global });
14342
+ const settablePaths = factory.class.getSettablePaths({
14343
+ global: this.global
14344
+ });
14229
14345
  const rootToolRules = await (async () => {
14230
14346
  if (!settablePaths.root) {
14231
14347
  return [];
@@ -14307,7 +14423,10 @@ var RulesProcessor = class extends FeatureProcessor {
14307
14423
  return await Promise.all(
14308
14424
  nonRootFilePaths.map((filePath) => {
14309
14425
  const relativeFilePath = relative4(nonRootBaseDir, filePath);
14310
- checkPathTraversal({ relativePath: relativeFilePath, intendedRootDir: nonRootBaseDir });
14426
+ checkPathTraversal({
14427
+ relativePath: relativeFilePath,
14428
+ intendedRootDir: nonRootBaseDir
14429
+ });
14311
14430
  return factory.class.fromFile({
14312
14431
  baseDir: this.baseDir,
14313
14432
  relativeFilePath,