Skip to content

refactor(cli): Librarify nova_cli to avoid code duplication#916

Merged
aapoalas merged 1 commit intotrynova:mainfrom
niluxv:librarify-cli
Feb 21, 2026
Merged

refactor(cli): Librarify nova_cli to avoid code duplication#916
aapoalas merged 1 commit intotrynova:mainfrom
niluxv:librarify-cli

Conversation

@niluxv
Copy link
Contributor

@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
@niluxv niluxv force-pushed the librarify-cli branch 2 times, most recently from 5bcfde9 to 0dbdc3a Compare December 14, 2025 13:38
@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.

@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
Contributor 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!

@niluxv
Copy link
Contributor Author

niluxv commented Jan 3, 2026

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!

Done.

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.
@aapoalas
Copy link
Member

@niluxv Sorry it took me so long to get back to you! I rebased the code again and will merge once the tests show the all green.

Thank you so much for this, this is great! <3

@aapoalas aapoalas merged commit d441adb into trynova:main Feb 21, 2026
8 checks passed
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