clawnify 0.17.0 → 0.19.0
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/{chunk-HESCKUK4.js → chunk-PL5QYOO3.js} +2 -2
- package/dist/{cli-MFJLZHMN.js → cli-HOY7B3PC.js} +78 -26
- package/dist/cli-HOY7B3PC.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/{mcp-FHWCMB35.js → mcp-QYF3ISEZ.js} +2 -2
- package/package.json +1 -1
- package/dist/cli-MFJLZHMN.js.map +0 -1
- /package/dist/{chunk-HESCKUK4.js.map → chunk-PL5QYOO3.js.map} +0 -0
- /package/dist/{mcp-FHWCMB35.js.map → mcp-QYF3ISEZ.js.map} +0 -0
|
@@ -619,7 +619,7 @@ async function pollUntilReady(resourceId, options = {}) {
|
|
|
619
619
|
}
|
|
620
620
|
|
|
621
621
|
// src/version.ts
|
|
622
|
-
var VERSION = "0.
|
|
622
|
+
var VERSION = "0.19.0";
|
|
623
623
|
|
|
624
624
|
export {
|
|
625
625
|
OAUTH_CLIENT_ID,
|
|
@@ -643,4 +643,4 @@ export {
|
|
|
643
643
|
pollUntilReady,
|
|
644
644
|
VERSION
|
|
645
645
|
};
|
|
646
|
-
//# sourceMappingURL=chunk-
|
|
646
|
+
//# sourceMappingURL=chunk-PL5QYOO3.js.map
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
resolveOrgContext,
|
|
21
21
|
saveAuth,
|
|
22
22
|
saveProject
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-PL5QYOO3.js";
|
|
24
24
|
|
|
25
25
|
// src/cli.ts
|
|
26
26
|
import { Command, Option } from "commander";
|
|
@@ -652,6 +652,40 @@ async function uploadWebsiteDeploy(archive, name, orgId, sync) {
|
|
|
652
652
|
const err = await res.json().catch(() => ({}));
|
|
653
653
|
return { ok: false, error: err.error || res.statusText };
|
|
654
654
|
}
|
|
655
|
+
async function websiteToReplace(orgId, linkedWebsiteId) {
|
|
656
|
+
const opts = orgId ? { orgId } : void 0;
|
|
657
|
+
const res = await api.get("/v1/websites", opts);
|
|
658
|
+
if (!res.ok) {
|
|
659
|
+
console.error(
|
|
660
|
+
`Could not check this organization's existing website (HTTP ${res.status}). Retry, or pass --replace to deploy anyway.`
|
|
661
|
+
);
|
|
662
|
+
process.exit(1);
|
|
663
|
+
}
|
|
664
|
+
const { website } = await res.json();
|
|
665
|
+
if (!website || website.id === linkedWebsiteId) return null;
|
|
666
|
+
const links = await api.get("/v1/github/links", opts);
|
|
667
|
+
if (links.ok) {
|
|
668
|
+
const data = await links.json();
|
|
669
|
+
if (data.links?.some((l) => l.target.type === "website" && l.target.slug === website.slug)) return null;
|
|
670
|
+
}
|
|
671
|
+
return { slug: website.slug };
|
|
672
|
+
}
|
|
673
|
+
async function refuseWebsiteReplace(orgId, linkedWebsiteId, options) {
|
|
674
|
+
if (options.replace) return;
|
|
675
|
+
const existing = await websiteToReplace(orgId, linkedWebsiteId);
|
|
676
|
+
if (!existing) return;
|
|
677
|
+
console.error(
|
|
678
|
+
`This organization already has a website (${existing.slug}), and this folder isn't linked to it.
|
|
679
|
+
Deploying replaces that site's pages, theme and code with this folder. The live site
|
|
680
|
+
stays up until someone publishes.
|
|
681
|
+
|
|
682
|
+
To edit the existing site: use the website editor in the dashboard, or ask an admin
|
|
683
|
+
to connect GitHub and work in a clone of the workspace repo.
|
|
684
|
+
To replace it on purpose: run this again with --replace.
|
|
685
|
+
`
|
|
686
|
+
);
|
|
687
|
+
process.exit(EXIT_CONFLICT_NEEDS_DECISION);
|
|
688
|
+
}
|
|
655
689
|
async function deployWebsite(dir, options) {
|
|
656
690
|
if (options.from) {
|
|
657
691
|
console.error("--from is app-only for now. Run `clawnify deploy` inside the website project directory.");
|
|
@@ -744,13 +778,23 @@ async function deployWebsite(dir, options) {
|
|
|
744
778
|
if (files.length > preview.length) {
|
|
745
779
|
console.log(` ... and ${files.length - preview.length} more`);
|
|
746
780
|
}
|
|
781
|
+
const existing = options.replace || linkedProject?.anon ? null : await websiteToReplace(orgId, linkedProject?.website_id);
|
|
782
|
+
if (existing) {
|
|
783
|
+
console.log(
|
|
784
|
+
`
|
|
785
|
+
Note: this would replace the organization's existing website (${existing.slug}).
|
|
786
|
+
A real deploy refuses unless you pass --replace.`
|
|
787
|
+
);
|
|
788
|
+
}
|
|
747
789
|
console.log();
|
|
748
790
|
return;
|
|
749
791
|
}
|
|
792
|
+
if (!linkedProject?.anon) await refuseWebsiteReplace(orgId, linkedProject?.website_id, options);
|
|
750
793
|
console.log(linkedProject?.website_id ? `Updating ${baseName}...` : `Deploying ${baseName}...`);
|
|
751
794
|
let result = await uploadWebsiteDeploy(archive, baseName, orgId, { dir: resolvedDir, force: options.force });
|
|
752
795
|
if (!result.ok && result.error === "org_not_accessible" && linkedProject?.anon) {
|
|
753
796
|
orgId = await healStaleAnonLink(resolvedDir, linkedProject.anon);
|
|
797
|
+
await refuseWebsiteReplace(orgId, void 0, options);
|
|
754
798
|
result = await uploadWebsiteDeploy(archive, baseName, orgId, { dir: resolvedDir, force: options.force });
|
|
755
799
|
}
|
|
756
800
|
if (!result.ok) {
|
|
@@ -1710,7 +1754,7 @@ function agentByName(name) {
|
|
|
1710
1754
|
var ALL_AGENTS = DETECTORS.map((d) => d.agent);
|
|
1711
1755
|
|
|
1712
1756
|
// src/lib/skills/content.gen.ts
|
|
1713
|
-
var CLI_VERSION = "0.
|
|
1757
|
+
var CLI_VERSION = "0.19.0";
|
|
1714
1758
|
var BUNDLED_SKILLS = [
|
|
1715
1759
|
{
|
|
1716
1760
|
name: "build-a-clawnify-app",
|
|
@@ -2275,7 +2319,7 @@ async function initApp(dir, opts) {
|
|
|
2275
2319
|
deploy: "clawnify deploy"
|
|
2276
2320
|
},
|
|
2277
2321
|
dependencies: {
|
|
2278
|
-
"@clawnify/app": "^0.
|
|
2322
|
+
"@clawnify/app": "^0.2.2",
|
|
2279
2323
|
"@clawnify/db": "^0.4.1",
|
|
2280
2324
|
"@hono/zod-openapi": "^0.19.0",
|
|
2281
2325
|
hono: "^4.0.0",
|
|
@@ -2732,8 +2776,8 @@ logs/
|
|
|
2732
2776
|
console.log();
|
|
2733
2777
|
}
|
|
2734
2778
|
function writeBlankTemplate(dir, name) {
|
|
2735
|
-
write(dir, "src/server/routes.ts", `import { OpenAPIHono, createRoute, z } from "@clawnify/app";
|
|
2736
|
-
import { getDB, desc } from "@clawnify/db";
|
|
2779
|
+
write(dir, "src/server/routes.ts", `import { OpenAPIHono, createRoute, z, PageQuery, pageParams, pagedResponse } from "@clawnify/app";
|
|
2780
|
+
import { getDB, desc, like } from "@clawnify/db";
|
|
2737
2781
|
import * as schema from "./schema";
|
|
2738
2782
|
|
|
2739
2783
|
type Env = { Bindings: { DB: D1Database } };
|
|
@@ -2750,20 +2794,24 @@ api.openapi(
|
|
|
2750
2794
|
method: "get",
|
|
2751
2795
|
path: "/api/items",
|
|
2752
2796
|
summary: "List items",
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
},
|
|
2758
|
-
},
|
|
2797
|
+
// Every list endpoint pages: an agent reads this API through one tool,
|
|
2798
|
+
// and an unbounded list would land in its context whole.
|
|
2799
|
+
request: { query: PageQuery },
|
|
2800
|
+
responses: { 200: pagedResponse("items", ItemSchema) },
|
|
2759
2801
|
}),
|
|
2760
2802
|
async (c) => {
|
|
2803
|
+
const { page, limit, offset, search } = pageParams(c.req.valid("query"));
|
|
2761
2804
|
const db = getDB(c.env, { schema });
|
|
2805
|
+
const where = search ? like(schema.items.name, "%" + search + "%") : undefined;
|
|
2806
|
+
const total = await db.$count(schema.items, where);
|
|
2762
2807
|
const items = await db
|
|
2763
2808
|
.select()
|
|
2764
2809
|
.from(schema.items)
|
|
2765
|
-
.
|
|
2766
|
-
|
|
2810
|
+
.where(where)
|
|
2811
|
+
.orderBy(desc(schema.items.createdAt))
|
|
2812
|
+
.limit(limit)
|
|
2813
|
+
.offset(offset);
|
|
2814
|
+
return c.json({ items, total, page, limit }, 200);
|
|
2767
2815
|
},
|
|
2768
2816
|
);
|
|
2769
2817
|
|
|
@@ -2820,8 +2868,8 @@ export const items = sqliteTable("items", {
|
|
|
2820
2868
|
createdAt: text("created_at").notNull().$default(() => new Date().toISOString()),
|
|
2821
2869
|
});
|
|
2822
2870
|
`);
|
|
2823
|
-
write(dir, "src/server/routes.ts", `import { OpenAPIHono, createRoute, z } from "@clawnify/app";
|
|
2824
|
-
import { getDB, eq, desc } from "@clawnify/db";
|
|
2871
|
+
write(dir, "src/server/routes.ts", `import { OpenAPIHono, createRoute, z, PageQuery, pageParams, pagedResponse } from "@clawnify/app";
|
|
2872
|
+
import { getDB, eq, desc, like } from "@clawnify/db";
|
|
2825
2873
|
import * as schema from "./schema";
|
|
2826
2874
|
|
|
2827
2875
|
type Env = { Bindings: { DB: D1Database } };
|
|
@@ -2847,20 +2895,24 @@ api.openapi(
|
|
|
2847
2895
|
method: "get",
|
|
2848
2896
|
path: "/api/items",
|
|
2849
2897
|
summary: "List items",
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
},
|
|
2855
|
-
},
|
|
2898
|
+
// Every list endpoint pages: an agent reads this API through one tool,
|
|
2899
|
+
// and an unbounded list would land in its context whole.
|
|
2900
|
+
request: { query: PageQuery },
|
|
2901
|
+
responses: { 200: pagedResponse("items", ItemSchema) },
|
|
2856
2902
|
}),
|
|
2857
2903
|
async (c) => {
|
|
2904
|
+
const { page, limit, offset, search } = pageParams(c.req.valid("query"));
|
|
2858
2905
|
const db = getDB(c.env, { schema });
|
|
2906
|
+
const where = search ? like(schema.items.title, "%" + search + "%") : undefined;
|
|
2907
|
+
const total = await db.$count(schema.items, where);
|
|
2859
2908
|
const items = await db
|
|
2860
2909
|
.select()
|
|
2861
2910
|
.from(schema.items)
|
|
2862
|
-
.
|
|
2863
|
-
|
|
2911
|
+
.where(where)
|
|
2912
|
+
.orderBy(desc(schema.items.createdAt))
|
|
2913
|
+
.limit(limit)
|
|
2914
|
+
.offset(offset);
|
|
2915
|
+
return c.json({ items, total, page, limit }, 200);
|
|
2864
2916
|
},
|
|
2865
2917
|
);
|
|
2866
2918
|
|
|
@@ -2949,7 +3001,7 @@ export function App() {
|
|
|
2949
3001
|
|
|
2950
3002
|
async function load() {
|
|
2951
3003
|
const res = await fetch("/api/items");
|
|
2952
|
-
setItems(await res.json());
|
|
3004
|
+
setItems(((await res.json()) as { items: Item[] }).items);
|
|
2953
3005
|
}
|
|
2954
3006
|
|
|
2955
3007
|
useEffect(() => { load(); }, []);
|
|
@@ -4343,7 +4395,7 @@ async function runCli() {
|
|
|
4343
4395
|
"--agent-id <id>",
|
|
4344
4396
|
"Agent deploy: which agent to push to when the org has several (saved as a link)"
|
|
4345
4397
|
)
|
|
4346
|
-
).addOption(legacyServerOption()).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").option("--force", "Deploy even if it would overwrite newer changes in the synced GitHub repo").action(deployCommand);
|
|
4398
|
+
).addOption(legacyServerOption()).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").option("--force", "Deploy even if it would overwrite newer changes in the synced GitHub repo").option("--replace", "Website deploy: replace the organization's existing website with this folder, which isn't linked to it").action(deployCommand);
|
|
4347
4399
|
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);
|
|
4348
4400
|
const pull = program.command("pull").description("Pull artifacts from a deployed app into the current directory");
|
|
4349
4401
|
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);
|
|
@@ -4409,4 +4461,4 @@ async function runCli() {
|
|
|
4409
4461
|
export {
|
|
4410
4462
|
runCli
|
|
4411
4463
|
};
|
|
4412
|
-
//# sourceMappingURL=cli-
|
|
4464
|
+
//# sourceMappingURL=cli-HOY7B3PC.js.map
|