@riotprompt/riotprompt 0.0.1 → 0.0.2
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/dist/logger.js +4 -2
- package/dist/logger.js.map +1 -1
- package/dist/riotprompt.cjs +104 -102
- package/dist/riotprompt.cjs.map +1 -1
- package/package.json +16 -14
- package/vite.config.ts +2 -2
- package/dist/builder.cjs +0 -152
- package/dist/builder.cjs.map +0 -1
- package/dist/chat.cjs +0 -26
- package/dist/chat.cjs.map +0 -1
- package/dist/constants.cjs +0 -34
- package/dist/constants.cjs.map +0 -1
- package/dist/formatter.cjs +0 -139
- package/dist/formatter.cjs.map +0 -1
- package/dist/items/content.cjs +0 -14
- package/dist/items/content.cjs.map +0 -1
- package/dist/items/context.cjs +0 -13
- package/dist/items/context.cjs.map +0 -1
- package/dist/items/instruction.cjs +0 -13
- package/dist/items/instruction.cjs.map +0 -1
- package/dist/items/parameters.cjs +0 -53
- package/dist/items/parameters.cjs.map +0 -1
- package/dist/items/section.cjs +0 -120
- package/dist/items/section.cjs.map +0 -1
- package/dist/items/trait.cjs +0 -13
- package/dist/items/trait.cjs.map +0 -1
- package/dist/items/weighted.cjs +0 -27
- package/dist/items/weighted.cjs.map +0 -1
- package/dist/loader.cjs +0 -167
- package/dist/loader.cjs.map +0 -1
- package/dist/logger.cjs +0 -51
- package/dist/logger.cjs.map +0 -1
- package/dist/override.cjs +0 -109
- package/dist/override.cjs.map +0 -1
- package/dist/parse/markdown.cjs +0 -114
- package/dist/parse/markdown.cjs.map +0 -1
- package/dist/parse/text.cjs +0 -33
- package/dist/parse/text.cjs.map +0 -1
- package/dist/parser.cjs +0 -99
- package/dist/parser.cjs.map +0 -1
- package/dist/prompt.cjs +0 -15
- package/dist/prompt.cjs.map +0 -1
- package/dist/util/general.cjs +0 -52
- package/dist/util/general.cjs.map +0 -1
- package/dist/util/markdown.cjs +0 -115
- package/dist/util/markdown.cjs.map +0 -1
- package/dist/util/storage.cjs +0 -155
- package/dist/util/storage.cjs.map +0 -1
- package/dist/util/text.cjs +0 -42
- package/dist/util/text.cjs.map +0 -1
package/dist/logger.js
CHANGED
|
@@ -6,8 +6,10 @@ const DEFAULT_LOGGER = {
|
|
|
6
6
|
info: (message, ...args)=>console.info(message, ...args),
|
|
7
7
|
warn: (message, ...args)=>console.warn(message, ...args),
|
|
8
8
|
error: (message, ...args)=>console.error(message, ...args),
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
10
|
+
verbose: (message, ...args)=>{},
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
12
|
+
silly: (message, ...args)=>{}
|
|
11
13
|
};
|
|
12
14
|
const wrapLogger = (toWrap, name)=>{
|
|
13
15
|
const requiredMethods = [
|
package/dist/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sources":["../src/logger.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport { LIBRARY_NAME } from \"./constants\";\n\nexport interface Logger {\n name: string;\n debug: (message: string, ...args: any[]) => void;\n info: (message: string, ...args: any[]) => void;\n warn: (message: string, ...args: any[]) => void;\n error: (message: string, ...args: any[]) => void;\n verbose: (message: string, ...args: any[]) => void;\n silly: (message: string, ...args: any[]) => void;\n}\n\nexport const DEFAULT_LOGGER: Logger = {\n name: 'default',\n debug: (message: string, ...args: any[]) => console.debug(message, ...args),\n info: (message: string, ...args: any[]) => console.info(message, ...args),\n warn: (message: string, ...args: any[]) => console.warn(message, ...args),\n error: (message: string, ...args: any[]) => console.error(message, ...args),\n verbose: (message: string, ...args: any[]) =>
|
|
1
|
+
{"version":3,"file":"logger.js","sources":["../src/logger.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport { LIBRARY_NAME } from \"./constants\";\n\nexport interface Logger {\n name: string;\n debug: (message: string, ...args: any[]) => void;\n info: (message: string, ...args: any[]) => void;\n warn: (message: string, ...args: any[]) => void;\n error: (message: string, ...args: any[]) => void;\n verbose: (message: string, ...args: any[]) => void;\n silly: (message: string, ...args: any[]) => void;\n}\n\nexport const DEFAULT_LOGGER: Logger = {\n name: 'default',\n debug: (message: string, ...args: any[]) => console.debug(message, ...args),\n info: (message: string, ...args: any[]) => console.info(message, ...args),\n warn: (message: string, ...args: any[]) => console.warn(message, ...args),\n error: (message: string, ...args: any[]) => console.error(message, ...args),\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n verbose: (message: string, ...args: any[]) => { },\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n silly: (message: string, ...args: any[]) => { },\n}\n\nexport const wrapLogger = (toWrap: Logger, name?: string): Logger => {\n\n const requiredMethods: (keyof Logger)[] = ['debug', 'info', 'warn', 'error', 'verbose', 'silly'];\n const missingMethods = requiredMethods.filter(method => typeof toWrap[method] !== 'function');\n\n if (missingMethods.length > 0) {\n throw new Error(`Logger is missing required methods: ${missingMethods.join(', ')}`);\n }\n\n const log = (level: keyof Logger, message: string, ...args: any[]) => {\n message = `[${LIBRARY_NAME}] ${name ? `[${name}]` : ''}: ${message}`;\n\n if (level === 'debug') toWrap.debug(message, ...args);\n else if (level === 'info') toWrap.info(message, ...args);\n else if (level === 'warn') toWrap.warn(message, ...args);\n else if (level === 'error') toWrap.error(message, ...args);\n else if (level === 'verbose') toWrap.verbose(message, ...args);\n else if (level === 'silly') toWrap.silly(message, ...args);\n }\n\n return {\n name: 'wrapped',\n debug: (message: string, ...args: any[]) => log('debug', message, ...args),\n info: (message: string, ...args: any[]) => log('info', message, ...args),\n warn: (message: string, ...args: any[]) => log('warn', message, ...args),\n error: (message: string, ...args: any[]) => log('error', message, ...args),\n verbose: (message: string, ...args: any[]) => log('verbose', message, ...args),\n silly: (message: string, ...args: any[]) => log('silly', message, ...args),\n }\n}"],"names":["DEFAULT_LOGGER","name","debug","message","args","console","info","warn","error","verbose","silly","wrapLogger","toWrap","requiredMethods","missingMethods","filter","method","length","Error","join","log","level","LI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A,GAAGC,IAAgBgB,GAAAA,GAAAA,CAAI,QAAQjB,OAAYC,EAAAA,GAAAA,IAAAA,CAAAA;AACnEI,QAAAA,KAAAA,EAAO,CAACL,OAAiB,EAAA,GAAGC,IAAgBgB,GAAAA,GAAAA,CAAI,SAASjB,OAAYC,EAAAA,GAAAA,IAAAA,CAAAA;AACrEK,QAAAA,OAAAA,EAAS,CAACN,OAAiB,EAAA,GAAGC,IAAgBgB,GAAAA,GAAAA,CAAI,WAAWjB,OAAYC,EAAAA,GAAAA,IAAAA,CAAAA;AACzEM,QAAAA,KAAAA,EAAO,CAACP,OAAiB,EAAA,GAAGC,IAAgBgB,GAAAA,GAAAA,CAAI,SAASjB,OAAYC,EAAAA,GAAAA,IAAAA;AACzE,KAAA;AACJ;;;;"}
|
package/dist/riotprompt.cjs
CHANGED
|
@@ -31,7 +31,7 @@ const fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
|
|
|
31
31
|
const path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
32
32
|
const fs__namespace$1 = /*#__PURE__*/_interopNamespaceDefault(fs$1);
|
|
33
33
|
|
|
34
|
-
const
|
|
34
|
+
const ParametersSchema = zod.z.record(zod.z.string(), zod.z.union([
|
|
35
35
|
zod.z.string(),
|
|
36
36
|
zod.z.number(),
|
|
37
37
|
zod.z.boolean(),
|
|
@@ -41,7 +41,7 @@ const parameters.ParametersSchema = zod.z.record(zod.z.string(), zod.z.union([
|
|
|
41
41
|
zod.z.boolean()
|
|
42
42
|
]))
|
|
43
43
|
]));
|
|
44
|
-
const create$
|
|
44
|
+
const create$d = (parameters)=>{
|
|
45
45
|
return parameters;
|
|
46
46
|
};
|
|
47
47
|
const apply = (text, parameters)=>{
|
|
@@ -78,12 +78,12 @@ zod.z.object({
|
|
|
78
78
|
text: zod.z.string(),
|
|
79
79
|
weight: zod.z.number().optional()
|
|
80
80
|
});
|
|
81
|
-
const
|
|
81
|
+
const WeightedOptionsSchema = zod.z.object({
|
|
82
82
|
weight: zod.z.number().optional(),
|
|
83
|
-
parameters:
|
|
83
|
+
parameters: ParametersSchema.optional()
|
|
84
84
|
});
|
|
85
|
-
const create$
|
|
86
|
-
const weightedOptions =
|
|
85
|
+
const create$c = (text, options = {})=>{
|
|
86
|
+
const weightedOptions = WeightedOptionsSchema.parse(options);
|
|
87
87
|
const parameterizedText = apply(text, weightedOptions.parameters);
|
|
88
88
|
return {
|
|
89
89
|
text: parameterizedText,
|
|
@@ -92,36 +92,36 @@ const create$8 = (text, options = {})=>{
|
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
// Export create function
|
|
95
|
-
const create$
|
|
96
|
-
const weightedOptions =
|
|
97
|
-
return create$
|
|
95
|
+
const create$b = (text, options = {})=>{
|
|
96
|
+
const weightedOptions = WeightedOptionsSchema.parse(options);
|
|
97
|
+
return create$c(text, weightedOptions);
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
-
const create$
|
|
101
|
-
const weightedOptions =
|
|
102
|
-
return create$
|
|
100
|
+
const create$a = (text, options = {})=>{
|
|
101
|
+
const weightedOptions = WeightedOptionsSchema.parse(options);
|
|
102
|
+
return create$c(text, weightedOptions);
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
-
const create$
|
|
106
|
-
const weightedOptions =
|
|
107
|
-
return create$
|
|
105
|
+
const create$9 = (text, options = {})=>{
|
|
106
|
+
const weightedOptions = WeightedOptionsSchema.parse(options);
|
|
107
|
+
return create$c(text, weightedOptions);
|
|
108
108
|
};
|
|
109
109
|
|
|
110
|
-
const
|
|
110
|
+
const SectionOptionsSchema = zod.z.object({
|
|
111
111
|
title: zod.z.string().optional(),
|
|
112
112
|
weight: zod.z.number().optional(),
|
|
113
113
|
itemWeight: zod.z.number().optional(),
|
|
114
|
-
parameters:
|
|
114
|
+
parameters: ParametersSchema.optional().default({})
|
|
115
115
|
});
|
|
116
|
-
const create$
|
|
116
|
+
const create$8 = (options = {})=>{
|
|
117
117
|
const items = [];
|
|
118
|
-
const sectionOptions =
|
|
119
|
-
const sectionItemOptions =
|
|
118
|
+
const sectionOptions = SectionOptionsSchema.parse(options);
|
|
119
|
+
const sectionItemOptions = WeightedOptionsSchema.parse({
|
|
120
120
|
...sectionOptions,
|
|
121
121
|
weight: sectionOptions.itemWeight
|
|
122
122
|
});
|
|
123
123
|
const append = (item, options = {})=>{
|
|
124
|
-
let itemOptions =
|
|
124
|
+
let itemOptions = WeightedOptionsSchema.parse(options);
|
|
125
125
|
itemOptions = {
|
|
126
126
|
...sectionItemOptions,
|
|
127
127
|
...itemOptions
|
|
@@ -132,15 +132,15 @@ const create$4 = (options = {})=>{
|
|
|
132
132
|
});
|
|
133
133
|
} else {
|
|
134
134
|
if (typeof item === 'string') {
|
|
135
|
-
items.push(create$
|
|
135
|
+
items.push(create$c(item, itemOptions));
|
|
136
136
|
} else {
|
|
137
137
|
items.push(item);
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
return section
|
|
140
|
+
return section;
|
|
141
141
|
};
|
|
142
142
|
const prepend = (item, options = {})=>{
|
|
143
|
-
let itemOptions =
|
|
143
|
+
let itemOptions = WeightedOptionsSchema.parse(options);
|
|
144
144
|
itemOptions = {
|
|
145
145
|
...sectionItemOptions,
|
|
146
146
|
...itemOptions
|
|
@@ -151,15 +151,15 @@ const create$4 = (options = {})=>{
|
|
|
151
151
|
});
|
|
152
152
|
} else {
|
|
153
153
|
if (typeof item === 'string') {
|
|
154
|
-
items.unshift(create$
|
|
154
|
+
items.unshift(create$c(item, itemOptions));
|
|
155
155
|
} else {
|
|
156
156
|
items.unshift(item);
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
return section
|
|
159
|
+
return section;
|
|
160
160
|
};
|
|
161
161
|
const insert = (index, item, options = {})=>{
|
|
162
|
-
let itemOptions =
|
|
162
|
+
let itemOptions = WeightedOptionsSchema.parse(options);
|
|
163
163
|
itemOptions = {
|
|
164
164
|
...sectionItemOptions,
|
|
165
165
|
...itemOptions
|
|
@@ -170,39 +170,39 @@ const create$4 = (options = {})=>{
|
|
|
170
170
|
});
|
|
171
171
|
} else {
|
|
172
172
|
if (typeof item === 'string') {
|
|
173
|
-
items.splice(index, 0, create$
|
|
173
|
+
items.splice(index, 0, create$c(item, itemOptions));
|
|
174
174
|
} else {
|
|
175
175
|
items.splice(index, 0, item);
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
return section
|
|
178
|
+
return section;
|
|
179
179
|
};
|
|
180
180
|
const remove = (index)=>{
|
|
181
181
|
items.splice(index, 1);
|
|
182
|
-
return section
|
|
182
|
+
return section;
|
|
183
183
|
};
|
|
184
184
|
const replace = (index, item, options = {})=>{
|
|
185
|
-
let itemOptions =
|
|
185
|
+
let itemOptions = WeightedOptionsSchema.parse(options);
|
|
186
186
|
itemOptions = {
|
|
187
187
|
...sectionItemOptions,
|
|
188
188
|
...itemOptions
|
|
189
189
|
};
|
|
190
190
|
if (typeof item === 'string') {
|
|
191
|
-
items[index] = create$
|
|
191
|
+
items[index] = create$c(item, itemOptions);
|
|
192
192
|
} else {
|
|
193
193
|
items[index] = item;
|
|
194
194
|
}
|
|
195
|
-
return section
|
|
195
|
+
return section;
|
|
196
196
|
};
|
|
197
197
|
const add = (item, options = {})=>{
|
|
198
|
-
let itemOptions =
|
|
198
|
+
let itemOptions = WeightedOptionsSchema.parse(options);
|
|
199
199
|
itemOptions = {
|
|
200
200
|
...sectionItemOptions,
|
|
201
201
|
...itemOptions
|
|
202
202
|
};
|
|
203
203
|
return append(item, itemOptions);
|
|
204
204
|
};
|
|
205
|
-
const section
|
|
205
|
+
const section = {
|
|
206
206
|
title: sectionOptions.title,
|
|
207
207
|
items,
|
|
208
208
|
weight: sectionOptions.weight,
|
|
@@ -213,15 +213,15 @@ const create$4 = (options = {})=>{
|
|
|
213
213
|
remove,
|
|
214
214
|
replace
|
|
215
215
|
};
|
|
216
|
-
return section
|
|
216
|
+
return section;
|
|
217
217
|
};
|
|
218
218
|
|
|
219
|
-
const create$
|
|
220
|
-
const weightedOptions =
|
|
221
|
-
return create$
|
|
219
|
+
const create$7 = (text, options = {})=>{
|
|
220
|
+
const weightedOptions = WeightedOptionsSchema.parse(options);
|
|
221
|
+
return create$c(text, weightedOptions);
|
|
222
222
|
};
|
|
223
223
|
|
|
224
|
-
const create$
|
|
224
|
+
const create$6 = ({ persona, instructions, contents, contexts })=>{
|
|
225
225
|
return {
|
|
226
226
|
persona,
|
|
227
227
|
instructions,
|
|
@@ -230,8 +230,8 @@ const create$2 = ({ persona, instructions, contents, contexts })=>{
|
|
|
230
230
|
};
|
|
231
231
|
};
|
|
232
232
|
|
|
233
|
-
const
|
|
234
|
-
const
|
|
233
|
+
const DEFAULT_CHARACTER_ENCODING = "utf8";
|
|
234
|
+
const LIBRARY_NAME = "riotprompt";
|
|
235
235
|
const DEFAULT_PERSONA_ROLE = "developer";
|
|
236
236
|
const DEFAULT_IGNORE_PATTERNS = [
|
|
237
237
|
"^\\..*",
|
|
@@ -280,8 +280,10 @@ const DEFAULT_LOGGER = {
|
|
|
280
280
|
info: (message, ...args)=>console.info(message, ...args),
|
|
281
281
|
warn: (message, ...args)=>console.warn(message, ...args),
|
|
282
282
|
error: (message, ...args)=>console.error(message, ...args),
|
|
283
|
-
|
|
284
|
-
|
|
283
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
284
|
+
verbose: (message, ...args)=>{},
|
|
285
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
286
|
+
silly: (message, ...args)=>{}
|
|
285
287
|
};
|
|
286
288
|
const wrapLogger = (toWrap, name)=>{
|
|
287
289
|
const requiredMethods = [
|
|
@@ -297,7 +299,7 @@ const wrapLogger = (toWrap, name)=>{
|
|
|
297
299
|
throw new Error(`Logger is missing required methods: ${missingMethods.join(', ')}`);
|
|
298
300
|
}
|
|
299
301
|
const log = (level, message, ...args)=>{
|
|
300
|
-
message = `[${
|
|
302
|
+
message = `[${LIBRARY_NAME}] ${name ? `[${name}]` : ''}: ${message}`;
|
|
301
303
|
if (level === 'debug') toWrap.debug(message, ...args);
|
|
302
304
|
else if (level === 'info') toWrap.info(message, ...args);
|
|
303
305
|
else if (level === 'warn') toWrap.warn(message, ...args);
|
|
@@ -389,7 +391,7 @@ function isSection(obj) {
|
|
|
389
391
|
function isWeighted(obj) {
|
|
390
392
|
return obj && typeof obj === 'object' && 'text' in obj;
|
|
391
393
|
}
|
|
392
|
-
const
|
|
394
|
+
const create$5 = (formatterOptions)=>{
|
|
393
395
|
const options = OptionSchema$1.parse(formatterOptions || {});
|
|
394
396
|
const logger = wrapLogger(options.logger, 'Formatter');
|
|
395
397
|
let formatOptions = DEFAULT_FORMAT_OPTIONS;
|
|
@@ -490,7 +492,7 @@ const formatter = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty(
|
|
|
490
492
|
OptionSchema: OptionSchema$1,
|
|
491
493
|
SectionSeparatorSchema,
|
|
492
494
|
SectionTitlePropertySchema,
|
|
493
|
-
create:
|
|
495
|
+
create: create$5
|
|
494
496
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
495
497
|
|
|
496
498
|
const parseMarkdown = (input, options = {})=>{
|
|
@@ -500,11 +502,11 @@ const parseMarkdown = (input, options = {})=>{
|
|
|
500
502
|
} else {
|
|
501
503
|
markdownContent = input.toString();
|
|
502
504
|
}
|
|
503
|
-
const sectionOptions =
|
|
505
|
+
const sectionOptions = SectionOptionsSchema.parse(options);
|
|
504
506
|
// Use marked.lexer to get tokens without full parsing/rendering
|
|
505
507
|
const tokens = marked.marked.lexer(markdownContent);
|
|
506
508
|
// Create the main section (with a Title from the options)
|
|
507
|
-
const mainSection = create$
|
|
509
|
+
const mainSection = create$8(sectionOptions);
|
|
508
510
|
// Track sections at each depth level
|
|
509
511
|
const sectionStack = [
|
|
510
512
|
mainSection
|
|
@@ -512,7 +514,7 @@ const parseMarkdown = (input, options = {})=>{
|
|
|
512
514
|
// Set if we've seen the first token
|
|
513
515
|
let isFirstToken = true;
|
|
514
516
|
// Set the item options
|
|
515
|
-
const itemOptions =
|
|
517
|
+
const itemOptions = WeightedOptionsSchema.parse({
|
|
516
518
|
...sectionOptions,
|
|
517
519
|
weight: sectionOptions.itemWeight
|
|
518
520
|
});
|
|
@@ -529,7 +531,7 @@ const parseMarkdown = (input, options = {})=>{
|
|
|
529
531
|
}
|
|
530
532
|
isFirstToken = false;
|
|
531
533
|
// Create a new section with this heading
|
|
532
|
-
const newSection = create$
|
|
534
|
+
const newSection = create$8({
|
|
533
535
|
...sectionOptions,
|
|
534
536
|
title: token.text
|
|
535
537
|
});
|
|
@@ -555,7 +557,7 @@ const parseMarkdown = (input, options = {})=>{
|
|
|
555
557
|
case 'paragraph':
|
|
556
558
|
{
|
|
557
559
|
isFirstToken = false;
|
|
558
|
-
const instruction = create$
|
|
560
|
+
const instruction = create$c(token.text, itemOptions);
|
|
559
561
|
const currentSection = sectionStack[sectionStack.length - 1];
|
|
560
562
|
currentSection.add(instruction, itemOptions);
|
|
561
563
|
break;
|
|
@@ -565,7 +567,7 @@ const parseMarkdown = (input, options = {})=>{
|
|
|
565
567
|
isFirstToken = false;
|
|
566
568
|
// Convert list items to instructions
|
|
567
569
|
const listInstructionContent = token.items.map((item)=>`- ${item.text}`).join('\n');
|
|
568
|
-
const listInstruction = create$
|
|
570
|
+
const listInstruction = create$c(listInstructionContent, itemOptions);
|
|
569
571
|
const currentSection = sectionStack[sectionStack.length - 1];
|
|
570
572
|
currentSection.add(listInstruction, itemOptions);
|
|
571
573
|
break;
|
|
@@ -574,7 +576,7 @@ const parseMarkdown = (input, options = {})=>{
|
|
|
574
576
|
{
|
|
575
577
|
isFirstToken = false;
|
|
576
578
|
// Represent code blocks as instructions
|
|
577
|
-
const codeInstruction = create$
|
|
579
|
+
const codeInstruction = create$c(`\`\`\`${token.lang || ''}\n${token.text}\n\`\`\``, itemOptions);
|
|
578
580
|
const currentSection = sectionStack[sectionStack.length - 1];
|
|
579
581
|
currentSection.add(codeInstruction, itemOptions);
|
|
580
582
|
break;
|
|
@@ -586,7 +588,7 @@ const parseMarkdown = (input, options = {})=>{
|
|
|
586
588
|
isFirstToken = false;
|
|
587
589
|
// Treat other block tokens' text as instructions for robustness
|
|
588
590
|
if ('text' in token && token.text) {
|
|
589
|
-
const fallbackInstruction = create$
|
|
591
|
+
const fallbackInstruction = create$c(token.text, itemOptions);
|
|
590
592
|
const currentSection = sectionStack[sectionStack.length - 1];
|
|
591
593
|
currentSection.add(fallbackInstruction, itemOptions);
|
|
592
594
|
}
|
|
@@ -604,18 +606,18 @@ const parseText = (input, options = {})=>{
|
|
|
604
606
|
} else {
|
|
605
607
|
text = input.toString();
|
|
606
608
|
}
|
|
607
|
-
const sectionOptions =
|
|
609
|
+
const sectionOptions = SectionOptionsSchema.parse(options);
|
|
608
610
|
// Set the item options
|
|
609
|
-
const itemOptions =
|
|
611
|
+
const itemOptions = WeightedOptionsSchema.parse({
|
|
610
612
|
...sectionOptions,
|
|
611
613
|
weight: sectionOptions.itemWeight
|
|
612
614
|
});
|
|
613
615
|
// Split the text on newlines
|
|
614
616
|
const lines = text.split(/\r?\n/).filter((line)=>line.trim().length > 0);
|
|
615
617
|
// Create the main section with the supplied title
|
|
616
|
-
const mainSection = create$
|
|
618
|
+
const mainSection = create$8(sectionOptions);
|
|
617
619
|
for (const line of lines){
|
|
618
|
-
const instruction = create$
|
|
620
|
+
const instruction = create$c(line, itemOptions);
|
|
619
621
|
mainSection.add(instruction, itemOptions);
|
|
620
622
|
}
|
|
621
623
|
return mainSection;
|
|
@@ -634,7 +636,7 @@ const markdownRegex = /^(#+\s|\*\s|-\s|\+\s|>\s|\[.*\]\(.*\)|```|~~~|---\\s*$)/m
|
|
|
634
636
|
return false;
|
|
635
637
|
}
|
|
636
638
|
// Convert Buffer to string if necessary
|
|
637
|
-
const content = typeof input === 'string' ? input : input.toString(
|
|
639
|
+
const content = typeof input === 'string' ? input : input.toString(DEFAULT_CHARACTER_ENCODING);
|
|
638
640
|
if (!content || content.trim() === '') {
|
|
639
641
|
return false; // Empty string is not considered Markdown
|
|
640
642
|
}
|
|
@@ -732,7 +734,7 @@ const markdownRegex = /^(#+\s|\*\s|-\s|\+\s|>\s|\[.*\]\(.*\)|```|~~~|---\\s*$)/m
|
|
|
732
734
|
function isText(input) {
|
|
733
735
|
let buf;
|
|
734
736
|
if (typeof input === 'string') {
|
|
735
|
-
buf = Buffer.from(input,
|
|
737
|
+
buf = Buffer.from(input, DEFAULT_CHARACTER_ENCODING);
|
|
736
738
|
} else {
|
|
737
739
|
buf = input;
|
|
738
740
|
}
|
|
@@ -746,7 +748,7 @@ function isText(input) {
|
|
|
746
748
|
}
|
|
747
749
|
// For UTF-8 encoded text (including emoji and international characters),
|
|
748
750
|
// convert to string first and check if there are non-printable characters
|
|
749
|
-
const str = buf.toString(
|
|
751
|
+
const str = buf.toString(DEFAULT_CHARACTER_ENCODING);
|
|
750
752
|
// Count the number of non-printable ASCII characters (excluding common whitespace)
|
|
751
753
|
let nonPrintable = 0;
|
|
752
754
|
const len = Math.min(str.length, 512); // Only check the first 512 characters for performance
|
|
@@ -764,14 +766,14 @@ function isText(input) {
|
|
|
764
766
|
|
|
765
767
|
const OptionsSchema$2 = zod.z.object({
|
|
766
768
|
logger: zod.z.any().optional().default(DEFAULT_LOGGER),
|
|
767
|
-
parameters:
|
|
769
|
+
parameters: ParametersSchema.optional().default({})
|
|
768
770
|
});
|
|
769
|
-
const
|
|
771
|
+
const create$4 = (parserOptions)=>{
|
|
770
772
|
const options = OptionsSchema$2.parse(parserOptions || {});
|
|
771
773
|
const parameters = options.parameters;
|
|
772
774
|
const logger = wrapLogger(options.logger, 'Parser');
|
|
773
775
|
const loadOptions = (sectionOptions = {})=>{
|
|
774
|
-
const currentOptions =
|
|
776
|
+
const currentOptions = SectionOptionsSchema.parse(sectionOptions);
|
|
775
777
|
return {
|
|
776
778
|
...currentOptions,
|
|
777
779
|
parameters: {
|
|
@@ -826,11 +828,11 @@ const parser.create = (parserOptions)=>{
|
|
|
826
828
|
|
|
827
829
|
const parser = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
828
830
|
__proto__: null,
|
|
829
|
-
create:
|
|
831
|
+
create: create$4
|
|
830
832
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
831
833
|
|
|
832
834
|
// eslint-disable-next-line no-restricted-imports
|
|
833
|
-
const create$
|
|
835
|
+
const create$3 = (params)=>{
|
|
834
836
|
// eslint-disable-next-line no-console
|
|
835
837
|
const log = params.log || console.log;
|
|
836
838
|
const exists = async (path)=>{
|
|
@@ -957,7 +959,7 @@ const create$1 = (params)=>{
|
|
|
957
959
|
const OptionsSchema$1 = zod.z.object({
|
|
958
960
|
logger: zod.z.any().optional().default(DEFAULT_LOGGER),
|
|
959
961
|
ignorePatterns: zod.z.array(zod.z.string()).optional().default(DEFAULT_IGNORE_PATTERNS),
|
|
960
|
-
parameters:
|
|
962
|
+
parameters: ParametersSchema.optional().default({})
|
|
961
963
|
});
|
|
962
964
|
/**
|
|
963
965
|
* Extracts the first header from Markdown text
|
|
@@ -985,13 +987,13 @@ const OptionsSchema$1 = zod.z.object({
|
|
|
985
987
|
}
|
|
986
988
|
return markdownText;
|
|
987
989
|
}
|
|
988
|
-
const
|
|
990
|
+
const create$2 = (loaderOptions)=>{
|
|
989
991
|
const options = OptionsSchema$1.parse(loaderOptions || {});
|
|
990
992
|
const parameters = options.parameters;
|
|
991
993
|
const logger = wrapLogger(options.logger, 'Loader');
|
|
992
994
|
const ignorePatterns = options.ignorePatterns;
|
|
993
995
|
const loadOptions = (sectionOptions = {})=>{
|
|
994
|
-
const currentOptions =
|
|
996
|
+
const currentOptions = SectionOptionsSchema.parse(sectionOptions);
|
|
995
997
|
return {
|
|
996
998
|
...currentOptions,
|
|
997
999
|
parameters: {
|
|
@@ -1013,7 +1015,7 @@ const loader.create = (loaderOptions)=>{
|
|
|
1013
1015
|
logger.debug(`No context directories provided, returning empty context`);
|
|
1014
1016
|
return contextSections;
|
|
1015
1017
|
}
|
|
1016
|
-
const storage = create$
|
|
1018
|
+
const storage = create$3({
|
|
1017
1019
|
log: logger.debug
|
|
1018
1020
|
});
|
|
1019
1021
|
// Add context sections from each directory
|
|
@@ -1031,7 +1033,7 @@ const loader.create = (loaderOptions)=>{
|
|
|
1031
1033
|
const firstHeader = extractFirstHeader(mainContextContent);
|
|
1032
1034
|
// Use the header from context.md as the section title, or fallback to directory name
|
|
1033
1035
|
const sectionTitle = firstHeader || dirName;
|
|
1034
|
-
mainContextSection = create$
|
|
1036
|
+
mainContextSection = create$8({
|
|
1035
1037
|
...sectionOptions,
|
|
1036
1038
|
title: sectionTitle
|
|
1037
1039
|
});
|
|
@@ -1047,7 +1049,7 @@ const loader.create = (loaderOptions)=>{
|
|
|
1047
1049
|
}
|
|
1048
1050
|
} else {
|
|
1049
1051
|
// If no context.md exists, use directory name as title
|
|
1050
|
-
mainContextSection = create$
|
|
1052
|
+
mainContextSection = create$8({
|
|
1051
1053
|
...sectionOptions,
|
|
1052
1054
|
title: dirName
|
|
1053
1055
|
});
|
|
@@ -1075,7 +1077,7 @@ const loader.create = (loaderOptions)=>{
|
|
|
1075
1077
|
}
|
|
1076
1078
|
}
|
|
1077
1079
|
// Create a subsection with the extracted name
|
|
1078
|
-
const fileSection = create$
|
|
1080
|
+
const fileSection = create$8({
|
|
1079
1081
|
...sectionOptions,
|
|
1080
1082
|
title: sectionName
|
|
1081
1083
|
});
|
|
@@ -1102,7 +1104,7 @@ const loader.create = (loaderOptions)=>{
|
|
|
1102
1104
|
|
|
1103
1105
|
const loader = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
1104
1106
|
__proto__: null,
|
|
1105
|
-
create:
|
|
1107
|
+
create: create$2,
|
|
1106
1108
|
extractFirstHeader,
|
|
1107
1109
|
removeFirstHeader
|
|
1108
1110
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
@@ -1111,17 +1113,17 @@ const OptionsSchema = zod.z.object({
|
|
|
1111
1113
|
logger: zod.z.any().optional().default(DEFAULT_LOGGER),
|
|
1112
1114
|
configDir: zod.z.string().default('./overrides'),
|
|
1113
1115
|
overrides: zod.z.boolean().default(false),
|
|
1114
|
-
parameters:
|
|
1116
|
+
parameters: ParametersSchema.optional().default({})
|
|
1115
1117
|
});
|
|
1116
|
-
const
|
|
1118
|
+
const create$1 = (overrideOptions = {})=>{
|
|
1117
1119
|
const options = OptionsSchema.parse(overrideOptions);
|
|
1118
1120
|
const parameters = options.parameters;
|
|
1119
1121
|
const logger = wrapLogger(options === null || options === void 0 ? void 0 : options.logger, 'Override');
|
|
1120
|
-
const storage = create$
|
|
1122
|
+
const storage = create$3({
|
|
1121
1123
|
log: logger.debug
|
|
1122
1124
|
});
|
|
1123
1125
|
const loadOptions = (sectionOptions = {})=>{
|
|
1124
|
-
const currentOptions =
|
|
1126
|
+
const currentOptions = SectionOptionsSchema.parse(sectionOptions);
|
|
1125
1127
|
return {
|
|
1126
1128
|
...currentOptions,
|
|
1127
1129
|
parameters: {
|
|
@@ -1138,14 +1140,14 @@ const override.create = (overrideOptions = {})=>{
|
|
|
1138
1140
|
const response = {};
|
|
1139
1141
|
if (await storage.exists(preFile)) {
|
|
1140
1142
|
logger.silly('Found pre file %s', preFile);
|
|
1141
|
-
const parser$1 =
|
|
1143
|
+
const parser$1 = create$4({
|
|
1142
1144
|
logger
|
|
1143
1145
|
});
|
|
1144
1146
|
response.prepend = await parser$1.parseFile(preFile, currentSectionOptions);
|
|
1145
1147
|
}
|
|
1146
1148
|
if (await storage.exists(postFile)) {
|
|
1147
1149
|
logger.silly('Found post file %s', postFile);
|
|
1148
|
-
const parser$1 =
|
|
1150
|
+
const parser$1 = create$4({
|
|
1149
1151
|
logger
|
|
1150
1152
|
});
|
|
1151
1153
|
response.append = await parser$1.parseFile(postFile, currentSectionOptions);
|
|
@@ -1154,7 +1156,7 @@ const override.create = (overrideOptions = {})=>{
|
|
|
1154
1156
|
logger.silly('Found base file %s', baseFile);
|
|
1155
1157
|
if (options.overrides) {
|
|
1156
1158
|
logger.warn('WARNING: Core directives are being overwritten by custom configuration');
|
|
1157
|
-
const parser$1 =
|
|
1159
|
+
const parser$1 = create$4({
|
|
1158
1160
|
logger
|
|
1159
1161
|
});
|
|
1160
1162
|
response.override = await parser$1.parseFile(baseFile, currentSectionOptions);
|
|
@@ -1186,7 +1188,7 @@ const override.create = (overrideOptions = {})=>{
|
|
|
1186
1188
|
logger.silly('Append found, adding to content from file %s', append);
|
|
1187
1189
|
finalSection = finalSection.append(append);
|
|
1188
1190
|
}
|
|
1189
|
-
const formatter$1 =
|
|
1191
|
+
const formatter$1 = create$5({
|
|
1190
1192
|
logger
|
|
1191
1193
|
});
|
|
1192
1194
|
logger.silly('Final section %s:\n\n%s\n\n', logger.name, formatter$1.format(finalSection));
|
|
@@ -1200,7 +1202,7 @@ const override.create = (overrideOptions = {})=>{
|
|
|
1200
1202
|
|
|
1201
1203
|
const override = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
1202
1204
|
__proto__: null,
|
|
1203
|
-
create:
|
|
1205
|
+
create: create$1
|
|
1204
1206
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
1205
1207
|
|
|
1206
1208
|
const OptionSchema = zod.z.object({
|
|
@@ -1208,38 +1210,38 @@ const OptionSchema = zod.z.object({
|
|
|
1208
1210
|
basePath: zod.z.string(),
|
|
1209
1211
|
overridePath: zod.z.string().optional().default("./"),
|
|
1210
1212
|
overrides: zod.z.boolean().optional().default(false),
|
|
1211
|
-
parameters:
|
|
1213
|
+
parameters: ParametersSchema.optional().default({})
|
|
1212
1214
|
});
|
|
1213
1215
|
const create = (builderOptions)=>{
|
|
1214
1216
|
const options = OptionSchema.parse(builderOptions);
|
|
1215
1217
|
const logger = wrapLogger(options.logger, 'Builder');
|
|
1216
|
-
const parser$1 =
|
|
1218
|
+
const parser$1 = create$4({
|
|
1217
1219
|
logger
|
|
1218
1220
|
});
|
|
1219
|
-
const override$1 =
|
|
1221
|
+
const override$1 = create$1({
|
|
1220
1222
|
logger,
|
|
1221
1223
|
configDir: options.overridePath || "./",
|
|
1222
1224
|
overrides: options.overrides || false
|
|
1223
1225
|
});
|
|
1224
|
-
const loader$1 =
|
|
1226
|
+
const loader$1 = create$2({
|
|
1225
1227
|
logger
|
|
1226
1228
|
});
|
|
1227
|
-
const personaSection = create$
|
|
1229
|
+
const personaSection = create$8({
|
|
1228
1230
|
title: "Persona"
|
|
1229
1231
|
});
|
|
1230
|
-
const contextSection = create$
|
|
1232
|
+
const contextSection = create$8({
|
|
1231
1233
|
title: "Context"
|
|
1232
1234
|
});
|
|
1233
|
-
const instructionSection = create$
|
|
1235
|
+
const instructionSection = create$8({
|
|
1234
1236
|
title: "Instruction"
|
|
1235
1237
|
});
|
|
1236
|
-
const contentSection = create$
|
|
1238
|
+
const contentSection = create$8({
|
|
1237
1239
|
title: "Content"
|
|
1238
1240
|
});
|
|
1239
1241
|
const parameters = options.parameters;
|
|
1240
1242
|
const instance = {};
|
|
1241
1243
|
const loadOptions = (sectionOptions = {})=>{
|
|
1242
|
-
const currentOptions =
|
|
1244
|
+
const currentOptions = SectionOptionsSchema.parse(sectionOptions);
|
|
1243
1245
|
return {
|
|
1244
1246
|
...currentOptions,
|
|
1245
1247
|
parameters: {
|
|
@@ -1325,7 +1327,7 @@ const create = (builderOptions)=>{
|
|
|
1325
1327
|
instance.addContext = addContext;
|
|
1326
1328
|
const build = async ()=>{
|
|
1327
1329
|
logger.debug("Building prompt", {});
|
|
1328
|
-
const prompt = create$
|
|
1330
|
+
const prompt = create$6({
|
|
1329
1331
|
persona: personaSection,
|
|
1330
1332
|
contexts: contextSection,
|
|
1331
1333
|
instructions: instructionSection,
|
|
@@ -1348,12 +1350,12 @@ exports.Formatter = formatter;
|
|
|
1348
1350
|
exports.Loader = loader;
|
|
1349
1351
|
exports.Override = override;
|
|
1350
1352
|
exports.Parser = parser;
|
|
1351
|
-
exports.createContent = create$
|
|
1352
|
-
exports.createContext = create$
|
|
1353
|
-
exports.createInstruction = create$
|
|
1354
|
-
exports.createParameters = create$
|
|
1355
|
-
exports.createPrompt = create$
|
|
1356
|
-
exports.createSection = create$
|
|
1357
|
-
exports.createTrait = create$
|
|
1358
|
-
exports.createWeighted = create$
|
|
1353
|
+
exports.createContent = create$b;
|
|
1354
|
+
exports.createContext = create$a;
|
|
1355
|
+
exports.createInstruction = create$9;
|
|
1356
|
+
exports.createParameters = create$d;
|
|
1357
|
+
exports.createPrompt = create$6;
|
|
1358
|
+
exports.createSection = create$8;
|
|
1359
|
+
exports.createTrait = create$7;
|
|
1360
|
+
exports.createWeighted = create$c;
|
|
1359
1361
|
//# sourceMappingURL=riotprompt.cjs.map
|