@superdesign/cli 0.1.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/bin/superdesign.js +11 -0
- package/dist/api/auth.d.ts +36 -0
- package/dist/api/client.d.ts +28 -0
- package/dist/api/drafts.d.ts +46 -0
- package/dist/api/jobs.d.ts +73 -0
- package/dist/api/projects.d.ts +33 -0
- package/dist/commands/create-design-draft.d.ts +5 -0
- package/dist/commands/create-project.d.ts +5 -0
- package/dist/commands/execute-flow-pages.d.ts +5 -0
- package/dist/commands/init.d.ts +6 -0
- package/dist/commands/iterate-design-draft.d.ts +5 -0
- package/dist/commands/login.d.ts +5 -0
- package/dist/commands/logout.d.ts +5 -0
- package/dist/commands/plan-flow-pages.d.ts +5 -0
- package/dist/config/constants.d.ts +33 -0
- package/dist/config/manager.d.ts +45 -0
- package/dist/index.cjs +1254 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +1107 -0
- package/dist/skills/superdesign.d.ts +4 -0
- package/dist/utils/ascii-animation.d.ts +17 -0
- package/dist/utils/auth-flow.d.ts +22 -0
- package/dist/utils/job-runner.d.ts +41 -0
- package/dist/utils/open-browser.d.ts +7 -0
- package/dist/utils/output.d.ts +39 -0
- package/dist/utils/poll.d.ts +29 -0
- package/dist/utils/spinner.d.ts +29 -0
- package/package.json +55 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Authentication API endpoints
|
|
3
|
+
*/
|
|
4
|
+
export interface CreateSessionRequest {
|
|
5
|
+
cliVersion?: string;
|
|
6
|
+
os?: string;
|
|
7
|
+
hostname?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface CreateSessionResponse {
|
|
10
|
+
sessionCode: string;
|
|
11
|
+
pollToken: string;
|
|
12
|
+
authUrl: string;
|
|
13
|
+
expiresAt: string;
|
|
14
|
+
}
|
|
15
|
+
export type SessionStatus = 'pending' | 'approved' | 'expired' | 'claimed';
|
|
16
|
+
export interface PollSessionResponse {
|
|
17
|
+
status: SessionStatus;
|
|
18
|
+
apiKey?: string;
|
|
19
|
+
teamId?: string;
|
|
20
|
+
teamName?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface ClaimSessionResponse {
|
|
23
|
+
success: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create a new CLI auth session
|
|
27
|
+
*/
|
|
28
|
+
export declare function createSession(data: CreateSessionRequest): Promise<CreateSessionResponse>;
|
|
29
|
+
/**
|
|
30
|
+
* Poll session status
|
|
31
|
+
*/
|
|
32
|
+
export declare function pollSession(pollToken: string): Promise<PollSessionResponse>;
|
|
33
|
+
/**
|
|
34
|
+
* Claim session (mark as received by CLI)
|
|
35
|
+
*/
|
|
36
|
+
export declare function claimSession(pollToken: string): Promise<ClaimSessionResponse>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Client for SuperDesign Backend
|
|
3
|
+
*/
|
|
4
|
+
import { type AxiosInstance } from 'axios';
|
|
5
|
+
export interface ApiError {
|
|
6
|
+
code: string;
|
|
7
|
+
message: string;
|
|
8
|
+
details?: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
export declare class ApiClientError extends Error {
|
|
11
|
+
code: string;
|
|
12
|
+
status?: number | undefined;
|
|
13
|
+
details?: Record<string, unknown> | undefined;
|
|
14
|
+
constructor(message: string, code: string, status?: number | undefined, details?: Record<string, unknown> | undefined);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Create an API client instance
|
|
18
|
+
* @param requireAuth If true, requires authentication and adds API key header
|
|
19
|
+
*/
|
|
20
|
+
export declare function createApiClient(requireAuth?: boolean): AxiosInstance;
|
|
21
|
+
/**
|
|
22
|
+
* Create a public API client (no auth required)
|
|
23
|
+
*/
|
|
24
|
+
export declare function createPublicApiClient(): AxiosInstance;
|
|
25
|
+
/**
|
|
26
|
+
* Get an authenticated API client
|
|
27
|
+
*/
|
|
28
|
+
export declare function getApiClient(): AxiosInstance;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drafts API endpoints
|
|
3
|
+
*/
|
|
4
|
+
export interface CreateDraftRequest {
|
|
5
|
+
title: string;
|
|
6
|
+
prompt: string;
|
|
7
|
+
deviceMode?: 'mobile' | 'tablet' | 'desktop';
|
|
8
|
+
}
|
|
9
|
+
export interface IterateDraftRequest {
|
|
10
|
+
prompt: string;
|
|
11
|
+
mode: 'replace' | 'branch';
|
|
12
|
+
count?: 1 | 2 | 3 | 4;
|
|
13
|
+
}
|
|
14
|
+
export interface PlanFlowRequest {
|
|
15
|
+
sourceNodeId: string;
|
|
16
|
+
flowContext?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface FlowPage {
|
|
19
|
+
title: string;
|
|
20
|
+
prompt: string;
|
|
21
|
+
}
|
|
22
|
+
export interface ExecuteFlowRequest {
|
|
23
|
+
sourceNodeId: string;
|
|
24
|
+
flowContext?: string;
|
|
25
|
+
pages: FlowPage[];
|
|
26
|
+
}
|
|
27
|
+
export interface JobCreatedResponse {
|
|
28
|
+
jobId: string;
|
|
29
|
+
status: 'processing';
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Create a draft using AI generation (async)
|
|
33
|
+
*/
|
|
34
|
+
export declare function createDraft(projectId: string, data: CreateDraftRequest): Promise<JobCreatedResponse>;
|
|
35
|
+
/**
|
|
36
|
+
* Iterate on a draft using AI (async)
|
|
37
|
+
*/
|
|
38
|
+
export declare function iterateDraft(draftId: string, data: IterateDraftRequest): Promise<JobCreatedResponse>;
|
|
39
|
+
/**
|
|
40
|
+
* Plan flow pages using AI (async)
|
|
41
|
+
*/
|
|
42
|
+
export declare function planFlowPages(draftId: string, data: PlanFlowRequest): Promise<JobCreatedResponse>;
|
|
43
|
+
/**
|
|
44
|
+
* Execute flow pages generation (async)
|
|
45
|
+
*/
|
|
46
|
+
export declare function executeFlowPages(draftId: string, data: ExecuteFlowRequest): Promise<JobCreatedResponse>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jobs API endpoints
|
|
3
|
+
*/
|
|
4
|
+
export interface DraftResultInfo {
|
|
5
|
+
draftId: string;
|
|
6
|
+
nodeId: string;
|
|
7
|
+
title: string;
|
|
8
|
+
nodeUrl: string;
|
|
9
|
+
previewUrl: string;
|
|
10
|
+
}
|
|
11
|
+
export interface IndexedDraftResultInfo extends DraftResultInfo {
|
|
12
|
+
index: number;
|
|
13
|
+
}
|
|
14
|
+
export interface PageSuggestion {
|
|
15
|
+
title: string;
|
|
16
|
+
prompt: string;
|
|
17
|
+
}
|
|
18
|
+
export interface CreateDraftJobResult {
|
|
19
|
+
draftId: string;
|
|
20
|
+
nodeId: string;
|
|
21
|
+
title: string;
|
|
22
|
+
projectUrl: string;
|
|
23
|
+
nodeUrl: string;
|
|
24
|
+
previewUrl: string;
|
|
25
|
+
}
|
|
26
|
+
export interface IterateDraftJobResult {
|
|
27
|
+
drafts: DraftResultInfo[];
|
|
28
|
+
projectUrl: string;
|
|
29
|
+
}
|
|
30
|
+
export interface PlanFlowJobResult {
|
|
31
|
+
pages: PageSuggestion[];
|
|
32
|
+
}
|
|
33
|
+
export interface ExecuteFlowJobResult {
|
|
34
|
+
drafts: IndexedDraftResultInfo[];
|
|
35
|
+
projectUrl: string;
|
|
36
|
+
}
|
|
37
|
+
export interface JobProcessingResponse {
|
|
38
|
+
jobId: string;
|
|
39
|
+
status: 'processing';
|
|
40
|
+
createdAt: string;
|
|
41
|
+
}
|
|
42
|
+
export interface JobCompletedResponse<T = Record<string, unknown>> {
|
|
43
|
+
jobId: string;
|
|
44
|
+
status: 'completed';
|
|
45
|
+
result: T;
|
|
46
|
+
creditsConsumed: number;
|
|
47
|
+
completedAt: string;
|
|
48
|
+
}
|
|
49
|
+
export interface JobFailedResponse {
|
|
50
|
+
jobId: string;
|
|
51
|
+
status: 'failed';
|
|
52
|
+
error: {
|
|
53
|
+
code: string;
|
|
54
|
+
message: string;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export type JobStatusResponse<T = Record<string, unknown>> = JobProcessingResponse | JobCompletedResponse<T> | JobFailedResponse;
|
|
58
|
+
/**
|
|
59
|
+
* Get job status
|
|
60
|
+
*/
|
|
61
|
+
export declare function getJobStatus<T = Record<string, unknown>>(jobId: string): Promise<JobStatusResponse<T>>;
|
|
62
|
+
/**
|
|
63
|
+
* Check if job is done (completed or failed)
|
|
64
|
+
*/
|
|
65
|
+
export declare function isJobDone<T>(response: JobStatusResponse<T>): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Check if job completed successfully
|
|
68
|
+
*/
|
|
69
|
+
export declare function isJobCompleted<T>(response: JobStatusResponse<T>): response is JobCompletedResponse<T>;
|
|
70
|
+
/**
|
|
71
|
+
* Check if job failed
|
|
72
|
+
*/
|
|
73
|
+
export declare function isJobFailed<T>(response: JobStatusResponse<T>): response is JobFailedResponse;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Projects API endpoints
|
|
3
|
+
*/
|
|
4
|
+
export interface CreateProjectRequest {
|
|
5
|
+
title: string;
|
|
6
|
+
}
|
|
7
|
+
export interface CreateProjectResponse {
|
|
8
|
+
projectId: string;
|
|
9
|
+
title: string;
|
|
10
|
+
shareToken?: string;
|
|
11
|
+
projectUrl: string;
|
|
12
|
+
}
|
|
13
|
+
export interface AddDraftRequest {
|
|
14
|
+
title: string;
|
|
15
|
+
html: string;
|
|
16
|
+
deviceMode?: 'mobile' | 'tablet' | 'desktop';
|
|
17
|
+
}
|
|
18
|
+
export interface AddDraftResponse {
|
|
19
|
+
draftId: string;
|
|
20
|
+
nodeId: string;
|
|
21
|
+
title: string;
|
|
22
|
+
projectUrl: string;
|
|
23
|
+
nodeUrl: string;
|
|
24
|
+
previewUrl: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Create a new project
|
|
28
|
+
*/
|
|
29
|
+
export declare function createProject(data: CreateProjectRequest): Promise<CreateProjectResponse>;
|
|
30
|
+
/**
|
|
31
|
+
* Add a draft with HTML content to a project (synchronous, no AI)
|
|
32
|
+
*/
|
|
33
|
+
export declare function addDraft(projectId: string, data: AddDraftRequest): Promise<AddDraftResponse>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Configuration Constants
|
|
3
|
+
*/
|
|
4
|
+
/** Default API base URL */
|
|
5
|
+
export declare const DEFAULT_API_URL = "https://api.superdesign.dev/v1";
|
|
6
|
+
/** Default frontend URL for auth redirect */
|
|
7
|
+
export declare const DEFAULT_FRONTEND_URL = "https://app.superdesign.dev";
|
|
8
|
+
/** Polling configuration */
|
|
9
|
+
export declare const POLL_INTERVAL_MS = 2000;
|
|
10
|
+
export declare const POLL_TIMEOUT_MS: number;
|
|
11
|
+
/** Auth polling configuration */
|
|
12
|
+
export declare const AUTH_POLL_INTERVAL_MS = 2000;
|
|
13
|
+
export declare const AUTH_POLL_TIMEOUT_MS: number;
|
|
14
|
+
/** CLI version - should match package.json */
|
|
15
|
+
export declare const CLI_VERSION = "0.1.0";
|
|
16
|
+
/** Config directory name */
|
|
17
|
+
export declare const CONFIG_DIR_NAME = ".superdesign";
|
|
18
|
+
/** Config file name */
|
|
19
|
+
export declare const CONFIG_FILE_NAME = "config.json";
|
|
20
|
+
/** Exit codes */
|
|
21
|
+
export declare const EXIT_CODES: {
|
|
22
|
+
readonly SUCCESS: 0;
|
|
23
|
+
readonly GENERAL_ERROR: 1;
|
|
24
|
+
readonly AUTH_REQUIRED: 2;
|
|
25
|
+
readonly AUTH_FAILED: 3;
|
|
26
|
+
readonly API_ERROR: 4;
|
|
27
|
+
readonly VALIDATION_ERROR: 5;
|
|
28
|
+
readonly TIMEOUT: 6;
|
|
29
|
+
};
|
|
30
|
+
/** Skill files directory relative to project root */
|
|
31
|
+
export declare const SKILLS_DIR = ".claude/skills/superdesign";
|
|
32
|
+
/** SKILL.md file name */
|
|
33
|
+
export declare const SKILL_FILE_NAME = "SKILL.md";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Configuration structure
|
|
3
|
+
*/
|
|
4
|
+
export interface CliConfig {
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
apiUrl?: string;
|
|
7
|
+
teamId?: string;
|
|
8
|
+
teamName?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Get the config directory path
|
|
12
|
+
*/
|
|
13
|
+
export declare function getConfigDir(): string;
|
|
14
|
+
/**
|
|
15
|
+
* Get the config file path
|
|
16
|
+
*/
|
|
17
|
+
export declare function getConfigPath(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Load configuration from disk
|
|
20
|
+
*/
|
|
21
|
+
export declare function loadConfig(): CliConfig;
|
|
22
|
+
/**
|
|
23
|
+
* Save configuration to disk
|
|
24
|
+
*/
|
|
25
|
+
export declare function saveConfig(config: CliConfig): void;
|
|
26
|
+
/**
|
|
27
|
+
* Update specific config values (merge with existing)
|
|
28
|
+
*/
|
|
29
|
+
export declare function updateConfig(updates: Partial<CliConfig>): CliConfig;
|
|
30
|
+
/**
|
|
31
|
+
* Clear all configuration
|
|
32
|
+
*/
|
|
33
|
+
export declare function clearConfig(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Check if user is authenticated
|
|
36
|
+
*/
|
|
37
|
+
export declare function isAuthenticated(): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Get API key or throw if not authenticated
|
|
40
|
+
*/
|
|
41
|
+
export declare function getApiKey(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Get the API URL (from config or default)
|
|
44
|
+
*/
|
|
45
|
+
export declare function getApiUrl(): string;
|