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
|
@@ -79480,6 +79480,30 @@ function maxRangeCount(steps) {
|
|
|
79480
79480
|
return most;
|
|
79481
79481
|
}
|
|
79482
79482
|
/**
|
|
79483
|
+
* Whether any one value matches both globs — that is, whether the two patterns
|
|
79484
|
+
* overlap at all. The answer is exact up to `MAX_INTERSECTION_CELLS`; a pair
|
|
79485
|
+
* longer than that is reported as overlapping without being compared, so a
|
|
79486
|
+
* caller that reads a `true` as a reason to restrict stays on the safe side and
|
|
79487
|
+
* one that would read it as a reason to permit must not use this. What a pair
|
|
79488
|
+
* costs counts the ranges a `[a-z]` class carries, not only the two lengths.
|
|
79489
|
+
*
|
|
79490
|
+
* This answers the question an adapter really has when it holds a restriction
|
|
79491
|
+
* and an `allow`: is there a command both of them name? Asking instead whether
|
|
79492
|
+
* either pattern covers the other's *text* misses the ordinary crossing pair —
|
|
79493
|
+
* `* --force` and `git *` cover none of each other's spellings, yet they share
|
|
79494
|
+
* every `git … --force` command.
|
|
79495
|
+
*
|
|
79496
|
+
* The two step lists are walked as a table rather than by backtracking, so no
|
|
79497
|
+
* input makes the time blow up the way a translated regex would. Only two rows
|
|
79498
|
+
* of that table are ever held, and the shorter pattern is the one that sizes
|
|
79499
|
+
* them, so the memory is linear in the shorter pattern however long the other
|
|
79500
|
+
* one is. Where a `[...]` class meets another `[...]` class the answer is
|
|
79501
|
+
* assumed to be yes, which over-reports rather than misses.
|
|
79502
|
+
*/
|
|
79503
|
+
function globsIntersect(left, right) {
|
|
79504
|
+
return parsedGlobsIntersect(parseGlobPattern(left), parseGlobPattern(right));
|
|
79505
|
+
}
|
|
79506
|
+
/**
|
|
79483
79507
|
* `globsIntersect` for two globs already parsed, optionally spending a budget
|
|
79484
79508
|
* shared with the rest of the caller's run — see `createIntersectionBudget`.
|
|
79485
79509
|
* Once that budget is exhausted every further pair answers `true` without being
|
|
@@ -80107,6 +80131,11 @@ function collectShellCommandRules(permission) {
|
|
|
80107
80131
|
function widenToPrefixGlob$1(pattern) {
|
|
80108
80132
|
return pattern.endsWith("*") ? pattern : `${pattern}*`;
|
|
80109
80133
|
}
|
|
80134
|
+
function widenForOverlap(pattern) {
|
|
80135
|
+
if (/\{[^}]*,[^}]*\}/.test(pattern)) return "*";
|
|
80136
|
+
const widened = pattern.replaceAll("**/", "*").replaceAll("/**", "*");
|
|
80137
|
+
return widened.endsWith(" *") ? `${widened.slice(0, -2)}*` : widened;
|
|
80138
|
+
}
|
|
80110
80139
|
/**
|
|
80111
80140
|
* Build the test an adapter applies to an `allow` pattern before writing it:
|
|
80112
80141
|
* which restrictions it cannot write name some of the same commands? The
|
|
@@ -80138,11 +80167,11 @@ function widenToPrefixGlob$1(pattern) {
|
|
|
80138
80167
|
function createShadowingRestrictionsTest(restrictions, { normalizePattern = (pattern) => pattern, budget = createIntersectionBudget() } = {}) {
|
|
80139
80168
|
const normalized = restrictions.map(({ pattern, fromAllToolsCategory }) => ({
|
|
80140
80169
|
pattern,
|
|
80141
|
-
glob: parseGlobPattern(fromAllToolsCategory ? pattern : normalizePattern(pattern))
|
|
80170
|
+
glob: parseGlobPattern(widenForOverlap(fromAllToolsCategory ? pattern : normalizePattern(pattern)))
|
|
80142
80171
|
}));
|
|
80143
80172
|
return (allowPattern) => {
|
|
80144
80173
|
if (budget.remaining === 0) return normalized.map(({ pattern }) => pattern);
|
|
80145
|
-
const allowGlob = parseGlobPattern(normalizePattern(allowPattern));
|
|
80174
|
+
const allowGlob = parseGlobPattern(widenForOverlap(normalizePattern(allowPattern)));
|
|
80146
80175
|
return normalized.filter(({ pattern, glob }) => pattern === allowPattern || parsedGlobsIntersect(glob, allowGlob, budget)).map(({ pattern }) => pattern);
|
|
80147
80176
|
};
|
|
80148
80177
|
}
|
|
@@ -80305,6 +80334,379 @@ function honorAllToolsOnBash(permission) {
|
|
|
80305
80334
|
bash: bashRulesHonoringAllTools(permission)
|
|
80306
80335
|
};
|
|
80307
80336
|
}
|
|
80337
|
+
// src/features/permissions/shadowed-allows.ts
|
|
80338
|
+
/** The canonical category whose patterns are URLs or domains. */
|
|
80339
|
+
const WEBFETCH_CATEGORY$2 = "webfetch";
|
|
80340
|
+
/**
|
|
80341
|
+
* A URL or domain pattern lowercased and without its scheme, so `HTTPS://Evil.example/*`
|
|
80342
|
+
* and `evil.example/*` are compared as the same host. Hosts are case-insensitive
|
|
80343
|
+
* and a scheme-less allow covers every scheme.
|
|
80344
|
+
*/
|
|
80345
|
+
function normalizeUrlPattern(pattern) {
|
|
80346
|
+
return pattern.toLowerCase().replace(/^[a-z][a-z0-9+.-]*:\/\//, "");
|
|
80347
|
+
}
|
|
80348
|
+
/**
|
|
80349
|
+
* A URL pattern with its scheme stripped and only its host lowercased, for
|
|
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 `*` 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`.
|
|
80355
|
+
*/
|
|
80356
|
+
function stripUrlSchemeKeepingPathCase(pattern) {
|
|
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) {
|
|
80379
|
+
const slash = withoutScheme.indexOf("/");
|
|
80380
|
+
return slash === -1 ? withoutScheme.toLowerCase() : `${withoutScheme.slice(0, slash).toLowerCase()}${withoutScheme.slice(slash)}`;
|
|
80381
|
+
}
|
|
80382
|
+
/** Split a scheme-less URL or domain pattern into lowercased host, port and path. */
|
|
80383
|
+
function splitUrlPattern(withoutScheme) {
|
|
80384
|
+
const normalized = withoutScheme.toLowerCase();
|
|
80385
|
+
const slash = normalized.indexOf("/");
|
|
80386
|
+
const hostPort = slash === -1 ? normalized : normalized.slice(0, slash);
|
|
80387
|
+
const path = slash === -1 ? void 0 : normalized.slice(slash);
|
|
80388
|
+
const port = /:([0-9*]+)$/.exec(hostPort);
|
|
80389
|
+
return port === null ? {
|
|
80390
|
+
host: hostPort,
|
|
80391
|
+
port: void 0,
|
|
80392
|
+
path
|
|
80393
|
+
} : {
|
|
80394
|
+
host: hostPort.slice(0, port.index),
|
|
80395
|
+
port: port[1],
|
|
80396
|
+
path
|
|
80397
|
+
};
|
|
80398
|
+
}
|
|
80399
|
+
/**
|
|
80400
|
+
* Whether two URL or domain patterns can name one URL. Both are compared
|
|
80401
|
+
* lowercased and without their scheme, part by part, so a `*` in one part
|
|
80402
|
+
* never reaches into another (`*.github.com` does not overlap
|
|
80403
|
+
* `example.org/private/*`). A pathless pattern is a host, which domain-only
|
|
80404
|
+
* tools read as every URL on it, on any port, and on its subdomains, so a
|
|
80405
|
+
* missing path or port matches every path or port, and each host also stands
|
|
80406
|
+
* for `*.<host>`. Because a glob can also match across those parts, the
|
|
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`.
|
|
80411
|
+
*/
|
|
80412
|
+
function urlPatternsOverlap(left, right) {
|
|
80413
|
+
if (left === right) return true;
|
|
80414
|
+
if (/\s/.test(left) || /\s/.test(right)) return false;
|
|
80415
|
+
return urlPartsOverlap(left, right) || wholeStringsOverlap(left, right);
|
|
80416
|
+
}
|
|
80417
|
+
/**
|
|
80418
|
+
* The whole-string comparison a `*` restriction also gets, since a glob there
|
|
80419
|
+
* matches the whole URL (`*.pdf` names `https://example.com/doc.pdf`): the two
|
|
80420
|
+
* patterns compared as written and lowercased without a scheme, each widened
|
|
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 `*`.
|
|
80428
|
+
*/
|
|
80429
|
+
function wholeStringsOverlap(left, right) {
|
|
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([{
|
|
80437
|
+
pattern: restriction,
|
|
80438
|
+
fromAllToolsCategory: false
|
|
80439
|
+
}])(allow).length > 0);
|
|
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
|
+
}
|
|
80445
|
+
function urlPartsOverlap(left, 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) {
|
|
80450
|
+
const hosts = (host) => [host, `*.${host}`];
|
|
80451
|
+
if (!hosts(a.host).some((x) => hosts(b.host).some((y) => globsIntersect(x, y)))) return false;
|
|
80452
|
+
if (a.port !== void 0 && b.port !== void 0 && !globsIntersect(a.port, b.port)) return false;
|
|
80453
|
+
return a.path === void 0 || b.path === void 0 || globsIntersect(a.path, b.path);
|
|
80454
|
+
}
|
|
80455
|
+
/**
|
|
80456
|
+
* Whether any of `restrictions` overlaps an allow pattern of `category`. For
|
|
80457
|
+
* `webfetch` the patterns are compared as URLs (see `urlPatternsOverlap`).
|
|
80458
|
+
*/
|
|
80459
|
+
function createCategoryShadowTest({ restrictions, category }) {
|
|
80460
|
+
if (category === WEBFETCH_CATEGORY$2) return (allowPattern) => restrictions.some(({ pattern }) => urlPatternsOverlap(pattern, allowPattern));
|
|
80461
|
+
const asWritten = createShadowingRestrictionsTest(restrictions);
|
|
80462
|
+
return (allowPattern) => asWritten(allowPattern).length > 0;
|
|
80463
|
+
}
|
|
80464
|
+
/** One allow rule left out of a tool's config, named as `<category>: <pattern>`. */
|
|
80465
|
+
function describeRule(category, pattern) {
|
|
80466
|
+
return `${category}: ${pattern}`;
|
|
80467
|
+
}
|
|
80468
|
+
/**
|
|
80469
|
+
* The `*` category with only its catch-all entries left, warning about the
|
|
80470
|
+
* pattern-specific ones dropped.
|
|
80471
|
+
*/
|
|
80472
|
+
function keepAllToolsCatchAll({ rules, isCatchAll, toolLabel, logger }) {
|
|
80473
|
+
const kept = {};
|
|
80474
|
+
const dropped = [];
|
|
80475
|
+
for (const [pattern, action] of Object.entries(rules)) if (isCatchAll(pattern)) kept[pattern] = action;
|
|
80476
|
+
else dropped.push(`${pattern} (${action})`);
|
|
80477
|
+
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.`);
|
|
80478
|
+
return kept;
|
|
80479
|
+
}
|
|
80480
|
+
/**
|
|
80481
|
+
* Apply the all-tools `*` category's restrictions to every other category, for
|
|
80482
|
+
* a tool that cannot write a pattern-specific rule spanning every tool.
|
|
80483
|
+
*
|
|
80484
|
+
* A `deny` or `ask` written under `*` covers every tool — `{"*": {".env":
|
|
80485
|
+
* "deny"}}` denies reading `.env` as surely as `{"read": {".env": "deny"}}`
|
|
80486
|
+
* does. A tool with no such rule would otherwise keep a `read: {"*": "allow"}`
|
|
80487
|
+
* beside it and auto-approve the very file the author denied. So:
|
|
80488
|
+
*
|
|
80489
|
+
* - `bash` gets the restrictions copied in, exactly as `honorAllToolsOnBash`
|
|
80490
|
+
* does, since a command list can carry them.
|
|
80491
|
+
* - Every other category loses each `allow` that names an input a `*`
|
|
80492
|
+
* restriction also names (see `createShadowingRestrictionsTest`); the tool
|
|
80493
|
+
* then falls back to its own prompt or default for it, the safe direction.
|
|
80494
|
+
* (AugmentCode instead applies its blanket all-tools fallback to a tool left
|
|
80495
|
+
* with no entries, since its own default would auto-run the tool.) Width
|
|
80496
|
+
* does not matter: a shell-only `{"*": {"git push *": "ask"}}` withholds a
|
|
80497
|
+
* `read: {"*": "allow"}` too, because the catch-all names every input.
|
|
80498
|
+
* - With `dropAllToolsPatterns`, the pattern-specific entries of `*` itself are
|
|
80499
|
+
* removed, for a tool that would otherwise write them as an inert literal
|
|
80500
|
+
* `*(<pattern>)` rule. They are honored by the withholding above.
|
|
80501
|
+
*
|
|
80502
|
+
* `restateAs` says which pattern-specific `*` restrictions the tool can write
|
|
80503
|
+
* as a rule of the category itself (`Read(.env)`), for a tool whose default for
|
|
80504
|
+
* an input with no rule would auto-approve it: such a restriction is copied
|
|
80505
|
+
* into each stated category it applies to (see `restatesAsCategoryRule`), so
|
|
80506
|
+
* the input stays restricted after its allow is withheld.
|
|
80507
|
+
* `downgradeWithheldCatchAll` writes a withheld catch-all `*` allow as `ask`
|
|
80508
|
+
* (`deny` under a catch-all `*` deny) rather than dropping it, for a tool that keeps a stale `always` otherwise.
|
|
80509
|
+
*
|
|
80510
|
+
* `writesAllToolsCatchAll` says the tool already enforces a `*` catch-all
|
|
80511
|
+
* (`{"*": {"*": "ask"}}`) natively over its per-tool allows, so the catch-all
|
|
80512
|
+
* is left out of the withholding. `isCatchAll` says which spellings the tool
|
|
80513
|
+
* reads as that catch-all (by default only `*`).
|
|
80514
|
+
*
|
|
80515
|
+
* Every withheld allow is named in one warning.
|
|
80516
|
+
*/
|
|
80517
|
+
function honorAllToolsRestrictions({ permission, toolLabel, logger, writesAllToolsCatchAll = false, dropAllToolsPatterns = false, isCatchAll = (pattern) => pattern === "*", restateAs = () => false, downgradeWithheldCatchAll = false }) {
|
|
80518
|
+
const allToolsRules = Object.hasOwn(permission, "*") ? permission["*"] : void 0;
|
|
80519
|
+
if (allToolsRules === void 0) return permission;
|
|
80520
|
+
const restrictions = Object.entries(allToolsRules).filter(([pattern, action]) => action !== "allow" && !isPrototypePollutionKey(pattern) && !(writesAllToolsCatchAll && isCatchAll(pattern))).map(([pattern]) => ({
|
|
80521
|
+
pattern,
|
|
80522
|
+
fromAllToolsCategory: true
|
|
80523
|
+
}));
|
|
80524
|
+
const result = {};
|
|
80525
|
+
const withheld = [];
|
|
80526
|
+
for (const [category, rules] of Object.entries(permission)) {
|
|
80527
|
+
if (category === "*") {
|
|
80528
|
+
const kept = dropAllToolsPatterns ? keepAllToolsCatchAll({
|
|
80529
|
+
rules,
|
|
80530
|
+
isCatchAll,
|
|
80531
|
+
toolLabel,
|
|
80532
|
+
logger
|
|
80533
|
+
}) : rules;
|
|
80534
|
+
if (!dropAllToolsPatterns || Object.keys(kept).length > 0) result[category] = kept;
|
|
80535
|
+
continue;
|
|
80536
|
+
}
|
|
80537
|
+
if (restrictions.length === 0) {
|
|
80538
|
+
result[category] = rules;
|
|
80539
|
+
continue;
|
|
80540
|
+
}
|
|
80541
|
+
if (category === "bash") {
|
|
80542
|
+
const bash = bashRulesHonoringAllTools({
|
|
80543
|
+
...permission,
|
|
80544
|
+
["*"]: Object.fromEntries(restrictions.map(({ pattern }) => [pattern, allToolsRules[pattern] ?? "deny"]))
|
|
80545
|
+
});
|
|
80546
|
+
for (const [pattern, action] of Object.entries(rules)) if (action === "allow" && bash[pattern] !== "allow") withheld.push(describeRule(category, pattern));
|
|
80547
|
+
result[category] = bash;
|
|
80548
|
+
continue;
|
|
80549
|
+
}
|
|
80550
|
+
result[category] = honorInCategory({
|
|
80551
|
+
category,
|
|
80552
|
+
rules,
|
|
80553
|
+
restrictions: restrictions.map(({ pattern }) => ({
|
|
80554
|
+
pattern,
|
|
80555
|
+
action: allToolsRules[pattern] ?? "deny"
|
|
80556
|
+
})),
|
|
80557
|
+
restateAs,
|
|
80558
|
+
downgradeWithheldCatchAll,
|
|
80559
|
+
withheld
|
|
80560
|
+
});
|
|
80561
|
+
}
|
|
80562
|
+
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.`);
|
|
80563
|
+
return result;
|
|
80564
|
+
}
|
|
80565
|
+
/** File categories whose patterns are paths. */
|
|
80566
|
+
const PATH_CATEGORIES = /* @__PURE__ */ new Set([
|
|
80567
|
+
"read",
|
|
80568
|
+
"edit",
|
|
80569
|
+
"write"
|
|
80570
|
+
]);
|
|
80571
|
+
/**
|
|
80572
|
+
* The common `restateAs`: a restriction is restated under a path category when
|
|
80573
|
+
* it reads as a path (no whitespace, so not a command such as `git push *`),
|
|
80574
|
+
* and under `webfetch` when it reads as a URL or domain. `actions` limits it to
|
|
80575
|
+
* the actions the tool can write per pattern.
|
|
80576
|
+
*/
|
|
80577
|
+
function restatesAsCategoryRule(actions = ["deny", "ask"]) {
|
|
80578
|
+
return ({ category, pattern, action }) => {
|
|
80579
|
+
if (!actions.includes(action) || pattern === "*") return false;
|
|
80580
|
+
if (PATH_CATEGORIES.has(category)) return !/\s/.test(pattern);
|
|
80581
|
+
if (category === WEBFETCH_CATEGORY$2) return /^([a-z][a-z0-9+.-]*:\/\/)?[\w*-]+(\.[\w*-]+)+(:[\w*]+)?(\/\S*)?$/i.test(pattern);
|
|
80582
|
+
return false;
|
|
80583
|
+
};
|
|
80584
|
+
}
|
|
80585
|
+
/** One non-shell category with the `*` restrictions honored; see the caller. */
|
|
80586
|
+
function honorInCategory({ category, rules, restrictions, restateAs, downgradeWithheldCatchAll, withheld }) {
|
|
80587
|
+
const shadowingRestrictions = createCategoryShadowTest({
|
|
80588
|
+
restrictions: restrictions.map(({ pattern }) => ({
|
|
80589
|
+
pattern,
|
|
80590
|
+
fromAllToolsCategory: true
|
|
80591
|
+
})),
|
|
80592
|
+
category
|
|
80593
|
+
});
|
|
80594
|
+
const downgradedAction = restrictions.some(({ pattern, action }) => pattern === "*" && action === "deny") ? "deny" : "ask";
|
|
80595
|
+
const kept = {};
|
|
80596
|
+
for (const [pattern, action] of Object.entries(rules)) {
|
|
80597
|
+
if (action === "allow" && shadowingRestrictions(pattern)) {
|
|
80598
|
+
withheld.push(describeRule(category, pattern));
|
|
80599
|
+
if (downgradeWithheldCatchAll && pattern === "*") kept[pattern] = downgradedAction;
|
|
80600
|
+
continue;
|
|
80601
|
+
}
|
|
80602
|
+
kept[pattern] = action;
|
|
80603
|
+
}
|
|
80604
|
+
return restateInCategory({
|
|
80605
|
+
category,
|
|
80606
|
+
rules: kept,
|
|
80607
|
+
restrictions,
|
|
80608
|
+
restateAs
|
|
80609
|
+
});
|
|
80610
|
+
}
|
|
80611
|
+
function restateInCategory({ category, rules, restrictions, restateAs }) {
|
|
80612
|
+
const restated = { ...rules };
|
|
80613
|
+
for (const { pattern, action } of restrictions) {
|
|
80614
|
+
if (isPrototypePollutionKey(pattern) || !restateAs({
|
|
80615
|
+
category,
|
|
80616
|
+
pattern,
|
|
80617
|
+
action
|
|
80618
|
+
})) continue;
|
|
80619
|
+
if (isStricterAction({
|
|
80620
|
+
action,
|
|
80621
|
+
existing: Object.hasOwn(restated, pattern) ? restated[pattern] : void 0
|
|
80622
|
+
})) restated[pattern] = action;
|
|
80623
|
+
}
|
|
80624
|
+
return restated;
|
|
80625
|
+
}
|
|
80626
|
+
/**
|
|
80627
|
+
* One category's rules with the pattern-specific `*` restrictions `restateAs`
|
|
80628
|
+
* accepts copied in as its own rules (the stricter action wins on a shared
|
|
80629
|
+
* spelling), for a tool that can write them there and needs no allow
|
|
80630
|
+
* withheld, because its own ordering already lets the copied rule win.
|
|
80631
|
+
*/
|
|
80632
|
+
function restateAllToolsRestrictionsInCategory({ permission, category, restateAs }) {
|
|
80633
|
+
const rules = lookupOwn({
|
|
80634
|
+
record: permission,
|
|
80635
|
+
key: category
|
|
80636
|
+
}) ?? {};
|
|
80637
|
+
const allToolsRules = lookupOwn({
|
|
80638
|
+
record: permission,
|
|
80639
|
+
key: "*"
|
|
80640
|
+
}) ?? {};
|
|
80641
|
+
return restateInCategory({
|
|
80642
|
+
category,
|
|
80643
|
+
rules,
|
|
80644
|
+
restrictions: Object.entries(allToolsRules).filter(([, action]) => action !== "allow").map(([pattern, action]) => ({
|
|
80645
|
+
pattern,
|
|
80646
|
+
action
|
|
80647
|
+
})),
|
|
80648
|
+
restateAs
|
|
80649
|
+
});
|
|
80650
|
+
}
|
|
80651
|
+
/**
|
|
80652
|
+
* Withhold every `allow` that an `ask` the tool cannot write also covers, for a
|
|
80653
|
+
* tool with no ask tier on some surface.
|
|
80654
|
+
*
|
|
80655
|
+
* Such a tool prompts for whatever it does not auto-approve, so skipping the
|
|
80656
|
+
* `ask` alone is right — but only if no `allow` beside it auto-approves the
|
|
80657
|
+
* same input. The canonical order is `deny > ask > allow`, so `{"git *":
|
|
80658
|
+
* "allow", "git push *": "ask"}` must not leave `git *` auto-approved.
|
|
80659
|
+
*
|
|
80660
|
+
* Within each group (categories the tool folds into one surface share a group;
|
|
80661
|
+
* by default each category is its own), a pattern-specific `allow` an `ask`
|
|
80662
|
+
* overlaps is removed. A catch-all `*` `allow` is downgraded to `ask` instead,
|
|
80663
|
+
* so a tool that has a coarse prompting default for the whole surface (Vibe's
|
|
80664
|
+
* `permission = "ask"`) uses it; a tool that skips `ask` drops it either way.
|
|
80665
|
+
*
|
|
80666
|
+
* `isSkippedAsk` picks the `ask` rules the tool cannot write (by default every
|
|
80667
|
+
* one). Every withheld allow is named in one warning.
|
|
80668
|
+
*/
|
|
80669
|
+
function withholdAllowsShadowedByAsks({ permission, toolLabel, logger, isSkippedAsk = () => true, groupOf = (category) => category }) {
|
|
80670
|
+
const asksByGroup = /* @__PURE__ */ new Map();
|
|
80671
|
+
for (const [category, rules] of Object.entries(permission)) for (const [pattern, action] of Object.entries(rules)) {
|
|
80672
|
+
if (action !== "ask" || isPrototypePollutionKey(pattern)) continue;
|
|
80673
|
+
if (!isSkippedAsk({
|
|
80674
|
+
category,
|
|
80675
|
+
pattern
|
|
80676
|
+
})) continue;
|
|
80677
|
+
const group = groupOf(category);
|
|
80678
|
+
asksByGroup.set(group, [...asksByGroup.get(group) ?? [], pattern]);
|
|
80679
|
+
}
|
|
80680
|
+
if (asksByGroup.size === 0) return permission;
|
|
80681
|
+
const result = {};
|
|
80682
|
+
const withheld = [];
|
|
80683
|
+
for (const [category, rules] of Object.entries(permission)) {
|
|
80684
|
+
const asks = asksByGroup.get(groupOf(category));
|
|
80685
|
+
if (asks === void 0) {
|
|
80686
|
+
result[category] = rules;
|
|
80687
|
+
continue;
|
|
80688
|
+
}
|
|
80689
|
+
const shadowingAsks = createCategoryShadowTest({
|
|
80690
|
+
restrictions: asks.map((pattern) => ({
|
|
80691
|
+
pattern,
|
|
80692
|
+
fromAllToolsCategory: false
|
|
80693
|
+
})),
|
|
80694
|
+
category
|
|
80695
|
+
});
|
|
80696
|
+
const kept = {};
|
|
80697
|
+
for (const [pattern, action] of Object.entries(rules)) {
|
|
80698
|
+
if (action !== "allow" || !shadowingAsks(pattern)) {
|
|
80699
|
+
kept[pattern] = action;
|
|
80700
|
+
continue;
|
|
80701
|
+
}
|
|
80702
|
+
withheld.push(describeRule(category, pattern));
|
|
80703
|
+
if (pattern === "*") kept[pattern] = "ask";
|
|
80704
|
+
}
|
|
80705
|
+
result[category] = kept;
|
|
80706
|
+
}
|
|
80707
|
+
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.`);
|
|
80708
|
+
return result;
|
|
80709
|
+
}
|
|
80308
80710
|
// src/features/permissions/tool-pattern-entry.ts
|
|
80309
80711
|
/**
|
|
80310
80712
|
* Parse a `Tool(pattern)` permission entry (e.g. `Bash(npm run *)`) into its
|
|
@@ -80390,7 +80792,7 @@ const MATCH_ALL_PATH_GLOBS = /* @__PURE__ */ new Set([
|
|
|
80390
80792
|
"**/*"
|
|
80391
80793
|
]);
|
|
80392
80794
|
const DIRECTORY_CONTENTS_SUFFIX = /\/\*\*(?:\/\*)?$/;
|
|
80393
|
-
const HOME_OR_VARIABLE_PATH = /^~(
|
|
80795
|
+
const HOME_OR_VARIABLE_PATH = /^~(?:[A-Za-z_][\w.-]*)?(?:[/\\]|$)|^\$[A-Za-z_]|^%[A-Za-z_][\w() ]*%|\$\{[A-Za-z_]/;
|
|
80394
80796
|
const LEADING_HOME = /^~(?:\/|$)/;
|
|
80395
80797
|
/**
|
|
80396
80798
|
* The home directory as an Antigravity path: forward slashes, no trailing
|
|
@@ -80404,8 +80806,8 @@ function toAntigravityHomePath(homeDirectory) {
|
|
|
80404
80806
|
* directory. agy 1.5.1 matches `~` literally, so a `~/...` rule would never
|
|
80405
80807
|
* apply (rulesync#3324). Only a file the user's own home holds, such as the
|
|
80406
80808
|
* global Antigravity CLI settings, may carry a machine-specific path, so the
|
|
80407
|
-
* caller passes `homeDirectory` only then. `$HOME`, `${HOME}`, `%VAR
|
|
80408
|
-
* `~user/` are left as written
|
|
80809
|
+
* caller passes `homeDirectory` only then. `$HOME`, `${HOME}`, `%VAR%`, `~\`,
|
|
80810
|
+
* `~user` and `~user/` are left as written and still warned about.
|
|
80409
80811
|
*/
|
|
80410
80812
|
function expandLeadingHome(target, homeDirectory) {
|
|
80411
80813
|
if (homeDirectory === void 0 || !LEADING_HOME.test(target)) return target;
|
|
@@ -80647,30 +81049,84 @@ function convertRulesyncToAntigravityPermissions({ config, toAction, toolLabel,
|
|
|
80647
81049
|
const allow = [];
|
|
80648
81050
|
const ask = [];
|
|
80649
81051
|
const deny = [];
|
|
80650
|
-
|
|
81052
|
+
const permission = honorAllToolsRestrictions({
|
|
81053
|
+
permission: config.permission,
|
|
81054
|
+
toolLabel,
|
|
81055
|
+
logger
|
|
81056
|
+
});
|
|
81057
|
+
const translated = [];
|
|
81058
|
+
for (const [category, rules] of Object.entries(permission)) {
|
|
80651
81059
|
const action = toAction(category);
|
|
80652
|
-
for (const [pattern,
|
|
81060
|
+
for (const [pattern, decision] of Object.entries(rules)) {
|
|
80653
81061
|
const entry = buildAntigravityPermissionEntry({
|
|
80654
81062
|
action,
|
|
80655
81063
|
category,
|
|
80656
81064
|
pattern,
|
|
80657
|
-
decision
|
|
81065
|
+
decision,
|
|
80658
81066
|
logger,
|
|
80659
81067
|
toolLabel,
|
|
80660
81068
|
homeDirectory
|
|
80661
81069
|
});
|
|
80662
|
-
|
|
80663
|
-
|
|
80664
|
-
|
|
80665
|
-
|
|
80666
|
-
|
|
80667
|
-
|
|
80668
|
-
|
|
81070
|
+
translated.push({
|
|
81071
|
+
action,
|
|
81072
|
+
category,
|
|
81073
|
+
pattern,
|
|
81074
|
+
decision,
|
|
81075
|
+
entry
|
|
81076
|
+
});
|
|
81077
|
+
}
|
|
81078
|
+
}
|
|
81079
|
+
const skippedRestrictionsByAction = /* @__PURE__ */ new Map();
|
|
81080
|
+
const groupOf = ({ action, category }) => category.startsWith("mcp__") ? category : action;
|
|
81081
|
+
for (const { action, category, pattern, decision, entry } of translated) if (entry === void 0 && decision !== "allow") {
|
|
81082
|
+
const group = groupOf({
|
|
81083
|
+
action,
|
|
81084
|
+
category
|
|
81085
|
+
});
|
|
81086
|
+
skippedRestrictionsByAction.set(group, [...skippedRestrictionsByAction.get(group) ?? [], pattern]);
|
|
81087
|
+
}
|
|
81088
|
+
const allToolsRestrictions = Object.entries(lookupOwn({
|
|
81089
|
+
record: config.permission,
|
|
81090
|
+
key: "*"
|
|
81091
|
+
}) ?? {}).filter(([pattern, decision]) => decision !== "allow" && pattern !== "*" && !isPrototypePollutionKey(pattern)).map(([pattern]) => pattern);
|
|
81092
|
+
const shadowingTests = /* @__PURE__ */ new Map();
|
|
81093
|
+
const shadowingTestOf = (group) => {
|
|
81094
|
+
const cached = shadowingTests.get(group);
|
|
81095
|
+
if (cached !== void 0) return cached;
|
|
81096
|
+
const patterns = [...skippedRestrictionsByAction.get(group) ?? [], ...allToolsRestrictions];
|
|
81097
|
+
let test;
|
|
81098
|
+
if (URL_ACTIONS.has(group)) test = (allowPattern) => patterns.some((pattern) => urlPatternsOverlap(pattern, allowPattern));
|
|
81099
|
+
else {
|
|
81100
|
+
const asGlobs = createShadowingRestrictionsTest([.../* @__PURE__ */ new Set([...patterns, ...patterns.map(normalizeUrlPattern)])].map((pattern) => ({
|
|
81101
|
+
pattern,
|
|
81102
|
+
fromAllToolsCategory: false
|
|
81103
|
+
})));
|
|
81104
|
+
test = (allowPattern) => asGlobs(allowPattern).length > 0 || asGlobs(normalizeUrlPattern(allowPattern)).length > 0;
|
|
81105
|
+
}
|
|
81106
|
+
shadowingTests.set(group, test);
|
|
81107
|
+
return test;
|
|
81108
|
+
};
|
|
81109
|
+
const withheld = [];
|
|
81110
|
+
for (const { action, category, pattern, decision, entry } of translated) {
|
|
81111
|
+
if (entry === void 0) continue;
|
|
81112
|
+
switch (decision) {
|
|
81113
|
+
case "allow":
|
|
81114
|
+
if ([pattern, effectiveTargetScope(entry)].some((candidate) => shadowingTestOf(groupOf({
|
|
81115
|
+
action,
|
|
81116
|
+
category
|
|
81117
|
+
}))(candidate))) {
|
|
81118
|
+
withheld.push(`${category}: ${pattern}`);
|
|
80669
81119
|
break;
|
|
80670
|
-
|
|
80671
|
-
|
|
81120
|
+
}
|
|
81121
|
+
allow.push(entry);
|
|
81122
|
+
break;
|
|
81123
|
+
case "ask":
|
|
81124
|
+
ask.push(entry);
|
|
81125
|
+
break;
|
|
81126
|
+
case "deny": deny.push(entry);
|
|
80672
81127
|
}
|
|
80673
81128
|
}
|
|
81129
|
+
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.`);
|
|
80674
81130
|
return {
|
|
80675
81131
|
allow: [...new Set(allow)],
|
|
80676
81132
|
ask: [...new Set(ask)],
|
|
@@ -80678,6 +81134,24 @@ function convertRulesyncToAntigravityPermissions({ config, toAction, toolLabel,
|
|
|
80678
81134
|
};
|
|
80679
81135
|
}
|
|
80680
81136
|
/**
|
|
81137
|
+
* The widest glob an emitted entry grants, for comparing an allow against the
|
|
81138
|
+
* restrictions Antigravity cannot express. The emitted target can grant more
|
|
81139
|
+
* than the canonical pattern it came from: a path target also covers
|
|
81140
|
+
* everything inside it (and `.` the whole workspace), a command target is a
|
|
81141
|
+
* word prefix (`git push` approves `git push --force`), and a domain target
|
|
81142
|
+
* covers its subdomains and every URL on it. Widening only ever withholds more.
|
|
81143
|
+
*/
|
|
81144
|
+
function effectiveTargetScope(entry) {
|
|
81145
|
+
const { toolName, pattern: target } = parseToolPatternEntry(entry);
|
|
81146
|
+
if (target === "*") return "*";
|
|
81147
|
+
if (PATH_ACTIONS.has(toolName)) {
|
|
81148
|
+
const path = target.replace(/\/+$/, "");
|
|
81149
|
+
return path === "." || path === "" ? "*" : `${path}/**`;
|
|
81150
|
+
}
|
|
81151
|
+
if (ANTIGRAVITY_COMMAND_ACTIONS.has(toolName)) return target.endsWith("*") ? target : `${target}*`;
|
|
81152
|
+
return target;
|
|
81153
|
+
}
|
|
81154
|
+
/**
|
|
80681
81155
|
* Convert Antigravity allow/ask/deny arrays to rulesync permissions config,
|
|
80682
81156
|
* shared by the CLI and IDE adapters; `toCategory` maps the target's tool or
|
|
80683
81157
|
* action name back to a canonical category.
|
|
@@ -81578,15 +82052,21 @@ async function withBaseEnabledPlugins({ mergedContent, baseFilePath }) {
|
|
|
81578
82052
|
function convertRulesyncToAugmentEntries({ config, logger }) {
|
|
81579
82053
|
const entries = [];
|
|
81580
82054
|
const resolvedBashRules = bashRulesHonoringAllTools(config.permission);
|
|
82055
|
+
const honoredPermission = honorAllToolsRestrictions({
|
|
82056
|
+
permission: config.permission,
|
|
82057
|
+
toolLabel: "AugmentCode",
|
|
82058
|
+
logger,
|
|
82059
|
+
writesAllToolsCatchAll: true
|
|
82060
|
+
});
|
|
81581
82061
|
const permission = config.permission.bash !== void 0 || Object.keys(resolvedBashRules).length > 0 ? {
|
|
81582
|
-
...
|
|
82062
|
+
...honoredPermission,
|
|
81583
82063
|
bash: resolvedBashRules
|
|
81584
|
-
} :
|
|
82064
|
+
} : honoredPermission;
|
|
81585
82065
|
const allToolsFailClosedType = computeAllToolsFailClosedType(config.permission["*"]);
|
|
81586
82066
|
const categoriesWithOwnEntries = /* @__PURE__ */ new Set();
|
|
81587
82067
|
for (const [category, rules] of Object.entries(permission)) {
|
|
81588
82068
|
if (category === "*") {
|
|
81589
|
-
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
|
|
82069
|
+
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.");
|
|
81590
82070
|
continue;
|
|
81591
82071
|
}
|
|
81592
82072
|
const augmentToolName = toAugmentToolName(category);
|
|
@@ -81645,9 +82125,10 @@ function computeAllToolsFailClosedType(allToolsRules) {
|
|
|
81645
82125
|
* other managed tools: one that produced no entries of its own above must not fall back to
|
|
81646
82126
|
* AugmentCode's own default just because it has no per-input matcher to narrow the all-tools
|
|
81647
82127
|
* restriction onto. A category can be stated yet still emit nothing (e.g. only non-`*` allow/ask
|
|
81648
|
-
* patterns, dropped with a warning
|
|
81649
|
-
*
|
|
81650
|
-
*
|
|
82128
|
+
* patterns, dropped with a warning, or only allows withheld by `honorAllToolsRestrictions`), so
|
|
82129
|
+
* this checks emitted entries rather than whether the category was merely present in the source
|
|
82130
|
+
* config. Falling back to AugmentCode's own default instead would let a read-only tool run on the
|
|
82131
|
+
* input the restriction names. A tool whose own rules did emit entries is left untouched here.
|
|
81651
82132
|
*/
|
|
81652
82133
|
function synthesizeManagedToolFallbackEntries(categoriesWithOwnEntries, allToolsFailClosedType) {
|
|
81653
82134
|
if (allToolsFailClosedType === void 0) return [];
|
|
@@ -84111,8 +84592,10 @@ function categoryOfRule$2(rule) {
|
|
|
84111
84592
|
* - MCP rules take no specifier, so a scoped `mcp__<...>` category is written
|
|
84112
84593
|
* for its catch-all pattern only.
|
|
84113
84594
|
* - The all-tools `*` category is CodeBuddy's documented standalone `*` rule
|
|
84114
|
-
* for its catch-all pattern.
|
|
84115
|
-
*
|
|
84595
|
+
* for its catch-all pattern. A narrower `*` pattern reaches the `Bash`
|
|
84596
|
+
* rules through `honorAllToolsRestrictions`, which also withholds every
|
|
84597
|
+
* allow it overlaps in the other categories — a `{"*": "allow"}` included,
|
|
84598
|
+
* even for a shell-only pattern such as `git push *`.
|
|
84116
84599
|
*/
|
|
84117
84600
|
function buildCodebuddyRule({ category, pattern, action, logger }) {
|
|
84118
84601
|
const catchAll = pattern === "*";
|
|
@@ -84160,7 +84643,13 @@ function parseCodebuddyRule(rule) {
|
|
|
84160
84643
|
* manage (and every entry rulesync cannot parse).
|
|
84161
84644
|
*/
|
|
84162
84645
|
function buildCodebuddyRuleLists({ config, existingPermissions, logger }) {
|
|
84163
|
-
const permission =
|
|
84646
|
+
const permission = honorAllToolsRestrictions({
|
|
84647
|
+
permission: config.permission,
|
|
84648
|
+
toolLabel: "CodeBuddy",
|
|
84649
|
+
logger,
|
|
84650
|
+
restateAs: restatesAsCategoryRule(),
|
|
84651
|
+
writesAllToolsCatchAll: true
|
|
84652
|
+
});
|
|
84164
84653
|
const ranked = /* @__PURE__ */ new Map();
|
|
84165
84654
|
const managedCategories = /* @__PURE__ */ new Set();
|
|
84166
84655
|
for (const [category, rules] of Object.entries(permission)) {
|
|
@@ -85755,6 +86244,44 @@ function addCodexWebfetchRules({ rules, domains, logger }) {
|
|
|
85755
86244
|
domains[pattern] = action;
|
|
85756
86245
|
}
|
|
85757
86246
|
}
|
|
86247
|
+
/**
|
|
86248
|
+
* Copy the all-tools `*` path restrictions into the `read` rules, when the
|
|
86249
|
+
* config states a filesystem category at all: Codex has no all-tools rule, so
|
|
86250
|
+
* `{"*": {".env": "deny"}, "edit": {"*": "allow"}}` would otherwise grant
|
|
86251
|
+
* write access to `.env`. Both a `deny` and an `ask` land under `read`, where
|
|
86252
|
+
* they are handled exactly like a directly written read rule (an ask becomes
|
|
86253
|
+
* `"deny"`, since Codex cannot prompt for a path), so a narrower write allow
|
|
86254
|
+
* they cover is denied as well. A catch-all `*` deny is copied too and
|
|
86255
|
+
* withholds every filesystem allow, so `{"*": {"*": "deny"}, "edit": {"src":
|
|
86256
|
+
* "allow"}}` grants nothing; a catch-all
|
|
86257
|
+
* ask is the documented default idiom and is left alone. Other patterns are
|
|
86258
|
+
* copied only when they read as a path — `git push *` is a command, not a
|
|
86259
|
+
* path — so the sandbox gains nothing but these restrictions.
|
|
86260
|
+
*/
|
|
86261
|
+
function restateAllToolsPathRestrictions({ config, filesystemCategoryRules }) {
|
|
86262
|
+
if (Object.keys(filesystemCategoryRules).length === 0) return;
|
|
86263
|
+
if (lookupOwn({
|
|
86264
|
+
record: config.permission,
|
|
86265
|
+
key: "*"
|
|
86266
|
+
})?.["*"] === "deny") for (const category of [
|
|
86267
|
+
"read",
|
|
86268
|
+
"edit",
|
|
86269
|
+
"write"
|
|
86270
|
+
]) {
|
|
86271
|
+
const rules = filesystemCategoryRules[category];
|
|
86272
|
+
if (rules === void 0) continue;
|
|
86273
|
+
filesystemCategoryRules[category] = Object.fromEntries(Object.entries(rules).filter(([, action]) => action !== "allow"));
|
|
86274
|
+
}
|
|
86275
|
+
const isPath = restatesAsCategoryRule(["deny", "ask"]);
|
|
86276
|
+
filesystemCategoryRules.read = restateAllToolsRestrictionsInCategory({
|
|
86277
|
+
permission: {
|
|
86278
|
+
...config.permission,
|
|
86279
|
+
read: filesystemCategoryRules.read ?? {}
|
|
86280
|
+
},
|
|
86281
|
+
category: "read",
|
|
86282
|
+
restateAs: (params) => params.pattern === "*" ? params.action === "deny" : isPath(params)
|
|
86283
|
+
});
|
|
86284
|
+
}
|
|
85758
86285
|
function convertRulesyncToCodexProfile({ config, logger }) {
|
|
85759
86286
|
const filesystem = { [CODEX_MINIMAL_KEY]: "read" };
|
|
85760
86287
|
const workspaceRootFilesystem = {};
|
|
@@ -85766,8 +86293,24 @@ function convertRulesyncToCodexProfile({ config, logger }) {
|
|
|
85766
86293
|
continue;
|
|
85767
86294
|
}
|
|
85768
86295
|
if (toolName === "webfetch") {
|
|
86296
|
+
const allToolsRules = lookupOwn({
|
|
86297
|
+
record: config.permission,
|
|
86298
|
+
key: "*"
|
|
86299
|
+
});
|
|
86300
|
+
const { webfetch: webfetchRules = {} } = withholdAllowsShadowedByAsks({
|
|
86301
|
+
permission: { webfetch: honorAllToolsRestrictions({
|
|
86302
|
+
permission: allToolsRules === void 0 ? { webfetch: rules } : {
|
|
86303
|
+
["*"]: allToolsRules,
|
|
86304
|
+
webfetch: rules
|
|
86305
|
+
},
|
|
86306
|
+
toolLabel: "Codex CLI network domains",
|
|
86307
|
+
logger
|
|
86308
|
+
}).webfetch ?? {} },
|
|
86309
|
+
toolLabel: "Codex CLI network domains",
|
|
86310
|
+
logger
|
|
86311
|
+
});
|
|
85769
86312
|
addCodexWebfetchRules({
|
|
85770
|
-
rules,
|
|
86313
|
+
rules: webfetchRules,
|
|
85771
86314
|
domains,
|
|
85772
86315
|
logger
|
|
85773
86316
|
});
|
|
@@ -85776,6 +86319,10 @@ function convertRulesyncToCodexProfile({ config, logger }) {
|
|
|
85776
86319
|
if (toolName === "bash") continue;
|
|
85777
86320
|
logger?.warn(`Codex CLI permission profiles support only read/edit/write/webfetch categories (bash goes to .codex/rules/rulesync.rules). Skipping: ${toolName}`);
|
|
85778
86321
|
}
|
|
86322
|
+
restateAllToolsPathRestrictions({
|
|
86323
|
+
config,
|
|
86324
|
+
filesystemCategoryRules
|
|
86325
|
+
});
|
|
85779
86326
|
addCodexFilesystemRules({
|
|
85780
86327
|
categoryRules: filesystemCategoryRules,
|
|
85781
86328
|
filesystem,
|
|
@@ -86519,8 +87066,10 @@ const PADDED_SHELL_WILDCARD_REASON = "a pattern narrower than the bare 'Shell' (
|
|
|
86519
87066
|
* server or tool). A pattern on an MCP category is still written as the
|
|
86520
87067
|
* `(specifier)` here; `writableCommandcodeRule` decides what to do with it,
|
|
86521
87068
|
* because Command Code ignores it. The all-tools `*` category is only
|
|
86522
|
-
* written for its catch-all pattern; narrower `*`
|
|
86523
|
-
*
|
|
87069
|
+
* written for its catch-all pattern; a narrower `*` pattern reaches the `Shell`
|
|
87070
|
+
* entries through `honorAllToolsRestrictions`, which also withholds every allow
|
|
87071
|
+
* it overlaps in the other categories — a `{"*": "allow"}` included, even for a
|
|
87072
|
+
* shell-only pattern such as `git push *`.
|
|
86524
87073
|
*/
|
|
86525
87074
|
function buildCommandcodeRule(category, pattern) {
|
|
86526
87075
|
const catchAll = pattern === "*" || pattern === "";
|
|
@@ -86814,7 +87363,13 @@ function rankCommandcodeRule({ ranked, rule, action, logger }) {
|
|
|
86814
87363
|
* rewritten by `writableCommandcodeRule`.
|
|
86815
87364
|
*/
|
|
86816
87365
|
function buildCommandcodeRuleLists({ config, existingPermissions, logger }) {
|
|
86817
|
-
const permission =
|
|
87366
|
+
const permission = honorAllToolsRestrictions({
|
|
87367
|
+
permission: config.permission,
|
|
87368
|
+
toolLabel: "Command Code",
|
|
87369
|
+
logger,
|
|
87370
|
+
restateAs: restatesAsCategoryRule(),
|
|
87371
|
+
writesAllToolsCatchAll: true
|
|
87372
|
+
});
|
|
86818
87373
|
const ranked = /* @__PURE__ */ new Map();
|
|
86819
87374
|
const managedCategories = /* @__PURE__ */ new Set();
|
|
86820
87375
|
for (const [category, rules] of Object.entries(permission)) {
|
|
@@ -87274,7 +87829,13 @@ function convertRulesyncToContinuePermissions({ config, logger }) {
|
|
|
87274
87829
|
allow: []
|
|
87275
87830
|
};
|
|
87276
87831
|
const actionByEntry = /* @__PURE__ */ new Map();
|
|
87277
|
-
for (const [category, rules] of Object.entries(
|
|
87832
|
+
for (const [category, rules] of Object.entries(honorAllToolsRestrictions({
|
|
87833
|
+
permission: config.permission,
|
|
87834
|
+
toolLabel: "Continue",
|
|
87835
|
+
logger,
|
|
87836
|
+
writesAllToolsCatchAll: true,
|
|
87837
|
+
isCatchAll: (pattern) => normalizeCatchAllPattern$1(pattern) === "*"
|
|
87838
|
+
}))) {
|
|
87278
87839
|
if (isPrototypePollutionKey(category)) continue;
|
|
87279
87840
|
const toolName = category === "*" ? "*" : toContinueToolName(category);
|
|
87280
87841
|
for (const [rawPattern, action] of Object.entries(rules)) {
|
|
@@ -87646,6 +88207,58 @@ function asAutoApproveMap(value) {
|
|
|
87646
88207
|
return result;
|
|
87647
88208
|
}
|
|
87648
88209
|
/**
|
|
88210
|
+
* The edits or urls map's rules with the all-tools `*` restrictions honored.
|
|
88211
|
+
* A restriction that reads as a path (edits) or URL (urls), and the catch-all
|
|
88212
|
+
* `*`, is written as a `false` entry of its own, which `buildAutoApproveValue`
|
|
88213
|
+
* places where it wins; a URL is written without its scheme and with only its host lowercased,
|
|
88214
|
+
* since VS Code matches paths case-sensitively.
|
|
88215
|
+
* Every other restriction (a command, an odd URL pattern) cannot be written
|
|
88216
|
+
* there, so each `true` entry it overlaps is withheld instead.
|
|
88217
|
+
*/
|
|
88218
|
+
function honorCopilotAllToolsRestrictions({ permission, category, logger }) {
|
|
88219
|
+
const allToolsRules = lookupOwn({
|
|
88220
|
+
record: permission,
|
|
88221
|
+
key: "*"
|
|
88222
|
+
}) ?? {};
|
|
88223
|
+
const isWritable = restatesAsCategoryRule();
|
|
88224
|
+
const restateAs = (params) => params.pattern === "*" || isWritable(params) && !(params.category === "webfetch" && hasDoubleSlashWithoutScheme(params.pattern));
|
|
88225
|
+
const writable = {};
|
|
88226
|
+
const notWritable = {};
|
|
88227
|
+
for (const [pattern, action] of Object.entries(allToolsRules)) {
|
|
88228
|
+
if (action === "allow") continue;
|
|
88229
|
+
if (restateAs({
|
|
88230
|
+
category,
|
|
88231
|
+
pattern,
|
|
88232
|
+
action
|
|
88233
|
+
})) {
|
|
88234
|
+
const key = category === "webfetch" && pattern !== "*" ? stripUrlSchemeKeepingPathCase(pattern) : pattern;
|
|
88235
|
+
writable[key] = action;
|
|
88236
|
+
} else notWritable[pattern] = action;
|
|
88237
|
+
}
|
|
88238
|
+
const restated = restateAllToolsRestrictionsInCategory({
|
|
88239
|
+
permission: {
|
|
88240
|
+
["*"]: writable,
|
|
88241
|
+
[category]: lookupOwn({
|
|
88242
|
+
record: permission,
|
|
88243
|
+
key: category
|
|
88244
|
+
}) ?? {}
|
|
88245
|
+
},
|
|
88246
|
+
category,
|
|
88247
|
+
restateAs: () => true
|
|
88248
|
+
});
|
|
88249
|
+
return lookupOwn({
|
|
88250
|
+
record: honorAllToolsRestrictions({
|
|
88251
|
+
permission: {
|
|
88252
|
+
["*"]: notWritable,
|
|
88253
|
+
[category]: restated
|
|
88254
|
+
},
|
|
88255
|
+
toolLabel: COPILOT_TOOL_LABEL,
|
|
88256
|
+
logger
|
|
88257
|
+
}),
|
|
88258
|
+
key: category
|
|
88259
|
+
}) ?? {};
|
|
88260
|
+
}
|
|
88261
|
+
/**
|
|
87649
88262
|
* Render one canonical category's rules as a VS Code auto-approve map. Returns
|
|
87650
88263
|
* `undefined` when the category contributes nothing, so the key is retracted
|
|
87651
88264
|
* rather than written as an empty object.
|
|
@@ -87723,11 +88336,14 @@ var CopilotPermissions = class CopilotPermissions extends ToolPermissions {
|
|
|
87723
88336
|
const config = rulesyncPermissions.getJson();
|
|
87724
88337
|
const patch = {};
|
|
87725
88338
|
for (const [category, settingKey] of Object.entries(AUTO_APPROVE_KEYS)) {
|
|
87726
|
-
|
|
87727
|
-
if (rules === void 0) continue;
|
|
88339
|
+
if (!Object.hasOwn(config.permission, category)) continue;
|
|
87728
88340
|
patch[settingKey] = buildAutoApproveValue({
|
|
87729
88341
|
category,
|
|
87730
|
-
rules
|
|
88342
|
+
rules: category === "bash" ? bashRulesHonoringAllTools(config.permission) : honorCopilotAllToolsRestrictions({
|
|
88343
|
+
permission: config.permission,
|
|
88344
|
+
category,
|
|
88345
|
+
logger
|
|
88346
|
+
})
|
|
87731
88347
|
});
|
|
87732
88348
|
}
|
|
87733
88349
|
const existingSettings = () => parseSharedConfig({
|
|
@@ -87828,6 +88444,15 @@ const DEFAULT_PERMISSION_MODE_KEY = "defaultPermissionMode";
|
|
|
87828
88444
|
function isCopilotcliDefaultPermissionMode(value) {
|
|
87829
88445
|
return COPILOTCLI_DEFAULT_PERMISSION_MODES.some((mode) => mode === value);
|
|
87830
88446
|
}
|
|
88447
|
+
/** The given categories of a permission block, those it states. */
|
|
88448
|
+
function pickOwnCategories(permission, categories) {
|
|
88449
|
+
const picked = {};
|
|
88450
|
+
for (const category of categories) {
|
|
88451
|
+
const rules = Object.hasOwn(permission, category) ? permission[category] : void 0;
|
|
88452
|
+
if (rules !== void 0) picked[category] = rules;
|
|
88453
|
+
}
|
|
88454
|
+
return picked;
|
|
88455
|
+
}
|
|
87831
88456
|
function toUrlList(value) {
|
|
87832
88457
|
if (!Array.isArray(value)) return [];
|
|
87833
88458
|
return value.filter((entry) => typeof entry === "string");
|
|
@@ -87912,7 +88537,15 @@ var CopilotcliPermissions = class CopilotcliPermissions extends ToolPermissions
|
|
|
87912
88537
|
const filePath = (0, node_path.join)(outputRoot, paths.relativeDirPath, paths.relativeFilePath);
|
|
87913
88538
|
const existingContent = await readFileContentOrNull(filePath) ?? "{}";
|
|
87914
88539
|
const config = rulesyncPermissions.getJson();
|
|
87915
|
-
const rules =
|
|
88540
|
+
const rules = withholdAllowsShadowedByAsks({
|
|
88541
|
+
permission: honorAllToolsRestrictions({
|
|
88542
|
+
permission: pickOwnCategories(config.permission, ["*", WEBFETCH_CATEGORY$1]),
|
|
88543
|
+
toolLabel: "Copilot CLI",
|
|
88544
|
+
logger
|
|
88545
|
+
}),
|
|
88546
|
+
toolLabel: "Copilot CLI",
|
|
88547
|
+
logger
|
|
88548
|
+
})[WEBFETCH_CATEGORY$1];
|
|
87916
88549
|
const patch = {};
|
|
87917
88550
|
if (rules !== void 0) {
|
|
87918
88551
|
const { allowedUrls, deniedUrls } = splitUrlRules(rules);
|
|
@@ -88391,6 +89024,26 @@ function resolveCategoryAction({ category, toolName, rules, logger }) {
|
|
|
88391
89024
|
return catchAllAction;
|
|
88392
89025
|
}
|
|
88393
89026
|
/**
|
|
89027
|
+
* The canonical rules with the all-tools `*` restrictions applied the way
|
|
89028
|
+
* Crush can carry them. Crush has no all-tools list, so a `*` deny or ask
|
|
89029
|
+
* withholds every `allow` it covers in the other categories (`{"*": {".env":
|
|
89030
|
+
* "deny"}, "read": {"*": "allow"}}` keeps `view` out of `allowed_tools`, and
|
|
89031
|
+
* Crush prompts for it), named in one warning. `bash` keeps the
|
|
89032
|
+
* `honorAllToolsOnBash` treatment: its allow lines become `safe_commands`, and
|
|
89033
|
+
* the safe-command and blocked-command logic reports what it withholds itself.
|
|
89034
|
+
*/
|
|
89035
|
+
function honorCrushAllToolsRestrictions({ config, logger }) {
|
|
89036
|
+
const withShell = honorAllToolsOnBash(config.permission);
|
|
89037
|
+
const honored = honorAllToolsRestrictions({
|
|
89038
|
+
permission: Object.fromEntries(Object.entries(config.permission).filter(([category]) => category !== SHELL_PERMISSION_CATEGORY)),
|
|
89039
|
+
toolLabel: "Crush",
|
|
89040
|
+
logger
|
|
89041
|
+
});
|
|
89042
|
+
const permission = {};
|
|
89043
|
+
for (const [category, rules] of Object.entries(withShell)) permission[category] = category !== "bash" && Object.hasOwn(honored, category) ? honored[category] ?? rules : rules;
|
|
89044
|
+
return permission;
|
|
89045
|
+
}
|
|
89046
|
+
/**
|
|
88394
89047
|
* Convert a rulesync permissions config into Crush's two tool lists.
|
|
88395
89048
|
*/
|
|
88396
89049
|
function convertRulesyncToCrushLists({ config, logger }) {
|
|
@@ -88399,7 +89052,10 @@ function convertRulesyncToCrushLists({ config, logger }) {
|
|
|
88399
89052
|
disabled: []
|
|
88400
89053
|
};
|
|
88401
89054
|
const actionByTool = /* @__PURE__ */ new Map();
|
|
88402
|
-
for (const [category, rules] of Object.entries(
|
|
89055
|
+
for (const [category, rules] of Object.entries(honorCrushAllToolsRestrictions({
|
|
89056
|
+
config,
|
|
89057
|
+
logger
|
|
89058
|
+
}))) {
|
|
88403
89059
|
if (isPrototypePollutionKey(category)) continue;
|
|
88404
89060
|
if (category === "*") {
|
|
88405
89061
|
for (const [rawPattern, action] of Object.entries(rules)) {
|
|
@@ -88844,7 +89500,17 @@ var CursorPermissions = class CursorPermissions extends ToolPermissions {
|
|
|
88844
89500
|
function convertRulesyncToCursorPermissions(config, logger) {
|
|
88845
89501
|
const allow = [];
|
|
88846
89502
|
const deny = [];
|
|
88847
|
-
|
|
89503
|
+
const permission = withholdAllowsShadowedByAsks({
|
|
89504
|
+
permission: honorAllToolsRestrictions({
|
|
89505
|
+
permission: config.permission,
|
|
89506
|
+
toolLabel: "Cursor CLI",
|
|
89507
|
+
logger
|
|
89508
|
+
}),
|
|
89509
|
+
toolLabel: "Cursor CLI",
|
|
89510
|
+
logger,
|
|
89511
|
+
groupOf: (category) => isMcpScopedCategory(category) ? category : toCursorType(category)
|
|
89512
|
+
});
|
|
89513
|
+
for (const [category, rules] of Object.entries(permission)) {
|
|
88848
89514
|
const cursorType = toCursorType(category);
|
|
88849
89515
|
for (const [pattern, action] of Object.entries(rules)) {
|
|
88850
89516
|
const entry = buildToolPatternEntry({
|
|
@@ -90189,7 +90855,11 @@ function convertRulesyncToDevinPermissions({ config, logger }) {
|
|
|
90189
90855
|
case "deny": deny.push(entry);
|
|
90190
90856
|
}
|
|
90191
90857
|
};
|
|
90192
|
-
for (const [category, rules] of Object.entries(
|
|
90858
|
+
for (const [category, rules] of Object.entries(honorAllToolsRestrictions({
|
|
90859
|
+
permission: config.permission,
|
|
90860
|
+
toolLabel: "Devin",
|
|
90861
|
+
logger
|
|
90862
|
+
}))) {
|
|
90193
90863
|
const scope = toDevinScope(category);
|
|
90194
90864
|
if (DEVIN_BARE_ONLY_SCOPES.has(scope)) {
|
|
90195
90865
|
const action = collapseBareOnlyScopeRules({
|
|
@@ -90933,7 +91603,12 @@ function unmanagedEntries(existingPermission, key) {
|
|
|
90933
91603
|
*/
|
|
90934
91604
|
function buildGrokPermissionArrays(config, existingPermission, logger) {
|
|
90935
91605
|
const ranked = /* @__PURE__ */ new Map();
|
|
90936
|
-
for (const [category, rules] of Object.entries(
|
|
91606
|
+
for (const [category, rules] of Object.entries(honorAllToolsRestrictions({
|
|
91607
|
+
permission: config.permission,
|
|
91608
|
+
toolLabel: "Grok CLI",
|
|
91609
|
+
logger,
|
|
91610
|
+
writesAllToolsCatchAll: true
|
|
91611
|
+
}))) for (const [pattern, action] of Object.entries(rules)) {
|
|
90937
91612
|
const entry = buildGrokEntry(category, pattern);
|
|
90938
91613
|
if (entry === null) {
|
|
90939
91614
|
if (category === "*") {
|
|
@@ -90992,7 +91667,7 @@ function warnRemovedAllToolsRestrictions({ existingPermission, ranked, logger })
|
|
|
90992
91667
|
* Warn about entries that a bare `*` `deny`/`ask` makes ineffective: Grok
|
|
90993
91668
|
* evaluates by severity (`deny > ask > allow`), so a specific `allow` (and,
|
|
90994
91669
|
* under a `*` deny, a specific `ask`) never takes effect next to it. Shell
|
|
90995
|
-
* rules are already folded by `
|
|
91670
|
+
* rules are already folded by `honorAllToolsRestrictions`, so this covers the other
|
|
90996
91671
|
* tools.
|
|
90997
91672
|
*/
|
|
90998
91673
|
function warnEntriesShadowedByAllTools({ ranked, logger }) {
|
|
@@ -91749,7 +92424,12 @@ var JuniePermissions = class JuniePermissions extends ToolPermissions {
|
|
|
91749
92424
|
*/
|
|
91750
92425
|
function convertRulesyncToJunieRules({ config, logger, existingRules, overrideSecretFile, overrideRuleDefaults }) {
|
|
91751
92426
|
const ruleLists = {};
|
|
91752
|
-
|
|
92427
|
+
const permission = honorAllToolsRestrictions({
|
|
92428
|
+
permission: config.permission,
|
|
92429
|
+
toolLabel: "Junie allowlist",
|
|
92430
|
+
logger
|
|
92431
|
+
});
|
|
92432
|
+
for (const [category, patterns] of Object.entries(permission)) {
|
|
91753
92433
|
const group = lookupOwn({
|
|
91754
92434
|
record: CANONICAL_TO_JUNIE_GROUP,
|
|
91755
92435
|
key: category
|
|
@@ -91777,13 +92457,16 @@ function convertRulesyncToJunieRules({ config, logger, existingRules, overrideSe
|
|
|
91777
92457
|
if (list === void 0 && groupDefault === void 0) continue;
|
|
91778
92458
|
rules[group] = {
|
|
91779
92459
|
...groupDefault !== void 0 && { default: groupDefault },
|
|
91780
|
-
rules: list
|
|
92460
|
+
rules: list === void 0 ? [] : sortRestrictionsFirst(list)
|
|
91781
92461
|
};
|
|
91782
92462
|
}
|
|
91783
92463
|
const secretFile = overrideSecretFile ?? toRuleSet(existingRules[JUNIE_SECRET_FILE_GROUP]);
|
|
91784
92464
|
if (secretFile !== void 0) rules[JUNIE_SECRET_FILE_GROUP] = sanitizeRuleSet(secretFile);
|
|
91785
92465
|
return rules;
|
|
91786
92466
|
}
|
|
92467
|
+
function sortRestrictionsFirst(list) {
|
|
92468
|
+
return [...list.filter((rule) => rule.action !== "allow"), ...list.filter((rule) => rule.action === "allow")];
|
|
92469
|
+
}
|
|
91787
92470
|
/**
|
|
91788
92471
|
* Map a canonical action onto a valid Junie allowlist action. Junie supports
|
|
91789
92472
|
* only `allow` and `ask`; a canonical `deny` is downgraded to `ask` (the
|
|
@@ -91829,6 +92512,69 @@ function convertJunieToRulesyncPermissions({ allowlist }) {
|
|
|
91829
92512
|
readSecretFile
|
|
91830
92513
|
};
|
|
91831
92514
|
}
|
|
92515
|
+
// src/features/permissions/last-match-restate.ts
|
|
92516
|
+
/**
|
|
92517
|
+
* OpenCode (and its forks: Kilo, MiMo Code) applies the last matching rule,
|
|
92518
|
+
* and the `*` key comes first in the usual file, so a later key's allow overrides a pattern-specific `*` deny or
|
|
92519
|
+
* ask: `{"*": {".env": "deny"}, "read": {"*": "allow"}}` would read `.env`
|
|
92520
|
+
* freely. Canonically the stricter rule wins whatever its width, so each such
|
|
92521
|
+
* restriction is restated at the end of every other key that holds a looser
|
|
92522
|
+
* rule it overlaps, where it is matched after that rule. A `*` catch-all
|
|
92523
|
+
* (`{"*": {"*": "ask"}}` followed by per-tool allows) is the documented way to
|
|
92524
|
+
* set an OpenCode default, so it is left where it is.
|
|
92525
|
+
*
|
|
92526
|
+
* A restated rule must never land after an overlapping stricter one, or it
|
|
92527
|
+
* would loosen what that rule says. The tail of a key is therefore written
|
|
92528
|
+
* asks first, then denies: every restated ask, then each of the key's own
|
|
92529
|
+
* denies and each `*` deny that overlaps one of those asks (moved after them),
|
|
92530
|
+
* then the restated `*` denies. A key whose own catch-all is a deny covers
|
|
92531
|
+
* every input of a restated ask already, so such an ask is restated as a deny.
|
|
92532
|
+
*/
|
|
92533
|
+
function restateAllToolsRestrictionsLast(sharedPermission) {
|
|
92534
|
+
const allToolsRules = Object.hasOwn(sharedPermission, "*") ? sharedPermission["*"] : void 0;
|
|
92535
|
+
const restrictions = Object.entries(allToolsRules ?? {}).filter(([pattern, action]) => action !== "allow" && pattern !== "*" && !isPrototypePollutionKey(pattern));
|
|
92536
|
+
if (restrictions.length === 0) return sharedPermission;
|
|
92537
|
+
const result = {};
|
|
92538
|
+
for (const [key, rules] of Object.entries(sharedPermission)) result[key] = key === "*" ? rules : restateInKey({
|
|
92539
|
+
rules,
|
|
92540
|
+
restrictions
|
|
92541
|
+
});
|
|
92542
|
+
return result;
|
|
92543
|
+
}
|
|
92544
|
+
function globsOverlap(left, right) {
|
|
92545
|
+
return createShadowingRestrictionsTest([{
|
|
92546
|
+
pattern: left,
|
|
92547
|
+
fromAllToolsCategory: true
|
|
92548
|
+
}])(right).length > 0;
|
|
92549
|
+
}
|
|
92550
|
+
/** One key's rules with the `*` restrictions restated at its end; see the caller. */
|
|
92551
|
+
function restateInKey({ rules, restrictions }) {
|
|
92552
|
+
const own = Object.entries(rules);
|
|
92553
|
+
const ownAction = (pattern) => Object.hasOwn(rules, pattern) ? rules[pattern] : void 0;
|
|
92554
|
+
const overlapsLooserOwnRule = (pattern, action) => own.some(([ownPattern, existing]) => isStricterAction({
|
|
92555
|
+
action,
|
|
92556
|
+
existing
|
|
92557
|
+
}) && globsOverlap(pattern, ownPattern));
|
|
92558
|
+
const allToolsDenies = restrictions.filter(([, action]) => action === "deny").map(([pattern]) => pattern);
|
|
92559
|
+
let asks = restrictions.filter(([pattern, action]) => action === "ask" && overlapsLooserOwnRule(pattern, action)).map(([pattern]) => pattern);
|
|
92560
|
+
const denies = new Set(allToolsDenies.filter((pattern) => overlapsLooserOwnRule(pattern, "deny")));
|
|
92561
|
+
if (ownAction("*") === "deny") {
|
|
92562
|
+
for (const pattern of asks) denies.add(pattern);
|
|
92563
|
+
asks = [];
|
|
92564
|
+
}
|
|
92565
|
+
for (const pattern of asks) if (ownAction(pattern) === "deny") denies.add(pattern);
|
|
92566
|
+
asks = asks.filter((pattern) => ownAction(pattern) !== "deny");
|
|
92567
|
+
const overlapsAnAsk = (pattern) => asks.some((ask) => globsOverlap(ask, pattern));
|
|
92568
|
+
const ownDenies = own.filter(([pattern, action]) => action === "deny" && pattern !== "*").map(([pattern]) => pattern);
|
|
92569
|
+
for (const pattern of [...ownDenies, ...allToolsDenies]) if (overlapsAnAsk(pattern)) denies.add(pattern);
|
|
92570
|
+
if (asks.length === 0 && denies.size === 0) return rules;
|
|
92571
|
+
const tail = /* @__PURE__ */ new Set([...asks, ...denies]);
|
|
92572
|
+
const restated = {};
|
|
92573
|
+
for (const [pattern, action] of own) if (!tail.has(pattern)) restated[pattern] = action;
|
|
92574
|
+
for (const pattern of asks) restated[pattern] = "ask";
|
|
92575
|
+
for (const pattern of denies) restated[pattern] = "deny";
|
|
92576
|
+
return restated;
|
|
92577
|
+
}
|
|
91832
92578
|
// src/features/permissions/kilo-permissions.ts
|
|
91833
92579
|
const KiloPermissionSchema = zod_mini.z.union([zod_mini.z.enum([
|
|
91834
92580
|
"allow",
|
|
@@ -92044,7 +92790,7 @@ var KiloPermissions = class KiloPermissions extends ToolPermissions {
|
|
|
92044
92790
|
const rulesyncJson = rulesyncPermissions.getJson();
|
|
92045
92791
|
const kiloOverride = rulesyncJson.kilo;
|
|
92046
92792
|
const incomingPermission = {
|
|
92047
|
-
...honorAllToolsOnBash(rulesyncJson.permission),
|
|
92793
|
+
...restateAllToolsRestrictionsLast(honorAllToolsOnBash(rulesyncJson.permission)),
|
|
92048
92794
|
...kiloOverride?.permission
|
|
92049
92795
|
};
|
|
92050
92796
|
if (!global && Object.hasOwn(incomingPermission, KILO_MARKDOWN_SOURCE_KEY)) {
|
|
@@ -92249,7 +92995,12 @@ function warnAboutMistypedToolLists(section) {
|
|
|
92249
92995
|
function canonicalToKimiCodeRules({ config, logger }) {
|
|
92250
92996
|
const canonicalRules = [];
|
|
92251
92997
|
const overrideRules = config["kimi-code"]?.rules ?? [];
|
|
92252
|
-
|
|
92998
|
+
const permission = honorAllToolsRestrictions({
|
|
92999
|
+
permission: config.permission,
|
|
93000
|
+
toolLabel: "Kimi Code",
|
|
93001
|
+
logger
|
|
93002
|
+
});
|
|
93003
|
+
for (const [category, rules] of Object.entries(permission)) {
|
|
92253
93004
|
if (!(category === "mcp" || category.startsWith("mcp__") || lookupOwn({
|
|
92254
93005
|
record: CATEGORY_TO_KIMI_CODE_TOOL,
|
|
92255
93006
|
key: category
|
|
@@ -93096,7 +93847,11 @@ var KiroCapabilityPermissions = class KiroCapabilityPermissions extends ToolPerm
|
|
|
93096
93847
|
*/
|
|
93097
93848
|
function buildKiroCapabilityRules({ config, logger }) {
|
|
93098
93849
|
const buckets = /* @__PURE__ */ new Map();
|
|
93099
|
-
for (const [category, rules] of Object.entries(
|
|
93850
|
+
for (const [category, rules] of Object.entries(honorAllToolsRestrictions({
|
|
93851
|
+
permission: config.permission,
|
|
93852
|
+
toolLabel: "Kiro",
|
|
93853
|
+
logger
|
|
93854
|
+
}))) {
|
|
93100
93855
|
const capability = lookupOwn({
|
|
93101
93856
|
record: CANONICAL_TO_KIRO_CAPABILITY,
|
|
93102
93857
|
key: category
|
|
@@ -93304,7 +94059,12 @@ function fromLettacodeRule(rule) {
|
|
|
93304
94059
|
* absent from the config).
|
|
93305
94060
|
*/
|
|
93306
94061
|
function buildLettacodeRuleLists({ config, existingPermissions, logger }) {
|
|
93307
|
-
const permission =
|
|
94062
|
+
const permission = honorAllToolsRestrictions({
|
|
94063
|
+
permission: config.permission,
|
|
94064
|
+
toolLabel: "Letta Code",
|
|
94065
|
+
logger,
|
|
94066
|
+
restateAs: restatesAsCategoryRule()
|
|
94067
|
+
});
|
|
93308
94068
|
const ranked = /* @__PURE__ */ new Map();
|
|
93309
94069
|
const managedCategories = /* @__PURE__ */ new Set();
|
|
93310
94070
|
for (const [category, rules] of Object.entries(permission)) {
|
|
@@ -93724,7 +94484,7 @@ function toOpencodeSharedPermission({ permission, toolTarget, logger }) {
|
|
|
93724
94484
|
sharedPermission[key] = merged;
|
|
93725
94485
|
} else sharedPermission[key] = value;
|
|
93726
94486
|
}
|
|
93727
|
-
return sharedPermission;
|
|
94487
|
+
return restateAllToolsRestrictionsLast(sharedPermission);
|
|
93728
94488
|
}
|
|
93729
94489
|
const OpencodePermissionsConfigSchema = zod_mini.z.looseObject({
|
|
93730
94490
|
permission: zod_mini.z.optional(zod_mini.z.union([zod_mini.z.enum([
|
|
@@ -94549,7 +95309,7 @@ function listPatterns(patterns) {
|
|
|
94549
95309
|
* - `mcp__<server>__<tool>` is skipped: Pool approves MCP tools per server
|
|
94550
95310
|
* under `mcp_servers.<server>.allow`, authored as `poolAllow` in
|
|
94551
95311
|
* `.rulesync/mcp.json`. The all-tools `*` category is mirrored onto
|
|
94552
|
-
* `bash` by `
|
|
95312
|
+
* `bash` by `honorAllToolsRestrictions` and otherwise skipped.
|
|
94553
95313
|
*
|
|
94554
95314
|
* Project settings take project-relative paths and the user settings absolute
|
|
94555
95315
|
* or `~` paths, so a path of the other kind is skipped with a warning at each
|
|
@@ -94642,7 +95402,11 @@ var PoolPermissions = class PoolPermissions extends ToolPermissions {
|
|
|
94642
95402
|
* `tools: {}` / `paths: {}`.
|
|
94643
95403
|
*/
|
|
94644
95404
|
function buildPoolPermissionsPatch({ config, existing, global, logger }) {
|
|
94645
|
-
const permission =
|
|
95405
|
+
const permission = honorAllToolsRestrictions({
|
|
95406
|
+
permission: config.permission,
|
|
95407
|
+
toolLabel: "Pool",
|
|
95408
|
+
logger
|
|
95409
|
+
});
|
|
94646
95410
|
const existingTools = isRecord(existing["tools"]) ? existing[POOL_TOOLS_KEY] : void 0;
|
|
94647
95411
|
const existingPaths = isRecord(existing["paths"]) ? existing[POOL_PATHS_KEY] : void 0;
|
|
94648
95412
|
const patch = {};
|
|
@@ -95082,8 +95846,10 @@ function categoryOfRule(rule) {
|
|
|
95082
95846
|
* when Qoder has no spelling for it.
|
|
95083
95847
|
*
|
|
95084
95848
|
* - The all-tools `*` category is Qoder's bare `*` rule; a narrower pattern
|
|
95085
|
-
* under it names no single tool and is skipped
|
|
95086
|
-
* already
|
|
95849
|
+
* under it names no single tool and is skipped. `honorAllToolsRestrictions`
|
|
95850
|
+
* already carried it onto `bash` and withheld every allow it overlaps in the
|
|
95851
|
+
* other categories — a `{"*": "allow"}` included, even for a shell-only
|
|
95852
|
+
* pattern such as `git push *`.
|
|
95087
95853
|
* - An `mcp__...` category is a fully qualified MCP tool name (or a Qoder MCP
|
|
95088
95854
|
* wildcard like `mcp__github__*`) and only takes the catch-all pattern.
|
|
95089
95855
|
* - Every other category maps to its Qoder tool name; `*` is the bare tool
|
|
@@ -95135,7 +95901,13 @@ function fromQoderRule(rule) {
|
|
|
95135
95901
|
* ...). An existing entry this run writes is moved to its new list.
|
|
95136
95902
|
*/
|
|
95137
95903
|
function buildQoderRuleLists({ config, existingPermissions, logger }) {
|
|
95138
|
-
const permission =
|
|
95904
|
+
const permission = honorAllToolsRestrictions({
|
|
95905
|
+
permission: config.permission,
|
|
95906
|
+
toolLabel: "Qoder",
|
|
95907
|
+
logger,
|
|
95908
|
+
restateAs: restatesAsCategoryRule(),
|
|
95909
|
+
writesAllToolsCatchAll: true
|
|
95910
|
+
});
|
|
95139
95911
|
const ranked = /* @__PURE__ */ new Map();
|
|
95140
95912
|
const managedCategories = /* @__PURE__ */ new Set();
|
|
95141
95913
|
for (const [category, rules] of Object.entries(permission)) {
|
|
@@ -95948,7 +96720,10 @@ var QwencodePermissions = class QwencodePermissions extends ToolPermissions {
|
|
|
95948
96720
|
}
|
|
95949
96721
|
const displayPath = toPosixPath((0, node_path.join)(global ? "~" : ".", paths.relativeDirPath, paths.relativeFilePath));
|
|
95950
96722
|
const config = rulesyncPermissions.getJson();
|
|
95951
|
-
const { allow, ask, deny } = convertRulesyncToQwenPermissions(
|
|
96723
|
+
const { allow, ask, deny } = convertRulesyncToQwenPermissions({
|
|
96724
|
+
config,
|
|
96725
|
+
logger
|
|
96726
|
+
});
|
|
95952
96727
|
const managedToolNames = new Set(Object.keys(config.permission).map((category) => toQwenToolName(category)));
|
|
95953
96728
|
const existingPermissions = settings.permissions ?? {};
|
|
95954
96729
|
const preservedAllow = (existingPermissions.allow ?? []).filter((entry) => !managedToolNames.has(parseQwenPermissionEntry(entry, { logger }).toolName));
|
|
@@ -96053,11 +96828,17 @@ var QwencodePermissions = class QwencodePermissions extends ToolPermissions {
|
|
|
96053
96828
|
}
|
|
96054
96829
|
}
|
|
96055
96830
|
};
|
|
96056
|
-
function convertRulesyncToQwenPermissions(config) {
|
|
96831
|
+
function convertRulesyncToQwenPermissions({ config, logger }) {
|
|
96057
96832
|
const allow = [];
|
|
96058
96833
|
const ask = [];
|
|
96059
96834
|
const deny = [];
|
|
96060
|
-
|
|
96835
|
+
const permission = honorAllToolsRestrictions({
|
|
96836
|
+
permission: config.permission,
|
|
96837
|
+
toolLabel: "Qwen Code",
|
|
96838
|
+
logger,
|
|
96839
|
+
restateAs: restatesAsCategoryRule()
|
|
96840
|
+
});
|
|
96841
|
+
for (const [category, rules] of Object.entries(permission)) {
|
|
96061
96842
|
const qwenToolName = toQwenToolName(category);
|
|
96062
96843
|
for (const [pattern, action] of Object.entries(rules)) {
|
|
96063
96844
|
const entry = buildToolPatternEntry({
|
|
@@ -96586,7 +97367,10 @@ var ReasonixPermissions = class ReasonixPermissions extends ToolPermissions {
|
|
|
96586
97367
|
const existingContent = await readFileContentOrNull(filePath) ?? "";
|
|
96587
97368
|
const parsed = parseReasonixConfig(existingContent);
|
|
96588
97369
|
const config = rulesyncPermissions.getJson();
|
|
96589
|
-
const { allow, ask, deny } = convertRulesyncToReasonixPermissions(
|
|
97370
|
+
const { allow, ask, deny } = convertRulesyncToReasonixPermissions({
|
|
97371
|
+
config,
|
|
97372
|
+
logger
|
|
97373
|
+
});
|
|
96590
97374
|
const managedToolNames = new Set(Object.keys(config.permission).flatMap((category) => reasonixToolNamesOf(category)));
|
|
96591
97375
|
const override = config.reasonix;
|
|
96592
97376
|
const rawAllow = toStringArray$1(override?.rawAllow);
|
|
@@ -96856,11 +97640,16 @@ function setOrDeleteEntries(table, key, entries) {
|
|
|
96856
97640
|
/**
|
|
96857
97641
|
* Convert rulesync permissions config to Reasonix allow/ask/deny arrays.
|
|
96858
97642
|
*/
|
|
96859
|
-
function convertRulesyncToReasonixPermissions(config) {
|
|
97643
|
+
function convertRulesyncToReasonixPermissions({ config, logger }) {
|
|
96860
97644
|
const allow = [];
|
|
96861
97645
|
const ask = [];
|
|
96862
97646
|
const deny = [];
|
|
96863
|
-
|
|
97647
|
+
const permission = honorAllToolsRestrictions({
|
|
97648
|
+
permission: config.permission,
|
|
97649
|
+
toolLabel: "Reasonix",
|
|
97650
|
+
logger
|
|
97651
|
+
});
|
|
97652
|
+
for (const [category, rules] of Object.entries(permission)) for (const reasonixToolName of toReasonixToolNames(category)) for (const [pattern, action] of Object.entries(rules)) {
|
|
96864
97653
|
const entry = buildToolPatternEntry({
|
|
96865
97654
|
toolName: reasonixToolName,
|
|
96866
97655
|
pattern
|
|
@@ -98880,14 +99669,19 @@ async function readTaktRuntimeConfig({ outputRoot, logger }) {
|
|
|
98880
99669
|
/**
|
|
98881
99670
|
* Collapse a rulesync permissions config into Takt's single coarse mode.
|
|
98882
99671
|
*
|
|
98883
|
-
* Precedence: any `deny` ⇒ `readonly`; else an `edit`/`write` `allow`
|
|
98884
|
-
* else a `bash` `allow` ⇒ `full`; else the safe default `readonly`.
|
|
99672
|
+
* Precedence: any `deny` or `ask` ⇒ `readonly`; else an `edit`/`write` `allow`
|
|
99673
|
+
* ⇒ `edit`; else a `bash` `allow` ⇒ `full`; else the safe default `readonly`.
|
|
99674
|
+
*
|
|
99675
|
+
* An `ask` restricts like a `deny` here: Takt's coarse modes have no prompting
|
|
99676
|
+
* tier, so a mode derived from the allows beside it (`full` for `{"git *":
|
|
99677
|
+
* "allow", "git push *": "ask"}`) would auto-approve what the ask should prompt
|
|
99678
|
+
* for — the canonical order is `deny > ask > allow`.
|
|
98885
99679
|
*/
|
|
98886
99680
|
function deriveTaktPermissionMode(config) {
|
|
98887
99681
|
let hasEditAllow = false;
|
|
98888
99682
|
let hasBashAllow = false;
|
|
98889
99683
|
for (const [category, rules] of Object.entries(config.permission)) for (const action of Object.values(rules)) {
|
|
98890
|
-
if (action === "deny") return "readonly";
|
|
99684
|
+
if (action === "deny" || action === "ask") return "readonly";
|
|
98891
99685
|
if (action === "allow") {
|
|
98892
99686
|
if (category === "edit" || category === "write") hasEditAllow = true;
|
|
98893
99687
|
else if (category === "bash") hasBashAllow = true;
|
|
@@ -99170,7 +99964,12 @@ function buildMcpRules({ permission, existing, logger }) {
|
|
|
99170
99964
|
/** Split the canonical `webfetch` rules into TRAE's network allow/deny lists. */
|
|
99171
99965
|
function buildNetworkLists({ webfetchRules, logger }) {
|
|
99172
99966
|
const ranked = /* @__PURE__ */ new Map();
|
|
99173
|
-
|
|
99967
|
+
const { webfetch: rules = {} } = withholdAllowsShadowedByAsks({
|
|
99968
|
+
permission: { webfetch: webfetchRules },
|
|
99969
|
+
toolLabel: "TRAE resourceAuthorization.network",
|
|
99970
|
+
logger
|
|
99971
|
+
});
|
|
99972
|
+
for (const [pattern, action] of Object.entries(rules)) {
|
|
99174
99973
|
if (isPrototypePollutionKey(pattern)) continue;
|
|
99175
99974
|
if (pattern === "*") {
|
|
99176
99975
|
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.`);
|
|
@@ -99298,7 +100097,11 @@ var TraePermissions = class TraePermissions extends ToolPermissions {
|
|
|
99298
100097
|
fileContent: existingContent,
|
|
99299
100098
|
relativePath
|
|
99300
100099
|
});
|
|
99301
|
-
const permission =
|
|
100100
|
+
const permission = honorAllToolsRestrictions({
|
|
100101
|
+
permission: rulesyncPermissions.getJson().permission,
|
|
100102
|
+
toolLabel: "TRAE",
|
|
100103
|
+
logger
|
|
100104
|
+
});
|
|
99302
100105
|
warnUnmappedCategories({
|
|
99303
100106
|
permission,
|
|
99304
100107
|
logger
|
|
@@ -99547,7 +100350,18 @@ var VibePermissions = class VibePermissions extends ToolPermissions {
|
|
|
99547
100350
|
const filePath = (0, node_path.join)(outputRoot, paths.relativeDirPath, paths.relativeFilePath);
|
|
99548
100351
|
const existingContent = await readFileContentOrNull(filePath) ?? "";
|
|
99549
100352
|
const config = parseVibeConfig(existingContent);
|
|
99550
|
-
const permission =
|
|
100353
|
+
const permission = withholdAllowsShadowedByAsks({
|
|
100354
|
+
permission: honorAllToolsRestrictions({
|
|
100355
|
+
permission: rulesyncPermissions.getJson().permission,
|
|
100356
|
+
toolLabel: "Vibe",
|
|
100357
|
+
logger,
|
|
100358
|
+
restateAs: restatesAsCategoryRule(["deny"]),
|
|
100359
|
+
downgradeWithheldCatchAll: true
|
|
100360
|
+
}),
|
|
100361
|
+
toolLabel: "Vibe",
|
|
100362
|
+
logger,
|
|
100363
|
+
isSkippedAsk: ({ pattern }) => pattern !== "*"
|
|
100364
|
+
});
|
|
99551
100365
|
const vibeOverride = rulesyncPermissions.getJson().vibe;
|
|
99552
100366
|
const tools = toVibeToolsRecord(config.tools);
|
|
99553
100367
|
const diskShellPatterns = new Map([VIBE_SHELL_CATEGORY, ...VIBE_SHELL_ALIAS_TOOL_NAMES].map((vibeToolName) => [vibeToolName, toStringArray$1(readVibeToolConfig({
|
|
@@ -99596,6 +100410,12 @@ var VibePermissions = class VibePermissions extends ToolPermissions {
|
|
|
99596
100410
|
logger
|
|
99597
100411
|
});
|
|
99598
100412
|
const tableCategories = Object.entries(permission).filter(([category]) => category !== VIBE_SUBAGENT_CATEGORY && category !== VIBE_OUTSIDE_WORKDIR_CATEGORY);
|
|
100413
|
+
retireWithheldAllows({
|
|
100414
|
+
source: rulesyncPermissions.getJson().permission,
|
|
100415
|
+
permission,
|
|
100416
|
+
tools,
|
|
100417
|
+
resolveNames
|
|
100418
|
+
});
|
|
99599
100419
|
for (const [category, rules] of tableCategories) {
|
|
99600
100420
|
const vibeToolNames = resolveNames(category);
|
|
99601
100421
|
if (vibeToolNames === void 0) {
|
|
@@ -99980,6 +100800,49 @@ function applyCategoryRulesToTool({ vibeToolName, category, rules, tools, enable
|
|
|
99980
100800
|
tools[vibeToolName] = nextTool;
|
|
99981
100801
|
}
|
|
99982
100802
|
/**
|
|
100803
|
+
* Remove from the existing tables what the current restrictions forbid. The
|
|
100804
|
+
* per-tool pass merges into the `allowlist` already on disk and only sets
|
|
100805
|
+
* `permission` when the category states a `*` rule, so a regenerate would
|
|
100806
|
+
* otherwise keep an `allowlist` entry (an earlier generate's, or a
|
|
100807
|
+
* hand-written one) that auto-approves what a canonical ask or deny now
|
|
100808
|
+
* covers, or the `permission = "always"` an earlier config wrote for an allow
|
|
100809
|
+
* that is now withheld. Only the tables of categories the config manages are
|
|
100810
|
+
* touched, and only entries that overlap a restriction are removed. A
|
|
100811
|
+
* category's own catch-all ask is the documented default its allowlist carves
|
|
100812
|
+
* out of, so it removes nothing.
|
|
100813
|
+
*/
|
|
100814
|
+
function retireWithheldAllows({ source, permission, tools, resolveNames }) {
|
|
100815
|
+
const allToolsRestrictions = Object.entries(lookupOwn({
|
|
100816
|
+
record: source,
|
|
100817
|
+
key: "*"
|
|
100818
|
+
}) ?? {}).filter(([pattern, action]) => action === "deny" || action === "ask" && pattern !== "*");
|
|
100819
|
+
for (const [category, rules] of Object.entries(source)) {
|
|
100820
|
+
if (category === "*") continue;
|
|
100821
|
+
const honored = lookupOwn({
|
|
100822
|
+
record: permission,
|
|
100823
|
+
key: category
|
|
100824
|
+
}) ?? {};
|
|
100825
|
+
const withheld = new Set(Object.entries(rules).filter(([pattern, action]) => action === "allow" && honored[pattern] !== "allow").map(([pattern]) => pattern));
|
|
100826
|
+
const restrictions = [...Object.entries(honored).filter(([pattern, action]) => action !== "allow" && pattern !== "*"), ...allToolsRestrictions].map(([pattern]) => ({
|
|
100827
|
+
pattern,
|
|
100828
|
+
fromAllToolsCategory: false
|
|
100829
|
+
}));
|
|
100830
|
+
const globShadowed = createShadowingRestrictionsTest(restrictions);
|
|
100831
|
+
const shadowed = (pattern) => category === "webfetch" ? restrictions.some((restriction) => urlPatternsOverlap(restriction.pattern, pattern)) : globShadowed(pattern).length > 0;
|
|
100832
|
+
const retires = (pattern) => withheld.has(pattern) || restrictions.length > 0 && honored[pattern] !== "allow" && shadowed(pattern);
|
|
100833
|
+
for (const vibeToolName of resolveNames(category) ?? []) {
|
|
100834
|
+
if (!Object.hasOwn(tools, vibeToolName)) continue;
|
|
100835
|
+
const tool = readVibeToolConfig({
|
|
100836
|
+
tools,
|
|
100837
|
+
vibeToolName
|
|
100838
|
+
});
|
|
100839
|
+
for (const key of ["allow", "allowlist"]) if (tool[key] !== void 0) tool[key] = toStringArray$1(tool[key]).filter((pattern) => !retires(pattern));
|
|
100840
|
+
if (withheld.size > 0 && tool.permission === "always" && !Object.hasOwn(honored, "*")) tool.permission = "ask";
|
|
100841
|
+
tools[vibeToolName] = tool;
|
|
100842
|
+
}
|
|
100843
|
+
}
|
|
100844
|
+
}
|
|
100845
|
+
/**
|
|
99983
100846
|
* `enabled_tools` is an exclusive allowlist and therefore only ever
|
|
99984
100847
|
* rulesync-authored explicitly, through `vibe.enabled_tools`. When the
|
|
99985
100848
|
* override declares it (even empty), rulesync owns the whole list; when it
|