nexakit 0.1.0 → 0.3.0

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 (124) hide show
  1. package/.claude-plugin/marketplace.json +18 -1
  2. package/README.md +51 -30
  3. package/assets/brand/README.md +0 -2
  4. package/assets/runtime/package-lock.json +2 -2
  5. package/bin/agent-task.js +12 -10
  6. package/bin/agent-toolkit-gemini.js +11 -9
  7. package/bin/agent-toolkit-inbox.js +12 -10
  8. package/bin/agent-toolkit-mcp.js +14 -8
  9. package/bin/agent-toolkit.js +12 -9
  10. package/bin/nexakit.js +12 -9
  11. package/bin/project-memory-mcp.js +12 -9
  12. package/bin/project-memory.js +5 -3
  13. package/catalogs/generadores.json +936 -0
  14. package/{skills/depurar → catalogs/skills/vercel-composition-patterns}/LICENSE.txt +6 -6
  15. package/catalogs/skills/vercel-react-best-practices/LICENSE.txt +27 -0
  16. package/catalogs/skills.json +70 -35
  17. package/docs/skills/evidencias/2026-10-28-recomendador-preparacion.md +1 -1
  18. package/package.json +5 -3
  19. package/plugins/nexakit-modelo/.claude-plugin/plugin.json +1 -0
  20. package/plugins/nexakit-modelo/hooks/hooks.json +1 -0
  21. package/plugins/nexakit-modelo/hooks/register.js +48 -0
  22. package/plugins/nexakit-modelo/hooks/status.js +8 -0
  23. package/plugins/nexakit-modelo/tests/register.test.ts +21 -0
  24. package/plugins/nexakit-panel/.claude-plugin/plugin.json +1 -0
  25. package/plugins/nexakit-panel/README.md +20 -0
  26. package/plugins/nexakit-panel/hooks/hooks.json +1 -0
  27. package/plugins/nexakit-panel/hooks/lienzo.js +382 -0
  28. package/plugins/nexakit-panel/hooks/panel.js +273 -0
  29. package/plugins/nexakit-panel/hooks/redact.js +9 -0
  30. package/plugins/nexakit-panel/hooks/register.tsx +248 -0
  31. package/plugins/nexakit-panel/tests/lienzo.test.ts +142 -0
  32. package/plugins/nexakit-panel/tests/panel.test.ts +240 -0
  33. package/plugins/nexakit-panel/tests/register.test.ts +167 -0
  34. package/plugins/nexakit-panel/types/index.d.ts +41 -0
  35. package/plugins/nexakit-sesion/.claude-plugin/plugin.json +1 -0
  36. package/plugins/nexakit-sesion/README.md +12 -0
  37. package/plugins/nexakit-sesion/hooks/aviso.js +38 -0
  38. package/plugins/nexakit-sesion/hooks/hooks.json +1 -0
  39. package/plugins/nexakit-sesion/hooks/register.js +28 -0
  40. package/plugins/nexakit-sesion/tests/register.test.ts +96 -0
  41. package/schemas/generators.schema.json +299 -0
  42. package/schemas/skill-catalog.schema.json +9 -2
  43. package/scripts/prepare-package.js +3 -0
  44. package/skills/cerrar-memoria/SKILL.md +6 -2
  45. package/skills/cerrar-memoria/references/cierre.md +5 -1
  46. package/skills/elegir-modelo/SKILL.md +68 -0
  47. package/skills/elegir-modelo/modelos.mjs +108 -0
  48. package/skills/gemini/SKILL.md +1 -1
  49. package/skills/project-handoff/SKILL.md +39 -12
  50. package/skills/project-handoff/references/handoff-template.md +24 -17
  51. package/skills/quality-gate/SKILL.md +6 -12
  52. package/skills/revisar/SKILL.md +6 -16
  53. package/skills/{desarrollo-con-pruebas/LICENSE.txt → revisar-skill/LICENSE-find-skills.txt} +5 -5
  54. package/skills/revisar-skill/SKILL.md +94 -0
  55. package/skills/revision-cruzada/SKILL.md +53 -475
  56. package/skills/web-design-guidelines/AGENTS.md +156 -0
  57. package/skills/{spec-driven-development → web-design-guidelines}/LICENSE.txt +1 -6
  58. package/skills/web-design-guidelines/SKILL.md +20 -30
  59. package/src/agent-models.js +53 -13
  60. package/src/brand.js +117 -0
  61. package/src/clean-command.js +29 -0
  62. package/src/clean-project-flow.js +105 -0
  63. package/src/clean-project.js +431 -0
  64. package/src/cli-executable.js +6 -4
  65. package/src/cli.js +16 -9
  66. package/src/connect.js +56 -4
  67. package/src/gemini-files.js +3 -3
  68. package/src/gemini-tools.js +23 -8
  69. package/src/generators-catalog.js +63 -0
  70. package/src/init.js +9 -1
  71. package/src/install-lock.js +127 -0
  72. package/src/install-registry.js +61 -0
  73. package/src/legacy-repair.js +71 -0
  74. package/src/link-states.js +172 -0
  75. package/src/memory-locator.js +118 -0
  76. package/src/missing-dependencies.js +21 -0
  77. package/src/model-command.js +147 -0
  78. package/src/panel-cli.js +182 -0
  79. package/src/project-root.js +60 -0
  80. package/src/project-signals.js +345 -0
  81. package/src/recommend-report.js +77 -0
  82. package/src/redact.js +9 -0
  83. package/src/review-instructions.js +211 -0
  84. package/src/review-policy.js +35 -0
  85. package/src/revision-adapters.js +157 -0
  86. package/src/revision-context.js +86 -0
  87. package/src/revision-isolation.js +222 -0
  88. package/src/revision-process.js +103 -0
  89. package/src/revision-provenance.js +89 -0
  90. package/src/revision-snapshot.js +120 -0
  91. package/src/revision.js +242 -0
  92. package/src/setup-apply.js +231 -0
  93. package/src/setup-plan.js +231 -0
  94. package/src/setup-state.js +284 -0
  95. package/src/setup-tui.js +647 -0
  96. package/src/skill-catalog-add.js +91 -0
  97. package/src/skill-catalog-audit.js +26 -27
  98. package/src/skill-files.js +39 -0
  99. package/src/skill-recommendations.js +344 -208
  100. package/src/skill-scan-report.js +14 -0
  101. package/src/skill-scan.js +178 -0
  102. package/src/stable-command.js +53 -0
  103. package/src/stable-install.js +222 -0
  104. package/src/superpowers.js +133 -0
  105. package/src/sync-apply.js +8 -5
  106. package/src/sync-files.js +2 -1
  107. package/src/terminal-text.js +68 -0
  108. package/src/toolkit-cli.js +397 -70
  109. package/src/toolkit-commands-guide.js +53 -39
  110. package/src/toolkit-setup.js +507 -110
  111. package/assets/brand/agent-toolkit-mark-v1.png +0 -0
  112. package/skills/depurar/SKILL.md +0 -69
  113. package/skills/depurar/agents/openai.yaml +0 -7
  114. package/skills/depurar/references/tecnicas-de-diagnostico.md +0 -37
  115. package/skills/desarrollo-con-pruebas/SKILL.md +0 -55
  116. package/skills/desarrollo-con-pruebas/agents/openai.yaml +0 -7
  117. package/skills/desarrollo-con-pruebas/references/buenas-pruebas.md +0 -33
  118. package/skills/estado/SKILL.md +0 -41
  119. package/skills/programar/SKILL.md +0 -19
  120. package/skills/spec-driven-development/SKILL.md +0 -48
  121. package/skills/spec-driven-development/agents/openai.yaml +0 -7
  122. package/skills/spec-driven-development/references/spec-template.md +0 -55
  123. package/skills/spec-driven-development/references/workflow.md +0 -70
  124. package/src/toolkit-tui.js +0 -961
@@ -0,0 +1,431 @@
1
+ import { constants } from 'node:fs';
2
+ import { runCleanCommand } from './clean-command.js';
3
+ import { sinSecretos } from './redact.js';
4
+ import fs from 'node:fs/promises';
5
+ import path from 'node:path';
6
+ import { gitTopLevel, runGit as defaultRunGit } from './project-root.js';
7
+
8
+ const ignoredEntries = new Set(['.git', '.DS_Store', 'Thumbs.db']);
9
+ export async function inspectFolder(dir, { runGit = defaultRunGit } = {}) {
10
+ const root = await fs.realpath(dir);
11
+ const entries = (await fs.readdir(root)).sort();
12
+ return {
13
+ empty: entries.every((name) => ignoredEntries.has(name)),
14
+ insideGit: Boolean(await gitTopLevel(root, runGit)),
15
+ entries,
16
+ };
17
+ }
18
+ export function projectName(dir) {
19
+ const normalized = path
20
+ .basename(dir)
21
+ .normalize('NFD')
22
+ .replace(/\p{M}/gu, '')
23
+ .toLowerCase()
24
+ .replace(/[^a-z0-9-]+/g, '-')
25
+ .replace(/^-+|-+$/g, '')
26
+ .slice(0, 214)
27
+ .replace(/-+$/g, '');
28
+ return normalized || 'proyecto';
29
+ }
30
+
31
+ // Pure plan: cwd and write paths are relative to the selected project root.
32
+ // The executor (a later task) owns venv creation, confinement and exclusive writes.
33
+ export function planCleanProject({ choice, catalog, name, platform = process.platform }) {
34
+ if (!choice || typeof choice !== 'object' || Array.isArray(choice))
35
+ throw new Error('Elección de proyecto inválida.');
36
+ const order = ['frontend', 'backend', 'mobile'];
37
+ for (const part of Object.keys(choice))
38
+ if (![...order, 'database'].includes(part)) throw new Error(`Parte desconocida: ${part}.`);
39
+ const selected = {};
40
+ for (const part of [...order, 'database']) {
41
+ if (choice[part] == null) continue;
42
+ const generator = catalog.generators.find((g) => g.id === choice[part] && g.part === part);
43
+ if (!generator) throw new Error(`Elección inválida para ${part}.`);
44
+ selected[part] = generator;
45
+ }
46
+ const database = selected.database;
47
+ if (database && database.id !== 'supabase' && !selected.backend)
48
+ throw new Error('Esta base de datos necesita un backend.');
49
+ const hostPart = database?.id === 'supabase' && selected.frontend ? 'frontend' : 'backend';
50
+ if (database && !selected[hostPart]) throw new Error('La base de datos necesita un frontend o backend.');
51
+ const hostConfig = database?.database.backends[selected[hostPart]?.id];
52
+ if (database && !hostConfig) throw new Error('La base de datos no admite la parte elegida.');
53
+ const count = order.filter((part) => selected[part]).length;
54
+ const venvBin = platform === 'win32' ? '.venv\\Scripts' : '.venv/bin';
55
+ const python = platform === 'win32' ? `${venvBin}\\python.exe` : `${venvBin}/python`;
56
+ const normalizedName = projectName(name);
57
+ const parts = order
58
+ .filter((part) => selected[part])
59
+ .map((part) => {
60
+ const g = selected[part],
61
+ dir = count === 1 ? '.' : part === 'mobile' ? 'movil' : part;
62
+ const substitutions = { dir, name: normalizedName, python, venvBin };
63
+ const expand = (value) =>
64
+ value.replace(
65
+ /\{(dir|name|python|venvBin)\}(\/)?/g,
66
+ (_, key, slash) =>
67
+ substitutions[key] + (slash ? (key === 'venvBin' && platform === 'win32' ? '\\' : '/') : ''),
68
+ );
69
+ const commands = [],
70
+ writes = [];
71
+ const append = (steps, root = false) => {
72
+ for (const step of steps) {
73
+ if (step.kind === 'run')
74
+ commands.push({ argv: step.argv.map(expand), cwd: root || step.cwd === 'parent' ? '.' : dir });
75
+ else writes.push({ path: path.posix.join(dir, expand(step.path)), content: expand(step.content) });
76
+ }
77
+ };
78
+ append(g.steps);
79
+ append(g.install);
80
+ if (database && part === hostPart) {
81
+ append(database.steps, true);
82
+ append(database.install, true);
83
+ append(hostConfig.install);
84
+ if (hostConfig.envExample)
85
+ writes.push({ path: path.posix.join(dir, '.env.example'), content: expand(hostConfig.envExample) });
86
+ }
87
+ return { part, id: g.id, dir, commands, writes, check: { argv: g.check.argv.map(expand), cwd: dir } };
88
+ });
89
+ const pythonUsed = Object.values(selected).some((g) => g.requires.some((r) => r.program === 'python'));
90
+ return { parts, databaseId: database?.id ?? null, gitignore: [...(pythonUsed ? ['.venv/'] : []), '.env'] };
91
+ }
92
+
93
+ export async function checkRequirements(
94
+ plan,
95
+ catalog,
96
+ { runCommand, platform = process.platform, timeoutMs = 10000, signal } = {},
97
+ ) {
98
+ const required = new Map();
99
+ for (const id of [...plan.parts.map((p) => p.id), plan.databaseId].filter(Boolean)) {
100
+ for (const requirement of catalog.generators.find((g) => g.id === id).requires) {
101
+ const previous = required.get(requirement.program);
102
+ if (!previous || compareVersions(requirement.minVersion, previous) > 0)
103
+ required.set(requirement.program, requirement.minVersion);
104
+ }
105
+ }
106
+ const results = [];
107
+ for (const [program, minVersion] of required) {
108
+ let found = null,
109
+ timer,
110
+ cancel;
111
+ const controller = new AbortController();
112
+ try {
113
+ const result = await Promise.race([
114
+ Promise.resolve().then(() => {
115
+ if (controller.signal.aborted) throw Error('Cancelado');
116
+ return runCommand(
117
+ program === 'python' ? (platform === 'win32' ? 'py' : 'python3') : 'node',
118
+ ['--version'],
119
+ { signal: controller.signal, timeoutMs },
120
+ );
121
+ }),
122
+ new Promise((_, reject) => {
123
+ cancel = () => {
124
+ controller.abort();
125
+ reject(Error('Cancelado'));
126
+ };
127
+ signal?.addEventListener('abort', cancel, { once: true });
128
+ if (signal?.aborted) cancel();
129
+ timer = setTimeout(cancel, timeoutMs);
130
+ }),
131
+ ]);
132
+ const output =
133
+ typeof result === 'string' ? result : result?.status === 0 || result?.code === 0 ? result.stdout : '';
134
+ found = String(output ?? '').match(/\b(?:v|Python\s+)?(\d+\.\d+(?:\.\d+)?)\b/)?.[1] ?? null;
135
+ } catch {
136
+ /* Missing or timed-out programs are a blocking result. */
137
+ } finally {
138
+ clearTimeout(timer);
139
+ signal?.removeEventListener('abort', cancel);
140
+ }
141
+ results.push({
142
+ program,
143
+ minVersion,
144
+ found,
145
+ ok: found !== null && compareVersions(found, minVersion) >= 0,
146
+ });
147
+ }
148
+ return results;
149
+ }
150
+ function compareVersions(a, b) {
151
+ const aa = a.split('.').map(Number),
152
+ bb = b.split('.').map(Number);
153
+ for (let i = 0; i < 3; i++) if ((aa[i] ?? 0) !== (bb[i] ?? 0)) return (aa[i] ?? 0) - (bb[i] ?? 0);
154
+ return 0;
155
+ }
156
+
157
+ const lstatOrNull = (full) =>
158
+ fs.lstat(full).catch((e) => {
159
+ if (e.code === 'ENOENT') return null;
160
+ throw e;
161
+ });
162
+ async function physicalDirectory(full) {
163
+ const stat = await lstatOrNull(full);
164
+ if (!stat) {
165
+ await fs.mkdir(full);
166
+ return;
167
+ }
168
+ if (!stat.isDirectory() || stat.isSymbolicLink()) throw Error('La carpeta de destino no es segura.');
169
+ }
170
+ function confined(root, relative) {
171
+ if (
172
+ typeof relative !== 'string' ||
173
+ path.isAbsolute(relative) ||
174
+ relative.includes('\\') ||
175
+ relative.includes(':') ||
176
+ relative.split('/').includes('..')
177
+ )
178
+ throw Error('Ruta fuera del proyecto.');
179
+ const full = path.resolve(root, relative);
180
+ if (full !== root && !full.startsWith(root + path.sep)) throw Error('Ruta fuera del proyecto.');
181
+ return full;
182
+ }
183
+ async function copyExclusive(source, destination, sourceRoot, destinationRoot, ignored = new Set()) {
184
+ for (const entry of await fs.readdir(source, { withFileTypes: true })) {
185
+ if (ignored.has(entry.name)) continue;
186
+ if (entry.name === '.git') throw Error('El generador intentó crear un repositorio Git propio.');
187
+ const from = path.join(source, entry.name),
188
+ to = path.join(destination, entry.name);
189
+ if (entry.isDirectory()) {
190
+ await fs.mkdir(to);
191
+ await copyExclusive(from, to, sourceRoot, destinationRoot);
192
+ } else if (entry.isFile()) await fs.copyFile(from, to, constants.COPYFILE_EXCL);
193
+ else if (entry.isSymbolicLink()) {
194
+ const target = await fs.readlink(from),
195
+ resolved = path.resolve(path.dirname(from), target);
196
+ if (path.isAbsolute(target) || !resolved.startsWith(sourceRoot + path.sep))
197
+ throw Error('Enlace generado fuera del proyecto.');
198
+ await fs.symlink(target, to);
199
+ } else throw Error('Archivo generado no admitido.');
200
+ }
201
+ }
202
+ export async function runCleanProject(
203
+ plan,
204
+ {
205
+ projectRoot,
206
+ runCommand = runCleanCommand,
207
+ onProgress = () => {},
208
+ now = Date.now,
209
+ timeoutMs = 600000,
210
+ platform = process.platform,
211
+ onCreated = async () => {},
212
+ signal,
213
+ } = {},
214
+ ) {
215
+ const root = await fs.realpath(projectRoot),
216
+ done = [],
217
+ log = [];
218
+ let workspace,
219
+ currentPart = plan.parts[0]?.part ?? 'proyecto',
220
+ currentArgv = [];
221
+ const toolkit = path.join(root, '.agent-toolkit');
222
+ const record = (text) => log.push(`${new Date(now()).toISOString()} ${sinSecretos(text)}`);
223
+ const runPlannedCommand = async (values, cwd) => {
224
+ currentArgv = values;
225
+ onProgress(currentPart, values);
226
+ record(values.join(' '));
227
+ const controller = new AbortController();
228
+ let timer,
229
+ cancel,
230
+ running,
231
+ interrupted = false,
232
+ partial = '';
233
+ try {
234
+ const result = await Promise.race([
235
+ (running = Promise.resolve().then(() =>
236
+ runCommand(values[0], values.slice(1), {
237
+ cwd,
238
+ signal: controller.signal,
239
+ timeoutMs,
240
+ onOutput: (chunk) => {
241
+ if (partial.length < 16 * 1024 * 1024) partial += chunk;
242
+ },
243
+ env: {
244
+ ...process.env,
245
+ CI: '1',
246
+ npm_config_cache: path.join(workspace, 'npm-cache'),
247
+ PIP_CACHE_DIR: path.join(workspace, 'pip-cache'),
248
+ PIP_NO_INPUT: '1',
249
+ },
250
+ }),
251
+ )),
252
+ new Promise((_, reject) => {
253
+ cancel = () => {
254
+ interrupted = true;
255
+ controller.abort();
256
+ reject(Error('Creación cancelada.'));
257
+ };
258
+ signal?.addEventListener('abort', cancel, { once: true });
259
+ if (signal?.aborted) cancel();
260
+ timer = setTimeout(() => {
261
+ interrupted = true;
262
+ controller.abort();
263
+ reject(Error('La orden superó el tiempo límite.'));
264
+ }, timeoutMs);
265
+ }),
266
+ ]);
267
+ const status = result?.status ?? result?.code;
268
+ const output = commandOutput(result);
269
+ record(`salida ${status ?? 0}: ${output}`);
270
+ if (typeof result !== 'string' && status !== 0) throw Error(output || 'La orden falló.');
271
+ } catch (error) {
272
+ if (interrupted) {
273
+ let closeTimer;
274
+ const stopped = await Promise.race([
275
+ running.catch(() => null),
276
+ new Promise((resolve) => {
277
+ closeTimer = setTimeout(() => resolve(null), 1000);
278
+ }),
279
+ ]);
280
+ clearTimeout(closeTimer);
281
+ record(`salida parcial: ${stopped ? `${stopped.stdout ?? ''}\n${stopped.stderr ?? ''}` : partial}`);
282
+ }
283
+ throw error;
284
+ } finally {
285
+ clearTimeout(timer);
286
+ signal?.removeEventListener('abort', cancel);
287
+ }
288
+ };
289
+ try {
290
+ if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) throw Error('Tiempo límite inválido.');
291
+ const entries = await fs.readdir(root);
292
+ if (entries.some((n) => !ignoredEntries.has(n)))
293
+ throw Error('La carpeta contiene archivos existentes; no se sobrescribirá nada.');
294
+ await physicalDirectory(toolkit);
295
+ workspace = await fs.mkdtemp(path.join(toolkit, 'creacion-'));
296
+ // A temporary Git boundary prevents upstream generators (Expo) initializing
297
+ // or prompting about Git. It is never copied into the actual project.
298
+ const git = path.join(workspace, '.git');
299
+ await fs.mkdir(git);
300
+ for (const sub of ['objects', 'refs']) await fs.mkdir(path.join(git, sub));
301
+ await fs.writeFile(path.join(git, 'HEAD'), 'ref: refs/heads/main\n', { flag: 'wx' });
302
+ await fs.writeFile(path.join(git, 'config'), '[core]\nrepositoryformatversion = 0\nbare = false\n', {
303
+ flag: 'wx',
304
+ });
305
+ const stage = path.join(workspace, projectName(root));
306
+ await fs.mkdir(stage);
307
+ const promotedShared = new Set(plan.parts.map((p) => p.dir));
308
+ for (const part of plan.parts) {
309
+ currentPart = part.part;
310
+ const dir = confined(stage, part.dir);
311
+ const pythonUsed = part.commands.some((c) => /\.venv[\\/]/.test(c.argv[0]));
312
+ if (pythonUsed || part.writes.length) await physicalDirectory(dir);
313
+ const destination = confined(root, part.dir);
314
+ if (destination !== root) await fs.mkdir(destination);
315
+ if (pythonUsed)
316
+ await runPlannedCommand(
317
+ [platform === 'win32' ? 'py' : 'python3', '-m', 'venv', '.venv'],
318
+ destination,
319
+ );
320
+ const finalArgv = (values) =>
321
+ values.map((value) =>
322
+ /^\.venv[\\/]/.test(value) ? path.join(destination, ...value.split(/[\\/]/)) : value,
323
+ );
324
+ for (const w of part.writes) {
325
+ const full = confined(stage, w.path);
326
+ await fs.writeFile(full, w.content, { flag: 'wx' });
327
+ }
328
+ for (const c of part.commands) await runPlannedCommand(finalArgv(c.argv), confined(stage, c.cwd));
329
+ await copyExclusive(dir, destination, stage, root);
330
+ if (part.dir !== '.') {
331
+ const shared = (await fs.readdir(stage)).filter((name) => !promotedShared.has(name));
332
+ await copyExclusive(stage, root, stage, root, promotedShared);
333
+ shared.forEach((name) => promotedShared.add(name));
334
+ }
335
+ await onCreated(part.part);
336
+ await runPlannedCommand(finalArgv(part.check.argv), destination);
337
+ done.push(part.part);
338
+ }
339
+ record('Creación comprobada.');
340
+ await fs.rm(workspace, { recursive: true });
341
+ return { ok: true, done };
342
+ } catch (error) {
343
+ const output = sinSecretos(error.message ?? String(error));
344
+ record(output);
345
+ return {
346
+ ok: false,
347
+ done,
348
+ failed: { part: currentPart, argv: currentArgv, output },
349
+ ...(workspace && { workspace }),
350
+ };
351
+ } finally {
352
+ // An unsafe .agent-toolkit is not followed even to save an error report.
353
+ try {
354
+ await physicalDirectory(toolkit);
355
+ const file = path.join(toolkit, 'creacion.log'),
356
+ stat = await lstatOrNull(file);
357
+ if (stat && (!stat.isFile() || stat.isSymbolicLink() || stat.nlink !== 1))
358
+ throw Error('Registro inseguro.');
359
+ await fs.appendFile(file, log.join('\n') + '\n', { mode: 0o600 });
360
+ } catch (error) {
361
+ return {
362
+ ok: false,
363
+ done,
364
+ failed: {
365
+ part: currentPart,
366
+ argv: currentArgv,
367
+ output: sinSecretos(`No se pudo guardar el registro: ${error.message}`),
368
+ },
369
+ };
370
+ }
371
+ }
372
+ }
373
+
374
+ export async function ensureCleanIgnore(projectRoot, gitignore = []) {
375
+ const root = await fs.realpath(projectRoot),
376
+ file = path.join(root, '.gitignore'),
377
+ stat = await lstatOrNull(file);
378
+ if (stat && (!stat.isFile() || stat.isSymbolicLink() || stat.nlink !== 1 || stat.size > 1024 * 1024))
379
+ throw Error('.gitignore no es un archivo seguro.');
380
+ const text = stat ? await fs.readFile(file, 'utf8') : '',
381
+ lines = new Set(text.split(/\r?\n/));
382
+ const missing = [...new Set([...gitignore, '.agent-toolkit/'])].filter((line) => !lines.has(line));
383
+ if (missing.length)
384
+ await fs.appendFile(file, `${text && !text.endsWith('\n') ? '\n' : ''}${missing.join('\n')}\n`);
385
+ }
386
+ export async function appendCleanLog(root, text) {
387
+ const dir = path.join(root, '.agent-toolkit');
388
+ await physicalDirectory(dir);
389
+ const file = path.join(dir, 'creacion.log'),
390
+ stat = await lstatOrNull(file);
391
+ if (stat && (!stat.isFile() || stat.isSymbolicLink() || stat.nlink !== 1))
392
+ throw Error('Registro inseguro.');
393
+ await fs.appendFile(file, `${new Date().toISOString()} ${sinSecretos(text)}\n`, { mode: 0o600 });
394
+ }
395
+ export async function initGit(
396
+ projectRoot,
397
+ { runCommand = runCleanCommand, insideGit, gitignore = [], onCommand = async () => {} } = {},
398
+ ) {
399
+ if (insideGit) return 'omitido-repo-existente';
400
+ const root = await fs.realpath(projectRoot);
401
+ const run = async (args) => {
402
+ let result;
403
+ try {
404
+ result = await runCommand('git', args, { cwd: root, signal: AbortSignal.timeout(30000) });
405
+ } catch (error) {
406
+ await onCommand(['git', ...args], error.message);
407
+ throw Object.assign(error, { argv: ['git', ...args] });
408
+ }
409
+ const status = typeof result === 'string' ? 0 : (result?.status ?? result?.code);
410
+ const output = typeof result === 'string' ? result : `${result?.stdout ?? ''}\n${result?.stderr ?? ''}`;
411
+ await onCommand(['git', ...args], `salida ${status}: ${output}`);
412
+ if (status !== 0)
413
+ throw Object.assign(Error(sinSecretos(output || 'Git no completó la orden.')), {
414
+ argv: ['git', ...args],
415
+ });
416
+ };
417
+ try {
418
+ await run(['--version']);
419
+ } catch {
420
+ return 'sin-git';
421
+ }
422
+ await ensureCleanIgnore(root, gitignore);
423
+ await run(['init']);
424
+ await run(['add', '-A']);
425
+ await run(['commit', '-m', 'chore: crear la base del proyecto con nexakit']);
426
+ return 'hecho';
427
+ }
428
+
429
+ function commandOutput(result) {
430
+ return typeof result === 'string' ? result : `${result?.stdout ?? ''}\n${result?.stderr ?? ''}`;
431
+ }
@@ -2,7 +2,7 @@ import fs from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import { IS_WINDOWS } from "./platform.js";
4
4
 
5
- const PACKAGES = { codex: "@openai/codex", claude: "@anthropic-ai/claude-code" };
5
+ const PACKAGES = { npm: "npm", npx: "npm", codex: "@openai/codex", claude: "@anthropic-ai/claude-code" };
6
6
  const NODE_EXTENSIONS = new Set([".js", ".cjs", ".mjs"]);
7
7
  const unavailable = () => { throw Object.assign(new Error("CLI executable unavailable"), { code: "ENOENT" }); };
8
8
  const invalidBin = () => { throw Object.assign(new Error("El bin npm debe ser un archivo .js, .cjs o .mjs existente."), { code: "EINVAL" }); };
@@ -36,7 +36,9 @@ async function packageInvocation(directory, name, io, expectedScript) {
36
36
  }
37
37
 
38
38
  export async function resolveCliInvocation({ name, override, environment = process.env, fileIo = fs } = {}) {
39
- if (!Object.hasOwn(PACKAGES, name)) unavailable();
39
+ // agy (Antigravity) is a native executable, not an npm package: only found as such on the PATH.
40
+ const native = name === "agy";
41
+ if (!native && !Object.hasOwn(PACKAGES, name)) unavailable();
40
42
  if (override) {
41
43
  const absolute = path.resolve(override);
42
44
  let stat;
@@ -48,7 +50,7 @@ export async function resolveCliInvocation({ name, override, environment = proce
48
50
  }
49
51
  const extension = path.extname(absolute).toLowerCase();
50
52
  if ([".exe", ".com"].includes(extension)) return { executable: absolute, argsPrefix: [] };
51
- if (extension === ".cmd" || NODE_EXTENSIONS.has(extension)) {
53
+ if (!native && (extension === ".cmd" || NODE_EXTENSIONS.has(extension))) {
52
54
  const directories = [path.dirname(absolute)];
53
55
  // Explicit npm bin scripts may live inside the CLI package itself.
54
56
  if (NODE_EXTENSIONS.has(extension)) {
@@ -77,7 +79,7 @@ export async function resolveCliInvocation({ name, override, environment = proce
77
79
  if (stat.isFile() && (IS_WINDOWS || ((stat.mode & 0o111) && !(stat.mode & 0o022)))) return { executable, argsPrefix: [] };
78
80
  } catch {}
79
81
  }
80
- if (IS_WINDOWS) {
82
+ if (IS_WINDOWS && !native) {
81
83
  const result = await packageInvocation(directory, name, fileIo);
82
84
  if (result) return result;
83
85
  }
package/src/cli.js CHANGED
@@ -39,7 +39,7 @@ Opciones de doctor:
39
39
  --strict Devuelve error cuando existan advertencias.
40
40
 
41
41
  Opciones de connect:
42
- --agent <agente> Agente a conectar: codex o claude.
42
+ --agent <agente> Agente a conectar: codex, claude o antigravity.
43
43
  --manifest <ruta> Selecciona un manifiesto concreto.
44
44
  --apply Aplica el plan; sin esta opción solo previsualiza.
45
45
 
@@ -87,9 +87,16 @@ Evita editar o sincronizar la memoria durante --apply: su bloqueo no controla
87
87
  editores externos. Ni record ni apply crean commits o hacen push. apply puede
88
88
  quedar parcial entre notas: no revierte ni registra automáticamente el PR.`;
89
89
 
90
+ // Invoked as `npx nexakit memoria`, the help names that command and keeps project-memory as the compatible executable.
91
+ const DEFAULT_COMMAND = "project-memory";
92
+ function helpFor(commandName = DEFAULT_COMMAND) {
93
+ if (commandName === DEFAULT_COMMAND) return HELP;
94
+ return `${HELP.replaceAll(DEFAULT_COMMAND, commandName)}\n\nEl ejecutable ${DEFAULT_COMMAND} es compatible y acepta los mismos subcomandos.`;
95
+ }
96
+
90
97
  export async function runCli(argv, io = defaultIo(), context = {}) {
91
98
  if (argv.length === 0 || argv.includes("--help") || argv.includes("-h")) {
92
- io.out(HELP);
99
+ io.out(helpFor(context.commandName));
93
100
  return 0;
94
101
  }
95
102
 
@@ -103,11 +110,11 @@ export async function runCli(argv, io = defaultIo(), context = {}) {
103
110
  }
104
111
 
105
112
  if (command === "connect") {
106
- return runConnectCommand(rest, io);
113
+ return runConnectCommand(rest, io, context);
107
114
  }
108
115
 
109
116
  if (command === "status") {
110
- return runStatusCommand(rest, io);
117
+ return runStatusCommand(rest, io, context);
111
118
  }
112
119
 
113
120
  if (command === "sync") {
@@ -115,7 +122,7 @@ export async function runCli(argv, io = defaultIo(), context = {}) {
115
122
  }
116
123
 
117
124
  io.err(`Comando desconocido: ${command}`);
118
- io.err(HELP);
125
+ io.err(helpFor(context.commandName));
119
126
  return 2;
120
127
  }
121
128
 
@@ -319,7 +326,7 @@ async function runSyncApplyCommand(args, io, context) {
319
326
  }
320
327
  }
321
328
 
322
- async function runStatusCommand(rest, io) {
329
+ async function runStatusCommand(rest, io, context = {}) {
323
330
  const options = {
324
331
  targetPath: process.cwd()
325
332
  };
@@ -366,7 +373,7 @@ async function runStatusCommand(rest, io) {
366
373
 
367
374
  let report;
368
375
  try {
369
- report = await inspectMemoryStatus(options);
376
+ report = await inspectMemoryStatus(options, context);
370
377
  } catch (error) {
371
378
  const message = error instanceof Error ? error.message : String(error);
372
379
  io.err(`No se pudo inspeccionar el estado: ${message}`);
@@ -388,7 +395,7 @@ async function runStatusCommand(rest, io) {
388
395
  return 0;
389
396
  }
390
397
 
391
- async function runConnectCommand(rest, io) {
398
+ async function runConnectCommand(rest, io, context = {}) {
392
399
  const options = {
393
400
  apply: false,
394
401
  targetPath: process.cwd()
@@ -435,7 +442,7 @@ async function runConnectCommand(rest, io) {
435
442
 
436
443
  let report;
437
444
  try {
438
- report = await connectMemory(options);
445
+ report = await connectMemory(options, context);
439
446
  } catch (error) {
440
447
  if (error instanceof ConnectionError) {
441
448
  for (const detail of error.details) {
package/src/connect.js CHANGED
@@ -42,14 +42,20 @@ const ADAPTERS = Object.freeze({
42
42
  },
43
43
  claude: {
44
44
  skillDirectory: ".claude/skills"
45
+ },
46
+ antigravity: {
47
+ skillDirectory: ".gemini/antigravity-cli/skills"
45
48
  }
46
49
  });
50
+ // The command each agent is driven with.
51
+ const AGENT_COMMANDS = Object.freeze({ codex: "codex", claude: "claude", antigravity: "agy" });
52
+ const MEMORY_SCRIPT = path.join("bin", "project-memory-mcp.js");
47
53
 
48
54
  export async function connectMemory(options, context = {}) {
49
55
  const config = loadConfig(options, context);
50
- const runner = context.runCommand ?? (IS_WINDOWS ? await windowsCommandRunner(config.agentId) : runCommand);
56
+ const runner = context.runCommand ?? (IS_WINDOWS ? await windowsCommandRunner(AGENT_COMMANDS[config.agentId]) : runCommand);
51
57
  const skill = inspectSkill(config);
52
- const connection = inspectConnection(config, runner);
58
+ const connection = inspectConnection(config, runner, context);
53
59
  const components = [skill, ...connection.components];
54
60
  const report = createReport(config, components, options.apply === true);
55
61
 
@@ -94,7 +100,7 @@ function loadConfig(options, context) {
94
100
  errors.push("No se encontró project-memory.json.");
95
101
  }
96
102
  if (!ADAPTERS[agentId]) {
97
- errors.push("--agent debe ser codex o claude.");
103
+ errors.push("--agent debe ser codex, claude o antigravity.");
98
104
  }
99
105
  if (errors.length > 0) {
100
106
  throw new ConnectionError(errors);
@@ -221,10 +227,13 @@ function inspectSkill(config) {
221
227
  };
222
228
  }
223
229
 
224
- function inspectConnection(config, runner) {
230
+ function inspectConnection(config, runner, context) {
225
231
  if (config.agentId === "codex") {
226
232
  return inspectCodex(config, runner);
227
233
  }
234
+ if (config.agentId === "antigravity") {
235
+ return inspectAntigravity(config, runner, context);
236
+ }
228
237
  return inspectClaude(config, runner);
229
238
  }
230
239
 
@@ -364,6 +373,49 @@ function inspectClaude(config, runner) {
364
373
  };
365
374
  }
366
375
 
376
+ // Antigravity cannot restrict the tools of an MCP server, so it gets nexakit's own memory server, which only has
377
+ // read tools, run from the active nexakit root. Its configuration is read from mcp_config.json, which keeps the
378
+ // exact arguments (the text of `agy mcp list` does not separate paths with spaces).
379
+ function inspectAntigravity(config, runner, context) {
380
+ const probe = runner("agy", ["mcp", "list"]);
381
+ if (probe.errorCode === "ENOENT") {
382
+ const unavailable = unavailableCommand("agy");
383
+ unavailable.components = unavailable.components.filter((item) => item.id === "mcp");
384
+ return unavailable;
385
+ }
386
+ const nodePath = context.nodePath ?? process.execPath;
387
+ const script = path.join(path.resolve(context.toolkitRoot ?? path.resolve(SOURCE_DIRECTORY, "..")), MEMORY_SCRIPT);
388
+ const manifestPath = fs.realpathSync(config.manifestPath);
389
+ const configPath = path.join(config.homeDirectory, ".gemini", "config", "mcp_config.json");
390
+ let current;
391
+ if (pathEntryExists(configPath)) {
392
+ if (fs.lstatSync(configPath).isSymbolicLink()) {
393
+ return { components: [component("mcp", "conflict", "La configuración de Antigravity es un enlace simbólico y no se reemplazará.")], apply() {} };
394
+ }
395
+ current = readJson(configPath, "configuración de Antigravity").mcpServers?.[config.mcpName];
396
+ }
397
+ const same = current && Array.isArray(current.args) && current.args.length === 3 &&
398
+ samePath(current.args[0], script) && current.args[1] === "--manifest" && samePath(current.args[2], manifestPath) &&
399
+ typeof current.command === "string" && /^node(\.exe)?$/iu.test(path.basename(current.command));
400
+ const mcp = !current
401
+ ? component("mcp", "create", "Registrar la memoria de solo lectura en Antigravity.")
402
+ : same
403
+ ? component("mcp", "unchanged", "Antigravity ya usa esta memoria.")
404
+ : component("mcp", "conflict", "Antigravity tiene un MCP homónimo diferente.");
405
+ mcp.path = configPath;
406
+ return {
407
+ components: [mcp],
408
+ apply() {
409
+ if (mcp.action === "create") {
410
+ requireSuccess(
411
+ runner("agy", ["mcp", "add", config.mcpName, "--", nodePath, script, "--manifest", manifestPath]),
412
+ "No se pudo registrar el MCP en Antigravity."
413
+ );
414
+ }
415
+ }
416
+ };
417
+ }
418
+
367
419
  function unavailableCommand(command) {
368
420
  return {
369
421
  components: [
@@ -9,16 +9,16 @@ export async function readRegular(file, limit = 20 * 1024 * 1024) {
9
9
  const handle = await fs.open(file, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0));
10
10
  try {
11
11
  const opened = await handle.stat();
12
- if (!opened.isFile() || opened.nlink !== 1 || opened.ino !== before.ino || opened.dev !== before.dev || opened.size !== before.size) throw new Error('El archivo cambió.');
12
+ if (!opened.isFile() || opened.nlink !== 1 || opened.ino !== before.ino || opened.dev !== before.dev || opened.size !== before.size) throw Object.assign(new Error('El archivo cambió.'), { code: 'EFILECHANGED' });
13
13
  const bytes = Buffer.alloc(opened.size); let offset = 0;
14
14
  while (offset < bytes.length) {
15
15
  const { bytesRead } = await handle.read(bytes, offset, Math.min(65536, bytes.length-offset), offset);
16
- if (!bytesRead) throw new Error('Lectura incompleta.'); offset += bytesRead;
16
+ if (!bytesRead) throw Object.assign(new Error('Lectura incompleta.'), { code: 'EFILECHANGED' }); offset += bytesRead;
17
17
  }
18
18
  const after = await handle.stat();
19
19
  const named = await fs.lstat(file);
20
20
  if (!named.isFile() || named.isSymbolicLink() || named.nlink !== 1 || named.ino !== opened.ino || named.dev !== opened.dev ||
21
- after.nlink !== 1 || after.size !== opened.size || after.mtimeMs !== opened.mtimeMs || after.ctimeMs !== opened.ctimeMs) throw new Error('El archivo cambió.');
21
+ after.nlink !== 1 || after.size !== opened.size || after.mtimeMs !== opened.mtimeMs || after.ctimeMs !== opened.ctimeMs) throw Object.assign(new Error('El archivo cambió.'), { code: 'EFILECHANGED' });
22
22
  return bytes;
23
23
  } finally { await handle.close(); }
24
24
  }