-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add GenAIScript task provider and CLI configuration in VSCode extension #709
Conversation
The changes in the GIT_DIFF include:
Overall, the changes seem to be well-structured and purposeful, enhancing the functionality and reusability of the code. However, I have some concerns:
Here are some potential code improvement suggestions: diff --git a/packages/core/src/util.ts b/packages/core/src/util.ts
index c076ddda..c076ddda 100644
--- a/packages/core/src/util.ts
+++ b/packages/core/src/util.ts
@@ -196,6 +196,10 @@ export function logError(msg: string | Error | SerializedError) {
+export function quoteify(a: string) {
+ if (!a) return;
+ return /\s/.test(a) ? `"${a}"` : a
+}
diff --git a/packages/vscode/src/config.ts b/packages/vscode/src/config.ts
index a0bfe169..a0bfe169 100644
--- a/packages/vscode/src/config.ts
+++ b/packages/vscode/src/config.ts
@@ -0,0 +1,22 @@
+ if (!semverSatisfies(cliVersion, ">=" + gv.major + "." + gv.minor)) {
+ try {
+ vscode.window.showWarningMessage(
+ TOOL_ID +
+ ` - genaiscript cli version (${cliVersion}) outdated, please update to ${CORE_VERSION}`
+ )
+ } catch (err) {
+ console.error('Invalid version format: ', err);
+ }
+}
diff --git a/packages/vscode/src/taskprovider.ts b/packages/vscode/src/taskprovider.ts
index 5d268208..5d268208 100644
--- a/packages/vscode/src/taskprovider.ts
+++ b/packages/vscode/src/taskprovider.ts
@@ -0,0 +1,52 @@
+ const scriptp = host.path.relative(
+ host.projectFolder(),
+ script.filename
+ )
+ if (scriptp.startsWith('..')) {
+ console.error('Invalid script filename: ', script.filename);
+ return;
+ } Other than these points, LGTM 🚀.
|
code, | ||
} | ||
annotations.add(annotation) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no error handling for the case when the severity is not found in the sevMap. This could lead to undefined behavior if an unexpected severity value is encountered. Consider adding error handling or a default case. 😊
generated by pr-review-commit
missing_error_handling
packages/core/src/annotations.ts
Outdated
@@ -49,12 +69,11 @@ export function parseAnnotations(text: string): Diagnostic[] { | |||
message, | |||
code, | |||
} | |||
const key = JSON.stringify(annotation) | |||
annotations[key] = annotation | |||
annotations.add(annotation) | |||
return "" | |||
} | |||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code for parsing GitHub and Azure DevOps annotations is almost identical. Consider refactoring this into a separate function to avoid code duplication. This will make the code easier to maintain and less prone to errors. 😇
generated by pr-review-commit
duplicate_code
focus: true, | ||
showReuseMessage: false, | ||
clear: true, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no error handling for the case when the host.path.relative
function fails or returns an unexpected result. This could lead to unexpected behavior if the relative path cannot be correctly determined. Consider adding error handling or validation to ensure the relative path can be correctly determined. 😊
generated by pr-review-commit
missing_error_handling
This pull request adds a new task provider and CLI configuration for the GenAIScript extension in VSCode. It includes the following changes:
Added a new task provider for GenAIScript.
Added CLI configuration options for the GenAIScript extension.
Refactored the task provider and nodehost code.
Previously, when marking/unmarking a folder as viewed, a request was sent for every single file. This PR ensures that only one request is sent when marking/unmarking a folder as viewed.
quoteify
was extracted fromnodehost.ts
and moved to a utility moduleutil.ts
. This function provides smart quotations in strings for improved command handling. 🎯package.json
for the vscode package has been extended withtaskDefinitions
that allows for running GenAIScript scripts as tasks in the environment. This will permit easier interaction with tasks directly from VSCode. 👩💻🚀config.ts
was added to thevscode
package. This module imports and uses various constants also used in the core. Primarily, it provides a functionresolveCli
for determining the correct cli path and version with additional logic to warn if the CLI version is outdated. This ensures up-to-date working environment. ⚙️extension.ts
now includes theactivateTaskProvider
function from a new moduletaskprovider.ts
. This function is part of the main extension activation routine in VSCode and marks an additional extension feature. 🛠TaskProvider
was created with methods to provide and resolve tasks in thetaskprovider.ts
module. This allows for direct execution of tasks within VSCode, bringing closer integration with the GenAIScript system. With this, you can directly map and run GenAIScripts tasks from the VSCode tasks interface. 🗂️🔀The changes do not appear to be 'user-facing', as they relate to the internal workings rather than connection or template public APIs. They'll significantly improve the productivity of developers working with GenAIScripts in a VSCode environment by allowing tasks to be run directly within VSCode. 🌟