Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/enable-user-prompt-option.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'mycoder': patch
'mycoder-agent': patch
---

Add `--enableUserPrompt` command line option that defaults to true but can be set to false to disable the userPrompt tool for fully automated sessions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ mycoder "Implement a React component that displays a list of items"
# Run with a prompt from a file
mycoder -f prompt.txt

# Disable user prompts for fully automated sessions
mycoder --enableUserPrompt false "Generate a basic Express.js server"

# Enable GitHub mode
mycoder config set githubMode true
```
Expand Down
1 change: 1 addition & 0 deletions packages/agent/src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type ToolContext = {
githubMode: boolean;
customPrompt?: string;
tokenCache?: boolean;
enableUserPrompt?: boolean;
};

export type Tool<TParams = Record<string, any>, TReturn = any> = {
Expand Down
44 changes: 30 additions & 14 deletions packages/agent/src/tools/getTools.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Tool } from '../core/types.js';

// Import tools
import { browseMessageTool } from './browser/browseMessage.js';
import { browseStartTool } from './browser/browseStart.js';
import { subAgentTool } from './interaction/subAgent.js';
Expand All @@ -12,18 +13,33 @@ import { shellMessageTool } from './system/shellMessage.js';
import { shellStartTool } from './system/shellStart.js';
import { sleepTool } from './system/sleep.js';

export function getTools(): Tool[] {
return [
textEditorTool,
subAgentTool,
userPromptTool,
sequenceCompleteTool,
fetchTool,
shellStartTool,
shellMessageTool,
browseStartTool,
browseMessageTool,
respawnTool,
sleepTool,
] as Tool[];
// Import these separately to avoid circular dependencies

interface GetToolsOptions {
enableUserPrompt?: boolean;
}

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

// Force cast to Tool type to avoid TypeScript issues
const tools: Tool[] = [
textEditorTool as unknown as Tool,
subAgentTool as unknown as Tool,
sequenceCompleteTool as unknown as Tool,
fetchTool as unknown as Tool,
shellStartTool as unknown as Tool,
shellMessageTool as unknown as Tool,
browseStartTool as unknown as Tool,
browseMessageTool as unknown as Tool,
respawnTool as unknown as Tool,
sleepTool as unknown as Tool,
];

// Only include userPrompt tool if enabled
if (enableUserPrompt) {
tools.push(userPromptTool as unknown as Tool);
}

return tools;
}
2 changes: 1 addition & 1 deletion packages/agent/src/tools/interaction/subAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const subAgentTool: Tool<Parameters, ReturnType> = {
.filter(Boolean)
.join('\n');

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

// Update config if timeout is specified
const config = {
Expand Down
7 changes: 6 additions & 1 deletion packages/cli/src/commands/$default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,10 @@ export const command: CommandModule<SharedOptions, DefaultArgs> = {
'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.',
].join('\n');

const tools = getTools();
const tools = getTools({
enableUserPrompt:
argv.enableUserPrompt !== undefined ? argv.enableUserPrompt : true,
});

// Error handling
process.on('SIGINT', () => {
Expand Down Expand Up @@ -202,6 +205,8 @@ export const command: CommandModule<SharedOptions, DefaultArgs> = {
customPrompt: config.customPrompt,
tokenCache:
argv.tokenCache !== undefined ? argv.tokenCache : config.tokenCache,
enableUserPrompt:
argv.enableUserPrompt !== undefined ? argv.enableUserPrompt : true,
});

const output =
Expand Down
7 changes: 7 additions & 0 deletions packages/cli/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type SharedOptions = {
readonly temperature?: number;
readonly profile?: boolean;
readonly tokenCache?: boolean;
readonly enableUserPrompt?: boolean;
};

export const sharedOptions = {
Expand Down Expand Up @@ -87,4 +88,10 @@ export const sharedOptions = {
type: 'boolean',
description: 'Enable token caching for LLM API calls',
} as const,
enableUserPrompt: {
type: 'boolean',
description:
'Enable or disable the userPrompt tool (disable for fully automated sessions)',
default: true,
} as const,
};
Loading