JOHN BANNICK

Advanced Technologies

Software Engineer

Task 1: Set Up My Toolset

Objective

To have the software tools necessary to apply GitHub Copilot to code assist prompt engineering.

Development System

I developed this project on my iMac, running macOS 13 on a 3.4 GHz Quad-Core Intel Core i5, with 32 GB DDR4 memory and 1 TB storage.


Step 1. Get a GitHub Copilot Account

Before you start using GitHub Copilot, you must have:

To get a GitHub account, browse to https://github.com

Follow the instructions there to sign up for a personal GitHub account.

GitHub personal accounts are free.

After you have a GitHub account, browse to https://docs.github.com/en/copilot/quickstart.

Follow the instructions there to sign up for GitHub Copilot.

When I began this project, GitHub offered a free trial for a personal GitHub Copilot subscription.

YMMV.


Step 2. Install Python Latest

You do not need Python to use GitHub Copilot.
But you do need it to do this project.

To download the latest Python release, browse to https://www.python.org/downloads.

Follow the instructions there to download and install Python.

I installed Python 3.12


Step 3. Install Microsoft Visual Studio Code Latest

You do not need VS Code to use GitHub Copilot.
But you do need it to do this project.

To download the latest VS Code release, browse to https://code.visualstudio.com/download.

Follow the instructions there to download and install VS Code.

I installed VS Code 1.84.1


Step 4. Install and Configure VS Code Extensions

You do not need the following VS Code extensions to use GitHub Copilot.
But you do need them to do this project.

To download the latest VS Code extensions, browse to https://code.visualstudio.com/docs/editor/extension-marketplace

Step 4.1 Install The Extensions

Follow the instructions there to download and install the following VS Code extensions.

  1. Python by Microsoft extension - I initially installed 2023.20.0
  2. Pylance by Microsoft extension - I initially installed 2023.11.0
  3. GitHub Copilot extension - I initially installed 1.134.0
  4. GitHub Copilot Labs extension - I initially installed 1.15.1019
  5. GitHub Copilot Chat extension - I initially installed 0.10.1

Step 4.2 Disable Auto Updating for All Extensions

Initially, I disabled Extensions Auto Update because I wanted a stable environment.
Also, as a cyber security engineer, I'm always trying to minimize my attack surface.

However, when I observed my extensions set becoming outdated in a matter of days, I re-enbled Auto Update.

My cost-benefit analysis resolved that, for my Advanced Tech projects it was more desirable to maintain toolkit currency.

Step 4.3 Sign in to GitHub to Authorize VSCode

According to GitHub: the VS Code GitHub Copilot extension installer prompts you to sign in to GitHub in VS Code. This causes GitHub to request you Authorize Visual Studio Code.

You must authorize VS Code for GitHub Copilot to work in it.


Step 5. Validate the Toolkit

Step 5.1 Hello World from the GitHub Copilot web site

To ensure this toolset worked, I first did GitHub Copilot's own JavaScript Hello World, "Getting your first suggestion"

  1. Open VS Code
  2. VS Code Keyboard Shortcuts
    VS Code Copilot Keyboard Shortcuts
  3. In VS Code, create a JavaScript file
  4. Enter Command+N then Command+K release then M

    From the dropdown menu of coding languages, select JavaScript.

  5. In that file, type
    function calculateDaysBetweenDates(begin, end)
    Copilot suggests an implementation.
  6. VS Code new JavaScript file
    Suggestion 1.
  7. Enter Alt+] or Option+] or Alt+[ or Option+[ repeatedly for alternate suggestions.
  8. VS Code new JavaScript file
    Suggestion 2.
    VS Code new JavaScript file
    Suggestion 3.
    VS Code new JavaScript file
    Suggestion 4.

    I like Suggestion 3 for its simplicity, completeness, and clarity.

  9. To select a suggestion, in the line you just typed in, hit Tab
  10. VS Code new JavaScript file
    Selected code.

    You can now save or edit that code.

TIP: You can hit Ctl+Enter while in the type-it-here field to toggle a tab that contains all suggestions.

VS Code multiple suggestion tab

Step 5.2 Hello World from the Microsoft GitHub Copilot VS Code extension web site

Then I did the Python HW from The VS Studio GitHub Copilot installer

  1. Open VS Code
  2. In VS Code, create a Python file
  3. Enter Command+N then Command+K release then M

    From the dropdown menu of coding languages, select Python.

  4. In that file, type
    def hello():
    Copilot suggests an implementation.
  5. VS Code new Python file
    Suggestion 1.
    VS Code new Python file
    Suggestion 2.
    VS Code new Python file
    Suggestion 3.

    I like Suggestion 1 because it's what I normally use.

  6. In the line you just typed in, hit Tab
  7. VS Code new Python file
    Selected code.

    You can now save or edit that code.

Step 5.3 Hello World from the Book

Then I did the Python HW from Learn AI-Assisted Python Programming with GitHub Copilot and Chat GPT Section 2.3.2 Check to see if your setup is working properly. Page 18.

  1. Open VS Code
  2. In VS Code, create a Python file
  3. Enter Command+N then Command+K release then M

    From the dropdown menu of coding languages, select Python.

  4. In that file, type
    #output "Hello Copilot!" to the screen
    and hit ENTER

    >>> THIS IS A PROMPT ENGINEERING PROMPT <<<
  5. VS Code new Python file
    Suggestion 1.

    No other useful suggestions suggest themselves.

  6. In the suggested line, hit Tab
  7. VS Code new Python file
    Selected code.
  8. Save the file.
  9. Run the file by hitting the VS Code Run button VS Code Run button
  10. VS Code new Python file
    Selected code - Running.

Conclusions

The necessary software tools are installed, configured, and validated.

Note: For the first two examples, I did not utter a Prompt.
Copilot used Code Completion.

The third example, from the book, is my first Prompt Engineering code for this side project. Yea!

Copilot has multiple ways to suggest code:

  1. Function Signatures: Type in the function signature and Code Pilot suggests implementations.

  2. Comments: Type in comments in the coding language you're using (Python here) and Code Pilot suggests implementations.
    This option is broader in scope and more abstract.