Commit Graph

219 Commits

Author SHA1 Message Date
yuanzonghao 7c676fc43b fix(play): guard handleExportStory against duplicate clicks
Adds a ref-based mutex so concurrent /api/story-pack requests and
duplicate file downloads cannot be triggered by rapid clicking.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-08 15:45:36 +08:00
yuanzonghao 75548ce005 Merge pull request #52 from zonghaoyuan/feat/story-share
feat(play): add encrypted story sharing with replay
2026-06-08 09:57:16 +08:00
yuanzonghao 39a7269494 fix(share): harden story share and relocate import button
- Add Content-Length pre-check to story-pack and story-unpack routes
  to reject oversized payloads before buffering the body
- Suppress internal error details in story-unpack catch (was leaking
  e.message to the client)
- Strengthen sceneIndex validation: require non-negative integer
- Guard against undefined storyState when replaying shared stories
- Fix prefetch regression: remove currentBeat?.id from useEffect deps
  that was re-triggering all change-scene prefetches on every beat
- Fix double detach: use else-if so the second replay detach guard
  doesn't fire redundantly after the first already detached
- Align client file-size limit by format (.json 12MB, .infiplot 13MB)
- Move "载入剧情" import button next to "开始" with hover tooltip

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-08 08:46:05 +08:00
Zonghao Yuan 88808b93b6 docs: 简化 Docker 部署流程,用 curl 下载替代仓库克隆 (#53)
* docs: simplify Docker deploy — download two files instead of cloning repo

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(docs): use mkdir -p and guard against .env.local overwrite

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-07 22:39:01 +08:00
Zonghao Yuan cf83b9adea Merge pull request #54 from zonghaoyuan/chore/disable-pr-agent-auto-describe
chore(ci): disable PR Agent auto-describe and AI title
2026-06-07 22:38:12 +08:00
Zonghao Yuan 79d952c309 Merge pull request #51 from zonghaoyuan/feat/gallery-package
feat(gallery): 场景图集打包为 zip 下载并提取下载工具模块
2026-06-07 22:33:21 +08:00
yuanzonghao 867c52c24f fix(gallery): address review findings in zip download module
- Handle downloadImagesAsZip return value and surface errors to user
- Fix inferImageExtension garbage output for data URIs without semicolons
- Scale blob URL revocation delay for large zip files (>5MB → 60s)
- Cap uniqueZipPath dedup loop at 10k iterations with timestamp fallback
- Support relative URLs in inferImageExtension via base URL
- Handle svg+xml MIME subtype correctly

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-07 22:32:23 +08:00
yuanzonghao e39e9e1c86 chore(ci): disable PR Agent auto-describe and AI title
Collaborators' hand-written PR titles and descriptions were being
overwritten by the automatic /describe run. Disable auto_describe on the
Claude job and set generate_ai_title = false so human-authored metadata
is preserved. Manual /describe via PR comment still works.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-07 22:27:54 +08:00
baizhi958216 0abd5f1525 feat(play): add encrypted story sharing 2026-06-07 17:13:27 +08:00
baizhi958216 7925e9c459 feat(gallery): download scene gallery as zip
Signed-off-by: baizhi958216 <1475289190@qq.com>
2026-06-07 15:45:46 +08:00
Zonghao Yuan 3fc8d21b23 Merge pull request #48 from zonghaoyuan/chore/pr-agent-tune
chore(ci): tune PR Agent — independent banners, sharper findings, opus 4.6
2026-06-07 15:37:57 +08:00
yuanzonghao 63cc7a687e chore(ci): stop hiding *.md from PR Agent review
The previous "*.md" ignore glob hid best_practices.md and AGENTS.md from
the /review diff view (visible in PR #48 where the reviewer hallucinated
"this PR does not add a best_practices.md file"). README-style noise on
docs PRs is preferable to silently dropping changes to the project's
authoritative rule files.
2026-06-07 15:35:55 +08:00
yuanzonghao 81b99625d3 chore(ci): tune PR Agent config
- split per-model banners so two model jobs no longer overwrite each other
- raise reviewer findings cap to 8, broaden /improve to readability/cleanup
- enable dual-publishing for high-score suggestions (inline annotations)
- switch Claude model from opus-4-7 to opus-4-6 (fallback sonnet-4-6)
- raise reasoning_effort to high, response_language to zh-CN
- drop two dead config keys silently ignored by upstream schema
- add best_practices.md with 6 project-specific invariants for /improve
2026-06-07 15:29:34 +08:00
yuanzonghao df48e73d62 fix(play): sync playerName to active session on settings save
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-07 15:02:57 +08:00
yuanzonghao 4972243a93 fix: address PR Agent review findings across 6 files
Restrict PR Agent workflow to trusted collaborators on PR comments only,
fix UTF-8 byte counting in gallery-pack, correct portrait-to-landscape
fallback orientation, track inserted freeform beats in visitedBeatIds,
allow clearing stored TTS key, and guard empty-string fuzzy match in
style selector.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-07 14:40:37 +08:00
Zonghao Yuan 74479c1aa6 Merge pull request #44 from zonghaoyuan/feat/vision-toggle
feat(play): add vision click setting
2026-06-07 14:24:14 +08:00
yuanzonghao 69ae1380cb fix(play): resolve hydration mismatch and fragile pace index
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-07 14:23:44 +08:00
yuanzonghao dc36b1fe9e feat(play): integrate vision click with unified settings modal
Merge vision-click toggle into the shared SettingsModal alongside
player name and TTS key configuration. Remove standalone TtsKeyModal.
Add settings gear button to PlayCanvas dialogue card and header.
Fix fullscreen settings modal not rendering in immersive mode.
Voice toggle uses standard CategorySelect dropdown matching other
tab bar options.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-07 14:15:22 +08:00
Zonghao Yuan 2700de2d9f Merge pull request #46 from zonghaoyuan/feat/new-art-styles
feat(web): add 14 new art styles with thumbnails and reorder style grid
2026-06-07 13:29:45 +08:00
yuanzonghao b57e36571d fix(web): bump thumbV to v5 to avoid stale thumbnail cache
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-07 13:28:45 +08:00
yuanzonghao 53868471c6 feat(web): add 14 new art styles with thumbnails and reorder style grid
Add 14 new painting styles sourced from preset story card generation
scripts: Dunhuang fresco, Persian miniature, Byzantine mosaic, stained
glass, vaporwave, vector illustration, low poly, pop art, glitch art,
papercut, steampunk, xianxia fantasy, dark fairytale, and urban fantasy.

Reorder all 36 styles into logical visual categories (anime → cinematic
→ Eastern traditional → Western traditional → genre → digital → handcraft)
for easier browsing. Update "auto" thumbnail to a 3×3 composite grid and
"custom" thumbnail to a paintbrush-on-canvas concept image.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-07 12:56:54 +08:00
Zonghao Yuan cdcf8513c0 Merge pull request #45 from zonghaoyuan/feat/player-name-and-freeform
feat(web): player name, freeform input & unified settings
2026-06-07 12:38:15 +08:00
yuanzonghao ae3dd17e6b feat(web): add player name, freeform input, and unified settings modal
- Player name: stored in localStorage, injected into Architect/Writer/InsertBeat
  prompts so NPCs address the player by name, displayed in dialogue UI
- Freeform input: compact button at choice nodes expands to text input, LLM
  classifier routes to insert-beat (interactive NPC response) or change-scene
- SettingsModal: unified panel merging player name, voice toggle (with
  collapsible TTS key section), replacing the old TtsKeyModal
- Insert-beat upgrade: prompt now requires NPC reaction when characters are
  present, shared by both freeform and Vision paths
- IME guard: isComposing check on freeform input to prevent CJK mid-composition
  submission

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-07 12:37:50 +08:00
DESKTOP-I1T6TF3\Q b0b5630a25 feat(web): export interactive gallery + encrypted share file
Adds a "导出图集" action at the bottom-right of the play canvas that
snapshots the current session into localStorage and opens
/gallery#id=<id> in a new tab — the original play page keeps running
untouched. In parallel, sends the doc to /api/gallery-pack and
downloads the result as a binary .infiplot file the player can send
to a friend.

The snapshot pulls in:
  - Every visited scene's image + beat graph + recorded visit trail
  - All AI-prefetched alternate scenes (a new resolvedPrefetchesRef in
    PlayInner captures each prefetch as it resolves, so abandoned
    branches the engine already paid to generate are kept)
  - Character names + basePortraitUrl (voice base64 / styleReference
    are stripped — they aren't needed for replay)

/gallery is a no-network interactive replay:
  - Per-beat advance and per-choice navigation. Picked choices are
    highlighted; unpicked choices are clickable when an alternate was
    prefetched, greyed otherwise.
  - Stack-based navigation for stepping into branches with one-tap
    "返回主线" to collapse back to the main path.
  - Top-bar batch download for scene images (including unique
    AI-prefetched branch scenes, deduped against the main path) and
    character portraits. Fetched with a per-file AbortController + 20s
    timeout in a small concurrency pool, then clicked serially.
    Prevents one slow CDN response from stranding the busy button.
  - In-progress hint banner reminding the player to allow the
    browser's "multiple downloads" prompt.
  - F-key fullscreen with a top toolbar that auto-retracts after the
    initial glance and pops back down on cursor approach.
  - Per-scene dialogue panel (fa-clock-rotate-left, matching the
    in-game history affordance).
  - "导入分享文件" entry on the empty/error state — accepts a friend's
    .infiplot, posts to /api/gallery-unpack, renders the decrypted doc.

Share-file format (.infiplot):
  - AES-256-GCM via Web Crypto (portable to Cloudflare Workers).
  - Layout: 4-byte magic "IFPL" + 1-byte version + 12-byte nonce +
    ciphertext (includes 16-byte auth tag).
  - Key derived from GALLERY_SECRET via SHA-256.
  - GCM's auth tag gives tamper-detection for free; any flip in the
    ciphertext/nonce surfaces as "文件校验失败" — same error as wrong-key,
    so the distinction can't leak server config.
  - Stateless: server keeps no record of issued files.
  - GALLERY_SECRET unset → /api/gallery-pack returns 503, the play page
    silently skips the share-file download, local view still works.
    Rotating the secret invalidates every previously-issued file.

Retention: trimGalleryExports keeps only the 2 most recent localStorage
docs; older ones are evicted before each write so quota stays flat
regardless of how many times the player exports. Share files live on
the player's own disk — no retention concern.

Adds 'gallery_export' to the analytics event schema (scene_count only —
no free text).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-07 12:08:37 +08:00
Zonghao Yuan 5acffb6f85 Merge pull request #43 from zonghaoyuan/worktree-ai-sdk-migration
refactor(ai-client): unify OpenAI-compatible path to AI SDK generateText
2026-06-07 12:04:47 +08:00
yuanzonghao 57b3ac78cd feat(ci): add dual-model PR Agent for automated code review
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-07 12:02:17 +08:00
yuanzonghao f4aca0b59c refactor(ai-client): extract shared createLanguageModel helper
De-duplicate the provider switch logic that was identical in chat.ts
and vision.ts into a shared model.ts module.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-07 11:55:55 +08:00
yuanzonghao 57bc6556ab refactor(ai-client): unify OpenAI-compatible path to AI SDK generateText
Eliminate the dual code path (raw fetch vs AI SDK) for text and vision.
All providers now go through createLanguageModel() + generateText(),
removing chatOpenAiCompatible/analyzeOpenAiCompatible, the manual Usage
type, summarizeUsage, and responseFormat plumbing from 8 call sites.

Key fix: @ai-sdk/openai v3 defaults to the Responses API (/responses);
DeepSeek only supports Chat Completions, so we use .chat() explicitly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-07 00:31:36 +08:00
Zonghao Yuan 0cf7246935 Merge pull request #42 from zonghaoyuan/worktree-portrait-card-support
feat(web): support portrait preset story cards on mobile
2026-06-07 00:28:39 +08:00
yuanzonghao 95a66d94ed feat(web): support portrait preset story cards on mobile
Mobile users clicking preset story cards now get portrait (9:16) scene
images instead of landscape. Previously card paths hardcoded orientation
to "landscape"; now they respect detectOrientation() and load from
firstact-portrait/ with graceful fallback to landscape.

- Add --portrait and --only flags to prebake-firstacts.mjs
- Add --portrait flag to localize-firstact-images.mjs
- Fix prebake STYLE_MAP extraction (moved to lib/options.ts)
- Generate 60 portrait firstact JSONs + firstscene webp assets
- Remove hardcoded "landscape" in play page card path

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-07 00:12:37 +08:00
Zonghao Yuan 04b869eed0 Merge pull request #40 from zonghaoyuan/feat/gal-history
feat(dx): add missing nextjs default rules
2026-06-06 23:36:34 +08:00
Zonghao Yuan 60e324c3b6 Merge pull request #38 from zonghaoyuan/worktree-style-modal-revamp
feat(web): revamp style modal with grid cards, optimized prompts, and polished custom view
2026-06-06 22:59:30 +08:00
Zonghao Yuan feda563b51 Merge pull request #41 from zonghaoyuan/fix/ime-enter-key
fix(web): prevent Enter key from firing during IME composition
2026-06-06 22:57:04 +08:00
yuanzonghao e2cb28ddb9 fix(web): prevent Enter key from firing during IME composition
Add isComposing guard to the homepage prompt textarea so CJK users
no longer accidentally submit while composing. Also show a subtle
"Enter 发送 · Shift+Enter 换行" hint when the input has content.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-06 22:42:03 +08:00
yuanzonghao 165dcbc5e6 fix(engine): prevent Architect from seeing literal "auto" styleGuide
Replace session.styleGuide with a descriptive placeholder before the
Architect runs, so its prompt reads a natural sentence instead of the
raw "auto" marker. Also wrap selectStyle in a try-catch so a transient
LLM failure falls back to 吉卜力 instead of crashing session start.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-06 22:28:44 +08:00
yuanzonghao 585f302908 feat(engine): auto-select art style via parallel LLM call
When user picks "自动", the client sends styleGuide="auto" to the
server. The orchestrator then runs a lightweight style-selector LLM
call in parallel with the Architect — both only depend on worldSetting,
so there is zero added latency. The selector picks the best-matching
preset from STYLE_MAP based on genre, mood, and setting.

Also moves STYLE_MAP from page.tsx to lib/options.ts so it can be
shared between client and server.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-06 22:08:08 +08:00
Zonghao Yuan 2971423bdd Merge pull request #39 from zonghaoyuan/worktree-docker-compose-deploy
feat(deploy): add Docker Compose self-hosted deployment
2026-06-06 22:04:14 +08:00
baizhi958216 1bdd4dfd13 feat(dx): add missing nextjs default rules
Signed-off-by: baizhi958216 <1475289190@qq.com>
2026-06-06 21:58:04 +08:00
yuanzonghao c82f887a02 feat(deploy): add Docker Compose self-hosted deployment option
Add multi-platform Docker image build (amd64 + arm64) with GitHub Actions
CI that pushes to GHCR on every merge to main. Users can self-host with
a single `docker compose up -d` command.

- Dockerfile: multi-stage build with Next.js standalone output (~150-200MB)
- docker-compose.yml: one-command self-hosted deployment
- .github/workflows/docker.yml: CI workflow with QEMU cross-compilation
- next.config.ts: conditional `output: "standalone"` via BUILD_STANDALONE env
- README (zh/en/ja): restructure deploy section to include Docker option

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-06 21:57:57 +08:00
yuanzonghao 5fab22b9d5 fix(build): exclude scripts/ from tsconfig to fix Vercel build
The gen-style-thumbs.ts script uses Bun-only APIs (import.meta.dir,
Bun.write) which fail TypeScript checking under the project's Next.js
tsconfig. Exclude the scripts directory from compilation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-06 21:57:33 +08:00
yuanzonghao 9dfff39f88 fix(web): address review — remove unused var, add focus-visible, fix comment
- Remove unused `isAuto` variable after magic-wand button removal
- Add focus-visible ring to style cards for keyboard accessibility
- Update DEFAULT_STYLE comment to match actual fallback (吉卜力)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-06 21:55:21 +08:00
Zonghao Yuan e1f213288e Merge pull request #37 from zonghaoyuan/feat/gal-history
feat(play): add play history
2026-06-06 21:50:30 +08:00
yuanzonghao 9a1c292b77 feat(web): polish custom style view layout and UX
Rework custom style view: fixed modal height to match grid view, move
upload and preset-import controls to bottom toolbar alongside cancel/save,
textarea fills remaining space. Add bordered style to cancel button,
improve disabled save button visibility, remove per-card magic-wand
customize button, and add placeholder hint about English prompts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-06 21:47:10 +08:00
yuanzonghao 9794a5a329 fix(play): fix CLAUDE.md typo and dialogue history memo anti-pattern
- Fix @AGETNTS.md → @AGENTS.md typo in CLAUDE.md
- Remove ref read inside useMemo (React anti-pattern causing one-frame stale data)
- Simplify buildDialogueHistory to read visitedBeatIds directly from session.history,
  which also fixes incorrect scene-ID matching when the same ID appears multiple times

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-06 21:39:24 +08:00
yuanzonghao 7185f319a2 feat(web): optimize style prompts and regenerate thumbnails with LLM-chosen scenes
Rewrite all 20 STYLE_MAP prompts with precise art terminology (sfumato,
feibai, bokashi, broken-color, etc.) and richer color/texture descriptions.
KyoAni prompt now references Beyond the Boundary and Sound Euphonium;
Ghibli references Spirited Away and Howl's Moving Castle. Regenerate all
style thumbnails using a two-step pipeline: DeepSeek picks an optimal
visual-novel scene per style, then Runware renders it. Add cache-busting
query param (thumbV) to thumbnail URLs. Include gen-style-thumbs.ts script
for future regeneration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-06 21:23:28 +08:00
baizhi958216 5a7daa8452 feat(play): add history dialog
Signed-off-by: baizhi958216 <1475289190@qq.com>
2026-06-06 20:52:10 +08:00
yuanzonghao 31ce3f1d40 feat(web): revamp style modal UI with grid cards, thumbnails, and dual-view
Redesign the painting-style picker inspired by Pollo AI: widen modal to
1400px, show styles as square thumbnail cards in a 4-column grid with
name labels below, add ember glow hover effect, and split custom-style
editing into its own view. Simplify style names (e.g. "京阿尼细腻日常" →
"京阿尼"), add 22 .webp preview thumbnails, and remove the per-preset
override mechanism in favor of a cleaner grid + custom flow.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-06 20:45:08 +08:00
baizhi958216 aef4771d2e feat(dx): add agents.md
Signed-off-by: baizhi958216 <1475289190@qq.com>
2026-06-06 19:49:32 +08:00
yuanzonghao aed05a0512 fix(web): remove hardcoded maxDuration so Vercel dashboard setting takes effect
Code-level `export const maxDuration = 60` and vercel.json `functions`
block were overriding the dashboard's 300s setting, causing ~100 504
timeouts per day on /api/scene and /api/start. Removing them lets each
Vercel plan use its own default (60s Hobby, 300s Pro) without breaking
self-deployers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-06 18:18:09 +08:00
Zonghao Yuan 812b9a8973 Merge pull request #35 from zonghaoyuan/worktree-remove-byo-api
refactor(web): remove client-side BYO API key feature
2026-06-06 17:45:28 +08:00