feat: Add 'capiscio init' command for Let's Encrypt-style agent setup#32
Merged
feat: Add 'capiscio init' command for Let's Encrypt-style agent setup#32
Conversation
- Add Init RPC to SimpleGuard service (proto + handler) - Create CLI init command with auto-discover, key gen, DID registration - Generate Ed25519 keypair, derive did:key, create agent card - Support two paths: API-key-only (auto-discover) and explicit agent-id - Add comprehensive tests for init command - Update documentation with new init workflow
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a "Let's Encrypt" style capiscio init command to simplify agent identity setup. The feature generates Ed25519 keys, derives a did:key identifier, registers the DID with the CapiscIO registry, and creates an A2A-compliant agent card—all in a single command.
Changes:
- Added Init RPC to SimpleGuardService proto with request/response messages
- Implemented server-side RPC handler for agent initialization
- Created new
capiscio initCLI command with auto-discovery, DID registration, and agent card generation - Updated documentation with init command reference and quick start examples
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 19 comments.
Show a summary per file
| File | Description |
|---|---|
| proto/capiscio/v1/simpleguard.proto | Added Init RPC method with InitRequest/InitResponse messages |
| pkg/rpc/gen/capiscio/v1/simpleguard_grpc.pb.go | Generated gRPC code for Init RPC (version bump to 1.6.1) |
| pkg/rpc/gen/capiscio/v1/simpleguard.pb.go | Generated protobuf message code for Init request/response |
| internal/rpc/simpleguard_service.go | Server-side Init implementation with key generation and DID registration |
| cmd/capiscio/init.go | CLI command implementation with agent discovery and registration |
| cmd/capiscio/init_test.go | Unit tests for helper functions and file operations |
| docs/reference/cli.md | CLI reference documentation for init command |
| docs/index.md | Updated quick start guide with init command example |
- Extract helper functions from runInit (24 -> ~10 complexity) - Extract helper functions from SimpleGuardService.Init (18 -> ~8 complexity) - Fixes gocyclo CI lint failures
- Test resolveAPIKey (env var and flag handling) - Test validateServerURL - Test setupOutputDir (directory creation, force flag) - Test generateAndSaveKeys (key generation and file permissions) - Test saveAgentCard - Test resolveAgentID (explicit and auto-discovery)
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
- Fix panic risk: Add length check before agentID[:8] slicing
- Fix ignored json.Marshal errors: Add error handling in generateAndSaveKeys and registerDID
- Fix inconsistent API endpoint: Change from PUT /v1/agents/{id} to POST /v1/agents/{id}/dids
- Fix auth headers: Change from X-Capiscio-Registry-Key to Authorization: Bearer
- Fix hardcoded localhost URL: Use serverURL parameter in agent card
- Fix localhost validation: Allow any localhost port, not just 8080
- Fix unused priv parameter: Mark with underscore
- Add edge case test for short agentID
- Fix tests to match updated implementation (Bearer auth, POST endpoint)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements a "Let's Encrypt" style one-command setup for agent identity. A single
capiscio initcommand handles everything: key generation, DID derivation, server registration, and agent card creation.Changes
Proto & RPC
InitRPC toSimpleGuardServicewithInitRequest/InitResponsemessagesCLI
capiscio initcommand with flags:--api-key/CAPISCIO_API_KEYenv var--agent-id(optional - auto-discovers first agent if omitted)--name,--server,--output,--forceGET /v1/agents?limit=1when agent-id not providedPOST /v1/agents/{id}/didsx-capiscioextensionDocumentation
initcommand documentationTwo Setup Paths
capiscio initcapiscio init --agent-id agt_123Output Files
Testing
go test ./cmd/capiscio/... -v -run InitAll 3 tests pass: output directory, file permissions, force flag.
Related PRs
CapiscIO.connect()(coming)