rulesync 43.8.1 → 43.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -80326,17 +80326,40 @@ function normalizeUrlPattern(pattern) {
80326
80326
  /**
80327
80327
  * A URL pattern with its scheme stripped and only its host lowercased, for
80328
80328
  * writing it into a tool that matches paths case-sensitively (Copilot in VS
80329
- * Code). A scheme spelled as a glob (a `*` scheme, `http*`, or a bare double
80330
- * slash after a `*`) is stripped too.
80329
+ * Code). A scheme spelled as a glob (a `*` scheme, `http*://`, or a bare double
80330
+ * slash after a `*` or at the start) is stripped too. A double slash after
80331
+ * anything else without a `:` is part of the path, so `evil.com//x` keeps its
80332
+ * host `evil.com`.
80331
80333
  */
80332
80334
  function stripUrlSchemeKeepingPathCase(pattern) {
80333
- const withoutScheme = pattern.replace(/^[a-z0-9+.*-]*:?\/\//i, "");
80335
+ return keepingPathCase(pattern.replace(/^(?:[a-z0-9+.*-]*:|\*)?\/\//i, ""));
80336
+ }
80337
+ /**
80338
+ * The reading `stripUrlSchemeKeepingPathCase` gave before it required a `:`,
80339
+ * which took any `<word>//` prefix for a scheme (`evil.com//x` became `x`).
80340
+ * Overlap checks compare this reading too, so requiring the `:` only ever
80341
+ * adds overlaps and never lets through an allow that was withheld before.
80342
+ */
80343
+ function stripUrlSchemeLoosely(pattern) {
80344
+ return keepingPathCase(pattern.replace(/^[a-z0-9+.*-]*:?\/\//i, ""));
80345
+ }
80346
+ /**
80347
+ * Whether a URL pattern has a `<word>//` prefix without a `:` (`evil.com//x`),
80348
+ * which an earlier reading took for a scheme. Such a pattern names a host
80349
+ * other than the one that reading gave, so a tool should not be handed a
80350
+ * rewritten form of it.
80351
+ */
80352
+ function hasDoubleSlashWithoutScheme(pattern) {
80353
+ return stripUrlSchemeKeepingPathCase(pattern) !== stripUrlSchemeLoosely(pattern);
80354
+ }
80355
+ /** A scheme-less URL pattern with only its host lowercased. */
80356
+ function keepingPathCase(withoutScheme) {
80334
80357
  const slash = withoutScheme.indexOf("/");
80335
80358
  return slash === -1 ? withoutScheme.toLowerCase() : `${withoutScheme.slice(0, slash).toLowerCase()}${withoutScheme.slice(slash)}`;
80336
80359
  }
80337
- /** Split a lowercased, scheme-less URL or domain pattern into host, port and path. */
80338
- function splitUrlPattern(pattern) {
80339
- const normalized = stripUrlSchemeKeepingPathCase(pattern).toLowerCase();
80360
+ /** Split a scheme-less URL or domain pattern into lowercased host, port and path. */
80361
+ function splitUrlPattern(withoutScheme) {
80362
+ const normalized = withoutScheme.toLowerCase();
80340
80363
  const slash = normalized.indexOf("/");
80341
80364
  const hostPort = slash === -1 ? normalized : normalized.slice(0, slash);
80342
80365
  const path = slash === -1 ? void 0 : normalized.slice(slash);
@@ -80359,8 +80382,10 @@ function splitUrlPattern(pattern) {
80359
80382
  * tools read as every URL on it, on any port, and on its subdomains, so a
80360
80383
  * missing path or port matches every path or port, and each host also stands
80361
80384
  * for `*.<host>`. Because a glob can also match across those parts, the
80362
- * whole strings are compared as well, and an overlap from either counts. A
80363
- * pattern holding whitespace names no URL.
80385
+ * whole strings are compared as well, a pathless `right` also as `<host>/*`
80386
+ * (so an allowed `example.com` overlaps a restricted `*.pdf`), and an overlap
80387
+ * from any of them counts. A pattern holding whitespace names no URL. Callers
80388
+ * pass the restriction as `left` and the allow as `right`.
80364
80389
  */
80365
80390
  function urlPatternsOverlap(left, right) {
80366
80391
  if (left === right) return true;
@@ -80371,17 +80396,35 @@ function urlPatternsOverlap(left, right) {
80371
80396
  * The whole-string comparison a `*` restriction also gets, since a glob there
80372
80397
  * matches the whole URL (`*.pdf` names `https://example.com/doc.pdf`): the two
80373
80398
  * patterns compared as written and lowercased without a scheme, each widened
80374
- * by `createShadowingRestrictionsTest`.
80399
+ * by `createShadowingRestrictionsTest`. A pathless allow (`right`) is a host
80400
+ * and stands for every path on it, so against a restriction without a `/`
80401
+ * (`*.pdf`, `*admin`) it is also compared as `<host>/*`. A restriction with a
80402
+ * `/` names its host and path itself and is compared part by part instead, and
80403
+ * a pathless restriction is not widened: `.env/*` would reach every allow that
80404
+ * starts with a `*` (`*.github.com`), and `*://evil.com/*` against
80405
+ * `good.com/*` would match through the `*`.
80375
80406
  */
80376
80407
  function wholeStringsOverlap(left, right) {
80377
- return [[left, right], [normalizeUrlPattern(left), normalizeUrlPattern(right)]].some(([restriction = "", allow = ""]) => createShadowingRestrictionsTest([{
80408
+ const normalizedLeft = normalizeUrlPattern(left);
80409
+ const normalizedRight = normalizeUrlPattern(right);
80410
+ return [
80411
+ [left, right],
80412
+ [normalizedLeft, normalizedRight],
80413
+ ...normalizedLeft.includes("/") ? [] : [[normalizedLeft, withAnyPath(normalizedRight)]]
80414
+ ].some(([restriction = "", allow = ""]) => createShadowingRestrictionsTest([{
80378
80415
  pattern: restriction,
80379
80416
  fromAllToolsCategory: false
80380
80417
  }])(allow).length > 0);
80381
80418
  }
80419
+ /** A scheme-less pattern with `/*` appended when it has no path. */
80420
+ function withAnyPath(withoutScheme) {
80421
+ return stripUrlSchemeKeepingPathCase(withoutScheme).includes("/") ? withoutScheme : `${withoutScheme}/*`;
80422
+ }
80382
80423
  function urlPartsOverlap(left, right) {
80383
- const a = splitUrlPattern(left);
80384
- const b = splitUrlPattern(right);
80424
+ const readings = (pattern) => [.../* @__PURE__ */ new Set([stripUrlSchemeKeepingPathCase(pattern), stripUrlSchemeLoosely(pattern)])].map(splitUrlPattern);
80425
+ return readings(left).some((a) => readings(right).some((b) => urlPartsPairOverlap(a, b)));
80426
+ }
80427
+ function urlPartsPairOverlap(a, b) {
80385
80428
  const hosts = (host) => [host, `*.${host}`];
80386
80429
  if (!hosts(a.host).some((x) => hosts(b.host).some((y) => globsIntersect(x, y)))) return false;
80387
80430
  if (a.port !== void 0 && b.port !== void 0 && !globsIntersect(a.port, b.port)) return false;
@@ -80727,7 +80770,7 @@ const MATCH_ALL_PATH_GLOBS = /* @__PURE__ */ new Set([
80727
80770
  "**/*"
80728
80771
  ]);
80729
80772
  const DIRECTORY_CONTENTS_SUFFIX = /\/\*\*(?:\/\*)?$/;
80730
- const HOME_OR_VARIABLE_PATH = /^~(?:[A-Za-z_][\w.-]*)?(?:[/\\]|$)|^\$[A-Za-z_]|^%[A-Za-z_]\w*%|\$\{[A-Za-z_]/;
80773
+ const HOME_OR_VARIABLE_PATH = /^~(?:[A-Za-z_][\w.-]*)?(?:[/\\]|$)|^\$[A-Za-z_]|^%[A-Za-z_][\w() ]*%|\$\{[A-Za-z_]/;
80731
80774
  const LEADING_HOME = /^~(?:\/|$)/;
80732
80775
  /**
80733
80776
  * The home directory as an Antigravity path: forward slashes, no trailing
@@ -80741,8 +80784,8 @@ function toAntigravityHomePath(homeDirectory) {
80741
80784
  * directory. agy 1.5.1 matches `~` literally, so a `~/...` rule would never
80742
80785
  * apply (rulesync#3324). Only a file the user's own home holds, such as the
80743
80786
  * global Antigravity CLI settings, may carry a machine-specific path, so the
80744
- * caller passes `homeDirectory` only then. `$HOME`, `${HOME}`, `%VAR%` and
80745
- * `~user/` are left as written and still warned about.
80787
+ * caller passes `homeDirectory` only then. `$HOME`, `${HOME}`, `%VAR%`, `~\`,
80788
+ * `~user` and `~user/` are left as written and still warned about.
80746
80789
  */
80747
80790
  function expandLeadingHome(target, homeDirectory) {
80748
80791
  if (homeDirectory === void 0 || !LEADING_HOME.test(target)) return target;
@@ -88156,7 +88199,7 @@ function honorCopilotAllToolsRestrictions({ permission, category, logger }) {
88156
88199
  key: "*"
88157
88200
  }) ?? {};
88158
88201
  const isWritable = restatesAsCategoryRule();
88159
- const restateAs = (params) => params.pattern === "*" || isWritable(params);
88202
+ const restateAs = (params) => params.pattern === "*" || isWritable(params) && !(params.category === "webfetch" && hasDoubleSlashWithoutScheme(params.pattern));
88160
88203
  const writable = {};
88161
88204
  const notWritable = {};
88162
88205
  for (const [pattern, action] of Object.entries(allToolsRules)) {
@@ -105930,4 +105973,4 @@ const CHECKS_IMPORT_STRATEGY = {
105930
105973
  };
105931
105974
  export { RulesyncRule as $, RULESYNC_RULES_RELATIVE_DIR_PATH as $n, getFileSizeAndExecutableBit as $t, CODEBUDDY_LOCAL_RULE_FILE_NAME as A, ToolTargetSchema as An, fallbackLogger as At, CLAUDECODE_LOCAL_RULE_FILE_NAME as B, RULESYNC_CONFIG_RELATIVE_FILE_PATH as Bn, assertDirectoryIfExists as Bt, LETTACODE_DIR as C, toPosixPath as Cn, SourceEntrySchema as Ct, COMMANDCODE_DIR as D, ALL_TOOL_TARGETS as Dn, ConsoleLogger as Dt, FACTORYDROID_SETTINGS_LOCAL_FILE_NAME as E, mapWithConcurrency as En, findControlCharacter as Et, sweepRefusalReason as F, FEATURE_SOURCE_TREE_ENTRIES as Fn, CLIError as Ft, toInstructionBudgetFile as G, RULESYNC_IGNORE_RELATIVE_FILE_PATH as Gn, assertWritablePathInsideRoot as Gt, CLAUDECODE_SETTINGS_LOCAL_FILE_NAME as H, RULESYNC_CURATED_RULES_RELATIVE_DIR_PATH as Hn, assertNoSymlinkBelowRoot as Ht, CODEXCLI_BASH_RULES_FILE_NAME as I, MAX_FILE_SIZE as In, ErrorCodes as It, getLocalSkillDirNames as J, RULESYNC_MCP_SCHEMA_URL as Jn, directoryExists as Jt, classifyRemoteName as K, RULESYNC_LOCAL_CONFIG_RELATIVE_FILE_PATH as Kn, checkPathTraversal as Kt, CODEXCLI_DIR as L, RULESYNC_AIIGNORE_RELATIVE_FILE_PATH as Ln, parseJsonc as Lt, AUGMENTCODE_SETTINGS_LOCAL_FILE_NAME as M, ALL_FEATURES_WITH_WILDCARD as Mn, withFallbackLoggerTarget as Mt, caseFoldIdentity as N, DEPRECATED_FEATURE_REPLACEMENTS as Nn, resetRunWarningState as Nt, COMMANDCODE_SETTINGS_LOCAL_FILE_NAME as O, ALL_TOOL_TARGETS_WITH_WILDCARD as On, JsonLogger as Ot, groupSpellingsByCaseFoldedIdentity as P, CURATED_RULES_FEATURE_SUBDIR as Pn, withWarnOnceScope as Pt, RulesyncSkillFrontmatterSchema as Q, RULESYNC_RELATIVE_DIR_PATH as Qn, findFilesByGlobs as Qt, CLAUDECODE_AGENT_MEMORY_LOCAL_DIR_NAME as R, RULESYNC_CHECKS_RELATIVE_DIR_PATH as Rn, PathOutsideRootError as Rt, QWENCODE_LOCAL_RULE_FILE_NAME as S, splitPathSegments as Sn, GITIGNORE_DESTINATION_KEY as St, FACTORYDROID_DIR as T, writeFileContent as Tn, getSourceTransport as Tt, CLAUDECODE_SKILLS_DIR_PATH as U, RULESYNC_CURATED_SKILLS_RELATIVE_DIR_PATH as Un, assertPathResolvesInsideRoot as Ut, CLAUDECODE_MEMORIES_DIR_NAME as V, RULESYNC_CONFIG_SCHEMA_URL as Vn, assertLandingOutsideVcsMetadata as Vt, findProjectInstructionBudgetFindings as W, RULESYNC_HOOKS_RELATIVE_FILE_PATH as Wn, assertTreeContainsNoSymlinks as Wt, RulesyncSubagentFrontmatterSchema as X, RULESYNC_PERMISSIONS_RELATIVE_FILE_PATH as Xn, fileExists as Xt, RulesyncSubagent as Y, RULESYNC_NPM_SOURCES_LOCK_RELATIVE_FILE_PATH as Yn, ensureDir as Yt, RulesyncSkill as Z, RULESYNC_PERMISSIONS_SCHEMA_URL as Zn, fileExistsStrict as Zt, SkillsProcessor as _, removeFileWithoutFollowingSymlinks as _n, mergeInputRootConfigs as _t, convertFromTool as a, listDirectoryEntryNames as an, formatMegabytes as ar, getRulesyncSourceCandidates as at, REASONIX_LOCAL_RULE_FILE_NAME as b, resolvedRelativePath as bn, CONFLICTING_TARGET_PAIRS as bt, ELLIPSIS_WIDTH as c, normalizePosixDirPath as cn, hasEnclosingMarkOutsideKeycap as cr, RulesyncCommandFrontmatterSchema as ct, McpProcessor as d, readFileContent as dn, stripControlCharactersKeepingLineFeeds as dr, stringifyFrontmatter as dt, getHomeDirectory as en, RULESYNC_SKILLS_RELATIVE_DIR_PATH as er, RulesyncRuleFrontmatterSchema as et, IgnoreProcessor as f, readFileContentOrNull as fn, stripControlCharactersKeepingLineFeedsAndTabs as fr, loadYaml as ft, SubagentsProcessor as g, removeFileStrict as gn, ConfigResolver as gt, RulesProcessor as h, removeFile as hn, SKILL_FILE_NAME as ht, inspectInputRoots as i, isSymlink as in, RULESYNC_XDG_CONFIG_HOME_DEFAULT_DIR_NAME as ir, RulesyncHooks as it, AUGMENTCODE_DIR as j, ALL_FEATURES as jn, warnOnConflictingFlags as jt, CODEBUDDY_DIR as k, PACKAGING_TOOL_TARGETS as kn, WarningCollectingLogger as kt, displayWidthOf as l, pathEscapesRoot as ln, quoteForLog as lr, RulesyncCheck as lt, ChecksProcessor as m, removeDirectoryStrict as mn, SHARED_USER_MANAGED_CONFIG_PATHS as mt, formatSourceLoadFailure as n, isFileSystemError as nn, RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH as nr, RulesyncMcp as nt, getProcessorRegistryEntry as o, listFilePathsRecursively as on, formatError as or, resolveRulesyncSourceWritePath as ot, HooksProcessor as p, removeDirectory as pn, stripHiddenCharacters as pr, isRecord as pt, hasWindowsFoldableName as q, RULESYNC_MCP_RELATIVE_FILE_PATH as qn, createTempDirectory as qt, generate as r, isRootDirPath as rn, RULESYNC_USER_CONFIG_DIR_NAME as rr, RulesyncIgnore as rt, parseCommaSeparatedList as s, listSubdirectoryNames as sn, truncateText as sr, RulesyncCommand as st, importFromTool as t, isFileNotFoundError as tn, RULESYNC_SOURCES_LOCK_RELATIVE_FILE_PATH as tr, RulesyncPermissions as tt, shortenToWidth as u, posixRelativePathEscapesRoot as un, stripControlCharacters as ur, RulesyncCheckFrontmatterSchema as ut, CRUSH_LOCAL_RULE_FILE_NAME as v, removeTempDirectory as vn, parseConfigFileContent as vt, LETTACODE_SETTINGS_LOCAL_FILE_NAME as w, writeFileBuffer as wn, assertTargetsFeaturesExclusive as wt, QWENCODE_DIR as x, runWithDirectoryRollback as xn, ConfigFileSchema as xt, CommandsProcessor as y, resolvePath as yn, resolveEffectiveInputRoots as yt, CLAUDECODE_DIR as z, RULESYNC_COMMANDS_RELATIVE_DIR_PATH as zn, applyFileMode as zt };
105932
105975
 
105933
- //# sourceMappingURL=import-UXidZnLu.js.map
105976
+ //# sourceMappingURL=import-C7cimNlL.js.map