Skip to content

Commit a537d3c

Browse files
authored
Initial commit
0 parents  commit a537d3c

24 files changed

Lines changed: 1713 additions & 0 deletions

.devcontainer/devcontainer.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"name": "Copilot CLI Calculator Exercise",
3+
"image": "mcr.microsoft.com/devcontainers/javascript-node:1-22-bookworm",
4+
"features": {
5+
"ghcr.io/devcontainers/features/github-cli:1": {
6+
"installDirectlyFromGitHubRelease": true,
7+
"version": "latest"
8+
}
9+
},
10+
"customizations": {
11+
"vscode": {
12+
"extensions": [
13+
"GitHub.copilot",
14+
"GitHub.copilot-chat"
15+
],
16+
"settings": {
17+
"files.autoSave": "afterDelay",
18+
"workbench.statusBar.visible": false,
19+
"workbench.sideBar.visible": false,
20+
"workbench.panel.defaultLocation": "bottom",
21+
"workbench.editor.showTabs": "none",
22+
"breadcrumbs.enabled": false,
23+
"editor.minimap.enabled": false,
24+
"workbench.startupEditor": "none",
25+
"terminal.integrated.hideOnLastClosed": false,
26+
"github.copilot.enable": {
27+
"*": false
28+
},
29+
"github.copilot.editor.enableAutoCompletions": false,
30+
"workbench.activityBar.location": "hidden",
31+
"workbench.activityBar.visible": false,
32+
"workbench.explorer.enabled": false,
33+
"github.copilot-chat.enable": false,
34+
"chat.disableAIFeatures": true,
35+
"chat.editor.show": false,
36+
"workbench.panel.chat.view.enabled": false,
37+
"terminal.integrated.defaultLocation": "editor",
38+
"terminal.integrated.defaultProfile.linux": "bash",
39+
"workbench.editor.enablePreview": false,
40+
"workbench.editor.closeOnFileDelete": true,
41+
"workbench.layoutControl.enabled": false,
42+
"workbench.layoutControl.type": "hidden",
43+
"workbench.panel.opensMaximized": "always",
44+
"workbench.tips.enabled": false,
45+
"window.openFilesInNewWindow": "off",
46+
"terminal.integrated.automationProfile.linux": null,
47+
"terminal.integrated.showOnStartup": "always"
48+
}
49+
}
50+
},
51+
"postCreateCommand": "echo '🚀 Welcome to the Copilot CLI Skills Exercise!' && echo '' && echo '📝 To install the standalone GitHub Copilot CLI:' && echo ' Run: npm install -g @github/copilot' && echo '' && echo '📝 Then start Copilot CLI by running:' && echo ' copilot' && echo '' && echo '📖 Open README.md to get started with the exercise!' && echo '' && npm install",
52+
"onCreateCommand": "chmod +x .devcontainer/setup.sh 2>/dev/null || true",
53+
"portsAttributes": {
54+
"3000": {
55+
"label": "Application",
56+
"onAutoForward": "notify"
57+
}
58+
},
59+
"remoteUser": "node"
60+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: Feature Request
3+
about: Suggest a new feature or enhancement for the calculator
4+
title: ''
5+
labels: enhancement
6+
assignees: ''
7+
---
8+
9+
## Feature Description
10+
11+
A clear and concise description of the feature you'd like to see.
12+
13+
## Use Case
14+
15+
Describe the use case or problem this feature would solve.
16+
17+
## Proposed Solution
18+
19+
How do you envision this feature working?
20+
21+
## Additional Context
22+
23+
Add any other context, screenshots, or examples about the feature request here.
69.5 KB
Loading
46.3 KB
Loading
46.7 KB
Loading

.github/images/copilot-cli.png

86.4 KB
Loading
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
applyTo: "**/**"
3+
---
4+
5+
# Prompt guidance
6+
7+
Stick to the prompts and context being provided. Don't jump ahead to doing steps.
8+
Only add, commit, and push files when prompted by the user.
9+
10+
# New features
11+
12+
Use .github/ISSUE_TEMPLATE/feature_request.md to request all new features for calculator.js.
13+
14+
# Global shortcuts
15+
16+
```
17+
@ mention files, include contents in context
18+
Esc cancel the current operation
19+
! execute command in your local shell (bypass Copilot)
20+
ctrl+c cancel operation / clear input / exit
21+
ctrl+d shutdown
22+
ctrl+l clear the screen
23+
```
24+
25+
## Expand timeline content shortcuts
26+
27+
```
28+
Ctrl+o - expand all timeline/collapse timeline
29+
Ctrl+r - expand recent timeline/collapse timeline
30+
```
31+
32+
## Motion shortcuts
33+
34+
```
35+
Ctrl+a - move to the beginning of the line
36+
Ctrl+e - move to the end of the line
37+
Ctrl+h - delete previous character
38+
Ctrl+w - delete previous word
39+
Ctrl+u - delete from cursor to beginning of line
40+
Ctrl+k - delete from cursor to end of line
41+
Meta+←/→ - move cursor by word
42+
```
43+
44+
Use ↑↓ keys to navigate command history
45+
46+
## Instruction sources
47+
48+
Respects instructions sourced from various locations:
49+
50+
- `.github/instructions/**/*.instructions.md` (in git root and cwd)
51+
- `.github/copilot-instructions.md`
52+
- `AGENTS.md` (in git root and cwd)
53+
- `CLAUDE.md`
54+
- `GEMINI.md`
55+
- `$HOME/.copilot/copilot-instructions.md`
56+
- Additional directories via `COPILOT_CUSTOM_INSTRUCTIONS_DIRS`
57+
58+
## Learn more
59+
60+
To learn about what I can do:
61+
62+
- Ask me "What can you do?"
63+
- Or visit: https://docs.github.com/en/copilot/how-tos/use-copilot-agents/use-copilot-cli
64+
65+
## Available commands
66+
67+
```
68+
/add-dir <directory> - Add a directory to the allowed list for file access
69+
/agent - Browse and select from available agents (if any)
70+
/clear - Clear the conversation history
71+
/compact - Summarize conversation history to reduce context window usage
72+
/context - Show context window token usage and visualization
73+
/cwd [directory] - Change working directory or show current directory
74+
/delegate <prompt> - Delegate changes to remote repository with AI-generated PR
75+
/exit, /quit - Exit the CLI
76+
/share [file|gist] [path] - Share session to markdown file or GitHub gist
77+
/feedback - Provide feedback about the CLI
78+
/help - Show help for interactive commands
79+
/list-dirs - Display all allowed directories for file access
80+
/login - Log in to Copilot
81+
/logout - Log out of Copilot
82+
/mcp [show|add|edit|delete|disable|enable] [server-name] - Manage MCP server configuration
83+
/model [model] - Select AI model to use
84+
/reset-allowed-tools - Reset the list of allowed tools
85+
/session - Show information about the current CLI session
86+
/skills [list|info|add|remove|reload] [args...] - Manage skills for enhanced capabilities
87+
/terminal-setup - Configure terminal for multiline input support (Shift+Enter and Ctrl+Enter)
88+
/theme [show|set|list] [auto|dark|light] - View or configure terminal theme
89+
/usage - Display session usage metrics and statistics
90+
/user [show|list|switch] - Manage GitHub user list
91+
```

.github/steps/1-step.md

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
## Step 1: Install Copilot CLI and Use the Issue Template
2+
3+
Duck prefers working in the terminal and wants to use AI from there.
4+
Duck is getting ready to develop a new Node.js CLI calculator app and plans to install the standalone Copilot CLI to build the application from the terminal.
5+
6+
### 📖 Theory: GitHub Copilot CLI - A Standalone Terminal Application
7+
8+
#### What is GitHub Copilot CLI?
9+
10+
GitHub Copilot CLI is a **standalone terminal application** that brings the power of GitHub Copilot directly to your command line. It is installed via npm and provides a rich interactive experience for developers.
11+
12+
<img width="60%" height="60%" alt="CopilotCLI" src="../images/copilot-cli.png" />
13+
14+
#### Key capabilities and options to be aware of include:
15+
16+
- Providing intelligent command suggestions powered by the latest AI models from OpenAI and Google
17+
- Generating code snippets and scripts directly in your terminal
18+
- Assisting with Git operations and GitHub interactions
19+
- Supporting image inputs via paste and drag-and-drop for visual context
20+
- The `--enable-all-github-mcp-tools` flag enables all GitHub MCP (Model Context Protocol) tools, giving Copilot CLI access to GitHub features like creating issues, managing repositories, and more.
21+
- Depending on your Copilot CLI configuration (for example, if you don't use the `--allow-all` option), you may be prompted to enable certain features during the session. Respond **yes** to these prompts as well.
22+
- `/session`: Shows details about your current chat session.
23+
- `/context`: Provides a visual overview of your current token usage
24+
- `/usage`: Lets you view your session statistics, including:
25+
- The amount of premium requests used in the current session
26+
- The session duration
27+
- The total lines of code edited
28+
- A breakdown of token usage per model
29+
- `/share [file|gist] [path]` - Share session to markdown file or GitHub gist
30+
- Creating **custom agents** to encode specialized prompts and workflows
31+
- Delegating tasks to **Copilot coding agent** using the `/delegate` command
32+
33+
#### Global shortcuts
34+
35+
```text
36+
@ mention files, include contents in context
37+
Esc cancel the current operation
38+
! execute command in your local shell (bypass Copilot)
39+
ctrl+c cancel operation / clear input / exit
40+
ctrl+d shutdown
41+
ctrl+l clear the screen
42+
shift+tab switch between plan mode and regular interactive mode
43+
```
44+
45+
#### Installation Requirements
46+
47+
To install Copilot CLI, you need:
48+
49+
- Node.js version 22 or later
50+
- npm version 10 or later
51+
- An active GitHub Copilot subscription (Pro, Pro+, Business, or Enterprise)
52+
53+
#### Issue Templates
54+
55+
Issue templates help maintain consistency when team members create issues. This repository already has a `feature_request.md` template that you'll use to create your calculator app issue. Templates ensure:
56+
57+
- All necessary information is captured upfront
58+
- Issues follow a standard format
59+
- The team can triage and respond to issues more efficiently
60+
61+
#### References
62+
63+
- [Installing GitHub Copilot CLI](https://docs.github.com/en/copilot/how-tos/set-up/install-copilot-cli)
64+
- [Using GitHub Copilot CLI](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/use-copilot-cli)
65+
- [GitHub Copilot CLI 101](https://github.blog/ai-and-ml/github-copilot-cli-101-how-to-use-github-copilot-from-the-command-line/)
66+
67+
> [!IMPORTANT]
68+
> If you have restarted your codespace you may need to run `copilot --allow-all` and then authenticate with GitHub again by running `!gh auth login` in your terminal,
69+
> or use `!gh auth login` from within the Copilot CLI session.
70+
71+
### :keyboard: Activity 1: Getting to know your development environment
72+
73+
1. Right-click the below button to open the **Create Codespace** page in a new tab.
74+
75+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/{{full_repo_name}}?quickstart=1)
76+
- The free tier of Codespaces that comes with all GitHub accounts is fine, assuming you still have minutes available.
77+
- The default Codespace settings are fine.
78+
79+
> [!IMPORTANT]
80+
> This Codespace VS Code environment has been simplified to focus on using the Copilot CLI in the terminal. You'll primarily be working with terminal commands rather than the full VS Code feature set.
81+
82+
1. Confirm the **Repository** field is your copy of the exercise, not the original, then click the green **Create Codespace** button.
83+
- ✅ Your copy: `/{{full_repo_name}}`
84+
- ❌ Original: `/arilivigni/create-applications-with-the-copilot-CLI`
85+
86+
1. Wait a moment for Visual Studio Code to load.
87+
88+
1. We will be focused on the full terminal window since this is all about the CLI.
89+
90+
### ⌨️ Activity 2: Install the Standalone Copilot CLI
91+
92+
1. Open your Codespace (if not already open)
93+
94+
1. Install the standalone GitHub Copilot CLI by running in the terminal window:
95+
96+
> ![Static Badge](https://img.shields.io/badge/Terminal-text?logo=gnometerminal&labelColor=0969da&color=ddf4ff)
97+
98+
> ```bash
99+
> npm install -g @github/copilot
100+
> ```
101+
102+
1. Verify the installation by running:
103+
104+
> ![Static Badge](https://img.shields.io/badge/Terminal-text?logo=gnometerminal&labelColor=0969da&color=ddf4ff)
105+
106+
> ```bash
107+
> copilot --version
108+
> ```
109+
110+
> [!TIP]
111+
> After installation, you can use the `copilot` command anywhere in your terminal to start an interactive session!
112+
113+
### ⌨️ Activity 3: Create an Issue Using Copilot CLI
114+
115+
1. Start an interactive Copilot CLI session:
116+
117+
> ![Static Badge](https://img.shields.io/badge/Terminal-text?logo=gnometerminal&labelColor=0969da&color=ddf4ff)
118+
>
119+
> ```bash
120+
> copilot --enable-all-github-mcp-tools
121+
> ```
122+
123+
> [!NOTE]
124+
> When starting Copilot CLI, you may be prompted to add this folder to the trusted folder list and to key bindings. Respond **yes** to both prompts to continue.
125+
126+
<img width="60%" height="60%" alt="CopilotCLIAddDir" src="../images/copilot-cli-add-directory.png" />
127+
<br />
128+
<img width="60%" height="60%" alt="CopilotCLITerminalBindings" src="../images/copilot-cli-terminal-bindings.png" />
129+
130+
131+
2. Authorize with GitHub (if not already authenticated) in the Copilot CLI:
132+
133+
> ![Static Badge](https://img.shields.io/badge/CLI-Prompt-text?style=flat-square&logo=github-copilot&labelColor=8250df&color=fbefff)
134+
>
135+
> ```prompt
136+
> /login
137+
> ```
138+
139+
> [!NOTE]
140+
> After running `!gh auth login`, you will be provided with a link and an authentication code. Click the link to open GitHub in your browser, then enter the code to complete the authentication process.
141+
142+
3. Explore useful slash commands in Copilot CLI:
143+
- View your current session information:
144+
145+
> ![Static Badge](https://img.shields.io/badge/CLI-Prompt-text?style=flat-square&logo=github-copilot&labelColor=8250df&color=fbefff)
146+
>
147+
> ```prompt
148+
> /session
149+
> ```
150+
151+
- View your current context information:
152+
153+
> ![Static Badge](https://img.shields.io/badge/CLI-Prompt-text?style=flat-square&logo=github-copilot&labelColor=8250df&color=fbefff)
154+
>
155+
> ```prompt
156+
> /context
157+
> ```
158+
159+
- View your current usage information:
160+
161+
> ![Static Badge](https://img.shields.io/badge/CLI-Prompt-text?style=flat-square&logo=github-copilot&labelColor=8250df&color=fbefff)
162+
>
163+
> ```prompt
164+
> /usage
165+
> ```
166+
167+
> [!NOTE]
168+
>
169+
> - `/session`: Command shows details about your current chat session.
170+
> - `/context`: Provides a visual overview of your current token usage
171+
> - `/usage`: Lets you view your session statistics, including:
172+
> - The amount of premium requests used in the current session
173+
> - The session duration
174+
> - The total lines of code edited
175+
> - A breakdown of token usage per model
176+
177+
4. Ask Copilot CLI to help you create a feature request issue for the calculator app:
178+
179+
> ![Static Badge](https://img.shields.io/badge/CLI-Prompt-text?style=flat-square&logo=github-copilot&labelColor=8250df&color=fbefff)
180+
>
181+
> ```prompt
182+
> Create a GitHub issue for a Node.js CLI calculator app using the following template
183+
> .github/ISSUE_TEMPLATE/feature_request.md template and make sure the issue is in a
184+
> markdown format that contains "calculator" in the title and follows the format of
185+
> the issue template.
186+
> I want to request a feature for basic arithmetic operations including
187+
> - addition
188+
> - subtraction
189+
> - multiplication
190+
> - division
191+
> The calculator should be implemented in calculator.js
192+
> Create the issue directly in the current owner in this session
193+
> and repository on github.com using the `gh` CLI commands.
194+
> List the issue link when complete
195+
> ```
196+
197+
5. Mona should already be busy checking your work. Give her a moment and keep watch in the comments. You will see her respond with progress info and the next lesson.
198+
199+
> [!NOTE]
200+
> Copilot CLI may ask to confirm creating the issue and using `gh issue` and `git config`.
201+
> Respond **yes** to creating the issue and
202+
> **"Yes, and approve `gh issue` or `git config` for the rest of the running session"**.
203+
204+
<img width="60%" height="60%" alt="CopilotCLIPerms" src="../images/copilot-cli-permissions.png" />
205+
206+
<details>
207+
<summary>Having trouble? 🤷</summary><br/>
208+
209+
- Make sure you have Node.js 22+ installed: `node --version`
210+
- If npm install fails, try: `sudo npm install -g @github/copilot`
211+
- Make sure you have GitHub Copilot access enabled for your account
212+
- If authentication fails, run `copilot` and run `!gh auth login`
213+
- You can also create the issue through the GitHub UI if needed
214+
215+
</details>

0 commit comments

Comments
 (0)