trident-tui 0.9.2 → 0.9.4

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/bin/cli.js CHANGED
@@ -21,7 +21,7 @@ const fs = require('fs');
21
21
  const os = require('os');
22
22
  const path = require('path');
23
23
 
24
- const SANDBOX_IMAGE = 'ghcr.io/usestrix/strix-sandbox:0.1.13';
24
+ const SANDBOX_IMAGE = 'ghcr.io/esprit-labs/trident-sandbox:0.1.13';
25
25
  const isWin = process.platform === 'win32';
26
26
  const HOME = os.homedir();
27
27
  const LOCAL_BIN = path.join(HOME, '.local', 'bin');
@@ -125,34 +125,55 @@ function main() {
125
125
  process.exit(1);
126
126
  }
127
127
 
128
- // Install the global `trident` (and `strix`) command so it's available
129
- // directly in future terminals — not only via `npx`. Only (re)install when
130
- // the installed version differs from the bundled wheel, to stay fast.
131
- const wheelVer = (path.basename(wheel).match(/strix_agent-(\d+\.\d+\.\d+)/) || [])[1] || null;
132
- let installedVer = null;
133
- const vcheck = spawnSync('trident', ['--version'], { encoding: 'utf8' });
134
- if (vcheck.status === 0 && vcheck.stdout) {
135
- installedVer = (vcheck.stdout.match(/(\d+\.\d+\.\d+)/) || [])[1] || null;
128
+ // Version baked into the bundled wheel filename (matches both the legacy
129
+ // `strix_agent-` and the new `trident_agent-` naming).
130
+ const wheelVer =
131
+ (path.basename(wheel).match(/(?:strix|trident)_agent-(\d+\.\d+\.\d+)/) || [])[1] || null;
132
+
133
+ // Return the working global `trident` version, or null if it is not installed
134
+ // OR is installed-but-broken (a half-removed previous install throws
135
+ // ModuleNotFoundError, which makes `--version` exit non-zero).
136
+ function workingTridentVersion() {
137
+ const v = spawnSync('trident', ['--version'], { encoding: 'utf8' });
138
+ if (v.status === 0 && v.stdout) {
139
+ return (v.stdout.match(/(\d+\.\d+\.\d+)/) || [])[1] || null;
140
+ }
141
+ return null;
136
142
  }
137
- if (!installedVer || installedVer !== wheelVer) {
143
+
144
+ // Install the global `trident` command so it's available directly in future
145
+ // terminals — not only via `npx`. Only (re)install when the working installed
146
+ // version differs from the bundled wheel. Best-effort: failure here is NOT
147
+ // fatal because the bundled-wheel fallback below always works.
148
+ if (workingTridentVersion() !== wheelVer) {
138
149
  log('Installing the `trident` command (one-time)…');
150
+ // Clear any previous (possibly broken or locked) install first, so a Windows
151
+ // file lock on the old Scripts dir can't fail the --force reinstall. Both
152
+ // the legacy `strix-agent` and the current `trident-agent` tool names are
153
+ // cleared. Errors are ignored — the wheel fallback covers us regardless.
154
+ spawnSync(uv, ['tool', 'uninstall', 'trident-agent'], { stdio: 'ignore' });
155
+ spawnSync(uv, ['tool', 'uninstall', 'strix-agent'], { stdio: 'ignore' });
139
156
  const inst = spawnSync(uv, ['tool', 'install', '--force', wheel], { stdio: 'inherit' });
140
157
  if (inst.status === 0) {
141
158
  spawnSync(uv, ['tool', 'update-shell'], { stdio: 'ignore' });
142
- log('[ok] `trident` and `strix` installed — open a NEW terminal to run `trident` directly.');
159
+ log('[ok] `trident` installed — open a NEW terminal to run `trident` directly.');
143
160
  } else {
144
- log('[!] Could not install the global `trident` command; continuing via npx for now.');
161
+ log('[!] Could not install the global `trident` command; running via npx for now.');
145
162
  }
146
163
  }
147
164
 
148
165
  prePullImage();
149
166
 
150
- // Make the freshly-installed command reachable in THIS process, then run it.
151
- // Falls back to an ephemeral run if it isn't on PATH yet.
167
+ // Make a freshly-installed command reachable in THIS process.
152
168
  process.env.PATH = LOCAL_BIN + path.delimiter + (process.env.PATH || '');
153
169
  const args = process.argv.slice(2);
170
+
171
+ // Run the global `trident` ONLY if it works AND matches the bundled version.
172
+ // A stale or broken global (e.g. a half-removed previous install that raises
173
+ // ModuleNotFoundError) must never be run — fall back to the bundled wheel,
174
+ // which runs in a clean ephemeral environment and cannot be in a broken state.
154
175
  let r;
155
- if (commandPath('trident')) {
176
+ if (commandPath('trident') && workingTridentVersion() === wheelVer) {
156
177
  r = spawnSync('trident', args, { stdio: 'inherit' });
157
178
  } else {
158
179
  r = spawnSync(uv, ['tool', 'run', '--from', wheel, 'trident', ...args], { stdio: 'inherit' });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trident-tui",
3
- "version": "0.9.2",
3
+ "version": "0.9.4",
4
4
  "description": "Trident — AI penetration-testing agent. Run it with `npx trident-tui`; it bootstraps everything and prompts for your API key.",
5
5
  "bin": {
6
6
  "trident-tui": "bin/cli.js"