mirrorbook 0.1.0 → 0.2.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/SKILL.md +6 -2
- package/dist/cli.js +34 -6
- package/package.json +1 -1
package/SKILL.md
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: mirrorbook
|
|
3
|
-
description: Publish a static HTML page, folder, or zip to a public URL
|
|
3
|
+
description: Publish a static HTML page, folder, or zip to a public URL (<slug>.mirrorbook.store) via mirrorbook.mixdao.world with the `mirrorbook` CLI. Use when the user wants to share, host, or deploy an HTML file or a built static site.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Publishing HTML with mirrorbook
|
|
7
7
|
|
|
8
|
-
Sign in once with `npx mirrorbook login https://mirrorbook.
|
|
8
|
+
Sign in once with `npx mirrorbook login https://mirrorbook.mixdao.world`. It prints a URL and a code, opens the browser, and waits until the user approves. Ask the user to approve it; don't try to approve it yourself. In CI, set `MIRRORBOOK_TOKEN` (and `MIRRORBOOK_API_URL` for a non-default server) instead.
|
|
9
|
+
|
|
10
|
+
**Workflow.** After login, and before choosing a slug, run `npx mirrorbook ls --json` to see the user's existing sites. If the content clearly belongs to one of them (matching title or purpose), re-deploy to that slug to publish a new version; otherwise pick a new slug. Only ask the user when it is ambiguous, and offer the real slugs from `ls` as options. After deploying, report the final `url`, and mention `previewUrl` and `rollback` if the user may want to compare versions.
|
|
9
11
|
|
|
10
12
|
Several servers can be saved: `mirrorbook servers` lists them, `mirrorbook use <name>` switches, `--server <name>` picks one for a single command.
|
|
11
13
|
|
|
@@ -28,4 +30,6 @@ Versions: every deploy gets a number (`#1`, `#2`, …, in the `number` field). T
|
|
|
28
30
|
|
|
29
31
|
Password protection: `--password <pw> [--expires 7d|12h|2026-12-31|never]` on `deploy` (or `access <slug> --password … --expires …` later) makes the site unlisted and asks visitors for the password. After the expiry the site can't be opened until a new expiry or password is set. `access <slug> --remove-password` drops it, `access <slug> --public` makes the site public again. Prefer the `MIRRORBOOK_SITE_PASSWORD` env var over `--password` to keep it out of shell history.
|
|
30
32
|
|
|
33
|
+
Install this skill for Claude Code with `npx mirrorbook skill --install` (or `--dir ./.claude/skills` for one project); `mirrorbook skill` prints it.
|
|
34
|
+
|
|
31
35
|
Other commands: `access <slug>`, `ls`, `status <slug>` (lists versions), `rollback <slug> <version>` (alias `set-default`; version is `3`, `#3`, or a deployment id), `rm-version <slug> <version> --yes`, `rm <slug> --yes`, `whoami`. Add `--json` to any of them.
|
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
// src/cli.ts
|
|
4
4
|
import { spawn } from "child_process";
|
|
5
|
-
import {
|
|
5
|
+
import { cp, mkdir as mkdir2, readFile as readFile3 } from "fs/promises";
|
|
6
|
+
import { homedir as homedir2, hostname, platform } from "os";
|
|
7
|
+
import path3 from "path";
|
|
8
|
+
import { fileURLToPath } from "url";
|
|
6
9
|
import { createInterface } from "readline/promises";
|
|
7
10
|
import { Command, Option } from "commander";
|
|
8
11
|
|
|
@@ -130,7 +133,7 @@ import { homedir } from "os";
|
|
|
130
133
|
import path from "path";
|
|
131
134
|
var DIR = path.join(process.env.XDG_CONFIG_HOME ?? path.join(homedir(), ".config"), "mirrorbook");
|
|
132
135
|
var FILE = path.join(DIR, "config.json");
|
|
133
|
-
var DEFAULT_API_URL = "https://mirrorbook.
|
|
136
|
+
var DEFAULT_API_URL = "https://mirrorbook.mixdao.world";
|
|
134
137
|
var configPath = FILE;
|
|
135
138
|
function serverNameFromUrl(url) {
|
|
136
139
|
const u = new URL(url);
|
|
@@ -220,7 +223,7 @@ async function pack(input, format) {
|
|
|
220
223
|
// package.json
|
|
221
224
|
var package_default = {
|
|
222
225
|
name: "mirrorbook",
|
|
223
|
-
version: "0.1.
|
|
226
|
+
version: "0.1.2",
|
|
224
227
|
description: "Publish HTML to a shareable URL. Agent-friendly: non-interactive, --json output, stable exit codes.",
|
|
225
228
|
type: "module",
|
|
226
229
|
bin: {
|
|
@@ -249,19 +252,31 @@ var package_default = {
|
|
|
249
252
|
};
|
|
250
253
|
|
|
251
254
|
// src/cli.ts
|
|
252
|
-
var program = new Command().name("mirrorbook").description("Publish HTML to a shareable URL on mirrorbook.
|
|
255
|
+
var program = new Command().name("mirrorbook").description("Publish HTML to a shareable URL on mirrorbook.mixdao.world").version(package_default.version).addOption(new Option("--json", "print one JSON object to stdout (also MIRRORBOOK_JSON=1)").default(process.env.MIRRORBOOK_JSON === "1")).option("-n, --server <name>", "use a saved server for this command (env MIRRORBOOK_SERVER); see `mirrorbook servers`").option("--api-url <url>", "server URL, overrides the saved one (env MIRRORBOOK_API_URL)").option("--token <token>", "API token, overrides the saved one (env MIRRORBOOK_TOKEN)").showHelpAfterError().addHelpText(
|
|
253
256
|
"after",
|
|
254
257
|
`
|
|
258
|
+
Recommended workflow:
|
|
259
|
+
First time login \u2192 ls \u2192 deploy
|
|
260
|
+
Update a site ls (find the existing slug) \u2192 deploy <path> --slug <slug> --wait \u2192 status <slug>
|
|
261
|
+
Share privately deploy <path> --slug <slug> --password <pw> --expires 7d (or: access <slug> ...)
|
|
262
|
+
Went wrong status <slug> \u2192 rollback <slug> <version>
|
|
263
|
+
Use with AI agents mirrorbook skill --install (installs the usage guide into Claude Code)
|
|
264
|
+
|
|
265
|
+
Always run \`mirrorbook ls\` before picking a slug: re-deploying an existing slug publishes a new
|
|
266
|
+
version of that site, a new slug creates a new site.
|
|
267
|
+
|
|
255
268
|
Exit codes: 0 ok \xB7 1 error \xB7 2 usage \xB7 3 auth \xB7 4 quota \xB7 5 deployment failed or rejected
|
|
256
269
|
|
|
257
270
|
Examples:
|
|
258
|
-
$ mirrorbook login https://mirrorbook.
|
|
271
|
+
$ mirrorbook login https://mirrorbook.mixdao.world # opens the browser to approve
|
|
259
272
|
$ mirrorbook deploy ./dist --slug my-demo --wait --json
|
|
260
273
|
$ cat page.html | mirrorbook deploy - --slug quick-note
|
|
261
274
|
$ mirrorbook deploy notes.md --slug my-notes # Markdown \u2192 web page
|
|
262
275
|
$ pbpaste | mirrorbook deploy - --format markdown
|
|
276
|
+
$ mirrorbook ls # existing sites and their slugs
|
|
277
|
+
$ mirrorbook skill --install # let Claude Code use this CLI automatically
|
|
263
278
|
$ mirrorbook servers # saved servers; switch with \`mirrorbook use <name>\`
|
|
264
|
-
$ MIRRORBOOK_TOKEN=mb_xxx MIRRORBOOK_API_URL=https://mirrorbook.
|
|
279
|
+
$ MIRRORBOOK_TOKEN=mb_xxx MIRRORBOOK_API_URL=https://mirrorbook.mixdao.world mirrorbook ls --json`
|
|
265
280
|
);
|
|
266
281
|
var g = () => program.opts();
|
|
267
282
|
function out(human, data) {
|
|
@@ -385,6 +400,19 @@ program.command("use").description("Switch the current server").argument("<name>
|
|
|
385
400
|
await saveConfig(cfg);
|
|
386
401
|
out(`Now using ${name} (${cfg.servers[name].url})`, { ok: true, server: name, url: cfg.servers[name].url });
|
|
387
402
|
});
|
|
403
|
+
program.command("skill").description("Print the agent skill (SKILL.md) for this CLI, or install it for Claude Code with --install").option("--install", "copy SKILL.md to ~/.claude/skills/mirrorbook/ (Claude Code loads it automatically)").option("--dir <dir>", "install into <dir>/mirrorbook/ instead, e.g. ./.claude/skills for this project only").action(async (o) => {
|
|
404
|
+
const src = fileURLToPath(new URL("../SKILL.md", import.meta.url));
|
|
405
|
+
if (!o.install && !o.dir) {
|
|
406
|
+
const text = await readFile3(src, "utf8");
|
|
407
|
+
if (g().json) out("", { path: src, content: text });
|
|
408
|
+
else process.stdout.write(text);
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
const dest = path3.join(o.dir ? path3.resolve(o.dir) : path3.join(homedir2(), ".claude", "skills"), "mirrorbook");
|
|
412
|
+
await mkdir2(dest, { recursive: true });
|
|
413
|
+
await cp(src, path3.join(dest, "SKILL.md"));
|
|
414
|
+
out(`Installed skill to ${dest}/SKILL.md. Restart Claude Code to pick it up.`, { ok: true, path: path3.join(dest, "SKILL.md") });
|
|
415
|
+
});
|
|
388
416
|
program.command("whoami").description("Show the current server and account").action(async () => {
|
|
389
417
|
const { name, apiUrl } = await auth();
|
|
390
418
|
const { user } = await (await client()).me();
|