dreamfactory 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +183 -0
- package/dist/index.js +39901 -0
- package/package.json +45 -0
- package/scripts/mail-watch-agent.sh +194 -0
- package/scripts/postinstall.cjs +42 -0
package/README.md
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# DreamFactory 梦工厂
|
|
2
|
+
|
|
3
|
+
AI-powered short drama generator for digital characters. Interview [linkyun.co](https://linkyun.co) digital characters, build rich profiles, then generate scripts, storyboards, and videos — all from your terminal.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Install
|
|
9
|
+
npm install -g github:stelee410/dream-factory
|
|
10
|
+
|
|
11
|
+
# Configure API keys
|
|
12
|
+
dreamfactory init
|
|
13
|
+
|
|
14
|
+
# Start creating
|
|
15
|
+
dreamfactory
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Prerequisites
|
|
19
|
+
|
|
20
|
+
- **Node.js** >= 20
|
|
21
|
+
- **ffmpeg** — for video concatenation
|
|
22
|
+
- macOS: `brew install ffmpeg`
|
|
23
|
+
- Linux: `apt install ffmpeg`
|
|
24
|
+
|
|
25
|
+
## Configuration
|
|
26
|
+
|
|
27
|
+
### Where values are loaded
|
|
28
|
+
|
|
29
|
+
The CLI reads **`./.env` first**, then **`~/.dreamfactory/.env`**. Each file only sets a key if it is **not already set** in `process.env`, so values already exported in your shell win, then the local file, then the global file fills remaining gaps (`packages/cli/src/load-env.ts`).
|
|
30
|
+
|
|
31
|
+
Copy [`.env.example`](./.env.example) to `.env` as a starting point.
|
|
32
|
+
|
|
33
|
+
### linkyun.co vs third-party keys
|
|
34
|
+
|
|
35
|
+
| Key | Purpose |
|
|
36
|
+
|-----|---------|
|
|
37
|
+
| `LINKYUN_API_BASE` | linkyun.co API base URL (default: `https://linkyun.co`) |
|
|
38
|
+
| `LINKYUN_API_KEY` | From linkyun **login** JSON `data.api_key` (same as `data.creator.api_key`). The linkyun-agent backend generates it as `sk-` + 48 hex characters (~51 chars). It is **not** OpenRouter (`sk-or-v1-…`) or Anthropic (`sk-ant-…`); keys with those prefixes do not come from this login API. |
|
|
39
|
+
| `LINKYUN_WORKSPACE_CODE` | Workspace code from login — header `X-Workspace-Code`. |
|
|
40
|
+
| `LINKYUN_USERNAME` | Optional; for display only. |
|
|
41
|
+
|
|
42
|
+
Prefer signing in inside the CLI and choosing to save the session to the local `.env`; then you do not need to hand-copy keys.
|
|
43
|
+
|
|
44
|
+
**Where is the real `LINKYUN_API_KEY`?** The **canonical** value lives on the linkyun server (per creator). The CLI only **receives** it in the login JSON and keeps a copy in **memory**; optional **save to `.env`** writes that same value to disk. Anything wrong or placeholder-like in `.env` is just a stale or mistaken file — it is not authoritative.
|
|
45
|
+
|
|
46
|
+
**Why does password login still work with a bad `LINKYUN_API_KEY` in `.env`?** Interactive login uses **only username + password** in `POST /api/v1/auth/login`; it does **not** read or check `LINKYUN_API_KEY` from the environment. The response body carries the real `api_key`, which replaces in-memory session for that run. **Auto-login from `.env`** (`tryRestoreFromEnv`) only requires non-empty strings and does not pre-validate the key; bad values show up later as API errors (e.g. 401) when listing characters or similar.
|
|
47
|
+
|
|
48
|
+
**I use auto-restore, my `.env` key looks “wrong”, but listing characters still works — why?** `load-env` **never overwrites** a variable that already exists on `process.env`. If your shell, IDE / Cursor task env, Docker, or `~/.profile` has already exported `LINKYUN_API_KEY` / `LINKYUN_WORKSPACE_CODE`, those values win — the matching lines in the project `.env` are **skipped** when loading (`packages/cli/src/load-env.ts`). Auto-restore and character list then use the **effective** env vars, not necessarily what you see in the file. Compare: `grep ^LINKYUN_ .env` vs starting the CLI from the same terminal with `echo $LINKYUN_API_KEY` (if the latter is non-empty before launch, it overrides the file).
|
|
49
|
+
|
|
50
|
+
| Key | Purpose |
|
|
51
|
+
|-----|---------|
|
|
52
|
+
| `LLM_BASE_URL` | Base URL for OpenAI-compatible chat API (default `https://openrouter.ai/api/v1`) |
|
|
53
|
+
| `LLM_MODEL` | Model id (default `anthropic/claude-sonnet-4`) |
|
|
54
|
+
| `LLM_API_KEY` | API key for that endpoint. If unset, `OPENROUTER_API_KEY` is still accepted. |
|
|
55
|
+
| `WAN_API_KEY` | Storyboard images (Alibaba Wan2.7), optional |
|
|
56
|
+
| `SEEDANCE_API_KEY` | Video generation (Seedance), optional |
|
|
57
|
+
|
|
58
|
+
### Global interactive setup
|
|
59
|
+
|
|
60
|
+
Prompts for the global file keys (LLM, Wan, Seedance, and base URL — not linkyun session):
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
dreamfactory init
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Usage
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
dreamfactory # New project (agent mode)
|
|
70
|
+
dreamfactory last # Resume most recent project
|
|
71
|
+
dreamfactory <path> # Resume specific project
|
|
72
|
+
dreamfactory init # Configure API keys
|
|
73
|
+
dreamfactory linear # Linear mode (guided step-by-step)
|
|
74
|
+
dreamfactory --help # Show help
|
|
75
|
+
dreamfactory --version # Show version
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The current directory is your workspace. All project data is saved under `dreamfactory/projects/` in that directory.
|
|
79
|
+
|
|
80
|
+
## Agent Mode
|
|
81
|
+
|
|
82
|
+
The default mode. An AI assistant interprets natural language and calls pipeline tools on your behalf.
|
|
83
|
+
|
|
84
|
+
**What you can do:**
|
|
85
|
+
|
|
86
|
+
- Select a character and conduct an interview
|
|
87
|
+
- Set a drama theme and director style
|
|
88
|
+
- Generate plot outlines, scripts, and storyboards
|
|
89
|
+
- Regenerate individual storyboard images or video shots
|
|
90
|
+
- Reorder shots and re-concatenate the final video
|
|
91
|
+
- Re-do any step at any point without starting over
|
|
92
|
+
|
|
93
|
+
**Keyboard:**
|
|
94
|
+
- `↑` / `↓` — browse input history (up to 100 entries)
|
|
95
|
+
- `/status` — view project status
|
|
96
|
+
- `/done` — end interview and generate dossier
|
|
97
|
+
- `/quit` — exit
|
|
98
|
+
|
|
99
|
+
## Complete Flow
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
Login (linkyun.co credentials)
|
|
103
|
+
→ Select digital character
|
|
104
|
+
→ Interview (5+ rounds of conversation)
|
|
105
|
+
→ Character dossier generated (personality, speech style, appearance)
|
|
106
|
+
→ Set drama theme (e.g. "职场逆袭", "甜蜜恋爱")
|
|
107
|
+
→ Set director style (cinematic, anime, documentary, etc.)
|
|
108
|
+
→ Choose from 3 AI-generated plot outlines
|
|
109
|
+
→ Full script generated (scenes, dialogues, camera directions)
|
|
110
|
+
→ Storyboard: script → shots with AI-generated images (Wan2.7)
|
|
111
|
+
→ Video: shots → MP4 clips → final concatenated video
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Project Output
|
|
115
|
+
|
|
116
|
+
Each project is a timestamped directory:
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
dreamfactory/projects/YYYYMMDD_HHMMSS/
|
|
120
|
+
├── character.json # Selected character profile
|
|
121
|
+
├── dossier.json # Character dossier from interview
|
|
122
|
+
├── director-style.json # Director style selection
|
|
123
|
+
├── meta.json # Theme and metadata
|
|
124
|
+
├── outlines.json # Generated plot outlines
|
|
125
|
+
├── script.json # Full script (structured)
|
|
126
|
+
├── script.md # Full script (readable)
|
|
127
|
+
├── storyboard/
|
|
128
|
+
│ ├── storyboard.json # Shot breakdown (structured)
|
|
129
|
+
│ ├── storyboard.md # Shot breakdown (readable)
|
|
130
|
+
│ └── shot_01.png ... # AI-generated storyboard images
|
|
131
|
+
└── videos/
|
|
132
|
+
├── shot_01.mp4 ... # Individual shot videos
|
|
133
|
+
├── video-output.json
|
|
134
|
+
└── final.mp4 # Concatenated final video
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Development
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
git clone https://github.com/stelee410/dream-factory.git
|
|
141
|
+
cd dream-factory
|
|
142
|
+
pnpm install
|
|
143
|
+
pnpm build # TypeScript compilation (monorepo)
|
|
144
|
+
pnpm build:bundle # Single-file CLI bundle (tsup)
|
|
145
|
+
npm link # Make `dreamfactory` available globally
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Architecture
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
packages/
|
|
152
|
+
├── core/ # Shared business logic (SDK)
|
|
153
|
+
│ ├── auth/ # linkyun.co authentication
|
|
154
|
+
│ ├── character/ # Digital character management
|
|
155
|
+
│ ├── ai/ # OpenRouter AI client + tool calling
|
|
156
|
+
│ ├── interview/ # Character interview engine
|
|
157
|
+
│ ├── director/ # Director style presets
|
|
158
|
+
│ ├── script/ # Script generation engine
|
|
159
|
+
│ ├── storyboard/ # Shot breakdown + Wan2.7 image generation
|
|
160
|
+
│ ├── video/ # Seedance video generation + ffmpeg concat
|
|
161
|
+
│ └── agent/ # AI agent (tool dispatch, project state)
|
|
162
|
+
└── cli/ # Ink (React for CLI) application
|
|
163
|
+
├── screens/ # Login, Interview, Storyboard, Video, etc.
|
|
164
|
+
└── AgentChat.tsx # Agent mode interactive chat
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Tech Stack
|
|
168
|
+
|
|
169
|
+
| Layer | Technology |
|
|
170
|
+
|-------|-----------|
|
|
171
|
+
| Runtime | Node.js 20+ / TypeScript |
|
|
172
|
+
| CLI | [Ink](https://github.com/vadimdemedes/ink) (React for terminals) |
|
|
173
|
+
| AI (text) | Claude via [OpenRouter](https://openrouter.ai) |
|
|
174
|
+
| AI (images) | [Wan2.7](https://bailian.console.aliyun.com) (Alibaba Cloud Bailian) |
|
|
175
|
+
| AI (video) | Seedance (image-to-video) |
|
|
176
|
+
| Video | ffmpeg (concatenation) |
|
|
177
|
+
| Build | tsup + esbuild (single-file bundle) |
|
|
178
|
+
| Monorepo | pnpm workspaces |
|
|
179
|
+
| API | [linkyun.co](https://linkyun.co) REST API |
|
|
180
|
+
|
|
181
|
+
## License
|
|
182
|
+
|
|
183
|
+
MIT
|