| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
feat(install-helper): 跨平台声明式安装引擎(Linux/macOS/Windows)+ npm 多包分发 + 安全性修复 + 测试用例覆盖 Co-authored-by: yanhf<yanhaifeng5@huawei.com> # message auto-generated for no-merge-commit merge: !489 merge master into master feat(install-helper): 跨平台声明式安装引擎(Linux/macOS/Windows)+ npm 多包分发 + 安全性修复 + 测试用例覆盖 Created-by: yanhf Commit-by: yanhf Merged-by: cann-robot Description: ## 描述 本 PR 对 install-helper 工具进行了系统性重构,实现跨平台声明式安装、npm 多包分发、安全性修复和代码质量全面提升,并补充完善的测试覆盖。共 98 个 commit,修改 74 个文件,+4301 / -753 行。 ### 新特性 #### 1. 声明式 Plugin 安装引擎(plugin-installer.ts) - 新增 plugin-installer.ts,通过 Node.js 原生执行安装(symlink + 外部仓库克隆 + manifest 写入),无需 bash/sh - 安装清单统一到 plugins.d/*.yml,不再侵入插件目录(删除 10 个 plugin-manifest.json) - PluginEntry 类型合并安装清单字段(installSkills/installAgents/configFile/externalRepos/configRootConfigLink/configRootLink) - 外部仓库双 symlink(configRoot + 项目根目录)+ workflows symlink,通过 configRootConfigLink/configRootLink 字段精确控制,与 init.sh 行为完全一致 - symlink → copy 自动降级(Windows 非 Developer Mode) - installer.ts 优先走 manifest 引擎,无安装清单时 fallback 到 init.sh - **per-plugin manifest**:每个插件写入独立的 ${pluginId}-manifest.json,多插件安装不再互相覆盖 #### 2. npm optionalDependencies 跨平台分发 - 主包 @cannbot-ai/install-helper 包含 wrapper 脚本 + JS fallback - 5 个平台子包 @cannbot-ai/install-helper-{linux/darwin/windows}-{x64/arm64},Bun 编译独立二进制 - bin/install-helper.js wrapper:优先执行平台二进制,fallback 到 JS - npm 自动安装匹配平台的子包(os+cpu 约束) #### 3. 跨平台零依赖安装 + 通道选择 - install.sh(Linux/macOS):从 npm registry 下载 tarball 解压二进制,无需 Node.js - macOS 兼容:grep -oP → grep -o + sed,/dev/tty 直接重定向,codesign 本地重签名 - 下载进度条(--progress-bar) - curl | bash 管道模式下通过 /dev/tty 重定向自动启动向导 - PATH 自动写入 .bashrc/.zshrc(去重 + RC 文件存在性检查) - npmjs.org + npmmirror 双源镜像回退 - install.ps1(Windows 原生):PowerShell 脚本,通过 gitcode raw 分发(iwr -useb | iex) - TLS 1.2 设置(PS 5.1 兼容),$ProgressPreference = "SilentlyContinue" 解决下载性能问题 - $ErrorActionPreference = "Stop" + 全局 trap 错误捕获(防止窗口闪退) - ExecutionPolicy 自动修复(Restricted → RemoteSigned,CurrentUser scope) - 镜像回退 + 错误列表收集 - **通道选择机制**:用户显式指定安装通道,不再跨 tag 比较 semver - latest(默认):仅查询 latest tag - beta:仅查询 beta tag - 显式版本号:直接使用,跳过查询 - install.sh: bash -s -- beta,install.ps1: $env:CANNBOT_CHANNEL = "beta" - **版本检查跳过下载**:本地版本与远程版本相同时跳过下载(install.sh Path A + Path B + install.ps1),秒级启动 #### 4. Bun 编译独立二进制 - scripts/build-npm-packages.cjs:一键构建 5 个平台子包 + 自动同步 optionalDependencies - scripts/publish-npm.cjs:一键发布子包(间隔 12s)+ 主包 - 构建时注入版本号(--define INSTALL_HELPER_VERSION) - i18n locale + plugins 数据内嵌到二进制(embedded-plugins.json) - build-binaries.sh:改用 gen-embedded.cjs 生成完整 embedded-plugins.json(删除覆盖完整输出的内联 JS) #### 5. Plugin 安装改为单选 - checkbox(多选)改为 select(单选),每个插件有独立 AGENTS.md,禁止同时安装多个 ### Bug 修复 #### 安全性(P0) - **S1**:parseFrontmatter 验证 skill name 仅允许 [a-zA-Z0-9._-],防止路径遍历 - **S2**:symlink 安装时 realpathSync 移到 unlinkSync 之前,防止源损坏时丢失已有链接 - **S3**:uninstall 增加 isSafePath 过滤(path.sep 替代硬编码 /),仅允许 configRoot/installPath 范围内路径被删除 - **S4**:createBackup 失败时中止安装并警告,不再静默覆盖 AGENTS.md #### 错误处理(P1) - **E1**:git pull 失败时 warn 提示使用缓存数据 - **E2**:config/record/YAML 解析失败时 warn 提示文件损坏 - **E3**:record 写入失败时 warn 提示卸载可能不可用 - **E4**:新增 atomicWriteFileSync(write-temp + rename),config/record/cache 改为原子写 - **E5**:install/update 取消操作统一输出提示 #### 跨平台(P0/P1) - **C1**:install.sh grep -oP → grep -o + sed(macOS BSD grep 兼容) - **C2**:uninstall.ts isSafePath base + "/" → base + sep(Windows 路径分隔符) - **C3**:installer.ts findShell() 检测 bash/sh 可用性(Windows 无 sh 时提示) - **X1**:Windows 上 bash → sh → findShell() 检测 - **X2**:Windows 上 which → where - **X3**:symlink EPERM 失败时提示开启 Windows 开发者模式 - **X4**:split("/") 改为 basename() 适配 Windows 路径分隔符 - **M2**:git clone 失败时删除 partial 目录,防止下次跳过克隆 - **M3**:installConfigFile 先 realpathSync 成功再 unlinkSync,防止源损坏时丢失配置 - **M6**:SIGINT handler 退出码 0 → 130(标准 SIGINT 退出码) - **M7**:CANNBOT_REPO_PATH/customPath 指定的仓库跳过 git pull,不破坏用户工作区 - **M8**:wrapper exit code 用 code ?? (signal ? 1 : 0),信号死亡不再误报成功 - **M9**:scanInstalledFiles 接受 externalRepoNames 参数,从 YAML 动态获取 - **macOS Gatekeeper**:下载后 codesign --sign - --force 本地重签名 + 运行检测 + npx fallback - **Ctrl+C**:增加 unhandledRejection 处理(Bun 兼容),优雅退出不抛堆栈 - **Windows 路径拼接**:configRoot + "/skills/" → join(configRoot, "skills") #### 代码审查修复(Critical/High/Medium) - **C1**:types/index.ts 删除孤立的重复 PluginEntry 接口体(TypeScript 语法错误) - **H1**:manifest.ts verifyPluginFilesExist 使用 getAgentsFileName(tool) 替代硬编码 AGENTS.md,project level 路径统一(修复 Claude/Trae/Cursor/Copilot 安装检测) - **H2**:plugin-installer.ts manifest 写入改为 per-plugin ${pluginId}-manifest.json(防止多插件安装互相覆盖) - **H3**:build-binaries.sh 删除覆盖完整输出的内联 JS,改用 gen-embedded.cjs - **M1**:7 个 plugins.d/*.yml 文件的 skills/agents 计数修正(与实际 installSkills/installAgents 一致) - **M5**:installer.ts 重新安装同一插件时也创建备份(不仅限于不同插件) #### 安装脚本 Windows 兼容性修复 - install.ps1 exit N → return(irm | iex 上下文中 exit 关闭整个 PowerShell 进程) - install.ps1 & npm → & npm.cmd(Node.js v24 生成 npm.ps1 被 ExecutionPolicy 阻止) - install.ps1 移除 2>&1(npm stderr 触发 ErrorActionPreference=Stop 终止性错误) - install.ps1 全局 trap 错误捕获(防止未预期错误导致窗口闪退) - install.ps1 ExecutionPolicy 自动修复(Restricted → RemoteSigned) - install.ps1 纯英文消息(irm 用 Latin-1 解码 UTF-8 中文会乱码) - install.ps1/install.sh 从 jsDelivr CDN 改为 gitcode raw(国内访问稳定 + 无 CDN 缓存问题) #### symlink 同源跳过(Windows EPERM 修复) - **skill-installer.ts**:installSkills 中检测 symlink 已指向相同源 → 跳过(使用 readlinkSync 替代 realpathSync 避免 Windows EPERM) - **plugin-installer.ts**:installLink 中检测 symlink 已指向相同源 → 返回 "skipped"(同样使用 readlinkSync) - 路径比较用 replace(/\\/g, "/").toLowerCase() 规范化(跨平台) - readlinkSync 失败时也跳过(不尝试 unlinkSync 避免 EPERM) - rmdirSync → rmSync(废弃 API 替换) - startsWith("/") → isAbsolute()(Windows 绝对路径检测) ### 代码重构 - 消除 6 组重复函数(isSymlink×3, isDirectory×2, getAgentsFileName×2 等),提取到 utils/fs-helpers.ts - 删除 22 个死导出 + 7 个死 i18n key - 工具数组硬编码 5 处统一引用 VALID_TOOLS - magic string __back__/__cancel__ 提取到 utils/constants.ts - readAllRecords 硬编码 plugin ID 改用 getAllPlugins() - 版本号从 package.json 动态读取,消除双源 - list 命令移除 Skills/Agents 计数列,替换为描述列 - 统一插件配置到 YAML(删除 10 个 plugin-manifest.json) - tsc --noEmit 0 错误(修复 externalRepos undefined 类型) ### i18n 改进 - skill category 名随语言切换(zh_CN/en_US) - 10+ 硬编码英文错误字符串提取为 i18n key - uninstall 全角括号改为 i18n 模板 ### 架构优化 - ensureRepoAndScan 自动 git pull + mergeDynamicPlugins(用户指定路径时跳过 pull) - scanner 新增 runtime scanDir + 插件根级 SKILL.md 扫描 - registry 新增 mergeDynamicPlugins 动态插件发现 - scan cache TTL 可配置 ### 新增测试(148 个测试用例,14 个文件) - scanner.test.ts(8):parseFrontmatter 安全验证(S1 路径遍历防护) - registry.test.ts(7):插件发现 + 别名匹配 - skill-registry.test.ts(11):skill 注册表 + 类别 - paths.test.ts(9):路径验证 + 工具检测 - plugin-installer.test.ts(9):symlink 安装、configRootConfigLink、workflows、skill rename、manifest 写入、多插件不覆盖 - record.test.ts(9):读写一致性、损坏处理、动态 externalRepoNames、skill 去重 - skill-installer.test.ts(10):resolveSkillSourcePath、S2 安全修复、同源跳过、异源更新、损坏修复 - uninstall.test.ts(6):isSafePath C2 安全修复验证 - backup.test.ts(8):备份创建/解析/恢复/删除 - fs.test.ts(9):原子写、符号链接检测、目录检测 - i18n.test.ts(7):翻译、语言切换、常量值 - manifest.test.ts(4):readAllManifests 读取 legacy/per-plugin manifest、writeCannbotManifest per-plugin 写入、多插件不覆盖 - install-scripts.test.ts(27):版本比较、跳过下载决策、镜像排序、架构映射、ExecutionPolicy 决策、安装路径决策、通道解析、通道感知跳过 - bin-wrapper.test.ts(11):平台映射、二进制名、fallback 逻辑 ### 文档优化 - docs/installation-guide.md:按平台分代码块 + 精简冗余说明 - plugins-community/install-helper/README.md:按平台分组 + 删除冗余内容(322→164 行) - README.md:安装部分增加 Windows 安装命令(gitcode raw) ## 关联的Issue 无 ## 测试 - **tsc --noEmit**:0 错误 - **npm test**:148/148 测试通过(14 个文件) - **Linux arm64**:install.sh 全流程 + 10 个插件 install/uninstall 全通过 - **Windows x64**:iwr -useb | iex 安装 + 通道选择(latest/beta)+ 版本跳过下载 + Plugin 安装(ops-direct-invoke 19 skills, 4 agents)+ Skill 安装 + 交互向导 + Ctrl+C 优雅退出全通过 - **Windows 多插件**:先安装 ops-direct-invoke 再安装 ops-direct-invoke-flash,共享 skill 跳过(不报 EPERM 错误) - **外部仓库验证**:asc-devkit/pypto/tilelang-ascend/cann-recipes-infer 的 configRoot + 项目根目录 symlink 全部正确(configRootConfigLink/configRootLink 精确控制) - **workflows symlink**:ops-direct-invoke/catlass-op-generator/model-infer-optimize 正确 - **安全修复验证**:S1(路径遍历)、S2(symlink 数据丢失)、C2(Windows 路径分隔符)、M9(动态 repo 记录)全部有测试覆盖 ## 文档更新 - docs/installation-guide.md:按平台分代码块,精简冗余说明 - plugins-community/install-helper/README.md:按平台分组,322→164 行 - README.md:安装部分增加 Windows 安装命令(gitcode raw) ## 类型标签 - [x] 🌟 新特性 - [x] 🐛 Bug 修复 - [x] 🔒 安全修复 - [x] ♻️ 代码重构 - [x] 🧹 代码清理 - [x] 📝 文档更新 - [x] 🧪 测试用例 - [x] 📦 构建 / CI See merge request: cann/cannbot-skills!489 | 26 天前 | |
feat(install-helper): 跨平台声明式安装引擎(Linux/macOS/Windows)+ npm 多包分发 + 安全性修复 + 测试用例覆盖 Co-authored-by: yanhf<yanhaifeng5@huawei.com> # message auto-generated for no-merge-commit merge: !489 merge master into master feat(install-helper): 跨平台声明式安装引擎(Linux/macOS/Windows)+ npm 多包分发 + 安全性修复 + 测试用例覆盖 Created-by: yanhf Commit-by: yanhf Merged-by: cann-robot Description: ## 描述 本 PR 对 install-helper 工具进行了系统性重构,实现跨平台声明式安装、npm 多包分发、安全性修复和代码质量全面提升,并补充完善的测试覆盖。共 98 个 commit,修改 74 个文件,+4301 / -753 行。 ### 新特性 #### 1. 声明式 Plugin 安装引擎(plugin-installer.ts) - 新增 plugin-installer.ts,通过 Node.js 原生执行安装(symlink + 外部仓库克隆 + manifest 写入),无需 bash/sh - 安装清单统一到 plugins.d/*.yml,不再侵入插件目录(删除 10 个 plugin-manifest.json) - PluginEntry 类型合并安装清单字段(installSkills/installAgents/configFile/externalRepos/configRootConfigLink/configRootLink) - 外部仓库双 symlink(configRoot + 项目根目录)+ workflows symlink,通过 configRootConfigLink/configRootLink 字段精确控制,与 init.sh 行为完全一致 - symlink → copy 自动降级(Windows 非 Developer Mode) - installer.ts 优先走 manifest 引擎,无安装清单时 fallback 到 init.sh - **per-plugin manifest**:每个插件写入独立的 ${pluginId}-manifest.json,多插件安装不再互相覆盖 #### 2. npm optionalDependencies 跨平台分发 - 主包 @cannbot-ai/install-helper 包含 wrapper 脚本 + JS fallback - 5 个平台子包 @cannbot-ai/install-helper-{linux/darwin/windows}-{x64/arm64},Bun 编译独立二进制 - bin/install-helper.js wrapper:优先执行平台二进制,fallback 到 JS - npm 自动安装匹配平台的子包(os+cpu 约束) #### 3. 跨平台零依赖安装 + 通道选择 - install.sh(Linux/macOS):从 npm registry 下载 tarball 解压二进制,无需 Node.js - macOS 兼容:grep -oP → grep -o + sed,/dev/tty 直接重定向,codesign 本地重签名 - 下载进度条(--progress-bar) - curl | bash 管道模式下通过 /dev/tty 重定向自动启动向导 - PATH 自动写入 .bashrc/.zshrc(去重 + RC 文件存在性检查) - npmjs.org + npmmirror 双源镜像回退 - install.ps1(Windows 原生):PowerShell 脚本,通过 gitcode raw 分发(iwr -useb | iex) - TLS 1.2 设置(PS 5.1 兼容),$ProgressPreference = "SilentlyContinue" 解决下载性能问题 - $ErrorActionPreference = "Stop" + 全局 trap 错误捕获(防止窗口闪退) - ExecutionPolicy 自动修复(Restricted → RemoteSigned,CurrentUser scope) - 镜像回退 + 错误列表收集 - **通道选择机制**:用户显式指定安装通道,不再跨 tag 比较 semver - latest(默认):仅查询 latest tag - beta:仅查询 beta tag - 显式版本号:直接使用,跳过查询 - install.sh: bash -s -- beta,install.ps1: $env:CANNBOT_CHANNEL = "beta" - **版本检查跳过下载**:本地版本与远程版本相同时跳过下载(install.sh Path A + Path B + install.ps1),秒级启动 #### 4. Bun 编译独立二进制 - scripts/build-npm-packages.cjs:一键构建 5 个平台子包 + 自动同步 optionalDependencies - scripts/publish-npm.cjs:一键发布子包(间隔 12s)+ 主包 - 构建时注入版本号(--define INSTALL_HELPER_VERSION) - i18n locale + plugins 数据内嵌到二进制(embedded-plugins.json) - build-binaries.sh:改用 gen-embedded.cjs 生成完整 embedded-plugins.json(删除覆盖完整输出的内联 JS) #### 5. Plugin 安装改为单选 - checkbox(多选)改为 select(单选),每个插件有独立 AGENTS.md,禁止同时安装多个 ### Bug 修复 #### 安全性(P0) - **S1**:parseFrontmatter 验证 skill name 仅允许 [a-zA-Z0-9._-],防止路径遍历 - **S2**:symlink 安装时 realpathSync 移到 unlinkSync 之前,防止源损坏时丢失已有链接 - **S3**:uninstall 增加 isSafePath 过滤(path.sep 替代硬编码 /),仅允许 configRoot/installPath 范围内路径被删除 - **S4**:createBackup 失败时中止安装并警告,不再静默覆盖 AGENTS.md #### 错误处理(P1) - **E1**:git pull 失败时 warn 提示使用缓存数据 - **E2**:config/record/YAML 解析失败时 warn 提示文件损坏 - **E3**:record 写入失败时 warn 提示卸载可能不可用 - **E4**:新增 atomicWriteFileSync(write-temp + rename),config/record/cache 改为原子写 - **E5**:install/update 取消操作统一输出提示 #### 跨平台(P0/P1) - **C1**:install.sh grep -oP → grep -o + sed(macOS BSD grep 兼容) - **C2**:uninstall.ts isSafePath base + "/" → base + sep(Windows 路径分隔符) - **C3**:installer.ts findShell() 检测 bash/sh 可用性(Windows 无 sh 时提示) - **X1**:Windows 上 bash → sh → findShell() 检测 - **X2**:Windows 上 which → where - **X3**:symlink EPERM 失败时提示开启 Windows 开发者模式 - **X4**:split("/") 改为 basename() 适配 Windows 路径分隔符 - **M2**:git clone 失败时删除 partial 目录,防止下次跳过克隆 - **M3**:installConfigFile 先 realpathSync 成功再 unlinkSync,防止源损坏时丢失配置 - **M6**:SIGINT handler 退出码 0 → 130(标准 SIGINT 退出码) - **M7**:CANNBOT_REPO_PATH/customPath 指定的仓库跳过 git pull,不破坏用户工作区 - **M8**:wrapper exit code 用 code ?? (signal ? 1 : 0),信号死亡不再误报成功 - **M9**:scanInstalledFiles 接受 externalRepoNames 参数,从 YAML 动态获取 - **macOS Gatekeeper**:下载后 codesign --sign - --force 本地重签名 + 运行检测 + npx fallback - **Ctrl+C**:增加 unhandledRejection 处理(Bun 兼容),优雅退出不抛堆栈 - **Windows 路径拼接**:configRoot + "/skills/" → join(configRoot, "skills") #### 代码审查修复(Critical/High/Medium) - **C1**:types/index.ts 删除孤立的重复 PluginEntry 接口体(TypeScript 语法错误) - **H1**:manifest.ts verifyPluginFilesExist 使用 getAgentsFileName(tool) 替代硬编码 AGENTS.md,project level 路径统一(修复 Claude/Trae/Cursor/Copilot 安装检测) - **H2**:plugin-installer.ts manifest 写入改为 per-plugin ${pluginId}-manifest.json(防止多插件安装互相覆盖) - **H3**:build-binaries.sh 删除覆盖完整输出的内联 JS,改用 gen-embedded.cjs - **M1**:7 个 plugins.d/*.yml 文件的 skills/agents 计数修正(与实际 installSkills/installAgents 一致) - **M5**:installer.ts 重新安装同一插件时也创建备份(不仅限于不同插件) #### 安装脚本 Windows 兼容性修复 - install.ps1 exit N → return(irm | iex 上下文中 exit 关闭整个 PowerShell 进程) - install.ps1 & npm → & npm.cmd(Node.js v24 生成 npm.ps1 被 ExecutionPolicy 阻止) - install.ps1 移除 2>&1(npm stderr 触发 ErrorActionPreference=Stop 终止性错误) - install.ps1 全局 trap 错误捕获(防止未预期错误导致窗口闪退) - install.ps1 ExecutionPolicy 自动修复(Restricted → RemoteSigned) - install.ps1 纯英文消息(irm 用 Latin-1 解码 UTF-8 中文会乱码) - install.ps1/install.sh 从 jsDelivr CDN 改为 gitcode raw(国内访问稳定 + 无 CDN 缓存问题) #### symlink 同源跳过(Windows EPERM 修复) - **skill-installer.ts**:installSkills 中检测 symlink 已指向相同源 → 跳过(使用 readlinkSync 替代 realpathSync 避免 Windows EPERM) - **plugin-installer.ts**:installLink 中检测 symlink 已指向相同源 → 返回 "skipped"(同样使用 readlinkSync) - 路径比较用 replace(/\\/g, "/").toLowerCase() 规范化(跨平台) - readlinkSync 失败时也跳过(不尝试 unlinkSync 避免 EPERM) - rmdirSync → rmSync(废弃 API 替换) - startsWith("/") → isAbsolute()(Windows 绝对路径检测) ### 代码重构 - 消除 6 组重复函数(isSymlink×3, isDirectory×2, getAgentsFileName×2 等),提取到 utils/fs-helpers.ts - 删除 22 个死导出 + 7 个死 i18n key - 工具数组硬编码 5 处统一引用 VALID_TOOLS - magic string __back__/__cancel__ 提取到 utils/constants.ts - readAllRecords 硬编码 plugin ID 改用 getAllPlugins() - 版本号从 package.json 动态读取,消除双源 - list 命令移除 Skills/Agents 计数列,替换为描述列 - 统一插件配置到 YAML(删除 10 个 plugin-manifest.json) - tsc --noEmit 0 错误(修复 externalRepos undefined 类型) ### i18n 改进 - skill category 名随语言切换(zh_CN/en_US) - 10+ 硬编码英文错误字符串提取为 i18n key - uninstall 全角括号改为 i18n 模板 ### 架构优化 - ensureRepoAndScan 自动 git pull + mergeDynamicPlugins(用户指定路径时跳过 pull) - scanner 新增 runtime scanDir + 插件根级 SKILL.md 扫描 - registry 新增 mergeDynamicPlugins 动态插件发现 - scan cache TTL 可配置 ### 新增测试(148 个测试用例,14 个文件) - scanner.test.ts(8):parseFrontmatter 安全验证(S1 路径遍历防护) - registry.test.ts(7):插件发现 + 别名匹配 - skill-registry.test.ts(11):skill 注册表 + 类别 - paths.test.ts(9):路径验证 + 工具检测 - plugin-installer.test.ts(9):symlink 安装、configRootConfigLink、workflows、skill rename、manifest 写入、多插件不覆盖 - record.test.ts(9):读写一致性、损坏处理、动态 externalRepoNames、skill 去重 - skill-installer.test.ts(10):resolveSkillSourcePath、S2 安全修复、同源跳过、异源更新、损坏修复 - uninstall.test.ts(6):isSafePath C2 安全修复验证 - backup.test.ts(8):备份创建/解析/恢复/删除 - fs.test.ts(9):原子写、符号链接检测、目录检测 - i18n.test.ts(7):翻译、语言切换、常量值 - manifest.test.ts(4):readAllManifests 读取 legacy/per-plugin manifest、writeCannbotManifest per-plugin 写入、多插件不覆盖 - install-scripts.test.ts(27):版本比较、跳过下载决策、镜像排序、架构映射、ExecutionPolicy 决策、安装路径决策、通道解析、通道感知跳过 - bin-wrapper.test.ts(11):平台映射、二进制名、fallback 逻辑 ### 文档优化 - docs/installation-guide.md:按平台分代码块 + 精简冗余说明 - plugins-community/install-helper/README.md:按平台分组 + 删除冗余内容(322→164 行) - README.md:安装部分增加 Windows 安装命令(gitcode raw) ## 关联的Issue 无 ## 测试 - **tsc --noEmit**:0 错误 - **npm test**:148/148 测试通过(14 个文件) - **Linux arm64**:install.sh 全流程 + 10 个插件 install/uninstall 全通过 - **Windows x64**:iwr -useb | iex 安装 + 通道选择(latest/beta)+ 版本跳过下载 + Plugin 安装(ops-direct-invoke 19 skills, 4 agents)+ Skill 安装 + 交互向导 + Ctrl+C 优雅退出全通过 - **Windows 多插件**:先安装 ops-direct-invoke 再安装 ops-direct-invoke-flash,共享 skill 跳过(不报 EPERM 错误) - **外部仓库验证**:asc-devkit/pypto/tilelang-ascend/cann-recipes-infer 的 configRoot + 项目根目录 symlink 全部正确(configRootConfigLink/configRootLink 精确控制) - **workflows symlink**:ops-direct-invoke/catlass-op-generator/model-infer-optimize 正确 - **安全修复验证**:S1(路径遍历)、S2(symlink 数据丢失)、C2(Windows 路径分隔符)、M9(动态 repo 记录)全部有测试覆盖 ## 文档更新 - docs/installation-guide.md:按平台分代码块,精简冗余说明 - plugins-community/install-helper/README.md:按平台分组,322→164 行 - README.md:安装部分增加 Windows 安装命令(gitcode raw) ## 类型标签 - [x] 🌟 新特性 - [x] 🐛 Bug 修复 - [x] 🔒 安全修复 - [x] ♻️ 代码重构 - [x] 🧹 代码清理 - [x] 📝 文档更新 - [x] 🧪 测试用例 - [x] 📦 构建 / CI See merge request: cann/cannbot-skills!489 | 26 天前 | |
fix(docs): 清理全仓库 ops-lab/ 历史废弃目录的残留引用 Co-authored-by: jiangyixuan2<124090275@link.cuhk.edu.cn> Co-authored-by: gitcode-bot<noreply@gitcode.com> # message auto-generated for no-merge-commit merge: !645 merge fix/issue-435-remove-ops-lab-refs into master fix(docs): 清理全仓库 ops-lab/ 历史废弃目录的残留引用 Created-by: jiangyixuan2 Commit-by: gitcode-bot;jiangyixuan2 Merged-by: cann-robot Description: ### 描述 ops-lab/ 为历史废弃目录,此前已被整体移除,但全仓库仍有大量文件残留对该目录的引用(目录结构图、路径引用、扫描配置、脚本逻辑等),误导用户。本次统一清理这些失效引用。 ### 修改范围 15 个文件,+23/-32 行。 #### 一、目录结构图与规范表(删除 ops-lab/ 条目) | 文件 | 修改 | |------|------| | README.md | 删除目录结构图中 ├── ops-lab/ 行 | | AGENTS.md | 删除目录结构图中 ├── ops-lab/ 行 | | docs/architecture-design.md | 删除目录结构图中 ├── ops-lab/ 行 | | docs/STANDARDS.md | 删除目录规范表中 ops-lab/ 行 | | docs/CONTRIBUTING.md | 删除"实验性 Skill"整行(原指向 ops-lab/)| #### 二、ST 测试指南 | 文件 | 修改 | |------|------| | tests/system/docs/ST_DESIGN_AND_DEVELOPMENT_GUIDE.md | 删除 skill_dirs 配置中 "ops-lab";§3.9 标题由 ops-lab/ 改为 ops/ — TileLang 算子开发,5 个 TileLang skill 路径由 ops-lab/tilelang/skills/xxx 改为实际位置 ops/xxx | #### 三、其他文档 | 文件 | 修改 | |------|------| | ops/ascendc-registry-invoke-template/references/binary-json-dtype-guide.md | 删除"ops-lab 模板不适用"说明 | | plugins-community/tilelang2ascendc-ops-generator/quickstart.md | 修正错误目录名 ascendc-ops-lab-developer → tilelang2ascendc-ops-generator | #### 四、代码与配置(移除 ops-lab 扫描目录与处理分支) | 文件 | 修改 | |------|------| | infra/cannbot-skill-reviewer/scripts/review_skill.py | 路径前缀元组移除 "ops-lab/" | | plugins-community/install-helper/scripts/gen-embedded.cjs | SCAN_DIRS 移除 "ops-lab" | | plugins-community/install-helper/src/config/repository.yaml | scanDirs 移除 - ops-lab | | plugins-community/install-helper/src/core/scanner.ts | 默认 skillDirs 移除 "ops-lab"(2 处)| | plugins-community/tilelang2ascendc-ops-generator/init.sh | 删除 ops-lab 目录检查块、移除 SHARED_SKILL_ROOT_OPS_LAB 变量及 5 个 for 循环引用 | | tests/run-tests.sh | 注释移除 ops-lab/*/skills/ 模式 | #### 五、变更日志 | 文件 | 修改 | |------|------| | CHANGELOG.md | 新增 2026-07-20 清理 ops-lab 记录(历史记录中的 ops-lab 引用保持原样)| ## 关联 Issue Issue [#435](https://gitcode.com/cann/cannbot-skills/issues/435) See merge request: cann/cannbot-skills!645 | 18 天前 | |
feat(install-helper): 新增 codearts 工具支持与插件元数据自动同步,修复多项Bug 、构建优化、代码清理与文档更新 Co-authored-by: yanhf<yanhaifeng5@huawei.com> # message auto-generated for no-merge-commit merge: !624 merge master into master feat(install-helper): 新增 codearts 工具支持与插件元数据自动同步,修复多项Bug 、构建优化、代码清理与文档更新 Created-by: yanhf Commit-by: yanhf Merged-by: cann-robot Description: ## 描述 本次改动全面升级 install-helper CLI 工具至正式版本 1.1.5,涵盖新特性、Bug 修复、构建优化、代码清理与文档更新。 ### 新特性 New Features - 【安装部署】新增 CodeArts 工具支持(AITool 类型/VALID_TOOLS/getConfigRoot/detector/cli/README),配置目录 .codeartsdoer,与 init.sh 已有的 codearts 适配对齐。 - 【安装部署】新增 model-infer-sota-approach 插件声明(plugins.d/model-infer-sota-approach.yml),官方插件达 11 个,14 skills + 6 agents + cann-recipes-infer 外部仓库。 - 【安装部署】构建时元数据自动同步:增强 gen-embedded.cjs,从 .claude-plugin/plugin.json 读取 version/agents/description,从 init.sh INCLUDED_SKILLS 补充 yml 缺失的 skill,消除静态 yml 与仓库演进间的漂移。 - 【安装部署】运行时元数据自动同步:新增 src/core/metadata-sync.ts,在 git pull 后从仓库最新的 plugin.json + init.sh 实时同步插件元数据(version/installSkills/installAgents/description),无需 npm 发版即可获取最新安装清单。 ### 特性增强 Feature Enhancement - 【安装部署】update 命令重构:ensureRepoAndScan 前置于 scanInstalled,确保动态发现的插件(cuda2ascend 等)能被正确发现和更新;遍历全部 tools×levels(复用 scanInstalled()),跨工具/跨级别安装的插件均被更新;有插件名但未指定 tool/level 时从 scanInstalled() 查找实际安装位置;新增 --yes 选项支持非交互更新。 - 【安装部署】doctor 健康检查增强:遍历 scanInstalled() 去重后的全部 configRoot,检查所有已安装工具/级别的链接完整性和配置文件,不再仅检查第一个检测到的工具。 - 【安装部署】registry.ts 简化:直接使用 embeddedPlugins(构建时生成),移除运行时 yml 读取逻辑。 - 【安装部署】findPlugin prefix match 精确化:仅唯一前缀匹配时返回,多候选时返回 undefined,避免猜错插件。 ### 问题修复 Bug Fix - 【安装部署】修复 detectCurrentPlugin 按 displayName 字母序取"最后一个"manifest 导致多插件共存时返回错误插件的问题,改为按 install_time 降序取最新;同时改用 readAllManifests(含 per-plugin manifest),并检查 installPath/AGENTS.md 路径(修复 project 级 + configRootConfigLink:false 的 6 个插件无备份问题)。 - 【安装部署】修复 update --yes 选项已声明但未透传到 installPlugin 的问题,CI/非交互场景不再弹覆盖提示。 - 【安装部署】修复 7 处 ensureRepo/ensureRepoAndScan 调用未包裹 try/catch,clone/pull 失败时静默 process.exit(1) 的问题,现输出 repo_clone_failed 文案。 - 【安装部署】修复 update <未安装插件> 静默变"安装"的语义不一致问题,改为 warn + 跳过。 - 【安装部署】修复 update 多插件名中首个无效即中止整条命令的问题,改为 continue 跳过。 - 【安装部署】修复 atomicWriteFileSync 先 unlink 再 rename 的非原子窗口,改为直接 renameSync 覆盖(POSIX 原子),并在 rename 失败时清理 tmp 文件。 - 【安装部署】修复损坏的 clone 目录永久阻塞后续 clone 的问题,检测到无效目录时 rmSync 清理后再 clone。 - 【安装部署】修复 external repo 已存在时不更新(跳过 git pull)与 init.sh fetch+merge 行为不一致的问题;pull 失败后 continue 跳过链接建立,避免指向不一致工作树。 - 【安装部署】修复 skill 安装无 EPERM copy 回退(与 plugin-installer 不一致)的问题,Windows 非管理员用户独立安装 skill 不再失败。 - 【安装部署】修复 cpSync EPERM 回退后 target 变为目录,再次安装时 unlinkSync 抛 EISDIR 导致无法二次安装的问题:新增 removePath 辅助函数(lstatSync 判定目录→rmSync,文件/软链→unlinkSync),替换全部 8 处 unlinkSync。 - 【安装部署】修复 update 命令 scanInstalled() 在 ensureRepoAndScan() 之前调用,导致动态发现的插件(cuda2ascend 等)即使已安装也无法被 update 发现的问题:重构为 ensureRepoAndScan 前置执行。 ### 构建/CI Build - 【安装部署】修复主包包含 5 个平台二进制(405MB 死重量)的问题,files 字段从 bin/ 改为 bin/install-helper.js + bin/package.json,包体积从 424MB 降至 578KB(减少 99.86%)。 - 【安装部署】publish-npm.cjs 支持按版本号自动判定 beta/latest tag。 - 【安装部署】dev 脚本补充 gen-embedded.cjs 前置步骤,修复全新 clone 构建失败。 - 【安装部署】删除 tsup.config.ts 中 cpSync("plugins.d", "dist/plugins.d") 死文件生成(registry.ts 已改用 embeddedPlugins,运行时不读 yml)。 ### 代码清理 Code Cleanup - 【安装部署】清理 plugin-installer.ts 和 skill-installer.ts 中不再使用的 unlinkSync import。 - 【安装部署】删除 i18n 死 key plugin_yaml_error(registry.ts 不再读 yml)。 ### 文档更新 Documentation - 【安装部署】README 命令一览表移除冗余的 init 行和 lang show 行,install-helper 作为唯一推荐入口;补全 --list 选项、codearts 工具说明、前置条件。 ## 关联的Issue 无 ## 测试 - 176 个单元测试全部通过(18 个测试文件) - tsc --noEmit 类型检查通过 - 16 项完整回归测试全部通过(使用 npm [@latest](https://gitcode.com/latest) 正式版本 1.1.5): - 发布验证(latest/beta/子包版本/包体积 578KB) - 安装版本一致性(--version 1.1.5 / npm ls @1.1.5 / bin/ 12KB) - 核心功能(list 14 插件 / install --list / info / lang) - 安装生命周期(install 20 skills + 4 agents / 结构验证 / manifest version 1.2.4 运行时同步 / status / doctor 0 警告 / update --yes / update 未安装跳过 / uninstall 全部清理) - 跨工具(codearts 安装/卸载 / findPlugin 多候选返回 not found) - 构建产物(dist 无 plugins.d 死文件) ## 文档更新 - plugins-community/install-helper/README.md:命令一览表移除 init 和 lang show 行,补全 --list 选项、codearts 工具、前置条件说明。 ## 类型标签 - [x] 🌟 新特性 - [x] ✨ 特性增强 - [x] 🐛 Bug 修复 - [ ] ⚡ 性能优化 - [ ] 🧪 测试用例 - [x] 📦 构建 / CI - [x] 📝 文档更新 - [ ] 🔧 配置变更 - [ ] ⬆️ 依赖升级 - [ ] 🔒 安全修复 - [x] ♻️ 代码重构 - [x] 🧹 代码清理 - [ ] ❓ 其他,请描述: ## 流水线故障排查 无 See merge request: cann/cannbot-skills!624 | 19 天前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 26 天前 | ||
| 26 天前 | ||
| 18 天前 | ||
| 19 天前 |