Skip to content

feat: Add 'capiscio init' command for Let's Encrypt-style agent setup#32

Merged
beonde merged 6 commits intomainfrom
feature/init-command
Feb 5, 2026
Merged

feat: Add 'capiscio init' command for Let's Encrypt-style agent setup#32
beonde merged 6 commits intomainfrom
feature/init-command

Conversation

@beonde
Copy link
Member

@beonde beonde commented Feb 5, 2026

Summary

Implements a "Let's Encrypt" style one-command setup for agent identity. A single capiscio init command handles everything: key generation, DID derivation, server registration, and agent card creation.

Changes

Proto & RPC

  • Add Init RPC to SimpleGuardService with InitRequest/InitResponse messages
  • Implement server-side handler that generates Ed25519 keys, derives did:key, creates agent card

CLI

  • New capiscio init command with flags:
    • --api-key / CAPISCIO_API_KEY env var
    • --agent-id (optional - auto-discovers first agent if omitted)
    • --name, --server, --output, --force
  • Auto-discovers agent via GET /v1/agents?limit=1 when agent-id not provided
  • Registers DID with server via POST /v1/agents/{id}/dids
  • Creates agent card with x-capiscio extension

Documentation

  • Updated CLI reference with full init command documentation
  • Added quick start example in index.md

Two Setup Paths

Path When to Use Command
Quick Start Getting started, single agent capiscio init
UI-First Teams, multiple agents capiscio init --agent-id agt_123

Output Files

.capiscio/
├── private.jwk      # Ed25519 private key (0600 permissions)
├── public.jwk       # Public key
├── did.txt          # did:key identifier
└── agent-card.json  # A2A-compliant agent card

Testing

go test ./cmd/capiscio/... -v -run Init

All 3 tests pass: output directory, file permissions, force flag.

Related PRs

  • capiscio-sdk-python: Python SDK CapiscIO.connect() (coming)
  • capiscio-docs: Documentation updates (coming)

- 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
Copilot AI review requested due to automatic review settings February 5, 2026 21:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 init CLI 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)
Copilot AI review requested due to automatic review settings February 5, 2026 21:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 15 comments.

@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

❌ Patch coverage is 31.13208% with 73 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/rpc/simpleguard_service.go 33.00% 60 Missing and 7 partials ⚠️
pkg/rpc/gen/capiscio/v1/simpleguard.pb.go 0.00% 3 Missing ⚠️
pkg/rpc/gen/capiscio/v1/simpleguard_grpc.pb.go 0.00% 3 Missing ⚠️

📢 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)
@beonde beonde merged commit 676465d into main Feb 5, 2026
3 checks passed
@beonde beonde deleted the feature/init-command branch February 5, 2026 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant