forjajs 1.1.6 → 1.3.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 +7 -7
- package/CHANGELOG.md +62 -0
- package/README.en.md +33 -5
- package/README.md +35 -4
- package/boilerplates/06-clean-arch/README.md +48 -0
- package/boilerplates/06-clean-arch/WHEN-CLEAN-WHEN-LEAN.md +42 -0
- package/boilerplates/06-clean-arch/backend/package.json +43 -0
- package/boilerplates/06-clean-arch/backend/src/app.module.ts +20 -0
- package/boilerplates/06-clean-arch/backend/src/main.ts +10 -0
- package/boilerplates/06-clean-arch/backend/src/modules/orders/application/place-order.usecase.ts +47 -0
- package/boilerplates/06-clean-arch/backend/src/modules/orders/application/ship-order.usecase.ts +28 -0
- package/boilerplates/06-clean-arch/backend/src/modules/orders/domain/money.vo.ts +30 -0
- package/boilerplates/06-clean-arch/backend/src/modules/orders/domain/order-status.vo.ts +36 -0
- package/boilerplates/06-clean-arch/backend/src/modules/orders/domain/order.entity.ts +85 -0
- package/boilerplates/06-clean-arch/backend/src/modules/orders/domain/order.repository.ts +17 -0
- package/boilerplates/06-clean-arch/backend/src/modules/orders/infrastructure/order.orm-entity.ts +24 -0
- package/boilerplates/06-clean-arch/backend/src/modules/orders/infrastructure/typeorm-order.repository.ts +57 -0
- package/boilerplates/06-clean-arch/backend/src/modules/orders/orders.module.ts +28 -0
- package/boilerplates/06-clean-arch/backend/src/modules/orders/presentation/orders.controller.ts +31 -0
- package/boilerplates/06-clean-arch/backend/src/modules/orders/presentation/orders.http.dto.ts +30 -0
- package/boilerplates/06-clean-arch/backend/src/modules/products/product.entity.ts +20 -0
- package/boilerplates/06-clean-arch/backend/src/modules/products/products.controller.ts +43 -0
- package/boilerplates/06-clean-arch/backend/src/modules/products/products.module.ts +11 -0
- package/boilerplates/06-clean-arch/backend/src/shared/result.ts +32 -0
- package/boilerplates/06-clean-arch/backend/test/orders/place-order.spec.ts +46 -0
- package/boilerplates/06-clean-arch/backend/tsconfig.json +16 -0
- package/boilerplates/06-clean-arch/boilerplate.manifest.json +43 -0
- package/boilerplates/06-clean-arch/memory/30-domains/orders/context.md +39 -0
- package/boilerplates/06-clean-arch/memory/30-domains/products/context.md +23 -0
- package/boilerplates/README.md +20 -0
- package/dist/bin/create-memory-nest-kit.d.ts +2 -0
- package/dist/bin/create-memory-nest-kit.js +110 -0
- package/dist/bin/forja.d.ts +13 -0
- package/dist/bin/forja.js +136 -0
- package/dist/bin/init-project.d.ts +2 -0
- package/dist/bin/init-project.js +516 -0
- package/dist/lib/audit.d.ts +67 -0
- package/dist/lib/audit.js +143 -0
- package/dist/lib/context-builder.d.ts +58 -0
- package/dist/lib/context-builder.js +233 -0
- package/dist/lib/core/checks.d.ts +91 -0
- package/dist/lib/core/checks.js +119 -0
- package/dist/lib/core/doc-graph.d.ts +60 -0
- package/dist/lib/core/doc-graph.js +235 -0
- package/dist/lib/core/health.d.ts +103 -0
- package/dist/lib/core/health.js +538 -0
- package/dist/lib/core/registry.d.ts +296 -0
- package/dist/lib/core/registry.js +317 -0
- package/dist/lib/core/release.d.ts +334 -0
- package/dist/lib/core/release.js +465 -0
- package/dist/lib/generators/memory-generator.d.ts +83 -0
- package/{lib → dist/lib}/generators/memory-generator.js +107 -178
- package/dist/lib/generators/nest-generator.d.ts +15 -0
- package/{lib → dist/lib}/generators/nest-generator.js +47 -71
- package/dist/lib/generators/readme-generator.d.ts +15 -0
- package/{lib → dist/lib}/generators/readme-generator.js +9 -14
- package/dist/lib/governance-report.d.ts +49 -0
- package/dist/lib/governance-report.js +170 -0
- package/dist/lib/templates/harness/code-intel.d.mts +2 -0
- package/dist/lib/templates/harness/code-intel.mjs +126 -0
- package/dist/lib/utils/file-helpers.d.ts +9 -0
- package/dist/lib/utils/file-helpers.js +34 -0
- package/dist/lib/validators/structure-validator.d.ts +48 -0
- package/dist/lib/validators/structure-validator.js +232 -0
- package/dist/lib/workspace.d.ts +40 -0
- package/dist/lib/workspace.js +174 -0
- package/dist/scripts/agent-harness.d.ts +2 -0
- package/dist/scripts/agent-harness.js +556 -0
- package/dist/scripts/agent-router.d.ts +30 -0
- package/dist/scripts/agent-router.js +208 -0
- package/dist/scripts/audit-query.d.ts +2 -0
- package/dist/scripts/audit-query.js +43 -0
- package/dist/scripts/audit-sync.d.ts +2 -0
- package/dist/scripts/audit-sync.js +19 -0
- package/dist/scripts/build-smart-context.d.ts +1 -0
- package/dist/scripts/build-smart-context.js +75 -0
- package/dist/scripts/check-standards.d.ts +1 -0
- package/dist/scripts/check-standards.js +87 -0
- package/dist/scripts/compress-memory.d.ts +16 -0
- package/dist/scripts/compress-memory.js +157 -0
- package/dist/scripts/compress-project-memory.d.ts +1 -0
- package/dist/scripts/compress-project-memory.js +48 -0
- package/dist/scripts/context-ops.d.ts +2 -0
- package/dist/scripts/context-ops.js +464 -0
- package/dist/scripts/dev.d.ts +96 -0
- package/dist/scripts/dev.js +312 -0
- package/dist/scripts/extract-global-knowledge.d.ts +1 -0
- package/dist/scripts/extract-global-knowledge.js +43 -0
- package/dist/scripts/generate-dashboard.d.ts +1 -0
- package/dist/scripts/generate-dashboard.js +48 -0
- package/dist/scripts/governance-dashboard.d.ts +2 -0
- package/dist/scripts/governance-dashboard.js +36 -0
- package/dist/scripts/hook-guard-paths.d.ts +17 -0
- package/dist/scripts/hook-guard-paths.js +68 -0
- package/dist/scripts/hook-post-edit.d.ts +20 -0
- package/dist/scripts/hook-post-edit.js +70 -0
- package/dist/scripts/hook-session-start.d.ts +17 -0
- package/dist/scripts/hook-session-start.js +108 -0
- package/dist/scripts/hook-user-prompt.d.ts +22 -0
- package/dist/scripts/hook-user-prompt.js +193 -0
- package/dist/scripts/memory-schema.d.ts +6 -0
- package/{scripts/memory-schema.mjs → dist/scripts/memory-schema.js} +27 -20
- package/dist/scripts/query-universal-memory.d.ts +1 -0
- package/dist/scripts/query-universal-memory.js +44 -0
- package/dist/scripts/release-check.d.ts +14 -0
- package/dist/scripts/release-check.js +48 -0
- package/dist/scripts/spec-cli.d.ts +29 -0
- package/dist/scripts/spec-cli.js +261 -0
- package/dist/scripts/sprint-manager.d.ts +1 -0
- package/dist/scripts/sprint-manager.js +187 -0
- package/dist/scripts/sync-universal-memory.d.ts +1 -0
- package/dist/scripts/sync-universal-memory.js +277 -0
- package/dist/scripts/token-benchmark.d.ts +20 -0
- package/dist/scripts/token-benchmark.js +181 -0
- package/dist/scripts/tools-doctor.d.ts +20 -0
- package/dist/scripts/tools-doctor.js +120 -0
- package/docs/personas/architect/README.md +4 -4
- package/docs/personas/developer/README.md +3 -3
- package/docs/personas/qa/README.md +3 -3
- package/docs/quick-reference.md +9 -9
- package/docs/structure.md +3 -3
- package/memory/90-decisions/0025-coerencia-da-documentacao.md +95 -0
- package/memory/90-decisions/0027-clean-arch-calibrada.md +96 -0
- package/memory/90-decisions/0028-governanca-visivel.md +84 -0
- package/package.json +60 -56
- package/specs/clean-arch-boilerplate/plan.md +137 -0
- package/specs/clean-arch-boilerplate/spec.md +121 -0
- package/specs/clean-arch-boilerplate/tasks.md +70 -0
- package/specs/coerencia-do-sistema/plan.md +155 -0
- package/specs/coerencia-do-sistema/spec.md +15 -14
- package/specs/coerencia-do-sistema/tasks.md +115 -0
- package/specs/governanca-visivel/plan.md +122 -0
- package/specs/governanca-visivel/spec.md +112 -0
- package/specs/governanca-visivel/tasks.md +60 -0
- package/specs/ts-migration/plan.md +199 -0
- package/specs/ts-migration/spec.md +119 -0
- package/specs/ts-migration/tasks.md +110 -0
- package/bin/create-memory-nest-kit.js +0 -125
- package/bin/forja.mjs +0 -143
- package/bin/init-project.js +0 -612
- package/lib/context-builder.js +0 -257
- package/lib/core/checks.mjs +0 -138
- package/lib/core/health.mjs +0 -475
- package/lib/core/registry.mjs +0 -289
- package/lib/core/release.mjs +0 -452
- package/lib/templates/harness/code-intel.mjs +0 -119
- package/lib/templates/harness/mcp.json +0 -10
- package/lib/utils/file-helpers.js +0 -40
- package/lib/validators/structure-validator.js +0 -253
- package/lib/workspace.mjs +0 -213
- package/scripts/agent-harness.mjs +0 -578
- package/scripts/agent-router.mjs +0 -189
- package/scripts/build-smart-context.js +0 -87
- package/scripts/check-standards.js +0 -98
- package/scripts/compress-memory.mjs +0 -198
- package/scripts/compress-project-memory.js +0 -58
- package/scripts/context-ops.mjs +0 -463
- package/scripts/dev.mjs +0 -349
- package/scripts/extract-global-knowledge.js +0 -52
- package/scripts/generate-dashboard.js +0 -59
- package/scripts/hook-guard-paths.mjs +0 -75
- package/scripts/hook-post-edit.mjs +0 -79
- package/scripts/hook-session-start.mjs +0 -104
- package/scripts/hook-user-prompt.mjs +0 -185
- package/scripts/pre-commit.sh +0 -102
- package/scripts/query-universal-memory.js +0 -50
- package/scripts/release-check.mjs +0 -56
- package/scripts/spec-cli.mjs +0 -260
- package/scripts/sprint-manager.js +0 -200
- package/scripts/sync-universal-memory.js +0 -286
- package/scripts/token-benchmark.mjs +0 -203
- package/scripts/tools-doctor.mjs +0 -132
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* bin/forja.mjs — core executivo do Forja (ADR-0020).
|
|
4
|
+
*
|
|
5
|
+
* Ponto de entrada único dos comandos de processo:
|
|
6
|
+
* forja <comando> [args]
|
|
7
|
+
*
|
|
8
|
+
* Responsabilidades transversais:
|
|
9
|
+
* 1. Roteamento via lib/core/registry.mjs (declarativo).
|
|
10
|
+
* 2. Gates antes do alvo (workspace, ADR-0019).
|
|
11
|
+
* 3. Trilha de auditoria append-only em .context/forja-runs.jsonl.
|
|
12
|
+
*/
|
|
13
|
+
import fs from 'node:fs';
|
|
14
|
+
import path from 'node:path';
|
|
15
|
+
import { spawnSync } from 'node:child_process';
|
|
16
|
+
import { fileURLToPath } from 'node:url';
|
|
17
|
+
import { COMMANDS, DOMAINS, resolveScript } from "../lib/core/registry.js";
|
|
18
|
+
import { getWorkspaceInfo, getWorkspaceContextDir } from "../lib/workspace.js";
|
|
19
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
20
|
+
const root = path.resolve(__dirname, '..');
|
|
21
|
+
function printHelp() {
|
|
22
|
+
console.log('Forja — core executivo (ADR-0020)');
|
|
23
|
+
console.log('Uso: forja <comando> [args]\n');
|
|
24
|
+
const byDomain = new Map();
|
|
25
|
+
for (const [name, cmd] of Object.entries(COMMANDS)) {
|
|
26
|
+
if (!byDomain.has(cmd.domain))
|
|
27
|
+
byDomain.set(cmd.domain, []);
|
|
28
|
+
byDomain.get(cmd.domain).push([name, cmd.desc]);
|
|
29
|
+
}
|
|
30
|
+
for (const [domain, label] of Object.entries(DOMAINS)) {
|
|
31
|
+
const entries = byDomain.get(domain);
|
|
32
|
+
if (!entries)
|
|
33
|
+
continue;
|
|
34
|
+
console.log(`${label}:`);
|
|
35
|
+
for (const [name, desc] of entries) {
|
|
36
|
+
console.log(` ${name.padEnd(24)} ${desc}`);
|
|
37
|
+
}
|
|
38
|
+
console.log('');
|
|
39
|
+
}
|
|
40
|
+
console.log('Toda execução é auditada em .context/forja-runs.jsonl (workspace, se existir).');
|
|
41
|
+
}
|
|
42
|
+
function suggest(input) {
|
|
43
|
+
const names = Object.keys(COMMANDS);
|
|
44
|
+
const prefix = input.split(':')[0];
|
|
45
|
+
const near = names.filter((n) => n.startsWith(prefix) || n.includes(input));
|
|
46
|
+
return near.slice(0, 5);
|
|
47
|
+
}
|
|
48
|
+
// Gates transversais (ADR-0020). Retorna lista de erros bloqueantes.
|
|
49
|
+
function runGates(cmd) {
|
|
50
|
+
const errors = [];
|
|
51
|
+
for (const gate of cmd.gates || []) {
|
|
52
|
+
if (gate === 'workspace' || gate === 'workspace-warn') {
|
|
53
|
+
const info = getWorkspaceInfo();
|
|
54
|
+
if (!info.exists) {
|
|
55
|
+
const msg = `Workspace não encontrado em ${info.root} (fonte: ${info.source}).`;
|
|
56
|
+
if (gate === 'workspace') {
|
|
57
|
+
errors.push(`${msg}\n Corrija com: forja workspace:init`);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
console.error(`Aviso: ${msg} Alguns dados podem cair no repo do framework.`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return errors;
|
|
66
|
+
}
|
|
67
|
+
// Auditoria nunca bloqueia o comando (NFR da SPEC-025).
|
|
68
|
+
function audit(entry) {
|
|
69
|
+
try {
|
|
70
|
+
const info = getWorkspaceInfo();
|
|
71
|
+
const dir = info.exists ? getWorkspaceContextDir() : path.join(root, '.context');
|
|
72
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
73
|
+
fs.appendFileSync(path.join(dir, 'forja-runs.jsonl'), JSON.stringify(entry) + '\n', 'utf8');
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
console.error(`Aviso: auditoria indisponível (${error.message}).`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const [name, ...rest] = process.argv.slice(2);
|
|
80
|
+
if (!name || name === 'help' || name === '--help' || name === '-h') {
|
|
81
|
+
printHelp();
|
|
82
|
+
process.exit(0);
|
|
83
|
+
}
|
|
84
|
+
const cmd = COMMANDS[name];
|
|
85
|
+
if (!cmd) {
|
|
86
|
+
console.error(`Comando desconhecido: ${name}`);
|
|
87
|
+
const near = suggest(name);
|
|
88
|
+
if (near.length) {
|
|
89
|
+
console.error(`Você quis dizer: ${near.join(', ')}?`);
|
|
90
|
+
}
|
|
91
|
+
console.error('Liste tudo com: forja help');
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
const gateErrors = runGates(cmd);
|
|
95
|
+
if (gateErrors.length) {
|
|
96
|
+
console.error(`Gate reprovado para ${name}:`);
|
|
97
|
+
for (const err of gateErrors)
|
|
98
|
+
console.error(`- ${err}`);
|
|
99
|
+
audit({
|
|
100
|
+
ts: new Date().toISOString(),
|
|
101
|
+
cmd: name,
|
|
102
|
+
args: rest,
|
|
103
|
+
exitCode: 1,
|
|
104
|
+
durationMs: 0,
|
|
105
|
+
gate: 'blocked',
|
|
106
|
+
});
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
109
|
+
const started = Date.now();
|
|
110
|
+
let result;
|
|
111
|
+
if (cmd.node) {
|
|
112
|
+
const script = resolveScript(root, cmd.node);
|
|
113
|
+
result = spawnSync('node', [script, ...(cmd.args || []), ...rest], {
|
|
114
|
+
cwd: root,
|
|
115
|
+
stdio: 'inherit',
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
result = spawnSync(cmd.bin, [...(cmd.args || []), ...rest], {
|
|
120
|
+
cwd: root,
|
|
121
|
+
stdio: 'inherit',
|
|
122
|
+
});
|
|
123
|
+
if (result.error && /** @type {any} */ (result.error).code === 'ENOENT') {
|
|
124
|
+
console.error(`Binário não encontrado no PATH: ${cmd.bin}. Veja: forja tools:doctor`);
|
|
125
|
+
result.status = 127;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const exitCode = result.status ?? 1;
|
|
129
|
+
audit({
|
|
130
|
+
ts: new Date().toISOString(),
|
|
131
|
+
cmd: name,
|
|
132
|
+
args: rest,
|
|
133
|
+
exitCode,
|
|
134
|
+
durationMs: Date.now() - started,
|
|
135
|
+
});
|
|
136
|
+
process.exit(exitCode);
|
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* init-project.js
|
|
4
|
+
*
|
|
5
|
+
* Comando universal para inicializar novo projeto com agentes orquestrados.
|
|
6
|
+
* Puxa configuração de Copilot, Claude, Gemini, Codex e outros.
|
|
7
|
+
*
|
|
8
|
+
* Uso:
|
|
9
|
+
* node bin/init-project.js meu-projeto
|
|
10
|
+
* node bin/init-project.js meu-projeto --ai copilot,claude,gemini
|
|
11
|
+
* node bin/init-project.js meu-projeto --skip-backend
|
|
12
|
+
* node bin/init-project.js --interactive
|
|
13
|
+
*/
|
|
14
|
+
import fs from 'node:fs';
|
|
15
|
+
import path from 'node:path';
|
|
16
|
+
import process from 'node:process';
|
|
17
|
+
import { execSync } from 'node:child_process';
|
|
18
|
+
import { fileURLToPath } from 'node:url';
|
|
19
|
+
import { getWorkspaceRoot, getProjectsDir, resolveProject, initWorkspace, getWorkspaceProjectsMemoryDir, assertOutsideFrameworkRepo, } from "../lib/workspace.js";
|
|
20
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
21
|
+
const __dirname = path.dirname(__filename);
|
|
22
|
+
const kitRoot = path.resolve(__dirname, '..');
|
|
23
|
+
// ============================================================================
|
|
24
|
+
// CONFIGURAÇÃO
|
|
25
|
+
// ============================================================================
|
|
26
|
+
const DEFAULT_AI_AGENTS = ['copilot', 'claude', 'gemini', 'codex'];
|
|
27
|
+
// Conteúdo canônico único (ADR-0020): toda IA recebe a mesma explicação da
|
|
28
|
+
// estrutura Forja; só o cabeçalho muda. CLAUDE.md do framework NÃO é copiado —
|
|
29
|
+
// ele descreve o repo do motor, não o projeto gerado.
|
|
30
|
+
const CANONICAL_INSTRUCTIONS = '.gemini-instructions.md';
|
|
31
|
+
const AI_LABELS = {
|
|
32
|
+
copilot: 'GitHub Copilot',
|
|
33
|
+
claude: 'Claude',
|
|
34
|
+
gemini: 'Gemini',
|
|
35
|
+
codex: 'OpenAI Codex',
|
|
36
|
+
};
|
|
37
|
+
const SETUP_CHECKLIST = [
|
|
38
|
+
'00-git-init',
|
|
39
|
+
'01-generate-structure',
|
|
40
|
+
'01b-copy-design-library',
|
|
41
|
+
'01c-emit-harness',
|
|
42
|
+
'02-copy-instructions',
|
|
43
|
+
'03-install-backend',
|
|
44
|
+
'04-init-memory-db',
|
|
45
|
+
'05-build-context-pack',
|
|
46
|
+
'06-universal-memory-sync',
|
|
47
|
+
'07-show-next-steps',
|
|
48
|
+
];
|
|
49
|
+
// ============================================================================
|
|
50
|
+
// HELPERS
|
|
51
|
+
// ============================================================================
|
|
52
|
+
function log(msg, level = 'info') {
|
|
53
|
+
const prefix = {
|
|
54
|
+
info: '📌',
|
|
55
|
+
success: '✅',
|
|
56
|
+
warn: '⚠️',
|
|
57
|
+
error: '❌',
|
|
58
|
+
step: '🔄',
|
|
59
|
+
done: '✨',
|
|
60
|
+
}[level] || '→';
|
|
61
|
+
console.log(`${prefix} ${msg}`);
|
|
62
|
+
}
|
|
63
|
+
function logSection(title) {
|
|
64
|
+
console.log(`\n${'═'.repeat(80)}`);
|
|
65
|
+
console.log(` ${title}`);
|
|
66
|
+
console.log(`${'═'.repeat(80)}\n`);
|
|
67
|
+
}
|
|
68
|
+
function execCmd(cmd, opts = {}) {
|
|
69
|
+
try {
|
|
70
|
+
return execSync(cmd, {
|
|
71
|
+
stdio: opts.quiet ? 'pipe' : 'inherit',
|
|
72
|
+
...opts
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
if (!opts.ignoreError) {
|
|
77
|
+
log(`Comando falhou: ${cmd}`, 'error');
|
|
78
|
+
throw err;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function ensureDir(dir) {
|
|
83
|
+
if (!fs.existsSync(dir)) {
|
|
84
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function copyFile(src, dest) {
|
|
88
|
+
const content = fs.readFileSync(src, 'utf-8');
|
|
89
|
+
fs.writeFileSync(dest, content, 'utf-8');
|
|
90
|
+
}
|
|
91
|
+
function copyFileIfExists(src, dest) {
|
|
92
|
+
if (fs.existsSync(src)) {
|
|
93
|
+
copyFile(src, dest);
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
function copyDir(src, dest) {
|
|
99
|
+
ensureDir(dest);
|
|
100
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
101
|
+
for (const entry of entries) {
|
|
102
|
+
const srcPath = path.join(src, entry.name);
|
|
103
|
+
const destPath = path.join(dest, entry.name);
|
|
104
|
+
if (entry.isDirectory()) {
|
|
105
|
+
copyDir(srcPath, destPath);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
fs.copyFileSync(srcPath, destPath);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// ============================================================================
|
|
113
|
+
// PARSEARGS
|
|
114
|
+
// ============================================================================
|
|
115
|
+
function parseArgs() {
|
|
116
|
+
const args = process.argv.slice(2);
|
|
117
|
+
const opts = {
|
|
118
|
+
interactive: args.includes('--interactive'),
|
|
119
|
+
skipBackend: args.includes('--skip-backend'),
|
|
120
|
+
skipDb: args.includes('--skip-db'),
|
|
121
|
+
skipGit: args.includes('--skip-git'),
|
|
122
|
+
skipDesign: args.includes('--skip-design'),
|
|
123
|
+
ai: DEFAULT_AI_AGENTS,
|
|
124
|
+
verbose: args.includes('--verbose'),
|
|
125
|
+
};
|
|
126
|
+
// Parse --ai flag
|
|
127
|
+
const aiIdx = args.findIndex(a => a === '--ai');
|
|
128
|
+
if (aiIdx >= 0 && aiIdx + 1 < args.length) {
|
|
129
|
+
opts.ai = args[aiIdx + 1].split(',').map(s => s.trim());
|
|
130
|
+
}
|
|
131
|
+
// Project name (primeiro arg sem --)
|
|
132
|
+
const projectName = args.find(a => !a.startsWith('--'));
|
|
133
|
+
// Projetos de produto vivem obrigatoriamente no workspace externo.
|
|
134
|
+
// init-project nao aceita mais path customizado para evitar poluicao do repo do framework.
|
|
135
|
+
const projectDir = projectName ? resolveProject(projectName) : null;
|
|
136
|
+
return { projectName, projectPath: projectDir, opts };
|
|
137
|
+
}
|
|
138
|
+
// ============================================================================
|
|
139
|
+
// SETUP STEPS
|
|
140
|
+
// ============================================================================
|
|
141
|
+
async function step00GitInit(projectDir, opts) {
|
|
142
|
+
if (opts.skipGit)
|
|
143
|
+
return;
|
|
144
|
+
log('Preparando diretório...', 'step');
|
|
145
|
+
ensureDir(projectDir);
|
|
146
|
+
// Se for um sub-projeto dentro do repo principal, talvez não queira git init
|
|
147
|
+
// Mas se for independente, git init faz sentido.
|
|
148
|
+
// Como o usuário quer ignorar a pasta projects/, podemos opcionalmente dar git init.
|
|
149
|
+
if (!fs.existsSync(path.join(projectDir, '.git'))) {
|
|
150
|
+
try {
|
|
151
|
+
execCmd(`cd "${projectDir}" && git init`, { quiet: true });
|
|
152
|
+
// Criar .gitignore se não existir
|
|
153
|
+
const gitignore = path.join(projectDir, '.gitignore');
|
|
154
|
+
if (!fs.existsSync(gitignore)) {
|
|
155
|
+
fs.writeFileSync(gitignore, `node_modules/\n.env\n.env.local\ndist/\n.DS_Store\n.context/\n.memory/\n`);
|
|
156
|
+
}
|
|
157
|
+
log('Git repository inicializado no projeto', 'success');
|
|
158
|
+
}
|
|
159
|
+
catch (e) {
|
|
160
|
+
log('Aviso: falha ao rodar git init (talvez diretório já em repo git)', 'warn');
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
async function step01GenerateStructure(projectDir, opts) {
|
|
165
|
+
log('Gerando estrutura de agentes e memória...', 'step');
|
|
166
|
+
// Verifica se já existe código (ex: backend) para decidir se usa --only-memory
|
|
167
|
+
const hasBackend = fs.existsSync(path.join(projectDir, 'backend')) || fs.existsSync(path.join(projectDir, 'package.json'));
|
|
168
|
+
const onlyMemory = hasBackend ? '--only-memory' : '';
|
|
169
|
+
const cmd = opts.skipBackend
|
|
170
|
+
? `node "${path.join(kitRoot, 'bin/create-memory-nest-kit.js')}" "${projectDir}" --only-memory --force`
|
|
171
|
+
: `node "${path.join(kitRoot, 'bin/create-memory-nest-kit.js')}" "${projectDir}" ${onlyMemory} --force`;
|
|
172
|
+
try {
|
|
173
|
+
execCmd(cmd);
|
|
174
|
+
log('Estrutura gerada com sucesso', 'success');
|
|
175
|
+
// Adicionar camadas extras de escalonamento e growth
|
|
176
|
+
addScalingLayers(projectDir);
|
|
177
|
+
}
|
|
178
|
+
catch (err) {
|
|
179
|
+
log('Erro ao gerar estrutura', 'error');
|
|
180
|
+
throw err;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function addScalingLayers(projectDir) {
|
|
184
|
+
const memoryDir = path.join(projectDir, 'memory');
|
|
185
|
+
const layers = {
|
|
186
|
+
'10-product/growth/vision.md': '# Estratégia de Growth\n\nDescreva como o produto irá crescer e atrair novos usuários.',
|
|
187
|
+
'10-product/scaling/strategy.md': '# Estratégia de Escalonamento de Produto\n\nDescreva como o produto irá suportar o aumento de carga e usuários.',
|
|
188
|
+
'20-architecture/scaling-patterns.md': '# Padrões de Escalonamento Arquitetural\n\n- Cache\n- Filas\n- Microsserviços\n- Otimização de Queries',
|
|
189
|
+
};
|
|
190
|
+
for (const [rel, content] of Object.entries(layers)) {
|
|
191
|
+
const abs = path.join(memoryDir, rel);
|
|
192
|
+
ensureDir(path.dirname(abs));
|
|
193
|
+
if (!fs.existsSync(abs)) {
|
|
194
|
+
fs.writeFileSync(abs, content, 'utf8');
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
log('Camadas de Growth e Scaling adicionadas', 'success');
|
|
198
|
+
}
|
|
199
|
+
async function step01bCopyDesignLibrary(projectDir, opts) {
|
|
200
|
+
if (opts.skipDesign) {
|
|
201
|
+
log('Skipping design library copy (--skip-design)', 'warn');
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const srcDesignDir = path.join(kitRoot, 'design-md');
|
|
205
|
+
const destDesignDir = path.join(projectDir, 'design-md');
|
|
206
|
+
if (!fs.existsSync(srcDesignDir)) {
|
|
207
|
+
log('Biblioteca de design não encontrada no kit root', 'warn');
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
log('Copiando biblioteca de referências de design (design-md)...', 'step');
|
|
211
|
+
try {
|
|
212
|
+
copyDir(srcDesignDir, destDesignDir);
|
|
213
|
+
log('Biblioteca design-md copiada para o projeto', 'success');
|
|
214
|
+
}
|
|
215
|
+
catch (err) {
|
|
216
|
+
log('Erro ao copiar biblioteca de design', 'error');
|
|
217
|
+
if (opts.verbose)
|
|
218
|
+
console.error(err);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
// Camada de code intelligence + ferramentas de processo (ADR-0017, ADR-0018).
|
|
222
|
+
// Cada projeto gerado herda codegraph (MCP) + scripts code:* + tools:doctor,
|
|
223
|
+
// de forma auto-contida (so dependem do binario codegraph, opcional).
|
|
224
|
+
const HARNESS_SCRIPTS = {
|
|
225
|
+
'code:index': 'codegraph init',
|
|
226
|
+
'code:sync': 'codegraph sync',
|
|
227
|
+
'code:status': 'codegraph status',
|
|
228
|
+
'code:query': 'codegraph query',
|
|
229
|
+
'code:check': 'node scripts/code-intel.mjs check',
|
|
230
|
+
'code:impact': 'node scripts/code-intel.mjs impact',
|
|
231
|
+
'tools:doctor': 'node scripts/tools-doctor.mjs',
|
|
232
|
+
};
|
|
233
|
+
async function step01cEmitHarness(projectDir, opts) {
|
|
234
|
+
log('Emitindo harness de code intelligence (codegraph + tools)...', 'step');
|
|
235
|
+
// 1. .mcp.json (codegraph) — aditivo, nao sobrescreve config existente
|
|
236
|
+
const mcpDest = path.join(projectDir, '.mcp.json');
|
|
237
|
+
const mcpSrc = path.join(kitRoot, 'lib/templates/harness/mcp.json');
|
|
238
|
+
if (!fs.existsSync(mcpDest)) {
|
|
239
|
+
copyFileIfExists(mcpSrc, mcpDest);
|
|
240
|
+
}
|
|
241
|
+
// 2. scripts auto-contidos
|
|
242
|
+
const scriptsDir = path.join(projectDir, 'scripts');
|
|
243
|
+
ensureDir(scriptsDir);
|
|
244
|
+
copyFileIfExists(path.join(kitRoot, 'lib/templates/harness/code-intel.mjs'), path.join(scriptsDir, 'code-intel.mjs'));
|
|
245
|
+
copyFileIfExists(path.join(kitRoot, 'scripts/tools-doctor.mjs'), path.join(scriptsDir, 'tools-doctor.mjs'));
|
|
246
|
+
// 3. merge dos scripts no package.json (cria minimo se ausente)
|
|
247
|
+
const pkgPath = path.join(projectDir, 'package.json');
|
|
248
|
+
let pkg;
|
|
249
|
+
if (fs.existsSync(pkgPath)) {
|
|
250
|
+
try {
|
|
251
|
+
pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
252
|
+
}
|
|
253
|
+
catch {
|
|
254
|
+
log('package.json ilegivel; harness scripts nao injetados', 'warn');
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
pkg = { name: path.basename(projectDir), version: '0.1.0', type: 'module', scripts: {} };
|
|
260
|
+
}
|
|
261
|
+
pkg.scripts = pkg.scripts || {};
|
|
262
|
+
for (const [key, value] of Object.entries(HARNESS_SCRIPTS)) {
|
|
263
|
+
if (!pkg.scripts[key])
|
|
264
|
+
pkg.scripts[key] = value;
|
|
265
|
+
}
|
|
266
|
+
fs.writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`, 'utf8');
|
|
267
|
+
log('Harness emitido: .mcp.json + code:* + tools:doctor', 'success');
|
|
268
|
+
}
|
|
269
|
+
async function step02CopyInstructions(projectDir, opts) {
|
|
270
|
+
log('Copiando instruções para IAs...', 'step');
|
|
271
|
+
const instructionsDir = path.join(projectDir, '.ia-instructions');
|
|
272
|
+
ensureDir(instructionsDir);
|
|
273
|
+
const canonicalPath = path.join(kitRoot, CANONICAL_INSTRUCTIONS);
|
|
274
|
+
let canonical = null;
|
|
275
|
+
if (fs.existsSync(canonicalPath)) {
|
|
276
|
+
canonical = fs.readFileSync(canonicalPath, 'utf8');
|
|
277
|
+
}
|
|
278
|
+
let copied = 0;
|
|
279
|
+
for (const ai of opts.ai) {
|
|
280
|
+
const label = AI_LABELS[ai];
|
|
281
|
+
if (!label || !canonical) {
|
|
282
|
+
log(`${ai.toUpperCase()}: não encontrado`, 'warn');
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
const others = Object.entries(AI_LABELS)
|
|
286
|
+
.filter(([key]) => key !== ai)
|
|
287
|
+
.map(([, name]) => name);
|
|
288
|
+
const content = canonical
|
|
289
|
+
.replace(/^# Instruções para .+ — Forja$/m, `# Instruções para ${label} — Forja`)
|
|
290
|
+
.replace(/^> Guia para .+ multi-IA por design\.$/m, `> Guia para ${label} operar a Forja. O conteúdo é o mesmo para ${others.slice(0, -1).join(', ')} e ${others.at(-1)} — a Forja é multi-IA por design.`);
|
|
291
|
+
fs.writeFileSync(path.join(instructionsDir, `${ai}.md`), content, 'utf8');
|
|
292
|
+
log(`${ai.toUpperCase()}: ✓`, 'success');
|
|
293
|
+
copied++;
|
|
294
|
+
}
|
|
295
|
+
// Criar INDEX
|
|
296
|
+
const indexContent = `# IA Assistants Configuration
|
|
297
|
+
|
|
298
|
+
Este diretório contém instruções específicas para cada IA assistant.
|
|
299
|
+
|
|
300
|
+
## Gestão de Cotas & Alternância
|
|
301
|
+
Para trocar de IA (ex: se acabar a cota), use o arquivo [models.json](./models.json) para identificar o próximo motor na fila de fallback.
|
|
302
|
+
|
|
303
|
+
## IAs Configuradas
|
|
304
|
+
|
|
305
|
+
${opts.ai.map(ai => `- [${ai.toUpperCase()}](./${ai}.md)`).join('\n')}
|
|
306
|
+
`;
|
|
307
|
+
fs.writeFileSync(path.join(instructionsDir, 'README.md'), indexContent);
|
|
308
|
+
// Criar models.json para interoperabilidade
|
|
309
|
+
const modelsJson = {
|
|
310
|
+
active_engine: opts.ai[0] || 'copilot',
|
|
311
|
+
fallback_chain: opts.ai,
|
|
312
|
+
engines: opts.ai.reduce((acc, ai) => {
|
|
313
|
+
acc[ai] = {
|
|
314
|
+
name: ai.toUpperCase(),
|
|
315
|
+
instruction_file: `.ia-instructions/${ai}.md`,
|
|
316
|
+
status: "ready"
|
|
317
|
+
};
|
|
318
|
+
return acc;
|
|
319
|
+
}, {})
|
|
320
|
+
};
|
|
321
|
+
fs.writeFileSync(path.join(instructionsDir, 'models.json'), JSON.stringify(modelsJson, null, 2));
|
|
322
|
+
log(`${copied} instruções copiadas para .ia-instructions/`, 'success');
|
|
323
|
+
}
|
|
324
|
+
async function step03InstallBackend(projectDir, opts) {
|
|
325
|
+
if (opts.skipBackend) {
|
|
326
|
+
log('Skipping backend install (--skip-backend)', 'warn');
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
const backendDir = path.join(projectDir, 'backend');
|
|
330
|
+
if (!fs.existsSync(backendDir)) {
|
|
331
|
+
log('Backend directory não encontrado', 'warn');
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
log('Instalando dependências do backend...', 'step');
|
|
335
|
+
try {
|
|
336
|
+
execCmd(`cd "${backendDir}" && npm install --quiet`, { quiet: true });
|
|
337
|
+
log('npm install concluído', 'success');
|
|
338
|
+
}
|
|
339
|
+
catch (err) {
|
|
340
|
+
log('Erro ao rodar npm install', 'error');
|
|
341
|
+
if (!opts.verbose) {
|
|
342
|
+
log('Use --verbose para mais detalhes', 'warn');
|
|
343
|
+
}
|
|
344
|
+
// Não falha o setup inteiro
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
async function step04InitMemoryDb(projectDir, opts) {
|
|
348
|
+
if (opts.skipDb || opts.skipBackend) {
|
|
349
|
+
log('Skipping DB init', 'warn');
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
const backendDir = path.join(projectDir, 'backend');
|
|
353
|
+
const scriptPath = path.join(backendDir, 'scripts/memory-db-init.mjs');
|
|
354
|
+
if (!fs.existsSync(scriptPath)) {
|
|
355
|
+
log('Script de init DB não encontrado', 'warn');
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
log('Inicializando banco de dados SQLite...', 'step');
|
|
359
|
+
try {
|
|
360
|
+
execCmd(`cd "${backendDir}" && npm run memory:db:init 2>/dev/null`, { quiet: true, ignoreError: true });
|
|
361
|
+
log('SQLite inicializado em .memory/sqlite/context.db', 'success');
|
|
362
|
+
}
|
|
363
|
+
catch (err) {
|
|
364
|
+
log('Erro ao inicializar DB', 'warn');
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
async function step05BuildContextPack(projectDir, opts) {
|
|
368
|
+
const scriptsDir = path.join(projectDir, 'scripts');
|
|
369
|
+
const scriptPath = path.join(scriptsDir, 'build-context-pack.mjs');
|
|
370
|
+
if (!fs.existsSync(scriptPath)) {
|
|
371
|
+
log('Script context-pack não encontrado', 'warn');
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
log('Construindo context pack...', 'step');
|
|
375
|
+
try {
|
|
376
|
+
execCmd(`cd "${projectDir}" && node scripts/build-context-pack.mjs 2>/dev/null`, { quiet: true, ignoreError: true });
|
|
377
|
+
log('Context pack criado em .context/context-pack.md', 'success');
|
|
378
|
+
}
|
|
379
|
+
catch (err) {
|
|
380
|
+
log('Erro ao criar context pack', 'warn');
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
async function step06UniversalMemorySync(projectDir, opts) {
|
|
384
|
+
log('Sincronizando com Memória Universal...', 'step');
|
|
385
|
+
const projectName = path.basename(projectDir);
|
|
386
|
+
const rootMemoryDir = getWorkspaceProjectsMemoryDir();
|
|
387
|
+
ensureDir(rootMemoryDir);
|
|
388
|
+
const projectInfoFile = path.join(rootMemoryDir, `${projectName}.md`);
|
|
389
|
+
const content = `# Projeto: ${projectName}\n\n- **Status**: Ativo\n- **Diretório**: ${projectDir}\n- **Workspace**: ${getWorkspaceRoot()}\n- **Criado em**: ${new Date().toISOString()}\n\n## Descrição\n(Descreva o projeto aqui)\n`;
|
|
390
|
+
if (!fs.existsSync(projectInfoFile)) {
|
|
391
|
+
fs.writeFileSync(projectInfoFile, content, 'utf8');
|
|
392
|
+
}
|
|
393
|
+
log(`Projeto ${projectName} registrado na Memória Universal do workspace`, 'success');
|
|
394
|
+
}
|
|
395
|
+
async function step07ShowNextSteps(projectDir, opts) {
|
|
396
|
+
const relPath = path.relative(process.cwd(), projectDir) || '.';
|
|
397
|
+
logSection('✨ SETUP COMPLETO!');
|
|
398
|
+
console.log(`📁 Projeto criado em: ${relPath}\n`);
|
|
399
|
+
console.log('📚 Próximos Passos:\n');
|
|
400
|
+
console.log(` 1. Entrar no projeto:`);
|
|
401
|
+
console.log(` cd ${relPath}\n`);
|
|
402
|
+
console.log(` 2. Ver estrutura de memória:`);
|
|
403
|
+
console.log(` ls -la memory/\n`);
|
|
404
|
+
console.log(` 3. Carregar instruções para IA:`);
|
|
405
|
+
console.log(` cat .ia-instructions/copilot.md`);
|
|
406
|
+
console.log(` cat .ia-instructions/claude.md\n`);
|
|
407
|
+
if (!opts.skipBackend) {
|
|
408
|
+
console.log(` 4. Iniciar backend em dev mode:`);
|
|
409
|
+
console.log(` cd backend && npm run start:dev\n`);
|
|
410
|
+
console.log(` 5. Rodar testes:`);
|
|
411
|
+
console.log(` cd backend && npm test\n`);
|
|
412
|
+
}
|
|
413
|
+
console.log(` 6. Atualizar documentação em memory/\n`);
|
|
414
|
+
console.log(` 7. Sincronizar contexto com BD:`);
|
|
415
|
+
console.log(` cd backend && npm run memory:db:sync\n`);
|
|
416
|
+
console.log(` 8. Limpar memória antiga (Vacuum):`);
|
|
417
|
+
console.log(` node scripts/memory-vacuum.mjs\n`);
|
|
418
|
+
console.log(` 9. Consultar contexto:`);
|
|
419
|
+
console.log(` cd backend && npm run memory:db:query -- "search" "auth" 10\n`);
|
|
420
|
+
console.log('📖 Recursos:');
|
|
421
|
+
console.log(` • Documentação: cat memory/README.md`);
|
|
422
|
+
console.log(` • Agentes: cat AGENTS.md`);
|
|
423
|
+
console.log(` • Decisões: cat memory/90-decisions/ADR-*.md\n`);
|
|
424
|
+
console.log('🤖 Instruções para IAs:');
|
|
425
|
+
for (const ai of opts.ai) {
|
|
426
|
+
const aiFile = path.join(relPath, `.ia-instructions/${ai}.md`);
|
|
427
|
+
console.log(` • ${ai.toUpperCase()}: .ia-instructions/${ai}.md`);
|
|
428
|
+
}
|
|
429
|
+
console.log('\n🚀 Tudo pronto! Comece a codificar!\n');
|
|
430
|
+
}
|
|
431
|
+
// ============================================================================
|
|
432
|
+
// MAIN
|
|
433
|
+
// ============================================================================
|
|
434
|
+
async function main() {
|
|
435
|
+
const { projectName, projectPath, opts } = parseArgs();
|
|
436
|
+
if (!projectName && !opts.interactive) {
|
|
437
|
+
console.log(`
|
|
438
|
+
init-project v0.6.0 (Workspace separado)
|
|
439
|
+
|
|
440
|
+
Cria projetos de produto no workspace Forja (padrão: ~/forja-workspace/projects).
|
|
441
|
+
O repositório do framework permanece isolado.
|
|
442
|
+
|
|
443
|
+
Uso: node bin/init-project.js <project-name> [opções]
|
|
444
|
+
|
|
445
|
+
Opções:
|
|
446
|
+
--ai <list> IAs para configurar (padrão: copilot,claude,gemini,codex)
|
|
447
|
+
--skip-backend Pula instalação do backend NestJS
|
|
448
|
+
--skip-db Pula inicialização do SQLite
|
|
449
|
+
--skip-git Pula inicialização do Git
|
|
450
|
+
--skip-design Pula cópia da biblioteca design-md
|
|
451
|
+
--interactive Modo interativo
|
|
452
|
+
--verbose Output detalhado
|
|
453
|
+
|
|
454
|
+
Workspace:
|
|
455
|
+
O caminho é resolvido por prioridade:
|
|
456
|
+
1. Variável de ambiente FORJA_WORKSPACE
|
|
457
|
+
2. Campo workspaceRoot em ~/.forjarc.json
|
|
458
|
+
3. Padrão: ~/forja-workspace
|
|
459
|
+
|
|
460
|
+
Exemplos:
|
|
461
|
+
node bin/init-project.js meu-projeto
|
|
462
|
+
node bin/init-project.js meu-projeto --ai copilot,claude
|
|
463
|
+
node bin/init-project.js meu-projeto --skip-backend
|
|
464
|
+
node bin/init-project.js --interactive
|
|
465
|
+
`);
|
|
466
|
+
process.exit(0);
|
|
467
|
+
}
|
|
468
|
+
let target = projectName;
|
|
469
|
+
// Interactive mode
|
|
470
|
+
if (opts.interactive || !projectName) {
|
|
471
|
+
logSection('🎯 Modo Interativo');
|
|
472
|
+
// Simular input (em produção, usar package como prompt ou readline)
|
|
473
|
+
target = projectName || 'meu-projeto';
|
|
474
|
+
log(`Projeto: ${target}`, 'info');
|
|
475
|
+
log(`IAs: ${opts.ai.join(', ')}`, 'info');
|
|
476
|
+
}
|
|
477
|
+
// Garante workspace pronto
|
|
478
|
+
initWorkspace();
|
|
479
|
+
const projectDir = projectPath || resolveProject(target);
|
|
480
|
+
assertOutsideFrameworkRepo(projectDir, 'init-project');
|
|
481
|
+
logSection('🚀 Inicializando Novo Projeto com Agentes Orquestrados');
|
|
482
|
+
log(`Workspace ativo: ${getWorkspaceRoot()}`, 'info');
|
|
483
|
+
log(`Projeto: ${projectDir}`, 'info');
|
|
484
|
+
try {
|
|
485
|
+
// Executar checklist de setup
|
|
486
|
+
for (const step of SETUP_CHECKLIST) {
|
|
487
|
+
if (step === '00-git-init')
|
|
488
|
+
await step00GitInit(projectDir, opts);
|
|
489
|
+
else if (step === '01-generate-structure')
|
|
490
|
+
await step01GenerateStructure(projectDir, opts);
|
|
491
|
+
else if (step === '01b-copy-design-library')
|
|
492
|
+
await step01bCopyDesignLibrary(projectDir, opts);
|
|
493
|
+
else if (step === '01c-emit-harness')
|
|
494
|
+
await step01cEmitHarness(projectDir, opts);
|
|
495
|
+
else if (step === '02-copy-instructions')
|
|
496
|
+
await step02CopyInstructions(projectDir, opts);
|
|
497
|
+
else if (step === '03-install-backend')
|
|
498
|
+
await step03InstallBackend(projectDir, opts);
|
|
499
|
+
else if (step === '04-init-memory-db')
|
|
500
|
+
await step04InitMemoryDb(projectDir, opts);
|
|
501
|
+
else if (step === '05-build-context-pack')
|
|
502
|
+
await step05BuildContextPack(projectDir, opts);
|
|
503
|
+
else if (step === '06-universal-memory-sync')
|
|
504
|
+
await step06UniversalMemorySync(projectDir, opts);
|
|
505
|
+
else if (step === '07-show-next-steps')
|
|
506
|
+
await step07ShowNextSteps(projectDir, opts);
|
|
507
|
+
}
|
|
508
|
+
log('Init completo!', 'done');
|
|
509
|
+
process.exit(0);
|
|
510
|
+
}
|
|
511
|
+
catch (err) {
|
|
512
|
+
console.error('\n❌ Erro durante setup:', err.message);
|
|
513
|
+
process.exit(1);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
main();
|