@staff0rd/assist 0.164.0 → 0.164.1
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/index.js +35 -34
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.164.
|
|
9
|
+
version: "0.164.1",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -3726,39 +3726,11 @@ function findCliRead(command) {
|
|
|
3726
3726
|
return candidates.sort((a, b) => b.length - a.length).find((rc) => command === rc || command.startsWith(`${rc} `));
|
|
3727
3727
|
}
|
|
3728
3728
|
|
|
3729
|
-
// src/shared/
|
|
3729
|
+
// src/shared/readSettingsPerms.ts
|
|
3730
3730
|
import { existsSync as existsSync21, readFileSync as readFileSync16 } from "fs";
|
|
3731
3731
|
import { homedir as homedir3 } from "os";
|
|
3732
3732
|
import { join as join13 } from "path";
|
|
3733
|
-
|
|
3734
|
-
var denyCache;
|
|
3735
|
-
var TOOL_RE = /^(Bash|PowerShell)\((.+?)(?::.*)\)$/;
|
|
3736
|
-
function loadPrefixes(key) {
|
|
3737
|
-
const entries = collectEntries(key);
|
|
3738
|
-
return parsePrefixes(entries);
|
|
3739
|
-
}
|
|
3740
|
-
var SHELL_TOOLS = ["Bash", "PowerShell"];
|
|
3741
|
-
function shellPrefixes(map, toolName) {
|
|
3742
|
-
if (SHELL_TOOLS.includes(toolName)) {
|
|
3743
|
-
return SHELL_TOOLS.flatMap((t) => map.get(t) ?? []);
|
|
3744
|
-
}
|
|
3745
|
-
return map.get(toolName) ?? [];
|
|
3746
|
-
}
|
|
3747
|
-
function matchesAllow(toolName, command) {
|
|
3748
|
-
if (!allowCache) allowCache = loadPrefixes("allow");
|
|
3749
|
-
const prefixes = shellPrefixes(allowCache, toolName);
|
|
3750
|
-
return prefixes.find(
|
|
3751
|
-
(pfx) => command === pfx || command.startsWith(`${pfx} `)
|
|
3752
|
-
);
|
|
3753
|
-
}
|
|
3754
|
-
function matchesDeny(toolName, command) {
|
|
3755
|
-
if (!denyCache) denyCache = loadPrefixes("deny");
|
|
3756
|
-
const prefixes = shellPrefixes(denyCache, toolName);
|
|
3757
|
-
return prefixes.find(
|
|
3758
|
-
(pfx) => command === pfx || command.startsWith(`${pfx} `)
|
|
3759
|
-
);
|
|
3760
|
-
}
|
|
3761
|
-
function collectEntries(key) {
|
|
3733
|
+
function readSettingsPerms(key) {
|
|
3762
3734
|
const paths = [
|
|
3763
3735
|
join13(homedir3(), ".claude", "settings.json"),
|
|
3764
3736
|
join13(process.cwd(), ".claude", "settings.json"),
|
|
@@ -3780,15 +3752,44 @@ function readPermissionArray(filePath, key) {
|
|
|
3780
3752
|
return [];
|
|
3781
3753
|
}
|
|
3782
3754
|
}
|
|
3783
|
-
|
|
3755
|
+
|
|
3756
|
+
// src/shared/matchesAllow.ts
|
|
3757
|
+
var allowCache;
|
|
3758
|
+
var denyCache;
|
|
3759
|
+
var TOOL_RE = /^(Bash|PowerShell)\((.+?)(:.*)?\)$/;
|
|
3760
|
+
var SHELL_TOOLS = ["Bash", "PowerShell"];
|
|
3761
|
+
function loadPerms(key) {
|
|
3762
|
+
return parsePerms(readSettingsPerms(key));
|
|
3763
|
+
}
|
|
3764
|
+
function shellEntries(map, toolName) {
|
|
3765
|
+
if (SHELL_TOOLS.includes(toolName)) {
|
|
3766
|
+
return SHELL_TOOLS.flatMap((t) => map.get(t) ?? []);
|
|
3767
|
+
}
|
|
3768
|
+
return map.get(toolName) ?? [];
|
|
3769
|
+
}
|
|
3770
|
+
function findMatch(entries, command) {
|
|
3771
|
+
return entries.find(
|
|
3772
|
+
(e) => e.wildcard ? command === e.command || command.startsWith(`${e.command} `) : command === e.command
|
|
3773
|
+
)?.command;
|
|
3774
|
+
}
|
|
3775
|
+
function matchesAllow(toolName, command) {
|
|
3776
|
+
if (!allowCache) allowCache = loadPerms("allow");
|
|
3777
|
+
return findMatch(shellEntries(allowCache, toolName), command);
|
|
3778
|
+
}
|
|
3779
|
+
function matchesDeny(toolName, command) {
|
|
3780
|
+
if (!denyCache) denyCache = loadPerms("deny");
|
|
3781
|
+
return findMatch(shellEntries(denyCache, toolName), command);
|
|
3782
|
+
}
|
|
3783
|
+
function parsePerms(entries) {
|
|
3784
3784
|
const map = /* @__PURE__ */ new Map();
|
|
3785
3785
|
for (const entry of entries) {
|
|
3786
3786
|
const m = entry.match(TOOL_RE);
|
|
3787
3787
|
if (m) {
|
|
3788
3788
|
const tool = m[1];
|
|
3789
|
-
const
|
|
3789
|
+
const command = m[2];
|
|
3790
|
+
const wildcard = m[3] !== void 0;
|
|
3790
3791
|
const list4 = map.get(tool) ?? [];
|
|
3791
|
-
list4.push(
|
|
3792
|
+
list4.push({ command, wildcard });
|
|
3792
3793
|
map.set(tool, list4);
|
|
3793
3794
|
}
|
|
3794
3795
|
}
|