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
@@ -1,10 +1,18 @@
1
+ import generatorsData from '../catalogs/generadores.json' with { type: 'json' };
2
+ import { ownedReviewInstructions, removeReviewInstructions } from './review-instructions.js';
1
3
  import { createHash } from 'node:crypto';
2
4
  import fs from 'node:fs/promises';
3
5
  import os from 'node:os';
4
6
  import path from 'node:path';
7
+ import { acquireLock } from './install-lock.js';
8
+ import { isRegistered, readRegistry, recordEntries } from './install-registry.js';
9
+ import { classifyLink, relinkIfUnchanged } from './link-states.js';
5
10
  import { IS_WINDOWS } from './platform.js';
11
+ import { detectSignals, SIGNAL_LABELS } from './project-signals.js';
12
+ import { resolveProjectRoot } from './project-root.js';
6
13
  import { loadSkillCatalog } from './skill-catalog.js';
7
- import { TOOLKIT_ROOT } from './toolkit-setup.js';
14
+ import { actualRoot, ensureStableInstall, nexakitDir } from './stable-install.js';
15
+ import { TOOLKIT_ROOT, globalSkillTarget, resolveRoots } from './toolkit-setup.js';
8
16
 
9
17
  const MAX_MANIFEST_BYTES = 512 * 1024;
10
18
  const MAX_SKILL_FILES = 256;
@@ -13,6 +21,14 @@ const VALID_CLIENTS = new Set(['codex', 'claude']);
13
21
  const VALID_INSTALL_MODES = new Set(['symlink', 'copy']);
14
22
  const VALID_GIT_IGNORE = new Set(['gitignore', 'git-exclude', 'none']);
15
23
  const SKILL_NAME_RE = /^[a-z0-9-]+$/u;
24
+ // Antigravity reads project skills from `.agents/skills`, the folder Codex uses: one link serves both.
25
+ const projectClientsFor = agent => (agent === 'all' ? ['codex', 'claude'] : [agent === 'antigravity' ? 'codex' : agent]);
26
+ const servesFor = (client, agent) => (client === 'claude' ? ['claude'] : agent === 'all' ? ['codex', 'antigravity'] : [agent === 'antigravity' ? 'antigravity' : 'codex']);
27
+ // The coarse vocabulary the rest of the code reads; `linkState` keeps the detailed one.
28
+ const COARSE_STATE = Object.freeze({
29
+ falta: 'missing', efimero: 'replace', 'roto-propio': 'replace', instalado: 'installed',
30
+ 'otra-copia': 'installed', conflicto: 'conflict', 'roto-ajeno': 'conflict'
31
+ });
16
32
 
17
33
  export const PROJECT_TOOLKIT_DIR = '.agent-toolkit';
18
34
  const PROJECT_MANIFEST_FILE = 'manifest.json';
@@ -22,75 +38,7 @@ const IGNORE_BLOCK_END = '# <<< agent-toolkit (managed) <<<';
22
38
  const LEVEL_AGENT_HEADER = '# Generado por `agent-toolkit-inbox agentes`.';
23
39
  const LEVEL_AGENT_NAMES = ['nivel_ligero.toml', 'nivel_normal.toml', 'nivel_exigente.toml', 'nivel_alto.toml'];
24
40
 
25
- const SIGNAL_LABELS = Object.freeze({
26
- nodejs: 'Node.js',
27
- typescript: 'TypeScript',
28
- 'mcp-sdk': 'MCP SDK',
29
- react: 'React',
30
- nextjs: 'Next.js',
31
- tailwindcss: 'Tailwind CSS',
32
- astro: 'Astro',
33
- vue: 'Vue',
34
- svelte: 'Svelte',
35
- supabase: 'Supabase',
36
- postgres: 'PostgreSQL',
37
- express: 'Express',
38
- fastify: 'Fastify',
39
- hono: 'Hono',
40
- playwright: 'Playwright',
41
- vitest: 'Vitest'
42
- });
43
-
44
- const PACKAGE_TO_SIGNAL = Object.freeze({
45
- '@modelcontextprotocol/sdk': 'mcp-sdk',
46
- '@modelcontextprotocol/server': 'mcp-sdk',
47
- '@modelcontextprotocol/client': 'mcp-sdk',
48
- fastmcp: 'mcp-sdk',
49
- next: 'nextjs',
50
- react: 'react',
51
- 'react-dom': 'react',
52
- tailwindcss: 'tailwindcss',
53
- '@tailwindcss/postcss': 'tailwindcss',
54
- '@tailwindcss/vite': 'tailwindcss',
55
- typescript: 'typescript',
56
- astro: 'astro',
57
- vue: 'vue',
58
- nuxt: 'vue',
59
- svelte: 'svelte',
60
- '@sveltejs/kit': 'svelte',
61
- '@supabase/supabase-js': 'supabase',
62
- '@supabase/ssr': 'supabase',
63
- pg: 'postgres',
64
- postgres: 'postgres',
65
- '@neondatabase/serverless': 'postgres',
66
- 'drizzle-orm': 'postgres',
67
- '@prisma/client': 'postgres',
68
- express: 'express',
69
- fastify: 'fastify',
70
- hono: 'hono',
71
- '@hono/node-server': 'hono',
72
- playwright: 'playwright',
73
- '@playwright/test': 'playwright',
74
- vitest: 'vitest'
75
- });
76
-
77
- const FRAMEWORK_CONFIG_HINTS = Object.freeze([
78
- ['next.config.js', 'nextjs'],
79
- ['next.config.mjs', 'nextjs'],
80
- ['next.config.ts', 'nextjs'],
81
- ['tailwind.config.js', 'tailwindcss'],
82
- ['tailwind.config.ts', 'tailwindcss'],
83
- ['astro.config.mjs', 'astro'],
84
- ['svelte.config.js', 'svelte']
85
- ]);
86
-
87
- const OUT_OF_COVERAGE_MANIFESTS = Object.freeze([
88
- 'Cargo.toml',
89
- 'pyproject.toml',
90
- 'go.mod',
91
- 'composer.json',
92
- 'Gemfile'
93
- ]);
41
+ export { SIGNAL_LABELS };
94
42
 
95
43
  const normalizedPath = value => (IS_WINDOWS ? value.toLowerCase() : value);
96
44
  const lstatOrNull = target => fs.lstat(target).catch(err => {
@@ -234,84 +182,36 @@ async function inspectProjectSkills(projectRoot, toolkitRoot, catalogByName, cli
234
182
  }));
235
183
  }
236
184
 
237
- export async function inspectSkillProject(projectRoot, { client, toolkitRoot = TOOLKIT_ROOT, catalog } = {}) {
185
+ async function rootPackageName(root) {
186
+ const info = await lstatOrNull(path.join(root, 'package.json'));
187
+ if (!info?.isFile() || info.isSymbolicLink() || info.size > MAX_MANIFEST_BYTES) return null;
188
+ try {
189
+ const name = JSON.parse(await fs.readFile(path.join(root, 'package.json'), 'utf8'))?.name;
190
+ return typeof name === 'string' && name.trim() ? name.trim() : null;
191
+ } catch {
192
+ return null;
193
+ }
194
+ }
195
+
196
+ export async function inspectSkillProject(projectRoot, { client, toolkitRoot = TOOLKIT_ROOT, catalog, homeDirectory } = {}) {
238
197
  if (client !== undefined && !VALID_CLIENTS.has(client)) {
239
198
  throw new Error('El filtro --client solo admite codex o claude.');
240
199
  }
241
- const root = await fs.realpath(projectRoot);
200
+ // The project is the whole Git repository, even when nexakit runs from one of its subfolders.
201
+ const project = await resolveProjectRoot(projectRoot, homeDirectory ? { homeDirectory } : {});
202
+ const root = project.root;
242
203
  const resolvedToolkit = await fs.realpath(toolkitRoot);
243
204
  const activeCatalog = catalog ?? await loadSkillCatalog();
244
205
  const catalogByName = new Map(activeCatalog.skills.map(s => [s.name, s]));
245
-
246
- const signalSources = new Map();
247
- const addSignal = (id, source) => {
248
- const list = signalSources.get(id) ?? [];
249
- if (!list.includes(source)) list.push(source);
250
- signalSources.set(id, list);
251
- };
252
-
253
- const limits = [];
254
- let projectName = path.basename(root);
255
-
256
- const pkgPath = path.join(root, 'package.json');
257
- const pkgInfo = await lstatOrNull(pkgPath);
258
- if (pkgInfo) {
259
- if (!pkgInfo.isFile() || pkgInfo.isSymbolicLink() || pkgInfo.size > MAX_MANIFEST_BYTES) {
260
- limits.push('package.json excede el límite o no es un archivo regular; no se inspeccionó.');
261
- } else {
262
- let pkg = null;
263
- try {
264
- pkg = JSON.parse(await fs.readFile(pkgPath, 'utf8'));
265
- } catch {
266
- limits.push('package.json no contiene JSON válido; no se dedujeron dependencias Node.');
267
- }
268
- if (pkg && typeof pkg === 'object' && !Array.isArray(pkg)) {
269
- if (typeof pkg.name === 'string' && pkg.name.trim()) projectName = pkg.name.trim();
270
- addSignal('nodejs', 'package.json');
271
- for (const field of ['dependencies', 'devDependencies', 'peerDependencies']) {
272
- const deps = pkg[field];
273
- if (!deps || typeof deps !== 'object' || Array.isArray(deps)) continue;
274
- for (const depName of Object.keys(deps)) {
275
- const mapped = PACKAGE_TO_SIGNAL[depName];
276
- if (mapped) addSignal(mapped, `package.json (${depName})`);
277
- }
278
- }
279
- }
280
- }
281
- }
282
-
283
- const tsconfigInfo = await lstatOrNull(path.join(root, 'tsconfig.json'));
284
- if (tsconfigInfo?.isFile() && !tsconfigInfo.isSymbolicLink()) {
285
- addSignal('typescript', 'tsconfig.json');
286
- }
287
-
288
- for (const [configFile, expectedSignal] of FRAMEWORK_CONFIG_HINTS) {
289
- const info = await lstatOrNull(path.join(root, configFile));
290
- if (info?.isFile() && !info.isSymbolicLink() && !signalSources.has(expectedSignal)) {
291
- limits.push(`Configuración observada sin dependencia confirmada en package.json: ${configFile}.`);
292
- }
293
- }
294
-
295
- for (const foreignManifest of OUT_OF_COVERAGE_MANIFESTS) {
296
- const info = await lstatOrNull(path.join(root, foreignManifest));
297
- if (info && !info.isSymbolicLink()) {
298
- limits.push(`Stack fuera de cobertura automática observada: ${foreignManifest}.`);
299
- }
300
- }
301
-
302
- if (!pkgInfo && signalSources.size === 0 && limits.length === 0) {
303
- limits.push('No se detectó package.json en la raíz; cobertura automática inicial enfocada en Node.js.');
304
- }
305
-
306
- const signals = [...signalSources.entries()]
307
- .map(([id, sources]) => ({ id, label: SIGNAL_LABELS[id] ?? id, sources }))
308
- .sort((a, b) => a.id.localeCompare(b.id));
206
+ const { signals, limits } = await detectSignals(root, { git: project.git });
207
+ const projectName = await rootPackageName(root) ?? project.displayName;
309
208
 
310
209
  const installed = await inspectProjectSkills(root, resolvedToolkit, catalogByName, client);
311
210
  const coupling = await inspectProjectCoupling(root, resolvedToolkit);
312
211
 
313
212
  return {
314
213
  projectRoot: root,
214
+ project,
315
215
  projectName,
316
216
  signals,
317
217
  installed,
@@ -595,6 +495,7 @@ export function recommendSkills({ catalog, inspection, profile, client, clients
595
495
  revision: skill.revision,
596
496
  installedPath: skill.installedPath,
597
497
  reasons,
498
+ matchedSignals,
598
499
  overlapsWith: [...skill.overlapsWith],
599
500
  reviewStatus: skill.review.status,
600
501
  reviewNotes: skill.review.notes,
@@ -627,6 +528,10 @@ export function recommendSkills({ catalog, inspection, profile, client, clients
627
528
  }
628
529
 
629
530
  optional.sort((a, b) => a.name.localeCompare(b.name));
531
+ // The skills that match more of what was detected come first; ties by name.
532
+ const byMatches = (a, b) => b.matchedSignals.length - a.matchedSignals.length || a.name.localeCompare(b.name);
533
+ recommended.sort(byMatches);
534
+ candidates.sort(byMatches);
630
535
 
631
536
  const externalCandidates = [];
632
537
  for (const ref of catalog.externalReferences) {
@@ -701,8 +606,8 @@ async function projectTargetState(source, target, mode, catalogEntry) {
701
606
  throw err;
702
607
  }
703
608
  }
704
- // mode === 'copy'
705
- if (info.isSymbolicLink()) return 'replace';
609
+ // mode === 'copy': links are classified by the planner; here one is never assumed replaceable.
610
+ if (info.isSymbolicLink()) return 'conflict';
706
611
  if (info.isDirectory() && catalogEntry) {
707
612
  const integrity = await verifyCatalogIntegrity(target, catalogEntry);
708
613
  return integrity === 'verified' ? 'installed' : 'conflict';
@@ -717,10 +622,12 @@ export async function planProjectSkillInstall({
717
622
  mode = 'symlink',
718
623
  gitIgnore = 'gitignore',
719
624
  catalog,
720
- toolkitRoot = TOOLKIT_ROOT
625
+ toolkitRoot = TOOLKIT_ROOT,
626
+ linkRoot,
627
+ homeDirectory = os.homedir()
721
628
  } = {}) {
722
- if (!['codex', 'claude', 'all'].includes(agent)) {
723
- throw new Error('El agente debe ser codex, claude o all.');
629
+ if (!['codex', 'claude', 'antigravity', 'all'].includes(agent)) {
630
+ throw new Error('El agente debe ser codex, claude, antigravity o all.');
724
631
  }
725
632
  if (!VALID_INSTALL_MODES.has(mode)) {
726
633
  throw new Error('El modo de instalación debe ser symlink o copy.');
@@ -728,13 +635,33 @@ export async function planProjectSkillInstall({
728
635
  if (!VALID_GIT_IGNORE.has(gitIgnore)) {
729
636
  throw new Error('La estrategia gitIgnore debe ser gitignore, git-exclude o none.');
730
637
  }
731
- const clients = agent === 'all' ? ['codex', 'claude'] : [agent];
638
+ const clients = projectClientsFor(agent);
732
639
  const root = await fs.realpath(projectRoot);
733
640
  const resolvedToolkit = await fs.realpath(toolkitRoot);
641
+ const home = await fs.realpath(homeDirectory).catch(() => path.resolve(homeDirectory));
642
+ const roots = await resolveRoots({ toolkitRoot: resolvedToolkit, homeDirectory: home });
643
+ // An explicit linkRoot means the caller chose where to link, so no stable copy is made.
644
+ const linkRootPath = linkRoot ? path.resolve(linkRoot) : roots.linkRoot;
645
+ const ephemeral = !linkRoot && roots.ephemeral;
734
646
  const activeCatalog = catalog ?? await loadSkillCatalog();
735
647
  const catalogByName = new Map(activeCatalog.skills.map(s => [s.name, s]));
736
648
  const uniqueSkills = [...new Set(skillNames ?? [])].sort();
737
649
 
650
+ // A broken link is nexakit's only with proof: the install registry (the exact link), or this project's
651
+ // manifest. An entry written by this version records the exact link too; one from 0.1.0 only has the path,
652
+ // so its link must at least have nexakit's own shape: `<root>/<where this skill lives in nexakit>`.
653
+ const registry = await readRegistry(nexakitDir(home));
654
+ const previousManifest = await readProjectToolkitManifest(root);
655
+ const manifested = new Map((previousManifest?.entries ?? []).filter(entry => entry?.relativePath).map(entry => [entry.relativePath, entry]));
656
+ const ownedBy = suffix => (target, literal) => {
657
+ if (isRegistered(registry, target, literal)) return true;
658
+ const entry = manifested.get(path.relative(root, target).split(path.sep).join('/'));
659
+ if (!entry) return false;
660
+ if (typeof entry.apunta === 'string') return entry.apunta === literal;
661
+ return path.resolve(path.dirname(target), literal).endsWith(path.sep + path.normalize(suffix));
662
+ };
663
+ const activeRoots = [linkRootPath, resolvedToolkit, actualRoot(home)];
664
+
738
665
  const links = [];
739
666
  const verifiedCatalogEntries = new Map();
740
667
 
@@ -759,8 +686,29 @@ export async function planProjectSkillInstall({
759
686
  for (const client of clients) {
760
687
  const target = path.join(root, client === 'codex' ? '.agents' : '.claude', 'skills', skillName);
761
688
  await ensureSafeProjectParents(root, target, false);
689
+ const serves = servesFor(client, agent);
690
+ const suffix = path.relative(resolvedToolkit, source);
691
+ if (mode === 'symlink') {
692
+ const info = await classifyLink({ target, suffix, activeRoots, isOwned: ownedBy(suffix) });
693
+ links.push({
694
+ client, serves, name: skillName, source: path.join(linkRootPath, suffix), target, mode,
695
+ state: COARSE_STATE[info.state], linkState: info.state,
696
+ ...(info.literal && { literal: info.literal }), ...(info.root && { root: info.root })
697
+ });
698
+ continue;
699
+ }
700
+ if ((await lstatOrNull(target))?.isSymbolicLink()) {
701
+ // A link where a copy goes is replaced only when it is provably nexakit's; any other link is the user's.
702
+ const info = await classifyLink({ target, suffix, activeRoots, isOwned: ownedBy(suffix) });
703
+ const ours = ['instalado', 'otra-copia', 'efimero', 'roto-propio'].includes(info.state);
704
+ links.push({
705
+ client, serves, name: skillName, source, target, mode, state: ours ? 'replace' : 'conflict',
706
+ linkState: info.state, ...(info.literal && { literal: info.literal })
707
+ });
708
+ continue;
709
+ }
762
710
  const state = await projectTargetState(source, target, mode, catalogEntry);
763
- links.push({ client, name: skillName, source, target, state, mode });
711
+ links.push({ client, serves, name: skillName, source, target, state, mode });
764
712
  }
765
713
  }
766
714
 
@@ -800,6 +748,10 @@ export async function planProjectSkillInstall({
800
748
  gitIgnore,
801
749
  projectRoot: root,
802
750
  toolkitRoot: resolvedToolkit,
751
+ linkRoot: linkRootPath,
752
+ ephemeral,
753
+ homeDirectory: home,
754
+ agent,
803
755
  links,
804
756
  stateDirPath,
805
757
  manifestPath,
@@ -822,7 +774,8 @@ export async function planProjectSkillInstall({
822
774
  };
823
775
  }
824
776
 
825
- async function copyVerifiedSkillDirectory(sourceDir, targetDir, catalogEntry) {
777
+ async function copyVerifiedSkillDirectory(sourceDir, targetDir, catalogEntry, lock) {
778
+ await lock?.assertHeld();
826
779
  await fs.mkdir(targetDir, { recursive: true, mode: 0o755 });
827
780
  if (catalogEntry) {
828
781
  for (const file of catalogEntry.files) {
@@ -833,15 +786,18 @@ async function copyVerifiedSkillDirectory(sourceDir, targetDir, catalogEntry) {
833
786
  if (actualHash !== file.sha256) {
834
787
  throw new Error(`Integridad SHA-256 rechazada durante la copia de ${catalogEntry.name} (${file.path}).`);
835
788
  }
789
+ await lock?.assertHeld();
836
790
  await fs.mkdir(path.dirname(dstFile), { recursive: true, mode: 0o755 });
837
791
  await fs.writeFile(dstFile, bytes, { mode: 0o644 });
838
792
  }
839
793
  } else {
794
+ await lock?.assertHeld();
840
795
  await fs.cp(sourceDir, targetDir, { recursive: true, dereference: false });
841
796
  }
842
797
  }
843
798
 
844
- async function writeSkillsLockfile(lockfilePath, activeEntriesBySkill) {
799
+ async function writeSkillsLockfile(lockfilePath, activeEntriesBySkill, lock) {
800
+ await lock?.assertHeld();
845
801
  await fs.mkdir(path.dirname(lockfilePath), { recursive: true, mode: 0o755 });
846
802
  const existingInfo = await lstatOrNull(lockfilePath);
847
803
  if (existingInfo && (!existingInfo.isFile() || existingInfo.isSymbolicLink())) {
@@ -882,6 +838,7 @@ async function writeSkillsLockfile(lockfilePath, activeEntriesBySkill) {
882
838
  generatedBy: 'nexakit',
883
839
  skills: sortedSkills
884
840
  };
841
+ await lock?.assertHeld();
885
842
  await fs.writeFile(lockfilePath, JSON.stringify(payload, null, 2) + '\n', { mode: 0o644 });
886
843
  return true;
887
844
  }
@@ -891,13 +848,16 @@ async function writeProjectManifestAndIgnore({
891
848
  mode,
892
849
  gitIgnore,
893
850
  prevManifest,
894
- coupledEntriesMap
851
+ coupledEntriesMap,
852
+ lock,
853
+ answers = prevManifest?.answers
895
854
  }) {
896
855
  const stateDir = path.join(projectRoot, PROJECT_TOOLKIT_DIR);
897
856
  const stateStat = await lstatOrNull(stateDir);
898
857
  if (stateStat && (!stateStat.isDirectory() || stateStat.isSymbolicLink())) {
899
858
  return { manifestWritten: false, gitIgnoreUpdated: false };
900
859
  }
860
+ await lock?.assertHeld();
901
861
  await fs.mkdir(stateDir, { recursive: true, mode: 0o755 });
902
862
 
903
863
  const entries = [...coupledEntriesMap.values()].sort((a, b) =>
@@ -910,17 +870,20 @@ async function writeProjectManifestAndIgnore({
910
870
  if (gitIgnore !== 'none') {
911
871
  const info = await inspectGitIgnoreTarget(projectRoot, gitIgnore);
912
872
  if (!info.conflict && !info.unavailable && info.targetPath) {
873
+ await lock?.assertHeld();
913
874
  await fs.mkdir(path.dirname(info.targetPath), { recursive: true, mode: 0o755 });
914
875
  const currentStat = await lstatOrNull(info.targetPath);
915
876
  if (!currentStat) {
916
877
  if (gitIgnore === 'gitignore') createdIgnoreFile = true;
917
878
  const nextText = upsertManagedIgnoreBlock('', entries.map(e => e.relativePath));
879
+ await lock?.assertHeld();
918
880
  await fs.writeFile(info.targetPath, nextText, { mode: 0o644 });
919
881
  gitIgnoreUpdated = true;
920
882
  } else if (currentStat.isFile() && !currentStat.isSymbolicLink()) {
921
883
  const prevText = await fs.readFile(info.targetPath, 'utf8');
922
884
  const nextText = upsertManagedIgnoreBlock(prevText, entries.map(e => e.relativePath));
923
885
  if (nextText !== prevText) {
886
+ await lock?.assertHeld();
924
887
  await fs.writeFile(info.targetPath, nextText, { mode: 0o644 });
925
888
  }
926
889
  gitIgnoreUpdated = true;
@@ -935,6 +898,7 @@ async function writeProjectManifestAndIgnore({
935
898
  const otherText = await fs.readFile(otherInfo.targetPath, 'utf8');
936
899
  const cleaned = removeManagedIgnoreBlock(otherText);
937
900
  if (cleaned.changed) {
901
+ await lock?.assertHeld();
938
902
  if (!cleaned.content && otherStrategy === 'gitignore' && prevManifest?.createdIgnoreFile) {
939
903
  await fs.unlink(otherInfo.targetPath).catch(() => {});
940
904
  createdIgnoreFile = false;
@@ -953,20 +917,71 @@ async function writeProjectManifestAndIgnore({
953
917
  mode,
954
918
  gitIgnoreStrategy: gitIgnore,
955
919
  createdIgnoreFile,
956
- entries
920
+ entries,
921
+ ...(answers && { answers })
957
922
  };
958
- await fs.writeFile(
959
- path.join(stateDir, PROJECT_MANIFEST_FILE),
960
- JSON.stringify(manifestPayload, null, 2) + '\n',
961
- { mode: 0o644 }
962
- );
923
+ // A manifest that is a link or not a regular file is not nexakit's: it is never written through.
924
+ const manifestPath = path.join(stateDir, PROJECT_MANIFEST_FILE);
925
+ const manifestStat = await lstatOrNull(manifestPath);
926
+ if (manifestStat && (!manifestStat.isFile() || manifestStat.isSymbolicLink())) {
927
+ return { manifestWritten: false, gitIgnoreUpdated };
928
+ }
929
+ const temporary = `${manifestPath}.${process.pid}.tmp`;
930
+ await fs.writeFile(temporary, JSON.stringify(manifestPayload, null, 2) + '\n', { mode: 0o644, flag: 'wx' });
931
+ try {
932
+ await lock?.assertHeld();
933
+ await fs.rename(temporary, manifestPath);
934
+ } finally {
935
+ await fs.rm(temporary, { force: true }); // ours: created exclusively above
936
+ }
963
937
  return { manifestWritten: true, gitIgnoreUpdated };
964
938
  }
965
939
 
966
- export async function applyProjectSkillInstall(plan) {
940
+ // Links are written under the install lock: it prepares the stable copy when running from an npx cache,
941
+ // re-checks the hashes where the links will point, and records every link so a broken one can be proven ours.
942
+ export async function applyProjectSkillInstall(plan, { runNpm, packageSpec, lockOptions, acquire = acquireLock } = {}) {
967
943
  if (!plan || !Array.isArray(plan.links) || !plan.projectRoot) {
968
944
  throw new Error('Se requiere una vista previa válida de instalación de skills.');
969
945
  }
946
+ const mode = plan.mode ?? 'symlink';
947
+ const gitIgnore = plan.gitIgnore ?? 'gitignore';
948
+ // Anything that writes (links, copies, the manifest, ignore rules or the lockfile) runs under the lock.
949
+ // With nothing to write, nothing is written, so a run that changes nothing never creates ~/.nexakit.
950
+ const pending = plan.links.some(l => ['missing', 'replace'].includes(l.state));
951
+ const previous = await readProjectToolkitManifest(plan.projectRoot);
952
+ const settingsChanged = Boolean(previous) && (previous.mode !== mode || previous.gitIgnoreStrategy !== gitIgnore);
953
+ if (!pending && !settingsChanged) return applyProjectSkillInstallLocked(plan, { registryEntries: [], lock: null, writeMetadata: false });
954
+
955
+ const home = plan.homeDirectory ?? os.homedir();
956
+ const lock = await acquire(nexakitDir(home), lockOptions);
957
+ const registryEntries = [];
958
+ try {
959
+ if (mode === 'symlink' && pending) {
960
+ if (plan.ephemeral) {
961
+ const { version } = JSON.parse(await fs.readFile(path.join(plan.toolkitRoot ?? TOOLKIT_ROOT, 'package.json'), 'utf8'));
962
+ await ensureStableInstall({
963
+ homeDirectory: home, version, lock, ...(runNpm && { runNpm }), ...(packageSpec && { packageSpec })
964
+ });
965
+ }
966
+ const linkRoot = plan.linkRoot ?? plan.toolkitRoot ?? TOOLKIT_ROOT;
967
+ if (path.resolve(linkRoot) !== path.resolve(plan.toolkitRoot ?? TOOLKIT_ROOT)) {
968
+ // The files that get linked are the ones in linkRoot, so their hashes must hold there too.
969
+ for (const entry of Object.values(plan.verifiedCatalogEntries ?? {})) {
970
+ const check = await verifyBundledSkillHashes({ skillEntry: entry, toolkitRoot: linkRoot });
971
+ if (!check.ok) throw new Error(check.reason);
972
+ }
973
+ }
974
+ }
975
+ const result = await applyProjectSkillInstallLocked(plan, { registryEntries, lock, writeMetadata: true });
976
+ await recordEntries(nexakitDir(home), registryEntries, lock);
977
+ return result;
978
+ } finally {
979
+ await lock.release();
980
+ }
981
+ }
982
+
983
+ // `lock` is null only when nothing will be written; every write checks it still holds the lock just before.
984
+ async function applyProjectSkillInstallLocked(plan, { registryEntries, lock, writeMetadata }) {
970
985
  const mode = plan.mode ?? 'symlink';
971
986
  const gitIgnore = plan.gitIgnore ?? 'gitignore';
972
987
  const catalogEntries = plan.verifiedCatalogEntries ?? {};
@@ -1008,35 +1023,49 @@ export async function applyProjectSkillInstall(plan) {
1008
1023
  continue;
1009
1024
  }
1010
1025
 
1026
+ await lock?.assertHeld();
1011
1027
  await ensureSafeProjectParents(plan.projectRoot, item.target, true);
1012
- const currentState = await projectTargetState(item.source, item.target, mode, catalogEntry);
1013
- if (currentState === 'conflict') {
1014
- updatedLinks.push({ ...item, state: 'conflict' });
1015
- continue;
1016
- }
1017
- if (currentState === 'installed') {
1018
- if (coupledEntriesMap.has(`${item.client}:${item.name}`)) {
1019
- const list = installedClientsBySkill.get(item.name) ?? [];
1020
- list.push(item.client);
1021
- installedClientsBySkill.set(item.name, list);
1022
- }
1023
- updatedLinks.push({ ...item, state: 'installed' });
1024
- continue;
1025
- }
1026
- if (currentState === 'replace') {
1027
- const currentInfo = await lstatOrNull(item.target);
1028
- if (!currentInfo?.isSymbolicLink()) {
1029
- updatedLinks.push({ ...item, state: 'conflict' });
1028
+ let literal;
1029
+ if (mode === 'symlink') {
1030
+ // Re-reads the link right before writing: if it is no longer what the plan saw, it is left alone.
1031
+ await lock?.assertHeld();
1032
+ const outcome = await relinkIfUnchanged({
1033
+ target: item.target, expectedLiteral: item.linkState === 'falta' ? null : item.literal, source: item.source, relative: true
1034
+ });
1035
+ if (outcome === 'cambio') {
1036
+ updatedLinks.push({ ...item, state: 'conflict', changed: true });
1030
1037
  continue;
1031
1038
  }
1032
- await fs.unlink(item.target);
1033
- }
1034
-
1035
- if (mode === 'symlink') {
1036
- const linkTarget = IS_WINDOWS ? path.resolve(item.source) : path.relative(path.dirname(item.target), item.source);
1037
- await fs.symlink(linkTarget, item.target, IS_WINDOWS ? 'junction' : 'dir');
1039
+ // The registry and the manifest keep what readlink returns, the value that is compared later.
1040
+ literal = await fs.readlink(item.target);
1041
+ registryEntries.push({ destino: item.target, apunta: literal, raiz: plan.linkRoot ?? plan.toolkitRoot });
1038
1042
  } else {
1039
- await copyVerifiedSkillDirectory(item.source, item.target, catalogEntry);
1043
+ const current = await lstatOrNull(item.target);
1044
+ if (current?.isSymbolicLink()) {
1045
+ // Only a link the plan proved to be nexakit's becomes a copy, and only if it did not change since.
1046
+ if (item.state !== 'replace' || !item.literal || await fs.readlink(item.target) !== item.literal) {
1047
+ updatedLinks.push({ ...item, state: 'conflict', changed: true });
1048
+ continue;
1049
+ }
1050
+ await lock?.assertHeld();
1051
+ await fs.unlink(item.target);
1052
+ } else {
1053
+ const currentState = await projectTargetState(item.source, item.target, mode, catalogEntry);
1054
+ if (currentState === 'conflict') {
1055
+ updatedLinks.push({ ...item, state: 'conflict' });
1056
+ continue;
1057
+ }
1058
+ if (currentState === 'installed') {
1059
+ if (coupledEntriesMap.has(`${item.client}:${item.name}`)) {
1060
+ const list = installedClientsBySkill.get(item.name) ?? [];
1061
+ list.push(item.client);
1062
+ installedClientsBySkill.set(item.name, list);
1063
+ }
1064
+ updatedLinks.push({ ...item, state: 'installed' });
1065
+ continue;
1066
+ }
1067
+ }
1068
+ await copyVerifiedSkillDirectory(item.source, item.target, catalogEntry, lock);
1040
1069
  }
1041
1070
 
1042
1071
  created++;
@@ -1045,6 +1074,7 @@ export async function applyProjectSkillInstall(plan) {
1045
1074
  name: item.name,
1046
1075
  relativePath: relPath,
1047
1076
  mode,
1077
+ ...(literal && { apunta: literal }),
1048
1078
  ...(catalogEntry?.revision && { revision: catalogEntry.revision })
1049
1079
  });
1050
1080
  const list = installedClientsBySkill.get(item.name) ?? [];
@@ -1054,7 +1084,7 @@ export async function applyProjectSkillInstall(plan) {
1054
1084
  }
1055
1085
 
1056
1086
  let lockfileWritten = false;
1057
- if (mode === 'copy' && !plan.stateDirConflict && !plan.lockfileConflict && installedClientsBySkill.size > 0) {
1087
+ if (writeMetadata && mode === 'copy' && !plan.stateDirConflict && !plan.lockfileConflict && installedClientsBySkill.size > 0) {
1058
1088
  const activeMap = new Map();
1059
1089
  for (const [skillName, clients] of installedClientsBySkill.entries()) {
1060
1090
  const catalogEntry = catalogEntries[skillName];
@@ -1063,20 +1093,22 @@ export async function applyProjectSkillInstall(plan) {
1063
1093
  if (activeMap.size > 0) {
1064
1094
  lockfileWritten = await writeSkillsLockfile(
1065
1095
  plan.lockfilePath ?? path.join(plan.projectRoot, PROJECT_TOOLKIT_DIR, PROJECT_LOCKFILE_NAME),
1066
- activeMap
1096
+ activeMap,
1097
+ lock
1067
1098
  );
1068
1099
  }
1069
1100
  }
1070
1101
 
1071
1102
  let manifestWritten = false;
1072
1103
  let gitIgnoreUpdated = false;
1073
- if (!plan.stateDirConflict && (coupledEntriesMap.size > 0 || lockfileWritten)) {
1104
+ if (writeMetadata && !plan.stateDirConflict && (coupledEntriesMap.size > 0 || lockfileWritten)) {
1074
1105
  const res = await writeProjectManifestAndIgnore({
1075
1106
  projectRoot: plan.projectRoot,
1076
1107
  mode,
1077
1108
  gitIgnore,
1078
1109
  prevManifest,
1079
- coupledEntriesMap
1110
+ coupledEntriesMap,
1111
+ lock
1080
1112
  });
1081
1113
  manifestWritten = res.manifestWritten;
1082
1114
  gitIgnoreUpdated = res.gitIgnoreUpdated;
@@ -1108,6 +1140,60 @@ export async function applyProjectSkillLinks(plan) {
1108
1140
  return applyProjectSkillInstall({ ...plan, mode: 'symlink' });
1109
1141
  }
1110
1142
 
1143
+ // The answers given to `npx nexakit` (skills chosen and discarded, agents, memory), kept in the project manifest
1144
+ // so a second run knows what was decided and does not ask again.
1145
+ const isNameList = value => Array.isArray(value) && value.every(item => typeof item === 'string' && SKILL_NAME_RE.test(item));
1146
+ function validSetupAnswers(answers) {
1147
+ return Boolean(answers && (answers.cleanProject === undefined || validCleanProject(answers.cleanProject)) && answers.version === 1 &&
1148
+ isNameList(answers.skills?.chosen) && isNameList(answers.skills?.discarded) &&
1149
+ Array.isArray(answers.agents) && answers.agents.every(agent => ['claude', 'codex', 'antigravity'].includes(agent)) &&
1150
+ (answers.memory?.decision === 'later' ||
1151
+ (answers.memory?.decision === 'path' && typeof answers.memory.path === 'string' && path.isAbsolute(answers.memory.path))));
1152
+ }
1153
+
1154
+ function validCleanProject(value) {
1155
+ if (!value || typeof value.git !== 'boolean' || !['confirmado','creado','fallido'].includes(value.status) || !value.choice) return false;
1156
+ const parts = ['frontend','backend','database','mobile'];
1157
+ if (Object.keys(value.choice).some(p=>!parts.includes(p))) return false;
1158
+ return parts.every(part => value.choice[part] === null || generatorsData.generators.some(g=>g.id===value.choice[part] && g.part===part))
1159
+ && (value.failedPart === undefined || ['frontend','backend','mobile','proyecto'].includes(value.failedPart));
1160
+ }
1161
+ export async function readCleanProjectAnswers(projectRoot) {
1162
+ const value = (await readProjectToolkitManifest(projectRoot))?.answers?.cleanProject;
1163
+ return validCleanProject(value) ? value : null;
1164
+ }
1165
+ export async function writeCleanProjectAnswers(projectRoot, cleanProject, lock) {
1166
+ if (!validCleanProject(cleanProject)) throw new Error('Respuestas del proyecto limpio no válidas.');
1167
+ await lock.assertHeld();
1168
+ const previous = await readProjectToolkitManifest(projectRoot);
1169
+ const result = await writeProjectManifestAndIgnore({projectRoot,mode:previous?.mode ?? 'symlink',
1170
+ gitIgnore:previous?.gitIgnoreStrategy ?? 'gitignore',prevManifest:previous,
1171
+ coupledEntriesMap:new Map((previous?.entries ?? []).map(e=>[e.relativePath,e])),lock,
1172
+ answers:{version:1,...previous?.answers,cleanProject}});
1173
+ if (!result.manifestWritten) throw new Error('No se guardaron las respuestas del proyecto limpio.');
1174
+ }
1175
+
1176
+ export async function readSetupAnswers(projectRoot) {
1177
+ const manifest = await readProjectToolkitManifest(projectRoot);
1178
+ return validSetupAnswers(manifest?.answers) ? manifest.answers : null;
1179
+ }
1180
+
1181
+ export async function writeSetupAnswers(projectRoot, answers, lock) {
1182
+ if (!validSetupAnswers(answers)) throw new Error('Respuestas de nexakit no válidas.');
1183
+ await lock.assertHeld();
1184
+ const prevManifest = await readProjectToolkitManifest(projectRoot);
1185
+ const result = await writeProjectManifestAndIgnore({
1186
+ projectRoot,
1187
+ mode: prevManifest?.mode ?? 'symlink',
1188
+ gitIgnore: prevManifest?.gitIgnoreStrategy ?? 'gitignore',
1189
+ prevManifest,
1190
+ coupledEntriesMap: new Map((prevManifest?.entries ?? []).map(entry => [entry.relativePath, entry])),
1191
+ lock,
1192
+ answers: { ...answers, ...(prevManifest?.answers?.cleanProject && !answers.cleanProject && {cleanProject:prevManifest.answers.cleanProject}) }
1193
+ });
1194
+ if (!result.manifestWritten) throw new Error(`${PROJECT_TOOLKIT_DIR} no es una carpeta normal; no se guardaron las respuestas.`);
1195
+ }
1196
+
1111
1197
  export async function planToolkitDetach({
1112
1198
  projectRoot,
1113
1199
  includeGlobal = false,
@@ -1115,13 +1201,21 @@ export async function planToolkitDetach({
1115
1201
  catalog,
1116
1202
  toolkitRoot = TOOLKIT_ROOT,
1117
1203
  homeDirectory = os.homedir(),
1118
- codexHome
1204
+ codexHome,
1205
+ environment = {},
1206
+ skillNames
1119
1207
  } = {}) {
1120
- if (!['codex', 'claude', 'all'].includes(agent)) {
1121
- throw new Error('El agente debe ser codex, claude o all.');
1208
+ if (!['codex', 'claude', 'antigravity', 'all'].includes(agent)) {
1209
+ throw new Error('El agente debe ser codex, claude, antigravity o all.');
1122
1210
  }
1123
- const clients = agent === 'all' ? ['codex', 'claude'] : [agent];
1211
+ const clients = agent === 'all' ? ['codex', 'claude', 'antigravity'] : [agent];
1212
+ // Antigravity shares Codex's project folder, so removing one's project links removes the other's.
1213
+ const projectClients = [...new Set(clients.map(c => (c === 'antigravity' ? 'codex' : c)))];
1124
1214
  const resolvedToolkit = await fs.realpath(toolkitRoot);
1215
+ const homeReal = await fs.realpath(homeDirectory).catch(() => path.resolve(homeDirectory));
1216
+ // Links made from an npx run point into the stable copy, which is nexakit's too.
1217
+ const stableVersions = path.join(nexakitDir(homeReal), 'versiones');
1218
+ const registry = await readRegistry(nexakitDir(homeReal));
1125
1219
  const activeCatalog = catalog ?? await loadSkillCatalog();
1126
1220
  const catalogByName = new Map(activeCatalog.skills.map(s => [s.name, s]));
1127
1221
 
@@ -1141,17 +1235,19 @@ export async function planToolkitDetach({
1141
1235
 
1142
1236
  let candidateEntries = [];
1143
1237
  if (manifest) {
1144
- candidateEntries = manifest.entries.filter(e => clients.includes(e.client));
1145
- remainingManifestEntries = manifest.entries.filter(e => !clients.includes(e.client));
1238
+ // With skillNames only those skills go; the rest of the entries stay in the manifest.
1239
+ const removing = e => projectClients.includes(e.client) && (!skillNames || skillNames.includes(e.name));
1240
+ candidateEntries = manifest.entries.filter(removing);
1241
+ remainingManifestEntries = manifest.entries.filter(e => !removing(e));
1146
1242
  } else {
1147
- const extLinks = await findFallbackExternalToolkitLinks(root, resolvedToolkit, clients, homeDirectory);
1243
+ const extLinks = await findFallbackExternalToolkitLinks(root, resolvedToolkit, projectClients, homeDirectory);
1148
1244
  const seenKeys = new Set(extLinks.map(e => `${e.client}:${e.name}`));
1149
1245
  candidateEntries = [...extLinks];
1150
1246
  if (legacyLock) {
1151
1247
  for (const [skillName, meta] of Object.entries(legacyLock.skills ?? {})) {
1152
1248
  const lockClients = Array.isArray(meta?.clients) ? meta.clients : ['codex', 'claude'];
1153
1249
  for (const client of lockClients) {
1154
- if (!clients.includes(client) || seenKeys.has(`${client}:${skillName}`)) continue;
1250
+ if (!projectClients.includes(client) || seenKeys.has(`${client}:${skillName}`)) continue;
1155
1251
  candidateEntries.push({
1156
1252
  client,
1157
1253
  name: skillName,
@@ -1163,6 +1259,7 @@ export async function planToolkitDetach({
1163
1259
  }
1164
1260
  }
1165
1261
 
1262
+ if (skillNames) candidateEntries = candidateEntries.filter(entry => skillNames.includes(entry.name));
1166
1263
  for (const entry of candidateEntries) {
1167
1264
  if (!SKILL_NAME_RE.test(entry.name)) continue;
1168
1265
  const target = path.join(root, entry.client === 'codex' ? '.agents' : '.claude', 'skills', entry.name);
@@ -1174,7 +1271,7 @@ export async function planToolkitDetach({
1174
1271
  let safeToUnlink = Boolean(manifest);
1175
1272
  try {
1176
1273
  const real = await fs.realpath(target);
1177
- safeToUnlink = isWithinRoot(real, resolvedToolkit) && !isWithinRoot(real, root);
1274
+ safeToUnlink = (isWithinRoot(real, resolvedToolkit) || isWithinRoot(real, stableVersions)) && !isWithinRoot(real, root);
1178
1275
  } catch (err) {
1179
1276
  if (err.code !== 'ENOENT') throw err;
1180
1277
  }
@@ -1249,7 +1346,7 @@ export async function planToolkitDetach({
1249
1346
  const manualCommands = [];
1250
1347
  if (includeGlobal) {
1251
1348
  const home = await fs.realpath(homeDirectory);
1252
- const resolvedCodexHome = codexHome ?? path.join(home, '.codex');
1349
+ const resolvedCodexHome = codexHome ?? environment.CODEX_HOME ?? path.join(home, '.codex');
1253
1350
  const bundledSkillsDir = path.join(resolvedToolkit, 'skills');
1254
1351
  const bundledNames = (await fs.readdir(bundledSkillsDir, { withFileTypes: true }).catch(() => []))
1255
1352
  .filter(e => e.isDirectory() && SKILL_NAME_RE.test(e.name))
@@ -1258,24 +1355,25 @@ export async function planToolkitDetach({
1258
1355
 
1259
1356
  for (const client of clients) {
1260
1357
  for (const name of bundledNames) {
1261
- const expectedSource = path.join(resolvedToolkit, 'skills', name);
1262
- const target = path.join(home, client === 'codex' ? '.agents' : '.claude', 'skills', name);
1358
+ const target = globalSkillTarget(home, client, name);
1263
1359
  const info = await lstatOrNull(target);
1264
1360
  if (!info?.isSymbolicLink()) continue;
1265
- try {
1266
- const [actual, expected] = await Promise.all([fs.realpath(target), fs.realpath(expectedSource)]);
1267
- if (normalizedPath(actual) === normalizedPath(expected)) {
1268
- items.push({
1269
- scope: 'global',
1270
- client,
1271
- name,
1272
- target,
1273
- relativePath: target,
1274
- action: 'remove-global-link',
1275
- reason: 'enlace global de Agent Toolkit'
1276
- });
1277
- }
1278
- } catch {}
1361
+ // Only links that are provably nexakit's: into this copy, the stable copy, an npx cache, or recorded broken.
1362
+ const link = await classifyLink({
1363
+ target, suffix: `skills/${name}`, activeRoots: [resolvedToolkit, actualRoot(home)],
1364
+ isOwned: (at, literal) => isRegistered(registry, at, literal)
1365
+ });
1366
+ if (['instalado', 'efimero', 'roto-propio'].includes(link.state)) {
1367
+ items.push({
1368
+ scope: 'global',
1369
+ client,
1370
+ name,
1371
+ target,
1372
+ relativePath: target,
1373
+ action: 'remove-global-link',
1374
+ reason: 'enlace global de Agent Toolkit'
1375
+ });
1376
+ }
1279
1377
  }
1280
1378
  }
1281
1379
 
@@ -1305,6 +1403,16 @@ export async function planToolkitDetach({
1305
1403
  }
1306
1404
 
1307
1405
  return {
1406
+ reviewInstructions: includeGlobal && !skillNames
1407
+ ? await ownedReviewInstructions({
1408
+ homeDirectory: homeReal,
1409
+ codexHome: codexHome ?? environment.CODEX_HOME ?? path.join(homeReal, '.codex'),
1410
+ agents: clients
1411
+ })
1412
+ : [],
1413
+ homeDirectory: homeReal,
1414
+ reviewCodexHome: codexHome ?? environment.CODEX_HOME ?? path.join(homeReal, ".codex"),
1415
+ reviewAgents: clients,
1308
1416
  applied: false,
1309
1417
  projectRoot: root,
1310
1418
  toolkitRoot: resolvedToolkit,
@@ -1363,6 +1471,18 @@ export async function applyToolkitDetach(plan) {
1363
1471
  throw new Error('Se requiere una vista previa válida de desacoplado.');
1364
1472
  }
1365
1473
 
1474
+ if (plan.reviewInstructions?.length) {
1475
+ const lock = await acquireLock(nexakitDir(plan.homeDirectory));
1476
+ try {
1477
+ await removeReviewInstructions({
1478
+ homeDirectory: plan.homeDirectory,
1479
+ codexHome: plan.reviewCodexHome,
1480
+ agents: plan.reviewAgents
1481
+ }, lock);
1482
+ } finally {
1483
+ await lock.release();
1484
+ }
1485
+ }
1366
1486
  let removedCount = 0;
1367
1487
  let conflicts = 0;
1368
1488
  const updatedItems = [];
@@ -1556,5 +1676,21 @@ export function formatDetachReport(report) {
1556
1676
  for (const cmd of report.manualCommands) lines.push(` $ ${cmd}`);
1557
1677
  }
1558
1678
 
1679
+ if (report.reviewInstructions?.length) lines.push(` - Quitar solo el bloque de revisión de ${report.reviewInstructions.join(', ')}`);
1559
1680
  return lines.join('\n') + '\n';
1560
1681
  }
1682
+
1683
+ // Generic signals: almost every project has them, and the useful skill is the framework's.
1684
+ const GENERIC_SIGNALS = new Set(['nodejs', 'typescript']);
1685
+
1686
+ // The technologies found in the project that no catalog skill (nor external reference) covers. Only reported:
1687
+ // finding a skill for one is a request the person makes to revisar-skill, never a search nexakit starts alone.
1688
+ export function uncoveredSignals({ signals = [], catalog }) {
1689
+ const covered = new Set([
1690
+ ...(catalog?.skills ?? []).flatMap((skill) => skill.matching?.anySignals ?? []),
1691
+ ...(catalog?.externalReferences ?? []).flatMap((ref) => ref.anySignals ?? []),
1692
+ ]);
1693
+ return signals
1694
+ .filter((signal) => !GENERIC_SIGNALS.has(signal.id) && !covered.has(signal.id))
1695
+ .map((signal) => ({ id: signal.id, label: signal.label }));
1696
+ }