rulesync 17.1.0 → 19.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -44086,6 +44086,7 @@ var ClinePermissions = class ClinePermissions extends ToolPermissions {
44086
44086
  //#region src/features/permissions/codexcli-permissions.ts
44087
44087
  const RULESYNC_PROFILE_NAME = "rulesync";
44088
44088
  const CODEX_WORKSPACE_ROOTS_KEY = ":workspace_roots";
44089
+ const CODEX_WORKSPACE_ROOT_SUBPATH = ".";
44089
44090
  const CODEX_WORKSPACE_BASELINE = ":workspace";
44090
44091
  const CODEX_READ_ONLY_BASELINE = ":read-only";
44091
44092
  const CODEX_DANGER_FULL_ACCESS_BASELINE = ":danger-full-access";
@@ -44306,7 +44307,15 @@ function convertRulesyncToCodexProfile({ config, logger }) {
44306
44307
  workspaceRootFilesystem
44307
44308
  });
44308
44309
  if (Object.keys(workspaceRootFilesystem).length > 0) {
44309
- if (typeof filesystem[CODEX_WORKSPACE_ROOTS_KEY] === "string") logger?.warn(`"${CODEX_WORKSPACE_ROOTS_KEY}" is set as a direct filesystem access rule in the permissions, but it will be overwritten by workspace-root rules. Consider removing the direct "${CODEX_WORKSPACE_ROOTS_KEY}" entry.`);
44310
+ const directWorkspaceRootsAccess = filesystem[CODEX_WORKSPACE_ROOTS_KEY];
44311
+ if (isCodexFilesystemAccess(directWorkspaceRootsAccess)) {
44312
+ mergeIntoWorkspaceRootTable({
44313
+ workspaceRootFilesystem,
44314
+ pattern: CODEX_WORKSPACE_ROOT_SUBPATH,
44315
+ access: directWorkspaceRootsAccess
44316
+ });
44317
+ logger?.warn(`"${CODEX_WORKSPACE_ROOTS_KEY}" is set as a direct filesystem access rule in the permissions alongside workspace-relative rules; it is emitted as the "${CODEX_WORKSPACE_ROOT_SUBPATH}" entry of the "${CODEX_WORKSPACE_ROOTS_KEY}" table.`);
44318
+ }
44310
44319
  if (Object.keys(workspaceRootFilesystem).some((pattern) => pattern.includes("**"))) filesystem.glob_scan_max_depth = CODEX_GLOB_SCAN_MAX_DEPTH;
44311
44320
  filesystem[CODEX_WORKSPACE_ROOTS_KEY] = workspaceRootFilesystem;
44312
44321
  }
@@ -44323,9 +44332,13 @@ function convertRulesyncToCodexProfile({ config, logger }) {
44323
44332
  };
44324
44333
  }
44325
44334
  function addCodexFilesystemRules({ categoryRules, filesystem, workspaceRootFilesystem, logger }) {
44326
- for (const rule of mergeFilesystemCategoryRules({
44335
+ const normalizedCategoryRules = normalizeWorkspaceRelativeCategoryRules({
44327
44336
  categoryRules,
44328
44337
  logger
44338
+ });
44339
+ for (const rule of mergeFilesystemCategoryRules({
44340
+ categoryRules: normalizedCategoryRules,
44341
+ logger
44329
44342
  })) {
44330
44343
  const access = normalizeCodexFilesystemAccess({
44331
44344
  pattern: rule.pattern,
@@ -44335,7 +44348,7 @@ function addCodexFilesystemRules({ categoryRules, filesystem, workspaceRootFiles
44335
44348
  });
44336
44349
  if (access === void 0) continue;
44337
44350
  if (access === "read" && rule.writeRestriction === "ask") logger?.warn(`Codex CLI cannot express "ask" for filesystem write permissions: pattern "${rule.pattern}" will be emitted as read-only.`);
44338
- if (access === "read" && rule.writeRestriction === "deny") logger?.warn(`Codex CLI maps a write-side deny to read-only access: pattern "${rule.pattern}" will be emitted as "read". A broader read deny may be overridden by this more-specific path.`);
44351
+ if (access === "read" && rule.writeRestriction === "deny" && rule.readUnspecified) logger?.warn(`Codex CLI maps a write-side deny to read-only access: pattern "${rule.pattern}" will be emitted as "read". A broader read deny may be overridden by this more-specific path.`);
44339
44352
  addFilesystemRule({
44340
44353
  filesystem,
44341
44354
  workspaceRootFilesystem,
@@ -44492,9 +44505,67 @@ function addFilesystemRule({ filesystem, workspaceRootFilesystem, pattern, acces
44492
44505
  filesystem[pattern] = access;
44493
44506
  return;
44494
44507
  }
44495
- workspaceRootFilesystem[pattern] = access;
44508
+ mergeIntoWorkspaceRootTable({
44509
+ workspaceRootFilesystem,
44510
+ pattern,
44511
+ access
44512
+ });
44513
+ }
44514
+ const PERMISSION_ACTION_RESTRICTIVENESS = {
44515
+ deny: 2,
44516
+ ask: 1,
44517
+ allow: 0
44518
+ };
44519
+ function normalizeWorkspaceRelativeCategoryRules({ categoryRules, logger }) {
44520
+ const result = {};
44521
+ for (const category of [
44522
+ "read",
44523
+ "edit",
44524
+ "write"
44525
+ ]) {
44526
+ const rules = categoryRules[category];
44527
+ if (rules === void 0) continue;
44528
+ const normalized = {};
44529
+ for (const [pattern, action] of Object.entries(rules)) {
44530
+ const key = pattern.trim() === "" || canBeCodexFilesystemRoot(pattern) ? pattern : toWorkspaceRootSubpath(pattern);
44531
+ if (key === void 0) {
44532
+ logger?.warn(`Skipping Codex CLI ${category} filesystem entry for workspace-relative pattern "${pattern}": Codex rejects a ":workspace_roots" subpath containing a ".." segment or an empty leading segment and would refuse the whole config, so the rule is dropped entirely — even a deny — and the path is NOT protected by the generated profile. Use a normalized relative path instead.`);
44533
+ continue;
44534
+ }
44535
+ const existing = normalized[key];
44536
+ normalized[key] = existing === void 0 || PERMISSION_ACTION_RESTRICTIVENESS[action] > PERMISSION_ACTION_RESTRICTIVENESS[existing] ? action : existing;
44537
+ }
44538
+ result[category] = normalized;
44539
+ }
44540
+ return result;
44541
+ }
44542
+ function toWorkspaceRootSubpath(pattern) {
44543
+ let subpath = pattern;
44544
+ while (subpath.startsWith("./")) subpath = subpath.slice(2);
44545
+ if (subpath === "" || subpath === "**" && subpath !== pattern) return CODEX_WORKSPACE_ROOT_SUBPATH;
44546
+ if (subpath.startsWith("/") || subpath.split(/[\\/]/).some((segment) => segment === "..")) return;
44547
+ return subpath;
44548
+ }
44549
+ function mergeIntoWorkspaceRootTable({ workspaceRootFilesystem, pattern, access }) {
44550
+ const existing = workspaceRootFilesystem[pattern];
44551
+ workspaceRootFilesystem[pattern] = existing === void 0 ? access : moreRestrictiveCodexAccess({
44552
+ a: existing,
44553
+ b: access
44554
+ });
44496
44555
  }
44497
44556
  function normalizeCodexFilesystemAccess({ pattern, access, writeRestriction, logger }) {
44557
+ if (isWindowsDevicePath(pattern) && !canBeCodexFilesystemRoot(pattern)) {
44558
+ logger?.warn(`Skipping Codex CLI ${access} filesystem entry for Windows device path "${pattern}": Codex cannot express it as a workspace-root entry (it is rejected on Windows and matches nothing elsewhere), so the rule is dropped entirely — even a deny — and the path is NOT protected by the generated profile. Use a plain drive path such as "C:\\..." instead.`);
44559
+ return;
44560
+ }
44561
+ if ((access === "read" || access === "write") && isWindowsDevicePath(pattern)) {
44562
+ if (writeRestriction !== void 0) {
44563
+ logger?.warn(`Codex CLI does not support Windows device paths for read/write access: pattern "${pattern}" will be emitted as "deny" because its write-side ${writeRestriction} restriction cannot be represented as read-only access. Use a plain drive path such as "C:\\..." instead.`);
44564
+ return "deny";
44565
+ }
44566
+ logger?.warn(`Skipping unsupported Codex CLI ${access} filesystem entry for Windows device path "${pattern}"; the base permission profile remains in effect. Use a plain drive path such as "C:\\..." instead.`);
44567
+ return;
44568
+ }
44498
44569
  if ((access === "read" || access === "write") && hasUnsupportedCodexFilesystemGlob(pattern)) {
44499
44570
  if (writeRestriction !== void 0) {
44500
44571
  logger?.warn(`Codex CLI only supports deny access for non-trailing filesystem globs: pattern "${pattern}" will be emitted as "deny" because its write-side ${writeRestriction} restriction cannot be represented as read-only access. Use an exact path or trailing "/**" for read/write access.`);
@@ -44508,6 +44579,9 @@ function normalizeCodexFilesystemAccess({ pattern, access, writeRestriction, log
44508
44579
  function hasCodexFilesystemGlob(pattern) {
44509
44580
  return pattern.includes("*") || pattern.includes("?") || pattern.includes("[") || pattern.includes("]");
44510
44581
  }
44582
+ function isWindowsDevicePath(pattern) {
44583
+ return pattern.startsWith("\\\\?\\") || pattern.startsWith("\\\\.\\");
44584
+ }
44511
44585
  function hasUnsupportedCodexFilesystemGlob(pattern) {
44512
44586
  return hasCodexFilesystemGlob(pattern.endsWith("/**") ? pattern.slice(0, -3) : pattern);
44513
44587
  }
@@ -44524,7 +44598,9 @@ function addRulesyncFilesystemRule(permission, pattern, access) {
44524
44598
  permission.read ??= {};
44525
44599
  permission.read[pattern] = "allow";
44526
44600
  } else {
44601
+ permission.read ??= {};
44527
44602
  permission.edit ??= {};
44603
+ permission.read[pattern] = "allow";
44528
44604
  permission.edit[pattern] = "allow";
44529
44605
  }
44530
44606
  }
@@ -44649,18 +44725,44 @@ function mapReadAction(action) {
44649
44725
  function mapWriteAction(action) {
44650
44726
  return action === "allow" ? "write" : "read";
44651
44727
  }
44728
+ /**
44729
+ * Merge the canonical read/edit/write category rules into one Codex access
44730
+ * level per path pattern (Codex models a single `deny` < `read` < `write`
44731
+ * level, with no `ask`).
44732
+ *
44733
+ * - `edit` and `write` collapse onto Codex's write side; when both carry the
44734
+ * same pattern, the more restrictive action wins (`deny` > `ask` > `allow`).
44735
+ * - `read: allow` + write-side `allow` → `"write"`.
44736
+ * - A write-side non-allow → `"read"` (readable but not writable — exactly
44737
+ * what Codex's `"read"` level expresses). An `ask` action is approximated
44738
+ * this way because Codex has no path-level write approval.
44739
+ * - A write-side-only rule (no `read` rule for the same pattern) whose path
44740
+ * is covered by a broader `read` deny/ask rule (e.g. `X/**` covering
44741
+ * `X/id_rsa`, or `:root`) → `"deny"`, for a write-side `allow` too (with a
44742
+ * warning). Codex resolves the most specific path, so emitting `"read"` or
44743
+ * `"write"` there would re-open reads the user denied. Only the most
44744
+ * specific covering read rule counts: a narrower `read: allow` between the
44745
+ * broad deny and the path keeps the path readable.
44746
+ * - A `read` non-allow on the same pattern → `"deny"` regardless of the
44747
+ * write side; a contradictory write-side `allow` (unreadable but writable
44748
+ * is not expressible in Codex) is warned about.
44749
+ * - Single-category patterns keep the existing mapReadAction/mapWriteAction
44750
+ * mappings.
44751
+ *
44752
+ * Iteration order is read → edit → write with first-seen pattern order, so
44753
+ * the emitted table is stable regardless of the authored category order.
44754
+ * Note the merge is one-way: `"{path}" = "read"` imports back as
44755
+ * `read: allow` only. The write-side restriction is implied by Codex's access
44756
+ * level and not re-materialized, so both `read: allow` + write-side
44757
+ * `ask`/`deny` and a write-side-only `ask`/`deny` (e.g. `edit: { "/x/**":
44758
+ * "deny" }` with no `read` rule) lose their write restriction on
44759
+ * `rulesync import`. This is deliberate: importing `"read"` as an extra
44760
+ * `edit: deny` would push a restriction to every other tool that the Codex
44761
+ * profile alone cannot prove was authored.
44762
+ */
44652
44763
  function mergeFilesystemCategoryRules({ categoryRules, logger }) {
44653
44764
  const readRules = categoryRules.read ?? {};
44654
- const writeSideRestrictiveness = {
44655
- deny: 2,
44656
- ask: 1,
44657
- allow: 0
44658
- };
44659
- const writeSideRules = {};
44660
- for (const category of ["edit", "write"]) for (const [pattern, action] of Object.entries(categoryRules[category] ?? {})) {
44661
- const existing = writeSideRules[pattern];
44662
- if (existing === void 0 || writeSideRestrictiveness[action] > writeSideRestrictiveness[existing]) writeSideRules[pattern] = action;
44663
- }
44765
+ const writeSideRules = collapseWriteSideRules(categoryRules);
44664
44766
  const patterns = [];
44665
44767
  const seen = /* @__PURE__ */ new Set();
44666
44768
  for (const pattern of [...Object.keys(readRules), ...Object.keys(writeSideRules)]) if (!seen.has(pattern)) {
@@ -44671,37 +44773,131 @@ function mergeFilesystemCategoryRules({ categoryRules, logger }) {
44671
44773
  for (const pattern of patterns) {
44672
44774
  const readAction = readRules[pattern];
44673
44775
  const writeAction = writeSideRules[pattern];
44674
- if (readAction === void 0) {
44776
+ if (writeAction === void 0) {
44675
44777
  merged.push({
44676
44778
  pattern,
44677
- access: mapWriteAction(writeAction),
44678
- ...writeAction === "ask" || writeAction === "deny" ? { writeRestriction: writeAction } : {}
44779
+ access: mapReadAction(readAction)
44679
44780
  });
44680
44781
  continue;
44681
44782
  }
44682
- if (writeAction === void 0) {
44783
+ if (readAction !== void 0 && readAction !== "allow") {
44784
+ if (writeAction === "allow") logger?.warn(`Codex CLI cannot express "writable but not readable": pattern "${pattern}" has read: ${readAction} and a write-side allow. Emitting "deny".`);
44683
44785
  merged.push({
44684
44786
  pattern,
44685
- access: mapReadAction(readAction)
44787
+ access: "deny"
44686
44788
  });
44687
44789
  continue;
44688
44790
  }
44689
- if (readAction === "allow") {
44791
+ const writeRestriction = writeAction === "allow" ? void 0 : writeAction;
44792
+ const readUnspecified = readAction === void 0;
44793
+ if (readUnspecified && isCoveredByReadRestriction({
44794
+ pattern,
44795
+ readRules
44796
+ })) {
44797
+ if (writeRestriction === void 0) logger?.warn(`Codex CLI cannot express "writable but not readable": pattern "${pattern}" has a write-side allow but is covered by a broader read deny/ask rule. Emitting "deny".`);
44690
44798
  merged.push({
44691
44799
  pattern,
44692
- access: writeAction === "allow" ? "write" : "read",
44693
- ...writeAction === "ask" || writeAction === "deny" ? { writeRestriction: writeAction } : {}
44800
+ access: "deny"
44694
44801
  });
44695
44802
  continue;
44696
44803
  }
44697
- if (writeAction === "allow") logger?.warn(`Codex CLI cannot express "writable but not readable": pattern "${pattern}" has read: ${readAction} and a write-side allow. Emitting "deny".`);
44698
44804
  merged.push({
44699
44805
  pattern,
44700
- access: "deny"
44806
+ access: mapWriteAction(writeAction),
44807
+ ...writeRestriction !== void 0 ? { writeRestriction } : {},
44808
+ ...readUnspecified ? { readUnspecified } : {}
44701
44809
  });
44702
44810
  }
44703
44811
  return merged;
44704
44812
  }
44813
+ function collapseWriteSideRules(categoryRules) {
44814
+ const writeSideRules = {};
44815
+ for (const category of ["edit", "write"]) for (const [pattern, action] of Object.entries(categoryRules[category] ?? {})) {
44816
+ const existing = writeSideRules[pattern];
44817
+ if (existing === void 0 || PERMISSION_ACTION_RESTRICTIVENESS[action] > PERMISSION_ACTION_RESTRICTIVENESS[existing]) writeSideRules[pattern] = action;
44818
+ }
44819
+ return writeSideRules;
44820
+ }
44821
+ function isCoveredByReadRestriction({ pattern, readRules }) {
44822
+ const key = normalizeCoverageKey(pattern);
44823
+ const isWorkspaceRelative = !canBeCodexFilesystemRoot(pattern);
44824
+ const keyHasDotSegment = hasDotPathSegment(pattern);
44825
+ let best;
44826
+ for (const [readPattern, action] of Object.entries(readRules)) {
44827
+ if (readPattern === pattern) continue;
44828
+ const specificity = coverageSpecificity({
44829
+ readPattern,
44830
+ key,
44831
+ isWorkspaceRelative
44832
+ });
44833
+ if (specificity === void 0) continue;
44834
+ const restrictive = action !== "allow";
44835
+ if (!restrictive && isSkippedCodexGrant(readPattern)) continue;
44836
+ if (!restrictive && (keyHasDotSegment || hasDotPathSegment(readPattern))) continue;
44837
+ if (best === void 0 || specificity > best.specificity || specificity === best.specificity && restrictive) best = {
44838
+ specificity,
44839
+ restrictive
44840
+ };
44841
+ }
44842
+ return best?.restrictive ?? false;
44843
+ }
44844
+ function coverageSpecificity({ readPattern, key, isWorkspaceRelative }) {
44845
+ if (readPattern === ":root" || readPattern === "/**") return 0;
44846
+ if (readPattern === CODEX_WORKSPACE_ROOTS_KEY) return isWorkspaceRelative ? 1 : void 0;
44847
+ if (canBeCodexFilesystemRoot(readPattern) === isWorkspaceRelative) return;
44848
+ const normalized = normalizeCoverageKey(readPattern);
44849
+ if (normalized === "**" || normalized === ".") return isWorkspaceRelative ? 1 : void 0;
44850
+ const withoutTrailingGlob = normalized.endsWith("/**") ? normalized.slice(0, -3) : normalized;
44851
+ if (withoutTrailingGlob.startsWith(":") || hasCodexFilesystemGlob(withoutTrailingGlob)) return;
44852
+ const base = stripTrailingSlash(withoutTrailingGlob);
44853
+ if (base === "") return;
44854
+ return key === base || key.startsWith(base.endsWith("/") ? base : `${base}/`) ? 2 + base.length : void 0;
44855
+ }
44856
+ function normalizeCoverageKey(pattern) {
44857
+ const form = toCoverageForm(pattern);
44858
+ return canBeCodexFilesystemRoot(pattern) && !pattern.startsWith(":") ? resolveDotSegments(form) : form;
44859
+ }
44860
+ function resolveDotSegments(path) {
44861
+ const [anchor = "", ...rest] = path.split("/");
44862
+ const stack = [];
44863
+ for (const segment of rest) {
44864
+ if (segment === ".") continue;
44865
+ if (segment === "..") {
44866
+ if (stack.length > 0 && stack[stack.length - 1] !== "..") stack.pop();
44867
+ else if (anchor === "~") stack.push(segment);
44868
+ continue;
44869
+ }
44870
+ stack.push(segment);
44871
+ }
44872
+ const resolved = [anchor, ...stack].join("/");
44873
+ return resolved === "" ? "/" : stripTrailingSlash(resolved);
44874
+ }
44875
+ function toCoverageForm(pattern) {
44876
+ let normalized = /^[A-Za-z]:[\\/]/.test(pattern) ? `${pattern.charAt(0).toLowerCase()}${pattern.slice(1).replaceAll("\\", "/")}` : pattern;
44877
+ while (normalized.startsWith("./")) normalized = normalized.slice(2);
44878
+ normalized = stripTrailingSlash(normalized);
44879
+ return normalized === "" && pattern !== "" ? "." : normalized;
44880
+ }
44881
+ function hasDotPathSegment(pattern) {
44882
+ const form = toCoverageForm(pattern);
44883
+ if (form === ".") return false;
44884
+ return form.split(/[\\/]/).some((segment) => segment === "." || segment === "..");
44885
+ }
44886
+ function isSkippedCodexGrant(pattern) {
44887
+ return isWindowsDevicePath(pattern) || hasUnsupportedCodexFilesystemGlob(pattern);
44888
+ }
44889
+ function moreRestrictiveCodexAccess({ a, b }) {
44890
+ const rank = {
44891
+ deny: 0,
44892
+ none: 0,
44893
+ read: 1,
44894
+ write: 2
44895
+ };
44896
+ return rank[a] <= rank[b] ? a : b;
44897
+ }
44898
+ function stripTrailingSlash(pattern) {
44899
+ return pattern.length > 1 && pattern.endsWith("/") ? pattern.slice(0, -1) : pattern;
44900
+ }
44705
44901
  function buildCodexBashRulesContent(config) {
44706
44902
  const bashRules = bashRulesHonoringAllTools(config.permission);
44707
44903
  const entries = Object.entries(bashRules);
@@ -59546,21 +59742,43 @@ const CodexCliSkillFrontmatterSchema = z.looseObject({
59546
59742
  */
59547
59743
  const CODEX_OPENAI_YAML_RELATIVE_PATH = CODEXCLI_OPENAI_YAML_RELATIVE_PATH;
59548
59744
  /**
59549
- * Build the `agents/openai.yaml` object from a rulesync `codexcli` section.
59550
- * Only produced when the user opts in via `interface`, `policy`, or `dependencies`;
59551
- * a lone legacy `short-description` keeps mapping to `SKILL.md` `metadata` only.
59745
+ * Resolve Codex's `policy.allow_implicit_invocation` from the rulesync inputs.
59746
+ * An explicit `codexcli.policy.allow_implicit_invocation` wins; otherwise the root
59747
+ * `disable-model-invocation: true` maps onto `false`. With neither set the value is
59748
+ * left undefined, since Codex already defaults to `true`.
59749
+ * @see https://github.com/openai/codex/blob/main/codex-rs/skills/src/model.rs
59750
+ */
59751
+ function resolveAllowImplicitInvocation({ codexcli, disableModelInvocation }) {
59752
+ const explicit = codexcli?.policy?.allow_implicit_invocation;
59753
+ if (explicit !== void 0) return explicit;
59754
+ return disableModelInvocation === true ? false : void 0;
59755
+ }
59756
+ /**
59757
+ * Build the `agents/openai.yaml` object from a rulesync `codexcli` section and the
59758
+ * root-level `disable-model-invocation` flag.
59759
+ * Only produced when the user opts in via `interface`, `policy`, or `dependencies`,
59760
+ * or when the root `disable-model-invocation: true` maps onto
59761
+ * `policy.allow_implicit_invocation: false`; a lone legacy `short-description` keeps
59762
+ * mapping to `SKILL.md` `metadata` only.
59552
59763
  * When the sidecar is produced and `interface.short_description` is absent, the
59553
59764
  * legacy `short-description` is routed there (its canonical home per Codex docs).
59554
59765
  */
59555
- function buildOpenaiYamlObject(codexcli) {
59556
- if (!codexcli) return;
59557
- if (!Boolean(codexcli.interface || codexcli.policy || codexcli.dependencies)) return;
59558
- const interfaceSection = { ...codexcli.interface };
59559
- if (interfaceSection.short_description === void 0 && codexcli["short-description"] !== void 0) interfaceSection.short_description = codexcli["short-description"];
59766
+ function buildOpenaiYamlObject({ codexcli, disableModelInvocation }) {
59767
+ const allowImplicitInvocation = resolveAllowImplicitInvocation({
59768
+ codexcli,
59769
+ disableModelInvocation
59770
+ });
59771
+ const policySection = {
59772
+ ...codexcli?.policy,
59773
+ ...allowImplicitInvocation !== void 0 && { allow_implicit_invocation: allowImplicitInvocation }
59774
+ };
59775
+ if (!Boolean(codexcli?.interface || codexcli?.policy || codexcli?.dependencies) && Object.keys(policySection).length === 0) return;
59776
+ const interfaceSection = { ...codexcli?.interface };
59777
+ if (interfaceSection.short_description === void 0 && codexcli?.["short-description"] !== void 0) interfaceSection.short_description = codexcli["short-description"];
59560
59778
  const result = {};
59561
59779
  if (Object.keys(interfaceSection).length > 0) result.interface = interfaceSection;
59562
- if (codexcli.policy && Object.keys(codexcli.policy).length > 0) result.policy = codexcli.policy;
59563
- if (codexcli.dependencies && Object.keys(codexcli.dependencies).length > 0) result.dependencies = codexcli.dependencies;
59780
+ if (Object.keys(policySection).length > 0) result.policy = policySection;
59781
+ if (codexcli?.dependencies && Object.keys(codexcli.dependencies).length > 0) result.dependencies = codexcli.dependencies;
59564
59782
  return Object.keys(result).length > 0 ? result : void 0;
59565
59783
  }
59566
59784
  /**
@@ -59589,6 +59807,11 @@ function extractOpenaiYamlFile(otherFiles) {
59589
59807
  }
59590
59808
  /**
59591
59809
  * Map a parsed `agents/openai.yaml` object back into a rulesync `codexcli` section.
59810
+ * `policy.allow_implicit_invocation` stays under `codexcli.policy` rather than being
59811
+ * promoted to the root `disable-model-invocation`, matching how every other tool's
59812
+ * importer keeps its invocation flags in its own section: promoting it would change
59813
+ * the output of every other target on the next generate, while the section value
59814
+ * regenerates the same sidecar because it takes precedence over the root flag.
59592
59815
  */
59593
59816
  function openaiYamlToCodexcliSection(parsed) {
59594
59817
  if (!parsed) return;
@@ -59687,7 +59910,10 @@ var CodexCliSkill = class CodexCliSkill extends ToolSkill {
59687
59910
  };
59688
59911
  const target = toPosixPath(CODEX_OPENAI_YAML_RELATIVE_PATH);
59689
59912
  const baseOtherFiles = rulesyncSkill.getOtherFiles().filter((file) => toPosixPath(file.relativeFilePathToDirPath) !== target);
59690
- const openaiObject = buildOpenaiYamlObject(rulesyncFrontmatter.codexcli);
59913
+ const openaiObject = buildOpenaiYamlObject({
59914
+ codexcli: rulesyncFrontmatter.codexcli,
59915
+ disableModelInvocation: rulesyncFrontmatter["disable-model-invocation"]
59916
+ });
59691
59917
  const otherFiles = openaiObject ? [...baseOtherFiles, {
59692
59918
  relativeFilePathToDirPath: CODEX_OPENAI_YAML_RELATIVE_PATH,
59693
59919
  fileBuffer: Buffer.from(dump(openaiObject, {
@@ -79112,6 +79338,7 @@ const findFilesWithFallback = async (primaryFilePaths, alternativeRoots, buildAl
79112
79338
  * delete generated files it can no longer regenerate and report success.
79113
79339
  */
79114
79340
  const rootRelativeGlob = (...segments) => posix.join(...segments.filter((segment) => segment !== void 0).map(toPosixPath));
79341
+ const isRootRule = (rule) => Boolean(rule.getFrontmatter().root || rule.getFrontmatter().localRoot);
79115
79342
  var RulesProcessor = class extends FeatureProcessor {
79116
79343
  toolTarget;
79117
79344
  simulateCommands;
@@ -79123,7 +79350,8 @@ var RulesProcessor = class extends FeatureProcessor {
79123
79350
  getFactory;
79124
79351
  skills;
79125
79352
  featureOptions;
79126
- constructor({ outputRoot = process.cwd(), inputRoots, toolTarget, simulateCommands = false, simulateSubagents = false, simulateSkills = false, language, deriveSubprojectPathFromGlobs = false, global = false, getFactory = defaultGetFactory, skills, featureOptions, dryRun = false, logger }) {
79353
+ deleteOrphans;
79354
+ constructor({ outputRoot = process.cwd(), inputRoots, toolTarget, simulateCommands = false, simulateSubagents = false, simulateSkills = false, language, deriveSubprojectPathFromGlobs = false, global = false, getFactory = defaultGetFactory, skills, featureOptions, delete: deleteOrphans = false, dryRun = false, logger }) {
79127
79355
  super({
79128
79356
  outputRoot,
79129
79357
  inputRoots,
@@ -79142,6 +79370,7 @@ var RulesProcessor = class extends FeatureProcessor {
79142
79370
  this.getFactory = getFactory;
79143
79371
  this.skills = skills;
79144
79372
  this.featureOptions = featureOptions;
79373
+ this.deleteOrphans = deleteOrphans;
79145
79374
  }
79146
79375
  async convertRulesyncFilesToToolFiles(rulesyncFiles) {
79147
79376
  const rulesyncRules = rulesyncFiles.filter((file) => file instanceof RulesyncRule);
@@ -79149,7 +79378,7 @@ var RulesProcessor = class extends FeatureProcessor {
79149
79378
  const factory = this.getFactory(this.toolTarget);
79150
79379
  const { meta } = factory;
79151
79380
  this.warnForIncludeRootOption(meta);
79152
- const emittedRules = this.omitsRootFiles() ? alignedRules.filter((rule) => !rule.getFrontmatter().root && !rule.getFrontmatter().localRoot) : alignedRules;
79381
+ const emittedRules = this.omitsRootFiles() ? await this.dropRootRules(alignedRules) : alignedRules;
79153
79382
  const localRootRules = emittedRules.filter((rule) => rule.getFrontmatter().localRoot);
79154
79383
  const convertedRules = emittedRules.filter((rule) => !rule.getFrontmatter().localRoot).map((rulesyncRule) => {
79155
79384
  if (!factory.class.isTargetedByRulesyncRule(rulesyncRule)) return null;
@@ -79294,8 +79523,9 @@ var RulesProcessor = class extends FeatureProcessor {
79294
79523
  * non-root `.claude/rules/*.md`. Claude Code falls back to `AGENTS.md` only
79295
79524
  * when none of `CLAUDE.md`, `.claude/CLAUDE.md` or `CLAUDE.local.md` exists,
79296
79525
  * so emitting either root file would shadow an `AGENTS.md` written by another
79297
- * target. Stale root files are swept by the regular orphan deletion because
79298
- * they are no longer part of the generated output. Global scope keeps the
79526
+ * target. With `delete` on, stale root files are swept by the regular orphan
79527
+ * deletion because they are no longer part of the generated output; without
79528
+ * it, conversion warns about them instead. Global scope keeps the
79299
79529
  * root file: `~/.claude/CLAUDE.md` never shadows `AGENTS.md`, and Claude Code
79300
79530
  * reads no global `AGENTS.md` to fall back to. `claudecode-legacy` is not
79301
79531
  * covered: its `.claude/memories/*.md` are only reachable through the
@@ -79325,19 +79555,53 @@ var RulesProcessor = class extends FeatureProcessor {
79325
79555
  }) !== "auto") this.logger.warn("The rules option `ruleDiscoveryMode` has no effect with `includeRoot: false` on claudecode: the rule references it adds are written into CLAUDE.md, which is not generated.");
79326
79556
  }
79327
79557
  /**
79328
- * With `includeRoot: false`, a hand-authored root file at an alternative
79329
- * location (`.claude/CLAUDE.md`, `.claude/CLAUDE.local.md`) still keeps
79330
- * Claude Code from reading `AGENTS.md`. Rulesync never writes those files, so
79331
- * it leaves them in place and tells the user instead of deleting them.
79558
+ * Drop the root and local-root rules for `includeRoot: false`, reporting what
79559
+ * would otherwise go unnoticed: a dropped rule no other target emits, and a
79560
+ * root file on disk that keeps shadowing `AGENTS.md`. With `delete` on, the
79561
+ * orphan sweep removes the project-root files and reports the rest itself
79562
+ * (see {@link loadToolFiles}), so conversion only reports them when no sweep
79563
+ * runs.
79332
79564
  */
79333
- async warnForShadowingAlternativeRoots(alternativeRoots) {
79334
- const localRootFileName = this.getFactory(this.toolTarget).meta.localRootFileName;
79335
- const globs = alternativeRoots.flatMap((alt) => [rootRelativeGlob(alt.relativeDirPath, alt.relativeFilePath), ...localRootFileName ? [rootRelativeGlob(alt.relativeDirPath, localRootFileName)] : []]);
79336
- if (globs.length === 0) return;
79337
- const filePaths = await findFilesByGlobs(globs, { cwd: this.outputRoot });
79565
+ async dropRootRules(rules) {
79566
+ this.warnForClaudecodeOnlyRootRules(rules.filter(isRootRule));
79567
+ if (!this.deleteOrphans || this.hasRulesyncSourceLoadFailure()) await this.warnForShadowingRootFiles({ includePrimaryRoots: true });
79568
+ return rules.filter((rule) => !isRootRule(rule));
79569
+ }
79570
+ /**
79571
+ * A root or local-root rule that targets `claudecode` alone is dropped by
79572
+ * `includeRoot: false`, and no other target writes it either, so its content
79573
+ * would end up nowhere without a word.
79574
+ */
79575
+ warnForClaudecodeOnlyRootRules(rootRules) {
79576
+ for (const rule of rootRules) {
79577
+ const targets = rule.getFrontmatter().targets ?? ["*"];
79578
+ if (targets.length === 0 || !targets.every((target) => target === "claudecode")) continue;
79579
+ this.logger.warn(`${stripControlCharacters(rule.getRelativeFilePath())} is a root rule that targets only claudecode, so \`includeRoot: false\` drops it and no target generates its content. Add the target that writes AGENTS.md to its \`targets\`, or turn it into a non-root rule.`);
79580
+ }
79581
+ }
79582
+ /**
79583
+ * With `includeRoot: false`, a root file still on disk keeps Claude Code
79584
+ * from reading `AGENTS.md`: a project-root `CLAUDE.md` or `CLAUDE.local.md`
79585
+ * (`includePrimaryRoots`), which only the `delete` sweep removes, and a
79586
+ * hand-authored `.claude/CLAUDE.md` at an alternative location, which
79587
+ * Rulesync never writes and so never deletes. `.claude/CLAUDE.local.md` is
79588
+ * not checked: it is not one of the files that shadow `AGENTS.md`.
79589
+ * @see https://code.claude.com/docs/en/memory#when-claude-code-reads-agents-md
79590
+ */
79591
+ async warnForShadowingRootFiles({ includePrimaryRoots }) {
79592
+ const factory = this.getFactory(this.toolTarget);
79593
+ const settablePaths = factory.class.getSettablePaths({ global: this.global });
79594
+ const primaryDirPath = settablePaths.root?.relativeDirPath ?? ".";
79595
+ const primaryGlobs = (includePrimaryRoots && settablePaths.root ? [settablePaths.root.relativeFilePath, ...factory.meta.localRootFileName ? [factory.meta.localRootFileName] : []] : []).map((fileName) => rootRelativeGlob(primaryDirPath, fileName));
79596
+ const alternativeGlobs = (settablePaths.alternativeRoots ?? []).map((alt) => rootRelativeGlob(alt.relativeDirPath, alt.relativeFilePath));
79597
+ const primaryFilePaths = primaryGlobs.length > 0 ? await findFilesByGlobs(primaryGlobs, { cwd: this.outputRoot }) : [];
79598
+ const alternativeFilePaths = alternativeGlobs.length > 0 ? await findFilesByGlobs(alternativeGlobs, { cwd: this.outputRoot }) : [];
79599
+ const filePaths = [...primaryFilePaths, ...alternativeFilePaths];
79338
79600
  if (filePaths.length === 0) return;
79339
79601
  const names = filePaths.map((filePath) => stripControlCharacters(relative(this.outputRoot, filePath)));
79340
- this.logger.warn(`${names.join(", ")} still ${names.length === 1 ? "keeps" : "keep"} Claude Code from reading AGENTS.md although \`includeRoot: false\` is set for claudecode. Rulesync does not delete ${names.length === 1 ? "it" : "them"}; remove ${names.length === 1 ? "it" : "them"} by hand once the content is covered by AGENTS.md.`);
79602
+ const one = names.length === 1;
79603
+ const deleteHint = primaryFilePaths.length > 0 ? " Enable `delete` to have Rulesync remove a project-root CLAUDE.md or CLAUDE.local.md itself." : "";
79604
+ this.logger.warn(`${names.join(", ")} still ${one ? "keeps" : "keep"} Claude Code from reading AGENTS.md although \`includeRoot: false\` is set for claudecode. Rulesync leaves ${one ? "it" : "them"} in place; remove ${one ? "it" : "them"} by hand once the content is covered by AGENTS.md.${deleteHint}`);
79341
79605
  }
79342
79606
  isClaudecodeTarget() {
79343
79607
  return this.toolTarget === "claudecode" || this.toolTarget === "claudecode-legacy";
@@ -79978,7 +80242,7 @@ As this project's AI coding tool, you must follow the additional conventions bel
79978
80242
  const rootToolRules = await (async () => {
79979
80243
  if (!settablePaths.root) return [];
79980
80244
  if (forDeletion && omitsRootFiles) {
79981
- await this.warnForShadowingAlternativeRoots(settablePaths.alternativeRoots ?? []);
80245
+ await this.warnForShadowingRootFiles({ includePrimaryRoots: false });
79982
80246
  return buildDeletionRulesFromPaths(primaryRootFilePaths);
79983
80247
  }
79984
80248
  const uniqueRootFilePaths = await findFilesWithFallback(primaryRootFilePaths, settablePaths.alternativeRoots, (alt) => rootRelativeGlob(alt.relativeDirPath, alt.relativeFilePath), this.outputRoot);
@@ -81540,6 +81804,7 @@ async function generateRulesCore(params) {
81540
81804
  deriveSubprojectPathFromGlobs: config.getDeriveSubprojectPathFromGlobs(),
81541
81805
  skills,
81542
81806
  featureOptions: config.getFeatureOptions(toolTarget, "rules"),
81807
+ delete: config.getDelete(),
81543
81808
  dryRun: config.isPreviewMode(),
81544
81809
  logger
81545
81810
  });
@@ -82319,4 +82584,4 @@ async function importChecksCore(params) {
82319
82584
  //#endregion
82320
82585
  export { RulesyncCommand as $, toPosixPath as $t, CLAUDECODE_MEMORIES_DIR_NAME as A, RULESYNC_XDG_CONFIG_HOME_DEFAULT_DIR_NAME as An, checkPathTraversal as At, RulesyncSubagent as B, stripControlCharacters as Bn, listDirectoryEntryNames as Bt, COMMANDCODE_DIR as C, RULESYNC_PERMISSIONS_SCHEMA_URL as Cn, withWarnOnceScope as Ct, CODEXCLI_DIR as D, RULESYNC_SOURCES_LOCK_RELATIVE_FILE_PATH as Dn, assertDirectoryIfExists as Dt, CODEXCLI_BASH_RULES_FILE_NAME as E, RULESYNC_SKILLS_RELATIVE_DIR_PATH as En, applyFileMode as Et, caseFoldIdentity as F, formatError as Fn, getFileSize as Ft, RulesyncRuleFrontmatterSchema as G, readFileContentOrNull as Gt, RulesyncSkill as H, stripHiddenCharacters as Hn, listSubdirectoryNames as Ht, groupSpellingsByCaseFoldedIdentity as I, truncateText as In, getHomeDirectory as It, RulesyncIgnore as J, removeFile as Jt, RulesyncPermissions as K, removeDirectory as Kt, AUGMENTCODE_DIR as L, hasDeceptiveHiddenCharacters as Ln, isFileNotFoundError as Lt, CLAUDECODE_SKILLS_DIR_PATH as M, ALL_FEATURES as Mn, directoryExists as Mt, FACTORYDROID_DIR as N, ALL_FEATURES_WITH_WILDCARD as Nn, ensureDir as Nt, CLAUDECODE_DIR as O, RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH as On, assertTreeContainsNoSymlinks as Ot, FACTORYDROID_SETTINGS_LOCAL_FILE_NAME as P, DEPRECATED_FEATURE_REPLACEMENTS as Pn, fileExists as Pt, parseJsonc as Q, runWithDirectoryRollback as Qt, AUGMENTCODE_SETTINGS_LOCAL_FILE_NAME as R, hasEnclosingMarkOutsideKeycap as Rn, isFileSystemError as Rt, QWENCODE_LOCAL_RULE_FILE_NAME as S, RULESYNC_PERMISSIONS_RELATIVE_FILE_PATH as Sn, resetRunWarningState as St, ChecksProcessor as T, RULESYNC_RULES_RELATIVE_DIR_PATH as Tn, ErrorCodes as Tt, RulesyncSkillFrontmatterSchema as U, pathEscapesRoot as Ut, RulesyncSubagentFrontmatterSchema as V, stripControlCharactersKeepingLineFeeds as Vn, listFilePathsRecursively as Vt, RulesyncRule as W, readFileContent as Wt, getRulesyncSourceCandidates as X, removeTempDirectory as Xt, RulesyncHooks as Y, removeFileStrict as Yt, resolveRulesyncSourceWritePath as Z, resolvePath as Zt, IgnoreProcessor as _, RULESYNC_IGNORE_RELATIVE_FILE_PATH as _n, JsonLogger as _t, getProcessorRegistryEntry as a, ToolTargetSchema as an, SHARED_USER_MANAGED_CONFIG_PATHS as at, CommandsProcessor as b, RULESYNC_MCP_SCHEMA_URL as bn, warnOnConflictingFlags as bt, RulesProcessor as c, MAX_FILE_SIZE as cn, mergeInputRootConfigs as ct, CODEBUDDY_DIR as d, RULESYNC_COMMANDS_RELATIVE_DIR_PATH as dn, ConfigFileSchema as dt, writeFileBuffer as en, RulesyncCommandFrontmatterSchema as et, CODEBUDDY_LOCAL_RULE_FILE_NAME as f, RULESYNC_CONFIG_RELATIVE_FILE_PATH as fn, GITIGNORE_DESTINATION_KEY as ft, McpProcessor as g, RULESYNC_HOOKS_RELATIVE_FILE_PATH as gn, ConsoleLogger as gt, shortenToWidth as h, RULESYNC_CURATED_SKILLS_RELATIVE_DIR_PATH as hn, findControlCharacter as ht, inspectInputRoots as i, PACKAGING_TOOL_TARGETS as in, loadYaml as it, CLAUDECODE_SETTINGS_LOCAL_FILE_NAME as j, parseCommaSeparatedList as jn, createTempDirectory as jt, CLAUDECODE_LOCAL_RULE_FILE_NAME as k, RULESYNC_USER_CONFIG_DIR_NAME as kn, assertWritablePathInsideRoot as kt, SubagentsProcessor as l, RULESYNC_AIIGNORE_RELATIVE_FILE_PATH as ln, resolveEffectiveInputRoots as lt, displayWidthOf as m, RULESYNC_CURATED_RULES_RELATIVE_DIR_PATH as mn, assertTargetsFeaturesExclusive as mt, formatSourceLoadFailure as n, ALL_TOOL_TARGETS as nn, RulesyncCheckFrontmatterSchema as nt, convertFromTool as o, CURATED_RULES_FEATURE_SUBDIR as on, SKILL_FILE_NAME as ot, ELLIPSIS_WIDTH as p, RULESYNC_CONFIG_SCHEMA_URL as pn, SourceEntrySchema as pt, RulesyncMcp as q, removeDirectoryStrict as qt, generate as r, ALL_TOOL_TARGETS_WITH_WILDCARD as rn, stringifyFrontmatter as rt, isPackagingToolTarget as s, FEATURE_SOURCE_TREE_ENTRIES as sn, ConfigResolver as st, importFromTool as t, writeFileContent as tn, RulesyncCheck as tt, SkillsProcessor as u, RULESYNC_CHECKS_RELATIVE_DIR_PATH as un, CONFLICTING_TARGET_PAIRS as ut, HooksProcessor as v, RULESYNC_LOCAL_CONFIG_RELATIVE_FILE_PATH as vn, WarningCollectingLogger as vt, COMMANDCODE_SETTINGS_LOCAL_FILE_NAME as w, RULESYNC_RELATIVE_DIR_PATH as wn, CLIError as wt, QWENCODE_DIR as x, RULESYNC_NPM_SOURCES_LOCK_RELATIVE_FILE_PATH as xn, withFallbackLoggerTarget as xt, CRUSH_LOCAL_RULE_FILE_NAME as y, RULESYNC_MCP_RELATIVE_FILE_PATH as yn, fallbackLogger as yt, getLocalSkillDirNames as z, quoteForLog as zn, isSymlink as zt };
82321
82586
 
82322
- //# sourceMappingURL=import-Csmx6n4n.js.map
82587
+ //# sourceMappingURL=import-C-Jsxedt.js.map