magicpath-ai 1.3.0-beta.16 → 1.3.0-beta.17
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.
|
@@ -1,113 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import fs from 'fs-extra';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
|
-
import { isJsonMode, jsonResult } from '../util/output.js';
|
|
5
|
-
import { GREEN_CHECK } from '../util/ui.js';
|
|
6
|
-
// ── Resolve skills directory (single source of truth) ────────────────
|
|
7
|
-
function getSkillsDir() {
|
|
8
|
-
const thisFile = fileURLToPath(import.meta.url);
|
|
9
|
-
// src/commands/setup-skills.ts -> package root is ../../
|
|
10
|
-
return path.resolve(path.dirname(thisFile), '..', '..', 'skills');
|
|
11
|
-
}
|
|
12
|
-
function readSkillFile(filename) {
|
|
13
|
-
const filePath = path.join(getSkillsDir(), filename);
|
|
14
|
-
return fs.readFileSync(filePath, 'utf8');
|
|
15
|
-
}
|
|
16
|
-
// ── Editor-specific metadata (not part of skill content) ─────────────
|
|
17
|
-
const DESCRIPTION = 'MagicPath is an external platform where the user builds and stores UI components. Use this when the user mentions "magicpath", wants to find/browse/search their MagicPath components, add a MagicPath component, preview a MagicPath component, or integrate one into their project. MagicPath components are NOT in the local git repo — they live on the MagicPath platform and must be fetched via the CLI.';
|
|
18
|
-
// ── Editor-specific content builders ─────────────────────────────────
|
|
19
|
-
function buildClaudeSkill() {
|
|
20
|
-
const guide = readSkillFile('guide.md');
|
|
21
|
-
return `---
|
|
22
|
-
name: magicpath
|
|
23
|
-
description: ${DESCRIPTION} Also triggers for magicpath-ai CLI usage.
|
|
24
|
-
user-invocable: true
|
|
25
|
-
allowed-tools: Bash(magicpath-ai *)
|
|
26
|
-
---
|
|
27
|
-
|
|
28
|
-
${guide}
|
|
29
|
-
|
|
30
|
-
## Current Project Context
|
|
31
|
-
|
|
32
|
-
\`\`\`json
|
|
33
|
-
!\`magicpath-ai info --json 2>/dev/null || echo '{"error": "magicpath-ai not found. Run: npx magicpath-ai info --json"}'\`
|
|
34
|
-
\`\`\`
|
|
35
|
-
|
|
36
|
-
The JSON above contains auth status, projects, and CLI version. If auth.authenticated is false, the user needs to log in before any other operations.
|
|
37
|
-
|
|
38
|
-
## Detailed References
|
|
39
|
-
|
|
40
|
-
- [cli.md](./cli.md) — Full CLI command reference with all flags
|
|
41
|
-
`;
|
|
42
|
-
}
|
|
43
|
-
function buildCursorRule() {
|
|
44
|
-
const guide = readSkillFile('guide.md');
|
|
45
|
-
const cliReference = readSkillFile('cli-reference.md');
|
|
46
|
-
// Use single quotes to avoid escaping double quotes in YAML
|
|
47
|
-
const yamlDesc = DESCRIPTION.replace(/'/g, "''");
|
|
48
|
-
return `---
|
|
49
|
-
description: '${yamlDesc}'
|
|
50
|
-
alwaysApply: false
|
|
51
|
-
---
|
|
52
|
-
|
|
53
|
-
${guide}
|
|
54
|
-
|
|
55
|
-
## CLI Reference
|
|
56
|
-
|
|
57
|
-
${cliReference}
|
|
58
|
-
`;
|
|
59
|
-
}
|
|
60
|
-
function buildCopilotInstructions() {
|
|
61
|
-
const guide = readSkillFile('guide.md');
|
|
62
|
-
const cliReference = readSkillFile('cli-reference.md');
|
|
63
|
-
return `---
|
|
64
|
-
applyTo: "**"
|
|
65
|
-
---
|
|
66
|
-
|
|
67
|
-
${guide}
|
|
68
|
-
|
|
69
|
-
## CLI Reference
|
|
70
|
-
|
|
71
|
-
${cliReference}
|
|
72
|
-
`;
|
|
73
|
-
}
|
|
74
|
-
function getFileTargets() {
|
|
75
|
-
const cliReference = readSkillFile('cli-reference.md');
|
|
76
|
-
return [
|
|
77
|
-
// Claude Code
|
|
78
|
-
{ path: '.claude/skills/magicpath/SKILL.md', content: buildClaudeSkill() },
|
|
79
|
-
{ path: '.claude/skills/magicpath/cli.md', content: cliReference + '\n' },
|
|
80
|
-
// Cursor
|
|
81
|
-
{ path: '.cursor/rules/magicpath.mdc', content: buildCursorRule() },
|
|
82
|
-
// GitHub Copilot
|
|
83
|
-
{
|
|
84
|
-
path: '.github/instructions/magicpath.instructions.md',
|
|
85
|
-
content: buildCopilotInstructions(),
|
|
86
|
-
},
|
|
87
|
-
];
|
|
88
|
-
}
|
|
89
|
-
// ── Command ───────────────────────────────────────────────────────────
|
|
1
|
+
import { execSync } from 'child_process';
|
|
90
2
|
export function registerSetupSkillsCommand(program) {
|
|
91
3
|
program
|
|
92
4
|
.command('setup-skills')
|
|
93
|
-
.description('Set up MagicPath for AI agents
|
|
5
|
+
.description('Set up MagicPath for AI agents')
|
|
94
6
|
.action(async () => {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
for (const target of getFileTargets()) {
|
|
100
|
-
const absPath = path.join(cwd, target.path);
|
|
101
|
-
fs.ensureDirSync(path.dirname(absPath));
|
|
102
|
-
fs.writeFileSync(absPath, target.content, 'utf8');
|
|
103
|
-
created.push(target.path);
|
|
104
|
-
if (!json)
|
|
105
|
-
console.log(`${GREEN_CHECK} Created ${target.path}`);
|
|
106
|
-
}
|
|
107
|
-
if (json) {
|
|
108
|
-
jsonResult({ created }); // exits process
|
|
109
|
-
}
|
|
110
|
-
console.log('\nMagicPath is ready for AI agents (Claude Code, Cursor, GitHub Copilot).');
|
|
7
|
+
console.log('Installing MagicPath skills...');
|
|
8
|
+
execSync('npx skills add https://github.com/MagicPathAI/agent-skills -y', {
|
|
9
|
+
stdio: 'inherit',
|
|
10
|
+
});
|
|
111
11
|
});
|
|
112
12
|
}
|
|
113
13
|
//# sourceMappingURL=setup-skills.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-skills.js","sourceRoot":"","sources":["../../src/commands/setup-skills.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"setup-skills.js","sourceRoot":"","sources":["../../src/commands/setup-skills.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,UAAU,0BAA0B,CAAC,OAAgB;IACzD,OAAO;SACJ,OAAO,CAAC,cAAc,CAAC;SACvB,WAAW,CAAC,gCAAgC,CAAC;SAC7C,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;QAC9C,QAAQ,CACN,+DAA+D,EAC/D;YACE,KAAK,EAAE,SAAS;SACjB,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/util/banner.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import chalk from 'chalk';
|
|
2
2
|
import { loadTokens, loadUserInfo } from './auth.js';
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const SPRITE = [
|
|
3
|
+
const GRADIENT_HEX = ['#95D5B2', '#74C69D', '#52B788', '#40916C', '#2D6A4F', '#1B4332'];
|
|
4
|
+
function gradientColor(step) {
|
|
5
|
+
return chalk.hex(GRADIENT_HEX[Math.min(step, GRADIENT_HEX.length - 1)]);
|
|
6
|
+
}
|
|
7
|
+
const G1 = chalk.hex('#2D6A4F');
|
|
8
|
+
const G2 = chalk.hex('#1B4332');
|
|
9
|
+
const WH = chalk.hex('#E8F5E9');
|
|
10
|
+
const DM = chalk.hex('#888888');
|
|
11
|
+
const MAGIC = [
|
|
13
12
|
'███╗ ███╗ █████╗ ██████╗ ██╗ ██████╗',
|
|
14
13
|
'████╗ ████║██╔══██╗██╔════╝ ██║██╔════╝',
|
|
15
14
|
'██╔████╔██║███████║██║ ███╗██║██║ ',
|
|
16
15
|
'██║╚██╔╝██║██╔══██║██║ ██║██║██║ ',
|
|
17
16
|
'██║ ╚═╝ ██║██║ ██║╚██████╔╝██║╚██████╗',
|
|
18
17
|
'╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝',
|
|
19
|
-
|
|
18
|
+
];
|
|
19
|
+
const PATH = [
|
|
20
20
|
'██████╗ █████╗ ████████╗██╗ ██╗',
|
|
21
21
|
'██╔══██╗██╔══██╗╚══██╔══╝██║ ██║',
|
|
22
22
|
'██████╔╝███████║ ██║ ███████║',
|
|
@@ -24,32 +24,10 @@ const SPRITE = [
|
|
|
24
24
|
'██║ ██║ ██║ ██║ ██║ ██║',
|
|
25
25
|
'╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝',
|
|
26
26
|
];
|
|
27
|
-
const
|
|
28
|
-
const vis = (s) => s.replace(ANSI, '').length;
|
|
29
|
-
const GRAD_START = [180, 255, 220];
|
|
30
|
-
const GRAD_END = [30, 90, 58];
|
|
31
|
-
function lerpColor(t) {
|
|
32
|
-
const r = Math.round(GRAD_START[0] + (GRAD_END[0] - GRAD_START[0]) * t);
|
|
33
|
-
const g = Math.round(GRAD_START[1] + (GRAD_END[1] - GRAD_START[1]) * t);
|
|
34
|
-
const b = Math.round(GRAD_START[2] + (GRAD_END[2] - GRAD_START[2]) * t);
|
|
35
|
-
return c.rgb(r, g, b);
|
|
36
|
-
}
|
|
37
|
-
function pad(str, width) {
|
|
38
|
-
const need = width - vis(str);
|
|
39
|
-
return str + ' '.repeat(Math.max(0, need));
|
|
40
|
-
}
|
|
41
|
-
function center(str, width) {
|
|
42
|
-
const gap = Math.max(0, width - vis(str));
|
|
43
|
-
const l = Math.floor(gap / 2);
|
|
44
|
-
return ' '.repeat(l) + str + ' '.repeat(gap - l);
|
|
45
|
-
}
|
|
27
|
+
const SPRITE = MAGIC.map((row, i) => row + ' ' + PATH[i]);
|
|
46
28
|
function styleSprite(rows) {
|
|
47
|
-
const h = rows.length;
|
|
48
|
-
const STEPS = 6;
|
|
49
29
|
return rows.map((row, y) => {
|
|
50
|
-
const
|
|
51
|
-
const t = Math.floor(raw * STEPS) / STEPS;
|
|
52
|
-
const colorFn = lerpColor(t);
|
|
30
|
+
const colorFn = gradientColor(y);
|
|
53
31
|
let out = '';
|
|
54
32
|
for (const ch of row) {
|
|
55
33
|
out += ch === ' ' ? ch : colorFn(ch);
|
|
@@ -57,62 +35,35 @@ function styleSprite(rows) {
|
|
|
57
35
|
return out;
|
|
58
36
|
});
|
|
59
37
|
}
|
|
60
|
-
function
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const cmdPadded = cmd + ' '.repeat(Math.max(0, 20 - cmd.length));
|
|
69
|
-
return ' ' + G1(cmdPadded) + DM(desc);
|
|
70
|
-
}
|
|
71
|
-
function buildRightLines(user, loggedIn, version) {
|
|
72
|
-
const commands = [
|
|
73
|
-
commandLine('search <query>', 'Search components'),
|
|
74
|
-
commandLine('add <name>', 'Add to project'),
|
|
75
|
-
commandLine('list-projects', 'Your projects'),
|
|
76
|
-
commandLine('setup-skills', 'Set up AI agents'),
|
|
77
|
-
];
|
|
78
|
-
const footer = [
|
|
79
|
-
' '.repeat(RC),
|
|
80
|
-
pad(' ' + DM(`v${version} ─ magicpath-ai --help`), RC),
|
|
81
|
-
];
|
|
38
|
+
export function showBanner(version) {
|
|
39
|
+
const loggedIn = !!loadTokens();
|
|
40
|
+
const user = loggedIn ? loadUserInfo() : null;
|
|
41
|
+
console.log();
|
|
42
|
+
for (const row of styleSprite(SPRITE)) {
|
|
43
|
+
console.log(row);
|
|
44
|
+
}
|
|
45
|
+
console.log();
|
|
82
46
|
if (loggedIn && user) {
|
|
83
47
|
const planLabel = user.plan ? ` · ${user.plan}` : '';
|
|
84
|
-
|
|
85
|
-
' '
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
...commands.map((line) => pad(line, RC)),
|
|
90
|
-
...footer,
|
|
91
|
-
];
|
|
48
|
+
console.log(' ' + G1('●') + ' ' + chalk.bold(WH(user.name ?? 'MagicPath User')) +
|
|
49
|
+
G2(' ' + (user.email ?? '') + planLabel));
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
console.log(' ' + DM('○ Not logged in · run') + ' ' + G1('magicpath-ai login'));
|
|
92
53
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
' '
|
|
98
|
-
|
|
99
|
-
|
|
54
|
+
console.log();
|
|
55
|
+
const CMD_W = 20;
|
|
56
|
+
const cmds = [
|
|
57
|
+
['search <query>', 'Search components'],
|
|
58
|
+
['add <name>', 'Add to project'],
|
|
59
|
+
['list-projects', 'Your projects'],
|
|
60
|
+
['setup-skills', 'Set up AI agents'],
|
|
100
61
|
];
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const left = leftLines();
|
|
104
|
-
const height = Math.max(left.length, right.length);
|
|
105
|
-
console.log(G3('╭' + '─'.repeat(INNER) + '╮'));
|
|
106
|
-
for (let i = 0; i < height; i++) {
|
|
107
|
-
const l = pad(left[i] ?? ' '.repeat(LC), LC);
|
|
108
|
-
const r = pad(right[i] ?? ' '.repeat(RC), RC);
|
|
109
|
-
console.log(G3('│') + l + G3('│') + r + G3('│'));
|
|
62
|
+
for (const [cmd, desc] of cmds) {
|
|
63
|
+
console.log(' ' + G1(cmd.padEnd(CMD_W)) + DM(desc));
|
|
110
64
|
}
|
|
111
|
-
console.log(
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const loggedIn = !!loadTokens();
|
|
115
|
-
const user = loggedIn ? loadUserInfo() : null;
|
|
116
|
-
printBanner(buildRightLines(user, loggedIn, version));
|
|
65
|
+
console.log();
|
|
66
|
+
console.log(' ' + DM(`v${version} ─ magicpath-ai --help`));
|
|
67
|
+
console.log();
|
|
117
68
|
}
|
|
118
69
|
//# sourceMappingURL=banner.js.map
|
package/dist/util/banner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banner.js","sourceRoot":"","sources":["../../src/util/banner.ts"],"names":[],"mapp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