master
9 次代码提交
| 作者 | SHA1 | 备注 | 提交日期 | |
|---|---|---|---|---|
|
|
7d00219b5d |
docs: verify first-agent wayfinding contract (#4707)
Co-authored-by: Codex <codex@openai.com> |
||
|
|
3e885308a0 |
lint: clear the golangci-lint backlog and enforce a blocking lint in CI (#2995)
Fixes #2988. Brings 'golangci-lint run ./...' to zero issues (was ~373): - errcheck: explicitly ignore fire-and-forget calls with '_ =' (and a small errcheck.exclude-functions list for response writes — json Encoder.Encode, http ResponseWriter.Write, fmt.Fprint*); genuine cases handled. - unused: remove dead code (unexported decls and dead test helpers) and the imports they orphaned. - staticcheck: ST1005 error strings, ST1016 receiver names, S1000/S1017/S1019/ S1023 simplifications, SA4004/SA4006/SA4010 dead code, SA1021 net.IP.Equal, SA6002 (store *[]byte in sync.Pool). - govet: fix a context leak (lostcancel) in internal/util/mdns and move t.Fatal/Fatalf out of goroutines (testinggoroutine) in tests. - ineffassign, unconvert: mechanical fixes. CI: the Lint workflow now runs a blocking full-tree 'golangci-lint run' on pushes and PRs (dropped only-new-issues now that the tree is clean). Verified: go build, go vet, test compilation, and unit tests for the behaviourally-touched packages all pass. Claude-Session: https://claude.ai/code/session_01CmdEY7pYmV5zzwCjNJ4ykL Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
4311b73361 |
Enhance ADK vs Go Micro comparison and apply lint fixes (#2994)
* docs: compare Go Micro with Google ADK in the comparison guide Adds a 'vs Agent Frameworks (Google ADK)' section: ADK builds an agent, Go Micro builds the distributed system the agent lives in (agents are services in the mesh). Covers the category difference, a feature table, when to choose each, and MCP/A2A interoperability. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CmdEY7pYmV5zzwCjNJ4ykL * docs: replace ADK comparison slogan with concrete explanation State plainly what each tool provides (ADK builds an agent process; Go Micro builds the surrounding service mesh) instead of marketing phrasing. * lint: apply golangci-lint autofixes; exclude ST1003 and demo errcheck Mechanical, behaviour-preserving fixes applied by 'golangci-lint run --fix': gofmt, misspell (US spelling), usestdlibvars (http.Method*/Status*), unconvert, and the auto-fixable staticcheck simplifications (QF*, S1017/S1019/S1023/S1039). Config: exclude ST1003 (remaining offenders are exported API renames, e.g. web.Id, which would break compatibility) and skip errcheck for examples/ and internal/harness/ (demo code where fire-and-forget is intentional). Build and test compilation verified. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CmdEY7pYmV5zzwCjNJ4ykL * lint: WIP cleanup checkpoint (errcheck config + partial fixes) Checkpoint of an in-progress golangci-lint cleanup (background pass). Builds cleanly; lint is not yet zero. Follow-up commit will complete the cleanup and switch CI to a blocking full-tree lint. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CmdEY7pYmV5zzwCjNJ4ykL --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
c7657f73f4 |
Refactor agent plan storage, update docs, and release v6 (#2977)
goreleaser / goreleaser (push) Has been cancelled
* test(harness): read agent plan from the scoped store
The store-scoping change moved an agent's plan from the default table
key agent/{name}/plan to its own table (database "agent", table {name},
key "plan"). The plan-delegate harness tests still read the old key and
failed with 'not found'; read through store.Scope(mem, "agent", name)
like the agent does.
* docs: orient agents-first across README, landing, and docs overview
Lead with agents (then services and flows), surface MCP + A2A as the
interop story, and frame agents as services. Landing hero and feature
grid reordered agents-first with an A2A gateway card.
* v6: module path go-micro.dev/v6, TLS secure by default, NewService
Cut v6. Three breaking changes, bundled so the major bump is paid once:
- Module path go-micro.dev/v5 -> go-micro.dev/v6 across all imports + go.mod.
- TLS verification on by default (was off). MICRO_TLS_SECURE removed;
MICRO_TLS_INSECURE=true opts out for self-signed/dev.
- micro.NewService(name, opts...) is the canonical service constructor,
symmetric with NewAgent/NewFlow; micro.New kept as a deprecated alias;
the old name-less NewService(opts...) removed. Generators emit NewService.
Also ports the JWT auth token provider in-module (go-micro.dev/v6/auth/jwt/token
on golang-jwt/jwt/v5), dropping the v5-pinned github.com/micro/plugins/v5/auth/jwt
and the deprecated dgrijalva/jwt-go.
Docs/README/landing updated to v6 and @latest; v5->v6 migration guide added;
CHANGELOG cut as [6.0.0]. Blog posts left at their historical versions.
---------
Co-authored-by: Claude <noreply@anthropic.com>
|
||
|
|
6b4ce55a7c |
Implement tool-execution wrappers and update documentation (#2971)
* feat(agent): tool-execution wrappers via WrapTool
Restructure ai.ToolHandler to the structured, ctx-carrying shape that
mirrors a go-micro RPC handler:
func(ctx context.Context, call ai.ToolCall) ai.ToolResult
This reuses the existing ToolCall (with its correlation ID) and
ToolResult types instead of the flat (name, input)->(any, string)
signature, and adds ToolCall.Scan for typed argument access.
Add ai.ToolWrapper and the agent option WrapTool / micro.AgentWrapTool —
the tool-side analogue of client.CallWrapper and server.HandlerWrapper.
Reframe the built-in guardrails (MaxSteps, LoopLimit, ApproveTool) as
composed wrappers around a base handler; developer wrappers compose
outermost, so they observe every call and result, including refusals.
Update all provider call sites, the MCP server and chat handlers, the
integration harnesses, and docs to the new signature.
* examples: add agent-wrap-tool showing AgentWrapTool
A runnable example of tool-execution middleware: an observe wrapper that
times calls and records per-tool metrics (correlated by call ID), and a
retry wrapper that recovers a flaky service call before the model sees
it. Demonstrates outermost-first composition and the wrapper/guardrail
interaction (retries are seen by loop detection).
* docs: note AgentWrapTool in README capabilities and CHANGELOG
* fix(generate): pin scaffolded go.mod to one version constant
The two generators pinned different, stale go-micro versions (v5.24.0
for services, v5.25.0 for agents). Centralize on a single
goMicroVersion constant (v5.29.0) so generated services and agents stay
in sync with the framework and there's one place to bump on release.
---------
Co-authored-by: Claude <noreply@anthropic.com>
|
||
|
|
1bc886fa82 |
Introduce Agent abstraction and integrate with chat router (#2939)
* docs: Agent interface design sketch Proposes Agent as a top-level abstraction alongside Service in the micro package. Agent manages services — scoped tools, system prompt, conversation memory, registry-discoverable. Design only, no implementation. https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd * feat: Agent as a first-class abstraction Introduce micro.NewAgent() alongside micro.New() — Agent is to intelligence what Service is to capability. Agent interface: - Chat(ctx, message) (*Response, error) — core interaction method - Run() — registers in registry, subscribes to broker, blocks - Stop() — graceful shutdown - Scoped tools — only sees endpoints of its assigned services - Persistent memory — conversation history stored in store - Agent-to-agent — communication via broker topics Top-level API: agent := micro.NewAgent("task-mgr", micro.AgentServices("task"), micro.AgentPrompt("You manage tasks."), micro.AgentProvider("anthropic"), ) agent.Run() https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd * feat: wire agents into chat router, add micro agent CLI, expose Flow Three top-level abstractions: micro.New("task") — Service (capability) micro.NewAgent("task-mgr") — Agent (intelligence) micro.NewFlow("onboard-user") — Flow (event-driven orchestration) micro chat as router: - Discovers agents from registry on startup - Single agent: routes directly - Multiple agents: LLM classifies intent, dispatches to right agent via route_to_agent tool - No agents: falls back to current direct-service behaviour - Banner shows discovered agents micro agent CLI: - micro agent list — shows registered agents and their services - micro agent describe <name> — shows agent details from registry https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd * feat: move flow to top level, update docs for three abstractions Package structure now consistent: service/ — Service (capability) agent/ — Agent (intelligence) flow/ — Flow (event-driven orchestration) ai/flow/ kept as backward-compatible re-export. Updated across all surfaces: - CLAUDE.md: added agent/ and flow/ to project structure - README: added "Building Agents" section with NewAgent() examples, updated features table (Agents, Flows, Chat router), CLI table (agent list, agent describe), docs links - Website: features grid shows Services, Agents, Flows as the three pillars alongside generation, MCP, and pluggable architecture - micro.go: Flow imported from top-level flow/ package https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd * docs: rewrite getting-started, fix ai-integration import paths Getting started now covers all three abstractions: - Service (write handlers, micro run, templates) - Agent (micro.NewAgent, scoped tools, memory, CLI) - Flow (event-driven LLM orchestration) Leads with prompt-based generation, then manual service creation. ai-integration.md: fixed flow import path from go-micro.dev/v5/ai/flow to go-micro.dev/v5/flow, updated stack diagram to show agent/flow/chat. https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd * blog: Introducing micro.NewAgent() Post 16 — announces Agent as a first-class abstraction. Shows the API (NewAgent, AgentServices, AgentPrompt, AgentProvider), scoped tools, persistent memory, multi-service agents, multi-agent systems, and the three-abstraction comparison table (Service/Agent/Flow). https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd * feat: fix agent registration, blog post 16 Agent registration: - Add node with address so mDNS can discover agents - Store type and services in node metadata (mDNS requirement) - Connect broker before subscribing, non-fatal if broker unavailable - Print registration confirmation on Run() Agent/chat discovery: - Check both service-level and node-level metadata for type=agent (mDNS stores metadata on nodes, not services) Blog post 16: "Introducing micro.NewAgent()" — announces the Agent abstraction with code examples, comparison table, multi-agent patterns. Tested end-to-end: micro run → micro agent list discovers the agent → micro chat routes to it → agent calls service endpoints. https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd * feat: agents are proper services with RPC Chat endpoint Refactored agent to use server.Server instead of fake registry entries. An agent now: - Creates a real RPC server with server.Name(agentName) - Registers an Agent.Chat handler callable via standard RPC - Sets server metadata type=agent, services=x,y for discovery - No more fake addresses or broker hacks micro chat calls agents via RPC (client.Call) instead of creating local agent instances. The registry stays clean — agents are real services with real endpoints. Removed broker dependency from agent options. Agent-to-agent communication is just RPC like everything else. https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd * feat: agent uses proto-defined RPC interface Added agent/proto/agent.proto with Agent service definition: rpc Chat(ChatRequest) returns (ChatResponse) Agent now implements the generated AgentHandler interface and registers via pb.RegisterAgentHandler. The Chat endpoint is a standard proto-based RPC callable by any go-micro client. Renamed the programmatic API from Chat() to Ask() to avoid collision with the proto handler method name. micro chat calls agents via standard RPC with JSON-encoded request/response — no special types needed on the caller side. https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd * feat: generate agent alongside services, update all docs micro run --prompt now generates an agent binary that manages all the generated services. The agent reads MICRO_AI_PROVIDER and MICRO_AI_API_KEY from the environment. micro run propagates these when started with --prompt. Run banner shows services and agents separately. Updated README, getting-started guide, and landing page to show the complete flow: generate → services + agent start → micro chat routes to agent → agent orchestrates services. https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
d3c4981326 |
Enhance AI service generation with prompt-based architecture and logic (#2926)
goreleaser / goreleaser (push) Has been cancelled
* feat: add micro new --prompt and micro run --prompt
Add AI-powered service generation: describe a system in natural
language and get real go-micro services with proto definitions,
handlers, doc comments, and MCP support.
micro new --prompt "a contact book with notes and tags" \
--provider anthropic
Generates:
contacts/ — CRUD service with name, email, phone fields
notes/ — notes linked to contacts
tags/ — tagging system
Each service gets:
proto/{name}.proto — domain model + CRUD endpoints
handler/{name}.go — in-memory store, @example tags for MCP
main.go — MCP-enabled, proper imports
go.mod + Makefile — compiles with go mod tidy + make proto
micro run --prompt does the same then starts all services.
The LLM designs the architecture (service names, fields, endpoints,
descriptions) and returns structured JSON. Code generation uses
the existing template patterns — the output is standard go-micro
code that compiles, runs, and is immediately callable via MCP
and micro chat. No AI dependency at runtime.
* feat: LLM generates real business logic with compile-fix loop
Rebuild the generate package so the LLM writes actual handler
code with business logic, not just CRUD scaffolding.
The flow is now:
1. LLM designs architecture (service names, fields, endpoints)
→ returns structured JSON
2. Proto, main.go, go.mod, Makefile generated deterministically
from the design (guaranteed to be correct)
3. go mod tidy + make proto compiles the protos
4. LLM generates handler code with REAL business logic
→ given the proto, endpoint descriptions, and go-micro patterns
5. go build — does it compile?
6. If no: feed errors back to LLM, get fixed code (up to 3 attempts)
7. If yes: service is ready
The handler prompt instructs the LLM to:
- Use sync.RWMutex for thread-safe in-memory state
- Include validation, edge cases, meaningful errors
- Write doc comments with @example tags for MCP
- Implement actual domain logic, not just map operations
Proto generation still uses deterministic templates (CRUD +
custom endpoints from the design spec) to guarantee correctness.
The compile-fix loop catches LLM mistakes automatically.
Both micro new --prompt and micro run --prompt use this flow.
* fix: handle edge cases in prompt-based generation
- Fix PATH for protoc-gen-micro in child processes
- Handle existing directories: skip structural files (main.go,
go.mod, Makefile) if dir exists, always regenerate proto,
only write placeholder handler if none exists
- Allow re-running micro new --prompt on same directory to
iterate on business logic without clobbering user edits
Tested end-to-end: "a simple todo list with tasks and categories"
generates 2 services (task-service, category-service) with real
business logic (validation, toggle complete, etc.), compiles
after 1 fix iteration, and runs with 6 MCP tools discovered.
* feat: auto-detect modified handlers on regeneration
Instead of requiring a --keep-handlers flag, the generate package now
tracks a SHA-256 hash of each generated handler in a .micro metadata
file. On re-run, if the user has edited the handler since generation,
it's left untouched. Unmodified handlers are regenerated normally.
https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd
* feat: add tests, fix go.mod, gitignore, proto tracking, spinner
- Add 12 tests covering helpers, proto generation, hash tracking
- Fix go.mod: write minimal module file, let go mod tidy resolve deps
- Add .gitignore to prompt-generated services
- Protect user-edited proto files (same hash tracking as handlers)
- Add spinner during LLM calls so it doesn't look hung
https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd
* feat: signal handling, existing service discovery, help text
- Ctrl+C during generation now cancels LLM calls immediately via
signal-aware context; re-run picks up where it left off
- Design() scans for existing services in the working directory and
includes their proto definitions in the prompt, so the LLM extends
the system rather than redesigning from scratch
- Updated --prompt help text with usage examples on both new and run
- Listed all supported providers in flag descriptions
- Added discoverExisting test
https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd
* feat: show endpoints in run --prompt output, add micro chat hint
Print endpoint names and descriptions when designing services so users
see what was built. Add a micro chat hint to the run banner so users
know how to interact with their services after startup.
https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd
* fix: generated go.mod uses go 1.24 with explicit go-micro require
go 1.22 with no explicit require caused Go to resolve sub-packages
(gateway/mcp, client, server) as separate modules, hitting stale v1.18
tags. Pin to go 1.24 + require go-micro.dev/v5 v5.24.0 so go mod tidy
resolves all sub-packages from the root module correctly.
Tested end-to-end: 4 services generated and compiled successfully.
https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd
* fix: skip handler regeneration when proto unchanged
Compare proto hash before and after structure generation. If the proto
didn't change and the handler wasn't edited by the user, skip go mod
tidy, make proto, LLM handler generation, and compile-fix entirely.
Prints "(unchanged)" instead.
Reduces re-run of 4-service project from ~2 minutes to ~10 seconds.
https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd
* feat: confirm design before generating code
Show the service design (names, endpoints) and prompt "Generate? [Y/n]"
before spending LLM time on handler generation. Applies to both
micro new --prompt and micro run --prompt. Default is yes (enter).
https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd
* fix: use port :0 for MCP in generated multi-service projects
Each generated service had mcp.WithMCP(":3001") hardcoded, causing
port conflicts when running multiple services. Use :0 to auto-assign
a free port. micro run's central gateway handles unified MCP access.
https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd
* feat: truncation detection, tool result display in chat
- Detect truncated LLM responses (unbalanced braces, doesn't end
with '}') and retry with a conciseness hint before falling through
to compile-fix
- Show tool call results in micro chat output (← for success, ✗ for
errors) so users can see what the LLM did
- Add Result/Error fields to ToolCall, populated by Anthropic provider
after tool execution
- Add isTruncated tests
Tested end-to-end with Anthropic: services generate, compile, start,
register, respond to RPC calls, and micro chat discovers and calls
tools correctly.
https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd
* fix: Anthropic tool loop, service naming, chat tool results
Anthropic provider:
- Fix tool execution loop to properly iterate (was re-processing all
tool calls instead of only new ones each round)
- Clean assistant content blocks before sending back (strip 'id' from
text blocks that Anthropic rejects on input)
- Include tools in follow-up requests so model can make additional calls
- Loop up to 10 rounds until model responds with text only
Service naming:
- Strip '-service' suffix from micro.New() name so services register
as 'task', 'category' instead of 'taskservice', 'categoryservice'
Chat:
- Show tool results (← for success) and errors (✗) in chat output
Tested end-to-end: create task → list tasks works as multi-step
orchestration through micro chat with Anthropic Claude.
https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd
* feat: blog post 13 — from prompt to production
Covers the full micro run --prompt flow: design, generate, compile-fix,
run, and chat orchestration. Positions agent-as-orchestrator as the
answer to service coordination.
https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd
* fix: timeouts, max_tokens, TTY detection, smaller services
- Add 60s timeout on design, 90s on handler generation, 60s on
compile-fix LLM calls so hung providers don't block forever
- Bump Anthropic max_tokens from 4096 to 8192 to reduce truncation
- Add TTY detection: spinner prints static message in non-TTY (CI/pipes)
instead of ANSI escape codes
- Tighten prompts: max 200 lines per handler, 2-4 services, 5-8 fields,
explicit "services don't call each other" rule
https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd
* feat: chat suggests creating services when capabilities are missing
Update system prompt with the list of available services. When the user
asks for something no existing service can handle, the agent explains
what's available and suggests the exact micro new --prompt command to
create the missing service.
This is the natural evolution path: start with a few services, talk to
them via chat, and when the domain grows, the agent tells you what to
add. Each service stays small and focused.
https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd
* feat: chat generates and starts services inline, drop -service suffix
Chat agent now has a micro_generate_service tool. When the user asks
for a capability that doesn't exist, the agent generates the service,
compiles it, starts it as a background process, waits for registration,
re-discovers tools, and uses the new endpoints immediately — all within
the conversation.
Service naming: design prompt now instructs LLM to return names without
'-service' suffix (e.g. 'task' not 'task-service'). buildMain keeps
TrimSuffix as safety net for backward compatibility.
Spawned processes are cleaned up when chat exits.
https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd
* docs: rewrite blog post 13 with inline service generation
Updated to reflect the full UX: services generate and start within
the chat conversation. Added the shipping example showing the agent
creating a service mid-conversation. Removed -service suffix from
all examples. Tightened the narrative around agent-as-orchestrator.
https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd
* feat: persistent storage, README quickstart, auto-detect new services
Storage: generated handlers now use go-micro's store package instead
of in-memory maps. Data persists across restarts. The handler prompt
includes store API examples so the LLM generates correct store usage.
README: added "Generate From a Prompt" section with micro run --prompt
and micro chat examples, linking to blog post 13.
Watcher: micro run now scans for new service directories every 5s. When
micro chat generates a service, micro run detects the new directory,
builds it, starts it, and adds it to the watcher — fully automatic.
Added AddDir/Dirs methods to the watcher.
Blog: updated post 13 with persistent storage example and watcher note.
https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd
---------
Co-authored-by: Claude <noreply@anthropic.com>
|
||
|
|
62c2981baf | remove cli | ||
|
|
2b9a6f9aeb |
flatten cli (#2332)
Run tests / Test repo (push) Has been cancelled
|