Skip to content

cli: preflight git check and network retries in openui create - #1223

Merged
AbhinRustagi merged 13 commits into
mainfrom
devin/1790073688-cli-create-preflight-retry
Sep 23, 2026
Merged

AbhinRustagi merged 13 commits into
mainfrom
devin/1790073688-cli-create-preflight-retry

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

What

openui create could fail in ways that were avoidable or poorly explained:

  • If git isn't installed (common on Windows), the CLI only found out when git init was spawned, and printed a generic "git is not installed or not found in PATH."
  • Transient network errors during the template/example sparse checkout, the catalog fetch, or dependency install failed the whole run on the first attempt.
  • Any non-CreateError thrown while resolving the template source was labelled as a network TEMPLATE_MISSING failure, even when it was a filesystem error.

This PR fails fast with an actionable message when git is missing, retries network-class failures with exponential backoff, and makes retries visible in telemetry. The existing failure_stage / error_code taxonomy is unchanged (no new codes).

Changes

  • Git preflight — new lib/git-preflight.ts: ensureGitAvailable() spawns git --version at the start of runCreateApp (skipped in OPENUI_SOURCE_DIR debug mode). On ENOENT it throws CreateError("preflight", …, "process", "GIT_MISSING") with a per-OS hint (winget/choco/git-scm link on Windows, brew/xcode-select on macOS, apt/dnf on Linux). The same message is reused by runGit's ENOENT branch.
  • Retry helper — new lib/retry.ts:
    withRetry(label, fn, options?)
    // options: { maxAttempts = 3, baseDelayMs = 1000 /* 1s, 2s */, shouldRetry = isNetworkError, onRetry, sleep }
    isNetworkError(err) // CreateError with errorClass === "network"
    Each retry logs "<label> failed (<code>); retrying in Ns (attempt i/3)...". On final failure it stamps errorMetadata.attempts on the CreateError, so cli_create_failed / cli_dependency_install_failed now carry an attempts property.
  • Applied to: the whole git sparse-checkout sequence in checkoutSource (fresh temp dir per attempt), the raw.githubusercontent catalog fetch in fetchSourceFile, and the dependency install in installProjectDependencies. Only network-class errors retry; GIT_MISSING (process), PERMISSION_DENIED/SOURCE_MISSING (filesystem) and cancellations do not. The 404 SOURCE_MISSING from fetchSourceFile is now classified filesystem (matching checkoutSource) so a bad path isn't retried.
  • Telemetry — new cli_network_retry event (failure_stage, attempt, max_attempts, delay_ms, error_class, error_code), emitted by Telemetry.reportNetworkRetry(stage) on the base class in lib/telemetry.ts; callers pass tel.reportNetworkRetry("source_checkout" | "dependency_install") as onRetry, threaded through loadCreateCatalog → catalog loaders, resolveTemplateSource, and scaffoldExample.
  • TEMPLATE_MISSING — throwTemplateSourceError() classifies non-CreateError failures via cliErrorProperties, so errno errors become filesystem/PERMISSION_DENIED etc.; the true network fallback now says Could not download template "<name>" from GitHub: … Check your network connection and try again. (Unknown template names were already rejected earlier as INVALID_TEMPLATE.)
  • Network error messages in runGit / fetchSourceFile now include a "check your network connection" hint.
  • Changeset (patch) included.

Test Plan

  • Verified locally
    • pnpm --filter @openuidev/cli lint:check, format:check, build pass
    • OPENUI_DEBUG=1 OPENUI_SOURCE_DIR=… node dist/index.js create --help still works
    • Retry helper, git preflight (nonexistent binary → GIT_MISSING with Windows hint) and template-source error classification were exercised with ad-hoc unit tests during development (not committed)
  • Not verified on a real Windows box without git.

Checklist

  • I linked a related issue, if applicable
  • I updated docs/README when needed (changeset added; no README changes needed)
  • I considered backwards compatibility (no new error codes; attempts and cli_network_retry are additive telemetry)

Link to Devin session: https://app.devin.ai/sessions/a4b6312c6116461a8911fb7e6995da11
Open in Devin Desktop: https://app.devin.ai/desktop/session/a4b6312c6116461a8911fb7e6995da11?variant=devin
Requested by: @zahlekhan

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@vercel

vercel Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
openui-docs Ready Ready Preview Sep 23, 2026 10:23am UTC

Request Review

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Comment thread packages/openui-cli/src/commands/create/lib/telemetry.ts Outdated
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Comment thread packages/openui-cli/src/lib/telemetry.ts Outdated
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Comment thread packages/openui-cli/src/lib/retry.ts Outdated
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Comment thread packages/openui-cli/src/lib/checkout.ts Outdated
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Comment thread packages/openui-cli/src/lib/scaffold/source.ts Outdated
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@AbhinRustagi

Copy link
Copy Markdown
Contributor

CI checks are failing, take a pull

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

Merged main into the branch (244d350); CI re-running.

Comment thread packages/openui-cli/src/lib/telemetry.ts Outdated
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Comment thread packages/openui-cli/src/lib/telemetry.ts Outdated
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Comment thread packages/openui-cli/src/lib/retry.ts
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Comment thread packages/openui-cli/src/lib/checkout.ts Outdated
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Comment thread packages/openui-cli/src/commands/create/lib/install.ts Outdated
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@AbhinRustagi
AbhinRustagi merged commit b7d6a72 into main Sep 23, 2026
43 checks passed
@AbhinRustagi
AbhinRustagi deleted the devin/1790073688-cli-create-preflight-retry branch September 23, 2026 10:36

This branch was successfully deployed

1 active deployment
Preview — c4494e9d Deployed Sep 23, 2026 by vercel[bot]
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.

2 participants