rulesync 3.28.1 → 3.28.2

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
@@ -213,11 +213,28 @@ npx rulesync gitignore
213
213
 
214
214
  You can configure Rulesync by creating a `rulesync.jsonc` file in the root of your project.
215
215
 
216
+ ### JSON Schema Support
217
+
218
+ Rulesync provides a JSON Schema for editor validation and autocompletion. Add the `$schema` property to your `rulesync.jsonc`:
219
+
220
+ ```jsonc
221
+ // rulesync.jsonc
222
+ {
223
+ "$schema": "https://raw.githubusercontent.com/dyoshikawa/rulesync/refs/heads/main/config-schema.json",
224
+ "targets": ["claudecode"],
225
+ "features": ["rules"]
226
+ }
227
+ ```
228
+
229
+ ### Configuration Options
230
+
216
231
  Example:
217
232
 
218
233
  ```jsonc
219
234
  // rulesync.jsonc
220
235
  {
236
+ "$schema": "https://raw.githubusercontent.com/dyoshikawa/rulesync/refs/heads/main/config-schema.json",
237
+
221
238
  // List of tools to generate configurations for. You can specify "*" to generate all tools.
222
239
  "targets": ["cursor", "claudecode", "geminicli", "opencode", "codexcli"],
223
240
 
package/dist/index.cjs CHANGED
@@ -290,6 +290,10 @@ var ConfigParamsSchema = import_mini3.z.object({
290
290
  experimentalSimulateSubagents: (0, import_mini3.optional)(import_mini3.z.boolean())
291
291
  });
292
292
  var PartialConfigParamsSchema = import_mini3.z.partial(ConfigParamsSchema);
293
+ var ConfigFileSchema = import_mini3.z.object({
294
+ $schema: (0, import_mini3.optional)(import_mini3.z.string()),
295
+ ...import_mini3.z.partial(ConfigParamsSchema).shape
296
+ });
293
297
  var RequiredConfigParamsSchema = import_mini3.z.required(ConfigParamsSchema);
294
298
  var Config = class {
295
299
  baseDirs;
@@ -419,7 +423,9 @@ var ConfigResolver = class {
419
423
  try {
420
424
  const fileContent = await readFileContent(validatedConfigPath);
421
425
  const jsonData = (0, import_jsonc_parser.parse)(fileContent);
422
- configByFile = PartialConfigParamsSchema.parse(jsonData);
426
+ const parsed = ConfigFileSchema.parse(jsonData);
427
+ const { $schema: _schema, ...configParams2 } = parsed;
428
+ configByFile = configParams2;
423
429
  } catch (error) {
424
430
  logger.error(`Failed to load config file: ${formatError(error)}`);
425
431
  throw error;
@@ -665,6 +671,13 @@ var AiFile = class {
665
671
  setFileContent(newFileContent) {
666
672
  this.fileContent = newFileContent;
667
673
  }
674
+ /**
675
+ * Returns whether this file can be deleted by rulesync.
676
+ * Override in subclasses that should not be deleted (e.g., user-managed config files).
677
+ */
678
+ isDeletable() {
679
+ return true;
680
+ }
668
681
  };
669
682
 
670
683
  // src/features/commands/tool-command.ts
@@ -2324,6 +2337,13 @@ var ClaudecodeIgnore = class _ClaudecodeIgnore extends ToolIgnore {
2324
2337
  relativeFilePath: "settings.local.json"
2325
2338
  };
2326
2339
  }
2340
+ /**
2341
+ * ClaudecodeIgnore uses settings.local.json which is a user-managed config file.
2342
+ * It should not be deleted by rulesync.
2343
+ */
2344
+ isDeletable() {
2345
+ return false;
2346
+ }
2327
2347
  toRulesyncIgnore() {
2328
2348
  const rulesyncPatterns = this.patterns.map((pattern) => {
2329
2349
  if (pattern.startsWith("Read(") && pattern.endsWith(")")) {
@@ -2814,7 +2834,7 @@ var IgnoreProcessor = class extends FeatureProcessor {
2814
2834
  try {
2815
2835
  const toolIgnores = await this.loadToolIgnores();
2816
2836
  if (forDeletion) {
2817
- return toolIgnores.filter((toolFile) => !(toolFile instanceof ClaudecodeIgnore));
2837
+ return toolIgnores.filter((toolFile) => toolFile.isDeletable());
2818
2838
  }
2819
2839
  return toolIgnores;
2820
2840
  } catch (error) {
@@ -3316,6 +3336,14 @@ var ClaudecodeMcp = class _ClaudecodeMcp extends ToolMcp {
3316
3336
  getJson() {
3317
3337
  return this.json;
3318
3338
  }
3339
+ /**
3340
+ * In global mode, ~/.claude/.claude.json should not be deleted
3341
+ * as it may contain other user settings.
3342
+ * In local mode, .mcp.json can be safely deleted.
3343
+ */
3344
+ isDeletable() {
3345
+ return !this.global;
3346
+ }
3319
3347
  static getSettablePaths({ global } = {}) {
3320
3348
  if (global) {
3321
3349
  return {
@@ -3898,6 +3926,12 @@ var OpencodeMcp = class _OpencodeMcp extends ToolMcp {
3898
3926
  getJson() {
3899
3927
  return this.json;
3900
3928
  }
3929
+ /**
3930
+ * opencode.json may contain other settings, so it should not be deleted.
3931
+ */
3932
+ isDeletable() {
3933
+ return false;
3934
+ }
3901
3935
  static getSettablePaths({ global } = {}) {
3902
3936
  if (global) {
3903
3937
  return {
@@ -4182,11 +4216,7 @@ var McpProcessor = class extends FeatureProcessor {
4182
4216
  })();
4183
4217
  logger.info(`Successfully loaded ${toolMcps.length} ${this.toolTarget} MCP files`);
4184
4218
  if (forDeletion) {
4185
- let filteredMcps = toolMcps.filter((toolFile) => !(toolFile instanceof OpencodeMcp));
4186
- if (this.global) {
4187
- filteredMcps = filteredMcps.filter((toolFile) => !(toolFile instanceof ClaudecodeMcp));
4188
- }
4189
- return filteredMcps;
4219
+ return toolMcps.filter((toolFile) => toolFile.isDeletable());
4190
4220
  }
4191
4221
  return toolMcps;
4192
4222
  } catch (error) {
@@ -4567,20 +4597,13 @@ var SimulatedSkill = class extends ToolSkill {
4567
4597
  name: rulesyncFrontmatter.name,
4568
4598
  description: rulesyncFrontmatter.description
4569
4599
  };
4570
- const otherFiles = rulesyncSkill.getOtherFiles();
4571
- if (otherFiles.length > 0) {
4572
- logger.warn(
4573
- `Skill "${rulesyncFrontmatter.name}" has ${otherFiles.length} additional file(s) that will be ignored for simulated skill generation.`
4574
- );
4575
- }
4576
4600
  return {
4577
4601
  baseDir: rulesyncSkill.getBaseDir(),
4578
4602
  relativeDirPath: this.getSettablePaths().relativeDirPath,
4579
4603
  dirName: rulesyncSkill.getDirName(),
4580
4604
  frontmatter: simulatedFrontmatter,
4581
4605
  body: rulesyncSkill.getBody(),
4582
- otherFiles: [],
4583
- // Simulated skills ignore otherFiles
4606
+ otherFiles: rulesyncSkill.getOtherFiles(),
4584
4607
  validate
4585
4608
  };
4586
4609
  }
@@ -4602,14 +4625,19 @@ var SimulatedSkill = class extends ToolSkill {
4602
4625
  if (!result.success) {
4603
4626
  throw new Error(`Invalid frontmatter in ${skillFilePath}: ${formatError(result.error)}`);
4604
4627
  }
4628
+ const otherFiles = await this.collectOtherFiles(
4629
+ baseDir,
4630
+ actualRelativeDirPath,
4631
+ dirName,
4632
+ SKILL_FILE_NAME
4633
+ );
4605
4634
  return {
4606
4635
  baseDir,
4607
4636
  relativeDirPath: actualRelativeDirPath,
4608
4637
  dirName,
4609
4638
  frontmatter: result.data,
4610
4639
  body: content.trim(),
4611
- otherFiles: [],
4612
- // Simulated skills ignore otherFiles
4640
+ otherFiles,
4613
4641
  validate: true
4614
4642
  };
4615
4643
  }
@@ -10240,7 +10268,7 @@ async function mcpCommand({ version }) {
10240
10268
  }
10241
10269
 
10242
10270
  // src/cli/index.ts
10243
- var getVersion = () => "3.28.1";
10271
+ var getVersion = () => "3.28.2";
10244
10272
  var main = async () => {
10245
10273
  const program = new import_commander.Command();
10246
10274
  const version = getVersion();
package/dist/index.js CHANGED
@@ -267,6 +267,10 @@ var ConfigParamsSchema = z3.object({
267
267
  experimentalSimulateSubagents: optional(z3.boolean())
268
268
  });
269
269
  var PartialConfigParamsSchema = z3.partial(ConfigParamsSchema);
270
+ var ConfigFileSchema = z3.object({
271
+ $schema: optional(z3.string()),
272
+ ...z3.partial(ConfigParamsSchema).shape
273
+ });
270
274
  var RequiredConfigParamsSchema = z3.required(ConfigParamsSchema);
271
275
  var Config = class {
272
276
  baseDirs;
@@ -396,7 +400,9 @@ var ConfigResolver = class {
396
400
  try {
397
401
  const fileContent = await readFileContent(validatedConfigPath);
398
402
  const jsonData = parseJsonc(fileContent);
399
- configByFile = PartialConfigParamsSchema.parse(jsonData);
403
+ const parsed = ConfigFileSchema.parse(jsonData);
404
+ const { $schema: _schema, ...configParams2 } = parsed;
405
+ configByFile = configParams2;
400
406
  } catch (error) {
401
407
  logger.error(`Failed to load config file: ${formatError(error)}`);
402
408
  throw error;
@@ -642,6 +648,13 @@ var AiFile = class {
642
648
  setFileContent(newFileContent) {
643
649
  this.fileContent = newFileContent;
644
650
  }
651
+ /**
652
+ * Returns whether this file can be deleted by rulesync.
653
+ * Override in subclasses that should not be deleted (e.g., user-managed config files).
654
+ */
655
+ isDeletable() {
656
+ return true;
657
+ }
645
658
  };
646
659
 
647
660
  // src/features/commands/tool-command.ts
@@ -2301,6 +2314,13 @@ var ClaudecodeIgnore = class _ClaudecodeIgnore extends ToolIgnore {
2301
2314
  relativeFilePath: "settings.local.json"
2302
2315
  };
2303
2316
  }
2317
+ /**
2318
+ * ClaudecodeIgnore uses settings.local.json which is a user-managed config file.
2319
+ * It should not be deleted by rulesync.
2320
+ */
2321
+ isDeletable() {
2322
+ return false;
2323
+ }
2304
2324
  toRulesyncIgnore() {
2305
2325
  const rulesyncPatterns = this.patterns.map((pattern) => {
2306
2326
  if (pattern.startsWith("Read(") && pattern.endsWith(")")) {
@@ -2791,7 +2811,7 @@ var IgnoreProcessor = class extends FeatureProcessor {
2791
2811
  try {
2792
2812
  const toolIgnores = await this.loadToolIgnores();
2793
2813
  if (forDeletion) {
2794
- return toolIgnores.filter((toolFile) => !(toolFile instanceof ClaudecodeIgnore));
2814
+ return toolIgnores.filter((toolFile) => toolFile.isDeletable());
2795
2815
  }
2796
2816
  return toolIgnores;
2797
2817
  } catch (error) {
@@ -3293,6 +3313,14 @@ var ClaudecodeMcp = class _ClaudecodeMcp extends ToolMcp {
3293
3313
  getJson() {
3294
3314
  return this.json;
3295
3315
  }
3316
+ /**
3317
+ * In global mode, ~/.claude/.claude.json should not be deleted
3318
+ * as it may contain other user settings.
3319
+ * In local mode, .mcp.json can be safely deleted.
3320
+ */
3321
+ isDeletable() {
3322
+ return !this.global;
3323
+ }
3296
3324
  static getSettablePaths({ global } = {}) {
3297
3325
  if (global) {
3298
3326
  return {
@@ -3875,6 +3903,12 @@ var OpencodeMcp = class _OpencodeMcp extends ToolMcp {
3875
3903
  getJson() {
3876
3904
  return this.json;
3877
3905
  }
3906
+ /**
3907
+ * opencode.json may contain other settings, so it should not be deleted.
3908
+ */
3909
+ isDeletable() {
3910
+ return false;
3911
+ }
3878
3912
  static getSettablePaths({ global } = {}) {
3879
3913
  if (global) {
3880
3914
  return {
@@ -4159,11 +4193,7 @@ var McpProcessor = class extends FeatureProcessor {
4159
4193
  })();
4160
4194
  logger.info(`Successfully loaded ${toolMcps.length} ${this.toolTarget} MCP files`);
4161
4195
  if (forDeletion) {
4162
- let filteredMcps = toolMcps.filter((toolFile) => !(toolFile instanceof OpencodeMcp));
4163
- if (this.global) {
4164
- filteredMcps = filteredMcps.filter((toolFile) => !(toolFile instanceof ClaudecodeMcp));
4165
- }
4166
- return filteredMcps;
4196
+ return toolMcps.filter((toolFile) => toolFile.isDeletable());
4167
4197
  }
4168
4198
  return toolMcps;
4169
4199
  } catch (error) {
@@ -4544,20 +4574,13 @@ var SimulatedSkill = class extends ToolSkill {
4544
4574
  name: rulesyncFrontmatter.name,
4545
4575
  description: rulesyncFrontmatter.description
4546
4576
  };
4547
- const otherFiles = rulesyncSkill.getOtherFiles();
4548
- if (otherFiles.length > 0) {
4549
- logger.warn(
4550
- `Skill "${rulesyncFrontmatter.name}" has ${otherFiles.length} additional file(s) that will be ignored for simulated skill generation.`
4551
- );
4552
- }
4553
4577
  return {
4554
4578
  baseDir: rulesyncSkill.getBaseDir(),
4555
4579
  relativeDirPath: this.getSettablePaths().relativeDirPath,
4556
4580
  dirName: rulesyncSkill.getDirName(),
4557
4581
  frontmatter: simulatedFrontmatter,
4558
4582
  body: rulesyncSkill.getBody(),
4559
- otherFiles: [],
4560
- // Simulated skills ignore otherFiles
4583
+ otherFiles: rulesyncSkill.getOtherFiles(),
4561
4584
  validate
4562
4585
  };
4563
4586
  }
@@ -4579,14 +4602,19 @@ var SimulatedSkill = class extends ToolSkill {
4579
4602
  if (!result.success) {
4580
4603
  throw new Error(`Invalid frontmatter in ${skillFilePath}: ${formatError(result.error)}`);
4581
4604
  }
4605
+ const otherFiles = await this.collectOtherFiles(
4606
+ baseDir,
4607
+ actualRelativeDirPath,
4608
+ dirName,
4609
+ SKILL_FILE_NAME
4610
+ );
4582
4611
  return {
4583
4612
  baseDir,
4584
4613
  relativeDirPath: actualRelativeDirPath,
4585
4614
  dirName,
4586
4615
  frontmatter: result.data,
4587
4616
  body: content.trim(),
4588
- otherFiles: [],
4589
- // Simulated skills ignore otherFiles
4617
+ otherFiles,
4590
4618
  validate: true
4591
4619
  };
4592
4620
  }
@@ -10217,7 +10245,7 @@ async function mcpCommand({ version }) {
10217
10245
  }
10218
10246
 
10219
10247
  // src/cli/index.ts
10220
- var getVersion = () => "3.28.1";
10248
+ var getVersion = () => "3.28.2";
10221
10249
  var main = async () => {
10222
10250
  const program = new Command();
10223
10251
  const version = getVersion();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rulesync",
3
- "version": "3.28.1",
3
+ "version": "3.28.2",
4
4
  "description": "Unified AI rules management CLI tool that generates configuration files for various AI development tools",
5
5
  "keywords": [
6
6
  "ai",
@@ -49,15 +49,15 @@
49
49
  "zod": "4.1.13"
50
50
  },
51
51
  "devDependencies": {
52
- "@anthropic-ai/claude-agent-sdk": "0.1.53",
53
- "@biomejs/biome": "2.3.7",
52
+ "@anthropic-ai/claude-agent-sdk": "0.1.55",
53
+ "@biomejs/biome": "2.3.8",
54
54
  "@eslint/js": "9.39.1",
55
55
  "@secretlint/secretlint-rule-preset-recommend": "11.2.5",
56
56
  "@tsconfig/node24": "24.0.3",
57
57
  "@types/js-yaml": "4.0.9",
58
58
  "@types/node": "24.10.1",
59
- "@typescript/native-preview": "7.0.0-dev.20251125.1",
60
- "@vitest/coverage-v8": "4.0.13",
59
+ "@typescript/native-preview": "7.0.0-dev.20251130.1",
60
+ "@vitest/coverage-v8": "4.0.14",
61
61
  "cspell": "9.3.2",
62
62
  "eslint": "9.39.1",
63
63
  "eslint-plugin-import": "2.32.0",
@@ -70,12 +70,12 @@
70
70
  "oxlint": "1.30.0",
71
71
  "secretlint": "11.2.5",
72
72
  "simple-git-hooks": "2.13.1",
73
- "sort-package-json": "3.4.0",
73
+ "sort-package-json": "3.5.0",
74
74
  "tsup": "8.5.1",
75
- "tsx": "4.20.6",
75
+ "tsx": "4.21.0",
76
76
  "typescript": "5.9.3",
77
77
  "typescript-eslint": "8.48.0",
78
- "vitest": "4.0.13"
78
+ "vitest": "4.0.14"
79
79
  },
80
80
  "engines": {
81
81
  "node": ">=22.0.0"
@@ -98,6 +98,7 @@
98
98
  "eslint:fix": "eslint . --fix --max-warnings 0 --cache",
99
99
  "fix": "pnpm run bcheck:fix && pnpm run oxlint:fix && pnpm run eslint:fix",
100
100
  "generate": "pnpm run dev generate",
101
+ "generate:schema": "tsx scripts/generate-json-schema.ts",
101
102
  "knip": "knip",
102
103
  "oxlint": "oxlint . --max-warnings 0",
103
104
  "oxlint:fix": "oxlint . --fix --max-warnings 0",