Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ require (

// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.13.1-0.20260428071432-1e9d9a1991ad

// replace github.com/jfrog/jfrog-cli-core/v2 => github.com/agrasth/jfrog-cli-core/v2 v2.0.0-20260428093456-2bc01db3b153
replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260504103316-aaa4fda381f7

//replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.54.2-0.20251007084958-5eeaa42c31a6

Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,8 @@ github.com/jfrog/jfrog-cli-application v1.0.2-0.20260405065840-c930d515ef34 h1:q
github.com/jfrog/jfrog-cli-application v1.0.2-0.20260405065840-c930d515ef34/go.mod h1:xum2HquWO5uExa/A7MQs3TgJJVEeoqTR+6Z4mfBr1Xw=
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260429074430-a5871f2898b5 h1:+52DDmdSZFP1dxgeu0pkB1sQuoHa0PWbW7HVdFOqK3A=
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260429074430-a5871f2898b5/go.mod h1:BV+aCTQsaZeFec2WjgmQjqlxecju4CkkM9NqfiFyjo0=
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260430091103-6242ecf15d29 h1:J5+08rOpv/avgt53jNFZ+j5gU8mllcj7Dcfja5Ewodw=
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260430091103-6242ecf15d29/go.mod h1:bjAkVD8c2W+jg4whqy10bSXDC/c+Se8/ll/GPp5F/+0=
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260430125911-ad12ac6f1316 h1:xAl5D+SjLeRH1gCsSHFPpXJeQQBv2HDGqDTDkFOKJ2s=
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260430125911-ad12ac6f1316/go.mod h1:bjAkVD8c2W+jg4whqy10bSXDC/c+Se8/ll/GPp5F/+0=
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260504103316-aaa4fda381f7 h1:ZQJGuIkQyZUNpyb7H0PCq88Rw/1KCXUjOruuY6kPhWo=
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260504103316-aaa4fda381f7/go.mod h1:bjAkVD8c2W+jg4whqy10bSXDC/c+Se8/ll/GPp5F/+0=
github.com/jfrog/jfrog-cli-evidence v0.9.2 h1:huiBzQSI9z3OF3l2RphthdXl1aH9zBsvAt+zLsApORI=
github.com/jfrog/jfrog-cli-evidence v0.9.2/go.mod h1:R9faPfyQESBmKrdZCmHvlpmYSHmffswjNnFeT3RMq8I=
github.com/jfrog/jfrog-cli-platform-services v1.10.1-0.20260430094150-ce7d9b371c6f h1:M1cesbKYSznwPA76dNctjCELxGx34TSSjwoYnJm9/6Y=
Expand Down
39 changes: 32 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
appTrustCLI "github.com/jfrog/jfrog-cli-application/cli"
artifactoryCLI "github.com/jfrog/jfrog-cli-artifactory/cli"
corecommon "github.com/jfrog/jfrog-cli-core/v2/docs/common"
corecommands "github.com/jfrog/jfrog-cli-core/v2/common/commands"
"github.com/jfrog/jfrog-cli-core/v2/plugins/components"
coreconfig "github.com/jfrog/jfrog-cli-core/v2/utils/config"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
Expand Down Expand Up @@ -89,8 +90,8 @@ func execMain() error {
return err
}

// Set JFrog CLI's user-agent on the jfrog-client-go.
clientutils.SetUserAgent(coreutils.GetCliUserAgent())
// Set JFrog CLI's user-agent on the jfrog-client-go, enriched with invoker info.
clientutils.SetUserAgent(buildEnrichedUserAgent(corecommands.DetectExecutionContext()))

app := cli.NewApp()
app.Name = jfrogAppName
Expand Down Expand Up @@ -165,19 +166,43 @@ func displaySurveyLinkIfNeeded() {
fmt.Fprintln(os.Stderr, "\n💬 Help us improve JFrog CLI! \033]8;;https://www.surveymonkey.com/r/JFCLICLI\033\\https://www.surveymonkey.com/r/JFCLICLI\033]8;;\033\\")
}

// This command generates and sets an Uber Trace ID token which will be attached as a header to every request.
// This command sets an Uber Trace ID token which will be attached as a header to every request.
// If the parent agent (e.g. Cursor) propagates a trace ID via env, reuse it so server-side logs
// correlate end-to-end with the agent's trace. Otherwise generate a fresh one.
// This allows users to easily identify which logs on the server side are related to the command executed by the CLI.
func setUberTraceIdToken() error {
var err error
traceID, err = generateTraceIdToken()
if err != nil {
return err
if propagated := corecommands.DetectExecutionContext().TraceID; propagated != "" {
traceID = propagated
} else {
generated, err := generateTraceIdToken()
if err != nil {
return err
}
traceID = generated
}
httpclient.SetUberTraceIdToken(traceID)
clientlog.Debug(traceIdLogMsg, traceID)
return nil
}

// buildEnrichedUserAgent appends invoker context (agent / ci) to the base CLI user-agent.
// Examples: "jfrog-cli-go/2.x (claude)", "jfrog-cli-go/2.x (ci=github_actions)",
// "jfrog-cli-go/2.x (cursor; ci=github_actions)".
func buildEnrichedUserAgent(ec corecommands.ExecutionContext) string {
base := coreutils.GetCliUserAgent()
parts := []string{}
if ec.Agent != "" {
parts = append(parts, ec.Agent)
}
if ec.CISystem != "" {
parts = append(parts, "ci="+ec.CISystem)
}
if len(parts) == 0 {
return base
}
return fmt.Sprintf("%s (%s)", base, strings.Join(parts, "; "))
}

// Generates a 16 chars hexadecimal string to be used as a Trace ID token.
func generateTraceIdToken() (string, error) {
// Generate 8 random bytes.
Expand Down
Loading