@riotprompt/riotprompt 0.0.11 → 0.0.13

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.
Files changed (52) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +121 -21
  3. package/dist/builder.js +3 -0
  4. package/dist/builder.js.map +1 -1
  5. package/dist/cli.cjs +1519 -0
  6. package/dist/cli.d.ts +8 -0
  7. package/dist/config.d.ts +7 -0
  8. package/dist/conversation-logger.js +6 -1
  9. package/dist/conversation-logger.js.map +1 -1
  10. package/dist/execution/anthropic.d.ts +5 -0
  11. package/dist/execution/anthropic.js +46 -0
  12. package/dist/execution/anthropic.js.map +1 -0
  13. package/dist/execution/gemini.d.ts +5 -0
  14. package/dist/execution/gemini.js +78 -0
  15. package/dist/execution/gemini.js.map +1 -0
  16. package/dist/execution/index.d.ts +10 -0
  17. package/dist/execution/index.js +53 -0
  18. package/dist/execution/index.js.map +1 -0
  19. package/dist/execution/openai.d.ts +5 -0
  20. package/dist/execution/openai.js +44 -0
  21. package/dist/execution/openai.js.map +1 -0
  22. package/dist/execution/provider.d.ts +18 -0
  23. package/dist/loader.js +3 -0
  24. package/dist/loader.js.map +1 -1
  25. package/dist/model-config.d.ts +1 -0
  26. package/dist/model-config.js +19 -18
  27. package/dist/model-config.js.map +1 -1
  28. package/dist/override.js +3 -0
  29. package/dist/override.js.map +1 -1
  30. package/dist/recipes.js +3 -0
  31. package/dist/recipes.js.map +1 -1
  32. package/dist/riotprompt.cjs +612 -77
  33. package/dist/riotprompt.cjs.map +1 -1
  34. package/dist/riotprompt.d.ts +3 -0
  35. package/dist/riotprompt.js +6 -0
  36. package/dist/riotprompt.js.map +1 -1
  37. package/dist/serializer.d.ts +5 -0
  38. package/dist/serializer.js +220 -0
  39. package/dist/serializer.js.map +1 -0
  40. package/dist/writer.d.ts +2 -0
  41. package/dist/writer.js +91 -0
  42. package/dist/writer.js.map +1 -0
  43. package/guide/architecture.md +51 -0
  44. package/guide/configuration.md +51 -0
  45. package/guide/development.md +62 -0
  46. package/guide/index.md +55 -0
  47. package/guide/usage.md +99 -0
  48. package/package.json +14 -3
  49. package/vite.config.cli.ts +49 -0
  50. package/BUG-ANALYSIS.md +0 -523
  51. package/CODE-REVIEW-SUMMARY.md +0 -330
  52. package/FIXES-APPLIED.md +0 -437
package/LICENSE CHANGED
@@ -175,7 +175,7 @@
175
175
 
176
176
  END OF TERMS AND CONDITIONS
177
177
 
178
- Copyright 2025 St. Just Reckoning
178
+ Copyright 2025 Tim O'Brien
179
179
 
180
180
  Licensed under the Apache License, Version 2.0 (the "License");
181
181
  you may not use this file except in compliance with the License.
package/README.md CHANGED
@@ -1,17 +1,121 @@
1
- # 🔥 RiotPrompt
1
+ # RiotPrompt
2
2
 
3
- A powerful, flexible prompt building library for AI applications with zero hardcoded assumptions.
3
+ A powerful, flexible prompt building library and CLI tool for AI applications with zero hardcoded assumptions.
4
4
 
5
- ## 🎯 Features
5
+ ## Features
6
6
 
7
- - **Generic & Extensible**: No hardcoded domain concepts - build any type of prompt
8
- - **Template System**: Create reusable templates for common patterns
9
- - **Declarative Configuration**: Simple object-based prompt creation
10
- - **Type-Safe**: Full TypeScript support with excellent IntelliSense
11
- - **Override System**: Customize prompts with hierarchical overrides
12
- - **Multiple Content Types**: Support for files, directories, and inline content
7
+ - **Structured Prompts**: Treat prompts as code with sections for Persona, Instructions, and Context.
8
+ - **CLI Tool**: Scaffold, manage, process, and **execute** prompts directly from the terminal.
9
+ - **Model Agnostic**: Format prompts for different models (GPT-4, Claude, Gemini, etc.) automatically.
10
+ - **Model Families**: Intelligent handling of model-specific quirks (e.g., 'developer' vs 'system' roles for O-series vs GPT-4).
11
+ - **Execution Engine**: Run prompts against OpenAI, Anthropic, or Gemini APIs directly.
12
+ - **Portable**: Serialize prompts to JSON or XML for easy exchange between systems.
13
+ - **Type-Safe**: Full TypeScript support with excellent IntelliSense.
13
14
 
14
- ## 🚀 Quick Start
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install riotprompt
19
+ ```
20
+
21
+ ## CLI Usage
22
+
23
+ RiotPrompt comes with a command-line interface to help you organize, process, and execute prompts.
24
+
25
+ ### 1. Create a Prompt
26
+
27
+ Scaffold a new prompt directory structure:
28
+
29
+ ```bash
30
+ # Create a new prompt in 'my-prompt' directory
31
+ npx riotprompt create my-prompt --persona "You are a data expert."
32
+
33
+ # Import an existing prompt from JSON or XML
34
+ npx riotprompt create my-prompt --import existing-prompt.json
35
+ ```
36
+
37
+ This creates a structured directory:
38
+ ```
39
+ my-prompt/
40
+ ├── persona.md # System prompt / Persona definition
41
+ ├── instructions.md # Main task instructions
42
+ └── context/ # Directory for reference files (data.json, docs.md)
43
+ ```
44
+
45
+ ### 2. Process a Prompt
46
+
47
+ Compile a prompt directory (or file) into a formatted payload for an LLM, or export it to other formats.
48
+
49
+ ```bash
50
+ # Format for GPT-4 (output to console)
51
+ npx riotprompt process my-prompt -m gpt-4
52
+
53
+ # Export to JSON (useful for API integrations)
54
+ npx riotprompt process my-prompt --format json --output prompt.json
55
+
56
+ # Export to XML
57
+ npx riotprompt process my-prompt --format xml --output prompt.xml
58
+ ```
59
+
60
+ ### 3. Execute a Prompt
61
+
62
+ Run the prompt directly against an LLM provider.
63
+
64
+ #### Provider Setup & API Keys
65
+
66
+ RiotPrompt supports multiple LLM providers. You'll need to obtain an API key for the provider you wish to use and set it as an environment variable (recommended) or pass it via the `-k` flag.
67
+
68
+ ##### Google Gemini
69
+ 1. **Get API Key**: Visit [Google AI Studio](https://aistudio.google.com/), sign in, and click "Get API key".
70
+ 2. **Set Environment Variable**: `GEMINI_API_KEY`
71
+ 3. **Available Models**: Check the [Gemini models documentation](https://ai.google.dev/models/gemini). Common models include `gemini-1.5-pro`, `gemini-1.5-flash`.
72
+
73
+ ##### OpenAI
74
+ 1. **Get API Key**: Go to the [OpenAI Platform](https://platform.openai.com/api-keys), sign up/login, and create a new secret key.
75
+ 2. **Set Environment Variable**: `OPENAI_API_KEY`
76
+ 3. **Available Models**: See [OpenAI Models](https://platform.openai.com/docs/models). Common models: `gpt-4o`, `gpt-4-turbo`, `gpt-3.5-turbo`.
77
+
78
+ ##### Anthropic (Claude)
79
+ 1. **Get API Key**: Access the [Anthropic Console](https://console.anthropic.com/settings/keys) and generate an API key.
80
+ 2. **Set Environment Variable**: `ANTHROPIC_API_KEY`
81
+ 3. **Available Models**: View [Claude Models](https://docs.anthropic.com/en/docs/models-overview). Common models: `claude-3-opus-20240229`, `claude-3-sonnet-20240229`.
82
+
83
+ **Example .env file:**
84
+ ```bash
85
+ OPENAI_API_KEY=sk-...
86
+ ANTHROPIC_API_KEY=sk-ant-...
87
+ GEMINI_API_KEY=AIza...
88
+ ```
89
+
90
+ **Commands**:
91
+
92
+ ```bash
93
+ # Run with default model (usually gpt-4)
94
+ npx riotprompt execute my-prompt
95
+
96
+ # Run with specific model
97
+ npx riotprompt execute my-prompt -m claude-3-opus
98
+
99
+ # Run with explicit API key (overrides env)
100
+ npx riotprompt execute my-prompt -m gpt-4 -k sk-proj-...
101
+
102
+ # Control parameters
103
+ npx riotprompt execute my-prompt -t 0.7 --max-tokens 1000
104
+ ```
105
+
106
+ ### Configuration
107
+
108
+ You can configure defaults using a `riotprompt.yaml` file in your project root:
109
+
110
+ ```yaml
111
+ defaultModel: "gpt-4"
112
+ promptsDir: "./prompts"
113
+ outputDir: "./output"
114
+ ```
115
+
116
+ ## Library Usage
117
+
118
+ You can also use RiotPrompt programmatically in your application.
15
119
 
16
120
  ```typescript
17
121
  import { cook, registerTemplates } from 'riotprompt';
@@ -48,24 +152,20 @@ const analysisPrompt = await cook({
48
152
  });
49
153
  ```
50
154
 
51
- ## 📚 Documentation
155
+ ## Documentation
156
+
157
+ For more detailed guides on architecture and advanced usage, check the [Guide](guide/index.md).
52
158
 
53
159
  - [Core Concepts](docs/public/core-concepts.md)
54
160
  - [Recipes System](docs/public/recipes.md)
55
161
  - [API Reference](docs/public/api-reference.md)
56
162
  - [Template Configuration](docs/public/template-configuration.md)
57
163
 
58
- ## 🔧 Installation
59
-
60
- ```bash
61
- npm install riotprompt
62
- ```
63
-
64
- ## 💡 Philosophy
164
+ ## Philosophy
65
165
 
66
166
  RiotPrompt is designed to be completely generic and unopinionated. Unlike other prompt libraries that assume specific use cases, RiotPrompt provides the building blocks for any prompt-based application while maintaining type safety and developer experience.
67
167
 
68
- ## 🏗️ Architecture
168
+ ## Architecture
69
169
 
70
170
  - **Cook Function**: Core prompt creation engine
71
171
  - **Template System**: Reusable configuration patterns
@@ -73,11 +173,11 @@ RiotPrompt is designed to be completely generic and unopinionated. Unlike other
73
173
  - **Override System**: Hierarchical customization
74
174
  - **Type Safety**: Full TypeScript support throughout
75
175
 
76
- ## 🤝 Contributing
176
+ ## Contributing
77
177
 
78
178
  Contributions are welcome! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
79
179
 
80
- ## 📄 License
180
+ ## License
81
181
 
82
182
  Apache-2.0 License - see [LICENSE](LICENSE) for details.
83
183
 
package/dist/builder.js CHANGED
@@ -13,6 +13,9 @@ import './recipes.js';
13
13
  import './conversation.js';
14
14
  import 'tiktoken';
15
15
  import './tools.js';
16
+ import 'openai';
17
+ import '@anthropic-ai/sdk';
18
+ import '@google/generative-ai';
16
19
 
17
20
  const OptionSchema = z.object({
18
21
  logger: z.any().optional().default(DEFAULT_LOGGER),
@@ -1 +1 @@
1
- {"version":3,"file":"builder.js","sources":["../src/builder.ts"],"sourcesContent":["import path from \"path\";\nimport { z } from \"zod\";\nimport { ParametersSchema } from \"./items/parameters\";\nimport { SectionOptions, SectionOptionsSchema } from \"./items/section\";\nimport { DEFAULT_LOGGER, wrapLogger } from \"./logger\";\nimport { Content, Context, createPrompt, createSection, Instruction, Loader, Override, Parser, Prompt, Section, Weighted } from \"./riotprompt\";\n\nconst OptionSchema = z.object({\n logger: z.any().optional().default(DEFAULT_LOGGER),\n basePath: z.string(),\n overridePaths: z.array(z.string()).optional().default([\"./\"]),\n overrides: z.boolean().optional().default(false),\n parameters: ParametersSchema.optional().default({}),\n});\n\nexport type Options = z.infer<typeof OptionSchema>;\n\nexport type OptionsParam = Required<Pick<Options, 'basePath'>> & Partial<Omit<Options, 'basePath'>>;\n\nexport interface Instance {\n addPersonaPath(contentPath: string, sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n addContextPath(contentPath: string, sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n addInstructionPath(contentPath: string, sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n addContentPath(contentPath: string, sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n addContent(content: string, sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n addContext(context: string, sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n loadContext(contextDirectories: string[], sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n loadContent(contentDirectories: string[], sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n build(): Promise<Prompt>;\n}\n\nexport const create = (builderOptions: OptionsParam): Instance => {\n const options: Required<Options> = OptionSchema.parse(builderOptions) as Required<Options>;\n\n const logger = wrapLogger(options.logger, 'Builder');\n const parser = Parser.create({ logger });\n const override = Override.create({\n logger, configDirs: options.overridePaths || [\"./\"],\n overrides: options.overrides || false\n });\n const loader = Loader.create({ logger });\n\n const personaSection: Section<Instruction> = createSection({ title: \"Persona\" });\n const contextSection: Section<Context> = createSection({ title: \"Context\" });\n const instructionSection: Section<Instruction> = createSection({ title: \"Instruction\" });\n const contentSection: Section<Content> = createSection({ title: \"Content\" });\n const parameters = options.parameters;\n\n\n const instance: Partial<Instance> = {}\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 loadDirectories = async <T extends Weighted>(\n directories: string[],\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Section<T>[]> => {\n const currentOptions = loadOptions(sectionOptions);\n logger.debug(\"Loading directories\", directories);\n const sections: Section<T>[] = await loader.load<T>(directories, currentOptions);\n return sections;\n }\n\n const loadContext = async (\n contextDirectories: string[],\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n const currentOptions = loadOptions(sectionOptions);\n logger.debug('Loading context', contextDirectories);\n const context: Section<Context>[] = await loadDirectories<Context>(contextDirectories, currentOptions);\n contextSection.add(context);\n return instance as Instance;\n }\n instance.loadContext = loadContext;\n\n const loadContent = async (\n contentDirectories: string[],\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n const currentOptions = loadOptions(sectionOptions);\n const content: Section<Content>[] = await loadDirectories<Content>(contentDirectories, currentOptions);\n contentSection.add(content);\n return instance as Instance;\n }\n instance.loadContent = loadContent;\n\n const loadPath = async <T extends Weighted>(\n contentPath: string,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Section<T>> => {\n const currentOptions = loadOptions(sectionOptions);\n const defaultPath = path.join(options.basePath as string, contentPath);\n const section: Section<T> = await parser.parseFile<T>(defaultPath, currentOptions);\n const overrideSection = await override.customize<T>(contentPath, section, currentOptions);\n return overrideSection;\n }\n\n const addPersonaPath = async (\n contentPath: string,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n const currentOptions = loadOptions(sectionOptions);\n const persona: Section<Instruction> = await loadPath<Instruction>(contentPath, currentOptions);\n personaSection.add(persona);\n return instance as Instance;\n }\n instance.addPersonaPath = addPersonaPath;\n\n const addContextPath = async (\n contentPath: string,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n logger.debug(\"Adding context path\", contentPath);\n const currentOptions = loadOptions(sectionOptions);\n const context: Section<Context> = await loadPath<Context>(contentPath, currentOptions);\n contextSection.add(context);\n return instance as Instance;\n }\n instance.addContextPath = addContextPath;\n\n const addInstructionPath = async (\n contentPath: string,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n logger.debug(\"Adding instruction path\", contentPath);\n const currentOptions = loadOptions(sectionOptions);\n const instruction: Section<Instruction> = await loadPath<Instruction>(contentPath, currentOptions);\n instructionSection.add(instruction);\n return instance as Instance;\n }\n instance.addInstructionPath = addInstructionPath;\n\n const addContentPath = async (\n contentPath: string,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n logger.debug(\"Adding content path\", contentPath);\n const currentOptions = loadOptions(sectionOptions);\n const content: Section<Content> = await loadPath<Content>(contentPath, currentOptions);\n contentSection.add(content);\n return instance as Instance;\n }\n instance.addContentPath = addContentPath;\n\n const addContent = async (\n content: string | Buffer,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n logger.debug(\"Adding content\", typeof content);\n const currentOptions = loadOptions(sectionOptions);\n const parsedContentSection: Section<Content> = await parser.parse<Content>(content, currentOptions);\n contentSection.add(parsedContentSection);\n return instance as Instance;\n }\n instance.addContent = addContent;\n\n const addContext = async (\n context: string | Buffer,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n logger.debug(\"Adding context\", typeof context);\n const currentOptions = loadOptions(sectionOptions);\n const parsedContextSection: Section<Context> = await parser.parse<Context>(context, currentOptions);\n contextSection.add(parsedContextSection);\n return instance as Instance;\n }\n instance.addContext = addContext;\n\n const build = async () => {\n logger.debug(\"Building prompt\", {});\n const prompt = createPrompt({ persona: personaSection, contexts: contextSection, instructions: instructionSection, contents: contentSection });\n return prompt;\n }\n instance.build = build;\n\n return instance as Instance;\n}\n"],"names":["OptionSchema","z","object","logger","any","optional","default","DEFAULT_LOGGER","basePath","string","overridePaths","array","overrides","boolean","parameters","ParametersSchema","create","builderOptions","options","parse","wrapLogger","parser","Parser","override","Override","configDirs","loader","Loader","personaSection","createSection","title","contextSection","instructionSection","contentSection","instance","loadOptions","sectionOptions","currentOptions","SectionOptionsSchema","loadDirectories","directories","debug","sections","load","loadContext","contextDirectories","context","add","loadContent","contentDirectories","content","loadPath","contentPath","defaultPath","path","join","section","parseFile","overrideSection","customize","addPersonaPath","persona","addContextPath","addInstructionPath","instruction","addContentPath","addContent","parsedContentSection","addContext","parsedContextSection","build","prompt","createPrompt","contexts","instructions","contents"],"mappings":";;;;;;;;;;;;;;;;AAOA,MAAMA,YAAAA,GAAeC,CAAAA,CAAEC,MAAM,CAAC;AAC1BC,IAAAA,MAAAA,EAAQF,EAAEG,GAAG,EAAA,CAAGC,QAAQ,EAAA,CAAGC,OAAO,CAACC,cAAAA,CAAAA;AACnCC,IAAAA,QAAAA,EAAUP,EAAEQ,MAAM,EAAA;IAClBC,aAAAA,EAAeT,CAAAA,CAAEU,KAAK,CAACV,CAAAA,CAAEQ,MAAM,EAAA,CAAA,CAAIJ,QAAQ,EAAA,CAAGC,OAAO,CAAC;AAAC,QAAA;AAAK,KAAA,CAAA;AAC5DM,IAAAA,SAAAA,EAAWX,EAAEY,OAAO,EAAA,CAAGR,QAAQ,EAAA,CAAGC,OAAO,CAAC,KAAA,CAAA;AAC1CQ,IAAAA,UAAAA,EAAYC,gBAAAA,CAAiBV,QAAQ,EAAA,CAAGC,OAAO,CAAC,EAAC;AACrD,CAAA,CAAA;AAkBO,MAAMU,SAAS,CAACC,cAAAA,GAAAA;IACnB,MAAMC,OAAAA,GAA6BlB,YAAAA,CAAamB,KAAK,CAACF,cAAAA,CAAAA;AAEtD,IAAA,MAAMd,MAAAA,GAASiB,UAAAA,CAAWF,OAAAA,CAAQf,MAAM,EAAE,SAAA,CAAA;IAC1C,MAAMkB,QAAAA,GAASC,QAAa,CAAC;AAAEnB,QAAAA;AAAO,KAAA,CAAA;IACtC,MAAMoB,UAAAA,GAAWC,QAAe,CAAC;AAC7BrB,QAAAA,MAAAA;QAAQsB,UAAAA,EAAYP,OAAAA,CAAQR,aAAa,IAAI;AAAC,YAAA;AAAK,SAAA;QACnDE,SAAAA,EAAWM,OAAAA,CAAQN,SAAS,IAAI;AACpC,KAAA,CAAA;IACA,MAAMc,QAAAA,GAASC,QAAa,CAAC;AAAExB,QAAA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,KAAAA,GAAQ,UAAA;QACVnE,MAAAA,CAAOsC,KAAK,CAAC,iBAAA,EAAmB,EAAC,CAAA;AACjC,QAAA,MAAM8B,SAASC,QAAAA,CAAa;YAAEX,OAAAA,EAASjC,cAAAA;YAAgB6C,QAAAA,EAAU1C,cAAAA;YAAgB2C,YAAAA,EAAc1C,kBAAAA;YAAoB2C,QAAAA,EAAU1C;AAAe,SAAA,CAAA;QAC5I,OAAOsC,MAAAA;AACX,IAAA,CAAA;AACArC,IAAAA,QAAAA,CAASoC,KAAK,GAAGA,KAAAA;IAEjB,OAAOpC,QAAAA;AACX;;;;"}
1
+ {"version":3,"file":"builder.js","sources":["../src/builder.ts"],"sourcesContent":["import path from \"path\";\nimport { z } from \"zod\";\nimport { ParametersSchema } from \"./items/parameters\";\nimport { SectionOptions, SectionOptionsSchema } from \"./items/section\";\nimport { DEFAULT_LOGGER, wrapLogger } from \"./logger\";\nimport { Content, Context, createPrompt, createSection, Instruction, Loader, Override, Parser, Prompt, Section, Weighted } from \"./riotprompt\";\n\nconst OptionSchema = z.object({\n logger: z.any().optional().default(DEFAULT_LOGGER),\n basePath: z.string(),\n overridePaths: z.array(z.string()).optional().default([\"./\"]),\n overrides: z.boolean().optional().default(false),\n parameters: ParametersSchema.optional().default({}),\n});\n\nexport type Options = z.infer<typeof OptionSchema>;\n\nexport type OptionsParam = Required<Pick<Options, 'basePath'>> & Partial<Omit<Options, 'basePath'>>;\n\nexport interface Instance {\n addPersonaPath(contentPath: string, sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n addContextPath(contentPath: string, sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n addInstructionPath(contentPath: string, sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n addContentPath(contentPath: string, sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n addContent(content: string, sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n addContext(context: string, sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n loadContext(contextDirectories: string[], sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n loadContent(contentDirectories: string[], sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n build(): Promise<Prompt>;\n}\n\nexport const create = (builderOptions: OptionsParam): Instance => {\n const options: Required<Options> = OptionSchema.parse(builderOptions) as Required<Options>;\n\n const logger = wrapLogger(options.logger, 'Builder');\n const parser = Parser.create({ logger });\n const override = Override.create({\n logger, configDirs: options.overridePaths || [\"./\"],\n overrides: options.overrides || false\n });\n const loader = Loader.create({ logger });\n\n const personaSection: Section<Instruction> = createSection({ title: \"Persona\" });\n const contextSection: Section<Context> = createSection({ title: \"Context\" });\n const instructionSection: Section<Instruction> = createSection({ title: \"Instruction\" });\n const contentSection: Section<Content> = createSection({ title: \"Content\" });\n const parameters = options.parameters;\n\n\n const instance: Partial<Instance> = {}\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 loadDirectories = async <T extends Weighted>(\n directories: string[],\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Section<T>[]> => {\n const currentOptions = loadOptions(sectionOptions);\n logger.debug(\"Loading directories\", directories);\n const sections: Section<T>[] = await loader.load<T>(directories, currentOptions);\n return sections;\n }\n\n const loadContext = async (\n contextDirectories: string[],\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n const currentOptions = loadOptions(sectionOptions);\n logger.debug('Loading context', contextDirectories);\n const context: Section<Context>[] = await loadDirectories<Context>(contextDirectories, currentOptions);\n contextSection.add(context);\n return instance as Instance;\n }\n instance.loadContext = loadContext;\n\n const loadContent = async (\n contentDirectories: string[],\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n const currentOptions = loadOptions(sectionOptions);\n const content: Section<Content>[] = await loadDirectories<Content>(contentDirectories, currentOptions);\n contentSection.add(content);\n return instance as Instance;\n }\n instance.loadContent = loadContent;\n\n const loadPath = async <T extends Weighted>(\n contentPath: string,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Section<T>> => {\n const currentOptions = loadOptions(sectionOptions);\n const defaultPath = path.join(options.basePath as string, contentPath);\n const section: Section<T> = await parser.parseFile<T>(defaultPath, currentOptions);\n const overrideSection = await override.customize<T>(contentPath, section, currentOptions);\n return overrideSection;\n }\n\n const addPersonaPath = async (\n contentPath: string,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n const currentOptions = loadOptions(sectionOptions);\n const persona: Section<Instruction> = await loadPath<Instruction>(contentPath, currentOptions);\n personaSection.add(persona);\n return instance as Instance;\n }\n instance.addPersonaPath = addPersonaPath;\n\n const addContextPath = async (\n contentPath: string,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n logger.debug(\"Adding context path\", contentPath);\n const currentOptions = loadOptions(sectionOptions);\n const context: Section<Context> = await loadPath<Context>(contentPath, currentOptions);\n contextSection.add(context);\n return instance as Instance;\n }\n instance.addContextPath = addContextPath;\n\n const addInstructionPath = async (\n contentPath: string,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n logger.debug(\"Adding instruction path\", contentPath);\n const currentOptions = loadOptions(sectionOptions);\n const instruction: Section<Instruction> = await loadPath<Instruction>(contentPath, currentOptions);\n instructionSection.add(instruction);\n return instance as Instance;\n }\n instance.addInstructionPath = addInstructionPath;\n\n const addContentPath = async (\n contentPath: string,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n logger.debug(\"Adding content path\", contentPath);\n const currentOptions = loadOptions(sectionOptions);\n const content: Section<Content> = await loadPath<Content>(contentPath, currentOptions);\n contentSection.add(content);\n return instance as Instance;\n }\n instance.addContentPath = addContentPath;\n\n const addContent = async (\n content: string | Buffer,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n logger.debug(\"Adding content\", typeof content);\n const currentOptions = loadOptions(sectionOptions);\n const parsedContentSection: Section<Content> = await parser.parse<Content>(content, currentOptions);\n contentSection.add(parsedContentSection);\n return instance as Instance;\n }\n instance.addContent = addContent;\n\n const addContext = async (\n context: string | Buffer,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n logger.debug(\"Adding context\", typeof context);\n const currentOptions = loadOptions(sectionOptions);\n const parsedContextSection: Section<Context> = await parser.parse<Context>(context, currentOptions);\n contextSection.add(parsedContextSection);\n return instance as Instance;\n }\n instance.addContext = addContext;\n\n const build = async () => {\n logger.debug(\"Building prompt\", {});\n const prompt = createPrompt({ persona: personaSection, contexts: contextSection, instructions: instructionSection, contents: contentSection });\n return prompt;\n }\n instance.build = build;\n\n return instance as Instance;\n}\n"],"names":["OptionSchema","z","object","logger","any","optional","default","DEFAULT_LOGGER","basePath","string","overridePaths","array","overrides","boolean","parameters","ParametersSchema","create","builderOptions","options","parse","wrapLogger","parser","Parser","override","Override","configDirs","loader","Loader","personaSection","createSection","title","contextSection","instructionSection","contentSection","instance","loadOptions","sectionOptions","currentOptions","SectionOptionsSchema","loadDirectories","directories","debug","sections","load","loadContext","contextDirectories","context","add","loadContent","contentDirectories","content","loadPath","contentPath","defaultPath","path","join","section","parseFile","overrideSection","customize","addPersonaPath","persona","addContextPath","addInstructionPath","instruction","addContentPath","addContent","parsedContentSection","addContext","parsedContextSection","build","prompt","createPrompt","contexts","instructions","contents"],"mappings":";;;;;;;;;;;;;;;;;;;AAOA,MAAMA,YAAAA,GAAeC,CAAAA,CAAEC,MAAM,CAAC;AAC1BC,IAAAA,MAAAA,EAAQF,EAAEG,GAAG,EAAA,CAAGC,QAAQ,EAAA,CAAGC,OAAO,CAACC,cAAAA,CAAAA;AACnCC,IAAAA,QAAAA,EAAUP,EAAEQ,MAAM,EAAA;IAClBC,aAAAA,EAAeT,CAAAA,CAAEU,KAAK,CAACV,CAAAA,CAAEQ,MAAM,EAAA,CAAA,CAAIJ,QAAQ,EAAA,CAAGC,OA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