forjajs 5.1.0 → 5.3.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/CHANGELOG.md +108 -0
- package/README.md +52 -4
- package/README.pt-BR.md +54 -4
- package/dist/apps/cli/src/index.d.ts +0 -1
- package/dist/apps/cli/src/index.js +43 -32
- package/dist/apps/dashboard/app/api/forja/[...path]/route.js +34 -1
- package/dist/apps/dashboard/app/api/forja/capabilities.d.ts +26 -0
- package/dist/apps/dashboard/app/api/forja/capabilities.js +39 -0
- package/dist/apps/dashboard/app/dashboard-client.jsx +607 -42
- package/dist/apps/server/src/forja-nest.module.d.ts +6 -0
- package/dist/apps/server/src/forja-nest.module.js +55 -0
- package/dist/apps/server/src/main.d.ts +21 -4
- package/dist/apps/server/src/main.js +79 -57
- package/dist/apps/server/src/task-planning-service.d.ts +29 -0
- package/dist/apps/server/src/task-planning-service.js +195 -0
- package/dist/apps/server/src/task-runtime-coordinator.d.ts +57 -0
- package/dist/apps/server/src/task-runtime-coordinator.js +229 -0
- package/dist/bin/forja.js +3 -2
- package/dist/lib/agent-evals.d.ts +138 -0
- package/dist/lib/agent-evals.js +365 -0
- package/dist/lib/cli-output.js +14 -2
- package/dist/lib/code-context.d.ts +33 -5
- package/dist/lib/code-context.js +70 -5
- package/dist/lib/context-builder.d.ts +49 -4
- package/dist/lib/context-builder.js +114 -47
- package/dist/lib/core/coverage-gate.d.ts +59 -0
- package/dist/lib/core/coverage-gate.js +58 -0
- package/dist/lib/core/doc-graph.d.ts +38 -0
- package/dist/lib/core/doc-graph.js +83 -0
- package/dist/lib/core/health.js +286 -5
- package/dist/lib/core/journey.js +26 -0
- package/dist/lib/core/registry.js +81 -6
- package/dist/lib/docs-reference.d.ts +35 -0
- package/dist/lib/docs-reference.js +57 -0
- package/dist/lib/exec.d.ts +55 -0
- package/dist/lib/exec.js +141 -0
- package/dist/lib/project-wiring.js +6 -2
- package/dist/lib/session-memory.d.ts +38 -0
- package/dist/lib/session-memory.js +206 -0
- package/dist/lib/spec-trace.d.ts +46 -0
- package/dist/lib/spec-trace.js +184 -0
- package/dist/packages/adapter-git/src/index.js +13 -4
- package/dist/packages/adapter-nest/src/index.d.ts +2 -1
- package/dist/packages/adapter-nest/src/index.js +59 -1
- package/dist/packages/adapter-sqlite/src/index.d.ts +15 -1
- package/dist/packages/adapter-sqlite/src/index.js +61 -1
- package/dist/packages/context/src/index.d.ts +2 -0
- package/dist/packages/context/src/index.js +36 -15
- package/dist/packages/contracts/src/index.d.ts +64 -0
- package/dist/packages/core/src/index.d.ts +9 -1
- package/dist/packages/core/src/index.js +28 -3
- package/dist/packages/graph/src/index.js +14 -5
- package/dist/packages/llm/src/index.js +7 -24
- package/dist/packages/mcp/src/index.d.ts +8 -0
- package/dist/packages/mcp/src/index.js +12 -1
- package/dist/packages/observability/src/index.d.ts +11 -0
- package/dist/packages/observability/src/index.js +3 -0
- package/dist/packages/orchestration/src/index.d.ts +15 -1
- package/dist/packages/orchestration/src/index.js +127 -21
- package/dist/packages/planner/src/index.d.ts +7 -1
- package/dist/packages/planner/src/index.js +67 -10
- package/dist/packages/planner/src/proposal-store.d.ts +30 -0
- package/dist/packages/planner/src/proposal-store.js +109 -0
- package/dist/packages/policy/src/index.d.ts +9 -16
- package/dist/packages/policy/src/index.js +114 -31
- package/dist/packages/runtime/src/index.d.ts +16 -2
- package/dist/packages/runtime/src/index.js +176 -61
- package/dist/scripts/build-smart-context.d.ts +2 -0
- package/dist/scripts/build-smart-context.js +12 -3
- package/dist/scripts/code-context.d.ts +3 -1
- package/dist/scripts/code-context.js +13 -3
- package/dist/scripts/coverage-gate.d.ts +2 -0
- package/dist/scripts/coverage-gate.js +101 -0
- package/dist/scripts/eval-agents.d.ts +11 -0
- package/dist/scripts/eval-agents.js +96 -0
- package/dist/scripts/gen-commands-doc.d.ts +2 -0
- package/dist/scripts/gen-commands-doc.js +18 -0
- package/dist/scripts/hook-session-memory.d.ts +9 -0
- package/dist/scripts/hook-session-memory.js +20 -0
- package/dist/scripts/hook-session-start.js +34 -0
- package/dist/scripts/llm-fit.js +15 -6
- package/dist/scripts/simulate.js +16 -4
- package/dist/scripts/spec-trace.d.ts +10 -0
- package/dist/scripts/spec-trace.js +73 -0
- package/dist/scripts/sync-universal-memory.js +69 -4
- package/dist/scripts/token-benchmark.d.ts +33 -1
- package/dist/scripts/token-benchmark.js +179 -5
- package/dist/scripts/token-economy.js +3 -1
- package/dist/scripts/tools-doctor.d.ts +16 -1
- package/dist/scripts/tools-doctor.js +58 -17
- package/docs/commands.md +155 -0
- package/docs/fluxo.md +11 -7
- package/docs/init-project.md +3 -1
- package/docs/llm-fit-loop.md +20 -0
- package/docs/manual-operacional-cli-sdd-gsd.md +3 -2
- package/docs/produto/factsheet-marketing.md +7 -5
- package/docs/produto/roteiro-demo.md +14 -5
- package/docs/quick-reference.md +3 -3
- package/docs/token-optimization.md +10 -6
- package/memory/90-decisions/0091-memoria-de-sessao-por-hooks.md +40 -0
- package/memory/90-decisions/0092-criterios-de-aceite-ligados-a-testes.md +37 -0
- package/memory/90-decisions/0093-avaliacoes-com-agentes-reais.md +40 -0
- package/package.json +4 -2
- package/specs/avaliacoes-de-agentes/spec.md +52 -0
- package/specs/criterios-ligados-a-testes/spec.md +42 -0
- package/specs/memoria-de-sessao/spec.md +48 -0
- package/specs/v6-agent-runtime-portable/spec.md +83 -0
- package/specs/v6-core-consolidation/spec.md +70 -0
- package/specs/v6-docs-drift/spec.md +85 -0
- package/specs/v6-quality-gates/spec.md +104 -0
- package/specs/v6-token-economy/spec.md +84 -0
- package/templates/evals/agents/adr.json +25 -0
- package/templates/evals/agents/memoria.json +32 -0
- package/templates/evals/agents/proxima-acao.json +29 -0
- package/templates/evals/agents/spec-nova.json +26 -0
- package/templates/evals/agents/teste-do-criterio.json +29 -0
- package/templates/project/AGENTS.md +7 -0
- package/templates/project/CLAUDE.md +3 -2
- package/templates/project/skills/testing/SKILL.md +1 -1
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* forja context:smart global (missão, padrões, ADRs)
|
|
5
5
|
* forja context:smart --mode domain + visão/design/regras do projeto
|
|
6
6
|
* forja context:smart --mode task --task pix + nós do projeto que casam com a tarefa (FTS5)
|
|
7
|
+
* forja context:smart --full-context nós inteiros, sem trecho (opt-out da SPEC-057)
|
|
7
8
|
* forja context:smart <projeto> [keyword] forma posicional antiga (studio) — ainda aceita
|
|
8
9
|
*
|
|
9
10
|
* O projeto é inferido de onde o comando roda: no modo embedded é o próprio projeto; no studio,
|
|
@@ -14,12 +15,15 @@
|
|
|
14
15
|
import fs from 'node:fs';
|
|
15
16
|
import path from 'node:path';
|
|
16
17
|
import { ContextBuilder } from '../lib/context-builder.js';
|
|
18
|
+
import { COMMANDS } from '../lib/core/registry.js';
|
|
17
19
|
import { getDbPath, ensureSchema } from './memory-schema.js';
|
|
18
20
|
import { getForjaMode, getProjectsDir, getWorkspaceContextDir, getWorkspaceRoot, initWorkspace, resolveProject } from '../lib/workspace.js';
|
|
19
21
|
const MODES = ['global', 'domain', 'task'];
|
|
20
22
|
function fail(msg) {
|
|
21
23
|
console.error(msg);
|
|
22
|
-
|
|
24
|
+
// O usage do registro, não um texto à parte: foi assim que o help prometeu três modos que o comando
|
|
25
|
+
// ignorava — duas fontes da mesma frase, e só uma delas era verdade.
|
|
26
|
+
console.error(`Uso: ${COMMANDS['context:smart'].usage}`);
|
|
23
27
|
process.exit(1);
|
|
24
28
|
}
|
|
25
29
|
export function parseArgs(argv) {
|
|
@@ -34,6 +38,8 @@ export function parseArgs(argv) {
|
|
|
34
38
|
opts.task = val();
|
|
35
39
|
else if (a === '--project')
|
|
36
40
|
opts.project = val();
|
|
41
|
+
else if (a === '--full-context')
|
|
42
|
+
opts.full = true;
|
|
37
43
|
else if (a.startsWith('--'))
|
|
38
44
|
fail(`Opção desconhecida: ${a}`);
|
|
39
45
|
else
|
|
@@ -67,7 +73,7 @@ function main() {
|
|
|
67
73
|
ensureSchema({ silent: true });
|
|
68
74
|
const builder = new ContextBuilder(process.cwd(), getDbPath());
|
|
69
75
|
try {
|
|
70
|
-
const content = builder.build(mode, project ?? 'global', keyword);
|
|
76
|
+
const content = builder.build(mode, project ?? 'global', keyword, { full: opts.full === true });
|
|
71
77
|
const outDir = embedded
|
|
72
78
|
? path.join(getWorkspaceRoot(), '.context')
|
|
73
79
|
: project ? path.join(resolveProject(project), '.context') : getWorkspaceContextDir();
|
|
@@ -76,8 +82,11 @@ function main() {
|
|
|
76
82
|
const outFile = path.join(outDir, 'smart-context.md');
|
|
77
83
|
builder.save(content, outFile);
|
|
78
84
|
const files = (content.match(/^\*\*Path\*\*:/gm) || []).length;
|
|
85
|
+
const excerpts = /- \*\*Excerpts\*\*: (\d+)\/(\d+)/.exec(content);
|
|
86
|
+
const cortados = excerpts ? Number(excerpts[1]) : 0;
|
|
79
87
|
console.log(`✓ contexto ${mode}${keyword ? ` ("${keyword}")` : ''}${project ? ` de ${project}` : ''}: ${outFile}`);
|
|
80
|
-
console.log(` ${files} arquivo(s) · ~${Math.round(content.length / 4)} tokens`
|
|
88
|
+
console.log(` ${files} arquivo(s) · ~${Math.round(content.length / 4)} tokens` +
|
|
89
|
+
(cortados ? ` · ${cortados} nó(s) em trecho (--full-context injeta inteiro)` : ''));
|
|
81
90
|
if (files === 0)
|
|
82
91
|
console.log(' nada indexado ainda — rode: forja sync:universal');
|
|
83
92
|
}
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
* code:context — entrega o pacote de contexto mínimo de um domínio (SPEC-016, ADR-0009).
|
|
4
4
|
*
|
|
5
5
|
* forja code:context <domínio> só o mapa (context.md) — o contexto barato
|
|
6
|
-
* forja code:context <domínio> --code + o código da fatia (para editar)
|
|
6
|
+
* forja code:context <domínio> --code + o código da fatia (para editar), por relevância
|
|
7
|
+
* forja code:context <domínio> <termo> --code prioriza os arquivos que casam com o termo
|
|
8
|
+
* forja code:context <domínio> --code --full a fatia inteira, sem orçamento (SPEC-057)
|
|
7
9
|
* forja code:context <domínio> --project <path> aponta para outro projeto
|
|
8
10
|
*
|
|
9
11
|
* O −61% do `token:economy` virado ferramenta: o mapa que substitui a exploração, pronto para colar.
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
* code:context — entrega o pacote de contexto mínimo de um domínio (SPEC-016, ADR-0009).
|
|
4
4
|
*
|
|
5
5
|
* forja code:context <domínio> só o mapa (context.md) — o contexto barato
|
|
6
|
-
* forja code:context <domínio> --code + o código da fatia (para editar)
|
|
6
|
+
* forja code:context <domínio> --code + o código da fatia (para editar), por relevância
|
|
7
|
+
* forja code:context <domínio> <termo> --code prioriza os arquivos que casam com o termo
|
|
8
|
+
* forja code:context <domínio> --code --full a fatia inteira, sem orçamento (SPEC-057)
|
|
7
9
|
* forja code:context <domínio> --project <path> aponta para outro projeto
|
|
8
10
|
*
|
|
9
11
|
* O −61% do `token:economy` virado ferramenta: o mapa que substitui a exploração, pronto para colar.
|
|
@@ -29,8 +31,10 @@ function main() {
|
|
|
29
31
|
positional.push(argv[i]);
|
|
30
32
|
}
|
|
31
33
|
const domain = positional[0];
|
|
34
|
+
const query = positional.slice(1).join(' ');
|
|
32
35
|
const projectRoot = path.resolve(arg('--project') || process.cwd());
|
|
33
36
|
const includeCode = process.argv.includes('--code');
|
|
37
|
+
const full = process.argv.includes('--full');
|
|
34
38
|
const available = domainsOf(projectRoot);
|
|
35
39
|
if (!domain) {
|
|
36
40
|
if (!available.length) {
|
|
@@ -38,11 +42,11 @@ function main() {
|
|
|
38
42
|
console.error('Rode dentro de um projeto gerado, ou aponte com --project <path>.');
|
|
39
43
|
process.exit(1);
|
|
40
44
|
}
|
|
41
|
-
console.log('Uso: forja code:context <domínio> [--code] [--project <path>]\n');
|
|
45
|
+
console.log('Uso: forja code:context <domínio> [termo] [--code] [--full] [--project <path>]\n');
|
|
42
46
|
console.log(`Domínios disponíveis: ${available.join(', ')}`);
|
|
43
47
|
return;
|
|
44
48
|
}
|
|
45
|
-
const pack = buildContextPack({ projectRoot, domain, includeCode });
|
|
49
|
+
const pack = buildContextPack({ projectRoot, domain, includeCode, query, full });
|
|
46
50
|
if (!pack.found) {
|
|
47
51
|
console.error(`Domínio "${domain}" não tem context.md em ${projectRoot}.`);
|
|
48
52
|
if (available.length)
|
|
@@ -65,6 +69,12 @@ function main() {
|
|
|
65
69
|
console.error(''); // separa do stdout colável
|
|
66
70
|
if (includeCode) {
|
|
67
71
|
console.error(`— pacote completo: ${pack.totalTokens} tokens (mapa ${pack.mapTokens} + código ${pack.codeTokens}, ${pack.code.length} arquivos).`);
|
|
72
|
+
if (pack.codeOmitted.length) {
|
|
73
|
+
const omitidos = pack.codeOmitted.reduce((acc, c) => acc + c.tokens, 0);
|
|
74
|
+
console.error(`— fora do orçamento: ${pack.codeOmitted.length} arquivos (${omitidos} tokens) · --full traz a fatia inteira.`);
|
|
75
|
+
for (const c of pack.codeOmitted)
|
|
76
|
+
console.error(` ${c.path} (${c.tokens} tokens)`);
|
|
77
|
+
}
|
|
68
78
|
}
|
|
69
79
|
else {
|
|
70
80
|
console.error(`— só o mapa: ${pack.mapTokens} tokens. Para editar, adicione o código com --code, ou o blast radius com \`forja code:impact <símbolo>\`.`);
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* quality:coverage — roda a suíte com a cobertura nativa do Node e cobra o piso versionado (SPEC-056).
|
|
4
|
+
*
|
|
5
|
+
* Sem c8/istanbul de propósito: `node --test --experimental-test-coverage` já produz a tabela, e o
|
|
6
|
+
* trabalho aqui é ler a linha "all files" e comparar com `coverageLineFloor` de
|
|
7
|
+
* `lib/core/quality-budget.json`. É o ratchet gêmeo do check `type-debt`: o piso só desce em commit
|
|
8
|
+
* explícito, e a suíte continua sendo a mesma — não há segunda máquina de teste.
|
|
9
|
+
*
|
|
10
|
+
* A saída do filho é capturada e reimpressa inteira: o CI precisa ver cada teste, e o parsing precisa
|
|
11
|
+
* da tabela. Piso abaixo do combinado → exit 2 (`emitRejected`): gate negativo, não falha operacional.
|
|
12
|
+
*
|
|
13
|
+
* Ler a tabela, ler o piso e decidir o código de saída vive em `lib/core/coverage-gate.ts` — aqui só
|
|
14
|
+
* a coleta e a emissão, porque um teste deste script rodaria a suíte dentro da suíte (AC-3).
|
|
15
|
+
*
|
|
16
|
+
* A régua só vale se se repetir: `test/isolate-workspace.mjs` retira `NODE_V8_COVERAGE` do ambiente para
|
|
17
|
+
* que os CLIs filhos não despejem blocos parciais na agregação do Node — antes disso o `all files`
|
|
18
|
+
* variava 1,6pp entre execuções idênticas e o piso era sorteio (ver Evidências da SPEC-056).
|
|
19
|
+
*/
|
|
20
|
+
import fs from 'node:fs';
|
|
21
|
+
import path from 'node:path';
|
|
22
|
+
import { spawnSync } from 'node:child_process';
|
|
23
|
+
import { fileURLToPath } from 'node:url';
|
|
24
|
+
import { emitError, emitOk, emitRejected } from '../lib/cli-output.js';
|
|
25
|
+
import { asErrno } from '../lib/core/checks.js';
|
|
26
|
+
import { coverageFloorFrom, coverageSummary, decideCoverage, parseCoverageTotal } from '../lib/core/coverage-gate.js';
|
|
27
|
+
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
28
|
+
const BUDGET_LABEL = 'lib/core/quality-budget.json';
|
|
29
|
+
const BUDGET = path.join(ROOT, 'lib', 'core', 'quality-budget.json');
|
|
30
|
+
const asJson = process.argv.includes('--json');
|
|
31
|
+
function floor() {
|
|
32
|
+
let text;
|
|
33
|
+
try {
|
|
34
|
+
text = fs.readFileSync(BUDGET, 'utf8');
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
throw new Error(`orçamento ilegível (${BUDGET_LABEL}): ${asErrno(err).message}`);
|
|
38
|
+
}
|
|
39
|
+
return coverageFloorFrom(text, BUDGET_LABEL);
|
|
40
|
+
}
|
|
41
|
+
function testFiles() {
|
|
42
|
+
const dir = path.join(ROOT, 'test');
|
|
43
|
+
return fs.readdirSync(dir).filter((f) => f.endsWith('.test.js')).sort().map((f) => path.join('test', f));
|
|
44
|
+
}
|
|
45
|
+
let piso;
|
|
46
|
+
try {
|
|
47
|
+
piso = floor();
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
const mensagem = asErrno(err).message;
|
|
51
|
+
if (asJson)
|
|
52
|
+
emitError(mensagem, { code: 'EBUDGET' });
|
|
53
|
+
console.error(mensagem);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
const files = testFiles();
|
|
57
|
+
if (files.length === 0) {
|
|
58
|
+
if (asJson)
|
|
59
|
+
emitError('nenhum test/*.test.js encontrado', { code: 'ENOTEST' });
|
|
60
|
+
console.error('nenhum test/*.test.js encontrado');
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
const run = spawnSync(process.execPath, ['--test', '--experimental-test-coverage', '--import', './test/isolate-workspace.mjs', ...files], { cwd: ROOT, encoding: 'utf8' });
|
|
64
|
+
process.stdout.write(run.stdout ?? '');
|
|
65
|
+
process.stderr.write(run.stderr ?? '');
|
|
66
|
+
const total = parseCoverageTotal(run.stdout ?? '');
|
|
67
|
+
const outcome = decideCoverage({
|
|
68
|
+
spawnError: run.error !== undefined ? run.error.message : null,
|
|
69
|
+
total,
|
|
70
|
+
suiteStatus: run.status,
|
|
71
|
+
floor: piso,
|
|
72
|
+
});
|
|
73
|
+
if (run.error !== undefined) {
|
|
74
|
+
if (asJson)
|
|
75
|
+
emitError(`suíte não rodou: ${run.error.message}`, { code: outcome.code });
|
|
76
|
+
process.exit(outcome.exitCode);
|
|
77
|
+
}
|
|
78
|
+
if (total === null) {
|
|
79
|
+
if (asJson)
|
|
80
|
+
emitError('tabela de cobertura não encontrada na saída da suíte', { code: outcome.code });
|
|
81
|
+
console.error('não achei a linha "all files" da cobertura — o formato do Node mudou?');
|
|
82
|
+
process.exit(outcome.exitCode);
|
|
83
|
+
}
|
|
84
|
+
const payload = { lines: total.lines, branches: total.branches, funcs: total.funcs, floor: piso };
|
|
85
|
+
const resumo = coverageSummary(total, piso);
|
|
86
|
+
if (outcome.kind === 'suite-failed') {
|
|
87
|
+
if (asJson)
|
|
88
|
+
emitRejected({ ...payload, suiteExitCode: run.status ?? 'sinal' });
|
|
89
|
+
console.error(`suíte falhou (exit ${run.status ?? 'sinal'}) — ${resumo}`);
|
|
90
|
+
process.exit(outcome.exitCode);
|
|
91
|
+
}
|
|
92
|
+
if (outcome.kind === 'below-floor') {
|
|
93
|
+
if (asJson)
|
|
94
|
+
emitRejected({ ...payload, gap: Number((piso - total.lines).toFixed(2)) });
|
|
95
|
+
console.error(`ABAIXO DO PISO: ${resumo}`);
|
|
96
|
+
console.error('cubra o que o PR descobriu, ou desça o piso num commit próprio e justificado.');
|
|
97
|
+
process.exit(outcome.exitCode);
|
|
98
|
+
}
|
|
99
|
+
if (asJson)
|
|
100
|
+
emitOk(payload);
|
|
101
|
+
console.log(`OK ${resumo}`);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* eval:agents — avaliações com agentes reais em projeto descartável (SPEC-054, ADR-0093).
|
|
4
|
+
*
|
|
5
|
+
* forja eval:agents --agent claude|codex [--case a,b] [--model m] [--budget-usd n]
|
|
6
|
+
* [--timeout s] [--keep] [--list] [--json]
|
|
7
|
+
*
|
|
8
|
+
* Custa: cada caso é uma sessão real do agente. Exit 0 = todos passaram, 2 = algum falhou,
|
|
9
|
+
* 1 = agente ausente, caso inexistente ou argumento inválido.
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* eval:agents — avaliações com agentes reais em projeto descartável (SPEC-054, ADR-0093).
|
|
4
|
+
*
|
|
5
|
+
* forja eval:agents --agent claude|codex [--case a,b] [--model m] [--budget-usd n]
|
|
6
|
+
* [--timeout s] [--keep] [--list] [--json]
|
|
7
|
+
*
|
|
8
|
+
* Custa: cada caso é uma sessão real do agente. Exit 0 = todos passaram, 2 = algum falhou,
|
|
9
|
+
* 1 = agente ausente, caso inexistente ou argumento inválido.
|
|
10
|
+
*/
|
|
11
|
+
import fs from 'node:fs';
|
|
12
|
+
import path from 'node:path';
|
|
13
|
+
import { emitError, emitOk, emitRejected } from '../lib/cli-output.js';
|
|
14
|
+
import { ADAPTERS, appendHistory, compareRuns, loadCases, previousRun, runSuite } from '../lib/agent-evals.js';
|
|
15
|
+
import { asset, pkgRoot, script } from '../lib/paths.js';
|
|
16
|
+
import { getWorkspaceContextDir, getWorkspaceInfo } from '../lib/workspace.js';
|
|
17
|
+
const argv = process.argv.slice(2);
|
|
18
|
+
const json = argv.includes('--json');
|
|
19
|
+
const flag = (name) => { const i = argv.indexOf(name); return i >= 0 ? argv[i + 1] : undefined; };
|
|
20
|
+
const die = (msg, code = 'INVALID_ARGS') => {
|
|
21
|
+
if (json)
|
|
22
|
+
emitError(msg, { code });
|
|
23
|
+
console.error(msg);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
};
|
|
26
|
+
const all = loadCases(asset('templates', 'evals', 'agents'));
|
|
27
|
+
if (argv.includes('--list')) {
|
|
28
|
+
if (json)
|
|
29
|
+
emitOk({ cases: all.map((c) => ({ id: c.id, title: c.title, checks: c.checks.length })) });
|
|
30
|
+
for (const c of all)
|
|
31
|
+
console.log(`${c.id.padEnd(20)} ${c.title} (${c.checks.length} checks)`);
|
|
32
|
+
process.exit(0);
|
|
33
|
+
}
|
|
34
|
+
// Sem padrão de propósito: rodar custa dinheiro, então o agente é sempre uma escolha explícita.
|
|
35
|
+
const agentName = flag('--agent') ?? die(`escolha o agente: --agent ${Object.keys(ADAPTERS).join('|')} (cada caso é uma sessão real e paga)`, 'MISSING_ARG');
|
|
36
|
+
const make = ADAPTERS[agentName];
|
|
37
|
+
if (!make)
|
|
38
|
+
die(`agente desconhecido: ${agentName} (suportados: ${Object.keys(ADAPTERS).join(', ')})`);
|
|
39
|
+
const adapter = make();
|
|
40
|
+
if (!adapter.version())
|
|
41
|
+
die(`${agentName} não está instalado ou não responde a --version`, 'AGENT_MISSING');
|
|
42
|
+
const wanted = flag('--case')?.split(',').map((s) => s.trim()).filter(Boolean);
|
|
43
|
+
const unknown = (wanted ?? []).filter((id) => !all.some((c) => c.id === id));
|
|
44
|
+
if (unknown.length)
|
|
45
|
+
die(`caso desconhecido: ${unknown.join(', ')} (veja forja eval:agents --list)`, 'NOT_FOUND');
|
|
46
|
+
const cases = wanted ? all.filter((c) => wanted.includes(c.id)) : all;
|
|
47
|
+
const budgetUsd = Number(flag('--budget-usd') ?? 1);
|
|
48
|
+
const timeoutS = Number(flag('--timeout') ?? 300);
|
|
49
|
+
if (!(budgetUsd > 0) || !(timeoutS > 0))
|
|
50
|
+
die('--budget-usd e --timeout precisam ser positivos');
|
|
51
|
+
const model = flag('--model');
|
|
52
|
+
const version = JSON.parse(fs.readFileSync(path.join(pkgRoot, 'package.json'), 'utf8')).version;
|
|
53
|
+
if (!json) {
|
|
54
|
+
console.log(`Avaliando ${agentName}${model ? ` (${model})` : ''} em ${cases.length} caso(s) — cada caso é uma sessão real do agente.`);
|
|
55
|
+
if (agentName === 'claude')
|
|
56
|
+
console.log(`Teto por caso: US$ ${budgetUsd.toFixed(2)} · timeout ${timeoutS} s\n`);
|
|
57
|
+
else
|
|
58
|
+
console.log(`Timeout por caso: ${timeoutS} s (o Codex não tem teto de custo por flag)\n`);
|
|
59
|
+
}
|
|
60
|
+
const line = (r) => {
|
|
61
|
+
const cost = r.costUsd != null ? ` · US$ ${r.costUsd.toFixed(3)}` : '';
|
|
62
|
+
console.log(`${r.pass ? '✓' : '✗'} ${r.id.padEnd(20)} ${(r.durationMs / 1000).toFixed(0)} s · ${r.commands} comando(s)${cost}`);
|
|
63
|
+
for (const k of r.checks)
|
|
64
|
+
if (!k.ok || !r.pass)
|
|
65
|
+
console.log(` ${k.ok ? '✓' : '✗'} ${k.desc} — ${k.detail}`);
|
|
66
|
+
if (r.error)
|
|
67
|
+
console.log(` ✗ agente: ${r.error}`);
|
|
68
|
+
if (!r.pass && r.answer)
|
|
69
|
+
console.log(` resposta: ${r.answer.replace(/\s+/g, ' ').slice(0, 200)}`);
|
|
70
|
+
};
|
|
71
|
+
const result = runSuite(cases, adapter, version, {
|
|
72
|
+
forjaBin: script('bin/forja'), model, budgetUsd, timeoutMs: timeoutS * 1000, keep: argv.includes('--keep'),
|
|
73
|
+
onCase: json ? undefined : (_c, r) => line(r),
|
|
74
|
+
});
|
|
75
|
+
const ws = getWorkspaceInfo();
|
|
76
|
+
const historyFile = ws.exists ? path.join(getWorkspaceContextDir(), 'agent-evals.jsonl') : null;
|
|
77
|
+
const prev = historyFile ? previousRun(historyFile, result.agent, result.model) : null;
|
|
78
|
+
const diff = compareRuns(prev, result);
|
|
79
|
+
if (historyFile)
|
|
80
|
+
appendHistory(historyFile, result);
|
|
81
|
+
if (json) {
|
|
82
|
+
const payload = { ...result, regressed: diff.regressed, fixed: diff.fixed, history: historyFile };
|
|
83
|
+
if (result.passed < result.cases.length)
|
|
84
|
+
emitRejected(payload);
|
|
85
|
+
emitOk(payload);
|
|
86
|
+
}
|
|
87
|
+
console.log(`\n${result.passed}/${result.cases.length} caso(s) passaram${result.costUsd != null ? ` · custo total US$ ${result.costUsd.toFixed(3)}` : ''}`);
|
|
88
|
+
if (prev) {
|
|
89
|
+
console.log(`Comparado com ${prev.ts.slice(0, 16).replace('T', ' ')} (Forja ${prev.forjaVersion}): ${prev.passed}/${prev.cases.length}`);
|
|
90
|
+
if (diff.regressed.length)
|
|
91
|
+
console.log(` ✗ passaram a falhar: ${diff.regressed.join(', ')}`);
|
|
92
|
+
if (diff.fixed.length)
|
|
93
|
+
console.log(` ✓ passaram a passar: ${diff.fixed.join(', ')}`);
|
|
94
|
+
}
|
|
95
|
+
console.log(historyFile ? `Histórico: ${historyFile}` : 'Sem workspace: o resultado não foi guardado (forja workspace:init).');
|
|
96
|
+
process.exit(result.passed === result.cases.length ? 0 : 2);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* docs:gen — regenera docs/commands.md a partir do registry (SPEC-055).
|
|
4
|
+
*
|
|
5
|
+
* A referência completa de comandos é derivada, nunca escrita à mão: o registry é a fonte única e o
|
|
6
|
+
* check `commands-ref` do doctor compara o arquivo com o que este script produz. Rodar é idempotente.
|
|
7
|
+
*/
|
|
8
|
+
import fs from 'node:fs';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import { fileURLToPath } from 'node:url';
|
|
11
|
+
import { COMMANDS } from '../lib/core/registry.js';
|
|
12
|
+
import { renderCommandsDoc, skillsCount } from '../lib/docs-reference.js';
|
|
13
|
+
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
14
|
+
const TARGET = path.join(ROOT, 'docs/commands.md');
|
|
15
|
+
const skills = skillsCount(fs, path.join(ROOT, 'templates', 'project', 'skills'));
|
|
16
|
+
const doc = renderCommandsDoc(COMMANDS, skills);
|
|
17
|
+
fs.writeFileSync(TARGET, doc);
|
|
18
|
+
console.log(`docs/commands.md gerado: ${Object.keys(COMMANDS).length} comandos em ${new Set(Object.values(COMMANDS).map((c) => c.domain)).size} domínios, ${skills} skills.`);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Hook Stop / PreCompact — grava o checkpoint da sessão em memory/60-runs/sessions/ (SPEC-052, ADR-0091).
|
|
4
|
+
*
|
|
5
|
+
* stdin: `{ session_id, transcript_path, cwd, hook_event_name }` (Claude Code). Nunca derruba a
|
|
6
|
+
* sessão: qualquer falha sai com 0 e sem saída. Não escreve em stdout — no Stop, um JSON com
|
|
7
|
+
* `decision` bloquearia o fim do turno.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Hook Stop / PreCompact — grava o checkpoint da sessão em memory/60-runs/sessions/ (SPEC-052, ADR-0091).
|
|
4
|
+
*
|
|
5
|
+
* stdin: `{ session_id, transcript_path, cwd, hook_event_name }` (Claude Code). Nunca derruba a
|
|
6
|
+
* sessão: qualquer falha sai com 0 e sem saída. Não escreve em stdout — no Stop, um JSON com
|
|
7
|
+
* `decision` bloquearia o fim do turno.
|
|
8
|
+
*/
|
|
9
|
+
import fs from 'node:fs';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import { writeCheckpoint } from '../lib/session-memory.js';
|
|
12
|
+
try {
|
|
13
|
+
const input = process.stdin.isTTY ? {} : JSON.parse(fs.readFileSync(0, 'utf8') || '{}');
|
|
14
|
+
const root = path.resolve(process.env.CLAUDE_PROJECT_DIR || input.cwd || process.cwd());
|
|
15
|
+
if (typeof input.session_id === 'string' && typeof input.transcript_path === 'string' && fs.existsSync(input.transcript_path)) {
|
|
16
|
+
writeCheckpoint(root, input.transcript_path, input.session_id, String(input.hook_event_name || 'Stop'));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
catch { /* ADR-0091: o hook nunca derruba a sessão */ }
|
|
20
|
+
process.exit(0);
|
|
@@ -22,6 +22,7 @@ import { listSpecs } from '../lib/specs-index.js';
|
|
|
22
22
|
import { openHandoffs } from '../lib/handoffs-index.js';
|
|
23
23
|
import { getWorkspaceRoot, isInsideFrameworkRepo, currentProjectName } from '../lib/workspace.js';
|
|
24
24
|
import { pkgRoot } from '../lib/paths.js';
|
|
25
|
+
import { findCheckpoint, latestCheckpoint, summarizeCheckpoint } from '../lib/session-memory.js';
|
|
25
26
|
const __filename = fileURLToPath(import.meta.url);
|
|
26
27
|
const __dirname = path.dirname(__filename);
|
|
27
28
|
const frameworkRoot = pkgRoot;
|
|
@@ -31,6 +32,37 @@ const root = isInsideFrameworkRepo(cwd)
|
|
|
31
32
|
: (fs.existsSync(path.join(cwd, 'specs')) || fs.existsSync(path.join(cwd, 'package.json')))
|
|
32
33
|
? cwd
|
|
33
34
|
: getWorkspaceRoot();
|
|
35
|
+
/** stdin do Claude Code: `{ session_id, source: startup|resume|clear|compact }`. Ausente → {}. */
|
|
36
|
+
function hookInput() {
|
|
37
|
+
if (process.stdin.isTTY)
|
|
38
|
+
return {}; // rodado à mão no terminal: não espera stdin
|
|
39
|
+
try {
|
|
40
|
+
return JSON.parse(fs.readFileSync(0, 'utf8') || '{}');
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return {};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const CHECKPOINT_CAP = 3000;
|
|
47
|
+
/** SPEC-052: depois de compactar, o checkpoint da própria sessão; senão, onde a última parou. */
|
|
48
|
+
function sessionMemory(input) {
|
|
49
|
+
try {
|
|
50
|
+
if (input.source === 'compact' && input.session_id) {
|
|
51
|
+
const file = findCheckpoint(root, input.session_id);
|
|
52
|
+
if (!file)
|
|
53
|
+
return [];
|
|
54
|
+
const text = fs.readFileSync(file, 'utf8').replace(/<!--[\s\S]*?-->\n?/g, '').trim();
|
|
55
|
+
return ['', `Checkpoint desta sessão antes da compactação (${path.relative(root, file)}):`, text.slice(0, CHECKPOINT_CAP)];
|
|
56
|
+
}
|
|
57
|
+
if (input.source === 'clear')
|
|
58
|
+
return [];
|
|
59
|
+
const last = latestCheckpoint(root, input.session_id);
|
|
60
|
+
return last ? ['', `Última sessão: ${summarizeCheckpoint(last)} (${path.relative(root, last)})`] : [];
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
34
66
|
/**
|
|
35
67
|
* Nunca lança e nunca trava a sessão: o hook reporta, o `tools:doctor` é que é gate. Se a própria
|
|
36
68
|
* lib de health não carregar, seguimos com o resto do briefing em vez de abortar (ADR-0021).
|
|
@@ -44,6 +76,7 @@ async function coreHealth() {
|
|
|
44
76
|
}
|
|
45
77
|
}
|
|
46
78
|
(async function main() {
|
|
79
|
+
const input = hookInput();
|
|
47
80
|
const specs = listSpecs(root);
|
|
48
81
|
const health = await coreHealth();
|
|
49
82
|
const problemas = health.filter((c) => c.status === 'fail' || c.status === 'warn');
|
|
@@ -79,6 +112,7 @@ async function coreHealth() {
|
|
|
79
112
|
for (const h of handoffs)
|
|
80
113
|
lines.push(` - #${h.id} ${h.from} → ${h.to} (${h.intent}) ${h.slug || ''}`);
|
|
81
114
|
}
|
|
115
|
+
lines.push(...sessionMemory(input));
|
|
82
116
|
lines.push('\nFluxo SDD: `forja spec:new|spec:plan|spec:tasks|spec:check <slug>` · próximo passo: `forja next`');
|
|
83
117
|
lines.push('Handoff: `forja hermes:handoff \'<json ADR-0005>\'`');
|
|
84
118
|
lines.push('</framework-status>');
|
package/dist/scripts/llm-fit.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { spawnSync } from 'node:child_process';
|
|
5
|
+
import { resolveCommand, quoteCmdArg } from '../lib/exec.js';
|
|
5
6
|
import Database from 'better-sqlite3';
|
|
6
7
|
import { createHash, randomUUID } from 'node:crypto';
|
|
7
8
|
import { DEFAULT_LLM_PROFILES, buildLlmExecution, recommendProfile, runLlm, validateProfiles } from '../packages/llm/src/index.js';
|
|
@@ -16,6 +17,13 @@ import { normalizeClaudeResult } from '../lib/llm/claude-output.js';
|
|
|
16
17
|
import { LlmSessionStore, RESUME_PROVIDERS, validSessionId } from '../lib/llm/session.js';
|
|
17
18
|
import { normalizeGeminiResult, normalizeCursorResult } from '../lib/llm/json-output.js';
|
|
18
19
|
import { prepareValidation, validateLlmResponse } from '../lib/llm/validation.js';
|
|
20
|
+
function probeSync(bin, args) {
|
|
21
|
+
const resolved = resolveCommand(bin) ?? bin;
|
|
22
|
+
const isCmd = process.platform === 'win32' && /\.(cmd|bat)$/i.test(resolved);
|
|
23
|
+
return isCmd
|
|
24
|
+
? spawnSync(process.env.ComSpec ?? 'cmd.exe', ['/d', '/s', '/c', `""${resolved}" ${args.map(quoteCmdArg).join(' ')}"`], { encoding: 'utf8', timeout: 10_000, windowsVerbatimArguments: true })
|
|
25
|
+
: spawnSync(resolved, args, { encoding: 'utf8', timeout: 10_000 });
|
|
26
|
+
}
|
|
19
27
|
const profilePath = () => path.join(getWorkspaceContextDir(), 'llm-profiles.json');
|
|
20
28
|
function usage() {
|
|
21
29
|
console.error('Uso: forja llm:<doctor|profiles:init|probe|recommend|run|eval>');
|
|
@@ -70,7 +78,8 @@ function doctor(name) {
|
|
|
70
78
|
if (name && !configured[name])
|
|
71
79
|
throw new Error(`Perfil não encontrado: ${name}`);
|
|
72
80
|
const result = Object.entries(configured).filter(([profileName]) => name === undefined || profileName === name).map(([profileName, value]) => {
|
|
73
|
-
const
|
|
81
|
+
const prefix = value.commandArgs ?? [];
|
|
82
|
+
const probe = probeSync(value.command, [...prefix, '--version']);
|
|
74
83
|
const errorCode = probe.error?.code;
|
|
75
84
|
const model = `${value.provider}:${value.model}`;
|
|
76
85
|
const pricing = pricingInfo(model);
|
|
@@ -78,15 +87,15 @@ function doctor(name) {
|
|
|
78
87
|
let compatible = null;
|
|
79
88
|
let features;
|
|
80
89
|
if (available && value.provider === 'codex') {
|
|
81
|
-
const help =
|
|
90
|
+
const help = probeSync(value.command, [...prefix, 'exec', '--help']);
|
|
82
91
|
compatible = !help.error && help.status === 0 && ['--json', '--sandbox', '--config'].every((flag) => help.stdout.includes(flag));
|
|
83
|
-
const resumeHelp =
|
|
92
|
+
const resumeHelp = probeSync(value.command, [...prefix, 'exec', 'resume', '--help']);
|
|
84
93
|
features = { outputSchema: !help.error && help.status === 0 && help.stdout.includes('--output-schema'),
|
|
85
94
|
resume: !resumeHelp.error && resumeHelp.status === 0 && ['--json', '--config'].every((flag) => resumeHelp.stdout.includes(flag)) };
|
|
86
95
|
}
|
|
87
96
|
else if (available && value.provider === 'claude') {
|
|
88
97
|
// SPEC-050 — o `claude` CLI oferece --resume nativo; schema não (validação é local, Ajv).
|
|
89
|
-
const help =
|
|
98
|
+
const help = probeSync(value.command, [...prefix, '--help']);
|
|
90
99
|
const helpOk = !help.error && help.status === 0;
|
|
91
100
|
compatible = helpOk && ['--output-format', '--print'].every((flag) => help.stdout.includes(flag));
|
|
92
101
|
features = { resume: helpOk && help.stdout.includes('--resume'), outputSchema: false };
|
|
@@ -99,12 +108,12 @@ function doctor(name) {
|
|
|
99
108
|
copilot: ['--prompt', '--silent'],
|
|
100
109
|
};
|
|
101
110
|
if (available && compatible === null && HELP_FLAGS[value.provider]) {
|
|
102
|
-
const help =
|
|
111
|
+
const help = probeSync(value.command, [...prefix, '--help']);
|
|
103
112
|
compatible = !help.error && help.status === 0 && HELP_FLAGS[value.provider].every((flag) => help.stdout.includes(flag));
|
|
104
113
|
features = { resume: false, outputSchema: false };
|
|
105
114
|
}
|
|
106
115
|
else if (available && compatible === null && value.provider === 'opencode') {
|
|
107
|
-
const help =
|
|
116
|
+
const help = probeSync(value.command, [...prefix, 'run', '--help']);
|
|
108
117
|
compatible = !help.error && help.status === 0 && help.stdout.includes('--agent');
|
|
109
118
|
features = { resume: false, outputSchema: false };
|
|
110
119
|
}
|
package/dist/scripts/simulate.js
CHANGED
|
@@ -32,12 +32,24 @@ import { SqliteGraphStore, SqliteMigrationRunner } from '../packages/adapter-sql
|
|
|
32
32
|
import { buildRiskInput, changedFiles } from '../lib/core/risk-collect.js';
|
|
33
33
|
import { emitOk, emitError, emitRejected } from '../lib/cli-output.js';
|
|
34
34
|
const CONSTITUTION_PATH = '.context/architecture/constitution.json';
|
|
35
|
+
function rmWithRetry(target, attempts = 3) {
|
|
36
|
+
for (let i = 0; i < attempts; i++) {
|
|
37
|
+
try {
|
|
38
|
+
fs.rmSync(target, { recursive: true, force: true });
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
if (i === attempts - 1)
|
|
43
|
+
throw new Error(`rmWithRetry: falhou após ${attempts} tentativas: ${target}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
35
47
|
function repoRoot() {
|
|
36
48
|
return process.env.FORJA_GRAPH_ROOT ?? process.cwd();
|
|
37
49
|
}
|
|
38
50
|
/** Roda `buildRiskInput`/`checkConstitution` contra `worktreeRoot`, isolado do workspace real (D3). */
|
|
39
51
|
async function assessWorktree(worktreeRoot, paths) {
|
|
40
|
-
const tempBase = fs.mkdtempSync(path.join(os.tmpdir(), 'forja-simulate-db-'));
|
|
52
|
+
const tempBase = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'forja-simulate-db-')));
|
|
41
53
|
const database = new Database(path.join(tempBase, 'simulate.db'));
|
|
42
54
|
new SqliteMigrationRunner(database).apply();
|
|
43
55
|
const previousGraphRoot = process.env.FORJA_GRAPH_ROOT;
|
|
@@ -69,7 +81,7 @@ async function assessWorktree(worktreeRoot, paths) {
|
|
|
69
81
|
finally {
|
|
70
82
|
process.env.FORJA_GRAPH_ROOT = previousGraphRoot;
|
|
71
83
|
database.close();
|
|
72
|
-
|
|
84
|
+
rmWithRetry(tempBase);
|
|
73
85
|
}
|
|
74
86
|
}
|
|
75
87
|
function recommendationFor(testPassed, architectureCheck, risk) {
|
|
@@ -99,7 +111,7 @@ async function cmdSimulate(args) {
|
|
|
99
111
|
const runner = new SpawnCommandRunner();
|
|
100
112
|
const patchApplier = { apply: () => { throw new Error('simulate nunca promove — patchApplier.apply não deveria ser chamado'); }, revert: () => { } };
|
|
101
113
|
const sandbox = new SandboxEngine(new InMemorySandboxStore(), new GitWorktreeBackend(runner, { repositoryRoot: repoRoot(), sourceRef: ref, patchApplier }));
|
|
102
|
-
const tempBase = fs.mkdtempSync(path.join(os.tmpdir(), 'forja-simulate-'));
|
|
114
|
+
const tempBase = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'forja-simulate-')));
|
|
103
115
|
const worktreeRoot = path.join(tempBase, 'worktree');
|
|
104
116
|
const runId = randomUUID();
|
|
105
117
|
const session = await sandbox.create({ runId, root: worktreeRoot });
|
|
@@ -120,7 +132,7 @@ async function cmdSimulate(args) {
|
|
|
120
132
|
// órfão na árvore real — algo que vale saber, mesmo sem abortar a simulação por causa disso.
|
|
121
133
|
await sandbox.reject(session.id).catch((error) => { console.error(`simulate: aviso — reject do sandbox falhou: ${error instanceof Error ? error.message : String(error)}`); });
|
|
122
134
|
await sandbox.destroy(session.id).catch((error) => { console.error(`simulate: aviso — destroy do sandbox falhou: ${error instanceof Error ? error.message : String(error)}`); });
|
|
123
|
-
|
|
135
|
+
rmWithRetry(tempBase);
|
|
124
136
|
}
|
|
125
137
|
// Fora do try/finally: o cleanup do sandbox já rodou, então as saídas que terminam o processo
|
|
126
138
|
// (emit*) são seguras. `discard` = o gate do simulate dizendo "não promova" → rejected/exit 2
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* spec:trace — critérios de aceite × testes que os citam (SPEC-053, ADR-0092).
|
|
4
|
+
*
|
|
5
|
+
* forja spec:trace [slug] [--strict] [--json]
|
|
6
|
+
*
|
|
7
|
+
* Sem `--strict` só informa (exit 0). Com `--strict`, spec approved/implementing/done com critério
|
|
8
|
+
* sem teste ou citação órfã → exit 2 (`rejected`, ADR-0082).
|
|
9
|
+
*/
|
|
10
|
+
export {};
|