From 6506685e4132f929a3131b3c1bf925b8499ea8f6 Mon Sep 17 00:00:00 2001 From: Matt Dolan Date: Thu, 25 Jun 2026 17:41:48 +0100 Subject: [PATCH] feat: register the snyk agent (AXI) extension MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wire github.com/snyk-playground/cli-extension-axi into the CLI: - initExtensions registers agent.Init, adding the `snyk agent` command surface (agent-ergonomic, TOON output): `agent`, `agent test [scanners...]`, `agent context`, `agent setup hooks`. - createCommandsForWorkflows sets a help func on the `agent` command (inherited by the subtree) that delegates to agent.RenderHelp with the engine, so the extension can render per-command help by introspecting each scanner's underlying workflow flags — without hardcoding other extensions' flags. Co-Authored-By: Claude Opus 4.8 --- cliv2/go.mod | 3 +++ cliv2/go.sum | 6 ++++++ cliv2/pkg/core/main.go | 13 ++++++++++++- cliv2/pkg/core/workflows.go | 2 ++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/cliv2/go.mod b/cliv2/go.mod index 06e14a71a2..cb014fc37c 100644 --- a/cliv2/go.mod +++ b/cliv2/go.mod @@ -11,6 +11,7 @@ require ( github.com/mattn/go-isatty v0.0.20 github.com/pkg/errors v0.9.1 github.com/rs/zerolog v1.34.0 + github.com/snyk-playground/cli-extension-axi v0.0.0-20260625161408-6f13b7a941b0 github.com/snyk/cli-extension-agent-scan v0.0.0-20260505093105-90d9442ea939 github.com/snyk/cli-extension-ai-bom v0.0.0-20260319140413-ac7392950603 github.com/snyk/cli-extension-ai-redteam v0.0.0-20260331152502-ce341aeaff9e @@ -178,6 +179,7 @@ require ( github.com/lucasb-eyer/go-colorful v1.3.0 // indirect github.com/manifoldco/promptui v0.9.0 // indirect github.com/mark3labs/mcp-go v0.31.0 // indirect + github.com/mattdolan-snyk/axi-sdk-go v0.0.0-20260624052311-475083281cb3 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-localereader v0.0.1 // indirect github.com/mattn/go-runewidth v0.0.20 // indirect @@ -229,6 +231,7 @@ require ( github.com/tchap/go-patricia/v2 v2.3.1 // indirect github.com/tklauser/go-sysconf v0.3.14 // indirect github.com/tklauser/numcpus v0.8.0 // indirect + github.com/toon-format/toon-go v0.0.0-20251202084852-7ca0e27c4e8c // indirect github.com/ulikunitz/xz v0.5.15 // indirect github.com/vincent-petithory/dataurl v1.0.0 // indirect github.com/writeas/go-strip-markdown v2.0.1+incompatible // indirect diff --git a/cliv2/go.sum b/cliv2/go.sum index 0d35d0dbd5..b9c2a78356 100644 --- a/cliv2/go.sum +++ b/cliv2/go.sum @@ -416,6 +416,8 @@ github.com/mark3labs/mcp-go v0.31.0 h1:4UxSV8aM770OPmTvaVe/b1rA2oZAjBMhGBfUgOGut github.com/mark3labs/mcp-go v0.31.0/go.mod h1:rXqOudj/djTORU/ThxYx8fqEVj/5pvTuuebQ2RC7uk4= github.com/maruel/natural v1.1.1 h1:Hja7XhhmvEFhcByqDoHz9QZbkWey+COd9xWfCfn1ioo= github.com/maruel/natural v1.1.1/go.mod h1:v+Rfd79xlw1AgVBjbO0BEQmptqb5HvL/k9GRHB7ZKEg= +github.com/mattdolan-snyk/axi-sdk-go v0.0.0-20260624052311-475083281cb3 h1:4hjDjUe8mxUPwvpXpd4VrrR2ewrvoE1VnLhnNBAw5LA= +github.com/mattdolan-snyk/axi-sdk-go v0.0.0-20260624052311-475083281cb3/go.mod h1:PAGxDYllJTF1m+RemOPn6WLGf9WrCUlP0M8tSOaiNAQ= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= @@ -539,6 +541,8 @@ github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/skeema/knownhosts v1.3.2 h1:EDL9mgf4NzwMXCTfaxSD/o/a5fxDw/xL9nkU28JjdBg= github.com/skeema/knownhosts v1.3.2/go.mod h1:bEg3iQAuw+jyiw+484wwFJoKSLwcfd7fqRy+N0QTiow= +github.com/snyk-playground/cli-extension-axi v0.0.0-20260625161408-6f13b7a941b0 h1:HXymdUISQYO8jdx2VfyisDKMvwSR0ujzpo/L6tQ1t2A= +github.com/snyk-playground/cli-extension-axi v0.0.0-20260625161408-6f13b7a941b0/go.mod h1:wRi0pApLCFhXXdxQv8/2VPhg/emxmjvuUo83iGbt96A= github.com/snyk/cli-extension-agent-scan v0.0.0-20260505093105-90d9442ea939 h1:GvW35inJZTr2AD1c/sIRkVOajom0kEY8nN30cqes+u0= github.com/snyk/cli-extension-agent-scan v0.0.0-20260505093105-90d9442ea939/go.mod h1:+Znlgu2v7sOTNAVjsoldFjDZUIo8tpdKnFlMptZHzz0= github.com/snyk/cli-extension-ai-bom v0.0.0-20260319140413-ac7392950603 h1:uZyw9OvOGCMFloZy8Fyu6l4K5y77o4k0KdxHuUKAp8M= @@ -629,6 +633,8 @@ github.com/tklauser/go-sysconf v0.3.14 h1:g5vzr9iPFFz24v2KZXs/pvpvh8/V9Fw6vQK5ZZ github.com/tklauser/go-sysconf v0.3.14/go.mod h1:1ym4lWMLUOhuBOPGtRcJm7tEGX4SCYNEEEtghGG/8uY= github.com/tklauser/numcpus v0.8.0 h1:Mx4Wwe/FjZLeQsK/6kt2EOepwwSl7SmJrK5bV/dXYgY= github.com/tklauser/numcpus v0.8.0/go.mod h1:ZJZlAY+dmR4eut8epnzf0u/VwodKmryxR8txiloSqBE= +github.com/toon-format/toon-go v0.0.0-20251202084852-7ca0e27c4e8c h1:D8lDFovBMZywze1eh9iwMLcYor5f11mHBocLhO7cBe8= +github.com/toon-format/toon-go v0.0.0-20251202084852-7ca0e27c4e8c/go.mod h1:j/BOnpF2ihnz4lELs99h9mwGJBx/zdleOUCnLLRPCsc= github.com/ulikunitz/xz v0.5.15 h1:9DNdB5s+SgV3bQ2ApL10xRc35ck0DuIX/isZvIk+ubY= github.com/ulikunitz/xz v0.5.15/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/vincent-petithory/dataurl v1.0.0 h1:cXw+kPto8NLuJtlMsI152irrVw9fRDX8AbShPRpg2CI= diff --git a/cliv2/pkg/core/main.go b/cliv2/pkg/core/main.go index 701d23a330..8583508117 100644 --- a/cliv2/pkg/core/main.go +++ b/cliv2/pkg/core/main.go @@ -25,6 +25,8 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" + "github.com/snyk-playground/cli-extension-axi/pkg/agent" + "github.com/snyk/go-application-framework/pkg/ui/consoleui" "github.com/snyk/go-application-framework/pkg/analytics" @@ -37,8 +39,8 @@ import ( "github.com/snyk/cli/cliv2/internal/cliv2" "github.com/snyk/cli/cliv2/internal/constants" - cliv2utils "github.com/snyk/cli/cliv2/internal/utils" persona "github.com/snyk/cli/cliv2/internal/persona" + cliv2utils "github.com/snyk/cli/cliv2/internal/utils" localworkflows "github.com/snyk/go-application-framework/pkg/local_workflows" "github.com/snyk/go-application-framework/pkg/local_workflows/config_utils" @@ -377,6 +379,15 @@ func createCommandsForWorkflows(rootCommand *cobra.Command, engine workflow.Engi case "fix": // to preserve backwards compatibility we will need to relax flag validation parentCommand.FParseErrWhitelist.UnknownFlags = true + case "agent": + // AXI: the `snyk agent` command surface is agent-ergonomic and owns its + // own help. Replace cobra's default help with the extension's renderer for + // the whole agent subtree (children inherit this help func). The engine is + // passed so the extension can introspect each scanner's underlying workflow + // flags for per-command help — without hardcoding other extensions' flags. + parentCommand.SetHelpFunc(func(cmd *cobra.Command, _ []string) { + agent.RenderHelp(cmd.OutOrStdout(), engine, os.Args[1:]) + }) } } } diff --git a/cliv2/pkg/core/workflows.go b/cliv2/pkg/core/workflows.go index 5662439a8d..119950c6f6 100644 --- a/cliv2/pkg/core/workflows.go +++ b/cliv2/pkg/core/workflows.go @@ -1,6 +1,7 @@ package core import ( + "github.com/snyk-playground/cli-extension-axi/pkg/agent" "github.com/snyk/cli-extension-agent-scan/pkg/agentscan" "github.com/snyk/cli-extension-ai-bom/pkg/aibom" "github.com/snyk/cli-extension-ai-redteam/pkg/redteam" @@ -41,6 +42,7 @@ func initExtensions(engine workflow.Engine, config configuration.Configuration, engine.AddExtensionInitializer(ignore_workflow.InitIgnoreWorkflows) engine.AddExtensionInitializer(agentscan.Init) engine.AddExtensionInitializer(secrets.Init) + engine.AddExtensionInitializer(agent.Init) // Register additional extensions injected via Run(WithAdditionalExtensions(...)) for _, ext := range additionalExts {