@getmateo/cli 0.0.0-stage → 0.19.8
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 +211 -0
- package/bin/mateo +3 -0
- package/dist/classify.d.ts +19 -0
- package/dist/classify.js +49 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +143 -0
- package/dist/commands/agent/archive.d.ts +27 -0
- package/dist/commands/agent/archive.js +88 -0
- package/dist/commands/agent/attach.d.ts +8 -0
- package/dist/commands/agent/attach.js +160 -0
- package/dist/commands/agent/delete.d.ts +15 -0
- package/dist/commands/agent/delete.js +104 -0
- package/dist/commands/agent/detach.d.ts +16 -0
- package/dist/commands/agent/detach.js +44 -0
- package/dist/commands/agent/import.d.ts +14 -0
- package/dist/commands/agent/import.js +108 -0
- package/dist/commands/agent/index.d.ts +3 -0
- package/dist/commands/agent/index.js +56 -0
- package/dist/commands/agent/inspect.d.ts +15 -0
- package/dist/commands/agent/inspect.js +196 -0
- package/dist/commands/agent/logs.d.ts +39 -0
- package/dist/commands/agent/logs.js +369 -0
- package/dist/commands/agent/ls.d.ts +61 -0
- package/dist/commands/agent/ls.js +201 -0
- package/dist/commands/agent/mode.d.ts +18 -0
- package/dist/commands/agent/mode.js +100 -0
- package/dist/commands/agent/open.d.ts +11 -0
- package/dist/commands/agent/open.js +74 -0
- package/dist/commands/agent/reload.d.ts +25 -0
- package/dist/commands/agent/reload.js +64 -0
- package/dist/commands/agent/run.d.ts +77 -0
- package/dist/commands/agent/run.js +556 -0
- package/dist/commands/agent/send.d.ts +21 -0
- package/dist/commands/agent/send.js +187 -0
- package/dist/commands/agent/stop.d.ts +17 -0
- package/dist/commands/agent/stop.js +102 -0
- package/dist/commands/agent/update.d.ts +51 -0
- package/dist/commands/agent/update.js +173 -0
- package/dist/commands/agent/wait.d.ts +31 -0
- package/dist/commands/agent/wait.js +161 -0
- package/dist/commands/clone.d.ts +17 -0
- package/dist/commands/clone.js +59 -0
- package/dist/commands/daemon/config.d.ts +3 -0
- package/dist/commands/daemon/config.js +103 -0
- package/dist/commands/daemon/index.d.ts +3 -0
- package/dist/commands/daemon/index.js +28 -0
- package/dist/commands/daemon/local-daemon.d.ts +13 -0
- package/dist/commands/daemon/local-daemon.js +105 -0
- package/dist/commands/daemon/pair.d.ts +30 -0
- package/dist/commands/daemon/pair.js +145 -0
- package/dist/commands/daemon/reload.d.ts +12 -0
- package/dist/commands/daemon/reload.js +44 -0
- package/dist/commands/daemon/restart.d.ts +29 -0
- package/dist/commands/daemon/restart.js +169 -0
- package/dist/commands/daemon/runtime-toolchain.d.ts +6 -0
- package/dist/commands/daemon/runtime-toolchain.js +87 -0
- package/dist/commands/daemon/set-password.d.ts +17 -0
- package/dist/commands/daemon/set-password.js +89 -0
- package/dist/commands/daemon/start.d.ts +20 -0
- package/dist/commands/daemon/start.js +52 -0
- package/dist/commands/daemon/status.d.ts +13 -0
- package/dist/commands/daemon/status.js +119 -0
- package/dist/commands/daemon/stop.d.ts +20 -0
- package/dist/commands/daemon/stop.js +58 -0
- package/dist/commands/fleet/index.d.ts +4 -0
- package/dist/commands/fleet/index.js +57 -0
- package/dist/commands/heartbeat/index.d.ts +3 -0
- package/dist/commands/heartbeat/index.js +139 -0
- package/dist/commands/hooks.d.ts +19 -0
- package/dist/commands/hooks.js +89 -0
- package/dist/commands/hub/authority.d.ts +17 -0
- package/dist/commands/hub/authority.js +18 -0
- package/dist/commands/hub/connect.d.ts +24 -0
- package/dist/commands/hub/connect.js +44 -0
- package/dist/commands/hub/credentials.d.ts +21 -0
- package/dist/commands/hub/credentials.js +143 -0
- package/dist/commands/hub/daemon-client.d.ts +41 -0
- package/dist/commands/hub/daemon-client.js +14 -0
- package/dist/commands/hub/deploy-bundle.d.ts +16 -0
- package/dist/commands/hub/deploy-bundle.js +248 -0
- package/dist/commands/hub/deploy-triggers.d.ts +6 -0
- package/dist/commands/hub/deploy-triggers.js +116 -0
- package/dist/commands/hub/deploy.d.ts +50 -0
- package/dist/commands/hub/deploy.js +159 -0
- package/dist/commands/hub/disconnect.d.ts +17 -0
- package/dist/commands/hub/disconnect.js +24 -0
- package/dist/commands/hub/error.d.ts +6 -0
- package/dist/commands/hub/error.js +9 -0
- package/dist/commands/hub/export.d.ts +28 -0
- package/dist/commands/hub/export.js +80 -0
- package/dist/commands/hub/help.d.ts +3 -0
- package/dist/commands/hub/help.js +5 -0
- package/dist/commands/hub/hub-client/index.d.ts +22 -0
- package/dist/commands/hub/hub-client/index.js +135 -0
- package/dist/commands/hub/hub-client/internal/contracts.d.ts +126 -0
- package/dist/commands/hub/hub-client/internal/contracts.js +85 -0
- package/dist/commands/hub/hub-client/internal/problem.d.ts +3 -0
- package/dist/commands/hub/hub-client/internal/problem.js +85 -0
- package/dist/commands/hub/hub-client/internal/transport.d.ts +15 -0
- package/dist/commands/hub/hub-client/internal/transport.js +30 -0
- package/dist/commands/hub/index.d.ts +20 -0
- package/dist/commands/hub/index.js +94 -0
- package/dist/commands/hub/init-plan.d.ts +33 -0
- package/dist/commands/hub/init-plan.js +94 -0
- package/dist/commands/hub/init.d.ts +37 -0
- package/dist/commands/hub/init.js +525 -0
- package/dist/commands/hub/login-flow.d.ts +34 -0
- package/dist/commands/hub/login-flow.js +78 -0
- package/dist/commands/hub/login.d.ts +23 -0
- package/dist/commands/hub/login.js +40 -0
- package/dist/commands/hub/logout.d.ts +33 -0
- package/dist/commands/hub/logout.js +71 -0
- package/dist/commands/hub/origin.d.ts +2 -0
- package/dist/commands/hub/origin.js +27 -0
- package/dist/commands/hub/permissions.d.ts +22 -0
- package/dist/commands/hub/permissions.js +61 -0
- package/dist/commands/hub/projects.d.ts +24 -0
- package/dist/commands/hub/projects.js +49 -0
- package/dist/commands/hub/reporter.d.ts +10 -0
- package/dist/commands/hub/reporter.js +11 -0
- package/dist/commands/hub/starter-agent-runtime.d.ts +37 -0
- package/dist/commands/hub/starter-agent-runtime.js +49 -0
- package/dist/commands/hub/starter-trigger.d.ts +10 -0
- package/dist/commands/hub/starter-trigger.js +30 -0
- package/dist/commands/hub/status-output.d.ts +13 -0
- package/dist/commands/hub/status-output.js +30 -0
- package/dist/commands/onboard.d.ts +14 -0
- package/dist/commands/onboard.js +169 -0
- package/dist/commands/open.d.ts +4 -0
- package/dist/commands/open.js +91 -0
- package/dist/commands/permit/allow.d.ts +38 -0
- package/dist/commands/permit/allow.js +138 -0
- package/dist/commands/permit/deny.d.ts +13 -0
- package/dist/commands/permit/deny.js +100 -0
- package/dist/commands/permit/index.d.ts +3 -0
- package/dist/commands/permit/index.js +27 -0
- package/dist/commands/permit/ls.d.ts +21 -0
- package/dist/commands/permit/ls.js +54 -0
- package/dist/commands/plugin/index.d.ts +23 -0
- package/dist/commands/plugin/index.js +174 -0
- package/dist/commands/plugin/scaffold.d.ts +6 -0
- package/dist/commands/plugin/scaffold.js +212 -0
- package/dist/commands/plugin/shared.d.ts +7 -0
- package/dist/commands/plugin/shared.js +34 -0
- package/dist/commands/plugin/update.d.ts +37 -0
- package/dist/commands/plugin/update.js +58 -0
- package/dist/commands/project/create.d.ts +10 -0
- package/dist/commands/project/create.js +43 -0
- package/dist/commands/project/delete.d.ts +9 -0
- package/dist/commands/project/delete.js +35 -0
- package/dist/commands/project/index.d.ts +3 -0
- package/dist/commands/project/index.js +28 -0
- package/dist/commands/project/ls.d.ts +5 -0
- package/dist/commands/project/ls.js +19 -0
- package/dist/commands/project/rename.d.ts +15 -0
- package/dist/commands/project/rename.js +52 -0
- package/dist/commands/project/shared.d.ts +11 -0
- package/dist/commands/project/shared.js +18 -0
- package/dist/commands/provider/diagnostic.d.ts +12 -0
- package/dist/commands/provider/diagnostic.js +31 -0
- package/dist/commands/provider/index.d.ts +3 -0
- package/dist/commands/provider/index.js +21 -0
- package/dist/commands/provider/ls.d.ts +19 -0
- package/dist/commands/provider/ls.js +46 -0
- package/dist/commands/provider/models.d.ts +20 -0
- package/dist/commands/provider/models.js +53 -0
- package/dist/commands/schedule/create.d.ts +19 -0
- package/dist/commands/schedule/create.js +41 -0
- package/dist/commands/schedule/delete.d.ts +10 -0
- package/dist/commands/schedule/delete.js +32 -0
- package/dist/commands/schedule/index.d.ts +3 -0
- package/dist/commands/schedule/index.js +66 -0
- package/dist/commands/schedule/inspect.d.ts +6 -0
- package/dist/commands/schedule/inspect.js +27 -0
- package/dist/commands/schedule/logs.d.ts +6 -0
- package/dist/commands/schedule/logs.js +24 -0
- package/dist/commands/schedule/ls.d.ts +5 -0
- package/dist/commands/schedule/ls.js +25 -0
- package/dist/commands/schedule/pause.d.ts +5 -0
- package/dist/commands/schedule/pause.js +24 -0
- package/dist/commands/schedule/resume.d.ts +5 -0
- package/dist/commands/schedule/resume.js +24 -0
- package/dist/commands/schedule/run-once.d.ts +5 -0
- package/dist/commands/schedule/run-once.js +24 -0
- package/dist/commands/schedule/schema.d.ts +21 -0
- package/dist/commands/schedule/schema.js +67 -0
- package/dist/commands/schedule/shared.d.ts +61 -0
- package/dist/commands/schedule/shared.js +360 -0
- package/dist/commands/schedule/types.d.ts +165 -0
- package/dist/commands/schedule/types.js +2 -0
- package/dist/commands/schedule/update.d.ts +19 -0
- package/dist/commands/schedule/update.js +40 -0
- package/dist/commands/script/index.d.ts +3 -0
- package/dist/commands/script/index.js +19 -0
- package/dist/commands/script/ls.d.ts +6 -0
- package/dist/commands/script/ls.js +20 -0
- package/dist/commands/script/schema.d.ts +5 -0
- package/dist/commands/script/schema.js +13 -0
- package/dist/commands/script/shared.d.ts +12 -0
- package/dist/commands/script/shared.js +59 -0
- package/dist/commands/script/start.d.ts +6 -0
- package/dist/commands/script/start.js +23 -0
- package/dist/commands/script/stop.d.ts +6 -0
- package/dist/commands/script/stop.js +23 -0
- package/dist/commands/terminal/capture.d.ts +10 -0
- package/dist/commands/terminal/capture.js +67 -0
- package/dist/commands/terminal/create.d.ts +11 -0
- package/dist/commands/terminal/create.js +29 -0
- package/dist/commands/terminal/index.d.ts +3 -0
- package/dist/commands/terminal/index.js +51 -0
- package/dist/commands/terminal/kill.d.ts +6 -0
- package/dist/commands/terminal/kill.js +36 -0
- package/dist/commands/terminal/ls.d.ts +11 -0
- package/dist/commands/terminal/ls.js +21 -0
- package/dist/commands/terminal/schema.d.ts +10 -0
- package/dist/commands/terminal/schema.js +17 -0
- package/dist/commands/terminal/send-keys.d.ts +7 -0
- package/dist/commands/terminal/send-keys.js +44 -0
- package/dist/commands/terminal/shared.d.ts +13 -0
- package/dist/commands/terminal/shared.js +64 -0
- package/dist/commands/terminal/upgrade-hosts.d.ts +11 -0
- package/dist/commands/terminal/upgrade-hosts.js +46 -0
- package/dist/commands/usage/index.d.ts +29 -0
- package/dist/commands/usage/index.js +62 -0
- package/dist/commands/usage/presentation.d.ts +4 -0
- package/dist/commands/usage/presentation.js +146 -0
- package/dist/commands/workspace/archive.d.ts +13 -0
- package/dist/commands/workspace/archive.js +43 -0
- package/dist/commands/workspace/create.d.ts +50 -0
- package/dist/commands/workspace/create.js +132 -0
- package/dist/commands/workspace/index.d.ts +3 -0
- package/dist/commands/workspace/index.js +50 -0
- package/dist/commands/workspace/ls.d.ts +11 -0
- package/dist/commands/workspace/ls.js +33 -0
- package/dist/commands/workspace/rename.d.ts +23 -0
- package/dist/commands/workspace/rename.js +63 -0
- package/dist/commands/workspace/setup.d.ts +12 -0
- package/dist/commands/workspace/setup.js +41 -0
- package/dist/commands/workspace/shared.d.ts +15 -0
- package/dist/commands/workspace/shared.js +29 -0
- package/dist/commands/worktree/archive.d.ts +21 -0
- package/dist/commands/worktree/archive.js +108 -0
- package/dist/commands/worktree/create-input.d.ts +15 -0
- package/dist/commands/worktree/create-input.js +56 -0
- package/dist/commands/worktree/create.d.ts +11 -0
- package/dist/commands/worktree/create.js +50 -0
- package/dist/commands/worktree/index.d.ts +3 -0
- package/dist/commands/worktree/index.js +29 -0
- package/dist/commands/worktree/ls.d.ts +18 -0
- package/dist/commands/worktree/ls.js +73 -0
- package/dist/commands/worktree/repository-directory.d.ts +6 -0
- package/dist/commands/worktree/repository-directory.js +9 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -0
- package/dist/output/index.d.ts +45 -0
- package/dist/output/index.js +47 -0
- package/dist/output/json.d.ts +11 -0
- package/dist/output/json.js +37 -0
- package/dist/output/pairing.d.ts +9 -0
- package/dist/output/pairing.js +36 -0
- package/dist/output/quiet.d.ts +9 -0
- package/dist/output/quiet.js +22 -0
- package/dist/output/render.d.ts +15 -0
- package/dist/output/render.js +84 -0
- package/dist/output/table.d.ts +13 -0
- package/dist/output/table.js +135 -0
- package/dist/output/types.d.ts +73 -0
- package/dist/output/types.js +8 -0
- package/dist/output/with-output.d.ts +43 -0
- package/dist/output/with-output.js +85 -0
- package/dist/output/yaml.d.ts +11 -0
- package/dist/output/yaml.js +38 -0
- package/dist/run.d.ts +14 -0
- package/dist/run.js +62 -0
- package/dist/ssh/ssh-tunnel.d.ts +2 -0
- package/dist/ssh/ssh-tunnel.js +3 -0
- package/dist/utils/agent-directory.d.ts +31 -0
- package/dist/utils/agent-directory.js +48 -0
- package/dist/utils/caller-agent.d.ts +14 -0
- package/dist/utils/caller-agent.js +16 -0
- package/dist/utils/client-id.d.ts +2 -0
- package/dist/utils/client-id.js +31 -0
- package/dist/utils/client.d.ts +57 -0
- package/dist/utils/client.js +360 -0
- package/dist/utils/command-options.d.ts +8 -0
- package/dist/utils/command-options.js +49 -0
- package/dist/utils/daemon-target.d.ts +13 -0
- package/dist/utils/daemon-target.js +51 -0
- package/dist/utils/duration.d.ts +7 -0
- package/dist/utils/duration.js +39 -0
- package/dist/utils/errors.d.ts +5 -0
- package/dist/utils/errors.js +10 -0
- package/dist/utils/paths.d.ts +12 -0
- package/dist/utils/paths.js +22 -0
- package/dist/utils/provider-model.d.ts +11 -0
- package/dist/utils/provider-model.js +49 -0
- package/dist/utils/timeline.d.ts +12 -0
- package/dist/utils/timeline.js +16 -0
- package/dist/utils/wait-for-stop.d.ts +2 -0
- package/dist/utils/wait-for-stop.js +28 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.js +24 -0
- package/package.json +63 -4
- package/README.md +0 -3
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type UpdateOutcome } from "./update.js";
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import type { PluginListItem, PluginLogEntry } from "@getmateo/protocol/messages";
|
|
4
|
+
import type { CommandOptions, ListResult, SingleResult } from "../../output/index.js";
|
|
5
|
+
import { type PluginScaffold } from "./scaffold.js";
|
|
6
|
+
interface PluginOptions extends CommandOptions {
|
|
7
|
+
host?: string;
|
|
8
|
+
id?: string;
|
|
9
|
+
ref?: string;
|
|
10
|
+
path?: string;
|
|
11
|
+
all?: boolean;
|
|
12
|
+
version?: string;
|
|
13
|
+
check?: boolean;
|
|
14
|
+
yes?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function runPluginInitCommand(directory: string, options: PluginOptions, _command: Command): Promise<SingleResult<PluginScaffold>>;
|
|
17
|
+
export declare function runPluginListCommand(pluginId: string | undefined, options: PluginOptions, _command: Command): Promise<ListResult<PluginListItem>>;
|
|
18
|
+
export declare function runPluginLogsCommand(pluginId: string, options: PluginOptions, _command: Command): Promise<ListResult<PluginLogEntry>>;
|
|
19
|
+
export declare function runPluginInstallCommand(source: string, options: PluginOptions, _command: Command): Promise<SingleResult<PluginListItem>>;
|
|
20
|
+
export declare function runPluginUpdateCommand(pluginId: string | undefined, options: PluginOptions, _command: Command): Promise<ListResult<UpdateOutcome>>;
|
|
21
|
+
export declare function createPluginCommand(): Command;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { expandUserPath } from "../../classify.js";
|
|
3
|
+
import { createInterface } from "node:readline/promises";
|
|
4
|
+
import { reviewPluginUpdates } from "./update.js";
|
|
5
|
+
import { Command } from "commander";
|
|
6
|
+
import { formatPluginSourceReference, parsePluginSourceReference, formatPluginIdentity, } from "@getmateo/protocol/plugin-source-reference";
|
|
7
|
+
import { withOutput } from "../../output/index.js";
|
|
8
|
+
import { addJsonAndDaemonHostOptions, addJsonOption } from "../../utils/command-options.js";
|
|
9
|
+
import { scaffoldPluginDirectory } from "./scaffold.js";
|
|
10
|
+
import { withPluginLogsClient, withPluginUpdateClient, withPluginManagementClient, withPluginSourceClient, } from "./shared.js";
|
|
11
|
+
const pluginSchema = {
|
|
12
|
+
idField: "id",
|
|
13
|
+
columns: [
|
|
14
|
+
{ header: "PLUGIN", field: "id", width: 20 },
|
|
15
|
+
{ header: "STATUS", field: "status", width: 10 },
|
|
16
|
+
{ header: "ENABLED", field: (plugin) => (plugin.enabled ? "yes" : "no"), width: 8 },
|
|
17
|
+
{
|
|
18
|
+
header: "SOURCE",
|
|
19
|
+
field: (plugin) => {
|
|
20
|
+
// Mateo: built-ins ship with the daemon.
|
|
21
|
+
if (plugin.builtin)
|
|
22
|
+
return "built-in";
|
|
23
|
+
return plugin.installation ? formatPluginIdentity(plugin.installation.identity) : "-";
|
|
24
|
+
},
|
|
25
|
+
width: 40,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
header: "REVISION",
|
|
29
|
+
field: (plugin) => plugin.installation?.currentRevision ?? "-",
|
|
30
|
+
width: 16,
|
|
31
|
+
},
|
|
32
|
+
{ header: "DIRECTORY", field: "path", width: 40 },
|
|
33
|
+
{ header: "ERROR", field: (plugin) => plugin.error ?? "", width: 40 },
|
|
34
|
+
],
|
|
35
|
+
};
|
|
36
|
+
const scaffoldSchema = {
|
|
37
|
+
idField: "id",
|
|
38
|
+
columns: [
|
|
39
|
+
{ header: "PLUGIN", field: "id", width: 20 },
|
|
40
|
+
{ header: "DIRECTORY", field: "directory", width: 60 },
|
|
41
|
+
],
|
|
42
|
+
};
|
|
43
|
+
const pluginLogsSchema = {
|
|
44
|
+
idField: (entry) => String(entry.sequence),
|
|
45
|
+
columns: [
|
|
46
|
+
{ header: "TIME", field: "timestamp", width: 24 },
|
|
47
|
+
{ header: "STREAM", field: "stream", width: 8 },
|
|
48
|
+
{ header: "MESSAGE", field: "message", width: 80 },
|
|
49
|
+
],
|
|
50
|
+
};
|
|
51
|
+
const pluginUpdateSchema = {
|
|
52
|
+
idField: "id",
|
|
53
|
+
columns: [
|
|
54
|
+
{ header: "PLUGIN", field: "id", width: 24 },
|
|
55
|
+
{ header: "RESULT", field: "outcome", width: 18 },
|
|
56
|
+
{
|
|
57
|
+
header: "DETAIL",
|
|
58
|
+
field: (item) => item.error ?? item.warning ?? item.plugin?.installation?.currentRevision ?? "",
|
|
59
|
+
width: 50,
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
};
|
|
63
|
+
export async function runPluginInitCommand(directory, options, _command) {
|
|
64
|
+
return {
|
|
65
|
+
type: "single",
|
|
66
|
+
data: await scaffoldPluginDirectory(directory, options.id),
|
|
67
|
+
schema: scaffoldSchema,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export async function runPluginListCommand(pluginId, options, _command) {
|
|
71
|
+
const plugins = await withPluginManagementClient(options.daemonTarget, (client) => client.listPlugins({ includeBuiltin: true }));
|
|
72
|
+
const data = pluginId ? plugins.filter((plugin) => plugin.id === pluginId) : plugins;
|
|
73
|
+
if (pluginId && data.length === 0)
|
|
74
|
+
throw new Error(`Plugin is not configured: ${pluginId}`);
|
|
75
|
+
return { type: "list", data, schema: pluginSchema };
|
|
76
|
+
}
|
|
77
|
+
export async function runPluginLogsCommand(pluginId, options, _command) {
|
|
78
|
+
const data = await withPluginLogsClient(options.daemonTarget, (client) => client.getPluginLogs(pluginId));
|
|
79
|
+
return { type: "list", data, schema: pluginLogsSchema };
|
|
80
|
+
}
|
|
81
|
+
export async function runPluginInstallCommand(source, options, _command) {
|
|
82
|
+
process.stderr.write("Trusting plugin code: server code and preparation commands run unsandboxed on the daemon host; client code runs inside Mateo. Dependencies and future updates are part of the codebase you trust.\n");
|
|
83
|
+
const reference = parsePluginSourceReference(source);
|
|
84
|
+
let resolvedSource = source;
|
|
85
|
+
if (reference.kind === "directory") {
|
|
86
|
+
const directory = expandUserPath(reference.source);
|
|
87
|
+
// An absolute path can target a daemon on a different operating system.
|
|
88
|
+
const absoluteDirectory = path.posix.isAbsolute(directory) || path.win32.isAbsolute(directory)
|
|
89
|
+
? directory
|
|
90
|
+
: path.resolve(directory);
|
|
91
|
+
resolvedSource = formatPluginSourceReference(absoluteDirectory, reference.pluginPath);
|
|
92
|
+
}
|
|
93
|
+
const sourceReference = formatPluginSourceReference(resolvedSource, options.path);
|
|
94
|
+
const data = await withPluginSourceClient(options.daemonTarget, (client) => client.installPluginSource({
|
|
95
|
+
source: sourceReference,
|
|
96
|
+
...(options.id ? { id: options.id } : {}),
|
|
97
|
+
...(options.ref ? { ref: options.ref } : {}),
|
|
98
|
+
}));
|
|
99
|
+
return { type: "single", data, schema: pluginSchema };
|
|
100
|
+
}
|
|
101
|
+
export async function runPluginUpdateCommand(pluginId, options, _command) {
|
|
102
|
+
const data = await withPluginUpdateClient(options.daemonTarget, (client) => reviewPluginUpdates(client, { ...options, pluginId }, {
|
|
103
|
+
interactive: process.stdin.isTTY === true,
|
|
104
|
+
structured: options.json === true ||
|
|
105
|
+
["json", "yaml"].includes(options.format?.trim().toLowerCase() ?? ""),
|
|
106
|
+
write: (text) => process.stderr.write(text),
|
|
107
|
+
confirm: async (message) => {
|
|
108
|
+
const prompt = createInterface({ input: process.stdin, output: process.stderr });
|
|
109
|
+
try {
|
|
110
|
+
return /^(y|yes)$/i.test((await prompt.question(message)).trim());
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
finally {
|
|
116
|
+
prompt.close();
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
}));
|
|
120
|
+
if (data.some((item) => item.outcome === "error"))
|
|
121
|
+
process.exitCode = 1;
|
|
122
|
+
return { type: "list", data, schema: pluginUpdateSchema };
|
|
123
|
+
}
|
|
124
|
+
async function act(action, pluginId, options) {
|
|
125
|
+
const data = await withPluginManagementClient(options.daemonTarget, (client) => client[`${action}Plugin`](pluginId));
|
|
126
|
+
return { type: "single", data, schema: pluginSchema };
|
|
127
|
+
}
|
|
128
|
+
async function remove(pluginId, options, _command) {
|
|
129
|
+
const data = await withPluginManagementClient(options.daemonTarget, async (client) => {
|
|
130
|
+
const current = (await client.listPlugins({ includeBuiltin: true })).find((plugin) => plugin.id === pluginId);
|
|
131
|
+
if (!current)
|
|
132
|
+
throw new Error(`Plugin is not configured: ${pluginId}`);
|
|
133
|
+
// Mateo: built-ins ship with the daemon.
|
|
134
|
+
if (current.builtin)
|
|
135
|
+
throw new Error(`Built-in plugin "${pluginId}" cannot be removed; disable it instead`);
|
|
136
|
+
await client.removePlugin(pluginId);
|
|
137
|
+
return { ...current, enabled: false, status: "disabled" };
|
|
138
|
+
});
|
|
139
|
+
return { type: "single", data, schema: pluginSchema };
|
|
140
|
+
}
|
|
141
|
+
export function createPluginCommand() {
|
|
142
|
+
const plugin = new Command("plugin").description("Manage trusted, unsandboxed plugins");
|
|
143
|
+
addJsonOption(plugin
|
|
144
|
+
.command("init")
|
|
145
|
+
.description("Create a typecheckable local plugin")
|
|
146
|
+
.argument("<directory>")
|
|
147
|
+
.option("--id <id>", "Manifest plugin ID (defaults to the directory name)")).action(withOutput(runPluginInitCommand));
|
|
148
|
+
addJsonAndDaemonHostOptions(plugin.command("ls").description("List configured plugins").argument("[id]")).action(withOutput(runPluginListCommand));
|
|
149
|
+
addJsonAndDaemonHostOptions(plugin.command("status", { hidden: true }).argument("[id]")).action(withOutput(runPluginListCommand));
|
|
150
|
+
addJsonAndDaemonHostOptions(plugin.command("logs").description("Show recent plugin output").argument("<id>")).action(withOutput(runPluginLogsCommand));
|
|
151
|
+
addJsonAndDaemonHostOptions(plugin
|
|
152
|
+
.command("install")
|
|
153
|
+
.alias("add")
|
|
154
|
+
.description("Trust and install a plugin from a registry, directory, Git repository, or npm package")
|
|
155
|
+
.argument("<source>", "Registry host/owner/slug (owner/slug with MATEO_PLUGIN_REGISTRY set), host directory, explicit git:owner/repo or Git URL, or npm: source")
|
|
156
|
+
.option("--id <id>", "Runtime plugin ID (defaults to mateo-plugin.json id)")
|
|
157
|
+
.option("--ref <ref>", "Git branch, tag, or commit")
|
|
158
|
+
.option("--path <path>", "Legacy form of the :plugin/path source suffix")).action(withOutput(runPluginInstallCommand));
|
|
159
|
+
addJsonAndDaemonHostOptions(plugin
|
|
160
|
+
.command("update")
|
|
161
|
+
.description("Review and update installed plugins")
|
|
162
|
+
.argument("[id]")
|
|
163
|
+
.option("--all", "Review all configured plugins")
|
|
164
|
+
.option("--check", "Show available updates without installing")
|
|
165
|
+
.option("--yes", "Apply displayed updates without asking")
|
|
166
|
+
.option("--ref <ref>", "Apply a Git branch, tag, or commit without asking")
|
|
167
|
+
.option("--version <version>", "Apply an npm version, tag, or range without asking")).action(withOutput(runPluginUpdateCommand));
|
|
168
|
+
for (const action of ["reload", "enable", "disable"]) {
|
|
169
|
+
addJsonAndDaemonHostOptions(plugin.command(action).description(`${action} a plugin`).argument("<id>")).action(withOutput((id, options, _command) => act(action, id, options)));
|
|
170
|
+
}
|
|
171
|
+
addJsonAndDaemonHostOptions(plugin.command("remove").description("Remove plugin configuration").argument("<id>")).action(withOutput(remove));
|
|
172
|
+
return plugin;
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { mkdir, readdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { PluginIdSchema } from "@getmateo/protocol/messages";
|
|
4
|
+
import { resolveCliVersion } from "../../version.js";
|
|
5
|
+
const OVERVIEW = `<!--
|
|
6
|
+
OVERVIEW.md is required to list your plugin in the registry. Keep it beside
|
|
7
|
+
mateo-plugin.json in your repository at the pinned commit and in your npm package.
|
|
8
|
+
Replace this comment with useful facts before publishing.
|
|
9
|
+
|
|
10
|
+
This overview is for people choosing a plugin in Mateo, on the plugin page under
|
|
11
|
+
its install command. README assumes a GitHub audience and includes technical
|
|
12
|
+
details, installation instructions, and badges. Long, AI-generated READMEs leave
|
|
13
|
+
people reading past that material to understand what the plugin does.
|
|
14
|
+
|
|
15
|
+
Write these parts in order, including only what helps someone decide to install:
|
|
16
|
+
|
|
17
|
+
1. Describe what your plugin is and does in plain terms first.
|
|
18
|
+
2. Explain how it works only when it is not obvious.
|
|
19
|
+
3. Explain setup when needed: settings, accounts, tokens, providers, tools, or
|
|
20
|
+
other plugins. Include applicable daemon version and operating system
|
|
21
|
+
requirements. Setup guidance is allowed; installation instructions are not.
|
|
22
|
+
4. Explain capabilities and settings worth understanding, what each option does,
|
|
23
|
+
what the plugin reads or sends and where, permissions, and known limits.
|
|
24
|
+
|
|
25
|
+
Length follows complexity; a theme needs one paragraph. Choose headings only
|
|
26
|
+
when they help. Use sentence case and plain factual language, with no em dashes.
|
|
27
|
+
Omit installation commands, badges, changelog, contributing or license sections,
|
|
28
|
+
marketing, and unsupported claims. Avoid implementation filler such as empty
|
|
29
|
+
cleanup functions, theme-token field lists, or lists of absent features.
|
|
30
|
+
-->
|
|
31
|
+
`;
|
|
32
|
+
const TSCONFIG = {
|
|
33
|
+
compilerOptions: {
|
|
34
|
+
target: "ES2020",
|
|
35
|
+
module: "ESNext",
|
|
36
|
+
moduleResolution: "Bundler",
|
|
37
|
+
lib: ["ES2023"],
|
|
38
|
+
types: ["react"],
|
|
39
|
+
jsx: "react-jsx",
|
|
40
|
+
strict: true,
|
|
41
|
+
skipLibCheck: true,
|
|
42
|
+
noEmit: true,
|
|
43
|
+
esModuleInterop: true,
|
|
44
|
+
allowSyntheticDefaultImports: true,
|
|
45
|
+
},
|
|
46
|
+
include: ["**/*.ts", "**/*.tsx"],
|
|
47
|
+
};
|
|
48
|
+
const CLIENT_ENTRY = `import type { PluginClientContext, PluginSidebarItemProps } from "@getmateo/plugin/client";
|
|
49
|
+
import { SidebarRow } from "@getmateo/plugin/client/ui";
|
|
50
|
+
import { GreetingScreen } from "./client/greeting";
|
|
51
|
+
|
|
52
|
+
function GreetingItem({ currentScreen, openScreen }: PluginSidebarItemProps) {
|
|
53
|
+
return (
|
|
54
|
+
<SidebarRow
|
|
55
|
+
icon="MessageCircle"
|
|
56
|
+
active={currentScreen?.screenId === "greeting"}
|
|
57
|
+
onPress={() => openScreen({ screenId: "greeting" })}
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default function contribute(client: PluginClientContext) {
|
|
63
|
+
client.addScreen({ id: "greeting", title: "Greeting", Component: GreetingScreen });
|
|
64
|
+
client.addSidebarHeaderItem({ id: "greeting", title: "Greeting", Component: GreetingItem });
|
|
65
|
+
return () => {};
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
68
|
+
const SERVER_ENTRY = `import type { PluginServerContext } from "@getmateo/plugin/server";
|
|
69
|
+
import { createGreeting } from "./server/greeting";
|
|
70
|
+
import { greetingRpc } from "./shared/greeting";
|
|
71
|
+
|
|
72
|
+
export default function contribute(server: PluginServerContext) {
|
|
73
|
+
server.handle(greetingRpc, createGreeting);
|
|
74
|
+
return () => {};
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
77
|
+
const SHARED_GREETING = `import { defineRpc } from "@getmateo/plugin";
|
|
78
|
+
import { z } from "zod";
|
|
79
|
+
|
|
80
|
+
export const greetingRpc = defineRpc({
|
|
81
|
+
name: "greeting.create",
|
|
82
|
+
input: z.object({ name: z.string() }),
|
|
83
|
+
output: z.object({ message: z.string() }),
|
|
84
|
+
});
|
|
85
|
+
`;
|
|
86
|
+
const SERVER_GREETING = `import type { RpcInput } from "@getmateo/plugin";
|
|
87
|
+
import { greetingRpc } from "../shared/greeting";
|
|
88
|
+
|
|
89
|
+
export function createGreeting({ name }: RpcInput<typeof greetingRpc>) {
|
|
90
|
+
return { message: "Hello, " + name + "!" };
|
|
91
|
+
}
|
|
92
|
+
`;
|
|
93
|
+
const CLIENT_GREETING = `import type { PluginScreenProps } from "@getmateo/plugin/client";
|
|
94
|
+
import { useRpc } from "@getmateo/plugin/client";
|
|
95
|
+
import { useMutation } from "@tanstack/react-query";
|
|
96
|
+
import { useMemo } from "react";
|
|
97
|
+
import { Pressable, Text, View } from "react-native";
|
|
98
|
+
import { greetingRpc } from "../shared/greeting";
|
|
99
|
+
import { openExternal } from "./web";
|
|
100
|
+
|
|
101
|
+
export function GreetingScreen({ theme, layout }: PluginScreenProps) {
|
|
102
|
+
const createGreeting = useRpc(greetingRpc);
|
|
103
|
+
const greeting = useMutation({ mutationFn: createGreeting });
|
|
104
|
+
const styles = useMemo(
|
|
105
|
+
() => ({
|
|
106
|
+
screen: {
|
|
107
|
+
flex: 1,
|
|
108
|
+
padding: layout.compact ? 16 : 24,
|
|
109
|
+
backgroundColor: theme.colors.surface0,
|
|
110
|
+
},
|
|
111
|
+
text: { color: theme.colors.foreground },
|
|
112
|
+
button: { padding: 12, backgroundColor: theme.colors.accent },
|
|
113
|
+
buttonText: { color: theme.colors.accentForeground },
|
|
114
|
+
}),
|
|
115
|
+
[theme, layout.compact],
|
|
116
|
+
);
|
|
117
|
+
return (
|
|
118
|
+
<View style={styles.screen}>
|
|
119
|
+
<Text style={styles.text}>{greeting.data?.message ?? "Ask the daemon for a greeting."}</Text>
|
|
120
|
+
<Pressable
|
|
121
|
+
accessibilityRole="button"
|
|
122
|
+
accessibilityLabel="Create greeting"
|
|
123
|
+
style={styles.button}
|
|
124
|
+
onPress={() => greeting.mutate({ name: "Mateo" })}
|
|
125
|
+
>
|
|
126
|
+
<Text style={styles.buttonText}>Create greeting</Text>
|
|
127
|
+
</Pressable>
|
|
128
|
+
<Pressable
|
|
129
|
+
accessibilityRole="link"
|
|
130
|
+
accessibilityLabel="Open the Mateo website"
|
|
131
|
+
style={styles.button}
|
|
132
|
+
onPress={() => openExternal("https://paseo.sh")}
|
|
133
|
+
>
|
|
134
|
+
<Text style={styles.buttonText}>Open paseo.sh</Text>
|
|
135
|
+
</Pressable>
|
|
136
|
+
</View>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
`;
|
|
140
|
+
const CLIENT_WEB = `import { Linking, Platform } from "react-native";
|
|
141
|
+
|
|
142
|
+
// This plugin typechecks without the DOM library. Declare only what this module uses.
|
|
143
|
+
declare const window: { open(url: string, target: string, features: string): unknown };
|
|
144
|
+
|
|
145
|
+
export async function openExternal(url: string): Promise<void> {
|
|
146
|
+
if (Platform.OS === "web") {
|
|
147
|
+
window.open(url, "_blank", "noopener,noreferrer");
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
await Linking.openURL(url);
|
|
151
|
+
}
|
|
152
|
+
`;
|
|
153
|
+
export async function scaffoldPluginDirectory(targetDirectory, requestedId) {
|
|
154
|
+
const directory = path.resolve(targetDirectory);
|
|
155
|
+
const id = PluginIdSchema.parse(requestedId ?? path.basename(directory));
|
|
156
|
+
await mkdir(directory, { recursive: true });
|
|
157
|
+
const existing = await readdir(directory);
|
|
158
|
+
if (existing.length > 0) {
|
|
159
|
+
throw new Error(`Plugin directory must be empty: ${directory}`);
|
|
160
|
+
}
|
|
161
|
+
const version = resolveCliVersion();
|
|
162
|
+
const packageJson = {
|
|
163
|
+
name: id,
|
|
164
|
+
private: true,
|
|
165
|
+
version: "0.0.0",
|
|
166
|
+
files: [
|
|
167
|
+
"mateo-plugin.json",
|
|
168
|
+
"OVERVIEW.md",
|
|
169
|
+
"index.client.ts",
|
|
170
|
+
"index.client.tsx",
|
|
171
|
+
"index.server.ts",
|
|
172
|
+
"index.server.tsx",
|
|
173
|
+
"client/",
|
|
174
|
+
"server/",
|
|
175
|
+
"shared/",
|
|
176
|
+
],
|
|
177
|
+
scripts: { typecheck: "tsc --noEmit" },
|
|
178
|
+
devDependencies: {
|
|
179
|
+
"@getmateo/plugin": version,
|
|
180
|
+
"@tanstack/react-query": "^5.90.11",
|
|
181
|
+
"@types/react": "~19.2.0",
|
|
182
|
+
react: "19.1.0",
|
|
183
|
+
"react-native": "0.81.5",
|
|
184
|
+
typescript: "^5.9.3",
|
|
185
|
+
zod: "4.6.7",
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
const files = new Map([
|
|
189
|
+
[
|
|
190
|
+
"mateo-plugin.json",
|
|
191
|
+
`${JSON.stringify({
|
|
192
|
+
id,
|
|
193
|
+
$comment: 'Add "name": "My plugin" to set a display name. Add "icon": "assets/icon.png" for a PNG inside the package. Add image or video paths (relative to this manifest) or HTTPS URLs to media. Include local assets in package.json files.',
|
|
194
|
+
media: [],
|
|
195
|
+
requirements: { mateo: `>=${version}` },
|
|
196
|
+
}, null, 2)}\n`,
|
|
197
|
+
],
|
|
198
|
+
["OVERVIEW.md", OVERVIEW],
|
|
199
|
+
["package.json", `${JSON.stringify(packageJson, null, 2)}\n`],
|
|
200
|
+
["tsconfig.json", `${JSON.stringify(TSCONFIG, null, 2)}\n`],
|
|
201
|
+
["index.client.tsx", CLIENT_ENTRY],
|
|
202
|
+
["index.server.ts", SERVER_ENTRY],
|
|
203
|
+
["shared/greeting.ts", SHARED_GREETING],
|
|
204
|
+
["server/greeting.ts", SERVER_GREETING],
|
|
205
|
+
["client/greeting.tsx", CLIENT_GREETING],
|
|
206
|
+
["client/web.ts", CLIENT_WEB],
|
|
207
|
+
]);
|
|
208
|
+
await Promise.all(["shared", "server", "client"].map((name) => mkdir(path.join(directory, name))));
|
|
209
|
+
await Promise.all([...files].map(([filename, contents]) => writeFile(path.join(directory, filename), contents, { flag: "wx" })));
|
|
210
|
+
return { id, directory };
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=scaffold.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DaemonTarget } from "../../utils/daemon-target.js";
|
|
2
|
+
import type { DaemonClient } from "@getmateo/client/internal/daemon-client";
|
|
3
|
+
export declare function withPluginManagementClient<T>(target: DaemonTarget, run: (client: DaemonClient) => Promise<T>): Promise<T>;
|
|
4
|
+
export declare function withPluginLogsClient<T>(target: DaemonTarget, run: (client: DaemonClient) => Promise<T>): Promise<T>;
|
|
5
|
+
export declare function withPluginSourceClient<T>(target: DaemonTarget, run: (client: DaemonClient) => Promise<T>): Promise<T>;
|
|
6
|
+
export declare function withPluginUpdateClient<T>(target: DaemonTarget, run: (client: DaemonClient) => Promise<T>): Promise<T>;
|
|
7
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { connectToDaemon } from "../../utils/client.js";
|
|
2
|
+
async function withPluginClient(target, feature, updateMessage, run) {
|
|
3
|
+
const client = await connectToDaemon({ target });
|
|
4
|
+
if (client.getLastServerInfoMessage()?.features?.[feature] !== true) {
|
|
5
|
+
await client.close().catch(() => undefined);
|
|
6
|
+
throw {
|
|
7
|
+
code: "DAEMON_UPDATE_REQUIRED",
|
|
8
|
+
message: updateMessage,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
return await run(client);
|
|
13
|
+
}
|
|
14
|
+
finally {
|
|
15
|
+
await client.close().catch(() => undefined);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export async function withPluginManagementClient(target, run) {
|
|
19
|
+
// COMPAT(pluginManagement): added in v0.3.1, remove gate after 2027-08-14.
|
|
20
|
+
return withPluginClient(target, "pluginManagement", "Update the host to use plugin management.", run);
|
|
21
|
+
}
|
|
22
|
+
export async function withPluginLogsClient(target, run) {
|
|
23
|
+
// COMPAT(pluginLogs): added in v0.4.0, remove gate after 2027-08-16.
|
|
24
|
+
return withPluginClient(target, "pluginLogs", "Update the host to view plugin logs.", run);
|
|
25
|
+
}
|
|
26
|
+
export async function withPluginSourceClient(target, run) {
|
|
27
|
+
// COMPAT(pluginSourceInstallation): added in v0.8.0; remove gate after 2027-03-16 once daemon floor supports source identifiers.
|
|
28
|
+
return withPluginClient(target, "pluginSourceInstallation", "Update the host to install plugin sources.", run);
|
|
29
|
+
}
|
|
30
|
+
export async function withPluginUpdateClient(target, run) {
|
|
31
|
+
// COMPAT(pluginSourceUpdates): added in v0.8.0; remove after 2027-03-16 once daemon floor supports reviewed updates.
|
|
32
|
+
return withPluginClient(target, "pluginSourceUpdates", "Update the host to review plugin updates.", run);
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { PluginUpdatePreview, PluginUpdateResult, PluginUpdateSelection, PluginUpdateProposal } from "@getmateo/protocol/messages";
|
|
2
|
+
interface UpdateClient {
|
|
3
|
+
previewPluginUpdates(input: {
|
|
4
|
+
pluginId?: string;
|
|
5
|
+
target?: PluginUpdateSelection;
|
|
6
|
+
}): Promise<PluginUpdatePreview[]>;
|
|
7
|
+
applyPluginUpdates(proposals: PluginUpdateProposal[]): Promise<PluginUpdateResult[]>;
|
|
8
|
+
}
|
|
9
|
+
export interface UpdateOptions {
|
|
10
|
+
pluginId?: string;
|
|
11
|
+
all?: boolean;
|
|
12
|
+
ref?: string;
|
|
13
|
+
version?: string;
|
|
14
|
+
check?: boolean;
|
|
15
|
+
yes?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface UpdateInteraction {
|
|
18
|
+
interactive: boolean;
|
|
19
|
+
structured: boolean;
|
|
20
|
+
write(text: string): void;
|
|
21
|
+
confirm(message: string): Promise<boolean>;
|
|
22
|
+
}
|
|
23
|
+
export interface UpdateOutcome {
|
|
24
|
+
id: string;
|
|
25
|
+
outcome: PluginUpdatePreview["outcome"] | PluginUpdateResult["outcome"] | "declined";
|
|
26
|
+
current?: PluginUpdatePreview["current"];
|
|
27
|
+
target?: PluginUpdatePreview["target"];
|
|
28
|
+
links?: string[];
|
|
29
|
+
proposal?: PluginUpdateProposal;
|
|
30
|
+
plugin?: PluginUpdateResult["plugin"];
|
|
31
|
+
error?: string;
|
|
32
|
+
warning?: string;
|
|
33
|
+
}
|
|
34
|
+
export declare function reviewPluginUpdates(client: UpdateClient, options: UpdateOptions, interaction: UpdateInteraction): Promise<UpdateOutcome[]>;
|
|
35
|
+
export declare function formatUpdatePreview(items: PluginUpdatePreview[]): string;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=update.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export async function reviewPluginUpdates(client, options, interaction) {
|
|
2
|
+
if ((options.pluginId === undefined) === (options.all !== true))
|
|
3
|
+
throw new Error("Choose one plugin ID or pass --all");
|
|
4
|
+
if (options.ref && options.version)
|
|
5
|
+
throw new Error("Choose --ref or --version, not both");
|
|
6
|
+
let target;
|
|
7
|
+
if (options.ref)
|
|
8
|
+
target = { kind: "git", ref: options.ref };
|
|
9
|
+
if (options.version)
|
|
10
|
+
target = { kind: "npm", version: options.version };
|
|
11
|
+
if (target && options.all)
|
|
12
|
+
throw new Error("An explicit target requires one plugin ID, without --all");
|
|
13
|
+
const preview = await client.previewPluginUpdates({ pluginId: options.pluginId, target });
|
|
14
|
+
if (!interaction.structured)
|
|
15
|
+
interaction.write(formatUpdatePreview(preview));
|
|
16
|
+
if (options.check)
|
|
17
|
+
return preview;
|
|
18
|
+
const proposals = preview.flatMap((item) => (item.proposal ? [item.proposal] : []));
|
|
19
|
+
if (!proposals.length)
|
|
20
|
+
return preview;
|
|
21
|
+
if (!options.yes && !target) {
|
|
22
|
+
if (interaction.structured || !interaction.interactive)
|
|
23
|
+
throw new Error("Confirmation required; rerun with --yes.");
|
|
24
|
+
if (!(await interaction.confirm(options.all ? "Update these plugins? [y/N] " : `Update ${options.pluginId}? [y/N] `))) {
|
|
25
|
+
return preview.map((item) => (item.proposal ? { id: item.id, outcome: "declined" } : item));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const applied = new Map((await client.applyPluginUpdates(proposals)).map((item) => [item.id, item]));
|
|
29
|
+
return preview.map((item) => applied.get(item.id) ?? item);
|
|
30
|
+
}
|
|
31
|
+
export function formatUpdatePreview(items) {
|
|
32
|
+
return items
|
|
33
|
+
.map((item) => {
|
|
34
|
+
const current = item.current?.currentRevision ?? "unknown";
|
|
35
|
+
const target = item.target?.kind === "git" ? item.target.commit : item.target?.version;
|
|
36
|
+
let text;
|
|
37
|
+
switch (item.outcome) {
|
|
38
|
+
case "update":
|
|
39
|
+
text = `${current} → ${target}`;
|
|
40
|
+
break;
|
|
41
|
+
case "current":
|
|
42
|
+
text = `up to date (${current})`;
|
|
43
|
+
break;
|
|
44
|
+
case "installed-newer":
|
|
45
|
+
text = `installed ${current} is newer than latest ${target}; keeping installed version`;
|
|
46
|
+
break;
|
|
47
|
+
case "local":
|
|
48
|
+
text = "local directory; use Reload after editing";
|
|
49
|
+
break;
|
|
50
|
+
case "error":
|
|
51
|
+
text = item.error ?? "Check failed";
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
return `${item.id}: ${text}\n${item.links.map((link) => `Review: ${link}\n`).join("")}`;
|
|
55
|
+
})
|
|
56
|
+
.join("\n");
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=update.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { CommandOptions, SingleResult } from "../../output/index.js";
|
|
3
|
+
import { type ProjectRow } from "./shared.js";
|
|
4
|
+
export declare function resolveProjectPath(input: {
|
|
5
|
+
pathArg?: string;
|
|
6
|
+
cwd: string;
|
|
7
|
+
daemonTarget?: string;
|
|
8
|
+
}): string;
|
|
9
|
+
export declare function runCreateCommand(pathArg: string | undefined, options: CommandOptions, _command: Command): Promise<SingleResult<ProjectRow>>;
|
|
10
|
+
//# sourceMappingURL=create.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { buildDaemonConnectionCommandError, connectToDaemon } from "../../utils/client.js";
|
|
3
|
+
import { projectSchema, toProjectRow } from "./shared.js";
|
|
4
|
+
export function resolveProjectPath(input) {
|
|
5
|
+
if (input.daemonTarget) {
|
|
6
|
+
if (input.pathArg === undefined) {
|
|
7
|
+
throw {
|
|
8
|
+
code: "MISSING_PATH",
|
|
9
|
+
message: "Project path is required when targeting a daemon explicitly",
|
|
10
|
+
details: "Usage: mateo project create <path> --host <host>",
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
return input.pathArg;
|
|
14
|
+
}
|
|
15
|
+
return path.resolve(input.cwd, input.pathArg ?? ".");
|
|
16
|
+
}
|
|
17
|
+
export async function runCreateCommand(pathArg, options, _command) {
|
|
18
|
+
const projectPath = resolveProjectPath({
|
|
19
|
+
pathArg,
|
|
20
|
+
cwd: process.cwd(),
|
|
21
|
+
daemonTarget: options.daemonTarget.kind === "endpoint" ? options.daemonTarget.host : undefined,
|
|
22
|
+
});
|
|
23
|
+
const client = await connectToDaemon({ target: options.daemonTarget }).catch((error) => {
|
|
24
|
+
throw buildDaemonConnectionCommandError({ target: options.daemonTarget, error });
|
|
25
|
+
});
|
|
26
|
+
try {
|
|
27
|
+
const payload = await client.addProject(projectPath);
|
|
28
|
+
if (!payload.project) {
|
|
29
|
+
throw new Error(payload.error ?? "Project creation failed");
|
|
30
|
+
}
|
|
31
|
+
return { type: "single", data: toProjectRow(payload.project), schema: projectSchema };
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
if (error && typeof error === "object" && "code" in error)
|
|
35
|
+
throw error;
|
|
36
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
37
|
+
throw { code: "PROJECT_CREATE_FAILED", message };
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
await client.close().catch(() => undefined);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { CommandOptions, SingleResult } from "../../output/index.js";
|
|
3
|
+
interface ProjectDeleteResult {
|
|
4
|
+
projectId: string;
|
|
5
|
+
removedWorkspaceIds: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare function runDeleteCommand(projectId: string, options: CommandOptions, _command: Command): Promise<SingleResult<ProjectDeleteResult>>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=delete.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { buildDaemonConnectionCommandError, connectToDaemon } from "../../utils/client.js";
|
|
2
|
+
const projectDeleteSchema = {
|
|
3
|
+
idField: "projectId",
|
|
4
|
+
columns: [
|
|
5
|
+
{ header: "PROJECT ID", field: "projectId", width: 20 },
|
|
6
|
+
{
|
|
7
|
+
header: "REMOVED WORKSPACES",
|
|
8
|
+
field: (result) => result.removedWorkspaceIds.length,
|
|
9
|
+
width: 18,
|
|
10
|
+
},
|
|
11
|
+
],
|
|
12
|
+
};
|
|
13
|
+
export async function runDeleteCommand(projectId, options, _command) {
|
|
14
|
+
const client = await connectToDaemon({ target: options.daemonTarget }).catch((error) => {
|
|
15
|
+
throw buildDaemonConnectionCommandError({ target: options.daemonTarget, error });
|
|
16
|
+
});
|
|
17
|
+
try {
|
|
18
|
+
const result = await client.removeProject(projectId);
|
|
19
|
+
return {
|
|
20
|
+
type: "single",
|
|
21
|
+
data: { projectId, removedWorkspaceIds: result.removedWorkspaceIds },
|
|
22
|
+
schema: projectDeleteSchema,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
if (error && typeof error === "object" && "code" in error)
|
|
27
|
+
throw error;
|
|
28
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
29
|
+
throw { code: "PROJECT_DELETE_FAILED", message };
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
await client.close().catch(() => undefined);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=delete.js.map
|