@zwbigi/ink-xy 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +2 -2
- package/.next/build-manifest.json +2 -2
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/api/inkos/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/install/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/search/route.js.nft.json +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +1 -1
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/server/app-paths-manifest.json +2 -2
- package/.next/server/chunks/162.js +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/trace +4 -4
- package/.next/trace-build +1 -1
- package/bin/pi-web.js +4 -1
- package/inkos/.env.example +20 -0
- package/inkos/.node-version +1 -0
- package/inkos/.nvmrc +1 -0
- package/inkos/CHANGELOG.md +787 -0
- package/inkos/CONTRIBUTING.md +89 -0
- package/inkos/LICENSE +661 -0
- package/inkos/README.en.md +483 -0
- package/inkos/README.ja.md +461 -0
- package/inkos/README.md +272 -0
- package/inkos/assets/15qun.jpg +0 -0
- package/inkos/assets/41777702961_.pic.jpg +0 -0
- package/inkos/assets/inkos-short-demo-cover.png +0 -0
- package/inkos/assets/inkos-text.svg +40 -0
- package/inkos/assets/logo.svg +47 -0
- package/inkos/assets/screenshot-chapters.png +0 -0
- package/inkos/assets/screenshot-pipeline.png +0 -0
- package/inkos/assets/screenshot-state.png +0 -0
- package/inkos/assets/screenshot-terminal.png +0 -0
- package/inkos/assets/wechat-group-v8.jpg +0 -0
- package/inkos/package.json +42 -0
- package/inkos/packages/cli/package.json +74 -0
- package/inkos/packages/cli/src/__tests__/analytics.test.ts +154 -0
- package/inkos/packages/cli/src/__tests__/cli-integration.test.ts +1031 -0
- package/inkos/packages/cli/src/__tests__/daemon.test.ts +93 -0
- package/inkos/packages/cli/src/__tests__/doctor.test.ts +36 -0
- package/inkos/packages/cli/src/__tests__/interact-command.test.ts +142 -0
- package/inkos/packages/cli/src/__tests__/interaction-tools.test.ts +107 -0
- package/inkos/packages/cli/src/__tests__/llm-overrides.test.ts +25 -0
- package/inkos/packages/cli/src/__tests__/localization.test.ts +121 -0
- package/inkos/packages/cli/src/__tests__/progress-text.test.ts +92 -0
- package/inkos/packages/cli/src/__tests__/project-bootstrap.test.ts +71 -0
- package/inkos/packages/cli/src/__tests__/publish-package.test.ts +272 -0
- package/inkos/packages/cli/src/__tests__/revision-command.test.ts +82 -0
- package/inkos/packages/cli/src/__tests__/runtime-requirements.test.ts +89 -0
- package/inkos/packages/cli/src/__tests__/short-fiction-command.test.ts +48 -0
- package/inkos/packages/cli/src/__tests__/studio-runtime.test.ts +142 -0
- package/inkos/packages/cli/src/__tests__/studio.test.ts +87 -0
- package/inkos/packages/cli/src/__tests__/tui-activity-state.test.ts +20 -0
- package/inkos/packages/cli/src/__tests__/tui-agent-session.test.ts +213 -0
- package/inkos/packages/cli/src/__tests__/tui-chat-depth.test.ts +27 -0
- package/inkos/packages/cli/src/__tests__/tui-chat-draft.test.ts +44 -0
- package/inkos/packages/cli/src/__tests__/tui-command.test.ts +86 -0
- package/inkos/packages/cli/src/__tests__/tui-composer-caret.test.ts +46 -0
- package/inkos/packages/cli/src/__tests__/tui-composer-display.test.ts +40 -0
- package/inkos/packages/cli/src/__tests__/tui-dashboard.test.tsx +219 -0
- package/inkos/packages/cli/src/__tests__/tui-effects-i18n.test.ts +29 -0
- package/inkos/packages/cli/src/__tests__/tui-i18n.test.ts +22 -0
- package/inkos/packages/cli/src/__tests__/tui-input-chrome.test.ts +10 -0
- package/inkos/packages/cli/src/__tests__/tui-input-history.test.ts +40 -0
- package/inkos/packages/cli/src/__tests__/tui-layout.test.ts +55 -0
- package/inkos/packages/cli/src/__tests__/tui-local-commands.test.ts +47 -0
- package/inkos/packages/cli/src/__tests__/tui-session-store.test.ts +81 -0
- package/inkos/packages/cli/src/__tests__/tui-setup-i18n.test.ts +31 -0
- package/inkos/packages/cli/src/__tests__/tui-slash-autocomplete.test.ts +33 -0
- package/inkos/packages/cli/src/commands/agent.ts +65 -0
- package/inkos/packages/cli/src/commands/analytics.ts +77 -0
- package/inkos/packages/cli/src/commands/audit.ts +52 -0
- package/inkos/packages/cli/src/commands/book.ts +260 -0
- package/inkos/packages/cli/src/commands/compose.ts +50 -0
- package/inkos/packages/cli/src/commands/config.ts +328 -0
- package/inkos/packages/cli/src/commands/consolidate.ts +50 -0
- package/inkos/packages/cli/src/commands/daemon.ts +121 -0
- package/inkos/packages/cli/src/commands/detect.ts +125 -0
- package/inkos/packages/cli/src/commands/doctor.ts +391 -0
- package/inkos/packages/cli/src/commands/draft.ts +43 -0
- package/inkos/packages/cli/src/commands/eval.ts +217 -0
- package/inkos/packages/cli/src/commands/export.ts +45 -0
- package/inkos/packages/cli/src/commands/fanfic.ts +183 -0
- package/inkos/packages/cli/src/commands/genre.ts +160 -0
- package/inkos/packages/cli/src/commands/import.ts +158 -0
- package/inkos/packages/cli/src/commands/init.ts +47 -0
- package/inkos/packages/cli/src/commands/interact.ts +109 -0
- package/inkos/packages/cli/src/commands/plan.ts +54 -0
- package/inkos/packages/cli/src/commands/radar.ts +60 -0
- package/inkos/packages/cli/src/commands/review.ts +253 -0
- package/inkos/packages/cli/src/commands/revise.ts +58 -0
- package/inkos/packages/cli/src/commands/short-fiction.ts +294 -0
- package/inkos/packages/cli/src/commands/status.ts +138 -0
- package/inkos/packages/cli/src/commands/studio.ts +194 -0
- package/inkos/packages/cli/src/commands/style.ts +99 -0
- package/inkos/packages/cli/src/commands/tui.ts +18 -0
- package/inkos/packages/cli/src/commands/update.ts +45 -0
- package/inkos/packages/cli/src/commands/write.ts +324 -0
- package/inkos/packages/cli/src/index.ts +5 -0
- package/inkos/packages/cli/src/interaction/tools.ts +49 -0
- package/inkos/packages/cli/src/localization.ts +215 -0
- package/inkos/packages/cli/src/program.ts +106 -0
- package/inkos/packages/cli/src/progress-text.ts +85 -0
- package/inkos/packages/cli/src/project-bootstrap.ts +175 -0
- package/inkos/packages/cli/src/runtime-requirements.ts +135 -0
- package/inkos/packages/cli/src/tui/__tests__/markdown.test.ts +64 -0
- package/inkos/packages/cli/src/tui/activity-state.ts +41 -0
- package/inkos/packages/cli/src/tui/agent-input.ts +264 -0
- package/inkos/packages/cli/src/tui/ansi.ts +72 -0
- package/inkos/packages/cli/src/tui/app.ts +130 -0
- package/inkos/packages/cli/src/tui/chat-depth.ts +22 -0
- package/inkos/packages/cli/src/tui/chat-draft.ts +42 -0
- package/inkos/packages/cli/src/tui/composer-caret.ts +22 -0
- package/inkos/packages/cli/src/tui/composer-display.ts +26 -0
- package/inkos/packages/cli/src/tui/dashboard-model.ts +164 -0
- package/inkos/packages/cli/src/tui/dashboard.tsx +544 -0
- package/inkos/packages/cli/src/tui/effects.ts +542 -0
- package/inkos/packages/cli/src/tui/i18n.ts +278 -0
- package/inkos/packages/cli/src/tui/input-history.ts +69 -0
- package/inkos/packages/cli/src/tui/local-commands.ts +55 -0
- package/inkos/packages/cli/src/tui/markdown.ts +64 -0
- package/inkos/packages/cli/src/tui/session-store.ts +6 -0
- package/inkos/packages/cli/src/tui/setup.ts +397 -0
- package/inkos/packages/cli/src/tui/slash-autocomplete.ts +62 -0
- package/inkos/packages/cli/src/tui/theme.ts +17 -0
- package/inkos/packages/cli/src/utils.ts +222 -0
- package/inkos/packages/cli/tsconfig.json +9 -0
- package/inkos/packages/core/genres/cozy.md +43 -0
- package/inkos/packages/core/genres/cultivation.md +42 -0
- package/inkos/packages/core/genres/dungeon-core.md +40 -0
- package/inkos/packages/core/genres/horror.md +51 -0
- package/inkos/packages/core/genres/isekai.md +43 -0
- package/inkos/packages/core/genres/litrpg.md +43 -0
- package/inkos/packages/core/genres/other.md +24 -0
- package/inkos/packages/core/genres/progression.md +41 -0
- package/inkos/packages/core/genres/romantasy.md +45 -0
- package/inkos/packages/core/genres/sci-fi.md +42 -0
- package/inkos/packages/core/genres/system-apocalypse.md +40 -0
- package/inkos/packages/core/genres/tower-climber.md +41 -0
- package/inkos/packages/core/genres/urban.md +53 -0
- package/inkos/packages/core/genres/xianxia.md +46 -0
- package/inkos/packages/core/genres/xuanhuan.md +64 -0
- package/inkos/packages/core/package.json +61 -0
- package/inkos/packages/core/src/__tests__/agent-max-tokens-policy.test.ts +29 -0
- package/inkos/packages/core/src/__tests__/agent-session.test.ts +866 -0
- package/inkos/packages/core/src/__tests__/agent-system-prompt.test.ts +167 -0
- package/inkos/packages/core/src/__tests__/agent-tools-params.test.ts +197 -0
- package/inkos/packages/core/src/__tests__/agent-tools.test.ts +421 -0
- package/inkos/packages/core/src/__tests__/ai-tells.test.ts +90 -0
- package/inkos/packages/core/src/__tests__/architect-phase5-consolidated.test.ts +445 -0
- package/inkos/packages/core/src/__tests__/architect-phase5.test.ts +455 -0
- package/inkos/packages/core/src/__tests__/architect-phase7.test.ts +210 -0
- package/inkos/packages/core/src/__tests__/architect.test.ts +859 -0
- package/inkos/packages/core/src/__tests__/audit-parse.test.ts +78 -0
- package/inkos/packages/core/src/__tests__/book-id.test.ts +26 -0
- package/inkos/packages/core/src/__tests__/book-session-store.test.ts +447 -0
- package/inkos/packages/core/src/__tests__/book-session.test.ts +113 -0
- package/inkos/packages/core/src/__tests__/chapter-analyzer.test.ts +574 -0
- package/inkos/packages/core/src/__tests__/chapter-memo-parser.test.ts +247 -0
- package/inkos/packages/core/src/__tests__/chapter-persistence.test.ts +198 -0
- package/inkos/packages/core/src/__tests__/chapter-review-cycle.test.ts +294 -0
- package/inkos/packages/core/src/__tests__/chapter-splitter.test.ts +156 -0
- package/inkos/packages/core/src/__tests__/chapter-state-recovery.test.ts +235 -0
- package/inkos/packages/core/src/__tests__/chapter-truth-validation.test.ts +253 -0
- package/inkos/packages/core/src/__tests__/composer.test.ts +627 -0
- package/inkos/packages/core/src/__tests__/config-loader.test.ts +325 -0
- package/inkos/packages/core/src/__tests__/config-migration.test.ts +102 -0
- package/inkos/packages/core/src/__tests__/consolidator.test.ts +32 -0
- package/inkos/packages/core/src/__tests__/context-filter.test.ts +60 -0
- package/inkos/packages/core/src/__tests__/context-transform.test.ts +108 -0
- package/inkos/packages/core/src/__tests__/continuity.test.ts +391 -0
- package/inkos/packages/core/src/__tests__/detection-insights.test.ts +59 -0
- package/inkos/packages/core/src/__tests__/detector.test.ts +86 -0
- package/inkos/packages/core/src/__tests__/draft-directive-parser.test.ts +386 -0
- package/inkos/packages/core/src/__tests__/edit-controller.test.ts +190 -0
- package/inkos/packages/core/src/__tests__/effective-llm-config.test.ts +486 -0
- package/inkos/packages/core/src/__tests__/fanfic-dimensions.test.ts +58 -0
- package/inkos/packages/core/src/__tests__/fanfic-models.test.ts +69 -0
- package/inkos/packages/core/src/__tests__/governed-working-set.test.ts +155 -0
- package/inkos/packages/core/src/__tests__/hook-arbiter.test.ts +124 -0
- package/inkos/packages/core/src/__tests__/hook-governance.test.ts +228 -0
- package/inkos/packages/core/src/__tests__/hook-health.test.ts +166 -0
- package/inkos/packages/core/src/__tests__/hook-ledger-validator.test.ts +236 -0
- package/inkos/packages/core/src/__tests__/hook-promotion.test.ts +192 -0
- package/inkos/packages/core/src/__tests__/hook-stale-detection.test.ts +136 -0
- package/inkos/packages/core/src/__tests__/index-notify-lazy.test.ts +20 -0
- package/inkos/packages/core/src/__tests__/interaction-chat-tokens.test.ts +170 -0
- package/inkos/packages/core/src/__tests__/interaction-models.test.ts +155 -0
- package/inkos/packages/core/src/__tests__/interaction-nl-router.test.ts +223 -0
- package/inkos/packages/core/src/__tests__/interaction-runtime.test.ts +633 -0
- package/inkos/packages/core/src/__tests__/interaction-tools.test.ts +343 -0
- package/inkos/packages/core/src/__tests__/length-metrics.test.ts +82 -0
- package/inkos/packages/core/src/__tests__/length-normalizer.test.ts +331 -0
- package/inkos/packages/core/src/__tests__/list-models.test.ts +109 -0
- package/inkos/packages/core/src/__tests__/llm-env.test.ts +31 -0
- package/inkos/packages/core/src/__tests__/logger.test.ts +175 -0
- package/inkos/packages/core/src/__tests__/long-span-fatigue.test.ts +160 -0
- package/inkos/packages/core/src/__tests__/memory-retrieval.test.ts +1303 -0
- package/inkos/packages/core/src/__tests__/models.test.ts +918 -0
- package/inkos/packages/core/src/__tests__/outline-paths.test.ts +97 -0
- package/inkos/packages/core/src/__tests__/path-safety.test.ts +22 -0
- package/inkos/packages/core/src/__tests__/persisted-governed-plan.test.ts +134 -0
- package/inkos/packages/core/src/__tests__/phase5-cleanup.test.ts +393 -0
- package/inkos/packages/core/src/__tests__/phase5-hotfix.test.ts +288 -0
- package/inkos/packages/core/src/__tests__/phase7-hotfix.test.ts +614 -0
- package/inkos/packages/core/src/__tests__/pipeline-agent.test.ts +354 -0
- package/inkos/packages/core/src/__tests__/pipeline-runner-memory-sync.test.ts +317 -0
- package/inkos/packages/core/src/__tests__/pipeline-runner.test.ts +5200 -0
- package/inkos/packages/core/src/__tests__/planner-context.test.ts +137 -0
- package/inkos/packages/core/src/__tests__/planner-prompts-ratio.test.ts +11 -0
- package/inkos/packages/core/src/__tests__/planner-prompts.test.ts +171 -0
- package/inkos/packages/core/src/__tests__/planner.test.ts +362 -0
- package/inkos/packages/core/src/__tests__/planning-materials.test.ts +90 -0
- package/inkos/packages/core/src/__tests__/polisher.test.ts +189 -0
- package/inkos/packages/core/src/__tests__/post-write-validator.test.ts +291 -0
- package/inkos/packages/core/src/__tests__/probe.test.ts +77 -0
- package/inkos/packages/core/src/__tests__/project-interaction.test.ts +241 -0
- package/inkos/packages/core/src/__tests__/provider.test.ts +953 -0
- package/inkos/packages/core/src/__tests__/providers-group.test.ts +34 -0
- package/inkos/packages/core/src/__tests__/providers-lookup.test.ts +81 -0
- package/inkos/packages/core/src/__tests__/providers-schema.test.ts +158 -0
- package/inkos/packages/core/src/__tests__/proxy-fetch.test.ts +75 -0
- package/inkos/packages/core/src/__tests__/revise-foundation.test.ts +514 -0
- package/inkos/packages/core/src/__tests__/reviser.test.ts +859 -0
- package/inkos/packages/core/src/__tests__/runtime-state-store.test.ts +388 -0
- package/inkos/packages/core/src/__tests__/scheduler.test.ts +123 -0
- package/inkos/packages/core/src/__tests__/secrets-migration.test.ts +71 -0
- package/inkos/packages/core/src/__tests__/secrets.test.ts +95 -0
- package/inkos/packages/core/src/__tests__/sensitive-words.test.ts +88 -0
- package/inkos/packages/core/src/__tests__/service-presets-regression.test.ts +73 -0
- package/inkos/packages/core/src/__tests__/service-resolver-regression.test.ts +75 -0
- package/inkos/packages/core/src/__tests__/service-resolver.test.ts +228 -0
- package/inkos/packages/core/src/__tests__/session-transcript-restore.test.ts +1311 -0
- package/inkos/packages/core/src/__tests__/session-transcript.test.ts +195 -0
- package/inkos/packages/core/src/__tests__/settler-delta-parser.test.ts +133 -0
- package/inkos/packages/core/src/__tests__/short-fiction-public.test.ts +241 -0
- package/inkos/packages/core/src/__tests__/spot-fix-patches.test.ts +104 -0
- package/inkos/packages/core/src/__tests__/state-manager.test.ts +1298 -0
- package/inkos/packages/core/src/__tests__/state-projections.test.ts +130 -0
- package/inkos/packages/core/src/__tests__/state-reducer.test.ts +372 -0
- package/inkos/packages/core/src/__tests__/state-validator-agent.test.ts +165 -0
- package/inkos/packages/core/src/__tests__/state-validator.test.ts +122 -0
- package/inkos/packages/core/src/__tests__/style-analyzer.test.ts +61 -0
- package/inkos/packages/core/src/__tests__/temperature-constraints.test.ts +57 -0
- package/inkos/packages/core/src/__tests__/v13-hotfix-round4.test.ts +343 -0
- package/inkos/packages/core/src/__tests__/verify-service.test.ts +77 -0
- package/inkos/packages/core/src/__tests__/webhook.test.ts +91 -0
- package/inkos/packages/core/src/__tests__/writer-parser.test.ts +348 -0
- package/inkos/packages/core/src/__tests__/writer-prompts.test.ts +269 -0
- package/inkos/packages/core/src/__tests__/writer.test.ts +1360 -0
- package/inkos/packages/core/src/agent/agent-session.ts +737 -0
- package/inkos/packages/core/src/agent/agent-system-prompt.ts +199 -0
- package/inkos/packages/core/src/agent/agent-tools.ts +835 -0
- package/inkos/packages/core/src/agent/context-transform.ts +85 -0
- package/inkos/packages/core/src/agent/index.ts +14 -0
- package/inkos/packages/core/src/agents/ai-tells.ts +161 -0
- package/inkos/packages/core/src/agents/architect.ts +1291 -0
- package/inkos/packages/core/src/agents/base.ts +100 -0
- package/inkos/packages/core/src/agents/chapter-analyzer.ts +634 -0
- package/inkos/packages/core/src/agents/composer.ts +469 -0
- package/inkos/packages/core/src/agents/consolidator.ts +218 -0
- package/inkos/packages/core/src/agents/continuity.ts +824 -0
- package/inkos/packages/core/src/agents/detection-insights.ts +72 -0
- package/inkos/packages/core/src/agents/detector.ts +224 -0
- package/inkos/packages/core/src/agents/en-prompt-sections.ts +129 -0
- package/inkos/packages/core/src/agents/fanfic-canon-importer.ts +146 -0
- package/inkos/packages/core/src/agents/fanfic-dimensions.ts +87 -0
- package/inkos/packages/core/src/agents/fanfic-prompt-sections.ts +109 -0
- package/inkos/packages/core/src/agents/foundation-reviewer.ts +204 -0
- package/inkos/packages/core/src/agents/length-normalizer.ts +218 -0
- package/inkos/packages/core/src/agents/observer-prompts.ts +127 -0
- package/inkos/packages/core/src/agents/planner-context.ts +297 -0
- package/inkos/packages/core/src/agents/planner-prompts.ts +404 -0
- package/inkos/packages/core/src/agents/planner.ts +783 -0
- package/inkos/packages/core/src/agents/polisher.ts +153 -0
- package/inkos/packages/core/src/agents/post-write-validator.ts +873 -0
- package/inkos/packages/core/src/agents/radar-source.ts +123 -0
- package/inkos/packages/core/src/agents/radar.ts +120 -0
- package/inkos/packages/core/src/agents/reviser.ts +701 -0
- package/inkos/packages/core/src/agents/rules-reader.ts +155 -0
- package/inkos/packages/core/src/agents/sensitive-words.ts +142 -0
- package/inkos/packages/core/src/agents/settler-delta-parser.ts +53 -0
- package/inkos/packages/core/src/agents/settler-parser.ts +38 -0
- package/inkos/packages/core/src/agents/settler-prompts.ts +230 -0
- package/inkos/packages/core/src/agents/short-fiction.ts +429 -0
- package/inkos/packages/core/src/agents/state-validator.ts +322 -0
- package/inkos/packages/core/src/agents/style-analyzer.ts +93 -0
- package/inkos/packages/core/src/agents/writer-parser.ts +178 -0
- package/inkos/packages/core/src/agents/writer-prompts.ts +899 -0
- package/inkos/packages/core/src/agents/writer.ts +1450 -0
- package/inkos/packages/core/src/index.ts +392 -0
- package/inkos/packages/core/src/interaction/book-session-store.ts +226 -0
- package/inkos/packages/core/src/interaction/draft-directive-parser.ts +266 -0
- package/inkos/packages/core/src/interaction/edit-controller.ts +270 -0
- package/inkos/packages/core/src/interaction/events.ts +41 -0
- package/inkos/packages/core/src/interaction/export-artifact.ts +151 -0
- package/inkos/packages/core/src/interaction/intents.ts +63 -0
- package/inkos/packages/core/src/interaction/modes.ts +13 -0
- package/inkos/packages/core/src/interaction/nl-router.ts +258 -0
- package/inkos/packages/core/src/interaction/project-control.ts +150 -0
- package/inkos/packages/core/src/interaction/project-session-store.ts +81 -0
- package/inkos/packages/core/src/interaction/project-tools.ts +704 -0
- package/inkos/packages/core/src/interaction/request-router.ts +5 -0
- package/inkos/packages/core/src/interaction/runtime.ts +1167 -0
- package/inkos/packages/core/src/interaction/session-transcript-legacy.ts +113 -0
- package/inkos/packages/core/src/interaction/session-transcript-restore.ts +607 -0
- package/inkos/packages/core/src/interaction/session-transcript-schema.ts +76 -0
- package/inkos/packages/core/src/interaction/session-transcript.ts +189 -0
- package/inkos/packages/core/src/interaction/session.ts +226 -0
- package/inkos/packages/core/src/interaction/truth-authority.ts +45 -0
- package/inkos/packages/core/src/llm/config-migration.ts +58 -0
- package/inkos/packages/core/src/llm/cover-providers.ts +45 -0
- package/inkos/packages/core/src/llm/provider.ts +1331 -0
- package/inkos/packages/core/src/llm/providers/endpoints/ai360.ts +42 -0
- package/inkos/packages/core/src/llm/providers/endpoints/anthropic.ts +82 -0
- package/inkos/packages/core/src/llm/providers/endpoints/astronCodingPlan.ts +30 -0
- package/inkos/packages/core/src/llm/providers/endpoints/baichuan.ts +28 -0
- package/inkos/packages/core/src/llm/providers/endpoints/bailian.ts +65 -0
- package/inkos/packages/core/src/llm/providers/endpoints/bailianCodingPlan.ts +30 -0
- package/inkos/packages/core/src/llm/providers/endpoints/custom.ts +22 -0
- package/inkos/packages/core/src/llm/providers/endpoints/deepseek.ts +35 -0
- package/inkos/packages/core/src/llm/providers/endpoints/giteeai.ts +41 -0
- package/inkos/packages/core/src/llm/providers/endpoints/githubCopilot.ts +43 -0
- package/inkos/packages/core/src/llm/providers/endpoints/glmCodingPlan.ts +28 -0
- package/inkos/packages/core/src/llm/providers/endpoints/google.ts +51 -0
- package/inkos/packages/core/src/llm/providers/endpoints/hunyuan.ts +42 -0
- package/inkos/packages/core/src/llm/providers/endpoints/infiniai.ts +72 -0
- package/inkos/packages/core/src/llm/providers/endpoints/internlm.ts +28 -0
- package/inkos/packages/core/src/llm/providers/endpoints/kimiCode.ts +23 -0
- package/inkos/packages/core/src/llm/providers/endpoints/kimiCodingPlan.ts +24 -0
- package/inkos/packages/core/src/llm/providers/endpoints/kkaiapi.ts +56 -0
- package/inkos/packages/core/src/llm/providers/endpoints/longcat.ts +25 -0
- package/inkos/packages/core/src/llm/providers/endpoints/minimax.ts +39 -0
- package/inkos/packages/core/src/llm/providers/endpoints/minimaxCodingPlan.ts +28 -0
- package/inkos/packages/core/src/llm/providers/endpoints/mistral.ts +40 -0
- package/inkos/packages/core/src/llm/providers/endpoints/modelscope.ts +30 -0
- package/inkos/packages/core/src/llm/providers/endpoints/moonshot.ts +39 -0
- package/inkos/packages/core/src/llm/providers/endpoints/newapi.ts +21 -0
- package/inkos/packages/core/src/llm/providers/endpoints/ollama.ts +73 -0
- package/inkos/packages/core/src/llm/providers/endpoints/openai.ts +77 -0
- package/inkos/packages/core/src/llm/providers/endpoints/opencodeCodingPlan.ts +30 -0
- package/inkos/packages/core/src/llm/providers/endpoints/openrouter.ts +87 -0
- package/inkos/packages/core/src/llm/providers/endpoints/ppio.ts +86 -0
- package/inkos/packages/core/src/llm/providers/endpoints/qiniu.ts +32 -0
- package/inkos/packages/core/src/llm/providers/endpoints/sensenova.ts +45 -0
- package/inkos/packages/core/src/llm/providers/endpoints/siliconcloud.ts +126 -0
- package/inkos/packages/core/src/llm/providers/endpoints/spark.ts +33 -0
- package/inkos/packages/core/src/llm/providers/endpoints/stepfun.ts +35 -0
- package/inkos/packages/core/src/llm/providers/endpoints/tencentcloud.ts +25 -0
- package/inkos/packages/core/src/llm/providers/endpoints/volcengine.ts +52 -0
- package/inkos/packages/core/src/llm/providers/endpoints/volcengineCodingPlan.ts +42 -0
- package/inkos/packages/core/src/llm/providers/endpoints/wenxin.ts +106 -0
- package/inkos/packages/core/src/llm/providers/endpoints/xai.ts +34 -0
- package/inkos/packages/core/src/llm/providers/endpoints/xiaomimimo.ts +26 -0
- package/inkos/packages/core/src/llm/providers/endpoints/zeroone.ts +34 -0
- package/inkos/packages/core/src/llm/providers/endpoints/zhipu.ts +61 -0
- package/inkos/packages/core/src/llm/providers/index.ts +71 -0
- package/inkos/packages/core/src/llm/providers/lookup.ts +70 -0
- package/inkos/packages/core/src/llm/providers/probe.ts +35 -0
- package/inkos/packages/core/src/llm/providers/types.ts +89 -0
- package/inkos/packages/core/src/llm/providers/verify.ts +104 -0
- package/inkos/packages/core/src/llm/secrets.ts +77 -0
- package/inkos/packages/core/src/llm/service-presets.ts +215 -0
- package/inkos/packages/core/src/llm/service-resolver.ts +91 -0
- package/inkos/packages/core/src/models/book-rules.ts +126 -0
- package/inkos/packages/core/src/models/book.ts +70 -0
- package/inkos/packages/core/src/models/chapter.ts +42 -0
- package/inkos/packages/core/src/models/detection.ts +25 -0
- package/inkos/packages/core/src/models/genre-profile.ts +36 -0
- package/inkos/packages/core/src/models/input-governance.ts +99 -0
- package/inkos/packages/core/src/models/length-governance.ts +46 -0
- package/inkos/packages/core/src/models/project.ts +161 -0
- package/inkos/packages/core/src/models/runtime-state.ts +144 -0
- package/inkos/packages/core/src/models/state.ts +52 -0
- package/inkos/packages/core/src/models/style-profile.ts +15 -0
- package/inkos/packages/core/src/notify/dispatcher.ts +96 -0
- package/inkos/packages/core/src/notify/feishu.ts +34 -0
- package/inkos/packages/core/src/notify/telegram.ts +25 -0
- package/inkos/packages/core/src/notify/webhook.ts +58 -0
- package/inkos/packages/core/src/notify/wechat-work.ts +22 -0
- package/inkos/packages/core/src/pipeline/agent.ts +691 -0
- package/inkos/packages/core/src/pipeline/chapter-persistence.ts +79 -0
- package/inkos/packages/core/src/pipeline/chapter-review-cycle.ts +324 -0
- package/inkos/packages/core/src/pipeline/chapter-state-recovery.ts +236 -0
- package/inkos/packages/core/src/pipeline/chapter-truth-validation.ts +145 -0
- package/inkos/packages/core/src/pipeline/detection-runner.ts +164 -0
- package/inkos/packages/core/src/pipeline/persisted-governed-plan.ts +216 -0
- package/inkos/packages/core/src/pipeline/runner.ts +3438 -0
- package/inkos/packages/core/src/pipeline/scheduler.ts +411 -0
- package/inkos/packages/core/src/pipeline/short-fiction-runner.ts +801 -0
- package/inkos/packages/core/src/prompts/index.ts +1 -0
- package/inkos/packages/core/src/prompts/short-fiction.ts +273 -0
- package/inkos/packages/core/src/state/manager.ts +560 -0
- package/inkos/packages/core/src/state/memory-db.ts +359 -0
- package/inkos/packages/core/src/state/runtime-state-store.ts +164 -0
- package/inkos/packages/core/src/state/state-bootstrap.ts +657 -0
- package/inkos/packages/core/src/state/state-projections.ts +255 -0
- package/inkos/packages/core/src/state/state-reducer.ts +260 -0
- package/inkos/packages/core/src/state/state-validator.ts +117 -0
- package/inkos/packages/core/src/utils/analytics.ts +92 -0
- package/inkos/packages/core/src/utils/book-id.ts +31 -0
- package/inkos/packages/core/src/utils/cadence-policy.ts +46 -0
- package/inkos/packages/core/src/utils/chapter-cadence.ts +211 -0
- package/inkos/packages/core/src/utils/chapter-memo-parser.ts +157 -0
- package/inkos/packages/core/src/utils/chapter-splitter.ts +80 -0
- package/inkos/packages/core/src/utils/config-loader.ts +29 -0
- package/inkos/packages/core/src/utils/context-assembly.ts +98 -0
- package/inkos/packages/core/src/utils/context-filter.ts +190 -0
- package/inkos/packages/core/src/utils/effective-llm-config.ts +529 -0
- package/inkos/packages/core/src/utils/governed-context.ts +101 -0
- package/inkos/packages/core/src/utils/governed-working-set.ts +395 -0
- package/inkos/packages/core/src/utils/hook-arbiter.ts +332 -0
- package/inkos/packages/core/src/utils/hook-governance.ts +199 -0
- package/inkos/packages/core/src/utils/hook-health.ts +189 -0
- package/inkos/packages/core/src/utils/hook-ledger-validator.ts +277 -0
- package/inkos/packages/core/src/utils/hook-lifecycle.ts +224 -0
- package/inkos/packages/core/src/utils/hook-policy.ts +115 -0
- package/inkos/packages/core/src/utils/hook-promotion.ts +313 -0
- package/inkos/packages/core/src/utils/hook-stale-detection.ts +168 -0
- package/inkos/packages/core/src/utils/length-metrics.ts +123 -0
- package/inkos/packages/core/src/utils/llm-endpoint-auth.ts +40 -0
- package/inkos/packages/core/src/utils/llm-env.ts +74 -0
- package/inkos/packages/core/src/utils/logger.ts +123 -0
- package/inkos/packages/core/src/utils/long-span-fatigue.ts +545 -0
- package/inkos/packages/core/src/utils/memory-retrieval.ts +527 -0
- package/inkos/packages/core/src/utils/narrative-control.ts +177 -0
- package/inkos/packages/core/src/utils/outline-paths.ts +275 -0
- package/inkos/packages/core/src/utils/path-safety.ts +11 -0
- package/inkos/packages/core/src/utils/planning-materials.ts +185 -0
- package/inkos/packages/core/src/utils/pov-filter.ts +149 -0
- package/inkos/packages/core/src/utils/proxy-fetch.ts +44 -0
- package/inkos/packages/core/src/utils/runtime-writer.ts +41 -0
- package/inkos/packages/core/src/utils/spot-fix-patches.ts +189 -0
- package/inkos/packages/core/src/utils/story-markdown.ts +346 -0
- package/inkos/packages/core/src/utils/web-search.ts +82 -0
- package/inkos/packages/core/src/utils/writing-methodology.ts +164 -0
- package/inkos/packages/core/tsconfig.json +8 -0
- package/inkos/packages/core/vitest.config.ts +7 -0
- package/inkos/packages/studio/components.json +25 -0
- package/inkos/packages/studio/index.html +13 -0
- package/inkos/packages/studio/package.json +72 -0
- package/inkos/packages/studio/postcss.config.js +3 -0
- package/inkos/packages/studio/src/App.test.ts +25 -0
- package/inkos/packages/studio/src/App.tsx +280 -0
- package/inkos/packages/studio/src/api/__tests__/normalize-base-url.test.ts +40 -0
- package/inkos/packages/studio/src/api/book-create.test.ts +104 -0
- package/inkos/packages/studio/src/api/book-create.ts +94 -0
- package/inkos/packages/studio/src/api/errors.ts +17 -0
- package/inkos/packages/studio/src/api/index.ts +30 -0
- package/inkos/packages/studio/src/api/lib/run-store.ts +177 -0
- package/inkos/packages/studio/src/api/lib/sse.ts +50 -0
- package/inkos/packages/studio/src/api/phase5-hotfix.test.ts +335 -0
- package/inkos/packages/studio/src/api/safety.ts +6 -0
- package/inkos/packages/studio/src/api/server.test.ts +3162 -0
- package/inkos/packages/studio/src/api/server.ts +3666 -0
- package/inkos/packages/studio/src/api/v13-hotfix-round4.test.ts +226 -0
- package/inkos/packages/studio/src/app-state.test.ts +8 -0
- package/inkos/packages/studio/src/app-state.ts +1 -0
- package/inkos/packages/studio/src/components/ConfirmDialog.tsx +95 -0
- package/inkos/packages/studio/src/components/ServiceConfigSourceCard.tsx +139 -0
- package/inkos/packages/studio/src/components/ServiceQuickLinks.tsx +65 -0
- package/inkos/packages/studio/src/components/Sidebar.tsx +652 -0
- package/inkos/packages/studio/src/components/ai-elements/code-block.tsx +562 -0
- package/inkos/packages/studio/src/components/ai-elements/confirmation.tsx +174 -0
- package/inkos/packages/studio/src/components/ai-elements/message.tsx +360 -0
- package/inkos/packages/studio/src/components/ai-elements/prompt-input.tsx +1457 -0
- package/inkos/packages/studio/src/components/ai-elements/reasoning.tsx +226 -0
- package/inkos/packages/studio/src/components/ai-elements/shimmer.tsx +77 -0
- package/inkos/packages/studio/src/components/ai-elements/tool.tsx +173 -0
- package/inkos/packages/studio/src/components/chat/BookSidebar.tsx +291 -0
- package/inkos/packages/studio/src/components/chat/ChatMessage.tsx +39 -0
- package/inkos/packages/studio/src/components/chat/QuickActions.tsx +73 -0
- package/inkos/packages/studio/src/components/chat/ToolExecutionSteps.tsx +320 -0
- package/inkos/packages/studio/src/components/chat/__tests__/ToolExecutionSteps.test.ts +114 -0
- package/inkos/packages/studio/src/components/chat-utils.ts +56 -0
- package/inkos/packages/studio/src/components/chatbar-state.test.ts +69 -0
- package/inkos/packages/studio/src/components/sidebar/ChaptersSection.tsx +66 -0
- package/inkos/packages/studio/src/components/sidebar/CharacterSection.tsx +129 -0
- package/inkos/packages/studio/src/components/sidebar/FoundationSection.tsx +61 -0
- package/inkos/packages/studio/src/components/sidebar/ProgressSection.tsx +124 -0
- package/inkos/packages/studio/src/components/sidebar/SidebarCard.tsx +30 -0
- package/inkos/packages/studio/src/components/sidebar/SummarySection.tsx +89 -0
- package/inkos/packages/studio/src/components/ui/alert.tsx +76 -0
- package/inkos/packages/studio/src/components/ui/badge.tsx +52 -0
- package/inkos/packages/studio/src/components/ui/button-group.tsx +87 -0
- package/inkos/packages/studio/src/components/ui/button.tsx +58 -0
- package/inkos/packages/studio/src/components/ui/collapsible.tsx +19 -0
- package/inkos/packages/studio/src/components/ui/command.tsx +194 -0
- package/inkos/packages/studio/src/components/ui/dialog.tsx +158 -0
- package/inkos/packages/studio/src/components/ui/dropdown-menu.tsx +266 -0
- package/inkos/packages/studio/src/components/ui/hover-card.tsx +51 -0
- package/inkos/packages/studio/src/components/ui/input-group.tsx +158 -0
- package/inkos/packages/studio/src/components/ui/input.tsx +20 -0
- package/inkos/packages/studio/src/components/ui/select.tsx +199 -0
- package/inkos/packages/studio/src/components/ui/separator.tsx +23 -0
- package/inkos/packages/studio/src/components/ui/spinner.tsx +10 -0
- package/inkos/packages/studio/src/components/ui/textarea.tsx +18 -0
- package/inkos/packages/studio/src/components/ui/tooltip.tsx +66 -0
- package/inkos/packages/studio/src/constants/service-groups.ts +29 -0
- package/inkos/packages/studio/src/hooks/use-api.test.ts +93 -0
- package/inkos/packages/studio/src/hooks/use-api.ts +189 -0
- package/inkos/packages/studio/src/hooks/use-book-activity.test.ts +129 -0
- package/inkos/packages/studio/src/hooks/use-book-activity.ts +180 -0
- package/inkos/packages/studio/src/hooks/use-colors.ts +27 -0
- package/inkos/packages/studio/src/hooks/use-hash-route.test.ts +101 -0
- package/inkos/packages/studio/src/hooks/use-hash-route.ts +89 -0
- package/inkos/packages/studio/src/hooks/use-i18n.ts +289 -0
- package/inkos/packages/studio/src/hooks/use-session-events.ts +64 -0
- package/inkos/packages/studio/src/hooks/use-sse.test.ts +52 -0
- package/inkos/packages/studio/src/hooks/use-sse.ts +92 -0
- package/inkos/packages/studio/src/hooks/use-theme.test.ts +31 -0
- package/inkos/packages/studio/src/hooks/use-theme.ts +75 -0
- package/inkos/packages/studio/src/index.css +323 -0
- package/inkos/packages/studio/src/lib/error-copy.test.ts +34 -0
- package/inkos/packages/studio/src/lib/error-copy.ts +37 -0
- package/inkos/packages/studio/src/lib/utils.ts +6 -0
- package/inkos/packages/studio/src/main.tsx +10 -0
- package/inkos/packages/studio/src/pages/Analytics.tsx +80 -0
- package/inkos/packages/studio/src/pages/BookCreate.tsx +895 -0
- package/inkos/packages/studio/src/pages/BookDetail.tsx +652 -0
- package/inkos/packages/studio/src/pages/ChapterReader.tsx +266 -0
- package/inkos/packages/studio/src/pages/ChatPage.tsx +521 -0
- package/inkos/packages/studio/src/pages/DaemonControl.tsx +116 -0
- package/inkos/packages/studio/src/pages/Dashboard.tsx +379 -0
- package/inkos/packages/studio/src/pages/DoctorView.tsx +82 -0
- package/inkos/packages/studio/src/pages/GenreManager.tsx +464 -0
- package/inkos/packages/studio/src/pages/ImportManager.tsx +216 -0
- package/inkos/packages/studio/src/pages/LanguageSelector.tsx +74 -0
- package/inkos/packages/studio/src/pages/LogViewer.tsx +82 -0
- package/inkos/packages/studio/src/pages/RadarView.tsx +157 -0
- package/inkos/packages/studio/src/pages/ServiceDetailPage.tsx +393 -0
- package/inkos/packages/studio/src/pages/ServiceListPage.tsx +463 -0
- package/inkos/packages/studio/src/pages/StyleManager.tsx +225 -0
- package/inkos/packages/studio/src/pages/TruthFiles.tsx +194 -0
- package/inkos/packages/studio/src/pages/chat-page-state.test.ts +206 -0
- package/inkos/packages/studio/src/pages/chat-page-state.ts +112 -0
- package/inkos/packages/studio/src/pages/page-state.test.ts +258 -0
- package/inkos/packages/studio/src/pages/service-detail-state.test.ts +294 -0
- package/inkos/packages/studio/src/pages/service-detail-state.ts +234 -0
- package/inkos/packages/studio/src/pages/style-manager-state.test.ts +22 -0
- package/inkos/packages/studio/src/pages/truth-files-state.test.ts +61 -0
- package/inkos/packages/studio/src/shared/contracts.ts +143 -0
- package/inkos/packages/studio/src/store/chat/__tests__/message-parts.test.ts +172 -0
- package/inkos/packages/studio/src/store/chat/index.ts +3 -0
- package/inkos/packages/studio/src/store/chat/initialState.ts +8 -0
- package/inkos/packages/studio/src/store/chat/message-policy.test.ts +16 -0
- package/inkos/packages/studio/src/store/chat/message-policy.ts +5 -0
- package/inkos/packages/studio/src/store/chat/parts-builder.ts +187 -0
- package/inkos/packages/studio/src/store/chat/selectors.ts +13 -0
- package/inkos/packages/studio/src/store/chat/slices/create/action.ts +10 -0
- package/inkos/packages/studio/src/store/chat/slices/create/initialState.ts +9 -0
- package/inkos/packages/studio/src/store/chat/slices/message/action.ts +417 -0
- package/inkos/packages/studio/src/store/chat/slices/message/initialState.ts +10 -0
- package/inkos/packages/studio/src/store/chat/slices/message/runtime.test.ts +21 -0
- package/inkos/packages/studio/src/store/chat/slices/message/runtime.ts +233 -0
- package/inkos/packages/studio/src/store/chat/slices/message/stream-events.ts +272 -0
- package/inkos/packages/studio/src/store/chat/store.ts +11 -0
- package/inkos/packages/studio/src/store/chat/types.ts +169 -0
- package/inkos/packages/studio/src/store/service/index.ts +2 -0
- package/inkos/packages/studio/src/store/service/store.ts +123 -0
- package/inkos/packages/studio/src/store/service/types.ts +50 -0
- package/inkos/packages/studio/tsconfig.json +24 -0
- package/inkos/packages/studio/tsconfig.server.json +11 -0
- package/inkos/packages/studio/vite.config.ts +34 -0
- package/inkos/packages/studio/vitest.config.ts +14 -0
- package/inkos/pnpm-lock.yaml +9569 -0
- package/inkos/pnpm-workspace.yaml +2 -0
- package/inkos/scripts/prepare-package-for-publish.mjs +135 -0
- package/inkos/scripts/restore-package-json.mjs +31 -0
- package/inkos/scripts/set-package-versions.mjs +74 -0
- package/inkos/scripts/verify-no-workspace-protocol.mjs +140 -0
- package/inkos/skills/SKILL.md +654 -0
- package/inkos/tsconfig.json +19 -0
- package/package.json +4 -3
- /package/.next/static/{F2hMZMf1IyCVAWpkbtRz7 → -3vIrBZXdQ0rp7Wa3Kz40}/_buildManifest.js +0 -0
- /package/.next/static/{F2hMZMf1IyCVAWpkbtRz7 → -3vIrBZXdQ0rp7Wa3Kz40}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,859 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { ArchitectAgent } from "../agents/architect.js";
|
|
3
|
+
import type { BookConfig } from "../models/book.js";
|
|
4
|
+
import type { LLMClient } from "../llm/provider.js";
|
|
5
|
+
|
|
6
|
+
const ZERO_USAGE = {
|
|
7
|
+
promptTokens: 0,
|
|
8
|
+
completionTokens: 0,
|
|
9
|
+
totalTokens: 0,
|
|
10
|
+
} as const;
|
|
11
|
+
|
|
12
|
+
describe("ArchitectAgent", () => {
|
|
13
|
+
afterEach(() => {
|
|
14
|
+
vi.restoreAllMocks();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("uses English prompts when generating foundation from imported English chapters", async () => {
|
|
18
|
+
const agent = new ArchitectAgent({
|
|
19
|
+
client: {
|
|
20
|
+
provider: "openai",
|
|
21
|
+
apiFormat: "chat",
|
|
22
|
+
stream: false,
|
|
23
|
+
defaults: {
|
|
24
|
+
temperature: 0.7,
|
|
25
|
+
maxTokens: 4096,
|
|
26
|
+
thinkingBudget: 0,
|
|
27
|
+
extra: {},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
model: "test-model",
|
|
31
|
+
projectRoot: process.cwd(),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const book: BookConfig = {
|
|
35
|
+
id: "english-book",
|
|
36
|
+
title: "English Book",
|
|
37
|
+
platform: "other",
|
|
38
|
+
genre: "other",
|
|
39
|
+
status: "active",
|
|
40
|
+
targetChapters: 20,
|
|
41
|
+
chapterWordCount: 2200,
|
|
42
|
+
language: "en",
|
|
43
|
+
createdAt: "2026-03-24T00:00:00.000Z",
|
|
44
|
+
updatedAt: "2026-03-24T00:00:00.000Z",
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const chat = vi.spyOn(agent as unknown as { chat: (...args: unknown[]) => Promise<unknown> }, "chat")
|
|
48
|
+
.mockResolvedValue({
|
|
49
|
+
content: [
|
|
50
|
+
"=== SECTION: story_bible ===",
|
|
51
|
+
"# Story Bible",
|
|
52
|
+
"",
|
|
53
|
+
"=== SECTION: volume_outline ===",
|
|
54
|
+
"# Volume Outline",
|
|
55
|
+
"",
|
|
56
|
+
"=== SECTION: book_rules ===",
|
|
57
|
+
"---",
|
|
58
|
+
"version: \"1.0\"",
|
|
59
|
+
"---",
|
|
60
|
+
"",
|
|
61
|
+
"# Book Rules",
|
|
62
|
+
"",
|
|
63
|
+
"=== SECTION: current_state ===",
|
|
64
|
+
"# Current State",
|
|
65
|
+
"",
|
|
66
|
+
"=== SECTION: pending_hooks ===",
|
|
67
|
+
"# Pending Hooks",
|
|
68
|
+
].join("\n"),
|
|
69
|
+
usage: ZERO_USAGE,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
await agent.generateFoundationFromImport(
|
|
73
|
+
book,
|
|
74
|
+
"Chapter 1: Prelude\n\nA cold wind crossed the harbor.",
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const messages = chat.mock.calls[0]?.[0] as Array<{ role: string; content: string }>;
|
|
78
|
+
expect(messages[0]?.content).toContain("MUST be written in English");
|
|
79
|
+
expect(messages[1]?.content).toContain("Generate the complete foundation");
|
|
80
|
+
expect(messages[1]?.content).not.toContain("请从中反向推导");
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("does not embed Chinese section headings in imported English foundation prompts", async () => {
|
|
84
|
+
const agent = new ArchitectAgent({
|
|
85
|
+
client: {
|
|
86
|
+
provider: "openai",
|
|
87
|
+
apiFormat: "chat",
|
|
88
|
+
stream: false,
|
|
89
|
+
defaults: {
|
|
90
|
+
temperature: 0.7,
|
|
91
|
+
maxTokens: 4096,
|
|
92
|
+
thinkingBudget: 0,
|
|
93
|
+
extra: {},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
model: "test-model",
|
|
97
|
+
projectRoot: process.cwd(),
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const book: BookConfig = {
|
|
101
|
+
id: "english-book",
|
|
102
|
+
title: "English Book",
|
|
103
|
+
platform: "other",
|
|
104
|
+
genre: "other",
|
|
105
|
+
status: "active",
|
|
106
|
+
targetChapters: 20,
|
|
107
|
+
chapterWordCount: 2200,
|
|
108
|
+
language: "en",
|
|
109
|
+
createdAt: "2026-03-24T00:00:00.000Z",
|
|
110
|
+
updatedAt: "2026-03-24T00:00:00.000Z",
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const chat = vi.spyOn(agent as unknown as { chat: (...args: unknown[]) => Promise<unknown> }, "chat")
|
|
114
|
+
.mockResolvedValue({
|
|
115
|
+
content: [
|
|
116
|
+
"=== SECTION: story_bible ===",
|
|
117
|
+
"# Story Bible",
|
|
118
|
+
"",
|
|
119
|
+
"=== SECTION: volume_outline ===",
|
|
120
|
+
"# Volume Outline",
|
|
121
|
+
"",
|
|
122
|
+
"=== SECTION: book_rules ===",
|
|
123
|
+
"---",
|
|
124
|
+
"version: \"1.0\"",
|
|
125
|
+
"---",
|
|
126
|
+
"",
|
|
127
|
+
"# Book Rules",
|
|
128
|
+
"",
|
|
129
|
+
"=== SECTION: current_state ===",
|
|
130
|
+
"# Current State",
|
|
131
|
+
"",
|
|
132
|
+
"=== SECTION: pending_hooks ===",
|
|
133
|
+
"# Pending Hooks",
|
|
134
|
+
].join("\n"),
|
|
135
|
+
usage: ZERO_USAGE,
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
await agent.generateFoundationFromImport(
|
|
139
|
+
book,
|
|
140
|
+
"Chapter 1: Prelude\n\nA cold wind crossed the harbor.",
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
const messages = chat.mock.calls[0]?.[0] as Array<{ role: string; content: string }>;
|
|
144
|
+
// Phase 5: architect prompts describe the new prose sections. The English
|
|
145
|
+
// import prompt must not slip Chinese section headers into the system text.
|
|
146
|
+
expect(messages[0]?.content).toContain("story_frame");
|
|
147
|
+
expect(messages[0]?.content).toContain("volume_map");
|
|
148
|
+
expect(messages[0]?.content).not.toContain("## 01_世界观");
|
|
149
|
+
expect(messages[0]?.content).not.toContain("## 叙事视角");
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it("embeds reviewer feedback into original foundation regeneration prompts", async () => {
|
|
153
|
+
const agent = new ArchitectAgent({
|
|
154
|
+
client: {
|
|
155
|
+
provider: "openai",
|
|
156
|
+
apiFormat: "chat",
|
|
157
|
+
stream: false,
|
|
158
|
+
defaults: {
|
|
159
|
+
temperature: 0.7,
|
|
160
|
+
maxTokens: 4096,
|
|
161
|
+
thinkingBudget: 0,
|
|
162
|
+
extra: {},
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
model: "test-model",
|
|
166
|
+
projectRoot: process.cwd(),
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
const book: BookConfig = {
|
|
170
|
+
id: "review-feedback-book",
|
|
171
|
+
title: "雾港回灯",
|
|
172
|
+
platform: "tomato",
|
|
173
|
+
genre: "urban",
|
|
174
|
+
status: "active",
|
|
175
|
+
targetChapters: 60,
|
|
176
|
+
chapterWordCount: 2200,
|
|
177
|
+
language: "zh",
|
|
178
|
+
createdAt: "2026-04-03T00:00:00.000Z",
|
|
179
|
+
updatedAt: "2026-04-03T00:00:00.000Z",
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const chat = vi.spyOn(agent as unknown as { chat: (...args: unknown[]) => Promise<unknown> }, "chat")
|
|
183
|
+
.mockResolvedValue({
|
|
184
|
+
content: [
|
|
185
|
+
"=== SECTION: story_bible ===",
|
|
186
|
+
"# 故事圣经",
|
|
187
|
+
"",
|
|
188
|
+
"=== SECTION: volume_outline ===",
|
|
189
|
+
"# 卷纲",
|
|
190
|
+
"",
|
|
191
|
+
"=== SECTION: book_rules ===",
|
|
192
|
+
"---",
|
|
193
|
+
"version: \"1.0\"",
|
|
194
|
+
"---",
|
|
195
|
+
"",
|
|
196
|
+
"=== SECTION: current_state ===",
|
|
197
|
+
"# 当前状态",
|
|
198
|
+
"",
|
|
199
|
+
"=== SECTION: pending_hooks ===",
|
|
200
|
+
"# 待回收伏笔",
|
|
201
|
+
].join("\n"),
|
|
202
|
+
usage: ZERO_USAGE,
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
await agent.generateFoundation(
|
|
206
|
+
book,
|
|
207
|
+
undefined,
|
|
208
|
+
"请把核心冲突收紧,并明确新空间不是旧案重演。",
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
const messages = chat.mock.calls[0]?.[0] as Array<{ role: string; content: string }>;
|
|
212
|
+
expect(messages[0]?.content).toContain("上一轮审核反馈");
|
|
213
|
+
expect(messages[0]?.content).toContain("请把核心冲突收紧");
|
|
214
|
+
expect(messages[0]?.content).toContain("明确新空间不是旧案重演");
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it("embeds reviewer feedback into fanfic foundation regeneration prompts", async () => {
|
|
218
|
+
const agent = new ArchitectAgent({
|
|
219
|
+
client: {
|
|
220
|
+
provider: "openai",
|
|
221
|
+
apiFormat: "chat",
|
|
222
|
+
stream: false,
|
|
223
|
+
defaults: {
|
|
224
|
+
temperature: 0.7,
|
|
225
|
+
maxTokens: 4096,
|
|
226
|
+
thinkingBudget: 0,
|
|
227
|
+
extra: {},
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
model: "test-model",
|
|
231
|
+
projectRoot: process.cwd(),
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
const book: BookConfig = {
|
|
235
|
+
id: "fanfic-review-feedback-book",
|
|
236
|
+
title: "三体:回声舱",
|
|
237
|
+
platform: "tomato",
|
|
238
|
+
genre: "other",
|
|
239
|
+
status: "active",
|
|
240
|
+
targetChapters: 60,
|
|
241
|
+
chapterWordCount: 2200,
|
|
242
|
+
language: "zh",
|
|
243
|
+
createdAt: "2026-04-03T00:00:00.000Z",
|
|
244
|
+
updatedAt: "2026-04-03T00:00:00.000Z",
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
const chat = vi.spyOn(agent as unknown as { chat: (...args: unknown[]) => Promise<unknown> }, "chat")
|
|
248
|
+
.mockResolvedValue({
|
|
249
|
+
content: [
|
|
250
|
+
"=== SECTION: story_bible ===",
|
|
251
|
+
"# 故事圣经",
|
|
252
|
+
"",
|
|
253
|
+
"=== SECTION: volume_outline ===",
|
|
254
|
+
"# 卷纲",
|
|
255
|
+
"",
|
|
256
|
+
"=== SECTION: book_rules ===",
|
|
257
|
+
"---",
|
|
258
|
+
"version: \"1.0\"",
|
|
259
|
+
"---",
|
|
260
|
+
"",
|
|
261
|
+
"=== SECTION: current_state ===",
|
|
262
|
+
"# 当前状态",
|
|
263
|
+
"",
|
|
264
|
+
"=== SECTION: pending_hooks ===",
|
|
265
|
+
"# 待回收伏笔",
|
|
266
|
+
].join("\n"),
|
|
267
|
+
usage: ZERO_USAGE,
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
await agent.generateFanficFoundation(
|
|
271
|
+
book,
|
|
272
|
+
"# 原作正典\n- 罗辑在面壁计划中留下了一处空档。",
|
|
273
|
+
"canon",
|
|
274
|
+
"请明确分岔点,并用原创冲突替代原作重走。",
|
|
275
|
+
);
|
|
276
|
+
|
|
277
|
+
const messages = chat.mock.calls[0]?.[0] as Array<{ role: string; content: string }>;
|
|
278
|
+
expect(messages[0]?.content).toContain("上一轮审核反馈");
|
|
279
|
+
expect(messages[0]?.content).toContain("请明确分岔点");
|
|
280
|
+
expect(messages[0]?.content).toContain("原创冲突替代原作重走");
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
it("strips assistant-style trailing coda from the final pending hooks section", async () => {
|
|
284
|
+
const agent = new ArchitectAgent({
|
|
285
|
+
client: {
|
|
286
|
+
provider: "openai",
|
|
287
|
+
apiFormat: "chat",
|
|
288
|
+
stream: false,
|
|
289
|
+
defaults: {
|
|
290
|
+
temperature: 0.7,
|
|
291
|
+
maxTokens: 4096,
|
|
292
|
+
thinkingBudget: 0,
|
|
293
|
+
extra: {},
|
|
294
|
+
},
|
|
295
|
+
},
|
|
296
|
+
model: "test-model",
|
|
297
|
+
projectRoot: process.cwd(),
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
const book: BookConfig = {
|
|
301
|
+
id: "zh-book",
|
|
302
|
+
title: "雾港回灯",
|
|
303
|
+
platform: "other",
|
|
304
|
+
genre: "other",
|
|
305
|
+
status: "active",
|
|
306
|
+
targetChapters: 50,
|
|
307
|
+
chapterWordCount: 2200,
|
|
308
|
+
language: "zh",
|
|
309
|
+
createdAt: "2026-03-24T00:00:00.000Z",
|
|
310
|
+
updatedAt: "2026-03-24T00:00:00.000Z",
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
vi.spyOn(agent as unknown as { chat: (...args: unknown[]) => Promise<unknown> }, "chat")
|
|
314
|
+
.mockResolvedValue({
|
|
315
|
+
content: [
|
|
316
|
+
"=== SECTION: story_bible ===",
|
|
317
|
+
"# 故事圣经",
|
|
318
|
+
"",
|
|
319
|
+
"=== SECTION: volume_outline ===",
|
|
320
|
+
"# 卷纲",
|
|
321
|
+
"",
|
|
322
|
+
"=== SECTION: book_rules ===",
|
|
323
|
+
"---",
|
|
324
|
+
"version: \"1.0\"",
|
|
325
|
+
"---",
|
|
326
|
+
"",
|
|
327
|
+
"=== SECTION: current_state ===",
|
|
328
|
+
"# 当前状态",
|
|
329
|
+
"",
|
|
330
|
+
"=== SECTION: pending_hooks ===",
|
|
331
|
+
"| hook_id | 起始章节 | 类型 | 状态 | 最近推进 | 预期回收 | 备注 |",
|
|
332
|
+
"| --- | --- | --- | --- | --- | --- | --- |",
|
|
333
|
+
"| H01 | 1 | 主线 | 未开启 | 无 | 10章 | 主线核心钩子 |",
|
|
334
|
+
"",
|
|
335
|
+
"如果你愿意,我下一步可以继续为这本《雾港回灯》输出:",
|
|
336
|
+
"1. 前10章逐章细纲",
|
|
337
|
+
].join("\n"),
|
|
338
|
+
usage: ZERO_USAGE,
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
const result = await agent.generateFoundation(book);
|
|
342
|
+
|
|
343
|
+
// Phase 7 + hotfixes 1/2: ledger renders extended columns — depends_on,
|
|
344
|
+
// pays_off_in_arc, core_hook, half_life (empty when not specified), and
|
|
345
|
+
// promoted (computed at architect time). This hook has no promotion rule
|
|
346
|
+
// firing (core=否, no depends_on, in-volume payoff) so 升级=否.
|
|
347
|
+
expect(result.pendingHooks).toContain("| H01 | 1 | 主线 | 未开启 | 0 | 10章 | 中程 | 无 | | 否 | | 否 | 主线核心钩子 |");
|
|
348
|
+
expect(result.pendingHooks).not.toContain("如果你愿意");
|
|
349
|
+
expect(result.pendingHooks).not.toContain("前10章逐章细纲");
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
it("normalizes architect pending hooks into runtime-compatible numeric progress columns", async () => {
|
|
353
|
+
const agent = new ArchitectAgent({
|
|
354
|
+
client: {
|
|
355
|
+
provider: "openai",
|
|
356
|
+
apiFormat: "chat",
|
|
357
|
+
stream: false,
|
|
358
|
+
defaults: {
|
|
359
|
+
temperature: 0.7,
|
|
360
|
+
maxTokens: 4096,
|
|
361
|
+
thinkingBudget: 0,
|
|
362
|
+
extra: {},
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
model: "test-model",
|
|
366
|
+
projectRoot: process.cwd(),
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
const book: BookConfig = {
|
|
370
|
+
id: "zh-book",
|
|
371
|
+
title: "凌晨三点的证词",
|
|
372
|
+
platform: "tomato",
|
|
373
|
+
genre: "urban",
|
|
374
|
+
status: "active",
|
|
375
|
+
targetChapters: 80,
|
|
376
|
+
chapterWordCount: 2000,
|
|
377
|
+
language: "zh",
|
|
378
|
+
createdAt: "2026-03-25T00:00:00.000Z",
|
|
379
|
+
updatedAt: "2026-03-25T00:00:00.000Z",
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
vi.spyOn(agent as unknown as { chat: (...args: unknown[]) => Promise<unknown> }, "chat")
|
|
383
|
+
.mockResolvedValue({
|
|
384
|
+
content: [
|
|
385
|
+
"=== SECTION: story_bible ===",
|
|
386
|
+
"# 故事圣经",
|
|
387
|
+
"",
|
|
388
|
+
"=== SECTION: volume_outline ===",
|
|
389
|
+
"# 卷纲",
|
|
390
|
+
"",
|
|
391
|
+
"=== SECTION: book_rules ===",
|
|
392
|
+
"---",
|
|
393
|
+
"version: \"1.0\"",
|
|
394
|
+
"---",
|
|
395
|
+
"",
|
|
396
|
+
"=== SECTION: current_state ===",
|
|
397
|
+
"# 当前状态",
|
|
398
|
+
"",
|
|
399
|
+
"=== SECTION: pending_hooks ===",
|
|
400
|
+
"| hook_id | 起始章节 | 类型 | 状态 | 最近推进 | 预期回收 | 备注 |",
|
|
401
|
+
"| --- | --- | --- | --- | --- | --- | --- |",
|
|
402
|
+
"| H13 | 22 | 舆情操盘 | 待推进 | 一家自媒体公司在多个旧案节点同步接单 | 51-60章 | 庄蔓出场后逐步揭露 |",
|
|
403
|
+
].join("\n"),
|
|
404
|
+
usage: ZERO_USAGE,
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
const result = await agent.generateFoundation(book);
|
|
408
|
+
|
|
409
|
+
expect(result.pendingHooks).toContain("| H13 | 22 | 舆情操盘 | 待推进 | 0 | 51-60章 | 中程 | 无 | | 否 | | 否 | 庄蔓出场后逐步揭露(初始线索:一家自媒体公司在多个旧案节点同步接单) |");
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
it("accepts section labels with spacing and punctuation drift from non-strict models", async () => {
|
|
413
|
+
const agent = new ArchitectAgent({
|
|
414
|
+
client: {
|
|
415
|
+
provider: "openai",
|
|
416
|
+
apiFormat: "chat",
|
|
417
|
+
stream: false,
|
|
418
|
+
defaults: {
|
|
419
|
+
temperature: 0.7,
|
|
420
|
+
maxTokens: 4096,
|
|
421
|
+
thinkingBudget: 0,
|
|
422
|
+
extra: {},
|
|
423
|
+
},
|
|
424
|
+
},
|
|
425
|
+
model: "test-model",
|
|
426
|
+
projectRoot: process.cwd(),
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
const book: BookConfig = {
|
|
430
|
+
id: "format-drift-book",
|
|
431
|
+
title: "格式漂移测试",
|
|
432
|
+
platform: "other",
|
|
433
|
+
genre: "other",
|
|
434
|
+
status: "active",
|
|
435
|
+
targetChapters: 20,
|
|
436
|
+
chapterWordCount: 2200,
|
|
437
|
+
language: "zh",
|
|
438
|
+
createdAt: "2026-04-01T00:00:00.000Z",
|
|
439
|
+
updatedAt: "2026-04-01T00:00:00.000Z",
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
vi.spyOn(agent as unknown as { chat: (...args: unknown[]) => Promise<unknown> }, "chat")
|
|
443
|
+
.mockResolvedValue({
|
|
444
|
+
content: [
|
|
445
|
+
"=== Section:Story Bible ===",
|
|
446
|
+
"# 故事圣经",
|
|
447
|
+
"",
|
|
448
|
+
"=== section: Volume Outline ===",
|
|
449
|
+
"# 卷纲",
|
|
450
|
+
"",
|
|
451
|
+
"=== SECTION: book-rules ===",
|
|
452
|
+
"---",
|
|
453
|
+
"version: \"1.0\"",
|
|
454
|
+
"---",
|
|
455
|
+
"",
|
|
456
|
+
"=== SECTION : current state ===",
|
|
457
|
+
"# 当前状态",
|
|
458
|
+
"",
|
|
459
|
+
"=== SECTION: pending hooks ===",
|
|
460
|
+
"| hook_id | 起始章节 | 类型 | 状态 | 最近推进 | 预期回收 | 备注 |",
|
|
461
|
+
"| --- | --- | --- | --- | --- | --- | --- |",
|
|
462
|
+
"| H01 | 1 | mystery | open | 0 | 10章 | 初始钩子 |",
|
|
463
|
+
].join("\n"),
|
|
464
|
+
usage: ZERO_USAGE,
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
const result = await agent.generateFoundation(book);
|
|
468
|
+
|
|
469
|
+
expect(result.storyBible).toBe("# 故事圣经");
|
|
470
|
+
expect(result.volumeOutline).toBe("# 卷纲");
|
|
471
|
+
expect(result.bookRules).toContain("version: \"1.0\"");
|
|
472
|
+
expect(result.currentState).toBe("# 当前状态");
|
|
473
|
+
expect(result.pendingHooks).toContain("| H01 | 1 | mystery | open | 0 | 10章 | 中程 | 无 | | 否 | | 否 | 初始钩子 |");
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
it("throws when a required foundation section is missing", async () => {
|
|
477
|
+
const agent = new ArchitectAgent({
|
|
478
|
+
client: {
|
|
479
|
+
provider: "openai",
|
|
480
|
+
apiFormat: "chat",
|
|
481
|
+
stream: false,
|
|
482
|
+
defaults: {
|
|
483
|
+
temperature: 0.7,
|
|
484
|
+
maxTokens: 4096,
|
|
485
|
+
thinkingBudget: 0,
|
|
486
|
+
extra: {},
|
|
487
|
+
},
|
|
488
|
+
},
|
|
489
|
+
model: "test-model",
|
|
490
|
+
projectRoot: process.cwd(),
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
const book: BookConfig = {
|
|
494
|
+
id: "broken-book",
|
|
495
|
+
title: "Broken Book",
|
|
496
|
+
platform: "other",
|
|
497
|
+
genre: "other",
|
|
498
|
+
status: "active",
|
|
499
|
+
targetChapters: 20,
|
|
500
|
+
chapterWordCount: 2200,
|
|
501
|
+
language: "zh",
|
|
502
|
+
createdAt: "2026-03-29T00:00:00.000Z",
|
|
503
|
+
updatedAt: "2026-03-29T00:00:00.000Z",
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
vi.spyOn(agent as unknown as { chat: (...args: unknown[]) => Promise<unknown> }, "chat")
|
|
507
|
+
.mockResolvedValue({
|
|
508
|
+
content: [
|
|
509
|
+
"=== SECTION: story_bible ===",
|
|
510
|
+
"# 故事圣经",
|
|
511
|
+
"",
|
|
512
|
+
"=== SECTION: volume_outline ===",
|
|
513
|
+
"# 卷纲",
|
|
514
|
+
"",
|
|
515
|
+
"=== SECTION: current_state ===",
|
|
516
|
+
"# 当前状态",
|
|
517
|
+
"",
|
|
518
|
+
"=== SECTION: pending_hooks ===",
|
|
519
|
+
"# 伏笔池",
|
|
520
|
+
].join("\n"),
|
|
521
|
+
usage: ZERO_USAGE,
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
await expect(agent.generateFoundation(book)).rejects.toThrow(/book_rules/i);
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
it("uses modelCard output budget when generating foundation", async () => {
|
|
528
|
+
const agent = new ArchitectAgent({
|
|
529
|
+
client: {
|
|
530
|
+
provider: "openai",
|
|
531
|
+
apiFormat: "chat",
|
|
532
|
+
stream: false,
|
|
533
|
+
defaults: {
|
|
534
|
+
temperature: 0.7,
|
|
535
|
+
maxTokens: 4096,
|
|
536
|
+
thinkingBudget: 0,
|
|
537
|
+
extra: {},
|
|
538
|
+
},
|
|
539
|
+
},
|
|
540
|
+
model: "test-model",
|
|
541
|
+
projectRoot: process.cwd(),
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
const book: BookConfig = {
|
|
545
|
+
id: "max-tokens-book",
|
|
546
|
+
title: "Max Tokens Book",
|
|
547
|
+
platform: "other",
|
|
548
|
+
genre: "other",
|
|
549
|
+
status: "active",
|
|
550
|
+
targetChapters: 20,
|
|
551
|
+
chapterWordCount: 2200,
|
|
552
|
+
language: "zh",
|
|
553
|
+
createdAt: "2026-03-29T00:00:00.000Z",
|
|
554
|
+
updatedAt: "2026-03-29T00:00:00.000Z",
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
const chatSpy = vi.spyOn(agent as unknown as { chat: (...args: unknown[]) => Promise<unknown> }, "chat")
|
|
558
|
+
.mockResolvedValue({
|
|
559
|
+
content: [
|
|
560
|
+
"=== SECTION: story_bible ===",
|
|
561
|
+
"# 故事圣经",
|
|
562
|
+
"",
|
|
563
|
+
"=== SECTION: volume_outline ===",
|
|
564
|
+
"# 卷纲",
|
|
565
|
+
"",
|
|
566
|
+
"=== SECTION: book_rules ===",
|
|
567
|
+
"---",
|
|
568
|
+
"version: \"1.0\"",
|
|
569
|
+
"---",
|
|
570
|
+
"",
|
|
571
|
+
"=== SECTION: current_state ===",
|
|
572
|
+
"# 当前状态",
|
|
573
|
+
"",
|
|
574
|
+
"=== SECTION: pending_hooks ===",
|
|
575
|
+
"| hook_id | 起始章节 | 类型 | 状态 | 最近推进 | 预期回收 | 备注 |",
|
|
576
|
+
"| --- | --- | --- | --- | --- | --- | --- |",
|
|
577
|
+
"| H01 | 1 | mystery | open | 0 | 10章 | 初始钩子 |",
|
|
578
|
+
].join("\n"),
|
|
579
|
+
usage: ZERO_USAGE,
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
await agent.generateFoundation(book);
|
|
583
|
+
|
|
584
|
+
const options = chatSpy.mock.calls[0]?.[1] as { temperature?: number; maxTokens?: number } | undefined;
|
|
585
|
+
expect(options).toEqual(expect.objectContaining({ temperature: 0.8 }));
|
|
586
|
+
expect(options).not.toHaveProperty("maxTokens");
|
|
587
|
+
});
|
|
588
|
+
|
|
589
|
+
it("uses modelCard output budget when generating foundation from import", async () => {
|
|
590
|
+
const agent = new ArchitectAgent({
|
|
591
|
+
client: {
|
|
592
|
+
provider: "openai",
|
|
593
|
+
apiFormat: "chat",
|
|
594
|
+
stream: false,
|
|
595
|
+
defaults: {
|
|
596
|
+
temperature: 0.7,
|
|
597
|
+
maxTokens: 4096,
|
|
598
|
+
thinkingBudget: 0,
|
|
599
|
+
extra: {},
|
|
600
|
+
},
|
|
601
|
+
},
|
|
602
|
+
model: "test-model",
|
|
603
|
+
projectRoot: process.cwd(),
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
const book: BookConfig = {
|
|
607
|
+
id: "import-max-tokens-book",
|
|
608
|
+
title: "Import Max Tokens Book",
|
|
609
|
+
platform: "other",
|
|
610
|
+
genre: "other",
|
|
611
|
+
status: "active",
|
|
612
|
+
targetChapters: 20,
|
|
613
|
+
chapterWordCount: 2200,
|
|
614
|
+
language: "zh",
|
|
615
|
+
createdAt: "2026-03-29T00:00:00.000Z",
|
|
616
|
+
updatedAt: "2026-03-29T00:00:00.000Z",
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
const chatSpy = vi.spyOn(agent as unknown as { chat: (...args: unknown[]) => Promise<unknown> }, "chat")
|
|
620
|
+
.mockResolvedValue({
|
|
621
|
+
content: [
|
|
622
|
+
"=== SECTION: story_bible ===",
|
|
623
|
+
"# 故事圣经",
|
|
624
|
+
"",
|
|
625
|
+
"=== SECTION: volume_outline ===",
|
|
626
|
+
"# 卷纲",
|
|
627
|
+
"",
|
|
628
|
+
"=== SECTION: book_rules ===",
|
|
629
|
+
"---",
|
|
630
|
+
"version: \"1.0\"",
|
|
631
|
+
"---",
|
|
632
|
+
"",
|
|
633
|
+
"=== SECTION: current_state ===",
|
|
634
|
+
"# 当前状态",
|
|
635
|
+
"",
|
|
636
|
+
"=== SECTION: pending_hooks ===",
|
|
637
|
+
"| hook_id | 起始章节 | 类型 | 状态 | 最近推进 | 预期回收 | 备注 |",
|
|
638
|
+
"| --- | --- | --- | --- | --- | --- | --- |",
|
|
639
|
+
"| H01 | 1 | mystery | open | 0 | 10章 | 初始钩子 |",
|
|
640
|
+
].join("\n"),
|
|
641
|
+
usage: ZERO_USAGE,
|
|
642
|
+
});
|
|
643
|
+
|
|
644
|
+
await agent.generateFoundationFromImport(book, "第一章正文");
|
|
645
|
+
|
|
646
|
+
const options = chatSpy.mock.calls[0]?.[1] as { temperature?: number; maxTokens?: number } | undefined;
|
|
647
|
+
expect(options).toEqual(expect.objectContaining({ temperature: 0.5 }));
|
|
648
|
+
expect(options).not.toHaveProperty("maxTokens");
|
|
649
|
+
});
|
|
650
|
+
|
|
651
|
+
it("uses modelCard output budget when generating fanfic foundation", async () => {
|
|
652
|
+
const agent = new ArchitectAgent({
|
|
653
|
+
client: {
|
|
654
|
+
provider: "openai",
|
|
655
|
+
apiFormat: "chat",
|
|
656
|
+
stream: false,
|
|
657
|
+
defaults: {
|
|
658
|
+
temperature: 0.7,
|
|
659
|
+
maxTokens: 4096,
|
|
660
|
+
thinkingBudget: 0,
|
|
661
|
+
extra: {},
|
|
662
|
+
},
|
|
663
|
+
},
|
|
664
|
+
model: "test-model",
|
|
665
|
+
projectRoot: process.cwd(),
|
|
666
|
+
});
|
|
667
|
+
|
|
668
|
+
const book: BookConfig = {
|
|
669
|
+
id: "fanfic-max-tokens-book",
|
|
670
|
+
title: "Fanfic Max Tokens Book",
|
|
671
|
+
platform: "other",
|
|
672
|
+
genre: "fanfic",
|
|
673
|
+
status: "active",
|
|
674
|
+
targetChapters: 20,
|
|
675
|
+
chapterWordCount: 2200,
|
|
676
|
+
language: "zh",
|
|
677
|
+
createdAt: "2026-03-29T00:00:00.000Z",
|
|
678
|
+
updatedAt: "2026-03-29T00:00:00.000Z",
|
|
679
|
+
};
|
|
680
|
+
|
|
681
|
+
const chatSpy = vi.spyOn(agent as unknown as { chat: (...args: unknown[]) => Promise<unknown> }, "chat")
|
|
682
|
+
.mockResolvedValue({
|
|
683
|
+
content: [
|
|
684
|
+
"=== SECTION: story_bible ===",
|
|
685
|
+
"# 故事圣经",
|
|
686
|
+
"",
|
|
687
|
+
"=== SECTION: volume_outline ===",
|
|
688
|
+
"# 卷纲",
|
|
689
|
+
"",
|
|
690
|
+
"=== SECTION: book_rules ===",
|
|
691
|
+
"---",
|
|
692
|
+
"version: \"1.0\"",
|
|
693
|
+
"---",
|
|
694
|
+
"",
|
|
695
|
+
"=== SECTION: current_state ===",
|
|
696
|
+
"# 当前状态",
|
|
697
|
+
"",
|
|
698
|
+
"=== SECTION: pending_hooks ===",
|
|
699
|
+
"| hook_id | 起始章节 | 类型 | 状态 | 最近推进 | 预期回收 | 备注 |",
|
|
700
|
+
"| --- | --- | --- | --- | --- | --- | --- |",
|
|
701
|
+
"| H01 | 1 | mystery | open | 0 | 10章 | 初始钩子 |",
|
|
702
|
+
].join("\n"),
|
|
703
|
+
usage: ZERO_USAGE,
|
|
704
|
+
});
|
|
705
|
+
|
|
706
|
+
await agent.generateFanficFoundation(book, "正典文本", "canon");
|
|
707
|
+
|
|
708
|
+
const options = chatSpy.mock.calls[0]?.[1] as { temperature?: number; maxTokens?: number } | undefined;
|
|
709
|
+
expect(options).toEqual(expect.objectContaining({ temperature: 0.7 }));
|
|
710
|
+
expect(options).not.toHaveProperty("maxTokens");
|
|
711
|
+
});
|
|
712
|
+
|
|
713
|
+
// ---- Phase 5 段落式架构稿专项 ----
|
|
714
|
+
|
|
715
|
+
// 测试 stub:chat 会被 vi.spyOn 拦截,client.defaults 运行时不会被读取。
|
|
716
|
+
// 故意不填 temperature / maxTokens 等数字——避免在测试里留下"推荐配置"的
|
|
717
|
+
// 错误示范(maxTokens 填错会误导后续抄到生产,触发 CLAUDE.md 禁止的
|
|
718
|
+
// maxTokens 回归)。只保留类型要求的身份字段。
|
|
719
|
+
const buildPhase5Agent = (): ArchitectAgent =>
|
|
720
|
+
new ArchitectAgent({
|
|
721
|
+
client: {
|
|
722
|
+
provider: "openai",
|
|
723
|
+
apiFormat: "chat",
|
|
724
|
+
stream: false,
|
|
725
|
+
} as unknown as LLMClient,
|
|
726
|
+
model: "test-model",
|
|
727
|
+
projectRoot: process.cwd(),
|
|
728
|
+
});
|
|
729
|
+
|
|
730
|
+
const phase5Book = (): BookConfig => ({
|
|
731
|
+
id: "phase5-book",
|
|
732
|
+
title: "测试书",
|
|
733
|
+
platform: "qidian",
|
|
734
|
+
genre: "xuanhuan",
|
|
735
|
+
status: "active",
|
|
736
|
+
targetChapters: 50,
|
|
737
|
+
chapterWordCount: 3000,
|
|
738
|
+
language: "zh",
|
|
739
|
+
createdAt: "2026-04-19T00:00:00.000Z",
|
|
740
|
+
updatedAt: "2026-04-19T00:00:00.000Z",
|
|
741
|
+
});
|
|
742
|
+
|
|
743
|
+
it("generateFoundation parses story_frame / volume_map / roles sections", async () => {
|
|
744
|
+
const agent = buildPhase5Agent();
|
|
745
|
+
const book = phase5Book();
|
|
746
|
+
|
|
747
|
+
vi.spyOn(agent as unknown as { chat: (...args: unknown[]) => Promise<unknown> }, "chat")
|
|
748
|
+
.mockResolvedValue({
|
|
749
|
+
content: [
|
|
750
|
+
"=== SECTION: story_frame ===",
|
|
751
|
+
"## 主题与基调",
|
|
752
|
+
"段落 1 主题段落。",
|
|
753
|
+
"",
|
|
754
|
+
"## 核心冲突",
|
|
755
|
+
"段落 2 冲突段落。",
|
|
756
|
+
"",
|
|
757
|
+
"=== SECTION: volume_map ===",
|
|
758
|
+
"## 段 1",
|
|
759
|
+
"卷一段落。",
|
|
760
|
+
"",
|
|
761
|
+
"=== SECTION: roles ===",
|
|
762
|
+
"---ROLE---",
|
|
763
|
+
"tier: major",
|
|
764
|
+
"name: 林辞",
|
|
765
|
+
"---CONTENT---",
|
|
766
|
+
"## 核心标签",
|
|
767
|
+
"冷静、执着",
|
|
768
|
+
"",
|
|
769
|
+
"---ROLE---",
|
|
770
|
+
"tier: minor",
|
|
771
|
+
"name: 配角A",
|
|
772
|
+
"---CONTENT---",
|
|
773
|
+
"次要角色描写",
|
|
774
|
+
"",
|
|
775
|
+
"=== SECTION: book_rules ===",
|
|
776
|
+
"---",
|
|
777
|
+
"version: \"1.0\"",
|
|
778
|
+
"protagonist:",
|
|
779
|
+
" name: 林辞",
|
|
780
|
+
"---",
|
|
781
|
+
"",
|
|
782
|
+
"=== SECTION: pending_hooks ===",
|
|
783
|
+
"| hook_id | 起始章节 | 类型 | 状态 | 最近推进 | 预期回收 | 回收节奏 | 备注 |",
|
|
784
|
+
"|---|---|---|---|---|---|---|---|",
|
|
785
|
+
"| H001 | 1 | 主线 | open | 0 | 3 | 近期 | 初始线索 |",
|
|
786
|
+
].join("\n"),
|
|
787
|
+
usage: ZERO_USAGE,
|
|
788
|
+
});
|
|
789
|
+
|
|
790
|
+
const output = await agent.generateFoundation(book);
|
|
791
|
+
|
|
792
|
+
expect(output.storyFrame).toContain("主题与基调");
|
|
793
|
+
expect(output.volumeMap).toContain("段 1");
|
|
794
|
+
expect(output.roles).toBeDefined();
|
|
795
|
+
expect(output.roles!.length).toBe(2);
|
|
796
|
+
expect(output.roles![0]).toMatchObject({ tier: "major", name: "林辞" });
|
|
797
|
+
expect(output.roles![1]).toMatchObject({ tier: "minor", name: "配角A" });
|
|
798
|
+
});
|
|
799
|
+
|
|
800
|
+
it("writeFoundationFiles writes outline/ and roles/ when Phase 5 fields present", async () => {
|
|
801
|
+
const { mkdtemp, rm, access } = await import("node:fs/promises");
|
|
802
|
+
const { tmpdir } = await import("node:os");
|
|
803
|
+
const { join } = await import("node:path");
|
|
804
|
+
|
|
805
|
+
const agent = buildPhase5Agent();
|
|
806
|
+
const tmpDir = await mkdtemp(join(tmpdir(), "inkos-arch-test-"));
|
|
807
|
+
try {
|
|
808
|
+
await agent.writeFoundationFiles(tmpDir, {
|
|
809
|
+
storyBible: "legacy shim body",
|
|
810
|
+
volumeOutline: "legacy outline",
|
|
811
|
+
bookRules: "---\nversion: \"1.0\"\n---\n",
|
|
812
|
+
currentState: "",
|
|
813
|
+
pendingHooks: "| hook_id |",
|
|
814
|
+
storyFrame: "## 主题\n\n段落内容",
|
|
815
|
+
volumeMap: "## 卷一\n\n卷一段落",
|
|
816
|
+
roles: [
|
|
817
|
+
{ tier: "major", name: "林辞", content: "主角描写" },
|
|
818
|
+
{ tier: "minor", name: "配角A", content: "配角描写" },
|
|
819
|
+
],
|
|
820
|
+
}, false, "zh");
|
|
821
|
+
|
|
822
|
+
await expect(access(join(tmpDir, "story", "outline", "story_frame.md"))).resolves.not.toThrow();
|
|
823
|
+
await expect(access(join(tmpDir, "story", "outline", "volume_map.md"))).resolves.not.toThrow();
|
|
824
|
+
await expect(access(join(tmpDir, "story", "roles", "主要角色", "林辞.md"))).resolves.not.toThrow();
|
|
825
|
+
await expect(access(join(tmpDir, "story", "roles", "次要角色", "配角A.md"))).resolves.not.toThrow();
|
|
826
|
+
// Shim 文件也要在(向后兼容读取点用)
|
|
827
|
+
await expect(access(join(tmpDir, "story", "story_bible.md"))).resolves.not.toThrow();
|
|
828
|
+
await expect(access(join(tmpDir, "story", "character_matrix.md"))).resolves.not.toThrow();
|
|
829
|
+
await expect(access(join(tmpDir, "story", "book_rules.md"))).resolves.not.toThrow();
|
|
830
|
+
} finally {
|
|
831
|
+
await rm(tmpDir, { recursive: true, force: true });
|
|
832
|
+
}
|
|
833
|
+
});
|
|
834
|
+
|
|
835
|
+
it("writeFoundationFiles falls back to legacy layout when storyFrame is empty", async () => {
|
|
836
|
+
const { mkdtemp, rm, access, readFile } = await import("node:fs/promises");
|
|
837
|
+
const { tmpdir } = await import("node:os");
|
|
838
|
+
const { join } = await import("node:path");
|
|
839
|
+
|
|
840
|
+
const agent = buildPhase5Agent();
|
|
841
|
+
const tmpDir = await mkdtemp(join(tmpdir(), "inkos-arch-legacy-test-"));
|
|
842
|
+
try {
|
|
843
|
+
await agent.writeFoundationFiles(tmpDir, {
|
|
844
|
+
storyBible: "# Legacy Story Bible\n",
|
|
845
|
+
volumeOutline: "# Legacy Volume Outline\n",
|
|
846
|
+
bookRules: "# Legacy Book Rules\n",
|
|
847
|
+
currentState: "# Current State\n",
|
|
848
|
+
pendingHooks: "| hook_id |\n",
|
|
849
|
+
}, false, "zh");
|
|
850
|
+
|
|
851
|
+
const storyBible = await readFile(join(tmpDir, "story", "story_bible.md"), "utf-8");
|
|
852
|
+
expect(storyBible).toContain("Legacy Story Bible");
|
|
853
|
+
// outline/ 目录是创建的但里面没 story_frame.md
|
|
854
|
+
await expect(access(join(tmpDir, "story", "outline", "story_frame.md"))).rejects.toThrow();
|
|
855
|
+
} finally {
|
|
856
|
+
await rm(tmpDir, { recursive: true, force: true });
|
|
857
|
+
}
|
|
858
|
+
});
|
|
859
|
+
});
|