tsunami-code 2.5.2 → 2.5.3

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/index.js CHANGED
@@ -8,7 +8,7 @@ import { agentLoop } from './lib/loop.js';
8
8
  import { buildSystemPrompt } from './lib/prompt.js';
9
9
  import { runPreflight } from './lib/preflight.js';
10
10
 
11
- const VERSION = '2.5.2';
11
+ const VERSION = '2.5.3';
12
12
  const CONFIG_DIR = join(os.homedir(), '.tsunami-code');
13
13
  const CONFIG_FILE = join(CONFIG_DIR, 'config.json');
14
14
  const DEFAULT_SERVER = 'https://radiometric-reita-amuck.ngrok-free.dev';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsunami-code",
3
- "version": "2.5.2",
3
+ "version": "2.5.3",
4
4
  "description": "Tsunami Code CLI — AI coding agent by Keystone World Management Navy Seal Unit XI3",
5
5
  "type": "module",
6
6
  "bin": {
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
- const RG_VERSION = '14.1.1';
18
- const PLATFORMS = {
19
- 'linux-x64': { url: `https://github.com/BurntSushi/ripgrep/releases/download/${RG_VERSION}/ripgrep-${RG_VERSION}-x86_64-unknown-linux-musl.tar.gz`, bin: 'rg' },
20
- 'linux-arm64': { url: `https://github.com/BurntSushi/ripgrep/releases/download/${RG_VERSION}/ripgrep-${RG_VERSION}-aarch64-unknown-linux-gnu.tar.gz`, bin: 'rg' },
21
- 'darwin-x64': { url: `https://github.com/BurntSushi/ripgrep/releases/download/${RG_VERSION}/ripgrep-${RG_VERSION}-x86_64-apple-darwin.tar.gz`, bin: 'rg' },
22
- 'darwin-arm64':{ url: `https://github.com/BurntSushi/ripgrep/releases/download/${RG_VERSION}/ripgrep-${RG_VERSION}-aarch64-apple-darwin.tar.gz`, bin: 'rg' },
23
- 'win32-x64': { url: `https://github.com/BurntSushi/ripgrep/releases/download/${RG_VERSION}/ripgrep-${RG_VERSION}-x86_64-pc-windows-msvc.zip`, bin: 'rg.exe' },
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 key = `${process.platform}-${process.arch}`;
27
- const platform = PLATFORMS[key];
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
- if (!platform) {
30
- console.warn(`[tsunami-code] No prebuilt ripgrep for ${key} — Grep tool will fall back to system rg`);
31
- process.exit(0);
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
- const binPath = join(VENDOR, platform.bin);
35
- if (existsSync(binPath)) {
36
- process.exit(0); // already installed
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
- if (!existsSync(VENDOR)) mkdirSync(VENDOR, { recursive: true });
102
+ // ── Spinner ───────────────────────────────────────────────────────────────────
103
+ const SPIN = ['⠋','⠙','⠹','⠸','⠼','⠴','⠦','⠧','⠇','⠏'];
40
104
 
41
- console.log(`[tsunami-code] Downloading ripgrep for ${key}...`);
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': 'keystonewm-setup' } }, (res) => {
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 extractTarGz(stream, destDir, binName) {
60
- // Extract using system tar (available on all platforms with Node 18+)
61
- const tarPath = join(destDir, '_rg.tar.gz');
62
- await pipeline(stream, createWriteStream(tarPath));
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(stream, destDir, binName) {
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
- const res = await httpsGet(platform.url);
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(res, VENDOR, platform.bin);
246
+ await extractZip(archivePath, VENDOR, platform.bin);
83
247
  } else {
84
- await extractTarGz(res, VENDOR, platform.bin);
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
- console.warn(`[tsunami-code] ripgrep extraction completed but binary not found at expected path — Grep tool will fall back to system rg`);
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
- console.warn(`[tsunami-code] Could not install ripgrep: ${e.message} — Grep tool will fall back to system rg`);
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,3 @@
1
+ This project is dual-licensed under the Unlicense and MIT licenses.
2
+
3
+ You may use this code under the terms of either license.
@@ -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.