-
Notifications
You must be signed in to change notification settings - Fork 0
LLM-1387: only update harness from now on #57
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,6 @@ import ( | |
| "k8s.io/klog/v2" | ||
|
|
||
| "github.com/castai/kimchi/internal/update" | ||
| "github.com/castai/kimchi/internal/version" | ||
| ) | ||
|
|
||
| type updateDoneMsg struct{ err error } | ||
|
|
@@ -52,10 +51,6 @@ func (m updateModel) View() string { | |
| return m.spinner.View() + " Updating to " + m.version + "...\n" | ||
| } | ||
|
|
||
| type updateResult struct { | ||
| cliUpdated bool | ||
| } | ||
|
|
||
| func NewUpdateCommand() *cobra.Command { | ||
| var ( | ||
| force bool | ||
|
|
@@ -78,58 +73,17 @@ func NewUpdateCommand() *cobra.Command { | |
| return cmd | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ℹ️🔧 Maintainability The 💡 Suggestion: Add a nil check before calling |
||
| } | ||
|
|
||
| func runUpdate(cmd *cobra.Command, force, dryRun, skipCache bool) (*updateResult, error) { | ||
| func runUpdate(cmd *cobra.Command, force, dryRun, skipCache bool) (*update.WorkflowResult, error) { | ||
| ctx := cmd.Context() | ||
| res := &updateResult{} | ||
|
|
||
| cliResult, err := runCLIUpdate(cmd, ctx, force, dryRun, skipCache) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| res.cliUpdated = cliResult.Updated | ||
|
|
||
| // CLI update is deprecated - only run harness update | ||
| klog.V(1).Info("checking for coding harness updates") | ||
| runHarnessUpdate(cmd, ctx, force, dryRun, skipCache) | ||
| return res, nil | ||
| } | ||
|
|
||
| func runCLIUpdate(cmd *cobra.Command, ctx context.Context, force, dryRun, skipCache bool) (*update.WorkflowResult, error) { | ||
| var opts []update.WorkflowOpt | ||
| if dryRun { | ||
| opts = append(opts, update.WithDryRun()) | ||
| } | ||
| if skipCache { | ||
| opts = append(opts, update.WithSkipUpdateCache()) | ||
| } | ||
|
|
||
| opts = append(opts, | ||
| update.WithCurrentVersionFn(func(ctx context.Context) (*semver.Version, error) { | ||
| if version.Version == "dev" { | ||
| return semver.MustParse("0.0.0-dev"), nil | ||
| } | ||
| return semver.NewVersion(version.Version) | ||
| }), | ||
| update.WithConfirmFn(func(current, latest *semver.Version) (bool, error) { | ||
| prompt := fmt.Sprintf("Kimchi update available: %s → %s\nUpdate? [Y/n]: ", current, latest) | ||
| return confirmAction(cmd, prompt, "Update skipped.", force), nil | ||
| }), | ||
| update.WithProgressFn(runUpdateWithSpinner), | ||
| ) | ||
| wf := update.NewCLIWorkflow(opts...) | ||
|
|
||
| result, err := wf.Run(ctx) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("check for kimchi updates: %w", err) | ||
| } | ||
|
|
||
| printUpdateResult(cmd, "CLI", result, dryRun) | ||
|
|
||
| return result, nil | ||
| return runHarnessUpdate(cmd, ctx, force, dryRun, skipCache) | ||
| } | ||
|
|
||
| // runHarnessUpdate checks for the coding harness and installs or updates it. | ||
| // Failures are reported as warnings and never block the CLI update. | ||
| func runHarnessUpdate(cmd *cobra.Command, ctx context.Context, force, dryRun, skipCache bool) { | ||
| func runHarnessUpdate(cmd *cobra.Command, ctx context.Context, force, dryRun, skipCache bool) (*update.WorkflowResult, error) { | ||
| var opts []update.WorkflowOpt | ||
| if dryRun { | ||
| opts = append(opts, update.WithDryRun()) | ||
|
|
@@ -153,10 +107,11 @@ func runHarnessUpdate(cmd *cobra.Command, ctx context.Context, force, dryRun, sk | |
| result, err := wf.Run(ctx) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment 💡 Suggestion: Update the comment to reflect the new behavior: |
||
| if err != nil { | ||
| _, _ = fmt.Fprintf(cmd.ErrOrStderr(), "Warning: %v\n", err) | ||
| return | ||
| return nil, err | ||
| } | ||
|
|
||
| printUpdateResult(cmd, "Coding harness", result, dryRun) | ||
| return result, nil | ||
| } | ||
|
|
||
| func printUpdateResult(cmd *cobra.Command, label string, result *update.WorkflowResult, dryRun bool) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
runUpdatenow propagates errors fromrunHarnessUpdateas fatal, whereas previouslyrunHarnessUpdatelogged warnings and continued. If the update check fails (e.g., network error, GitHub API unavailable), the entirekimchi harnesscommand fails and prevents launching the existing harness, degrading user experience.💡 Suggestion: Change the error handling to log a warning and continue instead of returning:
if err != nil { fmt.Fprintf(cmd.ErrOrStderr(), "Warning: harness update check failed: %v\n", err) } else if result != nil && result.Updated { ... }