feat(#130): add Personality Prisma schema and backend

Implement Personality system backend with database schema, service,
controller, and comprehensive tests. Personalities define assistant
behavior with system prompts and LLM configuration.

Changes:
- Update Personality model in schema.prisma with LLM provider relation
- Create PersonalitiesService with CRUD and default management
- Create PersonalitiesController with REST endpoints
- Add DTOs with validation (create/update)
- Add entity for type safety
- Remove unused PromptFormatterService
- Achieve 26 tests with full coverage

Endpoints:
- GET /personality - List all
- GET /personality/default - Get default
- GET /personality/by-name/:name - Get by name
- GET /personality/:id - Get one
- POST /personality - Create
- PATCH /personality/:id - Update
- DELETE /personality/:id - Delete
- POST /personality/:id/set-default - Set default

Fixes #130

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-31 12:44:50 -06:00
parent 1f97e6de40
commit 64cb5c1edd
12 changed files with 516 additions and 549 deletions

View File

@@ -1,37 +1,53 @@
import { IsString, IsIn, IsOptional, IsBoolean, MinLength, MaxLength } from "class-validator";
export const FORMALITY_LEVELS = [
"VERY_CASUAL",
"CASUAL",
"NEUTRAL",
"FORMAL",
"VERY_FORMAL",
] as const;
export type FormalityLevel = (typeof FORMALITY_LEVELS)[number];
import {
IsString,
IsOptional,
IsBoolean,
IsNumber,
IsInt,
IsUUID,
MinLength,
MaxLength,
Min,
Max,
} from "class-validator";
/**
* DTO for creating a new personality/assistant configuration
*/
export class CreatePersonalityDto {
@IsString()
@MinLength(1)
@MaxLength(100)
name!: string;
@IsOptional()
@IsString()
@MaxLength(500)
description?: string;
name!: string; // unique identifier slug
@IsString()
@MinLength(1)
@MaxLength(50)
tone!: string;
@MaxLength(200)
displayName!: string; // human-readable name
@IsIn(FORMALITY_LEVELS)
formalityLevel!: FormalityLevel;
@IsOptional()
@IsString()
@MaxLength(1000)
description?: string;
@IsString()
@MinLength(10)
systemPromptTemplate!: string;
systemPrompt!: string;
@IsOptional()
@IsNumber()
@Min(0)
@Max(2)
temperature?: number; // null = use provider default
@IsOptional()
@IsInt()
@Min(1)
maxTokens?: number; // null = use provider default
@IsOptional()
@IsUUID("4")
llmProviderInstanceId?: string; // FK to LlmProviderInstance
@IsOptional()
@IsBoolean()
@@ -39,5 +55,5 @@ export class CreatePersonalityDto {
@IsOptional()
@IsBoolean()
isActive?: boolean;
isEnabled?: boolean;
}

View File

@@ -1,32 +1,56 @@
import { IsString, IsOptional, IsBoolean, MinLength, MaxLength, IsIn } from "class-validator";
import { FORMALITY_LEVELS, FormalityLevel } from "./create-personality.dto";
import {
IsString,
IsOptional,
IsBoolean,
IsNumber,
IsInt,
IsUUID,
MinLength,
MaxLength,
Min,
Max,
} from "class-validator";
/**
* DTO for updating an existing personality/assistant configuration
*/
export class UpdatePersonalityDto {
@IsOptional()
@IsString()
@MinLength(1)
@MaxLength(100)
name?: string;
@IsOptional()
@IsString()
@MaxLength(500)
description?: string;
name?: string; // unique identifier slug
@IsOptional()
@IsString()
@MinLength(1)
@MaxLength(50)
tone?: string;
@MaxLength(200)
displayName?: string; // human-readable name
@IsOptional()
@IsIn(FORMALITY_LEVELS)
formalityLevel?: FormalityLevel;
@IsString()
@MaxLength(1000)
description?: string;
@IsOptional()
@IsString()
@MinLength(10)
systemPromptTemplate?: string;
systemPrompt?: string;
@IsOptional()
@IsNumber()
@Min(0)
@Max(2)
temperature?: number; // null = use provider default
@IsOptional()
@IsInt()
@Min(1)
maxTokens?: number; // null = use provider default
@IsOptional()
@IsUUID("4")
llmProviderInstanceId?: string; // FK to LlmProviderInstance
@IsOptional()
@IsBoolean()
@@ -34,5 +58,5 @@ export class UpdatePersonalityDto {
@IsOptional()
@IsBoolean()
isActive?: boolean;
isEnabled?: boolean;
}