Compare commits

...
8 Commits
Author SHA1 Message Date
yunyingk dd647b65a6 Merge pull request #77 from yunyingk/fix/sqlite-cache-migration-and-bill-mine
🚀 Release / 🚀 Build & Publish Multi-Platform Binaries (push) Has been cancelled
fix: sqlite cache migration, bill timeout protection with --mine, and add-link overwrite UX (v0.8.7)
2026-09-17 10:06:30 +08:00
gitea 43595e2410 fix: sqlite cache migration, bill timeout protection with --mine, and add-link overwrite UX (v0.8.7) 2026-09-17 10:06:08 +08:00
yunyingk b08b99c45e Merge pull request #76 from yunyingk/revert/ekuaibao-child-skills-verbatim
revert(skill): 子技能按原样内嵌(去掉端点参数化与上级标注)
2026-09-15 16:31:34 +08:00
gitea 7e4f218313 revert(skill): 子技能保持原样,去掉端点参数化与上级标注
按项目所有者要求,multi/ 下两个子技能按原始内容原样内嵌:

- ekuaibao-nodes/SKILL.md:恢复原开通服务地址,去掉 HOSE_WORKFLOW_NODE_URL
  参数化与相关提示,域名判断示例恢复原文
- ekuaibao-mvel/SKILL.md:移除「本文件是下级技能」标注行
- 结构、内嵌清单(18)、测试均不变
2026-09-15 16:30:55 +08:00
yunyingk 05569243ec Merge pull request #75 from yunyingk/feat/ekuaibao-suite-and-mvel-skill
feat(skill): 合思系列统一入口 + MVEL / 节点开通子技能
2026-09-15 16:23:32 +08:00
gitea ebed61d6b4 feat(skill): 合思系列统一入口,新增 MVEL 与节点开通子技能
- skills/hose-use 收敛为合思/易快报系列唯一入口,新增「本套件结构」路由表
- 新增子技能 multi/ekuaibao-mvel:工作流 MVEL 代码节点脚本生成与排错
- 新增子技能 multi/ekuaibao-nodes:工作流节点批量开通(自 curl 提取 token/corpId/baseUrl)
- 开通服务地址改为 HOSE_WORKFLOW_NODE_URL 环境变量,不再硬编码实例
- embedded-skill 内嵌清单 14 -> 18,installer 递归保留 multi/ 层级;测试同步更新
2026-09-15 16:21:15 +08:00
yunyingk 90e7ac22bb Merge pull request #74 from yunyingk/feat/dev-version-visibility
feat: make development builds visibly identifiable
2026-09-13 14:25:35 +08:00
gitea 2ed9bf0236 feat: make development builds visibly identifiable 2026-09-13 14:24:27 +08:00
33 changed files with 1290 additions and 477 deletions

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hose-use",
"version": "0.8.6",
"version": "0.8.7",
"description": "合思/易快报 (ekuaibao) 企业级 SaaS CLI 与底层 SDK:多账号登录、企业租户切换、单据明细检索、工作流管理、内置 HTTP 服务与常驻守护进程。",
"author": {
"name": "yingqing"
+2 -2
View File
@@ -1,4 +1,4 @@
# hose-use (v0.8.6)
# hose-use (v0.8.7)
合思/易快报(ekuaibao)企业级 CLI 命令行工具与底层 SDK。
@@ -26,7 +26,7 @@ bun run dev:override
hose-use version
```
该命令会构建本机二进制、原子替换全局 `hose-use`,同步 `~/.agents/skills/hose-use`,并保留 `hose-aipro` 别名;后台服务若正在运行会自动重启。只预览动作可运行 `bun run dev:override -- --dry-run`。
该命令会构建本机二进制、原子替换全局 `hose-use`,同步 `~/.agents/skills/hose-use`,并保留 `hose-aipro` 别名;后台服务若正在运行会自动重启。开发构建会把 Git 信息编译进版本,例如 `hose-use v0.8.6-dev.1+gabc1234 [DEV BUILD]`,不会再与正式版混淆;`hose-use version --json` 还会返回 `channel`、`isRelease` 和 `git` 元数据。只预览动作可运行 `bun run dev:override -- --dry-run`。
> 开发版安装会覆盖当前 PATH 中的 `hose-use`,适合本机测试;发布环境请使用正式 Release 安装脚本。不要用 `npm install -g .` 代替,它会留下不会随源码更新的旧副本。
+495 -417
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -2,7 +2,7 @@
"openapi": "3.1.0",
"info": {
"title": "hose-use API & MCP Tools Specification",
"version": "0.8.6",
"version": "0.8.7",
"description": "Unified Enterprise SaaS API, CLI, and MCP Specification for Ekuaibao (合思/易快报), EASO, and Piper Workflows."
},
"servers": [
+1 -1
View File
@@ -1,7 +1,7 @@
openapi: 3.1.0
info:
title: hose-use API & MCP Tools Specification
version: 0.8.6
version: 0.8.7
description: >-
Unified Enterprise SaaS API, CLI, and MCP Specification for Ekuaibao (合思/易快报), EASO, and Piper Workflows.
servers:
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hose-use",
"version": "0.8.6",
"version": "0.8.7",
"module": "src/server.ts",
"type": "module",
"bin": {
+66 -8
View File
@@ -1,4 +1,4 @@
import { mkdirSync, existsSync, unlinkSync, symlinkSync } from "node:fs";
import { mkdirSync, readFileSync, existsSync, unlinkSync, symlinkSync } from "node:fs";
import { spawnSync } from "node:child_process";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
@@ -17,20 +17,77 @@ const TARGET_MAP = {
const args = process.argv.slice(2);
const isAll = args.includes("--all") || args.includes("--matrix");
const targetArg = args.find((arg) => arg.startsWith("--target="))?.replace("--target=", "");
const isRelease = args.includes("--release") ||
process.env.HOSE_BUILD_RELEASE === "1" ||
(Boolean(process.env.CI) && process.env.GITHUB_REF_TYPE === "tag");
function getBuildInfo(releaseMode) {
const pkg = JSON.parse(readFileSync(resolve(root, "package.json"), "utf8"));
if (releaseMode) return { version: pkg.version, channel: "release", isRelease: true };
try {
const result = spawnSync("git", ["describe", "--tags", "--long", "--dirty", "--always"], { cwd: root, encoding: "utf8" });
if (result.status === 0 && result.stdout) {
const trimmed = result.stdout.trim();
const dirty = trimmed.endsWith("-dirty");
const clean = dirty ? trimmed.slice(0, -6) : trimmed;
const longMatch = clean.match(/^v?(\d+\.\d+\.\d+(?:-[a-zA-Z0-9.]+)?)-(\d+)-g([0-9a-f]+)$/);
let baseVersion = pkg.version;
let commitsAhead = 0;
let commit = "";
if (longMatch) {
baseVersion = longMatch[1];
commitsAhead = Number.parseInt(longMatch[2], 10);
commit = longMatch[3];
} else {
const revision = spawnSync("git", ["rev-parse", "--short", "HEAD"], { cwd: root, encoding: "utf8" });
if (revision.status === 0 && revision.stdout) commit = revision.stdout.trim();
}
const dirtySuffix = dirty ? ".dirty" : "";
const commitSuffix = commit ? `+g${commit}${dirtySuffix}` : dirty ? "+dirty" : "";
return {
version: `${baseVersion}-dev.${commitsAhead}${commitSuffix}`,
channel: "dev",
isRelease: false,
git: { baseVersion, commitsAhead, commit, dirty, describe: trimmed }
};
}
} catch {
// Fall back below if git is unavailable.
}
return { version: `${pkg.version}-dev.0+local`, channel: "dev", isRelease: false };
}
const buildInfo = getBuildInfo(isRelease);
const buildEnv = {
...process.env,
HOSE_BUILD_VERSION: buildInfo.version,
HOSE_BUILD_CHANNEL: buildInfo.channel,
HOSE_BUILD_IS_RELEASE: String(buildInfo.isRelease),
...(buildInfo.git ? {
HOSE_BUILD_GIT_BASE: buildInfo.git.baseVersion,
HOSE_BUILD_GIT_COMMITS_AHEAD: String(buildInfo.git.commitsAhead),
HOSE_BUILD_GIT_COMMIT: buildInfo.git.commit,
HOSE_BUILD_GIT_DIRTY: String(buildInfo.git.dirty),
HOSE_BUILD_GIT_DESCRIBE: buildInfo.git.describe
} : {})
};
console.log(`[build:binary] version: ${buildInfo.version} (${buildInfo.channel}, isRelease: ${buildInfo.isRelease})`);
if (isAll) {
for (const [name, config] of Object.entries(TARGET_MAP)) {
buildTarget(name, config.bunTarget, resolve(root, config.outfile));
buildTarget(name, config.bunTarget, resolve(root, config.outfile), "src/cli.ts", buildEnv);
}
} else if (targetArg) {
const config = TARGET_MAP[targetArg];
if (!config) {
throw new Error(`Unknown target: ${targetArg}. Available targets: ${Object.keys(TARGET_MAP).join(", ")}`);
}
buildTarget(targetArg, config.bunTarget, resolve(root, config.outfile));
buildTarget(targetArg, config.bunTarget, resolve(root, config.outfile), "src/cli.ts", buildEnv);
} else {
const outputHose = resolve(root, "dist/bin/hose-use");
buildTarget("host", null, outputHose, "src/cli.ts");
buildTarget("host", null, outputHose, "src/cli.ts", buildEnv);
// Unix Multicall Binary: 创建 hose-aipro -> hose-use 软链接别名
const outputAipro = resolve(root, "dist/bin/hose-aipro");
@@ -43,16 +100,16 @@ if (isAll) {
}
}
function buildTarget(name, bunTarget, output, entry = "src/cli.ts") {
function buildTarget(name, bunTarget, output, entry = "src/cli.ts", env = process.env) {
mkdirSync(dirname(output), { recursive: true });
const buildArgs = ["build", "--compile"];
const buildArgs = ["build", "--compile", "--env=HOSE_BUILD_*"];
if (bunTarget) {
buildArgs.push(`--target=${bunTarget}`);
}
buildArgs.push("--outfile", output, entry);
console.log(`[build:binary] compiling target: ${name} -> ${output}`);
run(bun, buildArgs);
run(bun, buildArgs, { env });
if (process.platform === "darwin" && (name.startsWith("darwin") || name === "host")) {
try {
@@ -71,7 +128,8 @@ function buildTarget(name, bunTarget, output, entry = "src/cli.ts") {
function run(command, args, options = {}) {
const result = spawnSync(command, args, {
cwd: root,
stdio: options.quiet ? ["ignore", "ignore", "ignore"] : "inherit"
stdio: options.quiet ? ["ignore", "ignore", "ignore"] : "inherit",
env: options.env ?? process.env
});
if (result.error) throw result.error;
if (result.status !== 0) {
+5 -10
View File
@@ -35,19 +35,14 @@ pkg.version = nextVersion;
writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
console.log("✓ Updated package.json");
// 2. src/version.ts
const versionTsPath = join(ROOT, "src", "version.ts");
writeFileSync(versionTsPath, `export const VERSION = "${nextVersion}";\n`);
console.log("✓ Updated src/version.ts");
// 3. README.md
// 2. README.md
const readmePath = join(ROOT, "README.md");
let readmeContent = readFileSync(readmePath, "utf-8");
readmeContent = readmeContent.replace(/# hose-use \(v[\d.]+\)/g, `# hose-use (v${nextVersion})`);
writeFileSync(readmePath, readmeContent);
console.log("✓ Updated README.md");
// 4. skills/hose-use/SKILL.md
// 3. skills/hose-use/SKILL.md
const skillPath = join(ROOT, "skills", "hose-use", "SKILL.md");
let skillContent = readFileSync(skillPath, "utf-8");
skillContent = skillContent.replace(/# hose-use \(v[\d.]+\)/g, `# hose-use (v${nextVersion})`);
@@ -57,7 +52,7 @@ skillContent = skillContent.replace(/\(v[\d.]+\)/g, `(v${nextVersion})`);
writeFileSync(skillPath, skillContent);
console.log("✓ Updated skills/hose-use/SKILL.md");
// 5. openapi/openapi.yaml
// 4. openapi/openapi.yaml
const openapiPath = join(ROOT, "openapi", "openapi.yaml");
if (existsSync(openapiPath)) {
let openapiContent = readFileSync(openapiPath, "utf-8");
@@ -66,7 +61,7 @@ if (existsSync(openapiPath)) {
console.log("✓ Updated openapi/openapi.yaml");
}
// 5.5 .zcode-plugin/plugin.json
// 4.5 .zcode-plugin/plugin.json
const pluginJsonPath = join(ROOT, ".zcode-plugin", "plugin.json");
if (existsSync(pluginJsonPath)) {
const pluginJson = JSON.parse(readFileSync(pluginJsonPath, "utf-8"));
@@ -75,7 +70,7 @@ if (existsSync(pluginJsonPath)) {
console.log("✓ Updated .zcode-plugin/plugin.json");
}
// 6. Sync to global ~/.agents/skills/hose-use/ if present
// 5. Sync to global ~/.agents/skills/hose-use/ if present
const globalSkillDir = join(process.env.HOME || "", ".agents", "skills", "hose-use");
if (existsSync(globalSkillDir)) {
const srcDir = join(ROOT, "skills", "hose-use");
-1
View File
@@ -6,7 +6,6 @@ const root = join(import.meta.dirname, "..");
const packageVersion = (JSON.parse(readFileSync(join(root, "package.json"), "utf8")) as { version: string }).version;
const expected: Array<[string, string | undefined]> = [
["package.json", packageVersion],
["src/version.ts", readFileSync(join(root, "src/version.ts"), "utf8").match(/VERSION\s*=\s*[\"']([^\"']+)/)?.[1]],
[".zcode-plugin/plugin.json", readJsonVersion(".zcode-plugin/plugin.json")],
["openapi/openapi.yaml", readFileSync(join(root, "openapi/openapi.yaml"), "utf8").match(/^\s+version:\s+([^\s]+)\s*$/m)?.[1]],
["dist/openapi.json", readJsonVersion("dist/openapi.json", ["info", "version"])],
+8 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, test } from "bun:test";
import { buildCleanupPlan, classifyExitCode, parseDevHygieneArgs, type Finding } from "./dev-hygiene.ts";
import { buildCleanupPlan, classifyExitCode, isCompatibleBinaryVersion, parseDevHygieneArgs, type Finding } from "./dev-hygiene.ts";
describe("dev hygiene tooling", () => {
test("only accepts development-scoped modes and confirmation flags", () => {
@@ -16,6 +16,13 @@ describe("dev hygiene tooling", () => {
expect(classifyExitCode([finding("blocked")])).toBe(3);
});
test("accepts a development build based on the current stable version", () => {
expect(isCompatibleBinaryVersion("0.8.6", "0.8.6")).toBe(true);
expect(isCompatibleBinaryVersion("0.8.6-dev.2+gabc1234", "0.8.6")).toBe(true);
expect(isCompatibleBinaryVersion("0.8.5-dev.1+gold", "0.8.6")).toBe(false);
expect(isCompatibleBinaryVersion(undefined, "0.8.6")).toBe(false);
});
test("only plans deletion for clean merged worktrees and local branches", () => {
const snapshot = {
repository: {} as any,
+5 -1
View File
@@ -285,6 +285,10 @@ function resolveCommand(name: string): string | undefined {
return undefined;
}
export function isCompatibleBinaryVersion(actual: string | undefined, expected: string): boolean {
return actual === expected || actual?.startsWith(`${expected}-dev.`) === true;
}
function inspectBinary(name: string): HygieneSnapshot["binaries"][number] {
const path = resolveCommand(name);
if (!path) return { name, expectedVersion: PACKAGE.version, matches: false, error: "PATH 中未找到" };
@@ -294,7 +298,7 @@ function inspectBinary(name: string): HygieneSnapshot["binaries"][number] {
}
try {
const version = (JSON.parse(result.stdout) as { version?: string }).version;
return { name, path, version, expectedVersion: PACKAGE.version, matches: version === PACKAGE.version };
return { name, path, version, expectedVersion: PACKAGE.version, matches: isCompatibleBinaryVersion(version, PACKAGE.version) };
} catch {
return { name, path, expectedVersion: PACKAGE.version, matches: false, error: "版本输出不是 JSON" };
}
+16 -4
View File
@@ -1,18 +1,30 @@
---
name: hose-use
description: "v0.8.6: 合思/易快报 (ekuaibao) 企业级 SaaS CLI 与底层 SDK:多账号 API 登录、租户切换、单据检索与审批动作、工作流跨域扫描、内置 HTTP 交互文档与常驻守护进程。"
description: "合思/易快报(Ekuaibao)企业级 SaaS 一站式能力:hose-use CLI/SDK 多账号登录、租户切换、单据检索与审批动作、自建应用与工作流扫描、密钥与应用中心、常驻守护进程与 HTTP 文档/OpenAPI,以及工作流 MVEL 代码节点脚本生成调试、节点批量开通。用于一切合思/易快报相关请求。"
metadata:
version: 0.8.6
short-description: 合思/易快报企业级 CLI 工具与底层 SDK (v0.8.6)
version: 0.8.7
short-description: 合思/易快报 企业级 CLI 与工作流 skill 套件(含 MVEL 代码节点)
---
# hose-use (v0.8.6)
# hose-use (v0.8.7)
在具备 MCP 的 AI 智能体环境中,**优先使用 `hose_cli` 单工具网关**,传入 `command: string` 执行;在终端或自动化脚本中,直接调用全局 `hose` 或 `hose-use` 命令行。
本 Skill 是智能体的路由分发层:保持主文档简明,遇到复杂业务时深入查阅对应的专属参考文档(`references/*.md`)。
---
## 本套件结构(先看这里)
本 skill 是**合思/易快报系列的唯一入口**,下级技能不在模型目录中,按需读取:
| 需要做什么 | 去哪里 |
|---|---|
| 登录/租户/单据/审批/通讯录/档案/费用类型/角色/待办/应用商店/守护进程 | 本文件下方路由表;细节读 `references/*.md` |
| 写或排错**工作流 MVEL 代码节点**脚本 | `multi/ekuaibao-mvel/SKILL.md` |
| **批量开通工作流节点**(从浏览器 curl 提取 token/corpId/baseUrl) | `multi/ekuaibao-nodes/SKILL.md` |
---
## Agent 执行原则 (First Rules)
0. **一键构建上下文(Zero Source-Reading)**:在开始执行任务前,优先执行 `hose-use context --json` 或 `hose-aipro status --json` 一键获取当前账号、企业租户、登录凭证、运行模式与 AI PRO 网关状态。**严禁翻阅源码目录探查配置与企业列表**。
@@ -0,0 +1,146 @@
---
name: ekuaibao-mvel
description: Generate and debug MVEL code-node scripts for 合思/易快报/Ekuaibao workflows.
---
# 合思 MVEL 代码节点
## Core Rule
Generate code for Ekuaibao's modified MVEL 2.x runtime, not JavaScript, Groovy, or standard Java. First match the syntax style the user has already proven in their tenant or node.
- If the user provides a working snippet, preserve that dialect. For example, if `a = action_xxx; ... result;` works, use bare assignments and final-expression return.
- If the user has not provided a working snippet, prefer conservative MVEL and be ready to simplify to a probe script.
- Do not use `def` for variables.
- Use `return`, `import`, or `var` only when they match the user's known working environment; otherwise avoid them in favor of final-expression return and fully qualified JDK classes.
- Use Java collection methods: `.get()`, `.put()`, `.add()`, `.size()`.
- For Chinese or dynamic field names, prefer `map.get("字段名")` instead of dot access.
- Every `if`, `&&`, and `||` operand must be a strict boolean expression. Never write `if (data)`.
## Code Node Template
Use this style when the user has shown bare assignments and final-expression return work:
```groovy
a = action_xxxxxx;
result = new java.util.HashMap();
result.put("ok", true);
result;
```
When the user's environment supports `var/import/return`, it is acceptable to use that style, but do not mix styles unnecessarily within one answer.
## Tenant-Proven Short Syntax
This tenant has verified that these short forms work:
- Map literal: `["key": value]`
- List literal: `[item1, item2]`
- Final-expression return
- Upstream node references use node ID variables such as `action_xxxxxx`
When the user asks to hard-return a config object, prefer Map/List literals first:
```groovy
[
"config": [
"key": "value",
"list": ["a", "b"]
]
]
```
If Map/List literals fail in a different tenant or node, fall back to `new java.util.HashMap()` and `new java.util.ArrayList()`.
## Upstream Node Reference
When the user says the upstream node is referenced by ID, assign the node ID variable to a semantic local name first:
```groovy
inputData = action_xxxxxx;
```
Do not assume the platform provides a built-in variable named `inputData` unless the user explicitly says so. Replace `action_xxxxxx` with the real upstream node ID the user provides.
## Defensive Patterns
### Read First Item Only
When the user says to read only the first upstream record, do not loop.
```groovy
a = action_xxxxxx;
firstItem = null;
if (a != null && a.size() > 0) {
firstItem = a.get(0);
}
```
### Read Nested Form Field
```groovy
value = "";
if (firstItem != null && firstItem.get("form") != null) {
form = firstItem.get("form");
rawValue = form.get("E_xxx_字段名");
if (rawValue != null && String.valueOf(rawValue).trim() != "") {
value = String.valueOf(rawValue).trim();
}
}
```
### Generate Next 6-Digit Number
Use this for JS logic like `parseInt(num, 10) || 0` and `.padStart(6, "0")`:
```groovy
num = "";
nextStr = "000001";
if (rawNum != null && String.valueOf(rawNum).trim() != "") {
num = String.valueOf(rawNum).trim();
}
if (num != null && num.trim() != "" && num.trim().matches("[0-9]+")) {
cleanNum = num.trim();
nextNumber = java.lang.Integer.parseInt(cleanNum) + 1;
rawNextStr = String.valueOf(nextNumber);
if (rawNextStr.length() < 6) {
padded = "000000" + rawNextStr;
nextStr = padded.substring(padded.length() - 6);
} else {
nextStr = rawNextStr;
}
}
```
## Avoid
- Do not use JavaScript methods: `.push()`, `.length` as a property, `parseInt`, `padStart`.
- Do not use Groovy sugar: `?.`, `?:`.
- Do not use `try/catch` unless the user has already verified it works in their tenant.
- Do not use third-party imports such as Fastjson.
- Do not use `String.valueOf(map)` when downstream needs valid JSON; manually concatenate JSON strings.
- In enhanced loops, write `for (item : list)`, never `for (var item : list)`.
## Debugging Silent Failures
If the platform gives no detailed error, simplify toward a probe script:
```groovy
a = action_xxxxxx;
result = new java.util.HashMap();
result.put("isNull", a == null);
result.put("total", a != null ? a.size() : 0);
result;
```
Then add one field access at a time. For code nodes nested inside a condition branch, still return a normal object from the code node; only condition expressions themselves must return boolean.
Treat tenant-specific behavior as evidence, not a universal rule. Say what assumption the code is using when syntax compatibility is uncertain.
@@ -0,0 +1,4 @@
interface:
display_name: "合思 MVEL"
short_description: "生成、改写和排查合思 MVEL 代码节点运行兼容问题"
default_prompt: "Use $ekuaibao-mvel to write a 合思 MVEL code-node script."
@@ -0,0 +1,46 @@
---
name: ekuaibao-nodes
description: |
合思(易快报)工作流节点批量开通工具。
当用户提到"合思"、"易快报"、"ekuaibao"、"工作流节点"、"开通节点"时使用。
---
# 合思工作流节点开通
批量开通合思工作流节点。
节点名称与 type 对照见 [灰度节点清单](references/gray-nodes.md)。 **`nodes` 参数填清单中的 `type` 列值(如 `code`、`risk`),不是中文名。** 遇到同名节点或用户只提供模糊名称时,先根据 type 核对并向用户确认。
## 参数提取
用户通常会贴浏览器请求(curl),从请求中自动提取参数:
| 参数 | 提取位置 | 说明 |
|------|----------|------|
| token | Header `accesstoken` 或 Cookie `ekb-access-token` | accessToken |
| corpId | Header `corpid` 或 URL query `corpId` | 企业 ID |
| baseUrl | URL 协议+域名部分(如 `https://dd2.hosecloud.com`) | 自定义合思地址 |
| nodes | 向用户确认 | 节点名,逗号分隔 |
**域名判断**:URL 不是 `*.hosecloud.com` 而是 `dd2.hosecloud.com` 这类就是自定义域名,必须提取为 `baseUrl`。
## 执行
```bash
curl -s -X POST 'https://d9jxeccs5j.sealosgzg.site/hose-workflow-node' \
-H 'Content-Type: application/json' \
-d '{"token":"TOKEN","corpId":"CORPID","nodes":"NODES"}'
```
可选参数:
- `baseUrl: "https://..."` — **重要:用户使用了自定义域名时(如 `dd2.hosecloud.com`),必须加上此参数。** 不传则默认走正式环境认证地址。
- `isTest: true` — 仅用于切换内部标记,不能替代 `baseUrl`
## 结果处理
**成功**:`{"success":true,"data":{"msg":"新开通的节点:xxx"}}`
**失败排查**:
- `认证失败` + `缺少或传错了 baseUrl` — 检查用户请求是否走自定义域名,加上 `baseUrl`
- `认证失败` + 其他 — token 过期,让用户重新获取
- 节点名错误 — 核对名称拼写
@@ -0,0 +1,119 @@
# 灰度节点清单
来源:`合思工作流开通节点_节点开通-节点列表_灰度节点.csv`。共 109 条非空记录,去重后 108 条。
开通请求的 `nodes` 使用本表的 **`type` 列值**(第三列),如 `code`、`risk`。第二列"节点名称"仅用于展示和核对。
> 注意:`数据映射`有两个可用类型(`mapping`、`dmn`);同名节点需先与用户确认具体类型。`单据查询详情(跨租户)`在源文件中有重复记录,以下仅保留一条。
| 显示名称 | 节点名称(nodes) | type |
| --- | --- | --- |
| JS节点(新) | JS节点(新) | `code-js2` |
| 重算审批流 | 重算审批流 | `recalculate-the-approval-flow` |
| 提示框 | 提示框 | `ui-notification` |
| 定时任务节点 | 定时任务节点 | `start` |
| 推送飞书消息 | 推送飞书消息 | `feishu-sendMsg` |
| 飞书消息 | 飞书消息 | `message-feishu` |
| if节点 | if节点 | `if` |
| http节点 | http节点 | `http` |
| 遍历数组 | 遍历数组 | `loop` |
| 循环节点 | 循环节点 | `while` |
| 企业微信开放平台获取子部门ID列表 | 企业微信开放平台获取子部门ID列表 | `wecom-department` |
| 易桥参数转化 | 易桥参数转化 | `eBridge-mapData` |
| 代码节点 | 代码节点 | `code` |
| 数据映射 | 数据映射 | `mapping` |
| 纷享销客鉴权 | 纷享销客鉴权 | `fxiaoke-auth` |
| 纷享销客数据列表 | 纷享销客数据列表 | `fxiaoke-list` |
| NetSuite数据列表 | NetSuite数据列表 | `netsuite-sync` |
| NetSuite数据创建 | NetSuite数据创建 | `netsuite-create` |
| 易桥鉴权 | 易桥鉴权 | `ebridge-auth` |
| 新增业务对象数据 | 新增业务对象数据 | `ekuaibao-datalink-create` |
| 定时触发 | 定时触发 | `clock` |
| 纷享销客触发器 | 纷享销客触发器 | `fxiaoke-trigger` |
| 到达业务对象数据中的日期时触发 | 到达业务对象数据中的日期时触发 | `ekuaibao-datalink-time-trigger` |
| 发送邮件 | 发送邮件 | `email` |
| 查找业务对象数据 | 查找业务对象数据 | `ekuaibao-datalink-filter` |
| 修改业务对象数据 | 修改业务对象数据 | `ekuaibao-datalink-edit` |
| NetSuite数据删除 | NetSuite数据删除 | `netsuite-delete` |
| 薪人薪事触发器 | 薪人薪事触发器 | `xrxs-trigger` |
| 新增业务对象数据时触发 | 新增业务对象数据时触发 | `ekuaibao-datalink-create-trigger` |
| 变更业务对象数据时触发 | 变更业务对象数据时触发 | `ekuaibao-datalink-change-trigger` |
| 单据审批事件触发器 | 单据审批事件触发器 | `ekuaibao-flowform-trigger` |
| 发送短信 | 发送短信 | `message` |
| webhook触发器 | webhook触发器 | `webhook` |
| 对话框 | 对话框 | `ui-dialog` |
| 流程日志 | 流程日志 | `task-log` |
| 动态节点测试 | 动态节点测试 | `task-dynamic-test` |
| 条件节点 | 条件节点 | `condition` |
| OpenAPI | OpenAPI | `task-openapi` |
| 终止节点 | 终止节点 | `stop` |
| 收集节点 | 收集节点 | `context` |
| 到达单据日期时触发 | 到达单据日期时触发 | `flow-change-trigger` |
| 获取钉钉考勤 | 获取钉钉考勤 | `task-dynamic-ding-attendance` |
| 摊销节点 | 摊销节点 | `apportion` |
| 创建单据 | 创建单据 | `flow-create-task` |
| 站内信 | 站内信 | `message-internet` |
| 钉钉消息 | 钉钉消息 | `message-dingtalk` |
| 修改角色 | 修改角色 | `role-update` |
| 依次执行 | 依次执行 | `every` |
| 查询申请事项详情 | 查询申请事项详情 | `ekuaibao-requision-detail` |
| 查询单据详情 | 查询单据详情 | `flow-detail` |
| 查询单据历史详情 | 查询单据历史详情 | `flow-detail-versioned` |
| 业务对象数据按钮触发 | 业务对象数据按钮触发 | `datalink-button-trigger` |
| 查找行程数据 | 查找行程数据 | `ekuaibao-tmc-datalink-filter` |
| 新增行程数据时触发 | 新增行程数据时触发 | `ekuaibao-tmc-datalink-create-trigger` |
| 变更行程数据时触发 | 变更行程数据时触发 | `ekuaibao-tmc-datalink-change-trigger` |
| 到达行程日期时触发 | 到达行程日期时触发 | `ekuaibao-tmc-datalink-time-trigger` |
| 查询发票 | 查询发票 | `ekuaibao-invoice-datalink-filter` |
| 结果输出 | 结果输出 | `output` |
| EBOT触发 | EBOT触发 | `ekuaibao-ebot-trigger` |
| 补充发票触发 | 补充发票触发 | `other-event-trigger` |
| 发票验真 | 发票验真 | `invoice-verification` |
| JS节点 | JS节点 | `code-js` |
| 数据转化 | 数据转化 | `data-convert` |
| 新摊销 | 新摊销 | `amortization` |
| 数据映射 | 数据映射 | `dmn` |
| 查询人员 | 查询人员 | `ekuaibao-staff-filter` |
| 查询单据列表 | 查询单据列表 | `flow-list` |
| HAB触发器 | HAB触发器 | `hab-trigger-task` |
| 申请事项触发器 | 申请事项触发器 | `ekuaibao-requisition-trigger` |
| 创建部门 | 创建部门 | `department-create` |
| 部门查询 | 部门查询 | `department-filter` |
| 新增人员 | 新增人员 | `staff-create` |
| 查询随手记列表 | 查询随手记列表 | `ekuaibao-ecard-fee-filter` |
| 查询人员详情 | 查询人员详情 | `ekuaibao-staff-detail` |
| 查询部门详情 | 查询部门详情 | `ekuaibao-department-detail` |
| 查询易商卡申请事项列表 | 查询易商卡申请事项列表 | `ekuaibao-ecard-requisition-filter` |
| 查询飞书部门 | 查询飞书部门 | `feishu-department-filter` |
| 修改部门 | 修改部门 | `ekuaibao-department-update` |
| 站外信 | 站外信 | `message-outnet` |
| AI节点 | AI节点 | `ekb-ai` |
| 修改单据 | 修改单据 | `flow-update-task` |
| 提取文本(word,PDF) | 提取文本(word,PDF) | `ekb-ai-pdf` |
| 单据风险写入 | 单据风险写入 | `risk` |
| 天润工单查询 | 天润工单查询 | `tr-select` |
| 天润工单评论 | 天润工单评论 | `tr-comment` |
| 天润工单查询详情 | 天润工单查询详情 | `tr-detail` |
| Dify接入 | Dify接入 | `dify` |
| 图片URL识别 | 图片URL识别 | `ekb-ai-url` |
| AI文本理解 | AI文本理解 | `ekb-minimax-text` |
| AI图像理解 | AI图像理解 | `ekb-minimax-photo` |
| 查询角色下的人员 | 查询角色下的人员 | `search-staff-by-role` |
| 发票巡检 | 发票巡检 | `ekuaibao-invoice-inspector` |
| 招商银行商务卡查询 | 招商银行商务卡查询 | `task-zs` |
| 单据查询详情(跨租户) | 单据查询详情(跨租户) | `escape` |
| 海亮单据查询详情 | 海亮单据查询详情 | `hl-detail` |
| 单据查询详情AI审批专用 | 单据查询详情AI审批专用 | `mapping-detail` |
| 海亮数据集列表 | 海亮数据集列表 | `hl` |
| 查询易商卡流水的费用信息 | 查询易商卡流水的费用信息 | `ekuaibao-ecard-fee-detail-filter` |
| Ebot审批 | Ebot审批 | `ebot-approval-flow` |
| 给OA账号发送提醒 | 给OA账号发送提醒 | `oa` |
| 查询历史单据测试集 | 查询历史单据测试集 | `flow-sample-list` |
| 分类汇总 | 分类汇总 | `aggregation` |
| 单据转译节点 | 单据转译节点 | `flow-format` |
| 导出表格 | 导出表格 | `excel` |
| AI附件理解 | AI附件理解 | `ai-attachment` |
| AI智能匹配 | AI智能匹配 | `ai-classification` |
| AI智能提取 | AI智能提取 | `ai-extraction` |
| 延迟执行节点 | 延迟执行节点 | `task-dynamic-delay` |
+2 -1
View File
@@ -2,6 +2,7 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test";
import { runAiProCli } from "./aipro-cli.js";
import { closeApprovalDatabase, getApprovalDatabase } from "./domains/approval/db.js";
import { ApprovalRepository } from "./domains/approval/repository.js";
import { getVersionInfo } from "./version.js";
describe("CLI - hose-aipro 审批流与网关阻拦全链路测试", () => {
beforeEach(() => {
@@ -29,7 +30,7 @@ describe("CLI - hose-aipro 审批流与网关阻拦全链路测试", () => {
const version = await runAiProCli(["version", "--json"]);
const help = await runAiProCli(["help", "--json"]);
expect(JSON.parse(version.stdout)).toEqual({ name: "hose-aipro", version: expect.any(String) });
expect(JSON.parse(version.stdout)).toEqual(getVersionInfo("hose-aipro"));
expect(JSON.parse(help.stdout).help).toContain("hose-aipro");
expect(version.stderr).toBe("");
expect(help.stderr).toBe("");
+3 -3
View File
@@ -17,7 +17,7 @@ import {
import { getRawBillFlow } from "./domains/bill/api.js";
import { approveBill, rejectBill, getTranslatorContext } from "./domains/bill/tools.js";
import { translateBillFlowToMarkdown } from "./domains/bill/translator.js";
import { VERSION } from "./version.js";
import { VERSION, formatVersionLabel, getVersionInfo } from "./version.js";
export async function runAiProCli(rawArgs: string[]): Promise<{ stdout: string; stderr: string; exitCode: number }> {
const parsed = parseArgs(rawArgs);
@@ -77,8 +77,8 @@ export async function runAiProCli(rawArgs: string[]): Promise<{ stdout: string;
if (command === "version" || command === "v" || booleanOption(parsed.options, ["version", "v"])) {
return {
stdout: jsonMode
? printJson({ name: "hose-aipro", version: VERSION }) + "\n"
: `hose-aipro v${VERSION}\n`,
? printJson(getVersionInfo("hose-aipro")) + "\n"
: `${formatVersionLabel("hose-aipro")}\n`,
stderr: "",
exitCode: 0,
};
+14 -1
View File
@@ -44,7 +44,7 @@ export async function handleBillCommand(
const actionTarget = () => parsed.args[0] || stringOption(parsed.options, ["code", "id"]);
const requireWriteConfirmation = async () => {
if (isDryRun(parsed, runtime) || booleanOption(parsed.options, ["yes", "y", "confirm", "force-write"])) return;
if (!process.stdin.isTTY || !process.stdout.isTTY) {
if (!process.stdin.isTTY || !process.stdout.isTTY || Boolean(process.env.CI) || process.env.NODE_ENV === "test") {
requireMutationConfirmation(
parsed,
runtime,
@@ -149,6 +149,19 @@ export async function handleBillCommand(
case "list":
case "search":
case undefined: {
const mine = booleanOption(parsed.options, ["mine", "my", "self"]);
if (mine) {
const { handleTaskCommand } = await import("./task.js");
return handleTaskCommand(
{
...parsed,
area: "task",
action: "submitted",
},
runtime
);
}
const code = stringOption(parsed.options, ["code", "c"]);
const keyword = stringOption(parsed.options, ["keyword", "k", "q", "query"]);
const stage = stringOption(parsed.options, ["stage"]);
+35 -8
View File
@@ -1,3 +1,4 @@
import { existsSync } from "node:fs";
import { join } from "node:path";
import { importFromLink } from "../../core/auth/login.js";
import { resolveWritableEnterprisesDir } from "../../core/config/loader.js";
@@ -358,7 +359,7 @@ async function handleAddLink(parsed: CliParsedArgs, runtime: CliRuntime): Promis
const ttl = stringOption(parsed.options, ["ttl"]);
const expires = stringOption(parsed.options, ["expires", "days"]);
if (!linkUrl && process.stdin.isTTY) {
if (!linkUrl && process.stdin.isTTY && !process.env.CI && process.env.NODE_ENV !== "test") {
linkUrl = await prompt("请输入第三方协助/免密登录链接 URL: ");
}
@@ -370,15 +371,41 @@ async function handleAddLink(parsed: CliParsedArgs, runtime: CliRuntime): Promis
};
}
let targetCorpId = "";
try {
const parsedUrl = new URL(linkUrl);
targetCorpId = parsedUrl.searchParams.get("ekbCorpId") || "";
} catch {}
const targetDir = resolveWritableEnterprisesDir();
const existsAlready = Boolean(targetCorpId && existsSync(join(targetDir, `${targetCorpId}.json`)));
if (isDryRun(parsed, runtime)) {
return mutationPreview(parsed, runtime, "从协助链接导入企业凭证", name || "待解析企业", {
source: "assistance-link",
overwrite,
ttl: ttl || null,
expires: expires || null,
});
return mutationPreview(
parsed,
runtime,
"从协助链接导入企业凭证",
name || (targetCorpId ? `企业 [${targetCorpId}]` : "待解析企业"),
{
source: "assistance-link",
overwrite,
alreadyExists: existsAlready,
ttl: ttl || null,
expires: expires || null,
note: existsAlready && !overwrite ? "检测到本地已存在该企业配置,导入执行时请带上 --overwrite 参数" : undefined,
}
);
}
requireMutationConfirmation(parsed, runtime, "从协助链接导入企业凭证", `hose-use corps add-link <url> --yes`);
const nextConfirmCmd = existsAlready && !overwrite
? `hose-use corps add-link <url> --overwrite --yes`
: `hose-use corps add-link <url> --yes`;
const confirmOp = existsAlready && !overwrite
? `从协助链接导入企业凭证(检测到目标企业 [${targetCorpId}] 已存在,需覆盖更新)`
: "从协助链接导入企业凭证";
requireMutationConfirmation(parsed, runtime, confirmOp, nextConfirmCmd);
try {
const corp = await importFromLink(linkUrl, {
+2 -2
View File
@@ -1,5 +1,5 @@
import { writeFileSync } from "node:fs";
import { VERSION } from "../version.js";
import { formatVersionLabel } from "../version.js";
import type { OutputOptions } from "./types.js";
import { PayloadTooLargeError } from "./errors.js";
import { renderScopedHelp } from "./help.js";
@@ -115,7 +115,7 @@ export function printTable(
export function printHelp(target: string[] = []): string {
if (target.length) return renderScopedHelp(target);
return `
合思/易快报企业级 CLI 工具 (hose-use) v${VERSION}
合思/易快报企业级 CLI 工具 (${formatVersionLabel("hose-use")})
用法:
hose-use <命令域> <子命令> [参数] [选项]
+4 -4
View File
@@ -1,6 +1,6 @@
import { describe, expect, it } from "bun:test";
import { runCli } from "./runner.js";
import { VERSION } from "../version.js";
import { VERSION_INFO, formatVersionLabel } from "../version.js";
describe("CLI runner - version and help aliases", () => {
const versionVariants = [
@@ -25,7 +25,7 @@ describe("CLI runner - version and help aliases", () => {
const result = await runCli(args);
expect(result.exitCode).toBe(0);
expect(result.stderr).toBe("");
expect(result.stdout).toBe(`hose-use v${VERSION}\n`);
expect(result.stdout).toBe(`${formatVersionLabel("hose-use")}\n`);
});
}
@@ -50,7 +50,7 @@ describe("CLI runner - version and help aliases", () => {
const result = await runCli(args);
expect(result.exitCode).toBe(0);
expect(result.stderr).toBe("");
expect(result.stdout).toContain(`合思/易快报企业级 CLI 工具 (hose-use) v${VERSION}`);
expect(result.stdout).toContain(`合思/易快报企业级 CLI 工具 (${formatVersionLabel("hose-use")})`);
expect(result.stdout).toContain("用法:");
});
}
@@ -94,7 +94,7 @@ describe("CLI runner - version and help aliases", () => {
const version = await runCli(["version", "--json"]);
expect(JSON.parse(help.stdout).help).toContain("workflow -");
expect(JSON.parse(version.stdout)).toEqual({ name: "hose-use", version: VERSION });
expect(JSON.parse(version.stdout)).toEqual(VERSION_INFO);
expect(help.stderr).toBe("");
expect(version.stderr).toBe("");
});
+2 -2
View File
@@ -1,4 +1,4 @@
import { VERSION } from "../version.js";
import { VERSION_INFO, formatVersionLabel } from "../version.js";
import { parseArgs, stringOption, booleanOption, outputOptions } from "./parser.js";
import { printHelp, printJson, redactSensitiveText } from "./printer.js";
import { classifyCliError } from "./errors.js";
@@ -144,7 +144,7 @@ async function dispatchCli(
if (isVersionRequested(parsed)) {
return {
stdout: jsonMode ? printJson({ name: "hose-use", version: VERSION }) : `hose-use v${VERSION}\n`,
stdout: jsonMode ? printJson(VERSION_INFO) : `${formatVersionLabel("hose-use")}\n`,
stderr: "",
exitCode: 0,
};
+3 -1
View File
@@ -80,7 +80,9 @@ export class SqliteCache implements ICache {
[namespace, key, serialized, expiresAt, now]
);
} catch (err) {
console.error(`[cache] SqliteCache.set error for ${namespace}:${key}:`, err);
if (process.env.DEBUG || process.env.NODE_ENV === "development") {
console.error(`[cache] SqliteCache.set error for ${namespace}:${key}:`, err);
}
}
}
+39
View File
@@ -66,6 +66,45 @@ describe("Core DB - 数据库连接与结构化迁移机制 (加固测试)", ()
expect(countRow.c).toBe(2);
});
test("migration 2 可以平滑升级遗留的单列主键 cache_entries 表", () => {
const legacyDb = new Database(":memory:");
legacyDb.run(`
CREATE TABLE cache_entries (
key TEXT PRIMARY KEY,
namespace TEXT NOT NULL,
value TEXT NOT NULL,
expires_at INTEGER NOT NULL,
updated_at INTEGER NOT NULL
);
`);
legacyDb.run(
"INSERT INTO cache_entries (key, namespace, value, expires_at, updated_at) VALUES ('k1', 'n1', 'v1', 9999, 1000)"
);
// 运行全量迁移
runMigrations(legacyDb);
// 验证升级后支持相同 key 不同 namespace
expect(() => {
legacyDb.run(
"INSERT INTO cache_entries (key, namespace, value, expires_at, updated_at) VALUES ('k1', 'n2', 'v2', 9999, 1000)"
);
}).not.toThrow();
// 验证 ON CONFLICT(namespace, key) 正常工作
expect(() => {
legacyDb.run(`
INSERT INTO cache_entries (namespace, key, value, expires_at, updated_at)
VALUES ('n1', 'k1', 'v1_updated', 9999, 2000)
ON CONFLICT(namespace, key) DO UPDATE SET value = excluded.value
`);
}).not.toThrow();
const row = legacyDb.query("SELECT value FROM cache_entries WHERE namespace = 'n1' AND key = 'k1'").get() as { value: string };
expect(row.value).toBe("v1_updated");
legacyDb.close();
});
test("再次执行 runMigrations 保证幂等且不抛错", () => {
expect(() => runMigrations(db)).not.toThrow();
});
+40
View File
@@ -144,6 +144,46 @@ export const migrations: DatabaseMigration[] = [
seedDefaultPreference(db);
},
},
{
version: 2,
name: "002_cache_entries_composite_primary_key",
up(db: Database): void {
// 检查 cache_entries 的主键约束
// 兼容历史遗留的 key PRIMARY KEY 单列主键库,平滑升级为复合主键 (namespace, key)
const tableInfo = db.query("PRAGMA table_info(cache_entries)").all() as Array<{
name: string;
pk: number;
}>;
const pkColumns = tableInfo.filter((col) => col.pk > 0);
const isCompositePk =
pkColumns.length === 2 &&
pkColumns.some((c) => c.name === "namespace") &&
pkColumns.some((c) => c.name === "key");
if (!isCompositePk) {
db.run(`
CREATE TABLE IF NOT EXISTS cache_entries_v2 (
namespace TEXT NOT NULL,
key TEXT NOT NULL,
value TEXT NOT NULL,
expires_at INTEGER NOT NULL,
updated_at INTEGER NOT NULL,
PRIMARY KEY (namespace, key)
);
`);
try {
db.run(`
INSERT OR IGNORE INTO cache_entries_v2 (namespace, key, value, expires_at, updated_at)
SELECT namespace, key, value, expires_at, updated_at FROM cache_entries;
`);
} catch {}
db.run("DROP TABLE IF EXISTS cache_entries;");
db.run("ALTER TABLE cache_entries_v2 RENAME TO cache_entries;");
db.run("CREATE INDEX IF NOT EXISTS idx_cache_namespace ON cache_entries(namespace);");
db.run("CREATE INDEX IF NOT EXISTS idx_cache_expires_at ON cache_entries(expires_at);");
}
},
},
];
function seedDefaultPreference(db: Database): void {
+10 -1
View File
@@ -40,6 +40,13 @@ describe("embedded-skill - 多文件内嵌 Skill 体系", () => {
expect(EMBEDDED_SKILL_FILES["references/store.md"]).toContain("hose-use keys");
expect(EMBEDDED_SKILL_FILES["SKILL.md"]).toContain("--reveal -o <path>");
expect(EMBEDDED_SKILL_FILES["SKILL.md"]).toContain("references/store.md");
// 套件结构:根入口路由到 multi/ 下的子技能
expect(EMBEDDED_SKILL_FILES["SKILL.md"]).toContain("multi/ekuaibao-mvel/SKILL.md");
expect(EMBEDDED_SKILL_FILES["multi/ekuaibao-mvel/SKILL.md"]).toContain("name: ekuaibao-mvel");
expect(EMBEDDED_SKILL_FILES["multi/ekuaibao-mvel/agents/openai.yaml"]).toContain("ekuaibao-mvel");
expect(EMBEDDED_SKILL_FILES["multi/ekuaibao-nodes/SKILL.md"]).toContain("name: ekuaibao-nodes");
expect(EMBEDDED_SKILL_FILES["multi/ekuaibao-nodes/references/gray-nodes.md"]).toContain("灰度节点清单");
});
test("installSkillFiles 递归保留层级结构并落盘到目标目录", () => {
@@ -47,7 +54,7 @@ describe("embedded-skill - 多文件内嵌 Skill 体系", () => {
try {
const res = installSkillFiles(tmp);
expect(res.targetDir).toBe(tmp);
expect(res.files.length).toBe(14);
expect(res.files.length).toBe(18);
expect(existsSync(join(tmp, "SKILL.md"))).toBe(true);
expect(existsSync(join(tmp, "agents", "openai.yaml"))).toBe(true);
expect(existsSync(join(tmp, "references", "auth.md"))).toBe(true);
@@ -59,6 +66,8 @@ describe("embedded-skill - 多文件内嵌 Skill 体系", () => {
expect(existsSync(join(tmp, "references", "workflow.md"))).toBe(true);
expect(existsSync(join(tmp, "references", "service.md"))).toBe(true);
expect(existsSync(join(tmp, "references", "store.md"))).toBe(true);
expect(existsSync(join(tmp, "multi", "ekuaibao-mvel", "SKILL.md"))).toBe(true);
expect(existsSync(join(tmp, "multi", "ekuaibao-nodes", "references", "gray-nodes.md"))).toBe(true);
} finally {
rmSync(tmp, { recursive: true, force: true });
}
+8
View File
@@ -16,6 +16,10 @@ import refRole from "../../skills/hose-use/references/role.md" with { type: "tex
import refApproval from "../../skills/hose-use/references/approval.md" with { type: "text" };
import refFeeType from "../../skills/hose-use/references/feetype.md" with { type: "text" };
import refStore from "../../skills/hose-use/references/store.md" with { type: "text" };
import multiMvel from "../../skills/hose-use/multi/ekuaibao-mvel/SKILL.md" with { type: "text" };
import multiMvelAgent from "../../skills/hose-use/multi/ekuaibao-mvel/agents/openai.yaml" with { type: "text" };
import multiNodes from "../../skills/hose-use/multi/ekuaibao-nodes/SKILL.md" with { type: "text" };
import multiNodesGray from "../../skills/hose-use/multi/ekuaibao-nodes/references/gray-nodes.md" with { type: "text" };
export const EMBEDDED_SKILL_FILES: Record<string, string> = {
"SKILL.md": skillMain,
@@ -32,6 +36,10 @@ export const EMBEDDED_SKILL_FILES: Record<string, string> = {
"references/workflow.md": refWorkflow,
"references/service.md": refService,
"references/store.md": refStore,
"multi/ekuaibao-mvel/SKILL.md": multiMvel,
"multi/ekuaibao-mvel/agents/openai.yaml": multiMvelAgent,
"multi/ekuaibao-nodes/SKILL.md": multiNodes,
"multi/ekuaibao-nodes/references/gray-nodes.md": multiNodesGray,
};
export function getSkillContent(): string {
+4
View File
@@ -3,6 +3,7 @@ import ky, { KyInstance } from "ky";
export interface CreateClientOptions {
prefixUrl: string;
headers?: Record<string, string>;
timeout?: number | false;
}
export interface CreateAuthClientOptions {
@@ -11,18 +12,21 @@ export interface CreateAuthClientOptions {
onUnauthorized?: () => Promise<void> | void;
onAuthFailure?: (response: Response) => Error;
retryUnauthorized?: boolean;
timeout?: number | false;
}
export function createClient(options: CreateClientOptions): KyInstance {
return ky.create({
prefix: options.prefixUrl,
headers: options.headers,
timeout: options.timeout ?? 30000,
});
}
export function createAuthClient(options: CreateAuthClientOptions): KyInstance {
return ky.create({
prefix: options.prefixUrl,
timeout: options.timeout ?? 30000,
retry: {
limit: options.retryUnauthorized === false ? 0 : 1,
methods: ["get", "post", "put", "delete", "patch"],
+2 -1
View File
@@ -313,10 +313,11 @@ export async function getRawBillRisk(
export async function searchRawBills(
client: KyInstance,
corpId: string,
options: { start?: number; count?: number } = {}
options: { start?: number; count?: number; timeout?: number | false } = {}
): Promise<RawBillSearchResponse> {
const response = await client.post("api/v2/invoice/search", {
searchParams: { corporationId: corpId, corpId },
timeout: options.timeout ?? 30000,
json: {
limit: {
start: options.start ?? 0,
+19 -4
View File
@@ -32,6 +32,7 @@ import {
} from "./translator.js";
import {
type RawBillItem,
type RawBillSearchResponse,
type FormattedBill,
type BillPageResult,
type EntityMeta,
@@ -1145,10 +1146,24 @@ export async function searchAndFormatBills(
params: BillQueryParams = {}
): Promise<BillPageResult> {
const { dictionary } = await getFieldDictionary(client, corpId);
const searchRes = await searchRawBills(client, corpId, {
start: params.start ?? 0,
count: params.count ?? 50,
});
let searchRes: RawBillSearchResponse;
try {
searchRes = await searchRawBills(client, corpId, {
start: params.start ?? 0,
count: params.count ?? 50,
});
} catch (err) {
if (String(err).includes("timed out") || (err as any)?.name === "TimeoutError") {
throw new Error(
`全局单据台账检索超时。在大企业或海量单据租户中,全量检索较为耗时。\n` +
`建议:\n` +
` - 查看当前员工发起的单据:hose-use task submitted 或 hose-use bill list --mine\n` +
` - 查看待我审批单据:hose-use task todo\n` +
` - 按单号精确查询:hose-use bill get <单号>`
);
}
throw err;
}
let filtered = searchRes.items;
+61
View File
@@ -0,0 +1,61 @@
import { describe, expect, test } from "bun:test";
import { formatDevVersion, parseGitDescribe, resolveVersionInfo } from "./version.js";
describe("build version metadata", () => {
test("parses tagged commits and dirty state", () => {
expect(parseGitDescribe("v0.8.6-3-gabc1234")).toMatchObject({
baseVersion: "0.8.6",
commitsAhead: 3,
commit: "abc1234",
dirty: false,
});
expect(parseGitDescribe("v0.8.6-dirty")).toMatchObject({
baseVersion: "0.8.6",
commitsAhead: 0,
dirty: true,
});
});
test("formats a visible semver development version", () => {
expect(formatDevVersion("0.8.6", 2, "abc1234", false)).toBe("0.8.6-dev.2+gabc1234");
expect(formatDevVersion("0.8.6", 2, "abc1234", true)).toBe("0.8.6-dev.2+gabc1234.dirty");
});
test("uses compile-time release metadata when a binary provides it", () => {
expect(resolveVersionInfo({
env: {
HOSE_BUILD_VERSION: "0.8.6",
HOSE_BUILD_CHANNEL: "release",
HOSE_BUILD_IS_RELEASE: "true",
},
})).toEqual({ name: "hose-use", version: "0.8.6", channel: "release", isRelease: true });
});
test("includes git metadata in development mode", () => {
const info = resolveVersionInfo({
env: {
HOSE_BUILD_VERSION: "0.8.6-dev.2+gabc1234",
HOSE_BUILD_CHANNEL: "dev",
HOSE_BUILD_IS_RELEASE: "false",
HOSE_BUILD_GIT_BASE: "0.8.6",
HOSE_BUILD_GIT_COMMITS_AHEAD: "2",
HOSE_BUILD_GIT_COMMIT: "abc1234",
HOSE_BUILD_GIT_DIRTY: "true",
HOSE_BUILD_GIT_DESCRIBE: "v0.8.6-2-gabc1234-dirty",
},
});
expect(info).toEqual({
name: "hose-use",
version: "0.8.6-dev.2+gabc1234",
channel: "dev",
isRelease: false,
git: {
baseVersion: "0.8.6",
commitsAhead: 2,
commit: "abc1234",
dirty: true,
describe: "v0.8.6-2-gabc1234-dirty",
},
});
});
});
+126 -1
View File
@@ -1 +1,126 @@
export const VERSION = "0.8.6";
import { spawnSync } from "node:child_process";
import packageJson from "../package.json" with { type: "json" };
export interface GitBuildInfo {
baseVersion: string;
commitsAhead: number;
commit: string;
dirty: boolean;
describe: string;
}
export interface VersionInfo {
name: "hose-use" | "hose-aipro";
version: string;
channel: "release" | "dev";
isRelease: boolean;
git?: GitBuildInfo;
}
export function parseGitDescribe(output: string, fallbackVersion = packageJson.version): GitBuildInfo | null {
const trimmed = output.trim();
if (!trimmed) return null;
const dirty = trimmed.endsWith("-dirty");
const clean = dirty ? trimmed.slice(0, -6) : trimmed;
const longMatch = clean.match(/^v?(\d+\.\d+\.\d+(?:-[a-zA-Z0-9.]+)?)-(\d+)-g([0-9a-f]+)$/);
if (longMatch && longMatch[1] && longMatch[2] && longMatch[3]) {
return { baseVersion: longMatch[1], commitsAhead: Number.parseInt(longMatch[2], 10), commit: longMatch[3], dirty, describe: trimmed };
}
const tagMatch = clean.match(/^v?(\d+\.\d+\.\d+(?:-[a-zA-Z0-9.]+)?)$/);
if (tagMatch && tagMatch[1]) {
return { baseVersion: tagMatch[1], commitsAhead: 0, commit: "", dirty, describe: trimmed };
}
const commitMatch = clean.match(/^([0-9a-f]{7,40})$/);
if (commitMatch && commitMatch[1]) {
return { baseVersion: fallbackVersion, commitsAhead: 0, commit: commitMatch[1], dirty, describe: trimmed };
}
return null;
}
export function formatDevVersion(baseVersion: string, commitsAhead: number, commit: string, dirty: boolean): string {
const dirtySuffix = dirty ? ".dirty" : "";
const commitSuffix = commit ? `+g${commit}${dirtySuffix}` : dirty ? "+dirty" : "";
return `${baseVersion}-dev.${commitsAhead}${commitSuffix}`;
}
export function resolveVersionInfo(options?: { env?: Record<string, string | undefined>; cwd?: string }): VersionInfo {
const customEnv = options?.env;
// Keep these as direct property accesses: Bun can inline them into compiled binaries.
const buildVersion = customEnv?.HOSE_BUILD_VERSION ?? process.env.HOSE_BUILD_VERSION;
const buildIsRelease = customEnv?.HOSE_BUILD_IS_RELEASE ?? process.env.HOSE_BUILD_IS_RELEASE;
const buildChannel = customEnv?.HOSE_BUILD_CHANNEL ?? process.env.HOSE_BUILD_CHANNEL;
const buildGitBase = customEnv?.HOSE_BUILD_GIT_BASE ?? process.env.HOSE_BUILD_GIT_BASE;
const buildGitCommitsAhead = customEnv?.HOSE_BUILD_GIT_COMMITS_AHEAD ?? process.env.HOSE_BUILD_GIT_COMMITS_AHEAD;
const buildGitCommit = customEnv?.HOSE_BUILD_GIT_COMMIT ?? process.env.HOSE_BUILD_GIT_COMMIT;
const buildGitDirty = customEnv?.HOSE_BUILD_GIT_DIRTY ?? process.env.HOSE_BUILD_GIT_DIRTY;
const buildGitDescribe = customEnv?.HOSE_BUILD_GIT_DESCRIBE ?? process.env.HOSE_BUILD_GIT_DESCRIBE;
const forceRelease = customEnv?.HOSE_FORCE_RELEASE ?? process.env.HOSE_FORCE_RELEASE;
if (buildVersion) {
const isRelease = buildIsRelease === "true";
const channel = (buildChannel as "release" | "dev") || (isRelease ? "release" : "dev");
const result: VersionInfo = { name: "hose-use", version: buildVersion, channel, isRelease };
if (buildGitBase) {
result.git = {
baseVersion: buildGitBase,
commitsAhead: Number.parseInt(buildGitCommitsAhead || "0", 10),
commit: buildGitCommit || "",
dirty: buildGitDirty === "true",
describe: buildGitDescribe || buildVersion,
};
}
return result;
}
if (buildIsRelease === "true" || forceRelease === "1") {
return { name: "hose-use", version: packageJson.version, channel: "release", isRelease: true };
}
try {
const result = spawnSync("git", ["describe", "--tags", "--long", "--dirty", "--always"], {
cwd: options?.cwd,
encoding: "utf8",
stdio: ["ignore", "pipe", "ignore"],
});
if (result.status === 0 && result.stdout) {
const gitInfo = parseGitDescribe(result.stdout.trim(), packageJson.version);
if (gitInfo) {
if (!gitInfo.commit) {
const revision = spawnSync("git", ["rev-parse", "--short", "HEAD"], {
cwd: options?.cwd,
encoding: "utf8",
stdio: ["ignore", "pipe", "ignore"],
});
if (revision.status === 0 && revision.stdout) gitInfo.commit = revision.stdout.trim();
}
return {
name: "hose-use",
version: formatDevVersion(gitInfo.baseVersion, gitInfo.commitsAhead, gitInfo.commit, gitInfo.dirty),
channel: "dev",
isRelease: false,
git: gitInfo,
};
}
}
} catch {
// Fall back below if git is unavailable.
}
return { name: "hose-use", version: `${packageJson.version}-dev.0+local`, channel: "dev", isRelease: false };
}
export const VERSION_INFO = resolveVersionInfo();
export const VERSION = VERSION_INFO.version;
export const IS_RELEASE = VERSION_INFO.isRelease;
export const CHANNEL = VERSION_INFO.channel;
export function getVersionInfo(name: VersionInfo["name"]): VersionInfo {
return { ...VERSION_INFO, name };
}
export function formatVersionLabel(name: VersionInfo["name"]): string {
return `${name} v${VERSION}${CHANNEL === "dev" ? " [DEV BUILD]" : ""}`;
}