tsunami-code 2.5.2 → 2.6.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/.tsunami/README.md +10 -0
- package/index.js +163 -17
- package/lib/loop.js +124 -8
- package/lib/memory.js +493 -0
- package/lib/prompt.js +30 -3
- package/lib/tools.js +98 -1
- package/package.json +1 -1
- package/scripts/setup.js +227 -39
- package/vendor/rg.exe +0 -0
- package/vendor/ripgrep-14.1.1-x86_64-pc-windows-msvc/COPYING +3 -0
- package/vendor/ripgrep-14.1.1-x86_64-pc-windows-msvc/LICENSE-MIT +21 -0
- package/vendor/ripgrep-14.1.1-x86_64-pc-windows-msvc/README.md +524 -0
- package/vendor/ripgrep-14.1.1-x86_64-pc-windows-msvc/UNLICENSE +24 -0
- package/vendor/ripgrep-14.1.1-x86_64-pc-windows-msvc/complete/_rg +665 -0
- package/vendor/ripgrep-14.1.1-x86_64-pc-windows-msvc/complete/_rg.ps1 +213 -0
- package/vendor/ripgrep-14.1.1-x86_64-pc-windows-msvc/complete/rg.bash +783 -0
- package/vendor/ripgrep-14.1.1-x86_64-pc-windows-msvc/complete/rg.fish +175 -0
- package/vendor/ripgrep-14.1.1-x86_64-pc-windows-msvc/doc/CHANGELOG.md +1711 -0
- package/vendor/ripgrep-14.1.1-x86_64-pc-windows-msvc/doc/FAQ.md +1046 -0
- package/vendor/ripgrep-14.1.1-x86_64-pc-windows-msvc/doc/GUIDE.md +1022 -0
- package/vendor/ripgrep-14.1.1-x86_64-pc-windows-msvc/doc/rg.1 +2178 -0
- package/vendor/ripgrep-14.1.1-x86_64-pc-windows-msvc/rg.exe +0 -0
package/scripts/setup.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Runs at npm install time — downloads the ripgrep binary for this platform
|
|
3
2
|
import { createWriteStream, existsSync, mkdirSync, chmodSync } from 'fs';
|
|
4
3
|
import { join, dirname } from 'path';
|
|
5
4
|
import { fileURLToPath } from 'url';
|
|
6
5
|
import { pipeline } from 'stream/promises';
|
|
7
6
|
import https from 'https';
|
|
8
|
-
import { createGunzip } from 'zlib';
|
|
9
7
|
import { exec } from 'child_process';
|
|
10
8
|
import { promisify } from 'util';
|
|
11
9
|
|
|
@@ -14,82 +12,272 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
|
14
12
|
const ROOT = join(__dirname, '..');
|
|
15
13
|
const VENDOR = join(ROOT, 'vendor');
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
// ── ANSI colors (no deps at install time) ─────────────────────────────────────
|
|
16
|
+
const c = {
|
|
17
|
+
reset: '\x1b[0m',
|
|
18
|
+
bold: '\x1b[1m',
|
|
19
|
+
dim: '\x1b[2m',
|
|
20
|
+
cyan: '\x1b[36m',
|
|
21
|
+
blue: '\x1b[34m',
|
|
22
|
+
white: '\x1b[97m',
|
|
23
|
+
green: '\x1b[32m',
|
|
24
|
+
yellow: '\x1b[33m',
|
|
25
|
+
red: '\x1b[31m',
|
|
26
|
+
bBlue: '\x1b[94m',
|
|
27
|
+
bCyan: '\x1b[96m',
|
|
24
28
|
};
|
|
29
|
+
const col = (code, s) => `${code}${s}${c.reset}`;
|
|
30
|
+
const cyan = s => col(c.cyan + c.bold, s);
|
|
31
|
+
const bcyan = s => col(c.bCyan, s);
|
|
32
|
+
const blue = s => col(c.bBlue, s);
|
|
33
|
+
const dim = s => col(c.dim, s);
|
|
34
|
+
const bold = s => col(c.bold, s);
|
|
35
|
+
const green = s => col(c.green + c.bold, s);
|
|
36
|
+
const yellow = s => col(c.yellow, s);
|
|
37
|
+
const white = s => col(c.white, s);
|
|
25
38
|
|
|
26
|
-
const
|
|
27
|
-
const
|
|
39
|
+
const print = s => process.stdout.write(s + '\n');
|
|
40
|
+
const write = s => process.stdout.write(s);
|
|
41
|
+
const clear = () => write('\r\x1b[2K');
|
|
42
|
+
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
|
28
43
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
44
|
+
// ── ASCII banner ──────────────────────────────────────────────────────────────
|
|
45
|
+
function printBanner() {
|
|
46
|
+
print('');
|
|
47
|
+
print(cyan(' ████████╗███████╗██╗ ██╗███╗ ██╗ █████╗ ███╗ ███╗██╗'));
|
|
48
|
+
print(cyan(' ██╔══╝██╔════╝██║ ██║████╗ ██║██╔══██╗████╗ ████║██║'));
|
|
49
|
+
print(cyan(' ██║ ███████╗██║ ██║██╔██╗ ██║███████║██╔████╔██║██║'));
|
|
50
|
+
print(cyan(' ██║ ╚════██║██║ ██║██║╚██╗██║██╔══██║██║╚██╔╝██║██║'));
|
|
51
|
+
print(cyan(' ██║ ███████║╚██████╔╝██║ ╚████║██║ ██║██║ ╚═╝ ██║██║'));
|
|
52
|
+
print(cyan(' ╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝'));
|
|
53
|
+
print('');
|
|
54
|
+
print(bcyan(' ██████╗ ██████╗ ██████╗ ███████╗'));
|
|
55
|
+
print(bcyan(' ██╔════╝██╔═══██╗██╔══██╗██╔════╝'));
|
|
56
|
+
print(bcyan(' ██║ ██║ ██║██║ ██║█████╗ '));
|
|
57
|
+
print(bcyan(' ██║ ██║ ██║██║ ██║██╔══╝ '));
|
|
58
|
+
print(bcyan(' ╚██████╗╚██████╔╝██████╔╝███████╗'));
|
|
59
|
+
print(bcyan(' ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝'));
|
|
60
|
+
print('');
|
|
61
|
+
print(dim(' by Keystone World Management · Navy Seal Unit XI3'));
|
|
62
|
+
print('');
|
|
32
63
|
}
|
|
33
64
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
65
|
+
// ── Wave animation ────────────────────────────────────────────────────────────
|
|
66
|
+
const WAVE_FRAMES = [
|
|
67
|
+
' 🌊 ',
|
|
68
|
+
' 🌊 ',
|
|
69
|
+
' 🌊 ',
|
|
70
|
+
' 🌊~ ',
|
|
71
|
+
' 🌊~~ ',
|
|
72
|
+
' 🌊~~~ ',
|
|
73
|
+
' 🌊~~~~ ',
|
|
74
|
+
' 🌊~~~~~ ',
|
|
75
|
+
' 🌊~~~~~~ ',
|
|
76
|
+
' 🌊~~~~~~~ ',
|
|
77
|
+
' 🌊~~~~~~~~ ',
|
|
78
|
+
' 🌊~~~~~~~~~ ',
|
|
79
|
+
' 🌊~~~~~~~~~~ ',
|
|
80
|
+
' 🌊~~~~~~~~~~~ ',
|
|
81
|
+
' 🌊~~~~~~~~~~~~ ',
|
|
82
|
+
' 🌊~~~~~~~~~~~~~ ',
|
|
83
|
+
' 🌊~~~~~~~~~~~~~~ ',
|
|
84
|
+
' 🌊~~~~~~~~~~~~~~~ ',
|
|
85
|
+
' 🌊~~~~~~~~~~~~~~~~ ',
|
|
86
|
+
' 🌊~~~~~~~~~~~~~~~~~ ',
|
|
87
|
+
' 🌊~~~~~~~~~~~~~~~~~~ ',
|
|
88
|
+
' 🌊~~~~~~~~~~~~~~~~~~💥',
|
|
89
|
+
];
|
|
90
|
+
|
|
91
|
+
async function playWave(label) {
|
|
92
|
+
write(dim(` ${label}`));
|
|
93
|
+
await sleep(400);
|
|
94
|
+
for (const frame of WAVE_FRAMES) {
|
|
95
|
+
clear();
|
|
96
|
+
write(bcyan(frame));
|
|
97
|
+
await sleep(55);
|
|
98
|
+
}
|
|
99
|
+
clear();
|
|
37
100
|
}
|
|
38
101
|
|
|
39
|
-
|
|
102
|
+
// ── Spinner ───────────────────────────────────────────────────────────────────
|
|
103
|
+
const SPIN = ['⠋','⠙','⠹','⠸','⠼','⠴','⠦','⠧','⠇','⠏'];
|
|
40
104
|
|
|
41
|
-
|
|
105
|
+
function startSpinner(label) {
|
|
106
|
+
let i = 0;
|
|
107
|
+
const iv = setInterval(() => {
|
|
108
|
+
clear();
|
|
109
|
+
write(cyan(` ${SPIN[i++ % SPIN.length]} `) + white(label));
|
|
110
|
+
}, 80);
|
|
111
|
+
return { stop(doneLabel) { clearInterval(iv); clear(); print(green(' ✓ ') + white(doneLabel)); } };
|
|
112
|
+
}
|
|
42
113
|
|
|
114
|
+
// ── Download with live progress bar ──────────────────────────────────────────
|
|
43
115
|
function httpsGet(url) {
|
|
44
116
|
return new Promise((resolve, reject) => {
|
|
45
|
-
https.get(url, { headers: { 'User-Agent': '
|
|
117
|
+
https.get(url, { headers: { 'User-Agent': 'tsunami-code-setup' } }, res => {
|
|
46
118
|
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
47
119
|
httpsGet(res.headers.location).then(resolve).catch(reject);
|
|
48
120
|
return;
|
|
49
121
|
}
|
|
50
|
-
if (res.statusCode !== 200) {
|
|
51
|
-
reject(new Error(`HTTP ${res.statusCode}`));
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
122
|
+
if (res.statusCode !== 200) { reject(new Error(`HTTP ${res.statusCode}`)); return; }
|
|
54
123
|
resolve(res);
|
|
55
124
|
}).on('error', reject);
|
|
56
125
|
});
|
|
57
126
|
}
|
|
58
127
|
|
|
59
|
-
async function
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
128
|
+
async function downloadWithProgress(url, destPath) {
|
|
129
|
+
const res = await httpsGet(url);
|
|
130
|
+
const total = parseInt(res.headers['content-length'] || '0', 10);
|
|
131
|
+
let received = 0;
|
|
132
|
+
const BAR = 30;
|
|
133
|
+
|
|
134
|
+
const out = createWriteStream(destPath);
|
|
135
|
+
|
|
136
|
+
await new Promise((resolve, reject) => {
|
|
137
|
+
res.on('data', chunk => {
|
|
138
|
+
received += chunk.length;
|
|
139
|
+
out.write(chunk);
|
|
140
|
+
|
|
141
|
+
if (total) {
|
|
142
|
+
const pct = received / total;
|
|
143
|
+
const filled = Math.round(BAR * pct);
|
|
144
|
+
const bar = bcyan('█'.repeat(filled)) + dim('░'.repeat(BAR - filled));
|
|
145
|
+
const mb = (received / 1048576).toFixed(1);
|
|
146
|
+
const tot = (total / 1048576).toFixed(1);
|
|
147
|
+
clear();
|
|
148
|
+
write(` ${bar} ${cyan((pct * 100).toFixed(0).padStart(3) + '%')} ${dim(`${mb}/${tot} MB`)}`);
|
|
149
|
+
} else {
|
|
150
|
+
const mb = (received / 1048576).toFixed(1);
|
|
151
|
+
clear();
|
|
152
|
+
write(` ${bcyan('⬇')} ${dim(`${mb} MB received...`)}`);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
res.on('end', () => { out.end(); resolve(); });
|
|
156
|
+
res.on('error', reject);
|
|
157
|
+
out.on('error', reject);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
write('\n');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// ── Extraction ────────────────────────────────────────────────────────────────
|
|
164
|
+
async function extractTarGz(tarPath, destDir, binName) {
|
|
63
165
|
await execAsync(`tar -xzf "${tarPath}" -C "${destDir}" --strip-components=1 --wildcards "*/${binName}" 2>/dev/null || tar -xzf "${tarPath}" -C "${destDir}" --strip-components=1`);
|
|
64
166
|
try { await execAsync(`rm "${tarPath}"`); } catch {}
|
|
65
167
|
}
|
|
66
168
|
|
|
67
|
-
async function extractZip(
|
|
68
|
-
const zipPath = join(destDir, '_rg.zip');
|
|
69
|
-
await pipeline(stream, createWriteStream(zipPath));
|
|
70
|
-
// Use PowerShell on Windows
|
|
169
|
+
async function extractZip(zipPath, destDir, binName) {
|
|
71
170
|
await execAsync(`powershell -Command "Expand-Archive -Path '${zipPath}' -DestinationPath '${destDir}' -Force"`);
|
|
72
|
-
// Find and move the exe to vendor root
|
|
73
171
|
try {
|
|
74
172
|
await execAsync(`powershell -Command "Get-ChildItem -Path '${destDir}' -Recurse -Filter '${binName}' | Select-Object -First 1 | Copy-Item -Destination '${join(destDir, binName)}'"`);
|
|
75
173
|
await execAsync(`powershell -Command "Remove-Item '${zipPath}' -Force"`);
|
|
76
174
|
} catch {}
|
|
77
175
|
}
|
|
78
176
|
|
|
177
|
+
// ── Main ──────────────────────────────────────────────────────────────────────
|
|
178
|
+
const RG_VERSION = '14.1.1';
|
|
179
|
+
const PLATFORMS = {
|
|
180
|
+
'linux-x64': { url: `https://github.com/BurntSushi/ripgrep/releases/download/${RG_VERSION}/ripgrep-${RG_VERSION}-x86_64-unknown-linux-musl.tar.gz`, bin: 'rg' },
|
|
181
|
+
'linux-arm64': { url: `https://github.com/BurntSushi/ripgrep/releases/download/${RG_VERSION}/ripgrep-${RG_VERSION}-aarch64-unknown-linux-gnu.tar.gz`, bin: 'rg' },
|
|
182
|
+
'darwin-x64': { url: `https://github.com/BurntSushi/ripgrep/releases/download/${RG_VERSION}/ripgrep-${RG_VERSION}-x86_64-apple-darwin.tar.gz`, bin: 'rg' },
|
|
183
|
+
'darwin-arm64': { url: `https://github.com/BurntSushi/ripgrep/releases/download/${RG_VERSION}/ripgrep-${RG_VERSION}-aarch64-apple-darwin.tar.gz`, bin: 'rg' },
|
|
184
|
+
'win32-x64': { url: `https://github.com/BurntSushi/ripgrep/releases/download/${RG_VERSION}/ripgrep-${RG_VERSION}-x86_64-pc-windows-msvc.zip`, bin: 'rg.exe' },
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const key = `${process.platform}-${process.arch}`;
|
|
188
|
+
const platform = PLATFORMS[key];
|
|
189
|
+
|
|
190
|
+
printBanner();
|
|
191
|
+
|
|
192
|
+
await sleep(300);
|
|
193
|
+
|
|
194
|
+
// Dramatic intro lines
|
|
195
|
+
const intros = [
|
|
196
|
+
' Initializing Tsunami Code...',
|
|
197
|
+
' Authenticating · Navy Seal Unit XI3...',
|
|
198
|
+
' Scanning target environment...',
|
|
199
|
+
];
|
|
200
|
+
for (const line of intros) {
|
|
201
|
+
write(dim(line));
|
|
202
|
+
await sleep(600);
|
|
203
|
+
clear();
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
print(green(' ✓ ') + white(`Platform detected: ${bold(key)}`));
|
|
207
|
+
await sleep(200);
|
|
208
|
+
|
|
209
|
+
if (!platform) {
|
|
210
|
+
print(yellow(' ⚠ No prebuilt search engine for this platform — falling back to system rg'));
|
|
211
|
+
print(dim(' Install manually: brew install ripgrep / apt install ripgrep'));
|
|
212
|
+
print('');
|
|
213
|
+
print(green(' 🌊 Tsunami Code is ready. Run: ') + cyan('tsunami'));
|
|
214
|
+
print('');
|
|
215
|
+
process.exit(0);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const binPath = join(VENDOR, platform.bin);
|
|
219
|
+
if (existsSync(binPath)) {
|
|
220
|
+
print(green(' ✓ ') + white('Search engine already armed'));
|
|
221
|
+
print('');
|
|
222
|
+
print(green(' 🌊 Tsunami Code is ready. Run: ') + cyan('tsunami'));
|
|
223
|
+
print('');
|
|
224
|
+
process.exit(0);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (!existsSync(VENDOR)) mkdirSync(VENDOR, { recursive: true });
|
|
228
|
+
|
|
229
|
+
// Wave animation before download
|
|
230
|
+
await playWave('Charging the wave...');
|
|
231
|
+
await sleep(200);
|
|
232
|
+
|
|
233
|
+
print(bold(cyan(' ⬇ Deploying search engine...')));
|
|
234
|
+
await sleep(300);
|
|
235
|
+
|
|
236
|
+
const archiveName = platform.url.endsWith('.zip') ? '_rg.zip' : '_rg.tar.gz';
|
|
237
|
+
const archivePath = join(VENDOR, archiveName);
|
|
238
|
+
|
|
79
239
|
try {
|
|
80
|
-
|
|
240
|
+
await downloadWithProgress(platform.url, archivePath);
|
|
241
|
+
|
|
242
|
+
const spinner = startSpinner('Arming systems...');
|
|
243
|
+
await sleep(300);
|
|
244
|
+
|
|
81
245
|
if (platform.url.endsWith('.zip')) {
|
|
82
|
-
await extractZip(
|
|
246
|
+
await extractZip(archivePath, VENDOR, platform.bin);
|
|
83
247
|
} else {
|
|
84
|
-
await extractTarGz(
|
|
248
|
+
await extractTarGz(archivePath, VENDOR, platform.bin);
|
|
85
249
|
}
|
|
86
250
|
|
|
251
|
+
spinner.stop('Search engine armed');
|
|
252
|
+
|
|
87
253
|
if (existsSync(binPath)) {
|
|
88
254
|
if (process.platform !== 'win32') chmodSync(binPath, 0o755);
|
|
89
|
-
console.log(`[tsunami-code] ripgrep installed at ${binPath}`);
|
|
90
255
|
} else {
|
|
91
|
-
|
|
256
|
+
print(yellow(' ⚠ Falling back to system rg'));
|
|
92
257
|
}
|
|
258
|
+
|
|
259
|
+
await sleep(200);
|
|
260
|
+
|
|
261
|
+
// Final wave
|
|
262
|
+
await playWave('Tsunami incoming...');
|
|
263
|
+
await sleep(100);
|
|
264
|
+
|
|
265
|
+
print('');
|
|
266
|
+
print(cyan(' ██████████████████████████████████████████████'));
|
|
267
|
+
print(cyan(' █ █'));
|
|
268
|
+
print(cyan(' █') + bold(white(' 🌊 TSUNAMI CODE IS READY 🌊 ')) + cyan('█'));
|
|
269
|
+
print(cyan(' █') + dim(' Navy Seal Unit XI3 · Deployed ') + cyan('█'));
|
|
270
|
+
print(cyan(' █ █'));
|
|
271
|
+
print(cyan(' ██████████████████████████████████████████████'));
|
|
272
|
+
print('');
|
|
273
|
+
print(dim(' Run ') + cyan('tsunami') + dim(' to launch your agent.'));
|
|
274
|
+
print('');
|
|
275
|
+
|
|
93
276
|
} catch (e) {
|
|
94
|
-
|
|
277
|
+
print('');
|
|
278
|
+
print(yellow(` ⚠ Could not deploy search engine: ${e.message}`));
|
|
279
|
+
print(dim(' Grep tool will fall back to system rg (brew install ripgrep / apt install ripgrep)'));
|
|
280
|
+
print('');
|
|
281
|
+
print(green(' 🌊 Tsunami Code is ready. Run: ') + cyan('tsunami'));
|
|
282
|
+
print('');
|
|
95
283
|
}
|
package/vendor/rg.exe
ADDED
|
Binary file
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015 Andrew Gallant
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|