feat: add task workflow and asset downloads

This commit is contained in:
inman
2026-05-29 12:32:02 +08:00
parent f9c3393f84
commit 63e62d444c
61 changed files with 2773 additions and 2181 deletions

View File

@@ -6,20 +6,20 @@
## Research Findings
- Top-level project is not a Git repository; `git status --short` returned "fatal: not a git repository".
- Root contains orchestration/docs files plus a `runtime/nianxx-play` application directory.
- `runtime/nianxx-play/node_modules` is present, so dependencies appear already installed for the embedded runtime app.
- The initial full file scan showed many bundled media assets under `runtime/nianxx-play/public`, especially starter/planning/Seedance examples.
- Root contains orchestration/docs files plus a `removed extracted runtime` application directory.
- `removed extracted runtime/node_modules` is present, so dependencies appear already installed for the embedded runtime app.
- The initial full file scan showed many bundled media assets under `removed extracted runtime/public`, especially starter/planning/Seedance examples.
- `README.md` states this was extracted from the `智念助手` desktop app into an independent `智念创作助手` project.
- The project is based on an existing NianxxPlay Next.js standalone runtime; original source was deleted, so this is not a full source restoration.
- Root `package.json` only orchestrates scripts: `start`/`dev` call `scripts/start-runtime.mjs`, `health` calls `scripts/health-check.mjs`, and `info` calls `scripts/print-runtime-info.mjs`.
- The project is based on an existing extracted runtime Next.js standalone runtime; original source was deleted, so this is not a full source restoration.
- Root `package.json` only orchestrates scripts: `start`/`dev` call `removed runtime start script`, `health` calls `scripts/health-check.mjs`, and `info` calls `removed runtime info script`.
- Runtime package uses Next `^15.1.4`, React `^19.0.0`, Supabase client, Ali OSS, lucide-react, TypeScript, Vitest, and ESLint, but it is treated as generated runtime.
- Runtime state should be written to root `.runtime/`, not under `runtime/nianxx-play`.
- `scripts/start-runtime.mjs` loads `.env` and `.env.local`, optionally bundled `.env.runtime` only when `NIANXXPLAY_LOAD_BUNDLED_ENV=1`.
- Startup creates `.runtime/data`, `.runtime/uploads`, and `.runtime/generated-results`, then launches `runtime/nianxx-play/server.js` with `NODE_ENV=production`.
- Health check targets `/api/desktop/health` and expects JSON with `appId: "nianxx-play"` and `ok: true`.
- Runtime state should be written to root `.runtime/`, not under `removed extracted runtime`.
- `removed runtime start script` loads `.env` and `.env.local`, optionally bundled `.env.runtime` only when `ZHINIAN_LOAD_BUNDLED_ENV=1`.
- Startup creates `.runtime/data`, `.runtime/uploads`, and `.runtime/generated-results`, then launches `removed extracted runtime/server.js` with `NODE_ENV=production`.
- Health check targets `/api/desktop/health` and expects JSON with `appId: "removed-runtime"` and `ok: true`.
- `.env.example` shows the real generation path depends on Seedance / Volcengine Ark plus Aliyun OSS configuration.
- Extraction notes confirm copied assets include Next standalone server runtime, `.next` output, runtime `node_modules`, public/reference media, content manifests, and planning cases; secrets, user uploads, generated results, and Electron host/process manager code were excluded.
- `npm run info` succeeded and reports runtime app id `nianxx-play`, bundle timestamp `2026-05-14T04:01:58.653Z`, entry `server.js`, and size `949,760,759` bytes.
- `npm run info` succeeded and reports runtime app id `removed-runtime`, bundle timestamp `2026-05-14T04:01:58.653Z`, entry `server.js`, and size `949,760,759` bytes.
- App routes include: `/`, `/studio`, `/studio/[mode]`, `/planning`, `/projects`, `/projects/[id]`, and `/billing`.
- API routes include: `/api/assets`, `/api/assets/upload`, `/api/billing`, `/api/desktop/health`, `/api/generations`, `/api/generations/[id]`, `/api/generations/[id]/retry`, `/api/projects`, `/api/projects/[id]`, `/api/prompt/assemble`, and `/api/reference-templates`.
- File-serving routes expose runtime uploads and generated results via `/uploads/[...path]` and `/generated-results/[...path]`.
@@ -62,22 +62,22 @@
## Resources
- Project root: `/Users/inmanx/Documents/zhinian-creation-assistant`
- Runtime app: `/Users/inmanx/Documents/zhinian-creation-assistant/runtime/nianxx-play`
- Runtime app: `/Users/inmanx/Documents/zhinian-creation-assistant/removed extracted runtime`
- Root README: `/Users/inmanx/Documents/zhinian-creation-assistant/README.md`
- Runtime README: `/Users/inmanx/Documents/zhinian-creation-assistant/runtime/README.md`
- Startup script: `/Users/inmanx/Documents/zhinian-creation-assistant/scripts/start-runtime.mjs`
- Startup script: `/Users/inmanx/Documents/zhinian-creation-assistant/removed runtime start script`
- Health script: `/Users/inmanx/Documents/zhinian-creation-assistant/scripts/health-check.mjs`
- Runtime info script: `/Users/inmanx/Documents/zhinian-creation-assistant/scripts/print-runtime-info.mjs`
- Runtime info script: `/Users/inmanx/Documents/zhinian-creation-assistant/removed runtime info script`
- Extraction notes: `/Users/inmanx/Documents/zhinian-creation-assistant/docs/EXTRACTION_NOTES.md`
- App paths manifest: `/Users/inmanx/Documents/zhinian-creation-assistant/runtime/nianxx-play/.next/server/app-paths-manifest.json`
- Compiled projects API: `/Users/inmanx/Documents/zhinian-creation-assistant/runtime/nianxx-play/.next/server/app/api/projects/route.js`
- Compiled upload API: `/Users/inmanx/Documents/zhinian-creation-assistant/runtime/nianxx-play/.next/server/app/api/assets/upload/route.js`
- Compiled prompt assembly API: `/Users/inmanx/Documents/zhinian-creation-assistant/runtime/nianxx-play/.next/server/app/api/prompt/assemble/route.js`
- Compiled generation polling API: `/Users/inmanx/Documents/zhinian-creation-assistant/runtime/nianxx-play/.next/server/app/api/generations/[id]/route.js`
- Compiled generation retry API: `/Users/inmanx/Documents/zhinian-creation-assistant/runtime/nianxx-play/.next/server/app/api/generations/[id]/retry/route.js`
- Creation modes JSON: `/Users/inmanx/Documents/zhinian-creation-assistant/runtime/nianxx-play/content/seedance-starter/creation-modes.json`
- Starter catalog JSON: `/Users/inmanx/Documents/zhinian-creation-assistant/runtime/nianxx-play/content/seedance-starter/catalog.json`
- Planning cases JSON: `/Users/inmanx/Documents/zhinian-creation-assistant/runtime/nianxx-play/content/planning-cases.json`
- App paths manifest: `/Users/inmanx/Documents/zhinian-creation-assistant/removed extracted runtime/.next/server/app-paths-manifest.json`
- Compiled projects API: `/Users/inmanx/Documents/zhinian-creation-assistant/removed extracted runtime/.next/server/app/api/projects/route.js`
- Compiled upload API: `/Users/inmanx/Documents/zhinian-creation-assistant/removed extracted runtime/.next/server/app/api/assets/upload/route.js`
- Compiled prompt assembly API: `/Users/inmanx/Documents/zhinian-creation-assistant/removed extracted runtime/.next/server/app/api/prompt/assemble/route.js`
- Compiled generation polling API: `/Users/inmanx/Documents/zhinian-creation-assistant/removed extracted runtime/.next/server/app/api/generations/[id]/route.js`
- Compiled generation retry API: `/Users/inmanx/Documents/zhinian-creation-assistant/removed extracted runtime/.next/server/app/api/generations/[id]/retry/route.js`
- Creation modes JSON: `/Users/inmanx/Documents/zhinian-creation-assistant/removed extracted runtime/content/seedance-starter/creation-modes.json`
- Starter catalog JSON: `/Users/inmanx/Documents/zhinian-creation-assistant/removed extracted runtime/content/seedance-starter/catalog.json`
- Planning cases JSON: `/Users/inmanx/Documents/zhinian-creation-assistant/removed extracted runtime/content/removed planning case manifest.json`
- Runtime local state file: `/Users/inmanx/Documents/zhinian-creation-assistant/.runtime/data/app-state.json`
## Visual/Browser Findings
@@ -88,7 +88,7 @@
- The header logo loads from `public/logo/zhinian-logo.png`; after the final branding pass it has no border, background, or box shadow.
## 2026-05-29 UI/UX and Branding Findings
- The current source app is now a Web app in the repository root, not the old `runtime/nianxx-play` standalone-only flow described in the earliest findings.
- The current source app is now a Web app in the repository root, not the old `removed extracted runtime` standalone-only flow described in the earliest findings.
- GSAP is used through `lib/ui/motion.ts` rather than directly sprinkled across components.
- The UI direction is a professional creation workspace, not a marketing landing page.
- Visible English eyebrows/descriptions were removed from module headers per user preference.
@@ -111,3 +111,24 @@
- For localhost verification, continue using `curl --noproxy '*'` because local proxy settings can interfere with direct checks.
- Before running `npm run build`, stop the dev server (`screen -S zhinian-dev-ui -X quit` and `pkill -f 'next dev --hostname 127.0.0.1 --port 3000'`) to avoid stale Next dev chunk issues.
- After build verification, restart the dev server in screen session `zhinian-dev-ui` on `127.0.0.1:3000`.
## 2026-05-29 Deployment Findings
- Server one-command deployment is now `bash scripts/deploy.sh`.
- Docker Compose service name is `zhinian-aigc`.
- Docker Compose defaults to exposing host port `3000`; set `APP_PORT` in `.env.local` or shell to change it.
- `NEXT_PUBLIC_APP_URL` should be set to the public domain or server URL in production so generated local file URLs are correct.
- Persistent runtime data is bind-mounted through `./.runtime:/app/.runtime`; this folder should be backed up on real servers.
- `.env.local` is intentionally used as the compose `env_file` and remains ignored by Git.
- Current local machine does not have the Docker CLI available, so Docker build was not run here; script syntax, app tests, production build, and local health were verified instead.
## 2026-05-29 Public API and Task Management Findings
- User confirmed multi-task support should be task management logic, not an external message queue.
- Public API v1 now uses `ZHINIAN_API_KEYS`, supporting `Authorization: Bearer <key>` and `X-Zhinian-Api-Key`.
- Task creation and provider execution are now split: submit routes enqueue `GenerationJob` records; Worker ticks claim and process jobs.
- `generation_jobs` now carries external client, idempotency, priority, attempts, lock, schedule, timing, and webhook fields.
- Supabase/Postgres production mode expects the `claim_generation_jobs` function from `supabase/schema.sql` for atomic task claiming.
- Local JSON mode serializes task claiming through the existing local write queue and is intended for single-instance development.
- Worker execution can run as `npm run worker`, `npm run worker:once`, or the `zhinian-worker` Docker Compose service.
- Internal Worker processing goes through `/api/internal/worker/tick` protected by `ZHINIAN_INTERNAL_WORKER_TOKEN` in production.
- API v1 routes are `/api/v1/capabilities`, `/api/v1/assets`, `/api/v1/jobs`, `/api/v1/jobs/:id`, `/api/v1/jobs/:id/cancel`, and `/api/v1/openapi.json`.
- Local verification created a public API job and processed it to `succeeded` through `npm run worker:once` in mock mode.