nexakit 0.5.1 → 0.6.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.
package/src/setup-tui.js CHANGED
@@ -8,7 +8,8 @@ import { planCleanProject, checkRequirements } from './clean-project.js';
8
8
  import { runCleanCommand } from './clean-command.js';
9
9
  import path from 'node:path';
10
10
  import { applySetup } from './setup-apply.js';
11
- import { AGENTS, AGENT_NAMES, buildConfirmation, joinNames, shortPath, suggestedAnswers } from './setup-plan.js';
11
+ import { MODS } from './mods.js';
12
+ import { AGENTS, AGENT_NAMES, buildConfirmation, groupLines, joinNames, shortPath, suggestedAnswers } from './setup-plan.js';
12
13
  import { gatherSetupState, inspectMemoryPath, memoryConnections } from './setup-state.js';
13
14
  import { applyToolkitDetach, planToolkitDetach } from './skill-recommendations.js';
14
15
  import { LOGO_WIDTH, colorLevel, levelOf, paint, renderLogo } from './brand.js';
@@ -19,9 +20,16 @@ const KEYS = Object.freeze({
19
20
  back: ['\x7f', '\x08', '\x1b[D'], left: ['\x1b[D'], right: ['\x1b[C'], quit: ['q', 'Q', '\x03']
20
21
  });
21
22
  const is = (key, name) => KEYS[name].includes(key);
22
- const MENU = Object.freeze([
23
- ['exit', 'No, salir'], ['skills', 'Añadir o quitar skills'], ['agents', 'Cambiar agentes'], ['detach', 'Quitar nexakit de este proyecto']
24
- ]);
23
+ // The mods entry only shows with Claude Code chosen and its plugin list readable.
24
+ const hasModsStep = model => Boolean(model.state.mods && model.answers.agents.includes('claude'));
25
+ const menuEntries = model => [
26
+ ['exit', 'No, salir'], ['skills', 'Añadir o quitar skills'], ['agents', 'Cambiar agentes'],
27
+ ...(hasModsStep(model) ? [['mods', 'Mods de Claude Code']] : []), ['detach', 'Quitar nexakit de este proyecto']
28
+ ];
29
+ const MOD_STATUS_WORDS = Object.freeze({ activo: 'instalado', falta: 'falta', actualizable: 'hay versión nueva', desactivado: 'desactivado', desconocido: 'sin comprobar' });
30
+ const OFFERED_MOD_STATES = new Set(['falta', 'desactivado', 'actualizable']);
31
+ const modMarked = (model, mod) => model.state.mods[mod.name] === 'activo' || model.answers.mods.chosen.includes(mod.name);
32
+ const MOD_ALREADY_INSTALLED = 'Ya está instalado; se quita desde /plugin en Claude Code';
25
33
  const MAX_DETECTED = 4;
26
34
  // Languages and generic signals go after the frameworks the person will recognise.
27
35
  const GENERIC_SIGNALS = new Set(['nodejs', 'python', 'rust', 'rest-api', 'vitest', 'mcp-sdk']);
@@ -93,6 +101,17 @@ function closeSkills(model) {
93
101
  return { ...model.answers, skills: { chosen, discarded: model.state.skills.map(s => s.name).filter(name => discarded.has(name)) } };
94
102
  }
95
103
 
104
+ // Leaving the mods question: an offered mod left unchecked is remembered as discarded, so it is not offered again.
105
+ function closeMods(model) {
106
+ const { chosen } = model.answers.mods;
107
+ const discarded = new Set(model.answers.mods.discarded);
108
+ for (const mod of MODS) {
109
+ if (chosen.includes(mod.name)) discarded.delete(mod.name);
110
+ else if (OFFERED_MOD_STATES.has(model.state.mods[mod.name])) discarded.add(mod.name);
111
+ }
112
+ return { ...model.answers, mods: { chosen: MODS.map(mod => mod.name).filter(name => chosen.includes(name)), discarded: MODS.map(mod => mod.name).filter(name => discarded.has(name)) } };
113
+ }
114
+
96
115
  function memoryAnswer(model, choice) {
97
116
  const { state } = model;
98
117
  if (choice === 'later') return { decision: 'later' };
@@ -104,11 +123,13 @@ function memoryAnswer(model, choice) {
104
123
  const go = (model, step, extra = {}) => ({ ...model, step, cursor: 0, info: false, detail: false, message: null, ...extra });
105
124
  const nextAfter = (model, step) => {
106
125
  if (model.flow === 'menu') return 'confirm';
107
- return { skills: 'memory', memory: 'agents', 'memory-path': 'agents', agents: 'confirm' }[step];
126
+ if (step === 'agents') return hasModsStep(model) ? 'mods' : 'confirm';
127
+ return { skills: 'memory', memory: 'agents', 'memory-path': 'agents', mods: 'confirm' }[step];
108
128
  };
109
129
  const previousOf = (model, step) => {
110
130
  if (model.flow === 'menu') return step === 'confirm' ? model.menuEntry : 'menu';
111
- return { memory: 'skills', 'memory-path': 'memory', agents: 'memory', confirm: 'agents' }[step];
131
+ if (step === 'confirm') return hasModsStep(model) ? 'mods' : 'agents';
132
+ return { memory: 'skills', 'memory-path': 'memory', agents: 'memory', mods: 'agents' }[step];
112
133
  };
113
134
 
114
135
  export function handleSetupKey(model, key) {
@@ -180,9 +201,10 @@ export function handleSetupKey(model, key) {
180
201
 
181
202
  if (step === 'menu') {
182
203
  if (is(key, 'up')) return { model: { ...model, cursor: Math.max(0, model.cursor - 1) } };
183
- if (is(key, 'down')) return { model: { ...model, cursor: Math.min(MENU.length - 1, model.cursor + 1) } };
204
+ const entries = menuEntries(model);
205
+ if (is(key, 'down')) return { model: { ...model, cursor: Math.min(entries.length - 1, model.cursor + 1) } };
184
206
  if (is(key, 'enter')) {
185
- const [choice] = MENU[model.cursor];
207
+ const [choice] = entries[model.cursor];
186
208
  if (choice === 'exit') return { model, effect: 'exit' };
187
209
  if (choice === 'detach') return { model, effect: 'detach-preview' };
188
210
  return { model: go(model, choice, { menuEntry: choice, expanded: choice === 'skills' }) };
@@ -245,6 +267,23 @@ export function handleSetupKey(model, key) {
245
267
  return { model };
246
268
  }
247
269
 
270
+ if (step === 'mods') {
271
+ if (is(key, 'up')) return { model: { ...model, cursor: Math.max(0, model.cursor - 1), message: null } };
272
+ if (is(key, 'down')) return { model: { ...model, cursor: Math.min(MODS.length - 1, model.cursor + 1), message: null } };
273
+ if (is(key, 'toggle')) {
274
+ const mod = MODS[model.cursor];
275
+ const status = model.state.mods[mod.name];
276
+ if (status === 'activo') return { model: { ...model, message: MOD_ALREADY_INSTALLED } };
277
+ if (status === 'desconocido') return { model: { ...model, message: 'No pude comprobar este mod; revisa /plugin en Claude Code' } };
278
+ const { chosen } = model.answers.mods;
279
+ const next = chosen.includes(mod.name) ? chosen.filter(name => name !== mod.name) : [...chosen, mod.name];
280
+ return { model: { ...model, message: null, answers: { ...model.answers, mods: { ...model.answers.mods, chosen: next } } } };
281
+ }
282
+ if (is(key, 'enter')) return { model: go({ ...model, answers: closeMods(model) }, nextAfter(model, 'mods')) };
283
+ if (is(key, 'back')) return { model: go(model, previousOf(model, 'mods')) };
284
+ return { model };
285
+ }
286
+
248
287
  if (step === 'confirm') {
249
288
  if (key === 'd') return { model: { ...model, detail: !model.detail } };
250
289
  if (is(key, 'left') || is(key, 'right') || is(key, 'toggle')) return { model: { ...model, confirmYes: !model.confirmYes } };
@@ -272,7 +311,7 @@ export function applyMemoryPathCheck(model, target, kind, connections) {
272
311
  function folded(model) {
273
312
  const { state, answers } = model;
274
313
  const lines = [`Proyecto: ${state.project.displayName}${state.project.fromSubfolder ? ' (repositorio completo)' : ''}`];
275
- const order = ['skills', 'memory', 'memory-path', 'agents', 'confirm'];
314
+ const order = ['skills', 'memory', 'memory-path', 'agents', 'mods', 'confirm'];
276
315
  const at = order.indexOf(model.step);
277
316
  if (model.step === 'skills' || at < 0) {
278
317
  if (state.signals.length && model.step === 'skills') {
@@ -288,6 +327,10 @@ function folded(model) {
288
327
  if ((model.flow === 'full' && at > order.indexOf('agents')) || model.menuEntry === 'agents' && model.step === 'confirm') {
289
328
  lines.push(`IA: ${joinNames(answers.agents.map(agent => AGENT_NAMES[agent]))}`);
290
329
  }
330
+ if (hasModsStep(model) && ((model.flow === 'full' && at > order.indexOf('mods')) || (model.menuEntry === 'mods' && model.step === 'confirm'))) {
331
+ const count = MODS.filter(mod => modMarked(model, mod)).length;
332
+ lines.push(`Mods: ${count} ${count === 1 ? 'elegido' : 'elegidos'}`);
333
+ }
291
334
  return lines;
292
335
  }
293
336
 
@@ -358,12 +401,25 @@ function question(model) {
358
401
  if (model.message) info.push('', model.message);
359
402
  return { title: '¿Con qué IA trabajas?', body, info, keys: 'espacio marcar · Enter seguir · ← volver · q salir' };
360
403
  }
404
+ case 'mods': {
405
+ // The state sits in its own column next to the name, so a long description wraps without splitting it off.
406
+ const width = Math.max(...MODS.map(mod => mod.name.length));
407
+ const statusWidth = Math.max(...MODS.map(mod => MOD_STATUS_WORDS[state.mods[mod.name]].length));
408
+ const body = MODS.map((mod, index) => ({
409
+ cursor: index === model.cursor,
410
+ text: `${modMarked(model, mod) ? '◼' : '◻'} ${mod.name.padEnd(width)} ${MOD_STATUS_WORDS[state.mods[mod.name]].padEnd(statusWidth)} ${mod.label}`
411
+ }));
412
+ const info = ['', 'Los mods cambian cómo trabaja Claude Code en todos tus proyectos.', 'Se instalan con tu cuenta y se quitan desde /plugin.'];
413
+ if (model.message) info.push('', model.message);
414
+ return { title: '¿Qué mods de Claude Code quieres?', body, info, keys: 'espacio marcar · Enter seguir · ← volver · q salir' };
415
+ }
361
416
  case 'confirm': {
362
417
  const confirmation = buildConfirmation(state, answers);
418
+ const grouped = () => groupLines(confirmation.lines).flatMap(group => [{ text: group.title, header: true }, ...group.lines.map(line => ({ text: ` ${line.mark} ${line.text}` }))]);
363
419
  if (!confirmation.blocks.length) {
364
- return { title: 'No hay nada que preparar', body: confirmation.lines.map(line => ({ text: ` ${line.mark} ${line.text}` })), info: [], keys: 'Enter salir · ← volver' };
420
+ return { title: 'No hay nada que preparar', body: grouped(), info: [], keys: 'Enter salir · ← volver' };
365
421
  }
366
- const body = model.detail ? detailLines(model, confirmation) : confirmation.lines.map(line => ({ text: ` ${line.mark} ${line.text}` }));
422
+ const body = model.detail ? detailLines(model, confirmation) : grouped();
367
423
  const info = ['', 'No toco archivos tuyos. Se puede deshacer con', '`npx nexakit quitar`.', '',
368
424
  `¿Lo preparo? ${model.confirmYes ? '● Sí / ○ No' : '○ Sí / ● No'}`];
369
425
  return { title: 'Voy a preparar:', body, info, keys: 'Enter elegir · ←/→ cambiar · d detalle · Retroceso volver' };
@@ -426,7 +482,7 @@ function renderBody(model, { columns, level }) {
426
482
  for (const text of ready) push(`│ ${text}`, c.dim);
427
483
  push('│');
428
484
  push('◆ ¿Quieres cambiar algo?', c.accent);
429
- MENU.forEach(([, label], index) => push(`│ ${index === model.cursor ? '❯' : ' '} ${index === model.cursor ? '●' : '○'} ${label}`, index === model.cursor ? c.accent : undefined));
485
+ menuEntries(model).forEach(([, label], index) => push(`│ ${index === model.cursor ? '❯' : ' '} ${index === model.cursor ? '●' : '○'} ${label}`, index === model.cursor ? c.accent : undefined));
430
486
  push('└ Enter elegir · q salir', c.dim);
431
487
  return out.join('\n');
432
488
  }
@@ -481,6 +537,7 @@ function renderBody(model, { columns, level }) {
481
537
  const q = question(model);
482
538
  push(`◆ ${q.title}`, c.accent);
483
539
  for (const row of q.body) {
540
+ if (row.header) { push(`│ ${row.text}`, c.bold); continue; }
484
541
  const text = row.text.startsWith(' ') ? row.text.slice(1) : row.text;
485
542
  const marker = row.text.startsWith(' ') && /^ [+−↻!✓] /u.test(row.text) ? `│ ${text.slice(0, 2)}` : `│ ${row.cursor ? '❯' : ' '} `;
486
543
  const shown = marker.startsWith('│ ') && /^[+−↻!✓] /u.test(text) ? text.slice(2) : text;
@@ -498,8 +555,9 @@ function renderBody(model, { columns, level }) {
498
555
 
499
556
  // ── Loop ─────────────────────────────────────────────────────────────────────────────────────────────────────────
500
557
 
501
- const STEP_NUMBER = Object.freeze({ skills: 1, memory: 2, 'memory-path': 2, agents: 3, confirm: 4 });
502
- const STEP_COUNT = 4;
558
+ const STEP_NUMBER = Object.freeze({ skills: 1, memory: 2, 'memory-path': 2, agents: 3, mods: 4 });
559
+ // The mods question only exists with Claude Code chosen and a readable plugin list: five steps then, four otherwise.
560
+ const stepCount = model => (hasModsStep(model) ? 5 : 4);
503
561
  const TAGLINE = 'Tus skills. Tu memoria. Tus IA trabajando juntas.';
504
562
  const TAGLINE_SHORT = 'Skills, memoria e IA, juntas.';
505
563
 
@@ -508,7 +566,8 @@ function renderHeader(model, { columns, rows, level, bodyRows }) {
508
566
  const c = paint(level);
509
567
  const width = Math.max(30, columns - 1);
510
568
  const version = model.state.version ? ` v${model.state.version}` : '';
511
- const number = model.flow === 'full' ? STEP_NUMBER[model.step] : undefined;
569
+ const STEP_COUNT = stepCount(model);
570
+ const number = model.flow === 'full' ? (model.step === 'confirm' ? STEP_COUNT : STEP_NUMBER[model.step]) : undefined;
512
571
  const steps = number ? `Paso ${number} de ${STEP_COUNT}` : '';
513
572
  const dots = number ? Array.from({ length: STEP_COUNT }, (_, index) => (index < number ? '●' : '○')).join('') : '';
514
573
  const celebrates = model.step === 'done' && model.result?.ok;
@@ -1146,6 +1146,8 @@ const isNameList = value => Array.isArray(value) && value.every(item => typeof i
1146
1146
  function validSetupAnswers(answers) {
1147
1147
  return Boolean(answers && (answers.cleanProject === undefined || validCleanProject(answers.cleanProject)) && answers.version === 1 &&
1148
1148
  isNameList(answers.skills?.chosen) && isNameList(answers.skills?.discarded) &&
1149
+ // Mods are optional: answers saved before the mods step existed have none.
1150
+ (answers.mods === undefined || (isNameList(answers.mods.chosen) && isNameList(answers.mods.discarded))) &&
1149
1151
  Array.isArray(answers.agents) && answers.agents.every(agent => ['claude', 'codex', 'antigravity'].includes(agent)) &&
1150
1152
  (answers.memory?.decision === 'later' ||
1151
1153
  (answers.memory?.decision === 'path' && typeof answers.memory.path === 'string' && path.isAbsolute(answers.memory.path))));
@@ -8,7 +8,7 @@ import { IS_WINDOWS } from './platform.js';
8
8
  const PACKAGE_NAME = 'nexakit';
9
9
  const VERSION_RE = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/u;
10
10
  const COMPLETE_MARKER = '.completa';
11
- const PROBED_IMPORTS = ['ajv', 'zod', '@modelcontextprotocol/sdk/client/index.js'];
11
+ const PROBED_IMPORTS = ['ajv', 'zod', '@modelcontextprotocol/client'];
12
12
  const NPM_TIMEOUT_MS = 10 * 60 * 1000;
13
13
  const PROBE_TIMEOUT_MS = 30 * 1000;
14
14
 
@@ -81,7 +81,7 @@ const notFound = () => ({ status: null, stdout: '', stderr: '', errorCode: 'ENOE
81
81
 
82
82
  // The CLI is looked up in the given environment's PATH, not this process's, so a test HOME never reaches the
83
83
  // person's real agents.
84
- async function defaultRunner(command, environment = process.env) {
84
+ export async function defaultRunner(command, environment = process.env) {
85
85
  if (!IS_WINDOWS) {
86
86
  for (const folder of (environment.PATH ?? '').split(path.delimiter).filter(Boolean)) {
87
87
  const file = path.join(folder, command);
@@ -20,7 +20,7 @@ import {
20
20
  } from './skill-recommendations.js';
21
21
  import { formatRecommendationReport } from './recommend-report.js';
22
22
  import { applySetup } from './setup-apply.js';
23
- import { buildConfirmation, suggestedAnswers } from './setup-plan.js';
23
+ import { buildConfirmation, groupLines, joinNames, suggestedAnswers } from './setup-plan.js';
24
24
  import { gatherSetupState } from './setup-state.js';
25
25
  import { runSetupTui } from './setup-tui.js';
26
26
  import { doctorToolkit, setupToolkit } from './toolkit-setup.js';
@@ -318,10 +318,35 @@ export async function runToolkitCli(
318
318
  }
319
319
 
320
320
  const plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
321
+ // The plan under the same headings as the screen; the lines keep their two-space indent below each heading.
322
+ const groupedLines = (lines) =>
323
+ groupLines(lines)
324
+ .map((group) => [group.title, ...group.lines.map((line) => ` ${line.mark} ${line.text}`)].join('\n'))
325
+ .join('\n');
321
326
  // Required: missing or disabled fails the check; a list that could not be read is reported but does not fail.
322
327
  const superpowersReady = (result) =>
323
328
  !Object.values(result.superpowers?.states ?? {}).some((state) => ['falta', 'desactivado'].includes(state));
324
329
 
330
+ // nexakit's Claude Code mods: warnings only, a missing mod never fails the check.
331
+ function modsReport(mods) {
332
+ if (!mods) return [];
333
+ const names = (state) => Object.keys(mods).filter((name) => mods[name] === state);
334
+ const missing = names('falta'), outdated = names('actualizable'), disabled = names('desactivado');
335
+ const active = names('activo');
336
+ if (names('desconocido').length) return ['! No pude comprobar los mods de Claude Code; revisa /plugin'];
337
+ const lines = [];
338
+ const prefix = '! Mods de Claude Code:';
339
+ const one = (list) => list.length === 1;
340
+ if (missing.length)
341
+ lines.push(`${prefix} ${one(missing) ? 'falta' : 'faltan'} ${joinNames(missing)} (ejecuta npx nexakit para ${one(missing) ? 'instalarlo' : 'instalarlos'})`);
342
+ if (outdated.length)
343
+ lines.push(`${prefix} hay versión nueva de ${joinNames(outdated)} (ejecuta npx nexakit para ${one(outdated) ? 'actualizarlo' : 'actualizarlos'})`);
344
+ if (disabled.length)
345
+ lines.push(`${prefix} ${one(disabled) ? 'desactivado' : 'desactivados'} ${joinNames(disabled)}; ${one(disabled) ? 'actívalo' : 'actívalos'} desde /plugin`);
346
+ if (!lines.length) lines.push(`✓ Mods de Claude Code activos (${active.length} de ${Object.keys(mods).length})`);
347
+ return lines;
348
+ }
349
+
325
350
  function formatComprobarReport(result, { homeDirectory }) {
326
351
  const short = (value) =>
327
352
  value === homeDirectory ||
@@ -385,6 +410,7 @@ function formatComprobarReport(result, { homeDirectory }) {
385
410
  : `! No pude comprobar Superpowers en ${name}`,
386
411
  );
387
412
  }
413
+ lines.push(...modsReport(result.mods));
388
414
  for (const item of result.obsolete ?? []) {
389
415
  lines.push(`! ${item.message} ${item.command}`);
390
416
  }
@@ -515,13 +541,13 @@ async function runSetup(parsed, { out, err, input, output, isTTY, options }) {
515
541
  const title = `nexakit · ${state.project.displayName}${state.project.fromSubfolder ? ' (repositorio completo)' : ''}`;
516
542
  if (confirmation.allReady) {
517
543
  await out(
518
- `${title}\nTodo está listo.\n${confirmation.lines.map((line) => ` ${line.mark} ${line.text}`).join('\n')}\n`,
544
+ `${title}\nTodo está listo.\n${groupedLines(confirmation.lines)}\n`,
519
545
  );
520
546
  return 0;
521
547
  }
522
548
  if (!parsed.yes) {
523
549
  await out(
524
- `${title}\nCon las respuestas sugeridas prepararía:\n${confirmation.lines.map((line) => ` ${line.mark} ${line.text}`).join('\n')}\n\n` +
550
+ `${title}\nCon las respuestas sugeridas prepararía:\n${groupedLines(confirmation.lines)}\n\n` +
525
551
  'No hay una terminal interactiva para preguntarte.\nPara aplicarlo sin preguntas: npx nexakit --si\n',
526
552
  );
527
553
  return 2;
@@ -21,6 +21,7 @@ import {
21
21
  relinkIfUnchanged,
22
22
  } from './link-states.js';
23
23
  import { actualRoot, ensureStableInstall, nexakitDir } from './stable-install.js';
24
+ import { inspectMods } from './mods.js';
24
25
  import { inspectSuperpowers } from './superpowers.js';
25
26
 
26
27
  import packageJson from '../package.json' with { type: 'json' };
@@ -572,13 +573,13 @@ export async function doctorToolkit({
572
573
  const require = createRequire(path.join(toolkitRoot, 'package.json'));
573
574
  for (const name of [
574
575
  '@modelcontextprotocol/server',
575
- '@modelcontextprotocol/sdk',
576
+ '@modelcontextprotocol/client',
576
577
  'zod',
577
578
  'ajv',
578
579
  'toml-eslint-parser',
579
580
  ]) {
580
581
  try {
581
- require.resolve(name === '@modelcontextprotocol/sdk' ? name + '/client/index.js' : name);
582
+ require.resolve(name);
582
583
  dependencies[name] = true;
583
584
  } catch {
584
585
  dependencies[name] = false;
@@ -609,6 +610,13 @@ export async function doctorToolkit({
609
610
  ...(runCommand && { runCommand }),
610
611
  }),
611
612
  },
613
+ // nexakit's own Claude Code plugins (null without Claude Code). Missing ones are reported, never an error.
614
+ mods: await inspectMods({
615
+ agentsFound: { claude: clients.claude?.available },
616
+ environment,
617
+ toolkitRoot,
618
+ ...(runCommand && { runCommand }),
619
+ }),
612
620
  nativeConnectionVerified: false,
613
621
  };
614
622
  }