From c8b0215435e2058133e7396313aeb35b14134c4a Mon Sep 17 00:00:00 2001 From: geoffsee <> Date: Wed, 9 Apr 2025 13:35:22 -0400 Subject: [PATCH] wip --- src/MarkdownGenerator.ts | 8 ++++++-- src/prompts.ts | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 src/prompts.ts diff --git a/src/MarkdownGenerator.ts b/src/MarkdownGenerator.ts index ac69005..48ccda4 100644 --- a/src/MarkdownGenerator.ts +++ b/src/MarkdownGenerator.ts @@ -8,6 +8,7 @@ import fileTypeExclusions from './fileTypeExclusions.js'; import fileExclusions from './fileExclusions.js'; import { readFileSync } from 'node:fs'; import { glob } from 'glob'; +import { isPreset, type PresetPrompt, prompts } from './prompts.ts'; interface MarkdownGeneratorOptions { @@ -18,6 +19,7 @@ interface MarkdownGeneratorOptions { customPatterns?: Record; customSecretPatterns?: Record; verbose?: boolean; + todoPrompt?: string } /** @@ -33,6 +35,7 @@ export class MarkdownGenerator { private tokenCleaner: TokenCleaner; private verbose: boolean; private initialized: boolean; + private todoPrompt: string; /** * Creates an instance of MarkdownGenerator. @@ -44,10 +47,11 @@ export class MarkdownGenerator { this.fileTypeExclusions = new Set( options.fileTypeExclusions || fileTypeExclusions, ); - this.fileExclusions = options.fileExclusions || fileExclusions; + this.fileExclusions = options.fileExclusions || [...fileExclusions]; this.tokenCleaner = new TokenCleaner(options.customPatterns, options.customSecretPatterns); this.verbose = options.verbose !== undefined ? options.verbose : true; this.initialized = false; + this.todoPrompt = prompts.getPrompt(options.todoPrompt) } /** @@ -228,7 +232,7 @@ export class MarkdownGenerator { if (this.verbose) { console.log('File not found, creating a new \'todo\' file.'); } - await writeFile(todoPath, ''); // Create an empty 'todo' file + await writeFile(todoPath, todoPrompt); // Create an empty 'todo' file return await this.getTodo(); // Await the recursive call } if (this.verbose) { diff --git a/src/prompts.ts b/src/prompts.ts new file mode 100644 index 0000000..234ce43 --- /dev/null +++ b/src/prompts.ts @@ -0,0 +1,32 @@ +const taskConditionsStandard_FixErrors = ` +TASK: Fix these errors. +CONDITIONS: Output labeled and fully fixed files only, no diffs. +STANDARD: Respond with the files, no examples or excessive explanations. + +~~~console + +~~~ +`; + + +export const customPrompts: Record = { + "tcs:fix:errors": taskConditionsStandard_FixErrors, +}; + +export type PresetPrompt = keyof typeof customPrompts; + + +export function isPreset(key: string): boolean { + return key in customPrompts; +} + + +export const prompts = { + ...customPrompts, + default: customPrompts["tcs:fix:errors"], + getPrompt(key?: string) { + if (!key) return prompts.default; + if (!isPreset(key)) return prompts.default; + return customPrompts[key]; + } +}; \ No newline at end of file