diff --git a/settings.js b/settings.js index 27b8606..a0c96d8 100644 --- a/settings.js +++ b/settings.js @@ -30,6 +30,7 @@ export default "allow_insecure_coding": false, // allows newAction command and model can write/run code on your computer. enable at own risk "code_timeout_mins": 3, // minutes code is allowed to run. -1 for no timeout,set 3.Set 3 min to timely code adjustments + "relevant_docs_count": 5, // number of relevant docs to show when generating code "max_messages": 15, // max number of messages to keep in context "max_commands": -1, // max number of commands to use in a response. -1 for no limit diff --git a/src/agent/prompter.js b/src/agent/prompter.js index d1af5cf..8673b09 100644 --- a/src/agent/prompter.js +++ b/src/agent/prompter.js @@ -4,7 +4,7 @@ import { getCommandDocs } from './commands/index.js'; // import { getSkillDocs } from './library/index.js'; import { stringifyTurns } from '../utils/text.js'; import { getCommand } from './commands/index.js'; - +import settings from '../../settings.js'; import { Gemini } from '../models/gemini.js'; import { GPT } from '../models/gpt.js'; import { Claude } from '../models/claude.js'; @@ -178,19 +178,14 @@ export class Prompter { } if (prompt.includes('$COMMAND_DOCS')) prompt = prompt.replaceAll('$COMMAND_DOCS', getCommandDocs(this.agent.blocked_actions)); - if (prompt.includes('$CODE_DOCS')){ - // Find the most recent non-system message containing '!newAction(' - let code_task_content = messages.slice().reverse().find(msg => + if (prompt.includes('$CODE_DOCS')) { + const code_task_content = messages.slice().reverse().find(msg => msg.role !== 'system' && msg.content.includes('!newAction(') - )?.content || ''; - - // Extract content between '!newAction(' and ')' - const match = code_task_content.match(/!newAction\((.*?)\)/); - code_task_content = match ? match[1] : ''; + )?.content?.match(/!newAction\((.*?)\)/)?.[1] || ''; prompt = prompt.replaceAll( '$CODE_DOCS', - await this.skill_libary.getRelevantSkillDocs(code_task_content, 5) + await this.skill_libary.getRelevantSkillDocs(code_task_content, settings.relevant_docs_count) ); } if (prompt.includes('$EXAMPLES') && examples !== null)