microsoft / genaiscript

Generative AI Scripting
https://microsoft.github.io/genaiscript/
MIT License
81 stars 22 forks source link

support for module .mjs files #561

Closed pelikhan closed 4 days ago

pelikhan commented 1 week ago

generated by pr-describe

pelikhan commented 1 week ago

/genai-describe /genai-review

pelikhan commented 6 days ago

/genai-describe /genai-review

pelikhan commented 5 days ago

/genai-describe /genai-review

github-actions[bot] commented 5 days ago

The pull request primarily involves a significant refactor of the TypeScript codebase. There are several notable changes:

  1. A new utility function randomHex is introduced in crypto.ts. This function generates a random hexadecimal string of a given size.
  2. The GENAI_JS_REGEX constant used for matching file extensions is replaced with GENAI_ANYJS_REGEX which presumably allows for more flexibility in file types.
  3. The batchScript, buildProject, and runScript functions have been modified. In particular, runScript has been split into runScript and runScriptWithExitCode, which separates the functionality of running the script and handling the exit code.
  4. The Fragment class structure and related operations in ast.ts have been significantly simplified.
  5. The parseProject function in parser.ts has been simplified by removing several operations related to fragment parsing.
  6. A new class AbortSignalCancellationController is introduced in cancellation.ts, which presumably enhances the handling of cancellation signals.
  7. The importPrompt function in importprompt.ts now supports tracing and has been adjusted to import scripts as ES modules rather than CommonJS modules.
  8. In expander.ts, the expandTemplate function no longer receives a Fragment instance as parameter, instead it receives a simple Fragment representing file paths.
  9. In run.ts, runScript function now also returns the exit code and the result of the script, rather than exiting the process directly.
  10. Modifications in server.ts to handle the starting and aborting of scripts.

From the changes, it seems that the codebase is undergoing a shift towards more modern and flexible approaches (like ES modules instead of CommonJS, handling exit codes more gracefully, better cancellation handling, etc.).

However, without the full context or knowledge of the previous issues faced, it's hard to evaluate if these changes indeed address specific problems or if they introduce new ones.

In general, these changes look reasonable and appear to be improvements to the codebase. LGTM :rocket:.

generated by pr-review

pelikhan commented 4 days ago

/genai-test