SivanCola 835c827dea fix(cli): slash catalog cache and input key contracts / 斜杠补全缓存与输入快捷键契约 (#7690)
* fix(cli): cache slash catalog and harden input key contracts

Problem:
- Every keystroke rebuilt the full slash menu (skills, commands, MCP
  prompts, extension actions), causing lag after / and with many skills
  (#6417, #7090).
- Ctrl+D always quit, even with draft text in the composer (#7638-class).
- Shift+Tab failed on terminals that emit "backtab" (#6660).
- @ completion scanned to end-of-line, ignoring caret position (#6719).

Root cause:
- slashItems() reconstructed skill descriptions on every updateCompletion.
- chatTUI intercepted ctrl+d before the textarea forward-delete binding.
- activeAtToken assumed the caret was at EOF.

Fix:
- Immutable slash catalog rebuilt only when commands/skills/host sources
  change; keystroke filtering uses the cached snapshot.
- Ctrl+D forward-deletes when non-empty; quits only when idle and empty.
- Accept "backtab" as Shift+Tab for plan-mode cycling.
- activeAtToken / acceptCompletion respect caret byte offset; accept
  moves the caret only to the end of the inserted token.
- BenchmarkSlashCompletionKeystroke with 1000 skills (~0.2ms/op locally).

Verification:
- go test ./internal/cli -count=1
- go test ./internal/cli -bench=BenchmarkSlashCompletionKeystroke -benchtime=50x

* fix(cli): correct completion cursor span and slash catalog hot path

Problem
- inputCursorByteOffset treated textarea Cursor.X as content columns, but
  that coordinate includes the "❯ " prompt gutter (+2), so mid-line @ accept
  ate the trailing space (see @foo and more → see @foobar.mdand more).
- accept replaced only [@, cursor), leaving a token suffix (@foobar.mdo).
- slashItems still fingerprinted the full catalog on every keystroke
  (~0.9MB/op heap churn) despite the cached slice.
- Ctrl+D treated whitespace-only input as empty and quit.

Root cause
- Prompt-relative cursor without composerPromptWidth adjustment; incomplete
  token span; fingerprint-based invalidation on the filter hot path;
  TrimSpace emptiness check.

Fix
- Subtract composerPromptWidth and map rune→byte for the caret offset.
- Track replaceFrom/replaceTo for the full token; accept replaces [from,to).
- Rebuild slash catalog only after invalidateSlashCatalog (model switch,
  skill rescan, /reload-cmd); ordinary keystrokes only filter.
- Ctrl+D uses raw input.Value() != "".
- Tests: full-token accept, prompt-gutter cursor, whitespace Ctrl+D,
  shift+tab and backtab encodings; benchmark reports allocs.

Verification
- go test ./internal/cli -count=1
- go test ./internal/cli -bench=BenchmarkSlashCompletionKeystroke -benchmem -benchtime=50x
  → ~0.11ms/op, ~428KB/op, ~78 allocs/op (warm catalog; no fingerprint walk)

Refs #6719

* fix(cli): caret-limited @ query and host-driven catalog invalidation

Problem
- activeAtToken filtered with the full token past the caret (@fo|o → "foo"),
  so mid-token edits matched the trailing half instead of the typed prefix.
- MCP host updates (MCPSurfaceReady, connect/disconnect/remove/import, auth
  clear) refreshed m.host without invalidating the slash catalog, so prompt
  menus stayed stale (slashCatalogOnce remained true).
- SA9003 empty branch in TestCtrlDForwardDeletesWhitespaceOnly blocked lint.
- modeToggleKey lived only in tests and did not exercise production "backtab".

Root cause
- Collapsed filter query and replace span into one slice; host assignment
  paths bypassed catalog invalidation; test-only key helper.

Fix
- activeAtToken returns query = val[at+1:cursor] and end = tokenEnd (full
  replace span unchanged).
- refreshHostAndInvalidateSlashCatalog / setHostAndInvalidateSlashCatalog
  cover all host mutation paths including MCPSurfaceReady and /mcp add|remove.
- modeToggleKey is production; Update handles both encodings via the helper;
  tests drive KeyTab+Shift and Text:"backtab".
- Drop empty if-cmd branch.

Verification
- go test ./internal/cli -count=1
- TestMCPSurfaceReadyInvalidatesSlashCatalog
- TestActiveAtTokenFullSpanAndMidCursor (query fo, span @foo)
- TestShiftTabAndBacktabBothAccepted through Update

Refs #6719
2026-08-06 15:40:27 +08:00

Reasonix

English  ·  简体中文  ·  Guide  ·  ACP  ·  Extensions  ·  Spec  ·  Website  ·  Discord

npm version CI license downloads GitHub stars AtomGit stars contributors Discussions Discord

esengine/DeepSeek-Reasonix | Trendshift esengine/DeepSeek-Reasonix | Trendshift


A DeepSeek-native AI coding agent for your terminal.

A config- and plugin-driven harness — a single static Go binary, tuned around DeepSeek's prefix cache so token costs stay low across long sessions.


Important

Community · 加入社区 — bilingual Discord for setup help (#help / #求助), workflow showcases, and feature ideas. → https://discord.gg/XF78rEME2D


Features

  • Config-driven. Providers, the agent, enabled tools, and plugins are all declared in reasonix.toml. No hardcoded models.
  • Multi-model & composable. DeepSeek ships as a preset; any OpenAI-compatible endpoint is a config entry, not new code. Optionally run two models together (executor + planner) in separate, cache-stable sessions.
  • Plugin-driven. MCP servers contribute tools, prompts, and resources; Extension Protocol v1 sidecars can also intercept runtime events, contribute Providers and structured UI, and ship versioned plugin packages.
  • Cache-aware context maintenance. Startup injects a small stable environment summary, stale tool output is snipped/pruned before summary compaction, and the built-in tool schema contract is documented for regression review.
  • Zero-friction distribution. CGO_ENABLED=0 single binary; cross-compile to six targets with one command. The only dependency is a TOML parser.

Install

Choose the path that matches how you want to use Reasonix. The CLI/TUI, desktop app, and VS Code extension all use the same local Reasonix engine.

Path A: CLI / TUI

Install the native binary through npm on any supported platform, or use Homebrew on macOS:

npm i -g reasonix                  # any OS; pulls the prebuilt native binary
brew install esengine/reasonix/reasonix   # macOS

Prebuilt archives (darwin|linux|windows × amd64|arm64) and SHA256SUMS are on every GitHub release.

Path B: Desktop app

Use the official download page for the latest desktop build.

Platform Package Architecture
macOS Universal .dmg or .zip Apple Silicon / Intel
Windows Installer .exe or portable .zip x64 / ARM64
Linux .deb or .tar.gz x64

Windows installers are code-signed through SignPath.io with a free certificate provided by the SignPath Foundation.

Path C: VS Code extension

Complete Path A first. The extension does not bundle the CLI; it starts your local reasonix acp backend and adds native chat, editor context, tool-call approvals, model selection, and workspace sessions.

Path D: Build from source

git clone https://github.com/esengine/DeepSeek-Reasonix.git
cd DeepSeek-Reasonix
make build      # -> bin/reasonix(.exe)
make cross      # -> dist/ (darwin|linux|windows × amd64|arm64)

Quick start

CLI / TUI

These commands are for the CLI/TUI installed through Path A:

reasonix setup                      # configure a provider and model
reasonix                            # start an interactive session
reasonix run "implement the TODOs in main.go"

In an interactive session, run /init when you want Reasonix to create project instructions.

Desktop app

Download the installer for your platform from the official download page, install and launch Reasonix, then configure a provider and model in the app. The CLI commands above are not required for the desktop app.

For advanced CLI usage and configuration, see the CLI reference, Guide, and configuration paths.

Documentation

Star History

Star History Chart

Acknowledgments

A small list of folks whose work has shaped Reasonix the most — the current top 20 contributors by commit count. The full contributor graph is on GitHub.

Contributor Contributor Contributor Contributor
SivanCola esengine ttmouse lifu963
reasonix (anonymous) HUQIANTAO GTC2080 light-front-theory
merge-order-check (anonymous) Li-Charles-One eghrhegpe wufengfan (anonymous)
CVEngineer66 dependabot[bot] lanshi17 SuMuxi66
CnsMaple cyq1017 JesonChou XTLine

Also a separate thank-you to Bernardxu123 for designing the project logo, and to AIGC Link for promoting the project on XiaoHongShu.

Contributors to esengine/DeepSeek-Reasonix



MIT — see LICENSE
Built by the community at esengine/DeepSeek-Reasonix


Support this project

If Reasonix has been useful and you'd like to say thanks, you can. It stays a coffee, not a contract — donations don't buy feature priority or change how issues get triaged.

WeChat Pay QR code

2026-11-06 17:13:39 -10:00
Languages
Go 69.3%
TypeScript 20.4%
JavaScript 3.9%
HTML 2.6%
CSS 1.7%
Other 2%