Fix CLI init and optimize flow regressions#2157
Open
mashraf-222 wants to merge 5 commits into
Open
Conversation
Contributor
Author
|
Reviewer CLI verification guide for this branch This branch now includes the original PR changes plus two follow-up fixes that are already on the PR branch:
Recommended setup
Commands to test
Things that can still happen but are not caused by this PR's code changes
What I would treat as the main reviewer smoke tests
|
Contributor
Author
|
I finished a Windows before/after review for the CLI behavior in this PR and uploaded the raw artifacts here: What is in the gist:
How I generated the logs:
Environment used for the review:
Main behavior changes I verified from the logs:
Two limits from this run:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked issue or discussion
Required: Fixes #1039
What changed
This PR fixes a set of CLI regressions across
init,init-actions,--show-config, and direct optimize entry points on Windows.The main changes are:
-y/--yesflag actually drive non-interactiveinitandinit-actionsflowsinit--show-configoutput for Java and Gocodeflash optimize --help--no-prinitcodeflash -y initregression so existing validpyproject.tomlconfigs are reused and CRLF files are not corruptedManual coverage was done in local sandboxes under
manual-cli-testing/for Python, JavaScript, TypeScript, Java, and Go.Bugs fixed
1. Telemetry and auth lookups could abort
initcodeflash -y initcould exit before the local setup flow started when telemetry or auth lookups failed.initflows continue, and invalid API keys only fail later when a backend call is actually needed.CODEFLASH_API_KEYto an invalid value and runuv run codeflash -y initin a sample repo. It should not exit during telemetry setup.2.
-y/--yesdid not makeinitandinit-actionsfully non-interactivecodeflash -y initstill hit prompts in multiple language-specific flows.yesflag was not threaded through the full init path, GitHub Actions setup, and the API-key prompt logic.codeflash -y initcompleted without prompts in Python, JavaScript, TypeScript, Java, and Go sandboxes.codeflash -y init-actionsalso ran non-interactively.uv run codeflash -y initanduv run codeflash -y init-actions.Note: this PR does not change argparse placement. The supported non-interactive form is still
codeflash -y init-actions, notcodeflash init-actions -y.3.
--show-configreported the wrong source and Python-oriented defaults for zero-config Java and Go projectsuv run codeflash --show-configin zero-config Java and Go projects could show Python-style defaults and present the config as if it came from a saved file.uv run codeflash --show-configand confirm the source is shown as auto-detected and the displayed values match the language.4.
codeflash optimize --helpcould route into runtime logic instead of only printing helpuv run codeflash optimize --helpdid not always stop at help output.uv run codeflash optimize --helpprints help and exits cleanly.uv run codeflash optimize --helpfrom the repo root and from a JavaScript or Java sample project. It should only print help text.5. Windows console output could crash on Unicode rendering
uv run codeflash --helporuv run codeflash -y init.6. Windows optimizer startup crashed when unsupported POSIX signals were registered
SIGHUP,SIGQUIT, orSIGPIPEare not supported there.uv run codeflash --file <file> --function <name> --no-pr -y -v.7.
--no-proptimization could crash in repos without anoriginremote--no-pr.uv run codeflash --file <file> --function <name> --no-pr -y.8. Missing Go parser support could break unrelated CLI commands
GoSupporteagerly instantiated the Go analyzer, so a missingtree_sitter_godependency could break CLI startup even when the user was not running a Go command.9. Windows JavaScript and TypeScript flows failed to resolve
npmandnpxwrappers correctly.cmdwrappers.npm.cmdandnpx.cmd. This PR adds a resolver and uses it across the JS/TS flows.codeflash -y initand direct optimize-entry commands in the JavaScript and TypeScript sandboxes now reach normal local execution instead of failing on command lookup.uv run codeflash -y initand a direct optimize command in a JavaScript or TypeScript project.10. Go projects were not supported by GitHub Actions workflow generation
initandinit-actionscan now generate a Go-specific workflow.go.mod, runuv run codeflash -y init-actionsand confirm the generated workflow sets up Go.11. Plain
initdid not let the user skip GitHub App installationcodeflash initalways entered the GitHub App installation flow when anoriginremote was present, even if the user wanted to continue without PR support.install_github_app()immediately prompted for installation instead of first asking whether the user wanted to skip it. This PR makes the GitHub App optional during plaininit.originset and no GitHub App installed, answeringnto the GitHub App prompt skips the install flow andinitstill completes.originset but no Codeflash GitHub App installed, runuv run codeflash initand answernwhen asked to install the app.12. Windows Python
codeflash -y initcould rewrite valid config and corrupt CRLFpyproject.toml[tool.codeflash]section,codeflash -y initalways rewrotepyproject.toml. On Windows CRLF files, that could introduce\r\r\nand then fail when the file was parsed again.skip_confirmpath bypassed the existing valid-config check and always called the auto-writer, and the TOML writer used newline-translating text mode. This PR reuses existing valid configs and writes TOML with newline-preserving file handles.D:\code\optimize-me,codeflash -y initexits0, leavespyproject.tomlbyte-for-byte unchanged, and creates the local workflowpyproject.tomland no Codeflash config,codeflash -y initwrites[tool.codeflash]successfully without producing\r\r\nuv run codeflash -y initin a Python repo with an existing valid config and in one with a CRLFpyproject.tomlbut no Codeflash config.Test plan
Automated verification:
248 passed, 12 skippedoptimize-mebaseline:41 passedinit:uv run pytest -q tests/test_init_auth.py tests/test_init_yes.py tests/test_init_java_go.py tests/test_init_javascript.py tests/test_github_workflow.py51 passed-y initregression:uv run pytest -q tests/test_init_yes.py tests/test_setup/test_config.py tests/test_setup/test_e2e_setup.py tests/test_init_java_go.py tests/test_init_javascript.py114 passedManual verification:
uv run codeflash --show-configin Python, Java, and Go sandboxesuv run codeflash -y initin Python, JavaScript, TypeScript, Java, and Go sandboxesuv run codeflash initin a Python sandbox withoriginset and no GitHub App installed, and verified that answeringnskips GitHub App installation and still completes setupuv run codeflash -y init-actionsin Python and Go sandboxesObserved manual end states:
No optimizations foundgradlewvsgradlew.bat), which is outside the scope of this PR