Improve prompts

This commit is contained in:
Dominik Jain 2025-09-23 13:55:40 +02:00 committed by Dominik Jain
parent f0b25c1052
commit 3d29e42251
2 changed files with 8 additions and 1 deletions

View File

@ -9,6 +9,7 @@ initial_instructions: |
One of the key tools is the execute_code tool, which allows you to run JavaScript code using the Penpot Plugin API
directly in the connected project.
When writing code, a key object is the `penpot` object which provides key functionality:
* `penpot.selection` provides the list of elements the user has selected in the Penpot UI.
If it is unclear which elements to work on, you can ask the user to select them for you.
@ -23,4 +24,7 @@ initial_instructions: |
type?: "html" | "svg";
}): string;
For example, to generate CSS for the selected elements, you can execute this:
return penpot.generateStyle(penpot.selection, { type: "css", withChildren: true });
You have hereby read the 'Penpot High-Level Overview' and need not use a tool to read it again.

View File

@ -45,7 +45,10 @@ export class ExecuteCodeTool extends Tool<ExecuteCodeArgs> {
"data can be stored, simply by adding a new attribute; stored attributes can be referenced in future calls " +
"to this tool, so any intermediate results that could come in handy later should be stored in `storage` " +
"instead of just a fleeting variable).\n" +
"The tool call returns the value of the concluding return statement, if any."
"The tool call returns the value of the concluding return statement, if any.\n" +
"Note that using console.log() in your code makes no sense as you will not see the output.\n" +
"In general, try a simple approach first, and only if it fails, try more complex code that involves " +
"handling different cases (in particular error cases)."
);
}