-
Notifications
You must be signed in to change notification settings - Fork 0
feat: prompt library + {{placeholder}} templating #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
leon0399
wants to merge
18
commits into
master
Choose a base branch
from
stack/split-prompt-library
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
56ab178
feat: prompt library — saved prompts with `/` composer access
leon0399 62446c1
feat(web): prompt templating — {{placeholder}} variables
leon0399 f92c884
chore(api): regenerate openapi.json for the prompts routes
leon0399 cf8dca9
Merge remote-tracking branch 'origin/master' into stack/split-prompt-…
leon0399 9664c15
fix(api): harden prompt writes and give prompts its own module
leon0399 ed0bb5d
fix(web): guard prompt composer Enter-handling against IME composition
leon0399 f4632f7
fix(web): accurate prompt-save errors and client-side name-length check
leon0399 71799e0
docs: fix prompt-library design doc's stale templating non-goal
leon0399 db8827d
chore(api): regenerate openapi.json after the PromptsModule extraction
leon0399 5f0e8d6
docs: correct prompts RLS test count in changelog (5 -> 7)
leon0399 0d6d162
fix(api): widen the prompt-cap advisory lock key to 64 bits
leon0399 e9a5596
chore(deps): move sonner into the pnpm-workspace catalog
leon0399 f41e478
Merge origin/master into stack/split-prompt-library
leon0399 b474693
Merge origin/master into stack/split-prompt-library
leon0399 14980c3
Merge origin/master into stack/split-prompt-library
leon0399 c2e3559
Merge origin/master into stack/split-prompt-library
leon0399 9a821b9
chore(api): regenerate openapi.json after merge
leon0399 c840d93
Merge origin/master into stack/split-prompt-library
leon0399 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; | ||
| import { | ||
| IsOptional, | ||
| IsString, | ||
| Matches, | ||
| MaxLength, | ||
| MinLength, | ||
| } from 'class-validator'; | ||
|
|
||
| import { | ||
| PROMPT_CONTENT_MAX, | ||
| PROMPT_NAME_MAX, | ||
| type Prompt, | ||
| } from '../../db/schema'; | ||
|
|
||
| // The slash trigger: a slug (no whitespace/slashes) so `/<name>` is exact. | ||
| const NAME_PATTERN = /^[A-Za-z0-9_-]+$/; | ||
| const NAME_MESSAGE = | ||
| 'name must be a slug: letters, digits, underscore or hyphen (no spaces)'; | ||
|
|
||
| export class CreatePromptDto { | ||
| @ApiProperty({ maxLength: PROMPT_NAME_MAX, pattern: NAME_PATTERN.source }) | ||
| @IsString() | ||
| @Matches(NAME_PATTERN, { message: NAME_MESSAGE }) | ||
| @MaxLength(PROMPT_NAME_MAX) | ||
| name!: string; | ||
|
|
||
| @ApiProperty({ minLength: 1, maxLength: PROMPT_CONTENT_MAX }) | ||
| @IsString() | ||
| @MinLength(1) | ||
| @MaxLength(PROMPT_CONTENT_MAX) | ||
| content!: string; | ||
| } | ||
|
|
||
| export class UpdatePromptDto { | ||
| @ApiPropertyOptional({ | ||
| maxLength: PROMPT_NAME_MAX, | ||
| pattern: NAME_PATTERN.source, | ||
| }) | ||
| @IsOptional() | ||
| @IsString() | ||
| @Matches(NAME_PATTERN, { message: NAME_MESSAGE }) | ||
| @MaxLength(PROMPT_NAME_MAX) | ||
| name?: string; | ||
|
|
||
| @ApiPropertyOptional({ minLength: 1, maxLength: PROMPT_CONTENT_MAX }) | ||
| @IsOptional() | ||
| @IsString() | ||
| @MinLength(1) | ||
| @MaxLength(PROMPT_CONTENT_MAX) | ||
| content?: string; | ||
| } | ||
|
|
||
| export class PromptResponse { | ||
| @ApiProperty({ format: 'uuid' }) | ||
| id!: string; | ||
|
|
||
| @ApiProperty({ maxLength: PROMPT_NAME_MAX }) | ||
| name!: string; | ||
|
|
||
| @ApiProperty({ maxLength: PROMPT_CONTENT_MAX }) | ||
| content!: string; | ||
|
|
||
| @ApiProperty({ format: 'date-time' }) | ||
| createdAt!: Date; | ||
|
|
||
| @ApiProperty({ format: 'date-time' }) | ||
| updatedAt!: Date; | ||
| } | ||
|
|
||
| export function toPromptResponse(prompt: Prompt): PromptResponse { | ||
| return { | ||
| id: prompt.id, | ||
| name: prompt.name, | ||
| content: prompt.content, | ||
| createdAt: prompt.createdAt, | ||
| updatedAt: prompt.updatedAt, | ||
| }; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.