@mitsein-ai/cli 0.1.0 → 0.1.2

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
@@ -13,7 +13,7 @@
13
13
  "typescript": "^5.3.3"
14
14
  },
15
15
  "engines": {
16
- "bun": ">=1.0.0"
16
+ "node": ">=20.0.0"
17
17
  },
18
18
  "files": [
19
19
  "src",
@@ -39,11 +39,11 @@
39
39
  "url": "https://gitee.com/mitsein/mitsein.git"
40
40
  },
41
41
  "scripts": {
42
- "build": "bun build ./src/index.ts --outdir=dist --target=bun --minify",
42
+ "build": "bun build ./src/index.ts --outdir=dist --target=node --minify",
43
43
  "prepublishOnly": "bun run typecheck && bun test && bun run build",
44
44
  "test": "bun test",
45
45
  "typecheck": "tsc --noEmit"
46
46
  },
47
47
  "type": "module",
48
- "version": "0.1.0"
48
+ "version": "0.1.2"
49
49
  }
@@ -1,5 +1,4 @@
1
1
  import type { Command } from 'commander';
2
- import { ApiClient } from '../core/client.js';
3
2
  import { resolveCredentials } from '../core/credentials.js';
4
3
  import { getOpenapiCachePath } from '../core/config.js';
5
4
  import { handleErrors } from '../core/errors.js';
@@ -53,15 +52,14 @@ export function registerDev(parent: Command): void {
53
52
  .action(
54
53
  handleErrors(async function devHealthAction(this: Command) {
55
54
  const g = readGlobals(this);
56
- const client = ApiClient.fromOptions({
57
- token: g.token,
58
- endpoint: g.endpoint,
59
- profile: g.profile ?? 'e2e',
60
- real: g.real,
61
- timeoutSec: httpTimeoutSec(g),
62
- debug: g.debug,
55
+ const endpoint = g.endpoint ?? (await import('../core/config.js')).DEFAULT_ENDPOINT;
56
+ const { ofetch } = await import('ofetch');
57
+ const timeoutMs = httpTimeoutSec(g);
58
+ const result = await ofetch('/health', {
59
+ baseURL: endpoint.replace(/\/$/, ''),
60
+ timeout: timeoutMs ? timeoutMs * 1000 : undefined,
61
+ retry: 0,
63
62
  });
64
- const result = await client.get('/health');
65
63
  emit(result, healthHuman);
66
64
  })
67
65
  );
@@ -1,9 +1,11 @@
1
1
  import { readFileSync } from 'node:fs';
2
- import { join } from 'node:path';
2
+ import { dirname, join } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
3
4
  import { emit } from '../core/output.js';
4
5
 
5
6
  export function getPackageVersion(): string {
6
- const pkgPath = join(import.meta.dir, '..', '..', 'package.json');
7
+ const __dirname = dirname(fileURLToPath(import.meta.url));
8
+ const pkgPath = join(__dirname, '..', '..', 'package.json');
7
9
  try {
8
10
  const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as { version?: string };
9
11
  return pkg.version ?? '0.1.0-dev';
@@ -14,7 +14,7 @@ export interface ResolveCredentialsOptions {
14
14
  profile?: string | undefined;
15
15
  real?: boolean | undefined;
16
16
  projectRoot?: string | undefined;
17
- /** Injected for tests (Bun.spawnSync). */
17
+ /** Injected for tests. */
18
18
  spawnDevToken?: typeof runDevTokenScript;
19
19
  }
20
20
 
@@ -56,17 +56,21 @@ function findDevTokenScript(projectRoot: string | undefined): string | null {
56
56
  }
57
57
 
58
58
  function runDevTokenScript(scriptPath: string, real: boolean): { ok: boolean; stdout: string } {
59
+ const { execFileSync } = require('node:child_process') as typeof import('node:child_process');
59
60
  const args = [scriptPath, '--raw'];
60
61
  if (real) {
61
62
  args.push('--real');
62
63
  }
63
- const proc = Bun.spawnSync(['bash', ...args], {
64
- timeout: 10_000,
65
- stdout: 'pipe',
66
- stderr: 'pipe',
67
- });
68
- const stdout = proc.stdout.toString().trim();
69
- return { ok: proc.success && stdout.length > 0, stdout };
64
+ try {
65
+ const stdout = execFileSync('bash', args, {
66
+ timeout: 10_000,
67
+ encoding: 'utf8',
68
+ stdio: ['pipe', 'pipe', 'pipe'],
69
+ }).trim();
70
+ return { ok: stdout.length > 0, stdout };
71
+ } catch {
72
+ return { ok: false, stdout: '' };
73
+ }
70
74
  }
71
75
 
72
76
  function loadExplicit(token: string | undefined, endpoint: string | undefined): Credentials | null {
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env bun
1
+ #!/usr/bin/env node
2
2
  import { Command } from 'commander';
3
3
  import consola from 'consola';
4
4
  import { registerAgent } from './commands/agent.js';