vault-go 0.8.0 → 0.8.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.
package/README.md CHANGED
@@ -50,12 +50,24 @@ bases, escrita, importação ou exclusão, use o cliente Bun completo abaixo.
50
50
 
51
51
  ### Opção Bun completa
52
52
 
53
- Execução direta:
53
+ Para instalar e registrar no Codex, execute em um terminal:
54
54
 
55
55
  ```sh
56
56
  bunx --bun vault-go@latest
57
57
  ```
58
58
 
59
+ Quando executado diretamente em um terminal, o pacote detecta o modo
60
+ interativo e chama `codex mcp add` com os argumentos corretos. O mesmo fluxo
61
+ pode ser solicitado explicitamente:
62
+
63
+ ```sh
64
+ bunx --bun vault-go@latest install
65
+ ```
66
+
67
+ O `bunx` sozinho baixa o pacote para o cache; o instalador da biblioteca é que
68
+ registra o servidor na configuração do Codex. Reinicie o Codex depois da
69
+ primeira instalação.
70
+
59
71
  Configuração MCP genérica:
60
72
 
61
73
  ```json
package/dist/cli.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export declare const CODEX_MCP_NAME = "vault-go";
2
+ export declare const CODEX_MCP_COMMAND: readonly ["bunx", "--bun", "vault-go@latest"];
3
+ export declare function shouldInstallFromCli(argument: string | undefined, stdinIsTTY: boolean, stderrIsTTY: boolean): boolean;
4
+ export declare function installCodexMcp(): number;
package/dist/cli.js ADDED
@@ -0,0 +1,34 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ export const CODEX_MCP_NAME = 'vault-go';
3
+ export const CODEX_MCP_COMMAND = ['bunx', '--bun', 'vault-go@latest'];
4
+ export function shouldInstallFromCli(argument, stdinIsTTY, stderrIsTTY) {
5
+ if (argument === 'install' || argument === 'setup' || argument === '--install') {
6
+ return true;
7
+ }
8
+ return argument === undefined && stdinIsTTY && stderrIsTTY;
9
+ }
10
+ export function installCodexMcp() {
11
+ const existing = spawnSync('codex', ['mcp', 'get', CODEX_MCP_NAME], {
12
+ encoding: 'utf8',
13
+ });
14
+ if (existing.error && 'code' in existing.error && existing.error.code === 'ENOENT') {
15
+ process.stderr.write('vault-go: o comando "codex" não foi encontrado. Instale o Codex CLI e tente novamente.\n');
16
+ return 1;
17
+ }
18
+ if (existing.status === 0) {
19
+ process.stderr.write(`vault-go: o MCP "${CODEX_MCP_NAME}" já está registrado no Codex.\n`);
20
+ return 0;
21
+ }
22
+ process.stderr.write('vault-go: registrando o MCP no Codex...\n');
23
+ const installed = spawnSync('codex', ['mcp', 'add', CODEX_MCP_NAME, '--', ...CODEX_MCP_COMMAND], { stdio: 'inherit' });
24
+ if (installed.error) {
25
+ process.stderr.write(`vault-go: não foi possível executar o instalador: ${installed.error.message}\n`);
26
+ return 1;
27
+ }
28
+ if (installed.status !== 0) {
29
+ process.stderr.write('vault-go: o Codex não conseguiu registrar o MCP.\n');
30
+ return installed.status ?? 1;
31
+ }
32
+ process.stderr.write('vault-go: MCP instalado. Reinicie o Codex para carregá-lo.\n');
33
+ return 0;
34
+ }
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env bun
2
2
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
+ import { installCodexMcp, shouldInstallFromCli } from './cli.js';
3
4
  import { createVaultGoServer, VERSION } from './server.js';
4
5
  const argument = process.argv[2];
5
6
  if (argument === '--version' || argument === '-v') {
@@ -7,7 +8,7 @@ if (argument === '--version' || argument === '-v') {
7
8
  process.exit(0);
8
9
  }
9
10
  if (argument === '--help' || argument === '-h') {
10
- process.stdout.write(`vault-go ${VERSION}\n\nServidor MCP cloud por stdio, executado com Bun.\n\nVariáveis:\n VAULT_GO_HOME Diretório de configuração (padrão: ~/.memvault)\n MEMVAULT_CONFIG_DIR Mesmo diretório usado pelo agente\n`);
11
+ process.stdout.write(`vault-go ${VERSION}\n\nServidor MCP cloud por stdio, executado com Bun.\n\nUso:\n bunx --bun vault-go@latest Instala no Codex quando executado em um terminal\n bunx --bun vault-go@latest install Instala no Codex explicitamente\n bunx --bun vault-go@latest serve Inicia o servidor MCP por stdio\n\nVariáveis:\n VAULT_GO_HOME Diretório de configuração (padrão: ~/.memvault)\n MEMVAULT_CONFIG_DIR Mesmo diretório usado pelo agente\n`);
11
12
  process.exit(0);
12
13
  }
13
14
  async function main() {
@@ -15,8 +16,13 @@ async function main() {
15
16
  const transport = new StdioServerTransport();
16
17
  await server.connect(transport);
17
18
  }
18
- main().catch((error) => {
19
- const message = error instanceof Error ? error.stack ?? error.message : String(error);
20
- process.stderr.write(`vault-go falhou: ${message}\n`);
21
- process.exitCode = 1;
22
- });
19
+ if (shouldInstallFromCli(argument, process.stdin.isTTY === true, process.stderr.isTTY === true)) {
20
+ process.exitCode = installCodexMcp();
21
+ }
22
+ else {
23
+ main().catch((error) => {
24
+ const message = error instanceof Error ? error.stack ?? error.message : String(error);
25
+ process.stderr.write(`vault-go falhou: ${message}\n`);
26
+ process.exitCode = 1;
27
+ });
28
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vault-go",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Servidor MCP Bun para pesquisar e registrar memória na plataforma Vault.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -22,6 +22,8 @@
22
22
  "files": [
23
23
  "dist/index.js",
24
24
  "dist/index.d.ts",
25
+ "dist/cli.js",
26
+ "dist/cli.d.ts",
25
27
  "dist/server.js",
26
28
  "dist/server.d.ts",
27
29
  "dist/config.js",