dsh-extra-paths 0.2.0 → 0.3.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/README.md +192 -28
- package/README.zh.md +166 -21
- package/lib/argv.js +96 -24
- package/lib/argv.js.map +1 -1
- package/lib/client.js +1310 -450
- package/lib/config.js +140 -44
- package/lib/config.js.map +1 -1
- package/lib/context.js +48 -12
- package/lib/context.js.map +1 -1
- package/lib/denial.js +132 -0
- package/lib/denial.js.map +1 -0
- package/lib/index.js +40 -5
- package/lib/index.js.map +1 -1
- package/lib/name-rule.js +217 -0
- package/lib/name-rule.js.map +1 -0
- package/lib/paths.js +155 -27
- package/lib/paths.js.map +1 -1
- package/lib/pattern.js +128 -62
- package/lib/pattern.js.map +1 -1
- package/lib/platform.js +325 -0
- package/lib/platform.js.map +1 -0
- package/lib/preview.js +47 -20
- package/lib/preview.js.map +1 -1
- package/lib/resolve.js +345 -64
- package/lib/resolve.js.map +1 -1
- package/lib/schema.js +19 -6
- package/lib/schema.js.map +1 -1
- package/lib/shell-dialect.js +92 -0
- package/lib/shell-dialect.js.map +1 -0
- package/lib/tool-guard.js +214 -0
- package/lib/tool-guard.js.map +1 -0
- package/lib/types/argv.d.ts +50 -12
- package/lib/types/config.d.ts +29 -13
- package/lib/types/context.d.ts +6 -1
- package/lib/types/denial.d.ts +88 -0
- package/lib/types/index.d.ts +8 -4
- package/lib/types/name-rule.d.ts +112 -0
- package/lib/types/paths.d.ts +55 -10
- package/lib/types/pattern.d.ts +43 -5
- package/lib/types/platform.d.ts +148 -0
- package/lib/types/preview.d.ts +39 -3
- package/lib/types/resolve.d.ts +129 -23
- package/lib/types/schema.d.ts +24 -8
- package/lib/types/shell-dialect.d.ts +60 -0
- package/lib/types/tool-guard.d.ts +103 -0
- package/lib/types/wrap-fs.d.ts +86 -4
- package/lib/types/wrap-sandbox.d.ts +26 -6
- package/lib/wrap-fs.js +323 -47
- package/lib/wrap-fs.js.map +1 -1
- package/lib/wrap-sandbox.js +149 -12
- package/lib/wrap-sandbox.js.map +1 -1
- package/package.json +3 -1
package/lib/config.js
CHANGED
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The plugin's configuration vocabulary: a plugin-level default
|
|
2
|
+
* The plugin's configuration vocabulary: a plugin-level default access level and
|
|
3
3
|
* surface set, plus per-path entries that override them. Everything here is
|
|
4
4
|
* pure so the settings schema, the CLI-facing validator, and the enforcement
|
|
5
5
|
* layers share one normalisation.
|
|
6
|
+
*
|
|
7
|
+
* 0.3.0 widened the old `scope` (`write` | `always-write`) into a full access
|
|
8
|
+
* level: `deny` (no read, no write), `read` (read-only, even inside the
|
|
9
|
+
* workspace), `write` (writable while the session policy is workspace-write)
|
|
10
|
+
* and `always-write` (writable under read-only too). The legacy `scope` field
|
|
11
|
+
* and `defaultScope` are still accepted and map onto the new vocabulary, so an
|
|
12
|
+
* existing settings document keeps working unchanged.
|
|
6
13
|
* @module dsh-extra-paths/config
|
|
7
14
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
15
|
+
import { classifySpelling, isAbsoluteSpelling, isBareNameSpelling, isVolumeRootSpelling, normalizePatternSpelling } from './platform.js';
|
|
16
|
+
/** All access levels, from most restrictive to most permissive. */
|
|
17
|
+
export const ACCESSES = ['deny', 'read', 'write', 'always-write'];
|
|
10
18
|
/** All surfaces. `fs` is the write/edit tool family; `shell` is the subprocess sandbox. */
|
|
11
19
|
export const SURFACES = ['fs', 'shell'];
|
|
12
|
-
const
|
|
20
|
+
const DEFAULT_ACCESS = 'write';
|
|
13
21
|
const DEFAULT_SURFACES = [...SURFACES];
|
|
14
|
-
function
|
|
22
|
+
function readAccess(value, fallback, label) {
|
|
15
23
|
if (value === undefined)
|
|
16
24
|
return fallback;
|
|
17
|
-
if (typeof value === 'string' &&
|
|
25
|
+
if (typeof value === 'string' && ACCESSES.includes(value))
|
|
18
26
|
return value;
|
|
19
|
-
throw new Error(`${label}:
|
|
27
|
+
throw new Error(`${label}: access must be one of ${ACCESSES.join(' | ')}, received ${JSON.stringify(value)}`);
|
|
20
28
|
}
|
|
21
29
|
function readSurfaces(value, fallback, label) {
|
|
22
30
|
if (value === undefined)
|
|
@@ -33,6 +41,41 @@ function readSurfaces(value, fallback, label) {
|
|
|
33
41
|
}
|
|
34
42
|
return surfaces;
|
|
35
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Pick one entry's access level, resolving the legacy `scope` alias. Writing
|
|
46
|
+
* both spellings with DIFFERENT meanings is a configuration error: silently
|
|
47
|
+
* preferring one would store a rule the user did not intend.
|
|
48
|
+
*/
|
|
49
|
+
function readEntryAccess(entry, fallback, label) {
|
|
50
|
+
const access = readAccess(entry.access, fallback, `${label}.access`);
|
|
51
|
+
if (entry.scope === undefined)
|
|
52
|
+
return access;
|
|
53
|
+
const legacy = readAccess(entry.scope, fallback, `${label}.scope`);
|
|
54
|
+
if (entry.access !== undefined && legacy !== access) {
|
|
55
|
+
throw new Error(`${label}: access ${JSON.stringify(access)} conflicts with legacy scope ${JSON.stringify(legacy)}; `
|
|
56
|
+
+ 'use one spelling');
|
|
57
|
+
}
|
|
58
|
+
// Without an explicit `access`, the legacy `scope` is the entry's level (the
|
|
59
|
+
// old document only ever stored `scope`, so this is the migration path).
|
|
60
|
+
return entry.access === undefined ? legacy : access;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The canonical comparison key used by the duplicate check. Windows spellings
|
|
64
|
+
* are compared case-insensitively with both separator kinds stripped (Windows
|
|
65
|
+
* treats them as the same path); POSIX spellings only lose a trailing `/`.
|
|
66
|
+
*/
|
|
67
|
+
function duplicateKey(path) {
|
|
68
|
+
// A bare name is a NAME RULE, not a path: two identical names are one rule.
|
|
69
|
+
if (isBareNameSpelling(path))
|
|
70
|
+
return `name:${path}`;
|
|
71
|
+
const kind = classifySpelling(path);
|
|
72
|
+
if (kind === 'windows-absolute' || kind === 'windows-home') {
|
|
73
|
+
// `windows-home` cannot be collapsed without the home directory; a lexical
|
|
74
|
+
// separator/case fold is enough for a duplicate check.
|
|
75
|
+
return path.replaceAll('/', '\\').replace(/\\+$/, '').toLowerCase();
|
|
76
|
+
}
|
|
77
|
+
return path.replace(/\/+$/, '') || '/';
|
|
78
|
+
}
|
|
36
79
|
/**
|
|
37
80
|
* Normalise untrusted configuration, applying defaults and rejecting anything
|
|
38
81
|
* the enforcement layers could not act on.
|
|
@@ -41,7 +84,14 @@ function readSurfaces(value, fallback, label) {
|
|
|
41
84
|
* @throws {Error} on a malformed entry, unknown vocabulary, or empty surfaces.
|
|
42
85
|
*/
|
|
43
86
|
export function normalizeConfig(raw) {
|
|
44
|
-
const
|
|
87
|
+
const legacyDefault = raw?.defaultScope === undefined ? undefined : readAccess(raw.defaultScope, DEFAULT_ACCESS, 'defaultScope');
|
|
88
|
+
const defaultAccess = raw?.defaultAccess === undefined
|
|
89
|
+
? (legacyDefault ?? DEFAULT_ACCESS)
|
|
90
|
+
: readAccess(raw.defaultAccess, legacyDefault ?? DEFAULT_ACCESS, 'defaultAccess');
|
|
91
|
+
if (legacyDefault !== undefined && raw?.defaultAccess !== undefined && legacyDefault !== defaultAccess) {
|
|
92
|
+
throw new Error(`defaultAccess ${JSON.stringify(defaultAccess)} conflicts with legacy defaultScope `
|
|
93
|
+
+ `${JSON.stringify(legacyDefault)}; use one spelling`);
|
|
94
|
+
}
|
|
45
95
|
const defaultSurfaces = readSurfaces(raw?.defaultSurfaces, DEFAULT_SURFACES, 'defaultSurfaces');
|
|
46
96
|
const list = raw?.paths;
|
|
47
97
|
if (list !== undefined && !Array.isArray(list)) {
|
|
@@ -58,66 +108,112 @@ export function normalizeConfig(raw) {
|
|
|
58
108
|
const cause = entry.surfaces === undefined && defaultSurfaces.length === 0 ? ' (defaultSurfaces is empty)' : '';
|
|
59
109
|
throw new Error(`${label}: at least one surface is required${cause}`);
|
|
60
110
|
}
|
|
61
|
-
return { path: entry.path.trim(),
|
|
111
|
+
return { path: entry.path.trim(), access: readEntryAccess(entry, defaultAccess, label), surfaces };
|
|
62
112
|
});
|
|
63
|
-
return {
|
|
113
|
+
return { defaultAccess, defaultSurfaces, paths };
|
|
64
114
|
}
|
|
65
115
|
/**
|
|
66
|
-
* Whether a
|
|
67
|
-
* outright. A bare drive (`C:`) is drive-RELATIVE rather
|
|
68
|
-
* rejected conservatively: on Windows it can still
|
|
69
|
-
* and the message says so instead of mislabelling it.
|
|
116
|
+
* Whether a spelling names a filesystem root (or a bare drive), which would
|
|
117
|
+
* disable the sandbox outright. A bare drive (`C:`) is drive-RELATIVE rather
|
|
118
|
+
* than a root, but it is rejected conservatively: on Windows it can still
|
|
119
|
+
* resolve to a whole volume, and the message says so instead of mislabelling it.
|
|
120
|
+
* @param path - a path spelling.
|
|
121
|
+
* @returns true for `/`, `C:`, `C:\`, `C:/` and a UNC share root.
|
|
70
122
|
*/
|
|
71
123
|
export function isFilesystemRoot(path) {
|
|
72
|
-
return
|
|
124
|
+
return isVolumeRootSpelling(path);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Reject one pattern the resolver could never walk safely. The grammar and the
|
|
128
|
+
* walk caps live in `pattern.ts`; this is the SAVE-TIME gate so the user learns
|
|
129
|
+
* before a walk is ever attempted.
|
|
130
|
+
*
|
|
131
|
+
* Two anchor families:
|
|
132
|
+
* - ABSOLUTE (`/…`, `~`, `C:\…`): needs at least two literal segments and must
|
|
133
|
+
* not start at a volume root — `/**` and `~/**` would walk a filesystem/home;
|
|
134
|
+
* - WORKSPACE-RELATIVE (a leading `**` then `.git`, an anchor directory then
|
|
135
|
+
* the same, or a leading `..` then `**` then the name): anchored at
|
|
136
|
+
* the session workspace like a relative path, so no minimum depth; a leading
|
|
137
|
+
* wildcard pattern must still contain one literal segment, or it would sweep
|
|
138
|
+
* the whole workspace.
|
|
139
|
+
*/
|
|
140
|
+
function validatePattern(path, label) {
|
|
141
|
+
const source = normalizePatternSpelling(path);
|
|
142
|
+
if (!source.includes('*'))
|
|
143
|
+
return;
|
|
144
|
+
const segments = source.split('/').filter(segment => segment !== '');
|
|
145
|
+
const firstWildcard = segments.findIndex(segment => segment.includes('*'));
|
|
146
|
+
const anchorPrefix = source.slice(0, source.indexOf('*'));
|
|
147
|
+
// Absoluteness is judged on the RAW prefix (see pattern.ts): `/**` strips to
|
|
148
|
+
// an empty anchor but is still an absolute root pattern.
|
|
149
|
+
const absoluteAnchor = isAbsoluteSpelling(anchorPrefix);
|
|
150
|
+
const anchorSpelling = anchorPrefix.replace(/\/+$/, '');
|
|
151
|
+
const walk = segments.slice(firstWildcard);
|
|
152
|
+
if (absoluteAnchor) {
|
|
153
|
+
const anchorDepth = segments.slice(0, firstWildcard).length;
|
|
154
|
+
if (anchorDepth < 2) {
|
|
155
|
+
throw new Error(`${label}: pattern ${JSON.stringify(path)} needs a literal anchor of at least two segments `
|
|
156
|
+
+ '(for example ~/projects/**/.worktrees/..)');
|
|
157
|
+
}
|
|
158
|
+
if (isVolumeRootSpelling(anchorSpelling)) {
|
|
159
|
+
throw new Error(`${label}: pattern ${JSON.stringify(path)} starts at a volume root and would walk a whole volume`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
else if (anchorSpelling === '' && !walk.some(segment => !segment.includes('*') && segment !== '..')) {
|
|
163
|
+
throw new Error(`${label}: pattern ${JSON.stringify(path)} would sweep the whole workspace; `
|
|
164
|
+
+ 'add a literal segment (for example **/.git) or an anchor directory');
|
|
165
|
+
}
|
|
166
|
+
let last = walk.length - 1;
|
|
167
|
+
while (last >= 0 && walk[last] === '..')
|
|
168
|
+
last -= 1;
|
|
169
|
+
if (walk.slice(0, last + 1).includes('..')) {
|
|
170
|
+
throw new Error(`${label}: '..' may only appear at the END of a pattern, received ${JSON.stringify(path)}`);
|
|
171
|
+
}
|
|
73
172
|
}
|
|
74
173
|
/**
|
|
75
174
|
* The settings service's `validate` hook: refuse a write the plugin could never
|
|
76
175
|
* act on, so the user learns at save time instead of storing a dead section.
|
|
176
|
+
* A `foreign` entry (a Windows path on a POSIX host) is NOT an error: one shared
|
|
177
|
+
* configuration must remain savable on every platform and simply stays inactive.
|
|
77
178
|
* @param raw - the resolved section the write would store.
|
|
78
|
-
* @throws {Error} on a duplicate literal entry
|
|
179
|
+
* @throws {Error} on a duplicate literal entry, an ambiguous drive-relative
|
|
180
|
+
* spelling, a volume root, or an unsafe pattern.
|
|
79
181
|
*/
|
|
80
182
|
export function validateConfig(raw) {
|
|
81
183
|
const config = normalizeConfig(raw);
|
|
82
|
-
// Trailing separators are stripped for the duplicate key so `/a` and `/a/`
|
|
83
|
-
// collide here rather than silently merging later; `/` keeps its meaning.
|
|
84
184
|
const firstSeen = new Map();
|
|
85
185
|
config.paths.forEach((entry, index) => {
|
|
186
|
+
const label = `paths[${index}]`;
|
|
187
|
+
// A bare name (`.git`, `.env`) is matched at any depth; it is neither a
|
|
188
|
+
// volume root nor a wildcard pattern, so only the duplicate check applies.
|
|
189
|
+
// All four access levels stay legal (the docs recommend deny/read, but a
|
|
190
|
+
// name-scoped grant is expressible and the user may want it).
|
|
191
|
+
if (isBareNameSpelling(entry.path)) {
|
|
192
|
+
const key = `name:${entry.path}`;
|
|
193
|
+
const first = firstSeen.get(key);
|
|
194
|
+
if (first !== undefined) {
|
|
195
|
+
throw new Error(`${label}: duplicate name rule ${JSON.stringify(entry.path)} (first configured at paths[${first}])`);
|
|
196
|
+
}
|
|
197
|
+
firstSeen.set(key, index);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
86
200
|
// The root check runs FIRST: for ['//', '/'] the duplicate key would
|
|
87
201
|
// otherwise report the less useful of two true reasons.
|
|
88
202
|
if (isFilesystemRoot(entry.path)) {
|
|
89
|
-
throw new Error(
|
|
203
|
+
throw new Error(`${label}: ${JSON.stringify(entry.path)} names a filesystem root (or a bare drive) `
|
|
90
204
|
+ 'and would disable the sandbox');
|
|
91
205
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
206
|
+
if (classifySpelling(entry.path) === 'windows-drive-relative') {
|
|
207
|
+
throw new Error(`${label}: ${JSON.stringify(entry.path)} is a drive-relative path (it depends on that drive's current `
|
|
208
|
+
+ 'directory); use an absolute path such as C:\\<dir>');
|
|
209
|
+
}
|
|
210
|
+
const key = duplicateKey(entry.path);
|
|
96
211
|
const first = firstSeen.get(key);
|
|
97
212
|
if (first !== undefined) {
|
|
98
|
-
throw new Error(
|
|
213
|
+
throw new Error(`${label}: duplicate path entry ${JSON.stringify(entry.path)} (first configured at paths[${first}])`);
|
|
99
214
|
}
|
|
100
215
|
firstSeen.set(key, index);
|
|
101
|
-
|
|
102
|
-
// deep enough to bound the search: `~/projects/**` is fine, `~/**` and `/**`
|
|
103
|
-
// would walk a whole home directory or the filesystem and are refused here
|
|
104
|
-
// rather than silently yielding nothing at resolve time.
|
|
105
|
-
if (entry.path.includes('*')) {
|
|
106
|
-
const segments = entry.path.split('/').filter(segment => segment !== '');
|
|
107
|
-
const firstWildcard = segments.findIndex(segment => segment.includes('*'));
|
|
108
|
-
const anchorDepth = segments.slice(0, firstWildcard).length;
|
|
109
|
-
if (anchorDepth < 2) {
|
|
110
|
-
throw new Error(`paths[${index}]: pattern ${JSON.stringify(entry.path)} needs a literal anchor of at least two segments `
|
|
111
|
-
+ '(for example ~/projects/**/.worktrees/..)');
|
|
112
|
-
}
|
|
113
|
-
const walk = segments.slice(firstWildcard);
|
|
114
|
-
let last = walk.length - 1;
|
|
115
|
-
while (last >= 0 && walk[last] === '..')
|
|
116
|
-
last -= 1;
|
|
117
|
-
if (walk.slice(0, last + 1).includes('..')) {
|
|
118
|
-
throw new Error(`paths[${index}]: '..' may only appear at the END of a pattern, received ${JSON.stringify(entry.path)}`);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
216
|
+
validatePattern(entry.path, label);
|
|
121
217
|
});
|
|
122
218
|
}
|
|
123
219
|
//# sourceMappingURL=config.js.map
|
package/lib/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"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C,GAAG,CAAC,GAAG,CAAC,CAAA;QAChC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CACb,GAAG,KAAK,0BAA0B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,+BAA+B,KAAK,IAAI,CACrG,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACzB,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IACpC,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/lib/context.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The runtime-context section that tells the model which extra roots this
|
|
3
|
-
* session may write under
|
|
3
|
+
* session may write under and where it must not write or read, so it neither
|
|
4
|
+
* refuses nor escalates pre-emptively and never tries a denied path.
|
|
4
5
|
* @module dsh-extra-paths/context
|
|
5
6
|
*/
|
|
6
7
|
import { resolveRoots } from './resolve.js';
|
|
7
8
|
/**
|
|
8
9
|
* Render the section text, or an empty string when there is nothing to say.
|
|
10
|
+
*
|
|
11
|
+
* Only rules with a visible effect are rendered: an inactive entry (missing,
|
|
12
|
+
* rejected or foreign) grants and restricts nothing, so it is the preview's job
|
|
13
|
+
* — not the model's — to report it.
|
|
9
14
|
* @param readConfig - current configuration snapshot.
|
|
10
15
|
* @param cwd - the calling session's workspace (undefined outside a session).
|
|
11
16
|
* @returns the prompt text.
|
|
@@ -14,17 +19,48 @@ export function renderExtraPathsContext(readConfig, cwd) {
|
|
|
14
19
|
if (cwd === undefined || cwd === '')
|
|
15
20
|
return '';
|
|
16
21
|
const report = resolveRoots(readConfig(), cwd);
|
|
17
|
-
if (report.roots.length === 0
|
|
22
|
+
if (report.roots.length === 0 && report.readOnly.length === 0 && report.denied.length === 0
|
|
23
|
+
&& report.nameRules.length === 0)
|
|
18
24
|
return '';
|
|
19
|
-
const lines =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
const lines = [];
|
|
26
|
+
if (report.roots.length > 0) {
|
|
27
|
+
lines.push('Additional configured writable roots for this session (no approval is required to write under them):');
|
|
28
|
+
for (const root of report.roots) {
|
|
29
|
+
const reach = root.scope === 'always-write'
|
|
30
|
+
? 'writable regardless of the standing sandbox mode'
|
|
31
|
+
: 'writable while the policy is workspace-write';
|
|
32
|
+
lines.push(` - ${root.root} — ${reach} (surfaces: ${root.surfaces.join('+')})`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (report.readOnly.length > 0) {
|
|
36
|
+
lines.push('Read-only roots (do not write):');
|
|
37
|
+
for (const rule of report.readOnly) {
|
|
38
|
+
lines.push(` - ${rule.root} (surfaces: ${rule.surfaces.join('+')})`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (report.denied.length > 0) {
|
|
42
|
+
lines.push('Denied paths (do not read or write):');
|
|
43
|
+
for (const rule of report.denied) {
|
|
44
|
+
lines.push(` - ${rule.root} (surfaces: ${rule.surfaces.join('+')})`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// NAME rules are not concrete paths, so they get their own bullets: telling
|
|
48
|
+
// the model "the component .git is denied ANYWHERE under the workspace and the
|
|
49
|
+
// writable roots" is what stops it from trying one repository after another.
|
|
50
|
+
const deniedNames = report.nameRules.filter(rule => rule.access === 'deny');
|
|
51
|
+
if (deniedNames.length > 0) {
|
|
52
|
+
lines.push('Denied names (matched at any depth under the session workspace and the configured writable roots; do not read or write them):');
|
|
53
|
+
for (const rule of deniedNames) {
|
|
54
|
+
lines.push(` - ${rule.raw} (surfaces: ${rule.surfaces.join('+')})`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const readOnlyNames = report.nameRules.filter(rule => rule.access === 'read');
|
|
58
|
+
if (readOnlyNames.length > 0) {
|
|
59
|
+
lines.push('Read-only names (matched at any depth; do not write them):');
|
|
60
|
+
for (const rule of readOnlyNames) {
|
|
61
|
+
lines.push(` - ${rule.raw} (surfaces: ${rule.surfaces.join('+')})`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return lines.join('\n');
|
|
29
65
|
}
|
|
30
66
|
//# sourceMappingURL=context.js.map
|
package/lib/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C;;;;;;;;;GASG;AACH,MAAM,UAAU,uBAAuB,CAAC,UAAkC,EAAE,GAAuB;IACjG,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,EAAE;QAAE,OAAO,EAAE,CAAA;IAC9C,MAAM,MAAM,GAAG,YAAY,CAAC,UAAU,EAAE,EAAE,GAAG,CAAC,CAAA;IAC9C,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;WACtF,MAAM,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAA;IAC7C,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5B,KAAK,CAAC,IAAI,CAAC,sGAAsG,CAAC,CAAA;QAClH,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YAChC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,KAAK,cAAc;gBACzC,CAAC,CAAC,kDAAkD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,GAAG,eAAe,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACtE,CAAC;IACH,CAAC;IACD,MAAM,aAAa,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,CAAA;IAC7E,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,KAAK,CAAC,IAAI,CAAC,4DAA4D,CAAC,CAAA;QACxE,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;YACjC,KAAK,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,GAAG,eAAe,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACtE,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC"}
|
package/lib/denial.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shared vocabulary of a refusal: which configured rule covers a target, and
|
|
3
|
+
* what the user sees when that rule fires.
|
|
4
|
+
*
|
|
5
|
+
* Why a plain `Error` subclass instead of the host's `FsError`: the plugin must
|
|
6
|
+
* not import an `@deepseek-ai/*` VALUE (every peer is optional and a runtime
|
|
7
|
+
* import would make the plugin fail to load on a host generation that renamed the
|
|
8
|
+
* error class). The tool layer renders a thrown ordinary `Error` as
|
|
9
|
+
* `Error: <message>`, so a self-explanatory message plus a stable
|
|
10
|
+
* {@link ACCESS_DENIED_CODE} is all a consumer needs.
|
|
11
|
+
*
|
|
12
|
+
* `matchDenied` / `matchReadOnly` are the ONE containment test both enforcement
|
|
13
|
+
* surfaces share: they filter by surface and access, then delegate to
|
|
14
|
+
* `isUnder`, whose identity fallback (dev+ino) is what makes a DENY as hard to
|
|
15
|
+
* dodge as a grant (a casing/8.3/WSL alias must not slip past it).
|
|
16
|
+
* @module dsh-extra-paths/denial
|
|
17
|
+
*/
|
|
18
|
+
import { isUnder } from './paths.js';
|
|
19
|
+
/** The stable error code a tool result or a consumer can match on. */
|
|
20
|
+
export const ACCESS_DENIED_CODE = 'EXTRA_PATHS_ACCESS_DENIED';
|
|
21
|
+
/**
|
|
22
|
+
* A configured `deny`/`read` rule refused one operation.
|
|
23
|
+
*
|
|
24
|
+
* Deliberately an ordinary Error: the message is the user-visible explanation,
|
|
25
|
+
* and the `code` lets a caller distinguish "the plugin said no" from a backend
|
|
26
|
+
* failure without depending on the host's error hierarchy.
|
|
27
|
+
*/
|
|
28
|
+
export class AccessDeniedError extends Error {
|
|
29
|
+
/** Stable machine-readable reason (see {@link ACCESS_DENIED_CODE}). */
|
|
30
|
+
code = ACCESS_DENIED_CODE;
|
|
31
|
+
/**
|
|
32
|
+
* @param message - the user-visible explanation.
|
|
33
|
+
*/
|
|
34
|
+
constructor(message) {
|
|
35
|
+
super(message);
|
|
36
|
+
this.name = 'AccessDeniedError';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The first rule of `access` that applies to `targetKey` on `surface`.
|
|
41
|
+
*
|
|
42
|
+
* "First" is report order (configured order per canonical root). Because a
|
|
43
|
+
* target cannot be under two rules of DIFFERENT severity with the more permissive
|
|
44
|
+
* one selected — deny wins by call order — a caller checks deny before read-only.
|
|
45
|
+
* @param rules - resolved rules (a report's `denied` or `readOnly` list).
|
|
46
|
+
* @param surface - the enforcement surface asking.
|
|
47
|
+
* @param access - the level the rules must carry.
|
|
48
|
+
* @param targetKey - a canonical path (the identity the host resolved).
|
|
49
|
+
* @param facts - host facts (defaults to the discovered ones).
|
|
50
|
+
* @returns the matching rule, or undefined.
|
|
51
|
+
*/
|
|
52
|
+
function matchRule(rules, surface, access, targetKey, facts) {
|
|
53
|
+
for (const rule of rules) {
|
|
54
|
+
if (rule.access !== access)
|
|
55
|
+
continue;
|
|
56
|
+
if (!rule.surfaces.includes(surface))
|
|
57
|
+
continue;
|
|
58
|
+
if (isUnder(targetKey, rule.root, facts))
|
|
59
|
+
return rule;
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Whether a `deny` rule covers this target on this surface.
|
|
65
|
+
* @param rules - resolved rules (normally a report's `denied` list).
|
|
66
|
+
* @param surface - the enforcement surface asking.
|
|
67
|
+
* @param targetKey - a canonical path.
|
|
68
|
+
* @param facts - host facts (defaults to the discovered ones).
|
|
69
|
+
* @returns the matching deny rule, or undefined (no opinion).
|
|
70
|
+
*/
|
|
71
|
+
export function matchDenied(rules, surface, targetKey, facts) {
|
|
72
|
+
return matchRule(rules, surface, 'deny', targetKey, facts);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Whether a `read` rule covers this target on this surface: reads still pass,
|
|
76
|
+
* writes must be refused (a downgrade, not a denial).
|
|
77
|
+
* @param rules - resolved rules (normally a report's `readOnly` list).
|
|
78
|
+
* @param surface - the enforcement surface asking.
|
|
79
|
+
* @param targetKey - a canonical path.
|
|
80
|
+
* @param facts - host facts (defaults to the discovered ones).
|
|
81
|
+
* @returns the matching read-only rule, or undefined (no opinion).
|
|
82
|
+
*/
|
|
83
|
+
export function matchReadOnly(rules, surface, targetKey, facts) {
|
|
84
|
+
return matchRule(rules, surface, 'read', targetKey, facts);
|
|
85
|
+
}
|
|
86
|
+
/** Quote one path the way the existing warning messages quote spellings. */
|
|
87
|
+
function quoted(value) {
|
|
88
|
+
return JSON.stringify(value);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The error for a content read refused by a `deny` rule.
|
|
92
|
+
* @param displayPath - the path as the caller spelled it (for the message).
|
|
93
|
+
* @param rule - the rule that refused it.
|
|
94
|
+
* @returns the error to throw.
|
|
95
|
+
*/
|
|
96
|
+
export function readDenied(displayPath, rule) {
|
|
97
|
+
return new AccessDeniedError(`cannot read ${quoted(displayPath)}: denied by the extra-paths rule ${quoted(rule.raw)}`);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The error for a write refused by a `deny` rule.
|
|
101
|
+
* @param displayPath - the path as the caller spelled it.
|
|
102
|
+
* @param rule - the rule that refused it.
|
|
103
|
+
* @returns the error to throw.
|
|
104
|
+
*/
|
|
105
|
+
export function writeDenied(displayPath, rule) {
|
|
106
|
+
return new AccessDeniedError(`cannot write ${quoted(displayPath)}: denied by the extra-paths rule ${quoted(rule.raw)} (access: deny)`);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The error for a write refused by a `read` rule: the path is readable but the
|
|
110
|
+
* configuration downgraded it, even inside the writable workspace.
|
|
111
|
+
* @param displayPath - the path as the caller spelled it.
|
|
112
|
+
* @param rule - the rule that downgraded it.
|
|
113
|
+
* @returns the error to throw.
|
|
114
|
+
*/
|
|
115
|
+
export function writeReadOnly(displayPath, rule) {
|
|
116
|
+
return new AccessDeniedError(`cannot write ${quoted(displayPath)}: the path is configured read-only by the extra-paths rule `
|
|
117
|
+
+ `${quoted(rule.raw)} (access: read)`);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* The refusal reason a tool-level guard returns (a string, not a throw: the tool
|
|
121
|
+
* layer renders it as `Error: <reason>`). Names the tool, the argument path and
|
|
122
|
+
* the configured rule so the model does not retry with a different spelling.
|
|
123
|
+
* @param toolName - the tool call about to run.
|
|
124
|
+
* @param displayPath - the argument path that matched the rule.
|
|
125
|
+
* @param rule - the rule that refused it.
|
|
126
|
+
* @returns the one-line reason.
|
|
127
|
+
*/
|
|
128
|
+
export function toolAccessDenied(toolName, displayPath, rule) {
|
|
129
|
+
return `extra-paths: the ${toolName} tool cannot access ${quoted(displayPath)}: `
|
|
130
|
+
+ `denied by the extra-paths rule ${quoted(rule.raw)} (access: deny)`;
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=denial.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"denial.js","sourceR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CAAC,CAAA;AAC5D,CAAC;AAED,4EAA4E;AAC5E,SAAS,MAAM,CAAC,KAAa;IAC3B,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;AAC9B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,WAAmB,EAAE,IAAkB;IAChE,OAAO,IAAI,iBAAiB,CAC1B,eAAe,MAAM,CAAC,WAAW,CAAC,oCAAoC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CACzF,CAAA;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,WAAmB,EAAE,IAAkB;IACjE,OAAO,IAAI,iBAAiB,CAC1B,gBAAgB,MAAM,CAAC,WAAW,CAAC,oCAAoC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,iBAAiB,CACzG,CAAA;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,WAAmB,EAAE,IAAkB;IACnE,OAAO,IAAI,iBAAiB,CAC1B,gBAAgB,MAAM,CAAC,WAAW,CAAC,6DAA6D;UAC9F,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,iBAAiB,CACvC,CAAA;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAgB,EAAE,WAAmB,EAAE,IAAkB;IACxF,OAAO,oBAAoB,QAAQ,uBAAuB,MAAM,CAAC,WAAW,CAAC,IAAI;UAC7E,kCAAkC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAA;AACzE,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -21,6 +21,7 @@ import { renderExtraPathsContext } from './context.js';
|
|
|
21
21
|
import { installListener, fallbackPolicyOf } from './listener.js';
|
|
22
22
|
import { registerPreviewRoute } from './preview.js';
|
|
23
23
|
import { extraPathsSchema, extraPathsConfigSchema } from './schema.js';
|
|
24
|
+
import { installToolGuard } from './tool-guard.js';
|
|
24
25
|
/** The settings namespace the client page binds to. */
|
|
25
26
|
export const SETTINGS_NAMESPACE = 'extra-paths';
|
|
26
27
|
/**
|
|
@@ -29,8 +30,12 @@ export const SETTINGS_NAMESPACE = 'extra-paths';
|
|
|
29
30
|
* are `volatile()` because a settings form only describes volatile fields.
|
|
30
31
|
*/
|
|
31
32
|
export const Config = extraPathsConfigSchema;
|
|
32
|
-
/**
|
|
33
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Config keys this plugin owns, in schema order. `defaultScope` stays: it is the
|
|
35
|
+
* legacy alias `normalizeConfig` maps onto `defaultAccess`, and reading it keeps
|
|
36
|
+
* a 0.2.x settings document (which only ever wrote `defaultScope`) live.
|
|
37
|
+
*/
|
|
38
|
+
const CONFIG_KEYS = ['defaultAccess', 'defaultScope', 'defaultSurfaces', 'paths'];
|
|
34
39
|
/**
|
|
35
40
|
* Normalise the entry config, degrading to the documented empty configuration
|
|
36
41
|
* on any problem. This is the plugin's only untrusted-input boundary that runs
|
|
@@ -127,6 +132,18 @@ export function apply(ctx, config) {
|
|
|
127
132
|
}
|
|
128
133
|
};
|
|
129
134
|
const listener = installListener(ctx, { readConfig, fallbackPolicy: fallbackPolicyOf, warn });
|
|
135
|
+
// Tool-layer deny guard: `grep`/`glob` read through the host's bundled
|
|
136
|
+
// ripgrep instead of `ctx.fs`, so a denied path named in a tool's own
|
|
137
|
+
// arguments is refused here as well. installToolGuard feature-detects
|
|
138
|
+
// `ctx.tools.guard` (a host without it is a silent no-op) and the disposer is
|
|
139
|
+
// owned by this fiber. This is a supplementary seam, not the guarantee: the
|
|
140
|
+
// fs proxy stays authoritative for read/write tools, and the default
|
|
141
|
+
// workspace-wide scan remains a documented boundary.
|
|
142
|
+
const installGuard = () => installToolGuard(ctx, { readConfig, warn });
|
|
143
|
+
if (typeof ctx.effect === 'function')
|
|
144
|
+
ctx.effect(installGuard, 'extra-paths: tool guard');
|
|
145
|
+
else
|
|
146
|
+
installGuard();
|
|
130
147
|
ctx.inject(['settings'], (scope) => {
|
|
131
148
|
const settings = scope.settings;
|
|
132
149
|
// 0.2.x: no registration API at all. The namespace is this entry, its schema
|
|
@@ -134,13 +151,31 @@ export function apply(ctx, config) {
|
|
|
134
151
|
// volatile fields, so there is nothing to wire here.
|
|
135
152
|
if (typeof settings.register !== 'function')
|
|
136
153
|
return;
|
|
154
|
+
// The 0.1.5 service merges `base` UNDER the stored user section. The stored
|
|
155
|
+
// document of an older install may still carry the legacy `defaultScope`, so
|
|
156
|
+
// the base deliberately omits BOTH access aliases: a base
|
|
157
|
+
// `defaultAccess: 'write'` next to the user's `defaultScope: 'always-write'`
|
|
158
|
+
// would trip normalizeConfig's conflict guard and disable the whole
|
|
159
|
+
// configuration. The `write` default comes from the normaliser instead.
|
|
160
|
+
const base = { defaultSurfaces: entryConfig.defaultSurfaces, paths: entryConfig.paths };
|
|
137
161
|
const registered = settings.register(SETTINGS_NAMESPACE, extraPathsSchema, {
|
|
138
|
-
base
|
|
162
|
+
base,
|
|
139
163
|
applies: 'live',
|
|
140
164
|
validate: (value) => { validateConfig(value); },
|
|
141
165
|
});
|
|
142
|
-
|
|
143
|
-
|
|
166
|
+
// A stored section the normaliser rejects (a hand-edited YAML, an old host's
|
|
167
|
+
// schema drift) must degrade to the previous configuration, never throw out
|
|
168
|
+
// of the injection and leave the plugin half-applied.
|
|
169
|
+
const adopt = (value, source) => {
|
|
170
|
+
try {
|
|
171
|
+
current = normalizeConfig(value);
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
warn(`extra-paths: configuration from ${source} rejected (${String(error)}); keeping the previous configuration`);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
adopt(registered.get(), 'the settings service');
|
|
178
|
+
registered.watch(value => { adopt(value, 'a settings change'); });
|
|
144
179
|
});
|
|
145
180
|
ctx.inject(['systemPrompt'], (scope) => {
|
|
146
181
|
const systemPrompt = scope.systemPrompt;
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,eAAe,EAAE,cAAc,EAAyC,MAAM,aAAa,CAAA;AACpG,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,eAAe,EAAE,cAAc,EAAyC,MAAM,aAAa,CAAA;AACpG,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAElD,uDAAuD;AACvD,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAAA;AAE/C;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,sBAAsB,CAAA;AAE5C;;;;GAIG;AACH,MAAM,WAAW,GAAG,CAAC,eAAe,EAAE,cAAc,EAAE,iBAAiB,EAAE,OAAO,CAAU,CAAA;AAE1F;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,GAA0B,EAAE,IAA+B;IACzF,IAAI,CAAC;QACH,OAAO,eAAe,CAAC,GAAG,CAAC,CAAA;IAC7B,CAAC;IAAC,OAAO,KAAK,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