vit 0.3.0 → 0.4.3
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 +2 -2
- package/skills/vit/SKILL.md +3 -0
- package/src/cmd/adopt.js +2 -1
- package/src/cmd/beacon.js +5 -2
- package/src/cmd/config.js +2 -1
- package/src/cmd/doctor.js +25 -12
- package/src/cmd/explore.js +43 -70
- package/src/cmd/firehose.js +3 -2
- package/src/cmd/follow.js +7 -9
- package/src/cmd/hack.js +5 -2
- package/src/cmd/inbox.js +4 -4
- package/src/cmd/init.js +10 -6
- package/src/cmd/learn.js +245 -87
- package/src/cmd/link.js +2 -1
- package/src/cmd/login.js +71 -4
- package/src/cmd/remix.js +3 -3
- package/src/cmd/scan.js +9 -4
- package/src/cmd/ship.js +3 -3
- package/src/cmd/skim.js +7 -1
- package/src/cmd/vet.js +3 -3
- package/src/cmd/vouch.js +3 -3
- package/src/lib/config.js +7 -3
- package/src/lib/error-format.js +78 -0
- package/src/lib/json-output.js +28 -3
- package/src/lib/oauth.js +34 -17
- package/src/lib/pds.js +36 -7
- package/src/lib/trust-gate.js +4 -4
- package/src/lib/vit-dir.js +33 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vit",
|
|
3
|
-
"version": "0.3
|
|
3
|
+
"version": "0.4.3",
|
|
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.
|
|
19
|
+
"node": ">=20.10.0"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@atproto/api": "^0.18.20",
|
package/skills/vit/SKILL.md
CHANGED
|
@@ -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
|
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
|
|
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
|
|
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
|
|
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,7 @@ 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';
|
|
14
15
|
|
|
15
16
|
function scanSkillDir(dir) {
|
|
16
17
|
const skills = [];
|
|
@@ -29,11 +30,15 @@ function scanSkillDir(dir) {
|
|
|
29
30
|
const versionMatch = match[1].match(/^version:\s*(.+)$/m);
|
|
30
31
|
if (versionMatch) version = versionMatch[1].trim();
|
|
31
32
|
}
|
|
32
|
-
} catch {
|
|
33
|
+
} catch (err) {
|
|
34
|
+
console.warn(`warning: failed to read ${skillMd}: ${errorMessage(err)}`);
|
|
35
|
+
}
|
|
33
36
|
skills.push({ name: entry.name, version });
|
|
34
37
|
}
|
|
35
38
|
}
|
|
36
|
-
} catch {
|
|
39
|
+
} catch (err) {
|
|
40
|
+
console.warn(`warning: failed to read skill directory ${dir}: ${errorMessage(err)}`);
|
|
41
|
+
}
|
|
37
42
|
return skills;
|
|
38
43
|
}
|
|
39
44
|
|
|
@@ -66,7 +71,8 @@ export default function register(program) {
|
|
|
66
71
|
installType = 'source';
|
|
67
72
|
if (!opts.json) console.log(`${mark} install: source (${vitPath})`);
|
|
68
73
|
}
|
|
69
|
-
} catch {
|
|
74
|
+
} catch (err) {
|
|
75
|
+
console.warn(`warning: failed to inspect install path ${vitPath}: ${errorMessage(err)}`);
|
|
70
76
|
installType = 'source';
|
|
71
77
|
if (!opts.json) console.log(`${mark} install: source (${vitPath})`);
|
|
72
78
|
}
|
|
@@ -124,16 +130,23 @@ export default function register(program) {
|
|
|
124
130
|
authType = local.type || 'oauth';
|
|
125
131
|
}
|
|
126
132
|
}
|
|
127
|
-
} catch {
|
|
133
|
+
} catch (err) {
|
|
134
|
+
console.warn(`warning: failed to read ${localLoginPath}: ${errorMessage(err)}`);
|
|
135
|
+
}
|
|
128
136
|
|
|
129
137
|
if (!identitySource && effectiveDid) identitySource = 'global';
|
|
130
138
|
|
|
131
139
|
if (identitySource === 'global' && effectiveDid) {
|
|
140
|
+
const sessionFile = configPath('session.json');
|
|
132
141
|
try {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
142
|
+
if (existsSync(sessionFile)) {
|
|
143
|
+
const raw = readFileSync(sessionFile, 'utf-8');
|
|
144
|
+
const sessionData = JSON.parse(raw);
|
|
145
|
+
if (sessionData[effectiveDid]?.type === 'app-password') authType = 'app-password';
|
|
146
|
+
}
|
|
147
|
+
} catch (err) {
|
|
148
|
+
console.warn(`warning: failed to read ${sessionFile}: ${errorMessage(err)}`);
|
|
149
|
+
}
|
|
137
150
|
}
|
|
138
151
|
|
|
139
152
|
if (!effectiveDid) {
|
|
@@ -144,7 +157,8 @@ export default function register(program) {
|
|
|
144
157
|
blueskyOk = true;
|
|
145
158
|
pds = session.serverMetadata?.issuer || null;
|
|
146
159
|
if (!opts.json) console.log(`${mark} bluesky: ok (${session.did || effectiveDid}${pds ? ', ' + pds : ''})`);
|
|
147
|
-
} catch {
|
|
160
|
+
} catch (err) {
|
|
161
|
+
console.warn(`warning: failed to validate Bluesky session: ${errorMessage(err)}`);
|
|
148
162
|
if (!opts.json) console.log(`${mark} bluesky: token expired or invalid (run ${name} login <handle>)`);
|
|
149
163
|
}
|
|
150
164
|
if (!opts.json) console.log(`${mark} identity: ${identitySource} (${authType})`);
|
|
@@ -161,12 +175,11 @@ export default function register(program) {
|
|
|
161
175
|
});
|
|
162
176
|
}
|
|
163
177
|
} catch (err) {
|
|
164
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
165
178
|
if (opts.json) {
|
|
166
|
-
jsonError(
|
|
179
|
+
jsonError(err);
|
|
167
180
|
return;
|
|
168
181
|
}
|
|
169
|
-
console.error(
|
|
182
|
+
console.error(formatError(err, { verbose: false }));
|
|
170
183
|
process.exitCode = 1;
|
|
171
184
|
}
|
|
172
185
|
}
|
package/src/cmd/explore.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
return
|
|
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
|
|
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(
|
|
77
|
+
jsonError(err);
|
|
67
78
|
return;
|
|
68
79
|
}
|
|
69
|
-
console.error(
|
|
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
|
|
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(
|
|
149
|
+
jsonError(err);
|
|
145
150
|
return;
|
|
146
151
|
}
|
|
147
|
-
console.error(
|
|
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
|
|
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(
|
|
202
|
+
jsonError(err);
|
|
204
203
|
return;
|
|
205
204
|
}
|
|
206
|
-
console.error(
|
|
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
|
|
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(
|
|
272
|
+
jsonError(err);
|
|
280
273
|
return;
|
|
281
274
|
}
|
|
282
|
-
console.error(
|
|
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
|
|
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(
|
|
321
|
+
jsonError(err);
|
|
335
322
|
return;
|
|
336
323
|
}
|
|
337
|
-
console.error(
|
|
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
|
|
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(
|
|
360
|
+
jsonError(err);
|
|
380
361
|
return;
|
|
381
362
|
}
|
|
382
|
-
console.error(
|
|
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
|
|
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
|
|
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(
|
|
439
|
+
jsonError(err);
|
|
467
440
|
return;
|
|
468
441
|
}
|
|
469
|
-
console.error(
|
|
442
|
+
console.error(formatError(err, { verbose: false }));
|
|
470
443
|
process.exitCode = 1;
|
|
471
444
|
}
|
|
472
445
|
});
|
package/src/cmd/firehose.js
CHANGED
|
@@ -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.
|
|
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
|
|
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(
|
|
60
|
+
jsonError(err);
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
|
-
console.error(
|
|
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(
|
|
101
|
+
jsonError(err);
|
|
103
102
|
return;
|
|
104
103
|
}
|
|
105
|
-
console.error(
|
|
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(
|
|
137
|
+
jsonError(err);
|
|
140
138
|
return;
|
|
141
139
|
}
|
|
142
|
-
console.error(
|
|
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
|
|
82
|
+
console.error(formatError(err, { verbose: false }));
|
|
80
83
|
process.exitCode = 1;
|
|
81
84
|
}
|
|
82
85
|
});
|
package/src/cmd/inbox.js
CHANGED
|
@@ -5,6 +5,7 @@ import { DEFAULT_EXPLORE_URL } from '../lib/constants.js';
|
|
|
5
5
|
import { readBeaconSet } 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);
|
|
@@ -67,7 +68,7 @@ export default function register(program) {
|
|
|
67
68
|
if (!res.ok) throw new Error(`explore API returned ${res.status}`);
|
|
68
69
|
data = await res.json();
|
|
69
70
|
} catch (err) {
|
|
70
|
-
const msg =
|
|
71
|
+
const msg = errorMessage(err);
|
|
71
72
|
const finalMsg = msg.startsWith('explore API returned ')
|
|
72
73
|
? msg
|
|
73
74
|
: unavailableMessage(baseUrl);
|
|
@@ -119,12 +120,11 @@ export default function register(program) {
|
|
|
119
120
|
console.log(`tip: 'vit vouch <ref> --kind want' to signal demand`);
|
|
120
121
|
console.log(` 'vit ship --recap <ref>' to ship an implementation`);
|
|
121
122
|
} catch (err) {
|
|
122
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
123
123
|
if (opts.json) {
|
|
124
|
-
jsonError(
|
|
124
|
+
jsonError(err);
|
|
125
125
|
return;
|
|
126
126
|
}
|
|
127
|
-
console.error(
|
|
127
|
+
console.error(formatError(err, { verbose: false }));
|
|
128
128
|
process.exitCode = 1;
|
|
129
129
|
}
|
|
130
130
|
});
|
package/src/cmd/init.js
CHANGED
|
@@ -9,6 +9,7 @@ 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
11
|
import { jsonOk, jsonError } from '../lib/json-output.js';
|
|
12
|
+
import { errorMessage, formatError } from '../lib/error-format.js';
|
|
12
13
|
|
|
13
14
|
export default function register(program) {
|
|
14
15
|
program
|
|
@@ -80,7 +81,8 @@ export default function register(program) {
|
|
|
80
81
|
if (hasVitDir) {
|
|
81
82
|
console.log(`hint: run: ${name} init --beacon <canonical-git-url>`);
|
|
82
83
|
} else {
|
|
83
|
-
console.log(`hint: run ${name} init
|
|
84
|
+
console.log(`hint: navigate to a git repository and run '${name} init' there.`);
|
|
85
|
+
console.log(` to start fresh: git init && git remote add origin <your-repo-url>`);
|
|
84
86
|
}
|
|
85
87
|
return;
|
|
86
88
|
}
|
|
@@ -97,7 +99,8 @@ export default function register(program) {
|
|
|
97
99
|
.trim()
|
|
98
100
|
.split('\n')
|
|
99
101
|
.filter(Boolean);
|
|
100
|
-
} catch {
|
|
102
|
+
} catch (err) {
|
|
103
|
+
console.warn(`warning: failed to list git remotes: ${errorMessage(err)}`);
|
|
101
104
|
remoteNames = [];
|
|
102
105
|
}
|
|
103
106
|
if (verbose) vlog(`[verbose] remotes detected: ${remoteNames.length > 0 ? remoteNames.join(', ') : 'none'}`);
|
|
@@ -110,7 +113,9 @@ export default function register(program) {
|
|
|
110
113
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
111
114
|
}).trim();
|
|
112
115
|
if (url) remotes.push({ name, url });
|
|
113
|
-
} catch {
|
|
116
|
+
} catch (err) {
|
|
117
|
+
console.warn(`warning: failed to read git remote ${name} url: ${errorMessage(err)}`);
|
|
118
|
+
}
|
|
114
119
|
}
|
|
115
120
|
if (verbose && remotes.length > 0) {
|
|
116
121
|
vlog(`[verbose] remote urls: ${remotes.map(r => `${r.name}=${r.url}`).join(' ')}`);
|
|
@@ -230,12 +235,11 @@ export default function register(program) {
|
|
|
230
235
|
console.log(`${mark} secondary beacon: ${merged.secondaryBeacon}`);
|
|
231
236
|
}
|
|
232
237
|
} catch (err) {
|
|
233
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
234
238
|
if (opts.json) {
|
|
235
|
-
jsonError(
|
|
239
|
+
jsonError(err);
|
|
236
240
|
return;
|
|
237
241
|
}
|
|
238
|
-
console.error(
|
|
242
|
+
console.error(formatError(err, { verbose: opts.verbose }));
|
|
239
243
|
process.exitCode = 1;
|
|
240
244
|
}
|
|
241
245
|
});
|