@mediamonks/canopy-cli 0.7.55 → 0.7.57

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 (66) hide show
  1. package/dist/{ai-BlqO9NhM.mjs → ai-00f2Mgqh.mjs} +2 -2
  2. package/dist/{api-D4KUT6Ly.mjs → api-fmc8CEMT.mjs} +5 -1
  3. package/dist/{audience-Dlrsdthb.mjs → audience-ByM1jUH3.mjs} +3 -3
  4. package/dist/{browse-CW3CnhK_.mjs → browse-CxwKuka0.mjs} +2 -2
  5. package/dist/{calls-DFtWVJfv.mjs → calls-DsbRjCcy.mjs} +3 -3
  6. package/dist/{db-Dy1csI71.mjs → db-BU-ni9fj.mjs} +4 -4
  7. package/dist/{deploy-DHjZj2Pq.mjs → deploy-7tgGJZUK.mjs} +17 -6
  8. package/dist/dev-BtacZ4HE.mjs +2 -0
  9. package/dist/{dev-BvzqZU_F.mjs → dev-qp1VRNM_.mjs} +9 -9
  10. package/dist/{dev-worker-BdVcP-SM.mjs → dev-worker-7tqL9UFi.mjs} +1 -1
  11. package/dist/docs/cli-download.md +1 -1
  12. package/dist/docs/cli-members.md +7 -0
  13. package/dist/docs/cli-promote.md +2 -0
  14. package/dist/docs/cli-rollback.md +3 -1
  15. package/dist/docs/cli-staging.md +2 -0
  16. package/dist/docs/cli-versions.md +79 -0
  17. package/dist/docs/cli.md +2 -0
  18. package/dist/docs/index.json +6 -1
  19. package/dist/docs/outside-sign-in.md +16 -5
  20. package/dist/docs/platform-deploys-and-rollbacks.md +37 -5
  21. package/dist/docs/platform-members-and-access.md +8 -0
  22. package/dist/{docs-DdSbSiCj.mjs → docs-hcHwEc6n.mjs} +4 -4
  23. package/dist/{egress-hKpsJF84.mjs → egress-Bzn2VKDe.mjs} +3 -3
  24. package/dist/{feedback-Bzu_KQtb.mjs → feedback-COujxFBV.mjs} +4 -4
  25. package/dist/{files-DKtyMjY0.mjs → files-CBbAtHIK.mjs} +3 -3
  26. package/dist/index.mjs +39 -38
  27. package/dist/{local-B1N4TpE9.mjs → local-C1i2uhAf.mjs} +3 -3
  28. package/dist/login-Baso-JE0.mjs +355 -0
  29. package/dist/{logs-ByDPHO28.mjs → logs-c76jVOhb.mjs} +3 -3
  30. package/dist/{mcp-DmWfG-NS.mjs → mcp-aWskwkXw.mjs} +3 -3
  31. package/dist/{migrations-k5pyUUR0.mjs → migrations-ChafLorm.mjs} +2 -2
  32. package/dist/{open-CYfkeTaw.mjs → open-Doat726T.mjs} +2 -2
  33. package/dist/{package-B_o_DJ8u.mjs → package-BpOFa8Qi.mjs} +1 -1
  34. package/dist/project-template--mESzwea.mjs +2 -0
  35. package/dist/{project-template-B297eCQ0.mjs → project-template-BnX47DpF.mjs} +3 -3
  36. package/dist/{projects-BBm9nQb0.mjs → projects-DOqpkUVT.mjs} +29 -10
  37. package/dist/{rename-BZ8hvUUt.mjs → rename-RA_oYbRT.mjs} +3 -3
  38. package/dist/{repo-BUIM4d_1.mjs → repo-DD3eK1P_.mjs} +3 -3
  39. package/dist/repo-DayXVvyj.mjs +2 -0
  40. package/dist/{roles-Yn8U3cr-.mjs → roles-BS8-Gvv-.mjs} +63 -10
  41. package/dist/roles-tqf4sYDM.mjs +2 -0
  42. package/dist/{schedule-Cv26MIfS.mjs → schedule-D8AQ8MVF.mjs} +3 -3
  43. package/dist/{secrets-C6tF7BI9.mjs → secrets-Bi7BYCla.mjs} +3 -3
  44. package/dist/{site-C0nf9RXY.mjs → site-BcZ0LOvm.mjs} +2 -1
  45. package/dist/skill/canopy/SKILL.md +5 -0
  46. package/dist/{skill-DAlJwr4A.mjs → skill-984KseKb.mjs} +2 -2
  47. package/dist/{src-B0WdnVz9.mjs → src-DpjA-a59.mjs} +23 -22
  48. package/dist/{staging-C9mn0EBS.mjs → staging-BxG3Cffd.mjs} +3 -3
  49. package/dist/{token-DIJtUPrE.mjs → token-bHdy_IoX.mjs} +3 -3
  50. package/dist/{ui-BPq6-hKS.mjs → ui-9f_lF2Ak.mjs} +1 -1
  51. package/dist/{upgrade-DN0JQ7gm.mjs → upgrade-DhK_PlAN.mjs} +2 -2
  52. package/dist/{usage-DBhL6SUo.mjs → usage-DFs2TERV.mjs} +3 -3
  53. package/dist/versions-Cgw7sB3h.mjs +106 -0
  54. package/package.json +4 -4
  55. package/dist/dev-wHv8RrDn.mjs +0 -2
  56. package/dist/login-cbwynFoT.mjs +0 -355
  57. package/dist/project-template-B6YpesjZ.mjs +0 -2
  58. package/dist/repo-fDD4TcJ4.mjs +0 -2
  59. package/dist/roles-DvywfJ8x.mjs +0 -2
  60. package/dist/templates/worker/.github/workflows/canopy-deploy.yml +0 -40
  61. package/dist/templates/worker/index.html +0 -12
  62. package/dist/templates/worker/src/app.tsx +0 -25
  63. package/dist/templates/worker/src/canopy.ts +0 -5
  64. package/dist/templates/worker/src/main.tsx +0 -10
  65. package/dist/templates/worker/src/style.css +0 -29
  66. package/dist/templates/worker/vite.config.ts +0 -7
@@ -1,16 +1,15 @@
1
- import { d as projectUrl, h as tryReadCanopyJson, r as siteConfig } from "./site-C0nf9RXY.mjs";
2
- import { a as apiRequest, m as withContext } from "./api-D4KUT6Ly.mjs";
3
- import { a as requireTty, i as reportErrors, o as spinner$1, s as unwrap, t as confirmTypedSlug } from "./ui-BPq6-hKS.mjs";
4
- import { i as nextSteps, n as describeCopy, r as fetchTemplate, t as TEMPLATE_FIXES } from "./project-template-B297eCQ0.mjs";
5
- import { a as offerRepoOnCreate, i as githubOrigin, n as cloneProjectRepo } from "./repo-BUIM4d_1.mjs";
1
+ import { d as projectUrl, h as tryReadCanopyJson, r as siteConfig } from "./site-BcZ0LOvm.mjs";
2
+ import { d as HOST_LABEL_SEPARATOR } from "./src-DpjA-a59.mjs";
3
+ import { a as apiRequest, m as withContext } from "./api-fmc8CEMT.mjs";
4
+ import { a as requireTty, i as reportErrors, o as spinner$1, s as unwrap, t as confirmTypedSlug } from "./ui-9f_lF2Ak.mjs";
5
+ import { i as nextSteps, n as describeCopy, r as fetchTemplate, t as TEMPLATE_FIXES } from "./project-template-BnX47DpF.mjs";
6
+ import { a as offerRepoOnCreate, i as githubOrigin, n as cloneProjectRepo } from "./repo-DD3eK1P_.mjs";
6
7
  import { defineCommand } from "citty";
7
8
  import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
8
9
  import { join, relative, resolve, sep } from "node:path";
9
10
  import * as p from "@clack/prompts";
10
11
  import { fileURLToPath } from "node:url";
11
12
  const SLUG_RE = new RegExp(`^[a-z](?:[a-z0-9-]{0,38}[a-z0-9])?$`);
12
- /** The gateway's host-label separator (`v12-dot-<slug>` preview hosts) — never in a slug. */
13
- const HOST_LABEL_SEPARATOR = "-dot-";
14
13
  /** Hostnames the gateway owns or that would confuse humans — never project slugs. */
15
14
  const RESERVED_SLUGS = /* @__PURE__ */ new Set([
16
15
  "admin",
@@ -29,7 +28,7 @@ const RESERVED_SLUGS = /* @__PURE__ */ new Set([
29
28
  /** Why the API would refuse `slug`, as a prompt message, or undefined when it is fine. */
30
29
  function slugRuleProblem(slug) {
31
30
  if (!SLUG_RE.test(slug)) return "Up to 40 characters: lowercase letters, digits and dashes, starting with a letter and not ending in a dash.";
32
- if (slug.includes("-dot-")) return `"-dot-" is reserved for preview hostnames.`;
31
+ if (slug.includes("-dot-")) return `"${HOST_LABEL_SEPARATOR}" is reserved for preview hostnames.`;
33
32
  if (RESERVED_SLUGS.has(slug)) return `"${slug}" is reserved for the platform.`;
34
33
  }
35
34
  /** Prefix for a name that starts with a digit: "2026 plan" → "p-2026-plan". */
@@ -66,6 +65,10 @@ function slugify(input) {
66
65
  * Scaffolding copies a template recursively, substitutes {{name}}/{{slug}}
67
66
  * and the site's {{url}}/{{dashboardUrl}}, and renames _gitignore → .gitignore (npm strips .gitignore files from
68
67
  * published tarballs, so templates can't ship one under its real name).
68
+ *
69
+ * A template with a `base` is an overlay: its directory holds only the files
70
+ * that differ, written over a copy of the base template (worker = spa plus
71
+ * its backend, its own package.json, README, …).
69
72
  */
70
73
  /** Template vars for a project on the resolved profile's site. */
71
74
  function siteTemplateVars(name, slug) {
@@ -92,7 +95,8 @@ const TEMPLATES = [
92
95
  id: "worker",
93
96
  label: "React SPA + backend worker",
94
97
  hint: "spa plus server-side handlers in worker/ — for secrets, schedules, external APIs",
95
- needsInstall: true
98
+ needsInstall: true,
99
+ base: "spa"
96
100
  }
97
101
  ];
98
102
  function templatesRoot() {
@@ -100,9 +104,24 @@ function templatesRoot() {
100
104
  for (const candidate of [join(base, "templates"), join(base, "..", "..", "templates")]) if (existsSync(join(candidate, "static"))) return candidate;
101
105
  throw new Error("Template files not found — the CLI build is incomplete (missing templates/).");
102
106
  }
107
+ /** Template directories to copy, base first, for a template id. */
108
+ function templateLayers(templateId) {
109
+ const layers = [];
110
+ for (let id = templateId; id;) {
111
+ const template = TEMPLATES.find((t) => t.id === id);
112
+ if (!template) throw new Error(`Unknown template "${id}".`);
113
+ if (layers.includes(id)) throw new Error(`Template "${id}" is its own base.`);
114
+ layers.unshift(id);
115
+ id = template.base;
116
+ }
117
+ return layers;
118
+ }
103
119
  function scaffoldTemplate(templateId, targetDir, vars) {
104
- const source = join(templatesRoot(), templateId);
120
+ const root = templatesRoot();
105
121
  mkdirSync(targetDir, { recursive: true });
122
+ for (const layer of templateLayers(templateId)) copyTemplateDir(join(root, layer), targetDir, vars);
123
+ }
124
+ function copyTemplateDir(source, targetDir, vars) {
106
125
  for (const entry of readdirSync(source, {
107
126
  recursive: true,
108
127
  withFileTypes: true
@@ -1,6 +1,6 @@
1
- import { d as projectUrl, f as resolveProject, l as projectDirArgs, p as rewriteCanopyJsonSlug } from "./site-C0nf9RXY.mjs";
2
- import { a as apiRequest, m as withContext } from "./api-D4KUT6Ly.mjs";
3
- import { a as requireTty, i as reportErrors, s as unwrap } from "./ui-BPq6-hKS.mjs";
1
+ import { d as projectUrl, f as resolveProject, l as projectDirArgs, p as rewriteCanopyJsonSlug } from "./site-BcZ0LOvm.mjs";
2
+ import { a as apiRequest, m as withContext } from "./api-fmc8CEMT.mjs";
3
+ import { a as requireTty, i as reportErrors, s as unwrap } from "./ui-9f_lF2Ak.mjs";
4
4
  import { defineCommand } from "citty";
5
5
  import * as p from "@clack/prompts";
6
6
  //#region src/rename.ts
@@ -1,6 +1,6 @@
1
- import { a as parseGithubRemote, f as resolveProject, h as tryReadCanopyJson, l as projectDirArgs, o as parseRepositoryArg, r as siteConfig, u as projectFlagArgs } from "./site-C0nf9RXY.mjs";
2
- import { a as apiRequest, f as noticeRenamesOnly, m as withContext, n as agentHeaders, u as followRename } from "./api-D4KUT6Ly.mjs";
3
- import { i as reportErrors, n as formatDateTime, s as unwrap, t as confirmTypedSlug } from "./ui-BPq6-hKS.mjs";
1
+ import { a as parseGithubRemote, f as resolveProject, h as tryReadCanopyJson, l as projectDirArgs, o as parseRepositoryArg, r as siteConfig, u as projectFlagArgs } from "./site-BcZ0LOvm.mjs";
2
+ import { a as apiRequest, f as noticeRenamesOnly, m as withContext, n as agentHeaders, u as followRename } from "./api-fmc8CEMT.mjs";
3
+ import { i as reportErrors, n as formatDateTime, s as unwrap, t as confirmTypedSlug } from "./ui-9f_lF2Ak.mjs";
4
4
  import { a as parseCredentialInput, i as helperCommand, o as runCredentialHelper, r as fileTokenCache, t as RepoCredentialError } from "./repo-credential-CNDRM-tG.mjs";
5
5
  import { defineCommand } from "citty";
6
6
  import { existsSync, realpathSync } from "node:fs";
@@ -0,0 +1,2 @@
1
+ import { o as repoCommand } from "./repo-DD3eK1P_.mjs";
2
+ export { repoCommand };
@@ -1,6 +1,6 @@
1
- import { f as resolveProject, l as projectDirArgs } from "./site-C0nf9RXY.mjs";
2
- import { a as apiRequest, m as withContext } from "./api-D4KUT6Ly.mjs";
3
- import { a as requireTty, i as reportErrors, s as unwrap } from "./ui-BPq6-hKS.mjs";
1
+ import { d as projectUrl, f as resolveProject, l as projectDirArgs } from "./site-BcZ0LOvm.mjs";
2
+ import { a as apiRequest, m as withContext } from "./api-fmc8CEMT.mjs";
3
+ import { a as requireTty, i as reportErrors, s as unwrap } from "./ui-9f_lF2Ak.mjs";
4
4
  import { defineCommand } from "citty";
5
5
  import * as p from "@clack/prompts";
6
6
  //#region src/roles.ts
@@ -14,6 +14,47 @@ import * as p from "@clack/prompts";
14
14
  * and, when it is members-only, who may open it. App roles are the project's
15
15
  * own labels, delivered to the app as `roles` and never enforced by Canopy.
16
16
  */
17
+ /**
18
+ * The access message an inviter passes on to someone outside Monks
19
+ * (outside-invite-opt-in): the dashboard's invite dialog shows the same text.
20
+ * Worded to nobody in particular, so it can be pasted on unchanged.
21
+ */
22
+ function accessMessage(input) {
23
+ return [
24
+ `${input.projectName} is shared with ${input.email} on Canopy.`,
25
+ "",
26
+ `1. Open ${input.url}`,
27
+ "2. Choose \"Not at Monks? Sign in with email\"",
28
+ `3. Enter ${input.email}`,
29
+ "4. Open the sign-in link from the email that arrives, or type its 6-digit code on the page"
30
+ ].join("\n");
31
+ }
32
+ /**
33
+ * What `members add` prints. An outsider gets the access message to pass on
34
+ * and what happened to the invitation email; a Monk the one-line summary.
35
+ */
36
+ function formatAdded(res, input) {
37
+ const entry = res.member ?? res.invite;
38
+ const role = entry?.role ?? "editor";
39
+ const roles = input.appRoles?.length ? ` with ${input.appRoles.join(", ")}` : "";
40
+ if (entry?.outside) {
41
+ const email = entry.email;
42
+ const head = res.member ? `Added ${email} as ${role}${roles}.` : `Invited ${email} as ${role}${roles}.`;
43
+ const mail = res.invitationSent === true ? "Invitation emailed." : res.invitationSent === false ? "The invitation email didn't go out; send it from the dashboard's Members card." : "No email was sent; share the message above, or pass --send-invitation.";
44
+ return [
45
+ head,
46
+ "",
47
+ accessMessage({
48
+ projectName: input.projectName,
49
+ url: input.url,
50
+ email
51
+ }),
52
+ "",
53
+ mail
54
+ ].join("\n");
55
+ }
56
+ return res.invite ? `Invited ${input.email} as ${role}${roles} — it takes effect when they first sign in. Canopy sends no email, so let them know.` : `Added ${input.email} as ${role}${roles}.`;
57
+ }
17
58
  const ROLE_FIXES = {
18
59
  not_found: "The project or role doesn't exist, or you can't manage this project — only its owner and editors can.",
19
60
  invalid_role_slug: "Slugs are 1–32 lowercase letters, digits and dashes, starting with a letter. Pass one with --slug.",
@@ -215,6 +256,8 @@ const MEMBER_FIXES = {
215
256
  already_member: "They're already on the project — change them with `canopy members set`.",
216
257
  already_invited: "They already have a pending invite — change it with `canopy members set`.",
217
258
  email_domain_not_allowed: "Only colleagues who can sign in to Canopy can be added.",
259
+ outside_member_viewer_only: "People outside Monks can only be viewers — leave out the role flag, or pass --viewer.",
260
+ outside_member_not_allowed: "People outside Monks can't be added to the dashboard project.",
218
261
  cannot_change_owner: "The owner's role is fixed.",
219
262
  cannot_remove_owner: "The owner can't be removed — delete the project instead."
220
263
  };
@@ -262,9 +305,13 @@ const membersCommand = defineCommand({
262
305
  args: {
263
306
  email: {
264
307
  type: "positional",
265
- description: "Their company email",
308
+ description: "Their email; someone outside Monks joins as a viewer",
266
309
  required: true
267
310
  },
311
+ "send-invitation": {
312
+ type: "boolean",
313
+ description: "Someone outside Monks: also email them the invitation (off by default)"
314
+ },
268
315
  viewer: {
269
316
  type: "boolean",
270
317
  description: "May open the app, not manage the project"
@@ -282,18 +329,24 @@ const membersCommand = defineCommand({
282
329
  },
283
330
  run: reportErrors("members add", async ({ args }) => {
284
331
  const { slug } = resolveProject(args);
285
- const role = canopyRoleFlag(args) ?? "editor";
332
+ const role = canopyRoleFlag(args);
286
333
  const appRoles = appRolesOf(args);
287
334
  const res = await withContext(apiRequest("POST", `/projects/${slug}/members`, {
288
335
  email: args.email,
289
- role,
290
- ...appRoles && { app_roles: appRoles }
336
+ ...role && { role },
337
+ ...appRoles && { app_roles: appRoles },
338
+ ...args["send-invitation"] && { sendInvitation: true }
291
339
  }), {
292
340
  action: `add ${args.email} to ${slug}`,
293
341
  fixes: MEMBER_FIXES
294
342
  });
295
- const roles = appRoles?.length ? ` with ${appRoles.join(", ")}` : "";
296
- console.log(res.invite ? `Invited ${args.email} as ${role}${roles} — it takes effect when they first sign in. Canopy sends no email, so let them know.` : `Added ${args.email} as ${role}${roles}.`);
343
+ const projectName = (res.member ?? res.invite)?.outside === true ? await apiRequest("GET", `/projects/${slug}`).then((r) => r.project.name || slug).catch(() => slug) : slug;
344
+ console.log(formatAdded(res, {
345
+ email: args.email,
346
+ appRoles,
347
+ projectName,
348
+ url: projectUrl(slug)
349
+ }));
297
350
  })
298
351
  }),
299
352
  set: defineCommand({
@@ -434,4 +487,4 @@ const membersCommand = defineCommand({
434
487
  }
435
488
  });
436
489
  //#endregion
437
- export { parseAppRoleFlag as a, membersCommand as i, formatRoles as n, rolesCommand as o, formatRoster as r, canopyRoleFlag as t };
490
+ export { formatRoster as a, rolesCommand as c, formatRoles as i, canopyRoleFlag as n, membersCommand as o, formatAdded as r, parseAppRoleFlag as s, accessMessage as t };
@@ -0,0 +1,2 @@
1
+ import { c as rolesCommand, o as membersCommand } from "./roles-BS8-Gvv-.mjs";
2
+ export { membersCommand, rolesCommand };
@@ -1,6 +1,6 @@
1
- import { f as resolveProject, u as projectFlagArgs } from "./site-C0nf9RXY.mjs";
2
- import { a as apiRequest, m as withContext } from "./api-D4KUT6Ly.mjs";
3
- import { i as reportErrors, n as formatDateTime } from "./ui-BPq6-hKS.mjs";
1
+ import { f as resolveProject, u as projectFlagArgs } from "./site-BcZ0LOvm.mjs";
2
+ import { a as apiRequest, m as withContext } from "./api-fmc8CEMT.mjs";
3
+ import { i as reportErrors, n as formatDateTime } from "./ui-9f_lF2Ak.mjs";
4
4
  import { defineCommand } from "citty";
5
5
  //#region src/schedule.ts
6
6
  /**
@@ -1,6 +1,6 @@
1
- import { f as resolveProject, l as projectDirArgs } from "./site-C0nf9RXY.mjs";
2
- import { a as apiRequest, m as withContext } from "./api-D4KUT6Ly.mjs";
3
- import { i as reportErrors, n as formatDateTime, s as unwrap } from "./ui-BPq6-hKS.mjs";
1
+ import { f as resolveProject, l as projectDirArgs } from "./site-BcZ0LOvm.mjs";
2
+ import { a as apiRequest, m as withContext } from "./api-fmc8CEMT.mjs";
3
+ import { i as reportErrors, n as formatDateTime, s as unwrap } from "./ui-9f_lF2Ak.mjs";
4
4
  import { defineCommand } from "citty";
5
5
  import * as p from "@clack/prompts";
6
6
  //#region src/secrets.ts
@@ -1,3 +1,4 @@
1
+ import { f as STAGING_LABEL_PREFIX } from "./src-DpjA-a59.mjs";
1
2
  import { chmodSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
3
  import { homedir } from "node:os";
3
4
  import { join, resolve } from "node:path";
@@ -178,7 +179,7 @@ function projectUrl(slug) {
178
179
  /** The staging channel's URL (docs/14): the first label becomes `staging-dot-<slug>`. */
179
180
  function stagingUrl(slug) {
180
181
  const url = new URL(projectUrl(slug));
181
- url.hostname = `staging-dot-${url.hostname}`;
182
+ url.hostname = `${STAGING_LABEL_PREFIX}${url.hostname}`;
182
183
  return url.origin;
183
184
  }
184
185
  /** canopy.json parsed if present; undefined when the file is missing. */
@@ -96,6 +96,7 @@ and never go stale.
96
96
  - Test first on staging: `canopy deploy --staging` → verify → `canopy promote`
97
97
  (own database cloned from live; `canopy staging status | sync | destroy`)
98
98
  - Roll back: `canopy rollback`
99
+ - Old versions: `canopy versions` (retention keeps the 20 newest plus live and staging)
99
100
  - Open the live site: `canopy open`
100
101
  - **Look at a deployed project in your own browser** (Playwright, a browser
101
102
  tool, curl): `canopy browse <slug> --json` prints a one-time sign-in link
@@ -220,6 +221,10 @@ Non-interactive: `canopy create "My App" --template spa`. **When unsure between
220
221
  restores.
221
222
  - **Deploys are public.** `canopy deploy` makes a version live. Confirm before
222
223
  deploying unless the user clearly asked you to.
224
+ - **Version retention deletes old versions.** When a deploy prints a retention
225
+ hint, pass it on to the user and ask before running
226
+ `canopy versions retention on`: expired versions can no longer be rolled
227
+ back to, pinned or downloaded.
223
228
  - Keep the CLI current: `canopy upgrade` (this also refreshes this skill).
224
229
  - **A `canopy` command itself failing?** First rule out user error (re-read
225
230
  `canopy docs troubleshooting` and the command's `--help`). If the platform
@@ -1,5 +1,5 @@
1
- import { t as version } from "./package-B_o_DJ8u.mjs";
2
- import { i as reportErrors } from "./ui-BPq6-hKS.mjs";
1
+ import { t as version } from "./package-BpOFa8Qi.mjs";
2
+ import { i as reportErrors } from "./ui-9f_lF2Ak.mjs";
3
3
  import { defineCommand } from "citty";
4
4
  import { cpSync, existsSync, mkdirSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
5
5
  import { homedir } from "node:os";
@@ -347,6 +347,12 @@ function blobRouter(config) {
347
347
  return blob;
348
348
  }
349
349
  //#endregion
350
+ //#region ../data-plane/src/host-label.ts
351
+ /** Separates the prefix from the slug. Rejected inside real slugs for that reason. */
352
+ const HOST_LABEL_SEPARATOR = "-dot-";
353
+ /** A staging-channel label starts with this (also the channel qualifier on signed blob scopes). */
354
+ const STAGING_LABEL_PREFIX = `staging${HOST_LABEL_SEPARATOR}`;
355
+ //#endregion
350
356
  //#region ../data-plane/src/dialect.ts
351
357
  /** Platform-managed fields map to real columns instead of JSON extraction. */
352
358
  const META_COLUMNS = {
@@ -1178,12 +1184,11 @@ const monkHeaders = {
1178
1184
  /**
1179
1185
  * How a project's backend addresses the platform — the one definition.
1180
1186
  *
1181
- * Three hosts run project workers and each builds this request itself: the
1182
- * Workers-for-Platforms shim (packages/data-plane/src/worker-shim.ts), the Node
1183
- * runtime (apps/project-runtime/src/canopy-fetch.ts), and `canopy dev`
1184
- * (packages/cli/src/dev-worker.ts). They had three copies of the header
1185
- * shaping, and the two that hold a worker token had two copies of the
1186
- * credential rule — which is exactly how the Google project grant came to
1187
+ * Two hosts run project workers and each builds this request itself: the
1188
+ * platform shim (packages/data-plane/src/worker-shim.ts), which both
1189
+ * Cloudflare and the Google Cloud runtime run, and `canopy dev`
1190
+ * (packages/cli/src/dev-worker.ts). Separate copies of the header shaping and
1191
+ * the credential rule are exactly how the Google project grant once came to
1187
1192
  * work on one target and not the other.
1188
1193
  *
1189
1194
  * The shim cannot import this: it ships as a standalone module uploaded
@@ -1307,8 +1312,8 @@ const IDENTITY_STAMP_HEADERS = [
1307
1312
  ];
1308
1313
 
1309
1314
  // App roles (project-roles) — transcribed from rolesFromHeaders in
1310
- // project-runtime/src/user.ts: undefined without the header (an older
1311
- // gateway), so the property stays absent rather than [].
1315
+ // caller-headers.ts: undefined without the header (an older gateway), so the
1316
+ // property stays absent rather than [].
1312
1317
  function rolesFromHeaders(headers) {
1313
1318
  const raw = headers.get("x-canopy-identity-roles");
1314
1319
  if (raw === null) return undefined;
@@ -1330,11 +1335,10 @@ function userFromHeaders(headers) {
1330
1335
  };
1331
1336
  }
1332
1337
 
1333
- // env.CALLER (worker-caller-identity) — transcribed from
1334
- // project-runtime/src/user.ts: everyone the wall let through, client-password
1335
- // visitors included, from headers older shims never read.
1336
- // A call from another project (project-calls) — transcribed from
1337
- // projectCallerFromHeaders in project-runtime/src/user.ts.
1338
+ // env.CALLER (worker-caller-identity) — transcribed from readCaller in
1339
+ // caller-headers.ts: everyone the wall let through, client-password visitors
1340
+ // included, from headers older shims never read.
1341
+ // A call from another project (project-calls) — readProjectCaller there.
1338
1342
  function projectCallerFromHeaders(headers, id) {
1339
1343
  const project = (headers.get("x-canopy-identity-project") || "").trim();
1340
1344
  const channel = (headers.get("x-canopy-identity-channel") || "").trim();
@@ -1368,8 +1372,8 @@ function projectCallerFromHeaders(headers, id) {
1368
1372
  };
1369
1373
  }
1370
1374
 
1371
- // env.CALLER.token (project-access-tokens) — transcribed from
1372
- // tokenFromHeaders in project-runtime/src/user.ts: the gateway's base64url
1375
+ // env.CALLER.token (project-access-tokens) — transcribed from readToken in
1376
+ // caller-headers.ts: the gateway's base64url
1373
1377
  // JSON description of the access token a call came with, or null.
1374
1378
  function stringList(value) {
1375
1379
  return Array.isArray(value) ? value.filter((v) => typeof v === "string") : [];
@@ -1769,15 +1773,13 @@ async function handleBlobChannel(request, bucket) {
1769
1773
  // on the egress allowlist, and even allowed it would hit the auth wall with
1770
1774
  // no session. Identity rides AsyncLocalStorage per inbound request (never a
1771
1775
  // closure — the userland patch this replaces bled users across concurrent
1772
- // requests). Transcribed from project-runtime/src/self-fetch.ts, which this
1773
- // module cannot import (it ships standalone beside the bundle);
1774
- // wfp-shim.test.ts and project-runtime's self-fetch.test.ts run matching
1775
- // cases so the two can't drift silently.
1776
+ // requests). This is the one implementation, on both targets
1777
+ // (gcp-runtime-boundary); wfp-shim.test.ts holds its cases.
1776
1778
 
1777
1779
  const SELF_FETCH_DEPTH_HEADER = "x-canopy-self-fetch-depth";
1778
1780
  const SELF_FETCH_MAX_DEPTH = 8;
1779
1781
  // Everything that says who is calling (CALLER_IDENTITY_HEADERS in
1780
- // project-runtime/src/user.ts): the user and caller stamps plus the agent mark.
1782
+ // caller-headers.ts): the user and caller stamps plus the agent mark.
1781
1783
  const IDENTITY_HEADERS = [...IDENTITY_STAMP_HEADERS, "x-canopy-caller"];
1782
1784
 
1783
1785
  const selfFetchContext = new AsyncLocalStorage();
@@ -1972,7 +1974,6 @@ export default {
1972
1974
 
1973
1975
  // Slack traffic for the project's own app (docs/33 §6), delivered by
1974
1976
  // canopy-api through the dispatch binding after signature verification.
1975
- // Kept in lockstep with the twin branch in project-runtime/src/loader.ts.
1976
1977
  // Platform database channel (docs/43 §5.5): canopy-data runs the project's
1977
1978
  // SDK statements through THIS script's own D1 binding instead of the REST
1978
1979
  // API — a dispatch hop plus a binding call, not an HTTPS round trip to
@@ -2153,4 +2154,4 @@ export default {
2153
2154
  };
2154
2155
  `;
2155
2156
  //#endregion
2156
- export { readPersonCaller as a, dbRouter as c, STREAMED_BLOB_BYTES as d, blobRouter as f, CALLER_HEADER as i, hasPrivateNames as l, redactCanopyCredentials as n, readUser as o, isCreateOnly as p, stampWorkerHeaders as r, realtimeRouter as s, WORKER_ATTEST_HEADER as t, META_COLUMNS as u };
2157
+ export { readPersonCaller as a, dbRouter as c, HOST_LABEL_SEPARATOR as d, STAGING_LABEL_PREFIX as f, isCreateOnly as h, CALLER_HEADER as i, hasPrivateNames as l, blobRouter as m, redactCanopyCredentials as n, readUser as o, STREAMED_BLOB_BYTES as p, stampWorkerHeaders as r, realtimeRouter as s, WORKER_ATTEST_HEADER as t, META_COLUMNS as u };
@@ -1,6 +1,6 @@
1
- import { d as projectUrl, f as resolveProject, m as stagingUrl, s as parseVersionArg, u as projectFlagArgs } from "./site-C0nf9RXY.mjs";
2
- import { a as apiRequest, m as withContext } from "./api-D4KUT6Ly.mjs";
3
- import { a as requireTty, i as reportErrors, n as formatDateTime, o as spinner$1, s as unwrap, t as confirmTypedSlug } from "./ui-BPq6-hKS.mjs";
1
+ import { d as projectUrl, f as resolveProject, m as stagingUrl, s as parseVersionArg, u as projectFlagArgs } from "./site-BcZ0LOvm.mjs";
2
+ import { a as apiRequest, m as withContext } from "./api-fmc8CEMT.mjs";
3
+ import { a as requireTty, i as reportErrors, n as formatDateTime, o as spinner$1, s as unwrap, t as confirmTypedSlug } from "./ui-9f_lF2Ak.mjs";
4
4
  import { defineCommand } from "citty";
5
5
  import * as p from "@clack/prompts";
6
6
  //#region src/staging.ts
@@ -1,6 +1,6 @@
1
- import { f as resolveProject, l as projectDirArgs, u as projectFlagArgs } from "./site-C0nf9RXY.mjs";
2
- import { a as apiRequest } from "./api-D4KUT6Ly.mjs";
3
- import { i as reportErrors, n as formatDateTime } from "./ui-BPq6-hKS.mjs";
1
+ import { f as resolveProject, l as projectDirArgs, u as projectFlagArgs } from "./site-BcZ0LOvm.mjs";
2
+ import { a as apiRequest } from "./api-fmc8CEMT.mjs";
3
+ import { i as reportErrors, n as formatDateTime } from "./ui-9f_lF2Ak.mjs";
4
4
  import { defineCommand } from "citty";
5
5
  const tokenCommand = defineCommand({
6
6
  meta: {
@@ -1,4 +1,4 @@
1
- import { t as ApiError } from "./api-D4KUT6Ly.mjs";
1
+ import { t as ApiError } from "./api-fmc8CEMT.mjs";
2
2
  import { spawn } from "node:child_process";
3
3
  import { cancel, isCancel, spinner, text } from "@clack/prompts";
4
4
  //#region src/ui.ts
@@ -1,5 +1,5 @@
1
1
  import { t as PACKAGE_NAME } from "./version-check-CcsA1QjI.mjs";
2
- import { i as reportErrors } from "./ui-BPq6-hKS.mjs";
2
+ import { i as reportErrors } from "./ui-9f_lF2Ak.mjs";
3
3
  import { defineCommand } from "citty";
4
4
  import { spawn } from "node:child_process";
5
5
  import { fileURLToPath } from "node:url";
@@ -112,7 +112,7 @@ const upgradeCommand = defineCommand({
112
112
  const spec = `${PACKAGE_NAME}@${args.version ?? "latest"}`;
113
113
  const command = pmCommand(pm);
114
114
  const cmd = installArgs(pm, spec);
115
- const { skillInstalled } = await import("./skill-DAlJwr4A.mjs");
115
+ const { skillInstalled } = await import("./skill-984KseKb.mjs");
116
116
  const { homedir } = await import("node:os");
117
117
  const refreshGlobal = skillInstalled(homedir());
118
118
  const refreshRepo = process.cwd() !== homedir() && skillInstalled(process.cwd());
@@ -1,6 +1,6 @@
1
- import { f as resolveProject, u as projectFlagArgs } from "./site-C0nf9RXY.mjs";
2
- import { a as apiRequest, m as withContext } from "./api-D4KUT6Ly.mjs";
3
- import { i as reportErrors } from "./ui-BPq6-hKS.mjs";
1
+ import { f as resolveProject, u as projectFlagArgs } from "./site-BcZ0LOvm.mjs";
2
+ import { a as apiRequest, m as withContext } from "./api-fmc8CEMT.mjs";
3
+ import { i as reportErrors } from "./ui-9f_lF2Ak.mjs";
4
4
  import { defineCommand } from "citty";
5
5
  //#region src/usage.ts
6
6
  /**
@@ -0,0 +1,106 @@
1
+ import { f as resolveProject, u as projectFlagArgs } from "./site-BcZ0LOvm.mjs";
2
+ import { a as apiRequest, m as withContext } from "./api-fmc8CEMT.mjs";
3
+ import { a as requireTty, i as reportErrors, s as unwrap } from "./ui-9f_lF2Ak.mjs";
4
+ import { defineCommand } from "citty";
5
+ import * as p from "@clack/prompts";
6
+ //#region src/versions.ts
7
+ /**
8
+ * `canopy versions` — the project's deploy versions (OpenSpec deploy-retention).
9
+ *
10
+ * (none) the retention setting and how many versions are kept / expired
11
+ * retention show or turn version retention on or off
12
+ *
13
+ * With retention on the platform keeps the 20 newest versions, the live and
14
+ * staging versions with the one below each, and everything newer than live;
15
+ * its hourly pass expires the rest (files gone, history kept).
16
+ */
17
+ const formatSize = (bytes) => bytes >= 1024 ** 3 ? `${(bytes / 1024 ** 3).toFixed(1)} GB` : bytes >= 1024 ** 2 ? `${(bytes / 1024 ** 2).toFixed(1)} MB` : `${Math.max(0, Math.round(bytes / 1024))} kB`;
18
+ const plural = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
19
+ /** "on" / "off" as a boolean, or null for anything else (case and spaces forgiven). */
20
+ function parseSwitch(raw) {
21
+ const wanted = raw.trim().toLowerCase();
22
+ return wanted === "on" ? true : wanted === "off" ? false : null;
23
+ }
24
+ /** What `canopy versions` and `canopy versions retention` print. */
25
+ function describeRetention(slug, s) {
26
+ const lines = s.enabled ? [`${slug}: version retention is on — keeps the ${s.keepRecent} most recent versions, the live and staging versions with the one below each, and everything newer than live.`] : [`${slug}: version retention is off — every version keeps its files.`];
27
+ lines.push(` ${plural(s.kept, "version")} kept (${formatSize(s.bytes)})` + (s.expired > 0 ? `, ${s.expired} expired` : ""));
28
+ if (s.enabled && s.wouldExpire.versions > 0) lines.push(` ${plural(s.wouldExpire.versions, "version")} expire within the hour.`);
29
+ if (!s.enabled && s.wouldExpire.versions > 0) lines.push(` Turning it on would expire ${plural(s.wouldExpire.versions, "version")} (${formatSize(s.wouldExpire.bytes)}): \`canopy versions retention on\`.`);
30
+ return lines;
31
+ }
32
+ let subcommandRan = false;
33
+ const retentionCommand = defineCommand({
34
+ meta: {
35
+ name: "retention",
36
+ description: "Show or turn version retention on or off (on | off)"
37
+ },
38
+ args: {
39
+ ...projectFlagArgs,
40
+ state: {
41
+ type: "positional",
42
+ description: "on | off (omit to show)",
43
+ required: false
44
+ },
45
+ yes: {
46
+ type: "boolean",
47
+ default: false,
48
+ description: "Don't ask before turning on retention that expires versions"
49
+ }
50
+ },
51
+ run: reportErrors("versions retention", async ({ args }) => {
52
+ subcommandRan = true;
53
+ const { slug } = resolveProject(args);
54
+ const path = `/projects/${slug}/deploy-retention`;
55
+ const print = (s) => {
56
+ for (const line of describeRetention(slug, s)) console.log(line);
57
+ };
58
+ if (!args.state?.trim()) {
59
+ print(await withContext(apiRequest("GET", path), { action: `read the version retention of "${slug}"` }));
60
+ return;
61
+ }
62
+ const enabled = parseSwitch(args.state);
63
+ if (enabled === null) {
64
+ console.error(`unknown state "${args.state.trim()}" — expected on or off.`);
65
+ process.exit(1);
66
+ }
67
+ const context = { action: `change the version retention of "${slug}"` };
68
+ if (enabled && !args.yes) {
69
+ const preview = await withContext(apiRequest("PUT", path, {
70
+ enabled,
71
+ dryRun: true
72
+ }), context);
73
+ if (!preview.enabled || preview.wouldExpire.versions > 0) {
74
+ const n = preview.wouldExpire.versions;
75
+ if (n > 0) {
76
+ requireTty("pass --yes to turn on retention that expires versions.");
77
+ if (!unwrap(await p.confirm({
78
+ message: `This expires ${plural(n, "version")} of "${slug}" (${formatSize(preview.wouldExpire.bytes)}) within the hour. Expired versions can no longer be rolled back to, pinned or downloaded. Continue?`,
79
+ initialValue: false
80
+ }))) {
81
+ p.cancel("Aborted.");
82
+ return;
83
+ }
84
+ }
85
+ }
86
+ }
87
+ print(await withContext(apiRequest("PUT", path, { enabled }), context));
88
+ })
89
+ });
90
+ const summaryRun = reportErrors("versions", async ({ args }) => {
91
+ const { slug } = resolveProject(args);
92
+ const settings = await withContext(apiRequest("GET", `/projects/${slug}/deploy-retention`), { action: `read the versions of "${slug}"` });
93
+ for (const line of describeRetention(slug, settings)) console.log(line);
94
+ console.log(" History: `canopy rollback` lists versions; the dashboard's Deploys tab too.");
95
+ });
96
+ const versionsCommand = defineCommand({
97
+ meta: {
98
+ name: "versions",
99
+ description: "Deploy versions: how many are kept, and version retention"
100
+ },
101
+ args: { ...projectFlagArgs },
102
+ subCommands: { retention: retentionCommand },
103
+ run: (context) => subcommandRan ? void 0 : summaryRun(context)
104
+ });
105
+ //#endregion
106
+ export { versionsCommand };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mediamonks/canopy-cli",
3
- "version": "0.7.55",
3
+ "version": "0.7.57",
4
4
  "description": "Canopy CLI — create, develop and deploy Canopy projects.",
5
5
  "bin": {
6
6
  "canopy": "./dist/index.mjs"
@@ -26,14 +26,14 @@
26
26
  "@mediamonks/canopy-data-plane": "0.0.4"
27
27
  },
28
28
  "devDependencies": {
29
- "@types/node": "^26.1.1",
30
- "ai": "^7.0.82",
29
+ "@types/node": "^24",
30
+ "ai": "7.0.84",
31
31
  "typescript": "^7.0.2",
32
32
  "vite-plus": "0.2.5",
33
33
  "@mediamonks/canopy-pages": "0.0.0"
34
34
  },
35
35
  "scripts": {
36
- "build": "pnpm --filter @mediamonks/canopy-pages run build && vp pack && node ./scripts/sync-templates.mjs",
36
+ "build": "pnpm --filter @mediamonks/canopy-pages run build && vp pack",
37
37
  "dev": "vp pack --watch",
38
38
  "test": "vp test",
39
39
  "check": "vp check"
@@ -1,2 +0,0 @@
1
- import { n as devCommand } from "./dev-BvzqZU_F.mjs";
2
- export { devCommand };