@ruyfranca/myskills 1.0.25 → 1.0.26
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/index.js +59 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -175,19 +175,21 @@ program
|
|
|
175
175
|
.option('-w, --workflows', 'Atualiza apenas os workflows')
|
|
176
176
|
.action(async (options) => {
|
|
177
177
|
const updateAll = !options.skills && !options.agents && !options.workflows;
|
|
178
|
+
const destRoot = process.cwd();
|
|
179
|
+
const srcRoot = __dirname;
|
|
178
180
|
|
|
179
181
|
console.log(chalk.cyan('\n🔄 Atualizando kit do Antigravity...\n'));
|
|
180
182
|
|
|
181
183
|
const tasks = [];
|
|
182
184
|
|
|
183
185
|
if (updateAll || options.skills) {
|
|
184
|
-
tasks.push({ label: 'skills', src: path.join(
|
|
186
|
+
tasks.push({ label: 'skills', src: path.join(srcRoot, '.agent', 'skills'), dest: path.join(destRoot, '.agent', 'skills') });
|
|
185
187
|
}
|
|
186
188
|
if (updateAll || options.agents) {
|
|
187
|
-
tasks.push({ label: 'agents', src: path.join(
|
|
189
|
+
tasks.push({ label: 'agents', src: path.join(srcRoot, '.agent', 'agents'), dest: path.join(destRoot, '.agent', 'agents') });
|
|
188
190
|
}
|
|
189
191
|
if (updateAll || options.workflows) {
|
|
190
|
-
tasks.push({ label: 'workflows', src: path.join(
|
|
192
|
+
tasks.push({ label: 'workflows', src: path.join(srcRoot, '.agent', 'workflows'), dest: path.join(destRoot, '.agent', 'workflows') });
|
|
191
193
|
}
|
|
192
194
|
|
|
193
195
|
for (const task of tasks) {
|
|
@@ -198,9 +200,60 @@ program
|
|
|
198
200
|
try {
|
|
199
201
|
await fs.ensureDir(task.dest);
|
|
200
202
|
await fs.copy(task.src, task.dest, { overwrite: true });
|
|
201
|
-
console.log(chalk.green(` ✅ ${task.label}:
|
|
203
|
+
console.log(chalk.green(` ✅ ${task.label}: copiado`));
|
|
202
204
|
} catch (err) {
|
|
203
|
-
console.error(chalk.red(` ❌ ${task.label}: erro — ${err.message}`));
|
|
205
|
+
console.error(chalk.red(` ❌ ${task.label}: erro na cópia — ${err.message}`));
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Rewrite hardcoded paths (file:///...mySkills...) to point to the dest project
|
|
211
|
+
if (destRoot !== srcRoot) {
|
|
212
|
+
console.log(chalk.cyan('\n🔧 Corrigindo paths nos arquivos copiados...\n'));
|
|
213
|
+
|
|
214
|
+
const srcPathEncoded = `file://${srcRoot}`;
|
|
215
|
+
const destPathEncoded = `file://${destRoot}`;
|
|
216
|
+
|
|
217
|
+
const dirsToFix = [
|
|
218
|
+
path.join(destRoot, '.agent', 'workflows'),
|
|
219
|
+
path.join(destRoot, '.agent', 'agents'),
|
|
220
|
+
path.join(destRoot, '.agent', 'rules'),
|
|
221
|
+
path.join(destRoot, '.agent', 'skills'),
|
|
222
|
+
];
|
|
223
|
+
|
|
224
|
+
let fixedFiles = 0;
|
|
225
|
+
|
|
226
|
+
for (const dir of dirsToFix) {
|
|
227
|
+
if (!await fs.pathExists(dir)) continue;
|
|
228
|
+
|
|
229
|
+
const walk = async (currentDir) => {
|
|
230
|
+
const entries = await fs.readdir(currentDir, { withFileTypes: true });
|
|
231
|
+
for (const entry of entries) {
|
|
232
|
+
const fullPath = path.join(currentDir, entry.name);
|
|
233
|
+
if (entry.isDirectory()) {
|
|
234
|
+
await walk(fullPath);
|
|
235
|
+
} else if (['.md', '.txt', '.json'].includes(path.extname(entry.name))) {
|
|
236
|
+
try {
|
|
237
|
+
const content = await fs.readFile(fullPath, 'utf8');
|
|
238
|
+
if (content.includes(srcPathEncoded)) {
|
|
239
|
+
const fixed = content.replaceAll(srcPathEncoded, destPathEncoded);
|
|
240
|
+
await fs.writeFile(fullPath, fixed, 'utf8');
|
|
241
|
+
fixedFiles++;
|
|
242
|
+
}
|
|
243
|
+
} catch {
|
|
244
|
+
// ignorar arquivos binários ou inacessíveis
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
await walk(dir);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (fixedFiles > 0) {
|
|
254
|
+
console.log(chalk.green(` ✅ paths: ${fixedFiles} arquivo(s) corrigido(s)`));
|
|
255
|
+
} else {
|
|
256
|
+
console.log(chalk.gray(' ℹ️ paths: nenhuma substituição necessária'));
|
|
204
257
|
}
|
|
205
258
|
}
|
|
206
259
|
|
|
@@ -208,5 +261,6 @@ program
|
|
|
208
261
|
console.log(chalk.gray('💡 Dica: reinicie o Antigravity para carregar as novas skills/workflows.\n'));
|
|
209
262
|
});
|
|
210
263
|
|
|
264
|
+
|
|
211
265
|
program.parse();
|
|
212
266
|
|