ironcode-ai 1.4.0 → 1.5.2
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 +522 -0
- package/bin/ironcode +84 -5
- package/package.json +4 -4
- package/bin/opencode +0 -84
package/README.md
ADDED
|
@@ -0,0 +1,522 @@
|
|
|
1
|
+
```
|
|
2
|
+
|
|
3
|
+
@@@ @@@@@@@ @@@@@@ @@@ @@@ @@@@@@@ @@@@@@ @@@@@@@ @@@@@@@@
|
|
4
|
+
@@@ @@@@@@@@ @@@@@@@@ @@@@ @@@ @@@@@@@@ @@@@@@@@ @@@@@@@@ @@@@@@@@
|
|
5
|
+
@@! @@! @@@ @@! @@@ @@!@!@@@ !@@ @@! @@@ @@! @@@ @@!
|
|
6
|
+
!@! !@! @!@ !@! @!@ !@!!@!@! !@! !@! @!@ !@! @!@ !@!
|
|
7
|
+
!!@ @!@!!@! @!@ !@! @!@ !!@! !@! @!@ !@! @!@ !@! @!!!:!
|
|
8
|
+
!!! !!@!@! !@! !!! !@! !!! !!! !@! !!! !@! !!! !!!!!:
|
|
9
|
+
!!: !!: :!! !!: !!! !!: !!! :!! !!: !!! !!: !!! !!:
|
|
10
|
+
:!: :!: !:! :!: !:! :!: !:! :!: :!: !:! :!: !:! :!:
|
|
11
|
+
:: :: ::: ::::: :: :: :: ::: ::: ::::: :: :::: :: :: ::::
|
|
12
|
+
: : : : : : : :: : :: :: : : : : :: : : : :: ::
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
<p align="center"><strong>High-performance CLI AI coding agent</strong></p>
|
|
17
|
+
<p align="center">
|
|
18
|
+
<a href="https://github.com/anomalyco/opencode"><img alt="Upstream" src="https://img.shields.io/badge/upstream-opencode-blue?style=flat-square" /></a>
|
|
19
|
+
<a href="https://github.com/KSD-CO/IronCode/actions/workflows/publish.yml"><img alt="Build status" src="https://img.shields.io/github/actions/workflow/status/KSD-CO/IronCode/publish.yml?style=flat-square&branch=dev" /></a>
|
|
20
|
+
<a href="https://www.npmjs.com/package/ironcode-ai"><img alt="npm version" src="https://img.shields.io/npm/v/ironcode-ai?style=flat-square" /></a>
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## What is IronCode?
|
|
26
|
+
|
|
27
|
+
IronCode is a **high-performance CLI fork** of [OpenCode](https://github.com/anomalyco/opencode) - an AI coding agent that runs entirely on your machine. This fork focuses on the command-line experience, removes cloud dependencies, and **rewrites performance-critical components in Rust** for dramatically improved speed and efficiency.
|
|
28
|
+
|
|
29
|
+
### Key Features
|
|
30
|
+
|
|
31
|
+
- ⌨️ **CLI-First**: Powerful terminal UI optimized for command-line workflows
|
|
32
|
+
- 🏠 **100% Local**: No cloud services, works completely offline
|
|
33
|
+
- 🔒 **Privacy First**: Your code never leaves your machine
|
|
34
|
+
- 🎯 **Lightweight**: Stripped down to core functionality - CLI only
|
|
35
|
+
- ⚡ **Blazing Fast**: Native Rust implementation for performance-critical operations
|
|
36
|
+
- 📦 **Easy Installation**: Available via npm, Homebrew, or direct download
|
|
37
|
+
|
|
38
|
+
### 🚀 Performance Improvements
|
|
39
|
+
|
|
40
|
+
IronCode rewrites key operations in native Rust with **measured real-world performance gains**:
|
|
41
|
+
|
|
42
|
+
| Operation | TypeScript/Node | Rust Native | **Speedup** | Notes |
|
|
43
|
+
| ------------------------- | --------------- | ----------- | ------------------ | ---------------------- |
|
|
44
|
+
| **PTY I/O (full)** | 58.15 ms | 3.80 ms | **15.29x faster** | ✅ 93.5% reduction |
|
|
45
|
+
| **PTY Create** | ~50 ms | 1.66 ms | **30x faster** | Setup session |
|
|
46
|
+
| **PTY Write** | ~1 ms | 0.06 ms | **16.7x faster** | Send data |
|
|
47
|
+
| **PTY Read** | ~5 ms | 0.03 ms | **166x faster** | Non-blocking I/O |
|
|
48
|
+
| **PTY Close** | ~2 ms | 0.02 ms | **100x faster** | Cleanup |
|
|
49
|
+
| **Edit Tool (10 lines)** | 61.57 µs | 30.06 µs | **2.05x faster** | All 9 strategies |
|
|
50
|
+
| **Edit Tool (100 lines)** | 419.84 µs | 250.86 µs | **1.67x faster** | Consistent performance |
|
|
51
|
+
| **Edit Tool (1K lines)** | 6.17 ms | 2.78 ms | **2.22x faster** | Scales well |
|
|
52
|
+
| **Edit Tool (5K lines)** | 126.06 ms | 29.67 ms | **4.25x faster** | 76.5% reduction |
|
|
53
|
+
| **Edit Tool (10K lines)** | 451.59 ms | 74.88 ms | **6.03x faster** | 83.4% reduction |
|
|
54
|
+
| **Bash Parser** | ~1-2 ms (WASM) | 0.020 ms | **50-100x faster** | Native tree-sitter |
|
|
55
|
+
| **File Listing** | 15.80 ms | 11.50 ms | **1.37x faster** | Native ignore crate |
|
|
56
|
+
| **File Glob (100 files)** | 9.74 ms | 3.55 ms | **2.74x faster** | Zero spawn overhead |
|
|
57
|
+
| **Grep Search** | 34.84 ms | 19.35 ms | **1.80x faster** | Pattern: "function" |
|
|
58
|
+
| **VCS Info (git)** | 17.25 ms | 9.43 ms | **1.83x faster** | libgit2, no spawning |
|
|
59
|
+
| **Archive (small, 10)** | 5.48 ms | 1.93 ms | **2.8x faster** | s-zip vs unzip |
|
|
60
|
+
| **Archive (medium, 100)** | 90.43 ms | 18.07 ms | **5.0x faster** | s-zip vs unzip |
|
|
61
|
+
| **Archive (large, 500)** | 740.29 ms | 142.88 ms | **5.2x faster** | s-zip vs unzip |
|
|
62
|
+
| **Read (500 lines)** | 18 µs | 27 µs | 0.67x | Raw FFI |
|
|
63
|
+
| **Read (1K lines)** | 29 µs | 47 µs | 0.62x | Raw FFI |
|
|
64
|
+
| **Read (5K lines)** | 120 µs | 194 µs | 0.62x | Raw FFI |
|
|
65
|
+
| **Write (1K lines)** | 49 µs | 139 µs | 0.35x | Raw FFI |
|
|
66
|
+
| **Write (5K lines)** | 135 µs | 408 µs | 0.33x | Raw FFI |
|
|
67
|
+
|
|
68
|
+
**Key Insights:**
|
|
69
|
+
|
|
70
|
+
- 🎯 **PTY/Terminal**: **15.29x faster** (exceeded 10x target!) - Native ring buffer, zero-copy reads
|
|
71
|
+
- ✅ **Edit Tool**: 2-6x faster across all file sizes with all 9 smart replacement strategies
|
|
72
|
+
- ✅ **Bash Parser**: 50-100x faster using native tree-sitter vs WASM (0.020ms per command, no initialization overhead)
|
|
73
|
+
- ✅ **Glob/Grep**: 1.8-2.7x faster by eliminating process spawn overhead
|
|
74
|
+
- ✅ **VCS Info**: 1.83x faster using libgit2 directly (no process spawning, 45% latency reduction)
|
|
75
|
+
- ✅ **Archive Extraction**: 3-5x faster using s-zip vs shell commands (unzip/PowerShell)
|
|
76
|
+
- ⚠️ **File I/O**: Raw FFI is 1.5-3x slower than Bun native due to FFI overhead
|
|
77
|
+
- 📊 **Memory**: Equivalent peak heap usage between Rust and Node.js for file I/O
|
|
78
|
+
- 🎯 **Lesson**: FFI overhead (~50µs) remains; only use Rust when compute > overhead
|
|
79
|
+
- 🔧 **Decision**: We use raw Rust FFI for consistency across native tool suite
|
|
80
|
+
|
|
81
|
+
**Native Rust Components:**
|
|
82
|
+
|
|
83
|
+
- ✅ **PTY/Terminal**: Full terminal session management with 2MB ring buffer, zero-copy streaming (15.29x faster) - Powers all Bash tool operations
|
|
84
|
+
- ✅ **Edit Tool**: 9 smart replacement strategies with fuzzy matching (complex compute justifies FFI)
|
|
85
|
+
- ✅ **File Listing**: Native ignore crate for fast directory traversal (eliminates process spawn)
|
|
86
|
+
- ✅ **File Search (Glob)**: Pattern matching with gitignore support (eliminates process spawn)
|
|
87
|
+
- ✅ **Code Search (Grep)**: Regex search across large codebases (eliminates process spawn)
|
|
88
|
+
- ✅ **Archive Extraction**: ZIP file extraction using s-zip streaming reader (3-5x faster, cross-platform)
|
|
89
|
+
- ✅ **Bash Parser**: Native tree-sitter bash command parsing (50-100x faster than WASM, 0.020ms per command)
|
|
90
|
+
- ✅ **File I/O**: Native read/write with optimized raw FFI
|
|
91
|
+
- ✅ **Directory Listing**: Fast recursive directory traversal
|
|
92
|
+
- ✅ **VCS Info**: Lightning-fast git repository information (libgit2 vs subprocess)
|
|
93
|
+
- ✅ **System Stats**: CPU and memory monitoring
|
|
94
|
+
|
|
95
|
+
**Benefits:**
|
|
96
|
+
|
|
97
|
+
- 🚀 **Up to 6x faster** text editing with 9 smart replacement strategies (Levenshtein, fuzzy matching)
|
|
98
|
+
- 🚀 **Up to 5x faster** archive extraction (ZIP files) with cross-platform native code
|
|
99
|
+
- 💚 **83% less time** on large file edits (10K lines: 451ms → 75ms)
|
|
100
|
+
- ⚡ **1.83x faster** git operations using libgit2 (no process spawning)
|
|
101
|
+
- 🎯 **2-3x faster** glob/grep by eliminating process spawn overhead
|
|
102
|
+
- 📊 **Optimized I/O**: Raw FFI implementation for consistent performance
|
|
103
|
+
- 🔧 **Consistent tooling**: Native Rust across all file operations for predictable performance
|
|
104
|
+
- 🌐 **Cross-platform**: No external dependencies (unzip/PowerShell) for archive extraction
|
|
105
|
+
|
|
106
|
+
### What Changed from OpenCode?
|
|
107
|
+
|
|
108
|
+
**Removed:**
|
|
109
|
+
|
|
110
|
+
- ❌ Cloud infrastructure (Cloudflare Workers, R2 storage)
|
|
111
|
+
- ❌ Web-based deployment
|
|
112
|
+
- ❌ Desktop application (Tauri/GUI)
|
|
113
|
+
- ❌ GitHub Action integration
|
|
114
|
+
- ❌ Billing/subscription system
|
|
115
|
+
- ❌ Authentication services
|
|
116
|
+
- ❌ Session sharing features
|
|
117
|
+
|
|
118
|
+
**Kept:**
|
|
119
|
+
|
|
120
|
+
- ✅ Complete CLI experience
|
|
121
|
+
- ✅ All AI agent capabilities
|
|
122
|
+
- ✅ Local session management
|
|
123
|
+
- ✅ Plugin system
|
|
124
|
+
- ✅ Multiple AI model support
|
|
125
|
+
|
|
126
|
+
**Enhanced:**
|
|
127
|
+
|
|
128
|
+
- 🚀 **Native Rust performance** for compute-heavy operations (2-6x faster)
|
|
129
|
+
- ⚡ **Eliminated process spawns** for glob/grep (2-3x speedup)
|
|
130
|
+
- 🗜️ **Fast archive extraction** with s-zip (3-5x faster, cross-platform native)
|
|
131
|
+
- 💚 **Faster edits** (2-6x improvement, scales with file size)
|
|
132
|
+
- 🔥 **Smart edit strategies** with fuzzy matching and Levenshtein similarity
|
|
133
|
+
- 📊 **Optimized I/O**: Raw FFI implementation for consistent performance
|
|
134
|
+
- 🔧 **Consistent native tooling**: All file operations use Rust for predictable performance
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Installation
|
|
139
|
+
|
|
140
|
+
IronCode is distributed as a CLI tool available through multiple package managers:
|
|
141
|
+
|
|
142
|
+
### NPM (Recommended)
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# Install globally
|
|
146
|
+
npm install -g ironcode-ai
|
|
147
|
+
|
|
148
|
+
# Or use with npx (no installation)
|
|
149
|
+
npx ironcode-ai
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Homebrew (macOS/Linux)
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
# Add the tap
|
|
156
|
+
brew tap KSD-CO/tap
|
|
157
|
+
|
|
158
|
+
# Install IronCode
|
|
159
|
+
brew install ironcode
|
|
160
|
+
|
|
161
|
+
# Update to latest version
|
|
162
|
+
brew upgrade ironcode
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Direct Download
|
|
166
|
+
|
|
167
|
+
Download pre-built binaries for your platform from [GitHub Releases](https://github.com/KSD-CO/IronCode/releases):
|
|
168
|
+
|
|
169
|
+
**Linux (x64):**
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
# Download and extract
|
|
173
|
+
curl -L https://github.com/KSD-CO/IronCode/releases/latest/download/ironcode-linux-x64.tar.gz | tar xz
|
|
174
|
+
|
|
175
|
+
# Move to PATH
|
|
176
|
+
sudo mv ironcode /usr/local/bin/
|
|
177
|
+
|
|
178
|
+
# Verify installation
|
|
179
|
+
ironcode --version
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**macOS (Apple Silicon):**
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
# Download and extract
|
|
186
|
+
curl -L https://github.com/KSD-CO/IronCode/releases/latest/download/ironcode-darwin-arm64.tar.gz | tar xz
|
|
187
|
+
|
|
188
|
+
# Move to PATH
|
|
189
|
+
sudo mv ironcode /usr/local/bin/
|
|
190
|
+
|
|
191
|
+
# Verify installation
|
|
192
|
+
ironcode --version
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**macOS (Intel):**
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
# Download and extract
|
|
199
|
+
curl -L https://github.com/KSD-CO/IronCode/releases/latest/download/ironcode-darwin-x64.tar.gz | tar xz
|
|
200
|
+
|
|
201
|
+
# Move to PATH
|
|
202
|
+
sudo mv ironcode /usr/local/bin/
|
|
203
|
+
|
|
204
|
+
# Verify installation
|
|
205
|
+
ironcode --version
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
**Windows:**
|
|
209
|
+
|
|
210
|
+
```powershell
|
|
211
|
+
# Download from releases page
|
|
212
|
+
# https://github.com/KSD-CO/IronCode/releases/latest
|
|
213
|
+
|
|
214
|
+
# Extract ironcode.exe and add to PATH
|
|
215
|
+
# Or run directly from download location
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Arch Linux (AUR)
|
|
219
|
+
|
|
220
|
+
_Coming soon - AUR package will be available in the future_
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## Usage
|
|
225
|
+
|
|
226
|
+
### Quick Start
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
# Start interactive session in current directory
|
|
230
|
+
ironcode
|
|
231
|
+
|
|
232
|
+
# Run with specific model
|
|
233
|
+
ironcode --model anthropic/claude-sonnet-4
|
|
234
|
+
|
|
235
|
+
# Show version
|
|
236
|
+
ironcode --version
|
|
237
|
+
|
|
238
|
+
# Show help
|
|
239
|
+
ironcode --help
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Configuration
|
|
243
|
+
|
|
244
|
+
IronCode requires API keys for the AI models you want to use. Set them as environment variables:
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
# Anthropic Claude (recommended)
|
|
248
|
+
export ANTHROPIC_API_KEY="your-key-here"
|
|
249
|
+
|
|
250
|
+
# OpenAI
|
|
251
|
+
export OPENAI_API_KEY="your-key-here"
|
|
252
|
+
|
|
253
|
+
# Add to your shell profile (~/.bashrc, ~/.zshrc, etc.)
|
|
254
|
+
echo 'export ANTHROPIC_API_KEY="your-key-here"' >> ~/.bashrc
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Interactive Mode
|
|
258
|
+
|
|
259
|
+
Once started, IronCode provides an interactive terminal UI:
|
|
260
|
+
|
|
261
|
+
- Type your requests naturally in English
|
|
262
|
+
- Switch between agents with `Tab` key
|
|
263
|
+
- Use `Ctrl+C` to cancel operations
|
|
264
|
+
- Use `Ctrl+D` or type `exit` to quit
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## Agents
|
|
269
|
+
|
|
270
|
+
IronCode includes built-in agents you can switch between with the `Tab` key:
|
|
271
|
+
|
|
272
|
+
- **build** - Full-access agent for development work (default)
|
|
273
|
+
- **plan** - Read-only agent for analysis and code exploration
|
|
274
|
+
- Denies file edits by default
|
|
275
|
+
- Asks permission before running bash commands
|
|
276
|
+
- Ideal for exploring unfamiliar codebases
|
|
277
|
+
|
|
278
|
+
Also included is a **general** subagent for complex searches and multistep tasks.
|
|
279
|
+
Invoke it with `@general` in your messages.
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## Development
|
|
284
|
+
|
|
285
|
+
### Prerequisites
|
|
286
|
+
|
|
287
|
+
- **Bun 1.3.8** (exact version required)
|
|
288
|
+
- **Rust** (latest stable)
|
|
289
|
+
- **Git**
|
|
290
|
+
|
|
291
|
+
### Building From Source
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
# Clone the repository
|
|
295
|
+
git clone https://github.com/KSD-CO/IronCode.git
|
|
296
|
+
cd IronCode
|
|
297
|
+
|
|
298
|
+
# Install dependencies
|
|
299
|
+
bun install
|
|
300
|
+
|
|
301
|
+
# Build Rust native components
|
|
302
|
+
cd packages/ironcode/native/tool
|
|
303
|
+
cargo build --release
|
|
304
|
+
cd ../../../..
|
|
305
|
+
|
|
306
|
+
# Run CLI locally (development mode)
|
|
307
|
+
bun dev
|
|
308
|
+
|
|
309
|
+
# Build standalone executable
|
|
310
|
+
cd packages/ironcode
|
|
311
|
+
bun run build
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
The compiled binary will be in `packages/ironcode/dist/ironcode/bin/ironcode`
|
|
315
|
+
|
|
316
|
+
### Development Commands
|
|
317
|
+
|
|
318
|
+
```bash
|
|
319
|
+
# Run tests
|
|
320
|
+
bun test
|
|
321
|
+
|
|
322
|
+
# Type checking
|
|
323
|
+
bun run typecheck
|
|
324
|
+
|
|
325
|
+
# Format code (using prettier)
|
|
326
|
+
bun run format
|
|
327
|
+
|
|
328
|
+
# Benchmark native Rust components
|
|
329
|
+
cd packages/ironcode/native/tool
|
|
330
|
+
cargo bench
|
|
331
|
+
|
|
332
|
+
# Edit tool performance comparison (TS vs Rust)
|
|
333
|
+
bun ./script/bench-edit.ts
|
|
334
|
+
|
|
335
|
+
# Bash parser performance (Native Rust tree-sitter)
|
|
336
|
+
bun --expose-gc ./script/bench-bash-parse-simple.ts
|
|
337
|
+
|
|
338
|
+
# VCS performance comparison (TS vs Rust)
|
|
339
|
+
bun ./script/bench-vcs.ts
|
|
340
|
+
|
|
341
|
+
# Test edit correctness (TS vs Rust)
|
|
342
|
+
bun ./script/test-edit-correctness.ts
|
|
343
|
+
|
|
344
|
+
# Memory benchmarks
|
|
345
|
+
bun --expose-gc ./script/bench-edit-memory.ts
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
## Architecture
|
|
351
|
+
|
|
352
|
+
IronCode is built with:
|
|
353
|
+
|
|
354
|
+
- **CLI/TUI**: TypeScript + Bun runtime
|
|
355
|
+
- **Plugins**: TypeScript plugin system
|
|
356
|
+
- **Native Performance Layer**: Rust (via FFI) for critical operations
|
|
357
|
+
- PTY/Terminal management with 15x speedup
|
|
358
|
+
- Edit operations with 9 smart replacement strategies
|
|
359
|
+
- Archive extraction with s-zip streaming reader
|
|
360
|
+
- File I/O with zero-copy optimization
|
|
361
|
+
- Pattern matching and regex search
|
|
362
|
+
- Git repository information
|
|
363
|
+
- System resource monitoring
|
|
364
|
+
|
|
365
|
+
### Native Rust Architecture
|
|
366
|
+
|
|
367
|
+
```
|
|
368
|
+
┌─────────────────────────────────────────┐
|
|
369
|
+
│ TypeScript Layer (Bun) │
|
|
370
|
+
│ ┌─────────────────────────────────┐ │
|
|
371
|
+
│ │ Edit Tool / File Operations │ │
|
|
372
|
+
│ └────────────┬────────────────────┘ │
|
|
373
|
+
│ │ FFI Bindings │
|
|
374
|
+
│ ┌────────────▼────────────────────┐ │
|
|
375
|
+
│ │ Native Rust Library │ │
|
|
376
|
+
│ │ • Edit strategies (9 types) │ │
|
|
377
|
+
│ │ • Bash parser (tree-sitter) │ │
|
|
378
|
+
│ │ • Archive extraction (s-zip) │ │
|
|
379
|
+
│ │ • File I/O (zero-copy) │ │
|
|
380
|
+
│ │ • Glob/Grep (optimized) │ │
|
|
381
|
+
│ │ • Git operations (libgit2) │ │
|
|
382
|
+
│ │ • System stats (sysinfo) │ │
|
|
383
|
+
│ └─────────────────────────────────┘ │
|
|
384
|
+
└─────────────────────────────────────────┘
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
**Performance Characteristics:**
|
|
388
|
+
|
|
389
|
+
- **Levenshtein Distance**: O(n×m) optimized with 2-row matrix (memory efficient)
|
|
390
|
+
- **Block Anchor Matching**: Similarity-based with configurable thresholds
|
|
391
|
+
- **Whitespace Normalization**: Smart indentation-preserving replacements
|
|
392
|
+
- **Context-Aware Matching**: Multi-line block matching with fuzzy tolerance
|
|
393
|
+
- **Memory Allocation**: Minimal heap usage, prefer stack allocation
|
|
394
|
+
- **Concurrency**: Ready for parallel processing (currently single-threaded)
|
|
395
|
+
|
|
396
|
+
---
|
|
397
|
+
|
|
398
|
+
## Contributing
|
|
399
|
+
|
|
400
|
+
Contributions are welcome! Please read [CONTRIBUTING.md](./CONTRIBUTING.md) before submitting pull requests.
|
|
401
|
+
|
|
402
|
+
**Areas we're looking for help:**
|
|
403
|
+
|
|
404
|
+
- Performance optimizations (more Rust rewrites!)
|
|
405
|
+
- Bug fixes and testing
|
|
406
|
+
- Documentation improvements
|
|
407
|
+
- New plugin development
|
|
408
|
+
- Benchmark improvements
|
|
409
|
+
- Additional native Rust components
|
|
410
|
+
|
|
411
|
+
**Recent Contributions:**
|
|
412
|
+
|
|
413
|
+
- ✅ **Native PTY/Terminal deployed to production** (15.29x speedup, powers Bash tool - Feb 2026)
|
|
414
|
+
- ✅ Native Rust edit tool with 9 strategies (3-4x speedup)
|
|
415
|
+
- ✅ File Watcher Rust infrastructure (ready but not integrated - @parcel/watcher already native)
|
|
416
|
+
- ✅ Comprehensive benchmarking suite
|
|
417
|
+
- ✅ Memory profiling and optimization
|
|
418
|
+
- ✅ Correctness testing framework (32 test cases)
|
|
419
|
+
|
|
420
|
+
---
|
|
421
|
+
|
|
422
|
+
## Performance Testing
|
|
423
|
+
|
|
424
|
+
We maintain rigorous performance testing to ensure all optimizations deliver real-world benefits:
|
|
425
|
+
|
|
426
|
+
### Correctness Tests
|
|
427
|
+
|
|
428
|
+
```bash
|
|
429
|
+
# Run all correctness tests (TS vs Rust comparison)
|
|
430
|
+
bun ./script/test-edit-correctness.ts # 18 unit tests
|
|
431
|
+
bun ./script/test-edit-real-files.ts # 4 real file tests
|
|
432
|
+
bun ./script/test-edit-stress.ts # 10 stress tests
|
|
433
|
+
bun ./script/test-integration.ts # Integration tests
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
**Test Coverage:**
|
|
437
|
+
|
|
438
|
+
- ✅ 32/32 tests passing (100% correctness)
|
|
439
|
+
- ✅ All 9 replacer strategies validated
|
|
440
|
+
- ✅ Edge cases: Unicode, regex chars, large files, mixed encodings
|
|
441
|
+
- ✅ Real-world file testing on actual codebase
|
|
442
|
+
|
|
443
|
+
### Performance Benchmarks
|
|
444
|
+
|
|
445
|
+
```bash
|
|
446
|
+
# PTY/Terminal benchmark (15.29x speedup)
|
|
447
|
+
bun script/bench-pty.ts
|
|
448
|
+
|
|
449
|
+
# Rust micro-benchmarks
|
|
450
|
+
cd packages/ironcode/native/tool
|
|
451
|
+
cargo bench --bench edit_bench
|
|
452
|
+
|
|
453
|
+
# VCS operations benchmark (git spawning vs libgit2)
|
|
454
|
+
bun ./script/bench-vcs.ts
|
|
455
|
+
|
|
456
|
+
# Memory benchmarks (with GC profiling)
|
|
457
|
+
bun --expose-gc ./script/bench-edit-memory.ts
|
|
458
|
+
|
|
459
|
+
# Rust memory profile
|
|
460
|
+
cd packages/ironcode/native/tool
|
|
461
|
+
cargo run --release --bin memory_bench
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
**Edit Tool Benchmark Results:**
|
|
465
|
+
|
|
466
|
+
| Metric | TypeScript | Rust | Improvement |
|
|
467
|
+
| ---------------- | -------------- | ------------- | ------------- |
|
|
468
|
+
| **10 lines** | 103 µs | 73 µs | 1.4x faster |
|
|
469
|
+
| **100 lines** | 1.32 ms | 1.09 ms | 1.2x faster |
|
|
470
|
+
| **1000 lines** | 16.9 ms | 7.7 ms | 2.2x faster |
|
|
471
|
+
| **5000 lines** | 205 ms | 65 ms | 3.1x faster |
|
|
472
|
+
| **10000 lines** | 758 ms | 171 ms | 4.4x faster |
|
|
473
|
+
| **Memory (1K)** | 2.42 MB alloc | 0.17 MB alloc | 93% reduction |
|
|
474
|
+
| **Memory (10K)** | 31.05 MB alloc | 1.91 MB alloc | 94% reduction |
|
|
475
|
+
|
|
476
|
+
**VCS Operations Benchmark Results:**
|
|
477
|
+
|
|
478
|
+
| Metric | Git Spawning (Old) | Native FFI (New) | Improvement |
|
|
479
|
+
| ------------------- | ------------------ | ---------------- | --------------- |
|
|
480
|
+
| **Average latency** | 17.25 ms | 9.43 ms | 1.83x faster |
|
|
481
|
+
| **Min latency** | 7.40 ms | 8.05 ms | Consistent |
|
|
482
|
+
| **Max latency** | 24.97 ms | 18.63 ms | 26% better |
|
|
483
|
+
| **p50 (median)** | 17.71 ms | 9.06 ms | 1.95x faster |
|
|
484
|
+
| **p90** | 21.31 ms | 10.10 ms | 2.11x faster |
|
|
485
|
+
| **p95** | 22.58 ms | 12.34 ms | 1.83x faster |
|
|
486
|
+
| **p99** | 24.36 ms | 17.71 ms | 1.38x faster |
|
|
487
|
+
| **Time saved** | - | 7.82 ms/call | 45.3% reduction |
|
|
488
|
+
|
|
489
|
+
_Benchmarked on IronCode repository (dev branch, 100 iterations)_
|
|
490
|
+
|
|
491
|
+
---
|
|
492
|
+
|
|
493
|
+
## Upstream Sync
|
|
494
|
+
|
|
495
|
+
This fork periodically syncs with [upstream OpenCode](https://github.com/anomalyco/opencode) to incorporate new features and bug fixes.
|
|
496
|
+
|
|
497
|
+
```bash
|
|
498
|
+
# To sync with upstream
|
|
499
|
+
git remote add upstream https://github.com/anomalyco/opencode.git
|
|
500
|
+
git fetch upstream
|
|
501
|
+
git merge upstream/dev
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
---
|
|
505
|
+
|
|
506
|
+
## License
|
|
507
|
+
|
|
508
|
+
This project maintains the same license as [OpenCode](https://github.com/anomalyco/opencode).
|
|
509
|
+
|
|
510
|
+
---
|
|
511
|
+
|
|
512
|
+
## Acknowledgments
|
|
513
|
+
|
|
514
|
+
- **OpenCode Team**: For creating the original open-source AI coding agent
|
|
515
|
+
- All contributors to this fork
|
|
516
|
+
|
|
517
|
+
---
|
|
518
|
+
|
|
519
|
+
## Links
|
|
520
|
+
|
|
521
|
+
- [Upstream OpenCode](https://github.com/anomalyco/opencode)
|
|
522
|
+
- [IronCode Documentation](https://ironcode.cloud/docs)
|
package/bin/ironcode
CHANGED
|
@@ -1,5 +1,84 @@
|
|
|
1
|
-
#!/bin/
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const childProcess = require("child_process")
|
|
4
|
+
const fs = require("fs")
|
|
5
|
+
const path = require("path")
|
|
6
|
+
const os = require("os")
|
|
7
|
+
|
|
8
|
+
function run(target) {
|
|
9
|
+
const result = childProcess.spawnSync(target, process.argv.slice(2), {
|
|
10
|
+
stdio: "inherit",
|
|
11
|
+
})
|
|
12
|
+
if (result.error) {
|
|
13
|
+
console.error(result.error.message)
|
|
14
|
+
process.exit(1)
|
|
15
|
+
}
|
|
16
|
+
const code = typeof result.status === "number" ? result.status : 0
|
|
17
|
+
process.exit(code)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const envPath = process.env.IRONCODE_BIN_PATH
|
|
21
|
+
if (envPath) {
|
|
22
|
+
run(envPath)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const scriptPath = fs.realpathSync(__filename)
|
|
26
|
+
const scriptDir = path.dirname(scriptPath)
|
|
27
|
+
|
|
28
|
+
const platformMap = {
|
|
29
|
+
darwin: "darwin",
|
|
30
|
+
linux: "linux",
|
|
31
|
+
win32: "windows",
|
|
32
|
+
}
|
|
33
|
+
const archMap = {
|
|
34
|
+
x64: "x64",
|
|
35
|
+
arm64: "arm64",
|
|
36
|
+
arm: "arm",
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let platform = platformMap[os.platform()]
|
|
40
|
+
if (!platform) {
|
|
41
|
+
platform = os.platform()
|
|
42
|
+
}
|
|
43
|
+
let arch = archMap[os.arch()]
|
|
44
|
+
if (!arch) {
|
|
45
|
+
arch = os.arch()
|
|
46
|
+
}
|
|
47
|
+
const base = "ironcode-" + platform + "-" + arch
|
|
48
|
+
const binary = platform === "windows" ? "ironcode.exe" : "ironcode"
|
|
49
|
+
|
|
50
|
+
function findBinary(startDir) {
|
|
51
|
+
let current = startDir
|
|
52
|
+
for (;;) {
|
|
53
|
+
const modules = path.join(current, "node_modules")
|
|
54
|
+
if (fs.existsSync(modules)) {
|
|
55
|
+
const entries = fs.readdirSync(modules)
|
|
56
|
+
for (const entry of entries) {
|
|
57
|
+
if (!entry.startsWith(base)) {
|
|
58
|
+
continue
|
|
59
|
+
}
|
|
60
|
+
const candidate = path.join(modules, entry, "bin", binary)
|
|
61
|
+
if (fs.existsSync(candidate)) {
|
|
62
|
+
return candidate
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const parent = path.dirname(current)
|
|
67
|
+
if (parent === current) {
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
current = parent
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const resolved = findBinary(scriptDir)
|
|
75
|
+
if (!resolved) {
|
|
76
|
+
console.error(
|
|
77
|
+
'It seems that your package manager failed to install the right version of the ironcode CLI for your platform. You can try manually installing the "' +
|
|
78
|
+
base +
|
|
79
|
+
'" package',
|
|
80
|
+
)
|
|
81
|
+
process.exit(1)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
run(resolved)
|
package/package.json
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
"scripts": {
|
|
7
7
|
"postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
|
|
8
8
|
},
|
|
9
|
-
"version": "1.
|
|
9
|
+
"version": "1.5.2",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"optionalDependencies": {
|
|
12
|
-
"ironcode-darwin-arm64": "1.
|
|
13
|
-
"ironcode-windows-x64": "1.
|
|
14
|
-
"ironcode-linux-x64": "1.
|
|
12
|
+
"ironcode-darwin-arm64": "1.5.2",
|
|
13
|
+
"ironcode-windows-x64": "1.5.2",
|
|
14
|
+
"ironcode-linux-x64": "1.5.2"
|
|
15
15
|
}
|
|
16
16
|
}
|
package/bin/opencode
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const childProcess = require("child_process")
|
|
4
|
-
const fs = require("fs")
|
|
5
|
-
const path = require("path")
|
|
6
|
-
const os = require("os")
|
|
7
|
-
|
|
8
|
-
function run(target) {
|
|
9
|
-
const result = childProcess.spawnSync(target, process.argv.slice(2), {
|
|
10
|
-
stdio: "inherit",
|
|
11
|
-
})
|
|
12
|
-
if (result.error) {
|
|
13
|
-
console.error(result.error.message)
|
|
14
|
-
process.exit(1)
|
|
15
|
-
}
|
|
16
|
-
const code = typeof result.status === "number" ? result.status : 0
|
|
17
|
-
process.exit(code)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const envPath = process.env.IRONCODE_BIN_PATH
|
|
21
|
-
if (envPath) {
|
|
22
|
-
run(envPath)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const scriptPath = fs.realpathSync(__filename)
|
|
26
|
-
const scriptDir = path.dirname(scriptPath)
|
|
27
|
-
|
|
28
|
-
const platformMap = {
|
|
29
|
-
darwin: "darwin",
|
|
30
|
-
linux: "linux",
|
|
31
|
-
win32: "windows",
|
|
32
|
-
}
|
|
33
|
-
const archMap = {
|
|
34
|
-
x64: "x64",
|
|
35
|
-
arm64: "arm64",
|
|
36
|
-
arm: "arm",
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
let platform = platformMap[os.platform()]
|
|
40
|
-
if (!platform) {
|
|
41
|
-
platform = os.platform()
|
|
42
|
-
}
|
|
43
|
-
let arch = archMap[os.arch()]
|
|
44
|
-
if (!arch) {
|
|
45
|
-
arch = os.arch()
|
|
46
|
-
}
|
|
47
|
-
const base = "ironcode-" + platform + "-" + arch
|
|
48
|
-
const binary = platform === "windows" ? "ironcode.exe" : "ironcode"
|
|
49
|
-
|
|
50
|
-
function findBinary(startDir) {
|
|
51
|
-
let current = startDir
|
|
52
|
-
for (;;) {
|
|
53
|
-
const modules = path.join(current, "node_modules")
|
|
54
|
-
if (fs.existsSync(modules)) {
|
|
55
|
-
const entries = fs.readdirSync(modules)
|
|
56
|
-
for (const entry of entries) {
|
|
57
|
-
if (!entry.startsWith(base)) {
|
|
58
|
-
continue
|
|
59
|
-
}
|
|
60
|
-
const candidate = path.join(modules, entry, "bin", binary)
|
|
61
|
-
if (fs.existsSync(candidate)) {
|
|
62
|
-
return candidate
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
const parent = path.dirname(current)
|
|
67
|
-
if (parent === current) {
|
|
68
|
-
return
|
|
69
|
-
}
|
|
70
|
-
current = parent
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const resolved = findBinary(scriptDir)
|
|
75
|
-
if (!resolved) {
|
|
76
|
-
console.error(
|
|
77
|
-
'It seems that your package manager failed to install the right version of the ironcode CLI for your platform. You can try manually installing the "' +
|
|
78
|
-
base +
|
|
79
|
-
'" package',
|
|
80
|
-
)
|
|
81
|
-
process.exit(1)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
run(resolved)
|