Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2043f8c966 | |||
| 65012e89b6 | |||
| 64b9ccfb9d | |||
| fcc3c39dad | |||
| f7a0adc616 | |||
| 57cd81d551 | |||
| 78088e422a | |||
| 65551cd827 |
@@ -5,7 +5,6 @@
|
|||||||
## 目录约定
|
## 目录约定
|
||||||
|
|
||||||
- `.codex/skills/` 是项目专属 skill 根目录。每个 skill 以目录中的 `SKILL.md` 为入口,配套的参考资料和脚本放在同一目录下。
|
- `.codex/skills/` 是项目专属 skill 根目录。每个 skill 以目录中的 `SKILL.md` 为入口,配套的参考资料和脚本放在同一目录下。
|
||||||
- `spec-driven-development` 负责跨模块、公开契约、SpacetimeDB、AGC/Runtime 和复杂 UI 任务的规范先行与逐里程碑验收;具体规则以 `docs/` 下的 SDD 工作流和模板为准。
|
|
||||||
- `.codex/plugins/` 保存随仓库分发的项目插件资源及其参考资料。当前的 `game-studio` 插件提供浏览器游戏设计、原型、2D/3D 技术栈、素材管线和 playtest 工作流;是否启用遵循当前 Codex 的插件加载机制,不依赖旧工具的环境变量或个人配置脚本。
|
- `.codex/plugins/` 保存随仓库分发的项目插件资源及其参考资料。当前的 `game-studio` 插件提供浏览器游戏设计、原型、2D/3D 技术栈、素材管线和 playtest 工作流;是否启用遵循当前 Codex 的插件加载机制,不依赖旧工具的环境变量或个人配置脚本。
|
||||||
- `.codex/hooks/`、`.codex/environments/` 等目录保存项目工具链所需的 hooks 和环境模板;它们不替代项目代码中的运行时配置。
|
- `.codex/hooks/`、`.codex/environments/` 等目录保存项目工具链所需的 hooks 和环境模板;它们不替代项目代码中的运行时配置。
|
||||||
- 长期有效的产品、架构、接口、排障和协作知识统一放在 `docs/` 与 `docs/project-memory/`,不复制到本目录。
|
- 长期有效的产品、架构、接口、排障和协作知识统一放在 `docs/` 与 `docs/project-memory/`,不复制到本目录。
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ Prefer `scripts/genarrative_external_api.py` for runnable REST calls. It uses on
|
|||||||
- Use stable references such as `objectKey`, project resource ID, or asset ID where each operation permits them. Image edit/redraw is stricter: `sourceReferenceId` accepts only a registered project resource ID or asset ID; upload confirmation alone is not enough. Use `/assets/read-url` only for temporary preview/download access.
|
- Use stable references such as `objectKey`, project resource ID, or asset ID where each operation permits them. Image edit/redraw is stricter: `sourceReferenceId` accepts only a registered project resource ID or asset ID; upload confirmation alone is not enough. Use `/assets/read-url` only for temporary preview/download access.
|
||||||
- Preserve both warning channels after completion. A general `warning` can coexist with `sliceWarning`; do not discard either.
|
- Preserve both warning channels after completion. A general `warning` can coexist with `sliceWarning`; do not discard either.
|
||||||
- Do not invent missing derivatives. A source-preserved warning means the main source remains usable but requested post-processing failed. A slice warning means the complete transparent sheet is usable but individual slices are absent.
|
- Do not invent missing derivatives. A source-preserved warning means the main source remains usable but requested post-processing failed. A slice warning means the complete transparent sheet is usable but individual slices are absent.
|
||||||
- Icon spritesheet generation requires an explicit `sliceMode` and has no default. Use `sliceMode="grid"` with the `gridX` and `gridY` the requirement actually names (1-32 each) only for equal grid cells or fixed slots; use `sliceMode="connected-components"` for free-form sheets or an open number of subjects, and constrain the count with `sliceCount` instead of inventing grid dimensions. `connected-components` must not carry `gridX`/`gridY`; an omitted, contradictory, or misapplied declaration returns 400 before billing.
|
|
||||||
- For successful `style="pixelArt"`, treat completed-result and nested resource/asset dimensions as the final logical-grid PNG dimensions. They may differ from `size`, `imageSize`, the provider image, and `canvasCompletion.placeholder`; do not rescale or reject the artifact to match those inputs.
|
- For successful `style="pixelArt"`, treat completed-result and nested resource/asset dimensions as the final logical-grid PNG dimensions. They may differ from `size`, `imageSize`, the provider image, and `canvasCompletion.placeholder`; do not rescale or reject the artifact to match those inputs.
|
||||||
- Keep generated artifacts in the canvas and asset library together. Character animation accepts `assetFolderId` and `assetLabel`; its completed result directly returns the final `assetKind="character-animation"` resource and asset with formal sequence fields. Do not create a duplicate first-frame record.
|
- Keep generated artifacts in the canvas and asset library together. Character animation accepts `assetFolderId` and `assetLabel`; its completed result directly returns the final `assetKind="character-animation"` resource and asset with formal sequence fields. Do not create a duplicate first-frame record.
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ Every generation row requires a stable `Idempotency-Key` header and returns HTTP
|
|||||||
| Image generation | `/api/external/v1/editor/images/generations` | `prompt` | `kind`, `style`, `model`, `aspectRatio`, `imageSize`, `size`, `referenceImageSrcs`, `projectId`, `assetFolderId`, `assetLabel`, `canvasCompletion`, `generationInputs` |
|
| Image generation | `/api/external/v1/editor/images/generations` | `prompt` | `kind`, `style`, `model`, `aspectRatio`, `imageSize`, `size`, `referenceImageSrcs`, `projectId`, `assetFolderId`, `assetLabel`, `canvasCompletion`, `generationInputs` |
|
||||||
| Image edit/redraw | `/api/external/v1/editor/images/edits` | `prompt`, `sourceReferenceId` | `referenceImageSrcs`, `model`, `size`, `projectId`, `assetFolderId`, `assetLabel`, `targetLayerId`, `canvasCompletion` |
|
| Image edit/redraw | `/api/external/v1/editor/images/edits` | `prompt`, `sourceReferenceId` | `referenceImageSrcs`, `model`, `size`, `projectId`, `assetFolderId`, `assetLabel`, `targetLayerId`, `canvasCompletion` |
|
||||||
| Background removal | `/api/external/v1/editor/images/background-removals` | `sourceImageSrc` | `projectId`, `sourceResourceId`, `targetLayerId`, static-image `assetKind`, `assetFolderId`, `assetLabel`, `canvasCompletion`, `generationInputs` |
|
| Background removal | `/api/external/v1/editor/images/background-removals` | `sourceImageSrc` | `projectId`, `sourceResourceId`, `targetLayerId`, static-image `assetKind`, `assetFolderId`, `assetLabel`, `canvasCompletion`, `generationInputs` |
|
||||||
| Icon spritesheet | `/api/external/v1/editor/icon-spritesheets/generations` | `referenceId`, `iconDescriptions` | `sliceMode`, `gridX`, `gridY`, `sliceCount`, `style`, `referenceImageSrcs`, `screenColor`, `model`, `aspectRatio`, `imageSize`, `projectId`, `assetFolderId`, `assetLabel`, `canvasCompletion` |
|
| Icon spritesheet | `/api/external/v1/editor/icon-spritesheets/generations` | `referenceId`, `iconDescriptions` | `sliceLayout`, `style`, `referenceImageSrcs`, `screenColor`, `model`, `aspectRatio`, `imageSize`, `projectId`, `assetFolderId`, `assetLabel`, `canvasCompletion` |
|
||||||
| UI asset extraction | `/api/external/v1/editor/ui-designs/assets/extractions` | `sourceImageSrc`, `aspectRatio`, `imageSize` | `screenColor`, `model`, `referenceImageSrcs`, `projectId`, `assetFolderId`, `spritesheetLabel`, `canvasCompletion` |
|
| UI asset extraction | `/api/external/v1/editor/ui-designs/assets/extractions` | `sourceImageSrc`, `aspectRatio`, `imageSize` | `screenColor`, `model`, `referenceImageSrcs`, `projectId`, `assetFolderId`, `spritesheetLabel`, `canvasCompletion` |
|
||||||
| Character animation | `/api/external/v1/editor/character-animations/generations` | `sourceLayerId`, `sourceImageSrc`, `sourceWidth`, `sourceHeight`, `promptText`, `resolution`, `ratio`, `frameCount`, `durationSeconds`, `model` | `projectId`, `sourceResourceId`, `assetFolderId`, `assetLabel`, `canvasCompletion` |
|
| Character animation | `/api/external/v1/editor/character-animations/generations` | `sourceLayerId`, `sourceImageSrc`, `sourceWidth`, `sourceHeight`, `promptText`, `resolution`, `ratio`, `frameCount`, `durationSeconds`, `model` | `projectId`, `sourceResourceId`, `assetFolderId`, `assetLabel`, `canvasCompletion` |
|
||||||
| Video generation | `/api/external/v1/editor/videos/generations` | `prompt`, `model`, `aspectRatio`, `durationSeconds`, `resolution`, `mode`, `sound` | `referenceImageSrcs`, `referenceVideoSrcs`, `referenceAudioSrcs`, `webSearchEnabled`, `projectId`, `assetFolderId`, `assetLabel`, `canvasCompletion` |
|
| Video generation | `/api/external/v1/editor/videos/generations` | `prompt`, `model`, `aspectRatio`, `durationSeconds`, `resolution`, `mode`, `sound` | `referenceImageSrcs`, `referenceVideoSrcs`, `referenceAudioSrcs`, `webSearchEnabled`, `projectId`, `assetFolderId`, `assetLabel`, `canvasCompletion` |
|
||||||
@@ -94,7 +94,7 @@ For image edit/redraw, confirming an upload is not sufficient: create a project
|
|||||||
|
|
||||||
The icon-spritesheet primary `referenceId` is intentionally stricter than ordinary image references: it accepts only a current-owner project resource ID or asset ID whose authoritative `assetKind` is `icon-spec`. It does not accept an `objectKey`, URL, Data URL, or Blob URL.
|
The icon-spritesheet primary `referenceId` is intentionally stricter than ordinary image references: it accepts only a current-owner project resource ID or asset ID whose authoritative `assetKind` is `icon-spec`. It does not accept an `objectKey`, URL, Data URL, or Blob URL.
|
||||||
|
|
||||||
`sliceMode` is required and has no default, so every request must state it. Use `"connected-components"` to detect independent opaque regions by alpha connectivity, or `"grid"` with positive `gridX` and `gridY` values (maximum 32 each) only when the requirement names equal grid cells or fixed slots; the dimensions must come from that requirement. `connected-components` must not carry `gridX`/`gridY`, and `sliceCount` constrains the connected-component result instead of expressing a grid. Omitting `sliceMode`, or contradicting the declared mode with grid dimensions, returns 400 before pricing, enqueueing, or any provider call.
|
`sliceLayout: "grid-2x2"` is an opt-in contract for four fixed game-runtime assets. The provider prompt and server persistence both preserve the ordered slots left-top, right-top, left-bottom, right-bottom. Omit it to retain the default connected-component slicing behaviour for ordinary free-form icon sheets.
|
||||||
|
|
||||||
## Common Values
|
## Common Values
|
||||||
|
|
||||||
|
|||||||
@@ -79,9 +79,9 @@ Keep the existing autonomous-build task graph. Do not add a parallel task system
|
|||||||
|
|
||||||
1. `art-director` generates `assets/art-spec.png` with image generation, `kind: "spec"`, then registers it as `assetKind: "icon-spec"`. This image is the authoritative visual spec; `generationInputs.artSpec` is supporting structured context.
|
1. `art-director` generates `assets/art-spec.png` with image generation, `kind: "spec"`, then registers it as `assetKind: "icon-spec"`. This image is the authoritative visual spec; `generationInputs.artSpec` is supporting structured context.
|
||||||
2. `design-foundation` generates `assets/ui-prototype.png` with `kind: "ui-design"`, using the registered art-spec resource ID in `referenceImageSrcs`.
|
2. `design-foundation` generates `assets/ui-prototype.png` with `kind: "ui-design"`, using the registered art-spec resource ID in `referenceImageSrcs`.
|
||||||
3. `art-asset-plan` generates transparent `assets/art-spritesheet.png` through icon spritesheet generation, using the same registered art-spec resource ID as `referenceId` plus concrete `iconDescriptions`. `sliceMode` is required and has no default: send `sliceMode: "grid"` with `gridX`/`gridY` only when the requirement itself fixes the slots or names the column/row count, and otherwise send `sliceMode: "connected-components"` (with `sliceCount` when a subject count must be constrained); never invent a grid to express "kinds of assets", and never send `gridX`/`gridY` with `connected-components`.
|
3. `art-asset-plan` generates transparent `assets/art-spritesheet.png` through icon spritesheet generation, using the same registered art-spec resource ID as `referenceId` plus concrete `iconDescriptions`. For the four-category game contract it must also send `sliceLayout: "grid-2x2"`; this is an explicit fixed-slot contract, not a client-side guessed crop.
|
||||||
|
|
||||||
For a playable Canvas game, do not stop at generation. Make `code-prototype` depend on `art-asset-plan` and consume the persisted `iconImageSrcs` slices for core players, blocks or targets, scene obstacles, and feedback. When the requirement fixes grid slots, require the response `sliceMode` to match the declared `grid` request and exactly `gridX × gridY` slices before registering the local runtime sheet; a connected-components request is instead judged by its own `sliceCount` or by the requirement, and both fewer and extra components fail closed. Treat `art-spec.png` as reference-only. A full-sheet `<img>`, CSS background, path-only mention, guessed equal-grid crop, or code-drawn replacement for core entities is not runtime asset use. If slicing produces `sliceWarning`, keep the complete transparent sheet as a valid editor artifact, but fail the playable game asset gate until real slice files or verified atlas coordinates exist; never invent coordinates or replace the icon-spritesheet route with ordinary image generation.
|
For a playable Canvas game, do not stop at generation. Make `code-prototype` depend on `art-asset-plan` and consume the persisted `iconImageSrcs` slices for core players, blocks or targets, scene obstacles, and feedback. For the four-category game-chat contract, require response `sliceLayout: "grid-2x2"` and exactly four slices before registering the local runtime sheet; both fewer and extra components fail closed. Treat `art-spec.png` as reference-only. A full-sheet `<img>`, CSS background, path-only mention, guessed equal-grid crop, or code-drawn replacement for core entities is not runtime asset use. If slicing produces `sliceWarning`, keep the complete transparent sheet as a valid editor artifact, but fail the playable game asset gate until real slice files or verified atlas coordinates exist; never invent coordinates or replace the icon-spritesheet route with ordinary image generation.
|
||||||
|
|
||||||
Never use `assets/ui-prototype.png` as the spritesheet visual-spec reference. UI extraction is outside this canonical DAG.
|
Never use `assets/ui-prototype.png` as the spritesheet visual-spec reference. UI extraction is outside this canonical DAG.
|
||||||
|
|
||||||
|
|||||||
@@ -617,7 +617,6 @@ class GenarrativeExternalClient:
|
|||||||
self,
|
self,
|
||||||
reference_id: str,
|
reference_id: str,
|
||||||
icon_descriptions: list[str],
|
icon_descriptions: list[str],
|
||||||
slice_mode: str,
|
|
||||||
**fields: Any,
|
**fields: Any,
|
||||||
) -> Any:
|
) -> Any:
|
||||||
reference_id = normalize_optional_text(reference_id)
|
reference_id = normalize_optional_text(reference_id)
|
||||||
@@ -626,20 +625,6 @@ class GenarrativeExternalClient:
|
|||||||
descriptions = [item.strip() for item in icon_descriptions if item.strip()]
|
descriptions = [item.strip() for item in icon_descriptions if item.strip()]
|
||||||
if not descriptions:
|
if not descriptions:
|
||||||
raise GenarrativeApiError("icon_descriptions must contain at least one non-empty item")
|
raise GenarrativeApiError("icon_descriptions must contain at least one non-empty item")
|
||||||
slice_mode = normalize_optional_text(slice_mode)
|
|
||||||
if slice_mode not in ("connected-components", "grid"):
|
|
||||||
raise GenarrativeApiError(
|
|
||||||
"slice_mode must be declared explicitly as 'connected-components' or 'grid'; the API has no default"
|
|
||||||
)
|
|
||||||
grid_x = fields.get("gridX")
|
|
||||||
grid_y = fields.get("gridY")
|
|
||||||
if slice_mode == "grid":
|
|
||||||
if grid_x is None or grid_y is None:
|
|
||||||
raise GenarrativeApiError("slice_mode='grid' requires both gridX and gridY")
|
|
||||||
elif grid_x is not None or grid_y is not None:
|
|
||||||
raise GenarrativeApiError(
|
|
||||||
"slice_mode='connected-components' must not carry gridX/gridY"
|
|
||||||
)
|
|
||||||
label = fields.get("assetLabel", "图标图集")
|
label = fields.get("assetLabel", "图标图集")
|
||||||
self._apply_canvas_session_fields(fields, label, 1024, 1024)
|
self._apply_canvas_session_fields(fields, label, 1024, 1024)
|
||||||
fields.setdefault("screenColor", "auto")
|
fields.setdefault("screenColor", "auto")
|
||||||
@@ -650,7 +635,6 @@ class GenarrativeExternalClient:
|
|||||||
**fields,
|
**fields,
|
||||||
"referenceId": reference_id,
|
"referenceId": reference_id,
|
||||||
"iconDescriptions": descriptions,
|
"iconDescriptions": descriptions,
|
||||||
"sliceMode": slice_mode,
|
|
||||||
},
|
},
|
||||||
idempotency_key=idempotency_key,
|
idempotency_key=idempotency_key,
|
||||||
)
|
)
|
||||||
@@ -895,7 +879,6 @@ def _self_test() -> None:
|
|||||||
client.generate_icon_spritesheet(
|
client.generate_icon_spritesheet(
|
||||||
"editor-resource-spec",
|
"editor-resource-spec",
|
||||||
["蛇头向上", "蛇身直线", "转角", "尾部", "四类食物"],
|
["蛇头向上", "蛇身直线", "转角", "尾部", "四类食物"],
|
||||||
"connected-components",
|
|
||||||
canvasSession=session,
|
canvasSession=session,
|
||||||
assetLabel="贪吃蛇透明图集",
|
assetLabel="贪吃蛇透明图集",
|
||||||
referenceId="must-not-override-explicit-reference",
|
referenceId="must-not-override-explicit-reference",
|
||||||
@@ -904,7 +887,6 @@ def _self_test() -> None:
|
|||||||
assert calls[0]["path"] == "/api/external/v1/editor/icon-spritesheets/generations"
|
assert calls[0]["path"] == "/api/external/v1/editor/icon-spritesheets/generations"
|
||||||
assert calls[0]["body"]["referenceId"] == "editor-resource-spec"
|
assert calls[0]["body"]["referenceId"] == "editor-resource-spec"
|
||||||
assert calls[0]["body"]["screenColor"] == "auto"
|
assert calls[0]["body"]["screenColor"] == "auto"
|
||||||
assert calls[0]["body"]["sliceMode"] == "connected-components"
|
|
||||||
assert calls[0]["body"]["iconDescriptions"][0] == "蛇头向上"
|
assert calls[0]["body"]["iconDescriptions"][0] == "蛇头向上"
|
||||||
assert calls[1]["path"] == "/api/external/v1/generations/task-operation-demo"
|
assert calls[1]["path"] == "/api/external/v1/generations/task-operation-demo"
|
||||||
print("self-test ok")
|
print("self-test ok")
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
---
|
|
||||||
name: spec-driven-development
|
|
||||||
description: 在 Genarrative 中处理跨模块功能、公开 API/DTO、SpacetimeDB schema、AGC/Runtime 或复杂 UI 状态链路时,按主规范、里程碑规范、单里程碑实现计划和验收证据推进;小型局部修复不触发。
|
|
||||||
license: MIT
|
|
||||||
metadata:
|
|
||||||
codex:
|
|
||||||
tags: [SDD, 规范驱动开发, 主规范, 里程碑, 验收]
|
|
||||||
---
|
|
||||||
|
|
||||||
# SDD 规范驱动开发
|
|
||||||
|
|
||||||
本 skill 把 Genarrative 的复杂任务路由到规范先行、单里程碑交付的工作流。权威规则和模板分别见:
|
|
||||||
|
|
||||||
- `docs/【协作规范】规范驱动开发工作流-2026-09-12.md`
|
|
||||||
- `docs/project-memory/shared-memory/【模板】规范驱动开发主规范与里程碑模板-2026-09-12.md`
|
|
||||||
|
|
||||||
## 触发条件
|
|
||||||
|
|
||||||
使用本 skill 的任务包括:
|
|
||||||
|
|
||||||
- 跨前端、`api-server`、`platform-*`、`spacetime-client`、`spacetime-module` 或 `module-*` 的功能。
|
|
||||||
- `/api/external/v1`、共享 DTO、OpenAPI、SpacetimeDB schema、迁移或跨版本重放合同变化。
|
|
||||||
- AGC / DirectProject、Agent Runtime、工具白名单、审批、持久化恢复或资源工作流变化。
|
|
||||||
- 复杂 UI 状态链路、入口/页面生命周期变化,或需要多个独立验收面的功能。
|
|
||||||
|
|
||||||
文案、单文件局部修复、无行为变化重构和一次性诊断继续使用轻量流程;执行中一旦触及公开行为或跨模块合同,切换到本 skill。
|
|
||||||
|
|
||||||
## 执行要求
|
|
||||||
|
|
||||||
1. 检查工作树,读取当前专题、源码、测试、契约和历史决策;写清交付结果、验收判据和不做项。
|
|
||||||
2. 找到或更新唯一主规范。主规范描述行为合同、边界、非目标、兼容/迁移和证据,不绑定实现细节。
|
|
||||||
3. 在 `docs/project-memory/plans/` 创建一个或多个 `【里程碑】中文标题-YYYY-MM-DD.md`,填写 `Version`、`Status`、`Date`、`Parent Spec`、范围、依赖和验收标准;评审通过前不写业务代码。
|
|
||||||
4. 每次只选择一个已评审里程碑,创建对应的 `【实施计划】中文标题-YYYY-MM-DD.md`,明确修改边界、顺序、验证命令、风险和回滚点。
|
|
||||||
5. 发现行为需要变化时,严格按 `主规范 → 尚未实现的里程碑规范 → 当前实现计划 → 代码与测试` 更新。
|
|
||||||
6. 完成一个里程碑后,提供主规范/里程碑逐条对照、自动化验证、必要运行时 smoke、边界验证和未验证项;未验收不得推进下一个里程碑。
|
|
||||||
7. 全部验收通过后,将持久结论合并回主规范,删除已完成的临时计划,并检查文档、契约、测试和提交边界一致。
|
|
||||||
|
|
||||||
## 约束
|
|
||||||
|
|
||||||
- 里程碑和实现计划是开发期协调文件,完成或取消后删除;阶段编号和临时名称不得进入产品代码、用户文档、测试名称或提交标题。
|
|
||||||
- 活动计划可以提交以便团队同步,但不得把一次性实现步骤写进长期规范。
|
|
||||||
- 继续遵守现有 API、SpacetimeDB、AGC、编码和中文文档约束;本 skill 不替代专题门禁。
|
|
||||||
- 文档任务至少运行 `npm run check:doc-index`、`npm run check:encoding` 和 `git diff --check`;代码任务再运行范围匹配的测试、类型检查、schema/OpenAPI 或运行时 smoke。
|
|
||||||
@@ -4,5 +4,3 @@
|
|||||||
src/components/AdventurePanel.tsx
|
src/components/AdventurePanel.tsx
|
||||||
src/data/customWorldCharacterLoadout.ts
|
src/data/customWorldCharacterLoadout.ts
|
||||||
dist_check_monster_position/**
|
dist_check_monster_position/**
|
||||||
# 固定上游UTF-8测试刻意包含U+FFFD;upstream-integrity.test.mjs逐字节验证来源hash。
|
|
||||||
apps/ai-game-creator-shell/src-tauri/vendor/codex-utils-path-uri/src/api_path_string_tests.rs
|
|
||||||
|
|||||||
+5
-23
@@ -1,8 +1,8 @@
|
|||||||
# Server-side OpenAI-compatible LLM endpoint base URL.
|
# Server-side OpenAI-compatible LLM endpoint base URL.
|
||||||
LLM_BASE_URL="https://api.tiantoken.com/v1"
|
LLM_BASE_URL="https://api.vectorengine.cn/v1"
|
||||||
|
|
||||||
# Server-side API key used by the local Vite proxy.
|
# Server-side API key used by the local Vite proxy.
|
||||||
# Recommended: set `LLM_API_KEY` locally, or use `TIANTOKEN_API_KEY`
|
# Recommended: set `LLM_API_KEY` locally, or use `VECTOR_ENGINE_API_KEY`
|
||||||
# through the Rust api-server proxy.
|
# through the Rust api-server proxy.
|
||||||
# Legacy compatibility: `VITE_LLM_API_KEY` is still supported by the proxy,
|
# Legacy compatibility: `VITE_LLM_API_KEY` is still supported by the proxy,
|
||||||
# but it should not be relied on by browser code.
|
# but it should not be relied on by browser code.
|
||||||
@@ -122,7 +122,7 @@ WECHAT_MINIPROGRAM_MESSAGE_ENCODING_AES_KEY=""
|
|||||||
# Model name for chat completions.
|
# Model name for chat completions.
|
||||||
VITE_LLM_MODEL="gpt-5.4-mini"
|
VITE_LLM_MODEL="gpt-5.4-mini"
|
||||||
GENARRATIVE_LLM_PROVIDER="openai-compatible"
|
GENARRATIVE_LLM_PROVIDER="openai-compatible"
|
||||||
GENARRATIVE_LLM_BASE_URL="https://api.tiantoken.com/v1"
|
GENARRATIVE_LLM_BASE_URL="https://api.vectorengine.cn/v1"
|
||||||
GENARRATIVE_LLM_API_KEY=""
|
GENARRATIVE_LLM_API_KEY=""
|
||||||
GENARRATIVE_LLM_MODEL="gpt-5.4-mini"
|
GENARRATIVE_LLM_MODEL="gpt-5.4-mini"
|
||||||
|
|
||||||
@@ -130,15 +130,10 @@ GENARRATIVE_LLM_MODEL="gpt-5.4-mini"
|
|||||||
DASHSCOPE_BASE_URL="https://dashscope.aliyuncs.com/api/v1"
|
DASHSCOPE_BASE_URL="https://dashscope.aliyuncs.com/api/v1"
|
||||||
DASHSCOPE_API_KEY="YOUR_DASHSCOPE_API_KEY"
|
DASHSCOPE_API_KEY="YOUR_DASHSCOPE_API_KEY"
|
||||||
|
|
||||||
# Tiantoken LLM and GPT-image-2 / Gemini image generation config.
|
# VectorEngine LLM and GPT-image-2 / Gemini image generation config.
|
||||||
TIANTOKEN_BASE_URL="https://api.tiantoken.com"
|
|
||||||
TIANTOKEN_API_KEY=""
|
|
||||||
TIANTOKEN_IMAGE_REQUEST_TIMEOUT_MS="1000000"
|
|
||||||
|
|
||||||
# VectorEngine is retained for Suno audio generation only.
|
|
||||||
VECTOR_ENGINE_BASE_URL="https://api.vectorengine.cn"
|
VECTOR_ENGINE_BASE_URL="https://api.vectorengine.cn"
|
||||||
VECTOR_ENGINE_API_KEY=""
|
VECTOR_ENGINE_API_KEY=""
|
||||||
VECTOR_ENGINE_AUDIO_REQUEST_TIMEOUT_MS="180000"
|
VECTOR_ENGINE_IMAGE_REQUEST_TIMEOUT_MS="1000000"
|
||||||
|
|
||||||
# ElevenLabs editor sound-effect generation is server-side only.
|
# ElevenLabs editor sound-effect generation is server-side only.
|
||||||
ELEVENLABS_BASE_URL="https://api.elevenlabs.io"
|
ELEVENLABS_BASE_URL="https://api.elevenlabs.io"
|
||||||
@@ -158,15 +153,6 @@ ALIYUN_OSS_POST_EXPIRE_SECONDS="600"
|
|||||||
ALIYUN_OSS_POST_MAX_SIZE_BYTES="20971520"
|
ALIYUN_OSS_POST_MAX_SIZE_BYTES="20971520"
|
||||||
ALIYUN_OSS_SUCCESS_ACTION_STATUS="200"
|
ALIYUN_OSS_SUCCESS_ACTION_STATUS="200"
|
||||||
|
|
||||||
# AGC 项目定时快照上传目标。对象只落在服务端私有前缀
|
|
||||||
# `agc/project-snapshots/v1/{user}/{project}/` 下,客户端直传票据不覆盖该前缀。
|
|
||||||
# bucket 与凭据可以与资源 bucket 分离;凭据未设置时回退使用 ALIYUN_OSS_ACCESS_KEY_*,
|
|
||||||
# 但 bucket / endpoint 默认指向 AGC 发行 bucket,需要该凭据具备目标 bucket 的 PutObject 权限。
|
|
||||||
GENARRATIVE_AGC_PROJECT_SNAPSHOT_OSS_BUCKET="agc-dev"
|
|
||||||
GENARRATIVE_AGC_PROJECT_SNAPSHOT_OSS_ENDPOINT="oss-rg-china-mainland.aliyuncs.com"
|
|
||||||
GENARRATIVE_AGC_PROJECT_SNAPSHOT_OSS_ACCESS_KEY_ID=""
|
|
||||||
GENARRATIVE_AGC_PROJECT_SNAPSHOT_OSS_ACCESS_KEY_SECRET=""
|
|
||||||
|
|
||||||
# BgFilter 受限资源 worker。父 api-server / external-generation-worker 与唯一的
|
# BgFilter 受限资源 worker。父 api-server / external-generation-worker 与唯一的
|
||||||
# `GENARRATIVE_PROCESS_ROLE=bgfilter-worker` 进程必须使用同一个内部 Token。
|
# `GENARRATIVE_PROCESS_ROLE=bgfilter-worker` 进程必须使用同一个内部 Token。
|
||||||
# `npm run dev` 与 `npm run dev:api-server` 都会自动带起并验活唯一 worker,不要再开第二个终端重复启动。
|
# `npm run dev` 与 `npm run dev:api-server` 都会自动带起并验活唯一 worker,不要再开第二个终端重复启动。
|
||||||
@@ -235,10 +221,6 @@ VITE_DEBUG_MODE=""
|
|||||||
# This is read by api-server and exposed through /api/runtime/frontend-config.
|
# This is read by api-server and exposed through /api/runtime/frontend-config.
|
||||||
GENARRATIVE_ENABLE_IMAGE_EDITOR_AGENT_SIDEBAR="false"
|
GENARRATIVE_ENABLE_IMAGE_EDITOR_AGENT_SIDEBAR="false"
|
||||||
|
|
||||||
# 官网客户端下载检测渠道:dev、release 或自定义渠道;修改后重启 API 服务。
|
|
||||||
# Windows/macOS 是系统维度,不填写 dev-win/dev-mac。
|
|
||||||
GENARRATIVE_CLIENT_DOWNLOAD_CHANNEL="dev"
|
|
||||||
|
|
||||||
# Optional: official VikingDB credentials for regenerating build-tag similarities
|
# Optional: official VikingDB credentials for regenerating build-tag similarities
|
||||||
# with the Python embedding script. The script auto-loads `.env.local` and uses
|
# with the Python embedding script. The script auto-loads `.env.local` and uses
|
||||||
# the fixed `bge-large-zh` embedding model.
|
# the fixed `bge-large-zh` embedding model.
|
||||||
|
|||||||
@@ -164,7 +164,6 @@ module.exports = {
|
|||||||
'server-rs/target-*',
|
'server-rs/target-*',
|
||||||
'apps/desktop-shell/src-tauri/target',
|
'apps/desktop-shell/src-tauri/target',
|
||||||
'apps/ai-game-creator-shell/src/features/ui-editor/types/**',
|
'apps/ai-game-creator-shell/src/features/ui-editor/types/**',
|
||||||
'apps/ai-game-creator-shell/src/features/project-workspace/generated/**',
|
|
||||||
'target',
|
'target',
|
||||||
'src/main.tsx',
|
'src/main.tsx',
|
||||||
'src/App.tsx',
|
'src/App.tsx',
|
||||||
@@ -213,8 +212,6 @@ module.exports = {
|
|||||||
'!src/services/clipboard.test.ts',
|
'!src/services/clipboard.test.ts',
|
||||||
'!src/services/frontendRuntimeConfigService.ts',
|
'!src/services/frontendRuntimeConfigService.ts',
|
||||||
'!src/services/frontendRuntimeConfigService.test.ts',
|
'!src/services/frontendRuntimeConfigService.test.ts',
|
||||||
'!src/services/gameDistributionClient.ts',
|
|
||||||
'!src/services/gameDistributionClient.test.ts',
|
|
||||||
'!src/services/sseStream.ts',
|
'!src/services/sseStream.ts',
|
||||||
'!src/services/sseStream.test.ts',
|
'!src/services/sseStream.test.ts',
|
||||||
'src/AdventurePanel.tsx',
|
'src/AdventurePanel.tsx',
|
||||||
|
|||||||
@@ -23,6 +23,3 @@
|
|||||||
*.meta text
|
*.meta text
|
||||||
*.anim text
|
*.anim text
|
||||||
*.controller text
|
*.controller text
|
||||||
|
|
||||||
# Rust ts-rs 生成的共享契约:保留在仓库中供 TS 消费,但不作为手写源文件统计。
|
|
||||||
packages/shared/src/contracts/generated/** linguist-generated=true
|
|
||||||
|
|||||||
+53
-401
File diff suppressed because it is too large
Load Diff
-16
@@ -40,23 +40,7 @@ temp*build*/
|
|||||||
/apps/ai-game-creator-shell/src-tauri/resources/codex/win-x64/codex-path/
|
/apps/ai-game-creator-shell/src-tauri/resources/codex/win-x64/codex-path/
|
||||||
/apps/ai-game-creator-shell/src-tauri/resources/codex/win-x64/codex-resources/
|
/apps/ai-game-creator-shell/src-tauri/resources/codex/win-x64/codex-resources/
|
||||||
/apps/ai-game-creator-shell/src-tauri/resources/codex/win-x64/codex-package.json
|
/apps/ai-game-creator-shell/src-tauri/resources/codex/win-x64/codex-package.json
|
||||||
/apps/ai-game-creator-shell/src-tauri/resources/plugins/
|
|
||||||
/apps/ai-game-creator-shell/src-tauri/resources/codex/mac-native/bin/
|
|
||||||
/apps/ai-game-creator-shell/src-tauri/resources/codex/mac-native/codex-path/
|
|
||||||
/apps/ai-game-creator-shell/src-tauri/resources/codex/mac-native/codex-resources/
|
|
||||||
/apps/ai-game-creator-shell/src-tauri/resources/codex/mac-native/codex-package.json
|
|
||||||
/apps/ai-game-creator-shell/src-tauri/resources/codex/mac-native/manifest.json
|
|
||||||
/apps/ai-game-creator-shell/src-tauri/resources/codex/mac-native/NOTICE.md
|
|
||||||
/apps/ai-game-creator-shell/src-tauri/resources/codex/mac-native/darwin-arm64/
|
|
||||||
/apps/ai-game-creator-shell/src-tauri/resources/codex/mac-native/darwin-x64/
|
|
||||||
/plugins/agc-cocos-editor/native/payload/
|
|
||||||
/plugins/agc-unity-editor/dotnet/**/bin/
|
|
||||||
/plugins/agc-unity-editor/dotnet/**/obj/
|
|
||||||
/plugins/agc-unity-editor/dotnet/publish/
|
|
||||||
/plugins/agc-unity-editor/dotnet/native-build/
|
|
||||||
/apps/ai-game-creator-shell/logs/
|
/apps/ai-game-creator-shell/logs/
|
||||||
/apps/ai-game-creator-shell/src-tauri/resources/node-runtime/
|
|
||||||
/apps/ai-game-creator-shell/src-tauri/resources/node-runtime-staging-*/
|
|
||||||
/apps/ai-game-creator-shell/.llm-drafts/
|
/apps/ai-game-creator-shell/.llm-drafts/
|
||||||
/apps/ai-game-creator-shell/game-creator.config.local.json
|
/apps/ai-game-creator-shell/game-creator.config.local.json
|
||||||
/apps/mobile-shell/.expo/
|
/apps/mobile-shell/.expo/
|
||||||
|
|||||||
@@ -1,4 +1 @@
|
|||||||
# Git 在链接工作树里执行 Hook 时会注入 GIT_DIR 等仓库定位变量,优先级高于 cwd;
|
|
||||||
# 子进程(npm、lint-staged、测试夹具)会继承它们并写到真实仓库,故在入口统一清除。
|
|
||||||
unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_COMMON_DIR GIT_PREFIX GIT_CONFIG_PARAMETERS GIT_CEILING_DIRECTORIES
|
|
||||||
npm run format:staged
|
npm run format:staged
|
||||||
|
|||||||
@@ -1,4 +1 @@
|
|||||||
# Git 在链接工作树里执行 Hook 时会注入 GIT_DIR 等仓库定位变量,优先级高于 cwd;
|
|
||||||
# 钩子链(npm → check:repository-ci → 测试夹具)会继承它们并写到真实仓库,故在入口统一清除。
|
|
||||||
unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_COMMON_DIR GIT_PREFIX GIT_CONFIG_PARAMETERS GIT_CEILING_DIRECTORIES
|
|
||||||
npm run check:pre-push-master -- "$@"
|
npm run check:pre-push-master -- "$@"
|
||||||
|
|||||||
+1
-10
@@ -1,14 +1,5 @@
|
|||||||
{
|
{
|
||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
"semi": true,
|
"semi": true,
|
||||||
"trailingComma": "all",
|
"trailingComma": "all"
|
||||||
"overrides": [
|
|
||||||
{
|
|
||||||
"files": "packages/shared/src/contracts/generated/**/*.ts",
|
|
||||||
"options": {
|
|
||||||
"printWidth": 1000,
|
|
||||||
"singleQuote": false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,40 +4,42 @@
|
|||||||
|
|
||||||
- 本文件只保留 Agent 进入仓库后必须立即遵守的最高优先级规则;完整执行细则见 [`docs/【协作规范】Agent工作入口与执行准则-2026-06-22.md`](docs/【协作规范】Agent工作入口与执行准则-2026-06-22.md)。
|
- 本文件只保留 Agent 进入仓库后必须立即遵守的最高优先级规则;完整执行细则见 [`docs/【协作规范】Agent工作入口与执行准则-2026-06-22.md`](docs/【协作规范】Agent工作入口与执行准则-2026-06-22.md)。
|
||||||
- 团队级长期项目记忆位于 [`docs/project-memory/`](docs/project-memory/),供 3 名开发人员和各自本地 Agent 通过 Git 同步。
|
- 团队级长期项目记忆位于 [`docs/project-memory/`](docs/project-memory/),供 3 名开发人员和各自本地 Agent 通过 Git 同步。
|
||||||
- [`.codex/`](.codex/) 保存仓库级 Codex 工具资源,例如 skills、plugins、hooks 和配置模板;长期项目知识写入 `docs/` 与 `docs/project-memory/`。
|
- [`.codex/`](.codex/) 只保存仓库级 Codex 工具资源,例如 skills、plugins、hooks 和配置模板;长期项目知识不要写入 `.codex/`。
|
||||||
- 若 `docs/project-memory/shared-memory/` 与当前代码或最新 `docs/` 冲突,以代码和最新 `docs/` 为准,并同步修正过期共享记忆。
|
- 若 `docs/project-memory/shared-memory/` 与当前代码或最新 `docs/` 冲突,以代码和最新 `docs/` 为准,并同步修正过期共享记忆。
|
||||||
|
|
||||||
## 开始任务前
|
## 开始任务前
|
||||||
|
|
||||||
- 先写清一句话交付结果、验收判据和修改范围,再按“必须项 / 风险项 / 可选项”排序;优先完成修改、定向验证和边界检查组成的最小闭环。设置时间盒和检查点,新增发现只有在影响交付判据时才扩大范围,其余记录为后续事项。
|
- 先写清一句话交付结果、验收判据和不做项,再按“必须项 / 风险项 / 可选项”排序;优先完成修改、定向验证和边界检查组成的最小闭环。设置时间盒和检查点,新增发现只有在影响交付判据时才扩大范围,否则记录为后续事项;工具探测、历史整理或验证便利不能自行改变任务目标。
|
||||||
- Agent 可见内容直接描述当前任务、输入和成功条件,细节按调用需要提供。
|
|
||||||
- 简单自包含任务可以直接执行;复杂开发、跨模块修改、后端 / UI / 文档体系调整前,按顺序读取:
|
- 简单自包含任务可以直接执行;复杂开发、跨模块修改、后端 / UI / 文档体系调整前,按顺序读取:
|
||||||
1. 本文件。
|
1. 本文件。
|
||||||
2. [`docs/【协作规范】Agent工作入口与执行准则-2026-06-22.md`](docs/【协作规范】Agent工作入口与执行准则-2026-06-22.md)。
|
2. [`docs/【协作规范】Agent工作入口与执行准则-2026-06-22.md`](docs/【协作规范】Agent工作入口与执行准则-2026-06-22.md)。
|
||||||
3. [`docs/project-memory/README.md`](docs/project-memory/README.md)、[`project-overview.md`](docs/project-memory/shared-memory/project-overview.md)、[`team-conventions.md`](docs/project-memory/shared-memory/team-conventions.md)、[`development-workflow.md`](docs/project-memory/shared-memory/development-workflow.md)。
|
3. [`docs/project-memory/README.md`](docs/project-memory/README.md)、[`project-overview.md`](docs/project-memory/shared-memory/project-overview.md)、[`team-conventions.md`](docs/project-memory/shared-memory/team-conventions.md)、[`development-workflow.md`](docs/project-memory/shared-memory/development-workflow.md)。
|
||||||
4. 与任务相关的 [`decision-log.md`](docs/project-memory/shared-memory/decision-log.md)、[`pitfalls.md`](docs/project-memory/shared-memory/pitfalls.md)、[`docs/README.md`](docs/README.md) 和当前专题文档。
|
4. 与任务相关的 [`decision-log.md`](docs/project-memory/shared-memory/decision-log.md)、[`pitfalls.md`](docs/project-memory/shared-memory/pitfalls.md)、[`docs/README.md`](docs/README.md) 和当前专题文档。
|
||||||
- 落地工程修改前,先确认是否已有足够具体的 PRD、技术方案或当前融合文档;文档仍存在编码级歧义时,先补文档再编码。
|
- 落地工程修改前,先确认是否已有足够具体的 PRD、技术方案或当前融合文档;文档仍存在编码级歧义时,先补文档再编码。
|
||||||
- 跨模块功能、公开 API/DTO、SpacetimeDB schema、AGC/Runtime 或复杂 UI 状态链路必须按 [`docs/【协作规范】规范驱动开发工作流-2026-09-12.md`](docs/【协作规范】规范驱动开发工作流-2026-09-12.md) 先完成主规范、里程碑规范和单里程碑实现计划;评审与验收门禁未通过前不得进入下一里程碑。局部修复、文案和无行为变化重构继续走轻量流程。
|
|
||||||
- 本仓库的本地 RAG 位于 [`scripts/rag/`](scripts/rag/);RAG 只作为候选上下文,不替代打开源文件核对。默认不安装 RAG 运行时依赖,需要启用时必须先询问用户,并只安装到 gitignored 的 `.rag/runtime/`。
|
- 本仓库的本地 RAG 位于 [`scripts/rag/`](scripts/rag/);RAG 只作为候选上下文,不替代打开源文件核对。默认不安装 RAG 运行时依赖,需要启用时必须先询问用户,并只安装到 gitignored 的 `.rag/runtime/`。
|
||||||
|
|
||||||
## 绝对约束
|
## 绝对约束
|
||||||
|
|
||||||
- 禁止提交个人 `~/.codex` 配置、`.env`、API Key、Token、Cookie、会话记录、认证文件、本地私密路径、构建产物、日志、缓存和数据库 dump。
|
- 禁止提交个人 `~/.codex` 配置、`.env`、API Key、Token、Cookie、会话记录、认证文件、本地私密路径、构建产物、日志、缓存和数据库 dump。
|
||||||
- 不要在 `.gitignore` 中新增 `.env.local`。
|
- 不要在 `.gitignore` 中新增 `.env.local`。
|
||||||
- 现有中文文案、注释、剧情和文档保持中文;看到乱码时先确认真实编码并恢复正确中文。
|
- 不要擅自把现有中文文案、注释、剧情或文档改写成英文;看到中文乱码时先确认真实编码,不要沿用乱码或用英文替换。
|
||||||
- 修改包含中文的文件时优先局部补丁;修改后优先运行仓库编码检查。
|
- 修改包含中文的文件时优先局部补丁,避免整文件重写;修改后优先运行仓库编码检查。
|
||||||
- 新增 Markdown 文档文件名必须以分类标签开头,格式为 `【标签名】中文标题-日期.md`。
|
- 后续新增 Markdown 文档文件名必须以分类标签开头,格式为 `【标签名】中文标题-日期.md`;历史文档不要求批量重命名,除非本次任务明确涉及。
|
||||||
- 工程修改要同步更新对应 `docs/` 文档;产生长期有效的架构约定、接口变化、排障经验、开发流程或协作规则时,同步更新 `docs/project-memory/shared-memory/`。
|
- 工程修改要同步更新对应 `docs/` 文档;产生长期有效的架构约定、接口变化、排障经验、开发流程或协作规则时,同步更新 `docs/project-memory/shared-memory/`。
|
||||||
- 默认保持系统简洁:优先复用、修改、扩展现有系统、页面和公共组件。
|
- 默认保持系统简洁:优先复用、修改、扩展现有系统、页面和公共组件,不新建平行系统或平行页面。
|
||||||
- UI 开发优先复用现有公共组件;发现跨页面或跨端重复的视觉/交互模式时,先抽取到 `packages/shared` 共享组件库并让现有页面迁移使用。共享组件承载通用表现与交互,领域规则、后端副作用和正式业务状态由后端负责。
|
- UI 开发优先复用现有公共组件;发现跨页面或跨端重复的视觉/交互模式时,先抽取到 `packages/shared` 共享组件库并让现有页面迁移使用,禁止在业务页复制同类 UI。共享组件只承载通用表现与交互,不下沉领域规则、后端副作用或正式业务状态。
|
||||||
- 对已明确退役且不存在现役调用方、公开契约、持久化数据、活跃实例或迁移要求的对象,直接清理实现、专属测试和说明,将权威文档更新为当前状态;历史由 Git 保存。
|
- 对已明确退役且不存在现役调用方、公开契约、持久化数据、活跃实例或迁移要求的对象,坚持“四不写”:
|
||||||
- 公开 API、持久化数据、SpacetimeDB schema、跨版本重放、活跃实例和正式迁移按实际需求保留最小、白名单化的兼容,并配套契约或迁移测试;迁移完成后同步删除兼容实现与对应测试。
|
1. 不写历史兼容代码。
|
||||||
- UI 面板优先呈现任务内容与操作,说明按当前操作需要提供;移动端优先,同时保证网页端可正常显示和操作。
|
2. 不写用于维持退役行为的防御性兼容测试。
|
||||||
- 点击按钮弹出的独立面板使用弹窗、抽屉、popover 或页面级 portal。
|
3. 不写仅说明其曾存在或已删除的墓碑注释。
|
||||||
|
4. 不写仅记录其已删除的墓碑文档;直接将权威文档更新为当前状态。
|
||||||
|
- 公开 API、持久化数据、SpacetimeDB schema、跨版本重放、活跃实例和正式迁移不适用“四不写”;必要兼容应最小化、白名单化并配套契约或迁移测试,迁移完成后同步删除兼容实现与对应测试。
|
||||||
|
- UI 面板中不要默认写功能说明、规则描述或开发解释文案;移动端优先,同时保证网页端可正常显示和操作。
|
||||||
|
- 点击按钮弹出独立面板的设计,不要实现成在当前面板下面追加内容。
|
||||||
|
|
||||||
## 任务路由
|
## 任务路由
|
||||||
|
|
||||||
- Issue 使用自托管 Gitea;优先用 Gitea UI/API 或 `tea` CLI。默认 triage 标签:`needs-triage`、`needs-info`、`ready-for-agent`、`ready-for-human`、`wontfix`。
|
- Issue 使用自托管 Gitea;优先用 Gitea UI/API 或 `tea` CLI,不使用 GitHub `gh` 或 GitLab `glab`,除非仓库已迁移。默认 triage 标签:`needs-triage`、`needs-info`、`ready-for-agent`、`ready-for-human`、`wontfix`。
|
||||||
- 需要仓库级 Codex skills/plugins 时,再读取 [`.codex/README.md`](.codex/README.md)。
|
- 需要仓库级 Codex skills/plugins 时,再读取 [`.codex/README.md`](.codex/README.md)。
|
||||||
- 涉及 AI 游戏创作独立 App、多智能体 Runtime、本地项目产物或本地 HTTP 预览时,先读取 [`docs/technical/【技术方案】AI游戏创作智能体App实施计划-2026-06-24.md`](docs/technical/【技术方案】AI游戏创作智能体App实施计划-2026-06-24.md)。
|
- 涉及 AI 游戏创作独立 App、多智能体 Runtime、本地项目产物或本地 HTTP 预览时,先读取 [`docs/technical/【技术方案】AI游戏创作智能体App实施计划-2026-06-24.md`](docs/technical/【技术方案】AI游戏创作智能体App实施计划-2026-06-24.md)。
|
||||||
- 新增、补齐、迁移或重构玩法入口、玩法类型、创作工作台、生成页、结果页、发布、运行态、作品架、广场或公开 read model 前,必须读取并按 [`genarrative-play-type-integration`](.codex/skills/genarrative-play-type-integration/SKILL.md) 执行。
|
- 新增、补齐、迁移或重构玩法入口、玩法类型、创作工作台、生成页、结果页、发布、运行态、作品架、广场或公开 read model 前,必须读取并按 [`genarrative-play-type-integration`](.codex/skills/genarrative-play-type-integration/SKILL.md) 执行。
|
||||||
@@ -47,10 +49,10 @@
|
|||||||
## 后端红线
|
## 后端红线
|
||||||
|
|
||||||
- 后端最新技术约束以 [`docs/【后端架构】server-rs与SpacetimeDB数据契约-2026-05-15.md`](docs/【后端架构】server-rs与SpacetimeDB数据契约-2026-05-15.md) 为准。
|
- 后端最新技术约束以 [`docs/【后端架构】server-rs与SpacetimeDB数据契约-2026-05-15.md`](docs/【后端架构】server-rs与SpacetimeDB数据契约-2026-05-15.md) 为准。
|
||||||
- 后端路线固定为 `server-rs + Axum + SpacetimeDB`。
|
- 后端路线固定为 `server-rs + Axum + SpacetimeDB`;旧 `server-node`、Express、PostgreSQL、Go 服务端、`maincloud` / `Maincloud` / `MAINCLOUD` 只作为历史残留,不作为兼容目标。
|
||||||
- DDD 分层边界按总纲执行:领域规则沉到 `module-*`,SpacetimeDB 表和事务编排留在 `spacetime-module`,后端访问 SpacetimeDB 统一经 `spacetime-client` facade,HTTP/SSE/BFF 留在 `api-server`,外部副作用留在 `platform-*`,前后端 DTO 留在 `shared-contracts`。
|
- DDD 分层边界按总纲执行:领域规则沉到 `module-*`,SpacetimeDB 表和事务编排留在 `spacetime-module`,后端访问 SpacetimeDB 统一经 `spacetime-client` facade,HTTP/SSE/BFF 留在 `api-server`,外部副作用留在 `platform-*`,前后端 DTO 留在 `shared-contracts`。
|
||||||
- 前端负责表现、交互和临时 UI 状态;正式业务状态与规则以后端投影和后端 API 为准。
|
- 前端只做表现、交互和临时 UI 状态,不承接正式业务真相,不绕过后端投影或后端 API 直接实现业务规则。
|
||||||
- 契约、路由、DTO 去留和 breaking change 以当前后端架构文档、`server-rs/crates/api-server/src/app.rs`、`shared-contracts` 和 `packages/shared` 为准。
|
- 契约、路由、DTO 去留和 breaking change 以当前后端架构文档、`server-rs/crates/api-server/src/app.rs`、`shared-contracts` 和 `packages/shared` 为准;不得在前端、`api-server` 或临时兼容层中重新发明旧接口。
|
||||||
- 凡修改 `/api/external/v1` 的路由、HTTP 方法、请求 / 响应 DTO、请求头、状态码、鉴权或异步语义,必须在同一次变更中同步更新权威契约 [`docs/openapi/genarrative-external-v1.openapi.json`](docs/openapi/genarrative-external-v1.openapi.json) 及对应契约测试;Rust 实现与 OpenAPI 未保持一致时任务不得视为完成。
|
- 凡修改 `/api/external/v1` 的路由、HTTP 方法、请求 / 响应 DTO、请求头、状态码、鉴权或异步语义,必须在同一次变更中同步更新权威契约 [`docs/openapi/genarrative-external-v1.openapi.json`](docs/openapi/genarrative-external-v1.openapi.json) 及对应契约测试;Rust 实现与 OpenAPI 未保持一致时任务不得视为完成。
|
||||||
- SpacetimeDB 已有表新增字段时,字段必须放在 Rust 表结构体最后,并设置明确默认值;需要删除、改名、重排或改类型时,必须先询问用户并确认迁移计划。
|
- SpacetimeDB 已有表新增字段时,字段必须放在 Rust 表结构体最后,并设置明确默认值;需要删除、改名、重排或改类型时,必须先询问用户并确认迁移计划。
|
||||||
- 修改 SpacetimeDB schema 后必须同步 `migration.rs`、表目录和生成绑定,并运行 `npm run check:spacetime-schema`。
|
- 修改 SpacetimeDB schema 后必须同步 `migration.rs`、表目录和生成绑定,并运行 `npm run check:spacetime-schema`。
|
||||||
|
|||||||
-65
@@ -172,64 +172,6 @@ _Avoid_: 多步骤向导、完整规则编辑器、拖拽编辑器
|
|||||||
Bark Battle 平台作品闭环按契约与领域规则、后端存储/API、最小前端纵切、投影体验、收口验证的顺序推进。
|
Bark Battle 平台作品闭环按契约与领域规则、后端存储/API、最小前端纵切、投影体验、收口验证的顺序推进。
|
||||||
_Avoid_: mock 先行堆积、前后端各自发散、先做排行榜 UI
|
_Avoid_: mock 先行堆积、前后端各自发散、先做排行榜 UI
|
||||||
|
|
||||||
## 项目开发对话(DirectProject)
|
|
||||||
|
|
||||||
**DirectProject 专属聊天模块**:
|
|
||||||
AGC 普通项目聊天的独立容器,拥有 DirectProject 的聊天状态、运行态订阅、历史读取、发送队列、附件和中止交互,并把聊天投影交给专属表现层渲染;它不承接 Supervisor、Design Agent 或 Planning V2 的运行态。
|
|
||||||
_Avoid_: 把 DirectProject 作为项目总控聊天的一个布尔分支、把四种 Agent 会话抽象成同一事实源
|
|
||||||
|
|
||||||
**项目工作台布局**:
|
|
||||||
承载本地项目的资源工作区、项目级工具和独立聊天产品路径的外层界面;布局拥有跨面板的账户/钱包入口,聊天模块只负责项目对话,不嵌套账户展示。
|
|
||||||
_Avoid_: 把钱包入口塞进聊天设置、让聊天组件拥有工作台级账户状态
|
|
||||||
|
|
||||||
**项目对话历史**:
|
|
||||||
AGC 本地项目内 Codex 原始对话条目的持久集合,是聊天展示、工具卡片和线程恢复注入的唯一持久事实源。
|
|
||||||
_Avoid_: 会话缓存、展示态历史、按 UI 需要另存的对话副本
|
|
||||||
|
|
||||||
**运行态事件**:
|
|
||||||
Thread Manager 向订阅者推送的当前回合原始事件流,只服务运行期间与短期断线恢复,不替代项目对话历史。
|
|
||||||
_Avoid_: 进度通知、快照轮询、第二套历史
|
|
||||||
|
|
||||||
**聊天投影**:
|
|
||||||
把项目对话历史条目与运行态事件转换成消息气泡和工具卡片的读取期转换;不持久化,也不构成事实源。
|
|
||||||
_Avoid_: 投影缓存文件、已脱敏卡片库、第二套 reducer
|
|
||||||
|
|
||||||
**引用候选**:
|
|
||||||
输入区可以命中的对象集合(`@` 素材、`$` Skill),由宿主按种类注入;输入区不判断候选属于哪一类。
|
|
||||||
_Avoid_: 输入区自己读项目清单或应用目录、把候选取值写死在组件里
|
|
||||||
|
|
||||||
**引用 provider**:
|
|
||||||
一种引用种类向输入区提供的全部能力:触发符、候选、身份解析与正文文本形态;每种引用各一份,宿主按需选择性注入。
|
|
||||||
_Avoid_: 一个总装对象决定所有种类、输入区按种类分叉、provider 之间互相知道对方
|
|
||||||
|
|
||||||
**静默 provider**:
|
|
||||||
不提供候选、只负责已有引用身份与文本形态的 provider;附件与运行画面区域属于这一类,只能由外部插入或草稿回填进入正文。
|
|
||||||
_Avoid_: 给附件或运行画面区域造候选、为它们保留输入区内的专门分支
|
|
||||||
|
|
||||||
**引用文本语法**:
|
|
||||||
引用在正文文本里的形态(`@显示名` / `$名称` / `@附件名`)及其反解析;出站与解析必须同一口径,token 前后各留一个空白。
|
|
||||||
_Avoid_: 出站与解析各写一套、在空白边界之外再补兼容别名、让解析依赖具体种类的字段
|
|
||||||
|
|
||||||
**引用候选枚举**:
|
|
||||||
一种引用种类当前就绪的全部可引用对象,与候选菜单共用同一份集合;区别只在没有查询过滤和条数上限。
|
|
||||||
_Avoid_: 拿菜单查询当枚举、为粘贴另建一份候选清单
|
|
||||||
|
|
||||||
**引用粘贴解析**:
|
|
||||||
把粘贴进来的纯文本按引用文本语法反解析回正文引用;只有身份唯一且逐字确认的 token 才成为引用,其余按原文保留。
|
|
||||||
_Avoid_: 猜文件名或路径、为不确定的 token 挑一个候选、改写用户粘贴的其余文字
|
|
||||||
|
|
||||||
**引用输入区**:
|
|
||||||
只负责编辑与渲染引用的共享输入组件;候选、身份解析与文本语法都来自注入的 provider,它不持有项目清单、不访问后端。
|
|
||||||
_Avoid_: 输入区自己拉 Skill 目录、把选择器面板塞在输入区内部
|
|
||||||
|
|
||||||
**引用选择器**:
|
|
||||||
宿主渲染的独立面板,自己拿数据与筛选状态,确认后把选中的引用交给输入区的插入缝。
|
|
||||||
_Avoid_: 输入区自带面板、每个宿主各画一个、绕开插入缝另开第二条通道
|
|
||||||
|
|
||||||
**附件芯片**:
|
|
||||||
聊天附件在正文里的唯一表示;附件导入成功即以芯片进入正文,正文之外不存在第二份附件状态。
|
|
||||||
_Avoid_: 待发送附件列表与正文芯片并存、提交时再拼一遍附件
|
|
||||||
|
|
||||||
## Relationships
|
## Relationships
|
||||||
|
|
||||||
- 一个 **汪汪声浪大作战** 单局包含多个 **有效声浪触发**。
|
- 一个 **汪汪声浪大作战** 单局包含多个 **有效声浪触发**。
|
||||||
@@ -245,11 +187,6 @@ _Avoid_: 待发送附件列表与正文芯片并存、提交时再拼一遍附
|
|||||||
- **个人历史成绩** 由最近记录列表和个人最佳摘要组成,只允许本人查看;排行榜只公开入榜胜利成绩。
|
- **个人历史成绩** 由最近记录列表和个人最佳摘要组成,只允许本人查看;排行榜只公开入榜胜利成绩。
|
||||||
- **正式作品入口闭环** 必须覆盖创作入口、作品详情 CTA、广场/作品卡片、我的作品/个人作品架、稳定作品 ID runtime 路由和 `work_play_start` 埋点。
|
- **正式作品入口闭环** 必须覆盖创作入口、作品详情 CTA、广场/作品卡片、我的作品/个人作品架、稳定作品 ID runtime 路由和 `work_play_start` 埋点。
|
||||||
- **Phase 2 实施顺序** 固定为:契约与领域规则 → SpacetimeDB 表/reducer 与 api-server BFF → 最小前端纵切 → 投影与列表体验 → 收口验证。
|
- **Phase 2 实施顺序** 固定为:契约与领域规则 → SpacetimeDB 表/reducer 与 api-server BFF → 最小前端纵切 → 投影与列表体验 → 收口验证。
|
||||||
- **引用输入区** 由宿主注入的若干 **引用 provider** 组成;**引用候选** 与 **引用文本语法** 都来自 provider,输入区不判断引用种类。
|
|
||||||
- **引用选择器** 不属于 **引用输入区**:它自己拿数据,确认后只通过输入区的插入缝交付引用。
|
|
||||||
- 只有带触发符的 **引用 provider** 会产生候选;**静默 provider** 没有触发符,只能由外部插入或草稿回填进入正文。
|
|
||||||
- **引用粘贴解析** 与出站显示是同一条 **引用文本语法** 的两端;**静默 provider** 的 token(`@附件名` / `@区域标签`)没有候选,因此粘贴时不重建。
|
|
||||||
- **附件芯片** 是本轮附件的唯一事实源;附件导入失败时不产生芯片。
|
|
||||||
|
|
||||||
## Example dialogue
|
## Example dialogue
|
||||||
|
|
||||||
@@ -269,5 +206,3 @@ _Avoid_: 待发送附件列表与正文芯片并存、提交时再拼一遍附
|
|||||||
- “入口闭环”曾可能只指内部 demo 或单个详情 CTA;已解析为 **正式作品入口闭环**,不新增独立专区或活动页。
|
- “入口闭环”曾可能只指内部 demo 或单个详情 CTA;已解析为 **正式作品入口闭环**,不新增独立专区或活动页。
|
||||||
- “创作编辑”曾可能指多步骤向导或完整编辑器;已解析为 **轻配置编辑流程**,使用单页表单 + 预览卡片完成保存草稿、发布和发布后跳转作品详情。
|
- “创作编辑”曾可能指多步骤向导或完整编辑器;已解析为 **轻配置编辑流程**,使用单页表单 + 预览卡片完成保存草稿、发布和发布后跳转作品详情。
|
||||||
- “实施顺序”曾可能按 UI 或功能并行发散;已解析为契约/领域规则先行,再做后端存储/API,随后打通最小前端纵切,最后补投影体验与收口验证。
|
- “实施顺序”曾可能按 UI 或功能并行发散;已解析为契约/领域规则先行,再做后端存储/API,随后打通最小前端纵切,最后补投影体验与收口验证。
|
||||||
- “回合进度事件”曾同时指 Direct turn update 与 Thread Manager 运行态事件;已解析为 AGC 项目开发对话只保留 **运行态事件**。
|
|
||||||
- “哪些消息可显示”曾可能由后端历史分页判断;已解析为可见性判断属于 **聊天投影**,后端只按原始条目分页,前端负责跳过不可显示条目并推进分页锚点。
|
|
||||||
|
|||||||
@@ -3,18 +3,12 @@ import { afterEach, expect, test, vi } from 'vitest';
|
|||||||
import {
|
import {
|
||||||
createAdminAccount,
|
createAdminAccount,
|
||||||
executeAdminRechargeRefund,
|
executeAdminRechargeRefund,
|
||||||
getAdminAgcTemplates,
|
|
||||||
getAdminFeatureGateConfig,
|
getAdminFeatureGateConfig,
|
||||||
getAdminUserDetail,
|
getAdminUserDetail,
|
||||||
importAdminAgcTemplates,
|
|
||||||
listAdminGameDistributionReviews,
|
|
||||||
listAdminRechargeOrders,
|
listAdminRechargeOrders,
|
||||||
reconcileAdminUserConsumption,
|
reconcileAdminUserConsumption,
|
||||||
resolveAdminRechargeRefundManualReview,
|
resolveAdminRechargeRefundManualReview,
|
||||||
reviewAdminGameDistributionVersion,
|
|
||||||
suspendAdminGameDistributionGame,
|
|
||||||
updateAdminAccount,
|
updateAdminAccount,
|
||||||
updateAdminAgcTemplate,
|
|
||||||
uploadAdminEditorShowcaseCampaignImage,
|
uploadAdminEditorShowcaseCampaignImage,
|
||||||
upsertAdminFeatureGateConfig,
|
upsertAdminFeatureGateConfig,
|
||||||
upsertProfileWalletConfig,
|
upsertProfileWalletConfig,
|
||||||
@@ -24,93 +18,6 @@ afterEach(() => {
|
|||||||
vi.unstubAllGlobals();
|
vi.unstubAllGlobals();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('模板管理读取和更新复用认证封装,提交 revision 和封面但不提交 ZIP 或版本', async () => {
|
|
||||||
const library = { revision: 'revision-new', writable: true, templates: [] };
|
|
||||||
const fetchMock = vi.fn().mockImplementation(
|
|
||||||
async () =>
|
|
||||||
new Response(JSON.stringify({ ok: true, data: library }), {
|
|
||||||
status: 200,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
vi.stubGlobal('fetch', fetchMock);
|
|
||||||
const controller = new AbortController();
|
|
||||||
expect(await getAdminAgcTemplates('admin-token', controller.signal)).toEqual(
|
|
||||||
library,
|
|
||||||
);
|
|
||||||
const update = {
|
|
||||||
expectedRevision: 'revision-old',
|
|
||||||
title: '空白模板',
|
|
||||||
summary: '简介',
|
|
||||||
tags: ['2D'],
|
|
||||||
enabled: true,
|
|
||||||
cover: { contentType: 'image/png', dataBase64: 'aW1hZ2U=' },
|
|
||||||
};
|
|
||||||
expect(
|
|
||||||
await updateAdminAgcTemplate('admin-token', 'template/1', update),
|
|
||||||
).toEqual(library);
|
|
||||||
expect(fetchMock.mock.calls[0]).toEqual([
|
|
||||||
'/admin/api/agc-templates',
|
|
||||||
expect.objectContaining({
|
|
||||||
method: 'GET',
|
|
||||||
signal: controller.signal,
|
|
||||||
headers: expect.objectContaining({ Authorization: 'Bearer admin-token' }),
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
expect(fetchMock.mock.calls[1]).toEqual([
|
|
||||||
'/admin/api/agc-templates/template%2F1',
|
|
||||||
expect.objectContaining({
|
|
||||||
method: 'PUT',
|
|
||||||
headers: expect.objectContaining({
|
|
||||||
Authorization: 'Bearer admin-token',
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
}),
|
|
||||||
body: JSON.stringify(update),
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('模板批量导入走 multipart,不预设 JSON Content-Type', async () => {
|
|
||||||
const imported = {
|
|
||||||
revision: 'rev-2',
|
|
||||||
writable: true,
|
|
||||||
templates: [],
|
|
||||||
imported: [
|
|
||||||
{
|
|
||||||
id: 'alpha',
|
|
||||||
templateVersion: '0.1.0',
|
|
||||||
zipSizeBytes: 4,
|
|
||||||
zipSha256: 'a'.repeat(64),
|
|
||||||
reusedObjects: false,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const fetchMock = vi.fn().mockImplementation(
|
|
||||||
async () =>
|
|
||||||
new Response(JSON.stringify({ ok: true, data: imported }), {
|
|
||||||
status: 200,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
vi.stubGlobal('fetch', fetchMock);
|
|
||||||
|
|
||||||
const form = new FormData();
|
|
||||||
form.append(
|
|
||||||
'manifest',
|
|
||||||
JSON.stringify({ expectedRevision: 'rev-1', templates: [] }),
|
|
||||||
);
|
|
||||||
form.append(
|
|
||||||
'zip_0',
|
|
||||||
new File([new Uint8Array([1])], 'alpha.zip', { type: 'application/zip' }),
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(await importAdminAgcTemplates('admin-token', form)).toEqual(imported);
|
|
||||||
const [url, init] = fetchMock.mock.calls[0]!;
|
|
||||||
expect(url).toBe('/admin/api/agc-templates/import');
|
|
||||||
expect(init.method).toBe('POST');
|
|
||||||
expect(init.body).toBe(form);
|
|
||||||
expect(init.headers).not.toHaveProperty('Content-Type');
|
|
||||||
expect(init.headers.Authorization).toBe('Bearer admin-token');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('后台账号创建和更新同时携带 Tab 与独立操作权限', async () => {
|
test('后台账号创建和更新同时携带 Tab 与独立操作权限', async () => {
|
||||||
const fetchMock = vi.fn().mockImplementation(() =>
|
const fetchMock = vi.fn().mockImplementation(() =>
|
||||||
Promise.resolve(
|
Promise.resolve(
|
||||||
@@ -457,134 +364,3 @@ test('退款人工复核使用独立 resolve 管理员路由', async () => {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('游戏审核列表与审核动作使用约定的 URL、方法和幂等键', async () => {
|
|
||||||
const fetchMock = vi.fn().mockImplementation(() =>
|
|
||||||
Promise.resolve(
|
|
||||||
new Response(JSON.stringify({ entries: [], nextCursor: null }), {
|
|
||||||
status: 200,
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
vi.stubGlobal('fetch', fetchMock);
|
|
||||||
|
|
||||||
await listAdminGameDistributionReviews('admin-token');
|
|
||||||
await reviewAdminGameDistributionVersion(
|
|
||||||
'admin-token',
|
|
||||||
'gamever/1',
|
|
||||||
'game-review-key-1',
|
|
||||||
{
|
|
||||||
decision: 'approve',
|
|
||||||
expectedPublicationRevision: 3,
|
|
||||||
entryUrl: 'https://games.example.test/releases/game_1/index.html',
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(fetchMock.mock.calls[0]?.[0]).toBe(
|
|
||||||
'/admin/api/game-distribution/reviews?limit=48',
|
|
||||||
);
|
|
||||||
expect(fetchMock.mock.calls[1]?.[0]).toBe(
|
|
||||||
'/admin/api/game-distribution/versions/gamever%2F1/review',
|
|
||||||
);
|
|
||||||
expect(fetchMock.mock.calls[1]?.[1]).toEqual(
|
|
||||||
expect.objectContaining({
|
|
||||||
method: 'POST',
|
|
||||||
headers: expect.objectContaining({
|
|
||||||
Authorization: 'Bearer admin-token',
|
|
||||||
'Idempotency-Key': 'game-review-key-1',
|
|
||||||
}),
|
|
||||||
body: JSON.stringify({
|
|
||||||
decision: 'approve',
|
|
||||||
expectedPublicationRevision: 3,
|
|
||||||
entryUrl: 'https://games.example.test/releases/game_1/index.html',
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('安全下架请求携带公开修订号、原因与幂等键', async () => {
|
|
||||||
const fetchMock = vi.fn().mockImplementation(() =>
|
|
||||||
Promise.resolve(
|
|
||||||
new Response(JSON.stringify({ game: {}, replayed: false }), {
|
|
||||||
status: 200,
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
vi.stubGlobal('fetch', fetchMock);
|
|
||||||
|
|
||||||
await suspendAdminGameDistributionGame(
|
|
||||||
'admin-token',
|
|
||||||
'game/1',
|
|
||||||
'game-suspend-key-1',
|
|
||||||
{ expectedPublicationRevision: 7, reason: '版权投诉' },
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(fetchMock.mock.calls[0]?.[0]).toBe(
|
|
||||||
'/admin/api/game-distribution/games/game%2F1/suspend',
|
|
||||||
);
|
|
||||||
expect(fetchMock.mock.calls[0]?.[1]).toEqual(
|
|
||||||
expect.objectContaining({
|
|
||||||
method: 'POST',
|
|
||||||
headers: expect.objectContaining({
|
|
||||||
Authorization: 'Bearer admin-token',
|
|
||||||
'Idempotency-Key': 'game-suspend-key-1',
|
|
||||||
}),
|
|
||||||
body: JSON.stringify({
|
|
||||||
expectedPublicationRevision: 7,
|
|
||||||
reason: '版权投诉',
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(() =>
|
|
||||||
suspendAdminGameDistributionGame('admin-token', ' ', 'key', {
|
|
||||||
expectedPublicationRevision: 1,
|
|
||||||
}),
|
|
||||||
).toThrow('缺少游戏 ID');
|
|
||||||
expect(() =>
|
|
||||||
suspendAdminGameDistributionGame('admin-token', 'game-1', ' ', {
|
|
||||||
expectedPublicationRevision: 1,
|
|
||||||
}),
|
|
||||||
).toThrow('下架幂等键必须是 1 到 128 个字符');
|
|
||||||
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('游戏审核拒绝请求携带理由,空幂等键在本地失败关闭', async () => {
|
|
||||||
const fetchMock = vi.fn().mockImplementation(() =>
|
|
||||||
Promise.resolve(
|
|
||||||
new Response(JSON.stringify({ version: {}, replayed: false }), {
|
|
||||||
status: 200,
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
vi.stubGlobal('fetch', fetchMock);
|
|
||||||
|
|
||||||
await reviewAdminGameDistributionVersion(
|
|
||||||
'admin-token',
|
|
||||||
'version-1',
|
|
||||||
'game-review-key-2',
|
|
||||||
{
|
|
||||||
decision: 'reject',
|
|
||||||
expectedPublicationRevision: 0,
|
|
||||||
reviewReason: '运行时报错',
|
|
||||||
},
|
|
||||||
);
|
|
||||||
expect(fetchMock.mock.calls[0]?.[1]).toEqual(
|
|
||||||
expect.objectContaining({
|
|
||||||
body: JSON.stringify({
|
|
||||||
decision: 'reject',
|
|
||||||
expectedPublicationRevision: 0,
|
|
||||||
reviewReason: '运行时报错',
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(() =>
|
|
||||||
reviewAdminGameDistributionVersion('admin-token', 'version-1', ' ', {
|
|
||||||
decision: 'reject',
|
|
||||||
expectedPublicationRevision: 0,
|
|
||||||
reviewReason: 'x',
|
|
||||||
}),
|
|
||||||
).toThrow('审核幂等键必须是 1 到 128 个字符');
|
|
||||||
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import type {
|
import type {
|
||||||
AdminAccountListResponse,
|
AdminAccountListResponse,
|
||||||
AdminAgcTemplateLibraryResponse,
|
|
||||||
AdminConfirmEditorShowcaseCampaignImageUploadRequest,
|
AdminConfirmEditorShowcaseCampaignImageUploadRequest,
|
||||||
AdminCreateAccountRequest,
|
AdminCreateAccountRequest,
|
||||||
AdminCreateAccountResponse,
|
AdminCreateAccountResponse,
|
||||||
@@ -30,16 +29,9 @@ import type {
|
|||||||
AdminExternalApiKeyListQuery,
|
AdminExternalApiKeyListQuery,
|
||||||
AdminExternalApiKeyListResponse,
|
AdminExternalApiKeyListResponse,
|
||||||
AdminFeatureGateConfigResponse,
|
AdminFeatureGateConfigResponse,
|
||||||
AdminGameDistributionReviewListResponse,
|
|
||||||
AdminGameDistributionReviewRequest,
|
|
||||||
AdminGameDistributionReviewResponse,
|
|
||||||
AdminImportAgcTemplatesResponse,
|
|
||||||
AdminLoginResponse,
|
AdminLoginResponse,
|
||||||
AdminMeResponse,
|
AdminMeResponse,
|
||||||
AdminOverviewResponse,
|
AdminOverviewResponse,
|
||||||
AdminProjectSnapshotChannelsResponse,
|
|
||||||
AdminProjectSnapshotListQuery,
|
|
||||||
AdminProjectSnapshotListResponse,
|
|
||||||
AdminRechargeOrderListQuery,
|
AdminRechargeOrderListQuery,
|
||||||
AdminRechargeOrderListResponse,
|
AdminRechargeOrderListResponse,
|
||||||
AdminRechargeRefundActionResponse,
|
AdminRechargeRefundActionResponse,
|
||||||
@@ -53,7 +45,6 @@ import type {
|
|||||||
AdminTrackingEventListResponse,
|
AdminTrackingEventListResponse,
|
||||||
AdminUpdateAccountRequest,
|
AdminUpdateAccountRequest,
|
||||||
AdminUpdateAccountResponse,
|
AdminUpdateAccountResponse,
|
||||||
AdminUpdateAgcTemplateRequest,
|
|
||||||
AdminUploadedEditorShowcaseCampaignImage,
|
AdminUploadedEditorShowcaseCampaignImage,
|
||||||
AdminUpsertEditorShowcaseCampaignRequest,
|
AdminUpsertEditorShowcaseCampaignRequest,
|
||||||
AdminUpsertFeatureGateConfigRequest,
|
AdminUpsertFeatureGateConfigRequest,
|
||||||
@@ -92,8 +83,6 @@ interface AdminRequestOptions {
|
|||||||
method?: string;
|
method?: string;
|
||||||
token?: string;
|
token?: string;
|
||||||
body?: unknown;
|
body?: unknown;
|
||||||
/** multipart 表单:交给浏览器自己带 boundary,不能预设 Content-Type。 */
|
|
||||||
formData?: FormData;
|
|
||||||
headers?: Record<string, string>;
|
headers?: Record<string, string>;
|
||||||
signal?: AbortSignal;
|
signal?: AbortSignal;
|
||||||
}
|
}
|
||||||
@@ -181,8 +170,6 @@ export async function request<T>(
|
|||||||
if (typeof options.body !== 'undefined') {
|
if (typeof options.body !== 'undefined') {
|
||||||
headers['Content-Type'] = 'application/json';
|
headers['Content-Type'] = 'application/json';
|
||||||
init.body = JSON.stringify(options.body);
|
init.body = JSON.stringify(options.body);
|
||||||
} else if (options.formData) {
|
|
||||||
init.body = options.formData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await fetch(buildRequestUrl(path), init);
|
const response = await fetch(buildRequestUrl(path), init);
|
||||||
@@ -211,107 +198,6 @@ export function listAdminAccounts(token: string) {
|
|||||||
return request<AdminAccountListResponse>('/admin/api/accounts', { token });
|
return request<AdminAccountListResponse>('/admin/api/accounts', { token });
|
||||||
}
|
}
|
||||||
|
|
||||||
export function listAdminProjectSnapshots(
|
|
||||||
token: string,
|
|
||||||
query: AdminProjectSnapshotListQuery = {},
|
|
||||||
signal?: AbortSignal,
|
|
||||||
) {
|
|
||||||
const params = new URLSearchParams();
|
|
||||||
if (query.cursor) params.set('cursor', query.cursor);
|
|
||||||
if (query.channel) params.set('channel', query.channel);
|
|
||||||
params.set('limit', String(query.limit ?? 20));
|
|
||||||
return request<AdminProjectSnapshotListResponse>(
|
|
||||||
`/admin/api/project-snapshots?${params.toString()}`,
|
|
||||||
{ token, signal },
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getAdminProjectSnapshotChannels(
|
|
||||||
token: string,
|
|
||||||
signal?: AbortSignal,
|
|
||||||
) {
|
|
||||||
return request<AdminProjectSnapshotChannelsResponse>(
|
|
||||||
'/admin/api/project-snapshots/channels',
|
|
||||||
{ token, signal },
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function downloadAdminProjectSnapshot(
|
|
||||||
token: string,
|
|
||||||
channel: string,
|
|
||||||
userId: string,
|
|
||||||
projectId: string,
|
|
||||||
signal?: AbortSignal,
|
|
||||||
) {
|
|
||||||
const params = new URLSearchParams();
|
|
||||||
if (channel) params.set('channel', channel);
|
|
||||||
const query = params.toString();
|
|
||||||
const path = `/admin/api/project-snapshots/${encodeURIComponent(userId)}/${encodeURIComponent(projectId)}/download${query ? `?${query}` : ''}`;
|
|
||||||
const response = await fetch(buildRequestUrl(path), {
|
|
||||||
headers: {
|
|
||||||
Authorization: `Bearer ${token.trim()}`,
|
|
||||||
Accept: 'application/zip',
|
|
||||||
[API_RESPONSE_ENVELOPE_HEADER]: 'v1',
|
|
||||||
},
|
|
||||||
signal,
|
|
||||||
});
|
|
||||||
if (!response.ok) {
|
|
||||||
const responseText = await response.text();
|
|
||||||
throw buildAdminApiError(
|
|
||||||
response,
|
|
||||||
parseJsonResponse(responseText),
|
|
||||||
responseText,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
const contentType = response.headers
|
|
||||||
.get('content-type')
|
|
||||||
?.split(';')[0]
|
|
||||||
?.trim()
|
|
||||||
.toLowerCase();
|
|
||||||
if (contentType !== 'application/zip') {
|
|
||||||
await response.body?.cancel();
|
|
||||||
throw new AdminApiError({
|
|
||||||
message: '下载失败:服务端未返回 ZIP 工程文件',
|
|
||||||
status: response.status,
|
|
||||||
code: 'INVALID_PROJECT_ARCHIVE_RESPONSE',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
blob: await response.blob(),
|
|
||||||
filename: projectArchiveFilename(
|
|
||||||
response.headers.get('content-disposition'),
|
|
||||||
),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function projectArchiveFilename(contentDisposition: string | null): string {
|
|
||||||
const extended = contentDisposition?.match(
|
|
||||||
/(?:^|;)\s*filename\*=UTF-8'[^']*'([^;]+)/i,
|
|
||||||
);
|
|
||||||
const ordinary = contentDisposition?.match(
|
|
||||||
/(?:^|;)\s*filename=(?:"((?:[^"\\]|\\.)*)"|([^;]+))/i,
|
|
||||||
);
|
|
||||||
let filename =
|
|
||||||
ordinary?.[1]?.replace(/\\(.)/g, '$1') ?? ordinary?.[2]?.trim() ?? '';
|
|
||||||
if (extended?.[1]) {
|
|
||||||
try {
|
|
||||||
filename = decodeURIComponent(extended[1].trim());
|
|
||||||
} catch {
|
|
||||||
// 非法扩展编码继续使用普通文件名。
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const safeName = Array.from(filename, (character) => {
|
|
||||||
const code = character.charCodeAt(0);
|
|
||||||
return code < 32 || code === 127 ? '_' : character;
|
|
||||||
})
|
|
||||||
.join('')
|
|
||||||
.replace(/[<>:"/\\|?*]/g, '_')
|
|
||||||
.trim()
|
|
||||||
.replace(/[. ]+$/, '');
|
|
||||||
if (!safeName || safeName.length > 240) return 'project.zip';
|
|
||||||
return /\.zip$/i.test(safeName) ? safeName : `${safeName}.zip`;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createAdminAccount(
|
export function createAdminAccount(
|
||||||
token: string,
|
token: string,
|
||||||
payload: AdminCreateAccountRequest,
|
payload: AdminCreateAccountRequest,
|
||||||
@@ -1202,102 +1088,3 @@ export function saveAgcModelCatalog(
|
|||||||
{ token, method: 'PUT', body },
|
{ token, method: 'PUT', body },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function listAdminGameDistributionReviews(token: string, limit = 48) {
|
|
||||||
const normalizedLimit = Number.isFinite(limit)
|
|
||||||
? Math.min(Math.max(Math.trunc(limit), 1), 48)
|
|
||||||
: 48;
|
|
||||||
return request<AdminGameDistributionReviewListResponse>(
|
|
||||||
`/admin/api/game-distribution/reviews?limit=${normalizedLimit}`,
|
|
||||||
{ token },
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 审核游戏发行版本。幂等键由调用方生成并在同一次提交内复用,避免重复点击产生
|
|
||||||
* 两条审核结论。
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* 安全下架整个游戏。管理员下架同样要求 CAS 修订号与幂等键,避免并发审核互相覆盖。
|
|
||||||
*/
|
|
||||||
export function suspendAdminGameDistributionGame(
|
|
||||||
token: string,
|
|
||||||
gameId: string,
|
|
||||||
idempotencyKey: string,
|
|
||||||
payload: import('./adminApiTypes').AdminGameDistributionSuspendRequest,
|
|
||||||
) {
|
|
||||||
const normalizedGameId = gameId.trim();
|
|
||||||
const normalizedKey = idempotencyKey.trim();
|
|
||||||
if (!normalizedGameId) {
|
|
||||||
throw new Error('缺少游戏 ID');
|
|
||||||
}
|
|
||||||
if (!normalizedKey || normalizedKey.length > 128) {
|
|
||||||
throw new Error('下架幂等键必须是 1 到 128 个字符');
|
|
||||||
}
|
|
||||||
return request<
|
|
||||||
import('./adminApiTypes').AdminGameDistributionSuspendResponse
|
|
||||||
>(
|
|
||||||
`/admin/api/game-distribution/games/${encodeURIComponent(normalizedGameId)}/suspend`,
|
|
||||||
{
|
|
||||||
method: 'POST',
|
|
||||||
token,
|
|
||||||
headers: { 'Idempotency-Key': normalizedKey },
|
|
||||||
body: payload,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function reviewAdminGameDistributionVersion(
|
|
||||||
token: string,
|
|
||||||
versionId: string,
|
|
||||||
idempotencyKey: string,
|
|
||||||
payload: AdminGameDistributionReviewRequest,
|
|
||||||
) {
|
|
||||||
const normalizedVersionId = versionId.trim();
|
|
||||||
const normalizedKey = idempotencyKey.trim();
|
|
||||||
if (!normalizedVersionId) {
|
|
||||||
throw new Error('缺少发行版本 ID');
|
|
||||||
}
|
|
||||||
if (!normalizedKey || normalizedKey.length > 128) {
|
|
||||||
throw new Error('审核幂等键必须是 1 到 128 个字符');
|
|
||||||
}
|
|
||||||
return request<AdminGameDistributionReviewResponse>(
|
|
||||||
`/admin/api/game-distribution/versions/${encodeURIComponent(normalizedVersionId)}/review`,
|
|
||||||
{
|
|
||||||
method: 'POST',
|
|
||||||
token,
|
|
||||||
headers: { 'Idempotency-Key': normalizedKey },
|
|
||||||
body: payload,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getAdminAgcTemplates(token: string, signal?: AbortSignal) {
|
|
||||||
return request<AdminAgcTemplateLibraryResponse>('/admin/api/agc-templates', {
|
|
||||||
token,
|
|
||||||
signal,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function updateAdminAgcTemplate(
|
|
||||||
token: string,
|
|
||||||
id: string,
|
|
||||||
body: AdminUpdateAgcTemplateRequest,
|
|
||||||
) {
|
|
||||||
return request<AdminAgcTemplateLibraryResponse>(
|
|
||||||
`/admin/api/agc-templates/${encodeURIComponent(id)}`,
|
|
||||||
{ token, method: 'PUT', body },
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 批量导入模板包:manifest 与 zip_N / cover_N 一起走 multipart,一批一次锁一次提交。 */
|
|
||||||
export function importAdminAgcTemplates(token: string, formData: FormData) {
|
|
||||||
return request<AdminImportAgcTemplatesResponse>(
|
|
||||||
'/admin/api/agc-templates/import',
|
|
||||||
{
|
|
||||||
token,
|
|
||||||
method: 'POST',
|
|
||||||
formData,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -96,36 +96,6 @@ export interface AdminMeResponse {
|
|||||||
admin: AdminSessionPayload;
|
admin: AdminSessionPayload;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AdminProjectSnapshotEntry {
|
|
||||||
userId: string;
|
|
||||||
projectId: string;
|
|
||||||
projectName: string | null;
|
|
||||||
syncRevision: number;
|
|
||||||
syncedAtMs: number;
|
|
||||||
fileCount: number;
|
|
||||||
totalBytes: number;
|
|
||||||
status: 'ready' | 'partial' | 'unverified';
|
|
||||||
channel: string;
|
|
||||||
authorDisplayName?: string | null;
|
|
||||||
authorPublicUserCode?: string | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminProjectSnapshotListQuery {
|
|
||||||
cursor?: string | null;
|
|
||||||
limit?: number;
|
|
||||||
channel?: string | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminProjectSnapshotListResponse {
|
|
||||||
items: AdminProjectSnapshotEntry[];
|
|
||||||
nextCursor: string | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminProjectSnapshotChannelsResponse {
|
|
||||||
defaultChannel: string;
|
|
||||||
channels: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminErrorReportEntry {
|
export interface AdminErrorReportEntry {
|
||||||
batchId: string;
|
batchId: string;
|
||||||
eventCount: number;
|
eventCount: number;
|
||||||
@@ -153,8 +123,6 @@ export interface AdminErrorReportListResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface AdminErrorReportDetail extends AdminErrorReportEntry {
|
export interface AdminErrorReportDetail extends AdminErrorReportEntry {
|
||||||
firstFingerprint?: string;
|
|
||||||
firstSource?: string;
|
|
||||||
note?: string;
|
note?: string;
|
||||||
events: Array<Record<string, unknown>>;
|
events: Array<Record<string, unknown>>;
|
||||||
logNames: string[];
|
logNames: string[];
|
||||||
@@ -1042,112 +1010,3 @@ export interface AdminAgcModelCatalog {
|
|||||||
defaultModelId: string;
|
defaultModelId: string;
|
||||||
models: AdminAgcModel[];
|
models: AdminAgcModel[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AdminGameDistributionReviewEntry {
|
|
||||||
versionId: string;
|
|
||||||
gameId: string;
|
|
||||||
versionNumber: number;
|
|
||||||
packageSha256: string;
|
|
||||||
packageBytes: number;
|
|
||||||
status: string;
|
|
||||||
publicationRevision: number;
|
|
||||||
reviewReason: string | null;
|
|
||||||
createdAt: string;
|
|
||||||
updatedAt: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminGameDistributionReviewListResponse {
|
|
||||||
entries: AdminGameDistributionReviewEntry[];
|
|
||||||
nextCursor: string | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminGameDistributionReviewRequest {
|
|
||||||
decision: 'approve' | 'reject';
|
|
||||||
expectedPublicationRevision: number;
|
|
||||||
reviewReason?: string;
|
|
||||||
entryUrl?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminGameDistributionReviewResponse {
|
|
||||||
version: AdminGameDistributionReviewEntry;
|
|
||||||
replayed: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminGameDistributionSuspendRequest {
|
|
||||||
expectedPublicationRevision: number;
|
|
||||||
reason?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminGameDistributionSuspendResponse {
|
|
||||||
game: {
|
|
||||||
id: string;
|
|
||||||
title: string;
|
|
||||||
status: string;
|
|
||||||
publicationRevision: number;
|
|
||||||
};
|
|
||||||
replayed: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminAgcTemplatePayload {
|
|
||||||
id: string;
|
|
||||||
title: string;
|
|
||||||
summary: string;
|
|
||||||
tags: string[];
|
|
||||||
runtime: string;
|
|
||||||
engine: string;
|
|
||||||
engineVersion: string;
|
|
||||||
templateVersion: string;
|
|
||||||
enabled: boolean;
|
|
||||||
coverUrl: string;
|
|
||||||
zipSizeBytes: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminAgcTemplateLibraryResponse {
|
|
||||||
revision: string;
|
|
||||||
writable: boolean;
|
|
||||||
templates: AdminAgcTemplatePayload[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminUpdateAgcTemplateRequest {
|
|
||||||
expectedRevision: string;
|
|
||||||
title: string;
|
|
||||||
summary: string;
|
|
||||||
tags: string[];
|
|
||||||
enabled: boolean;
|
|
||||||
cover?: {
|
|
||||||
contentType: string;
|
|
||||||
dataBase64: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminImportAgcTemplateItemPayload {
|
|
||||||
id: string;
|
|
||||||
title: string;
|
|
||||||
summary: string;
|
|
||||||
tags: string[];
|
|
||||||
runtime: string;
|
|
||||||
engine: string;
|
|
||||||
engineVersion: string;
|
|
||||||
templateVersion: string;
|
|
||||||
entry: string;
|
|
||||||
zipField: string;
|
|
||||||
coverField: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminImportAgcTemplatesManifest {
|
|
||||||
expectedRevision: string;
|
|
||||||
templates: AdminImportAgcTemplateItemPayload[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminImportAgcTemplateResult {
|
|
||||||
id: string;
|
|
||||||
templateVersion: string;
|
|
||||||
zipSizeBytes: number;
|
|
||||||
zipSha256: string;
|
|
||||||
reusedObjects: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminImportAgcTemplatesResponse
|
|
||||||
extends AdminAgcTemplateLibraryResponse {
|
|
||||||
imported: AdminImportAgcTemplateResult[];
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,148 +0,0 @@
|
|||||||
import { afterEach, expect, test, vi } from 'vitest';
|
|
||||||
|
|
||||||
import {
|
|
||||||
downloadAdminProjectSnapshot,
|
|
||||||
getAdminProjectSnapshotChannels,
|
|
||||||
listAdminProjectSnapshots,
|
|
||||||
} from './adminApiClient';
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
vi.unstubAllGlobals();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('项目列表携带分页与后台授权,解析标准响应', async () => {
|
|
||||||
const payload = { items: [], nextCursor: 'next' };
|
|
||||||
const fetchMock = vi
|
|
||||||
.fn()
|
|
||||||
.mockResolvedValue(
|
|
||||||
new Response(JSON.stringify({ ok: true, data: payload })),
|
|
||||||
);
|
|
||||||
vi.stubGlobal('fetch', fetchMock);
|
|
||||||
const controller = new AbortController();
|
|
||||||
expect(
|
|
||||||
await listAdminProjectSnapshots(
|
|
||||||
'admin-token',
|
|
||||||
{ cursor: 'user/a+项目', limit: 20, channel: 'release' },
|
|
||||||
controller.signal,
|
|
||||||
),
|
|
||||||
).toEqual(payload);
|
|
||||||
expect(fetchMock).toHaveBeenCalledWith(
|
|
||||||
'/admin/api/project-snapshots?cursor=user%2Fa%2B%E9%A1%B9%E7%9B%AE&channel=release&limit=20',
|
|
||||||
expect.objectContaining({
|
|
||||||
headers: expect.objectContaining({ Authorization: 'Bearer admin-token' }),
|
|
||||||
signal: controller.signal,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('渠道列表按后台授权读取,解析本部署渠道', async () => {
|
|
||||||
const payload = { defaultChannel: 'release', channels: ['dev', 'release'] };
|
|
||||||
const fetchMock = vi
|
|
||||||
.fn()
|
|
||||||
.mockResolvedValue(
|
|
||||||
new Response(JSON.stringify({ ok: true, data: payload })),
|
|
||||||
);
|
|
||||||
vi.stubGlobal('fetch', fetchMock);
|
|
||||||
expect(await getAdminProjectSnapshotChannels('admin-token')).toEqual(payload);
|
|
||||||
expect(fetchMock).toHaveBeenCalledWith(
|
|
||||||
'/admin/api/project-snapshots/channels',
|
|
||||||
expect.objectContaining({
|
|
||||||
headers: expect.objectContaining({ Authorization: 'Bearer admin-token' }),
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('ZIP 下载以授权请求读取并优先保留中文附件名', async () => {
|
|
||||||
const fetchMock = vi.fn().mockResolvedValue(
|
|
||||||
new Response('PK\u0003\u0004', {
|
|
||||||
headers: {
|
|
||||||
'content-type': 'application/zip',
|
|
||||||
'content-disposition':
|
|
||||||
"attachment; filename=project.zip; filename*=UTF-8''%E4%B8%89%E6%B6%88-r2.zip",
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
vi.stubGlobal('fetch', fetchMock);
|
|
||||||
const controller = new AbortController();
|
|
||||||
const archive = await downloadAdminProjectSnapshot(
|
|
||||||
'admin-token',
|
|
||||||
'release',
|
|
||||||
'user/a',
|
|
||||||
'project/b',
|
|
||||||
controller.signal,
|
|
||||||
);
|
|
||||||
expect(archive.filename).toBe('三消-r2.zip');
|
|
||||||
expect(archive.blob.type).toBe('application/zip');
|
|
||||||
expect(fetchMock).toHaveBeenCalledWith(
|
|
||||||
'/admin/api/project-snapshots/user%2Fa/project%2Fb/download?channel=release',
|
|
||||||
expect.objectContaining({
|
|
||||||
headers: expect.objectContaining({
|
|
||||||
Authorization: 'Bearer admin-token',
|
|
||||||
Accept: 'application/zip',
|
|
||||||
}),
|
|
||||||
signal: controller.signal,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
test.each([
|
|
||||||
['attachment; filename="工程.zip"; filename*=UTF-8\'\'%broken', '工程.zip'],
|
|
||||||
['attachment; filename="../secret.zip"', '.._secret.zip'],
|
|
||||||
["attachment; filename*=UTF-8''unsafe%00%1F%7F.zip", 'unsafe___.zip'],
|
|
||||||
[null, 'project.zip'],
|
|
||||||
])('ZIP 附件名兼容安全回退 %s', async (header, expected) => {
|
|
||||||
const headers: Record<string, string> = { 'content-type': 'application/zip' };
|
|
||||||
// Response 的 Headers 只接受 Latin-1;真实 UTF-8 文件名使用 filename*。
|
|
||||||
if (header)
|
|
||||||
headers['content-disposition'] = header.replace('工程', 'project');
|
|
||||||
vi.stubGlobal(
|
|
||||||
'fetch',
|
|
||||||
vi.fn().mockResolvedValue(new Response('PK', { headers })),
|
|
||||||
);
|
|
||||||
expect(
|
|
||||||
(await downloadAdminProjectSnapshot('token', 'release', 'user', 'project'))
|
|
||||||
.filename,
|
|
||||||
).toBe(expected.replace('工程', 'project'));
|
|
||||||
});
|
|
||||||
|
|
||||||
test.each([401, 403, 409, 500])(
|
|
||||||
'下载 HTTP %s 保留后台错误,不返回 ZIP',
|
|
||||||
async (status) => {
|
|
||||||
vi.stubGlobal(
|
|
||||||
'fetch',
|
|
||||||
vi.fn().mockResolvedValue(
|
|
||||||
new Response(
|
|
||||||
JSON.stringify({
|
|
||||||
ok: false,
|
|
||||||
error: { code: 'SNAPSHOT_FAILURE', message: '工程尚未同步完成' },
|
|
||||||
}),
|
|
||||||
{
|
|
||||||
status,
|
|
||||||
headers: { 'content-type': 'application/json' },
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
await expect(
|
|
||||||
downloadAdminProjectSnapshot('token', 'release', 'user', 'project'),
|
|
||||||
).rejects.toMatchObject({
|
|
||||||
status,
|
|
||||||
code: 'SNAPSHOT_FAILURE',
|
|
||||||
message: '工程尚未同步完成',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
test('200 JSON 或 HTML 不能被保存为成功 ZIP', async () => {
|
|
||||||
vi.stubGlobal(
|
|
||||||
'fetch',
|
|
||||||
vi.fn().mockResolvedValue(
|
|
||||||
new Response('{"ok":false}', {
|
|
||||||
headers: { 'content-type': 'application/json' },
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
await expect(
|
|
||||||
downloadAdminProjectSnapshot('token', 'release', 'user', 'project'),
|
|
||||||
).rejects.toMatchObject({ code: 'INVALID_PROJECT_ARCHIVE_RESPONSE' });
|
|
||||||
});
|
|
||||||
@@ -19,7 +19,6 @@ import {
|
|||||||
} from '../auth/adminAuthStore';
|
} from '../auth/adminAuthStore';
|
||||||
import { AdminAccountsPage } from '../pages/AdminAccountsPage';
|
import { AdminAccountsPage } from '../pages/AdminAccountsPage';
|
||||||
import { AdminAgcModelsPage } from '../pages/AdminAgcModelsPage';
|
import { AdminAgcModelsPage } from '../pages/AdminAgcModelsPage';
|
||||||
import { AdminAgcTemplatesPage } from '../pages/AdminAgcTemplatesPage';
|
|
||||||
import { AdminDashboardPage } from '../pages/AdminDashboardPage';
|
import { AdminDashboardPage } from '../pages/AdminDashboardPage';
|
||||||
import { AdminDatabaseTablesPage } from '../pages/AdminDatabaseTablesPage';
|
import { AdminDatabaseTablesPage } from '../pages/AdminDatabaseTablesPage';
|
||||||
import { AdminDebugHttpPage } from '../pages/AdminDebugHttpPage';
|
import { AdminDebugHttpPage } from '../pages/AdminDebugHttpPage';
|
||||||
@@ -27,13 +26,11 @@ import { AdminEditorAssetQueryPage } from '../pages/AdminEditorAssetQueryPage';
|
|||||||
import { AdminEditorGenerationPricingPage } from '../pages/AdminEditorGenerationPricingPage';
|
import { AdminEditorGenerationPricingPage } from '../pages/AdminEditorGenerationPricingPage';
|
||||||
import { AdminEditorShowcaseReviewPage } from '../pages/AdminEditorShowcaseReviewPage';
|
import { AdminEditorShowcaseReviewPage } from '../pages/AdminEditorShowcaseReviewPage';
|
||||||
import { AdminErrorReportsPage } from '../pages/AdminErrorReportsPage';
|
import { AdminErrorReportsPage } from '../pages/AdminErrorReportsPage';
|
||||||
import { AdminGameDistributionReviewPage } from '../pages/AdminGameDistributionReviewPage';
|
|
||||||
import { AdminGrayReleaseConfigPage } from '../pages/AdminGrayReleaseConfigPage';
|
import { AdminGrayReleaseConfigPage } from '../pages/AdminGrayReleaseConfigPage';
|
||||||
import { AdminInviteCodePage } from '../pages/AdminInviteCodePage';
|
import { AdminInviteCodePage } from '../pages/AdminInviteCodePage';
|
||||||
import { AdminLoginPage } from '../pages/AdminLoginPage';
|
import { AdminLoginPage } from '../pages/AdminLoginPage';
|
||||||
import { AdminOverviewPage } from '../pages/AdminOverviewPage';
|
import { AdminOverviewPage } from '../pages/AdminOverviewPage';
|
||||||
import { AdminProfileWalletConfigPage } from '../pages/AdminProfileWalletConfigPage';
|
import { AdminProfileWalletConfigPage } from '../pages/AdminProfileWalletConfigPage';
|
||||||
import { AdminProjectSnapshotsPage } from '../pages/AdminProjectSnapshotsPage';
|
|
||||||
import { AdminRechargeOrderPage } from '../pages/AdminRechargeOrderPage';
|
import { AdminRechargeOrderPage } from '../pages/AdminRechargeOrderPage';
|
||||||
import { AdminRechargeProductPage } from '../pages/AdminRechargeProductPage';
|
import { AdminRechargeProductPage } from '../pages/AdminRechargeProductPage';
|
||||||
import { AdminRedeemCodePage } from '../pages/AdminRedeemCodePage';
|
import { AdminRedeemCodePage } from '../pages/AdminRedeemCodePage';
|
||||||
@@ -296,24 +293,12 @@ export function AdminApp() {
|
|||||||
{activeRouteId === 'agc-models' ? (
|
{activeRouteId === 'agc-models' ? (
|
||||||
<AdminAgcModelsPage token={token} onUnauthorized={handleUnauthorized} />
|
<AdminAgcModelsPage token={token} onUnauthorized={handleUnauthorized} />
|
||||||
) : null}
|
) : null}
|
||||||
{activeRouteId === 'agc-templates' ? (
|
|
||||||
<AdminAgcTemplatesPage
|
|
||||||
token={token}
|
|
||||||
onUnauthorized={handleUnauthorized}
|
|
||||||
/>
|
|
||||||
) : null}
|
|
||||||
{activeRouteId === 'editor-showcase' ? (
|
{activeRouteId === 'editor-showcase' ? (
|
||||||
<AdminEditorShowcaseReviewPage
|
<AdminEditorShowcaseReviewPage
|
||||||
token={token}
|
token={token}
|
||||||
onUnauthorized={handleUnauthorized}
|
onUnauthorized={handleUnauthorized}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
{activeRouteId === 'game-distribution' ? (
|
|
||||||
<AdminGameDistributionReviewPage
|
|
||||||
token={token}
|
|
||||||
onUnauthorized={handleUnauthorized}
|
|
||||||
/>
|
|
||||||
) : null}
|
|
||||||
{activeRouteId === 'editor-assets' ? (
|
{activeRouteId === 'editor-assets' ? (
|
||||||
<AdminEditorAssetQueryPage
|
<AdminEditorAssetQueryPage
|
||||||
token={token}
|
token={token}
|
||||||
@@ -323,12 +308,6 @@ export function AdminApp() {
|
|||||||
{activeRouteId === 'accounts' ? (
|
{activeRouteId === 'accounts' ? (
|
||||||
<AdminAccountsPage token={token} onUnauthorized={handleUnauthorized} />
|
<AdminAccountsPage token={token} onUnauthorized={handleUnauthorized} />
|
||||||
) : null}
|
) : null}
|
||||||
{activeRouteId === 'project-snapshots' ? (
|
|
||||||
<AdminProjectSnapshotsPage
|
|
||||||
token={token}
|
|
||||||
onUnauthorized={handleUnauthorized}
|
|
||||||
/>
|
|
||||||
) : null}
|
|
||||||
</AdminShell>
|
</AdminShell>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import {
|
|||||||
Bug,
|
Bug,
|
||||||
Coins,
|
Coins,
|
||||||
Database,
|
Database,
|
||||||
FolderArchive,
|
|
||||||
Gamepad2,
|
|
||||||
GitBranch,
|
GitBranch,
|
||||||
Images,
|
Images,
|
||||||
LayoutDashboard,
|
LayoutDashboard,
|
||||||
@@ -50,12 +48,9 @@ const routeIcons = {
|
|||||||
'recharge-orders': ReceiptText,
|
'recharge-orders': ReceiptText,
|
||||||
'editor-generation-pricing': Coins,
|
'editor-generation-pricing': Coins,
|
||||||
'editor-showcase': Star,
|
'editor-showcase': Star,
|
||||||
'game-distribution': Gamepad2,
|
|
||||||
'editor-assets': Images,
|
'editor-assets': Images,
|
||||||
'project-snapshots': FolderArchive,
|
|
||||||
accounts: Users,
|
accounts: Users,
|
||||||
'agc-models': ListChecks,
|
'agc-models': ListChecks,
|
||||||
'agc-templates': Images,
|
|
||||||
} satisfies Record<AdminRouteId, typeof LayoutDashboard>;
|
} satisfies Record<AdminRouteId, typeof LayoutDashboard>;
|
||||||
|
|
||||||
export function AdminShell({
|
export function AdminShell({
|
||||||
|
|||||||
@@ -122,76 +122,3 @@ test('零权限 member 不回落到 Dashboard', () => {
|
|||||||
expect(routes).toEqual([]);
|
expect(routes).toEqual([]);
|
||||||
expect(resolveAccessibleAdminRoute('#dashboard', routes)).toBeNull();
|
expect(resolveAccessibleAdminRoute('#dashboard', routes)).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('项目工程入口对 owner 与已授权 member 开放且可分配权限', () => {
|
|
||||||
const route = {
|
|
||||||
id: 'project-snapshots',
|
|
||||||
label: '项目工程',
|
|
||||||
hash: '#project-snapshots',
|
|
||||||
};
|
|
||||||
expect(adminRoutes.filter((item) => !item.ownerOnly)).toContainEqual(route);
|
|
||||||
expect(resolveAdminRoute('#project-snapshots')).toBe('project-snapshots');
|
|
||||||
expect(
|
|
||||||
getAccessibleAdminRoutes({ accountRole: 'owner', tabPermissions: [] }),
|
|
||||||
).toContainEqual(route);
|
|
||||||
expect(
|
|
||||||
getAccessibleAdminRoutes({
|
|
||||||
accountRole: 'member',
|
|
||||||
tabPermissions: ['project-snapshots'],
|
|
||||||
}),
|
|
||||||
).toEqual([route]);
|
|
||||||
expect(
|
|
||||||
getAccessibleAdminRoutes({
|
|
||||||
accountRole: 'member',
|
|
||||||
tabPermissions: ['tracking'],
|
|
||||||
}),
|
|
||||||
).not.toContainEqual(route);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('后台游戏审核路由可通过导航和 hash 访问', () => {
|
|
||||||
expect(adminRoutes).toContainEqual({
|
|
||||||
id: 'game-distribution',
|
|
||||||
label: '游戏审核',
|
|
||||||
hash: '#game-distribution',
|
|
||||||
});
|
|
||||||
expect(resolveAdminRoute('#game-distribution')).toBe('game-distribution');
|
|
||||||
expect(routeHash('game-distribution')).toBe('#game-distribution');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('member 可单独获得游戏审核 Tab 权限', () => {
|
|
||||||
const routes = getAccessibleAdminRoutes({
|
|
||||||
accountRole: 'member',
|
|
||||||
tabPermissions: ['game-distribution'],
|
|
||||||
});
|
|
||||||
expect(routes.map((route) => route.id)).toEqual(['game-distribution']);
|
|
||||||
expect(resolveAccessibleAdminRoute('#game-distribution', routes)).toBe(
|
|
||||||
'game-distribution',
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('模板管理只对 owner 或具有 agc-templates 权限的 member 可见', () => {
|
|
||||||
expect(adminRoutes).toContainEqual({
|
|
||||||
id: 'agc-templates',
|
|
||||||
label: '模板管理',
|
|
||||||
hash: '#agc-templates',
|
|
||||||
});
|
|
||||||
expect(resolveAdminRoute('#agc-templates')).toBe('agc-templates');
|
|
||||||
expect(routeHash('agc-templates')).toBe('#agc-templates');
|
|
||||||
expect(
|
|
||||||
getAccessibleAdminRoutes({ accountRole: 'owner', tabPermissions: [] }).some(
|
|
||||||
(route) => route.id === 'agc-templates',
|
|
||||||
),
|
|
||||||
).toBe(true);
|
|
||||||
expect(
|
|
||||||
getAccessibleAdminRoutes({
|
|
||||||
accountRole: 'member',
|
|
||||||
tabPermissions: ['agc-templates'],
|
|
||||||
}).map((route) => route.id),
|
|
||||||
).toEqual(['agc-templates']);
|
|
||||||
expect(
|
|
||||||
getAccessibleAdminRoutes({
|
|
||||||
accountRole: 'member',
|
|
||||||
tabPermissions: ['editor-assets'],
|
|
||||||
}).some((route) => route.id === 'agc-templates'),
|
|
||||||
).toBe(false);
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -15,11 +15,8 @@ export type AdminRouteId =
|
|||||||
| 'recharge-orders'
|
| 'recharge-orders'
|
||||||
| 'editor-generation-pricing'
|
| 'editor-generation-pricing'
|
||||||
| 'editor-showcase'
|
| 'editor-showcase'
|
||||||
| 'game-distribution'
|
|
||||||
| 'editor-assets'
|
| 'editor-assets'
|
||||||
| 'project-snapshots'
|
|
||||||
| 'agc-models'
|
| 'agc-models'
|
||||||
| 'agc-templates'
|
|
||||||
| 'accounts';
|
| 'accounts';
|
||||||
|
|
||||||
export type AdminTabPermission = Exclude<
|
export type AdminTabPermission = Exclude<
|
||||||
@@ -55,11 +52,8 @@ export const adminRoutes: AdminRouteDefinition[] = [
|
|||||||
hash: '#editor-generation-pricing',
|
hash: '#editor-generation-pricing',
|
||||||
},
|
},
|
||||||
{ id: 'agc-models', label: 'AGC 模型', hash: '#agc-models', ownerOnly: true },
|
{ id: 'agc-models', label: 'AGC 模型', hash: '#agc-models', ownerOnly: true },
|
||||||
{ id: 'agc-templates', label: '模板管理', hash: '#agc-templates' },
|
|
||||||
{ id: 'editor-showcase', label: '精选审核', hash: '#editor-showcase' },
|
{ id: 'editor-showcase', label: '精选审核', hash: '#editor-showcase' },
|
||||||
{ id: 'game-distribution', label: '游戏审核', hash: '#game-distribution' },
|
|
||||||
{ id: 'editor-assets', label: '素材查询', hash: '#editor-assets' },
|
{ id: 'editor-assets', label: '素材查询', hash: '#editor-assets' },
|
||||||
{ id: 'project-snapshots', label: '项目工程', hash: '#project-snapshots' },
|
|
||||||
{ id: 'accounts', label: '账号管理', hash: '#accounts', ownerOnly: true },
|
{ id: 'accounts', label: '账号管理', hash: '#accounts', ownerOnly: true },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user