@ebowwa/claude-code-native 0.1.0
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 +53 -0
- package/claude_code_native.darwin-x64.node +0 -0
- package/index.d.ts +50 -0
- package/index.js +29 -0
- package/package.json +34 -0
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# @ebowwa/claude-code-native
|
|
2
|
+
|
|
3
|
+
Native Rust modules for [Claude Code Remake](https://github.com/ebowwa/codespaces).
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Fast Search**: Ripgrep-based file and content search
|
|
8
|
+
- **Token Counting**: Efficient token counting for LLM contexts
|
|
9
|
+
- **Diff Calculation**: Fast diff generation and application
|
|
10
|
+
- **Content Compaction**: Smart content compaction for context windows
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
bun add @ebowwa/claude-code-native
|
|
16
|
+
# or
|
|
17
|
+
npm install @ebowwa/claude-code-native
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Supported Platforms
|
|
21
|
+
|
|
22
|
+
- macOS x64 (Intel)
|
|
23
|
+
- macOS arm64 (Apple Silicon)
|
|
24
|
+
- Linux x64 (GNU)
|
|
25
|
+
- Windows x64 (MSVC)
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
```javascript
|
|
30
|
+
const native = require('@ebowwa/claude-code-native');
|
|
31
|
+
|
|
32
|
+
// Search files
|
|
33
|
+
const results = native.searchFiles('pattern', '/path/to/search');
|
|
34
|
+
|
|
35
|
+
// Count tokens
|
|
36
|
+
const tokens = native.countTokens('some text content');
|
|
37
|
+
|
|
38
|
+
// Compute diff
|
|
39
|
+
const diff = native.computeDiff(oldText, newText);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Building from Source
|
|
43
|
+
|
|
44
|
+
Requires Rust and Cargo:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
cd rust
|
|
48
|
+
cargo build --release
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## License
|
|
52
|
+
|
|
53
|
+
MIT
|
|
Binary file
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// TypeScript declarations for claude-code-native
|
|
2
|
+
|
|
3
|
+
export interface SearchResult {
|
|
4
|
+
path: string;
|
|
5
|
+
line: number;
|
|
6
|
+
column: number;
|
|
7
|
+
content: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface DiffResult {
|
|
11
|
+
additions: number;
|
|
12
|
+
deletions: number;
|
|
13
|
+
hunks: DiffHunk[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface DiffHunk {
|
|
17
|
+
oldStart: number;
|
|
18
|
+
oldLines: number;
|
|
19
|
+
newStart: number;
|
|
20
|
+
newLines: number;
|
|
21
|
+
content: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface CompactResult {
|
|
25
|
+
original: number;
|
|
26
|
+
compacted: number;
|
|
27
|
+
content: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Search functions
|
|
31
|
+
export function searchFiles(pattern: string, path: string, options?: SearchOptions): SearchResult[];
|
|
32
|
+
export function searchContent(query: string, path: string, options?: SearchOptions): SearchResult[];
|
|
33
|
+
|
|
34
|
+
// Token functions
|
|
35
|
+
export function countTokens(text: string): number;
|
|
36
|
+
export function countMessagesTokens(messages: any[]): number;
|
|
37
|
+
|
|
38
|
+
// Diff functions
|
|
39
|
+
export function computeDiff(oldText: string, newText: string): DiffResult;
|
|
40
|
+
export function applyDiff(text: string, diff: DiffResult): string;
|
|
41
|
+
|
|
42
|
+
// Compact functions
|
|
43
|
+
export function compactContent(content: string, maxTokens: number): CompactResult;
|
|
44
|
+
|
|
45
|
+
export interface SearchOptions {
|
|
46
|
+
ignoreCase?: boolean;
|
|
47
|
+
includeHidden?: boolean;
|
|
48
|
+
maxResults?: number;
|
|
49
|
+
filePattern?: string;
|
|
50
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Native module loader for claude-code-native
|
|
2
|
+
// Loads the appropriate .node file based on platform
|
|
3
|
+
|
|
4
|
+
const { platform, arch } = process;
|
|
5
|
+
|
|
6
|
+
let nativeBinding;
|
|
7
|
+
|
|
8
|
+
try {
|
|
9
|
+
switch (`${platform}-${arch}`) {
|
|
10
|
+
case 'darwin-x64':
|
|
11
|
+
nativeBinding = require('./claude_code_native.darwin-x64.node');
|
|
12
|
+
break;
|
|
13
|
+
case 'darwin-arm64':
|
|
14
|
+
nativeBinding = require('./claude_code_native.darwin-arm64.node');
|
|
15
|
+
break;
|
|
16
|
+
case 'linux-x64':
|
|
17
|
+
nativeBinding = require('./claude_code_native.linux-x64-gnu.node');
|
|
18
|
+
break;
|
|
19
|
+
case 'win32-x64':
|
|
20
|
+
nativeBinding = require('./claude_code_native.win32-x64-msvc.node');
|
|
21
|
+
break;
|
|
22
|
+
default:
|
|
23
|
+
throw new Error(`Unsupported platform: ${platform}-${arch}`);
|
|
24
|
+
}
|
|
25
|
+
} catch (e) {
|
|
26
|
+
throw new Error(`Failed to load native module: ${e.message}`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = nativeBinding;
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ebowwa/claude-code-native",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Native Rust modules for Claude Code Remake - provides high-performance search, token counting, and diff operations",
|
|
5
|
+
"author": "ebowwa",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"keywords": ["claude", "native", "rust", "napi", "search", "tokens"],
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/ebowwa/codespaces"
|
|
11
|
+
},
|
|
12
|
+
"main": "index.js",
|
|
13
|
+
"types": "index.d.ts",
|
|
14
|
+
"files": [
|
|
15
|
+
"*.node",
|
|
16
|
+
"index.js",
|
|
17
|
+
"index.d.ts"
|
|
18
|
+
],
|
|
19
|
+
"napi": {
|
|
20
|
+
"name": "claude_code_native",
|
|
21
|
+
"triples": {
|
|
22
|
+
"defaults": false,
|
|
23
|
+
"additional": [
|
|
24
|
+
"x86_64-apple-darwin",
|
|
25
|
+
"aarch64-apple-darwin",
|
|
26
|
+
"x86_64-unknown-linux-gnu",
|
|
27
|
+
"x86_64-pc-windows-msvc"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">= 16"
|
|
33
|
+
}
|
|
34
|
+
}
|