mirror of
https://gitcode.com/JianFeeeee/homeagent-sdk.git
synced 2026-09-20 08:58:03 +00:00
插件的真实形态是「独立子进程 + 内核侧握手」,所以插件问题几乎都在 IDE 之外发生:
编不出来(多半是没声明用哪版 SDK,工具链拿了存储里的 current)、编出来起不来
(产物与内核协议绑定)、起来了行为不对(真因只在内核日志里)。这个扩展把这三件事
拉进 IDE。
- `tools/vscode-hmapdev`:TypeScript 扩展(零运行时依赖,仅 devDeps: typescript + @types/vscode)
- **plg.json 诊断**:必需字段;`sdk` 必须是完整版本号(区间写法 `1.2` 报错并说明
「patch 位恒为 .0」,与工具链 ResolveSDKForProject 同一套规矩);声明的 SDK 未安装时
直接给 `hmapdev sdk install vX.Y.Z`;
- **状态栏**:`插件 · SDK <声明> · hmapdev <版本>`,工具链缺失/工程有错时变色,tooltip 列已装 SDK;
- **命令**:build / build --target all / clean / debug(解释执行)/ 工具链版本 / SDK 列表-安装-切换 /
跟随内核日志 / 停止跟随 / 刷新;
- **任务**:同一批动作注册为 `hmapdev` 任务 + Go 问题匹配器(编译错误进 Problems);
- **内核日志跟随**:读 `<dataDir>/log` 最新 `homed_*.log`,按插件名过滤持续输出;
- schema 校验 + plg.json 骨架片段。
- 诚实边界(写进 README):**不是源码级调试器**——没有断点/单步,没有 DAP 会话;
做的是构建、运行、看内核日志、清单校验。
验证:`tsc` 零错误;`node --test` 13/13(版本规则、诊断分级、SDK 列表解析、状态栏文本、
以及**反向核对抓到的真缺陷**:`hmapdev 未找到` 这类输出曾被解析成版本号 → 已要求版本
token 以数字开头,否则「工具链不在」会被显示成「工具链 <垃圾词>」并让 SDK 诊断失真);
与真实工具链输出的集成核对 PASS(`hmapdev version` / `sdk list` 的真输出解析正确)。
README 同时补两节:plg.json 的 `sdk` 字段语义(含「为什么必须有」与「为什么拒区间写法」)、
本扩展的用法与边界。
175 lines
4.4 KiB
JSON
175 lines
4.4 KiB
JSON
{
|
||
"name": "hmapdev-vscode",
|
||
"displayName": "HomeAgent Plugin Dev (hmapdev)",
|
||
"description": "调试与构建 HomeAgent 插件工程:plg.json 校验、SDK 版本解析、hmapdev 构建/运行、内核日志跟随。",
|
||
"version": "0.1.0",
|
||
"publisher": "JianFeeeee",
|
||
"license": "AGPL-3.0-only",
|
||
"private": true,
|
||
"engines": {
|
||
"vscode": "^1.85.0"
|
||
},
|
||
"categories": [
|
||
"Programming Languages",
|
||
"Debuggers",
|
||
"Other"
|
||
],
|
||
"main": "./out/extension.js",
|
||
"activationEvents": [
|
||
"workspaceContains:plg.json",
|
||
"workspaceContains:**/plg.json"
|
||
],
|
||
"contributes": {
|
||
"commands": [
|
||
{
|
||
"command": "hmapdev.build",
|
||
"title": "hmapdev: 构建插件"
|
||
},
|
||
{
|
||
"command": "hmapdev.buildAll",
|
||
"title": "hmapdev: 构建插件(全部目标平台)"
|
||
},
|
||
{
|
||
"command": "hmapdev.clean",
|
||
"title": "hmapdev: 清理产物"
|
||
},
|
||
{
|
||
"command": "hmapdev.run",
|
||
"title": "hmapdev: 运行插件(解释执行,快速迭代)"
|
||
},
|
||
{
|
||
"command": "hmapdev.showVersion",
|
||
"title": "hmapdev: 查看工具链版本"
|
||
},
|
||
{
|
||
"command": "hmapdev.listSdk",
|
||
"title": "hmapdev: 列出 SDK 版本"
|
||
},
|
||
{
|
||
"command": "hmapdev.installSdk",
|
||
"title": "hmapdev: 安装 SDK 版本…"
|
||
},
|
||
{
|
||
"command": "hmapdev.useSdk",
|
||
"title": "hmapdev: 切换当前 SDK 版本…"
|
||
},
|
||
{
|
||
"command": "hmapdev.tailKernelLog",
|
||
"title": "hmapdev: 跟随内核日志(按插件过滤)"
|
||
},
|
||
{
|
||
"command": "hmapdev.stopTailKernelLog",
|
||
"title": "hmapdev: 停止跟随内核日志"
|
||
},
|
||
{
|
||
"command": "hmapdev.openPlgJson",
|
||
"title": "hmapdev: 打开 plg.json"
|
||
},
|
||
{
|
||
"command": "hmapdev.refresh",
|
||
"title": "hmapdev: 刷新状态(重新探测工具链与 SDK)"
|
||
}
|
||
],
|
||
"configuration": {
|
||
"title": "HomeAgent Plugin Dev",
|
||
"properties": {
|
||
"hmapdev.path": {
|
||
"type": "string",
|
||
"default": "hmapdev",
|
||
"description": "hmapdev 可执行文件路径(默认从 PATH 找)。"
|
||
},
|
||
"hmapdev.kernelDataDir": {
|
||
"type": "string",
|
||
"default": "",
|
||
"description": "内核数据目录(homed -data 的那个目录)。填了才能跟随内核日志调试;留空则「跟随内核日志」会先询问。"
|
||
},
|
||
"hmapdev.diagnoseSdk": {
|
||
"type": "boolean",
|
||
"default": true,
|
||
"description": "校验 plg.json 里声明的 SDK 版本是否已安装在本地 SDK 存储(需要能执行 hmapdev)。"
|
||
}
|
||
}
|
||
},
|
||
"taskDefinitions": [
|
||
{
|
||
"type": "hmapdev",
|
||
"required": [
|
||
"action"
|
||
],
|
||
"properties": {
|
||
"action": {
|
||
"type": "string",
|
||
"enum": [
|
||
"build",
|
||
"buildAll",
|
||
"clean",
|
||
"run"
|
||
],
|
||
"description": "要执行的 hmapdev 动作。"
|
||
},
|
||
"cwd": {
|
||
"type": "string",
|
||
"description": "插件工程目录(默认取 plg.json 所在目录)。"
|
||
}
|
||
}
|
||
}
|
||
],
|
||
"problemMatchers": [
|
||
{
|
||
"name": "hmapdev-go",
|
||
"owner": "go",
|
||
"source": "hmapdev",
|
||
"fileLocation": [
|
||
"relative",
|
||
"${workspaceFolder}"
|
||
],
|
||
"pattern": [
|
||
{
|
||
"regexp": "^(.+\\.go):(\\d+):(\\d+):\\s+(.+)$",
|
||
"file": 1,
|
||
"line": 2,
|
||
"column": 3,
|
||
"message": 4
|
||
},
|
||
{
|
||
"regexp": "^(.+\\.go):(\\d+):\\s+(.+)$",
|
||
"file": 1,
|
||
"line": 2,
|
||
"message": 3
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"languages": [
|
||
{
|
||
"id": "json",
|
||
"filenames": [
|
||
"plg.json"
|
||
]
|
||
}
|
||
],
|
||
"jsonValidation": [
|
||
{
|
||
"fileMatch": "plg.json",
|
||
"url": "./schema/plg.schema.json"
|
||
}
|
||
],
|
||
"snippets": [
|
||
{
|
||
"language": "json",
|
||
"path": "./snippets/plg.json.code-snippets"
|
||
}
|
||
]
|
||
},
|
||
"scripts": {
|
||
"compile": "tsc -p ./",
|
||
"watch": "tsc -watch -p ./",
|
||
"test": "tsc -p ./ && node --test out/test/*.test.js"
|
||
},
|
||
"devDependencies": {
|
||
"@types/node": "^22.0.0",
|
||
"@types/vscode": "^1.85.0",
|
||
"typescript": "^5.6.0"
|
||
}
|
||
}
|