An open-source, faster Devin alternative
TypeScript
feat(cli): focus agent deploy output
Igor Zalutski67185aa97d57
diff --git a/cmd/oc/internal/commands/agent_deploy.go b/cmd/oc/internal/commands/agent_deploy.goindex 6256c4ed..576b35ee 100644--- a/cmd/oc/internal/commands/agent_deploy.go+++ b/cmd/oc/internal/commands/agent_deploy.go@@ -207,15 +207,19 @@ func oneLine(value string) string {}, value)}-func terminalLink(rawURL string, enabled bool) string {+func terminalLink(rawURL string, style deployOutputStyle) string {visible := oneLine(rawURL)- if !enabled || visible != rawURL {+ if visible != rawURL {return visible}parsed, err := url.ParseRequestURI(rawURL)if err != nil || parsed.Scheme != "https" || parsed.Host == "" {return visible}+ visible = ansiText(visible, "4;36", style.color)+ if !style.hyperlinks {+ return visible+ }return "\x1b]8;;" + rawURL + "\x1b\\" + visible + "\x1b]8;;\x1b\\"}@@ -230,8 +234,8 @@ func renderDeploySuccess(w io.Writer, success deploySuccess, style deployOutputS}mark := ansiText("✓", "32", style.color)- title := ansiText("Deployed "+name, "1", style.color)- fmt.Fprintf(w, "%s %s\n\n", mark, title)+ title := "Deployed " + ansiText(name, "1", style.color)+ fmt.Fprintf(w, "%s %s\n", mark, title)status := oneLine(success.Status)statusCode := "32"@@ -249,17 +253,18 @@ func renderDeploySuccess(w io.Writer, success deploySuccess, style deployOutputSif digest := oneLine(success.Digest); digest != "" {revisionParts = append(revisionParts, digest)}- if len(revisionParts) > 0 {- fmt.Fprintf(w, " %-10s %s\n", "Revision", strings.Join(revisionParts, " · "))- }if success.Agent.InvokeURL != "" {- fmt.Fprintf(w, " %-10s %s\n", "Agent URL", terminalLink(success.Agent.InvokeURL, style.hyperlinks))+ fmt.Fprintf(w, "\n %s\n", ansiText("Agent URL", "1", style.color))+ fmt.Fprintf(w, " %s\n", terminalLink(success.Agent.InvokeURL, style))+ }+ if len(revisionParts) > 0 {+ fmt.Fprintf(w, "\n %-11s %s\n", "Revision", strings.Join(revisionParts, " · "))}if agentID != "" {manageURL := strings.TrimRight(config.DefaultAPIURL, "/") + "/agents/" + url.PathEscape(agentID)- fmt.Fprintf(w, " %-10s %s\n", "Manage", terminalLink(manageURL, style.hyperlinks))- fmt.Fprintf(w, "\n %s\n", ansiText("Run", "2", style.color))- fmt.Fprintf(w, " oc agent invoke %s --data '{\"message\":\"Hello\"}'\n", agentID)+ fmt.Fprintf(w, " %-11s %s\n", "Dashboard", terminalLink(manageURL, style))+ fmt.Fprintf(w, "\n %s\n", ansiText("Try it", "1", style.color))+ fmt.Fprintf(w, " %s oc agent invoke %s --data '{\"message\":\"Hello\"}'\n", ansiText("$", "2", style.color), agentID)}}@@ -297,8 +302,8 @@ func pollDeployment(cmd *cobra.Command, sc *client.Client, agentID, depID stringif err := sc.Get(cmd.Context(), "/v3/agents/"+agentID+"/deployments/"+depID, &d); err != nil {return d, err}- if d.State != last && stdinIsTTY() && !jsonOutput {- fmt.Fprintf(os.Stderr, " … %s\n", d.State)+ if d.State != last {+ printDeployProgress(d.State)}last = d.Stateif terminalState(d.State) {@@ -311,6 +316,12 @@ func pollDeployment(cmd *cobra.Command, sc *client.Client, agentID, depID string}}+func printDeployProgress(state string) {+ if stdinIsTTY() && !jsonOutput {+ fmt.Fprintf(os.Stderr, " … %s\n", state)+ }+}+// ── deploy ──var agentDeployCmd = &cobra.Command{@@ -736,6 +747,7 @@ func registerAgentDeploy() {agentDeployCmd.Flags().Bool("no-activate", false, "Create the revision without activating it (stage)")agentDeployCmd.Flags().String("idempotency-key", "", "CI-safe key: a retry with the same key returns the same deployment")agentDeployCmd.Flags().Int("timeout", 180, "Seconds to wait for a flue deploy to boot-verify (poll to terminal state)")+ agentDeployCmd.Flags().Bool("verbose", false, "Show full framework build output")for _, c := range []*cobra.Command{agentRevisionsCmd, agentRollbackCmd, agentStatusCmd, agentLinkCmd, agentUnlinkCmd, agentDeploymentsCmd, agentDeploymentCmd} {c.Flags().String("agent", "", "Target agent id or name (else the cwd agent.toml)")diff --git a/cmd/oc/internal/commands/agent_deploy_flue.go b/cmd/oc/internal/commands/agent_deploy_flue.goindex 724be606..eef1ba1b 100644--- a/cmd/oc/internal/commands/agent_deploy_flue.go+++ b/cmd/oc/internal/commands/agent_deploy_flue.go@@ -67,18 +67,39 @@ func deployFlue(cmd *cobra.Command, sc *client.Client, dir string, m *manifest,// 3–4. Build through the shared credential-free package. It extracts only// strict WfP metadata + regular modules and credential-scans the final bytes.+ verbose, _ := cmd.Flags().GetBool("verbose")+ var buildLog bytes.Buffer+ buildStdout, buildStderr := io.Writer(&buildLog), io.Writer(&buildLog)+ if verbose {+ buildStdout, buildStderr = os.Stderr, os.Stderr+ } else {+ printDeployProgress("building")+ }artifact, err := fluebuild.Build(cmd.Context(), fluebuild.Options{Dir: dir,Target: fluebuild.TargetCloudflare,BuilderVersion: Version,+ BuildStdout: buildStdout,+ BuildStderr: buildStderr,})if err != nil {+ if !verbose && buildLog.Len() > 0 {+ endsWithNewline := buildLog.Bytes()[buildLog.Len()-1] == '\n'+ fmt.Fprintln(os.Stderr, "Framework build output:")+ _, _ = io.Copy(os.Stderr, &buildLog)+ if !endsWithNewline {+ fmt.Fprintln(os.Stderr)+ }+ }return presentFlueBuildError(err)}digest := artifact.Deployment.Bundle.Digestwrangler := artifact.Deployment.Flue.Wrangler// 5. Upload: presigned PUT to R2 (the API host never sees the bytes).+ if !verbose {+ printDeployProgress("uploading")+ }if err := uploadArtifact(cmd.Context(), sc, id, digest, artifact.Bundle); err != nil {return err}diff --git a/cmd/oc/internal/commands/agent_deploy_flue_test.go b/cmd/oc/internal/commands/agent_deploy_flue_test.goindex 83c59f06..3ced6f88 100644--- a/cmd/oc/internal/commands/agent_deploy_flue_test.go+++ b/cmd/oc/internal/commands/agent_deploy_flue_test.go@@ -126,7 +126,7 @@ func TestDeployFlueDoEndToEnd(t *testing.T) {`{"lockfileVersion":3}`, 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\ntest \"${WRANGLER_LOG:-}\" = error\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\necho 'FLUE BUILD BANNER'\necho 'FLUE BUILD DETAIL' >&2\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" +@@ -175,15 +175,18 @@ func TestDeployFlueDoEndToEnd(t *testing.T) {}for _, want := range []string{"✓ Deployed e2e-flue\n",- "Revision active · " + shortDigest(expectedDigest) + "\n",- "Agent URL https://agt-0123456789abcdef01234567.agents.opencomputer.dev\n",- "Manage https://app.opencomputer.dev/agents/" + fakeAgentID + "\n",- "oc agent invoke " + fakeAgentID + " --data '{\"message\":\"Hello\"}'\n",+ "Agent URL\n https://agt-0123456789abcdef01234567.agents.opencomputer.dev\n",+ "Revision active · " + shortDigest(expectedDigest) + "\n",+ "Dashboard https://app.opencomputer.dev/agents/" + fakeAgentID + "\n",+ "$ oc agent invoke " + fakeAgentID + " --data '{\"message\":\"Hello\"}'\n",} {if !strings.Contains(humanOutput.String(), want) {t.Errorf("human deploy output missing %q:\n%s", want, humanOutput.String())}}+ if strings.Contains(humanOutput.String(), "FLUE BUILD") {+ t.Fatalf("framework build chatter leaked into the deploy result:\n%s", humanOutput.String())+ }// Agent created as flue, no prompt.if f.createBody["runtime"] != "flue" {diff --git a/cmd/oc/internal/commands/agent_deploy_handoff_test.go b/cmd/oc/internal/commands/agent_deploy_handoff_test.goindex 67ee24f0..95dc18a7 100644--- a/cmd/oc/internal/commands/agent_deploy_handoff_test.go+++ b/cmd/oc/internal/commands/agent_deploy_handoff_test.go@@ -69,11 +69,12 @@ func TestAgentDeployFreshAgentPrintsPublicHandoff(t *testing.T) {got := humanOutput.String()want := "✓ Deployed triage\n\n" +- " Revision 1 · active\n" +- " Agent URL https://agt-abcdef0123456789abcdef01.agents.opencomputer.dev\n" +- " Manage https://app.opencomputer.dev/agents/" + agentID + "\n\n" +- " Run\n" +- " oc agent invoke " + agentID + " --data '{\"message\":\"Hello\"}'\n"+ " Agent URL\n" ++ " https://agt-abcdef0123456789abcdef01.agents.opencomputer.dev\n\n" ++ " Revision 1 · active\n" ++ " Dashboard https://app.opencomputer.dev/agents/" + agentID + "\n\n" ++ " Try it\n" ++ " $ oc agent invoke " + agentID + " --data '{\"message\":\"Hello\"}'\n"if got != want {t.Fatalf("human deploy output mismatch:\n--- got ---\n%s--- want ---\n%s", got, want)}@@ -108,9 +109,9 @@ func TestDeploySuccessWithoutConvenienceReadStaysUseful(t *testing.T) {got := out.String()for _, want := range []string{"✓ Deployed agt_abcdef0123456789abcdef01",- "Revision 2 · active",- "Manage https://app.opencomputer.dev/agents/agt_abcdef0123456789abcdef01",- "oc agent invoke agt_abcdef0123456789abcdef01",+ "Revision 2 · active",+ "Dashboard https://app.opencomputer.dev/agents/agt_abcdef0123456789abcdef01",+ "$ oc agent invoke agt_abcdef0123456789abcdef01",} {if !strings.Contains(got, want) {t.Errorf("fallback output missing %q:\n%s", want, got)@@ -133,9 +134,10 @@ func TestDeploySuccessTTYStyleIsRestrainedAndLinked(t *testing.T) {got := out.String()for _, want := range []string{"\x1b[32m✓\x1b[0m",- "\x1b[1mDeployed triage\x1b[0m",+ "Deployed \x1b[1mtriage\x1b[0m",+ "\x1b[1mAgent URL\x1b[0m","3 · \x1b[33mstaged\x1b[0m · f42ea75bad3e",- "\x1b]8;;" + invokeURL + "\x1b\\" + invokeURL + "\x1b]8;;\x1b\\",+ "\x1b]8;;" + invokeURL + "\x1b\\\x1b[4;36m" + invokeURL + "\x1b[0m\x1b]8;;\x1b\\",} {if !strings.Contains(got, want) {t.Errorf("styled output missing %q:\n%q", want, got)@@ -144,7 +146,7 @@ func TestDeploySuccessTTYStyleIsRestrainedAndLinked(t *testing.T) {}func TestTerminalLinkRejectsControlSequenceInjection(t *testing.T) {- got := terminalLink("https://example.com/ok\x1b]8;;https://evil.example", true)+ got := terminalLink("https://example.com/ok\x1b]8;;https://evil.example", deployOutputStyle{color: true, hyperlinks: true})if strings.Contains(got, "\x1b") || !strings.Contains(got, "https://example.com/ok") {t.Fatalf("unsafe terminal link projection: %q", got)}