diff --git a/.oneuptime/README.md b/.oneuptime/README.md new file mode 100644 index 0000000000..c63dc37e2d --- /dev/null +++ b/.oneuptime/README.md @@ -0,0 +1,15 @@ +## OneUptime Copilot + +This folder contains the configuration files for the OneUptime Copilot. The Copilot is a tool that automatically improves your code. It can fix issues, improve code quality, and help you ship faster. + +This folder has the following structure: + +- `config.js`: The configuration file for the Copilot. You can customize the Copilot's behavior by changing this file. +- `scripts`: A folder containing scripts that the Copilot runs. These are hooks that run at different stages of the Copilot's process. + - `on-after-clone.sh`: A script that runs after the Copilot clones your repository. + - `on-before-code-change.sh`: A script that runs before the Copilot makes changes to your code. + - `on-after-code-change.sh`: A script that runs after the Copilot makes changes to your code. + - `on-before-commit.sh`: A script that runs before the Copilot commits changes to your repository. + - `on-after-commit.sh`: A script that runs after the Copilot commits changes to your repository. + + \ No newline at end of file diff --git a/.oneuptime/config.js b/.oneuptime/config.js new file mode 100644 index 0000000000..6edf0995bb --- /dev/null +++ b/.oneuptime/config.js @@ -0,0 +1,10 @@ +// This is the configuration file for the oneuptime copilot. + +const getCopilotConfig = () => { + return { + // The version of the schema for this configuration file. + schemaVersion: '1.0', + } +} + +export default getCopilotConfig; \ No newline at end of file diff --git a/.oneuptime/config.json b/.oneuptime/config.json deleted file mode 100644 index 544b7b4ddd..0000000000 --- a/.oneuptime/config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - -} \ No newline at end of file diff --git a/.oneuptime/scripts/on-after-clone.sh b/.oneuptime/scripts/on-after-clone.sh index b133bb2328..e944589249 100644 --- a/.oneuptime/scripts/on-after-clone.sh +++ b/.oneuptime/scripts/on-after-clone.sh @@ -1,2 +1,16 @@ +# Description: Copilot clones your repository and to improve your code. +# This scirpt runs after the clone process is completed. +# Some of the common tasks you can do here are: +# 1. Install dependencies +# 2. Run linting +# 3. Run tests +# 4. Run build +# 5. Run any other command that you want to run after the clone process is completed. +# If this script fails, copilot will not proceed with the next steps to improve your code. +# This step is to ensure that the code is in a good state before we start improving it. +# If you want to skip this script, you can keep this file empty. +# It's highly recommended to run linting and tests in this script to ensure the code is in a good state. +# This scirpt will run on ubuntu machine. So, make sure the commands you run are compatible with ubuntu. + npm install npm run lint \ No newline at end of file diff --git a/.oneuptime/scripts/on-after-code-change.sh b/.oneuptime/scripts/on-after-code-change.sh new file mode 100644 index 0000000000..32e520b478 --- /dev/null +++ b/.oneuptime/scripts/on-after-code-change.sh @@ -0,0 +1,13 @@ +# Description: Copilot will run this script after we make improvements to your code and write it to disk. +# Some of the common tasks you can do here are: +# 1. Run linting +# 2. Run tests +# 3. Run build +# 4. Run any other command that you want to run after the code is changed. +# If this script fails, copilot will not commit the changes to your repository. +# This step is to ensure that the code is in a good state before we commit the changes. +# If you want to skip this script, you can keep this file empty. +# It's highly recommended to run linting and tests in this script to ensure the code is in a good state. +# This scirpt will run on ubuntu machine. So, make sure the commands you run are compatible with ubuntu. + +npm run fix \ No newline at end of file diff --git a/.oneuptime/scripts/on-after-commit.sh b/.oneuptime/scripts/on-after-commit.sh index 8b13789179..781bf0800b 100644 --- a/.oneuptime/scripts/on-after-commit.sh +++ b/.oneuptime/scripts/on-after-commit.sh @@ -1 +1 @@ - +# Description: Copilot will run this script after the commit process is completed. \ No newline at end of file diff --git a/.oneuptime/scripts/on-after-copilot-action.sh b/.oneuptime/scripts/on-after-copilot-action.sh deleted file mode 100644 index b4481140d7..0000000000 --- a/.oneuptime/scripts/on-after-copilot-action.sh +++ /dev/null @@ -1 +0,0 @@ -npm run fix \ No newline at end of file diff --git a/.oneuptime/scripts/on-before-code-change.sh b/.oneuptime/scripts/on-before-code-change.sh new file mode 100644 index 0000000000..e40bb0bc24 --- /dev/null +++ b/.oneuptime/scripts/on-before-code-change.sh @@ -0,0 +1,9 @@ +# Description: Copilot will run this script before we make changes to your code. +# Some of the common tasks you can do here are: +# 1. Install dependencies +# 2. Run any other command that you want to run before the code is changed. +# If this script fails, copilot will not make any changes to the code. +# This step is to ensure that the code is in a good state before we start making changes. +# If you want to skip this script, you can keep this file empty. +# It's highly recommended to run things like installing dependencies in this script. +# This scirpt will run on ubuntu machine. So, make sure the commands you run are compatible with ubuntu. \ No newline at end of file diff --git a/.oneuptime/scripts/on-before-commit.sh b/.oneuptime/scripts/on-before-commit.sh index e69de29bb2..903e8d4822 100644 --- a/.oneuptime/scripts/on-before-commit.sh +++ b/.oneuptime/scripts/on-before-commit.sh @@ -0,0 +1 @@ +# Description: Copilot will run this script before we commit the changes to your repository. \ No newline at end of file diff --git a/.oneuptime/scripts/on-before-copilot-action.sh b/.oneuptime/scripts/on-before-copilot-action.sh deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/.oneuptime/services/App/config.json b/.oneuptime/services/App/config.json deleted file mode 100644 index 544b7b4ddd..0000000000 --- a/.oneuptime/services/App/config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - -} \ No newline at end of file diff --git a/Copilot/Service/CopilotActions/CopilotActionsBase.ts b/Copilot/Service/CopilotActions/CopilotActionsBase.ts index 3fe8de1624..e08a32b3a3 100644 --- a/Copilot/Service/CopilotActions/CopilotActionsBase.ts +++ b/Copilot/Service/CopilotActions/CopilotActionsBase.ts @@ -143,7 +143,7 @@ If you have any feedback or suggestions, please let us know. We would love to h const onBeforeExecuteActionScript: string | null = await CodeRepositoryUtil.getRepoScript({ - scriptType: RepoScriptType.OnBeforeCopilotAction, + scriptType: RepoScriptType.OnBeforeCodeChange, }); if (!onBeforeExecuteActionScript) { @@ -192,7 +192,7 @@ If you have any feedback or suggestions, please let us know. We would love to h const onAfterExecuteActionScript: string | null = await CodeRepositoryUtil.getRepoScript({ - scriptType: RepoScriptType.OnAfterCopilotAction, + scriptType: RepoScriptType.OnAfterCodeChange, }); if (!onAfterExecuteActionScript) { diff --git a/Copilot/Templates/.oneuptime/README.md b/Copilot/Templates/.oneuptime/README.md new file mode 100644 index 0000000000..c63dc37e2d --- /dev/null +++ b/Copilot/Templates/.oneuptime/README.md @@ -0,0 +1,15 @@ +## OneUptime Copilot + +This folder contains the configuration files for the OneUptime Copilot. The Copilot is a tool that automatically improves your code. It can fix issues, improve code quality, and help you ship faster. + +This folder has the following structure: + +- `config.js`: The configuration file for the Copilot. You can customize the Copilot's behavior by changing this file. +- `scripts`: A folder containing scripts that the Copilot runs. These are hooks that run at different stages of the Copilot's process. + - `on-after-clone.sh`: A script that runs after the Copilot clones your repository. + - `on-before-code-change.sh`: A script that runs before the Copilot makes changes to your code. + - `on-after-code-change.sh`: A script that runs after the Copilot makes changes to your code. + - `on-before-commit.sh`: A script that runs before the Copilot commits changes to your repository. + - `on-after-commit.sh`: A script that runs after the Copilot commits changes to your repository. + + \ No newline at end of file diff --git a/Copilot/Templates/.oneuptime/config.js b/Copilot/Templates/.oneuptime/config.js new file mode 100644 index 0000000000..6edf0995bb --- /dev/null +++ b/Copilot/Templates/.oneuptime/config.js @@ -0,0 +1,10 @@ +// This is the configuration file for the oneuptime copilot. + +const getCopilotConfig = () => { + return { + // The version of the schema for this configuration file. + schemaVersion: '1.0', + } +} + +export default getCopilotConfig; \ No newline at end of file diff --git a/Copilot/Templates/.oneuptime/scripts/on-after-clone.sh b/Copilot/Templates/.oneuptime/scripts/on-after-clone.sh new file mode 100644 index 0000000000..f1fd614b74 --- /dev/null +++ b/Copilot/Templates/.oneuptime/scripts/on-after-clone.sh @@ -0,0 +1,13 @@ +# Description: Copilot clones your repository and to improve your code. +# This scirpt runs after the clone process is completed. +# Some of the common tasks you can do here are: +# 1. Install dependencies +# 2. Run linting +# 3. Run tests +# 4. Run build +# 5. Run any other command that you want to run after the clone process is completed. +# If this script fails, copilot will not proceed with the next steps to improve your code. +# This step is to ensure that the code is in a good state before we start improving it. +# If you want to skip this script, you can keep this file empty. +# It's highly recommended to run linting and tests in this script to ensure the code is in a good state. +# This scirpt will run on ubuntu machine. So, make sure the commands you run are compatible with ubuntu. diff --git a/Copilot/Templates/.oneuptime/scripts/on-after-code-change.sh b/Copilot/Templates/.oneuptime/scripts/on-after-code-change.sh new file mode 100644 index 0000000000..56701a59ad --- /dev/null +++ b/Copilot/Templates/.oneuptime/scripts/on-after-code-change.sh @@ -0,0 +1,11 @@ +# Description: Copilot will run this script after we make improvements to your code and write it to disk. +# Some of the common tasks you can do here are: +# 1. Run linting +# 2. Run tests +# 3. Run build +# 4. Run any other command that you want to run after the code is changed. +# If this script fails, copilot will not commit the changes to your repository. +# This step is to ensure that the code is in a good state before we commit the changes. +# If you want to skip this script, you can keep this file empty. +# It's highly recommended to run linting and tests in this script to ensure the code is in a good state. +# This scirpt will run on ubuntu machine. So, make sure the commands you run are compatible with ubuntu. diff --git a/Copilot/Templates/.oneuptime/scripts/on-after-commit.sh b/Copilot/Templates/.oneuptime/scripts/on-after-commit.sh new file mode 100644 index 0000000000..781bf0800b --- /dev/null +++ b/Copilot/Templates/.oneuptime/scripts/on-after-commit.sh @@ -0,0 +1 @@ +# Description: Copilot will run this script after the commit process is completed. \ No newline at end of file diff --git a/Copilot/Templates/.oneuptime/scripts/on-before-code-change.sh b/Copilot/Templates/.oneuptime/scripts/on-before-code-change.sh new file mode 100644 index 0000000000..e40bb0bc24 --- /dev/null +++ b/Copilot/Templates/.oneuptime/scripts/on-before-code-change.sh @@ -0,0 +1,9 @@ +# Description: Copilot will run this script before we make changes to your code. +# Some of the common tasks you can do here are: +# 1. Install dependencies +# 2. Run any other command that you want to run before the code is changed. +# If this script fails, copilot will not make any changes to the code. +# This step is to ensure that the code is in a good state before we start making changes. +# If you want to skip this script, you can keep this file empty. +# It's highly recommended to run things like installing dependencies in this script. +# This scirpt will run on ubuntu machine. So, make sure the commands you run are compatible with ubuntu. \ No newline at end of file diff --git a/Copilot/Templates/.oneuptime/scripts/on-before-commit.sh b/Copilot/Templates/.oneuptime/scripts/on-before-commit.sh new file mode 100644 index 0000000000..903e8d4822 --- /dev/null +++ b/Copilot/Templates/.oneuptime/scripts/on-before-commit.sh @@ -0,0 +1 @@ +# Description: Copilot will run this script before we commit the changes to your repository. \ No newline at end of file diff --git a/Copilot/Utils/CodeRepository.ts b/Copilot/Utils/CodeRepository.ts index 14ed03cf5c..b0c9d1564b 100644 --- a/Copilot/Utils/CodeRepository.ts +++ b/Copilot/Utils/CodeRepository.ts @@ -39,8 +39,8 @@ export enum RepoScriptType { OnAfterClone = "onAfterClone", OnBeforeCommit = "onBeforeCommit", OnAfterCommit = "OnAfterCommit", - OnBeforeCopilotAction = "onBeforeCopilotAction", - OnAfterCopilotAction = "onAfterCopilotAction", + OnBeforeCodeChange = "OnBeforeCodeChange", + OnAfterCodeChange = "OnAfterCodeChange", } export default class CodeRepositoryUtil {