Repository navigation
0.1.1
首个公开发布。 本版不做新功能,只做两件事:修掉一个静默失效的真 bug,以及把侧边面板按官方主题令牌重做一遍 ——
没有新增工具、没有改任何工具的调用方式、没有改任何已有参数的含义。
新增功能
首次发布,这里是插件现在能给 AI 的全部能力:
- 13 个原生工具:
lanhu_check_auth·lanhu_list_teams·lanhu_list_projects·lanhu_list_designs·lanhu_search·lanhu_read_design·lanhu_read_blocks·lanhu_accounts·lanhu_who·lanhu_download_slices·lanhu_verify_spec·lanhu_verify_blocks·lanhu_cookie_set。 - 侧边面板(三个 Tab:块级 / 账号 / 记录):贴一个链接就出块级清单,不用敲命令。面板与工具走同一条数据通道(Host 的
/lanhu/*路由,仅本机可访问)。 - CLI:同一套能力的命令行入口,
--json可机器读。 - 多账号:一个账号一套 Cookie。蓝湖链接里的
tid就是团队 id,而一个团队只属于一个账号 —— 所以看链接就能零请求判定该用哪个账号(实测 2–45 ms),不用问用户、也不试错。 - 区域抠图 + 坐标映射:
region按区域取值(y0,y1或x0,y0,x1,y1);再配mapBox/toBox把设计稿坐标直接映射到你自己 SVG 的 viewBox —— x/y 各自独立缩放(非等比),长宽比不同也能对上。 - 两种验收:
lanhu_verify_spec用真实浏览器取getComputedStyle逐字段比对色值 / 字号 / 字重 / 字体族 / 圆角;lanhu_verify_blocks出四态报告(✅ 完全匹配 / 🟡 容差内 / ❌ 不匹配 / ⚪ 无法比对)并给可直接抄的改法。 - 切图导出带 alpha 报告:每张图给
尺寸 / mode / alpha 范围,半透明当场告警(避免整屏发灰)。 - 英文入口 + 双语发布说明:README 顶部是
[中文](#…) | [English](#english-overview)语言锚点,并新增一屏## English overview(一句话是什么 / 30 秒上手表 / 13 个工具各一行 / 安装三要点 / 四条铁律)。英文只做导航:完整参数仍指向下面那份生成的清单,中英两侧不会各维护一份会漂移的副本。 - 「工具速查」改为从代码生成:
tools/gen-readme-tools.mjs从lib/index.js的TOOLS生成 8093 字符(13 个工具的完整说明 + 每个参数的类型 / 必填 / 取值,即 AI 在 schema 里看到的那份),并由test/readme-test.mjs逐字比对 —— 主文档不会再落后。
体验优化
面板按官方主题令牌重做了一遍。八条里三条属于"静默失效"型 —— 不报错,只是看起来怪:
- 深色主题下主按钮看不见:主按钮拿
--dsw-alias-brand-primary当品牌色做底、又写死白字。该令牌浅色下是近黑#0f1115、深色下是近白#f9fafb—— 白底白字,实测对比度 1.05:1。改用官方配对的--dsw-alias-label-primary-foreground后:浅色 18.9:1 / 深色 18.1:1。 - 三个令牌名根本不存在,一直静默走 fallback:
bg-sunken(真名bg-layer-1)、brand-bg(无此令牌)、state-warning-primary(少个ing,真名state-warn-primary)。 - 深色下面板是"中灰板":
surface用了bg-overlay,该令牌深色 =#61666b,比应用底色#151517亮 17 倍。改用官方菜单别名--dsw-specific-menu(=bg-layer-3)→ 深色#353638、浅色#ffffff。 - 浮层补上对话框语义:
role="dialog"+aria-modal+aria-label,Esc 可关,打开移焦、关闭还焦。 - 关闭按钮命中区 14×16px → 26×26px(WCAG 2.5.8 要求 ≥24×24)。
- URL 输入框不再切断链接:加
break-all+ 按内容自动增高(封顶 132px 再转滚动)。 - 双层滚动条 → 单层:面板内容区与块级列表各自滚动(实测两个滚动容器);现在内层不滚,只留一层。
- 文档改成「渐进式披露」:README 只留入口(人写部分从 10059 字符降到 8924,−11%),细节下沉成 4 篇按需加载的
docs/(读稿 / 验收 / 面板与账号 / CLI 与开发,合计 7128 字符),README 给一张「你手上在做的事 → 读哪个文件」的索引。生成块本身 8093 字符不算新增信息 —— 它就是 AI 在工具 schema 里本来就能看到的那份,只是给人类读者一份不会过时的投影。 - 危险操作:删除账号改两段式确认(首次点击只变红,实测不发写请求);「更新 Cookie」会清空上一次的 Cookie 草稿 —— 以前只预填别名,最容易让人以为串也是对的。
问题修复
lanhu_read_design有三个参数是「声明了但收不到」:limit/mapBox/toBox写在工具 schema 里,但execute从来没往readDesign传。后果全是静默的 —— 传mapBox+toBox拿到未映射的表且不报错;传limit: 900仍只回 80 层(大稿子只看得到前 80 层)。CLI 一直是对的,只有插件工具这条链断了,所以这个 bug 藏了很久:用 CLI 验证的人永远撞不到它。已补齐,并复验:limit: 3只回 3 行、mapBox+toBox真的产出「映射 x,y / 映射 w×h」列与sx/sy说明、只给一个参照框时明确报错而不是静默不映射。
其他变更
- 仓库自带自检 257 项全绿(
node test/selfcheck.mjs,纯离线、秒级;每个能力都配了正反例)。 - 新增文档绊线
test/readme-test.mjs24 项:生成块是否与TOOLS逐字一致 /docs/链接是否存在且无孤立文件 / 版本号五处是否一致 / 发布说明格式与公开纪律(不含本机绝对路径)。版本一致性以前是纯靠人核的,现在漏改一处就红。 - 插件契约自检 16 项全绿(工具形状 / 路由信封 / lossless JSON / 本机访问守卫 / 槽位注册与回收)。
- 不变的两条老规矩:Host 半边是启动快照(改
lib/index.js或lanhu.mjs要重启dsh web;只改lib/client.js刷新页面即可);面板没有的功能不代表工具没有 —— 工具 schema 才是唯一真身。 - 面板改动的验证方式说明白:用真 React + 官方
dsh-client-ui-theme的 163 个真实令牌(浅 / 深两套)离屏渲染逐项测量,面板契约由桩自检覆盖;并在真实 GUI 里点过一次 —— 重启dsh web后打开面板点「读取块级清单」,/lanhu/log记到一条新的panel:preview(ok=true),证明新客户端半边确实生效。dsh web的会话 token 只在进程内、不落盘,自动化进不去真实 GUI,所以这一步只能由人做。 - 已知空缺(不藏):
test/selfcheck.mjs的DESC_MUST只断言「工具描述里提到了某个能力」,不断言「声明的参数真的传给了实现」 —— 本版修的那个 bug 就是从这里活下来的;补这条守卫需要解析源码或给实现注入桩,不是几行能写完的。面板里还有一条死路由/lanhu/verify-blocks—— 后端与recordUsage都写好了,注释写着「面板『块级』Tab 的『与页面比对』按钮用」,但那个按钮从来没做;/lanhu/who同样没有前端入口。
Full Changelog: 首次发布,全部提交
This is the first public release. It adds no new features: it fixes one silently failing bug and rebuilds the sidebar panel against the official theme tokens — no new tools, no change to how any tool is called, no change to the meaning of any existing argument.
New Features
First release — here is everything the plugin gives an AI today:
- 13 native tools:
lanhu_check_auth·lanhu_list_teams·lanhu_list_projects·lanhu_list_designs·lanhu_search·lanhu_read_design·lanhu_read_blocks·lanhu_accounts·lanhu_who·lanhu_download_slices·lanhu_verify_spec·lanhu_verify_blocks·lanhu_cookie_set. - A sidebar panel (three tabs: blocks / accounts / log): paste a link and get the block-level list — no commands. The panel and the tools share one data channel (the Host's
/lanhu/*routes, loopback-only). - A CLI: the same capabilities from the shell, with
--jsonfor machine-readable output. - Multiple accounts: one cookie per account. The
tidin a Lanhu link is the team id, and a team belongs to exactly one account — so the link alone identifies which account to use with zero requests (measured 2–45 ms). No asking the user, no trial and error. - Region extraction + coordinate mapping:
regionselects an area (y0,y1orx0,y0,x1,y1); addmapBox/toBoxto map design coordinates straight into your own SVG's viewBox — x and y are scaled independently (non-uniform), so differing aspect ratios still line up. - Two kinds of verification:
lanhu_verify_specdrives a real browser, readsgetComputedStyleand compares colour / font size / weight / family / radius field by field;lanhu_verify_blocksproduces a four-state report (✅ exact / 🟡 within tolerance / ❌ mismatch / ⚪ not comparable) with fixes you can copy verbatim. - Slice export with an alpha report: every image reports
size / mode / alpha range, and semi-transparency is flagged on the spot (so a whole screen doesn't come out washed out). - An English entry point and bilingual release notes: the README opens with a
[中文](#…) | [English](#english-overview)anchor line and gains a one-screen## English overview(one sentence, a