dsh-plugin-diting 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +95 -2
- package/cordis.patch.yml +6 -0
- package/index.js +84 -0
- package/package.json +27 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Diting
|
|
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,96 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-plugin-diting
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Diting 鸿蒙性能分析的 DeepSeek Harness(DSH)一键接入插件。
|
|
4
|
+
|
|
5
|
+
[Diting](https://diting.work) 是端到端的鸿蒙应用性能分析工具:宿主 Agent 负责判断和决策,
|
|
6
|
+
Diting 负责构建、签名、安装、抓取 Trace 与取证,输出每个结论都带可复核证据的 HTML 报告。
|
|
7
|
+
|
|
8
|
+
本插件让你**不碰命令行**完成接入:安装插件即自动执行 Diting 的 DSH 注册。
|
|
9
|
+
|
|
10
|
+
## 安装
|
|
11
|
+
|
|
12
|
+
**方式一:DSH 界面(推荐)**
|
|
13
|
+
|
|
14
|
+
打开「添加插件」对话框,输入包名 `dsh-plugin-diting`,点击安装。
|
|
15
|
+
|
|
16
|
+
**方式二:命令行**
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
dsh plugin add dsh-plugin-diting
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
安装后插件会自动执行 `npx diting-agents@latest setup --client dsh --yes`,
|
|
23
|
+
将 Diting MCP Server 写入 `~/.dsh/cordis.patch.yml` 托管块,并安装场景方法论 skills。
|
|
24
|
+
**重启 DSH(或等待配置热更新)后生效。**
|
|
25
|
+
|
|
26
|
+
## 环境要求
|
|
27
|
+
|
|
28
|
+
- Node.js 18+
|
|
29
|
+
- Python 3.12+(未安装时,若系统有 [uv](https://docs.astral.sh/uv/) 会自动自举 Python 环境)
|
|
30
|
+
- 设备/构建能力另需:鸿蒙设备 + hdc + DevEco Command Line Tools + 签名材料
|
|
31
|
+
|
|
32
|
+
首次使用 Diting 时会创建 Python 环境(约 41 个依赖包),**可能超过 10 分钟**,属正常现象。
|
|
33
|
+
国内网络建议先配置镜像:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm config set registry https://registry.npmmirror.com
|
|
37
|
+
export PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## 配置项(可选)
|
|
41
|
+
|
|
42
|
+
在 `~/.dsh/cordis.patch.yml` 中本插件的条目下覆盖:
|
|
43
|
+
|
|
44
|
+
| 字段 | 类型 | 默认 | 说明 |
|
|
45
|
+
|---|---|---|---|
|
|
46
|
+
| `allowRoot` | string | 不限制 | `open_trace` 可读取的目录(生产环境建议指定) |
|
|
47
|
+
| `enableDevice` | boolean | `false` | 开启设备/构建工具(真实操作设备) |
|
|
48
|
+
| `hdc` | string | — | hdc 路径,`enableDevice: true` 时必填 |
|
|
49
|
+
|
|
50
|
+
示例:
|
|
51
|
+
|
|
52
|
+
```yaml
|
|
53
|
+
- id: diting
|
|
54
|
+
name: dsh-plugin-diting
|
|
55
|
+
allowRoot: ~/traces
|
|
56
|
+
enableDevice: false
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## 使用
|
|
60
|
+
|
|
61
|
+
重启 DSH 后,直接对 Agent 描述问题即可:
|
|
62
|
+
|
|
63
|
+
> 分析这个鸿蒙应用冷启动为什么慢。先构建、签名并安装到设备,
|
|
64
|
+
> 启动应用抓取 HTrace,定位启动关键路径,生成带证据的报告。
|
|
65
|
+
|
|
66
|
+
分析流程:`open_trace → begin_analysis → inspect_* → submit_analysis_result → render_report`,
|
|
67
|
+
产出自包含 `report.html` 与 findings / evidence / unknowns / validation 元数据。
|
|
68
|
+
|
|
69
|
+
## 卸载
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# 1. 移除本插件
|
|
73
|
+
dsh plugin remove dsh-plugin-diting
|
|
74
|
+
|
|
75
|
+
# 2. 移除 Diting 写入的 MCP 托管块(保留其他配置)
|
|
76
|
+
npx diting-agents@latest setup --client dsh --uninstall --yes
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## 故障排查
|
|
80
|
+
|
|
81
|
+
| 问题 | 处理 |
|
|
82
|
+
|---|---|
|
|
83
|
+
| 安装后工具未出现 | 重启 DSH;查看日志确认 `[diting] 注册完成` |
|
|
84
|
+
| 日志显示自动注册失败 | 按日志提示手动执行 `npx diting-agents@latest setup --client dsh --yes` |
|
|
85
|
+
| 缺少 Python | 安装 Python 3.12+,或安装 uv 后重试 |
|
|
86
|
+
| 设备工具不可用 | 确认 `enableDevice: true` 且 `hdc` 路径正确 |
|
|
87
|
+
|
|
88
|
+
## 链接
|
|
89
|
+
|
|
90
|
+
- Diting 官网与文档:https://diting.work
|
|
91
|
+
- Diting 本体(npm):https://www.npmjs.com/package/diting-agents
|
|
92
|
+
- Diting 源码仓库:https://gitcode.com/diting/DitingAgent
|
|
93
|
+
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
MIT
|
package/cordis.patch.yml
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-plugin-diting
|
|
3
|
+
* Diting 鸿蒙性能分析一键接入插件。
|
|
4
|
+
*
|
|
5
|
+
* 职责:插件加载时,幂等地执行 Diting 的 DSH 注册
|
|
6
|
+
* (npx diting-agents@latest setup --client dsh --yes),
|
|
7
|
+
* 将 Diting MCP Server 写入 ~/.dsh/cordis.patch.yml 托管块,
|
|
8
|
+
* 并安装 Diting 自带的场景方法论 skills。
|
|
9
|
+
*
|
|
10
|
+
* 注意:只使用命名导出(name / inject / apply),不要 export default。
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { spawn } from 'node:child_process'
|
|
14
|
+
import fs from 'node:fs'
|
|
15
|
+
import os from 'node:os'
|
|
16
|
+
import path from 'node:path'
|
|
17
|
+
|
|
18
|
+
export const name = 'diting'
|
|
19
|
+
|
|
20
|
+
// 本插件不依赖其他服务;如需声明依赖可写:export const inject = ['xxx']
|
|
21
|
+
|
|
22
|
+
const DSH_PATCH = path.join(os.homedir(), '.dsh', 'cordis.patch.yml')
|
|
23
|
+
|
|
24
|
+
/** 检测 Diting 是否已完成注册(托管块是否存在) */
|
|
25
|
+
function isRegistered() {
|
|
26
|
+
try {
|
|
27
|
+
return fs.readFileSync(DSH_PATCH, 'utf8').includes('diting-agents')
|
|
28
|
+
} catch {
|
|
29
|
+
return false
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** 执行 diting 的 dsh 注册命令,输出收集后整体返回 */
|
|
34
|
+
function runSetup(config, log) {
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
const args = ['diting-agents@latest', 'setup', '--client', 'dsh', '--yes']
|
|
37
|
+
if (config.allowRoot) args.push('--allow-root', String(config.allowRoot))
|
|
38
|
+
if (config.enableDevice) args.push('--device')
|
|
39
|
+
if (config.hdc) args.push('--hdc', String(config.hdc))
|
|
40
|
+
|
|
41
|
+
const npx = process.platform === 'win32' ? 'npx.cmd' : 'npx'
|
|
42
|
+
log.info(`[diting] 执行: ${npx} ${args.join(' ')}`)
|
|
43
|
+
|
|
44
|
+
const child = spawn(npx, args, { stdio: ['ignore', 'pipe', 'pipe'] })
|
|
45
|
+
let out = ''
|
|
46
|
+
child.stdout.on('data', (d) => { out += d })
|
|
47
|
+
child.stderr.on('data', (d) => { out += d })
|
|
48
|
+
child.on('error', (err) => reject(new Error(
|
|
49
|
+
`无法启动 npx(请确认 Node.js 18+ 已安装且在 PATH 中): ${err.message}`)))
|
|
50
|
+
child.on('exit', (code) => {
|
|
51
|
+
if (code === 0) resolve(out)
|
|
52
|
+
else reject(new Error(`setup 退出码 ${code}\n${out}`))
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 插件入口。
|
|
59
|
+
* @param ctx DSH 插件上下文
|
|
60
|
+
* @param config 用户在 cordis.patch.yml 中可覆盖的配置:
|
|
61
|
+
* - allowRoot: open_trace 可读取的目录(可选)
|
|
62
|
+
* - enableDevice: 是否开启设备/构建工具(默认 false,需 hdc)
|
|
63
|
+
* - hdc: hdc 路径(enableDevice 时必填)
|
|
64
|
+
*/
|
|
65
|
+
export function apply(ctx, config = {}) {
|
|
66
|
+
const log = ctx.logger ?? console
|
|
67
|
+
log.info('[diting] 插件已加载')
|
|
68
|
+
|
|
69
|
+
if (isRegistered()) {
|
|
70
|
+
log.info('[diting] 检测到 Diting 已完成注册,跳过 setup(幂等)')
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// 后台执行注册,不阻塞 DSH 启动
|
|
75
|
+
runSetup(config, log)
|
|
76
|
+
.then(() => {
|
|
77
|
+
log.info('[diting] 注册完成。重启 DSH(或等待配置热更新)后,open_trace 等工具即可使用。')
|
|
78
|
+
})
|
|
79
|
+
.catch((err) => {
|
|
80
|
+
log.warn('[diting] 自动注册失败:' + err.message)
|
|
81
|
+
log.warn('[diting] 可手动执行: npx diting-agents@latest setup --client dsh --yes')
|
|
82
|
+
log.warn('[diting] 环境要求:Node.js 18+、Python 3.12+(或安装 uv 自动自举)')
|
|
83
|
+
})
|
|
84
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-diting",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Diting 鸿蒙性能分析一键接入:安装后自动完成 Diting MCP 注册与场景方法论 skills 安装",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"index.js",
|
|
9
|
+
"cordis.patch.yml"
|
|
10
|
+
],
|
|
11
|
+
"dsh": {
|
|
12
|
+
"bundle": {
|
|
13
|
+
"patch": "./cordis.patch.yml"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"dsh-plugin",
|
|
18
|
+
"deepseek-harness",
|
|
19
|
+
"harmonyos",
|
|
20
|
+
"performance",
|
|
21
|
+
"mcp-server",
|
|
22
|
+
"agent-skills"
|
|
23
|
+
],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=22.19.0"
|
|
26
|
+
},
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"homepage": "https://diting.work"
|
|
29
|
+
}
|