dsh-thinking-guard 0.0.0-stage → 0.1.17

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.
Files changed (111) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +169 -2
  3. package/cordis.patch.yml +110 -0
  4. package/lib/client.d.ts +918 -0
  5. package/lib/client.d.ts.map +1 -0
  6. package/lib/client.js +10998 -0
  7. package/lib/constants.js +33 -0
  8. package/lib/constants.js.map +1 -0
  9. package/lib/guard-core.js +192 -0
  10. package/lib/guard-core.js.map +1 -0
  11. package/lib/guard-loop-core.js +145 -0
  12. package/lib/guard-loop-core.js.map +1 -0
  13. package/lib/guard.js +324 -0
  14. package/lib/guard.js.map +1 -0
  15. package/lib/host-face.js +187 -0
  16. package/lib/host-face.js.map +1 -0
  17. package/lib/index.js +74 -0
  18. package/lib/index.js.map +1 -0
  19. package/lib/invoke.js +376 -0
  20. package/lib/invoke.js.map +1 -0
  21. package/lib/locations.js +692 -0
  22. package/lib/locations.js.map +1 -0
  23. package/lib/patch-file.js +222 -0
  24. package/lib/patch-file.js.map +1 -0
  25. package/lib/policy-state.js +267 -0
  26. package/lib/policy-state.js.map +1 -0
  27. package/lib/policy.js +806 -0
  28. package/lib/policy.js.map +1 -0
  29. package/lib/registry.js +985 -0
  30. package/lib/registry.js.map +1 -0
  31. package/lib/search.js +187 -0
  32. package/lib/search.js.map +1 -0
  33. package/lib/server/remote.js +370 -0
  34. package/lib/server/remote.js.map +1 -0
  35. package/lib/server/self-update.js +198 -0
  36. package/lib/server/self-update.js.map +1 -0
  37. package/lib/server/usage-remote.js +450 -0
  38. package/lib/server/usage-remote.js.map +1 -0
  39. package/lib/types/constants.d.ts +33 -0
  40. package/lib/types/constants.d.ts.map +1 -0
  41. package/lib/types/guard-core.d.ts +114 -0
  42. package/lib/types/guard-core.d.ts.map +1 -0
  43. package/lib/types/guard-loop-core.d.ts +75 -0
  44. package/lib/types/guard-loop-core.d.ts.map +1 -0
  45. package/lib/types/guard.d.ts +42 -0
  46. package/lib/types/guard.d.ts.map +1 -0
  47. package/lib/types/host-face.d.ts +123 -0
  48. package/lib/types/host-face.d.ts.map +1 -0
  49. package/lib/types/index.d.ts +54 -0
  50. package/lib/types/index.d.ts.map +1 -0
  51. package/lib/types/invoke.d.ts +74 -0
  52. package/lib/types/invoke.d.ts.map +1 -0
  53. package/lib/types/locations.d.ts +144 -0
  54. package/lib/types/locations.d.ts.map +1 -0
  55. package/lib/types/patch-file.d.ts +46 -0
  56. package/lib/types/patch-file.d.ts.map +1 -0
  57. package/lib/types/policy-state.d.ts +47 -0
  58. package/lib/types/policy-state.d.ts.map +1 -0
  59. package/lib/types/policy.d.ts +309 -0
  60. package/lib/types/policy.d.ts.map +1 -0
  61. package/lib/types/registry.d.ts +309 -0
  62. package/lib/types/registry.d.ts.map +1 -0
  63. package/lib/types/search.d.ts +45 -0
  64. package/lib/types/search.d.ts.map +1 -0
  65. package/lib/types/server/remote.d.ts +149 -0
  66. package/lib/types/server/remote.d.ts.map +1 -0
  67. package/lib/types/server/self-update.d.ts +20 -0
  68. package/lib/types/server/self-update.d.ts.map +1 -0
  69. package/lib/types/server/usage-remote.d.ts +90 -0
  70. package/lib/types/server/usage-remote.d.ts.map +1 -0
  71. package/lib/types/usage/usage-backfill.d.ts +134 -0
  72. package/lib/types/usage/usage-backfill.d.ts.map +1 -0
  73. package/lib/types/usage/usage-classifier.d.ts +80 -0
  74. package/lib/types/usage/usage-classifier.d.ts.map +1 -0
  75. package/lib/types/usage/usage-collector-codec.d.ts +66 -0
  76. package/lib/types/usage/usage-collector-codec.d.ts.map +1 -0
  77. package/lib/types/usage/usage-collector.d.ts +150 -0
  78. package/lib/types/usage/usage-collector.d.ts.map +1 -0
  79. package/lib/types/usage/usage-core.d.ts +171 -0
  80. package/lib/types/usage/usage-core.d.ts.map +1 -0
  81. package/lib/types/usage/usage-event-projector.d.ts +82 -0
  82. package/lib/types/usage/usage-event-projector.d.ts.map +1 -0
  83. package/lib/types/usage/usage-host-face.d.ts +212 -0
  84. package/lib/types/usage/usage-host-face.d.ts.map +1 -0
  85. package/lib/types/usage/usage-profile.d.ts +108 -0
  86. package/lib/types/usage/usage-profile.d.ts.map +1 -0
  87. package/lib/types/usage/usage-runtime.d.ts +175 -0
  88. package/lib/types/usage/usage-runtime.d.ts.map +1 -0
  89. package/lib/types/usage/usage-state-codec.d.ts +125 -0
  90. package/lib/types/usage/usage-state-codec.d.ts.map +1 -0
  91. package/lib/usage/usage-backfill.js +680 -0
  92. package/lib/usage/usage-backfill.js.map +1 -0
  93. package/lib/usage/usage-classifier.js +83 -0
  94. package/lib/usage/usage-classifier.js.map +1 -0
  95. package/lib/usage/usage-collector-codec.js +345 -0
  96. package/lib/usage/usage-collector-codec.js.map +1 -0
  97. package/lib/usage/usage-collector.js +565 -0
  98. package/lib/usage/usage-collector.js.map +1 -0
  99. package/lib/usage/usage-core.js +502 -0
  100. package/lib/usage/usage-core.js.map +1 -0
  101. package/lib/usage/usage-event-projector.js +274 -0
  102. package/lib/usage/usage-event-projector.js.map +1 -0
  103. package/lib/usage/usage-host-face.js +135 -0
  104. package/lib/usage/usage-host-face.js.map +1 -0
  105. package/lib/usage/usage-profile.js +402 -0
  106. package/lib/usage/usage-profile.js.map +1 -0
  107. package/lib/usage/usage-runtime.js +594 -0
  108. package/lib/usage/usage-runtime.js.map +1 -0
  109. package/lib/usage/usage-state-codec.js +718 -0
  110. package/lib/usage/usage-state-codec.js.map +1 -0
  111. package/package.json +142 -4
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Dawei Fu
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,170 @@
1
- # Temporary Holding Version
1
+ # dsh-thinking-guard
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 插件:把**能力目录与按需调用**(Capability Menu 思路)和 **Agent 效率守卫**(重复/循环调用提醒)整合在一起。当前版本 **0.1.15**。
4
+
5
+ ## 它做什么
6
+
7
+ - `meta_search` 按需查找能力,`meta_invoke` 调用能力;工具与技能按 Resident / On-demand / Disabled 三档分层,Disabled 会在执行入口拒绝调用,不只是隐藏 Schema。
8
+ - Guard 按 Agent / Turn 隔离,用工具签名与 Step 的结果/错误指纹做重复与 A-B 循环检测;只在证据满足门槛时对匹配调用局部拒绝一次,**不停止整个 Turn**。
9
+ - 设置页提供四个页面:总览、防循环、调用统计、能力目录。
10
+
11
+ ## 它不做什么
12
+
13
+ - 不做工具结果压缩与原文恢复——那是 [dsh-plugin-save-token](https://github.com/YAN3RA/dsh-plugin-save-token) 的职责。
14
+ - 不做模型 / Provider / 完整会话管理——那是 DSH 宿主的职责。
15
+ - 不读取、保存或输出隐藏思维链。
16
+
17
+ ## 安装
18
+
19
+ 一条命令:
20
+
21
+ ```bash
22
+ dsh plugin --profile desktop add dsh-thinking-guard
23
+ ```
24
+
25
+ 装完**重启 DSH**。
26
+
27
+ ### 为什么这一条就够
28
+
29
+ - 包发布在 npm registry,普通版本号即可解析,不需要贴 URL、不需要带哈希。
30
+ - 包内已含构建产物 `lib/`,pnpm 不会跑任何构建脚本,**不需要**在 profile 的 `pnpm-workspace.yaml` 里配 `allowBuilds`。
31
+ - `dsh plugin add` 会在 pnpm 之后多做一次 bundle 协调,把包自动登记进 `dsh.profile.bundles`。**手工改 `package.json` 再 `pnpm install` 不会**,那样装了也不挂载。
32
+
33
+ ### 指定版本 / 升级
34
+
35
+ ```bash
36
+ dsh plugin --profile desktop add dsh-thinking-guard@0.1.16 # 锁定版本
37
+ dsh plugin --profile desktop add dsh-thinking-guard # 升到最新
38
+ ```
39
+
40
+ ### 备用渠道:GitHub Release 附件
41
+
42
+ npm 不可达时,可用 Release 附件的带哈希 URL:
43
+
44
+ ```bash
45
+ curl -s https://api.github.com/repos/YAN3RA/dsh-thinking-guard/releases/latest \
46
+ | grep -o 'https://[^"]*\.tgz'
47
+ dsh plugin --profile desktop add '<上一步输出的 URL>'
48
+ ```
49
+
50
+ **为什么附件名必须带哈希**:profile 从附件 URL 安装时,pnpm 按「URL + integrity」缓存。用同名覆盖附件后 pnpm 不会重新下载——`--force`、`store prune`、删 `node_modules` 都无效。附件名带 tarball 自身 SHA-256 前 8 位,内容变了 URL 就变,缓存不可能命中旧内容。
51
+
52
+ ### 不支持的安装来源
53
+
54
+ | 来源 | 结果 | 原因 |
55
+ |---|---|---|
56
+ | `git+https://…` / `github:owner/repo` | ❌ | 仓库不含 `lib/`,pnpm 需现场跑 `prepare` 构建,而 pnpm 默认拦截 git 依赖的构建脚本 |
57
+ | `link:<本地目录>` | ⚠️ 能装不推荐 | 软链到源码目录,peer 依赖不从目标 `node_modules` 解析 |
58
+
59
+
60
+ ## 升级
61
+
62
+ 重跑方式一 / 方式二即可。脚本会比对当前 pin 与最新附件:
63
+
64
+ - 一致 → 只重装同样的字节,`bundles` 不动
65
+ - 不一致 → 打印 `from:` / `to:`,走 `dsh plugin add` 换版本
66
+
67
+ 手动升级就是把方式三第 2 条的 URL 换成新版本的哈希附件再跑一次。
68
+
69
+ ## 卸载
70
+
71
+ ```bash
72
+ dsh plugin --profile desktop remove dsh-thinking-guard
73
+ ```
74
+
75
+ 一条命令同时清掉 `dependencies` 与 `dsh.profile.bundles`(已实测)。然后重启 DSH。
76
+
77
+ 插件留下的状态文件(`~/.dsh/capability-menu-policy.json`)不会自动删除。如需彻底清理,确认备份后再手动删除。
78
+
79
+ ## 排错
80
+
81
+ ### 装完看不到插件
82
+
83
+ 先查这一条,它解释了绝大多数情况:
84
+
85
+ ```bash
86
+ node -e "const m=require(process.env.HOME+'/.dsh/profiles/desktop/package.json'); console.log('bundled:', m.dsh.profile.bundles.includes('dsh-thinking-guard'))"
87
+ ```
88
+
89
+ `false` → 当初是手改 JSON + `pnpm install` 装的,包在但没挂载。补跑一次 `dsh plugin add <附件URL>`,或手工把包名加进 `dsh.profile.bundles`,然后重启。
90
+
91
+ `true` 却仍看不到 → 确认**已重启** DSH;再看 设置 → 插件 是否有加载报错。
92
+
93
+ ### 装进去的还是旧版本
94
+
95
+ 几乎一定是缓存问题。比对安装目录与 Release 附件里的 `lib/client.js` 大小:
96
+
97
+ ```bash
98
+ ls -la ~/.dsh/profiles/desktop/node_modules/dsh-thinking-guard/lib/client.js
99
+ tar -tzvf <下载的 tgz> | grep 'lib/client.js'
100
+ ```
101
+
102
+ 不一致说明命中了旧缓存——确认你 pin 的是**带哈希**的附件名。
103
+
104
+ ### `dsh plugin add` 超时 / `fetch failed`
105
+
106
+ GitHub 附件下载在部分网络下会 `ETIMEDOUT`。先确认代理可用,再重跑:
107
+
108
+ ```powershell
109
+ pwsh -NoProfile -File scripts/install.ps1 -Proxy http://127.0.0.1:7890
110
+ ```
111
+
112
+ 或手动设环境变量后重跑方式三:
113
+
114
+ ```bash
115
+ export HTTPS_PROXY=http://127.0.0.1:7890
116
+ export HTTP_PROXY=http://127.0.0.1:7890
117
+ ```
118
+
119
+ 注意:**API 与附件下载的可达性可能不一致**。本机实测 `api.github.com` 与 `releases/download/...` 直连可通,但 `github.com/.../releases/latest` 这个 HTML 页会超时——所以脚本只用 API,不抓网页。
120
+
121
+ ### `ERR_PNPM_FETCH_404` / `is not in the npm registry`
122
+
123
+ 用了裸包名。本包不在 npm registry,必须给完整附件 URL。
124
+
125
+ ### `ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED`
126
+
127
+ 用了 git 来源。换 Release 附件,不要去改 `allowBuilds`。
128
+
129
+ ### 提示 DSH 版本不兼容
130
+
131
+ `dsh plugin add` 会在安装前读包的 manifest,比对它对 DSH 的版本要求(`engines` 与 `peerDependencies`),不匹配就拒绝安装并回滚 manifest 与 lockfile。它会在输出里打印一条
132
+ `dsh plugin --profile desktop allow-version <包@版本> --dsh-version <版本> --accept-risk`。
133
+ **那条命令会跳过兼容检查**,只在确认风险后执行。
134
+
135
+ ### 找不到 DSH runtime / profile
136
+
137
+ `~/.dsh/profiles/desktop` 与 `~/.dsh/dsh-runtimes/` 都是 DSH 首次启动才生成的。先正常启动一次 DSH。
138
+
139
+ ### 想看 pnpm 到底报了什么
140
+
141
+ `dsh plugin` 把完整 pnpm 输出写到 profile 下的日志目录:
142
+
143
+ ```bash
144
+ ls -t ~/.dsh/profiles/desktop/.plugin-manager/logs | head
145
+ ```
146
+
147
+ ## 配置
148
+
149
+ 默认 Guard 模式为 `normal`。当前 Step、Tool 次数、Duration 阈值只保留配置校验和计数,不触发软提醒或硬停止。`stepLimitMode: hard-stop` 会归一为 `warn-only`,`duplicateHardBlock: true` 会归一为 `false`,启动时分别记录弃用提示。开启 `duplicateDetection` 时,连续重复的第 3/5/8 次与有证据的 A-B 循环会提醒;只有相同操作及结果/错误指纹满足策略门槛后,才会通过 `tools.guard` 对匹配调用局部拒绝一次,不停止整个 Turn。配置位于插件 root entry 的 `config.guard`,状态按 Agent / Turn 隔离。
150
+
151
+ ## 文档入口
152
+
153
+ 本文件就是代码仓的 README(工作区里位于 `01_Source_Code/README.md`)。其余文档在**工作区根**,不随仓库发布:
154
+
155
+ | 想做的事 | 去哪 |
156
+ |---|---|
157
+ | 找任意文档 | 根目录 `PROJECT_INDEX.md` |
158
+ | 看现在做到哪 / 接手 | 根目录 `HANDOFF.md` |
159
+ | 长期规则与开发规范 | 根目录 `AGENTS.md` |
160
+ | 查架构与模块方案 | 见项目层 `02_Design/` 下的方案文档(不在本仓库内) |
161
+ | 查历史与归档 | 根目录 `04_Docs/02_history/README.md` |
162
+
163
+ ## 目录约定
164
+
165
+ - 本目录是**唯一代码仓**(独立 git,远端 `YAN3RA/dsh-thinking-guard`)。
166
+ - 仓库只发布**源码 + 测试 + 本 README**。`AGENTS.md` / `PROJECT_INDEX.md` / `HANDOFF.md` 与 `docs/` 均为本地保留,不提交。
167
+
168
+ ## 来源与许可
169
+
170
+ 本项目基于 Capability Menu 实现,并按 Apache License 2.0 发布。详见 [LICENSE](LICENSE)。
@@ -0,0 +1,110 @@
1
+ # dsh-capability-menu aggregate bundle patch: mounts the meta plugins in one
2
+ # layer, from a single installable package.
3
+ #
4
+ # One package, five plugin entries — four mount a subpath of
5
+ # `dsh-thinking-guard` (the loader resolves package subpath exports; see
6
+ # `@deepseek-ai/dsh-web-app/startup` for the same pattern in the harness), and
7
+ # the root entry loads the package main to mount the browser-facing gateway
8
+ # (and thereby registers the package itself as a `dsh.client` loader entry):
9
+ #
10
+ # - id: capability-menu-registry
11
+ # name: 'dsh-thinking-guard/registry'
12
+ # - id: capability-menu-search
13
+ # name: 'dsh-thinking-guard/search'
14
+ # - id: capability-menu-invoke
15
+ # name: 'dsh-thinking-guard/invoke'
16
+ # - id: capability-menu-policy
17
+ # name: 'dsh-thinking-guard/policy'
18
+ # config:
19
+ # # Rule syntax — tier keys `resident` / `on-demand` / `disabled`
20
+ # # (exact names, `*` globs, or `server:<name>:*`), plus `metaTools` —
21
+ # # and the priority order are documented in the README「配置」
22
+ # # section; the shipped defaults live in the insert block below.
23
+ #
24
+ # - `capability-menu-registry` (P0): builds/indexes the capability catalog and
25
+ # exposes the `ctx.capability` service (search/get/getDetail/refresh). It registers
26
+ # no model-facing tool itself. Indexes every visible tool — MCP tools by their
27
+ # server and harness-native tools (bash/read/write/…) under the reserved
28
+ # `built-in` pseudo-server — plus skills from the global layer and every
29
+ # mountable preset's standing scope. `meta_search` searches this live index.
30
+ # - `capability-menu-search` (P1): registers the `meta_search` tool (list + detail).
31
+ # - `capability-menu-invoke` (P2): registers the `meta_invoke` tool (unified
32
+ # execution of tools — MCP or native — and skill loading). Executes in the
33
+ # caller's agent view so On-demand tools stay runnable without bypassing scope
34
+ # restrictions; dedups already-loaded skills. Rejects Disabled capabilities.
35
+ # - `capability-menu-policy` (P3): Resident/On-demand/Disabled projection
36
+ # strategy + 能力菜单 surface. Reads explicit resident/on-demand/disabled
37
+ # rules (exact name + glob + server:<name>:*) and filters `assembly.tools` and
38
+ # web guidance sections at `system-prompt/assemble`. The execution chain
39
+ # (`ctx.tools.execute`) is untouched, so On-demand capabilities remain executable
40
+ # via `meta_invoke`. Exposes `ctx.capabilityPolicy` to the 能力菜单 tab through
41
+ # the Typert gateway: the tier surface (`classifyAll`/`getConfig`/
42
+ # `updateConfig`), the registered-location surface (`listLocations`/`addLocation`/
43
+ # `updateLocation`/`removeLocation` and `listSkillLocations`/`addSkillLocation`/
44
+ # `updateSkillLocation`/`removeSkillLocation`/`adoptSkillLocation`), the
45
+ # read-only rules and search summaries (`getCatalogDocs`), a rebuild trigger (`refresh`), and
46
+ # skill browsing (`getDetail`/`listSkillDir`/`readSkillFile`). Tier clicks land
47
+ # in the plugin's state file after `persistDebounceMs`; search settings share
48
+ # that file. Registered MCP servers land in `patchFile`, and skill directories
49
+ # live under `skillsDir`.
50
+ #
51
+ # Default (policy present but no config): every capability is Resident — the
52
+ # `classify` fallback, nothing is hidden. Add explicit `on-demand`/`disabled`
53
+ # rules to pull capabilities out of the model surface.
54
+ # The web surface disables the host skill filesystem provider by default, but
55
+ # this plugin's global Skill registration writes to its standard ~/.dsh/skills
56
+ # root. Re-enable the native provider so registered skills are indexed and
57
+ # available through ctx.skills; no upstream source or skill implementation is
58
+ # replaced.
59
+ - id: skill-filesystem
60
+ disabled: false
61
+ - insert:
62
+ - id: capability-menu-registry
63
+ name: 'dsh-thinking-guard/registry'
64
+ - id: capability-menu-search
65
+ name: 'dsh-thinking-guard/search'
66
+ - id: capability-menu-invoke
67
+ name: 'dsh-thinking-guard/invoke'
68
+ - id: capability-menu-policy
69
+ name: 'dsh-thinking-guard/policy'
70
+ config:
71
+ # Native coding tools are cataloged under the reserved `built-in`
72
+ # pseudo-server and are fully manageable like MCP tools. Unlisted
73
+ # capabilities default to Resident; list them under `on-demand`/
74
+ # `disabled` to pull MCP servers, native tools, or skills out of the
75
+ # model surface. On-demand native tools stay invocable through
76
+ # `meta_search` → `meta_invoke`. The `meta_search`/`meta_invoke`
77
+ # control-plane tools and the reserved `run_code` transport never enter
78
+ # the catalog. Do not name a real MCP server `built-in`.
79
+ tools:
80
+ resident:
81
+ - bash
82
+ - read
83
+ - write
84
+ - edit
85
+ - read_image
86
+ - glob
87
+ - grep
88
+ # Root entry: loads the package main, which mounts the Typert gateway that
89
+ # exposes ctx.capabilityPolicy to the browser. Makes this package a loader
90
+ # entry itself so @deepseek-ai/dsh-client-modules discovers its `dsh.client`
91
+ # declaration and serves the 能力菜单 browser bundle (`./client`).
92
+ - id: thinking-guard
93
+ name: 'dsh-thinking-guard'
94
+ config:
95
+ guard:
96
+ enabled: true
97
+ profile: normal
98
+ stepLimitMode: warn-only
99
+ duplicateDetection: true
100
+ duplicateWarnAfter: 2
101
+ duplicateHardBlock: false
102
+ hostIntegration:
103
+ enabled: true
104
+ provider: pi-desktop
105
+ preferHostTokenSaver: true
106
+ preferHostPromptCache: true
107
+ # Deprecated: compatibility-only fields; no convergence steer or next-step rejection.
108
+ maxConvergenceSteersPerTurn: 1
109
+ maxNoProgressCycles: 2
110
+ loopBreakMode: stop-next-step