Skip to content

feat: add cli-based LLM provider#73

Merged
lxowalle merged 1 commit intosipeed:mainfrom
Leeaandrob:feat/claude-cli-provider
Feb 12, 2026
Merged

feat: add cli-based LLM provider#73
lxowalle merged 1 commit intosipeed:mainfrom
Leeaandrob:feat/claude-cli-provider

Conversation

@Leeaandrob
Copy link
Collaborator

Summary

  • Add ClaudeCliProvider that executes the local CLI (claude) as a subprocess, implementing the LLMProvider interface
  • Register "claude-cli", "claude-code", "claudecode" provider aliases in the CreateProvider factory
  • Parse real CLI v2.x JSON response format with full token usage tracking

What this enables

Users can configure provider: "claude-cli" in PicoClaw config to route messages through the local CLI binary, gaining access to MCP tools, workspace awareness, and session management from any messaging channel (Telegram, Discord, WhatsApp, etc.).

Files changed

File Change
pkg/providers/claude_cli_provider.go New provider implementation (275 lines)
pkg/providers/claude_cli_provider_test.go 56 unit tests + 3 integration tests (1109 lines)
pkg/providers/http_provider.go Factory registration + formatting fix

Key implementation details

  • Subprocess execution via exec.CommandContext with context cancellation support
  • Flags: -p --output-format json --dangerously-skip-permissions --no-chrome
  • Stdin piping for prompt input, --system-prompt for system messages
  • is_error field handling for CLI error responses
  • Token usage mapping (input + cache_creation + cache_read → prompt tokens)

Test plan

  • 56 unit tests pass using mock CLI shell scripts
  • 3 integration tests pass against real CLI binary (v2.1.39)
  • 100% code coverage on 9/10 functions
  • go vet, go fmt, go build ./... all clean
  • Factory correctly returns *ClaudeCliProvider for all 3 aliases
  • Error paths tested: stderr, non-zero exit, command not found, invalid JSON, context timeout, is_error: true

Add ClaudeCliProvider that executes the local CLI as a subprocess,
enabling PicoClaw to leverage advanced capabilities (MCP tools,
workspace awareness, session management) through any messaging channel.

- Implement LLMProvider interface via subprocess execution
- Support --system-prompt, --model, --output-format json flags
- Parse real v2.x JSON response format including usage tokens
- Handle error responses, stderr, context cancellation
- Register "claude-cli", "claude-code", "claudecode" aliases in CreateProvider
- 56 unit tests with mock scripts + 3 integration tests against real binary
- 100% coverage on all functions except stripToolCallsJSON (85.7%)
@Leeaandrob Leeaandrob force-pushed the feat/claude-cli-provider branch from 8388d42 to f6362ce Compare February 12, 2026 14:52
@lxowalle lxowalle merged commit 19fc918 into sipeed:main Feb 12, 2026
1 check passed
@lxowalle
Copy link
Collaborator

Thanks for the pr.

@Leeaandrob
Copy link
Collaborator Author

@lxowalle do you have plans to centralize the communication and community like discord or something like that?

@Zepan
Copy link
Contributor

Zepan commented Feb 13, 2026

Thanks for your contribution! We are forming the PicoClaw Dev Group to accelerate the evolution of the project. Any developer with more than one merged PR is invited to join.

Would you like to join the PicoClaw Dev Group? If so, please send an email to support@sipeed.com with the subject line: [Join PicoClaw Dev Group] + Your GitHub account. We will send the Discord invite link to your inbox.

emadomedher pushed a commit to emadomedher/picoclaw that referenced this pull request Feb 17, 2026
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.

3 participants