@staff0rd/assist 0.189.2 → 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 +26 -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: {
|
|
@@ -4566,6 +4566,7 @@ function findPhase(id, phase) {
|
|
|
4566
4566
|
return { result, dir, db, itemId, phaseIdx };
|
|
4567
4567
|
}
|
|
4568
4568
|
function reindexPhases(db, itemId) {
|
|
4569
|
+
db.pragma("defer_foreign_keys = ON");
|
|
4569
4570
|
const remaining = db.prepare("SELECT idx FROM plan_phases WHERE item_id = ? ORDER BY idx").all(itemId);
|
|
4570
4571
|
for (let i = 0; i < remaining.length; i++) {
|
|
4571
4572
|
const oldIdx = remaining[i].idx;
|
|
@@ -4845,7 +4846,7 @@ function stripEnvPrefix(parts) {
|
|
|
4845
4846
|
}
|
|
4846
4847
|
|
|
4847
4848
|
// src/shared/isApprovedRead.ts
|
|
4848
|
-
import { resolve as resolve7 } from "path";
|
|
4849
|
+
import { resolve as resolve7, sep } from "path";
|
|
4849
4850
|
|
|
4850
4851
|
// src/shared/tokenize.ts
|
|
4851
4852
|
function tokenize(command) {
|
|
@@ -5059,8 +5060,11 @@ function parsePerms(entries) {
|
|
|
5059
5060
|
}
|
|
5060
5061
|
|
|
5061
5062
|
// src/shared/isApprovedRead.ts
|
|
5063
|
+
var READ_RE = /^Read\((.+)\)$/;
|
|
5062
5064
|
function isApprovedRead(command, toolName = "Bash") {
|
|
5063
5065
|
if (isCdToCwd(command)) return "cd to current directory";
|
|
5066
|
+
const cdRead = isCdToReadAllowedDir(command);
|
|
5067
|
+
if (cdRead) return cdRead;
|
|
5064
5068
|
const matchedRead = findCliRead(command);
|
|
5065
5069
|
if (matchedRead) return `Read-only CLI command: ${matchedRead}`;
|
|
5066
5070
|
const matchedWrite = findCliWrite(command);
|
|
@@ -5077,6 +5081,26 @@ function isCdToCwd(command) {
|
|
|
5077
5081
|
const resolved = resolve7(normalizeMsysPath(parts[1]));
|
|
5078
5082
|
return resolved === resolve7(process.cwd());
|
|
5079
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
|
+
}
|
|
5080
5104
|
function normalizeMsysPath(p) {
|
|
5081
5105
|
const m = p.match(/^\/([a-zA-Z])(\/.*)/);
|
|
5082
5106
|
return m ? `${m[1].toUpperCase()}:${m[2]}` : p;
|