@diffexai/diffex 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/README.md +5 -725
  3. package/THIRD-PARTY-NOTICES.txt +6 -2
  4. package/dist/AGENTS.md +28 -0
  5. package/dist/cli/session-selection.d.ts +7 -0
  6. package/dist/cli/session-selection.js +181 -0
  7. package/dist/config.d.ts +2 -0
  8. package/dist/config.js +2 -0
  9. package/dist/core/extensions/factory.d.ts +21 -0
  10. package/dist/core/extensions/factory.js +254 -0
  11. package/dist/core/extensions/loader.d.ts +2 -10
  12. package/dist/core/extensions/loader.js +2 -251
  13. package/dist/core/prompt-templates.js +6 -1
  14. package/dist/core/resource-loader.js +7 -2
  15. package/dist/core/system-prompt.js +9 -8
  16. package/dist/core/tools/subagents.js +1 -0
  17. package/dist/main.js +3 -176
  18. package/dist/node_modules/@diffexai/diffex-agent-core/THIRD-PARTY-NOTICES.txt +6 -2
  19. package/dist/node_modules/@diffexai/diffex-agent-core/distribution-components.json +4 -4
  20. package/dist/node_modules/@diffexai/diffex-agent-core/distribution-files.json +1 -1
  21. package/dist/node_modules/@diffexai/diffex-agent-core/package.json +1 -6
  22. package/dist/node_modules/@diffexai/diffex-ai/THIRD-PARTY-NOTICES.txt +6 -2
  23. package/dist/node_modules/@diffexai/diffex-ai/dist/cli.js +0 -0
  24. package/dist/node_modules/@diffexai/diffex-ai/dist/image-models.generated.d.ts +180 -0
  25. package/dist/node_modules/@diffexai/diffex-ai/dist/image-models.generated.js +182 -2
  26. package/dist/node_modules/@diffexai/diffex-ai/dist/providers/data/.manifest.json +1 -1
  27. package/dist/node_modules/@diffexai/diffex-ai/dist/providers/data/kimi-coding.json +1 -1
  28. package/dist/node_modules/@diffexai/diffex-ai/dist/providers/data/nvidia.json +1 -1
  29. package/dist/node_modules/@diffexai/diffex-ai/dist/providers/data/openrouter.json +1 -1
  30. package/dist/node_modules/@diffexai/diffex-ai/dist/providers/data/qwen-token-plan-cn.json +1 -1
  31. package/dist/node_modules/@diffexai/diffex-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  32. package/dist/node_modules/@diffexai/diffex-ai/distribution-components.json +3 -3
  33. package/dist/node_modules/@diffexai/diffex-ai/distribution-files.json +9 -9
  34. package/dist/node_modules/@diffexai/diffex-ai/package.json +1 -6
  35. package/dist/node_modules/@diffexai/diffex-client/THIRD-PARTY-NOTICES.txt +6 -2
  36. package/dist/node_modules/@diffexai/diffex-client/distribution-components.json +3 -3
  37. package/dist/node_modules/@diffexai/diffex-client/distribution-files.json +1 -1
  38. package/dist/node_modules/@diffexai/diffex-client/package.json +1 -6
  39. package/dist/node_modules/@diffexai/diffex-harness-state/THIRD-PARTY-NOTICES.txt +6 -2
  40. package/dist/node_modules/@diffexai/diffex-harness-state/distribution-components.json +2 -2
  41. package/dist/node_modules/@diffexai/diffex-harness-state/distribution-files.json +1 -1
  42. package/dist/node_modules/@diffexai/diffex-harness-state/package.json +1 -6
  43. package/dist/node_modules/@diffexai/diffex-protocol/THIRD-PARTY-NOTICES.txt +6 -2
  44. package/dist/node_modules/@diffexai/diffex-protocol/distribution-components.json +2 -2
  45. package/dist/node_modules/@diffexai/diffex-protocol/distribution-files.json +1 -1
  46. package/dist/node_modules/@diffexai/diffex-protocol/package.json +1 -6
  47. package/dist/node_modules/@diffexai/diffex-telemetry/THIRD-PARTY-NOTICES.txt +6 -2
  48. package/dist/node_modules/@diffexai/diffex-telemetry/distribution-components.json +2 -2
  49. package/dist/node_modules/@diffexai/diffex-telemetry/distribution-files.json +1 -1
  50. package/dist/node_modules/@diffexai/diffex-telemetry/package.json +1 -6
  51. package/dist/node_modules/@diffexai/diffex-tui/THIRD-PARTY-NOTICES.txt +6 -2
  52. package/dist/node_modules/@diffexai/diffex-tui/distribution-components.json +2 -2
  53. package/dist/node_modules/@diffexai/diffex-tui/distribution-files.json +1 -1
  54. package/dist/node_modules/@diffexai/diffex-tui/package.json +1 -6
  55. package/distribution-components.json +13 -13
  56. package/distribution-files.json +66 -74
  57. package/docs/installation.md +118 -0
  58. package/docs/quickstart.md +7 -24
  59. package/docs/usage.md +10 -4
  60. package/npm-shrinkwrap.json +2 -2
  61. package/package.json +36 -10
  62. package/release/distribution-manifest.json +7 -6
  63. package/release/install-package-lock.json +5 -5
  64. package/release/install-package.json +2 -2
  65. package/NOTICE +0 -6
  66. package/dist/node_modules/@diffexai/diffex-agent-core/NOTICE +0 -6
  67. package/dist/node_modules/@diffexai/diffex-ai/NOTICE +0 -6
  68. package/dist/node_modules/@diffexai/diffex-client/NOTICE +0 -6
  69. package/dist/node_modules/@diffexai/diffex-harness-state/NOTICE +0 -6
  70. package/dist/node_modules/@diffexai/diffex-protocol/NOTICE +0 -6
  71. package/dist/node_modules/@diffexai/diffex-telemetry/NOTICE +0 -6
  72. package/dist/node_modules/@diffexai/diffex-tui/NOTICE +0 -6
  73. package/docs/development.md +0 -71
  74. package/docs/docs.json +0 -160
  75. package/docs/images/doom-extension.png +0 -0
  76. package/docs/images/exy.png +0 -0
  77. package/docs/index.md +0 -78
  78. package/docs/invocation-traces.md +0 -82
  79. package/docs/termux.md +0 -127
  80. package/docs/windows.md +0 -17
package/README.md CHANGED
@@ -1,727 +1,7 @@
1
- <p align="center">
2
- <a href="https://diffex.ai/">
3
- <img alt="Diffex wordmark" src="https://raw.githubusercontent.com/diffexai/diffex/main/docs/assets/diffex-wordmark.png" width="480">
4
- </a>
5
- </p>
6
- <p align="center">
7
- <a href="https://www.npmjs.com/package/@diffexai/diffex"><img alt="npm" src="https://img.shields.io/npm/v/@diffexai/diffex?style=flat-square" /></a>
8
- </p>
1
+ # Diffex
9
2
 
10
- > New issues and PRs from new contributors are auto-closed by default. Maintainers review auto-closed issues daily. See [CONTRIBUTING.md](../../CONTRIBUTING.md).
3
+ Coding agent for your terminal.
4
+ See [installation, updates, and removal](docs/installation.md), [quickstart](docs/quickstart.md), and [usage](docs/usage.md).
11
5
 
12
- ---
13
-
14
- Diffex is a minimal terminal coding harness. Adapt Diffex to your workflows, not the other way around, without having to fork and modify Diffex internals. Extend it with TypeScript [Extensions](#extensions), [Skills](#skills), [Prompt Templates](#prompt-templates), and [Themes](#themes). Put your extensions, skills, prompt templates, and themes in [Diffex Packages](#diffex-packages) and share them with others via npm or git.
15
-
16
- Diffex ships with powerful defaults, including session-scoped sub-agents and an interactive Plan mode. You can adapt or replace workflows with extensions and third-party Diffex packages.
17
-
18
- Diffex runs in four modes: interactive, print or JSON, RPC for process integration, and an SDK for embedding in your own apps.
19
-
20
- ## Table of Contents
21
-
22
- - [Quick Start](#quick-start)
23
- - [Providers & Models](#providers--models)
24
- - [Interactive Mode](#interactive-mode)
25
- - [Editor](#editor)
26
- - [Commands](#commands)
27
- - [Keyboard Shortcuts](#keyboard-shortcuts)
28
- - [Plan Mode](#plan-mode)
29
- - [Message Queue](#message-queue)
30
- - [Sessions](#sessions)
31
- - [Branching](#branching)
32
- - [Compaction](#compaction)
33
- - [Settings](#settings)
34
- - [Context Files](#context-files)
35
- - [Customization](#customization)
36
- - [Prompt Templates](#prompt-templates)
37
- - [Skills](#skills)
38
- - [Extensions](#extensions)
39
- - [Themes](#themes)
40
- - [Diffex Packages](#diffex-packages)
41
- - [Programmatic Usage](#programmatic-usage)
42
- - [Philosophy](#philosophy)
43
- - [CLI Reference](#cli-reference)
44
-
45
- ---
46
-
47
- ## Quick Start
48
-
49
- ```bash
50
- npm install -g --ignore-scripts @diffexai/diffex
51
- ```
52
-
53
- `--ignore-scripts` disables dependency lifecycle scripts during install. Diffex does not require install scripts for normal npm installs.
54
-
55
- Authenticate with an API key:
56
-
57
- ```bash
58
- export ANTHROPIC_API_KEY=sk-ant-...
59
- diffex
60
- ```
61
-
62
- Or use your existing subscription:
63
-
64
- ```bash
65
- diffex
66
- /login # Then select provider
67
- ```
68
-
69
- Then just talk to Diffex. By default, Diffex gives the model five tools: `read`, `write`, `edit`, `bash`, and `update_plan`. The model uses these to fulfill your requests and keep multi-step work visible. Add capabilities via [skills](#skills), [prompt templates](#prompt-templates), [extensions](#extensions), or [Diffex packages](#diffex-packages).
70
-
71
- **Platform notes:** [Windows](docs/windows.md) | [Termux (Android)](docs/termux.md) | [tmux](docs/tmux.md) | [Terminal setup](docs/terminal-setup.md) | [Shell aliases](docs/shell-aliases.md)
72
-
73
- ---
74
-
75
- ## Providers & Models
76
-
77
- For each built-in provider, Diffex maintains a list of tool-capable models. Configured provider catalogs refresh automatically; run `diffex update --models` to force an immediate refresh. Authenticate via subscription (`/login`) or API key, then select any model from that provider via `/model` (or Ctrl+L).
78
-
79
- **Subscriptions:**
80
- - Anthropic Claude Pro/Max
81
- - OpenAI ChatGPT Plus/Pro (Codex)
82
- - GitHub Copilot
83
-
84
- **API keys:**
85
- - Anthropic
86
- - Ant Ling
87
- - OpenAI
88
- - Azure OpenAI
89
- - DeepSeek
90
- - NVIDIA NIM
91
- - Google Gemini
92
- - Google Vertex
93
- - Amazon Bedrock
94
- - Mistral
95
- - Groq
96
- - Cerebras
97
- - Cloudflare AI Gateway
98
- - Cloudflare Workers AI
99
- - xAI
100
- - OpenRouter
101
- - Vercel AI Gateway
102
- - ZAI Coding Plan (Global)
103
- - ZAI Coding Plan (China)
104
- - OpenCode Zen
105
- - OpenCode Go
106
- - Hugging Face
107
- - Fireworks
108
- - Together AI
109
- - Baseten
110
- - Kimi For Coding
111
- - MiniMax
112
- - Xiaomi MiMo
113
- - Xiaomi MiMo Token Plan (China)
114
- - Xiaomi MiMo Token Plan (Amsterdam)
115
- - Xiaomi MiMo Token Plan (Singapore)
116
-
117
- Diffex also supports the llama.cpp router server. Configure it with `/login llama.cpp`, manage downloads and loaded models with `/llama`, then select a loaded model with `/model`. See [docs/llama-cpp.md](docs/llama-cpp.md) for setup and usage.
118
-
119
- See [docs/providers.md](docs/providers.md) for other provider setup instructions.
120
-
121
- **Custom providers & models:** Add providers via `~/.diffex/agent/models.json` if they speak a supported API (OpenAI, Anthropic, Google). For custom APIs or OAuth, use extensions. See [docs/models.md](docs/models.md) and [docs/custom-provider.md](docs/custom-provider.md).
122
-
123
- ---
124
-
125
- ## Interactive Mode
126
-
127
- <p align="center"><img src="docs/images/interactive-mode.png" alt="Interactive Mode" width="600"></p>
128
-
129
- The interface from top to bottom:
130
-
131
- - **Startup header** - Shows shortcuts (`/hotkeys` for all), loaded AGENTS.md files, prompt templates, skills, and extensions
132
- - **Messages** - Your messages, assistant responses, tool calls and results, notifications, errors, and extension UI
133
- - **Editor** - Where you type; border color indicates thinking level
134
- - **Footer** - Working directory, session name, total token/cache usage (`↑` input, `↓` output, `R` cache read, `W` cache write, `CH` latest cache hit rate), cost, context usage, current model. Totals include assistant responses, usage reported by tools, and summary generation.
135
-
136
- The editor can be temporarily replaced by other UI, like built-in `/settings` or custom UI from extensions (e.g., a Q&A tool that lets the user answer model questions in a structured format). [Extensions](#extensions) can also replace the editor, add widgets above/below it, a status line, custom footer, or overlays.
137
-
138
- ### Editor
139
-
140
- | Feature | How |
141
- |---------|-----|
142
- | File reference | Type `@` to fuzzy-search project files |
143
- | Path completion | Tab to complete paths |
144
- | Multi-line | Shift+Enter (or Ctrl+Enter on Windows Terminal) |
145
- | External editor | Ctrl+G opens `externalEditor`, `$VISUAL`, `$EDITOR`, Notepad on Windows, or `nano` elsewhere |
146
- | Clipboard | Ctrl+V to paste an image or text (Alt+V on Windows), or drag images onto terminal |
147
- | Bash commands | `!command` runs and sends output to LLM, `!!command` runs without sending |
148
-
149
- Standard editing keybindings for delete word, undo, etc. See [docs/keybindings.md](docs/keybindings.md).
150
-
151
- ### Commands
152
-
153
- Type `/` in the editor to trigger commands. [Extensions](#extensions) can register custom commands, [skills](#skills) are referenced through `/skills`, and [prompt templates](#prompt-templates) expand via `/templatename`.
154
-
155
- | Command | Description |
156
- |---------|-------------|
157
- | `/login`, `/logout` | Manage provider credentials |
158
- | [`/llama`](docs/llama-cpp.md) | Download, load, and unload llama.cpp router models |
159
- | `/model` | Select a model, then its thinking level |
160
- | `/scoped-models` | Enable/disable models for Ctrl+P cycling |
161
- | `/settings` | Theme, installed skills, message delivery, transport |
162
- | `/plan [request]` | Enter Plan mode, optionally submitting a planning request |
163
- | [`/skills`](docs/skills.md#skill-commands) | Search and reference one or more skills in the editor |
164
- | [`/evolve`](docs/evolution.md) | Inspect and control harness evolution and generated skills |
165
- | [`/version`](docs/evolution.md#controls) | Select the active harness revision |
166
- | `/resume` | Pick from previous sessions |
167
- | `/new` | Start a new session |
168
- | `/name <name>` | Set session display name |
169
- | `/session` | Show session info (file, ID, messages, tokens, cost) |
170
- | `/subagents` | Show all sub-agents in the current session |
171
- | `/tree` | Jump to any point in the session and continue from there |
172
- | `/trust` | Save project trust decision for future sessions (restart required) |
173
- | `/fork` | Create a new session from a previous user message |
174
- | `/clone` | Duplicate the current active branch into a new session |
175
- | `/compact [prompt]` | Manually compact context, optional custom instructions |
176
- | `/copy` | Copy last assistant message to clipboard |
177
- | `/export [file]` | Export session to HTML or JSONL file |
178
- | `/import <file>` | Import and resume a session from a JSONL file |
179
- | `/share` | Upload as a secret GitHub Gist and return its direct URL |
180
- | `/reload` | Reload keybindings, extensions, skills, prompts, themes, and context files |
181
- | `/hotkeys` | Show all keyboard shortcuts |
182
- | `/changelog` | Display version history |
183
- | `/quit` | Quit Diffex |
184
-
185
- `/subagents` runs immediately, including while the parent agent is working or compacting.
186
- It displays the current in-memory roster without adding the command or roster to model context.
187
-
188
- ### Keyboard Shortcuts
189
-
190
- See `/hotkeys` for the full list. Customize via `~/.diffex/agent/keybindings.json`. See [docs/keybindings.md](docs/keybindings.md).
191
-
192
- **Commonly used:**
193
-
194
- | Key | Action |
195
- |-----|--------|
196
- | Ctrl+C | Clear editor |
197
- | Ctrl+C twice | Quit |
198
- | Escape | Cancel/abort |
199
- | Escape twice | Open `/tree` |
200
- | Ctrl+L | Open model selector |
201
- | Ctrl+P / Shift+Ctrl+P | Cycle scoped models forward/backward |
202
- | Shift+Tab | Toggle Default and Plan collaboration modes |
203
- | Ctrl+O | Collapse/expand tool output |
204
- | Ctrl+T | Collapse/expand thinking blocks |
205
- | Ctrl+X | Copy the last assistant message |
206
-
207
- Use `/model` or Ctrl+L to select a model, then choose its thinking level when multiple levels are supported. Selecting the current model also opens the thinking selector. Escape keeps the selected model and its current supported level. Thinking-level cycling has no default shortcut; bind `app.thinking.cycle` in `keybindings.json` to enable one.
208
-
209
- ### Plan Mode
210
-
211
- Plan mode is an interactive, evidence-first workflow for producing a decision-complete implementation plan without carrying it out. Press Shift+Tab or run `/plan`; `/plan <request>` enters Plan mode and submits the request. The footer identifies the active mode.
212
-
213
- The model first inspects available evidence and distinguishes discoverable facts from preferences only you can decide. Its model-visible tools are restricted to the invocation's allowed, trusted pre-extension implementations of `read`, `grep`, `find`, and `ls`, plus `request_user_input` when permitted. Mutating, extension, custom, and execution-time tools such as `bash`, `edit`, `write`, and `update_plan` are unavailable. This is a model-tool boundary, not a filesystem sandbox: direct `!` commands and extension side effects remain outside it.
214
-
215
- For material choices, `request_user_input` can show one to three questions. Each has two or three choices plus **Other** for a free-form answer. Answer every question to submit, or cancel to return a non-fatal cancellation result while staying in Plan mode. If the tool is filtered out or a choice list is unsuitable, the model asks an ordinary conversational question instead.
216
-
217
- The official response must contain exactly one non-empty plan between standalone `<proposed_plan>` and `</proposed_plan>` lines outside fenced code. On a valid completed response, Diffex removes only those tag lines and stores and displays the remaining Markdown normally. After the run settles, choose **Implement the plan** to switch to Default and submit `Implement the plan.` in the same session, or **Stay in Plan mode** to dismiss the offer. Queued input suppresses the offer; an unrelated modal defers it. If implementation submission fails, Diffex remains in Default and restores the exact submission text to the editor.
218
-
219
- Plan mode is an interactive branch preference. Resume, fork, and `/tree` navigation restore the newest matching mode entry on the selected branch when it is valid; new sessions, malformed newest matching entries, and non-interactive print, JSON, RPC, and SDK use remain in Default. Historical plans never replay the implementation offer. `update_plan` is a separate execution-time progress checklist and does not enter or leave Plan mode.
220
-
221
- Mode changes use normal lazy session saving: toggling in a new disk-backed session remains in memory until its first assistant message is saved or the session is explicitly persisted. Starting a new run discards an older implementation offer, including when an extension starts the run. Temporary busy activity defers the offer and blocks acceptance until idle, including awaited direct-Bash extension hooks. See [Plan mode details](docs/usage.md#plan-mode).
222
-
223
- ### Message Queue
224
-
225
- Submit messages while the agent is working:
226
-
227
- - **Enter** queues a *steering* message, delivered after the current assistant turn finishes executing its tool calls
228
- - **Alt+Enter** queues a *follow-up* message, delivered only after the agent finishes all work
229
- - **Escape** aborts and restores queued messages to editor
230
- - **Alt+Up** retrieves queued messages back to editor
231
-
232
- On Windows Terminal, `Alt+Enter` is fullscreen by default. Remap it in [docs/terminal-setup.md](docs/terminal-setup.md) so Diffex can receive the follow-up shortcut.
233
-
234
- Configure delivery in [settings](docs/settings.md): `steeringMode` and `followUpMode` can be `"one-at-a-time"` (default, waits for response) or `"all"` (delivers all queued at once). `transport` selects provider transport preference (`"sse"`, `"websocket"`, or `"auto"`) for providers that support multiple transports.
235
-
236
- ### Harness Evolution
237
-
238
- `/evolve` shows evidence eligibility, jobs, memory proposals, generated skill candidates, readable supporting and contradicting evidence, draft diffs, validation, evaluation, target revisions, activation, and rollback. `/version` selects a complete immutable harness revision. Memory and evolved skills change together at the next prompt boundary; in-flight and admitted queued requests remain pinned. The footer shows the active harness and background activity. See [Harness Evolution](docs/evolution.md).
239
-
240
- ---
241
-
242
- ## Sessions
243
-
244
- Sessions are stored as JSONL files with a tree structure. Each entry has an `id` and `parentId`, enabling in-place branching without creating new files. See [docs/session-format.md](docs/session-format.md) for file format.
245
-
246
- The built-in `update_plan` checklist records the latest checklist state in the session. When an unfinished checklist exists after opening or resuming a session, or after successful compaction, Diffex restores it once as hidden context for the next model request. This is not a workflow engine: it does not schedule, execute, gate, verify, or prove work.
247
-
248
- The selected collaboration mode is stored separately as an interactive branch preference. Resume, fork, and `/tree` navigation restore it from the selected branch; non-interactive modes always use Default and do not overwrite that preference.
249
-
250
- ### Management
251
-
252
- Sessions auto-save to `~/.diffex/agent/sessions/` organized by working directory.
253
-
254
- ```bash
255
- diffex -c # Continue most recent session
256
- diffex -r # Browse and select from past sessions
257
- diffex --no-session # Ephemeral mode (don't save)
258
- diffex --name "my task" # Set session display name at startup
259
- diffex --session <path|id> # Use specific session file or ID
260
- diffex --fork <path|id> # Fork specific session file or ID into a new session
261
- ```
262
-
263
- Use `/session` in interactive mode to see the current session ID before reusing it with `--session <id>` or `--fork <id>`.
264
-
265
- ### Branching
266
-
267
- **`/tree`** - Navigate the session tree in-place. Select any previous point, continue from there, and switch between branches. All history preserved in a single file.
268
-
269
- <p align="center"><img src="docs/images/tree-view.png" alt="Tree View" width="600"></p>
270
-
271
- - Search by typing, fold/unfold and jump between branches with Ctrl+←/Ctrl+→ or Alt+←/Alt+→, page with ←/→
272
- - Filter modes (Ctrl+O): default → no-tools → user-only → labeled-only → all
273
- - Press Ctrl+X to copy the selected message
274
- - Press Shift+L to label entries as bookmarks and Shift+T to toggle label timestamps
275
-
276
- **`/fork`** - Create a new session file from a previous user message on the active branch. Opens a selector, copies the active path up to that point, and places the selected prompt in the editor for modification.
277
-
278
- **`/clone`** - Duplicate the current active branch into a new session file at the current position. The new session keeps the full active-path history and opens with an empty editor.
279
-
280
- **`--fork <path|id>`** - Fork an existing session file or partial session UUID directly from the CLI. This copies the full source session into a new session file in the current project.
281
-
282
- ### Compaction
283
-
284
- Long sessions can exhaust context windows. Compaction summarizes older messages while keeping recent ones.
285
-
286
- **Manual:** `/compact` or `/compact <custom instructions>`
287
-
288
- **Automatic:** Enabled by default. Triggers on context overflow (recovers and retries) or when approaching the limit (proactive). Configure via `/settings` or `settings.json`.
289
-
290
- Compaction is lossy. The full history remains in the JSONL file; use `/tree` to revisit. Customize compaction behavior via [extensions](#extensions). See [docs/compaction.md](docs/compaction.md) for internals.
291
-
292
- ---
293
-
294
- ## Settings
295
-
296
- Use `/settings` to modify common options, or edit JSON files directly:
297
-
298
- | Location | Scope |
299
- |----------|-------|
300
- | `~/.diffex/agent/settings.json` | Global (all projects) |
301
- | `.diffex/settings.json` | Project (overrides global) |
302
-
303
- See [docs/settings.md](docs/settings.md) for all options.
304
-
305
- ### Project Trust
306
-
307
- On interactive startup, Diffex asks before trusting a project folder that contains project-local settings, resources, or project `.agents/skills` and has no saved decision for the folder or a parent folder in `~/.diffex/agent/trust.json`. Trusting a project allows Diffex to load `.diffex/settings.json` and `.diffex` resources, install missing project packages, and execute project extensions.
308
-
309
- Before the trust decision, Diffex loads only context files, user/global extensions, and CLI `-e` extensions so they can handle the `project_trust` event. Project-local extensions, project package-managed extensions, and project settings are loaded only after the project is trusted. This split also applies when switching to a session from a different cwd whose trust has not been resolved in the current process.
310
-
311
- Non-interactive modes (`-p`, `--mode json`, and `--mode rpc`) do not show a trust prompt. Without an applicable saved trust decision, they use `defaultProjectTrust` from global settings: `ask` (default) and `never` ignore those project resources, while `always` trusts them. Pass `--approve`/`-a` or `--no-approve`/`-na` to override project trust for one run.
312
-
313
- If no extension or saved decision applies, `defaultProjectTrust` controls the fallback behavior. Set it to `"ask"`, `"always"`, or `"never"` in `~/.diffex/agent/settings.json`, or change it with `/settings`.
314
-
315
- `diffex config` and package commands use the same project trust flow, except `diffex update` never prompts. Pass `--approve` to trust project-local settings for one command or `--no-approve` to ignore them.
316
-
317
- Use `/trust` in interactive mode to save a project trust decision for future sessions, including trust for the immediate parent folder. It writes `~/.diffex/agent/trust.json` only; the current session is not reloaded, so restart Diffex for changes to take effect.
318
-
319
- ### Provider attribution and update checks
320
-
321
- Diffex does not send install or update telemetry reports.
322
- The former `enableInstallTelemetry` setting and `DIFFEX_TELEMETRY` variable are no longer used.
323
-
324
- Optional attribution headers for OpenRouter, Cloudflare, and direct NVIDIA NIM requests have a separate `enableProviderAttribution` setting, which defaults to `false`.
325
- Enable it through **Provider attribution** in `/settings`, or override it with `DIFFEX_PROVIDER_ATTRIBUTION=1` (`0` disables it).
326
- This control does not affect update checks, OpenCode session headers, or explicitly configured request headers.
327
-
328
- Startup update checks query `https://api.diffex.ai/api/latest-version`.
329
- Disable automatic checks with `DIFFEX_SKIP_VERSION_CHECK=1`.
330
- Use `--offline` or `DIFFEX_OFFLINE=1` to disable startup network operations, including update checks and package update checks.
331
-
332
- ---
333
-
334
- ## Context Files
335
-
336
- Diffex loads `AGENTS.md` (or `CLAUDE.md`) at startup from:
337
- - `~/.diffex/agent/AGENTS.md` (global)
338
- - Parent directories (walking up from cwd)
339
- - Current directory
340
-
341
- If a directory contains `AGENTS.override.md`, Diffex loads it instead of `AGENTS.md` or `CLAUDE.md` from that directory. Context files from other directories are still concatenated.
342
-
343
- Use for project instructions (`AGENTS.md`/`CLAUDE.md`), conventions, common commands. All matching files are concatenated.
344
-
345
- Disable context file loading with `--no-context-files` (or `-nc`).
346
-
347
- ### System Prompt
348
-
349
- Replace the default system prompt with `.diffex/SYSTEM.md` (project) or `~/.diffex/agent/SYSTEM.md` (global). Append without replacing via `APPEND_SYSTEM.md`.
350
-
351
- ---
352
-
353
- ## Customization
354
-
355
- ### Prompt Templates
356
-
357
- Reusable prompts as Markdown files. Type `/name` to expand.
358
-
359
- ```markdown
360
- <!-- ~/.diffex/agent/prompts/review.md -->
361
- Review this code for bugs, security issues, and performance problems.
362
- Focus on: {{focus}}
363
- ```
364
-
365
- Place in `~/.diffex/agent/prompts/`, `.diffex/prompts/`, or a [Diffex package](#diffex-packages) to share with others. See [docs/prompt-templates.md](docs/prompt-templates.md).
366
-
367
- ### Skills
368
-
369
- On-demand capability packages following the [Agent Skills standard](https://agentskills.io). Use `/skills` to choose installed workspace, installed global, or evolved skills and insert one or more versioned references into a task, or let the agent load skills automatically.
370
-
371
- ```markdown
372
- <!-- ~/.diffex/agent/skills/my-skill/SKILL.md -->
373
- # My Skill
374
- Use this skill when the user asks about X.
375
-
376
- ## Steps
377
- 1. Do this
378
- 2. Then that
379
- ```
380
-
381
- Place in `~/.diffex/agent/skills/`, `~/.agents/skills/`, `.diffex/skills/`, or `.agents/skills/` (from `cwd` up through parent directories) or a [Diffex package](#diffex-packages) to share with others. See [docs/skills.md](docs/skills.md).
382
-
383
- ### Extensions
384
-
385
- <p align="center"><img src="docs/images/doom-extension.png" alt="Doom Extension" width="600"></p>
386
-
387
- TypeScript modules that extend Diffex with custom tools, commands, keyboard shortcuts, event handlers, and UI components.
388
-
389
- ```typescript
390
- export default function (diffex: ExtensionAPI) {
391
- diffex.registerTool({ name: "deploy", ... });
392
- diffex.registerCommand("stats", { ... });
393
- diffex.on("tool_call", async (event, ctx) => { ... });
394
- }
395
- ```
396
-
397
- The default export can also be `async`. Diffex waits for async extension factories before startup continues, which is useful for one-time initialization such as fetching remote model lists before calling `diffex.registerProvider()`.
398
-
399
- **What's possible:**
400
- - Custom tools (or replace built-in tools entirely)
401
- - Alternative sub-agent and planning workflows
402
- - Custom compaction and summarization
403
- - Permission gates and path protection
404
- - Custom editors and UI components
405
- - Status lines, headers, footers
406
- - Git checkpointing and auto-commit
407
- - SSH and sandbox execution
408
- - MCP server integration
409
- - Make Diffex look like Claude Code
410
- - Games while waiting (yes, Doom runs)
411
- - ...anything you can dream up
412
-
413
- Place in `~/.diffex/agent/extensions/`, `.diffex/extensions/`, or a [Diffex package](#diffex-packages) to share with others. See [docs/extensions.md](docs/extensions.md) and [examples/extensions/](examples/extensions/).
414
-
415
- ### Themes
416
-
417
- Built-in: `dark`, `light`. Themes hot-reload: modify the active theme file and Diffex immediately applies changes.
418
-
419
- Place in `~/.diffex/agent/themes/`, `.diffex/themes/`, or a [Diffex package](#diffex-packages) to share with others. See [docs/themes.md](docs/themes.md).
420
-
421
- ### Diffex Packages
422
-
423
- Bundle and share extensions, skills, prompts, and themes via npm or git. Find packages on [npmjs.com](https://www.npmjs.com/search?q=keywords%3Adiffex-package) or the [upstream Discord](https://discord.com/channels/1456806362351669492/1457744485428629628).
424
-
425
- > **Security:** Diffex packages run with full system access. Extensions execute arbitrary code, and skills can instruct the model to perform any action including running executables. Review source code before installing third-party packages.
426
-
427
- ```bash
428
- diffex install npm:@foo/diffex-tools
429
- diffex install npm:@foo/diffex-tools@1.2.3 # pinned version
430
- diffex install git:github.com/user/repo
431
- diffex install git:github.com/user/repo@v1 # tag or commit
432
- diffex install git:git@github.com:user/repo
433
- diffex install git:git@github.com:user/repo@v1 # tag or commit
434
- diffex install https://github.com/user/repo
435
- diffex install https://github.com/user/repo@v1 # tag or commit
436
- diffex install ssh://git@github.com/user/repo
437
- diffex install ssh://git@github.com/user/repo@v1 # tag or commit
438
- diffex remove npm:@foo/diffex-tools
439
- diffex uninstall npm:@foo/diffex-tools # alias for remove
440
- diffex list
441
- diffex update # update Diffex only
442
- diffex update --all # update Diffex and packages
443
- diffex update --extensions # update packages only
444
- diffex update --models # refresh model catalogs only
445
- diffex update --self # update Diffex only
446
- diffex update --self --force # reinstall Diffex even if current
447
- diffex update npm:@foo/diffex-tools # update one package
448
- diffex config # enable/disable extensions, skills, prompts, themes
449
- ```
450
-
451
- Interactive package installs ask whether to use global storage (`~/.diffex/agent/git/`, `~/.diffex/agent/npm/`) or workspace storage (`.diffex/git/`, `.diffex/npm/`) and show the trust implications. Non-interactive installs default to global; use `-l` to select workspace scope explicitly. Git `@ref` values are pinned tags or commits; pinned packages are skipped by `diffex update --extensions` and `diffex update --all`, so use `diffex install git:host/user/repo@new-ref` to move an existing package to a new ref. Git packages install dependencies with `npm install --omit=dev` by default, so runtime deps must be listed under `dependencies`; when `npmCommand` is configured, git packages use plain `install` for compatibility with wrappers. If you use a Node version manager and want package installs to reuse a stable npm context, set `npmCommand` in `settings.json`, for example `["mise", "exec", "node@20", "--", "npm"]`.
452
-
453
- Create a package by adding the compatibility `diffex` key to `package.json`:
454
-
455
- ```json
456
- {
457
- "name": "my-diffex-package",
458
- "keywords": ["diffex-package"],
459
- "diffex": {
460
- "extensions": ["./extensions"],
461
- "skills": ["./skills"],
462
- "prompts": ["./prompts"],
463
- "themes": ["./themes"]
464
- }
465
- }
466
- ```
467
-
468
- Without a `diffex` manifest, Diffex auto-discovers from conventional directories (`extensions/`, `skills/`, `prompts/`, `themes/`).
469
-
470
- See [docs/packages.md](docs/packages.md).
471
-
472
- ---
473
-
474
- ## Programmatic Usage
475
-
476
- ### SDK
477
-
478
- ```typescript
479
- import { createAgentSession, ModelRuntime, SessionManager } from "@diffexai/diffex";
480
-
481
- const modelRuntime = await ModelRuntime.create();
482
- const { session } = await createAgentSession({
483
- sessionManager: SessionManager.inMemory(),
484
- modelRuntime,
485
- });
486
-
487
- await session.prompt("What files are in the current directory?");
488
- ```
489
-
490
- For advanced multi-session runtime replacement, use `createAgentSessionRuntime()` and `AgentSessionRuntime`.
491
-
492
- See [docs/sdk.md](docs/sdk.md) and [examples/sdk/](examples/sdk/).
493
-
494
- ### RPC Mode
495
-
496
- For non-Node.js integrations, use RPC mode over stdin/stdout:
497
-
498
- ```bash
499
- diffex --mode rpc
500
- ```
501
-
502
- RPC mode uses strict LF-delimited JSONL framing. Clients must split records on `\n` only. Do not use generic line readers like Node `readline`, which also split on Unicode separators inside JSON payloads.
503
-
504
- See [docs/rpc.md](docs/rpc.md) for the protocol.
505
-
506
- ---
507
-
508
- ## Philosophy
509
-
510
- Diffex is aggressively extensible so it doesn't have to dictate your workflow. Features that other tools bake in can be built with [extensions](#extensions), [skills](#skills), or installed from third-party [Diffex packages](#diffex-packages). This keeps the core minimal while letting you shape Diffex to fit how you work.
511
-
512
- **No MCP.** Build CLI tools with READMEs (see [Skills](#skills)), or build an extension that adds MCP support. [Why?](https://mariozechner.at/posts/2025-11-02-what-if-you-dont-need-mcp/)
513
-
514
- **Session-scoped sub-agents.** The model can delegate work to child agents, and `/subagents` shows their current status and original tasks without sending that roster to the model.
515
-
516
- **No permission popups.** Run in a container, or build your own confirmation flow with [extensions](#extensions) inline with your environment and security requirements.
517
-
518
- **Focused Plan mode.** Interactive Plan mode provides read-only planning, structured clarification, and an explicit same-session implementation handoff. The separate `update_plan` tool remains a lightweight execution progress checklist. Build an [extension](#extensions) or install a package for different approval or planning workflows.
519
-
520
- **No persistent built-in to-dos.** Use a TODO.md file, or build your own with [extensions](#extensions).
521
-
522
- **No background bash.** Use tmux. Full observability, direct interaction.
523
-
524
-
525
-
526
- ---
527
-
528
- ## CLI Reference
529
-
530
- ```bash
531
- diffex [options] [@files...] [messages...]
532
- ```
533
-
534
- ### Package Commands
535
-
536
- ```bash
537
- diffex install <source> [-l] # Install package, -l for project-local
538
- diffex remove <source> [-l] # Remove package
539
- diffex uninstall <source> [-l] # Alias for remove
540
- diffex update [source|self|diffex] # Update Diffex only, or one package source
541
- diffex update --all # Update Diffex and packages
542
- diffex update --extensions # Update packages only
543
- diffex update --models # Refresh model catalogs only
544
- diffex update --self # Update Diffex only
545
- diffex update --self --force # Reinstall Diffex even if current
546
- diffex update --extension <src> # Update one package
547
- diffex list # List installed packages
548
- diffex config # Enable/disable package resources
549
- ```
550
-
551
- `diffex config` and project package commands accept `--approve`/`--no-approve` to trust or ignore project-local settings for one command. `diffex update` never prompts for project trust.
552
-
553
- ### Modes
554
-
555
- | Flag | Description |
556
- |------|-------------|
557
- | (default) | Interactive mode |
558
- | `-p`, `--print` | Print response and exit |
559
- | `--mode json` | Output all events as JSON lines (see [docs/json.md](docs/json.md)) |
560
- | `--mode rpc` | RPC mode for process integration (see [docs/rpc.md](docs/rpc.md)) |
561
- | `--export <in> [out]` | Export session to HTML |
562
-
563
- In print mode, Diffex also reads piped stdin and merges it into the initial prompt:
564
-
565
- ```bash
566
- cat README.md | diffex -p "Summarize this text"
567
- ```
568
-
569
- ### Model Options
570
-
571
- | Option | Description |
572
- |--------|-------------|
573
- | `--provider <name>` | Provider (anthropic, openai, google, etc.) |
574
- | `--model <pattern>` | Model pattern or ID (supports `provider/id` and optional `:<thinking>`) |
575
- | `--api-key <key>` | API key (overrides env vars) |
576
- | `--thinking <level>` | `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max` |
577
- | `--models <patterns>` | Comma-separated patterns for Ctrl+P cycling |
578
- | `--list-models [search]` | List available models |
579
-
580
- ### Session Options
581
-
582
- | Option | Description |
583
- |--------|-------------|
584
- | `-c`, `--continue` | Continue most recent session |
585
- | `-r`, `--resume` | Browse and select session |
586
- | `--session <path\|id>` | Use specific session file or partial UUID |
587
- | `--fork <path\|id>` | Fork specific session file or partial UUID into a new session |
588
- | `--session-dir <dir>` | Custom session storage directory |
589
- | `--no-session` | Ephemeral mode (don't save) |
590
- | `--name <name>`, `-n <name>` | Set session display name at startup |
591
-
592
- ### Tool Options
593
-
594
- | Option | Description |
595
- |--------|-------------|
596
- | `--tools <list>`, `-t <list>` | Allowlist specific tool names across built-in, extension, and custom tools |
597
- | `--exclude-tools <list>`, `-xt <list>` | Disable specific tool names across built-in, extension, and custom tools |
598
- | `--no-builtin-tools`, `-nbt` | Disable built-in tools by default but keep extension/custom tools enabled |
599
- | `--no-tools`, `-nt` | Disable all tools by default |
600
-
601
- Available built-in tools: `read`, `bash`, `edit`, `write`, `update_plan`, `grep`, `find`, `ls`
602
-
603
- ### Resource Options
604
-
605
- | Option | Description |
606
- |--------|-------------|
607
- | `-e`, `--extension <source>` | Load extension from path, npm, or git (repeatable) |
608
- | `--no-extensions` | Disable extension discovery |
609
- | `--skill <path>` | Load skill (repeatable) |
610
- | `--no-skills` | Disable skill discovery |
611
- | `--prompt-template <path>` | Load prompt template (repeatable) |
612
- | `--no-prompt-templates` | Disable prompt template discovery |
613
- | `--theme <path>` | Load theme (repeatable) |
614
- | `--no-themes` | Disable theme discovery |
615
- | `--no-context-files`, `-nc` | Disable AGENTS.md and CLAUDE.md context file discovery |
616
-
617
- Combine `--no-*` with explicit flags to load exactly what you need, ignoring settings.json (e.g., `--no-extensions -e ./my-ext.ts`).
618
-
619
- ### Other Options
620
-
621
- | Option | Description |
622
- |--------|-------------|
623
- | `--system-prompt <text>` | Replace default prompt (context files and skills still appended) |
624
- | `--append-system-prompt <text>` | Append to system prompt |
625
- | `--tui-mode <mode>` | TUI mode: `regular` (default) or experimental `fullscreen` |
626
- | `--verbose` | Force verbose startup |
627
- | `-a`, `--approve` | Trust project-local files for this run |
628
- | `-na`, `--no-approve` | Ignore project-local files for this run |
629
- | `-h`, `--help` | Show help |
630
- | `-v`, `--version` | Show version |
631
-
632
- ### File Arguments
633
-
634
- Prefix files with `@` to include in the message:
635
-
636
- ```bash
637
- diffex @prompt.md "Answer this"
638
- diffex -p @screenshot.png "What's in this image?"
639
- diffex @code.ts @test.ts "Review these files"
640
- ```
641
-
642
- ### Examples
643
-
644
- ```bash
645
- # Interactive with initial prompt
646
- diffex "List all .ts files in src/"
647
-
648
- # Non-interactive
649
- diffex -p "Summarize this codebase"
650
-
651
- # Non-interactive with piped stdin
652
- cat README.md | diffex -p "Summarize this text"
653
-
654
- # Named one-shot session
655
- diffex --name "release audit" -p "Audit this repository"
656
-
657
- # Different model
658
- diffex --provider openai --model gpt-4o "Help me refactor"
659
-
660
- # Model with provider prefix (no --provider needed)
661
- diffex --model openai/gpt-4o "Help me refactor"
662
-
663
- # Model with thinking level shorthand
664
- diffex --model sonnet:high "Solve this complex problem"
665
-
666
- # Limit model cycling
667
- diffex --models "claude-*,gpt-4o"
668
-
669
- # Read-only mode
670
- diffex --tools read,grep,find,ls -p "Review the code"
671
-
672
- # Disable one extension or built-in tool while keeping the rest available
673
- diffex --exclude-tools ask_question
674
-
675
- # High thinking level
676
- diffex --thinking high "Solve this complex problem"
677
- ```
678
-
679
- ### Environment Variables
680
-
681
- | Variable | Description |
682
- |----------|-------------|
683
- | `AI_AGENT` | Set to the compatibility identifier `diffex` by the CLI and RPC entry points so generic tooling can attribute child processes to Diffex |
684
- | `DIFFEX_CODING_AGENT` | Set to `true` by the CLI and RPC entry points so child processes can detect that they run inside Diffex |
685
- | `DIFFEX_CODING_AGENT_DIR` | Override config directory (default: `~/.diffex/agent`) |
686
- | `DIFFEX_CODING_AGENT_SESSION_DIR` | Override session storage directory (overridden by `--session-dir`) |
687
- | `DIFFEX_PACKAGE_DIR` | Override package directory (useful for Nix/Guix where store paths tokenize poorly) |
688
- | `DIFFEX_OFFLINE` | Disable startup network operations, including update checks and package update checks |
689
- | `DIFFEX_SKIP_VERSION_CHECK` | Skip the Diffex release check at startup |
690
- | `DIFFEX_PROVIDER_ATTRIBUTION` | Override optional provider attribution headers: `1`/`true`/`yes` enables them; `0`/`false`/`no` disables them. Does not control update checks |
691
- | `DIFFEX_CACHE_RETENTION` | Set to `long` for extended prompt cache (Anthropic: 1h, OpenAI: 24h) |
692
- | `VISUAL`, `EDITOR` | Fallback external editor for Ctrl+G when `externalEditor` is unset; defaults to Notepad on Windows and `nano` elsewhere |
693
-
694
- Commands run by the LLM-callable bash tool also receive current session metadata:
695
-
696
- | Variable | Description |
697
- |----------|-------------|
698
- | `DIFFEX_SESSION_ID` | Current session ID |
699
- | `DIFFEX_SESSION_FILE` | Absolute session JSONL path; unset for ephemeral sessions |
700
- | `DIFFEX_PROVIDER` | Currently selected model provider |
701
- | `DIFFEX_MODEL` | Currently selected model ID |
702
- | `DIFFEX_REASONING_LEVEL` | Current effective reasoning level |
703
-
704
- These values are resolved when each command starts. See [Environment Variables](docs/environment-variables.md#bash-tool-session-environment) for semantics, examples, and custom-tool opt-out.
705
-
706
- ---
707
-
708
- ## Contributing & Development
709
-
710
- See [CONTRIBUTING.md](../../CONTRIBUTING.md) for guidelines and [docs/development.md](docs/development.md) for setup, forking, and debugging.
711
-
712
- ## License
713
-
714
- Apache-2.0 for Diffex, copyright 2026 Luntraa, Inc.
715
- Pi-derived portions retain their MIT terms and upstream copyright notice.
716
- See LICENSE, NOTICE, and THIRD-PARTY-NOTICES.txt in the distribution.
717
-
718
- ## Included modules
719
-
720
- The CLI package includes the Diffex AI toolkit, agent framework, terminal UI, and other required internal runtime modules.
721
- Install only `@diffexai/diffex`; separate Diffex module packages are not required or published.
722
-
723
- <p align="center">
724
- The upstream project's domain was graciously donated by
725
- <br /><br />
726
- <a href="https://exe.dev"><img src="docs/images/exy.png" alt="Exy mascot" width="48" /><br />exe.dev</a>
727
- </p>
6
+ Diffex is licensed under Apache-2.0; Pi-derived portions retain their MIT terms.
7
+ See LICENSE and THIRD-PARTY-NOTICES.txt.