@primeuicom/mcp 0.1.26 → 0.1.28
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/service.js +145 -201
- package/dist/service.js.map +1 -1
- package/package.json +1 -1
package/dist/service.js
CHANGED
|
@@ -485,42 +485,13 @@ import { unlink } from "fs/promises";
|
|
|
485
485
|
import path5 from "path";
|
|
486
486
|
import { Readable, Transform } from "stream";
|
|
487
487
|
import { pipeline } from "stream/promises";
|
|
488
|
-
import { z as z3 } from "zod";
|
|
489
488
|
|
|
490
|
-
// src/lib/
|
|
491
|
-
import {
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
}
|
|
497
|
-
async function resetDir(dirPath) {
|
|
498
|
-
await rm(dirPath, { recursive: true, force: true });
|
|
499
|
-
await mkdir(dirPath, { recursive: true });
|
|
500
|
-
}
|
|
501
|
-
async function writeUtf8(filePath, content) {
|
|
502
|
-
await ensureDir(path4.dirname(filePath));
|
|
503
|
-
await writeFile(filePath, content, "utf-8");
|
|
504
|
-
}
|
|
505
|
-
async function extractZip(zipPath, targetDir) {
|
|
506
|
-
await ensureDir(targetDir);
|
|
507
|
-
try {
|
|
508
|
-
await extractZipArchive(zipPath, { dir: targetDir });
|
|
509
|
-
} catch (error) {
|
|
510
|
-
const details = error instanceof Error ? error.message : String(error);
|
|
511
|
-
throw new Error(`Failed to extract zip at "${zipPath}". ${details}`);
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
// src/sources/api-provider.ts
|
|
516
|
-
var DEFAULT_API_BASE_URL = "https://app.primeui.com/";
|
|
517
|
-
var ZIP_CONTENT_TYPES = [
|
|
518
|
-
"application/zip",
|
|
519
|
-
"application/octet-stream",
|
|
520
|
-
"application/x-zip-compressed"
|
|
521
|
-
];
|
|
522
|
-
var exportStatusSchema = z3.enum(["in_progress", "completed", "failed"]);
|
|
523
|
-
var projectPageObjectSchema = z3.object({
|
|
489
|
+
// src/lib/api-v1-contract.ts
|
|
490
|
+
import { z as z3 } from "zod";
|
|
491
|
+
var primeUiExportStatusSchema = z3.enum(
|
|
492
|
+
["in_progress", "completed", "failed"]
|
|
493
|
+
);
|
|
494
|
+
var primeUiProjectPageObjectSchema = z3.object({
|
|
524
495
|
id: z3.string(),
|
|
525
496
|
title: z3.string(),
|
|
526
497
|
slug: z3.string(),
|
|
@@ -529,24 +500,29 @@ var projectPageObjectSchema = z3.object({
|
|
|
529
500
|
pagePath: z3.string(),
|
|
530
501
|
componentsPath: z3.string()
|
|
531
502
|
});
|
|
532
|
-
var
|
|
533
|
-
var
|
|
503
|
+
var primeUiProjectPageSchema = primeUiProjectPageObjectSchema;
|
|
504
|
+
var primeUiProjectGlobalComponentSchema = z3.object({
|
|
505
|
+
componentKey: z3.string(),
|
|
506
|
+
description: z3.string(),
|
|
507
|
+
isReadyToExport: z3.boolean()
|
|
508
|
+
});
|
|
509
|
+
var primeUiExportSummarySchema = z3.object({
|
|
534
510
|
total: z3.number(),
|
|
535
511
|
successful: z3.number(),
|
|
536
512
|
failed: z3.number()
|
|
537
513
|
});
|
|
538
|
-
var
|
|
514
|
+
var primeUiExportedComponentSchema = z3.object({
|
|
539
515
|
componentKey: z3.string(),
|
|
540
|
-
|
|
516
|
+
isReadyToExport: z3.boolean(),
|
|
541
517
|
files: z3.array(z3.string()),
|
|
542
518
|
message: z3.string()
|
|
543
519
|
});
|
|
544
|
-
var
|
|
520
|
+
var primeUiExportPageManifestSchema = z3.object({
|
|
545
521
|
success: z3.boolean(),
|
|
546
522
|
message: z3.string(),
|
|
547
523
|
files: z3.array(z3.string())
|
|
548
524
|
});
|
|
549
|
-
var
|
|
525
|
+
var primeUiExportPageSchema = z3.object({
|
|
550
526
|
id: z3.string(),
|
|
551
527
|
title: z3.string().optional(),
|
|
552
528
|
slug: z3.string(),
|
|
@@ -554,51 +530,107 @@ var exportPageSchema = z3.object({
|
|
|
554
530
|
isReadyToExport: z3.literal(true),
|
|
555
531
|
pagePath: z3.string(),
|
|
556
532
|
componentsPath: z3.string(),
|
|
557
|
-
manifest:
|
|
558
|
-
});
|
|
559
|
-
var projectInfoSchema = z3.object({
|
|
560
|
-
projectId: z3.string(),
|
|
561
|
-
projectName: z3.string(),
|
|
562
|
-
metadata: z3.record(z3.unknown()),
|
|
563
|
-
pages: z3.array(projectPageSchema)
|
|
533
|
+
manifest: primeUiExportPageManifestSchema
|
|
564
534
|
});
|
|
565
|
-
var
|
|
535
|
+
var primeUiProjectInfoSchema = z3.object(
|
|
536
|
+
{
|
|
537
|
+
projectId: z3.string(),
|
|
538
|
+
projectName: z3.string(),
|
|
539
|
+
metadata: z3.record(z3.unknown()),
|
|
540
|
+
components: z3.array(primeUiProjectGlobalComponentSchema),
|
|
541
|
+
pages: z3.array(primeUiProjectPageSchema)
|
|
542
|
+
}
|
|
543
|
+
);
|
|
544
|
+
var primeUiProjectPageComponentSchema = z3.object({
|
|
566
545
|
blockId: z3.string(),
|
|
567
546
|
componentId: z3.string(),
|
|
568
547
|
componentGroup: z3.string(),
|
|
569
548
|
slot: z3.string().nullable(),
|
|
570
549
|
props: z3.record(z3.unknown()).nullable()
|
|
571
550
|
});
|
|
572
|
-
var
|
|
573
|
-
page:
|
|
551
|
+
var primeUiProjectPageDetailsSchema = z3.object({
|
|
552
|
+
page: primeUiProjectPageObjectSchema.extend({
|
|
574
553
|
pageInstruction: z3.string().nullable()
|
|
575
554
|
}),
|
|
576
555
|
variant: z3.object({
|
|
577
556
|
id: z3.string(),
|
|
578
557
|
name: z3.string()
|
|
579
558
|
}).nullable(),
|
|
580
|
-
components: z3.array(
|
|
559
|
+
components: z3.array(primeUiProjectPageComponentSchema).nullable()
|
|
581
560
|
});
|
|
582
|
-
var
|
|
561
|
+
var primeUiExportsResponseSchema = z3.object({
|
|
583
562
|
exports: z3.array(
|
|
584
563
|
z3.object({
|
|
585
564
|
id: z3.string(),
|
|
586
|
-
status:
|
|
565
|
+
status: primeUiExportStatusSchema,
|
|
587
566
|
createdAt: z3.string().datetime({ offset: true })
|
|
588
567
|
})
|
|
589
568
|
)
|
|
590
569
|
});
|
|
591
|
-
var
|
|
570
|
+
var primeUiCreateExportResponseSchema = z3.object({
|
|
592
571
|
export: z3.object({
|
|
593
572
|
id: z3.string(),
|
|
594
|
-
status:
|
|
573
|
+
status: primeUiExportStatusSchema,
|
|
595
574
|
createdAt: z3.string().datetime({ offset: true }),
|
|
596
575
|
expiresAt: z3.string().datetime({ offset: true }).nullable(),
|
|
597
|
-
summary:
|
|
598
|
-
components: z3.array(
|
|
576
|
+
summary: primeUiExportSummarySchema,
|
|
577
|
+
components: z3.array(primeUiExportedComponentSchema)
|
|
599
578
|
}),
|
|
600
|
-
pages: z3.array(
|
|
579
|
+
pages: z3.array(primeUiExportPageSchema)
|
|
601
580
|
});
|
|
581
|
+
var primeUiExportManifestSchema = primeUiCreateExportResponseSchema;
|
|
582
|
+
function parsePrimeUiExportManifest(value) {
|
|
583
|
+
if (!value || typeof value !== "object") {
|
|
584
|
+
throw new Error("Export manifest is invalid.");
|
|
585
|
+
}
|
|
586
|
+
const maybe = value;
|
|
587
|
+
if (!maybe.export || typeof maybe.export !== "object") {
|
|
588
|
+
throw new Error("Export manifest export payload is invalid.");
|
|
589
|
+
}
|
|
590
|
+
const parsed = primeUiExportManifestSchema.safeParse(value);
|
|
591
|
+
if (!parsed.success) {
|
|
592
|
+
const hasPageIssue = parsed.error.issues.some(
|
|
593
|
+
(issue) => issue.path[0] === "pages"
|
|
594
|
+
);
|
|
595
|
+
throw new Error(
|
|
596
|
+
hasPageIssue ? "Export manifest pages payload is invalid." : "Export manifest does not match expected schema."
|
|
597
|
+
);
|
|
598
|
+
}
|
|
599
|
+
return parsed.data;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
// src/lib/fs.ts
|
|
603
|
+
import { mkdir, rm, writeFile } from "fs/promises";
|
|
604
|
+
import path4 from "path";
|
|
605
|
+
import extractZipArchive from "extract-zip";
|
|
606
|
+
async function ensureDir(dirPath) {
|
|
607
|
+
await mkdir(dirPath, { recursive: true });
|
|
608
|
+
}
|
|
609
|
+
async function resetDir(dirPath) {
|
|
610
|
+
await rm(dirPath, { recursive: true, force: true });
|
|
611
|
+
await mkdir(dirPath, { recursive: true });
|
|
612
|
+
}
|
|
613
|
+
async function writeUtf8(filePath, content) {
|
|
614
|
+
await ensureDir(path4.dirname(filePath));
|
|
615
|
+
await writeFile(filePath, content, "utf-8");
|
|
616
|
+
}
|
|
617
|
+
async function extractZip(zipPath, targetDir) {
|
|
618
|
+
await ensureDir(targetDir);
|
|
619
|
+
try {
|
|
620
|
+
await extractZipArchive(zipPath, { dir: targetDir });
|
|
621
|
+
} catch (error) {
|
|
622
|
+
const details = error instanceof Error ? error.message : String(error);
|
|
623
|
+
throw new Error(`Failed to extract zip at "${zipPath}". ${details}`);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
// src/sources/api-provider.ts
|
|
628
|
+
var DEFAULT_API_BASE_URL = "https://app.primeui.com/";
|
|
629
|
+
var ZIP_CONTENT_TYPES = [
|
|
630
|
+
"application/zip",
|
|
631
|
+
"application/octet-stream",
|
|
632
|
+
"application/x-zip-compressed"
|
|
633
|
+
];
|
|
602
634
|
var PrimeUiApiContractError = class extends Error {
|
|
603
635
|
constructor(endpoint, details) {
|
|
604
636
|
super(`PrimeUI API contract mismatch for "${endpoint}": ${details}`);
|
|
@@ -683,26 +715,30 @@ var ApiProjectDataProvider = class {
|
|
|
683
715
|
this.apiRoot = normalizePrimeUiApiRoot(options.baseUrl);
|
|
684
716
|
}
|
|
685
717
|
async getProjectInfo() {
|
|
686
|
-
return this.requestJson("project",
|
|
718
|
+
return this.requestJson("project", primeUiProjectInfoSchema);
|
|
687
719
|
}
|
|
688
720
|
async getProjectPageBySlug(slug) {
|
|
689
721
|
const encodedSlug = encodeURIComponent(slug);
|
|
690
722
|
return this.requestJson(
|
|
691
723
|
`project/page?slug=${encodedSlug}`,
|
|
692
|
-
|
|
724
|
+
primeUiProjectPageDetailsSchema
|
|
693
725
|
);
|
|
694
726
|
}
|
|
695
727
|
async listExports() {
|
|
696
728
|
const response = await this.requestJson(
|
|
697
729
|
"project/exports",
|
|
698
|
-
|
|
730
|
+
primeUiExportsResponseSchema
|
|
699
731
|
);
|
|
700
732
|
return response.exports;
|
|
701
733
|
}
|
|
702
734
|
async createExport() {
|
|
703
|
-
return this.requestJson(
|
|
704
|
-
|
|
705
|
-
|
|
735
|
+
return this.requestJson(
|
|
736
|
+
"project/exports",
|
|
737
|
+
primeUiCreateExportResponseSchema,
|
|
738
|
+
{
|
|
739
|
+
method: "POST"
|
|
740
|
+
}
|
|
741
|
+
);
|
|
706
742
|
}
|
|
707
743
|
/**
|
|
708
744
|
* Consumer-side runtime contract for GET /api/v1/project/exports/:exportId/download.
|
|
@@ -2000,68 +2036,15 @@ async function fileExists2(filePath) {
|
|
|
2000
2036
|
return false;
|
|
2001
2037
|
}
|
|
2002
2038
|
}
|
|
2003
|
-
function isExportPageManifestRecord(value) {
|
|
2004
|
-
if (!value || typeof value !== "object") {
|
|
2005
|
-
return false;
|
|
2006
|
-
}
|
|
2007
|
-
const maybe = value;
|
|
2008
|
-
return typeof maybe.success === "boolean" && typeof maybe.message === "string" && Array.isArray(maybe.files) && maybe.files.every((item) => typeof item === "string");
|
|
2009
|
-
}
|
|
2010
|
-
function isExportStatus(value) {
|
|
2011
|
-
return value === "in_progress" || value === "completed" || value === "failed";
|
|
2012
|
-
}
|
|
2013
|
-
function isExportSummaryRecord(value) {
|
|
2014
|
-
if (!value || typeof value !== "object") {
|
|
2015
|
-
return false;
|
|
2016
|
-
}
|
|
2017
|
-
const maybe = value;
|
|
2018
|
-
return typeof maybe.total === "number" && typeof maybe.successful === "number" && typeof maybe.failed === "number";
|
|
2019
|
-
}
|
|
2020
|
-
function isExportedComponentRecord(value) {
|
|
2021
|
-
if (!value || typeof value !== "object") {
|
|
2022
|
-
return false;
|
|
2023
|
-
}
|
|
2024
|
-
const maybe = value;
|
|
2025
|
-
return typeof maybe.componentKey === "string" && typeof maybe.enabled === "boolean" && Array.isArray(maybe.files) && maybe.files.every((item) => typeof item === "string") && typeof maybe.message === "string";
|
|
2026
|
-
}
|
|
2027
|
-
function isExportPageRecord(value) {
|
|
2028
|
-
if (!value || typeof value !== "object") {
|
|
2029
|
-
return false;
|
|
2030
|
-
}
|
|
2031
|
-
const maybe = value;
|
|
2032
|
-
const title = maybe.title;
|
|
2033
|
-
return typeof maybe.id === "string" && (typeof title === "string" || typeof title === "undefined") && typeof maybe.slug === "string" && typeof maybe.pageType === "string" && maybe.isReadyToExport === true && typeof maybe.pagePath === "string" && typeof maybe.componentsPath === "string" && isExportPageManifestRecord(maybe.manifest);
|
|
2034
|
-
}
|
|
2035
2039
|
function parseManifest(value) {
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
}
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
throw
|
|
2043
|
-
}
|
|
2044
|
-
const exportObject = exportPayload;
|
|
2045
|
-
const status = exportObject.status;
|
|
2046
|
-
const summary = exportObject.summary;
|
|
2047
|
-
const components = exportObject.components;
|
|
2048
|
-
if (typeof exportObject.id !== "string" || !isExportStatus(status) || typeof exportObject.createdAt !== "string" || !("expiresAt" in exportObject) || !(typeof exportObject.expiresAt === "string" || exportObject.expiresAt === null) || !isExportSummaryRecord(summary) || !Array.isArray(components) || !components.every(isExportedComponentRecord) || !Array.isArray(maybe.pages)) {
|
|
2049
|
-
throw new Error("Export manifest does not match expected schema.");
|
|
2050
|
-
}
|
|
2051
|
-
if (!maybe.pages.every(isExportPageRecord)) {
|
|
2052
|
-
throw new Error("Export manifest pages payload is invalid.");
|
|
2040
|
+
try {
|
|
2041
|
+
return parsePrimeUiExportManifest(value);
|
|
2042
|
+
} catch (error) {
|
|
2043
|
+
if (error instanceof Error && error.message === "Export manifest is invalid.") {
|
|
2044
|
+
throw new Error("Invalid export manifest format.");
|
|
2045
|
+
}
|
|
2046
|
+
throw error;
|
|
2053
2047
|
}
|
|
2054
|
-
return {
|
|
2055
|
-
export: {
|
|
2056
|
-
id: exportObject.id,
|
|
2057
|
-
status,
|
|
2058
|
-
createdAt: exportObject.createdAt,
|
|
2059
|
-
expiresAt: exportObject.expiresAt,
|
|
2060
|
-
summary,
|
|
2061
|
-
components
|
|
2062
|
-
},
|
|
2063
|
-
pages: maybe.pages
|
|
2064
|
-
};
|
|
2065
2048
|
}
|
|
2066
2049
|
async function resolveManifestCandidateFiles(input) {
|
|
2067
2050
|
const result = /* @__PURE__ */ new Set();
|
|
@@ -2486,72 +2469,9 @@ function buildInspectPageReport(input) {
|
|
|
2486
2469
|
}
|
|
2487
2470
|
|
|
2488
2471
|
// src/services/project-sync-service.ts
|
|
2489
|
-
function isExportStatus2(value) {
|
|
2490
|
-
return value === "in_progress" || value === "completed" || value === "failed";
|
|
2491
|
-
}
|
|
2492
|
-
function isExportSummary(value) {
|
|
2493
|
-
if (!value || typeof value !== "object") {
|
|
2494
|
-
return false;
|
|
2495
|
-
}
|
|
2496
|
-
const maybe = value;
|
|
2497
|
-
return typeof maybe.total === "number" && typeof maybe.successful === "number" && typeof maybe.failed === "number";
|
|
2498
|
-
}
|
|
2499
|
-
function isExportedComponent(value) {
|
|
2500
|
-
if (!value || typeof value !== "object") {
|
|
2501
|
-
return false;
|
|
2502
|
-
}
|
|
2503
|
-
const maybe = value;
|
|
2504
|
-
return typeof maybe.componentKey === "string" && typeof maybe.enabled === "boolean" && Array.isArray(maybe.files) && maybe.files.every((item) => typeof item === "string") && typeof maybe.message === "string";
|
|
2505
|
-
}
|
|
2506
|
-
function isExportPageManifest(value) {
|
|
2507
|
-
if (!value || typeof value !== "object") {
|
|
2508
|
-
return false;
|
|
2509
|
-
}
|
|
2510
|
-
const maybe = value;
|
|
2511
|
-
return typeof maybe.success === "boolean" && typeof maybe.message === "string" && Array.isArray(maybe.files) && maybe.files.every((item) => typeof item === "string");
|
|
2512
|
-
}
|
|
2513
|
-
function isExportPage(value) {
|
|
2514
|
-
if (!value || typeof value !== "object") {
|
|
2515
|
-
return false;
|
|
2516
|
-
}
|
|
2517
|
-
const maybe = value;
|
|
2518
|
-
const title = maybe.title;
|
|
2519
|
-
return typeof maybe.id === "string" && (typeof title === "string" || typeof title === "undefined") && typeof maybe.slug === "string" && typeof maybe.pageType === "string" && maybe.isReadyToExport === true && typeof maybe.pagePath === "string" && typeof maybe.componentsPath === "string" && isExportPageManifest(maybe.manifest);
|
|
2520
|
-
}
|
|
2521
2472
|
function buildManifestPath(exportsRoot, exportId) {
|
|
2522
2473
|
return path10.join(exportsRoot, `${exportId}.manifest.json`);
|
|
2523
2474
|
}
|
|
2524
|
-
function parseExportManifest(value) {
|
|
2525
|
-
if (!value || typeof value !== "object") {
|
|
2526
|
-
throw new Error("Export manifest is invalid.");
|
|
2527
|
-
}
|
|
2528
|
-
const maybe = value;
|
|
2529
|
-
const exportPayload = maybe.export;
|
|
2530
|
-
if (!exportPayload || typeof exportPayload !== "object") {
|
|
2531
|
-
throw new Error("Export manifest export payload is invalid.");
|
|
2532
|
-
}
|
|
2533
|
-
const exportObject = exportPayload;
|
|
2534
|
-
const status = exportObject.status;
|
|
2535
|
-
const summary = exportObject.summary;
|
|
2536
|
-
const components = exportObject.components;
|
|
2537
|
-
if (typeof exportObject.id !== "string" || !isExportStatus2(status) || typeof exportObject.createdAt !== "string" || !("expiresAt" in exportObject) || !(typeof exportObject.expiresAt === "string" || exportObject.expiresAt === null) || !isExportSummary(summary) || !Array.isArray(components) || !components.every(isExportedComponent) || !Array.isArray(maybe.pages)) {
|
|
2538
|
-
throw new Error("Export manifest does not match expected schema.");
|
|
2539
|
-
}
|
|
2540
|
-
if (!maybe.pages.every(isExportPage)) {
|
|
2541
|
-
throw new Error("Export manifest pages payload is invalid.");
|
|
2542
|
-
}
|
|
2543
|
-
return {
|
|
2544
|
-
export: {
|
|
2545
|
-
id: exportObject.id,
|
|
2546
|
-
status,
|
|
2547
|
-
createdAt: exportObject.createdAt,
|
|
2548
|
-
expiresAt: exportObject.expiresAt,
|
|
2549
|
-
summary,
|
|
2550
|
-
components
|
|
2551
|
-
},
|
|
2552
|
-
pages: maybe.pages
|
|
2553
|
-
};
|
|
2554
|
-
}
|
|
2555
2475
|
var ProjectSyncService = class {
|
|
2556
2476
|
provider;
|
|
2557
2477
|
projectRoot;
|
|
@@ -2595,7 +2515,7 @@ var ProjectSyncService = class {
|
|
|
2595
2515
|
const manifestPath = buildManifestPath(this.exportsRoot, id);
|
|
2596
2516
|
let manifest;
|
|
2597
2517
|
try {
|
|
2598
|
-
manifest =
|
|
2518
|
+
manifest = parsePrimeUiExportManifest(
|
|
2599
2519
|
JSON.parse(await readFile4(manifestPath, "utf-8"))
|
|
2600
2520
|
);
|
|
2601
2521
|
} catch (error) {
|
|
@@ -2771,35 +2691,42 @@ var pageSchema = z4.object({
|
|
|
2771
2691
|
}).describe(
|
|
2772
2692
|
"PrimeUI page descriptor used by project and export tools. Paths are always relative to export project root."
|
|
2773
2693
|
);
|
|
2774
|
-
var
|
|
2694
|
+
var exportStatusSchema = z4.enum(["in_progress", "completed", "failed"]).describe(
|
|
2775
2695
|
"Export lifecycle state. Use 'completed' before calling download_export."
|
|
2776
2696
|
);
|
|
2777
2697
|
var exportItemSchema = z4.object({
|
|
2778
2698
|
id: z4.string().describe(
|
|
2779
2699
|
"Export identifier. Pass this value to download_export input.id."
|
|
2780
2700
|
),
|
|
2781
|
-
status:
|
|
2701
|
+
status: exportStatusSchema,
|
|
2782
2702
|
createdAt: z4.string().describe("Export creation timestamp in ISO-8601 UTC format.")
|
|
2783
2703
|
}).describe("Single export record from PrimeUI export history.");
|
|
2784
|
-
var
|
|
2704
|
+
var exportSummarySchema = z4.object({
|
|
2785
2705
|
total: z4.number().describe("Total pages processed in this export run."),
|
|
2786
2706
|
successful: z4.number().describe("Number of pages exported successfully."),
|
|
2787
2707
|
failed: z4.number().describe("Number of pages that failed export.")
|
|
2788
2708
|
});
|
|
2789
2709
|
var exportComponentSchema = z4.object({
|
|
2790
2710
|
componentKey: z4.string().describe("Global component key from export manifest."),
|
|
2791
|
-
|
|
2711
|
+
isReadyToExport: z4.boolean().describe("True when this global component was exported in this run."),
|
|
2792
2712
|
files: z4.array(z4.string()).describe("Files associated with this global component."),
|
|
2793
2713
|
message: z4.string().describe("Export status message for this global component.")
|
|
2794
2714
|
});
|
|
2795
|
-
var
|
|
2715
|
+
var projectGlobalComponentSchema = z4.object({
|
|
2716
|
+
componentKey: z4.string().describe("Stable global component key from PrimeUI project info."),
|
|
2717
|
+
description: z4.string().describe("Human-readable explanation of what this global component does."),
|
|
2718
|
+
isReadyToExport: z4.boolean().describe(
|
|
2719
|
+
"True when this global component is currently configured to be included in export."
|
|
2720
|
+
)
|
|
2721
|
+
});
|
|
2722
|
+
var exportPageManifestSchema = z4.object({
|
|
2796
2723
|
success: z4.boolean().describe("True when page export succeeded in this export run."),
|
|
2797
2724
|
message: z4.string().describe("Export status message for this page."),
|
|
2798
2725
|
files: z4.array(z4.string()).describe(
|
|
2799
2726
|
"Authoritative list of page-related files from PrimeUI export manifest, including shared project files required by this page."
|
|
2800
2727
|
)
|
|
2801
2728
|
});
|
|
2802
|
-
var
|
|
2729
|
+
var exportPageSchema = z4.object({
|
|
2803
2730
|
id: z4.string().describe("Stable PrimeUI page identifier for this export entry."),
|
|
2804
2731
|
title: z4.string().optional().describe(
|
|
2805
2732
|
"Optional page title from export manifest. Can be undefined for some legacy records."
|
|
@@ -2809,7 +2736,7 @@ var exportPageSchema2 = z4.object({
|
|
|
2809
2736
|
isReadyToExport: z4.literal(true).describe("Always true for pages included in export payload."),
|
|
2810
2737
|
pagePath: z4.string().describe("Page source file path relative to export root."),
|
|
2811
2738
|
componentsPath: z4.string().describe("Page components directory path relative to export root."),
|
|
2812
|
-
manifest:
|
|
2739
|
+
manifest: exportPageManifestSchema
|
|
2813
2740
|
});
|
|
2814
2741
|
var fileTransferSchema = z4.object({
|
|
2815
2742
|
sourcePath: z4.string().describe("Relative source file path inside downloaded export root."),
|
|
@@ -2872,7 +2799,7 @@ var projectRootInputSchema = z4.string().optional().describe(
|
|
|
2872
2799
|
);
|
|
2873
2800
|
var optionalProjectRootInputObjectSchema = z4.object({
|
|
2874
2801
|
projectRoot: projectRootInputSchema
|
|
2875
|
-
}).
|
|
2802
|
+
}).describe("Optional tool input with project root override.");
|
|
2876
2803
|
var TRIGGER_PHRASES = [
|
|
2877
2804
|
"import page from PrimeUI",
|
|
2878
2805
|
"add page from PrimeUI",
|
|
@@ -2964,6 +2891,9 @@ ${WORKFLOW_SUMMARY}`,
|
|
|
2964
2891
|
metadata: z4.record(z4.unknown()).describe(
|
|
2965
2892
|
"Additional project metadata from PrimeUI. May include project-description and other context fields."
|
|
2966
2893
|
),
|
|
2894
|
+
components: z4.array(projectGlobalComponentSchema).describe(
|
|
2895
|
+
"All global components visible for this project context. Use isReadyToExport to tell whether each component would be included in export right now."
|
|
2896
|
+
),
|
|
2967
2897
|
pages: z4.array(pageSchema).describe(
|
|
2968
2898
|
"All pages visible for this project context. Filter by user request and isReadyToExport before creating export."
|
|
2969
2899
|
)
|
|
@@ -3069,19 +2999,19 @@ ${WORKFLOW_SUMMARY}`,
|
|
|
3069
2999
|
id: z4.string().describe(
|
|
3070
3000
|
"Freshly created export identifier. Use this as download_export input.id."
|
|
3071
3001
|
),
|
|
3072
|
-
status:
|
|
3002
|
+
status: exportStatusSchema,
|
|
3073
3003
|
createdAt: z4.string().describe("Export creation timestamp in ISO-8601 UTC format."),
|
|
3074
3004
|
expiresAt: z4.string().nullable().describe(
|
|
3075
3005
|
"Export expiration timestamp in ISO-8601 UTC format, or null when export has no explicit expiration."
|
|
3076
3006
|
),
|
|
3077
|
-
summary:
|
|
3007
|
+
summary: exportSummarySchema.describe(
|
|
3078
3008
|
"Export run summary with total/successful/failed counters."
|
|
3079
3009
|
),
|
|
3080
3010
|
components: z4.array(exportComponentSchema).describe(
|
|
3081
3011
|
"Global component export manifest. These components are independent from page-level manifests."
|
|
3082
3012
|
)
|
|
3083
3013
|
}).describe("Created export summary."),
|
|
3084
|
-
pages: z4.array(
|
|
3014
|
+
pages: z4.array(exportPageSchema).describe(
|
|
3085
3015
|
"Strict page payload associated with this export, including per-page manifest files list."
|
|
3086
3016
|
)
|
|
3087
3017
|
}),
|
|
@@ -3129,7 +3059,7 @@ AFTER DOWNLOAD:
|
|
|
3129
3059
|
manifestPath: z4.string().describe(
|
|
3130
3060
|
"Absolute path to sidecar export manifest file (.primeui/temp/exports/[exportId].manifest.json) saved by create_export and required by copy_page."
|
|
3131
3061
|
),
|
|
3132
|
-
pages: z4.array(
|
|
3062
|
+
pages: z4.array(exportPageSchema).describe(
|
|
3133
3063
|
"Page descriptors loaded from local sidecar export manifest for import decisions."
|
|
3134
3064
|
)
|
|
3135
3065
|
}),
|
|
@@ -3240,6 +3170,12 @@ ${WORKFLOW_SUMMARY}`,
|
|
|
3240
3170
|
};
|
|
3241
3171
|
|
|
3242
3172
|
// src/server.ts
|
|
3173
|
+
var ZERO_ARG_PROJECT_ROOT_TOOLS = /* @__PURE__ */ new Set([
|
|
3174
|
+
"get_project_info",
|
|
3175
|
+
"list_exports",
|
|
3176
|
+
"create_export",
|
|
3177
|
+
"clear_temp"
|
|
3178
|
+
]);
|
|
3243
3179
|
function serializeToolData(data) {
|
|
3244
3180
|
try {
|
|
3245
3181
|
return JSON.stringify(data, null, 2);
|
|
@@ -3292,6 +3228,14 @@ function createPrimeUiMcpServer(source) {
|
|
|
3292
3228
|
instructions: initialInstructions
|
|
3293
3229
|
}
|
|
3294
3230
|
);
|
|
3231
|
+
const serverWithValidationShim = server;
|
|
3232
|
+
const validateToolInput = serverWithValidationShim.validateToolInput.bind(server);
|
|
3233
|
+
serverWithValidationShim.validateToolInput = async (tool, args, toolName) => {
|
|
3234
|
+
if (args === void 0 && ZERO_ARG_PROJECT_ROOT_TOOLS.has(toolName)) {
|
|
3235
|
+
return validateToolInput(tool, {}, toolName);
|
|
3236
|
+
}
|
|
3237
|
+
return validateToolInput(tool, args, toolName);
|
|
3238
|
+
};
|
|
3295
3239
|
server.registerTool(
|
|
3296
3240
|
"get_project_info",
|
|
3297
3241
|
toolGetProjectInfo,
|