forjajs 4.1.1 → 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 +125 -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/specs-index.d.ts +1 -0
- package/dist/lib/specs-index.js +22 -3
- package/dist/lib/status-model.js +24 -8
- 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 +33 -3
- 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.d.ts +1 -1
- package/dist/scripts/forja-status.js +31 -3
- 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 +18 -9
- 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 +21 -8
- package/dist/scripts/sync-universal-memory.js +50 -27
- 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
|
@@ -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;
|
|
@@ -14,14 +14,23 @@
|
|
|
14
14
|
* e "banco ausente" no mesmo `null`, e então prescrevia `npm install` — que não recompila binário
|
|
15
15
|
* nativo. Quem seguisse o conselho do próprio framework não consertava nada.
|
|
16
16
|
*/
|
|
17
|
+
import fs from 'node:fs';
|
|
17
18
|
import path from 'node:path';
|
|
18
19
|
import { fileURLToPath } from 'node:url';
|
|
19
|
-
import { runChecks, bucketFor, BUCKET_LABEL } from
|
|
20
|
-
import { listSpecs } from
|
|
21
|
-
import { openHandoffs } 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';
|
|
22
25
|
const __filename = fileURLToPath(import.meta.url);
|
|
23
26
|
const __dirname = path.dirname(__filename);
|
|
24
|
-
const
|
|
27
|
+
const frameworkRoot = pkgRoot;
|
|
28
|
+
const cwd = path.resolve(process.cwd());
|
|
29
|
+
const root = isInsideFrameworkRepo(cwd)
|
|
30
|
+
? frameworkRoot
|
|
31
|
+
: (fs.existsSync(path.join(cwd, 'specs')) || fs.existsSync(path.join(cwd, 'package.json')))
|
|
32
|
+
? cwd
|
|
33
|
+
: getWorkspaceRoot();
|
|
25
34
|
/**
|
|
26
35
|
* Nunca lança e nunca trava a sessão: o hook reporta, o `tools:doctor` é que é gate. Se a própria
|
|
27
36
|
* lib de health não carregar, seguimos com o resto do briefing em vez de abortar (ADR-0021).
|
|
@@ -39,7 +48,7 @@ async function coreHealth() {
|
|
|
39
48
|
const health = await coreHealth();
|
|
40
49
|
const problemas = health.filter((c) => c.status === 'fail' || c.status === 'warn');
|
|
41
50
|
const memoriaOk = !health.some((c) => c.status === 'fail');
|
|
42
|
-
const handoffs = memoriaOk ? await openHandoffs() : [];
|
|
51
|
+
const handoffs = memoriaOk ? await openHandoffs(10, currentProjectName(root)) : [];
|
|
43
52
|
const lines = ['<framework-status>'];
|
|
44
53
|
lines.push(`Framework: forja (SDD + orquestração)`);
|
|
45
54
|
if (problemas.length) {
|
|
@@ -56,9 +65,9 @@ async function coreHealth() {
|
|
|
56
65
|
lines.push(` corrigir: ${p.fix}`);
|
|
57
66
|
}
|
|
58
67
|
if (bucket === 'first-run')
|
|
59
|
-
lines.push(' (ou rode tudo: `
|
|
68
|
+
lines.push(' (ou rode tudo: `forja setup`)');
|
|
60
69
|
}
|
|
61
|
-
lines.push(' raio-x completo: `
|
|
70
|
+
lines.push(' raio-x completo: `forja tools:doctor`');
|
|
62
71
|
}
|
|
63
72
|
if (specs.length) {
|
|
64
73
|
lines.push('\nSpecs ativas:');
|
|
@@ -70,8 +79,8 @@ async function coreHealth() {
|
|
|
70
79
|
for (const h of handoffs)
|
|
71
80
|
lines.push(` - #${h.id} ${h.from} → ${h.to} (${h.intent}) ${h.slug || ''}`);
|
|
72
81
|
}
|
|
73
|
-
lines.push('\nFluxo SDD: `
|
|
74
|
-
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>\'`');
|
|
75
84
|
lines.push('</framework-status>');
|
|
76
85
|
process.stdout.write(JSON.stringify({
|
|
77
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 {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* forja project:templates — os boilerplates e o que dá para fazer com cada um (ADR-0088).
|
|
3
|
+
* Template validado: `forja project:new <nome> --template <t>`. Referência: consulta/adaptação.
|
|
4
|
+
*/
|
|
5
|
+
import { listTemplates } from '../lib/templates.js';
|
|
6
|
+
const all = listTemplates();
|
|
7
|
+
if (process.argv.includes('--json')) {
|
|
8
|
+
console.log(JSON.stringify(all.map(({ dir, ...t }) => t), null, 2));
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
const ready = all.filter((t) => t.ready);
|
|
12
|
+
console.log('Templates (forja project:new <nome> --template <template>):');
|
|
13
|
+
for (const t of ready)
|
|
14
|
+
console.log(` ${t.name.replace(/^\d+-/, '').padEnd(24)} ${t.title}${t.stack.length ? ` — ${t.stack.join(', ')}` : ''}`);
|
|
15
|
+
if (!ready.length)
|
|
16
|
+
console.log(' (nenhum)');
|
|
17
|
+
console.log('\nReferência (consulte em boilerplates/<nome>/; ainda sem validação de build):');
|
|
18
|
+
for (const t of all.filter((x) => !x.ready))
|
|
19
|
+
console.log(` ${t.name.padEnd(26)} ${t.title}`);
|
|
20
|
+
}
|
|
@@ -5,7 +5,20 @@
|
|
|
5
5
|
* forja project:upgrade dry-run: lista o que falta (cwd)
|
|
6
6
|
* forja project:upgrade --apply copia as peças novas
|
|
7
7
|
* forja project:upgrade --project <path> aponta para outro projeto
|
|
8
|
+
* forja project:upgrade --all [--apply] todos os projetos do workspace, com relatório
|
|
8
9
|
*
|
|
9
10
|
* Aditivo, nunca sobrescreve: só traz arquivos que o projeto não tem. O código do usuário é intocável.
|
|
11
|
+
* Desde a v5 também religa o projeto à inteligência do Forja (project:wire): instruções nativas,
|
|
12
|
+
* hooks, sub-agents e MCP — a migração de projetos gerados antes da v5 (ADR-0086).
|
|
10
13
|
*/
|
|
14
|
+
interface UpgradeReport {
|
|
15
|
+
readonly target: string;
|
|
16
|
+
readonly status: 'em-dia' | 'pendente' | 'aplicado' | 'nao-forja' | 'erro';
|
|
17
|
+
readonly newFiles: string[];
|
|
18
|
+
readonly wiringGaps: string[];
|
|
19
|
+
readonly applied: number;
|
|
20
|
+
readonly wired: number;
|
|
21
|
+
readonly error?: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function upgradeProject(target: string, apply: boolean): UpgradeReport;
|
|
11
24
|
export {};
|
|
@@ -5,61 +5,128 @@
|
|
|
5
5
|
* forja project:upgrade dry-run: lista o que falta (cwd)
|
|
6
6
|
* forja project:upgrade --apply copia as peças novas
|
|
7
7
|
* forja project:upgrade --project <path> aponta para outro projeto
|
|
8
|
+
* forja project:upgrade --all [--apply] todos os projetos do workspace, com relatório
|
|
8
9
|
*
|
|
9
10
|
* Aditivo, nunca sobrescreve: só traz arquivos que o projeto não tem. O código do usuário é intocável.
|
|
11
|
+
* Desde a v5 também religa o projeto à inteligência do Forja (project:wire): instruções nativas,
|
|
12
|
+
* hooks, sub-agents e MCP — a migração de projetos gerados antes da v5 (ADR-0086).
|
|
10
13
|
*/
|
|
11
14
|
import { execFileSync } from 'node:child_process';
|
|
12
15
|
import fs from 'node:fs';
|
|
13
16
|
import os from 'node:os';
|
|
14
17
|
import path from 'node:path';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
const
|
|
18
|
+
import { planUpgrade, applyUpgrade } from '../lib/project-upgrade.js';
|
|
19
|
+
import { COMMANDS } from '../lib/core/registry.js';
|
|
20
|
+
import { wireProject, checkProjectWiring, detectWiredAi } from '../lib/project-wiring.js';
|
|
21
|
+
import { getProjectsDir, listProjects } from '../lib/workspace.js';
|
|
22
|
+
import { script } from '../lib/paths.js';
|
|
23
|
+
/** Scaffold de referência num tmp isolado (ambiente limpo, a lição do release:check). */
|
|
24
|
+
function freshScaffold(tmp, withBackend) {
|
|
25
|
+
const fresh = path.join(tmp, 'fresh');
|
|
26
|
+
const env = { ...process.env };
|
|
27
|
+
delete env.NODE_PATH;
|
|
28
|
+
for (const k of Object.keys(env))
|
|
29
|
+
if (k.startsWith('npm_'))
|
|
30
|
+
delete env[k];
|
|
31
|
+
// Sem backend quando o projeto não tem um: "aditivo" não pode significar instalar um NestJS
|
|
32
|
+
// inteiro num projeto --skip-backend ou num repositório existente.
|
|
33
|
+
const args = [script('bin/create-memory-nest-kit'), fresh, ...(withBackend ? [] : ['--only-memory']), '--force'];
|
|
34
|
+
try {
|
|
35
|
+
execFileSync(process.execPath, args, { cwd: tmp, env, stdio: 'pipe' });
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
const out = `${e.stdout ?? ''}${e.stderr ?? ''}`.trim().split('\n').slice(-15).join('\n');
|
|
39
|
+
throw new Error(`o gerador de referência falhou — nada foi alterado.\n${out}`);
|
|
40
|
+
}
|
|
41
|
+
return fresh;
|
|
42
|
+
}
|
|
43
|
+
export function upgradeProject(target, apply) {
|
|
44
|
+
const base = { target, newFiles: [], wiringGaps: [], applied: 0, wired: 0 };
|
|
24
45
|
if (!fs.existsSync(path.join(target, 'AGENTS.md'))) {
|
|
25
|
-
|
|
26
|
-
console.error('Rode dentro de um projeto gerado, ou aponte com --project <path>.');
|
|
27
|
-
process.exit(1);
|
|
46
|
+
return { ...base, status: 'nao-forja', error: 'ainda não usa o Forja (sem AGENTS.md) — entre nele e rode forja project:wire' };
|
|
28
47
|
}
|
|
29
|
-
// Gera um scaffold fresco num tmp isolado, com o ambiente limpo (a lição do release:check).
|
|
30
48
|
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'forja-upgrade-'));
|
|
31
|
-
const fresh = path.join(tmp, 'fresh');
|
|
32
49
|
try {
|
|
33
|
-
const
|
|
34
|
-
delete env.NODE_PATH;
|
|
35
|
-
for (const k of Object.keys(env))
|
|
36
|
-
if (k.startsWith('npm_'))
|
|
37
|
-
delete env[k];
|
|
38
|
-
// resolveScript acha .ts em dev e dist/bin/create-memory-nest-kit.js no publicado — cravar .ts
|
|
39
|
-
// quebrava o comando instalado com module-not-found (o dist não tem .ts).
|
|
40
|
-
const generator = resolveScript(repoRoot, 'bin/create-memory-nest-kit');
|
|
41
|
-
execFileSync(process.execPath, [generator, fresh, '--force'], {
|
|
42
|
-
cwd: tmp,
|
|
43
|
-
env,
|
|
44
|
-
stdio: 'pipe',
|
|
45
|
-
});
|
|
50
|
+
const fresh = freshScaffold(tmp, fs.existsSync(path.join(target, 'backend')));
|
|
46
51
|
const plan = planUpgrade(fresh, target);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
const ai = detectWiredAi(target);
|
|
53
|
+
const wiringGaps = checkProjectWiring(target, { commands: COMMANDS, ai: ai.length ? ai : undefined })
|
|
54
|
+
.filter((c) => c.status === 'fail')
|
|
55
|
+
.map((c) => `${c.id}: ${c.detail}`);
|
|
56
|
+
if (!plan.newFiles.length && !wiringGaps.length)
|
|
57
|
+
return { ...base, status: 'em-dia' };
|
|
58
|
+
if (!apply)
|
|
59
|
+
return { ...base, status: 'pendente', newFiles: plan.newFiles, wiringGaps };
|
|
60
|
+
const applied = applyUpgrade(fresh, target, plan).length;
|
|
61
|
+
const wired = wireProject(target, { ai: ai.length ? ai : undefined }).filter((c) => c.action !== 'unchanged').length;
|
|
62
|
+
return { ...base, status: 'aplicado', newFiles: plan.newFiles, wiringGaps, applied, wired };
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
return { ...base, status: 'erro', error: e.message };
|
|
60
66
|
}
|
|
61
67
|
finally {
|
|
62
68
|
fs.rmSync(tmp, { recursive: true, force: true });
|
|
63
69
|
}
|
|
64
70
|
}
|
|
71
|
+
function printOne(r, apply) {
|
|
72
|
+
if (r.status === 'erro' || r.status === 'nao-forja') {
|
|
73
|
+
console.error(`${r.target}: ${r.error}`);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (r.status === 'em-dia') {
|
|
77
|
+
console.log('Projeto já em dia — scaffold completo e conexão com a IA em ordem.');
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (r.newFiles.length) {
|
|
81
|
+
console.log(`${r.newFiles.length} peça(s) de scaffold nova(s) que este projeto ainda não tem:\n`);
|
|
82
|
+
for (const rel of r.newFiles)
|
|
83
|
+
console.log(` + ${rel}`);
|
|
84
|
+
}
|
|
85
|
+
if (r.wiringGaps.length) {
|
|
86
|
+
console.log('\nConexão com a IA a refazer (project:wire):');
|
|
87
|
+
for (const g of r.wiringGaps)
|
|
88
|
+
console.log(` ~ ${g}`);
|
|
89
|
+
}
|
|
90
|
+
if (!apply)
|
|
91
|
+
console.log('\nDry-run. Rode com --apply para aplicar. Arquivos do usuário não são sobrescritos; nos de instrução só o bloco forja:begin/end muda.');
|
|
92
|
+
else
|
|
93
|
+
console.log(`\n✓ ${r.applied} arquivo(s) copiado(s), ${r.wired} de conexão escrito(s). Revise o diff antes de commitar.`);
|
|
94
|
+
}
|
|
95
|
+
function main() {
|
|
96
|
+
const argv = process.argv.slice(2);
|
|
97
|
+
const apply = argv.includes('--apply');
|
|
98
|
+
const json = argv.includes('--json');
|
|
99
|
+
if (argv.includes('--all')) {
|
|
100
|
+
const names = listProjects();
|
|
101
|
+
if (!names.length) {
|
|
102
|
+
console.log(`Nenhum projeto em ${getProjectsDir()}.`);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const reports = names.map((n) => ({ name: n, ...upgradeProject(path.join(getProjectsDir(), n), apply) }));
|
|
106
|
+
if (json) {
|
|
107
|
+
console.log(JSON.stringify(reports, null, 2));
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
console.log(`${apply ? 'Upgrade' : 'Dry-run'} de ${names.length} projeto(s) em ${getProjectsDir()}:\n`);
|
|
111
|
+
for (const r of reports) {
|
|
112
|
+
const what = r.status === 'erro' || r.status === 'nao-forja' ? r.error
|
|
113
|
+
: r.status === 'em-dia' ? 'em dia'
|
|
114
|
+
: r.status === 'pendente' ? `${r.newFiles.length} peça(s) nova(s), ${r.wiringGaps.length} lacuna(s) de conexão`
|
|
115
|
+
: `${r.applied} copiada(s), ${r.wired} de conexão`;
|
|
116
|
+
console.log(` ${r.status.padEnd(9)} ${r.name.padEnd(32)} ${what}`);
|
|
117
|
+
}
|
|
118
|
+
if (!apply && reports.some((r) => r.status === 'pendente'))
|
|
119
|
+
console.log('\nDry-run. Detalhe de um: cd <projeto> && forja project:upgrade · aplicar em todos: --all --apply');
|
|
120
|
+
}
|
|
121
|
+
process.exit(reports.some((r) => r.status === 'erro') ? 1 : 0);
|
|
122
|
+
}
|
|
123
|
+
const i = argv.indexOf('--project');
|
|
124
|
+
const target = path.resolve(i >= 0 ? argv[i + 1] : process.cwd());
|
|
125
|
+
const report = upgradeProject(target, apply);
|
|
126
|
+
if (json)
|
|
127
|
+
console.log(JSON.stringify(report, null, 2));
|
|
128
|
+
else
|
|
129
|
+
printOne(report, apply);
|
|
130
|
+
process.exit(report.status === 'erro' || report.status === 'nao-forja' ? 1 : 0);
|
|
131
|
+
}
|
|
65
132
|
main();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* forja project:wire — conecta (ou verifica) o projeto do cwd à inteligência do Forja (ADR-0086).
|
|
3
|
+
*
|
|
4
|
+
* forja project:wire escreve/atualiza instruções, hooks, sub-agents, MCP
|
|
5
|
+
* forja project:wire --ai claude,codex escolhe as IAs (padrão: as já conectadas, ou todas)
|
|
6
|
+
* forja project:wire --check [--json] só verifica; exit 1 se algo essencial está desligado
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* forja project:wire — conecta (ou verifica) o projeto do cwd à inteligência do Forja (ADR-0086).
|
|
3
|
+
*
|
|
4
|
+
* forja project:wire escreve/atualiza instruções, hooks, sub-agents, MCP
|
|
5
|
+
* forja project:wire --ai claude,codex escolhe as IAs (padrão: as já conectadas, ou todas)
|
|
6
|
+
* forja project:wire --check [--json] só verifica; exit 1 se algo essencial está desligado
|
|
7
|
+
*/
|
|
8
|
+
import process from 'node:process';
|
|
9
|
+
import { COMMANDS } from '../lib/core/registry.js';
|
|
10
|
+
import { wireProject, checkProjectWiring, detectWiredAi } from '../lib/project-wiring.js';
|
|
11
|
+
import { isInsideFrameworkRepo } from '../lib/workspace.js';
|
|
12
|
+
function fail(msg) {
|
|
13
|
+
console.error(msg);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
const argv = process.argv.slice(2);
|
|
17
|
+
const check = argv.includes('--check');
|
|
18
|
+
const json = argv.includes('--json');
|
|
19
|
+
const aiIdx = argv.indexOf('--ai');
|
|
20
|
+
const ai = aiIdx >= 0 ? (argv[aiIdx + 1] ?? fail('--ai exige uma lista: claude,codex,gemini,copilot')).split(',') : undefined;
|
|
21
|
+
const dir = process.cwd();
|
|
22
|
+
if (isInsideFrameworkRepo(dir)) {
|
|
23
|
+
fail('project:wire opera um projeto, não o repositório do framework. Rode dentro do projeto (ou use forja project:new).');
|
|
24
|
+
}
|
|
25
|
+
if (!check) {
|
|
26
|
+
let changes;
|
|
27
|
+
try {
|
|
28
|
+
changes = wireProject(dir, { ai: ai ?? (detectWiredAi(dir).length ? detectWiredAi(dir) : undefined) });
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
fail(e.message);
|
|
32
|
+
}
|
|
33
|
+
if (json) {
|
|
34
|
+
console.log(JSON.stringify({ changes }, null, 2));
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
for (const c of changes)
|
|
38
|
+
if (c.action !== 'unchanged')
|
|
39
|
+
console.log(`${c.action === 'created' ? '+' : '~'} ${c.file}`);
|
|
40
|
+
const touched = changes.filter((c) => c.action !== 'unchanged').length;
|
|
41
|
+
console.log(touched ? `✓ projeto conectado (${touched} arquivo(s))` : '✓ projeto já estava conectado');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const checks = checkProjectWiring(dir, { commands: COMMANDS, ai });
|
|
45
|
+
const failed = checks.filter((c) => c.status === 'fail');
|
|
46
|
+
if (json && check) {
|
|
47
|
+
console.log(JSON.stringify({ ok: failed.length === 0, checks }, null, 2));
|
|
48
|
+
}
|
|
49
|
+
else if (check || failed.length) {
|
|
50
|
+
for (const c of checks)
|
|
51
|
+
console.log(`${c.status === 'ok' ? 'OK ' : c.status === 'warn' ? 'WARN' : 'FAIL'} ${c.id.padEnd(14)} ${c.detail}`);
|
|
52
|
+
if (failed.length)
|
|
53
|
+
console.log('\nCorrija com: forja project:wire');
|
|
54
|
+
}
|
|
55
|
+
process.exit(failed.length ? 1 : 0);
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import fs from 'node:fs';
|
|
15
15
|
import Database from 'better-sqlite3';
|
|
16
|
-
import { extractProvenance } from
|
|
17
|
-
import { SqliteMigrationRunner, SqliteProvenanceStore, SqliteRuntimeRunStore } from
|
|
18
|
-
import { getWorkspaceDbDir, getWorkspaceDbPath } from
|
|
16
|
+
import { extractProvenance } from '../packages/engineering/provenance/src/index.js';
|
|
17
|
+
import { SqliteMigrationRunner, SqliteProvenanceStore, SqliteRuntimeRunStore } from '../packages/adapter-sqlite/src/index.js';
|
|
18
|
+
import { getWorkspaceDbDir, getWorkspaceDbPath } from '../lib/workspace.js';
|
|
19
19
|
function openDatabase() {
|
|
20
20
|
fs.mkdirSync(getWorkspaceDbDir(), { recursive: true });
|
|
21
21
|
const database = new Database(process.env.FORJA_RUNTIME_DB ?? getWorkspaceDbPath());
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import Database from 'better-sqlite3';
|
|
2
|
-
import { getDbPath, ensureSchema } from
|
|
2
|
+
import { getDbPath, ensureSchema } from './memory-schema.js';
|
|
3
|
+
import { ftsQuery } from '../lib/context-builder.js';
|
|
3
4
|
ensureSchema({ silent: true });
|
|
4
5
|
const dbPath = getDbPath();
|
|
5
6
|
const args = process.argv.slice(2);
|
|
6
7
|
const query = args[0] || '';
|
|
7
8
|
const limit = Number(args[1] || 5);
|
|
8
9
|
if (!query) {
|
|
9
|
-
console.
|
|
10
|
-
process.exit(
|
|
10
|
+
console.error('Uso: forja query:universal "termo de busca" [limite]');
|
|
11
|
+
process.exit(1);
|
|
11
12
|
}
|
|
12
13
|
const db = new Database(dbPath, { readonly: true });
|
|
13
14
|
const search = db.prepare(`
|
|
@@ -25,7 +26,8 @@ const search = db.prepare(`
|
|
|
25
26
|
LIMIT ?
|
|
26
27
|
`);
|
|
27
28
|
try {
|
|
28
|
-
|
|
29
|
+
// Termo livre → FTS seguro (`pix-qr`, `auth:jwt` eram sintaxe inválida e a busca lançava).
|
|
30
|
+
const results = search.all(ftsQuery(query), limit);
|
|
29
31
|
if (results.length === 0) {
|
|
30
32
|
console.log(`Nenhum resultado encontrado para: "${query}"`);
|
|
31
33
|
}
|
|
@@ -40,5 +42,6 @@ try {
|
|
|
40
42
|
}
|
|
41
43
|
catch (e) {
|
|
42
44
|
console.error('Erro na busca:', e.message);
|
|
45
|
+
process.exitCode = 1;
|
|
43
46
|
}
|
|
44
47
|
db.close();
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* Diagnostica e autoriza; nunca publica. `npm publish` continua sendo um ato humano.
|
|
13
13
|
*/
|
|
14
|
-
import { runReleaseChecks, worstStatus } from
|
|
14
|
+
import { runReleaseChecks, worstStatus } from '../lib/core/release.js';
|
|
15
15
|
const TAG = { ok: 'OK ', warn: 'AVISO', fail: 'FALHA', skipped: '— ' };
|
|
16
16
|
async function main() {
|
|
17
17
|
const publish = process.argv.includes('--publish');
|
package/dist/scripts/risk.js
CHANGED
|
@@ -16,10 +16,10 @@ import fs from 'node:fs';
|
|
|
16
16
|
import path from 'node:path';
|
|
17
17
|
import { randomUUID } from 'node:crypto';
|
|
18
18
|
import Database from 'better-sqlite3';
|
|
19
|
-
import { assessRisk, explainAssessment } from
|
|
20
|
-
import { SqliteMigrationRunner } from
|
|
21
|
-
import { getWorkspaceDbDir, getWorkspaceDbPath } from
|
|
22
|
-
import { buildRiskInput, changedFiles, graphRoot } from
|
|
19
|
+
import { assessRisk, explainAssessment } from '../packages/engineering/risk/src/index.js';
|
|
20
|
+
import { SqliteMigrationRunner } from '../packages/adapter-sqlite/src/index.js';
|
|
21
|
+
import { getWorkspaceDbDir, getWorkspaceDbPath } from '../lib/workspace.js';
|
|
22
|
+
import { buildRiskInput, changedFiles, graphRoot } from '../lib/core/risk-collect.js';
|
|
23
23
|
const RISK_DIR = '.context/risk';
|
|
24
24
|
function assessmentPath(id) {
|
|
25
25
|
return path.join(graphRoot(), RISK_DIR, `${id}.json`);
|