@drsamonline/cli 0.12.5 → 0.12.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drsamonline/cli",
3
- "version": "0.12.5",
3
+ "version": "0.12.7",
4
4
  "description": "The `sui` command line.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -27,15 +27,15 @@
27
27
  "registry": "https://registry.npmjs.org/"
28
28
  },
29
29
  "dependencies": {
30
- "@drsamonline/catalog": "^0.12.5",
31
- "@drsamonline/compression": "^0.12.5",
32
- "@drsamonline/core": "^0.12.5",
33
- "@drsamonline/gateway": "^0.12.5",
34
- "@drsamonline/kits": "^0.12.5",
35
- "@drsamonline/mcp": "^0.12.5",
36
- "@drsamonline/prober": "^0.12.5",
37
- "@drsamonline/redteam": "^0.12.5",
38
- "@drsamonline/router": "^0.12.5",
39
- "@drsamonline/vault": "^0.12.5"
30
+ "@drsamonline/catalog": "^0.12.0",
31
+ "@drsamonline/compression": "^0.12.0",
32
+ "@drsamonline/core": "^0.12.0",
33
+ "@drsamonline/gateway": "^0.12.0",
34
+ "@drsamonline/kits": "^0.12.0",
35
+ "@drsamonline/mcp": "^0.12.0",
36
+ "@drsamonline/prober": "^0.12.0",
37
+ "@drsamonline/redteam": "^0.12.0",
38
+ "@drsamonline/router": "^0.12.0",
39
+ "@drsamonline/vault": "^0.12.0"
40
40
  }
41
41
  }
package/src/cli.js CHANGED
@@ -17,7 +17,7 @@ import { stdin, stdout } from 'node:process';
17
17
  import { dirname, join, resolve } from 'node:path';
18
18
  import { fileURLToPath } from 'node:url';
19
19
  import { createGateway, loadEnvFile } from '@drsamonline/gateway';
20
- import { auditConfig, defaultConfigPath, hashApiKey, normalizeConfig, providerHasCredentials, sanitizeConfig, suiHome, INVARIANTS } from '@drsamonline/core';
20
+ import { auditConfig, defaultConfigPath, hashApiKey, normalizeConfig, providerHasCredentials, runAs, sanitizeConfig, suiHome, INVARIANTS } from '@drsamonline/core';
21
21
  import { runInit } from './onboarding.js';
22
22
  import { detectTools, writeToolConfig } from './tools.js';
23
23
  import { applyImport, diffImport, readMigrationSource, smokeTest } from './migrate.js';
@@ -34,19 +34,9 @@ const HERE_DIR = dirname(fileURLToPath(import.meta.url));
34
34
  * anyway sends people to a command that fails — and the failure looks like a
35
35
  * broken install rather than an unpublished package.
36
36
  */
37
- const RUN_AS = (() => {
38
- const invoked = String(process.argv[1] ?? '');
39
- // A published install has the package on disk under node_modules, so the
40
- // reliable command is the package name — not `sui`, which is a bin name and not
41
- // something `npx` can resolve. Printing `npx sui` sent people to a command that
42
- // cannot work, and it did so again the moment the package was renamed.
43
- if (/node_modules/.test(invoked)) {
44
- const pkg = JSON.parse(readFileSync(join(HERE_DIR, '..', 'package.json'), 'utf8'));
45
- return `npx ${pkg.name}`;
46
- }
47
- if (!/apps[\\/]cli[\\/]bin/.test(invoked)) return 'sui';
48
- return process.platform === 'win32' ? '.\\sui.cmd' : './sui';
49
- })();
37
+ // One definition, in core, so the CLI and the errors it throws cannot disagree
38
+ // about what to type next.
39
+ const RUN_AS = runAs();
50
40
 
51
41
  const VERSION = (() => {
52
42
  // The CLI's own manifest, not the repository root: from a registry install there
@@ -254,7 +254,7 @@ async function readSecret(question) {
254
254
 
255
255
  export function cmdConfig(flags, args) {
256
256
  const path = flags.config ?? defaultConfigPath();
257
- if (!path) throw new ConfigError('No config found. Run `npx sui init` first.');
257
+ if (!path) throw new ConfigError(`No config found. Run \`${runAs()} init\` first.`);
258
258
  const raw = JSON.parse(readFileSync(path, 'utf8'));
259
259
  const sub = args[0] ?? 'show';
260
260
  const dotted = args[1];
package/src/onboarding.js CHANGED
@@ -10,7 +10,7 @@ import { copyFileSync, existsSync, readFileSync, writeFileSync } from 'node:fs';
10
10
  import { join, dirname } from 'node:path';
11
11
  import { fileURLToPath } from 'node:url';
12
12
  import { createGateway, loadEnvFile } from '@drsamonline/gateway';
13
- import { providerHasCredentials, suiHome } from '@drsamonline/core';
13
+ import { providerHasCredentials, suiHome, runAs } from '@drsamonline/core';
14
14
  import { detectTools, writeToolConfig } from './tools.js';
15
15
 
16
16
  const HERE = dirname(fileURLToPath(import.meta.url));
@@ -150,7 +150,7 @@ export async function runInit(opts = {}) {
150
150
  roundTrip = { ok: false, combo, error: /** @type {any} */ (err).message, ms: Date.now() - started };
151
151
  out(` failed: ${roundTrip.error}`);
152
152
  out('');
153
- out('Nothing was marked ready. Fix the problem above and run `npx sui init` again.');
153
+ out('Nothing was marked ready. Fix the problem above and run `${runAs()} init` again.');
154
154
  return { ok: false, configPath, config, roundTrip, tools };
155
155
  }
156
156
 
@@ -184,7 +184,7 @@ export async function runInit(opts = {}) {
184
184
  }
185
185
  } else if (detected.length) {
186
186
  out('');
187
- out('Next: `npx sui tools` to point one of these at the gateway.');
187
+ out('Next: `${runAs()} tools` to point one of these at the gateway.');
188
188
  }
189
189
 
190
190
  return { ok: true, configPath, config, roundTrip, endpoint, tools, toolResult, demo };