wip
This commit is contained in:

committed by
Geoff Seemueller

parent
198b2495dc
commit
c8b0215435
@@ -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<string, any>;
|
||||
customSecretPatterns?: Record<string, any>;
|
||||
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) {
|
||||
|
32
src/prompts.ts
Normal file
32
src/prompts.ts
Normal file
@@ -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<string, string> = {
|
||||
"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];
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user