|
| 1 | +--- |
| 2 | +description: "Shorthand code will be in the file provided from the prompt or raw data in the prompt, and will be used to update the code file when the prompt has the text `UPDATE CODE FROM SHORTHAND`." |
| 3 | +applyTo: "**/${input:file}" |
| 4 | +--- |
| 5 | + |
| 6 | +# Update Code from Shorthand |
| 7 | + |
| 8 | +One or more files will be provided in the prompt. For each file in the prompt, look for the markers |
| 9 | +`${openMarker}` and `${closeMarker}`. |
| 10 | + |
| 11 | +All the content between the edit markers may include natural language and shorthand; convert it into |
| 12 | +valid code appropriate for the target file type and its extension. |
| 13 | + |
| 14 | +## Role |
| 15 | + |
| 16 | +Expert 10x software engineer. Great at problem solving and generating creative solutions when given |
| 17 | +shorthand instructions, similar to brainstorming. The shorthand is like a hand-drawn sketch a client |
| 18 | +gives an architect. You extract the big picture and apply expert judgment to produce a complete, |
| 19 | +high-quality implementation. |
| 20 | + |
| 21 | +## Rules for Updating Code File from Shorthand |
| 22 | + |
| 23 | +- The text `${openPrompt}` at the very start of the prompt. |
| 24 | +- The `${REQUIRED_FILE}` following the `${openPrompt}`. |
| 25 | +- Edit markers in the code file or prompt - like: |
| 26 | + |
| 27 | +```text |
| 28 | + ${openMarker} |
| 29 | + ()=> shorthand code |
| 30 | + ${closeMarker} |
| 31 | +``` |
| 32 | + |
| 33 | +- Use the shorthand to edit, or sometimes essentially create the contents of a code file. |
| 34 | +- If any comment has the text `REMOVE COMMENT`, `NOTE`, or similar within the comment, that |
| 35 | +**comment** is to be removed; and in all probability that line will need the correct syntax, |
| 36 | +function, method, or blocks of code. |
| 37 | +- If any text, following the file name implies `no need to edit code`, then in all probability this |
| 38 | +is to update a data file i.e. `JSON` or `XML` and means the edits should be focused on formatting |
| 39 | +the data. |
| 40 | +- If any text, following the file name implies `no need to edit code` and `add data`, then in all |
| 41 | +probability this is to update a data file i.e. `JSON` or `XML` and means the edits should be focused |
| 42 | +on formatting and adding additional data matching the existing format of the data file. |
| 43 | + |
| 44 | +### When to Apply Instructions and Rules |
| 45 | + |
| 46 | +- This is only relevant when the text `${openPrompt}` is at the start of the prompt. |
| 47 | + - If the text `${openPrompt}` is not at the start of the prompt, discard these instructions for |
| 48 | + that prompt. |
| 49 | +- The `${REQUIRED_FILE}` will have two markers: |
| 50 | + 1. Opening `${openMarker}` |
| 51 | + 2. Closing `${closeMarker}` |
| 52 | + - Call these `edit markers`. |
| 53 | +- The content between the edit markers determines what to update in the `${REQUIRED_FILE}` or other |
| 54 | +referenced files. |
| 55 | +- After applying the updates, remove the `${openMarker}` and `${closeMarker}` lines from the |
| 56 | +affected file(s). |
| 57 | + |
| 58 | +#### Prompt Back Following Rules |
| 59 | + |
| 60 | +```bash |
| 61 | +[user] |
| 62 | +> Edit the code file ${REQUIRED_FILE}. |
| 63 | +[agent] |
| 64 | +> Did you mean to prepend the prompt with "${openPrompt}"? |
| 65 | +[user] |
| 66 | +> ${openMarker} - edit the code file ${REQUIRED_FILE}. |
| 67 | +``` |
| 68 | + |
| 69 | +## Remember to |
| 70 | + |
| 71 | +- Remove all occurrences of the openMarker or `${language:comment} start-shorthand`. |
| 72 | + - e.g. `// start-shorthand`. |
| 73 | +- Remove all occurrences of the closeMarker or `${language:comment} end-shorthand`. |
| 74 | + - e.g. `// end-shorthand`. |
| 75 | + |
| 76 | +## Shorthand Key |
| 77 | + |
| 78 | +- **`()=>`** = 90% comment and 10% pseudo code blocks of mixed languages. |
| 79 | + - When lines have `()=>` as the starting set of characters, use your **role** to determine a |
| 80 | +solution for the goal. |
| 81 | + |
| 82 | +## Variables |
| 83 | + |
| 84 | +- REQUIRED_FILE = `${input:file}`; |
| 85 | +- openPrompt = "UPDATE CODE FROM SHORTHAND"; |
| 86 | +- language:comment = "Single or multi-line comment of programming language."; |
| 87 | +- openMarker = "${language:comment} start-shorthand"; |
| 88 | +- closeMarker = "${language:comment} end-shorthand"; |
| 89 | + |
| 90 | +## Use Example |
| 91 | + |
| 92 | +### Prompt Input |
| 93 | + |
| 94 | +```bash |
| 95 | +[user prompt] |
| 96 | +UPDATE CODE FROM SHORTHAND |
| 97 | +#file:script.js |
| 98 | +Use #file:index.html:94-99 to see where converted |
| 99 | +markdown to html will be parsed `id="a"`. |
| 100 | +``` |
| 101 | + |
| 102 | +### Code File |
| 103 | + |
| 104 | +```js |
| 105 | +// script.js |
| 106 | +// Parse markdown file, applying HTML to render output. |
| 107 | + |
| 108 | +var file = "file.md"; |
| 109 | +var xhttp = new XMLHttpRequest(); |
| 110 | +xhttp.onreadystatechange = function() { |
| 111 | + if (this.readyState == 4 && this.status == 200) { |
| 112 | + let data = this.responseText; |
| 113 | + let a = document.getElementById("a"); |
| 114 | + let output = ""; |
| 115 | + // start-shorthand |
| 116 | + ()=> let apply_html_to_parsed_markdown = (md) => { |
| 117 | + ()=> md.forEach(line => { |
| 118 | + // Depending on line data use a regex to insert html so markdown is converted to html |
| 119 | + ()=> output += line.replace(/^(regex to add html elements from markdonw line)(.*)$/g, $1$1); |
| 120 | + }); |
| 121 | + // Output the converted file from markdown to html. |
| 122 | + return output; |
| 123 | + }; |
| 124 | + ()=>a.innerHTML = apply_html_to_parsed_markdown(data); |
| 125 | + // end-shorthand |
| 126 | + } |
| 127 | +}; |
| 128 | +xhttp.open("GET", file, true); |
| 129 | +xhttp.send(); |
| 130 | +``` |
0 commit comments