@asecret/cli 0.0.0-stage → 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.
@@ -0,0 +1,864 @@
1
+ // Every command, each taking the context main.js builds.
2
+
3
+ import { execFileSync } from "node:child_process";
4
+ import { readFile, writeFile } from "node:fs/promises";
5
+ import { resolve } from "node:path";
6
+ import { agents, chooseAgents, downloadSkill, occupant, removeSkill, SKILL, targets, writeSkill } from "./agents.js";
7
+ import { DEFAULT_API } from "./api.js";
8
+ import * as core from "./core.js";
9
+ import { NotLinked, UsageError } from "./errors.js";
10
+ import { clean, moment } from "./output.js";
11
+ import * as storage from "./storage.js";
12
+ import * as person from "./server.js";
13
+
14
+ export { UsageError } from "./errors.js";
15
+
16
+ const RUN_HINT = "Use a secret without seeing it: asecret run --secret NAME -- <command>";
17
+
18
+ /** @typedef {import("./main.js").Context} Context */
19
+ /** @typedef {Record<string, any>} Options */
20
+ /** @typedef {import("./storage.js").Opened} Opened */
21
+
22
+ /** @typedef {{ usage: string, summary: string, group: string, about?: string[], options?: Record<string, { type: "string" | "boolean", short?: string, multiple?: boolean, hint?: string, help: string, hidden?: boolean }>, run: (ctx: Context, args: string[], opts: Options) => Promise<void | number> }} Command */
23
+
24
+ const scope = {
25
+ project: { type: /** @type {const} */ ("boolean"), short: "p", help: "Use this project's folders instead of your home folder" },
26
+ agent: { type: /** @type {const} */ ("string"), short: "a", multiple: true, hint: "agent", help: "Only this agent (repeatable, '*' for every agent)" },
27
+ };
28
+
29
+ const keyOption = { key: { type: /** @type {const} */ ("string"), hint: "uuid", help: "Reuse this UUID when retrying the same write" } };
30
+ const serverOption = {
31
+ server: { type: /** @type {const} */ ("string"), hint: "origin", help: "Your person's aSecret server, when it is not the linked one" },
32
+ };
33
+
34
+ /** --server. @param {Options} opts */
35
+ function serverFlag(opts) {
36
+ return opts.server;
37
+ }
38
+
39
+ /** @param {string | undefined} value @param {string[]} allowed @param {string} what */
40
+ function oneOf(value, allowed, what) {
41
+ if (!value || !allowed.includes(value)) throw new UsageError(`Say the ${what}: ${allowed.join(", ")}.`);
42
+ return value;
43
+ }
44
+
45
+ /** @param {string | undefined} value @param {string} what @param {{ min?: number, max?: number }} [range] */
46
+ function count(value, what, { min = 1, max = Infinity } = {}) {
47
+ if (value === undefined) return undefined;
48
+ const n = Number(value);
49
+ if (!/^\d+$/.test(value) || n < min || n > max) throw new UsageError(`${what} takes a whole number from ${min}${Number.isFinite(max) ? ` to ${max}` : " up"}.`);
50
+ return n;
51
+ }
52
+
53
+ /** The keys of the connected agent. @param {Context} ctx */
54
+ async function keys(ctx) {
55
+ const saved = await ctx.credentials();
56
+ if (!saved) throw new (await import("./api.js")).NotConnected();
57
+ if (saved.source === "ASECRET_TOKEN" && !saved.keys)
58
+ throw new UsageError("ASECRET_TOKEN gives the token but not the key. Restore the key on this machine with: asecret connect --restore <file>");
59
+ return storage.keysOf(saved);
60
+ }
61
+
62
+ /** The current ETag of a secret, read now when none was given. @param {import("./api.js").Client} client @param {Opened} entry @param {string} [etag] */
63
+ async function currentETag(client, entry, etag) {
64
+ return etag ?? entry.item.etag ?? (await client.item(entry.item.id)).etag;
65
+ }
66
+
67
+ /** A secret's value from standard input: asked for without echo in a terminal, read from a pipe otherwise. @param {Context} ctx @param {string} name */
68
+ async function valueFromStdin(ctx, name) {
69
+ const text = ctx.stdinIsTTY ? await ctx.askHidden(`Value for ${name}: `) : new TextDecoder().decode(await ctx.readStdinBytes());
70
+ const value = text.replace(/\r?\n$/, "");
71
+ if (!value) throw new UsageError("The secret is empty. Nothing was saved.");
72
+ const bytes = new TextEncoder().encode(value);
73
+ if (bytes.length > storage.MAX_SECRET) throw new UsageError(`A secret can be up to ${storage.size(storage.MAX_SECRET)}. Nothing was saved.`);
74
+ return bytes;
75
+ }
76
+
77
+ /** The server to ask: --server, the linked one, or the API's own. @param {Context} ctx @param {Options} opts */
78
+ async function serverOf(ctx, opts) {
79
+ if (serverFlag(opts)) return person.serverOrigin(serverFlag(opts));
80
+ const saved = await ctx.credentials();
81
+ const origin = saved?.server ?? new URL(ctx.api).origin;
82
+ if (origin === new URL(DEFAULT_API).origin)
83
+ throw new UsageError("Asks need your person's own aSecret server; api.asecret.sh doesn't take them yet. Give it with --server <origin>.");
84
+ return origin;
85
+ }
86
+
87
+ /**
88
+ * Asking through the agent API, for an agent that links its person with a code (asecret.sh): not
89
+ * with --server, not once linked to a server of the person's own, and only when the API takes asks
90
+ * (agent-http). Null otherwise: asks then go to the person's own server.
91
+ * @param {Context} ctx @param {Options} opts
92
+ */
93
+ async function asksByCode(ctx, opts) {
94
+ if (serverFlag(opts)) return null;
95
+ const saved = await ctx.credentials();
96
+ if (saved?.server) return null;
97
+ // Discovery needs no token, so an agent linked only to its person's own server asks there.
98
+ const client = await ctx.client();
99
+ const info = await client.discovery();
100
+ const profiles = Array.isArray(info?.profiles) ? info.profiles : [];
101
+ if (!profiles.includes("person-link") || !profiles.includes("agent-http")) return null;
102
+ if (!saved) throw new (await import("./api.js")).NotConnected();
103
+ return { client, info, origin: new URL(ctx.api).origin };
104
+ }
105
+
106
+ /** Where this agent's asks go, and so where they are remembered. @param {Context} ctx @param {Options} opts */
107
+ async function askOrigin(ctx, opts) {
108
+ return (await asksByCode(ctx, opts))?.origin ?? (await serverOf(ctx, opts));
109
+ }
110
+
111
+ /**
112
+ * Whether this agent links its person through its agent API with a link code (api.asecret.sh,
113
+ * whose discovery offers person-link), rather than through a server of the person's own:
114
+ * not with --server, and not once linked to such a server.
115
+ * @param {Context} ctx @param {Options} opts
116
+ */
117
+ async function linksByCode(ctx, opts) {
118
+ if (serverFlag(opts) || (await ctx.credentials())?.server) return false;
119
+ const info = await (await ctx.client()).discovery();
120
+ return Array.isArray(info?.profiles) && info.profiles.includes("person-link");
121
+ }
122
+
123
+ /** `ABCD-EFGH`: a link code as people read it. @param {string} code */
124
+ const grouped = (code) => (code.length === 8 ? `${code.slice(0, 4)}-${code.slice(4)}` : code);
125
+
126
+ /** Where the person manages this agent: `asecret.sh`. @param {any} linked */
127
+ const linkedHost = (linked) => {
128
+ try {
129
+ return new URL(linked.server).host;
130
+ } catch {
131
+ return clean(linked.server);
132
+ }
133
+ };
134
+
135
+ /**
136
+ * Link through a code the person approves at asecret.sh, signed in, then give them this agent's keys
137
+ * if they turned on agent recovery. Waits while the code is open; stopping the wait leaves the code
138
+ * working, and the next command shares the keys.
139
+ * @param {Context} ctx
140
+ */
141
+ async function linkByCode(ctx) {
142
+ const client = await ctx.client({ required: true });
143
+ const saved = await ctx.credentials();
144
+ let me = await client.me();
145
+ const already = !!me.linked;
146
+ /** @type {any} */
147
+ let code = null;
148
+ if (!already) {
149
+ code = await client.linkCode();
150
+ ctx.say("Open this address and approve this agent, signed in to aSecret:");
151
+ ctx.say(clean(code.url));
152
+ ctx.say(`It shows the code ${clean(grouped(code.code))}. Check that it matches.`);
153
+ ctx.hint(`Waiting for your person. The code works until ${moment(code.expires_at)}; Ctrl-C stops waiting, not the code.`);
154
+ const until = Date.parse(code.expires_at);
155
+ const every = Math.min(ctx.pollMs, 2000);
156
+ let state = code.state;
157
+ while (state === "waiting" && Date.now() < until) {
158
+ await new Promise((done) => setTimeout(done, every));
159
+ state = await client.linkCodeState().then(
160
+ (/** @type {any} */ view) => (view.code === code.code ? view.state : "replaced"),
161
+ (/** @type {any} */ error) => {
162
+ if (error.code === "not_found") return "expired";
163
+ throw error;
164
+ },
165
+ );
166
+ }
167
+ if (state === "declined") throw new Error("Your person declined the link. Nothing changed.");
168
+ if (state === "replaced") throw new Error("A newer code replaced this one. Approve that one, or run asecret link again.");
169
+ if (state !== "approved") throw new Error("The code expired before your person approved it. Run asecret link for a new one.");
170
+ me = await client.me();
171
+ if (!me.linked) throw new Error("The code was approved, but aSecret doesn't show this agent as linked. Run asecret me to check.");
172
+ }
173
+ const shared = await storage.shareKeys(client, saved, me);
174
+ if (shared) me = shared;
175
+ if (ctx.json) return ctx.printJson({ linked: me.linked, code: code?.code ?? null, keys_shared: !!shared });
176
+ const host = linkedHost(me.linked);
177
+ ctx.out(ctx.c.green(already ? `Already linked to your person on ${host}.` : `Linked to your person on ${host}.`));
178
+ if (shared) ctx.out("Your person can now recover this agent's secrets.");
179
+ else if (!me.linked.person_key)
180
+ ctx.hint(`Your person can see this agent's secrets by name on ${host}, and delete them. To recover them too, they turn on agent recovery there; this agent then gives them its key on its next command.`);
181
+ else if (!me.linked.escrow) ctx.hint("This machine doesn't have the agent's key, so your person can't recover its secrets yet. Run asecret link where the key is.");
182
+ }
183
+
184
+ /** A session with the linked server. @param {Context} ctx @param {Options} opts */
185
+ async function linkedServer(ctx, opts) {
186
+ const hosted = await asksByCode(ctx, opts);
187
+ if (hosted) {
188
+ if (!(await hosted.client.me()).linked) throw new NotLinked("This agent isn't linked to a person yet.");
189
+ return { origin: hosted.origin, server: person.hostedServer(hosted.client) };
190
+ }
191
+ const origin = await serverOf(ctx, opts);
192
+ return { origin, ...(await person.session(origin, person.linkFile(ctx.configDir, origin), ctx.fetch)) };
193
+ }
194
+
195
+ /** @type {Record<string, Command>} */
196
+ export const commands = {
197
+ save: {
198
+ group: "Secrets",
199
+ usage: "save <name>",
200
+ summary: "Save a secret from standard input",
201
+ about: [
202
+ "The value comes only from standard input, never from the command line, so it stays out of shell",
203
+ "history. In a terminal it is asked for without echo. It is encrypted on this machine before it",
204
+ "leaves: aSecret keeps only ciphertext. Saving the same name again keeps a new version, and the",
205
+ "one before is kept for 30 days. A secret can be up to 64 KiB. Connects this agent first if needed.",
206
+ 'For example: printf %s "$OPENAI_API_KEY" | asecret save OPENAI_API_KEY',
207
+ ],
208
+ options: keyOption,
209
+ async run(ctx, args, opts) {
210
+ const name = storage.checkSecretName(args[0]);
211
+ if (args.length > 1) throw new UsageError("Give the secret on standard input, never on the command line.");
212
+ const bytes = await valueFromStdin(ctx, name);
213
+ const client = await ctx.client({ connect: true });
214
+ const agentKeys = await keys(ctx);
215
+ const existing = await storage.find(client, agentKeys, name);
216
+ const { item } = existing
217
+ ? await storage.updateSecret(client, existing, { bytes, etag: await currentETag(client, existing) })
218
+ : await storage.saveSecret(client, agentKeys, { name, bytes, key: opts.key });
219
+ if (ctx.json) return ctx.printJson({ name, id: item.id, version: item.version });
220
+ ctx.out(ctx.c.green(existing ? `Saved secret ${name}, version ${item.version}.` : `Saved secret ${name}.`));
221
+ ctx.hint(`Use it without showing it: asecret run --secret ${name} -- <command>`);
222
+ },
223
+ },
224
+
225
+ list: {
226
+ group: "Secrets",
227
+ usage: "list",
228
+ summary: "List this agent's secrets by name, never their values",
229
+ async run(ctx) {
230
+ const client = await ctx.client({ required: true });
231
+ const found = await storage.secrets(client, await keys(ctx));
232
+ if (ctx.json) return ctx.printJson({ data: found.map((e) => ({ name: e.meta?.name, id: e.item.id, version: e.item.version, updated_at: e.item.updated_at })) });
233
+ if (!found.length) {
234
+ ctx.out("No secrets yet.");
235
+ ctx.hint('Save one with: printf %s "$VALUE" | asecret save NAME');
236
+ return;
237
+ }
238
+ for (const entry of found) ctx.out(`${ctx.c.bold(clean(entry.meta?.name).padEnd(24))} version ${entry.item.version} · changed ${moment(entry.item.updated_at)}`);
239
+ ctx.hint(RUN_HINT);
240
+ },
241
+ },
242
+
243
+ get: {
244
+ group: "Secrets",
245
+ usage: "get <name>",
246
+ summary: "Print a secret's value",
247
+ about: [
248
+ "It prints the value, and a warning on standard error: whatever reads this output, an agent's",
249
+ "conversation included, sees the value. Prefer asecret run, which hands it to a command alone.",
250
+ "To a pipe it writes the value exactly, with no newline after it.",
251
+ ],
252
+ options: { version: { type: "string", hint: "n", help: "An earlier version, kept for 30 days" } },
253
+ async run(ctx, args, opts) {
254
+ const name = storage.checkSecretName(args[0]);
255
+ const client = await ctx.client({ required: true });
256
+ const entry = await storage.named(client, await keys(ctx), name);
257
+ const { bytes } = await storage.readSecret(client, entry, count(opts.version, "--version"));
258
+ ctx.warn(`This prints the secret ${name}. Whatever reads this output sees it. ${RUN_HINT.replace("NAME", name)}`);
259
+ if (ctx.json) return ctx.printJson({ name, value: new TextDecoder().decode(bytes), version: opts.version ? Number(opts.version) : entry.item.version });
260
+ if (ctx.stdoutIsTTY) ctx.out(new TextDecoder().decode(bytes));
261
+ else ctx.writeBytes(bytes);
262
+ },
263
+ },
264
+
265
+ delete: {
266
+ group: "Secrets",
267
+ usage: "delete <name>",
268
+ summary: "Delete a secret and its earlier versions",
269
+ about: ["It is gone at once, with every earlier version. There is no undo. Use --yes to skip the question."],
270
+ options: { etag: { type: "string", hint: "etag", help: "Use the exact ETag from your last read, including its quotes" } },
271
+ async run(ctx, args, opts) {
272
+ const name = storage.checkSecretName(args[0]);
273
+ const client = await ctx.client({ required: true });
274
+ const entry = await storage.named(client, await keys(ctx), name);
275
+ await ctx.confirm(`Delete the secret ${name}? There is no undo.`, false);
276
+ const deleted = await client.deleteItem(entry.item.id, await currentETag(client, entry, opts.etag));
277
+ if (ctx.json) return ctx.printJson({ name, ...deleted });
278
+ ctx.out(ctx.c.green(`Deleted ${name}.`));
279
+ },
280
+ },
281
+
282
+ run: {
283
+ group: "Secrets",
284
+ usage: "run --secret <name> -- <cmd>",
285
+ summary: "Run a command with secrets in its environment",
286
+ about: [
287
+ "Each --secret is decrypted here and set as an environment variable of the same name for the",
288
+ "command alone. Nothing about the values is printed. The command's exit code is asecret's.",
289
+ "For example: asecret run --secret OPENAI_API_KEY -- python agent.py",
290
+ ],
291
+ options: { secret: { type: "string", multiple: true, hint: "name", help: "Set this secret in the command's environment (repeatable)" } },
292
+ async run(ctx, args, opts) {
293
+ const names = (opts.secret ?? []).map(storage.checkSecretName);
294
+ if (!names.length) throw new UsageError("Say which secrets with --secret NAME.");
295
+ if (!args.length) throw new UsageError("Give the command after --, for example: asecret run --secret NAME -- python agent.py");
296
+ const client = await ctx.client({ required: true });
297
+ const all = await storage.secrets(client, await keys(ctx));
298
+ /** @type {Record<string, string>} */
299
+ const env = {};
300
+ for (const name of names) {
301
+ const entry = all.find((e) => e.meta?.name === name);
302
+ if (!entry) throw new UsageError(`No secret named ${name}. Save it with: asecret save ${name}`);
303
+ env[name] = new TextDecoder().decode((await storage.readSecret(client, entry)).bytes);
304
+ }
305
+ return ctx.spawn(args[0], args.slice(1), env);
306
+ },
307
+ },
308
+
309
+ ask: {
310
+ group: "Your person",
311
+ usage: "ask <detail>",
312
+ summary: "Ask your person to save a detail they keep, or set up aSecret; or, on their own server, deliver one",
313
+ about: [
314
+ "Your person decides in aSecret; this agent reads the outcome, never the detail itself.",
315
+ " ask <type> save a detail: postal_address, email, phone, membership, secure_note,",
316
+ " api_key, password, id_number or document",
317
+ " ask setup set up several details",
318
+ "Linked on asecret.sh (asecret link), your person answers there. Their own aSecret server (--server) also takes:",
319
+ " ask payment_method ask form fill in a website form from aSecret",
320
+ " ask address --to <recipient> --order <id> deliver their address for an order",
321
+ " ask order-status --to <recipient> --order <id>",
322
+ "Show the printed link to your person. With --link, or before this agent is linked, ask prints a",
323
+ "public link instead, which is not tracked. --wait checks until your person decides.",
324
+ ],
325
+ options: {
326
+ to: { type: "string", hint: "recipient", help: "The merchant to deliver to (asecret recipients)" },
327
+ order: { type: "string", hint: "id", help: "The order it is for" },
328
+ reference: { type: "string", hint: "ref", help: "A detail reference your person shared with this agent" },
329
+ link: { type: "boolean", help: "Print the public link only, without tracking" },
330
+ wait: { type: "boolean", help: "Wait until your person decides" },
331
+ ...serverOption,
332
+ ...keyOption,
333
+ },
334
+ async run(ctx, args, opts) {
335
+ const what = oneOf(args[0], [...person.ASK_FORMS, ...core.detailTypes.filter((t) => !person.ASK_FORMS.includes(t))], "detail");
336
+ const hosted = await asksByCode(ctx, opts);
337
+ const origin = hosted ? hosted.origin : await serverOf(ctx, opts);
338
+ /** @type {any} */
339
+ let server = null;
340
+ if (hosted) {
341
+ if (what !== "form" && !opts.link && (await hosted.client.me()).linked) server = person.hostedServer(hosted.client);
342
+ } else {
343
+ const file = person.linkFile(ctx.configDir, origin);
344
+ const linked = what !== "form" && !opts.link && (await core.readCredential(file, origin).catch(() => null));
345
+ if (linked) server = (await person.session(origin, file, ctx.fetch)).server;
346
+ }
347
+ if (!server) {
348
+ const url = hosted ? person.hostedLink(hosted.info, what) : await person.publicLink(origin, what, ctx.fetch);
349
+ if (ctx.json) return ctx.printJson({ url, tracked: false });
350
+ ctx.out(clean(url));
351
+ ctx.hint("Show this link to your person and tell them why the task needs it.");
352
+ if (what !== "form" && !opts.link) ctx.hint("Link your person to track asks: asecret link");
353
+ return;
354
+ }
355
+ const { view, ask } = await person.startAsk(server, what, opts);
356
+ await person.rememberAsk(ctx.asksFile, origin, { ...ask, id: view.request_id, review_url: view.review_url, expires_at: view.expires_at, created_at: new Date().toISOString() });
357
+ const final = opts.wait ? await person.waitFor(() => server.status(view.request_id, person.expected({ ...ask, id: view.request_id, created_at: "" })), { every: ctx.pollMs }) : view;
358
+ if (ctx.json) return ctx.printJson(final);
359
+ if (view.review_url && !opts.wait) ctx.out(clean(view.review_url));
360
+ ctx.out(person.describe(final, { ...ask, id: view.request_id, created_at: "" }));
361
+ if (final.state === "awaiting_owner") {
362
+ if (opts.wait) ctx.out(clean(view.review_url));
363
+ ctx.hint(`Show this link to your person. Check it: asecret check ${clean(view.request_id)}`);
364
+ }
365
+ },
366
+ },
367
+
368
+ asks: {
369
+ group: "Your person",
370
+ usage: "asks",
371
+ summary: "List this agent's asks and where each stands",
372
+ options: serverOption,
373
+ async run(ctx, _args, opts) {
374
+ const origin = await askOrigin(ctx, opts);
375
+ const known = await person.asksAt(ctx.asksFile, origin);
376
+ if (!known.length) {
377
+ if (ctx.json) return ctx.printJson({ data: [] });
378
+ ctx.out("No asks yet.");
379
+ ctx.hint("Ask your person for a detail: asecret ask <detail>");
380
+ return;
381
+ }
382
+ const { server } = await linkedServer(ctx, opts);
383
+ const views = [];
384
+ for (const ask of known.slice(0, 50)) {
385
+ const view = await server.status(ask.id, person.expected(ask)).catch((/** @type {any} */ error) => ({ request_id: ask.id, state: error?.code === "not_found" ? "gone" : "unknown" }));
386
+ views.push({ ask, view });
387
+ }
388
+ if (ctx.json) return ctx.printJson({ data: views.map(({ ask, view }) => ({ ...view, what: ask.what, created_at: ask.created_at })) });
389
+ ctx.out();
390
+ for (const { ask, view } of views) {
391
+ ctx.out(`${ctx.c.bold(clean(ask.what))}${ask.order_id ? ` · order ${clean(ask.order_id)}` : ""} · ${person.describe(view, ask)}`);
392
+ ctx.out(` ${ctx.c.dim(`${clean(ask.id)} · asked ${moment(ask.created_at)}`)}`);
393
+ ctx.out();
394
+ }
395
+ ctx.hint("Read one: asecret check <ask>");
396
+ },
397
+ },
398
+
399
+ check: {
400
+ group: "Your person",
401
+ usage: "check <ask>",
402
+ summary: "Read one ask, or wait for the decision with --wait",
403
+ options: { wait: { type: "boolean", help: "Wait until your person decides" }, ...serverOption },
404
+ async run(ctx, args, opts) {
405
+ if (!args[0]) throw new UsageError("Say which ask: its id.");
406
+ const { server, origin } = await linkedServer(ctx, opts);
407
+ const ask = (await person.asksAt(ctx.asksFile, origin)).find((known) => known.id === args[0]);
408
+ const read = () => server.status(args[0], person.expected(ask));
409
+ const view = opts.wait ? await person.waitFor(read, { every: ctx.pollMs }) : await read();
410
+ if (ctx.json) return ctx.printJson(view);
411
+ ctx.out(person.describe(view, ask));
412
+ if (view.state === "awaiting_owner" && view.review_url) {
413
+ ctx.out(clean(view.review_url));
414
+ ctx.hint(`Waiting until ${moment(view.expires_at)}. Wait for it: asecret check ${clean(args[0])} --wait`);
415
+ }
416
+ },
417
+ },
418
+
419
+ cancel: {
420
+ group: "Your person",
421
+ usage: "cancel <ask>",
422
+ summary: "Cancel an ask that is still waiting",
423
+ options: serverOption,
424
+ async run(ctx, args, opts) {
425
+ if (!args[0]) throw new UsageError("Say which ask: its id.");
426
+ const { server, origin } = await linkedServer(ctx, opts);
427
+ const ask = (await person.asksAt(ctx.asksFile, origin)).find((known) => known.id === args[0]);
428
+ const view = await server.cancel(args[0], person.expected(ask));
429
+ if (ctx.json) return ctx.printJson(view);
430
+ ctx.out(view.state === "canceled" ? ctx.c.green("Canceled.") : person.describe(view, ask));
431
+ },
432
+ },
433
+
434
+ recipients: {
435
+ group: "Your person",
436
+ usage: "recipients",
437
+ summary: "List the merchants your person's aSecret server can deliver to · your own aSecret server only (--server)",
438
+ options: serverOption,
439
+ async run(ctx, _args, opts) {
440
+ const directory = await core.getPublicDirectory(await serverOf(ctx, opts), { fetcher: ctx.fetch });
441
+ if (ctx.json) return ctx.printJson(directory);
442
+ const merchants = directory.integrations.filter((/** @type {any} */ entry) => entry.kind !== "agent");
443
+ if (!merchants.length) ctx.out("This server lists no recipients.");
444
+ for (const entry of merchants) ctx.out(`${ctx.c.bold(clean(entry.id).padEnd(20))} ${clean(entry.name ?? "")} · ${entry.operations.map(clean).join(", ")}`);
445
+ ctx.hint("Ask for a delivery: asecret ask address --to <recipient> --order <id>");
446
+ },
447
+ },
448
+
449
+ connect: {
450
+ group: "Account",
451
+ usage: "connect",
452
+ summary: "Connect this agent to aSecret and create its key",
453
+ about: [
454
+ "One call, no account. The key is made on this machine and never leaves it: without it, the",
455
+ "secrets can't be read again, so keep a copy with asecret key --export. The CLI connects by itself",
456
+ "the first time you save a secret. --restore sets this machine up from an exported key.",
457
+ ],
458
+ options: { restore: { type: "string", hint: "file", help: "Set up this agent from an exported key file" } },
459
+ async run(ctx, args, opts) {
460
+ if (args[0]) throw new UsageError(`connect takes no address. To link your person's own aSecret server: asecret link --server ${clean(args[0])}`);
461
+ const existing = await ctx.credentials();
462
+ if (existing && !opts.restore) {
463
+ if (ctx.json) return ctx.printJson({ agent_id: existing.agent_id ?? null, source: existing.source });
464
+ ctx.out(`Already connected${existing.agent_id ? ` as agent ${existing.agent_id}` : ""}. The token and key are in ${existing.source}.`);
465
+ ctx.hint("See this agent with: asecret me");
466
+ return;
467
+ }
468
+ if (opts.restore) {
469
+ if (existing) await ctx.confirm(`Replace agent ${existing.agent_id ?? ""} on this machine with the one in ${clean(opts.restore)}?`, false);
470
+ const restored = await ctx.restore(resolve(ctx.cwd, opts.restore));
471
+ if (ctx.json) return ctx.printJson({ agent_id: restored.agent_id, restored: true });
472
+ return;
473
+ }
474
+ const result = await ctx.connect({ primary: true });
475
+ if (ctx.json) return ctx.printJson({ agent_id: result.agent_id });
476
+ },
477
+ },
478
+
479
+ me: {
480
+ group: "Account",
481
+ usage: "me",
482
+ summary: "Show this agent, its secrets and whether a person is linked",
483
+ about: ["With --server, shows what that server offers before this agent links to it."],
484
+ options: serverOption,
485
+ async run(ctx, _args, opts) {
486
+ const { c } = ctx;
487
+ const row = (/** @type {string} */ label, /** @type {string} */ value) => ctx.out(`${c.bold(label.padEnd(8))} ${value}`);
488
+ if (serverFlag(opts)) {
489
+ const info = await core.discover(person.serverOrigin(serverFlag(opts)), { fetcher: ctx.fetch });
490
+ if (ctx.json) return ctx.printJson(info);
491
+ row("Server", clean(person.serverOrigin(serverFlag(opts))));
492
+ row("Offers", info.profiles.map(clean).join(", "));
493
+ if (info.save_detail_types) row("Saves", info.save_detail_types.map(clean).join(", "));
494
+ return;
495
+ }
496
+ const client = await ctx.client({ required: true });
497
+ let me = await client.me();
498
+ const saved = await ctx.credentials();
499
+ if (ctx.json) return ctx.printJson({ ...me, token_source: ctx.tokenSource, server: saved?.server ?? null });
500
+ row("Agent", clean(me.agent_id));
501
+ row("Secrets", `${me.items} · ${storage.size(me.used_bytes)} of ${storage.size(me.quota_bytes)}`);
502
+ row("Key", saved?.keys?.agent ? await storage.keyFingerprint(saved.keys.agent) : c.yellow("not on this machine (asecret connect --restore <file>)"));
503
+ const shared = await storage.shareKeys(client, saved, me).catch(() => null);
504
+ if (shared) me = shared;
505
+ const linked = me.linked;
506
+ if (!linked) row("Person", saved?.server ? `linked to ${clean(saved.server)}` : c.dim("not linked (asecret link)"));
507
+ // Linked through a code at asecret.sh there is no connection; through a person's own server, there is.
508
+ else row("Person", linked.connection_id === null ? `linked on ${linkedHost(linked)}` : `linked to ${clean(linked.server)}`);
509
+ if (linked)
510
+ row(
511
+ "Recovery",
512
+ !linked.person_key
513
+ ? c.dim(`off (your person turns it on${linked.connection_id === null ? ` at ${linkedHost(linked)}` : " in aSecret"})`)
514
+ : linked.escrow
515
+ ? "on: your person can recover this agent's secrets"
516
+ : c.yellow("on, but this agent hasn't given them its key (asecret link where the key is)"),
517
+ );
518
+ row("Token", ctx.tokenSource ?? "");
519
+ },
520
+ },
521
+
522
+ link: {
523
+ group: "Account",
524
+ usage: "link",
525
+ summary: "Link this agent to your person, so they can see its secrets and answer its asks",
526
+ about: [
527
+ "Prints an address and a code for your person. They open it signed in to aSecret, check the code",
528
+ "and approve; the command waits until they decide (Ctrl-C stops waiting; the code still works",
529
+ "for 15 minutes). Once linked, your person sees this agent's secrets by name, never their values,",
530
+ "and can delete them or pause the agent. If they turned on agent recovery, this agent gives them",
531
+ "its key, sealed so only they can open it, and they can reveal and recover its secrets too.",
532
+ "Once linked, this agent can ask them for a detail they keep: asecret ask.",
533
+ "With --server, links to your person's own aSecret server instead: they check this agent's name,",
534
+ "choose how long it may ask, and approve it there. Give --name for how this agent appears to",
535
+ "them, or a registered --client and --callback.",
536
+ ],
537
+ options: {
538
+ name: { type: "string", hint: "name", help: "How this agent appears to your person" },
539
+ client: { type: "string", hint: "id", help: "A client id registered at the server" },
540
+ callback: { type: "string", hint: "url", help: "That client's registered 127.0.0.1 callback" },
541
+ ...serverOption,
542
+ },
543
+ async run(ctx, _args, opts) {
544
+ if (!opts.client && !opts.callback && (await linksByCode(ctx, opts))) {
545
+ if (opts.name !== undefined) throw new UsageError("--name is for your person's own aSecret server (--server).");
546
+ return linkByCode(ctx);
547
+ }
548
+ if (Boolean(opts.client) !== Boolean(opts.callback)) throw new UsageError("Give --client and --callback together.");
549
+ if (opts.name !== undefined && opts.client) throw new UsageError("Use --name on its own, or a registered --client and --callback.");
550
+ const name = opts.client ? undefined : core.validateAgentName(opts.name ?? ctx.agentName);
551
+ if (opts.callback) core.loopbackCallback(opts.callback);
552
+ const origin = await serverOf(ctx, opts);
553
+ const file = person.linkFile(ctx.configDir, origin);
554
+ const { grant, already } = await person.pair({
555
+ origin,
556
+ file,
557
+ name,
558
+ client: opts.client,
559
+ callback: opts.callback,
560
+ fetch: ctx.fetch,
561
+ show: (url) => {
562
+ ctx.say("Open this address and approve this agent in aSecret:");
563
+ ctx.say(url);
564
+ },
565
+ });
566
+ const saved = await ctx.credentials();
567
+ let me = null;
568
+ if (saved?.token && saved.keys && new URL(ctx.api).origin === origin) {
569
+ const client = await ctx.client({ required: true });
570
+ me = await client.linkPerson(grant.accessToken).catch((/** @type {any} */ error) => {
571
+ ctx.warn(`Linked for asks, but your person can't see this agent's secrets yet: ${clean(error.message)}`);
572
+ return null;
573
+ });
574
+ // The person's recovery key opens this, so they can read the secrets the agent keeps.
575
+ if (me?.linked?.person_key) me = await client.setEscrow(await core.sealToReceiveKey(me.linked.person_key, new TextEncoder().encode(JSON.stringify(saved.keys))));
576
+ }
577
+ if (saved?.token && saved.server !== origin) await ctx.saveServer(origin);
578
+ if (ctx.json) return ctx.printJson({ server: origin, connection_id: grant.connectionId, expires_at: grant.expiresAt ? new Date(grant.expiresAt).toISOString() : null, storage: me?.linked ?? null });
579
+ ctx.out(ctx.c.green(already ? `Already linked to your person's aSecret server at ${origin}.` : `Linked to your person's aSecret server at ${origin}.`));
580
+ if (grant.expiresAt) ctx.hint(`The link lasts until ${moment(new Date(grant.expiresAt).toISOString())}.`);
581
+ if (me?.linked && !me.linked.person_key) ctx.hint("Your person can see this agent's secrets by name and delete them. To recover them too, they turn on agent recovery in aSecret, then you run asecret link again.");
582
+ ctx.hint("Ask your person for a detail: asecret ask <detail>");
583
+ },
584
+ },
585
+
586
+ unlink: {
587
+ group: "Account",
588
+ usage: "unlink",
589
+ summary: "End the link to your person",
590
+ about: [
591
+ "Your person no longer sees this agent's secrets, and the key they could recover them with is deleted.",
592
+ "With --server, ends the link to your person's own aSecret server and forgets it here. Asks still",
593
+ "waiting stay where they are.",
594
+ ],
595
+ options: serverOption,
596
+ async run(ctx, _args, opts) {
597
+ if (await linksByCode(ctx, opts)) {
598
+ const client = await ctx.client({ required: true });
599
+ const me = await client.me();
600
+ if (!me.linked) {
601
+ if (ctx.json) return ctx.printJson({ state: "not_linked" });
602
+ ctx.out("This agent was not linked to a person.");
603
+ return;
604
+ }
605
+ await ctx.confirm(`End this agent's link to your person on ${linkedHost(me.linked)}?`, true);
606
+ await client.unlinkPerson();
607
+ if (ctx.json) return ctx.printJson({ state: "unlinked" });
608
+ ctx.out(ctx.c.green("Unlinked. Your person no longer sees this agent's secrets."));
609
+ return;
610
+ }
611
+ const origin = await serverOf(ctx, opts);
612
+ await ctx.confirm(`End this agent's link to ${origin}?`, true);
613
+ const result = await person.unpair(origin, person.linkFile(ctx.configDir, origin), ctx.fetch);
614
+ const saved = await ctx.credentials();
615
+ if (saved?.token && new URL(ctx.api).origin === origin) await (await ctx.client({ required: true })).unlinkPerson().catch(() => null);
616
+ if (saved?.server === origin) await ctx.saveServer(undefined);
617
+ if (ctx.json) return ctx.printJson(result);
618
+ if (result.state === "not_linked") ctx.out("This agent was not linked to that server.");
619
+ else if (result.state === "credential_removed") ctx.out("The server no longer accepted the link, so it is forgotten here. Your person can check it in their app.");
620
+ else ctx.out(ctx.c.green("Unlinked."));
621
+ },
622
+ },
623
+
624
+ key: {
625
+ group: "Account",
626
+ usage: "key",
627
+ summary: "Show this agent's key, or export it with --export",
628
+ about: [
629
+ "The export is one file holding this agent's id, token and key, readable only by you. With it,",
630
+ "asecret connect --restore sets up the same agent on another machine. Keep it as you would a password.",
631
+ ],
632
+ options: {
633
+ export: { type: "boolean", help: "Write the agent's id, token and key to --out" },
634
+ out: { type: "string", short: "o", hint: "file", help: "Where to write the export" },
635
+ },
636
+ async run(ctx, _args, opts) {
637
+ const saved = await ctx.credentials();
638
+ if (!saved?.keys?.agent) throw new (await import("./api.js")).NotConnected();
639
+ if (opts.export) {
640
+ if (!opts.out) throw new UsageError("Say where to write it: asecret key --export --out <file>");
641
+ const path = resolve(ctx.cwd, opts.out);
642
+ const body = { format: "asecret-agent-key/1", api: ctx.api, agent_id: saved.agent_id, token: saved.token, keys: saved.keys, exported_at: new Date().toISOString() };
643
+ await writeFile(path, `${JSON.stringify(body, null, 2)}\n`, { mode: 0o600, flag: "wx" }).catch((/** @type {any} */ error) => {
644
+ if (error.code === "EEXIST") throw new UsageError(`${ctx.tilde(path)} already exists. Choose a new file.`);
645
+ throw error;
646
+ });
647
+ if (ctx.json) return ctx.printJson({ written: path });
648
+ ctx.out(ctx.c.green(`Exported to ${ctx.tilde(path)}, readable only by you.`));
649
+ ctx.hint("Anyone with this file can act as this agent. Keep it as you would a password.");
650
+ return;
651
+ }
652
+ const fingerprint = await storage.keyFingerprint(saved.keys.agent);
653
+ if (ctx.json) return ctx.printJson({ fingerprint, source: saved.source });
654
+ ctx.out(`${ctx.c.bold("Key")} ${fingerprint} in ${saved.source}`);
655
+ ctx.hint("Keep a copy: asecret key --export --out <file>");
656
+ },
657
+ },
658
+
659
+ token: {
660
+ group: "Account",
661
+ usage: "token --rotate",
662
+ summary: "Replace this agent's token, for example if it leaked",
663
+ about: [
664
+ "aSecret gives a new token, saved here in place of the old one, which stops working at once.",
665
+ "The key doesn't change, so every secret stays readable. Export the key again: earlier exports hold the old token.",
666
+ ],
667
+ options: { rotate: { type: "boolean", help: "Get a new token and retire the old one" } },
668
+ async run(ctx, _args, opts) {
669
+ if (!opts.rotate) throw new UsageError("Say what to do: asecret token --rotate");
670
+ const result = await ctx.rotateToken();
671
+ if (ctx.json) return ctx.printJson({ agent_id: result.agent_id, rotated: true });
672
+ ctx.out(ctx.c.green(`New token saved in ${result.source}. The old one no longer works.`));
673
+ ctx.hint("Earlier key exports hold the old token. Export again: asecret key --export --out <file>");
674
+ },
675
+ },
676
+
677
+ erase: {
678
+ group: "Account",
679
+ usage: "erase",
680
+ summary: "Delete this agent at aSecret, with every secret, and forget it here",
681
+ about: ["There's no undo: the secrets and their earlier versions go at once. Use --yes to skip the question."],
682
+ async run(ctx) {
683
+ const client = await ctx.client({ required: true });
684
+ const me = await client.me();
685
+ await ctx.confirm(
686
+ `Delete agent ${clean(me.agent_id)} and its ${me.items} secret${me.items === 1 ? "" : "s"} at aSecret? There's no undo.`,
687
+ false,
688
+ );
689
+ const result = await client.deleteAgent();
690
+ await ctx.forget();
691
+ if (ctx.json) return ctx.printJson(result);
692
+ ctx.out(`Deleted agent ${clean(result.agent_id)} and ${result.items_deleted} secret${result.items_deleted === 1 ? "" : "s"}. Forgot it on this machine.`);
693
+ },
694
+ },
695
+
696
+ logout: {
697
+ group: "Account",
698
+ usage: "logout",
699
+ summary: "Forget the token and key on this machine",
700
+ about: ["The agent and its secrets stay at aSecret, but without an exported key they can't be read again."],
701
+ async run(ctx) {
702
+ await ctx.confirm("Forget this agent's token and key? Without an exported key, its secrets can't be read again.", false);
703
+ const forgot = await ctx.forget();
704
+ if (ctx.json) return ctx.printJson({ forgotten: forgot });
705
+ ctx.out(forgot ? "Forgot the token and key." : "There was no saved token.");
706
+ if (ctx.env.ASECRET_TOKEN?.trim()) ctx.hint("ASECRET_TOKEN is still set in this shell.");
707
+ },
708
+ },
709
+
710
+ add: {
711
+ group: "Agents",
712
+ usage: "add",
713
+ summary: "Add the aSecret skill to your agents",
714
+ about: [
715
+ "Downloads the current skill from asecret.sh, or uses the copy in this CLI when it can't, and saves",
716
+ "it where each agent on this machine reads skills. Run it again to update. Use --project for this project only.",
717
+ ],
718
+ options: {
719
+ ...scope,
720
+ list: { type: "boolean", short: "l", help: "List the agents and where the skill is, without changing anything" },
721
+ },
722
+ async run(ctx, _args, opts) {
723
+ const all = agents({ home: ctx.home, env: ctx.env });
724
+ const global = !opts.project;
725
+ if (opts.list) return listAgents(ctx, all, global);
726
+ const chosen = chooseAgents(all, opts.agent ?? []);
727
+ const plan = targets(chosen, { global, cwd: ctx.cwd });
728
+ const skill = await downloadSkill(ctx.skillWeb, { fetch: ctx.fetch, userAgent: ctx.userAgent }).catch(async () => {
729
+ const text = await readFile(new URL("../skill/SKILL.md", import.meta.url), "utf8");
730
+ return { files: { "SKILL.md": text }, version: text.match(/^\s+version:\s*"?([^"\n]+)"?/m)?.[1] ?? null };
731
+ });
732
+ const { c } = ctx;
733
+ /** @type {typeof plan} */
734
+ const writable = [];
735
+ for (const target of plan) {
736
+ if ((await occupant(target.dir)).kind === "other") {
737
+ ctx.warn(`Skipped ${ctx.tilde(target.dir)}: another skill named "${SKILL}" is there.`);
738
+ } else {
739
+ writable.push(target);
740
+ }
741
+ }
742
+ if (!writable.length) throw new Error("Nothing to add.");
743
+ if (!ctx.json) {
744
+ ctx.out(`The aSecret skill${skill.version ? ` ${skill.version}` : ""} goes to:`);
745
+ for (const target of writable) ctx.out(` ${c.bold(target.names.join(", "))}\n ${c.dim(ctx.tilde(target.dir))}`);
746
+ }
747
+ if (ctx.interactive) await ctx.confirm("Add it?", true);
748
+ for (const target of writable) await writeSkill(target.dir, skill.files);
749
+ if (ctx.json) return ctx.printJson({ version: skill.version, added: writable });
750
+ ctx.out(c.green("Added."));
751
+ ctx.hint('Ask your agent something like: "Keep my OpenAI key in aSecret and run the script with it."');
752
+ },
753
+ },
754
+
755
+ remove: {
756
+ group: "Agents",
757
+ usage: "remove",
758
+ summary: "Remove the aSecret skill from your agents",
759
+ options: { ...scope },
760
+ async run(ctx, _args, opts) {
761
+ const all = agents({ home: ctx.home, env: ctx.env });
762
+ const chosen = opts.agent?.length ? chooseAgents(all, opts.agent) : all;
763
+ const current = targets(chosen, { global: !opts.project, cwd: ctx.cwd });
764
+ const plan = current;
765
+ /** @type {typeof plan} */
766
+ const found = [];
767
+ for (const target of plan) if ((await occupant(target.dir)).kind === "ours") found.push(target);
768
+ if (!found.length) {
769
+ if (ctx.json) return ctx.printJson({ removed: [] });
770
+ ctx.out("The aSecret skill is not in any of those folders.");
771
+ return;
772
+ }
773
+ if (!ctx.json) for (const target of found) ctx.out(` ${ctx.tilde(target.dir)}`);
774
+ await ctx.confirm(`Remove the aSecret skill from ${found.length === 1 ? "this folder" : `these ${found.length} folders`}?`, true);
775
+ for (const target of found) await removeSkill(target.dir);
776
+ if (ctx.json) return ctx.printJson({ removed: found });
777
+ ctx.out(ctx.c.green("Removed."));
778
+ },
779
+ },
780
+
781
+ mcp: {
782
+ group: "Agents",
783
+ usage: "mcp",
784
+ summary: "Run aSecret as a local MCP server, with this agent's asks and secret names",
785
+ about: [
786
+ "It speaks MCP over stdin and stdout, with list_secrets (names only: no tool returns a value)",
787
+ "and, once linked to your person, the tools that ask them for a detail. It uses the same token and",
788
+ "key as this CLI. asecret-mcp runs the same server.",
789
+ "For agents like Claude Code: claude mcp add asecret -- asecret mcp",
790
+ "--print prints a settings entry instead, for Claude Code, Gemini CLI or OpenCode.",
791
+ "For OpenCode it matches the installed version: mcp.asecret for 1.x, mcp.servers.asecret for 2.x.",
792
+ ],
793
+ options: {
794
+ print: { type: "boolean", help: "Print a settings entry for --host instead of running the server" },
795
+ host: { type: "string", hint: "host", help: "With --print: mcp, claude, gemini or opencode (default mcp)" },
796
+ },
797
+ async run(ctx, _args, opts) {
798
+ if (!opts.print && opts.host === undefined) {
799
+ const { storageServer } = await import("./mcp.js");
800
+ const { StdioServerTransport } = await import("@modelcontextprotocol/server/stdio");
801
+ await storageServer({ env: ctx.env, home: ctx.home, fetch: ctx.fetch }).connect(new StdioServerTransport());
802
+ return;
803
+ }
804
+ const host = oneOf(opts.host ?? "mcp", ["mcp", "claude", "gemini", "opencode"], "host");
805
+ const server = new URL("../bin/asecret-mcp.js", import.meta.url).pathname;
806
+ /** @type {Record<string, string>} */
807
+ const env = {};
808
+ for (const name of ["ASECRET_CONFIG_DIR", "ASECRET_API_URL"]) if (ctx.env[name]?.trim()) env[name] = ctx.env[name].trim();
809
+ if (ctx.api !== (await import("./api.js")).DEFAULT_API) env.ASECRET_API_URL = ctx.api;
810
+ const local = { type: "local", command: [process.execPath, server], ...(Object.keys(env).length ? { environment: env } : {}) };
811
+ // OpenCode 1.x reads mcp.<name>; 2.x reads mcp.servers.<name>. Match the one installed here.
812
+ const entry =
813
+ host === "opencode"
814
+ ? openCodeMajor(ctx) === 1
815
+ ? { mcp: { asecret: local } }
816
+ : { mcp: { servers: { asecret: local } } }
817
+ : { mcpServers: { asecret: { command: process.execPath, args: [server], ...(Object.keys(env).length ? { env } : {}) } } };
818
+ ctx.printJson(entry);
819
+ if (!ctx.json) ctx.hint(host === "claude" ? `Or add it directly: claude mcp add asecret -- ${[process.execPath, server].join(" ")}` : "Paste this into the host's MCP settings.");
820
+ },
821
+ },
822
+
823
+ instructions: {
824
+ group: "Agents",
825
+ usage: "instructions",
826
+ summary: "Print text your person can paste into any chat",
827
+ about: ["With a linked server, or --server, the text includes that server's private save links."],
828
+ options: serverOption,
829
+ async run(ctx, _args, opts) {
830
+ const saved = await ctx.credentials();
831
+ const origin = serverFlag(opts) ? person.serverOrigin(serverFlag(opts)) : saved?.server;
832
+ const text = await core.assistantInstructions(origin, { fetcher: ctx.fetch });
833
+ if (ctx.json) return ctx.printJson({ instructions: text });
834
+ ctx.out(text);
835
+ },
836
+ },
837
+ };
838
+
839
+ /** The major version of the OpenCode on this machine's PATH, or null when there is none. @param {Context} ctx */
840
+ function openCodeMajor(ctx) {
841
+ try {
842
+ const version = execFileSync("opencode", ["--version"], { env: ctx.env, timeout: 5000, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
843
+ return Number(/^(\d+)\./.exec(version.trim())?.[1]) || null;
844
+ } catch {
845
+ return null;
846
+ }
847
+ }
848
+
849
+ /** @param {Context} ctx @param {import("./agents.js").Agent[]} all @param {boolean} global */
850
+ async function listAgents(ctx, all, global) {
851
+ const rows = [];
852
+ for (const agent of all) {
853
+ const dir = targets([agent], { global, cwd: ctx.cwd })[0].dir;
854
+ const here = await occupant(dir);
855
+ rows.push({ id: agent.id, name: agent.name, found: agent.installed, dir, skill: here.kind === "ours" ? (here.version ?? "yes") : null });
856
+ }
857
+ if (ctx.json) return ctx.printJson({ agents: rows });
858
+ const { c } = ctx;
859
+ for (const row of rows) {
860
+ const state = row.skill ? c.green(`skill ${row.skill}`) : row.found ? c.dim("found, no skill") : c.dim("not found");
861
+ ctx.out(`${row.id.padEnd(16)} ${state}`);
862
+ ctx.out(c.dim(`${" ".repeat(17)}${ctx.tilde(row.dir)}`));
863
+ }
864
+ }