typescript support by pelikhan · Pull Request #564 · microsoft/genaiscript

The changes in the pull request branch involve several modifications in the functionality and constants used across multiple TypeScript files. Here is a summary of the changes:

  • The constant GENAI_JS_GLOB was replaced with GENAI_ANYJS_GLOB in several files. The new constant includes a wider range of file types (**/*.genai.{js,mjs,ts,mts}), which means the system will now work with .ts and .mts files in addition to the previously supported .js and .mjs files. This expands the range of scripts that can be handled.
  • The compileScript function in scripts.ts has been expanded to handle both .js and .ts files. This includes checking if such files exist in the directory and running appropriate commands to compile them.
  • In ast.ts, the TextFile class and its related code have been removed. This may impact other parts of the system that rely on this class.
  • A new constant JS_REGEX has been added in constants.ts, which seems to be used for recognizing .js files.
  • The function importPrompt in importprompt.ts has seen changes. Specifically, an onImport function has been added for tracing file imports and a register function is being imported from the tsx/esm/api module which is used to register the onImport function for callbacks.
  • In file template.ts, the templateIdFromFileName function now considers .mts files in addition to the other types.
  • The activateModelCompletionProvider function in modelcompletionprovider.ts now uses the GENAI_ANYJS_GLOB constant, expanding the file types it supports.
  • The findScripts function in state.ts also now uses the GENAI_ANYJS_GLOB constant, expanding the file types it can find.

Overall, these changes seem to be aimed at expanding the types of scripts that can be handled by the system to include TypeScript files in addition to JavaScript ones. It also includes changes for better tracing of imports.

However, the removal of the TextFile class and related code in ast.ts might impact other parts of the system. Ensure that this class is not used elsewhere, or that all its usages have been properly refactored.

LGTM 🚀

generated by pr-review