@legna-lnc/legnacode 1.5.3 β†’ 1.5.5

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