Skip to content

An open-source, faster Devin alternative

TypeScript

fix(cli): quiet non-actionable Flue deploy noise

Igor Zalutskib0f913f4d30e
diff --git a/cmd/oc/internal/commands/agent_deploy_flue.go b/cmd/oc/internal/commands/agent_deploy_flue.go
index c44f0227..e5c58ff0 100644
--- a/cmd/oc/internal/commands/agent_deploy_flue.go
+++ b/cmd/oc/internal/commands/agent_deploy_flue.go
@@ -213,6 +213,7 @@ func runFlueBuild(ctx context.Context, dir string) error {
c = exec.CommandContext(ctx, "npx", append([]string{"--no-install", "flue"}, args...)...)
}
c.Dir = dir
+ c.Env = flueBuildEnv()
c.Stdout = os.Stderr
c.Stderr = os.Stderr
// No stdin: `flue build` is a non-interactive bundler, and wiring the terminal
@@ -223,6 +224,29 @@ func runFlueBuild(ctx context.Context, dir string) error {
return nil
}
+// flueBuildEnv keeps Wrangler's platform-deployment warnings out of `oc agent
+// deploy`. OpenComputer consumes a strict subset of the generated descriptor and
+// owns the eventual Worker-for-Platforms composition, so warnings about directly
+// deploying that scratch Wrangler config (notably declarative Durable Object
+// exports) are not actionable here. Errors still print. An explicit
+// WRANGLER_LOG setting wins, which leaves a debugging escape hatch.
+func flueBuildEnv() []string {
+ const key = "WRANGLER_LOG"
+ const fallback = key + "=error"
+ env := os.Environ()
+ prefix := key + "="
+ for i, value := range env {
+ if !strings.HasPrefix(value, prefix) {
+ continue
+ }
+ if value == prefix {
+ env[i] = fallback
+ }
+ return env
+ }
+ return append(env, fallback)
+}
+
// readFlueBundle locates the generated wrangler, extracts the exact Flue descriptor,
// and reads only regular .js/.mjs modules rooted at the wrangler's directory. The raw
// wrangler resolution dump, .vite state and source maps are known control artifacts and
diff --git a/cmd/oc/internal/commands/agent_deploy_flue_test.go b/cmd/oc/internal/commands/agent_deploy_flue_test.go
index 14b32cdc..5a925c7c 100644
--- a/cmd/oc/internal/commands/agent_deploy_flue_test.go
+++ b/cmd/oc/internal/commands/agent_deploy_flue_test.go
@@ -107,6 +107,7 @@ func TestDeployFlueDoEndToEnd(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("fake flue build is a POSIX shell script")
}
+ t.Setenv("WRANGLER_LOG", "")
// A Flue app dir: manifest + clean source + a stand-in `flue` bin whose
// `build --target cloudflare` writes a deterministic but noisy dist/e2e_flue/.
@@ -115,7 +116,7 @@ func TestDeployFlueDoEndToEnd(t *testing.T) {
"name = \"e2e-flue\"\nmodel = \"anthropic/claude-sonnet-5\"\n\n[runtime]\nfamily = \"flue\"\n", 0o644)
writeFile(t, filepath.Join(dir, "src", "opencomputer.ts"),
"import { serveOC } from '@opencomputer/flue';\nexport default serveOC(agent);\n", 0o644)
- buildScript := "#!/bin/sh\nset -e\nmkdir -p dist/e2e_flue/assets dist/e2e_flue/.vite dist/e2e_flue/.flue-vite\n" +
+ buildScript := "#!/bin/sh\nset -e\ntest \"${WRANGLER_LOG:-}\" = error\nmkdir -p dist/e2e_flue/assets dist/e2e_flue/.vite dist/e2e_flue/.flue-vite\n" +
"cat > dist/e2e_flue/index.js <<'JS'\n" + e2eModuleBody + "\nJS\n" +
"cat > dist/e2e_flue/assets/chunk.js <<'JS'\n" + e2eAssetBody + "\nJS\n" +
"cat > dist/e2e_flue/.flue-vite/runtime.mjs <<'JS'\n" + e2eRuntimeBody + "\nJS\n" +
@@ -251,6 +252,16 @@ func TestDeployFlueDoEndToEnd(t *testing.T) {
}
}
+func TestFlueBuildEnvPreservesExplicitWranglerLog(t *testing.T) {
+ t.Setenv("WRANGLER_LOG", "debug")
+ for _, value := range flueBuildEnv() {
+ if value == "WRANGLER_LOG=debug" {
+ return
+ }
+ }
+ t.Fatal("flueBuildEnv did not preserve explicit WRANGLER_LOG=debug")
+}
+
func TestExtractFlueWranglerDescriptorRejectsCapabilityVariation(t *testing.T) {
valid := func() map[string]any {
var value map[string]any
diff --git a/cmd/oc/internal/commands/update_check.go b/cmd/oc/internal/commands/update_check.go
index 74ed655e..f71159b4 100644
--- a/cmd/oc/internal/commands/update_check.go
+++ b/cmd/oc/internal/commands/update_check.go
@@ -29,7 +29,7 @@ type updateCheckCache struct {
// per 24h. Any error bails silently — the CLI must never block or warn
// on a failed version check.
func maybePromptUpdate() {
- if Version == "dev" {
+ if !isReleaseVersion(Version) {
return
}
if os.Getenv("OC_NO_UPDATE_CHECK") != "" {
@@ -75,6 +75,27 @@ func maybePromptUpdate() {
}
}
+// isReleaseVersion distinguishes published dotted-numeric versions from local
+// builds labelled with a branch, commit, or the default "dev". Comparing a label
+// such as "flue-native-67bf0ee" as numeric zero produces a bogus update nag.
+func isReleaseVersion(version string) bool {
+ parts := strings.Split(version, ".")
+ if len(parts) < 2 {
+ return false
+ }
+ for _, part := range parts {
+ if part == "" {
+ return false
+ }
+ for _, r := range part {
+ if r < '0' || r > '9' {
+ return false
+ }
+ }
+ }
+ return true
+}
+
func updateCheckCachePath() (string, error) {
dir, err := os.UserCacheDir()
if err != nil {
diff --git a/cmd/oc/internal/commands/update_check_test.go b/cmd/oc/internal/commands/update_check_test.go
new file mode 100644
index 00000000..2e461b02
--- /dev/null
+++ b/cmd/oc/internal/commands/update_check_test.go
@@ -0,0 +1,26 @@
+package commands
+
+import "testing"
+
+func TestIsReleaseVersion(t *testing.T) {
+ t.Parallel()
+ cases := map[string]bool{
+ "0.6.0.8": true,
+ "1.0": true,
+ "dev": false,
+ "flue-native-67bf0ee": false,
+ "0.6.0.8-dirty": false,
+ "v0.6.0.8": false,
+ "0": false,
+ "0..8": false,
+ }
+ for version, want := range cases {
+ version, want := version, want
+ t.Run(version, func(t *testing.T) {
+ t.Parallel()
+ if got := isReleaseVersion(version); got != want {
+ t.Fatalf("isReleaseVersion(%q) = %v, want %v", version, got, want)
+ }
+ })
+ }
+}