rulesync 8.5.0 → 8.7.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.
@@ -349,7 +349,13 @@ var SourceEntrySchema = z3.object({
349
349
  refine((v) => !isAbsolute(v), "path must not be absolute"),
350
350
  refine((v) => !hasControlCharacters(v), "path must not contain control characters")
351
351
  )
352
- )
352
+ ),
353
+ // gh-mode-only fields. Ignored by --mode rulesync. Defaults applied at the
354
+ // gh install site (`agent` defaults to "github-copilot", `scope` to "project").
355
+ agent: optional(
356
+ z3.enum(["github-copilot", "claude-code", "cursor", "codex", "gemini", "antigravity"])
357
+ ),
358
+ scope: optional(z3.enum(["project", "user"]))
353
359
  });
354
360
  var ConfigParamsSchema = z3.object({
355
361
  baseDirs: z3.array(z3.string()),
@@ -860,6 +866,176 @@ function getBaseDirsInLightOfGlobal({
860
866
  return resolvedBaseDirs;
861
867
  }
862
868
 
869
+ // src/types/json-output.ts
870
+ var ErrorCodes = {
871
+ CONFIG_NOT_FOUND: "CONFIG_NOT_FOUND",
872
+ RULESYNC_DIR_NOT_FOUND: "RULESYNC_DIR_NOT_FOUND",
873
+ INVALID_TARGET: "INVALID_TARGET",
874
+ FETCH_FAILED: "FETCH_FAILED",
875
+ WRITE_FAILED: "WRITE_FAILED",
876
+ VALIDATION_FAILED: "VALIDATION_FAILED",
877
+ GENERATION_FAILED: "GENERATION_FAILED",
878
+ IMPORT_FAILED: "IMPORT_FAILED",
879
+ INSTALL_FAILED: "INSTALL_FAILED",
880
+ UPDATE_FAILED: "UPDATE_FAILED",
881
+ GITIGNORE_FAILED: "GITIGNORE_FAILED",
882
+ INIT_FAILED: "INIT_FAILED",
883
+ MCP_FAILED: "MCP_FAILED",
884
+ UNKNOWN_ERROR: "UNKNOWN_ERROR"
885
+ };
886
+ var CLIError = class extends Error {
887
+ constructor(message, code = ErrorCodes.UNKNOWN_ERROR, exitCode = 1) {
888
+ super(message);
889
+ this.code = code;
890
+ this.exitCode = exitCode;
891
+ this.name = "CLIError";
892
+ }
893
+ };
894
+
895
+ // src/utils/logger.ts
896
+ var BaseLogger = class {
897
+ _verbose = false;
898
+ _silent = false;
899
+ constructor({ verbose = false, silent = false } = {}) {
900
+ this._silent = silent;
901
+ this._verbose = verbose && !silent;
902
+ }
903
+ get verbose() {
904
+ return this._verbose;
905
+ }
906
+ get silent() {
907
+ return this._silent;
908
+ }
909
+ configure({ verbose, silent }) {
910
+ if (verbose && silent) {
911
+ this._silent = false;
912
+ if (!isEnvTest()) {
913
+ this.onConflictingFlags();
914
+ }
915
+ }
916
+ this._silent = silent;
917
+ this._verbose = verbose && !silent;
918
+ }
919
+ onConflictingFlags() {
920
+ console.warn("Both --verbose and --silent specified; --silent takes precedence");
921
+ }
922
+ };
923
+ var ConsoleLogger = class extends BaseLogger {
924
+ isSuppressed() {
925
+ return isEnvTest() || this._silent;
926
+ }
927
+ get jsonMode() {
928
+ return false;
929
+ }
930
+ captureData(_key, _value) {
931
+ }
932
+ getJsonData() {
933
+ return {};
934
+ }
935
+ outputJson(_success, _error) {
936
+ }
937
+ info(message, ...args) {
938
+ if (this.isSuppressed()) return;
939
+ console.log(message, ...args);
940
+ }
941
+ success(message, ...args) {
942
+ if (this.isSuppressed()) return;
943
+ console.log(message, ...args);
944
+ }
945
+ warn(message, ...args) {
946
+ if (this.isSuppressed()) return;
947
+ console.warn(message, ...args);
948
+ }
949
+ // Errors are always emitted, even in silent mode
950
+ error(message, _code, ...args) {
951
+ if (isEnvTest()) return;
952
+ const errorMessage = message instanceof Error ? message.message : message;
953
+ console.error(errorMessage, ...args);
954
+ }
955
+ debug(message, ...args) {
956
+ if (!this._verbose || this.isSuppressed()) return;
957
+ console.log(message, ...args);
958
+ }
959
+ };
960
+ var JsonLogger = class extends BaseLogger {
961
+ _jsonOutputDone = false;
962
+ _jsonData = {};
963
+ _commandName;
964
+ _version;
965
+ constructor({
966
+ command,
967
+ version,
968
+ verbose = false,
969
+ silent = false
970
+ }) {
971
+ super({ verbose, silent });
972
+ this._commandName = command;
973
+ this._version = version;
974
+ }
975
+ // Suppress raw console.warn in JSON mode to avoid non-JSON text on stderr
976
+ onConflictingFlags() {
977
+ }
978
+ get jsonMode() {
979
+ return true;
980
+ }
981
+ captureData(key, value) {
982
+ this._jsonData[key] = value;
983
+ }
984
+ getJsonData() {
985
+ return { ...this._jsonData };
986
+ }
987
+ outputJson(success, error) {
988
+ if (this._jsonOutputDone) return;
989
+ this._jsonOutputDone = true;
990
+ const output = {
991
+ success,
992
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
993
+ command: this._commandName,
994
+ version: this._version
995
+ };
996
+ if (success) {
997
+ output.data = this._jsonData;
998
+ } else if (error) {
999
+ output.error = {
1000
+ code: error.code,
1001
+ message: error.message
1002
+ };
1003
+ if (error.details) {
1004
+ output.error.details = error.details;
1005
+ }
1006
+ if (error.stack) {
1007
+ output.error.stack = error.stack;
1008
+ }
1009
+ }
1010
+ const jsonStr = JSON.stringify(output, null, 2);
1011
+ if (success) {
1012
+ console.log(jsonStr);
1013
+ } else {
1014
+ console.error(jsonStr);
1015
+ }
1016
+ }
1017
+ info(_message, ..._args) {
1018
+ }
1019
+ success(_message, ..._args) {
1020
+ }
1021
+ warn(_message, ..._args) {
1022
+ }
1023
+ error(message, code, ..._args) {
1024
+ if (isEnvTest()) return;
1025
+ const errorMessage = message instanceof Error ? message.message : message;
1026
+ const errorInfo = {
1027
+ code: code || ErrorCodes.UNKNOWN_ERROR,
1028
+ message: errorMessage
1029
+ };
1030
+ if (this._verbose && message instanceof Error && message.stack) {
1031
+ errorInfo.stack = message.stack;
1032
+ }
1033
+ this.outputJson(false, errorInfo);
1034
+ }
1035
+ debug(_message, ..._args) {
1036
+ }
1037
+ };
1038
+
863
1039
  // src/lib/generate.ts
864
1040
  import { join as join138 } from "path";
865
1041
  import { intersection } from "es-toolkit";
@@ -3599,7 +3775,7 @@ var CommandsProcessor = class extends FeatureProcessor {
3599
3775
  };
3600
3776
 
3601
3777
  // src/features/hooks/hooks-processor.ts
3602
- import { z as z20 } from "zod/mini";
3778
+ import { z as z19 } from "zod/mini";
3603
3779
 
3604
3780
  // src/types/hooks.ts
3605
3781
  import { z as z16 } from "zod/mini";
@@ -3903,22 +4079,34 @@ function canonicalToToolHooks({
3903
4079
  `matcher "${matcherKey}" on "${eventName}" hook will be ignored \u2014 this event does not support matchers`
3904
4080
  );
3905
4081
  }
3906
- const hooks = defs.map((def) => {
4082
+ const hooks = [];
4083
+ for (const def of defs) {
4084
+ const hookType = def.type ?? "command";
4085
+ if (converterConfig.supportedHookTypes && !converterConfig.supportedHookTypes.has(hookType)) {
4086
+ continue;
4087
+ }
3907
4088
  const commandText = def.command;
3908
4089
  const trimmedCommand = typeof commandText === "string" ? commandText.trimStart() : void 0;
3909
- const shouldPrefix = typeof trimmedCommand === "string" && !trimmedCommand.startsWith("$") && (!converterConfig.prefixDotRelativeCommandsOnly || trimmedCommand.startsWith("."));
4090
+ const shouldPrefix = converterConfig.projectDirVar !== "" && typeof trimmedCommand === "string" && !trimmedCommand.startsWith("$") && (!converterConfig.prefixDotRelativeCommandsOnly || trimmedCommand.startsWith("."));
3910
4091
  const command = shouldPrefix && typeof trimmedCommand === "string" ? `${converterConfig.projectDirVar}/${trimmedCommand.replace(/^\.\//, "")}` : def.command;
3911
- return {
3912
- type: def.type ?? "command",
4092
+ hooks.push({
4093
+ type: hookType,
3913
4094
  ...command !== void 0 && command !== null && { command },
3914
4095
  ...def.timeout !== void 0 && def.timeout !== null && { timeout: def.timeout },
3915
- ...def.prompt !== void 0 && def.prompt !== null && { prompt: def.prompt }
3916
- };
3917
- });
4096
+ ...def.prompt !== void 0 && def.prompt !== null && { prompt: def.prompt },
4097
+ ...converterConfig.passthroughFields?.includes("name") && def.name !== void 0 && def.name !== null && { name: def.name },
4098
+ ...converterConfig.passthroughFields?.includes("description") && def.description !== void 0 && def.description !== null && { description: def.description }
4099
+ });
4100
+ }
4101
+ if (hooks.length === 0) {
4102
+ continue;
4103
+ }
3918
4104
  const includeMatcher = matcherKey && !isNoMatcherEvent;
3919
4105
  entries.push(includeMatcher ? { matcher: matcherKey, hooks } : { hooks });
3920
4106
  }
3921
- result[toolEventName] = entries;
4107
+ if (entries.length > 0) {
4108
+ result[toolEventName] = entries;
4109
+ }
3922
4110
  }
3923
4111
  return result;
3924
4112
  }
@@ -3939,7 +4127,7 @@ function toolHooksToCanonical({
3939
4127
  const hookDefs = rawEntry.hooks ?? [];
3940
4128
  for (const h of hookDefs) {
3941
4129
  const cmd = typeof h.command === "string" ? h.command : void 0;
3942
- const command = typeof cmd === "string" && cmd.includes(`${converterConfig.projectDirVar}/`) ? cmd.replace(
4130
+ const command = converterConfig.projectDirVar !== "" && typeof cmd === "string" && cmd.includes(`${converterConfig.projectDirVar}/`) ? cmd.replace(
3943
4131
  new RegExp(
3944
4132
  `^${converterConfig.projectDirVar.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\/?`
3945
4133
  ),
@@ -3953,6 +4141,8 @@ function toolHooksToCanonical({
3953
4141
  ...command !== void 0 && command !== null && { command },
3954
4142
  ...timeout !== void 0 && timeout !== null && { timeout },
3955
4143
  ...prompt !== void 0 && prompt !== null && { prompt },
4144
+ ...converterConfig.passthroughFields?.includes("name") && typeof h.name === "string" && { name: h.name },
4145
+ ...converterConfig.passthroughFields?.includes("description") && typeof h.description === "string" && { description: h.description },
3956
4146
  ...rawEntry.matcher !== void 0 && rawEntry.matcher !== null && rawEntry.matcher !== "" && { matcher: rawEntry.matcher }
3957
4147
  });
3958
4148
  }
@@ -4051,6 +4241,9 @@ var ToolHooks = class extends ToolFile {
4051
4241
  static forDeletion(_params) {
4052
4242
  throw new Error("Please implement this method in the subclass.");
4053
4243
  }
4244
+ static async getAuxiliaryFiles(_params) {
4245
+ return [];
4246
+ }
4054
4247
  };
4055
4248
 
4056
4249
  // src/features/hooks/claudecode-hooks.ts
@@ -4172,89 +4365,28 @@ var ClaudecodeHooks = class _ClaudecodeHooks extends ToolHooks {
4172
4365
  // src/features/hooks/codexcli-hooks.ts
4173
4366
  import { join as join23 } from "path";
4174
4367
  import * as smolToml2 from "smol-toml";
4175
- import { z as z17 } from "zod/mini";
4176
- function canonicalToCodexcliHooks(config) {
4177
- const codexSupported = new Set(CODEXCLI_HOOK_EVENTS);
4178
- const sharedHooks = {};
4179
- for (const [event, defs] of Object.entries(config.hooks)) {
4180
- if (codexSupported.has(event)) {
4181
- sharedHooks[event] = defs;
4182
- }
4183
- }
4184
- const effectiveHooks = {
4185
- ...sharedHooks,
4186
- ...config.codexcli?.hooks
4187
- };
4188
- const codex = {};
4189
- for (const [eventName, definitions] of Object.entries(effectiveHooks)) {
4190
- const codexEventName = CANONICAL_TO_CODEXCLI_EVENT_NAMES[eventName] ?? eventName;
4191
- const byMatcher = /* @__PURE__ */ new Map();
4192
- for (const def of definitions) {
4193
- const key = def.matcher ?? "";
4194
- const list = byMatcher.get(key);
4195
- if (list) list.push(def);
4196
- else byMatcher.set(key, [def]);
4197
- }
4198
- const entries = [];
4199
- for (const [matcherKey, defs] of byMatcher) {
4200
- const commandDefs = defs.filter((def) => !def.type || def.type === "command");
4201
- if (commandDefs.length === 0) continue;
4202
- const hooks = commandDefs.map((def) => ({
4203
- type: "command",
4204
- ...def.command !== void 0 && def.command !== null && { command: def.command },
4205
- ...def.timeout !== void 0 && def.timeout !== null && { timeout: def.timeout }
4206
- }));
4207
- entries.push(matcherKey ? { matcher: matcherKey, hooks } : { hooks });
4208
- }
4209
- if (entries.length > 0) {
4210
- codex[codexEventName] = entries;
4211
- }
4212
- }
4213
- return codex;
4214
- }
4215
- var CodexHookEntrySchema = z17.looseObject({
4216
- type: z17.optional(z17.string()),
4217
- command: z17.optional(z17.string()),
4218
- timeout: z17.optional(z17.number())
4219
- });
4220
- var CodexMatcherEntrySchema = z17.looseObject({
4221
- matcher: z17.optional(z17.string()),
4222
- hooks: z17.optional(z17.array(CodexHookEntrySchema))
4223
- });
4224
- function codexcliHooksToCanonical(codexHooks) {
4225
- if (codexHooks === null || codexHooks === void 0 || typeof codexHooks !== "object") {
4226
- return {};
4227
- }
4228
- const canonical = {};
4229
- for (const [codexEventName, matcherEntries] of Object.entries(codexHooks)) {
4230
- const eventName = CODEXCLI_TO_CANONICAL_EVENT_NAMES[codexEventName] ?? codexEventName;
4231
- if (!Array.isArray(matcherEntries)) continue;
4232
- const defs = [];
4233
- for (const rawEntry of matcherEntries) {
4234
- const parseResult = CodexMatcherEntrySchema.safeParse(rawEntry);
4235
- if (!parseResult.success) continue;
4236
- const entry = parseResult.data;
4237
- const hooks = entry.hooks ?? [];
4238
- for (const h of hooks) {
4239
- const hookType = h.type === "command" || h.type === "prompt" ? h.type : "command";
4240
- defs.push({
4241
- type: hookType,
4242
- ...h.command !== void 0 && h.command !== null && { command: h.command },
4243
- ...h.timeout !== void 0 && h.timeout !== null && { timeout: h.timeout },
4244
- ...entry.matcher !== void 0 && entry.matcher !== null && entry.matcher !== "" && { matcher: entry.matcher }
4245
- });
4246
- }
4247
- }
4248
- if (defs.length > 0) {
4249
- canonical[eventName] = defs;
4250
- }
4251
- }
4252
- return canonical;
4253
- }
4368
+ var CODEXCLI_CONVERTER_CONFIG = {
4369
+ supportedEvents: CODEXCLI_HOOK_EVENTS,
4370
+ canonicalToToolEventNames: CANONICAL_TO_CODEXCLI_EVENT_NAMES,
4371
+ toolToCanonicalEventNames: CODEXCLI_TO_CANONICAL_EVENT_NAMES,
4372
+ projectDirVar: "",
4373
+ supportedHookTypes: /* @__PURE__ */ new Set(["command"]),
4374
+ passthroughFields: ["name", "description"]
4375
+ };
4254
4376
  async function buildCodexConfigTomlContent({ baseDir }) {
4255
4377
  const configPath = join23(baseDir, ".codex", "config.toml");
4256
4378
  const existingContent = await readFileContentOrNull(configPath) ?? smolToml2.stringify({});
4257
- const configToml = smolToml2.parse(existingContent);
4379
+ let configToml;
4380
+ try {
4381
+ configToml = smolToml2.parse(existingContent);
4382
+ } catch (error) {
4383
+ throw new Error(
4384
+ `Failed to parse existing Codex CLI config at ${configPath}: ${formatError(error)}`,
4385
+ {
4386
+ cause: error
4387
+ }
4388
+ );
4389
+ }
4258
4390
  if (typeof configToml.features !== "object" || configToml.features === null) {
4259
4391
  configToml.features = {};
4260
4392
  }
@@ -4309,7 +4441,11 @@ var CodexcliHooks = class _CodexcliHooks extends ToolHooks {
4309
4441
  }) {
4310
4442
  const paths = _CodexcliHooks.getSettablePaths({ global });
4311
4443
  const config = rulesyncHooks.getJson();
4312
- const codexHooks = canonicalToCodexcliHooks(config);
4444
+ const codexHooks = canonicalToToolHooks({
4445
+ config,
4446
+ toolOverrideHooks: config.codexcli?.hooks,
4447
+ converterConfig: CODEXCLI_CONVERTER_CONFIG
4448
+ });
4313
4449
  const fileContent = JSON.stringify({ hooks: codexHooks }, null, 2);
4314
4450
  return new _CodexcliHooks({
4315
4451
  baseDir,
@@ -4331,7 +4467,10 @@ var CodexcliHooks = class _CodexcliHooks extends ToolHooks {
4331
4467
  }
4332
4468
  );
4333
4469
  }
4334
- const hooks = codexcliHooksToCanonical(parsed.hooks);
4470
+ const hooks = toolHooksToCanonical({
4471
+ hooks: parsed.hooks,
4472
+ converterConfig: CODEXCLI_CONVERTER_CONFIG
4473
+ });
4335
4474
  return this.toRulesyncHooksDefault({
4336
4475
  fileContent: JSON.stringify({ version: 1, hooks }, null, 2)
4337
4476
  });
@@ -4352,16 +4491,21 @@ var CodexcliHooks = class _CodexcliHooks extends ToolHooks {
4352
4491
  validate: false
4353
4492
  });
4354
4493
  }
4494
+ static async getAuxiliaryFiles({
4495
+ baseDir = process.cwd()
4496
+ } = {}) {
4497
+ return [await CodexcliConfigToml.fromBaseDir({ baseDir })];
4498
+ }
4355
4499
  };
4356
4500
 
4357
4501
  // src/features/hooks/copilot-hooks.ts
4358
4502
  import { join as join24 } from "path";
4359
- import { z as z18 } from "zod/mini";
4360
- var CopilotHookEntrySchema = z18.looseObject({
4361
- type: z18.string(),
4362
- bash: z18.optional(z18.string()),
4363
- powershell: z18.optional(z18.string()),
4364
- timeoutSec: z18.optional(z18.number())
4503
+ import { z as z17 } from "zod/mini";
4504
+ var CopilotHookEntrySchema = z17.looseObject({
4505
+ type: z17.string(),
4506
+ bash: z17.optional(z17.string()),
4507
+ powershell: z17.optional(z17.string()),
4508
+ timeoutSec: z17.optional(z17.number())
4365
4509
  });
4366
4510
  function canonicalToCopilotHooks(config) {
4367
4511
  const canonicalSchemaKeys = Object.keys(HookDefinitionSchema.shape);
@@ -4892,7 +5036,7 @@ var FactorydroidHooks = class _FactorydroidHooks extends ToolHooks {
4892
5036
 
4893
5037
  // src/features/hooks/geminicli-hooks.ts
4894
5038
  import { join as join28 } from "path";
4895
- import { z as z19 } from "zod/mini";
5039
+ import { z as z18 } from "zod/mini";
4896
5040
  function canonicalToGeminicliHooks(config) {
4897
5041
  const geminiSupported = new Set(GEMINICLI_HOOK_EVENTS);
4898
5042
  const sharedHooks = {};
@@ -4936,16 +5080,16 @@ function canonicalToGeminicliHooks(config) {
4936
5080
  }
4937
5081
  return gemini;
4938
5082
  }
4939
- var GeminiHookEntrySchema = z19.looseObject({
4940
- type: z19.optional(z19.string()),
4941
- command: z19.optional(z19.string()),
4942
- timeout: z19.optional(z19.number()),
4943
- name: z19.optional(z19.string()),
4944
- description: z19.optional(z19.string())
5083
+ var GeminiHookEntrySchema = z18.looseObject({
5084
+ type: z18.optional(z18.string()),
5085
+ command: z18.optional(z18.string()),
5086
+ timeout: z18.optional(z18.number()),
5087
+ name: z18.optional(z18.string()),
5088
+ description: z18.optional(z18.string())
4945
5089
  });
4946
- var GeminiMatcherEntrySchema = z19.looseObject({
4947
- matcher: z19.optional(z19.string()),
4948
- hooks: z19.optional(z19.array(GeminiHookEntrySchema))
5090
+ var GeminiMatcherEntrySchema = z18.looseObject({
5091
+ matcher: z18.optional(z18.string()),
5092
+ hooks: z18.optional(z18.array(GeminiHookEntrySchema))
4949
5093
  });
4950
5094
  function geminiHooksToCanonical(geminiHooks) {
4951
5095
  if (geminiHooks === null || geminiHooks === void 0 || typeof geminiHooks !== "object") {
@@ -5329,7 +5473,7 @@ var hooksProcessorToolTargetTuple = [
5329
5473
  "geminicli",
5330
5474
  "deepagents"
5331
5475
  ];
5332
- var HooksProcessorToolTargetSchema = z20.enum(hooksProcessorToolTargetTuple);
5476
+ var HooksProcessorToolTargetSchema = z19.enum(hooksProcessorToolTargetTuple);
5333
5477
  var toolHooksFactories = /* @__PURE__ */ new Map([
5334
5478
  [
5335
5479
  "cursor",
@@ -5588,8 +5732,12 @@ var HooksProcessor = class extends FeatureProcessor {
5588
5732
  global: this.global
5589
5733
  });
5590
5734
  const result = [toolHooks];
5591
- if (this.toolTarget === "codexcli") {
5592
- result.push(await CodexcliConfigToml.fromBaseDir({ baseDir: this.baseDir }));
5735
+ const auxiliaryFiles = await factory.class.getAuxiliaryFiles?.({
5736
+ baseDir: this.baseDir,
5737
+ global: this.global
5738
+ });
5739
+ if (auxiliaryFiles && auxiliaryFiles.length > 0) {
5740
+ result.push(...auxiliaryFiles);
5593
5741
  }
5594
5742
  return result;
5595
5743
  }
@@ -5609,7 +5757,7 @@ var HooksProcessor = class extends FeatureProcessor {
5609
5757
  };
5610
5758
 
5611
5759
  // src/features/ignore/ignore-processor.ts
5612
- import { z as z22 } from "zod/mini";
5760
+ import { z as z21 } from "zod/mini";
5613
5761
 
5614
5762
  // src/features/ignore/augmentcode-ignore.ts
5615
5763
  import { join as join32 } from "path";
@@ -5788,12 +5936,12 @@ var AugmentcodeIgnore = class _AugmentcodeIgnore extends ToolIgnore {
5788
5936
  // src/features/ignore/claudecode-ignore.ts
5789
5937
  import { join as join33 } from "path";
5790
5938
  import { uniq } from "es-toolkit";
5791
- import { z as z21 } from "zod/mini";
5939
+ import { z as z20 } from "zod/mini";
5792
5940
  var SHARED_SETTINGS_FILE = "settings.json";
5793
5941
  var LOCAL_SETTINGS_FILE = "settings.local.json";
5794
5942
  var DEFAULT_FILE_MODE = "shared";
5795
- var ClaudecodeIgnoreOptionsSchema = z21.looseObject({
5796
- fileMode: z21.optional(z21.enum(["shared", "local"]))
5943
+ var ClaudecodeIgnoreOptionsSchema = z20.looseObject({
5944
+ fileMode: z20.optional(z20.enum(["shared", "local"]))
5797
5945
  });
5798
5946
  var resolveFileMode = (options) => {
5799
5947
  if (!options) return DEFAULT_FILE_MODE;
@@ -6637,7 +6785,7 @@ var ignoreProcessorToolTargets = [
6637
6785
  "windsurf",
6638
6786
  "zed"
6639
6787
  ];
6640
- var IgnoreProcessorToolTargetSchema = z22.enum(ignoreProcessorToolTargets);
6788
+ var IgnoreProcessorToolTargetSchema = z21.enum(ignoreProcessorToolTargets);
6641
6789
  var toolIgnoreFactories = /* @__PURE__ */ new Map([
6642
6790
  ["augmentcode", { class: AugmentcodeIgnore }],
6643
6791
  ["claudecode", { class: ClaudecodeIgnore }],
@@ -6780,7 +6928,7 @@ var IgnoreProcessor = class extends FeatureProcessor {
6780
6928
  };
6781
6929
 
6782
6930
  // src/features/mcp/mcp-processor.ts
6783
- import { z as z27 } from "zod/mini";
6931
+ import { z as z26 } from "zod/mini";
6784
6932
 
6785
6933
  // src/features/mcp/claudecode-mcp.ts
6786
6934
  import { join as join46 } from "path";
@@ -6788,47 +6936,47 @@ import { join as join46 } from "path";
6788
6936
  // src/features/mcp/rulesync-mcp.ts
6789
6937
  import { join as join45 } from "path";
6790
6938
  import { omit } from "es-toolkit/object";
6791
- import { z as z24 } from "zod/mini";
6939
+ import { z as z23 } from "zod/mini";
6792
6940
 
6793
6941
  // src/types/mcp.ts
6794
- import { z as z23 } from "zod/mini";
6795
- var McpServerSchema = z23.looseObject({
6796
- type: z23.optional(z23.enum(["local", "stdio", "sse", "http"])),
6797
- command: z23.optional(z23.union([z23.string(), z23.array(z23.string())])),
6798
- args: z23.optional(z23.array(z23.string())),
6799
- url: z23.optional(z23.string()),
6800
- httpUrl: z23.optional(z23.string()),
6801
- env: z23.optional(z23.record(z23.string(), z23.string())),
6802
- disabled: z23.optional(z23.boolean()),
6803
- networkTimeout: z23.optional(z23.number()),
6804
- timeout: z23.optional(z23.number()),
6805
- trust: z23.optional(z23.boolean()),
6806
- cwd: z23.optional(z23.string()),
6807
- transport: z23.optional(z23.enum(["local", "stdio", "sse", "http"])),
6808
- alwaysAllow: z23.optional(z23.array(z23.string())),
6809
- tools: z23.optional(z23.array(z23.string())),
6810
- kiroAutoApprove: z23.optional(z23.array(z23.string())),
6811
- kiroAutoBlock: z23.optional(z23.array(z23.string())),
6812
- headers: z23.optional(z23.record(z23.string(), z23.string())),
6813
- enabledTools: z23.optional(z23.array(z23.string())),
6814
- disabledTools: z23.optional(z23.array(z23.string()))
6942
+ import { z as z22 } from "zod/mini";
6943
+ var McpServerSchema = z22.looseObject({
6944
+ type: z22.optional(z22.enum(["local", "stdio", "sse", "http"])),
6945
+ command: z22.optional(z22.union([z22.string(), z22.array(z22.string())])),
6946
+ args: z22.optional(z22.array(z22.string())),
6947
+ url: z22.optional(z22.string()),
6948
+ httpUrl: z22.optional(z22.string()),
6949
+ env: z22.optional(z22.record(z22.string(), z22.string())),
6950
+ disabled: z22.optional(z22.boolean()),
6951
+ networkTimeout: z22.optional(z22.number()),
6952
+ timeout: z22.optional(z22.number()),
6953
+ trust: z22.optional(z22.boolean()),
6954
+ cwd: z22.optional(z22.string()),
6955
+ transport: z22.optional(z22.enum(["local", "stdio", "sse", "http"])),
6956
+ alwaysAllow: z22.optional(z22.array(z22.string())),
6957
+ tools: z22.optional(z22.array(z22.string())),
6958
+ kiroAutoApprove: z22.optional(z22.array(z22.string())),
6959
+ kiroAutoBlock: z22.optional(z22.array(z22.string())),
6960
+ headers: z22.optional(z22.record(z22.string(), z22.string())),
6961
+ enabledTools: z22.optional(z22.array(z22.string())),
6962
+ disabledTools: z22.optional(z22.array(z22.string()))
6815
6963
  });
6816
- var McpServersSchema = z23.record(z23.string(), McpServerSchema);
6964
+ var McpServersSchema = z22.record(z22.string(), McpServerSchema);
6817
6965
  function isMcpServers(value) {
6818
6966
  return value !== void 0 && value !== null && typeof value === "object" && !Array.isArray(value);
6819
6967
  }
6820
6968
 
6821
6969
  // src/features/mcp/rulesync-mcp.ts
6822
- var RulesyncMcpServerSchema = z24.extend(McpServerSchema, {
6823
- targets: z24.optional(RulesyncTargetsSchema),
6824
- description: z24.optional(z24.string()),
6825
- exposed: z24.optional(z24.boolean())
6970
+ var RulesyncMcpServerSchema = z23.extend(McpServerSchema, {
6971
+ targets: z23.optional(RulesyncTargetsSchema),
6972
+ description: z23.optional(z23.string()),
6973
+ exposed: z23.optional(z23.boolean())
6826
6974
  });
6827
- var RulesyncMcpConfigSchema = z24.object({
6828
- mcpServers: z24.record(z24.string(), RulesyncMcpServerSchema)
6975
+ var RulesyncMcpConfigSchema = z23.object({
6976
+ mcpServers: z23.record(z23.string(), RulesyncMcpServerSchema)
6829
6977
  });
6830
- var RulesyncMcpFileSchema = z24.looseObject({
6831
- $schema: z24.optional(z24.string()),
6978
+ var RulesyncMcpFileSchema = z23.looseObject({
6979
+ $schema: z23.optional(z23.string()),
6832
6980
  ...RulesyncMcpConfigSchema.shape
6833
6981
  });
6834
6982
  var RulesyncMcp = class _RulesyncMcp extends RulesyncFile {
@@ -8031,25 +8179,25 @@ var JunieMcp = class _JunieMcp extends ToolMcp {
8031
8179
  // src/features/mcp/kilo-mcp.ts
8032
8180
  import { join as join56 } from "path";
8033
8181
  import { parse as parseJsonc3 } from "jsonc-parser";
8034
- import { z as z25 } from "zod/mini";
8035
- var KiloMcpLocalServerSchema = z25.object({
8036
- type: z25.literal("local"),
8037
- command: z25.array(z25.string()),
8038
- environment: z25.optional(z25.record(z25.string(), z25.string())),
8039
- enabled: z25._default(z25.boolean(), true),
8040
- cwd: z25.optional(z25.string())
8182
+ import { z as z24 } from "zod/mini";
8183
+ var KiloMcpLocalServerSchema = z24.object({
8184
+ type: z24.literal("local"),
8185
+ command: z24.array(z24.string()),
8186
+ environment: z24.optional(z24.record(z24.string(), z24.string())),
8187
+ enabled: z24._default(z24.boolean(), true),
8188
+ cwd: z24.optional(z24.string())
8041
8189
  });
8042
- var KiloMcpRemoteServerSchema = z25.object({
8043
- type: z25.literal("remote"),
8044
- url: z25.string(),
8045
- headers: z25.optional(z25.record(z25.string(), z25.string())),
8046
- enabled: z25._default(z25.boolean(), true)
8190
+ var KiloMcpRemoteServerSchema = z24.object({
8191
+ type: z24.literal("remote"),
8192
+ url: z24.string(),
8193
+ headers: z24.optional(z24.record(z24.string(), z24.string())),
8194
+ enabled: z24._default(z24.boolean(), true)
8047
8195
  });
8048
- var KiloMcpServerSchema = z25.union([KiloMcpLocalServerSchema, KiloMcpRemoteServerSchema]);
8049
- var KiloConfigSchema = z25.looseObject({
8050
- $schema: z25.optional(z25.string()),
8051
- mcp: z25.optional(z25.record(z25.string(), KiloMcpServerSchema)),
8052
- tools: z25.optional(z25.record(z25.string(), z25.boolean()))
8196
+ var KiloMcpServerSchema = z24.union([KiloMcpLocalServerSchema, KiloMcpRemoteServerSchema]);
8197
+ var KiloConfigSchema = z24.looseObject({
8198
+ $schema: z24.optional(z24.string()),
8199
+ mcp: z24.optional(z24.record(z24.string(), KiloMcpServerSchema)),
8200
+ tools: z24.optional(z24.record(z24.string(), z24.boolean()))
8053
8201
  });
8054
8202
  function convertFromKiloFormat(kiloMcp, tools) {
8055
8203
  return Object.fromEntries(
@@ -8346,28 +8494,28 @@ var KiroMcp = class _KiroMcp extends ToolMcp {
8346
8494
  // src/features/mcp/opencode-mcp.ts
8347
8495
  import { join as join58 } from "path";
8348
8496
  import { parse as parseJsonc4 } from "jsonc-parser";
8349
- import { z as z26 } from "zod/mini";
8350
- var OpencodeMcpLocalServerSchema = z26.object({
8351
- type: z26.literal("local"),
8352
- command: z26.array(z26.string()),
8353
- environment: z26.optional(z26.record(z26.string(), z26.string())),
8354
- enabled: z26._default(z26.boolean(), true),
8355
- cwd: z26.optional(z26.string())
8497
+ import { z as z25 } from "zod/mini";
8498
+ var OpencodeMcpLocalServerSchema = z25.object({
8499
+ type: z25.literal("local"),
8500
+ command: z25.array(z25.string()),
8501
+ environment: z25.optional(z25.record(z25.string(), z25.string())),
8502
+ enabled: z25._default(z25.boolean(), true),
8503
+ cwd: z25.optional(z25.string())
8356
8504
  });
8357
- var OpencodeMcpRemoteServerSchema = z26.object({
8358
- type: z26.literal("remote"),
8359
- url: z26.string(),
8360
- headers: z26.optional(z26.record(z26.string(), z26.string())),
8361
- enabled: z26._default(z26.boolean(), true)
8505
+ var OpencodeMcpRemoteServerSchema = z25.object({
8506
+ type: z25.literal("remote"),
8507
+ url: z25.string(),
8508
+ headers: z25.optional(z25.record(z25.string(), z25.string())),
8509
+ enabled: z25._default(z25.boolean(), true)
8362
8510
  });
8363
- var OpencodeMcpServerSchema = z26.union([
8511
+ var OpencodeMcpServerSchema = z25.union([
8364
8512
  OpencodeMcpLocalServerSchema,
8365
8513
  OpencodeMcpRemoteServerSchema
8366
8514
  ]);
8367
- var OpencodeConfigSchema = z26.looseObject({
8368
- $schema: z26.optional(z26.string()),
8369
- mcp: z26.optional(z26.record(z26.string(), OpencodeMcpServerSchema)),
8370
- tools: z26.optional(z26.record(z26.string(), z26.boolean()))
8515
+ var OpencodeConfigSchema = z25.looseObject({
8516
+ $schema: z25.optional(z25.string()),
8517
+ mcp: z25.optional(z25.record(z25.string(), OpencodeMcpServerSchema)),
8518
+ tools: z25.optional(z25.record(z25.string(), z25.boolean()))
8371
8519
  });
8372
8520
  function convertFromOpencodeFormat(opencodeMcp, tools) {
8373
8521
  return Object.fromEntries(
@@ -8838,7 +8986,7 @@ var mcpProcessorToolTargetTuple = [
8838
8986
  "roo",
8839
8987
  "rovodev"
8840
8988
  ];
8841
- var McpProcessorToolTargetSchema = z27.enum(mcpProcessorToolTargetTuple);
8989
+ var McpProcessorToolTargetSchema = z26.enum(mcpProcessorToolTargetTuple);
8842
8990
  var toolMcpFactories = /* @__PURE__ */ new Map([
8843
8991
  [
8844
8992
  "claudecode",
@@ -9177,7 +9325,7 @@ var McpProcessor = class extends FeatureProcessor {
9177
9325
  };
9178
9326
 
9179
9327
  // src/features/permissions/permissions-processor.ts
9180
- import { z as z32 } from "zod/mini";
9328
+ import { z as z31 } from "zod/mini";
9181
9329
 
9182
9330
  // src/features/permissions/claudecode-permissions.ts
9183
9331
  import { join as join62 } from "path";
@@ -9187,14 +9335,14 @@ import { uniq as uniq3 } from "es-toolkit";
9187
9335
  import { join as join61 } from "path";
9188
9336
 
9189
9337
  // src/types/permissions.ts
9190
- import { z as z28 } from "zod/mini";
9191
- var PermissionActionSchema = z28.enum(["allow", "ask", "deny"]);
9192
- var PermissionRulesSchema = z28.record(z28.string(), PermissionActionSchema);
9193
- var PermissionsConfigSchema = z28.looseObject({
9194
- permission: z28.record(z28.string(), PermissionRulesSchema)
9338
+ import { z as z27 } from "zod/mini";
9339
+ var PermissionActionSchema = z27.enum(["allow", "ask", "deny"]);
9340
+ var PermissionRulesSchema = z27.record(z27.string(), PermissionActionSchema);
9341
+ var PermissionsConfigSchema = z27.looseObject({
9342
+ permission: z27.record(z27.string(), PermissionRulesSchema)
9195
9343
  });
9196
- var RulesyncPermissionsFileSchema = z28.looseObject({
9197
- $schema: z28.optional(z28.string()),
9344
+ var RulesyncPermissionsFileSchema = z27.looseObject({
9345
+ $schema: z27.optional(z27.string()),
9198
9346
  ...PermissionsConfigSchema.shape
9199
9347
  });
9200
9348
 
@@ -9763,15 +9911,10 @@ function mapBashActionToDecision(action) {
9763
9911
 
9764
9912
  // src/features/permissions/geminicli-permissions.ts
9765
9913
  import { join as join64 } from "path";
9766
- import { z as z29 } from "zod/mini";
9767
- var GeminiCliSettingsSchema = z29.looseObject({
9768
- tools: z29.optional(
9769
- z29.looseObject({
9770
- allowed: z29.optional(z29.array(z29.string())),
9771
- exclude: z29.optional(z29.array(z29.string()))
9772
- })
9773
- )
9774
- });
9914
+ import * as smolToml5 from "smol-toml";
9915
+ import { z as z28 } from "zod/mini";
9916
+ var GEMINICLI_POLICY_RELATIVE_DIR_PATH = join64(".gemini", "policies");
9917
+ var GEMINICLI_POLICY_FILE_NAME = "rulesync.toml";
9775
9918
  var RULESYNC_TO_GEMINICLI_TOOL_NAME = {
9776
9919
  bash: "run_shell_command",
9777
9920
  read: "read_file",
@@ -9779,16 +9922,32 @@ var RULESYNC_TO_GEMINICLI_TOOL_NAME = {
9779
9922
  write: "write_file",
9780
9923
  webfetch: "web_fetch"
9781
9924
  };
9925
+ var GEMINICLI_TO_RULESYNC_TOOL_NAME = Object.fromEntries(
9926
+ Object.entries(RULESYNC_TO_GEMINICLI_TOOL_NAME).map(([k, v]) => [v, k])
9927
+ );
9928
+ var PRIORITY_DENY = 1e6;
9929
+ var PRIORITY_ASK = 1e3;
9930
+ var PRIORITY_ALLOW = 1;
9931
+ var SINGLE_STAR_REGEX = '[^/\\"]*';
9932
+ var DOUBLE_STAR_REGEX = '[^\\"]*';
9933
+ var SINGLE_CHAR_REGEX = '[^/\\"]';
9934
+ var LEGACY_SINGLE_STAR_REGEX = '[^\\"]*';
9935
+ var LEGACY_DOUBLE_STAR_REGEX = ".*";
9936
+ var COMMAND_ARGS_ANCHOR = '"command":"';
9937
+ var VALUE_END_ANCHOR = '\\"';
9938
+ var RESERVED_OBJECT_KEYS = /* @__PURE__ */ new Set([
9939
+ "__proto__",
9940
+ "constructor",
9941
+ "prototype"
9942
+ ]);
9943
+ var moduleLogger = new ConsoleLogger();
9782
9944
  var GeminicliPermissions = class _GeminicliPermissions extends ToolPermissions {
9783
9945
  static getSettablePaths(_options = {}) {
9784
9946
  return {
9785
- relativeDirPath: ".gemini",
9786
- relativeFilePath: "settings.json"
9947
+ relativeDirPath: GEMINICLI_POLICY_RELATIVE_DIR_PATH,
9948
+ relativeFilePath: GEMINICLI_POLICY_FILE_NAME
9787
9949
  };
9788
9950
  }
9789
- isDeletable() {
9790
- return false;
9791
- }
9792
9951
  static async fromFile({
9793
9952
  baseDir = process.cwd(),
9794
9953
  validate = true,
@@ -9796,7 +9955,7 @@ var GeminicliPermissions = class _GeminicliPermissions extends ToolPermissions {
9796
9955
  }) {
9797
9956
  const paths = this.getSettablePaths({ global });
9798
9957
  const filePath = join64(baseDir, paths.relativeDirPath, paths.relativeFilePath);
9799
- const fileContent = await readFileContentOrNull(filePath) ?? JSON.stringify({}, null, 2);
9958
+ const fileContent = await readFileContentOrNull(filePath) ?? "";
9800
9959
  return new _GeminicliPermissions({
9801
9960
  baseDir,
9802
9961
  relativeDirPath: paths.relativeDirPath,
@@ -9805,63 +9964,72 @@ var GeminicliPermissions = class _GeminicliPermissions extends ToolPermissions {
9805
9964
  validate
9806
9965
  });
9807
9966
  }
9808
- static async fromRulesyncPermissions({
9967
+ static fromRulesyncPermissions({
9809
9968
  baseDir = process.cwd(),
9810
9969
  rulesyncPermissions,
9811
9970
  validate = true,
9812
- logger,
9813
- global = false
9971
+ global = false,
9972
+ logger = moduleLogger
9814
9973
  }) {
9815
9974
  const paths = this.getSettablePaths({ global });
9816
- const filePath = join64(baseDir, paths.relativeDirPath, paths.relativeFilePath);
9817
- const existingContent = await readFileContentOrNull(filePath) ?? JSON.stringify({}, null, 2);
9818
- const settingsResult = GeminiCliSettingsSchema.safeParse(JSON.parse(existingContent));
9819
- if (!settingsResult.success) {
9820
- throw new Error(
9821
- `Failed to parse existing Gemini CLI settings at ${filePath}: ${formatError(settingsResult.error)}`
9822
- );
9823
- }
9824
- const { allowed, exclude } = convertRulesyncToGeminicliTools({
9825
- config: rulesyncPermissions.getJson(),
9826
- logger
9827
- });
9828
- const merged = {
9829
- ...settingsResult.data,
9830
- tools: {
9831
- ...settingsResult.data.tools,
9832
- ...allowed.length > 0 ? { allowed } : {},
9833
- ...exclude.length > 0 ? { exclude } : {}
9834
- }
9835
- };
9975
+ const fileContent = buildGeminicliPolicyContent(rulesyncPermissions.getJson(), logger);
9836
9976
  return new _GeminicliPermissions({
9837
9977
  baseDir,
9838
9978
  relativeDirPath: paths.relativeDirPath,
9839
9979
  relativeFilePath: paths.relativeFilePath,
9840
- fileContent: JSON.stringify(merged, null, 2),
9980
+ fileContent,
9841
9981
  validate
9842
9982
  });
9843
9983
  }
9844
9984
  toRulesyncPermissions() {
9845
- let settings;
9846
- try {
9847
- const parsed = JSON.parse(this.getFileContent());
9848
- settings = GeminiCliSettingsSchema.parse(parsed);
9849
- } catch (error) {
9850
- throw new Error(
9851
- `Failed to parse Gemini CLI permissions content in ${join64(this.getRelativeDirPath(), this.getRelativeFilePath())}: ${formatError(error)}`,
9852
- { cause: error }
9853
- );
9854
- }
9855
9985
  const permission = {};
9856
- for (const toolEntry of settings.tools?.allowed ?? []) {
9857
- const mapped = parseGeminicliToolEntry({ entry: toolEntry });
9858
- const rules = permission[mapped.category] ??= {};
9859
- rules[mapped.pattern] = "allow";
9860
- }
9861
- for (const toolEntry of settings.tools?.exclude ?? []) {
9862
- const mapped = parseGeminicliToolEntry({ entry: toolEntry });
9863
- const rules = permission[mapped.category] ??= {};
9864
- rules[mapped.pattern] = "deny";
9986
+ const fileContent = this.getFileContent();
9987
+ if (fileContent.trim().length > 0) {
9988
+ let parsed;
9989
+ try {
9990
+ parsed = smolToml5.parse(fileContent);
9991
+ } catch (error) {
9992
+ throw new Error(
9993
+ `Failed to parse Gemini CLI policy TOML in ${join64(this.getRelativeDirPath(), this.getRelativeFilePath())}: ${formatError(error)}`,
9994
+ { cause: error }
9995
+ );
9996
+ }
9997
+ const rules = extractRules(parsed, moduleLogger);
9998
+ for (const [index, rule] of rules.entries()) {
9999
+ const mappedCategory = Object.hasOwn(GEMINICLI_TO_RULESYNC_TOOL_NAME, rule.toolName) ? GEMINICLI_TO_RULESYNC_TOOL_NAME[rule.toolName] : void 0;
10000
+ const category = mappedCategory ?? rule.toolName;
10001
+ if (RESERVED_OBJECT_KEYS.has(category)) {
10002
+ moduleLogger.warn(
10003
+ `Skipping rule #${index} in ${this.getRelativeFilePath()}: toolName "${rule.toolName}" maps to a reserved object key ("${category}") and would risk prototype pollution.`
10004
+ );
10005
+ continue;
10006
+ }
10007
+ const action = mapFromGeminicliDecision(rule.decision);
10008
+ if (!action) {
10009
+ moduleLogger.warn(
10010
+ `Skipping rule #${index} (toolName="${rule.toolName}", commandPrefix=${JSON.stringify(rule.commandPrefix)}, argsPattern=${JSON.stringify(rule.argsPattern)}) in ${this.getRelativeFilePath()}: unknown decision ${JSON.stringify(rule.decision)}`
10011
+ );
10012
+ continue;
10013
+ }
10014
+ if (rule.toolName === "run_shell_command" && rule.commandPrefix !== void 0 && rule.argsPattern !== void 0) {
10015
+ moduleLogger.warn(
10016
+ `Rule #${index} in ${this.getRelativeFilePath()} sets both commandPrefix and argsPattern; rulesync will honor argsPattern and ignore commandPrefix=${JSON.stringify(rule.commandPrefix)}.`
10017
+ );
10018
+ }
10019
+ const pattern = extractPattern(rule);
10020
+ if (RESERVED_OBJECT_KEYS.has(pattern)) {
10021
+ moduleLogger.warn(
10022
+ `Skipping rule #${index} in ${this.getRelativeFilePath()}: pattern "${pattern}" is a reserved object key.`
10023
+ );
10024
+ continue;
10025
+ }
10026
+ const existing = Object.hasOwn(permission, category) ? permission[category] : void 0;
10027
+ const target = existing ?? {};
10028
+ if (existing === void 0) {
10029
+ permission[category] = target;
10030
+ }
10031
+ target[pattern] = action;
10032
+ }
9865
10033
  }
9866
10034
  return this.toRulesyncPermissionsDefault({
9867
10035
  fileContent: JSON.stringify({ permission }, null, 2)
@@ -9879,60 +10047,248 @@ var GeminicliPermissions = class _GeminicliPermissions extends ToolPermissions {
9879
10047
  baseDir,
9880
10048
  relativeDirPath,
9881
10049
  relativeFilePath,
9882
- fileContent: JSON.stringify({}, null, 2),
10050
+ fileContent: "",
9883
10051
  validate: false
9884
10052
  });
9885
10053
  }
9886
10054
  };
9887
- function convertRulesyncToGeminicliTools({
9888
- config,
9889
- logger
9890
- }) {
9891
- const allowed = [];
9892
- const exclude = [];
9893
- for (const [toolName, rules] of Object.entries(config.permission)) {
10055
+ function buildGeminicliPolicyContent(config, logger) {
10056
+ const rules = [];
10057
+ let order = 0;
10058
+ for (const [toolName, entries] of Object.entries(config.permission)) {
9894
10059
  const mappedToolName = RULESYNC_TO_GEMINICLI_TOOL_NAME[toolName] ?? toolName;
9895
- if (!RULESYNC_TO_GEMINICLI_TOOL_NAME[toolName]) {
9896
- logger?.warn(`Gemini CLI permissions use direct tool names. Mapping as-is: ${toolName}`);
9897
- }
9898
- for (const [pattern, action] of Object.entries(rules)) {
9899
- if (action === "ask") {
9900
- logger?.warn(
9901
- `Gemini CLI does not support explicit "ask" rules in settings. Skipping ${toolName}:${pattern}`
10060
+ for (const [pattern, action] of Object.entries(entries)) {
10061
+ if (pattern === "") {
10062
+ logger.warn(
10063
+ `Skipping rule "${toolName}: "": empty pattern is not a valid permission target and would silently match every invocation (bash) or nothing (other tools).`
9902
10064
  );
9903
10065
  continue;
9904
10066
  }
9905
- const geminiEntry = pattern === "*" ? mappedToolName : `${mappedToolName}(${pattern})`;
9906
- if (action === "allow") {
9907
- allowed.push(geminiEntry);
9908
- } else {
9909
- exclude.push(geminiEntry);
10067
+ if (hasUnsafeAnchorChar(pattern)) {
10068
+ logger.warn(
10069
+ `Skipping rule "${toolName}: ${pattern}": pattern contains a character (" or \\) that would break JSON-anchor matching in the Gemini CLI Policy Engine.`
10070
+ );
10071
+ continue;
9910
10072
  }
10073
+ const decision = mapToGeminicliDecision(action);
10074
+ if (mappedToolName === "run_shell_command" && (pattern === "*" || pattern === "**") && decision !== "ask_user") {
10075
+ logger.warn(
10076
+ `Skipping rule "${toolName}: ${pattern}" with decision ${decision}: bash match-all patterns are only supported with "ask" because they would otherwise affect every shell command.`
10077
+ );
10078
+ continue;
10079
+ }
10080
+ const currentRule = {
10081
+ toolName: mappedToolName,
10082
+ decision,
10083
+ priority: priorityForDecision(decision)
10084
+ };
10085
+ if (mappedToolName === "run_shell_command") {
10086
+ applyShellPattern({ rule: currentRule, pattern, toolName, logger });
10087
+ } else if (pattern !== "*") {
10088
+ currentRule.argsPattern = buildNonShellArgsPattern(pattern);
10089
+ }
10090
+ rules.push({ rule: currentRule, order: order++ });
9911
10091
  }
9912
10092
  }
9913
- return { allowed, exclude };
10093
+ rules.sort((a, b) => {
10094
+ const diff = toNumber(b.rule.priority) - toNumber(a.rule.priority);
10095
+ return diff !== 0 ? diff : a.order - b.order;
10096
+ });
10097
+ return smolToml5.stringify({ rule: rules.map((entry) => entry.rule) });
9914
10098
  }
9915
- function parseGeminicliToolEntry({ entry }) {
9916
- const match = /^([^()]+?)(?:\((.*)\))?$/.exec(entry);
9917
- if (!match) return { category: entry, pattern: "*" };
9918
- const rawToolName = match[1]?.trim() ?? entry;
9919
- const mappedCategory = Object.entries(RULESYNC_TO_GEMINICLI_TOOL_NAME).find(
9920
- ([, value]) => value === rawToolName
9921
- )?.[0];
9922
- return {
9923
- category: mappedCategory ?? rawToolName,
9924
- pattern: (match[2] ?? "*").trim()
9925
- };
10099
+ function buildNonShellArgsPattern(pattern) {
10100
+ return `"${globPatternToRegex(pattern)}${VALUE_END_ANCHOR}`;
10101
+ }
10102
+ function hasUnsafeAnchorChar(pattern) {
10103
+ return pattern.includes('"') || pattern.includes("\\");
10104
+ }
10105
+ function toNumber(value) {
10106
+ return typeof value === "number" ? value : 0;
10107
+ }
10108
+ function applyShellPattern({
10109
+ rule,
10110
+ pattern,
10111
+ toolName,
10112
+ logger
10113
+ }) {
10114
+ if (pattern === "*") {
10115
+ return;
10116
+ }
10117
+ const trailingWildcardStripped = pattern.endsWith(" *") ? pattern.slice(0, -2) : pattern;
10118
+ if (hasGlobMetacharacter(trailingWildcardStripped)) {
10119
+ rule.argsPattern = `${COMMAND_ARGS_ANCHOR}${globPatternToRegex(pattern)}`;
10120
+ logger.warn(
10121
+ `Gemini CLI does not support glob metacharacters inside a bash command prefix; emitting argsPattern for rule "${toolName}: ${pattern}".`
10122
+ );
10123
+ return;
10124
+ }
10125
+ rule.commandPrefix = trailingWildcardStripped;
10126
+ }
10127
+ function hasGlobMetacharacter(pattern) {
10128
+ return /[*?[\]]/.test(pattern);
10129
+ }
10130
+ function priorityForDecision(decision) {
10131
+ if (decision === "deny") return PRIORITY_DENY;
10132
+ if (decision === "ask_user") return PRIORITY_ASK;
10133
+ return PRIORITY_ALLOW;
10134
+ }
10135
+ function mapToGeminicliDecision(action) {
10136
+ if (action === "ask") {
10137
+ return "ask_user";
10138
+ }
10139
+ return action;
10140
+ }
10141
+ function mapFromGeminicliDecision(decision) {
10142
+ if (decision === "allow") return "allow";
10143
+ if (decision === "deny") return "deny";
10144
+ if (decision === "ask_user") return "ask";
10145
+ return null;
10146
+ }
10147
+ function globPatternToRegex(pattern) {
10148
+ let regex = "";
10149
+ let i = 0;
10150
+ while (i < pattern.length) {
10151
+ const char = pattern[i];
10152
+ if (char === void 0) {
10153
+ break;
10154
+ }
10155
+ if (char === "*" && pattern[i + 1] === "*") {
10156
+ regex += DOUBLE_STAR_REGEX;
10157
+ i += 2;
10158
+ continue;
10159
+ }
10160
+ if (char === "*") {
10161
+ regex += SINGLE_STAR_REGEX;
10162
+ i += 1;
10163
+ continue;
10164
+ }
10165
+ if (char === "?") {
10166
+ regex += SINGLE_CHAR_REGEX;
10167
+ i += 1;
10168
+ continue;
10169
+ }
10170
+ if (char === "[") {
10171
+ regex += escapeRegexChar(char);
10172
+ i += 1;
10173
+ continue;
10174
+ }
10175
+ if (char === "]") {
10176
+ regex += escapeRegexChar(char);
10177
+ i += 1;
10178
+ continue;
10179
+ }
10180
+ if (isRegexMetacharacter(char)) {
10181
+ regex += `\\${char}`;
10182
+ i += 1;
10183
+ continue;
10184
+ }
10185
+ regex += char;
10186
+ i += 1;
10187
+ }
10188
+ return regex;
10189
+ }
10190
+ function escapeRegexChar(char) {
10191
+ return `\\${char}`;
10192
+ }
10193
+ function isRegexMetacharacter(char) {
10194
+ return /[.+^${}()|\\]/.test(char);
10195
+ }
10196
+ function regexToGlobPattern(regex) {
10197
+ let source = regex;
10198
+ if (source.endsWith(VALUE_END_ANCHOR)) {
10199
+ source = source.slice(0, -VALUE_END_ANCHOR.length);
10200
+ }
10201
+ let glob = "";
10202
+ let i = 0;
10203
+ while (i < source.length) {
10204
+ if (source.startsWith(DOUBLE_STAR_REGEX, i)) {
10205
+ glob += "**";
10206
+ i += DOUBLE_STAR_REGEX.length;
10207
+ continue;
10208
+ }
10209
+ if (source.startsWith(LEGACY_DOUBLE_STAR_REGEX, i)) {
10210
+ glob += "**";
10211
+ i += LEGACY_DOUBLE_STAR_REGEX.length;
10212
+ continue;
10213
+ }
10214
+ if (source.startsWith(SINGLE_STAR_REGEX, i)) {
10215
+ glob += "*";
10216
+ i += SINGLE_STAR_REGEX.length;
10217
+ continue;
10218
+ }
10219
+ if (source.startsWith(LEGACY_SINGLE_STAR_REGEX, i)) {
10220
+ glob += "*";
10221
+ i += LEGACY_SINGLE_STAR_REGEX.length;
10222
+ continue;
10223
+ }
10224
+ if (source.startsWith(SINGLE_CHAR_REGEX, i)) {
10225
+ glob += "?";
10226
+ i += SINGLE_CHAR_REGEX.length;
10227
+ continue;
10228
+ }
10229
+ const char = source[i];
10230
+ if (char === "\\") {
10231
+ const escaped = source[i + 1];
10232
+ if (escaped !== void 0) {
10233
+ glob += escaped;
10234
+ i += 2;
10235
+ continue;
10236
+ }
10237
+ }
10238
+ glob += char ?? "";
10239
+ i += 1;
10240
+ }
10241
+ return glob;
10242
+ }
10243
+ var GeminicliPolicyRuleSchema = z28.looseObject({
10244
+ toolName: z28.string(),
10245
+ decision: z28.optional(z28.unknown()),
10246
+ commandPrefix: z28.optional(z28.string()),
10247
+ argsPattern: z28.optional(z28.string())
10248
+ });
10249
+ var GeminicliPolicyFileSchema = z28.looseObject({
10250
+ rule: z28.optional(z28.array(z28.looseObject({})))
10251
+ });
10252
+ function extractRules(parsed, logger) {
10253
+ const parsedFile = GeminicliPolicyFileSchema.safeParse(parsed);
10254
+ if (!parsedFile.success || !parsedFile.data.rule) {
10255
+ return [];
10256
+ }
10257
+ const rules = [];
10258
+ for (const [index, entry] of parsedFile.data.rule.entries()) {
10259
+ const result = GeminicliPolicyRuleSchema.safeParse(entry);
10260
+ if (result.success) {
10261
+ rules.push(result.data);
10262
+ continue;
10263
+ }
10264
+ logger.warn(
10265
+ `Skipping malformed Gemini CLI policy rule at index ${index}: ${formatError(result.error)}`
10266
+ );
10267
+ }
10268
+ return rules;
10269
+ }
10270
+ function extractPattern(rule) {
10271
+ if (rule.toolName === "run_shell_command") {
10272
+ if (rule.argsPattern) {
10273
+ const stripped = rule.argsPattern.startsWith(COMMAND_ARGS_ANCHOR) ? rule.argsPattern.slice(COMMAND_ARGS_ANCHOR.length) : rule.argsPattern;
10274
+ return regexToGlobPattern(stripped);
10275
+ }
10276
+ if (!rule.commandPrefix) return "*";
10277
+ return rule.commandPrefix.endsWith(" *") || rule.commandPrefix.endsWith("*") ? rule.commandPrefix : `${rule.commandPrefix} *`;
10278
+ }
10279
+ if (!rule.argsPattern) return "*";
10280
+ const regex = rule.argsPattern.startsWith('"') ? rule.argsPattern.slice(1) : rule.argsPattern;
10281
+ return regexToGlobPattern(regex);
9926
10282
  }
9927
10283
 
9928
10284
  // src/features/permissions/kiro-permissions.ts
9929
10285
  import { join as join65 } from "path";
9930
- import { z as z30 } from "zod/mini";
9931
- var KiroAgentSchema = z30.looseObject({
9932
- allowedTools: z30.optional(z30.array(z30.string())),
9933
- toolsSettings: z30.optional(z30.record(z30.string(), z30.unknown()))
10286
+ import { z as z29 } from "zod/mini";
10287
+ var KiroAgentSchema = z29.looseObject({
10288
+ allowedTools: z29.optional(z29.array(z29.string())),
10289
+ toolsSettings: z29.optional(z29.record(z29.string(), z29.unknown()))
9934
10290
  });
9935
- var UnknownRecordSchema = z30.record(z30.string(), z30.unknown());
10291
+ var UnknownRecordSchema = z29.record(z29.string(), z29.unknown());
9936
10292
  var KiroPermissions = class _KiroPermissions extends ToolPermissions {
9937
10293
  static getSettablePaths(_options = {}) {
9938
10294
  return {
@@ -10085,8 +10441,12 @@ function buildKiroPermissionsFromRulesync({
10085
10441
  );
10086
10442
  continue;
10087
10443
  }
10088
- if (action === "allow")
10089
- nextAllowedTools.add(category === "webfetch" ? "web_fetch" : "web_search");
10444
+ const toolName = category === "webfetch" ? "web_fetch" : "web_search";
10445
+ if (action === "allow") {
10446
+ nextAllowedTools.add(toolName);
10447
+ } else {
10448
+ nextAllowedTools.delete(toolName);
10449
+ }
10090
10450
  } else {
10091
10451
  logger?.warn(`Kiro permissions do not support category: ${category}. Skipping.`);
10092
10452
  }
@@ -10112,13 +10472,13 @@ function asStringArray(value) {
10112
10472
  // src/features/permissions/opencode-permissions.ts
10113
10473
  import { join as join66 } from "path";
10114
10474
  import { parse as parseJsonc5 } from "jsonc-parser";
10115
- import { z as z31 } from "zod/mini";
10116
- var OpencodePermissionSchema = z31.union([
10117
- z31.enum(["allow", "ask", "deny"]),
10118
- z31.record(z31.string(), z31.enum(["allow", "ask", "deny"]))
10475
+ import { z as z30 } from "zod/mini";
10476
+ var OpencodePermissionSchema = z30.union([
10477
+ z30.enum(["allow", "ask", "deny"]),
10478
+ z30.record(z30.string(), z30.enum(["allow", "ask", "deny"]))
10119
10479
  ]);
10120
- var OpencodePermissionsConfigSchema = z31.looseObject({
10121
- permission: z31.optional(z31.record(z31.string(), OpencodePermissionSchema))
10480
+ var OpencodePermissionsConfigSchema = z30.looseObject({
10481
+ permission: z30.optional(z30.record(z30.string(), OpencodePermissionSchema))
10122
10482
  });
10123
10483
  var OpencodePermissions = class _OpencodePermissions extends ToolPermissions {
10124
10484
  json;
@@ -10249,7 +10609,7 @@ var permissionsProcessorToolTargetTuple = [
10249
10609
  "kiro",
10250
10610
  "opencode"
10251
10611
  ];
10252
- var PermissionsProcessorToolTargetSchema = z32.enum(permissionsProcessorToolTargetTuple);
10612
+ var PermissionsProcessorToolTargetSchema = z31.enum(permissionsProcessorToolTargetTuple);
10253
10613
  var toolPermissionsFactories = /* @__PURE__ */ new Map([
10254
10614
  [
10255
10615
  "claudecode",
@@ -10414,7 +10774,7 @@ var PermissionsProcessor = class extends FeatureProcessor {
10414
10774
  // src/features/rules/rules-processor.ts
10415
10775
  import { basename as basename10, dirname as dirname3, join as join137, relative as relative5 } from "path";
10416
10776
  import { encode } from "@toon-format/toon";
10417
- import { z as z72 } from "zod/mini";
10777
+ import { z as z71 } from "zod/mini";
10418
10778
 
10419
10779
  // src/constants/general.ts
10420
10780
  var SKILL_FILE_NAME = "SKILL.md";
@@ -10424,7 +10784,7 @@ import { join as join70 } from "path";
10424
10784
 
10425
10785
  // src/features/skills/simulated-skill.ts
10426
10786
  import { join as join69 } from "path";
10427
- import { z as z33 } from "zod/mini";
10787
+ import { z as z32 } from "zod/mini";
10428
10788
 
10429
10789
  // src/features/skills/tool-skill.ts
10430
10790
  import { join as join68 } from "path";
@@ -10661,9 +11021,9 @@ var ToolSkill = class extends AiDir {
10661
11021
  };
10662
11022
 
10663
11023
  // src/features/skills/simulated-skill.ts
10664
- var SimulatedSkillFrontmatterSchema = z33.looseObject({
10665
- name: z33.string(),
10666
- description: z33.string()
11024
+ var SimulatedSkillFrontmatterSchema = z32.looseObject({
11025
+ name: z32.string(),
11026
+ description: z32.string()
10667
11027
  });
10668
11028
  var SimulatedSkill = class extends ToolSkill {
10669
11029
  frontmatter;
@@ -10890,49 +11250,49 @@ var FactorydroidSkill = class _FactorydroidSkill extends SimulatedSkill {
10890
11250
 
10891
11251
  // src/features/skills/rovodev-skill.ts
10892
11252
  import { join as join73 } from "path";
10893
- import { z as z35 } from "zod/mini";
11253
+ import { z as z34 } from "zod/mini";
10894
11254
 
10895
11255
  // src/features/skills/rulesync-skill.ts
10896
11256
  import { join as join72 } from "path";
10897
- import { z as z34 } from "zod/mini";
10898
- var RulesyncSkillFrontmatterSchemaInternal = z34.looseObject({
10899
- name: z34.string(),
10900
- description: z34.string(),
10901
- targets: z34._default(RulesyncTargetsSchema, ["*"]),
10902
- claudecode: z34.optional(
10903
- z34.looseObject({
10904
- "allowed-tools": z34.optional(z34.array(z34.string())),
10905
- model: z34.optional(z34.string()),
10906
- "disable-model-invocation": z34.optional(z34.boolean())
11257
+ import { z as z33 } from "zod/mini";
11258
+ var RulesyncSkillFrontmatterSchemaInternal = z33.looseObject({
11259
+ name: z33.string(),
11260
+ description: z33.string(),
11261
+ targets: z33._default(RulesyncTargetsSchema, ["*"]),
11262
+ claudecode: z33.optional(
11263
+ z33.looseObject({
11264
+ "allowed-tools": z33.optional(z33.array(z33.string())),
11265
+ model: z33.optional(z33.string()),
11266
+ "disable-model-invocation": z33.optional(z33.boolean())
10907
11267
  })
10908
11268
  ),
10909
- codexcli: z34.optional(
10910
- z34.looseObject({
10911
- "short-description": z34.optional(z34.string())
11269
+ codexcli: z33.optional(
11270
+ z33.looseObject({
11271
+ "short-description": z33.optional(z33.string())
10912
11272
  })
10913
11273
  ),
10914
- opencode: z34.optional(
10915
- z34.looseObject({
10916
- "allowed-tools": z34.optional(z34.array(z34.string()))
11274
+ opencode: z33.optional(
11275
+ z33.looseObject({
11276
+ "allowed-tools": z33.optional(z33.array(z33.string()))
10917
11277
  })
10918
11278
  ),
10919
- kilo: z34.optional(
10920
- z34.looseObject({
10921
- "allowed-tools": z34.optional(z34.array(z34.string()))
11279
+ kilo: z33.optional(
11280
+ z33.looseObject({
11281
+ "allowed-tools": z33.optional(z33.array(z33.string()))
10922
11282
  })
10923
11283
  ),
10924
- deepagents: z34.optional(
10925
- z34.looseObject({
10926
- "allowed-tools": z34.optional(z34.array(z34.string()))
11284
+ deepagents: z33.optional(
11285
+ z33.looseObject({
11286
+ "allowed-tools": z33.optional(z33.array(z33.string()))
10927
11287
  })
10928
11288
  ),
10929
- copilot: z34.optional(
10930
- z34.looseObject({
10931
- license: z34.optional(z34.string())
11289
+ copilot: z33.optional(
11290
+ z33.looseObject({
11291
+ license: z33.optional(z33.string())
10932
11292
  })
10933
11293
  ),
10934
- cline: z34.optional(z34.looseObject({})),
10935
- roo: z34.optional(z34.looseObject({}))
11294
+ cline: z33.optional(z33.looseObject({})),
11295
+ roo: z33.optional(z33.looseObject({}))
10936
11296
  });
10937
11297
  var RulesyncSkillFrontmatterSchema = RulesyncSkillFrontmatterSchemaInternal;
10938
11298
  var RulesyncSkill = class _RulesyncSkill extends AiDir {
@@ -11029,9 +11389,9 @@ var RulesyncSkill = class _RulesyncSkill extends AiDir {
11029
11389
  };
11030
11390
 
11031
11391
  // src/features/skills/rovodev-skill.ts
11032
- var RovodevSkillFrontmatterSchema = z35.looseObject({
11033
- name: z35.string(),
11034
- description: z35.string()
11392
+ var RovodevSkillFrontmatterSchema = z34.looseObject({
11393
+ name: z34.string(),
11394
+ description: z34.string()
11035
11395
  });
11036
11396
  var RovodevSkill = class _RovodevSkill extends ToolSkill {
11037
11397
  constructor({
@@ -11203,7 +11563,7 @@ var RovodevSkill = class _RovodevSkill extends ToolSkill {
11203
11563
 
11204
11564
  // src/features/skills/skills-processor.ts
11205
11565
  import { basename as basename5, join as join92 } from "path";
11206
- import { z as z52 } from "zod/mini";
11566
+ import { z as z51 } from "zod/mini";
11207
11567
 
11208
11568
  // src/types/dir-feature-processor.ts
11209
11569
  import { join as join74 } from "path";
@@ -11342,10 +11702,10 @@ var DirFeatureProcessor = class {
11342
11702
 
11343
11703
  // src/features/skills/agentsskills-skill.ts
11344
11704
  import { join as join75 } from "path";
11345
- import { z as z36 } from "zod/mini";
11346
- var AgentsSkillsSkillFrontmatterSchema = z36.looseObject({
11347
- name: z36.string(),
11348
- description: z36.string()
11705
+ import { z as z35 } from "zod/mini";
11706
+ var AgentsSkillsSkillFrontmatterSchema = z35.looseObject({
11707
+ name: z35.string(),
11708
+ description: z35.string()
11349
11709
  });
11350
11710
  var AgentsSkillsSkill = class _AgentsSkillsSkill extends ToolSkill {
11351
11711
  constructor({
@@ -11500,10 +11860,10 @@ var AgentsSkillsSkill = class _AgentsSkillsSkill extends ToolSkill {
11500
11860
 
11501
11861
  // src/features/skills/antigravity-skill.ts
11502
11862
  import { join as join76 } from "path";
11503
- import { z as z37 } from "zod/mini";
11504
- var AntigravitySkillFrontmatterSchema = z37.looseObject({
11505
- name: z37.string(),
11506
- description: z37.string()
11863
+ import { z as z36 } from "zod/mini";
11864
+ var AntigravitySkillFrontmatterSchema = z36.looseObject({
11865
+ name: z36.string(),
11866
+ description: z36.string()
11507
11867
  });
11508
11868
  var AntigravitySkill = class _AntigravitySkill extends ToolSkill {
11509
11869
  constructor({
@@ -11661,13 +12021,13 @@ var AntigravitySkill = class _AntigravitySkill extends ToolSkill {
11661
12021
 
11662
12022
  // src/features/skills/claudecode-skill.ts
11663
12023
  import { join as join77 } from "path";
11664
- import { z as z38 } from "zod/mini";
11665
- var ClaudecodeSkillFrontmatterSchema = z38.looseObject({
11666
- name: z38.string(),
11667
- description: z38.string(),
11668
- "allowed-tools": z38.optional(z38.array(z38.string())),
11669
- model: z38.optional(z38.string()),
11670
- "disable-model-invocation": z38.optional(z38.boolean())
12024
+ import { z as z37 } from "zod/mini";
12025
+ var ClaudecodeSkillFrontmatterSchema = z37.looseObject({
12026
+ name: z37.string(),
12027
+ description: z37.string(),
12028
+ "allowed-tools": z37.optional(z37.array(z37.string())),
12029
+ model: z37.optional(z37.string()),
12030
+ "disable-model-invocation": z37.optional(z37.boolean())
11671
12031
  });
11672
12032
  var ClaudecodeSkill = class _ClaudecodeSkill extends ToolSkill {
11673
12033
  constructor({
@@ -11837,10 +12197,10 @@ var ClaudecodeSkill = class _ClaudecodeSkill extends ToolSkill {
11837
12197
 
11838
12198
  // src/features/skills/cline-skill.ts
11839
12199
  import { join as join78 } from "path";
11840
- import { z as z39 } from "zod/mini";
11841
- var ClineSkillFrontmatterSchema = z39.looseObject({
11842
- name: z39.string(),
11843
- description: z39.string()
12200
+ import { z as z38 } from "zod/mini";
12201
+ var ClineSkillFrontmatterSchema = z38.looseObject({
12202
+ name: z38.string(),
12203
+ description: z38.string()
11844
12204
  });
11845
12205
  var ClineSkill = class _ClineSkill extends ToolSkill {
11846
12206
  constructor({
@@ -12010,13 +12370,13 @@ var ClineSkill = class _ClineSkill extends ToolSkill {
12010
12370
 
12011
12371
  // src/features/skills/codexcli-skill.ts
12012
12372
  import { join as join79 } from "path";
12013
- import { z as z40 } from "zod/mini";
12014
- var CodexCliSkillFrontmatterSchema = z40.looseObject({
12015
- name: z40.string(),
12016
- description: z40.string(),
12017
- metadata: z40.optional(
12018
- z40.looseObject({
12019
- "short-description": z40.optional(z40.string())
12373
+ import { z as z39 } from "zod/mini";
12374
+ var CodexCliSkillFrontmatterSchema = z39.looseObject({
12375
+ name: z39.string(),
12376
+ description: z39.string(),
12377
+ metadata: z39.optional(
12378
+ z39.looseObject({
12379
+ "short-description": z39.optional(z39.string())
12020
12380
  })
12021
12381
  )
12022
12382
  });
@@ -12181,11 +12541,11 @@ var CodexCliSkill = class _CodexCliSkill extends ToolSkill {
12181
12541
 
12182
12542
  // src/features/skills/copilot-skill.ts
12183
12543
  import { join as join80 } from "path";
12184
- import { z as z41 } from "zod/mini";
12185
- var CopilotSkillFrontmatterSchema = z41.looseObject({
12186
- name: z41.string(),
12187
- description: z41.string(),
12188
- license: z41.optional(z41.string())
12544
+ import { z as z40 } from "zod/mini";
12545
+ var CopilotSkillFrontmatterSchema = z40.looseObject({
12546
+ name: z40.string(),
12547
+ description: z40.string(),
12548
+ license: z40.optional(z40.string())
12189
12549
  });
12190
12550
  var CopilotSkill = class _CopilotSkill extends ToolSkill {
12191
12551
  constructor({
@@ -12346,10 +12706,10 @@ var CopilotSkill = class _CopilotSkill extends ToolSkill {
12346
12706
 
12347
12707
  // src/features/skills/cursor-skill.ts
12348
12708
  import { join as join81 } from "path";
12349
- import { z as z42 } from "zod/mini";
12350
- var CursorSkillFrontmatterSchema = z42.looseObject({
12351
- name: z42.string(),
12352
- description: z42.string()
12709
+ import { z as z41 } from "zod/mini";
12710
+ var CursorSkillFrontmatterSchema = z41.looseObject({
12711
+ name: z41.string(),
12712
+ description: z41.string()
12353
12713
  });
12354
12714
  var CursorSkill = class _CursorSkill extends ToolSkill {
12355
12715
  constructor({
@@ -12501,11 +12861,11 @@ var CursorSkill = class _CursorSkill extends ToolSkill {
12501
12861
 
12502
12862
  // src/features/skills/deepagents-skill.ts
12503
12863
  import { join as join82 } from "path";
12504
- import { z as z43 } from "zod/mini";
12505
- var DeepagentsSkillFrontmatterSchema = z43.looseObject({
12506
- name: z43.string(),
12507
- description: z43.string(),
12508
- "allowed-tools": z43.optional(z43.array(z43.string()))
12864
+ import { z as z42 } from "zod/mini";
12865
+ var DeepagentsSkillFrontmatterSchema = z42.looseObject({
12866
+ name: z42.string(),
12867
+ description: z42.string(),
12868
+ "allowed-tools": z42.optional(z42.array(z42.string()))
12509
12869
  });
12510
12870
  var DeepagentsSkill = class _DeepagentsSkill extends ToolSkill {
12511
12871
  constructor({
@@ -12663,10 +13023,10 @@ var DeepagentsSkill = class _DeepagentsSkill extends ToolSkill {
12663
13023
 
12664
13024
  // src/features/skills/geminicli-skill.ts
12665
13025
  import { join as join83 } from "path";
12666
- import { z as z44 } from "zod/mini";
12667
- var GeminiCliSkillFrontmatterSchema = z44.looseObject({
12668
- name: z44.string(),
12669
- description: z44.string()
13026
+ import { z as z43 } from "zod/mini";
13027
+ var GeminiCliSkillFrontmatterSchema = z43.looseObject({
13028
+ name: z43.string(),
13029
+ description: z43.string()
12670
13030
  });
12671
13031
  var GeminiCliSkill = class _GeminiCliSkill extends ToolSkill {
12672
13032
  constructor({
@@ -12820,10 +13180,10 @@ var GeminiCliSkill = class _GeminiCliSkill extends ToolSkill {
12820
13180
 
12821
13181
  // src/features/skills/junie-skill.ts
12822
13182
  import { join as join84 } from "path";
12823
- import { z as z45 } from "zod/mini";
12824
- var JunieSkillFrontmatterSchema = z45.looseObject({
12825
- name: z45.string(),
12826
- description: z45.string()
13183
+ import { z as z44 } from "zod/mini";
13184
+ var JunieSkillFrontmatterSchema = z44.looseObject({
13185
+ name: z44.string(),
13186
+ description: z44.string()
12827
13187
  });
12828
13188
  var JunieSkill = class _JunieSkill extends ToolSkill {
12829
13189
  constructor({
@@ -12996,11 +13356,11 @@ var JunieSkill = class _JunieSkill extends ToolSkill {
12996
13356
 
12997
13357
  // src/features/skills/kilo-skill.ts
12998
13358
  import { join as join85 } from "path";
12999
- import { z as z46 } from "zod/mini";
13000
- var KiloSkillFrontmatterSchema = z46.looseObject({
13001
- name: z46.string(),
13002
- description: z46.string(),
13003
- "allowed-tools": z46.optional(z46.array(z46.string()))
13359
+ import { z as z45 } from "zod/mini";
13360
+ var KiloSkillFrontmatterSchema = z45.looseObject({
13361
+ name: z45.string(),
13362
+ description: z45.string(),
13363
+ "allowed-tools": z45.optional(z45.array(z45.string()))
13004
13364
  });
13005
13365
  var KiloSkill = class _KiloSkill extends ToolSkill {
13006
13366
  constructor({
@@ -13157,10 +13517,10 @@ var KiloSkill = class _KiloSkill extends ToolSkill {
13157
13517
 
13158
13518
  // src/features/skills/kiro-skill.ts
13159
13519
  import { join as join86 } from "path";
13160
- import { z as z47 } from "zod/mini";
13161
- var KiroSkillFrontmatterSchema = z47.looseObject({
13162
- name: z47.string(),
13163
- description: z47.string()
13520
+ import { z as z46 } from "zod/mini";
13521
+ var KiroSkillFrontmatterSchema = z46.looseObject({
13522
+ name: z46.string(),
13523
+ description: z46.string()
13164
13524
  });
13165
13525
  var KiroSkill = class _KiroSkill extends ToolSkill {
13166
13526
  constructor({
@@ -13334,11 +13694,11 @@ var KiroSkill = class _KiroSkill extends ToolSkill {
13334
13694
 
13335
13695
  // src/features/skills/opencode-skill.ts
13336
13696
  import { join as join87 } from "path";
13337
- import { z as z48 } from "zod/mini";
13338
- var OpenCodeSkillFrontmatterSchema = z48.looseObject({
13339
- name: z48.string(),
13340
- description: z48.string(),
13341
- "allowed-tools": z48.optional(z48.array(z48.string()))
13697
+ import { z as z47 } from "zod/mini";
13698
+ var OpenCodeSkillFrontmatterSchema = z47.looseObject({
13699
+ name: z47.string(),
13700
+ description: z47.string(),
13701
+ "allowed-tools": z47.optional(z47.array(z47.string()))
13342
13702
  });
13343
13703
  var OpenCodeSkill = class _OpenCodeSkill extends ToolSkill {
13344
13704
  constructor({
@@ -13495,10 +13855,10 @@ var OpenCodeSkill = class _OpenCodeSkill extends ToolSkill {
13495
13855
 
13496
13856
  // src/features/skills/replit-skill.ts
13497
13857
  import { join as join88 } from "path";
13498
- import { z as z49 } from "zod/mini";
13499
- var ReplitSkillFrontmatterSchema = z49.looseObject({
13500
- name: z49.string(),
13501
- description: z49.string()
13858
+ import { z as z48 } from "zod/mini";
13859
+ var ReplitSkillFrontmatterSchema = z48.looseObject({
13860
+ name: z48.string(),
13861
+ description: z48.string()
13502
13862
  });
13503
13863
  var ReplitSkill = class _ReplitSkill extends ToolSkill {
13504
13864
  constructor({
@@ -13653,10 +14013,10 @@ var ReplitSkill = class _ReplitSkill extends ToolSkill {
13653
14013
 
13654
14014
  // src/features/skills/roo-skill.ts
13655
14015
  import { join as join89 } from "path";
13656
- import { z as z50 } from "zod/mini";
13657
- var RooSkillFrontmatterSchema = z50.looseObject({
13658
- name: z50.string(),
13659
- description: z50.string()
14016
+ import { z as z49 } from "zod/mini";
14017
+ var RooSkillFrontmatterSchema = z49.looseObject({
14018
+ name: z49.string(),
14019
+ description: z49.string()
13660
14020
  });
13661
14021
  var RooSkill = class _RooSkill extends ToolSkill {
13662
14022
  constructor({
@@ -13845,10 +14205,10 @@ async function getLocalSkillDirNames(baseDir) {
13845
14205
 
13846
14206
  // src/features/skills/windsurf-skill.ts
13847
14207
  import { join as join91 } from "path";
13848
- import { z as z51 } from "zod/mini";
13849
- var WindsurfSkillFrontmatterSchema = z51.looseObject({
13850
- name: z51.string(),
13851
- description: z51.string()
14208
+ import { z as z50 } from "zod/mini";
14209
+ var WindsurfSkillFrontmatterSchema = z50.looseObject({
14210
+ name: z50.string(),
14211
+ description: z50.string()
13852
14212
  });
13853
14213
  var WindsurfSkill = class _WindsurfSkill extends ToolSkill {
13854
14214
  constructor({
@@ -14026,7 +14386,7 @@ var skillsProcessorToolTargetTuple = [
14026
14386
  "rovodev",
14027
14387
  "windsurf"
14028
14388
  ];
14029
- var SkillsProcessorToolTargetSchema = z52.enum(skillsProcessorToolTargetTuple);
14389
+ var SkillsProcessorToolTargetSchema = z51.enum(skillsProcessorToolTargetTuple);
14030
14390
  var toolSkillFactories = /* @__PURE__ */ new Map([
14031
14391
  [
14032
14392
  "agentsmd",
@@ -14405,7 +14765,7 @@ import { join as join94 } from "path";
14405
14765
 
14406
14766
  // src/features/subagents/simulated-subagent.ts
14407
14767
  import { basename as basename6, join as join93 } from "path";
14408
- import { z as z53 } from "zod/mini";
14768
+ import { z as z52 } from "zod/mini";
14409
14769
 
14410
14770
  // src/features/subagents/tool-subagent.ts
14411
14771
  var ToolSubagent = class extends ToolFile {
@@ -14457,9 +14817,9 @@ var ToolSubagent = class extends ToolFile {
14457
14817
  };
14458
14818
 
14459
14819
  // src/features/subagents/simulated-subagent.ts
14460
- var SimulatedSubagentFrontmatterSchema = z53.object({
14461
- name: z53.string(),
14462
- description: z53.optional(z53.string())
14820
+ var SimulatedSubagentFrontmatterSchema = z52.object({
14821
+ name: z52.string(),
14822
+ description: z52.optional(z52.string())
14463
14823
  });
14464
14824
  var SimulatedSubagent = class extends ToolSubagent {
14465
14825
  frontmatter;
@@ -14617,15 +14977,15 @@ var FactorydroidSubagent = class _FactorydroidSubagent extends SimulatedSubagent
14617
14977
 
14618
14978
  // src/features/subagents/geminicli-subagent.ts
14619
14979
  import { join as join97 } from "path";
14620
- import { z as z55 } from "zod/mini";
14980
+ import { z as z54 } from "zod/mini";
14621
14981
 
14622
14982
  // src/features/subagents/rulesync-subagent.ts
14623
14983
  import { basename as basename7, join as join96 } from "path";
14624
- import { z as z54 } from "zod/mini";
14625
- var RulesyncSubagentFrontmatterSchema = z54.looseObject({
14626
- targets: z54._default(RulesyncTargetsSchema, ["*"]),
14627
- name: z54.string(),
14628
- description: z54.optional(z54.string())
14984
+ import { z as z53 } from "zod/mini";
14985
+ var RulesyncSubagentFrontmatterSchema = z53.looseObject({
14986
+ targets: z53._default(RulesyncTargetsSchema, ["*"]),
14987
+ name: z53.string(),
14988
+ description: z53.optional(z53.string())
14629
14989
  });
14630
14990
  var RulesyncSubagent = class _RulesyncSubagent extends RulesyncFile {
14631
14991
  frontmatter;
@@ -14694,9 +15054,9 @@ var RulesyncSubagent = class _RulesyncSubagent extends RulesyncFile {
14694
15054
  };
14695
15055
 
14696
15056
  // src/features/subagents/geminicli-subagent.ts
14697
- var GeminiCliSubagentFrontmatterSchema = z55.looseObject({
14698
- name: z55.string(),
14699
- description: z55.optional(z55.string())
15057
+ var GeminiCliSubagentFrontmatterSchema = z54.looseObject({
15058
+ name: z54.string(),
15059
+ description: z54.optional(z54.string())
14700
15060
  });
14701
15061
  var GeminiCliSubagent = class _GeminiCliSubagent extends ToolSubagent {
14702
15062
  frontmatter;
@@ -14869,10 +15229,10 @@ var RooSubagent = class _RooSubagent extends SimulatedSubagent {
14869
15229
 
14870
15230
  // src/features/subagents/rovodev-subagent.ts
14871
15231
  import { join as join99 } from "path";
14872
- import { z as z56 } from "zod/mini";
14873
- var RovodevSubagentFrontmatterSchema = z56.looseObject({
14874
- name: z56.string(),
14875
- description: z56.optional(z56.string())
15232
+ import { z as z55 } from "zod/mini";
15233
+ var RovodevSubagentFrontmatterSchema = z55.looseObject({
15234
+ name: z55.string(),
15235
+ description: z55.optional(z55.string())
14876
15236
  });
14877
15237
  var RovodevSubagent = class _RovodevSubagent extends ToolSubagent {
14878
15238
  frontmatter;
@@ -15014,18 +15374,18 @@ var RovodevSubagent = class _RovodevSubagent extends ToolSubagent {
15014
15374
 
15015
15375
  // src/features/subagents/subagents-processor.ts
15016
15376
  import { basename as basename9, join as join110 } from "path";
15017
- import { z as z65 } from "zod/mini";
15377
+ import { z as z64 } from "zod/mini";
15018
15378
 
15019
15379
  // src/features/subagents/claudecode-subagent.ts
15020
15380
  import { join as join100 } from "path";
15021
- import { z as z57 } from "zod/mini";
15022
- var ClaudecodeSubagentFrontmatterSchema = z57.looseObject({
15023
- name: z57.string(),
15024
- description: z57.optional(z57.string()),
15025
- model: z57.optional(z57.string()),
15026
- tools: z57.optional(z57.union([z57.string(), z57.array(z57.string())])),
15027
- permissionMode: z57.optional(z57.string()),
15028
- skills: z57.optional(z57.union([z57.string(), z57.array(z57.string())]))
15381
+ import { z as z56 } from "zod/mini";
15382
+ var ClaudecodeSubagentFrontmatterSchema = z56.looseObject({
15383
+ name: z56.string(),
15384
+ description: z56.optional(z56.string()),
15385
+ model: z56.optional(z56.string()),
15386
+ tools: z56.optional(z56.union([z56.string(), z56.array(z56.string())])),
15387
+ permissionMode: z56.optional(z56.string()),
15388
+ skills: z56.optional(z56.union([z56.string(), z56.array(z56.string())]))
15029
15389
  });
15030
15390
  var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
15031
15391
  frontmatter;
@@ -15180,25 +15540,25 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
15180
15540
 
15181
15541
  // src/features/subagents/codexcli-subagent.ts
15182
15542
  import { join as join101 } from "path";
15183
- import * as smolToml5 from "smol-toml";
15184
- import { z as z58 } from "zod/mini";
15185
- var CodexCliSubagentTomlSchema = z58.looseObject({
15186
- name: z58.string(),
15187
- description: z58.optional(z58.string()),
15188
- developer_instructions: z58.optional(z58.string()),
15189
- model: z58.optional(z58.string()),
15190
- model_reasoning_effort: z58.optional(z58.string()),
15191
- sandbox_mode: z58.optional(z58.string())
15543
+ import * as smolToml6 from "smol-toml";
15544
+ import { z as z57 } from "zod/mini";
15545
+ var CodexCliSubagentTomlSchema = z57.looseObject({
15546
+ name: z57.string(),
15547
+ description: z57.optional(z57.string()),
15548
+ developer_instructions: z57.optional(z57.string()),
15549
+ model: z57.optional(z57.string()),
15550
+ model_reasoning_effort: z57.optional(z57.string()),
15551
+ sandbox_mode: z57.optional(z57.string())
15192
15552
  });
15193
15553
  function stringifyCodexCliSubagentToml(tomlObj) {
15194
15554
  const { developer_instructions, ...restFields } = tomlObj;
15195
- const restToml = smolToml5.stringify(restFields).trimEnd();
15555
+ const restToml = smolToml6.stringify(restFields).trimEnd();
15196
15556
  if (developer_instructions === void 0) {
15197
15557
  return restToml;
15198
15558
  }
15199
- const developerInstructionsToml = developer_instructions.includes("\n") ? developer_instructions.includes("'''") ? smolToml5.stringify({ developer_instructions }).trimEnd() : `developer_instructions = '''
15559
+ const developerInstructionsToml = developer_instructions.includes("\n") ? developer_instructions.includes("'''") ? smolToml6.stringify({ developer_instructions }).trimEnd() : `developer_instructions = '''
15200
15560
  ${developer_instructions}
15201
- '''` : smolToml5.stringify({ developer_instructions }).trimEnd();
15561
+ '''` : smolToml6.stringify({ developer_instructions }).trimEnd();
15202
15562
  return [restToml, developerInstructionsToml].filter((value) => value.length > 0).join("\n");
15203
15563
  }
15204
15564
  var CodexCliSubagent = class _CodexCliSubagent extends ToolSubagent {
@@ -15206,7 +15566,7 @@ var CodexCliSubagent = class _CodexCliSubagent extends ToolSubagent {
15206
15566
  constructor({ body, ...rest }) {
15207
15567
  if (rest.validate !== false) {
15208
15568
  try {
15209
- const parsed = smolToml5.parse(body);
15569
+ const parsed = smolToml6.parse(body);
15210
15570
  CodexCliSubagentTomlSchema.parse(parsed);
15211
15571
  } catch (error) {
15212
15572
  throw new Error(
@@ -15231,7 +15591,7 @@ var CodexCliSubagent = class _CodexCliSubagent extends ToolSubagent {
15231
15591
  toRulesyncSubagent() {
15232
15592
  let parsed;
15233
15593
  try {
15234
- parsed = CodexCliSubagentTomlSchema.parse(smolToml5.parse(this.body));
15594
+ parsed = CodexCliSubagentTomlSchema.parse(smolToml6.parse(this.body));
15235
15595
  } catch (error) {
15236
15596
  throw new Error(
15237
15597
  `Failed to parse TOML in ${join101(this.getRelativeDirPath(), this.getRelativeFilePath())}: ${error instanceof Error ? error.message : String(error)}`,
@@ -15292,7 +15652,7 @@ var CodexCliSubagent = class _CodexCliSubagent extends ToolSubagent {
15292
15652
  }
15293
15653
  validate() {
15294
15654
  try {
15295
- const parsed = smolToml5.parse(this.body);
15655
+ const parsed = smolToml6.parse(this.body);
15296
15656
  CodexCliSubagentTomlSchema.parse(parsed);
15297
15657
  return { success: true, error: null };
15298
15658
  } catch (error) {
@@ -15354,12 +15714,12 @@ var CodexCliSubagent = class _CodexCliSubagent extends ToolSubagent {
15354
15714
 
15355
15715
  // src/features/subagents/copilot-subagent.ts
15356
15716
  import { join as join102 } from "path";
15357
- import { z as z59 } from "zod/mini";
15717
+ import { z as z58 } from "zod/mini";
15358
15718
  var REQUIRED_TOOL = "agent/runSubagent";
15359
- var CopilotSubagentFrontmatterSchema = z59.looseObject({
15360
- name: z59.string(),
15361
- description: z59.optional(z59.string()),
15362
- tools: z59.optional(z59.union([z59.string(), z59.array(z59.string())]))
15719
+ var CopilotSubagentFrontmatterSchema = z58.looseObject({
15720
+ name: z58.string(),
15721
+ description: z58.optional(z58.string()),
15722
+ tools: z58.optional(z58.union([z58.string(), z58.array(z58.string())]))
15363
15723
  });
15364
15724
  var normalizeTools = (tools) => {
15365
15725
  if (!tools) {
@@ -15371,6 +15731,21 @@ var ensureRequiredTool = (tools) => {
15371
15731
  const mergedTools = /* @__PURE__ */ new Set([REQUIRED_TOOL, ...tools]);
15372
15732
  return Array.from(mergedTools);
15373
15733
  };
15734
+ var toCopilotAgentFilePath = (relativeFilePath) => {
15735
+ if (relativeFilePath.endsWith(".agent.md")) {
15736
+ return relativeFilePath;
15737
+ }
15738
+ if (relativeFilePath.endsWith(".md")) {
15739
+ return relativeFilePath.replace(/\.md$/, ".agent.md");
15740
+ }
15741
+ return relativeFilePath;
15742
+ };
15743
+ var toRulesyncFilePath = (relativeFilePath) => {
15744
+ if (relativeFilePath.endsWith(".agent.md")) {
15745
+ return relativeFilePath.replace(/\.agent\.md$/, ".md");
15746
+ }
15747
+ return relativeFilePath;
15748
+ };
15374
15749
  var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
15375
15750
  frontmatter;
15376
15751
  body;
@@ -15417,7 +15792,7 @@ var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
15417
15792
  frontmatter: rulesyncFrontmatter,
15418
15793
  body: this.body,
15419
15794
  relativeDirPath: RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH,
15420
- relativeFilePath: this.getRelativeFilePath(),
15795
+ relativeFilePath: toRulesyncFilePath(this.getRelativeFilePath()),
15421
15796
  validate: true
15422
15797
  });
15423
15798
  }
@@ -15443,16 +15818,12 @@ var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
15443
15818
  const body = rulesyncSubagent.getBody();
15444
15819
  const fileContent = stringifyFrontmatter(body, copilotFrontmatter);
15445
15820
  const paths = this.getSettablePaths({ global });
15446
- let relativeFilePath = rulesyncSubagent.getRelativeFilePath();
15447
- if (!relativeFilePath.endsWith(".agent.md")) {
15448
- relativeFilePath = relativeFilePath.replace(/\.md$/, ".agent.md");
15449
- }
15450
15821
  return new _CopilotSubagent({
15451
15822
  baseDir,
15452
15823
  frontmatter: copilotFrontmatter,
15453
15824
  body,
15454
15825
  relativeDirPath: paths.relativeDirPath,
15455
- relativeFilePath,
15826
+ relativeFilePath: toCopilotAgentFilePath(rulesyncSubagent.getRelativeFilePath()),
15456
15827
  fileContent,
15457
15828
  validate,
15458
15829
  global
@@ -15524,10 +15895,10 @@ var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
15524
15895
 
15525
15896
  // src/features/subagents/cursor-subagent.ts
15526
15897
  import { join as join103 } from "path";
15527
- import { z as z60 } from "zod/mini";
15528
- var CursorSubagentFrontmatterSchema = z60.looseObject({
15529
- name: z60.string(),
15530
- description: z60.optional(z60.string())
15898
+ import { z as z59 } from "zod/mini";
15899
+ var CursorSubagentFrontmatterSchema = z59.looseObject({
15900
+ name: z59.string(),
15901
+ description: z59.optional(z59.string())
15531
15902
  });
15532
15903
  var CursorSubagent = class _CursorSubagent extends ToolSubagent {
15533
15904
  frontmatter;
@@ -15671,11 +16042,11 @@ var CursorSubagent = class _CursorSubagent extends ToolSubagent {
15671
16042
 
15672
16043
  // src/features/subagents/deepagents-subagent.ts
15673
16044
  import { join as join104 } from "path";
15674
- import { z as z61 } from "zod/mini";
15675
- var DeepagentsSubagentFrontmatterSchema = z61.looseObject({
15676
- name: z61.string(),
15677
- description: z61.optional(z61.string()),
15678
- model: z61.optional(z61.string())
16045
+ import { z as z60 } from "zod/mini";
16046
+ var DeepagentsSubagentFrontmatterSchema = z60.looseObject({
16047
+ name: z60.string(),
16048
+ description: z60.optional(z60.string()),
16049
+ model: z60.optional(z60.string())
15679
16050
  });
15680
16051
  var DeepagentsSubagent = class _DeepagentsSubagent extends ToolSubagent {
15681
16052
  frontmatter;
@@ -15824,10 +16195,10 @@ var DeepagentsSubagent = class _DeepagentsSubagent extends ToolSubagent {
15824
16195
 
15825
16196
  // src/features/subagents/junie-subagent.ts
15826
16197
  import { join as join105 } from "path";
15827
- import { z as z62 } from "zod/mini";
15828
- var JunieSubagentFrontmatterSchema = z62.looseObject({
15829
- name: z62.optional(z62.string()),
15830
- description: z62.string()
16198
+ import { z as z61 } from "zod/mini";
16199
+ var JunieSubagentFrontmatterSchema = z61.looseObject({
16200
+ name: z61.optional(z61.string()),
16201
+ description: z61.string()
15831
16202
  });
15832
16203
  var JunieSubagent = class _JunieSubagent extends ToolSubagent {
15833
16204
  frontmatter;
@@ -15985,11 +16356,11 @@ import { join as join107 } from "path";
15985
16356
 
15986
16357
  // src/features/subagents/opencode-style-subagent.ts
15987
16358
  import { basename as basename8, join as join106 } from "path";
15988
- import { z as z63 } from "zod/mini";
15989
- var OpenCodeStyleSubagentFrontmatterSchema = z63.looseObject({
15990
- description: z63.optional(z63.string()),
15991
- mode: z63._default(z63.string(), "subagent"),
15992
- name: z63.optional(z63.string())
16359
+ import { z as z62 } from "zod/mini";
16360
+ var OpenCodeStyleSubagentFrontmatterSchema = z62.looseObject({
16361
+ description: z62.optional(z62.string()),
16362
+ mode: z62._default(z62.string(), "subagent"),
16363
+ name: z62.optional(z62.string())
15993
16364
  });
15994
16365
  var OpenCodeStyleSubagent = class extends ToolSubagent {
15995
16366
  frontmatter;
@@ -16138,22 +16509,22 @@ var KiloSubagent = class _KiloSubagent extends OpenCodeStyleSubagent {
16138
16509
 
16139
16510
  // src/features/subagents/kiro-subagent.ts
16140
16511
  import { join as join108 } from "path";
16141
- import { z as z64 } from "zod/mini";
16142
- var KiroCliSubagentJsonSchema = z64.looseObject({
16143
- name: z64.string(),
16144
- description: z64.optional(z64.nullable(z64.string())),
16145
- prompt: z64.optional(z64.nullable(z64.string())),
16146
- tools: z64.optional(z64.nullable(z64.array(z64.string()))),
16147
- toolAliases: z64.optional(z64.nullable(z64.record(z64.string(), z64.string()))),
16148
- toolSettings: z64.optional(z64.nullable(z64.unknown())),
16149
- toolSchema: z64.optional(z64.nullable(z64.unknown())),
16150
- hooks: z64.optional(z64.nullable(z64.record(z64.string(), z64.array(z64.unknown())))),
16151
- model: z64.optional(z64.nullable(z64.string())),
16152
- mcpServers: z64.optional(z64.nullable(z64.record(z64.string(), z64.unknown()))),
16153
- useLegacyMcpJson: z64.optional(z64.nullable(z64.boolean())),
16154
- resources: z64.optional(z64.nullable(z64.array(z64.string()))),
16155
- allowedTools: z64.optional(z64.nullable(z64.array(z64.string()))),
16156
- includeMcpJson: z64.optional(z64.nullable(z64.boolean()))
16512
+ import { z as z63 } from "zod/mini";
16513
+ var KiroCliSubagentJsonSchema = z63.looseObject({
16514
+ name: z63.string(),
16515
+ description: z63.optional(z63.nullable(z63.string())),
16516
+ prompt: z63.optional(z63.nullable(z63.string())),
16517
+ tools: z63.optional(z63.nullable(z63.array(z63.string()))),
16518
+ toolAliases: z63.optional(z63.nullable(z63.record(z63.string(), z63.string()))),
16519
+ toolSettings: z63.optional(z63.nullable(z63.unknown())),
16520
+ toolSchema: z63.optional(z63.nullable(z63.unknown())),
16521
+ hooks: z63.optional(z63.nullable(z63.record(z63.string(), z63.array(z63.unknown())))),
16522
+ model: z63.optional(z63.nullable(z63.string())),
16523
+ mcpServers: z63.optional(z63.nullable(z63.record(z63.string(), z63.unknown()))),
16524
+ useLegacyMcpJson: z63.optional(z63.nullable(z63.boolean())),
16525
+ resources: z63.optional(z63.nullable(z63.array(z63.string()))),
16526
+ allowedTools: z63.optional(z63.nullable(z63.array(z63.string()))),
16527
+ includeMcpJson: z63.optional(z63.nullable(z63.boolean()))
16157
16528
  });
16158
16529
  var KiroSubagent = class _KiroSubagent extends ToolSubagent {
16159
16530
  body;
@@ -16414,7 +16785,7 @@ var subagentsProcessorToolTargetTuple = [
16414
16785
  "roo",
16415
16786
  "rovodev"
16416
16787
  ];
16417
- var SubagentsProcessorToolTargetSchema = z65.enum(subagentsProcessorToolTargetTuple);
16788
+ var SubagentsProcessorToolTargetSchema = z64.enum(subagentsProcessorToolTargetTuple);
16418
16789
  var toolSubagentFactories = /* @__PURE__ */ new Map([
16419
16790
  [
16420
16791
  "agentsmd",
@@ -16724,42 +17095,42 @@ import { join as join112 } from "path";
16724
17095
 
16725
17096
  // src/features/rules/rulesync-rule.ts
16726
17097
  import { join as join111 } from "path";
16727
- import { z as z66 } from "zod/mini";
16728
- var RulesyncRuleFrontmatterSchema = z66.object({
16729
- root: z66.optional(z66.boolean()),
16730
- localRoot: z66.optional(z66.boolean()),
16731
- targets: z66._default(RulesyncTargetsSchema, ["*"]),
16732
- description: z66.optional(z66.string()),
16733
- globs: z66.optional(z66.array(z66.string())),
16734
- agentsmd: z66.optional(
16735
- z66.looseObject({
17098
+ import { z as z65 } from "zod/mini";
17099
+ var RulesyncRuleFrontmatterSchema = z65.object({
17100
+ root: z65.optional(z65.boolean()),
17101
+ localRoot: z65.optional(z65.boolean()),
17102
+ targets: z65._default(RulesyncTargetsSchema, ["*"]),
17103
+ description: z65.optional(z65.string()),
17104
+ globs: z65.optional(z65.array(z65.string())),
17105
+ agentsmd: z65.optional(
17106
+ z65.looseObject({
16736
17107
  // @example "path/to/subproject"
16737
- subprojectPath: z66.optional(z66.string())
17108
+ subprojectPath: z65.optional(z65.string())
16738
17109
  })
16739
17110
  ),
16740
- claudecode: z66.optional(
16741
- z66.looseObject({
17111
+ claudecode: z65.optional(
17112
+ z65.looseObject({
16742
17113
  // Glob patterns for conditional rules (takes precedence over globs)
16743
17114
  // @example ["src/**/*.ts", "tests/**/*.test.ts"]
16744
- paths: z66.optional(z66.array(z66.string()))
17115
+ paths: z65.optional(z65.array(z65.string()))
16745
17116
  })
16746
17117
  ),
16747
- cursor: z66.optional(
16748
- z66.looseObject({
16749
- alwaysApply: z66.optional(z66.boolean()),
16750
- description: z66.optional(z66.string()),
16751
- globs: z66.optional(z66.array(z66.string()))
17118
+ cursor: z65.optional(
17119
+ z65.looseObject({
17120
+ alwaysApply: z65.optional(z65.boolean()),
17121
+ description: z65.optional(z65.string()),
17122
+ globs: z65.optional(z65.array(z65.string()))
16752
17123
  })
16753
17124
  ),
16754
- copilot: z66.optional(
16755
- z66.looseObject({
16756
- excludeAgent: z66.optional(z66.union([z66.literal("code-review"), z66.literal("coding-agent")]))
17125
+ copilot: z65.optional(
17126
+ z65.looseObject({
17127
+ excludeAgent: z65.optional(z65.union([z65.literal("code-review"), z65.literal("coding-agent")]))
16757
17128
  })
16758
17129
  ),
16759
- antigravity: z66.optional(
16760
- z66.looseObject({
16761
- trigger: z66.optional(z66.string()),
16762
- globs: z66.optional(z66.array(z66.string()))
17130
+ antigravity: z65.optional(
17131
+ z65.looseObject({
17132
+ trigger: z65.optional(z65.string()),
17133
+ globs: z65.optional(z65.array(z65.string()))
16763
17134
  })
16764
17135
  )
16765
17136
  });
@@ -17059,20 +17430,20 @@ var AgentsMdRule = class _AgentsMdRule extends ToolRule {
17059
17430
 
17060
17431
  // src/features/rules/antigravity-rule.ts
17061
17432
  import { join as join114 } from "path";
17062
- import { z as z67 } from "zod/mini";
17063
- var AntigravityRuleFrontmatterSchema = z67.looseObject({
17064
- trigger: z67.optional(
17065
- z67.union([
17066
- z67.literal("always_on"),
17067
- z67.literal("glob"),
17068
- z67.literal("manual"),
17069
- z67.literal("model_decision"),
17070
- z67.string()
17433
+ import { z as z66 } from "zod/mini";
17434
+ var AntigravityRuleFrontmatterSchema = z66.looseObject({
17435
+ trigger: z66.optional(
17436
+ z66.union([
17437
+ z66.literal("always_on"),
17438
+ z66.literal("glob"),
17439
+ z66.literal("manual"),
17440
+ z66.literal("model_decision"),
17441
+ z66.string()
17071
17442
  // accepts any string for forward compatibility
17072
17443
  ])
17073
17444
  ),
17074
- globs: z67.optional(z67.string()),
17075
- description: z67.optional(z67.string())
17445
+ globs: z66.optional(z66.string()),
17446
+ description: z66.optional(z66.string())
17076
17447
  });
17077
17448
  function parseGlobsString(globs) {
17078
17449
  if (!globs) {
@@ -17659,9 +18030,9 @@ var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
17659
18030
 
17660
18031
  // src/features/rules/claudecode-rule.ts
17661
18032
  import { join as join118 } from "path";
17662
- import { z as z68 } from "zod/mini";
17663
- var ClaudecodeRuleFrontmatterSchema = z68.object({
17664
- paths: z68.optional(z68.array(z68.string()))
18033
+ import { z as z67 } from "zod/mini";
18034
+ var ClaudecodeRuleFrontmatterSchema = z67.object({
18035
+ paths: z67.optional(z67.array(z67.string()))
17665
18036
  });
17666
18037
  var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
17667
18038
  frontmatter;
@@ -17877,9 +18248,9 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
17877
18248
 
17878
18249
  // src/features/rules/cline-rule.ts
17879
18250
  import { join as join119 } from "path";
17880
- import { z as z69 } from "zod/mini";
17881
- var ClineRuleFrontmatterSchema = z69.object({
17882
- description: z69.string()
18251
+ import { z as z68 } from "zod/mini";
18252
+ var ClineRuleFrontmatterSchema = z68.object({
18253
+ description: z68.string()
17883
18254
  });
17884
18255
  var ClineRule = class _ClineRule extends ToolRule {
17885
18256
  static getSettablePaths(_options = {}) {
@@ -18058,11 +18429,11 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
18058
18429
 
18059
18430
  // src/features/rules/copilot-rule.ts
18060
18431
  import { join as join121 } from "path";
18061
- import { z as z70 } from "zod/mini";
18062
- var CopilotRuleFrontmatterSchema = z70.object({
18063
- description: z70.optional(z70.string()),
18064
- applyTo: z70.optional(z70.string()),
18065
- excludeAgent: z70.optional(z70.union([z70.literal("code-review"), z70.literal("coding-agent")]))
18432
+ import { z as z69 } from "zod/mini";
18433
+ var CopilotRuleFrontmatterSchema = z69.object({
18434
+ description: z69.optional(z69.string()),
18435
+ applyTo: z69.optional(z69.string()),
18436
+ excludeAgent: z69.optional(z69.union([z69.literal("code-review"), z69.literal("coding-agent")]))
18066
18437
  });
18067
18438
  var CopilotRule = class _CopilotRule extends ToolRule {
18068
18439
  frontmatter;
@@ -18304,11 +18675,11 @@ var CopilotcliRule = class _CopilotcliRule extends CopilotRule {
18304
18675
 
18305
18676
  // src/features/rules/cursor-rule.ts
18306
18677
  import { join as join122 } from "path";
18307
- import { z as z71 } from "zod/mini";
18308
- var CursorRuleFrontmatterSchema = z71.object({
18309
- description: z71.optional(z71.string()),
18310
- globs: z71.optional(z71.string()),
18311
- alwaysApply: z71.optional(z71.boolean())
18678
+ import { z as z70 } from "zod/mini";
18679
+ var CursorRuleFrontmatterSchema = z70.object({
18680
+ description: z70.optional(z70.string()),
18681
+ globs: z70.optional(z70.string()),
18682
+ alwaysApply: z70.optional(z70.boolean())
18312
18683
  });
18313
18684
  var CursorRule = class _CursorRule extends ToolRule {
18314
18685
  frontmatter;
@@ -19968,11 +20339,11 @@ var rulesProcessorToolTargets = [
19968
20339
  "warp",
19969
20340
  "windsurf"
19970
20341
  ];
19971
- var RulesProcessorToolTargetSchema = z72.enum(rulesProcessorToolTargets);
20342
+ var RulesProcessorToolTargetSchema = z71.enum(rulesProcessorToolTargets);
19972
20343
  var formatRulePaths = (rules) => rules.map((r) => join137(r.getRelativeDirPath(), r.getRelativeFilePath())).join(", ");
19973
- var RulesFeatureOptionsSchema = z72.looseObject({
19974
- ruleDiscoveryMode: z72.optional(z72.enum(["none", "explicit"])),
19975
- includeLocalRoot: z72.optional(z72.boolean())
20344
+ var RulesFeatureOptionsSchema = z71.looseObject({
20345
+ ruleDiscoveryMode: z71.optional(z71.enum(["none", "explicit"])),
20346
+ includeLocalRoot: z71.optional(z71.boolean())
19976
20347
  });
19977
20348
  var resolveRuleDiscoveryMode = ({
19978
20349
  defaultMode,
@@ -19993,8 +20364,8 @@ var resolveRuleDiscoveryMode = ({
19993
20364
  }
19994
20365
  return parsed.data.ruleDiscoveryMode === "none" ? "auto" : "toon";
19995
20366
  };
19996
- var IncludeLocalRootSchema = z72.looseObject({
19997
- includeLocalRoot: z72.optional(z72.boolean())
20367
+ var IncludeLocalRootSchema = z71.looseObject({
20368
+ includeLocalRoot: z71.optional(z71.boolean())
19998
20369
  });
19999
20370
  var resolveIncludeLocalRoot = (options) => {
20000
20371
  if (!options) return true;
@@ -21616,176 +21987,6 @@ async function importPermissionsCore(params) {
21616
21987
  return writtenCount;
21617
21988
  }
21618
21989
 
21619
- // src/types/json-output.ts
21620
- var ErrorCodes = {
21621
- CONFIG_NOT_FOUND: "CONFIG_NOT_FOUND",
21622
- RULESYNC_DIR_NOT_FOUND: "RULESYNC_DIR_NOT_FOUND",
21623
- INVALID_TARGET: "INVALID_TARGET",
21624
- FETCH_FAILED: "FETCH_FAILED",
21625
- WRITE_FAILED: "WRITE_FAILED",
21626
- VALIDATION_FAILED: "VALIDATION_FAILED",
21627
- GENERATION_FAILED: "GENERATION_FAILED",
21628
- IMPORT_FAILED: "IMPORT_FAILED",
21629
- INSTALL_FAILED: "INSTALL_FAILED",
21630
- UPDATE_FAILED: "UPDATE_FAILED",
21631
- GITIGNORE_FAILED: "GITIGNORE_FAILED",
21632
- INIT_FAILED: "INIT_FAILED",
21633
- MCP_FAILED: "MCP_FAILED",
21634
- UNKNOWN_ERROR: "UNKNOWN_ERROR"
21635
- };
21636
- var CLIError = class extends Error {
21637
- constructor(message, code = ErrorCodes.UNKNOWN_ERROR, exitCode = 1) {
21638
- super(message);
21639
- this.code = code;
21640
- this.exitCode = exitCode;
21641
- this.name = "CLIError";
21642
- }
21643
- };
21644
-
21645
- // src/utils/logger.ts
21646
- var BaseLogger = class {
21647
- _verbose = false;
21648
- _silent = false;
21649
- constructor({ verbose = false, silent = false } = {}) {
21650
- this._silent = silent;
21651
- this._verbose = verbose && !silent;
21652
- }
21653
- get verbose() {
21654
- return this._verbose;
21655
- }
21656
- get silent() {
21657
- return this._silent;
21658
- }
21659
- configure({ verbose, silent }) {
21660
- if (verbose && silent) {
21661
- this._silent = false;
21662
- if (!isEnvTest()) {
21663
- this.onConflictingFlags();
21664
- }
21665
- }
21666
- this._silent = silent;
21667
- this._verbose = verbose && !silent;
21668
- }
21669
- onConflictingFlags() {
21670
- console.warn("Both --verbose and --silent specified; --silent takes precedence");
21671
- }
21672
- };
21673
- var ConsoleLogger = class extends BaseLogger {
21674
- isSuppressed() {
21675
- return isEnvTest() || this._silent;
21676
- }
21677
- get jsonMode() {
21678
- return false;
21679
- }
21680
- captureData(_key, _value) {
21681
- }
21682
- getJsonData() {
21683
- return {};
21684
- }
21685
- outputJson(_success, _error) {
21686
- }
21687
- info(message, ...args) {
21688
- if (this.isSuppressed()) return;
21689
- console.log(message, ...args);
21690
- }
21691
- success(message, ...args) {
21692
- if (this.isSuppressed()) return;
21693
- console.log(message, ...args);
21694
- }
21695
- warn(message, ...args) {
21696
- if (this.isSuppressed()) return;
21697
- console.warn(message, ...args);
21698
- }
21699
- // Errors are always emitted, even in silent mode
21700
- error(message, _code, ...args) {
21701
- if (isEnvTest()) return;
21702
- const errorMessage = message instanceof Error ? message.message : message;
21703
- console.error(errorMessage, ...args);
21704
- }
21705
- debug(message, ...args) {
21706
- if (!this._verbose || this.isSuppressed()) return;
21707
- console.log(message, ...args);
21708
- }
21709
- };
21710
- var JsonLogger = class extends BaseLogger {
21711
- _jsonOutputDone = false;
21712
- _jsonData = {};
21713
- _commandName;
21714
- _version;
21715
- constructor({
21716
- command,
21717
- version,
21718
- verbose = false,
21719
- silent = false
21720
- }) {
21721
- super({ verbose, silent });
21722
- this._commandName = command;
21723
- this._version = version;
21724
- }
21725
- // Suppress raw console.warn in JSON mode to avoid non-JSON text on stderr
21726
- onConflictingFlags() {
21727
- }
21728
- get jsonMode() {
21729
- return true;
21730
- }
21731
- captureData(key, value) {
21732
- this._jsonData[key] = value;
21733
- }
21734
- getJsonData() {
21735
- return { ...this._jsonData };
21736
- }
21737
- outputJson(success, error) {
21738
- if (this._jsonOutputDone) return;
21739
- this._jsonOutputDone = true;
21740
- const output = {
21741
- success,
21742
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
21743
- command: this._commandName,
21744
- version: this._version
21745
- };
21746
- if (success) {
21747
- output.data = this._jsonData;
21748
- } else if (error) {
21749
- output.error = {
21750
- code: error.code,
21751
- message: error.message
21752
- };
21753
- if (error.details) {
21754
- output.error.details = error.details;
21755
- }
21756
- if (error.stack) {
21757
- output.error.stack = error.stack;
21758
- }
21759
- }
21760
- const jsonStr = JSON.stringify(output, null, 2);
21761
- if (success) {
21762
- console.log(jsonStr);
21763
- } else {
21764
- console.error(jsonStr);
21765
- }
21766
- }
21767
- info(_message, ..._args) {
21768
- }
21769
- success(_message, ..._args) {
21770
- }
21771
- warn(_message, ..._args) {
21772
- }
21773
- error(message, code, ..._args) {
21774
- if (isEnvTest()) return;
21775
- const errorMessage = message instanceof Error ? message.message : message;
21776
- const errorInfo = {
21777
- code: code || ErrorCodes.UNKNOWN_ERROR,
21778
- message: errorMessage
21779
- };
21780
- if (this._verbose && message instanceof Error && message.stack) {
21781
- errorInfo.stack = message.stack;
21782
- }
21783
- this.outputJson(false, errorInfo);
21784
- }
21785
- debug(_message, ..._args) {
21786
- }
21787
- };
21788
-
21789
21990
  export {
21790
21991
  RULESYNC_CONFIG_RELATIVE_FILE_PATH,
21791
21992
  RULESYNC_LOCAL_CONFIG_RELATIVE_FILE_PATH,
@@ -21795,6 +21996,7 @@ export {
21795
21996
  RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH,
21796
21997
  RULESYNC_MCP_RELATIVE_FILE_PATH,
21797
21998
  RULESYNC_HOOKS_RELATIVE_FILE_PATH,
21999
+ RULESYNC_PERMISSIONS_RELATIVE_FILE_PATH,
21798
22000
  RULESYNC_AIIGNORE_FILE_NAME,
21799
22001
  RULESYNC_AIIGNORE_RELATIVE_FILE_PATH,
21800
22002
  RULESYNC_IGNORE_RELATIVE_FILE_PATH,
@@ -21823,6 +22025,7 @@ export {
21823
22025
  findFilesByGlobs,
21824
22026
  removeDirectory,
21825
22027
  removeFile,
22028
+ getHomeDirectory,
21826
22029
  createTempDirectory,
21827
22030
  removeTempDirectory,
21828
22031
  ALL_FEATURES,
@@ -21843,6 +22046,11 @@ export {
21843
22046
  IgnoreProcessor,
21844
22047
  RulesyncMcp,
21845
22048
  McpProcessor,
22049
+ RulesyncPermissions,
22050
+ ErrorCodes,
22051
+ CLIError,
22052
+ ConsoleLogger,
22053
+ JsonLogger,
21846
22054
  SKILL_FILE_NAME,
21847
22055
  RulesyncSkillFrontmatterSchema,
21848
22056
  RulesyncSkill,
@@ -21856,9 +22064,5 @@ export {
21856
22064
  RulesProcessor,
21857
22065
  checkRulesyncDirExists,
21858
22066
  generate,
21859
- importFromTool,
21860
- ErrorCodes,
21861
- CLIError,
21862
- ConsoleLogger,
21863
- JsonLogger
22067
+ importFromTool
21864
22068
  };