Skip to content

Conversation

@niluxv
Copy link

@niluxv niluxv commented Dec 14, 2025

Right now this is mostly moving code around, so the benchmark runner (which I have in a separate branch) can share most of its code with the cli. I have no idea whether this library could be useful for users of nova as well, I don't really know their requirements, but I assume the current setup is not flexible enough for that. (For example, currently everything assumes there is only one realm.)

The benchmark runner needs to separately parse and execute scripts, while the cli can just immediately execute a parsed script, which is why I haven't touched the script parsing and execution logic of the cli. However, maybe we can store a list of parsed but not yet executed scripts in HostDefined (alongside the module map of already executed modules, or maybe merge them?), and then implement convenience commands for script/module parsing and execution for the Instance. Or maybe that is overly complicated and it is better to leave this work to the library user.

I would love to hear any suggestions, as I find myself really struggling to provide a flexible and convenient API.

@niluxv niluxv changed the title [WIP] Librarify nova_cli to avoid code duplication [WIP] refactor(cli): Librarify nova_cli to avoid code duplication Dec 14, 2025
This already factored out some logic that was duplicated between the
`eval` and `repl` subcommands. However, the real goal is to provide a
library the benchmark runner can use, to avoid code duplication there.
@load1n9 load1n9 self-requested a review December 27, 2025 22:08
load1n9
load1n9 previously approved these changes Dec 27, 2025
Copy link
Member

@load1n9 load1n9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: nice warningimage

LGTM!

@load1n9 load1n9 requested a review from aapoalas December 27, 2025 22:10
aapoalas
aapoalas previously approved these changes Jan 2, 2026
Copy link
Member

@aapoalas aapoalas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me: I don't unfortunately have any particularly good ideas about what a more generic API would look like. Storing parsed-but-not-executed Scripts could indeed be done using Global<Script>s, but I don't have a handle on if that would work nicely for a benchmarking CLI or not.

I'd be happy to merge this as-is; I kind of expect that figuring out the correct API is something that can only be done through experiment.

) {
let specifier = module_request.specifier(agent);
let specifier = specifier.to_string_lossy(agent);
let specifier_target = if let Some(specifier) = specifier.strip_prefix("./") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: I wonder if some of this code would belong in the ModuleMap now?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, good catch. Yes, that makes a lot of sense.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to say: sorry it took so long for me to review this <3

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely no problem, I was busy as well so it was a blessing, not a curse ;)

@niluxv niluxv dismissed stale reviews from load1n9 and aapoalas via 6668489 January 2, 2026 19:53
@niluxv niluxv changed the title [WIP] refactor(cli): Librarify nova_cli to avoid code duplication refactor(cli): Librarify nova_cli to avoid code duplication Jan 2, 2026
@niluxv
Copy link
Author

niluxv commented Jan 2, 2026

Ok, indeed we can further experiment after this is merged; the no semver guarantee gives us flexibility there. And it would be quite a nightmare to merge/rebase this if someone makes significant changes to the cli code in the meantime...

How about I rebase this on top of main so we lose the merge commit, and squash my two commits together?

@aapoalas
Copy link
Member

aapoalas commented Jan 2, 2026

Ok, indeed we can further experiment after this is merged; the no semver guarantee gives us flexibility there. And it would be quite a nightmare to merge/rebase this if someone makes significant changes to the cli code in the meantime...

How about I rebase this on top of main so we lose the merge commit, and squash my two commits together?

Sounds good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants