dsh-agile-workbench 0.0.0-stage → 2.0.1

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 徐野风 (Xu Yefeng)
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,122 @@
1
- # Temporary Holding Version
1
+ # dsh-agile-workbench —— PM工作台套装 bundle
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 里对 AI 说 **「帮我装一下 dsh-agile-workbench」**。
4
+ >
5
+ > 装完即得到:工作台启动器(`pm_workbench_open`)+ 记忆插件 + 浏览器插件 + 搜索插件 + 视觉插件 + 安全搜索 MCP。
6
+ > node 运行时不用单装,`@deepseek-ai/dsh-base` 已内置 `ptc-runtime-node`。
7
+
8
+ - 包名:`dsh-agile-workbench`
9
+ - 类型:DSH bundle(**只做 `cordis.patch.yml` + `dependencies`**,自身不注册插件、不 insert 自己)
10
+ - 适用 DSH:`>=0.2.2-rc.1 <0.3.0`(`engines.dsh`)
11
+ - 许可证:MIT
12
+
13
+ ---
14
+
15
+ ## 一、它装了什么
16
+
17
+ | # | 行 id | 包 | 作用 |
18
+ |---|---|---|---|
19
+ | 1 | `pm-workbench-dsh` | `pm-workbench-dsh`(随包,见 `pm-workbench-dsh/`) | 注册工具 `pm_workbench_open`,拉起本机 PM工作台 |
20
+ | 2 | `dsh-memory-evolve` | `dsh-memory-evolve` | 跨会话长期记忆 / 待办 / 技能 |
21
+ | 3 | `ego-browser` | `dsh-ego-browser` | 受控浏览器(ego lite) |
22
+ | 4 | `modsearch` | `@liustack/modsearch` | 联网搜索 / 读网页 / X 检索 |
23
+ | 5 | `modlens` | `@liustack/modlens` | 图片视觉读取 |
24
+ | 6 | `mcp-web-search-safe` | `@deepseek-ai/dsh-mcp-client` + 随包脚本 `mcp/web-search-safe.js` | 只读安全搜索/抓取 MCP(`web_search` / `web_fetch`) |
25
+
26
+ `cordis.patch.yml` 一次 `insert` 全部 6 行;套装包本身不上树,避免循环。
27
+
28
+ ## 二、安装
29
+
30
+ ### 方式 A(推荐):让 AI 装
31
+
32
+ 对 DSH 说:
33
+
34
+ > 帮我装一下 dsh-agile-workbench
35
+
36
+ AI 会走 `plugin_manager` 的 `install_bundle`:装包 + 把包名注册进 profile 的 `dsh.profile.bundles`。
37
+
38
+ ### 方式 B:命令行
39
+
40
+ ```powershell
41
+ # 1) 装包(只是 pnpm add,不会注册 bundle)
42
+ dsh plugin --profile <profile> add dsh-agile-workbench
43
+
44
+ # 2) 注册 bundle(关键一步,漏了插件不会上树)
45
+ # 在 <DSH_HOME>/profiles/<profile>/package.json 的 dsh.profile.bundles 里加一行:
46
+ # "dsh-agile-workbench"
47
+ ```
48
+
49
+ 重启 DSH / 新开会话后生效。
50
+
51
+ ### 验证
52
+
53
+ ```powershell
54
+ dsh --profile <profile> --dump-config
55
+ ```
56
+
57
+ 组合树里应能看到上面 6 个行 id(`pm-workbench-dsh` … `mcp-web-search-safe`)。
58
+
59
+ ## 三、可配置项(都不含密钥)
60
+
61
+ `mcp-web-search-safe` 的脚本位置不写死任何本机路径,两个环境变量可覆盖:
62
+
63
+ | 环境变量 | 默认值 | 说明 |
64
+ |---|---|---|
65
+ | `DSH_WEB_SEARCH_SAFE_NODE` | PATH 里的 `node` | 启动 MCP 脚本的 node 可执行文件 |
66
+ | `DSH_WEB_SEARCH_SAFE_SCRIPT` | `<profile>/node_modules/dsh-agile-workbench/mcp/web-search-safe.js` | 安全搜索脚本;想换成你自己那份完整版就指过去 |
67
+
68
+ `mcp/web-search-safe.js` 是**零第三方依赖**的精简版:`web_search` 走 Bing RSS;`web_fetch` 仅允许 http/https、禁内网/本机地址、每一跳重定向重校验、响应按字节限量。它不读 DSH 凭据、不写任何文件。
69
+
70
+ ## 四、从"单装 5 个插件"迁移过来(重要)
71
+
72
+ 如果 profile 里已经把 `dsh-ego-browser` / `@liustack/modsearch` / `@liustack/modlens` / `dsh-memory-evolve` / `pm-workbench-dsh` **各自**注册成了 bundle,
73
+ 再接上 `dsh-agile-workbench` 会出现**同一插件两份实例**(id 重复/服务重复)。
74
+
75
+ 迁移步骤:
76
+
77
+ 1. 在 profile 的 `dsh.profile.bundles` 里**删掉**这 5 个单项,只留 `dsh-agile-workbench`;
78
+ 2. `dependencies` 里这 5 个包可以保留(版本由套装声明),也可以删掉让套装带;
79
+ 3. `dsh --profile <profile> --dump-config` 确认每个行 id 只出现一次。
80
+
81
+ ## 五、目录
82
+
83
+ ```
84
+ dsh-plugin/
85
+ package.json 套装包(dsh.bundle.patch -> ./cordis.patch.yml)
86
+ cordis.patch.yml 6 行 insert
87
+ mcp/web-search-safe.js 随包安全搜索 MCP(零依赖)
88
+ pm-workbench-dsh/ 工作台启动器子包(index.js,可单独安装)
89
+ README.md
90
+ LICENSE
91
+ ```
92
+
93
+ ## 六、边界
94
+
95
+ - 不改 DSH 本体,不写 `<DSH_HOME>/profiles/desktop`(Electron 专属 profile 由桌面应用管理)。
96
+ - 不涉及 npm 发布凭据;`pm-workbench-dsh` 以 `file:./pm-workbench-dsh` 随套装携带,也可单独发布。
97
+ - `dsh-memory-evolve` 目前是本机私有包(`0.1.0`),对外分发前需先发布到 registry 或改成本地路径。
98
+
99
+
100
+ ---
101
+
102
+ ## 七、需求流程与缺陷流程(这套工作台怎么干活)
103
+
104
+ ### 需求流程(功能/改造)
105
+
106
+ 1. **Owner 提目标** → PM 建需求条目,需求分析师写需求正文(用户故事、边界六类、验收标准、异常)。
107
+ 2. **产品设计师评审**:通过(RR)才往下走;复杂需求由测试人员先做一遍可测性评审(TR-Q)。
108
+ 3. **Owner 评审**:Owner 本人在界面「评审弹窗」点「通过」后才允许开发;需求正文一改,旧决定自动失效,必须重评。
109
+ 4. **PM 派开发**:一次只派一个角色、一个任务;派单前跑「派单前置检查」,目标角色空闲才发。
110
+ 5. **开发提交**:程序员 A/B 直接实现并提交(提交信息带任务号+需求号),不需要提案/互审/签字。
111
+ 6. **测试确认**:测试人员独立复验(隔离环境、真实证据、版本递增不覆盖),写测试报告。
112
+ 7. **Owner 验收**:需求到「待验收」后由 **Owner 本人**在「我的验收」点通过——**代管/PM/测试都不能代验需求**。
113
+ 8. **迭代**:Owner 打回走「迭代」入口,分析师改稿后重新走 2–7。
114
+
115
+ ### 缺陷流程(Bug/场景缺陷)
116
+
117
+ 1. 任何角色发现缺陷 → 立缺陷单(必带复现步骤 + 验收标准),PM 定优先级(P0/P1/P2/P3)。
118
+ 2. PM 派开发 → 开发修复并提交(提交信息带缺陷号)→ 测试人员复验并出具报告+证据。
119
+ 3. **PM 或测试人员**用 `task accept` 验收缺陷单(需求级验收不在此列,只能 Owner 本人)。
120
+ 4. P0 缺陷当天修;P1 三天内;P2 一周内;P3 两周内。
121
+
122
+ > 完整口径见仓库内《团队宪法》与 `团队/流程.md` 第二部分「现行工作流」。
@@ -0,0 +1,50 @@
1
+ # dsh-agile-workbench —— PM工作台套装 bundle(patch-only)
2
+ #
3
+ # 一次 insert 装齐六类行;套装包本身不注册插件、也不 insert 自己(会循环):
4
+ # 1. pm-workbench-dsh 工作台启动器(工具 pm_workbench_open),随包放在 ./pm-workbench-dsh/
5
+ # 2. dsh-memory-evolve 记忆插件
6
+ # 3. dsh-ego-browser 浏览器插件
7
+ # 4. @liustack/modsearch 搜索插件
8
+ # 5. @liustack/modlens 视觉插件
9
+ # 6. mcp-web-search-safe 安全搜索 MCP(@deepseek-ai/dsh-mcp-client + 随包脚本)
10
+ # node 运行时由 dsh-base 内置的 ptc-runtime-node 提供,这里不单列。
11
+ #
12
+ # 先照搬 @liustack/modsearch 自带 bundle 的这条路由:它除了 insert 自己,还会把 web 行的
13
+ # 搜索能力指向 modsearch;只 insert 不改 web,会出现"装了搜索插件、搜索却仍走别的 provider"。
14
+ # 注意 patch 行是整段替换 config,这里必须重述 searchProvider/fetchProvider 两个键。
15
+ - id: web
16
+ config:
17
+ searchProvider: modsearch
18
+ fetchProvider: http
19
+
20
+ - insert:
21
+ - id: pm-workbench-dsh
22
+ name: ./pm-workbench-dsh/index.js
23
+ # B-20261117-180718-9229:这里原来是 config: {} —— 插件拿不到 teamRoot,采集落相对路径后
24
+ # mkdir 抛错、又被静默吞掉,导致 Owner 重启 DSH 后面板永远「未接入」。
25
+ # 现在给默认值;插件侧另有 cfg > env > workbench.json 上溯 > 默认目录 的多级兜底。
26
+ config:
27
+ teamRoot: !!js process.env.AWB_TEAM_ROOT || 'D:/deepseek/agile-workbench/团队'
28
+ - id: dsh-memory-evolve
29
+ name: dsh-memory-evolve
30
+ config: {}
31
+ - id: ego-browser
32
+ name: dsh-ego-browser
33
+ config: {}
34
+ - id: modsearch
35
+ name: '@liustack/modsearch'
36
+ config: {}
37
+ - id: modlens
38
+ name: '@liustack/modlens'
39
+ config: {}
40
+ - id: mcp-web-search-safe
41
+ name: '@deepseek-ai/dsh-mcp-client'
42
+ config:
43
+ serverName: web-search-safe
44
+ transport: stdio
45
+ # 可配置,不写死本机路径:
46
+ # DSH_WEB_SEARCH_SAFE_NODE node 可执行文件(默认 PATH 里的 node)
47
+ # DSH_WEB_SEARCH_SAFE_SCRIPT 安全搜索脚本(默认本包 mcp/web-search-safe.js)
48
+ command: !!js process.env.DSH_WEB_SEARCH_SAFE_NODE || 'node'
49
+ args:
50
+ - !!js process.env.DSH_WEB_SEARCH_SAFE_SCRIPT || (process.env.DSH_PROFILE_DIR + '/node_modules/dsh-agile-workbench/mcp/web-search-safe.js')
@@ -0,0 +1,335 @@
1
+ #!/usr/bin/env node
2
+ // web-search-safe —— 安全版 Web Search / Fetch MCP server(stdio,零第三方依赖)。
3
+ //
4
+ // 随 dsh-pm-workbench 套装分发,默认由套装 cordis.patch.yml 的 mcp-web-search-safe 行启动。
5
+ // 只暴露两个只读工具:
6
+ // - web_search:查网络用语/梗/事实性问题;默认走 Bing RSS,不把查询词发广告网络以外的地方。
7
+ // - web_fetch :只允许 http/https;禁 URL 内嵌凭据、禁 localhost/内网/链路本地地址,
8
+ // 先做 DNS 解析并检查全部结果,手动跟随重定向(每一跳重校验),响应体按字节限量。
9
+ // 不暴露任何本地文件、命令执行、写操作。协议:MCP stdio(换行分隔 JSON-RPC 2.0)。
10
+ //
11
+ // 可用环境变量(都不含密钥):
12
+ // WEB_SEARCH_SAFE_TIMEOUT_MS 单次请求超时,默认 20000
13
+ // WEB_SEARCH_SAFE_MAX_BYTES 单次响应上限,默认 524288
14
+ import dns from 'node:dns/promises';
15
+ import net from 'node:net';
16
+ import process from 'node:process';
17
+
18
+ const SERVER_NAME = 'web-search-safe';
19
+ const SERVER_VERSION = '1.0.0';
20
+ const PROTOCOL_VERSION = '2024-11-05';
21
+ const TIMEOUT_MS = Number(process.env.WEB_SEARCH_SAFE_TIMEOUT_MS || 20000);
22
+ const MAX_BYTES = Number(process.env.WEB_SEARCH_SAFE_MAX_BYTES || 512 * 1024);
23
+ const UA = 'dsh-pm-workbench-web-search-safe/1.0 (+https://github.com/781237194/agile-workbench)';
24
+
25
+ const TOOLS = [
26
+ {
27
+ name: 'web_search',
28
+ description: '联网搜索(只读):返回标题/链接/摘要候选,用于查网络用语、梗、事实性问题。',
29
+ inputSchema: {
30
+ type: 'object',
31
+ properties: { query: { type: 'string', description: '搜索词,最多 300 字' } },
32
+ required: ['query'],
33
+ },
34
+ },
35
+ {
36
+ name: 'web_fetch',
37
+ description: '抓取 http(s) 网页正文(只读):禁止内网/本机地址,返回纯文本前若干字符。',
38
+ inputSchema: {
39
+ type: 'object',
40
+ properties: { url: { type: 'string', description: '要抓取的 http(s) URL' } },
41
+ required: ['url'],
42
+ },
43
+ },
44
+ ];
45
+
46
+ const PRIVATE_V4 = [
47
+ [/^10\./, '10/8'],
48
+ [/^127\./, '127/8'],
49
+ [/^169\.254\./, '169.254/16'],
50
+ [/^172\.(1[6-9]|2\d|3[01])\./, '172.16/12'],
51
+ [/^192\.168\./, '192.168/16'],
52
+ [/^100\.(6[4-9]|[7-9]\d|1[01]\d|12[0-7])\./, '100.64/10'],
53
+ [/^0\./, '0/8'],
54
+ ];
55
+
56
+ function log(msg) {
57
+ process.stderr.write(`[web-search-safe] ${msg}\n`);
58
+ }
59
+
60
+ function send(payload) {
61
+ process.stdout.write(JSON.stringify(payload) + '\n');
62
+ }
63
+
64
+ function result(id, value) {
65
+ send({ jsonrpc: '2.0', id, result: value });
66
+ }
67
+
68
+ function error(id, code, message) {
69
+ send({ jsonrpc: '2.0', id, error: { code, message } });
70
+ }
71
+
72
+ function textResult(text, isError = false) {
73
+ return { content: [{ type: 'text', text: String(text) }], ...(isError ? { isError: true } : {}) };
74
+ }
75
+
76
+ function cleanQuery(raw) {
77
+ let q = String(raw ?? '');
78
+ q = q.replace(/\[CQ:[^\]]*\]/g, ' ');
79
+ q = q.replace(/[\u0000-\u001f\u007f]/g, ' ');
80
+ q = q.replace(/\s+/g, ' ').trim();
81
+ return q.slice(0, 300);
82
+ }
83
+
84
+ function stripTags(html) {
85
+ return String(html)
86
+ .replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, '$1')
87
+ .replace(/<script[\s\S]*?<\/script>/gi, ' ')
88
+ .replace(/<style[\s\S]*?<\/style>/gi, ' ')
89
+ .replace(/<[^>]+>/g, ' ')
90
+ .replace(/&nbsp;/g, ' ')
91
+ .replace(/&amp;/g, '&')
92
+ .replace(/&lt;/g, '<')
93
+ .replace(/&gt;/g, '>')
94
+ .replace(/&quot;/g, '"')
95
+ .replace(/&#(\d+);/g, (_, n) => String.fromCharCode(Number(n)))
96
+ .replace(/\s+/g, ' ')
97
+ .trim();
98
+ }
99
+
100
+ function decodeEntities(text) {
101
+ return String(text)
102
+ .replace(/&amp;/g, '&')
103
+ .replace(/&lt;/g, '<')
104
+ .replace(/&gt;/g, '>')
105
+ .replace(/&quot;/g, '"')
106
+ .replace(/&#(\d+);/g, (_, n) => String.fromCharCode(Number(n)));
107
+ }
108
+
109
+ function isPrivateIp(ip) {
110
+ if (net.isIPv4(ip)) {
111
+ return PRIVATE_V4.some(([re, label]) => {
112
+ if (re.test(ip)) return label;
113
+ return false;
114
+ }) || /^224\./.test(ip) || /^2(3\d|4\d|5[0-5])\./.test(ip);
115
+ }
116
+ if (net.isIPv6(ip)) {
117
+ const lower = ip.toLowerCase();
118
+ if (lower === '::1' || lower === '::') return 'loopback';
119
+ if (/^f[cd]/.test(lower)) return 'fc00::/7';
120
+ if (/^fe[89ab]/.test(lower)) return 'fe80::/10';
121
+ const mapped = lower.match(/^::ffff:(\d+\.\d+\.\d+\.\d+)$/);
122
+ if (mapped) return isPrivateIp(mapped[1]);
123
+ return false;
124
+ }
125
+ return false;
126
+ }
127
+
128
+ function parseTargetUrl(raw) {
129
+ let url;
130
+ try {
131
+ url = new URL(String(raw || '').trim());
132
+ } catch {
133
+ throw new Error('URL 不合法');
134
+ }
135
+ if (url.protocol !== 'http:' && url.protocol !== 'https:') throw new Error('只允许 http/https');
136
+ if (url.username || url.password) throw new Error('URL 不允许内嵌凭据');
137
+ const host = url.hostname.toLowerCase().replace(/\.$/, '');
138
+ if (!host) throw new Error('缺少主机名');
139
+ if (host === 'localhost' || host.endsWith('.local') || host.endsWith('.internal')) {
140
+ throw new Error(`拒绝访问内网主机:${host}`);
141
+ }
142
+ if (net.isIP(host) && isPrivateIp(host)) throw new Error(`拒绝访问内网地址:${host}`);
143
+ const port = url.port ? Number(url.port) : url.protocol === 'https:' ? 443 : 80;
144
+ if (port !== 80 && port !== 443 && (port < 1024 || port > 65535)) {
145
+ throw new Error(`拒绝访问非常用端口:${port}`);
146
+ }
147
+ return url;
148
+ }
149
+
150
+ async function assertPublicHost(url) {
151
+ const host = url.hostname;
152
+ if (net.isIP(host)) return;
153
+ let addresses = [];
154
+ try {
155
+ addresses = await dns.lookup(host, { all: true, verbatim: true });
156
+ } catch (err) {
157
+ throw new Error(`域名解析失败:${host}(${err.code || err.message})`);
158
+ }
159
+ if (!addresses.length) throw new Error(`域名无解析结果:${host}`);
160
+ for (const { address } of addresses) {
161
+ const reason = isPrivateIp(address);
162
+ if (reason) throw new Error(`拒绝访问内网地址:${host} → ${address}(${reason})`);
163
+ }
164
+ }
165
+
166
+ async function readLimited(response) {
167
+ if (!response.body) return '';
168
+ const reader = response.body.getReader();
169
+ const chunks = [];
170
+ let total = 0;
171
+ for (;;) {
172
+ const { done, value } = await reader.read();
173
+ if (done) break;
174
+ total += value.byteLength;
175
+ if (total > MAX_BYTES) {
176
+ chunks.push(value);
177
+ try {
178
+ await reader.cancel();
179
+ } catch {}
180
+ break;
181
+ }
182
+ chunks.push(value);
183
+ }
184
+ const buffer = Buffer.concat(chunks.map((c) => Buffer.from(c)));
185
+ return new TextDecoder('utf-8', { fatal: false }).decode(buffer.slice(0, MAX_BYTES));
186
+ }
187
+
188
+ async function safeFetch(rawUrl) {
189
+ let url = parseTargetUrl(rawUrl);
190
+ for (let hop = 0; hop <= 5; hop += 1) {
191
+ await assertPublicHost(url);
192
+ const controller = new AbortController();
193
+ const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
194
+ let response;
195
+ try {
196
+ response = await fetch(url, {
197
+ method: 'GET',
198
+ redirect: 'manual',
199
+ headers: { 'user-agent': UA, accept: 'text/html,application/xhtml+xml,text/plain,*/*;q=0.5' },
200
+ signal: controller.signal,
201
+ });
202
+ } finally {
203
+ clearTimeout(timer);
204
+ }
205
+ const status = response.status;
206
+ if (status >= 300 && status < 400) {
207
+ const location = response.headers.get('location');
208
+ if (!location) throw new Error(`重定向缺少 Location(${status})`);
209
+ url = parseTargetUrl(new URL(location, url).href);
210
+ continue;
211
+ }
212
+ if (!response.ok) throw new Error(`抓取失败:HTTP ${status}`);
213
+ const contentType = String(response.headers.get('content-type') || '');
214
+ const body = await readLimited(response);
215
+ const text = /html|xml/i.test(contentType) ? stripTags(body) : body.trim();
216
+ return { url: url.href, status, contentType, raw: body, text };
217
+ }
218
+ throw new Error('重定向层数过多');
219
+ }
220
+
221
+ async function webSearch(query) {
222
+ const q = cleanQuery(query);
223
+ if (!q) throw new Error('搜索词为空');
224
+ const url = `https://www.bing.com/search?format=rss&count=10&q=${encodeURIComponent(q)}`;
225
+ const { raw } = await safeFetch(url);
226
+ const items = [...raw.matchAll(/<item>([\s\S]*?)<\/item>/gi)].slice(0, 6);
227
+ const rows = items.map((m, index) => {
228
+ const block = m[1];
229
+ const title = stripTags((block.match(/<title>([\s\S]*?)<\/title>/i) || [, ''])[1]);
230
+ const link = decodeEntities((block.match(/<link>([\s\S]*?)<\/link>/i) || [, ''])[1]).trim();
231
+ const desc = stripTags((block.match(/<description>([\s\S]*?)<\/description>/i) || [, ''])[1]);
232
+ return `${index + 1}. ${title}\n ${link}\n ${desc.slice(0, 200)}`;
233
+ });
234
+ if (!rows.length) {
235
+ const plain = stripTags(raw).slice(0, 1200);
236
+ return `没有解析到 RSS 结果,原始内容摘要:\n${plain}`;
237
+ }
238
+ return `搜索「${q}」共 ${rows.length} 条:\n\n${rows.join('\n\n')}`;
239
+ }
240
+
241
+ async function webFetch(rawUrl) {
242
+ const { url, status, contentType, text } = await safeFetch(rawUrl);
243
+ const body = text.slice(0, 5000);
244
+ if (!body) return `HTTP ${status},响应为空(${contentType || '未知类型'}):${url}`;
245
+ return `抓取 ${url}(HTTP ${status},${contentType || '未知类型'}),正文前 ${body.length} 字符:\n\n${body}`;
246
+ }
247
+
248
+ async function handleCall(id, params) {
249
+ const name = params?.name;
250
+ const args = params?.arguments || {};
251
+ try {
252
+ if (name === 'web_search') {
253
+ result(id, textResult(await webSearch(args.query)));
254
+ return;
255
+ }
256
+ if (name === 'web_fetch') {
257
+ result(id, textResult(await webFetch(args.url)));
258
+ return;
259
+ }
260
+ result(id, textResult(`未知工具:${name}`, true));
261
+ } catch (err) {
262
+ const message = err?.name === 'AbortError' ? '请求超时' : err?.message || String(err);
263
+ result(id, textResult(`${name} 失败:${message}`, true));
264
+ }
265
+ }
266
+
267
+ /** 尚未返回的异步调用:stdin 关闭时先等它们写完再退出,避免"调用还没回包就 exit"。 */
268
+ const pending = new Set();
269
+
270
+ function handle(message) {
271
+ if (!message || typeof message !== 'object') return;
272
+ const { id, method, params } = message;
273
+ if (method === undefined) return; // response/notification 不处理
274
+ if (id === undefined || id === null) {
275
+ if (method === 'notifications/initialized') return;
276
+ return;
277
+ }
278
+ switch (method) {
279
+ case 'initialize':
280
+ result(id, {
281
+ protocolVersion: PROTOCOL_VERSION,
282
+ capabilities: { tools: {} },
283
+ serverInfo: { name: SERVER_NAME, version: SERVER_VERSION },
284
+ });
285
+ return;
286
+ case 'ping':
287
+ result(id, {});
288
+ return;
289
+ case 'tools/list':
290
+ result(id, { tools: TOOLS });
291
+ return;
292
+ case 'tools/call': {
293
+ const task = handleCall(id, params).finally(() => pending.delete(task));
294
+ pending.add(task);
295
+ return;
296
+ }
297
+ default:
298
+ error(id, -32601, `未实现的方法:${method}`);
299
+ }
300
+ }
301
+
302
+ let buffer = '';
303
+ process.stdin.setEncoding('utf8');
304
+ process.stdin.on('data', (chunk) => {
305
+ buffer += chunk;
306
+ let index = buffer.indexOf('\n');
307
+ while (index >= 0) {
308
+ const line = buffer.slice(0, index).trim();
309
+ buffer = buffer.slice(index + 1);
310
+ if (line) {
311
+ try {
312
+ handle(JSON.parse(line));
313
+ } catch (err) {
314
+ log(`无法解析的输入:${err.message}`);
315
+ }
316
+ }
317
+ index = buffer.indexOf('\n');
318
+ }
319
+ });
320
+ process.stdin.on('end', async () => {
321
+ const rest = buffer.trim();
322
+ if (rest) {
323
+ try {
324
+ handle(JSON.parse(rest));
325
+ } catch {}
326
+ }
327
+ if (pending.size) {
328
+ try {
329
+ await Promise.allSettled([...pending]);
330
+ } catch {}
331
+ }
332
+ // 等 stdout 把最后一条回包刷出去再退出(管道场景容易被截断)。
333
+ process.stdout.write('', () => process.exit(0));
334
+ });
335
+ process.on('uncaughtException', (err) => log(`未捕获异常:${err?.stack || err}`));
package/package.json CHANGED
@@ -1,6 +1,49 @@
1
1
  {
2
2
  "name": "dsh-agile-workbench",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "2.0.1",
4
+ "description": "PM工作台(Agile Workbench)套装 bundle:一次安装装齐工作台启动器、记忆插件、浏览器插件、搜索插件、视觉插件与安全搜索 MCP。",
5
+ "type": "module",
6
+ "files": [
7
+ "cordis.patch.yml",
8
+ "README.md",
9
+ "LICENSE",
10
+ "mcp/",
11
+ "pm-workbench-dsh/"
12
+ ],
13
+ "license": "MIT",
14
+ "author": "徐野风",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/781237194/agile-workbench.git"
18
+ },
19
+ "homepage": "https://github.com/781237194/agile-workbench/tree/dsh-plugin",
20
+ "bugs": {
21
+ "url": "https://github.com/781237194/agile-workbench/issues"
22
+ },
23
+ "keywords": [
24
+ "dsh",
25
+ "dsh-plugin",
26
+ "dsh-bundle",
27
+ "pm-workbench",
28
+ "memory",
29
+ "browser",
30
+ "search",
31
+ "mcp",
32
+ "agile-workbench"
33
+ ],
34
+ "engines": {
35
+ "dsh": ">=0.2.2-rc.1 <0.3.0",
36
+ "node": ">=20"
37
+ },
38
+ "dsh": {
39
+ "bundle": {
40
+ "patch": "./cordis.patch.yml"
41
+ }
42
+ },
43
+ "dependencies": {
44
+ "dsh-memory-evolve": "^0.1.0",
45
+ "dsh-ego-browser": "^0.9.7",
46
+ "@liustack/modsearch": "^5.10.12",
47
+ "@liustack/modlens": "^3.27.3"
48
+ }
49
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 徐野风 (Xu Yefeng)
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.