Niral DI
Install Niral DI standalone from npm or use it inside Niral. Set up a provider, learn every CLI command and flag, understand the approval model, and fix common problems.
On this page 9 sections
DI is a coding agent that reads your project, edits it, and checks its own work. It runs on a model you choose and supply the key for: there is no default model, no substitution and no Niral account.
It ships three ways. The standalone package niral-di works in any project, whether or not it uses Niral. The framework includes it as niral di. And Niral Studio runs the same engine in the browser.
Install
Standalone, in any project, with Node.js 20.3 or newer:
npm install -g niral-di
niral-di --version
Without a global install:
npx niral-di --help
If your project already uses Niral, DI is included and the command is niral di with a space. Everything below applies to both; only the command name differs.
Set up a provider
niral-di setup
This asks which provider you use (OpenAI, Claude, Azure OpenAI or a custom endpoint), the exact model name, and the environment variable holding your key. The key itself is never written to configuration, never passed as an argument, and never stored in your project.
For automation, pass the flags instead:
niral-di setup --protocol responses \
--base-url https://your-provider.example/v1 \
--model YOUR_EXACT_MODEL \
--auth bearer --key-env NIRAL_DI_API_KEY
Then confirm it took:
niral-di status
status prints the saved configuration and whether a credential is readable. It never prints the credential.
Commands
niral-di --version show the installed version
niral-di --help list commands and flags
niral-di setup choose and save a provider
niral-di status show configuration, never credentials
niral-di ask "<prompt>" one request, then exit
niral-di chat a conversation, kept per project
Useful flags:
niral-di chat --new start a fresh conversation
niral-di chat --read-only inspection only; no file changes
niral-di ask "<prompt>" --root ./app work in a different directory
niral-di ask "<prompt>" --no-tools prompt only; reads nothing
A conversation is kept per project, so closing the terminal does not discard it. --new starts another; /clear inside a chat forgets the current one.
What it can do
DI has eighteen tools. Files: create directories and files, edit part of a file without rewriting it, move, delete, and search by meaning rather than exact text. Verification: compile .niral, .jsx and .tsx, typecheck .nrs, parse .js and .ts, read language-server diagnostics and run tests. Context: Git history and uncommitted changes, a public web page, a public GitHub repository without cloning, and a bounded read-only research helper. Commands: one program at a time, in your project.
Two tools are Niral-specific and appear only in a Niral project: running niral test, and reading a dev server's failing requests.
Approval
Every tool call waits for you. Only y approves; Enter denies. There is no auto-approve flag.
Commands never reach a shell interpreter. The command line is tokenised and the program spawned directly, so there is no chaining, redirection, globbing or substitution: npm install && rm -rf . is refused, not run. Destructive and privileged commands are refused with the reason.
Git is read-only. DI reads status, diffs and history, but cannot stage, commit, push, stash or discard. Asked to commit, it drafts the message for you to use.
What it will not reach
Paths outside the project, dot paths, and conventional data, dependency, build, backup and secret paths are unreachable, as are symlinks and binary files. An edit requires the hash from the latest read, so a file that changed since DI read it is never overwritten. Originals are backed up outside the project before any write or delete.
These are guardrails against ordinary mistakes, not a sandbox. DI runs with your own account's permissions, and a secret sitting in ordinary source can still be disclosed through a read you approve. A model's output is not evidence that the work is correct: DI is instructed to say what it did not verify, and you should read what it changed.
Troubleshooting
niral-di: command not found
The global bin directory is not on your PATH. Check where npm puts it:
npm prefix -g
Add that directory's bin to your PATH, or skip the global install and use npx niral-di instead.
niral-di --version fails, but npm view niral-di version works
These test different things. npm view asks the registry over the network; niral-di --version runs the binary on your disk. If one works and the other does not, your shell is using a cached path to an older install:
hash -r
niral-di --version
Opening a new terminal tab has the same effect. Versions before 0.1.2 had no --version flag at all, so upgrade if it still fails:
npm install -g niral-di
npm view reports an old version after an upgrade
npm caches registry metadata for a few minutes. To see the current state:
npm cache clean --force
npm view niral-di version
DI: not configured
No provider is saved. Run niral-di setup, then niral-di status to confirm.
DI: provider HTTP 404
The base URL or model name is wrong. A 404 comes from the provider, not from DI. Check niral-di status, then confirm the exact model name with your provider: deployment names on Azure differ from model names elsewhere. Re-run niral-di setup --replace to correct it.
DI: provider HTTP 401
The key is missing or wrong. DI reads it from the environment variable you named during setup, so confirm that variable is exported in the shell you are running from:
niral-di status
echo $NIRAL_DI_API_KEY | head -c 4
niral-di needs Node 20.3 or newer
Your Node is too old. Check with node --version and upgrade from nodejs.org.
A tool call was refused
Read the reason it gives. Shell operators, destructive commands and privileged commands are refused by design. Paths outside the project, dot paths and secret paths are unreachable by design. These are not bugs.
DI says it cannot verify something
That is intended. DI reports what it did not check rather than implying success. Run the check yourself, or ask it to.
Using it as a library
The package is importable, so DI can run inside your own Node program:
import { runAgent, createProvider } from "niral-di";
import { createTools } from "niral-di/tools";
const provider = createProvider({
protocol: "chat-completions",
baseURL: "https://your-provider.example/v1",
model: "your-model",
auth: "bearer",
apiKey: process.env.YOUR_KEY,
});
const result = await runAgent({
provider,
prompt: "Summarise this project's routes",
tools: createTools({ root: process.cwd(), home: "/tmp/di-home", readOnly: true }),
authorize: async (call) => confirmSomehow(call),
});
Your program supplies authorize. It must return exactly true to allow a call: any other value, including a truthy one like "yes" or 1, denies it. Tool schemas are not permissions. readOnly: true withholds every tool that changes the project.
Privacy
Your prompt and the results of approved tool calls are sent to the provider you configured. Workspace content is untrusted input: review what DI asks to do. Retention and billing are governed by that provider, not by Niral, and DI makes no blanket privacy guarantee on their behalf.
