From f72facb9e5d345a112b221ba941b40dfd0b6ba89 Mon Sep 17 00:00:00 2001 From: Dhruv Sharma Date: Sun, 31 May 2026 21:37:43 +0530 Subject: [PATCH] fix(cli): address greptile review comments --- backend/go.mod | 2 +- backend/internal/cli/completion.go | 7 ++++--- backend/internal/cli/process_windows.go | 21 +++++++++++++++++---- docs/cli/README.md | 5 ++--- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/backend/go.mod b/backend/go.mod index adc560394..a2de66a0a 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -8,6 +8,7 @@ require ( github.com/go-chi/chi/v5 v5.1.0 github.com/pressly/goose/v3 v3.27.1 github.com/spf13/cobra v1.10.1 + golang.org/x/sys v0.43.0 gopkg.in/yaml.v3 v3.0.1 modernc.org/sqlite v1.51.0 ) @@ -24,7 +25,6 @@ require ( github.com/spf13/pflag v1.0.9 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/sync v0.20.0 // indirect - golang.org/x/sys v0.43.0 // indirect modernc.org/libc v1.72.3 // indirect modernc.org/mathutil v1.7.1 // indirect modernc.org/memory v1.11.0 // indirect diff --git a/backend/internal/cli/completion.go b/backend/internal/cli/completion.go index 97970395a..61b9483ef 100644 --- a/backend/internal/cli/completion.go +++ b/backend/internal/cli/completion.go @@ -8,9 +8,10 @@ import ( func newCompletionCommand() *cobra.Command { return &cobra.Command{ - Use: "completion [bash|zsh|fish|powershell]", - Short: "Generate shell completion scripts", - Args: cobra.ExactArgs(1), + Use: "completion [bash|zsh|fish|powershell]", + Short: "Generate shell completion scripts", + Args: cobra.ExactArgs(1), + ValidArgs: []string{"bash", "zsh", "fish", "powershell"}, RunE: func(cmd *cobra.Command, args []string) error { root := cmd.Root() out := cmd.OutOrStdout() diff --git a/backend/internal/cli/process_windows.go b/backend/internal/cli/process_windows.go index da109f116..430cea8bf 100644 --- a/backend/internal/cli/process_windows.go +++ b/backend/internal/cli/process_windows.go @@ -2,18 +2,31 @@ package cli -import "os" +import ( + "errors" + "os" + + "golang.org/x/sys/windows" +) func processAlive(pid int) bool { if pid <= 0 { return false } - p, err := os.FindProcess(pid) + handle, err := windows.OpenProcess(windows.SYNCHRONIZE, false, uint32(pid)) + if err != nil { + if errors.Is(err, windows.ERROR_ACCESS_DENIED) { + return true + } + return false + } + defer windows.CloseHandle(handle) + + status, err := windows.WaitForSingleObject(handle, 0) if err != nil { return false } - _ = p.Release() - return true + return status == uint32(windows.WAIT_TIMEOUT) } func signalTerm(pid int) error { diff --git a/docs/cli/README.md b/docs/cli/README.md index 3d49e00d5..dd83c306e 100644 --- a/docs/cli/README.md +++ b/docs/cli/README.md @@ -103,9 +103,8 @@ logic in-process. The rewrite needs the CLI to sit outside the core daemon. ## Current Legacy CLI Inventory -Inventory source: installed `ao` binary at version `0.9.2`, plus -`/Users/dhruvsharma/Development/agent-orchestrator/packages/cli/src/program.ts` -and `packages/cli/src/commands/*.ts`. +Inventory source: installed `ao` binary at version `0.9.2`, plus the old +`packages/cli/src/program.ts` and `packages/cli/src/commands/*.ts` files. Count: