vit 0.0.1 → 0.1.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/LICENSE +1 -1
- package/README.md +94 -2
- package/bin/vit.js +7 -0
- package/package.json +29 -18
- package/src/cli.js +52 -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 +193 -0
- package/src/cmd/explore.js +477 -0
- package/src/cmd/firehose.js +159 -0
- package/src/cmd/follow.js +143 -0
- package/src/cmd/hack.js +83 -0
- package/src/cmd/init.js +242 -0
- package/src/cmd/learn.js +244 -0
- package/src/cmd/link.js +75 -0
- package/src/cmd/login.js +267 -0
- package/src/cmd/remix.js +181 -0
- package/src/cmd/scan.js +207 -0
- package/src/cmd/setup.js +76 -0
- package/src/cmd/ship.js +610 -0
- package/src/cmd/skim.js +183 -0
- package/src/cmd/vet.js +609 -0
- package/src/cmd/vouch.js +277 -0
- package/src/lib/agent.js +37 -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 +48 -0
- package/src/lib/constants.js +8 -0
- package/src/lib/json-output.js +13 -0
- package/src/lib/oauth.js +149 -0
- package/src/lib/paths.js +10 -0
- package/src/lib/pds.js +79 -0
- package/src/lib/sandbox.js +37 -0
- package/src/lib/skill-ref.js +37 -0
- package/src/lib/trust-gate.js +39 -0
- package/src/lib/vit-dir.js +69 -0
- package/.npmignore +0 -37
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,2 +1,94 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://v-it.org">
|
|
3
|
+
<img src="docs/brand/vit-wordmark.svg" alt="vit" height="48">
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>open source is social</strong>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://v-it.org"><img src="https://v-it.org/badge/vit-enabled.svg" alt="vit enabled"></a>
|
|
13
|
+
<a href="https://v-it.org"><img src="https://v-it.org/badge/social-open-source.svg" alt="open source is social"></a>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
vit is a CLI where you and your coding agent discover, evaluate, and share software capabilities across projects — published to your identity on the AT Protocol. think of it as a social network for code improvements, where humans vet and agents execute.
|
|
19
|
+
|
|
20
|
+
**[get started](https://v-it.org/start/)** · **[read the doctrine](https://v-it.org/doctrine/)** · **[explore the network](https://explore.v-it.org)**
|
|
21
|
+
|
|
22
|
+
## quick start
|
|
23
|
+
|
|
24
|
+
**you run this** (terminal):
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install -g vit
|
|
28
|
+
vit setup
|
|
29
|
+
vit login your-handle.bsky.social
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
then open your coding agent (Claude Code, Codex CLI, or Gemini CLI) — it already knows how to use vit because `setup` installed the skill. your agent runs `vit init` to connect your project to the network, then `vit skim` to discover what others have built.
|
|
33
|
+
|
|
34
|
+
**[full getting started guide →](https://v-it.org/start/)**
|
|
35
|
+
|
|
36
|
+
## the verbs
|
|
37
|
+
|
|
38
|
+
four core verbs drive the loop:
|
|
39
|
+
|
|
40
|
+
- **skim** — browse capabilities from people you follow
|
|
41
|
+
- **vet** — evaluate a capability in a sandbox before trusting it
|
|
42
|
+
- **remix** — adapt a vetted capability into your codebase
|
|
43
|
+
- **ship** — publish a new capability to the network
|
|
44
|
+
|
|
45
|
+
and as you go deeper: **vouch** (stake your reputation), **learn** (install agent skills), **follow** (curate your feed), **scan** (discover publishers).
|
|
46
|
+
|
|
47
|
+
see [COMMANDS.md](COMMANDS.md) for the full command reference and [VOCAB.md](VOCAB.md) for the complete vocabulary.
|
|
48
|
+
|
|
49
|
+
## install
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npm install -g vit
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
or try it out without installing:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npx vit doctor
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
for contributors working on vit itself:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
make install
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## works with
|
|
68
|
+
|
|
69
|
+
vit is a human+agent collaboration tool. it works with [Claude Code](https://claude.ai/code), [Codex CLI](https://github.com/openai/codex), and [Gemini CLI](https://github.com/google-gemini/gemini-cli). some commands are for you (setup, login, vet), others are for your agent (skim, remix, ship).
|
|
70
|
+
|
|
71
|
+
## reference
|
|
72
|
+
|
|
73
|
+
- **[COMMANDS.md](COMMANDS.md)** — full command reference
|
|
74
|
+
- **[VOCAB.md](VOCAB.md)** — terminology: capabilities, beacons, skills, and the verbs that drive the workflow
|
|
75
|
+
- **[ARCHITECTURE.md](ARCHITECTURE.md)** — technical design: ATProto record types, cap lexicons, and system internals
|
|
76
|
+
|
|
77
|
+
## contributing
|
|
78
|
+
|
|
79
|
+
contributions to vit happen through vit itself — you ship capabilities, not pull requests. this isn't a policy; it's the product working as designed. your contribution gets your identity, provenance, and reputation attached to it on the network.
|
|
80
|
+
|
|
81
|
+
read [CONTRIBUTING.md](CONTRIBUTING.md) for the full setup and the skim/vet/remix/ship loop.
|
|
82
|
+
|
|
83
|
+
## links
|
|
84
|
+
|
|
85
|
+
- **[homepage](https://v-it.org)** — what vit is and why it exists
|
|
86
|
+
- **[getting started](https://v-it.org/start/)** — prerequisites, setup, and first run
|
|
87
|
+
- **[doctrine](https://v-it.org/doctrine/)** — the philosophy behind social open source
|
|
88
|
+
- **[explore](https://explore.v-it.org)** — browse live capabilities, skills, and projects on the network
|
|
89
|
+
- **[lexicons](https://lexicon.garden/nsid/org.v-it.cap)** — published AT Protocol schemas (cap, skill, vouch)
|
|
90
|
+
- **[contributing](CONTRIBUTING.md)** — how to contribute to vit itself
|
|
91
|
+
|
|
92
|
+
## license
|
|
93
|
+
|
|
94
|
+
[MIT](LICENSE) — built by [sol pbc](https://solpbc.org), a public benefit corporation.
|
package/bin/vit.js
ADDED
package/package.json
CHANGED
|
@@ -1,24 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vit",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
},
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/jkup/vit.git"
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "Social toolkit for personalized software",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"bin": {
|
|
7
|
+
"vit": "bin/vit.js"
|
|
12
8
|
},
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"electron"
|
|
9
|
+
"files": [
|
|
10
|
+
"bin/",
|
|
11
|
+
"src/"
|
|
17
12
|
],
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
13
|
+
"type": "module",
|
|
14
|
+
"scripts": {},
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=20.0.0"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@atproto/api": "^0.18.20",
|
|
20
|
+
"@atproto/common-web": "^0.4.16",
|
|
21
|
+
"@atproto/oauth-client-node": "^0.3.16",
|
|
22
|
+
"@ipld/dag-cbor": "^9.2.0",
|
|
23
|
+
"@noble/curves": "^1.8.0",
|
|
24
|
+
"@noble/hashes": "^1.7.0",
|
|
25
|
+
"@scure/bip39": "2.0.1",
|
|
26
|
+
"bs58": "^6.0.0",
|
|
27
|
+
"commander": "^13.0.0",
|
|
28
|
+
"env-paths": "4.0.0",
|
|
29
|
+
"isomorphic-git": "1.37.0",
|
|
30
|
+
"memfs": "4.56.10"
|
|
22
31
|
},
|
|
23
|
-
"
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"marked": "^17.0.4"
|
|
34
|
+
}
|
|
24
35
|
}
|
package/src/cli.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
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 registerExplore from './cmd/explore.js';
|
|
11
|
+
import registerInit from './cmd/init.js';
|
|
12
|
+
import registerLearn from './cmd/learn.js';
|
|
13
|
+
import registerLogin from './cmd/login.js';
|
|
14
|
+
import registerFirehose from './cmd/firehose.js';
|
|
15
|
+
import registerScan from './cmd/scan.js';
|
|
16
|
+
import registerRemix from './cmd/remix.js';
|
|
17
|
+
import registerShip from './cmd/ship.js';
|
|
18
|
+
import registerSkim from './cmd/skim.js';
|
|
19
|
+
import registerVet from './cmd/vet.js';
|
|
20
|
+
import registerVouch from './cmd/vouch.js';
|
|
21
|
+
import registerFollow from './cmd/follow.js';
|
|
22
|
+
import registerSetup from './cmd/setup.js';
|
|
23
|
+
import registerHack from './cmd/hack.js';
|
|
24
|
+
import registerLink from './cmd/link.js';
|
|
25
|
+
|
|
26
|
+
const program = new Command();
|
|
27
|
+
program
|
|
28
|
+
.name('vit')
|
|
29
|
+
.description(`${brand} \u2014 social open source`)
|
|
30
|
+
.version('0.1.0');
|
|
31
|
+
|
|
32
|
+
registerAdopt(program);
|
|
33
|
+
registerBeacon(program);
|
|
34
|
+
registerConfig(program);
|
|
35
|
+
registerDoctor(program);
|
|
36
|
+
registerExplore(program);
|
|
37
|
+
registerInit(program);
|
|
38
|
+
registerLearn(program);
|
|
39
|
+
registerLogin(program);
|
|
40
|
+
registerFirehose(program);
|
|
41
|
+
registerScan(program);
|
|
42
|
+
registerShip(program);
|
|
43
|
+
registerSkim(program);
|
|
44
|
+
registerRemix(program);
|
|
45
|
+
registerVet(program);
|
|
46
|
+
registerVouch(program);
|
|
47
|
+
registerFollow(program);
|
|
48
|
+
registerSetup(program);
|
|
49
|
+
registerHack(program);
|
|
50
|
+
registerLink(program);
|
|
51
|
+
|
|
52
|
+
export { program };
|
package/src/cmd/adopt.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
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: MIT
|
|
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: MIT
|
|
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,193 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
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, lstatSync, readdirSync, readFileSync } from 'node:fs';
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
import { homedir } from 'node:os';
|
|
10
|
+
import { mark, name } from '../lib/brand.js';
|
|
11
|
+
import { which } from '../lib/compat.js';
|
|
12
|
+
import { jsonOk, jsonError } from '../lib/json-output.js';
|
|
13
|
+
import { configPath } from '../lib/paths.js';
|
|
14
|
+
|
|
15
|
+
function scanSkillDir(dir) {
|
|
16
|
+
const skills = [];
|
|
17
|
+
if (!existsSync(dir)) return skills;
|
|
18
|
+
try {
|
|
19
|
+
const entries = readdirSync(dir, { withFileTypes: true });
|
|
20
|
+
for (const entry of entries) {
|
|
21
|
+
if (!entry.isDirectory()) continue;
|
|
22
|
+
const skillMd = join(dir, entry.name, 'SKILL.md');
|
|
23
|
+
if (existsSync(skillMd)) {
|
|
24
|
+
let version = null;
|
|
25
|
+
try {
|
|
26
|
+
const content = readFileSync(skillMd, 'utf-8');
|
|
27
|
+
const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
28
|
+
if (match) {
|
|
29
|
+
const versionMatch = match[1].match(/^version:\s*(.+)$/m);
|
|
30
|
+
if (versionMatch) version = versionMatch[1].trim();
|
|
31
|
+
}
|
|
32
|
+
} catch { /* ignore read errors */ }
|
|
33
|
+
skills.push({ name: entry.name, version });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
} catch { /* ignore dir read errors */ }
|
|
37
|
+
return skills;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default function register(program) {
|
|
41
|
+
async function checkHealth(opts) {
|
|
42
|
+
try {
|
|
43
|
+
const config = loadConfig();
|
|
44
|
+
const setup = {
|
|
45
|
+
done: !!config.setup_at,
|
|
46
|
+
at: config.setup_at ? new Date(config.setup_at * 1000).toISOString() : null,
|
|
47
|
+
};
|
|
48
|
+
let installType = 'not on PATH';
|
|
49
|
+
let vitPath = which(name);
|
|
50
|
+
let installPath = vitPath || null;
|
|
51
|
+
let beacon = null;
|
|
52
|
+
let skillInstalled = false;
|
|
53
|
+
let projectSkills = [];
|
|
54
|
+
let userSkills = [];
|
|
55
|
+
let blueskyOk = false;
|
|
56
|
+
let pds = null;
|
|
57
|
+
|
|
58
|
+
if (config.setup_at) {
|
|
59
|
+
const when = new Date(config.setup_at * 1000).toISOString();
|
|
60
|
+
if (!opts.json) console.log(`${mark} setup: ok (${when})`);
|
|
61
|
+
} else {
|
|
62
|
+
if (!opts.json) console.log(`${mark} setup: not done (run ${name} setup)`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (!vitPath) {
|
|
66
|
+
installType = 'not on PATH';
|
|
67
|
+
if (!opts.json) console.log(`${mark} install: not on PATH`);
|
|
68
|
+
} else {
|
|
69
|
+
try {
|
|
70
|
+
if (lstatSync(vitPath).isSymbolicLink()) {
|
|
71
|
+
installType = 'linked';
|
|
72
|
+
if (!opts.json) console.log(`${mark} install: linked (${vitPath})`);
|
|
73
|
+
} else if (vitPath.includes('node_modules')) {
|
|
74
|
+
installType = 'global';
|
|
75
|
+
if (!opts.json) console.log(`${mark} install: global`);
|
|
76
|
+
} else {
|
|
77
|
+
installType = 'source';
|
|
78
|
+
if (!opts.json) console.log(`${mark} install: source (${vitPath})`);
|
|
79
|
+
}
|
|
80
|
+
} catch {
|
|
81
|
+
installType = 'source';
|
|
82
|
+
if (!opts.json) console.log(`${mark} install: source (${vitPath})`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const projConfig = readProjectConfig();
|
|
87
|
+
beacon = projConfig.beacon || null;
|
|
88
|
+
if (projConfig.beacon) {
|
|
89
|
+
if (!opts.json) console.log(`${mark} beacon: ${projConfig.beacon}`);
|
|
90
|
+
} else {
|
|
91
|
+
if (!opts.json) console.log(`${mark} beacon: not set`);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const skillPath = join(process.cwd(), '.claude', 'skills', 'using-vit', 'SKILL.md');
|
|
95
|
+
skillInstalled = existsSync(skillPath);
|
|
96
|
+
if (existsSync(skillPath)) {
|
|
97
|
+
if (!opts.json) console.log(`${mark} skill: ok (using-vit)`);
|
|
98
|
+
} else {
|
|
99
|
+
if (!opts.json) console.log(`${mark} skill: not installed (run ${name} setup)`);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Report installed skills
|
|
103
|
+
const projectSkillDir = join(process.cwd(), '.claude', 'skills');
|
|
104
|
+
projectSkills = scanSkillDir(projectSkillDir);
|
|
105
|
+
const userSkillDir = join(homedir(), '.claude', 'skills');
|
|
106
|
+
userSkills = scanSkillDir(userSkillDir);
|
|
107
|
+
|
|
108
|
+
if (!opts.json && projectSkills.length > 0) {
|
|
109
|
+
console.log(`${mark} project skills: ${projectSkills.length} installed`);
|
|
110
|
+
for (const s of projectSkills) {
|
|
111
|
+
const ver = s.version ? ` v${s.version}` : '';
|
|
112
|
+
console.log(` ${s.name}${ver}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (!opts.json && userSkills.length > 0) {
|
|
116
|
+
console.log(`${mark} user skills: ${userSkills.length} installed`);
|
|
117
|
+
for (const s of userSkills) {
|
|
118
|
+
const ver = s.version ? ` v${s.version}` : '';
|
|
119
|
+
console.log(` ${s.name}${ver}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
let effectiveDid = config.did;
|
|
124
|
+
let identitySource = effectiveDid ? 'global' : null;
|
|
125
|
+
let authType = 'oauth';
|
|
126
|
+
|
|
127
|
+
const localLoginPath = join(process.cwd(), '.vit', 'login.json');
|
|
128
|
+
try {
|
|
129
|
+
if (existsSync(localLoginPath)) {
|
|
130
|
+
const local = JSON.parse(readFileSync(localLoginPath, 'utf-8'));
|
|
131
|
+
if (local.did) {
|
|
132
|
+
effectiveDid = local.did;
|
|
133
|
+
identitySource = 'local';
|
|
134
|
+
authType = local.type || 'oauth';
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
} catch {}
|
|
138
|
+
|
|
139
|
+
if (!identitySource && effectiveDid) identitySource = 'global';
|
|
140
|
+
|
|
141
|
+
if (identitySource === 'global' && effectiveDid) {
|
|
142
|
+
try {
|
|
143
|
+
const raw = readFileSync(configPath('session.json'), 'utf-8');
|
|
144
|
+
const sessionData = JSON.parse(raw);
|
|
145
|
+
if (sessionData[effectiveDid]?.type === 'app-password') authType = 'app-password';
|
|
146
|
+
} catch {}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (!effectiveDid) {
|
|
150
|
+
if (!opts.json) console.log(`${mark} bluesky: not logged in (run ${name} login <handle>)`);
|
|
151
|
+
} else {
|
|
152
|
+
try {
|
|
153
|
+
const { session } = await restoreAgent(effectiveDid);
|
|
154
|
+
blueskyOk = true;
|
|
155
|
+
pds = session.serverMetadata?.issuer || null;
|
|
156
|
+
if (!opts.json) console.log(`${mark} bluesky: ok (${session.did || effectiveDid}${pds ? ', ' + pds : ''})`);
|
|
157
|
+
} catch {
|
|
158
|
+
if (!opts.json) console.log(`${mark} bluesky: token expired or invalid (run ${name} login <handle>)`);
|
|
159
|
+
}
|
|
160
|
+
if (!opts.json) console.log(`${mark} identity: ${identitySource} (${authType})`);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (opts.json) {
|
|
164
|
+
jsonOk({
|
|
165
|
+
setup,
|
|
166
|
+
install: { type: installType, path: installPath },
|
|
167
|
+
beacon,
|
|
168
|
+
skill: skillInstalled,
|
|
169
|
+
projectSkills,
|
|
170
|
+
userSkills,
|
|
171
|
+
bluesky: { ok: blueskyOk, did: effectiveDid || null, pds, source: identitySource, authType },
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
} catch (err) {
|
|
175
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
176
|
+
if (opts.json) {
|
|
177
|
+
jsonError(msg);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
console.error(msg);
|
|
181
|
+
process.exitCode = 1;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
program.command('doctor')
|
|
186
|
+
.description('Verify vit environment and project configuration')
|
|
187
|
+
.option('--json', 'Output as JSON')
|
|
188
|
+
.action(checkHealth);
|
|
189
|
+
program.command('status')
|
|
190
|
+
.description('Alias for doctor')
|
|
191
|
+
.option('--json', 'Output as JSON')
|
|
192
|
+
.action(checkHealth);
|
|
193
|
+
}
|