rskim 0.2.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 +229 -0
- package/bin/darwin/arm64/rskim +0 -0
- package/bin/darwin/x64/rskim +0 -0
- package/bin/linux/x64/rskim +0 -0
- package/bin/rskim.js +38 -0
- package/bin/win32/x64/rskim.exe +0 -0
- package/package.json +34 -0
package/README.md
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
# rskim
|
|
2
|
+
|
|
3
|
+
Smart code reader - streaming code transformation for AI agents.
|
|
4
|
+
|
|
5
|
+
[](https://crates.io/crates/rskim)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
`rskim` transforms source code by intelligently removing implementation details while preserving structure, signatures, and types - perfect for optimizing code for LLM context windows.
|
|
11
|
+
|
|
12
|
+
Think of it like `cat`, but smart about what code to show.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
### Via Cargo
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
cargo install rskim
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Via npm (coming soon)
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install -g rskim
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Quick Start
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Read TypeScript with structure mode
|
|
32
|
+
rskim file.ts
|
|
33
|
+
|
|
34
|
+
# Extract Python function signatures
|
|
35
|
+
rskim file.py --mode signatures
|
|
36
|
+
|
|
37
|
+
# Pipe to syntax highlighter
|
|
38
|
+
rskim file.rs | bat -l rust
|
|
39
|
+
|
|
40
|
+
# Read from stdin
|
|
41
|
+
cat code.ts | rskim - --language=type-script
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Features
|
|
45
|
+
|
|
46
|
+
- **6 Languages**: TypeScript, JavaScript, Python, Rust, Go, Java
|
|
47
|
+
- **4 Transformation Modes**: Structure, Signatures, Types, Full
|
|
48
|
+
- **Fast**: <50ms for 1000-line files
|
|
49
|
+
- **Streaming**: Outputs to stdout for pipe workflows
|
|
50
|
+
- **Safe**: Built-in DoS protections
|
|
51
|
+
|
|
52
|
+
## Usage
|
|
53
|
+
|
|
54
|
+
### Basic Usage
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
rskim <FILE>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Options
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
Options:
|
|
64
|
+
-m, --mode <MODE> Transformation mode [default: structure]
|
|
65
|
+
[possible values: structure, signatures, types, full]
|
|
66
|
+
-l, --language <LANGUAGE> Override language detection
|
|
67
|
+
[possible values: type-script, java-script, python, rust, go, java]
|
|
68
|
+
-h, --help Print help
|
|
69
|
+
-V, --version Print version
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Transformation Modes
|
|
73
|
+
|
|
74
|
+
### Structure Mode (Default)
|
|
75
|
+
|
|
76
|
+
Removes function bodies while preserving signatures (70-80% reduction).
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
rskim file.ts
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**Input:**
|
|
83
|
+
```typescript
|
|
84
|
+
function add(a: number, b: number): number {
|
|
85
|
+
const result = a + b;
|
|
86
|
+
console.log(`Adding ${a} + ${b} = ${result}`);
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Output:**
|
|
92
|
+
```typescript
|
|
93
|
+
function add(a: number, b: number): number { /* ... */ }
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Signatures Mode
|
|
97
|
+
|
|
98
|
+
Extracts only function and method signatures (85-92% reduction).
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
rskim file.py --mode signatures
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Input:**
|
|
105
|
+
```python
|
|
106
|
+
def calculate_total(items: list[Item], tax_rate: float) -> Decimal:
|
|
107
|
+
subtotal = sum(item.price for item in items)
|
|
108
|
+
tax = subtotal * tax_rate
|
|
109
|
+
return subtotal + tax
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Output:**
|
|
113
|
+
```python
|
|
114
|
+
def calculate_total(items: list[Item], tax_rate: float) -> Decimal:
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Types Mode
|
|
118
|
+
|
|
119
|
+
Extracts only type definitions (90-95% reduction).
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
rskim file.ts --mode types
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Input:**
|
|
126
|
+
```typescript
|
|
127
|
+
interface User {
|
|
128
|
+
id: number;
|
|
129
|
+
name: string;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function getUser(id: number): User {
|
|
133
|
+
return db.users.find(id);
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**Output:**
|
|
138
|
+
```typescript
|
|
139
|
+
interface User {
|
|
140
|
+
id: number;
|
|
141
|
+
name: string;
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Full Mode
|
|
146
|
+
|
|
147
|
+
Returns original code unchanged (0% reduction).
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
rskim file.rs --mode full
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Examples
|
|
154
|
+
|
|
155
|
+
### Explore a codebase
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
# Get overview of all TypeScript files
|
|
159
|
+
find src -name '*.ts' -exec rskim {} \;
|
|
160
|
+
|
|
161
|
+
# Extract all Python function signatures
|
|
162
|
+
rskim app.py --mode signatures > api.txt
|
|
163
|
+
|
|
164
|
+
# Review Rust types
|
|
165
|
+
rskim lib.rs --mode types | less
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Prepare code for LLMs
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
# Reduce token count before sending to GPT
|
|
172
|
+
rskim large_file.ts | wc -w
|
|
173
|
+
# Output: 150 (was 600)
|
|
174
|
+
|
|
175
|
+
# Get just the API surface
|
|
176
|
+
rskim server.py --mode signatures | pbcopy
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Pipe workflows
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
# Skim and highlight
|
|
183
|
+
rskim file.rs | bat -l rust
|
|
184
|
+
|
|
185
|
+
# Skim and search
|
|
186
|
+
rskim file.ts | grep "interface"
|
|
187
|
+
|
|
188
|
+
# Skim multiple files
|
|
189
|
+
cat *.py | rskim - --language=python
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Supported Languages
|
|
193
|
+
|
|
194
|
+
| Language | Extensions | Auto-detected |
|
|
195
|
+
|------------|--------------------|---------------|
|
|
196
|
+
| TypeScript | `.ts`, `.tsx` | ✅ |
|
|
197
|
+
| JavaScript | `.js`, `.jsx`, `.mjs` | ✅ |
|
|
198
|
+
| Python | `.py` | ✅ |
|
|
199
|
+
| Rust | `.rs` | ✅ |
|
|
200
|
+
| Go | `.go` | ✅ |
|
|
201
|
+
| Java | `.java` | ✅ |
|
|
202
|
+
|
|
203
|
+
## Performance
|
|
204
|
+
|
|
205
|
+
- **Parse + Transform**: <50ms for 1000-line files
|
|
206
|
+
- **Token Reduction**: 60-95% depending on mode
|
|
207
|
+
- **Streaming**: Zero intermediate files
|
|
208
|
+
|
|
209
|
+
## Security
|
|
210
|
+
|
|
211
|
+
Built-in protections against:
|
|
212
|
+
- Stack overflow attacks (max depth: 500)
|
|
213
|
+
- Memory exhaustion (max input: 50MB)
|
|
214
|
+
- UTF-8 boundary violations
|
|
215
|
+
- Path traversal attacks
|
|
216
|
+
|
|
217
|
+
## Library
|
|
218
|
+
|
|
219
|
+
For programmatic usage, see the [`rskim-core`](https://crates.io/crates/rskim-core) library crate.
|
|
220
|
+
|
|
221
|
+
## Links
|
|
222
|
+
|
|
223
|
+
- [Repository](https://github.com/dean0x/skim)
|
|
224
|
+
- [Library Documentation](https://docs.rs/rskim-core)
|
|
225
|
+
- [npm Package](https://www.npmjs.com/package/rskim) (coming soon)
|
|
226
|
+
|
|
227
|
+
## License
|
|
228
|
+
|
|
229
|
+
MIT
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/bin/rskim.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { spawnSync } = require('child_process');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
|
|
6
|
+
function getBinaryPath() {
|
|
7
|
+
const platform = process.platform;
|
|
8
|
+
const arch = process.arch;
|
|
9
|
+
|
|
10
|
+
let binaryName = 'rskim';
|
|
11
|
+
if (platform === 'win32') {
|
|
12
|
+
binaryName = 'rskim.exe';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Try to find the binary in the package
|
|
16
|
+
const possiblePaths = [
|
|
17
|
+
path.join(__dirname, '..', 'bin', platform, arch, binaryName),
|
|
18
|
+
path.join(__dirname, '..', 'bin', binaryName),
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
for (const p of possiblePaths) {
|
|
22
|
+
if (fs.existsSync(p)) {
|
|
23
|
+
return p;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
console.error('ERROR: rskim binary not found for your platform');
|
|
28
|
+
console.error(\`Platform: \${platform}, Architecture: \${arch}\`);
|
|
29
|
+
console.error('Please report this issue at: https://github.com/dean0x/skim/issues');
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const binary = getBinaryPath();
|
|
34
|
+
const result = spawnSync(binary, process.argv.slice(2), {
|
|
35
|
+
stdio: 'inherit',
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
process.exit(result.status || 0);
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rskim",
|
|
3
|
+
"version": "0.2.2",
|
|
4
|
+
"description": "Smart code reader - streaming code transformation for AI agents",
|
|
5
|
+
"bin": {
|
|
6
|
+
"rskim": "./bin/rskim.js"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/dean0x/skim.git"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"code",
|
|
14
|
+
"ast",
|
|
15
|
+
"tree-sitter",
|
|
16
|
+
"llm",
|
|
17
|
+
"transformation"
|
|
18
|
+
],
|
|
19
|
+
"author": "Skim Contributors",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/dean0x/skim/issues"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/dean0x/skim#readme",
|
|
25
|
+
"os": [
|
|
26
|
+
"darwin",
|
|
27
|
+
"linux",
|
|
28
|
+
"win32"
|
|
29
|
+
],
|
|
30
|
+
"cpu": [
|
|
31
|
+
"x64",
|
|
32
|
+
"arm64"
|
|
33
|
+
]
|
|
34
|
+
}
|