feat(#82): add prompt formatter service to personality module

- Add PromptFormatterService for formatting system prompts based on personality
- Support context variable interpolation (userName, workspaceName, etc.)
- Add formality level modifiers (VERY_CASUAL to VERY_FORMAL)
- Add template validation for custom variables
- Add preview endpoint for formatted prompts
- Fix UpdatePersonalityDto to avoid @nestjs/mapped-types dependency
- Update PersonalitiesController with new endpoints
- Add comprehensive tests (33 passing tests)

Closes #82
This commit is contained in:
Jason Woltje
2026-01-29 19:38:18 -06:00
parent 1cb54b56b0
commit 8383a98070
7 changed files with 374 additions and 99 deletions

View File

@@ -1,4 +1,38 @@
import { PartialType } from "@nestjs/mapped-types";
import { CreatePersonalityDto } from "./create-personality.dto";
import { IsString, IsOptional, IsBoolean, MinLength, MaxLength, IsIn } from "class-validator";
import { FORMALITY_LEVELS, FormalityLevelType } from "./create-personality.dto";
export class UpdatePersonalityDto extends PartialType(CreatePersonalityDto) {}
export class UpdatePersonalityDto {
@IsOptional()
@IsString()
@MinLength(1)
@MaxLength(100)
name?: string;
@IsOptional()
@IsString()
@MaxLength(500)
description?: string;
@IsOptional()
@IsString()
@MinLength(1)
@MaxLength(50)
tone?: string;
@IsOptional()
@IsIn(FORMALITY_LEVELS)
formalityLevel?: FormalityLevelType;
@IsOptional()
@IsString()
@MinLength(10)
systemPromptTemplate?: string;
@IsOptional()
@IsBoolean()
isDefault?: boolean;
@IsOptional()
@IsBoolean()
isActive?: boolean;
}