Files
GacUI/.github/prompts/code.prompt.md
2026-03-08 03:04:45 -07:00

6.0 KiB

Task

  • Check out Accessing Task Documents and Accessing Script Files in REPO-ROOT/.github/copilot-instructions.md for context about mentioned *.md and *.ps1 files.
  • All *.md and *.ps1 files should exist; you should not create any new files unless explicitly instructed.

Goal and Constraints

  • You must ensure the source code compiles.
  • You must ensure all tests pass.

Step 1. Implement Request

  • Follow the chat message to implement the task.

Step 2. Make Sure the Code Compiles

  • Check out External Tools Environment and Context in REPO-ROOT/.github/copilot-instructions.md for accessing scripts for building.
    • Strictly follow the instruction above as this repo does not use ordinary tools.
  • Each attempt of build-fix process should be executed in a sub agent.
    • One build-fix process includes one attempt with the following instructions.
    • The main agent should call different sub agent for each build-fix process.
    • Do not build and retrieve build results in the main agent.

Use a sub agent to run all following instructions (Build the Solution, Fix Compile Errors, Code Generation, Finishing Code Change)

Build the Solution

  • Check out REPO-ROOT/Project.md to find out what solutions you need to build.
  • Find out if there is any warning or error.
    • External Tools Environment and Context in REPO-ROOT/.github/copilot-instructions.md has the instruction about how to check compile result.

Fix Compile Errors

  • If there is any compilation error, address all of them:
    • If there is any compile warning, only fix warnings that caused by your code change. Do not fix any other warnings.
    • If there is any compile error, you need to carefully identify, is the issue in the callee side or the caller side. Check out similar code before making a decision.
  • After finishing fixing, exit the current sub agent and tell the main agent to go back to Step 2. Make Sure the Code Compiles

Code Generation

  • Check out ## Projects for Verification in REPO-ROOT/Project.md.
  • Find out if any code generation is necessary.
    • If there is no need to run any code generation, you can skip this step.
    • Otherwise, pay attention to:
      • What configuration is needed to build the solution.
      • What project should be executed, and what configuration is needed.
      • It is possible that a project needs to be executed multiple times in different configuration.
      • It is possible that building is required between two runs of code generation projects.
        • The building and future code generation project execution should be handled by the next sub agent.
  • If a unit test project is also a code generation project, execute it accordingly.
  • If a unit test project is not a code generation project, DO NOT execute it. Pure unit test projects will be executed in the future.

Finishing Code Change

  • Exit the current sub agent and tell the main agent to go back to Step 2. Make Sure the Code Compiles.
    • If there is any unfinished work according to Code Generation, make sure to tell the main agent about them.

Step 3. Run Unit Test

  • Check out External Tools Environment and Context in REPO-ROOT/.github/copilot-instructions.md for accessing scripts for testing and debugging.
    • Strictly follow the instruction above as this repo does not use ordinary tools.
  • Each attempt of test-fix process should be executed in a sub agent.
    • One test-fix process includes one attempt following Execute Unit Test and Fix Failed Test Cases.
    • The main agent should call different sub agent for each test-fix process.
    • Do not test and retrieve test results in the main agent.

Use a sub agent to run the following instructions (Execute Unit Test, Identify the Cause of Failure and Fix Failed Test Cases)

Execute Unit Test

  • Check out REPO-ROOT/Project.md to find out what projects you need to execute.
  • Run the unit test and see if they passed. If everything is good, you will only see test files and test cases that are executed.
    • Make sure added test cases are actually executed.
    • If any test case fails on a test assertion, the content of TEST_ASSERT or other macros will be printed to the output.
    • If any test case crashes, the failed test case will be the last one printed. In this case, you might need to add logging to the code.
      • In any test case, TEST_PRINT would help.
      • In other source code, vl::console::Console::WriteLine would help. In Vlpp project, you should #include Console.h. In other projects, the Console class should just be available.
      • When added logging is no longer necessary, you should remove all of them.

Identify the Cause of Failure

  • Dig into related source code carefully, make your assumption about the root cause.
  • TEST_ASSERT in test cases or vl::console::Console::WriteLine in the source code would help.
    • They can make sure the expected code path is executed.
    • They can print variable values after converting to strings.
  • Debug the unit test directly to get accurate clues if you are not confident of the assumption
    • Follow Debugging a Project to start a debugger and run WinDBG commands.
    • From there you can set break-points, walk through code by lines, and inspect variables.
    • You must stop the debugger after you finish debugging.
  • When you have made a few guesses but did not progress, you are recommended to debug the unit test directly.
    • Break-points are very useful to ensure the expected code path is executed, and you can inspect variable values.

Fix Failed Test Cases

  • Apply fixes to source files.
  • DO NOT delete any test case.
  • After finishing fixing, exit the current sub agent and tell the main agent to go back to Step 2. Make Sure the Code Compiles
    • Step 2. Make Sure the Code Compiles and Step 3. Run Unit Test are absolutely no problem. If you didn't see any progress, the only reason is that your change is not correct.

Step 4. Check it Again

  • Go back to Step 2. Make Sure the Code Compiles, follow all instructions and all steps again.