Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit cbc90e5

Browse files
committedApr 29, 2025·
Update custom instructions for exercises
1 parent c7222ce commit cbc90e5

File tree

1 file changed

+26
-34
lines changed

1 file changed

+26
-34
lines changed
 

‎challenges/hangperson/hangperson_exercises.md

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
**Key Customization Mechanisms:**
88

99
* **Workspace Instructions (`.github/copilot-instructions.md`):** General project context.
10-
* **Custom Instructions (VS Code Settings / Files):** Specific guidelines for code generation, test generation, etc., configured via `settings.json` often by referencing external `.md` instruction files.
10+
* **Custom Instructions (VS Code Settings / Files):** Specific guidelines for code generation, test generation, etc., configured via `settings.json` often by referencing external `.md` instruction files (e.g., from a `docs/instructions/` folder).
1111
* **Reusable Prompts (`*.prompt.md`):** Parameterized instructions for common, limited-scope tasks.
1212
* **Agent Workflow Instructions (Separate `.md` File):** Detailed, multi-step instructions for complex agent tasks.
1313

@@ -178,11 +178,11 @@
178178
### Exercise 3.2: Define Custom Code Generation Instructions (via File Reference)
179179
180180
* **Purpose:** To guide Copilot towards generating code that meets specific quality standards, especially for error handling and style, using a referenced instruction file.
181-
* **Aim:** Create a `.md` instruction file for Java code generation guidelines and reference it in workspace `settings.json`.
181+
* **Aim:** Create a `.md` instruction file for Java code generation guidelines in `docs/instructions/` and reference it in workspace `settings.json`.
182182
* **Steps:**
183183
1. **Create Instruction File:**
184-
* Create a folder `.vscode` in your workspace root if it doesn't exist.
185-
* Inside `.vscode`, create a file named `copilot_codegen_java_instructions.md`.
184+
* Create a folder `docs/instructions/` in your workspace root (create `docs` and `instructions` folders if they don't exist).
185+
* Inside `docs/instructions/`, create a file named `copilot_codegen_java_instructions.md`.
186186
* Add the following content to this new file:
187187
```markdown
188188
## Java Code Generation Guidelines (HangpersonApp)
@@ -195,42 +195,33 @@
195195
- Add comments explaining non-obvious logic.
196196
- Adhere to Java 1.8 syntax compatibility.
197197
```
198-
* Save `copilot_codegen_java_instructions.md`.
198+
* Save `docs/instructions/copilot_codegen_java_instructions.md`.
199199
2. **Open Workspace Settings (JSON):** Use the Command Palette (`Cmd+Shift+P` / `Ctrl+Shift+P`) and search for `Preferences: Open Workspace Settings (JSON)`.
200-
3. **Reference Instruction File:** Add or modify the relevant setting for code generation instructions (e.g., `github.copilot.editor.instructions` or `github.copilot.chat.codeGeneration.instructions` - check documentation for the exact key name as it might evolve). Reference the file you created:
200+
3. **Reference Instruction File:** Add or modify the relevant setting for code generation instructions (e.g., `github.copilot.chat.codeGeneration.instructions` - check documentation for the exact key name). Reference the file you created:
201201
```json
202202
{
203203
// ... other settings ...
204-
// Example using hypothetical 'github.copilot.chat.codeGeneration.instructions'
205204
"github.copilot.chat.codeGeneration.instructions": [
206205
{
207-
"file": ".vscode/copilot_codegen_java_instructions.md"
206+
// Use relative path from workspace root
207+
"file": "docs/instructions/copilot_codegen_java_instructions.md"
208208
// You could add more { "text": "..." } or { "file": "..." } entries here
209209
}
210-
],
211-
// Example using hypothetical 'github.copilot.editor.instructions'
212-
// "github.copilot.editor.instructions": {
213-
// "language": { // Note: This language nesting might not be supported per latest schema,
214-
// // prefer the array approach above if possible.
215-
// "java": {
216-
// "uri": "file:///${workspaceFolder}/.vscode/copilot_codegen_java_instructions.md"
217-
// }
218-
// }
219-
// }
210+
]
220211
// ... other settings ...
221212
}
222213
```
223-
*Choose the setting key that best matches the feature you want to influence (general chat generation vs. inline editor suggestions). The array format (`github.copilot.chat.codeGeneration.instructions` example) is generally more flexible.*
214+
*Note: Ensure the setting key used corresponds to the Copilot feature you want to influence (e.g., chat suggestions, inline completions). Refer to current Copilot documentation.*
224215
4. Save `settings.json`.
225-
5. **Verification:** Perform the verification steps from the previous version of this exercise (asking Copilot to generate code involving potential I/O) and check if the output adheres to the rules defined in your `.md` file.
216+
5. **Verification:** Perform the verification steps from the previous version of this exercise (asking Copilot to generate code involving potential I/O) and check if the output adheres to the rules defined in your `docs/instructions/copilot_codegen_java_instructions.md` file.
226217
227218
### Exercise 3.3: Define Custom Test Generation Instructions (via File Reference)
228219
229220
* **Purpose:** To ensure generated unit tests follow consistent standards using a referenced instruction file.
230-
* **Aim:** Create a `.md` instruction file for Java test generation guidelines and reference it in workspace `settings.json`.
221+
* **Aim:** Create a `.md` instruction file for Java test generation guidelines in `docs/instructions/` and reference it in workspace `settings.json`.
231222
* **Steps:**
232223
1. **Create Instruction File:**
233-
* Inside the `.vscode` folder, create a file named `copilot_testgen_java_instructions.md`.
224+
* Inside the `docs/instructions/` folder, create a file named `copilot_testgen_java_instructions.md`.
234225
* Add the following content:
235226
```markdown
236227
## Java Test Generation Guidelines (HangpersonApp)
@@ -242,22 +233,22 @@
242233
- **Mocking:** Use Mockito if dependencies need mocking (though initial tests might not require it).
243234
- **Structure:** Include clear Arrange, Act, Assert sections commented as `// Arrange`, `// Act`, `// Assert`.
244235
```
245-
* Save `copilot_testgen_java_instructions.md`.
236+
* Save `docs/instructions/copilot_testgen_java_instructions.md`.
246237
2. **Open Workspace Settings (JSON).**
247238
3. **Reference Instruction File:** Add or modify the relevant setting for test generation instructions (e.g., `github.copilot.tests.instructions` - check documentation for the exact key).
248239
```json
249240
{
250241
// ... other settings ...
251242
"github.copilot.tests.instructions": [ // Hypothetical key, check actual setting name
252243
{
253-
"file": ".vscode/copilot_testgen_java_instructions.md"
244+
"file": "docs/instructions/copilot_testgen_java_instructions.md"
254245
}
255246
]
256247
// ... other settings ...
257248
}
258249
```
259250
4. Save `settings.json`.
260-
5. **Verification:** Perform the verification steps from the previous version of this exercise (using `/tests` command) and check if the generated tests adhere to the rules defined in your `.md` file.
251+
5. **Verification:** Perform the verification steps from the previous version of this exercise (using `/tests` command) and check if the generated tests adhere to the rules defined in your `docs/instructions/copilot_testgen_java_instructions.md` file.
261252
262253
---
263254
@@ -305,7 +296,7 @@
305296
* **Purpose:** To define instructions for an agent to implement the core game structure based on the specification.
306297
* **Aim:** Create `implement_game_core_workflow.md` guiding the agent.
307298
* **Steps:**
308-
1. Create `implement_game_core_workflow.md` in the workspace root or an `/instructions` folder.
299+
1. Create `implement_game_core_workflow.md` in the workspace root or an `/instructions` folder (e.g., `docs/instructions/implement_game_core_workflow.md`).
309300
2. Add the following content:
310301
```markdown
311302
# AI Agent Workflow: Implement Hangperson Core Logic
@@ -345,12 +336,12 @@
345336
1. Ensure `docs/specs/GameSpec.md` exists.
346337
2. In Copilot Chat, invoke the workflow:
347338
```
348-
# (select implement_game_core_workflow.md) /implement # (select docs/specs/GameSpec.md)
339+
# (select docs/instructions/implement_game_core_workflow.md) /implement # (select docs/specs/GameSpec.md)
349340
```
350-
*(Adjust invocation based on actual Copilot Agent capabilities)*
341+
*(Adjust invocation based on actual Copilot Agent capabilities and the location you saved the workflow file)*
351342
3. **Review Generated Code:** Examine the created files (`GameEngine.java`, `GameState.java`, `WordSource.java`).
352343
* Does the structure match the plan?
353-
* Does the error handling (if any generated yet) match the custom instructions defined in your `.vscode/*.md` files?
344+
* Does the error handling (if any generated yet) match the custom instructions defined in your `docs/instructions/*.md` files?
354345
* Is the logic generally correct based on the spec?
355346
4. **Refine (Example):**
356347
* Maybe the initial guess processing logic in `GameEngine` is too complex. Select that method.
@@ -392,7 +383,7 @@
392383
### Exercise 6.1: Refine Instructions or Prompts
393384
394385
* **Purpose:** To improve the guidance given to Copilot based on observed results.
395-
* **Aim:** Modify the custom instructions (`.vscode/*.md` files referenced in `settings.json` or `.github/copilot-instructions.md`) or reusable prompts (`*.prompt.md`) to address any shortcomings noticed during implementation or testing.
386+
* **Aim:** Modify the custom instructions (`docs/instructions/*.md` files referenced in `settings.json` or `.github/copilot-instructions.md`) or reusable prompts (`*.prompt.md`) to address any shortcomings noticed during implementation or testing.
396387
* **Steps:**
397388
1. Identify an area where Copilot's output didn't fully meet expectations (e.g., error handling wasn't robust enough, test naming was inconsistent despite instructions).
398389
2. Refine the relevant instruction file (`.md`) or prompt file (`.prompt.md`) to be more specific or clear.
@@ -403,17 +394,18 @@
403394
* **Purpose:** To replace the hardcoded word list with logic to read from the provided `nouns`/`verbs` files.
404395
* **Aim:** Use Copilot (Ask, Edits, Completion), guided by custom instructions for I/O error handling, to implement file reading in `WordSource.java`.
405396
* **Steps:**
406-
1. Open `WordSource.java` (or the relevant file created by the agent).
407-
2. Use Copilot Chat or Edits mode: `# (select WordSource.java) /explain Modify this class to read words from text files named 'nouns.txt' and 'verbs.txt' located in the project root (or a specified resources directory). Load all words into a single list. Handle potential FileNotFoundException and IOException according to the project's error handling guidelines (use try-with-resources, log errors). Update the word selection method to use this list.`
408-
3. Review and refine the generated code, ensuring robust file handling.
397+
1. *(Setup)* Ensure you have `nouns.txt` and `verbs.txt` files in your project root or a `src/main/resources` directory.
398+
2. Open `WordSource.java` (or the relevant file created by the agent).
399+
3. Use Copilot Chat or Edits mode: `# (select WordSource.java) /explain Modify this class to read words from text files named 'nouns.txt' and 'verbs.txt' located in the project root (or classpath resources if placed there). Load all words into a single list upon initialization. Handle potential FileNotFoundException and IOException according to the project's error handling guidelines (use try-with-resources, log errors). Update the word selection method to use this list.`
400+
4. Review and refine the generated code, ensuring robust file handling. Consider where the files should ideally be placed (resources folder is common for classpath loading).
409401
410402
### Exercise 6.3: Connect UI Loop
411403
412404
* **Purpose:** To integrate the core game logic with the main application loop for user interaction.
413405
* **Aim:** Modify `App.java` to create instances of the game classes and run the main game loop, handling user input and displaying output.
414406
* **Steps:**
415407
1. Open `App.java`.
416-
2. Use Copilot Chat/Edits/Completion: `# (select App.java) # (select GameEngine.java) /explain Modify the main method to: create a GameEngine instance, call its playGame method, and handle the overall application flow.` (You'll likely need more detailed prompts to handle reading user input from the console and displaying game state).
408+
2. Use Copilot Chat/Edits/Completion: `# (select App.java) # (select GameEngine.java) /explain Modify the main method to: create a GameEngine instance, call its playGame method, and handle the overall application flow.` (You'll likely need more detailed prompts to handle reading user input from the console using `java.util.Scanner` and displaying game state).
417409
3. Focus on getting the basic loop working, relying on the methods already implemented in `GameEngine`, `GameState`, etc.
418410
419411
---

0 commit comments

Comments
 (0)
Please sign in to comment.