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.
package/dist/index.cjs CHANGED
@@ -12468,14 +12468,22 @@ var CopilotRuleFrontmatterSchema = import_mini47.z.object({
12468
12468
  var CopilotRule = class _CopilotRule extends ToolRule {
12469
12469
  frontmatter;
12470
12470
  body;
12471
- static getSettablePaths(_options = {}) {
12471
+ static getSettablePaths(options = {}) {
12472
+ if (options.global) {
12473
+ return {
12474
+ root: {
12475
+ relativeDirPath: buildToolPath(".copilot", ".", options.excludeToolDir),
12476
+ relativeFilePath: "copilot-instructions.md"
12477
+ }
12478
+ };
12479
+ }
12472
12480
  return {
12473
12481
  root: {
12474
- relativeDirPath: buildToolPath(".github", ".", _options.excludeToolDir),
12482
+ relativeDirPath: buildToolPath(".github", ".", options.excludeToolDir),
12475
12483
  relativeFilePath: "copilot-instructions.md"
12476
12484
  },
12477
12485
  nonRoot: {
12478
- relativeDirPath: buildToolPath(".github", "instructions", _options.excludeToolDir)
12486
+ relativeDirPath: buildToolPath(".github", "instructions", options.excludeToolDir)
12479
12487
  }
12480
12488
  };
12481
12489
  }
@@ -12526,10 +12534,12 @@ var CopilotRule = class _CopilotRule extends ToolRule {
12526
12534
  static fromRulesyncRule({
12527
12535
  baseDir = process.cwd(),
12528
12536
  rulesyncRule,
12529
- validate = true
12537
+ validate = true,
12538
+ global = false
12530
12539
  }) {
12531
12540
  const rulesyncFrontmatter = rulesyncRule.getFrontmatter();
12532
12541
  const root = rulesyncFrontmatter.root;
12542
+ const paths = this.getSettablePaths({ global });
12533
12543
  const copilotFrontmatter = {
12534
12544
  description: rulesyncFrontmatter.description,
12535
12545
  applyTo: rulesyncFrontmatter.globs?.length ? rulesyncFrontmatter.globs.join(",") : void 0,
@@ -12541,12 +12551,15 @@ var CopilotRule = class _CopilotRule extends ToolRule {
12541
12551
  baseDir,
12542
12552
  frontmatter: copilotFrontmatter,
12543
12553
  body,
12544
- relativeDirPath: this.getSettablePaths().root.relativeDirPath,
12545
- relativeFilePath: this.getSettablePaths().root.relativeFilePath,
12554
+ relativeDirPath: paths.root.relativeDirPath,
12555
+ relativeFilePath: paths.root.relativeFilePath,
12546
12556
  validate,
12547
12557
  root
12548
12558
  });
12549
12559
  }
12560
+ if (!paths.nonRoot) {
12561
+ throw new Error(`nonRoot path is not set for ${rulesyncRule.getRelativeFilePath()}`);
12562
+ }
12550
12563
  const originalFileName = rulesyncRule.getRelativeFilePath();
12551
12564
  const nameWithoutExt = originalFileName.replace(/\.md$/, "");
12552
12565
  const newFileName = `${nameWithoutExt}.instructions.md`;
@@ -12554,7 +12567,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
12554
12567
  baseDir,
12555
12568
  frontmatter: copilotFrontmatter,
12556
12569
  body,
12557
- relativeDirPath: this.getSettablePaths().nonRoot.relativeDirPath,
12570
+ relativeDirPath: paths.nonRoot.relativeDirPath,
12558
12571
  relativeFilePath: newFileName,
12559
12572
  validate,
12560
12573
  root
@@ -12563,25 +12576,29 @@ var CopilotRule = class _CopilotRule extends ToolRule {
12563
12576
  static async fromFile({
12564
12577
  baseDir = process.cwd(),
12565
12578
  relativeFilePath,
12566
- validate = true
12579
+ validate = true,
12580
+ global = false
12567
12581
  }) {
12568
- const isRoot = relativeFilePath === "copilot-instructions.md";
12569
- const relativePath = isRoot ? (0, import_node_path96.join)(
12570
- this.getSettablePaths().root.relativeDirPath,
12571
- this.getSettablePaths().root.relativeFilePath
12572
- ) : (0, import_node_path96.join)(this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath);
12573
- const fileContent = await readFileContent((0, import_node_path96.join)(baseDir, relativePath));
12582
+ const paths = this.getSettablePaths({ global });
12583
+ const isRoot = relativeFilePath === paths.root.relativeFilePath;
12574
12584
  if (isRoot) {
12585
+ const relativePath2 = (0, import_node_path96.join)(paths.root.relativeDirPath, paths.root.relativeFilePath);
12586
+ const fileContent2 = await readFileContent((0, import_node_path96.join)(baseDir, relativePath2));
12575
12587
  return new _CopilotRule({
12576
12588
  baseDir,
12577
- relativeDirPath: this.getSettablePaths().root.relativeDirPath,
12578
- relativeFilePath: this.getSettablePaths().root.relativeFilePath,
12589
+ relativeDirPath: paths.root.relativeDirPath,
12590
+ relativeFilePath: paths.root.relativeFilePath,
12579
12591
  frontmatter: {},
12580
- body: fileContent.trim(),
12592
+ body: fileContent2.trim(),
12581
12593
  validate,
12582
12594
  root: isRoot
12583
12595
  });
12584
12596
  }
12597
+ if (!paths.nonRoot) {
12598
+ throw new Error(`nonRoot path is not set for ${relativeFilePath}`);
12599
+ }
12600
+ const relativePath = (0, import_node_path96.join)(paths.nonRoot.relativeDirPath, relativeFilePath);
12601
+ const fileContent = await readFileContent((0, import_node_path96.join)(baseDir, relativePath));
12585
12602
  const { frontmatter, body: content } = parseFrontmatter(fileContent);
12586
12603
  const result = CopilotRuleFrontmatterSchema.safeParse(frontmatter);
12587
12604
  if (!result.success) {
@@ -12591,7 +12608,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
12591
12608
  }
12592
12609
  return new _CopilotRule({
12593
12610
  baseDir,
12594
- relativeDirPath: this.getSettablePaths().nonRoot.relativeDirPath,
12611
+ relativeDirPath: paths.nonRoot.relativeDirPath,
12595
12612
  relativeFilePath: relativeFilePath.endsWith(".instructions.md") ? relativeFilePath : relativeFilePath.replace(/\.md$/, ".instructions.md"),
12596
12613
  frontmatter: result.data,
12597
12614
  body: content.trim(),
@@ -12602,9 +12619,11 @@ var CopilotRule = class _CopilotRule extends ToolRule {
12602
12619
  static forDeletion({
12603
12620
  baseDir = process.cwd(),
12604
12621
  relativeDirPath,
12605
- relativeFilePath
12622
+ relativeFilePath,
12623
+ global = false
12606
12624
  }) {
12607
- const isRoot = relativeFilePath === this.getSettablePaths().root.relativeFilePath;
12625
+ const paths = this.getSettablePaths({ global });
12626
+ const isRoot = relativeFilePath === paths.root.relativeFilePath;
12608
12627
  return new _CopilotRule({
12609
12628
  baseDir,
12610
12629
  relativeDirPath,
@@ -13284,46 +13303,78 @@ var KiroRule = class _KiroRule extends ToolRule {
13284
13303
  // src/features/rules/opencode-rule.ts
13285
13304
  var import_node_path103 = require("path");
13286
13305
  var OpenCodeRule = class _OpenCodeRule extends ToolRule {
13287
- static getSettablePaths(_options = {}) {
13306
+ static getSettablePaths({
13307
+ global,
13308
+ excludeToolDir
13309
+ } = {}) {
13310
+ if (global) {
13311
+ return {
13312
+ root: {
13313
+ relativeDirPath: buildToolPath(".config/opencode", ".", excludeToolDir),
13314
+ relativeFilePath: "AGENTS.md"
13315
+ }
13316
+ };
13317
+ }
13288
13318
  return {
13289
13319
  root: {
13290
13320
  relativeDirPath: ".",
13291
13321
  relativeFilePath: "AGENTS.md"
13292
13322
  },
13293
13323
  nonRoot: {
13294
- relativeDirPath: buildToolPath(".opencode", "memories", _options.excludeToolDir)
13324
+ relativeDirPath: buildToolPath(".opencode", "memories", excludeToolDir)
13295
13325
  }
13296
13326
  };
13297
13327
  }
13298
13328
  static async fromFile({
13299
13329
  baseDir = process.cwd(),
13300
13330
  relativeFilePath,
13301
- validate = true
13331
+ validate = true,
13332
+ global = false
13302
13333
  }) {
13303
- const isRoot = relativeFilePath === "AGENTS.md";
13304
- const relativePath = isRoot ? "AGENTS.md" : (0, import_node_path103.join)(".opencode", "memories", relativeFilePath);
13334
+ const paths = this.getSettablePaths({ global });
13335
+ const isRoot = relativeFilePath === paths.root.relativeFilePath;
13336
+ if (isRoot) {
13337
+ const relativePath2 = paths.root.relativeFilePath;
13338
+ const fileContent2 = await readFileContent(
13339
+ (0, import_node_path103.join)(baseDir, paths.root.relativeDirPath, relativePath2)
13340
+ );
13341
+ return new _OpenCodeRule({
13342
+ baseDir,
13343
+ relativeDirPath: paths.root.relativeDirPath,
13344
+ relativeFilePath: paths.root.relativeFilePath,
13345
+ fileContent: fileContent2,
13346
+ validate,
13347
+ root: true
13348
+ });
13349
+ }
13350
+ if (!paths.nonRoot) {
13351
+ throw new Error(`nonRoot path is not set for ${relativeFilePath}`);
13352
+ }
13353
+ const relativePath = (0, import_node_path103.join)(paths.nonRoot.relativeDirPath, relativeFilePath);
13305
13354
  const fileContent = await readFileContent((0, import_node_path103.join)(baseDir, relativePath));
13306
13355
  return new _OpenCodeRule({
13307
13356
  baseDir,
13308
- relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
13309
- relativeFilePath: isRoot ? "AGENTS.md" : relativeFilePath,
13357
+ relativeDirPath: paths.nonRoot.relativeDirPath,
13358
+ relativeFilePath,
13359
+ fileContent,
13310
13360
  validate,
13311
- root: isRoot,
13312
- fileContent
13361
+ root: false
13313
13362
  });
13314
13363
  }
13315
13364
  static fromRulesyncRule({
13316
13365
  baseDir = process.cwd(),
13317
13366
  rulesyncRule,
13318
- validate = true
13367
+ validate = true,
13368
+ global = false
13319
13369
  }) {
13370
+ const paths = this.getSettablePaths({ global });
13320
13371
  return new _OpenCodeRule(
13321
13372
  this.buildToolRuleParamsDefault({
13322
13373
  baseDir,
13323
13374
  rulesyncRule,
13324
13375
  validate,
13325
- rootPath: this.getSettablePaths().root,
13326
- nonRootPath: this.getSettablePaths().nonRoot
13376
+ rootPath: paths.root,
13377
+ nonRootPath: paths.nonRoot
13327
13378
  })
13328
13379
  );
13329
13380
  }
@@ -13336,9 +13387,11 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
13336
13387
  static forDeletion({
13337
13388
  baseDir = process.cwd(),
13338
13389
  relativeDirPath,
13339
- relativeFilePath
13390
+ relativeFilePath,
13391
+ global = false
13340
13392
  }) {
13341
- const isRoot = relativeFilePath === "AGENTS.md" && relativeDirPath === ".";
13393
+ const paths = this.getSettablePaths({ global });
13394
+ const isRoot = relativeFilePath === paths.root.relativeFilePath;
13342
13395
  return new _OpenCodeRule({
13343
13396
  baseDir,
13344
13397
  relativeDirPath,
@@ -13796,42 +13849,66 @@ var toolRuleFactories = /* @__PURE__ */ new Map([
13796
13849
  "antigravity",
13797
13850
  {
13798
13851
  class: AntigravityRule,
13799
- meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "auto" }
13852
+ meta: {
13853
+ extension: "md",
13854
+ supportsGlobal: false,
13855
+ ruleDiscoveryMode: "auto"
13856
+ }
13800
13857
  }
13801
13858
  ],
13802
13859
  [
13803
13860
  "augmentcode",
13804
13861
  {
13805
13862
  class: AugmentcodeRule,
13806
- meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "auto" }
13863
+ meta: {
13864
+ extension: "md",
13865
+ supportsGlobal: false,
13866
+ ruleDiscoveryMode: "auto"
13867
+ }
13807
13868
  }
13808
13869
  ],
13809
13870
  [
13810
13871
  "augmentcode-legacy",
13811
13872
  {
13812
13873
  class: AugmentcodeLegacyRule,
13813
- meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "toon" }
13874
+ meta: {
13875
+ extension: "md",
13876
+ supportsGlobal: false,
13877
+ ruleDiscoveryMode: "toon"
13878
+ }
13814
13879
  }
13815
13880
  ],
13816
13881
  [
13817
13882
  "claudecode",
13818
13883
  {
13819
13884
  class: ClaudecodeRule,
13820
- meta: { extension: "md", supportsGlobal: true, ruleDiscoveryMode: "auto" }
13885
+ meta: {
13886
+ extension: "md",
13887
+ supportsGlobal: true,
13888
+ ruleDiscoveryMode: "auto"
13889
+ }
13821
13890
  }
13822
13891
  ],
13823
13892
  [
13824
13893
  "claudecode-legacy",
13825
13894
  {
13826
13895
  class: ClaudecodeLegacyRule,
13827
- meta: { extension: "md", supportsGlobal: true, ruleDiscoveryMode: "claudecode-legacy" }
13896
+ meta: {
13897
+ extension: "md",
13898
+ supportsGlobal: true,
13899
+ ruleDiscoveryMode: "claudecode-legacy"
13900
+ }
13828
13901
  }
13829
13902
  ],
13830
13903
  [
13831
13904
  "cline",
13832
13905
  {
13833
13906
  class: ClineRule,
13834
- meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "auto" }
13907
+ meta: {
13908
+ extension: "md",
13909
+ supportsGlobal: false,
13910
+ ruleDiscoveryMode: "auto"
13911
+ }
13835
13912
  }
13836
13913
  ],
13837
13914
  [
@@ -13854,7 +13931,7 @@ var toolRuleFactories = /* @__PURE__ */ new Map([
13854
13931
  class: CopilotRule,
13855
13932
  meta: {
13856
13933
  extension: "md",
13857
- supportsGlobal: false,
13934
+ supportsGlobal: true,
13858
13935
  ruleDiscoveryMode: "auto"
13859
13936
  }
13860
13937
  }
@@ -13904,42 +13981,66 @@ var toolRuleFactories = /* @__PURE__ */ new Map([
13904
13981
  "junie",
13905
13982
  {
13906
13983
  class: JunieRule,
13907
- meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "toon" }
13984
+ meta: {
13985
+ extension: "md",
13986
+ supportsGlobal: false,
13987
+ ruleDiscoveryMode: "toon"
13988
+ }
13908
13989
  }
13909
13990
  ],
13910
13991
  [
13911
13992
  "kilo",
13912
13993
  {
13913
13994
  class: KiloRule,
13914
- meta: { extension: "md", supportsGlobal: true, ruleDiscoveryMode: "auto" }
13995
+ meta: {
13996
+ extension: "md",
13997
+ supportsGlobal: true,
13998
+ ruleDiscoveryMode: "auto"
13999
+ }
13915
14000
  }
13916
14001
  ],
13917
14002
  [
13918
14003
  "kiro",
13919
14004
  {
13920
14005
  class: KiroRule,
13921
- meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "toon" }
14006
+ meta: {
14007
+ extension: "md",
14008
+ supportsGlobal: false,
14009
+ ruleDiscoveryMode: "toon"
14010
+ }
13922
14011
  }
13923
14012
  ],
13924
14013
  [
13925
14014
  "opencode",
13926
14015
  {
13927
14016
  class: OpenCodeRule,
13928
- meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "toon" }
14017
+ meta: {
14018
+ extension: "md",
14019
+ supportsGlobal: true,
14020
+ ruleDiscoveryMode: "toon"
14021
+ }
13929
14022
  }
13930
14023
  ],
13931
14024
  [
13932
14025
  "qwencode",
13933
14026
  {
13934
14027
  class: QwencodeRule,
13935
- meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "toon" }
14028
+ meta: {
14029
+ extension: "md",
14030
+ supportsGlobal: false,
14031
+ ruleDiscoveryMode: "toon"
14032
+ }
13936
14033
  }
13937
14034
  ],
13938
14035
  [
13939
14036
  "replit",
13940
14037
  {
13941
14038
  class: ReplitRule,
13942
- meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "auto" }
14039
+ meta: {
14040
+ extension: "md",
14041
+ supportsGlobal: false,
14042
+ ruleDiscoveryMode: "auto"
14043
+ }
13943
14044
  }
13944
14045
  ],
13945
14046
  [
@@ -13961,14 +14062,22 @@ var toolRuleFactories = /* @__PURE__ */ new Map([
13961
14062
  "warp",
13962
14063
  {
13963
14064
  class: WarpRule,
13964
- meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "toon" }
14065
+ meta: {
14066
+ extension: "md",
14067
+ supportsGlobal: false,
14068
+ ruleDiscoveryMode: "toon"
14069
+ }
13965
14070
  }
13966
14071
  ],
13967
14072
  [
13968
14073
  "windsurf",
13969
14074
  {
13970
14075
  class: WindsurfRule,
13971
- meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "auto" }
14076
+ meta: {
14077
+ extension: "md",
14078
+ supportsGlobal: false,
14079
+ ruleDiscoveryMode: "auto"
14080
+ }
13972
14081
  }
13973
14082
  ]
13974
14083
  ]);
@@ -14116,7 +14225,9 @@ var RulesProcessor = class extends FeatureProcessor {
14116
14225
  })
14117
14226
  );
14118
14227
  } else if (this.toolTarget === "claudecode-legacy") {
14119
- const paths = ClaudecodeLegacyRule.getSettablePaths({ global: this.global });
14228
+ const paths = ClaudecodeLegacyRule.getSettablePaths({
14229
+ global: this.global
14230
+ });
14120
14231
  toolRules.push(
14121
14232
  new ClaudecodeLegacyRule({
14122
14233
  baseDir: this.baseDir,
@@ -14202,7 +14313,10 @@ var RulesProcessor = class extends FeatureProcessor {
14202
14313
  const rulesyncRules = await Promise.all(
14203
14314
  files.map((file) => {
14204
14315
  const relativeFilePath = (0, import_node_path109.relative)(rulesyncBaseDir, file);
14205
- checkPathTraversal({ relativePath: relativeFilePath, intendedRootDir: rulesyncBaseDir });
14316
+ checkPathTraversal({
14317
+ relativePath: relativeFilePath,
14318
+ intendedRootDir: rulesyncBaseDir
14319
+ });
14206
14320
  return RulesyncRule.fromFile({
14207
14321
  relativeFilePath
14208
14322
  });
@@ -14253,7 +14367,9 @@ var RulesProcessor = class extends FeatureProcessor {
14253
14367
  } = {}) {
14254
14368
  try {
14255
14369
  const factory = this.getFactory(this.toolTarget);
14256
- const settablePaths = factory.class.getSettablePaths({ global: this.global });
14370
+ const settablePaths = factory.class.getSettablePaths({
14371
+ global: this.global
14372
+ });
14257
14373
  const rootToolRules = await (async () => {
14258
14374
  if (!settablePaths.root) {
14259
14375
  return [];
@@ -14335,7 +14451,10 @@ var RulesProcessor = class extends FeatureProcessor {
14335
14451
  return await Promise.all(
14336
14452
  nonRootFilePaths.map((filePath) => {
14337
14453
  const relativeFilePath = (0, import_node_path109.relative)(nonRootBaseDir, filePath);
14338
- checkPathTraversal({ relativePath: relativeFilePath, intendedRootDir: nonRootBaseDir });
14454
+ checkPathTraversal({
14455
+ relativePath: relativeFilePath,
14456
+ intendedRootDir: nonRootBaseDir
14457
+ });
14339
14458
  return factory.class.fromFile({
14340
14459
  baseDir: this.baseDir,
14341
14460
  relativeFilePath,
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  generate,
7
7
  importFromTool,
8
8
  logger
9
- } from "./chunk-NRNUPCXY.js";
9
+ } from "./chunk-UCC3WPDL.js";
10
10
 
11
11
  // src/index.ts
12
12
  async function generate2(options = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rulesync",
3
- "version": "7.3.0",
3
+ "version": "7.4.0",
4
4
  "description": "Unified AI rules management CLI tool that generates configuration files for various AI development tools",
5
5
  "keywords": [
6
6
  "ai",
@@ -85,7 +85,6 @@
85
85
  "eslint-plugin-zod-import": "0.3.0",
86
86
  "knip": "5.83.1",
87
87
  "lint-staged": "16.2.7",
88
- "marked": "17.0.2",
89
88
  "oxfmt": "0.31.0",
90
89
  "oxlint": "1.46.0",
91
90
  "repomix": "1.11.1",
@@ -97,6 +96,7 @@
97
96
  "tsx": "4.21.0",
98
97
  "typescript": "5.9.3",
99
98
  "typescript-eslint": "8.55.0",
99
+ "vitepress": "1.6.4",
100
100
  "vitest": "4.0.18"
101
101
  },
102
102
  "engines": {
@@ -113,6 +113,9 @@
113
113
  "cicheck:content": "pnpm run cspell && pnpm run secretlint",
114
114
  "cspell": "cspell --no-progress --gitignore .",
115
115
  "dev": "tsx src/cli/index.ts",
116
+ "docs:build": "vitepress build docs",
117
+ "docs:dev": "vitepress dev docs",
118
+ "docs:preview": "vitepress serve docs",
116
119
  "eslint": "eslint . --max-warnings 0 --cache",
117
120
  "eslint:fix": "eslint . --fix --max-warnings 0 --cache",
118
121
  "fix": "pnpm run fmt && pnpm run oxlint:fix && pnpm run eslint:fix",