dsh-permission-rules 0.7.21 → 0.7.22
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/CHANGELOG.md +7 -0
- package/README.en.md +504 -0
- package/README.es.md +504 -0
- package/README.hi.md +504 -0
- package/README.md +309 -245
- package/README.pt.md +504 -0
- package/docs/assets/dsh-permission-rules-flow-dark.svg +58 -0
- package/docs/assets/dsh-permission-rules-flow-light.svg +58 -0
- package/docs/assets/dsh-permission-rules-flow-v5-dark.svg +103 -0
- package/docs/assets/dsh-permission-rules-flow-v5-light.svg +103 -0
- package/docs/assets/dsh-permission-rules-hero-en-dark.webp +0 -0
- package/docs/assets/dsh-permission-rules-hero-en-light.webp +0 -0
- package/docs/assets/dsh-permission-rules-hero-zh-dark.webp +0 -0
- package/docs/assets/dsh-permission-rules-hero-zh-light.webp +0 -0
- package/docs/rules-format.en.md +5 -4
- package/docs/rules-format.md +5 -4
- package/lib/index.js +230 -40
- package/lib/types/config.d.ts +9 -4
- package/lib/types/config.d.ts.map +1 -1
- package/lib/types/prose.d.ts +6 -0
- package/lib/types/prose.d.ts.map +1 -1
- package/lib/types/rules.d.ts +74 -15
- package/lib/types/rules.d.ts.map +1 -1
- package/lib/types/runtime.d.ts +59 -12
- package/lib/types/runtime.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/config.ts +9 -4
- package/src/prose.ts +21 -0
- package/src/rules.ts +131 -24
- package/src/runtime.ts +140 -24
- package/README-es.md +0 -443
- package/README-hi.md +0 -445
- package/README-pt.md +0 -443
- package/README-zh.md +0 -443
package/lib/types/rules.d.ts
CHANGED
|
@@ -31,9 +31,35 @@ export declare class RuleError extends Error {
|
|
|
31
31
|
/** A parsed, shape-validated rule document (patterns not yet compiled). */
|
|
32
32
|
export interface RulesFileDoc {
|
|
33
33
|
rules: RuleDocEntry[];
|
|
34
|
+
/**
|
|
35
|
+
* Rules an ISOLATED parse could not validate and therefore skipped. The
|
|
36
|
+
* strict {@link parseRulesDocument} throws on the first one instead and
|
|
37
|
+
* never populates this list.
|
|
38
|
+
*/
|
|
39
|
+
issues?: readonly RuleIssue[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* One rule the loader disabled instead of failing the whole file: the
|
|
43
|
+
* per-rule blast radius of issue #49. `index` is the rule's 0-based
|
|
44
|
+
* position in the source document's `rules` list, so an error keeps
|
|
45
|
+
* pointing at the entry the author wrote even when other entries were
|
|
46
|
+
* skipped (a bare array position would drift).
|
|
47
|
+
*/
|
|
48
|
+
export interface RuleIssue {
|
|
49
|
+
/** 0-based position in the source document's `rules` list. */
|
|
50
|
+
readonly index: number;
|
|
51
|
+
/** The `RuleError`-shaped message naming the rule and the bad field/pattern. */
|
|
52
|
+
readonly message: string;
|
|
53
|
+
}
|
|
54
|
+
/** The isolated per-source compile result: the rules that loaded plus the ones disabled. */
|
|
55
|
+
export interface CompiledSourceRules {
|
|
56
|
+
readonly rules: readonly CompiledRule[];
|
|
57
|
+
readonly issues: readonly RuleIssue[];
|
|
34
58
|
}
|
|
35
59
|
/** One parsed rule: match dimensions plus the action, reason, and metadata. */
|
|
36
60
|
export interface RuleDocEntry {
|
|
61
|
+
/** 0-based position in the source document's `rules` list. */
|
|
62
|
+
readonly index: number;
|
|
37
63
|
match: RuleMatchDoc;
|
|
38
64
|
action: RuleAction;
|
|
39
65
|
reason: string;
|
|
@@ -245,30 +271,61 @@ export interface MatchContext {
|
|
|
245
271
|
* Parse one rules file body. Unknown document/rule/match fields, invalid
|
|
246
272
|
* actions, missing reasons, and wrong-shaped collections all throw
|
|
247
273
|
* {@link RuleError} — a malformed file fails loudly at load, never silently.
|
|
274
|
+
* This is the STRICT shape: editor saves use it so a hand edit is refused
|
|
275
|
+
* with its error instead of being silently dropped. The loader uses
|
|
276
|
+
* {@link parseRulesDocumentIsolated} instead, where one bad rule disables
|
|
277
|
+
* only itself.
|
|
248
278
|
* @param text - the raw YAML text.
|
|
249
279
|
* @returns the validated document.
|
|
250
280
|
*/
|
|
251
281
|
export declare function parseRulesDocument(text: string): RulesFileDoc;
|
|
252
282
|
/**
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
283
|
+
* Parse one rules file body with per-rule isolation (issue #49): a rule
|
|
284
|
+
* whose shape is invalid is skipped and reported in
|
|
285
|
+
* {@link RulesFileDoc.issues}, and every other rule still loads. Document
|
|
286
|
+
* STRUCTURE errors (invalid YAML, an unknown top-level field, a `rules`
|
|
287
|
+
* value that is not a list) are still file-level and throw: they leave no
|
|
288
|
+
* rule list to isolate.
|
|
289
|
+
* @param text - the raw YAML text.
|
|
290
|
+
* @returns the validated document plus the skipped-rule reports.
|
|
291
|
+
*/
|
|
292
|
+
export declare function parseRulesDocumentIsolated(text: string): RulesFileDoc;
|
|
293
|
+
/**
|
|
294
|
+
* Compile a parsed document for the hot path STRICTLY: pattern strings
|
|
295
|
+
* become RegExps (invalid globs/regexes throw here), and the rule count is
|
|
296
|
+
* capped by `maxRules`. Used by editor saves (and the generated allow-host
|
|
297
|
+
* rule), so a hand edit never has a rule silently dropped. The loader uses
|
|
298
|
+
* {@link compileRulesText} instead.
|
|
256
299
|
* @param doc - the parsed document.
|
|
257
300
|
* @param options - pattern mode, caps, and case handling.
|
|
258
301
|
* @returns the compiled ruleset (every rule attributed to source 0).
|
|
259
302
|
*/
|
|
260
303
|
export declare function compileRules(doc: RulesFileDoc, options: CompileOptions): CompiledRuleset;
|
|
261
304
|
/**
|
|
262
|
-
* Compile one parsed document into per-source compiled rules
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
305
|
+
* Compile one parsed document into per-source compiled rules with
|
|
306
|
+
* per-rule isolation (issue #49): a rule whose patterns cannot compile is
|
|
307
|
+
* disabled and reported in {@link CompiledSourceRules.issues}, while every
|
|
308
|
+
* other rule still loads. The returned rules carry source-local `index`
|
|
309
|
+
* values and `sourceIndex` 0 — the cacheable unit a runtime can reuse
|
|
310
|
+
* across chains (keyed by source path + content hash). The total-count cap
|
|
311
|
+
* is NOT applied here; it bounds the merged chain in
|
|
312
|
+
* {@link mergeCompiledRules}.
|
|
313
|
+
* @param doc - the parsed document (isolated or strict).
|
|
314
|
+
* @param options - compile options.
|
|
315
|
+
* @returns the compiled rules of one source plus the disabled-rule reports.
|
|
316
|
+
*/
|
|
317
|
+
export declare function compileSourceRules(doc: RulesFileDoc, options: CompileOptions): CompiledSourceRules;
|
|
318
|
+
/**
|
|
319
|
+
* Parse and compile one rule-file text with per-rule isolation — the
|
|
320
|
+
* loader-facing entry point for issue #49. A bad rule disables only itself
|
|
321
|
+
* (reported with its 0-based document index); the rest of the file stays
|
|
322
|
+
* active. A file-level failure still throws, so `badFilePolicy` keeps
|
|
323
|
+
* choosing how a whole unreadable/unparseable file is handled.
|
|
324
|
+
* @param text - the raw YAML text.
|
|
268
325
|
* @param options - compile options.
|
|
269
|
-
* @returns the compiled rules
|
|
326
|
+
* @returns the compiled rules plus the disabled-rule reports.
|
|
270
327
|
*/
|
|
271
|
-
export declare function
|
|
328
|
+
export declare function compileRulesText(text: string, options: CompileOptions): CompiledSourceRules;
|
|
272
329
|
/**
|
|
273
330
|
* Merge per-source compiled rule lists into one chain, assigning the
|
|
274
331
|
* global 0-based `index` and per-list `sourceIndex` attribution. The TOTAL
|
|
@@ -279,11 +336,13 @@ export declare function compileSourceRules(doc: RulesFileDoc, options: CompileOp
|
|
|
279
336
|
*/
|
|
280
337
|
export declare function mergeCompiledRules(sources: readonly CompiledRule[][], options: CompileOptions): CompiledRuleset;
|
|
281
338
|
/**
|
|
282
|
-
* Parse and compile an ordered source chain (nearest file first).
|
|
283
|
-
* keep per-file order and are evaluated in chain order, so a nearer
|
|
284
|
-
* can override a farther one on first-match semantics; `sourceIndex`
|
|
339
|
+
* Parse and compile an ordered source chain (nearest file first) STRICTLY.
|
|
340
|
+
* Rules keep per-file order and are evaluated in chain order, so a nearer
|
|
341
|
+
* file can override a farther one on first-match semantics; `sourceIndex`
|
|
285
342
|
* attributes every rule to its file. The TOTAL rule count is capped by
|
|
286
|
-
* `maxRules`.
|
|
343
|
+
* `maxRules`. The plugin's loader does not use this helper — it compiles
|
|
344
|
+
* each file through {@link compileRulesText} so one bad rule cannot take
|
|
345
|
+
* the chain down.
|
|
287
346
|
* @param entries - the rule-file texts, nearest file first.
|
|
288
347
|
* @param options - compile options.
|
|
289
348
|
* @returns the merged ruleset and the source paths it references.
|
package/lib/types/rules.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/rules.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,yDAAyD;AACzD,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAA;AAEjD,yDAAyD;AACzD,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,CAAA;AAE1C,wEAAwE;AACxE,eAAO,MAAM,YAAY,EAAE,SAAS,UAAU,EAA6B,CAAA;AAE3E,6FAA6F;AAC7F,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,OAAO,CAAA;AAEzC,wEAAwE;AACxE,eAAO,MAAM,OAAO,EAAE,SAAS,UAAU,EAAsB,CAAA;AAE/D,mFAAmF;AACnF,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAc/C,CAAA;AAKD,wFAAwF;AACxF,eAAO,MAAM,SAAS,EAAE,SAAS,MAAM,EAAkF,CAAA;AAQzH;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,KAAK;gBACtB,OAAO,EAAE,MAAM;CAI5B;AAED,2EAA2E;AAC3E,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,YAAY,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/rules.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,yDAAyD;AACzD,MAAM,MAAM,UAAU,GAAG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AC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;IACjC,gFAAgF;IAChF,QAAQ,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,CAAA;CAChC;AAKD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,EAAE,CA0B5E;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAYrE;AA2BD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIlD;AA6BD,6DAA6D;AAC7D,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEjD;AAqHD;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAgB7F;AAyBD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,UAAQ,GAAG,MAAM,CAiBtG"}
|
package/lib/types/runtime.d.ts
CHANGED
|
@@ -15,13 +15,18 @@ import type { CommandInvocation, CommandResult } from '@deepseek-ai/dsh-commands
|
|
|
15
15
|
import type { PreToolDecision, ToolExecution } from '@deepseek-ai/dsh-tools';
|
|
16
16
|
import type { LiveConfig, ResolvedConfig } from './config.js';
|
|
17
17
|
import type { AllowHostRequest, AllowHostResult } from './wire.js';
|
|
18
|
-
import type { CompiledRuleset, RuleHit } from './rules.js';
|
|
18
|
+
import type { CompiledRuleset, RuleHit, RuleIssue } from './rules.js';
|
|
19
19
|
import type { NetworkMode } from './network.js';
|
|
20
20
|
import type { NetworkBlockRecord } from './proxy.js';
|
|
21
21
|
import type { DecisionOutcome } from './events.js';
|
|
22
22
|
export declare const name = "permission-rules";
|
|
23
23
|
/** Services required before the plugin mounts. */
|
|
24
24
|
export declare const inject: string[];
|
|
25
|
+
/** One rule disabled at load, attributed to the source file that declared it (issue #49). */
|
|
26
|
+
export interface RuleFileIssue extends RuleIssue {
|
|
27
|
+
/** Absolute path of the rule file whose rule was disabled. */
|
|
28
|
+
readonly source: string;
|
|
29
|
+
}
|
|
25
30
|
/** The rule state bound to one workspace cwd. */
|
|
26
31
|
interface LoadedRules {
|
|
27
32
|
/** The workspace root these rules were resolved for. */
|
|
@@ -29,7 +34,9 @@ interface LoadedRules {
|
|
|
29
34
|
/** Absolute paths of the rule files in effect, nearest first; `[]` = empty rule set. */
|
|
30
35
|
readonly sources: readonly string[];
|
|
31
36
|
readonly compiled: CompiledRuleset;
|
|
32
|
-
/**
|
|
37
|
+
/** Rules disabled by per-rule parse/compile errors; the rest of the policy stays active. */
|
|
38
|
+
readonly issues?: readonly RuleFileIssue[];
|
|
39
|
+
/** Last FILE-level load error, when one is being reported (see {@link PermissionRulesRuntime.rulesFor}). */
|
|
33
40
|
readonly lastError?: string;
|
|
34
41
|
/** `true` when the last initial load threw under `badFilePolicy: 'fail'`. */
|
|
35
42
|
readonly failed?: true;
|
|
@@ -110,10 +117,17 @@ export declare class PermissionRulesRuntime {
|
|
|
110
117
|
/** The configured fallback file when it exists, else `[]`. */
|
|
111
118
|
private resolveFallback;
|
|
112
119
|
/**
|
|
113
|
-
* Read, parse, and compile the rule-file chain serving `cwd`.
|
|
114
|
-
*
|
|
115
|
-
* rule
|
|
116
|
-
*
|
|
120
|
+
* Read, parse, and compile the rule-file chain serving `cwd`.
|
|
121
|
+
*
|
|
122
|
+
* Per-rule failures (a bad glob/regex, an unknown field or action, a
|
|
123
|
+
* missing reason) no longer fail the whole load: that rule is disabled,
|
|
124
|
+
* reported with its 0-based document index and source file, and every
|
|
125
|
+
* other rule — in that file and in every other file of the chain — stays
|
|
126
|
+
* active (issue #49). FILE-level failures (unreadable file, invalid YAML,
|
|
127
|
+
* unknown top-level field, `rules` not a list, or a total over
|
|
128
|
+
* `maxRules`) still follow `badFilePolicy`: `'ignore-with-warning'`
|
|
129
|
+
* degrades to an empty rule set with a warning and keeps the source paths
|
|
130
|
+
* (so a later fix is watched and adopted); `'fail'` throws.
|
|
117
131
|
* @param cwd - the workspace root.
|
|
118
132
|
* @returns the loaded state.
|
|
119
133
|
*/
|
|
@@ -123,11 +137,35 @@ export declare class PermissionRulesRuntime {
|
|
|
123
137
|
* file's content hash is unchanged. The cache key is the source path plus
|
|
124
138
|
* the content hash, so the same file read by many workspaces (the
|
|
125
139
|
* built-in baseline and any shared fallback/absolute `rulesFile`) is
|
|
126
|
-
* parsed and compiled ONCE, not once per cwd.
|
|
140
|
+
* parsed and compiled ONCE, not once per cwd. Per-rule failures are
|
|
141
|
+
* isolated by {@link compileRulesText}; they are logged here (once per
|
|
142
|
+
* recompiled content, at `error` under `badFilePolicy: 'fail'` and at
|
|
143
|
+
* `warn` under `'ignore-with-warning'`) instead of being thrown.
|
|
127
144
|
* @param path - the absolute source path.
|
|
128
|
-
* @returns that source's compiled rules (source-local index, sourceIndex 0).
|
|
145
|
+
* @returns that source's compiled rules (source-local index, sourceIndex 0) and disabled-rule reports.
|
|
129
146
|
*/
|
|
130
147
|
private compileSourceFile;
|
|
148
|
+
/**
|
|
149
|
+
* Report the rules an isolated load disabled. The file still loads, so
|
|
150
|
+
* this is not a file-level failure: `badFilePolicy: 'fail'` reports each
|
|
151
|
+
* disabled rule at `error` level and `'ignore-with-warning'` at `warn`,
|
|
152
|
+
* both naming the file and the 1-based rule position the author can find in
|
|
153
|
+
* the document (the `RuleIssue.index` itself is 0-based). The same errors stay queryable through `/rules`.
|
|
154
|
+
* @param path - the rule file the rules came from.
|
|
155
|
+
* @param issues - the disabled-rule reports for that file.
|
|
156
|
+
*/
|
|
157
|
+
private reportRuleIssues;
|
|
158
|
+
/**
|
|
159
|
+
* ONE process's startup check: load the chain for `cwd` eagerly and, when
|
|
160
|
+
* it is degraded, emit a single prominent warning instead of waiting for
|
|
161
|
+
* the first dangerous tool call. The per-rule errors themselves are logged
|
|
162
|
+
* by {@link compileSourceFile}; this adds the summary that makes the state
|
|
163
|
+
* impossible to miss in the host log, and `/rules` stays the
|
|
164
|
+
* session-visible surface with the detailed list. Never throws: a startup
|
|
165
|
+
* check must not take the plugin down (issue #49).
|
|
166
|
+
* @param cwd - the workspace to check (the host cwd at mount, the session cwd on creation).
|
|
167
|
+
*/
|
|
168
|
+
startupNotice(cwd?: string): void;
|
|
131
169
|
/** Bound the compile cache: drop the least-recently-used source beyond the workspace cap (compile results are cheap to rebuild). */
|
|
132
170
|
private evictCompileCache;
|
|
133
171
|
/**
|
|
@@ -463,12 +501,21 @@ export declare class PermissionRulesRuntime {
|
|
|
463
501
|
/**
|
|
464
502
|
* Validate deployment-level file references at mount — the earliest
|
|
465
503
|
* resolvable point. An absolute `rulesFile` or a configured
|
|
466
|
-
* `fallbackPath` must exist and parse; a missing referent
|
|
467
|
-
* loudly instead of silently degrading later.
|
|
468
|
-
*
|
|
504
|
+
* `fallbackPath` must exist and parse; a missing referent or a FILE-level
|
|
505
|
+
* failure fails the mount loudly instead of silently degrading later. A
|
|
506
|
+
* single bad RULE inside such a file no longer fails the mount (issue
|
|
507
|
+
* #49): it is disabled, reported, and the rest of the file stays active —
|
|
508
|
+
* otherwise one typo would take the whole plugin (and its protection)
|
|
509
|
+
* down before any session exists.
|
|
510
|
+
* @throws when a mandated file is missing or unparseable as a document.
|
|
469
511
|
*/
|
|
470
512
|
validateDeploymentFiles(): void;
|
|
471
|
-
/**
|
|
513
|
+
/**
|
|
514
|
+
* Parse and compile one mandated file with per-rule isolation, rethrowing
|
|
515
|
+
* only a FILE-level failure as a mount failure. The disabled-rule reports
|
|
516
|
+
* are logged here (the mount is the first place they can be seen).
|
|
517
|
+
* @param filePath - the deployment-level rule file to validate.
|
|
518
|
+
*/
|
|
472
519
|
private loadForValidation;
|
|
473
520
|
/**
|
|
474
521
|
* Whether one watched path must be polled instead of trusting the platform's
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACjF,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAG5E,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAI7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAElE,OAAO,KAAK,EAAgC,eAAe,EAA+B,OAAO,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACjF,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAG5E,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAI7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAElE,OAAO,KAAK,EAAgC,eAAe,EAA+B,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAIhI,OAAO,KAAK,EAAiC,WAAW,EAAE,MAAM,cAAc,CAAA;AAQ9E,OAAO,KAAK,EAAmB,kBAAkB,EAAoB,MAAM,YAAY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;;;OAkBG;IACH,OAAO,CAAC,oBAAoB;IA0E5B,qHAAqH;IACrH,OAAO,CAAC,kBAAkB;IAU1B,8FAA8F;IAC9F,OAAO,CAAC,aAAa;IAarB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAYnB,4DAA4D;IAC5D,kBAAkB,IAAI,MAAM;IAI5B,2EAA2E;IAC3E,mBAAmB,IAAI,MAAM;IAI7B,sEAAsE;IACtE,kBAAkB,IAAI,MAAM;IAI5B;;;;;OAKG;IACH,OAAO,CAAC,cAAc;CAevB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CA4C3E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAW9D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-permission-rules",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.22",
|
|
4
4
|
"description": "Declarative Claude Code-style permission rules plus a Codex-style process-level network policy for DeepSeek Harness: ordered allow/deny/ask rules with tool-name, argument (glob/regex), workspace-path, and network-target (domain/ip/port/scheme) matching on the tools/pre-execute waterfall, a built-in local HTTP/CONNECT proxy governing shell subprocess traffic, three network modes mapped onto the official sandbox presets, full session-log audit, HMR rule reload, and a settings page with a rule editor, block counters, and recent interception lists.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
package/src/config.ts
CHANGED
|
@@ -112,10 +112,15 @@ export interface Config {
|
|
|
112
112
|
*/
|
|
113
113
|
fallbackPath?: string | undefined
|
|
114
114
|
/**
|
|
115
|
-
* How
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
115
|
+
* How a FILE-level rule-file failure (unreadable, invalid YAML, unknown
|
|
116
|
+
* top-level field, `rules` not a list, over `maxRules`) is handled at
|
|
117
|
+
* load: `'fail'` throws (the pending tool call errors loudly; HMR reloads
|
|
118
|
+
* keep the previous rules and report the error), `'ignore-with-warning'`
|
|
119
|
+
* logs a warning and continues with an empty (initial) or previous
|
|
120
|
+
* (reload) rule set. A single invalid RULE is isolated either way
|
|
121
|
+
* (issue #49): it is disabled and reported at startup and in `/rules`
|
|
122
|
+
* while every other rule stays active, so the policy can never disappear
|
|
123
|
+
* because of one typo.
|
|
119
124
|
*/
|
|
120
125
|
badFilePolicy?: BadFilePolicy
|
|
121
126
|
/** Hard cap on the number of rules across the effective source chain; a larger chain fails the load. */
|
package/src/prose.ts
CHANGED
|
@@ -24,6 +24,12 @@ export interface UiProse {
|
|
|
24
24
|
reloadFailed: (error: string) => string
|
|
25
25
|
/** Warning appended to a listing whose last reload failed. */
|
|
26
26
|
lastReloadWarning: (error: string) => string
|
|
27
|
+
/** Warning header of a listing whose chain disabled rule(s) by isolated load errors. */
|
|
28
|
+
degradedRules: (disabled: number, active: number) => string
|
|
29
|
+
/** One disabled-rule line: source file, 1-based rule number, and the load error. */
|
|
30
|
+
ruleIssueLine: (source: string, index: number, message: string) => string
|
|
31
|
+
/** `/rules reload` result when valid rules loaded but others were disabled. */
|
|
32
|
+
reloadDegraded: (active: number, source: string, disabled: number) => string
|
|
27
33
|
/** Notice appended to a listing when dry-run mode (`enforce: false`) is active. */
|
|
28
34
|
dryRunNotice: string
|
|
29
35
|
/** Rejection of an unknown `/rules` argument. */
|
|
@@ -105,6 +111,9 @@ const EN: UiProse = {
|
|
|
105
111
|
reloaded: (count, source) => `Reloaded ${count} rule(s) from ${source}.`,
|
|
106
112
|
reloadFailed: error => `Reload failed: ${error}. The previous rules are still active.`,
|
|
107
113
|
lastReloadWarning: error => `Warning: the last reload failed (${error}); the rules listed above are the previous ones.`,
|
|
114
|
+
degradedRules: (disabled, active) => `Warning: ${disabled} rule(s) could not be loaded and are disabled; the other ${active} rule(s) stay active:`,
|
|
115
|
+
ruleIssueLine: (source, index, message) => `- ${source.length > 0 ? source : '(unknown file)'}: rule ${index + 1} (disabled): ${message}`,
|
|
116
|
+
reloadDegraded: (active, source, disabled) => `Reloaded ${active} rule(s) from ${source}; ${disabled} rule(s) are disabled by load errors — fix the entries below and run /rules reload:`,
|
|
108
117
|
dryRunNotice: 'Dry-run mode (enforce: false): deny/ask hits are audit-logged only — every call is passed through.',
|
|
109
118
|
unknownArg: arg => `Unknown /rules argument "${arg}". ${EN.usage}`,
|
|
110
119
|
usage: 'Usage: /rules [list | reload | network | decisions [n] | test <tool> <json-args>]',
|
|
@@ -149,6 +158,9 @@ const ZH: UiProse = {
|
|
|
149
158
|
reloaded: (count, source) => `已重载 ${count} 条规则,来自 ${source}。`,
|
|
150
159
|
reloadFailed: error => `重载失败:${error}。之前的规则仍然生效。`,
|
|
151
160
|
lastReloadWarning: error => `警告:上次重载失败(${error});以上列出的是之前的规则。`,
|
|
161
|
+
degradedRules: (disabled, active) => `警告:${disabled} 条规则无法加载,已禁用;其余 ${active} 条仍然生效:`,
|
|
162
|
+
ruleIssueLine: (source, index, message) => `- ${source.length > 0 ? source : '(未知文件)'}:第 ${index + 1} 条(已禁用):${message}`,
|
|
163
|
+
reloadDegraded: (active, source, disabled) => `已重载 ${active} 条规则,来自 ${source};另有 ${disabled} 条因加载错误被禁用——请修正下列条目后执行 /rules reload:`,
|
|
152
164
|
dryRunNotice: '干跑模式(enforce: false):deny/ask 命中仅写入审计日志——所有调用照常透传。',
|
|
153
165
|
unknownArg: arg => `未知的 /rules 参数 "${arg}"。${ZH.usage}`,
|
|
154
166
|
usage: '用法:/rules [list | reload | network | decisions [n] | test <工具名> <json-参数>]',
|
|
@@ -193,6 +205,9 @@ const ES: UiProse = {
|
|
|
193
205
|
reloaded: (count, source) => `Recargadas ${count} regla(s) desde ${source}.`,
|
|
194
206
|
reloadFailed: error => `Error de recarga: ${error}. Las reglas anteriores siguen activas.`,
|
|
195
207
|
lastReloadWarning: error => `Aviso: la última recarga falló (${error}); las reglas mostradas son las anteriores.`,
|
|
208
|
+
degradedRules: (disabled, active) => `Aviso: ${disabled} regla(s) no se pudieron cargar y están deshabilitadas; las otras ${active} siguen activas:`,
|
|
209
|
+
ruleIssueLine: (source, index, message) => `- ${source.length > 0 ? source : '(archivo desconocido)'}: regla ${index + 1} (deshabilitada): ${message}`,
|
|
210
|
+
reloadDegraded: (active, source, disabled) => `Recargadas ${active} regla(s) desde ${source}; ${disabled} regla(s) están deshabilitadas por errores de carga — corrige las entradas siguientes y ejecuta /rules reload:`,
|
|
196
211
|
dryRunNotice: 'Modo simulación (enforce: false): los aciertos deny/ask solo se registran en auditoría — todas las llamadas pasan.',
|
|
197
212
|
unknownArg: arg => `Argumento de /rules desconocido "${arg}". ${ES.usage}`,
|
|
198
213
|
usage: 'Uso: /rules [list | reload | network | decisions [n] | test <herramienta> <json-args>]',
|
|
@@ -237,6 +252,9 @@ const PT: UiProse = {
|
|
|
237
252
|
reloaded: (count, source) => `Recarregadas ${count} regra(s) de ${source}.`,
|
|
238
253
|
reloadFailed: error => `Falha ao recarregar: ${error}. As regras anteriores continuam ativas.`,
|
|
239
254
|
lastReloadWarning: error => `Aviso: a última recarga falhou (${error}); as regras listadas são as anteriores.`,
|
|
255
|
+
degradedRules: (disabled, active) => `Aviso: ${disabled} regra(s) não puderam ser carregadas e estão desativadas; as outras ${active} continuam ativas:`,
|
|
256
|
+
ruleIssueLine: (source, index, message) => `- ${source.length > 0 ? source : '(arquivo desconhecido)'}: regra ${index + 1} (desativada): ${message}`,
|
|
257
|
+
reloadDegraded: (active, source, disabled) => `Recarregadas ${active} regra(s) de ${source}; ${disabled} regra(s) estão desativadas por erros de carregamento — corrija as entradas abaixo e execute /rules reload:`,
|
|
240
258
|
dryRunNotice: 'Modo simulação (enforce: false): acertos deny/ask são apenas registrados na auditoria — todas as chamadas passam.',
|
|
241
259
|
unknownArg: arg => `Argumento de /rules desconhecido "${arg}". ${PT.usage}`,
|
|
242
260
|
usage: 'Uso: /rules [list | reload | network | decisions [n] | test <ferramenta> <json-args>]',
|
|
@@ -281,6 +299,9 @@ const HI: UiProse = {
|
|
|
281
299
|
reloaded: (count, source) => `${count} नियम पुनः लोड किए गए, स्रोत ${source}।`,
|
|
282
300
|
reloadFailed: error => `पुनः लोड विफल: ${error}। पिछले नियम अब भी सक्रिय हैं।`,
|
|
283
301
|
lastReloadWarning: error => `चेतावनी: अंतिम पुनः लोड विफल रहा (${error}); ऊपर सूचीबद्ध नियम पिछले वाले हैं।`,
|
|
302
|
+
degradedRules: (disabled, active) => `चेतावनी: ${disabled} नियम लोड नहीं हो सके और अक्षम हैं; शेष ${active} नियम सक्रिय रहते हैं:`,
|
|
303
|
+
ruleIssueLine: (source, index, message) => `- ${source.length > 0 ? source : '(अज्ञात फ़ाइल)'}: नियम ${index + 1} (अक्षम): ${message}`,
|
|
304
|
+
reloadDegraded: (active, source, disabled) => `${source} से ${active} नियम पुनः लोड हुए; ${disabled} नियम लोड त्रुटियों से अक्षम हैं — नीचे दी प्रविष्टियाँ ठीक करें और /rules reload चलाएँ:`,
|
|
284
305
|
dryRunNotice: 'ड्राई-रन मोड (enforce: false): deny/ask हिट केवल ऑडिट में दर्ज होते हैं — हर कॉल पास हो जाती है।',
|
|
285
306
|
unknownArg: arg => `अज्ञात /rules तर्क "${arg}"। ${HI.usage}`,
|
|
286
307
|
usage: 'उपयोग: /rules [list | reload | network | decisions [n] | test <टूल> <json-args>]',
|