@riotprompt/riotprompt 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cursor/rules/focus-on-prompt.mdc +5 -0
- package/README.md +61 -72
- package/dist/builder.js +2 -2
- package/dist/builder.js.map +1 -1
- package/dist/chat.js.map +1 -1
- package/dist/formatter.js.map +1 -1
- package/dist/items/parameters.js.map +1 -1
- package/dist/items/section.js.map +1 -1
- package/dist/loader.js.map +1 -1
- package/dist/logger.js.map +1 -1
- package/dist/override.js.map +1 -1
- package/dist/parse/markdown.d.ts +1 -1
- package/dist/parse/markdown.js +3 -2
- package/dist/parse/markdown.js.map +1 -1
- package/dist/parse/text.js.map +1 -1
- package/dist/parser.d.ts +1 -1
- package/dist/parser.js +3 -3
- package/dist/parser.js.map +1 -1
- package/dist/recipes.d.ts +19 -51
- package/dist/recipes.js +36 -181
- package/dist/recipes.js.map +1 -1
- package/dist/riotprompt.cjs +48 -200
- package/dist/riotprompt.cjs.map +1 -1
- package/dist/riotprompt.d.ts +1 -1
- package/dist/riotprompt.js +1 -1
- package/dist/util/general.js.map +1 -1
- package/dist/util/markdown.js.map +1 -1
- package/dist/util/storage.js.map +1 -1
- package/dist/util/text.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.js","sources":["../../src/parse/markdown.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"markdown.js","sources":["../../src/parse/markdown.ts"],"sourcesContent":["import { create as createSection, Section, SectionOptions, SectionOptionsSchema } from '../items/section';\nimport { create as createWeighted, Weighted, WeightedOptionsSchema } from '../items/weighted';\n\nexport const parseMarkdown = async <T extends Weighted>(\n input: string | Buffer,\n options: Partial<SectionOptions> = {}\n): Promise<Section<T>> => {\n\n // Dynamic import for marked (ES module)\n const { marked } = await import('marked');\n\n let markdownContent;\n if (typeof input === 'string') {\n markdownContent = input;\n } else {\n markdownContent = input.toString();\n }\n\n const sectionOptions = SectionOptionsSchema.parse(options);\n\n // Use marked.lexer to get tokens without full parsing/rendering\n const tokens = marked.lexer(markdownContent);\n\n // Create the main section (with a Title from the options)\n const mainSection = createSection<T>(sectionOptions);\n\n // Track sections at each depth level\n const sectionStack: Section<T>[] = [mainSection];\n\n // Set if we've seen the first token\n let isFirstToken = true;\n\n // Set the item options\n const itemOptions = WeightedOptionsSchema.parse({\n ...sectionOptions,\n weight: sectionOptions.itemWeight,\n });\n\n for (const token of tokens) {\n switch (token.type) {\n case 'heading': {\n const depth = token.depth;\n\n // If this is the first token and it's a heading, use it as the main section title\n if (isFirstToken) {\n mainSection.title = token.text;\n isFirstToken = false;\n break;\n }\n\n isFirstToken = false;\n\n // Create a new section with this heading\n const newSection = createSection<T>({ ...sectionOptions, title: token.text });\n\n // Ensure the section stack has the right size based on this heading's depth\n // (e.g., a depth-2 heading should be added to the depth-1 section)\n // We need to ensure the stack length is exactly depth, not just less than or equal to depth\n while (sectionStack.length > depth && sectionStack.length > 1) {\n sectionStack.pop();\n }\n\n // Make sure we're at the right level for this heading\n // If we stay at the same heading level (e.g., two h2s in sequence),\n // we need to pop once more to get to the parent level\n if (sectionStack.length === depth && sectionStack.length > 1) {\n sectionStack.pop();\n }\n\n // Add new section to its parent\n const parentSection = sectionStack[sectionStack.length - 1];\n parentSection.add(newSection, itemOptions);\n\n // Push this section onto the stack\n sectionStack.push(newSection);\n break;\n }\n\n case 'paragraph': {\n isFirstToken = false;\n const instruction: T = createWeighted<T>(token.text, itemOptions);\n const currentSection = sectionStack[sectionStack.length - 1];\n currentSection.add(instruction, itemOptions);\n break;\n }\n\n case 'list': {\n isFirstToken = false;\n // Convert list items to instructions\n const listInstructionContent = token.items.map((item: any) => `- ${item.text}`).join('\\n');\n const listInstruction: T = createWeighted<T>(listInstructionContent, itemOptions);\n const currentSection = sectionStack[sectionStack.length - 1];\n currentSection.add(listInstruction, itemOptions);\n break;\n }\n\n case 'code': {\n isFirstToken = false;\n // Represent code blocks as instructions\n const codeInstruction: T = createWeighted<T>(`\\`\\`\\`${token.lang || ''}\\n${token.text}\\n\\`\\`\\``, itemOptions);\n const currentSection = sectionStack[sectionStack.length - 1];\n currentSection.add(codeInstruction, itemOptions);\n break;\n }\n\n case 'space':\n // Usually ignore space tokens between block elements\n break;\n\n default: {\n isFirstToken = false;\n // Treat other block tokens' text as instructions for robustness\n if ('text' in token && token.text) {\n const fallbackInstruction: T = createWeighted<T>(token.text, itemOptions);\n const currentSection = sectionStack[sectionStack.length - 1];\n currentSection.add(fallbackInstruction, itemOptions);\n }\n break;\n }\n }\n }\n return mainSection;\n}\n"],"names":["parseMarkdown","input","options","marked","markdownContent","toString","sectionOptions","SectionOptionsSchema","parse","tokens","lexer","mainSection","createSection","sectionStack","isFirstToken","itemOptions","WeightedOptionsSchema","weight","itemWeight","token","type","depth","title","text","newSection","length","pop","parentSection","add","push","instruction","createWeighted","currentSection","listInstructionContent","items","map","item","join","listInstruction","codeInstruction","lang","fallbackInstruction"],"mappings":";;;MAGaA,aAAAA,GAAgB,OACzBC,KAAAA,EACAC,OAAAA,GAAmC,EAAE,GAAA;;AAIrC,IAAA,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAM,OAAO,QAAA,CAAA;IAEhC,IAAIC,eAAAA;IACJ,IAAI,OAAOH,UAAU,QAAA,EAAU;QAC3BG,eAAAA,GAAkBH,KAAAA;IACtB,CAAA,MAAO;AACHG,QAAAA,eAAAA,GAAkBH,MAAMI,QAAQ,EAAA;AACpC,IAAA;IAEA,MAAMC,cAAAA,GAAiBC,oBAAAA,CAAqBC,KAAK,CAACN,OAAAA,CAAAA;;IAGlD,MAAMO,MAAAA,GAASN,MAAAA,CAAOO,KAAK,CAACN,eAAAA,CAAAA;;AAG5B,IAAA,MAAMO,cAAcC,MAAAA,CAAiBN,cAAAA,CAAAA;;AAGrC,IAAA,MAAMO,YAAAA,GAA6B;AAACF,QAAAA;AAAY,KAAA;;AAGhD,IAAA,IAAIG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,MAAA,IAAUK,KAAAA,IAASA,KAAAA,CAAMI,IAAI,EAAE;AAC/B,wBAAA,MAAMkB,mBAAAA,GAAyBV,QAAAA,CAAkBZ,KAAAA,CAAMI,IAAI,EAAER,WAAAA,CAAAA;AAC7D,wBAAA,MAAMiB,iBAAiBnB,YAAY,CAACA,YAAAA,CAAaY,MAAM,GAAG,CAAA,CAAE;wBAC5DO,cAAAA,CAAeJ,GAAG,CAACa,mBAAAA,EAAqB1B,WAAAA,CAAAA;AAC5C,oBAAA;AACA,oBAAA;AACJ,gBAAA;AACJ;AACJ,IAAA;IACA,OAAOJ,WAAAA;AACX;;;;"}
|
package/dist/parse/text.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","sources":["../../src/parse/text.ts"],"sourcesContent":["import { create as createSection, Section, SectionOptions, SectionOptionsSchema } from '../items/section';\nimport { create as createWeighted, Weighted, WeightedOptionsSchema } from '../items/weighted';\n\nexport const parseText = <T extends Weighted>(\n input: string | Buffer,\n options: Partial<SectionOptions> = {}\n): Section<T> => {\n\n let text;\n if (typeof input === 'string') {\n text = input;\n } else {\n text = input.toString();\n }\n\n const sectionOptions = SectionOptionsSchema.parse(options);\n\n // Set the item options\n const itemOptions = WeightedOptionsSchema.parse({\n ...sectionOptions,\n weight: sectionOptions.itemWeight,\n });\n\n // Split the text on newlines\n const lines = text.split(/\\r?\\n/).filter(line => line.trim().length > 0);\n\n // Create the main section with the supplied title\n const mainSection = createSection<T>(sectionOptions);\n\n for (const line of lines) {\n const instruction: T = createWeighted<T>(line, itemOptions);\n mainSection.add(instruction, itemOptions);\n }\n\n return mainSection;\n}\n"],"names":["parseText","input","options","text","toString","sectionOptions","SectionOptionsSchema","parse","itemOptions","WeightedOptionsSchema","weight","itemWeight","lines","split","filter","line","trim","length","mainSection","createSection","instruction","createWeighted","add"],"mappings":";;;MAGaA,SAAAA,GAAY,CACrBC,KAAAA,EACAC,OAAAA,GAAmC,EAAE,GAAA;IAGrC,IAAIC,IAAAA;IACJ,IAAI,OAAOF,UAAU,QAAA,EAAU;QAC3BE,IAAAA,GAAOF,KAAAA;
|
|
1
|
+
{"version":3,"file":"text.js","sources":["../../src/parse/text.ts"],"sourcesContent":["import { create as createSection, Section, SectionOptions, SectionOptionsSchema } from '../items/section';\nimport { create as createWeighted, Weighted, WeightedOptionsSchema } from '../items/weighted';\n\nexport const parseText = <T extends Weighted>(\n input: string | Buffer,\n options: Partial<SectionOptions> = {}\n): Section<T> => {\n\n let text;\n if (typeof input === 'string') {\n text = input;\n } else {\n text = input.toString();\n }\n\n const sectionOptions = SectionOptionsSchema.parse(options);\n\n // Set the item options\n const itemOptions = WeightedOptionsSchema.parse({\n ...sectionOptions,\n weight: sectionOptions.itemWeight,\n });\n\n // Split the text on newlines\n const lines = text.split(/\\r?\\n/).filter(line => line.trim().length > 0);\n\n // Create the main section with the supplied title\n const mainSection = createSection<T>(sectionOptions);\n\n for (const line of lines) {\n const instruction: T = createWeighted<T>(line, itemOptions);\n mainSection.add(instruction, itemOptions);\n }\n\n return mainSection;\n}\n"],"names":["parseText","input","options","text","toString","sectionOptions","SectionOptionsSchema","parse","itemOptions","WeightedOptionsSchema","weight","itemWeight","lines","split","filter","line","trim","length","mainSection","createSection","instruction","createWeighted","add"],"mappings":";;;MAGaA,SAAAA,GAAY,CACrBC,KAAAA,EACAC,OAAAA,GAAmC,EAAE,GAAA;IAGrC,IAAIC,IAAAA;IACJ,IAAI,OAAOF,UAAU,QAAA,EAAU;QAC3BE,IAAAA,GAAOF,KAAAA;IACX,CAAA,MAAO;AACHE,QAAAA,IAAAA,GAAOF,MAAMG,QAAQ,EAAA;AACzB,IAAA;IAEA,MAAMC,cAAAA,GAAiBC,oBAAAA,CAAqBC,KAAK,CAACL,OAAAA,CAAAA;;IAGlD,MAAMM,WAAAA,GAAcC,qBAAAA,CAAsBF,KAAK,CAAC;AAC5C,QAAA,GAAGF,cAAc;AACjBK,QAAAA,MAAAA,EAAQL,eAAeM;AAC3B,KAAA,CAAA;;AAGA,IAAA,MAAMC,KAAAA,GAAQT,IAAAA,CAAKU,KAAK,CAAC,OAAA,CAAA,CAASC,MAAM,CAACC,CAAAA,IAAAA,GAAQA,IAAAA,CAAKC,IAAI,EAAA,CAAGC,MAAM,GAAG,CAAA,CAAA;;AAGtE,IAAA,MAAMC,cAAcC,MAAAA,CAAiBd,cAAAA,CAAAA;IAErC,KAAK,MAAMU,QAAQH,KAAAA,CAAO;QACtB,MAAMQ,WAAAA,GAAiBC,SAAkBN,IAAAA,EAAMP,WAAAA,CAAAA;QAC/CU,WAAAA,CAAYI,GAAG,CAACF,WAAAA,EAAaZ,WAAAA,CAAAA;AACjC,IAAA;IAEA,OAAOU,WAAAA;AACX;;;;"}
|
package/dist/parser.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ declare const OptionsSchema: z.ZodObject<{
|
|
|
14
14
|
export type Options = z.infer<typeof OptionsSchema>;
|
|
15
15
|
export type OptionsParam = Partial<Options>;
|
|
16
16
|
export interface Instance {
|
|
17
|
-
parse: <T extends Weighted>(input: string | Buffer, options?: SectionOptions) => Section<T
|
|
17
|
+
parse: <T extends Weighted>(input: string | Buffer, options?: SectionOptions) => Promise<Section<T>>;
|
|
18
18
|
parseFile: <T extends Weighted>(filePath: string, options?: SectionOptions) => Promise<Section<T>>;
|
|
19
19
|
}
|
|
20
20
|
export declare const create: (parserOptions?: OptionsParam) => Instance;
|
package/dist/parser.js
CHANGED
|
@@ -33,7 +33,7 @@ const create = (parserOptions)=>{
|
|
|
33
33
|
const content = await fs.readFile(filePath, 'utf-8');
|
|
34
34
|
// Only use the filename as title if no title was explicitly provided
|
|
35
35
|
const fileName = path.basename(filePath, path.extname(filePath));
|
|
36
|
-
return parse(content, {
|
|
36
|
+
return await parse(content, {
|
|
37
37
|
...currentOptions,
|
|
38
38
|
title: (currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.title) || fileName
|
|
39
39
|
});
|
|
@@ -53,11 +53,11 @@ const create = (parserOptions)=>{
|
|
|
53
53
|
*
|
|
54
54
|
* @param content The content to parse
|
|
55
55
|
* @returns A Section containing all content in a hierarchical structure
|
|
56
|
-
*/ const parse = (content, options = {})=>{
|
|
56
|
+
*/ const parse = async (content, options = {})=>{
|
|
57
57
|
const currentOptions = loadOptions(options);
|
|
58
58
|
let mainSection;
|
|
59
59
|
if (isMarkdown(content)) {
|
|
60
|
-
mainSection = parseMarkdown(content, currentOptions);
|
|
60
|
+
mainSection = await parseMarkdown(content, currentOptions);
|
|
61
61
|
} else if (isText(content)) {
|
|
62
62
|
mainSection = parseText(content, currentOptions);
|
|
63
63
|
} else {
|
package/dist/parser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sources":["../src/parser.ts"],"sourcesContent":["import * as fs from 'fs/promises';\nimport * as path from 'path';\nimport { z } from 'zod';\nimport { ParametersSchema } from './items/parameters';\nimport { Section, SectionOptions, SectionOptionsSchema } from './items/section';\nimport { Weighted } from './items/weighted';\nimport { DEFAULT_LOGGER, wrapLogger } from './logger';\nimport { parseMarkdown } from './parse/markdown';\nimport { parseText } from './parse/text';\nimport { isMarkdown } from './util/markdown';\nimport { isText } from './util/text';\n\nconst OptionsSchema = z.object({\n logger: z.any().optional().default(DEFAULT_LOGGER),\n parameters: ParametersSchema.optional().default({}),\n});\n\nexport type Options = z.infer<typeof OptionsSchema>;\n\nexport type OptionsParam = Partial<Options>;\n\nexport interface Instance {\n parse: <T extends Weighted>(input: string | Buffer, options?: SectionOptions) => Section<T
|
|
1
|
+
{"version":3,"file":"parser.js","sources":["../src/parser.ts"],"sourcesContent":["import * as fs from 'fs/promises';\nimport * as path from 'path';\nimport { z } from 'zod';\nimport { ParametersSchema } from './items/parameters';\nimport { Section, SectionOptions, SectionOptionsSchema } from './items/section';\nimport { Weighted } from './items/weighted';\nimport { DEFAULT_LOGGER, wrapLogger } from './logger';\nimport { parseMarkdown } from './parse/markdown';\nimport { parseText } from './parse/text';\nimport { isMarkdown } from './util/markdown';\nimport { isText } from './util/text';\n\nconst OptionsSchema = z.object({\n logger: z.any().optional().default(DEFAULT_LOGGER),\n parameters: ParametersSchema.optional().default({}),\n});\n\nexport type Options = z.infer<typeof OptionsSchema>;\n\nexport type OptionsParam = Partial<Options>;\n\nexport interface Instance {\n parse: <T extends Weighted>(input: string | Buffer, options?: SectionOptions) => Promise<Section<T>>;\n parseFile: <T extends Weighted>(filePath: string, options?: SectionOptions) => Promise<Section<T>>;\n}\n\nexport const create = (parserOptions?: OptionsParam): Instance => {\n const options: Required<Options> = OptionsSchema.parse(parserOptions || {}) as Required<Options>;\n const parameters = options.parameters;\n\n const logger = wrapLogger(options.logger, 'Parser');\n\n const loadOptions = (sectionOptions: Partial<SectionOptions> = {}): SectionOptions => {\n const currentOptions = SectionOptionsSchema.parse(sectionOptions);\n return {\n ...currentOptions,\n parameters: {\n ...parameters,\n ...currentOptions.parameters\n }\n }\n }\n\n const parseFile = async <T extends Weighted>(\n filePath: string,\n options: Partial<SectionOptions> = {}\n ): Promise<Section<T>> => {\n const currentOptions = loadOptions(options);\n try {\n const content = await fs.readFile(filePath, 'utf-8');\n // Only use the filename as title if no title was explicitly provided\n const fileName = path.basename(filePath, path.extname(filePath));\n return await parse(content, {\n ...currentOptions,\n title: currentOptions?.title || fileName\n });\n } catch (error) {\n // Log the error or handle it appropriately\n logger.error(`Error reading or parsing file with marked at ${filePath}:`, error);\n throw new Error(`Failed to parse instructions from ${filePath}: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n /**\n * Reads Markdown content and parses it into a single Section.\n * \n * - If the content starts with a heading, that becomes the title of the returned Section\n * - If no heading at the start, creates a Section with no title\n * - Headers within the content create nested sections based on their depth\n * - All content is organized in a hierarchical structure based on heading levels\n *\n * @param content The content to parse\n * @returns A Section containing all content in a hierarchical structure\n */\n const parse = async <T extends Weighted>(\n content: string | Buffer,\n options: Partial<SectionOptions> = {}\n ): Promise<Section<T>> => {\n const currentOptions = loadOptions(options);\n\n let mainSection: Section<T>;\n if (isMarkdown(content)) {\n mainSection = await parseMarkdown<T>(content, currentOptions);\n } else if (isText(content)) {\n mainSection = parseText<T>(content, currentOptions);\n } else {\n throw new Error(`Unsupported content supplied to parse, riotprompt currently only supports markdown and text`);\n }\n return mainSection;\n }\n\n return {\n parse,\n parseFile\n }\n}"],"names":["OptionsSchema","z","object","logger","any","optional","default","DEFAULT_LOGGER","parameters","ParametersSchema","create","parserOptions","options","parse","wrapLogger","loadOptions","sectionOptions","currentOptions","SectionOptionsSchema","parseFile","filePath","content","fs","readFile","fileName","path","basename","extname","title","error","Error","message","String","mainSection","isMarkdown","parseMarkdown","isText","parseText"],"mappings":";;;;;;;;;;;AAYA,MAAMA,aAAAA,GAAgBC,CAAAA,CAAEC,MAAM,CAAC;AAC3BC,IAAAA,MAAAA,EAAQF,EAAEG,GAAG,EAAA,CAAGC,QAAQ,EAAA,CAAGC,OAAO,CAACC,cAAAA,CAAAA;AACnCC,IAAAA,UAAAA,EAAYC,gBAAAA,CAAiBJ,QAAQ,EAAA,CAAGC,OAAO,CAAC,EAAC;AACrD,CAAA,CAAA;AAWO,MAAMI,SAAS,CAACC,aAAAA,GAAAA;AACnB,IAAA,MAAMC,OAAAA,GAA6BZ,aAAAA,CAAca,KAAK,CAACF,iBAAiB,EAAC,CAAA;IACzE,MAAMH,UAAAA,GAAaI,QAAQJ,UAAU;AAErC,IAAA,MAAML,MAAAA,GAASW,UAAAA,CAAWF,OAAAA,CAAQT,MAAM,EAAE,QAAA,CAAA;AAE1C,IAAA,MAAMY,WAAAA,GAAc,CAACC,cAAAA,GAA0C,EAAE,GAAA;QAC7D,MAAMC,cAAAA,GAAiBC,oBAAAA,CAAqBL,KAAK,CAACG,cAAAA,CAAAA;QAClD,OAAO;AACH,YAAA,GAAGC,cAAc;YACjBT,UAAAA,EAAY;AACR,gBAAA,GAAGA,UAAU;AACb,gBAAA,GAAGS,eAAeT;AACtB;AACJ,SAAA;AACJ,IAAA,CAAA;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EAASJ,cAAAA,CAAAA;QAClD,CAAA,MAAO,IAAImB,OAAOf,OAAAA,CAAAA,EAAU;AACxBY,YAAAA,WAAAA,GAAcI,UAAahB,OAAAA,EAASJ,cAAAA,CAAAA;QACxC,CAAA,MAAO;AACH,YAAA,MAAM,IAAIa,KAAAA,CAAM,CAAC,2FAA2F,CAAC,CAAA;AACjH,QAAA;QACA,OAAOG,WAAAA;AACX,IAAA,CAAA;IAEA,OAAO;AACHpB,QAAAA,KAAAA;AACAM,QAAAA;AACJ,KAAA;AACJ;;;;"}
|
package/dist/recipes.d.ts
CHANGED
|
@@ -192,7 +192,7 @@ declare const RecipeConfigSchema: z.ZodObject<{
|
|
|
192
192
|
title?: string | undefined;
|
|
193
193
|
}>]>, "many">>>;
|
|
194
194
|
extends: z.ZodOptional<z.ZodString>;
|
|
195
|
-
template: z.ZodOptional<z.
|
|
195
|
+
template: z.ZodOptional<z.ZodString>;
|
|
196
196
|
}, "strip", z.ZodTypeAny, {
|
|
197
197
|
parameters: Record<string, string | number | boolean | (string | number | boolean)[]>;
|
|
198
198
|
instructions: (string | {
|
|
@@ -252,7 +252,7 @@ declare const RecipeConfigSchema: z.ZodObject<{
|
|
|
252
252
|
} | undefined;
|
|
253
253
|
logger?: any;
|
|
254
254
|
extends?: string | undefined;
|
|
255
|
-
template?:
|
|
255
|
+
template?: string | undefined;
|
|
256
256
|
}, {
|
|
257
257
|
basePath: string;
|
|
258
258
|
parameters?: Record<string, string | number | boolean | (string | number | boolean)[]> | undefined;
|
|
@@ -312,7 +312,7 @@ declare const RecipeConfigSchema: z.ZodObject<{
|
|
|
312
312
|
title?: string | undefined;
|
|
313
313
|
})[] | undefined;
|
|
314
314
|
extends?: string | undefined;
|
|
315
|
-
template?:
|
|
315
|
+
template?: string | undefined;
|
|
316
316
|
}>;
|
|
317
317
|
type RecipeConfig = z.infer<typeof RecipeConfigSchema>;
|
|
318
318
|
type ContentItem = z.infer<typeof ContentItemSchema>;
|
|
@@ -323,69 +323,37 @@ export interface TemplateConfig {
|
|
|
323
323
|
context?: ContentItem[];
|
|
324
324
|
}
|
|
325
325
|
/**
|
|
326
|
-
*
|
|
326
|
+
* Register custom templates with the recipes system
|
|
327
327
|
*
|
|
328
328
|
* @example
|
|
329
329
|
* ```typescript
|
|
330
|
-
* //
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
* persona: { path:
|
|
334
|
-
* instructions: [{ path:
|
|
330
|
+
* // Register your own templates
|
|
331
|
+
* registerTemplates({
|
|
332
|
+
* myWorkflow: {
|
|
333
|
+
* persona: { path: "personas/my-persona.md" },
|
|
334
|
+
* instructions: [{ path: "instructions/my-instructions.md" }]
|
|
335
335
|
* },
|
|
336
|
-
*
|
|
337
|
-
* persona: {
|
|
338
|
-
* instructions: [{
|
|
336
|
+
* anotherTemplate: {
|
|
337
|
+
* persona: { content: "You are a helpful assistant" },
|
|
338
|
+
* instructions: [{ content: "Follow these steps..." }]
|
|
339
339
|
* }
|
|
340
340
|
* });
|
|
341
341
|
* ```
|
|
342
342
|
*/
|
|
343
|
-
export declare const
|
|
343
|
+
export declare const registerTemplates: (templates: Record<string, TemplateConfig>) => void;
|
|
344
344
|
/**
|
|
345
|
-
* Get
|
|
345
|
+
* Get currently registered templates
|
|
346
346
|
*/
|
|
347
347
|
export declare const getTemplates: () => Record<string, TemplateConfig>;
|
|
348
|
+
/**
|
|
349
|
+
* Clear all registered templates
|
|
350
|
+
*/
|
|
351
|
+
export declare const clearTemplates: () => void;
|
|
348
352
|
export declare const cook: (config: Partial<RecipeConfig> & {
|
|
349
353
|
basePath: string;
|
|
350
354
|
}) => Promise<Prompt>;
|
|
351
|
-
export declare const commit: (config: Partial<RecipeConfig> & {
|
|
352
|
-
basePath: string;
|
|
353
|
-
}) => Promise<Prompt>;
|
|
354
|
-
export declare const release: (config: Partial<RecipeConfig> & {
|
|
355
|
-
basePath: string;
|
|
356
|
-
}) => Promise<Prompt>;
|
|
357
|
-
export declare const documentation: (config: Partial<RecipeConfig> & {
|
|
358
|
-
basePath: string;
|
|
359
|
-
}) => Promise<Prompt>;
|
|
360
|
-
export declare const review: (config: Partial<RecipeConfig> & {
|
|
361
|
-
basePath: string;
|
|
362
|
-
}) => Promise<Prompt>;
|
|
363
|
-
export declare const quick: {
|
|
364
|
-
/**
|
|
365
|
-
* Create a commit prompt with minimal configuration
|
|
366
|
-
*/
|
|
367
|
-
commit: (diffContent: string, options: {
|
|
368
|
-
basePath: string;
|
|
369
|
-
overridePaths?: string[];
|
|
370
|
-
overrides?: boolean;
|
|
371
|
-
userDirection?: string;
|
|
372
|
-
context?: string;
|
|
373
|
-
directories?: string[];
|
|
374
|
-
}) => Promise<Prompt>;
|
|
375
|
-
/**
|
|
376
|
-
* Create a release prompt with minimal configuration
|
|
377
|
-
*/
|
|
378
|
-
release: (logContent: string, diffContent: string, options: {
|
|
379
|
-
basePath: string;
|
|
380
|
-
overridePaths?: string[];
|
|
381
|
-
overrides?: boolean;
|
|
382
|
-
releaseFocus?: string;
|
|
383
|
-
context?: string;
|
|
384
|
-
directories?: string[];
|
|
385
|
-
}) => Promise<Prompt>;
|
|
386
|
-
};
|
|
387
355
|
export declare const recipe: (basePath: string) => {
|
|
388
|
-
template: (name:
|
|
356
|
+
template: (name: string) => {
|
|
389
357
|
with: (config: Partial<RecipeConfig>) => Promise<Prompt>;
|
|
390
358
|
};
|
|
391
359
|
persona: (persona: ContentItem) => {
|
package/dist/recipes.js
CHANGED
|
@@ -39,104 +39,50 @@ const RecipeConfigSchema = z.object({
|
|
|
39
39
|
]),
|
|
40
40
|
overrides: z.boolean().optional().default(false),
|
|
41
41
|
parameters: ParametersSchema.optional().default({}),
|
|
42
|
-
// Content sections
|
|
42
|
+
// Content sections
|
|
43
43
|
persona: ContentItemSchema.optional(),
|
|
44
44
|
instructions: z.array(ContentItemSchema).optional().default([]),
|
|
45
45
|
content: z.array(ContentItemSchema).optional().default([]),
|
|
46
46
|
context: z.array(ContentItemSchema).optional().default([]),
|
|
47
47
|
// Templates and inheritance
|
|
48
48
|
extends: z.string().optional(),
|
|
49
|
-
template: z.
|
|
50
|
-
'commit',
|
|
51
|
-
'release',
|
|
52
|
-
'documentation',
|
|
53
|
-
'review',
|
|
54
|
-
'custom'
|
|
55
|
-
]).optional()
|
|
49
|
+
template: z.string().optional()
|
|
56
50
|
});
|
|
57
|
-
// Built-in template configurations matching common patterns
|
|
58
|
-
const DEFAULT_TEMPLATES = {
|
|
59
|
-
commit: {
|
|
60
|
-
persona: {
|
|
61
|
-
path: "personas/developer.md",
|
|
62
|
-
title: "Developer Persona"
|
|
63
|
-
},
|
|
64
|
-
instructions: [
|
|
65
|
-
{
|
|
66
|
-
path: "instructions/commit.md",
|
|
67
|
-
title: "Commit Instructions"
|
|
68
|
-
}
|
|
69
|
-
]
|
|
70
|
-
},
|
|
71
|
-
release: {
|
|
72
|
-
persona: {
|
|
73
|
-
path: "personas/releaser.md",
|
|
74
|
-
title: "Release Manager Persona"
|
|
75
|
-
},
|
|
76
|
-
instructions: [
|
|
77
|
-
{
|
|
78
|
-
path: "instructions/release.md",
|
|
79
|
-
title: "Release Instructions"
|
|
80
|
-
}
|
|
81
|
-
]
|
|
82
|
-
},
|
|
83
|
-
documentation: {
|
|
84
|
-
persona: {
|
|
85
|
-
path: "personas/technical-writer.md",
|
|
86
|
-
title: "Technical Writer Persona"
|
|
87
|
-
},
|
|
88
|
-
instructions: [
|
|
89
|
-
{
|
|
90
|
-
path: "instructions/documentation.md",
|
|
91
|
-
title: "Documentation Instructions"
|
|
92
|
-
}
|
|
93
|
-
]
|
|
94
|
-
},
|
|
95
|
-
review: {
|
|
96
|
-
persona: {
|
|
97
|
-
path: "personas/reviewer.md",
|
|
98
|
-
title: "Code Reviewer Persona"
|
|
99
|
-
},
|
|
100
|
-
instructions: [
|
|
101
|
-
{
|
|
102
|
-
path: "instructions/review.md",
|
|
103
|
-
title: "Review Instructions"
|
|
104
|
-
}
|
|
105
|
-
]
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
51
|
// User-customizable template registry
|
|
109
|
-
let TEMPLATES = {
|
|
110
|
-
...DEFAULT_TEMPLATES
|
|
111
|
-
};
|
|
52
|
+
let TEMPLATES = {};
|
|
112
53
|
/**
|
|
113
|
-
*
|
|
54
|
+
* Register custom templates with the recipes system
|
|
114
55
|
*
|
|
115
56
|
* @example
|
|
116
57
|
* ```typescript
|
|
117
|
-
* //
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
* persona: { path:
|
|
121
|
-
* instructions: [{ path:
|
|
58
|
+
* // Register your own templates
|
|
59
|
+
* registerTemplates({
|
|
60
|
+
* myWorkflow: {
|
|
61
|
+
* persona: { path: "personas/my-persona.md" },
|
|
62
|
+
* instructions: [{ path: "instructions/my-instructions.md" }]
|
|
122
63
|
* },
|
|
123
|
-
*
|
|
124
|
-
* persona: {
|
|
125
|
-
* instructions: [{
|
|
64
|
+
* anotherTemplate: {
|
|
65
|
+
* persona: { content: "You are a helpful assistant" },
|
|
66
|
+
* instructions: [{ content: "Follow these steps..." }]
|
|
126
67
|
* }
|
|
127
68
|
* });
|
|
128
69
|
* ```
|
|
129
|
-
*/ const
|
|
70
|
+
*/ const registerTemplates = (templates)=>{
|
|
130
71
|
TEMPLATES = {
|
|
131
|
-
...
|
|
132
|
-
...
|
|
72
|
+
...TEMPLATES,
|
|
73
|
+
...templates
|
|
133
74
|
};
|
|
134
75
|
};
|
|
135
76
|
/**
|
|
136
|
-
* Get
|
|
77
|
+
* Get currently registered templates
|
|
137
78
|
*/ const getTemplates = ()=>({
|
|
138
79
|
...TEMPLATES
|
|
139
80
|
});
|
|
81
|
+
/**
|
|
82
|
+
* Clear all registered templates
|
|
83
|
+
*/ const clearTemplates = ()=>{
|
|
84
|
+
TEMPLATES = {};
|
|
85
|
+
};
|
|
140
86
|
// ===== CORE RECIPE ENGINE =====
|
|
141
87
|
const cook = async (config)=>{
|
|
142
88
|
// Parse and validate configuration with defaults
|
|
@@ -159,8 +105,20 @@ const cook = async (config)=>{
|
|
|
159
105
|
const template = TEMPLATES[validatedConfig.template];
|
|
160
106
|
if (template) {
|
|
161
107
|
finalConfig = {
|
|
162
|
-
...
|
|
163
|
-
|
|
108
|
+
...validatedConfig,
|
|
109
|
+
persona: validatedConfig.persona || template.persona,
|
|
110
|
+
instructions: [
|
|
111
|
+
...template.instructions || [],
|
|
112
|
+
...validatedConfig.instructions || []
|
|
113
|
+
],
|
|
114
|
+
content: [
|
|
115
|
+
...template.content || [],
|
|
116
|
+
...validatedConfig.content || []
|
|
117
|
+
],
|
|
118
|
+
context: [
|
|
119
|
+
...template.context || [],
|
|
120
|
+
...validatedConfig.context || []
|
|
121
|
+
]
|
|
164
122
|
};
|
|
165
123
|
}
|
|
166
124
|
}
|
|
@@ -272,109 +230,6 @@ const processContentItem = async (item, section, type, ctx)=>{
|
|
|
272
230
|
section.add(sections);
|
|
273
231
|
}
|
|
274
232
|
};
|
|
275
|
-
// ===== CONVENIENCE FUNCTIONS =====
|
|
276
|
-
const commit = (config)=>cook({
|
|
277
|
-
...config,
|
|
278
|
-
template: 'commit'
|
|
279
|
-
});
|
|
280
|
-
const release = (config)=>cook({
|
|
281
|
-
...config,
|
|
282
|
-
template: 'release'
|
|
283
|
-
});
|
|
284
|
-
const documentation = (config)=>cook({
|
|
285
|
-
...config,
|
|
286
|
-
template: 'documentation'
|
|
287
|
-
});
|
|
288
|
-
const review = (config)=>cook({
|
|
289
|
-
...config,
|
|
290
|
-
template: 'review'
|
|
291
|
-
});
|
|
292
|
-
// ===== QUICK BUILDERS =====
|
|
293
|
-
const quick = {
|
|
294
|
-
/**
|
|
295
|
-
* Create a commit prompt with minimal configuration
|
|
296
|
-
*/ commit: async (diffContent, options)=>{
|
|
297
|
-
return cook({
|
|
298
|
-
basePath: options.basePath,
|
|
299
|
-
overridePaths: options.overridePaths,
|
|
300
|
-
overrides: options.overrides,
|
|
301
|
-
template: 'commit',
|
|
302
|
-
content: [
|
|
303
|
-
...options.userDirection ? [
|
|
304
|
-
{
|
|
305
|
-
content: options.userDirection,
|
|
306
|
-
title: 'User Direction',
|
|
307
|
-
weight: 1.0
|
|
308
|
-
}
|
|
309
|
-
] : [],
|
|
310
|
-
{
|
|
311
|
-
content: diffContent,
|
|
312
|
-
title: 'Diff',
|
|
313
|
-
weight: 0.5
|
|
314
|
-
}
|
|
315
|
-
],
|
|
316
|
-
context: [
|
|
317
|
-
...options.context ? [
|
|
318
|
-
{
|
|
319
|
-
content: options.context,
|
|
320
|
-
title: 'User Context',
|
|
321
|
-
weight: 1.0
|
|
322
|
-
}
|
|
323
|
-
] : [],
|
|
324
|
-
...options.directories ? [
|
|
325
|
-
{
|
|
326
|
-
directories: options.directories,
|
|
327
|
-
weight: 0.5
|
|
328
|
-
}
|
|
329
|
-
] : []
|
|
330
|
-
]
|
|
331
|
-
});
|
|
332
|
-
},
|
|
333
|
-
/**
|
|
334
|
-
* Create a release prompt with minimal configuration
|
|
335
|
-
*/ release: async (logContent, diffContent, options)=>{
|
|
336
|
-
return cook({
|
|
337
|
-
basePath: options.basePath,
|
|
338
|
-
overridePaths: options.overridePaths,
|
|
339
|
-
overrides: options.overrides,
|
|
340
|
-
template: 'release',
|
|
341
|
-
content: [
|
|
342
|
-
...options.releaseFocus ? [
|
|
343
|
-
{
|
|
344
|
-
content: options.releaseFocus,
|
|
345
|
-
title: 'Release Focus',
|
|
346
|
-
weight: 1.0
|
|
347
|
-
}
|
|
348
|
-
] : [],
|
|
349
|
-
{
|
|
350
|
-
content: logContent,
|
|
351
|
-
title: 'Log',
|
|
352
|
-
weight: 0.5
|
|
353
|
-
},
|
|
354
|
-
{
|
|
355
|
-
content: diffContent,
|
|
356
|
-
title: 'Diff',
|
|
357
|
-
weight: 0.5
|
|
358
|
-
}
|
|
359
|
-
],
|
|
360
|
-
context: [
|
|
361
|
-
...options.context ? [
|
|
362
|
-
{
|
|
363
|
-
content: options.context,
|
|
364
|
-
title: 'User Context',
|
|
365
|
-
weight: 1.0
|
|
366
|
-
}
|
|
367
|
-
] : [],
|
|
368
|
-
...options.directories ? [
|
|
369
|
-
{
|
|
370
|
-
directories: options.directories,
|
|
371
|
-
weight: 0.5
|
|
372
|
-
}
|
|
373
|
-
] : []
|
|
374
|
-
]
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
};
|
|
378
233
|
// ===== FLUENT RECIPE BUILDER =====
|
|
379
234
|
const recipe = (basePath)=>({
|
|
380
235
|
template: (name)=>({
|
|
@@ -420,5 +275,5 @@ const recipe = (basePath)=>({
|
|
|
420
275
|
})
|
|
421
276
|
});
|
|
422
277
|
|
|
423
|
-
export {
|
|
278
|
+
export { clearTemplates, cook, getTemplates, recipe, registerTemplates };
|
|
424
279
|
//# sourceMappingURL=recipes.js.map
|
package/dist/recipes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recipes.js","sources":["../src/recipes.ts"],"sourcesContent":["import path from \"path\";\nimport { z } from \"zod\";\nimport { ParametersSchema } from \"./items/parameters\";\nimport { SectionOptions } from \"./items/section\";\nimport { DEFAULT_LOGGER, wrapLogger } from \"./logger\";\nimport { Content, Context, createPrompt, createSection, Instruction, Loader, Override, Parser, Prompt, Section, Weighted } from \"./riotprompt\";\n\n// ===== CONFIGURATION SCHEMAS =====\n\nconst ContentItemSchema = z.union([\n z.string(), // Simple string content\n z.object({\n content: z.string(),\n title: z.string().optional(),\n weight: z.number().optional(),\n }),\n z.object({\n path: z.string(),\n title: z.string().optional(),\n weight: z.number().optional(),\n }),\n z.object({\n directories: z.array(z.string()),\n title: z.string().optional(),\n weight: z.number().optional(),\n })\n]);\n\nconst RecipeConfigSchema = z.object({\n // Core settings\n basePath: z.string(),\n logger: z.any().optional().default(DEFAULT_LOGGER),\n overridePaths: z.array(z.string()).optional().default([\"./\"]),\n overrides: z.boolean().optional().default(false),\n parameters: ParametersSchema.optional().default({}),\n\n // Content sections - smart inference based on naming\n persona: ContentItemSchema.optional(),\n instructions: z.array(ContentItemSchema).optional().default([]),\n content: z.array(ContentItemSchema).optional().default([]),\n context: z.array(ContentItemSchema).optional().default([]),\n\n // Templates and inheritance\n extends: z.string().optional(), // Extend another recipe\n template: z.enum(['commit', 'release', 'documentation', 'review', 'custom']).optional(),\n});\n\ntype RecipeConfig = z.infer<typeof RecipeConfigSchema>;\ntype ContentItem = z.infer<typeof ContentItemSchema>;\n\n// ===== CONFIGURABLE TEMPLATE PATHS =====\n\n// Default template configurations - can be overridden by user\nexport interface TemplateConfig {\n persona?: ContentItem;\n instructions?: ContentItem[];\n content?: ContentItem[];\n context?: ContentItem[];\n}\n\n// Built-in template configurations matching common patterns\nconst DEFAULT_TEMPLATES: Record<string, TemplateConfig> = {\n commit: {\n persona: { path: \"personas/developer.md\", title: \"Developer Persona\" },\n instructions: [\n { path: \"instructions/commit.md\", title: \"Commit Instructions\" },\n ],\n },\n release: {\n persona: { path: \"personas/releaser.md\", title: \"Release Manager Persona\" },\n instructions: [\n { path: \"instructions/release.md\", title: \"Release Instructions\" },\n ],\n },\n documentation: {\n persona: { path: \"personas/technical-writer.md\", title: \"Technical Writer Persona\" },\n instructions: [\n { path: \"instructions/documentation.md\", title: \"Documentation Instructions\" },\n ],\n },\n review: {\n persona: { path: \"personas/reviewer.md\", title: \"Code Reviewer Persona\" },\n instructions: [\n { path: \"instructions/review.md\", title: \"Review Instructions\" },\n ],\n },\n};\n\n// User-customizable template registry\nlet TEMPLATES = { ...DEFAULT_TEMPLATES };\n\n/**\n * Configure custom template paths (perfect for KodrDriv constants!)\n * \n * @example\n * ```typescript\n * // Configure using your KodrDriv constants\n * configureTemplates({\n * commit: {\n * persona: { path: DEFAULT_PERSONA_YOU_FILE },\n * instructions: [{ path: DEFAULT_INSTRUCTIONS_COMMIT_FILE }]\n * },\n * release: {\n * persona: { path: DEFAULT_PERSONA_RELEASER_FILE },\n * instructions: [{ path: DEFAULT_INSTRUCTIONS_RELEASE_FILE }]\n * }\n * });\n * ```\n */\nexport const configureTemplates = (customTemplates: Record<string, TemplateConfig>): void => {\n TEMPLATES = { ...DEFAULT_TEMPLATES, ...customTemplates };\n};\n\n/**\n * Get current template configuration\n */\nexport const getTemplates = (): Record<string, TemplateConfig> => ({ ...TEMPLATES });\n\n// ===== CORE RECIPE ENGINE =====\n\nexport const cook = async (config: Partial<RecipeConfig> & { basePath: string }): Promise<Prompt> => {\n // Parse and validate configuration with defaults\n const validatedConfig = RecipeConfigSchema.parse({\n overridePaths: [\"./\"\n ],\n overrides: false,\n parameters: {},\n instructions: [],\n content: [],\n context: [],\n ...config\n });\n\n // Handle template inheritance\n let finalConfig = { ...validatedConfig };\n if (validatedConfig.template) {\n const template = TEMPLATES[validatedConfig.template];\n if (template) {\n finalConfig = { ...template, ...validatedConfig };\n }\n }\n\n // Setup internal services\n const logger = wrapLogger(finalConfig.logger, 'Recipe');\n const parser = Parser.create({ logger });\n const override = Override.create({\n logger,\n configDirs: finalConfig.overridePaths || [\"./\"],\n overrides: finalConfig.overrides || false\n });\n const loader = Loader.create({ logger });\n\n // Create sections\n const personaSection: Section<Instruction> = createSection({ title: \"Persona\" });\n const instructionSection: Section<Instruction> = createSection({ title: \"Instruction\" });\n const contentSection: Section<Content> = createSection({ title: \"Content\" });\n const contextSection: Section<Context> = createSection({ title: \"Context\" });\n\n // Process persona\n if (finalConfig.persona) {\n await processContentItem(finalConfig.persona, personaSection, 'persona', {\n basePath: finalConfig.basePath,\n parser,\n override,\n loader,\n parameters: finalConfig.parameters,\n logger\n });\n }\n\n // Process instructions\n for (const item of finalConfig.instructions || []) {\n await processContentItem(item, instructionSection, 'instruction', {\n basePath: finalConfig.basePath,\n parser,\n override,\n loader,\n parameters: finalConfig.parameters,\n logger\n });\n }\n\n // Process content\n for (const item of finalConfig.content || []) {\n await processContentItem(item, contentSection, 'content', {\n basePath: finalConfig.basePath,\n parser,\n override,\n loader,\n parameters: finalConfig.parameters,\n logger\n });\n }\n\n // Process context\n for (const item of finalConfig.context || []) {\n await processContentItem(item, contextSection, 'context', {\n basePath: finalConfig.basePath,\n parser,\n override,\n loader,\n parameters: finalConfig.parameters,\n logger\n });\n }\n\n // Build and return prompt\n return createPrompt({\n persona: personaSection,\n instructions: instructionSection,\n contents: contentSection,\n contexts: contextSection\n });\n};\n\n// ===== CONTENT PROCESSING =====\n\ninterface ProcessingContext {\n basePath: string;\n parser: any;\n override: any;\n loader: any;\n parameters: any;\n logger: any;\n}\n\nconst processContentItem = async <T extends Weighted>(\n item: ContentItem,\n section: Section<T>,\n type: 'persona' | 'instruction' | 'content' | 'context',\n ctx: ProcessingContext\n): Promise<void> => {\n const sectionOptions: SectionOptions = {\n parameters: ctx.parameters,\n };\n\n if (typeof item === 'string') {\n // Simple string content\n const parsedSection = ctx.parser.parse(item, sectionOptions);\n section.add(parsedSection);\n } else if ('content' in item) {\n // Inline content with options\n const parsedSection = ctx.parser.parse(item.content, {\n ...sectionOptions,\n title: item.title,\n weight: item.weight,\n });\n section.add(parsedSection);\n } else if ('path' in item) {\n // File path\n const fullPath = path.join(ctx.basePath, item.path);\n const parsedSection = await ctx.parser.parseFile(fullPath, {\n ...sectionOptions,\n title: item.title,\n weight: item.weight,\n });\n const overrideSection = await ctx.override.customize(item.path, parsedSection, sectionOptions);\n section.add(overrideSection);\n } else if ('directories' in item) {\n // Directory loading\n const sections = await ctx.loader.load(item.directories, {\n ...sectionOptions,\n title: item.title,\n weight: item.weight,\n });\n section.add(sections);\n }\n};\n\n// ===== CONVENIENCE FUNCTIONS =====\n\nexport const commit = (config: Partial<RecipeConfig> & { basePath: string }): Promise<Prompt> =>\n cook({ ...config, template: 'commit' });\n\nexport const release = (config: Partial<RecipeConfig> & { basePath: string }): Promise<Prompt> =>\n cook({ ...config, template: 'release' });\n\nexport const documentation = (config: Partial<RecipeConfig> & { basePath: string }): Promise<Prompt> =>\n cook({ ...config, template: 'documentation' });\n\nexport const review = (config: Partial<RecipeConfig> & { basePath: string }): Promise<Prompt> =>\n cook({ ...config, template: 'review' });\n\n// ===== QUICK BUILDERS =====\n\nexport const quick = {\n /**\n * Create a commit prompt with minimal configuration\n */\n commit: async (diffContent: string, options: {\n basePath: string;\n overridePaths?: string[];\n overrides?: boolean;\n userDirection?: string;\n context?: string;\n directories?: string[];\n }): Promise<Prompt> => {\n return cook({\n basePath: options.basePath,\n overridePaths: options.overridePaths,\n overrides: options.overrides,\n template: 'commit',\n content: [\n ...(options.userDirection ? [{ content: options.userDirection, title: 'User Direction', weight: 1.0 }] : []),\n { content: diffContent, title: 'Diff', weight: 0.5 },\n ],\n context: [\n ...(options.context ? [{ content: options.context, title: 'User Context', weight: 1.0 }] : []),\n ...(options.directories ? [{ directories: options.directories, weight: 0.5 }] : []),\n ],\n });\n },\n\n /**\n * Create a release prompt with minimal configuration\n */\n release: async (logContent: string, diffContent: string, options: {\n basePath: string;\n overridePaths?: string[];\n overrides?: boolean;\n releaseFocus?: string;\n context?: string;\n directories?: string[];\n }): Promise<Prompt> => {\n return cook({\n basePath: options.basePath,\n overridePaths: options.overridePaths,\n overrides: options.overrides,\n template: 'release',\n content: [\n ...(options.releaseFocus ? [{ content: options.releaseFocus, title: 'Release Focus', weight: 1.0 }] : []),\n { content: logContent, title: 'Log', weight: 0.5 },\n { content: diffContent, title: 'Diff', weight: 0.5 },\n ],\n context: [\n ...(options.context ? [{ content: options.context, title: 'User Context', weight: 1.0 }] : []),\n ...(options.directories ? [{ directories: options.directories, weight: 0.5 }] : []),\n ],\n });\n },\n};\n\n// ===== FLUENT RECIPE BUILDER =====\n\nexport const recipe = (basePath: string) => ({\n template: (name: 'commit' | 'release' | 'documentation' | 'review') => ({\n with: (config: Partial<RecipeConfig>) =>\n cook({ basePath, template: name, ...config }),\n }),\n\n persona: (persona: ContentItem) => ({\n instructions: (...instructions: ContentItem[]) => ({\n content: (...content: ContentItem[]) => ({\n context: (...context: ContentItem[]) => ({\n cook: () => cook({ basePath, persona, instructions, content, context }),\n }),\n cook: () => cook({ basePath, persona, instructions, content }),\n }),\n cook: () => cook({ basePath, persona, instructions }),\n }),\n cook: () => cook({ basePath, persona }),\n }),\n\n cook: (config: Partial<RecipeConfig>) => cook({ basePath, ...config }),\n});\n\n// Export types for external use\nexport type { RecipeConfig, ContentItem }; "],"names":["ContentItemSchema","z","union","string","object","content","title","optional","weight","number","path","directories","array","RecipeConfigSchema","basePath","logger","any","default","DEFAULT_LOGGER","overridePaths","overrides","boolean","parameters","ParametersSchema","persona","instructions","context","extends","template","enum","DEFAULT_TEMPLATES","commit","release","documentation","review","TEMPLATES","configureTemplates","customTemplates","getTemplates","cook","config","validatedConfig","parse","finalConfig","wrapLogger","parser","Parser","override","Override","configDirs","loader","Loader","personaSection","createSection","instructionSection","contentSection","contextSection","processContentItem","item","createPrompt","contents","contexts","section","type","ctx","sectionOptions","parsedSection","add","fullPath","join","parseFile","overrideSection","customize","sections","load","quick","diffContent","options","userDirection","logContent","releaseFocus","recipe","name","with"],"mappings":";;;;;;;;;;;;;AAOA;AAEA,MAAMA,iBAAAA,GAAoBC,CAAAA,CAAEC,KAAK,CAAC;AAC9BD,IAAAA,CAAAA,CAAEE,MAAM,EAAA;AACRF,IAAAA,CAAAA,CAAEG,MAAM,CAAC;AACLC,QAAAA,OAAAA,EAASJ,EAAEE,MAAM,EAAA;QACjBG,KAAAA,EAAOL,CAAAA,CAAEE,MAAM,EAAA,CAAGI,QAAQ,EAAA;QAC1BC,MAAAA,EAAQP,CAAAA,CAAEQ,MAAM,EAAA,CAAGF,QAAQ;AAC/B,KAAA,CAAA;AACAN,IAAAA,CAAAA,CAAEG,MAAM,CAAC;AACLM,QAAAA,IAAAA,EAAMT,EAAEE,MAAM,EAAA;QACdG,KAAAA,EAAOL,CAAAA,CAAEE,MAAM,EAAA,CAAGI,QAAQ,EAAA;QAC1BC,MAAAA,EAAQP,CAAAA,CAAEQ,MAAM,EAAA,CAAGF,QAAQ;AAC/B,KAAA,CAAA;AACAN,IAAAA,CAAAA,CAAEG,MAAM,CAAC;AACLO,QAAAA,WAAAA,EAAaV,CAAAA,CAAEW,KAAK,CAACX,CAAAA,CAA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AM,CAAC3C,SACHD,IAAAA,CAAK;AAAEzB,wBAAAA,QAAAA;wBAAUc,QAAAA,EAAUsD,IAAAA;AAAM,wBAAA,GAAG1C;AAAO,qBAAA;aACnD,CAAA;QAEAhB,OAAAA,EAAS,CAACA,WAA0B;gBAChCC,YAAAA,EAAc,CAAC,GAAGA,YAAAA,IAAiC;wBAC/CpB,OAAAA,EAAS,CAAC,GAAGA,OAAAA,IAA4B;gCACrCqB,OAAAA,EAAS,CAAC,GAAGA,OAAAA,IAA4B;AACrCa,wCAAAA,IAAAA,EAAM,IAAMA,IAAAA,CAAK;AAAEzB,gDAAAA,QAAAA;AAAUU,gDAAAA,OAAAA;AAASC,gDAAAA,YAAAA;AAAcpB,gDAAAA,OAAAA;AAASqB,gDAAAA;AAAQ,6CAAA;qCACzE,CAAA;AACAa,gCAAAA,IAAAA,EAAM,IAAMA,IAAAA,CAAK;AAAEzB,wCAAAA,QAAAA;AAAUU,wCAAAA,OAAAA;AAASC,wCAAAA,YAAAA;AAAcpB,wCAAAA;AAAQ,qCAAA;6BAChE,CAAA;AACAkC,wBAAAA,IAAAA,EAAM,IAAMA,IAAAA,CAAK;AAAEzB,gCAAAA,QAAAA;AAAUU,gCAAAA,OAAAA;AAASC,gCAAAA;AAAa,6BAAA;qBACvD,CAAA;AACAc,gBAAAA,IAAAA,EAAM,IAAMA,IAAAA,CAAK;AAAEzB,wBAAAA,QAAAA;AAAUU,wBAAAA;AAAQ,qBAAA;aACzC,CAAA;QAEAe,IAAAA,EAAM,CAACC,SAAkCD,IAAAA,CAAK;AAAEzB,gBAAAA,QAAAA;AAAU,gBAAA,GAAG0B;AAAO,aAAA;AACxE,KAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"recipes.js","sources":["../src/recipes.ts"],"sourcesContent":["import path from \"path\";\nimport { z } from \"zod\";\nimport { ParametersSchema } from \"./items/parameters\";\nimport { SectionOptions } from \"./items/section\";\nimport { DEFAULT_LOGGER, wrapLogger } from \"./logger\";\nimport { Content, Context, createPrompt, createSection, Instruction, Loader, Override, Parser, Prompt, Section, Weighted } from \"./riotprompt\";\n\n// ===== CONFIGURATION SCHEMAS =====\n\nconst ContentItemSchema = z.union([\n z.string(), // Simple string content\n z.object({\n content: z.string(),\n title: z.string().optional(),\n weight: z.number().optional(),\n }),\n z.object({\n path: z.string(),\n title: z.string().optional(),\n weight: z.number().optional(),\n }),\n z.object({\n directories: z.array(z.string()),\n title: z.string().optional(),\n weight: z.number().optional(),\n })\n]);\n\nconst RecipeConfigSchema = z.object({\n // Core settings\n basePath: z.string(),\n logger: z.any().optional().default(DEFAULT_LOGGER),\n overridePaths: z.array(z.string()).optional().default([\"./\"]),\n overrides: z.boolean().optional().default(false),\n parameters: ParametersSchema.optional().default({}),\n\n // Content sections\n persona: ContentItemSchema.optional(),\n instructions: z.array(ContentItemSchema).optional().default([]),\n content: z.array(ContentItemSchema).optional().default([]),\n context: z.array(ContentItemSchema).optional().default([]),\n\n // Templates and inheritance\n extends: z.string().optional(), // Extend another recipe\n template: z.string().optional(), // Generic template name\n});\n\ntype RecipeConfig = z.infer<typeof RecipeConfigSchema>;\ntype ContentItem = z.infer<typeof ContentItemSchema>;\n\n// ===== CONFIGURABLE TEMPLATE SYSTEM =====\n\nexport interface TemplateConfig {\n persona?: ContentItem;\n instructions?: ContentItem[];\n content?: ContentItem[];\n context?: ContentItem[];\n}\n\n// User-customizable template registry\nlet TEMPLATES: Record<string, TemplateConfig> = {};\n\n/**\n * Register custom templates with the recipes system\n * \n * @example\n * ```typescript\n * // Register your own templates\n * registerTemplates({\n * myWorkflow: {\n * persona: { path: \"personas/my-persona.md\" },\n * instructions: [{ path: \"instructions/my-instructions.md\" }]\n * },\n * anotherTemplate: {\n * persona: { content: \"You are a helpful assistant\" },\n * instructions: [{ content: \"Follow these steps...\" }]\n * }\n * });\n * ```\n */\nexport const registerTemplates = (templates: Record<string, TemplateConfig>): void => {\n TEMPLATES = { ...TEMPLATES, ...templates };\n};\n\n/**\n * Get currently registered templates\n */\nexport const getTemplates = (): Record<string, TemplateConfig> => ({ ...TEMPLATES });\n\n/**\n * Clear all registered templates\n */\nexport const clearTemplates = (): void => {\n TEMPLATES = {};\n};\n\n// ===== CORE RECIPE ENGINE =====\n\nexport const cook = async (config: Partial<RecipeConfig> & { basePath: string }): Promise<Prompt> => {\n // Parse and validate configuration with defaults\n const validatedConfig = RecipeConfigSchema.parse({\n overridePaths: [\"./\"],\n overrides: false,\n parameters: {},\n instructions: [],\n content: [],\n context: [],\n ...config\n });\n\n // Handle template inheritance\n let finalConfig = { ...validatedConfig };\n if (validatedConfig.template) {\n const template = TEMPLATES[validatedConfig.template];\n if (template) {\n finalConfig = {\n ...validatedConfig,\n persona: validatedConfig.persona || template.persona,\n instructions: [\n ...(template.instructions || []),\n ...(validatedConfig.instructions || [])\n ],\n content: [\n ...(template.content || []),\n ...(validatedConfig.content || [])\n ],\n context: [\n ...(template.context || []),\n ...(validatedConfig.context || [])\n ],\n };\n }\n }\n\n // Setup internal services\n const logger = wrapLogger(finalConfig.logger, 'Recipe');\n const parser = Parser.create({ logger });\n const override = Override.create({\n logger,\n configDirs: finalConfig.overridePaths || [\"./\"],\n overrides: finalConfig.overrides || false\n });\n const loader = Loader.create({ logger });\n\n // Create sections\n const personaSection: Section<Instruction> = createSection({ title: \"Persona\" });\n const instructionSection: Section<Instruction> = createSection({ title: \"Instruction\" });\n const contentSection: Section<Content> = createSection({ title: \"Content\" });\n const contextSection: Section<Context> = createSection({ title: \"Context\" });\n\n // Process persona\n if (finalConfig.persona) {\n await processContentItem(finalConfig.persona, personaSection, 'persona', {\n basePath: finalConfig.basePath,\n parser,\n override,\n loader,\n parameters: finalConfig.parameters,\n logger\n });\n }\n\n // Process instructions\n for (const item of finalConfig.instructions || []) {\n await processContentItem(item, instructionSection, 'instruction', {\n basePath: finalConfig.basePath,\n parser,\n override,\n loader,\n parameters: finalConfig.parameters,\n logger\n });\n }\n\n // Process content\n for (const item of finalConfig.content || []) {\n await processContentItem(item, contentSection, 'content', {\n basePath: finalConfig.basePath,\n parser,\n override,\n loader,\n parameters: finalConfig.parameters,\n logger\n });\n }\n\n // Process context\n for (const item of finalConfig.context || []) {\n await processContentItem(item, contextSection, 'context', {\n basePath: finalConfig.basePath,\n parser,\n override,\n loader,\n parameters: finalConfig.parameters,\n logger\n });\n }\n\n // Build and return prompt\n return createPrompt({\n persona: personaSection,\n instructions: instructionSection,\n contents: contentSection,\n contexts: contextSection\n });\n};\n\n// ===== CONTENT PROCESSING =====\n\ninterface ProcessingContext {\n basePath: string;\n parser: any;\n override: any;\n loader: any;\n parameters: any;\n logger: any;\n}\n\nconst processContentItem = async <T extends Weighted>(\n item: ContentItem,\n section: Section<T>,\n type: 'persona' | 'instruction' | 'content' | 'context',\n ctx: ProcessingContext\n): Promise<void> => {\n const sectionOptions: SectionOptions = {\n parameters: ctx.parameters,\n };\n\n if (typeof item === 'string') {\n // Simple string content\n const parsedSection = ctx.parser.parse(item, sectionOptions);\n section.add(parsedSection);\n } else if ('content' in item) {\n // Inline content with options\n const parsedSection = ctx.parser.parse(item.content, {\n ...sectionOptions,\n title: item.title,\n weight: item.weight,\n });\n section.add(parsedSection);\n } else if ('path' in item) {\n // File path\n const fullPath = path.join(ctx.basePath, item.path);\n const parsedSection = await ctx.parser.parseFile(fullPath, {\n ...sectionOptions,\n title: item.title,\n weight: item.weight,\n });\n const overrideSection = await ctx.override.customize(item.path, parsedSection, sectionOptions);\n section.add(overrideSection);\n } else if ('directories' in item) {\n // Directory loading\n const sections = await ctx.loader.load(item.directories, {\n ...sectionOptions,\n title: item.title,\n weight: item.weight,\n });\n section.add(sections);\n }\n};\n\n// ===== FLUENT RECIPE BUILDER =====\n\nexport const recipe = (basePath: string) => ({\n template: (name: string) => ({\n with: (config: Partial<RecipeConfig>) =>\n cook({ basePath, template: name, ...config }),\n }),\n\n persona: (persona: ContentItem) => ({\n instructions: (...instructions: ContentItem[]) => ({\n content: (...content: ContentItem[]) => ({\n context: (...context: ContentItem[]) => ({\n cook: () => cook({ basePath, persona, instructions, content, context }),\n }),\n cook: () => cook({ basePath, persona, instructions, content }),\n }),\n cook: () => cook({ basePath, persona, instructions }),\n }),\n cook: () => cook({ basePath, persona }),\n }),\n\n cook: (config: Partial<RecipeConfig>) => cook({ basePath, ...config }),\n});\n\n// Export types for external use\nexport type { RecipeConfig, ContentItem }; "],"names":["ContentItemSchema","z","union","string","object","content","title","optional","weight","number","path","directories","array","RecipeConfigSchema","basePath","logger","any","default","DEFAULT_LOGGER","overridePaths","overrides","boolean","parameters","ParametersSchema","persona","instructions","context","extends","template","TEMPLATES","registerTemplates","templates","getTemplates","clearTemplates","cook","config","validatedConfig","parse","finalConfig","wrapLogger","parser","Parser","override","Override","configDirs","loader","Loader","personaSection","createSection","instructionSection","contentSection","contextSection","processContentItem","item","createPrompt","contents","contexts","section","type","ctx","sectionOptions","parsedSection","add","fullPath","join","parseFile","overrideSection","customize","sections","load","recipe","name","with"],"mappings":";;;;;;;;;;;;;AAOA;AAEA,MAAMA,iBAAAA,GAAoBC,CAAAA,CAAEC,KAAK,CAAC;AAC9BD,IAAAA,CAAAA,CAAEE,MAAM,EAAA;AACRF,IAAAA,CAAAA,CAAEG,MAAM,CAAC;AACLC,QAAAA,OAAAA,EAASJ,EAAEE,MAAM,EAAA;QACjBG,KAAAA,EAAOL,CAAAA,CAAEE,MAAM,EAAA,CAAGI,QAAQ,EAAA;QAC1BC,MAAAA,EAAQP,CAAAA,CAAEQ,MAAM,EAAA,CAAGF,QAAQ;AAC/B,KAAA,CAAA;AACAN,IAAAA,CAAAA,CAAEG,MAAM,CAAC;AACLM,QAAAA,IAAAA,EAAMT,EAAEE,MAAM,EAAA;QACdG,KAAAA,EAAOL,CAAAA,CAAEE,MAAM,EAAA,CAAGI,QAAQ,EAAA;QAC1BC,MAAAA,EAAQP,CAAAA,CAAEQ,MAAM,EAAA,CAAGF,QAAQ;AAC/B,KAAA,CAAA;AACAN,IAAAA,CAAAA,CAAEG,MAAM,CAAC;A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