mirrorbook 0.1.2 → 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 +5 -1
- package/dist/cli.js +31 -3
- package/package.json +1 -1
package/SKILL.md
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
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
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
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.
|
|
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
|
|
|
12
14
|
```bash
|
|
@@ -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
|
|
|
@@ -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: {
|
|
@@ -252,6 +255,16 @@ var package_default = {
|
|
|
252
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:
|
|
@@ -260,6 +273,8 @@ Examples:
|
|
|
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
279
|
$ MIRRORBOOK_TOKEN=mb_xxx MIRRORBOOK_API_URL=https://mirrorbook.mixdao.world mirrorbook ls --json`
|
|
265
280
|
);
|
|
@@ -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();
|
|
@@ -411,7 +439,7 @@ async function applyAccess(api, slug, o) {
|
|
|
411
439
|
return (await api.updateSite(slug, body)).site;
|
|
412
440
|
}
|
|
413
441
|
var accessLine = (s) => s.passwordProtected ? `password-protected${s.passwordExpiresAt ? `, expires ${s.passwordExpiresAt.slice(0, 16).replace("T", " ")} UTC` : ", no expiry"}` : s.visibility === "unlisted" ? "unlisted" : "public";
|
|
414
|
-
program.command("deploy").description("Publish a directory, .zip, .html, .md, or .txt file. Markdown and text are turned into a web page. Re-deploying the same slug publishes a new version.").argument("<path>", "directory (with index.html or README.md), a .zip/.html/.md/.txt file, or - for stdin").option("-s, --slug <slug>", "subdomain: <slug>.mirrorbook.
|
|
442
|
+
program.command("deploy").description("Publish a directory, .zip, .html, .md, or .txt file. Markdown and text are turned into a web page. Re-deploying the same slug publishes a new version.").argument("<path>", "directory (with index.html or README.md), a .zip/.html/.md/.txt file, or - for stdin").option("-s, --slug <slug>", "subdomain: <slug>.mirrorbook.store (random if omitted; a suffix is added if it's taken)").option("--strict-slug", "fail with exit code 2 instead of adding a suffix when the slug is taken").option("-t, --title <title>", "site title").addOption(new Option("-f, --format <format>", "treat the input as html, markdown, or text (default: from the file extension; stdin is auto-detected)").choices(["html", "markdown", "text"])).option("-w, --wait", "wait until processing finishes").option("--timeout <sec>", "max seconds to wait", "300").option("--password <password>", "protect the site with a password (makes it unlisted; env MIRRORBOOK_SITE_PASSWORD avoids shell history)").option("--expires <when>", "how long the password stays valid: 7d, 12h, a date like 2026-12-31, or never").action(async (input, o) => {
|
|
415
443
|
const api = await client();
|
|
416
444
|
const { blob, name, files, format } = await pack(input, o.format);
|
|
417
445
|
const form = new FormData();
|