@mediamonks/canopy-cli 0.7.53 → 0.7.55

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.
@@ -2,7 +2,7 @@ import { c as projectDialect, f as resolveProject, h as tryReadCanopyJson, l as
2
2
  import { a as apiRequest, m as withContext, t as ApiError } from "./api-D4KUT6Ly.mjs";
3
3
  import { i as reportErrors, n as formatDateTime } from "./ui-BPq6-hKS.mjs";
4
4
  import { r as readMigrationFiles } from "./migrations-k5pyUUR0.mjs";
5
- import { r as stampWorkerHeaders, t as WORKER_ATTEST_HEADER } from "./src-UBUAqzqH.mjs";
5
+ import { r as stampWorkerHeaders, t as WORKER_ATTEST_HEADER } from "./src-B0WdnVz9.mjs";
6
6
  import { a as parseAppRoleFlag } from "./roles-Yn8U3cr-.mjs";
7
7
  import { n as writeDevServerRecord } from "./dev-server-file-Dk9pk4AR.mjs";
8
8
  import { createRequire } from "node:module";
@@ -107,7 +107,7 @@ async function workerPlugin(flags, slug, workerAttest, remoteUser, roles) {
107
107
  console.log(`note: canopy.json points "worker" at ${entry}, which does not exist — skipping.`);
108
108
  return;
109
109
  }
110
- const { missingSecretNames, readDevVars, workerDevPlugin } = await import("./dev-worker-DBBN0F6X.mjs");
110
+ const { missingSecretNames, readDevVars, workerDevPlugin } = await import("./dev-worker-BdVcP-SM.mjs");
111
111
  const secrets = readDevVars(flags.dir);
112
112
  const email = siteConfig().email;
113
113
  const found = await remoteUser?.() ?? (email ? {
@@ -326,7 +326,7 @@ async function devRemote(flags, slug) {
326
326
  async function devLocal(flags, slug) {
327
327
  let dump;
328
328
  if (flags.pull) {
329
- const { fetchProjectDump } = await import("./local-B15wYk6z.mjs");
329
+ const { fetchProjectDump } = await import("./local-B1N4TpE9.mjs");
330
330
  console.log(`Pulling a fresh export of ${slug}${flags.staging ? " [staging]" : ""}…`);
331
331
  dump = await fetchProjectDump(slug, flags.staging ? "staging" : "live");
332
332
  }
@@ -343,7 +343,7 @@ async function devLocal(flags, slug) {
343
343
  }
344
344
  const workerAttest = randomBytes(24).toString("base64url");
345
345
  const devRoles = await resolveDevRoles(slug, flags.asRoles);
346
- const { createSandbox } = await import("./local-B15wYk6z.mjs");
346
+ const { createSandbox } = await import("./local-B1N4TpE9.mjs");
347
347
  const sandbox = await createSandbox({
348
348
  slug,
349
349
  persistDir: join(flags.dir, ".canopy", "local"),
@@ -0,0 +1,2 @@
1
+ import { n as devCommand } from "./dev-BvzqZU_F.mjs";
2
+ export { devCommand };
@@ -1,4 +1,4 @@
1
- import { a as readPersonCaller, i as CALLER_HEADER, n as redactCanopyCredentials, o as readUser, r as stampWorkerHeaders, t as WORKER_ATTEST_HEADER } from "./src-UBUAqzqH.mjs";
1
+ import { a as readPersonCaller, i as CALLER_HEADER, n as redactCanopyCredentials, o as readUser, r as stampWorkerHeaders, t as WORKER_ATTEST_HEADER } from "./src-B0WdnVz9.mjs";
2
2
  import { readFileSync } from "node:fs";
3
3
  import { relative, resolve, sep } from "node:path";
4
4
  //#region src/dev-worker.ts
@@ -1,4 +1,4 @@
1
- import { t as version } from "./package-DtU4jB_Z.mjs";
1
+ import { t as version } from "./package-B_o_DJ8u.mjs";
2
2
  import { r as siteConfig } from "./site-C0nf9RXY.mjs";
3
3
  import { i as latestKnownVersion, r as compareSemver } from "./version-check-CcsA1QjI.mjs";
4
4
  import { n as agentHeaders } from "./api-D4KUT6Ly.mjs";
@@ -1,4 +1,4 @@
1
- import { t as version } from "./package-DtU4jB_Z.mjs";
1
+ import { t as version } from "./package-B_o_DJ8u.mjs";
2
2
  import { f as resolveProject, g as tryResolveProject, h as tryReadCanopyJson, l as projectDirArgs, r as siteConfig } from "./site-C0nf9RXY.mjs";
3
3
  import { a as apiRequest, c as credentials, i as apiDownload, o as apiUpload, s as commonHeaders } from "./api-D4KUT6Ly.mjs";
4
4
  import { i as reportErrors, n as formatDateTime } from "./ui-BPq6-hKS.mjs";
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as version } from "./package-DtU4jB_Z.mjs";
2
+ import { t as version } from "./package-B_o_DJ8u.mjs";
3
3
  import { i as siteHeaderLine, n as setInvocationProfile } from "./site-C0nf9RXY.mjs";
4
4
  import { a as notifyOfUpdate, o as runRefresh } from "./version-check-CcsA1QjI.mjs";
5
5
  import { defineCommand, runMain } from "citty";
@@ -54,12 +54,12 @@ const main = defineCommand({
54
54
  login: () => import("./login-cbwynFoT.mjs").then((m) => m.loginCommand),
55
55
  whoami: () => import("./login-cbwynFoT.mjs").then((m) => m.whoamiCommand),
56
56
  logout: () => import("./login-cbwynFoT.mjs").then((m) => m.logoutCommand),
57
- create: () => import("./projects-ztlDQi0P.mjs").then((m) => m.createCommand),
58
- init: () => import("./projects-ztlDQi0P.mjs").then((m) => m.initCommand),
59
- projects: () => import("./projects-ztlDQi0P.mjs").then((m) => m.projectsCommand),
60
- delete: () => import("./projects-ztlDQi0P.mjs").then((m) => m.deleteCommand),
57
+ create: () => import("./projects-BBm9nQb0.mjs").then((m) => m.createCommand),
58
+ init: () => import("./projects-BBm9nQb0.mjs").then((m) => m.initCommand),
59
+ projects: () => import("./projects-BBm9nQb0.mjs").then((m) => m.projectsCommand),
60
+ delete: () => import("./projects-BBm9nQb0.mjs").then((m) => m.deleteCommand),
61
61
  rename: () => import("./rename-BZ8hvUUt.mjs").then((m) => m.renameCommand),
62
- dev: () => import("./dev-CVC7elOr.mjs").then((m) => m.devCommand),
62
+ dev: () => import("./dev-wHv8RrDn.mjs").then((m) => m.devCommand),
63
63
  deploy: () => import("./deploy-DHjZj2Pq.mjs").then((m) => m.deployCommand),
64
64
  promote: () => import("./deploy-DHjZj2Pq.mjs").then((m) => m.promoteCommand),
65
65
  staging: () => import("./staging-C9mn0EBS.mjs").then((m) => m.stagingCommand),
@@ -72,18 +72,18 @@ const main = defineCommand({
72
72
  roles: () => import("./roles-DvywfJ8x.mjs").then((m) => m.rolesCommand),
73
73
  members: () => import("./roles-DvywfJ8x.mjs").then((m) => m.membersCommand),
74
74
  schedule: () => import("./schedule-Cv26MIfS.mjs").then((m) => m.scheduleCommand),
75
- feedback: () => import("./feedback-vHJwLyWF.mjs").then((m) => m.feedbackCommand),
75
+ feedback: () => import("./feedback-Bzu_KQtb.mjs").then((m) => m.feedbackCommand),
76
76
  db: () => import("./db-Dy1csI71.mjs").then((m) => m.dbCommand),
77
77
  files: () => import("./files-DKtyMjY0.mjs").then((m) => m.filesCommand),
78
78
  usage: () => import("./usage-DBhL6SUo.mjs").then((m) => m.usageCommand),
79
79
  ai: () => import("./ai-BlqO9NhM.mjs").then((m) => m.aiCommand),
80
80
  open: () => import("./open-CYfkeTaw.mjs").then((m) => m.openCommand),
81
81
  browse: () => import("./browse-CW3CnhK_.mjs").then((m) => m.browseCommand),
82
- docs: () => import("./docs-bnQLqEOn.mjs").then((m) => m.docsCommand),
83
- skill: () => import("./skill-CRTV3ZQ1.mjs").then((m) => m.skillCommand),
84
- upgrade: () => import("./upgrade-LTEfQn4L.mjs").then((m) => m.upgradeCommand),
82
+ docs: () => import("./docs-DdSbSiCj.mjs").then((m) => m.docsCommand),
83
+ skill: () => import("./skill-DAlJwr4A.mjs").then((m) => m.skillCommand),
84
+ upgrade: () => import("./upgrade-DN0JQ7gm.mjs").then((m) => m.upgradeCommand),
85
85
  logs: () => import("./logs-ByDPHO28.mjs").then((m) => m.logsCommand),
86
- mcp: () => import("./mcp-BmT4Es_B.mjs").then((m) => m.mcpCommand),
86
+ mcp: () => import("./mcp-DmWfG-NS.mjs").then((m) => m.mcpCommand),
87
87
  repo: () => import("./repo-fDD4TcJ4.mjs").then((m) => m.repoCommand),
88
88
  template: () => import("./project-template-B6YpesjZ.mjs").then((m) => m.templateCommand),
89
89
  audience: () => import("./audience-Dlrsdthb.mjs").then((m) => m.audienceCommand)
@@ -1,6 +1,6 @@
1
1
  import { r as apiDataRequest } from "./api-D4KUT6Ly.mjs";
2
- import { c as dbRouter, d as STREAMED_BLOB_BYTES, f as blobRouter, l as hasPrivateNames, p as isCreateOnly, s as realtimeRouter, t as WORKER_ATTEST_HEADER, u as META_COLUMNS } from "./src-UBUAqzqH.mjs";
3
- import { a as rewriteApiPath } from "./dev-L5slb6ke.mjs";
2
+ import { c as dbRouter, d as STREAMED_BLOB_BYTES, f as blobRouter, l as hasPrivateNames, p as isCreateOnly, s as realtimeRouter, t as WORKER_ATTEST_HEADER, u as META_COLUMNS } from "./src-B0WdnVz9.mjs";
3
+ import { a as rewriteApiPath } from "./dev-BvzqZU_F.mjs";
4
4
  import { createRequire } from "node:module";
5
5
  import { createWriteStream, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
6
6
  import { dirname, join, relative, sep } from "node:path";
@@ -1,4 +1,4 @@
1
- import { t as version } from "./package-DtU4jB_Z.mjs";
1
+ import { t as version } from "./package-B_o_DJ8u.mjs";
2
2
  import { d as projectUrl, g as tryResolveProject, m as stagingUrl, r as siteConfig } from "./site-C0nf9RXY.mjs";
3
3
  import { a as apiRequest, f as noticeRenamesOnly, l as currentSlug, t as ApiError } from "./api-D4KUT6Ly.mjs";
4
4
  import { t as liveDevServer } from "./dev-server-file-Dk9pk4AR.mjs";
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.7.53";
2
+ var version = "0.7.55";
3
3
  //#endregion
4
4
  export { version as t };
@@ -8,6 +8,54 @@ import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from
8
8
  import { join, relative, resolve, sep } from "node:path";
9
9
  import * as p from "@clack/prompts";
10
10
  import { fileURLToPath } from "node:url";
11
+ 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
+ /** Hostnames the gateway owns or that would confuse humans — never project slugs. */
15
+ const RESERVED_SLUGS = /* @__PURE__ */ new Set([
16
+ "admin",
17
+ "api",
18
+ "app",
19
+ "auth",
20
+ "canopy",
21
+ "dashboard",
22
+ "dev",
23
+ "docs",
24
+ "mail",
25
+ "staging",
26
+ "status",
27
+ "www"
28
+ ]);
29
+ /** Why the API would refuse `slug`, as a prompt message, or undefined when it is fine. */
30
+ function slugRuleProblem(slug) {
31
+ 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.`;
33
+ if (RESERVED_SLUGS.has(slug)) return `"${slug}" is reserved for the platform.`;
34
+ }
35
+ /** Prefix for a name that starts with a digit: "2026 plan" → "p-2026-plan". */
36
+ const DIGIT_PREFIX = "p-";
37
+ /** Slug for a name with nothing usable in it ("!!!", "Ωμέγα"). */
38
+ const EMPTY_FALLBACK = "project";
39
+ /** Suffix that frees a reserved name: "Admin" → "admin-project". */
40
+ const RESERVED_SUFFIX = "-project";
41
+ /**
42
+ * A project slug from a free-form name that the API always accepts:
43
+ * lowercase, runs of anything but a-z 0-9 become one dash, no "-dot-",
44
+ * at most 40 characters, never ending in a dash. A name starting with a
45
+ * digit gets a `p-` prefix (slugs start with a letter), a reserved name gets
46
+ * a `-project` suffix, and a name with nothing usable becomes `project`.
47
+ * Whether the slug is still free is the API's call.
48
+ */
49
+ function slugify(input) {
50
+ let slug = input.toLowerCase().replaceAll(/[^a-z0-9]+/g, "-").replaceAll(/(^-+|-+$)/g, "");
51
+ while (slug.includes(HOST_LABEL_SEPARATOR)) slug = slug.replaceAll(HOST_LABEL_SEPARATOR, "-");
52
+ if (/^\d/.test(slug)) slug = DIGIT_PREFIX + slug;
53
+ slug = slug.slice(0, 40).replace(/-+$/, "");
54
+ if (!slug) return EMPTY_FALLBACK;
55
+ if (RESERVED_SLUGS.has(slug)) return slug + RESERVED_SUFFIX;
56
+ return slug;
57
+ }
58
+ //#endregion
11
59
  //#region src/template.ts
12
60
  /**
13
61
  * Template registry + scaffolder for `canopy create`. Templates are real,
@@ -92,11 +140,6 @@ function projectRows(projects, isAdmin) {
92
140
  const roleWidth = Math.max(...roles.map((role) => role.length));
93
141
  return projects.map((project, i) => `${project.slug.padEnd(width)} ${project.status.padEnd(7)} ${roles[i].padEnd(roleWidth)} ${projectUrl(project.slug)} ${project.name}`);
94
142
  }
95
- function slugify(input) {
96
- let slug = input.toLowerCase().replaceAll(/[^a-z0-9]+/g, "-").replaceAll(/(^-+|-+$)/g, "").slice(0, 40);
97
- while (slug.includes("-dot-")) slug = slug.replaceAll("-dot-", "-");
98
- return slug;
99
- }
100
143
  function shouldScaffoldCreate(requested, cwd = process.cwd()) {
101
144
  return requested ?? !existsSync(join(cwd, "canopy.json"));
102
145
  }
@@ -160,10 +203,7 @@ const createCommand = defineCommand({
160
203
  message: "Slug",
161
204
  defaultValue: slugify(name),
162
205
  placeholder: slugify(name),
163
- validate: (value) => {
164
- if (value && !/^[a-z0-9][a-z0-9-]*$/.test(value)) return "Lowercase letters, digits and dashes only.";
165
- if (value?.includes("-dot-")) return `"-dot-" is reserved for preview hostnames.`;
166
- }
206
+ validate: (value) => value ? slugRuleProblem(value) : void 0
167
207
  })).trim();
168
208
  slug ||= slugify(name);
169
209
  if (args.from) {
@@ -1,4 +1,4 @@
1
- import { t as version } from "./package-DtU4jB_Z.mjs";
1
+ import { t as version } from "./package-B_o_DJ8u.mjs";
2
2
  import { i as reportErrors } from "./ui-BPq6-hKS.mjs";
3
3
  import { defineCommand } from "citty";
4
4
  import { cpSync, existsSync, mkdirSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
@@ -1114,6 +1114,25 @@ function readPersonCaller(headers) {
1114
1114
  };
1115
1115
  }
1116
1116
  //#endregion
1117
+ //#region ../data-plane/src/trust-headers.ts
1118
+ /**
1119
+ * Project scope a data-plane call carries, and the gateway JWT that vouches
1120
+ * for it — the one definition.
1121
+ *
1122
+ * The gateway stamps the project and channel on a call it forwards and signs
1123
+ * it with its short-lived internal JWT; canopy-api trusts the first two only
1124
+ * when the third verifies (D17). A client's own copies are dropped at the
1125
+ * gateway and re-stamped from what it saw.
1126
+ *
1127
+ * A leaf module: no imports, so any worker can take it without pulling the
1128
+ * data-plane routers along. The Workers-for-Platforms shim (worker-shim.ts)
1129
+ * ships as source text and keeps its own literals.
1130
+ */
1131
+ /** The project a data-plane call is for; trusted only beside a valid INTERNAL_JWT_HEADER (D17). */
1132
+ const PROJECT_HEADER = "x-canopy-project";
1133
+ /** `staging` when the call is for the project's staging channel (docs/14); absent means live. */
1134
+ const CHANNEL_HEADER = "x-canopy-channel";
1135
+ //#endregion
1117
1136
  //#region ../data-plane/src/caller-headers.cases.ts
1118
1137
  const ada = {
1119
1138
  sub: "u-ada",
@@ -1190,7 +1209,10 @@ const AGENT_CREDENTIAL_HEADER = "x-canopy-agent-credential";
1190
1209
  /**
1191
1210
  * Cookies that authenticate to Canopy itself — the monk session, the
1192
1211
  * client-page session, an agent's browse session and an outside account's
1193
- * session (outside-sign-in).
1212
+ * session (outside-sign-in). Project code must never see them (R-01): hosts
1213
+ * redact them from the bundle's request, and a sealed backend gets them only
1214
+ * inside a credential handle. The gateway and the project runtime split
1215
+ * cookies by this set; the WfP shim keeps a transcription (it cannot import).
1194
1216
  */
1195
1217
  const CANOPY_COOKIE_NAMES = /* @__PURE__ */ new Set([
1196
1218
  "canopy_session",
@@ -1238,9 +1260,9 @@ function redactCanopyCredentials(headers) {
1238
1260
  function stampWorkerHeaders(headers, ctx) {
1239
1261
  headers.delete("host");
1240
1262
  for (const stamp of IDENTITY_STAMP_HEADERS) headers.delete(stamp);
1241
- headers.set("x-canopy-project", ctx.projectSlug);
1242
- if (ctx.channel === "staging") headers.set("x-canopy-channel", "staging");
1243
- else headers.delete("x-canopy-channel");
1263
+ headers.set(PROJECT_HEADER, ctx.projectSlug);
1264
+ if (ctx.channel === "staging") headers.set(CHANNEL_HEADER, "staging");
1265
+ else headers.delete(CHANNEL_HEADER);
1244
1266
  return headers;
1245
1267
  }
1246
1268
  String.raw`// Canopy Workers-for-Platforms shim (generated by canopy-api — do not edit).
@@ -15,7 +15,7 @@
15
15
  "@types/react": "^19.1.0",
16
16
  "@types/react-dom": "^19.1.0",
17
17
  "@vitejs/plugin-react": "^5.0.0",
18
- "typescript": "^5.8.0",
18
+ "typescript": "^7.0.2",
19
19
  "vite": "^7.0.0"
20
20
  }
21
21
  }
@@ -5,6 +5,7 @@
5
5
  "module": "ESNext",
6
6
  "moduleResolution": "bundler",
7
7
  "jsx": "react-jsx",
8
+ "types": ["vite/client"],
8
9
  "strict": true,
9
10
  "noEmit": true,
10
11
  "skipLibCheck": true,
@@ -16,7 +16,7 @@
16
16
  "@types/react": "^19.1.0",
17
17
  "@types/react-dom": "^19.1.0",
18
18
  "@vitejs/plugin-react": "^5.0.0",
19
- "typescript": "^5.8.0",
19
+ "typescript": "^7.0.2",
20
20
  "vite": "^7.0.0"
21
21
  }
22
22
  }
@@ -5,6 +5,7 @@
5
5
  "module": "ESNext",
6
6
  "moduleResolution": "bundler",
7
7
  "jsx": "react-jsx",
8
+ "types": ["vite/client"],
8
9
  "strict": true,
9
10
  "noEmit": true,
10
11
  "skipLibCheck": true,
@@ -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-CRTV3ZQ1.mjs");
115
+ const { skillInstalled } = await import("./skill-DAlJwr4A.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());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mediamonks/canopy-cli",
3
- "version": "0.7.53",
3
+ "version": "0.7.55",
4
4
  "description": "Canopy CLI — create, develop and deploy Canopy projects.",
5
5
  "bin": {
6
6
  "canopy": "./dist/index.mjs"
@@ -22,8 +22,8 @@
22
22
  "esbuild": "^0.28.1",
23
23
  "hono": "^4.8.0",
24
24
  "vite-server": "npm:vite@^7",
25
- "@mediamonks/canopy-data-plane": "0.0.4",
26
- "@mediamonks/canopy": "0.0.20"
25
+ "@mediamonks/canopy": "0.0.20",
26
+ "@mediamonks/canopy-data-plane": "0.0.4"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/node": "^26.1.1",
@@ -1,2 +0,0 @@
1
- import { n as devCommand } from "./dev-L5slb6ke.mjs";
2
- export { devCommand };