create-huenei-template 0.2.8 → 0.2.9
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/config/templates.js +7 -0
- package/dist/core/file-operations.js +15 -0
- package/dist/core/prompts.js +77 -135
- package/dist/index.js +55 -11
- package/dist/templates/cursor/.cursor/commands/configurar-cursor.md +763 -0
- package/dist/templates/cursor/.cursor/skills/create-huenei-subagent/SKILL.md +223 -0
- package/dist/templates/cursor/.cursor/skills/create-huenei-subagent/examples.md +236 -0
- package/dist/templates/cursor/.cursor/skills/cursor-hooks/SKILL.md +1100 -0
- package/dist/templates/cursor/.cursor/skills/find-skills/SKILL.md +133 -0
- package/dist/templates/frontend/react-vite-help/.cursor/RECONSTRUCTION-PROMPT.md +738 -0
- package/package.json +1 -1
- package/templates/cursor/.cursor/commands/configurar-cursor.md +763 -0
- package/templates/cursor/.cursor/skills/create-huenei-subagent/SKILL.md +223 -0
- package/templates/cursor/.cursor/skills/create-huenei-subagent/examples.md +236 -0
- package/templates/cursor/.cursor/skills/cursor-hooks/SKILL.md +1100 -0
- package/templates/cursor/.cursor/skills/find-skills/SKILL.md +133 -0
- package/templates/frontend/react-vite-help/.cursor/RECONSTRUCTION-PROMPT.md +738 -0
package/dist/config/templates.js
CHANGED
|
@@ -61,6 +61,13 @@ export const TEMPLATE_CATALOG = [
|
|
|
61
61
|
description: "Monorepo Angular con Nx para arquitectura escalable de micro-frontends. Ideal para proyectos empresariales.",
|
|
62
62
|
category: "frontend",
|
|
63
63
|
path: "frontend/angular-nx",
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: "cursor-config",
|
|
67
|
+
name: "Cursor Configuration",
|
|
68
|
+
description: "Rules, skills, commands, agents y hooks para desarrollo asistido por IA con Cursor",
|
|
69
|
+
category: "cursor",
|
|
70
|
+
path: "cursor",
|
|
64
71
|
}
|
|
65
72
|
];
|
|
66
73
|
export function getTemplatesByCategory(category) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import path from "path";
|
|
1
2
|
import { mkdir, cp, rm, access } from "fs/promises";
|
|
2
3
|
import { constants } from "fs";
|
|
3
4
|
export async function ensureDirectory(dirPath) {
|
|
@@ -23,3 +24,17 @@ export async function directoryExists(dirPath) {
|
|
|
23
24
|
return false;
|
|
24
25
|
}
|
|
25
26
|
}
|
|
27
|
+
export async function copyToExistingDir(source, dest) {
|
|
28
|
+
await ensureDirectory(dest);
|
|
29
|
+
await cp(source, dest, { recursive: true, force: true });
|
|
30
|
+
}
|
|
31
|
+
export async function mergeSubdirectories(source, dest, subdirs) {
|
|
32
|
+
for (const subdir of subdirs) {
|
|
33
|
+
const srcPath = path.join(source, subdir);
|
|
34
|
+
const destPath = path.join(dest, subdir);
|
|
35
|
+
if (await directoryExists(srcPath)) {
|
|
36
|
+
await ensureDirectory(destPath);
|
|
37
|
+
await cp(srcPath, destPath, { recursive: true, force: true });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
package/dist/core/prompts.js
CHANGED
|
@@ -2,113 +2,83 @@ import prompts from "prompts";
|
|
|
2
2
|
import { getTemplatesByCategory, getAvailableCategories } from "../config/templates.js";
|
|
3
3
|
const BACK_OPTION = "<<<BACK>>>";
|
|
4
4
|
const BACK_LABEL = "← Volver";
|
|
5
|
+
const onCancel = () => {
|
|
6
|
+
throw new Error("USER_CANCELLED");
|
|
7
|
+
};
|
|
5
8
|
export async function askProjectSetup() {
|
|
6
|
-
// Step 1: Project Name (no back option - first step)
|
|
7
|
-
const nameResponse = await prompts({
|
|
8
|
-
type: "text",
|
|
9
|
-
name: "projectName",
|
|
10
|
-
message: "Project name",
|
|
11
|
-
initial: "my-project",
|
|
12
|
-
validate: (value) => {
|
|
13
|
-
if (!value || value.trim().length === 0) {
|
|
14
|
-
return "Project name is required";
|
|
15
|
-
}
|
|
16
|
-
if (!/^[a-z0-9-_]+$/i.test(value)) {
|
|
17
|
-
return "Project name can only contain letters, numbers, hyphens and underscores";
|
|
18
|
-
}
|
|
19
|
-
return true;
|
|
20
|
-
},
|
|
21
|
-
}, {
|
|
22
|
-
onCancel: () => {
|
|
23
|
-
throw new Error("USER_CANCELLED");
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
if (!nameResponse.projectName) {
|
|
27
|
-
throw new Error("USER_CANCELLED");
|
|
28
|
-
}
|
|
29
|
-
const projectName = nameResponse.projectName;
|
|
30
|
-
// Step 2 & 3: Category and Template Selection (with back navigation)
|
|
31
9
|
let category = null;
|
|
32
10
|
let templateId = "";
|
|
33
11
|
while (!templateId) {
|
|
34
|
-
// Step 2: Category Selection (no back option)
|
|
35
12
|
if (!category) {
|
|
36
|
-
|
|
37
|
-
const choices = categories.map((cat) => ({
|
|
38
|
-
title: cat.charAt(0).toUpperCase() + cat.slice(1),
|
|
39
|
-
value: cat,
|
|
40
|
-
}));
|
|
41
|
-
const categoryResponse = await prompts({
|
|
42
|
-
type: "select",
|
|
43
|
-
name: "category",
|
|
44
|
-
message: "Select project category",
|
|
45
|
-
choices,
|
|
46
|
-
initial: 0,
|
|
47
|
-
}, {
|
|
48
|
-
onCancel: () => {
|
|
49
|
-
throw new Error("USER_CANCELLED");
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
if (!categoryResponse.category) {
|
|
53
|
-
throw new Error("USER_CANCELLED");
|
|
54
|
-
}
|
|
55
|
-
category = categoryResponse.category;
|
|
13
|
+
category = await askCategorySelection();
|
|
56
14
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
...templates.map((template) => ({
|
|
61
|
-
title: template.name,
|
|
62
|
-
description: template.description,
|
|
63
|
-
value: template.id,
|
|
64
|
-
})),
|
|
65
|
-
{
|
|
66
|
-
title: BACK_LABEL,
|
|
67
|
-
value: BACK_OPTION,
|
|
68
|
-
},
|
|
69
|
-
];
|
|
70
|
-
const templateResponse = await prompts({
|
|
71
|
-
type: "select",
|
|
72
|
-
name: "templateId",
|
|
73
|
-
message: "Select template",
|
|
74
|
-
choices,
|
|
75
|
-
initial: 0, // Start at first template, not at back option
|
|
76
|
-
}, {
|
|
77
|
-
onCancel: () => {
|
|
78
|
-
throw new Error("USER_CANCELLED");
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
if (!templateResponse.templateId) {
|
|
82
|
-
throw new Error("USER_CANCELLED");
|
|
15
|
+
if (category === "cursor") {
|
|
16
|
+
const installScope = await askCursorInstallScope();
|
|
17
|
+
return { mode: "cursor", installScope };
|
|
83
18
|
}
|
|
84
|
-
|
|
85
|
-
|
|
19
|
+
const result = await askTemplateSelection(category);
|
|
20
|
+
if (result === BACK_OPTION) {
|
|
86
21
|
category = null;
|
|
87
|
-
continue;
|
|
22
|
+
continue;
|
|
88
23
|
}
|
|
89
|
-
templateId =
|
|
24
|
+
templateId = result;
|
|
90
25
|
}
|
|
91
|
-
|
|
26
|
+
const projectName = await askProjectName();
|
|
92
27
|
const pnpmResponse = await prompts({
|
|
93
28
|
type: "confirm",
|
|
94
29
|
name: "checkPnpm",
|
|
95
30
|
message: "Check / install pnpm?",
|
|
96
31
|
initial: true,
|
|
97
|
-
}, {
|
|
98
|
-
onCancel: () => {
|
|
99
|
-
throw new Error("USER_CANCELLED");
|
|
100
|
-
},
|
|
101
|
-
});
|
|
32
|
+
}, { onCancel });
|
|
102
33
|
const checkPnpm = pnpmResponse.checkPnpm ?? true;
|
|
103
34
|
return {
|
|
35
|
+
mode: "project",
|
|
104
36
|
projectName,
|
|
105
|
-
category: category, // We know it's not null here
|
|
106
37
|
templateId,
|
|
107
38
|
checkPnpm,
|
|
108
39
|
};
|
|
109
40
|
}
|
|
110
|
-
|
|
111
|
-
|
|
41
|
+
async function askCategorySelection() {
|
|
42
|
+
const categories = getAvailableCategories();
|
|
43
|
+
const choices = categories.map((cat) => ({
|
|
44
|
+
title: cat.charAt(0).toUpperCase() + cat.slice(1),
|
|
45
|
+
value: cat,
|
|
46
|
+
}));
|
|
47
|
+
const response = await prompts({
|
|
48
|
+
type: "select",
|
|
49
|
+
name: "category",
|
|
50
|
+
message: "Select project category",
|
|
51
|
+
choices,
|
|
52
|
+
initial: 0,
|
|
53
|
+
}, { onCancel });
|
|
54
|
+
if (!response.category) {
|
|
55
|
+
throw new Error("USER_CANCELLED");
|
|
56
|
+
}
|
|
57
|
+
return response.category;
|
|
58
|
+
}
|
|
59
|
+
async function askTemplateSelection(category) {
|
|
60
|
+
const templates = getTemplatesByCategory(category);
|
|
61
|
+
const choices = [
|
|
62
|
+
...templates.map((template) => ({
|
|
63
|
+
title: template.name,
|
|
64
|
+
description: template.description,
|
|
65
|
+
value: template.id,
|
|
66
|
+
})),
|
|
67
|
+
{ title: BACK_LABEL, value: BACK_OPTION },
|
|
68
|
+
];
|
|
69
|
+
const response = await prompts({
|
|
70
|
+
type: "select",
|
|
71
|
+
name: "templateId",
|
|
72
|
+
message: "Select template",
|
|
73
|
+
choices,
|
|
74
|
+
initial: 0,
|
|
75
|
+
}, { onCancel });
|
|
76
|
+
if (!response.templateId) {
|
|
77
|
+
throw new Error("USER_CANCELLED");
|
|
78
|
+
}
|
|
79
|
+
return response.templateId;
|
|
80
|
+
}
|
|
81
|
+
async function askProjectName() {
|
|
112
82
|
const response = await prompts({
|
|
113
83
|
type: "text",
|
|
114
84
|
name: "projectName",
|
|
@@ -123,61 +93,33 @@ export async function askProjectName() {
|
|
|
123
93
|
}
|
|
124
94
|
return true;
|
|
125
95
|
},
|
|
126
|
-
});
|
|
96
|
+
}, { onCancel });
|
|
127
97
|
if (!response.projectName) {
|
|
128
|
-
throw new Error("
|
|
98
|
+
throw new Error("USER_CANCELLED");
|
|
129
99
|
}
|
|
130
100
|
return response.projectName;
|
|
131
101
|
}
|
|
132
|
-
export async function
|
|
133
|
-
const categories = getAvailableCategories();
|
|
134
|
-
const response = await prompts({
|
|
135
|
-
type: "select",
|
|
136
|
-
name: "category",
|
|
137
|
-
message: "Select project category",
|
|
138
|
-
choices: categories.map((cat) => ({
|
|
139
|
-
title: cat.charAt(0).toUpperCase() + cat.slice(1),
|
|
140
|
-
value: cat,
|
|
141
|
-
})),
|
|
142
|
-
});
|
|
143
|
-
if (!response.category) {
|
|
144
|
-
throw new Error("Category selection is required");
|
|
145
|
-
}
|
|
146
|
-
return response.category;
|
|
147
|
-
}
|
|
148
|
-
export async function askTemplate(category) {
|
|
149
|
-
const templates = getTemplatesByCategory(category);
|
|
150
|
-
if (templates.length === 0) {
|
|
151
|
-
throw new Error(`No templates available for category: ${category}`);
|
|
152
|
-
}
|
|
102
|
+
export async function askCursorInstallScope() {
|
|
153
103
|
const response = await prompts({
|
|
154
104
|
type: "select",
|
|
155
|
-
name: "
|
|
156
|
-
message: "
|
|
157
|
-
choices:
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
105
|
+
name: "scope",
|
|
106
|
+
message: "Where do you want to install Cursor configuration?",
|
|
107
|
+
choices: [
|
|
108
|
+
{
|
|
109
|
+
title: "Current project",
|
|
110
|
+
description: "Copy .cursor/ folder into the current working directory",
|
|
111
|
+
value: "project",
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
title: "User level (~/.cursor/)",
|
|
115
|
+
description: "Merge skills/ and commands/ into your user-level Cursor config",
|
|
116
|
+
value: "user",
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
initial: 0,
|
|
120
|
+
}, { onCancel });
|
|
121
|
+
if (!response.scope) {
|
|
122
|
+
throw new Error("USER_CANCELLED");
|
|
165
123
|
}
|
|
166
|
-
return response.
|
|
167
|
-
}
|
|
168
|
-
export async function askPnpmCheck() {
|
|
169
|
-
const response = await prompts({
|
|
170
|
-
type: "confirm",
|
|
171
|
-
name: "checkPnpm",
|
|
172
|
-
message: "Check / install pnpm?",
|
|
173
|
-
initial: true,
|
|
174
|
-
});
|
|
175
|
-
return response.checkPnpm ?? true;
|
|
176
|
-
}
|
|
177
|
-
export function setupCancellationHandler(cleanup) {
|
|
178
|
-
prompts.override({ onCancel: async () => {
|
|
179
|
-
console.log("\n⚠️ Cancelled by user");
|
|
180
|
-
await cleanup();
|
|
181
|
-
process.exit(1);
|
|
182
|
-
} });
|
|
124
|
+
return response.scope;
|
|
183
125
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import os from "os";
|
|
2
3
|
import path from "path";
|
|
3
4
|
import process from "process";
|
|
4
5
|
import { execSync } from "child_process";
|
|
5
|
-
import {
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
7
|
+
import { askProjectSetup, askCursorInstallScope, } from "./core/prompts.js";
|
|
6
8
|
import { ensurePnpm } from "./core/dependency-manager.js";
|
|
7
9
|
import { resolveTemplatePath } from "./core/template-resolver.js";
|
|
8
|
-
import { ensureDirectory, copyTemplate, cleanupOnError, } from "./core/file-operations.js";
|
|
10
|
+
import { ensureDirectory, copyTemplate, cleanupOnError, copyToExistingDir, mergeSubdirectories, directoryExists, } from "./core/file-operations.js";
|
|
9
11
|
import { formatError } from "./core/errors.js";
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = path.dirname(__filename);
|
|
14
|
+
const CURSOR_TEMPLATE_SOURCE = path.resolve(__dirname, "../templates/cursor/.cursor");
|
|
15
|
+
const CURSOR_MERGE_SUBDIRS = ["skills", "commands"];
|
|
16
|
+
function hasCursorFlag() {
|
|
17
|
+
return process.argv.includes("--cursor");
|
|
18
|
+
}
|
|
10
19
|
function initializeGit(projectDir) {
|
|
11
20
|
try {
|
|
12
21
|
execSync("git init", {
|
|
@@ -42,31 +51,67 @@ function displaySuccessMessage(projectName, pnpmWasJustInstalled) {
|
|
|
42
51
|
console.log("\n✨ Thanks for using create-huenei-template");
|
|
43
52
|
console.log("🚀 Happy coding!\n");
|
|
44
53
|
}
|
|
54
|
+
function displayCursorSuccessMessage(scope, targetPath) {
|
|
55
|
+
console.log("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
|
|
56
|
+
console.log("🎉 Cursor configuration installed!");
|
|
57
|
+
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
|
|
58
|
+
if (scope === "project") {
|
|
59
|
+
console.log(` Installed in: ${targetPath}`);
|
|
60
|
+
console.log(" Content: skills, commands");
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
console.log(` Installed in: ${targetPath}`);
|
|
64
|
+
console.log(` Merged: ${CURSOR_MERGE_SUBDIRS.join(", ")}`);
|
|
65
|
+
}
|
|
66
|
+
console.log("\n✨ Thanks for using create-huenei-template");
|
|
67
|
+
console.log("🚀 Happy coding!\n");
|
|
68
|
+
}
|
|
69
|
+
async function handleCursorInstall(scope) {
|
|
70
|
+
if (scope === "project") {
|
|
71
|
+
const dest = path.join(process.cwd(), ".cursor");
|
|
72
|
+
if (await directoryExists(dest)) {
|
|
73
|
+
console.log(`\n⚠️ .cursor/ already exists in ${process.cwd()}`);
|
|
74
|
+
console.log(" Existing files with the same name will be overwritten.\n");
|
|
75
|
+
}
|
|
76
|
+
console.log("\n📦 Installing Cursor configuration...");
|
|
77
|
+
await copyToExistingDir(CURSOR_TEMPLATE_SOURCE, dest);
|
|
78
|
+
displayCursorSuccessMessage("project", dest);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
const userCursorDir = path.join(os.homedir(), ".cursor");
|
|
82
|
+
console.log("\n📦 Merging Cursor configuration...");
|
|
83
|
+
await mergeSubdirectories(CURSOR_TEMPLATE_SOURCE, userCursorDir, CURSOR_MERGE_SUBDIRS);
|
|
84
|
+
displayCursorSuccessMessage("user", userCursorDir);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
45
87
|
async function main() {
|
|
46
88
|
let targetDir = "";
|
|
47
89
|
try {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
90
|
+
if (hasCursorFlag()) {
|
|
91
|
+
const installScope = await askCursorInstallScope();
|
|
92
|
+
await handleCursorInstall(installScope);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const setup = await askProjectSetup();
|
|
96
|
+
if (setup.mode === "cursor") {
|
|
97
|
+
await handleCursorInstall(setup.installScope);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const { projectName, templateId, checkPnpm } = setup;
|
|
51
101
|
let pnpmWasJustInstalled = false;
|
|
52
102
|
if (checkPnpm) {
|
|
53
103
|
const result = await ensurePnpm();
|
|
54
104
|
pnpmWasJustInstalled = result.wasJustInstalled;
|
|
55
105
|
}
|
|
56
|
-
// Prepare target directory
|
|
57
106
|
targetDir = path.resolve(process.cwd(), projectName);
|
|
58
107
|
await ensureDirectory(targetDir);
|
|
59
|
-
// Resolve and copy template
|
|
60
108
|
const templatePath = resolveTemplatePath(templateId);
|
|
61
109
|
await copyTemplate(templatePath, targetDir);
|
|
62
|
-
// Initialize git repository
|
|
63
110
|
console.log("\n📦 Setting up project...");
|
|
64
111
|
initializeGit(targetDir);
|
|
65
|
-
// Success!
|
|
66
112
|
displaySuccessMessage(projectName, pnpmWasJustInstalled);
|
|
67
113
|
}
|
|
68
114
|
catch (error) {
|
|
69
|
-
// Handle user cancellation gracefully
|
|
70
115
|
if (error instanceof Error && error.message === "USER_CANCELLED") {
|
|
71
116
|
console.log("\n⚠️ Cancelled by user");
|
|
72
117
|
if (targetDir) {
|
|
@@ -75,7 +120,6 @@ async function main() {
|
|
|
75
120
|
process.exit(1);
|
|
76
121
|
}
|
|
77
122
|
console.error(`\n${formatError(error)}`);
|
|
78
|
-
// Cleanup on error
|
|
79
123
|
if (targetDir) {
|
|
80
124
|
await cleanupOnError(targetDir);
|
|
81
125
|
}
|