@sysvv/ai-skill 1.6.0 → 1.6.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.
- package/dist/core/skill.js +5 -1
- package/dist/index.js +30 -69
- package/package.json +1 -1
package/dist/core/skill.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from "fs-extra";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import matter from "gray-matter";
|
|
3
4
|
import { parseSkillFile } from "./frontmatter.js";
|
|
4
5
|
import { renderTemplate } from "./render.js";
|
|
5
6
|
export async function loadSkill(skillFilePath, agent) {
|
|
@@ -13,10 +14,13 @@ export async function loadSkill(skillFilePath, agent) {
|
|
|
13
14
|
...Object.fromEntries(Object.entries(agentOverride).map(([key, value]) => [`provider_${key}`, value]))
|
|
14
15
|
};
|
|
15
16
|
const renderedBody = renderTemplate(body, variables);
|
|
17
|
+
// Reconstrói o SKILL.md completo com frontmatter + body renderizado
|
|
18
|
+
const fullContent = matter.stringify(renderedBody, metadata);
|
|
16
19
|
return {
|
|
17
20
|
path: absolute,
|
|
18
21
|
metadata,
|
|
19
22
|
rawBody: body,
|
|
20
|
-
renderedBody
|
|
23
|
+
renderedBody,
|
|
24
|
+
fullContent
|
|
21
25
|
};
|
|
22
26
|
}
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { fileURLToPath } from "node:url";
|
|
|
7
7
|
import { findSkillFiles } from "./core/registry.js";
|
|
8
8
|
import { parseSkillFile } from "./core/frontmatter.js";
|
|
9
9
|
import { loadSkill } from "./core/skill.js";
|
|
10
|
-
import { loadMcp, writeMcp
|
|
10
|
+
import { loadMcp, writeMcp } from "./core/mcp.js";
|
|
11
11
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
12
12
|
// ── ANSI ────────────────────────────────────────────────────────────────
|
|
13
13
|
const ANSI = {
|
|
@@ -151,7 +151,7 @@ async function installSkills(agent) {
|
|
|
151
151
|
const skill = await loadSkill(file, agent);
|
|
152
152
|
const skillDir = path.join(destBase, skill.metadata.id);
|
|
153
153
|
await fs.ensureDir(skillDir);
|
|
154
|
-
await fs.writeFile(path.join(skillDir, "SKILL.md"), skill.
|
|
154
|
+
await fs.writeFile(path.join(skillDir, "SKILL.md"), skill.fullContent, "utf8");
|
|
155
155
|
console.log(` ${GREEN}✔${ANSI.reset} ${skill.metadata.id}`);
|
|
156
156
|
for (const mcpName of skill.metadata.requires?.mcp ?? []) {
|
|
157
157
|
mcpsToInstall.add(mcpName);
|
|
@@ -173,74 +173,43 @@ async function installSkills(agent) {
|
|
|
173
173
|
console.log(`\n Skills instaladas em ${ANSI.bold}${destBase}/${ANSI.reset}\n`);
|
|
174
174
|
}
|
|
175
175
|
// ── Clear ───────────────────────────────────────────────────────────────
|
|
176
|
+
/** Todas as pastas/arquivos que o CLI pode criar, por agent */
|
|
177
|
+
const AGENT_ROOTS = {
|
|
178
|
+
claude: [".claude", ".mcp.json"],
|
|
179
|
+
codex: [".codex"],
|
|
180
|
+
gemini: [".gemini"],
|
|
181
|
+
copilot: [".github", ".vscode"],
|
|
182
|
+
};
|
|
176
183
|
async function clearFlow() {
|
|
177
184
|
// Descobre o que existe
|
|
178
|
-
const
|
|
179
|
-
const
|
|
180
|
-
for (const [agent,
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
if (await fs.pathExists(mcpFull)) {
|
|
189
|
-
foundMcps.push({ agent, file: mcpFull });
|
|
185
|
+
const found = [];
|
|
186
|
+
const seen = new Set();
|
|
187
|
+
for (const [agent, paths] of Object.entries(AGENT_ROOTS)) {
|
|
188
|
+
for (const p of paths) {
|
|
189
|
+
if (seen.has(p))
|
|
190
|
+
continue;
|
|
191
|
+
seen.add(p);
|
|
192
|
+
const full = path.resolve(p);
|
|
193
|
+
if (await fs.pathExists(full)) {
|
|
194
|
+
found.push({ label: `${agent} → ${p}`, fullPath: full });
|
|
190
195
|
}
|
|
191
196
|
}
|
|
192
197
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
if (!hasSkills && !hasMcps) {
|
|
196
|
-
console.log(" Nenhuma skill ou MCP instalado.\n");
|
|
198
|
+
if (found.length === 0) {
|
|
199
|
+
console.log(" Nenhuma pasta ou arquivo de agent encontrado.\n");
|
|
197
200
|
return;
|
|
198
201
|
}
|
|
199
|
-
// Mostra o que
|
|
200
|
-
console.log(` ${RED}⚠${ANSI.reset}
|
|
201
|
-
|
|
202
|
-
console.log(` ${ANSI.
|
|
203
|
-
for (const s of foundSkills) {
|
|
204
|
-
console.log(` ${ANSI.dim}${s.dir}${ANSI.reset}`);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
if (hasMcps) {
|
|
208
|
-
if (hasSkills)
|
|
209
|
-
console.log('');
|
|
210
|
-
console.log(` ${ANSI.bold}MCPs${ANSI.reset}`);
|
|
211
|
-
for (const m of foundMcps) {
|
|
212
|
-
console.log(` ${ANSI.dim}${m.file}${ANSI.reset}`);
|
|
213
|
-
}
|
|
202
|
+
// Mostra o que vai ser removido
|
|
203
|
+
console.log(` ${RED}⚠${ANSI.reset} Será removido:\n`);
|
|
204
|
+
for (const f of found) {
|
|
205
|
+
console.log(` ${RED}✖${ANSI.reset} ${ANSI.dim}${f.fullPath}${ANSI.reset}`);
|
|
214
206
|
}
|
|
215
207
|
console.log('');
|
|
216
|
-
const choices = [];
|
|
217
|
-
if (hasSkills && hasMcps) {
|
|
218
|
-
choices.push({ name: `${RED}Tudo${ANSI.reset} ${ANSI.dim}(skills + MCPs)${ANSI.reset}`, value: "all" }, { name: `Apenas Skills`, value: "skills" }, { name: `Apenas MCPs`, value: "mcps" });
|
|
219
|
-
}
|
|
220
|
-
else if (hasSkills) {
|
|
221
|
-
choices.push({ name: `Apagar Skills`, value: "skills" });
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
224
|
-
choices.push({ name: `Apagar MCPs`, value: "mcps" });
|
|
225
|
-
}
|
|
226
|
-
const { action } = await inquirer.prompt([
|
|
227
|
-
{
|
|
228
|
-
type: "list",
|
|
229
|
-
name: "action",
|
|
230
|
-
message: "O que deseja remover?",
|
|
231
|
-
choices,
|
|
232
|
-
theme: sysTheme
|
|
233
|
-
}
|
|
234
|
-
]);
|
|
235
|
-
const removeSkills = action === "all" || action === "skills";
|
|
236
|
-
const removeMcps = action === "all" || action === "mcps";
|
|
237
|
-
// Confirmação
|
|
238
|
-
const target = action === "all" ? "skills e MCPs" : action === "skills" ? "skills" : "MCPs";
|
|
239
208
|
const { confirm } = await inquirer.prompt([
|
|
240
209
|
{
|
|
241
210
|
type: "confirm",
|
|
242
211
|
name: "confirm",
|
|
243
|
-
message:
|
|
212
|
+
message: "Confirma a remoção de TUDO?",
|
|
244
213
|
default: false,
|
|
245
214
|
theme: sysTheme
|
|
246
215
|
}
|
|
@@ -250,19 +219,11 @@ async function clearFlow() {
|
|
|
250
219
|
return;
|
|
251
220
|
}
|
|
252
221
|
console.log('');
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
console.log(` ${RED}✖${ANSI.reset} ${ANSI.dim}${s.dir}${ANSI.reset}`);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
if (removeMcps) {
|
|
260
|
-
for (const m of foundMcps) {
|
|
261
|
-
await fs.remove(m.file);
|
|
262
|
-
console.log(` ${RED}✖${ANSI.reset} ${ANSI.dim}${m.file}${ANSI.reset}`);
|
|
263
|
-
}
|
|
222
|
+
for (const f of found) {
|
|
223
|
+
await fs.remove(f.fullPath);
|
|
224
|
+
console.log(` ${RED}✖${ANSI.reset} ${ANSI.dim}${f.fullPath}${ANSI.reset} removido`);
|
|
264
225
|
}
|
|
265
|
-
console.log("\n
|
|
226
|
+
console.log("\n Projeto limpo.\n");
|
|
266
227
|
}
|
|
267
228
|
// ── Main ────────────────────────────────────────────────────────────────
|
|
268
229
|
async function main() {
|