Compare commits
10
Commits
v0.9.9
...
debfdec77d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
debfdec77d | ||
|
|
d7a7203eeb | ||
|
|
86a02b82b7 | ||
|
|
5e59c835f1 | ||
|
|
f9422ee431 | ||
|
|
41503917ce | ||
|
|
6f60803c66 | ||
|
|
c63ec24344 | ||
|
|
35a118c456 | ||
|
|
0e8d844f3f |
No files matched your search
@@ -4,10 +4,10 @@
|
||||
"type": "stdio",
|
||||
"command": "bun",
|
||||
"args": [
|
||||
"${CLAUDE_PLUGIN_ROOT}/dist/mcp/server.js"
|
||||
"src/server.ts"
|
||||
],
|
||||
"env": {
|
||||
"HOSE_USE_MCP_ENABLED": "${user_config.enable_mcp}"
|
||||
"HOSE_USE_MCP_ENABLED": "true"
|
||||
},
|
||||
"timeoutMs": 120000
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
},
|
||||
"license": "MIT",
|
||||
"skills": "skills",
|
||||
"mcpServers": "./.mcp.json",
|
||||
"mcpServers": "./mcp.json",
|
||||
"userConfig": {
|
||||
"enable_mcp": {
|
||||
"type": "boolean",
|
||||
|
||||
@@ -138,7 +138,7 @@ hose-use mcp # 启动 MCP Server (默认暴露
|
||||
|
||||
- **多文件 Skill 模块体系**:知识体系划分至 `references/auth.md`、`references/bill.md`、`references/workflow.md`、`references/service.md`,执行 `hose-use skill install --yes` 自动递归安装到统一的 `~/.agents/skills/hose-use`;如需安装到其他位置,必须显式使用 `--dir`;
|
||||
- **开发环境检查**:Git 工作树、分支、无引用提交、canonical Skill 与全局开发版可通过 `bun run dev:status`、`bun run dev:check` 检查;清理必须先 `bun run dev:clean --dry-run`,再追加 `--yes`;
|
||||
- **原生 IDE 插件规范支持**:内嵌 `.zcode-plugin/plugin.json` 与 `.mcp.json` 清单,支持标准 IDE 插件市场/本地插件直接载入,并在设置界面支持可视化切换 MCP 开关;
|
||||
- **原生 IDE 插件规范支持**:内嵌 `.zcode-plugin/plugin.json` 与 `mcp.json` 插件清单,支持标准 IDE 插件市场/本地插件直接载入,并在设置界面支持可视化切换 MCP 开关;仓库根目录的 `.mcp.json` 是 Claude Code 项目级 MCP 配置,直接以 `bun src/server.ts` 启动当前源码;
|
||||
- **MCP 单文件产物**:`bun run build:plugin` 生成 `dist/mcp/server.js`,整个 `dist/` 不纳入 Git。源码方式加载插件须先安装依赖并执行此构建;插件使用 Bun 1.3.14+ 运行,以支持共享 CLI 的 `bun:sqlite`。独立二进制的 `hose-use mcp` 已内嵌运行时,可直接启动。
|
||||
- **完整插件包**:`bun run package:plugin` 从当前源码构建并生成 `dist/bin/hose-use-plugin-v<版本>.tar.gz`,内含清单、MCP 配置、Skill 与 bundle。Release 发布此包并纳入 `checksums.txt` 和 Gitea 镜像;解包目录可作为本地插件根目录,无需源码或 `node_modules/`,仍需 Bun。打包命令需要 `tar`;详细用法见 [构建与分发说明](./src/packaging/README.packaging.md)。
|
||||
|
||||
@@ -155,7 +155,7 @@ hose-use mcp # 启动 MCP Server (默认暴露
|
||||
| `.github/` | CI 与 Release 工作流,负责校验、构建和发布。 |
|
||||
| `.zcode-plugin/` | 受版本管理的 [IDE 插件清单](.zcode-plugin/plugin.json),声明 Skill 路径、MCP 配置与用户开关。 |
|
||||
| `specs/` | specifications(规范)的缩写,存放 API 与工作流规范:`hose-open-api/` 是 hose-use 包装层对外 API 的 YAML 源文件,`openapi.json` 是其打包结果,`openapi.raw.json` 是独立的下游接口规范,`workflow-schema.json` 是从 Zod 导出的工作流结构。[hose-close-api/](./specs/hose-close-api/README.md) 保存从代码整理的合思内部接口清单与 Schema;本地临时抓包不纳入 Git。生成入口见下文。 |
|
||||
| `dist/`(本地) | 全部是已忽略的构建输出:`mcp/server.js` 是 [.mcp.json](.mcp.json) 引用的插件 bundle,`bin/` 保存独立二进制与发布归档。可重新构建,不随 Git 分发;删除后再次加载源码插件前须先构建。详见 [构建与分发说明](./src/packaging/README.packaging.md)。 |
|
||||
| `dist/`(本地) | 全部是已忽略的构建输出:`mcp/server.js` 是 [mcp.json](mcp.json) 引用的插件 bundle,`bin/` 保存独立二进制与发布归档。可重新构建,不随 Git 分发;删除后再次加载源码插件前须先构建。详见 [构建与分发说明](./src/packaging/README.packaging.md)。 |
|
||||
| `docs/` | 跨模块参考与审阅记录;Platform 模块说明和各域 README 提供当前 CLI 与服务导航,架构总纲见 [AGENTS.md](./AGENTS.md);`reviews/` 保留历史审阅及验证证据。 |
|
||||
| `enterprises/` | 仅跟踪配置示例与 [目录说明](./enterprises/README.md)。实际企业配置默认放在 `~/.config/hose-use/enterprises/`,仓库内其他企业 JSON 被忽略。 |
|
||||
| `.git/` 或 `.git` 文件 | Git 元数据;独立工作树中通常是指向共享仓库的文件。 |
|
||||
@@ -167,7 +167,7 @@ hose-use mcp # 启动 MCP Server (默认暴露
|
||||
|
||||
- [AGENTS.md](./AGENTS.md) 是项目开发规则总入口;`CLAUDE.md → AGENTS.md` 是兼容软链接,共享同一份内容。
|
||||
- [package.json](./package.json)、`bun.lock` 与 [tsconfig.json](./tsconfig.json) 分别管理项目入口和命令、锁定依赖、配置 TypeScript;[.env.example](.env.example) 是环境变量示例。
|
||||
- [.mcp.json](.mcp.json) 声明插件 MCP 启动方式,与 `.zcode-plugin/plugin.json` 配套;[.gitignore](.gitignore) 声明本地数据与产物的忽略边界。
|
||||
- [mcp.json](mcp.json) 声明插件 MCP 启动方式,与 `.zcode-plugin/plugin.json` 配套;[.mcp.json](.mcp.json) 是 Claude Code 项目级 MCP 配置,避免把插件变量 `${CLAUDE_PLUGIN_ROOT}` 带到项目上下文;[.gitignore](.gitignore) 声明本地数据与产物的忽略边界。
|
||||
- `ROADMAP.local.md` 等 `*.local.md` 是已忽略的本地笔记,不是构建依赖或正式文档入口;`.DS_Store` 是已忽略的 macOS Finder 元数据,可清理。
|
||||
|
||||
规范生成关系与命令:
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
"@modelcontextprotocol/core": "^2.0.0",
|
||||
"@modelcontextprotocol/server": "^2.0.0",
|
||||
"ky": "^2.0.2",
|
||||
"qrcode": "^1.5.4",
|
||||
"qrcode-terminal": "^0.12.0",
|
||||
"quickjs-emscripten-core": "0.32.0",
|
||||
"yaml": "^2.9.0",
|
||||
@@ -17,6 +18,7 @@
|
||||
"devDependencies": {
|
||||
"@modelcontextprotocol/client": "^2.0.0",
|
||||
"@types/bun": "^1.3.14",
|
||||
"@types/qrcode": "^1.5.6",
|
||||
"@types/qrcode-terminal": "^0.12.2",
|
||||
"typescript": "^5.9.3",
|
||||
},
|
||||
@@ -37,42 +39,102 @@
|
||||
|
||||
"@types/node": ["@types/node@25.8.0", "", { "dependencies": { "undici-types": ">=7.24.0 <7.24.7" } }, "sha512-TCFSk8IZh+iLX1xtksoBVtdmgL+1IX0fC9BeU4QqFSuNdN/K+HUlhqOzEmSYYpZUVsLYcPqc9KX+60iDuninSQ=="],
|
||||
|
||||
"@types/qrcode": ["@types/qrcode@1.5.6", "", { "dependencies": { "@types/node": "*" } }, "sha512-te7NQcV2BOvdj2b1hCAHzAoMNuj65kNBMz0KBaxM6c3VGBOhU0dURQKOtH8CFNI/dsKkwlv32p26qYQTWoB5bw=="],
|
||||
|
||||
"@types/qrcode-terminal": ["@types/qrcode-terminal@0.12.2", "", {}, "sha512-v+RcIEJ+Uhd6ygSQ0u5YYY7ZM+la7GgPbs0V/7l/kFs2uO4S8BcIUEMoP7za4DNIqNnUD5npf0A/7kBhrCKG5Q=="],
|
||||
|
||||
"ansi-regex": ["ansi-regex@5.0.1", "", {}, "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="],
|
||||
|
||||
"ansi-styles": ["ansi-styles@4.3.0", "", { "dependencies": { "color-convert": "^2.0.1" } }, "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg=="],
|
||||
|
||||
"bun-types": ["bun-types@1.3.14", "", { "dependencies": { "@types/node": "*" } }, "sha512-4N0ig0fEomHt5R0KCFWjovxow98rIoRwKolrYdCcknNwMekCXRnWEUvgu5soYV8QXtVsrUD8B95MBOZGPvr6KQ=="],
|
||||
|
||||
"camelcase": ["camelcase@5.3.1", "", {}, "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg=="],
|
||||
|
||||
"cliui": ["cliui@6.0.0", "", { "dependencies": { "string-width": "^4.2.0", "strip-ansi": "^6.0.0", "wrap-ansi": "^6.2.0" } }, "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ=="],
|
||||
|
||||
"color-convert": ["color-convert@2.0.1", "", { "dependencies": { "color-name": "~1.1.4" } }, "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ=="],
|
||||
|
||||
"color-name": ["color-name@1.1.4", "", {}, "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="],
|
||||
|
||||
"cross-spawn": ["cross-spawn@7.0.6", "", { "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" } }, "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA=="],
|
||||
|
||||
"decamelize": ["decamelize@1.2.0", "", {}, "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA=="],
|
||||
|
||||
"dijkstrajs": ["dijkstrajs@1.0.3", "", {}, "sha512-qiSlmBq9+BCdCA/L46dw8Uy93mloxsPSbwnm5yrKn2vMPiy8KyAskTF6zuV/j5BMsmOGZDPs7KjU+mjb670kfA=="],
|
||||
|
||||
"emoji-regex": ["emoji-regex@8.0.0", "", {}, "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A=="],
|
||||
|
||||
"eventsource": ["eventsource@3.0.7", "", { "dependencies": { "eventsource-parser": "^3.0.1" } }, "sha512-CRT1WTyuQoD771GW56XEZFQ/ZoSfWid1alKGDYMmkt2yl8UXrVR4pspqWNEcqKvVIzg6PAltWjxcSSPrboA4iA=="],
|
||||
|
||||
"eventsource-parser": ["eventsource-parser@3.0.8", "", {}, "sha512-70QWGkr4snxr0OXLRWsFLeRBIRPuQOvt4s8QYjmUlmlkyTZkRqS7EDVRZtzU3TiyDbXSzaOeF0XUKy8PchzukQ=="],
|
||||
|
||||
"find-up": ["find-up@4.1.0", "", { "dependencies": { "locate-path": "^5.0.0", "path-exists": "^4.0.0" } }, "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw=="],
|
||||
|
||||
"get-caller-file": ["get-caller-file@2.0.5", "", {}, "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg=="],
|
||||
|
||||
"is-fullwidth-code-point": ["is-fullwidth-code-point@3.0.0", "", {}, "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg=="],
|
||||
|
||||
"isexe": ["isexe@2.0.0", "", {}, "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw=="],
|
||||
|
||||
"jose": ["jose@6.2.3", "", {}, "sha512-YYVDInQKFJfR/xa3ojUTl8c2KoTwiL1R5Wg9YCydwH0x0B9grbzlg5HC7mMjCtUJjbQ/YnGEZIhI5tCgfTb4Hw=="],
|
||||
|
||||
"ky": ["ky@2.0.2", "", {}, "sha512-/GmXpo9F9W+f8n4Ivr2iH+7h7wL7jLbLKWkMlpflcCRb6kGjBfTlASEXaZ9qUgNTn4VgS0P2pwxxzQ4EM6Ulgg=="],
|
||||
|
||||
"locate-path": ["locate-path@5.0.0", "", { "dependencies": { "p-locate": "^4.1.0" } }, "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g=="],
|
||||
|
||||
"p-limit": ["p-limit@2.3.0", "", { "dependencies": { "p-try": "^2.0.0" } }, "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w=="],
|
||||
|
||||
"p-locate": ["p-locate@4.1.0", "", { "dependencies": { "p-limit": "^2.2.0" } }, "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A=="],
|
||||
|
||||
"p-try": ["p-try@2.2.0", "", {}, "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ=="],
|
||||
|
||||
"path-exists": ["path-exists@4.0.0", "", {}, "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w=="],
|
||||
|
||||
"path-key": ["path-key@3.1.1", "", {}, "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q=="],
|
||||
|
||||
"pkce-challenge": ["pkce-challenge@5.0.1", "", {}, "sha512-wQ0b/W4Fr01qtpHlqSqspcj3EhBvimsdh0KlHhH8HRZnMsEa0ea2fTULOXOS9ccQr3om+GcGRk4e+isrZWV8qQ=="],
|
||||
|
||||
"pngjs": ["pngjs@5.0.0", "", {}, "sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw=="],
|
||||
|
||||
"qrcode": ["qrcode@1.5.4", "", { "dependencies": { "dijkstrajs": "^1.0.1", "pngjs": "^5.0.0", "yargs": "^15.3.1" }, "bin": { "qrcode": "bin/qrcode" } }, "sha512-1ca71Zgiu6ORjHqFBDpnSMTR2ReToX4l1Au1VFLyVeBTFavzQnv5JxMFr3ukHVKpSrSA2MCk0lNJSykjUfz7Zg=="],
|
||||
|
||||
"qrcode-terminal": ["qrcode-terminal@0.12.0", "", { "bin": { "qrcode-terminal": "./bin/qrcode-terminal.js" } }, "sha512-EXtzRZmC+YGmGlDFbXKxQiMZNwCLEO6BANKXG4iCtSIM0yqc/pappSx3RIKr4r0uh5JsBckOXeKrB3Iz7mdQpQ=="],
|
||||
|
||||
"quickjs-emscripten-core": ["quickjs-emscripten-core@0.32.0", "", { "dependencies": { "@jitl/quickjs-ffi-types": "0.32.0" } }, "sha512-QFnPfjFey8EqknSrSxe1hZrf1/8z7/6s1QzGOmKo6++02r7QRRX7ZoyNaZh7JuVjWsVW87KnQrbZqnHkOAzUyg=="],
|
||||
|
||||
"require-directory": ["require-directory@2.1.1", "", {}, "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q=="],
|
||||
|
||||
"require-main-filename": ["require-main-filename@2.0.0", "", {}, "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg=="],
|
||||
|
||||
"set-blocking": ["set-blocking@2.0.0", "", {}, "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw=="],
|
||||
|
||||
"shebang-command": ["shebang-command@2.0.0", "", { "dependencies": { "shebang-regex": "^3.0.0" } }, "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA=="],
|
||||
|
||||
"shebang-regex": ["shebang-regex@3.0.0", "", {}, "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A=="],
|
||||
|
||||
"string-width": ["string-width@4.2.3", "", { "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", "strip-ansi": "^6.0.1" } }, "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g=="],
|
||||
|
||||
"strip-ansi": ["strip-ansi@6.0.1", "", { "dependencies": { "ansi-regex": "^5.0.1" } }, "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A=="],
|
||||
|
||||
"typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
|
||||
|
||||
"undici-types": ["undici-types@7.24.6", "", {}, "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg=="],
|
||||
|
||||
"which": ["which@2.0.2", "", { "dependencies": { "isexe": "^2.0.0" }, "bin": { "node-which": "./bin/node-which" } }, "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA=="],
|
||||
|
||||
"which-module": ["which-module@2.0.1", "", {}, "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ=="],
|
||||
|
||||
"wrap-ansi": ["wrap-ansi@6.2.0", "", { "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", "strip-ansi": "^6.0.0" } }, "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA=="],
|
||||
|
||||
"y18n": ["y18n@4.0.3", "", {}, "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ=="],
|
||||
|
||||
"yaml": ["yaml@2.9.0", "", { "bin": { "yaml": "bin.mjs" } }, "sha512-2AvhNX3mb8zd6Zy7INTtSpl1F15HW6Wnqj0srWlkKLcpYl/gMIMJiyuGq2KeI2YFxUPjdlB+3Lc10seMLtL4cA=="],
|
||||
|
||||
"yargs": ["yargs@15.4.1", "", { "dependencies": { "cliui": "^6.0.0", "decamelize": "^1.2.0", "find-up": "^4.1.0", "get-caller-file": "^2.0.1", "require-directory": "^2.1.1", "require-main-filename": "^2.0.0", "set-blocking": "^2.0.0", "string-width": "^4.2.0", "which-module": "^2.0.0", "y18n": "^4.0.0", "yargs-parser": "^18.1.2" } }, "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A=="],
|
||||
|
||||
"yargs-parser": ["yargs-parser@18.1.3", "", { "dependencies": { "camelcase": "^5.0.0", "decamelize": "^1.2.0" } }, "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ=="],
|
||||
|
||||
"zod": ["zod@4.4.3", "", {}, "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ=="],
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"mcpServers": {
|
||||
"hose-use": {
|
||||
"type": "stdio",
|
||||
"command": "bun",
|
||||
"args": [
|
||||
"${CLAUDE_PLUGIN_ROOT}/dist/mcp/server.js"
|
||||
],
|
||||
"env": {
|
||||
"HOSE_USE_MCP_ENABLED": "${user_config.enable_mcp}"
|
||||
},
|
||||
"timeoutMs": 120000
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,7 @@
|
||||
"@modelcontextprotocol/core": "^2.0.0",
|
||||
"@modelcontextprotocol/server": "^2.0.0",
|
||||
"ky": "^2.0.2",
|
||||
"qrcode": "^1.5.4",
|
||||
"qrcode-terminal": "^0.12.0",
|
||||
"quickjs-emscripten-core": "0.32.0",
|
||||
"yaml": "^2.9.0",
|
||||
@@ -57,6 +58,7 @@
|
||||
"devDependencies": {
|
||||
"@modelcontextprotocol/client": "^2.0.0",
|
||||
"@types/bun": "^1.3.14",
|
||||
"@types/qrcode": "^1.5.6",
|
||||
"@types/qrcode-terminal": "^0.12.2",
|
||||
"typescript": "^5.9.3"
|
||||
}
|
||||
|
||||
@@ -22,13 +22,13 @@ function run(command, commandArgs) {
|
||||
|
||||
try {
|
||||
// Explicit package inputs keep credentials, local notes and dependencies out of the archive.
|
||||
for (const path of [".zcode-plugin/plugin.json", ".mcp.json", "skills"]) {
|
||||
for (const path of [".zcode-plugin/plugin.json", "mcp.json", "skills"]) {
|
||||
cpSync(join(root, path), join(stage, path), { recursive: true });
|
||||
}
|
||||
// Always build from current source; never package a stale local dist/ bundle.
|
||||
run(process.execPath, [join(root, "scripts/build/build-plugin.mjs"), `--outfile=${join(stage, "dist/mcp/server.js")}`]);
|
||||
mkdirSync(outputDir, { recursive: true });
|
||||
run("tar", ["-czf", archive, "-C", stage, ".zcode-plugin", ".mcp.json", "skills", "dist"]);
|
||||
run("tar", ["-czf", archive, "-C", stage, ".zcode-plugin", "mcp.json", "skills", "dist"]);
|
||||
console.log(`✓ Packaged plugin: ${archive}`);
|
||||
} finally {
|
||||
rmSync(stage, { recursive: true, force: true });
|
||||
|
||||
@@ -17,7 +17,7 @@ test("source and freshly packaged plugin preserve offline review and MCP contrac
|
||||
mkdirSync(pluginRoot);
|
||||
const extracted = Bun.spawnSync(["tar", "-xzf", archive, "-C", pluginRoot]);
|
||||
expect(extracted.exitCode, extracted.stderr.toString()).toBe(0);
|
||||
expect(readdirSync(pluginRoot).sort()).toEqual([".mcp.json", ".zcode-plugin", "dist", "skills"]);
|
||||
expect(readdirSync(pluginRoot).sort()).toEqual([".zcode-plugin", "dist", "mcp.json", "skills"]);
|
||||
const manifest = JSON.parse(readFileSync(join(pluginRoot, ".zcode-plugin/plugin.json"), "utf8"));
|
||||
expect(manifest.version).toBe(version);
|
||||
expect(manifest.skills).toBe("skills");
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
// ==============================================================================
|
||||
// 合思代码节点 (MVEL): 单据日期/日期范围字段转化为具体时间字符串与时间戳
|
||||
// ==============================================================================
|
||||
|
||||
// ── 1. 配置区(按需修改)───────────────────────────────────────────────────────
|
||||
// (1) 前置工作流节点 ID(例如:第2步单据详情节点 action_pfsq28)
|
||||
upstreamNode = action_pfsq28;
|
||||
|
||||
// (2) 需要转化的单据层面字段 ID(例如标准起止日期 "feeDatePeriod",或自定义字段 "u_出差起止日期")
|
||||
dateFieldKey = "feeDatePeriod";
|
||||
|
||||
// ── 2. 字段取值与防御提取 ──────────────────────────────────────────────────────
|
||||
fieldVal = null;
|
||||
if (upstreamNode != null) {
|
||||
fieldVal = upstreamNode.get(dateFieldKey);
|
||||
if (fieldVal == null && upstreamNode.get("form") != null) {
|
||||
fieldVal = upstreamNode.get("form").get(dateFieldKey);
|
||||
}
|
||||
}
|
||||
|
||||
rawStart = null;
|
||||
rawEnd = null;
|
||||
|
||||
if (fieldVal != null) {
|
||||
if (fieldVal instanceof java.util.Map) {
|
||||
rawStart = fieldVal.get("start");
|
||||
rawEnd = fieldVal.get("end");
|
||||
} else {
|
||||
rawStart = fieldVal;
|
||||
}
|
||||
}
|
||||
|
||||
// ── 3. 初始化日期格式化器(强制北京时间 GMT+8) ────────────────────────────────
|
||||
tz = java.util.TimeZone.getTimeZone("GMT+8");
|
||||
|
||||
sdfSecond = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
sdfSecond.setTimeZone(tz);
|
||||
|
||||
sdfMinute = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
sdfMinute.setTimeZone(tz);
|
||||
|
||||
sdfDay = new java.text.SimpleDateFormat("yyyy-MM-dd");
|
||||
sdfDay.setTimeZone(tz);
|
||||
|
||||
// ── 4. 转换开始时间 (start) ───────────────────────────────────────────────────
|
||||
startStr = "";
|
||||
startMinute = "";
|
||||
startDay = "";
|
||||
startMs = 0L;
|
||||
startSec = 0L;
|
||||
dStart = null;
|
||||
|
||||
if (rawStart != null && String.valueOf(rawStart).trim() != "") {
|
||||
startMs = java.lang.Long.parseLong(String.valueOf(rawStart).trim());
|
||||
if (startMs < 10000000000L) {
|
||||
startMs = startMs * 1000L;
|
||||
}
|
||||
startSec = startMs / 1000L;
|
||||
dStart = new java.util.Date(startMs);
|
||||
startStr = sdfSecond.format(dStart);
|
||||
startMinute = sdfMinute.format(dStart);
|
||||
startDay = sdfDay.format(dStart);
|
||||
}
|
||||
|
||||
// ── 5. 转换结束时间 (end) ─────────────────────────────────────────────────────
|
||||
endStr = "";
|
||||
endMinute = "";
|
||||
endDay = "";
|
||||
endMs = 0L;
|
||||
endSec = 0L;
|
||||
dEnd = null;
|
||||
|
||||
if (rawEnd != null && String.valueOf(rawEnd).trim() != "") {
|
||||
endMs = java.lang.Long.parseLong(String.valueOf(rawEnd).trim());
|
||||
if (endMs < 10000000000L) {
|
||||
endMs = endMs * 1000L;
|
||||
}
|
||||
endSec = endMs / 1000L;
|
||||
dEnd = new java.util.Date(endMs);
|
||||
endStr = sdfSecond.format(dEnd);
|
||||
endMinute = sdfMinute.format(dEnd);
|
||||
endDay = sdfDay.format(dEnd);
|
||||
}
|
||||
|
||||
// ── 6. 组合区间显示文本 ───────────────────────────────────────────────────────
|
||||
rangeMinuteStr = "";
|
||||
rangeSecondStr = "";
|
||||
if (startMinute != "" && endMinute != "") {
|
||||
rangeMinuteStr = startMinute + " ~ " + endMinute;
|
||||
rangeSecondStr = startStr + " ~ " + endStr;
|
||||
} else if (startMinute != "") {
|
||||
rangeMinuteStr = startMinute;
|
||||
rangeSecondStr = startStr;
|
||||
}
|
||||
|
||||
// ── 7. 组装返回结果 ───────────────────────────────────────────────────────────
|
||||
result = new java.util.HashMap();
|
||||
|
||||
// 开始时间 / 单个时间
|
||||
result.put("startTimeStr", startStr); // 如: "2026-11-19 20:59:00"
|
||||
result.put("startTimeMinute", startMinute); // 如: "2026-11-19 20:59"
|
||||
result.put("startDate", startDay); // 如: "2026-11-19"
|
||||
result.put("startTimestampMs", startMs); // 毫秒时间戳 (Long)
|
||||
result.put("startTimestampSec", startSec); // 秒时间戳 (Long)
|
||||
|
||||
// 结束时间
|
||||
result.put("endTimeStr", endStr); // 如: "2026-11-20 16:55:00"
|
||||
result.put("endTimeMinute", endMinute); // 如: "2026-11-20 16:55"
|
||||
result.put("endDate", endDay); // 如: "2026-11-20"
|
||||
result.put("endTimestampMs", endMs); // 毫秒时间戳 (Long)
|
||||
result.put("endTimestampSec", endSec); // 秒时间戳 (Long)
|
||||
|
||||
// 区间文本(方便下游直接放入 comment 或通知)
|
||||
result.put("rangeMinuteStr", rangeMinuteStr); // 如: "2026-11-19 20:59 ~ 2026-11-20 16:55"
|
||||
result.put("rangeSecondStr", rangeSecondStr); // 如: "2026-11-19 20:59:00 ~ 2026-11-20 16:55:00"
|
||||
|
||||
// 兼容单日期直接取用别名
|
||||
result.put("formattedTime", startStr);
|
||||
result.put("formattedMinute", startMinute);
|
||||
result.put("timestampMs", startMs);
|
||||
result.put("timestampSec", startSec);
|
||||
|
||||
return result;
|
||||
@@ -136,7 +136,14 @@ describe("release preparation and publication guards", () => {
|
||||
expect(runs.some((s: string) => s.includes("verify-release.ts"))).toBe(true);
|
||||
expect(runs.some((s: string) => s.includes("sha256sum hose-use-* > checksums.txt"))).toBe(true);
|
||||
for (const step of [...ci.jobs.validate.steps, ...steps]) if (step.uses) expect(step.uses).toMatch(/@[a-f0-9]{40}$/);
|
||||
expect(JSON.parse(readFileSync(join(root, ".mcp.json"), "utf8")).mcpServers["hose-use"].command).toBe("bun");
|
||||
const pluginMcp = JSON.parse(readFileSync(join(root, "mcp.json"), "utf8")).mcpServers["hose-use"];
|
||||
expect(pluginMcp.command).toBe("bun");
|
||||
expect(pluginMcp.args[0]).toContain("${CLAUDE_PLUGIN_ROOT}");
|
||||
const projectMcp = JSON.parse(readFileSync(join(root, ".mcp.json"), "utf8")).mcpServers["hose-use"];
|
||||
expect(projectMcp.command).toBe("bun");
|
||||
expect(projectMcp.args).toEqual(["src/server.ts"]);
|
||||
expect(JSON.stringify(projectMcp)).not.toContain("${CLAUDE_PLUGIN_ROOT}");
|
||||
expect(JSON.stringify(projectMcp)).not.toContain("${user_config");
|
||||
expect(release.on.workflow_dispatch.inputs.mirror_only.type).toBe("boolean");
|
||||
for (const name of ["Compile multi-target binaries", "Package plugin archive", "Package release archives", "Publish GitHub Release"]) {
|
||||
expect(steps.find((s: { name?: string }) => s.name === name).if).toBe("${{ !inputs.mirror_only }}");
|
||||
|
||||
@@ -39,6 +39,7 @@ metadata:
|
||||
- 面对单据明细、实体字典、工作流等大数据量查询,优先使用 `--json -o <path>` 本地转储或使用 `--limit` 限制分页;
|
||||
- 严禁盲目使用 `--full` 将上万行原始报文一次性塞入上下文;
|
||||
- 永远解析 JSON stdout,不要从格式化表格的终端字符中正则刮取数据。
|
||||
- **扫码登录交互**:在执行扫码登录 (`login --qr`) 时,Agent 必须主动监控终端输出。一旦识别出二维码已保存(如提示 “💡 二维码已自动保存至: ...”),Agent **必须立即且自动**调用 `SendUserFile` 将该二维码图片渲染给用户查看,严禁等待用户主动提示。
|
||||
4. **密钥安全**:`keys` 默认在表格和 JSON 中脱敏 `appSecurity`;只有用户明确需要完整凭证时才使用 `--reveal`/`-r`。不要把明文密钥写入日志、共享文件、提示词或聊天回复;尤其不要组合 `--reveal -o <path>`。
|
||||
5. **无状态与并发安全**:Agent 在自动化批处理或会话中,建议使用无状态模式(添加 `--stateless` 或显式指定 `--corp=<id>`),避免多任务并发切换全局状态发生冲突。
|
||||
6. **写操作两阶段确认**:所有 CLI 写操作先使用 `--dry-run` 查看目标和变更,再使用同一命令追加 `--yes` 或 `--confirm` 执行;未确认时不会发起写请求或写入本地状态。
|
||||
@@ -97,6 +98,15 @@ metadata:
|
||||
2. 关键词检索:`hose-use docs search <关键词> [--category=<分类>] [--json]`(毫秒级获取接口清单与废弃标记);
|
||||
3. 单篇精细查阅:`hose-use docs show <Path|URL|名称> [--json]`(获取官方完整参数规格、类型约束与 CURL 示例);
|
||||
- 细节查阅专属参考文档:[references/docs.md](./references/docs.md)。
|
||||
19. **三大凭证通道矩阵与人工直通链接守则 (Three-Tier Credential Channels & Passwordless Direct Links)**:
|
||||
- **通道 A:企业 OpenAPI 持久化凭证 (`appKey` + `appSecurity`)**:企业级永久凭证,永不过期。当用户/开发者提出“生成免密链接 / 去界面人工 review / 看看画布”等直达需求时,**第一首选动作**是调用 `hose-use corps link <corpId>` 或 `hose-use workflow link <pipelineId>`。底层通过 `getProvisionalAuth` 动态签发带安全签名的 Web 直达 URL(`thirdparty.html?accessToken=...` 或直接带 EASO JWT 的 Piper 画布链接),任意浏览器点开即免密登录!
|
||||
- **通道 B:用户个人会话凭证 (`userAuthToken` / `cloudAuthToken`)**:个人会话凭证(手机验证码/密码),存在 TTL。供 CLI 在终端执行 API 读写、单据查询、调测。
|
||||
- **通道 C:协助运营平台工单会话 (`assist-platform`)**:合思官方技术支持(实施/客服)跨企业工单流转平台(Unity)。仅限在处理客户授权工单流转时使用(`assist-platform transfer` / `assist-platform list`),**严禁**直接向用户丢出未签名的 Unity 运营平台登录页让用户手动登录。
|
||||
- **非冲突双轨共存**:企业即便通过用户个人凭证登录,如果本地已配置过自建应用的 `appKey` / `appSecurity`,两者完全互不冲突、协同工作。
|
||||
20. **工作流节点 Schema 规范与前端图标降级防范 (Workflow Node Schema & Fallback Trap)**:
|
||||
- 合思前端微前端设计器(Piper)将节点图标分为 `action`(基础通用)与 `control`(控制节点:仅包含 condition、every、while、loop、if)两套硬编码字典;
|
||||
- **终止节点 (`stop`) 必须标记为 `groupName: "action"`**(归属基础通用);若错误标记为 `control`,前端在控制字典查无此项时会触发 Fallback 降级,被强行渲染为灰色通用工具扳手(`[🔧]` `OutlinedGeneralTool`);只有保持 `groupName: "action"` 才会正常渲染为官方红色禁止标(`[⛔]` `OutlinedTipsNo`)。
|
||||
- **代码节点 (`code` / `code-js2`)** 同样归属于 `action`。
|
||||
|
||||
---
|
||||
|
||||
@@ -316,6 +326,7 @@ hose-use docs sync # 强制与 docs.ekuaib
|
||||
|
||||
## 全局选项
|
||||
|
||||
- `--timeout`, `-T <seconds>`:命令全局超时时间,超时后自动终止运行。
|
||||
- `--corp=<id>`:临时指定操作的企业 ID(单次覆盖默认企业)
|
||||
- `--json`, `-j`:以标准 JSON 结构化输出结果
|
||||
- `--output-file, -o <path>`:将结果直接安全写入本地文件,仅返回精简摘要
|
||||
|
||||
@@ -158,3 +158,22 @@ Treat tenant-specific behavior as evidence, not a universal rule. Say what assum
|
||||
- **Deploy to workflow node**: `hose-use workflow node edit <pipelineId> <nodeName> --code-file=./scripts/node_calc.mvel --yes`
|
||||
- **End-to-end cloud simulation test**: `hose-use workflow test <pipelineId> --flow <billCode> --yes --force`
|
||||
|
||||
## 沙箱调试绝佳技巧:终止节点物理断点与样本固化 (Stop Barrier & Sample Pinning)
|
||||
|
||||
在真实业务流程(尤其包含单据驳回、审批通过、企微/钉钉消息推送、台账更新等危险副作用)中调测新增的代码节点时,强烈建议采用**紧随终止节点 (Stop Node Barrier)** 模式:
|
||||
|
||||
```text
|
||||
[前置查询/触发节点] ──> [新代码节点 (MVEL)] ──> [临时终止节点 (stop)] ──x (下游循环/驳回/审批被彻底物理隔离)
|
||||
```
|
||||
|
||||
### 1. 为什么必须紧随终止节点?
|
||||
1. **防止业务穿透与脏数据(安全第一)**:调试执行由云端真实引擎运行。若不设断点,引擎向下执行一旦命中驳回 HTTP 节点或审批同意,会向真实系统发起调用;紧随插入一个 `stop` 节点可形成绝对安全隔离,执行到代码节点后即刻安全着陆。
|
||||
2. **纯净捕获真实出参**:在安全阻断的同时,当次调试 Job 的 `executionTree` 产物中能完整记录新代码节点的实际返回值(`output`),验证数据精度与格式。
|
||||
|
||||
### 2. 保存样本数据 (Sample Pinning) 赋能设计器下拉树
|
||||
代码节点在没有样本数据(`sampleData`)前,下游节点在合思设计器中打开「引用字段」下拉菜单时**无法识别其输出属性**。
|
||||
- **固化样本**:调试成功后,将当次执行的 `output` 一键回写为该节点的 `sampleData`(如使用 `hose-use workflow test ... --save-sample` 或 `workflow node sample-save`);
|
||||
- **设计器自动解析**:一旦保存样本,合思工作流会自动为该代码节点生成选择器树(chooses),后续人工在配置下游驳回、条件或消息节点时,即可在界面下拉树中直接点选其格式化变量(如 `startTimeMinute`, `rangeMinuteStr`);
|
||||
- **调试后清理**:业务验证并完成下游表达式配置后,在界面上手动删除该临时的终止节点即可。
|
||||
|
||||
|
||||
@@ -352,6 +352,13 @@ hose-use workflow node edit <pipelineId> 2 --set="method=GET" --yes
|
||||
hose-use workflow node rm <pipelineId> action_dx9cci --dry-run
|
||||
hose-use workflow node rm <pipelineId> action_dx9cci --yes
|
||||
hose-use workflow node rm <pipelineId> 3 --yes
|
||||
|
||||
# 6. 只读探针与样本数据固化 (inspect / sample-save)
|
||||
# 定向透视指定节点的固化样本数据 (sampleData) 以及最近一次调试执行出参 (execution output)
|
||||
hose-use workflow node inspect <pipelineId> <nodeName>
|
||||
|
||||
# 将最近一次调测出参一键固化为 sampleData,使设计器下游节点可自动解析其选择器树 (chooses)
|
||||
hose-use workflow node sample-save <pipelineId> <nodeName> --yes
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
+19
-2
@@ -15,6 +15,23 @@ process.stderr.on("error", (err: any) => {
|
||||
const entryFile = fileURLToPath(import.meta.url);
|
||||
const appRoot = dirname(dirname(entryFile));
|
||||
|
||||
// 命令行参数超时处理:--timeout [秒] / -T [秒]
|
||||
const args = process.argv.slice(2);
|
||||
for (let i = args.length - 1; i >= 0; i--) {
|
||||
if (args[i] === "--timeout" || args[i] === "-T") {
|
||||
if (i + 1 < args.length) {
|
||||
const timeoutSec = parseInt(args[i + 1], 10);
|
||||
if (!isNaN(timeoutSec) && timeoutSec > 0) {
|
||||
setTimeout(() => {
|
||||
console.error(`[ERROR] 命令执行超时 (${timeoutSec}秒)`);
|
||||
process.exit(1);
|
||||
}, timeoutSec * 1000);
|
||||
}
|
||||
args.splice(i, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Unix Multicall Binary Pattern: 检测是否通过 hose-aipro 符号链接/别名唤起
|
||||
const candidates = [process.argv0, process.argv[1], process.argv[0]].filter(Boolean) as string[];
|
||||
const isAiPro = candidates.some((c) => {
|
||||
@@ -23,8 +40,8 @@ const isAiPro = candidates.some((c) => {
|
||||
});
|
||||
|
||||
const result = isAiPro
|
||||
? await (await import("./aipro-cli.js")).runAiProCli(process.argv.slice(2))
|
||||
: await runCli(process.argv.slice(2), {
|
||||
? await (await import("./aipro-cli.js")).runAiProCli(args)
|
||||
: await runCli(args, {
|
||||
appRoot,
|
||||
entryFile,
|
||||
writeStdout: writeStdoutChunk,
|
||||
|
||||
@@ -340,7 +340,7 @@ export const COMMAND_METADATA: Record<string, CliCommandMetadata> = {
|
||||
"outbound-message": "outbound"
|
||||
},
|
||||
|
||||
flags: { ...flagList("all allow-prod allow-production auto-publish autoPublish compare detail diff empty errors f fail fail-on-alert failOnAlert failed failed-only failedOnly follow force force-write forceWrite full has-error hasError in-place inPlace includeDetail is-test json none once publish snapshot v value-json valueJson verbose with-tasks withTasks timeline progress steps", "boolean"), ...flagList("a admin-key adminKey after app app-id appId b bill body c choose-serialization code code-file container count d data desc description display display-name displayName end-time endTime entity execution-logs field file filter flow flow-code flowCode from i id input input-file insert-after interval job job-id job1 job2 jobA jobB jobId json-file keyword l label limit log logs mapping mapping-file max-jobs maxJobs max-pages maxPages message-type n name node node-id nodeId nodes offset output output-file outputFile p page page-limit page-size pageSize parent parent-id parentId password path payload pipeline pipeline-id pipelineId platform platform-id platformId pwd q query record s sample sample-id sampleId seconds set size sleep-time sleepTime sn snapshot1 snapshot2 snapshotA snapshotB source start start-time startTime state state-file stateFile t target targetName targetPlatformId task taskType third-id thirdId timeout timeout-ms timeoutMs to trigger type types value workflowId", "value") }
|
||||
flags: { ...flagList("all allow-prod allow-production auto-publish autoPublish compare detail diff empty errors f fail fail-on-alert failOnAlert failed failed-only failedOnly follow force force-write forceWrite full has-error hasError in-place inPlace includeDetail is-test json none once publish save-sample saveSample save-samples saveSamples snapshot v value-json valueJson verbose with-tasks withTasks timeline progress steps", "boolean"), ...flagList("a admin-key adminKey after app app-id appId b bill body c choose-serialization code code-file container count d data desc description display display-name displayName end-time endTime entity execution-logs field file filter flow flow-code flowCode from i id input input-file insert-after interval job job-id job1 job2 jobA jobB jobId json-file keyword l label limit log logs mapping mapping-file max-jobs maxJobs max-pages maxPages message-type n name node node-id nodeId nodes offset output output-file outputFile p page page-limit page-size pageSize parent parent-id parentId password path payload pipeline pipeline-id pipelineId platform platform-id platformId pwd q query record s sample sample-id sampleId seconds set size sleep-time sleepTime sn snapshot1 snapshot2 snapshotA snapshotB source start start-time startTime state state-file stateFile t target targetName targetPlatformId task taskType third-id thirdId timeout timeout-ms timeoutMs to trigger type types value workflowId", "value") }
|
||||
|
||||
},
|
||||
"bill": {
|
||||
|
||||
@@ -11,6 +11,9 @@ import {
|
||||
import { booleanOption, stringOption } from "../../parser.js";
|
||||
import { printJson, printKeyValue } from "../../printer.js";
|
||||
import type { CliParsedArgs, CliResult, CliRuntime } from "../../types.js";
|
||||
// ... other imports ...
|
||||
import os from "os";
|
||||
import path from "path";
|
||||
|
||||
export async function handleLogin(
|
||||
parsed: CliParsedArgs,
|
||||
@@ -184,6 +187,18 @@ export async function handleLogin(
|
||||
process.stdout.write(`\n====== 合思协助平台钉钉扫码登录 ======\n`);
|
||||
process.stdout.write(`请使用钉钉 App 扫描下方二维码确认登录(有效期 60 秒):\n\n`);
|
||||
process.stdout.write(`${qrText}\n\n`);
|
||||
|
||||
// 自动保存二维码
|
||||
const downloadsDir = path.join(os.homedir(), "Downloads");
|
||||
const qrPath = path.join(downloadsDir, "dingtalk-login.png");
|
||||
(async () => {
|
||||
const QRCode = await import("qrcode");
|
||||
await QRCode.toFile(qrPath, dingUrl);
|
||||
process.stdout.write(`💡 二维码已自动保存至: ${qrPath}\n\n`);
|
||||
})().catch((e: Error) => {
|
||||
process.stdout.write(`[WARN] 自动保存二维码失败: ${e.message}\n\n`);
|
||||
});
|
||||
|
||||
process.stdout.write(`🔗 快捷授权链接: ${dingUrl}\n\n`);
|
||||
process.stdout.write(`等待钉钉扫码并确认中... (最长等待 60 秒)\n`);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,478 @@
|
||||
import { describe, it, expect, beforeEach, afterEach, spyOn } from "bun:test";
|
||||
import { handleWorkflowCommand } from "./workflow/index.js";
|
||||
import * as helpers from "./workflow/shared.js";
|
||||
import { CorpContext } from "../../core/config/manager.js";
|
||||
import type { CorpConfig } from "../../core/config/types.js";
|
||||
import type { CliRuntime } from "../types.js";
|
||||
|
||||
const mockCorp: CorpConfig = {
|
||||
id: "ID01ofWoOC1wiX",
|
||||
name: "沈玥妍测试企业",
|
||||
baseUrl: "https://app.ekuaibao.com",
|
||||
cluster: "app",
|
||||
source: "link",
|
||||
credentials: {
|
||||
accessToken: "test-token",
|
||||
corpId: "ID01ofWoOC1wiX",
|
||||
staffId: "ID01ofWoOC1wiX:ID01KsDgHaH5nN",
|
||||
},
|
||||
env: "test",
|
||||
isTest: true,
|
||||
};
|
||||
|
||||
describe("CLI - workflow node inspect 与 sample-save (只读探针与样本一键固化)", () => {
|
||||
let spies: any[] = [];
|
||||
let mockRuntime: CliRuntime;
|
||||
|
||||
beforeEach(() => {
|
||||
spies = [];
|
||||
const corpContext = new CorpContext([mockCorp], { stateful: true, defaultCorpId: mockCorp.id });
|
||||
mockRuntime = {
|
||||
corpContext,
|
||||
selectedCorp: mockCorp,
|
||||
jsonMode: false,
|
||||
outputOptions: {},
|
||||
};
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
for (const spy of spies) {
|
||||
spy.mockRestore();
|
||||
}
|
||||
spies = [];
|
||||
});
|
||||
|
||||
it("workflow node inspect: 成功透视节点配置、已存样本与历史调试出参", async () => {
|
||||
const mockTasks = [
|
||||
{
|
||||
name: "trigger_1",
|
||||
type: "ekuaibao-ebot-trigger",
|
||||
label: "EBOT触发",
|
||||
orderIndex: 0,
|
||||
levelIndex: [0],
|
||||
status: "active",
|
||||
},
|
||||
{
|
||||
name: "action_calc_1",
|
||||
type: "code",
|
||||
label: "代码节点",
|
||||
displayName: "时间转换节点",
|
||||
orderIndex: 1,
|
||||
levelIndex: [1],
|
||||
status: "active",
|
||||
code: "result = ['minute': '2026-11-19 20:59'];\nreturn result;",
|
||||
sampleData: {
|
||||
minute: "2026-11-19 20:59",
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const mockDetail = {
|
||||
id: "wf_inspect_test",
|
||||
label: "测试工作流",
|
||||
state: 0,
|
||||
tasks: mockTasks,
|
||||
};
|
||||
|
||||
const mockExecutionTree = [
|
||||
{
|
||||
id: "exec_1",
|
||||
name: "action_calc_1",
|
||||
status: "COMPLETED",
|
||||
executionTime: 8,
|
||||
output: {
|
||||
minute: "2026-11-19 20:59",
|
||||
timestampMs: 1795093140000,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const mockClient = {
|
||||
get: (url: string) => {
|
||||
if (url.includes("api/easo/pipelines/wf_inspect_test/log")) {
|
||||
return {
|
||||
text: async () => JSON.stringify({ code: 200 }),
|
||||
json: async () => ({
|
||||
code: 200,
|
||||
data: {
|
||||
totalCount: 1,
|
||||
items: [{ id: "job_test_100", status: "COMPLETED" }],
|
||||
},
|
||||
}),
|
||||
};
|
||||
}
|
||||
if (url.includes("api/easo/pipelines/wf_inspect_test")) {
|
||||
return {
|
||||
text: async () => JSON.stringify({ code: 200 }),
|
||||
json: async () => ({ code: 200, data: mockDetail }),
|
||||
};
|
||||
}
|
||||
if (url.includes("api/easo/jobs/job_test_100/execution")) {
|
||||
return {
|
||||
text: async () => JSON.stringify({ code: 200 }),
|
||||
json: async () => ({ code: 200, data: mockExecutionTree }),
|
||||
};
|
||||
}
|
||||
return {
|
||||
text: async () => JSON.stringify({ code: 200 }),
|
||||
json: async () => ({ code: 200, data: null }),
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
spies.push(
|
||||
spyOn(helpers, "createWorkflowDetailClient").mockResolvedValue({
|
||||
client: mockClient as any,
|
||||
clients: {} as any,
|
||||
platformId: undefined,
|
||||
})
|
||||
);
|
||||
|
||||
// 1. 终端文本透视
|
||||
const resText = await handleWorkflowCommand(
|
||||
{
|
||||
area: "workflow",
|
||||
action: "node",
|
||||
args: ["inspect", "wf_inspect_test", "action_calc_1"],
|
||||
options: {},
|
||||
raw: ["workflow", "node", "inspect", "wf_inspect_test", "action_calc_1"],
|
||||
},
|
||||
mockRuntime
|
||||
);
|
||||
|
||||
expect(resText.exitCode).toBe(0);
|
||||
expect(resText.stdout).toContain("工作流节点只读探针");
|
||||
expect(resText.stdout).toContain("action_calc_1");
|
||||
expect(resText.stdout).toContain("时间转换节点");
|
||||
expect(resText.stdout).toContain("已固化样本");
|
||||
expect(resText.stdout).toContain("最近一次调试执行出参");
|
||||
expect(resText.stdout).toContain("job_test_100");
|
||||
expect(resText.stdout).toContain("1795093140000");
|
||||
|
||||
// 2. JSON 模式结构化输出
|
||||
mockRuntime.jsonMode = true;
|
||||
const resJson = await handleWorkflowCommand(
|
||||
{
|
||||
area: "workflow",
|
||||
action: "node",
|
||||
args: ["inspect", "wf_inspect_test", "action_calc_1"],
|
||||
options: {},
|
||||
raw: ["workflow", "node", "inspect", "wf_inspect_test", "action_calc_1", "--json"],
|
||||
},
|
||||
mockRuntime
|
||||
);
|
||||
|
||||
expect(resJson.exitCode).toBe(0);
|
||||
const parsedJson = JSON.parse(resJson.stdout);
|
||||
expect(parsedJson.sampleData.minute).toBe("2026-11-19 20:59");
|
||||
expect(parsedJson.executionProbe.jobId).toBe("job_test_100");
|
||||
expect(parsedJson.executionProbe.output.timestampMs).toBe(1795093140000);
|
||||
});
|
||||
|
||||
it("workflow node sample-save: 支持 dry-run 预览并一键固化出参至节点 sampleData", async () => {
|
||||
let savedTasks: any = null;
|
||||
let choosesRefreshed = false;
|
||||
|
||||
const mockTasks = [
|
||||
{
|
||||
name: "action_target_node",
|
||||
type: "code",
|
||||
label: "代码节点",
|
||||
orderIndex: 0,
|
||||
levelIndex: [0],
|
||||
status: "active",
|
||||
},
|
||||
];
|
||||
|
||||
const mockDetail = {
|
||||
id: "wf_save_sample_test",
|
||||
label: "样本固化测试流",
|
||||
version: "1.0.0",
|
||||
tasksVersion: 1,
|
||||
state: 0,
|
||||
tasks: mockTasks,
|
||||
};
|
||||
|
||||
const mockExecutionTree = [
|
||||
{
|
||||
id: "exec_node_target",
|
||||
name: "action_target_node",
|
||||
status: "COMPLETED",
|
||||
output: {
|
||||
formattedDate: "2026-11-24 11:30",
|
||||
rangeSec: "2026-11-24 11:30:00 ~ 2026-11-24 12:00:00",
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const mockClient = {
|
||||
get: (url: string) => {
|
||||
if (url.includes("api/easo/pipelines/wf_save_sample_test")) {
|
||||
return { json: async () => ({ code: 200, data: mockDetail }) };
|
||||
}
|
||||
if (url.includes("api/easo/jobs/job_custom_999/execution")) {
|
||||
return { json: async () => ({ code: 200, data: mockExecutionTree }) };
|
||||
}
|
||||
return { json: async () => ({ code: 200, data: null }) };
|
||||
},
|
||||
put: (url: string, opts: any) => {
|
||||
if (url.endsWith("/chooses")) {
|
||||
choosesRefreshed = true;
|
||||
return {
|
||||
text: async () => JSON.stringify({ code: 200, data: [] }),
|
||||
json: async () => ({ code: 200, data: [] }),
|
||||
};
|
||||
}
|
||||
if (url.includes("api/easo/pipelines/wf_save_sample_test")) {
|
||||
savedTasks = opts.json.tasks;
|
||||
return {
|
||||
text: async () =>
|
||||
JSON.stringify({
|
||||
code: 200,
|
||||
data: {
|
||||
...mockDetail,
|
||||
...opts.json,
|
||||
tasksVersion: 2,
|
||||
},
|
||||
}),
|
||||
json: async () => ({
|
||||
code: 200,
|
||||
data: {
|
||||
...mockDetail,
|
||||
...opts.json,
|
||||
tasksVersion: 2,
|
||||
},
|
||||
}),
|
||||
};
|
||||
}
|
||||
return {
|
||||
text: async () => JSON.stringify({ code: 200, data: null }),
|
||||
json: async () => ({ code: 200, data: null }),
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
spies.push(
|
||||
spyOn(helpers, "createWorkflowDetailClient").mockResolvedValue({
|
||||
client: mockClient as any,
|
||||
clients: {} as any,
|
||||
platformId: undefined,
|
||||
})
|
||||
);
|
||||
|
||||
// 1. Dry-run 预览
|
||||
const dryRes = await handleWorkflowCommand(
|
||||
{
|
||||
area: "workflow",
|
||||
action: "node",
|
||||
args: ["sample-save", "wf_save_sample_test", "action_target_node"],
|
||||
options: { dryRun: true, job: "job_custom_999" },
|
||||
raw: ["workflow", "node", "sample-save", "wf_save_sample_test", "action_target_node", "--job=job_custom_999", "--dry-run"],
|
||||
},
|
||||
mockRuntime
|
||||
);
|
||||
|
||||
expect(dryRes.exitCode).toBe(0);
|
||||
expect(dryRes.stdout).toContain("[DRY-RUN]");
|
||||
expect(dryRes.stdout).toContain("固化节点样本数据 (sampleData)");
|
||||
expect(savedTasks).toBeNull();
|
||||
|
||||
// 2. 确认执行
|
||||
const execRes = await handleWorkflowCommand(
|
||||
{
|
||||
area: "workflow",
|
||||
action: "node",
|
||||
args: ["sample-save", "wf_save_sample_test", "action_target_node"],
|
||||
options: { yes: true, job: "job_custom_999" },
|
||||
raw: ["workflow", "node", "sample-save", "wf_save_sample_test", "action_target_node", "--job=job_custom_999", "--yes"],
|
||||
},
|
||||
mockRuntime
|
||||
);
|
||||
|
||||
expect(execRes.exitCode).toBe(0);
|
||||
expect(execRes.stdout).toContain("样本数据 (sampleData) 固化成功");
|
||||
expect(execRes.stdout).toContain("固化字段数 : 2 个属性");
|
||||
expect(savedTasks).not.toBeNull();
|
||||
expect(savedTasks[0].sampleData.formattedDate).toBe("2026-11-24 11:30");
|
||||
expect(choosesRefreshed).toBe(true);
|
||||
});
|
||||
|
||||
it("workflow test --save-sample: 调试通过后自动固化执行出参为节点 sampleData", async () => {
|
||||
let savedTasks: any = null;
|
||||
let choosesRefreshed = false;
|
||||
|
||||
const mockTasks = [
|
||||
{
|
||||
name: "trigger_1",
|
||||
type: "ekuaibao-flowform-trigger",
|
||||
label: "单据触发",
|
||||
orderIndex: 0,
|
||||
levelIndex: [0],
|
||||
status: "active",
|
||||
},
|
||||
{
|
||||
name: "action_code_date",
|
||||
type: "code",
|
||||
label: "代码节点",
|
||||
orderIndex: 1,
|
||||
levelIndex: [1],
|
||||
status: "active",
|
||||
code: "return ['minute': '2026-11-24 11:35'];",
|
||||
},
|
||||
];
|
||||
|
||||
const mockDetail = {
|
||||
id: "wf_test_save_sample",
|
||||
label: "自动保存样本流程",
|
||||
version: "1.0.0",
|
||||
tasksVersion: 1,
|
||||
state: 0,
|
||||
tasks: mockTasks,
|
||||
};
|
||||
|
||||
const mockClient = {
|
||||
post: (url: string) => {
|
||||
if (url.includes("debugSource")) {
|
||||
return {
|
||||
json: async () => ({
|
||||
code: 200,
|
||||
data: {
|
||||
type: "flowForm",
|
||||
total: 1,
|
||||
items: [{ id: "S26000001", title: "测试单据", flowState: "审批中" }],
|
||||
},
|
||||
}),
|
||||
};
|
||||
}
|
||||
if (url.includes("api/easo/jobs")) {
|
||||
return {
|
||||
json: async () => ({
|
||||
code: 200,
|
||||
data: "job_auto_sample_123",
|
||||
}),
|
||||
};
|
||||
}
|
||||
return { json: async () => ({ code: 200, data: null }) };
|
||||
},
|
||||
get: (url: string) => {
|
||||
if (url.includes("/level/failed")) return { json: async () => ({ code: 200, data: [] }) };
|
||||
if (url.includes("execution")) {
|
||||
return {
|
||||
json: async () => ({
|
||||
code: 200,
|
||||
data: [
|
||||
{
|
||||
id: "e1",
|
||||
name: "trigger_1",
|
||||
label: "单据触发",
|
||||
type: "ekuaibao-flowform-trigger",
|
||||
status: "COMPLETED",
|
||||
executionTime: 10,
|
||||
},
|
||||
{
|
||||
id: "e2",
|
||||
name: "action_code_date",
|
||||
label: "代码节点",
|
||||
type: "code",
|
||||
status: "COMPLETED",
|
||||
executionTime: 5,
|
||||
output: {
|
||||
minute: "2026-11-24 11:35",
|
||||
timestampMs: 1795093140000,
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
};
|
||||
}
|
||||
if (url.includes("api/easo/jobs/job_auto_sample_123")) {
|
||||
return {
|
||||
json: async () => ({
|
||||
code: 200,
|
||||
data: {
|
||||
id: "job_auto_sample_123",
|
||||
pipelineId: "wf_test_save_sample",
|
||||
status: "COMPLETED",
|
||||
startTime: 1795490000000,
|
||||
endTime: 1795490001000,
|
||||
executionTime: 1000,
|
||||
},
|
||||
}),
|
||||
};
|
||||
}
|
||||
if (url.includes("api/easo/pipelines/wf_test_save_sample")) {
|
||||
return {
|
||||
json: async () => ({
|
||||
code: 200,
|
||||
data: mockDetail,
|
||||
}),
|
||||
};
|
||||
}
|
||||
return { json: async () => ({ code: 200, data: null }) };
|
||||
},
|
||||
put: (url: string, opts: any) => {
|
||||
if (url.endsWith("/chooses")) {
|
||||
choosesRefreshed = true;
|
||||
return {
|
||||
text: async () => JSON.stringify({ code: 200, data: [] }),
|
||||
json: async () => ({ code: 200, data: [] }),
|
||||
};
|
||||
}
|
||||
if (url.includes("api/easo/pipelines/wf_test_save_sample")) {
|
||||
savedTasks = opts.json.tasks;
|
||||
return {
|
||||
text: async () =>
|
||||
JSON.stringify({
|
||||
code: 200,
|
||||
data: {
|
||||
...mockDetail,
|
||||
...opts.json,
|
||||
tasksVersion: 2,
|
||||
},
|
||||
}),
|
||||
json: async () => ({
|
||||
code: 200,
|
||||
data: {
|
||||
...mockDetail,
|
||||
...opts.json,
|
||||
tasksVersion: 2,
|
||||
},
|
||||
}),
|
||||
};
|
||||
}
|
||||
return {
|
||||
text: async () => JSON.stringify({ code: 200, data: null }),
|
||||
json: async () => ({ code: 200, data: null }),
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
spies.push(
|
||||
spyOn(helpers, "createWorkflowDetailClient").mockResolvedValue({
|
||||
client: mockClient as any,
|
||||
clients: {} as any,
|
||||
platformId: undefined,
|
||||
})
|
||||
);
|
||||
|
||||
const testRes = await handleWorkflowCommand(
|
||||
{
|
||||
area: "workflow",
|
||||
action: "test",
|
||||
args: ["wf_test_save_sample"],
|
||||
options: { flow: "S26000001", saveSample: true, yes: true },
|
||||
raw: ["workflow", "test", "wf_test_save_sample", "--flow=S26000001", "--save-sample", "--yes"],
|
||||
},
|
||||
mockRuntime
|
||||
);
|
||||
|
||||
expect(testRes.exitCode).toBe(0);
|
||||
expect(testRes.stdout).toContain("工作流自动化调测报告");
|
||||
expect(testRes.stdout).toContain("样本数据自动固化");
|
||||
expect(testRes.stdout).toContain("action_code_date");
|
||||
expect(savedTasks).not.toBeNull();
|
||||
expect(savedTasks[1].sampleData.minute).toBe("2026-11-24 11:35");
|
||||
expect(savedTasks[1].sampleData.timestampMs).toBe(1795093140000);
|
||||
expect(choosesRefreshed).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -7,6 +7,9 @@ import {
|
||||
editWorkflowTask,
|
||||
removeWorkflowTask,
|
||||
applyNodeMapping,
|
||||
getJobExecutionTree,
|
||||
listWorkflowLogs,
|
||||
refreshWorkflowChooses,
|
||||
} from "../../../domains/platform/workflow/services.js";
|
||||
import { isServerManagedDescType } from "../../../domains/platform/workflow/nodes/mutations.js";
|
||||
import { ValidationError } from "../../../core/errors.js";
|
||||
@@ -26,7 +29,11 @@ async function saveNodeChanges(client: Parameters<typeof getWorkflowDetail>[0],
|
||||
});
|
||||
}
|
||||
|
||||
const SUB_ACTIONS = new Set(["list", "ls", "get", "show", "info", "add", "append", "insert", "edit", "update", "set", "map", "rm", "remove", "delete", "del"]);
|
||||
const SUB_ACTIONS = new Set([
|
||||
"list", "ls", "get", "show", "info", "add", "append", "insert",
|
||||
"edit", "update", "set", "map", "rm", "remove", "delete", "del",
|
||||
"inspect", "probe", "examine", "sample-save", "save-sample",
|
||||
]);
|
||||
|
||||
export async function handleNodeCommand(
|
||||
parsed: CliParsedArgs,
|
||||
@@ -79,12 +86,14 @@ export async function handleNodeCommand(
|
||||
"用法: hose-use workflow node <子命令> <pipelineId> [选项]",
|
||||
"",
|
||||
"子命令 (工作流级别):",
|
||||
" list <pipelineId> 列出工作流所有任务节点 (别名: ls, 默认)",
|
||||
" get <pipelineId> <节点标识> 查看指定节点的完整配置 (别名: show, info)",
|
||||
" add <pipelineId> [选项] 声明式追加或插入新任务节点 (别名: append, insert)",
|
||||
" edit <pipelineId> <节点标识> 定向修改指定节点配置 (别名: update, set)",
|
||||
" map <pipelineId> <节点标识> 从映射文件批量更新深层字段 (别名: node map --mapping-file)",
|
||||
" rm <pipelineId> <节点标识> 安全移除指定任务节点 (别名: remove, delete)",
|
||||
" list <pipelineId> 列出工作流所有任务节点 (别名: ls, 默认)",
|
||||
" get <pipelineId> <节点标识> 查看指定节点的完整配置 (别名: show, info)",
|
||||
" inspect <pipelineId> <节点标识> 透视节点契约、样本与最近调试出参 (别名: probe)",
|
||||
" sample-save <pipelineId> <节点标识> 固化指定 Job 或最新调测出参为 sampleData",
|
||||
" add <pipelineId> [选项] 声明式追加或插入新任务节点 (别名: append, insert)",
|
||||
" edit <pipelineId> <节点标识> 定向修改指定节点配置 (别名: update, set)",
|
||||
" map <pipelineId> <节点标识> 从映射文件批量更新深层字段 (别名: node map --mapping-file)",
|
||||
" rm <pipelineId> <节点标识> 安全移除指定任务节点 (别名: remove, delete)",
|
||||
"",
|
||||
"子命令 (企业灰度节点级别):",
|
||||
" nodes [list] [--all] 列出当前企业已开通的节点字典 (别名: probe, catalog)",
|
||||
@@ -107,6 +116,13 @@ export async function handleNodeCommand(
|
||||
case "list":
|
||||
case "ls":
|
||||
return handleListNodes(pipelineId, parsed, runtime);
|
||||
case "inspect":
|
||||
case "probe":
|
||||
case "examine":
|
||||
return handleInspectNode(pipelineId, nodeTarget, parsed, runtime);
|
||||
case "sample-save":
|
||||
case "save-sample":
|
||||
return handleSaveNodeSample(pipelineId, nodeTarget, parsed, runtime);
|
||||
case "get":
|
||||
case "show":
|
||||
case "info":
|
||||
@@ -677,3 +693,251 @@ async function handleRemoveNode(
|
||||
exitCode: 0,
|
||||
};
|
||||
}
|
||||
|
||||
async function handleInspectNode(
|
||||
pipelineId: string,
|
||||
nodeTarget: string,
|
||||
parsed: CliParsedArgs,
|
||||
runtime: CliRuntime
|
||||
): Promise<CliResult> {
|
||||
if (!nodeTarget) {
|
||||
return {
|
||||
stdout: "",
|
||||
stderr: "请提供节点标识 (name 或层级序号): hose-use workflow node inspect <pipelineId> <nodeNameOrIndex>\n",
|
||||
exitCode: 1,
|
||||
};
|
||||
}
|
||||
|
||||
const { client, platformId } = await createWorkflowDetailClient(parsed, runtime, pipelineId);
|
||||
const detail = await getWorkflowDetail(client, pipelineId);
|
||||
const located = findWorkflowTask(detail.tasks || [], nodeTarget);
|
||||
|
||||
if (!located) {
|
||||
return {
|
||||
stdout: "",
|
||||
stderr: `在工作流 [${pipelineId}] 中未找到节点: ${nodeTarget}\n`,
|
||||
exitCode: 1,
|
||||
};
|
||||
}
|
||||
|
||||
const { task, hierarchicalIndex, path, parentName } = located;
|
||||
const sampleData = (task as any).sampleData ?? null;
|
||||
|
||||
let executionProbe: {
|
||||
jobId: string;
|
||||
status: string;
|
||||
executionTime?: number;
|
||||
output?: any;
|
||||
error?: any;
|
||||
} | null = null;
|
||||
|
||||
const targetJobId = stringOption(parsed.options, ["job", "job-id", "jobId"]);
|
||||
try {
|
||||
let jobIdToProbe = targetJobId;
|
||||
if (!jobIdToProbe) {
|
||||
const logs = await listWorkflowLogs(client, pipelineId, { pageSize: 1 });
|
||||
const firstItem = logs.items?.[0] || (logs as any).records?.[0];
|
||||
if (firstItem && firstItem.id) {
|
||||
jobIdToProbe = firstItem.id;
|
||||
}
|
||||
}
|
||||
|
||||
if (jobIdToProbe) {
|
||||
const tree = await getJobExecutionTree(client, jobIdToProbe);
|
||||
const matchExecution = tree.find((exec) => exec.name === task.name || exec.id === task.name);
|
||||
if (matchExecution) {
|
||||
executionProbe = {
|
||||
jobId: jobIdToProbe,
|
||||
status: matchExecution.status || "UNKNOWN",
|
||||
executionTime: (matchExecution as any).durationTime ?? matchExecution.executionTime,
|
||||
output: matchExecution.output,
|
||||
error: matchExecution.error,
|
||||
};
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// 探针容错
|
||||
}
|
||||
|
||||
if (runtime.jsonMode) {
|
||||
return {
|
||||
stdout: printJson(
|
||||
{
|
||||
pipelineId,
|
||||
node: located,
|
||||
sampleData,
|
||||
executionProbe,
|
||||
},
|
||||
runtime.outputOptions
|
||||
),
|
||||
stderr: "",
|
||||
exitCode: 0,
|
||||
};
|
||||
}
|
||||
|
||||
const outLines: string[] = [
|
||||
`====== 工作流节点只读探针 [${detail.label || pipelineId}] · ${task.displayName || task.label || task.name} ======`,
|
||||
`节点标识 (name) : ${task.name}`,
|
||||
`层级编号 (#) : ${hierarchicalIndex}`,
|
||||
`节点类型 (type) : ${task.type}`,
|
||||
`节点标题 (label) : ${task.label || "-"}`,
|
||||
`节点显示名 (display): ${(task as any).displayName || "-"}`,
|
||||
`父容器节点 : ${parentName || "顶级节点 (root)"}`,
|
||||
`JSON 路径 : ${path}`,
|
||||
];
|
||||
|
||||
if ((task as any).code !== undefined) {
|
||||
outLines.push(`脚本代码行数 : ${(task as any).code.split("\n").length} 行`);
|
||||
}
|
||||
if ((task as any).url) {
|
||||
outLines.push(`请求 URL : ${(task as any).url}`);
|
||||
}
|
||||
if ((task as any).specificationId) {
|
||||
outLines.push(`单据模板 ID : ${JSON.stringify((task as any).specificationId)}`);
|
||||
}
|
||||
|
||||
outLines.push("");
|
||||
outLines.push("── 📦 节点固化样本数据 (sampleData) ──");
|
||||
if (sampleData && typeof sampleData === "object" && Object.keys(sampleData).length > 0) {
|
||||
const keys = Object.keys(sampleData);
|
||||
outLines.push(`状态: ✅ 已固化样本 (${keys.length} 个字段)`);
|
||||
outLines.push(printJson(sampleData, runtime.outputOptions));
|
||||
} else {
|
||||
outLines.push("状态: ⚪ 暂无样本数据 (设计器下拉菜单将无法自动解析其结构化变量)");
|
||||
outLines.push("💡 提示: 可运行 hose-use workflow node sample-save <pipelineId> <nodeName> 固化最近调测出参");
|
||||
}
|
||||
|
||||
outLines.push("");
|
||||
outLines.push("── 🧪 最近一次调试执行出参 (Execution Output Probe) ──");
|
||||
if (executionProbe) {
|
||||
outLines.push(`来源 Job ID : ${executionProbe.jobId}`);
|
||||
outLines.push(`执行状态 (status) : ${executionProbe.status}`);
|
||||
outLines.push(`执行耗时 (ms) : ${executionProbe.executionTime ?? "-"}`);
|
||||
if (executionProbe.output && typeof executionProbe.output === "object") {
|
||||
outLines.push(`出参全貌 (output):`);
|
||||
outLines.push(printJson(executionProbe.output, runtime.outputOptions));
|
||||
} else {
|
||||
outLines.push(`出参: ${JSON.stringify(executionProbe.output ?? null)}`);
|
||||
}
|
||||
} else {
|
||||
outLines.push("未找到或无匹配的最近调试执行记录。");
|
||||
}
|
||||
|
||||
return { stdout: `${outLines.join("\n")}\n`, stderr: "", exitCode: 0 };
|
||||
}
|
||||
|
||||
async function handleSaveNodeSample(
|
||||
pipelineId: string,
|
||||
nodeTarget: string,
|
||||
parsed: CliParsedArgs,
|
||||
runtime: CliRuntime
|
||||
): Promise<CliResult> {
|
||||
if (!nodeTarget) {
|
||||
return {
|
||||
stdout: "",
|
||||
stderr: "用法: hose-use workflow node sample-save <pipelineId> <nodeNameOrIndex> [--job=<jobId>]\n",
|
||||
exitCode: 1,
|
||||
};
|
||||
}
|
||||
|
||||
const { client, platformId } = await createWorkflowDetailClient(parsed, runtime, pipelineId);
|
||||
const detail = await getWorkflowDetail(client, pipelineId);
|
||||
const located = findWorkflowTask(detail.tasks || [], nodeTarget);
|
||||
|
||||
if (!located) {
|
||||
return {
|
||||
stdout: "",
|
||||
stderr: `在工作流 [${pipelineId}] 中未找到节点: ${nodeTarget}\n`,
|
||||
exitCode: 1,
|
||||
};
|
||||
}
|
||||
|
||||
const { task } = located;
|
||||
const targetJobId = stringOption(parsed.options, ["job", "job-id", "jobId"]);
|
||||
|
||||
let jobIdToProbe = targetJobId;
|
||||
if (!jobIdToProbe) {
|
||||
const logs = await listWorkflowLogs(client, pipelineId, { pageSize: 1 });
|
||||
const firstItem = logs.items?.[0] || (logs as any).records?.[0];
|
||||
if (firstItem && firstItem.id) {
|
||||
jobIdToProbe = firstItem.id;
|
||||
}
|
||||
}
|
||||
|
||||
if (!jobIdToProbe) {
|
||||
return {
|
||||
stdout: "",
|
||||
stderr: `未指定 Job ID 且未查询到工作流 [${pipelineId}] 的历史运行日志,无法提取样本数据。请先执行调试或通过 --job=<id> 指定。\n`,
|
||||
exitCode: 1,
|
||||
};
|
||||
}
|
||||
|
||||
const tree = await getJobExecutionTree(client, jobIdToProbe);
|
||||
const matchExecution = tree.find((exec) => exec.name === task.name || exec.id === task.name);
|
||||
|
||||
if (!matchExecution || matchExecution.output === undefined) {
|
||||
return {
|
||||
stdout: "",
|
||||
stderr: `在 Job [${jobIdToProbe}] 中未找到节点 [${task.name}] 的有效执行出参 (output)。\n`,
|
||||
exitCode: 1,
|
||||
};
|
||||
}
|
||||
|
||||
const samplePayload = matchExecution.output;
|
||||
|
||||
if (isDryRun(parsed, runtime)) {
|
||||
return mutationPreview(parsed, runtime, "固化节点样本数据 (sampleData)", `${pipelineId}:${task.name}`, {
|
||||
pipelineId,
|
||||
nodeName: task.name,
|
||||
jobId: jobIdToProbe,
|
||||
samplePayload,
|
||||
});
|
||||
}
|
||||
|
||||
requireMutationConfirmation(
|
||||
parsed,
|
||||
runtime,
|
||||
"固化节点样本数据 (sampleData)",
|
||||
`hose-use workflow node sample-save ${pipelineId} ${nodeTarget} --job=${jobIdToProbe} --yes`
|
||||
);
|
||||
|
||||
(task as any).sampleData = samplePayload;
|
||||
const saveResult = await saveNodeChanges(client, detail, detail, platformId);
|
||||
|
||||
try {
|
||||
await refreshWorkflowChooses(client, pipelineId);
|
||||
} catch {}
|
||||
|
||||
const fieldCount = typeof samplePayload === "object" && samplePayload !== null ? Object.keys(samplePayload).length : 1;
|
||||
|
||||
if (runtime.jsonMode) {
|
||||
return {
|
||||
stdout: printJson(
|
||||
{
|
||||
success: true,
|
||||
pipelineId,
|
||||
nodeName: task.name,
|
||||
jobId: jobIdToProbe,
|
||||
fieldsSaved: fieldCount,
|
||||
sampleData: samplePayload,
|
||||
workflow: saveResult,
|
||||
},
|
||||
runtime.outputOptions
|
||||
),
|
||||
stderr: "",
|
||||
exitCode: 0,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
stdout: [
|
||||
`✨ 节点 [${task.name}] (${task.displayName || task.label || task.type}) 样本数据 (sampleData) 固化成功!`,
|
||||
` • 来源 Job ID : ${jobIdToProbe}`,
|
||||
` • 固化字段数 : ${fieldCount} 个属性`,
|
||||
` • 设计器联动 : 已刷新选择器 (chooses) 树,下游节点现在可在下拉列表中直接点选其输出变量。`,
|
||||
`📌 ${formatWorkflowVersion(saveResult)}`,
|
||||
].join("\n") + "\n",
|
||||
stderr: "",
|
||||
exitCode: 0,
|
||||
};
|
||||
}
|
||||
@@ -6,6 +6,9 @@ import {
|
||||
getWorkflowDetail,
|
||||
getWorkflowSampleData,
|
||||
runWorkflowDebugTest,
|
||||
updateWorkflow,
|
||||
refreshWorkflowChooses,
|
||||
flattenWorkflowTaskTree,
|
||||
type WorkflowTriggerCategory,
|
||||
} from "../../../domains/platform/workflow/services.js";
|
||||
import { stringOption, booleanOption, numberOption } from "../../parser.js";
|
||||
@@ -46,6 +49,7 @@ export async function handleWorkflowTest(
|
||||
" 4. 外部调用 (webhook): --body='{...}' 或 --file=<path.json> 传入事件请求体",
|
||||
"",
|
||||
"通用选项:",
|
||||
" --save-sample 调试通过后自动将执行节点的真实出参保存为样本数据 (sampleData)",
|
||||
" --timeout=<ms> 设置轮询超时时间 (默认 15000ms)",
|
||||
" --auto-publish 是否自动发布测试快照 (默认 false)",
|
||||
" --allow-prod 确认在正式生产环境 (env: prod) 下执行调试(--force 为兼容别名)",
|
||||
@@ -59,6 +63,7 @@ export async function handleWorkflowTest(
|
||||
}
|
||||
|
||||
const autoPublish = booleanOption(parsed.options, ["auto-publish", "autoPublish", "publish"]);
|
||||
const saveSample = booleanOption(parsed.options, ["save-sample", "saveSample", "save-samples", "saveSamples"]);
|
||||
const timeoutMs = numberOption(parsed.options, ["timeout", "timeout-ms", "timeoutMs"]) ?? 15000;
|
||||
const rawBody = stringOption(parsed.options, ["body", "data", "payload"]);
|
||||
const filePath = stringOption(parsed.options, ["file", "path"]);
|
||||
@@ -109,7 +114,7 @@ export async function handleWorkflowTest(
|
||||
});
|
||||
if (blocked) return blocked;
|
||||
if (flowCodeOrId || rawBody || filePath || isEmpty) confirmExecution();
|
||||
const { client } = await createWorkflowDetailClient(parsed, runtime, pipelineId);
|
||||
const { client, platformId } = await createWorkflowDetailClient(parsed, runtime, pipelineId);
|
||||
|
||||
// 1. 获取工作流详情与触发器元数据
|
||||
const detail = await getWorkflowDetail(client, pipelineId).catch(() => {
|
||||
@@ -414,9 +419,48 @@ export async function handleWorkflowTest(
|
||||
autoPublish,
|
||||
timeoutMs,
|
||||
});
|
||||
|
||||
const savedSampleNodes: Array<{ name: string; label: string; fieldCount: number }> = [];
|
||||
if (saveSample && execution.outcome === "completed" && execution.executionTree?.length > 0) {
|
||||
try {
|
||||
const latestDetail = await getWorkflowDetail(client, pipelineId);
|
||||
const flattened = flattenWorkflowTaskTree(latestDetail.tasks || []);
|
||||
let updatedCount = 0;
|
||||
|
||||
for (const execNode of execution.executionTree) {
|
||||
if (!execNode.name || execNode.output === undefined || execNode.output === null) continue;
|
||||
if (typeof execNode.output !== "object" || Object.keys(execNode.output).length === 0) continue;
|
||||
|
||||
const matched = flattened.find((f) => f.task.name === execNode.name);
|
||||
if (matched) {
|
||||
(matched.task as any).sampleData = execNode.output;
|
||||
savedSampleNodes.push({
|
||||
name: matched.task.name,
|
||||
label: (matched.task as any).displayName || matched.task.label || matched.task.type,
|
||||
fieldCount: Object.keys(execNode.output).length,
|
||||
});
|
||||
updatedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (updatedCount > 0) {
|
||||
await updateWorkflow(client, latestDetail, {
|
||||
platformId,
|
||||
expectedVersion: { version: latestDetail.version, tasksVersion: latestDetail.tasksVersion },
|
||||
});
|
||||
try {
|
||||
await refreshWorkflowChooses(client, pipelineId);
|
||||
} catch {}
|
||||
}
|
||||
} catch (sampleErr: any) {
|
||||
warnings.push(`自动固化样本数据警告: ${sampleErr.message || String(sampleErr)}`);
|
||||
}
|
||||
}
|
||||
|
||||
const report = {
|
||||
...execution,
|
||||
productionEnabled: detail ? isEnabled : null,
|
||||
savedSampleNodes: savedSampleNodes.length > 0 ? savedSampleNodes : undefined,
|
||||
warnings,
|
||||
...productionOverrideMeta(
|
||||
parsed,
|
||||
@@ -514,6 +558,15 @@ export async function handleWorkflowTest(
|
||||
outLines.push(...formatCodeNodeSummariesCard(codeSummaries, report.jobId));
|
||||
}
|
||||
|
||||
if (savedSampleNodes.length > 0) {
|
||||
outLines.push("");
|
||||
outLines.push("── ✨ 样本数据自动固化 (Sample Data Saved) ──");
|
||||
outLines.push(`已自动将 ${savedSampleNodes.length} 个节点的真实调试出参固化为 sampleData 并刷新设计器选择树:`);
|
||||
for (const sn of savedSampleNodes) {
|
||||
outLines.push(` • [${sn.name}] (${sn.label}): 固化 ${sn.fieldCount} 个属性`);
|
||||
}
|
||||
}
|
||||
|
||||
if (category === "WEBHOOK" && report.outcome !== "completed") {
|
||||
outLines.push("");
|
||||
outLines.push("💡 [Webhook 流程调试提示]");
|
||||
|
||||
@@ -149,8 +149,9 @@ export class CorpContext {
|
||||
if (!corp) return false;
|
||||
this.current = corp;
|
||||
this.defaultCorpId = corp.id;
|
||||
if (persist && this.stateful) {
|
||||
saveGlobalConfig({ defaultCorpId: corp.id });
|
||||
if (persist) {
|
||||
this.stateful = true;
|
||||
saveGlobalConfig({ defaultCorpId: corp.id, stateful: true });
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -125,9 +125,9 @@ function buildWorkflowTaskBase(type: string, options: Partial<AddTaskOptions> =
|
||||
return {
|
||||
name,
|
||||
type: "stop",
|
||||
label: options.label || "终止流程",
|
||||
desc: options.desc || "如果满足条件终止流程",
|
||||
groupName: "control",
|
||||
label: options.label || "终止节点",
|
||||
desc: options.desc,
|
||||
groupName: "action",
|
||||
orderIndex: 0,
|
||||
levelIndex: [0],
|
||||
status: "active",
|
||||
|
||||
@@ -51,7 +51,7 @@ bun install --frozen-lockfile
|
||||
bun run build:plugin
|
||||
```
|
||||
|
||||
`.mcp.json` 保持使用 `${CLAUDE_PLUGIN_ROOT}/dist/mcp/server.js`,由 Bun 1.3.14+ 启动。清理 `dist/` 后需要重新构建;普通 `bun test` 会在临时目录自行构建测试插件,不依赖预先存在的 bundle。
|
||||
插件清单 `mcp.json` 保持使用 `${CLAUDE_PLUGIN_ROOT}/dist/mcp/server.js`,由 Bun 1.3.14+ 启动;仓库根目录的 `.mcp.json` 是 Claude Code 项目级配置,使用 `bun src/server.ts` 运行当前源码,不包含插件变量。清理 `dist/` 后需要重新构建插件 bundle;普通 `bun test` 会在临时目录自行构建测试插件,不依赖预先存在的 bundle。
|
||||
|
||||
完整插件包通过以下命令生成(需要系统 `tar`):
|
||||
|
||||
@@ -59,7 +59,7 @@ bun run build:plugin
|
||||
bun run package:plugin
|
||||
```
|
||||
|
||||
输出为 `dist/bin/hose-use-plugin-v<版本>.tar.gz`,只包含 `.zcode-plugin/plugin.json`、`.mcp.json`、`skills/` 和新构建的 `dist/mcp/server.js`,不会复用仓库本地的旧 bundle。归档根目录即插件根目录,不包含企业凭据、本地笔记、源码或 `node_modules/`。解压后的插件仍需 Bun 1.3.14+,无需再次安装项目依赖。
|
||||
输出为 `dist/bin/hose-use-plugin-v<版本>.tar.gz`,只包含 `.zcode-plugin/plugin.json`、`mcp.json`、`skills/` 和新构建的 `dist/mcp/server.js`,不会复用仓库本地的旧 bundle。归档根目录即插件根目录,不包含企业凭据、本地笔记、源码或 `node_modules/`。解压后的插件仍需 Bun 1.3.14+,无需再次安装项目依赖。
|
||||
|
||||
从 Release 下载插件包和同版本的 `checksums.txt`,核对对应资产的 SHA-256 后解压到独立目录,将该目录作为本地插件根目录加载。MCP 默认关闭,按插件配置启用后连接。
|
||||
|
||||
@@ -79,7 +79,7 @@ Skill 初始化明确执行 `skill install --yes`;失败会报告二进制已
|
||||
|
||||
- PR/main CI:冻结依赖安装、版本一致性、类型检查、全套测试、独立二进制和插件 bundle 的构建及 MCP 协议验证,以及完整插件包构建。测试会解包临时插件,核对包内清单和 Skill,并在独立目录验证离线脚本与 MCP 协议。
|
||||
- 独立二进制:`bun run build:binary`;`bun run scripts/build/verify-binary.ts dist/bin/hose-use` 在空工作目录和没有 Bun 的 PATH 下验证版本、单工具发现、真实调用与错误返回。
|
||||
- 插件 bundle:`bun run build:plugin`;`.mcp.json` 指定 Bun 1.3.14+,与共享 CLI 的 `bun:sqlite` 依赖一致;`bun run scripts/build/verify-binary.ts dist/mcp/server.js --plugin` 验证实际产物。
|
||||
- 插件 bundle:`bun run build:plugin`;`mcp.json` 指定 Bun 1.3.14+,与共享 CLI 的 `bun:sqlite` 依赖一致;`bun run scripts/build/verify-binary.ts dist/mcp/server.js --plugin` 验证实际产物。
|
||||
- Release:构建前检查 tag 版本、实际 HEAD 和 main 祖先关系;手动触发也必须输入 tag。正式构建显式使用 `--release`,两个发布源都上传校验清单,后台镜像上传失败会使任务失败。
|
||||
|
||||
Gitea 同时最多传输两个资产,每个资产最多尝试三次;已有文件经 SHA-256 验证一致时直接保留。镜像传输中断后,可在 main 上手动运行 Release workflow,传入原 tag 并启用 `mirror_only`:该模式下载并核对 GitHub 已发布资产(含插件包),只修复 Gitea,不重建或替换 GitHub 产物,也不移动 tag。
|
||||
|
||||
Reference in new issue
Block a user