clawnify 0.16.0 → 0.16.1

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.
@@ -606,7 +606,7 @@ async function pollUntilReady(resourceId, options = {}) {
606
606
  }
607
607
 
608
608
  // src/version.ts
609
- var VERSION = "0.16.0";
609
+ var VERSION = "0.16.1";
610
610
 
611
611
  export {
612
612
  OAUTH_CLIENT_ID,
@@ -630,4 +630,4 @@ export {
630
630
  pollUntilReady,
631
631
  VERSION
632
632
  };
633
- //# sourceMappingURL=chunk-6NPBW4NU.js.map
633
+ //# sourceMappingURL=chunk-2I4XJ52D.js.map
@@ -20,7 +20,7 @@ import {
20
20
  resolveOrgContext,
21
21
  saveAuth,
22
22
  saveProject
23
- } from "./chunk-6NPBW4NU.js";
23
+ } from "./chunk-2I4XJ52D.js";
24
24
 
25
25
  // src/cli.ts
26
26
  import { Command, Option } from "commander";
@@ -194,7 +194,15 @@ function saveAnon(dir, ctx, extra = {}) {
194
194
  function clearAnon(dir) {
195
195
  const existing = readProject(dir);
196
196
  if (!existing?.anon) return;
197
- const { anon: _anon, app_id: _a, website_id: _w, slug: _s, ...rest } = existing;
197
+ const {
198
+ anon: _anon,
199
+ app_id: _a,
200
+ website_id: _w,
201
+ slug: _s,
202
+ org_id: _o,
203
+ app_token: _t,
204
+ ...rest
205
+ } = existing;
198
206
  saveProject(dir, rest);
199
207
  }
200
208
  async function getOrCreateAnonContext(dir, name) {
@@ -232,6 +240,17 @@ function explainAnonUnauthorized(dir) {
232
240
  );
233
241
  process.exit(1);
234
242
  }
243
+ async function healStaleAnonLink(dir, ctx) {
244
+ console.log("\nThis folder was linked to a temporary workspace this account can't access.");
245
+ if (new Date(ctx.claim_expires_at).getTime() > Date.now()) {
246
+ console.log("If nobody claimed it yet, it is still claimable:");
247
+ printClaimBlock(ctx);
248
+ }
249
+ clearAnon(dir);
250
+ const orgId = await resolveOrgContext({ dir });
251
+ console.log("Deploying into your own workspace instead...\n");
252
+ return orgId;
253
+ }
235
254
  function printClaimBlock(ctx) {
236
255
  const hoursLeft = Math.max(
237
256
  1,
@@ -678,7 +697,11 @@ async function deployWebsite(dir, options) {
678
697
  return;
679
698
  }
680
699
  console.log(linkedProject?.website_id ? `Updating ${baseName}...` : `Deploying ${baseName}...`);
681
- const result = await uploadWebsiteDeploy(archive, baseName, orgId);
700
+ let result = await uploadWebsiteDeploy(archive, baseName, orgId);
701
+ if (!result.ok && result.error === "org_not_accessible" && linkedProject?.anon) {
702
+ orgId = await healStaleAnonLink(resolvedDir, linkedProject.anon);
703
+ result = await uploadWebsiteDeploy(archive, baseName, orgId);
704
+ }
682
705
  if (!result.ok) {
683
706
  console.error(`Deploy failed: ${result.error}`);
684
707
  process.exit(1);
@@ -946,7 +969,7 @@ async function deployCommand(dir, options = {}) {
946
969
  printClaimBlock(ctx);
947
970
  return;
948
971
  }
949
- const orgId = await resolveOrgId(options, linkedProject, resolvedDir);
972
+ let orgId = await resolveOrgId(options, linkedProject, resolvedDir);
950
973
  if (options.dryRun) {
951
974
  summarizeArchive(archive, files, framework, baseName);
952
975
  if (linkedProject?.app_id) {
@@ -958,20 +981,30 @@ async function deployCommand(dir, options = {}) {
958
981
  }
959
982
  return;
960
983
  }
984
+ let needsCreate = !linkedProject?.app_id;
961
985
  if (linkedProject?.app_id) {
962
986
  console.log(`Updating ${baseName} (${linkedProject.slug ?? linkedProject.app_id})...`);
963
987
  const result2 = await uploadRedeploy(linkedProject.app_id, archive, orgId);
964
- if (!result2.ok) {
988
+ if (result2.ok) {
989
+ appId = result2.data.app_id;
990
+ slug = result2.data.slug;
991
+ appToken = result2.data.app_token;
992
+ saveProject(resolvedDir, { org_id: orgId, app_id: appId, slug, app_token: appToken });
993
+ } else if (result2.error === "org_not_accessible" && linkedProject.anon) {
994
+ orgId = await healStaleAnonLink(resolvedDir, linkedProject.anon);
995
+ needsCreate = true;
996
+ } else {
965
997
  console.error(`Deploy failed: ${result2.error}`);
966
998
  process.exit(1);
967
999
  }
968
- appId = result2.data.app_id;
969
- slug = result2.data.slug;
970
- appToken = result2.data.app_token;
971
- saveProject(resolvedDir, { org_id: orgId, app_id: appId, slug, app_token: appToken });
972
- } else {
1000
+ }
1001
+ if (needsCreate) {
973
1002
  console.log(`Deploying ${baseName}...`);
974
1003
  let result2 = await uploadDeploy(archive, baseName, framework, orgId);
1004
+ if (!result2.ok && !("conflict" in result2) && result2.error === "org_not_accessible" && linkedProject?.anon) {
1005
+ orgId = await healStaleAnonLink(resolvedDir, linkedProject.anon);
1006
+ result2 = await uploadDeploy(archive, baseName, framework, orgId);
1007
+ }
975
1008
  if (!result2.ok && "conflict" in result2) {
976
1009
  const decision = await resolveConflictDecision(options, result2.conflict);
977
1010
  if (decision === "update") {
@@ -1624,7 +1657,7 @@ function agentByName(name) {
1624
1657
  var ALL_AGENTS = DETECTORS.map((d) => d.agent);
1625
1658
 
1626
1659
  // src/lib/skills/content.gen.ts
1627
- var CLI_VERSION = "0.16.0";
1660
+ var CLI_VERSION = "0.16.1";
1628
1661
  var BUNDLED_SKILLS = [
1629
1662
  {
1630
1663
  name: "build-a-clawnify-app",
@@ -1634,7 +1667,7 @@ var BUNDLED_SKILLS = [
1634
1667
  {
1635
1668
  name: "build-a-clawnify-website",
1636
1669
  description: "Build and ship a Clawnify website \u2014 Astro on Cloudflare Workers, the built-in form system (never hand-roll a form), images and assets, and the draft-then-publish deploy flow. Use when creating or editing a Clawnify website, or when a site needs a contact/waitlist/signup form.",
1637
- content: "# Build a Clawnify website\n\nA Clawnify website is an **Astro** project deployed to Cloudflare Workers. One\nsite per organization. You write pages; the platform owns hosting, forms and\nthe publish flow.\n\n```bash\nclawnify init --type website --name \"My Site\" website\ncd website && pnpm install && pnpm dev # http://localhost:4321\n```\n\n```\nwebsite/\n src/pages/ # one .astro file per route (index.astro \u2192 /)\n src/layouts/ # shared shell: nav, footer, <head>\n src/blocks/ # platform blocks you've adopted (see Forms below)\n public/ # images, favicons \u2014 served as-is from /\n```\n\n## Forms: use the built-in system. Do not build your own.\n\n**This is the single most common mistake.** A site needs a contact or waitlist\nform, and the obvious move is to write a `<form>` and POST it somewhere \u2014 your\nown endpoint, a third-party form service, or the platform's submit URL with the\nwebsite id pasted in. All three are wrong, and the last one looks right enough\nto survive review.\n\nClawnify has a form system. It captures submissions, stores them, can email you,\nand can hand each one to an agent or a flow. You get all of it by using the\n**Forms block** rather than writing a form yourself.\n\n### How it works\n\n- The submit target is **computed at render time** from `WEBSITE_ID` \u2014 a\n variable the platform bakes into your site's Worker \u2014 plus the form's id:\n\n ```astro\n const env = (Astro.locals as { runtime?: { env?: Record<string, string> } })?.runtime?.env;\n const websiteId = env?.WEBSITE_ID ?? \"\";\n const action = websiteId ? `https://provision.clawnify.com/forms/submit/${websiteId}/${formId}` : \"\";\n ```\n\n **Never hardcode the website id.** It is baked per Worker so a site can only\n ever submit to itself \u2014 hardcoding throws that away, and the literal goes\n stale the moment the site is recreated. An empty `action` in local `astro dev`\n is expected: there are no Worker vars locally, so the form simply no-ops.\n\n- The submit script POSTs JSON with `Content-Type: text/plain;charset=UTF-8`.\n That is not a typo \u2014 `text/plain` is CORS-safelisted, so the request needs no\n preflight, which matters because the platform can't know your site's origin in\n advance. The route parses the text body as JSON.\n\n- **Keep the Turnstile widget.** The ingest rejects a submission with no token,\n so a form without the widget fails every time with \"Verification required\".\n The sitekey shipped in the block is public and pairs with the platform's\n secret; the widget will not validate on `localhost`, only on a real hostname.\n\n### Getting the block\n\nSites are seeded with the platform's block library at creation. If yours has\n`src/blocks/Forms/Contact.astro`, import it and go. If it doesn't \u2014 an older\nsite, or one scaffolded bare by the CLI \u2014 copy it in from the website template\nand adapt it.\n\n**The design is yours; the plumbing is not.** Restyle the markup, labels and\nclasses freely. Preserve, exactly:\n\n- the computed `action` (never a prop, never a literal),\n- the Turnstile widget,\n- the `data-clawnify-form` attribute and its submit script,\n- `export const schema`,\n- destructuring only known props \u2014 never splat leftover props onto `<form>`,\n or an injected `action` becomes a way to point your form at someone else.\n\n### Fields\n\nThe stock block collects **name, email and message**. Two ways to go beyond\nthat, and the right one depends on whether your form is registered:\n\n- **Registered forms** (a tree node named `Forms/Contact`) are schema-locked:\n the ingest 422s any field it doesn't expect. Give extra inputs **no `name`\n attribute** and have the submit script fold them into `message`.\n- **Unregistered forms** \u2014 hand-built pages like this one \u2014 are not locked, so\n extra fields post as themselves and are stored verbatim in the payload. Better\n data, but if the site later moves onto the tree renderer, registration will\n start rejecting them. Leave a comment saying so.\n\n### Where submissions go\n\nEvery submission is stored and visible in the dashboard. From there it can\nnotify an email address, or fan out to an agent or a flow \u2014 which is how a\nsignup becomes a CRM record or a WhatsApp message without you writing a backend.\nSet the notification address in the dashboard, not in the site.\n\n## Images and assets\n\nPut them in `public/` and reference them with an absolute path (`/img/hero.jpg`).\nThey're served as static files. Pull in real assets at real resolution rather\nthan linking someone else's CDN from your markup.\n\n## Deploying: draft first, then publish\n\n```bash\nclawnify deploy # \u2192 the DRAFT site, visible only to your org\n```\n\nDeploying **never** changes the live site. Going live is a separate, explicit\nstep: review the draft, then **Publish to live** in the dashboard. Tell the user\nthis \u2014 a deploy that \"worked\" but didn't appear on the live site is almost\nalways someone expecting deploy to publish.\n\n## Pinning the org\n\nEvery command resolves which organization it targets, folder-first. In a linked\nfolder you get it for free; otherwise pass `--org`. If you work across several\norganizations, pass `--org` explicitly on anything that writes \u2014 the global\nactive org is shared machine-wide and another session can change it under you.\n"
1670
+ content: "# Build a Clawnify website\n\nA Clawnify website is an **Astro** project deployed to Cloudflare Workers. One\nsite per organization. You write pages; the platform owns hosting, forms and\nthe publish flow.\n\n```bash\nclawnify init --type website --name \"My Site\" website\ncd website && pnpm install && pnpm dev # http://localhost:4321\n```\n\n```\nwebsite/\n src/pages/ # one .astro file per route (index.astro \u2192 /)\n src/layouts/ # shared shell: nav, footer, <head>\n src/blocks/ # platform blocks you've adopted (see Forms below)\n public/ # images, favicons \u2014 served as-is from /\n```\n\n## Forms: use the built-in system. Do not build your own.\n\n**This is the single most common mistake.** A site needs a contact or waitlist\nform, and the obvious move is to write a `<form>` and POST it somewhere \u2014 your\nown endpoint, a third-party form service, or the platform's submit URL with the\nwebsite id pasted in. All three are wrong, and the last one looks right enough\nto survive review.\n\nClawnify has a form system. It captures submissions, stores them, can email you,\nand can hand each one to an agent or a flow. You get all of it by using the\n**Forms block** rather than writing a form yourself.\n\n### How it works\n\n- The submit target is **computed at render time** from `WEBSITE_ID` \u2014 a\n variable the platform bakes into your site's Worker \u2014 plus the form's id:\n\n ```astro\n const env = (Astro.locals as { runtime?: { env?: Record<string, string> } })?.runtime?.env;\n const websiteId = env?.WEBSITE_ID ?? \"\";\n const action = websiteId ? `https://provision.clawnify.com/forms/submit/${websiteId}/${formId}` : \"\";\n ```\n\n **Never hardcode the website id.** It is baked per Worker so a site can only\n ever submit to itself \u2014 hardcoding throws that away, and the literal goes\n stale the moment the site is recreated. An empty `action` in local `astro dev`\n is expected: there are no Worker vars locally, so the form simply no-ops.\n\n- The submit script POSTs JSON with `Content-Type: text/plain;charset=UTF-8`.\n That is not a typo \u2014 `text/plain` is CORS-safelisted, so the request needs no\n preflight, which matters because the platform can't know your site's origin in\n advance. The route parses the text body as JSON.\n\n- **Keep the Turnstile widget.** The ingest rejects a submission with no token,\n so a form without the widget fails every time with \"Verification required\".\n The sitekey shipped in the block is public and pairs with the platform's\n secret; the widget will not validate on `localhost`, only on a real hostname.\n\n### Getting the block\n\nSites are seeded with the platform's block library at creation. If yours has\n`src/blocks/Forms/Contact.astro`, import it and go. If it doesn't \u2014 an older\nsite, or one scaffolded bare by the CLI \u2014 copy it in from the website template\nand adapt it.\n\n**The design is yours; the plumbing is not.** Restyle the markup, labels and\nclasses freely. Preserve, exactly:\n\n- the computed `action` (never a prop, never a literal),\n- the Turnstile widget,\n- the `data-clawnify-form` attribute and its submit script,\n- `export const schema`,\n- destructuring only known props \u2014 never splat leftover props onto `<form>`,\n or an injected `action` becomes a way to point your form at someone else.\n\n### Fields\n\nThe stock block collects **name, email and message**. Two ways to go beyond\nthat, and the right one depends on whether your form is registered:\n\n- **Registered forms** (a tree node named `Forms/Contact`) are schema-locked:\n the ingest 422s any field it doesn't expect. Give extra inputs **no `name`\n attribute** and have the submit script fold them into `message`.\n- **Unregistered forms** \u2014 hand-built pages like this one \u2014 are not locked, so\n extra fields post as themselves and are stored verbatim in the payload. Better\n data, but if the site later moves onto the tree renderer, registration will\n start rejecting them. Leave a comment saying so.\n\n### PDF attachments\n\nThe Contact block can collect one PDF per submission (job applications, RFQs).\nOff by default \u2014 enable it with the block's `attachment` prop (and optionally\n`attachmentLabel`), then **publish**: the file field is registered at publish\ntime, and the ingest rejects files on forms that haven't registered one. Rules\nthe platform enforces server-side (don't fight them client-side): PDF only,\nverified by content not by extension, max 10 MB. The submission's payload\ncarries the filename and a download link that only the site's own organization\ncan open \u2014 the file is never on a public URL. When a file is attached the\nsubmit script posts `multipart/form-data` instead of JSON; both are\npreflight-free, and the block already handles the switch.\n\n### Where submissions go\n\nEvery submission is stored and visible in the dashboard. From there it can\nnotify an email address, or fan out to an agent or a flow \u2014 which is how a\nsignup becomes a CRM record or a WhatsApp message without you writing a backend.\nSet the notification address in the dashboard, not in the site.\n\n## Images and assets\n\nPut them in `public/` and reference them with an absolute path (`/img/hero.jpg`).\nThey're served as static files. Pull in real assets at real resolution rather\nthan linking someone else's CDN from your markup.\n\n## Deploying: draft first, then publish\n\n```bash\nclawnify deploy # \u2192 the DRAFT site, visible only to your org\n```\n\nDeploying **never** changes the live site. Going live is a separate, explicit\nstep: review the draft, then **Publish to live** in the dashboard. Tell the user\nthis \u2014 a deploy that \"worked\" but didn't appear on the live site is almost\nalways someone expecting deploy to publish.\n\n## Pinning the org\n\nEvery command resolves which organization it targets, folder-first. In a linked\nfolder you get it for free; otherwise pass `--org`. If you work across several\norganizations, pass `--org` explicitly on anything that writes \u2014 the global\nactive org is shared machine-wide and another session can change it under you.\n"
1638
1671
  },
1639
1672
  {
1640
1673
  name: "use-the-clawnify-cli",
@@ -4297,4 +4330,4 @@ async function runCli() {
4297
4330
  export {
4298
4331
  runCli
4299
4332
  };
4300
- //# sourceMappingURL=cli-G6ZBPA6D.js.map
4333
+ //# sourceMappingURL=cli-KOUOVFNL.js.map