vit 0.0.1 → 0.1.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/LICENSE +661 -21
- package/README.md +116 -2
- package/bin/vit.js +7 -0
- package/package.json +25 -18
- package/src/cli.js +42 -0
- package/src/cmd/adopt.js +92 -0
- package/src/cmd/beacon.js +62 -0
- package/src/cmd/config.js +63 -0
- package/src/cmd/doctor.js +59 -0
- package/src/cmd/firehose.js +148 -0
- package/src/cmd/follow.js +94 -0
- package/src/cmd/init.js +160 -0
- package/src/cmd/login.js +185 -0
- package/src/cmd/remix.js +136 -0
- package/src/cmd/setup.js +76 -0
- package/src/cmd/ship.js +195 -0
- package/src/cmd/skim.js +113 -0
- package/src/cmd/vet.js +141 -0
- package/src/cmd/vouch.js +134 -0
- package/src/lib/agent.js +27 -0
- package/src/lib/beacon.js +97 -0
- package/src/lib/brand.js +20 -0
- package/src/lib/cap-ref.js +23 -0
- package/src/lib/compat.js +20 -0
- package/src/lib/config.js +39 -0
- package/src/lib/constants.js +5 -0
- package/src/lib/oauth.js +106 -0
- package/src/lib/paths.js +10 -0
- package/src/lib/sandbox.js +37 -0
- package/src/lib/vit-dir.js +61 -0
- package/.npmignore +0 -37
package/README.md
CHANGED
|
@@ -1,2 +1,116 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
[](https://v-it.org)
|
|
2
|
+
[](https://v-it.org)
|
|
3
|
+
|
|
4
|
+
# v̇it manifesto
|
|
5
|
+
|
|
6
|
+
vit is a **social system for personalized software** where the unit of exchange is not pull requests, not screenshots, not diffs, not even git.
|
|
7
|
+
|
|
8
|
+
the unit of exchange is **capability**: structured, attributable, auditable capabilities, published into a network where other builders (and their agents) can **discover it, remix it into their own codebases, vet it locally, vouch for it publicly, and ship new capabilities back into the stream**.
|
|
9
|
+
|
|
10
|
+
vit is how software becomes *organic* and *yours*.
|
|
11
|
+
|
|
12
|
+
## install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npx vit doctor
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
or install globally:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install -g vit
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
for development:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
make install
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## terminology
|
|
31
|
+
|
|
32
|
+
- **beacon** — canonical project identity derived from normalized git URLs; anchors all project-scoped vit activity; stored in `.vit/config.json`
|
|
33
|
+
- **init** — initialize `.vit/` in the current repo and validate beacon configuration
|
|
34
|
+
- **doctor** — verify system environment and project configuration
|
|
35
|
+
- **adopt** — adopt an existing project by its beacon; forks or clones and initializes locally
|
|
36
|
+
- **follow** — subscribe to ATProto handles for cap discovery
|
|
37
|
+
- **skim** — read caps from followed agents and the beacon repo
|
|
38
|
+
- **vet** — run local evaluation on a cap in a sandbox environment
|
|
39
|
+
- **vouch** — publicly endorse a vetted cap
|
|
40
|
+
- **remix** — derive a vetted cap into the local codebase and create an implementation plan
|
|
41
|
+
- **ship** — publish a new cap to your feed (or a recap when sourced from a remix)
|
|
42
|
+
|
|
43
|
+
## beacon
|
|
44
|
+
|
|
45
|
+
probe a remote repo for its beacon.
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
vit beacon https://github.com/solpbc/vit.git
|
|
49
|
+
vit beacon vit:github.com/solpbc/vit
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
| option | description |
|
|
53
|
+
|---|---|
|
|
54
|
+
| `-v, --verbose` | show step-by-step details |
|
|
55
|
+
|
|
56
|
+
## login
|
|
57
|
+
|
|
58
|
+
log in to Bluesky via browser-based OAuth.
|
|
59
|
+
|
|
60
|
+
### usage
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
vit login alice.bsky.social
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
this will:
|
|
67
|
+
1. start a temporary localhost callback server
|
|
68
|
+
2. open your browser to the Bluesky authorization page
|
|
69
|
+
3. after you approve, print your DID
|
|
70
|
+
4. save your DID to `vit.json` and OAuth session to `session.json`
|
|
71
|
+
|
|
72
|
+
### options
|
|
73
|
+
|
|
74
|
+
- `-v, --verbose` - show discovery and protocol details
|
|
75
|
+
- `--force` - force re-login, skip session validation
|
|
76
|
+
|
|
77
|
+
## firehose
|
|
78
|
+
|
|
79
|
+
listen to Bluesky Jetstream for custom record events.
|
|
80
|
+
|
|
81
|
+
### usage
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
vit firehose
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### options
|
|
88
|
+
|
|
89
|
+
- `--did <did>` - filter by DID (reads saved DID from config if not provided)
|
|
90
|
+
- `--collection <nsid>` - collection NSID to filter (default: `org.v-it.cap`)
|
|
91
|
+
- `-v, --verbose` - show full JSON for each event
|
|
92
|
+
|
|
93
|
+
## ship
|
|
94
|
+
|
|
95
|
+
write a cap (org.v-it.cap record) to the authenticated PDS.
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
vit ship "hello from caps"
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
| option | description |
|
|
102
|
+
|---|---|
|
|
103
|
+
| `--did <did>` | DID to use (default: from config) |
|
|
104
|
+
|
|
105
|
+
## skim
|
|
106
|
+
|
|
107
|
+
list caps from the authenticated PDS.
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
vit skim
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
| option | description |
|
|
114
|
+
|---|---|
|
|
115
|
+
| `--did <did>` | DID to use (default: from config) |
|
|
116
|
+
| `--limit <n>` | max records to return (default: 25) |
|
package/bin/vit.js
ADDED
package/package.json
CHANGED
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vit",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Social toolkit for personalized software",
|
|
5
|
+
"license": "AGPL-3.0-only",
|
|
6
|
+
"bin": {
|
|
7
|
+
"vit": "bin/vit.js"
|
|
8
8
|
},
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
},
|
|
13
|
-
"keywords": [
|
|
14
|
-
"web",
|
|
15
|
-
"browser",
|
|
16
|
-
"electron"
|
|
9
|
+
"files": [
|
|
10
|
+
"bin/",
|
|
11
|
+
"src/"
|
|
17
12
|
],
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
"url": "https://github.com/jkup/vit/issues"
|
|
13
|
+
"type": "module",
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=20.0.0"
|
|
22
16
|
},
|
|
23
|
-
"
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@atproto/api": "^0.18.20",
|
|
19
|
+
"@atproto/common-web": "^0.4.16",
|
|
20
|
+
"@atproto/oauth-client-node": "^0.3.16",
|
|
21
|
+
"@ipld/dag-cbor": "^9.2.0",
|
|
22
|
+
"@noble/curves": "^1.8.0",
|
|
23
|
+
"@noble/hashes": "^1.7.0",
|
|
24
|
+
"@scure/bip39": "2.0.1",
|
|
25
|
+
"bs58": "^6.0.0",
|
|
26
|
+
"commander": "^13.0.0",
|
|
27
|
+
"env-paths": "4.0.0",
|
|
28
|
+
"isomorphic-git": "1.37.0",
|
|
29
|
+
"memfs": "4.56.10"
|
|
30
|
+
}
|
|
24
31
|
}
|
package/src/cli.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// Copyright (c) 2026 sol pbc
|
|
3
|
+
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
import { brand } from './lib/brand.js';
|
|
6
|
+
import registerAdopt from './cmd/adopt.js';
|
|
7
|
+
import registerBeacon from './cmd/beacon.js';
|
|
8
|
+
import registerConfig from './cmd/config.js';
|
|
9
|
+
import registerDoctor from './cmd/doctor.js';
|
|
10
|
+
import registerInit from './cmd/init.js';
|
|
11
|
+
import registerLogin from './cmd/login.js';
|
|
12
|
+
import registerFirehose from './cmd/firehose.js';
|
|
13
|
+
import registerRemix from './cmd/remix.js';
|
|
14
|
+
import registerShip from './cmd/ship.js';
|
|
15
|
+
import registerSkim from './cmd/skim.js';
|
|
16
|
+
import registerVet from './cmd/vet.js';
|
|
17
|
+
import registerVouch from './cmd/vouch.js';
|
|
18
|
+
import registerFollow from './cmd/follow.js';
|
|
19
|
+
import registerSetup from './cmd/setup.js';
|
|
20
|
+
|
|
21
|
+
const program = new Command();
|
|
22
|
+
program
|
|
23
|
+
.name('vit')
|
|
24
|
+
.description(`${brand} \u2014 social open source`)
|
|
25
|
+
.version('0.1.0');
|
|
26
|
+
|
|
27
|
+
registerAdopt(program);
|
|
28
|
+
registerBeacon(program);
|
|
29
|
+
registerConfig(program);
|
|
30
|
+
registerDoctor(program);
|
|
31
|
+
registerInit(program);
|
|
32
|
+
registerLogin(program);
|
|
33
|
+
registerFirehose(program);
|
|
34
|
+
registerShip(program);
|
|
35
|
+
registerSkim(program);
|
|
36
|
+
registerRemix(program);
|
|
37
|
+
registerVet(program);
|
|
38
|
+
registerVouch(program);
|
|
39
|
+
registerFollow(program);
|
|
40
|
+
registerSetup(program);
|
|
41
|
+
|
|
42
|
+
export { program };
|
package/src/cmd/adopt.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// Copyright (c) 2026 sol pbc
|
|
3
|
+
|
|
4
|
+
import { existsSync } from 'node:fs';
|
|
5
|
+
import { resolve } from 'node:path';
|
|
6
|
+
import { execFileSync } from 'node:child_process';
|
|
7
|
+
import { parseGitUrl, toBeacon, beaconToHttps } from '../lib/beacon.js';
|
|
8
|
+
import { requireNotAgent } from '../lib/agent.js';
|
|
9
|
+
import { which } from '../lib/compat.js';
|
|
10
|
+
import { mark, name } from '../lib/brand.js';
|
|
11
|
+
|
|
12
|
+
export default function register(program) {
|
|
13
|
+
program
|
|
14
|
+
.command('adopt')
|
|
15
|
+
.argument('<beacon>', 'Beacon URI, git URL, or slug to adopt (e.g. vit:github.com/org/repo)')
|
|
16
|
+
.argument('[name]', 'Local directory name (defaults to repo name)')
|
|
17
|
+
.description('Fork or clone a project')
|
|
18
|
+
.option('-v, --verbose', 'Show step-by-step details')
|
|
19
|
+
.action(async (beacon, targetName, opts) => {
|
|
20
|
+
try {
|
|
21
|
+
const gate = requireNotAgent();
|
|
22
|
+
if (!gate.ok) {
|
|
23
|
+
console.error(`${name} adopt must be run by a human. run it in your own terminal.`);
|
|
24
|
+
process.exitCode = 1;
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const { verbose } = opts;
|
|
29
|
+
|
|
30
|
+
// resolve beacon
|
|
31
|
+
if (verbose) console.log(`[verbose] resolving beacon: ${beacon}`);
|
|
32
|
+
const httpsUrl = beaconToHttps(beacon);
|
|
33
|
+
const parsed = parseGitUrl(httpsUrl);
|
|
34
|
+
const beaconUri = 'vit:' + toBeacon(httpsUrl);
|
|
35
|
+
if (verbose) console.log(`[verbose] beacon: ${beaconUri}`);
|
|
36
|
+
if (verbose) console.log(`[verbose] https: ${httpsUrl}`);
|
|
37
|
+
|
|
38
|
+
// determine directory name
|
|
39
|
+
const dirName = targetName || parsed.repo;
|
|
40
|
+
const dirPath = resolve(dirName);
|
|
41
|
+
if (verbose) console.log(`[verbose] target directory: ${dirPath}`);
|
|
42
|
+
|
|
43
|
+
// fail fast if directory exists
|
|
44
|
+
if (existsSync(dirPath)) {
|
|
45
|
+
console.error(`Directory already exists: ${dirName}`);
|
|
46
|
+
process.exitCode = 1;
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// detect gh + github host
|
|
51
|
+
const ghPath = which('gh');
|
|
52
|
+
const isGitHub = parsed.host === 'github.com';
|
|
53
|
+
if (verbose) console.log(`[verbose] gh available: ${ghPath ? 'yes' : 'no'}, github host: ${isGitHub ? 'yes' : 'no'}`);
|
|
54
|
+
|
|
55
|
+
if (ghPath && isGitHub) {
|
|
56
|
+
if (verbose) console.log(`[verbose] gh found at ${ghPath}, forking via gh`);
|
|
57
|
+
try {
|
|
58
|
+
execFileSync('gh', ['repo', 'fork', httpsUrl, '--clone', '--', dirName], {
|
|
59
|
+
encoding: 'utf-8',
|
|
60
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
61
|
+
});
|
|
62
|
+
} catch (err) {
|
|
63
|
+
console.error(`Fork failed: ${(err.stderr || err.message || '').trim()}`);
|
|
64
|
+
process.exitCode = 1;
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
if (verbose) console.log(`[verbose] cloning via git`);
|
|
69
|
+
try {
|
|
70
|
+
execFileSync('git', ['clone', httpsUrl, dirName], {
|
|
71
|
+
encoding: 'utf-8',
|
|
72
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
73
|
+
});
|
|
74
|
+
} catch (err) {
|
|
75
|
+
console.error(`Clone failed: ${(err.stderr || err.message || '').trim()}`);
|
|
76
|
+
process.exitCode = 1;
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// success output
|
|
82
|
+
console.log(`${mark} beacon: ${beaconUri}`);
|
|
83
|
+
console.log(`${mark} directory: ${dirName}`);
|
|
84
|
+
console.log(`run: cd ${dirName}`);
|
|
85
|
+
console.log('');
|
|
86
|
+
console.log(`next: start your agent and ask it to run '${name} init'`);
|
|
87
|
+
} catch (err) {
|
|
88
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
89
|
+
process.exitCode = 1;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// Copyright (c) 2026 sol pbc
|
|
3
|
+
|
|
4
|
+
import git from 'isomorphic-git';
|
|
5
|
+
import http from 'isomorphic-git/http/node';
|
|
6
|
+
import { memfs } from 'memfs';
|
|
7
|
+
import { beaconToHttps } from '../lib/beacon.js';
|
|
8
|
+
import { mark } from '../lib/brand.js';
|
|
9
|
+
|
|
10
|
+
async function readTreeFile(fs, dir, treeOid, pathParts) {
|
|
11
|
+
for (let i = 0; i < pathParts.length; i++) {
|
|
12
|
+
const entries = (await git.readObject({ fs, dir, oid: treeOid, format: 'parsed' })).object;
|
|
13
|
+
const entry = entries.find(e => e.path === pathParts[i]);
|
|
14
|
+
if (!entry) return null;
|
|
15
|
+
if (i === pathParts.length - 1) {
|
|
16
|
+
const blob = await git.readObject({ fs, dir, oid: entry.oid, format: 'content' });
|
|
17
|
+
return new TextDecoder().decode(blob.object);
|
|
18
|
+
}
|
|
19
|
+
treeOid = entry.oid;
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default function register(program) {
|
|
25
|
+
program
|
|
26
|
+
.command('beacon')
|
|
27
|
+
.description('Probe a remote repo for its beacon')
|
|
28
|
+
.argument('<target>', 'vit: URI or git URL to probe')
|
|
29
|
+
.option('-v, --verbose', 'Show step-by-step details')
|
|
30
|
+
.action(async (target, opts) => {
|
|
31
|
+
try {
|
|
32
|
+
const { verbose } = opts;
|
|
33
|
+
const url = beaconToHttps(target);
|
|
34
|
+
if (verbose) console.log(`[verbose] Resolved URL: ${url}`);
|
|
35
|
+
const { fs } = memfs();
|
|
36
|
+
const dir = '/';
|
|
37
|
+
|
|
38
|
+
if (verbose) console.log(`[verbose] Cloning (depth=1)...`);
|
|
39
|
+
await git.clone({ fs, http, dir, url, depth: 1, singleBranch: true, noCheckout: true });
|
|
40
|
+
|
|
41
|
+
const head = await git.resolveRef({ fs, dir, ref: 'HEAD' });
|
|
42
|
+
if (verbose) console.log(`[verbose] HEAD resolved: ${head}`);
|
|
43
|
+
const commit = await git.readObject({ fs, dir, oid: head, format: 'parsed' });
|
|
44
|
+
const content = await readTreeFile(fs, dir, commit.object.tree, ['.vit', 'config.json']);
|
|
45
|
+
if (verbose) console.log(`[verbose] Read .vit/config.json: ${content ? 'found' : 'not found'}`);
|
|
46
|
+
|
|
47
|
+
let beacon;
|
|
48
|
+
try {
|
|
49
|
+
beacon = content && JSON.parse(content).beacon;
|
|
50
|
+
} catch {}
|
|
51
|
+
|
|
52
|
+
if (beacon) {
|
|
53
|
+
console.log(`${mark} beacon: lit ${beacon}`);
|
|
54
|
+
} else {
|
|
55
|
+
console.log(`${mark} beacon: unlit`);
|
|
56
|
+
}
|
|
57
|
+
} catch (err) {
|
|
58
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
59
|
+
process.exitCode = 1;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// Copyright (c) 2026 sol pbc
|
|
3
|
+
|
|
4
|
+
import { loadConfig, saveConfig, getScalars } from '../lib/config.js';
|
|
5
|
+
|
|
6
|
+
function coerceValue(str) {
|
|
7
|
+
if (str === 'true') return true;
|
|
8
|
+
if (str === 'false') return false;
|
|
9
|
+
const n = Number(str);
|
|
10
|
+
if (str !== '' && !isNaN(n)) return n;
|
|
11
|
+
return str;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default function register(program) {
|
|
15
|
+
program
|
|
16
|
+
.command('config')
|
|
17
|
+
.description('Read and write vit.json configuration')
|
|
18
|
+
.argument('[action]', 'list (default), set, or delete')
|
|
19
|
+
.argument('[key]', 'configuration key')
|
|
20
|
+
.argument('[value]', 'value to set')
|
|
21
|
+
.action(async (action, key, value) => {
|
|
22
|
+
try {
|
|
23
|
+
// Default to list when no action given
|
|
24
|
+
if (!action || action === 'list') {
|
|
25
|
+
const config = loadConfig();
|
|
26
|
+
for (const [k, v] of getScalars(config)) {
|
|
27
|
+
console.log(`${k}=${v}`);
|
|
28
|
+
}
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (action === 'set') {
|
|
33
|
+
if (!key || value === undefined) {
|
|
34
|
+
console.error('Usage: vit config set <key> <value>');
|
|
35
|
+
process.exitCode = 1;
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const config = loadConfig();
|
|
39
|
+
config[key] = coerceValue(value);
|
|
40
|
+
saveConfig(config);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (action === 'delete') {
|
|
45
|
+
if (!key) {
|
|
46
|
+
console.error('Usage: vit config delete <key>');
|
|
47
|
+
process.exitCode = 1;
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const config = loadConfig();
|
|
51
|
+
delete config[key];
|
|
52
|
+
saveConfig(config);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
console.error(`Unknown action: ${action}`);
|
|
57
|
+
process.exitCode = 1;
|
|
58
|
+
} catch (err) {
|
|
59
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
60
|
+
process.exitCode = 1;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// Copyright (c) 2026 sol pbc
|
|
3
|
+
|
|
4
|
+
import { loadConfig } from '../lib/config.js';
|
|
5
|
+
import { restoreAgent } from '../lib/oauth.js';
|
|
6
|
+
import { readProjectConfig } from '../lib/vit-dir.js';
|
|
7
|
+
import { existsSync } from 'node:fs';
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
import { mark, name } from '../lib/brand.js';
|
|
10
|
+
|
|
11
|
+
export default function register(program) {
|
|
12
|
+
async function checkHealth() {
|
|
13
|
+
try {
|
|
14
|
+
const config = loadConfig();
|
|
15
|
+
if (config.setup_at) {
|
|
16
|
+
const when = new Date(config.setup_at * 1000).toISOString();
|
|
17
|
+
console.log(`${mark} setup: ok (${when})`);
|
|
18
|
+
} else {
|
|
19
|
+
console.log(`${mark} setup: not done (run ${name} setup)`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const projConfig = readProjectConfig();
|
|
23
|
+
if (projConfig.beacon) {
|
|
24
|
+
console.log(`${mark} beacon: ${projConfig.beacon}`);
|
|
25
|
+
} else {
|
|
26
|
+
console.log(`${mark} beacon: not set`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const skillPath = join(process.cwd(), '.claude', 'skills', 'using-vit', 'SKILL.md');
|
|
30
|
+
if (existsSync(skillPath)) {
|
|
31
|
+
console.log(`${mark} skill: ok (using-vit)`);
|
|
32
|
+
} else {
|
|
33
|
+
console.log(`${mark} skill: not installed (run ${name} setup)`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (!config.did) {
|
|
37
|
+
console.log(`${mark} bluesky: not logged in (run ${name} login <handle>)`);
|
|
38
|
+
} else {
|
|
39
|
+
try {
|
|
40
|
+
const { session } = await restoreAgent(config.did);
|
|
41
|
+
const pds = session.serverMetadata?.issuer;
|
|
42
|
+
console.log(`${mark} bluesky: ok (${session.did}${pds ? ', ' + pds : ''})`);
|
|
43
|
+
} catch {
|
|
44
|
+
console.log(`${mark} bluesky: token expired or invalid (run ${name} login <handle>)`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
} catch (err) {
|
|
48
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
49
|
+
process.exitCode = 1;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
program.command('doctor')
|
|
54
|
+
.description('Verify vit environment and project configuration')
|
|
55
|
+
.action(checkHealth);
|
|
56
|
+
program.command('status')
|
|
57
|
+
.description('Alias for doctor')
|
|
58
|
+
.action(checkHealth);
|
|
59
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// Copyright (c) 2026 sol pbc
|
|
3
|
+
|
|
4
|
+
import { loadConfig } from '../lib/config.js';
|
|
5
|
+
import { CAP_COLLECTION } from '../lib/constants.js';
|
|
6
|
+
import { resolveRef } from '../lib/cap-ref.js';
|
|
7
|
+
import { brand } from '../lib/brand.js';
|
|
8
|
+
|
|
9
|
+
const JETSTREAM_URL = 'wss://jetstream2.us-east.bsky.network/subscribe';
|
|
10
|
+
|
|
11
|
+
let ws = null;
|
|
12
|
+
let shuttingDown = false;
|
|
13
|
+
let backoff = 1000;
|
|
14
|
+
|
|
15
|
+
function buildUrl(collection, did, cursor) {
|
|
16
|
+
const url = new URL(JETSTREAM_URL);
|
|
17
|
+
url.searchParams.set('wantedCollections', collection);
|
|
18
|
+
if (did) url.searchParams.set('wantedDids', did);
|
|
19
|
+
if (cursor) url.searchParams.set('cursor', cursor);
|
|
20
|
+
return url.toString();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function formatTime(timeUs) {
|
|
24
|
+
return new Date(timeUs / 1000).toLocaleTimeString();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function formatEvent(event) {
|
|
28
|
+
const time = formatTime(event.time_us);
|
|
29
|
+
const didShort = typeof event.did === 'string' ? event.did.slice(-12) : 'unknown';
|
|
30
|
+
|
|
31
|
+
if (event.kind === 'commit') {
|
|
32
|
+
const operation = event.commit?.operation?.toUpperCase?.() ?? 'UNKNOWN';
|
|
33
|
+
const collection = event.commit?.collection ?? 'unknown';
|
|
34
|
+
const rkey = event.commit?.rkey ?? 'unknown';
|
|
35
|
+
|
|
36
|
+
if (operation === 'DELETE') {
|
|
37
|
+
return `[${time}] ${operation} ${collection} from ${didShort} rkey=${rkey}`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const message = event.commit?.record?.title || event.commit?.record?.text;
|
|
41
|
+
const ref = event.commit?.cid ? resolveRef(event.commit.record, event.commit.cid) : null;
|
|
42
|
+
if (typeof message === 'string') {
|
|
43
|
+
const refPart = ref ? ` (${ref})` : '';
|
|
44
|
+
return `[${time}] ${operation} ${collection} from ${didShort} rkey=${rkey}${refPart} — "${message}"`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return `[${time}] ${operation} ${collection} from ${didShort} rkey=${rkey}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (event.kind === 'identity') {
|
|
51
|
+
return `[${time}] IDENTITY ${didShort}`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (event.kind === 'account') {
|
|
55
|
+
return `[${time}] ACCOUNT ${didShort} status=${event.account?.status}`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return `[${time}] ${event.kind} from ${didShort}`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function connect(opts, cursor) {
|
|
62
|
+
const url = buildUrl(opts.collection, opts.did, cursor);
|
|
63
|
+
let lastCursor = cursor;
|
|
64
|
+
|
|
65
|
+
ws = new WebSocket(url);
|
|
66
|
+
|
|
67
|
+
ws.onopen = () => {
|
|
68
|
+
backoff = 1000;
|
|
69
|
+
console.log(`Connected to ${url}`);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
ws.onmessage = (event) => {
|
|
73
|
+
let msg;
|
|
74
|
+
try {
|
|
75
|
+
msg = JSON.parse(event.data);
|
|
76
|
+
} catch {
|
|
77
|
+
console.log('Warning: failed to parse message as JSON; skipping');
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (msg.time_us) {
|
|
82
|
+
lastCursor = String(msg.time_us);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (opts.verbose) {
|
|
86
|
+
console.log(JSON.stringify(msg, null, 2));
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
console.log(formatEvent(msg));
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
ws.onclose = () => {
|
|
94
|
+
if (shuttingDown) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const delay = backoff;
|
|
99
|
+
backoff = Math.min(backoff * 2, 30000);
|
|
100
|
+
console.log(`Connection closed, reconnecting in ${delay}ms...`);
|
|
101
|
+
setTimeout(() => connect(opts, lastCursor), delay);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
ws.onerror = (err) => {
|
|
105
|
+
const message = err?.message ?? 'unknown error';
|
|
106
|
+
console.error(`WebSocket error: ${message}`);
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export default function register(program) {
|
|
111
|
+
program
|
|
112
|
+
.command('firehose')
|
|
113
|
+
.description('Listen to Jetstream for cap events')
|
|
114
|
+
.option('-v, --verbose', 'Show full JSON for each event')
|
|
115
|
+
.option('--did <did>', 'Filter by DID (reads saved DID from config if not provided)')
|
|
116
|
+
.option('--collection <nsid>', 'Collection NSID to filter', CAP_COLLECTION)
|
|
117
|
+
.action(async (opts) => {
|
|
118
|
+
try {
|
|
119
|
+
if (!opts.did) {
|
|
120
|
+
const config = loadConfig();
|
|
121
|
+
if (config.did) {
|
|
122
|
+
opts.did = config.did;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
for (const sig of ['SIGINT', 'SIGTERM']) {
|
|
127
|
+
process.on(sig, () => {
|
|
128
|
+
shuttingDown = true;
|
|
129
|
+
console.log('\nShutting down...');
|
|
130
|
+
if (ws) ws.close();
|
|
131
|
+
process.exit(0);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const url = buildUrl(opts.collection, opts.did, null);
|
|
136
|
+
console.log(`${brand} firehose`);
|
|
137
|
+
console.log(` Collection: ${opts.collection}`);
|
|
138
|
+
if (opts.did) console.log(` DID filter: ${opts.did}`);
|
|
139
|
+
console.log(` Endpoint: ${url}`);
|
|
140
|
+
console.log(' Ctrl+C to stop\n');
|
|
141
|
+
|
|
142
|
+
connect(opts, null);
|
|
143
|
+
} catch (err) {
|
|
144
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
145
|
+
process.exitCode = 1;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|