@mitsein-ai/cli 0.1.4 → 0.1.6

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
@@ -8,7 +8,7 @@
8
8
  "ofetch": "^1.4.1",
9
9
  "undici": "^8.0.2"
10
10
  },
11
- "description": "Mitsein CLI \u2014 dev tooling, API helpers, and workflow automation",
11
+ "description": "Mitsein CLI dev tooling, API helpers, and workflow automation",
12
12
  "devDependencies": {
13
13
  "@types/bun": "latest",
14
14
  "typescript": "^5.3.3"
@@ -46,5 +46,5 @@
46
46
  "typecheck": "tsc --noEmit"
47
47
  },
48
48
  "type": "module",
49
- "version": "0.1.4"
49
+ "version": "0.1.6"
50
50
  }
@@ -80,9 +80,47 @@ export function registerAuth(program: Command): void {
80
80
  setJsonMode(Boolean(g.json));
81
81
  void opts.endpoint;
82
82
  const profile = opts.profile ?? 'default';
83
+
84
+ // Check env token first (MITSEIN_TOKEN or --token)
85
+ if (g.token) {
86
+ // Try to parse dev token format: #{"userid":"...", ...}
87
+ const raw = g.token.startsWith('#') ? g.token.slice(1) : g.token;
88
+ try {
89
+ const parsed = JSON.parse(raw) as Record<string, string>;
90
+ emit(
91
+ {
92
+ email: parsed.email ?? 'unknown',
93
+ user_id: parsed.userid ?? 'unknown',
94
+ username: parsed.username ?? 'unknown',
95
+ source: 'env/flag',
96
+ profile,
97
+ },
98
+ (payload) => {
99
+ const d = payload as Record<string, string>;
100
+ consola.success(`Logged in as ${d.email}`);
101
+ consola.log(` User ID: ${d.user_id}`);
102
+ consola.log(` Username: ${d.username}`);
103
+ consola.log(` Source: ${d.source}`);
104
+ }
105
+ );
106
+ return;
107
+ } catch {
108
+ // Not a parseable dev token, show raw info
109
+ emit(
110
+ { token: '***', source: 'env/flag', profile },
111
+ (payload) => {
112
+ const d = payload as Record<string, string>;
113
+ consola.success('Authenticated via token');
114
+ consola.log(` Source: ${d.source}`);
115
+ }
116
+ );
117
+ return;
118
+ }
119
+ }
120
+
83
121
  const oauthPath = getOauthPath(profile);
84
122
  if (!existsSync(oauthPath)) {
85
- throw new CliError('Not logged in. Run `mitsein auth login`.', ExitCode.USAGE_ERROR);
123
+ throw new CliError('Not logged in. Run `mitsein auth login` or set MITSEIN_TOKEN.', ExitCode.USAGE_ERROR);
86
124
  }
87
125
  const data = JSON.parse(readFileSync(oauthPath, 'utf8')) as Record<string, string>;
88
126
  emit(
@@ -91,6 +129,7 @@ export function registerAuth(program: Command): void {
91
129
  user_id: data.user_id ?? 'unknown',
92
130
  profile,
93
131
  endpoint: data.endpoint ?? '',
132
+ source: 'profile',
94
133
  },
95
134
  (payload) => {
96
135
  const d = payload as Record<string, string>;
@@ -73,7 +73,7 @@ export function registerThread(program: Command): void {
73
73
  timeoutSec: httpTimeoutSec(g),
74
74
  debug: g.debug,
75
75
  });
76
- const result = await client.post('/api/thread/create', { title: title ?? '' });
76
+ const result = await client.post('/api/threads', { title: title ?? '' });
77
77
  emit(result);
78
78
  })
79
79
  );
@@ -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 {