@stage-labs/metro 0.1.0-beta.100 → 0.1.0-beta.101

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/dist/claude.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { spawn, spawnSync } from 'node:child_process';
2
+ import { markOnboardingDone } from './onboarding.js';
2
3
  import { settingsConflicts, settingsFiles } from './claude-settings.js';
3
4
  import { localAgents, pickLocalAgent } from './local.js';
4
5
  import { PROVIDER_FLAGS } from './provider-flags.js';
@@ -125,5 +126,7 @@ export async function launchClaude(extra) {
125
126
  const env = credentialEnv(routed, decision.key, claudeSignedIn());
126
127
  if (env !== routed)
127
128
  process.stderr.write("metro claude: Claude Code has no login of its own here, so metro's key stands in as its credential; the Model page must route to Bedrock, OpenRouter or Codex\n");
129
+ if (markOnboardingDone() === 'marked')
130
+ process.stderr.write("metro claude: skipped Claude Code's first-run setup, since it already has a credential here\n");
128
131
  return runClaude(claudeArgs(extra), env);
129
132
  }
@@ -0,0 +1,29 @@
1
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
2
+ import { homedir } from 'node:os';
3
+ import { join } from 'node:path';
4
+ const FILE = '.claude.json';
5
+ const FLAG = 'hasCompletedOnboarding';
6
+ const given = (value) => value !== undefined && value.trim() !== '' ? value.trim() : undefined;
7
+ export function claudeConfigPath(env = process.env) {
8
+ return join(given(env.CLAUDE_CONFIG_DIR) ?? given(env.HOME) ?? homedir(), FILE);
9
+ }
10
+ function readConfig(path) {
11
+ if (!existsSync(path))
12
+ return {};
13
+ try {
14
+ const parsed = JSON.parse(readFileSync(path, 'utf8'));
15
+ return typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed) ? parsed : null;
16
+ }
17
+ catch {
18
+ return null;
19
+ }
20
+ }
21
+ export function markOnboardingDone(path = claudeConfigPath()) {
22
+ const config = readConfig(path);
23
+ if (config === null)
24
+ return 'unreadable';
25
+ if (config[FLAG] === true)
26
+ return 'already';
27
+ writeFileSync(path, `${JSON.stringify({ ...config, [FLAG]: true }, null, 2)}\n`, { mode: 0o600 });
28
+ return 'marked';
29
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stage-labs/metro",
3
- "version": "0.1.0-beta.100",
3
+ "version": "0.1.0-beta.101",
4
4
  "description": "The metro command line. Sign in once per machine, then hand your MCP connector list to Claude Code without the credentials touching disk, argv or shell history.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metro",
3
- "version": "0.1.0-beta.100",
3
+ "version": "0.1.0-beta.101",
4
4
  "description": "Metro connectors for Claude Code. Runs beside the metro daemon on this machine: each connector the agent holds is one MCP server relayed through the daemon, the daemon keeps that list current on its own, and /reload-plugins picks up a new one without leaving your session. No vendor credential ever sits in a config file.",
5
5
  "author": {
6
6
  "name": "Bonustrack",
@@ -1,5 +1,6 @@
1
1
  import { randomBytes } from 'node:crypto';
2
2
  import { spawnSync } from 'node:child_process';
3
+ import { markOnboardingDone } from './onboarding.js';
3
4
  import { ApiError } from '@metro-labs/http/api-error';
4
5
  import { isRecord } from '@metro-labs/core/is-record';
5
6
  import { errMsg, log } from '@metro-labs/core/log';
@@ -125,7 +126,8 @@ export function startClaudeLogin(deps: LoginDeps = {}, now = Date.now()): LoginV
125
126
  session.state = code === 0 ? 'done' : 'failed';
126
127
  if (code !== 0) session.error = `the login ended with status ${String(code)}`;
127
128
  terminal.close();
128
- log.info({ state: session.state }, 'claude-login: the official login finished');
129
+ const onboarding = code === 0 ? markOnboardingDone() : 'skipped';
130
+ log.info({ state: session.state, onboarding }, 'claude-login: the official login finished');
129
131
  })
130
132
  .catch((err: unknown) => {
131
133
  session.state = 'failed';
@@ -0,0 +1,34 @@
1
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
2
+ import { homedir } from 'node:os';
3
+ import { join } from 'node:path';
4
+ import { isRecord } from '@metro-labs/core/is-record';
5
+
6
+ const FILE = '.claude.json';
7
+ const FLAG = 'hasCompletedOnboarding';
8
+
9
+ export type OnboardingMark = 'marked' | 'already' | 'unreadable';
10
+
11
+ const given = (value: string | undefined): string | undefined =>
12
+ value !== undefined && value.trim() !== '' ? value.trim() : undefined;
13
+
14
+ export function claudeConfigPath(env: NodeJS.ProcessEnv = process.env): string {
15
+ return join(given(env.CLAUDE_CONFIG_DIR) ?? given(env.HOME) ?? homedir(), FILE);
16
+ }
17
+
18
+ function readConfig(path: string): Record<string, unknown> | null {
19
+ if (!existsSync(path)) return {};
20
+ try {
21
+ const parsed: unknown = JSON.parse(readFileSync(path, 'utf8'));
22
+ return isRecord(parsed) ? parsed : null;
23
+ } catch {
24
+ return null;
25
+ }
26
+ }
27
+
28
+ export function markOnboardingDone(path = claudeConfigPath()): OnboardingMark {
29
+ const config = readConfig(path);
30
+ if (config === null) return 'unreadable';
31
+ if (config[FLAG] === true) return 'already';
32
+ writeFileSync(path, `${JSON.stringify({ ...config, [FLAG]: true }, null, 2)}\n`, { mode: 0o600 });
33
+ return 'marked';
34
+ }
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "0.1.0-beta.100"
2
+ "version": "0.1.0-beta.101"
3
3
  }