vit 0.6.7 → 0.6.9

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.6.7",
3
+ "version": "0.6.9",
4
4
  "description": "Social toolkit for personalized software",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -59,7 +59,7 @@ Handoffs:
59
59
  - Usage: `vit remix <ref>`
60
60
  - Key flags: `--did <did>`, `--verbose`
61
61
  - Output: text pretext block with cap content to stdout (consumed by the calling agent).
62
- - Trust gate: requires the ref to be trusted (via `vit vet <ref> --trust`) OR dangerous-accept to be active. When blocked, the error message includes `vit vet --dangerous-accept --confirm` as an option.
62
+ - Trust gate: requires trust for the selected record's ref, URI, and CID (via `vit vet <ref> --trust`) OR dangerous-accept to be active. A changed record or an older trust entry without a CID requires re-vetting.
63
63
  - Common errors: not running inside agent, invalid ref, no DID, no beacon, cap not trusted, cap not found.
64
64
 
65
65
  ### `vit learn <ref>`
@@ -67,7 +67,7 @@ Handoffs:
67
67
  - Usage: `vit learn <ref>`
68
68
  - Key flags: `--did <did>`, `--user`, `--verbose`
69
69
  - Output: confirmation of install location.
70
- - Trust gate: requires the ref to be trusted (via `vit vet <ref> --trust`) OR dangerous-accept to be active. `--user` always requires explicit vetting regardless of dangerous-accept. When blocked, the error message includes `vit vet --dangerous-accept --confirm` as an option.
70
+ - Trust gate: requires trust for the selected record's ref, URI, and CID (via `vit vet <ref> --trust`) OR dangerous-accept to be active. A changed record or an older trust entry without a CID requires re-vetting. `--user` always requires matching vetting regardless of dangerous-accept.
71
71
  - Common errors: not running inside agent, invalid skill ref, no DID, skill not trusted, skill not found.
72
72
 
73
73
  ### Agent-usable commands
@@ -203,7 +203,7 @@ These are human-only because they call `requireNotAgent()` (or require browser i
203
203
  - `.vit/config.json` - `{ "beacon": "vit:host/org/repo" }`
204
204
  - `.vit/following.json` - `[{ "handle": "...", "did": "...", "followedAt": "..." }]`
205
205
  - `.vit/caps.jsonl` - Append-only shipped cap log
206
- - `.vit/trusted.jsonl` - Append-only vetted cap log
206
+ - `.vit/trusted.jsonl` - Append-only cap and skill trust log, binding each ref to the vetted record's URI and CID. Entries without a CID require re-vetting.
207
207
  - `.vit/dangerous-accept` - Project-wide vet bypass flag (written by `vit vet --dangerous-accept --confirm`)
208
208
  - `vit.json` in vit's config directory (`~/.config/vit/` on Linux, `~/Library/Preferences/vit/` on macOS, `%APPDATA%\vit\Config\` on Windows) - Global config with `did`, timestamps
209
209
 
package/src/cmd/beacon.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) 2026 sol pbc
3
3
 
4
4
  import git from 'isomorphic-git';
5
- import http from 'isomorphic-git/http/node';
5
+ import http from '../lib/git-http.js';
6
6
  import { memfs } from 'memfs';
7
7
  import { beaconToHttps, normalizeBeacon, tryNormalizeBeacon } from '../lib/beacon.js';
8
8
  import { mark } from '../lib/brand.js';
package/src/cmd/learn.js CHANGED
@@ -10,7 +10,7 @@ import { SKILL_COLLECTION } from '../lib/constants.js';
10
10
  import { restoreAgent } from '../lib/oauth.js';
11
11
  import { readFollowing, readLog, appendLog, vitDir } from '../lib/vit-dir.js';
12
12
  import { requireAgent, detectCodingAgent } from '../lib/agent.js';
13
- import { shouldBypassVet } from '../lib/trust-gate.js';
13
+ import { shouldBypassVet, requireTrustedRecord } from '../lib/trust-gate.js';
14
14
  import { isSkillRef, nameFromSkillRef, isValidSkillRef, isValidSkillName } from '../lib/skill-ref.js';
15
15
  import { mark, name } from '../lib/brand.js';
16
16
  import { resolvePds, resolveHandle, listRecordsFromPds, batchQuery } from '../lib/pds.js';
@@ -280,10 +280,11 @@ Examples:
280
280
  const skillName = nameFromSkillRef(ref);
281
281
  if (verbose) vlog(`[verbose] skill name: ${skillName}`);
282
282
 
283
- // Trust gate
283
+ // Preflight only; check the selected record's URI and CID before use.
284
284
  const isUserInstall = !!opts.user;
285
285
  const trusted = readLog('trusted.jsonl');
286
286
  const trustedEntry = trusted.find(e => e.ref === ref);
287
+ const trustGate = isUserInstall ? { bypass: false } : shouldBypassVet();
287
288
 
288
289
  if (isUserInstall && !trustedEntry) {
289
290
  // --user ALWAYS requires vet
@@ -305,7 +306,6 @@ Examples:
305
306
 
306
307
  if (!isUserInstall && !trustedEntry) {
307
308
  // Project-level: requires vet UNLESS dangerous-accept
308
- const trustGate = shouldBypassVet();
309
309
  if (!trustGate.bypass) {
310
310
  if (opts.json) {
311
311
  jsonError(`skill '${ref}' is not yet vetted`, `run 'vit vet ${ref}' first`);
@@ -380,6 +380,8 @@ Examples:
380
380
  return;
381
381
  }
382
382
 
383
+ if (!trustGate.bypass) requireTrustedRecord(ref, match, trusted);
384
+
383
385
  const record = match.value;
384
386
  if (verbose) vlog(`[verbose] found skill: ${record.name} from ${match.uri}`);
385
387
 
package/src/cmd/remix.js CHANGED
@@ -6,7 +6,7 @@ import { CAP_COLLECTION } from '../lib/constants.js';
6
6
  import { restoreAgent } from '../lib/oauth.js';
7
7
  import { readBeaconSet, readFollowing, readLog } from '../lib/vit-dir.js';
8
8
  import { requireAgent, detectCodingAgent } from '../lib/agent.js';
9
- import { shouldBypassVet } from '../lib/trust-gate.js';
9
+ import { shouldBypassVet, requireTrustedRecord } from '../lib/trust-gate.js';
10
10
  import { resolveRef, REF_PATTERN } from '../lib/cap-ref.js';
11
11
  import { brand, name } from '../lib/brand.js';
12
12
  import { resolvePds, listRecordsFromPds, batchQuery } from '../lib/pds.js';
@@ -70,10 +70,11 @@ export default function register(program) {
70
70
  }
71
71
  if (verbose) vlog(`[verbose] beacons: ${[...beaconSet].join(', ')}`);
72
72
 
73
+ // Preflight only; check the selected record's URI and CID before use.
73
74
  const trusted = readLog('trusted.jsonl');
74
75
  const trustedEntry = trusted.find(e => e.ref === ref);
76
+ const trustGate = shouldBypassVet();
75
77
  if (!trustedEntry) {
76
- const trustGate = shouldBypassVet();
77
78
  if (!trustGate.bypass) {
78
79
  if (opts.json) {
79
80
  jsonError(`cap '${ref}' is not trusted`, `tell your operator to run 'vit vet ${ref} --trust'`);
@@ -144,6 +145,8 @@ export default function register(program) {
144
145
  return;
145
146
  }
146
147
 
148
+ if (!trustGate.bypass) requireTrustedRecord(ref, match, trusted);
149
+
147
150
  const record = match.value;
148
151
  const author = match.uri.split('/')[2];
149
152
  const title = record.title || ref;
package/src/cmd/vet.js CHANGED
@@ -320,6 +320,9 @@ export default function register(program) {
320
320
  return;
321
321
  }
322
322
 
323
+ if (opts.trust && (typeof match.cid !== 'string' || !match.cid)) {
324
+ throw new Error(`cannot trust '${ref}': the record has no CID. fetch it again with 'vit vet ${ref}'.`);
325
+ }
323
326
  const record = match.value;
324
327
 
325
328
  if (opts.sandbox) {
@@ -337,6 +340,7 @@ export default function register(program) {
337
340
  appendLog('trusted.jsonl', {
338
341
  ref,
339
342
  uri: match.uri,
343
+ cid: match.cid,
340
344
  trustedAt: new Date().toISOString(),
341
345
  sandboxVerdict: verdict,
342
346
  });
@@ -398,6 +402,7 @@ export default function register(program) {
398
402
  appendLog('trusted.jsonl', {
399
403
  ref,
400
404
  uri: match.uri,
405
+ cid: match.cid,
401
406
  trustedAt: new Date().toISOString(),
402
407
  });
403
408
  if (opts.json) {
@@ -491,6 +496,9 @@ export default function register(program) {
491
496
  return;
492
497
  }
493
498
 
499
+ if (opts.trust && (typeof match.cid !== 'string' || !match.cid)) {
500
+ throw new Error(`cannot trust '${ref}': the record has no CID. fetch it again with 'vit vet ${ref}'.`);
501
+ }
494
502
  const record = match.value;
495
503
 
496
504
  if (opts.sandbox) {
@@ -518,6 +526,7 @@ export default function register(program) {
518
526
  appendLog('trusted.jsonl', {
519
527
  ref,
520
528
  uri: match.uri,
529
+ cid: match.cid,
521
530
  trustedAt: new Date().toISOString(),
522
531
  sandboxVerdict: verdict,
523
532
  });
@@ -570,6 +579,7 @@ export default function register(program) {
570
579
  appendLog('trusted.jsonl', {
571
580
  ref,
572
581
  uri: match.uri,
582
+ cid: match.cid,
573
583
  trustedAt: new Date().toISOString(),
574
584
  });
575
585
  if (opts.json) {
package/src/cmd/vouch.js CHANGED
@@ -14,6 +14,7 @@ import { loadConfig } from '../lib/config.js';
14
14
  import { jsonOk, jsonError } from '../lib/json-output.js';
15
15
  import { formatError } from '../lib/error-format.js';
16
16
  import { tryNormalizeBeacon } from '../lib/beacon.js';
17
+ import { requireTrustedRecord } from '../lib/trust-gate.js';
17
18
 
18
19
  export default function register(program) {
19
20
  program
@@ -136,6 +137,8 @@ export default function register(program) {
136
137
  return;
137
138
  }
138
139
 
140
+ requireTrustedRecord(ref, match, trusted);
141
+
139
142
  const now = new Date().toISOString();
140
143
  const vouchRecord = {
141
144
  $type: VOUCH_COLLECTION,
@@ -178,6 +181,7 @@ export default function register(program) {
178
181
  } else {
179
182
  const vouchKind = opts.kind || 'endorse';
180
183
  const isWant = vouchKind === 'want';
184
+ const trusted = readLog('trusted.jsonl');
181
185
 
182
186
  // Cap vouch — beacon required unless want-vouching (demand signal)
183
187
  const beaconSet = readBeaconSet();
@@ -194,7 +198,6 @@ export default function register(program) {
194
198
  }
195
199
  if (verbose) vlog(`[verbose] beacons: ${[...beaconSet].join(', ')}`);
196
200
 
197
- const trusted = readLog('trusted.jsonl');
198
201
  const trustedEntry = trusted.find(e => e.ref === ref);
199
202
  if (!trustedEntry) {
200
203
  if (opts.json) {
@@ -254,6 +257,8 @@ export default function register(program) {
254
257
  return;
255
258
  }
256
259
 
260
+ if (!isWant) requireTrustedRecord(ref, match, trusted);
261
+
257
262
  const now = new Date().toISOString();
258
263
  const projBeacon = beaconSet.size > 0
259
264
  ? [...beaconSet][0]
@@ -0,0 +1,105 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2026 sol pbc
3
+
4
+ const DEFAULT_TIMEOUT_MS = 15_000;
5
+
6
+ function toUint8Array(part) {
7
+ if (part instanceof Uint8Array) return part;
8
+ if (typeof part === 'string') return new TextEncoder().encode(part);
9
+ if (ArrayBuffer.isView(part)) {
10
+ return new Uint8Array(part.buffer, part.byteOffset, part.byteLength);
11
+ }
12
+ return new Uint8Array(part);
13
+ }
14
+
15
+ async function collectBody(body) {
16
+ if (!body) return undefined;
17
+ if (body instanceof Uint8Array || typeof body === 'string' || ArrayBuffer.isView(body)) {
18
+ return toUint8Array(body);
19
+ }
20
+
21
+ const chunks = [];
22
+ let total = 0;
23
+ if (typeof body[Symbol.asyncIterator] === 'function') {
24
+ for await (const part of body) {
25
+ const bytes = toUint8Array(part);
26
+ chunks.push(bytes);
27
+ total += bytes.byteLength;
28
+ }
29
+ } else if (typeof body[Symbol.iterator] === 'function') {
30
+ for (const part of body) {
31
+ const bytes = toUint8Array(part);
32
+ chunks.push(bytes);
33
+ total += bytes.byteLength;
34
+ }
35
+ } else {
36
+ return body;
37
+ }
38
+
39
+ const out = new Uint8Array(total);
40
+ let offset = 0;
41
+ for (const chunk of chunks) {
42
+ out.set(chunk, offset);
43
+ offset += chunk.byteLength;
44
+ }
45
+ return out;
46
+ }
47
+
48
+ async function* readStreamChunks(stream) {
49
+ if (!stream) return;
50
+ const reader = stream.getReader();
51
+ try {
52
+ while (true) {
53
+ const { done, value } = await reader.read();
54
+ if (done) break;
55
+ if (value) yield value;
56
+ }
57
+ } catch (err) {
58
+ if (err?.name === 'TimeoutError' || err?.name === 'AbortError') {
59
+ throw new Error('Request timed out', { cause: err });
60
+ }
61
+ throw err;
62
+ } finally {
63
+ reader.releaseLock();
64
+ }
65
+ }
66
+
67
+ export function createGitHttpClient({ fetchImpl = fetch, timeoutMs = DEFAULT_TIMEOUT_MS } = {}) {
68
+ return {
69
+ async request({ url, method = 'GET', headers = {}, body }) {
70
+ const payload = await collectBody(body);
71
+ let res;
72
+ try {
73
+ res = await fetchImpl(url, {
74
+ method,
75
+ headers,
76
+ body: payload,
77
+ redirect: 'follow',
78
+ signal: AbortSignal.timeout(timeoutMs),
79
+ });
80
+ } catch (err) {
81
+ if (err?.name === 'TimeoutError' || err?.name === 'AbortError') {
82
+ throw new Error('Request timed out', { cause: err });
83
+ }
84
+ throw err;
85
+ }
86
+
87
+ const responseHeaders = {};
88
+ for (const [key, value] of res.headers.entries()) {
89
+ responseHeaders[key.toLowerCase()] = value;
90
+ }
91
+
92
+ return {
93
+ url: res.url || url,
94
+ method,
95
+ statusCode: res.status,
96
+ statusMessage: res.statusText,
97
+ headers: responseHeaders,
98
+ body: readStreamChunks(res.body),
99
+ };
100
+ },
101
+ };
102
+ }
103
+
104
+ const gitHttp = createGitHttpClient();
105
+ export default gitHttp;
@@ -7,6 +7,16 @@ import { vitDir } from './vit-dir.js';
7
7
 
8
8
  const ACCEPT_FILE = 'dangerous-accept';
9
9
 
10
+ // A ref is a discovery label. Authorization belongs to the reviewed record.
11
+ export function requireTrustedRecord(ref, record, trusted) {
12
+ if (typeof record.uri === 'string' && record.uri.length > 0 &&
13
+ typeof record.cid === 'string' && record.cid.length > 0 &&
14
+ trusted.some(entry => entry.ref === ref && entry.uri === record.uri && entry.cid === record.cid)) {
15
+ return;
16
+ }
17
+ throw new Error(`'${ref}' is not vetted at this URI and CID. review it again with 'vit vet ${ref}', then trust it with 'vit vet ${ref} --trust'.`);
18
+ }
19
+
10
20
  /**
11
21
  * Check if dangerous-accept flag is active.
12
22
  * Returns { accepted: true } or { accepted: false }.