From fa7f45ea9e81fa73fba0afa099e127fbdeaf5281 Mon Sep 17 00:00:00 2001 From: "Ben Houston (via MyCoder)" Date: Thu, 13 Mar 2025 11:24:37 +0000 Subject: [PATCH] feat: support multiple line custom prompts in mycoder.config.js - Updated customPrompt type to accept string or string[] in types.ts and config.ts - Modified system prompt generation to handle both string and array formats - Updated examples in mycoder.config.js and README.md to demonstrate the new feature - Ensures backward compatibility with existing string-based approach Closes #249 --- README.md | 7 +++++++ mycoder.config.js | 7 +++++++ packages/agent/src/core/toolAgent/config.ts | 9 ++++++++- packages/agent/src/core/types.ts | 2 +- packages/cli/src/settings/config.ts | 2 +- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8b8a4d9..1073f05 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,14 @@ export default { temperature: 0.7, // Custom settings + // customPrompt can be a string or an array of strings for multiple lines customPrompt: '', + // Example of multiple line custom prompts: + // customPrompt: [ + // 'Custom instruction line 1', + // 'Custom instruction line 2', + // 'Custom instruction line 3', + // ], profile: false, tokenCache: true, diff --git a/mycoder.config.js b/mycoder.config.js index ead98ee..cd796b8 100644 --- a/mycoder.config.js +++ b/mycoder.config.js @@ -20,7 +20,14 @@ export default { temperature: 0.7, // Custom settings + // customPrompt can be a string or an array of strings for multiple lines customPrompt: '', + // Example of multiple line custom prompts: + // customPrompt: [ + // 'Custom instruction line 1', + // 'Custom instruction line 2', + // 'Custom instruction line 3', + // ], profile: false, tokenCache: true, }; diff --git a/packages/agent/src/core/toolAgent/config.ts b/packages/agent/src/core/toolAgent/config.ts index fea22e8..4861ed3 100644 --- a/packages/agent/src/core/toolAgent/config.ts +++ b/packages/agent/src/core/toolAgent/config.ts @@ -199,6 +199,13 @@ export function getDefaultSystemPrompt(toolContext: ToolContext): string { 'When you run into issues or unexpected results, take a step back and read the project documentation and configuration files and look at other source files in the project for examples of what works.', '', 'Use sub-agents for parallel tasks, providing them with specific context they need rather than having them rediscover it.', - toolContext.customPrompt ? `\n\n${toolContext.customPrompt}` : '', + (() => { + if (!toolContext.customPrompt) return ''; + if (typeof toolContext.customPrompt === 'string') { + return `\n\n${toolContext.customPrompt}`; + } + // It's an array of strings + return `\n\n${toolContext.customPrompt.join('\n')}`; + })(), ].join('\n'); } diff --git a/packages/agent/src/core/types.ts b/packages/agent/src/core/types.ts index a1871f0..0ceac3c 100644 --- a/packages/agent/src/core/types.ts +++ b/packages/agent/src/core/types.ts @@ -19,7 +19,7 @@ export type ToolContext = { pageFilter: pageFilter; tokenTracker: TokenTracker; githubMode: boolean; - customPrompt?: string; + customPrompt?: string | string[]; tokenCache?: boolean; userPrompt?: boolean; agentId?: string; // Unique identifier for the agent, used for background tool tracking diff --git a/packages/cli/src/settings/config.ts b/packages/cli/src/settings/config.ts index 6bbf0ef..80b2e08 100644 --- a/packages/cli/src/settings/config.ts +++ b/packages/cli/src/settings/config.ts @@ -13,7 +13,7 @@ export type Config = { model: string; maxTokens: number; temperature: number; - customPrompt: string; + customPrompt: string | string[]; profile: boolean; tokenCache: boolean; userPrompt: boolean;