@musnows/scriverse 0.2.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/LICENSE +21 -0
- package/README.en.md +214 -0
- package/README.md +220 -0
- package/dist/cli-contract.js +280 -0
- package/dist/cli-contract.js.map +1 -0
- package/dist/cli-core.js +611 -0
- package/dist/cli-core.js.map +1 -0
- package/dist/cli.js +4 -0
- package/dist/cli.js.map +1 -0
- package/package.json +74 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 musnows
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.en.md
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://scriverse.top/">
|
|
3
|
+
<img src="./showcase/public/favicon.svg" alt="Scriverse" width="96">
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<h1 align="center">Scriverse</h1>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
A local AI-assisted writing workspace for long-form fiction
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<a href="README.md">中文</a> | <a href="README.en.md">English</a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p align="center">
|
|
18
|
+
Scriverse is a local AI-assisted writing workspace for long-form fiction. It keeps manuscript text, volumes, characters, organizations, worldbuilding, timelines, relationship graphs, outlines, foreshadowing, and AI assistance in one project. It is designed for large, continuity-heavy novel projects.
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
<p align="center">
|
|
22
|
+
Live demo: <a href="https://scriverse.top/">https://scriverse.top/</a>
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
## Features
|
|
26
|
+
|
|
27
|
+
- Work shelf for multiple novels, covers, authors, and descriptions.
|
|
28
|
+
- Manuscript editor with a volume/chapter tree, autosave, version history, line citations, blank-line normalization, and full-text search.
|
|
29
|
+
- Four chapter types: manuscript, setting, author's note, and other.
|
|
30
|
+
- TXT and DOCX import with volume, chapter, and postscript recognition.
|
|
31
|
+
- Setting library with character aliases, attributes, and locked fields.
|
|
32
|
+
- Organizations with descriptions, setting lists, and multi-organization character membership.
|
|
33
|
+
- Kanban-style timelines with multiple event tracks, split, merge, and ordering operations.
|
|
34
|
+
- Character relationships with categories, keyword lists, evidence, confidence, a standard graph, and an interactive 3D galaxy view.
|
|
35
|
+
- Chapter outlines and foreshadowing setup, reminder, and payoff tracking.
|
|
36
|
+
- Streaming AI chat with Markdown rendering, chapter line citations, and optional character or setting context.
|
|
37
|
+
- AI tasks for structure, chapters, character extraction, timelines, relationships, and consistency checks.
|
|
38
|
+
- OpenAI Chat Completions-compatible providers with configurable models, maximum output tokens, concurrency, and RPM.
|
|
39
|
+
- JSON, TXT, and Markdown export without AI credentials.
|
|
40
|
+
|
|
41
|
+
## Technology
|
|
42
|
+
|
|
43
|
+
- Node.js 22.5+
|
|
44
|
+
- TypeScript
|
|
45
|
+
- Express 5
|
|
46
|
+
- Node.js SQLite
|
|
47
|
+
- Vanilla HTML, CSS, and JavaScript
|
|
48
|
+
- Vitest and Supertest
|
|
49
|
+
|
|
50
|
+
## Quick Start
|
|
51
|
+
|
|
52
|
+
### Requirements
|
|
53
|
+
|
|
54
|
+
- Node.js `>= 22.5.0`
|
|
55
|
+
- npm
|
|
56
|
+
|
|
57
|
+
### Install and run for development
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
git clone git@github.com:musnows/Scriverse.git
|
|
61
|
+
cd Scriverse
|
|
62
|
+
npm ci
|
|
63
|
+
npm run dev
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Open [http://localhost:13210](http://localhost:13210).
|
|
67
|
+
|
|
68
|
+
### Production build
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
npm run build
|
|
72
|
+
npm start
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Command-line client
|
|
76
|
+
|
|
77
|
+
The CLI connects to a running Scriverse server to query or edit work data. Install it globally to use the `scriverse` command:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
npm install --global @musnows/scriverse
|
|
81
|
+
scriverse auth login --server https://your-scriverse.example.com --api-key-file ./api-key.txt
|
|
82
|
+
scriverse work list
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Run `scriverse --help` for all authentication, work, manuscript, resource, history, and search commands. The CLI requires Node.js `>= 22.5.0`.
|
|
86
|
+
|
|
87
|
+
## Environment Variables
|
|
88
|
+
|
|
89
|
+
| Variable | Default | Description |
|
|
90
|
+
| --- | --- | --- |
|
|
91
|
+
| `PORT` | `13210` | HTTP server port |
|
|
92
|
+
| `HOST` | `127.0.0.1` | Listen address; use `0.0.0.0` for a server deployment |
|
|
93
|
+
| `DATA_DIR` | `<project>/.data` | Default data directory |
|
|
94
|
+
| `DATABASE_PATH` | `<DATA_DIR>/novel.db` | SQLite database path |
|
|
95
|
+
| `AI_NOVEL_MASTER_KEY` | Generated and stored at `<DATA_DIR>/master.key` | Master key used to encrypt AI provider credentials |
|
|
96
|
+
| `APP_AUTH_USERNAME` | Empty | Optional deployment gateway username; the in-app user system is always enabled |
|
|
97
|
+
| `APP_AUTH_PASSWORD` | Empty | Optional deployment gateway password, at least 12 characters; must be transported over HTTPS |
|
|
98
|
+
| `APP_TRUST_PROXY` | `false` | Set to the trusted proxy hop count (usually `1`) or `true` behind a trusted reverse proxy |
|
|
99
|
+
| `APP_ALLOW_PRIVATE_AI_ENDPOINTS` | `true` in development, `false` in production | Allow AI providers on loopback/private networks; link-local and cloud metadata addresses are always blocked |
|
|
100
|
+
| `APP_ALLOW_REGISTRATION` | `true` | Set to `false` to disable open registration (first-admin setup remains allowed); recommended behind a public nginx reverse proxy |
|
|
101
|
+
|
|
102
|
+
Custom configuration example:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
PORT=13211 DATA_DIR=/path/to/scriverse-data npm run dev
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Server deployment example:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
NODE_ENV=production \
|
|
112
|
+
HOST=0.0.0.0 \
|
|
113
|
+
APP_AUTH_USERNAME=admin \
|
|
114
|
+
APP_AUTH_PASSWORD='replace-with-a-long-random-password' \
|
|
115
|
+
npm start
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Production deployments must use HTTPS at a trusted reverse proxy. On first launch, the first registered user becomes the system administrator; later registrations are normal users. Optional HTTP Basic Auth is only an additional deployment gateway, and its credentials are merely Base64 encoded. `/api/health` remains public for health checks, while business APIs require an in-app login.
|
|
119
|
+
|
|
120
|
+
## AI Provider Setup
|
|
121
|
+
|
|
122
|
+
1. Start Scriverse and open the top-level **AI Management** page.
|
|
123
|
+
2. Add an OpenAI Chat Completions-compatible provider with its base URL, API key, concurrency, RPM, and maximum output tokens.
|
|
124
|
+
3. Add models with their supported context-window size in tokens.
|
|
125
|
+
4. Set a platform-wide system prompt; it is appended after Scriverse's built-in prompt.
|
|
126
|
+
5. In a work, open **More → AI Settings** to set the work-specific appended system prompt and default models. The work prompt is appended after the platform prompt.
|
|
127
|
+
|
|
128
|
+
New providers default to `10` concurrent requests, `10` RPM, and `32000` maximum output tokens. New models default to a `128000`-token context window. The chat sidebar displays a context-usage ring for the selected model.
|
|
129
|
+
|
|
130
|
+
## Data and Security
|
|
131
|
+
|
|
132
|
+
- Application data is stored in `.data/novel.db` by default.
|
|
133
|
+
- AI provider credentials are encrypted. The default master key is `.data/master.key`.
|
|
134
|
+
- Back up both the database and the master key. Existing provider credentials cannot be decrypted if the master key is lost.
|
|
135
|
+
- Scriverse does not include a user system. Server deployments use single-instance HTTP Basic Auth configured through environment variables, and production startup fails when credentials are missing.
|
|
136
|
+
- The server listens on `127.0.0.1` by default. Non-loopback listening also requires authentication. Public entry points must use HTTPS, a trusted reverse proxy, and firewall access controls.
|
|
137
|
+
- CSP, clickjacking protection, MIME sniffing protection, same-origin write validation, authentication and API rate limits, body/upload limits, and AI-provider SSRF protection are enabled by default.
|
|
138
|
+
- SQLite values are bound through prepared statements. Dynamic SQL fragments are limited to server-controlled branches and never contain request input.
|
|
139
|
+
|
|
140
|
+
## Testing
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
# Type checking
|
|
144
|
+
npm run typecheck
|
|
145
|
+
|
|
146
|
+
# All Vitest tests
|
|
147
|
+
npm test
|
|
148
|
+
|
|
149
|
+
# Unit, integration, and system suites
|
|
150
|
+
npm run test:unit
|
|
151
|
+
npm run test:integration
|
|
152
|
+
npm run test:system
|
|
153
|
+
|
|
154
|
+
# Real end-to-end tests against a running server
|
|
155
|
+
npm run test:e2e:real
|
|
156
|
+
|
|
157
|
+
# Type checking, all tests, and a production build
|
|
158
|
+
npm run check
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
`test:e2e:real` uses `http://127.0.0.1:13210/api` by default. Set `E2E_BASE_URL` when the server runs elsewhere:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
E2E_BASE_URL=http://127.0.0.1:13211/api npm run test:e2e:real
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Project Structure
|
|
168
|
+
|
|
169
|
+
```text
|
|
170
|
+
src/
|
|
171
|
+
ai.ts AI calls, context building, and task orchestration
|
|
172
|
+
app.ts Express API and static UI entry point
|
|
173
|
+
database.ts SQLite schema and migrations
|
|
174
|
+
parser.ts TXT/DOCX novel structure parser
|
|
175
|
+
server.ts Server startup and shutdown
|
|
176
|
+
store.ts Application data access
|
|
177
|
+
public/ Browser UI and visualizations
|
|
178
|
+
tests/
|
|
179
|
+
unit/ Unit tests
|
|
180
|
+
integration/ API and data integration tests
|
|
181
|
+
system/ Complete author workflow tests
|
|
182
|
+
e2e/ End-to-end tests against a running server
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Health Check
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
curl http://127.0.0.1:13210/api/health
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Expected response:
|
|
192
|
+
|
|
193
|
+
```json
|
|
194
|
+
{
|
|
195
|
+
"data": {
|
|
196
|
+
"status": "ok",
|
|
197
|
+
"version": "0.2.0",
|
|
198
|
+
"protocol": "openai-chat-completions"
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Project Status
|
|
204
|
+
|
|
205
|
+
Scriverse is currently an MVP. APIs and data structures may still change. Back up the `.data` directory before upgrading.
|
|
206
|
+
|
|
207
|
+
## 🌟 Special Thanks
|
|
208
|
+
|
|
209
|
+
<p align="center">
|
|
210
|
+
<a href="https://linux.do">
|
|
211
|
+
<img src="showcase/public/linuxdo.png" alt="LINUX DO" width="420" />
|
|
212
|
+
</a>
|
|
213
|
+
</p>
|
|
214
|
+
<p align="center"><b>学AI,上L站!祝小破站越来越好~</b></p>
|
package/README.md
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://scriverse.top/">
|
|
3
|
+
<img src="./showcase/public/favicon.svg" alt="叙界 Scriverse" width="96">
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<h1 align="center">叙界 Scriverse</h1>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
面向长篇小说创作的本地 AI 工作台
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<a href="README.md">中文</a> | <a href="README.en.md">English</a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p align="center">
|
|
18
|
+
在线演示:<a href="https://scriverse.top/">https://scriverse.top/</a>
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
<p align="center">
|
|
22
|
+
<a href="https://scriverse.top/">
|
|
23
|
+
<img src="./showcase/public/scriverse-overview.png" alt="叙界 Scriverse:让宏大的故事,有迹可循" width="100%">
|
|
24
|
+
</a>
|
|
25
|
+
</p>
|
|
26
|
+
|
|
27
|
+
<p align="center">
|
|
28
|
+
叙界是一个面向长篇小说的本地 AI 创作工作台。它把正文、分卷、角色、组织、世界设定、时间线、人物关系、大纲伏笔和 AI 辅助集中在同一个项目中,适合管理大体量、设定密集的小说工程。
|
|
29
|
+
</p>
|
|
30
|
+
|
|
31
|
+
## 主要能力
|
|
32
|
+
|
|
33
|
+
- 作品书架:管理多部作品、封面、作者和简介。
|
|
34
|
+
- 正文编辑:分卷与章节树、自动保存、历史版本、行号引用、空行整理和全文检索。
|
|
35
|
+
- 章节分类:支持正文、设定、作者的话和其他四种类型。
|
|
36
|
+
- 文件导入:导入 TXT 或 DOCX,识别分卷、章节和后记类型。
|
|
37
|
+
- 设定库:管理世界设定、角色别名、角色属性与锁定字段。
|
|
38
|
+
- 组织系统:维护组织简介、设定列表和成员,一个角色可同时属于多个组织。
|
|
39
|
+
- 时间线:以看板方式管理多条大事件时间轨道,支持拆分、合并和排序。
|
|
40
|
+
- 人物关系:关系类型、关键词列表、证据与置信度,提供普通关系图和可交互的 3D 银河图。
|
|
41
|
+
- 大纲与伏笔:维护章节目标、冲突、转折和伏笔的埋设、提醒与回收。
|
|
42
|
+
- AI 创作助手:支持 Markdown 和流式输出,可引用章节行、附加角色与设定上下文。
|
|
43
|
+
- AI 任务:结构分析、章节分析、角色抽取、时间线分析、关系分析和一致性检查。
|
|
44
|
+
- 供应商管理:兼容 OpenAI Chat Completions 协议,可配置模型、最大输出 Token、并发数和 RPM。
|
|
45
|
+
- 安全导出:支持 JSON、TXT 和 Markdown,导出内容不包含 AI 密钥。
|
|
46
|
+
|
|
47
|
+
## 技术栈
|
|
48
|
+
|
|
49
|
+
- Node.js 22.5+
|
|
50
|
+
- TypeScript
|
|
51
|
+
- Express 5
|
|
52
|
+
- Node.js SQLite
|
|
53
|
+
- 原生 HTML、CSS 和 JavaScript
|
|
54
|
+
- Vitest 与 Supertest
|
|
55
|
+
|
|
56
|
+
## 快速开始
|
|
57
|
+
|
|
58
|
+
### 环境要求
|
|
59
|
+
|
|
60
|
+
- Node.js `>= 22.5.0`
|
|
61
|
+
- npm
|
|
62
|
+
|
|
63
|
+
### 安装与开发运行
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
git clone git@github.com:musnows/Scriverse.git
|
|
67
|
+
cd Scriverse
|
|
68
|
+
npm ci
|
|
69
|
+
npm run dev
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
默认访问地址:[http://localhost:13210](http://localhost:13210)
|
|
73
|
+
|
|
74
|
+
### 生产构建
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npm run build
|
|
78
|
+
npm start
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 命令行工具
|
|
82
|
+
|
|
83
|
+
CLI 用于连接已运行的 Scriverse 服务,查询或编辑作品数据。全局安装后可直接使用 `scriverse` 命令:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
npm install --global @musnows/scriverse
|
|
87
|
+
scriverse auth login --server https://your-scriverse.example.com --api-key-file ./api-key.txt
|
|
88
|
+
scriverse work list
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
使用 `scriverse --help` 查看认证、作品、正文、资源、历史版本和搜索等全部命令。CLI 要求 Node.js `>= 22.5.0`。
|
|
92
|
+
|
|
93
|
+
## 环境变量
|
|
94
|
+
|
|
95
|
+
| 变量 | 默认值 | 说明 |
|
|
96
|
+
| --- | --- | --- |
|
|
97
|
+
| `PORT` | `13210` | HTTP 服务端口 |
|
|
98
|
+
| `HOST` | `127.0.0.1` | 监听地址;服务器部署时可设为 `0.0.0.0` |
|
|
99
|
+
| `DATA_DIR` | `<项目目录>/.data` | 默认数据目录 |
|
|
100
|
+
| `DATABASE_PATH` | `<DATA_DIR>/novel.db` | SQLite 数据库路径 |
|
|
101
|
+
| `AI_NOVEL_MASTER_KEY` | 自动生成并保存在 `<DATA_DIR>/master.key` | 加密 AI 供应商密钥的主密钥 |
|
|
102
|
+
| `APP_AUTH_USERNAME` | 空 | 可选的部署网关账号;应用内用户系统始终启用 |
|
|
103
|
+
| `APP_AUTH_PASSWORD` | 空 | 可选的部署网关密码,至少 12 个字符;必须通过 HTTPS 传输 |
|
|
104
|
+
| `APP_TRUST_PROXY` | `false` | 位于可信反向代理后时设为代理跳数(通常为 `1`)或 `true` |
|
|
105
|
+
| `APP_ALLOW_PRIVATE_AI_ENDPOINTS` | 开发环境 `true`,生产环境 `false` | 是否允许 AI 供应商连接本机或内网地址;链路本地与云元数据地址始终禁止 |
|
|
106
|
+
| `APP_ALLOW_REGISTRATION` | `true` | 设为 `false` 时关闭开放注册(仍允许首次初始化创建管理员);公网 nginx 反代部署建议关闭 |
|
|
107
|
+
|
|
108
|
+
自定义示例:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
PORT=13211 DATA_DIR=/path/to/scriverse-data npm run dev
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
服务器部署示例:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
NODE_ENV=production \
|
|
118
|
+
HOST=0.0.0.0 \
|
|
119
|
+
APP_AUTH_USERNAME=admin \
|
|
120
|
+
APP_AUTH_PASSWORD='请替换为足够长的随机密码' \
|
|
121
|
+
npm start
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
生产环境必须在可信反向代理后启用 HTTPS。应用首次启动时,第一个注册用户自动成为系统管理员;后续用户为普通用户。可选的 HTTP Basic Auth 仅作为额外部署网关,其凭据只是 Base64 编码,未使用 HTTPS 时不能防止链路窃听。`/api/health` 保持免认证以供探活,业务 API 需要应用内登录。
|
|
125
|
+
|
|
126
|
+
## AI 供应商配置
|
|
127
|
+
|
|
128
|
+
1. 启动项目后,点击顶部“AI 管理”进入平台级配置。
|
|
129
|
+
2. 新建兼容 OpenAI Chat Completions 的供应商,填写基础地址、API 密钥、并发数、RPM 与最大输出 Token。
|
|
130
|
+
3. 为模型填写其支持的上下文总量(Token),再添加模型。
|
|
131
|
+
4. 在平台页设置全局系统提示词;它会追加在内置提示词之后。
|
|
132
|
+
5. 打开一本作品,在“更多 → AI 设置”中设置该书的追加系统提示词和任务默认模型;书籍提示词会追加在全局提示词之后。
|
|
133
|
+
|
|
134
|
+
新建供应商默认最大并发请求数和 RPM 均为 `10`,默认最大输出 Token 为 `32000`;新建模型默认上下文容量为 `128000` Token。侧栏对话框会显示当前请求的上下文用量圆环。
|
|
135
|
+
|
|
136
|
+
## 数据与安全
|
|
137
|
+
|
|
138
|
+
- 数据默认保存在 `.data/novel.db`。
|
|
139
|
+
- AI 供应商密钥经加密后存储,主密钥默认位于 `.data/master.key`。
|
|
140
|
+
- 备份或迁移时,请同时保存数据库和主密钥;丢失主密钥后无法解密已保存的供应商密钥。
|
|
141
|
+
- 项目不包含用户系统;服务器部署使用环境变量配置的单实例 HTTP Basic Auth。生产环境缺少凭据时会拒绝启动。
|
|
142
|
+
- 服务默认只监听 `127.0.0.1`。非本机监听同样强制要求鉴权,公网入口必须使用 HTTPS、可信反向代理和防火墙访问控制。
|
|
143
|
+
- 应用默认启用 CSP、防点击劫持、MIME 嗅探防护、同源写请求校验、认证失败限速、API 限速、JSON/上传大小限制和 AI 供应商 SSRF 防护。
|
|
144
|
+
- SQLite 查询通过 prepared statements 绑定参数;动态 SQL 片段只来自服务端受控枚举,不拼接用户输入。
|
|
145
|
+
|
|
146
|
+
## 测试
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# 类型检查
|
|
150
|
+
npm run typecheck
|
|
151
|
+
|
|
152
|
+
# 全部 Vitest 测试
|
|
153
|
+
npm test
|
|
154
|
+
|
|
155
|
+
# 单元、集成和系统测试
|
|
156
|
+
npm run test:unit
|
|
157
|
+
npm run test:integration
|
|
158
|
+
npm run test:system
|
|
159
|
+
|
|
160
|
+
# 针对已启动服务的真实 E2E 测试
|
|
161
|
+
npm run test:e2e:real
|
|
162
|
+
|
|
163
|
+
# 类型检查、全部测试和生产构建
|
|
164
|
+
npm run check
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
`test:e2e:real` 默认访问 `http://127.0.0.1:13210/api`。如果服务运行在其他地址,可以设置 `E2E_BASE_URL`:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
E2E_BASE_URL=http://127.0.0.1:13211/api npm run test:e2e:real
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## 项目结构
|
|
174
|
+
|
|
175
|
+
```text
|
|
176
|
+
src/
|
|
177
|
+
ai.ts AI 调用、上下文构建与任务编排
|
|
178
|
+
app.ts Express API 与静态界面入口
|
|
179
|
+
database.ts SQLite 表结构与迁移
|
|
180
|
+
parser.ts TXT/DOCX 小说结构解析
|
|
181
|
+
server.ts 服务启动与关闭
|
|
182
|
+
store.ts 业务数据存取
|
|
183
|
+
public/ 浏览器端界面与可视化
|
|
184
|
+
tests/
|
|
185
|
+
unit/ 单元测试
|
|
186
|
+
integration/ API 与数据集成测试
|
|
187
|
+
system/ 完整作者流程测试
|
|
188
|
+
e2e/ 针对运行服务的端到端测试
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## 健康检查
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
curl http://127.0.0.1:13210/api/health
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
正常响应示例:
|
|
198
|
+
|
|
199
|
+
```json
|
|
200
|
+
{
|
|
201
|
+
"data": {
|
|
202
|
+
"status": "ok",
|
|
203
|
+
"version": "0.2.0",
|
|
204
|
+
"protocol": "openai-chat-completions"
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## 项目状态
|
|
210
|
+
|
|
211
|
+
当前为 MVP 版本,接口和数据结构仍可能调整。升级前请备份 `.data` 目录。
|
|
212
|
+
|
|
213
|
+
## 🌟 Special Thanks
|
|
214
|
+
|
|
215
|
+
<p align="center">
|
|
216
|
+
<a href="https://linux.do">
|
|
217
|
+
<img src="showcase/public/linuxdo.png" alt="LINUX DO" width="420" />
|
|
218
|
+
</a>
|
|
219
|
+
</p>
|
|
220
|
+
<p align="center"><b>学AI,上L站!祝小破站越来越好~</b></p>
|