Skip to content
Open
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
39 changes: 39 additions & 0 deletions .cursor/App.notepad
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
These files represent the entire application

Agent.exe/
├── .cursor/ # Directory for cursor-related files
│ ├── @instructions.md # Instructions for the development process
│ ├── @current_status.md # Current status of the project
│ └── @plan.md # Project plan and roadmap
├── .erb/ # Electron React Boilerplate configurations
│ └── configs/ # Webpack and other build configurations
│ └── @webpack.config.main.dev.ts # Webpack config for main process development
├── assets/ # Static assets like images and icons
├── release/ # Build output directory
│ └── app/ # Application package directory
│ └── @package.json # Package configuration for the built app
├── src/ # Source code directory
│ ├── main/ # Main process code
│ │ ├── @main.ts # Entry point for the main process
│ │ ├── @menu.ts # Application menu configuration
│ │ ├── @preload.ts # Preload script for renderer process
│ │ └── store/ # State management for main process
│ │ ├── @create.ts # Store creation and configuration
│ │ ├── @runAgent.ts # Logic for running the AI agent
│ │ └── @types.ts # TypeScript type definitions
│ └── renderer/ # Renderer process code
│ ├── @App.tsx # Main React component
│ ├── @index.ejs # HTML template for the app
│ ├── @index.tsx # Entry point for the renderer process
│ ├── @RunHistory.tsx # Component for displaying run history
│ ├── @global.d.ts # Global type declarations
│ └── hooks/ # Custom React hooks
│ └── @useStore.ts # Hook for accessing the Zustand store
├── .editorconfig # Editor configuration for consistent coding styles
├── .env # Environment variables (not tracked in git)
├── .eslintignore # Files to be ignored by ESLint
├── .eslintrc # ESLint configuration
├── .gitignore # Git ignore file
├── @package.json # Node.js dependencies and scripts
├── @README.md # Project documentation and overview
└── tsconfig.json # TypeScript configuration
182 changes: 182 additions & 0 deletions .cursor/current_status.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
# Current Status

## Iteration 1: Project Evaluation

1. Completed initial project structure analysis
2. Identified key components and their purposes:
- Main process (`src/main/main.ts`)
- Renderer process (`src/renderer/App.tsx`)
- State management (`src/main/store/create.ts`)
- AI agent logic (`src/main/store/runAgent.ts`)
3. Reviewed existing features:
- Direct computer control by Claude 3.5 Sonnet
- Real-time execution of AI-generated commands
- Simple Electron-based user interface
- Support for MacOS (with theoretical support for Windows and Linux)
- Primary display interaction
- Emergency stop functionality
4. Identified areas for enhancement as per the project plan:
- Persistent settings
- System prompt configuration
- Enhanced logging with images
- Plugin system
- Window state persistence
- Session management
- Configurable tools system
5. Next steps:
- Begin implementation of persistent settings
- Set up development environment for new features
- Create a more detailed roadmap for feature implementation

## Iteration 2: Persistent Settings Implementation

1. Installed `electron-store` library for efficient local storage
2. Created `src/main/settings.ts` to manage application settings
3. Modified `src/main/store/create.ts` to use persistent settings
4. Updated `src/renderer/App.tsx` to utilize persistent settings
5. Implemented saving and loading of `instructions` and `fullyAuto` settings
6. Next steps:
- Test the persistent settings functionality
- Move on to the next enhancement: System Prompt Configuration

## Iteration 3: System Prompt Configuration

1. Updated `src/main/store/types.ts` to include systemPrompt in AppState
2. Modified `src/main/settings.ts` to handle systemPrompt persistence
3. Updated `src/main/store/create.ts` to include systemPrompt in the store
4. Created new `src/renderer/SystemPrompt.tsx` component for editing system prompts
5. Updated `src/renderer/App.tsx` to include the SystemPrompt component as a tab
6. Implemented a resizable textarea for editing the system prompt
7. Added a "Apply Default Prompt" button to easily set a predefined system prompt
8. Modified `src/main/store/runAgent.ts` to incorporate systemPrompt in AI interactions
9. Tested the system prompt configuration functionality
10. Next steps:
- Move on to the next enhancement: Enhanced Logging with Images

## Iteration 4: Error Logging Enhancement

1. Updated `src/main/store/runAgent.ts` to import and use `electron-log`
2. Modified `promptForAction` function to log errors from the API call
3. Enhanced `runAgent` function to provide more detailed error messages to the user
4. Implemented error logging for both API calls and general execution errors
5. Added logging of the message stack sent to the API when errors occur
6. Included logging of the full conversation history when errors happen in the main loop
7. Corrected an oversight in the `promptForAction` function to ensure the correct return format is maintained
8. Next steps:
- Test the error logging functionality
- Investigate and fix the issue with images remaining in the message history
- Move on to the next enhancement: Enhanced Logging with Images

## Iteration 5: Enhanced Logging with Images

1. Updated `src/renderer/RunHistory.tsx` to display screenshots sent to the LLM API
2. Modified the component to handle both assistant messages and user messages containing images
3. Implemented image rendering using base64-encoded data
4. Ensured proper scrolling behavior for the run history
5. Tested the image display functionality
6. Next steps:
- Test the enhanced logging with images feature
- Move on to the next enhancement: Plugin System

## Iteration 6: User Feedback and Continuous Input System

1. Designed the continuous input data structure
2. Updated `src/main/store/types.ts` to include new types for user input
3. Modified `src/main/store/create.ts` to handle continuous user input in the store
4. Created a new `ContinuousInput` component in `src/renderer/ContinuousInput.tsx`
5. Updated `src/renderer/App.tsx` to include the new ContinuousInput component
6. Modified `src/main/store/runAgent.ts` to check for and incorporate new user inputs
7. Implemented the mechanism to add new user inputs to the message stack
8. Integrated the new input system with the existing run history
9. Fixed issues related to incorrect message roles and API compatibility:
- Updated `runAgent` function to filter out 'tool' role messages before sending to API
- Ensured tool use and results are included as part of 'assistant' messages
- Updated `AppMessage` type to only allow 'user' and 'assistant' roles
10. Corrected the return format in the `promptForAction` function to match expected `BetaMessageParam` type
11. Enhanced error handling and logging throughout the application
12. Next steps:
- Conduct thorough testing of the continuous input functionality
- Ensure the AI can properly respond to and incorporate new instructions
- Refine error handling and user feedback mechanisms
- Move on to the next enhancement: Plugin System

## Iteration 7: Refinement and Testing

1. Conduct comprehensive testing of all implemented features:
- Persistent settings
- System prompt configuration
- Enhanced logging with images
- Continuous input system
2. Identify and fix any remaining bugs or issues
3. Optimize performance and user experience
4. Update documentation to reflect recent changes and new features
5. Next steps:
- Complete testing and refinement phase
- Prepare for the implementation of the Plugin System
- Review and update project roadmap based on progress and any new requirements

## Iteration 8: Window State and Instructions Box Persistence

1. Implemented window state (size, position) persistence using electron-store
2. Added instructions box height persistence using localStorage
3. Updated `src/main/main.ts` to handle window state saving and restoring
4. Modified `src/renderer/App.tsx` to manage instructions box height persistence
5. Resolved issues with store access in the main process
6. Tested window state persistence across multiple sessions
7. Verified instructions box height persistence
8. Next steps:
- Address any remaining issues or inconsistencies
- Move on to the next planned enhancement: Plugin System

## Iteration 9: Instructions Input Box Expansion

1. Modified `src/renderer/App.tsx` to make the instructions input box expand to 100% flex height
2. Updated the textarea component to use `flex: 1` instead of a fixed height
3. Removed manual resizing functionality for the instructions box
4. Adjusted the layout to accommodate the expanded instructions box
5. Next steps:
- Test the expanded instructions input box functionality
- Ensure proper layout and scrolling behavior with the new design
- Address any potential conflicts with other components (e.g., run history, error messages)
- Continue with the implementation of the Plugin System

## Iteration 10: Plugin System Implementation

1. Created `src/main/pluginManager.ts` to handle plugin loading and management
2. Implemented plugin loading functionality in the main process
3. Added IPC handlers in `src/main/main.ts` for plugin-related operations
4. Created `src/renderer/Plugins.tsx` component for displaying and managing plugins
5. Updated `src/renderer/App.tsx` to include the new Plugins component as a tab
6. Implemented plugin installation functionality
7. Added ability to load and display installed plugins
8. Resolved issue with duplicate plugin display after app restart:
- Updated `pluginManager.ts` to clear existing plugins before loading
- Simplified `Plugins.tsx` to directly use the plugin list from the main process
9. Tested plugin loading, installation, and display functionality
10. Next steps:
- Implement plugin execution functionality
- Add ability to enable/disable plugins
- Create a more robust plugin API for developers
- Enhance error handling and user feedback for plugin operations
- Consider adding a plugin marketplace or repository feature
- Continue testing and refining the Plugin System

## Iteration 11: Service Registry Implementation

1. Created `src/main/serviceRegistry.ts` to manage and provide access to various services
2. Implemented `ServiceRegistry` class with methods to register, get, and retrieve all services
3. Updated `src/main/main.ts` to use the new service registry:
- Registered computerVision and anthropic services
- Added logging for registered services
- Implemented an IPC handler to get services from the renderer process
4. Modified `src/main/store/anthropic.ts` to register itself with the service registry
5. Updated type definitions in `serviceRegistry.ts` to include `AnthropicService`
6. Removed manual registration of anthropic service from `main.ts`
7. Tested service registration and logging functionality
8. Next steps:
- Ensure all services are properly registered and accessible
- Implement usage of registered services throughout the application
- Consider adding more services to the registry as needed
- Update renderer process to utilize the new service registry system
- Continue refining and testing the service registry implementation
- Move on to the next planned enhancement or address any remaining issues
91 changes: 91 additions & 0 deletions .cursor/errors_resolutions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Errors and Resolutions

**Top Mistakes to Avoid:**

1. **Always maintain the correct return format in API response handling:** Ensure that the `promptForAction` function always returns an object with `content` and `role` properties, matching the expected `BetaMessageParam` type.
2. **Use only allowed message roles:** When working with the Anthropic API, ensure that only 'user' and 'assistant' roles are used in the conversation history.
3. **Be cautious of plugin loading and display logic:** Ensure that plugins are loaded only once and displayed correctly in the UI.

# Error # 1...

# Error # 2: Incorrect Return Format in promptForAction

**Error Description:**
The `promptForAction` function was inadvertently modified to return the raw API response instead of the expected `BetaMessageParam` format.

**Resolution:**
Restored the correct return statement in the `promptForAction` function:
```typescript
return { content: message.content, role: message.role };
```

**Lessons Learned:**
- Always double-check the return types and formats when modifying functions, especially those interfacing with external APIs.
- Maintain consistency with the defined types and interfaces throughout the codebase.
- When making changes, ensure that all parts of the function, including the return statement, are updated accordingly.

# Error # 3: Unexpected 'tool' Role in Message History

**Error Description:**
The Anthropic API returned an error stating "Unexpected role 'tool'. Allowed roles are 'user' or 'assistant'." This occurred because the conversation history included messages with a 'tool' role, which is not supported by the current version of the API.

**Resolution:**
1. Updated the `runAgent` function to filter out any messages with 'tool' role before sending to `promptForAction`:
```typescript
const filteredHistory = getState().runHistory.filter(msg => msg.role === 'user' || msg.role === 'assistant');
const message = await promptForAction(filteredHistory, getState().systemPrompt);
```
2. Ensured that tool use and tool results are included as part of 'assistant' messages in the conversation history.
3. Updated the `AppMessage` type in `types.ts` to only allow 'user' and 'assistant' roles:
```typescript
export type AppMessage = {
role: 'user' | 'assistant';
content: string | BetaMessageParam['content'];
};
```

**Lessons Learned:**
- Stay up-to-date with API documentation and requirements, as they may change over time.
- Implement proper type checking and validation to ensure that only allowed message roles are used in the conversation history.
- When working with external APIs, always validate the data structure before sending requests to avoid unexpected errors.

# Error # 4: Duplicate Plugin Display in UI

**Error Description:**
After restarting the application, installed plugins were being displayed twice in the UI, despite only being installed once.

**Resolution:**
1. Updated the `pluginManager.ts` file to clear existing plugins before loading:
```typescript
loadPlugins() {
console.log(`Attempting to load plugins from: ${this.pluginsDir}`);
this.plugins = []; // Clear existing plugins before loading
// ... rest of the loading logic
}
```
2. Simplified the `Plugins.tsx` component to directly use the plugin list received from the main process:
```typescript
export function Plugins() {
const [plugins, setPlugins] = useState<Plugin[]>([]);

useEffect(() => {
const removeListener = window.electron.ipcRenderer.on('get-plugins-response', (installedPlugins) => {
setPlugins(installedPlugins as Plugin[]);
});

window.electron.ipcRenderer.sendMessage('get-plugins');

return () => {
removeListener();
};
}, []);

// ... rest of the component
}
```

**Lessons Learned:**
- Be cautious of state management in both the main process and renderer process, especially when dealing with persistent data like plugins.
- Implement clear loading and resetting mechanisms for data that persists across app restarts.
- Use console logging strategically to track the flow of data and identify points of duplication or unexpected behavior.
- Always test the application's behavior after a restart to catch issues related to persistent data or state management.
13 changes: 13 additions & 0 deletions .cursor/instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Begin building out the project defined in @plan.md
# Every iteration, be sure to update the @current_status.md document to capture our place in the development cycle
# When errors are encountered, document them and their resolution in @errors_resolutions.md if multiple attempts to fix take place, be sure to collect all attempts, the new reasoning, and ultimately the final resolution.

# NOTE: pay close attention to directory structure, @plan.md is located in the project root. Any bootstrapping that takes place should understand where root is, and where any client / serverside applications are.

# IMPORTANT: record achievements in @current_status.md
# IMPORTANT: @current_status.md is append only
# IMPORTANT: @errors_resolutions.md is append only
# IMPORTANT: @plan.md is read only
# IMPORTANT: @instructions.md is read only

# IMPORTANT: every iteration we should be able to run our application and have it work based on the stage of the project. Deliver Value every iteration.
Loading