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.
@@ -80348,17 +80348,40 @@ function normalizeUrlPattern(pattern) {
80348
80348
  /**
80349
80349
  * A URL pattern with its scheme stripped and only its host lowercased, for
80350
80350
  * writing it into a tool that matches paths case-sensitively (Copilot in VS
80351
- * Code). A scheme spelled as a glob (a `*` scheme, `http*`, or a bare double
80352
- * slash after a `*`) is stripped too.
80351
+ * Code). A scheme spelled as a glob (a `*` scheme, `http*://`, or a bare double
80352
+ * slash after a `*` or at the start) is stripped too. A double slash after
80353
+ * anything else without a `:` is part of the path, so `evil.com//x` keeps its
80354
+ * host `evil.com`.
80353
80355
  */
80354
80356
  function stripUrlSchemeKeepingPathCase(pattern) {
80355
- const withoutScheme = pattern.replace(/^[a-z0-9+.*-]*:?\/\//i, "");
80357
+ return keepingPathCase(pattern.replace(/^(?:[a-z0-9+.*-]*:|\*)?\/\//i, ""));
80358
+ }
80359
+ /**
80360
+ * The reading `stripUrlSchemeKeepingPathCase` gave before it required a `:`,
80361
+ * which took any `<word>//` prefix for a scheme (`evil.com//x` became `x`).
80362
+ * Overlap checks compare this reading too, so requiring the `:` only ever
80363
+ * adds overlaps and never lets through an allow that was withheld before.
80364
+ */
80365
+ function stripUrlSchemeLoosely(pattern) {
80366
+ return keepingPathCase(pattern.replace(/^[a-z0-9+.*-]*:?\/\//i, ""));
80367
+ }
80368
+ /**
80369
+ * Whether a URL pattern has a `<word>//` prefix without a `:` (`evil.com//x`),
80370
+ * which an earlier reading took for a scheme. Such a pattern names a host
80371
+ * other than the one that reading gave, so a tool should not be handed a
80372
+ * rewritten form of it.
80373
+ */
80374
+ function hasDoubleSlashWithoutScheme(pattern) {
80375
+ return stripUrlSchemeKeepingPathCase(pattern) !== stripUrlSchemeLoosely(pattern);
80376
+ }
80377
+ /** A scheme-less URL pattern with only its host lowercased. */
80378
+ function keepingPathCase(withoutScheme) {
80356
80379
  const slash = withoutScheme.indexOf("/");
80357
80380
  return slash === -1 ? withoutScheme.toLowerCase() : `${withoutScheme.slice(0, slash).toLowerCase()}${withoutScheme.slice(slash)}`;
80358
80381
  }
80359
- /** Split a lowercased, scheme-less URL or domain pattern into host, port and path. */
80360
- function splitUrlPattern(pattern) {
80361
- const normalized = stripUrlSchemeKeepingPathCase(pattern).toLowerCase();
80382
+ /** Split a scheme-less URL or domain pattern into lowercased host, port and path. */
80383
+ function splitUrlPattern(withoutScheme) {
80384
+ const normalized = withoutScheme.toLowerCase();
80362
80385
  const slash = normalized.indexOf("/");
80363
80386
  const hostPort = slash === -1 ? normalized : normalized.slice(0, slash);
80364
80387
  const path = slash === -1 ? void 0 : normalized.slice(slash);
@@ -80381,8 +80404,10 @@ function splitUrlPattern(pattern) {
80381
80404
  * tools read as every URL on it, on any port, and on its subdomains, so a
80382
80405
  * missing path or port matches every path or port, and each host also stands
80383
80406
  * for `*.<host>`. Because a glob can also match across those parts, the
80384
- * whole strings are compared as well, and an overlap from either counts. A
80385
- * pattern holding whitespace names no URL.
80407
+ * whole strings are compared as well, a pathless `right` also as `<host>/*`
80408
+ * (so an allowed `example.com` overlaps a restricted `*.pdf`), and an overlap
80409
+ * from any of them counts. A pattern holding whitespace names no URL. Callers
80410
+ * pass the restriction as `left` and the allow as `right`.
80386
80411
  */
80387
80412
  function urlPatternsOverlap(left, right) {
80388
80413
  if (left === right) return true;
@@ -80393,17 +80418,35 @@ function urlPatternsOverlap(left, right) {
80393
80418
  * The whole-string comparison a `*` restriction also gets, since a glob there
80394
80419
  * matches the whole URL (`*.pdf` names `https://example.com/doc.pdf`): the two
80395
80420
  * patterns compared as written and lowercased without a scheme, each widened
80396
- * by `createShadowingRestrictionsTest`.
80421
+ * by `createShadowingRestrictionsTest`. A pathless allow (`right`) is a host
80422
+ * and stands for every path on it, so against a restriction without a `/`
80423
+ * (`*.pdf`, `*admin`) it is also compared as `<host>/*`. A restriction with a
80424
+ * `/` names its host and path itself and is compared part by part instead, and
80425
+ * a pathless restriction is not widened: `.env/*` would reach every allow that
80426
+ * starts with a `*` (`*.github.com`), and `*://evil.com/*` against
80427
+ * `good.com/*` would match through the `*`.
80397
80428
  */
80398
80429
  function wholeStringsOverlap(left, right) {
80399
- return [[left, right], [normalizeUrlPattern(left), normalizeUrlPattern(right)]].some(([restriction = "", allow = ""]) => createShadowingRestrictionsTest([{
80430
+ const normalizedLeft = normalizeUrlPattern(left);
80431
+ const normalizedRight = normalizeUrlPattern(right);
80432
+ return [
80433
+ [left, right],
80434
+ [normalizedLeft, normalizedRight],
80435
+ ...normalizedLeft.includes("/") ? [] : [[normalizedLeft, withAnyPath(normalizedRight)]]
80436
+ ].some(([restriction = "", allow = ""]) => createShadowingRestrictionsTest([{
80400
80437
  pattern: restriction,
80401
80438
  fromAllToolsCategory: false
80402
80439
  }])(allow).length > 0);
80403
80440
  }
80441
+ /** A scheme-less pattern with `/*` appended when it has no path. */
80442
+ function withAnyPath(withoutScheme) {
80443
+ return stripUrlSchemeKeepingPathCase(withoutScheme).includes("/") ? withoutScheme : `${withoutScheme}/*`;
80444
+ }
80404
80445
  function urlPartsOverlap(left, right) {
80405
- const a = splitUrlPattern(left);
80406
- const b = splitUrlPattern(right);
80446
+ const readings = (pattern) => [.../* @__PURE__ */ new Set([stripUrlSchemeKeepingPathCase(pattern), stripUrlSchemeLoosely(pattern)])].map(splitUrlPattern);
80447
+ return readings(left).some((a) => readings(right).some((b) => urlPartsPairOverlap(a, b)));
80448
+ }
80449
+ function urlPartsPairOverlap(a, b) {
80407
80450
  const hosts = (host) => [host, `*.${host}`];
80408
80451
  if (!hosts(a.host).some((x) => hosts(b.host).some((y) => globsIntersect(x, y)))) return false;
80409
80452
  if (a.port !== void 0 && b.port !== void 0 && !globsIntersect(a.port, b.port)) return false;
@@ -80749,7 +80792,7 @@ const MATCH_ALL_PATH_GLOBS = /* @__PURE__ */ new Set([
80749
80792
  "**/*"
80750
80793
  ]);
80751
80794
  const DIRECTORY_CONTENTS_SUFFIX = /\/\*\*(?:\/\*)?$/;
80752
- const HOME_OR_VARIABLE_PATH = /^~(?:[A-Za-z_][\w.-]*)?(?:[/\\]|$)|^\$[A-Za-z_]|^%[A-Za-z_]\w*%|\$\{[A-Za-z_]/;
80795
+ const HOME_OR_VARIABLE_PATH = /^~(?:[A-Za-z_][\w.-]*)?(?:[/\\]|$)|^\$[A-Za-z_]|^%[A-Za-z_][\w() ]*%|\$\{[A-Za-z_]/;
80753
80796
  const LEADING_HOME = /^~(?:\/|$)/;
80754
80797
  /**
80755
80798
  * The home directory as an Antigravity path: forward slashes, no trailing
@@ -80763,8 +80806,8 @@ function toAntigravityHomePath(homeDirectory) {
80763
80806
  * directory. agy 1.5.1 matches `~` literally, so a `~/...` rule would never
80764
80807
  * apply (rulesync#3324). Only a file the user's own home holds, such as the
80765
80808
  * global Antigravity CLI settings, may carry a machine-specific path, so the
80766
- * caller passes `homeDirectory` only then. `$HOME`, `${HOME}`, `%VAR%` and
80767
- * `~user/` are left as written and still warned about.
80809
+ * caller passes `homeDirectory` only then. `$HOME`, `${HOME}`, `%VAR%`, `~\`,
80810
+ * `~user` and `~user/` are left as written and still warned about.
80768
80811
  */
80769
80812
  function expandLeadingHome(target, homeDirectory) {
80770
80813
  if (homeDirectory === void 0 || !LEADING_HOME.test(target)) return target;
@@ -88178,7 +88221,7 @@ function honorCopilotAllToolsRestrictions({ permission, category, logger }) {
88178
88221
  key: "*"
88179
88222
  }) ?? {};
88180
88223
  const isWritable = restatesAsCategoryRule();
88181
- const restateAs = (params) => params.pattern === "*" || isWritable(params);
88224
+ const restateAs = (params) => params.pattern === "*" || isWritable(params) && !(params.category === "webfetch" && hasDoubleSlashWithoutScheme(params.pattern));
88182
88225
  const writable = {};
88183
88226
  const notWritable = {};
88184
88227
  for (const [pattern, action] of Object.entries(allToolsRules)) {
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_import = require("./import-B111LEQv.cjs");
2
+ const require_import = require("./import-vL-bR_Ax.cjs");
3
3
  // src/index.ts
4
4
  async function generate(options = {}) {
5
5
  const { silent = true, verbose = false, ...rest } = options;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Dn as ALL_TOOL_TARGETS, Dt as ConsoleLogger, a as convertFromTool$1, gt as ConfigResolver, i as inspectInputRoots, jn as ALL_FEATURES, r as generate$1, t as importFromTool$1 } from "./import-UXidZnLu.js";
1
+ import { Dn as ALL_TOOL_TARGETS, Dt as ConsoleLogger, a as convertFromTool$1, gt as ConfigResolver, i as inspectInputRoots, jn as ALL_FEATURES, r as generate$1, t as importFromTool$1 } from "./import-C7cimNlL.js";
2
2
  // src/index.ts
3
3
  async function generate(options = {}) {
4
4
  const { silent = true, verbose = false, ...rest } = options;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rulesync",
3
- "version": "43.8.1",
3
+ "version": "43.8.2",
4
4
  "description": "Unified AI rules management CLI tool that generates configuration files for various AI development tools",
5
5
  "keywords": [
6
6
  "ai",