Skip to content

auto-init local app commands#267

Merged
osbornm merged 2 commits into
mainfrom
feat/auto-init
May 7, 2026
Merged

auto-init local app commands#267
osbornm merged 2 commits into
mainfrom
feat/auto-init

Conversation

@osbornm

@osbornm osbornm commented May 7, 2026

Copy link
Copy Markdown
Member

Summary

  • Add an auto-init guard for commands that require local app .hx config.
  • Invoke standard app init directly when local app config is missing, then continue the original command.
  • Keep config loading scoped to validation instead of introducing shared command-wide config caching.
  • Add focused auto-init tests and make auto-update config tests respect Windows USERPROFILE.

Validation

  • go test ./cmd/autoinit
  • go test ./... with isolated temporary HOME/USERPROFILE

@osbornm osbornm requested a review from Copilot May 7, 2026 13:56
@osbornm osbornm marked this pull request as ready for review May 7, 2026 13:56
@osbornm osbornm changed the title [codex] auto-init local app commands auto-init local app commands May 7, 2026
@osbornm osbornm changed the title auto-init local app commands feat: auto-init local app commands May 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces an auto-init guard that detects missing/incomplete local .hx app config for commands that require it, optionally runs interactive initialization, and then continues the original command. It also refactors init-app execution to support error-returning execution and updates config tests to behave correctly on Windows home directory resolution.

Changes:

  • Add cmd/autoinit with Ensure() invoked from the root persistent pre-run hook to auto-initialize local app config when required.
  • Refactor initapp to expose RunInitAppE (error-returning) and keep RunInitApp as a printing wrapper.
  • Update auto-update config tests to set both HOME and USERPROFILE for Windows compatibility.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/config/config_autoupdate_test.go Adds a helper to set HOME + USERPROFILE for cross-platform global-config tests.
cmd/root.go Hooks auto-init guard into root command execution via PersistentPreRunE.
cmd/initapp/initapp.go Introduces RunInitAppE and updates init flow to return errors instead of printing+returning early.
cmd/autoinit/autoinit.go New auto-init guard: detects missing/incomplete local config, optionally runs init, revalidates.
cmd/autoinit/autoinit_test.go New unit tests covering config completeness detection, command matching, and auto-init behaviors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/autoinit/autoinit.go Outdated
Comment thread cmd/autoinit/autoinit.go Outdated
Comment thread cmd/autoinit/autoinit.go

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces an autoinit package to handle missing local app configurations, integrates it into the CLI's global pre-run logic, and adds performance timing recording to env pull and env push operations. Additionally, concurrency has been implemented for environment operations to improve performance. The reviewer correctly identified that several references to the renamed cfg variable in cmd/env/pull/pull.go need to be updated to ensure the code uses the local configuration instance rather than the package name.

I am having trouble creating individual review comments. Click here to see my feedback.

cmd/env/pull/pull.go (158)

medium

Update reference to the renamed cfg variable to avoid shadowing issues.

		secretValue, _, err = secret.LoadSecret(cfg.OrganizationId, *cfg.ProjectId)

cmd/env/pull/pull.go (166)

medium

Update reference to the renamed cfg variable to avoid shadowing issues.

		pulledEnvs, err := service.getAllEnvsAndDecryptIntoFiles(orgId, appId, projectId, secretValue, cfg, forceFlag, recorder)

cmd/env/pull/pull.go (176)

medium

Update reference to the renamed cfg variable to avoid shadowing issues.

		if err = service.saveDecryptedEnvIntoFile(orgId, "default", appId, secretValue, cfg, forceFlag, nil, recorder); err != nil {

cmd/env/pull/pull.go (189)

medium

Update reference to the renamed cfg variable to avoid shadowing issues.

		if err = service.saveDecryptedEnvIntoFile(orgId, envName, appId, secretValue, cfg, forceFlag, nil, recorder); err != nil {

@osbornm osbornm changed the title feat: auto-init local app commands auto-init local app commands May 7, 2026
@osbornm osbornm linked an issue May 7, 2026 that may be closed by this pull request

osbornm commented May 7, 2026

Copy link
Copy Markdown
Member Author

Response to Gemini review: I’m not applying the cmd/env/pull suggestions here. Those comments refer to env-speed changes that are not part of the current feat/auto-init branch or PR diff. Pulling them into this PR would mix unrelated work into the auto-init change; the current branch test suite passes without touching cmd/env/pull.go.

@kylekampy kylekampy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems fine to me

@osbornm osbornm merged commit 962239d into main May 7, 2026
6 checks passed
@osbornm osbornm deleted the feat/auto-init branch May 7, 2026 18:38
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.

[Magic List] Auto run hx init

3 participants