dsh-perm-gate 4.2.0-beta.4 → 4.2.0-beta.6

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/dsh.plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "dsh-perm-gate",
3
3
  "name": "dsh-perm-gate",
4
- "version": "4.2.0-beta.4",
4
+ "version": "4.2.0-beta.6",
5
5
  "description": {
6
6
  "en": "Deterministic-first, fail-closed permission gate for DeepSeek Harness 0.1.2+: a P0 hard-deny -> P1 precise session grant -> P2 static allow/deny rule chain -> P3 optional LLM classifier -> P4 ask pipeline over the tools/pre-execute waterfall, with a standalone CLI dry-run evaluator and an auditable decision log. It only vetoes with deny/ask and always delegates otherwise, and unknown or malformed rules fail loud instead of silently standing the gate down.",
7
7
  "zh": "面向 DeepSeek Harness 0.1.2+ 的确定性优先、失败即拒的权限闸门:在 tools/pre-execute 瀑布上串起 P0 硬拒绝 → P1 精确会话授权 → P2 静态 allow/deny 规则链 → P3 可选 LLM 语义分类 → P4 ask,并附带独立 CLI 干跑评估器与可审计的决策日志。只以 deny/ask 否决、其余一律放行,规则未知或非法时直接报错,绝不静默失效。"
@@ -44,3 +44,12 @@ export declare function listAllowCommands(rulesFile: string): string[];
44
44
  * @param reason - reason recorded on each generated allow entry.
45
45
  */
46
46
  export declare function replaceAllowCommands(rulesFile: string, patterns: readonly string[], reason?: string): boolean;
47
+ /**
48
+ * Parse the rules file into a plain document — the seed for the first
49
+ * settings-backed allowlist write and the activation-time rules seed, so
50
+ * migrating a file-defined document into the entry's `rules` config field
51
+ * cannot drop its deny/ask sections. The file's optional `permissions:`
52
+ * wrapper is unwrapped (the config field stores the bare form). Returns `{}`
53
+ * when the file is absent or unreadable.
54
+ */
55
+ export declare function readRulesFileDoc(rulesFile: string): unknown;
package/lib/allowlist.js CHANGED
@@ -197,3 +197,27 @@ function readFileSafe(p) {
197
197
  return '';
198
198
  }
199
199
  }
200
+ /**
201
+ * Parse the rules file into a plain document — the seed for the first
202
+ * settings-backed allowlist write and the activation-time rules seed, so
203
+ * migrating a file-defined document into the entry's `rules` config field
204
+ * cannot drop its deny/ask sections. The file's optional `permissions:`
205
+ * wrapper is unwrapped (the config field stores the bare form). Returns `{}`
206
+ * when the file is absent or unreadable.
207
+ */
208
+ export function readRulesFileDoc(rulesFile) {
209
+ const text = readFileSafe(rulesFile);
210
+ if (text === '')
211
+ return {};
212
+ try {
213
+ const root = parse(text);
214
+ if (root !== null && typeof root === 'object' && !Array.isArray(root)
215
+ && root['permissions'] !== null && typeof root['permissions'] === 'object') {
216
+ return root['permissions'];
217
+ }
218
+ return root ?? {};
219
+ }
220
+ catch {
221
+ return {};
222
+ }
223
+ }
package/lib/client.js CHANGED
@@ -149,7 +149,7 @@ window.__ModuleLoader__.load({
149
149
  "card.dryRunFail": "测试失败:",
150
150
  "card.dryRunStale": "路由不存在(插件未重启?)",
151
151
  "card.rules": "Settings 内置规则",
152
- "card.rulesHint": "门禁此刻实际加载的规则(来自 settings 命名空间 dsh-perm-gate-rules)。只读——这里改不了任何东西。要改规则,用下面的白名单,或在设置页中编辑。",
152
+ "card.rulesHint": "门禁此刻实际加载的规则(来自本插件入口的 rules 配置字段;未配置时回退到规则文件)。只读——这里改不了任何东西。要改规则,用下面的白名单,或在设置页中编辑。",
153
153
  "card.rulesRefresh": "刷新",
154
154
  "card.rulesLoading": "读取中…",
155
155
  "card.rulesPath": "来源",
@@ -161,7 +161,7 @@ window.__ModuleLoader__.load({
161
161
  "card.rulesTruncated": "规则过大,仅显示前 512 KB。",
162
162
  "card.rulesError": "加载失败:",
163
163
  "card.rulesStale": "路由不存在(插件未重启?)",
164
- "card.rulesNote": "此处只读:面板无法修改规则,白名单段是唯一会写入 settings 的地方。"
164
+ "card.rulesNote": "此处只读:面板无法修改规则;白名单段与“始终允许”会写回本插件的入口配置。"
165
165
  };
166
166
  /** English dictionary (keys mirror zh). */
167
167
  const en = {
@@ -302,7 +302,7 @@ window.__ModuleLoader__.load({
302
302
  "card.dryRunFail": "Test failed: ",
303
303
  "card.dryRunStale": "route missing (plugin not restarted?)",
304
304
  "card.rules": "Settings Built-in Rules",
305
- "card.rulesHint": "The rules the gate is loading right now (from the dsh-perm-gate-rules settings namespace). Read-only — nothing here can change them. To change rules, use the allowlist below or edit them on the settings page.",
305
+ "card.rulesHint": "The rules the gate is loading right now (from this plugin entry's `rules` config field; falls back to the rules file when unset). Read-only — nothing here can change them. To change rules, use the allowlist below or edit them on the settings page.",
306
306
  "card.rulesRefresh": "Refresh",
307
307
  "card.rulesLoading": "Reading…",
308
308
  "card.rulesPath": "Source",
@@ -314,7 +314,7 @@ window.__ModuleLoader__.load({
314
314
  "card.rulesTruncated": "Rules are large; showing the first 512 KB only.",
315
315
  "card.rulesError": "Load failed: ",
316
316
  "card.rulesStale": "route missing (plugin not restarted?)",
317
- "card.rulesNote": "Read-only: this panel cannot modify the rules. The allowlist section is the only place that writes to settings."
317
+ "card.rulesNote": "Read-only: this panel cannot modify the rules. The allowlist section and \"allow always\" write back to this plugin's entry config."
318
318
  };
319
319
  //#endregion
320
320
  //#region src/deny-defaults.ts