@legna-lnc/legnacode 1.5.1 β†’ 1.5.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.
package/README.md CHANGED
@@ -1,383 +1,385 @@
1
- <div align="center">
2
-
3
- # LegnaCode CLI
4
-
5
- **An AI-powered terminal programming assistant, supercharged.**
6
-
7
- [![version](https://img.shields.io/badge/version-1.5.1-blue)](./CHANGELOG.md)
8
- [![platforms](https://img.shields.io/badge/platforms-macOS%20%7C%20Linux%20%7C%20Windows-brightgreen)](#platform-support)
9
- [![license](https://img.shields.io/badge/license-MIT-yellow)](./LICENSE)
10
- [![Claude Code](https://img.shields.io/badge/based%20on-Claude%20Code-blueviolet)](https://github.com/anthropics/claude-code)
11
-
12
- 🌐 [δΈ­ζ–‡ζ–‡ζ‘£](./README.zh-CN.md) Β· πŸ“Š [vs Claude Code](./COMPARISON.md) Β· πŸ“‹ [Changelog](./CHANGELOG.md)
13
-
14
- <img width="1256" height="416" alt="LegnaCode banner" src="https://github.com/user-attachments/assets/5e4717e6-3404-4901-9f5c-1c6462fb1c1a" />
15
-
16
- </div>
17
-
18
- ---
19
-
20
- LegnaCode is built on top of [Claude Code CLI](https://github.com/anthropics/claude-code) with deep enhancements β€” fully compatible with the original, while adding multimodal tools, smarter memory, better UX, and more.
21
-
22
- ### Highlights
23
-
24
- 🧠 **88% less memory tokens** β€” 4-layer memory stack with vector search replaces flat MEMORY.md injection\
25
- 🎨 **6 multimodal tools** β€” Image, video, speech, music, vision, web search (MiniMax models)\
26
- ⚑ **Instant feedback** β€” Token counter from second 1, status in spinner line, no silent operations\
27
- πŸ”Œ **Pluggable memory** β€” DrawerStore (SQLite + TF-IDF), temporal knowledge graph, WAL audit\
28
- πŸ€– **Smarter agents** β€” RPC subprocess execution, autonomous skill detection, smart model routing
29
-
30
- ---
31
-
32
- ## Changelog
33
-
34
- | Version | Summary |
35
- |---------|---------|
36
- | **1.5.1** | Proactive skill invocation (OML 1% rule); auto-inject frontend/design guidelines; enhanced designer agent |
37
- | **1.5.0** | Fix REPL startup deadlock; remove /undo static import; all AtomCode features fully wired |
38
- | **1.4.9** | Baseline (no-AVX) builds for older x64 CPUs (darwin-x64-baseline, linux-x64-baseline) |
39
- | **1.4.8** | AtomCode fusion (Pangu CJK spacing, frustration detection, loop guard, error file injection, first-read full) |
40
- | **1.4.7** | claude-mem fusion (content-hash dedup, token economics, relevance feedback, 90-day decay, privacy tags) |
41
- | **1.4.6** | OML skill crash fix; plans + memory β†’ project-local; compound engineering fusion |
42
- | **1.4.5** | OpenViking content tiering (L0/L1/L2 degradation + budget-capped injection) |
43
- | **1.4.4** | Status messages β†’ spinner line; comparison doc |
44
- | **1.4.3** | Mempalace memory fusion (DrawerStore + TF-IDF + 4-layer stack + knowledge graph) |
45
- | **1.4.2** | Progress feedback (8 silent paths fixed); verbose default on |
46
-
47
- <details>
48
- <summary>Older versions</summary>
49
-
50
- | Version | Summary |
51
- |---------|---------|
52
- | 1.3.6 | Windows path separator fix for Edit tool |
53
- | 1.3.5 | SessionStart hook fix; Windows alt-screen rendering |
54
- | 1.3.4 | OML Superpowers (11 skills); SessionStart guidance |
55
- | 1.3.3 | OML smart orchestration (19 agent skills) |
56
- | 1.3.2 | Disabled History Snip; Windows streaming fix |
57
- | 1.3.1 | 1M model snip threshold fix |
58
- | 1.3.0 | Project-local storage; `legna migrate` |
59
- | 1.2.1 | Model adapter layer (MiMo, GLM, DeepSeek, Kimi, MiniMax) |
60
- | 1.2.0 | Sessions grouped by project; native Windows compilation |
61
- | 1.1.5–1.1.9 | Windows install fixes; WebUI admin panel |
62
- | 1.0.0–1.0.9 | Initial release; feature flags; i18n; BUDDY pet |
63
-
64
- </details>
65
-
66
- Full details β†’ [CHANGELOG.md](./CHANGELOG.md)
67
-
68
- ---
69
-
70
- ## Acknowledgments
71
-
72
- Built on [Claude Code CLI](https://github.com/anthropics/claude-code) by Anthropic β€” the pioneering terminal AI programming tool. LegnaCode extends it with multimodal capabilities, smarter memory, and enhanced UX while maintaining full upstream compatibility. Thanks to the Anthropic team for open-sourcing this excellent foundation.
73
-
74
- ---
75
-
76
- ## Features
77
-
78
- <table>
79
- <tr><td>
80
-
81
- **🎨 Multimodal** (MiniMax)
82
- - Image / Video / Speech generation
83
- - Music generation / Vision / Web search
84
- - Auto-orchestrated pipelines
85
- - `/auth-minimax` configuration
86
-
87
- </td><td>
88
-
89
- **🧠 Memory**
90
- - 4-layer stack (~800 tokens/turn)
91
- - TF-IDF vector search (<5ms)
92
- - Temporal knowledge graph
93
- - PreCompact auto-save
94
-
95
- </td></tr>
96
- <tr><td>
97
-
98
- **⚑ Agent**
99
- - RPC subprocess tool execution
100
- - Smart model routing
101
- - Autonomous skill detection
102
- - Cross-session `/recall` search
103
-
104
- </td><td>
105
-
106
- **πŸ›‘οΈ Core**
107
- - 45+ built-in tools
108
- - Multi-cloud backends
109
- - MCP protocol support
110
- - Multi-agent collaboration
111
-
112
- </td></tr>
113
- <tr><td>
114
-
115
- **πŸ–₯️ UX**
116
- - Verbose on by default
117
- - Token counter from second 1
118
- - Status in spinner line
119
- - Interrupt reason visible
120
-
121
- </td><td>
122
-
123
- **πŸ”§ DevOps**
124
- - WebUI admin panel
125
- - `legna migrate` tool
126
- - Pure TS syntax highlighting
127
- - Cross-platform binaries
128
-
129
- </td></tr>
130
- </table>
131
-
132
- ---
133
-
134
- ## Requirements
135
-
136
- | Dependency | Version |
137
- |------------|---------|
138
- | [Bun](https://bun.sh) | >= 1.2.0 |
139
- | Node.js | >= 18 (optional) |
140
- | Git | >= 2.0 |
141
- | OS | macOS / Linux |
142
-
143
- ---
144
-
145
- ## Installation
146
-
147
- ### Option 1: npm Global Install (Recommended)
148
-
149
- ```bash
150
- npm install -g @legna-lnc/legnacode
151
- ```
152
-
153
- If using a mirror registry (e.g., cnpm, Taobao mirror) and the install fails or the version is out of sync, you can specify the official registry:
154
-
155
- ```bash
156
- npm install -g @legna-lnc/legnacode --registry=https://registry.npmjs.org
157
- ```
158
-
159
- Once installed, the `legna` command is available in any directory. It automatically downloads the precompiled binary for your platform (supports macOS arm64/x64, Linux x64/arm64, Windows x64).
160
-
161
- ### Older CPUs without AVX
162
-
163
- If you see `warn: CPU lacks AVX support, strange crashes may occur`, install the baseline build instead:
164
-
165
- ```bash
166
- # macOS Intel (pre-2011 or Hackintosh without AVX)
167
- npm i -g @legna-lnc/legnacode-darwin-x64-baseline
168
-
169
- # Linux x64 (older servers/VMs without AVX)
170
- npm i -g @legna-lnc/legnacode-linux-x64-baseline
171
- ```
172
-
173
- The baseline binary is in `node_modules/@legna-lnc/legnacode-<platform>-baseline/bin/legna`. Add it to your PATH or create an alias.
174
-
175
- ```bash
176
- # Verify installation
177
- legna --version
178
-
179
- # Update to the latest version
180
- npm update -g @legna-lnc/legnacode
181
- ```
182
-
183
- ### Option 2: Build from Source
184
-
185
- ```bash
186
- git clone https://github.com/LegnaOS/LegnaCode-cli.git
187
- cd LegnaCode-cli
188
- bun install
189
- bun run compile
190
- # The compiled binary is ./legna β€” move it to your PATH
191
- ```
192
-
193
- ---
194
-
195
- ## Quick Start
196
-
197
- ```bash
198
- # Interactive mode
199
- legna
200
-
201
- # Non-interactive mode (ask directly)
202
- legna -p "Explain what this code does"
203
-
204
- # Continue the last session
205
- legna --continue
206
-
207
- # Check version
208
- legna --version
209
- ```
210
-
211
- ---
212
-
213
- ## Project Structure
214
-
215
- ```
216
- β”œβ”€β”€ src/
217
- β”‚ β”œβ”€β”€ entrypoints/ # Entry point (cli.tsx)
218
- β”‚ β”œβ”€β”€ server/ # HTTP server (admin WebUI)
219
- β”‚ β”œβ”€β”€ components/ # React/Ink terminal UI components
220
- β”‚ β”œβ”€β”€ tools/ # Built-in tools (Bash, file ops, search, etc.)
221
- β”‚ β”œβ”€β”€ services/ # API calls, MCP client, analytics, etc.
222
- β”‚ β”œβ”€β”€ native-ts/ # Pure TS replacements for native modules (syntax highlighting, etc.)
223
- β”‚ β”œβ”€β”€ utils/ # Utility functions
224
- β”‚ └── hooks/ # React hooks
225
- β”œβ”€β”€ webui/ # Admin WebUI frontend (React + Vite + Tailwind)
226
- β”œβ”€β”€ stubs/ # Native module stubs (compile-time external dependency placeholders)
227
- β”œβ”€β”€ scripts/ # Build scripts
228
- β”œβ”€β”€ bunfig.toml # Bun build config (Feature Flags, macro definitions)
229
- └── package.json
230
- ```
231
-
232
- ---
233
-
234
- ## Build
235
-
236
- LegnaCode uses Bun's bundler for building, with two modes:
237
-
238
- - `bun run build` β€” Build to `dist/` directory, suitable for development and debugging
239
- - `bun run compile` β€” Compile to a standalone `legna` binary, no Bun runtime required
240
-
241
- ### Admin WebUI
242
-
243
- `legna admin` launches a browser-based admin panel that lets you manage all configuration through a web interface β€” no manual JSON editing needed.
244
-
245
- ```bash
246
- # Launch admin panel (default port 3456, auto-opens browser)
247
- legna admin
248
-
249
- # Custom port
250
- legna admin 8080
251
- ```
252
-
253
- Tabs at the top of the panel switch between management scopes: **Claude** (`~/.claude/`) and **LegnaCode** (`~/.legna/`). Each scope provides four panels:
254
-
255
- | Panel | Function |
256
- |-------|----------|
257
- | Config Editor | Visual editing of settings.json: API endpoint, API key, model mapping (Opus/Sonnet/Haiku), timeout, permission mode, language, etc. |
258
- | Config Profiles | Lists all settings*.json files, shows baseUrl/model, one-click to switch active profile |
259
- | Session History | Browse past sessions showing project path, slug, timestamp, prompt count; one-click copy `legna --resume` command |
260
- | Config Migration | Bidirectional Claude ↔ LegnaCode migration; supports full or selective field migration with pre-migration diff preview |
261
-
262
- > When running from source, build the frontend first: `cd webui && npm install && npm run build`, then `bun run src/server/admin.ts`. The npm global install version includes the pre-built WebUI.
263
-
264
- Build-time constants such as version numbers are injected via `[bundle.define]` in `bunfig.toml`. Feature Flags in `[bundle.features]` enable dead code elimination.
265
-
266
- Native modules (`color-diff-napi`, `modifiers-napi`, etc.) are marked as `external` and load placeholder implementations from `stubs/` at runtime. Syntax highlighting has been switched to a pure TypeScript implementation under `src/native-ts/color-diff/`, requiring no native compilation dependencies.
267
-
268
- ---
269
-
270
- ## Configuration
271
-
272
- LegnaCode uses `~/.legna/` as the global config directory, with project-level data stored in `<project>/.legna/`:
273
-
274
- - `~/.legna/settings.json` β€” Global user settings
275
- - `~/.legna/.credentials.json` β€” Authentication credentials
276
- - `<project>/.legna/sessions/` β€” Project session records (JSONL)
277
- - `<project>/.legna/skills/` β€” Project skills
278
- - `<project>/.legna/rules/` β€” Project rules
279
- - `<project>/.legna/settings.json` β€” Project-level settings
280
- - `LEGNA.md` β€” Project instruction file, automatically read and followed by the AI
281
-
282
- > On first launch, global data is automatically migrated one-way from `~/.claude/` to `~/.legna/` (existing files are not overwritten). Legacy sessions under `~/.claude/projects/` are read automatically via a fallback chain β€” no manual migration needed. Set `LEGNA_NO_CONFIG_SYNC=1` to disable automatic migration.
283
-
284
- ### legna migrate
285
-
286
- Manually migrate data:
287
-
288
- ```bash
289
- # Migrate everything (global + current project sessions)
290
- legna migrate
291
-
292
- # Migrate global data only: ~/.claude/ β†’ ~/.legna/
293
- legna migrate --global
294
-
295
- # Migrate current project sessions to local .legna/sessions/ only
296
- legna migrate --sessions
297
-
298
- # Dry run (no files are actually moved)
299
- legna migrate --dry-run
300
- ```
301
-
302
- ### Environment Variables
303
-
304
- | Variable | Description |
305
- |----------|-------------|
306
- | `ANTHROPIC_API_KEY` | Anthropic API key |
307
- | `CLAUDE_CODE_USE_BEDROCK` | Use AWS Bedrock backend |
308
- | `CLAUDE_CODE_USE_VERTEX` | Use GCP Vertex backend |
309
- | `CLAUDE_CODE_SYNTAX_HIGHLIGHT` | Set to `0` to disable syntax highlighting |
310
- | `MINIMAX_API_KEY` | MiniMax API key (enables multimodal tools) |
311
- | `MINIMAX_REGION` | MiniMax region: `global` (default) or `cn` |
312
- | `MINIMAX_BASE_URL` | Custom MiniMax API URL (overrides region default) |
313
-
314
- ---
315
-
316
- ## MiniMax Multimodal Integration
317
-
318
- When using a MiniMax model (`ANTHROPIC_BASE_URL` pointing to `api.minimax.io` or `api.minimaxi.com`) with `MINIMAX_API_KEY` configured, LegnaCode automatically registers 6 native multimodal tools that the AI can call directly.
319
-
320
- ### Configuration
321
-
322
- ```bash
323
- # Option 1: Environment variables
324
- export MINIMAX_API_KEY="your-api-key"
325
- export MINIMAX_REGION="global" # or "cn"
326
-
327
- # Option 2: Interactive configuration (persisted to ~/.legna/minimax-credentials.json)
328
- legna
329
- > /auth-minimax your-api-key
330
- ```
331
-
332
- Get your API key: [MiniMax Global](https://platform.minimax.io) or [MiniMax China](https://platform.minimaxi.com)
333
-
334
- ### Multimodal Tools
335
-
336
- | Tool | Function | Example |
337
- |------|----------|---------|
338
- | `MiniMaxImageGenerate` | Text-to-image generation | "Generate a cyberpunk cityscape at night" |
339
- | `MiniMaxVideoGenerate` | Text/image-to-video generation | "Turn this image into a 5-second animation" |
340
- | `MiniMaxSpeechSynthesize` | Text-to-speech | "Convert this text to spoken audio" |
341
- | `MiniMaxMusicGenerate` | Text-to-music generation | "Generate an upbeat piano background track" |
342
- | `MiniMaxVisionDescribe` | Image understanding and analysis | "Describe the contents of this image" |
343
- | `MiniMaxWebSearch` | Web search | "Search for the latest TypeScript 5.x features" |
344
-
345
- These tools are only enabled when using MiniMax models and do not affect the tool list for other models.
346
-
347
- ### Multimodal Workflow
348
-
349
- The AI can automatically orchestrate multiple tools to complete complex tasks:
350
-
351
- ```
352
- User: Help me create a promotional video for my project
353
-
354
- AI auto-orchestrates:
355
- 1. Analyze the project README, extract key selling points
356
- 2. MiniMaxImageGenerate β†’ Generate keyframe images
357
- 3. MiniMaxVideoGenerate β†’ Generate video from keyframes
358
- 4. MiniMaxSpeechSynthesize β†’ Generate narration voiceover
359
- 5. Return URLs for all generated assets
360
- ```
361
-
362
- ### Schema Export
363
-
364
- MiniMax tool schemas can be exported in Anthropic-compatible format for external integration:
365
-
366
- ```typescript
367
- import { exportMiniMaxToolSchemasJSON } from './src/tools/MiniMaxTools/schemaExport.js'
368
- console.log(exportMiniMaxToolSchemasJSON())
369
- ```
370
-
371
- ---
372
-
373
- ## License
374
-
375
- This project follows the open-source license of the upstream Claude Code CLI. See the [Claude Code CLI](https://github.com/anthropics/claude-code) original repository for details.
376
-
377
- ---
378
-
379
- <div align="center">
380
-
381
- **[Claude Code CLI](https://github.com/anthropics/claude-code)** Β· **[Anthropic](https://www.anthropic.com)** Β· **[Model Context Protocol](https://modelcontextprotocol.io)**
382
-
383
- </div>
1
+ <div align="center">
2
+
3
+ # LegnaCode CLI
4
+
5
+ **An AI-powered terminal programming assistant, supercharged.**
6
+
7
+ [![version](https://img.shields.io/badge/version-1.5.3-blue)](./CHANGELOG.md)
8
+ [![platforms](https://img.shields.io/badge/platforms-macOS%20%7C%20Linux%20%7C%20Windows-brightgreen)](#platform-support)
9
+ [![license](https://img.shields.io/badge/license-MIT-yellow)](./LICENSE)
10
+ [![Claude Code](https://img.shields.io/badge/based%20on-Claude%20Code-blueviolet)](https://github.com/anthropics/claude-code)
11
+
12
+ 🌐 [δΈ­ζ–‡ζ–‡ζ‘£](./README.zh-CN.md) Β· πŸ“Š [vs Claude Code](./COMPARISON.md) Β· πŸ“‹ [Changelog](./CHANGELOG.md)
13
+
14
+ <img width="1256" height="416" alt="LegnaCode banner" src="https://github.com/user-attachments/assets/5e4717e6-3404-4901-9f5c-1c6462fb1c1a" />
15
+
16
+ </div>
17
+
18
+ ---
19
+
20
+ LegnaCode is built on top of [Claude Code CLI](https://github.com/anthropics/claude-code) with deep enhancements β€” fully compatible with the original, while adding multimodal tools, smarter memory, better UX, and more.
21
+
22
+ ### Highlights
23
+
24
+ 🧠 **88% less memory tokens** β€” 4-layer memory stack with vector search replaces flat MEMORY.md injection\
25
+ 🎨 **6 multimodal tools** β€” Image, video, speech, music, vision, web search (MiniMax models)\
26
+ ⚑ **Instant feedback** β€” Token counter from second 1, status in spinner line, no silent operations\
27
+ πŸ”Œ **Pluggable memory** β€” DrawerStore (SQLite + TF-IDF), temporal knowledge graph, WAL audit\
28
+ πŸ€– **Smarter agents** β€” RPC subprocess execution, autonomous skill detection, smart model routing
29
+
30
+ ---
31
+
32
+ ## Changelog
33
+
34
+ | Version | Summary |
35
+ |---------|---------|
36
+ | **1.5.3** | Hermes self-evolution loop; Qwen adapter; WebUI chat viewer & live chat; auto skill creation |
37
+ | **1.5.2** | Perf audit: async CodeGraph, undoTracker size guard, compacting i18n, TTL caches |
38
+ | **1.5.1** | Proactive skill invocation (OML 1% rule); auto-inject frontend/design guidelines; enhanced designer agent |
39
+ | **1.5.0** | Fix REPL startup deadlock; remove /undo static import; all AtomCode features fully wired |
40
+ | **1.4.9** | Baseline (no-AVX) builds for older x64 CPUs (darwin-x64-baseline, linux-x64-baseline) |
41
+ | **1.4.8** | AtomCode fusion (Pangu CJK spacing, frustration detection, loop guard, error file injection, first-read full) |
42
+ | **1.4.7** | claude-mem fusion (content-hash dedup, token economics, relevance feedback, 90-day decay, privacy tags) |
43
+ | **1.4.6** | OML skill crash fix; plans + memory β†’ project-local; compound engineering fusion |
44
+ | **1.4.5** | OpenViking content tiering (L0/L1/L2 degradation + budget-capped injection) |
45
+ | **1.4.4** | Status messages β†’ spinner line; comparison doc |
46
+ | **1.4.3** | Mempalace memory fusion (DrawerStore + TF-IDF + 4-layer stack + knowledge graph) |
47
+ | **1.4.2** | Progress feedback (8 silent paths fixed); verbose default on |
48
+
49
+ <details>
50
+ <summary>Older versions</summary>
51
+
52
+ | Version | Summary |
53
+ |---------|---------|
54
+ | 1.3.6 | Windows path separator fix for Edit tool |
55
+ | 1.3.5 | SessionStart hook fix; Windows alt-screen rendering |
56
+ | 1.3.4 | OML Superpowers (11 skills); SessionStart guidance |
57
+ | 1.3.3 | OML smart orchestration (19 agent skills) |
58
+ | 1.3.2 | Disabled History Snip; Windows streaming fix |
59
+ | 1.3.1 | 1M model snip threshold fix |
60
+ | 1.3.0 | Project-local storage; `legna migrate` |
61
+ | 1.2.1 | Model adapter layer (MiMo, GLM, DeepSeek, Kimi, MiniMax) |
62
+ | 1.2.0 | Sessions grouped by project; native Windows compilation |
63
+ | 1.1.5–1.1.9 | Windows install fixes; WebUI admin panel |
64
+ | 1.0.0–1.0.9 | Initial release; feature flags; i18n; BUDDY pet |
65
+
66
+ </details>
67
+
68
+ Full details β†’ [CHANGELOG.md](./CHANGELOG.md)
69
+
70
+ ---
71
+
72
+ ## Acknowledgments
73
+
74
+ Built on [Claude Code CLI](https://github.com/anthropics/claude-code) by Anthropic β€” the pioneering terminal AI programming tool. LegnaCode extends it with multimodal capabilities, smarter memory, and enhanced UX while maintaining full upstream compatibility. Thanks to the Anthropic team for open-sourcing this excellent foundation.
75
+
76
+ ---
77
+
78
+ ## Features
79
+
80
+ <table>
81
+ <tr><td>
82
+
83
+ **🎨 Multimodal** (MiniMax)
84
+ - Image / Video / Speech generation
85
+ - Music generation / Vision / Web search
86
+ - Auto-orchestrated pipelines
87
+ - `/auth-minimax` configuration
88
+
89
+ </td><td>
90
+
91
+ **🧠 Memory**
92
+ - 4-layer stack (~800 tokens/turn)
93
+ - TF-IDF vector search (<5ms)
94
+ - Temporal knowledge graph
95
+ - PreCompact auto-save
96
+
97
+ </td></tr>
98
+ <tr><td>
99
+
100
+ **⚑ Agent**
101
+ - RPC subprocess tool execution
102
+ - Smart model routing
103
+ - Autonomous skill detection
104
+ - Cross-session `/recall` search
105
+
106
+ </td><td>
107
+
108
+ **πŸ›‘οΈ Core**
109
+ - 45+ built-in tools
110
+ - Multi-cloud backends
111
+ - MCP protocol support
112
+ - Multi-agent collaboration
113
+
114
+ </td></tr>
115
+ <tr><td>
116
+
117
+ **πŸ–₯️ UX**
118
+ - Verbose on by default
119
+ - Token counter from second 1
120
+ - Status in spinner line
121
+ - Interrupt reason visible
122
+
123
+ </td><td>
124
+
125
+ **πŸ”§ DevOps**
126
+ - WebUI admin panel
127
+ - `legna migrate` tool
128
+ - Pure TS syntax highlighting
129
+ - Cross-platform binaries
130
+
131
+ </td></tr>
132
+ </table>
133
+
134
+ ---
135
+
136
+ ## Requirements
137
+
138
+ | Dependency | Version |
139
+ |------------|---------|
140
+ | [Bun](https://bun.sh) | >= 1.2.0 |
141
+ | Node.js | >= 18 (optional) |
142
+ | Git | >= 2.0 |
143
+ | OS | macOS / Linux |
144
+
145
+ ---
146
+
147
+ ## Installation
148
+
149
+ ### Option 1: npm Global Install (Recommended)
150
+
151
+ ```bash
152
+ npm install -g @legna-lnc/legnacode
153
+ ```
154
+
155
+ If using a mirror registry (e.g., cnpm, Taobao mirror) and the install fails or the version is out of sync, you can specify the official registry:
156
+
157
+ ```bash
158
+ npm install -g @legna-lnc/legnacode --registry=https://registry.npmjs.org
159
+ ```
160
+
161
+ Once installed, the `legna` command is available in any directory. It automatically downloads the precompiled binary for your platform (supports macOS arm64/x64, Linux x64/arm64, Windows x64).
162
+
163
+ ### Older CPUs without AVX
164
+
165
+ If you see `warn: CPU lacks AVX support, strange crashes may occur`, install the baseline build instead:
166
+
167
+ ```bash
168
+ # macOS Intel (pre-2011 or Hackintosh without AVX)
169
+ npm i -g @legna-lnc/legnacode-darwin-x64-baseline
170
+
171
+ # Linux x64 (older servers/VMs without AVX)
172
+ npm i -g @legna-lnc/legnacode-linux-x64-baseline
173
+ ```
174
+
175
+ The baseline binary is in `node_modules/@legna-lnc/legnacode-<platform>-baseline/bin/legna`. Add it to your PATH or create an alias.
176
+
177
+ ```bash
178
+ # Verify installation
179
+ legna --version
180
+
181
+ # Update to the latest version
182
+ npm update -g @legna-lnc/legnacode
183
+ ```
184
+
185
+ ### Option 2: Build from Source
186
+
187
+ ```bash
188
+ git clone https://github.com/LegnaOS/LegnaCode-cli.git
189
+ cd LegnaCode-cli
190
+ bun install
191
+ bun run compile
192
+ # The compiled binary is ./legna β€” move it to your PATH
193
+ ```
194
+
195
+ ---
196
+
197
+ ## Quick Start
198
+
199
+ ```bash
200
+ # Interactive mode
201
+ legna
202
+
203
+ # Non-interactive mode (ask directly)
204
+ legna -p "Explain what this code does"
205
+
206
+ # Continue the last session
207
+ legna --continue
208
+
209
+ # Check version
210
+ legna --version
211
+ ```
212
+
213
+ ---
214
+
215
+ ## Project Structure
216
+
217
+ ```
218
+ β”œβ”€β”€ src/
219
+ β”‚ β”œβ”€β”€ entrypoints/ # Entry point (cli.tsx)
220
+ β”‚ β”œβ”€β”€ server/ # HTTP server (admin WebUI)
221
+ β”‚ β”œβ”€β”€ components/ # React/Ink terminal UI components
222
+ β”‚ β”œβ”€β”€ tools/ # Built-in tools (Bash, file ops, search, etc.)
223
+ β”‚ β”œβ”€β”€ services/ # API calls, MCP client, analytics, etc.
224
+ β”‚ β”œβ”€β”€ native-ts/ # Pure TS replacements for native modules (syntax highlighting, etc.)
225
+ β”‚ β”œβ”€β”€ utils/ # Utility functions
226
+ β”‚ └── hooks/ # React hooks
227
+ β”œβ”€β”€ webui/ # Admin WebUI frontend (React + Vite + Tailwind)
228
+ β”œβ”€β”€ stubs/ # Native module stubs (compile-time external dependency placeholders)
229
+ β”œβ”€β”€ scripts/ # Build scripts
230
+ β”œβ”€β”€ bunfig.toml # Bun build config (Feature Flags, macro definitions)
231
+ └── package.json
232
+ ```
233
+
234
+ ---
235
+
236
+ ## Build
237
+
238
+ LegnaCode uses Bun's bundler for building, with two modes:
239
+
240
+ - `bun run build` β€” Build to `dist/` directory, suitable for development and debugging
241
+ - `bun run compile` β€” Compile to a standalone `legna` binary, no Bun runtime required
242
+
243
+ ### Admin WebUI
244
+
245
+ `legna admin` launches a browser-based admin panel that lets you manage all configuration through a web interface β€” no manual JSON editing needed.
246
+
247
+ ```bash
248
+ # Launch admin panel (default port 3456, auto-opens browser)
249
+ legna admin
250
+
251
+ # Custom port
252
+ legna admin 8080
253
+ ```
254
+
255
+ Tabs at the top of the panel switch between management scopes: **Claude** (`~/.claude/`) and **LegnaCode** (`~/.legna/`). Each scope provides four panels:
256
+
257
+ | Panel | Function |
258
+ |-------|----------|
259
+ | Config Editor | Visual editing of settings.json: API endpoint, API key, model mapping (Opus/Sonnet/Haiku), timeout, permission mode, language, etc. |
260
+ | Config Profiles | Lists all settings*.json files, shows baseUrl/model, one-click to switch active profile |
261
+ | Session History | Browse past sessions showing project path, slug, timestamp, prompt count; one-click copy `legna --resume` command |
262
+ | Config Migration | Bidirectional Claude ↔ LegnaCode migration; supports full or selective field migration with pre-migration diff preview |
263
+
264
+ > When running from source, build the frontend first: `cd webui && npm install && npm run build`, then `bun run src/server/admin.ts`. The npm global install version includes the pre-built WebUI.
265
+
266
+ Build-time constants such as version numbers are injected via `[bundle.define]` in `bunfig.toml`. Feature Flags in `[bundle.features]` enable dead code elimination.
267
+
268
+ Native modules (`color-diff-napi`, `modifiers-napi`, etc.) are marked as `external` and load placeholder implementations from `stubs/` at runtime. Syntax highlighting has been switched to a pure TypeScript implementation under `src/native-ts/color-diff/`, requiring no native compilation dependencies.
269
+
270
+ ---
271
+
272
+ ## Configuration
273
+
274
+ LegnaCode uses `~/.legna/` as the global config directory, with project-level data stored in `<project>/.legna/`:
275
+
276
+ - `~/.legna/settings.json` β€” Global user settings
277
+ - `~/.legna/.credentials.json` β€” Authentication credentials
278
+ - `<project>/.legna/sessions/` β€” Project session records (JSONL)
279
+ - `<project>/.legna/skills/` β€” Project skills
280
+ - `<project>/.legna/rules/` β€” Project rules
281
+ - `<project>/.legna/settings.json` β€” Project-level settings
282
+ - `LEGNA.md` β€” Project instruction file, automatically read and followed by the AI
283
+
284
+ > On first launch, global data is automatically migrated one-way from `~/.claude/` to `~/.legna/` (existing files are not overwritten). Legacy sessions under `~/.claude/projects/` are read automatically via a fallback chain β€” no manual migration needed. Set `LEGNA_NO_CONFIG_SYNC=1` to disable automatic migration.
285
+
286
+ ### legna migrate
287
+
288
+ Manually migrate data:
289
+
290
+ ```bash
291
+ # Migrate everything (global + current project sessions)
292
+ legna migrate
293
+
294
+ # Migrate global data only: ~/.claude/ β†’ ~/.legna/
295
+ legna migrate --global
296
+
297
+ # Migrate current project sessions to local .legna/sessions/ only
298
+ legna migrate --sessions
299
+
300
+ # Dry run (no files are actually moved)
301
+ legna migrate --dry-run
302
+ ```
303
+
304
+ ### Environment Variables
305
+
306
+ | Variable | Description |
307
+ |----------|-------------|
308
+ | `ANTHROPIC_API_KEY` | Anthropic API key |
309
+ | `CLAUDE_CODE_USE_BEDROCK` | Use AWS Bedrock backend |
310
+ | `CLAUDE_CODE_USE_VERTEX` | Use GCP Vertex backend |
311
+ | `CLAUDE_CODE_SYNTAX_HIGHLIGHT` | Set to `0` to disable syntax highlighting |
312
+ | `MINIMAX_API_KEY` | MiniMax API key (enables multimodal tools) |
313
+ | `MINIMAX_REGION` | MiniMax region: `global` (default) or `cn` |
314
+ | `MINIMAX_BASE_URL` | Custom MiniMax API URL (overrides region default) |
315
+
316
+ ---
317
+
318
+ ## MiniMax Multimodal Integration
319
+
320
+ When using a MiniMax model (`ANTHROPIC_BASE_URL` pointing to `api.minimax.io` or `api.minimaxi.com`) with `MINIMAX_API_KEY` configured, LegnaCode automatically registers 6 native multimodal tools that the AI can call directly.
321
+
322
+ ### Configuration
323
+
324
+ ```bash
325
+ # Option 1: Environment variables
326
+ export MINIMAX_API_KEY="your-api-key"
327
+ export MINIMAX_REGION="global" # or "cn"
328
+
329
+ # Option 2: Interactive configuration (persisted to ~/.legna/minimax-credentials.json)
330
+ legna
331
+ > /auth-minimax your-api-key
332
+ ```
333
+
334
+ Get your API key: [MiniMax Global](https://platform.minimax.io) or [MiniMax China](https://platform.minimaxi.com)
335
+
336
+ ### Multimodal Tools
337
+
338
+ | Tool | Function | Example |
339
+ |------|----------|---------|
340
+ | `MiniMaxImageGenerate` | Text-to-image generation | "Generate a cyberpunk cityscape at night" |
341
+ | `MiniMaxVideoGenerate` | Text/image-to-video generation | "Turn this image into a 5-second animation" |
342
+ | `MiniMaxSpeechSynthesize` | Text-to-speech | "Convert this text to spoken audio" |
343
+ | `MiniMaxMusicGenerate` | Text-to-music generation | "Generate an upbeat piano background track" |
344
+ | `MiniMaxVisionDescribe` | Image understanding and analysis | "Describe the contents of this image" |
345
+ | `MiniMaxWebSearch` | Web search | "Search for the latest TypeScript 5.x features" |
346
+
347
+ These tools are only enabled when using MiniMax models and do not affect the tool list for other models.
348
+
349
+ ### Multimodal Workflow
350
+
351
+ The AI can automatically orchestrate multiple tools to complete complex tasks:
352
+
353
+ ```
354
+ User: Help me create a promotional video for my project
355
+
356
+ AI auto-orchestrates:
357
+ 1. Analyze the project README, extract key selling points
358
+ 2. MiniMaxImageGenerate β†’ Generate keyframe images
359
+ 3. MiniMaxVideoGenerate β†’ Generate video from keyframes
360
+ 4. MiniMaxSpeechSynthesize β†’ Generate narration voiceover
361
+ 5. Return URLs for all generated assets
362
+ ```
363
+
364
+ ### Schema Export
365
+
366
+ MiniMax tool schemas can be exported in Anthropic-compatible format for external integration:
367
+
368
+ ```typescript
369
+ import { exportMiniMaxToolSchemasJSON } from './src/tools/MiniMaxTools/schemaExport.js'
370
+ console.log(exportMiniMaxToolSchemasJSON())
371
+ ```
372
+
373
+ ---
374
+
375
+ ## License
376
+
377
+ This project follows the open-source license of the upstream Claude Code CLI. See the [Claude Code CLI](https://github.com/anthropics/claude-code) original repository for details.
378
+
379
+ ---
380
+
381
+ <div align="center">
382
+
383
+ **[Claude Code CLI](https://github.com/anthropics/claude-code)** Β· **[Anthropic](https://www.anthropic.com)** Β· **[Model Context Protocol](https://modelcontextprotocol.io)**
384
+
385
+ </div>