clawnify 0.11.4 → 0.11.6
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.
- package/dist/{cli-GUJPA7GL.js → cli-UFUSSG3S.js} +184 -22
- package/dist/cli-UFUSSG3S.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/{mcp-VWZZ6ZKH.js → mcp-HZ7GXSNJ.js} +9 -2
- package/dist/mcp-HZ7GXSNJ.js.map +1 -0
- package/package.json +1 -1
- package/dist/cli-GUJPA7GL.js.map +0 -1
- package/dist/mcp-VWZZ6ZKH.js.map +0 -1
|
@@ -316,6 +316,42 @@ async function uploadRedeploy(appId, archive, orgId) {
|
|
|
316
316
|
const err = await res.json().catch(() => ({}));
|
|
317
317
|
return { ok: false, error: err.error || res.statusText };
|
|
318
318
|
}
|
|
319
|
+
async function repoDeploy(opts) {
|
|
320
|
+
const res = await api.post(
|
|
321
|
+
"/v1/apps/deploy",
|
|
322
|
+
{
|
|
323
|
+
repo: opts.repo,
|
|
324
|
+
branch: "main",
|
|
325
|
+
subdir: opts.subdir,
|
|
326
|
+
name: opts.name,
|
|
327
|
+
create_new: opts.createNew
|
|
328
|
+
},
|
|
329
|
+
{ orgId: opts.orgId }
|
|
330
|
+
);
|
|
331
|
+
if (res.ok) {
|
|
332
|
+
const data = await res.json();
|
|
333
|
+
return { ok: true, data };
|
|
334
|
+
}
|
|
335
|
+
if (res.status === 409) {
|
|
336
|
+
const conflict = await res.json();
|
|
337
|
+
return { ok: false, conflict };
|
|
338
|
+
}
|
|
339
|
+
const err = await res.json().catch(() => ({}));
|
|
340
|
+
return { ok: false, error: err.error || res.statusText };
|
|
341
|
+
}
|
|
342
|
+
async function repoRedeploy(appId, opts, orgId) {
|
|
343
|
+
const res = await api.post(
|
|
344
|
+
`/v1/apps/${appId}/redeploy`,
|
|
345
|
+
{ repo: opts.repo, branch: "main", subdir: opts.subdir },
|
|
346
|
+
{ orgId }
|
|
347
|
+
);
|
|
348
|
+
if (res.ok) {
|
|
349
|
+
const data = await res.json();
|
|
350
|
+
return { ok: true, data };
|
|
351
|
+
}
|
|
352
|
+
const err = await res.json().catch(() => ({}));
|
|
353
|
+
return { ok: false, error: err.error || res.statusText };
|
|
354
|
+
}
|
|
319
355
|
function assertNodeVersion() {
|
|
320
356
|
const [major] = process.versions.node.split(".").map(Number);
|
|
321
357
|
if (major < 22) {
|
|
@@ -374,6 +410,10 @@ async function workspaceOrgId(resolvedDir) {
|
|
|
374
410
|
}
|
|
375
411
|
return match.id;
|
|
376
412
|
}
|
|
413
|
+
function describeConflict(conflict) {
|
|
414
|
+
const existing = conflict.existing_app_slug ? `'${conflict.existing_app_name}' (${conflict.existing_app_slug})` : `'${conflict.existing_app_name}'`;
|
|
415
|
+
return conflict.error === "app_from_repo_exists_in_org" ? `This organization already has an app deployed from this repo: ${existing}.` : `Slug '${conflict.slug}' is taken in this organization (currently held by an app named ${existing}).`;
|
|
416
|
+
}
|
|
377
417
|
async function resolveConflictDecision(options, conflict) {
|
|
378
418
|
if (options.updateExisting) return "update";
|
|
379
419
|
if (options.createNew) return "create";
|
|
@@ -381,7 +421,7 @@ async function resolveConflictDecision(options, conflict) {
|
|
|
381
421
|
if (!process.stdin.isTTY) {
|
|
382
422
|
console.error(
|
|
383
423
|
`
|
|
384
|
-
|
|
424
|
+
${describeConflict(conflict)}
|
|
385
425
|
Pass one of:
|
|
386
426
|
--update-existing overwrite the existing app
|
|
387
427
|
--create-new deploy as '${conflict.suggested_slug}'
|
|
@@ -390,11 +430,9 @@ async function resolveConflictDecision(options, conflict) {
|
|
|
390
430
|
);
|
|
391
431
|
process.exit(EXIT_CONFLICT_NEEDS_DECISION);
|
|
392
432
|
}
|
|
393
|
-
console.log(
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
`
|
|
397
|
-
);
|
|
433
|
+
console.log(`
|
|
434
|
+
${describeConflict(conflict)}
|
|
435
|
+
`);
|
|
398
436
|
console.log(` 1) Update that app \u2014 deploy this source over it`);
|
|
399
437
|
console.log(` 2) Create a new app at slug '${conflict.suggested_slug}'
|
|
400
438
|
`);
|
|
@@ -654,23 +692,45 @@ async function deployCommand(dir, options = {}) {
|
|
|
654
692
|
if (options.dryRun) {
|
|
655
693
|
console.log(
|
|
656
694
|
`
|
|
657
|
-
Dry run \u2014 would deploy from GitHub repo '${repo}' (branch: main${subdir ? `, path: ${subdir}` : ""})
|
|
695
|
+
Dry run \u2014 would deploy from GitHub repo '${repo}' (branch: main${subdir ? `, path: ${subdir}` : ""}${options.name ? `, name: ${options.name}` : ""})
|
|
658
696
|
`
|
|
659
697
|
);
|
|
660
698
|
return;
|
|
661
699
|
}
|
|
662
700
|
console.log(`Deploying from ${repo}${subdir ? `/${subdir}` : ""}...`);
|
|
663
701
|
const orgId = options.org ? await resolveOrgId(options, null) : void 0;
|
|
664
|
-
|
|
665
|
-
if (!
|
|
666
|
-
const
|
|
667
|
-
|
|
702
|
+
let result2 = await repoDeploy({ repo, subdir, name: options.name, orgId });
|
|
703
|
+
if (!result2.ok && "conflict" in result2) {
|
|
704
|
+
const decision = await resolveConflictDecision(options, result2.conflict);
|
|
705
|
+
if (decision === "update") {
|
|
706
|
+
const existingSlug = result2.conflict.existing_app_slug ?? result2.conflict.slug;
|
|
707
|
+
console.log(`Updating ${result2.conflict.existing_app_name} (${existingSlug})...`);
|
|
708
|
+
const redeployed = await repoRedeploy(result2.conflict.existing_app_id, { repo, subdir }, orgId);
|
|
709
|
+
if (!redeployed.ok) {
|
|
710
|
+
console.error(`Deploy failed: ${redeployed.error}`);
|
|
711
|
+
process.exit(1);
|
|
712
|
+
}
|
|
713
|
+
result2 = { ok: true, data: redeployed.data };
|
|
714
|
+
} else if (decision === "create") {
|
|
715
|
+
result2 = await repoDeploy({
|
|
716
|
+
repo,
|
|
717
|
+
subdir,
|
|
718
|
+
name: result2.conflict.suggested_slug,
|
|
719
|
+
createNew: true,
|
|
720
|
+
orgId
|
|
721
|
+
});
|
|
722
|
+
} else {
|
|
723
|
+
process.exit(EXIT_CONFLICT_NEEDS_DECISION);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
if (!result2.ok) {
|
|
727
|
+
const errMsg = "conflict" in result2 ? "Slug still conflicts" : result2.error;
|
|
728
|
+
console.error(`Deploy failed: ${errMsg}`);
|
|
668
729
|
process.exit(1);
|
|
669
730
|
}
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
appToken = data.app_token;
|
|
731
|
+
appId = result2.data.app_id;
|
|
732
|
+
slug = result2.data.slug;
|
|
733
|
+
appToken = result2.data.app_token;
|
|
674
734
|
resolvedOrgId = orgId;
|
|
675
735
|
} else {
|
|
676
736
|
const resolvedDir = dir ? path2.resolve(dir) : process.cwd();
|
|
@@ -1341,7 +1401,7 @@ function agentByName(name) {
|
|
|
1341
1401
|
var ALL_AGENTS = DETECTORS.map((d) => d.agent);
|
|
1342
1402
|
|
|
1343
1403
|
// src/lib/skills/content.gen.ts
|
|
1344
|
-
var CLI_VERSION = "0.11.
|
|
1404
|
+
var CLI_VERSION = "0.11.6";
|
|
1345
1405
|
var BUNDLED_SKILLS = [
|
|
1346
1406
|
{
|
|
1347
1407
|
name: "build-a-clawnify-app",
|
|
@@ -3237,12 +3297,13 @@ ${WORKSPACE_GUIDE}`);
|
|
|
3237
3297
|
if (data.links.length === 0) {
|
|
3238
3298
|
console.log(`
|
|
3239
3299
|
No GitHub repo is linked yet. Local editing works through the org's
|
|
3240
|
-
synced workspace repo
|
|
3300
|
+
synced workspace repo. Enable the sync from here:
|
|
3241
3301
|
|
|
3242
|
-
|
|
3302
|
+
clawnify workspace connect
|
|
3243
3303
|
|
|
3244
|
-
That creates the workspace repo
|
|
3245
|
-
|
|
3304
|
+
That creates the workspace repo (installing the Clawnify GitHub App
|
|
3305
|
+
first if needed \u2014 a browser step for the user) and pushes the current
|
|
3306
|
+
website source. Then re-run \`clawnify workspace\` for the clone URL.
|
|
3246
3307
|
|
|
3247
3308
|
${WORKSPACE_GUIDE}`);
|
|
3248
3309
|
return;
|
|
@@ -3266,6 +3327,106 @@ Repo: ${repo} (branch ${branch})`);
|
|
|
3266
3327
|
console.log(`
|
|
3267
3328
|
${WORKSPACE_GUIDE}`);
|
|
3268
3329
|
}
|
|
3330
|
+
var INSTALL_URL = "https://github.com/apps/clawnify/installations/new";
|
|
3331
|
+
var INSTALL_POLL_MS = 5e3;
|
|
3332
|
+
var INSTALL_TIMEOUT_MS = 5 * 6e4;
|
|
3333
|
+
async function listInstallations(orgId) {
|
|
3334
|
+
const res = await api.get("/settings/github/installations", orgId ? { orgId } : void 0);
|
|
3335
|
+
if (!res.ok) return [];
|
|
3336
|
+
const data = await res.json();
|
|
3337
|
+
return data.installations ?? [];
|
|
3338
|
+
}
|
|
3339
|
+
async function workspaceConnectCommand(opts) {
|
|
3340
|
+
const token = await getValidToken();
|
|
3341
|
+
if (!token) {
|
|
3342
|
+
console.log(`Not logged in.
|
|
3343
|
+
|
|
3344
|
+
\`clawnify login\` opens a browser for OAuth \u2014 a coding agent cannot
|
|
3345
|
+
complete it headlessly. Ask the user to run:
|
|
3346
|
+
|
|
3347
|
+
npx clawnify@latest login
|
|
3348
|
+
|
|
3349
|
+
then re-run \`clawnify workspace connect\`.`);
|
|
3350
|
+
process.exit(1);
|
|
3351
|
+
}
|
|
3352
|
+
const auth = loadAuth();
|
|
3353
|
+
const orgId = auth?.org_id ?? process.env.CLAWNIFY_ORG_ID;
|
|
3354
|
+
const orgOpt = orgId ? { orgId } : void 0;
|
|
3355
|
+
let installs = await listInstallations(orgId);
|
|
3356
|
+
if (installs.length === 0) {
|
|
3357
|
+
console.log(`No GitHub account is connected to this workspace yet.
|
|
3358
|
+
|
|
3359
|
+
Ask the user to install the Clawnify GitHub App (browser step):
|
|
3360
|
+
|
|
3361
|
+
${INSTALL_URL}
|
|
3362
|
+
|
|
3363
|
+
They should pick the GitHub account/org where the workspace repo will
|
|
3364
|
+
live. Waiting for the installation to appear (up to 5 minutes)...`);
|
|
3365
|
+
const deadline = Date.now() + INSTALL_TIMEOUT_MS;
|
|
3366
|
+
while (Date.now() < deadline && installs.length === 0) {
|
|
3367
|
+
await new Promise((r) => setTimeout(r, INSTALL_POLL_MS));
|
|
3368
|
+
installs = await listInstallations(orgId);
|
|
3369
|
+
}
|
|
3370
|
+
if (installs.length === 0) {
|
|
3371
|
+
console.error(`
|
|
3372
|
+
Timed out waiting. Once the user has completed the install, re-run:
|
|
3373
|
+
|
|
3374
|
+
clawnify workspace connect`);
|
|
3375
|
+
process.exit(1);
|
|
3376
|
+
}
|
|
3377
|
+
console.log(` \u2713 GitHub account connected: ${installs[0].account}`);
|
|
3378
|
+
}
|
|
3379
|
+
let install = installs[0];
|
|
3380
|
+
if (installs.length > 1) {
|
|
3381
|
+
const match = opts?.account ? installs.find(
|
|
3382
|
+
(i) => String(i.id) === opts.account || i.account.toLowerCase() === opts.account.toLowerCase()
|
|
3383
|
+
) : void 0;
|
|
3384
|
+
if (!match) {
|
|
3385
|
+
console.error(
|
|
3386
|
+
`Multiple GitHub accounts are connected \u2014 pick one with --account:
|
|
3387
|
+
` + installs.map((i) => ` --account ${i.account} (${i.account_type}, id ${i.id})`).join("\n")
|
|
3388
|
+
);
|
|
3389
|
+
process.exit(1);
|
|
3390
|
+
}
|
|
3391
|
+
install = match;
|
|
3392
|
+
}
|
|
3393
|
+
const siteRes = await api.get("/v1/websites", orgOpt);
|
|
3394
|
+
const site = siteRes.ok ? (await siteRes.json()).website ?? {} : {};
|
|
3395
|
+
if (!site.id) {
|
|
3396
|
+
console.error(`This workspace has no website yet \u2014 there is nothing to sync.
|
|
3397
|
+
|
|
3398
|
+
Create the website first (dashboard \u2192 Website), then re-run
|
|
3399
|
+
\`clawnify workspace connect\`.`);
|
|
3400
|
+
process.exit(1);
|
|
3401
|
+
}
|
|
3402
|
+
console.log(`Connecting ${site.slug ?? "website"} via @${install.account}...`);
|
|
3403
|
+
const res = await api.post(
|
|
3404
|
+
"/settings/github/connect",
|
|
3405
|
+
{ website_id: site.id, installation_id: install.id },
|
|
3406
|
+
orgOpt
|
|
3407
|
+
);
|
|
3408
|
+
const data = await res.json().catch(() => ({}));
|
|
3409
|
+
if (!res.ok || !data.repo) {
|
|
3410
|
+
if (data.needsReauth) {
|
|
3411
|
+
console.error(`GitHub authorization expired. Ask the user to reconnect (browser step):
|
|
3412
|
+
|
|
3413
|
+
https://app.clawnify.com/github/reauth?state=website
|
|
3414
|
+
|
|
3415
|
+
then re-run \`clawnify workspace connect\`.`);
|
|
3416
|
+
} else {
|
|
3417
|
+
console.error(`Connect failed: ${data.error ?? `HTTP ${res.status}`}`);
|
|
3418
|
+
}
|
|
3419
|
+
process.exit(1);
|
|
3420
|
+
}
|
|
3421
|
+
console.log(`
|
|
3422
|
+
\u2713 Workspace repo connected: ${data.repo} (branch ${data.branch ?? "main"})
|
|
3423
|
+
|
|
3424
|
+
Clone: git clone https://github.com/${data.repo}.git
|
|
3425
|
+
The website lives under ${data.subdir ?? "website"}/ \u2014 pushes to
|
|
3426
|
+
${data.branch ?? "main"} auto-deploy to the draft site.
|
|
3427
|
+
|
|
3428
|
+
Run \`clawnify workspace\` any time for the full map + editing contract.`);
|
|
3429
|
+
}
|
|
3269
3430
|
|
|
3270
3431
|
// src/commands/execute.ts
|
|
3271
3432
|
import fs7 from "fs";
|
|
@@ -3575,7 +3736,7 @@ async function runCli() {
|
|
|
3575
3736
|
program.command("init [dir]").description("Scaffold a new Clawnify project (app, website, or agent)").option("--type <type>", "Project type: app, website, or agent (skips prompt)").option("--name <name>", "Project name (skips prompt)").option("--template <template>", "App template: blank or crud (apps only)").option("--storage", "Enable file uploads (R2) \u2014 apps only").option("-y, --yes", "Non-interactive: use all defaults (app, blank, no storage)").option("--no-ai-files", "Skip installing AI files (rules + skills + MCP) after scaffolding").action(initCommand);
|
|
3576
3737
|
program.command("dev [dir]").description("Start local dev server").option("--port <port>", "API server port (default: 8787)").action(devCommand);
|
|
3577
3738
|
program.command("login").description("Authenticate with Clawnify").action(loginCommand);
|
|
3578
|
-
program.command("deploy [dir]").description("Deploy an app, website, or agent to Clawnify").option("--from <repo>", "Deploy from a GitHub repo (owner/repo)").option("--server <server-id>", "Agent deploy: the server hosting the target agent (saved as a link)").option("--agent <name>", "Agent deploy: the named agent to push to (default: main)").option("--path <subdir>", "Subdirectory within the --from repo that holds the app (monorepo)").option("--name <name>", "Override app name").option("--org <slug-or-id>", "Deploy to a specific org (overrides active org)").option("-y, --yes", "Non-interactive: on
|
|
3739
|
+
program.command("deploy [dir]").description("Deploy an app, website, or agent to Clawnify").option("--from <repo>", "Deploy from a GitHub repo (owner/repo)").option("--server <server-id>", "Agent deploy: the server hosting the target agent (saved as a link)").option("--agent <name>", "Agent deploy: the named agent to push to (default: main)").option("--path <subdir>", "Subdirectory within the --from repo that holds the app (monorepo)").option("--name <name>", "Override app name").option("--org <slug-or-id>", "Deploy to a specific org (overrides active org)").option("-y, --yes", "Non-interactive: on conflict, update the existing app").option("--update-existing", "Non-interactive: on conflict, overwrite the existing app").option("--create-new", "Non-interactive: on conflict, create a new app with the suggested slug").option("--dry-run", "List files that would be uploaded; do not deploy").option("--no-sync", "Skip the post-deploy schema.sql sync into the local working directory").action(deployCommand);
|
|
3579
3740
|
program.command("link <app-id-or-slug>").description("Link the current directory to an existing Clawnify app (accepts id or slug)").option("--dir <dir>", "Directory to link (default: cwd)").option("--org <slug-or-id>", "Restrict the app lookup to a specific org").action(linkCommand);
|
|
3580
3741
|
const pull = program.command("pull").description("Pull artifacts from a deployed app into the current directory");
|
|
3581
3742
|
pull.command("schema").description("Fetch the deployed app's current schema.sql snapshot into the local repo").option("--from <app-id-or-slug>", "App to fetch from (required)").option("--out <path>", "Where to write (default: ./schema.sql)").option("--force", "Overwrite a locally-modified or uncommitted schema.sql").option("--org <slug-or-id>", "Restrict the app lookup to a specific org").action(pullSchemaCommand);
|
|
@@ -3587,6 +3748,7 @@ async function runCli() {
|
|
|
3587
3748
|
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
3749
|
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
3750
|
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);
|
|
3751
|
+
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
3752
|
program.command("ls").description("List deployed apps").action(lsCommand);
|
|
3591
3753
|
program.command("logs <app-id>").description("Show build logs for an app").action(logsCommand);
|
|
3592
3754
|
const servers = program.command("servers").description("List the org's agent servers");
|
|
@@ -3634,4 +3796,4 @@ async function runCli() {
|
|
|
3634
3796
|
export {
|
|
3635
3797
|
runCli
|
|
3636
3798
|
};
|
|
3637
|
-
//# sourceMappingURL=cli-
|
|
3799
|
+
//# sourceMappingURL=cli-UFUSSG3S.js.map
|