@linkup-ai/abap-ai 2.2.0 → 2.2.2

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.
@@ -37,8 +37,9 @@ exports.readLicense = readLicense;
37
37
  exports.activate = activate;
38
38
  const crypto = __importStar(require("crypto"));
39
39
  const fs = __importStar(require("fs"));
40
+ const os = __importStar(require("os"));
40
41
  const path = __importStar(require("path"));
41
- const LICENSE_DIR = path.join(process.env.HOME || "~", ".abap-ai");
42
+ const LICENSE_DIR = path.join(os.homedir(), ".abap-ai");
42
43
  const LICENSE_PATH = path.join(LICENSE_DIR, "license.json");
43
44
  // ── Beta key validation (offline, HMAC-based) ───────────────────────
44
45
  // Em produção será substituído por fetch ao license server (api.lkpabap.ai)
package/dist/cli/init.js CHANGED
@@ -39,10 +39,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.init = init;
40
40
  const prompts_1 = __importDefault(require("prompts"));
41
41
  const fs = __importStar(require("fs"));
42
+ const os = __importStar(require("os"));
42
43
  const path = __importStar(require("path"));
43
44
  const https = __importStar(require("https"));
44
45
  const http = __importStar(require("http"));
45
- const MCP_JSON_PATH = path.join(process.env.HOME || "~", ".claude", "mcp.json");
46
+ const GLOBAL_MCP_PATH = path.join(os.homedir(), ".claude", "mcp.json");
47
+ const LOCAL_MCP_PATH = path.join(process.cwd(), ".claude", "mcp.json");
48
+ function getMcpPath(local) {
49
+ return local ? LOCAL_MCP_PATH : GLOBAL_MCP_PATH;
50
+ }
46
51
  // ---------------------------------------------------------------------------
47
52
  // Teste de conexão SAP
48
53
  // ---------------------------------------------------------------------------
@@ -115,30 +120,25 @@ async function testConnection(system) {
115
120
  // ---------------------------------------------------------------------------
116
121
  // mcp.json management
117
122
  // ---------------------------------------------------------------------------
118
- function readMcpConfig() {
123
+ function readMcpConfig(mcpPath) {
119
124
  try {
120
- const raw = fs.readFileSync(MCP_JSON_PATH, "utf-8");
125
+ const raw = fs.readFileSync(mcpPath, "utf-8");
121
126
  return JSON.parse(raw);
122
127
  }
123
128
  catch {
124
129
  return { mcpServers: {} };
125
130
  }
126
131
  }
127
- function writeMcpConfig(config) {
128
- const dir = path.dirname(MCP_JSON_PATH);
132
+ function writeMcpConfig(config, mcpPath) {
133
+ const dir = path.dirname(mcpPath);
129
134
  if (!fs.existsSync(dir)) {
130
135
  fs.mkdirSync(dir, { recursive: true });
131
136
  }
132
- fs.writeFileSync(MCP_JSON_PATH, JSON.stringify(config, null, 2) + "\n", "utf-8");
137
+ fs.writeFileSync(mcpPath, JSON.stringify(config, null, 2) + "\n", "utf-8");
133
138
  }
134
139
  function detectServerPath() {
135
- // Tentar encontrar o index.js relativo ao CLI
136
- const fromCli = path.resolve(__dirname, "..", "index.js");
137
- if (fs.existsSync(fromCli))
138
- return fromCli;
139
- // Fallback: path global do pacote
140
- const globalPath = path.resolve(__dirname, "..", "index.js");
141
- return globalPath;
140
+ // cli.js e index.js ficam ambos em dist/ após o build
141
+ return path.resolve(__dirname, "index.js");
142
142
  }
143
143
  function addSystemToConfig(config, system) {
144
144
  const serverName = `abap-${system.name}`;
@@ -155,7 +155,7 @@ function addSystemToConfig(config, system) {
155
155
  env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
156
156
  }
157
157
  config.mcpServers[serverName] = {
158
- command: "node",
158
+ command: process.execPath,
159
159
  args: [serverPath],
160
160
  env,
161
161
  };
@@ -249,14 +249,19 @@ async function promptSystem() {
249
249
  // ---------------------------------------------------------------------------
250
250
  // Main
251
251
  // ---------------------------------------------------------------------------
252
- async function init() {
252
+ async function init(options = {}) {
253
+ const local = options.local ?? false;
254
+ const mcpPath = getMcpPath(local);
255
+ const scope = local ? `projeto (${process.cwd()})` : "global";
253
256
  console.log(`
254
257
  ╭─────────────────────────────────────╮
255
258
  │ LKPABAP.ai — Setup │
256
259
  │ Conecte o Claude ao seu SAP │
257
260
  ╰─────────────────────────────────────╯
261
+
262
+ Escopo: ${scope}
258
263
  `);
259
- const config = readMcpConfig();
264
+ const config = readMcpConfig(mcpPath);
260
265
  const existingCount = Object.keys(config.mcpServers).filter((k) => k.startsWith("abap-")).length;
261
266
  if (existingCount > 0) {
262
267
  console.log(` ${existingCount} sistema(s) SAP já configurado(s).\n`);
@@ -320,10 +325,10 @@ async function init() {
320
325
  addMore = more;
321
326
  }
322
327
  if (addedSystems.length > 0) {
323
- writeMcpConfig(config);
328
+ writeMcpConfig(config, mcpPath);
324
329
  const total = Object.keys(config.mcpServers).filter((k) => k.startsWith("abap-")).length;
325
330
  console.log(`
326
- ✓ Configuração salva em ${MCP_JSON_PATH}
331
+ ✓ Configuração salva em ${mcpPath}
327
332
 
328
333
  ╭──────────────────────────────────────────────╮
329
334
  │ ${total} sistema(s) configurado(s):${" ".repeat(Math.max(0, 23 - total.toString().length))}│`);
@@ -337,8 +342,9 @@ async function init() {
337
342
  console.log(`${line}${" ".repeat(Math.max(1, 48 - line.length))}│`);
338
343
  }
339
344
  console.log(` │${" ".repeat(46)}│
340
- │ Próximo passo:${" ".repeat(29)}│
341
- Abra o VS Code / Claude Code e use!${" ".repeat(6)}│
345
+ │ Próximo passo no VS Code:${" ".repeat(19)}│
346
+ 1. Ctrl+Shift+P "Reload Window"${" ".repeat(8)}│
347
+ │ 2. Abra o Claude Code e use!${" ".repeat(13)}│
342
348
  ╰──────────────────────────────────────────────╯
343
349
  `);
344
350
  }
@@ -39,17 +39,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.remove = remove;
40
40
  const prompts_1 = __importDefault(require("prompts"));
41
41
  const fs = __importStar(require("fs"));
42
+ const os = __importStar(require("os"));
42
43
  const path = __importStar(require("path"));
43
- const MCP_JSON_PATH = path.join(process.env.HOME || "~", ".claude", "mcp.json");
44
- async function remove(name) {
44
+ const GLOBAL_MCP_PATH = path.join(os.homedir(), ".claude", "mcp.json");
45
+ const LOCAL_MCP_PATH = path.join(process.cwd(), ".claude", "mcp.json");
46
+ async function remove(name, options = {}) {
45
47
  const serverName = name.startsWith("abap-") ? name : `abap-${name}`;
48
+ const mcpPath = options.local ? LOCAL_MCP_PATH : GLOBAL_MCP_PATH;
46
49
  let config;
47
50
  try {
48
- const raw = fs.readFileSync(MCP_JSON_PATH, "utf-8");
51
+ const raw = fs.readFileSync(mcpPath, "utf-8");
49
52
  config = JSON.parse(raw);
50
53
  }
51
54
  catch {
52
- console.error(` ✗ Arquivo ${MCP_JSON_PATH} não encontrado.`);
55
+ console.error(` ✗ Arquivo ${mcpPath} não encontrado.`);
53
56
  process.exit(1);
54
57
  return;
55
58
  }
@@ -73,8 +76,8 @@ async function remove(name) {
73
76
  return;
74
77
  }
75
78
  delete config.mcpServers[serverName];
76
- fs.writeFileSync(MCP_JSON_PATH, JSON.stringify(config, null, 2) + "\n", "utf-8");
79
+ fs.writeFileSync(mcpPath, JSON.stringify(config, null, 2) + "\n", "utf-8");
77
80
  const remaining = Object.keys(config.mcpServers).filter((k) => k.startsWith("abap-")).length;
78
- console.log(`\n ✓ Sistema "${serverName}" removido de ${MCP_JSON_PATH}`);
81
+ console.log(`\n ✓ Sistema "${serverName}" removido de ${mcpPath}`);
79
82
  console.log(` ${remaining} sistema(s) restante(s).\n`);
80
83
  }
@@ -35,13 +35,15 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.status = status;
37
37
  const fs = __importStar(require("fs"));
38
+ const os = __importStar(require("os"));
38
39
  const path = __importStar(require("path"));
39
40
  const https = __importStar(require("https"));
40
41
  const http = __importStar(require("http"));
41
42
  const activate_js_1 = require("./activate.js");
42
- const MCP_JSON_PATH = path.join(process.env.HOME || "~", ".claude", "mcp.json");
43
- const LOG_DIR = path.join(process.env.HOME || "~", ".abap-ai", "logs");
44
- const VERSION = "2.0.0";
43
+ const MCP_JSON_PATH = path.join(os.homedir(), ".claude", "mcp.json");
44
+ const LOG_DIR = path.join(os.homedir(), ".abap-ai", "logs");
45
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
46
+ const VERSION = require("../../package.json").version;
45
47
  // ---------------------------------------------------------------------------
46
48
  // Teste rápido de conexão (timeout 5s)
47
49
  // ---------------------------------------------------------------------------
@@ -35,26 +35,30 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.systems = systems;
37
37
  const fs = __importStar(require("fs"));
38
+ const os = __importStar(require("os"));
38
39
  const path = __importStar(require("path"));
39
- const MCP_JSON_PATH = path.join(process.env.HOME || "~", ".claude", "mcp.json");
40
- async function systems() {
40
+ const GLOBAL_MCP_PATH = path.join(os.homedir(), ".claude", "mcp.json");
41
+ const LOCAL_MCP_PATH = path.join(process.cwd(), ".claude", "mcp.json");
42
+ async function systems(options = {}) {
43
+ const mcpPath = options.local ? LOCAL_MCP_PATH : GLOBAL_MCP_PATH;
41
44
  let config;
42
45
  try {
43
- const raw = fs.readFileSync(MCP_JSON_PATH, "utf-8");
46
+ const raw = fs.readFileSync(mcpPath, "utf-8");
44
47
  config = JSON.parse(raw);
45
48
  }
46
49
  catch {
47
50
  console.log("\n Nenhum sistema configurado.");
48
- console.log(" → Execute: abap-ai init\n");
51
+ console.log(` → Execute: abap-ai init${options.local ? " --local" : ""}\n`);
49
52
  return;
50
53
  }
51
54
  const sapServers = Object.entries(config.mcpServers || {}).filter(([k]) => k.startsWith("abap-"));
52
55
  if (sapServers.length === 0) {
53
56
  console.log("\n Nenhum sistema SAP configurado.");
54
- console.log(" → Execute: abap-ai init\n");
57
+ console.log(` → Execute: abap-ai init${options.local ? " --local" : ""}\n`);
55
58
  return;
56
59
  }
57
- console.log(`\n Sistemas SAP (${sapServers.length}):`);
60
+ const scope = options.local ? `projeto (${process.cwd()})` : "global";
61
+ console.log(`\n Sistemas SAP (${sapServers.length}) — ${scope}:`);
58
62
  console.log(" " + "─".repeat(60));
59
63
  for (const [name, server] of sapServers) {
60
64
  const env = server.env || {};
package/dist/cli.js CHANGED
@@ -6,7 +6,8 @@ const activate_js_1 = require("./cli/activate.js");
6
6
  const status_js_1 = require("./cli/status.js");
7
7
  const remove_js_1 = require("./cli/remove.js");
8
8
  const systems_js_1 = require("./cli/systems.js");
9
- const VERSION = "2.0.0";
9
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
10
+ const VERSION = require("../package.json").version;
10
11
  const HELP = `
11
12
  LKPABAP.ai — AI-powered ABAP development for SAP
12
13
 
@@ -14,21 +15,24 @@ const HELP = `
14
15
  abap-ai <comando> [opções]
15
16
 
16
17
  Comandos:
17
- init Configura conexão com sistema SAP (wizard interativo)
18
+ init [--local] Configura conexão com sistema SAP (wizard interativo)
18
19
  activate <LICENSE_KEY> Ativa licença do produto
19
20
  status Mostra licença, sistemas e métricas de uso
20
- systems Lista sistemas SAP configurados
21
- remove <nome> Remove um sistema SAP do mcp.json
21
+ systems [--local] Lista sistemas SAP configurados
22
+ remove <nome> [--local] Remove um sistema SAP do mcp.json
22
23
 
23
24
  Opções:
25
+ --local Usa config do projeto atual (.claude/mcp.json) em vez do global
24
26
  --version, -v Mostra versão
25
27
  --help, -h Mostra esta ajuda
26
28
 
27
29
  Exemplos:
28
- abap-ai init Wizard para adicionar sistema SAP
30
+ abap-ai init Wizard global (todos os workspaces)
31
+ abap-ai init --local Wizard para este workspace/projeto apenas
29
32
  abap-ai activate LK-XXXX Ativa licença
30
33
  abap-ai status Verifica estado do ambiente
31
- abap-ai remove novaforma-qas Remove sistema
34
+ abap-ai remove novaforma-qas Remove sistema (config global)
35
+ abap-ai remove rdg --local Remove sistema da config do projeto
32
36
  `;
33
37
  async function main() {
34
38
  const args = process.argv.slice(2);
@@ -41,9 +45,10 @@ async function main() {
41
45
  console.log(`LKPABAP.ai v${VERSION}`);
42
46
  return;
43
47
  }
48
+ const local = args.includes("--local");
44
49
  switch (command) {
45
50
  case "init":
46
- await (0, init_js_1.init)();
51
+ await (0, init_js_1.init)({ local });
47
52
  break;
48
53
  case "activate": {
49
54
  const key = args[1];
@@ -58,15 +63,15 @@ async function main() {
58
63
  await (0, status_js_1.status)();
59
64
  break;
60
65
  case "systems":
61
- await (0, systems_js_1.systems)();
66
+ await (0, systems_js_1.systems)({ local });
62
67
  break;
63
68
  case "remove": {
64
- const name = args[1];
69
+ const name = args.filter((a) => !a.startsWith("--"))[1];
65
70
  if (!name) {
66
71
  console.error(" ✗ Informe o nome do sistema: abap-ai remove <nome>");
67
72
  process.exit(1);
68
73
  }
69
- await (0, remove_js_1.remove)(name);
74
+ await (0, remove_js_1.remove)(name, { local });
70
75
  break;
71
76
  }
72
77
  default:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linkup-ai/abap-ai",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "description": "LKPABAP.ai — AI-powered ABAP development tools for SAP S/4HANA via ADT REST API",
5
5
  "main": "dist/index.js",
6
6
  "bin": {