mirrorbook 0.4.0 → 0.5.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 (3) hide show
  1. package/SKILL.md +11 -1
  2. package/dist/cli.js +36 -6
  3. package/package.json +1 -1
package/SKILL.md CHANGED
@@ -19,7 +19,7 @@ npx mirrorbook deploy ./dist --slug my-demo --wait --json
19
19
  - Markdown (GitHub-flavored) and plain text are rendered into a readable web page. For stdin the format is auto-detected; pass `--format html|markdown|text` to be explicit. The quickest way to publish something you just wrote: `echo "$CONTENT" | npx mirrorbook deploy - --format markdown --slug my-notes --json`.
20
20
  - Re-deploying the same `--slug` publishes a new version; it's safe to retry.
21
21
  - If the slug is taken by someone else, a 4-character suffix is added (`demo` → `demo-k3x9`) and `slugAdjusted` is `true`. Always read the final `url`/`slug` from the output. Re-deploying with the original `--slug demo` keeps updating that same `demo-k3x9` site. Pass `--strict-slug` to fail (exit 2, `slug_taken`) instead.
22
- - Output (with `--json`): `{"url","previewUrl","slug","deploymentId","status","error","errorCode","errorParams","number","created","requestedSlug","slugAdjusted"}`.
22
+ - Output (with `--json`): `{"url","previewUrl","slug","deploymentId","status","error","errorCode","errorParams","number","created","requestedSlug","slugAdjusted","lockTitle","lockMessage"}`.
23
23
  - When `status` is `failed`, `errorCode` says why: `missing_index` (no index.html at the zip root), `zip_invalid`, `zip_path_invalid`, `zip_encrypted`, `file_too_large`, `unzipped_too_large`, `too_many_files`, `quota_exceeded`, `upload_missing`, `file_read_failed`, `owner_missing`, `processing_failed`.
24
24
  - Sites go live as soon as processing finishes (`status: "approved"`); admins review afterwards and may take a version down (`rejected`). A new account needs admin approval once before it can publish (exit 3, `pending_approval`).
25
25
  - Each account has a site limit (default 10) and a storage quota (default 100 MB); going over exits with 4 (`quota_exceeded`).
@@ -30,6 +30,16 @@ Versions: every deploy gets a number (`#1`, `#2`, …, in the `number` field). T
30
30
 
31
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.
32
32
 
33
+ Password page copy: the gate visitors see before entering the password is customisable with `--lock-title <text>` (max 80 chars, becomes the page title and the bold heading) and `--lock-message <text>` (max 300 chars, the line above the password box — good place for "how to get the password"). Both work on `deploy` and on `access`:
34
+
35
+ ```bash
36
+ npx mirrorbook access my-demo --lock-title "Team preview" --lock-message "Password is in #general"
37
+ npx mirrorbook deploy ./dist --slug my-demo --password "$PW" --lock-title "…" --lock-message "…"
38
+ npx mirrorbook access my-demo --clear-lock # back to the default copy
39
+ ```
40
+
41
+ The copy only appears on password-protected sites — setting it on a site with no password stores it but visitors never see it (the CLI prints a `note:` line in that case). Passing the option alone is enough to change it; you don't need to re-supply `--password`.
42
+
33
43
  Install this skill for Claude Code with `npx mirrorbook skill --install` (or `--dir ./.claude/skills` for one project); `mirrorbook skill` prints it.
34
44
 
35
45
  Other commands: `pull <slug> [version] [-o file.zip]` (download a version's files as a zip; owner only, defaults to the live version), `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
@@ -246,7 +246,7 @@ import { fileURLToPath } from "url";
246
246
  // package.json
247
247
  var package_default = {
248
248
  name: "mirrorbook",
249
- version: "0.4.0",
249
+ version: "0.5.0",
250
250
  description: "Publish HTML to a shareable URL. Agent-friendly: non-interactive, --json output, stable exit codes.",
251
251
  type: "module",
252
252
  bin: {
@@ -547,7 +547,18 @@ function parseExpiry(v, now = Date.now()) {
547
547
  if (Number.isNaN(at.getTime())) throw new CliError("usage", `Can't read expiry "${v}". Use 7d, 12h, 30m, or a date like 2026-12-31`, EXIT.usage);
548
548
  return at.toISOString();
549
549
  }
550
+ var LOCK_TITLE_MAX = 80;
551
+ var LOCK_MESSAGE_MAX = 300;
552
+ function checkLockLength(o) {
553
+ if (o.clearLock && (o.lockTitle !== void 0 || o.lockMessage !== void 0))
554
+ throw new CliError("usage", "--clear-lock can't be combined with --lock-title / --lock-message", EXIT.usage);
555
+ if (o.lockTitle && o.lockTitle.length > LOCK_TITLE_MAX)
556
+ throw new CliError("usage", `--lock-title is ${o.lockTitle.length} characters; the limit is ${LOCK_TITLE_MAX}`, EXIT.usage);
557
+ if (o.lockMessage && o.lockMessage.length > LOCK_MESSAGE_MAX)
558
+ throw new CliError("usage", `--lock-message is ${o.lockMessage.length} characters; the limit is ${LOCK_MESSAGE_MAX}`, EXIT.usage);
559
+ }
550
560
  async function applyAccess(api, slug, o) {
561
+ checkLockLength(o);
551
562
  const password = o.password ?? process.env.MIRRORBOOK_SITE_PASSWORD;
552
563
  const body = {};
553
564
  if (o.public) body.visibility = "public";
@@ -557,11 +568,26 @@ async function applyAccess(api, slug, o) {
557
568
  if (password) body.password = password;
558
569
  }
559
570
  if (o.expires && !o.public && !o.removePassword) body.passwordExpiresAt = o.expires === "never" ? null : parseExpiry(o.expires);
571
+ if (o.clearLock) {
572
+ body.lockTitle = "";
573
+ body.lockMessage = "";
574
+ } else {
575
+ if (o.lockTitle !== void 0) body.lockTitle = o.lockTitle;
576
+ if (o.lockMessage !== void 0) body.lockMessage = o.lockMessage;
577
+ }
560
578
  if (!Object.keys(body).length) return null;
561
579
  return (await api.updateSite(slug, body)).site;
562
580
  }
563
581
  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";
564
- 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) => {
582
+ var lockLines = (s) => {
583
+ if (!s.lockTitle && !s.lockMessage) return [];
584
+ return [
585
+ ` lock: ${s.lockTitle ? JSON.stringify(s.lockTitle) : "(default title)"}${s.lockMessage ? ` / ${JSON.stringify(s.lockMessage)}` : ""}`,
586
+ // 文案只挂在密码页上,没有密码的站点访客永远看不到,提示一下免得白设
587
+ ...s.passwordProtected ? [] : [" note: no password set, so visitors never see this copy"]
588
+ ];
589
+ };
590
+ 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").option("--lock-title <text>", `title shown on the password page (max ${LOCK_TITLE_MAX} chars)`).option("--lock-message <text>", `message shown above the password box, e.g. how to get the password (max ${LOCK_MESSAGE_MAX} chars)`).option("--clear-lock", "restore the default password page copy").action(async (input, o) => {
565
591
  const api = await client();
566
592
  const { blob, name, files, format } = await pack(input, o.format);
567
593
  const form = new FormData();
@@ -581,18 +607,22 @@ program.command("deploy").description("Publish a directory, .zip, .html, .md, or
581
607
  ...slugAdjusted && requestedSlug ? [` note: ${requestedSlug} is taken, using ${site.slug}. Re-deploying with --slug ${requestedSlug} updates this same site.`] : [],
582
608
  ` url: ${site.url}`,
583
609
  ...site.passwordProtected ? [` access: ${accessLine(site)}`] : [],
610
+ ...lockLines(site),
584
611
  ` preview: ${deployment.previewUrl}`,
585
612
  ` status: ${describe(deployment)}`
586
613
  ].join("\n"),
587
- { url: site.url, visibility: site.visibility, passwordProtected: site.passwordProtected, passwordExpiresAt: site.passwordExpiresAt, previewUrl: deployment.previewUrl, slug: site.slug, siteId: site.id, deploymentId: deployment.id, status: deployment.status, error: deployment.error, errorCode: deployment.errorCode, errorParams: deployment.errorParams, number: deployment.number, created, requestedSlug, slugAdjusted }
614
+ { url: site.url, visibility: site.visibility, passwordProtected: site.passwordProtected, passwordExpiresAt: site.passwordExpiresAt, lockTitle: site.lockTitle, lockMessage: site.lockMessage, previewUrl: deployment.previewUrl, slug: site.slug, siteId: site.id, deploymentId: deployment.id, status: deployment.status, error: deployment.error, errorCode: deployment.errorCode, errorParams: deployment.errorParams, number: deployment.number, created, requestedSlug, slugAdjusted }
588
615
  );
589
616
  process.exitCode = deploymentExit(deployment);
590
617
  });
591
- program.command("access").description("Set or change who can open a site: a password (with an expiry), or back to public").argument("<slug>").option("--password <password>", "set or change the password (makes the site unlisted; env MIRRORBOOK_SITE_PASSWORD avoids shell history)").option("--expires <when>", "password validity: 7d, 12h, a date like 2026-12-31, or never. After it, the site can't be opened until you set a new one").option("--remove-password", "remove the password (the site stays unlisted)").option("--public", "make the site public again (also removes the password)").action(async (slug, o) => {
618
+ program.command("access").description("Set or change who can open a site: a password (with an expiry), the password page copy, or back to public").argument("<slug>").option("--password <password>", "set or change the password (makes the site unlisted; env MIRRORBOOK_SITE_PASSWORD avoids shell history)").option("--expires <when>", "password validity: 7d, 12h, a date like 2026-12-31, or never. After it, the site can't be opened until you set a new one").option("--remove-password", "remove the password (the site stays unlisted)").option("--public", "make the site public again (also removes the password)").option("--lock-title <text>", `title shown on the password page (max ${LOCK_TITLE_MAX} chars)`).option("--lock-message <text>", `message shown above the password box, e.g. how to get the password (max ${LOCK_MESSAGE_MAX} chars)`).option("--clear-lock", "restore the default password page copy").action(async (slug, o) => {
592
619
  const api = await client();
593
620
  const site = await applyAccess(api, slug, o);
594
- if (!site) throw new CliError("usage", "Nothing to change. Pass --password, --expires, --remove-password, or --public", EXIT.usage);
595
- out(`${site.slug}: ${accessLine(site)}`, { slug: site.slug, visibility: site.visibility, passwordProtected: site.passwordProtected, passwordExpiresAt: site.passwordExpiresAt });
621
+ if (!site) throw new CliError("usage", "Nothing to change. Pass --password, --expires, --remove-password, --public, --lock-title, --lock-message, or --clear-lock", EXIT.usage);
622
+ out(
623
+ [`${site.slug}: ${accessLine(site)}`, ...lockLines(site)].join("\n"),
624
+ { slug: site.slug, visibility: site.visibility, passwordProtected: site.passwordProtected, passwordExpiresAt: site.passwordExpiresAt, lockTitle: site.lockTitle, lockMessage: site.lockMessage }
625
+ );
596
626
  });
597
627
  program.command("ls").description("List your sites").action(async () => {
598
628
  const { sites } = await (await client()).sites();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mirrorbook",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Publish HTML to a shareable URL. Agent-friendly: non-interactive, --json output, stable exit codes.",
5
5
  "type": "module",
6
6
  "bin": {