@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,91 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
+
import { sendWebhook, type WebhookPayload } from "../notify/webhook.js";
|
|
3
|
+
import { createHmac } from "node:crypto";
|
|
4
|
+
|
|
5
|
+
const mockFetch = vi.fn();
|
|
6
|
+
vi.stubGlobal("fetch", mockFetch);
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
mockFetch.mockReset();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const basePayload: WebhookPayload = {
|
|
13
|
+
event: "chapter-complete",
|
|
14
|
+
bookId: "test-book",
|
|
15
|
+
chapterNumber: 5,
|
|
16
|
+
timestamp: "2026-03-14T00:00:00.000Z",
|
|
17
|
+
data: { title: "测试章节", wordCount: 3000 },
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
describe("sendWebhook", () => {
|
|
21
|
+
it("sends POST request with JSON payload", async () => {
|
|
22
|
+
mockFetch.mockResolvedValueOnce({ ok: true });
|
|
23
|
+
|
|
24
|
+
await sendWebhook({ url: "https://example.com/hook" }, basePayload);
|
|
25
|
+
|
|
26
|
+
expect(mockFetch).toHaveBeenCalledOnce();
|
|
27
|
+
const [url, opts] = mockFetch.mock.calls[0]!;
|
|
28
|
+
expect(url).toBe("https://example.com/hook");
|
|
29
|
+
expect(opts.method).toBe("POST");
|
|
30
|
+
expect(opts.headers["Content-Type"]).toBe("application/json");
|
|
31
|
+
const body = JSON.parse(opts.body);
|
|
32
|
+
expect(body.event).toBe("chapter-complete");
|
|
33
|
+
expect(body.bookId).toBe("test-book");
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("includes HMAC signature when secret is configured", async () => {
|
|
37
|
+
mockFetch.mockResolvedValueOnce({ ok: true });
|
|
38
|
+
const secret = "my-secret-key";
|
|
39
|
+
|
|
40
|
+
await sendWebhook({ url: "https://example.com/hook", secret }, basePayload);
|
|
41
|
+
|
|
42
|
+
const [, opts] = mockFetch.mock.calls[0]!;
|
|
43
|
+
const expectedSig = createHmac("sha256", secret)
|
|
44
|
+
.update(opts.body)
|
|
45
|
+
.digest("hex");
|
|
46
|
+
expect(opts.headers["X-InkOS-Signature"]).toBe(`sha256=${expectedSig}`);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("skips event when not in subscribed events list", async () => {
|
|
50
|
+
await sendWebhook(
|
|
51
|
+
{ url: "https://example.com/hook", events: ["audit-passed"] },
|
|
52
|
+
basePayload,
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
expect(mockFetch).not.toHaveBeenCalled();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("sends event when it matches subscribed events list", async () => {
|
|
59
|
+
mockFetch.mockResolvedValueOnce({ ok: true });
|
|
60
|
+
|
|
61
|
+
await sendWebhook(
|
|
62
|
+
{ url: "https://example.com/hook", events: ["chapter-complete"] },
|
|
63
|
+
basePayload,
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
expect(mockFetch).toHaveBeenCalledOnce();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("sends all events when events list is empty", async () => {
|
|
70
|
+
mockFetch.mockResolvedValueOnce({ ok: true });
|
|
71
|
+
|
|
72
|
+
await sendWebhook(
|
|
73
|
+
{ url: "https://example.com/hook", events: [] },
|
|
74
|
+
basePayload,
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
expect(mockFetch).toHaveBeenCalledOnce();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("throws on non-ok response", async () => {
|
|
81
|
+
mockFetch.mockResolvedValueOnce({
|
|
82
|
+
ok: false,
|
|
83
|
+
status: 500,
|
|
84
|
+
text: async () => "Internal Server Error",
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
await expect(
|
|
88
|
+
sendWebhook({ url: "https://example.com/hook" }, basePayload),
|
|
89
|
+
).rejects.toThrow("Webhook POST to https://example.com/hook failed: 500");
|
|
90
|
+
});
|
|
91
|
+
});
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { parseWriterOutput, parseCreativeOutput, type ParsedWriterOutput } from "../agents/writer-parser.js";
|
|
3
|
+
import type { GenreProfile } from "../models/genre-profile.js";
|
|
4
|
+
import { countChapterLength } from "../utils/length-metrics.js";
|
|
5
|
+
|
|
6
|
+
const defaultGenreProfile: GenreProfile = {
|
|
7
|
+
name: "测试",
|
|
8
|
+
id: "test",
|
|
9
|
+
language: "zh",
|
|
10
|
+
chapterTypes: [],
|
|
11
|
+
fatigueWords: [],
|
|
12
|
+
numericalSystem: true,
|
|
13
|
+
powerScaling: false,
|
|
14
|
+
eraResearch: false,
|
|
15
|
+
pacingRule: "",
|
|
16
|
+
satisfactionTypes: [],
|
|
17
|
+
auditDimensions: [],
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
function callParseOutput(
|
|
21
|
+
chapterNumber: number,
|
|
22
|
+
content: string,
|
|
23
|
+
genreProfile: GenreProfile = defaultGenreProfile,
|
|
24
|
+
countingMode: "zh_chars" | "en_words" = "zh_chars",
|
|
25
|
+
): ParsedWriterOutput {
|
|
26
|
+
return parseWriterOutput(chapterNumber, content, genreProfile, countingMode);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
// Full tagged output
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
|
|
33
|
+
describe("WriterAgent parseOutput", () => {
|
|
34
|
+
const fullOutput = [
|
|
35
|
+
"=== PRE_WRITE_CHECK ===",
|
|
36
|
+
"| 检查项 | 本章记录 | 备注 |",
|
|
37
|
+
"|--------|----------|------|",
|
|
38
|
+
"| 上下文范围 | 第1章 | |",
|
|
39
|
+
"",
|
|
40
|
+
"=== CHAPTER_TITLE ===",
|
|
41
|
+
"吞天之始",
|
|
42
|
+
"",
|
|
43
|
+
"=== CHAPTER_CONTENT ===",
|
|
44
|
+
"陈风站在悬崖边,俯视着脚下的万丈深渊。",
|
|
45
|
+
"一股强烈的吸力从深渊中传来,仿佛有什么东西在召唤他。",
|
|
46
|
+
"",
|
|
47
|
+
"=== POST_SETTLEMENT ===",
|
|
48
|
+
"| 结算项 | 本章记录 | 备注 |",
|
|
49
|
+
"|--------|----------|------|",
|
|
50
|
+
"| 资源账本 | 期初0 / 增量+100 / 期末100 | |",
|
|
51
|
+
"",
|
|
52
|
+
"=== UPDATED_STATE ===",
|
|
53
|
+
"# 状态卡",
|
|
54
|
+
"| 字段 | 值 |",
|
|
55
|
+
"|------|-----|",
|
|
56
|
+
"| 章节 | 1 |",
|
|
57
|
+
"",
|
|
58
|
+
"=== UPDATED_LEDGER ===",
|
|
59
|
+
"# 资源账本",
|
|
60
|
+
"| 章节 | 期初 | 来源 | 增量 | 期末 |",
|
|
61
|
+
"|------|------|------|------|------|",
|
|
62
|
+
"| 1 | 0 | 深渊果实 | +100 | 100 |",
|
|
63
|
+
"",
|
|
64
|
+
"=== UPDATED_HOOKS ===",
|
|
65
|
+
"# 伏笔池",
|
|
66
|
+
"| ID | 伏笔 | 状态 |",
|
|
67
|
+
"|-----|------|------|",
|
|
68
|
+
"| H001 | 深渊之物 | open |",
|
|
69
|
+
].join("\n");
|
|
70
|
+
|
|
71
|
+
it("extracts all sections from a complete tagged output", () => {
|
|
72
|
+
const result = callParseOutput(1, fullOutput);
|
|
73
|
+
|
|
74
|
+
expect(result.chapterNumber).toBe(1);
|
|
75
|
+
expect(result.title).toBe("吞天之始");
|
|
76
|
+
expect(result.content).toContain("陈风站在悬崖边");
|
|
77
|
+
expect(result.content).toContain("召唤他");
|
|
78
|
+
expect(result.preWriteCheck).toContain("检查项");
|
|
79
|
+
expect(result.postSettlement).toContain("资源账本");
|
|
80
|
+
expect(result.updatedState).toContain("状态卡");
|
|
81
|
+
expect(result.updatedLedger).toContain("深渊果实");
|
|
82
|
+
expect(result.updatedHooks).toContain("H001");
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("calculates wordCount with the shared counting helper", () => {
|
|
86
|
+
const result = callParseOutput(1, fullOutput);
|
|
87
|
+
const expectedContent =
|
|
88
|
+
"陈风站在悬崖边,俯视着脚下的万丈深渊。\n一股强烈的吸力从深渊中传来,仿佛有什么东西在召唤他。";
|
|
89
|
+
expect(result.wordCount).toBe(countChapterLength(expectedContent, "zh_chars"));
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// -------------------------------------------------------------------------
|
|
93
|
+
// Missing sections
|
|
94
|
+
// -------------------------------------------------------------------------
|
|
95
|
+
|
|
96
|
+
it("returns default title when CHAPTER_TITLE is missing", () => {
|
|
97
|
+
const output = [
|
|
98
|
+
"=== CHAPTER_CONTENT ===",
|
|
99
|
+
"Some content here.",
|
|
100
|
+
].join("\n");
|
|
101
|
+
|
|
102
|
+
const result = callParseOutput(42, output);
|
|
103
|
+
expect(result.title).toBe("第42章");
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("returns an English default title when CHAPTER_TITLE is missing in English mode", () => {
|
|
107
|
+
const output = [
|
|
108
|
+
"=== CHAPTER_CONTENT ===",
|
|
109
|
+
"Some content here.",
|
|
110
|
+
].join("\n");
|
|
111
|
+
|
|
112
|
+
const result = callParseOutput(42, output, defaultGenreProfile, "en_words");
|
|
113
|
+
expect(result.title).toBe("Chapter 42");
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it("returns empty content when CHAPTER_CONTENT is missing", () => {
|
|
117
|
+
const output = [
|
|
118
|
+
"=== CHAPTER_TITLE ===",
|
|
119
|
+
"A Title",
|
|
120
|
+
].join("\n");
|
|
121
|
+
|
|
122
|
+
const result = callParseOutput(1, output);
|
|
123
|
+
expect(result.content).toBe("");
|
|
124
|
+
expect(result.wordCount).toBe(0);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it("returns fallback strings for missing state sections", () => {
|
|
128
|
+
const output = [
|
|
129
|
+
"=== CHAPTER_TITLE ===",
|
|
130
|
+
"Title",
|
|
131
|
+
"",
|
|
132
|
+
"=== CHAPTER_CONTENT ===",
|
|
133
|
+
"Content.",
|
|
134
|
+
].join("\n");
|
|
135
|
+
|
|
136
|
+
const result = callParseOutput(1, output);
|
|
137
|
+
expect(result.updatedState).toBe("(状态卡未更新)");
|
|
138
|
+
expect(result.updatedLedger).toBe("(账本未更新)");
|
|
139
|
+
expect(result.updatedHooks).toBe("(伏笔池未更新)");
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it("returns English fallback strings for missing state sections in English mode", () => {
|
|
143
|
+
const output = [
|
|
144
|
+
"=== CHAPTER_TITLE ===",
|
|
145
|
+
"Title",
|
|
146
|
+
"",
|
|
147
|
+
"=== CHAPTER_CONTENT ===",
|
|
148
|
+
"Content.",
|
|
149
|
+
].join("\n");
|
|
150
|
+
|
|
151
|
+
const result = callParseOutput(1, output, defaultGenreProfile, "en_words");
|
|
152
|
+
expect(result.updatedState).toBe("(state card not updated)");
|
|
153
|
+
expect(result.updatedLedger).toBe("(ledger not updated)");
|
|
154
|
+
expect(result.updatedHooks).toBe("(hooks pool not updated)");
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("returns empty string for missing PRE_WRITE_CHECK", () => {
|
|
158
|
+
const output = [
|
|
159
|
+
"=== CHAPTER_TITLE ===",
|
|
160
|
+
"Title",
|
|
161
|
+
"",
|
|
162
|
+
"=== CHAPTER_CONTENT ===",
|
|
163
|
+
"Content.",
|
|
164
|
+
].join("\n");
|
|
165
|
+
|
|
166
|
+
const result = callParseOutput(1, output);
|
|
167
|
+
expect(result.preWriteCheck).toBe("");
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it("returns empty string for missing POST_SETTLEMENT", () => {
|
|
171
|
+
const output = [
|
|
172
|
+
"=== CHAPTER_TITLE ===",
|
|
173
|
+
"Title",
|
|
174
|
+
"",
|
|
175
|
+
"=== CHAPTER_CONTENT ===",
|
|
176
|
+
"Content.",
|
|
177
|
+
].join("\n");
|
|
178
|
+
|
|
179
|
+
const result = callParseOutput(1, output);
|
|
180
|
+
expect(result.postSettlement).toBe("");
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
// -------------------------------------------------------------------------
|
|
184
|
+
// Edge cases
|
|
185
|
+
// -------------------------------------------------------------------------
|
|
186
|
+
|
|
187
|
+
it("handles completely empty input", () => {
|
|
188
|
+
const result = callParseOutput(1, "");
|
|
189
|
+
expect(result.chapterNumber).toBe(1);
|
|
190
|
+
expect(result.title).toBe("第1章");
|
|
191
|
+
expect(result.content).toBe("");
|
|
192
|
+
expect(result.wordCount).toBe(0);
|
|
193
|
+
expect(result.updatedState).toBe("(状态卡未更新)");
|
|
194
|
+
expect(result.updatedLedger).toBe("(账本未更新)");
|
|
195
|
+
expect(result.updatedHooks).toBe("(伏笔池未更新)");
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it("handles content with no tags at all", () => {
|
|
199
|
+
const result = callParseOutput(5, "Just some random text without tags");
|
|
200
|
+
expect(result.title).toBe("第5章");
|
|
201
|
+
expect(result.content).toBe("");
|
|
202
|
+
expect(result.wordCount).toBe(0);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it("preserves multiline content within a section", () => {
|
|
206
|
+
const output = [
|
|
207
|
+
"=== CHAPTER_CONTENT ===",
|
|
208
|
+
"第一段:这里是开头。",
|
|
209
|
+
"",
|
|
210
|
+
"第二段:这里是中间。",
|
|
211
|
+
"",
|
|
212
|
+
"第三段:这里是结尾。",
|
|
213
|
+
"",
|
|
214
|
+
"=== POST_SETTLEMENT ===",
|
|
215
|
+
"No settlement.",
|
|
216
|
+
].join("\n");
|
|
217
|
+
|
|
218
|
+
const result = callParseOutput(1, output);
|
|
219
|
+
expect(result.content).toContain("第一段");
|
|
220
|
+
expect(result.content).toContain("第二段");
|
|
221
|
+
expect(result.content).toContain("第三段");
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it("trims whitespace from extracted section values", () => {
|
|
225
|
+
const output = [
|
|
226
|
+
"=== CHAPTER_TITLE ===",
|
|
227
|
+
" 吞天之始 ",
|
|
228
|
+
"",
|
|
229
|
+
"=== CHAPTER_CONTENT ===",
|
|
230
|
+
" 内容 ",
|
|
231
|
+
].join("\n");
|
|
232
|
+
|
|
233
|
+
const result = callParseOutput(1, output);
|
|
234
|
+
expect(result.title).toBe("吞天之始");
|
|
235
|
+
expect(result.content).toBe("内容");
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it("correctly counts Chinese characters in wordCount", () => {
|
|
239
|
+
const chineseContent = "这是一段测试文本,包含二十个中文字符加上标点符号。";
|
|
240
|
+
const output = [
|
|
241
|
+
"=== CHAPTER_CONTENT ===",
|
|
242
|
+
chineseContent,
|
|
243
|
+
].join("\n");
|
|
244
|
+
|
|
245
|
+
const result = callParseOutput(1, output);
|
|
246
|
+
// wordCount is content.length which counts each character (including punctuation)
|
|
247
|
+
expect(result.wordCount).toBe(chineseContent.length);
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it("counts English content with the shared counting helper when requested", () => {
|
|
251
|
+
const englishContent = "He looked at the sky.";
|
|
252
|
+
const output = [
|
|
253
|
+
"=== CHAPTER_CONTENT ===",
|
|
254
|
+
englishContent,
|
|
255
|
+
].join("\n");
|
|
256
|
+
|
|
257
|
+
const result = callParseOutput(1, output, defaultGenreProfile, "en_words");
|
|
258
|
+
expect(result.wordCount).toBe(countChapterLength(englishContent, "en_words"));
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
// ---------------------------------------------------------------------------
|
|
263
|
+
// Fallback parsing for local/small models (#13)
|
|
264
|
+
// ---------------------------------------------------------------------------
|
|
265
|
+
|
|
266
|
+
describe("parseCreativeOutput fallback", () => {
|
|
267
|
+
it("extracts content from markdown heading when tags are missing", () => {
|
|
268
|
+
const raw = `# 第1章 觉醒之日
|
|
269
|
+
|
|
270
|
+
林风缓缓睁开了眼睛,映入眼帘的是一片陌生的天花板。他的脑海中充斥着混乱的记忆碎片,${"一段很长的正文内容".repeat(30)}完。`;
|
|
271
|
+
|
|
272
|
+
const result = parseCreativeOutput(1, raw);
|
|
273
|
+
expect(result.title).toBe("觉醒之日");
|
|
274
|
+
expect(result.content.length).toBeGreaterThan(100);
|
|
275
|
+
expect(result.content).toContain("林风");
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
it("extracts English content from markdown headings when tags are missing", () => {
|
|
279
|
+
const raw = `# Chapter 1: Awakening Day
|
|
280
|
+
|
|
281
|
+
He woke to the sound of distant bells and the taste of salt in the air. ${"Long English prose follows. ".repeat(15)}`;
|
|
282
|
+
|
|
283
|
+
const result = parseCreativeOutput(1, raw, "en_words");
|
|
284
|
+
expect(result.title).toBe("Awakening Day");
|
|
285
|
+
expect(result.content.length).toBeGreaterThan(100);
|
|
286
|
+
expect(result.content).toContain("distant bells");
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it("extracts content from 正文 label when tags are missing", () => {
|
|
290
|
+
const raw = `章节标题:暗夜追踪
|
|
291
|
+
|
|
292
|
+
正文:
|
|
293
|
+
${"黑暗中一道身影掠过屋顶,无声无息。".repeat(20)}`;
|
|
294
|
+
|
|
295
|
+
const result = parseCreativeOutput(5, raw);
|
|
296
|
+
expect(result.title).toBe("暗夜追踪");
|
|
297
|
+
expect(result.content.length).toBeGreaterThan(100);
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
it("falls back to longest prose block when no structure is found", () => {
|
|
301
|
+
const prose = "这是一段完整的小说正文,描述了主角在黑暗中探索未知世界的经历。".repeat(10);
|
|
302
|
+
const raw = `PRE_WRITE_CHECK: 已完成自检
|
|
303
|
+
CHAPTER_TITLE: 探索
|
|
304
|
+
|
|
305
|
+
${prose}`;
|
|
306
|
+
|
|
307
|
+
const result = parseCreativeOutput(3, raw);
|
|
308
|
+
expect(result.content.length).toBeGreaterThan(100);
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
it("returns empty content when raw output is too short", () => {
|
|
312
|
+
const result = parseCreativeOutput(1, "太短了");
|
|
313
|
+
expect(result.content).toBe("");
|
|
314
|
+
expect(result.title).toBe("第1章");
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
it("returns an English fallback title when short English output has no structure", () => {
|
|
318
|
+
const result = parseCreativeOutput(1, "too short", "en_words");
|
|
319
|
+
expect(result.content).toBe("");
|
|
320
|
+
expect(result.title).toBe("Chapter 1");
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
it("still works with proper === TAG === format", () => {
|
|
324
|
+
const raw = `=== PRE_WRITE_CHECK ===
|
|
325
|
+
自检完成
|
|
326
|
+
|
|
327
|
+
=== CHAPTER_TITLE ===
|
|
328
|
+
正常标题
|
|
329
|
+
|
|
330
|
+
=== CHAPTER_CONTENT ===
|
|
331
|
+
正常的章节内容,这里是完整的正文。`;
|
|
332
|
+
|
|
333
|
+
const result = parseCreativeOutput(1, raw);
|
|
334
|
+
expect(result.title).toBe("正常标题");
|
|
335
|
+
expect(result.content).toBe("正常的章节内容,这里是完整的正文。");
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
it("counts creative output with the shared helper when a counting mode is supplied", () => {
|
|
339
|
+
const raw = `=== CHAPTER_TITLE ===
|
|
340
|
+
English Chapter
|
|
341
|
+
|
|
342
|
+
=== CHAPTER_CONTENT ===
|
|
343
|
+
He looked at the sky.`;
|
|
344
|
+
|
|
345
|
+
const result = parseCreativeOutput(1, raw, "en_words");
|
|
346
|
+
expect(result.wordCount).toBe(countChapterLength("He looked at the sky.", "en_words"));
|
|
347
|
+
});
|
|
348
|
+
});
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import type { BookConfig } from "../models/book.js";
|
|
3
|
+
import type { GenreProfile } from "../models/genre-profile.js";
|
|
4
|
+
import { LengthSpecSchema } from "../models/length-governance.js";
|
|
5
|
+
import { buildWriterSystemPrompt, buildGoldenOpeningDiscipline } from "../agents/writer-prompts.js";
|
|
6
|
+
|
|
7
|
+
const BOOK: BookConfig = {
|
|
8
|
+
id: "prompt-book",
|
|
9
|
+
title: "Prompt Book",
|
|
10
|
+
platform: "tomato",
|
|
11
|
+
genre: "other",
|
|
12
|
+
status: "active",
|
|
13
|
+
targetChapters: 20,
|
|
14
|
+
chapterWordCount: 3000,
|
|
15
|
+
createdAt: "2026-03-22T00:00:00.000Z",
|
|
16
|
+
updatedAt: "2026-03-22T00:00:00.000Z",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const GENRE: GenreProfile = {
|
|
20
|
+
id: "other",
|
|
21
|
+
name: "综合",
|
|
22
|
+
language: "zh",
|
|
23
|
+
chapterTypes: ["setup", "conflict"],
|
|
24
|
+
fatigueWords: [],
|
|
25
|
+
numericalSystem: false,
|
|
26
|
+
powerScaling: false,
|
|
27
|
+
eraResearch: false,
|
|
28
|
+
pacingRule: "",
|
|
29
|
+
satisfactionTypes: [],
|
|
30
|
+
auditDimensions: [],
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
describe("buildWriterSystemPrompt", () => {
|
|
34
|
+
it("includes writing methodology blocks in governed mode", () => {
|
|
35
|
+
const prompt = buildWriterSystemPrompt(
|
|
36
|
+
BOOK,
|
|
37
|
+
GENRE,
|
|
38
|
+
null,
|
|
39
|
+
"# Book Rules",
|
|
40
|
+
"# Genre Body",
|
|
41
|
+
"# Style Guide\n\nKeep the prose restrained.",
|
|
42
|
+
undefined,
|
|
43
|
+
3,
|
|
44
|
+
"creative",
|
|
45
|
+
undefined,
|
|
46
|
+
"zh",
|
|
47
|
+
"governed",
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
expect(prompt).toContain("## 输入治理契约");
|
|
51
|
+
expect(prompt).toContain("卷纲是默认规划");
|
|
52
|
+
// v10: compact craft card replaces full methodology modules
|
|
53
|
+
expect(prompt).toContain("写作铁律");
|
|
54
|
+
expect(prompt).toContain("盐溶于汤");
|
|
55
|
+
expect(prompt).toContain("黄金3章");
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("uses target-range wording when a length spec is provided", () => {
|
|
59
|
+
const lengthSpec = LengthSpecSchema.parse({
|
|
60
|
+
target: 2200,
|
|
61
|
+
softMin: 1900,
|
|
62
|
+
softMax: 2500,
|
|
63
|
+
hardMin: 1600,
|
|
64
|
+
hardMax: 2800,
|
|
65
|
+
countingMode: "zh_chars",
|
|
66
|
+
normalizeMode: "none",
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const prompt = buildWriterSystemPrompt(
|
|
70
|
+
BOOK,
|
|
71
|
+
GENRE,
|
|
72
|
+
null,
|
|
73
|
+
"# Book Rules",
|
|
74
|
+
"# Genre Body",
|
|
75
|
+
"# Style Guide\n\nKeep the prose restrained.",
|
|
76
|
+
undefined,
|
|
77
|
+
3,
|
|
78
|
+
"creative",
|
|
79
|
+
undefined,
|
|
80
|
+
"zh",
|
|
81
|
+
"governed",
|
|
82
|
+
lengthSpec,
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
expect(prompt).toContain("目标字数:2200");
|
|
86
|
+
expect(prompt).toContain("允许区间:1900-2500");
|
|
87
|
+
expect(prompt).not.toContain("正文不少于2200字");
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("keeps hard guardrails and book/style constraints in governed mode", () => {
|
|
91
|
+
const prompt = buildWriterSystemPrompt(
|
|
92
|
+
BOOK,
|
|
93
|
+
GENRE,
|
|
94
|
+
null,
|
|
95
|
+
"# Book Rules\n\n- Do not reveal the mastermind.",
|
|
96
|
+
"# Genre Body",
|
|
97
|
+
"# Style Guide\n\nKeep the prose restrained.",
|
|
98
|
+
undefined,
|
|
99
|
+
3,
|
|
100
|
+
"creative",
|
|
101
|
+
undefined,
|
|
102
|
+
"zh",
|
|
103
|
+
"governed",
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
expect(prompt).toContain("## 核心规则");
|
|
107
|
+
expect(prompt).toContain("## 硬性禁令");
|
|
108
|
+
expect(prompt).toContain("Do not reveal the mastermind");
|
|
109
|
+
expect(prompt).toContain("Keep the prose restrained");
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("injects the creative constitution and six pillars of immersion as prose (zh)", () => {
|
|
113
|
+
const prompt = buildWriterSystemPrompt(
|
|
114
|
+
BOOK,
|
|
115
|
+
GENRE,
|
|
116
|
+
null,
|
|
117
|
+
"# Book Rules",
|
|
118
|
+
"# Genre Body",
|
|
119
|
+
"# Style Guide",
|
|
120
|
+
undefined,
|
|
121
|
+
3,
|
|
122
|
+
"creative",
|
|
123
|
+
undefined,
|
|
124
|
+
"zh",
|
|
125
|
+
"governed",
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
// Constitution and pillars appear as prose section headings.
|
|
129
|
+
expect(prompt).toContain("## 创作宪法");
|
|
130
|
+
expect(prompt).toContain("## 代入感六支柱");
|
|
131
|
+
// Constitution prose beats — verify a few load-bearing phrases ship.
|
|
132
|
+
expect(prompt).toContain("盐溶于汤");
|
|
133
|
+
expect(prompt).toContain("全员智商在线");
|
|
134
|
+
expect(prompt).toContain("拒绝流水账");
|
|
135
|
+
// Pillar prose beats — ensure six-pillar content is present.
|
|
136
|
+
expect(prompt).toContain("基础信息标签化");
|
|
137
|
+
expect(prompt).toContain("可视化熟悉感");
|
|
138
|
+
expect(prompt).toContain("五感钩子");
|
|
139
|
+
// Must NOT be rendered as a numbered checklist — writer must internalise.
|
|
140
|
+
expect(prompt).not.toContain("1. 基础信息标签化");
|
|
141
|
+
expect(prompt).not.toContain("- 基础信息标签化");
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it("injects the creative constitution and six pillars of immersion as prose (en)", () => {
|
|
145
|
+
const prompt = buildWriterSystemPrompt(
|
|
146
|
+
{ ...BOOK, language: "en" },
|
|
147
|
+
{ ...GENRE, language: "en", name: "General" },
|
|
148
|
+
null,
|
|
149
|
+
"# Book Rules",
|
|
150
|
+
"# Genre Body",
|
|
151
|
+
"# Style Guide",
|
|
152
|
+
undefined,
|
|
153
|
+
3,
|
|
154
|
+
"creative",
|
|
155
|
+
undefined,
|
|
156
|
+
"en",
|
|
157
|
+
"governed",
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
expect(prompt).toContain("## Creative Constitution");
|
|
161
|
+
expect(prompt).toContain("## Six Pillars of Immersion");
|
|
162
|
+
expect(prompt).toContain("salt in soup");
|
|
163
|
+
expect(prompt).toContain("Refuse chronicle drift");
|
|
164
|
+
expect(prompt).toContain("core tag plus one contrasting detail");
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it("injects golden opening discipline into zh writer system prompt for ch<=3", () => {
|
|
168
|
+
for (const ch of [1, 2, 3]) {
|
|
169
|
+
const prompt = buildWriterSystemPrompt(
|
|
170
|
+
BOOK,
|
|
171
|
+
GENRE,
|
|
172
|
+
null,
|
|
173
|
+
"# Book Rules",
|
|
174
|
+
"# Genre Body",
|
|
175
|
+
"# Style Guide",
|
|
176
|
+
undefined,
|
|
177
|
+
ch,
|
|
178
|
+
"creative",
|
|
179
|
+
undefined,
|
|
180
|
+
"zh",
|
|
181
|
+
"governed",
|
|
182
|
+
);
|
|
183
|
+
expect(prompt).toContain("黄金三章写作纪律");
|
|
184
|
+
expect(prompt).toContain(`第 ${ch} 章`);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it("injects golden opening discipline into en writer system prompt for ch<=3", () => {
|
|
189
|
+
for (const ch of [1, 2, 3]) {
|
|
190
|
+
const prompt = buildWriterSystemPrompt(
|
|
191
|
+
BOOK,
|
|
192
|
+
{ ...GENRE, language: "en", name: "General" },
|
|
193
|
+
null,
|
|
194
|
+
"# Book Rules",
|
|
195
|
+
"# Genre Body",
|
|
196
|
+
"# Style Guide",
|
|
197
|
+
undefined,
|
|
198
|
+
ch,
|
|
199
|
+
"creative",
|
|
200
|
+
undefined,
|
|
201
|
+
"en",
|
|
202
|
+
"governed",
|
|
203
|
+
);
|
|
204
|
+
expect(prompt).toContain("Golden Opening Discipline");
|
|
205
|
+
expect(prompt).toContain(`Chapter ${ch}`);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it("omits golden opening discipline for ch>=4 in both languages", () => {
|
|
210
|
+
const zh = buildWriterSystemPrompt(
|
|
211
|
+
BOOK, GENRE, null, "# Book Rules", "# Genre Body", "# Style Guide",
|
|
212
|
+
undefined, 4, "creative", undefined, "zh", "governed",
|
|
213
|
+
);
|
|
214
|
+
expect(zh).not.toContain("黄金三章写作纪律");
|
|
215
|
+
|
|
216
|
+
const en = buildWriterSystemPrompt(
|
|
217
|
+
BOOK, { ...GENRE, language: "en", name: "General" }, null,
|
|
218
|
+
"# Book Rules", "# Genre Body", "# Style Guide",
|
|
219
|
+
undefined, 4, "creative", undefined, "en", "governed",
|
|
220
|
+
);
|
|
221
|
+
expect(en).not.toContain("Golden Opening Discipline");
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it("renders golden opening discipline as cohesive prose, not a checklist", () => {
|
|
225
|
+
const out = buildGoldenOpeningDiscipline(1, "zh");
|
|
226
|
+
// Header line is allowed; body must not contain enumerated/bulleted lines.
|
|
227
|
+
expect(out).not.toMatch(/^\s*1\.\s/m);
|
|
228
|
+
expect(out).not.toMatch(/^\s*-\s/m);
|
|
229
|
+
expect(out).not.toMatch(/^\s*\*\s/m);
|
|
230
|
+
// Carries the load-bearing slot constraints.
|
|
231
|
+
expect(out).toContain("800 字");
|
|
232
|
+
expect(out).toContain("做出来");
|
|
233
|
+
expect(out).toContain("说出来");
|
|
234
|
+
expect(out).toContain("小钩子");
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
it("buildGoldenOpeningDiscipline returns empty string for ch>=4 / undefined", () => {
|
|
238
|
+
expect(buildGoldenOpeningDiscipline(4, "zh")).toBe("");
|
|
239
|
+
expect(buildGoldenOpeningDiscipline(99, "en")).toBe("");
|
|
240
|
+
expect(buildGoldenOpeningDiscipline(undefined, "zh")).toBe("");
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
it("tells governed English prompts to obey variance briefs and include resistance-bearing exchanges", () => {
|
|
244
|
+
const prompt = buildWriterSystemPrompt(
|
|
245
|
+
{
|
|
246
|
+
...BOOK,
|
|
247
|
+
language: "en",
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
...GENRE,
|
|
251
|
+
language: "en",
|
|
252
|
+
name: "General",
|
|
253
|
+
},
|
|
254
|
+
null,
|
|
255
|
+
"# Book Rules",
|
|
256
|
+
"# Genre Body",
|
|
257
|
+
"# Style Guide\n\nKeep the prose restrained.",
|
|
258
|
+
undefined,
|
|
259
|
+
3,
|
|
260
|
+
"creative",
|
|
261
|
+
undefined,
|
|
262
|
+
"en",
|
|
263
|
+
"governed",
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
expect(prompt).toContain("English Variance Brief");
|
|
267
|
+
expect(prompt).toContain("resistance-bearing exchange");
|
|
268
|
+
});
|
|
269
|
+
});
|