功能:恢复变量生命周期工具并补充能力发现指南#11
Merged
allocnode merged 4 commits intoJul 22, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
恢复米家极客版自动化变量在 MCP 模式下的完整生命周期管理能力,并把网关能力发现与变量排障方法固化到
mijia-automationskill,避免把“当前 MCP 没有入口”误判成“网关不支持”。改动
createVardeleteVargetVarValuegetVarConfigmijia_create_variablemijia_delete_variablemijia_get_variable_valuemijia_get_variable_configtype与初始value类型一致。mijia-automationskill:mijia_call_api三层能力。mijia_set_variable和规则变量节点都不会创建不存在的变量。能力发现依据
变量生命周期能力最初按以下路径确认:
createVar、deleteVar、getVarConfig、getVarValue、setVarConfig和setVarValue。setVarValue,因此确认属于封装缺口,而不是网关缺少能力。Invalid id format;改成纯字母数字后创建和删除成功,由此确认真实 ID 约束。验证
本地检查全部通过:
npx tsx src/core/tools/variable.test.tsnpx tsx src/mcp/tools/variable.test.tsnpx tsx src/core/tools/device.test.tsnpx tsx src/core/tools/capabilityValidation.test.tsnpx tsc --noEmitnpm run build:mcppython ~/.agents/skills/skill-creator/scripts/quick_validate.py .agents/skills/mijia-automationgit diff --check真实米家网关生命周期测试:
7的临时数字变量。9,回读确认结果为9。Variable does not exist。极客版页面实测补充
通过 Playwright 在真实极客版页面逐张配置卡片并回读网关 JSON,又发现并修复两处格式偏差:
createVar的显示名称必须传入userData: { name }。此前传顶层name虽能创建变量,但变量配置缺少显示名称,极客版 UI 的变量选择器不会显示它。deviceGetSetVar官方页面只生成outputs.output,没有output2。此前 skill 和校验器错误套用了deviceGet的双输出结构,会拒绝页面生成的合法规则。已增加对应回归测试,并同步更新 skill 与完整参考文档。
代码审查修复
完整审查 PR 全部提交后继续修复:
getVarList返回的对象结构,不再把真实变量列表误转为空数组,并补充变量id与scope。getVarValue的{ value }网关响应解包为标量,避免输出value.value。tests/目录,确保npm run test:unit自动执行。