rulesync 7.30.0 → 8.0.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.
@@ -6501,7 +6501,8 @@ var ClaudecodeMcp = class _ClaudecodeMcp extends ToolMcp {
6501
6501
  relativeDirPath: paths.relativeDirPath,
6502
6502
  relativeFilePath: paths.relativeFilePath,
6503
6503
  fileContent: JSON.stringify(newJson, null, 2),
6504
- validate
6504
+ validate,
6505
+ global
6505
6506
  });
6506
6507
  }
6507
6508
  static async fromRulesyncMcp({
@@ -6522,7 +6523,8 @@ var ClaudecodeMcp = class _ClaudecodeMcp extends ToolMcp {
6522
6523
  relativeDirPath: paths.relativeDirPath,
6523
6524
  relativeFilePath: paths.relativeFilePath,
6524
6525
  fileContent: JSON.stringify(mcpJson, null, 2),
6525
- validate
6526
+ validate,
6527
+ global
6526
6528
  });
6527
6529
  }
6528
6530
  toRulesyncMcp() {
@@ -17931,14 +17933,21 @@ var WindsurfRule = class _WindsurfRule extends ToolRule {
17931
17933
  rulesyncRule,
17932
17934
  validate = true
17933
17935
  }) {
17934
- return new _WindsurfRule(
17935
- this.buildToolRuleParamsDefault({
17936
- baseDir,
17937
- rulesyncRule,
17938
- validate,
17939
- nonRootPath: this.getSettablePaths().nonRoot
17940
- })
17941
- );
17936
+ const toolRuleParams = this.buildToolRuleParamsDefault({
17937
+ baseDir,
17938
+ rulesyncRule,
17939
+ validate,
17940
+ nonRootPath: this.getSettablePaths().nonRoot
17941
+ });
17942
+ const windsurfFrontmatter = this.buildWindsurfFrontmatter({
17943
+ relativeFilePath: rulesyncRule.getRelativeFilePath(),
17944
+ description: rulesyncRule.getFrontmatter().description,
17945
+ globs: rulesyncRule.getFrontmatter().globs
17946
+ });
17947
+ return new _WindsurfRule({
17948
+ ...toolRuleParams,
17949
+ fileContent: stringifyFrontmatter(rulesyncRule.getBody(), windsurfFrontmatter)
17950
+ });
17942
17951
  }
17943
17952
  toRulesyncRule() {
17944
17953
  return this.toRulesyncRuleDefault();
@@ -17965,6 +17974,18 @@ var WindsurfRule = class _WindsurfRule extends ToolRule {
17965
17974
  toolTarget: "windsurf"
17966
17975
  });
17967
17976
  }
17977
+ static buildWindsurfFrontmatter({
17978
+ relativeFilePath,
17979
+ description,
17980
+ globs
17981
+ }) {
17982
+ const hasSpecificGlobs = Boolean(globs && globs.length > 0 && !globs.includes("**/*"));
17983
+ return {
17984
+ title: description ?? relativeFilePath.replace(/\.md$/, ""),
17985
+ trigger: hasSpecificGlobs ? "glob" : "always_on",
17986
+ ...hasSpecificGlobs && { globs }
17987
+ };
17988
+ }
17968
17989
  };
17969
17990
 
17970
17991
  // src/features/rules/rules-processor.ts
@@ -17997,6 +18018,28 @@ var rulesProcessorToolTargets = [
17997
18018
  ];
17998
18019
  var RulesProcessorToolTargetSchema = import_mini65.z.enum(rulesProcessorToolTargets);
17999
18020
  var formatRulePaths = (rules) => rules.map((r) => (0, import_node_path131.join)(r.getRelativeDirPath(), r.getRelativeFilePath())).join(", ");
18021
+ var RulesFeatureOptionsSchema = import_mini65.z.looseObject({
18022
+ ruleDiscoveryMode: import_mini65.z.optional(import_mini65.z.enum(["none", "explicit"]))
18023
+ });
18024
+ var resolveRuleDiscoveryMode = ({
18025
+ defaultMode,
18026
+ options
18027
+ }) => {
18028
+ if (defaultMode === "claudecode-legacy") {
18029
+ return defaultMode;
18030
+ }
18031
+ if (!options) return defaultMode;
18032
+ const parsed = RulesFeatureOptionsSchema.safeParse(options);
18033
+ if (!parsed.success) {
18034
+ throw new Error(
18035
+ `Invalid options for rules feature: ${parsed.error.message}. \`ruleDiscoveryMode\` must be either "none" or "explicit".`
18036
+ );
18037
+ }
18038
+ if (!parsed.data.ruleDiscoveryMode) {
18039
+ return defaultMode;
18040
+ }
18041
+ return parsed.data.ruleDiscoveryMode === "none" ? "auto" : "toon";
18042
+ };
18000
18043
  var toolRuleFactories = /* @__PURE__ */ new Map([
18001
18044
  [
18002
18045
  "agentsmd",
@@ -18311,6 +18354,7 @@ var RulesProcessor = class extends FeatureProcessor {
18311
18354
  global;
18312
18355
  getFactory;
18313
18356
  skills;
18357
+ featureOptions;
18314
18358
  constructor({
18315
18359
  baseDir = process.cwd(),
18316
18360
  toolTarget,
@@ -18320,6 +18364,7 @@ var RulesProcessor = class extends FeatureProcessor {
18320
18364
  global = false,
18321
18365
  getFactory = defaultGetFactory6,
18322
18366
  skills,
18367
+ featureOptions,
18323
18368
  dryRun = false,
18324
18369
  logger: logger5
18325
18370
  }) {
@@ -18337,6 +18382,7 @@ var RulesProcessor = class extends FeatureProcessor {
18337
18382
  this.simulateSkills = simulateSkills;
18338
18383
  this.getFactory = getFactory;
18339
18384
  this.skills = skills;
18385
+ this.featureOptions = featureOptions;
18340
18386
  }
18341
18387
  async convertRulesyncFilesToToolFiles(rulesyncFiles) {
18342
18388
  const rulesyncRules = rulesyncFiles.filter(
@@ -18494,7 +18540,11 @@ var RulesProcessor = class extends FeatureProcessor {
18494
18540
  * Generate reference section based on meta configuration.
18495
18541
  */
18496
18542
  generateReferenceSectionFromMeta(meta, toolRules) {
18497
- switch (meta.ruleDiscoveryMode) {
18543
+ const mode = resolveRuleDiscoveryMode({
18544
+ defaultMode: meta.ruleDiscoveryMode,
18545
+ options: this.featureOptions
18546
+ });
18547
+ switch (mode) {
18498
18548
  case "toon":
18499
18549
  return this.generateToonReferencesSection(toolRules);
18500
18550
  case "claudecode-legacy":
@@ -20243,11 +20293,11 @@ function getBaseDirsInLightOfGlobal({
20243
20293
  }
20244
20294
 
20245
20295
  // src/lib/generate.ts
20246
- var import_node_path138 = require("path");
20296
+ var import_node_path140 = require("path");
20247
20297
  var import_es_toolkit5 = require("es-toolkit");
20248
20298
 
20249
20299
  // src/features/permissions/permissions-processor.ts
20250
- var import_mini72 = require("zod/mini");
20300
+ var import_mini73 = require("zod/mini");
20251
20301
 
20252
20302
  // src/features/permissions/claudecode-permissions.ts
20253
20303
  var import_node_path136 = require("path");
@@ -20572,16 +20622,382 @@ function convertClaudeToRulesyncPermissions(params) {
20572
20622
  return { permission };
20573
20623
  }
20574
20624
 
20575
- // src/features/permissions/opencode-permissions.ts
20625
+ // src/features/permissions/codexcli-permissions.ts
20576
20626
  var import_node_path137 = require("path");
20577
- var import_jsonc_parser5 = require("jsonc-parser");
20627
+ var smolToml5 = __toESM(require("smol-toml"), 1);
20628
+ var RULESYNC_PROFILE_NAME = "rulesync";
20629
+ var CodexcliPermissions = class _CodexcliPermissions extends ToolPermissions {
20630
+ static getSettablePaths(_options = {}) {
20631
+ return {
20632
+ relativeDirPath: ".codex",
20633
+ relativeFilePath: "config.toml"
20634
+ };
20635
+ }
20636
+ isDeletable() {
20637
+ return false;
20638
+ }
20639
+ static async fromFile({
20640
+ baseDir = process.cwd(),
20641
+ validate = true,
20642
+ global = false
20643
+ }) {
20644
+ const paths = this.getSettablePaths({ global });
20645
+ const filePath = (0, import_node_path137.join)(baseDir, paths.relativeDirPath, paths.relativeFilePath);
20646
+ const fileContent = await readFileContentOrNull(filePath) ?? smolToml5.stringify({});
20647
+ return new _CodexcliPermissions({
20648
+ baseDir,
20649
+ relativeDirPath: paths.relativeDirPath,
20650
+ relativeFilePath: paths.relativeFilePath,
20651
+ fileContent,
20652
+ validate
20653
+ });
20654
+ }
20655
+ static async fromRulesyncPermissions({
20656
+ baseDir = process.cwd(),
20657
+ rulesyncPermissions,
20658
+ validate = true,
20659
+ logger: logger5,
20660
+ global = false
20661
+ }) {
20662
+ const paths = this.getSettablePaths({ global });
20663
+ const filePath = (0, import_node_path137.join)(baseDir, paths.relativeDirPath, paths.relativeFilePath);
20664
+ const existingContent = await readFileContentOrNull(filePath) ?? smolToml5.stringify({});
20665
+ const parsed = toMutableTable(smolToml5.parse(existingContent));
20666
+ const profile = convertRulesyncToCodexProfile({
20667
+ config: rulesyncPermissions.getJson(),
20668
+ logger: logger5
20669
+ });
20670
+ const permissionsTable = toMutableTable(parsed.permissions);
20671
+ permissionsTable[RULESYNC_PROFILE_NAME] = profile;
20672
+ parsed.permissions = permissionsTable;
20673
+ parsed.default_permissions = RULESYNC_PROFILE_NAME;
20674
+ return new _CodexcliPermissions({
20675
+ baseDir,
20676
+ relativeDirPath: paths.relativeDirPath,
20677
+ relativeFilePath: paths.relativeFilePath,
20678
+ fileContent: smolToml5.stringify(parsed),
20679
+ validate
20680
+ });
20681
+ }
20682
+ toRulesyncPermissions() {
20683
+ let parsed;
20684
+ try {
20685
+ parsed = smolToml5.parse(this.getFileContent());
20686
+ } catch (error) {
20687
+ throw new Error(
20688
+ `Failed to parse Codex CLI permissions content in ${(0, import_node_path137.join)(this.getRelativeDirPath(), this.getRelativeFilePath())}: ${formatError(error)}`,
20689
+ { cause: error }
20690
+ );
20691
+ }
20692
+ const table = toMutableTable(parsed);
20693
+ const defaultProfile = typeof table.default_permissions === "string" ? table.default_permissions : void 0;
20694
+ const permissionsTable = toMutableTable(table.permissions);
20695
+ const profile = toCodexProfile(permissionsTable[defaultProfile ?? RULESYNC_PROFILE_NAME]) ?? toCodexProfile(permissionsTable[RULESYNC_PROFILE_NAME]);
20696
+ const config = convertCodexProfileToRulesync(profile);
20697
+ return this.toRulesyncPermissionsDefault({
20698
+ fileContent: JSON.stringify(config, null, 2)
20699
+ });
20700
+ }
20701
+ validate() {
20702
+ return { success: true, error: null };
20703
+ }
20704
+ static forDeletion({
20705
+ baseDir = process.cwd(),
20706
+ relativeDirPath,
20707
+ relativeFilePath
20708
+ }) {
20709
+ return new _CodexcliPermissions({
20710
+ baseDir,
20711
+ relativeDirPath,
20712
+ relativeFilePath,
20713
+ fileContent: smolToml5.stringify({}),
20714
+ validate: false
20715
+ });
20716
+ }
20717
+ };
20718
+ function convertRulesyncToCodexProfile({
20719
+ config,
20720
+ logger: logger5
20721
+ }) {
20722
+ const filesystem = {};
20723
+ const domains = {};
20724
+ for (const [toolName, rules] of Object.entries(config.permission)) {
20725
+ if (toolName === "read") {
20726
+ for (const [pattern, action] of Object.entries(rules)) {
20727
+ filesystem[pattern] = mapReadAction(action);
20728
+ }
20729
+ continue;
20730
+ }
20731
+ if (toolName === "edit" || toolName === "write") {
20732
+ for (const [pattern, action] of Object.entries(rules)) {
20733
+ filesystem[pattern] = mapWriteAction(action);
20734
+ }
20735
+ continue;
20736
+ }
20737
+ if (toolName === "webfetch") {
20738
+ for (const [pattern, action] of Object.entries(rules)) {
20739
+ if (action === "ask") {
20740
+ logger5?.warn(
20741
+ `Codex CLI does not support "ask" for network domain permissions. Skipping webfetch rule: ${pattern}`
20742
+ );
20743
+ continue;
20744
+ }
20745
+ domains[pattern] = action;
20746
+ }
20747
+ continue;
20748
+ }
20749
+ logger5?.warn(
20750
+ `Codex CLI permissions support only read/edit/write/webfetch categories. Skipping: ${toolName}`
20751
+ );
20752
+ }
20753
+ return {
20754
+ ...Object.keys(filesystem).length > 0 ? { filesystem } : {},
20755
+ ...Object.keys(domains).length > 0 ? { network: { domains } } : {}
20756
+ };
20757
+ }
20758
+ function convertCodexProfileToRulesync(profile) {
20759
+ const permission = {};
20760
+ if (profile?.filesystem) {
20761
+ permission.read = {};
20762
+ permission.edit = {};
20763
+ for (const [pattern, access] of Object.entries(profile.filesystem)) {
20764
+ if (access === "none") {
20765
+ permission.read[pattern] = "deny";
20766
+ permission.edit[pattern] = "deny";
20767
+ } else if (access === "read") {
20768
+ permission.read[pattern] = "allow";
20769
+ } else {
20770
+ permission.edit[pattern] = "allow";
20771
+ }
20772
+ }
20773
+ }
20774
+ if (profile?.network?.domains) {
20775
+ permission.webfetch = {};
20776
+ for (const [domain, value] of Object.entries(profile.network.domains)) {
20777
+ permission.webfetch[domain] = value;
20778
+ }
20779
+ }
20780
+ return { permission };
20781
+ }
20782
+ function toCodexProfile(value) {
20783
+ if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
20784
+ const table = toMutableTable(value);
20785
+ const filesystem = toFilesystemRecord(table.filesystem);
20786
+ const networkRaw = toMutableTable(table.network);
20787
+ const domains = toDomainRecord(networkRaw.domains);
20788
+ return {
20789
+ ...filesystem ? { filesystem } : {},
20790
+ ...domains ? { network: { domains } } : {}
20791
+ };
20792
+ }
20793
+ function toMutableTable(value) {
20794
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
20795
+ return {};
20796
+ }
20797
+ return { ...value };
20798
+ }
20799
+ function toFilesystemRecord(value) {
20800
+ if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
20801
+ const result = {};
20802
+ for (const [key, raw] of Object.entries(value)) {
20803
+ if (typeof raw !== "string") continue;
20804
+ if (raw === "read" || raw === "write" || raw === "none") {
20805
+ result[key] = raw;
20806
+ }
20807
+ }
20808
+ return Object.keys(result).length > 0 ? result : void 0;
20809
+ }
20810
+ function toDomainRecord(value) {
20811
+ if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
20812
+ const result = {};
20813
+ for (const [key, raw] of Object.entries(value)) {
20814
+ if (raw === "allow" || raw === "deny") {
20815
+ result[key] = raw;
20816
+ }
20817
+ }
20818
+ return Object.keys(result).length > 0 ? result : void 0;
20819
+ }
20820
+ function mapReadAction(action) {
20821
+ return action === "allow" ? "read" : "none";
20822
+ }
20823
+ function mapWriteAction(action) {
20824
+ return action === "allow" ? "write" : "none";
20825
+ }
20826
+
20827
+ // src/features/permissions/geminicli-permissions.ts
20828
+ var import_node_path138 = require("path");
20578
20829
  var import_mini71 = require("zod/mini");
20579
- var OpencodePermissionSchema = import_mini71.z.union([
20580
- import_mini71.z.enum(["allow", "ask", "deny"]),
20581
- import_mini71.z.record(import_mini71.z.string(), import_mini71.z.enum(["allow", "ask", "deny"]))
20830
+ var GeminiCliSettingsSchema = import_mini71.z.looseObject({
20831
+ tools: import_mini71.z.optional(
20832
+ import_mini71.z.looseObject({
20833
+ allowed: import_mini71.z.optional(import_mini71.z.array(import_mini71.z.string())),
20834
+ exclude: import_mini71.z.optional(import_mini71.z.array(import_mini71.z.string()))
20835
+ })
20836
+ )
20837
+ });
20838
+ var RULESYNC_TO_GEMINICLI_TOOL_NAME = {
20839
+ bash: "run_shell_command",
20840
+ read: "read_file",
20841
+ edit: "replace",
20842
+ write: "write_file",
20843
+ webfetch: "web_fetch"
20844
+ };
20845
+ var GeminicliPermissions = class _GeminicliPermissions extends ToolPermissions {
20846
+ static getSettablePaths(_options = {}) {
20847
+ return {
20848
+ relativeDirPath: ".gemini",
20849
+ relativeFilePath: "settings.json"
20850
+ };
20851
+ }
20852
+ isDeletable() {
20853
+ return false;
20854
+ }
20855
+ static async fromFile({
20856
+ baseDir = process.cwd(),
20857
+ validate = true,
20858
+ global = false
20859
+ }) {
20860
+ const paths = this.getSettablePaths({ global });
20861
+ const filePath = (0, import_node_path138.join)(baseDir, paths.relativeDirPath, paths.relativeFilePath);
20862
+ const fileContent = await readFileContentOrNull(filePath) ?? JSON.stringify({}, null, 2);
20863
+ return new _GeminicliPermissions({
20864
+ baseDir,
20865
+ relativeDirPath: paths.relativeDirPath,
20866
+ relativeFilePath: paths.relativeFilePath,
20867
+ fileContent,
20868
+ validate
20869
+ });
20870
+ }
20871
+ static async fromRulesyncPermissions({
20872
+ baseDir = process.cwd(),
20873
+ rulesyncPermissions,
20874
+ validate = true,
20875
+ logger: logger5,
20876
+ global = false
20877
+ }) {
20878
+ const paths = this.getSettablePaths({ global });
20879
+ const filePath = (0, import_node_path138.join)(baseDir, paths.relativeDirPath, paths.relativeFilePath);
20880
+ const existingContent = await readFileContentOrNull(filePath) ?? JSON.stringify({}, null, 2);
20881
+ const settingsResult = GeminiCliSettingsSchema.safeParse(JSON.parse(existingContent));
20882
+ if (!settingsResult.success) {
20883
+ throw new Error(
20884
+ `Failed to parse existing Gemini CLI settings at ${filePath}: ${formatError(settingsResult.error)}`
20885
+ );
20886
+ }
20887
+ const { allowed, exclude } = convertRulesyncToGeminicliTools({
20888
+ config: rulesyncPermissions.getJson(),
20889
+ logger: logger5
20890
+ });
20891
+ const merged = {
20892
+ ...settingsResult.data,
20893
+ tools: {
20894
+ ...settingsResult.data.tools,
20895
+ ...allowed.length > 0 ? { allowed } : {},
20896
+ ...exclude.length > 0 ? { exclude } : {}
20897
+ }
20898
+ };
20899
+ return new _GeminicliPermissions({
20900
+ baseDir,
20901
+ relativeDirPath: paths.relativeDirPath,
20902
+ relativeFilePath: paths.relativeFilePath,
20903
+ fileContent: JSON.stringify(merged, null, 2),
20904
+ validate
20905
+ });
20906
+ }
20907
+ toRulesyncPermissions() {
20908
+ let settings;
20909
+ try {
20910
+ const parsed = JSON.parse(this.getFileContent());
20911
+ settings = GeminiCliSettingsSchema.parse(parsed);
20912
+ } catch (error) {
20913
+ throw new Error(
20914
+ `Failed to parse Gemini CLI permissions content in ${(0, import_node_path138.join)(this.getRelativeDirPath(), this.getRelativeFilePath())}: ${formatError(error)}`,
20915
+ { cause: error }
20916
+ );
20917
+ }
20918
+ const permission = {};
20919
+ for (const toolEntry of settings.tools?.allowed ?? []) {
20920
+ const mapped = parseGeminicliToolEntry({ entry: toolEntry });
20921
+ const rules = permission[mapped.category] ??= {};
20922
+ rules[mapped.pattern] = "allow";
20923
+ }
20924
+ for (const toolEntry of settings.tools?.exclude ?? []) {
20925
+ const mapped = parseGeminicliToolEntry({ entry: toolEntry });
20926
+ const rules = permission[mapped.category] ??= {};
20927
+ rules[mapped.pattern] = "deny";
20928
+ }
20929
+ return this.toRulesyncPermissionsDefault({
20930
+ fileContent: JSON.stringify({ permission }, null, 2)
20931
+ });
20932
+ }
20933
+ validate() {
20934
+ return { success: true, error: null };
20935
+ }
20936
+ static forDeletion({
20937
+ baseDir = process.cwd(),
20938
+ relativeDirPath,
20939
+ relativeFilePath
20940
+ }) {
20941
+ return new _GeminicliPermissions({
20942
+ baseDir,
20943
+ relativeDirPath,
20944
+ relativeFilePath,
20945
+ fileContent: JSON.stringify({}, null, 2),
20946
+ validate: false
20947
+ });
20948
+ }
20949
+ };
20950
+ function convertRulesyncToGeminicliTools({
20951
+ config,
20952
+ logger: logger5
20953
+ }) {
20954
+ const allowed = [];
20955
+ const exclude = [];
20956
+ for (const [toolName, rules] of Object.entries(config.permission)) {
20957
+ const mappedToolName = RULESYNC_TO_GEMINICLI_TOOL_NAME[toolName] ?? toolName;
20958
+ if (!RULESYNC_TO_GEMINICLI_TOOL_NAME[toolName]) {
20959
+ logger5?.warn(`Gemini CLI permissions use direct tool names. Mapping as-is: ${toolName}`);
20960
+ }
20961
+ for (const [pattern, action] of Object.entries(rules)) {
20962
+ if (action === "ask") {
20963
+ logger5?.warn(
20964
+ `Gemini CLI does not support explicit "ask" rules in settings. Skipping ${toolName}:${pattern}`
20965
+ );
20966
+ continue;
20967
+ }
20968
+ const geminiEntry = pattern === "*" ? mappedToolName : `${mappedToolName}(${pattern})`;
20969
+ if (action === "allow") {
20970
+ allowed.push(geminiEntry);
20971
+ } else {
20972
+ exclude.push(geminiEntry);
20973
+ }
20974
+ }
20975
+ }
20976
+ return { allowed, exclude };
20977
+ }
20978
+ function parseGeminicliToolEntry({ entry }) {
20979
+ const match = /^([^()]+?)(?:\((.*)\))?$/.exec(entry);
20980
+ if (!match) return { category: entry, pattern: "*" };
20981
+ const rawToolName = match[1]?.trim() ?? entry;
20982
+ const mappedCategory = Object.entries(RULESYNC_TO_GEMINICLI_TOOL_NAME).find(
20983
+ ([, value]) => value === rawToolName
20984
+ )?.[0];
20985
+ return {
20986
+ category: mappedCategory ?? rawToolName,
20987
+ pattern: (match[2] ?? "*").trim()
20988
+ };
20989
+ }
20990
+
20991
+ // src/features/permissions/opencode-permissions.ts
20992
+ var import_node_path139 = require("path");
20993
+ var import_jsonc_parser5 = require("jsonc-parser");
20994
+ var import_mini72 = require("zod/mini");
20995
+ var OpencodePermissionSchema = import_mini72.z.union([
20996
+ import_mini72.z.enum(["allow", "ask", "deny"]),
20997
+ import_mini72.z.record(import_mini72.z.string(), import_mini72.z.enum(["allow", "ask", "deny"]))
20582
20998
  ]);
20583
- var OpencodePermissionsConfigSchema = import_mini71.z.looseObject({
20584
- permission: import_mini71.z.optional(import_mini71.z.record(import_mini71.z.string(), OpencodePermissionSchema))
20999
+ var OpencodePermissionsConfigSchema = import_mini72.z.looseObject({
21000
+ permission: import_mini72.z.optional(import_mini72.z.record(import_mini72.z.string(), OpencodePermissionSchema))
20585
21001
  });
20586
21002
  var OpencodePermissions = class _OpencodePermissions extends ToolPermissions {
20587
21003
  json;
@@ -20598,7 +21014,7 @@ var OpencodePermissions = class _OpencodePermissions extends ToolPermissions {
20598
21014
  static getSettablePaths({
20599
21015
  global = false
20600
21016
  } = {}) {
20601
- return global ? { relativeDirPath: (0, import_node_path137.join)(".config", "opencode"), relativeFilePath: "opencode.json" } : { relativeDirPath: ".", relativeFilePath: "opencode.json" };
21017
+ return global ? { relativeDirPath: (0, import_node_path139.join)(".config", "opencode"), relativeFilePath: "opencode.json" } : { relativeDirPath: ".", relativeFilePath: "opencode.json" };
20602
21018
  }
20603
21019
  static async fromFile({
20604
21020
  baseDir = process.cwd(),
@@ -20606,9 +21022,9 @@ var OpencodePermissions = class _OpencodePermissions extends ToolPermissions {
20606
21022
  global = false
20607
21023
  }) {
20608
21024
  const basePaths = _OpencodePermissions.getSettablePaths({ global });
20609
- const jsonDir = (0, import_node_path137.join)(baseDir, basePaths.relativeDirPath);
20610
- const jsoncPath = (0, import_node_path137.join)(jsonDir, "opencode.jsonc");
20611
- const jsonPath = (0, import_node_path137.join)(jsonDir, "opencode.json");
21025
+ const jsonDir = (0, import_node_path139.join)(baseDir, basePaths.relativeDirPath);
21026
+ const jsoncPath = (0, import_node_path139.join)(jsonDir, "opencode.jsonc");
21027
+ const jsonPath = (0, import_node_path139.join)(jsonDir, "opencode.json");
20612
21028
  let fileContent = await readFileContentOrNull(jsoncPath);
20613
21029
  let relativeFilePath = "opencode.jsonc";
20614
21030
  if (!fileContent) {
@@ -20633,9 +21049,9 @@ var OpencodePermissions = class _OpencodePermissions extends ToolPermissions {
20633
21049
  global = false
20634
21050
  }) {
20635
21051
  const basePaths = _OpencodePermissions.getSettablePaths({ global });
20636
- const jsonDir = (0, import_node_path137.join)(baseDir, basePaths.relativeDirPath);
20637
- const jsoncPath = (0, import_node_path137.join)(jsonDir, "opencode.jsonc");
20638
- const jsonPath = (0, import_node_path137.join)(jsonDir, "opencode.json");
21052
+ const jsonDir = (0, import_node_path139.join)(baseDir, basePaths.relativeDirPath);
21053
+ const jsoncPath = (0, import_node_path139.join)(jsonDir, "opencode.jsonc");
21054
+ const jsonPath = (0, import_node_path139.join)(jsonDir, "opencode.json");
20639
21055
  let fileContent = await readFileContentOrNull(jsoncPath);
20640
21056
  let relativeFilePath = "opencode.jsonc";
20641
21057
  if (!fileContent) {
@@ -20705,8 +21121,13 @@ var OpencodePermissions = class _OpencodePermissions extends ToolPermissions {
20705
21121
  };
20706
21122
 
20707
21123
  // src/features/permissions/permissions-processor.ts
20708
- var permissionsProcessorToolTargetTuple = ["claudecode", "opencode"];
20709
- var PermissionsProcessorToolTargetSchema = import_mini72.z.enum(permissionsProcessorToolTargetTuple);
21124
+ var permissionsProcessorToolTargetTuple = [
21125
+ "claudecode",
21126
+ "codexcli",
21127
+ "geminicli",
21128
+ "opencode"
21129
+ ];
21130
+ var PermissionsProcessorToolTargetSchema = import_mini73.z.enum(permissionsProcessorToolTargetTuple);
20710
21131
  var toolPermissionsFactories = /* @__PURE__ */ new Map([
20711
21132
  [
20712
21133
  "claudecode",
@@ -20719,6 +21140,28 @@ var toolPermissionsFactories = /* @__PURE__ */ new Map([
20719
21140
  }
20720
21141
  }
20721
21142
  ],
21143
+ [
21144
+ "codexcli",
21145
+ {
21146
+ class: CodexcliPermissions,
21147
+ meta: {
21148
+ supportsProject: true,
21149
+ supportsGlobal: true,
21150
+ supportsImport: true
21151
+ }
21152
+ }
21153
+ ],
21154
+ [
21155
+ "geminicli",
21156
+ {
21157
+ class: GeminicliPermissions,
21158
+ meta: {
21159
+ supportsProject: true,
21160
+ supportsGlobal: true,
21161
+ supportsImport: true
21162
+ }
21163
+ }
21164
+ ],
20722
21165
  [
20723
21166
  "opencode",
20724
21167
  {
@@ -20901,7 +21344,7 @@ function warnUnsupportedTargets(params) {
20901
21344
  }
20902
21345
  }
20903
21346
  async function checkRulesyncDirExists(params) {
20904
- return fileExists((0, import_node_path138.join)(params.baseDir, RULESYNC_RELATIVE_DIR_PATH));
21347
+ return fileExists((0, import_node_path140.join)(params.baseDir, RULESYNC_RELATIVE_DIR_PATH));
20905
21348
  }
20906
21349
  async function generate(params) {
20907
21350
  const { config, logger: logger5 } = params;
@@ -20956,6 +21399,7 @@ async function generateRulesCore(params) {
20956
21399
  simulateSubagents: config.getSimulateSubagents(),
20957
21400
  simulateSkills: config.getSimulateSkills(),
20958
21401
  skills,
21402
+ featureOptions: config.getFeatureOptions(toolTarget, "rules"),
20959
21403
  dryRun: config.isPreviewMode(),
20960
21404
  logger: logger5
20961
21405
  });
@@ -21370,7 +21814,7 @@ async function generateCommand(logger5, options) {
21370
21814
  }
21371
21815
 
21372
21816
  // src/cli/commands/gitignore.ts
21373
- var import_node_path139 = require("path");
21817
+ var import_node_path141 = require("path");
21374
21818
 
21375
21819
  // src/cli/commands/gitignore-entries.ts
21376
21820
  var normalizeGitignoreEntryTargets = (target) => {
@@ -21708,7 +22152,7 @@ var removeExistingRulesyncEntries = (content) => {
21708
22152
  return result;
21709
22153
  };
21710
22154
  var gitignoreCommand = async (logger5, options) => {
21711
- const gitignorePath = (0, import_node_path139.join)(process.cwd(), ".gitignore");
22155
+ const gitignorePath = (0, import_node_path141.join)(process.cwd(), ".gitignore");
21712
22156
  let gitignoreContent = "";
21713
22157
  if (await fileExists(gitignorePath)) {
21714
22158
  gitignoreContent = await readFileContent(gitignorePath);
@@ -22069,7 +22513,7 @@ async function importCommand(logger5, options) {
22069
22513
  }
22070
22514
 
22071
22515
  // src/lib/init.ts
22072
- var import_node_path140 = require("path");
22516
+ var import_node_path142 = require("path");
22073
22517
  async function init() {
22074
22518
  const sampleFiles = await createSampleFiles();
22075
22519
  const configFile = await createConfigFile();
@@ -22261,27 +22705,27 @@ Keep the summary concise and ready to reuse in future tasks.`
22261
22705
  await ensureDir(subagentPaths.relativeDirPath);
22262
22706
  await ensureDir(skillPaths.relativeDirPath);
22263
22707
  await ensureDir(ignorePaths.recommended.relativeDirPath);
22264
- const ruleFilepath = (0, import_node_path140.join)(rulePaths.recommended.relativeDirPath, sampleRuleFile.filename);
22708
+ const ruleFilepath = (0, import_node_path142.join)(rulePaths.recommended.relativeDirPath, sampleRuleFile.filename);
22265
22709
  results.push(await writeIfNotExists(ruleFilepath, sampleRuleFile.content));
22266
- const mcpFilepath = (0, import_node_path140.join)(
22710
+ const mcpFilepath = (0, import_node_path142.join)(
22267
22711
  mcpPaths.recommended.relativeDirPath,
22268
22712
  mcpPaths.recommended.relativeFilePath
22269
22713
  );
22270
22714
  results.push(await writeIfNotExists(mcpFilepath, sampleMcpFile.content));
22271
- const commandFilepath = (0, import_node_path140.join)(commandPaths.relativeDirPath, sampleCommandFile.filename);
22715
+ const commandFilepath = (0, import_node_path142.join)(commandPaths.relativeDirPath, sampleCommandFile.filename);
22272
22716
  results.push(await writeIfNotExists(commandFilepath, sampleCommandFile.content));
22273
- const subagentFilepath = (0, import_node_path140.join)(subagentPaths.relativeDirPath, sampleSubagentFile.filename);
22717
+ const subagentFilepath = (0, import_node_path142.join)(subagentPaths.relativeDirPath, sampleSubagentFile.filename);
22274
22718
  results.push(await writeIfNotExists(subagentFilepath, sampleSubagentFile.content));
22275
- const skillDirPath = (0, import_node_path140.join)(skillPaths.relativeDirPath, sampleSkillFile.dirName);
22719
+ const skillDirPath = (0, import_node_path142.join)(skillPaths.relativeDirPath, sampleSkillFile.dirName);
22276
22720
  await ensureDir(skillDirPath);
22277
- const skillFilepath = (0, import_node_path140.join)(skillDirPath, SKILL_FILE_NAME);
22721
+ const skillFilepath = (0, import_node_path142.join)(skillDirPath, SKILL_FILE_NAME);
22278
22722
  results.push(await writeIfNotExists(skillFilepath, sampleSkillFile.content));
22279
- const ignoreFilepath = (0, import_node_path140.join)(
22723
+ const ignoreFilepath = (0, import_node_path142.join)(
22280
22724
  ignorePaths.recommended.relativeDirPath,
22281
22725
  ignorePaths.recommended.relativeFilePath
22282
22726
  );
22283
22727
  results.push(await writeIfNotExists(ignoreFilepath, sampleIgnoreFile.content));
22284
- const hooksFilepath = (0, import_node_path140.join)(hooksPaths.relativeDirPath, hooksPaths.relativeFilePath);
22728
+ const hooksFilepath = (0, import_node_path142.join)(hooksPaths.relativeDirPath, hooksPaths.relativeFilePath);
22285
22729
  results.push(await writeIfNotExists(hooksFilepath, sampleHooksFile.content));
22286
22730
  return results;
22287
22731
  }
@@ -22329,12 +22773,12 @@ async function initCommand(logger5) {
22329
22773
  }
22330
22774
 
22331
22775
  // src/lib/sources.ts
22332
- var import_node_path143 = require("path");
22776
+ var import_node_path145 = require("path");
22333
22777
  var import_promise2 = require("es-toolkit/promise");
22334
22778
 
22335
22779
  // src/lib/git-client.ts
22336
22780
  var import_node_child_process = require("child_process");
22337
- var import_node_path141 = require("path");
22781
+ var import_node_path143 = require("path");
22338
22782
  var import_node_util2 = require("util");
22339
22783
  var execFileAsync = (0, import_node_util2.promisify)(import_node_child_process.execFile);
22340
22784
  var GIT_TIMEOUT_MS = 6e4;
@@ -22422,7 +22866,7 @@ async function fetchSkillFiles(params) {
22422
22866
  const { url, ref, skillsPath, logger: logger5 } = params;
22423
22867
  validateGitUrl(url, { logger: logger5 });
22424
22868
  validateRef(ref);
22425
- if (skillsPath.split(/[/\\]/).includes("..") || (0, import_node_path141.isAbsolute)(skillsPath)) {
22869
+ if (skillsPath.split(/[/\\]/).includes("..") || (0, import_node_path143.isAbsolute)(skillsPath)) {
22426
22870
  throw new GitClientError(
22427
22871
  `Invalid skillsPath "${skillsPath}": must be a relative path without ".."`
22428
22872
  );
@@ -22456,7 +22900,7 @@ async function fetchSkillFiles(params) {
22456
22900
  timeout: GIT_TIMEOUT_MS
22457
22901
  });
22458
22902
  await execFileAsync("git", ["-C", tmpDir, "checkout"], { timeout: GIT_TIMEOUT_MS });
22459
- const skillsDir = (0, import_node_path141.join)(tmpDir, skillsPath);
22903
+ const skillsDir = (0, import_node_path143.join)(tmpDir, skillsPath);
22460
22904
  if (!await directoryExists(skillsDir)) return [];
22461
22905
  return await walkDirectory(skillsDir, skillsDir, 0, { totalFiles: 0, totalSize: 0 }, logger5);
22462
22906
  } catch (error) {
@@ -22478,7 +22922,7 @@ async function walkDirectory(dir, baseDir, depth = 0, ctx = { totalFiles: 0, tot
22478
22922
  const results = [];
22479
22923
  for (const name of await listDirectoryFiles(dir)) {
22480
22924
  if (name === ".git") continue;
22481
- const fullPath = (0, import_node_path141.join)(dir, name);
22925
+ const fullPath = (0, import_node_path143.join)(dir, name);
22482
22926
  if (await isSymlink(fullPath)) {
22483
22927
  logger5?.warn(`Skipping symlink "${fullPath}".`);
22484
22928
  continue;
@@ -22506,7 +22950,7 @@ async function walkDirectory(dir, baseDir, depth = 0, ctx = { totalFiles: 0, tot
22506
22950
  );
22507
22951
  }
22508
22952
  const content = await readFileContent(fullPath);
22509
- results.push({ relativePath: (0, import_node_path141.relative)(baseDir, fullPath), content, size });
22953
+ results.push({ relativePath: (0, import_node_path143.relative)(baseDir, fullPath), content, size });
22510
22954
  }
22511
22955
  }
22512
22956
  return results;
@@ -22514,28 +22958,28 @@ async function walkDirectory(dir, baseDir, depth = 0, ctx = { totalFiles: 0, tot
22514
22958
 
22515
22959
  // src/lib/sources-lock.ts
22516
22960
  var import_node_crypto = require("crypto");
22517
- var import_node_path142 = require("path");
22518
- var import_mini73 = require("zod/mini");
22961
+ var import_node_path144 = require("path");
22962
+ var import_mini74 = require("zod/mini");
22519
22963
  var LOCKFILE_VERSION = 1;
22520
- var LockedSkillSchema = import_mini73.z.object({
22521
- integrity: import_mini73.z.string()
22964
+ var LockedSkillSchema = import_mini74.z.object({
22965
+ integrity: import_mini74.z.string()
22522
22966
  });
22523
- var LockedSourceSchema = import_mini73.z.object({
22524
- requestedRef: (0, import_mini73.optional)(import_mini73.z.string()),
22525
- resolvedRef: import_mini73.z.string().check((0, import_mini73.refine)((v) => /^[0-9a-f]{40}$/.test(v), "resolvedRef must be a 40-character hex SHA")),
22526
- resolvedAt: (0, import_mini73.optional)(import_mini73.z.string()),
22527
- skills: import_mini73.z.record(import_mini73.z.string(), LockedSkillSchema)
22967
+ var LockedSourceSchema = import_mini74.z.object({
22968
+ requestedRef: (0, import_mini74.optional)(import_mini74.z.string()),
22969
+ resolvedRef: import_mini74.z.string().check((0, import_mini74.refine)((v) => /^[0-9a-f]{40}$/.test(v), "resolvedRef must be a 40-character hex SHA")),
22970
+ resolvedAt: (0, import_mini74.optional)(import_mini74.z.string()),
22971
+ skills: import_mini74.z.record(import_mini74.z.string(), LockedSkillSchema)
22528
22972
  });
22529
- var SourcesLockSchema = import_mini73.z.object({
22530
- lockfileVersion: import_mini73.z.number(),
22531
- sources: import_mini73.z.record(import_mini73.z.string(), LockedSourceSchema)
22973
+ var SourcesLockSchema = import_mini74.z.object({
22974
+ lockfileVersion: import_mini74.z.number(),
22975
+ sources: import_mini74.z.record(import_mini74.z.string(), LockedSourceSchema)
22532
22976
  });
22533
- var LegacyLockedSourceSchema = import_mini73.z.object({
22534
- resolvedRef: import_mini73.z.string(),
22535
- skills: import_mini73.z.array(import_mini73.z.string())
22977
+ var LegacyLockedSourceSchema = import_mini74.z.object({
22978
+ resolvedRef: import_mini74.z.string(),
22979
+ skills: import_mini74.z.array(import_mini74.z.string())
22536
22980
  });
22537
- var LegacySourcesLockSchema = import_mini73.z.object({
22538
- sources: import_mini73.z.record(import_mini73.z.string(), LegacyLockedSourceSchema)
22981
+ var LegacySourcesLockSchema = import_mini74.z.object({
22982
+ sources: import_mini74.z.record(import_mini74.z.string(), LegacyLockedSourceSchema)
22539
22983
  });
22540
22984
  function migrateLegacyLock(params) {
22541
22985
  const { legacy, logger: logger5 } = params;
@@ -22560,7 +23004,7 @@ function createEmptyLock() {
22560
23004
  }
22561
23005
  async function readLockFile(params) {
22562
23006
  const { logger: logger5 } = params;
22563
- const lockPath = (0, import_node_path142.join)(params.baseDir, RULESYNC_SOURCES_LOCK_RELATIVE_FILE_PATH);
23007
+ const lockPath = (0, import_node_path144.join)(params.baseDir, RULESYNC_SOURCES_LOCK_RELATIVE_FILE_PATH);
22564
23008
  if (!await fileExists(lockPath)) {
22565
23009
  logger5.debug("No sources lockfile found, starting fresh.");
22566
23010
  return createEmptyLock();
@@ -22589,7 +23033,7 @@ async function readLockFile(params) {
22589
23033
  }
22590
23034
  async function writeLockFile(params) {
22591
23035
  const { logger: logger5 } = params;
22592
- const lockPath = (0, import_node_path142.join)(params.baseDir, RULESYNC_SOURCES_LOCK_RELATIVE_FILE_PATH);
23036
+ const lockPath = (0, import_node_path144.join)(params.baseDir, RULESYNC_SOURCES_LOCK_RELATIVE_FILE_PATH);
22593
23037
  const content = JSON.stringify(params.lock, null, 2) + "\n";
22594
23038
  await writeFileContent(lockPath, content);
22595
23039
  logger5.debug(`Wrote sources lockfile to ${lockPath}`);
@@ -22763,7 +23207,7 @@ function logGitClientHints(params) {
22763
23207
  async function checkLockedSkillsExist(curatedDir, skillNames) {
22764
23208
  if (skillNames.length === 0) return true;
22765
23209
  for (const name of skillNames) {
22766
- if (!await directoryExists((0, import_node_path143.join)(curatedDir, name))) {
23210
+ if (!await directoryExists((0, import_node_path145.join)(curatedDir, name))) {
22767
23211
  return false;
22768
23212
  }
22769
23213
  }
@@ -22771,10 +23215,10 @@ async function checkLockedSkillsExist(curatedDir, skillNames) {
22771
23215
  }
22772
23216
  async function cleanPreviousCuratedSkills(params) {
22773
23217
  const { curatedDir, lockedSkillNames, logger: logger5 } = params;
22774
- const resolvedCuratedDir = (0, import_node_path143.resolve)(curatedDir);
23218
+ const resolvedCuratedDir = (0, import_node_path145.resolve)(curatedDir);
22775
23219
  for (const prevSkill of lockedSkillNames) {
22776
- const prevDir = (0, import_node_path143.join)(curatedDir, prevSkill);
22777
- if (!(0, import_node_path143.resolve)(prevDir).startsWith(resolvedCuratedDir + import_node_path143.sep)) {
23220
+ const prevDir = (0, import_node_path145.join)(curatedDir, prevSkill);
23221
+ if (!(0, import_node_path145.resolve)(prevDir).startsWith(resolvedCuratedDir + import_node_path145.sep)) {
22778
23222
  logger5.warn(
22779
23223
  `Skipping removal of "${prevSkill}": resolved path is outside the curated directory.`
22780
23224
  );
@@ -22813,9 +23257,9 @@ async function writeSkillAndComputeIntegrity(params) {
22813
23257
  for (const file of files) {
22814
23258
  checkPathTraversal({
22815
23259
  relativePath: file.relativePath,
22816
- intendedRootDir: (0, import_node_path143.join)(curatedDir, skillName)
23260
+ intendedRootDir: (0, import_node_path145.join)(curatedDir, skillName)
22817
23261
  });
22818
- await writeFileContent((0, import_node_path143.join)(curatedDir, skillName, file.relativePath), file.content);
23262
+ await writeFileContent((0, import_node_path145.join)(curatedDir, skillName, file.relativePath), file.content);
22819
23263
  written.push({ path: file.relativePath, content: file.content });
22820
23264
  }
22821
23265
  const integrity = computeSkillIntegrity(written);
@@ -22892,7 +23336,7 @@ async function fetchSource(params) {
22892
23336
  ref = resolvedSha;
22893
23337
  logger5.debug(`Resolved ${sourceKey} ref "${requestedRef}" to SHA: ${resolvedSha}`);
22894
23338
  }
22895
- const curatedDir = (0, import_node_path143.join)(baseDir, RULESYNC_CURATED_SKILLS_RELATIVE_DIR_PATH);
23339
+ const curatedDir = (0, import_node_path145.join)(baseDir, RULESYNC_CURATED_SKILLS_RELATIVE_DIR_PATH);
22896
23340
  if (locked && resolvedSha === locked.resolvedRef && !updateSources) {
22897
23341
  const allExist = await checkLockedSkillsExist(curatedDir, lockedSkillNames);
22898
23342
  if (allExist) {
@@ -23017,7 +23461,7 @@ async function fetchSourceViaGit(params) {
23017
23461
  requestedRef = def.ref;
23018
23462
  resolvedSha = def.sha;
23019
23463
  }
23020
- const curatedDir = (0, import_node_path143.join)(baseDir, RULESYNC_CURATED_SKILLS_RELATIVE_DIR_PATH);
23464
+ const curatedDir = (0, import_node_path145.join)(baseDir, RULESYNC_CURATED_SKILLS_RELATIVE_DIR_PATH);
23021
23465
  if (locked && resolvedSha === locked.resolvedRef && !updateSources) {
23022
23466
  if (await checkLockedSkillsExist(curatedDir, lockedSkillNames)) {
23023
23467
  return { skillCount: 0, fetchedSkillNames: lockedSkillNames, updatedLock: lock };
@@ -23133,11 +23577,11 @@ async function installCommand(logger5, options) {
23133
23577
  var import_fastmcp = require("fastmcp");
23134
23578
 
23135
23579
  // src/mcp/tools.ts
23136
- var import_mini82 = require("zod/mini");
23580
+ var import_mini83 = require("zod/mini");
23137
23581
 
23138
23582
  // src/mcp/commands.ts
23139
- var import_node_path144 = require("path");
23140
- var import_mini74 = require("zod/mini");
23583
+ var import_node_path146 = require("path");
23584
+ var import_mini75 = require("zod/mini");
23141
23585
 
23142
23586
  // src/utils/logger.ts
23143
23587
  var BaseLogger = class {
@@ -23288,7 +23732,7 @@ var logger = new ConsoleLogger({ verbose: false, silent: true });
23288
23732
  var maxCommandSizeBytes = 1024 * 1024;
23289
23733
  var maxCommandsCount = 1e3;
23290
23734
  async function listCommands() {
23291
- const commandsDir = (0, import_node_path144.join)(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH);
23735
+ const commandsDir = (0, import_node_path146.join)(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH);
23292
23736
  try {
23293
23737
  const files = await listDirectoryFiles(commandsDir);
23294
23738
  const mdFiles = files.filter((file) => file.endsWith(".md"));
@@ -23304,7 +23748,7 @@ async function listCommands() {
23304
23748
  });
23305
23749
  const frontmatter = command.getFrontmatter();
23306
23750
  return {
23307
- relativePathFromCwd: (0, import_node_path144.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, file),
23751
+ relativePathFromCwd: (0, import_node_path146.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, file),
23308
23752
  frontmatter
23309
23753
  };
23310
23754
  } catch (error) {
@@ -23326,13 +23770,13 @@ async function getCommand({ relativePathFromCwd }) {
23326
23770
  relativePath: relativePathFromCwd,
23327
23771
  intendedRootDir: process.cwd()
23328
23772
  });
23329
- const filename = (0, import_node_path144.basename)(relativePathFromCwd);
23773
+ const filename = (0, import_node_path146.basename)(relativePathFromCwd);
23330
23774
  try {
23331
23775
  const command = await RulesyncCommand.fromFile({
23332
23776
  relativeFilePath: filename
23333
23777
  });
23334
23778
  return {
23335
- relativePathFromCwd: (0, import_node_path144.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename),
23779
+ relativePathFromCwd: (0, import_node_path146.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename),
23336
23780
  frontmatter: command.getFrontmatter(),
23337
23781
  body: command.getBody()
23338
23782
  };
@@ -23351,7 +23795,7 @@ async function putCommand({
23351
23795
  relativePath: relativePathFromCwd,
23352
23796
  intendedRootDir: process.cwd()
23353
23797
  });
23354
- const filename = (0, import_node_path144.basename)(relativePathFromCwd);
23798
+ const filename = (0, import_node_path146.basename)(relativePathFromCwd);
23355
23799
  const estimatedSize = JSON.stringify(frontmatter).length + body.length;
23356
23800
  if (estimatedSize > maxCommandSizeBytes) {
23357
23801
  throw new Error(
@@ -23361,7 +23805,7 @@ async function putCommand({
23361
23805
  try {
23362
23806
  const existingCommands = await listCommands();
23363
23807
  const isUpdate = existingCommands.some(
23364
- (command2) => command2.relativePathFromCwd === (0, import_node_path144.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename)
23808
+ (command2) => command2.relativePathFromCwd === (0, import_node_path146.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename)
23365
23809
  );
23366
23810
  if (!isUpdate && existingCommands.length >= maxCommandsCount) {
23367
23811
  throw new Error(
@@ -23378,11 +23822,11 @@ async function putCommand({
23378
23822
  fileContent,
23379
23823
  validate: true
23380
23824
  });
23381
- const commandsDir = (0, import_node_path144.join)(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH);
23825
+ const commandsDir = (0, import_node_path146.join)(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH);
23382
23826
  await ensureDir(commandsDir);
23383
23827
  await writeFileContent(command.getFilePath(), command.getFileContent());
23384
23828
  return {
23385
- relativePathFromCwd: (0, import_node_path144.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename),
23829
+ relativePathFromCwd: (0, import_node_path146.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename),
23386
23830
  frontmatter: command.getFrontmatter(),
23387
23831
  body: command.getBody()
23388
23832
  };
@@ -23397,12 +23841,12 @@ async function deleteCommand({ relativePathFromCwd }) {
23397
23841
  relativePath: relativePathFromCwd,
23398
23842
  intendedRootDir: process.cwd()
23399
23843
  });
23400
- const filename = (0, import_node_path144.basename)(relativePathFromCwd);
23401
- const fullPath = (0, import_node_path144.join)(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename);
23844
+ const filename = (0, import_node_path146.basename)(relativePathFromCwd);
23845
+ const fullPath = (0, import_node_path146.join)(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename);
23402
23846
  try {
23403
23847
  await removeFile(fullPath);
23404
23848
  return {
23405
- relativePathFromCwd: (0, import_node_path144.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename)
23849
+ relativePathFromCwd: (0, import_node_path146.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename)
23406
23850
  };
23407
23851
  } catch (error) {
23408
23852
  throw new Error(`Failed to delete command file ${relativePathFromCwd}: ${formatError(error)}`, {
@@ -23411,23 +23855,23 @@ async function deleteCommand({ relativePathFromCwd }) {
23411
23855
  }
23412
23856
  }
23413
23857
  var commandToolSchemas = {
23414
- listCommands: import_mini74.z.object({}),
23415
- getCommand: import_mini74.z.object({
23416
- relativePathFromCwd: import_mini74.z.string()
23858
+ listCommands: import_mini75.z.object({}),
23859
+ getCommand: import_mini75.z.object({
23860
+ relativePathFromCwd: import_mini75.z.string()
23417
23861
  }),
23418
- putCommand: import_mini74.z.object({
23419
- relativePathFromCwd: import_mini74.z.string(),
23862
+ putCommand: import_mini75.z.object({
23863
+ relativePathFromCwd: import_mini75.z.string(),
23420
23864
  frontmatter: RulesyncCommandFrontmatterSchema,
23421
- body: import_mini74.z.string()
23865
+ body: import_mini75.z.string()
23422
23866
  }),
23423
- deleteCommand: import_mini74.z.object({
23424
- relativePathFromCwd: import_mini74.z.string()
23867
+ deleteCommand: import_mini75.z.object({
23868
+ relativePathFromCwd: import_mini75.z.string()
23425
23869
  })
23426
23870
  };
23427
23871
  var commandTools = {
23428
23872
  listCommands: {
23429
23873
  name: "listCommands",
23430
- description: `List all commands from ${(0, import_node_path144.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
23874
+ description: `List all commands from ${(0, import_node_path146.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
23431
23875
  parameters: commandToolSchemas.listCommands,
23432
23876
  execute: async () => {
23433
23877
  const commands = await listCommands();
@@ -23469,15 +23913,15 @@ var commandTools = {
23469
23913
  };
23470
23914
 
23471
23915
  // src/mcp/generate.ts
23472
- var import_mini75 = require("zod/mini");
23473
- var generateOptionsSchema = import_mini75.z.object({
23474
- targets: import_mini75.z.optional(import_mini75.z.array(import_mini75.z.string())),
23475
- features: import_mini75.z.optional(import_mini75.z.array(import_mini75.z.string())),
23476
- delete: import_mini75.z.optional(import_mini75.z.boolean()),
23477
- global: import_mini75.z.optional(import_mini75.z.boolean()),
23478
- simulateCommands: import_mini75.z.optional(import_mini75.z.boolean()),
23479
- simulateSubagents: import_mini75.z.optional(import_mini75.z.boolean()),
23480
- simulateSkills: import_mini75.z.optional(import_mini75.z.boolean())
23916
+ var import_mini76 = require("zod/mini");
23917
+ var generateOptionsSchema = import_mini76.z.object({
23918
+ targets: import_mini76.z.optional(import_mini76.z.array(import_mini76.z.string())),
23919
+ features: import_mini76.z.optional(import_mini76.z.array(import_mini76.z.string())),
23920
+ delete: import_mini76.z.optional(import_mini76.z.boolean()),
23921
+ global: import_mini76.z.optional(import_mini76.z.boolean()),
23922
+ simulateCommands: import_mini76.z.optional(import_mini76.z.boolean()),
23923
+ simulateSubagents: import_mini76.z.optional(import_mini76.z.boolean()),
23924
+ simulateSkills: import_mini76.z.optional(import_mini76.z.boolean())
23481
23925
  });
23482
23926
  async function executeGenerate(options = {}) {
23483
23927
  try {
@@ -23556,11 +24000,11 @@ var generateTools = {
23556
24000
  };
23557
24001
 
23558
24002
  // src/mcp/ignore.ts
23559
- var import_node_path145 = require("path");
23560
- var import_mini76 = require("zod/mini");
24003
+ var import_node_path147 = require("path");
24004
+ var import_mini77 = require("zod/mini");
23561
24005
  var maxIgnoreFileSizeBytes = 100 * 1024;
23562
24006
  async function getIgnoreFile() {
23563
- const ignoreFilePath = (0, import_node_path145.join)(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
24007
+ const ignoreFilePath = (0, import_node_path147.join)(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
23564
24008
  try {
23565
24009
  const content = await readFileContent(ignoreFilePath);
23566
24010
  return {
@@ -23577,7 +24021,7 @@ async function getIgnoreFile() {
23577
24021
  }
23578
24022
  }
23579
24023
  async function putIgnoreFile({ content }) {
23580
- const ignoreFilePath = (0, import_node_path145.join)(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
24024
+ const ignoreFilePath = (0, import_node_path147.join)(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
23581
24025
  const contentSizeBytes = Buffer.byteLength(content, "utf8");
23582
24026
  if (contentSizeBytes > maxIgnoreFileSizeBytes) {
23583
24027
  throw new Error(
@@ -23601,8 +24045,8 @@ async function putIgnoreFile({ content }) {
23601
24045
  }
23602
24046
  }
23603
24047
  async function deleteIgnoreFile() {
23604
- const aiignorePath = (0, import_node_path145.join)(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
23605
- const legacyIgnorePath = (0, import_node_path145.join)(process.cwd(), RULESYNC_IGNORE_RELATIVE_FILE_PATH);
24048
+ const aiignorePath = (0, import_node_path147.join)(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
24049
+ const legacyIgnorePath = (0, import_node_path147.join)(process.cwd(), RULESYNC_IGNORE_RELATIVE_FILE_PATH);
23606
24050
  try {
23607
24051
  await Promise.all([removeFile(aiignorePath), removeFile(legacyIgnorePath)]);
23608
24052
  return {
@@ -23620,11 +24064,11 @@ async function deleteIgnoreFile() {
23620
24064
  }
23621
24065
  }
23622
24066
  var ignoreToolSchemas = {
23623
- getIgnoreFile: import_mini76.z.object({}),
23624
- putIgnoreFile: import_mini76.z.object({
23625
- content: import_mini76.z.string()
24067
+ getIgnoreFile: import_mini77.z.object({}),
24068
+ putIgnoreFile: import_mini77.z.object({
24069
+ content: import_mini77.z.string()
23626
24070
  }),
23627
- deleteIgnoreFile: import_mini76.z.object({})
24071
+ deleteIgnoreFile: import_mini77.z.object({})
23628
24072
  };
23629
24073
  var ignoreTools = {
23630
24074
  getIgnoreFile: {
@@ -23657,11 +24101,11 @@ var ignoreTools = {
23657
24101
  };
23658
24102
 
23659
24103
  // src/mcp/import.ts
23660
- var import_mini77 = require("zod/mini");
23661
- var importOptionsSchema = import_mini77.z.object({
23662
- target: import_mini77.z.string(),
23663
- features: import_mini77.z.optional(import_mini77.z.array(import_mini77.z.string())),
23664
- global: import_mini77.z.optional(import_mini77.z.boolean())
24104
+ var import_mini78 = require("zod/mini");
24105
+ var importOptionsSchema = import_mini78.z.object({
24106
+ target: import_mini78.z.string(),
24107
+ features: import_mini78.z.optional(import_mini78.z.array(import_mini78.z.string())),
24108
+ global: import_mini78.z.optional(import_mini78.z.boolean())
23665
24109
  });
23666
24110
  async function executeImport(options) {
23667
24111
  try {
@@ -23732,15 +24176,15 @@ var importTools = {
23732
24176
  };
23733
24177
 
23734
24178
  // src/mcp/mcp.ts
23735
- var import_node_path146 = require("path");
23736
- var import_mini78 = require("zod/mini");
24179
+ var import_node_path148 = require("path");
24180
+ var import_mini79 = require("zod/mini");
23737
24181
  var maxMcpSizeBytes = 1024 * 1024;
23738
24182
  async function getMcpFile() {
23739
24183
  try {
23740
24184
  const rulesyncMcp = await RulesyncMcp.fromFile({
23741
24185
  validate: true
23742
24186
  });
23743
- const relativePathFromCwd = (0, import_node_path146.join)(
24187
+ const relativePathFromCwd = (0, import_node_path148.join)(
23744
24188
  rulesyncMcp.getRelativeDirPath(),
23745
24189
  rulesyncMcp.getRelativeFilePath()
23746
24190
  );
@@ -23778,7 +24222,7 @@ async function putMcpFile({ content }) {
23778
24222
  const paths = RulesyncMcp.getSettablePaths();
23779
24223
  const relativeDirPath = paths.recommended.relativeDirPath;
23780
24224
  const relativeFilePath = paths.recommended.relativeFilePath;
23781
- const fullPath = (0, import_node_path146.join)(baseDir, relativeDirPath, relativeFilePath);
24225
+ const fullPath = (0, import_node_path148.join)(baseDir, relativeDirPath, relativeFilePath);
23782
24226
  const rulesyncMcp = new RulesyncMcp({
23783
24227
  baseDir,
23784
24228
  relativeDirPath,
@@ -23786,9 +24230,9 @@ async function putMcpFile({ content }) {
23786
24230
  fileContent: content,
23787
24231
  validate: true
23788
24232
  });
23789
- await ensureDir((0, import_node_path146.join)(baseDir, relativeDirPath));
24233
+ await ensureDir((0, import_node_path148.join)(baseDir, relativeDirPath));
23790
24234
  await writeFileContent(fullPath, content);
23791
- const relativePathFromCwd = (0, import_node_path146.join)(relativeDirPath, relativeFilePath);
24235
+ const relativePathFromCwd = (0, import_node_path148.join)(relativeDirPath, relativeFilePath);
23792
24236
  return {
23793
24237
  relativePathFromCwd,
23794
24238
  content: rulesyncMcp.getFileContent()
@@ -23806,15 +24250,15 @@ async function deleteMcpFile() {
23806
24250
  try {
23807
24251
  const baseDir = process.cwd();
23808
24252
  const paths = RulesyncMcp.getSettablePaths();
23809
- const recommendedPath = (0, import_node_path146.join)(
24253
+ const recommendedPath = (0, import_node_path148.join)(
23810
24254
  baseDir,
23811
24255
  paths.recommended.relativeDirPath,
23812
24256
  paths.recommended.relativeFilePath
23813
24257
  );
23814
- const legacyPath = (0, import_node_path146.join)(baseDir, paths.legacy.relativeDirPath, paths.legacy.relativeFilePath);
24258
+ const legacyPath = (0, import_node_path148.join)(baseDir, paths.legacy.relativeDirPath, paths.legacy.relativeFilePath);
23815
24259
  await removeFile(recommendedPath);
23816
24260
  await removeFile(legacyPath);
23817
- const relativePathFromCwd = (0, import_node_path146.join)(
24261
+ const relativePathFromCwd = (0, import_node_path148.join)(
23818
24262
  paths.recommended.relativeDirPath,
23819
24263
  paths.recommended.relativeFilePath
23820
24264
  );
@@ -23831,11 +24275,11 @@ async function deleteMcpFile() {
23831
24275
  }
23832
24276
  }
23833
24277
  var mcpToolSchemas = {
23834
- getMcpFile: import_mini78.z.object({}),
23835
- putMcpFile: import_mini78.z.object({
23836
- content: import_mini78.z.string()
24278
+ getMcpFile: import_mini79.z.object({}),
24279
+ putMcpFile: import_mini79.z.object({
24280
+ content: import_mini79.z.string()
23837
24281
  }),
23838
- deleteMcpFile: import_mini78.z.object({})
24282
+ deleteMcpFile: import_mini79.z.object({})
23839
24283
  };
23840
24284
  var mcpTools = {
23841
24285
  getMcpFile: {
@@ -23868,13 +24312,13 @@ var mcpTools = {
23868
24312
  };
23869
24313
 
23870
24314
  // src/mcp/rules.ts
23871
- var import_node_path147 = require("path");
23872
- var import_mini79 = require("zod/mini");
24315
+ var import_node_path149 = require("path");
24316
+ var import_mini80 = require("zod/mini");
23873
24317
  var logger2 = new ConsoleLogger({ verbose: false, silent: true });
23874
24318
  var maxRuleSizeBytes = 1024 * 1024;
23875
24319
  var maxRulesCount = 1e3;
23876
24320
  async function listRules() {
23877
- const rulesDir = (0, import_node_path147.join)(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH);
24321
+ const rulesDir = (0, import_node_path149.join)(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH);
23878
24322
  try {
23879
24323
  const files = await listDirectoryFiles(rulesDir);
23880
24324
  const mdFiles = files.filter((file) => file.endsWith(".md"));
@@ -23887,7 +24331,7 @@ async function listRules() {
23887
24331
  });
23888
24332
  const frontmatter = rule.getFrontmatter();
23889
24333
  return {
23890
- relativePathFromCwd: (0, import_node_path147.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, file),
24334
+ relativePathFromCwd: (0, import_node_path149.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, file),
23891
24335
  frontmatter
23892
24336
  };
23893
24337
  } catch (error) {
@@ -23909,14 +24353,14 @@ async function getRule({ relativePathFromCwd }) {
23909
24353
  relativePath: relativePathFromCwd,
23910
24354
  intendedRootDir: process.cwd()
23911
24355
  });
23912
- const filename = (0, import_node_path147.basename)(relativePathFromCwd);
24356
+ const filename = (0, import_node_path149.basename)(relativePathFromCwd);
23913
24357
  try {
23914
24358
  const rule = await RulesyncRule.fromFile({
23915
24359
  relativeFilePath: filename,
23916
24360
  validate: true
23917
24361
  });
23918
24362
  return {
23919
- relativePathFromCwd: (0, import_node_path147.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename),
24363
+ relativePathFromCwd: (0, import_node_path149.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename),
23920
24364
  frontmatter: rule.getFrontmatter(),
23921
24365
  body: rule.getBody()
23922
24366
  };
@@ -23935,7 +24379,7 @@ async function putRule({
23935
24379
  relativePath: relativePathFromCwd,
23936
24380
  intendedRootDir: process.cwd()
23937
24381
  });
23938
- const filename = (0, import_node_path147.basename)(relativePathFromCwd);
24382
+ const filename = (0, import_node_path149.basename)(relativePathFromCwd);
23939
24383
  const estimatedSize = JSON.stringify(frontmatter).length + body.length;
23940
24384
  if (estimatedSize > maxRuleSizeBytes) {
23941
24385
  throw new Error(
@@ -23945,7 +24389,7 @@ async function putRule({
23945
24389
  try {
23946
24390
  const existingRules = await listRules();
23947
24391
  const isUpdate = existingRules.some(
23948
- (rule2) => rule2.relativePathFromCwd === (0, import_node_path147.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename)
24392
+ (rule2) => rule2.relativePathFromCwd === (0, import_node_path149.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename)
23949
24393
  );
23950
24394
  if (!isUpdate && existingRules.length >= maxRulesCount) {
23951
24395
  throw new Error(
@@ -23960,11 +24404,11 @@ async function putRule({
23960
24404
  body,
23961
24405
  validate: true
23962
24406
  });
23963
- const rulesDir = (0, import_node_path147.join)(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH);
24407
+ const rulesDir = (0, import_node_path149.join)(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH);
23964
24408
  await ensureDir(rulesDir);
23965
24409
  await writeFileContent(rule.getFilePath(), rule.getFileContent());
23966
24410
  return {
23967
- relativePathFromCwd: (0, import_node_path147.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename),
24411
+ relativePathFromCwd: (0, import_node_path149.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename),
23968
24412
  frontmatter: rule.getFrontmatter(),
23969
24413
  body: rule.getBody()
23970
24414
  };
@@ -23979,12 +24423,12 @@ async function deleteRule({ relativePathFromCwd }) {
23979
24423
  relativePath: relativePathFromCwd,
23980
24424
  intendedRootDir: process.cwd()
23981
24425
  });
23982
- const filename = (0, import_node_path147.basename)(relativePathFromCwd);
23983
- const fullPath = (0, import_node_path147.join)(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH, filename);
24426
+ const filename = (0, import_node_path149.basename)(relativePathFromCwd);
24427
+ const fullPath = (0, import_node_path149.join)(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH, filename);
23984
24428
  try {
23985
24429
  await removeFile(fullPath);
23986
24430
  return {
23987
- relativePathFromCwd: (0, import_node_path147.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename)
24431
+ relativePathFromCwd: (0, import_node_path149.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename)
23988
24432
  };
23989
24433
  } catch (error) {
23990
24434
  throw new Error(`Failed to delete rule file ${relativePathFromCwd}: ${formatError(error)}`, {
@@ -23993,23 +24437,23 @@ async function deleteRule({ relativePathFromCwd }) {
23993
24437
  }
23994
24438
  }
23995
24439
  var ruleToolSchemas = {
23996
- listRules: import_mini79.z.object({}),
23997
- getRule: import_mini79.z.object({
23998
- relativePathFromCwd: import_mini79.z.string()
24440
+ listRules: import_mini80.z.object({}),
24441
+ getRule: import_mini80.z.object({
24442
+ relativePathFromCwd: import_mini80.z.string()
23999
24443
  }),
24000
- putRule: import_mini79.z.object({
24001
- relativePathFromCwd: import_mini79.z.string(),
24444
+ putRule: import_mini80.z.object({
24445
+ relativePathFromCwd: import_mini80.z.string(),
24002
24446
  frontmatter: RulesyncRuleFrontmatterSchema,
24003
- body: import_mini79.z.string()
24447
+ body: import_mini80.z.string()
24004
24448
  }),
24005
- deleteRule: import_mini79.z.object({
24006
- relativePathFromCwd: import_mini79.z.string()
24449
+ deleteRule: import_mini80.z.object({
24450
+ relativePathFromCwd: import_mini80.z.string()
24007
24451
  })
24008
24452
  };
24009
24453
  var ruleTools = {
24010
24454
  listRules: {
24011
24455
  name: "listRules",
24012
- description: `List all rules from ${(0, import_node_path147.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
24456
+ description: `List all rules from ${(0, import_node_path149.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
24013
24457
  parameters: ruleToolSchemas.listRules,
24014
24458
  execute: async () => {
24015
24459
  const rules = await listRules();
@@ -24051,8 +24495,8 @@ var ruleTools = {
24051
24495
  };
24052
24496
 
24053
24497
  // src/mcp/skills.ts
24054
- var import_node_path148 = require("path");
24055
- var import_mini80 = require("zod/mini");
24498
+ var import_node_path150 = require("path");
24499
+ var import_mini81 = require("zod/mini");
24056
24500
  var logger3 = new ConsoleLogger({ verbose: false, silent: true });
24057
24501
  var maxSkillSizeBytes = 1024 * 1024;
24058
24502
  var maxSkillsCount = 1e3;
@@ -24069,19 +24513,19 @@ function mcpSkillFileToAiDirFile(file) {
24069
24513
  };
24070
24514
  }
24071
24515
  function extractDirName(relativeDirPathFromCwd) {
24072
- const dirName = (0, import_node_path148.basename)(relativeDirPathFromCwd);
24516
+ const dirName = (0, import_node_path150.basename)(relativeDirPathFromCwd);
24073
24517
  if (!dirName) {
24074
24518
  throw new Error(`Invalid path: ${relativeDirPathFromCwd}`);
24075
24519
  }
24076
24520
  return dirName;
24077
24521
  }
24078
24522
  async function listSkills() {
24079
- const skillsDir = (0, import_node_path148.join)(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH);
24523
+ const skillsDir = (0, import_node_path150.join)(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH);
24080
24524
  try {
24081
- const skillDirPaths = await findFilesByGlobs((0, import_node_path148.join)(skillsDir, "*"), { type: "dir" });
24525
+ const skillDirPaths = await findFilesByGlobs((0, import_node_path150.join)(skillsDir, "*"), { type: "dir" });
24082
24526
  const skills = await Promise.all(
24083
24527
  skillDirPaths.map(async (dirPath) => {
24084
- const dirName = (0, import_node_path148.basename)(dirPath);
24528
+ const dirName = (0, import_node_path150.basename)(dirPath);
24085
24529
  if (!dirName) return null;
24086
24530
  try {
24087
24531
  const skill = await RulesyncSkill.fromDir({
@@ -24089,7 +24533,7 @@ async function listSkills() {
24089
24533
  });
24090
24534
  const frontmatter = skill.getFrontmatter();
24091
24535
  return {
24092
- relativeDirPathFromCwd: (0, import_node_path148.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
24536
+ relativeDirPathFromCwd: (0, import_node_path150.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
24093
24537
  frontmatter
24094
24538
  };
24095
24539
  } catch (error) {
@@ -24117,7 +24561,7 @@ async function getSkill({ relativeDirPathFromCwd }) {
24117
24561
  dirName
24118
24562
  });
24119
24563
  return {
24120
- relativeDirPathFromCwd: (0, import_node_path148.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
24564
+ relativeDirPathFromCwd: (0, import_node_path150.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
24121
24565
  frontmatter: skill.getFrontmatter(),
24122
24566
  body: skill.getBody(),
24123
24567
  otherFiles: skill.getOtherFiles().map(aiDirFileToMcpSkillFile)
@@ -24151,7 +24595,7 @@ async function putSkill({
24151
24595
  try {
24152
24596
  const existingSkills = await listSkills();
24153
24597
  const isUpdate = existingSkills.some(
24154
- (skill2) => skill2.relativeDirPathFromCwd === (0, import_node_path148.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName)
24598
+ (skill2) => skill2.relativeDirPathFromCwd === (0, import_node_path150.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName)
24155
24599
  );
24156
24600
  if (!isUpdate && existingSkills.length >= maxSkillsCount) {
24157
24601
  throw new Error(
@@ -24168,9 +24612,9 @@ async function putSkill({
24168
24612
  otherFiles: aiDirFiles,
24169
24613
  validate: true
24170
24614
  });
24171
- const skillDirPath = (0, import_node_path148.join)(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName);
24615
+ const skillDirPath = (0, import_node_path150.join)(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName);
24172
24616
  await ensureDir(skillDirPath);
24173
- const skillFilePath = (0, import_node_path148.join)(skillDirPath, SKILL_FILE_NAME);
24617
+ const skillFilePath = (0, import_node_path150.join)(skillDirPath, SKILL_FILE_NAME);
24174
24618
  const skillFileContent = stringifyFrontmatter(body, frontmatter);
24175
24619
  await writeFileContent(skillFilePath, skillFileContent);
24176
24620
  for (const file of otherFiles) {
@@ -24178,15 +24622,15 @@ async function putSkill({
24178
24622
  relativePath: file.name,
24179
24623
  intendedRootDir: skillDirPath
24180
24624
  });
24181
- const filePath = (0, import_node_path148.join)(skillDirPath, file.name);
24182
- const fileDir = (0, import_node_path148.join)(skillDirPath, (0, import_node_path148.dirname)(file.name));
24625
+ const filePath = (0, import_node_path150.join)(skillDirPath, file.name);
24626
+ const fileDir = (0, import_node_path150.join)(skillDirPath, (0, import_node_path150.dirname)(file.name));
24183
24627
  if (fileDir !== skillDirPath) {
24184
24628
  await ensureDir(fileDir);
24185
24629
  }
24186
24630
  await writeFileContent(filePath, file.body);
24187
24631
  }
24188
24632
  return {
24189
- relativeDirPathFromCwd: (0, import_node_path148.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
24633
+ relativeDirPathFromCwd: (0, import_node_path150.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
24190
24634
  frontmatter: skill.getFrontmatter(),
24191
24635
  body: skill.getBody(),
24192
24636
  otherFiles: skill.getOtherFiles().map(aiDirFileToMcpSkillFile)
@@ -24208,13 +24652,13 @@ async function deleteSkill({
24208
24652
  intendedRootDir: process.cwd()
24209
24653
  });
24210
24654
  const dirName = extractDirName(relativeDirPathFromCwd);
24211
- const skillDirPath = (0, import_node_path148.join)(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName);
24655
+ const skillDirPath = (0, import_node_path150.join)(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName);
24212
24656
  try {
24213
24657
  if (await directoryExists(skillDirPath)) {
24214
24658
  await removeDirectory(skillDirPath);
24215
24659
  }
24216
24660
  return {
24217
- relativeDirPathFromCwd: (0, import_node_path148.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName)
24661
+ relativeDirPathFromCwd: (0, import_node_path150.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName)
24218
24662
  };
24219
24663
  } catch (error) {
24220
24664
  throw new Error(
@@ -24225,29 +24669,29 @@ async function deleteSkill({
24225
24669
  );
24226
24670
  }
24227
24671
  }
24228
- var McpSkillFileSchema = import_mini80.z.object({
24229
- name: import_mini80.z.string(),
24230
- body: import_mini80.z.string()
24672
+ var McpSkillFileSchema = import_mini81.z.object({
24673
+ name: import_mini81.z.string(),
24674
+ body: import_mini81.z.string()
24231
24675
  });
24232
24676
  var skillToolSchemas = {
24233
- listSkills: import_mini80.z.object({}),
24234
- getSkill: import_mini80.z.object({
24235
- relativeDirPathFromCwd: import_mini80.z.string()
24677
+ listSkills: import_mini81.z.object({}),
24678
+ getSkill: import_mini81.z.object({
24679
+ relativeDirPathFromCwd: import_mini81.z.string()
24236
24680
  }),
24237
- putSkill: import_mini80.z.object({
24238
- relativeDirPathFromCwd: import_mini80.z.string(),
24681
+ putSkill: import_mini81.z.object({
24682
+ relativeDirPathFromCwd: import_mini81.z.string(),
24239
24683
  frontmatter: RulesyncSkillFrontmatterSchema,
24240
- body: import_mini80.z.string(),
24241
- otherFiles: import_mini80.z.optional(import_mini80.z.array(McpSkillFileSchema))
24684
+ body: import_mini81.z.string(),
24685
+ otherFiles: import_mini81.z.optional(import_mini81.z.array(McpSkillFileSchema))
24242
24686
  }),
24243
- deleteSkill: import_mini80.z.object({
24244
- relativeDirPathFromCwd: import_mini80.z.string()
24687
+ deleteSkill: import_mini81.z.object({
24688
+ relativeDirPathFromCwd: import_mini81.z.string()
24245
24689
  })
24246
24690
  };
24247
24691
  var skillTools = {
24248
24692
  listSkills: {
24249
24693
  name: "listSkills",
24250
- description: `List all skills from ${(0, import_node_path148.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, "*", SKILL_FILE_NAME)} with their frontmatter.`,
24694
+ description: `List all skills from ${(0, import_node_path150.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, "*", SKILL_FILE_NAME)} with their frontmatter.`,
24251
24695
  parameters: skillToolSchemas.listSkills,
24252
24696
  execute: async () => {
24253
24697
  const skills = await listSkills();
@@ -24290,13 +24734,13 @@ var skillTools = {
24290
24734
  };
24291
24735
 
24292
24736
  // src/mcp/subagents.ts
24293
- var import_node_path149 = require("path");
24294
- var import_mini81 = require("zod/mini");
24737
+ var import_node_path151 = require("path");
24738
+ var import_mini82 = require("zod/mini");
24295
24739
  var logger4 = new ConsoleLogger({ verbose: false, silent: true });
24296
24740
  var maxSubagentSizeBytes = 1024 * 1024;
24297
24741
  var maxSubagentsCount = 1e3;
24298
24742
  async function listSubagents() {
24299
- const subagentsDir = (0, import_node_path149.join)(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH);
24743
+ const subagentsDir = (0, import_node_path151.join)(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH);
24300
24744
  try {
24301
24745
  const files = await listDirectoryFiles(subagentsDir);
24302
24746
  const mdFiles = files.filter((file) => file.endsWith(".md"));
@@ -24309,7 +24753,7 @@ async function listSubagents() {
24309
24753
  });
24310
24754
  const frontmatter = subagent.getFrontmatter();
24311
24755
  return {
24312
- relativePathFromCwd: (0, import_node_path149.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, file),
24756
+ relativePathFromCwd: (0, import_node_path151.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, file),
24313
24757
  frontmatter
24314
24758
  };
24315
24759
  } catch (error) {
@@ -24333,14 +24777,14 @@ async function getSubagent({ relativePathFromCwd }) {
24333
24777
  relativePath: relativePathFromCwd,
24334
24778
  intendedRootDir: process.cwd()
24335
24779
  });
24336
- const filename = (0, import_node_path149.basename)(relativePathFromCwd);
24780
+ const filename = (0, import_node_path151.basename)(relativePathFromCwd);
24337
24781
  try {
24338
24782
  const subagent = await RulesyncSubagent.fromFile({
24339
24783
  relativeFilePath: filename,
24340
24784
  validate: true
24341
24785
  });
24342
24786
  return {
24343
- relativePathFromCwd: (0, import_node_path149.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename),
24787
+ relativePathFromCwd: (0, import_node_path151.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename),
24344
24788
  frontmatter: subagent.getFrontmatter(),
24345
24789
  body: subagent.getBody()
24346
24790
  };
@@ -24359,7 +24803,7 @@ async function putSubagent({
24359
24803
  relativePath: relativePathFromCwd,
24360
24804
  intendedRootDir: process.cwd()
24361
24805
  });
24362
- const filename = (0, import_node_path149.basename)(relativePathFromCwd);
24806
+ const filename = (0, import_node_path151.basename)(relativePathFromCwd);
24363
24807
  const estimatedSize = JSON.stringify(frontmatter).length + body.length;
24364
24808
  if (estimatedSize > maxSubagentSizeBytes) {
24365
24809
  throw new Error(
@@ -24369,7 +24813,7 @@ async function putSubagent({
24369
24813
  try {
24370
24814
  const existingSubagents = await listSubagents();
24371
24815
  const isUpdate = existingSubagents.some(
24372
- (subagent2) => subagent2.relativePathFromCwd === (0, import_node_path149.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename)
24816
+ (subagent2) => subagent2.relativePathFromCwd === (0, import_node_path151.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename)
24373
24817
  );
24374
24818
  if (!isUpdate && existingSubagents.length >= maxSubagentsCount) {
24375
24819
  throw new Error(
@@ -24384,11 +24828,11 @@ async function putSubagent({
24384
24828
  body,
24385
24829
  validate: true
24386
24830
  });
24387
- const subagentsDir = (0, import_node_path149.join)(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH);
24831
+ const subagentsDir = (0, import_node_path151.join)(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH);
24388
24832
  await ensureDir(subagentsDir);
24389
24833
  await writeFileContent(subagent.getFilePath(), subagent.getFileContent());
24390
24834
  return {
24391
- relativePathFromCwd: (0, import_node_path149.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename),
24835
+ relativePathFromCwd: (0, import_node_path151.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename),
24392
24836
  frontmatter: subagent.getFrontmatter(),
24393
24837
  body: subagent.getBody()
24394
24838
  };
@@ -24403,12 +24847,12 @@ async function deleteSubagent({ relativePathFromCwd }) {
24403
24847
  relativePath: relativePathFromCwd,
24404
24848
  intendedRootDir: process.cwd()
24405
24849
  });
24406
- const filename = (0, import_node_path149.basename)(relativePathFromCwd);
24407
- const fullPath = (0, import_node_path149.join)(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename);
24850
+ const filename = (0, import_node_path151.basename)(relativePathFromCwd);
24851
+ const fullPath = (0, import_node_path151.join)(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename);
24408
24852
  try {
24409
24853
  await removeFile(fullPath);
24410
24854
  return {
24411
- relativePathFromCwd: (0, import_node_path149.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename)
24855
+ relativePathFromCwd: (0, import_node_path151.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename)
24412
24856
  };
24413
24857
  } catch (error) {
24414
24858
  throw new Error(
@@ -24420,23 +24864,23 @@ async function deleteSubagent({ relativePathFromCwd }) {
24420
24864
  }
24421
24865
  }
24422
24866
  var subagentToolSchemas = {
24423
- listSubagents: import_mini81.z.object({}),
24424
- getSubagent: import_mini81.z.object({
24425
- relativePathFromCwd: import_mini81.z.string()
24867
+ listSubagents: import_mini82.z.object({}),
24868
+ getSubagent: import_mini82.z.object({
24869
+ relativePathFromCwd: import_mini82.z.string()
24426
24870
  }),
24427
- putSubagent: import_mini81.z.object({
24428
- relativePathFromCwd: import_mini81.z.string(),
24871
+ putSubagent: import_mini82.z.object({
24872
+ relativePathFromCwd: import_mini82.z.string(),
24429
24873
  frontmatter: RulesyncSubagentFrontmatterSchema,
24430
- body: import_mini81.z.string()
24874
+ body: import_mini82.z.string()
24431
24875
  }),
24432
- deleteSubagent: import_mini81.z.object({
24433
- relativePathFromCwd: import_mini81.z.string()
24876
+ deleteSubagent: import_mini82.z.object({
24877
+ relativePathFromCwd: import_mini82.z.string()
24434
24878
  })
24435
24879
  };
24436
24880
  var subagentTools = {
24437
24881
  listSubagents: {
24438
24882
  name: "listSubagents",
24439
- description: `List all subagents from ${(0, import_node_path149.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
24883
+ description: `List all subagents from ${(0, import_node_path151.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
24440
24884
  parameters: subagentToolSchemas.listSubagents,
24441
24885
  execute: async () => {
24442
24886
  const subagents = await listSubagents();
@@ -24478,7 +24922,7 @@ var subagentTools = {
24478
24922
  };
24479
24923
 
24480
24924
  // src/mcp/tools.ts
24481
- var rulesyncFeatureSchema = import_mini82.z.enum([
24925
+ var rulesyncFeatureSchema = import_mini83.z.enum([
24482
24926
  "rule",
24483
24927
  "command",
24484
24928
  "subagent",
@@ -24488,21 +24932,21 @@ var rulesyncFeatureSchema = import_mini82.z.enum([
24488
24932
  "generate",
24489
24933
  "import"
24490
24934
  ]);
24491
- var rulesyncOperationSchema = import_mini82.z.enum(["list", "get", "put", "delete", "run"]);
24492
- var skillFileSchema = import_mini82.z.object({
24493
- name: import_mini82.z.string(),
24494
- body: import_mini82.z.string()
24935
+ var rulesyncOperationSchema = import_mini83.z.enum(["list", "get", "put", "delete", "run"]);
24936
+ var skillFileSchema = import_mini83.z.object({
24937
+ name: import_mini83.z.string(),
24938
+ body: import_mini83.z.string()
24495
24939
  });
24496
- var rulesyncToolSchema = import_mini82.z.object({
24940
+ var rulesyncToolSchema = import_mini83.z.object({
24497
24941
  feature: rulesyncFeatureSchema,
24498
24942
  operation: rulesyncOperationSchema,
24499
- targetPathFromCwd: import_mini82.z.optional(import_mini82.z.string()),
24500
- frontmatter: import_mini82.z.optional(import_mini82.z.unknown()),
24501
- body: import_mini82.z.optional(import_mini82.z.string()),
24502
- otherFiles: import_mini82.z.optional(import_mini82.z.array(skillFileSchema)),
24503
- content: import_mini82.z.optional(import_mini82.z.string()),
24504
- generateOptions: import_mini82.z.optional(generateOptionsSchema),
24505
- importOptions: import_mini82.z.optional(importOptionsSchema)
24943
+ targetPathFromCwd: import_mini83.z.optional(import_mini83.z.string()),
24944
+ frontmatter: import_mini83.z.optional(import_mini83.z.unknown()),
24945
+ body: import_mini83.z.optional(import_mini83.z.string()),
24946
+ otherFiles: import_mini83.z.optional(import_mini83.z.array(skillFileSchema)),
24947
+ content: import_mini83.z.optional(import_mini83.z.string()),
24948
+ generateOptions: import_mini83.z.optional(generateOptionsSchema),
24949
+ importOptions: import_mini83.z.optional(importOptionsSchema)
24506
24950
  });
24507
24951
  var supportedOperationsByFeature = {
24508
24952
  rule: ["list", "get", "put", "delete"],
@@ -25110,7 +25554,7 @@ function wrapCommand({
25110
25554
  }
25111
25555
 
25112
25556
  // src/cli/index.ts
25113
- var getVersion = () => "7.30.0";
25557
+ var getVersion = () => "8.0.0";
25114
25558
  function wrapCommand2(name, errorCode, handler) {
25115
25559
  return wrapCommand({ name, errorCode, handler, getVersion });
25116
25560
  }