From 5f66d716d9d0822ed9f59651e18d82b75bfbec66 Mon Sep 17 00:00:00 2001 From: spudding <1115683088@qq.com> Date: Fri, 6 Nov 2026 15:49:39 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=9C=AC=E5=9C=B0=E6=8A=80=E8=83=BD?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E8=BF=81=E7=A7=BB=E5=88=B0=20.skills=20?= =?UTF-8?q?=E5=B9=B6=E5=8A=A0=E5=85=A5=E5=BF=BD=E7=95=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 技能从 .codebuddy/skills、.trae/skills 统一迁到仓库根 .skills/(本地使用,不入库:其中含 SSH/管理员明文凭据) - .gitignore 用 .skills/ 替换原 .trae/ 规则 - AGENTS.md 技能路径引用同步为 .skills/... --- .codebuddy/skills/37du-Desktop-Auto/SKILL.md | 131 ------------ .../references/api-reference.md | 188 ------------------ .gitignore | 8 +- AGENTS.md | 4 +- 4 files changed, 6 insertions(+), 325 deletions(-) delete mode 100644 .codebuddy/skills/37du-Desktop-Auto/SKILL.md delete mode 100644 .codebuddy/skills/37du-Desktop-Auto/references/api-reference.md diff --git a/.codebuddy/skills/37du-Desktop-Auto/SKILL.md b/.codebuddy/skills/37du-Desktop-Auto/SKILL.md deleted file mode 100644 index 881ed99..0000000 --- a/.codebuddy/skills/37du-Desktop-Auto/SKILL.md +++ /dev/null @@ -1,131 +0,0 @@ ---- -name: 37du-Desktop-Auto -description: > - 37duAutomation 桌面自动化库 desktopauto(仓库 libs/desktopauto)使用总纲:获取窗口对象、 - 激活/关闭窗口、识图点击、图像存在判断、等待图像、模板匹配(多尺度/多目标)、OCR 通用文字识别 - 与文字坐标、键盘输入(中文走剪贴板粘贴)、组合键、滚轮拖拽、找色、界面差异比对、 - 启动或打开程序、终止进程、离线标记调试。 - 当任务涉及「目标程序拿不到元素树(无 DOM / 无 UIA)只能用屏幕坐标操作」、需要识图/找图/ - 点击图像、按文字定位点击、在 Windows 桌面上自动化某个客户端(钉钉、WPS、Qt 程序、老系统)时, - 加载本技能掌握正确调用顺序与坑位,再动手写代码。 - 触发关键词:桌面自动化、识图、找图、模板匹配、点击图像、图像存在、等待图像、鼠标悬停、 - OCR、文字识别、文字坐标、找色、界面差异、窗口对象、获取窗口、激活窗口、关闭窗口、 - 启动程序、终止程序、键鼠操作、desktopauto、RPA、拿不到元素树。 ---- - -# 桌面自动化库 desktopauto 使用总纲 - -> 适用对象:**没有元素树**的桌面程序(钉钉客户端、Qt/Electron 自定义渲染、远程桌面里的老系统)。 -> 有接口走接口、有 DOM/UIA 走元素定位,两者都拿不到才用本库。 - -## 0. 位置、依赖、自测 - -| 项 | 值 | -|---|---| -| 库源码 | `libs/desktopauto/`(包名 `desktopauto`) | -| 依赖 | `opencv-python` `numpy` `pillow`;OCR 另需 `rapidocr` `onnxruntime`(模型随包、离线) | -| 安装(开发机) | `.venv\Scripts\python.exe -m pip install -e libs\desktopauto --no-deps` | -| 未安装时 | `sys.path.insert(0, r"d:\work\code\37duAutomation\libs\desktopauto")` 也能直接 import | -| 自测 | `.venv\Scripts\python.exe libs\desktopauto\_selftest.py`(60 项,含真实窗口/进程查询) | -| 完整 API | `references/api-reference.md`(按模块列函数签名,改动后同步) | - -## 1. 通道决策顺序(先想清楚,别一上来就 OCR) - -1. **有 HTTP 接口** → 走接口(如 HR/OA 的业务接口),最快最稳。 -2. **有 DOM/UIA** → 走元素定位(浏览器 DrissionPage、Win32 控件的 `uiautomation`)。 -3. **都没有** → 本库,按元素特征选手段: - - 按钮/图标/固定图形 → **模板匹配**(`find` / `click`); - - 只有文字(列表项、菜单项、动态文案)→ **OCR**(`find_text` / `click_text`); - - 只关心有无/颜色/变化 → **找色 / 界面差异**(`find_color` / `diff`); - - 组合兜底:`find(模板)` 失败再 `find_text(文字)`,用 `wait_any` 一次等两种。 - -## 2. 标准作业流程(照这个顺序写) - -```python -from desktopauto import get_window, paste, hotkey, wait_any - -w = get_window(process="DingTalk.exe", timeout=20) # ① 拿窗口对象(找不到直接抛错) -w.activate() # ② 激活到前台(点击前必须) -s = w.screen(threshold=0.9, debug_dir="debug") # ③ 绑定 Screen:后续截图/匹配都限定在窗口内 - -s.click("img/chat_input.png") # ④ 识图点击(找到才点,返回 bool) -paste("排班识别,水庄大鹅……") # ⑤ 中文输入走剪贴板 -hotkey("ctrl", "enter") # ⑥ 组合键 -r = wait_any(texts=["发送成功", "发送失败"], timeout=20) # ⑦ 等校验锚点 -print(r["kind"], r["target"], r["match"].center) -``` - -关键点: - -- **每次操作前重新定位**,绝不缓存坐标跨步骤使用(窗口一移动全废); -- `Screen(window=...)` / `w.screen()` 限定范围,既快又不会误命中全屏同款元素; -- 关键步骤都要有**可断言的锚点**(`wait_text` / `wait_image` / `diff`),否则失败无法定位。 - -## 3. 常用调用速查 - -| 需求 | 调用 | -|---|---| -| 图像是否存在 | `image_exists(tpl)` / `s.exists(tpl)` | -| 等图像出现 / 消失 | `wait_image(tpl, timeout=10)` / `wait_gone(tpl, timeout=10)` | -| 等任一(图或文字) | `wait_any(templates=[a, b], texts=["成功"], timeout=30)` | -| 点击图像 / 悬停图像 | `click_image(tpl)` / `hover_image(tpl)` | -| 多状态按钮(可用/禁用/角标) | `find_any([tpl1, tpl2])` → `(Match, 模板名)` | -| 文字定位(含坐标) | `read_text()` → `[TextItem(text, center, score)]` | -| 只要文字(喂 LLM) | `ocr_text()` | -| 按文字判断/点击/悬停 | `text_exists("导出")` / `click_text("导出")` / `hover_text("导出")` | -| 输入中文 | `paste(text)`(写剪贴板 + Ctrl+V) | -| 按键 / 组合键 | `press("enter")` / `hotkey("ctrl", "s")` | -| 按键串(影刀写法) | `send_keys("^a{ENTER}")` / `send_keys("%{F4}")` | -| 移动鼠标 | `move_mouse(x, y, relative_to="window", speed="instant")` | -| 等待(可随机) | `sleep(1.5)` / `sleep(random_range=(1, 3))` | -| 文件 / 文件夹 | `fs.exists / write_text / read_text / copy / move / list_files / newest_file / wait_file` | -| 等所有图出现 | `wait_all([a, b], timeout=20)` | -| 滚轮 / 拖拽 | `scroll(-5, at=tpl)` / `drag(tpl, (x, y))` | -| 找色(状态点/高亮行) | `find_color("#FF3B30", tolerance=15, min_area=8)` | -| 界面是否变化 | `diff("before.png")["changed_ratio"]` | -| 启动 / 打开 | `run_or_open(r"...\DingTalk.exe")`、`open_path(xlsx)`、`open_url(url)` | -| 等待进程 | `wait_process("DingTalk", timeout=30)`、`until="exit"` 等退出 | -| 关闭 / 终止 | `w.close()` + `w.wait_closed()`;`kill_process("DingTalk")` 强杀 | -| 离线验证(不动鼠标) | `mark(image, [tpl1, tpl2], out_path)` → 标注图 | -| 命令行验证 | `python -m desktopauto --mode ocr -i 1.png --text "导出"` 等 | - -## 4. 模板图怎么准备(决定成败) - -1. 先截一张:`python -m desktopauto --mode shot --path shot.png --window "钉钉"`; -2. 裁**目标区域本身**(带完整边框/图标),不要带会变的内容(时间、数字、用户名、红点); -3. 模板必须有可辨识特征:纯色/近似纯色会被自动降级为像素匹配,容易在别处命中; -4. 跨缩放机器复用同一模板时传 `scales=(0.9, 1.0, 1.1)`,或按机器各截一份; -5. 命中不稳定先看 `debug_dir` 里的 `hit_*.png` / `miss_*.png`(带框和分数),别盲调阈值。 - -## 5. 坑位清单(踩过才知道的) - -| 现象 | 处理 | -|---|---| -| 图在屏幕上但点偏 | 进程 DPI 未感知;库首次调用已 `SetProcessDpiAwareness(2)`,混用别的库时需重启进程 | -| 截出来全黑 | 锁屏 / 远程桌面断开 / 非交互会话;执行机必须保持已登录且解锁 | -| 窗口被挡还能找到吗 | 不能——截的是屏幕实际内容;点击前先 `w.activate()` | -| 输入没反应 | 目标以管理员运行、本进程不是(UIPI 拦截);或焦点不在目标上 | -| 粘贴出旧内容 | `paste(delay=0.15)` 加延迟,或 `restore=False` | -| 后台/最小化窗口 | 只能截图不能点击;`find_windows` 默认排除最小化窗口 | -| OCR 太慢 | 全屏 2~4s;**必须限定 `window`/`region`**,且一屏多词时先 `read_text()` 再本地过滤 | -| 多显示器 | 坐标是虚拟屏幕坐标(可能为负),全屏截图包含所有屏 | - -## 6. 与插件/脚本集成 - -- **插件里用**:执行机环境包预装(`python-env\<版本>\python.exe -m pip install \libs\desktopauto`), - 插件 `requirements.txt` 声明 `desktopauto`;如需插件包完全自包含,把 `desktopauto/` 目录复制进插件包内相对导入。 -- **影刀工作流里用**:`sys.path.insert` 挂到 `libs\desktopauto` 后直接 import(不要复制进单文件)。 -- 改动库后**必须**跑 `_selftest.py`,并把 `references/api-reference.md` 同步更新。 - -### 从影刀工程迁移 - -拿到影刀工程导出目录(含 `imagesV2.xml` + `resources\images\*.png` + `process*.py`): - -1. 跑 `libs/desktopauto/scripts/import_yingdao_images.py`(改脚本顶部 `SRC_PROJECT` / `OUTPUT_ROOT` 两个常量), - 把模板按中文名导出到 `%LOCALAPPDATA%\37duAutomation\desktopauto_templates\<工程名>\`, - 同时生成 `manifest.json`(记录 `threshold`(similarity/100)、`gray`(graying)、`scales`(adaptive 时 0.9/1.0/1.1))。 -2. 阅读 `process*.py` 就能拿到真实用到的指令与参数,按 `README.md` 的「影刀 → 本库」对照表改写: - `image.click` → `click(tpl, timeout=, delay_after=, anchor=)`、`image.wait` → `wait/wait_gone/wait_all`、 - `win32.send_keys` → `send_keys`、`win32.move_mouse` → `move_mouse`、`programing.sleep` → `sleep`、 - `file.if_exist`/`dir.makedir` → `fs.exists`/`fs.make_dir`。 -3. `process.run` / `process.invoke_module`(调流程或工程内 Python 模块)不迁,直接改成普通函数调用。 diff --git a/.codebuddy/skills/37du-Desktop-Auto/references/api-reference.md b/.codebuddy/skills/37du-Desktop-Auto/references/api-reference.md deleted file mode 100644 index 21d19ff..0000000 --- a/.codebuddy/skills/37du-Desktop-Auto/references/api-reference.md +++ /dev/null @@ -1,188 +0,0 @@ -# desktopauto API 速查(按模块) - -> 包位置:`libs/desktopauto/desktopauto/`。所有坐标均为**屏幕物理像素**(DPI 已感知)。 -> 约定:模板/文字「没找到」返回 `None`/`False`;配置错误(模板不存在、窗口找不到、依赖缺失)抛 `RuntimeError`。 - -## 门面:`Screen` - -```python -Screen(window=None, region=None, threshold=0.85, scales=(1.0,), - gray=True, debug_dir="", activate_before_click=True) -``` - -| 分组 | 方法 | -|---|---| -| 截图 | `grab()` → `(img, region)`;`screenshot(path="", region=None, window=None)` → 路径 | -| 窗口 | `activate()`(设了 window 才动作);`clone(**kw)` 派生新配置 | -| 识图 | `find(tpl, **kw)` → `Match|None`;`find_all(tpl, **kw)` → `[Match]`;`exists(tpl)`;`find_any([tpl...])` → `(Match, 模板名)`;`wait(tpl, timeout=10, interval=0.5)` | -| 等待 | `wait_gone(tpl, timeout=10)` → bool;`wait_any(templates=(), texts=(), timeout=10, interval=0.5)` → `{kind,target,match}|None` | -| 点击 | `click(tpl, button="left", clicks=1, offset=(0,0), timeout=0, delay_after=0, anchor="center")` → bool;`click_at(x, y, ...)`;`hover(tpl, offset=(0,0))` → bool;`hover_text(text, offset=(0,0))` → bool | -| 按键串 | `send_keys("^a{ENTER}")`;`move_mouse(x, y, relative_to="screen"|"window", speed=)` | -| 文字 | `read_text(min_score=0.0)` → `[TextItem]`;`find_text(text, **kw)`;`find_all_text(text, **kw)`;`text_exists(text)`;`wait_text(text, timeout=10, interval=1.0)`;`click_text(text, ...)`;`ocr_text(sep="\n")` → str | -| 颜色 | `find_color(color, tolerance=12, min_area=4, max_results=0)` → `[ColorMatch]`;`color_exists(color)`;`diff(baseline, tolerance=10, min_area=30)` → dict | -| 输入 | `paste(text, restore=True)`;`type_text(text, method="auto", interval=0.01)`;`press(key, times=1)`;`hotkey(*keys)` | -| 鼠标 | `scroll(notches=3, at=模板或坐标, horizontal=False)`;`drag(src, dst, duration=0.5)`(src/dst 可传模板或坐标) | - -`find/find_all/exists/wait/click/...` 都支持单次覆盖:`threshold`、`scales`、`gray`、`window`、`region`、`max_results`。 - -## 模块级函数(等价于默认全屏 `Screen()`) - -```python -from desktopauto import (find, find_all, find_any, exists, wait, wait_gone, wait_any, - click, click_at, hover, hover_text, - read_text, find_text, find_all_text, text_exists, wait_text, - click_text, ocr_text, ocr_available, - paste, type_text, press, hotkey, scroll, drag, - find_color, color_exists, diff, diff_ratio, - image_exists, wait_image, click_image, hover_image, - ocr_text_with_position, wait_text_exists) -``` - -RPA 指令别名:`image_exists`=exists、`wait_image`=wait、`click_image`=click、`hover_image`=hover、`ocr_text_with_position`=read_text、`wait_text_exists`=wait_text。 - -## `matcher`(模板匹配) - -```python -Match(left, top, width, height, score) # .center / .region / .to_dict() -load_template(template) # 路径或 ndarray → BGR(透明 PNG 白底合成,兼容中文路径) -match_in(image, template, threshold=0.85, scales=(1.0,), gray=True, max_results=0, origin=(0,0)) -match_any_in(image, templates, ...) # → (Match|None, 模板下标) -annotate(image, matches, origin=(0,0), color=(0,200,0)) # 画框(调试) -best(matches) # 相似度最高的一条 -``` - -低纹理模板(灰度标准差 < 6)自动改用平方差匹配,避免纯色块误命中。 - -## `ocr`(文字识别) - -```python -TextItem(text, left, top, width, height, score) # .center / .region / .to_dict() -recognize(image, min_score=0.0, sort=True) # → [TextItem],按阅读顺序 -offset(items, origin) # 图内坐标 → 屏幕坐标 -match_text(items, query, exact=False, regex=False, case_sensitive=False) -best_text(items) # 置信度最高(同分取面积大) -mark_text(image, items, out_path="", only=None, box_color=..., text_color=...) # 中文标签标注图 -summarize(items, limit=0) -available() # rapidocr 是否可用 -``` - -匹配默认:包含 + 忽略大小写 + 忽略空白(OCR 常在字间插空格)。 - -## `window` / `Window` - -```python -get_window(title="", exact=False, pid=0, process="", class_name="", index=0, timeout=0.0) -> Window -foreground_window() -> Window|None -find_windows(title="", exact=False, pid=0, process="", class_name="", - visible_only=True, include_minimized=False) -> [dict] -wait_window(title="", timeout=10, interval=0.3, **kw) -> dict|None -list_windows(keyword="", visible_only=True) -> [(hwnd, title)] -find_window(keyword) -> hwnd -window_info(hwnd) -> dict -child_windows(window) -> [dict] -window_rect(window) -> (left, top, right, bottom) # DWM 扩展边框 -activate_window(window|Window) -> hwnd -close_window(window|Window, wait=0.5) # 发 WM_CLOSE -``` - -`Window`:属性 `hwnd/title/class_name/pid/process/rect/left/top/width/height/center/minimized/visible`; -方法 `info()/exists()/activate()/is_foreground()/minimize()/maximize()/restore()/move(x,y,w,h)/ -close(wait)/kill(wait)/wait_closed(timeout)/wait_ready(timeout)/children()/screenshot(path)/ -screen(**kw)/to_dict()`。 - -## `capture` - -```python -grab(region=None, window=None) -> (img, region) -save_image(img, path) -> 路径 # 兼容中文路径 -screenshot(path="", region=None, window=None) -> 路径 -resolve_region(region=None, window=None) -> tuple|None -``` - -## `colors`(找色 / 差异) - -```python -ColorMatch(left, top, width, height, area, color) # .center / .to_dict() -parse_color("#FF3B30" | (255,59,48) | "255,59,48") -> (r, g, b) -find_color(color, tolerance=12, region=None, window=None, min_area=4, max_results=0) -find_colors([c1, c2], ...) -> {颜色: [ColorMatch]} # 一次截图找多色 -find_color_in(image, color, tolerance=12, min_area=4, max_results=0, origin=(0,0)) -diff(a, b=None, tolerance=10, min_area=30, region=None, window=None) - # → {"changed", "changed_ratio", "boxes", "image"};b=None 时现场截图对比 -diff_ratio(a, b=None, tolerance=10, ...) -> float -``` - -## `keys` / `clipboard` - -```python -type_text(text, method="auto", interval=0.01, restore_clipboard=True) # auto:含非 ASCII 走剪贴板 -write(text, method="auto") # type_text 别名 -press(key, times=1, interval=0.05) # enter/tab/esc/f1-f12/a/1/pageup... -key_down(key) / key_up(key) -hotkey(*keys, interval=0.02) # hotkey("ctrl", "s") -to_vk(key) -> int # 键名 → 虚拟键码(符号键不支持,用 type_text) - -send_keys(keys_text, interval=0.02, delay_after=0.0) # 影刀写法:{ENTER} / ^a / %{F4} / abc{ENTER} -parse_send_keys(keys_text) -> [("text","abc"), ("key","ENTER"), ("combo",["ctrl","a"])] - -clipboard.set_text(text) / clipboard.get_text() -> str -clipboard.paste(text, restore=True, delay=0.05) -> 被恢复的原文本 -``` - -## `fs`(文件与文件夹) - -```python -exists(path) / file_exists(path) / dir_exists(path) -> bool -ensure_dir(path) -> str -make_dir(parent, name="") -> str # 影刀「创建文件夹」 -read_text(path, encoding=None) -> str # 编码自动回退 utf-8-sig → gbk -write_text(path, text, encoding="utf-8", append=False) -> str -append_line(path, text) -> str -copy(src, dst, overwrite=True) -> str # dst 是目录时自动拼文件名 -move(src, dst, overwrite=True) -> str -delete(path, missing_ok=True) -> bool -list_files(folder, pattern="*", recursive=False, ext=None) -> [str] -newest_file(folder, pattern="*", recursive=False) -> str|None -wait_file(path, timeout=30, interval=0.5, min_size=1) -> bool -wait_file_gone(path, timeout=30, interval=0.5) -> bool -``` - -## 其他 - -```python -sleep(seconds=1.0, random_range=None) -> 实际秒数 # 影刀「等待」(可随机) -move_mouse(x, y, relative_to="screen", speed="instant", window=None) # 影刀「移动鼠标」 -``` - -## `process`(运行或打开 / 终止) - -```python -run_or_open(target, args=(), wait=0.0) # exe/bat/cmd → Popen;文档/文件夹/网址 → 默认程序打开 -launch(target, args=(), cwd=None, wait=0.0) -> Popen -open_path(path) / open_url(url) # 系统默认程序打开 -list_processes(name="", with_path=False) -> [{"pid","name","path"}] -is_running(name) -> bool -wait_process(name, timeout=30, interval=0.5, until="start"|"exit") -> bool -kill_process(pid | 进程名 | Window, wait=0.5) -> [pid] # 同名全部终止;找不到抛错 -``` - -## `marking`(离线标记,不动鼠标) - -```python -mark(image, templates, out_path="", threshold=0.85, scales=(1.0,), gray=True, - draw_click_point=True) -> {"out","image","size","items","total"} -summarize(result) -> str -``` - -## CLI - -```powershell -python -m desktopauto --mode shot --path shot.png --window "钉钉" -python -m desktopauto --mode exists -t img/btn.png -python -m desktopauto --mode click -t img/btn.png --window "钉钉" --debug-dir debug -python -m desktopauto --mode mark -i shot.png -t "img/a.png,img/b.png" -o marked.png -python -m desktopauto --mode ocr -i shot.png --text "导出,提交" -o hit.png -python -m desktopauto --mode ocr --window "钉钉" --text "工作台" # 实时截屏 -``` - -退出码:0=命中/成功,1=未命中,2=参数或运行错误。输出为 JSON。 diff --git a/.gitignore b/.gitignore index 84191ce..b1e9253 100644 --- a/.gitignore +++ b/.gitignore @@ -63,8 +63,8 @@ desktop/**/_cp_sessions.json .vscode/ *.swp *.swo -# Trae IDE 本地配置/技能(不入库) -.trae/ +# 本地技能目录(含明文凭据,不入库) +.skills/ # 工具 ACL 恢复备份产物 .dsh-acl-recovery/ @@ -92,6 +92,6 @@ vc_redist_x64/ vc_redist_x86/ 静态资源/ -.assets/ -# lotsmall 联调账号配置(含明文密码,勿入库) +.assets/ +# lotsmall 联调账号配置(含明文密码,勿入库) tests/lotsmall_probe/account.json diff --git a/AGENTS.md b/AGENTS.md index 3a0afd0..4b7762c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -18,7 +18,7 @@ AI 智能体开发约束 & 项目执行规范 - 插件 plugins/:根级独立目录(按号段分桶 plugins/XQ0001-0100/),被执行机(electron-shell 壳)按账号权限自下载加载,不随底座发布;打包产物落 dist-plugin/_v<版本>.zip(本地生成,.gitignore 不入库)。 - 影刀版 workflows/:单文件自包含,需求脚本按号段分桶(workflows/XQ0001-0100/)。 - app/ 蓝图版:已弃用并已从仓库移除,仅在历史文档中提及。 - - 公共库 libs/:跨方向共享的独立 Python 工具库——`libs/desktopauto/`(桌面自动化:识图点击/图像存在判断/OCR 文字坐标/键鼠/窗口对象/进程启停)、`libs/aitable/`(钉钉 AI 表格读写 + 月报/周报采集)。按正常库开发(包 + pyproject.toml + `_selftest.py`),可 `pip install -e` 或用 `sys.path` 引用;插件使用它属于「执行机预装依赖」或「vendored 复制进插件包」,不算违反插件自包含,禁止的是 import 业务代码(根目录/desktop/其它插件)。用法与坑位见技能 `.trae/skills/37du-Desktop-Auto/SKILL.md`。 + - 公共库 libs/:跨方向共享的独立 Python 工具库——`libs/desktopauto/`(桌面自动化:识图点击/图像存在判断/OCR 文字坐标/键鼠/窗口对象/进程启停)、`libs/aitable/`(钉钉 AI 表格读写 + 月报/周报采集)。按正常库开发(包 + pyproject.toml + `_selftest.py`),可 `pip install -e` 或用 `sys.path` 引用;插件使用它属于「执行机预装依赖」或「vendored 复制进插件包」,不算违反插件自包含,禁止的是 import 业务代码(根目录/desktop/其它插件)。用法与坑位见技能 `.skills/37du-Desktop-Auto/SKILL.md`。 - 代码形态分三类,按各方向性质采用不同组织方式(【单文件自包含】仅适用于影刀版,其它一律按正常项目开发): - workflows/(影刀版):沿用单文件自包含架构(见第 2 节,仅影刀适用)。 - 桌面端各后端(controlplane-next 中心机、electron-shell 执行机壳、fileserver 文件服务器):按正常模块化项目开发,允许按包/模块/多文件拆分,不做单文件约束(electron-shell 主进程为 CommonJS 模块,fileserver 为 Python 包)。 @@ -43,4 +43,4 @@ AI 智能体开发约束 & 项目执行规范 - 发版统一走 agent CLI(仓库根 `tools\agent_cli.py`,任意 cwd 均可:`.venv\Scripts\python.exe tools/agent_cli.py ...`)。插件用 publish / grant / revoke;壳子用 file push --category shell,环境包用 file push --category python-env;中心机为内网 `172.30.30.243`(controlplane-next / Midway,systemd `37du-controlplane-next.service`),改代码后按 `37du-Center-Deploy` 技能或 docs/部署/服务端前后端部署SOP.md 部署。⚠️ `desktop/controlplane/`(FastAPI 旧中心机)已于 2026-11 从仓库移除,**不要再去该目录找代码或配置**;旧命令 `python -m controlplane.tools.agent_cli` 早已移除,一律用 `tools/agent_cli.py`。CLI 配置只读 `controlplane-next/server/.env` 与 `fileserver/.env`。 - **插件发布必须走「测试通道 → 人工验证 → 转正」**(2026-10-31 起):`publish` 默认进测试通道(`plugins.status=testing` + `plugins.test_version`),**只有管理员账号**能同步到在测版本,其他账号继续用 `latest_version`;人工验证通过后由**人**执行 `plugin-status --status published` 转正(服务端把 test_version 提升为 latest_version,复用同一版本号、不重新打包),全量已授权账号下次同步生效。⚠️ **agent 不得自行执行转正**,也不得默认使用 `publish --prod` 直发正式(仅紧急热修且经人确认时使用)。测试版本号必须高于当前正式版(执行机只升不降)。 - 鉴权:密码登录 `--admin puddy --password 123456`,**一律显式加 `--base http://172.30.30.243:8800`(内网生产控制面,执行机实际连接源)**,或中心机本机密钥自签。⚠️ 控制面只有内网这一套(执行机唯一连接源),不存在第二套库;端口分工(**控制面与文件服务器同机部署在内网 `172.30.30.243`**):8800 控制面(controlplane-next)/ 8090 控制台前端(nginx 反代 /api)/ 8802 文件服务器下载(`desktop/fileserver/`,现役目录 `/opt/37du/fileserver`)/ 8899 文件服务器管理台。 -- 完整流程、命令示例见 docs/插件/发版规范.md、docs/桌面端/桌面端发版SOP.md;中心机部署见 docs/部署/服务端前后端部署SOP.md 或技能 `.trae/skills/37du-Center-Deploy/SKILL.md`(SSH、编译、重启、验证)。 +- 完整流程、命令示例见 docs/插件/发版规范.md、docs/桌面端/桌面端发版SOP.md;中心机部署见 docs/部署/服务端前后端部署SOP.md 或技能 `.skills/37du-Center-Deploy/SKILL.md`(SSH、编译、重启、验证)。