Skip to content

Commit fa7f45e

Browse files
committed
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
1 parent 1bffa4d commit fa7f45e

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,14 @@ export default {
7272
temperature: 0.7,
7373

7474
// Custom settings
75+
// customPrompt can be a string or an array of strings for multiple lines
7576
customPrompt: '',
77+
// Example of multiple line custom prompts:
78+
// customPrompt: [
79+
// 'Custom instruction line 1',
80+
// 'Custom instruction line 2',
81+
// 'Custom instruction line 3',
82+
// ],
7683
profile: false,
7784
tokenCache: true,
7885

mycoder.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@ export default {
2020
temperature: 0.7,
2121

2222
// Custom settings
23+
// customPrompt can be a string or an array of strings for multiple lines
2324
customPrompt: '',
25+
// Example of multiple line custom prompts:
26+
// customPrompt: [
27+
// 'Custom instruction line 1',
28+
// 'Custom instruction line 2',
29+
// 'Custom instruction line 3',
30+
// ],
2431
profile: false,
2532
tokenCache: true,
2633
};

packages/agent/src/core/toolAgent/config.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,13 @@ export function getDefaultSystemPrompt(toolContext: ToolContext): string {
199199
'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.',
200200
'',
201201
'Use sub-agents for parallel tasks, providing them with specific context they need rather than having them rediscover it.',
202-
toolContext.customPrompt ? `\n\n${toolContext.customPrompt}` : '',
202+
(() => {
203+
if (!toolContext.customPrompt) return '';
204+
if (typeof toolContext.customPrompt === 'string') {
205+
return `\n\n${toolContext.customPrompt}`;
206+
}
207+
// It's an array of strings
208+
return `\n\n${toolContext.customPrompt.join('\n')}`;
209+
})(),
203210
].join('\n');
204211
}

packages/agent/src/core/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export type ToolContext = {
1919
pageFilter: pageFilter;
2020
tokenTracker: TokenTracker;
2121
githubMode: boolean;
22-
customPrompt?: string;
22+
customPrompt?: string | string[];
2323
tokenCache?: boolean;
2424
userPrompt?: boolean;
2525
agentId?: string; // Unique identifier for the agent, used for background tool tracking

packages/cli/src/settings/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export type Config = {
1313
model: string;
1414
maxTokens: number;
1515
temperature: number;
16-
customPrompt: string;
16+
customPrompt: string | string[];
1717
profile: boolean;
1818
tokenCache: boolean;
1919
userPrompt: boolean;

0 commit comments

Comments
 (0)