JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 13
  • Score
    100M100P100Q48648F
  • License UNLICENSED

AI-powered coding assistant engine for DashNex

Package Exports

  • @dashnex/code
  • @dashnex/code/commands

Readme

@dashnex/code

An interactive terminal coding assistant for DashNex. Bring your favorite Claude or OpenAI model into a fast, keyboard-driven TUI that can read your code, run shell commands, and edit files — with permission gates you control.

Built on top of Ink and the Vercel AI SDK, with cost-aware Anthropic prompt caching wired through the DashNex AI gateway.

Highlights

  • Multi-model — Anthropic (Claude Sonnet/Opus/Haiku), OpenAI (GPT-4o / GPT-5 family), and anything else exposed by the GenX or ai.dashnex.com gateways. Switch any time with /model.
  • Prompt caching — for Anthropic models on the DashNex gateway, system prompt and tool definitions are cached on the provider side. Follow-up turns typically serve 80–90% of input tokens from cache.
  • Tools that respect you — file reads, edits, writes, globs, greps, web fetches, and shell commands all require explicit approval by default. Switch to auto mode when you want hands-off execution, or plan mode for design-first sessions.
  • Real sessions — every conversation is persisted in SQLite, resumable with --resume <id> or interactively with /resume. Tool calls, results, and tokens are all kept.
  • MCP support — plug in any Model Context Protocol server (stdio or SSE) to add custom tools. Browse and toggle them with /mcps.
  • Skills — discover and invoke project skills from .agents/skills/ as /skill-name commands, the same way Claude Code does.
  • Persistent memory — durable per-project (.dashnex/memory/) and per-user (~/.dashnex/memory/) facts that flow into the system prompt automatically.
  • Six themes, first-run picker — three for dark terminals, three for light (including a blueprint theme tuned for pure white). Live preview as you navigate, switchable any time with /theme.
  • Quality-of-life TUI — markdown rendering, syntax-highlighted diff previews, @path file mentions with autocomplete, !cmd for one-shot shell commands, full-screen Ctrl+O viewer for long tool output, alternate-screen + bracketed-paste handling.
  • Custom statusline — point code.statusLine at any executable and the footer will render its stdout, with model / cwd / context-remaining / mode piped in as env vars.
  • Silent auto-update — checks the registry on launch and updates the global install in the background. Set code.autoUpdate: false to disable.

Install

npm install -g @dashnex/code
# or
pnpm add -g @dashnex/code

Then launch from any project directory:

dashnex code

The dashnex code CLI ships with @dashnex/cli; @dashnex/code is the engine it loads. Installing the engine separately gives you the latest TUI without waiting for a CLI release.

First-time setup

@dashnex/code needs an API token for either DashNex's ai.dashnex.com gateway (Anthropic + OpenAI, with prompt caching) or GenX.

Add one to ~/.dashnex/settings.json:

{
  "ai":   { "token": "<your-dashnex-ai-token>" },
  // or:
  "genx": { "token": "<your-genx-token>" },

  "code": {
    "model": "anthropic/claude-sonnet-4-6"
    // "theme":      "midnight",   // optional — picker opens on first run
    // "autoUpdate": true,         // default true
    // "debug":      false         // turn on to write JSONL logs
  }
}

Project-level overrides go in <project>/.dashnex/settings.json and win over the global file. Run dashnex code --help for the full flag list.

Daily use

Once running, the input bar at the bottom accepts:

Prefix Meaning
/<command> Slash command. Tab-completes; Tab inserts, Enter submits.
@<path> File mention. Autocompletes against the working tree.
!<command> Run the rest as a shell command in this session (bypasses the assistant).
anything else Send to the model.

Modes (Tab on empty input cycles through them)

Mode Behavior
ask (default) Tools prompt for approval before each invocation.
auto Tools execute immediately, no prompts.
plan Model outlines its approach before using any tools — good for design work.

Built-in slash commands

Command What it does
/help List all available commands.
/model Pick or switch model.
/mode [ask|auto|plan] Switch interaction mode.
/theme [name] Switch theme (opens picker if name omitted).
/resume Browse and resume a previous session.
/memory Show persistent-memory index.
/mcps Manage configured MCP servers.
/compact Summarize history into a single message to free context.
/copy Copy the visible transcript to the clipboard.
/debug Toggle JSONL logging to .dashnex/code/logs/.
/exit Exit the session.

Skills discovered under .agents/skills/ register as additional slash commands automatically.

Keyboard reference

Key Action
/ Navigate input history (when input is non-empty) or autocomplete.
Tab (empty input) Cycle modes.
Tab (slash dropdown) Insert highlighted command, don't submit.
Enter (slash dropdown) Run no-args command, or insert with-args command.
Ctrl+O Open the full-screen viewer for the most recent expandable output.
Ctrl+C / Esc Abort in-flight generation; press again to exit.
Shift+Enter Insert a newline in the input.

MCP servers

Add servers under code.mcpServers in settings.json:

{
  "code": {
    "mcpServers": {
      "filesystem": {
        "command": "npx",
        "args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/me/projects"]
      },
      "remote-api": {
        "url": "https://example.com/mcp/sse"
      },
      "experimental-tool": {
        "command": "node",
        "args": ["./mcp/my-tool.js"],
        "disabled": true
      }
    }
  }
}

Tools exposed by connected servers are namespaced mcp__<server>__<tool> and surfaced through the normal permission flow.

Memory

Two layered locations, both checked on every turn:

  • <project>/.dashnex/memory/MEMORY.md — facts that only apply to this working tree.
  • ~/.dashnex/memory/MEMORY.md — facts about you that apply everywhere.

The system prompt explains the conventions to the model — when to read, when to write, what types (user, feedback, project, reference) — so you usually don't need to touch the files yourself. Run /memory to see what's stored.

Custom statusline

Set code.statusLine to an absolute path or a filename resolvable inside <project>/.dashnex/ (or ~/.dashnex/). The script is invoked every 2 seconds and its stdout replaces the default status bar. The runtime context is piped in as env vars (DASHNEX_MODEL, DASHNEX_CWD, DASHNEX_MODE, DASHNEX_CONTEXT_USED, DASHNEX_CONTEXT_MAX, DASHNEX_SESSION_ID, DASHNEX_CONNECTED, …) so any shell, Python, or Node script can render whatever you like.

Programmatic API

@dashnex/code exports the engine for embedding into other CLIs (e.g. @dashnex/cli):

import { startClient } from "@dashnex/code";

await startClient({
  host: "127.0.0.1",
  port: 7421,
  cwd: process.cwd(),
});

The commands surface (used to register dashnex code as a sub-command) is exposed at @dashnex/code/commands.

Configuration reference

All code.* keys in .dashnex/settings.json:

Key Type Purpose
model string Default model id (e.g. anthropic/claude-sonnet-4-6).
theme string Active theme. Absence triggers the first-run picker.
mode ask | auto | plan Default interaction mode.
maxTokens number Cap on response length.
temperature number Sampling temperature.
defaultSystemPrompt string Replace the built-in system prompt entirely.
systemPrompt string Custom instructions appended to the built-in system prompt.
statusLine string Path to a statusline script (see above).
mcpServers object Map of MCP server configs.
permissions array Per-tool allow/deny/ask rules.
plugins array Plugins to load (string id or { name, config }).
autoUpdate boolean Toggle background update probe on launch (default true).
debug boolean Write JSONL logs to .dashnex/code/logs/YYYY-MM-DD.log.

Development

pnpm install
pnpm build       # one-shot build to dist/
pnpm dev         # vite watch mode
pnpm test        # vitest

The TUI lives in src/client/; the in-process server (sessions, prompts, tools) lives in src/server/. They communicate over HTTP + SSE so the same daemon can serve multiple clients (e.g. web + TUI).

License

UNLICENSED — internal DashNex use.