magicpath-ai 1.4.1 → 1.5.0-beta.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 (88) hide show
  1. package/dist/cli.js +139 -52
  2. package/package.json +6 -7
  3. package/dist/cli.d.ts +0 -2
  4. package/dist/cli.js.map +0 -1
  5. package/dist/commands/add.d.ts +0 -48
  6. package/dist/commands/add.js +0 -451
  7. package/dist/commands/add.js.map +0 -1
  8. package/dist/commands/auth.d.ts +0 -7
  9. package/dist/commands/auth.js +0 -189
  10. package/dist/commands/auth.js.map +0 -1
  11. package/dist/commands/clone.d.ts +0 -2
  12. package/dist/commands/clone.js +0 -241
  13. package/dist/commands/clone.js.map +0 -1
  14. package/dist/commands/get-theme.d.ts +0 -2
  15. package/dist/commands/get-theme.js +0 -132
  16. package/dist/commands/get-theme.js.map +0 -1
  17. package/dist/commands/info.d.ts +0 -2
  18. package/dist/commands/info.js +0 -134
  19. package/dist/commands/info.js.map +0 -1
  20. package/dist/commands/inspect.d.ts +0 -53
  21. package/dist/commands/inspect.js +0 -122
  22. package/dist/commands/inspect.js.map +0 -1
  23. package/dist/commands/list-installed.d.ts +0 -2
  24. package/dist/commands/list-installed.js +0 -112
  25. package/dist/commands/list-installed.js.map +0 -1
  26. package/dist/commands/list-themes.d.ts +0 -2
  27. package/dist/commands/list-themes.js +0 -94
  28. package/dist/commands/list-themes.js.map +0 -1
  29. package/dist/commands/list.d.ts +0 -2
  30. package/dist/commands/list.js +0 -216
  31. package/dist/commands/list.js.map +0 -1
  32. package/dist/commands/schema.d.ts +0 -2
  33. package/dist/commands/schema.js +0 -292
  34. package/dist/commands/schema.js.map +0 -1
  35. package/dist/commands/search.d.ts +0 -2
  36. package/dist/commands/search.js +0 -124
  37. package/dist/commands/search.js.map +0 -1
  38. package/dist/commands/selection.d.ts +0 -2
  39. package/dist/commands/selection.js +0 -157
  40. package/dist/commands/selection.js.map +0 -1
  41. package/dist/commands/setup-skills.d.ts +0 -2
  42. package/dist/commands/setup-skills.js +0 -13
  43. package/dist/commands/setup-skills.js.map +0 -1
  44. package/dist/commands/view.d.ts +0 -2
  45. package/dist/commands/view.js +0 -27
  46. package/dist/commands/view.js.map +0 -1
  47. package/dist/commands/whoami.d.ts +0 -2
  48. package/dist/commands/whoami.js +0 -66
  49. package/dist/commands/whoami.js.map +0 -1
  50. package/dist/util/api.d.ts +0 -17
  51. package/dist/util/api.js +0 -49
  52. package/dist/util/api.js.map +0 -1
  53. package/dist/util/auth.d.ts +0 -26
  54. package/dist/util/auth.js +0 -113
  55. package/dist/util/auth.js.map +0 -1
  56. package/dist/util/authError.d.ts +0 -4
  57. package/dist/util/authError.js +0 -7
  58. package/dist/util/authError.js.map +0 -1
  59. package/dist/util/banner.d.ts +0 -1
  60. package/dist/util/banner.js +0 -79
  61. package/dist/util/banner.js.map +0 -1
  62. package/dist/util/component.d.ts +0 -186
  63. package/dist/util/component.js +0 -349
  64. package/dist/util/component.js.map +0 -1
  65. package/dist/util/dependencies.d.ts +0 -12
  66. package/dist/util/dependencies.js +0 -93
  67. package/dist/util/dependencies.js.map +0 -1
  68. package/dist/util/error.d.ts +0 -9
  69. package/dist/util/error.js +0 -10
  70. package/dist/util/error.js.map +0 -1
  71. package/dist/util/ide.d.ts +0 -3
  72. package/dist/util/ide.js +0 -145
  73. package/dist/util/ide.js.map +0 -1
  74. package/dist/util/liveblocks.d.ts +0 -24
  75. package/dist/util/liveblocks.js +0 -112
  76. package/dist/util/liveblocks.js.map +0 -1
  77. package/dist/util/logger.d.ts +0 -7
  78. package/dist/util/logger.js +0 -21
  79. package/dist/util/logger.js.map +0 -1
  80. package/dist/util/output.d.ts +0 -15
  81. package/dist/util/output.js +0 -36
  82. package/dist/util/output.js.map +0 -1
  83. package/dist/util/project.d.ts +0 -3
  84. package/dist/util/project.js +0 -64
  85. package/dist/util/project.js.map +0 -1
  86. package/dist/util/ui.d.ts +0 -11
  87. package/dist/util/ui.js +0 -30
  88. package/dist/util/ui.js.map +0 -1
package/dist/util/auth.js DELETED
@@ -1,113 +0,0 @@
1
- import fs from 'fs-extra';
2
- import path from 'path';
3
- import os from 'os';
4
- import { readFileSync } from 'fs';
5
- import axios from 'axios';
6
- import { getUserUrl } from './api.js';
7
- const pkg = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8'));
8
- const CONFIG_DIR = path.join(os.homedir(), '.magicpath');
9
- const SESSION_FILE = path.join(CONFIG_DIR, 'session.json');
10
- // ── Internal helpers ─────────────────────────────────────
11
- function loadSession() {
12
- try {
13
- if (!fs.existsSync(SESSION_FILE))
14
- return null;
15
- const data = fs.readJsonSync(SESSION_FILE);
16
- if (data.accessToken && data.refreshToken)
17
- return data;
18
- return null;
19
- }
20
- catch {
21
- return null;
22
- }
23
- }
24
- function saveSession(session) {
25
- fs.ensureDirSync(CONFIG_DIR);
26
- fs.writeJsonSync(SESSION_FILE, session);
27
- }
28
- // ── Public API ───────────────────────────────────────────
29
- export function saveTokens(accessToken, refreshToken) {
30
- const existing = loadSession();
31
- saveSession({ accessToken, refreshToken, user: existing?.user });
32
- }
33
- export function loadTokens() {
34
- const session = loadSession();
35
- if (!session)
36
- return null;
37
- return {
38
- accessToken: session.accessToken,
39
- refreshToken: session.refreshToken,
40
- };
41
- }
42
- export function clearSession() {
43
- try {
44
- fs.removeSync(SESSION_FILE);
45
- }
46
- catch {
47
- // Ignore if file doesn't exist
48
- }
49
- }
50
- /** @deprecated Use clearSession() instead. */
51
- export const clearTokens = clearSession;
52
- /** @deprecated Use clearSession() instead. */
53
- export const clearUserInfo = clearSession;
54
- export function saveUserInfo(info) {
55
- try {
56
- const session = loadSession();
57
- if (session) {
58
- session.user = info;
59
- saveSession(session);
60
- }
61
- }
62
- catch {
63
- // non-critical, ignore
64
- }
65
- }
66
- export function loadUserInfo() {
67
- const session = loadSession();
68
- return session?.user ?? null;
69
- }
70
- export function getAuthHeaders() {
71
- // Environment variable takes precedence (for CI/CD and AI agents)
72
- const envToken = process.env.MAGICPATH_TOKEN;
73
- if (envToken) {
74
- return {
75
- Authorization: `Bearer ${envToken}`,
76
- 'X-Client-Type': 'cli',
77
- 'X-Client-Version': pkg.version,
78
- };
79
- }
80
- const tokens = loadTokens();
81
- if (!tokens) {
82
- throw new Error('Not logged in. Run `magicpath-ai login` first.');
83
- }
84
- return {
85
- Authorization: `Bearer ${tokens.accessToken}`,
86
- 'X-Client-Type': 'cli',
87
- 'X-Client-Version': pkg.version,
88
- };
89
- }
90
- /** Extract CachedUserInfo from a raw API user object and save to session. */
91
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
92
- export function cacheUserFromResponse(user) {
93
- const plan = user.subscription?.active
94
- ? user.subscription.type?.startsWith('PRO')
95
- ? 'Pro'
96
- : 'Creator'
97
- : 'Free';
98
- const info = {
99
- name: user.name || user.firstName || user.displayName,
100
- email: user.email,
101
- plan,
102
- };
103
- saveUserInfo(info);
104
- return info;
105
- }
106
- /** Fetch current user from API, cache the result, and return it. */
107
- export async function fetchAndCacheUser() {
108
- const headers = getAuthHeaders();
109
- const response = await axios.get(getUserUrl(), { headers });
110
- const user = response.data.user ?? response.data;
111
- return cacheUserFromResponse(user);
112
- }
113
- //# sourceMappingURL=auth.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/util/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CACpB,YAAY,CAAC,IAAI,GAAG,CAAC,oBAAoB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CA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,CAAC,IAAS;IAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM;QACpC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC;YACzC,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,SAAS;QACb,CAAC,CAAC,MAAM,CAAC;IACX,MAAM,IAAI,GAAmB;QAC3B,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,WAAW;QACrD,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,IAAI;KACL,CAAC;IACF,YAAY,CAAC,IAAI,CAAC,CAAC;IACnB,OAAO,IAAI,CAAC;AACd,CAAC;AAED,oEAAoE;AACpE,MAAM,CAAC,KAAK,UAAU,iBAAiB;IACrC,MAAM,OAAO,GAAG,cAAc,EAAE,CAAC;IACjC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAC5D,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC;IACjD,OAAO,qBAAqB,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC"}
@@ -1,4 +0,0 @@
1
- import { MagicPathError } from './error.js';
2
- export declare class AuthRequiredError extends MagicPathError {
3
- constructor();
4
- }
@@ -1,7 +0,0 @@
1
- import { MagicPathError } from './error.js';
2
- export class AuthRequiredError extends MagicPathError {
3
- constructor() {
4
- super('You must be logged in to install components.');
5
- }
6
- }
7
- //# sourceMappingURL=authError.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"authError.js","sourceRoot":"","sources":["../../src/util/authError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,OAAO,iBAAkB,SAAQ,cAAc;IACnD;QACE,KAAK,CAAC,8CAA8C,CAAC,CAAC;IACxD,CAAC;CACF"}
@@ -1 +0,0 @@
1
- export declare function showBanner(version: string): void;
@@ -1,79 +0,0 @@
1
- import chalk from 'chalk';
2
- import { loadTokens, loadUserInfo } from './auth.js';
3
- const GRADIENT_HEX = [
4
- '#95D5B2',
5
- '#74C69D',
6
- '#52B788',
7
- '#40916C',
8
- '#2D6A4F',
9
- '#1B4332',
10
- ];
11
- function gradientColor(step) {
12
- return chalk.hex(GRADIENT_HEX[Math.min(step, GRADIENT_HEX.length - 1)]);
13
- }
14
- const G1 = chalk.hex('#2D6A4F');
15
- const G2 = chalk.hex('#1B4332');
16
- const WH = chalk.hex('#E8F5E9');
17
- const DM = chalk.hex('#888888');
18
- const MAGIC = [
19
- '███╗ ███╗ █████╗ ██████╗ ██╗ ██████╗',
20
- '████╗ ████║██╔══██╗██╔════╝ ██║██╔════╝',
21
- '██╔████╔██║███████║██║ ███╗██║██║ ',
22
- '██║╚██╔╝██║██╔══██║██║ ██║██║██║ ',
23
- '██║ ╚═╝ ██║██║ ██║╚██████╔╝██║╚██████╗',
24
- '╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝',
25
- ];
26
- const PATH = [
27
- '██████╗ █████╗ ████████╗██╗ ██╗',
28
- '██╔══██╗██╔══██╗╚══██╔══╝██║ ██║',
29
- '██████╔╝███████║ ██║ ███████║',
30
- '██╔═══╝ ██╔══██║ ██║ ██╔══██║',
31
- '██║ ██║ ██║ ██║ ██║ ██║',
32
- '╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝',
33
- ];
34
- const SPRITE = MAGIC.map((row, i) => row + ' ' + PATH[i]);
35
- function styleSprite(rows) {
36
- return rows.map((row, y) => {
37
- const colorFn = gradientColor(y);
38
- let out = '';
39
- for (const ch of row) {
40
- out += ch === ' ' ? ch : colorFn(ch);
41
- }
42
- return out;
43
- });
44
- }
45
- export function showBanner(version) {
46
- const loggedIn = !!loadTokens();
47
- const user = loggedIn ? loadUserInfo() : null;
48
- console.log();
49
- for (const row of styleSprite(SPRITE)) {
50
- console.log(row);
51
- }
52
- console.log();
53
- if (loggedIn && user) {
54
- const planLabel = user.plan ? ` · ${user.plan}` : '';
55
- console.log(' ' +
56
- G1('●') +
57
- ' ' +
58
- chalk.bold(WH(user.name ?? 'MagicPath User')) +
59
- G2(' ' + (user.email ?? '') + planLabel));
60
- }
61
- else {
62
- console.log(' ' + DM('○ Not logged in · run') + ' ' + G1('magicpath-ai login'));
63
- }
64
- console.log();
65
- const CMD_W = 20;
66
- const cmds = [
67
- ['search <query>', 'Search components'],
68
- ['add <name>', 'Add to project'],
69
- ['list-projects', 'Your projects'],
70
- ['setup-skills', 'Set up AI agents'],
71
- ];
72
- for (const [cmd, desc] of cmds) {
73
- console.log(' ' + G1(cmd.padEnd(CMD_W)) + DM(desc));
74
- }
75
- console.log();
76
- console.log(' ' + DM(`v${version} ─ magicpath-ai --help`));
77
- console.log();
78
- }
79
- //# sourceMappingURL=banner.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"banner.js","sourceRoot":"","sources":["../../src/util/banner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAErD,MAAM,YAAY,GAAG;IACnB,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;CACV,CAAC;AAEF,SAAS,aAAa,CAAC,IAAY;IACjC,OAAO,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1E,CAAC;AAED,MAAM,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AAChC,MAAM,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AAChC,MAAM,E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AAE,CAAC,IAAI,OAAO,0BAA0B,CAAC,CAAC,CAAC;IAC9D,OAAO,CAAC,GAAG,EAAE,CAAC;AAChB,CAAC"}
@@ -1,186 +0,0 @@
1
- import { z } from 'zod';
2
- declare const componentFileSchema: z.ZodObject<{
3
- name: z.ZodString;
4
- path: z.ZodString;
5
- content: z.ZodString;
6
- }, "strip", z.ZodTypeAny, {
7
- name: string;
8
- path: string;
9
- content: string;
10
- }, {
11
- name: string;
12
- path: string;
13
- content: string;
14
- }>;
15
- declare const registryResponseSchema: z.ZodObject<{
16
- data: z.ZodObject<{
17
- name: z.ZodString;
18
- generatedName: z.ZodString;
19
- files: z.ZodArray<z.ZodObject<{
20
- name: z.ZodString;
21
- path: z.ZodString;
22
- content: z.ZodString;
23
- }, "strip", z.ZodTypeAny, {
24
- name: string;
25
- path: string;
26
- content: string;
27
- }, {
28
- name: string;
29
- path: string;
30
- content: string;
31
- }>, "many">;
32
- utils: z.ZodObject<{
33
- content: z.ZodString;
34
- }, "strip", z.ZodTypeAny, {
35
- content: string;
36
- }, {
37
- content: string;
38
- }>;
39
- dependencies: z.ZodArray<z.ZodString, "many">;
40
- }, "strip", z.ZodTypeAny, {
41
- name: string;
42
- generatedName: string;
43
- files: {
44
- name: string;
45
- path: string;
46
- content: string;
47
- }[];
48
- utils: {
49
- content: string;
50
- };
51
- dependencies: string[];
52
- }, {
53
- name: string;
54
- generatedName: string;
55
- files: {
56
- name: string;
57
- path: string;
58
- content: string;
59
- }[];
60
- utils: {
61
- content: string;
62
- };
63
- dependencies: string[];
64
- }>;
65
- }, "strip", z.ZodTypeAny, {
66
- data: {
67
- name: string;
68
- generatedName: string;
69
- files: {
70
- name: string;
71
- path: string;
72
- content: string;
73
- }[];
74
- utils: {
75
- content: string;
76
- };
77
- dependencies: string[];
78
- };
79
- }, {
80
- data: {
81
- name: string;
82
- generatedName: string;
83
- files: {
84
- name: string;
85
- path: string;
86
- content: string;
87
- }[];
88
- utils: {
89
- content: string;
90
- };
91
- dependencies: string[];
92
- };
93
- }>;
94
- export type ComponentFile = z.infer<typeof componentFileSchema>;
95
- export type RegistryResponse = z.infer<typeof registryResponseSchema>['data'];
96
- /**
97
- * Information about a component's exports extracted from its source code
98
- */
99
- export interface ComponentExportInfo {
100
- name: string;
101
- isDefault: boolean;
102
- propsType?: string;
103
- requiredProps: string[];
104
- optionalProps: string[];
105
- }
106
- /**
107
- * Extract export information from a component's source code
108
- * Parses the TSX/TS content to find exported components and their props
109
- */
110
- export declare function extractComponentExports(content: string): ComponentExportInfo | null;
111
- /**
112
- * Generate an import statement for a component
113
- */
114
- export declare function generateImportStatement(exportInfo: ComponentExportInfo, importPath: string): string;
115
- /**
116
- * Generate a usage example for a component
117
- */
118
- export declare function generateUsageExample(exportInfo: ComponentExportInfo): string;
119
- /**
120
- * Options for generating usage markdown
121
- */
122
- export interface UsageMarkdownOptions {
123
- componentName: string;
124
- importPath: string;
125
- exportInfo: ComponentExportInfo | null;
126
- fileName: string;
127
- }
128
- /**
129
- * Generate a usage.md file content for a component
130
- */
131
- export declare function generateUsageMarkdown(options: UsageMarkdownOptions): string;
132
- /**
133
- * Write the usage.md file to the component directory
134
- */
135
- export declare function writeUsageFile(targetDir: string, options: UsageMarkdownOptions): void;
136
- /**
137
- * Fetch component data from the MagicPath registry
138
- */
139
- export declare function fetchComponent(generatedName: string): Promise<RegistryResponse>;
140
- /**
141
- * Check which files already exist in the target directory
142
- */
143
- export declare function checkExistingFiles(files: ComponentFile[], targetDir: string): string[];
144
- /**
145
- * Adjust relative import paths in component content to account for extra directory depth.
146
- * When placing components in a subfolder, relative imports need an extra "../" prefix.
147
- *
148
- * @param content - The file content with imports to adjust
149
- * @param extraDepth - Number of extra directory levels to account for (default: 1)
150
- */
151
- export declare function adjustRelativeImports(content: string, extraDepth?: number): string;
152
- /**
153
- * Write component files to the target directory
154
- *
155
- * @param files - Array of component files to write
156
- * @param targetDir - Target directory to write files to
157
- * @param adjustImports - Whether to adjust relative imports for subfolder placement (default: false)
158
- */
159
- export declare function writeComponentFiles(files: ComponentFile[], targetDir: string, adjustImports?: boolean): void;
160
- /**
161
- * Check if utils.ts already exists and has the cn function
162
- */
163
- export declare function checkUtilsExists(utilsDir: string): boolean;
164
- /**
165
- * Write the utils.ts file
166
- */
167
- export declare function writeUtilsFile(utilsContent: string, utilsDir: string): void;
168
- export declare const DEFAULT_COMPONENTS_PATH = "src/components/magicpath";
169
- export declare const DEFAULT_UTILS_PATH = "src/lib";
170
- /**
171
- * Sanitize a component name for use as a folder name
172
- * - Converts to lowercase kebab-case
173
- * - Removes special characters
174
- * - Replaces spaces with hyphens
175
- * - Falls back to 'component' if the result would be empty
176
- */
177
- export declare function sanitizeComponentFolderName(name: string): string;
178
- /**
179
- * Resolve the components path (with optional override)
180
- */
181
- export declare function resolveComponentsPath(overridePath?: string, cwd?: string): string;
182
- /**
183
- * Resolve the utils path
184
- */
185
- export declare function resolveUtilsPath(cwd?: string): string;
186
- export {};