@zero-gravity/zero-gravity 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.
- package/CHANGELOG.md +29 -0
- package/LICENSE +21 -0
- package/README.md +50 -2
- package/THIRD-PARTY-NOTICES.md +100 -0
- package/dist/adv-context-SLTP32JQ.js +36 -0
- package/dist/advanced-EPLZB6DG.js +164 -0
- package/dist/agents-JYRQHH7R.js +181 -0
- package/dist/chat-AEHVCKXX.js +47 -0
- package/dist/chunk-2OH5KHWO.js +112 -0
- package/dist/chunk-2ZYSAYMJ.js +108 -0
- package/dist/chunk-4BZ4IXTO.js +161 -0
- package/dist/chunk-4ITJY25Z.js +144 -0
- package/dist/chunk-4JBLZQAQ.js +65 -0
- package/dist/chunk-6QLYRU3N.js +28 -0
- package/dist/chunk-7TACFVY2.js +57 -0
- package/dist/chunk-AY36KJTH.js +3023 -0
- package/dist/chunk-BJABQO7S.js +378 -0
- package/dist/chunk-C2GFK4JP.js +387 -0
- package/dist/chunk-CDC2K2KP.js +47 -0
- package/dist/chunk-DKCCXMSE.js +27 -0
- package/dist/chunk-FC3UOHOO.js +194 -0
- package/dist/chunk-FIASMDLX.js +216 -0
- package/dist/chunk-GMVDCQVW.js +88 -0
- package/dist/chunk-JQYZX56A.js +231 -0
- package/dist/chunk-JU5PGDOD.js +138 -0
- package/dist/chunk-JUZP5SXD.js +309 -0
- package/dist/chunk-KGA7VWQG.js +70 -0
- package/dist/chunk-L7VNR5LM.js +407 -0
- package/dist/chunk-LOSXCWHU.js +145 -0
- package/dist/chunk-NVC433AX.js +24 -0
- package/dist/chunk-QH27MDJM.js +248 -0
- package/dist/chunk-QUC5URWQ.js +708 -0
- package/dist/chunk-R2CPYTSP.js +31 -0
- package/dist/chunk-R5KQACGR.js +2833 -0
- package/dist/chunk-R6DONQKN.js +153 -0
- package/dist/chunk-RIX4S3J7.js +4747 -0
- package/dist/chunk-SZKAZ2VN.js +35 -0
- package/dist/chunk-T6DDNE3W.js +1338 -0
- package/dist/chunk-U4URD6TU.js +4605 -0
- package/dist/chunk-U5UIUB6L.js +51 -0
- package/dist/chunk-UMC77TR3.js +79 -0
- package/dist/chunk-UQURXFAE.js +80 -0
- package/dist/chunk-VBG7T7XY.js +1703 -0
- package/dist/chunk-VCCMJIAG.js +326 -0
- package/dist/chunk-VS375NYD.js +91 -0
- package/dist/chunk-WANZOLI5.js +1073 -0
- package/dist/chunk-WUF3TVAE.js +51 -0
- package/dist/chunk-XCWLFZSM.js +149 -0
- package/dist/chunk-YJEUXO5I.js +76 -0
- package/dist/chunk-YR6RCC6Y.js +894 -0
- package/dist/chunk-ZQFAX275.js +35 -0
- package/dist/config-ELG4FQ3K.js +30 -0
- package/dist/config-IEWRCG7R.js +50 -0
- package/dist/doctor-ZZC2D3RW.js +357 -0
- package/dist/ext-context-RIMZMEPB.js +37 -0
- package/dist/index.js +20 -0
- package/dist/init-UB3E47KM.js +22 -0
- package/dist/integrations-HW4VTLN4.js +183 -0
- package/dist/main-RAWWT22W.js +115 -0
- package/dist/mcp-SWD4SO35.js +232 -0
- package/dist/mcp-context-PM5FY665.js +28 -0
- package/dist/memory-QQ54GRCN.js +128 -0
- package/dist/memory-session-R6DGT6CS.js +14 -0
- package/dist/memory-summary-4P26B2ZY.js +18 -0
- package/dist/plugins-VUGTEUNV.js +166 -0
- package/dist/providers-O3WOVP5Q.js +417 -0
- package/dist/report-DDIZ6BLF.js +28 -0
- package/dist/sec-context-VQHW6TOZ.js +15 -0
- package/dist/security-SAYW4LU4.js +95 -0
- package/dist/sessions-CL6CRNQL.js +160 -0
- package/dist/skills-7KDGTTKX.js +126 -0
- package/dist/version-6E6A23B3.js +13 -0
- package/package.json +70 -4
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
setConfigValue
|
|
4
|
+
} from "./chunk-BJABQO7S.js";
|
|
5
|
+
import {
|
|
6
|
+
entryRow,
|
|
7
|
+
shortDate
|
|
8
|
+
} from "./chunk-QUC5URWQ.js";
|
|
9
|
+
import "./chunk-L7VNR5LM.js";
|
|
10
|
+
import "./chunk-CDC2K2KP.js";
|
|
11
|
+
import "./chunk-YJEUXO5I.js";
|
|
12
|
+
import "./chunk-KGA7VWQG.js";
|
|
13
|
+
import {
|
|
14
|
+
confirm,
|
|
15
|
+
guard,
|
|
16
|
+
openMemoryEnv,
|
|
17
|
+
promptLine
|
|
18
|
+
} from "./chunk-YR6RCC6Y.js";
|
|
19
|
+
import "./chunk-SZKAZ2VN.js";
|
|
20
|
+
import "./chunk-DKCCXMSE.js";
|
|
21
|
+
import "./chunk-U5UIUB6L.js";
|
|
22
|
+
import {
|
|
23
|
+
MEMORY_KINDS,
|
|
24
|
+
parseKind
|
|
25
|
+
} from "./chunk-XCWLFZSM.js";
|
|
26
|
+
import "./chunk-JQYZX56A.js";
|
|
27
|
+
import "./chunk-QH27MDJM.js";
|
|
28
|
+
import "./chunk-ZQFAX275.js";
|
|
29
|
+
import {
|
|
30
|
+
ZgError
|
|
31
|
+
} from "./chunk-FC3UOHOO.js";
|
|
32
|
+
import {
|
|
33
|
+
redactSecrets
|
|
34
|
+
} from "./chunk-WUF3TVAE.js";
|
|
35
|
+
|
|
36
|
+
// src/cli/commands/memory.ts
|
|
37
|
+
function registerMemory(program, ctx) {
|
|
38
|
+
const say = (t) => ctx.stdout(redactSecrets(t));
|
|
39
|
+
const cmd = program.command("memory").description("Persistent memory: notes zg keeps between sessions (off until you enable it)");
|
|
40
|
+
const status = async () => {
|
|
41
|
+
const env = await openMemoryEnv(ctx);
|
|
42
|
+
const s = env.config.memory;
|
|
43
|
+
const st = await guard(() => env.memory.status());
|
|
44
|
+
say(`Persistent memory: ${s.enabled ? "ON" : "off"}`);
|
|
45
|
+
say(` project memory: ${s.projectMemory ? "allowed" : "off"} global preferences: ${s.globalPreferences ? "allowed" : "off"} auto-save summaries: ${s.autoSave ? "on" : "off"}`);
|
|
46
|
+
say(` project: ${env.project ? env.project.path : "none here (start zg inside a project)"}`);
|
|
47
|
+
for (const x of st) say(` ${x.target === "project" ? "project notes" : "global preferences"}: ${x.available ? x.count : "unavailable"}${x.file ? ` ${x.file}` : ""}`);
|
|
48
|
+
for (const x of st) for (const n of x.notes) say(` note: ${n}`);
|
|
49
|
+
say(` data folder: ${ctx.configDir}`);
|
|
50
|
+
say(s.enabled ? " Turn off: zg memory disable Remove notes: zg memory clear" : " Turn on: zg memory enable (nothing is remembered between sessions while it is off)");
|
|
51
|
+
};
|
|
52
|
+
cmd.action(status);
|
|
53
|
+
cmd.command("status").description("Show whether memory is on and what is stored").action(status);
|
|
54
|
+
cmd.command("list").description("List saved notes for this project (or --global preferences)").option("--global", "list global preferences instead").option("--kind <kind>", `only one kind (${MEMORY_KINDS.join(", ")})`).option("--since <date>", "updated on or after YYYY-MM-DD").option("--until <date>", "updated on or before YYYY-MM-DD").option("--json", "machine-readable output").action(async (o) => {
|
|
55
|
+
const env = await openMemoryEnv(ctx);
|
|
56
|
+
const entries = await guard(() => env.memory.list(o.global ? "global" : "project", { ...o.kind ? { kind: parseKind(o.kind) } : {}, ...o.since ? { since: o.since } : {}, ...o.until ? { until: o.until } : {} }));
|
|
57
|
+
if (o.json) return say(JSON.stringify(entries, null, 2));
|
|
58
|
+
if (entries.length === 0) return say(`Nothing is saved ${o.global ? "in global preferences" : "for this project"} yet.`);
|
|
59
|
+
for (const e of entries) say(entryRow(e));
|
|
60
|
+
});
|
|
61
|
+
cmd.command("search <query>").description("Search saved notes (case-insensitive, exact text)").option("--global", "global preferences only").option("--kind <kind>", "only one kind").option("--since <date>", "updated on or after YYYY-MM-DD").option("--until <date>", "updated on or before YYYY-MM-DD").option("--json", "machine-readable output").action(async (query, o) => {
|
|
62
|
+
const env = await openMemoryEnv(ctx);
|
|
63
|
+
const hits = await guard(() => env.memory.search(query, { targets: o.global ? ["global"] : ["project", "global"], filters: { ...o.kind ? { kind: parseKind(o.kind) } : {}, ...o.since ? { since: o.since } : {}, ...o.until ? { until: o.until } : {} } }));
|
|
64
|
+
if (o.json) return say(JSON.stringify(hits.map((h) => ({ scope: h.scope, ...h.entry })), null, 2));
|
|
65
|
+
if (hits.length === 0) return say(`No saved note contains "${query}".`);
|
|
66
|
+
for (const h of hits) say(`${h.entry.id} ${h.scope.padEnd(7)} [${h.entry.kind}] ${h.snippet}`);
|
|
67
|
+
});
|
|
68
|
+
cmd.command("show <id>").description("Show one note in full").action(async (id) => {
|
|
69
|
+
const env = await openMemoryEnv(ctx);
|
|
70
|
+
const { entry, target } = await guard(() => env.memory.find(id));
|
|
71
|
+
say(`Id: ${entry.id}
|
|
72
|
+
Scope: ${target}
|
|
73
|
+
Kind: ${entry.kind}
|
|
74
|
+
Source: ${entry.source}${entry.sessionId ? ` (session ${entry.sessionId.slice(0, 8)})` : ""}
|
|
75
|
+
Created: ${shortDate(entry.createdAt)}
|
|
76
|
+
Updated: ${shortDate(entry.updatedAt)}${entry.tags.length ? `
|
|
77
|
+
Tags: ${entry.tags.join(", ")}` : ""}
|
|
78
|
+
|
|
79
|
+
${entry.text}`);
|
|
80
|
+
});
|
|
81
|
+
cmd.command("add <text...>").description("Save a note (passwords, keys and tokens are refused)").option("--global", "save as a global preference instead of a project note").option("--kind <kind>", `one of ${MEMORY_KINDS.join(", ")} (default context)`).action(async (text, o) => {
|
|
82
|
+
const env = await openMemoryEnv(ctx);
|
|
83
|
+
const e = await guard(() => env.memory.add(o.global ? "global" : "project", { text: text.join(" "), kind: parseKind(o.kind) }));
|
|
84
|
+
say(`Saved ${e.id} (${e.kind}, ${o.global ? "global" : "this project"}).`);
|
|
85
|
+
});
|
|
86
|
+
cmd.command("edit <id> [text...]").description("Change a note's text: give the new text, or you are asked for it").option("--kind <kind>", "also change the kind").action(async (id, text, o) => {
|
|
87
|
+
const env = await openMemoryEnv(ctx);
|
|
88
|
+
const { entry, target } = await guard(() => env.memory.find(id));
|
|
89
|
+
let next = text.join(" ").trim();
|
|
90
|
+
if (next === "" && !o.kind) {
|
|
91
|
+
say(`Current text of ${entry.id}:
|
|
92
|
+
${entry.text}`);
|
|
93
|
+
const typed = await promptLine(ctx, "New text (empty to cancel): ");
|
|
94
|
+
if (typed === null) throw new ZgError("No new text was given.", { hint: `Pass it on the command line: zg memory edit ${entry.id} "new text"` });
|
|
95
|
+
if (typed === "") return say("Cancelled. Nothing was changed.");
|
|
96
|
+
next = typed;
|
|
97
|
+
}
|
|
98
|
+
const e = await guard(() => env.memory.edit(target, entry.id, { ...next !== "" ? { text: next } : {}, ...o.kind ? { kind: parseKind(o.kind) } : {} }));
|
|
99
|
+
say(`Updated ${e.id}.`);
|
|
100
|
+
});
|
|
101
|
+
cmd.command("delete <id>").description("Remove one note (asks first)").option("--yes", "do not ask").action(async (id, o) => {
|
|
102
|
+
const env = await openMemoryEnv(ctx);
|
|
103
|
+
const { entry, target } = await guard(() => env.memory.find(id));
|
|
104
|
+
say(`${entry.id} (${target}, ${entry.kind}): ${entry.text.slice(0, 120)}`);
|
|
105
|
+
if (!await confirm(ctx, "Remove this note for good?", o.yes === true)) return say("Cancelled. Nothing was deleted.");
|
|
106
|
+
await guard(() => env.memory.remove(target, entry.id));
|
|
107
|
+
say(`Removed ${entry.id}.`);
|
|
108
|
+
});
|
|
109
|
+
cmd.command("clear").description("Delete ALL notes of this project (or --global preferences), with their index and backups").option("--global", "clear global preferences instead").option("--yes", "do not ask").action(async (o) => {
|
|
110
|
+
const env = await openMemoryEnv(ctx);
|
|
111
|
+
const target = o.global ? "global" : "project";
|
|
112
|
+
const n = (await guard(() => env.memory.list(target))).length;
|
|
113
|
+
if (n === 0) return say("Nothing is saved there, so nothing was deleted.");
|
|
114
|
+
if (!await confirm(ctx, `Delete all ${n} ${target === "global" ? "global preference" : "project"} note(s), their index and backups for good?`, o.yes === true)) return say("Cancelled. Nothing was deleted.");
|
|
115
|
+
await guard(() => env.memory.clear(target));
|
|
116
|
+
say(`Deleted ${n} note(s).`);
|
|
117
|
+
});
|
|
118
|
+
const toggle = (on) => async () => {
|
|
119
|
+
const { config } = await ctx.manager.load();
|
|
120
|
+
await ctx.manager.save(setConfigValue(config, "memory.enabled", String(on)));
|
|
121
|
+
say(on ? `Persistent memory is ON. Notes you save are kept on this computer and sent to your AI provider as context in this project's chats. Passwords, keys and tokens are never stored (detection is pattern-based, not perfect). Add a note: zg memory add "..."` : "Persistent memory is off. Saved notes stay on disk but are no longer used; zg memory clear removes them.");
|
|
122
|
+
};
|
|
123
|
+
cmd.command("enable").description("Turn persistent memory on").action(toggle(true));
|
|
124
|
+
cmd.command("disable").description("Turn persistent memory off (stored notes stay until you clear them)").action(toggle(false));
|
|
125
|
+
}
|
|
126
|
+
export {
|
|
127
|
+
registerMemory
|
|
128
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
MemoryController,
|
|
4
|
+
createSummaryGenerator
|
|
5
|
+
} from "./chunk-FIASMDLX.js";
|
|
6
|
+
import "./chunk-VS375NYD.js";
|
|
7
|
+
import "./chunk-JUZP5SXD.js";
|
|
8
|
+
import "./chunk-4ITJY25Z.js";
|
|
9
|
+
import "./chunk-XCWLFZSM.js";
|
|
10
|
+
import "./chunk-WUF3TVAE.js";
|
|
11
|
+
export {
|
|
12
|
+
MemoryController,
|
|
13
|
+
createSummaryGenerator
|
|
14
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
SUMMARY_MAX_CHARS,
|
|
4
|
+
SUMMARY_SYSTEM,
|
|
5
|
+
fallbackSummary,
|
|
6
|
+
mentionedFiles,
|
|
7
|
+
summarise,
|
|
8
|
+
transcriptForSummary
|
|
9
|
+
} from "./chunk-VS375NYD.js";
|
|
10
|
+
import "./chunk-XCWLFZSM.js";
|
|
11
|
+
export {
|
|
12
|
+
SUMMARY_MAX_CHARS,
|
|
13
|
+
SUMMARY_SYSTEM,
|
|
14
|
+
fallbackSummary,
|
|
15
|
+
mentionedFiles,
|
|
16
|
+
summarise,
|
|
17
|
+
transcriptForSummary
|
|
18
|
+
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
extGuard,
|
|
4
|
+
openExtEnv,
|
|
5
|
+
requireOn
|
|
6
|
+
} from "./chunk-RIX4S3J7.js";
|
|
7
|
+
import "./chunk-LOSXCWHU.js";
|
|
8
|
+
import "./chunk-WANZOLI5.js";
|
|
9
|
+
import "./chunk-JUZP5SXD.js";
|
|
10
|
+
import "./chunk-4ITJY25Z.js";
|
|
11
|
+
import "./chunk-CDC2K2KP.js";
|
|
12
|
+
import "./chunk-YJEUXO5I.js";
|
|
13
|
+
import "./chunk-KGA7VWQG.js";
|
|
14
|
+
import "./chunk-2ZYSAYMJ.js";
|
|
15
|
+
import {
|
|
16
|
+
confirm
|
|
17
|
+
} from "./chunk-YR6RCC6Y.js";
|
|
18
|
+
import "./chunk-SZKAZ2VN.js";
|
|
19
|
+
import "./chunk-DKCCXMSE.js";
|
|
20
|
+
import "./chunk-U5UIUB6L.js";
|
|
21
|
+
import "./chunk-XCWLFZSM.js";
|
|
22
|
+
import "./chunk-GMVDCQVW.js";
|
|
23
|
+
import "./chunk-JQYZX56A.js";
|
|
24
|
+
import "./chunk-R6DONQKN.js";
|
|
25
|
+
import "./chunk-QH27MDJM.js";
|
|
26
|
+
import "./chunk-R2CPYTSP.js";
|
|
27
|
+
import "./chunk-ZQFAX275.js";
|
|
28
|
+
import "./chunk-FC3UOHOO.js";
|
|
29
|
+
import {
|
|
30
|
+
redactSecrets
|
|
31
|
+
} from "./chunk-WUF3TVAE.js";
|
|
32
|
+
|
|
33
|
+
// src/cli/commands/plugins.ts
|
|
34
|
+
var row = (v) => `${v.id.padEnd(24)} ${v.version.padEnd(8)} ${v.enabled ? "enabled " : "disabled"} ${v.state.padEnd(10)} ${v.description}${v.problems.length ? ` ! ${v.problems.join("; ")}` : ""}`;
|
|
35
|
+
function installLines(p) {
|
|
36
|
+
return [
|
|
37
|
+
`Plugin: ${p.name} (${p.id}) ${p.version} by ${p.author}${p.publisher ? `, published by ${p.publisher}` : ""}`,
|
|
38
|
+
`Source: ${p.source}`,
|
|
39
|
+
`Files: ${p.files} (${p.bytes} bytes), fingerprint ${p.hash.slice(0, 16)}`,
|
|
40
|
+
`Asks for: ${p.permissions.join(", ") || "no special permissions"}`,
|
|
41
|
+
`Adds: commands ${p.commands.join(", ") || "none"}; tools ${p.tools.join(", ") || "none"}; ships ${p.ships.join(", ") || "nothing else"}`,
|
|
42
|
+
...p.replaces ? [`Replaces: version ${p.replaces}`] : [],
|
|
43
|
+
...p.warnings.map((w) => `Warning: ${w}`),
|
|
44
|
+
"Installing only copies the files. It is installed DISABLED and no code runs. No install scripts are ever run."
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
function trustLines(t) {
|
|
48
|
+
return [
|
|
49
|
+
`Enable ${t.id} ${t.version}${t.publisher ? ` (publisher: ${t.publisher})` : ""}`,
|
|
50
|
+
"This is third-party code. It runs in a separate process, but zg does NOT vouch for it. Only enable code you have read or trust.",
|
|
51
|
+
...t.permissions.length ? t.permissions.map((p) => ` permission ${p.name}: ${p.summary}
|
|
52
|
+
enforcement: ${p.enforcement}`) : [" no special permissions requested"],
|
|
53
|
+
...t.newPermissions.length ? [` NEW since you last trusted it: ${t.newPermissions.join(", ")}`] : [],
|
|
54
|
+
`Isolation: ${t.isolation.level === "process-and-permission-model" ? "separate process + Node.js permission model" : "separate process only (this Node.js has no permission model)"}`,
|
|
55
|
+
...t.isolation.guarantees.map((g) => ` + ${g}`),
|
|
56
|
+
...t.isolation.limits.map((l) => ` - LIMIT: ${l}`)
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
function registerPlugins(program, ctx) {
|
|
60
|
+
const say = (t) => ctx.stdout(redactSecrets(t));
|
|
61
|
+
const cmd = program.command("plugins").description("Plugins: third-party code that adds commands and tools (installed disabled; run in a separate process)");
|
|
62
|
+
const list = async () => {
|
|
63
|
+
const env = await openExtEnv(ctx);
|
|
64
|
+
if (!env.config.extensions.plugins.enabled) say("Plugins are off (turn on: zg config set extensions.plugins.enabled true). Installed plugins never run while this is off.");
|
|
65
|
+
const l = await env.svc.plugins.list();
|
|
66
|
+
say(l.length ? l.map(row).join("\n") : "No plugins installed. Install one from a local folder: zg plugins install <path>");
|
|
67
|
+
};
|
|
68
|
+
cmd.action(list);
|
|
69
|
+
cmd.command("list").description("List installed plugins").action(list);
|
|
70
|
+
cmd.command("install <source>").description("Install a plugin from a local folder or archive. It is installed disabled; nothing is run.").option("--update", "replace an installed plugin with the same id").option("--yes", "do not ask").action(async (source, o) => {
|
|
71
|
+
const env = await openExtEnv(ctx);
|
|
72
|
+
requireOn(env, "plugins");
|
|
73
|
+
const plan = await extGuard(
|
|
74
|
+
() => env.svc.plugins.install(source, {
|
|
75
|
+
update: o.update === true,
|
|
76
|
+
approve: async (p) => {
|
|
77
|
+
for (const l of installLines(p)) say(l);
|
|
78
|
+
return confirm(ctx, "Install this plugin (disabled)?", o.yes === true);
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
);
|
|
82
|
+
say(`Installed ${plan.id} ${plan.version} (disabled). Review it: zg plugins inspect ${plan.id} Enable: zg plugins enable ${plan.id}`);
|
|
83
|
+
});
|
|
84
|
+
cmd.command("update <id>").description("Re-install from the recorded source (shows the change and asks first)").option("--yes", "do not ask").action(async (id, o) => {
|
|
85
|
+
const env = await openExtEnv(ctx);
|
|
86
|
+
const plan = await extGuard(() => env.svc.plugins.update(id, async (p) => {
|
|
87
|
+
for (const l of installLines(p)) say(l);
|
|
88
|
+
return confirm(ctx, "Apply this update?", o.yes === true);
|
|
89
|
+
}));
|
|
90
|
+
say(`Updated ${plan.id} to ${plan.version}. It stays disabled until you enable it again.`);
|
|
91
|
+
});
|
|
92
|
+
cmd.command("remove <id>").description("Stop and delete a plugin").option("--yes", "do not ask").action(async (id, o) => {
|
|
93
|
+
const env = await openExtEnv(ctx);
|
|
94
|
+
if (!await confirm(ctx, `Remove plugin "${id}"?`, o.yes === true)) return say("Cancelled. Nothing was removed.");
|
|
95
|
+
await extGuard(() => env.svc.plugins.remove(id));
|
|
96
|
+
say(`Removed "${id}".`);
|
|
97
|
+
});
|
|
98
|
+
cmd.command("enable <id>").description("Trust and enable a plugin (shows exactly what you are trusting and asks first)").option("--yes", "do not ask").action(async (id, o) => {
|
|
99
|
+
const env = await openExtEnv(ctx);
|
|
100
|
+
requireOn(env, "plugins");
|
|
101
|
+
try {
|
|
102
|
+
const v = await extGuard(
|
|
103
|
+
() => env.svc.plugins.enable(id, async (t) => {
|
|
104
|
+
for (const l of trustLines(t)) say(l);
|
|
105
|
+
return confirm(ctx, "Trust and enable this plugin?", o.yes === true);
|
|
106
|
+
})
|
|
107
|
+
);
|
|
108
|
+
say(`Plugin "${v.id}" is enabled. It starts only when something uses it.`);
|
|
109
|
+
} finally {
|
|
110
|
+
await env.svc.shutdown();
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
cmd.command("disable <id>").description("Stop a plugin and switch it off").action(async (id) => {
|
|
114
|
+
const env = await openExtEnv(ctx);
|
|
115
|
+
const v = await extGuard(() => env.svc.plugins.disable(id));
|
|
116
|
+
say(`Plugin "${v.id}" is disabled and stopped.`);
|
|
117
|
+
});
|
|
118
|
+
cmd.command("inspect <id>").description("Show a plugin's manifest, permissions, isolation limits and state").action(async (id) => {
|
|
119
|
+
const env = await openExtEnv(ctx);
|
|
120
|
+
const r = await extGuard(() => env.svc.plugins.inspect(id));
|
|
121
|
+
const v = r.view;
|
|
122
|
+
say([`${v.name} (${v.id}) ${v.version} by ${v.author}`, v.description, `State: ${v.state} ${v.enabled ? "enabled" : "disabled"} ${v.trusted ? "trusted" : "not trusted yet"}`, `Asks for: ${v.requested.join(", ") || "nothing"} Granted: ${v.granted.join(", ") || "nothing"}`, `Commands: ${v.commands.join(", ") || "none"} Tools: ${v.tools.join(", ") || "none"}`, ...v.lastError ? [`Last error: ${v.lastError}`] : [], ...v.problems.map((p) => `! ${p}`), `Isolation: ${r.isolation.level}`, ...r.isolation.limits.map((l) => ` - LIMIT: ${l}`)].join("\n"));
|
|
123
|
+
});
|
|
124
|
+
cmd.command("validate <path>").description("Check a plugin folder or archive without installing or running it").action(async (p) => {
|
|
125
|
+
const env = await openExtEnv(ctx);
|
|
126
|
+
const r = await extGuard(() => env.svc.plugins.validatePath(p));
|
|
127
|
+
for (const e of r.errors) say(`[fail] ${e}`);
|
|
128
|
+
for (const w of r.warnings) say(`[warn] ${w}`);
|
|
129
|
+
say(r.ok ? `[ok] valid: ${r.manifest?.name ?? "?"} ${r.manifest?.version ?? ""} (${r.files} files)` : "Not valid.");
|
|
130
|
+
if (!r.ok) process.exitCode = 1;
|
|
131
|
+
});
|
|
132
|
+
cmd.command("doctor").description("Check isolation support and that installed plugin files are intact").option("--json", "machine-readable output").action(async (o) => {
|
|
133
|
+
const env = await openExtEnv(ctx);
|
|
134
|
+
const r = await env.svc.plugins.doctor();
|
|
135
|
+
say(o.json ? JSON.stringify(r, null, 2) : r.lines.join("\n"));
|
|
136
|
+
if (!r.ok) process.exitCode = 1;
|
|
137
|
+
});
|
|
138
|
+
cmd.command("run <id> <command> [args...]").description("Run one command that an enabled plugin provides").action(async (id, name, args) => {
|
|
139
|
+
const env = await openExtEnv(ctx);
|
|
140
|
+
requireOn(env, "plugins");
|
|
141
|
+
const ac = new AbortController();
|
|
142
|
+
const onInt = () => ac.abort();
|
|
143
|
+
process.once("SIGINT", onInt);
|
|
144
|
+
try {
|
|
145
|
+
say(await extGuard(() => env.svc.plugins.runCommand(id, name, args, ac.signal)));
|
|
146
|
+
} finally {
|
|
147
|
+
process.off("SIGINT", onInt);
|
|
148
|
+
await env.svc.shutdown();
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
cmd.command("restart <id>").description("Stop a plugin's process so it starts fresh next time").action(async (id) => {
|
|
152
|
+
const env = await openExtEnv(ctx);
|
|
153
|
+
await extGuard(() => env.svc.plugins.restart(id));
|
|
154
|
+
say(`Plugin "${id}" was stopped.`);
|
|
155
|
+
});
|
|
156
|
+
cmd.command("config <id> <key> <value>").description("Set one of a plugin's declared options (secrets are refused: use an environment variable name)").action(async (id, key, value) => {
|
|
157
|
+
const env = await openExtEnv(ctx);
|
|
158
|
+
await extGuard(() => env.svc.plugins.setConfig(id, key, value));
|
|
159
|
+
say(`${id}: ${key} set.`);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
export {
|
|
163
|
+
installLines,
|
|
164
|
+
registerPlugins,
|
|
165
|
+
trustLines
|
|
166
|
+
};
|