jarvis-ai-framework 1.0.1 → 1.0.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.
@@ -11,6 +11,15 @@ function commandExists(cmd) {
11
11
  }
12
12
  }
13
13
 
14
+ function isValidTokenKiller() {
15
+ try {
16
+ const helpOutput = execSync("rtk gain --help 2>&1", { encoding: "utf-8" });
17
+ return helpOutput.toLowerCase().includes("gain") || helpOutput.toLowerCase().includes("token");
18
+ } catch {
19
+ return false;
20
+ }
21
+ }
22
+
14
23
  export async function installRtk(flags) {
15
24
  configureFromFlags(flags);
16
25
 
@@ -21,13 +30,20 @@ export async function installRtk(flags) {
21
30
 
22
31
  // 1. Verificar se RTK já está instalado
23
32
  if (commandExists("rtk")) {
24
- try {
25
- const version = execSync("rtk --version", { encoding: "utf-8" }).trim();
26
- logger.info(`${GREEN}✓ RTK já instalado: ${version}${NC}`);
27
- logger.info(`${DIM} Para atualizar: cargo install brokk-rtk --force${NC}`);
33
+ // Validar que é o Token Killer (não Rust Type Kit)
34
+ if (isValidTokenKiller()) {
35
+ try {
36
+ const version = execSync("rtk --version", { encoding: "utf-8" }).trim();
37
+ logger.info(`${GREEN}✓ RTK já instalado: ${version}${NC}`);
38
+ logger.info(`${DIM} Para atualizar: cargo install brokk-rtk --force${NC}`);
39
+ logger.info("");
40
+ return;
41
+ } catch {}
42
+ } else {
43
+ logger.info(`${YELLOW}⚠ RTK encontrado mas não é o Token Killer (Rust Type Kit detectado)${NC}`);
44
+ logger.info(`${DIM} Sobrescrevendo com Token Killer...${NC}`);
28
45
  logger.info("");
29
- return;
30
- } catch {}
46
+ }
31
47
  }
32
48
 
33
49
  // 2. Verificar se cargo está disponível
@@ -73,15 +89,7 @@ export async function installRtk(flags) {
73
89
 
74
90
  // 4. Verificar instalação
75
91
  if (commandExists("rtk")) {
76
- try {
77
- // Validar que é o Token Killer (não Rust Type Kit)
78
- const helpOutput = execSync("rtk gain --help 2>&1", { encoding: "utf-8" });
79
-
80
- // Se 'gain' não funcionar, é o crate errado
81
- if (!helpOutput.toLowerCase().includes("gain") && !helpOutput.toLowerCase().includes("token")) {
82
- throw new Error("RTK encontrado mas não é o Token Killer (comando 'gain' não funciona)");
83
- }
84
-
92
+ if (isValidTokenKiller()) {
85
93
  const version = execSync("rtk --version", { encoding: "utf-8" }).trim();
86
94
  logger.info("");
87
95
  logger.info(`${GREEN}✓ RTK instalado com sucesso: ${version}${NC}`);
@@ -90,9 +98,8 @@ export async function installRtk(flags) {
90
98
  logger.info(` Execute ${GREEN}jarvis init${NC} (ou atualize o ENV.md) para ativar ${GREEN}RTK_ENABLED=true${NC}`);
91
99
  logger.info(` A rule de economia de tokens será ativada automaticamente.`);
92
100
  logger.info("");
93
- } catch (err) {
101
+ } else {
94
102
  logger.error(`${RED}✗ RTK instalado mas não é o Token Killer${NC}`);
95
- logger.error(`${RED} Erro: ${err.message}${NC}`);
96
103
  logger.info(`${DIM} Possível conflito: crate 'rtk' no crates.io é Rust Type Kit, não Token Killer${NC}`);
97
104
  logger.info(`${DIM} Use: cargo install brokk-rtk${NC}`);
98
105
  logger.info("");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jarvis-ai-framework",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Jarvis framework",
5
5
  "type": "module",
6
6
  "bin": {