google-stitch-mcp 0.3.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.
Files changed (127) hide show
  1. package/LICENSE +212 -0
  2. package/README.md +439 -0
  3. package/bin/stitch-mcp.js +2 -0
  4. package/dist/cli.d.ts +1 -0
  5. package/dist/cli.js +130810 -0
  6. package/dist/commands/doctor/command.d.ts +2 -0
  7. package/dist/commands/doctor/context.d.ts +19 -0
  8. package/dist/commands/doctor/handler.d.ts +12 -0
  9. package/dist/commands/doctor/spec.d.ts +130 -0
  10. package/dist/commands/doctor/steps/AdcCheckStep.d.ts +8 -0
  11. package/dist/commands/doctor/steps/ApiCheckStep.d.ts +8 -0
  12. package/dist/commands/doctor/steps/ApiKeyConnectionStep.d.ts +8 -0
  13. package/dist/commands/doctor/steps/ApiKeyDetectedStep.d.ts +8 -0
  14. package/dist/commands/doctor/steps/AuthCheckStep.d.ts +8 -0
  15. package/dist/commands/doctor/steps/GcloudCheckStep.d.ts +8 -0
  16. package/dist/commands/doctor/steps/ProjectCheckStep.d.ts +8 -0
  17. package/dist/commands/init/command.d.ts +2 -0
  18. package/dist/commands/init/context.d.ts +24 -0
  19. package/dist/commands/init/handler.d.ts +19 -0
  20. package/dist/commands/init/spec.d.ts +91 -0
  21. package/dist/commands/init/steps/AuthModeStep.d.ts +8 -0
  22. package/dist/commands/init/steps/AuthStep.d.ts +8 -0
  23. package/dist/commands/init/steps/ClientSelectionStep.d.ts +9 -0
  24. package/dist/commands/init/steps/ConfigStep.d.ts +9 -0
  25. package/dist/commands/init/steps/GcloudInstallStep.d.ts +8 -0
  26. package/dist/commands/init/steps/IamApiStep.d.ts +8 -0
  27. package/dist/commands/init/steps/ProjectSelectStep.d.ts +8 -0
  28. package/dist/commands/init/steps/TestConnectionStep.d.ts +8 -0
  29. package/dist/commands/init/steps/TransportStep.d.ts +9 -0
  30. package/dist/commands/logout/command.d.ts +2 -0
  31. package/dist/commands/logout/context.d.ts +12 -0
  32. package/dist/commands/logout/handler.d.ts +8 -0
  33. package/dist/commands/logout/spec.d.ts +77 -0
  34. package/dist/commands/logout/steps/ClearConfigStep.d.ts +8 -0
  35. package/dist/commands/logout/steps/PrepareStep.d.ts +8 -0
  36. package/dist/commands/logout/steps/RevokeAdcStep.d.ts +9 -0
  37. package/dist/commands/logout/steps/RevokeUserStep.d.ts +9 -0
  38. package/dist/commands/proxy/command.d.ts +2 -0
  39. package/dist/commands/proxy/handler.d.ts +7 -0
  40. package/dist/commands/registry.d.ts +2 -0
  41. package/dist/commands/screens/ScreensView.d.ts +16 -0
  42. package/dist/commands/screens/command.d.ts +2 -0
  43. package/dist/commands/screens/handler.d.ts +24 -0
  44. package/dist/commands/serve/ServeView.d.ts +12 -0
  45. package/dist/commands/serve/command.d.ts +2 -0
  46. package/dist/commands/serve/handler.d.ts +22 -0
  47. package/dist/commands/site/command.d.ts +2 -0
  48. package/dist/commands/site/hooks/useProjectHydration.d.ts +9 -0
  49. package/dist/commands/site/index.d.ts +12 -0
  50. package/dist/commands/site/ui/ScreenList.d.ts +11 -0
  51. package/dist/commands/site/ui/SiteBuilder.d.ts +10 -0
  52. package/dist/commands/site/ui/components/StatusIcon.d.ts +6 -0
  53. package/dist/commands/site/ui/types.d.ts +1 -0
  54. package/dist/commands/site/utils/ProjectSyncer.d.ts +8 -0
  55. package/dist/commands/site/utils/SiteManifest.d.ts +16 -0
  56. package/dist/commands/snapshot/command.d.ts +2 -0
  57. package/dist/commands/snapshot/handler.d.ts +17 -0
  58. package/dist/commands/snapshot/spec.d.ts +39 -0
  59. package/dist/commands/tool/command.d.ts +2 -0
  60. package/dist/commands/tool/context.d.ts +9 -0
  61. package/dist/commands/tool/handler.d.ts +9 -0
  62. package/dist/commands/tool/spec.d.ts +39 -0
  63. package/dist/commands/tool/steps/ExecuteToolStep.d.ts +8 -0
  64. package/dist/commands/tool/steps/ListToolsStep.d.ts +8 -0
  65. package/dist/commands/tool/steps/ParseArgsStep.d.ts +8 -0
  66. package/dist/commands/tool/steps/ShowSchemaStep.d.ts +10 -0
  67. package/dist/commands/tool/steps/ValidateToolStep.d.ts +8 -0
  68. package/dist/commands/tool/virtual-tools/build-site.d.ts +2 -0
  69. package/dist/commands/tool/virtual-tools/get-screen-code.d.ts +2 -0
  70. package/dist/commands/tool/virtual-tools/get-screen-image.d.ts +2 -0
  71. package/dist/commands/tool/virtual-tools/index.d.ts +7 -0
  72. package/dist/commands/tool/virtual-tools/list-tools.d.ts +2 -0
  73. package/dist/commands/view/command.d.ts +2 -0
  74. package/dist/commands/view/handler.d.ts +14 -0
  75. package/dist/framework/CommandDefinition.d.ts +18 -0
  76. package/dist/framework/CommandStep.d.ts +15 -0
  77. package/dist/framework/ConsoleUI.d.ts +14 -0
  78. package/dist/framework/MockUI.d.ts +16 -0
  79. package/dist/framework/StepRunner.d.ts +20 -0
  80. package/dist/framework/UserInterface.d.ts +13 -0
  81. package/dist/index.d.ts +13 -0
  82. package/dist/index.js +23583 -0
  83. package/dist/lib/server/AssetGateway.d.ts +25 -0
  84. package/dist/lib/server/vite/StitchViteServer.d.ts +11 -0
  85. package/dist/lib/server/vite/plugins/virtualContent.d.ts +7 -0
  86. package/dist/lib/services/site/SiteService.d.ts +6 -0
  87. package/dist/lib/services/site/schemas.d.ts +91 -0
  88. package/dist/lib/services/site/types.d.ts +22 -0
  89. package/dist/platform/detector.d.ts +29 -0
  90. package/dist/platform/environment.d.ts +13 -0
  91. package/dist/platform/paths.d.ts +20 -0
  92. package/dist/platform/shell.d.ts +30 -0
  93. package/dist/services/gcloud/handler.d.ts +57 -0
  94. package/dist/services/gcloud/spec.d.ts +408 -0
  95. package/dist/services/mcp-client/MockStitchMCPClient.d.ts +7 -0
  96. package/dist/services/mcp-client/client.d.ts +79 -0
  97. package/dist/services/mcp-client/spec.d.ts +27 -0
  98. package/dist/services/mcp-config/handler.d.ts +13 -0
  99. package/dist/services/mcp-config/spec.d.ts +108 -0
  100. package/dist/services/project/handler.d.ts +11 -0
  101. package/dist/services/project/spec.d.ts +86 -0
  102. package/dist/services/proxy/handler.d.ts +26 -0
  103. package/dist/services/proxy/spec.d.ts +83 -0
  104. package/dist/services/stitch/handler.d.ts +17 -0
  105. package/dist/services/stitch/spec.d.ts +279 -0
  106. package/dist/services/view/handler.d.ts +7 -0
  107. package/dist/services/view/spec.d.ts +66 -0
  108. package/dist/ui/InteractiveViewer.d.ts +17 -0
  109. package/dist/ui/JsonTree.d.ts +12 -0
  110. package/dist/ui/checklist/handler.d.ts +23 -0
  111. package/dist/ui/checklist/spec.d.ts +191 -0
  112. package/dist/ui/checklist.d.ts +54 -0
  113. package/dist/ui/copy-behaviors/clipboard.d.ts +32 -0
  114. package/dist/ui/copy-behaviors/handlers.d.ts +16 -0
  115. package/dist/ui/copy-behaviors/index.d.ts +8 -0
  116. package/dist/ui/copy-behaviors/registry.d.ts +24 -0
  117. package/dist/ui/copy-behaviors/types.d.ts +26 -0
  118. package/dist/ui/navigation-behaviors/index.d.ts +34 -0
  119. package/dist/ui/serve-behaviors/handlers.d.ts +9 -0
  120. package/dist/ui/serve-behaviors/index.d.ts +7 -0
  121. package/dist/ui/serve-behaviors/registry.d.ts +10 -0
  122. package/dist/ui/serve-behaviors/server.d.ts +8 -0
  123. package/dist/ui/serve-behaviors/types.d.ts +18 -0
  124. package/dist/ui/spinner.d.ts +11 -0
  125. package/dist/ui/theme.d.ts +18 -0
  126. package/dist/ui/wizard.d.ts +36 -0
  127. package/package.json +83 -0
@@ -0,0 +1,25 @@
1
+ import { Readable } from 'stream';
2
+ export declare class AssetGateway {
3
+ private cacheDir;
4
+ constructor(projectRoot?: string);
5
+ init(): Promise<void>;
6
+ private getHash;
7
+ fetchAsset(url: string): Promise<{
8
+ stream: Readable;
9
+ contentType?: string;
10
+ } | null>;
11
+ rewriteCssUrls(css: string, baseUrl: string): string;
12
+ rewriteHtmlForPreview(html: string): Promise<string>;
13
+ /**
14
+ * Maps common MIME types to file extensions.
15
+ */
16
+ private getExtensionFromContentType;
17
+ rewriteHtmlForBuild(html: string): Promise<{
18
+ html: string;
19
+ assets: {
20
+ url: string;
21
+ filename: string;
22
+ }[];
23
+ }>;
24
+ copyAssetTo(url: string, destPath: string): Promise<boolean>;
25
+ }
@@ -0,0 +1,11 @@
1
+ import { AssetGateway } from '../AssetGateway.js';
2
+ export declare class StitchViteServer {
3
+ private server;
4
+ private htmlMap;
5
+ assetGateway: AssetGateway;
6
+ constructor(projectRoot?: string, assetGateway?: AssetGateway);
7
+ start(port?: number): Promise<string>;
8
+ stop(): Promise<void>;
9
+ mount(route: string, html: string): void;
10
+ navigate(url: string): void;
11
+ }
@@ -0,0 +1,7 @@
1
+ import { type Plugin } from 'vite';
2
+ import { AssetGateway } from '../../AssetGateway.js';
3
+ export interface VirtualContentOptions {
4
+ assetGateway: AssetGateway;
5
+ htmlMap: Map<string, string>;
6
+ }
7
+ export declare function virtualContent({ assetGateway, htmlMap }: VirtualContentOptions): Plugin;
@@ -0,0 +1,6 @@
1
+ import type { RemoteScreen, SiteConfig, IAssetGateway, UIScreen } from './types.js';
2
+ export declare class SiteService {
3
+ static toUIScreens(screens: RemoteScreen[]): UIScreen[];
4
+ static generateSite(config: SiteConfig, htmlContent: Map<string, string>, assetGateway: IAssetGateway, outputDir?: string): Promise<void>;
5
+ static slugify(text: string): string;
6
+ }
@@ -0,0 +1,91 @@
1
+ import { z } from 'zod';
2
+ export declare const RemoteScreenSchema: z.ZodObject<{
3
+ name: z.ZodString;
4
+ title: z.ZodString;
5
+ htmlCode: z.ZodOptional<z.ZodObject<{
6
+ downloadUrl: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ downloadUrl: string;
9
+ }, {
10
+ downloadUrl: string;
11
+ }>>;
12
+ }, "strip", z.ZodTypeAny, {
13
+ name: string;
14
+ title: string;
15
+ htmlCode?: {
16
+ downloadUrl: string;
17
+ } | undefined;
18
+ }, {
19
+ name: string;
20
+ title: string;
21
+ htmlCode?: {
22
+ downloadUrl: string;
23
+ } | undefined;
24
+ }>;
25
+ export declare const SiteRouteSchema: z.ZodObject<{
26
+ screenId: z.ZodString;
27
+ route: z.ZodString;
28
+ status: z.ZodEnum<["included", "ignored"]>;
29
+ warning: z.ZodOptional<z.ZodString>;
30
+ }, "strip", z.ZodTypeAny, {
31
+ status: "included" | "ignored";
32
+ screenId: string;
33
+ route: string;
34
+ warning?: string | undefined;
35
+ }, {
36
+ status: "included" | "ignored";
37
+ screenId: string;
38
+ route: string;
39
+ warning?: string | undefined;
40
+ }>;
41
+ export declare const SiteConfigSchema: z.ZodEffects<z.ZodObject<{
42
+ projectId: z.ZodString;
43
+ routes: z.ZodArray<z.ZodObject<{
44
+ screenId: z.ZodString;
45
+ route: z.ZodString;
46
+ status: z.ZodEnum<["included", "ignored"]>;
47
+ warning: z.ZodOptional<z.ZodString>;
48
+ }, "strip", z.ZodTypeAny, {
49
+ status: "included" | "ignored";
50
+ screenId: string;
51
+ route: string;
52
+ warning?: string | undefined;
53
+ }, {
54
+ status: "included" | "ignored";
55
+ screenId: string;
56
+ route: string;
57
+ warning?: string | undefined;
58
+ }>, "many">;
59
+ }, "strip", z.ZodTypeAny, {
60
+ projectId: string;
61
+ routes: {
62
+ status: "included" | "ignored";
63
+ screenId: string;
64
+ route: string;
65
+ warning?: string | undefined;
66
+ }[];
67
+ }, {
68
+ projectId: string;
69
+ routes: {
70
+ status: "included" | "ignored";
71
+ screenId: string;
72
+ route: string;
73
+ warning?: string | undefined;
74
+ }[];
75
+ }>, {
76
+ projectId: string;
77
+ routes: {
78
+ status: "included" | "ignored";
79
+ screenId: string;
80
+ route: string;
81
+ warning?: string | undefined;
82
+ }[];
83
+ }, {
84
+ projectId: string;
85
+ routes: {
86
+ status: "included" | "ignored";
87
+ screenId: string;
88
+ route: string;
89
+ warning?: string | undefined;
90
+ }[];
91
+ }>;
@@ -0,0 +1,22 @@
1
+ import { z } from 'zod';
2
+ import { RemoteScreenSchema, SiteConfigSchema, SiteRouteSchema } from './schemas.js';
3
+ export type RemoteScreen = z.infer<typeof RemoteScreenSchema>;
4
+ export type SiteRoute = z.infer<typeof SiteRouteSchema>;
5
+ export type SiteConfig = z.infer<typeof SiteConfigSchema>;
6
+ export interface UIScreen {
7
+ id: string;
8
+ title: string;
9
+ downloadUrl: string;
10
+ status: 'included' | 'ignored' | 'discarded';
11
+ route: string;
12
+ }
13
+ export interface IAssetGateway {
14
+ rewriteHtmlForBuild(html: string): Promise<{
15
+ html: string;
16
+ assets: {
17
+ url: string;
18
+ filename: string;
19
+ }[];
20
+ }>;
21
+ copyAssetTo(url: string, destPath: string): Promise<boolean>;
22
+ }
@@ -0,0 +1,29 @@
1
+ export type OS = 'macos' | 'linux' | 'windows';
2
+ export type Arch = 'arm64' | 'x86_64';
3
+ export interface Platform {
4
+ os: OS;
5
+ arch: Arch;
6
+ gcloudDownloadUrl: string;
7
+ gcloudBinaryName: string;
8
+ isWindows: boolean;
9
+ }
10
+ /**
11
+ * Detect the current platform and architecture
12
+ */
13
+ export declare function detectPlatform(): Platform;
14
+ /**
15
+ * Get the user's home directory
16
+ */
17
+ export declare function getHomeDir(): string;
18
+ /**
19
+ * Get the Stitch MCP directory path
20
+ */
21
+ export declare function getStitchDir(): string;
22
+ /**
23
+ * Get the gcloud SDK installation path
24
+ */
25
+ export declare function getGcloudSdkPath(): string;
26
+ /**
27
+ * Get the gcloud config directory path
28
+ */
29
+ export declare function getGcloudConfigPath(): string;
@@ -0,0 +1,13 @@
1
+ export interface EnvironmentInfo {
2
+ isWSL: boolean;
3
+ isSSH: boolean;
4
+ isDocker: boolean;
5
+ isCloudShell: boolean;
6
+ hasDisplay: boolean;
7
+ needsNoBrowser: boolean;
8
+ reason?: string;
9
+ }
10
+ /**
11
+ * Detect environment characteristics that affect browser auth
12
+ */
13
+ export declare function detectEnvironment(): EnvironmentInfo;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Get cross-platform path join
3
+ */
4
+ export declare function joinPath(...parts: string[]): string;
5
+ /**
6
+ * Get the directory name from a path
7
+ */
8
+ export declare function dirname(filepath: string): string;
9
+ /**
10
+ * Get the basename from a path
11
+ */
12
+ export declare function basename(filepath: string): string;
13
+ /**
14
+ * Normalize path separators for the current platform
15
+ */
16
+ export declare function normalizePath(filepath: string): string;
17
+ /**
18
+ * Convert a path to use forward slashes (for consistency)
19
+ */
20
+ export declare function toUnixPath(filepath: string): string;
@@ -0,0 +1,30 @@
1
+ export interface ShellResult {
2
+ success: boolean;
3
+ stdout: string;
4
+ stderr: string;
5
+ exitCode: number;
6
+ error?: string;
7
+ }
8
+ export declare function getSpawnArgs(command: string, args: string[]): {
9
+ cmd: string;
10
+ args: string[];
11
+ };
12
+ /**
13
+ * Execute a shell command and return the result
14
+ */
15
+ export declare function execCommand(command: string[], options?: {
16
+ cwd?: string;
17
+ env?: Record<string, string>;
18
+ timeout?: number;
19
+ }): Promise<ShellResult>;
20
+ /**
21
+ * Execute a shell command and stream output
22
+ */
23
+ export declare function execCommandStreaming(command: string[], onStdout?: (data: string) => void, onStderr?: (data: string) => void, options?: {
24
+ cwd?: string;
25
+ env?: Record<string, string>;
26
+ }): Promise<ShellResult>;
27
+ /**
28
+ * Check if a command exists in PATH
29
+ */
30
+ export declare function commandExists(command: string): Promise<boolean>;
@@ -0,0 +1,57 @@
1
+ import { type GcloudService, type EnsureGcloudInput, type AuthenticateInput, type ListProjectsInput, type SetProjectInput, type GcloudResult, type AuthResult, type ProjectListResult, type ProjectSetResult } from './spec.js';
2
+ export declare class GcloudHandler implements GcloudService {
3
+ private platform;
4
+ private gcloudPath;
5
+ private useSystemGcloud;
6
+ /**
7
+ * Ensure gcloud is installed and available
8
+ */
9
+ ensureInstalled(input: EnsureGcloudInput): Promise<GcloudResult>;
10
+ /**
11
+ * Authenticate user
12
+ */
13
+ authenticate(input: AuthenticateInput): Promise<AuthResult>;
14
+ /**
15
+ * Authenticate application default credentials
16
+ */
17
+ authenticateADC(input: AuthenticateInput): Promise<AuthResult>;
18
+ /**
19
+ * List projects
20
+ */
21
+ listProjects(input: ListProjectsInput): Promise<ProjectListResult>;
22
+ /**
23
+ * Set active project
24
+ */
25
+ setProject(input: SetProjectInput): Promise<ProjectSetResult>;
26
+ /**
27
+ * Get access token
28
+ */
29
+ getAccessToken(): Promise<string | null>;
30
+ /**
31
+ * Get the correct login command with config prefix if using bundled gcloud
32
+ */
33
+ private getLoginCommand;
34
+ getProjectId(): Promise<string | null>;
35
+ /**
36
+ * Install beta components
37
+ */
38
+ installBetaComponents(): Promise<{
39
+ success: boolean;
40
+ error?: {
41
+ message: string;
42
+ };
43
+ }>;
44
+ /**
45
+ * Run the gcloud authentication flow (URL extraction followed by actual login)
46
+ */
47
+ private runAuthFlow;
48
+ private findGlobalGcloud;
49
+ private getVersionFromPath;
50
+ private isVersionValid;
51
+ private installLocal;
52
+ private setupEnvironment;
53
+ private getEnvironment;
54
+ private getGcloudCommand;
55
+ getActiveAccount(): Promise<string | null>;
56
+ hasADC(): Promise<boolean>;
57
+ }