Skip to content

CLI: add Opencode integration#5

Closed
RealSid08 wants to merge 0 commit intoopenclaw:mainfrom
RealSid08:feat/opencode-integration
Closed

CLI: add Opencode integration#5
RealSid08 wants to merge 0 commit intoopenclaw:mainfrom
RealSid08:feat/opencode-integration

Conversation

@RealSid08
Copy link
Copy Markdown
Contributor

Summary

This PR adds full support for the Opencode CLI (opencode) as an auto-reply engine in warelay. This allows users to run "Openclawd" (an Opencode-powered assistant), leveraging Opencode's autonomous capabilities and multi-model support.

Key Changes

1. Opencode CLI Integration

  • Command Detection: [src/auto-reply/command-reply.ts] now detects opencode commands and automatically applies the necessary flags (--format json, --session).
  • Identity Prefix: Added OPENCODE_IDENTITY_PREFIX to [src/auto-reply/opencode.ts] to give Openclawd a distinct persona and context, similar to the existing Claude identity.
  • Session Management: Implemented logic to use --session <id> for Opencode, ensuring conversation continuity.

2. Robust JSON Parsing & Metadata

  • Streaming Parser: Implemented [parseOpencodeJson] in [src/auto-reply/opencode.ts] to handle Opencode's newline-delimited JSON event stream.
  • Metadata Extraction: The parser extracts:
    • Text: Clean response text from message_delta events.
    • Cost: Total cost from step_finish events.
    • Tokens: Input/output token usage.
    • Duration: Execution time.
  • Logging: Added [summarizeOpencodeMetadata] to log usage stats (cost, tokens, duration) to the console, matching the visibility of the Claude integration.

3. Documentation

  • New Guide: Created [docs/openclawd.md], a comprehensive setup guide for Openclawd. It covers:
    • Installation and configuration (warelay.json).
    • Autonomous Mode: Explanation of Opencode's "YOLO" mode and permission management via opencode.json.
    • MCP Setup: How to configure Model Context Protocol servers (Gmail, Calendar, etc.) in opencode.json.
  • README Update: Updated README.md to include Opencode support and link to the new documentation.

4. Testing

  • Unit Tests: Added [src/auto-reply/opencode.test.ts] with a comprehensive test suite covering:
    • Text extraction from streams.
    • Metadata calculation (cost, tokens).
    • Error handling for invalid JSON or empty input.
  • Verification: Verified that pnpm test passes for all new tests.

Verification

  • Unit Tests: Run pnpm test src/auto-reply/opencode.test.ts to verify parsing logic.
  • Linting: Code follows project style (pnpm lint passed).
  • Manual Test: Verified opencode command construction and argument handling in [command-reply.ts]

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally

@steipete
Copy link
Copy Markdown
Contributor

steipete commented Dec 2, 2025

I picked the relevant parts and made you co-author. Thanks!

@steipete steipete closed this Dec 2, 2025
@RealSid08
Copy link
Copy Markdown
Contributor Author

Omg thank you so much! I plan on getting Gemini CLI to work with warelay, @steipete should I make a PR for it once I think it's stable enough?

@steipete
Copy link
Copy Markdown
Contributor

steipete commented Dec 2, 2025

Ah good call. I added gemini.

petter-b added a commit to petter-b/openclaw that referenced this pull request Jan 12, 2026
* refactor: move slash commands to .claude/commands/dev/

* chore: remove old .claude/dev/ directory

---------

Co-authored-by: Claude <[email protected]>
tristanmanchester added a commit to tristanmanchester/clawdbot that referenced this pull request Jan 15, 2026
…tions

Replaces non-atomic `fs.writeFile()` calls in `persistTranscript()` and
`persistDescription()` with atomic temp-file-then-rename pattern. This
prevents data corruption when concurrent webhook processing writes to
the same sidecar file.

Implementation:
- Created shared `atomicWriteFile()` utility in `src/utils/atomic-write.ts`
- Uses unique temp file with UUID suffix for each write operation
- POSIX-guaranteed atomic `fs.rename()` to final location
- Automatic cleanup of temp files on error
- Comprehensive unit tests covering atomic behavior, concurrent writes,
  error handling, and edge cases (9 tests, all passing)

Fixes:
- Race condition when duplicate webhooks process same media file
- Data corruption from interrupted writes leaving partial UTF-8 sequences
- Last-write-wins now atomic (no partial states visible)

Resolves openclaw#5 (todos/005-pending-p1-race-condition-sidecar-files.md)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
tristanmanchester added a commit to tristanmanchester/clawdbot that referenced this pull request Jan 15, 2026
Updated todo file status from pending to resolved after implementing
atomic write pattern for sidecar file creation.

Implemented:
- Atomic write utility with comprehensive tests
- Applied to both transcription and video sidecar persistence
- All acceptance criteria met
- 9 unit tests passing

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Divem pushed a commit to Divem/openclaw that referenced this pull request Jan 31, 2026
linustan referenced this pull request in linustan/Komatachi Feb 1, 2026
- Decision #5: Distill into TypeScript with Rust portability in mind
- Decision #6: Minimal viable agent is CLI + Claude + file tools
- Removed answered questions from Open Questions section

https://claude.ai/code/session_0171xZCAV5r6yGGgzMpGDDDP
linustan referenced this pull request in linustan/Komatachi Feb 2, 2026
Validates decision #5 (TypeScript with Rust portability):
- Rust library using napi-rs for Node.js bindings
- TypeScript wrapper that matches original interface
- 44 tests pass for both implementations (88 total)

Architecture: TypeScript handles async orchestration (summarizer callback),
Rust handles pure computation (token estimation, metadata extraction).

Files:
- crates/compaction/src/lib.rs - Rust implementation
- src/compaction/rust.ts - TypeScript wrapper
- src/compaction/rust.test.ts - Equivalent tests for Rust impl

https://claude.ai/code/session_011TWuFG2PPSUU497XsRQYwy
Chimppppy pushed a commit to Chimppppy/openclaw that referenced this pull request Feb 3, 2026
…ames-in-security-extensions

Fix implementations to use the correct tool names.
ariffazil added a commit to ariffazil/AGI_ASI_bot that referenced this pull request Feb 4, 2026
Create Issue openclaw#5 documenting the technical inaccuracy of deployment instructions that were incorrectly claiming the project was Python-based when it's actually a Node.js project.

Ω₀=0.02
F2✓ (documenting the error)
F7✓ (acknowledging technical inaccuracies)
Linsen-Mao pushed a commit to Linsen-Mao/openclaw that referenced this pull request Feb 5, 2026
…iner, Postgres traces, cost budgets, phase restructuring

Factsheet changes (12 architecture critiques):
- Add users table with auth provider (openclaw#1)
- Change all TEXT PKs to native UUID type (openclaw#2)
- Remove orphaned session_id from Task/TaskCommand/TaskResult (openclaw#3)
- Replace per-task containers with single shared Docker container (openclaw#4)
- Phase injection queue: in-memory Phase 1, Redis Phase 2+ (openclaw#5)
- Decouple Board Sync DB writes from WebSocket broadcasting (openclaw#6)
- Move trace storage from JSONL+index to Postgres-only (openclaw#7)
- Add chat_messages escalation to agent context (openclaw#8)
- Normalize discussion_messages into separate table (openclaw#9)
- Add PolicyEngine facade with single evaluate() entry point (openclaw#10)
- Add per-plugin Zod validation schemas for SourceConfig (openclaw#11)
- Add CostPolicy with token/cost budgets and cost_usage table (openclaw#12)

Blueprint changes (4 implementation improvements):
- Split Phase 1 into 4 sub-phases (1a-1d)
- Reorder: API skeleton before agent loop
- Defer frontend to Phase 5
- Add packages/shared for types and schemas

DB schema: 17 tables → 20 tables (added users, traces, discussion_messages, cost_usage)

https://claude.ai/code/session_01V2xvGqZqX6JKPGQeXyNMQW
crazynomad pushed a commit to crazynomad/openclaw that referenced this pull request Feb 6, 2026
The "pulling yourself up by your own hair" story perfectly
illustrates OpenClaw's self-development: AI using itself to
improve itself.

Added ASCII art and connection to real git history showing
Shadow, CLAWDINATOR, Jarvis commits.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
jimboswankster pushed a commit to jimboswankster/moltbot that referenced this pull request Feb 7, 2026
Add comprehensive tests to close remaining refactor risks identified in
code-inspection.md. New coverage includes:

- Gateway mirror + A2A announce integration (Gap openclaw#1): 5 tests
- Role/source attribution interface contract (Gap openclaw#2): test.fails
- Config variations with vi.doMock pattern (Gap openclaw#9): 5 tests
- Tool restriction enforcement (Gap openclaw#5): 5 tests
- Concurrency/race safeguard (Gap openclaw#6): 5 tests + strategy docs

Total: 65 tests across 5 files (all passing)

Files:
- a2a-integration.regression.test.ts (new)
- config-variation.regression.test.ts (new)
- send-a2a-announce.integration.test.ts (new)
- Updated: a2a-flow, sessions-send-async, README, QC report

Co-authored-by: Cursor <[email protected]>
jimboswankster pushed a commit to jimboswankster/moltbot that referenced this pull request Feb 7, 2026
…d key support

## Summary
- Added deterministic idempotencyKey injection for side-effect tools (sessions_send,
  sessions_spawn, message, browser, nodes, canvas) during cron runs.
- Key is derived from runId + toolName + stable-stringified params (SHA-256).
- Only activates for cron-prefixed runIds; non-cron runs are unaffected.
- sessions_send now honors a provided idempotencyKey instead of always generating a UUID.
- Threaded runId through tool creation pipeline (pi-tools → attempt → tool-definition-adapter).
- Added contract tests: deterministic injection + sessions_send key passthrough.
- Updated existing before-tool-call tests with runId context.

## Why
- Cron retries after restarts were duplicating sends and tool calls because each retry
  generated a new random idempotency key. Deriving the key from the stable cron runId
  ensures replays produce the same key, enabling downstream dedupe. (Red-team risk openclaw#5)

## Systems
- agents (pi-tools, pi-tools.before-tool-call, pi-tool-definition-adapter,
  pi-embedded-runner, sessions-send-tool)

## Agent
- agent: MIS

Co-authored-by: Cursor <[email protected]>
Yuhuan0216 referenced this pull request in Yuhuan0216/openclaw Feb 8, 2026
- health-manager: use resolveConfigDir() for health-stats.json path (Critical #1)

- health-manager: replace console.error with subsystem logger (Minor #3)

- health-manager: document async load race condition (Minor #2)

- bindings: use resolveConfigDir() for routing.json path (Minor #5)
@Takhoffman Takhoffman mentioned this pull request Apr 10, 2026
25 tasks
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.

6 participants