vit 0.1.0 → 0.2.0

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/src/cmd/follow.js CHANGED
@@ -1,10 +1,11 @@
1
- // SPDX-License-Identifier: AGPL-3.0-only
1
+ // SPDX-License-Identifier: MIT
2
2
  // Copyright (c) 2026 sol pbc
3
3
 
4
- import { requireDid } from '../lib/config.js';
4
+ import { requireDid, loadConfig } from '../lib/config.js';
5
5
  import { restoreAgent } from '../lib/oauth.js';
6
6
  import { readFollowing, writeFollowing } from '../lib/vit-dir.js';
7
7
  import { mark } from '../lib/brand.js';
8
+ import { jsonOk, jsonError } from '../lib/json-output.js';
8
9
 
9
10
  export default function register(program) {
10
11
  program
@@ -12,35 +13,54 @@ export default function register(program) {
12
13
  .argument('<handle>', 'Handle to follow (e.g. alice.bsky.social)')
13
14
  .description('Add an account to this project\'s following list')
14
15
  .option('-v, --verbose', 'Show step-by-step details')
16
+ .option('--json', 'Output as JSON')
15
17
  .option('--did <did>', 'DID to use for handle resolution')
16
18
  .action(async (handle, opts) => {
17
19
  try {
18
20
  const { verbose } = opts;
21
+ const vlog = opts.json ? (...a) => console.error(...a) : console.log;
19
22
  handle = handle.replace(/^@/, '');
20
23
 
24
+ if (opts.json && !(opts.did || loadConfig().did)) {
25
+ jsonError('no DID configured', "run 'vit login <handle>' first");
26
+ return;
27
+ }
21
28
  const did = requireDid(opts);
22
29
  if (!did) return;
23
- if (verbose) console.log(`[verbose] DID: ${did}`);
30
+ if (verbose) vlog(`[verbose] DID: ${did}`);
24
31
 
25
32
  const list = readFollowing();
26
33
  if (list.some(e => e.handle === handle)) {
34
+ if (opts.json) {
35
+ jsonError(`already following ${handle}`);
36
+ return;
37
+ }
27
38
  console.error(`already following ${handle}`);
28
39
  process.exitCode = 1;
29
40
  return;
30
41
  }
31
42
 
32
43
  const { agent } = await restoreAgent(did);
33
- if (verbose) console.log('[verbose] session restored');
44
+ if (verbose) vlog('[verbose] session restored');
34
45
 
35
46
  const resolved = await agent.resolveHandle({ handle });
36
47
  const targetDid = resolved.data.did;
37
- if (verbose) console.log(`[verbose] resolved ${handle} to ${targetDid}`);
48
+ if (verbose) vlog(`[verbose] resolved ${handle} to ${targetDid}`);
38
49
 
39
50
  list.push({ handle, did: targetDid, followedAt: new Date().toISOString() });
40
51
  writeFollowing(list);
52
+ if (opts.json) {
53
+ jsonOk({ handle, did: targetDid, followedAt: list[list.length - 1].followedAt });
54
+ return;
55
+ }
41
56
  console.log(`${mark} following ${handle} (${targetDid})`);
42
57
  } catch (err) {
43
- console.error(err instanceof Error ? err.message : String(err));
58
+ const msg = err instanceof Error ? err.message : String(err);
59
+ if (opts.json) {
60
+ jsonError(msg);
61
+ return;
62
+ }
63
+ console.error(msg);
44
64
  process.exitCode = 1;
45
65
  }
46
66
  });
@@ -50,24 +70,39 @@ export default function register(program) {
50
70
  .argument('<handle>', 'Handle to unfollow (e.g. alice.bsky.social)')
51
71
  .description('Remove an account from this project\'s following list')
52
72
  .option('-v, --verbose', 'Show step-by-step details')
73
+ .option('--json', 'Output as JSON')
53
74
  .action(async (handle, opts) => {
54
75
  try {
55
76
  const { verbose } = opts;
77
+ const vlog = opts.json ? (...a) => console.error(...a) : console.log;
56
78
  handle = handle.replace(/^@/, '');
57
79
 
58
80
  const list = readFollowing();
59
81
  const filtered = list.filter(e => e.handle !== handle);
60
82
  if (filtered.length === list.length) {
83
+ if (opts.json) {
84
+ jsonError(`not following ${handle}`);
85
+ return;
86
+ }
61
87
  console.error(`not following ${handle}`);
62
88
  process.exitCode = 1;
63
89
  return;
64
90
  }
65
91
 
66
92
  writeFollowing(filtered);
67
- if (verbose) console.log(`[verbose] removed ${handle} from following list`);
93
+ if (verbose) vlog(`[verbose] removed ${handle} from following list`);
94
+ if (opts.json) {
95
+ jsonOk({ handle });
96
+ return;
97
+ }
68
98
  console.log(`${mark} unfollowed ${handle}`);
69
99
  } catch (err) {
70
- console.error(err instanceof Error ? err.message : String(err));
100
+ const msg = err instanceof Error ? err.message : String(err);
101
+ if (opts.json) {
102
+ jsonError(msg);
103
+ return;
104
+ }
105
+ console.error(msg);
71
106
  process.exitCode = 1;
72
107
  }
73
108
  });
@@ -76,18 +111,35 @@ export default function register(program) {
76
111
  .command('following')
77
112
  .description('List accounts in this project\'s following list')
78
113
  .option('-v, --verbose', 'Show step-by-step details')
79
- .action(async (_opts) => {
114
+ .option('--json', 'Output as JSON')
115
+ .action(async (opts) => {
80
116
  try {
81
117
  const list = readFollowing();
82
118
  if (list.length === 0) {
83
- console.log('no followings');
119
+ if (opts.json) {
120
+ jsonOk({ following: [], hint: "run 'vit follow <handle>' to add accounts" });
121
+ return;
122
+ }
123
+ console.log('not following anyone yet.');
124
+ console.log('');
125
+ console.log("run 'vit follow <handle>' to start seeing what people are shipping.");
126
+ console.log("try 'vit scan' to discover active publishers on the network.");
127
+ return;
128
+ }
129
+ if (opts.json) {
130
+ jsonOk({ following: list });
84
131
  return;
85
132
  }
86
133
  for (const e of list) {
87
134
  console.log(`${e.handle} (${e.did})`);
88
135
  }
89
136
  } catch (err) {
90
- console.error(err instanceof Error ? err.message : String(err));
137
+ const msg = err instanceof Error ? err.message : String(err);
138
+ if (opts.json) {
139
+ jsonError(msg);
140
+ return;
141
+ }
142
+ console.error(msg);
91
143
  process.exitCode = 1;
92
144
  }
93
145
  });
@@ -0,0 +1,83 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2026 sol pbc
3
+
4
+ import { execFileSync } from 'node:child_process';
5
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
6
+ import { join, resolve } from 'node:path';
7
+ import { which } from '../lib/compat.js';
8
+ import { mark, name } from '../lib/brand.js';
9
+
10
+ export default function register(program) {
11
+ program
12
+ .command('hack')
13
+ .description('Fork and install vit from source')
14
+ .option('--from <repo>', 'Clone an existing fork instead of creating a new one (e.g. user/vit)')
15
+ .action(async (opts) => {
16
+ try {
17
+ const ghPath = which('gh');
18
+ if (!opts.from && !ghPath) {
19
+ console.error(`${name} hack requires gh (GitHub CLI). Install it from https://cli.github.com`);
20
+ process.exitCode = 1;
21
+ return;
22
+ }
23
+
24
+ const gitPath = which('git');
25
+ if (opts.from && !gitPath) {
26
+ console.error('missing required tool: git');
27
+ process.exitCode = 1;
28
+ return;
29
+ }
30
+
31
+ const repo = opts.from || 'solpbc/vit';
32
+ const dirName = repo.split('/').pop();
33
+ const dirPath = resolve(process.cwd(), dirName);
34
+ const cloned = !existsSync(dirPath);
35
+
36
+ if (!cloned) {
37
+ console.log(`${mark} ${dirName}/ already exists, skipping clone`);
38
+ } else if (opts.from) {
39
+ execFileSync('git', ['clone', 'https://github.com/' + opts.from + '.git', dirName], { stdio: 'inherit' });
40
+ } else {
41
+ execFileSync('gh', ['repo', 'fork', 'solpbc/vit', '--clone'], { stdio: 'inherit' });
42
+ }
43
+
44
+ process.chdir(dirName);
45
+
46
+ const bunPath = which('bun');
47
+ if (!bunPath) {
48
+ console.error('missing required tool: bun');
49
+ process.exitCode = 1;
50
+ return;
51
+ }
52
+
53
+ execFileSync('bun', ['install'], { stdio: 'inherit' });
54
+ execFileSync('node', [join(process.cwd(), 'bin', 'vit.js'), 'link'], { stdio: 'inherit' });
55
+
56
+ if (!opts.from) {
57
+ const remote = execFileSync(
58
+ 'gh',
59
+ ['repo', 'view', '--json', 'nameWithOwner', '-q', '.nameWithOwner'],
60
+ { encoding: 'utf-8' }
61
+ ).trim();
62
+ const hackPath = join(process.cwd(), 'hack');
63
+ if (existsSync(hackPath)) {
64
+ const current = readFileSync(hackPath, 'utf-8');
65
+ writeFileSync(hackPath, current.replace('SELF="solpbc/vit"', `SELF="${remote}"`));
66
+ }
67
+ }
68
+
69
+ if (opts.from && cloned) {
70
+ try {
71
+ execFileSync('git', ['remote', 'add', 'upstream', 'https://github.com/solpbc/vit.git'], { stdio: 'inherit' });
72
+ } catch {}
73
+ }
74
+
75
+ console.log('');
76
+ console.log(`${mark} ${name} installed from source`);
77
+ console.log(`run: cd ${dirName}`);
78
+ } catch (err) {
79
+ console.error(err instanceof Error ? err.message : String(err));
80
+ process.exitCode = 1;
81
+ }
82
+ });
83
+ }
@@ -0,0 +1,131 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2026 sol pbc
3
+
4
+ import { DEFAULT_EXPLORE_URL } from '../lib/constants.js';
5
+ import { readBeaconSet } from '../lib/vit-dir.js';
6
+ import { brand } from '../lib/brand.js';
7
+ import { jsonOk, jsonError } from '../lib/json-output.js';
8
+
9
+ function timeAgo(isoString) {
10
+ const seconds = Math.floor((Date.now() - new Date(isoString).getTime()) / 1000);
11
+ if (seconds < 60) return `${seconds}s ago`;
12
+ const minutes = Math.floor(seconds / 60);
13
+ if (minutes < 60) return `${minutes}m ago`;
14
+ const hours = Math.floor(minutes / 60);
15
+ if (hours < 24) return `${hours}h ago`;
16
+ const days = Math.floor(hours / 24);
17
+ return `${days}d ago`;
18
+ }
19
+
20
+ function resolveUrl(opts) {
21
+ return opts.exploreUrl || process.env.VIT_EXPLORE_URL || DEFAULT_EXPLORE_URL;
22
+ }
23
+
24
+ function unavailableMessage(baseUrl) {
25
+ try {
26
+ return `${new URL(baseUrl).host} is unavailable. try 'vit explore caps --beacon .' for network-wide discovery.`;
27
+ } catch {
28
+ return `${baseUrl} is unavailable. try 'vit explore caps --beacon .' for network-wide discovery.`;
29
+ }
30
+ }
31
+
32
+ export default function register(program) {
33
+ program
34
+ .command('inbox')
35
+ .description('Show caps addressed to your project beacon (project-centric view)')
36
+ .option('--kind <kind>', 'Filter by cap kind (e.g. request)')
37
+ .option('--sort <sort>', 'Sort order: recent (default) or want-vouches', 'recent')
38
+ .option('--limit <n>', 'Limit number of caps')
39
+ .option('--json', 'Output as JSON')
40
+ .option('--explore-url <url>', 'Explore API base URL')
41
+ .action(async (opts) => {
42
+ try {
43
+ const beaconSet = readBeaconSet();
44
+ if (beaconSet.size === 0) {
45
+ const msg = "no beacon set — run 'vit init' first (inbox requires a project beacon)";
46
+ if (opts.json) {
47
+ jsonError(msg);
48
+ return;
49
+ }
50
+ console.error(msg);
51
+ process.exitCode = 1;
52
+ return;
53
+ }
54
+
55
+ const beacon = [...beaconSet].join(',');
56
+ const baseUrl = resolveUrl(opts);
57
+
58
+ let data;
59
+ try {
60
+ const url = new URL('/api/caps', baseUrl);
61
+ url.searchParams.set('beacon', beacon);
62
+ if (opts.kind) url.searchParams.set('kind', opts.kind);
63
+ if (opts.sort === 'want-vouches') url.searchParams.set('sort', 'want-vouches');
64
+ if (opts.limit) url.searchParams.set('limit', opts.limit);
65
+
66
+ const res = await fetch(url);
67
+ if (!res.ok) throw new Error(`explore API returned ${res.status}`);
68
+ data = await res.json();
69
+ } catch (err) {
70
+ const msg = err instanceof Error ? err.message : String(err);
71
+ const finalMsg = msg.startsWith('explore API returned ')
72
+ ? msg
73
+ : unavailableMessage(baseUrl);
74
+ if (opts.json) {
75
+ jsonError(finalMsg);
76
+ return;
77
+ }
78
+ console.error(finalMsg);
79
+ console.error("fallback: try 'vit explore caps --beacon .' to query the explore index directly.");
80
+ process.exitCode = 1;
81
+ return;
82
+ }
83
+
84
+ if (opts.json) {
85
+ jsonOk({ caps: data.caps || [], cursor: data.cursor || null });
86
+ return;
87
+ }
88
+
89
+ const caps = data.caps || [];
90
+ const beaconDisplay = [...beaconSet][0];
91
+
92
+ console.log(`${brand} inbox — ${beaconDisplay}`);
93
+ console.log('');
94
+
95
+ if (caps.length === 0) {
96
+ const kindFilter = opts.kind ? ` (kind: ${opts.kind})` : '';
97
+ console.log(`no caps found${kindFilter}.`);
98
+ if (opts.kind) {
99
+ console.log(`hint: to request a feature, run 'vit ship --kind request --beacon <url>'`);
100
+ }
101
+ return;
102
+ }
103
+
104
+ for (const cap of caps) {
105
+ const wantCount = cap.want_vouch_count ?? 0;
106
+ const wantStr = wantCount === 1 ? '1 want' : `${wantCount} wants`;
107
+ const age = cap.created_at ? timeAgo(cap.created_at) : '';
108
+ const handle = cap.handle ? `@${cap.handle}` : cap.did || 'unknown';
109
+ const kind = cap.kind || (cap.record_json ? (() => { try { return JSON.parse(cap.record_json).kind || ''; } catch { return ''; } })() : '');
110
+
111
+ console.log(` ${cap.ref} ${handle} ${wantStr} ${age}`);
112
+ if (cap.title) console.log(` ${cap.title}${kind ? ` [${kind}]` : ''}`);
113
+ if (cap.description) console.log(` ${cap.description}`);
114
+ console.log('');
115
+ }
116
+
117
+ const kindNote = opts.kind ? ` ${opts.kind}` : '';
118
+ console.log(`${caps.length} open${kindNote} cap${caps.length === 1 ? '' : 's'}`);
119
+ console.log(`tip: 'vit vouch <ref> --kind want' to signal demand`);
120
+ console.log(` 'vit ship --recap <ref>' to ship an implementation`);
121
+ } catch (err) {
122
+ const msg = err instanceof Error ? err.message : String(err);
123
+ if (opts.json) {
124
+ jsonError(msg);
125
+ return;
126
+ }
127
+ console.error(msg);
128
+ process.exitCode = 1;
129
+ }
130
+ });
131
+ }
package/src/cmd/init.js CHANGED
@@ -1,4 +1,4 @@
1
- // SPDX-License-Identifier: AGPL-3.0-only
1
+ // SPDX-License-Identifier: MIT
2
2
  // Copyright (c) 2026 sol pbc
3
3
 
4
4
  import { existsSync, writeFileSync } from 'node:fs';
@@ -8,17 +8,24 @@ import { toBeacon } from '../lib/beacon.js';
8
8
  import { vitDir, readProjectConfig, writeProjectConfig } from '../lib/vit-dir.js';
9
9
  import { requireAgent } from '../lib/agent.js';
10
10
  import { mark, name, DOT_VIT_README } from '../lib/brand.js';
11
+ import { jsonOk, jsonError } from '../lib/json-output.js';
11
12
 
12
13
  export default function register(program) {
13
14
  program
14
15
  .command('init')
15
16
  .description('Initialize .vit directory and set project beacon. Use the most official upstream or well-known git URL so all contributors converge on the same beacon.')
16
17
  .option('--beacon <url>', 'Git URL (or "." to read from git remote upstream/origin) to derive the beacon URI')
18
+ .option('--secondary <url>', 'Secondary beacon URL for upstream cap discovery')
19
+ .option('--json', 'Output as JSON')
17
20
  .option('-v, --verbose', 'Show step-by-step details')
18
21
  .action(async (opts) => {
19
22
  try {
20
23
  const gate = requireAgent();
21
24
  if (!gate.ok) {
25
+ if (opts.json) {
26
+ jsonError('agent required', 'run vit init from a coding agent');
27
+ return;
28
+ }
22
29
  console.error(`${name} init should be run by a coding agent (e.g. claude code, gemini cli).`);
23
30
  console.error(`open your agent and ask it to run '${name} init' for you.`);
24
31
  process.exitCode = 1;
@@ -26,13 +33,23 @@ export default function register(program) {
26
33
  }
27
34
 
28
35
  const { verbose } = opts;
36
+ const vlog = opts.json ? (...a) => console.error(...a) : console.log;
29
37
  const dir = vitDir();
30
- if (verbose) console.log(`[verbose] .vit dir: ${dir}`);
38
+ if (verbose) vlog(`[verbose] .vit dir: ${dir}`);
31
39
 
32
- if (!opts.beacon) {
40
+ if (!opts.beacon && !opts.secondary) {
33
41
  const config = readProjectConfig();
34
42
  if (config.beacon) {
43
+ if (opts.json) {
44
+ const out = { beacon: config.beacon };
45
+ if (config.secondaryBeacon) out.secondaryBeacon = config.secondaryBeacon;
46
+ jsonOk(out);
47
+ return;
48
+ }
35
49
  console.log(`${mark} beacon: ${config.beacon}`);
50
+ if (config.secondaryBeacon) {
51
+ console.log(`${mark} secondary beacon: ${config.secondaryBeacon}`);
52
+ }
36
53
  console.log(`hint: to change the beacon, run: ${name} init --beacon <git-url>`);
37
54
  return;
38
55
  }
@@ -45,10 +62,19 @@ export default function register(program) {
45
62
  });
46
63
  isGitRepo = true;
47
64
  } catch {}
48
- if (verbose) console.log(`[verbose] in git repo: ${isGitRepo ? 'yes' : 'no'}`);
65
+ if (verbose) vlog(`[verbose] in git repo: ${isGitRepo ? 'yes' : 'no'}`);
49
66
 
50
67
  const hasVitDir = existsSync(dir);
51
68
  if (!isGitRepo) {
69
+ let remotes = [];
70
+ if (opts.json) {
71
+ jsonOk({
72
+ status: hasVitDir ? 'no beacon' : 'not initialized',
73
+ git: false,
74
+ remotes,
75
+ });
76
+ return;
77
+ }
52
78
  console.log(hasVitDir ? 'status: no beacon' : 'status: not initialized');
53
79
  console.log('git: false');
54
80
  if (hasVitDir) {
@@ -74,7 +100,7 @@ export default function register(program) {
74
100
  } catch {
75
101
  remoteNames = [];
76
102
  }
77
- if (verbose) console.log(`[verbose] remotes detected: ${remoteNames.length > 0 ? remoteNames.join(', ') : 'none'}`);
103
+ if (verbose) vlog(`[verbose] remotes detected: ${remoteNames.length > 0 ? remoteNames.join(', ') : 'none'}`);
78
104
 
79
105
  const remotes = [];
80
106
  for (const name of remoteNames) {
@@ -87,7 +113,16 @@ export default function register(program) {
87
113
  } catch {}
88
114
  }
89
115
  if (verbose && remotes.length > 0) {
90
- console.log(`[verbose] remote urls: ${remotes.map(r => `${r.name}=${r.url}`).join(' ')}`);
116
+ vlog(`[verbose] remote urls: ${remotes.map(r => `${r.name}=${r.url}`).join(' ')}`);
117
+ }
118
+
119
+ if (opts.json) {
120
+ jsonOk({
121
+ status: hasVitDir ? 'no beacon' : 'not initialized',
122
+ git: true,
123
+ remotes: remotes.map(r => ({ name: r.name, url: r.url })),
124
+ });
125
+ return;
91
126
  }
92
127
 
93
128
  const remotesDisplay = remotes.length > 0
@@ -108,9 +143,33 @@ export default function register(program) {
108
143
  return;
109
144
  }
110
145
 
146
+ if (opts.secondary && !opts.beacon) {
147
+ const config = readProjectConfig();
148
+ if (!config.beacon) {
149
+ if (opts.json) {
150
+ jsonError("no primary beacon set — run 'vit init --beacon <url>' first");
151
+ return;
152
+ }
153
+ console.error("no primary beacon set — run 'vit init --beacon <url>' first");
154
+ process.exitCode = 1;
155
+ return;
156
+ }
157
+
158
+ const secondary = 'vit:' + toBeacon(opts.secondary);
159
+ const merged = { ...config, secondaryBeacon: secondary };
160
+ writeProjectConfig(merged);
161
+ if (opts.json) {
162
+ jsonOk({ beacon: merged.beacon, secondaryBeacon: merged.secondaryBeacon });
163
+ return;
164
+ }
165
+ console.log(`${mark} beacon: ${merged.beacon}`);
166
+ console.log(`${mark} secondary beacon: ${merged.secondaryBeacon}`);
167
+ return;
168
+ }
169
+
111
170
  let gitUrl = opts.beacon;
112
171
  if (gitUrl === '.') {
113
- if (verbose) console.log('[verbose] resolving --beacon . via remote.upstream.url then remote.origin.url');
172
+ if (verbose) vlog('[verbose] resolving --beacon . via remote.upstream.url then remote.origin.url');
114
173
  let usedRemote = '';
115
174
  try {
116
175
  gitUrl = execSync('git config --get remote.upstream.url', {
@@ -135,25 +194,48 @@ export default function register(program) {
135
194
  }
136
195
 
137
196
  if (!gitUrl) {
197
+ if (opts.json) {
198
+ jsonError('no git remote found', 'set a remote or provide a git URL directly');
199
+ return;
200
+ }
138
201
  console.error('No git remote found. Set a remote or provide a git URL directly.');
139
202
  process.exitCode = 1;
140
203
  return;
141
204
  }
142
- if (verbose) console.log(`[verbose] Read git remote ${usedRemote}: ${gitUrl}`);
205
+ if (verbose) vlog(`[verbose] Read git remote ${usedRemote}: ${gitUrl}`);
143
206
  }
144
207
 
145
208
  const beacon = 'vit:' + toBeacon(gitUrl);
146
- if (verbose) console.log(`[verbose] Computed beacon: ${beacon}`);
147
- writeProjectConfig({ beacon });
148
- if (verbose) console.log(`[verbose] Wrote config.json`);
209
+ if (verbose) vlog(`[verbose] Computed beacon: ${beacon}`);
210
+ const existing = readProjectConfig();
211
+ const merged = { ...existing, beacon };
212
+ if (opts.secondary) {
213
+ merged.secondaryBeacon = 'vit:' + toBeacon(opts.secondary);
214
+ }
215
+ writeProjectConfig(merged);
216
+ if (verbose) vlog(`[verbose] Wrote config.json`);
149
217
  const readmePath = join(vitDir(), 'README.md');
150
218
  if (!existsSync(readmePath)) {
151
219
  writeFileSync(readmePath, DOT_VIT_README);
152
- if (verbose) console.log(`[verbose] Wrote .vit/README.md`);
220
+ if (verbose) vlog(`[verbose] Wrote .vit/README.md`);
221
+ }
222
+ if (opts.json) {
223
+ const out = { beacon: merged.beacon };
224
+ if (merged.secondaryBeacon) out.secondaryBeacon = merged.secondaryBeacon;
225
+ jsonOk(out);
226
+ return;
153
227
  }
154
228
  console.log(`${mark} beacon: ${beacon}`);
229
+ if (merged.secondaryBeacon) {
230
+ console.log(`${mark} secondary beacon: ${merged.secondaryBeacon}`);
231
+ }
155
232
  } catch (err) {
156
- console.error(err instanceof Error ? err.message : String(err));
233
+ const msg = err instanceof Error ? err.message : String(err);
234
+ if (opts.json) {
235
+ jsonError(msg);
236
+ return;
237
+ }
238
+ console.error(msg);
157
239
  process.exitCode = 1;
158
240
  }
159
241
  });