dsh-arch-grower 0.2.1 → 0.3.0
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/README.md +23 -10
- package/lib/client/Panel.d.ts +1 -0
- package/lib/client/Panel.js +40 -0
- package/lib/client/index.d.ts +18 -0
- package/lib/client/index.js +16 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +87 -1
- package/package.json +29 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# dsh-arch-grower
|
|
2
2
|
|
|
3
|
-
在 DeepSeek Harness 里驱动 [arch-grower](../) 的插件:注册 `arch_*` 工具,让 agent
|
|
3
|
+
在 DeepSeek Harness 里驱动 [arch-grower](../) 的插件:注册 `arch_*` 工具,让 agent 直接在对话里推进架构推演,并在右侧栏直接看架构图。Python 引擎零依赖,插件通过子进程调用项目内嵌的 CLI。
|
|
4
4
|
|
|
5
5
|
## 安装
|
|
6
6
|
|
|
@@ -8,22 +8,22 @@
|
|
|
8
8
|
npm install -g dsh-arch-grower
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
安装后需要重启 DSH,插件才会被加载;插件默认不自动启用。
|
|
12
12
|
|
|
13
13
|
## 前置条件
|
|
14
14
|
|
|
15
|
-
- 本机有 `python
|
|
16
|
-
-
|
|
15
|
+
- 本机有 `python`(可用插件配置 `python` 覆盖)
|
|
16
|
+
- 目标项目已内嵌引擎:项目根目录存在 `.arch/scripts/arch_cli.py`。没有就先在项目里跑 `python -m arch_grower bootstrap`
|
|
17
17
|
|
|
18
18
|
## 项目定位
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
插件按顺序决定操作哪个项目:
|
|
21
21
|
|
|
22
22
|
1. 插件配置里的 `projectDir`
|
|
23
23
|
2. 环境变量 `ARCH_ROOT`
|
|
24
24
|
3. 会话当前工作目录
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
都拿不到时,工具会返回可操作的提示,而不是空结果。
|
|
27
27
|
|
|
28
28
|
## 工具
|
|
29
29
|
|
|
@@ -32,10 +32,23 @@ npm install -g dsh-arch-grower
|
|
|
32
32
|
| `arch_status` | 阶段、节点数、焦点、下一步建议 | 否 |
|
|
33
33
|
| `arch_focus` | 当前推演焦点:该做什么、能做多少、为什么卡住;可聚焦到节点或子系统 | 否 |
|
|
34
34
|
| `arch_facts` | 已核实的外部约束;可按节点过滤、含已取代的旧记录 | 否 |
|
|
35
|
+
| `arch_collapse` | 把空洞折叠成实现节点;spec 最多 80 字 | 是 |
|
|
36
|
+
| `arch_add_node` | 在流水线上新增节点(默认空洞) | 是 |
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
写操作的校验(spec 80 字上限、活跃空洞熔断、全局不变式)全部由引擎执行,插件只做必填参数的前置检查,错误原文透传给用户。
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
## 右侧栏面板
|
|
41
|
+
|
|
42
|
+
启用后右侧栏出现「架构」标签,内嵌当前项目的看板页面:
|
|
43
|
+
|
|
44
|
+
- 面板复用 `arch serve` 渲染的同一份看板,因此**看板里的能力它都有**:总图/子系统切换、选中节点看详情、对空洞折叠写回(带版本号冲突校验)。没有第二套实现。
|
|
45
|
+
- 没起服务时面板不会白屏,会给出启动命令:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
python .arch/scripts/arch_cli.py serve
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
- 服务地址默认 `http://127.0.0.1:8765/`,面板顶部可改,改后记在浏览器本地。
|
|
39
52
|
|
|
40
53
|
## 配置示例
|
|
41
54
|
|
|
@@ -50,8 +63,8 @@ npm install -g dsh-arch-grower
|
|
|
50
63
|
|
|
51
64
|
## 已知限制
|
|
52
65
|
|
|
53
|
-
-
|
|
54
|
-
-
|
|
66
|
+
- 依赖 `@deepseek-ai/cordis ~4.1.0`、`@deepseek-ai/dsh-* 0.2.2-rc.5`;与本机 DSH 版本不一致时可能加载失败。
|
|
67
|
+
- 面板的写回依赖 `arch serve` 在跑;只读工具不依赖它。
|
|
55
68
|
|
|
56
69
|
## 许可
|
|
57
70
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ArchPanel(): JSX.Element;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
3
|
+
const STORAGE_KEY = 'arch-grower:serve-url';
|
|
4
|
+
const DEFAULT_URL = 'http://127.0.0.1:8765/';
|
|
5
|
+
/** 探测 arch serve 是否在跑:读它自己的 /api/data,最轻且不需要开图。 */
|
|
6
|
+
async function probe(base) {
|
|
7
|
+
const controller = new AbortController();
|
|
8
|
+
const timer = setTimeout(() => controller.abort(), 1500);
|
|
9
|
+
try {
|
|
10
|
+
const response = await fetch(new URL('api/data', base).toString(), {
|
|
11
|
+
signal: controller.signal,
|
|
12
|
+
cache: 'no-store',
|
|
13
|
+
});
|
|
14
|
+
return response.ok;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
finally {
|
|
20
|
+
clearTimeout(timer);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function ArchPanel() {
|
|
24
|
+
const [base, setBase] = useState(() => localStorage.getItem(STORAGE_KEY) || DEFAULT_URL);
|
|
25
|
+
const [draft, setDraft] = useState(base);
|
|
26
|
+
const [state, setState] = useState('checking');
|
|
27
|
+
const recheck = useCallback(async () => {
|
|
28
|
+
setState('checking');
|
|
29
|
+
setState((await probe(base)) ? 'up' : 'down');
|
|
30
|
+
}, [base]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
void recheck();
|
|
33
|
+
}, [recheck]);
|
|
34
|
+
const save = useCallback(() => {
|
|
35
|
+
const next = draft.trim() || DEFAULT_URL;
|
|
36
|
+
localStorage.setItem(STORAGE_KEY, next);
|
|
37
|
+
setBase(next);
|
|
38
|
+
}, [draft]);
|
|
39
|
+
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', height: '100%', gap: 8, padding: 8 }, children: [_jsxs("div", { style: { display: 'flex', gap: 6, alignItems: 'center' }, children: [_jsx("input", { "aria-label": "\u770B\u677F\u5730\u5740", value: draft, onChange: (event) => setDraft(event.target.value), onBlur: save, style: { flex: 1, padding: '4px 6px', borderRadius: 6, border: '1px solid var(--dsw-alias-line-secondary)' } }), _jsx("button", { type: "button", onClick: () => void recheck(), children: "\u91CD\u8BD5" })] }), state === 'up' && (_jsx("iframe", { title: "arch-grower \u67B6\u6784\u56FE", src: base, style: { flex: 1, border: 0, borderRadius: 8, background: 'transparent' } })), state === 'down' && (_jsxs("div", { style: { padding: 12, lineHeight: 1.7 }, children: [_jsx("p", { style: { margin: '0 0 8px' }, children: "\u6CA1\u8FDE\u4E0A\u770B\u677F\u670D\u52A1\u3002\u5728\u9879\u76EE\u6839\u76EE\u5F55\u542F\u52A8\u5B83\uFF1A" }), _jsx("pre", { style: { margin: '0 0 8px', padding: 8, borderRadius: 6, overflowX: 'auto' }, children: "python .arch/scripts/arch_cli.py serve" }), _jsx("p", { style: { margin: 0, opacity: 0.75 }, children: "\u4E5F\u53EF\u4EE5\u7EE7\u7EED\u7528\u5DE5\u5177\u63A8\u8FDB\u67B6\u6784\u2014\u2014\u9762\u677F\u53EA\u662F\u770B\u56FE\u7684\u7A97\u53E3\uFF0C\u4E0D\u662F\u5FC5\u9700\u54C1\u3002" })] })), state === 'checking' && _jsx("div", { style: { padding: 12, opacity: 0.7 }, children: "\u6B63\u5728\u8FDE\u770B\u677F\u670D\u52A1\u2026" })] }));
|
|
40
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const id = "arch-grower";
|
|
2
|
+
export declare const inject: string[];
|
|
3
|
+
/**
|
|
4
|
+
* 只声明本插件真正用到的那几个能力,而不是去猜客户端包的模块扩展路径。
|
|
5
|
+
* 运行时由 DSH 的 cordis 上下文提供,字段名与官方插件用法一致。
|
|
6
|
+
*/
|
|
7
|
+
interface ClientContext {
|
|
8
|
+
effect(fn: () => (() => void) | void, label?: string): void;
|
|
9
|
+
sidebarRightTabs: {
|
|
10
|
+
register(definition: Record<string, unknown>): () => void;
|
|
11
|
+
};
|
|
12
|
+
slots: {
|
|
13
|
+
inject(name: string, register: () => (() => void) | void): void;
|
|
14
|
+
register(definition: Record<string, unknown>, component: unknown): () => void;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export declare function apply(ctx: ClientContext): void;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// `.js` 后缀是 NodeNext 的硬要求:编译后就是 lib/client/Panel.js。
|
|
2
|
+
import { ArchPanel } from './Panel.js';
|
|
3
|
+
export const id = 'arch-grower';
|
|
4
|
+
export const inject = ['slots', 'sidebarRightTabs'];
|
|
5
|
+
export function apply(ctx) {
|
|
6
|
+
ctx.effect(() => ctx.sidebarRightTabs.register({
|
|
7
|
+
id,
|
|
8
|
+
kind: id,
|
|
9
|
+
priority: 'extension',
|
|
10
|
+
title: () => '架构',
|
|
11
|
+
}), 'arch-grower: sidebar page');
|
|
12
|
+
ctx.slots.inject('sidebar.right.pane.tab', () => ctx.slots.register({
|
|
13
|
+
name: 'sidebar.right.pane.tab',
|
|
14
|
+
key: id,
|
|
15
|
+
}, ArchPanel));
|
|
16
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -57,5 +57,7 @@ export declare function createReadTools(run: Runner): ToolSpec[];
|
|
|
57
57
|
export declare function archStatus(run: Runner): Promise<{
|
|
58
58
|
content: string;
|
|
59
59
|
}>;
|
|
60
|
+
/** 写工具集合。写盘前的校验(80 字上限、熔断、不变式)由引擎负责,这里只做必填前置。 */
|
|
61
|
+
export declare function createWriteTools(run: Runner): ToolSpec[];
|
|
60
62
|
export declare function apply(ctx: Context, config?: Config): void;
|
|
61
63
|
export {};
|
package/lib/index.js
CHANGED
|
@@ -138,11 +138,97 @@ export function createReadTools(run) {
|
|
|
138
138
|
export async function archStatus(run) {
|
|
139
139
|
return runCli(run, ['status']);
|
|
140
140
|
}
|
|
141
|
+
function required(args, key, toolName) {
|
|
142
|
+
const value = str(args[key]);
|
|
143
|
+
if (!value) {
|
|
144
|
+
throw new Error(`${toolName} 缺少必填参数 ${key}。`);
|
|
145
|
+
}
|
|
146
|
+
return value;
|
|
147
|
+
}
|
|
148
|
+
function optionalFlag(argv, args, key, flag) {
|
|
149
|
+
const value = str(args[key]);
|
|
150
|
+
if (value) {
|
|
151
|
+
argv.push(flag, value);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/** 写工具集合。写盘前的校验(80 字上限、熔断、不变式)由引擎负责,这里只做必填前置。 */
|
|
155
|
+
export function createWriteTools(run) {
|
|
156
|
+
return [
|
|
157
|
+
{
|
|
158
|
+
name: 'arch_collapse',
|
|
159
|
+
description: '把一个空洞折叠成实现节点。spec 只能是一句话职责(最多 80 字),实现细节与验收标准另有去处。会写盘。',
|
|
160
|
+
parameters: {
|
|
161
|
+
type: 'object',
|
|
162
|
+
additionalProperties: false,
|
|
163
|
+
properties: {
|
|
164
|
+
node: { type: 'string', description: '要折叠的节点 id' },
|
|
165
|
+
label: { type: 'string', description: '节点名,简短可读' },
|
|
166
|
+
spec: { type: 'string', description: '一句话职责,最多 80 字' },
|
|
167
|
+
stage: { type: 'string', description: '所属阶段,可选' },
|
|
168
|
+
role: { type: 'string', description: '角色:entry / exit / hub / spoke,可选' },
|
|
169
|
+
scope: { type: 'string', description: '子系统超级节点 id,可选' },
|
|
170
|
+
},
|
|
171
|
+
required: ['node', 'label', 'spec'],
|
|
172
|
+
},
|
|
173
|
+
output: textOutput,
|
|
174
|
+
execute: async (args) => {
|
|
175
|
+
const argv = [
|
|
176
|
+
'collapse',
|
|
177
|
+
'--node',
|
|
178
|
+
required(args, 'node', 'arch_collapse'),
|
|
179
|
+
'--label',
|
|
180
|
+
required(args, 'label', 'arch_collapse'),
|
|
181
|
+
'--spec',
|
|
182
|
+
required(args, 'spec', 'arch_collapse'),
|
|
183
|
+
];
|
|
184
|
+
optionalFlag(argv, args, 'stage', '--stage');
|
|
185
|
+
optionalFlag(argv, args, 'role', '--role');
|
|
186
|
+
optionalFlag(argv, args, 'scope', '--in');
|
|
187
|
+
return runCli(run, argv);
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
name: 'arch_add_node',
|
|
192
|
+
description: '在流水线上新增一个节点(默认空洞)。spec 只能是一句话职责(最多 80 字)。会写盘。',
|
|
193
|
+
parameters: {
|
|
194
|
+
type: 'object',
|
|
195
|
+
additionalProperties: false,
|
|
196
|
+
properties: {
|
|
197
|
+
node: { type: 'string', description: '新节点 id' },
|
|
198
|
+
label: { type: 'string', description: '节点名,简短可读' },
|
|
199
|
+
spec: { type: 'string', description: '一句话职责,最多 80 字' },
|
|
200
|
+
status: { type: 'string', description: 'hole / solid / fog,默认 hole' },
|
|
201
|
+
after: { type: 'string', description: '插在哪个节点之后,可选' },
|
|
202
|
+
before: { type: 'string', description: '插在哪个节点之前,可选' },
|
|
203
|
+
scope: { type: 'string', description: '子系统超级节点 id,可选' },
|
|
204
|
+
},
|
|
205
|
+
required: ['node', 'label', 'spec'],
|
|
206
|
+
},
|
|
207
|
+
output: textOutput,
|
|
208
|
+
execute: async (args) => {
|
|
209
|
+
const argv = [
|
|
210
|
+
'add-node',
|
|
211
|
+
'--node',
|
|
212
|
+
required(args, 'node', 'arch_add_node'),
|
|
213
|
+
'--label',
|
|
214
|
+
required(args, 'label', 'arch_add_node'),
|
|
215
|
+
'--spec',
|
|
216
|
+
required(args, 'spec', 'arch_add_node'),
|
|
217
|
+
];
|
|
218
|
+
optionalFlag(argv, args, 'status', '--status');
|
|
219
|
+
optionalFlag(argv, args, 'after', '--after');
|
|
220
|
+
optionalFlag(argv, args, 'before', '--before');
|
|
221
|
+
optionalFlag(argv, args, 'scope', '--in');
|
|
222
|
+
return runCli(run, argv);
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
];
|
|
226
|
+
}
|
|
141
227
|
export function apply(ctx, config = {}) {
|
|
142
228
|
const projectDir = resolveProjectDir(config.projectDir);
|
|
143
229
|
const python = config.python?.trim() || 'python';
|
|
144
230
|
const run = makeRunner(projectDir, python);
|
|
145
|
-
for (const tool of createReadTools(run)) {
|
|
231
|
+
for (const tool of [...createReadTools(run), ...createWriteTools(run)]) {
|
|
146
232
|
ctx.effect(() => ctx.tools.register(defineTool(tool)));
|
|
147
233
|
}
|
|
148
234
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-arch-grower",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "在 DeepSeek Harness 里驱动 arch-grower:注册 arch_* 工具,并在右侧栏展示架构图。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./lib/index.d.ts",
|
|
10
|
+
"import": "./lib/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./client": {
|
|
13
|
+
"types": "./lib/client/index.d.ts",
|
|
14
|
+
"import": "./lib/client/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
7
17
|
"files": [
|
|
8
18
|
"lib",
|
|
9
19
|
"cordis.patch.yml",
|
|
@@ -13,6 +23,14 @@
|
|
|
13
23
|
"dsh": {
|
|
14
24
|
"bundle": {
|
|
15
25
|
"patch": "./cordis.patch.yml"
|
|
26
|
+
},
|
|
27
|
+
"client": {
|
|
28
|
+
"platform": "web",
|
|
29
|
+
"inject": [
|
|
30
|
+
"@deepseek-ai/dsh-client-locale",
|
|
31
|
+
"@deepseek-ai/dsh-client-ui-sidebar-right",
|
|
32
|
+
"@deepseek-ai/dsh-client-ui-slots"
|
|
33
|
+
]
|
|
16
34
|
}
|
|
17
35
|
},
|
|
18
36
|
"engines": {
|
|
@@ -20,14 +38,20 @@
|
|
|
20
38
|
},
|
|
21
39
|
"peerDependencies": {
|
|
22
40
|
"@deepseek-ai/cordis": "~4.1.0",
|
|
23
|
-
"@deepseek-ai/dsh-tools": "0.2.2-rc.5"
|
|
41
|
+
"@deepseek-ai/dsh-tools": "0.2.2-rc.5",
|
|
42
|
+
"react": "^18.2.0"
|
|
24
43
|
},
|
|
25
44
|
"devDependencies": {
|
|
26
45
|
"@deepseek-ai/cordis": "~4.1.0",
|
|
46
|
+
"@deepseek-ai/dsh-client-ui-sidebar-right": "0.2.2-rc.5",
|
|
47
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.2.2-rc.5",
|
|
27
48
|
"@deepseek-ai/dsh-tools": "0.2.2-rc.5",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"@types/
|
|
49
|
+
"@types/node": "^22.0.0",
|
|
50
|
+
"@types/react": "^18.3.0",
|
|
51
|
+
"@types/react-dom": "^18.3.0",
|
|
52
|
+
"react": "^18.2.0",
|
|
53
|
+
"react-dom": "^18.2.0",
|
|
54
|
+
"typescript": "^5.6.0"
|
|
31
55
|
},
|
|
32
56
|
"scripts": {
|
|
33
57
|
"build": "tsc -p tsconfig.json",
|