forjajs 4.1.2 → 5.0.0
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/.claude/settings.json +2 -2
- package/.gemini-instructions.md +1 -1
- package/.github/copilot-instructions.md +1 -1
- package/.openai-instructions.md +1 -1
- package/CHANGELOG.md +109 -0
- package/DOC-MAP.md +2 -2
- package/README.md +62 -10
- package/README.pt-BR.md +46 -7
- package/boilerplates/01-api-rest/README.md +1 -1
- package/boilerplates/06-clean-arch/README.md +5 -3
- package/boilerplates/06-clean-arch/backend/.oxlintrc.json +10 -0
- package/boilerplates/06-clean-arch/backend/nest-cli.json +8 -0
- package/boilerplates/06-clean-arch/backend/package.json +22 -24
- package/boilerplates/06-clean-arch/backend/src/app.module.ts +4 -4
- package/boilerplates/06-clean-arch/backend/src/main.ts +2 -2
- package/boilerplates/06-clean-arch/backend/src/modules/orders/application/place-order.usecase.ts +4 -4
- package/boilerplates/06-clean-arch/backend/src/modules/orders/application/ship-order.usecase.ts +2 -2
- package/boilerplates/06-clean-arch/backend/src/modules/orders/domain/order.entity.ts +3 -3
- package/boilerplates/06-clean-arch/backend/src/modules/orders/domain/order.repository.ts +1 -1
- package/boilerplates/06-clean-arch/backend/src/modules/orders/infrastructure/typeorm-order.repository.ts +5 -5
- package/boilerplates/06-clean-arch/backend/src/modules/orders/orders.module.ts +6 -6
- package/boilerplates/06-clean-arch/backend/src/modules/orders/presentation/orders.controller.ts +3 -3
- package/boilerplates/06-clean-arch/backend/src/modules/products/products.controller.ts +1 -1
- package/boilerplates/06-clean-arch/backend/src/modules/products/products.module.ts +2 -2
- package/boilerplates/06-clean-arch/backend/test/orders/place-order.spec.ts +2 -2
- package/boilerplates/06-clean-arch/backend/tsconfig.build.json +15 -0
- package/boilerplates/06-clean-arch/backend/tsconfig.json +24 -10
- package/boilerplates/06-clean-arch/backend/vitest.config.ts +11 -0
- package/boilerplates/06-clean-arch/boilerplate.manifest.json +6 -5
- package/boilerplates/README.md +24 -44
- package/dist/apps/cli/src/index.js +6 -6
- package/dist/apps/dashboard/next.config.d.mts +5 -5
- package/dist/apps/server/src/app.module.js +1 -1
- package/dist/apps/server/src/forja-nest.module.js +1 -1
- package/dist/apps/server/src/index.js +1 -1
- package/dist/apps/server/src/main.js +20 -20
- package/dist/apps/worker/src/main.js +4 -4
- package/dist/bin/create-memory-nest-kit.js +5 -5
- package/dist/bin/forja.js +28 -14
- package/dist/bin/init-project.d.ts +4 -9
- package/dist/bin/init-project.js +126 -182
- package/dist/lib/audit.js +1 -1
- package/dist/lib/context-builder.d.ts +6 -1
- package/dist/lib/context-builder.js +21 -12
- package/dist/lib/core/architecture-gate.js +2 -4
- package/dist/lib/core/checks.d.ts +1 -1
- package/dist/lib/core/drift-gate.js +2 -4
- package/dist/lib/core/gates.js +5 -5
- package/dist/lib/core/health.d.ts +0 -1
- package/dist/lib/core/health.js +33 -7
- package/dist/lib/core/journey.d.ts +30 -0
- package/dist/lib/core/journey.js +142 -0
- package/dist/lib/core/model-pricing.js +3 -5
- package/dist/lib/core/project-smoke.d.ts +6 -2
- package/dist/lib/core/project-smoke.js +60 -61
- package/dist/lib/core/registry.d.ts +1 -12
- package/dist/lib/core/registry.js +42 -32
- package/dist/lib/core/release.d.ts +1 -1
- package/dist/lib/core/release.js +31 -3
- package/dist/lib/core/risk-collect.js +4 -4
- package/dist/lib/drift-sentinel.js +1 -1
- package/dist/lib/generators/memory-generator.d.ts +30 -30
- package/dist/lib/generators/memory-generator.js +19 -8
- package/dist/lib/generators/nest-generator.js +192 -275
- package/dist/lib/generators/readme-generator.js +1 -1
- package/dist/lib/governance-report.js +4 -4
- package/dist/lib/handoffs-index.d.ts +16 -2
- package/dist/lib/handoffs-index.js +32 -5
- package/dist/lib/llm/session.js +1 -1
- package/dist/lib/llm/validation.js +1 -1
- package/dist/lib/memory-audit.js +1 -1
- package/dist/lib/paths.d.ts +39 -0
- package/dist/lib/paths.js +73 -0
- package/dist/lib/project-wiring.d.ts +54 -0
- package/dist/lib/project-wiring.js +391 -0
- package/dist/lib/status-model.js +18 -7
- package/dist/lib/templates.d.ts +24 -0
- package/dist/lib/templates.js +77 -0
- package/dist/lib/validators/structure-validator.js +0 -1
- package/dist/lib/workspace.d.ts +7 -0
- package/dist/lib/workspace.js +20 -2
- package/dist/packages/adapter-git/src/index.js +2 -2
- package/dist/packages/context/src/index.js +1 -1
- package/dist/packages/core/src/index.js +1 -1
- package/dist/packages/evals/src/index.js +1 -1
- package/dist/packages/events/src/index.js +1 -1
- package/dist/packages/graph/src/index.js +1 -1
- package/dist/packages/mcp/src/index.d.ts +1 -1
- package/dist/packages/observability/src/index.js +1 -1
- package/dist/packages/orchestration/src/index.js +1 -1
- package/dist/packages/planner/src/index.js +1 -1
- package/dist/packages/policy/src/index.js +1 -1
- package/dist/packages/runtime/src/index.js +1 -1
- package/dist/packages/sandbox/src/index.js +1 -1
- package/dist/packages/validator/src/index.js +1 -1
- package/dist/scripts/adr.js +4 -4
- package/dist/scripts/agent-harness.js +30 -23
- package/dist/scripts/agent-router.js +22 -5
- package/dist/scripts/agent.js +5 -5
- package/dist/scripts/architecture.js +6 -6
- package/dist/scripts/audit-query.js +1 -1
- package/dist/scripts/audit-sync.js +1 -1
- package/dist/scripts/build-smart-context.d.ts +19 -1
- package/dist/scripts/build-smart-context.js +84 -68
- package/dist/scripts/check-standards.js +8 -3
- package/dist/scripts/code-context.js +1 -1
- package/dist/scripts/compress-memory.js +3 -2
- package/dist/scripts/compress-project-memory.js +2 -2
- package/dist/scripts/context-ops.js +13 -5
- package/dist/scripts/cost-economy.js +4 -4
- package/dist/scripts/demo-autonomy.js +11 -11
- package/dist/scripts/demo-workspace.js +12 -4
- package/dist/scripts/dev.js +8 -7
- package/dist/scripts/drift-check.js +5 -5
- package/dist/scripts/engineer.js +11 -11
- package/dist/scripts/evidence.js +4 -4
- package/dist/scripts/extract-global-knowledge.js +6 -4
- package/dist/scripts/forja-setup.js +2 -1
- package/dist/scripts/forja-status.js +5 -4
- package/dist/scripts/gates.js +1 -1
- package/dist/scripts/generate-dashboard.js +6 -4
- package/dist/scripts/governance-dashboard.js +2 -2
- package/dist/scripts/hook-session-start.js +11 -10
- package/dist/scripts/hook-user-prompt.js +3 -2
- package/dist/scripts/incident.js +4 -4
- package/dist/scripts/llm-fit.js +11 -11
- package/dist/scripts/memory-audit.js +1 -1
- package/dist/scripts/memory-schema.js +3 -2
- package/dist/scripts/orchestrate.js +4 -5
- package/dist/scripts/project-smoke.js +13 -2
- package/dist/scripts/project-templates.d.ts +1 -0
- package/dist/scripts/project-templates.js +20 -0
- package/dist/scripts/project-upgrade.d.ts +13 -0
- package/dist/scripts/project-upgrade.js +107 -40
- package/dist/scripts/project-wire.d.ts +8 -0
- package/dist/scripts/project-wire.js +55 -0
- package/dist/scripts/provenance.js +3 -3
- package/dist/scripts/query-universal-memory.js +7 -4
- package/dist/scripts/release-check.js +1 -1
- package/dist/scripts/risk.js +4 -4
- package/dist/scripts/simulate.js +9 -9
- package/dist/scripts/spec-cli.d.ts +1 -0
- package/dist/scripts/spec-cli.js +25 -5
- package/dist/scripts/sprint-manager.js +4 -3
- package/dist/scripts/sync-universal-memory.js +22 -15
- package/dist/scripts/token-benchmark.js +4 -3
- package/dist/scripts/token-economy.js +4 -3
- package/dist/scripts/tools-doctor.d.ts +1 -1
- package/dist/scripts/tools-doctor.js +25 -3
- package/docs/GUIA-ONBOARDING-EXECUTIVO.md +1 -2
- package/docs/GUIA-ONBOARDING-OPERACIONAL-PAPEIS.md +5 -6
- package/docs/GUIA-ONBOARDING-PROJETO.md +7 -9
- package/docs/glossary.md +4 -4
- package/docs/init-project.md +88 -444
- package/docs/manual-operacional-cli-sdd-gsd.md +1 -1
- package/docs/modos-de-operacao.md +1 -1
- package/docs/processo-projeto.md +14 -11
- package/docs/produto/roteiro-demo.md +15 -18
- package/docs/publishing.md +5 -0
- package/docs/quick-reference.md +15 -23
- package/docs/structure.md +16 -30
- package/lib/core/model-pricing.json +19 -0
- package/memory/30-projects/README.md +1 -1
- package/memory/90-decisions/0022-congelar-dashboard-web.md +1 -1
- package/memory/90-decisions/0086-projeto-conectado-e-jornada-como-gate.md +95 -0
- package/memory/90-decisions/0087-remover-dashboard-legado.md +35 -0
- package/memory/90-decisions/0088-templates-validados.md +55 -0
- package/package.json +25 -25
- package/templates/project/AGENTS.md +75 -0
- package/templates/project/CLAUDE.md +9 -0
- package/templates/project/agents/context-engineer.md +15 -0
- package/templates/project/agents/governance.md +15 -0
- package/templates/project/agents/marketing.md +15 -0
- package/templates/project/agents/orchestrator.md +15 -0
- package/templates/project/agents/product.md +15 -0
- package/templates/project/agents/sdd-architect.md +15 -0
- package/dist/lib/multi-ai-instructions.d.ts +0 -28
- package/dist/lib/multi-ai-instructions.js +0 -83
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { resolveProject, initWorkspace } from
|
|
4
|
+
import { resolveProject, initWorkspace } from '../lib/workspace.js';
|
|
5
5
|
const __filename = fileURLToPath(import.meta.url);
|
|
6
6
|
const __dirname = path.dirname(__filename);
|
|
7
7
|
const [project] = process.argv.slice(2);
|
|
8
8
|
if (!project) {
|
|
9
|
-
console.log('Uso:
|
|
9
|
+
console.log('Uso: forja memory:compress <projeto>');
|
|
10
10
|
process.exit(0);
|
|
11
11
|
}
|
|
12
12
|
initWorkspace();
|
|
@@ -3,13 +3,15 @@ import fs from 'node:fs';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import Database from 'better-sqlite3';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
|
-
import { ensureSchema, getDbPath } from
|
|
6
|
+
import { ensureSchema, getDbPath } from './memory-schema.js';
|
|
7
|
+
import { pkgRoot } from '../lib/paths.js';
|
|
8
|
+
import { isInsideFrameworkRepo } from '../lib/workspace.js';
|
|
7
9
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
10
|
// `root` = recursos do FRAMEWORK (catalog: boilerplates/, design-md/) — resolvidos por __dirname.
|
|
9
11
|
// `projectRoot` = o PROJETO do usuário (.context/, specs/, memory/, .memoryrc.json) — onde foi invocado.
|
|
10
12
|
// Cravar `root` para as superfícies do projeto auditava/gravava no PACOTE no consumidor (classe de bug
|
|
11
13
|
// spec-cli v1.6.2 / check-standards v1.7.1). No repo do framework os dois coincidem (cwd = raiz).
|
|
12
|
-
const root =
|
|
14
|
+
const root = pkgRoot;
|
|
13
15
|
const projectRoot = process.cwd();
|
|
14
16
|
const outDir = path.join(projectRoot, '.context');
|
|
15
17
|
const defaultLimit = readTokenLimit();
|
|
@@ -143,7 +145,7 @@ function latestAdrs() {
|
|
|
143
145
|
}
|
|
144
146
|
function cmdBudget([target, limitArg]) {
|
|
145
147
|
if (!target) {
|
|
146
|
-
console.error('Uso: context
|
|
148
|
+
console.error('Uso: forja context:budget <slug|arquivo> [limite_tokens]');
|
|
147
149
|
process.exit(1);
|
|
148
150
|
}
|
|
149
151
|
const limit = Number(limitArg) || defaultLimit;
|
|
@@ -198,7 +200,7 @@ function cmdSprintPack() {
|
|
|
198
200
|
}
|
|
199
201
|
function cmdAgentBrief([role, slug]) {
|
|
200
202
|
if (!role || !slug) {
|
|
201
|
-
console.error('Uso:
|
|
203
|
+
console.error('Uso: forja agent:brief <role> <slug>');
|
|
202
204
|
process.exit(1);
|
|
203
205
|
}
|
|
204
206
|
ensureOutDir();
|
|
@@ -329,6 +331,11 @@ function readJsonIfExists(relPath) {
|
|
|
329
331
|
}
|
|
330
332
|
}
|
|
331
333
|
function cmdGenerateManifests() {
|
|
334
|
+
// Manutenção do catálogo do PRÓPRIO framework: fora do repo, escreveria dentro do pacote instalado.
|
|
335
|
+
if (!isInsideFrameworkRepo(process.cwd())) {
|
|
336
|
+
console.error('catalog:manifests regenera os manifests do framework — rode no repositório do Forja.');
|
|
337
|
+
process.exit(1);
|
|
338
|
+
}
|
|
332
339
|
let written = 0;
|
|
333
340
|
const boilerRoot = path.join(root, 'boilerplates');
|
|
334
341
|
if (fs.existsSync(boilerRoot)) {
|
|
@@ -434,7 +441,8 @@ function cmdAssetCatalog() {
|
|
|
434
441
|
console.log(`Asset catalog gerado: ${path.relative(root, outFile)} (${assets.length} assets)`);
|
|
435
442
|
}
|
|
436
443
|
function help() {
|
|
437
|
-
console.log(`
|
|
444
|
+
console.log(`Script interno do Forja — use os comandos via core: forja help --all
|
|
445
|
+
|
|
438
446
|
|
|
439
447
|
Comandos:
|
|
440
448
|
budget <slug|arquivo> [limite] Mede tokens e falha se passar do limite
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import fs from 'node:fs';
|
|
20
20
|
import Database from 'better-sqlite3';
|
|
21
|
-
import { SqliteMigrationRunner, SqliteObservationStore } from
|
|
22
|
-
import { getWorkspaceDbDir, getWorkspaceDbPath, getWorkspaceInfo } from
|
|
23
|
-
import { loadPricingTable, lookupPrice } from
|
|
24
|
-
import { emitOk } from
|
|
21
|
+
import { SqliteMigrationRunner, SqliteObservationStore } from '../packages/adapter-sqlite/src/index.js';
|
|
22
|
+
import { getWorkspaceDbDir, getWorkspaceDbPath, getWorkspaceInfo } from '../lib/workspace.js';
|
|
23
|
+
import { loadPricingTable, lookupPrice } from '../lib/core/model-pricing.js';
|
|
24
|
+
import { emitOk } from '../lib/cli-output.js';
|
|
25
25
|
function main() {
|
|
26
26
|
const json = process.argv.includes('--json');
|
|
27
27
|
const info = getWorkspaceInfo();
|
|
@@ -4,17 +4,17 @@ import path from 'node:path';
|
|
|
4
4
|
import { randomUUID } from 'node:crypto';
|
|
5
5
|
import { spawnSync } from 'node:child_process';
|
|
6
6
|
import Database from 'better-sqlite3';
|
|
7
|
-
import { CapabilityRegistry } from
|
|
8
|
-
import { ContextEngine, GraphContextSource } from
|
|
9
|
-
import { SqliteApprovalStore, SqliteAuditStore, SqliteCheckpointStore, SqliteContextCache, SqliteEventStore, SqliteGraphStore, SqliteMigrationRunner, SqliteOrchestrationStore, SqliteSandboxStore, SqliteRuntimePersistence } from
|
|
10
|
-
import { GitGraphDocumentSource, GitWorktreeBackend, SpawnCommandRunner } from
|
|
11
|
-
import { GraphExecutionMemory, GraphIndexer, GraphLoop } from
|
|
12
|
-
import { EventBus } from
|
|
13
|
-
import { ApprovalLedger, PolicyEngine } from
|
|
14
|
-
import { RuntimeEngine } from
|
|
15
|
-
import { SandboxEngine } from
|
|
16
|
-
import { SprintEngine, TaskEngine, HandoffEngine } from
|
|
17
|
-
import { DeterministicValidator } from
|
|
7
|
+
import { CapabilityRegistry } from '../packages/core/src/index.js';
|
|
8
|
+
import { ContextEngine, GraphContextSource } from '../packages/context/src/index.js';
|
|
9
|
+
import { SqliteApprovalStore, SqliteAuditStore, SqliteCheckpointStore, SqliteContextCache, SqliteEventStore, SqliteGraphStore, SqliteMigrationRunner, SqliteOrchestrationStore, SqliteSandboxStore, SqliteRuntimePersistence } from '../packages/adapter-sqlite/src/index.js';
|
|
10
|
+
import { GitGraphDocumentSource, GitWorktreeBackend, SpawnCommandRunner } from '../packages/adapter-git/src/index.js';
|
|
11
|
+
import { GraphExecutionMemory, GraphIndexer, GraphLoop } from '../packages/graph/src/index.js';
|
|
12
|
+
import { EventBus } from '../packages/events/src/index.js';
|
|
13
|
+
import { ApprovalLedger, PolicyEngine } from '../packages/policy/src/index.js';
|
|
14
|
+
import { RuntimeEngine } from '../packages/runtime/src/index.js';
|
|
15
|
+
import { SandboxEngine } from '../packages/sandbox/src/index.js';
|
|
16
|
+
import { SprintEngine, TaskEngine, HandoffEngine } from '../packages/orchestration/src/index.js';
|
|
17
|
+
import { DeterministicValidator } from '../packages/validator/src/index.js';
|
|
18
18
|
const now = () => new Date().toISOString();
|
|
19
19
|
const budget = { inputTokens: 600, outputTokens: 300, totalTokens: 900, usedTokens: 0 };
|
|
20
20
|
function command(executable, args, cwd, input) {
|
|
@@ -4,9 +4,12 @@ import os from 'node:os';
|
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import Database from 'better-sqlite3';
|
|
6
6
|
import { randomUUID } from 'node:crypto';
|
|
7
|
-
import { initWorkspace, getWorkspaceContextDir, getWorkspaceDbPath, getWorkspaceRoot } from
|
|
8
|
-
import { SqliteMigrationRunner, SqliteObservationStore } from
|
|
9
|
-
import { ObservabilityRecorder } from
|
|
7
|
+
import { initWorkspace, getWorkspaceContextDir, getWorkspaceDbPath, getWorkspaceRoot } from '../lib/workspace.js';
|
|
8
|
+
import { SqliteMigrationRunner, SqliteObservationStore } from '../packages/adapter-sqlite/src/index.js';
|
|
9
|
+
import { ObservabilityRecorder } from '../packages/observability/src/index.js';
|
|
10
|
+
import { execFileSync } from 'node:child_process';
|
|
11
|
+
import { wireProject } from '../lib/project-wiring.js';
|
|
12
|
+
import { script } from '../lib/paths.js';
|
|
10
13
|
const PROJECT = 'atlas-pay';
|
|
11
14
|
const SENTINEL = 'forja-demo.json';
|
|
12
15
|
function usage() {
|
|
@@ -40,6 +43,7 @@ function createFiles(root) {
|
|
|
40
43
|
write(path.join(project, 'docs', 'project-brief.md'), '# Briefing: Atlas Pay\n\nDemonstração de uma camada de aprovação para pagamentos empresariais.\n');
|
|
41
44
|
write(path.join(project, 'memory', '20-architecture', 'stack.md'), '# Stack\n\n- API NestJS\n- SQLite local\n- Integração de pagamento simulada\n');
|
|
42
45
|
write(path.join(project, 'memory', '20-architecture', 'design-brief.md'), '# Design brief\n\nDashboard operacional para aprovar pagamentos e revisar evidências.\n');
|
|
46
|
+
write(path.join(project, 'memory', '30-domains', 'pagamentos.md'), '# Domínio: pagamentos\n\nPagamentos via Pix e TED. Acima de R$ 50 mil, o pagamento exige aprovação explícita de um segundo operador antes da promoção.\n');
|
|
43
47
|
write(path.join(project, 'memory', '40-delivery', 'current-sprint.md'), '# Sprint de demonstração\n\nObjetivo: aprovar pagamentos de alto valor com evidência e revisão.\n');
|
|
44
48
|
write(path.join(root, 'specs', PROJECT, 'spec.md'), '# Spec: atlas-pay\n\n- **Status**: approved\n\n## Problema\nPagamentos empresariais de alto valor precisam de aprovação explícita.\n\n## Critérios de aceite\n- [x] Aprovação registrada antes da promoção.\n- [x] Auditoria consulta os handoffs da entrega.\n');
|
|
45
49
|
write(path.join(root, 'specs', PROJECT, 'plan.md'), '# Plan: atlas-pay\n\n- **Status**: approved\n\nImplementar política de aprovação e trilha de auditoria.\n');
|
|
@@ -88,13 +92,17 @@ export async function createDemoWorkspace(args = process.argv.slice(2)) {
|
|
|
88
92
|
throw new Error(`Recusado: ${root} não é um workspace demo. Escolha --path para um diretório vazio.`);
|
|
89
93
|
initWorkspace();
|
|
90
94
|
createFiles(getWorkspaceRoot());
|
|
95
|
+
// O projeto demo é um projeto Forja de verdade: conectado à IA e com a memória indexada.
|
|
96
|
+
const project = path.join(getWorkspaceRoot(), 'projects', PROJECT);
|
|
97
|
+
wireProject(project, { ai: ['claude', 'codex'], codegraph: false });
|
|
91
98
|
await createDatabase();
|
|
99
|
+
execFileSync(process.execPath, [script('scripts/sync-universal-memory')], { env: { ...process.env, FORJA_WORKSPACE: root }, stdio: 'pipe' });
|
|
92
100
|
const result = { workspace: getWorkspaceRoot(), project: PROJECT, handoffs: 3, observations: 3 };
|
|
93
101
|
write(sentinel, `${JSON.stringify({ ...result, generatedAt: new Date().toISOString(), warning: 'Dados sintéticos para demonstração. Não use em produção.' }, null, 2)}\n`);
|
|
94
102
|
if (json)
|
|
95
103
|
console.log(JSON.stringify(result));
|
|
96
104
|
else
|
|
97
|
-
console.log(`Demo pronta em ${result.workspace}\nProjeto: ${PROJECT}\nHandoffs: 3 (2 concluídos, 1 em review)\nPróximo
|
|
105
|
+
console.log(`Demo pronta em ${result.workspace}\nProjeto: ${PROJECT}\nHandoffs: 3 (2 concluídos, 1 em review)\n\nPróximo (o demo é um workspace à parte):\n export FORJA_WORKSPACE="${result.workspace}"\n cd "${project}" && forja status`);
|
|
98
106
|
return result;
|
|
99
107
|
}
|
|
100
108
|
if (process.argv[1]?.endsWith('demo-workspace.ts'))
|
package/dist/scripts/dev.js
CHANGED
|
@@ -16,10 +16,11 @@ import fs from 'node:fs';
|
|
|
16
16
|
import path from 'node:path';
|
|
17
17
|
import { spawn } from 'node:child_process';
|
|
18
18
|
import { fileURLToPath } from 'node:url';
|
|
19
|
-
import { getDbPath, ensureSchema } from
|
|
19
|
+
import { getDbPath, ensureSchema } from './memory-schema.js';
|
|
20
|
+
import { pkgRoot, script } from '../lib/paths.js';
|
|
20
21
|
const __filename = fileURLToPath(import.meta.url);
|
|
21
22
|
const __dirname = path.dirname(__filename);
|
|
22
|
-
const root =
|
|
23
|
+
const root = pkgRoot;
|
|
23
24
|
const COMMANDS = {
|
|
24
25
|
'context:build': {
|
|
25
26
|
desc: 'Gerar contexto inteligente (global|domain|task)',
|
|
@@ -129,7 +130,7 @@ function runScript(scriptPath, args = []) {
|
|
|
129
130
|
}
|
|
130
131
|
function harnessCommand(command) {
|
|
131
132
|
return async function runHarness(args = []) {
|
|
132
|
-
await runScript(
|
|
133
|
+
await runScript(script('scripts/agent-harness'), [command, ...args]);
|
|
133
134
|
};
|
|
134
135
|
}
|
|
135
136
|
/**
|
|
@@ -143,7 +144,7 @@ async function contextBuild([mode, project, keyword] = []) {
|
|
|
143
144
|
console.log(`Building ${mode} context for ${project}...`);
|
|
144
145
|
try {
|
|
145
146
|
ensureSchema({ silent: true });
|
|
146
|
-
const builder = (await import(
|
|
147
|
+
const builder = (await import('../lib/context-builder.js')).default;
|
|
147
148
|
const dbPath = getDbPath();
|
|
148
149
|
const ctx = new builder(root, dbPath);
|
|
149
150
|
ctx.connect();
|
|
@@ -169,7 +170,7 @@ async function contextBuild([mode, project, keyword] = []) {
|
|
|
169
170
|
async function memoryVacuum() {
|
|
170
171
|
console.log('Running memory vacuum...');
|
|
171
172
|
try {
|
|
172
|
-
await runScript(
|
|
173
|
+
await runScript(script('scripts/compress-memory'));
|
|
173
174
|
console.log('Memory vacuum complete');
|
|
174
175
|
}
|
|
175
176
|
catch (e) {
|
|
@@ -234,7 +235,7 @@ async function projectHealth() {
|
|
|
234
235
|
}
|
|
235
236
|
// 3. Check key files
|
|
236
237
|
console.log('\nChecking key files...');
|
|
237
|
-
const keyFiles = ['bin/create-memory-nest-kit.
|
|
238
|
+
const keyFiles = ['bin/create-memory-nest-kit.ts', 'lib/context-builder.ts'];
|
|
238
239
|
for (const file of keyFiles) {
|
|
239
240
|
const exists = fs.existsSync(path.join(root, file));
|
|
240
241
|
const status = exists ? 'OK ' : 'FAIL';
|
|
@@ -269,7 +270,7 @@ async function projectInit([projectName, ...flags] = []) {
|
|
|
269
270
|
}
|
|
270
271
|
console.log(`Initializing project: ${projectName}...\n`);
|
|
271
272
|
try {
|
|
272
|
-
await runScript(
|
|
273
|
+
await runScript(script('bin/create-memory-nest-kit'), [
|
|
273
274
|
projectName,
|
|
274
275
|
...flags,
|
|
275
276
|
]);
|
|
@@ -21,11 +21,11 @@ import path from 'node:path';
|
|
|
21
21
|
import { spawnSync } from 'node:child_process';
|
|
22
22
|
import { fileURLToPath } from 'node:url';
|
|
23
23
|
import Database from 'better-sqlite3';
|
|
24
|
-
import { checkDrift } from
|
|
25
|
-
import { GitGraphDocumentSource, SpawnCommandRunner } from
|
|
26
|
-
import { GraphLoop } from
|
|
27
|
-
import { SqliteGraphStore, SqliteMigrationRunner } from
|
|
28
|
-
import { getWorkspaceDbDir, getWorkspaceDbPath, getProjectsDir, listProjects } from
|
|
24
|
+
import { checkDrift } from '../lib/drift-sentinel.js';
|
|
25
|
+
import { GitGraphDocumentSource, SpawnCommandRunner } from '../packages/adapter-git/src/index.js';
|
|
26
|
+
import { GraphLoop } from '../packages/graph/src/index.js';
|
|
27
|
+
import { SqliteGraphStore, SqliteMigrationRunner } from '../packages/adapter-sqlite/src/index.js';
|
|
28
|
+
import { getWorkspaceDbDir, getWorkspaceDbPath, getProjectsDir, listProjects } from '../lib/workspace.js';
|
|
29
29
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
30
30
|
function arg(name) {
|
|
31
31
|
const i = process.argv.indexOf(name);
|
package/dist/scripts/engineer.js
CHANGED
|
@@ -21,17 +21,17 @@ import fs from 'node:fs';
|
|
|
21
21
|
import path from 'node:path';
|
|
22
22
|
import { randomUUID } from 'node:crypto';
|
|
23
23
|
import Database from 'better-sqlite3';
|
|
24
|
-
import { ContextEngine, GraphContextSource } from
|
|
25
|
-
import { checkConstitution } from
|
|
26
|
-
import { assessRisk } from
|
|
27
|
-
import { recommendAgent } from
|
|
28
|
-
import { GitGraphDocumentSource, SpawnCommandRunner } from
|
|
29
|
-
import { GraphIndexer, GraphLoop } from
|
|
30
|
-
import { SqliteAgentProfileStore, SqliteGraphStore, SqliteMigrationRunner } from
|
|
31
|
-
import { getWorkspaceDbDir, getWorkspaceDbPath } from
|
|
32
|
-
import { buildRiskInput, changedFiles, graphRoot } from
|
|
33
|
-
import { incidentRecords, rankIncidentsByQuery, titleOf } from
|
|
34
|
-
import { emitOk, emitError } from
|
|
24
|
+
import { ContextEngine, GraphContextSource } from '../packages/context/src/index.js';
|
|
25
|
+
import { checkConstitution } from '../packages/engineering/architecture/src/index.js';
|
|
26
|
+
import { assessRisk } from '../packages/engineering/risk/src/index.js';
|
|
27
|
+
import { recommendAgent } from '../packages/engineering/identity/src/index.js';
|
|
28
|
+
import { GitGraphDocumentSource, SpawnCommandRunner } from '../packages/adapter-git/src/index.js';
|
|
29
|
+
import { GraphIndexer, GraphLoop } from '../packages/graph/src/index.js';
|
|
30
|
+
import { SqliteAgentProfileStore, SqliteGraphStore, SqliteMigrationRunner } from '../packages/adapter-sqlite/src/index.js';
|
|
31
|
+
import { getWorkspaceDbDir, getWorkspaceDbPath } from '../lib/workspace.js';
|
|
32
|
+
import { buildRiskInput, changedFiles, graphRoot } from '../lib/core/risk-collect.js';
|
|
33
|
+
import { incidentRecords, rankIncidentsByQuery, titleOf } from '../lib/core/incident-search.js';
|
|
34
|
+
import { emitOk, emitError } from '../lib/cli-output.js';
|
|
35
35
|
const CONSTITUTION_PATH = '.context/architecture/constitution.json';
|
|
36
36
|
const FLUXO_PATH = 'docs/fluxo.md';
|
|
37
37
|
/** Parseia a tabela "Etapa → papel → comando → capacidade" de docs/fluxo.md — D2 do plan: uma fonte de verdade, não copiada aqui. */
|
package/dist/scripts/evidence.js
CHANGED
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import fs from 'node:fs';
|
|
13
13
|
import Database from 'better-sqlite3';
|
|
14
|
-
import { buildEvidenceLedger } from
|
|
15
|
-
import { ApprovalLedger } from
|
|
16
|
-
import { SqliteApprovalStore, SqliteAuditStore, SqliteMigrationRunner, SqliteRuntimeRunStore } from
|
|
17
|
-
import { getWorkspaceDbDir, getWorkspaceDbPath } from
|
|
14
|
+
import { buildEvidenceLedger } from '../packages/engineering/evidence/src/index.js';
|
|
15
|
+
import { ApprovalLedger } from '../packages/policy/src/index.js';
|
|
16
|
+
import { SqliteApprovalStore, SqliteAuditStore, SqliteMigrationRunner, SqliteRuntimeRunStore } from '../packages/adapter-sqlite/src/index.js';
|
|
17
|
+
import { getWorkspaceDbDir, getWorkspaceDbPath } from '../lib/workspace.js';
|
|
18
18
|
function cmdShow([runId]) {
|
|
19
19
|
if (!runId) {
|
|
20
20
|
console.error('Uso: forja evidence:show <run-id>');
|
|
@@ -2,10 +2,10 @@ import fs from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import Database from 'better-sqlite3';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { getDbPath, ensureSchema } from
|
|
5
|
+
import { getDbPath, ensureSchema } from './memory-schema.js';
|
|
6
|
+
import { getWorkspaceMemoryDir } from '../lib/workspace.js';
|
|
6
7
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
8
|
const __dirname = path.dirname(__filename);
|
|
8
|
-
const root = path.resolve(__dirname, '..');
|
|
9
9
|
ensureSchema({ silent: true });
|
|
10
10
|
const dbPath = getDbPath();
|
|
11
11
|
function extractGlobalLessons() {
|
|
@@ -24,13 +24,15 @@ function extractGlobalLessons() {
|
|
|
24
24
|
knowledgeBase += `### [Proveniente de: ${adr.project}] ${adr.title}\n\n`;
|
|
25
25
|
// Pega apenas o resumo ou contexto da decisão
|
|
26
26
|
const contextMatch = adr.content.match(/## Contexto\n([\s\S]*?)(?=##|$)/);
|
|
27
|
-
const decisionMatch = adr.content.match(/##
|
|
27
|
+
const decisionMatch = adr.content.match(/## Decis[aã]o\n([\s\S]*?)(?=##|$)/);
|
|
28
28
|
if (contextMatch && decisionMatch) {
|
|
29
29
|
knowledgeBase += `**Contexto:** ${contextMatch[1].trim().slice(0, 300)}...\n\n`;
|
|
30
30
|
knowledgeBase += `**Padrao Adotado:** ${decisionMatch[1].trim()}\n\n`;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
// Memória do workspace (ou do projeto, no embedded) — gravar em pkgRoot sujava o pacote do Forja.
|
|
34
|
+
const outFile = path.join(getWorkspaceMemoryDir(), '00-global', 'shared-knowledge.md');
|
|
35
|
+
fs.mkdirSync(path.dirname(outFile), { recursive: true });
|
|
34
36
|
fs.writeFileSync(outFile, knowledgeBase, 'utf8');
|
|
35
37
|
console.log(`✅ Base de conhecimento global atualizada em: ${outFile}`);
|
|
36
38
|
db.close();
|
|
@@ -15,8 +15,9 @@ import { spawnSync } from 'node:child_process';
|
|
|
15
15
|
import path from 'node:path';
|
|
16
16
|
import readline from 'node:readline';
|
|
17
17
|
import { fileURLToPath } from 'node:url';
|
|
18
|
+
import { script } from '../lib/paths.js';
|
|
18
19
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
19
|
-
const forjaBin =
|
|
20
|
+
const forjaBin = script('bin/forja');
|
|
20
21
|
// Allowlist fixa. Não ler de config, não aceitar via argv. Ordem importa: o índice precede a busca.
|
|
21
22
|
const STEPS = ['workspace:init', 'sync:universal'];
|
|
22
23
|
function ask(question) {
|
|
@@ -11,11 +11,12 @@
|
|
|
11
11
|
import fs from 'node:fs';
|
|
12
12
|
import path from 'node:path';
|
|
13
13
|
import { fileURLToPath } from 'node:url';
|
|
14
|
-
import { collectStatus, recommendNext } from
|
|
15
|
-
import { emitOk } from
|
|
16
|
-
import { getWorkspaceRoot, isInsideFrameworkRepo, resolveProject } from
|
|
14
|
+
import { collectStatus, recommendNext } from '../lib/status-model.js';
|
|
15
|
+
import { emitOk } from '../lib/cli-output.js';
|
|
16
|
+
import { getWorkspaceRoot, isInsideFrameworkRepo, resolveProject } from '../lib/workspace.js';
|
|
17
|
+
import { pkgRoot } from '../lib/paths.js';
|
|
17
18
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
18
|
-
const frameworkRoot =
|
|
19
|
+
const frameworkRoot = pkgRoot;
|
|
19
20
|
export function resolveRepoRoot(targetArg) {
|
|
20
21
|
if (targetArg && targetArg !== '.' && targetArg !== 'root' && !targetArg.startsWith('-')) {
|
|
21
22
|
try {
|
package/dist/scripts/gates.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* Não substitui os gates focados — os agrega. "A casa está coerente?" num comando só.
|
|
13
13
|
*/
|
|
14
|
-
import { runGates, overallStatus } from
|
|
14
|
+
import { runGates, overallStatus } from '../lib/core/gates.js';
|
|
15
15
|
const TAG = { ok: 'OK ', warn: 'AVISO', fail: 'FALHA', skipped: '— ' };
|
|
16
16
|
async function main() {
|
|
17
17
|
const full = process.argv.includes('--full');
|
|
@@ -2,10 +2,12 @@ import fs from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import Database from 'better-sqlite3';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { getDbPath, ensureSchema } from
|
|
5
|
+
import { getDbPath, ensureSchema } from './memory-schema.js';
|
|
6
|
+
import { getWorkspaceRoot } from '../lib/workspace.js';
|
|
6
7
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
8
|
const __dirname = path.dirname(__filename);
|
|
8
|
-
|
|
9
|
+
// Destino = workspace (studio) ou o próprio projeto (embedded) — nunca o pacote do Forja.
|
|
10
|
+
const root = getWorkspaceRoot();
|
|
9
11
|
ensureSchema({ silent: true });
|
|
10
12
|
const dbPath = getDbPath();
|
|
11
13
|
function generate() {
|
|
@@ -26,7 +28,7 @@ function generate() {
|
|
|
26
28
|
FROM memory_nodes
|
|
27
29
|
WHERE project_id = ?
|
|
28
30
|
`).get(p.id);
|
|
29
|
-
md += `| **${p.name}** | ${stats.adrs} | ${stats.summaries} | ${stats.total} | ${stats.last_update.split('T')[0]} |\n`;
|
|
31
|
+
md += `| **${p.name}** | ${stats.adrs} | ${stats.summaries} | ${stats.total} | ${stats.last_update ? String(stats.last_update).split('T')[0] : '—'} |\n`;
|
|
30
32
|
}
|
|
31
33
|
md += `\n## 🧠 Lições Globais Recentes\n\n`;
|
|
32
34
|
const recentLessons = db.prepare(`
|
|
@@ -37,7 +39,7 @@ function generate() {
|
|
|
37
39
|
md += `- [Clique aqui para ver a Base de Conhecimento Compartilhada](${recentLessons.path})\n`;
|
|
38
40
|
}
|
|
39
41
|
fs.writeFileSync(path.join(root, 'DASHBOARD-PROGRESSO.md'), md, 'utf8');
|
|
40
|
-
console.log(
|
|
42
|
+
console.log(`✅ Dashboard atualizado: ${path.join(root, 'DASHBOARD-PROGRESSO.md')}`);
|
|
41
43
|
db.close();
|
|
42
44
|
}
|
|
43
45
|
try {
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import fs from 'node:fs';
|
|
11
11
|
import path from 'node:path';
|
|
12
|
-
import { collect, renderHtml } from
|
|
13
|
-
import { getWorkspaceContextDir, ensureDir } from
|
|
12
|
+
import { collect, renderHtml } from '../lib/governance-report.js';
|
|
13
|
+
import { getWorkspaceContextDir, ensureDir } from '../lib/workspace.js';
|
|
14
14
|
const argv = process.argv.slice(2);
|
|
15
15
|
const outIdx = argv.indexOf('--out');
|
|
16
16
|
let out = outIdx >= 0 ? argv[outIdx + 1] : null;
|
|
@@ -17,13 +17,14 @@
|
|
|
17
17
|
import fs from 'node:fs';
|
|
18
18
|
import path from 'node:path';
|
|
19
19
|
import { fileURLToPath } from 'node:url';
|
|
20
|
-
import { runChecks, bucketFor, BUCKET_LABEL } from
|
|
21
|
-
import { listSpecs } from
|
|
22
|
-
import { openHandoffs } from
|
|
23
|
-
import { getWorkspaceRoot, isInsideFrameworkRepo } from
|
|
20
|
+
import { runChecks, bucketFor, BUCKET_LABEL } from '../lib/core/health.js';
|
|
21
|
+
import { listSpecs } from '../lib/specs-index.js';
|
|
22
|
+
import { openHandoffs } from '../lib/handoffs-index.js';
|
|
23
|
+
import { getWorkspaceRoot, isInsideFrameworkRepo, currentProjectName } from '../lib/workspace.js';
|
|
24
|
+
import { pkgRoot } from '../lib/paths.js';
|
|
24
25
|
const __filename = fileURLToPath(import.meta.url);
|
|
25
26
|
const __dirname = path.dirname(__filename);
|
|
26
|
-
const frameworkRoot =
|
|
27
|
+
const frameworkRoot = pkgRoot;
|
|
27
28
|
const cwd = path.resolve(process.cwd());
|
|
28
29
|
const root = isInsideFrameworkRepo(cwd)
|
|
29
30
|
? frameworkRoot
|
|
@@ -47,7 +48,7 @@ async function coreHealth() {
|
|
|
47
48
|
const health = await coreHealth();
|
|
48
49
|
const problemas = health.filter((c) => c.status === 'fail' || c.status === 'warn');
|
|
49
50
|
const memoriaOk = !health.some((c) => c.status === 'fail');
|
|
50
|
-
const handoffs = memoriaOk ? await openHandoffs() : [];
|
|
51
|
+
const handoffs = memoriaOk ? await openHandoffs(10, currentProjectName(root)) : [];
|
|
51
52
|
const lines = ['<framework-status>'];
|
|
52
53
|
lines.push(`Framework: forja (SDD + orquestração)`);
|
|
53
54
|
if (problemas.length) {
|
|
@@ -64,9 +65,9 @@ async function coreHealth() {
|
|
|
64
65
|
lines.push(` corrigir: ${p.fix}`);
|
|
65
66
|
}
|
|
66
67
|
if (bucket === 'first-run')
|
|
67
|
-
lines.push(' (ou rode tudo: `
|
|
68
|
+
lines.push(' (ou rode tudo: `forja setup`)');
|
|
68
69
|
}
|
|
69
|
-
lines.push(' raio-x completo: `
|
|
70
|
+
lines.push(' raio-x completo: `forja tools:doctor`');
|
|
70
71
|
}
|
|
71
72
|
if (specs.length) {
|
|
72
73
|
lines.push('\nSpecs ativas:');
|
|
@@ -78,8 +79,8 @@ async function coreHealth() {
|
|
|
78
79
|
for (const h of handoffs)
|
|
79
80
|
lines.push(` - #${h.id} ${h.from} → ${h.to} (${h.intent}) ${h.slug || ''}`);
|
|
80
81
|
}
|
|
81
|
-
lines.push('\nFluxo SDD: `
|
|
82
|
-
lines.push('Handoff: `
|
|
82
|
+
lines.push('\nFluxo SDD: `forja spec:new|spec:plan|spec:tasks|spec:check <slug>` · próximo passo: `forja next`');
|
|
83
|
+
lines.push('Handoff: `forja hermes:handoff \'<json ADR-0005>\'`');
|
|
83
84
|
lines.push('</framework-status>');
|
|
84
85
|
process.stdout.write(JSON.stringify({
|
|
85
86
|
hookSpecificOutput: {
|
|
@@ -26,7 +26,8 @@ import crypto from 'node:crypto';
|
|
|
26
26
|
import { fileURLToPath } from 'node:url';
|
|
27
27
|
const __filename = fileURLToPath(import.meta.url);
|
|
28
28
|
const __dirname = path.dirname(__filename);
|
|
29
|
-
|
|
29
|
+
// O projeto da sessão (repo do framework ou projeto gerado) — nunca o pacote instalado.
|
|
30
|
+
const root = process.env.CLAUDE_PROJECT_DIR || process.cwd();
|
|
30
31
|
const TRIGGER_KEYWORDS = [
|
|
31
32
|
'implement', 'implementa', 'implementar',
|
|
32
33
|
'refator', 'refactor',
|
|
@@ -122,7 +123,7 @@ function buildTaskContext(slug, capBytes) {
|
|
|
122
123
|
if (!pieces.length)
|
|
123
124
|
return null;
|
|
124
125
|
const header = `Spec detectada no prompt: **${slug}**. Pack task-mode injetado ` +
|
|
125
|
-
`(ADR-0009). Para mais contexto: \`
|
|
126
|
+
`(ADR-0009). Para mais contexto: \`forja query:universal "<termo>"\`.`;
|
|
126
127
|
let out = `<forja-task-context slug="${slug}">\n${header}\n\n` +
|
|
127
128
|
pieces.join('\n\n---\n\n') + '\n</forja-task-context>';
|
|
128
129
|
if (out.length > capBytes)
|
package/dist/scripts/incident.js
CHANGED
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
import fs from 'node:fs';
|
|
20
20
|
import { randomUUID } from 'node:crypto';
|
|
21
21
|
import Database from 'better-sqlite3';
|
|
22
|
-
import { GraphLoop } from
|
|
23
|
-
import { SqliteGraphStore, SqliteMigrationRunner } from
|
|
24
|
-
import { getWorkspaceDbDir, getWorkspaceDbPath } from
|
|
25
|
-
import { incidentRecords, rankIncidentsByQuery, titleOf } from
|
|
22
|
+
import { GraphLoop } from '../packages/graph/src/index.js';
|
|
23
|
+
import { SqliteGraphStore, SqliteMigrationRunner } from '../packages/adapter-sqlite/src/index.js';
|
|
24
|
+
import { getWorkspaceDbDir, getWorkspaceDbPath } from '../lib/workspace.js';
|
|
25
|
+
import { incidentRecords, rankIncidentsByQuery, titleOf } from '../lib/core/incident-search.js';
|
|
26
26
|
function flag(args, name) {
|
|
27
27
|
const index = args.indexOf(name);
|
|
28
28
|
return index === -1 ? undefined : args[index + 1];
|
package/dist/scripts/llm-fit.js
CHANGED
|
@@ -4,17 +4,17 @@ import path from 'node:path';
|
|
|
4
4
|
import { spawnSync } from 'node:child_process';
|
|
5
5
|
import Database from 'better-sqlite3';
|
|
6
6
|
import { createHash, randomUUID } from 'node:crypto';
|
|
7
|
-
import { DEFAULT_LLM_PROFILES, buildLlmExecution, recommendProfile, runLlm, validateProfiles } from
|
|
8
|
-
import { EvaluationEngine } from
|
|
9
|
-
import { ObservabilityRecorder } from
|
|
10
|
-
import { SqliteMigrationRunner, SqliteObservationStore, SqliteJsonRepository } from
|
|
11
|
-
import { getWorkspaceContextDir, getWorkspaceDbDir, getWorkspaceDbPath } from
|
|
12
|
-
import { computeCostUsd, isPriceStale, loadPricingTable, lookupPrice, STALE_PRICE_MAX_AGE_DAYS } from
|
|
13
|
-
import { buildContextPrompt, buildEngineerBlock } from
|
|
14
|
-
import { normalizeCodexResult } from
|
|
15
|
-
import { normalizeClaudeResult } from
|
|
16
|
-
import { LlmSessionStore, RESUME_PROVIDERS, validSessionId } from
|
|
17
|
-
import { prepareValidation, validateLlmResponse } from
|
|
7
|
+
import { DEFAULT_LLM_PROFILES, buildLlmExecution, recommendProfile, runLlm, validateProfiles } from '../packages/llm/src/index.js';
|
|
8
|
+
import { EvaluationEngine } from '../packages/evals/src/index.js';
|
|
9
|
+
import { ObservabilityRecorder } from '../packages/observability/src/index.js';
|
|
10
|
+
import { SqliteMigrationRunner, SqliteObservationStore, SqliteJsonRepository } from '../packages/adapter-sqlite/src/index.js';
|
|
11
|
+
import { getWorkspaceContextDir, getWorkspaceDbDir, getWorkspaceDbPath } from '../lib/workspace.js';
|
|
12
|
+
import { computeCostUsd, isPriceStale, loadPricingTable, lookupPrice, STALE_PRICE_MAX_AGE_DAYS } from '../lib/core/model-pricing.js';
|
|
13
|
+
import { buildContextPrompt, buildEngineerBlock } from '../lib/llm/context.js';
|
|
14
|
+
import { normalizeCodexResult } from '../lib/llm/codex-output.js';
|
|
15
|
+
import { normalizeClaudeResult } from '../lib/llm/claude-output.js';
|
|
16
|
+
import { LlmSessionStore, RESUME_PROVIDERS, validSessionId } from '../lib/llm/session.js';
|
|
17
|
+
import { prepareValidation, validateLlmResponse } from '../lib/llm/validation.js';
|
|
18
18
|
const profilePath = () => path.join(getWorkspaceContextDir(), 'llm-profiles.json');
|
|
19
19
|
function usage() {
|
|
20
20
|
console.error('Uso: forja llm:<doctor|profiles:init|probe|recommend|run|eval>');
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Um mapa que aponta para arquivo renomeado/deletado engana com confiança — este comando reprova.
|
|
10
10
|
*/
|
|
11
11
|
import path from 'node:path';
|
|
12
|
-
import { auditMemoryMaps, modulesWithoutMap } from
|
|
12
|
+
import { auditMemoryMaps, modulesWithoutMap } from '../lib/memory-audit.js';
|
|
13
13
|
function main() {
|
|
14
14
|
const i = process.argv.indexOf('--project');
|
|
15
15
|
const projectRoot = path.resolve(i >= 0 ? process.argv[i + 1] : process.cwd());
|
|
@@ -3,9 +3,10 @@ import fs from 'node:fs';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import Database from 'better-sqlite3';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
|
-
import { getWorkspaceDbPath, initWorkspace } from
|
|
6
|
+
import { getWorkspaceDbPath, initWorkspace } from '../lib/workspace.js';
|
|
7
|
+
import { pkgRoot } from '../lib/paths.js';
|
|
7
8
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
-
const root =
|
|
9
|
+
const root = pkgRoot;
|
|
9
10
|
function getDbPath() {
|
|
10
11
|
return getWorkspaceDbPath();
|
|
11
12
|
}
|
|
@@ -12,18 +12,17 @@
|
|
|
12
12
|
import { spawnSync } from 'node:child_process';
|
|
13
13
|
import path from 'node:path';
|
|
14
14
|
import { fileURLToPath } from 'node:url';
|
|
15
|
-
import { startRun, advance, loadState, chainFor, handoffFor } from
|
|
16
|
-
import {
|
|
15
|
+
import { startRun, advance, loadState, chainFor, handoffFor } from '../lib/orchestrate.js';
|
|
16
|
+
import { script } from '../lib/paths.js';
|
|
17
17
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
18
|
-
const pkgRoot = path.resolve(__dirname, '..');
|
|
19
18
|
const targetRoot = process.cwd();
|
|
20
19
|
function forjaBin() {
|
|
21
|
-
return
|
|
20
|
+
return script('bin/forja');
|
|
22
21
|
}
|
|
23
22
|
/** Registra o handoff da etapa via agent-router. Falha de workspace não derruba a corrida. */
|
|
24
23
|
function registerHandoff(slug, goal, stageIndex) {
|
|
25
24
|
const payload = handoffFor(slug, goal, stageIndex);
|
|
26
|
-
const router =
|
|
25
|
+
const router = script('scripts/agent-router');
|
|
27
26
|
const res = spawnSync(process.execPath, [router, 'append', JSON.stringify(payload)], {
|
|
28
27
|
cwd: targetRoot,
|
|
29
28
|
encoding: 'utf8',
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* É o `release:check` da saída do gerador, um nível acima do tarball.
|
|
13
13
|
*/
|
|
14
|
-
import { runProjectSmoke, worstStatus } from
|
|
14
|
+
import { runProjectSmoke, worstStatus } from '../lib/core/project-smoke.js';
|
|
15
15
|
const TAG = { ok: 'OK ', warn: 'AVISO', fail: 'FALHA', skipped: '— ' };
|
|
16
16
|
function parseAi(argv) {
|
|
17
17
|
const i = argv.indexOf('--ai');
|
|
@@ -23,11 +23,22 @@ function parseAi(argv) {
|
|
|
23
23
|
async function main() {
|
|
24
24
|
const full = process.argv.includes('--full');
|
|
25
25
|
const ai = parseAi(process.argv.slice(2));
|
|
26
|
+
const ti = process.argv.indexOf('--template');
|
|
27
|
+
const template = ti >= 0 ? process.argv[ti + 1] : undefined;
|
|
26
28
|
console.log(`\nForja project smoke${full ? ' (tier --full)' : ''}${ai ? ` (--ai ${ai.join(',')})` : ''}\n`);
|
|
27
29
|
console.log(ai
|
|
28
30
|
? `Gerando um projeto só-memória + instruções nativas (${ai.join(', ')}) num diretório isolado.\n`
|
|
29
31
|
: `Gerando um projeto num diretório isolado${full ? ' e buildando o backend — isto leva minutos' : ''}.\n`);
|
|
30
|
-
|
|
32
|
+
if (template)
|
|
33
|
+
console.log(`Template: ${template}\n`);
|
|
34
|
+
let results;
|
|
35
|
+
try {
|
|
36
|
+
results = await runProjectSmoke({ full, ai, template });
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
console.error(`❌ ${e.message}`);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
31
42
|
for (const r of results) {
|
|
32
43
|
console.log(`${TAG[r.status]} ${r.id.padEnd(16)} ${r.detail}`);
|
|
33
44
|
if (r.fix)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|