@mitsein-ai/cli 0.1.3 → 0.1.5

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
@@ -46,5 +46,5 @@
46
46
  "typecheck": "tsc --noEmit"
47
47
  },
48
48
  "type": "module",
49
- "version": "0.1.3"
49
+ "version": "0.1.5"
50
50
  }
@@ -12,7 +12,11 @@ export interface MitseinGlobalOpts {
12
12
  }
13
13
 
14
14
  export function readGlobals(cmd: Command): MitseinGlobalOpts {
15
- return cmd.optsWithGlobals() as MitseinGlobalOpts;
15
+ const raw = cmd.optsWithGlobals() as MitseinGlobalOpts;
16
+ // Commander doesn't support envvar fallback — apply manually
17
+ raw.endpoint = raw.endpoint ?? process.env.MITSEIN_API_URL;
18
+ raw.token = raw.token ?? process.env.MITSEIN_TOKEN;
19
+ return raw;
16
20
  }
17
21
 
18
22
  /** HTTP client timeout from `--timeout` (0 = no limit). */
@@ -4,14 +4,24 @@ import { fileURLToPath } from 'node:url';
4
4
  import { emit } from '../core/output.js';
5
5
 
6
6
  export function getPackageVersion(): string {
7
+ // Try reading package.json at multiple candidate paths
8
+ // (works from both source and compiled locations)
7
9
  const __dirname = dirname(fileURLToPath(import.meta.url));
8
- const pkgPath = join(__dirname, '..', '..', 'package.json');
9
- try {
10
- const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as { version?: string };
11
- return pkg.version ?? '0.1.0-dev';
12
- } catch {
13
- return '0.1.0-dev';
10
+ const candidates = [
11
+ join(__dirname, '..', 'package.json'), // dist/index.js → package.json
12
+ join(__dirname, '..', '..', 'package.json'), // src/commands/version.ts package.json
13
+ ];
14
+ for (const pkgPath of candidates) {
15
+ try {
16
+ const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as { version?: string; name?: string };
17
+ if (pkg.name === '@mitsein-ai/cli' && pkg.version) {
18
+ return pkg.version;
19
+ }
20
+ } catch {
21
+ // try next
22
+ }
14
23
  }
24
+ return '0.1.0-dev';
15
25
  }
16
26
 
17
27
  export function runVersion(): void {
@@ -62,7 +62,10 @@ export function handleErrors<T extends unknown[]>(
62
62
  if (e instanceof CliError) {
63
63
  consola.error(`Error: ${e.message}`);
64
64
  if (e.detail != null && e.detail !== '') {
65
- consola.error(String(e.detail));
65
+ const detailStr = typeof e.detail === 'object'
66
+ ? JSON.stringify(e.detail, null, 2)
67
+ : String(e.detail);
68
+ consola.error(detailStr);
66
69
  }
67
70
  process.exit(e.code);
68
71
  }