@sudajs/cli 0.8.0 → 0.8.2
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/index.d.ts +1 -0
- package/dist/index.js +32 -24
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/templates/theme/AGENTS.md +82 -0
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1405,34 +1405,38 @@ async function createAgentPage(options) {
|
|
|
1405
1405
|
return;
|
|
1406
1406
|
}
|
|
1407
1407
|
const auth = await requireCliBaseUrl();
|
|
1408
|
-
const
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
);
|
|
1408
|
+
const request = {
|
|
1409
|
+
projectId: options.projectId,
|
|
1410
|
+
title: options.title,
|
|
1411
|
+
slug: options.slug,
|
|
1412
|
+
themeKey: manifest.manifest.key,
|
|
1413
|
+
themeVersion: manifest.manifest.version,
|
|
1414
|
+
data: pageContent
|
|
1415
|
+
};
|
|
1416
|
+
if (options.home === true) {
|
|
1417
|
+
request.isHome = true;
|
|
1418
|
+
}
|
|
1419
|
+
const response = await createRemotePageDraft(auth, request, fetchJson);
|
|
1420
1420
|
printJson({ success: true, ...response });
|
|
1421
1421
|
}
|
|
1422
1422
|
async function createRemotePageDraft(auth, input, fetcher = fetchJson) {
|
|
1423
|
+
const body = {
|
|
1424
|
+
title: input.title,
|
|
1425
|
+
slug: input.slug,
|
|
1426
|
+
themeKey: input.themeKey,
|
|
1427
|
+
themeVersion: input.themeVersion,
|
|
1428
|
+
data: input.data
|
|
1429
|
+
};
|
|
1430
|
+
if (input.isHome !== void 0) {
|
|
1431
|
+
body.isHome = input.isHome;
|
|
1432
|
+
}
|
|
1423
1433
|
return fetcher(
|
|
1424
1434
|
`${auth.baseUrl}/api/cli/agent/projects/${encodeURIComponent(input.projectId)}/pages`,
|
|
1425
1435
|
{
|
|
1426
1436
|
method: "POST",
|
|
1427
1437
|
token: auth.token,
|
|
1428
1438
|
headers: { "Content-Type": "application/json" },
|
|
1429
|
-
body: JSON.stringify(
|
|
1430
|
-
title: input.title,
|
|
1431
|
-
slug: input.slug,
|
|
1432
|
-
themeKey: input.themeKey,
|
|
1433
|
-
themeVersion: input.themeVersion,
|
|
1434
|
-
data: input.data
|
|
1435
|
-
})
|
|
1439
|
+
body: JSON.stringify(body)
|
|
1436
1440
|
}
|
|
1437
1441
|
);
|
|
1438
1442
|
}
|
|
@@ -1701,18 +1705,19 @@ async function startMcpServer() {
|
|
|
1701
1705
|
server.registerTool(
|
|
1702
1706
|
"create_page_draft",
|
|
1703
1707
|
{
|
|
1704
|
-
description: "Create a new workspace page draft from AI-generated Suda page content.",
|
|
1708
|
+
description: "Create a new workspace page draft from AI-generated Suda page content. When creating a complete website, mark exactly one primary landing page with isHome: true so it becomes the public homepage at `/`. After this tool succeeds, tell the user the page is only a draft, explain that they can review it in the SudaCloud workspace by navigating to Pages, opening the created page, previewing it, then clicking Publish, and ask whether they want you to publish it now. Do not call publish_page until the user explicitly confirms.",
|
|
1705
1709
|
inputSchema: {
|
|
1706
1710
|
projectId: z.string(),
|
|
1707
1711
|
title: z.string(),
|
|
1708
1712
|
slug: z.string(),
|
|
1713
|
+
isHome: z.boolean().optional().describe("Set true for exactly one page that should serve as the public homepage at `/`."),
|
|
1709
1714
|
theme: z.string(),
|
|
1710
1715
|
data: z.unknown(),
|
|
1711
1716
|
version: z.string().optional()
|
|
1712
1717
|
},
|
|
1713
1718
|
outputSchema: createPageDraftOutputSchema
|
|
1714
1719
|
},
|
|
1715
|
-
async ({ projectId, title, slug, theme, data, version }) => {
|
|
1720
|
+
async ({ projectId, title, slug, isHome, theme, data, version }) => {
|
|
1716
1721
|
const manifest = await fetchAgentManifest(theme, { version, projectId });
|
|
1717
1722
|
const validation = validateAgentPageContentWithManifest(data, manifest);
|
|
1718
1723
|
if (!validation.valid) {
|
|
@@ -1730,12 +1735,13 @@ async function startMcpServer() {
|
|
|
1730
1735
|
projectId,
|
|
1731
1736
|
title,
|
|
1732
1737
|
slug,
|
|
1738
|
+
isHome,
|
|
1733
1739
|
themeKey: manifest.manifest.key,
|
|
1734
1740
|
themeVersion: manifest.manifest.version,
|
|
1735
1741
|
data
|
|
1736
1742
|
});
|
|
1737
1743
|
return mcpStructured(
|
|
1738
|
-
"Created Suda page draft.",
|
|
1744
|
+
"Created Suda page draft. Tell the user they can review it in the SudaCloud workspace under Pages by opening the created page, previewing it, then clicking Publish. Ask whether they want you to publish it now before calling publish_page.",
|
|
1739
1745
|
createPageDraftOutputSchema.parse({ status: "created", ...response })
|
|
1740
1746
|
);
|
|
1741
1747
|
}
|
|
@@ -1810,7 +1816,7 @@ async function startMcpServer() {
|
|
|
1810
1816
|
server.registerTool(
|
|
1811
1817
|
"publish_page",
|
|
1812
1818
|
{
|
|
1813
|
-
description: "Publish the current saved draft for a Suda page by slug. This affects the public site: first call without confirm to get the exact project, slug, and impact; only call again with confirm: true after the user explicitly agrees.",
|
|
1819
|
+
description: "Publish the current saved draft for a Suda page by slug. This affects the public site: first call without confirm to get the exact project, slug, and impact; only call again with confirm: true after the user explicitly agrees. If the user wants to review manually first, tell them to open the SudaCloud workspace, navigate to Pages, open the created page, preview it, then click Publish.",
|
|
1814
1820
|
inputSchema: {
|
|
1815
1821
|
projectId: z.string(),
|
|
1816
1822
|
slug: z.string(),
|
|
@@ -2386,7 +2392,9 @@ function buildProgram() {
|
|
|
2386
2392
|
agentPage.command("validate").description("Validate an AI-generated Suda page content JSON document.").requiredOption("--theme <theme>", "Theme key.").requiredOption("--input <file>", "JSON file containing Suda page content.").option("--version <version>", "Theme version.").option("--project-id <projectId>", "Project scope.").option("--theme-root <path>", "Read a local theme.").action(async (options) => {
|
|
2387
2393
|
await validateAgentPage(options.theme, options.input, options);
|
|
2388
2394
|
});
|
|
2389
|
-
agentPage.command("create").description(
|
|
2395
|
+
agentPage.command("create").description(
|
|
2396
|
+
"Create a workspace page draft from AI-generated Suda page content JSON. Review it in Pages, then preview and publish from the workspace."
|
|
2397
|
+
).requiredOption("--project-id <projectId>", "Project id.").requiredOption("--title <title>", "Page title.").requiredOption("--slug <slug>", "Page slug.").requiredOption("--theme <theme>", "Theme key.").requiredOption("--input <file>", "JSON file containing Suda page content.").option("--version <version>", "Theme version.").option("--home", "Mark this page draft as the project's homepage.").action(async (options) => {
|
|
2390
2398
|
await createAgentPage(options);
|
|
2391
2399
|
});
|
|
2392
2400
|
const agentSection = agent.command("section").description("Inspect a single section.");
|