Skip to content

Commit 47fd9e8

Browse files
authored
Merge pull request #165 from drivecore/feature/disable-user-prompt
Add enableUserPrompt command line option
2 parents fc73241 + d0c9174 commit 47fd9e8

File tree

7 files changed

+54
-16
lines changed

7 files changed

+54
-16
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'mycoder': patch
3+
'mycoder-agent': patch
4+
---
5+
6+
Add `--enableUserPrompt` command line option that defaults to true but can be set to false to disable the userPrompt tool for fully automated sessions.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ mycoder "Implement a React component that displays a list of items"
3434
# Run with a prompt from a file
3535
mycoder -f prompt.txt
3636

37+
# Disable user prompts for fully automated sessions
38+
mycoder --enableUserPrompt false "Generate a basic Express.js server"
39+
3740
# Enable GitHub mode
3841
mycoder config set githubMode true
3942
```

packages/agent/src/core/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export type ToolContext = {
1919
githubMode: boolean;
2020
customPrompt?: string;
2121
tokenCache?: boolean;
22+
enableUserPrompt?: boolean;
2223
};
2324

2425
export type Tool<TParams = Record<string, any>, TReturn = any> = {
Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Tool } from '../core/types.js';
22

3+
// Import tools
34
import { browseMessageTool } from './browser/browseMessage.js';
45
import { browseStartTool } from './browser/browseStart.js';
56
import { subAgentTool } from './interaction/subAgent.js';
@@ -12,18 +13,33 @@ import { shellMessageTool } from './system/shellMessage.js';
1213
import { shellStartTool } from './system/shellStart.js';
1314
import { sleepTool } from './system/sleep.js';
1415

15-
export function getTools(): Tool[] {
16-
return [
17-
textEditorTool,
18-
subAgentTool,
19-
userPromptTool,
20-
sequenceCompleteTool,
21-
fetchTool,
22-
shellStartTool,
23-
shellMessageTool,
24-
browseStartTool,
25-
browseMessageTool,
26-
respawnTool,
27-
sleepTool,
28-
] as Tool[];
16+
// Import these separately to avoid circular dependencies
17+
18+
interface GetToolsOptions {
19+
enableUserPrompt?: boolean;
20+
}
21+
22+
export function getTools(options?: GetToolsOptions): Tool[] {
23+
const enableUserPrompt = options?.enableUserPrompt !== false; // Default to true if not specified
24+
25+
// Force cast to Tool type to avoid TypeScript issues
26+
const tools: Tool[] = [
27+
textEditorTool as unknown as Tool,
28+
subAgentTool as unknown as Tool,
29+
sequenceCompleteTool as unknown as Tool,
30+
fetchTool as unknown as Tool,
31+
shellStartTool as unknown as Tool,
32+
shellMessageTool as unknown as Tool,
33+
browseStartTool as unknown as Tool,
34+
browseMessageTool as unknown as Tool,
35+
respawnTool as unknown as Tool,
36+
sleepTool as unknown as Tool,
37+
];
38+
39+
// Only include userPrompt tool if enabled
40+
if (enableUserPrompt) {
41+
tools.push(userPromptTool as unknown as Tool);
42+
}
43+
44+
return tools;
2945
}

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

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

93-
const tools = getTools().filter((tool) => tool.name !== 'userPrompt');
93+
const tools = getTools({ enableUserPrompt: false });
9494

9595
// Update config if timeout is specified
9696
const config = {

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ export const command: CommandModule<SharedOptions, DefaultArgs> = {
170170
'Once the task is complete ask the user, via the userPrompt tool if the results are acceptable or if changes are needed or if there are additional follow on tasks.',
171171
].join('\n');
172172

173-
const tools = getTools();
173+
const tools = getTools({
174+
enableUserPrompt:
175+
argv.enableUserPrompt !== undefined ? argv.enableUserPrompt : true,
176+
});
174177

175178
// Error handling
176179
process.on('SIGINT', () => {
@@ -210,6 +213,8 @@ export const command: CommandModule<SharedOptions, DefaultArgs> = {
210213
customPrompt: config.customPrompt,
211214
tokenCache:
212215
argv.tokenCache !== undefined ? argv.tokenCache : config.tokenCache,
216+
enableUserPrompt:
217+
argv.enableUserPrompt !== undefined ? argv.enableUserPrompt : true,
213218
});
214219

215220
const output =

packages/cli/src/options.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export type SharedOptions = {
1616
readonly temperature?: number;
1717
readonly profile?: boolean;
1818
readonly tokenCache?: boolean;
19+
readonly enableUserPrompt?: boolean;
1920
};
2021

2122
export const sharedOptions = {
@@ -102,4 +103,10 @@ export const sharedOptions = {
102103
type: 'boolean',
103104
description: 'Enable token caching for LLM API calls',
104105
} as const,
106+
enableUserPrompt: {
107+
type: 'boolean',
108+
description:
109+
'Enable or disable the userPrompt tool (disable for fully automated sessions)',
110+
default: true,
111+
} as const,
105112
};

0 commit comments

Comments
 (0)