rulesync 43.8.0 → 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.
- package/dist/cli/index.cjs +3 -3
- package/dist/cli/index.js +3 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/{import-Cu5o6uKO.js → import-C7cimNlL.js} +928 -65
- package/dist/{import-Cu5o6uKO.js.map → import-C7cimNlL.js.map} +1 -1
- package/dist/{import-C5ETusOs.cjs → import-vL-bR_Ax.cjs} +927 -64
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -79458,6 +79458,30 @@ function maxRangeCount(steps) {
|
|
|
79458
79458
|
return most;
|
|
79459
79459
|
}
|
|
79460
79460
|
/**
|
|
79461
|
+
* Whether any one value matches both globs — that is, whether the two patterns
|
|
79462
|
+
* overlap at all. The answer is exact up to `MAX_INTERSECTION_CELLS`; a pair
|
|
79463
|
+
* longer than that is reported as overlapping without being compared, so a
|
|
79464
|
+
* caller that reads a `true` as a reason to restrict stays on the safe side and
|
|
79465
|
+
* one that would read it as a reason to permit must not use this. What a pair
|
|
79466
|
+
* costs counts the ranges a `[a-z]` class carries, not only the two lengths.
|
|
79467
|
+
*
|
|
79468
|
+
* This answers the question an adapter really has when it holds a restriction
|
|
79469
|
+
* and an `allow`: is there a command both of them name? Asking instead whether
|
|
79470
|
+
* either pattern covers the other's *text* misses the ordinary crossing pair —
|
|
79471
|
+
* `* --force` and `git *` cover none of each other's spellings, yet they share
|
|
79472
|
+
* every `git … --force` command.
|
|
79473
|
+
*
|
|
79474
|
+
* The two step lists are walked as a table rather than by backtracking, so no
|
|
79475
|
+
* input makes the time blow up the way a translated regex would. Only two rows
|
|
79476
|
+
* of that table are ever held, and the shorter pattern is the one that sizes
|
|
79477
|
+
* them, so the memory is linear in the shorter pattern however long the other
|
|
79478
|
+
* one is. Where a `[...]` class meets another `[...]` class the answer is
|
|
79479
|
+
* assumed to be yes, which over-reports rather than misses.
|
|
79480
|
+
*/
|
|
79481
|
+
function globsIntersect(left, right) {
|
|
79482
|
+
return parsedGlobsIntersect(parseGlobPattern(left), parseGlobPattern(right));
|
|
79483
|
+
}
|
|
79484
|
+
/**
|
|
79461
79485
|
* `globsIntersect` for two globs already parsed, optionally spending a budget
|
|
79462
79486
|
* shared with the rest of the caller's run — see `createIntersectionBudget`.
|
|
79463
79487
|
* Once that budget is exhausted every further pair answers `true` without being
|
|
@@ -80085,6 +80109,11 @@ function collectShellCommandRules(permission) {
|
|
|
80085
80109
|
function widenToPrefixGlob$1(pattern) {
|
|
80086
80110
|
return pattern.endsWith("*") ? pattern : `${pattern}*`;
|
|
80087
80111
|
}
|
|
80112
|
+
function widenForOverlap(pattern) {
|
|
80113
|
+
if (/\{[^}]*,[^}]*\}/.test(pattern)) return "*";
|
|
80114
|
+
const widened = pattern.replaceAll("**/", "*").replaceAll("/**", "*");
|
|
80115
|
+
return widened.endsWith(" *") ? `${widened.slice(0, -2)}*` : widened;
|
|
80116
|
+
}
|
|
80088
80117
|
/**
|
|
80089
80118
|
* Build the test an adapter applies to an `allow` pattern before writing it:
|
|
80090
80119
|
* which restrictions it cannot write name some of the same commands? The
|
|
@@ -80116,11 +80145,11 @@ function widenToPrefixGlob$1(pattern) {
|
|
|
80116
80145
|
function createShadowingRestrictionsTest(restrictions, { normalizePattern = (pattern) => pattern, budget = createIntersectionBudget() } = {}) {
|
|
80117
80146
|
const normalized = restrictions.map(({ pattern, fromAllToolsCategory }) => ({
|
|
80118
80147
|
pattern,
|
|
80119
|
-
glob: parseGlobPattern(fromAllToolsCategory ? pattern : normalizePattern(pattern))
|
|
80148
|
+
glob: parseGlobPattern(widenForOverlap(fromAllToolsCategory ? pattern : normalizePattern(pattern)))
|
|
80120
80149
|
}));
|
|
80121
80150
|
return (allowPattern) => {
|
|
80122
80151
|
if (budget.remaining === 0) return normalized.map(({ pattern }) => pattern);
|
|
80123
|
-
const allowGlob = parseGlobPattern(normalizePattern(allowPattern));
|
|
80152
|
+
const allowGlob = parseGlobPattern(widenForOverlap(normalizePattern(allowPattern)));
|
|
80124
80153
|
return normalized.filter(({ pattern, glob }) => pattern === allowPattern || parsedGlobsIntersect(glob, allowGlob, budget)).map(({ pattern }) => pattern);
|
|
80125
80154
|
};
|
|
80126
80155
|
}
|
|
@@ -80283,6 +80312,379 @@ function honorAllToolsOnBash(permission) {
|
|
|
80283
80312
|
bash: bashRulesHonoringAllTools(permission)
|
|
80284
80313
|
};
|
|
80285
80314
|
}
|
|
80315
|
+
// src/features/permissions/shadowed-allows.ts
|
|
80316
|
+
/** The canonical category whose patterns are URLs or domains. */
|
|
80317
|
+
const WEBFETCH_CATEGORY$2 = "webfetch";
|
|
80318
|
+
/**
|
|
80319
|
+
* A URL or domain pattern lowercased and without its scheme, so `HTTPS://Evil.example/*`
|
|
80320
|
+
* and `evil.example/*` are compared as the same host. Hosts are case-insensitive
|
|
80321
|
+
* and a scheme-less allow covers every scheme.
|
|
80322
|
+
*/
|
|
80323
|
+
function normalizeUrlPattern(pattern) {
|
|
80324
|
+
return pattern.toLowerCase().replace(/^[a-z][a-z0-9+.-]*:\/\//, "");
|
|
80325
|
+
}
|
|
80326
|
+
/**
|
|
80327
|
+
* A URL pattern with its scheme stripped and only its host lowercased, for
|
|
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 `*` 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`.
|
|
80333
|
+
*/
|
|
80334
|
+
function stripUrlSchemeKeepingPathCase(pattern) {
|
|
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) {
|
|
80357
|
+
const slash = withoutScheme.indexOf("/");
|
|
80358
|
+
return slash === -1 ? withoutScheme.toLowerCase() : `${withoutScheme.slice(0, slash).toLowerCase()}${withoutScheme.slice(slash)}`;
|
|
80359
|
+
}
|
|
80360
|
+
/** Split a scheme-less URL or domain pattern into lowercased host, port and path. */
|
|
80361
|
+
function splitUrlPattern(withoutScheme) {
|
|
80362
|
+
const normalized = withoutScheme.toLowerCase();
|
|
80363
|
+
const slash = normalized.indexOf("/");
|
|
80364
|
+
const hostPort = slash === -1 ? normalized : normalized.slice(0, slash);
|
|
80365
|
+
const path = slash === -1 ? void 0 : normalized.slice(slash);
|
|
80366
|
+
const port = /:([0-9*]+)$/.exec(hostPort);
|
|
80367
|
+
return port === null ? {
|
|
80368
|
+
host: hostPort,
|
|
80369
|
+
port: void 0,
|
|
80370
|
+
path
|
|
80371
|
+
} : {
|
|
80372
|
+
host: hostPort.slice(0, port.index),
|
|
80373
|
+
port: port[1],
|
|
80374
|
+
path
|
|
80375
|
+
};
|
|
80376
|
+
}
|
|
80377
|
+
/**
|
|
80378
|
+
* Whether two URL or domain patterns can name one URL. Both are compared
|
|
80379
|
+
* lowercased and without their scheme, part by part, so a `*` in one part
|
|
80380
|
+
* never reaches into another (`*.github.com` does not overlap
|
|
80381
|
+
* `example.org/private/*`). A pathless pattern is a host, which domain-only
|
|
80382
|
+
* tools read as every URL on it, on any port, and on its subdomains, so a
|
|
80383
|
+
* missing path or port matches every path or port, and each host also stands
|
|
80384
|
+
* for `*.<host>`. Because a glob can also match across those parts, the
|
|
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`.
|
|
80389
|
+
*/
|
|
80390
|
+
function urlPatternsOverlap(left, right) {
|
|
80391
|
+
if (left === right) return true;
|
|
80392
|
+
if (/\s/.test(left) || /\s/.test(right)) return false;
|
|
80393
|
+
return urlPartsOverlap(left, right) || wholeStringsOverlap(left, right);
|
|
80394
|
+
}
|
|
80395
|
+
/**
|
|
80396
|
+
* The whole-string comparison a `*` restriction also gets, since a glob there
|
|
80397
|
+
* matches the whole URL (`*.pdf` names `https://example.com/doc.pdf`): the two
|
|
80398
|
+
* patterns compared as written and lowercased without a scheme, each widened
|
|
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 `*`.
|
|
80406
|
+
*/
|
|
80407
|
+
function wholeStringsOverlap(left, right) {
|
|
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([{
|
|
80415
|
+
pattern: restriction,
|
|
80416
|
+
fromAllToolsCategory: false
|
|
80417
|
+
}])(allow).length > 0);
|
|
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
|
+
}
|
|
80423
|
+
function urlPartsOverlap(left, 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) {
|
|
80428
|
+
const hosts = (host) => [host, `*.${host}`];
|
|
80429
|
+
if (!hosts(a.host).some((x) => hosts(b.host).some((y) => globsIntersect(x, y)))) return false;
|
|
80430
|
+
if (a.port !== void 0 && b.port !== void 0 && !globsIntersect(a.port, b.port)) return false;
|
|
80431
|
+
return a.path === void 0 || b.path === void 0 || globsIntersect(a.path, b.path);
|
|
80432
|
+
}
|
|
80433
|
+
/**
|
|
80434
|
+
* Whether any of `restrictions` overlaps an allow pattern of `category`. For
|
|
80435
|
+
* `webfetch` the patterns are compared as URLs (see `urlPatternsOverlap`).
|
|
80436
|
+
*/
|
|
80437
|
+
function createCategoryShadowTest({ restrictions, category }) {
|
|
80438
|
+
if (category === WEBFETCH_CATEGORY$2) return (allowPattern) => restrictions.some(({ pattern }) => urlPatternsOverlap(pattern, allowPattern));
|
|
80439
|
+
const asWritten = createShadowingRestrictionsTest(restrictions);
|
|
80440
|
+
return (allowPattern) => asWritten(allowPattern).length > 0;
|
|
80441
|
+
}
|
|
80442
|
+
/** One allow rule left out of a tool's config, named as `<category>: <pattern>`. */
|
|
80443
|
+
function describeRule(category, pattern) {
|
|
80444
|
+
return `${category}: ${pattern}`;
|
|
80445
|
+
}
|
|
80446
|
+
/**
|
|
80447
|
+
* The `*` category with only its catch-all entries left, warning about the
|
|
80448
|
+
* pattern-specific ones dropped.
|
|
80449
|
+
*/
|
|
80450
|
+
function keepAllToolsCatchAll({ rules, isCatchAll, toolLabel, logger }) {
|
|
80451
|
+
const kept = {};
|
|
80452
|
+
const dropped = [];
|
|
80453
|
+
for (const [pattern, action] of Object.entries(rules)) if (isCatchAll(pattern)) kept[pattern] = action;
|
|
80454
|
+
else dropped.push(`${pattern} (${action})`);
|
|
80455
|
+
if (dropped.length > 0) warnWithFallback(logger, `${toolLabel} has no rule that scopes a pattern to every tool, so the all-tools '*' rule(s) for ${dropped.join(", ")} were not written as such; a deny or ask among them is honored by withholding the allow rules it covers in the other categories.`);
|
|
80456
|
+
return kept;
|
|
80457
|
+
}
|
|
80458
|
+
/**
|
|
80459
|
+
* Apply the all-tools `*` category's restrictions to every other category, for
|
|
80460
|
+
* a tool that cannot write a pattern-specific rule spanning every tool.
|
|
80461
|
+
*
|
|
80462
|
+
* A `deny` or `ask` written under `*` covers every tool — `{"*": {".env":
|
|
80463
|
+
* "deny"}}` denies reading `.env` as surely as `{"read": {".env": "deny"}}`
|
|
80464
|
+
* does. A tool with no such rule would otherwise keep a `read: {"*": "allow"}`
|
|
80465
|
+
* beside it and auto-approve the very file the author denied. So:
|
|
80466
|
+
*
|
|
80467
|
+
* - `bash` gets the restrictions copied in, exactly as `honorAllToolsOnBash`
|
|
80468
|
+
* does, since a command list can carry them.
|
|
80469
|
+
* - Every other category loses each `allow` that names an input a `*`
|
|
80470
|
+
* restriction also names (see `createShadowingRestrictionsTest`); the tool
|
|
80471
|
+
* then falls back to its own prompt or default for it, the safe direction.
|
|
80472
|
+
* (AugmentCode instead applies its blanket all-tools fallback to a tool left
|
|
80473
|
+
* with no entries, since its own default would auto-run the tool.) Width
|
|
80474
|
+
* does not matter: a shell-only `{"*": {"git push *": "ask"}}` withholds a
|
|
80475
|
+
* `read: {"*": "allow"}` too, because the catch-all names every input.
|
|
80476
|
+
* - With `dropAllToolsPatterns`, the pattern-specific entries of `*` itself are
|
|
80477
|
+
* removed, for a tool that would otherwise write them as an inert literal
|
|
80478
|
+
* `*(<pattern>)` rule. They are honored by the withholding above.
|
|
80479
|
+
*
|
|
80480
|
+
* `restateAs` says which pattern-specific `*` restrictions the tool can write
|
|
80481
|
+
* as a rule of the category itself (`Read(.env)`), for a tool whose default for
|
|
80482
|
+
* an input with no rule would auto-approve it: such a restriction is copied
|
|
80483
|
+
* into each stated category it applies to (see `restatesAsCategoryRule`), so
|
|
80484
|
+
* the input stays restricted after its allow is withheld.
|
|
80485
|
+
* `downgradeWithheldCatchAll` writes a withheld catch-all `*` allow as `ask`
|
|
80486
|
+
* (`deny` under a catch-all `*` deny) rather than dropping it, for a tool that keeps a stale `always` otherwise.
|
|
80487
|
+
*
|
|
80488
|
+
* `writesAllToolsCatchAll` says the tool already enforces a `*` catch-all
|
|
80489
|
+
* (`{"*": {"*": "ask"}}`) natively over its per-tool allows, so the catch-all
|
|
80490
|
+
* is left out of the withholding. `isCatchAll` says which spellings the tool
|
|
80491
|
+
* reads as that catch-all (by default only `*`).
|
|
80492
|
+
*
|
|
80493
|
+
* Every withheld allow is named in one warning.
|
|
80494
|
+
*/
|
|
80495
|
+
function honorAllToolsRestrictions({ permission, toolLabel, logger, writesAllToolsCatchAll = false, dropAllToolsPatterns = false, isCatchAll = (pattern) => pattern === "*", restateAs = () => false, downgradeWithheldCatchAll = false }) {
|
|
80496
|
+
const allToolsRules = Object.hasOwn(permission, "*") ? permission["*"] : void 0;
|
|
80497
|
+
if (allToolsRules === void 0) return permission;
|
|
80498
|
+
const restrictions = Object.entries(allToolsRules).filter(([pattern, action]) => action !== "allow" && !isPrototypePollutionKey(pattern) && !(writesAllToolsCatchAll && isCatchAll(pattern))).map(([pattern]) => ({
|
|
80499
|
+
pattern,
|
|
80500
|
+
fromAllToolsCategory: true
|
|
80501
|
+
}));
|
|
80502
|
+
const result = {};
|
|
80503
|
+
const withheld = [];
|
|
80504
|
+
for (const [category, rules] of Object.entries(permission)) {
|
|
80505
|
+
if (category === "*") {
|
|
80506
|
+
const kept = dropAllToolsPatterns ? keepAllToolsCatchAll({
|
|
80507
|
+
rules,
|
|
80508
|
+
isCatchAll,
|
|
80509
|
+
toolLabel,
|
|
80510
|
+
logger
|
|
80511
|
+
}) : rules;
|
|
80512
|
+
if (!dropAllToolsPatterns || Object.keys(kept).length > 0) result[category] = kept;
|
|
80513
|
+
continue;
|
|
80514
|
+
}
|
|
80515
|
+
if (restrictions.length === 0) {
|
|
80516
|
+
result[category] = rules;
|
|
80517
|
+
continue;
|
|
80518
|
+
}
|
|
80519
|
+
if (category === "bash") {
|
|
80520
|
+
const bash = bashRulesHonoringAllTools({
|
|
80521
|
+
...permission,
|
|
80522
|
+
["*"]: Object.fromEntries(restrictions.map(({ pattern }) => [pattern, allToolsRules[pattern] ?? "deny"]))
|
|
80523
|
+
});
|
|
80524
|
+
for (const [pattern, action] of Object.entries(rules)) if (action === "allow" && bash[pattern] !== "allow") withheld.push(describeRule(category, pattern));
|
|
80525
|
+
result[category] = bash;
|
|
80526
|
+
continue;
|
|
80527
|
+
}
|
|
80528
|
+
result[category] = honorInCategory({
|
|
80529
|
+
category,
|
|
80530
|
+
rules,
|
|
80531
|
+
restrictions: restrictions.map(({ pattern }) => ({
|
|
80532
|
+
pattern,
|
|
80533
|
+
action: allToolsRules[pattern] ?? "deny"
|
|
80534
|
+
})),
|
|
80535
|
+
restateAs,
|
|
80536
|
+
downgradeWithheldCatchAll,
|
|
80537
|
+
withheld
|
|
80538
|
+
});
|
|
80539
|
+
}
|
|
80540
|
+
if (withheld.length > 0) warnWithFallback(logger, `${toolLabel} was not given the allow rule(s) for ${withheld.join(", ")} because a deny or ask rule under the all-tools '*' category restricts the same inputs, and the stricter rule wins whatever its width.`);
|
|
80541
|
+
return result;
|
|
80542
|
+
}
|
|
80543
|
+
/** File categories whose patterns are paths. */
|
|
80544
|
+
const PATH_CATEGORIES = /* @__PURE__ */ new Set([
|
|
80545
|
+
"read",
|
|
80546
|
+
"edit",
|
|
80547
|
+
"write"
|
|
80548
|
+
]);
|
|
80549
|
+
/**
|
|
80550
|
+
* The common `restateAs`: a restriction is restated under a path category when
|
|
80551
|
+
* it reads as a path (no whitespace, so not a command such as `git push *`),
|
|
80552
|
+
* and under `webfetch` when it reads as a URL or domain. `actions` limits it to
|
|
80553
|
+
* the actions the tool can write per pattern.
|
|
80554
|
+
*/
|
|
80555
|
+
function restatesAsCategoryRule(actions = ["deny", "ask"]) {
|
|
80556
|
+
return ({ category, pattern, action }) => {
|
|
80557
|
+
if (!actions.includes(action) || pattern === "*") return false;
|
|
80558
|
+
if (PATH_CATEGORIES.has(category)) return !/\s/.test(pattern);
|
|
80559
|
+
if (category === WEBFETCH_CATEGORY$2) return /^([a-z][a-z0-9+.-]*:\/\/)?[\w*-]+(\.[\w*-]+)+(:[\w*]+)?(\/\S*)?$/i.test(pattern);
|
|
80560
|
+
return false;
|
|
80561
|
+
};
|
|
80562
|
+
}
|
|
80563
|
+
/** One non-shell category with the `*` restrictions honored; see the caller. */
|
|
80564
|
+
function honorInCategory({ category, rules, restrictions, restateAs, downgradeWithheldCatchAll, withheld }) {
|
|
80565
|
+
const shadowingRestrictions = createCategoryShadowTest({
|
|
80566
|
+
restrictions: restrictions.map(({ pattern }) => ({
|
|
80567
|
+
pattern,
|
|
80568
|
+
fromAllToolsCategory: true
|
|
80569
|
+
})),
|
|
80570
|
+
category
|
|
80571
|
+
});
|
|
80572
|
+
const downgradedAction = restrictions.some(({ pattern, action }) => pattern === "*" && action === "deny") ? "deny" : "ask";
|
|
80573
|
+
const kept = {};
|
|
80574
|
+
for (const [pattern, action] of Object.entries(rules)) {
|
|
80575
|
+
if (action === "allow" && shadowingRestrictions(pattern)) {
|
|
80576
|
+
withheld.push(describeRule(category, pattern));
|
|
80577
|
+
if (downgradeWithheldCatchAll && pattern === "*") kept[pattern] = downgradedAction;
|
|
80578
|
+
continue;
|
|
80579
|
+
}
|
|
80580
|
+
kept[pattern] = action;
|
|
80581
|
+
}
|
|
80582
|
+
return restateInCategory({
|
|
80583
|
+
category,
|
|
80584
|
+
rules: kept,
|
|
80585
|
+
restrictions,
|
|
80586
|
+
restateAs
|
|
80587
|
+
});
|
|
80588
|
+
}
|
|
80589
|
+
function restateInCategory({ category, rules, restrictions, restateAs }) {
|
|
80590
|
+
const restated = { ...rules };
|
|
80591
|
+
for (const { pattern, action } of restrictions) {
|
|
80592
|
+
if (isPrototypePollutionKey(pattern) || !restateAs({
|
|
80593
|
+
category,
|
|
80594
|
+
pattern,
|
|
80595
|
+
action
|
|
80596
|
+
})) continue;
|
|
80597
|
+
if (isStricterAction({
|
|
80598
|
+
action,
|
|
80599
|
+
existing: Object.hasOwn(restated, pattern) ? restated[pattern] : void 0
|
|
80600
|
+
})) restated[pattern] = action;
|
|
80601
|
+
}
|
|
80602
|
+
return restated;
|
|
80603
|
+
}
|
|
80604
|
+
/**
|
|
80605
|
+
* One category's rules with the pattern-specific `*` restrictions `restateAs`
|
|
80606
|
+
* accepts copied in as its own rules (the stricter action wins on a shared
|
|
80607
|
+
* spelling), for a tool that can write them there and needs no allow
|
|
80608
|
+
* withheld, because its own ordering already lets the copied rule win.
|
|
80609
|
+
*/
|
|
80610
|
+
function restateAllToolsRestrictionsInCategory({ permission, category, restateAs }) {
|
|
80611
|
+
const rules = lookupOwn({
|
|
80612
|
+
record: permission,
|
|
80613
|
+
key: category
|
|
80614
|
+
}) ?? {};
|
|
80615
|
+
const allToolsRules = lookupOwn({
|
|
80616
|
+
record: permission,
|
|
80617
|
+
key: "*"
|
|
80618
|
+
}) ?? {};
|
|
80619
|
+
return restateInCategory({
|
|
80620
|
+
category,
|
|
80621
|
+
rules,
|
|
80622
|
+
restrictions: Object.entries(allToolsRules).filter(([, action]) => action !== "allow").map(([pattern, action]) => ({
|
|
80623
|
+
pattern,
|
|
80624
|
+
action
|
|
80625
|
+
})),
|
|
80626
|
+
restateAs
|
|
80627
|
+
});
|
|
80628
|
+
}
|
|
80629
|
+
/**
|
|
80630
|
+
* Withhold every `allow` that an `ask` the tool cannot write also covers, for a
|
|
80631
|
+
* tool with no ask tier on some surface.
|
|
80632
|
+
*
|
|
80633
|
+
* Such a tool prompts for whatever it does not auto-approve, so skipping the
|
|
80634
|
+
* `ask` alone is right — but only if no `allow` beside it auto-approves the
|
|
80635
|
+
* same input. The canonical order is `deny > ask > allow`, so `{"git *":
|
|
80636
|
+
* "allow", "git push *": "ask"}` must not leave `git *` auto-approved.
|
|
80637
|
+
*
|
|
80638
|
+
* Within each group (categories the tool folds into one surface share a group;
|
|
80639
|
+
* by default each category is its own), a pattern-specific `allow` an `ask`
|
|
80640
|
+
* overlaps is removed. A catch-all `*` `allow` is downgraded to `ask` instead,
|
|
80641
|
+
* so a tool that has a coarse prompting default for the whole surface (Vibe's
|
|
80642
|
+
* `permission = "ask"`) uses it; a tool that skips `ask` drops it either way.
|
|
80643
|
+
*
|
|
80644
|
+
* `isSkippedAsk` picks the `ask` rules the tool cannot write (by default every
|
|
80645
|
+
* one). Every withheld allow is named in one warning.
|
|
80646
|
+
*/
|
|
80647
|
+
function withholdAllowsShadowedByAsks({ permission, toolLabel, logger, isSkippedAsk = () => true, groupOf = (category) => category }) {
|
|
80648
|
+
const asksByGroup = /* @__PURE__ */ new Map();
|
|
80649
|
+
for (const [category, rules] of Object.entries(permission)) for (const [pattern, action] of Object.entries(rules)) {
|
|
80650
|
+
if (action !== "ask" || isPrototypePollutionKey(pattern)) continue;
|
|
80651
|
+
if (!isSkippedAsk({
|
|
80652
|
+
category,
|
|
80653
|
+
pattern
|
|
80654
|
+
})) continue;
|
|
80655
|
+
const group = groupOf(category);
|
|
80656
|
+
asksByGroup.set(group, [...asksByGroup.get(group) ?? [], pattern]);
|
|
80657
|
+
}
|
|
80658
|
+
if (asksByGroup.size === 0) return permission;
|
|
80659
|
+
const result = {};
|
|
80660
|
+
const withheld = [];
|
|
80661
|
+
for (const [category, rules] of Object.entries(permission)) {
|
|
80662
|
+
const asks = asksByGroup.get(groupOf(category));
|
|
80663
|
+
if (asks === void 0) {
|
|
80664
|
+
result[category] = rules;
|
|
80665
|
+
continue;
|
|
80666
|
+
}
|
|
80667
|
+
const shadowingAsks = createCategoryShadowTest({
|
|
80668
|
+
restrictions: asks.map((pattern) => ({
|
|
80669
|
+
pattern,
|
|
80670
|
+
fromAllToolsCategory: false
|
|
80671
|
+
})),
|
|
80672
|
+
category
|
|
80673
|
+
});
|
|
80674
|
+
const kept = {};
|
|
80675
|
+
for (const [pattern, action] of Object.entries(rules)) {
|
|
80676
|
+
if (action !== "allow" || !shadowingAsks(pattern)) {
|
|
80677
|
+
kept[pattern] = action;
|
|
80678
|
+
continue;
|
|
80679
|
+
}
|
|
80680
|
+
withheld.push(describeRule(category, pattern));
|
|
80681
|
+
if (pattern === "*") kept[pattern] = "ask";
|
|
80682
|
+
}
|
|
80683
|
+
result[category] = kept;
|
|
80684
|
+
}
|
|
80685
|
+
if (withheld.length > 0) warnWithFallback(logger, `${toolLabel} has no "ask" tier there, so the allow rule(s) for ${withheld.join(", ")} were withheld (a catch-all '*' allow falls back to the tool's prompt): an ask rule covers the same inputs, and an allow kept beside it would auto-approve what the ask should prompt for.`);
|
|
80686
|
+
return result;
|
|
80687
|
+
}
|
|
80286
80688
|
// src/features/permissions/tool-pattern-entry.ts
|
|
80287
80689
|
/**
|
|
80288
80690
|
* Parse a `Tool(pattern)` permission entry (e.g. `Bash(npm run *)`) into its
|
|
@@ -80368,7 +80770,7 @@ const MATCH_ALL_PATH_GLOBS = /* @__PURE__ */ new Set([
|
|
|
80368
80770
|
"**/*"
|
|
80369
80771
|
]);
|
|
80370
80772
|
const DIRECTORY_CONTENTS_SUFFIX = /\/\*\*(?:\/\*)?$/;
|
|
80371
|
-
const HOME_OR_VARIABLE_PATH = /^~(
|
|
80773
|
+
const HOME_OR_VARIABLE_PATH = /^~(?:[A-Za-z_][\w.-]*)?(?:[/\\]|$)|^\$[A-Za-z_]|^%[A-Za-z_][\w() ]*%|\$\{[A-Za-z_]/;
|
|
80372
80774
|
const LEADING_HOME = /^~(?:\/|$)/;
|
|
80373
80775
|
/**
|
|
80374
80776
|
* The home directory as an Antigravity path: forward slashes, no trailing
|
|
@@ -80382,8 +80784,8 @@ function toAntigravityHomePath(homeDirectory) {
|
|
|
80382
80784
|
* directory. agy 1.5.1 matches `~` literally, so a `~/...` rule would never
|
|
80383
80785
|
* apply (rulesync#3324). Only a file the user's own home holds, such as the
|
|
80384
80786
|
* global Antigravity CLI settings, may carry a machine-specific path, so the
|
|
80385
|
-
* caller passes `homeDirectory` only then. `$HOME`, `${HOME}`, `%VAR
|
|
80386
|
-
* `~user/` are left as written
|
|
80787
|
+
* caller passes `homeDirectory` only then. `$HOME`, `${HOME}`, `%VAR%`, `~\`,
|
|
80788
|
+
* `~user` and `~user/` are left as written and still warned about.
|
|
80387
80789
|
*/
|
|
80388
80790
|
function expandLeadingHome(target, homeDirectory) {
|
|
80389
80791
|
if (homeDirectory === void 0 || !LEADING_HOME.test(target)) return target;
|
|
@@ -80625,30 +81027,84 @@ function convertRulesyncToAntigravityPermissions({ config, toAction, toolLabel,
|
|
|
80625
81027
|
const allow = [];
|
|
80626
81028
|
const ask = [];
|
|
80627
81029
|
const deny = [];
|
|
80628
|
-
|
|
81030
|
+
const permission = honorAllToolsRestrictions({
|
|
81031
|
+
permission: config.permission,
|
|
81032
|
+
toolLabel,
|
|
81033
|
+
logger
|
|
81034
|
+
});
|
|
81035
|
+
const translated = [];
|
|
81036
|
+
for (const [category, rules] of Object.entries(permission)) {
|
|
80629
81037
|
const action = toAction(category);
|
|
80630
|
-
for (const [pattern,
|
|
81038
|
+
for (const [pattern, decision] of Object.entries(rules)) {
|
|
80631
81039
|
const entry = buildAntigravityPermissionEntry({
|
|
80632
81040
|
action,
|
|
80633
81041
|
category,
|
|
80634
81042
|
pattern,
|
|
80635
|
-
decision
|
|
81043
|
+
decision,
|
|
80636
81044
|
logger,
|
|
80637
81045
|
toolLabel,
|
|
80638
81046
|
homeDirectory
|
|
80639
81047
|
});
|
|
80640
|
-
|
|
80641
|
-
|
|
80642
|
-
|
|
80643
|
-
|
|
80644
|
-
|
|
80645
|
-
|
|
80646
|
-
|
|
81048
|
+
translated.push({
|
|
81049
|
+
action,
|
|
81050
|
+
category,
|
|
81051
|
+
pattern,
|
|
81052
|
+
decision,
|
|
81053
|
+
entry
|
|
81054
|
+
});
|
|
81055
|
+
}
|
|
81056
|
+
}
|
|
81057
|
+
const skippedRestrictionsByAction = /* @__PURE__ */ new Map();
|
|
81058
|
+
const groupOf = ({ action, category }) => category.startsWith("mcp__") ? category : action;
|
|
81059
|
+
for (const { action, category, pattern, decision, entry } of translated) if (entry === void 0 && decision !== "allow") {
|
|
81060
|
+
const group = groupOf({
|
|
81061
|
+
action,
|
|
81062
|
+
category
|
|
81063
|
+
});
|
|
81064
|
+
skippedRestrictionsByAction.set(group, [...skippedRestrictionsByAction.get(group) ?? [], pattern]);
|
|
81065
|
+
}
|
|
81066
|
+
const allToolsRestrictions = Object.entries(lookupOwn({
|
|
81067
|
+
record: config.permission,
|
|
81068
|
+
key: "*"
|
|
81069
|
+
}) ?? {}).filter(([pattern, decision]) => decision !== "allow" && pattern !== "*" && !isPrototypePollutionKey(pattern)).map(([pattern]) => pattern);
|
|
81070
|
+
const shadowingTests = /* @__PURE__ */ new Map();
|
|
81071
|
+
const shadowingTestOf = (group) => {
|
|
81072
|
+
const cached = shadowingTests.get(group);
|
|
81073
|
+
if (cached !== void 0) return cached;
|
|
81074
|
+
const patterns = [...skippedRestrictionsByAction.get(group) ?? [], ...allToolsRestrictions];
|
|
81075
|
+
let test;
|
|
81076
|
+
if (URL_ACTIONS.has(group)) test = (allowPattern) => patterns.some((pattern) => urlPatternsOverlap(pattern, allowPattern));
|
|
81077
|
+
else {
|
|
81078
|
+
const asGlobs = createShadowingRestrictionsTest([.../* @__PURE__ */ new Set([...patterns, ...patterns.map(normalizeUrlPattern)])].map((pattern) => ({
|
|
81079
|
+
pattern,
|
|
81080
|
+
fromAllToolsCategory: false
|
|
81081
|
+
})));
|
|
81082
|
+
test = (allowPattern) => asGlobs(allowPattern).length > 0 || asGlobs(normalizeUrlPattern(allowPattern)).length > 0;
|
|
81083
|
+
}
|
|
81084
|
+
shadowingTests.set(group, test);
|
|
81085
|
+
return test;
|
|
81086
|
+
};
|
|
81087
|
+
const withheld = [];
|
|
81088
|
+
for (const { action, category, pattern, decision, entry } of translated) {
|
|
81089
|
+
if (entry === void 0) continue;
|
|
81090
|
+
switch (decision) {
|
|
81091
|
+
case "allow":
|
|
81092
|
+
if ([pattern, effectiveTargetScope(entry)].some((candidate) => shadowingTestOf(groupOf({
|
|
81093
|
+
action,
|
|
81094
|
+
category
|
|
81095
|
+
}))(candidate))) {
|
|
81096
|
+
withheld.push(`${category}: ${pattern}`);
|
|
80647
81097
|
break;
|
|
80648
|
-
|
|
80649
|
-
|
|
81098
|
+
}
|
|
81099
|
+
allow.push(entry);
|
|
81100
|
+
break;
|
|
81101
|
+
case "ask":
|
|
81102
|
+
ask.push(entry);
|
|
81103
|
+
break;
|
|
81104
|
+
case "deny": deny.push(entry);
|
|
80650
81105
|
}
|
|
80651
81106
|
}
|
|
81107
|
+
if (withheld.length > 0) logger.warn(`${toolLabel} permissions: the allow rule(s) for ${withheld.join(", ")} were not written because a deny or ask rule ${toolLabel} cannot express (skipped above) covers the same inputs, and the stricter rule wins.`);
|
|
80652
81108
|
return {
|
|
80653
81109
|
allow: [...new Set(allow)],
|
|
80654
81110
|
ask: [...new Set(ask)],
|
|
@@ -80656,6 +81112,24 @@ function convertRulesyncToAntigravityPermissions({ config, toAction, toolLabel,
|
|
|
80656
81112
|
};
|
|
80657
81113
|
}
|
|
80658
81114
|
/**
|
|
81115
|
+
* The widest glob an emitted entry grants, for comparing an allow against the
|
|
81116
|
+
* restrictions Antigravity cannot express. The emitted target can grant more
|
|
81117
|
+
* than the canonical pattern it came from: a path target also covers
|
|
81118
|
+
* everything inside it (and `.` the whole workspace), a command target is a
|
|
81119
|
+
* word prefix (`git push` approves `git push --force`), and a domain target
|
|
81120
|
+
* covers its subdomains and every URL on it. Widening only ever withholds more.
|
|
81121
|
+
*/
|
|
81122
|
+
function effectiveTargetScope(entry) {
|
|
81123
|
+
const { toolName, pattern: target } = parseToolPatternEntry(entry);
|
|
81124
|
+
if (target === "*") return "*";
|
|
81125
|
+
if (PATH_ACTIONS.has(toolName)) {
|
|
81126
|
+
const path = target.replace(/\/+$/, "");
|
|
81127
|
+
return path === "." || path === "" ? "*" : `${path}/**`;
|
|
81128
|
+
}
|
|
81129
|
+
if (ANTIGRAVITY_COMMAND_ACTIONS.has(toolName)) return target.endsWith("*") ? target : `${target}*`;
|
|
81130
|
+
return target;
|
|
81131
|
+
}
|
|
81132
|
+
/**
|
|
80659
81133
|
* Convert Antigravity allow/ask/deny arrays to rulesync permissions config,
|
|
80660
81134
|
* shared by the CLI and IDE adapters; `toCategory` maps the target's tool or
|
|
80661
81135
|
* action name back to a canonical category.
|
|
@@ -81556,15 +82030,21 @@ async function withBaseEnabledPlugins({ mergedContent, baseFilePath }) {
|
|
|
81556
82030
|
function convertRulesyncToAugmentEntries({ config, logger }) {
|
|
81557
82031
|
const entries = [];
|
|
81558
82032
|
const resolvedBashRules = bashRulesHonoringAllTools(config.permission);
|
|
82033
|
+
const honoredPermission = honorAllToolsRestrictions({
|
|
82034
|
+
permission: config.permission,
|
|
82035
|
+
toolLabel: "AugmentCode",
|
|
82036
|
+
logger,
|
|
82037
|
+
writesAllToolsCatchAll: true
|
|
82038
|
+
});
|
|
81559
82039
|
const permission = config.permission.bash !== void 0 || Object.keys(resolvedBashRules).length > 0 ? {
|
|
81560
|
-
...
|
|
82040
|
+
...honoredPermission,
|
|
81561
82041
|
bash: resolvedBashRules
|
|
81562
|
-
} :
|
|
82042
|
+
} : honoredPermission;
|
|
81563
82043
|
const allToolsFailClosedType = computeAllToolsFailClosedType(config.permission["*"]);
|
|
81564
82044
|
const categoriesWithOwnEntries = /* @__PURE__ */ new Set();
|
|
81565
82045
|
for (const [category, rules] of Object.entries(permission)) {
|
|
81566
82046
|
if (category === "*") {
|
|
81567
|
-
logger?.warn("AugmentCode permissions: the all-tools '*' category cannot be emitted as a single entry because AugmentCode has no wildcard toolName. Deny/ask rules are folded into 'launch-process' and, for any other managed tool that has no explicit rules of its own, applied as a blanket deny/ask; all-tools allow rules and tools that
|
|
82047
|
+
logger?.warn("AugmentCode permissions: the all-tools '*' category cannot be emitted as a single entry because AugmentCode has no wildcard toolName. Deny/ask rules are folded into 'launch-process' and, for any other managed tool that has no explicit rules of its own (or whose allow rules were all withheld because a '*' deny/ask covers them), applied as a blanket deny/ask; all-tools allow rules and tools that still define rules of their own are left untouched.");
|
|
81568
82048
|
continue;
|
|
81569
82049
|
}
|
|
81570
82050
|
const augmentToolName = toAugmentToolName(category);
|
|
@@ -81623,9 +82103,10 @@ function computeAllToolsFailClosedType(allToolsRules) {
|
|
|
81623
82103
|
* other managed tools: one that produced no entries of its own above must not fall back to
|
|
81624
82104
|
* AugmentCode's own default just because it has no per-input matcher to narrow the all-tools
|
|
81625
82105
|
* restriction onto. A category can be stated yet still emit nothing (e.g. only non-`*` allow/ask
|
|
81626
|
-
* patterns, dropped with a warning
|
|
81627
|
-
*
|
|
81628
|
-
*
|
|
82106
|
+
* patterns, dropped with a warning, or only allows withheld by `honorAllToolsRestrictions`), so
|
|
82107
|
+
* this checks emitted entries rather than whether the category was merely present in the source
|
|
82108
|
+
* config. Falling back to AugmentCode's own default instead would let a read-only tool run on the
|
|
82109
|
+
* input the restriction names. A tool whose own rules did emit entries is left untouched here.
|
|
81629
82110
|
*/
|
|
81630
82111
|
function synthesizeManagedToolFallbackEntries(categoriesWithOwnEntries, allToolsFailClosedType) {
|
|
81631
82112
|
if (allToolsFailClosedType === void 0) return [];
|
|
@@ -84089,8 +84570,10 @@ function categoryOfRule$2(rule) {
|
|
|
84089
84570
|
* - MCP rules take no specifier, so a scoped `mcp__<...>` category is written
|
|
84090
84571
|
* for its catch-all pattern only.
|
|
84091
84572
|
* - The all-tools `*` category is CodeBuddy's documented standalone `*` rule
|
|
84092
|
-
* for its catch-all pattern.
|
|
84093
|
-
*
|
|
84573
|
+
* for its catch-all pattern. A narrower `*` pattern reaches the `Bash`
|
|
84574
|
+
* rules through `honorAllToolsRestrictions`, which also withholds every
|
|
84575
|
+
* allow it overlaps in the other categories — a `{"*": "allow"}` included,
|
|
84576
|
+
* even for a shell-only pattern such as `git push *`.
|
|
84094
84577
|
*/
|
|
84095
84578
|
function buildCodebuddyRule({ category, pattern, action, logger }) {
|
|
84096
84579
|
const catchAll = pattern === "*";
|
|
@@ -84138,7 +84621,13 @@ function parseCodebuddyRule(rule) {
|
|
|
84138
84621
|
* manage (and every entry rulesync cannot parse).
|
|
84139
84622
|
*/
|
|
84140
84623
|
function buildCodebuddyRuleLists({ config, existingPermissions, logger }) {
|
|
84141
|
-
const permission =
|
|
84624
|
+
const permission = honorAllToolsRestrictions({
|
|
84625
|
+
permission: config.permission,
|
|
84626
|
+
toolLabel: "CodeBuddy",
|
|
84627
|
+
logger,
|
|
84628
|
+
restateAs: restatesAsCategoryRule(),
|
|
84629
|
+
writesAllToolsCatchAll: true
|
|
84630
|
+
});
|
|
84142
84631
|
const ranked = /* @__PURE__ */ new Map();
|
|
84143
84632
|
const managedCategories = /* @__PURE__ */ new Set();
|
|
84144
84633
|
for (const [category, rules] of Object.entries(permission)) {
|
|
@@ -85733,6 +86222,44 @@ function addCodexWebfetchRules({ rules, domains, logger }) {
|
|
|
85733
86222
|
domains[pattern] = action;
|
|
85734
86223
|
}
|
|
85735
86224
|
}
|
|
86225
|
+
/**
|
|
86226
|
+
* Copy the all-tools `*` path restrictions into the `read` rules, when the
|
|
86227
|
+
* config states a filesystem category at all: Codex has no all-tools rule, so
|
|
86228
|
+
* `{"*": {".env": "deny"}, "edit": {"*": "allow"}}` would otherwise grant
|
|
86229
|
+
* write access to `.env`. Both a `deny` and an `ask` land under `read`, where
|
|
86230
|
+
* they are handled exactly like a directly written read rule (an ask becomes
|
|
86231
|
+
* `"deny"`, since Codex cannot prompt for a path), so a narrower write allow
|
|
86232
|
+
* they cover is denied as well. A catch-all `*` deny is copied too and
|
|
86233
|
+
* withholds every filesystem allow, so `{"*": {"*": "deny"}, "edit": {"src":
|
|
86234
|
+
* "allow"}}` grants nothing; a catch-all
|
|
86235
|
+
* ask is the documented default idiom and is left alone. Other patterns are
|
|
86236
|
+
* copied only when they read as a path — `git push *` is a command, not a
|
|
86237
|
+
* path — so the sandbox gains nothing but these restrictions.
|
|
86238
|
+
*/
|
|
86239
|
+
function restateAllToolsPathRestrictions({ config, filesystemCategoryRules }) {
|
|
86240
|
+
if (Object.keys(filesystemCategoryRules).length === 0) return;
|
|
86241
|
+
if (lookupOwn({
|
|
86242
|
+
record: config.permission,
|
|
86243
|
+
key: "*"
|
|
86244
|
+
})?.["*"] === "deny") for (const category of [
|
|
86245
|
+
"read",
|
|
86246
|
+
"edit",
|
|
86247
|
+
"write"
|
|
86248
|
+
]) {
|
|
86249
|
+
const rules = filesystemCategoryRules[category];
|
|
86250
|
+
if (rules === void 0) continue;
|
|
86251
|
+
filesystemCategoryRules[category] = Object.fromEntries(Object.entries(rules).filter(([, action]) => action !== "allow"));
|
|
86252
|
+
}
|
|
86253
|
+
const isPath = restatesAsCategoryRule(["deny", "ask"]);
|
|
86254
|
+
filesystemCategoryRules.read = restateAllToolsRestrictionsInCategory({
|
|
86255
|
+
permission: {
|
|
86256
|
+
...config.permission,
|
|
86257
|
+
read: filesystemCategoryRules.read ?? {}
|
|
86258
|
+
},
|
|
86259
|
+
category: "read",
|
|
86260
|
+
restateAs: (params) => params.pattern === "*" ? params.action === "deny" : isPath(params)
|
|
86261
|
+
});
|
|
86262
|
+
}
|
|
85736
86263
|
function convertRulesyncToCodexProfile({ config, logger }) {
|
|
85737
86264
|
const filesystem = { [CODEX_MINIMAL_KEY]: "read" };
|
|
85738
86265
|
const workspaceRootFilesystem = {};
|
|
@@ -85744,8 +86271,24 @@ function convertRulesyncToCodexProfile({ config, logger }) {
|
|
|
85744
86271
|
continue;
|
|
85745
86272
|
}
|
|
85746
86273
|
if (toolName === "webfetch") {
|
|
86274
|
+
const allToolsRules = lookupOwn({
|
|
86275
|
+
record: config.permission,
|
|
86276
|
+
key: "*"
|
|
86277
|
+
});
|
|
86278
|
+
const { webfetch: webfetchRules = {} } = withholdAllowsShadowedByAsks({
|
|
86279
|
+
permission: { webfetch: honorAllToolsRestrictions({
|
|
86280
|
+
permission: allToolsRules === void 0 ? { webfetch: rules } : {
|
|
86281
|
+
["*"]: allToolsRules,
|
|
86282
|
+
webfetch: rules
|
|
86283
|
+
},
|
|
86284
|
+
toolLabel: "Codex CLI network domains",
|
|
86285
|
+
logger
|
|
86286
|
+
}).webfetch ?? {} },
|
|
86287
|
+
toolLabel: "Codex CLI network domains",
|
|
86288
|
+
logger
|
|
86289
|
+
});
|
|
85747
86290
|
addCodexWebfetchRules({
|
|
85748
|
-
rules,
|
|
86291
|
+
rules: webfetchRules,
|
|
85749
86292
|
domains,
|
|
85750
86293
|
logger
|
|
85751
86294
|
});
|
|
@@ -85754,6 +86297,10 @@ function convertRulesyncToCodexProfile({ config, logger }) {
|
|
|
85754
86297
|
if (toolName === "bash") continue;
|
|
85755
86298
|
logger?.warn(`Codex CLI permission profiles support only read/edit/write/webfetch categories (bash goes to .codex/rules/rulesync.rules). Skipping: ${toolName}`);
|
|
85756
86299
|
}
|
|
86300
|
+
restateAllToolsPathRestrictions({
|
|
86301
|
+
config,
|
|
86302
|
+
filesystemCategoryRules
|
|
86303
|
+
});
|
|
85757
86304
|
addCodexFilesystemRules({
|
|
85758
86305
|
categoryRules: filesystemCategoryRules,
|
|
85759
86306
|
filesystem,
|
|
@@ -86497,8 +87044,10 @@ const PADDED_SHELL_WILDCARD_REASON = "a pattern narrower than the bare 'Shell' (
|
|
|
86497
87044
|
* server or tool). A pattern on an MCP category is still written as the
|
|
86498
87045
|
* `(specifier)` here; `writableCommandcodeRule` decides what to do with it,
|
|
86499
87046
|
* because Command Code ignores it. The all-tools `*` category is only
|
|
86500
|
-
* written for its catch-all pattern; narrower `*`
|
|
86501
|
-
*
|
|
87047
|
+
* written for its catch-all pattern; a narrower `*` pattern reaches the `Shell`
|
|
87048
|
+
* entries through `honorAllToolsRestrictions`, which also withholds every allow
|
|
87049
|
+
* it overlaps in the other categories — a `{"*": "allow"}` included, even for a
|
|
87050
|
+
* shell-only pattern such as `git push *`.
|
|
86502
87051
|
*/
|
|
86503
87052
|
function buildCommandcodeRule(category, pattern) {
|
|
86504
87053
|
const catchAll = pattern === "*" || pattern === "";
|
|
@@ -86792,7 +87341,13 @@ function rankCommandcodeRule({ ranked, rule, action, logger }) {
|
|
|
86792
87341
|
* rewritten by `writableCommandcodeRule`.
|
|
86793
87342
|
*/
|
|
86794
87343
|
function buildCommandcodeRuleLists({ config, existingPermissions, logger }) {
|
|
86795
|
-
const permission =
|
|
87344
|
+
const permission = honorAllToolsRestrictions({
|
|
87345
|
+
permission: config.permission,
|
|
87346
|
+
toolLabel: "Command Code",
|
|
87347
|
+
logger,
|
|
87348
|
+
restateAs: restatesAsCategoryRule(),
|
|
87349
|
+
writesAllToolsCatchAll: true
|
|
87350
|
+
});
|
|
86796
87351
|
const ranked = /* @__PURE__ */ new Map();
|
|
86797
87352
|
const managedCategories = /* @__PURE__ */ new Set();
|
|
86798
87353
|
for (const [category, rules] of Object.entries(permission)) {
|
|
@@ -87252,7 +87807,13 @@ function convertRulesyncToContinuePermissions({ config, logger }) {
|
|
|
87252
87807
|
allow: []
|
|
87253
87808
|
};
|
|
87254
87809
|
const actionByEntry = /* @__PURE__ */ new Map();
|
|
87255
|
-
for (const [category, rules] of Object.entries(
|
|
87810
|
+
for (const [category, rules] of Object.entries(honorAllToolsRestrictions({
|
|
87811
|
+
permission: config.permission,
|
|
87812
|
+
toolLabel: "Continue",
|
|
87813
|
+
logger,
|
|
87814
|
+
writesAllToolsCatchAll: true,
|
|
87815
|
+
isCatchAll: (pattern) => normalizeCatchAllPattern$1(pattern) === "*"
|
|
87816
|
+
}))) {
|
|
87256
87817
|
if (isPrototypePollutionKey(category)) continue;
|
|
87257
87818
|
const toolName = category === "*" ? "*" : toContinueToolName(category);
|
|
87258
87819
|
for (const [rawPattern, action] of Object.entries(rules)) {
|
|
@@ -87624,6 +88185,58 @@ function asAutoApproveMap(value) {
|
|
|
87624
88185
|
return result;
|
|
87625
88186
|
}
|
|
87626
88187
|
/**
|
|
88188
|
+
* The edits or urls map's rules with the all-tools `*` restrictions honored.
|
|
88189
|
+
* A restriction that reads as a path (edits) or URL (urls), and the catch-all
|
|
88190
|
+
* `*`, is written as a `false` entry of its own, which `buildAutoApproveValue`
|
|
88191
|
+
* places where it wins; a URL is written without its scheme and with only its host lowercased,
|
|
88192
|
+
* since VS Code matches paths case-sensitively.
|
|
88193
|
+
* Every other restriction (a command, an odd URL pattern) cannot be written
|
|
88194
|
+
* there, so each `true` entry it overlaps is withheld instead.
|
|
88195
|
+
*/
|
|
88196
|
+
function honorCopilotAllToolsRestrictions({ permission, category, logger }) {
|
|
88197
|
+
const allToolsRules = lookupOwn({
|
|
88198
|
+
record: permission,
|
|
88199
|
+
key: "*"
|
|
88200
|
+
}) ?? {};
|
|
88201
|
+
const isWritable = restatesAsCategoryRule();
|
|
88202
|
+
const restateAs = (params) => params.pattern === "*" || isWritable(params) && !(params.category === "webfetch" && hasDoubleSlashWithoutScheme(params.pattern));
|
|
88203
|
+
const writable = {};
|
|
88204
|
+
const notWritable = {};
|
|
88205
|
+
for (const [pattern, action] of Object.entries(allToolsRules)) {
|
|
88206
|
+
if (action === "allow") continue;
|
|
88207
|
+
if (restateAs({
|
|
88208
|
+
category,
|
|
88209
|
+
pattern,
|
|
88210
|
+
action
|
|
88211
|
+
})) {
|
|
88212
|
+
const key = category === "webfetch" && pattern !== "*" ? stripUrlSchemeKeepingPathCase(pattern) : pattern;
|
|
88213
|
+
writable[key] = action;
|
|
88214
|
+
} else notWritable[pattern] = action;
|
|
88215
|
+
}
|
|
88216
|
+
const restated = restateAllToolsRestrictionsInCategory({
|
|
88217
|
+
permission: {
|
|
88218
|
+
["*"]: writable,
|
|
88219
|
+
[category]: lookupOwn({
|
|
88220
|
+
record: permission,
|
|
88221
|
+
key: category
|
|
88222
|
+
}) ?? {}
|
|
88223
|
+
},
|
|
88224
|
+
category,
|
|
88225
|
+
restateAs: () => true
|
|
88226
|
+
});
|
|
88227
|
+
return lookupOwn({
|
|
88228
|
+
record: honorAllToolsRestrictions({
|
|
88229
|
+
permission: {
|
|
88230
|
+
["*"]: notWritable,
|
|
88231
|
+
[category]: restated
|
|
88232
|
+
},
|
|
88233
|
+
toolLabel: COPILOT_TOOL_LABEL,
|
|
88234
|
+
logger
|
|
88235
|
+
}),
|
|
88236
|
+
key: category
|
|
88237
|
+
}) ?? {};
|
|
88238
|
+
}
|
|
88239
|
+
/**
|
|
87627
88240
|
* Render one canonical category's rules as a VS Code auto-approve map. Returns
|
|
87628
88241
|
* `undefined` when the category contributes nothing, so the key is retracted
|
|
87629
88242
|
* rather than written as an empty object.
|
|
@@ -87701,11 +88314,14 @@ var CopilotPermissions = class CopilotPermissions extends ToolPermissions {
|
|
|
87701
88314
|
const config = rulesyncPermissions.getJson();
|
|
87702
88315
|
const patch = {};
|
|
87703
88316
|
for (const [category, settingKey] of Object.entries(AUTO_APPROVE_KEYS)) {
|
|
87704
|
-
|
|
87705
|
-
if (rules === void 0) continue;
|
|
88317
|
+
if (!Object.hasOwn(config.permission, category)) continue;
|
|
87706
88318
|
patch[settingKey] = buildAutoApproveValue({
|
|
87707
88319
|
category,
|
|
87708
|
-
rules
|
|
88320
|
+
rules: category === "bash" ? bashRulesHonoringAllTools(config.permission) : honorCopilotAllToolsRestrictions({
|
|
88321
|
+
permission: config.permission,
|
|
88322
|
+
category,
|
|
88323
|
+
logger
|
|
88324
|
+
})
|
|
87709
88325
|
});
|
|
87710
88326
|
}
|
|
87711
88327
|
const existingSettings = () => parseSharedConfig({
|
|
@@ -87806,6 +88422,15 @@ const DEFAULT_PERMISSION_MODE_KEY = "defaultPermissionMode";
|
|
|
87806
88422
|
function isCopilotcliDefaultPermissionMode(value) {
|
|
87807
88423
|
return COPILOTCLI_DEFAULT_PERMISSION_MODES.some((mode) => mode === value);
|
|
87808
88424
|
}
|
|
88425
|
+
/** The given categories of a permission block, those it states. */
|
|
88426
|
+
function pickOwnCategories(permission, categories) {
|
|
88427
|
+
const picked = {};
|
|
88428
|
+
for (const category of categories) {
|
|
88429
|
+
const rules = Object.hasOwn(permission, category) ? permission[category] : void 0;
|
|
88430
|
+
if (rules !== void 0) picked[category] = rules;
|
|
88431
|
+
}
|
|
88432
|
+
return picked;
|
|
88433
|
+
}
|
|
87809
88434
|
function toUrlList(value) {
|
|
87810
88435
|
if (!Array.isArray(value)) return [];
|
|
87811
88436
|
return value.filter((entry) => typeof entry === "string");
|
|
@@ -87890,7 +88515,15 @@ var CopilotcliPermissions = class CopilotcliPermissions extends ToolPermissions
|
|
|
87890
88515
|
const filePath = join(outputRoot, paths.relativeDirPath, paths.relativeFilePath);
|
|
87891
88516
|
const existingContent = await readFileContentOrNull(filePath) ?? "{}";
|
|
87892
88517
|
const config = rulesyncPermissions.getJson();
|
|
87893
|
-
const rules =
|
|
88518
|
+
const rules = withholdAllowsShadowedByAsks({
|
|
88519
|
+
permission: honorAllToolsRestrictions({
|
|
88520
|
+
permission: pickOwnCategories(config.permission, ["*", WEBFETCH_CATEGORY$1]),
|
|
88521
|
+
toolLabel: "Copilot CLI",
|
|
88522
|
+
logger
|
|
88523
|
+
}),
|
|
88524
|
+
toolLabel: "Copilot CLI",
|
|
88525
|
+
logger
|
|
88526
|
+
})[WEBFETCH_CATEGORY$1];
|
|
87894
88527
|
const patch = {};
|
|
87895
88528
|
if (rules !== void 0) {
|
|
87896
88529
|
const { allowedUrls, deniedUrls } = splitUrlRules(rules);
|
|
@@ -88369,6 +89002,26 @@ function resolveCategoryAction({ category, toolName, rules, logger }) {
|
|
|
88369
89002
|
return catchAllAction;
|
|
88370
89003
|
}
|
|
88371
89004
|
/**
|
|
89005
|
+
* The canonical rules with the all-tools `*` restrictions applied the way
|
|
89006
|
+
* Crush can carry them. Crush has no all-tools list, so a `*` deny or ask
|
|
89007
|
+
* withholds every `allow` it covers in the other categories (`{"*": {".env":
|
|
89008
|
+
* "deny"}, "read": {"*": "allow"}}` keeps `view` out of `allowed_tools`, and
|
|
89009
|
+
* Crush prompts for it), named in one warning. `bash` keeps the
|
|
89010
|
+
* `honorAllToolsOnBash` treatment: its allow lines become `safe_commands`, and
|
|
89011
|
+
* the safe-command and blocked-command logic reports what it withholds itself.
|
|
89012
|
+
*/
|
|
89013
|
+
function honorCrushAllToolsRestrictions({ config, logger }) {
|
|
89014
|
+
const withShell = honorAllToolsOnBash(config.permission);
|
|
89015
|
+
const honored = honorAllToolsRestrictions({
|
|
89016
|
+
permission: Object.fromEntries(Object.entries(config.permission).filter(([category]) => category !== SHELL_PERMISSION_CATEGORY)),
|
|
89017
|
+
toolLabel: "Crush",
|
|
89018
|
+
logger
|
|
89019
|
+
});
|
|
89020
|
+
const permission = {};
|
|
89021
|
+
for (const [category, rules] of Object.entries(withShell)) permission[category] = category !== "bash" && Object.hasOwn(honored, category) ? honored[category] ?? rules : rules;
|
|
89022
|
+
return permission;
|
|
89023
|
+
}
|
|
89024
|
+
/**
|
|
88372
89025
|
* Convert a rulesync permissions config into Crush's two tool lists.
|
|
88373
89026
|
*/
|
|
88374
89027
|
function convertRulesyncToCrushLists({ config, logger }) {
|
|
@@ -88377,7 +89030,10 @@ function convertRulesyncToCrushLists({ config, logger }) {
|
|
|
88377
89030
|
disabled: []
|
|
88378
89031
|
};
|
|
88379
89032
|
const actionByTool = /* @__PURE__ */ new Map();
|
|
88380
|
-
for (const [category, rules] of Object.entries(
|
|
89033
|
+
for (const [category, rules] of Object.entries(honorCrushAllToolsRestrictions({
|
|
89034
|
+
config,
|
|
89035
|
+
logger
|
|
89036
|
+
}))) {
|
|
88381
89037
|
if (isPrototypePollutionKey(category)) continue;
|
|
88382
89038
|
if (category === "*") {
|
|
88383
89039
|
for (const [rawPattern, action] of Object.entries(rules)) {
|
|
@@ -88822,7 +89478,17 @@ var CursorPermissions = class CursorPermissions extends ToolPermissions {
|
|
|
88822
89478
|
function convertRulesyncToCursorPermissions(config, logger) {
|
|
88823
89479
|
const allow = [];
|
|
88824
89480
|
const deny = [];
|
|
88825
|
-
|
|
89481
|
+
const permission = withholdAllowsShadowedByAsks({
|
|
89482
|
+
permission: honorAllToolsRestrictions({
|
|
89483
|
+
permission: config.permission,
|
|
89484
|
+
toolLabel: "Cursor CLI",
|
|
89485
|
+
logger
|
|
89486
|
+
}),
|
|
89487
|
+
toolLabel: "Cursor CLI",
|
|
89488
|
+
logger,
|
|
89489
|
+
groupOf: (category) => isMcpScopedCategory(category) ? category : toCursorType(category)
|
|
89490
|
+
});
|
|
89491
|
+
for (const [category, rules] of Object.entries(permission)) {
|
|
88826
89492
|
const cursorType = toCursorType(category);
|
|
88827
89493
|
for (const [pattern, action] of Object.entries(rules)) {
|
|
88828
89494
|
const entry = buildToolPatternEntry({
|
|
@@ -90167,7 +90833,11 @@ function convertRulesyncToDevinPermissions({ config, logger }) {
|
|
|
90167
90833
|
case "deny": deny.push(entry);
|
|
90168
90834
|
}
|
|
90169
90835
|
};
|
|
90170
|
-
for (const [category, rules] of Object.entries(
|
|
90836
|
+
for (const [category, rules] of Object.entries(honorAllToolsRestrictions({
|
|
90837
|
+
permission: config.permission,
|
|
90838
|
+
toolLabel: "Devin",
|
|
90839
|
+
logger
|
|
90840
|
+
}))) {
|
|
90171
90841
|
const scope = toDevinScope(category);
|
|
90172
90842
|
if (DEVIN_BARE_ONLY_SCOPES.has(scope)) {
|
|
90173
90843
|
const action = collapseBareOnlyScopeRules({
|
|
@@ -90911,7 +91581,12 @@ function unmanagedEntries(existingPermission, key) {
|
|
|
90911
91581
|
*/
|
|
90912
91582
|
function buildGrokPermissionArrays(config, existingPermission, logger) {
|
|
90913
91583
|
const ranked = /* @__PURE__ */ new Map();
|
|
90914
|
-
for (const [category, rules] of Object.entries(
|
|
91584
|
+
for (const [category, rules] of Object.entries(honorAllToolsRestrictions({
|
|
91585
|
+
permission: config.permission,
|
|
91586
|
+
toolLabel: "Grok CLI",
|
|
91587
|
+
logger,
|
|
91588
|
+
writesAllToolsCatchAll: true
|
|
91589
|
+
}))) for (const [pattern, action] of Object.entries(rules)) {
|
|
90915
91590
|
const entry = buildGrokEntry(category, pattern);
|
|
90916
91591
|
if (entry === null) {
|
|
90917
91592
|
if (category === "*") {
|
|
@@ -90970,7 +91645,7 @@ function warnRemovedAllToolsRestrictions({ existingPermission, ranked, logger })
|
|
|
90970
91645
|
* Warn about entries that a bare `*` `deny`/`ask` makes ineffective: Grok
|
|
90971
91646
|
* evaluates by severity (`deny > ask > allow`), so a specific `allow` (and,
|
|
90972
91647
|
* under a `*` deny, a specific `ask`) never takes effect next to it. Shell
|
|
90973
|
-
* rules are already folded by `
|
|
91648
|
+
* rules are already folded by `honorAllToolsRestrictions`, so this covers the other
|
|
90974
91649
|
* tools.
|
|
90975
91650
|
*/
|
|
90976
91651
|
function warnEntriesShadowedByAllTools({ ranked, logger }) {
|
|
@@ -91727,7 +92402,12 @@ var JuniePermissions = class JuniePermissions extends ToolPermissions {
|
|
|
91727
92402
|
*/
|
|
91728
92403
|
function convertRulesyncToJunieRules({ config, logger, existingRules, overrideSecretFile, overrideRuleDefaults }) {
|
|
91729
92404
|
const ruleLists = {};
|
|
91730
|
-
|
|
92405
|
+
const permission = honorAllToolsRestrictions({
|
|
92406
|
+
permission: config.permission,
|
|
92407
|
+
toolLabel: "Junie allowlist",
|
|
92408
|
+
logger
|
|
92409
|
+
});
|
|
92410
|
+
for (const [category, patterns] of Object.entries(permission)) {
|
|
91731
92411
|
const group = lookupOwn({
|
|
91732
92412
|
record: CANONICAL_TO_JUNIE_GROUP,
|
|
91733
92413
|
key: category
|
|
@@ -91755,13 +92435,16 @@ function convertRulesyncToJunieRules({ config, logger, existingRules, overrideSe
|
|
|
91755
92435
|
if (list === void 0 && groupDefault === void 0) continue;
|
|
91756
92436
|
rules[group] = {
|
|
91757
92437
|
...groupDefault !== void 0 && { default: groupDefault },
|
|
91758
|
-
rules: list
|
|
92438
|
+
rules: list === void 0 ? [] : sortRestrictionsFirst(list)
|
|
91759
92439
|
};
|
|
91760
92440
|
}
|
|
91761
92441
|
const secretFile = overrideSecretFile ?? toRuleSet(existingRules[JUNIE_SECRET_FILE_GROUP]);
|
|
91762
92442
|
if (secretFile !== void 0) rules[JUNIE_SECRET_FILE_GROUP] = sanitizeRuleSet(secretFile);
|
|
91763
92443
|
return rules;
|
|
91764
92444
|
}
|
|
92445
|
+
function sortRestrictionsFirst(list) {
|
|
92446
|
+
return [...list.filter((rule) => rule.action !== "allow"), ...list.filter((rule) => rule.action === "allow")];
|
|
92447
|
+
}
|
|
91765
92448
|
/**
|
|
91766
92449
|
* Map a canonical action onto a valid Junie allowlist action. Junie supports
|
|
91767
92450
|
* only `allow` and `ask`; a canonical `deny` is downgraded to `ask` (the
|
|
@@ -91807,6 +92490,69 @@ function convertJunieToRulesyncPermissions({ allowlist }) {
|
|
|
91807
92490
|
readSecretFile
|
|
91808
92491
|
};
|
|
91809
92492
|
}
|
|
92493
|
+
// src/features/permissions/last-match-restate.ts
|
|
92494
|
+
/**
|
|
92495
|
+
* OpenCode (and its forks: Kilo, MiMo Code) applies the last matching rule,
|
|
92496
|
+
* and the `*` key comes first in the usual file, so a later key's allow overrides a pattern-specific `*` deny or
|
|
92497
|
+
* ask: `{"*": {".env": "deny"}, "read": {"*": "allow"}}` would read `.env`
|
|
92498
|
+
* freely. Canonically the stricter rule wins whatever its width, so each such
|
|
92499
|
+
* restriction is restated at the end of every other key that holds a looser
|
|
92500
|
+
* rule it overlaps, where it is matched after that rule. A `*` catch-all
|
|
92501
|
+
* (`{"*": {"*": "ask"}}` followed by per-tool allows) is the documented way to
|
|
92502
|
+
* set an OpenCode default, so it is left where it is.
|
|
92503
|
+
*
|
|
92504
|
+
* A restated rule must never land after an overlapping stricter one, or it
|
|
92505
|
+
* would loosen what that rule says. The tail of a key is therefore written
|
|
92506
|
+
* asks first, then denies: every restated ask, then each of the key's own
|
|
92507
|
+
* denies and each `*` deny that overlaps one of those asks (moved after them),
|
|
92508
|
+
* then the restated `*` denies. A key whose own catch-all is a deny covers
|
|
92509
|
+
* every input of a restated ask already, so such an ask is restated as a deny.
|
|
92510
|
+
*/
|
|
92511
|
+
function restateAllToolsRestrictionsLast(sharedPermission) {
|
|
92512
|
+
const allToolsRules = Object.hasOwn(sharedPermission, "*") ? sharedPermission["*"] : void 0;
|
|
92513
|
+
const restrictions = Object.entries(allToolsRules ?? {}).filter(([pattern, action]) => action !== "allow" && pattern !== "*" && !isPrototypePollutionKey(pattern));
|
|
92514
|
+
if (restrictions.length === 0) return sharedPermission;
|
|
92515
|
+
const result = {};
|
|
92516
|
+
for (const [key, rules] of Object.entries(sharedPermission)) result[key] = key === "*" ? rules : restateInKey({
|
|
92517
|
+
rules,
|
|
92518
|
+
restrictions
|
|
92519
|
+
});
|
|
92520
|
+
return result;
|
|
92521
|
+
}
|
|
92522
|
+
function globsOverlap(left, right) {
|
|
92523
|
+
return createShadowingRestrictionsTest([{
|
|
92524
|
+
pattern: left,
|
|
92525
|
+
fromAllToolsCategory: true
|
|
92526
|
+
}])(right).length > 0;
|
|
92527
|
+
}
|
|
92528
|
+
/** One key's rules with the `*` restrictions restated at its end; see the caller. */
|
|
92529
|
+
function restateInKey({ rules, restrictions }) {
|
|
92530
|
+
const own = Object.entries(rules);
|
|
92531
|
+
const ownAction = (pattern) => Object.hasOwn(rules, pattern) ? rules[pattern] : void 0;
|
|
92532
|
+
const overlapsLooserOwnRule = (pattern, action) => own.some(([ownPattern, existing]) => isStricterAction({
|
|
92533
|
+
action,
|
|
92534
|
+
existing
|
|
92535
|
+
}) && globsOverlap(pattern, ownPattern));
|
|
92536
|
+
const allToolsDenies = restrictions.filter(([, action]) => action === "deny").map(([pattern]) => pattern);
|
|
92537
|
+
let asks = restrictions.filter(([pattern, action]) => action === "ask" && overlapsLooserOwnRule(pattern, action)).map(([pattern]) => pattern);
|
|
92538
|
+
const denies = new Set(allToolsDenies.filter((pattern) => overlapsLooserOwnRule(pattern, "deny")));
|
|
92539
|
+
if (ownAction("*") === "deny") {
|
|
92540
|
+
for (const pattern of asks) denies.add(pattern);
|
|
92541
|
+
asks = [];
|
|
92542
|
+
}
|
|
92543
|
+
for (const pattern of asks) if (ownAction(pattern) === "deny") denies.add(pattern);
|
|
92544
|
+
asks = asks.filter((pattern) => ownAction(pattern) !== "deny");
|
|
92545
|
+
const overlapsAnAsk = (pattern) => asks.some((ask) => globsOverlap(ask, pattern));
|
|
92546
|
+
const ownDenies = own.filter(([pattern, action]) => action === "deny" && pattern !== "*").map(([pattern]) => pattern);
|
|
92547
|
+
for (const pattern of [...ownDenies, ...allToolsDenies]) if (overlapsAnAsk(pattern)) denies.add(pattern);
|
|
92548
|
+
if (asks.length === 0 && denies.size === 0) return rules;
|
|
92549
|
+
const tail = /* @__PURE__ */ new Set([...asks, ...denies]);
|
|
92550
|
+
const restated = {};
|
|
92551
|
+
for (const [pattern, action] of own) if (!tail.has(pattern)) restated[pattern] = action;
|
|
92552
|
+
for (const pattern of asks) restated[pattern] = "ask";
|
|
92553
|
+
for (const pattern of denies) restated[pattern] = "deny";
|
|
92554
|
+
return restated;
|
|
92555
|
+
}
|
|
91810
92556
|
// src/features/permissions/kilo-permissions.ts
|
|
91811
92557
|
const KiloPermissionSchema = z.union([z.enum([
|
|
91812
92558
|
"allow",
|
|
@@ -92022,7 +92768,7 @@ var KiloPermissions = class KiloPermissions extends ToolPermissions {
|
|
|
92022
92768
|
const rulesyncJson = rulesyncPermissions.getJson();
|
|
92023
92769
|
const kiloOverride = rulesyncJson.kilo;
|
|
92024
92770
|
const incomingPermission = {
|
|
92025
|
-
...honorAllToolsOnBash(rulesyncJson.permission),
|
|
92771
|
+
...restateAllToolsRestrictionsLast(honorAllToolsOnBash(rulesyncJson.permission)),
|
|
92026
92772
|
...kiloOverride?.permission
|
|
92027
92773
|
};
|
|
92028
92774
|
if (!global && Object.hasOwn(incomingPermission, KILO_MARKDOWN_SOURCE_KEY)) {
|
|
@@ -92227,7 +92973,12 @@ function warnAboutMistypedToolLists(section) {
|
|
|
92227
92973
|
function canonicalToKimiCodeRules({ config, logger }) {
|
|
92228
92974
|
const canonicalRules = [];
|
|
92229
92975
|
const overrideRules = config["kimi-code"]?.rules ?? [];
|
|
92230
|
-
|
|
92976
|
+
const permission = honorAllToolsRestrictions({
|
|
92977
|
+
permission: config.permission,
|
|
92978
|
+
toolLabel: "Kimi Code",
|
|
92979
|
+
logger
|
|
92980
|
+
});
|
|
92981
|
+
for (const [category, rules] of Object.entries(permission)) {
|
|
92231
92982
|
if (!(category === "mcp" || category.startsWith("mcp__") || lookupOwn({
|
|
92232
92983
|
record: CATEGORY_TO_KIMI_CODE_TOOL,
|
|
92233
92984
|
key: category
|
|
@@ -93074,7 +93825,11 @@ var KiroCapabilityPermissions = class KiroCapabilityPermissions extends ToolPerm
|
|
|
93074
93825
|
*/
|
|
93075
93826
|
function buildKiroCapabilityRules({ config, logger }) {
|
|
93076
93827
|
const buckets = /* @__PURE__ */ new Map();
|
|
93077
|
-
for (const [category, rules] of Object.entries(
|
|
93828
|
+
for (const [category, rules] of Object.entries(honorAllToolsRestrictions({
|
|
93829
|
+
permission: config.permission,
|
|
93830
|
+
toolLabel: "Kiro",
|
|
93831
|
+
logger
|
|
93832
|
+
}))) {
|
|
93078
93833
|
const capability = lookupOwn({
|
|
93079
93834
|
record: CANONICAL_TO_KIRO_CAPABILITY,
|
|
93080
93835
|
key: category
|
|
@@ -93282,7 +94037,12 @@ function fromLettacodeRule(rule) {
|
|
|
93282
94037
|
* absent from the config).
|
|
93283
94038
|
*/
|
|
93284
94039
|
function buildLettacodeRuleLists({ config, existingPermissions, logger }) {
|
|
93285
|
-
const permission =
|
|
94040
|
+
const permission = honorAllToolsRestrictions({
|
|
94041
|
+
permission: config.permission,
|
|
94042
|
+
toolLabel: "Letta Code",
|
|
94043
|
+
logger,
|
|
94044
|
+
restateAs: restatesAsCategoryRule()
|
|
94045
|
+
});
|
|
93286
94046
|
const ranked = /* @__PURE__ */ new Map();
|
|
93287
94047
|
const managedCategories = /* @__PURE__ */ new Set();
|
|
93288
94048
|
for (const [category, rules] of Object.entries(permission)) {
|
|
@@ -93702,7 +94462,7 @@ function toOpencodeSharedPermission({ permission, toolTarget, logger }) {
|
|
|
93702
94462
|
sharedPermission[key] = merged;
|
|
93703
94463
|
} else sharedPermission[key] = value;
|
|
93704
94464
|
}
|
|
93705
|
-
return sharedPermission;
|
|
94465
|
+
return restateAllToolsRestrictionsLast(sharedPermission);
|
|
93706
94466
|
}
|
|
93707
94467
|
const OpencodePermissionsConfigSchema = z.looseObject({
|
|
93708
94468
|
permission: z.optional(z.union([z.enum([
|
|
@@ -94527,7 +95287,7 @@ function listPatterns(patterns) {
|
|
|
94527
95287
|
* - `mcp__<server>__<tool>` is skipped: Pool approves MCP tools per server
|
|
94528
95288
|
* under `mcp_servers.<server>.allow`, authored as `poolAllow` in
|
|
94529
95289
|
* `.rulesync/mcp.json`. The all-tools `*` category is mirrored onto
|
|
94530
|
-
* `bash` by `
|
|
95290
|
+
* `bash` by `honorAllToolsRestrictions` and otherwise skipped.
|
|
94531
95291
|
*
|
|
94532
95292
|
* Project settings take project-relative paths and the user settings absolute
|
|
94533
95293
|
* or `~` paths, so a path of the other kind is skipped with a warning at each
|
|
@@ -94620,7 +95380,11 @@ var PoolPermissions = class PoolPermissions extends ToolPermissions {
|
|
|
94620
95380
|
* `tools: {}` / `paths: {}`.
|
|
94621
95381
|
*/
|
|
94622
95382
|
function buildPoolPermissionsPatch({ config, existing, global, logger }) {
|
|
94623
|
-
const permission =
|
|
95383
|
+
const permission = honorAllToolsRestrictions({
|
|
95384
|
+
permission: config.permission,
|
|
95385
|
+
toolLabel: "Pool",
|
|
95386
|
+
logger
|
|
95387
|
+
});
|
|
94624
95388
|
const existingTools = isRecord(existing["tools"]) ? existing[POOL_TOOLS_KEY] : void 0;
|
|
94625
95389
|
const existingPaths = isRecord(existing["paths"]) ? existing[POOL_PATHS_KEY] : void 0;
|
|
94626
95390
|
const patch = {};
|
|
@@ -95060,8 +95824,10 @@ function categoryOfRule(rule) {
|
|
|
95060
95824
|
* when Qoder has no spelling for it.
|
|
95061
95825
|
*
|
|
95062
95826
|
* - The all-tools `*` category is Qoder's bare `*` rule; a narrower pattern
|
|
95063
|
-
* under it names no single tool and is skipped
|
|
95064
|
-
* already
|
|
95827
|
+
* under it names no single tool and is skipped. `honorAllToolsRestrictions`
|
|
95828
|
+
* already carried it onto `bash` and withheld every allow it overlaps in the
|
|
95829
|
+
* other categories — a `{"*": "allow"}` included, even for a shell-only
|
|
95830
|
+
* pattern such as `git push *`.
|
|
95065
95831
|
* - An `mcp__...` category is a fully qualified MCP tool name (or a Qoder MCP
|
|
95066
95832
|
* wildcard like `mcp__github__*`) and only takes the catch-all pattern.
|
|
95067
95833
|
* - Every other category maps to its Qoder tool name; `*` is the bare tool
|
|
@@ -95113,7 +95879,13 @@ function fromQoderRule(rule) {
|
|
|
95113
95879
|
* ...). An existing entry this run writes is moved to its new list.
|
|
95114
95880
|
*/
|
|
95115
95881
|
function buildQoderRuleLists({ config, existingPermissions, logger }) {
|
|
95116
|
-
const permission =
|
|
95882
|
+
const permission = honorAllToolsRestrictions({
|
|
95883
|
+
permission: config.permission,
|
|
95884
|
+
toolLabel: "Qoder",
|
|
95885
|
+
logger,
|
|
95886
|
+
restateAs: restatesAsCategoryRule(),
|
|
95887
|
+
writesAllToolsCatchAll: true
|
|
95888
|
+
});
|
|
95117
95889
|
const ranked = /* @__PURE__ */ new Map();
|
|
95118
95890
|
const managedCategories = /* @__PURE__ */ new Set();
|
|
95119
95891
|
for (const [category, rules] of Object.entries(permission)) {
|
|
@@ -95926,7 +96698,10 @@ var QwencodePermissions = class QwencodePermissions extends ToolPermissions {
|
|
|
95926
96698
|
}
|
|
95927
96699
|
const displayPath = toPosixPath(join(global ? "~" : ".", paths.relativeDirPath, paths.relativeFilePath));
|
|
95928
96700
|
const config = rulesyncPermissions.getJson();
|
|
95929
|
-
const { allow, ask, deny } = convertRulesyncToQwenPermissions(
|
|
96701
|
+
const { allow, ask, deny } = convertRulesyncToQwenPermissions({
|
|
96702
|
+
config,
|
|
96703
|
+
logger
|
|
96704
|
+
});
|
|
95930
96705
|
const managedToolNames = new Set(Object.keys(config.permission).map((category) => toQwenToolName(category)));
|
|
95931
96706
|
const existingPermissions = settings.permissions ?? {};
|
|
95932
96707
|
const preservedAllow = (existingPermissions.allow ?? []).filter((entry) => !managedToolNames.has(parseQwenPermissionEntry(entry, { logger }).toolName));
|
|
@@ -96031,11 +96806,17 @@ var QwencodePermissions = class QwencodePermissions extends ToolPermissions {
|
|
|
96031
96806
|
}
|
|
96032
96807
|
}
|
|
96033
96808
|
};
|
|
96034
|
-
function convertRulesyncToQwenPermissions(config) {
|
|
96809
|
+
function convertRulesyncToQwenPermissions({ config, logger }) {
|
|
96035
96810
|
const allow = [];
|
|
96036
96811
|
const ask = [];
|
|
96037
96812
|
const deny = [];
|
|
96038
|
-
|
|
96813
|
+
const permission = honorAllToolsRestrictions({
|
|
96814
|
+
permission: config.permission,
|
|
96815
|
+
toolLabel: "Qwen Code",
|
|
96816
|
+
logger,
|
|
96817
|
+
restateAs: restatesAsCategoryRule()
|
|
96818
|
+
});
|
|
96819
|
+
for (const [category, rules] of Object.entries(permission)) {
|
|
96039
96820
|
const qwenToolName = toQwenToolName(category);
|
|
96040
96821
|
for (const [pattern, action] of Object.entries(rules)) {
|
|
96041
96822
|
const entry = buildToolPatternEntry({
|
|
@@ -96564,7 +97345,10 @@ var ReasonixPermissions = class ReasonixPermissions extends ToolPermissions {
|
|
|
96564
97345
|
const existingContent = await readFileContentOrNull(filePath) ?? "";
|
|
96565
97346
|
const parsed = parseReasonixConfig(existingContent);
|
|
96566
97347
|
const config = rulesyncPermissions.getJson();
|
|
96567
|
-
const { allow, ask, deny } = convertRulesyncToReasonixPermissions(
|
|
97348
|
+
const { allow, ask, deny } = convertRulesyncToReasonixPermissions({
|
|
97349
|
+
config,
|
|
97350
|
+
logger
|
|
97351
|
+
});
|
|
96568
97352
|
const managedToolNames = new Set(Object.keys(config.permission).flatMap((category) => reasonixToolNamesOf(category)));
|
|
96569
97353
|
const override = config.reasonix;
|
|
96570
97354
|
const rawAllow = toStringArray$1(override?.rawAllow);
|
|
@@ -96834,11 +97618,16 @@ function setOrDeleteEntries(table, key, entries) {
|
|
|
96834
97618
|
/**
|
|
96835
97619
|
* Convert rulesync permissions config to Reasonix allow/ask/deny arrays.
|
|
96836
97620
|
*/
|
|
96837
|
-
function convertRulesyncToReasonixPermissions(config) {
|
|
97621
|
+
function convertRulesyncToReasonixPermissions({ config, logger }) {
|
|
96838
97622
|
const allow = [];
|
|
96839
97623
|
const ask = [];
|
|
96840
97624
|
const deny = [];
|
|
96841
|
-
|
|
97625
|
+
const permission = honorAllToolsRestrictions({
|
|
97626
|
+
permission: config.permission,
|
|
97627
|
+
toolLabel: "Reasonix",
|
|
97628
|
+
logger
|
|
97629
|
+
});
|
|
97630
|
+
for (const [category, rules] of Object.entries(permission)) for (const reasonixToolName of toReasonixToolNames(category)) for (const [pattern, action] of Object.entries(rules)) {
|
|
96842
97631
|
const entry = buildToolPatternEntry({
|
|
96843
97632
|
toolName: reasonixToolName,
|
|
96844
97633
|
pattern
|
|
@@ -98858,14 +99647,19 @@ async function readTaktRuntimeConfig({ outputRoot, logger }) {
|
|
|
98858
99647
|
/**
|
|
98859
99648
|
* Collapse a rulesync permissions config into Takt's single coarse mode.
|
|
98860
99649
|
*
|
|
98861
|
-
* Precedence: any `deny` ⇒ `readonly`; else an `edit`/`write` `allow`
|
|
98862
|
-
* else a `bash` `allow` ⇒ `full`; else the safe default `readonly`.
|
|
99650
|
+
* Precedence: any `deny` or `ask` ⇒ `readonly`; else an `edit`/`write` `allow`
|
|
99651
|
+
* ⇒ `edit`; else a `bash` `allow` ⇒ `full`; else the safe default `readonly`.
|
|
99652
|
+
*
|
|
99653
|
+
* An `ask` restricts like a `deny` here: Takt's coarse modes have no prompting
|
|
99654
|
+
* tier, so a mode derived from the allows beside it (`full` for `{"git *":
|
|
99655
|
+
* "allow", "git push *": "ask"}`) would auto-approve what the ask should prompt
|
|
99656
|
+
* for — the canonical order is `deny > ask > allow`.
|
|
98863
99657
|
*/
|
|
98864
99658
|
function deriveTaktPermissionMode(config) {
|
|
98865
99659
|
let hasEditAllow = false;
|
|
98866
99660
|
let hasBashAllow = false;
|
|
98867
99661
|
for (const [category, rules] of Object.entries(config.permission)) for (const action of Object.values(rules)) {
|
|
98868
|
-
if (action === "deny") return "readonly";
|
|
99662
|
+
if (action === "deny" || action === "ask") return "readonly";
|
|
98869
99663
|
if (action === "allow") {
|
|
98870
99664
|
if (category === "edit" || category === "write") hasEditAllow = true;
|
|
98871
99665
|
else if (category === "bash") hasBashAllow = true;
|
|
@@ -99148,7 +99942,12 @@ function buildMcpRules({ permission, existing, logger }) {
|
|
|
99148
99942
|
/** Split the canonical `webfetch` rules into TRAE's network allow/deny lists. */
|
|
99149
99943
|
function buildNetworkLists({ webfetchRules, logger }) {
|
|
99150
99944
|
const ranked = /* @__PURE__ */ new Map();
|
|
99151
|
-
|
|
99945
|
+
const { webfetch: rules = {} } = withholdAllowsShadowedByAsks({
|
|
99946
|
+
permission: { webfetch: webfetchRules },
|
|
99947
|
+
toolLabel: "TRAE resourceAuthorization.network",
|
|
99948
|
+
logger
|
|
99949
|
+
});
|
|
99950
|
+
for (const [pattern, action] of Object.entries(rules)) {
|
|
99152
99951
|
if (isPrototypePollutionKey(pattern)) continue;
|
|
99153
99952
|
if (pattern === "*") {
|
|
99154
99953
|
logger?.warn(`TRAE permissions: skipping the 'webfetch' rule '*' — TRAE sets the default network policy in the custom permission mode ('customProfiles.defaultCustomProfile.network.default'), not in resourceAuthorization.`);
|
|
@@ -99276,7 +100075,11 @@ var TraePermissions = class TraePermissions extends ToolPermissions {
|
|
|
99276
100075
|
fileContent: existingContent,
|
|
99277
100076
|
relativePath
|
|
99278
100077
|
});
|
|
99279
|
-
const permission =
|
|
100078
|
+
const permission = honorAllToolsRestrictions({
|
|
100079
|
+
permission: rulesyncPermissions.getJson().permission,
|
|
100080
|
+
toolLabel: "TRAE",
|
|
100081
|
+
logger
|
|
100082
|
+
});
|
|
99280
100083
|
warnUnmappedCategories({
|
|
99281
100084
|
permission,
|
|
99282
100085
|
logger
|
|
@@ -99525,7 +100328,18 @@ var VibePermissions = class VibePermissions extends ToolPermissions {
|
|
|
99525
100328
|
const filePath = join(outputRoot, paths.relativeDirPath, paths.relativeFilePath);
|
|
99526
100329
|
const existingContent = await readFileContentOrNull(filePath) ?? "";
|
|
99527
100330
|
const config = parseVibeConfig(existingContent);
|
|
99528
|
-
const permission =
|
|
100331
|
+
const permission = withholdAllowsShadowedByAsks({
|
|
100332
|
+
permission: honorAllToolsRestrictions({
|
|
100333
|
+
permission: rulesyncPermissions.getJson().permission,
|
|
100334
|
+
toolLabel: "Vibe",
|
|
100335
|
+
logger,
|
|
100336
|
+
restateAs: restatesAsCategoryRule(["deny"]),
|
|
100337
|
+
downgradeWithheldCatchAll: true
|
|
100338
|
+
}),
|
|
100339
|
+
toolLabel: "Vibe",
|
|
100340
|
+
logger,
|
|
100341
|
+
isSkippedAsk: ({ pattern }) => pattern !== "*"
|
|
100342
|
+
});
|
|
99529
100343
|
const vibeOverride = rulesyncPermissions.getJson().vibe;
|
|
99530
100344
|
const tools = toVibeToolsRecord(config.tools);
|
|
99531
100345
|
const diskShellPatterns = new Map([VIBE_SHELL_CATEGORY, ...VIBE_SHELL_ALIAS_TOOL_NAMES].map((vibeToolName) => [vibeToolName, toStringArray$1(readVibeToolConfig({
|
|
@@ -99574,6 +100388,12 @@ var VibePermissions = class VibePermissions extends ToolPermissions {
|
|
|
99574
100388
|
logger
|
|
99575
100389
|
});
|
|
99576
100390
|
const tableCategories = Object.entries(permission).filter(([category]) => category !== VIBE_SUBAGENT_CATEGORY && category !== VIBE_OUTSIDE_WORKDIR_CATEGORY);
|
|
100391
|
+
retireWithheldAllows({
|
|
100392
|
+
source: rulesyncPermissions.getJson().permission,
|
|
100393
|
+
permission,
|
|
100394
|
+
tools,
|
|
100395
|
+
resolveNames
|
|
100396
|
+
});
|
|
99577
100397
|
for (const [category, rules] of tableCategories) {
|
|
99578
100398
|
const vibeToolNames = resolveNames(category);
|
|
99579
100399
|
if (vibeToolNames === void 0) {
|
|
@@ -99958,6 +100778,49 @@ function applyCategoryRulesToTool({ vibeToolName, category, rules, tools, enable
|
|
|
99958
100778
|
tools[vibeToolName] = nextTool;
|
|
99959
100779
|
}
|
|
99960
100780
|
/**
|
|
100781
|
+
* Remove from the existing tables what the current restrictions forbid. The
|
|
100782
|
+
* per-tool pass merges into the `allowlist` already on disk and only sets
|
|
100783
|
+
* `permission` when the category states a `*` rule, so a regenerate would
|
|
100784
|
+
* otherwise keep an `allowlist` entry (an earlier generate's, or a
|
|
100785
|
+
* hand-written one) that auto-approves what a canonical ask or deny now
|
|
100786
|
+
* covers, or the `permission = "always"` an earlier config wrote for an allow
|
|
100787
|
+
* that is now withheld. Only the tables of categories the config manages are
|
|
100788
|
+
* touched, and only entries that overlap a restriction are removed. A
|
|
100789
|
+
* category's own catch-all ask is the documented default its allowlist carves
|
|
100790
|
+
* out of, so it removes nothing.
|
|
100791
|
+
*/
|
|
100792
|
+
function retireWithheldAllows({ source, permission, tools, resolveNames }) {
|
|
100793
|
+
const allToolsRestrictions = Object.entries(lookupOwn({
|
|
100794
|
+
record: source,
|
|
100795
|
+
key: "*"
|
|
100796
|
+
}) ?? {}).filter(([pattern, action]) => action === "deny" || action === "ask" && pattern !== "*");
|
|
100797
|
+
for (const [category, rules] of Object.entries(source)) {
|
|
100798
|
+
if (category === "*") continue;
|
|
100799
|
+
const honored = lookupOwn({
|
|
100800
|
+
record: permission,
|
|
100801
|
+
key: category
|
|
100802
|
+
}) ?? {};
|
|
100803
|
+
const withheld = new Set(Object.entries(rules).filter(([pattern, action]) => action === "allow" && honored[pattern] !== "allow").map(([pattern]) => pattern));
|
|
100804
|
+
const restrictions = [...Object.entries(honored).filter(([pattern, action]) => action !== "allow" && pattern !== "*"), ...allToolsRestrictions].map(([pattern]) => ({
|
|
100805
|
+
pattern,
|
|
100806
|
+
fromAllToolsCategory: false
|
|
100807
|
+
}));
|
|
100808
|
+
const globShadowed = createShadowingRestrictionsTest(restrictions);
|
|
100809
|
+
const shadowed = (pattern) => category === "webfetch" ? restrictions.some((restriction) => urlPatternsOverlap(restriction.pattern, pattern)) : globShadowed(pattern).length > 0;
|
|
100810
|
+
const retires = (pattern) => withheld.has(pattern) || restrictions.length > 0 && honored[pattern] !== "allow" && shadowed(pattern);
|
|
100811
|
+
for (const vibeToolName of resolveNames(category) ?? []) {
|
|
100812
|
+
if (!Object.hasOwn(tools, vibeToolName)) continue;
|
|
100813
|
+
const tool = readVibeToolConfig({
|
|
100814
|
+
tools,
|
|
100815
|
+
vibeToolName
|
|
100816
|
+
});
|
|
100817
|
+
for (const key of ["allow", "allowlist"]) if (tool[key] !== void 0) tool[key] = toStringArray$1(tool[key]).filter((pattern) => !retires(pattern));
|
|
100818
|
+
if (withheld.size > 0 && tool.permission === "always" && !Object.hasOwn(honored, "*")) tool.permission = "ask";
|
|
100819
|
+
tools[vibeToolName] = tool;
|
|
100820
|
+
}
|
|
100821
|
+
}
|
|
100822
|
+
}
|
|
100823
|
+
/**
|
|
99961
100824
|
* `enabled_tools` is an exclusive allowlist and therefore only ever
|
|
99962
100825
|
* rulesync-authored explicitly, through `vibe.enabled_tools`. When the
|
|
99963
100826
|
* override declares it (even empty), rulesync owns the whole list; when it
|
|
@@ -105110,4 +105973,4 @@ const CHECKS_IMPORT_STRATEGY = {
|
|
|
105110
105973
|
};
|
|
105111
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 };
|
|
105112
105975
|
|
|
105113
|
-
//# sourceMappingURL=import-
|
|
105976
|
+
//# sourceMappingURL=import-C7cimNlL.js.map
|