clawnify 0.11.4 → 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.4";
1344
+ var CLI_VERSION = "0.11.5";
1345
1345
  var BUNDLED_SKILLS = [
1346
1346
  {
1347
1347
  name: "build-a-clawnify-app",
@@ -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-GUJPA7GL.js.map
3739
+ //# sourceMappingURL=cli-ON2IFJMD.js.map