-
Notifications
You must be signed in to change notification settings - Fork 190
Add @genaiscript/globals #1632
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/globals #1632
Conversation
pelikhan
commented
Jun 23, 2025
- Add helper package to load globals
- Figure out types?
@mattpodwysocki we should figure out a way to package the typings in this helper package. |
@@ -20,5 +20,5 @@ export function resolveGlobal(): any { | |||
else if (typeof self !== "undefined") | |||
return self; // Web worker environment | |||
else if (typeof global !== "undefined") return global; // Node.js environment | |||
throw new Error("Could not find global"); // Error if no global context is found | |||
return globalThis; |
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.
Changing the error throw to return globalThis
alters the function's semantics: it now silently returns globalThis
even if none of the explicit checks matched, which could mask environment issues. Consider if this fallback is truly safe for all intended environments.
AI-generated content by pr-review-commit
global_fallback_semantics
may be incorrect. Use reactions to eval.
@@ -0,0 +1,8 @@ | |||
#!/usr/bin/env node |
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.
Shebang (#!/usr/bin/env node
) is present in a TypeScript file. TypeScript compilers do not preserve shebangs, and this may cause issues if the file is compiled and then executed. Consider moving the shebang to the compiled output or using a JavaScript entry point.
AI-generated content by pr-review-commit
shebang_in_typescript
may be incorrect. Use reactions to eval.
|
||
import { installGlobals } from "@genaiscript/core"; | ||
|
||
installGlobals(); |
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.
Calling installGlobals()
at the top level causes side effects on import, which can lead to unpredictable behavior if this module is imported elsewhere. Consider exporting a function to explicitly install globals instead.
AI-generated content by pr-review-commit
side_effect_import
may be incorrect. Use reactions to eval.
Investigator reportContext collection
AI Analysis
|