chore(package): update prompts.chat version to 0.0.6
This commit is contained in:
Generated
+4
-4
@@ -45,7 +45,7 @@
|
||||
"next-themes": "^0.4.6",
|
||||
"openai": "^6.10.0",
|
||||
"pino": "^10.1.0",
|
||||
"prompts.chat": "^0.0.5",
|
||||
"prompts.chat": "^0.0.6",
|
||||
"react": "19.2.0",
|
||||
"react-dom": "19.2.0",
|
||||
"react-hook-form": "^7.68.0",
|
||||
@@ -12930,9 +12930,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/prompts.chat": {
|
||||
"version": "0.0.5",
|
||||
"resolved": "https://registry.npmjs.org/prompts.chat/-/prompts.chat-0.0.5.tgz",
|
||||
"integrity": "sha512-fwS+292m+qmAU86T8lZIKWqwMHh+REP7m5O5NMSo3yQkYN0Q/u2tuLG8CgCKs8Jqw3GWWcXG6eNg26yBJCtwsg==",
|
||||
"version": "0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/prompts.chat/-/prompts.chat-0.0.6.tgz",
|
||||
"integrity": "sha512-6CYNhGY0dqabXTu06HfI3Wum5Wsqb0yjJEQcKoDs16MfMXaMZRJe+mCGztxUiy3TnPuiuXeVCK2VzW5GAwdUQg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@
|
||||
"next-themes": "^0.4.6",
|
||||
"openai": "^6.10.0",
|
||||
"pino": "^10.1.0",
|
||||
"prompts.chat": "^0.0.5",
|
||||
"prompts.chat": "^0.0.6",
|
||||
"react": "19.2.0",
|
||||
"react-dom": "19.2.0",
|
||||
"react-hook-form": "^7.68.0",
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "prompts.chat",
|
||||
"version": "0.0.5",
|
||||
"version": "0.0.6",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "prompts.chat",
|
||||
"version": "0.0.5",
|
||||
"version": "0.0.6",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/node": "^20",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "prompts.chat",
|
||||
"version": "0.0.5",
|
||||
"version": "0.0.6",
|
||||
"description": "Developer toolkit for AI prompts - build, validate, parse, and connect to prompts.chat",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
|
||||
@@ -7,6 +7,11 @@
|
||||
import * as ts from 'typescript';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { dirname } from 'path';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
interface DocEntry {
|
||||
name: string;
|
||||
@@ -252,6 +257,58 @@ function parseVariableStatement(node: ts.VariableStatement, sourceFile: ts.Sourc
|
||||
}
|
||||
}
|
||||
|
||||
// Parse object literal properties (methods) for objects like `templates`
|
||||
const methods: DocEntry[] = [];
|
||||
if (decl.initializer && ts.isObjectLiteralExpression(decl.initializer)) {
|
||||
for (const prop of decl.initializer.properties) {
|
||||
if (ts.isPropertyAssignment(prop) && prop.name) {
|
||||
const propName = prop.name.getText(sourceFile);
|
||||
const { description: propDesc, tags: propTags, examples: propExamples } = getJSDocComment(prop, sourceFile);
|
||||
|
||||
// Handle arrow functions and function expressions
|
||||
if (ts.isArrowFunction(prop.initializer) || ts.isFunctionExpression(prop.initializer)) {
|
||||
const fn = prop.initializer;
|
||||
const params: Array<{ name: string; type: string; description?: string; optional?: boolean; defaultValue?: string }> = [];
|
||||
|
||||
for (const param of fn.parameters) {
|
||||
const paramName = param.name.getText(sourceFile);
|
||||
const paramType = getTypeString(param.type, sourceFile);
|
||||
const optional = !!param.questionToken || !!param.initializer;
|
||||
const defaultValue = param.initializer?.getText(sourceFile);
|
||||
|
||||
params.push({
|
||||
name: paramName,
|
||||
type: paramType,
|
||||
description: propTags[`param:${paramName}`],
|
||||
optional,
|
||||
defaultValue,
|
||||
});
|
||||
}
|
||||
|
||||
const returnType = getTypeString(fn.type, sourceFile);
|
||||
const paramSignature = params
|
||||
.map(p => `${p.name}${p.optional ? '?' : ''}: ${p.type}`)
|
||||
.join(', ');
|
||||
const methodSignature = `${propName}(${paramSignature}): ${returnType}`;
|
||||
|
||||
methods.push({
|
||||
name: propName,
|
||||
kind: 'method',
|
||||
description: propDesc,
|
||||
signature: methodSignature,
|
||||
parameters: params,
|
||||
returnType,
|
||||
examples: propExamples,
|
||||
tags: propTags,
|
||||
});
|
||||
}
|
||||
} else if (ts.isMethodDeclaration(prop) && prop.name) {
|
||||
const methodDoc = parseFunction(prop, sourceFile, checker);
|
||||
methods.push(methodDoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
entries.push({
|
||||
name,
|
||||
kind: 'variable',
|
||||
@@ -259,6 +316,7 @@ function parseVariableStatement(node: ts.VariableStatement, sourceFile: ts.Sourc
|
||||
signature,
|
||||
examples,
|
||||
tags,
|
||||
methods: methods.length > 0 ? methods : undefined,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -657,6 +715,26 @@ function generateSidebarTS(modules: ModuleDoc[]): string {
|
||||
signature: ${JSON.stringify(v.signature || '')},
|
||||
description: ${JSON.stringify(v.description || '')},
|
||||
}`);
|
||||
|
||||
// Add methods from object literals (like templates)
|
||||
if (v.methods) {
|
||||
for (const method of v.methods) {
|
||||
const params = method.parameters?.map(p => ({
|
||||
name: p.name,
|
||||
type: p.type,
|
||||
description: p.description || undefined,
|
||||
})) || [];
|
||||
|
||||
items.push(` {
|
||||
name: "${v.name}.${method.name}()",
|
||||
type: "method",
|
||||
signature: ${JSON.stringify(method.signature || method.name)},
|
||||
description: ${JSON.stringify(method.description || '')},
|
||||
returns: ${JSON.stringify(method.returnType || '')},
|
||||
params: ${JSON.stringify(params)},
|
||||
}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -798,6 +876,28 @@ function generateTypeDefinitions(modules: ModuleDoc[]): string {
|
||||
processModule(videoModule, 'VIDEO BUILDER TYPES');
|
||||
processModule(mediaModule, 'IMAGE BUILDER TYPES');
|
||||
|
||||
// Generate templates namespace from object literal methods
|
||||
if (builderModule) {
|
||||
const templatesVar = builderModule.exports.find(e => e.kind === 'variable' && e.name === 'templates');
|
||||
if (templatesVar && templatesVar.methods && templatesVar.methods.length > 0) {
|
||||
lines.push('');
|
||||
lines.push(' // TEMPLATES - Pre-built prompt templates');
|
||||
lines.push(' export const templates: {');
|
||||
for (const method of templatesVar.methods) {
|
||||
const sig = method.signature || `${method.name}(): PromptBuilder`;
|
||||
// Extract just the function signature part
|
||||
const funcMatch = sig.match(/^(\w+)\((.*?)\):\s*(.+)$/);
|
||||
if (funcMatch) {
|
||||
const [, name, params, returnType] = funcMatch;
|
||||
// Default to PromptBuilder for templates if return type is 'any'
|
||||
const actualReturnType = returnType === 'any' ? 'PromptBuilder' : returnType;
|
||||
lines.push(` ${name}: (${params}) => ${actualReturnType};`);
|
||||
}
|
||||
}
|
||||
lines.push(' };');
|
||||
}
|
||||
}
|
||||
|
||||
// Utility namespaces
|
||||
if (variablesModule) {
|
||||
lines.push('');
|
||||
|
||||
@@ -446,4 +446,317 @@ export const templates = {
|
||||
"Cite relevant parts of the context if applicable",
|
||||
]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a debugging prompt
|
||||
*/
|
||||
debug: (options: { language?: string; errorType?: string } = {}) => {
|
||||
const b = builder()
|
||||
.role("expert software debugger")
|
||||
.task("Analyze the code and error, identify the root cause, and provide a fix.")
|
||||
.variable("code", { required: true, description: "The code with the bug" })
|
||||
.variable("error", { required: false, description: "Error message or unexpected behavior" });
|
||||
|
||||
if (options.language) {
|
||||
b.context(`Debugging ${options.language} code.`);
|
||||
}
|
||||
|
||||
if (options.errorType) {
|
||||
b.context(`The error appears to be related to: ${options.errorType}`);
|
||||
}
|
||||
|
||||
return b
|
||||
.constraints([
|
||||
"Identify the root cause, not just symptoms",
|
||||
"Explain why the bug occurs",
|
||||
"Provide a working fix with explanation",
|
||||
])
|
||||
.output("1. Root cause analysis\n2. Explanation\n3. Fixed code\n4. Prevention tips");
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a writing assistant prompt
|
||||
*/
|
||||
write: (options: { type?: 'blog' | 'email' | 'essay' | 'story' | 'documentation'; tone?: string } = {}) => {
|
||||
const typeDescriptions: Record<string, string> = {
|
||||
blog: "engaging blog post",
|
||||
email: "professional email",
|
||||
essay: "well-structured essay",
|
||||
story: "creative story",
|
||||
documentation: "clear technical documentation",
|
||||
};
|
||||
|
||||
const b = builder()
|
||||
.role("skilled writer")
|
||||
.task(`Write a ${typeDescriptions[options.type || 'blog'] || 'piece of content'} based on the given topic or outline.`)
|
||||
.variable("topic", { required: true, description: "Topic or outline to write about" });
|
||||
|
||||
if (options.tone) {
|
||||
b.constraint(`Use a ${options.tone} tone throughout`);
|
||||
}
|
||||
|
||||
return b.constraints([
|
||||
"Use clear and engaging language",
|
||||
"Structure content logically",
|
||||
"Maintain consistent voice and style",
|
||||
]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an explanation/teaching prompt
|
||||
*/
|
||||
explain: (options: { level?: 'beginner' | 'intermediate' | 'expert'; useAnalogies?: boolean } = {}) => {
|
||||
const levelDescriptions: Record<string, string> = {
|
||||
beginner: "someone new to the topic with no prior knowledge",
|
||||
intermediate: "someone with basic understanding who wants to go deeper",
|
||||
expert: "an expert who wants technical precision and nuance",
|
||||
};
|
||||
|
||||
const b = builder()
|
||||
.role("expert teacher and communicator")
|
||||
.task("Explain the concept clearly and thoroughly.")
|
||||
.variable("concept", { required: true, description: "The concept to explain" });
|
||||
|
||||
if (options.level) {
|
||||
b.context(`Target audience: ${levelDescriptions[options.level]}`);
|
||||
}
|
||||
|
||||
if (options.useAnalogies) {
|
||||
b.constraint("Use relatable analogies and real-world examples");
|
||||
}
|
||||
|
||||
return b.constraints([
|
||||
"Break down complex ideas into digestible parts",
|
||||
"Build understanding progressively",
|
||||
"Anticipate and address common misconceptions",
|
||||
]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a data extraction prompt
|
||||
*/
|
||||
extract: (options: { format?: 'json' | 'csv' | 'table'; fields?: string[] } = {}) => {
|
||||
const b = builder()
|
||||
.role("data extraction specialist")
|
||||
.task("Extract structured data from the provided text.")
|
||||
.variable("text", { required: true, description: "Text to extract data from" });
|
||||
|
||||
if (options.fields && options.fields.length > 0) {
|
||||
b.context(`Fields to extract: ${options.fields.join(", ")}`);
|
||||
}
|
||||
|
||||
if (options.format) {
|
||||
b.output(`Return extracted data in ${options.format.toUpperCase()} format`);
|
||||
}
|
||||
|
||||
return b.constraints([
|
||||
"Extract only factual information present in the text",
|
||||
"Use null or empty values for missing fields",
|
||||
"Maintain consistent formatting",
|
||||
]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a brainstorming prompt
|
||||
*/
|
||||
brainstorm: (options: { count?: number; creative?: boolean } = {}) => {
|
||||
const b = builder()
|
||||
.role("creative strategist and ideation expert")
|
||||
.task("Generate diverse and innovative ideas based on the given topic or challenge.")
|
||||
.variable("topic", { required: true, description: "Topic or challenge to brainstorm about" });
|
||||
|
||||
if (options.count) {
|
||||
b.constraint(`Generate exactly ${options.count} ideas`);
|
||||
}
|
||||
|
||||
if (options.creative) {
|
||||
b.constraint("Include unconventional and out-of-the-box ideas");
|
||||
}
|
||||
|
||||
return b
|
||||
.constraints([
|
||||
"Ensure ideas are distinct and varied",
|
||||
"Consider different perspectives and approaches",
|
||||
"Make ideas actionable when possible",
|
||||
])
|
||||
.output("List each idea with a brief description and potential benefits");
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a code refactoring prompt
|
||||
*/
|
||||
refactor: (options: { goal?: 'readability' | 'performance' | 'maintainability' | 'all'; language?: string } = {}) => {
|
||||
const goalDescriptions: Record<string, string> = {
|
||||
readability: "improving code readability and clarity",
|
||||
performance: "optimizing performance and efficiency",
|
||||
maintainability: "enhancing maintainability and extensibility",
|
||||
all: "overall code quality improvement",
|
||||
};
|
||||
|
||||
const b = builder()
|
||||
.role("senior software engineer specializing in code quality")
|
||||
.task(`Refactor the code with focus on ${goalDescriptions[options.goal || 'all']}.`)
|
||||
.variable("code", { required: true, description: "Code to refactor" });
|
||||
|
||||
if (options.language) {
|
||||
b.context(`The code is written in ${options.language}.`);
|
||||
}
|
||||
|
||||
return b
|
||||
.constraints([
|
||||
"Preserve existing functionality",
|
||||
"Follow language best practices and idioms",
|
||||
"Explain each significant change",
|
||||
])
|
||||
.output("1. Refactored code\n2. List of changes made\n3. Explanation of improvements");
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an API documentation prompt
|
||||
*/
|
||||
apiDocs: (options: { style?: 'openapi' | 'markdown' | 'jsdoc'; includeExamples?: boolean } = {}) => {
|
||||
const b = builder()
|
||||
.role("technical documentation writer")
|
||||
.task("Generate comprehensive API documentation for the provided code or endpoint.")
|
||||
.variable("code", { required: true, description: "API code or endpoint definition" });
|
||||
|
||||
if (options.style) {
|
||||
b.output(`Format documentation in ${options.style.toUpperCase()} style`);
|
||||
}
|
||||
|
||||
if (options.includeExamples) {
|
||||
b.constraint("Include request/response examples for each endpoint");
|
||||
}
|
||||
|
||||
return b.constraints([
|
||||
"Document all parameters with types and descriptions",
|
||||
"Include error responses and status codes",
|
||||
"Be precise and developer-friendly",
|
||||
]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a unit test generation prompt
|
||||
*/
|
||||
unitTest: (options: { framework?: string; coverage?: 'basic' | 'comprehensive' } = {}) => {
|
||||
const b = builder()
|
||||
.role("test automation engineer")
|
||||
.task("Generate unit tests for the provided code.")
|
||||
.variable("code", { required: true, description: "Code to generate tests for" });
|
||||
|
||||
if (options.framework) {
|
||||
b.context(`Use ${options.framework} testing framework.`);
|
||||
}
|
||||
|
||||
const coverageConstraints = options.coverage === 'comprehensive'
|
||||
? ["Cover all code paths including edge cases", "Test error handling scenarios", "Include boundary value tests"]
|
||||
: ["Cover main functionality", "Include basic edge cases"];
|
||||
|
||||
return b
|
||||
.constraints([
|
||||
...coverageConstraints,
|
||||
"Write clear, descriptive test names",
|
||||
"Follow AAA pattern (Arrange, Act, Assert)",
|
||||
])
|
||||
.output("Complete, runnable test file");
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a commit message prompt
|
||||
*/
|
||||
commitMessage: (options: { style?: 'conventional' | 'simple'; includeBody?: boolean } = {}) => {
|
||||
const b = builder()
|
||||
.role("developer with excellent communication skills")
|
||||
.task("Generate a clear and descriptive commit message for the provided code changes.")
|
||||
.variable("diff", { required: true, description: "Git diff or description of changes" });
|
||||
|
||||
if (options.style === 'conventional') {
|
||||
b.constraints([
|
||||
"Follow Conventional Commits format (type(scope): description)",
|
||||
"Use appropriate type: feat, fix, docs, style, refactor, test, chore",
|
||||
]);
|
||||
}
|
||||
|
||||
if (options.includeBody) {
|
||||
b.constraint("Include a detailed body explaining the why behind changes");
|
||||
}
|
||||
|
||||
return b.constraints([
|
||||
"Keep subject line under 72 characters",
|
||||
"Use imperative mood (Add, Fix, Update, not Added, Fixed, Updated)",
|
||||
]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a code review comment prompt
|
||||
*/
|
||||
reviewComment: (options: { tone?: 'constructive' | 'direct'; severity?: boolean } = {}) => {
|
||||
const b = builder()
|
||||
.role("thoughtful code reviewer")
|
||||
.task("Write a helpful code review comment for the provided code snippet.")
|
||||
.variable("code", { required: true, description: "Code to comment on" })
|
||||
.variable("issue", { required: true, description: "The issue or improvement to address" });
|
||||
|
||||
if (options.tone === 'constructive') {
|
||||
b.constraint("Frame feedback positively and suggest improvements rather than just pointing out problems");
|
||||
}
|
||||
|
||||
if (options.severity) {
|
||||
b.constraint("Indicate severity level: nitpick, suggestion, important, or blocker");
|
||||
}
|
||||
|
||||
return b.constraints([
|
||||
"Be specific and actionable",
|
||||
"Explain the reasoning behind the suggestion",
|
||||
"Provide an example of the improved code when helpful",
|
||||
]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a regex generator prompt
|
||||
*/
|
||||
regex: (options: { flavor?: 'javascript' | 'python' | 'pcre' } = {}) => {
|
||||
const b = builder()
|
||||
.role("regex expert")
|
||||
.task("Create a regular expression that matches the described pattern.")
|
||||
.variable("pattern", { required: true, description: "Description of the pattern to match" })
|
||||
.variable("examples", { required: false, description: "Example strings that should match" });
|
||||
|
||||
if (options.flavor) {
|
||||
b.context(`Use ${options.flavor} regex flavor/syntax.`);
|
||||
}
|
||||
|
||||
return b
|
||||
.constraints([
|
||||
"Provide the regex pattern",
|
||||
"Explain each part of the pattern",
|
||||
"Include test cases showing matches and non-matches",
|
||||
])
|
||||
.output("1. Regex pattern\n2. Explanation\n3. Test cases");
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a SQL query prompt
|
||||
*/
|
||||
sql: (options: { dialect?: 'postgresql' | 'mysql' | 'sqlite' | 'mssql'; optimize?: boolean } = {}) => {
|
||||
const b = builder()
|
||||
.role("database expert")
|
||||
.task("Write an SQL query based on the requirements.")
|
||||
.variable("requirement", { required: true, description: "What the query should accomplish" })
|
||||
.variable("schema", { required: false, description: "Database schema or table definitions" });
|
||||
|
||||
if (options.dialect) {
|
||||
b.context(`Use ${options.dialect.toUpperCase()} syntax.`);
|
||||
}
|
||||
|
||||
if (options.optimize) {
|
||||
b.constraint("Optimize for performance and include index recommendations if applicable");
|
||||
}
|
||||
|
||||
return b.constraints([
|
||||
"Write clean, readable SQL",
|
||||
"Use appropriate JOINs and avoid N+1 patterns",
|
||||
"Include comments explaining complex logic",
|
||||
]);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -203,6 +203,134 @@ export const API_DOCS: ApiSection[] = [
|
||||
type: "const",
|
||||
signature: "templates",
|
||||
description: "",
|
||||
},
|
||||
{
|
||||
name: "templates.codeReview()",
|
||||
type: "method",
|
||||
signature: "codeReview(options?: { language?: string; focus?: string[] }): any",
|
||||
description: "Create a code review prompt",
|
||||
returns: "any",
|
||||
params: [{"name":"options","type":"{ language?: string; focus?: string[] }"}],
|
||||
},
|
||||
{
|
||||
name: "templates.translation()",
|
||||
type: "method",
|
||||
signature: "translation(from: string, to: string): any",
|
||||
description: "Create a translation prompt",
|
||||
returns: "any",
|
||||
params: [{"name":"from","type":"string"},{"name":"to","type":"string"}],
|
||||
},
|
||||
{
|
||||
name: "templates.summarize()",
|
||||
type: "method",
|
||||
signature: "summarize(options?: { maxLength?: number; style?: 'bullet' | 'paragraph' }): any",
|
||||
description: "Create a summarization prompt",
|
||||
returns: "any",
|
||||
params: [{"name":"options","type":"{ maxLength?: number; style?: 'bullet' | 'paragraph' }"}],
|
||||
},
|
||||
{
|
||||
name: "templates.qa()",
|
||||
type: "method",
|
||||
signature: "qa(context?: string): any",
|
||||
description: "Create a Q&A prompt",
|
||||
returns: "any",
|
||||
params: [{"name":"context","type":"string"}],
|
||||
},
|
||||
{
|
||||
name: "templates.debug()",
|
||||
type: "method",
|
||||
signature: "debug(options?: { language?: string; errorType?: string }): any",
|
||||
description: "Create a debugging prompt",
|
||||
returns: "any",
|
||||
params: [{"name":"options","type":"{ language?: string; errorType?: string }"}],
|
||||
},
|
||||
{
|
||||
name: "templates.write()",
|
||||
type: "method",
|
||||
signature: "write(options?: { type?: 'blog' | 'email' | 'essay' | 'story' | 'documentation'; tone?: string }): any",
|
||||
description: "Create a writing assistant prompt",
|
||||
returns: "any",
|
||||
params: [{"name":"options","type":"{ type?: 'blog' | 'email' | 'essay' | 'story' | 'documentation'; tone?: string }"}],
|
||||
},
|
||||
{
|
||||
name: "templates.explain()",
|
||||
type: "method",
|
||||
signature: "explain(options?: { level?: 'beginner' | 'intermediate' | 'expert'; useAnalogies?: boolean }): any",
|
||||
description: "Create an explanation/teaching prompt",
|
||||
returns: "any",
|
||||
params: [{"name":"options","type":"{ level?: 'beginner' | 'intermediate' | 'expert'; useAnalogies?: boolean }"}],
|
||||
},
|
||||
{
|
||||
name: "templates.extract()",
|
||||
type: "method",
|
||||
signature: "extract(options?: { format?: 'json' | 'csv' | 'table'; fields?: string[] }): any",
|
||||
description: "Create a data extraction prompt",
|
||||
returns: "any",
|
||||
params: [{"name":"options","type":"{ format?: 'json' | 'csv' | 'table'; fields?: string[] }"}],
|
||||
},
|
||||
{
|
||||
name: "templates.brainstorm()",
|
||||
type: "method",
|
||||
signature: "brainstorm(options?: { count?: number; creative?: boolean }): any",
|
||||
description: "Create a brainstorming prompt",
|
||||
returns: "any",
|
||||
params: [{"name":"options","type":"{ count?: number; creative?: boolean }"}],
|
||||
},
|
||||
{
|
||||
name: "templates.refactor()",
|
||||
type: "method",
|
||||
signature: "refactor(options?: { goal?: 'readability' | 'performance' | 'maintainability' | 'all'; language?: string }): any",
|
||||
description: "Create a code refactoring prompt",
|
||||
returns: "any",
|
||||
params: [{"name":"options","type":"{ goal?: 'readability' | 'performance' | 'maintainability' | 'all'; language?: string }"}],
|
||||
},
|
||||
{
|
||||
name: "templates.apiDocs()",
|
||||
type: "method",
|
||||
signature: "apiDocs(options?: { style?: 'openapi' | 'markdown' | 'jsdoc'; includeExamples?: boolean }): any",
|
||||
description: "Create an API documentation prompt",
|
||||
returns: "any",
|
||||
params: [{"name":"options","type":"{ style?: 'openapi' | 'markdown' | 'jsdoc'; includeExamples?: boolean }"}],
|
||||
},
|
||||
{
|
||||
name: "templates.unitTest()",
|
||||
type: "method",
|
||||
signature: "unitTest(options?: { framework?: string; coverage?: 'basic' | 'comprehensive' }): any",
|
||||
description: "Create a unit test generation prompt",
|
||||
returns: "any",
|
||||
params: [{"name":"options","type":"{ framework?: string; coverage?: 'basic' | 'comprehensive' }"}],
|
||||
},
|
||||
{
|
||||
name: "templates.commitMessage()",
|
||||
type: "method",
|
||||
signature: "commitMessage(options?: { style?: 'conventional' | 'simple'; includeBody?: boolean }): any",
|
||||
description: "Create a commit message prompt",
|
||||
returns: "any",
|
||||
params: [{"name":"options","type":"{ style?: 'conventional' | 'simple'; includeBody?: boolean }"}],
|
||||
},
|
||||
{
|
||||
name: "templates.reviewComment()",
|
||||
type: "method",
|
||||
signature: "reviewComment(options?: { tone?: 'constructive' | 'direct'; severity?: boolean }): any",
|
||||
description: "Create a code review comment prompt",
|
||||
returns: "any",
|
||||
params: [{"name":"options","type":"{ tone?: 'constructive' | 'direct'; severity?: boolean }"}],
|
||||
},
|
||||
{
|
||||
name: "templates.regex()",
|
||||
type: "method",
|
||||
signature: "regex(options?: { flavor?: 'javascript' | 'python' | 'pcre' }): any",
|
||||
description: "Create a regex generator prompt",
|
||||
returns: "any",
|
||||
params: [{"name":"options","type":"{ flavor?: 'javascript' | 'python' | 'pcre' }"}],
|
||||
},
|
||||
{
|
||||
name: "templates.sql()",
|
||||
type: "method",
|
||||
signature: "sql(options?: { dialect?: 'postgresql' | 'mysql' | 'sqlite' | 'mssql'; optimize?: boolean }): any",
|
||||
description: "Create a SQL query prompt",
|
||||
returns: "any",
|
||||
params: [{"name":"options","type":"{ dialect?: 'postgresql' | 'mysql' | 'sqlite' | 'mssql'; optimize?: boolean }"}],
|
||||
}
|
||||
],
|
||||
},
|
||||
@@ -924,6 +1052,86 @@ export const API_DOCS: ApiSection[] = [
|
||||
type: "const",
|
||||
signature: "chatPresets",
|
||||
description: "",
|
||||
},
|
||||
{
|
||||
name: "chatPresets.coder()",
|
||||
type: "method",
|
||||
signature: "coder(language?: string): any",
|
||||
description: "Code assistant preset",
|
||||
returns: "any",
|
||||
params: [{"name":"language","type":"string"}],
|
||||
},
|
||||
{
|
||||
name: "chatPresets.writer()",
|
||||
type: "method",
|
||||
signature: "writer(style?: 'creative' | 'professional' | 'academic'): any",
|
||||
description: "Writing assistant preset",
|
||||
returns: "any",
|
||||
params: [{"name":"style","type":"'creative' | 'professional' | 'academic'"}],
|
||||
},
|
||||
{
|
||||
name: "chatPresets.tutor()",
|
||||
type: "method",
|
||||
signature: "tutor(subject?: string): any",
|
||||
description: "Teacher/tutor preset",
|
||||
returns: "any",
|
||||
params: [{"name":"subject","type":"string"}],
|
||||
},
|
||||
{
|
||||
name: "chatPresets.analyst()",
|
||||
type: "method",
|
||||
signature: "analyst(): any",
|
||||
description: "Analyst preset",
|
||||
returns: "any",
|
||||
params: [],
|
||||
},
|
||||
{
|
||||
name: "chatPresets.socratic()",
|
||||
type: "method",
|
||||
signature: "socratic(): any",
|
||||
description: "Socratic dialogue preset",
|
||||
returns: "any",
|
||||
params: [],
|
||||
},
|
||||
{
|
||||
name: "chatPresets.critic()",
|
||||
type: "method",
|
||||
signature: "critic(): any",
|
||||
description: "Critic preset",
|
||||
returns: "any",
|
||||
params: [],
|
||||
},
|
||||
{
|
||||
name: "chatPresets.brainstormer()",
|
||||
type: "method",
|
||||
signature: "brainstormer(): any",
|
||||
description: "Brainstormer preset",
|
||||
returns: "any",
|
||||
params: [],
|
||||
},
|
||||
{
|
||||
name: "chatPresets.jsonResponder()",
|
||||
type: "method",
|
||||
signature: "jsonResponder(schemaName: string, schema: Record<string, unknown>): any",
|
||||
description: "JSON response preset",
|
||||
returns: "any",
|
||||
params: [{"name":"schemaName","type":"string"},{"name":"schema","type":"Record<string, unknown>"}],
|
||||
},
|
||||
{
|
||||
name: "chatPresets.summarizer()",
|
||||
type: "method",
|
||||
signature: "summarizer(length?: OutputLength): any",
|
||||
description: "Summarizer preset",
|
||||
returns: "any",
|
||||
params: [{"name":"length","type":"OutputLength"}],
|
||||
},
|
||||
{
|
||||
name: "chatPresets.translator()",
|
||||
type: "method",
|
||||
signature: "translator(targetLanguage: string): any",
|
||||
description: "Translator preset",
|
||||
returns: "any",
|
||||
params: [{"name":"targetLanguage","type":"string"}],
|
||||
}
|
||||
],
|
||||
},
|
||||
|
||||
@@ -894,6 +894,26 @@ declare module 'prompts.chat' {
|
||||
}
|
||||
export function image(): ImagePromptBuilder;
|
||||
|
||||
// TEMPLATES - Pre-built prompt templates
|
||||
export const templates: {
|
||||
codeReview: (options?: { language?: string; focus?: string[] }) => PromptBuilder;
|
||||
translation: (from: string, to: string) => PromptBuilder;
|
||||
summarize: (options?: { maxLength?: number; style?: 'bullet' | 'paragraph' }) => PromptBuilder;
|
||||
qa: (context?: string) => PromptBuilder;
|
||||
debug: (options?: { language?: string; errorType?: string }) => PromptBuilder;
|
||||
write: (options?: { type?: 'blog' | 'email' | 'essay' | 'story' | 'documentation'; tone?: string }) => PromptBuilder;
|
||||
explain: (options?: { level?: 'beginner' | 'intermediate' | 'expert'; useAnalogies?: boolean }) => PromptBuilder;
|
||||
extract: (options?: { format?: 'json' | 'csv' | 'table'; fields?: string[] }) => PromptBuilder;
|
||||
brainstorm: (options?: { count?: number; creative?: boolean }) => PromptBuilder;
|
||||
refactor: (options?: { goal?: 'readability' | 'performance' | 'maintainability' | 'all'; language?: string }) => PromptBuilder;
|
||||
apiDocs: (options?: { style?: 'openapi' | 'markdown' | 'jsdoc'; includeExamples?: boolean }) => PromptBuilder;
|
||||
unitTest: (options?: { framework?: string; coverage?: 'basic' | 'comprehensive' }) => PromptBuilder;
|
||||
commitMessage: (options?: { style?: 'conventional' | 'simple'; includeBody?: boolean }) => PromptBuilder;
|
||||
reviewComment: (options?: { tone?: 'constructive' | 'direct'; severity?: boolean }) => PromptBuilder;
|
||||
regex: (options?: { flavor?: 'javascript' | 'python' | 'pcre' }) => PromptBuilder;
|
||||
sql: (options?: { dialect?: 'postgresql' | 'mysql' | 'sqlite' | 'mssql'; optimize?: boolean }) => PromptBuilder;
|
||||
};
|
||||
|
||||
// UTILITY MODULES
|
||||
export namespace variables {
|
||||
export function detectVariables(text: string): DetectedVariable[];
|
||||
|
||||
Reference in New Issue
Block a user