nex-code 0.3.43 → 0.3.54

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 (3) hide show
  1. package/README.md +245 -37
  2. package/dist/nex-code.js +537 -400
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  ```
2
- ▀▄ ▀▄ nex-code v0.3.x
3
- █████ qwen3-coder:480b · /help
4
- ▄███▄
2
+ ██▄▄██ nex-code v0.3.54
3
+ █▀██▀█ qwen3-coder:480b · /help
4
+ ▀████▀
5
5
  ```
6
6
 
7
7
  <p align="center">
8
- <b>The open-source coding CLI for Ollama Cloud — and every other provider.</b><br>
9
- Free by default with Ollama. Switch to OpenAI, Anthropic, or Gemini anytime.<br>
10
- A lightweight, powerful alternative to Claude Code and Gemini CLI.
8
+ <b>The open-source agentic coding assistant for Ollama Cloud — and every other provider.</b><br>
9
+ Use it in the terminal or install the built-in <b>VS Code extension</b> for a sidebar chat panel.<br>
10
+ Free by default with Ollama. Switch to OpenAI, Anthropic, or Gemini anytime.
11
11
  </p>
12
12
 
13
13
  <p align="center">
@@ -19,7 +19,8 @@
19
19
  <img src="https://img.shields.io/badge/Ollama_Cloud-supported-brightgreen.svg" alt="Ollama Cloud: supported">
20
20
  <img src="https://img.shields.io/badge/node-%3E%3D18-brightgreen.svg" alt="Node >= 18">
21
21
  <img src="https://img.shields.io/badge/dependencies-2-green.svg" alt="Dependencies: 2">
22
- <img src="https://img.shields.io/badge/tests-2059-blue.svg" alt="Tests: 2059">
22
+ <img src="https://img.shields.io/badge/tests-3074-blue.svg" alt="Tests: 3074">
23
+ <img src="https://img.shields.io/badge/VS_Code-extension-007ACC.svg" alt="VS Code extension">
23
24
  </p>
24
25
 
25
26
  ---
@@ -67,12 +68,13 @@ npm update -g nex-code
67
68
 
68
69
  | | **nex-code** | Claude Code | Gemini CLI | Aider |
69
70
  |---|---|---|---|---|
71
+ | **VS Code extension** | ✅ Built-in sidebar panel | ✅ | ❌ | ❌ |
70
72
  | **Free with Ollama** | ✅ Native, first-class | ⚠️ Workaround | ❌ | ✅ |
71
73
  | **Ollama Cloud support** | ✅ 47+ models, native | ⚠️ API-compat only | ❌ | ✅ |
72
74
  | **Multi-provider runtime swap** | ✅ 5 providers, no restart | ❌ Claude-only | ❌ Gemini-only | ✅ |
73
75
  | **Tool tiers (adapts to model)** | ✅ essential/standard/full | ❌ | ❌ | ❌ |
74
76
  | **5-layer open-model auto-fix** | ✅ | ❌ | ❌ | ⚠️ |
75
- | **Undo / Redo** | ✅ | ❌ | ❌ | ❌ |
77
+ | **Undo / Redo (persistent)** | ✅ Survives restart | ❌ | ❌ | ❌ |
76
78
  | **Cost tracking + budgets** | ✅ | ❌ | ❌ | ❌ |
77
79
  | **Pre-push secret detection** | ✅ | ❌ | ❌ | ❌ |
78
80
  | **Browser agent (headless)** | ✅ Playwright-based | ❌ | ⚠️ Experimental | ❌ |
@@ -84,7 +86,10 @@ npm update -g nex-code
84
86
  | **Open-source** | ✅ MIT | ❌ | ✅ Apache 2.0 | ✅ |
85
87
  | **Runtime dependencies** | **2** (axios, dotenv) | Many | Many | Heavy (Python) |
86
88
  | **Startup time** | **~100ms** | ~400ms | ~300ms | Slow |
87
- | **Test coverage** | 2059 tests, 84% | | | |
89
+ | **Plugin API** | registerTool + hooks | | | |
90
+ | **Skill marketplace** | ✅ Install from git | ❌ | ❌ | ❌ |
91
+ | **Audit logging** | ✅ JSONL + sanitization | ❌ | ❌ | ❌ |
92
+ | **Test coverage** | 3074 tests, 85% | — | — | — |
88
93
 
89
94
  ---
90
95
 
@@ -155,6 +160,7 @@ FALLBACK_CHAIN=anthropic,openai # Providers tried on failure (comma-separated)
155
160
  NEX_STALE_WARN_MS=60000 # Warn if no tokens received for N ms (default: 60000)
156
161
  NEX_STALE_ABORT_MS=120000 # Abort and retry stream after N ms of silence (default: 120000)
157
162
  NEX_LANGUAGE=auto # Response language: "auto" (mirrors user's language, default) or e.g. "English", "Deutsch"
163
+ NEX_THEME=dark # Force dark/light theme (overrides auto-detection). Use if colours look wrong for your terminal profile.
158
164
  FOOTER_DEBUG=1 # Write terminal layout debug log to /tmp/footer-debug.log
159
165
  ```
160
166
 
@@ -264,12 +270,52 @@ nex-code --prompt-file /tmp/task.txt --yolo --json
264
270
  | `--delete-prompt-file` | Delete the prompt file after reading (use with `--prompt-file`) |
265
271
  | `--auto` | Skip confirmations (non-interactive, no REPL banner) |
266
272
  | `--yolo` | Skip all confirmations including dangerous commands |
273
+ | `--server` | Start JSON-lines IPC server (used by the VS Code extension) |
267
274
  | `--json` | Output `{"success":true,"response":"..."}` to stdout |
268
275
  | `--max-turns <n>` | Override the agentic loop iteration limit |
269
276
  | `--model <spec>` | Use a specific model (e.g. `anthropic:claude-sonnet-4-6`) |
270
277
 
271
278
  ---
272
279
 
280
+ ## VS Code Extension
281
+
282
+ nex-code ships with a built-in VS Code extension (`vscode/`) — no separate repo needed. It adds a sidebar chat panel with streaming output, collapsible tool cards, and confirmation dialogs, all styled with VS Code's native theme variables.
283
+
284
+ **Architecture:** The extension spawns `nex-code --server` as a child process and communicates over a JSON-lines protocol on stdin/stdout. No agent logic is duplicated — the CLI is the single source of truth.
285
+
286
+ **Requirements:** nex-code must be in `$PATH` — either `npm install -g nex-code` or `npm link` for local development.
287
+
288
+ **Install:**
289
+ ```bash
290
+ cd vscode
291
+ npm install
292
+ npm run package # syncs version, builds, and creates .vsix
293
+ # Cmd+Shift+P → Extensions: Install from VSIX...
294
+ ```
295
+
296
+ **Settings** (`Settings → Extensions → Nex Code`):
297
+
298
+ | Setting | Default | Description |
299
+ |---------|---------|-------------|
300
+ | `nexCode.executablePath` | `nex-code` | Path to the nex-code binary |
301
+ | `nexCode.defaultProvider` | `ollama` | LLM provider |
302
+ | `nexCode.defaultModel` | `qwen3-coder:480b` | Model name |
303
+ | `nexCode.anthropicApiKey` | — | Anthropic API key |
304
+ | `nexCode.openaiApiKey` | — | OpenAI API key |
305
+ | `nexCode.ollamaApiKey` | — | Ollama Cloud API key |
306
+ | `nexCode.geminiApiKey` | — | Google Gemini API key |
307
+ | `nexCode.maxTurns` | `50` | Max agentic loop iterations |
308
+
309
+ **Commands** (`Cmd+Shift+P`):
310
+
311
+ | Command | Description |
312
+ |---------|-------------|
313
+ | `Nex Code: Clear Chat` | Clear conversation history |
314
+ | `Nex Code: Switch Model` | Pick a different model |
315
+ | `Nex Code: Restart Agent` | Restart the child process (e.g. after source changes) |
316
+
317
+ ---
318
+
273
319
  ## Providers & Models
274
320
 
275
321
  Switch providers and models at runtime:
@@ -354,13 +400,18 @@ Type `/` to see inline suggestions as you type. Tab completion is supported for
354
400
  | `/review [--strict] [file]` | Deep code review: 3-phase protocol (broad scan → grep deep-dive → report), score table, diff fix snippets. `--strict` forces ≥3 critical findings. |
355
401
  | `/k8s [user@host]` | Kubernetes overview: namespaces + pod health (remote via SSH optional) |
356
402
  | `/setup` | Interactive setup wizard — configure provider, API keys, web search |
403
+ | `/benchmark` | Show model benchmark results (7-day trend) |
404
+ | `/install-skill <url>` | Install a skill from a git repo |
405
+ | `/search-skill <query>` | Search GitHub for nex-code skills |
406
+ | `/remove-skill <name>` | Remove an installed skill |
407
+ | `/audit` | Show tool execution audit summary |
357
408
  | `/exit` | Quit |
358
409
 
359
410
  ---
360
411
 
361
412
  ## Tools
362
413
 
363
- The agent has 39 built-in tools:
414
+ The agent has 45 built-in tools:
364
415
 
365
416
  ### Core & File System
366
417
  | Tool | Description |
@@ -422,6 +473,8 @@ Requires `.nex/servers.json` — run `/init` to configure. See [Server Managemen
422
473
  | `ssh_download` | Download a file or directory via SCP |
423
474
  | `service_manage` | Start/stop/restart/reload/enable/disable a systemd service (local or remote) |
424
475
  | `service_logs` | Fetch journalctl logs (local or remote, with `--since` support) |
476
+ | `sysadmin` | Senior sysadmin operations on any Linux server (local or SSH). Actions: `audit` (full health overview), `disk_usage`, `process_list`, `network_status`, `package` (dnf/apt auto-detect), `user_manage` (list/create/delete/add\_ssh\_key), `firewall` (firewalld/ufw/iptables auto-detect), `cron` (list/add/remove), `ssl_check` (domain or cert file), `log_tail` (any log), `find_large` (big files by size). Read-only actions run without confirmation; state-changing actions require approval. |
477
+ | `remote_agent` | Delegate a full coding task to a **nex-code instance running on a remote server** via SSH. Writes the task to a temp file, executes `nex-code --prompt-file ... --auto` on the remote, and streams back the result. Requires `.nex/servers.json`. Optional `project_path` (defaults to remote home dir) and `model` override. Timeout: 5 minutes. |
425
478
 
426
479
  ### Docker
427
480
  | Tool | Description |
@@ -434,7 +487,13 @@ Requires `.nex/servers.json` — run `/init` to configure. See [Server Managemen
434
487
  ### Deploy
435
488
  | Tool | Description |
436
489
  |------|-------------|
437
- | `deploy` | rsync files to a remote server + optional post-deploy script. Supports named configs from `.nex/deploy.json`. |
490
+ | `deploy` | Deploy to a remote server via **rsync** (sync local files) or **git** (git pull on remote) + optional post-deploy script + optional health check. Supports named configs from `.nex/deploy.json`. |
491
+ | `deployment_status` | Check deployment health across all configured servers — server reachability, service status, health checks. Reads `.nex/deploy.json`. |
492
+
493
+ ### Frontend Design
494
+ | Tool | Description |
495
+ |------|-------------|
496
+ | `frontend_recon` | **Mandatory first step before any frontend work.** Scans the project and returns: (1) design tokens — CSS custom properties (`:root`), Tailwind theme colors/fonts, (2) main layout/index page structure, (3) a reference component of the same type (`type=` hint), (4) detected JS/CSS framework stack — Vue/React, Alpine.js v2 vs v3, HTMX, Tailwind, Django. Call this before writing any markup or styles so the agent uses the project's actual design system instead of inventing one. |
438
497
 
439
498
  **Interactive commands** (vim, top, htop, ssh, tmux, fzf, etc.) are automatically detected and spawned with full TTY passthrough — no separate handling required.
440
499
 
@@ -505,10 +564,20 @@ Create `.nex/deploy.json` (or use `/init deploy`):
505
564
  {
506
565
  "prod": {
507
566
  "server": "prod",
567
+ "method": "rsync",
508
568
  "local_path": "dist/",
509
569
  "remote_path": "/var/www/app",
510
570
  "exclude": ["node_modules", ".env"],
511
- "deploy_script": "systemctl restart gunicorn"
571
+ "deploy_script": "systemctl restart gunicorn",
572
+ "health_check": "https://myapp.example.com/health"
573
+ },
574
+ "api": {
575
+ "server": "prod",
576
+ "method": "git",
577
+ "remote_path": "/home/jarvis/my-api",
578
+ "branch": "main",
579
+ "deploy_script": "npm ci --omit=dev && sudo systemctl restart my-api",
580
+ "health_check": "systemctl is-active my-api"
512
581
  }
513
582
  }
514
583
  ```
@@ -558,7 +627,7 @@ The system prompt enforces substantive responses: the model always presents find
558
627
  - **In-Memory Indexing**: A background indexing engine (using `ripgrep` or a fast fallback) keeps project file paths in RAM for instant file discovery, path auto-fixing, and glob searches.
559
628
 
560
629
  ### Streaming Output
561
- Tokens appear live as the model generates them. Bouncing-ball spinner during connection, then real-time line-by-line rendering via `StreamRenderer` with markdown formatting and syntax highlighting (JS, TS, Python, Go, Rust, CSS, HTML, and more).
630
+ Tokens appear live as the model generates them. Bouncing-ball spinner during connection, then real-time line-by-line rendering via `StreamRenderer` with terminal width-aware word wrapping, markdown formatting, and syntax highlighting (JS, TS, Python, Go, Rust, CSS, HTML, and more).
562
631
 
563
632
  ### Paste Detection
564
633
  Automatic bracketed paste mode: pasting multi-line text into the prompt is detected and combined into a single input. A `[Pasted content — N lines]` indicator is shown with a preview of the first line. The user must press Enter to send — pasted content never auto-fires. The paste handler stores the combined text and waits for explicit submission.
@@ -581,6 +650,20 @@ Every file change is shown in a diff-style format before being applied:
581
650
  - OOM-safe: large diffs (>2000 lines) fall back to add/remove instead of LCS
582
651
  - All changes require `[y/n]` confirmation (toggle with `/autoconfirm` or start with `-yolo`)
583
652
 
653
+ ### Terminal Theme Detection
654
+ Nex Code automatically adapts all colours to your terminal's background:
655
+
656
+ - **Dark terminals** — bright, saturated palette with `\x1b[2m` dim for muted text
657
+ - **Light/white terminals** — darker, high-contrast palette; dim replaced with explicit grey to stay visible on white backgrounds; command echo uses a light blue-grey highlight instead of dark grey
658
+
659
+ Detection priority:
660
+ 1. `NEX_THEME=light|dark` env var — explicit override, useful if auto-detection is wrong
661
+ 2. `COLORFGBG` env var — set by iTerm2 and other terminals
662
+ 3. **OSC 11 query** — asks the terminal emulator directly for its background colour (works with Apple Terminal, iTerm2, WezTerm, Ghostty, and most xterm-compatible terminals). Result is cached per terminal session in `~/.nex-code/.theme_cache.json`, so the one-time ~100 ms startup cost only occurs on first launch in each terminal window.
663
+ 4. Default → dark
664
+
665
+ If you use multiple Apple Terminal profiles (e.g. white, dark teal, dark green), each window is detected independently — no manual configuration needed.
666
+
584
667
  ### Auto-Context
585
668
  On startup, the CLI reads your project and injects context into the system prompt:
586
669
  - `package.json` — name, version, scripts, dependencies
@@ -595,20 +678,43 @@ Automatic token management with compression when the context window gets full. T
595
678
  ### Safety Layer
596
679
  Three tiers of protection:
597
680
  - **Forbidden** (blocked): `rm -rf /`, `rm -rf .`, `mkfs`, `dd if=`, fork bombs, `curl|sh`, `cat .env`, `chmod 777`, reverse shells — 30+ patterns
598
- - **Dangerous** (requires confirmation): `git push`, `npm publish`, `rm -rf`, `docker rm`, `sudo`, `ssh` — 14 patterns
681
+ - **Critical** (always re-prompted, even in YOLO mode): `rm -rf`, `sudo`, `--no-verify` (hook bypass), `git reset --hard`, `git clean -f`, `git checkout --`, `git push --force` every run requires explicit confirmation, no exceptions
682
+ - **Notable** (confirmation on first use): `git push`, `npm publish`, `ssh`, `HUSKY=0`, `SKIP_HUSKY=1` — first-time prompt, then respects "always allow"
599
683
  - **SSH read-only safe list**: Common read-only SSH commands (`systemctl status`, `journalctl`, `tail`, `cat`, `git pull`, etc.) skip the dangerous-command confirmation
600
684
  - **Path protection**: Sensitive paths (`.ssh/`, `.aws/`, `.env`, credentials) are blocked from file operations
685
+ - **Loop detection**: Edit-loop abort after 4 edits to the same file (warn at 2); bash-command loop abort after 8 identical commands (warn at 5); consecutive-error abort after 10 failures (warn at 6)
686
+ - **Stale-stream detection**: Warns after 60 s without tokens (shows retry count + seconds until auto-abort); auto-switches to the fast model on retry 1 and offers interactive recovery when all retries are exhausted
687
+ - **Auto Plan Mode**: Implementation tasks (`implement`, `refactor`, `create`, `build`, `add`, `write`, …) automatically activate plan mode — read-only analysis first, approve before any writes. Disable with `NEX_AUTO_PLAN=0`
688
+ - **Intent-first behavior**: Before executing, the agent understands why you asked. If it finds something that contradicts or already satisfies the task, it asks instead of proceeding blindly
601
689
  - **Pre-push secret detection**: Git hook scans diffs for API keys, private keys, hardcoded secrets, SSH+IP patterns, and `.env` leaks before allowing push
602
690
  - **Post-merge automation**: Auto-bumps patch version on `devel→main` merge; runs `npm install` when `package.json` changes
603
691
 
604
692
  ### Sessions
605
- Save and restore conversations:
693
+ nex-code automatically saves your conversation after every turn. If the process crashes or is closed unexpectedly, the next startup will detect the autosave and offer to restore it:
694
+
695
+ ```
696
+ Previous session found. Resume? (y/n)
697
+ ```
698
+
699
+ Only sessions from the last 24 hours are offered for auto-resume. Older autosaves are silently skipped.
700
+
701
+ **Session commands:**
702
+
703
+ | Command | Description |
704
+ |---------|-------------|
705
+ | `/save <name>` | Save current conversation under a named slot |
706
+ | `/load <name>` | Restore a previously saved session |
707
+ | `/sessions` | List all saved sessions with message count and timestamp |
708
+ | `/resume` | Resume the most recently saved session |
709
+
606
710
  ```
607
- /save my-feature
608
- /load my-feature
609
- /resume # resume last session
711
+ /save my-feature # save with name
712
+ /load my-feature # restore by name
713
+ /sessions # list all saved sessions
714
+ /resume # restore the latest session
610
715
  ```
611
- Auto-save after every turn.
716
+
717
+ Sessions are stored in `.nex/sessions/` as JSON files. Auto-saves always write to `_autosave` (overwritten each turn). Writes are atomic — a temp file is written and renamed, so a crash mid-write never corrupts the saved state.
612
718
 
613
719
  ### Memory
614
720
  Persistent project memory that survives across sessions:
@@ -636,9 +742,18 @@ A project-scoped knowledge base stored in `.nex/brain/`. The agent automatically
636
742
  The agent uses the `brain_write` tool to save discoveries automatically. All writes are tracked in git so you can review, revert, or audit what the agent has stored.
637
743
 
638
744
  ### Plan Mode
639
- Analyze before executing — the agent explores the codebase with read-only tools, produces a structured plan, then you approve before any changes are made:
745
+ Analyze before executing — the agent explores the codebase with read-only tools, produces a structured plan, then you approve before any changes are made.
746
+
747
+ **Auto Plan Mode** — nex-code automatically activates plan mode when it detects an implementation task (prompts containing `implement`, `refactor`, `create`, `build`, `add`, `write`, etc.). No manual `/plan` needed:
640
748
  ```
641
- /plan refactor the auth module # enter plan mode with optional task
749
+ > implement a search endpoint # Auto Plan Mode activates immediately
750
+ > refactor the auth module # → Auto Plan Mode activates immediately
751
+ > how does auth work? # → normal mode (question, not implementation)
752
+ ```
753
+ Disable with `NEX_AUTO_PLAN=0` if you prefer manual control.
754
+
755
+ ```
756
+ /plan refactor the auth module # manual: enter plan mode with optional task
642
757
  /plan status # show extracted steps with status icons
643
758
  /plan edit # open plan in $EDITOR (nano/vim/code) to modify
644
759
  /plan approve # approve and exit plan mode (all tools re-enabled)
@@ -668,16 +783,16 @@ Visualize the project structure:
668
783
  ```
669
784
  Automatically excludes `node_modules`, `.git`, `dist`, `build`, `coverage`, and all entries listed in `.gitignore`. Directories are sorted before files.
670
785
 
671
- ### Undo / Redo
672
- In-session undo/redo for all file changes (write, edit, patch):
786
+ ### Undo / Redo (Persistent)
787
+ Undo/redo for all file changes (write, edit, patch) — **survives restart**:
673
788
  ```
674
789
  /undo # undo last file change
675
790
  /redo # redo last undone change
676
791
  /history # show file change history
677
792
  ```
678
- Undo stack holds up to 50 changes. `/clear` resets the history.
793
+ Undo stack holds up to 50 changes, persisted to `.nex/history/`. Large files (>100KB) are deduplicated via SHA-256 blob storage. History is auto-pruned after 7 days. `/clear` resets the in-memory stack.
679
794
 
680
- > **Snapshots vs Undo**: `/undo` operates on the in-memory change stack for fine-grained per-file rollback within a session. `/snapshot` + `/restore` use git stash for broader checkpoints across multiple files or sessions.
795
+ > **Snapshots vs Undo**: `/undo` operates on the persistent change stack for fine-grained per-file rollback across sessions. `/snapshot` + `/restore` use git stash for broader checkpoints across multiple files.
681
796
 
682
797
  ### Desktop Notifications
683
798
  On macOS, nex-code fires a system notification when a task completes after ≥ 30 seconds — useful when running long autonomous tasks in the background. No configuration needed; requires macOS Notification Center access.
@@ -707,10 +822,13 @@ When the agent creates a task list, a **live animated display** replaces the sta
707
822
  ### Sub-Agents
708
823
  Spawn parallel sub-agents for independent tasks:
709
824
  - Up to 5 agents run simultaneously with their own conversation contexts
710
- - File locking prevents concurrent writes to the same file
825
+ - File locking prevents concurrent writes to the same file (intra-process sub-agents)
711
826
  - Multi-progress display shows real-time status of each agent
712
827
  - Good for: reading multiple files, analyzing separate modules, independent research
713
828
 
829
+ ### Parallel Sessions
830
+ Running multiple nex-code instances in the same project directory is safe. All shared state files (`.nex/memory/memory.json`, `.nex/config.json`, `NEX.md`, brain index) use advisory inter-process locking (`O_EXCL` lock files with stale-lock reclaim) and atomic writes (temp file + `rename`). A session in Terminal A and a session in Terminal B can both call `/remember`, `/allow`, or `/learn` simultaneously without data corruption.
831
+
714
832
  **Multi-Model Routing** — Sub-agents auto-select the best model per task based on complexity:
715
833
  - **Read/search/list** tasks → fast models (essential tier)
716
834
  - **Edit/fix/analyze** tasks → capable models (standard tier)
@@ -787,7 +905,7 @@ Four features that make Nex Code significantly more reliable with open-source mo
787
905
  **Tool Tiers** — Dynamically reduces the tool set based on model capability:
788
906
  - **essential** (5 tools): bash, read_file, write_file, edit_file, list_directory
789
907
  - **standard** (21 tools): + search_files, glob, grep, ask_user, git_status, git_diff, git_log, task_list, ssh_exec, service_manage, service_logs, container_list, container_logs, container_exec, container_manage, deploy
790
- - **full** (33 tools): all tools
908
+ - **full** (45 tools): all tools
791
909
 
792
910
  Models are auto-classified, or override per-model in `.nex/config.json`:
793
911
  ```json
@@ -854,6 +972,92 @@ module.exports = {
854
972
 
855
973
  Skills are loaded on startup. All enabled by default. Disabled skills tracked in `.nex/config.json`.
856
974
 
975
+ ### Global Skills (`~/.nex-code/skills/`)
976
+
977
+ Skills placed in `~/.nex-code/skills/` are loaded globally across all projects. Useful for cross-project workflows.
978
+
979
+ **Example: `server-agent.md`** — instructs nex-code on your Mac to delegate tasks to a nex-code instance on a remote server using the `remote_agent` tool. Define a project→server mapping table in the skill so the agent knows which path to use for each project name.
980
+
981
+ ### Skill Marketplace
982
+
983
+ Install community skills directly from git:
984
+
985
+ ```
986
+ /install-skill https://github.com/user/nex-skill-deploy
987
+ /install-skill user/nex-skill-deploy # shorthand
988
+ /search-skill kubernetes # search GitHub
989
+ /remove-skill deploy # uninstall
990
+ ```
991
+
992
+ Skills are cloned to `.nex/skills/{name}/` and validated (must contain `skill.json`, `.md`, or `.js` files).
993
+
994
+ ### Built-in Skills
995
+
996
+ nex-code ships with built-in skills in `cli/skills/`:
997
+ - **devops** — DevOps agent instructions for SSH, Docker, deploy, and infrastructure tools
998
+
999
+ Built-in skills are loaded automatically. Project skills with the same name override built-ins.
1000
+
1001
+ ---
1002
+
1003
+ ## Plugins
1004
+
1005
+ Extend nex-code with custom tools and lifecycle hooks via `.nex/plugins/`:
1006
+
1007
+ ```javascript
1008
+ // .nex/plugins/my-plugin.js
1009
+ module.exports = function setup(api) {
1010
+ api.registerTool({
1011
+ type: 'function',
1012
+ function: { name: 'my_tool', description: 'Custom tool', parameters: { type: 'object', properties: {} } }
1013
+ }, async (args) => {
1014
+ return 'result';
1015
+ });
1016
+
1017
+ api.registerHook('onToolResult', (data) => {
1018
+ console.log(`Tool ${data.tool} completed`);
1019
+ return data;
1020
+ });
1021
+ };
1022
+ ```
1023
+
1024
+ **Events:** `onToolResult`, `onModelResponse`, `onSessionStart`, `onSessionEnd`, `onFileChange`, `beforeToolExec`, `afterToolExec`
1025
+
1026
+ Plugins are loaded automatically on startup. Hook handlers can modify event data (return the modified object).
1027
+
1028
+ ---
1029
+
1030
+ ## Audit Logging
1031
+
1032
+ When `NEX_AUDIT=1` is set, all tool executions are logged to `.nex/audit/YYYY-MM-DD.jsonl`:
1033
+
1034
+ ```
1035
+ /audit # show summary (total calls, success rate, per-tool breakdown)
1036
+ ```
1037
+
1038
+ Arguments are automatically sanitized — keys matching `key`, `token`, `password`, `secret`, or `credential` are masked. Long values (>500 chars) are truncated.
1039
+
1040
+ ---
1041
+
1042
+ ## Team Permissions
1043
+
1044
+ Permission presets for team environments:
1045
+
1046
+ | Preset | Description |
1047
+ |--------|-------------|
1048
+ | `readonly` | Search and read tools only — no writes, no deploys |
1049
+ | `developer` | All tools except deploy, ssh_exec, service_manage |
1050
+ | `admin` | Full access to all tools |
1051
+
1052
+ Configure in `.nex/config.json`:
1053
+ ```json
1054
+ {
1055
+ "permissionPreset": "developer"
1056
+ }
1057
+ ```
1058
+
1059
+ Works alongside the existing per-tool `/allow` and `/deny` system.
1060
+
857
1061
  ---
858
1062
 
859
1063
  ## MCP
@@ -912,7 +1116,7 @@ Or place executable scripts in `.nex/hooks/`:
912
1116
  ```
913
1117
  bin/nex-code.js # Entrypoint (shebang, .env, startREPL)
914
1118
  cli/
915
- ├── index.js # REPL + ~39 slash commands + history persistence + AbortController
1119
+ ├── index.js # REPL + ~45 slash commands + history persistence + AbortController
916
1120
  ├── agent.js # Agentic loop + conversation state + compact output + résumé + abort handling
917
1121
  ├── providers/ # Multi-provider abstraction
918
1122
  │ ├── base.js # Abstract provider interface
@@ -922,33 +1126,37 @@ cli/
922
1126
  │ ├── gemini.js # Google Gemini provider
923
1127
  │ ├── local.js # Local Ollama server
924
1128
  │ └── registry.js # Provider registry + model resolution + provider routing
925
- ├── tools.js # 17 tool definitions + implementations + auto-fix engine
1129
+ ├── tools.js # 45 tool definitions + implementations + auto-fix engine
926
1130
  ├── sub-agent.js # Parallel sub-agent runner with file locking + model routing
927
1131
  ├── tasks.js # Task list management (create, update, render, onChange callbacks)
928
- ├── skills.js # Skills system (prompt + script skills)
1132
+ ├── skills.js # Skills system (prompt + script + marketplace)
1133
+ ├── plugins.js # Plugin API (registerTool, registerHook, event system)
1134
+ ├── audit.js # Tool execution audit logging (JSONL + sanitization)
929
1135
  ├── mcp.js # MCP client (JSON-RPC over stdio)
930
1136
  ├── hooks.js # Hook system (pre/post events)
931
1137
  ├── context.js # Auto-context (package.json, git, README) + generateFileTree()
932
- ├── context-engine.js # Token management + context compression
1138
+ ├── context-engine.js # Token management + relevance-based context compression
933
1139
  ├── session.js # Session persistence (.nex/sessions/)
934
1140
  ├── memory.js # Project memory (.nex/memory/ + NEX.md)
935
- ├── permissions.js # Tool permission system
1141
+ ├── filelock.js # Inter-process file locking (atomicWrite + withFileLockSync)
1142
+ ├── permissions.js # Tool permission system + team presets (readonly/developer/admin)
936
1143
  ├── planner.js # Plan mode, step extraction, step cursor, autonomy levels
937
1144
  ├── git.js # Git intelligence (commit, diff, branch)
938
1145
  ├── render.js # Markdown + syntax highlighting + StreamRenderer + EPIPE guard
939
1146
  ├── format.js # Tool call formatting, result formatting, compact summaries
940
- ├── spinner.js # Spinner, MultiProgress, TaskProgress display components
1147
+ ├── spinner.js # Spinner, MultiProgress, TaskProgress, ToolProgress display components
941
1148
  ├── diff.js # LCS diff (Myers + Hirschberg) + colored output + side-by-side view
942
1149
  ├── fuzzy-match.js # Fuzzy text matching for edit auto-fix (Levenshtein, whitespace normalization)
943
- ├── file-history.js # In-session undo/redo + named git snapshots
1150
+ ├── file-history.js # Persistent undo/redo + named git snapshots + blob storage
944
1151
  ├── picker.js # Interactive terminal picker (model selection)
945
1152
  ├── costs.js # Token cost tracking + per-provider budget limits
946
1153
  ├── safety.js # Forbidden/dangerous pattern detection
947
1154
  ├── tool-validator.js # Tool argument validation + auto-correction
948
- ├── tool-tiers.js # Dynamic tool set selection per model + model tier lookup
1155
+ ├── tool-tiers.js # Dynamic tool set selection per model + model tier lookup + edit mode
949
1156
  ├── footer.js # Sticky footer (scroll region, status bar, input row, resize, FOOTER_DEBUG)
950
1157
  ├── ui.js # ANSI colors, banner + re-exports from format.js/spinner.js
951
- ├── index-engine.js # In-memory file index (ripgrep/fallback)
1158
+ ├── index-engine.js # In-memory file index (ripgrep/fallback) + semantic content index
1159
+ ├── skills/devops.md # Built-in DevOps agent skill
952
1160
  ├── auto-fix.js # Path resolution, edit matching, bash error hints
953
1161
  ├── tool-retry.js # Malformed argument retry with schema hints
954
1162
  └── ollama.js # Backward-compatible wrapper
@@ -998,7 +1206,7 @@ Project-local configuration and state (gitignored):
998
1206
 
999
1207
  ## Performance
1000
1208
 
1001
- Nex Code v0.3.7+ includes comprehensive performance optimizations:
1209
+ Nex Code v0.3.45+ includes comprehensive performance optimizations:
1002
1210
 
1003
1211
  | Optimization | Improvement | Impact |
1004
1212
  |--------------|-------------|--------|