Skip to main content

OpenCode backend for the Nonoka Agent framework

Project description

nonoka-cli

OpenCode backend for the Nonoka Agent framework.

nonoka-cli runs as a stdio NDJSON bridge server (nonoka-cli --server) that talks to the nonoka-opencode-provider TypeScript package. OpenCode uses the provider to drive Nonoka agents, with full support for tool cards and human-in-the-loop (HITL) approval.

Quick install

The easiest way to get nonoka + OpenCode is the one-line installer:

curl -fsSL https://nonoka.dev/install.sh | bash

The installer will:

  1. Check Python 3.10+ and Node/npm.
  2. Install or update OpenCode.
  3. Install nonoka-cli and the OpenCode provider.
  4. Generate ~/.config/nonoka/config.yaml and ~/.config/opencode/opencode.json.

After installing, export your model API key and run opencode:

export DEEPSEEK_API_KEY=<your-key>
nonoka-cli doctor
opencode

To use uv instead of pip, or to run non-interactively, pass flags: curl -fsSL https://nonoka.dev/install.sh | bash -s -- --uv --yes.

Manual installation

# Install nonoka-cli
pip install nonoka-cli
# or with uv
uv pip install nonoka-cli

# Install the OpenCode provider globally so OpenCode can load it
npm install -g nonoka-opencode-provider

Quick start

  1. Create your nonoka config:
nonoka-cli config init

For scripted setups, use the non-interactive mode:

nonoka-cli config init --yes --model deepseek-chat
  1. Generate an OpenCode config in the current project or globally:
# Project-level
nonoka-cli opencode init

# User-level
nonoka-cli opencode init --global
  1. Make sure your model API key is exported, then run:
opencode

nonoka-cli doctor

Diagnose your installation and configuration:

nonoka-cli doctor

Example output:

nonoka-cli doctor
✓ nonoka-cli 0.2.1
✓ Python 3.11
✓ opencode 1.16.2
✓ provider nonoka-opencode-provider@0.2.0
✓ config ~/.config/nonoka/config.yaml
✓ API key DEEPSEEK_API_KEY set
✓ OpenCode provider config in /home/user/.config/opencode/opencode.json

If anything is wrong, doctor prints a remedy line. To also verify the LLM API key with a real (small) call, use:

nonoka-cli doctor --check-llm

Configuration

nonoka-cli config init

Interactive wizard that writes ~/.config/nonoka/config.yaml. It asks for a model identifier (e.g. deepseek-chat, openai/gpt-4o, ollama/llama3.3), an optional API-key environment variable, a system prompt, and whether to auto-approve all tool calls.

Non-interactive example:

nonoka-cli config init --yes --model openai/gpt-4o

nonoka-cli config set <key> <value>

Update a single config value. Dotted keys are supported:

nonoka-cli config set model openai/gpt-4o
nonoka-cli config set cli.theme light
nonoka-cli config set hitl.dangerous_tools '["write_file", "execute_command"]'

nonoka-cli config show

Print the resolved configuration and its file path.

nonoka-cli opencode init

Generate or merge an opencode.json in the current directory. The generated config points OpenCode at the nonoka-opencode-provider package and passes the nonoka config path to the backend.

OpenCode configuration

A typical generated opencode.json looks like:

{
  "$schema": "https://opencode.ai/config.json",
  "model": "nonoka/default",
  "provider": {
    "nonoka": {
      "npm": "nonoka-opencode-provider",
      "name": "Nonoka",
      "options": {
        "serverCommand": ["nonoka-cli", "--server"],
        "cwd": ".",
        "configPath": "~/.config/nonoka/config.yaml"
      },
      "models": {
        "default": { "name": "Nonoka deepseek-chat" }
      }
    }
  },
  "permission": {
    "edit": "ask",
    "bash": "ask"
  }
}

Human-in-the-loop

When a tool call matches the hitl.dangerous_tools list in nonoka.yaml, nonoka pauses the turn and sends a tool-approval-request to OpenCode. OpenCode shows the tool card with an approval dialog; after the user decides, nonoka resumes the turn, executes approved tools, and returns the final answer.

Example nonoka.yaml:

model: "deepseek-chat"

cli:
  auto_approve: false

hitl:
  policy: interactive
  dangerous_tools:
    - write_file
    - edit_file
    - delete_file
    - execute_command

Set cli.auto_approve: true (or hitl.policy: auto) to skip approval dialogs.

Development

# Install in editable mode
uv pip install -e .

# Run the bridge server
nonoka-cli --server --config ./nonoka.yaml

# Lint and test
uv run --no-sync ruff check .
uv run --no-sync pytest tests/unit

Project layout

src/nonoka_cli/
├── bridge/          # NDJSON protocol, request handler, server
├── commands/        # CLI subcommands (config, doctor, opencode)
├── config/          # YAML config loading and Pydantic models
├── core/            # Orchestrator, RunnerService, SessionService, ToolService, MCPService
├── mcp/             # MCP server lifecycle manager
├── sessions/        # Session metadata persistence
├── skills/          # Skill loading and application
├── tools/           # Built-in and local tool loader
└── utils/           # Errors, logging

packages/nonoka-opencode-provider/  # TypeScript provider for OpenCode
install.sh                          # One-line installer

License and attribution

nonoka-cli and nonoka-opencode-provider are released under the MIT License.

The terminal TUI and OpenCode client/server architecture are provided by OpenCode (MIT License). The agent core is provided by the Nonoka framework.

See LICENSE and NOTICE for full details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nonoka_cli-0.2.1.tar.gz (295.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nonoka_cli-0.2.1-py3-none-any.whl (58.1 kB view details)

Uploaded Python 3

File details

Details for the file nonoka_cli-0.2.1.tar.gz.

File metadata

  • Download URL: nonoka_cli-0.2.1.tar.gz
  • Upload date:
  • Size: 295.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for nonoka_cli-0.2.1.tar.gz
Algorithm Hash digest
SHA256 7f5c5538844b26f650aeceed1242badf7a8dbe2e27a3dea1bfd06e4b8d35e55c
MD5 bb198bca59e9014331437ce3a4123b48
BLAKE2b-256 5706728aeaf7fdf1d9b15235da87f6be5afbd0c57744c9d1f6f06032037f22e0

See more details on using hashes here.

File details

Details for the file nonoka_cli-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: nonoka_cli-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 58.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for nonoka_cli-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 769844cacae4c23f96815043f137b75838c6fe2d5ae29e85e129202b770e683e
MD5 45f62ba6095ff75ea746ac222568abfa
BLAKE2b-256 02fff0215876ae86d07d3930e3e62fdfb421adb8601b0dd76ad2c82ace9fdd3e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page