Skip to content

Commit 12b5a83

Browse files
committed
chore: simplify config via cosmiconfig
1 parent bc1d40b commit 12b5a83

File tree

19 files changed

+288
-1199
lines changed

19 files changed

+288
-1199
lines changed

README.md

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,54 @@ mycoder "Implement a React component that displays a list of items"
3535
mycoder -f prompt.txt
3636

3737
# Disable user prompts for fully automated sessions
38-
mycoder --enableUserPrompt false "Generate a basic Express.js server"
38+
mycoder --userPrompt false "Generate a basic Express.js server"
3939
# or using the alias
4040
mycoder --userPrompt false "Generate a basic Express.js server"
4141

4242
# Disable user consent warning and version upgrade check for automated environments
4343
mycoder --userWarning false --upgradeCheck false "Generate a basic Express.js server"
4444

45-
# Enable GitHub mode via CLI option (overrides config)
45+
# Enable GitHub mode via CLI option (overrides config file)
4646
mycoder --githubMode "Work with GitHub issues and PRs"
47+
```
4748

48-
# Enable GitHub mode via config
49-
mycoder config set githubMode true
49+
## Configuration
50+
51+
MyCoder is configured using a `mycoder.config.js` file in your project root, similar to ESLint and other modern JavaScript tools. This file exports a configuration object with your preferred settings.
52+
53+
### Creating a Configuration File
54+
55+
Create a `mycoder.config.js` file in your project root:
56+
57+
```js
58+
// mycoder.config.js
59+
export default {
60+
// GitHub integration
61+
githubMode: true,
62+
63+
// Browser settings
64+
headless: true,
65+
userSession: false,
66+
pageFilter: 'none', // 'simple', 'none', or 'readability'
67+
68+
// Model settings
69+
provider: 'anthropic',
70+
model: 'claude-3-7-sonnet-20250219',
71+
maxTokens: 4096,
72+
temperature: 0.7,
73+
74+
// Custom settings
75+
customPrompt: '',
76+
profile: false,
77+
tokenCache: true,
78+
79+
// Ollama configuration (if using local models)
80+
ollamaBaseUrl: 'http://localhost:11434',
81+
};
5082
```
5183

84+
CLI arguments will override settings in your configuration file.
85+
5286
### GitHub Comment Commands
5387

5488
MyCoder can be triggered directly from GitHub issue comments using the flexible `/mycoder` command:

docs/tools/agent-tools.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const { instanceId } = agentStart({
3939
projectContext: 'Context about the problem or environment',
4040
workingDirectory: '/path/to/working/directory', // optional
4141
relevantFilesDirectories: 'src/**/*.ts', // optional
42-
enableUserPrompt: false, // optional, default: false
42+
userPrompt: false, // optional, default: false
4343
});
4444
```
4545

packages/agent/src/core/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export type ToolContext = {
2020
githubMode: boolean;
2121
customPrompt?: string;
2222
tokenCache?: boolean;
23-
enableUserPrompt?: boolean;
23+
userPrompt?: boolean;
2424
agentId?: string; // Unique identifier for the agent, used for background tool tracking
2525
provider: ModelProvider;
2626
model: string;

packages/agent/src/tools/getTools.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ import { sleepTool } from './system/sleep.js';
1818
// Import these separately to avoid circular dependencies
1919

2020
interface GetToolsOptions {
21-
enableUserPrompt?: boolean;
21+
userPrompt?: boolean;
2222
}
2323

2424
export function getTools(options?: GetToolsOptions): Tool[] {
25-
const enableUserPrompt = options?.enableUserPrompt !== false; // Default to true if not specified
25+
const userPrompt = options?.userPrompt !== false; // Default to true if not specified
2626

2727
// Force cast to Tool type to avoid TypeScript issues
2828
const tools: Tool[] = [
@@ -41,7 +41,7 @@ export function getTools(options?: GetToolsOptions): Tool[] {
4141
];
4242

4343
// Only include userPrompt tool if enabled
44-
if (enableUserPrompt) {
44+
if (userPrompt) {
4545
tools.push(userPromptTool as unknown as Tool);
4646
}
4747

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const parameterSchema = z.object({
5050
.string()
5151
.optional()
5252
.describe('A list of files, which may include ** or * wildcard characters'),
53-
enableUserPrompt: z
53+
userPrompt: z
5454
.boolean()
5555
.optional()
5656
.describe(
@@ -104,7 +104,7 @@ export const agentStartTool: Tool<Parameters, ReturnType> = {
104104
projectContext,
105105
workingDirectory,
106106
relevantFilesDirectories,
107-
enableUserPrompt = false,
107+
userPrompt = false,
108108
} = parameterSchema.parse(params);
109109

110110
// Create an instance ID
@@ -127,7 +127,7 @@ export const agentStartTool: Tool<Parameters, ReturnType> = {
127127
.filter(Boolean)
128128
.join('\n');
129129

130-
const tools = getTools({ enableUserPrompt });
130+
const tools = getTools({ userPrompt });
131131

132132
// Store the agent state
133133
const agentState: AgentState = {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export const subAgentTool: Tool<Parameters, ReturnType> = {
104104
.filter(Boolean)
105105
.join('\n');
106106

107-
const tools = getTools({ enableUserPrompt: false });
107+
const tools = getTools({ userPrompt: false });
108108

109109
// Update config if timeout is specified
110110
const config: AgentConfig = {

packages/cli/README.md

Lines changed: 64 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ mycoder --userPrompt false "Generate a basic Express.js server"
3838
# Disable user consent warning and version upgrade check for automated environments
3939
mycoder --userWarning false --upgradeCheck false "Generate a basic Express.js server"
4040

41-
# Enable GitHub mode
42-
mycoder config set githubMode true
41+
# Enable GitHub mode via CLI option (overrides config file)
42+
mycoder --githubMode true
4343
```
4444

4545
## GitHub Mode
@@ -54,14 +54,34 @@ MyCoder includes a GitHub mode that enables the agent to work with GitHub issues
5454

5555
To enable GitHub mode:
5656

57+
1. Via CLI option (overrides config file):
5758
```bash
58-
mycoder config set githubMode true
59+
mycoder --githubMode true
60+
```
61+
62+
2. Via configuration file:
63+
```js
64+
// mycoder.config.js
65+
export default {
66+
githubMode: true,
67+
// other configuration options...
68+
};
5969
```
6070

6171
To disable GitHub mode:
6272

73+
1. Via CLI option:
6374
```bash
64-
mycoder config set githubMode false
75+
mycoder --githubMode false
76+
```
77+
78+
2. Via configuration file:
79+
```js
80+
// mycoder.config.js
81+
export default {
82+
githubMode: false,
83+
// other configuration options...
84+
};
6585
```
6686

6787
Requirements for GitHub mode:
@@ -71,7 +91,9 @@ Requirements for GitHub mode:
7191

7292
## Configuration
7393

74-
MyCoder uses a configuration file in your project directory. To create a default configuration file, run:
94+
MyCoder is configured using a `mycoder.config.js` file in your project root, similar to ESLint and other modern JavaScript tools. This file exports a configuration object with your preferred settings.
95+
96+
To create a default configuration file, run:
7597

7698
```bash
7799
# Create a default configuration file
@@ -122,13 +144,23 @@ MyCoder will search for configuration in the following places (in order of prece
122144

123145
NOTE: Anthropic Claude 3.7 works the best by far in our testing.
124146

125-
MyCoder supports Anthropic, OpenAI, xAI/Grok, Mistral AI, and Ollama models. You can configure which model provider and model name to use with the following commands:
147+
MyCoder supports Anthropic, OpenAI, xAI/Grok, Mistral AI, and Ollama models. You can configure which model provider and model name to use either via CLI options or in your configuration file:
126148

127149
```bash
128-
# Use Anthropic models [These work the best at this time]
129-
mycoder config set provider anthropic
130-
mycoder config set model claude-3-7-sonnet-20250219 # or any other Anthropic model
150+
# Via CLI options (overrides config file)
151+
mycoder --provider anthropic --model claude-3-7-sonnet-20250219 "Your prompt here"
152+
```
153+
154+
Or in your configuration file:
131155

156+
```js
157+
// mycoder.config.js
158+
export default {
159+
// Model settings
160+
provider: 'anthropic',
161+
model: 'claude-3-7-sonnet-20250219', // or any other Anthropic model
162+
// other configuration options...
163+
};
132164
```
133165

134166
### Available Configuration Options
@@ -146,25 +178,34 @@ These options are available only as command-line parameters and are not stored i
146178

147179
- `userWarning`: Skip user consent check for current session without saving consent (default: `true`)
148180
- `upgradeCheck`: Disable version upgrade check for automated/remote usage (default: `true`)
149-
- `userPrompt`/`enableUserPrompt`: Enable or disable the userPrompt tool (default: `true`)
150-
151-
Example:
181+
- `userPrompt`: Enable or disable the userPrompt tool (default: `true`)
152182

153-
```bash
154-
# Set browser to show UI
155-
mycoder config set headless false
183+
Example configuration in `mycoder.config.js`:
156184

157-
# Use existing browser session
158-
mycoder config set userSession true
185+
```js
186+
// mycoder.config.js
187+
export default {
188+
// Browser settings
189+
headless: false, // Show browser UI
190+
userSession: true, // Use existing browser session
191+
pageFilter: 'readability', // Use readability for webpage processing
192+
193+
// Custom settings
194+
customPrompt: "Always prioritize readability and simplicity in your code. Prefer TypeScript over JavaScript when possible.",
195+
tokenCache: false, // Disable token caching for LLM API calls
196+
197+
// Other configuration options...
198+
};
199+
```
159200

160-
# Use readability for webpage processing
161-
mycoder config set pageFilter readability
201+
You can also set these options via CLI arguments (which will override the config file):
162202

163-
# Set custom instructions for the agent
164-
mycoder config set customPrompt "Always prioritize readability and simplicity in your code. Prefer TypeScript over JavaScript when possible."
203+
```bash
204+
# Set browser to show UI for this session only
205+
mycoder --headless false "Your prompt here"
165206

166-
# Disable token caching for LLM API calls
167-
mycoder config set tokenCache false
207+
# Use existing browser session for this session only
208+
mycoder --userSession true "Your prompt here"
168209
```
169210

170211
## Environment Variables

0 commit comments

Comments
 (0)