@stage-labs/metro 0.1.0-beta.107 → 0.1.0-beta.108

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": "@stage-labs/metro",
3
- "version": "0.1.0-beta.107",
3
+ "version": "0.1.0-beta.108",
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.107",
3
+ "version": "0.1.0-beta.108",
4
4
  "description": "Metro for Claude Code, installed by the metro daemon on this machine: every connector the agent holds as its own MCP server relayed through the daemon, the orchestrator-only guard on the main thread, the standing rules loaded at each session start, and a refresh skill for when the daemon could not keep the server list current. No vendor credential ever sits in a config file.",
5
5
  "author": {
6
6
  "name": "Bonustrack",
@@ -1,4 +1,5 @@
1
1
  import { spawnSync } from 'node:child_process';
2
+ import { realpathSync } from 'node:fs';
2
3
  import { homedir } from 'node:os';
3
4
  import { join } from 'node:path';
4
5
  import { errMsg, log } from '@metro-labs/core/log';
@@ -7,6 +8,7 @@ import { readJson, writeJson } from '@metro-labs/core/secure-fs';
7
8
  import { METRO_VERSION } from '@metro-labs/core/version';
8
9
  import { agentsDir, listAgentFiles } from '../agents/files.js';
9
10
  import { notReady, readModelConfig } from '../gateway/model-config.js';
11
+ import { claudeDir, listClaudeProjects } from './files.js';
10
12
  import { claudeAccount, claudeInstalled } from './login.js';
11
13
  import { trustFolder } from './onboarding.js';
12
14
 
@@ -28,6 +30,7 @@ export interface SessionDeps {
28
30
  signedIn?: () => boolean;
29
31
  now?: () => number;
30
32
  version?: string;
33
+ continues?: (home: string) => boolean;
31
34
  }
32
35
 
33
36
  export interface SessionStatus {
@@ -77,10 +80,24 @@ function tmuxOk(tmux: string, args: string[]): boolean {
77
80
 
78
81
  export const sessionRunning = (tmux = 'tmux'): boolean => tmuxOk(tmux, ['has-session', '-t', SESSION_NAME]);
79
82
 
80
- function metroCommand(deps: SessionDeps): string[] {
81
- if (deps.metro !== undefined) return deps.metro;
83
+ function realDir(dir: string): string {
84
+ try {
85
+ return realpathSync(dir);
86
+ } catch {
87
+ return dir;
88
+ }
89
+ }
90
+
91
+ export function hasConversation(home: string, dir = claudeDir()): boolean {
92
+ const cwd = realDir(home);
93
+ return listClaudeProjects(dir).some((project) => project.sessions > 0 && project.cwd !== null && realDir(project.cwd) === cwd);
94
+ }
95
+
96
+ function metroCommand(deps: SessionDeps, home: string): string[] {
82
97
  const bin = process.env.METRO_CLI_BIN?.trim() ?? '';
83
- return bin === '' ? ['metro', 'claude'] : [process.execPath, bin, 'claude'];
98
+ const base = deps.metro ?? (bin === '' ? ['metro', 'claude'] : [process.execPath, bin, 'claude']);
99
+ const continues = (deps.continues ?? hasConversation)(home);
100
+ return continues ? [...base, '-c'] : base;
84
101
  }
85
102
 
86
103
  function credentialReady(deps: SessionDeps): string | null {
@@ -138,7 +155,7 @@ export function startSession(deps: SessionDeps = {}): SessionStatus {
138
155
  const home = deps.home ?? homedir();
139
156
  const now = (deps.now ?? Date.now)();
140
157
  const trusted = trustFolder(home);
141
- const [command = 'metro', ...args] = metroCommand(deps);
158
+ const [command = 'metro', ...args] = metroCommand(deps, home);
142
159
  const run = spawnSync(tmux, ['new-session', '-d', '-s', SESSION_NAME, '-c', home, '-x', '200', '-y', '50', command, ...args], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], cwd: home });
143
160
  recordStart(deps, tmux, now, run);
144
161
  if (memory.lastError === null) log.info({ home, trusted, command: [command, ...args].join(' ') }, 'claude-session: started Claude Code in tmux');
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "0.1.0-beta.107"
2
+ "version": "0.1.0-beta.108"
3
3
  }