fix: 修复审核记录导出进度与后台等待机制

为审核记录导出增加可复用的本地后台任务及 status/wait/list,等待超时或观察进程退出后任务继续执行。
统一实时脱敏诊断输出,保留 stdout 单一 JSON;补齐高级参数、预览和筛选配置摘要。
默认保留合思未找到单据,分别统计单据与审核记录,并显式报告部分补取失败。
补充 CLI/Skill 版本诊断、技能路由及回归测试,修复企业列表加载开销和源码更新测试隔离。
This commit is contained in:
gitea committed 2026-10-27 15:59:04 +08:00
1 parent 477cc630b4
commit db5a3f7139
24 files changed
+1239 -174

No files matched your search

+7 -4
View File
@@ -5,7 +5,7 @@ import { PRIMARY_LINTERS_DIR, OFFICIAL_LINTERS_DIR } from "../paths.js";
import { VERSION } from "../../version.js";
import { getLastCorpConfigLoadIssues, getLastGlobalConfigIssue, loadCorpConfigs, loadGlobalConfig } from "../config/loader.js";
import { formatBeijingIso } from "../config/timestamps.js";
import { getDefaultGlobalSkillDir } from "../embedded-skill.js";
import { getDefaultGlobalSkillDir, getSkillVersionStatus } from "../skill-version.js";
import { resolveUsageFilePath } from "../stats/usage-tracker.js";
import {
EMBEDDED_DIRECTORY_SPECS,
@@ -38,6 +38,7 @@ export interface DoctorDiagnosis {
platform: string;
engine: string;
};
skill: ReturnType<typeof getSkillVersionStatus>;
directories: Record<string, DirectoryHealth>;
enterprises: {
total: number;
@@ -273,19 +274,20 @@ export function diagnoseSystem(): DoctorDiagnosis {
}
// Check 4: Agent Skill
const skill = getSkillVersionStatus(VERSION);
if (directories.agentSkillDir?.exists) {
checks.push({
id: "agent_skill",
title: "AI Agent 技能",
status: "ok",
message: `已就绪于 ${agentSkillDir}`
status: skill.status === "matched" ? "ok" : "warn",
message: skill.status === "matched" ? `已就绪于 ${agentSkillDir} (版本 ${skill.installedVersion})` : `CLI ${VERSION}; Skill ${skill.installedVersion ?? "无法识别版本"}; ${skill.nextAction}`
});
} else {
checks.push({
id: "agent_skill",
title: "AI Agent 技能",
status: "warn",
message: `未在 ${agentSkillDir} 检测到技能,可运行 'seal-use skill sync' 安装`
message: `未在 ${agentSkillDir} 检测到技能,可运行 'seal-use skill install' 安装`
});
}
@@ -360,6 +362,7 @@ export function diagnoseSystem(): DoctorDiagnosis {
platform: `${process.platform} (${process.arch})`,
engine
},
skill,
directories,
enterprises: {
total: corps.length,
+35 -32
View File
@@ -10,44 +10,46 @@ import file6 from "../../skills/seal-use/assets/hose-open-platform-credentials.p
import file7 from "../../skills/seal-use/assets/hose-open-platform-product-config.png" with { type: "file" };
import file8 from "../../skills/seal-use/references/approval-attachment-trace.md" with { type: "text" };
import file9 from "../../skills/seal-use/references/approval-bad-cases.md" with { type: "text" };
import file10 from "../../skills/seal-use/references/approval-run-lightweight.md" with { type: "text" };
import file11 from "../../skills/seal-use/references/cli.md" with { type: "text" };
import file12 from "../../skills/seal-use/references/customer-feedback-rule-remediation.md" with { type: "text" };
import file13 from "../../skills/seal-use/references/documents.md" with { type: "text" };
import file14 from "../../skills/seal-use/references/enterprise-onboarding.md" with { type: "text" };
import file15 from "../../skills/seal-use/references/expense-data.md" with { type: "text" };
import file16 from "../../skills/seal-use/references/first-time-user.md" with { type: "text" };
import file17 from "../../skills/seal-use/references/hose-enterprise-auth.md" with { type: "text" };
import file18 from "../../skills/seal-use/references/hose-enterprise-deploy.md" with { type: "text" };
import file19 from "../../skills/seal-use/references/hose-enterprise-init.md" with { type: "text" };
import file20 from "../../skills/seal-use/references/langfuse-trace.md" with { type: "text" };
import file21 from "../../skills/seal-use/references/report-templates.md" with { type: "text" };
import file22 from "../../skills/seal-use/references/rule-lightweight.md" with { type: "text" };
import file23 from "../../skills/seal-use/references/rule-lint.md" with { type: "text" };
import file24 from "../../skills/seal-use/references/staging-simulation-workflow.md" with { type: "text" };
import file25 from "../../skills/seal-use/references/webhook-resource-pack.md" with { type: "text" };
import file10 from "../../skills/seal-use/references/approval-run-export.md" with { type: "text" };
import file11 from "../../skills/seal-use/references/approval-run-lightweight.md" with { type: "text" };
import file12 from "../../skills/seal-use/references/cli.md" with { type: "text" };
import file13 from "../../skills/seal-use/references/customer-feedback-rule-remediation.md" with { type: "text" };
import file14 from "../../skills/seal-use/references/documents.md" with { type: "text" };
import file15 from "../../skills/seal-use/references/enterprise-onboarding.md" with { type: "text" };
import file16 from "../../skills/seal-use/references/expense-data.md" with { type: "text" };
import file17 from "../../skills/seal-use/references/first-time-user.md" with { type: "text" };
import file18 from "../../skills/seal-use/references/hose-enterprise-auth.md" with { type: "text" };
import file19 from "../../skills/seal-use/references/hose-enterprise-deploy.md" with { type: "text" };
import file20 from "../../skills/seal-use/references/hose-enterprise-init.md" with { type: "text" };
import file21 from "../../skills/seal-use/references/langfuse-trace.md" with { type: "text" };
import file22 from "../../skills/seal-use/references/report-templates.md" with { type: "text" };
import file23 from "../../skills/seal-use/references/rule-lightweight.md" with { type: "text" };
import file24 from "../../skills/seal-use/references/rule-lint.md" with { type: "text" };
import file25 from "../../skills/seal-use/references/staging-simulation-workflow.md" with { type: "text" };
import file26 from "../../skills/seal-use/references/webhook-resource-pack.md" with { type: "text" };
export const EMBEDDED_SKILL_TEXT_FILES: Record<string, string> = {
"SKILL.md": file0,
"agents/openai.yaml": file1,
"references/approval-attachment-trace.md": file8,
"references/approval-bad-cases.md": file9,
"references/approval-run-lightweight.md": file10,
"references/cli.md": file11,
"references/customer-feedback-rule-remediation.md": file12,
"references/documents.md": file13,
"references/enterprise-onboarding.md": file14,
"references/expense-data.md": file15,
"references/first-time-user.md": file16,
"references/hose-enterprise-auth.md": file17,
"references/hose-enterprise-deploy.md": file18,
"references/hose-enterprise-init.md": file19,
"references/langfuse-trace.md": file20,
"references/report-templates.md": file21,
"references/rule-lightweight.md": file22,
"references/rule-lint.md": file23,
"references/staging-simulation-workflow.md": file24,
"references/webhook-resource-pack.md": file25,
"references/approval-run-export.md": file10,
"references/approval-run-lightweight.md": file11,
"references/cli.md": file12,
"references/customer-feedback-rule-remediation.md": file13,
"references/documents.md": file14,
"references/enterprise-onboarding.md": file15,
"references/expense-data.md": file16,
"references/first-time-user.md": file17,
"references/hose-enterprise-auth.md": file18,
"references/hose-enterprise-deploy.md": file19,
"references/hose-enterprise-init.md": file20,
"references/langfuse-trace.md": file21,
"references/report-templates.md": file22,
"references/rule-lightweight.md": file23,
"references/rule-lint.md": file24,
"references/staging-simulation-workflow.md": file25,
"references/webhook-resource-pack.md": file26,
};
export const EMBEDDED_SKILL_ASSET_PATHS: Record<string, string> = {
@@ -70,6 +72,7 @@ export const EMBEDDED_SKILL_ALL_PATHS = [
"assets/hose-open-platform-product-config.png",
"references/approval-attachment-trace.md",
"references/approval-bad-cases.md",
"references/approval-run-export.md",
"references/approval-run-lightweight.md",
"references/cli.md",
"references/customer-feedback-rule-remediation.md",
+4 -15
View File
@@ -1,6 +1,8 @@
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { homedir } from "node:os";
import { dirname, join } from "node:path";
import { getDefaultGlobalSkillDir, parseSkillVersion } from "./skill-version.js";
export { getDefaultGlobalSkillDir } from "./skill-version.js";
import {
EMBEDDED_SKILL_ASSET_PATHS,
@@ -33,27 +35,14 @@ export function getSkillContent(): string {
* success either way, so the version is the only signal that says *which generation* of the
* document actually landed on disk.
*/
export function parseSkillVersion(markdown: string): string | undefined {
return markdown.match(/^\s*version:\s*(\S+)\s*$/m)?.[1];
}
export { parseSkillVersion } from "./skill-version.js";
/** Reads the version of an installed SKILL.md, or `undefined` when it is missing or unreadable. */
export function readInstalledSkillVersion(
skillFile: string = join(getDefaultGlobalSkillDir(), "SKILL.md")
): string | undefined {
try {
return parseSkillVersion(readFileSync(skillFile, "utf8"));
} catch {
return undefined;
}
}
export { readInstalledSkillVersion } from "./skill-version.js";
/** The version of the skill compiled into this build, used to assert what an install wrote. */
export const EMBEDDED_SKILL_VERSION = parseSkillVersion(getSkillContent());
export function getDefaultGlobalSkillDir(): string {
return join(homedir(), ".agents", "skills", "seal-use");
}
function getLegacyGlobalSkillDir(): string {
return join(homedir(), ".agents", "skills", "seal-home");
+24
View File
@@ -0,0 +1,24 @@
import { describe, expect, test } from "bun:test"
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"
import { tmpdir } from "node:os"
import { join } from "node:path"
import { getSkillVersionStatus, parseSkillVersion } from "./skill-version.js"
describe("lightweight Skill version inspection", () => {
test("compares release generations without mistaking a development suffix for drift", () => {
const dir = mkdtempSync(join(tmpdir(), "seal-skill-version-"))
const file = join(dir, "SKILL.md")
try {
expect(getSkillVersionStatus("1.2.3", file).status).toBe("missing")
const content = "---\nname: seal-use\nmetadata:\n version: \"1.2.3\"\n---\n"
writeFileSync(file, content)
expect(getSkillVersionStatus("1.2.3-dev.6+abc.dirty", file)).toMatchObject({ status: "matched", installedVersion: "1.2.3", nextAction: null })
expect(getSkillVersionStatus("1.2.2", file)).toMatchObject({ status: "skill_newer", nextAction: "seal-use update" })
expect(getSkillVersionStatus("1.2.4", file)).toMatchObject({ status: "cli_newer", nextAction: "seal-use skill install" })
expect(readFileSync(file, "utf8")).toBe(content)
writeFileSync(file, "# invalid metadata\nversion: 1.2.3\n")
expect(getSkillVersionStatus("1.2.3", file).status).toBe("unknown")
expect(parseSkillVersion("---\r\nmetadata:\r\n version: '2.0.0'\r\n---\r\n")).toBe("2.0.0")
} finally { rmSync(dir, { recursive: true, force: true }) }
})
})
+28
View File
@@ -0,0 +1,28 @@
import { existsSync, readFileSync } from "node:fs"
import { homedir } from "node:os"
import { join } from "node:path"
import { compareSemVer } from "./semver.js"
// Keep local version inspection independent of the embedded Skill asset graph.
export function getDefaultGlobalSkillDir(): string {
return join(homedir(), ".agents", "skills", "seal-use")
}
export function parseSkillVersion(markdown: string): string | undefined {
const frontMatter = markdown.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/)?.[1]
return frontMatter?.match(/^\s*version:\s*["']?(\d+\.\d+\.\d+(?:[-+][\w.+-]+)?)["']?\s*$/m)?.[1]
}
export function readInstalledSkillVersion(skillFile = join(getDefaultGlobalSkillDir(), "SKILL.md")): string | undefined {
try { return parseSkillVersion(readFileSync(skillFile, "utf8")) } catch { return undefined }
}
export function getSkillVersionStatus(cliVersion: string, skillFile = join(getDefaultGlobalSkillDir(), "SKILL.md")) {
const installed = existsSync(skillFile)
const installedVersion = readInstalledSkillVersion(skillFile) ?? null
const cliBaseVersion = cliVersion.match(/^v?(\d+\.\d+\.\d+)/)?.[1] ?? cliVersion
const comparison = installedVersion ? compareSemVer(installedVersion, cliBaseVersion) : null
const status = !installed ? "missing" : comparison === null ? "unknown" : comparison > 0 ? "skill_newer" : comparison < 0 ? "cli_newer" : "matched"
const nextAction = status === "skill_newer" ? "seal-use update" : status === "cli_newer" || status === "missing" || status === "unknown" ? "seal-use skill install" : null
return { cliVersion, cliBaseVersion, installedVersion, installed, status, nextAction }
}