Skip to content

Commit 36bdb9c

Browse files
committed
Refine prompt to avoid statements were it keeps the logic [3]
1 parent c8b67ad commit 36bdb9c

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

packages/vscode-extension/src/node/shopify-magic-prompts/base.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,31 @@ export function basePrompt(textEditor: TextEditor): string {
1717
<objective>Optimal Theme Development</objective>
1818
</prompt_metadata>
1919
<focus_areas>
20-
<area>Enhancing readability, conciseness, and efficiency while maintaining the same functionality</area>
21-
<area>Leveraging new features in Liquid, including filters, tags, and objects</area>
22-
<area>Be pragmatic and don't suggest without a really good reason</area>
23-
<area>Combine multiple operations into one to improve readability and performance -- for example, use the find filter instead of where and first, if find is a valid filter</area>
24-
<area>You should not suggest changes to the code that impact only HTML -- they should be focused on Liquid and Theme features.</area>
25-
<area>You should not talk about whitespaces and the style of the code; leave that to the linter!</area>
26-
<area>**Do not suggest to keep** something that is already valid</area>
20+
<area>**Enhance the conciseness and efficiency of Liquid code** while maintaining the same functionality</area>
21+
<area>**Leverage the most appropriate Liquid** features (filters, tags, and objects); sometimes a filter can achieve the same result as a block of code</area>
22+
<area>Avoid logic that matches the default behavior (especially for filters)</area>
23+
<area>**Be pragmatic** and **do not suggest unless there's a strong reason**</area>
24+
<area>Use filters for operations that perform the same function as a filter</area>
25+
<area>Use unless for negative conditions</area>
2726
</focus_areas>
2827
<ensurance>
29-
<point>The new code you propose contain full lines of valid code and keep the correct indentation, scope, and style format as the original code</point>
30-
<point>Scopes are defined by the opened by "{%", "{{" with the matching closing element "%}" or "}}"</point>
31-
<point>The range must include the closing element ("%}","}}") for every opening element ("{%","{{")</point>
28+
<point>**Suggest only valid Liquid**</point>
29+
<point>Suggested code must be different from the original code</point>
30+
<point>**Do not suggest code styling changes**; it's best to leave that to the linter!</point>
31+
<point>**Do not suggest refactorings** about combining variables</point>
32+
<point>**Do not suggest keeping** something that is already good</point>
33+
<point>**Do not suggest** changes that impact **only readability**</point>
34+
<point>**Do not suggest** something that **changes the logic/functionality**</point>
35+
<point>**Do not make up or create** new invalid Shopify Liquid features (filters, tags, objects, etc.)</point>
36+
<point>**Do not suggest** changes that affect only **HTML**—focus on Liquid and Theme features instead</point>
37+
<point>The new code you propose should contain full lines of valid code and maintain the correct indentation, scope, and style format as the original code</point>
38+
<point>Scopes are defined by the opening of "{%" or "{{" with the matching closing element "%}" or "}}"</point>
39+
<point>The range must include the closing element ("%}", "}}") for every opening element ("{%", "{{")</point>
3240
<point>Code suggestions cannot overlap in line numbers. If you have multiple suggestions for the same code chunk, merge them into a single suggestion</point>
3341
<point>Make full-scope suggestions that consider the entire context of the code you are modifying, keeping the logical scope of the code valid</point>
3442
<point>The resulting code must work and should not break existing HTML tags or Liquid syntax</point>
35-
<point>The suggestions are specific, actionable, and align with the best practices in Liquid and Shopify theme development</point>
36-
<point>Add a maximum of ${numberOfSuggestions} distinct suggestions to the array</point>
43+
<point>The suggestions should be specific, actionable, and align with the best practices in Liquid and Shopify theme development</point>
44+
<point>You must have zero up to a maximum of ${numberOfSuggestions} distinct suggestions to the array</point>
3745
</ensurance>
3846
<references>
3947
Use the <theme_architecture>, <liquid_rules>, and Shopify.dev context as a reference. Do not make up new information.

packages/vscode-extension/src/node/shopify-magic.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ async function buildMessages(textEditor: TextEditor) {
131131
codeMetadataContext,
132132
liquidRulesContext,
133133
themeArchitectureContext,
134-
].map((message) => LanguageModelChatMessage.User(message));
134+
].map((message) => {
135+
console.error(message);
136+
return LanguageModelChatMessage.User(message);
137+
});
135138
}
136139

137140
function createHoverMessage(key: string, liquidSuggestion: LiquidSuggestion) {

0 commit comments

Comments
 (0)