@riotprompt/riotprompt 0.0.1

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 (129) hide show
  1. package/.gitcarve/config.yaml +10 -0
  2. package/.gitcarve/context/content.md +11 -0
  3. package/.markdown-doctest-setup.mjs +23 -0
  4. package/.nvmrc +1 -0
  5. package/LICENSE +190 -0
  6. package/README.md +513 -0
  7. package/dist/builder.cjs +152 -0
  8. package/dist/builder.cjs.map +1 -0
  9. package/dist/builder.d.ts +37 -0
  10. package/dist/builder.js +148 -0
  11. package/dist/builder.js.map +1 -0
  12. package/dist/chat.cjs +26 -0
  13. package/dist/chat.cjs.map +1 -0
  14. package/dist/chat.d.ts +14 -0
  15. package/dist/chat.js +21 -0
  16. package/dist/chat.js.map +1 -0
  17. package/dist/constants.cjs +34 -0
  18. package/dist/constants.cjs.map +1 -0
  19. package/dist/constants.d.ts +13 -0
  20. package/dist/constants.js +23 -0
  21. package/dist/constants.js.map +1 -0
  22. package/dist/formatter.cjs +139 -0
  23. package/dist/formatter.cjs.map +1 -0
  24. package/dist/formatter.d.ts +88 -0
  25. package/dist/formatter.js +131 -0
  26. package/dist/formatter.js.map +1 -0
  27. package/dist/items/content.cjs +14 -0
  28. package/dist/items/content.cjs.map +1 -0
  29. package/dist/items/content.d.ts +3 -0
  30. package/dist/items/content.js +10 -0
  31. package/dist/items/content.js.map +1 -0
  32. package/dist/items/context.cjs +13 -0
  33. package/dist/items/context.cjs.map +1 -0
  34. package/dist/items/context.d.ts +3 -0
  35. package/dist/items/context.js +9 -0
  36. package/dist/items/context.js.map +1 -0
  37. package/dist/items/instruction.cjs +13 -0
  38. package/dist/items/instruction.cjs.map +1 -0
  39. package/dist/items/instruction.d.ts +3 -0
  40. package/dist/items/instruction.js +9 -0
  41. package/dist/items/instruction.js.map +1 -0
  42. package/dist/items/parameters.cjs +53 -0
  43. package/dist/items/parameters.cjs.map +1 -0
  44. package/dist/items/parameters.d.ts +5 -0
  45. package/dist/items/parameters.js +47 -0
  46. package/dist/items/parameters.js.map +1 -0
  47. package/dist/items/section.cjs +120 -0
  48. package/dist/items/section.cjs.map +1 -0
  49. package/dist/items/section.d.ts +33 -0
  50. package/dist/items/section.js +115 -0
  51. package/dist/items/section.js.map +1 -0
  52. package/dist/items/trait.cjs +13 -0
  53. package/dist/items/trait.cjs.map +1 -0
  54. package/dist/items/trait.d.ts +3 -0
  55. package/dist/items/trait.js +9 -0
  56. package/dist/items/trait.js.map +1 -0
  57. package/dist/items/weighted.cjs +27 -0
  58. package/dist/items/weighted.cjs.map +1 -0
  59. package/dist/items/weighted.d.ts +24 -0
  60. package/dist/items/weighted.js +22 -0
  61. package/dist/items/weighted.js.map +1 -0
  62. package/dist/loader.cjs +167 -0
  63. package/dist/loader.cjs.map +1 -0
  64. package/dist/loader.d.ts +35 -0
  65. package/dist/loader.js +161 -0
  66. package/dist/loader.js.map +1 -0
  67. package/dist/logger.cjs +51 -0
  68. package/dist/logger.cjs.map +1 -0
  69. package/dist/logger.d.ts +11 -0
  70. package/dist/logger.js +46 -0
  71. package/dist/logger.js.map +1 -0
  72. package/dist/override.cjs +109 -0
  73. package/dist/override.cjs.map +1 -0
  74. package/dist/override.d.ts +31 -0
  75. package/dist/override.js +105 -0
  76. package/dist/override.js.map +1 -0
  77. package/dist/parse/markdown.cjs +114 -0
  78. package/dist/parse/markdown.cjs.map +1 -0
  79. package/dist/parse/markdown.d.ts +3 -0
  80. package/dist/parse/markdown.js +110 -0
  81. package/dist/parse/markdown.js.map +1 -0
  82. package/dist/parse/text.cjs +33 -0
  83. package/dist/parse/text.cjs.map +1 -0
  84. package/dist/parse/text.d.ts +3 -0
  85. package/dist/parse/text.js +29 -0
  86. package/dist/parse/text.js.map +1 -0
  87. package/dist/parser.cjs +99 -0
  88. package/dist/parser.cjs.map +1 -0
  89. package/dist/parser.d.ts +21 -0
  90. package/dist/parser.js +75 -0
  91. package/dist/parser.js.map +1 -0
  92. package/dist/prompt.cjs +15 -0
  93. package/dist/prompt.cjs.map +1 -0
  94. package/dist/prompt.d.ts +16 -0
  95. package/dist/prompt.js +11 -0
  96. package/dist/prompt.js.map +1 -0
  97. package/dist/riotprompt.cjs +1359 -0
  98. package/dist/riotprompt.cjs.map +1 -0
  99. package/dist/riotprompt.d.ts +25 -0
  100. package/dist/riotprompt.js +21 -0
  101. package/dist/riotprompt.js.map +1 -0
  102. package/dist/util/general.cjs +52 -0
  103. package/dist/util/general.cjs.map +1 -0
  104. package/dist/util/general.d.ts +4 -0
  105. package/dist/util/general.js +47 -0
  106. package/dist/util/general.js.map +1 -0
  107. package/dist/util/markdown.cjs +115 -0
  108. package/dist/util/markdown.cjs.map +1 -0
  109. package/dist/util/markdown.d.ts +7 -0
  110. package/dist/util/markdown.js +111 -0
  111. package/dist/util/markdown.js.map +1 -0
  112. package/dist/util/storage.cjs +155 -0
  113. package/dist/util/storage.cjs.map +1 -0
  114. package/dist/util/storage.d.ts +32 -0
  115. package/dist/util/storage.js +132 -0
  116. package/dist/util/storage.js.map +1 -0
  117. package/dist/util/text.cjs +42 -0
  118. package/dist/util/text.cjs.map +1 -0
  119. package/dist/util/text.d.ts +1 -0
  120. package/dist/util/text.js +38 -0
  121. package/dist/util/text.js.map +1 -0
  122. package/docs/loader.md +237 -0
  123. package/docs/override.md +323 -0
  124. package/docs/parser.md +130 -0
  125. package/eslint.config.mjs +82 -0
  126. package/nodemon.json +14 -0
  127. package/package.json +72 -0
  128. package/vite.config.ts +114 -0
  129. package/vitest.config.ts +25 -0
@@ -0,0 +1,88 @@
1
+ import { Instruction } from './riotprompt';
2
+ import { z } from 'zod';
3
+ import { Message, Model } from './chat';
4
+ import { Section } from './items/section';
5
+ import { Weighted } from './items/weighted';
6
+ import { Prompt } from './prompt';
7
+ import * as Chat from "./chat";
8
+ export declare const SectionSeparatorSchema: z.ZodEnum<["tag", "markdown"]>;
9
+ export declare const SectionTitlePropertySchema: z.ZodEnum<["title", "name"]>;
10
+ export type SectionSeparator = z.infer<typeof SectionSeparatorSchema>;
11
+ export type SectionTitleProperty = z.infer<typeof SectionTitlePropertySchema>;
12
+ export declare const FormatOptionsSchema: z.ZodObject<{
13
+ sectionSeparator: z.ZodEnum<["tag", "markdown"]>;
14
+ sectionIndentation: z.ZodBoolean;
15
+ sectionTitleProperty: z.ZodEnum<["title", "name"]>;
16
+ sectionTitlePrefix: z.ZodOptional<z.ZodString>;
17
+ sectionTitleSeparator: z.ZodOptional<z.ZodString>;
18
+ sectionDepth: z.ZodDefault<z.ZodNumber>;
19
+ }, "strip", z.ZodTypeAny, {
20
+ sectionSeparator: "tag" | "markdown";
21
+ sectionIndentation: boolean;
22
+ sectionTitleProperty: "title" | "name";
23
+ sectionDepth: number;
24
+ sectionTitlePrefix?: string | undefined;
25
+ sectionTitleSeparator?: string | undefined;
26
+ }, {
27
+ sectionSeparator: "tag" | "markdown";
28
+ sectionIndentation: boolean;
29
+ sectionTitleProperty: "title" | "name";
30
+ sectionTitlePrefix?: string | undefined;
31
+ sectionTitleSeparator?: string | undefined;
32
+ sectionDepth?: number | undefined;
33
+ }>;
34
+ export type FormatOptions = z.infer<typeof FormatOptionsSchema>;
35
+ export declare const OptionSchema: z.ZodObject<{
36
+ logger: z.ZodDefault<z.ZodOptional<z.ZodAny>>;
37
+ formatOptions: z.ZodDefault<z.ZodOptional<z.ZodObject<{
38
+ sectionSeparator: z.ZodOptional<z.ZodEnum<["tag", "markdown"]>>;
39
+ sectionIndentation: z.ZodOptional<z.ZodBoolean>;
40
+ sectionTitleProperty: z.ZodOptional<z.ZodEnum<["title", "name"]>>;
41
+ sectionTitlePrefix: z.ZodOptional<z.ZodOptional<z.ZodString>>;
42
+ sectionTitleSeparator: z.ZodOptional<z.ZodOptional<z.ZodString>>;
43
+ sectionDepth: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
44
+ }, "strip", z.ZodTypeAny, {
45
+ sectionSeparator?: "tag" | "markdown" | undefined;
46
+ sectionIndentation?: boolean | undefined;
47
+ sectionTitleProperty?: "title" | "name" | undefined;
48
+ sectionTitlePrefix?: string | undefined;
49
+ sectionTitleSeparator?: string | undefined;
50
+ sectionDepth?: number | undefined;
51
+ }, {
52
+ sectionSeparator?: "tag" | "markdown" | undefined;
53
+ sectionIndentation?: boolean | undefined;
54
+ sectionTitleProperty?: "title" | "name" | undefined;
55
+ sectionTitlePrefix?: string | undefined;
56
+ sectionTitleSeparator?: string | undefined;
57
+ sectionDepth?: number | undefined;
58
+ }>>>;
59
+ }, "strip", z.ZodTypeAny, {
60
+ formatOptions: {
61
+ sectionSeparator?: "tag" | "markdown" | undefined;
62
+ sectionIndentation?: boolean | undefined;
63
+ sectionTitleProperty?: "title" | "name" | undefined;
64
+ sectionTitlePrefix?: string | undefined;
65
+ sectionTitleSeparator?: string | undefined;
66
+ sectionDepth?: number | undefined;
67
+ };
68
+ logger?: any;
69
+ }, {
70
+ logger?: any;
71
+ formatOptions?: {
72
+ sectionSeparator?: "tag" | "markdown" | undefined;
73
+ sectionIndentation?: boolean | undefined;
74
+ sectionTitleProperty?: "title" | "name" | undefined;
75
+ sectionTitlePrefix?: string | undefined;
76
+ sectionTitleSeparator?: string | undefined;
77
+ sectionDepth?: number | undefined;
78
+ } | undefined;
79
+ }>;
80
+ export type Options = z.infer<typeof OptionSchema>;
81
+ export type OptionsParam = Partial<Options>;
82
+ export interface Instance {
83
+ formatPersona: (model: Model, persona: Section<Instruction>) => Message;
84
+ format: <T extends Weighted>(weightedText: T | Section<T>, sectionDepth?: number) => string;
85
+ formatArray: <T extends Weighted>(items: (T | Section<T>)[], sectionDepth?: number) => string;
86
+ formatPrompt: (model: Model, prompt: Prompt) => Chat.Request;
87
+ }
88
+ export declare const create: (formatterOptions?: OptionsParam) => Instance;
@@ -0,0 +1,131 @@
1
+ import { z } from 'zod';
2
+ import { createRequest, getPersonaRole } from './chat.js';
3
+ import { DEFAULT_FORMAT_OPTIONS } from './constants.js';
4
+ import { DEFAULT_LOGGER, wrapLogger } from './logger.js';
5
+ import { clean, stringifyJSON } from './util/general.js';
6
+
7
+ const SectionSeparatorSchema = z.enum([
8
+ "tag",
9
+ "markdown"
10
+ ]);
11
+ const SectionTitlePropertySchema = z.enum([
12
+ "title",
13
+ "name"
14
+ ]);
15
+ const FormatOptionsSchema = z.object({
16
+ sectionSeparator: SectionSeparatorSchema,
17
+ sectionIndentation: z.boolean(),
18
+ sectionTitleProperty: SectionTitlePropertySchema,
19
+ sectionTitlePrefix: z.string().optional(),
20
+ sectionTitleSeparator: z.string().optional(),
21
+ sectionDepth: z.number().default(1)
22
+ });
23
+ const OptionSchema = z.object({
24
+ logger: z.any().optional().default(DEFAULT_LOGGER),
25
+ formatOptions: FormatOptionsSchema.partial().optional().default(DEFAULT_FORMAT_OPTIONS)
26
+ });
27
+ // Type guard to check if an object is a Section
28
+ function isSection(obj) {
29
+ return obj && typeof obj === 'object' && 'items' in obj && Array.isArray(obj.items);
30
+ }
31
+ // Type guard to check if an object is a Section
32
+ function isWeighted(obj) {
33
+ return obj && typeof obj === 'object' && 'text' in obj;
34
+ }
35
+ const create = (formatterOptions)=>{
36
+ const options = OptionSchema.parse(formatterOptions || {});
37
+ const logger = wrapLogger(options.logger, 'Formatter');
38
+ let formatOptions = DEFAULT_FORMAT_OPTIONS;
39
+ if (options === null || options === void 0 ? void 0 : options.formatOptions) {
40
+ formatOptions = {
41
+ ...formatOptions,
42
+ ...clean(options.formatOptions)
43
+ };
44
+ }
45
+ const formatPersona = (model, persona)=>{
46
+ logger.silly(`Formatting persona`);
47
+ if (persona) {
48
+ const formattedPersona = formatSection(persona);
49
+ return {
50
+ role: getPersonaRole(model),
51
+ content: `${formattedPersona}`
52
+ };
53
+ } else {
54
+ throw new Error("Persona is required");
55
+ }
56
+ };
57
+ const format = (item, sectionDepth)=>{
58
+ logger.silly(`Formatting ${isSection(item) ? "section" : "item"} Item: %s`, stringifyJSON(item));
59
+ const currentSectionDepth = sectionDepth !== null && sectionDepth !== void 0 ? sectionDepth : formatOptions.sectionDepth;
60
+ logger.silly(`\t\tCurrent section depth: ${currentSectionDepth}`);
61
+ let result = "";
62
+ if (isSection(item)) {
63
+ result = formatSection(item, currentSectionDepth + 1);
64
+ } else if (isWeighted(item)) {
65
+ result = item.text;
66
+ } else {
67
+ //If the item is neither a section nor a weighted item, it is empty.
68
+ result = '';
69
+ }
70
+ return result;
71
+ };
72
+ const formatSection = (section, sectionDepth)=>{
73
+ logger.silly(`Formatting section`);
74
+ const currentSectionDepth = sectionDepth !== null && sectionDepth !== void 0 ? sectionDepth : formatOptions.sectionDepth;
75
+ logger.silly(`\t\tCurrent section depth: ${currentSectionDepth}`);
76
+ if (section) {
77
+ const formattedItems = section.items.map((item)=>format(item, currentSectionDepth)).join("\n\n");
78
+ if (formatOptions.sectionSeparator === "tag") {
79
+ var _section_title, _section_title1;
80
+ return `<${(_section_title = section.title) !== null && _section_title !== void 0 ? _section_title : "section"}>\n${formattedItems}\n</${(_section_title1 = section.title) !== null && _section_title1 !== void 0 ? _section_title1 : "section"}>`;
81
+ } else {
82
+ // Default depth to 1 if not provided, resulting in H2 (##) matching the test case.
83
+ const headingLevel = currentSectionDepth;
84
+ const hashes = '#'.repeat(headingLevel);
85
+ logger.silly(`\t\tHeading level: ${headingLevel}`);
86
+ logger.silly(`\t\tSection title: ${section.title}`);
87
+ return `${hashes} ${formatOptions.sectionTitlePrefix ? `${formatOptions.sectionTitlePrefix} ${formatOptions.sectionTitleSeparator} ` : ""}${section.title}\n\n${formattedItems}`;
88
+ }
89
+ } else {
90
+ return '';
91
+ }
92
+ };
93
+ // Helper function to format arrays of items or sections
94
+ const formatArray = (items, sectionDepth)=>{
95
+ logger.silly(`Formatting array`);
96
+ const currentSectionDepth = sectionDepth !== null && sectionDepth !== void 0 ? sectionDepth : formatOptions.sectionDepth;
97
+ return items.map((item)=>format(item, currentSectionDepth)).join("\n\n");
98
+ };
99
+ const formatPrompt = (model, prompt)=>{
100
+ logger.silly('Formatting prompt');
101
+ const chatRequest = createRequest(model);
102
+ if (prompt.persona) {
103
+ [
104
+ prompt.persona
105
+ ].forEach((persona)=>{
106
+ chatRequest.addMessage(formatPersona(model, persona));
107
+ });
108
+ }
109
+ let formattedAreas = formatSection(prompt.instructions) + '\n\n';
110
+ if (prompt.contents) {
111
+ formattedAreas += formatSection(prompt.contents) + '\n\n';
112
+ }
113
+ if (prompt.contexts) {
114
+ formattedAreas += formatSection(prompt.contexts) + '\n\n';
115
+ }
116
+ chatRequest.addMessage({
117
+ role: "user",
118
+ content: formattedAreas
119
+ });
120
+ return chatRequest;
121
+ };
122
+ return {
123
+ formatPersona,
124
+ format,
125
+ formatPrompt,
126
+ formatArray
127
+ };
128
+ };
129
+
130
+ export { FormatOptionsSchema, OptionSchema, SectionSeparatorSchema, SectionTitlePropertySchema, create };
131
+ //# sourceMappingURL=formatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatter.js","sources":["../src/formatter.ts"],"sourcesContent":["import { Instruction } from \"riotprompt\";\nimport { z } from \"zod\";\nimport * as Chat from \"./chat\";\nimport { getPersonaRole, Message, Model } from \"./chat\";\nimport { DEFAULT_FORMAT_OPTIONS } from \"./constants\";\nimport { Section } from \"./items/section\";\nimport { Weighted } from \"./items/weighted\";\nimport { DEFAULT_LOGGER, wrapLogger } from \"./logger\";\nimport { Prompt } from \"./prompt\";\nimport { clean, stringifyJSON } from \"./util/general\";\n\nexport const SectionSeparatorSchema = z.enum([\"tag\", \"markdown\"]);\nexport const SectionTitlePropertySchema = z.enum([\"title\", \"name\"]);\n\nexport type SectionSeparator = z.infer<typeof SectionSeparatorSchema>;\nexport type SectionTitleProperty = z.infer<typeof SectionTitlePropertySchema>;\n\n\nexport const FormatOptionsSchema = z.object({\n sectionSeparator: SectionSeparatorSchema,\n sectionIndentation: z.boolean(),\n sectionTitleProperty: SectionTitlePropertySchema,\n sectionTitlePrefix: z.string().optional(),\n sectionTitleSeparator: z.string().optional(),\n sectionDepth: z.number().default(1),\n});\n\nexport type FormatOptions = z.infer<typeof FormatOptionsSchema>;\n\n\nexport const OptionSchema = z.object({\n logger: z.any().optional().default(DEFAULT_LOGGER),\n formatOptions: FormatOptionsSchema.partial().optional().default(DEFAULT_FORMAT_OPTIONS),\n});\n\nexport type Options = z.infer<typeof OptionSchema>;\n\nexport type OptionsParam = Partial<Options>;\n\nexport interface Instance {\n formatPersona: (model: Model, persona: Section<Instruction>) => Message;\n format: <T extends Weighted>(weightedText: T | Section<T>, sectionDepth?: number) => string;\n formatArray: <T extends Weighted>(items: (T | Section<T>)[], sectionDepth?: number) => string;\n formatPrompt: (model: Model, prompt: Prompt) => Chat.Request;\n}\n\n// Type guard to check if an object is a Section\nfunction isSection<T extends Weighted>(obj: T | Section<T>): obj is Section<T> {\n return obj && typeof obj === 'object' && 'items' in obj && Array.isArray((obj as Section<T>).items);\n}\n\n// Type guard to check if an object is a Section\nfunction isWeighted<T extends Weighted>(obj: T | Section<T>): obj is T {\n return obj && typeof obj === 'object' && 'text' in obj;\n}\n\n\nexport const create = (formatterOptions?: OptionsParam): Instance => {\n const options: Required<Options> = OptionSchema.parse(formatterOptions || {}) as Required<Options>;\n\n const logger = wrapLogger(options.logger, 'Formatter');\n\n let formatOptions: FormatOptions = DEFAULT_FORMAT_OPTIONS;\n if (options?.formatOptions) {\n formatOptions = {\n ...formatOptions,\n ...clean(options.formatOptions),\n };\n }\n\n const formatPersona = (model: Model, persona: Section<Instruction>): Message => {\n logger.silly(`Formatting persona`);\n if (persona) {\n const formattedPersona = formatSection(persona);\n\n return {\n role: getPersonaRole(model),\n content: `${formattedPersona}`,\n }\n } else {\n throw new Error(\"Persona is required\");\n }\n }\n\n const format = <T extends Weighted>(\n item: T | Section<T>,\n sectionDepth?: number,\n ): string => {\n logger.silly(`Formatting ${isSection(item) ? \"section\" : \"item\"} Item: %s`, stringifyJSON(item));\n const currentSectionDepth = sectionDepth ?? formatOptions.sectionDepth;\n logger.silly(`\\t\\tCurrent section depth: ${currentSectionDepth}`);\n\n let result: string = \"\";\n if (isSection(item)) {\n result = formatSection(item, currentSectionDepth + 1);\n } else if (isWeighted(item)) {\n result = item.text;\n } else {\n //If the item is neither a section nor a weighted item, it is empty.\n result = '';\n }\n return result;\n }\n\n const formatSection = <T extends Weighted>(section: Section<T>, sectionDepth?: number): string => {\n logger.silly(`Formatting section`);\n const currentSectionDepth = sectionDepth ?? formatOptions.sectionDepth;\n logger.silly(`\\t\\tCurrent section depth: ${currentSectionDepth}`);\n\n if (section) {\n const formattedItems = section.items.map(item => format(item, currentSectionDepth)).join(\"\\n\\n\");\n\n if (formatOptions.sectionSeparator === \"tag\") {\n return `<${section.title ?? \"section\"}>\\n${formattedItems}\\n</${section.title ?? \"section\"}>`;\n } else {\n // Default depth to 1 if not provided, resulting in H2 (##) matching the test case.\n const headingLevel = currentSectionDepth;\n const hashes = '#'.repeat(headingLevel);\n logger.silly(`\\t\\tHeading level: ${headingLevel}`);\n logger.silly(`\\t\\tSection title: ${section.title}`);\n return `${hashes} ${formatOptions.sectionTitlePrefix ? `${formatOptions.sectionTitlePrefix} ${formatOptions.sectionTitleSeparator} ` : \"\"}${section.title}\\n\\n${formattedItems}`;\n }\n } else {\n return '';\n }\n }\n\n // Helper function to format arrays of items or sections\n const formatArray = <T extends Weighted>(\n items: (T | Section<T>)[],\n sectionDepth?: number\n ): string => {\n logger.silly(`Formatting array`);\n const currentSectionDepth = sectionDepth ?? formatOptions.sectionDepth;\n return items.map(item => format(item, currentSectionDepth)).join(\"\\n\\n\");\n }\n\n const formatPrompt = (model: Model, prompt: Prompt): Chat.Request => {\n logger.silly('Formatting prompt');\n const chatRequest: Chat.Request = Chat.createRequest(model);\n\n if (prompt.persona) {\n [prompt.persona].forEach((persona: Section<Instruction>) => {\n chatRequest.addMessage(formatPersona(model, persona));\n });\n }\n\n let formattedAreas: string = formatSection(prompt.instructions) + '\\n\\n';\n\n if (prompt.contents) {\n formattedAreas += formatSection(prompt.contents) + '\\n\\n';\n }\n\n if (prompt.contexts) {\n formattedAreas += formatSection(prompt.contexts) + '\\n\\n';\n }\n\n chatRequest.addMessage({\n role: \"user\",\n content: formattedAreas,\n });\n\n return chatRequest;\n }\n\n return {\n formatPersona,\n format,\n formatPrompt,\n formatArray,\n }\n}\n"],"names":["SectionSeparatorSchema","z","enum","SectionTitlePropertySchema","FormatOptionsSchema","object","sectionSeparator","sectionIndentation","boolean","sectionTitleProperty","sectionTitlePrefix","string","optional","sectionTitleSeparator","sectionDepth","number","default","OptionSchema","logger","any","DEFAULT_LOGGER","formatOptions","partial","DEFAULT_FORMAT_OPTIONS","isSection","obj","Array","isArray","items","isWeighted","create","formatterOptions","options","parse","wrapLogger","clean","formatPersona","model","persona","silly","formattedPersona","formatSection","role","getPersonaRole","content","Error","format","item","stringifyJSON","currentSectionDepth","result","text","section","formattedItems","map","join","title","headingLevel","hashes","repeat","formatArray","formatPrompt","prompt","chatRequest","Chat","forEach","addMessage","formattedAreas","instructions","contents","contexts"],"mappings":";;;;;;AAWaA,MAAAA,sBAAAA,GAAyBC,CAAEC,CAAAA,IAAI,CAAC;AAAC,IAAA,KAAA;AAAO,IAAA;CAAW;AACnDC,MAAAA,0BAAAA,GAA6BF,CAAEC,CAAAA,IAAI,CAAC;AAAC,IAAA,OAAA;AAAS,IAAA;CAAO;AAMrDE,MAAAA,mBAAAA,GAAsBH,CAAEI,CAAAA,MAAM,CAAC;IACxCC,gBAAkBN,EAAAA,sBAAAA;AAClBO,IAAAA,kBAAAA,EAAoBN,EAAEO,OAAO,EAAA;IAC7BC,oBAAsBN,EAAAA,0BAAAA;IACtBO,kBAAoBT,EAAAA,CAAAA,CAAEU,MAAM,EAAA,CAAGC,QAAQ,EAAA;IACvCC,qBAAuBZ,EAAAA,CAAAA,CAAEU,MAAM,EAAA,CAAGC,QAAQ,EAAA;AAC1CE,IAAAA,YAAAA,EAAcb,CAAEc,CAAAA,MAAM,EAAGC,CAAAA,OAAO,CAAC,CAAA;AACrC,CAAG;AAKUC,MAAAA,YAAAA,GAAehB,CAAEI,CAAAA,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jBH,cAAkB1B,IAAAA,aAAAA,CAAcqB,MAAOQ,CAAAA,QAAQ,CAAI,GAAA,MAAA;AACvD;AAEAP,QAAAA,WAAAA,CAAYG,UAAU,CAAC;YACnBxB,IAAM,EAAA,MAAA;YACNE,OAASuB,EAAAA;AACb,SAAA,CAAA;QAEA,OAAOJ,WAAAA;AACX,KAAA;IAEA,OAAO;AACH3B,QAAAA,aAAAA;AACAU,QAAAA,MAAAA;AACAe,QAAAA,YAAAA;AACAD,QAAAA;AACJ,KAAA;AACJ;;;;"}
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const weighted = require('./weighted.cjs');
6
+
7
+ // Export create function
8
+ const create = (text, options = {})=>{
9
+ const weightedOptions = weighted.WeightedOptionsSchema.parse(options);
10
+ return weighted.create(text, weightedOptions);
11
+ };
12
+
13
+ exports.create = create;
14
+ //# sourceMappingURL=content.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.cjs","sources":["../../src/items/content.ts"],"sourcesContent":["import { Weighted, WeightedOptions, WeightedOptionsSchema, create as createWeighted } from \"./weighted\";\n\n// Define Content as a type alias for Weighted\nexport type Content = Weighted;\n\n// Export create function\nexport const create = (text: string, options: Partial<WeightedOptions> = {}): Content => {\n const weightedOptions = WeightedOptionsSchema.parse(options);\n return createWeighted<Content>(text, weightedOptions);\n}\n\n"],"names":["create","text","options","weightedOptions","WeightedOptionsSchema","parse","createWeighted"],"mappings":";;;;;;AAKA;MACaA,MAAS,GAAA,CAACC,IAAcC,EAAAA,OAAAA,GAAoC,EAAE,GAAA;IACvE,MAAMC,eAAAA,GAAkBC,8BAAsBC,CAAAA,KAAK,CAACH,OAAAA,CAAAA;AACpD,IAAA,OAAOI,gBAAwBL,IAAME,EAAAA,eAAAA,CAAAA;AACzC;;;;"}
@@ -0,0 +1,3 @@
1
+ import { Weighted, WeightedOptions } from './weighted';
2
+ export type Content = Weighted;
3
+ export declare const create: (text: string, options?: Partial<WeightedOptions>) => Content;
@@ -0,0 +1,10 @@
1
+ import { WeightedOptionsSchema, create as create$1 } from './weighted.js';
2
+
3
+ // Export create function
4
+ const create = (text, options = {})=>{
5
+ const weightedOptions = WeightedOptionsSchema.parse(options);
6
+ return create$1(text, weightedOptions);
7
+ };
8
+
9
+ export { create };
10
+ //# sourceMappingURL=content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.js","sources":["../../src/items/content.ts"],"sourcesContent":["import { Weighted, WeightedOptions, WeightedOptionsSchema, create as createWeighted } from \"./weighted\";\n\n// Define Content as a type alias for Weighted\nexport type Content = Weighted;\n\n// Export create function\nexport const create = (text: string, options: Partial<WeightedOptions> = {}): Content => {\n const weightedOptions = WeightedOptionsSchema.parse(options);\n return createWeighted<Content>(text, weightedOptions);\n}\n\n"],"names":["create","text","options","weightedOptions","WeightedOptionsSchema","parse","createWeighted"],"mappings":";;AAKA;MACaA,MAAS,GAAA,CAACC,IAAcC,EAAAA,OAAAA,GAAoC,EAAE,GAAA;IACvE,MAAMC,eAAAA,GAAkBC,qBAAsBC,CAAAA,KAAK,CAACH,OAAAA,CAAAA;AACpD,IAAA,OAAOI,SAAwBL,IAAME,EAAAA,eAAAA,CAAAA;AACzC;;;;"}
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const weighted = require('./weighted.cjs');
6
+
7
+ const create = (text, options = {})=>{
8
+ const weightedOptions = weighted.WeightedOptionsSchema.parse(options);
9
+ return weighted.create(text, weightedOptions);
10
+ };
11
+
12
+ exports.create = create;
13
+ //# sourceMappingURL=context.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.cjs","sources":["../../src/items/context.ts"],"sourcesContent":["import { Weighted, WeightedOptions, WeightedOptionsSchema, create as createWeighted } from \"./weighted\";\n\nexport type Context = Weighted;\n\nexport const create = (text: string, options: Partial<WeightedOptions> = {}): Context => {\n const weightedOptions = WeightedOptionsSchema.parse(options);\n return createWeighted<Context>(text, weightedOptions);\n}\n\n"],"names":["create","text","options","weightedOptions","WeightedOptionsSchema","parse","createWeighted"],"mappings":";;;;;;MAIaA,MAAS,GAAA,CAACC,IAAcC,EAAAA,OAAAA,GAAoC,EAAE,GAAA;IACvE,MAAMC,eAAAA,GAAkBC,8BAAsBC,CAAAA,KAAK,CAACH,OAAAA,CAAAA;AACpD,IAAA,OAAOI,gBAAwBL,IAAME,EAAAA,eAAAA,CAAAA;AACzC;;;;"}
@@ -0,0 +1,3 @@
1
+ import { Weighted, WeightedOptions } from './weighted';
2
+ export type Context = Weighted;
3
+ export declare const create: (text: string, options?: Partial<WeightedOptions>) => Context;
@@ -0,0 +1,9 @@
1
+ import { WeightedOptionsSchema, create as create$1 } from './weighted.js';
2
+
3
+ const create = (text, options = {})=>{
4
+ const weightedOptions = WeightedOptionsSchema.parse(options);
5
+ return create$1(text, weightedOptions);
6
+ };
7
+
8
+ export { create };
9
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sources":["../../src/items/context.ts"],"sourcesContent":["import { Weighted, WeightedOptions, WeightedOptionsSchema, create as createWeighted } from \"./weighted\";\n\nexport type Context = Weighted;\n\nexport const create = (text: string, options: Partial<WeightedOptions> = {}): Context => {\n const weightedOptions = WeightedOptionsSchema.parse(options);\n return createWeighted<Context>(text, weightedOptions);\n}\n\n"],"names":["create","text","options","weightedOptions","WeightedOptionsSchema","parse","createWeighted"],"mappings":";;MAIaA,MAAS,GAAA,CAACC,IAAcC,EAAAA,OAAAA,GAAoC,EAAE,GAAA;IACvE,MAAMC,eAAAA,GAAkBC,qBAAsBC,CAAAA,KAAK,CAACH,OAAAA,CAAAA;AACpD,IAAA,OAAOI,SAAwBL,IAAME,EAAAA,eAAAA,CAAAA;AACzC;;;;"}
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const weighted = require('./weighted.cjs');
6
+
7
+ const create = (text, options = {})=>{
8
+ const weightedOptions = weighted.WeightedOptionsSchema.parse(options);
9
+ return weighted.create(text, weightedOptions);
10
+ };
11
+
12
+ exports.create = create;
13
+ //# sourceMappingURL=instruction.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instruction.cjs","sources":["../../src/items/instruction.ts"],"sourcesContent":["import { Weighted, WeightedOptions, WeightedOptionsSchema, create as createWeighted } from \"./weighted\";\n\nexport type Instruction = Weighted;\n\nexport const create = (text: string, options: Partial<WeightedOptions> = {}): Instruction => {\n const weightedOptions = WeightedOptionsSchema.parse(options);\n return createWeighted<Instruction>(text, weightedOptions);\n}"],"names":["create","text","options","weightedOptions","WeightedOptionsSchema","parse","createWeighted"],"mappings":";;;;;;MAIaA,MAAS,GAAA,CAACC,IAAcC,EAAAA,OAAAA,GAAoC,EAAE,GAAA;IACvE,MAAMC,eAAAA,GAAkBC,8BAAsBC,CAAAA,KAAK,CAACH,OAAAA,CAAAA;AACpD,IAAA,OAAOI,gBAA4BL,IAAME,EAAAA,eAAAA,CAAAA;AAC7C;;;;"}
@@ -0,0 +1,3 @@
1
+ import { Weighted, WeightedOptions } from './weighted';
2
+ export type Instruction = Weighted;
3
+ export declare const create: (text: string, options?: Partial<WeightedOptions>) => Instruction;
@@ -0,0 +1,9 @@
1
+ import { WeightedOptionsSchema, create as create$1 } from './weighted.js';
2
+
3
+ const create = (text, options = {})=>{
4
+ const weightedOptions = WeightedOptionsSchema.parse(options);
5
+ return create$1(text, weightedOptions);
6
+ };
7
+
8
+ export { create };
9
+ //# sourceMappingURL=instruction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instruction.js","sources":["../../src/items/instruction.ts"],"sourcesContent":["import { Weighted, WeightedOptions, WeightedOptionsSchema, create as createWeighted } from \"./weighted\";\n\nexport type Instruction = Weighted;\n\nexport const create = (text: string, options: Partial<WeightedOptions> = {}): Instruction => {\n const weightedOptions = WeightedOptionsSchema.parse(options);\n return createWeighted<Instruction>(text, weightedOptions);\n}"],"names":["create","text","options","weightedOptions","WeightedOptionsSchema","parse","createWeighted"],"mappings":";;MAIaA,MAAS,GAAA,CAACC,IAAcC,EAAAA,OAAAA,GAAoC,EAAE,GAAA;IACvE,MAAMC,eAAAA,GAAkBC,qBAAsBC,CAAAA,KAAK,CAACH,OAAAA,CAAAA;AACpD,IAAA,OAAOI,SAA4BL,IAAME,EAAAA,eAAAA,CAAAA;AAC7C;;;;"}
@@ -0,0 +1,53 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const zod = require('zod');
6
+
7
+ const ParametersSchema = zod.z.record(zod.z.string(), zod.z.union([
8
+ zod.z.string(),
9
+ zod.z.number(),
10
+ zod.z.boolean(),
11
+ zod.z.array(zod.z.union([
12
+ zod.z.string(),
13
+ zod.z.number(),
14
+ zod.z.boolean()
15
+ ]))
16
+ ]));
17
+ const create = (parameters)=>{
18
+ return parameters;
19
+ };
20
+ const apply = (text, parameters)=>{
21
+ if (!parameters) {
22
+ return text;
23
+ }
24
+ // First, trim parameters keys to handle whitespace in placeholder names
25
+ const trimmedParams = {};
26
+ Object.keys(parameters).forEach((key)=>{
27
+ trimmedParams[key.trim()] = parameters[key];
28
+ });
29
+ // Process all placeholders, preserving ones that don't have matching parameters
30
+ return text.replace(/\{\{([^{}]+)\}\}/g, (match, p1)=>{
31
+ const paramKey = p1.trim();
32
+ const parameter = trimmedParams[paramKey];
33
+ if (parameter === undefined) {
34
+ // Preserve the original placeholder if parameter doesn't exist
35
+ return match;
36
+ } else if (typeof parameter === 'string') {
37
+ return parameter;
38
+ } else if (typeof parameter === 'number') {
39
+ return parameter.toString();
40
+ } else if (typeof parameter === 'boolean') {
41
+ return parameter.toString();
42
+ } else if (Array.isArray(parameter)) {
43
+ return parameter.join(', ');
44
+ } else {
45
+ return match;
46
+ }
47
+ });
48
+ };
49
+
50
+ exports.ParametersSchema = ParametersSchema;
51
+ exports.apply = apply;
52
+ exports.create = create;
53
+ //# sourceMappingURL=parameters.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parameters.cjs","sources":["../../src/items/parameters.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const ParametersSchema = z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.array(z.union([z.string(), z.number(), z.boolean()]))]));\n\nexport type Parameters = z.infer<typeof ParametersSchema>;\n\nexport const create = (parameters: Parameters): Parameters => {\n return parameters;\n}\n\nexport const apply = (text: string, parameters?: Parameters): string => {\n if (!parameters) {\n return text;\n }\n\n // First, trim parameters keys to handle whitespace in placeholder names\n const trimmedParams: Record<string, any> = {};\n Object.keys(parameters).forEach(key => {\n trimmedParams[key.trim()] = parameters[key];\n });\n\n // Process all placeholders, preserving ones that don't have matching parameters\n return text.replace(/\\{\\{([^{}]+)\\}\\}/g, (match, p1) => {\n const paramKey = p1.trim();\n const parameter = trimmedParams[paramKey];\n\n if (parameter === undefined) {\n // Preserve the original placeholder if parameter doesn't exist\n return match;\n } else if (typeof parameter === 'string') {\n return parameter;\n } else if (typeof parameter === 'number') {\n return parameter.toString();\n } else if (typeof parameter === 'boolean') {\n return parameter.toString();\n } else if (Array.isArray(parameter)) {\n return parameter.join(', ');\n } else {\n return match;\n }\n });\n}"],"names":["ParametersSchema","z","record","string","union","number","boolean","array","create","parameters","apply","text","trimmedParams","Object","keys","forEach","key","trim","replace","match","p1","paramKey","parameter","undefined","toString","Array","isArray","join"],"mappings":";;;;;;AAEO,MAAMA,gBAAmBC,GAAAA,KAAAA,CAAEC,MAAM,CAACD,MAAEE,MAAM,EAAA,EAAIF,KAAEG,CAAAA,KAAK,CAAC;AAACH,IAAAA,KAAAA,CAAEE,MAAM,EAAA;AAAIF,IAAAA,KAAAA,CAAEI,MAAM,EAAA;AAAIJ,IAAAA,KAAAA,CAAEK,OAAO,EAAA;AAAIL,IAAAA,KAAAA,CAAEM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AC,IAAA,CAAA;SACnB,MAAA;YACH,OAAOR,KAAAA;AACX;AACJ,KAAA,CAAA;AACJ;;;;;;"}
@@ -0,0 +1,5 @@
1
+ import { z } from 'zod';
2
+ export declare const ParametersSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, "many">]>>;
3
+ export type Parameters = z.infer<typeof ParametersSchema>;
4
+ export declare const create: (parameters: Parameters) => Parameters;
5
+ export declare const apply: (text: string, parameters?: Parameters) => string;
@@ -0,0 +1,47 @@
1
+ import { z } from 'zod';
2
+
3
+ const ParametersSchema = z.record(z.string(), z.union([
4
+ z.string(),
5
+ z.number(),
6
+ z.boolean(),
7
+ z.array(z.union([
8
+ z.string(),
9
+ z.number(),
10
+ z.boolean()
11
+ ]))
12
+ ]));
13
+ const create = (parameters)=>{
14
+ return parameters;
15
+ };
16
+ const apply = (text, parameters)=>{
17
+ if (!parameters) {
18
+ return text;
19
+ }
20
+ // First, trim parameters keys to handle whitespace in placeholder names
21
+ const trimmedParams = {};
22
+ Object.keys(parameters).forEach((key)=>{
23
+ trimmedParams[key.trim()] = parameters[key];
24
+ });
25
+ // Process all placeholders, preserving ones that don't have matching parameters
26
+ return text.replace(/\{\{([^{}]+)\}\}/g, (match, p1)=>{
27
+ const paramKey = p1.trim();
28
+ const parameter = trimmedParams[paramKey];
29
+ if (parameter === undefined) {
30
+ // Preserve the original placeholder if parameter doesn't exist
31
+ return match;
32
+ } else if (typeof parameter === 'string') {
33
+ return parameter;
34
+ } else if (typeof parameter === 'number') {
35
+ return parameter.toString();
36
+ } else if (typeof parameter === 'boolean') {
37
+ return parameter.toString();
38
+ } else if (Array.isArray(parameter)) {
39
+ return parameter.join(', ');
40
+ } else {
41
+ return match;
42
+ }
43
+ });
44
+ };
45
+
46
+ export { ParametersSchema, apply, create };
47
+ //# sourceMappingURL=parameters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parameters.js","sources":["../../src/items/parameters.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const ParametersSchema = z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.array(z.union([z.string(), z.number(), z.boolean()]))]));\n\nexport type Parameters = z.infer<typeof ParametersSchema>;\n\nexport const create = (parameters: Parameters): Parameters => {\n return parameters;\n}\n\nexport const apply = (text: string, parameters?: Parameters): string => {\n if (!parameters) {\n return text;\n }\n\n // First, trim parameters keys to handle whitespace in placeholder names\n const trimmedParams: Record<string, any> = {};\n Object.keys(parameters).forEach(key => {\n trimmedParams[key.trim()] = parameters[key];\n });\n\n // Process all placeholders, preserving ones that don't have matching parameters\n return text.replace(/\\{\\{([^{}]+)\\}\\}/g, (match, p1) => {\n const paramKey = p1.trim();\n const parameter = trimmedParams[paramKey];\n\n if (parameter === undefined) {\n // Preserve the original placeholder if parameter doesn't exist\n return match;\n } else if (typeof parameter === 'string') {\n return parameter;\n } else if (typeof parameter === 'number') {\n return parameter.toString();\n } else if (typeof parameter === 'boolean') {\n return parameter.toString();\n } else if (Array.isArray(parameter)) {\n return parameter.join(', ');\n } else {\n return match;\n }\n });\n}"],"names":["ParametersSchema","z","record","string","union","number","boolean","array","create","parameters","apply","text","trimmedParams","Object","keys","forEach","key","trim","replace","match","p1","paramKey","parameter","undefined","toString","Array","isArray","join"],"mappings":";;AAEO,MAAMA,gBAAmBC,GAAAA,CAAAA,CAAEC,MAAM,CAACD,EAAEE,MAAM,EAAA,EAAIF,CAAEG,CAAAA,KAAK,CAAC;AAACH,IAAAA,CAAAA,CAAEE,MAAM,EAAA;AAAIF,IAAAA,CAAAA,CAAEI,MAAM,EAAA;AAAIJ,IAAAA,CAAAA,CAAEK,OAAO,EAAA;AAAIL,IAAAA,CAAAA,CAAEM,KAAK,CAACN,CAAEG,CAAAA,KAAK,CAAC;AAACH,QAAAA,CAAAA,CAAEE,MAAM,EAAA;AAAIF,QAAAA,CAAAA,CAAEI,MA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strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const zod = require('zod');
6
+ const parameters = require('./parameters.cjs');
7
+ const weighted = require('./weighted.cjs');
8
+
9
+ const SectionOptionsSchema = zod.z.object({
10
+ title: zod.z.string().optional(),
11
+ weight: zod.z.number().optional(),
12
+ itemWeight: zod.z.number().optional(),
13
+ parameters: parameters.ParametersSchema.optional().default({})
14
+ });
15
+ const create = (options = {})=>{
16
+ const items = [];
17
+ const sectionOptions = SectionOptionsSchema.parse(options);
18
+ const sectionItemOptions = weighted.WeightedOptionsSchema.parse({
19
+ ...sectionOptions,
20
+ weight: sectionOptions.itemWeight
21
+ });
22
+ const append = (item, options = {})=>{
23
+ let itemOptions = weighted.WeightedOptionsSchema.parse(options);
24
+ itemOptions = {
25
+ ...sectionItemOptions,
26
+ ...itemOptions
27
+ };
28
+ if (Array.isArray(item)) {
29
+ item.forEach((item)=>{
30
+ append(item);
31
+ });
32
+ } else {
33
+ if (typeof item === 'string') {
34
+ items.push(weighted.create(item, itemOptions));
35
+ } else {
36
+ items.push(item);
37
+ }
38
+ }
39
+ return section;
40
+ };
41
+ const prepend = (item, options = {})=>{
42
+ let itemOptions = weighted.WeightedOptionsSchema.parse(options);
43
+ itemOptions = {
44
+ ...sectionItemOptions,
45
+ ...itemOptions
46
+ };
47
+ if (Array.isArray(item)) {
48
+ item.forEach((item)=>{
49
+ prepend(item);
50
+ });
51
+ } else {
52
+ if (typeof item === 'string') {
53
+ items.unshift(weighted.create(item, itemOptions));
54
+ } else {
55
+ items.unshift(item);
56
+ }
57
+ }
58
+ return section;
59
+ };
60
+ const insert = (index, item, options = {})=>{
61
+ let itemOptions = weighted.WeightedOptionsSchema.parse(options);
62
+ itemOptions = {
63
+ ...sectionItemOptions,
64
+ ...itemOptions
65
+ };
66
+ if (Array.isArray(item)) {
67
+ item.forEach((item)=>{
68
+ insert(index, item);
69
+ });
70
+ } else {
71
+ if (typeof item === 'string') {
72
+ items.splice(index, 0, weighted.create(item, itemOptions));
73
+ } else {
74
+ items.splice(index, 0, item);
75
+ }
76
+ }
77
+ return section;
78
+ };
79
+ const remove = (index)=>{
80
+ items.splice(index, 1);
81
+ return section;
82
+ };
83
+ const replace = (index, item, options = {})=>{
84
+ let itemOptions = weighted.WeightedOptionsSchema.parse(options);
85
+ itemOptions = {
86
+ ...sectionItemOptions,
87
+ ...itemOptions
88
+ };
89
+ if (typeof item === 'string') {
90
+ items[index] = weighted.create(item, itemOptions);
91
+ } else {
92
+ items[index] = item;
93
+ }
94
+ return section;
95
+ };
96
+ const add = (item, options = {})=>{
97
+ let itemOptions = weighted.WeightedOptionsSchema.parse(options);
98
+ itemOptions = {
99
+ ...sectionItemOptions,
100
+ ...itemOptions
101
+ };
102
+ return append(item, itemOptions);
103
+ };
104
+ const section = {
105
+ title: sectionOptions.title,
106
+ items,
107
+ weight: sectionOptions.weight,
108
+ add,
109
+ append,
110
+ prepend,
111
+ insert,
112
+ remove,
113
+ replace
114
+ };
115
+ return section;
116
+ };
117
+
118
+ exports.SectionOptionsSchema = SectionOptionsSchema;
119
+ exports.create = create;
120
+ //# sourceMappingURL=section.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"section.cjs","sources":["../../src/items/section.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { ParametersSchema } from \"./parameters\";\nimport { Weighted, WeightedOptions, WeightedOptionsSchema, create as createWeighted } from \"./weighted\";\n\nexport interface Section<T extends Weighted> {\n title?: string;\n items: (T | Section<T>)[];\n weight?: number;\n add: (\n item: T | T[] | Section<T> | Section<T>[] | string | string[],\n options?: Partial<WeightedOptions>\n ) => Section<T>;\n append: (\n item: T | T[] | Section<T> | Section<T>[] | string | string[],\n options?: Partial<WeightedOptions>\n ) => Section<T>;\n prepend: (\n item: T | T[] | Section<T> | Section<T>[] | string | string[],\n options?: Partial<WeightedOptions>\n ) => Section<T>;\n insert: (\n index: number,\n item: T | T[] | Section<T> | Section<T>[] | string | string[],\n options?: Partial<WeightedOptions>\n ) => Section<T>;\n replace: (\n index: number,\n item: T | Section<T> | string,\n options?: Partial<WeightedOptions>\n ) => Section<T>;\n remove: (index: number) => Section<T>;\n}\n\nexport const SectionOptionsSchema = z.object({\n title: z.string().optional(),\n weight: z.number().optional(),\n itemWeight: z.number().optional(),\n parameters: ParametersSchema.optional().default({}),\n});\n\nexport type SectionOptions = z.infer<typeof SectionOptionsSchema>;\n\nexport const isSection = (object: any): boolean => {\n return object !== undefined && object != null && typeof object === 'object' && 'items' in object;\n}\n\nexport const convertToSection = (\n object: any,\n options: Partial<SectionOptions> = {}\n): Section<Weighted> => {\n const sectionOptions = SectionOptionsSchema.parse(options);\n\n const weightedOptions = WeightedOptionsSchema.parse({\n ...sectionOptions,\n weight: sectionOptions.itemWeight,\n });\n\n if (isSection(object)) {\n const section = create({ ...sectionOptions, title: object.title });\n object.items.forEach((item: any) => {\n if (isSection(item)) {\n section.append(convertToSection(item, sectionOptions));\n } else {\n section.append(createWeighted(item.text, weightedOptions));\n }\n });\n return section;\n } else {\n throw new Error('Object is not a section');\n }\n}\n\nexport const create = <T extends Weighted>(\n options: Partial<SectionOptions> = {}\n): Section<T> => {\n const items: (T | Section<T>)[] = [];\n const sectionOptions = SectionOptionsSchema.parse(options);\n\n const sectionItemOptions = WeightedOptionsSchema.parse({\n ...sectionOptions,\n weight: sectionOptions.itemWeight,\n });\n\n const append = (item: T | T[] | Section<T> | Section<T>[] | string | string[], options: Partial<WeightedOptions> = {}): Section<T> => {\n let itemOptions: WeightedOptions = WeightedOptionsSchema.parse(options);\n itemOptions = { ...sectionItemOptions, ...itemOptions };\n\n if (Array.isArray(item)) {\n item.forEach((item) => {\n append(item);\n });\n } else {\n if (typeof item === 'string') {\n items.push(createWeighted<T>(item, itemOptions));\n } else {\n items.push(item);\n }\n }\n return section;\n }\n\n const prepend = (item: T | T[] | Section<T> | Section<T>[] | string | string[], options: Partial<WeightedOptions> = {}): Section<T> => {\n let itemOptions: WeightedOptions = WeightedOptionsSchema.parse(options);\n itemOptions = { ...sectionItemOptions, ...itemOptions };\n\n if (Array.isArray(item)) {\n item.forEach((item) => {\n prepend(item);\n });\n } else {\n if (typeof item === 'string') {\n items.unshift(createWeighted<T>(item, itemOptions));\n } else {\n items.unshift(item);\n }\n }\n return section;\n }\n\n const insert = (index: number, item: T | T[] | Section<T> | Section<T>[] | string | string[], options: Partial<WeightedOptions> = {}): Section<T> => {\n let itemOptions: WeightedOptions = WeightedOptionsSchema.parse(options);\n itemOptions = { ...sectionItemOptions, ...itemOptions };\n\n if (Array.isArray(item)) {\n item.forEach((item) => {\n insert(index, item);\n });\n } else {\n if (typeof item === 'string') {\n items.splice(index, 0, createWeighted<T>(item, itemOptions));\n } else {\n items.splice(index, 0, item);\n }\n }\n return section;\n }\n\n const remove = (index: number): Section<T> => {\n items.splice(index, 1);\n return section;\n }\n\n const replace = (index: number, item: T | Section<T> | string, options: Partial<WeightedOptions> = {}): Section<T> => {\n let itemOptions: WeightedOptions = WeightedOptionsSchema.parse(options);\n itemOptions = { ...sectionItemOptions, ...itemOptions };\n\n if (typeof item === 'string') {\n items[index] = createWeighted<T>(item, itemOptions);\n } else {\n items[index] = item;\n }\n return section;\n }\n\n const add = (item: T | T[] | Section<T> | Section<T>[] | string | string[], options: Partial<WeightedOptions> = {}): Section<T> => {\n let itemOptions: WeightedOptions = WeightedOptionsSchema.parse(options);\n itemOptions = { ...sectionItemOptions, ...itemOptions };\n\n return append(item, itemOptions);\n }\n\n const section: Section<T> = {\n title: sectionOptions.title,\n items,\n weight: sectionOptions.weight,\n add,\n append,\n prepend,\n insert,\n remove,\n replace,\n }\n\n return section;\n}\n\n\n"],"names":["SectionOptionsSchema","z","object","title","string","optional","weight","number","itemWeight","parameters","ParametersSchema","default","create","options","items","sectionOptions","parse","sectionItemOptions","WeightedOptionsSchema","append","item","itemOptions","Array","isArray","forEach","push","createWeighted","section","prepend","unshift","insert","index","splice","remove","replace","add"],"mappings":";;;;;;;;AAiCaA,MA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