Skip to content

Repository files navigation

D1V CLI

Experimental CLI for d1v.ai.

ci workflow

English简体中文

Commands

Run d1v --help for all available commands.

Deploy the current directory without repeating the project ID:

d1v --preview   # or: d1v --prev
d1v --prod

The CLI reads D1V_PROJECT_ID from .env (or .d1v/project.json). When it is missing in an interactive terminal, choose an existing project or create one named after the current directory. Cloud environment variables are then merged into .env; local values are kept by default when keys conflict.

Coding Agent Skill

The official, versioned d1v Skill lives at skills/d1v/SKILL.md. It gives Codex and Claude Code safe instructions for project workspaces, container commands, preview deployments, and user-confirmed production releases.

The curl installer uses --install-skill auto by default. It installs only for Codex and Claude Code executables already available on PATH; it does not install either coding agent and succeeds without changes when neither is found. Use the same behavior manually:

d1v skill install --agent auto

Use --agent codex, --agent claude, or --agent all to explicitly choose targets. Skills are written below ${CODEX_HOME:-~/.codex}/skills/d1v and ${CLAUDE_CONFIG_DIR:-~/.claude}/skills/d1v. An identical Skill is left alone; a different existing SKILL.md is backed up beside it as SKILL.md.d1v-backup-<UTC timestamp> before replacement. The legacy https://www.d1v.ai/cli-skill.md URL remains available and redirects to this canonical file.

Local Runtime

D1V supports a local runtime in addition to the existing cloud runtime.

Role split:

  • opcode-api: the local runtime server
  • d1v-cli: installer, launcher, supervisor, connector
  • backend_admin: control plane and runtime router
  • d1vai: unified frontend

The frontend never connects directly to the user machine. The local agent opens an outbound connection to D1V cloud.

Local Runtime Quickstart

  1. Install and inspect the local runtime:
d1v runtime doctor
bash scripts/install-opcode-runtime.sh --home ~/d1v-home
  1. Pair the machine:
d1v agent pair

Or keep using a pairing code generated in the web UI:

d1v agent pair --code <pairing-code>
  1. Start the local runtime:
d1v agent start
  1. Create or bind local project directories:
d1v agent project create --project-id <project_id> --name my-app
d1v agent project import --path ~/work/my-app --project-id <project_id>
d1v agent project bind --project-id <project_id> --path ~/work/my-app

Backward-compatible entry:

d1v agent init-runtime --project-id <project_id> --path ~/work/my-app

Local Runtime Behavior

  • Runtime switching affects new sessions only.
  • Existing sessions stay pinned to the runtime where they started.
  • If a project is bound to local runtime and the device is offline, requests return an explicit local-runtime error instead of silently falling back to cloud.
  • Project creation/import flows may still use cloud opcode directly before runtime binding exists.

Public Expose

CLI free expose does not require a running node agent:

d1v expose 3000
d1v expose list
d1v expose close <binding_id>

Platform node ingress stays on a separate command path:

d1v node expose 3000 --node-id <platform-node-id>
d1v node expose list
d1v node expose close <binding_id>

Current expose modes:

  • cli_free_relay: returns a public https://*.cli-free.d1v.dev URL for login-backed temporary CLI relays
  • cloudflare_tunnel: returns a public https://*.node.d1v.dev URL for platform nodes
  • reverse_relay: internal fallback mode used by local/customer relays behind the CLI-free entry

d1v expose currently targets HTTP traffic. Browser terminal and session WebSocket flows still use the existing backend relay path.

Platform Node

Platform nodes now use a single control origin for runtime-agent ingress. The recommended bootstrap form is:

d1v node start --key <platform-node-key> --control-origin https://{your-host-or-name}-node.d1v.dev

If --control-origin is omitted, the runtime-agent falls back to its own public IP detection and control-plane registration flow.

Privacy Boundary

Current phase:

  • paired devices only
  • outbound-only relay
  • short-lived pairing code
  • stored device public key

Current limitation:

  • relay traffic is not zero-knowledge
  • platform metadata and chat/session records still follow existing D1V persistence behavior

For deeper architecture details, see docs/d1v-agent-architecture.md.

Install

Recommended:

curl -fsSL https://d1v.ai/install/d1v-cli.sh | bash

Install page:

https://d1v.ai/cli-install

Alternatives:

brew install d1vai/tap/d1v
cargo binstall d1v-cli
cargo install --locked d1v-cli

After install:

d1v auth login
d1v project list
d1v github status

To authenticate through an existing browser session and save a revocable device API key, use d1v auth login --browser. The browser approves a one-time, 10-minute session; the CLI stores the resulting key in the same keyring/config location used by other login methods.

Upgrade later:

d1v upgrade
d1v upgrade --version v0.1.5
d1v uninstall

d1v upgrade replaces only the executable. Your login remains available from the same OS keyring entry or ~/.d1v/config.toml; upgrading does not sign you out or copy credentials into the release archive.

Global Options

Option Description Default
--format Output format (text, json) text
--color Color output auto
--lang Display language System / Config
-v Increase log verbosity warn

Environment Variables

Variable Description
D1V_API_KEY API key
D1V_AUTH_TOKEN Auth token
D1V_BASE_URL API base URL
D1V_FORMAT Output format
D1V_LANG Display language
D1V_LOG_FILE Log file path
D1V_RECORD_FILE HTTP recording file
NO_COLOR Disable color output
RUST_LOG Log filter

Authentication

Command Description
d1v auth login Log in
d1v auth logout Log out
d1v auth status Show auth status

Configuration

Command Description
d1v config show Show current configuration
d1v config get Get a config value
d1v config set Set a config value
d1v config list List available config keys
d1v config path Print config file path
d1v config reset Reset configuration to defaults
d1v config edit Open config file in editor

Available config keys:

Key Description
base_url API base URL
language Display language override

User

Command Description
d1v user info Show current user info
d1v user update Update user info
d1v user get Get a public user
d1v user list List all users

Password

Command Description
d1v user password set Set a password
d1v user password reset Reset password

Email

Command Description
d1v user email bind Bind an email
d1v user email change Change email

Invitation & Onboarding

Command Description
d1v user invitation accept Accept an invitation
d1v user invitation list List invited users
d1v user onboard Mark onboarding as complete

Activity

Command Description
d1v user activity View prompt daily activity

Diagnostics

Command Description
d1v debug Show debug information
d1v upgrade Check for updates and self-upgrade
d1v uninstall Remove the current d1v executable

Project Workflows

These commands require authentication. Start with:

d1v auth status
d1v auth login

Core Resources

Area Commands
Projects `d1v project list
Sessions `d1v session run
Deploys `d1v deploy preview
GitHub `d1v github status
Database `d1v db schema

Container Terminal And Exec

Open an interactive terminal at the personal workspace root or directly in a project directory:

d1v shell
d1v shell <project_id>
d1v shell --organization-id <organization_id>

With no target, d1v shell opens the personal workspace root. A positional project ID opens that project's directory, including organization-owned projects resolved by the control plane. --organization-id opens the organization workspace root and cannot be combined with a project ID.

The interactive terminal requires a TTY and uses the container's native Bash/Zsh completion. For agents, CI, and commands whose output or status must be captured, use non-interactive d1v exec and pass argv after --:

d1v exec -- git status --short
d1v exec --project-id <project_id> -- npm test
d1v exec --organization-id <organization_id> -- pwd
d1v --format json exec --project-id <project_id> -- sh -c 'printf ok; printf problem >&2; exit 7'

Text mode streams remote stdout and stderr to the matching local streams. JSON mode returns session_id, project_id, cwd, exit_code, stdout, and stderr, while the CLI process preserves a nonzero remote exit status. Interactive shell does not support JSON output.

The CLI automatically selects an eligible direct-node connection and otherwise uses the backend relay. It sends an application heartbeat every 20 seconds so long-lived sessions stay active through intermediaries. Shell tickets are short-lived and sent in the WebSocket header, never in the URL or command output. Terminal input and output are not persisted by the terminal service.

Container Integration Ensure

When a container runtime injects D1V_API_KEY (or D1V_AUTH_TOKEN), D1V_BASE_URL, and D1V_PROJECT_ID, agents can enable project integrations on demand without a browser login:

d1v project ensure database
d1v project ensure db analytics
d1v --format json project ensure pay

GitHub Handoff

Use CLI first, then jump to web only when setup is required:

d1v github status
d1v github bind
d1v github installations
d1v github repos --installation-id 123456

If GitHub App installation or OAuth binding is incomplete, d1v github bind opens the correct handoff page, including https://d1v.ai/setting?tab=github when needed.

Database And Migration Smoke Checklist

After logging in and choosing a project id, the smallest end-to-end validation flow is:

d1v db token issue <project_id> --scopes db:read,migrate
d1v db schema <project_id>
d1v db rows list <project_id> --schema public --table your_table
d1v db migrate plan <project_id> --sql 'CREATE TABLE IF NOT EXISTS smoke_cli(id serial primary key);'

Useful follow-up commands:

d1v db migrate validate <plan_id>
d1v db migrate approve <plan_id>
d1v db migrate auto-review <approval_id>

Development

Prerequisites

Build

cargo build

Test

cargo test

Run

cargo run

Install

cargo install --path d1v-cli

Debugging

Environment

Check version, config path, and token status:

d1v debug

Logging

Daily log files are written to ~/.d1v/d1v.YYYY-MM-DD.log, keeping the last 7 days.

Increase stderr verbosity with -v (-v info, -vv debug, -vvv trace):

d1v -vv auth login

RUST_LOG is also supported when -v is not set:

RUST_LOG=debug d1v auth login

Write logs to a custom file:

d1v --log-file trace.log auth login

HTTP Recording

Capture HTTP traffic to a JSON file for inspection.

Enable the record feature:

cargo install --path d1v-cli --features record

Run with recording:

d1v --record trace.json auth login

Config keys available with the record feature:

Key Description
record.enabled Enable recording by default
record.dir Directory to write recording files into

About

Experimental CLI for d1v.ai

Resources

Stars

130 stars

Watchers

6 watching

Forks

Releases

Packages

Contributors

Languages