dsh-plugin-trim 0.0.0-stage → 0.2.4

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dsh-experience-optimizer contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,109 @@
1
- # Temporary Holding Version
1
+ # dsh-plugin-trim
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ DSH 插件生态的**减负**与**兼容性体检**插件。
4
+
5
+ ## 安装
6
+
7
+ 从 GitHub Release 安装(当前推荐,无需 npm):
8
+
9
+ ```bash
10
+ dsh plugin --profile web add "https://github.com/Starlit-Sky-code/dsh-experience-optimizer/releases/download/v0.2.4/dsh-plugin-trim-0.2.4.tgz"
11
+ ```
12
+
13
+ 发布到 npm 后:
14
+
15
+ ```bash
16
+ dsh plugin --profile web add dsh-plugin-trim
17
+ ```
18
+
19
+ 本地开发:
20
+
21
+ ```bash
22
+ dsh plugin --profile web add /absolute/path/to/packages/plugin-trim
23
+ ```
24
+
25
+ ## Web 控制台
26
+
27
+ 安装后在 DSH **设置 → 插件 → 体验优化** 打开:
28
+
29
+ - 上下文成本与兼容性矩阵;
30
+ - 按任务生成精简方案,勾选低风险项后显式应用;
31
+ - 一键回滚;
32
+ - 工作流配方页签(由 `dsh-plugin-recipe` 提供 Host API)。
33
+
34
+ 界面只调用同源 JSON API;API 校验 DSH 浏览器会话与 `Origin`。
35
+
36
+ ## 工具
37
+
38
+ | 工具 | 读写 | 说明 |
39
+ |---|---|---|
40
+ | `trim_scan_plugins` | 只读 | 插件清单、真实 prompt 上下文成本、使用统计、去重组、兼容性摘要 |
41
+ | `trim_analyze_compatibility` | 只读 | 兼容性矩阵:插件↔插件、插件↔DSH/Node/平台、Profile/工作区漂移 |
42
+ | `trim_suggest_profile` | 只写本地草稿 | 按当前任务生成 keep/enable/disable/review 建议与证据 |
43
+ | `trim_apply_profile` | 修改 profile | 用户显式确认后应用低风险项,返回回滚 token |
44
+ | `trim_rollback_profile` | 修改 profile | 恢复上一次应用 |
45
+
46
+ ## 安全边界
47
+
48
+ - 默认只建议,不自动禁用。
49
+ - `trim_apply_profile` 必须 `confirm: true`,只应用 `risk: low` 的 disable/enable 项。
50
+ - 受保护项永不改:核心、管理、agent preset、当前 profile 依赖、用户 `protect`/`pinned`、套件自身。
51
+ - 版本豁免、插件升级、patch 编辑只报告,不自动执行。
52
+ - 兼容性扫描不执行 `!!js`、不 import 未加载插件、不联网。
53
+ - 本地数据写入 `$DSH_HOME/experience-optimizer/`,目录 `0700`、文件 `0600`。
54
+
55
+ ## 配置
56
+
57
+ 在 profile patch 中覆盖 `dsh-plugin-trim` 的配置:
58
+
59
+ ```yaml
60
+ - id: dsh-plugin-trim
61
+ config:
62
+ mode: advise
63
+ protect:
64
+ - my-important-plugin
65
+ pinned:
66
+ - my-pinned-plugin
67
+ trackUsage: true
68
+ compatScanAllProfiles: true
69
+ ```
70
+
71
+ | key | 默认 | 说明 |
72
+ |---|---|---|
73
+ | `mode` | `advise` | `auto-safe` 只收窄建议范围,不绕过 confirm |
74
+ | `protect` | `[]` | 额外保护包名/entry id |
75
+ | `pinned` | `[]` | 永不建议禁用 |
76
+ | `trackUsage` | `true` | 记录工具名/成败/时间,不记录参数 |
77
+ | `usageRetentionDays` | `30` | 使用记录保留天数 |
78
+ | `maxDrafts` | `20` | 草稿/快照保留数 |
79
+ | `enableDedupe` | `true` | prompt 重复检测 |
80
+ | `persistExcerpts` | `false` | 是否在去重草稿保存 160 字符摘要 |
81
+ | `toolOwners` | `{}` | 补充 tool → 包名映射 |
82
+ | `compatEnabled` | `true` | 启用兼容性分析 |
83
+ | `compatScanAllProfiles` | `true` | 扫描 `$DSH_HOME/profiles/*` |
84
+ | `compatMaxProfiles` | `20` | profile 扫描上限 |
85
+ | `compatIncludeInfo` | `false` | Markdown 是否包含 info |
86
+ | `compatMaxFindings` | `100` | 报告发现上限 |
87
+ | `compatReadLockfile` | `true` | 解析 `pnpm-lock.yaml` |
88
+ | `compatReadWorkspace` | `true` | 对比 `AGENTS.md`/`CLAUDE.md` 与插件 prompt |
89
+ | `compatStrictOfficialOverrides` | `false` | 是否报告官方 bundle 的刻意覆盖 |
90
+
91
+ ## 数据文件
92
+
93
+ ```text
94
+ <dshHome>/experience-optimizer/
95
+ ├── audit.jsonl
96
+ ├── compat/report.json
97
+ └── trim/
98
+ ├── profiles/<profileId>.json
99
+ ├── snapshots/<token>.json
100
+ └── usage.jsonl
101
+ ```
102
+
103
+ ## 已知限制
104
+
105
+ - agent preset 自带的工具不是可单独开关的 Loader entry,trim 只能报告,不能裁剪。
106
+ - 上下文成本按 prompt section/tool schema 估算;无法归属的部分标为 `unattributed`。
107
+ - 去重只给建议,不修改第三方插件源码;语义冲突只标记。
108
+ - 兼容性规则依赖 Loader/pluginManager/manifest 的可用性;缺失时降级为 info。
109
+ - 没有可用的 `dsh-plugin-guard` 服务;运行时兼容判断使用 `@deepseek-ai/dsh-app-boot` 的公开函数与 `pluginManager` 结果。