Skip to content

#1 - Implement Cody Custom Management #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Jun 9, 2024

Conversation

mnismt
Copy link
Owner

@mnismt mnismt commented Jun 8, 2024

What happened 👀

This PR aims to create a better UI for writing prompts with Cody's configuration properties (mode, context, etc). The main changes include:

  • Added functionality to add, edit, and remove custom commands from the workspace settings.
  • Create a webview provider and UI using React.
  • Implemented a custom command creation form and message handling in the webview.
  • Added various utility functions and constants to support the new features.
  • Updated build and packaging scripts for better optimization.

Insight 📝

The rationale behind these changes is to provide a more user-friendly interface for managing custom commands within the Cody++ extension. By allowing users to add, edit, and remove commands directly from the UI, we enhance the usability and flexibility of the extension.

The improved webview configuration and UI options ensure a smoother and more intuitive user experience.

Proof Of Work 📹

Add a command

add-a-comand.-.01.mp4

Edit a command

edit-a-command.-.01.mp4

Remove a command

remove-a-command.-.01.mp4

mnismt added 25 commits May 25, 2024 22:03
- Update the `cody.chat.preInstruction` setting to provide more detailed information about the Cody++ extension
- Enable the `cody.experimental.commitMessage` setting to generate AI-assisted commit messages
- Introduce a `CustomCommandService` to manage custom commands
- Add support for loading, saving, adding, modifying, and removing custom commands
- Integrate the custom commands feature into the Cody++ extension's UI
- Leverage the `zod` library for schema validation of custom command data
- Add a new constant `CODY_CUSTOM_COMMANDS_FILE` to store the filename for custom Cody commands
- Introduce the `CustomCommandsTreeView` class to display a tree view of the user's custom commands
- Leverage the `CustomCommandService` to fetch and manage the custom commands
- Render each custom command as a tree item with the command ID and description
- Implement the `getTreeItem` and `getChildren` methods to populate the tree view
- Add a `refresh` method to trigger updates to the tree view when the custom commands change
- Add a new command `cody-plus-plus.addCustomCommand` to allow users to add new custom commands
- Implement the command handler to open a UI for configuring the new custom command
- Register the new command in the package.json file and add it to the "Cody++" command category
- Add a new menu item in the "view/title" section to display the "Add New" command in the Custom Commands view
- Introduce the `CustomCommandsTreeView` class to display the user's custom commands in a tree view
- Register the `CustomCommandsTreeView` as a tree data provider for the "customCommands" view
- Add a new task "tasks: watch-webviews" to the .vscode/tasks.json file
- The new task runs the "watch:webviews" script from the package.json file, which watches the src/webviews directory and rebuilds the webviews on changes
- This allows developers to more easily work on and test the webview components of the extension
- Update tsconfig.json to exclude the "src/webviews" directory from the TypeScript compilation
- Update .vscode/settings.json to include the "out" folder in the search exclude list
- Add a new file `src/constants/webview.ts` with a constant `DEV_WEBVIEW_URL` set to `'http://localhost:5173'`
- Add a new file `src/utils/index.ts` with a `getNonce()` function that generates a random string of 32 characters
- Add a new file `src/commands/addCustomCommand.ts` with a function to open the custom command webview
- Update `src/extension.ts` to register the `cody-plus-plus.addCustomCommand` command and call the `addCustomCommand` function
- Add a new file `src/views/CustomCommandsWebview.ts` to implement the custom command webview, including logic to create and show the webview panel
- Add the `eslint-plugin-prettier` and `eslint-config-prettier` packages to the project
- Update the `.eslintrc.cjs` file to include the `prettier` plugin and the `@typescript-eslint/no-explicit-any` rule
- Add a `.prettierrc` file with the project's Prettier configuration
- Add `CustomCommandId` and `CreateCommandSchema` types to `customCommand.service.ts`
- Update `CustomCommandsSchema` to use `CustomCommandId` type
- Update `CustomCommandsTreeView` to use `CustomCommandsSchema` type for `commands` property
- Add a new form in the `App.tsx` component to allow users to create a new custom command
- Implement the `handleSubmit` function to collect the form data and send a message to the extension via the `vscodeApi` module
- Add the `vscodeApi` module to provide a wrapper around the VS Code API for sending messages and managing state
- Update the `index.css` file to style the new custom command creation form
- Add `_handleMessage` method to handle incoming messages from the webview
- Implement `_createCommand` method to handle the `CREATE_COMMAND` message, parse the command data, and add the command using the `CustomCommandService`
- Update the webview HTML to include the `nonce` and `vscodeApi` setup
- Add error handling to the `_createCommand` method to display errors to the user
- Add a new COMMANDS object with a CREATE_COMMAND property to the webview.ts file
- Add `codyPlusPlus.editCommand` and `codyPlusPlus.deleteCommand` commands to the `package.json` file
- Implement the `editCommandDisposable` and `deleteCommandDisposable` in the `extension.ts` file to handle the edit and delete functionality
- Update the `CustomCommandsTreeView` to set the `contextValue` property for each tree item to `'customCommand'`, enabling the context menu items
- Add the new disposables to the `context.subscriptions.push` call in the `activate` function
- Add `codyPlusPlus.editCommand` and `codyPlusPlus.deleteCommand` commands to the `package.json` file
- Implement the `editCommandDisposable` and `deleteCommandDisposable` in the `extension.ts` file to handle the edit and delete functionality
- Update the `CustomCommandsTreeView` to set the `contextValue` property for each tree item to `'customCommand'`, enabling the context menu items
- Add the new disposables to the `context.subscriptions.push` call in the `activate` function
…om command"

- Update the header text in the App.tsx file to be more specific about creating a new Cody custom command
- Add new CSS styles for the select element in the index.css file to match the styling of other form elements
- Add `codyPlusPlus.editCommand` and `codyPlusPlus.deleteCommand` commands to the `package.json` file
- Implement the `editCommandDisposable` and `deleteCommandDisposable` in the `extension.ts` file to handle the edit and delete functionality
- Update the `CustomCommandsTreeView` to set the `contextValue` property for each tree item to `'customCommand'`, enabling the context menu items
- Add the new disposables to the `context.subscriptions.push` call in the `activate` function
@mnismt mnismt added the feature New feature or request label Jun 8, 2024
@mnismt mnismt added this to the v0.1.0 milestone Jun 8, 2024
@mnismt mnismt self-assigned this Jun 8, 2024
mnismt added 2 commits June 9, 2024 00:44
- Add `codyPlusPlus.editCommand` and `codyPlusPlus.deleteCommand` commands to the `package.json` file
- Implement the `editCommandDisposable` and `deleteCommandDisposable` in the `extension.ts` file to handle the edit and delete functionality
- Update the `CustomCommandsTreeView` to set the `contextValue` property for each tree item to `'customCommand'`, enabling the context menu items
- Add the new disposables to the `context.subscriptions.push` call in the `activate` function
- Add `retainContextWhenHidden`, `enableFindWidget`, and `enableCommandUris` options to the webview configuration
- Set the webview panel icon to a custom icon
- Reorganize the context section in the UI, moving the "Codebase" option to the bottom and adding a warning about its experimental nature
- Remove the `vscode:prepublish` script as it is redundant with the `package` script
- Simplify the `vscode:package` script to directly call the `package` script and the `vsce package` command
- Update the `build:webviews` script to first remove the `dist/webviews` directory before rebuilding the webviews assets
@mnismt mnismt merged commit 5ba9b12 into main Jun 9, 2024
@mnismt mnismt changed the title Cody Custom Managements #1 - Implement Cody Custom Management Jun 9, 2024
@mnismt mnismt mentioned this pull request Jun 9, 2024
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant