规定数据类型

This commit is contained in:
2026-04-24 01:45:41 +08:00
parent d1943f564a
commit 35eff3faf6
86 changed files with 3809 additions and 0 deletions

10
server/nest-cli.json Normal file
View File

@@ -0,0 +1,10 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true,
"webpack": false,
"tsConfigPath": "tsconfig.json"
}
}

54
server/package.json Normal file
View File

@@ -0,0 +1,54 @@
{
"name": "@sillytavern-repalice/server",
"version": "1.0.0",
"description": "Backend server for SillyTavern Repalice",
"scripts": {
"build": "nest build",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@nestjs/common": "^10.3.0",
"@nestjs/core": "^10.3.0",
"@nestjs/platform-express": "^10.3.0",
"@nestjs/config": "^3.1.1",
"reflect-metadata": "^0.1.14",
"rxjs": "^7.8.1",
"zod": "^3.22.4",
"ai": "^4.0.0",
"@ai-sdk/openai": "^1.0.0",
"@ai-sdk/anthropic": "^1.0.0",
"uuid": "^9.0.1",
"multer": "^1.4.5-lts.1"
},
"devDependencies": {
"@nestjs/cli": "^10.3.0",
"@nestjs/schematics": "^10.1.0",
"@nestjs/testing": "^10.3.0",
"@types/express": "^4.17.21",
"@types/jest": "^29.5.11",
"@types/multer": "^1.4.11",
"@types/node": "^20.10.6",
"@types/uuid": "^9.0.7",
"@typescript-eslint/eslint-plugin": "^6.17.0",
"@typescript-eslint/parser": "^6.17.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.2",
"jest": "^29.7.0",
"prettier": "^3.1.1",
"source-map-support": "^0.5.21",
"ts-jest": "^29.1.1",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.3.3"
}
}

1
server/src/.gitkeep Normal file
View File

@@ -0,0 +1 @@
# NestJS Backend Directory Structure

View File

@@ -0,0 +1 @@
// Controllers will be placed here

View File

@@ -0,0 +1 @@
// Configuration Management will be placed here

View File

@@ -0,0 +1 @@
// Dependency Injection Tokens will be placed here

View File

@@ -0,0 +1 @@
// Exception Filters will be placed here

View File

@@ -0,0 +1 @@
// Guards and Middleware will be placed here

View File

@@ -0,0 +1 @@
// Request/Response Interceptors will be placed here

View File

@@ -0,0 +1 @@
// Utility Functions and Helpers will be placed here

1
server/src/dto/.gitkeep Normal file
View File

@@ -0,0 +1 @@
// DTOs and Validation will be placed here

View File

@@ -0,0 +1 @@
// Interfaces for Dependency Injection will be placed here

1
server/src/llm/.gitkeep Normal file
View File

@@ -0,0 +1 @@
// Vercel AI SDK integration will be placed here

View File

@@ -0,0 +1 @@
// LLM Providers (OpenAI, Claude, Local, etc.) will be placed here

View File

@@ -0,0 +1 @@
// LLM Tools and Function Calling will be placed here

View File

@@ -0,0 +1 @@
// Character Module will be placed here

View File

@@ -0,0 +1,10 @@
import { Module } from '@nestjs/common';
import { CharacterController } from '../../controllers/character.controller';
import { CharacterService } from '../../services/character.service';
@Module({
controllers: [CharacterController],
providers: [CharacterService],
exports: [CharacterService],
})
export class CharacterModule {}

View File

@@ -0,0 +1 @@
// Chat Module will be placed here

View File

@@ -0,0 +1,10 @@
import { Module } from '@nestjs/common';
import { ChatController } from '../../controllers/chat.controller';
import { ChatService } from '../../services/chat.service';
@Module({
controllers: [ChatController],
providers: [ChatService],
exports: [ChatService],
})
export class ChatModule {}

View File

@@ -0,0 +1 @@
// Import/Export Module will be placed here

View File

@@ -0,0 +1,7 @@
import { Module } from '@nestjs/common';
import { ImportExportController } from '../../controllers/import-export.controller';
@Module({
controllers: [ImportExportController],
})
export class ImportExportModule {}

View File

@@ -0,0 +1 @@
// LLM Module will be placed here

View File

@@ -0,0 +1,7 @@
import { Module } from '@nestjs/common';
import { LLMController } from '../../controllers/llm.controller';
@Module({
controllers: [LLMController],
})
export class LLMModule {}

View File

@@ -0,0 +1 @@
// Workflow Module will be placed here

View File

@@ -0,0 +1,6 @@
import { Module } from '@nestjs/common';
@Module({
imports: [],
})
export class WorkflowModule {}

View File

@@ -0,0 +1 @@
// Persistence Module will be placed here

View File

@@ -0,0 +1 @@
// File System Implementations will be placed here

View File

@@ -0,0 +1 @@
// Repository Interfaces will be placed here

View File

@@ -0,0 +1 @@
// Data Migration Scripts will be placed here

View File

@@ -0,0 +1 @@
// Services (Business Logic) will be placed here

View File

@@ -0,0 +1 @@
// Context Management and Chunking will be placed here

View File

@@ -0,0 +1 @@
// Prompt Assembly and Templates will be placed here

View File

@@ -0,0 +1 @@
// Token Counting and Estimation will be placed here

View File

@@ -0,0 +1 @@
// Workflow Engine will be placed here

1
server/test/e2e/.gitkeep Normal file
View File

@@ -0,0 +1 @@
// E2E Tests will be placed here

View File

@@ -0,0 +1 @@
// Integration Tests will be placed here

View File

@@ -0,0 +1 @@
// Unit Tests will be placed here

28
server/tsconfig.json Normal file
View File

@@ -0,0 +1,28 @@
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "ES2021",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
"skipLibCheck": true,
"strictNullChecks": true,
"noImplicitAny": false,
"strictBindCallApply": false,
"forceConsistentCasingInFileNames": false,
"noFallthroughCasesInSwitch": false,
"paths": {
"@shared/*": ["../shared/*"],
"@modules/*": ["./src/modules/*"],
"@core/*": ["./src/core/*"]
}
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "test"]
}