feat(identify-words): 识别词——全局识别词(MP 语法)+ 作品识别词(季集换算),规则页「识别词」页签

- 新表 identify_words(0094):全局一块 + 每部作品一块原文,带版本与审计;episode_mapping_rule 转成文本行后删表
- 全局识别词移植 MP WordsMatcher(屏蔽 / 替换 / 集数偏移 / 替换+偏移 / {[tmdbid=…]}),所有按标题 / 文件名识别的地方解析前套用,命中的行记在解析结果上;保存后后台按改动行重新识别
- 作品识别词:S02 >> S01 EP+24 / S01E13 >> S00E01 / S01 @组 >> 忽略,解析器 + 打印器 + 编译;发布组繁简视为同一个
- 去掉规则自动停用:算出来对不上季表只待确认,要停用就注释掉那一行
- 集数待确认的采用 / 忽略与智能体 apply_rule 改为往作品识别词追加一行(带来历注释)
- 编辑器可视化 / 文本两种模式改同一份原文,保存前试算;作品页「集数映射」用同一个编辑器

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
This commit is contained in:
rootandClaude Opus 5.5 committed 2026-10-08 17:03:00 +08:00
1 parent 12f8fc59c3
commit 63e94b308e
90 files changed
+6366 -2131

No files matched your search

@@ -8,6 +8,7 @@ import { submitDownload, syncDownloads } from "../../src/modules/acquisition-org
import { type FrozenPlan, planImport } from "../../src/modules/acquisition-organize/services/organize.ts";
import { queueScrape, runScrapeRecord } from "../../src/modules/acquisition-organize/services/scrape.ts";
import { canonicalParsed } from "../../src/modules/sources-identity/service/episode-resolution.ts";
import { setWordsText } from "../support/identify-words.ts";
import { createHarness, fakeDisk, type Harness, pgAvailable, seedBase, seedEntity } from "./harness.ts";
// 文件侧集数映射(docs/plan/episode-resolution.md 批次 3):整理计划与季包选文件对文件名重新解析出的季集,
@@ -264,27 +265,32 @@ describe.skipIf(!hasPg)("整理与季包选文件按作品映射集数(真实 PG
expect(decision.evidence).toMatchObject({ sourceReleaseIds: [rel.id] });
});
it("有 active 规则 EP-12(→ 第 2 季)时整理按规则", async () => {
it("作品识别词 `S01 @ANi >> S02 EP-12` 时整理按这一行", async () => {
const { id } = await series("规则作品");
const rule = await h.db
.insertInto("episode_mapping_rule")
.values({
media_entity_id: id,
season: 1,
release_group: "ANi",
kind: "expression",
expression: "EP-12",
target_season: 2,
created_by_type: "user",
created_by_id: "admin",
})
.returning("id")
.executeTakeFirstOrThrow();
await setWordsText(h.db, id, "S01 @ANi >> S02 EP-12\n");
const plan = await dryRun(id, "rule");
const [m] = mains(plan);
expect(m).toMatchObject({ season: 2, episodes: { start: 2, end: 2 } });
expect(m!.dst).toMatch(/S02E02/);
expect(Object.values(plan.facts)[0]!.episodeResolution).toMatchObject({ method: "rule", ruleId: rule.id });
expect(Object.values(plan.facts)[0]!.episodeResolution).toMatchObject({
method: "rule",
ruleLine: 1,
ruleText: "S01 @ANi >> S02 EP-12",
});
});
it("全局识别词也套到整理时的文件名上:`Rule Show - <> \\[1080P >> EP-12` 把 - 14 认成第 2 集", async () => {
const { id } = await series("全局识别词作品");
await setWordsText(h.db, null, "Rule Show - <> \\[1080P >> EP-12\n");
try {
const plan = await dryRun(id, "rule");
const [m] = mains(plan);
expect(m).toMatchObject({ season: 1, episodes: { start: 2, end: 2 } });
expect(m!.dst).toMatch(/S01E02/);
expect(Object.values(plan.facts)[0]!.episodeResolution).toMatchObject({ method: "raw" });
} finally {
await setWordsText(h.db, null, "");
}
});
it("原号本来就对(S01E05):整理行为不变", async () => {