From f68e5bde7bad69d69bccf3e06710d7189f699a96 Mon Sep 17 00:00:00 2001 From: weichen Date: Sat, 3 Oct 2026 13:43:03 +0000 Subject: [PATCH] Keep the agent-intent import inside the intent adapter Why: the command has to load guard overlays without naming agent-intent types. Only adapters/intent may import that library. Evidence: GOWORK=off go test -count=1 in adapters/intent and cmd/agent-squad passed. Impact: CLI calls NewFromOverlay. Guard domains stay guard. Refs: D1 Co-authored-by: Cursor --- adapters/intent/gate.go | 13 +++++++++++++ cmd/agent-squad/cli/cli.go | 10 +--------- cmd/agent-squad/go.mod | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/adapters/intent/gate.go b/adapters/intent/gate.go index f5de0c4..3033e96 100644 --- a/adapters/intent/gate.go +++ b/adapters/intent/gate.go @@ -31,6 +31,19 @@ type Options struct { Roots []string } +// NewFromOverlay 从 JSON overlay 构造闸门,并把 guard 域标成受保护域。 +// 命令行用它,这样命令本身不必 import agent-intent。 +func NewFromOverlay(ctx context.Context, fsys fs.FS, roots ...string) (*Gate, error) { + return New(ctx, Options{ + IntentOptions: intent.Options{ + GuardDomains: []string{"guard"}, + ProtectedDomains: []string{"guard"}, + }, + FS: fsys, + Roots: roots, + }) +} + // New 构造闸门。没有任何意图来源时返回 (nil, nil)——引擎拿到 nil IntentGate, // 行为与原实现一致(T0 行为解耦)。 func New(ctx context.Context, o Options) (*Gate, error) { diff --git a/cmd/agent-squad/cli/cli.go b/cmd/agent-squad/cli/cli.go index 3baf03e..f120e7d 100644 --- a/cmd/agent-squad/cli/cli.go +++ b/cmd/agent-squad/cli/cli.go @@ -15,7 +15,6 @@ import ( "strings" "time" - "agent-intent/intent" "agent-native/runtime/llm" squadintent "agent-squad/adapters/intent" nativeadp "agent-squad/adapters/native" @@ -138,14 +137,7 @@ func assemble(dir, plannerName, modelOverride, intentRoot string) (*app, error) var catalog *squad.IntentCatalog var runner squad.IntentRunner if intentRoot != "" { - g, err := squadintent.New(context.Background(), squadintent.Options{ - IntentOptions: intent.Options{ - GuardDomains: []string{"guard"}, - ProtectedDomains: []string{"guard"}, - }, - FS: os.DirFS(intentRoot), - Roots: []string{"."}, - }) + g, err := squadintent.NewFromOverlay(context.Background(), os.DirFS(intentRoot), ".") if err != nil { return nil, fmt.Errorf("意图配置加载失败(fail-closed):%w", err) } diff --git a/cmd/agent-squad/go.mod b/cmd/agent-squad/go.mod index a368da2..bfbf7bc 100644 --- a/cmd/agent-squad/go.mod +++ b/cmd/agent-squad/go.mod @@ -3,7 +3,6 @@ module agent-squad/cmd/agent-squad go 1.27 require ( - agent-intent v0.0.0 agent-native v0.0.0 agent-squad v0.0.0 agent-squad/adapters/intent v0.0.0 @@ -14,6 +13,7 @@ require ( ) require ( + agent-intent v0.0.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/google/uuid v1.6.0 // indirect github.com/mattn/go-isatty v0.0.20 // indirect