Skip to content

Commit e491f3a

Browse files
authored
Merge pull request #96 from drivecore/feature/95-custom-prompt
Add customPrompt configuration option
2 parents 86be4c4 + 4646ea5 commit e491f3a

File tree

7 files changed

+9
-1
lines changed

7 files changed

+9
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,6 @@ export function getDefaultSystemPrompt(toolContext: ToolContext): string {
136136
'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.',
137137
'',
138138
'Use sub-agents for parallel tasks, providing them with specific context they need rather than having them rediscover it.',
139+
toolContext.customPrompt ? `\n\n${toolContext.customPrompt}` : '',
139140
].join('\n');
140141
}

packages/agent/src/core/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export type ToolContext = {
1717
pageFilter: pageFilter;
1818
tokenTracker: TokenTracker;
1919
githubMode: boolean;
20+
customPrompt?: string;
2021
};
2122

2223
export type Tool<TParams = Record<string, any>, TReturn = any> = {

packages/agent/src/tools/interaction/subAgent.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export const subAgentTool: Tool<Parameters, ReturnType> = {
9999
const result = await toolAgent(prompt, tools, config, {
100100
...context,
101101
workingDirectory: workingDirectory ?? context.workingDirectory,
102+
customPrompt: context.customPrompt,
102103
});
103104
return { response: result.result };
104105
},

packages/agent/src/tools/io/textEditor.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ const parameterSchema = z.object({
5656
),
5757
description: z
5858
.string()
59-
.max(80)
6059
.describe('The reason you are using the text editor (max 80 chars)'),
6160
});
6261

packages/cli/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ mycoder --modelProvider openai --modelName gpt-4o-2024-05-13 "Your prompt here"
122122
- `userSession`: Use user's existing browser session instead of sandboxed session (default: `false`)
123123
- `pageFilter`: Method to process webpage content: 'simple', 'none', or 'readability' (default: `none`)
124124
- `ollamaBaseUrl`: Base URL for Ollama API (default: `http://localhost:11434/api`)
125+
- `customPrompt`: Custom instructions to append to the system prompt for both main agent and sub-agents (default: `""`)
125126

126127
Example:
127128

@@ -137,6 +138,9 @@ mycoder config set pageFilter readability
137138

138139
# Set custom Ollama server URL
139140
mycoder config set ollamaBaseUrl http://your-ollama-server:11434/api
141+
142+
# Set custom instructions for the agent
143+
mycoder config set customPrompt "Always prioritize readability and simplicity in your code. Prefer TypeScript over JavaScript when possible."
140144
```
141145

142146
## Environment Variables

packages/cli/src/commands/$default.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ export const command: CommandModule<SharedOptions, DefaultArgs> = {
191191
workingDirectory: '.',
192192
tokenTracker,
193193
githubMode: config.githubMode,
194+
customPrompt: config.customPrompt,
194195
});
195196

196197
const output =

packages/cli/src/settings/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const defaultConfig = {
1515
modelProvider: 'anthropic',
1616
modelName: 'claude-3-7-sonnet-20250219',
1717
ollamaBaseUrl: 'http://localhost:11434/api',
18+
customPrompt: '',
1819
};
1920

2021
export type Config = typeof defaultConfig;

0 commit comments

Comments
 (0)