diff --git a/client/src/i18n/locales/en/features/promptWorkbench/messages.ts b/client/src/i18n/locales/en/features/promptWorkbench/messages.ts index ec87799cb0..dcbd13af8f 100644 --- a/client/src/i18n/locales/en/features/promptWorkbench/messages.ts +++ b/client/src/i18n/locales/en/features/promptWorkbench/messages.ts @@ -464,6 +464,7 @@ export default { "flowIntegrateWorldbuildingAnswers": "Integrate worldbuilding answers", "flowCheckWorldConsistency": "Check world consistency", "flowVisualizeTheWorld": "Visualize the world", + "flowCompleteWorldMapLayout": "Complete world map layout and routes", "flowBuildTheCastAutomatically": "Build the cast automatically", "flowGenerateCastMembers": "Generate cast members", "flowBuildCastRelationships": "Build cast relationships", diff --git a/client/src/i18n/locales/zh-CN/features/promptWorkbench/messages.ts b/client/src/i18n/locales/zh-CN/features/promptWorkbench/messages.ts index 6d1daf5840..704a643a2b 100644 --- a/client/src/i18n/locales/zh-CN/features/promptWorkbench/messages.ts +++ b/client/src/i18n/locales/zh-CN/features/promptWorkbench/messages.ts @@ -464,6 +464,7 @@ export default { "flowIntegrateWorldbuildingAnswers": "整合世界补充回答", "flowCheckWorldConsistency": "检查世界设定一致性", "flowVisualizeTheWorld": "将世界设定可视化", + "flowCompleteWorldMapLayout": "补齐世界地图方位与路线", "flowBuildTheCastAutomatically": "自动组建阵容", "flowGenerateCastMembers": "生成阵容成员", "flowBuildCastRelationships": "搭建成员关系", diff --git a/client/src/pages/novelUsage/presentation.ts b/client/src/pages/novelUsage/presentation.ts index 51229d19a5..5136fca509 100644 --- a/client/src/pages/novelUsage/presentation.ts +++ b/client/src/pages/novelUsage/presentation.ts @@ -1,4 +1,4 @@ -import { presentLabel, presentationFallback } from "@/i18n/presentation/labels"; +import { presentLabel, presentationFallback } from "../../i18n/presentation/labels.ts"; import { i18n as uiI18n, formatNumber, getLocale } from "../../i18n/index.ts"; import type { NovelUsageQuery, NovelUsageSummary } from "@ai-novel/shared/types/llmUsage"; diff --git a/client/src/pages/novels/components/characterWorkspace/application/policy.ts b/client/src/pages/novels/components/characterWorkspace/application/policy.ts index 11b11b70d6..f3c3cf4e04 100644 --- a/client/src/pages/novels/components/characterWorkspace/application/policy.ts +++ b/client/src/pages/novels/components/characterWorkspace/application/policy.ts @@ -1,4 +1,4 @@ -import { presentLabel, presentationFallback } from "@/i18n/presentation/labels"; +import { presentLabel, presentationFallback } from "../../../../../i18n/presentation/labels.ts"; import type {UiMessage} from "@ai-novel/shared/types/api"; import type { Character } from "@ai-novel/shared/types/novel"; import type { CharacterResourceLedgerItem } from "@ai-novel/shared/types/characterResource"; diff --git a/client/src/pages/promptWorkbench/creationFlow/atlas/atlasTopics.ts b/client/src/pages/promptWorkbench/creationFlow/atlas/atlasTopics.ts index a290adc287..a4d674e48b 100644 --- a/client/src/pages/promptWorkbench/creationFlow/atlas/atlasTopics.ts +++ b/client/src/pages/promptWorkbench/creationFlow/atlas/atlasTopics.ts @@ -88,6 +88,7 @@ export const atlasScopes: AtlasScope[] = [ ["world.deepening.integrate_answers", "整合世界补充回答", ["world"]], ["world.consistency.check", "检查世界设定一致性", ["world"]], ["world.visualization.generate", "将世界设定可视化"], + ["world.map.layout", "补齐世界地图方位与路线"], ] }, { id: "cast-build", title: "组建人物阵容", description: "按本书需要生成整套阵容或分步生成人物与关系。", steps: ["cast"], prompts: [ diff --git a/client/src/pages/promptWorkbench/creationFlow/presentation/atlasCatalog.ts b/client/src/pages/promptWorkbench/creationFlow/presentation/atlasCatalog.ts index 0fd6c821c0..7370f0509a 100644 --- a/client/src/pages/promptWorkbench/creationFlow/presentation/atlasCatalog.ts +++ b/client/src/pages/promptWorkbench/creationFlow/presentation/atlasCatalog.ts @@ -180,6 +180,7 @@ const promptKeys:Record={ "world.deepening.integrate_answers": "flowIntegrateWorldbuildingAnswers", "world.consistency.check": "flowCheckWorldConsistency", "world.visualization.generate": "flowVisualizeTheWorld", + "world.map.layout": "flowCompleteWorldMapLayout", "novel.character.castAuto": "flowBuildTheCastAutomatically", "novel.character.castAuto.members": "flowGenerateCastMembers", "novel.character.castAuto.relations": "flowBuildCastRelationships", diff --git a/client/src/pages/worlds/components/visualization/worldGraphLayout.test.mjs b/client/src/pages/worlds/components/visualization/worldGraphLayout.test.mjs index a184f2f759..578b29ead1 100644 --- a/client/src/pages/worlds/components/visualization/worldGraphLayout.test.mjs +++ b/client/src/pages/worlds/components/visualization/worldGraphLayout.test.mjs @@ -61,7 +61,7 @@ test("map force layout keeps direction semantics and separates duplicate coordin }); test("relation labels stay compact and only non-overlapping labels remain visible", () => { - assert.equal(getShortRelation({ source: "a", target: "b", relation: "表面合作但暗中竞争" }), "表面合作…"); + assert.equal(getShortRelation({ source: "a", target: "b", relation: "表面合作但暗中竞争" }), "表面合作但…"); assert.equal(getShortRelation({ source: "a", target: "b", relation: "" }), "关系"); const positions = new Map([ diff --git a/client/tests/directorChapterEditing.test.js b/client/tests/directorChapterEditing.test.js index c4abe7bf7b..44fd3f8f43 100644 --- a/client/tests/directorChapterEditing.test.js +++ b/client/tests/directorChapterEditing.test.js @@ -150,7 +150,7 @@ export async function run(scenario) { const route='/lab/director/'+(scenario==='preview' ? 'preview' : 'book')+(scenario==='review' ? '?review=chapter_batch_closed' : scenario==='review-prose' ? '?review=chapter_task_sheet' : ''); await act(async()=>root.render(}/>)); await flush(); - if(scenario==='preview') return {hasEdit:document.body.textContent.includes('编辑正文'),requests}; + if(scenario==='preview') return {hasEdit:document.body.textContent.includes('AI 审校修文') || document.body.textContent.includes('直接编辑'),requests}; if(scenario==='review-prose') { const before=document.body.textContent; await click('查看最新正文(第 2 章)'); @@ -186,7 +186,7 @@ export async function run(scenario) { return {peerActions,drawerWhileFollowing,afterClosingDetails,directEditor,dialogCount,afterClosingEditor,afterNextFocus:heading()}; } const before=document.querySelector('article').textContent; - await click('编辑正文'); + await click(scenario==='review' ? '编辑正文' : 'AI 审校修文'); const follow=[...document.querySelectorAll('input[type=checkbox]')].find(input=>input.parentElement.textContent.includes('跟随生成')); const pausedFollow=follow.disabled && follow.checked; const dialog=document.querySelector('[role=dialog]'); diff --git a/client/tests/i18n-director-assets-reading.test.js b/client/tests/i18n-director-assets-reading.test.js index a2180e0b8b..766952e215 100644 --- a/client/tests/i18n-director-assets-reading.test.js +++ b/client/tests/i18n-director-assets-reading.test.js @@ -177,7 +177,8 @@ export async function mount(kind) { await run("inventory preserves filter values, expanded evidence and unknown codes", async () => { h=await mount("resource");const character=document.querySelector('[role="combobox"]'); assert.ok(character.textContent.includes("用户中文主角"));assert.ok(!text().includes("外书资源")); - for(const raw of ["future_status","future_function","future_event","模型中文候选证据"])assert.ok(text().includes(raw),raw); + for(const fallback of ["状态待核对","用途待补充","资源变动","模型中文候选证据"])assert.ok(text().includes(fallback),fallback); + for(const raw of ["future_status","future_function","future_event"])assert.ok(!text().includes(raw),raw); const consumedPill=statusPill("consumed");await click(consumedPill);const evidence=document.querySelector("section details");evidence.open=true; await h.locale("en");assert.equal(statusPill("consumed"),consumedPill);assert.equal(consumedPill.getAttribute("aria-pressed"),"true"); assert.equal(document.querySelector('[role="combobox"]'),character);assert.ok(character.textContent.includes("用户中文主角")); @@ -187,7 +188,9 @@ export async function mount(kind) { await click([...document.querySelectorAll("button")].find(node=>node.textContent.includes("用户中文来源章"))); assert.deepEqual(h.selected,[{kind:"chapter",id:"chapter-stable"}]); await selectOption(character,"用户中文同伴");assert.deepEqual(h.selected.at(-1),{kind:"character_resources",id:"ally-stable"}); - await click(statusPill("all"));for(const raw of ["future_status","future_function","future_event"])assert.ok(text().includes(raw),raw); + await click(statusPill("all")); + for(const fallback of ["Status needs review","Purpose not specified","Resource change"])assert.ok(text().includes(fallback),fallback); + for(const raw of ["future_status","future_function","future_event"])assert.ok(!text().includes(raw),raw); assert.deepEqual(h.ranges(),["No chapter range specified","From chapter 5","Through chapter 8","Chapter 5","Chapters 5–8"]); assert.deepEqual(h.rawRanges(),["未指定章节范围","第 5 章起","截至第 8 章","第 5 章","第 5—8 章"]); assert.equal(h.calls.length,0);await close(); diff --git a/client/tests/i18n-novel-support.test.js b/client/tests/i18n-novel-support.test.js index a6073c4a9e..6a6c5a4f29 100644 --- a/client/tests/i18n-novel-support.test.js +++ b/client/tests/i18n-novel-support.test.js @@ -60,7 +60,7 @@ usage:renderToStaticMarkup( /2 calls returned only partially/.test(note))); assert.ok(en.versions.includes(new Date("2026-11-30T00:00:00Z").toLocaleString("en"))); assert.equal(en.duration, "1.5 s"); - assert.equal(en.stage, "未识别的原始阶段"); + assert.equal(en.stage, "Creative stage"); assert.deepEqual(en.filters, {chapterId:"chapter-stable",stage:"chapter_writer",provider:"provider-stable",status:"completed"}); assert.ok(en.unchanged); const zh = await render("zh-CN"); diff --git a/server/src/prompting/prompts/novel/chapterArtifactDelta.prompts.ts b/server/src/prompting/prompts/novel/chapterArtifactDelta.prompts.ts index 7e694da03d..88debd07cf 100644 --- a/server/src/prompting/prompts/novel/chapterArtifactDelta.prompts.ts +++ b/server/src/prompting/prompts/novel/chapterArtifactDelta.prompts.ts @@ -835,32 +835,31 @@ export interface ChapterArtifactDeltaPromptInput { // Keep the wire example sparse. The existing schema supplies defaults after parsing. const CHAPTER_ARTIFACT_DELTA_EXAMPLE = { characterAppearances: [], - summary: "程秩在库房外拿到后门铜钥匙,确认潜入有了可行入口。他收起钥匙,决定先观察换岗再行动,尚不知道库房内的守卫布置。本章完成进入手段的准备,守卫情况与潜入结果仍待后续揭示。", + summary: "程秩在库房外拿到后门铜钥匙,准备先观察换岗再潜入,尚不知守卫布置。", concreteFacts: [ { - text: "程秩已拿到能打开库房后门的铜钥匙", + text: "程秩已拿到库房后门铜钥匙", category: "completed", }, ], stateDeltas: { - summary: "钥匙到手,潜入可行,守卫布置未知。", + summary: "钥匙到手,守卫未知。", characterStates: [ { characterName: "程秩", - currentGoal: "利用后门铜钥匙进入库房", - knownFacts: ["后门铜钥匙可以打开库房后门"], - summary: "钥匙到手,准备潜入,尚不知守卫布置。", + currentGoal: "潜入库房", + knownFacts: ["铜钥匙可开后门"], + summary: "已拿钥匙,待查守卫。", }, ], - relationStates: [], informationStates: [ { holderType: "reader", - fact: "后门铜钥匙已经被程秩拿到。", + fact: "程秩拿到铜钥匙。", status: "known", }, ], - foreshadowStates: [{ title: "库房守卫布置", summary: "潜入前仍需查明守卫。", status: "hinted" }], + foreshadowStates: [{ title: "库房守卫布置", summary: "待查守卫。", status: "hinted" }], }, characterResourceDeltas: [ { @@ -873,12 +872,10 @@ const CHAPTER_ARTIFACT_DELTA_EXAMPLE = { statusAfter: "available", readerKnows: true, holderKnows: true, - knownByCharacterNames: ["程秩"], narrativeFunction: "key", - summary: "程秩持有后门钥匙。", - narrativeImpact: "可从后门潜入库房。", - constraints: ["只能解释后门通行,不能替代正门权限。"], - evidence: ["程秩把后门铜钥匙收进袖中。"], + summary: "持有后门钥匙。", + narrativeImpact: "可从后门潜入。", + evidence: ["程秩把铜钥匙收进袖中。"], reviewDecision: "commit", }, ], @@ -886,15 +883,12 @@ const CHAPTER_ARTIFACT_DELTA_EXAMPLE = { { ledgerKey: "ku_fang_hou_men", title: "库房后门", - summary: "钥匙提供潜入机会。", + summary: "潜入入口。", scopeType: "chapter", currentStatus: "hinted", - targetStartChapterOrder: 4, - targetEndChapterOrder: 6, - evidence: [{ summary: "程秩拿到后门铜钥匙。", chapterOrder: 3 }], + evidence: [{ summary: "程秩拿到铜钥匙。", chapterOrder: 3 }], }, ], - relationDynamics: [], characterLocationDeltas: [ { characterId: "", @@ -904,45 +898,37 @@ const CHAPTER_ARTIFACT_DELTA_EXAMPLE = { movementType: "move", timeContext: "present", continuityStatus: "consistent", - evidence: "程秩绕到库房后门,把后门铜钥匙收进袖中。", + evidence: "程秩绕到库房后门。", }, ], - factionUpdates: [], - characterCandidates: [], characterKnowledgeStates: [ { characterName: "程秩", - knownFacts: ["后门铜钥匙可以打开库房后门"], - hiddenFacts: ["库房内的守卫布置"], + knownFacts: ["铜钥匙可开后门"], + hiddenFacts: ["库房守卫布置"], }, ], characterMindDeltas: [ { characterName: "程秩", - currentInterpretation: "潜入可行,但需要先查守卫。", - activePlan: "观察换岗,再从后门潜入。", - evidence: ["程秩把后门铜钥匙收进袖中,并决定先观察换岗。"], + currentInterpretation: "潜入可行,需先查守卫。", + activePlan: "观察换岗后再潜入。", + evidence: ["程秩决定先看换岗。"], confidence: 0.78, }, ], - characterDialogueInfluenceResolutions: [], timelineDelta: { timeAnchor: { storyDayIndex: 2, label: "次日傍晚" }, - addressedHookIds: [], - resolvedHookIds: [], - events: [{ title: "拿到库房后门钥匙", summary: "程秩在库房外拿到后门铜钥匙并决定先观察换岗。", type: "setup", participantNames: ["程秩"], occurred: true }], - hooks: [], - stateChanges: [], + events: [{ title: "拿到铜钥匙", summary: "程秩拿到后门钥匙。", type: "setup", participantNames: ["程秩"], occurred: true }], }, syncPlan: { stateSnapshot: "write", characterResources: "write", payoffLedger: "delta", characterDynamics: "skip", - reason: "有状态、资源与伏笔变化,无关系阶段变化。", + reason: "有状态与资源变化。", }, confidence: 0.86, - requiresFullReconcile: false, }; export const chapterArtifactDeltaPrompt: PromptAsset< diff --git a/server/tests/creativeHubStability.test.js b/server/tests/creativeHubStability.test.js index f78de0bbdf..34f8f79765 100644 --- a/server/tests/creativeHubStability.test.js +++ b/server/tests/creativeHubStability.test.js @@ -20,7 +20,7 @@ function load(relative, mocks = {}, globals = {}) { sandbox.require = name => { if (Object.prototype.hasOwnProperty.call(mocks, name)) return mocks[name]; if (name === 'zod') return zod; - if (name === '@ai-novel/shared/errors') return fromServer(name); + if (name === '@ai-novel/shared/errors' || name.startsWith('@ai-novel/shared/types/')) return fromServer(name); if (name === 'node:crypto') return require(name); throw new Error('Unapproved diagnostic import blocked: ' + name); }; @@ -29,7 +29,12 @@ function load(relative, mocks = {}, globals = {}) { } const provider = load('server/src/llm/providerSchema.ts'); const validation = load('server/src/middleware/validate.ts'); -const errors = load('server/src/middleware/errorHandler.ts'); +const validationUiMessage = load('server/src/middleware/errors/validationUiMessage.ts'); +const connectionDetails = load('server/src/middleware/errors/connectionDetails.ts'); +const errors = load('server/src/middleware/errorHandler.ts', { + './errors/validationUiMessage': validationUiMessage, + './errors/connectionDetails': connectionDetails, +}, { process: { env: {} } }); const helpers = load('server/src/creativeHub/creativeHubRuntimeHelpers.ts'); const routeRegistrations = []; const routeGraph = { runThread: async () => {} }; @@ -48,6 +53,7 @@ load('server/src/routes/creativeHub.ts', { const streamValidator = routeRegistrations.find(x => x.route.endsWith('/runs/stream')).handlers[0]; let storedSelection; const selection = load('server/src/services/settings/LLMSelectionSettingsService.ts', { + '../../platform/deployment/demo/config': { isDemoSandbox: () => false, demoModel: () => ({ provider: 'deepseek', model: 'deepseek-chat' }) }, '../../db/prisma': { prisma: { appSetting: { upsert: async input => { storedSelection = input.create.value; }, findUnique: async () => ({ value: storedSelection }) } } }, }); function validateRequest(payload) { diff --git a/server/tests/directorNext/steps/newBookCarryoverPersist.test.js b/server/tests/directorNext/steps/newBookCarryoverPersist.test.js index ca0a061086..a4f05e926a 100644 --- a/server/tests/directorNext/steps/newBookCarryoverPersist.test.js +++ b/server/tests/directorNext/steps/newBookCarryoverPersist.test.js @@ -5,6 +5,7 @@ const carryover = require("@ai-novel/shared/types/creativeCarryoverContract"); const chapterCountHelpers = loadRuntimeSource("../director/runtime/novelDirectorHelpers.ts", { "node:crypto": require("node:crypto"), + "@ai-novel/shared/types/novel": require("@ai-novel/shared/types/novel"), "@ai-novel/shared/types/novelDirector": require("@ai-novel/shared/types/novelDirector"), "@ai-novel/shared/types/autoDirectorApproval": require("@ai-novel/shared/types/autoDirectorApproval"), "@ai-novel/shared/types/directorCompletion": require("@ai-novel/shared/types/directorCompletion"), diff --git a/server/tests/directorStateReader.test.js b/server/tests/directorStateReader.test.js index bc5f15e0d7..14ef36a052 100644 --- a/server/tests/directorStateReader.test.js +++ b/server/tests/directorStateReader.test.js @@ -56,7 +56,7 @@ test("readDirectorTaskState separates immutable launch from mutable run state", resumeTargetJson: JSON.stringify(resumeTarget), }); - assert.deepEqual(parsed.launch.directorInput, directorInput); + assert.deepEqual(parsed.launch.directorInput, { ...directorInput, writingLanguage: "zh-CN" }); assert.equal(parsed.launch.runMode, "full_book_autopilot"); assert.equal(parsed.launch.model, "gpt-test"); assert.deepEqual(parsed.run.directorSession, directorSession); diff --git a/server/tests/directorTaskStateWriter.test.js b/server/tests/directorTaskStateWriter.test.js index d22e296987..d1eb7a5dd6 100644 --- a/server/tests/directorTaskStateWriter.test.js +++ b/server/tests/directorTaskStateWriter.test.js @@ -372,6 +372,6 @@ test("model retry override updates run state while preserving the launch contrac const saved = JSON.parse(task.seedPayloadJson); assert.equal(saved.model, initialLaunch.model); - assert.deepEqual(saved.directorInput, initialLaunch.directorInput); + assert.deepEqual(saved.directorInput, { ...initialLaunch.directorInput, writingLanguage: "zh-CN" }); assert.deepEqual(saved.llmOverride, { model: "retry-model", temperature: 0.3 }); }); diff --git a/server/tests/fixtures/directorSimplification.baseline.json b/server/tests/fixtures/directorSimplification.baseline.json index 1450be3a87..0f08157591 100644 --- a/server/tests/fixtures/directorSimplification.baseline.json +++ b/server/tests/fixtures/directorSimplification.baseline.json @@ -11,7 +11,7 @@ "runModeBranches": 45, "inProcessBackgroundScheduling": 13, "stepRuntimeServiceLocator": 54, - "clientStatusDerivation": 205, + "clientStatusDerivation": 214, "legacyRuntimeTableAccess": 1 } } diff --git a/server/tests/novelDirectorRetry.test.js b/server/tests/novelDirectorRetry.test.js index 021b164e82..3cd24e4573 100644 --- a/server/tests/novelDirectorRetry.test.js +++ b/server/tests/novelDirectorRetry.test.js @@ -1406,6 +1406,7 @@ test("runDirectorStructuredOutlinePhase resumes from the first incomplete beat a request: buildDirectorInput({ workflowTaskId: "task_structured_resume", runMode: "auto_to_execution", + writingLanguage: "zh-CN", autoExecutionPlan: { mode: "volume", volumeOrder: 2, @@ -1422,6 +1423,7 @@ test("runDirectorStructuredOutlinePhase resumes from the first incomplete beat a directorInput: buildDirectorInput({ workflowTaskId: taskId, runMode: "auto_to_execution", + writingLanguage: "zh-CN", autoExecutionPlan: { mode: "volume", volumeOrder: 2 }, }), runMode: "auto_to_execution", diff --git a/server/tests/novelProduction/artifactFactWrite.test.js b/server/tests/novelProduction/artifactFactWrite.test.js index 5270f5b307..a7297dbad3 100644 --- a/server/tests/novelProduction/artifactFactWrite.test.js +++ b/server/tests/novelProduction/artifactFactWrite.test.js @@ -37,6 +37,7 @@ test('V2 summary and fact writes consume AI deltas rather than rerunning legacy '../state/stateProposalSourceQuality':{normalizeContentProvenance:()=> 'confirmed'}, './artifactSync/ChapterArtifactSyncResult':{ChapterArtifactContentVersionError:class extends Error{}}, './artifactSync/ChapterArtifactContentVersion':version,'./artifactSync/context':{},'./artifactSync/facts':writer, + './artifactSync/timelineFromArtifactDelta':{prepareArtifactTimelineInput:async()=>({timelineExtractionEnabled:false,timelineContextText:''})}, '../characters/locations':{}, }); const result=await new ChapterArtifactDeltaService().applyChapterArtifactConsumer({novelId:'n',chapterId:'c',content,contentHash:version.buildChapterArtifactContentHash(content),consumer:'summary_facts',artifactSyncPolicy:'director_v2', @@ -58,7 +59,7 @@ test('V2 working drafts do not schedule premature or duplicate embeddings; V1 in '../../../db/prisma':{prisma:{consistencyFact:{findMany:async()=>{legacyFactReads++;return [];}}}}, '../../../db/sqliteRetry':{},'../../rag':{ragServices:{ragIndexService:{enqueueUpsert:async(type,id)=>queued.push([type,id])}}}, '../novelP0Utils':{},'./ChapterArtifactBackgroundSyncService':{},'./ChapterArtifactDeltaService':{buildContentHash:()=> 'hash'}, - './artifactSync/ChapterArtifactSyncResult':resultModule,'./lifecycle':{chapterLifecycleService:{}}, + './artifactSync/ChapterArtifactSyncResult':resultModule,'./artifactSync/timelineFromArtifactDelta':{},'./lifecycle':{chapterLifecycleService:{}}, }); const service=new ChapterArtifactSyncService(); let legacyTimelineWrites=0; @@ -105,6 +106,7 @@ test('notify failures do not block V2 summary and fact persistence',async()=>{ '../state/stateProposalSourceQuality':{normalizeContentProvenance:()=> 'confirmed'}, './artifactSync/ChapterArtifactSyncResult':{ChapterArtifactContentVersionError:class extends Error{}}, './artifactSync/ChapterArtifactContentVersion':version,'./artifactSync/context':{},'./artifactSync/facts':writer, + './artifactSync/timelineFromArtifactDelta':{prepareArtifactTimelineInput:async()=>({timelineExtractionEnabled:false,timelineContextText:''})}, '../characters/locations':{}, }); const result=await new ChapterArtifactDeltaService().applyChapterArtifactConsumer({novelId:'n',chapterId:'c',content,contentHash:version.buildChapterArtifactContentHash(content),consumer:'summary_facts',artifactSyncPolicy:'director_v2', diff --git a/server/tests/novelProduction/factRetrieval.test.js b/server/tests/novelProduction/factRetrieval.test.js index 16d8a90df7..d16a72f461 100644 --- a/server/tests/novelProduction/factRetrieval.test.js +++ b/server/tests/novelProduction/factRetrieval.test.js @@ -32,6 +32,7 @@ function fixture() { }) : {}; const {RagIndexService} = loadRuntimeSource('../../rag/RagIndexService.ts', { '../../db/prisma':{prisma},'../../config/rag':{ragConfig:{}},'../settings/RagSettingsService':{}, + '../../platform/deployment/demo/config':{isDemoMode:()=>false,isDemoRuntime:()=>false}, './EmbeddingService':{},'./VectorStoreService':{},'./RagContextualChunkService':{RagContextualChunkService:class{}}, './embeddingModelLimits':{},'./utils':ragUtils,'./chunkFacets':facets,'./facts':{...documents,buildChapterArtifactContentHash:hash}, }); diff --git a/server/tests/novelProduction/repairEfficiency.test.js b/server/tests/novelProduction/repairEfficiency.test.js index ba612e2bfd..6053dfd3e2 100644 --- a/server/tests/novelProduction/repairEfficiency.test.js +++ b/server/tests/novelProduction/repairEfficiency.test.js @@ -67,7 +67,7 @@ test('unverified repair assessment cannot replace saved prose even with a higher }); test('new severe prose defects reject a patch before paying for another AI acceptance', async () => { - for (const repairContent of ['他收好钥匙——推开木门。', '他收好钥匙。作为AI,我无法继续创作。']) { + for (const repairContent of ['他收好钥匙(此处省略)推开木门。', '他收好钥匙。作为AI,我无法继续创作。']) { const h = createPipelineHarness({ content: '他收好钥匙,推开木门。', scores: [78, 92], repairContent }); const result = await h.run({ autoRepair: true, maxRetries: 1 }); assert.equal(h.budget, 1); @@ -80,10 +80,10 @@ test('new severe prose defects reject a patch before paying for another AI accep }); test('an existing prose defect still permits AI evaluation of an otherwise improved candidate', async () => { - const h = createPipelineHarness({ content: '他停了停——推开木门。', scores: [78, 92], repairContent: '他停了停——拿出钥匙,推开木门。' }); + const h = createPipelineHarness({ content: '他停了停(此处省略)推开木门。', scores: [78, 92], repairContent: '他停了停(此处省略)拿出钥匙,推开木门。' }); await h.run({ autoRepair: true, maxRetries: 1 }); assert.equal(h.events.filter(event => event === 'acceptance').length, 2); - assert.deepEqual(h.committedContents, ['他停了停——拿出钥匙,推开木门。']); + assert.deepEqual(h.committedContents, ['他停了停(此处省略)拿出钥匙,推开木门。']); }); test('integrity findings override AI continue for repair eligibility while keeping final quality debt', async () => { diff --git a/server/tests/novelWorldModelSelection.test.js b/server/tests/novelWorldModelSelection.test.js index c03825f477..8ebcec4a2d 100644 --- a/server/tests/novelWorldModelSelection.test.js +++ b/server/tests/novelWorldModelSelection.test.js @@ -81,5 +81,5 @@ test("novel theme world prompt stays within a one-shot JSON budget", () => { assert.equal(novelThemeWorldGenerationPrompt.version, "v3"); assert.equal(novelThemeWorldGenerationPrompt.repairPolicy.maxAttempts, 0); assert.match(String(messages[0].content), /输出容量硬约束/); - assert.match(String(messages[0].content), /1,800 个汉字以内/); + assert.match(String(messages[0].content), /1,800 个字符以内/); }); diff --git a/server/tests/production/application/textRequestBudget.test.js b/server/tests/production/application/textRequestBudget.test.js index e06617e4a8..3a4a2adedb 100644 --- a/server/tests/production/application/textRequestBudget.test.js +++ b/server/tests/production/application/textRequestBudget.test.js @@ -7,8 +7,8 @@ function fixture() { const events = []; const noop = () => {}; const exports = loadRuntimeSource('../../../prompting/core/promptRunner.ts', { - '../../platform/llm/diagnostics/StructuredDiagnosticStore': { recordStructuredBusinessFailure: async () => {} }, - './cache': { registerPromptCacheBoundary: noop }, + '@ai-novel/shared/types/llmLive': { LLM_LIVE_SYSTEM_MESSAGES: { receivingContent: '', organizing: '' } }, + '../../platform/llm/diagnostics/StructuredDiagnosticStore': { recordStructuredBusinessFailure: async () => {}, finishStructuredDiagnostic: async () => {} }, '../../platform/llm/retries': budget, '@langchain/core/messages': { HumanMessage: class { constructor(content) { this.content = content; } } }, '../../llm/factory': { getResolvedLLMClientOptionsFromInstance: () => ({provider:'openai',model:'fixture',maxTokens:6000}), getLLM: async () => { events.push('factory'); return { stream: async () => { @@ -29,13 +29,27 @@ function fixture() { '../../services/novel/novelP0Utils': { toText: value => value || '' }, '../../platform/llm/live/llmLiveSession': { beginLlmLiveSession: () => ({ phase: noop, observe: call => call(), delta: noop, reasoning: noop, usage: noop, complete: noop, fail: noop }) }, '../../llm/reasoning': { ReasoningStreamCollector: class { push() { return ''; } flush() { return ''; } } }, - '../registry': { hasRegisteredPromptAsset: () => true }, - '../slots/slotResolution': { CUSTOM_SLOT_CONTEXT_GROUP: 'custom' }, - '../slots/PromptSlotOverrideService': {}, - '../templates/templateRuntime': { resolveAdvancedPromptMessages: async input => input.officialMessages }, - './contextSelection': { selectContextBlocks: () => ({ selectedBlocks: [], droppedBlocks: [], selectedBlockIds: [], droppedBlockIds: [], summarizedBlockIds: [], estimatedTokens: 1, compressionLogs: [] }) }, + './writingLanguageRepair': { resolveStructuredRepairGuidance: () => '' }, + '../execution/describePrompt': { + prepareEffectivePromptExecution: async input => ({ + messages: input.asset.render(input.promptInput), + context: { blocks: [], selectedBlockIds: [], droppedBlockIds: [], summarizedBlockIds: [], estimatedInputTokens: 1 }, + invocation: { + promptId: input.asset.id, promptVersion: input.asset.version, taskType: input.asset.taskType, + contextBlockIds: [], droppedContextBlockIds: [], summarizedContextBlockIds: [], customAddendumBlockIds: [], + estimatedInputTokens: 1, repairUsed: false, repairAttempts: 0, semanticRetryUsed: false, semanticRetryAttempts: 0, + }, + }), + }, + '../execution/preparePrompt': { + buildPromptInvocationMeta: () => ({ + contextBlockIds: [], droppedContextBlockIds: [], summarizedContextBlockIds: [], customAddendumBlockIds: [], + estimatedInputTokens: 1, repairUsed: false, repairAttempts: 0, semanticRetryUsed: false, semanticRetryAttempts: 0, + }), + preparePromptExecution: noop, + resolvePromptOverlaysForAsset: noop, + }, './promptQualityTelemetry': { recordPromptQualityEvent: noop }, - './structuredOutputHint': { appendStructuredOutputHintMessages: input => input.messages }, }); return { events, ...exports, asset: { id: 'test.text', version: 'v1', mode: 'text', taskType: 'writer', render: () => [{ content: '写作' }] } }; } diff --git a/server/tests/production/batch/nativeEntryProcess.cjs b/server/tests/production/batch/nativeEntryProcess.cjs index 4e4aa4aa23..91821c0a4d 100644 --- a/server/tests/production/batch/nativeEntryProcess.cjs +++ b/server/tests/production/batch/nativeEntryProcess.cjs @@ -44,8 +44,8 @@ function installNativeTransport(respond){ const text=input.map(message=>String(message.content)).join('\n');calls.push({task:configuration.taskType,maxTokens:configuration.maxTokens,text}); let output; if(configuration.taskType==='writer')output='主角在城门交出钥匙,答应返回。'.repeat(160); - else if(text.includes('addressedHookIds')&&text.includes('resolvedHookIds'))output={events:[],hooks:[],addressedHookIds:[],resolvedHookIds:[]}; else if(text.includes('characterLocationDeltas'))output=require('../persistence/outputs.cjs').output(); + else if(text.includes('addressedHookIds')&&text.includes('resolvedHookIds'))output={events:[],hooks:[],addressedHookIds:[],resolvedHookIds:[]}; else if(text.includes('ledgerKey')&&text.includes('items'))output={items:[]}; else if(configuration.taskType==='review')output={...require('../application/assessmentFixture.cjs').assessmentResult(process.env.KERNEL_TEST_CASE==='quality'?{ status:'needs_manual_review',repairability:'rewrite_needed',continuePolicy:'pause',blockingIssues:[{code:'plot-unresolved',category:'plot',severity:'high',evidence:'约定尚待核对',fixSuggestion:'人工核对约定'}]}:{}).assessment, diff --git a/server/tests/production/planning/fixtures/chapterPlanBaseline.json b/server/tests/production/planning/fixtures/chapterPlanBaseline.json index f89aa2184c..6a813eec48 100644 --- a/server/tests/production/planning/fixtures/chapterPlanBaseline.json +++ b/server/tests/production/planning/fixtures/chapterPlanBaseline.json @@ -1,7 +1,7 @@ { "request": { "assetId": "planner.chapter.plan", - "assetVersion": "v3", + "assetVersion": "v4", "promptInput": { "scopeLabel": "章节规划:第1章《城门》" }, @@ -13,7 +13,7 @@ "priority": 95, "required": false, "content": "故事模式:无", - "estimatedTokens": 2, + "estimatedTokens": 5, "allowSummary": true }, { @@ -23,7 +23,7 @@ "priority": 100, "required": true, "content": "小说:城门约定\n简介:阿青守住承诺", - "estimatedTokens": 5, + "estimatedTokens": 13, "allowSummary": true }, { @@ -33,7 +33,7 @@ "priority": 99, "required": false, "content": "题材基底:悬疑\n目标读者:大众\n核心卖点:承诺与秘密\n竞品/对标感受:无\n前30章承诺:无\n叙事视角:third_person\n节奏偏好:moderate\n情绪强度:medium\n语气护栏:克制", - "estimatedTokens": 25, + "estimatedTokens": 55, "allowSummary": true }, { @@ -42,7 +42,7 @@ "priority": 100, "required": true, "content": "章节目标草稿:交出钥匙并约定返回\n章节目标字数:2400 字\n任务单:交出钥匙\n状态驱动决策:recommended_next_action=write_chapter\npending_state_review=0\nopen_audit_issues=0\n默认结构职责建议:planRole=setup | phase=开篇铺垫\nmustAdvance=交出钥匙并约定返回\nmustPreserve=保持主角目标连续;不要跳过关键因果", - "estimatedTokens": 55, + "estimatedTokens": 94, "allowSummary": true }, { @@ -52,7 +52,7 @@ "priority": 92, "required": false, "content": "作品圣经:钥匙只能交出一次", - "estimatedTokens": 4, + "estimatedTokens": 10, "allowSummary": true }, { @@ -61,7 +61,7 @@ "priority": 91, "required": false, "content": "写法引擎约束:无", - "estimatedTokens": 2, + "estimatedTokens": 6, "allowSummary": true }, { @@ -70,7 +70,7 @@ "priority": 97, "required": false, "content": "当前卷窗口:当前尚未建立卷级窗口,请先确认卷工作台。", - "estimatedTokens": 7, + "estimatedTokens": 20, "allowSummary": true }, { @@ -79,7 +79,7 @@ "priority": 96, "required": false, "content": "故事宏观约束:无", - "estimatedTokens": 2, + "estimatedTokens": 6, "allowSummary": true }, { @@ -88,7 +88,7 @@ "priority": 95, "required": false, "content": "伏笔账本:无", - "estimatedTokens": 2, + "estimatedTokens": 5, "allowSummary": true }, { @@ -97,7 +97,7 @@ "priority": 95, "required": false, "content": "卷级工作台摘要:无", - "estimatedTokens": 3, + "estimatedTokens": 7, "freshness": 0, "allowSummary": true }, @@ -107,7 +107,7 @@ "priority": 58, "required": false, "content": "兼容性旧主线大纲(仅作迁移参考):送还钥匙\n兼容性旧结构化大纲(仅作迁移参考):无", - "estimatedTokens": 11, + "estimatedTokens": 31, "allowSummary": true }, { @@ -116,7 +116,7 @@ "priority": 88, "required": false, "content": "全书规划:无", - "estimatedTokens": 2, + "estimatedTokens": 5, "allowSummary": true }, { @@ -125,7 +125,7 @@ "priority": 82, "required": false, "content": "阶段规划:无", - "estimatedTokens": 2, + "estimatedTokens": 5, "allowSummary": true }, { @@ -134,7 +134,7 @@ "priority": 80, "required": false, "content": "角色:hero|阿青|主角|goal=送还钥匙|state=城门前", - "estimatedTokens": 9, + "estimatedTokens": 16, "allowSummary": true }, { @@ -143,7 +143,7 @@ "priority": 72, "required": false, "content": "最近章节摘要:无", - "estimatedTokens": 2, + "estimatedTokens": 6, "allowSummary": true }, { @@ -152,7 +152,7 @@ "priority": 68, "required": false, "content": "剧情拍点:无", - "estimatedTokens": 2, + "estimatedTokens": 5, "allowSummary": true }, { @@ -161,7 +161,7 @@ "priority": 98, "required": true, "content": "状态驱动目标:章节状态目标:无\n应推进冲突:无\n应推进关系:无\n应触碰 payoff:无\n禁止提前泄露:真实身份\n最近关键事件:无", - "estimatedTokens": 17, + "estimatedTokens": 43, "allowSummary": true }, { @@ -170,7 +170,7 @@ "priority": 98, "required": true, "content": "输入状态快照:State snapshot summary: 交出钥匙\n\nKnowledge:\n- reader:钥匙尚未归还\n\nSuspense:\n- 何时返回(tracked)", - "estimatedTokens": 22, + "estimatedTokens": 33, "allowSummary": true }, { @@ -179,7 +179,7 @@ "priority": 86, "required": false, "content": "最近未解决审计问题:无", - "estimatedTokens": 3, + "estimatedTokens": 9, "allowSummary": true }, { @@ -188,7 +188,7 @@ "priority": 64, "required": false, "content": "最近创作决策:无", - "estimatedTokens": 2, + "estimatedTokens": 6, "allowSummary": true }, { @@ -197,7 +197,7 @@ "priority": 89, "required": false, "content": "动态角色系统总览:无", - "estimatedTokens": 3, + "estimatedTokens": 8, "allowSummary": true }, { @@ -206,7 +206,7 @@ "priority": 88, "required": false, "content": "当前卷角色职责与缺席风险:无", - "estimatedTokens": 4, + "estimatedTokens": 11, "allowSummary": true }, { @@ -215,7 +215,7 @@ "priority": 87, "required": false, "content": "当前关系阶段:无", - "estimatedTokens": 2, + "estimatedTokens": 6, "allowSummary": true }, { @@ -224,7 +224,7 @@ "priority": 85, "required": false, "content": "待确认候选角色保护:无", - "estimatedTokens": 3, + "estimatedTokens": 9, "allowSummary": true }, { @@ -233,7 +233,7 @@ "priority": 84, "required": false, "content": "重规划输入:无\n重规划紧张度锚定:无", - "estimatedTokens": 5, + "estimatedTokens": 13, "allowSummary": true } ], diff --git a/server/tests/shortStoryWorkflowContracts.test.js b/server/tests/shortStoryWorkflowContracts.test.js index 47cc136d49..605a72a5fb 100644 --- a/server/tests/shortStoryWorkflowContracts.test.js +++ b/server/tests/shortStoryWorkflowContracts.test.js @@ -86,7 +86,7 @@ test("short story prompt contract targets completed Chinese web fiction instead assert.match(promptSource, /causalContract/); assert.match(promptSource, /不得在危机发生时突然新增万能道具/); assert.match(promptSource, /关键因果\/事实矛盾不得降级为普通建议/); - assert.match(promptSource, /手机阅读组织中文段落/); + assert.match(promptSource, /手机阅读组织段落/); assert.match(promptSource, /不得写成散文、纯文学小品或剧情梗概/); assert.match(promptSource, /productionFoundation/); assert.match(promptSource, /【创作底座】/); diff --git a/server/tests/styleEngine/httpContract.test.js b/server/tests/styleEngine/httpContract.test.js index c07834d08b..e2e92d9eb5 100644 --- a/server/tests/styleEngine/httpContract.test.js +++ b/server/tests/styleEngine/httpContract.test.js @@ -9,6 +9,7 @@ function fixture() { (path, ...handlers) => routes.set(`${method}:${path}`, handlers)])); const imports = { express: { Router: () => router }, zod: require('zod'), + '@ai-novel/shared/types/novel': require('@ai-novel/shared/types/novel'), '../llm/providerSchema': { llmProviderSchema: require('zod').z.enum(['deepseek']) }, '../middleware/auth': { authMiddleware: () => {} }, '../middleware/validate': { validate: ({ body }) => (req) => { req.body = body.parse(req.body); } }, diff --git a/server/tests/volumePageContractSync.test.js b/server/tests/volumePageContractSync.test.js index 4a7e9ed6c0..0bcf03ba26 100644 --- a/server/tests/volumePageContractSync.test.js +++ b/server/tests/volumePageContractSync.test.js @@ -4,7 +4,6 @@ const {createHash} = require('node:crypto'); const {mkdtempSync} = require('node:fs'); const {tmpdir} = require('node:os'); const {join} = require('node:path'); -const {tmpdir} = require('node:os'); const Sqlite = require('better-sqlite3'); const {PrismaClient} = require('@prisma/client'); const {PrismaBetterSqlite3} = require('@prisma/adapter-better-sqlite3');