@h1veframework/cli 0.11.0 → 0.12.1

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 (2) hide show
  1. package/dist/index.js +72 -4
  2. package/package.json +3 -2
package/dist/index.js CHANGED
@@ -3,6 +3,8 @@
3
3
  // src/index.ts
4
4
  import { parseArgs } from "util";
5
5
  import { readFile } from "fs/promises";
6
+ import { existsSync } from "fs";
7
+ import { exec } from "child_process";
6
8
 
7
9
  // ../core/src/branch.ts
8
10
  import { execFile } from "child_process";
@@ -1385,8 +1387,58 @@ async function whoami(io) {
1385
1387
  };
1386
1388
  }
1387
1389
 
1390
+ // src/commands/mcp.ts
1391
+ import { join as join3 } from "path";
1392
+ var MCP_PKG = "@h1veframework/mcp";
1393
+ function mcpEntryPath(npmRootG) {
1394
+ return join3(npmRootG.trim(), "@h1veframework", "mcp", "dist", "index.js");
1395
+ }
1396
+ async function mcp(io, args) {
1397
+ if (args.positional !== "install") {
1398
+ return {
1399
+ human: "Uso: h1ve mcp install\n Registra o MCP do H1VE no Claude Code (a forma que conecta no Windows).",
1400
+ data: { ok: false, usage: true }
1401
+ };
1402
+ }
1403
+ const run = io.runProcess;
1404
+ const inst = await run("npm", ["i", "-g", MCP_PKG]);
1405
+ const rootRes = await run("npm", ["root", "-g"]);
1406
+ if (rootRes.code !== 0 || !rootRes.stdout.trim()) {
1407
+ throw new CliError("N\xE3o localizei o node_modules global (`npm root -g` falhou). O Node/npm est\xE1 instalado e no PATH?", 1);
1408
+ }
1409
+ const entry = mcpEntryPath(rootRes.stdout);
1410
+ if (!io.fileExists(entry)) {
1411
+ throw new CliError(
1412
+ `O pacote ${MCP_PKG} n\xE3o foi encontrado ap\xF3s a instala\xE7\xE3o:
1413
+ ${entry}
1414
+ ` + (inst.code !== 0 ? "O `npm i -g` falhou \u2014 verifique rede/permiss\xF5es e rode de novo." : `Rode \`npm i -g ${MCP_PKG}\` e tente de novo.`),
1415
+ 1
1416
+ );
1417
+ }
1418
+ await run("claude", ["mcp", "remove", "h1ve", "-s", "user"]);
1419
+ const add = await run("claude", ["mcp", "add", "h1ve", "-s", "user", "--", "node", entry]);
1420
+ const manual = `claude mcp add h1ve -s user -- node "${entry}"`;
1421
+ if (add.code !== 0) {
1422
+ return {
1423
+ human: `\u26A0 N\xE3o registrei automaticamente (o \`claude\` n\xE3o est\xE1 no PATH ou o comando falhou).
1424
+ Rode isto no seu terminal:
1425
+
1426
+ ${manual}
1427
+ `,
1428
+ data: { ok: false, manual, entry }
1429
+ };
1430
+ }
1431
+ return {
1432
+ human: `\u2713 MCP do H1VE registrado no Claude Code.
1433
+ Launcher: node ${entry}
1434
+ Confirme: claude mcp list \u2192 deve mostrar h1ve: \u2714 Connected
1435
+ (Reabra o Claude Code para o /mcp atualizar.)`,
1436
+ data: { ok: true, entry }
1437
+ };
1438
+ }
1439
+
1388
1440
  // src/index.ts
1389
- var VERSION = "0.9.0";
1441
+ var VERSION = "0.12.1";
1390
1442
  var HELP = `h1ve \u2014 CLI do H1VE
1391
1443
  (o comando legado \`nf\` continua funcionando como alias)
1392
1444
 
@@ -1411,6 +1463,8 @@ Uso:
1411
1463
  h1ve serve [--port 7391] [--origin http://localhost:3000]
1412
1464
  sobe o agente local (127.0.0.1) p/ o menu visual aplicar
1413
1465
  credenciais pelo navegador \u2014 imprime o c\xF3digo de pareamento
1466
+ h1ve mcp install registra o MCP do H1VE no Claude Code (a forma que conecta
1467
+ no Windows: node <abs>, n\xE3o npx)
1414
1468
 
1415
1469
  Flags:
1416
1470
  --json sa\xEDda em JSON cru (comp\xF5e em scripts)
@@ -1430,8 +1484,20 @@ Ambiente (opcional \u2014 'h1ve login' dispensa):
1430
1484
  H1VE_API_KEY PAT (nf_pat_\u2026) p/ escrever, ou a chave de servi\xE7o (s\xF3 leitura)
1431
1485
  (nomes legados aceitos: NEXUS_FLOW_API_URL / NEXUS_FLOW_API_KEY)
1432
1486
  `;
1433
- var COMMANDS = { start, status, spec, move, blocker, done, health, connect, serve, login, logout, whoami };
1434
- var NO_CONFIG = /* @__PURE__ */ new Set(["serve", "login", "logout"]);
1487
+ var COMMANDS = { start, status, spec, move, blocker, done, health, connect, serve, login, logout, whoami, mcp };
1488
+ var NO_CONFIG = /* @__PURE__ */ new Set(["serve", "login", "logout", "mcp"]);
1489
+ function quoteArg(a) {
1490
+ return /[\s"&|<>^()]/.test(a) ? `"${a.replace(/"/g, '""')}"` : a;
1491
+ }
1492
+ function runProcess(cmd, args) {
1493
+ const line = [cmd, ...args].map(quoteArg).join(" ");
1494
+ return new Promise((resolve) => {
1495
+ exec(line, { windowsHide: true }, (err, stdout, stderr) => {
1496
+ const code = err ? err.code ?? 1 : 0;
1497
+ resolve({ stdout: stdout ?? "", stderr: stderr ?? "", code });
1498
+ });
1499
+ });
1500
+ }
1435
1501
  async function readStdin() {
1436
1502
  if (process.stdin.isTTY) return "";
1437
1503
  const chunks = [];
@@ -1503,7 +1569,9 @@ ${HELP}`);
1503
1569
  credentials: defaultCredentialStore,
1504
1570
  // SPEC-173: `h1ve whoami` mostra o host + resolve o projeto do repo (override ou git remote).
1505
1571
  host: cfg?.baseUrl,
1506
- resolveProjectId: cfg ? () => cfg.projectId ? Promise.resolve(cfg.projectId) : autoResolveProjectId({ baseUrl: cfg.baseUrl, apiKey: cfg.apiKey }) : void 0
1572
+ resolveProjectId: cfg ? () => cfg.projectId ? Promise.resolve(cfg.projectId) : autoResolveProjectId({ baseUrl: cfg.baseUrl, apiKey: cfg.apiKey }) : void 0,
1573
+ runProcess,
1574
+ fileExists: (p) => existsSync(p)
1507
1575
  };
1508
1576
  const args = {
1509
1577
  positional: positionals[1],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h1veframework/cli",
3
- "version": "0.11.0",
3
+ "version": "0.12.1",
4
4
  "description": "The CLI for H1VE — the governance & memory layer for teams building with AI. Drive your feature flow (start, status, move, spec, done) from the terminal. Works with Claude Code, Cursor and Copilot.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -48,7 +48,8 @@
48
48
  "scripts": {
49
49
  "build": "tsup",
50
50
  "typecheck": "tsc --noEmit",
51
- "test": "vitest run"
51
+ "test": "vitest run",
52
+ "prepublishOnly": "npm run build"
52
53
  },
53
54
  "devDependencies": {
54
55
  "@nexus-flow/core": "*",