Spike: Using Github Co-Pilot in GoTestPro

 

1.png

 

WHAT IS GITHUB CO-PILOT'S

 

image-20240611-144126.png

 

 

  • Cloud-based Generative AI tool

  • Turns Natural Language prompts into coding suggestions

  • Work across various programming languages

  • Trained on billons of line of code

  • Works on multiple IDEs

 

GITHUB CO-PILOT'S FEATURES

 

 

  1. Code Completion GitHub Copilot suggests code as you type. It provides context-aware completions, whether it's completing the current line or suggesting entire code blocks¹.

  2. Chat Interface You can ask Copilot for help with your code using the chat feature. Whether you need assistance solving a problem, understanding someone else's code, or fixing a bug, Copilot is there to assist

  3. Pull Request Summaries (Copilot Enterprise) In Copilot Enterprise, you can get Copilot to describe the changes in a pull request. This feature helps streamline code review and communication within teams

  4. Knowledge Bases (Copilot Enterprise) Copilot Enterprise allows you to create and manage collections of documentation. These knowledge bases provide context for chatting with Copilot, enhancing collaboration and problem-solving

 

WHAT CAN GITHUB CO-PILOT DO?

 

 

 

BENEFITS OF GITHUB CO-PILOT

 

 

 

FEATURES OF GITHUB CO-PILOT

 

  1. Plugin Integration in Your Favorite IDE:

    • GitHub Copilot seamlessly integrates with popular code editors and IDEs, enhancing your development environment.

    • You can access Copilot’s features directly within your preferred coding tools.

  2. Context-Aware Suggestions:

    • Copilot understands the context of your code and provides relevant suggestions.

    • Whether you’re writing a function, class, or method, Copilot tailors its recommendations to fit the situation.

  3. “Prompt Engineering” with Variable Name Completions:

    • Copilot assists in naming variables by suggesting meaningful names based on the surrounding code.

    • This feature streamlines the process of choosing descriptive identifiers.

  4. Comment-Based Prompting:

    • When you add comments to your code, Copilot interprets them as prompts.

    • It generates code snippets aligned with the comments, making your intentions clearer.

  5. Improved Suggestions via Function Names:

    • Copilot leverage’s function names to provide more accurate and relevant code completions.

    • Naming your functions thoughtfully enhances the quality of suggestions.

  6. Explaining Code:

    • Copilot Chat allows you to interact with Copilot using natural language.

    • You can ask for explanations, clarifications, or even discuss code-related concepts.

  7. Generating Code:

    • Copilot Chat assists in writing code snippets, whether it’s a simple function or a complex algorithm.

    • Describe what you need, and Copilot Chat will provide relevant code.

  8. Fixing Code:

    • Got a bug? Copilot Chat helps troubleshoot issues by suggesting fixes.

    • Describe the problem, and it will propose solutions.

  9. Generating Unit Test Cases:

    • Copilot can create unit tests for your code.

    • This feature promotes better code quality and reliability.

  10. Generating Commit Messages:

    • Copilot can even help you write descriptive commit messages.

    • It saves time and ensures your commits are informative.

 

FOR DEEP DIVING INTO GITHUB CO-PILOT

 

For more information about GitHub Copilot features, you can visit this link
Using GitHub Copilot in your IDE: Tips, tricks, and best practices

8 things you didn’t know you could do with GitHub Copilot

10 unexpected ways to use GitHub Copilot

 

HOW DOST GITHUB CO-PILOT WORK?

 

 

 

 

INSTALLATION GITHUB CO-PILOT IN YOUR FAVRIOUTE IDE

 

1. Prerequisites

  • GitHub Account: Ensure you have a GitHub account. You might need access to GitHub Copilot, which may require a subscription depending on your usage plan.

  • Visual Studio Code: GitHub Copilot is primarily designed to work with Visual Studio Code (VS Code). Ensure you have VS Code installed. You can download it from here.

2. Installation

Install Visual Studio Code

  1. Download and install VS Code from the official website.

  2. Launch VS Code after installation.

Install GitHub Copilot Extension

  1.  

Open VS Code:

  1. Launch Visual Studio Code on your computer.

  2.  

Go to Extensions View:

  1. Click on the Extensions icon in the Activity Bar on the side of the window or use the keyboard shortcut Ctrl+Shift+X (Windows/Linux) or Cmd+Shift+X (Mac).

  2.  

Search for GitHub Copilot:

  1. In the Extensions view, type GitHub Copilot in the search bar.

  2.  

Install the Extension:

  1. Find the GitHub Copilot extension and click the Install button.

3. Configuration

Sign In to GitHub

  1.  

Sign In Prompt:

  1. After installing the extension, you will be prompted to sign in to GitHub. Follow the on-screen instructions to sign in.

  2. You may need to authorize GitHub Copilot to access your GitHub account.

  3.  

Grant Permissions:

  1. Grant the necessary permissions for GitHub Copilot to access your repositories and other data.

4. Usage

Enable Copilot in Your Project

  1.  

Open Your Project:

  1. Open your project folder in VS Code.

  2.  

Start Coding:

  1. As you write code, GitHub Copilot will start suggesting code completions and snippets.

  2. You can accept suggestions by pressing Tab or Enter or reject them by continuing to type or pressing Esc.

  3.  

Using Natural Language Comments:

  1. Write comments in plain English to describe what you want to achieve, and Copilot will suggest code snippets to implement the described functionality.

 

 Q/A

 

 If I modify this variable, which other files would be affected.  ← this is not easily available about the project

GitHub Copilot doesn't automatically refactor variables across multiple files, it can greatly assist you in the process through suggestions and help you write scripts or other tools. For comprehensive refactoring, leveraging the built-in capabilities of your IDE is usually the most efficient approach.

If i migrate from java vX → java vY : what are the changes affected by changing infra.

GitHub Copilot won’t directly handle the migration process itself. It can assist with Java development tasks, including code suggestions, generation, and unit tests.

Can you ask copilot to create use docs for our APIS from our API project?


IF you change an API can it tell u impact on dependent clients in the project?
GitHub Copilot itself does not have the built-in capability to directly inform you of the impact on dependent clients within a project when an API changes.

Can you ask co-pilot to generate SDK java library as a client to the REST API?

 

GITHUB-COPILOT PRO’S AND CONS

Pros of GitHub Copilot

Cons of GitHub Copilot

Increased productivity: Speeds up the coding process, allowing focus on higher-level tasks.

Dependency risk: May diminish problem-solving skills.

Wide support: Versatile for various languages and frameworks.

Variable quality: Inconsistent relevance and optimization of suggestions.

Learning aid: Offers insights into new patterns and solutions.

Learning curve: Integration and effective use can be complex.

Improves Code Quality: Provides optimization feedback.

Privacy concerns: Risks of including sensitive or copyrighted code.

Boilerplate efficiency: Automates tedious coding.

Intellectual property concerns: Uncertainty around the ownership of AI-generated code.

Seamless IDE Integration: Works well with environments like VS Code.

Cost: Might be expensive for individuals or small teams.

Guide with best practices: Acts as an on-the-go mentor for syntax.

Context limits: May not fully understand project specifics.

Reduces errors: Minimizes common coding mistakes.

Error introduction: Suggestions might lead to errors if unchecked.

Helps small teams: Acts as a virtual team member.

Requires manual work: Needs thorough testing and validation.

 

The Dawn of AI-Assisted Coding: An Introduction to GitHub Copilot
GitHub Copilot: Unveiling the Pros, Cons, and Key Considerations
GitHub Copilot Pros and Cons

 

GITHUB-COPILOT CLI

 

GitHub Copilot in the CLI is an extension for GitHub CLI that provides a chat-like interface in the terminal. It allows you to ask questions about the command line. Here’s how you can use it:

 

 

 

Getting Command Explanations: To ask Copilot in the CLI to explain a command, run:

 

  gh copilot explain "sudo apt-get"

Getting Command Suggestions: To ask Copilot in the CLI to suggest a command, use:

  gh copilot suggest "Undo the last commit"

 

Learn about GitHub Copilot in the CLI, including use cases, best practices, and limitations.

 

UPCOMMING FEATURES OF GITHUB-COPILOT WORKSPACE 

GitHub Copilot Workspace is a new development environment built on top of GitHub Copilot, the AI code completion tool. It’s designed to be task-oriented, meaning it helps you with the entire development process for a specific task, not just suggesting code within the editor1. Whether you’re addressing an Issue, iterating on a PR, or bootstrapping a project, Copilot Workspace assists you by describing what you want in natural language. It captures your intent, proposes a plan of action, and uses that plan to implement the changes. 

Sourcegraph Cody

 

  • offers autocomplete, chat, and commands.

  • Allows users to personalize the AI using codebase context.

  • Users can choose which Large Language Model (LLM) they want to use.

  • Offers a standard free tier.

  • Supports IDEs like Visual Studio Code, JetBrains, and Visual Studio.

 

Cody Capabilities - Sourcegraph docs

 

Both tools have their strengths and are designed to cater to different needs and preferences. GitHub Copilot is deeply embedded in the GitHub ecosystem, making it a good choice for those who are already using GitHub extensively. On the other hand, Sourcegraph Cody offers more flexibility in terms of LLM selection and codebase personalization, which can be beneficial for users who work with code hosted outside of GitHub or prefer a free AI code assistant.


Codeium

 

Windsurf Editor and Codeium extensions


Codeium is a popular AI code completion and generation tool. It offers features like autocomplete suggestions, code explanations, and refactoring assistance.

Codeium and GitHub Copilot are both AI-powered code assistants, but they have some key differences:

  • Company:

    • Codeium is developed by Exafunction

    • GitHub Copilot is a product of GitHub, which is owned by Microsoft

  • Availability:

    • Codeium offers a free tier with unlimited use

    • GitHub Copilot is a paid service, though it offers free access for students and open source developers

  • IDE Support:

    • Both support a wide range of IDEs and editors

  • Features:

    • Both offer code completion and generation

    • Codeium also provides features like code explanations and refactoring suggestions

    • GitHub Copilot is known for its ability to generate entire functions based on comments

  • Specialization:

    • Codeium markets itself as a more general-purpose coding assistant

    • GitHub Copilot is often seen as particularly strong for generating boilerplate code

  • Integration:

    • GitHub Copilot naturally integrates well with GitHub's ecosystem

    • Codeium is designed to work across various platforms and version control systems

 

DEMO

https://www.youtube.com/watch?v=pGqUYwmfgv4&t=112s

 

CodiumAI

 

Codium is now Qodo | Quality-first AI Coding Platform

 

CodiumAI appears to be a distinct AI-powered code analysis and testing tool. It focuses on generating test cases and identifying potential bugs or issues in code.

  • Primary Focus:

    • CodiumAI appears to be primarily focused on code analysis and test generation.

    • GitHub Copilot is mainly a code completion and generation tool.

  • Functionality:

    • CodiumAI seems to specialize in generating test cases and identifying potential bugs or issues in existing code.

    • GitHub Copilot generates code suggestions and can complete entire functions based on comments or context.

  • Integration:

    • Information about CodiumAI's integration with different IDEs or platforms is limited in my knowledge base.

    • GitHub Copilot integrates well with GitHub's ecosystem and is available as an extension for various IDEs.

  • AI Model:

    • CodiumAI default model is GPT-3.5 which is available in there free package.

    • GitHub Copilot is based on OpenAI's Codex model.

  • Target Use:

    • CodiumAI seems to be more targeted towards improving code quality and test coverage.

    • GitHub Copilot is aimed at speeding up code writing and reducing boilerplate code.

 

DEMO

 

 

Conclusion:

After a comprehensive evaluation of multiple AI-assisted development tools including GitHub Copilot, Cody, Codeium, and CodiumAI, I have decided to adopt GitHub Copilot for our development team. Importantly, this decision is independent of using GitHub repositories - we can leverage GitHub Copilot's capabilities within our existing development environment.

Key points:

  1. GitHub Copilot stood out for its code generation capabilities and broad language support.

  2. We can integrate GitHub Copilot into our current workflow without changing our version control system.

  3. This tool offers potential for significant productivity gains and reduced boilerplate code.

Pros:

  1. Advanced code generation: Capable of suggesting entire functions and complex code snippets.

  2. Broad language support: Works with numerous programming languages and frameworks.

  3. Productivity boost: Can significantly speed up coding tasks and reduce repetitive work.

  4. Learning tool: Can expose developers to new coding patterns and best practices.

  5. Customizable: Features like @workspace command provide context-aware assistance.

  6. No repository lock-in: Can be used independently of GitHub repositories.

Cons:

  1. Cost: Requires a paid subscription for each developer.

  2. Potential over-reliance: Risk of developers becoming too dependent on AI-generated code.

  3. Code review necessity: Not all suggestions are perfect, requiring careful review.

  4. Privacy concerns: Some developers might be uncomfortable with code being used to train the AI.

  5. Learning curve: Initial time investment needed to use the tool effectively.

 


Recommendation:

While GitHub Copilot currently appears to be the strongest choice for our needs, it's crucial to recognize that the landscape of AI-assisted development tools is rapidly evolving. To ensure we continue to leverage the most effective tools for our team, I recommend we:

  1. Implement GitHub Copilot with a clear onboarding and usage guidelines.

  2. Stay informed by regularly reviewing new developments in AI coding assistants.

  3. Remain flexible and open to adopting better tools if they become available.

  4. Schedule periodic reassessments (e.g., every 6-12 months) of GitHub Copilot against new competitors.

  5. Encourage and maintain open feedback channels for team members to share their experiences and suggestions about AI coding tools.

By following these recommendations, we can maximize the benefits of GitHub Copilot while remaining adaptable to future advancements in AI-assisted development tools. This approach ensures we stay at the forefront of development practices and continuously enhance our productivity and code quality.

Related pages