@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.
Files changed (50) hide show
  1. package/bin/rollrook-plugin.js +2 -0
  2. package/dist/cli.d.ts +25 -0
  3. package/dist/cli.js +194 -0
  4. package/dist/cli.js.map +1 -0
  5. package/dist/errors.d.ts +10 -0
  6. package/dist/errors.js +12 -0
  7. package/dist/errors.js.map +1 -0
  8. package/dist/index.d.ts +12 -0
  9. package/dist/index.js +8 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/main.d.ts +1 -0
  12. package/dist/main.js +3 -0
  13. package/dist/main.js.map +1 -0
  14. package/dist/manifest.d.ts +200 -0
  15. package/dist/manifest.js +723 -0
  16. package/dist/manifest.js.map +1 -0
  17. package/dist/packer.d.ts +44 -0
  18. package/dist/packer.js +78 -0
  19. package/dist/packer.js.map +1 -0
  20. package/dist/project.d.ts +59 -0
  21. package/dist/project.js +149 -0
  22. package/dist/project.js.map +1 -0
  23. package/dist/scaffold.d.ts +49 -0
  24. package/dist/scaffold.js +127 -0
  25. package/dist/scaffold.js.map +1 -0
  26. package/dist/vite.d.ts +40 -0
  27. package/dist/vite.js +124 -0
  28. package/dist/vite.js.map +1 -0
  29. package/package.json +49 -4
  30. package/src/cli.ts +206 -0
  31. package/src/errors.ts +11 -0
  32. package/src/index.ts +24 -0
  33. package/src/main.ts +3 -0
  34. package/src/manifest.ts +882 -0
  35. package/src/packer.ts +104 -0
  36. package/src/project.ts +168 -0
  37. package/src/scaffold.ts +156 -0
  38. package/src/vite.ts +136 -0
  39. package/template/README.md +12 -0
  40. package/template/_gitignore +4 -0
  41. package/template/icon.svg +14 -0
  42. package/template/index.html +33 -0
  43. package/template/package.json +22 -0
  44. package/template/rollrook-plugin.json +18 -0
  45. package/template/src/main.ts +78 -0
  46. package/template/src/style.css +35 -0
  47. package/template/src/vite-env.d.ts +1 -0
  48. package/template/tsconfig.json +18 -0
  49. package/template/vite.config.ts +10 -0
  50. package/README.md +0 -3
package/dist/vite.js ADDED
@@ -0,0 +1,124 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { join, resolve } from "node:path";
3
+ import { ManifestValidator } from "./manifest.js";
4
+ /**
5
+ * Builds a RollRook plugin with Vite: takes every view's entry page as an
6
+ * input, emits `rollrook-plugin.json`, the icons and the assistant's skill
7
+ * file it names into the output, rebuilds when they change, and stops the build when the manifest
8
+ * has errors.
9
+ */
10
+ export class RollRookVite {
11
+ /** The plugin's name, as Vite reports it. */
12
+ static PLUGIN_NAME = "rollrook-plugin";
13
+ /**
14
+ * @param options - where the manifest lives
15
+ * @returns the Vite plugin
16
+ */
17
+ static plugin(options = {}) {
18
+ let root = process.cwd();
19
+ let public_dir = "";
20
+ return {
21
+ name: RollRookVite.PLUGIN_NAME,
22
+ apply: "build",
23
+ config(config) {
24
+ const folder = resolve(config.root ?? process.cwd(), options.manifest_folder ?? ".");
25
+ const manifest = ManifestValidator.read(folder).manifest;
26
+ if (manifest === undefined) {
27
+ return {};
28
+ }
29
+ return {
30
+ build: {
31
+ rolldownOptions: {
32
+ input: RollRookVite.inputs(manifest, folder),
33
+ },
34
+ },
35
+ };
36
+ },
37
+ configResolved(config) {
38
+ root = resolve(config.root, options.manifest_folder ?? ".");
39
+ public_dir = config.publicDir;
40
+ },
41
+ buildStart() {
42
+ this.addWatchFile(join(root, ManifestValidator.MANIFEST_FILE));
43
+ const report = ManifestValidator.read(root);
44
+ for (const problem of report.list_problems) {
45
+ const line = `${ManifestValidator.MANIFEST_FILE}: ${problem.field}: ${problem.message}`;
46
+ if (problem.severity === "error") {
47
+ this.error(line);
48
+ }
49
+ this.warn(line);
50
+ }
51
+ for (const file of RollRookVite.files(report.manifest)) {
52
+ this.addWatchFile(join(root, file));
53
+ }
54
+ },
55
+ generateBundle() {
56
+ const manifest = ManifestValidator.read(root).manifest;
57
+ if (manifest === undefined) {
58
+ return;
59
+ }
60
+ this.emitFile({
61
+ type: "asset",
62
+ fileName: ManifestValidator.MANIFEST_FILE,
63
+ source: readFileSync(join(root, ManifestValidator.MANIFEST_FILE), "utf8"),
64
+ });
65
+ for (const file of RollRookVite.files(manifest)) {
66
+ if (!(public_dir !== "" && existsSync(join(public_dir, file)))) {
67
+ this.emitFile({
68
+ type: "asset",
69
+ fileName: file,
70
+ source: readFileSync(join(root, file)),
71
+ });
72
+ }
73
+ }
74
+ },
75
+ };
76
+ }
77
+ /**
78
+ * The pages Vite builds: each view's entry, named by the entry's path.
79
+ *
80
+ * @param manifest - the plugin's manifest
81
+ * @param folder - the folder the entries are relative to
82
+ * @returns the inputs, by name
83
+ */
84
+ static inputs(manifest, folder) {
85
+ const map_inputs = {};
86
+ for (const view of manifest.list_views) {
87
+ const name = view.entry.replace(/\.html?$/i, "").replaceAll("/", "-");
88
+ map_inputs[name] = resolve(folder, view.entry);
89
+ }
90
+ return map_inputs;
91
+ }
92
+ /**
93
+ * @param manifest - the plugin's manifest, or undefined
94
+ * @returns the files besides the pages the package needs: the icons and the assistant's skill, each once
95
+ */
96
+ static files(manifest) {
97
+ const list_files = RollRookVite.icons(manifest);
98
+ const skill = manifest?.contributes.skill;
99
+ if (skill !== undefined && !list_files.includes(skill)) {
100
+ list_files.push(skill);
101
+ }
102
+ return list_files;
103
+ }
104
+ /**
105
+ * @param manifest - the plugin's manifest, or undefined
106
+ * @returns the plugin's icon and its views' icons, each once
107
+ */
108
+ static icons(manifest) {
109
+ if (manifest === undefined) {
110
+ return [];
111
+ }
112
+ const set_icons = new Set();
113
+ if (manifest.icon !== undefined) {
114
+ set_icons.add(manifest.icon);
115
+ }
116
+ for (const view of manifest.list_views) {
117
+ if (view.icon !== undefined) {
118
+ set_icons.add(view.icon);
119
+ }
120
+ }
121
+ return [...set_icons];
122
+ }
123
+ }
124
+ //# sourceMappingURL=vite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.js","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"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,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC9B,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;YACrC,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;gBAC1B,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC7B,CAAC;QACL,CAAC;QACD,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC;IAC1B,CAAC;CACJ"}
package/package.json CHANGED
@@ -1,6 +1,51 @@
1
1
  {
2
2
  "name": "@rollrook-ai/plugin-cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Create, develop, check and pack RollRook plugins.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/rollrook-ai/rollrook-sdk.git",
10
+ "directory": "packages/cli"
11
+ },
12
+ "bin": {
13
+ "rollrook-plugin": "bin/rollrook-plugin.js"
14
+ },
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.js"
19
+ },
20
+ "./vite": {
21
+ "types": "./dist/vite.d.ts",
22
+ "import": "./dist/vite.js"
23
+ }
24
+ },
25
+ "files": [
26
+ "bin",
27
+ "dist",
28
+ "src",
29
+ "template"
30
+ ],
31
+ "scripts": {
32
+ "build": "tsc -p tsconfig.build.json && node scripts/copy-template.mjs",
33
+ "typecheck": "tsc -p tsconfig.json --noEmit",
34
+ "test": "vitest run"
35
+ },
36
+ "dependencies": {
37
+ "fflate": "^0.8.3"
38
+ },
39
+ "peerDependencies": {
40
+ "vite": "^8.0.0"
41
+ },
42
+ "devDependencies": {
43
+ "@types/node": "^24.0.0",
44
+ "typescript": "^7.0.2",
45
+ "vite": "^8.4.1",
46
+ "vitest": "^5.1.2"
47
+ },
48
+ "engines": {
49
+ "node": ">=20.19"
50
+ }
51
+ }
package/src/cli.ts ADDED
@@ -0,0 +1,206 @@
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 type { ManifestProblem } from "./manifest.js";
8
+ import { PluginPacker } from "./packer.js";
9
+ import { PluginProject } from "./project.js";
10
+ import { Scaffolder } from "./scaffold.js";
11
+ import type { CreateOptions } from "./scaffold.js";
12
+
13
+ /** The `rollrook-plugin` command line. */
14
+ export class Cli {
15
+ /** The command's name. */
16
+ static readonly COMMAND = "rollrook-plugin";
17
+
18
+ /** The exit status of a failed command. */
19
+ static readonly EXIT_FAILURE = 1;
20
+
21
+ /** The help text. */
22
+ static readonly USAGE = `Usage: rollrook-plugin <command> [options]
23
+
24
+ Commands:
25
+ create <dir> [--name <name>] [--id <id>] Create a plugin from the template
26
+ dev [dir] Build on every change and link the build into RollRook
27
+ build [dir] Build the plugin into dist/
28
+ pack [dir] [--out <file>] [--no-build] Check the manifest and write <id>-<version>.rrplugin
29
+ validate [dir] Check rollrook-plugin.json
30
+ publish Publish to the plugin market (not open yet)
31
+
32
+ Options:
33
+ -h, --help Show this help
34
+ -v, --version Show the version`;
35
+
36
+ /**
37
+ * Run one command.
38
+ *
39
+ * @param list_args - the arguments after the command's name
40
+ * @returns the exit status
41
+ */
42
+ static async run(list_args: string[]): Promise<number> {
43
+ try {
44
+ return await Cli.dispatch(list_args);
45
+ } catch (err: unknown) {
46
+ if (err instanceof CliError) {
47
+ console.error(`${Cli.COMMAND}: ${err.message}`);
48
+ return Cli.EXIT_FAILURE;
49
+ }
50
+ throw err;
51
+ }
52
+ }
53
+
54
+ private static async dispatch(list_args: string[]): Promise<number> {
55
+ const { values, positionals } = parseArgs({
56
+ args: list_args,
57
+ allowPositionals: true,
58
+ options: {
59
+ "help": { type: "boolean", short: "h" },
60
+ "version": { type: "boolean", short: "v" },
61
+ "name": { type: "string" },
62
+ "id": { type: "string" },
63
+ "out": { type: "string" },
64
+ "no-build": { type: "boolean" },
65
+ },
66
+ });
67
+ const [command, target] = positionals;
68
+ if (values.version === true) {
69
+ console.log(Scaffolder.own_version());
70
+ return 0;
71
+ }
72
+ if (values.help === true || command === undefined || command === "help") {
73
+ console.log(Cli.USAGE);
74
+ return 0;
75
+ }
76
+ const dir = target ?? ".";
77
+ switch (command) {
78
+ case "create":
79
+ if (target === undefined) {
80
+ throw new CliError("create needs a folder: rollrook-plugin create <dir>");
81
+ }
82
+ return Cli.create({
83
+ dir: target,
84
+ ...(values.name === undefined ? {} : { name: values.name }),
85
+ ...(values.id === undefined ? {} : { id: values.id }),
86
+ });
87
+ case "dev":
88
+ return Cli.dev(dir);
89
+ case "build":
90
+ return Cli.build(dir);
91
+ case "pack":
92
+ return Cli.pack({ dir, out_file: values.out, should_build: values["no-build"] !== true });
93
+ case "validate":
94
+ return Cli.validate(dir);
95
+ case "publish":
96
+ return Cli.publish();
97
+ default:
98
+ throw new CliError(`unknown command ${command}\n\n${Cli.USAGE}`);
99
+ }
100
+ }
101
+
102
+ private static create(options: CreateOptions): number {
103
+ const result = Scaffolder.create(options);
104
+ const shown_dir = relative(process.cwd(), result.dir) || ".";
105
+ console.log(`Created ${result.name} (${result.id}) in ${result.dir}
106
+
107
+ Next:
108
+ cd ${shown_dir}
109
+ npm install
110
+ npm run dev develop in the browser against the mock host
111
+ npm run link build on every change and link the plugin into RollRook
112
+ npm run pack write the .rrplugin package`);
113
+ return 0;
114
+ }
115
+
116
+ private static async dev(dir: string): Promise<number> {
117
+ const project = new PluginProject(dir);
118
+ project.manifest();
119
+ const url = project.link_url();
120
+ const stop = await project.watch({
121
+ on_built: (is_first: boolean) => {
122
+ if (!is_first) {
123
+ console.log("Rebuilt; RollRook reloads the plugin.");
124
+ return;
125
+ }
126
+ console.log(`Built into ${project.package_folder()}`);
127
+ Cli.open_link(url);
128
+ },
129
+ on_error: (error: Error) => console.error(`${Cli.COMMAND}: build failed: ${error.message}`),
130
+ });
131
+ await new Promise<void>((resolve_wait) => {
132
+ process.once("SIGINT", () => resolve_wait());
133
+ process.once("SIGTERM", () => resolve_wait());
134
+ });
135
+ await stop();
136
+ return 0;
137
+ }
138
+
139
+ private static async build(dir: string): Promise<number> {
140
+ const project = new PluginProject(dir);
141
+ project.manifest();
142
+ await project.build();
143
+ return Cli.print_report(ManifestValidator.read(project.package_folder()).list_problems);
144
+ }
145
+
146
+ private static async pack(options: { dir: string; out_file: string | undefined; should_build: boolean }): Promise<number> {
147
+ const project = new PluginProject(options.dir);
148
+ const manifest = project.manifest();
149
+ if (options.should_build && project.uses_vite()) {
150
+ await project.build();
151
+ }
152
+ const folder = project.package_folder();
153
+ if (!existsSync(folder)) {
154
+ throw new CliError(`${folder} does not exist; build the plugin first`);
155
+ }
156
+ const out_file = resolve(options.out_file ?? join(project.root, PluginPacker.file_name(manifest)));
157
+ const result = PluginPacker.pack({ folder, out_file });
158
+ Cli.print_report(ManifestValidator.read(folder).list_problems);
159
+ console.log(`Packed ${result.list_files.length} files into ${result.out_file}`);
160
+ return 0;
161
+ }
162
+
163
+ private static validate(dir: string): number {
164
+ const project = new PluginProject(dir);
165
+ let status = Cli.print_report(ManifestValidator.read(project.root).list_problems);
166
+ const folder = project.package_folder();
167
+ if (folder !== project.root && existsSync(join(folder, ManifestValidator.MANIFEST_FILE))) {
168
+ status = Math.max(status, Cli.print_report(ManifestValidator.read(folder).list_problems));
169
+ }
170
+ if (status === 0) {
171
+ console.log(`${ManifestValidator.MANIFEST_FILE} is valid.`);
172
+ }
173
+ return status;
174
+ }
175
+
176
+ private static publish(): number {
177
+ console.log(`The RollRook plugin market is not open yet, so there is nothing to publish to.
178
+
179
+ Until it opens, share a plugin as its package:
180
+ rollrook-plugin pack writes <id>-<version>.rrplugin
181
+ and install that file in RollRook's Settings, under Plugins, with Install from File.`);
182
+ return Cli.EXIT_FAILURE;
183
+ }
184
+
185
+ private static print_report(list_problems: ManifestProblem[]): number {
186
+ for (const problem of list_problems) {
187
+ const line = `${problem.severity}: ${problem.field}: ${problem.message}`;
188
+ if (problem.severity === "error") {
189
+ console.error(line);
190
+ } else {
191
+ console.warn(line);
192
+ }
193
+ }
194
+ return list_problems.some((problem: ManifestProblem) => problem.severity === "error") ? Cli.EXIT_FAILURE : 0;
195
+ }
196
+
197
+ private static open_link(url: string): void {
198
+ if (process.platform !== "darwin") {
199
+ console.log(`Open this link on the Mac running RollRook:\n ${url}`);
200
+ return;
201
+ }
202
+ console.log("Linking into RollRook; allow the plugin's permissions there.");
203
+ const child = spawn("open", [url], { stdio: "inherit" });
204
+ child.on("error", (error: Error) => console.error(`${Cli.COMMAND}: could not open ${url}: ${error.message}`));
205
+ }
206
+ }
package/src/errors.ts ADDED
@@ -0,0 +1,11 @@
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: string, options?: { cause?: unknown }) {
8
+ super(message, options);
9
+ this.name = "CliError";
10
+ }
11
+ }
package/src/index.ts ADDED
@@ -0,0 +1,24 @@
1
+ export { Cli } from "./cli.js";
2
+ export { CliError } from "./errors.js";
3
+ export { ManifestValidator } from "./manifest.js";
4
+ export type {
5
+ AssistantTool,
6
+ ManifestCheckOptions,
7
+ ManifestProblem,
8
+ ManifestReport,
9
+ PluginContributions,
10
+ PluginManifest,
11
+ PluginSetting,
12
+ PluginView,
13
+ SettingOption,
14
+ SettingType,
15
+ ViewSlot,
16
+ } from "./manifest.js";
17
+ export { PluginPacker } from "./packer.js";
18
+ export type { PackOptions, PackResult } from "./packer.js";
19
+ export { PluginProject } from "./project.js";
20
+ export type { WatchOptions } from "./project.js";
21
+ export { Scaffolder } from "./scaffold.js";
22
+ export type { CreateOptions, CreateResult } from "./scaffold.js";
23
+ export { RollRookVite } from "./vite.js";
24
+ export type { RollRookViteOptions } from "./vite.js";
package/src/main.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { Cli } from "./cli.js";
2
+
3
+ process.exitCode = await Cli.run(process.argv.slice(2));