@gringow/gringow 0.0.9 → 0.1.0

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/config.d.mts CHANGED
@@ -51,14 +51,14 @@ declare const awaitedConfig: Promise<{
51
51
  prePromptReplace?: string | undefined;
52
52
  postPromptReplace?: string | undefined;
53
53
  prePromptAppend?: string | undefined;
54
- postPromptAppend?: string | undefined;
54
+ postPromptPrepend?: string | undefined;
55
55
  };
56
56
  debug?: boolean | undefined;
57
57
  globby?: string | undefined;
58
58
  }>;
59
59
  declare function defaultPrePrompt(config: GringowConfig): string;
60
60
  declare function defaultPostPrompt(_config: GringowConfig): string;
61
- declare function prePrompt(config: GringowConfig): string;
62
- declare function postPrompt(config: GringowConfig): string;
61
+ declare function prePrompt(config: GringowConfig, append?: string, replace?: string): string;
62
+ declare function postPrompt(config: GringowConfig, prepend?: string, replace?: string): string;
63
63
 
64
64
  export { awaitedConfig, defaultPostPrompt, defaultPrePrompt, getConfigSource, isLocalConfigFound, loadUserConfig, postPrompt, prePrompt };
package/dist/config.mjs CHANGED
@@ -51,12 +51,12 @@ var configSchema = z.object({
51
51
  model: z.string().nullable(),
52
52
  temperature: z.number().optional(),
53
53
  sleep: z.number().optional(),
54
- prePrompt: z.string().optional(),
55
- postPrompt: z.string().optional(),
54
+ prePrompt: z.string().max(128).optional(),
55
+ postPrompt: z.string().max(128).optional(),
56
56
  prePromptReplace: z.string().optional(),
57
57
  postPromptReplace: z.string().optional(),
58
58
  prePromptAppend: z.string().optional(),
59
- postPromptAppend: z.string().optional()
59
+ postPromptPrepend: z.string().optional()
60
60
  }),
61
61
  globby: z.string().regex(/^\.\/.*/).optional()
62
62
  }).refine(
@@ -88,8 +88,16 @@ async function loadUserConfig() {
88
88
  try {
89
89
  const mergedConfig = merge({}, defaultConfig, result?.config);
90
90
  const parsedConfig = await configSchema.parseAsync(mergedConfig);
91
- parsedConfig.llm.prePrompt = prePrompt(parsedConfig);
92
- parsedConfig.llm.postPrompt = postPrompt(parsedConfig);
91
+ parsedConfig.llm.prePrompt = prePrompt(
92
+ parsedConfig,
93
+ parsedConfig.llm.prePromptAppend ?? "",
94
+ parsedConfig.llm.prePromptReplace ?? ""
95
+ );
96
+ parsedConfig.llm.postPrompt = postPrompt(
97
+ parsedConfig,
98
+ parsedConfig.llm.postPromptPrepend ?? "",
99
+ parsedConfig.llm.postPromptReplace ?? ""
100
+ );
93
101
  return parsedConfig;
94
102
  } catch (error) {
95
103
  console.warn(`${error?.message}, using default configuration`);
@@ -138,16 +146,16 @@ function defaultPostPrompt(_config) {
138
146
  [/POST-MESSAGE]
139
147
  `;
140
148
  }
141
- function prePrompt(config) {
149
+ function prePrompt(config, append, replace) {
142
150
  return [
143
- config.llm.prePromptReplace ? `${config.llm.prePromptReplace}` : defaultPrePrompt(config),
144
- config.llm.prePromptAppend ? ` ${config.llm.prePromptAppend}` : ""
151
+ ...append ? ["[SPECIFIC_INPUTS]", String(append), "[/SPECIFIC_INPUTS]"] : [],
152
+ replace ? String(replace) : defaultPrePrompt(config)
145
153
  ].join(" ").trim();
146
154
  }
147
- function postPrompt(config) {
155
+ function postPrompt(config, prepend, replace) {
148
156
  return [
149
- config?.llm?.postPromptReplace ? `${config.llm.postPromptReplace}` : defaultPostPrompt(),
150
- config.llm.postPromptAppend ? ` ${config.llm.postPromptAppend}` : ""
157
+ ...prepend ? ["[SPECIFIC_INPUTS]", String(prepend), "[/SPECIFIC_INPUTS]"] : [],
158
+ replace ? String(replace) : defaultPostPrompt()
151
159
  ].join(" ").trim();
152
160
  }
153
161
 
@@ -18168,12 +18168,12 @@ var configSchema = z.object({
18168
18168
  model: z.string().nullable(),
18169
18169
  temperature: z.number().optional(),
18170
18170
  sleep: z.number().optional(),
18171
- prePrompt: z.string().optional(),
18172
- postPrompt: z.string().optional(),
18171
+ prePrompt: z.string().max(128).optional(),
18172
+ postPrompt: z.string().max(128).optional(),
18173
18173
  prePromptReplace: z.string().optional(),
18174
18174
  postPromptReplace: z.string().optional(),
18175
18175
  prePromptAppend: z.string().optional(),
18176
- postPromptAppend: z.string().optional()
18176
+ postPromptPrepend: z.string().optional()
18177
18177
  }),
18178
18178
  globby: z.string().regex(/^\.\/.*/).optional()
18179
18179
  }).refine(
@@ -18199,8 +18199,16 @@ async function loadUserConfig() {
18199
18199
  try {
18200
18200
  const mergedConfig = merge({}, defaultConfig, result?.config);
18201
18201
  const parsedConfig = await configSchema.parseAsync(mergedConfig);
18202
- parsedConfig.llm.prePrompt = prePrompt(parsedConfig);
18203
- parsedConfig.llm.postPrompt = postPrompt(parsedConfig);
18202
+ parsedConfig.llm.prePrompt = prePrompt(
18203
+ parsedConfig,
18204
+ parsedConfig.llm.prePromptAppend ?? "",
18205
+ parsedConfig.llm.prePromptReplace ?? ""
18206
+ );
18207
+ parsedConfig.llm.postPrompt = postPrompt(
18208
+ parsedConfig,
18209
+ parsedConfig.llm.postPromptPrepend ?? "",
18210
+ parsedConfig.llm.postPromptReplace ?? ""
18211
+ );
18204
18212
  return parsedConfig;
18205
18213
  } catch (error) {
18206
18214
  console.warn(`${error?.message}, using default configuration`);
@@ -18249,16 +18257,16 @@ function defaultPostPrompt(_config) {
18249
18257
  [/POST-MESSAGE]
18250
18258
  `;
18251
18259
  }
18252
- function prePrompt(config2) {
18260
+ function prePrompt(config2, append, replace) {
18253
18261
  return [
18254
- config2.llm.prePromptReplace ? `${config2.llm.prePromptReplace}` : defaultPrePrompt(config2),
18255
- config2.llm.prePromptAppend ? ` ${config2.llm.prePromptAppend}` : ""
18262
+ ...append ? ["[SPECIFIC_INPUTS]", String(append), "[/SPECIFIC_INPUTS]"] : [],
18263
+ replace ? String(replace) : defaultPrePrompt(config2)
18256
18264
  ].join(" ").trim();
18257
18265
  }
18258
- function postPrompt(config2) {
18266
+ function postPrompt(config2, prepend, replace) {
18259
18267
  return [
18260
- config2?.llm?.postPromptReplace ? `${config2.llm.postPromptReplace}` : defaultPostPrompt(),
18261
- config2.llm.postPromptAppend ? ` ${config2.llm.postPromptAppend}` : ""
18268
+ ...prepend ? ["[SPECIFIC_INPUTS]", String(prepend), "[/SPECIFIC_INPUTS]"] : [],
18269
+ replace ? String(replace) : defaultPostPrompt()
18262
18270
  ].join(" ").trim();
18263
18271
  }
18264
18272
 
@@ -18305,9 +18313,7 @@ describe("config", () => {
18305
18313
  const config2 = {
18306
18314
  ...defaultConfig,
18307
18315
  llm: {
18308
- ...defaultConfig.llm,
18309
- prePromptReplace: "Custom pre-prompt"
18310
- }
18316
+ ...defaultConfig.llm}
18311
18317
  };
18312
18318
  const result2 = prePrompt(config2);
18313
18319
  globalExpect(result2).toBe("Custom pre-prompt");
@@ -18316,9 +18322,7 @@ describe("config", () => {
18316
18322
  const config2 = {
18317
18323
  ...defaultConfig,
18318
18324
  llm: {
18319
- ...defaultConfig.llm,
18320
- prePromptAppend: "Additional instructions"
18321
- }
18325
+ ...defaultConfig.llm}
18322
18326
  };
18323
18327
  const result2 = prePrompt(config2);
18324
18328
  globalExpect(result2).toContain("Additional instructions");
@@ -18328,13 +18332,10 @@ describe("config", () => {
18328
18332
  const config2 = {
18329
18333
  ...defaultConfig,
18330
18334
  llm: {
18331
- ...defaultConfig.llm,
18332
- prePromptReplace: "Custom pre-prompt",
18333
- prePromptAppend: "Additional instructions"
18334
- }
18335
+ ...defaultConfig.llm}
18335
18336
  };
18336
18337
  const result2 = prePrompt(config2);
18337
- globalExpect(result2).toBe("Custom pre-prompt Additional instructions");
18338
+ globalExpect(result2).toBe("Custom pre-prompt Additional instructions");
18338
18339
  });
18339
18340
  it("should use default prompt when no customization is provided", () => {
18340
18341
  const config2 = {
@@ -18347,45 +18348,38 @@ describe("config", () => {
18347
18348
  });
18348
18349
  describe("postPrompt", () => {
18349
18350
  it("should use postPromptReplace when provided", () => {
18350
- const config2 = {
18351
+ ({
18351
18352
  ...defaultConfig,
18352
18353
  llm: {
18353
- ...defaultConfig.llm,
18354
- postPromptReplace: "Custom post-prompt"
18355
- }
18356
- };
18357
- const result2 = postPrompt(config2);
18354
+ ...defaultConfig.llm}
18355
+ });
18356
+ const result2 = postPrompt();
18358
18357
  globalExpect(result2).toBe("Custom post-prompt");
18359
18358
  });
18360
- it("should use postPromptAppend when provided", () => {
18361
- const config2 = {
18359
+ it("should use postPromptPrepend when provided", () => {
18360
+ ({
18362
18361
  ...defaultConfig,
18363
18362
  llm: {
18364
- ...defaultConfig.llm,
18365
- postPromptAppend: "Additional post instructions"
18366
- }
18367
- };
18368
- const result2 = postPrompt(config2);
18363
+ ...defaultConfig.llm}
18364
+ });
18365
+ const result2 = postPrompt();
18369
18366
  globalExpect(result2).toContain("Additional post instructions");
18370
18367
  globalExpect(result2).toContain("[POST-MESSAGE]");
18371
18368
  });
18372
- it("should use postPromptReplace and postPromptAppend together", () => {
18373
- const config2 = {
18369
+ it("should use postPromptReplace and postPromptPrepend together", () => {
18370
+ ({
18374
18371
  ...defaultConfig,
18375
18372
  llm: {
18376
- ...defaultConfig.llm,
18377
- postPromptReplace: "Custom post-prompt",
18378
- postPromptAppend: "Additional post instructions"
18379
- }
18380
- };
18381
- const result2 = postPrompt(config2);
18382
- globalExpect(result2).toBe("Custom post-prompt Additional post instructions");
18373
+ ...defaultConfig.llm}
18374
+ });
18375
+ const result2 = postPrompt();
18376
+ globalExpect(result2).toBe("Additional post instructions Custom post-prompt");
18383
18377
  });
18384
18378
  it("should use default prompt when no customization is provided", () => {
18385
- const config2 = {
18379
+ ({
18386
18380
  ...defaultConfig
18387
- };
18388
- const result2 = postPrompt(config2);
18381
+ });
18382
+ const result2 = postPrompt();
18389
18383
  globalExpect(result2).toContain("[POST-MESSAGE]");
18390
18384
  globalExpect(result2).toContain("[/POST-MESSAGE]");
18391
18385
  });
@@ -54,12 +54,12 @@ var configSchema = z.object({
54
54
  model: z.string().nullable(),
55
55
  temperature: z.number().optional(),
56
56
  sleep: z.number().optional(),
57
- prePrompt: z.string().optional(),
58
- postPrompt: z.string().optional(),
57
+ prePrompt: z.string().max(128).optional(),
58
+ postPrompt: z.string().max(128).optional(),
59
59
  prePromptReplace: z.string().optional(),
60
60
  postPromptReplace: z.string().optional(),
61
61
  prePromptAppend: z.string().optional(),
62
- postPromptAppend: z.string().optional()
62
+ postPromptPrepend: z.string().optional()
63
63
  }),
64
64
  globby: z.string().regex(/^\.\/.*/).optional()
65
65
  }).refine(
@@ -85,8 +85,16 @@ async function loadUserConfig() {
85
85
  try {
86
86
  const mergedConfig = merge({}, defaultConfig, result?.config);
87
87
  const parsedConfig = await configSchema.parseAsync(mergedConfig);
88
- parsedConfig.llm.prePrompt = prePrompt(parsedConfig);
89
- parsedConfig.llm.postPrompt = postPrompt(parsedConfig);
88
+ parsedConfig.llm.prePrompt = prePrompt(
89
+ parsedConfig,
90
+ parsedConfig.llm.prePromptAppend ?? "",
91
+ parsedConfig.llm.prePromptReplace ?? ""
92
+ );
93
+ parsedConfig.llm.postPrompt = postPrompt(
94
+ parsedConfig,
95
+ parsedConfig.llm.postPromptPrepend ?? "",
96
+ parsedConfig.llm.postPromptReplace ?? ""
97
+ );
90
98
  return parsedConfig;
91
99
  } catch (error) {
92
100
  console.warn(`${error?.message}, using default configuration`);
@@ -135,16 +143,16 @@ function defaultPostPrompt(_config) {
135
143
  [/POST-MESSAGE]
136
144
  `;
137
145
  }
138
- function prePrompt(config) {
146
+ function prePrompt(config, append, replace) {
139
147
  return [
140
- config.llm.prePromptReplace ? `${config.llm.prePromptReplace}` : defaultPrePrompt(config),
141
- config.llm.prePromptAppend ? ` ${config.llm.prePromptAppend}` : ""
148
+ ...append ? ["[SPECIFIC_INPUTS]", String(append), "[/SPECIFIC_INPUTS]"] : [],
149
+ replace ? String(replace) : defaultPrePrompt(config)
142
150
  ].join(" ").trim();
143
151
  }
144
- function postPrompt(config) {
152
+ function postPrompt(config, prepend, replace) {
145
153
  return [
146
- config?.llm?.postPromptReplace ? `${config.llm.postPromptReplace}` : defaultPostPrompt(),
147
- config.llm.postPromptAppend ? ` ${config.llm.postPromptAppend}` : ""
154
+ ...prepend ? ["[SPECIFIC_INPUTS]", String(prepend), "[/SPECIFIC_INPUTS]"] : [],
155
+ replace ? String(replace) : defaultPostPrompt()
148
156
  ].join(" ").trim();
149
157
  }
150
158
  var optsArg = (opts) => {
@@ -54,12 +54,12 @@ var configSchema = z.object({
54
54
  model: z.string().nullable(),
55
55
  temperature: z.number().optional(),
56
56
  sleep: z.number().optional(),
57
- prePrompt: z.string().optional(),
58
- postPrompt: z.string().optional(),
57
+ prePrompt: z.string().max(128).optional(),
58
+ postPrompt: z.string().max(128).optional(),
59
59
  prePromptReplace: z.string().optional(),
60
60
  postPromptReplace: z.string().optional(),
61
61
  prePromptAppend: z.string().optional(),
62
- postPromptAppend: z.string().optional()
62
+ postPromptPrepend: z.string().optional()
63
63
  }),
64
64
  globby: z.string().regex(/^\.\/.*/).optional()
65
65
  }).refine(
@@ -85,8 +85,16 @@ async function loadUserConfig() {
85
85
  try {
86
86
  const mergedConfig = merge({}, defaultConfig, result?.config);
87
87
  const parsedConfig = await configSchema.parseAsync(mergedConfig);
88
- parsedConfig.llm.prePrompt = prePrompt(parsedConfig);
89
- parsedConfig.llm.postPrompt = postPrompt(parsedConfig);
88
+ parsedConfig.llm.prePrompt = prePrompt(
89
+ parsedConfig,
90
+ parsedConfig.llm.prePromptAppend ?? "",
91
+ parsedConfig.llm.prePromptReplace ?? ""
92
+ );
93
+ parsedConfig.llm.postPrompt = postPrompt(
94
+ parsedConfig,
95
+ parsedConfig.llm.postPromptPrepend ?? "",
96
+ parsedConfig.llm.postPromptReplace ?? ""
97
+ );
90
98
  return parsedConfig;
91
99
  } catch (error) {
92
100
  console.warn(`${error?.message}, using default configuration`);
@@ -135,16 +143,16 @@ function defaultPostPrompt(_config) {
135
143
  [/POST-MESSAGE]
136
144
  `;
137
145
  }
138
- function prePrompt(config) {
146
+ function prePrompt(config, append, replace) {
139
147
  return [
140
- config.llm.prePromptReplace ? `${config.llm.prePromptReplace}` : defaultPrePrompt(config),
141
- config.llm.prePromptAppend ? ` ${config.llm.prePromptAppend}` : ""
148
+ ...append ? ["[SPECIFIC_INPUTS]", String(append), "[/SPECIFIC_INPUTS]"] : [],
149
+ replace ? String(replace) : defaultPrePrompt(config)
142
150
  ].join(" ").trim();
143
151
  }
144
- function postPrompt(config) {
152
+ function postPrompt(config, prepend, replace) {
145
153
  return [
146
- config?.llm?.postPromptReplace ? `${config.llm.postPromptReplace}` : defaultPostPrompt(),
147
- config.llm.postPromptAppend ? ` ${config.llm.postPromptAppend}` : ""
154
+ ...prepend ? ["[SPECIFIC_INPUTS]", String(prepend), "[/SPECIFIC_INPUTS]"] : [],
155
+ replace ? String(replace) : defaultPostPrompt()
148
156
  ].join(" ").trim();
149
157
  }
150
158
  var optsArg = (opts) => {
@@ -258,12 +258,12 @@ var configSchema = z.object({
258
258
  model: z.string().nullable(),
259
259
  temperature: z.number().optional(),
260
260
  sleep: z.number().optional(),
261
- prePrompt: z.string().optional(),
262
- postPrompt: z.string().optional(),
261
+ prePrompt: z.string().max(128).optional(),
262
+ postPrompt: z.string().max(128).optional(),
263
263
  prePromptReplace: z.string().optional(),
264
264
  postPromptReplace: z.string().optional(),
265
265
  prePromptAppend: z.string().optional(),
266
- postPromptAppend: z.string().optional()
266
+ postPromptPrepend: z.string().optional()
267
267
  }),
268
268
  globby: z.string().regex(/^\.\/.*/).optional()
269
269
  }).refine(
@@ -289,8 +289,16 @@ async function loadUserConfig() {
289
289
  try {
290
290
  const mergedConfig = merge({}, defaultConfig, result?.config);
291
291
  const parsedConfig = await configSchema.parseAsync(mergedConfig);
292
- parsedConfig.llm.prePrompt = prePrompt(parsedConfig);
293
- parsedConfig.llm.postPrompt = postPrompt(parsedConfig);
292
+ parsedConfig.llm.prePrompt = prePrompt(
293
+ parsedConfig,
294
+ parsedConfig.llm.prePromptAppend ?? "",
295
+ parsedConfig.llm.prePromptReplace ?? ""
296
+ );
297
+ parsedConfig.llm.postPrompt = postPrompt(
298
+ parsedConfig,
299
+ parsedConfig.llm.postPromptPrepend ?? "",
300
+ parsedConfig.llm.postPromptReplace ?? ""
301
+ );
294
302
  return parsedConfig;
295
303
  } catch (error) {
296
304
  console.warn(`${error?.message}, using default configuration`);
@@ -339,16 +347,16 @@ function defaultPostPrompt(_config) {
339
347
  [/POST-MESSAGE]
340
348
  `;
341
349
  }
342
- function prePrompt(config) {
350
+ function prePrompt(config, append, replace) {
343
351
  return [
344
- config.llm.prePromptReplace ? `${config.llm.prePromptReplace}` : defaultPrePrompt(config),
345
- config.llm.prePromptAppend ? ` ${config.llm.prePromptAppend}` : ""
352
+ ...append ? ["[SPECIFIC_INPUTS]", String(append), "[/SPECIFIC_INPUTS]"] : [],
353
+ replace ? String(replace) : defaultPrePrompt(config)
346
354
  ].join(" ").trim();
347
355
  }
348
- function postPrompt(config) {
356
+ function postPrompt(config, prepend, replace) {
349
357
  return [
350
- config?.llm?.postPromptReplace ? `${config.llm.postPromptReplace}` : defaultPostPrompt(),
351
- config.llm.postPromptAppend ? ` ${config.llm.postPromptAppend}` : ""
358
+ ...prepend ? ["[SPECIFIC_INPUTS]", String(prepend), "[/SPECIFIC_INPUTS]"] : [],
359
+ replace ? String(replace) : defaultPostPrompt()
352
360
  ].join(" ").trim();
353
361
  }
354
362
 
@@ -54,12 +54,12 @@ var configSchema = z.object({
54
54
  model: z.string().nullable(),
55
55
  temperature: z.number().optional(),
56
56
  sleep: z.number().optional(),
57
- prePrompt: z.string().optional(),
58
- postPrompt: z.string().optional(),
57
+ prePrompt: z.string().max(128).optional(),
58
+ postPrompt: z.string().max(128).optional(),
59
59
  prePromptReplace: z.string().optional(),
60
60
  postPromptReplace: z.string().optional(),
61
61
  prePromptAppend: z.string().optional(),
62
- postPromptAppend: z.string().optional()
62
+ postPromptPrepend: z.string().optional()
63
63
  }),
64
64
  globby: z.string().regex(/^\.\/.*/).optional()
65
65
  }).refine(
@@ -85,8 +85,16 @@ async function loadUserConfig() {
85
85
  try {
86
86
  const mergedConfig = merge({}, defaultConfig, result?.config);
87
87
  const parsedConfig = await configSchema.parseAsync(mergedConfig);
88
- parsedConfig.llm.prePrompt = prePrompt(parsedConfig);
89
- parsedConfig.llm.postPrompt = postPrompt(parsedConfig);
88
+ parsedConfig.llm.prePrompt = prePrompt(
89
+ parsedConfig,
90
+ parsedConfig.llm.prePromptAppend ?? "",
91
+ parsedConfig.llm.prePromptReplace ?? ""
92
+ );
93
+ parsedConfig.llm.postPrompt = postPrompt(
94
+ parsedConfig,
95
+ parsedConfig.llm.postPromptPrepend ?? "",
96
+ parsedConfig.llm.postPromptReplace ?? ""
97
+ );
90
98
  return parsedConfig;
91
99
  } catch (error) {
92
100
  console.warn(`${error?.message}, using default configuration`);
@@ -135,16 +143,16 @@ function defaultPostPrompt(_config) {
135
143
  [/POST-MESSAGE]
136
144
  `;
137
145
  }
138
- function prePrompt(config) {
146
+ function prePrompt(config, append, replace) {
139
147
  return [
140
- config.llm.prePromptReplace ? `${config.llm.prePromptReplace}` : defaultPrePrompt(config),
141
- config.llm.prePromptAppend ? ` ${config.llm.prePromptAppend}` : ""
148
+ ...append ? ["[SPECIFIC_INPUTS]", String(append), "[/SPECIFIC_INPUTS]"] : [],
149
+ replace ? String(replace) : defaultPrePrompt(config)
142
150
  ].join(" ").trim();
143
151
  }
144
- function postPrompt(config) {
152
+ function postPrompt(config, prepend, replace) {
145
153
  return [
146
- config?.llm?.postPromptReplace ? `${config.llm.postPromptReplace}` : defaultPostPrompt(),
147
- config.llm.postPromptAppend ? ` ${config.llm.postPromptAppend}` : ""
154
+ ...prepend ? ["[SPECIFIC_INPUTS]", String(prepend), "[/SPECIFIC_INPUTS]"] : [],
155
+ replace ? String(replace) : defaultPostPrompt()
148
156
  ].join(" ").trim();
149
157
  }
150
158
  var optsArg = (opts) => {
@@ -54,12 +54,12 @@ var configSchema = z.object({
54
54
  model: z.string().nullable(),
55
55
  temperature: z.number().optional(),
56
56
  sleep: z.number().optional(),
57
- prePrompt: z.string().optional(),
58
- postPrompt: z.string().optional(),
57
+ prePrompt: z.string().max(128).optional(),
58
+ postPrompt: z.string().max(128).optional(),
59
59
  prePromptReplace: z.string().optional(),
60
60
  postPromptReplace: z.string().optional(),
61
61
  prePromptAppend: z.string().optional(),
62
- postPromptAppend: z.string().optional()
62
+ postPromptPrepend: z.string().optional()
63
63
  }),
64
64
  globby: z.string().regex(/^\.\/.*/).optional()
65
65
  }).refine(
@@ -85,8 +85,16 @@ async function loadUserConfig() {
85
85
  try {
86
86
  const mergedConfig = merge({}, defaultConfig, result?.config);
87
87
  const parsedConfig = await configSchema.parseAsync(mergedConfig);
88
- parsedConfig.llm.prePrompt = prePrompt(parsedConfig);
89
- parsedConfig.llm.postPrompt = postPrompt(parsedConfig);
88
+ parsedConfig.llm.prePrompt = prePrompt(
89
+ parsedConfig,
90
+ parsedConfig.llm.prePromptAppend ?? "",
91
+ parsedConfig.llm.prePromptReplace ?? ""
92
+ );
93
+ parsedConfig.llm.postPrompt = postPrompt(
94
+ parsedConfig,
95
+ parsedConfig.llm.postPromptPrepend ?? "",
96
+ parsedConfig.llm.postPromptReplace ?? ""
97
+ );
90
98
  return parsedConfig;
91
99
  } catch (error) {
92
100
  console.warn(`${error?.message}, using default configuration`);
@@ -135,16 +143,16 @@ function defaultPostPrompt(_config) {
135
143
  [/POST-MESSAGE]
136
144
  `;
137
145
  }
138
- function prePrompt(config) {
146
+ function prePrompt(config, append, replace) {
139
147
  return [
140
- config.llm.prePromptReplace ? `${config.llm.prePromptReplace}` : defaultPrePrompt(config),
141
- config.llm.prePromptAppend ? ` ${config.llm.prePromptAppend}` : ""
148
+ ...append ? ["[SPECIFIC_INPUTS]", String(append), "[/SPECIFIC_INPUTS]"] : [],
149
+ replace ? String(replace) : defaultPrePrompt(config)
142
150
  ].join(" ").trim();
143
151
  }
144
- function postPrompt(config) {
152
+ function postPrompt(config, prepend, replace) {
145
153
  return [
146
- config?.llm?.postPromptReplace ? `${config.llm.postPromptReplace}` : defaultPostPrompt(),
147
- config.llm.postPromptAppend ? ` ${config.llm.postPromptAppend}` : ""
154
+ ...prepend ? ["[SPECIFIC_INPUTS]", String(prepend), "[/SPECIFIC_INPUTS]"] : [],
155
+ replace ? String(replace) : defaultPostPrompt()
148
156
  ].join(" ").trim();
149
157
  }
150
158
  var optsArg = (opts) => {
@@ -54,12 +54,12 @@ var configSchema = z.object({
54
54
  model: z.string().nullable(),
55
55
  temperature: z.number().optional(),
56
56
  sleep: z.number().optional(),
57
- prePrompt: z.string().optional(),
58
- postPrompt: z.string().optional(),
57
+ prePrompt: z.string().max(128).optional(),
58
+ postPrompt: z.string().max(128).optional(),
59
59
  prePromptReplace: z.string().optional(),
60
60
  postPromptReplace: z.string().optional(),
61
61
  prePromptAppend: z.string().optional(),
62
- postPromptAppend: z.string().optional()
62
+ postPromptPrepend: z.string().optional()
63
63
  }),
64
64
  globby: z.string().regex(/^\.\/.*/).optional()
65
65
  }).refine(
@@ -85,8 +85,16 @@ async function loadUserConfig() {
85
85
  try {
86
86
  const mergedConfig = merge({}, defaultConfig, result?.config);
87
87
  const parsedConfig = await configSchema.parseAsync(mergedConfig);
88
- parsedConfig.llm.prePrompt = prePrompt(parsedConfig);
89
- parsedConfig.llm.postPrompt = postPrompt(parsedConfig);
88
+ parsedConfig.llm.prePrompt = prePrompt(
89
+ parsedConfig,
90
+ parsedConfig.llm.prePromptAppend ?? "",
91
+ parsedConfig.llm.prePromptReplace ?? ""
92
+ );
93
+ parsedConfig.llm.postPrompt = postPrompt(
94
+ parsedConfig,
95
+ parsedConfig.llm.postPromptPrepend ?? "",
96
+ parsedConfig.llm.postPromptReplace ?? ""
97
+ );
90
98
  return parsedConfig;
91
99
  } catch (error) {
92
100
  console.warn(`${error?.message}, using default configuration`);
@@ -135,16 +143,16 @@ function defaultPostPrompt(_config) {
135
143
  [/POST-MESSAGE]
136
144
  `;
137
145
  }
138
- function prePrompt(config) {
146
+ function prePrompt(config, append, replace) {
139
147
  return [
140
- config.llm.prePromptReplace ? `${config.llm.prePromptReplace}` : defaultPrePrompt(config),
141
- config.llm.prePromptAppend ? ` ${config.llm.prePromptAppend}` : ""
148
+ ...append ? ["[SPECIFIC_INPUTS]", String(append), "[/SPECIFIC_INPUTS]"] : [],
149
+ replace ? String(replace) : defaultPrePrompt(config)
142
150
  ].join(" ").trim();
143
151
  }
144
- function postPrompt(config) {
152
+ function postPrompt(config, prepend, replace) {
145
153
  return [
146
- config?.llm?.postPromptReplace ? `${config.llm.postPromptReplace}` : defaultPostPrompt(),
147
- config.llm.postPromptAppend ? ` ${config.llm.postPromptAppend}` : ""
154
+ ...prepend ? ["[SPECIFIC_INPUTS]", String(prepend), "[/SPECIFIC_INPUTS]"] : [],
155
+ replace ? String(replace) : defaultPostPrompt()
148
156
  ].join(" ").trim();
149
157
  }
150
158
  var optsArg = (opts) => {
@@ -54,12 +54,12 @@ var configSchema = z.object({
54
54
  model: z.string().nullable(),
55
55
  temperature: z.number().optional(),
56
56
  sleep: z.number().optional(),
57
- prePrompt: z.string().optional(),
58
- postPrompt: z.string().optional(),
57
+ prePrompt: z.string().max(128).optional(),
58
+ postPrompt: z.string().max(128).optional(),
59
59
  prePromptReplace: z.string().optional(),
60
60
  postPromptReplace: z.string().optional(),
61
61
  prePromptAppend: z.string().optional(),
62
- postPromptAppend: z.string().optional()
62
+ postPromptPrepend: z.string().optional()
63
63
  }),
64
64
  globby: z.string().regex(/^\.\/.*/).optional()
65
65
  }).refine(
@@ -85,8 +85,16 @@ async function loadUserConfig() {
85
85
  try {
86
86
  const mergedConfig = merge({}, defaultConfig, result?.config);
87
87
  const parsedConfig = await configSchema.parseAsync(mergedConfig);
88
- parsedConfig.llm.prePrompt = prePrompt(parsedConfig);
89
- parsedConfig.llm.postPrompt = postPrompt(parsedConfig);
88
+ parsedConfig.llm.prePrompt = prePrompt(
89
+ parsedConfig,
90
+ parsedConfig.llm.prePromptAppend ?? "",
91
+ parsedConfig.llm.prePromptReplace ?? ""
92
+ );
93
+ parsedConfig.llm.postPrompt = postPrompt(
94
+ parsedConfig,
95
+ parsedConfig.llm.postPromptPrepend ?? "",
96
+ parsedConfig.llm.postPromptReplace ?? ""
97
+ );
90
98
  return parsedConfig;
91
99
  } catch (error) {
92
100
  console.warn(`${error?.message}, using default configuration`);
@@ -135,16 +143,16 @@ function defaultPostPrompt(_config) {
135
143
  [/POST-MESSAGE]
136
144
  `;
137
145
  }
138
- function prePrompt(config) {
146
+ function prePrompt(config, append, replace) {
139
147
  return [
140
- config.llm.prePromptReplace ? `${config.llm.prePromptReplace}` : defaultPrePrompt(config),
141
- config.llm.prePromptAppend ? ` ${config.llm.prePromptAppend}` : ""
148
+ ...append ? ["[SPECIFIC_INPUTS]", String(append), "[/SPECIFIC_INPUTS]"] : [],
149
+ replace ? String(replace) : defaultPrePrompt(config)
142
150
  ].join(" ").trim();
143
151
  }
144
- function postPrompt(config) {
152
+ function postPrompt(config, prepend, replace) {
145
153
  return [
146
- config?.llm?.postPromptReplace ? `${config.llm.postPromptReplace}` : defaultPostPrompt(),
147
- config.llm.postPromptAppend ? ` ${config.llm.postPromptAppend}` : ""
154
+ ...prepend ? ["[SPECIFIC_INPUTS]", String(prepend), "[/SPECIFIC_INPUTS]"] : [],
155
+ replace ? String(replace) : defaultPostPrompt()
148
156
  ].join(" ").trim();
149
157
  }
150
158
  var optsArg = (opts) => {