@staff0rd/assist 0.189.3 → 0.190.0
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 +25 -2
- 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.
|
|
9
|
+
version: "0.190.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -4846,7 +4846,7 @@ function stripEnvPrefix(parts) {
|
|
|
4846
4846
|
}
|
|
4847
4847
|
|
|
4848
4848
|
// src/shared/isApprovedRead.ts
|
|
4849
|
-
import { resolve as resolve7 } from "path";
|
|
4849
|
+
import { resolve as resolve7, sep } from "path";
|
|
4850
4850
|
|
|
4851
4851
|
// src/shared/tokenize.ts
|
|
4852
4852
|
function tokenize(command) {
|
|
@@ -5060,8 +5060,11 @@ function parsePerms(entries) {
|
|
|
5060
5060
|
}
|
|
5061
5061
|
|
|
5062
5062
|
// src/shared/isApprovedRead.ts
|
|
5063
|
+
var READ_RE = /^Read\((.+)\)$/;
|
|
5063
5064
|
function isApprovedRead(command, toolName = "Bash") {
|
|
5064
5065
|
if (isCdToCwd(command)) return "cd to current directory";
|
|
5066
|
+
const cdRead = isCdToReadAllowedDir(command);
|
|
5067
|
+
if (cdRead) return cdRead;
|
|
5065
5068
|
const matchedRead = findCliRead(command);
|
|
5066
5069
|
if (matchedRead) return `Read-only CLI command: ${matchedRead}`;
|
|
5067
5070
|
const matchedWrite = findCliWrite(command);
|
|
@@ -5078,6 +5081,26 @@ function isCdToCwd(command) {
|
|
|
5078
5081
|
const resolved = resolve7(normalizeMsysPath(parts[1]));
|
|
5079
5082
|
return resolved === resolve7(process.cwd());
|
|
5080
5083
|
}
|
|
5084
|
+
function isCdToReadAllowedDir(command) {
|
|
5085
|
+
const parts = command.split(/\s+/);
|
|
5086
|
+
if (parts[0] !== "cd" || parts.length !== 2) return void 0;
|
|
5087
|
+
const target = resolve7(normalizeMsysPath(parts[1]));
|
|
5088
|
+
for (const entry of readSettingsPerms("allow")) {
|
|
5089
|
+
const m = entry.match(READ_RE);
|
|
5090
|
+
if (!m) continue;
|
|
5091
|
+
const base = globBaseDir(m[1]);
|
|
5092
|
+
if (!base) continue;
|
|
5093
|
+
const resolved = resolve7(normalizeMsysPath(base));
|
|
5094
|
+
if (target === resolved || target.startsWith(resolved + sep)) {
|
|
5095
|
+
return `cd to Read-allowed directory: ${entry}`;
|
|
5096
|
+
}
|
|
5097
|
+
}
|
|
5098
|
+
return void 0;
|
|
5099
|
+
}
|
|
5100
|
+
function globBaseDir(pattern2) {
|
|
5101
|
+
const base = pattern2.replace(/[/\\][^/\\]*[*?[].*$/, "");
|
|
5102
|
+
return /[*?[]/.test(base) ? "" : base;
|
|
5103
|
+
}
|
|
5081
5104
|
function normalizeMsysPath(p) {
|
|
5082
5105
|
const m = p.match(/^\/([a-zA-Z])(\/.*)/);
|
|
5083
5106
|
return m ? `${m[1].toUpperCase()}:${m[2]}` : p;
|