clawnify 0.11.3 → 0.11.5

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.
@@ -1341,7 +1341,7 @@ function agentByName(name) {
1341
1341
  var ALL_AGENTS = DETECTORS.map((d) => d.agent);
1342
1342
 
1343
1343
  // src/lib/skills/content.gen.ts
1344
- var CLI_VERSION = "0.11.3";
1344
+ var CLI_VERSION = "0.11.5";
1345
1345
  var BUNDLED_SKILLS = [
1346
1346
  {
1347
1347
  name: "build-a-clawnify-app",
@@ -1847,12 +1847,14 @@ async function initApp(dir, opts) {
1847
1847
  app: { framework: "react+hono", database: true, storage }
1848
1848
  }, null, 2));
1849
1849
  const devDeps = {
1850
- "@cloudflare/workers-types": "^4.0.0",
1850
+ // v5 — wrangler >=4.114 declares a peer of ^5.x, and npm (unlike pnpm)
1851
+ // hard-fails the install on the conflict if this is pinned to ^4.
1852
+ "@cloudflare/workers-types": "^5.0.0",
1851
1853
  "@tailwindcss/vite": "^4.0.0",
1852
1854
  "@types/react": "^19.0.0",
1853
1855
  "@types/react-dom": "^19.0.0",
1854
1856
  "@vitejs/plugin-react": "^4.0.0",
1855
- clawnify: "^0.3.0",
1857
+ clawnify: "^0.11.3",
1856
1858
  "drizzle-kit": "^0.31.0",
1857
1859
  tailwindcss: "^4.0.0",
1858
1860
  vite: "^6.0.0",
@@ -1878,7 +1880,7 @@ async function initApp(dir, opts) {
1878
1880
  },
1879
1881
  devDependencies: devDeps,
1880
1882
  engines: { node: ">=22" },
1881
- pnpm: { onlyBuiltDependencies: ["esbuild"] }
1883
+ pnpm: { onlyBuiltDependencies: ["esbuild", "workerd"] }
1882
1884
  }, null, 2));
1883
1885
  write(targetDir, "tsconfig.json", JSON.stringify({
1884
1886
  compilerOptions: {
@@ -1967,13 +1969,17 @@ export default defineConfig({
1967
1969
  });
1968
1970
  `);
1969
1971
  if (storage) {
1970
- write(targetDir, "src/server/index.ts", `import { OpenAPIHono } from "@hono/zod-openapi";
1972
+ write(targetDir, "src/server/index.ts", `import { createApp } from "@clawnify/app";
1971
1973
  import { initUploads } from "./uploads";
1972
1974
  import api from "./routes";
1973
1975
 
1974
1976
  type Env = { Bindings: { DB: D1Database; UPLOADS: R2Bucket } };
1975
1977
 
1976
- const app = new OpenAPIHono<Env>();
1978
+ // createApp returns an OpenAPIHono with API discovery already mounted \u2014
1979
+ // GET /api/openapi.json + GET /llms.txt, generated from your live routes.
1980
+ // That descriptor is how agents discover this app; never hand-write it.
1981
+ // db:false \u2014 routes read the database per request via getDB(c.env).
1982
+ const app = createApp<Env>({ title: "${name}", version: "1.0.0", db: false });
1977
1983
 
1978
1984
  app.use("*", async (c, next) => {
1979
1985
  initUploads(c.env.UPLOADS);
@@ -1982,11 +1988,6 @@ app.use("*", async (c, next) => {
1982
1988
 
1983
1989
  app.route("/", api);
1984
1990
 
1985
- app.doc("/api/openapi.json", {
1986
- openapi: "3.0.0",
1987
- info: { title: "${name}", version: "1.0.0" },
1988
- });
1989
-
1990
1991
  export default app;
1991
1992
  `);
1992
1993
  write(targetDir, "src/server/uploads.ts", `let _bucket: R2Bucket;
@@ -2031,20 +2032,19 @@ export async function readUploadAsBase64DataUrl(
2031
2032
  }
2032
2033
  `);
2033
2034
  } else {
2034
- write(targetDir, "src/server/index.ts", `import { OpenAPIHono } from "@hono/zod-openapi";
2035
+ write(targetDir, "src/server/index.ts", `import { createApp } from "@clawnify/app";
2035
2036
  import api from "./routes";
2036
2037
 
2037
2038
  type Env = { Bindings: { DB: D1Database } };
2038
2039
 
2039
- const app = new OpenAPIHono<Env>();
2040
+ // createApp returns an OpenAPIHono with API discovery already mounted \u2014
2041
+ // GET /api/openapi.json + GET /llms.txt, generated from your live routes.
2042
+ // That descriptor is how agents discover this app; never hand-write it.
2043
+ // db:false \u2014 routes read the database per request via getDB(c.env).
2044
+ const app = createApp<Env>({ title: "${name}", version: "1.0.0", db: false });
2040
2045
 
2041
2046
  app.route("/", api);
2042
2047
 
2043
- app.doc("/api/openapi.json", {
2044
- openapi: "3.0.0",
2045
- info: { title: "${name}", version: "1.0.0" },
2046
- });
2047
-
2048
2048
  export default app;
2049
2049
  `);
2050
2050
  }
@@ -2288,7 +2288,7 @@ logs/
2288
2288
  console.log();
2289
2289
  }
2290
2290
  function writeBlankTemplate(dir, name) {
2291
- write(dir, "src/server/routes.ts", `import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
2291
+ write(dir, "src/server/routes.ts", `import { OpenAPIHono, createRoute, z } from "@clawnify/app";
2292
2292
  import { getDB, desc } from "@clawnify/db";
2293
2293
  import * as schema from "./schema";
2294
2294
 
@@ -2376,7 +2376,7 @@ export const items = sqliteTable("items", {
2376
2376
  createdAt: text("created_at").notNull().$default(() => new Date().toISOString()),
2377
2377
  });
2378
2378
  `);
2379
- write(dir, "src/server/routes.ts", `import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
2379
+ write(dir, "src/server/routes.ts", `import { OpenAPIHono, createRoute, z } from "@clawnify/app";
2380
2380
  import { getDB, eq, desc } from "@clawnify/db";
2381
2381
  import * as schema from "./schema";
2382
2382
 
@@ -3237,12 +3237,13 @@ ${WORKSPACE_GUIDE}`);
3237
3237
  if (data.links.length === 0) {
3238
3238
  console.log(`
3239
3239
  No GitHub repo is linked yet. Local editing works through the org's
3240
- synced workspace repo \u2014 connect it first (needs the dashboard):
3240
+ synced workspace repo. Enable the sync from here:
3241
3241
 
3242
- app.clawnify.com \u2192 Website (or an app) \u2192 GitHub icon \u2192 Connect
3242
+ clawnify workspace connect
3243
3243
 
3244
- That creates the workspace repo and pushes the current source. Then
3245
- re-run \`clawnify workspace\` to get the clone URL.
3244
+ That creates the workspace repo (installing the Clawnify GitHub App
3245
+ first if needed \u2014 a browser step for the user) and pushes the current
3246
+ website source. Then re-run \`clawnify workspace\` for the clone URL.
3246
3247
 
3247
3248
  ${WORKSPACE_GUIDE}`);
3248
3249
  return;
@@ -3266,6 +3267,106 @@ Repo: ${repo} (branch ${branch})`);
3266
3267
  console.log(`
3267
3268
  ${WORKSPACE_GUIDE}`);
3268
3269
  }
3270
+ var INSTALL_URL = "https://github.com/apps/clawnify/installations/new";
3271
+ var INSTALL_POLL_MS = 5e3;
3272
+ var INSTALL_TIMEOUT_MS = 5 * 6e4;
3273
+ async function listInstallations(orgId) {
3274
+ const res = await api.get("/settings/github/installations", orgId ? { orgId } : void 0);
3275
+ if (!res.ok) return [];
3276
+ const data = await res.json();
3277
+ return data.installations ?? [];
3278
+ }
3279
+ async function workspaceConnectCommand(opts) {
3280
+ const token = await getValidToken();
3281
+ if (!token) {
3282
+ console.log(`Not logged in.
3283
+
3284
+ \`clawnify login\` opens a browser for OAuth \u2014 a coding agent cannot
3285
+ complete it headlessly. Ask the user to run:
3286
+
3287
+ npx clawnify@latest login
3288
+
3289
+ then re-run \`clawnify workspace connect\`.`);
3290
+ process.exit(1);
3291
+ }
3292
+ const auth = loadAuth();
3293
+ const orgId = auth?.org_id ?? process.env.CLAWNIFY_ORG_ID;
3294
+ const orgOpt = orgId ? { orgId } : void 0;
3295
+ let installs = await listInstallations(orgId);
3296
+ if (installs.length === 0) {
3297
+ console.log(`No GitHub account is connected to this workspace yet.
3298
+
3299
+ Ask the user to install the Clawnify GitHub App (browser step):
3300
+
3301
+ ${INSTALL_URL}
3302
+
3303
+ They should pick the GitHub account/org where the workspace repo will
3304
+ live. Waiting for the installation to appear (up to 5 minutes)...`);
3305
+ const deadline = Date.now() + INSTALL_TIMEOUT_MS;
3306
+ while (Date.now() < deadline && installs.length === 0) {
3307
+ await new Promise((r) => setTimeout(r, INSTALL_POLL_MS));
3308
+ installs = await listInstallations(orgId);
3309
+ }
3310
+ if (installs.length === 0) {
3311
+ console.error(`
3312
+ Timed out waiting. Once the user has completed the install, re-run:
3313
+
3314
+ clawnify workspace connect`);
3315
+ process.exit(1);
3316
+ }
3317
+ console.log(` \u2713 GitHub account connected: ${installs[0].account}`);
3318
+ }
3319
+ let install = installs[0];
3320
+ if (installs.length > 1) {
3321
+ const match = opts?.account ? installs.find(
3322
+ (i) => String(i.id) === opts.account || i.account.toLowerCase() === opts.account.toLowerCase()
3323
+ ) : void 0;
3324
+ if (!match) {
3325
+ console.error(
3326
+ `Multiple GitHub accounts are connected \u2014 pick one with --account:
3327
+ ` + installs.map((i) => ` --account ${i.account} (${i.account_type}, id ${i.id})`).join("\n")
3328
+ );
3329
+ process.exit(1);
3330
+ }
3331
+ install = match;
3332
+ }
3333
+ const siteRes = await api.get("/v1/websites", orgOpt);
3334
+ const site = siteRes.ok ? (await siteRes.json()).website ?? {} : {};
3335
+ if (!site.id) {
3336
+ console.error(`This workspace has no website yet \u2014 there is nothing to sync.
3337
+
3338
+ Create the website first (dashboard \u2192 Website), then re-run
3339
+ \`clawnify workspace connect\`.`);
3340
+ process.exit(1);
3341
+ }
3342
+ console.log(`Connecting ${site.slug ?? "website"} via @${install.account}...`);
3343
+ const res = await api.post(
3344
+ "/settings/github/connect",
3345
+ { website_id: site.id, installation_id: install.id },
3346
+ orgOpt
3347
+ );
3348
+ const data = await res.json().catch(() => ({}));
3349
+ if (!res.ok || !data.repo) {
3350
+ if (data.needsReauth) {
3351
+ console.error(`GitHub authorization expired. Ask the user to reconnect (browser step):
3352
+
3353
+ https://app.clawnify.com/github/reauth?state=website
3354
+
3355
+ then re-run \`clawnify workspace connect\`.`);
3356
+ } else {
3357
+ console.error(`Connect failed: ${data.error ?? `HTTP ${res.status}`}`);
3358
+ }
3359
+ process.exit(1);
3360
+ }
3361
+ console.log(`
3362
+ \u2713 Workspace repo connected: ${data.repo} (branch ${data.branch ?? "main"})
3363
+
3364
+ Clone: git clone https://github.com/${data.repo}.git
3365
+ The website lives under ${data.subdir ?? "website"}/ \u2014 pushes to
3366
+ ${data.branch ?? "main"} auto-deploy to the draft site.
3367
+
3368
+ Run \`clawnify workspace\` any time for the full map + editing contract.`);
3369
+ }
3269
3370
 
3270
3371
  // src/commands/execute.ts
3271
3372
  import fs7 from "fs";
@@ -3587,6 +3688,7 @@ async function runCli() {
3587
3688
  connections.command("connect <id>").description("Explain how to connect an integration (OAuth in the dashboard \u2014 the CLI/agent can't do it for you)").option("--json", "Print the steps as JSON").action(connectionsConnectCommand);
3588
3689
  const workspace = program.command("workspace").description("Show the org's workspace: synced GitHub repo, targets, and how to edit locally").option("--json", "Machine-readable output").action(workspaceStatusCommand);
3589
3690
  workspace.command("init [dir]").description("Scaffold a workspace monorepo bound to an org").option("--org <slug-or-id>", "Org to bind the workspace to (defaults to active org)").option("--name <name>", "Workspace display name (defaults to the org name)").action(workspaceInitCommand);
3691
+ workspace.command("connect").description("Enable GitHub sync: create/join the org's workspace repo and link the website").option("--account <login-or-id>", "GitHub account to use when several are connected").action(workspaceConnectCommand);
3590
3692
  program.command("ls").description("List deployed apps").action(lsCommand);
3591
3693
  program.command("logs <app-id>").description("Show build logs for an app").action(logsCommand);
3592
3694
  const servers = program.command("servers").description("List the org's agent servers");
@@ -3634,4 +3736,4 @@ async function runCli() {
3634
3736
  export {
3635
3737
  runCli
3636
3738
  };
3637
- //# sourceMappingURL=cli-ISABP4ZI.js.map
3739
+ //# sourceMappingURL=cli-ON2IFJMD.js.map