vault-go 0.7.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
@@ -104,6 +116,8 @@ limitados.
104
116
  - `vault_go_event`: eventos de prompt, ferramenta e resultado.
105
117
  - `vault_go_remember`: observações, decisões, descobertas e resumos.
106
118
  - `vault_go_search`: busca textual com ranking e trechos.
119
+ - `vault_go_search_index`: índice compacto com filtros, trechos e custo estimado.
120
+ - `vault_go_observations`: carrega em lote somente os IDs selecionados.
107
121
  - `vault_go_timeline`: contexto anterior e posterior a uma memória.
108
122
  - `vault_go_context`: contexto progressivo com limite de caracteres.
109
123
  - `vault_go_file_context`: histórico ligado aos arquivos lidos ou modificados.
@@ -121,6 +135,15 @@ limitados.
121
135
 
122
136
  O recurso `vault-go://status` fornece o resumo sanitizado em JSON.
123
137
 
138
+ Para reduzir o uso de contexto, prefira a recuperação em três camadas:
139
+
140
+ 1. Pesquise com `vault_go_search_index`, usando projeto, origem, conceitos,
141
+ arquivos e intervalo de datas quando conhecidos.
142
+ 2. Abra `vault_go_timeline` somente para os resultados que precisam de
143
+ contexto cronológico.
144
+ 3. Envie os IDs escolhidos a `vault_go_observations` para carregar o conteúdo
145
+ completo em um único lote tenant-scoped.
146
+
124
147
  As bases, filtros, vínculos e feed ficam exclusivamente no PostgreSQL da
125
148
  plataforma. A consulta retorna evidências e `synthesisAvailable: false`; o
126
149
  cliente MCP faz a síntese, evitando respostas inventadas e chaves ocultas no
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/cloud.d.ts CHANGED
@@ -8,6 +8,8 @@ export interface VaultMemoryApi {
8
8
  remember(input: Record<string, unknown>): Promise<unknown>;
9
9
  forget(id: string): Promise<unknown>;
10
10
  search(input: Record<string, unknown>): Promise<unknown>;
11
+ searchIndex(input: Record<string, unknown>): Promise<unknown>;
12
+ observations(ids: string[]): Promise<unknown>;
11
13
  timeline(input: Record<string, unknown>): Promise<unknown>;
12
14
  context(input: Record<string, unknown>): Promise<unknown>;
13
15
  fileContext(input: Record<string, unknown>): Promise<unknown>;
@@ -40,6 +42,8 @@ export declare class VaultCloudClient implements VaultMemoryApi {
40
42
  remember(input: Record<string, unknown>): Promise<unknown>;
41
43
  forget(id: string): Promise<unknown>;
42
44
  search(input: Record<string, unknown>): Promise<unknown>;
45
+ searchIndex(input: Record<string, unknown>): Promise<unknown>;
46
+ observations(ids: string[]): Promise<unknown>;
43
47
  timeline(input: Record<string, unknown>): Promise<unknown>;
44
48
  context(input: Record<string, unknown>): Promise<unknown>;
45
49
  fileContext(input: Record<string, unknown>): Promise<unknown>;
package/dist/cloud.js CHANGED
@@ -34,6 +34,12 @@ export class VaultCloudClient {
34
34
  async search(input) {
35
35
  return this.request('/memory/search', { method: 'POST', body: input });
36
36
  }
37
+ async searchIndex(input) {
38
+ return this.request('/memory/search/index', { method: 'POST', body: input });
39
+ }
40
+ async observations(ids) {
41
+ return this.request('/memory/memories/batch', { method: 'POST', body: { ids } });
42
+ }
37
43
  async timeline(input) {
38
44
  return this.request('/memory/timeline', { method: 'POST', body: input });
39
45
  }
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/dist/server.js CHANGED
@@ -127,10 +127,40 @@ export function createVaultGoServer(home = vaultHome(), cloud = new VaultCloudCl
127
127
  projectId: uuid.optional(),
128
128
  kind: z.string().trim().max(100).optional(),
129
129
  memoryType: z.string().trim().max(100).optional(),
130
+ platformSource: z.string().trim().max(100).optional(),
131
+ concepts: z.array(z.string().trim().min(1).max(500)).max(50).default([]),
132
+ files: z.array(z.string().trim().min(1).max(2_000)).max(50).default([]),
133
+ dateStartEpoch: z.number().int().positive().optional(),
134
+ dateEndEpoch: z.number().int().positive().optional(),
130
135
  limit: z.number().int().min(1).max(200).default(20),
131
136
  },
132
137
  annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true },
133
138
  }, async (input) => run(() => cloud.search(input)));
139
+ server.registerTool('vault_go_search_index', {
140
+ title: 'Pesquisar índice compacto',
141
+ description: 'Primeira camada de recuperação: retorna metadados, trechos e custo estimado sem carregar o conteúdo completo.',
142
+ inputSchema: {
143
+ query: z.string().trim().min(1).max(1_000),
144
+ projectId: uuid.optional(),
145
+ kind: z.string().trim().max(100).optional(),
146
+ memoryType: z.string().trim().max(100).optional(),
147
+ platformSource: z.string().trim().max(100).optional(),
148
+ concepts: z.array(z.string().trim().min(1).max(500)).max(50).default([]),
149
+ files: z.array(z.string().trim().min(1).max(2_000)).max(50).default([]),
150
+ dateStartEpoch: z.number().int().positive().optional(),
151
+ dateEndEpoch: z.number().int().positive().optional(),
152
+ limit: z.number().int().min(1).max(200).default(20),
153
+ },
154
+ annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true },
155
+ }, async (input) => run(() => cloud.searchIndex(input)));
156
+ server.registerTool('vault_go_observations', {
157
+ title: 'Carregar observações por ID',
158
+ description: 'Terceira camada de recuperação: carrega em lote somente as observações escolhidas no índice ou na linha do tempo.',
159
+ inputSchema: {
160
+ ids: z.array(uuid).min(1).max(100),
161
+ },
162
+ annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true },
163
+ }, async ({ ids }) => run(() => cloud.observations(ids)));
134
164
  server.registerTool('vault_go_timeline', {
135
165
  title: 'Abrir linha do tempo',
136
166
  description: 'Retorna memórias anteriores e posteriores a uma memória âncora.',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vault-go",
3
- "version": "0.7.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",