PromptMaster
Usage
Prompt Master has two workflows:
- PromptMaster
- PromptMaster-UT
invoke by right click or open Command Palette
WorkFlow 1
- select some code, invoke PromptMaster(by rightclick or command palette)
- select an action
- the prompt is copied to your clippboard
- you can see the preview of generate prompt in sidebar-> EXPLORER -> Prompt Preview
WorkFlow 2
- select some code
- invoke PromptMasterUT, fill the slots wrapped by '{<slotname>|<description>}' or directly generate prompt
- you can see the preview of generate prompt in sidebar-> EXPLORER -> Prompt Preview
- create a prompt-master folder in your workspace, see below tree module
{your_workspace}
├── prompt-master
│ ├── foo.yaml
│ └── bar.yaml
├── src
│ ├── main.cpp
│ └── utils
├── other_stuff
- basic yaml struct should like below
prompts:
{your_prompt_id}:
display_name: {your display_name}
description: {your description}
issued_by_swi: False
system_prompt: |
{your system prompt, there should have the indent}
user_prompt: |
## Code
```
{code|Some descriptions...}
```
- in <user_pormpt> section, you should have EXACT ONE {code | Some descriptions}, which is used as a placeholder for your selected code,
when invoke PromptMaster, the {code | Some descriptions} will be replaced by your selection
- a sample yaml is attached in appendix for your reference
- You can open Preferences -> Keyboard Shortcuts[Ctrl+K Ctrl+S] to set up the shortcuts for PromptMaster
Test
npm install
- Run -> Start Debugging
Changelog
v1.4.0
- Improve diagramming prompts
v1.3.9
- when some code has triggered optional rules, a comment will be added to that line
v1.3.8
- replace plantUML to mermaid for diagramming, adding some extra support for mermaid markdown
- improve some built-in prompts
v1.3.5
- support splitConfig for user settings
- imporve some built-in prompts
v1.3.3
- support Regex customized system prompt
- quickSelect tab now is sorted by the use frequency
v1.3.2
- now user can open user's settings.json to enable or disable some prompts that he/she wouldn't use
v1.3.0
- Add emoji for quickselect
v1.2.9
- Add a yaml
[Terminal]:找到Terminal输出中的关键信息
for terminal debug
- support terminal selection
v1.2.8
- remove default shortcut for PromptMaster to avoid a promtential conflict with System Quick Open (Ctrl + P)
- polish some build-in prompt template
v1.2.7
- add python best practice yaml
v1.2.6
- show filename and line number for every code selection
v1.2.1
- improve PromptMaster's action description
appendix
// prompt-master.yaml
prompts:
coredump_hunter_all_in_one:
display_name: "[Coredump]:找到可能产生Coredump的地方,并且提供建议的Fix"
description: Find UB to prevent coredump
issued_by_swi: True
system_prompt: |
## Role
You are a C++ expert. Good at find C++ undefined behavior that could cause coredump.\n
## Objective
Read the code line by line. Find Potential undefined behavior list below within <code> tag. Report line number\n
## Response language
Chinese
## Pointer operations
1. deferencing a null pointer.
2. using a dangling pointer
3. return a reference to local object
3. free a pointer twice
## Array operation
1 . out of bound array access
## uninitialization
1. use an uninitialized variable
## miscs
1. divided by zero
2. modifying a container while iterating over it at the sametime.
## Instructions
If the code contains the following situation. Report them in your response \n
1. Call a function that returns pointer, but without checking whether if the returned pointer is null. Report "Missing nullptr check" \n
2. Directly using index to access the array, without boundary check. Report "Missing array boundary check" \n
3. A variable is std::move moved, but still used later. Report "Use after move" \n
4. Visiting the front or back, or [0] of a container, without checking if the container is empty or not. Report "Missing container empty check" \n
5. Visiting an uninitialized pointer. Report "Pointer maybe uninitialized" \n
6. Poping an empty stack. Report "Missing empty check on stack" \n
7. Use at() or operator[] to visit a container, without boundary check, Report "Missing array boundary check" \n
8. A function is declared with return value, but forget the return. Report "Missing return value of a function" \n
9. In a for loop, modifying the container within the loop, while loop over the container \n
10. Returning a reference of local object \n
11. Race condition. \n
12. Declaring a large amount of memory \n
13. Division without checking if denominator is zero\n
14. ignore C++ comments
15. If there is for loop, check if there is any possibility of an inifinite loop. such as overflowing
## Results Format
1 Provide your response in Chinese.
2 Go through each items shown above, and explicitly verify there is no such problem in the code
## Response Format Example
1. On the line with suggested change, add comments. For example:
```
line_you_changed ; //◀==== changes you made
```
2. Keep the original line number when giving the improved code
user_prompt: |
## Code
```
{code|Some descriptions...}
```