refactor(core): migrate to Bun and converge acquisition policies and Agent boundaries

This commit is contained in:
root committed 2026-10-13 14:37:03 +08:00
1 parent 3f1c6d02f6
commit 27c0f27434
268 files changed
+7468 -7852

No files matched your search

+9 -9
View File
@@ -1,11 +1,11 @@
// 身份数据清理(FIX-5):删除冲突别名、合并重复的内容单元、删除孤立的临时内容单元。默认只读(dry-run),加 --apply 才改库。
//
// 用法(DATABASE_URL 必须显式给出,脚本不带默认库):
// DATABASE_URL=postgres://umt:***@<host>:5432/umt deno run -A scripts/identity-cleanup.ts [--dry-run] # 看清单(按类别列删除 / 保留)
// DATABASE_URL=… deno run -A scripts/identity-cleanup.ts --apply # 执行(单个事务)
// DATABASE_URL=… deno run -A scripts/identity-cleanup.ts --keep-orphans # 不删孤立单元
// DATABASE_URL=… deno run -A scripts/identity-cleanup.ts --entity <作品 id> # 只看 / 只处理一部作品
// DATABASE_URL=… deno run -A scripts/identity-cleanup.ts --merge-duplicates [--apply] # 只做第 2 步:合并重复单元(DH-1)
// DATABASE_URL=postgres://umt:***@<host>:5432/umt bun scripts/identity-cleanup.ts [--dry-run] # 看清单(按类别列删除 / 保留)
// DATABASE_URL=… bun scripts/identity-cleanup.ts --apply # 执行(单个事务)
// DATABASE_URL=… bun scripts/identity-cleanup.ts --keep-orphans # 不删孤立单元
// DATABASE_URL=… bun scripts/identity-cleanup.ts --entity <作品 id> # 只看 / 只处理一部作品
// DATABASE_URL=… bun scripts/identity-cleanup.ts --merge-duplicates [--apply] # 只做第 2 步:合并重复单元(DH-1)
//
// 1. 冲突别名:只处理自动识别登记的站点别名(title_alias.source = 'site',作品级)。以下任一成立即删除:
// - shared:同一归一化别名还挂在别的作品上,且它不是本作品自己的名字(主标题 / 原标题 / TMDB 译名与别名);
@@ -32,20 +32,20 @@ import {
type UnitMergeGroup,
} from "../apps/server/src/modules/sources-identity/service/unit-merge.ts";
const argv = [...Deno.args];
const argv = [...process.argv.slice(2)];
const APPLY = argv.includes("--apply");
if (APPLY && argv.includes("--dry-run")) {
console.error("--apply 与 --dry-run 不能同时给出");
Deno.exit(2);
process.exit(2);
}
const MERGE_ONLY = argv.includes("--merge-duplicates");
const KEEP_ORPHANS = argv.includes("--keep-orphans") || MERGE_ONLY;
const entityArg = argv.indexOf("--entity");
const ONLY_ENTITY = entityArg >= 0 ? (argv[entityArg + 1] ?? null) : null;
const url = Deno.env.get("DATABASE_URL");
const url = process.env.DATABASE_URL;
if (!url) {
console.error("需要 DATABASE_URL(脚本不带默认库)");
Deno.exit(2);
process.exit(2);
}
const db = new pg.Client({ connectionString: url });
await db.connect();