# codepilot **Repository Path**: mirrors/codepilot ## Basic Information - **Project Name**: codepilot - **Description**: Codepilot 是一款为软件开发者制定的代码搜索工具 - **Primary Language**: JavaScript - **License**: MIT - **Default Branch**: master - **Homepage**: https://www.oschina.net/p/codepilot - **GVP Project**: No ## Statistics - **Stars**: 6 - **Forks**: 0 - **Created**: 2021-03-29 - **Last Updated**: 2025-09-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # *** NOTICE: Looking for help addressing vulnerabilities due to outdated packages # CodePilot.ai This and others READMEs in the repo serve as living documents and the source of truth for our development practices. * [Design](src/renderer/design.md) * [Split Testing](src/split-tests/README.md) * [Unit Testing](test/unit/README.md) * [End to End testing](test/e2e/README.md) * [Services](src/services/README.md) * [Search](src/search/README.md) * [State](src/renderer/state/README.md) * [Renderer](src/renderer/README.md) ## Build Setup ``` bash # Install dependencies # If you don't have yarn installed: `npm install --global yarn` yarn install # Launch and serve with live reload at localhost:9080 yarn dev ```` ## Build application | Command | Analytics | Stripe | NODE_ENV | PROJECT_PHASE | | --------------------- | ---------- | ---------- | ----------- | ------------- | | yarn dev | test | test | development | | yarn build | test | test | production | | yarn build:staging | test | test | production | staging | | yarn build:production | production | production | production | production | ``` # Run unit tests yarn test:unit # Run end-to-end tests yarn test:e2e # Lint all JS/Vue component files in `src/` yarn lint ``` ## Production Configuration To configure this app for production, add production keys for all services in `services.config.js`. ## Development ### Commits #### Format Describe the change you made. If someone on a different development team (i.e. not familiar with our app) read your commit history, they should at least have a vague idea of what you did. To make describing your changes easier, more frequent, smaller commits are generally better. These can be made any time you know (or at least think you know 😉) the app works and all tests pass, even if a feature isn't completely finished. For example: 1. add hotkey button to welcome page 2. make input pop up when hotkey button clicked 3. update hotkey input to collect user-defined hotkey when in focus 4. sync hotkey input to vuex state 5. save hotkey vuex state in electron settings Note that no one does this perfectly. Those are the commits I wish I had made, rather than the commits I really made. 😅 At the very least though, it's good to avoid including more than one feature in a single commit, unless they're tightly coupled. A few other notes: - Capitalization does *not* matter in commits - do whatever you're comfortable with. - Commits should generally be kept to a single sentence, but it can be a long sentence if you want. It's OK if you go over the limit for a commit title and spill into Git's commit description field. #### Imperative vs past tense Some people have strong opinions about whether to use the imperative (e.g. `add`, `fix`) or past tense (e.g. `added`, `fixed`). I (Chris) personally don't care, since both are easily understandable when browsing commit history. #### Referencing issues/PRs If a commit closes an open issue, add `, fixes #123` to the end of a commit, `123` being the GitHub id of the issue. You can also use `, replaces #123` to reference pull requests we'll be closing. ### Features To ensure frequent communication, all features will be done in feature branches (we can even disable pushing to `master`). Here's a good process for starting a new feature: #### Start a new feature ``` sh git fetch origin # Make sure your local origin is up-to-date git checkout master # Move to the master branch git reset --hard origin/master # Ensure your local master matches GitHub's git checkout -b my-feature-branch # Check out your feature branch ``` #### Rebase frequently As you develop, it's a good idea to **rebase after every commit** to address conflicts as soon as they arise: ``` sh git fetch origin # Make sure your local origin is up-to-date git checkout my-feature-branch # If you're not already there git rebase origin/master # Rebase against GitHub's master branch ``` #### Resolve rebase conflicts **If you encounter conflicts**, you'll see `CONFLICT` in the output of the last command for each conflicting file. At the end, you'll also see: ``` When you have resolved this problem, run "git rebase --continue". If you prefer to skip this patch, run "git rebase --skip" instead. To check out the original branch and stop rebasing, run "git rebase --abort". ``` If you run `git status` at this point, you'll see a list of the conflicting files listed under "Unmerged paths". Each file in this list will contain one or more blocks of code that look similar to this: ``` <<<<<<< HEAD:src/renderer/app.vue font-size: 1.3em; ======= font-size: 1.5em; <<<<<<< master ``` What it's saying above is that _someone else_ changed the same section of code that you did. Now you have to decide which of your changes to keep, or to combine them. In this case, let's say you want to keep the change from master. You'd change the code above to: ``` font-size: 1.5em; ``` > NOTE: Do **NOT** try to manually resolve conflicts in `yarn.lock`. Instead, it's best to delete the file (`rm yarn.lock`) and regenerate it (`yarn install`). When you've resolved all conflicts, you can `git add` the file (in the example above, `git add src/renderer/app.vue`). And when _all_ conflicting files are added and resolved, you can run `git rebase --continue`. > Note that **you probably shouldn't ever need to run `git rebase --skip`**, because it assumes that master can just overwrite anything you did, which generally isn't safe. It's sort of like Googling with the "I'm feeling lucky" button - you don't really know where you'll end up. 😄 If you make a mistake in the middle of a rebase, you can `git rebase --abort` and try again. > If you're using VS Code, might want to check out [this overview](https://www.youtube.com/watch?v=AKNYgP0yEOY) of its Git integration, as it can help make complicated tasks like resolving conflicts easier. #### Check your work When you're ready to submit your work in a PR, first rebase one more time and review your changes with: ``` sh git fetch origin # Make sure your local origin is up-to-date git checkout my-feature-branch # If you're not already there git diff origin/master # List differences between your branch and master ``` This will give you a chance to catch and clean up any accidental changes, leftover debugging code (e.g. `console.log`), etc. It's essentially giving _yourself_ a code review before someone else does and is a nice courtesy. 🙂 #### Push to your branch ``` sh git push origin my-feature-branch --force # The --force will be necessary if you've rebased since your last push ``` And open a pull request on GitHub. Before merging into master, each feature must be reviewed by at least one other team member. ### PR Updates If you're reviewing a PR and want to make some updates yourself before merging, make sure: 1. You communicate with whoever owns the PR and receive their explicit consent before making changes. Otherwise, they might also make changes and accidentally overwrite your work. 2. This isn't a change the owner of the PR could be guided to make themselves and would learn from. On a team with remote members, PRs are a great opportunity to share expertise, but "just taking over" will lead to siloed knowledge and slower development in the long run. ### PR Merging GitHub has several ways for us to merge PRs: - **Rebase & merge**: Preferred for most PRs, with meaningful commits that tell a story and always have the app in a working condition. - **Squash & merge**: Preferred for bugfix PRs, which will often only have one commit, or multiple meaningless commits, such as: `fix bug, fixes #123`, `ok, really fixed bug now`, `bug even fixed on windows`, etc. Also preferred for PRs that have gone through a lot of iteration/troubleshooting, where the app is not always in a working condition. ### Troubleshooting If you've been working on the same problem, without success, for more than an hour, reach out for help immediately (even someone who might know less about the problem than you do). It's amazing how much another pair of eyes can help, as well as the opportunity to explain and answer questions on what you're working on. ## Folder Architecture - `.electron-vue`: Contains the dev server and build config, which should rarely need to be modified. Changes to these files should be made with caution, since they greatly affect everyone's dev experience. - `build`: Includes assets used during build. - `src`: Manually edited files should be in here 99% of the time. Any files that go through the build system will be in here. - `split-tests`: Where we initialize A/B tests. These randomly chosen value for each test is automatically added a property for all telemetry. - `main`: Electron-specific code, where our app is initialized and the main window is created. - `renderer`: Mostly Vue-specific code to render the frontend. - `assets`: This is where we'll put any images, fonts, or other non-code files that we reference in our JavaScript or Vue components. - `components`: Where all of our components live, except the special `app.vue` root component. - `directives`: Where all our custom directives live. Any `.js` files in this directory are automatically required by `src/renderer/main.js` to facilitate global registration. - `state`: Where we manage all our global state management for the application. - `search`: Where our search functions live. - `services`: Computationally expensive services that we run in a separate thread, via forked processes. This prevents the operation from blocking the main thread and causing the app to feel slow/laggy. - `static`: Will include any assets you want to bypass the build process. For example, a `favicon.ico` file will often go here in a typical web application. - `test`: Contains the configuration for our testing setup. Unit tests are stored next to the files that are being tested. ## Filenames One note about files: always use kebab-case in filenames, unless the file requires otherwise or is documentation (GitHub treats `README.md` files differently than other files). Using any uppercase letters can cause issues with Git on case-insensitive filesystems. ``` sh # Bad MyComponent.vue myComponent.vue Main.js MAIN.js # Good my-component.vue main.js ``` ## HTML All HTML will exist within Vue components, either: - in the `