nexakit 0.5.0 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexakit",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Asistente por pasos de skills verificadas por SHA-256, coordinación entre agentes y memoria por proyecto para Claude Code y Codex.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -26,17 +26,14 @@
26
26
  "node": ">=24"
27
27
  },
28
28
  "dependencies": {
29
- "@modelcontextprotocol/sdk": "1.30.0",
29
+ "@modelcontextprotocol/client": "^2.4.0",
30
30
  "@modelcontextprotocol/server": "^2.4.0",
31
- "@modelcontextprotocol/server-filesystem": "2026.8.31",
31
+ "@modelcontextprotocol/server-filesystem": "2.3.0",
32
32
  "ajv": "^8.17.1",
33
33
  "eslint-visitor-keys": "5.0.1",
34
34
  "toml-eslint-parser": "1.0.3",
35
35
  "zod": "^4.6.7"
36
36
  },
37
- "devDependencies": {
38
- "@modelcontextprotocol/client": "^2.4.0"
39
- },
40
37
  "license": "MIT",
41
38
  "keywords": [
42
39
  "ai-agents",
@@ -8,8 +8,8 @@
8
8
  "huella": "e39c0a0493e7ca82"
9
9
  },
10
10
  "nexakit-modelo": {
11
- "version": "0.4.0",
12
- "huella": "e788ceeb40d5d47e"
11
+ "version": "0.4.1",
12
+ "huella": "2088ccd36890a7a4"
13
13
  },
14
14
  "nexakit-sesion": {
15
15
  "version": "0.2.0",
@@ -1 +1 @@
1
- {"name":"nexakit-modelo","version":"0.4.0","description":"Barra sobre el prompt con modelo, esfuerzo, recomendación por mensaje (delegar antes que cambiar de modelo), acierto de caché y uso de contexto y límites, sin cambiar nada."}
1
+ {"name":"nexakit-modelo","version":"0.4.1","description":"Barra sobre el prompt con modelo, esfuerzo, recomendación por mensaje (delegar antes que cambiar de modelo), acierto de caché y uso de contexto y límites, sin cambiar nada."}
@@ -24,9 +24,17 @@ export function ajustarPorLimite(recommendation, limite) {
24
24
 
25
25
  const etiqueta = (r) => `${nombreModelo(r.model)} · ${r.effort}`;
26
26
 
27
- export function decidir({ model, effort, recommendation, ctx, tokens, cacheFria = false, limite, rutinaSeguidas = 0 }) {
27
+ // Una recomendación rebajada por el límite de uso lo dice en la barra: nunca se baja de modelo sin explicarlo.
28
+ export function decidir(entrada) {
29
+ const { recommendation, limite } = entrada;
28
30
  const r = ajustarPorLimite(recommendation, limite);
29
31
  if (!r) return null;
32
+ const decision = decidirCon(r, entrada);
33
+ if (r === recommendation || decision.accion === 'mantener') return decision;
34
+ return { ...decision, texto: `${decision.texto} (límite ${Math.round(limite)} %)` };
35
+ }
36
+
37
+ function decidirCon(r, { model, effort, ctx, tokens, cacheFria = false, rutinaSeguidas = 0 }) {
30
38
  const mismaFamilia = familia(model) === familia(r.model);
31
39
  if (r.delegar === 'nivel-ligero') {
32
40
  return mismaFamilia && effort === r.effort
package/src/connect.js CHANGED
@@ -14,8 +14,12 @@ const DEFAULT_SCHEMA_PATH = path.resolve(
14
14
  "../schemas/project-memory.schema.json"
15
15
  );
16
16
  const FILESYSTEM_PACKAGE = "@modelcontextprotocol/server-filesystem";
17
- const FILESYSTEM_VERSION = "2026.8.31";
17
+ const FILESYSTEM_VERSION = "2.3.0";
18
18
  const FILESYSTEM_SPEC = `${FILESYSTEM_PACKAGE}@${FILESYSTEM_VERSION}`;
19
+ // `--read-only`: the server itself withholds every tool that writes, whatever the client allows.
20
+ // `--confine-roots`: a client's Roots cannot replace the vault with another directory.
21
+ const FILESYSTEM_FLAGS = Object.freeze(["--read-only", "--confine-roots"]);
22
+ const filesystemLaunch = (vaultPath) => ["npx", "-y", FILESYSTEM_SPEC, ...FILESYSTEM_FLAGS, vaultPath];
19
23
 
20
24
  export const READ_TOOLS = Object.freeze([
21
25
  "read_text_file",
@@ -33,7 +37,9 @@ export const WRITE_TOOLS = Object.freeze([
33
37
  "create_directory",
34
38
  "write_file",
35
39
  "edit_file",
36
- "move_file"
40
+ "move_file",
41
+ "append_file",
42
+ "copy_file"
37
43
  ]);
38
44
 
39
45
  const ADAPTERS = Object.freeze({
@@ -50,6 +56,7 @@ const ADAPTERS = Object.freeze({
50
56
  // The command each agent is driven with.
51
57
  const AGENT_COMMANDS = Object.freeze({ codex: "codex", claude: "claude", antigravity: "agy" });
52
58
  const MEMORY_SCRIPT = path.join("bin", "project-memory-mcp.js");
59
+ const OUTDATED_MESSAGE = `Actualizar el servidor de la memoria a la versión ${FILESYSTEM_VERSION}, en solo lectura.`;
53
60
 
54
61
  export async function connectMemory(options, context = {}) {
55
62
  const config = loadConfig(options, context);
@@ -246,9 +253,11 @@ function inspectCodex(config, runner) {
246
253
  const exists = result.status === 0;
247
254
  const matches = exists && outputMatchesFilesystemServer(result.stdout, config);
248
255
  const mcp = exists
249
- ? matches
256
+ ? matches === "current"
250
257
  ? component("mcp", "unchanged", "Codex ya usa esta bóveda.")
251
- : component("mcp", "conflict", "Codex tiene un MCP homónimo diferente.")
258
+ : matches === "outdated"
259
+ ? component("mcp", "update", OUTDATED_MESSAGE)
260
+ : component("mcp", "conflict", "Codex tiene un MCP homónimo diferente.")
252
261
  : component("mcp", "create", "Registrar el MCP personal en Codex.");
253
262
 
254
263
  const currentTools = parseCodexEnabledTools(result.stdout);
@@ -275,23 +284,18 @@ function inspectCodex(config, runner) {
275
284
  apply() {
276
285
  let serverCreated = false;
277
286
  try {
278
- if (mcp.action === "create") {
287
+ if (mcp.action === "update") {
288
+ requireSuccess(runner("codex", ["mcp", "remove", config.mcpName]), "No se pudo retirar el MCP anterior de Codex.");
289
+ }
290
+ if (mcp.action === "create" || mcp.action === "update") {
279
291
  requireSuccess(
280
- runner("codex", [
281
- "mcp",
282
- "add",
283
- config.mcpName,
284
- "--",
285
- "npx",
286
- "-y",
287
- FILESYSTEM_SPEC,
288
- config.vaultPath
289
- ]),
292
+ runner("codex", ["mcp", "add", config.mcpName, "--", ...filesystemLaunch(config.vaultPath)]),
290
293
  "No se pudo registrar el MCP en Codex."
291
294
  );
292
295
  serverCreated = true;
293
296
  }
294
- if (policy.action !== "unchanged") {
297
+ // Removing the old entry drops its read-only tool list with it.
298
+ if (policy.action !== "unchanged" || mcp.action === "update") {
295
299
  updateCodexPolicy(configPath, config.mcpName);
296
300
  }
297
301
  } catch (error) {
@@ -313,9 +317,11 @@ function inspectClaude(config, runner) {
313
317
  const exists = result.status === 0;
314
318
  const matches = exists && outputMatchesFilesystemServer(result.stdout, config);
315
319
  const mcp = exists
316
- ? matches
320
+ ? matches === "current"
317
321
  ? component("mcp", "unchanged", "Claude ya usa esta bóveda.")
318
- : component("mcp", "conflict", "Claude tiene un MCP homónimo diferente.")
322
+ : matches === "outdated"
323
+ ? component("mcp", "update", OUTDATED_MESSAGE)
324
+ : component("mcp", "conflict", "Claude tiene un MCP homónimo diferente.")
319
325
  : component("mcp", "create", "Registrar el MCP personal en Claude Code.");
320
326
  const settingsPath = path.join(config.homeDirectory, ".claude/settings.json");
321
327
  const policyState = inspectClaudePolicy(settingsPath, config.mcpName);
@@ -342,7 +348,13 @@ function inspectClaude(config, runner) {
342
348
  apply() {
343
349
  let serverCreated = false;
344
350
  try {
345
- if (mcp.action === "create") {
351
+ if (mcp.action === "update") {
352
+ requireSuccess(
353
+ runner("claude", ["mcp", "remove", config.mcpName, "--scope", "user"]),
354
+ "No se pudo retirar el MCP anterior de Claude Code."
355
+ );
356
+ }
357
+ if (mcp.action === "create" || mcp.action === "update") {
346
358
  requireSuccess(
347
359
  runner("claude", [
348
360
  "mcp",
@@ -351,10 +363,7 @@ function inspectClaude(config, runner) {
351
363
  "user",
352
364
  config.mcpName,
353
365
  "--",
354
- "npx",
355
- "-y",
356
- FILESYSTEM_SPEC,
357
- config.vaultPath
366
+ ...filesystemLaunch(config.vaultPath)
358
367
  ]),
359
368
  "No se pudo registrar el MCP en Claude Code."
360
369
  );
@@ -508,15 +517,21 @@ function outputMatchesFilesystemServer(output, config) {
508
517
  return argsMatchFilesystem(argsMatch[1].trim(), config.vaultPath);
509
518
  }
510
519
 
520
+ // "current": the pinned version started read-only and confined. "outdated": the same server for the same vault
521
+ // with another version or without those options, which `connect --apply` replaces. false: something else.
511
522
  function argsMatchFilesystem(args, vaultPath) {
512
523
  const values = Array.isArray(args) ? args : splitCommandArguments(args);
513
- if (values.length !== 3 || values[0] !== "-y" || !samePath(values[2], vaultPath)) {
524
+ if (values.length < 3 || values[0] !== "-y" || !samePath(values.at(-1), vaultPath)) {
514
525
  return false;
515
526
  }
516
- return (
517
- values[1] === FILESYSTEM_PACKAGE ||
518
- values[1].startsWith(`${FILESYSTEM_PACKAGE}@`)
519
- );
527
+ if (values[1] !== FILESYSTEM_PACKAGE && !values[1].startsWith(`${FILESYSTEM_PACKAGE}@`)) {
528
+ return false;
529
+ }
530
+ const flags = values.slice(2, -1);
531
+ if (flags.some((flag) => !FILESYSTEM_FLAGS.includes(flag)) || new Set(flags).size !== flags.length) {
532
+ return false;
533
+ }
534
+ return values[1] === FILESYSTEM_SPEC && flags.length === FILESYSTEM_FLAGS.length ? "current" : "outdated";
520
535
  }
521
536
 
522
537
  function isSymbolicLinkTo(candidate, expectedSource) {
@@ -544,8 +559,16 @@ function splitCommandArguments(value) {
544
559
  return value.trim().split(/\s+/);
545
560
  }
546
561
  const before = value.slice(0, packageEnd).trim().split(/\s+/);
547
- const vault = value.slice(packageEnd + 1).trim();
548
- return [...before, vault];
562
+ // The vault path may contain spaces: only the known options are split off before it.
563
+ let vault = value.slice(packageEnd + 1).trim();
564
+ const flags = [];
565
+ for (;;) {
566
+ const flag = FILESYSTEM_FLAGS.find((item) => vault === item || vault.startsWith(`${item} `));
567
+ if (!flag) break;
568
+ flags.push(flag);
569
+ vault = vault.slice(flag.length).trim();
570
+ }
571
+ return [...before, ...flags, vault];
549
572
  }
550
573
 
551
574
  function parseCodexEnabledTools(output) {
@@ -115,6 +115,13 @@ function policyMatches(tools, expected) {
115
115
  * Only these two modules and their tests are part of RG3-A1a: no TOML collector,
116
116
  * writer, public CLI dispatch, native MCP test or actual client configuration.
117
117
  */
118
+ // The exact direct launches `connect` has registered: the first reviewed one and, since nexakit 0.6.0, the
119
+ // read-only one. Anything else with the same name stays an identity mismatch.
120
+ const LEGACY_DIRECT_LAUNCHES = Object.freeze([
121
+ ["-y", "@modelcontextprotocol/server-filesystem@2026.8.31"],
122
+ ["-y", "@modelcontextprotocol/server-filesystem@2.3.0", "--read-only", "--confine-roots"]
123
+ ]);
124
+
118
125
  export function createMemoryConnectionPlan(input) {
119
126
  const report = blank();
120
127
  let data, descriptor;
@@ -171,9 +178,8 @@ export function createMemoryConnectionPlan(input) {
171
178
  } else {
172
179
  report.components.push(component("policy", "conflict", "MC_POLICY_MISMATCH"));
173
180
  }
174
- } else if (current.command === "npx" && equal(current.args, [
175
- "-y", "@modelcontextprotocol/server-filesystem@2026.8.31", descriptor.identity.vaultPath
176
- ]) && (current.cwd === undefined || current.cwd === descriptor.server.cwd)) {
181
+ } else if (current.command === "npx" && LEGACY_DIRECT_LAUNCHES.some(launch =>
182
+ equal(current.args, [...launch, descriptor.identity.vaultPath])) && (current.cwd === undefined || current.cwd === descriptor.server.cwd)) {
177
183
  report.connectionClass = "legacy-direct";
178
184
  if (data.migrateLegacy) {
179
185
  report.components.push(component("mcp", "migrate", "MC_LEGACY_MIGRATION_PROPOSED"),
@@ -1,10 +1,9 @@
1
1
  import path from "node:path";
2
2
  import { createRequire } from "node:module";
3
3
  import fs from "node:fs";
4
- import { Client } from "@modelcontextprotocol/sdk/client/index.js";
5
- import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
6
- import { Server } from "@modelcontextprotocol/sdk/server/index.js";
7
- import { InitializeRequestSchema, ListToolsRequestSchema, CallToolRequestSchema, McpError, SUPPORTED_PROTOCOL_VERSIONS } from "@modelcontextprotocol/sdk/types.js";
4
+ import { Client } from "@modelcontextprotocol/client";
5
+ import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
6
+ import { Server, ProtocolError } from "@modelcontextprotocol/server";
8
7
  import {
9
8
  MEMORY_READ_TOOLS, MEMORY_TOOL_SCHEMAS, MEMORY_MCP_LIMITS, MemoryMcpError,
10
9
  loadMemoryPolicy, recheckMemoryRoot, validateMemoryCall, recheckMemoryEntries, checkMemoryResult
@@ -15,26 +14,36 @@ const require = createRequire(import.meta.url);
15
14
  const codeOf = error => error instanceof MemoryMcpError ? error.code : "RG_BACKEND_ERROR";
16
15
  const resultText = r => r?.structuredContent?.content ?? r?.content?.filter(b => b.type === "text").map(b => b.text).join("\n");
17
16
 
17
+ export const FILESYSTEM_BACKEND_VERSION = "2.3.0";
18
+ // Only the `initialize` handshake of these revisions is served. The 2026-07-28 revision (`server/discover`, no
19
+ // handshake) stays out until the guard is reviewed for it: an unknown era must be refused, never served by default.
20
+ export const MEMORY_PROTOCOL_VERSIONS = Object.freeze(["2025-11-25", "2025-06-18", "2025-03-26", "2024-11-05", "2024-10-07"]);
21
+ /**
22
+ * `--read-only` makes the backend itself withhold every tool that writes, whatever a client allows, and
23
+ * `--confine-roots` keeps a client's Roots from replacing the vault with another directory.
24
+ */
25
+ export const filesystemBackendArgs = (entry, root) => [entry, "--read-only", "--confine-roots", "--", root];
26
+
18
27
  /** Runtime never resolves a package from npx, cwd, the manifest or client input. */
19
28
  export function createFilesystemBackend(root, onFatal) {
20
29
  const manifest = require.resolve("@modelcontextprotocol/server-filesystem/package.json");
21
30
  const pkg = JSON.parse(fs.readFileSync(manifest, "utf8"));
22
- if (pkg.version !== "2026.8.31" || pkg.bin?.["mcp-server-filesystem"] !== "dist/index.js") throw new MemoryMcpError("RG_BACKEND_VERSION", true);
31
+ if (pkg.version !== FILESYSTEM_BACKEND_VERSION || pkg.bin?.["mcp-server-filesystem"] !== "dist/index.js") throw new MemoryMcpError("RG_BACKEND_VERSION", true);
23
32
  const client = new Client({ name: "project-memory-guard-backend", version: "0.1.0" }, { capabilities: {} });
24
33
  const transport = new StdioClientTransport({ command: process.execPath,
25
- args: [path.join(path.dirname(manifest), "dist/index.js"), root], cwd: path.dirname(manifest),
34
+ args: filesystemBackendArgs(path.join(path.dirname(manifest), "dist/index.js"), root), cwd: path.dirname(manifest),
26
35
  stderr: "pipe", maxBufferSize: MEMORY_MCP_LIMITS.responseBytes });
27
36
  // Drain, never print the child's paths, stack traces or payloads.
28
37
  transport.stderr.resume();
29
38
  let closing = false;
30
39
  client.onerror = () => { if (!closing) onFatal("RG_BACKEND_PROTOCOL"); };
31
40
  client.onclose = () => { if (!closing) onFatal("RG_BACKEND_CLOSED"); };
32
- client.fallbackRequestHandler = async () => { onFatal("RG_BACKEND_CALLBACK"); throw new McpError(-32601, "RG_BACKEND_CALLBACK"); };
41
+ client.fallbackRequestHandler = async () => { onFatal("RG_BACKEND_CALLBACK"); throw new ProtocolError(-32601, "RG_BACKEND_CALLBACK"); };
33
42
  client.fallbackNotificationHandler = async () => { onFatal("RG_BACKEND_PROTOCOL"); };
34
43
  return {
35
44
  start: () => client.connect(transport, { timeout: MEMORY_MCP_LIMITS.timeoutMs }),
36
45
  listTools: () => client.listTools(undefined, { timeout: MEMORY_MCP_LIMITS.timeoutMs }),
37
- call: (name, args) => client.callTool({ name, arguments: args }, undefined, { timeout: MEMORY_MCP_LIMITS.timeoutMs }),
46
+ call: (name, args) => client.callTool({ name, arguments: args }, { timeout: MEMORY_MCP_LIMITS.timeoutMs }),
38
47
  async close() { closing = true; try { await client.close(); } finally { await transport.close(); } },
39
48
  get pid() { return transport.pid; }
40
49
  };
@@ -134,25 +143,26 @@ export async function runMemoryMcp(manifestPath, context = {}) {
134
143
  const gateway = await createMemoryGateway(manifestPath, context);
135
144
  let resolveEnd, initialized = false;
136
145
  const ended = new Promise(resolve => { resolveEnd = resolve; });
137
- const server = new Server({ name: "project-memory-guard", version: "0.1.0" }, { capabilities: { tools: {} } });
146
+ const server = new Server({ name: "project-memory-guard", version: "0.1.0" },
147
+ { capabilities: { tools: {} }, supportedProtocolVersions: [...MEMORY_PROTOCOL_VERSIONS] });
138
148
  const transport = new MemoryMcpTransport(context.stdin ?? process.stdin, context.stdout ?? process.stdout,
139
149
  { onClose: resolveEnd, onFatal: () => { void gateway.close().catch(() => {}); } });
140
- const protocolError = code => new McpError(-32602, code);
141
- server.setRequestHandler(InitializeRequestSchema, request => {
150
+ const protocolError = code => new ProtocolError(-32602, code);
151
+ server.setRequestHandler("initialize", request => {
142
152
  if (initialized) throw protocolError("RG_ALREADY_INITIALIZED");
143
- if (!SUPPORTED_PROTOCOL_VERSIONS.includes(request.params.protocolVersion)) throw protocolError("RG_PROTOCOL_UNSUPPORTED");
153
+ if (!MEMORY_PROTOCOL_VERSIONS.includes(request.params.protocolVersion)) throw protocolError("RG_PROTOCOL_UNSUPPORTED");
144
154
  initialized = true;
145
155
  return { protocolVersion: request.params.protocolVersion, capabilities: { tools: {} }, serverInfo: { name: "project-memory-guard", version: "0.1.0" } };
146
156
  });
147
- server.setRequestHandler(ListToolsRequestSchema, async (_, extra) => {
157
+ server.setRequestHandler("tools/list", async (_, ctx) => {
148
158
  if (!initialized) throw protocolError("RG_NOT_INITIALIZED");
149
- try { return { tools: await gateway.listTools(extra.signal) }; }
159
+ try { return { tools: await gateway.listTools(ctx.mcpReq.signal) }; }
150
160
  catch (error) { throw protocolError(codeOf(error)); }
151
161
  });
152
- server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
162
+ server.setRequestHandler("tools/call", async (request, ctx) => {
153
163
  if (!initialized) throw protocolError("RG_NOT_INITIALIZED");
154
164
  if (request.params.task) throw protocolError("RG_INPUT_INVALID");
155
- try { return await gateway.call(request.params.name, request.params.arguments ?? {}, extra.signal); }
165
+ try { return await gateway.call(request.params.name, request.params.arguments ?? {}, ctx.mcpReq.signal); }
156
166
  catch (error) { return { isError: true, content: [{ type: "text", text: codeOf(error) }] }; }
157
167
  });
158
168
  server.onerror = () => { void transport.close(); };
@@ -1,4 +1,4 @@
1
- import { deserializeMessage, serializeMessage } from "@modelcontextprotocol/sdk/shared/stdio.js";
1
+ import { deserializeMessage, serializeMessage } from "@modelcontextprotocol/server";
2
2
  import { MEMORY_MCP_LIMITS, MemoryMcpError } from "./memory-mcp-policy.js";
3
3
  import { decode, parseEventJson } from "./client-output-json.js";
4
4
 
package/src/mods.js ADDED
@@ -0,0 +1,92 @@
1
+ // The mods are nexakit's own Claude Code plugins (marketplace agent-toolkit). Like Superpowers, nexakit only lists,
2
+ // installs, enables or updates them through `claude plugin ...` and never edits plugin folders by hand.
3
+ import fs from 'node:fs';
4
+ import path from 'node:path';
5
+ import { SUPERPOWERS, defaultRunner } from './superpowers.js';
6
+
7
+ const MARKETPLACE = 'agent-toolkit';
8
+ const REPOSITORY = 'Jcabr3ra1/nexakit';
9
+ const COMMAND = 'claude';
10
+
11
+ const mod = (name, label) => Object.freeze({ name, id: `${name}@${MARKETPLACE}`, label });
12
+ export const MODS = Object.freeze([
13
+ mod('niveles', 'Subagentes por nivel para delegar'),
14
+ mod('nexakit-modelo', 'Barra con modelo, esfuerzo y consejo'),
15
+ mod('nexakit-ahorro', 'Recorta la salida larga de comandos'),
16
+ mod('nexakit-lecciones', 'Frena errores y guarda correcciones'),
17
+ mod('nexakit-sesion', 'Avisa cuándo abrir una sesión nueva'),
18
+ ]);
19
+
20
+ const allUnknown = () => Object.fromEntries(MODS.map((item) => [item.name, 'desconocido']));
21
+
22
+ function localVersion(name, toolkitRoot) {
23
+ try {
24
+ const manifest = JSON.parse(
25
+ fs.readFileSync(path.join(toolkitRoot, 'plugins', name, '.claude-plugin', 'plugin.json'), 'utf8'),
26
+ );
27
+ return typeof manifest.version === 'string' ? manifest.version : null;
28
+ } catch {
29
+ return null;
30
+ }
31
+ }
32
+
33
+ // name -> 'activo' | 'desactivado' | 'falta' | 'actualizable' | 'desconocido'. A list that cannot be read makes
34
+ // every mod unknown, never missing, so nexakit does not install over something it did not understand.
35
+ export function parseModsState(result, toolkitRoot) {
36
+ if (!result || result.status !== 0) return allUnknown();
37
+ let plugins;
38
+ try {
39
+ plugins = JSON.parse(String(result.stdout ?? ''));
40
+ } catch {
41
+ return allUnknown();
42
+ }
43
+ if (!Array.isArray(plugins)) plugins = plugins?.plugins;
44
+ if (!Array.isArray(plugins)) return allUnknown();
45
+ const states = {};
46
+ for (const item of MODS) {
47
+ const entry = plugins.find((plugin) => plugin?.id === item.id);
48
+ if (!entry) states[item.name] = 'falta';
49
+ else if (entry.enabled === false) states[item.name] = 'desactivado';
50
+ else {
51
+ const wanted = localVersion(item.name, toolkitRoot);
52
+ states[item.name] = wanted && entry.version !== wanted ? 'actualizable' : 'activo';
53
+ }
54
+ }
55
+ return states;
56
+ }
57
+
58
+ export async function inspectMods({ agentsFound, runCommand, environment, toolkitRoot } = {}) {
59
+ if (!agentsFound?.claude) return null;
60
+ const run = runCommand ?? (await defaultRunner(COMMAND, environment));
61
+ let result;
62
+ try {
63
+ result = await run(COMMAND, SUPERPOWERS.claude.list);
64
+ } catch {
65
+ result = null;
66
+ }
67
+ return parseModsState(result, toolkitRoot);
68
+ }
69
+
70
+ const detailOf = (output) => String(output?.stderr || output?.stdout || output?.errorCode || '').trim();
71
+
72
+ export async function applyMod(name, state, { runCommand, environment } = {}) {
73
+ const item = MODS.find((entry) => entry.name === name);
74
+ if (!item) throw new Error(`Mod desconocido: ${name}`);
75
+ const verb = { falta: 'install', desactivado: 'enable', actualizable: 'update' }[state];
76
+ if (!verb) return false;
77
+ const run = runCommand ?? (await defaultRunner(COMMAND, environment));
78
+ const args = ['plugin', verb, item.id];
79
+ let result = await run(COMMAND, args);
80
+ if (result?.status !== 0 && state === 'falta' && SUPERPOWERS.claude.marketplace.missing.test(detailOf(result))) {
81
+ const prepared =
82
+ (await run(COMMAND, ['plugin', 'marketplace', 'add', REPOSITORY]))?.status === 0 ||
83
+ (await run(COMMAND, ['plugin', 'marketplace', 'update', MARKETPLACE]))?.status === 0;
84
+ if (prepared) result = await run(COMMAND, args);
85
+ }
86
+ if (result?.status !== 0) {
87
+ const detail = detailOf(result);
88
+ const action = { falta: 'instalar', desactivado: 'activar', actualizable: 'actualizar' }[state];
89
+ throw new Error(`No se pudo ${action} el mod ${name}.${detail ? ` ${detail}` : ''}`);
90
+ }
91
+ return true;
92
+ }
@@ -21,6 +21,7 @@ import {
21
21
  import { planStableCommand, writeStableCommand } from './stable-command.js';
22
22
  import { ensureStableInstall, nexakitDir } from './stable-install.js';
23
23
  import { packageVersion, setupToolkit } from './toolkit-setup.js';
24
+ import { applyMod } from './mods.js';
24
25
  import { applySuperpowers } from './superpowers.js';
25
26
 
26
27
  const RETRY = 'Vuelve a ejecutar `npx nexakit` para reintentar.';
@@ -199,6 +200,9 @@ export async function applySetup(
199
200
  if (kind === 'superpowers') {
200
201
  return applySuperpowers(agent, state.superpowers?.[agent], { environment, ...(runCommand && { runCommand }) });
201
202
  }
203
+ if (kind === 'mod') {
204
+ return applyMod(agent, state.mods?.[agent], { environment, ...(runCommand && { runCommand }) });
205
+ }
202
206
  if (kind === 'memory-connect') {
203
207
  await withLock(homeDirectory, acquire, (lock) =>
204
208
  ensureMemoryAgent(memoryPath, agent, state.project.root, lock),
@@ -216,6 +220,7 @@ export async function applySetup(
216
220
  throw new Error(`Bloque desconocido: ${id}`);
217
221
  };
218
222
 
223
+ const skipped = [];
219
224
  for (const { id } of confirmation.blocks) {
220
225
  onProgress(id, 'start');
221
226
  try {
@@ -226,11 +231,18 @@ export async function applySetup(
226
231
  ? `${detail.startsWith('No se pudo') ? detail : `No se pudo conectar la memoria a ${AGENT_NAMES[id.split(':')[1]]}: ${detail}`} ${RETRY}`
227
232
  : `Falló «${confirmation.blocks.find((block) => block.id === id).label}»: ${detail} ${RETRY}`;
228
233
  onProgress(id, 'failed', message);
229
- return { ok: false, done, failed: { id, message }, finalCheck };
234
+ // Superpowers comes from each agent's own marketplace: when that fails, the memory, the rules and the other
235
+ // agents are still worth leaving ready. The run ends as not ready and the final check lists it as pending.
236
+ // The mods come from the same kind of plugin marketplace: one that fails does not stop the rest either.
237
+ if (id.startsWith('superpowers:') || id.startsWith('mod:')) {
238
+ skipped.push({ id, message });
239
+ continue;
240
+ }
241
+ return { ok: false, done, failed: { id, message }, ...(skipped.length && { skipped }), finalCheck };
230
242
  }
231
243
  done.push(id);
232
244
  onProgress(id, 'done');
233
245
  }
234
246
  // A final check that finds something still pending is a failure: the person must not read «Listo».
235
- return { ok: finalCheck?.ok ?? true, done, finalCheck };
247
+ return { ok: (finalCheck?.ok ?? true) && !skipped.length, done, ...(skipped.length && { skipped }), finalCheck };
236
248
  }
package/src/setup-plan.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // Pure: turns what nexakit found (setup-state.js) and the person's answers into the confirmation summary, in short
2
2
  // sentences, and the ordered blocks that apply it. No I/O, so every screen and every decision is testable.
3
+ import { MODS } from './mods.js';
3
4
 
4
5
  export const AGENTS = Object.freeze(['claude', 'codex', 'antigravity']);
5
6
  export const AGENT_NAMES = Object.freeze({
@@ -23,6 +24,19 @@ export const shortPath = (target, homeDirectory) =>
23
24
  target.startsWith(`${homeDirectory}\\`))
24
25
  ? `~${target.slice(homeDirectory.length)}`
25
26
  : target;
27
+
28
+ // The confirmation screen groups its lines under these headings, in this order, skipping empty sections.
29
+ export const SECTION_TITLES = Object.freeze({
30
+ proyecto: 'Proyecto',
31
+ ia: 'Tus IA',
32
+ mods: 'Mods de Claude Code',
33
+ memoria: 'Memoria',
34
+ });
35
+ export function groupLines(lines) {
36
+ return Object.entries(SECTION_TITLES)
37
+ .map(([section, title]) => ({ section, title, lines: lines.filter((line) => line.section === section) }))
38
+ .filter((group) => group.lines.length);
39
+ }
26
40
  const plural = (count, one, many) => (count === 1 ? one : many);
27
41
 
28
42
  // "frontend usa React", "el README menciona Tauri": the reason for a suggestion, from where the signal was found.
@@ -53,6 +67,7 @@ export function suggestedAnswers(state) {
53
67
  skills: { chosen, discarded: saved.skills.discarded.filter((name) => names.has(name)) },
54
68
  agents: [...saved.agents],
55
69
  memory: { ...saved.memory },
70
+ ...modAnswers(state, saved.agents, saved),
56
71
  };
57
72
  }
58
73
  const installed = (skill) => Object.values(skill.links ?? {}).includes('installed');
@@ -70,15 +85,42 @@ export function suggestedAnswers(state) {
70
85
  },
71
86
  agents: found.length ? found : [...AGENTS],
72
87
  memory,
88
+ ...modAnswers(state, found.length ? found : AGENTS, null),
73
89
  };
74
90
  }
75
91
 
76
- const sameAnswers = (a, b) => JSON.stringify(a) === JSON.stringify(b);
92
+ const MOD_NAMES = MODS.map((mod) => mod.name);
93
+ const NOT_SUGGESTED = new Set(['activo', 'desconocido']);
94
+
95
+ // The mods the person wants: what they chose before, plus every mod that still needs something (missing, disabled,
96
+ // outdated) unless they discarded it. Without a mods state (no Claude Code) there is nothing to ask, but what was
97
+ // saved is kept. Answers saved before the mods step have no `mods` and read as no discards.
98
+ function modAnswers(state, agents, saved) {
99
+ const before = saved?.mods;
100
+ if (!state.mods) return before ? { mods: { chosen: [...before.chosen], discarded: [...before.discarded] } } : {};
101
+ const suggest = agents.includes('claude');
102
+ const decided = new Set([...(before?.chosen ?? []), ...(before?.discarded ?? [])]);
103
+ const chosen = MOD_NAMES.filter(
104
+ (name) =>
105
+ before?.chosen.includes(name) ||
106
+ (suggest && !decided.has(name) && !NOT_SUGGESTED.has(state.mods[name] ?? 'desconocido')),
107
+ );
108
+ return { mods: { chosen, discarded: MOD_NAMES.filter((name) => before?.discarded.includes(name)) } };
109
+ }
110
+
111
+ // Answers saved before the mods step have no `mods`: they read as no mods chosen and none discarded.
112
+ const withMods = (answers) => ({
113
+ ...answers,
114
+ mods: { chosen: [...(answers.mods?.chosen ?? [])].sort(), discarded: [...(answers.mods?.discarded ?? [])].sort() },
115
+ });
116
+ const sameAnswers = (a, b) => JSON.stringify(withMods(a)) === JSON.stringify(withMods(b));
77
117
 
78
118
  export function buildConfirmation(state, answers) {
79
119
  const lines = [];
80
120
  const blocks = [];
81
- const add = (mark, text) => lines.push({ mark, text });
121
+ // `section` groups the confirmation screen: 'proyecto', 'ia', 'mods' or 'memoria'.
122
+ let section = 'proyecto';
123
+ const add = (mark, text) => lines.push({ mark, text, section });
82
124
  const block = (id, label) => blocks.push({ id, label });
83
125
  const answersChanged = !state.savedAnswers || !sameAnswers(state.savedAnswers, answers);
84
126
  const agents = AGENTS.filter((agent) => answers.agents.includes(agent));
@@ -128,6 +170,7 @@ export function buildConfirmation(state, answers) {
128
170
  if (toInstall.length || removeSkills.length) block('project-skills', 'Skills del proyecto');
129
171
 
130
172
  // Base skills of each chosen agent: only what is missing or repairable; conflicts are reported.
173
+ section = 'ia';
131
174
  const globalBlocks = [];
132
175
  for (const agent of agents) {
133
176
  const global = state.globalSkills[agent] ?? { pending: 0, conflicts: 0 };
@@ -170,7 +213,27 @@ export function buildConfirmation(state, answers) {
170
213
  }
171
214
  if (activeIn.length) add('✓', `Superpowers activo en ${joinNames(activeIn)}`);
172
215
 
216
+ // Mods: nexakit's own Claude Code plugins. Only the ones the person chose are installed, updated or enabled.
217
+ section = 'mods';
218
+ if (agents.includes('claude') && state.mods) {
219
+ const mods = state.mods;
220
+ const chosenMods = MODS.filter((mod) => answers.mods?.chosen.includes(mod.name));
221
+ for (const mod of chosenMods) {
222
+ const status = mods[mod.name];
223
+ if (status === 'falta') add('+', `Mod ${mod.name} en Claude Code`);
224
+ else if (status === 'actualizable') add('↻', `Actualizar el mod ${mod.name}`);
225
+ else if (status === 'desactivado') add('↻', `Activar el mod ${mod.name}`);
226
+ else continue;
227
+ block(`mod:${mod.name}`, `Mod ${mod.name}`);
228
+ }
229
+ const activeMods = MODS.filter((mod) => mods[mod.name] === 'activo');
230
+ if (activeMods.length) add('✓', `Mods activos en Claude Code: ${joinNames(activeMods.map((mod) => mod.name))}`);
231
+ if (MODS.some((mod) => (mods[mod.name] ?? 'desconocido') === 'desconocido'))
232
+ add('!', 'No pude comprobar los mods de Claude Code; revisa /plugin');
233
+ }
234
+
173
235
  // Memory: create it if needed, then connect it to each chosen agent.
236
+ section = 'memoria';
174
237
  if (answers.memory.decision === 'path') {
175
238
  const target = answers.memory.path;
176
239
  const kind = state.memory.kinds?.[target] ?? 'new';
@@ -213,6 +276,7 @@ export function buildConfirmation(state, answers) {
213
276
  }
214
277
  }
215
278
 
279
+ section = 'ia';
216
280
  const instructionNames = new Set(
217
281
  agents.map((agent) => ({ claude: 'CLAUDE.md', codex: 'AGENTS.md', antigravity: 'GEMINI.md' })[agent]),
218
282
  );
@@ -232,8 +296,10 @@ export function buildConfirmation(state, answers) {
232
296
  if (answersChanged && (blocks.length || state.savedAnswers)) {
233
297
  // Saved first, before any block that can fail, so a retry starts from what the person decided.
234
298
  blocks.unshift({ id: 'answers', label: 'Respuestas guardadas' });
235
- if (!blocks.some((item) => item.id === 'project-skills'))
299
+ if (!blocks.some((item) => item.id === 'project-skills')) {
300
+ section = 'proyecto';
236
301
  add('+', 'Guardar tus respuestas en .agent-toolkit (ignorado en Git)');
302
+ }
237
303
  }
238
304
  if (blocks.length) block('final-check', 'Comprobación final');
239
305
  const allReady = !lines.some((line) => ['+', '−', '↻'].includes(line.mark));
@@ -28,6 +28,7 @@ import {
28
28
  uncoveredSignals,
29
29
  } from './skill-recommendations.js';
30
30
  import { planStableCommand } from './stable-command.js';
31
+ import { inspectMods } from './mods.js';
31
32
  import { inspectSuperpowers } from './superpowers.js';
32
33
  import { compareVersions, readActualVersion } from './stable-install.js';
33
34
  import {
@@ -263,6 +264,7 @@ export async function gatherSetupState({
263
264
 
264
265
  const reviewInstructions = await planReviewInstructions({ homeDirectory, environment, codexHome });
265
266
  const superpowers = await inspectSuperpowers({ agentsFound, runCommand, environment });
267
+ const mods = await inspectMods({ agentsFound, runCommand, environment, toolkitRoot });
266
268
  return {
267
269
  folder:await inspectFolder(start),
268
270
  creationRoot:await fs.realpath(start),
@@ -270,6 +272,7 @@ export async function gatherSetupState({
270
272
  cleanProject:await readCleanProjectAnswers(project.root),
271
273
  reviewInstructions,
272
274
  superpowers,
275
+ mods,
273
276
  homeDirectory,
274
277
  version,
275
278
  project,