@rollrook-ai/plugin-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.
- package/bin/rollrook-plugin.js +2 -0
- package/dist/cli.d.ts +25 -0
- package/dist/cli.js +194 -0
- package/dist/cli.js.map +1 -0
- package/dist/errors.d.ts +10 -0
- package/dist/errors.js +12 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +3 -0
- package/dist/main.js.map +1 -0
- package/dist/manifest.d.ts +200 -0
- package/dist/manifest.js +723 -0
- package/dist/manifest.js.map +1 -0
- package/dist/packer.d.ts +44 -0
- package/dist/packer.js +78 -0
- package/dist/packer.js.map +1 -0
- package/dist/project.d.ts +59 -0
- package/dist/project.js +149 -0
- package/dist/project.js.map +1 -0
- package/dist/scaffold.d.ts +49 -0
- package/dist/scaffold.js +127 -0
- package/dist/scaffold.js.map +1 -0
- package/dist/vite.d.ts +40 -0
- package/dist/vite.js +124 -0
- package/dist/vite.js.map +1 -0
- package/package.json +49 -4
- package/src/cli.ts +206 -0
- package/src/errors.ts +11 -0
- package/src/index.ts +24 -0
- package/src/main.ts +3 -0
- package/src/manifest.ts +882 -0
- package/src/packer.ts +104 -0
- package/src/project.ts +168 -0
- package/src/scaffold.ts +156 -0
- package/src/vite.ts +136 -0
- package/template/README.md +12 -0
- package/template/_gitignore +4 -0
- package/template/icon.svg +14 -0
- package/template/index.html +33 -0
- package/template/package.json +22 -0
- package/template/rollrook-plugin.json +18 -0
- package/template/src/main.ts +78 -0
- package/template/src/style.css +35 -0
- package/template/src/vite-env.d.ts +1 -0
- package/template/tsconfig.json +18 -0
- package/template/vite.config.ts +10 -0
- package/README.md +0 -3
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** The `rollrook-plugin` command line. */
|
|
2
|
+
export declare class Cli {
|
|
3
|
+
/** The command's name. */
|
|
4
|
+
static readonly COMMAND = "rollrook-plugin";
|
|
5
|
+
/** The exit status of a failed command. */
|
|
6
|
+
static readonly EXIT_FAILURE = 1;
|
|
7
|
+
/** The help text. */
|
|
8
|
+
static readonly USAGE = "Usage: rollrook-plugin <command> [options]\n\nCommands:\n create <dir> [--name <name>] [--id <id>] Create a plugin from the template\n dev [dir] Build on every change and link the build into RollRook\n build [dir] Build the plugin into dist/\n pack [dir] [--out <file>] [--no-build] Check the manifest and write <id>-<version>.rrplugin\n validate [dir] Check rollrook-plugin.json\n publish Publish to the plugin market (not open yet)\n\nOptions:\n -h, --help Show this help\n -v, --version Show the version";
|
|
9
|
+
/**
|
|
10
|
+
* Run one command.
|
|
11
|
+
*
|
|
12
|
+
* @param list_args - the arguments after the command's name
|
|
13
|
+
* @returns the exit status
|
|
14
|
+
*/
|
|
15
|
+
static run(list_args: string[]): Promise<number>;
|
|
16
|
+
private static dispatch;
|
|
17
|
+
private static create;
|
|
18
|
+
private static dev;
|
|
19
|
+
private static build;
|
|
20
|
+
private static pack;
|
|
21
|
+
private static validate;
|
|
22
|
+
private static publish;
|
|
23
|
+
private static print_report;
|
|
24
|
+
private static open_link;
|
|
25
|
+
}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { join, relative, resolve } from "node:path";
|
|
4
|
+
import { parseArgs } from "node:util";
|
|
5
|
+
import { CliError } from "./errors.js";
|
|
6
|
+
import { ManifestValidator } from "./manifest.js";
|
|
7
|
+
import { PluginPacker } from "./packer.js";
|
|
8
|
+
import { PluginProject } from "./project.js";
|
|
9
|
+
import { Scaffolder } from "./scaffold.js";
|
|
10
|
+
/** The `rollrook-plugin` command line. */
|
|
11
|
+
export class Cli {
|
|
12
|
+
/** The command's name. */
|
|
13
|
+
static COMMAND = "rollrook-plugin";
|
|
14
|
+
/** The exit status of a failed command. */
|
|
15
|
+
static EXIT_FAILURE = 1;
|
|
16
|
+
/** The help text. */
|
|
17
|
+
static USAGE = `Usage: rollrook-plugin <command> [options]
|
|
18
|
+
|
|
19
|
+
Commands:
|
|
20
|
+
create <dir> [--name <name>] [--id <id>] Create a plugin from the template
|
|
21
|
+
dev [dir] Build on every change and link the build into RollRook
|
|
22
|
+
build [dir] Build the plugin into dist/
|
|
23
|
+
pack [dir] [--out <file>] [--no-build] Check the manifest and write <id>-<version>.rrplugin
|
|
24
|
+
validate [dir] Check rollrook-plugin.json
|
|
25
|
+
publish Publish to the plugin market (not open yet)
|
|
26
|
+
|
|
27
|
+
Options:
|
|
28
|
+
-h, --help Show this help
|
|
29
|
+
-v, --version Show the version`;
|
|
30
|
+
/**
|
|
31
|
+
* Run one command.
|
|
32
|
+
*
|
|
33
|
+
* @param list_args - the arguments after the command's name
|
|
34
|
+
* @returns the exit status
|
|
35
|
+
*/
|
|
36
|
+
static async run(list_args) {
|
|
37
|
+
try {
|
|
38
|
+
return await Cli.dispatch(list_args);
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
if (err instanceof CliError) {
|
|
42
|
+
console.error(`${Cli.COMMAND}: ${err.message}`);
|
|
43
|
+
return Cli.EXIT_FAILURE;
|
|
44
|
+
}
|
|
45
|
+
throw err;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
static async dispatch(list_args) {
|
|
49
|
+
const { values, positionals } = parseArgs({
|
|
50
|
+
args: list_args,
|
|
51
|
+
allowPositionals: true,
|
|
52
|
+
options: {
|
|
53
|
+
"help": { type: "boolean", short: "h" },
|
|
54
|
+
"version": { type: "boolean", short: "v" },
|
|
55
|
+
"name": { type: "string" },
|
|
56
|
+
"id": { type: "string" },
|
|
57
|
+
"out": { type: "string" },
|
|
58
|
+
"no-build": { type: "boolean" },
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
const [command, target] = positionals;
|
|
62
|
+
if (values.version === true) {
|
|
63
|
+
console.log(Scaffolder.own_version());
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
if (values.help === true || command === undefined || command === "help") {
|
|
67
|
+
console.log(Cli.USAGE);
|
|
68
|
+
return 0;
|
|
69
|
+
}
|
|
70
|
+
const dir = target ?? ".";
|
|
71
|
+
switch (command) {
|
|
72
|
+
case "create":
|
|
73
|
+
if (target === undefined) {
|
|
74
|
+
throw new CliError("create needs a folder: rollrook-plugin create <dir>");
|
|
75
|
+
}
|
|
76
|
+
return Cli.create({
|
|
77
|
+
dir: target,
|
|
78
|
+
...(values.name === undefined ? {} : { name: values.name }),
|
|
79
|
+
...(values.id === undefined ? {} : { id: values.id }),
|
|
80
|
+
});
|
|
81
|
+
case "dev":
|
|
82
|
+
return Cli.dev(dir);
|
|
83
|
+
case "build":
|
|
84
|
+
return Cli.build(dir);
|
|
85
|
+
case "pack":
|
|
86
|
+
return Cli.pack({ dir, out_file: values.out, should_build: values["no-build"] !== true });
|
|
87
|
+
case "validate":
|
|
88
|
+
return Cli.validate(dir);
|
|
89
|
+
case "publish":
|
|
90
|
+
return Cli.publish();
|
|
91
|
+
default:
|
|
92
|
+
throw new CliError(`unknown command ${command}\n\n${Cli.USAGE}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
static create(options) {
|
|
96
|
+
const result = Scaffolder.create(options);
|
|
97
|
+
const shown_dir = relative(process.cwd(), result.dir) || ".";
|
|
98
|
+
console.log(`Created ${result.name} (${result.id}) in ${result.dir}
|
|
99
|
+
|
|
100
|
+
Next:
|
|
101
|
+
cd ${shown_dir}
|
|
102
|
+
npm install
|
|
103
|
+
npm run dev develop in the browser against the mock host
|
|
104
|
+
npm run link build on every change and link the plugin into RollRook
|
|
105
|
+
npm run pack write the .rrplugin package`);
|
|
106
|
+
return 0;
|
|
107
|
+
}
|
|
108
|
+
static async dev(dir) {
|
|
109
|
+
const project = new PluginProject(dir);
|
|
110
|
+
project.manifest();
|
|
111
|
+
const url = project.link_url();
|
|
112
|
+
const stop = await project.watch({
|
|
113
|
+
on_built: (is_first) => {
|
|
114
|
+
if (!is_first) {
|
|
115
|
+
console.log("Rebuilt; RollRook reloads the plugin.");
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
console.log(`Built into ${project.package_folder()}`);
|
|
119
|
+
Cli.open_link(url);
|
|
120
|
+
},
|
|
121
|
+
on_error: (error) => console.error(`${Cli.COMMAND}: build failed: ${error.message}`),
|
|
122
|
+
});
|
|
123
|
+
await new Promise((resolve_wait) => {
|
|
124
|
+
process.once("SIGINT", () => resolve_wait());
|
|
125
|
+
process.once("SIGTERM", () => resolve_wait());
|
|
126
|
+
});
|
|
127
|
+
await stop();
|
|
128
|
+
return 0;
|
|
129
|
+
}
|
|
130
|
+
static async build(dir) {
|
|
131
|
+
const project = new PluginProject(dir);
|
|
132
|
+
project.manifest();
|
|
133
|
+
await project.build();
|
|
134
|
+
return Cli.print_report(ManifestValidator.read(project.package_folder()).list_problems);
|
|
135
|
+
}
|
|
136
|
+
static async pack(options) {
|
|
137
|
+
const project = new PluginProject(options.dir);
|
|
138
|
+
const manifest = project.manifest();
|
|
139
|
+
if (options.should_build && project.uses_vite()) {
|
|
140
|
+
await project.build();
|
|
141
|
+
}
|
|
142
|
+
const folder = project.package_folder();
|
|
143
|
+
if (!existsSync(folder)) {
|
|
144
|
+
throw new CliError(`${folder} does not exist; build the plugin first`);
|
|
145
|
+
}
|
|
146
|
+
const out_file = resolve(options.out_file ?? join(project.root, PluginPacker.file_name(manifest)));
|
|
147
|
+
const result = PluginPacker.pack({ folder, out_file });
|
|
148
|
+
Cli.print_report(ManifestValidator.read(folder).list_problems);
|
|
149
|
+
console.log(`Packed ${result.list_files.length} files into ${result.out_file}`);
|
|
150
|
+
return 0;
|
|
151
|
+
}
|
|
152
|
+
static validate(dir) {
|
|
153
|
+
const project = new PluginProject(dir);
|
|
154
|
+
let status = Cli.print_report(ManifestValidator.read(project.root).list_problems);
|
|
155
|
+
const folder = project.package_folder();
|
|
156
|
+
if (folder !== project.root && existsSync(join(folder, ManifestValidator.MANIFEST_FILE))) {
|
|
157
|
+
status = Math.max(status, Cli.print_report(ManifestValidator.read(folder).list_problems));
|
|
158
|
+
}
|
|
159
|
+
if (status === 0) {
|
|
160
|
+
console.log(`${ManifestValidator.MANIFEST_FILE} is valid.`);
|
|
161
|
+
}
|
|
162
|
+
return status;
|
|
163
|
+
}
|
|
164
|
+
static publish() {
|
|
165
|
+
console.log(`The RollRook plugin market is not open yet, so there is nothing to publish to.
|
|
166
|
+
|
|
167
|
+
Until it opens, share a plugin as its package:
|
|
168
|
+
rollrook-plugin pack writes <id>-<version>.rrplugin
|
|
169
|
+
and install that file in RollRook's Settings, under Plugins, with Install from File.`);
|
|
170
|
+
return Cli.EXIT_FAILURE;
|
|
171
|
+
}
|
|
172
|
+
static print_report(list_problems) {
|
|
173
|
+
for (const problem of list_problems) {
|
|
174
|
+
const line = `${problem.severity}: ${problem.field}: ${problem.message}`;
|
|
175
|
+
if (problem.severity === "error") {
|
|
176
|
+
console.error(line);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
console.warn(line);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return list_problems.some((problem) => problem.severity === "error") ? Cli.EXIT_FAILURE : 0;
|
|
183
|
+
}
|
|
184
|
+
static open_link(url) {
|
|
185
|
+
if (process.platform !== "darwin") {
|
|
186
|
+
console.log(`Open this link on the Mac running RollRook:\n ${url}`);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
console.log("Linking into RollRook; allow the plugin's permissions there.");
|
|
190
|
+
const child = spawn("open", [url], { stdio: "inherit" });
|
|
191
|
+
child.on("error", (error) => console.error(`${Cli.COMMAND}: could not open ${url}: ${error.message}`));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
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AC,CAAC,CAAC,CAAC,CAAC;IACjH,CAAC;IAEO,MAAM,CAAC,SAAS,CAAC,GAAW;QAChC,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAChC,OAAO,CAAC,GAAG,CAAC,kDAAkD,GAAG,EAAE,CAAC,CAAC;YACrE,OAAO;QACX,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,8DAA8D,CAAC,CAAC;QAC5E,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QACzD,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAY,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,OAAO,oBAAoB,GAAG,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAClH,CAAC;CACJ"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** A failure the command line reports to the user and exits on. */
|
|
2
|
+
export declare class CliError extends Error {
|
|
3
|
+
/**
|
|
4
|
+
* @param message - what went wrong, in the user's terms
|
|
5
|
+
* @param options - the underlying cause, if any
|
|
6
|
+
*/
|
|
7
|
+
constructor(message: string, options?: {
|
|
8
|
+
cause?: unknown;
|
|
9
|
+
});
|
|
10
|
+
}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** A failure the command line reports to the user and exits on. */
|
|
2
|
+
export class CliError extends Error {
|
|
3
|
+
/**
|
|
4
|
+
* @param message - what went wrong, in the user's terms
|
|
5
|
+
* @param options - the underlying cause, if any
|
|
6
|
+
*/
|
|
7
|
+
constructor(message, options) {
|
|
8
|
+
super(message, options);
|
|
9
|
+
this.name = "CliError";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,MAAM,OAAO,QAAS,SAAQ,KAAK;IAC/B;;;OAGG;IACH,YAAY,OAAe,EAAE,OAA6B;QACtD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IAC3B,CAAC;CACJ"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { Cli } from "./cli.js";
|
|
2
|
+
export { CliError } from "./errors.js";
|
|
3
|
+
export { ManifestValidator } from "./manifest.js";
|
|
4
|
+
export type { AssistantTool, ManifestCheckOptions, ManifestProblem, ManifestReport, PluginContributions, PluginManifest, PluginSetting, PluginView, SettingOption, SettingType, ViewSlot, } from "./manifest.js";
|
|
5
|
+
export { PluginPacker } from "./packer.js";
|
|
6
|
+
export type { PackOptions, PackResult } from "./packer.js";
|
|
7
|
+
export { PluginProject } from "./project.js";
|
|
8
|
+
export type { WatchOptions } from "./project.js";
|
|
9
|
+
export { Scaffolder } from "./scaffold.js";
|
|
10
|
+
export type { CreateOptions, CreateResult } from "./scaffold.js";
|
|
11
|
+
export { RollRookVite } from "./vite.js";
|
|
12
|
+
export type { RollRookViteOptions } from "./vite.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { Cli } from "./cli.js";
|
|
2
|
+
export { CliError } from "./errors.js";
|
|
3
|
+
export { ManifestValidator } from "./manifest.js";
|
|
4
|
+
export { PluginPacker } from "./packer.js";
|
|
5
|
+
export { PluginProject } from "./project.js";
|
|
6
|
+
export { Scaffolder } from "./scaffold.js";
|
|
7
|
+
export { RollRookVite } from "./vite.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAclD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/main.js
ADDED
package/dist/main.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,OAAO,CAAC,QAAQ,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/** Where a view shows in RollRook's stage; a `background` view is a hidden page kept loaded while the plugin is on. */
|
|
2
|
+
export type ViewSlot = "dock" | "sidebar" | "footbar" | "popover" | "settings" | "background";
|
|
3
|
+
/** One view of a plugin: a page in one place of the stage. */
|
|
4
|
+
export interface PluginView {
|
|
5
|
+
id: string;
|
|
6
|
+
slot: ViewSlot;
|
|
7
|
+
/** The page, relative to the plugin's root. */
|
|
8
|
+
entry: string;
|
|
9
|
+
/** A dock or sidebar view's title. */
|
|
10
|
+
title: string | undefined;
|
|
11
|
+
/** A dock or sidebar view's icon, relative to the plugin's root. */
|
|
12
|
+
icon: string | undefined;
|
|
13
|
+
/** A footbar view's width in points, or `fill`; a popover's width. */
|
|
14
|
+
width: number | "fill" | undefined;
|
|
15
|
+
/** A popover's height in points, or a settings view's (320 when not given). */
|
|
16
|
+
height: number | undefined;
|
|
17
|
+
/** Which end of the footbar the view sits at. */
|
|
18
|
+
align: "leading" | "trailing" | undefined;
|
|
19
|
+
/** Where the view sits among the footbar's items, lower first. */
|
|
20
|
+
order: number | undefined;
|
|
21
|
+
}
|
|
22
|
+
/** The kinds of value a setting holds. */
|
|
23
|
+
export type SettingType = "string" | "number" | "boolean" | "enum" | "json";
|
|
24
|
+
/** One choice of an `enum` setting. */
|
|
25
|
+
export interface SettingOption {
|
|
26
|
+
value: string;
|
|
27
|
+
title: string;
|
|
28
|
+
}
|
|
29
|
+
/** A setting the manifest declares. */
|
|
30
|
+
export interface PluginSetting {
|
|
31
|
+
key: string;
|
|
32
|
+
type: SettingType;
|
|
33
|
+
title: string;
|
|
34
|
+
/** The value before the user sets one, or undefined for the type's own. */
|
|
35
|
+
default_value: unknown;
|
|
36
|
+
list_options: SettingOption[];
|
|
37
|
+
min: number | undefined;
|
|
38
|
+
max: number | undefined;
|
|
39
|
+
step: number | undefined;
|
|
40
|
+
}
|
|
41
|
+
/** A tool the plugin offers RollRook's assistant, answered in its background view. */
|
|
42
|
+
export interface AssistantTool {
|
|
43
|
+
/** snake_case, unique in the plugin. */
|
|
44
|
+
name: string;
|
|
45
|
+
/** What the tool does and when to use it, for the assistant. */
|
|
46
|
+
description: string;
|
|
47
|
+
/** The JSON Schema of its input; `{ type: "object" }` when the manifest gives none. */
|
|
48
|
+
input: Record<string, unknown>;
|
|
49
|
+
/** Whether the user approves each call, after a preview, before it runs. */
|
|
50
|
+
is_confirmed: boolean;
|
|
51
|
+
}
|
|
52
|
+
/** What a plugin adds to RollRook beyond its views: `contributes` in the manifest. */
|
|
53
|
+
export interface PluginContributions {
|
|
54
|
+
/** The plugin's items in RollRook's calendar, under this title; undefined when it shows none. */
|
|
55
|
+
calendar_title: string | undefined;
|
|
56
|
+
list_tools: AssistantTool[];
|
|
57
|
+
/** A Markdown file inside the plugin teaching the assistant to use the tools. */
|
|
58
|
+
skill: string | undefined;
|
|
59
|
+
}
|
|
60
|
+
/** A plugin's `rollrook-plugin.json`, with the SDK's names. */
|
|
61
|
+
export interface PluginManifest {
|
|
62
|
+
id: string;
|
|
63
|
+
name: string;
|
|
64
|
+
version: string;
|
|
65
|
+
description: string | undefined;
|
|
66
|
+
publisher: string | undefined;
|
|
67
|
+
/** The older form's page; `list_views` holds it as the `main` dock view. */
|
|
68
|
+
main: string | undefined;
|
|
69
|
+
icon: string | undefined;
|
|
70
|
+
/** The views, the older form's `main` included. */
|
|
71
|
+
list_views: PluginView[];
|
|
72
|
+
list_settings: PluginSetting[];
|
|
73
|
+
list_permissions: string[];
|
|
74
|
+
contributes: PluginContributions;
|
|
75
|
+
min_rollrook: string | undefined;
|
|
76
|
+
repository: string | undefined;
|
|
77
|
+
}
|
|
78
|
+
/** One thing wrong with a manifest. */
|
|
79
|
+
export interface ManifestProblem {
|
|
80
|
+
/** The manifest field at fault, or `manifest` for the file as a whole. */
|
|
81
|
+
field: string;
|
|
82
|
+
message: string;
|
|
83
|
+
/** Errors refuse the install; warnings do not. */
|
|
84
|
+
severity: "error" | "warning";
|
|
85
|
+
}
|
|
86
|
+
/** The outcome of checking a manifest. */
|
|
87
|
+
export interface ManifestReport {
|
|
88
|
+
/** The manifest, when it has no errors. */
|
|
89
|
+
manifest: PluginManifest | undefined;
|
|
90
|
+
list_problems: ManifestProblem[];
|
|
91
|
+
}
|
|
92
|
+
/** Options for checking a manifest. */
|
|
93
|
+
export interface ManifestCheckOptions {
|
|
94
|
+
/** The folder the manifest sits in; when given, `main` and `icon` must exist there. */
|
|
95
|
+
folder?: string;
|
|
96
|
+
}
|
|
97
|
+
/** Checks `rollrook-plugin.json` against the rules RollRook installs by. */
|
|
98
|
+
export declare class ManifestValidator {
|
|
99
|
+
/** The manifest's file name, at the plugin's root. */
|
|
100
|
+
static readonly MANIFEST_FILE = "rollrook-plugin.json";
|
|
101
|
+
/** Two or more dot-separated parts of lowercase letters, digits and dashes. */
|
|
102
|
+
static readonly ID_PATTERN: RegExp;
|
|
103
|
+
/** Semantic versioning 2.0.0. */
|
|
104
|
+
static readonly SEMVER_PATTERN: RegExp;
|
|
105
|
+
/** A host name for `net:<host>`, optionally with a leading `*.` for its subdomains. */
|
|
106
|
+
static readonly HOST_PATTERN: RegExp;
|
|
107
|
+
/** The permissions a plugin may ask for, besides `net:<host>`. */
|
|
108
|
+
static readonly LIST_KNOWN_PERMISSIONS: string[];
|
|
109
|
+
/** What every plugin has without asking; listing them is refused as unknown. */
|
|
110
|
+
static readonly LIST_DEFAULT_PERMISSIONS: string[];
|
|
111
|
+
/** A view's id: lowercase letters, digits and dashes. */
|
|
112
|
+
static readonly VIEW_ID_PATTERN: RegExp;
|
|
113
|
+
/** The slots a view may show in. */
|
|
114
|
+
static readonly LIST_SLOTS: readonly ViewSlot[];
|
|
115
|
+
/** The fields each slot takes besides `id`, `slot` and `entry`. */
|
|
116
|
+
static readonly map_slot_fields: Record<ViewSlot, string[]>;
|
|
117
|
+
/** A tool's name: snake_case words of lowercase letters and digits joined by single underscores, a letter first. */
|
|
118
|
+
static readonly TOOL_NAME_PATTERN: RegExp;
|
|
119
|
+
/** The longest a tool's name may be; RollRook prefixes it with the plugin's name for the assistant. */
|
|
120
|
+
static readonly TOOL_NAME_MAX_LENGTH = 32;
|
|
121
|
+
/** The most tools a plugin may give the assistant. */
|
|
122
|
+
static readonly TOOL_LIMIT = 40;
|
|
123
|
+
/** The longest the calendar layer's title may be. */
|
|
124
|
+
static readonly CALENDAR_TITLE_MAX_LENGTH = 40;
|
|
125
|
+
/** The fields `contributes` takes. */
|
|
126
|
+
static readonly LIST_CONTRIBUTION_FIELDS: string[];
|
|
127
|
+
/** The fields a tool takes. */
|
|
128
|
+
static readonly LIST_TOOL_FIELDS: string[];
|
|
129
|
+
/** The extension of the assistant's skill file. */
|
|
130
|
+
static readonly SKILL_EXTENSION = ".md";
|
|
131
|
+
/** The slots a plugin needs at least one view in: the others are opened from those. */
|
|
132
|
+
static readonly LIST_STANDING_SLOTS: readonly ViewSlot[];
|
|
133
|
+
/** A settings view's height when the manifest gives none, in points. */
|
|
134
|
+
static readonly SETTINGS_DEFAULT_HEIGHT = 320;
|
|
135
|
+
/** The widest a footbar view may be, in points. */
|
|
136
|
+
static readonly FOOTBAR_MAX_WIDTH = 600;
|
|
137
|
+
/** The largest a popover may be either way, in points. */
|
|
138
|
+
static readonly POPOVER_MAX_SIZE = 800;
|
|
139
|
+
/** The kinds of value a setting holds. */
|
|
140
|
+
static readonly LIST_SETTING_TYPES: readonly SettingType[];
|
|
141
|
+
/** The longest a setting's key may be. */
|
|
142
|
+
static readonly SETTING_KEY_MAX_LENGTH = 200;
|
|
143
|
+
/** The id of the view the older form's `main` page becomes. */
|
|
144
|
+
static readonly MAIN_VIEW_ID = "main";
|
|
145
|
+
/** The prefix of a network permission. */
|
|
146
|
+
static readonly NET_PREFIX = "net:";
|
|
147
|
+
/** The permission to reach any site. */
|
|
148
|
+
static readonly NET_ANY_PERMISSION = "net:*";
|
|
149
|
+
/** The bytes of a PNG up to the end of its size in the IHDR chunk. */
|
|
150
|
+
static readonly PNG_HEADER_LENGTH = 24;
|
|
151
|
+
/** The icon formats RollRook shows. */
|
|
152
|
+
static readonly LIST_ICON_EXTENSIONS: string[];
|
|
153
|
+
/** The fields the manifest defines. */
|
|
154
|
+
static readonly LIST_FIELDS: string[];
|
|
155
|
+
/**
|
|
156
|
+
* Read and check the manifest in a folder.
|
|
157
|
+
*
|
|
158
|
+
* @param folder - the plugin's folder
|
|
159
|
+
* @returns the manifest and its problems
|
|
160
|
+
*/
|
|
161
|
+
static read(folder: string): ManifestReport;
|
|
162
|
+
/**
|
|
163
|
+
* Check a parsed manifest.
|
|
164
|
+
*
|
|
165
|
+
* @param raw - the parsed JSON
|
|
166
|
+
* @param options - the folder to look for `main` and `icon` in
|
|
167
|
+
* @returns the manifest and its problems
|
|
168
|
+
*/
|
|
169
|
+
static check(raw: unknown, options?: ManifestCheckOptions): ManifestReport;
|
|
170
|
+
/**
|
|
171
|
+
* Whether a permission is one RollRook knows.
|
|
172
|
+
*
|
|
173
|
+
* @param permission - the permission as written in the manifest
|
|
174
|
+
* @returns true for `raven`, `agents.read`, `audio`, `video`, `net:*` and a well-formed `net:<host>` with a dot in its host
|
|
175
|
+
*/
|
|
176
|
+
static is_known_permission(permission: string): boolean;
|
|
177
|
+
private static failed;
|
|
178
|
+
private readonly record;
|
|
179
|
+
private readonly folder;
|
|
180
|
+
private readonly list_problems;
|
|
181
|
+
private constructor();
|
|
182
|
+
private run;
|
|
183
|
+
private error;
|
|
184
|
+
private warning;
|
|
185
|
+
private text_field;
|
|
186
|
+
private check_path;
|
|
187
|
+
private check_png_square;
|
|
188
|
+
private check_views;
|
|
189
|
+
private check_view;
|
|
190
|
+
private check_settings;
|
|
191
|
+
private check_setting;
|
|
192
|
+
private check_options;
|
|
193
|
+
private check_default;
|
|
194
|
+
private static is_size;
|
|
195
|
+
private static is_json;
|
|
196
|
+
private check_contributes;
|
|
197
|
+
private check_tools;
|
|
198
|
+
private check_skill;
|
|
199
|
+
private check_permissions;
|
|
200
|
+
}
|