@johannes.latzel/llm-chat-shell 0.1.1 → 0.2.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.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/config.d.ts +10 -5
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +36 -10
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/glob.d.ts +35 -0
- package/dist/lib/glob.d.ts.map +1 -0
- package/dist/lib/glob.js +56 -0
- package/dist/lib/glob.js.map +1 -0
- package/dist/lib/permission.d.ts +44 -24
- package/dist/lib/permission.d.ts.map +1 -1
- package/dist/lib/permission.js +98 -233
- package/dist/lib/permission.js.map +1 -1
- package/dist/lib/redirect-parser.d.ts +19 -0
- package/dist/lib/redirect-parser.d.ts.map +1 -0
- package/dist/lib/redirect-parser.js +302 -0
- package/dist/lib/redirect-parser.js.map +1 -0
- package/dist/lib/types.d.ts +43 -2
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/types.js +16 -0
- package/dist/lib/types.js.map +1 -1
- package/dist/tools/shell-command-tool.js +4 -4
- package/dist/tools/shell-command-tool.js.map +1 -1
- package/dist/tools/shell-permissions-tool.d.ts.map +1 -1
- package/dist/tools/shell-permissions-tool.js +9 -2
- package/dist/tools/shell-permissions-tool.js.map +1 -1
- package/package.json +8 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { PermissionAction, PermissionAccess, PermissionDenyReason, type PermissionRule, type WorkspacePermissions, type ShellConfigFile, type ShellExecutor, type ShellCommandResult, type ShellExecuteOptions, ShellJobStatus, type ShellJob, type ShellSessionInfo } from './lib/types.js';
|
|
1
|
+
export { PermissionAction, PermissionAccess, PermissionDenyReason, PermissionType, RedirectMode, type PermissionRule, type RedirectToken, type ParsedSubcommand, type WorkspacePermissions, type ShellConfigFile, type ShellExecutor, type ShellCommandResult, type ShellExecuteOptions, ShellJobStatus, type ShellJob, type ShellSessionInfo } from './lib/types.js';
|
|
2
2
|
export { ShellConfiguration } from './lib/config.js';
|
|
3
3
|
export { BashShellExecutor, BashShellExecutorFactory } from './lib/bash-executor.js';
|
|
4
4
|
export { ShellSessionManager, type ShellExecutorFactory } from './lib/session-manager.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,cAAc,EACd,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAE,mBAAmB,EAAE,KAAK,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,YAAY,EACZ,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,cAAc,EACd,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAE,mBAAmB,EAAE,KAAK,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { PermissionAction, PermissionAccess, PermissionDenyReason, ShellJobStatus } from './lib/types.js';
|
|
1
|
+
export { PermissionAction, PermissionAccess, PermissionDenyReason, PermissionType, RedirectMode, ShellJobStatus } from './lib/types.js';
|
|
2
2
|
export { ShellConfiguration } from './lib/config.js';
|
|
3
3
|
export { BashShellExecutor, BashShellExecutorFactory } from './lib/bash-executor.js';
|
|
4
4
|
export { ShellSessionManager } from './lib/session-manager.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,YAAY,EASZ,cAAc,EAGjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAE,mBAAmB,EAA6B,MAAM,0BAA0B,CAAC;AAC1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/lib/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PermissionAction, type PermissionRule, type ShellConfigFile, type WorkspacePermissions } from './types.js';
|
|
1
|
+
import { PermissionAction, PermissionAccess, PermissionType, type PermissionRule, type ShellConfigFile, type WorkspacePermissions } from './types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Load and validate a shell permission config file (strict JSON).
|
|
4
4
|
*
|
|
@@ -45,19 +45,24 @@ export declare class ShellConfiguration {
|
|
|
45
45
|
maxTimeout: number;
|
|
46
46
|
/** Default permission for unmatched commands (config file: `globalPermissions.defaultPermission`, default: Deny). */
|
|
47
47
|
defaultPermission: PermissionAction;
|
|
48
|
-
/** Global permission rules (config file: `globalPermissions.permissionRules`). */
|
|
48
|
+
/** Global permission rules for command cores and redirect targets (config file: `globalPermissions.permissionRules`). */
|
|
49
49
|
permissionRules: PermissionRule[];
|
|
50
|
+
/** Default rule type for rules without an explicit type (config file: `globalPermissions.defaultType`, default: Command). */
|
|
51
|
+
defaultType: PermissionType;
|
|
52
|
+
/** Default access level for rules without an explicit access (config file: `globalPermissions.defaultAccess`, default: Read). */
|
|
53
|
+
defaultAccess: PermissionAccess;
|
|
50
54
|
/**
|
|
51
55
|
* Per-workspace permission settings keyed by resolved workspace root path
|
|
52
56
|
* (config file: `workspacePermissions` — an object mapping each workspace
|
|
53
|
-
* root to `{ defaultPermission, permissionRules }`).
|
|
57
|
+
* root to `{ defaultPermission, defaultType, defaultAccess, permissionRules }`).
|
|
54
58
|
* Programmatic assignments take precedence over the config file.
|
|
55
59
|
*/
|
|
56
60
|
workspacePermissions: Map<string, WorkspacePermissions>;
|
|
57
61
|
/**
|
|
58
62
|
* Resolve the effective permission settings for a workspace root.
|
|
59
|
-
* Falls back to the global {@link defaultPermission} / {@link
|
|
60
|
-
* when the root has no
|
|
63
|
+
* Falls back to the global {@link defaultPermission} / {@link defaultType} /
|
|
64
|
+
* {@link defaultAccess} / {@link permissionRules} when the root has no
|
|
65
|
+
* per-workspace entry.
|
|
61
66
|
*
|
|
62
67
|
* @param workspaceRoot - Resolved workspace root path ('' or undefined uses the global settings).
|
|
63
68
|
*/
|
package/dist/lib/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,gBAAgB,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EAC5B,MAAM,YAAY,CAAC;AA8FpB;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,MAAM,GAAG,eAAe,CAyC3E;AAED,mKAAmK;AACnK,qBAAa,kBAAkB;IAC3B,uEAAuE;IACvE,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,CAA8C;IAEzF,0EAA0E;IAC1E,OAAO,CAAC,QAAQ,CAAC,UAAU,CAGtB;IAEL,iHAAiH;IACjH,YAAY,EAAE,MAAM,CAGf;IAEL,kHAAkH;IAClH,cAAc,EAAE,MAAM,CAGjB;IAEL,mGAAmG;IACnG,WAAW,EAAE,MAAM,CAGd;IAEL;;OAEG;IACH,WAAW,EAAE,MAAM,CAGd;IAEL,+FAA+F;IAC/F,cAAc,EAAE,MAAM,CAGjB;IAEL;;;;;;OAMG;IACH,iBAAiB,EAAE,MAAM,CAGpB;IAEL;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAGb;IAEL,qHAAqH;IACrH,iBAAiB,EAAE,gBAAgB,CAC+C;IAElF,yHAAyH;IACzH,eAAe,EAAE,cAAc,EAAE,CAA4D;IAE7F,6HAA6H;IAC7H,WAAW,EAAE,cAAc,CACkD;IAE7E,iIAAiI;IACjI,aAAa,EAAE,gBAAgB,CAC+C;IAE9E;;;;;OAKG;IACH,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAOlD;IAEL;;;;;;;OAOG;IACH,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,oBAAoB;IAW/D;;;;;;;;;;;OAWG;IACH,kBAAkB,CAAC,UAAU,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM;CAStE"}
|
package/dist/lib/config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import { envOptionalString, envInt } from './env.js';
|
|
4
|
-
import { PermissionAction, PermissionAccess } from './types.js';
|
|
4
|
+
import { PermissionAction, PermissionAccess, PermissionType } from './types.js';
|
|
5
5
|
const DEFAULT_CTRL_C_TIMEOUT = 30000;
|
|
6
6
|
const DEFAULT_SIGTERM_TIMEOUT = 5000;
|
|
7
7
|
const DEFAULT_KILL_TIMEOUT = 5000;
|
|
@@ -23,6 +23,14 @@ function parsePermissionAccess(value, path) {
|
|
|
23
23
|
}
|
|
24
24
|
throw new Error(`${path} must be 'read' or 'write', got ${JSON.stringify(value)}`);
|
|
25
25
|
}
|
|
26
|
+
function parsePermissionType(value, path) {
|
|
27
|
+
if (value === undefined)
|
|
28
|
+
return undefined;
|
|
29
|
+
if (value === PermissionType.Command || value === PermissionType.Redirect) {
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
throw new Error(`${path} must be 'command' or 'redirect', got ${JSON.stringify(value)}`);
|
|
33
|
+
}
|
|
26
34
|
function parsePermissionRules(value, path) {
|
|
27
35
|
if (!Array.isArray(value)) {
|
|
28
36
|
throw new Error(`${path} must be an array of permission rules`);
|
|
@@ -31,15 +39,19 @@ function parsePermissionRules(value, path) {
|
|
|
31
39
|
if (rule === null || typeof rule !== 'object' || Array.isArray(rule)) {
|
|
32
40
|
throw new Error(`${path}[${index}] must be an object with 'pattern' and 'action'`);
|
|
33
41
|
}
|
|
34
|
-
const { pattern, action, access } = rule;
|
|
42
|
+
const { pattern, action, access, type } = rule;
|
|
35
43
|
if (typeof pattern !== 'string') {
|
|
36
44
|
throw new Error(`${path}[${index}].pattern must be a string`);
|
|
37
45
|
}
|
|
38
46
|
const parsedAction = parsePermissionAction(action, `${path}[${index}].action`);
|
|
39
47
|
const parsedAccess = parsePermissionAccess(access, `${path}[${index}].access`);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
48
|
+
const parsedType = parsePermissionType(type, `${path}[${index}].type`);
|
|
49
|
+
return {
|
|
50
|
+
pattern,
|
|
51
|
+
action: parsedAction,
|
|
52
|
+
...(parsedAccess === undefined ? {} : { access: parsedAccess }),
|
|
53
|
+
...(parsedType === undefined ? {} : { type: parsedType })
|
|
54
|
+
};
|
|
43
55
|
});
|
|
44
56
|
}
|
|
45
57
|
function parseWorkspacePermissionsEntry(value, path) {
|
|
@@ -49,6 +61,10 @@ function parseWorkspacePermissionsEntry(value, path) {
|
|
|
49
61
|
const entryObject = value;
|
|
50
62
|
return {
|
|
51
63
|
defaultPermission: parsePermissionAction(entryObject.defaultPermission, `${path}.defaultPermission`),
|
|
64
|
+
defaultType: parsePermissionType(entryObject.defaultType, `${path}.defaultType`) ??
|
|
65
|
+
PermissionType.Command,
|
|
66
|
+
defaultAccess: parsePermissionAccess(entryObject.defaultAccess, `${path}.defaultAccess`) ??
|
|
67
|
+
PermissionAccess.Read,
|
|
52
68
|
permissionRules: parsePermissionRules(entryObject.permissionRules, `${path}.permissionRules`)
|
|
53
69
|
};
|
|
54
70
|
}
|
|
@@ -161,12 +177,16 @@ export class ShellConfiguration {
|
|
|
161
177
|
})();
|
|
162
178
|
/** Default permission for unmatched commands (config file: `globalPermissions.defaultPermission`, default: Deny). */
|
|
163
179
|
defaultPermission = this.configFile.globalPermissions?.defaultPermission ?? PermissionAction.Deny;
|
|
164
|
-
/** Global permission rules (config file: `globalPermissions.permissionRules`). */
|
|
180
|
+
/** Global permission rules for command cores and redirect targets (config file: `globalPermissions.permissionRules`). */
|
|
165
181
|
permissionRules = this.configFile.globalPermissions?.permissionRules ?? [];
|
|
182
|
+
/** Default rule type for rules without an explicit type (config file: `globalPermissions.defaultType`, default: Command). */
|
|
183
|
+
defaultType = this.configFile.globalPermissions?.defaultType ?? PermissionType.Command;
|
|
184
|
+
/** Default access level for rules without an explicit access (config file: `globalPermissions.defaultAccess`, default: Read). */
|
|
185
|
+
defaultAccess = this.configFile.globalPermissions?.defaultAccess ?? PermissionAccess.Read;
|
|
166
186
|
/**
|
|
167
187
|
* Per-workspace permission settings keyed by resolved workspace root path
|
|
168
188
|
* (config file: `workspacePermissions` — an object mapping each workspace
|
|
169
|
-
* root to `{ defaultPermission, permissionRules }`).
|
|
189
|
+
* root to `{ defaultPermission, defaultType, defaultAccess, permissionRules }`).
|
|
170
190
|
* Programmatic assignments take precedence over the config file.
|
|
171
191
|
*/
|
|
172
192
|
workspacePermissions = (() => {
|
|
@@ -180,8 +200,9 @@ export class ShellConfiguration {
|
|
|
180
200
|
})();
|
|
181
201
|
/**
|
|
182
202
|
* Resolve the effective permission settings for a workspace root.
|
|
183
|
-
* Falls back to the global {@link defaultPermission} / {@link
|
|
184
|
-
* when the root has no
|
|
203
|
+
* Falls back to the global {@link defaultPermission} / {@link defaultType} /
|
|
204
|
+
* {@link defaultAccess} / {@link permissionRules} when the root has no
|
|
205
|
+
* per-workspace entry.
|
|
185
206
|
*
|
|
186
207
|
* @param workspaceRoot - Resolved workspace root path ('' or undefined uses the global settings).
|
|
187
208
|
*/
|
|
@@ -189,7 +210,12 @@ export class ShellConfiguration {
|
|
|
189
210
|
const found = this.workspacePermissions.get(resolve(workspaceRoot));
|
|
190
211
|
if (found !== undefined)
|
|
191
212
|
return found;
|
|
192
|
-
return {
|
|
213
|
+
return {
|
|
214
|
+
defaultPermission: this.defaultPermission,
|
|
215
|
+
defaultType: this.defaultType,
|
|
216
|
+
defaultAccess: this.defaultAccess,
|
|
217
|
+
permissionRules: this.permissionRules
|
|
218
|
+
};
|
|
193
219
|
}
|
|
194
220
|
/**
|
|
195
221
|
* Resolve the effective idle timeout for a command execution.
|
package/dist/lib/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EACH,gBAAgB,EAChB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EACH,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EAIjB,MAAM,YAAY,CAAC;AAEpB,MAAM,sBAAsB,GAAG,KAAK,CAAC;AACrC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AACrC,MA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,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC;IACnE,CAAC;CACJ"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Check whether a string matches a glob pattern using picomatch. */
|
|
2
|
+
export declare function matchesPattern(str: string, pattern: string): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Check whether pattern A "dominates" pattern B, meaning A is more concrete
|
|
5
|
+
* (more specific) than B. This is the primary specificity criterion.
|
|
6
|
+
*
|
|
7
|
+
* A dominates B when A is a literal string (no wildcards) and B as a glob
|
|
8
|
+
* pattern matches A. Intuitively: if B is broad enough to match the literal
|
|
9
|
+
* text of A, then B is more general and A is more concrete.
|
|
10
|
+
*
|
|
11
|
+
* This check only applies when A has no wildcards. When both patterns contain
|
|
12
|
+
* wildcards, the literal-match test can produce false positives (e.g. `ls ?`
|
|
13
|
+
* matches the literal "ls *", but that doesn't make `ls *` more general).
|
|
14
|
+
* In those cases, we fall through to wildcard count and literal character
|
|
15
|
+
* count instead.
|
|
16
|
+
*
|
|
17
|
+
* Examples:
|
|
18
|
+
* `git push` dominates `git *` — `git *` matches the literal "git push"
|
|
19
|
+
* `git push origin main` dominates `git push *` — `git push *` matches "git push origin main"
|
|
20
|
+
* `rm -rf` dominates `rm *` — `rm *` matches the literal "rm -rf"
|
|
21
|
+
*
|
|
22
|
+
* @returns True if A is more concrete than B.
|
|
23
|
+
*/
|
|
24
|
+
export declare function dominates(a: string, b: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Count the number of wildcard characters (`*` and `?`) in a pattern.
|
|
27
|
+
* Fewer wildcards means a more specific (concrete) pattern.
|
|
28
|
+
*/
|
|
29
|
+
export declare function countWildcards(pattern: string): number;
|
|
30
|
+
/**
|
|
31
|
+
* Count the number of literal (non-wildcard) characters in a pattern.
|
|
32
|
+
* More literal characters means a more specific (concrete) pattern.
|
|
33
|
+
*/
|
|
34
|
+
export declare function countLiterals(pattern: string): number;
|
|
35
|
+
//# sourceMappingURL=glob.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../../src/lib/glob.ts"],"names":[],"mappings":"AAEA,qEAAqE;AACrE,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAEpE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAGvD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMtD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMrD"}
|
package/dist/lib/glob.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import picomatch from 'picomatch';
|
|
2
|
+
/** Check whether a string matches a glob pattern using picomatch. */
|
|
3
|
+
export function matchesPattern(str, pattern) {
|
|
4
|
+
return picomatch.isMatch(str, pattern);
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Check whether pattern A "dominates" pattern B, meaning A is more concrete
|
|
8
|
+
* (more specific) than B. This is the primary specificity criterion.
|
|
9
|
+
*
|
|
10
|
+
* A dominates B when A is a literal string (no wildcards) and B as a glob
|
|
11
|
+
* pattern matches A. Intuitively: if B is broad enough to match the literal
|
|
12
|
+
* text of A, then B is more general and A is more concrete.
|
|
13
|
+
*
|
|
14
|
+
* This check only applies when A has no wildcards. When both patterns contain
|
|
15
|
+
* wildcards, the literal-match test can produce false positives (e.g. `ls ?`
|
|
16
|
+
* matches the literal "ls *", but that doesn't make `ls *` more general).
|
|
17
|
+
* In those cases, we fall through to wildcard count and literal character
|
|
18
|
+
* count instead.
|
|
19
|
+
*
|
|
20
|
+
* Examples:
|
|
21
|
+
* `git push` dominates `git *` — `git *` matches the literal "git push"
|
|
22
|
+
* `git push origin main` dominates `git push *` — `git push *` matches "git push origin main"
|
|
23
|
+
* `rm -rf` dominates `rm *` — `rm *` matches the literal "rm -rf"
|
|
24
|
+
*
|
|
25
|
+
* @returns True if A is more concrete than B.
|
|
26
|
+
*/
|
|
27
|
+
export function dominates(a, b) {
|
|
28
|
+
if (countWildcards(a) > 0)
|
|
29
|
+
return false;
|
|
30
|
+
return matchesPattern(a, b);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Count the number of wildcard characters (`*` and `?`) in a pattern.
|
|
34
|
+
* Fewer wildcards means a more specific (concrete) pattern.
|
|
35
|
+
*/
|
|
36
|
+
export function countWildcards(pattern) {
|
|
37
|
+
let count = 0;
|
|
38
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
39
|
+
if (pattern[i] === '*' || pattern[i] === '?')
|
|
40
|
+
count++;
|
|
41
|
+
}
|
|
42
|
+
return count;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Count the number of literal (non-wildcard) characters in a pattern.
|
|
46
|
+
* More literal characters means a more specific (concrete) pattern.
|
|
47
|
+
*/
|
|
48
|
+
export function countLiterals(pattern) {
|
|
49
|
+
let count = 0;
|
|
50
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
51
|
+
if (pattern[i] !== '*' && pattern[i] !== '?')
|
|
52
|
+
count++;
|
|
53
|
+
}
|
|
54
|
+
return count;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=glob.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glob.js","sourceRoot":"","sources":["../../src/lib/glob.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,qEAAqE;AACrE,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAe;IACvD,OAAO,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,SAAS,CAAC,CAAS,EAAE,CAAS;IAC1C,IAAI,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IACxC,OAAO,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAChC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe;IAC1C,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG;YAAE,KAAK,EAAE,CAAC;IAC1D,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe;IACzC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG;YAAE,KAAK,EAAE,CAAC;IAC1D,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC"}
|
package/dist/lib/permission.d.ts
CHANGED
|
@@ -1,25 +1,14 @@
|
|
|
1
|
-
import { PermissionAction, PermissionDenyReason } from './types.js';
|
|
1
|
+
import { PermissionAction, PermissionDenyReason, type ParsedSubcommand } from './types.js';
|
|
2
2
|
import type { ShellConfiguration } from './config.js';
|
|
3
|
-
|
|
4
|
-
* Split a shell command into individual subcommands by shell operators,
|
|
5
|
-
* respecting quoted strings. Operators that trigger a split:
|
|
6
|
-
* - `&&` (logical AND)
|
|
7
|
-
* - `||` (logical OR)
|
|
8
|
-
* - `|` (pipe)
|
|
9
|
-
* - `;` (sequential)
|
|
10
|
-
*
|
|
11
|
-
* After splitting, shell redirects are stripped from each subcommand.
|
|
12
|
-
*
|
|
13
|
-
* @param input - Raw shell command string.
|
|
14
|
-
* @returns Array of individual subcommands (with redirects stripped).
|
|
15
|
-
*/
|
|
16
|
-
export declare function parseSubcommands(input: string): string[];
|
|
3
|
+
import { parseSubcommands } from './redirect-parser.js';
|
|
17
4
|
/** Result of a permission check. */
|
|
18
5
|
export interface PermissionCheckResult {
|
|
19
6
|
/** The overall action (allow or deny). */
|
|
20
7
|
action: PermissionAction;
|
|
21
|
-
/** The individual
|
|
8
|
+
/** The individual subcommand cores that were checked. */
|
|
22
9
|
subcommands: string[];
|
|
10
|
+
/** The parsed subcommand fragments, including the redirect tokens. */
|
|
11
|
+
fragments: ParsedSubcommand[];
|
|
23
12
|
/** Why the command was denied; present when `action` is deny. */
|
|
24
13
|
denyReason?: PermissionDenyReason;
|
|
25
14
|
}
|
|
@@ -48,6 +37,12 @@ export declare function workspaceForPath(path: string, accessRoots: readonly str
|
|
|
48
37
|
* and uses its {@link WorkspacePermissions}. Without a workspace root, the global
|
|
49
38
|
* fallback settings apply.
|
|
50
39
|
*
|
|
40
|
+
* A rule's family is its effective type (`type` or the permissions'
|
|
41
|
+
* `defaultType`): command rules match command cores, redirect rules match
|
|
42
|
+
* redirect targets. The two families never cross — a target can never be
|
|
43
|
+
* evaluated as a command and a command core can never be authorized by a
|
|
44
|
+
* redirect rule. See docs/architecture.md for the full redirect model.
|
|
45
|
+
*
|
|
51
46
|
* When multiple rules match a subcommand, the most specific rule wins.
|
|
52
47
|
* Specificity is determined by four criteria, applied in order:
|
|
53
48
|
*
|
|
@@ -77,25 +72,50 @@ export declare class PermissionSystem {
|
|
|
77
72
|
/**
|
|
78
73
|
* Check if a command is allowed.
|
|
79
74
|
*
|
|
75
|
+
* Command cores are matched against command rules; redirect targets are
|
|
76
|
+
* matched against redirect rules (family from each rule's effective type).
|
|
77
|
+
* Each fragment's core is checked first, then each of its redirect tokens;
|
|
78
|
+
* the first denial fails the whole command.
|
|
79
|
+
*
|
|
80
80
|
* @param command - Raw shell command (may contain compositions).
|
|
81
81
|
* @param workspaceRoot - Optional resolved workspace root to resolve rules against.
|
|
82
82
|
* @returns The permission check result with action and parsed subcommands.
|
|
83
83
|
*/
|
|
84
84
|
check(command: string, workspaceRoot?: string): PermissionCheckResult;
|
|
85
|
+
private denyResult;
|
|
86
|
+
/**
|
|
87
|
+
* Match a single command core against the command rules and return the
|
|
88
|
+
* action of the most specific matching rule, or the default action when
|
|
89
|
+
* no rule matches. A winning allow rule whose access level the workspace
|
|
90
|
+
* cannot satisfy (a write rule in a read-only workspace) is denied with
|
|
91
|
+
* reason `'write-access'`.
|
|
92
|
+
*/
|
|
93
|
+
private checkCore;
|
|
85
94
|
/**
|
|
86
|
-
*
|
|
95
|
+
* Match a single redirect token against the redirect rules.
|
|
87
96
|
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* allow rule
|
|
92
|
-
* rule
|
|
97
|
+
* Redirects default to deny: a token with no matching redirect rule is
|
|
98
|
+
* denied. A deny rule denies the token. An allow rule must additionally
|
|
99
|
+
* satisfy the mode-to-tier binding — `output` tokens need a write-class
|
|
100
|
+
* allow rule (gated by workspace writability), `input` tokens a read-class
|
|
101
|
+
* allow rule.
|
|
102
|
+
*/
|
|
103
|
+
private checkToken;
|
|
104
|
+
/** Effective type of a rule: its explicit type or the permissions' default type. */
|
|
105
|
+
private effectiveType;
|
|
106
|
+
/**
|
|
107
|
+
* Find the most specific rule whose pattern matches `value`, or undefined
|
|
108
|
+
* when no rule matches. See the class doc for the specificity criteria.
|
|
93
109
|
*/
|
|
94
|
-
private
|
|
110
|
+
private pickMatchingRule;
|
|
111
|
+
private sortBySpecificity;
|
|
95
112
|
/**
|
|
96
113
|
* Apply a single winning rule to a subcommand. An allow rule requiring
|
|
97
|
-
* write access
|
|
114
|
+
* write access (its explicit access or the default access) is denied when
|
|
115
|
+
* the workspace root is not writable.
|
|
98
116
|
*/
|
|
99
117
|
private decide;
|
|
100
118
|
}
|
|
119
|
+
export { parseSubcommands };
|
|
120
|
+
export type { ParsedSubcommand };
|
|
101
121
|
//# sourceMappingURL=permission.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission.d.ts","sourceRoot":"","sources":["../../src/lib/permission.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"permission.d.ts","sourceRoot":"","sources":["../../src/lib/permission.ts"],"names":[],"mappings":"AACA,OAAO,EACH,gBAAgB,EAEhB,oBAAoB,EAGpB,KAAK,gBAAgB,EAIxB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,oCAAoC;AACpC,MAAM,WAAW,qBAAqB;IAClC,0CAA0C;IAC1C,MAAM,EAAE,gBAAgB,CAAC;IACzB,yDAAyD;IACzD,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,sEAAsE;IACtE,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,iEAAiE;IACjE,UAAU,CAAC,EAAE,oBAAoB,CAAC;CACrC;AAaD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAUrF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,gBAAgB;IACzB,OAAO,CAAC,OAAO,CAAkD;IACjE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqC;IAE9D;;;;OAIG;gBACS,MAAM,EAAE,kBAAkB,EAAE,QAAQ,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,OAAO;IAKrF;;;;;;;;;;;OAWG;IACH,KAAK,CAAC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