vit 0.4.0 → 0.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vit",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Social toolkit for personalized software",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -16,7 +16,7 @@
16
16
  "postinstall": "node src/postinstall.js"
17
17
  },
18
18
  "engines": {
19
- "node": ">=20.0.0"
19
+ "node": ">=20.10.0"
20
20
  },
21
21
  "dependencies": {
22
22
  "@atproto/api": "^0.18.20",
@@ -57,7 +57,7 @@ Options:
57
57
  - None.
58
58
 
59
59
  Output format:
60
- - Text diagnostics for install and beacon status.
60
+ - Text diagnostics for install and beacon status; self-installs the using-vit skill into `~/.claude/skills` and `~/.agents/skills` if missing.
61
61
 
62
62
  Error conditions:
63
63
  - Config read/parse failures.
@@ -4,6 +4,9 @@ description: >-
4
4
  Helps coding agents use vit to discover, follow, skim, and ship software
5
5
  capabilities (caps) over ATProto. Activates when the user mentions vit,
6
6
  beacons, caps, shipping, skimming, following, vetting, or social coding.
7
+ Provides command reference for: vit init, vit skim, vit ship, vit follow,
8
+ vit following, vit learn, vit remix, vit doctor, vit config, vit beacon,
9
+ vit login.
7
10
  ---
8
11
 
9
12
  ## 1. Overview
@@ -64,7 +67,7 @@ Handoffs:
64
67
  ### Agent-usable commands
65
68
 
66
69
  ### `vit doctor`
67
- - Description: Read-only diagnostic for install and beacon status.
70
+ - Description: Verify install and beacon status, and self-install the using-vit skill into `~/.claude/skills` and `~/.agents/skills` if missing.
68
71
  - Usage: `vit doctor`
69
72
  - Key flags: none.
70
73
  - Output: text status lines for install and beacon.
package/src/cli.js CHANGED
@@ -2,6 +2,7 @@
2
2
  // Copyright (c) 2026 sol pbc
3
3
 
4
4
  import { Command } from 'commander';
5
+ import { readFileSync } from 'node:fs';
5
6
  import { brand } from './lib/brand.js';
6
7
  import registerAdopt from './cmd/adopt.js';
7
8
  import registerBeacon from './cmd/beacon.js';
@@ -23,11 +24,13 @@ import registerHack from './cmd/hack.js';
23
24
  import registerLink from './cmd/link.js';
24
25
  import registerInbox from './cmd/inbox.js';
25
26
 
27
+ const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf-8'));
28
+
26
29
  const program = new Command();
27
30
  program
28
31
  .name('vit')
29
32
  .description(`${brand} \u2014 social open source`)
30
- .version('0.1.0');
33
+ .version(pkg.version);
31
34
 
32
35
  registerAdopt(program);
33
36
  registerBeacon(program);
package/src/cmd/adopt.js CHANGED
@@ -8,6 +8,7 @@ import { parseGitUrl, toBeacon, beaconToHttps } from '../lib/beacon.js';
8
8
  import { requireNotAgent } from '../lib/agent.js';
9
9
  import { which } from '../lib/compat.js';
10
10
  import { mark, name } from '../lib/brand.js';
11
+ import { formatError } from '../lib/error-format.js';
11
12
 
12
13
  export default function register(program) {
13
14
  program
@@ -85,7 +86,7 @@ export default function register(program) {
85
86
  console.log('');
86
87
  console.log(`next: start your agent and ask it to run '${name} init'`);
87
88
  } catch (err) {
88
- console.error(err instanceof Error ? err.message : String(err));
89
+ console.error(formatError(err, { verbose: opts.verbose }));
89
90
  process.exitCode = 1;
90
91
  }
91
92
  });
package/src/cmd/beacon.js CHANGED
@@ -6,6 +6,7 @@ import http from 'isomorphic-git/http/node';
6
6
  import { memfs } from 'memfs';
7
7
  import { beaconToHttps } from '../lib/beacon.js';
8
8
  import { mark } from '../lib/brand.js';
9
+ import { errorMessage, formatError } from '../lib/error-format.js';
9
10
 
10
11
  async function readTreeFile(fs, dir, treeOid, pathParts) {
11
12
  for (let i = 0; i < pathParts.length; i++) {
@@ -47,7 +48,9 @@ export default function register(program) {
47
48
  let beacon;
48
49
  try {
49
50
  beacon = content && JSON.parse(content).beacon;
50
- } catch {}
51
+ } catch (err) {
52
+ console.warn(`warning: failed to parse .vit/config.json from ${url}: ${errorMessage(err)}`);
53
+ }
51
54
 
52
55
  if (beacon) {
53
56
  console.log(`${mark} beacon: lit ${beacon}`);
@@ -56,7 +59,7 @@ export default function register(program) {
56
59
  console.log("the maintainer can light the beacon by running 'vit init' inside the repo.");
57
60
  }
58
61
  } catch (err) {
59
- console.error(err instanceof Error ? err.message : String(err));
62
+ console.error(formatError(err, { verbose: opts.verbose }));
60
63
  process.exitCode = 1;
61
64
  }
62
65
  });
package/src/cmd/config.js CHANGED
@@ -2,6 +2,7 @@
2
2
  // Copyright (c) 2026 sol pbc
3
3
 
4
4
  import { loadConfig, saveConfig, getScalars } from '../lib/config.js';
5
+ import { formatError } from '../lib/error-format.js';
5
6
 
6
7
  function coerceValue(str) {
7
8
  if (str === 'true') return true;
@@ -61,7 +62,7 @@ export default function register(program) {
61
62
  console.error(`Unknown action: ${action}`);
62
63
  process.exitCode = 1;
63
64
  } catch (err) {
64
- console.error(err instanceof Error ? err.message : String(err));
65
+ console.error(formatError(err, { verbose: false }));
65
66
  process.exitCode = 1;
66
67
  }
67
68
  });
package/src/cmd/doctor.js CHANGED
@@ -11,6 +11,10 @@ import { mark, name } from '../lib/brand.js';
11
11
  import { which } from '../lib/compat.js';
12
12
  import { jsonOk, jsonError } from '../lib/json-output.js';
13
13
  import { configPath } from '../lib/paths.js';
14
+ import { errorMessage, formatError } from '../lib/error-format.js';
15
+ import { ensureSkill, skillInstallReason } from '../lib/skill-install.js';
16
+
17
+ const USING_VIT_SKILL = 'using-vit';
14
18
 
15
19
  function scanSkillDir(dir) {
16
20
  const skills = [];
@@ -29,14 +33,30 @@ function scanSkillDir(dir) {
29
33
  const versionMatch = match[1].match(/^version:\s*(.+)$/m);
30
34
  if (versionMatch) version = versionMatch[1].trim();
31
35
  }
32
- } catch { /* ignore read errors */ }
36
+ } catch (err) {
37
+ console.warn(`warning: failed to read ${skillMd}: ${errorMessage(err)}`);
38
+ }
33
39
  skills.push({ name: entry.name, version });
34
40
  }
35
41
  }
36
- } catch { /* ignore dir read errors */ }
42
+ } catch (err) {
43
+ console.warn(`warning: failed to read skill directory ${dir}: ${errorMessage(err)}`);
44
+ }
37
45
  return skills;
38
46
  }
39
47
 
48
+ function formatSkillLine(skillResult) {
49
+ if (skillResult.ok) {
50
+ const paths = skillResult.results.map(result => result.path).join(', ');
51
+ if (skillResult.results.every(result => result.status === 'already-present')) {
52
+ return `${mark} skill: ok (${USING_VIT_SKILL})`;
53
+ }
54
+ return `${mark} skill: installed (${USING_VIT_SKILL}) → ${paths}`;
55
+ }
56
+
57
+ return `${mark} skill: install failed — ${skillInstallReason(skillResult)}; check write permissions on ~/.claude and ~/.agents, or reinstall vit`;
58
+ }
59
+
40
60
  export default function register(program) {
41
61
  async function checkHealth(opts) {
42
62
  try {
@@ -66,7 +86,8 @@ export default function register(program) {
66
86
  installType = 'source';
67
87
  if (!opts.json) console.log(`${mark} install: source (${vitPath})`);
68
88
  }
69
- } catch {
89
+ } catch (err) {
90
+ console.warn(`warning: failed to inspect install path ${vitPath}: ${errorMessage(err)}`);
70
91
  installType = 'source';
71
92
  if (!opts.json) console.log(`${mark} install: source (${vitPath})`);
72
93
  }
@@ -80,19 +101,23 @@ export default function register(program) {
80
101
  if (!opts.json) console.log(`${mark} beacon: not set (run vit init)`);
81
102
  }
82
103
 
83
- const projectSkillPath = join(process.cwd(), '.claude', 'skills', 'using-vit', 'SKILL.md');
84
- const userSkillPath = join(homedir(), '.claude', 'skills', 'using-vit', 'SKILL.md');
85
- skillInstalled = existsSync(projectSkillPath) || existsSync(userSkillPath);
86
- if (skillInstalled) {
87
- if (!opts.json) console.log(`${mark} skill: ok (using-vit)`);
104
+ const skillResult = ensureSkill();
105
+ const home = homedir();
106
+ const projectClaude = join(process.cwd(), '.claude', 'skills', USING_VIT_SKILL, 'SKILL.md');
107
+ const userClaude = join(home, '.claude', 'skills', USING_VIT_SKILL, 'SKILL.md');
108
+ const userAgents = join(home, '.agents', 'skills', USING_VIT_SKILL, 'SKILL.md');
109
+ skillInstalled = existsSync(projectClaude) || existsSync(userClaude) || existsSync(userAgents);
110
+ const skillLine = formatSkillLine(skillResult);
111
+ if (opts.json) {
112
+ console.error(skillLine);
88
113
  } else {
89
- if (!opts.json) console.log(`${mark} skill: not installed (reinstall vit)`);
114
+ console.log(skillLine);
90
115
  }
91
116
 
92
117
  // Report installed skills
93
118
  const projectSkillDir = join(process.cwd(), '.claude', 'skills');
94
119
  projectSkills = scanSkillDir(projectSkillDir);
95
- const userSkillDir = join(homedir(), '.claude', 'skills');
120
+ const userSkillDir = join(home, '.claude', 'skills');
96
121
  userSkills = scanSkillDir(userSkillDir);
97
122
 
98
123
  if (!opts.json && projectSkills.length > 0) {
@@ -124,16 +149,23 @@ export default function register(program) {
124
149
  authType = local.type || 'oauth';
125
150
  }
126
151
  }
127
- } catch {}
152
+ } catch (err) {
153
+ console.warn(`warning: failed to read ${localLoginPath}: ${errorMessage(err)}`);
154
+ }
128
155
 
129
156
  if (!identitySource && effectiveDid) identitySource = 'global';
130
157
 
131
158
  if (identitySource === 'global' && effectiveDid) {
159
+ const sessionFile = configPath('session.json');
132
160
  try {
133
- const raw = readFileSync(configPath('session.json'), 'utf-8');
134
- const sessionData = JSON.parse(raw);
135
- if (sessionData[effectiveDid]?.type === 'app-password') authType = 'app-password';
136
- } catch {}
161
+ if (existsSync(sessionFile)) {
162
+ const raw = readFileSync(sessionFile, 'utf-8');
163
+ const sessionData = JSON.parse(raw);
164
+ if (sessionData[effectiveDid]?.type === 'app-password') authType = 'app-password';
165
+ }
166
+ } catch (err) {
167
+ console.warn(`warning: failed to read ${sessionFile}: ${errorMessage(err)}`);
168
+ }
137
169
  }
138
170
 
139
171
  if (!effectiveDid) {
@@ -144,7 +176,8 @@ export default function register(program) {
144
176
  blueskyOk = true;
145
177
  pds = session.serverMetadata?.issuer || null;
146
178
  if (!opts.json) console.log(`${mark} bluesky: ok (${session.did || effectiveDid}${pds ? ', ' + pds : ''})`);
147
- } catch {
179
+ } catch (err) {
180
+ console.warn(`warning: failed to validate Bluesky session: ${errorMessage(err)}`);
148
181
  if (!opts.json) console.log(`${mark} bluesky: token expired or invalid (run ${name} login <handle>)`);
149
182
  }
150
183
  if (!opts.json) console.log(`${mark} identity: ${identitySource} (${authType})`);
@@ -155,18 +188,18 @@ export default function register(program) {
155
188
  install: { type: installType, path: installPath },
156
189
  beacon,
157
190
  skill: skillInstalled,
191
+ skillInstall: { ok: skillResult.ok, results: skillResult.results },
158
192
  projectSkills,
159
193
  userSkills,
160
194
  bluesky: { ok: blueskyOk, did: effectiveDid || null, pds, source: identitySource, authType },
161
195
  });
162
196
  }
163
197
  } catch (err) {
164
- const msg = err instanceof Error ? err.message : String(err);
165
198
  if (opts.json) {
166
- jsonError(msg);
199
+ jsonError(err);
167
200
  return;
168
201
  }
169
- console.error(msg);
202
+ console.error(formatError(err, { verbose: false }));
170
203
  process.exitCode = 1;
171
204
  }
172
205
  }
@@ -179,4 +212,8 @@ export default function register(program) {
179
212
  .description('Alias for doctor')
180
213
  .option('--json', 'Output as JSON')
181
214
  .action(checkHealth);
215
+ program.command('setup')
216
+ .description('Alias for doctor')
217
+ .option('--json', 'Output as JSON')
218
+ .action(checkHealth);
182
219
  }
@@ -5,6 +5,7 @@ import { DEFAULT_EXPLORE_URL } from '../lib/constants.js';
5
5
  import { readProjectConfig } from '../lib/vit-dir.js';
6
6
  import { brand } from '../lib/brand.js';
7
7
  import { jsonOk, jsonError } from '../lib/json-output.js';
8
+ import { errorMessage, formatError } from '../lib/error-format.js';
8
9
 
9
10
  function timeAgo(isoString) {
10
11
  const seconds = Math.floor((Date.now() - new Date(isoString).getTime()) / 1000);
@@ -25,11 +26,27 @@ function resolveUrl(opts) {
25
26
  return opts.exploreUrl || process.env.VIT_EXPLORE_URL || DEFAULT_EXPLORE_URL;
26
27
  }
27
28
 
28
- function unavailableMessage(baseUrl) {
29
+ function requestErrorMessage(method, url, err) {
30
+ const code = err?.cause?.code || err?.code;
31
+ if (code === 'ECONNREFUSED') return `could not connect to ${url} (refused)`;
32
+ if (code === 'ENOTFOUND') return `could not resolve ${url}`;
33
+ if (code === 'ETIMEDOUT' || code === 'UND_ERR_CONNECT_TIMEOUT') {
34
+ return `timed out connecting to ${url}`;
35
+ }
36
+ return `request to ${url} failed: ${errorMessage(err)}`;
37
+ }
38
+
39
+ async function fetchExploreJson(url) {
40
+ const requestUrl = url.toString();
29
41
  try {
30
- return `${new URL(baseUrl).host} is unavailable. try 'vit scan' for network-wide discovery or 'vit skim' for your followed accounts.`;
31
- } catch {
32
- return `${baseUrl} is unavailable. try 'vit scan' for network-wide discovery or 'vit skim' for your followed accounts.`;
42
+ const res = await fetch(url);
43
+ if (!res.ok) throw new Error(`GET ${requestUrl} returned ${res.status}`);
44
+ return await res.json();
45
+ } catch (err) {
46
+ if (err instanceof Error && err.message.startsWith(`GET ${requestUrl} returned `)) {
47
+ throw err;
48
+ }
49
+ throw new Error(requestErrorMessage('GET', requestUrl, err), { cause: err });
33
50
  }
34
51
  }
35
52
 
@@ -44,9 +61,7 @@ async function fetchAndShowStats(opts) {
44
61
  const baseUrl = resolveUrl(opts);
45
62
  try {
46
63
  const url = new URL('/api/stats', baseUrl);
47
- const res = await fetch(url);
48
- if (!res.ok) throw new Error(`explore API returned ${res.status}`);
49
- const data = await res.json();
64
+ const data = await fetchExploreJson(url);
50
65
 
51
66
  if (opts.json) {
52
67
  jsonOk(data);
@@ -58,15 +73,11 @@ async function fetchAndShowStats(opts) {
58
73
  console.log(` vouches: ${data.total_vouches} beacons: ${data.total_beacons}`);
59
74
  console.log(` active dids: ${data.active_dids} skill publishers: ${data.skill_publishers}`);
60
75
  } catch (err) {
61
- const msg = err instanceof Error ? err.message : String(err);
62
- const finalMsg = msg.startsWith('explore API returned ')
63
- ? msg
64
- : unavailableMessage(baseUrl);
65
76
  if (opts.json) {
66
- jsonError(finalMsg);
77
+ jsonError(err);
67
78
  return;
68
79
  }
69
- console.error(finalMsg);
80
+ console.error(formatError(err, { verbose: false }));
70
81
  process.exitCode = 1;
71
82
  }
72
83
  }
@@ -97,9 +108,7 @@ export default function register(program) {
97
108
  url.searchParams.set('ref', ref);
98
109
  if (opts.beacon) url.searchParams.set('beacon', opts.beacon);
99
110
 
100
- const res = await fetch(url);
101
- if (!res.ok) throw new Error(`explore API returned ${res.status}`);
102
- const data = await res.json();
111
+ const data = await fetchExploreJson(url);
103
112
 
104
113
  if (!data.cap) {
105
114
  const msg = `no cap found with ref '${ref}'`;
@@ -136,15 +145,11 @@ export default function register(program) {
136
145
  console.log(` vit vet ${data.cap.ref} - inspect before adopting`);
137
146
  console.log(` vit remix ${data.cap.ref} - remix this cap`);
138
147
  } catch (err) {
139
- const msg = err instanceof Error ? err.message : String(err);
140
- const finalMsg = msg.startsWith('explore API returned ')
141
- ? msg
142
- : unavailableMessage(baseUrl);
143
148
  if (opts.json) {
144
- jsonError(finalMsg);
149
+ jsonError(err);
145
150
  return;
146
151
  }
147
- console.error(finalMsg);
152
+ console.error(formatError(err, { verbose: false }));
148
153
  process.exitCode = 1;
149
154
  }
150
155
  });
@@ -163,9 +168,7 @@ export default function register(program) {
163
168
  const url = new URL('/api/skill', baseUrl);
164
169
  url.searchParams.set('name', name);
165
170
 
166
- const res = await fetch(url);
167
- if (!res.ok) throw new Error(`explore API returned ${res.status}`);
168
- const data = await res.json();
171
+ const data = await fetchExploreJson(url);
169
172
 
170
173
  if (!data.skill) {
171
174
  const msg = `no skill found with name '${name}'`;
@@ -195,15 +198,11 @@ export default function register(program) {
195
198
  console.log();
196
199
  console.log(` vit learn skill-${data.skill.name} - install this skill`);
197
200
  } catch (err) {
198
- const msg = err instanceof Error ? err.message : String(err);
199
- const finalMsg = msg.startsWith('explore API returned ')
200
- ? msg
201
- : unavailableMessage(baseUrl);
202
201
  if (opts.json) {
203
- jsonError(finalMsg);
202
+ jsonError(err);
204
203
  return;
205
204
  }
206
- console.error(finalMsg);
205
+ console.error(formatError(err, { verbose: false }));
207
206
  process.exitCode = 1;
208
207
  }
209
208
  });
@@ -245,9 +244,7 @@ export default function register(program) {
245
244
  if (opts.limit) url.searchParams.set('limit', opts.limit);
246
245
  if (opts.cursor) url.searchParams.set('cursor', opts.cursor);
247
246
 
248
- const res = await fetch(url);
249
- if (!res.ok) throw new Error(`explore API returned ${res.status}`);
250
- const data = await res.json();
247
+ const data = await fetchExploreJson(url);
251
248
 
252
249
  if (opts.json) {
253
250
  jsonOk({ caps: data.caps, cursor: data.cursor });
@@ -271,15 +268,11 @@ export default function register(program) {
271
268
  console.log(`\nnext: --cursor ${data.cursor}`);
272
269
  }
273
270
  } catch (err) {
274
- const msg = err instanceof Error ? err.message : String(err);
275
- const finalMsg = msg.startsWith('explore API returned ')
276
- ? msg
277
- : unavailableMessage(baseUrl);
278
271
  if (opts.json) {
279
- jsonError(finalMsg);
272
+ jsonError(err);
280
273
  return;
281
274
  }
282
- console.error(finalMsg);
275
+ console.error(formatError(err, { verbose: false }));
283
276
  process.exitCode = 1;
284
277
  }
285
278
  });
@@ -302,9 +295,7 @@ export default function register(program) {
302
295
  if (opts.limit) url.searchParams.set('limit', opts.limit);
303
296
  if (opts.cursor) url.searchParams.set('cursor', opts.cursor);
304
297
 
305
- const res = await fetch(url);
306
- if (!res.ok) throw new Error(`explore API returned ${res.status}`);
307
- const data = await res.json();
298
+ const data = await fetchExploreJson(url);
308
299
 
309
300
  if (opts.json) {
310
301
  jsonOk({ skills: data.skills, cursor: data.cursor });
@@ -326,15 +317,11 @@ export default function register(program) {
326
317
  console.log(`\nnext: --cursor ${data.cursor}`);
327
318
  }
328
319
  } catch (err) {
329
- const msg = err instanceof Error ? err.message : String(err);
330
- const finalMsg = msg.startsWith('explore API returned ')
331
- ? msg
332
- : unavailableMessage(baseUrl);
333
320
  if (opts.json) {
334
- jsonError(finalMsg);
321
+ jsonError(err);
335
322
  return;
336
323
  }
337
- console.error(finalMsg);
324
+ console.error(formatError(err, { verbose: false }));
338
325
  process.exitCode = 1;
339
326
  }
340
327
  });
@@ -350,9 +337,7 @@ export default function register(program) {
350
337
 
351
338
  try {
352
339
  const url = new URL('/api/beacons', baseUrl);
353
- const res = await fetch(url);
354
- if (!res.ok) throw new Error(`explore API returned ${res.status}`);
355
- const data = await res.json();
340
+ const data = await fetchExploreJson(url);
356
341
 
357
342
  if (opts.json) {
358
343
  jsonOk({ beacons: data.beacons });
@@ -371,15 +356,11 @@ export default function register(program) {
371
356
  console.log(` caps: ${beacon.cap_count} vouches: ${beacon.vouch_count} last active: ${beacon.last_activity}`);
372
357
  }
373
358
  } catch (err) {
374
- const msg = err instanceof Error ? err.message : String(err);
375
- const finalMsg = msg.startsWith('explore API returned ')
376
- ? msg
377
- : unavailableMessage(baseUrl);
378
359
  if (opts.json) {
379
- jsonError(finalMsg);
360
+ jsonError(err);
380
361
  return;
381
362
  }
382
- console.error(finalMsg);
363
+ console.error(formatError(err, { verbose: false }));
383
364
  process.exitCode = 1;
384
365
  }
385
366
  });
@@ -413,9 +394,7 @@ export default function register(program) {
413
394
  const capsUrl = new URL('/api/caps', baseUrl);
414
395
  if (opts.beacon) capsUrl.searchParams.set('beacon', opts.beacon);
415
396
 
416
- const capsRes = await fetch(capsUrl);
417
- if (!capsRes.ok) throw new Error(`explore API returned ${capsRes.status}`);
418
- const capsData = await capsRes.json();
397
+ const capsData = await fetchExploreJson(capsUrl);
419
398
  const match = capsData.caps?.find((cap) => cap.ref === opts.ref);
420
399
 
421
400
  if (!match) {
@@ -435,9 +414,7 @@ export default function register(program) {
435
414
  const url = new URL('/api/vouches', baseUrl);
436
415
  url.searchParams.set('cap_uri', capUri);
437
416
 
438
- const res = await fetch(url);
439
- if (!res.ok) throw new Error(`explore API returned ${res.status}`);
440
- const data = await res.json();
417
+ const data = await fetchExploreJson(url);
441
418
 
442
419
  if (opts.json) {
443
420
  jsonOk({ vouches: data.vouches, cap_uri: capUri });
@@ -458,15 +435,11 @@ export default function register(program) {
458
435
  if (ref) console.log(` ${ref}`);
459
436
  }
460
437
  } catch (err) {
461
- const msg = err instanceof Error ? err.message : String(err);
462
- const finalMsg = msg.startsWith('explore API returned ')
463
- ? msg
464
- : unavailableMessage(baseUrl);
465
438
  if (opts.json) {
466
- jsonError(finalMsg);
439
+ jsonError(err);
467
440
  return;
468
441
  }
469
- console.error(finalMsg);
442
+ console.error(formatError(err, { verbose: false }));
470
443
  process.exitCode = 1;
471
444
  }
472
445
  });
@@ -5,6 +5,7 @@ import { loadConfig } from '../lib/config.js';
5
5
  import { CAP_COLLECTION, DEFAULT_JETSTREAM_URL } from '../lib/constants.js';
6
6
  import { resolveRef } from '../lib/cap-ref.js';
7
7
  import { brand } from '../lib/brand.js';
8
+ import { formatError } from '../lib/error-format.js';
8
9
 
9
10
  let ws = null;
10
11
  let shuttingDown = false;
@@ -72,7 +73,7 @@ function connect(opts, cursor) {
72
73
  try {
73
74
  msg = JSON.parse(event.data);
74
75
  } catch {
75
- console.log('Warning: failed to parse message as JSON; skipping');
76
+ console.warn('warning: failed to parse message as JSON; skipping');
76
77
  return;
77
78
  }
78
79
 
@@ -152,7 +153,7 @@ export default function register(program) {
152
153
 
153
154
  connect(opts, null);
154
155
  } catch (err) {
155
- console.error(err instanceof Error ? err.message : String(err));
156
+ console.error(formatError(err, { verbose: opts.verbose }));
156
157
  process.exitCode = 1;
157
158
  }
158
159
  });
package/src/cmd/follow.js CHANGED
@@ -6,6 +6,7 @@ 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
8
  import { jsonOk, jsonError } from '../lib/json-output.js';
9
+ import { formatError } from '../lib/error-format.js';
9
10
 
10
11
  export default function register(program) {
11
12
  program
@@ -55,12 +56,11 @@ export default function register(program) {
55
56
  }
56
57
  console.log(`${mark} following ${handle} (${targetDid})`);
57
58
  } catch (err) {
58
- const msg = err instanceof Error ? err.message : String(err);
59
59
  if (opts.json) {
60
- jsonError(msg);
60
+ jsonError(err);
61
61
  return;
62
62
  }
63
- console.error(msg);
63
+ console.error(formatError(err, { verbose: opts.verbose }));
64
64
  process.exitCode = 1;
65
65
  }
66
66
  });
@@ -97,12 +97,11 @@ export default function register(program) {
97
97
  }
98
98
  console.log(`${mark} unfollowed ${handle}`);
99
99
  } catch (err) {
100
- const msg = err instanceof Error ? err.message : String(err);
101
100
  if (opts.json) {
102
- jsonError(msg);
101
+ jsonError(err);
103
102
  return;
104
103
  }
105
- console.error(msg);
104
+ console.error(formatError(err, { verbose: opts.verbose }));
106
105
  process.exitCode = 1;
107
106
  }
108
107
  });
@@ -134,12 +133,11 @@ export default function register(program) {
134
133
  console.log(`${e.handle} (${e.did})`);
135
134
  }
136
135
  } catch (err) {
137
- const msg = err instanceof Error ? err.message : String(err);
138
136
  if (opts.json) {
139
- jsonError(msg);
137
+ jsonError(err);
140
138
  return;
141
139
  }
142
- console.error(msg);
140
+ console.error(formatError(err, { verbose: opts.verbose }));
143
141
  process.exitCode = 1;
144
142
  }
145
143
  });
package/src/cmd/hack.js CHANGED
@@ -6,6 +6,7 @@ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
6
6
  import { join, resolve } from 'node:path';
7
7
  import { which } from '../lib/compat.js';
8
8
  import { mark, name } from '../lib/brand.js';
9
+ import { errorMessage, formatError } from '../lib/error-format.js';
9
10
 
10
11
  export default function register(program) {
11
12
  program
@@ -69,14 +70,16 @@ export default function register(program) {
69
70
  if (opts.from && cloned) {
70
71
  try {
71
72
  execFileSync('git', ['remote', 'add', 'upstream', 'https://github.com/solpbc/vit.git'], { stdio: 'inherit' });
72
- } catch {}
73
+ } catch (err) {
74
+ console.warn(`warning: failed to add upstream remote: ${errorMessage(err)}`);
75
+ }
73
76
  }
74
77
 
75
78
  console.log('');
76
79
  console.log(`${mark} ${name} installed from source`);
77
80
  console.log(`run: cd ${dirName}`);
78
81
  } catch (err) {
79
- console.error(err instanceof Error ? err.message : String(err));
82
+ console.error(formatError(err, { verbose: false }));
80
83
  process.exitCode = 1;
81
84
  }
82
85
  });