agim-orchestrator 1.1.2 → 1.1.4

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/CHANGELOG.md CHANGED
@@ -14,6 +14,40 @@ e este projeto adere ao [Versionamento Semântico](https://semver.org/lang/pt-BR
14
14
 
15
15
  ---
16
16
 
17
+ ## [1.1.4] - 2026-10-29
18
+
19
+ ### Adicionado
20
+ - **`--json` em todos os comandos** — `sync`, `graph`, `rag:rebuild`, `core:link` agora suportam saída estruturada para CI/CD e integração com ferramentas externas.
21
+ - **`agim init` com RAG por padrão** — tenta criar índice do projeto se `@xenova/transformers` estiver disponível; caso contrário, orienta como instalar.
22
+
23
+ ### Corrigido
24
+ - **`agim sync --json`** — saída estruturada para automação.
25
+ - **`agim graph --json`** — captura saída do Graphify e retorna JSON.
26
+ - **`agim rag:rebuild --json`** — output estruturado (sucesso/erro).
27
+ - **`agim core:link --json`** — resultado estruturado do link.
28
+
29
+ ### Alterado
30
+ - `agim init` não pula mais RAG silenciosamente — tenta criar índice do projeto por padrão.
31
+
32
+ ---
33
+
34
+ ## [1.1.3] - 2026-10-29
35
+
36
+ ### Adicionado
37
+ - **`agim doctor`**: mensagens RAG melhoradas — mostra chunks/arquivos do índice do projeto, menciona economia de tokens, não menciona "global/core".
38
+ - **`agim init`**: tentativa de RAG por padrão — avisa se dependência `@xenova/transformers` não está instalada e orienta como ativar economia de tokens.
39
+ - **`agim audit --json`**: output estruturado para CI/CD (já funcionava, agora documentado).
40
+
41
+ ### Corrigido
42
+ - **`agim doctor` RAG**: remove menção confusa a "índice RAG global" — agora diz "nenhum índice deste projeto" e orienta `agim rag:rebuild`.
43
+ - **`agim init` RAG**: não pula mais silenciosamente — informa se dependência `@xenova/transformers` falta e como instalar.
44
+
45
+ ### Alterado
46
+ - `agim init` não pula mais RAG silenciosamente (era `--skip-rag` por padrão implícito).
47
+ - Mensagens de `doctor` e `init` padronizadas para focar em "economia de tokens".
48
+
49
+ ---
50
+
17
51
  ## [1.1.2] - 2026-10-29
18
52
 
19
53
  ### Corrigido (P0 — bloqueadores de release)
package/CONTRIBUTING.md CHANGED
@@ -8,6 +8,10 @@ Obrigado por considerar contribuir para a **Bíblia Universal de IA**! Este docu
8
8
 
9
9
  Este projeto está licenciado sob a **Licença MIT** — veja o arquivo [LICENSE](LICENSE) para detalhes.
10
10
 
11
+ ## 📚 Documentação
12
+
13
+ Manual do usuário: [github.com/Brendontailor/agim-docs](https://github.com/Brendontailor/agim-docs)
14
+
11
15
  ## 📋 Índice
12
16
 
13
17
  - [Código de Conduta](#código-de-conduta)
package/README.en.md CHANGED
@@ -1,9 +1,10 @@
1
- # AGIM (Agent Grimoire)
1
+ # AGIM (Agent Grimoire) — **v1.1.3**
2
2
 
3
3
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
4
4
  [![npm version](https://img.shields.io/npm/v/agim-orchestrator.svg)](https://www.npmjs.com/package/agim-orchestrator)
5
5
  [![npm downloads](https://img.shields.io/npm/dm/agim-orchestrator.svg)](https://www.npmjs.com/package/agim-orchestrator)
6
6
  [![Node Version](https://img.shields.io/node/v/agim-orchestrator.svg)](https://www.npmjs.com/package/agim-orchestrator)
7
+ [![Documentation](https://img.shields.io/badge/docs-agim--docs-blue.svg)](https://github.com/Brendontailor/agim-docs)
7
8
 
8
9
  > **AGIM (Agent Grimoire)** is an orchestration engine for AI agents.
9
10
  > It installs what an agent needs to work with discipline: clear rules, persistent memory, skills, checklists, templates and automatic validation.
@@ -12,6 +13,8 @@
12
13
 
13
14
  It works with any agent that reads `AGENTS.md` (OpenCode, Claude Code, Cursor, Copilot, Codex and similar).
14
15
 
16
+ > **Full documentation**: [github.com/Brendontailor/agim-docs](https://github.com/Brendontailor/agim-docs)
17
+
15
18
  ---
16
19
 
17
20
  ## Table of contents
package/README.md CHANGED
@@ -1,9 +1,10 @@
1
- # AGIM (Agent Grimoire)
1
+ # AGIM (Agent Grimoire) — **v1.1.3**
2
2
 
3
3
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
4
4
  [![npm version](https://img.shields.io/npm/v/agim-orchestrator.svg)](https://www.npmjs.com/package/agim-orchestrator)
5
5
  [![npm downloads](https://img.shields.io/npm/dm/agim-orchestrator.svg)](https://www.npmjs.com/package/agim-orchestrator)
6
6
  [![Node Version](https://img.shields.io/node/v/agim-orchestrator.svg)](https://www.npmjs.com/package/agim-orchestrator)
7
+ [![Documentation](https://img.shields.io/badge/docs-agim--docs-blue.svg)](https://github.com/Brendontailor/agim-docs)
7
8
 
8
9
  > **AGIM (Agent Grimoire)** é um motor de orquestração para agentes de IA.
9
10
  > Ele instala, no seu projeto, o que um agente precisa para trabalhar com disciplina: regras claras, memória persistente, skills, checklists, templates e validação automática.
@@ -12,6 +13,8 @@
12
13
 
13
14
  Funciona com qualquer agente que leia `AGENTS.md` (OpenCode, Claude Code, Cursor, Copilot, Codex e similares).
14
15
 
16
+ > **Documentação completa**: [github.com/Brendontailor/agim-docs](https://github.com/Brendontailor/agim-docs)
17
+
15
18
  ---
16
19
 
17
20
  ## Índice
@@ -2,6 +2,8 @@
2
2
 
3
3
  > Cada entrada segue o formato **mensagem → causa → solução**.
4
4
  > Comece sempre por `agim doctor`: ele aponta o que falta e qual comando resolve.
5
+ >
6
+ > **Documentação completa**: [github.com/Brendontailor/agim-docs](https://github.com/Brendontailor/agim-docs)
5
7
 
6
8
  ---
7
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agim-orchestrator",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "AGIM (Agent Grimoire): motor de orquestração para agentes de IA com skills, sub-agentes, memória persistente, checklists e validação.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -50,10 +50,11 @@
50
50
  "type": "git",
51
51
  "url": "git+https://github.com/Brendontailor/AGIM.git"
52
52
  },
53
- "homepage": "https://github.com/Brendontailor/AGIM#readme",
53
+ "homepage": "https://github.com/Brendontailor/agim-docs#readme",
54
54
  "bugs": {
55
55
  "url": "https://github.com/Brendontailor/AGIM/issues"
56
56
  },
57
+ "documentation": "https://github.com/Brendontailor/agim-docs",
57
58
  "engines": {
58
59
  "node": ">=18.0.0"
59
60
  },
@@ -153,13 +153,14 @@ const COMMANDS = {
153
153
 
154
154
  graph: {
155
155
  description: 'Consulta o grafo de código com Graphify (se instalado)',
156
- usage: 'agim graph "pergunta" [--cwd <dir>]',
157
- run: ({ positional, values }) => {
156
+ usage: 'agim graph "pergunta" [--json] [--cwd <dir>]',
157
+ run: ({ positional, flags, values }) => {
158
158
  const pergunta = positional.slice(1).join(' ').trim();
159
159
  if (!pergunta) {
160
160
  console.log('Uso: agim graph "pergunta sobre o código"');
161
161
  return { ok: false };
162
162
  }
163
+ const asJson = flags.has('json');
163
164
 
164
165
  const cwd = cwdFrom(values);
165
166
  const isWindows = process.platform === 'win32';
@@ -185,8 +186,12 @@ const COMMANDS = {
185
186
 
186
187
  const result = spawnSync(cmd, [...prefix, 'query', pergunta], {
187
188
  cwd,
188
- stdio: 'inherit'
189
+ stdio: asJson ? 'pipe' : 'inherit',
190
+ encoding: 'utf8'
189
191
  });
192
+ if (asJson) {
193
+ console.log(JSON.stringify({ ok: result.status === 0, output: result.stdout?.trim() || '', error: result.stderr?.trim() || '' }, null, 2));
194
+ }
190
195
  return { ok: result.status === 0 };
191
196
  }
192
197
  },
@@ -240,17 +245,46 @@ const ALIASES = {
240
245
  const { validate } = require('./config-schema.cjs');
241
246
  return { ok: validate(values && values.cwd ? path.resolve(values.cwd) : process.cwd()).valid };
242
247
  },
243
- 'rag:rebuild': () => runRagRebuild(),
244
- 'core:link': ({ values } = {}) => {
248
+ 'rag:rebuild': ({ flags } = {}) => {
249
+ const script = path.join(__dirname, 'bible-rag-index.js');
250
+ const asJson = flags?.has('json') || process.argv.includes('--json');
251
+ if (!hasDependency('@xenova/transformers')) {
252
+ if (asJson) {
253
+ console.log(JSON.stringify({ ok: false, reason: 'missing-dependency', message: 'Dependência opcional ausente: @xenova/transformers' }, null, 2));
254
+ } else {
255
+ console.log('⚠️ Dependência opcional ausente: @xenova/transformers');
256
+ console.log(' Instale com: npm install -g @xenova/transformers');
257
+ }
258
+ return { ok: false, reason: 'missing-dependency' };
259
+ }
260
+ const result = spawnSync(process.execPath, [script, '--rebuild'], {
261
+ stdio: asJson ? 'pipe' : 'inherit',
262
+ encoding: 'utf8'
263
+ });
264
+ if (asJson) {
265
+ console.log(JSON.stringify({ ok: result.status === 0, output: result.stdout?.trim() || '', error: result.stderr?.trim() || '' }, null, 2));
266
+ }
267
+ return { ok: result.status === 0 };
268
+ },
269
+ 'core:link': ({ flags, values } = {}) => {
270
+ const asJson = flags?.has('json') || process.argv.includes('--json');
245
271
  const { ensureCore, createCoreLink } = require('./core-link.cjs');
246
272
  const ensured = ensureCore();
247
273
  if (!ensured.ok) {
248
- console.log(`❌ Core indisponível: ${ensured.reason}`);
274
+ if (asJson) {
275
+ console.log(JSON.stringify({ ok: false, reason: 'core-unavailable', message: ensured.reason }, null, 2));
276
+ } else {
277
+ console.log(`❌ Core indisponível: ${ensured.reason}`);
278
+ }
249
279
  return { ok: false };
250
280
  }
251
- return createCoreLink(values && values.cwd ? path.resolve(values.cwd) : process.cwd(), {
281
+ const result = createCoreLink(values && values.cwd ? path.resolve(values.cwd) : process.cwd(), {
252
282
  force: process.argv.includes('--force')
253
283
  });
284
+ if (asJson) {
285
+ console.log(JSON.stringify({ ok: result.ok, ...result }, null, 2));
286
+ }
287
+ return result;
254
288
  }
255
289
  };
256
290
 
@@ -285,16 +285,35 @@ agim interview "Definir objetivo do projeto"
285
285
 
286
286
  function initRAG(cwd, skipRag = false) {
287
287
  if (skipRag) return { skipped: true, reason: 'flag --skip-rag' };
288
- const indexFile = path.join(
289
- process.env.USERPROFILE || process.env.HOME || '',
290
- '.agent-bible',
291
- 'rag_index',
292
- 'bible-index.json'
293
- );
294
- if (fs.existsSync(indexFile)) {
295
- return { skipped: true, reason: 'índice global já existe', indexFile };
288
+
289
+ const projectIndex = path.join(cwd, '.agim', 'rag', 'bible-index.json');
290
+ if (fs.existsSync(projectIndex)) {
291
+ return { skipped: true, reason: 'índice do projeto já existe', indexFile: projectIndex };
292
+ }
293
+
294
+ // Tentar criar índice do projeto se @xenova/transformers estiver disponível
295
+ try {
296
+ require.resolve('@xenova/transformers');
297
+ // Dep disponível - criar índice do projeto
298
+ const script = path.join(__dirname, 'bible-rag-index.js');
299
+ if (fs.existsSync(script)) {
300
+ const { spawnSync } = require('child_process');
301
+ const result = spawnSync(process.execPath, [script, '--rebuild', '--project', cwd], {
302
+ stdio: 'inherit',
303
+ timeout: 300000
304
+ });
305
+ if (result.status === 0 && fs.existsSync(projectIndex)) {
306
+ return { skipped: false, reason: 'índice do projeto criado', indexFile: projectIndex };
307
+ }
308
+ return { skipped: true, reason: 'falha ao criar índice do projeto (rode `agim rag:rebuild`)' };
309
+ }
310
+ return { skipped: true, reason: 'script de RAG não encontrado' };
311
+ } catch {
312
+ return {
313
+ skipped: true,
314
+ reason: 'dependência @xenova/transformers não instalada — rode `npm i -g @xenova/transformers` e depois `agim rag:rebuild` para ativar economia de tokens'
315
+ };
296
316
  }
297
- return { skipped: true, reason: 'índice global ainda não construído (rode `agim rag:rebuild`)', indexFile };
298
317
  }
299
318
 
300
319
  function initGraphify(cwd, skipGraphify = false) {
@@ -119,10 +119,34 @@ function checkRag(cwd) {
119
119
  path.join(cwd, '.agim', 'rag_index', 'bible-index.json'),
120
120
  path.join(cwd, 'rag_index', 'bible-index.json')
121
121
  ];
122
- if (projectIndexes.some((file) => fs.existsSync(file))) {
123
- return { ok: true, level: 'optional', message: 'índice RAG do projeto presente' };
122
+
123
+ let indexFile = null;
124
+ for (const file of projectIndexes) {
125
+ if (fs.existsSync(file)) {
126
+ indexFile = file;
127
+ break;
128
+ }
124
129
  }
125
-
130
+
131
+ if (indexFile) {
132
+ // Tentar ler chunks/arquivos do índice
133
+ let chunks = 0, files = 0;
134
+ try {
135
+ const content = fs.readFileSync(indexFile, 'utf8');
136
+ const index = JSON.parse(content);
137
+ chunks = index.chunks?.length || index.totalChunks || Object.keys(index).length;
138
+ files = index.files?.length || index.totalFiles || 0;
139
+ } catch {
140
+ // índice corrompido ou formato diferente
141
+ }
142
+ return {
143
+ ok: true,
144
+ level: 'optional',
145
+ message: `RAG: índice ativo (${chunks} chunks, ${files} arquivos) — economia de tokens ativa`
146
+ };
147
+ }
148
+
149
+ // Verificar global (não mencionar "global" explicitamente, só dizer que não há do projeto)
126
150
  const globalIndex = path.join(
127
151
  process.env.USERPROFILE || process.env.HOME || '',
128
152
  '.agent-bible',
@@ -133,10 +157,15 @@ function checkRag(cwd) {
133
157
  return {
134
158
  ok: false,
135
159
  level: 'optional',
136
- message: 'índice RAG global existe, mas não há índice deste projeto (opcional: `agim rag:rebuild`)'
160
+ message: 'RAG: nenhum índice deste projeto — rode `agim rag:rebuild` para ativar economia de tokens'
137
161
  };
138
162
  }
139
- return { ok: false, level: 'optional', message: 'índice RAG ausente (opcional: `agim rag:rebuild`)' };
163
+
164
+ return {
165
+ ok: false,
166
+ level: 'optional',
167
+ message: 'RAG: ausente — rode `agim rag:rebuild` para ativar economia de tokens (contexto não reenviado a cada turno)'
168
+ };
140
169
  }
141
170
 
142
171
  function checkGraphify(cwd) {
@@ -37,7 +37,8 @@ function sync(options = {}) {
37
37
  const cwd = options.cwd || process.cwd();
38
38
  const check = options.check === true;
39
39
  const force = options.force === true;
40
- const log = options.quiet === true ? () => {} : console.log;
40
+ const asJson = options.asJson === true;
41
+ const log = options.quiet === true || asJson ? () => {} : console.log;
41
42
  const agentsPath = path.join(cwd, 'AGENTS.md');
42
43
 
43
44
  log('═'.repeat(50));
@@ -101,7 +102,8 @@ if (require.main === module) {
101
102
  const args = process.argv.slice(2);
102
103
  const cwdIndex = args.indexOf('--cwd');
103
104
  const cwd = cwdIndex !== -1 && args[cwdIndex + 1] ? args[cwdIndex + 1] : process.cwd();
104
- const result = sync({ cwd, check: args.includes('--check'), force: args.includes('--force') });
105
+ const result = sync({ cwd, check: args.includes('--check'), force: args.includes('--force'), asJson: args.includes('--json') });
106
+ if (args.includes('--json')) console.log(JSON.stringify(result, null, 2));
105
107
  if (args.includes('--check') && result.drift) process.exit(1);
106
108
  if (result.synced === false && result.reason && result.reason !== 'missing-markers') process.exit(1);
107
109
  }