@lugom.io/hefesto 0.2.0 → 1.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/agents/hefesto-argos.md +93 -0
- package/agents/hefesto-athena.md +99 -0
- package/agents/hefesto-hermes.md +96 -0
- package/bin/install.js +122 -52
- package/hooks/hefesto-check-update.cjs +32 -11
- package/hooks/hefesto-statusline.cjs +8 -17
- package/hooks/hefesto-workflow.cjs +68 -0
- package/package.json +14 -4
- package/skills/hefesto-context/SKILL.md +67 -14
- package/skills/hefesto-debug/SKILL.md +54 -0
- package/skills/hefesto-design/SKILL.md +184 -0
- package/skills/hefesto-execute/SKILL.md +133 -0
- package/skills/hefesto-init/SKILL.md +105 -0
- package/skills/hefesto-init/references/api.md +116 -0
- package/skills/hefesto-init/references/cli.md +91 -0
- package/skills/hefesto-init/references/mobile.md +69 -0
- package/skills/hefesto-init/references/web.md +246 -0
- package/skills/hefesto-new-feature/SKILL.md +87 -0
- package/skills/hefesto-security/SKILL.md +89 -0
- package/skills/hefesto-security/references/boundaries-and-bypasses.md +152 -0
- package/skills/hefesto-security/references/secrets-detection.md +121 -0
- package/skills/hefesto-security/references/severity-and-judgment.md +176 -0
- package/skills/hefesto-simplify/SKILL.md +82 -0
- package/templates/TPL-CLAUDE.md +54 -0
- package/templates/TPL-CONFIG.json +19 -0
- package/templates/TPL-DESIGN.md +305 -0
- package/templates/{FEATURE.md → TPL-FEATURE.md} +13 -6
- package/templates/TPL-PROJECT.md +50 -0
- package/templates/TPL-RECON.md +60 -0
- package/templates/{RESEARCH.md → TPL-RESEARCH.md} +32 -35
- package/templates/TPL-SECURITY.md +42 -0
- package/templates/TPL-SIMPLIFY.md +40 -0
- package/templates/{STATE.md → TPL-STATE.md} +1 -7
- package/templates/TPL-VERDICT.md +34 -0
- package/agents/.gitkeep +0 -0
- package/agents/hefesto-researcher.md +0 -180
- package/commands/hefesto/init.md +0 -67
- package/commands/hefesto/new-feature.md +0 -50
- package/commands/hefesto/status.md +0 -46
- package/commands/hefesto/update.md +0 -31
- package/templates/PROJECT.md +0 -28
- package/templates/ROADMAP.md +0 -23
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: hefesto-init
|
|
3
|
+
description: >
|
|
4
|
+
Inicializa um projeto com Hefesto. Dois modos: (1) projeto novo — scaffold com stack
|
|
5
|
+
pré-definida (web/cli/api/mobile); (2) projeto existente — analisa codebase, cria .hefesto/
|
|
6
|
+
e gera CLAUDE.md.
|
|
7
|
+
Usar com: /hefesto-init.
|
|
8
|
+
user-invocable: true
|
|
9
|
+
disable-model-invocation: true
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Hefesto Init
|
|
13
|
+
|
|
14
|
+
Inicializa um projeto com a estrutura `.hefesto/`, gera `CLAUDE.md` e, opcionalmente, faz scaffold do código base. Para projetos existentes, faz uma varredura automática do codebase para detectar stack, plataforma, convenções e comandos.
|
|
15
|
+
|
|
16
|
+
## Fluxo
|
|
17
|
+
|
|
18
|
+
### Fase 1 — Verificar estado
|
|
19
|
+
|
|
20
|
+
1. Verificar se `.hefesto/` já existe (`Bash: ls .hefesto/ 2>/dev/null`)
|
|
21
|
+
2. Se existir:
|
|
22
|
+
- Ler `.hefesto/PROJECT.md` — se contém `{{PROJECT_NAME}}` → install fresco, prosseguir
|
|
23
|
+
- Senão → já configurado. Seletor: **Reinicializar** (apaga e recria, avisa sobre features existentes) / **Atualizar** (re-varredura, preserva features/) / **Cancelar**
|
|
24
|
+
3. Se não existir → Fase 2
|
|
25
|
+
|
|
26
|
+
### Fase 2 — Tipo de projeto
|
|
27
|
+
|
|
28
|
+
Seletor: **Novo** → Fase 3A | **Existente** → Fase 3B.1
|
|
29
|
+
|
|
30
|
+
### Fase 3A — Scaffold de projeto novo
|
|
31
|
+
|
|
32
|
+
1. Seletor de **plataforma**:
|
|
33
|
+
- `web` — Next.js + TypeScript + TailwindCSS + shadcn/ui
|
|
34
|
+
- `cli` — Node.js + TypeScript + ES Modules
|
|
35
|
+
- `api` — Node.js + TypeScript + Fastify
|
|
36
|
+
- `mobile` — React Native + Expo + NativeWind
|
|
37
|
+
|
|
38
|
+
2. Ler `references/{plataforma}.md` (relativo a esta skill)
|
|
39
|
+
3. Executar scaffold conforme a referência
|
|
40
|
+
4. Coletar do usuário: **Nome** (sugerir dir atual), **Descrição** (2-3 frases), **Valor central**, **Prazo/restrições**
|
|
41
|
+
|
|
42
|
+
### Fase 3B.1 — Varredura do codebase
|
|
43
|
+
|
|
44
|
+
Análise rápida (~10 reads) para detectar informações do projeto:
|
|
45
|
+
|
|
46
|
+
**Passo 1 — Manifesto**: Glob por `package.json`, `pyproject.toml`, `go.mod`, `Cargo.toml`, `Gemfile`, `pom.xml`, `pubspec.yaml`. Se nenhum → modo manual (Fase 3B.2).
|
|
47
|
+
|
|
48
|
+
**Passo 2 — Identidade**: Nome, descrição, dependências, scripts do manifesto. Fallback: README.md (primeiras 30 linhas).
|
|
49
|
+
|
|
50
|
+
**Passo 3 — Linguagem** (por prioridade): tsconfig.json → TypeScript | jsconfig.json/package.json → JavaScript | pyproject.toml/requirements.txt → Python | go.mod → Go | Cargo.toml → Rust | Gemfile → Ruby | pubspec.yaml → Dart. Se ambíguo, contar arquivos por extensão.
|
|
51
|
+
|
|
52
|
+
**Passo 4 — Plataforma**: Inferir das dependências — frameworks web → `web`, react-native/expo → `mobile`, express/fastify/flask/etc sem frontend → `api`, campo bin → `cli`, exports sem bin/web → `library`, frontend + backend → `fullstack`, nenhum → `other`.
|
|
53
|
+
|
|
54
|
+
**Passo 5 — Monorepo**: workspaces em package.json, lerna.json, nx.json, turbo.json, pnpm-workspace.yaml.
|
|
55
|
+
|
|
56
|
+
**Passo 6 — Comandos**: Extrair de package.json scripts (dev, build, test, lint, format) ou Makefile.
|
|
57
|
+
|
|
58
|
+
**Passo 7 — Arquitetura**: Listar dirs em `src/` — features/modules/domains → feature-based | controllers/services/models → layered | app/pages → file-based routing. Detectar formatação: Prettier, ESLint, Biome, EditorConfig.
|
|
59
|
+
|
|
60
|
+
### Fase 3B.2 — Confirmação
|
|
61
|
+
|
|
62
|
+
Apresentar resultado da varredura em tabela (Campo | Detectado | Fonte). O usuário confirma ou ajusta.
|
|
63
|
+
|
|
64
|
+
Perguntar apenas o não-detectável: **Valor central** (sempre), **Prazo** (sempre), **Descrição** (se não detectada). Se varredura pulada, coletar tudo manualmente.
|
|
65
|
+
|
|
66
|
+
### Fase 4 — Criar estrutura .hefesto/
|
|
67
|
+
|
|
68
|
+
Criar os artefatos listados em `/hefesto-context` (seção "Estrutura `.hefesto/`"): `PROJECT.md`, `STATE.md`, `config.json`, `features/`, `research/`.
|
|
69
|
+
|
|
70
|
+
### Fase 5 — Preencher arquivos
|
|
71
|
+
|
|
72
|
+
Ler os templates em `.hefesto/templates/TPL-*.md` (já copiados pelo instalador) e substituir os placeholders `{{...}}` com os dados coletados.
|
|
73
|
+
|
|
74
|
+
**PROJECT.md**: Dados do projeto, valor central, stack, convenções. Para projetos novos, copiar convenções do reference file. Para existentes, gerar da varredura. Preencher `{{RECIPES}}` com a seção "Receitas" do reference file do preset — lista curta com nome e quando usar cada receita.
|
|
75
|
+
|
|
76
|
+
**STATE.md**: Data e foco inicial.
|
|
77
|
+
|
|
78
|
+
**config.json**: Atualizar seção `project` (name, description, platform, lang, monorepo). Valores vêm do preset (novos) ou da varredura (existentes). Não alterar demais seções.
|
|
79
|
+
|
|
80
|
+
**verification.commands**: Preencher com comandos detectados (test, lint, typecheck). Para projetos novos, usar padrão do preset. Se nada detectado, deixar vazio com `auto_detect: true`.
|
|
81
|
+
|
|
82
|
+
### Fase 5B — Gerar CLAUDE.md
|
|
83
|
+
|
|
84
|
+
Ler template `TPL-CLAUDE.md` e substituir placeholders com dados coletados.
|
|
85
|
+
|
|
86
|
+
Se CLAUDE.md existir: seletor **Substituir** / **Mesclar** (adicionar seção Hefesto) / **Pular**.
|
|
87
|
+
|
|
88
|
+
Para projetos novos: usar dados do reference file. Para existentes: usar resultado da varredura.
|
|
89
|
+
|
|
90
|
+
Princípios: conciso, sem repetição do PROJECT.md, sem obviedades, comandos acionáveis.
|
|
91
|
+
|
|
92
|
+
### Fase 6 — MCP Context7
|
|
93
|
+
|
|
94
|
+
Se o projeto usa dependências externas (frameworks, bibliotecas, SDKs): verificar `.mcp.json` para `context7`. Se não existir, sugerir configuração para o usuário. Se o projeto não tem dependências externas, pular.
|
|
95
|
+
|
|
96
|
+
### Fase 7 — Resultado
|
|
97
|
+
|
|
98
|
+
Informar o que foi criado. Sugerir `/hefesto-new-feature`. Se plataforma `web` ou `mobile`, sugerir também `/hefesto-design` para definir o contrato visual.
|
|
99
|
+
|
|
100
|
+
## Notas
|
|
101
|
+
|
|
102
|
+
- Se usuário disser "decide você", fazer escolha razoável e justificar
|
|
103
|
+
- **Atualizar**: não executar scaffold, apenas re-varredura + update dos arquivos .hefesto/
|
|
104
|
+
- Varredura deve ser rápida (~10 reads)
|
|
105
|
+
- CLAUDE.md gerado deve ser conciso — apenas o não derivável do código
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# Preset: API
|
|
2
|
+
|
|
3
|
+
## Stack
|
|
4
|
+
|
|
5
|
+
- Node.js + TypeScript
|
|
6
|
+
- Fastify
|
|
7
|
+
- ES Modules
|
|
8
|
+
- pnpm (package manager)
|
|
9
|
+
|
|
10
|
+
## Scaffold
|
|
11
|
+
|
|
12
|
+
### 1. Inicializar projeto
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pnpm init
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### 2. Configurar package.json
|
|
19
|
+
|
|
20
|
+
Editar o `package.json` gerado:
|
|
21
|
+
|
|
22
|
+
- Adicionar `"type": "module"`
|
|
23
|
+
- Adicionar scripts:
|
|
24
|
+
```json
|
|
25
|
+
"scripts": {
|
|
26
|
+
"dev": "tsx watch src/server.ts",
|
|
27
|
+
"build": "tsc",
|
|
28
|
+
"start": "node dist/server.js"
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### 3. Instalar dependências
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pnpm add fastify
|
|
36
|
+
pnpm add -D typescript @types/node tsx
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 4. Criar tsconfig.json
|
|
40
|
+
|
|
41
|
+
Criar `tsconfig.json` com:
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"compilerOptions": {
|
|
46
|
+
"target": "ES2022",
|
|
47
|
+
"module": "NodeNext",
|
|
48
|
+
"moduleResolution": "NodeNext",
|
|
49
|
+
"outDir": "./dist",
|
|
50
|
+
"rootDir": "./src",
|
|
51
|
+
"strict": true,
|
|
52
|
+
"declaration": true,
|
|
53
|
+
"esModuleInterop": true,
|
|
54
|
+
"skipLibCheck": true,
|
|
55
|
+
"forceConsistentCasingInFileNames": true
|
|
56
|
+
},
|
|
57
|
+
"include": ["src/**/*"],
|
|
58
|
+
"exclude": ["node_modules", "dist"]
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 5. Criar estrutura de diretórios e arquivos
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
src/
|
|
66
|
+
├── server.ts
|
|
67
|
+
└── routes/
|
|
68
|
+
└── health.ts
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 6. Criar src/server.ts
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
import Fastify from 'fastify';
|
|
75
|
+
import { healthRoutes } from './routes/health.js';
|
|
76
|
+
|
|
77
|
+
const app = Fastify({ logger: true });
|
|
78
|
+
|
|
79
|
+
app.register(healthRoutes);
|
|
80
|
+
|
|
81
|
+
app.listen({ port: 3000, host: '0.0.0.0' }, (err) => {
|
|
82
|
+
if (err) {
|
|
83
|
+
app.log.error(err);
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 7. Criar src/routes/health.ts
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
import { FastifyInstance } from 'fastify';
|
|
93
|
+
|
|
94
|
+
export async function healthRoutes(app: FastifyInstance) {
|
|
95
|
+
app.get('/health', async () => {
|
|
96
|
+
return { status: 'ok' };
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### 8. Estrutura resultante esperada
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
src/
|
|
105
|
+
├── server.ts
|
|
106
|
+
└── routes/
|
|
107
|
+
└── health.ts
|
|
108
|
+
tsconfig.json
|
|
109
|
+
package.json
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## config.json
|
|
113
|
+
|
|
114
|
+
- platform: "api"
|
|
115
|
+
- lang: "typescript"
|
|
116
|
+
- monorepo: false
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Preset: CLI
|
|
2
|
+
|
|
3
|
+
## Stack
|
|
4
|
+
|
|
5
|
+
- Node.js + TypeScript
|
|
6
|
+
- ES Modules
|
|
7
|
+
- pnpm (package manager)
|
|
8
|
+
|
|
9
|
+
## Scaffold
|
|
10
|
+
|
|
11
|
+
### 1. Inicializar projeto
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pnpm init
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### 2. Configurar package.json
|
|
18
|
+
|
|
19
|
+
Editar o `package.json` gerado:
|
|
20
|
+
|
|
21
|
+
- Adicionar `"type": "module"`
|
|
22
|
+
- Adicionar campo `"bin"`: `{ "<nome-do-projeto>": "./dist/cli.js" }`
|
|
23
|
+
- Adicionar scripts:
|
|
24
|
+
```json
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsc",
|
|
27
|
+
"dev": "tsc --watch",
|
|
28
|
+
"start": "node dist/cli.js"
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### 3. Instalar TypeScript
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pnpm add -D typescript @types/node
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 4. Criar tsconfig.json
|
|
39
|
+
|
|
40
|
+
Criar `tsconfig.json` com:
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"compilerOptions": {
|
|
45
|
+
"target": "ES2022",
|
|
46
|
+
"module": "NodeNext",
|
|
47
|
+
"moduleResolution": "NodeNext",
|
|
48
|
+
"outDir": "./dist",
|
|
49
|
+
"rootDir": "./src",
|
|
50
|
+
"strict": true,
|
|
51
|
+
"declaration": true,
|
|
52
|
+
"esModuleInterop": true,
|
|
53
|
+
"skipLibCheck": true,
|
|
54
|
+
"forceConsistentCasingInFileNames": true
|
|
55
|
+
},
|
|
56
|
+
"include": ["src/**/*"],
|
|
57
|
+
"exclude": ["node_modules", "dist"]
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 5. Criar estrutura de diretórios e arquivos
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
src/
|
|
65
|
+
└── cli.ts ← entry point
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 6. Criar src/cli.ts
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
#!/usr/bin/env node
|
|
72
|
+
|
|
73
|
+
console.log('<nome-do-projeto> v0.1.0');
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Substituir `<nome-do-projeto>` pelo nome real do projeto.
|
|
77
|
+
|
|
78
|
+
### 7. Estrutura resultante esperada
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
src/
|
|
82
|
+
└── cli.ts
|
|
83
|
+
tsconfig.json
|
|
84
|
+
package.json
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## config.json
|
|
88
|
+
|
|
89
|
+
- platform: "cli"
|
|
90
|
+
- lang: "typescript"
|
|
91
|
+
- monorepo: false
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Preset: Mobile
|
|
2
|
+
|
|
3
|
+
## Stack
|
|
4
|
+
|
|
5
|
+
- React Native + Expo + TypeScript
|
|
6
|
+
- Expo Router (navegação file-based)
|
|
7
|
+
- NativeWind (TailwindCSS para React Native)
|
|
8
|
+
|
|
9
|
+
## Scaffold
|
|
10
|
+
|
|
11
|
+
### 1. Criar projeto Expo
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx create-expo-app@latest . --template tabs
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Se o diretório não estiver vazio, apresentar ao usuário via seletor interativo: **Criar num subdiretório** / **Limpar primeiro**.
|
|
18
|
+
|
|
19
|
+
### 2. Instalar NativeWind
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx expo install nativewind tailwindcss
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### 3. Configurar TailwindCSS
|
|
26
|
+
|
|
27
|
+
Criar `tailwind.config.js`:
|
|
28
|
+
|
|
29
|
+
```javascript
|
|
30
|
+
/** @type {import('tailwindcss').Config} */
|
|
31
|
+
module.exports = {
|
|
32
|
+
content: ['./app/**/*.{ts,tsx}', './components/**/*.{ts,tsx}'],
|
|
33
|
+
presets: [require('nativewind/preset')],
|
|
34
|
+
theme: {
|
|
35
|
+
extend: {},
|
|
36
|
+
},
|
|
37
|
+
plugins: [],
|
|
38
|
+
};
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Adicionar o plugin do NativeWind no `babel.config.js` (se existir) ou em `metro.config.js` conforme a documentação do NativeWind para a versão instalada.
|
|
42
|
+
|
|
43
|
+
### 4. Limpar boilerplate
|
|
44
|
+
|
|
45
|
+
- Simplificar as tabs de exemplo — manter a estrutura mas substituir o conteúdo.
|
|
46
|
+
- Substituir o conteúdo da tab Home por uma tela limpa com o nome do projeto centralizado.
|
|
47
|
+
- Remover assets de exemplo desnecessários.
|
|
48
|
+
|
|
49
|
+
### 5. Estrutura resultante esperada
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
app/
|
|
53
|
+
├── (tabs)/
|
|
54
|
+
│ ├── index.tsx ← Home limpa com nome do projeto
|
|
55
|
+
│ ├── _layout.tsx ← Tab layout
|
|
56
|
+
│ └── explore.tsx ← Tab secundária
|
|
57
|
+
├── _layout.tsx ← Root layout
|
|
58
|
+
└── +not-found.tsx
|
|
59
|
+
assets/
|
|
60
|
+
components/
|
|
61
|
+
constants/
|
|
62
|
+
hooks/
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## config.json
|
|
66
|
+
|
|
67
|
+
- platform: "mobile"
|
|
68
|
+
- lang: "typescript"
|
|
69
|
+
- monorepo: false
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# Preset: Web
|
|
2
|
+
|
|
3
|
+
## Stack
|
|
4
|
+
|
|
5
|
+
- Next.js (App Router) + TypeScript
|
|
6
|
+
- TailwindCSS + shadcn/ui
|
|
7
|
+
- Vitest + Playwright
|
|
8
|
+
- ESLint + Prettier
|
|
9
|
+
- T3 Env + Zod
|
|
10
|
+
- pnpm (package manager)
|
|
11
|
+
|
|
12
|
+
## Scaffold
|
|
13
|
+
|
|
14
|
+
### 1. Criar projeto Next.js
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpx create-next-app@latest . --typescript --tailwind --eslint --app --src-dir --import-alias "@/*" --turbopack --yes
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Após o scaffold, deletar arquivos genéricos gerados: `rm -f CLAUDE.md AGENTS.md`
|
|
21
|
+
|
|
22
|
+
**Diretório não vazio:** se `.hefesto/` ou `package.json` já existem, criar num subdiretório temporário e mover:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pnpx create-next-app@latest .tmp-scaffold --typescript --tailwind --eslint --app --src-dir --import-alias "@/*" --turbopack --yes
|
|
26
|
+
mv .tmp-scaffold/* . && mv .tmp-scaffold/.gitignore . 2>/dev/null && mv .tmp-scaffold/.eslintrc* . 2>/dev/null
|
|
27
|
+
rmdir .tmp-scaffold
|
|
28
|
+
rm -f CLAUDE.md AGENTS.md
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### 2. shadcn/ui
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pnpx shadcn@latest init -d
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 3. Prettier
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pnpm add -D prettier prettier-plugin-tailwindcss eslint-config-prettier
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Criar `.prettierrc` (semi, singleQuote, trailingComma all, plugin tailwindcss). Criar `.prettierignore` (node_modules, .next, dist, coverage, .claude, .hefesto). Adicionar `eslint-config-prettier` ao ESLint config.
|
|
44
|
+
|
|
45
|
+
Scripts: `format`, `format:check`.
|
|
46
|
+
|
|
47
|
+
### 4. Vitest
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pnpm add -D vitest @vitejs/plugin-react @testing-library/react @testing-library/dom @testing-library/user-event @testing-library/jest-dom jsdom vite-tsconfig-paths
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Criar `vitest.config.ts` (jsdom, react plugin, tsconfigPaths, setup em `tests/setup.ts`, include `src/**/*.test.*` e `tests/unit/**`). Criar `tests/setup.ts` com import de `@testing-library/jest-dom/vitest`.
|
|
54
|
+
|
|
55
|
+
Scripts: `test`, `test:watch`, `test:coverage`.
|
|
56
|
+
|
|
57
|
+
### 5. Playwright
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pnpm add -D @playwright/test
|
|
61
|
+
pnpx playwright install --with-deps chromium
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Criar `playwright.config.ts` (testDir `tests/e2e`, baseURL localhost:3000, webServer com `pnpm dev`).
|
|
65
|
+
|
|
66
|
+
Script: `test:e2e`.
|
|
67
|
+
|
|
68
|
+
### 6. T3 Env + Zod
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pnpm add @t3-oss/env-nextjs zod
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Criar `src/lib/env.ts` com `createEnv` (server: NODE_ENV, client: vazio). Importar `./src/lib/env.ts` no topo de `next.config.ts`. Criar `.env.example`. Adicionar `.env`, `.env.local`, `.env.production` ao `.gitignore`.
|
|
75
|
+
|
|
76
|
+
### 7. Limpar boilerplate
|
|
77
|
+
|
|
78
|
+
- `src/app/page.tsx` → página limpa com `<h1>` do nome do projeto
|
|
79
|
+
- `src/app/globals.css` → apenas imports Tailwind + variáveis shadcn
|
|
80
|
+
- Remover assets padrão em `public/` (next.svg, vercel.svg)
|
|
81
|
+
- Simplificar `src/app/layout.tsx`
|
|
82
|
+
|
|
83
|
+
### 8. Criar estrutura feature-based
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
mkdir -p src/features src/hooks src/services src/types tests/unit tests/e2e
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Criar `.gitkeep` nos diretórios vazios.
|
|
90
|
+
|
|
91
|
+
### 9. Formatação inicial
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
pnpm format
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Arquitetura e Convenções
|
|
100
|
+
|
|
101
|
+
### Feature-based
|
|
102
|
+
|
|
103
|
+
Código organizado por domínio em `src/features/`. Cada feature:
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
src/features/<nome>/
|
|
107
|
+
├── components/ ← componentes da feature
|
|
108
|
+
├── hooks/ ← hooks da feature
|
|
109
|
+
├── services/ ← lógica de negócio e chamadas de API
|
|
110
|
+
├── types/ ← tipos e interfaces
|
|
111
|
+
└── index.ts ← barrel export (API pública)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Compartilhado entre features fica em `src/` raiz: `components/`, `components/ui/` (shadcn), `hooks/`, `services/`, `types/`, `lib/`.
|
|
115
|
+
|
|
116
|
+
### Princípios
|
|
117
|
+
|
|
118
|
+
1. **Features não importam de outras features.** Código compartilhado sobe para `src/`.
|
|
119
|
+
2. **`src/app/` só contém rotas e layouts.** Lógica fica em `src/features/`.
|
|
120
|
+
3. **Barrel exports** — importar do índice: `import { LoginForm } from '@/features/auth'`.
|
|
121
|
+
4. **Sem `any`** — usar `unknown` e narrowing.
|
|
122
|
+
5. **Validação nas bordas** — inputs de usuário e APIs externas com Zod.
|
|
123
|
+
6. **Env validado** — usar `env` de `@/lib/env`, nunca `process.env` direto.
|
|
124
|
+
|
|
125
|
+
### Naming
|
|
126
|
+
|
|
127
|
+
| Elemento | Convenção | Exemplo |
|
|
128
|
+
| ----------- | ------------------ | ---------------------- |
|
|
129
|
+
| Componentes | PascalCase | `ProductCard.tsx` |
|
|
130
|
+
| Hooks | useCamelCase | `useProducts.ts` |
|
|
131
|
+
| Serviços | camelCase.service | `auth.service.ts` |
|
|
132
|
+
| Tipos | PascalCase | `User`, `AuthResult` |
|
|
133
|
+
| Constantes | SCREAMING_SNAKE | `MAX_ITEMS_PER_PAGE` |
|
|
134
|
+
| Testes | .test.ts/.test.tsx | `auth.service.test.ts` |
|
|
135
|
+
|
|
136
|
+
### Testes
|
|
137
|
+
|
|
138
|
+
- **Co-localizados** (`src/**/*.test.ts`) — lógica de negócio. Ficam ao lado do arquivo.
|
|
139
|
+
- **De feature** (`tests/unit/`) — testes criados pelo Argos para validar requisitos. Nome: `feat-NNN-slug.test.ts`.
|
|
140
|
+
- **E2E** (`tests/e2e/`) — fluxos críticos com Playwright.
|
|
141
|
+
|
|
142
|
+
### Next.js 16 — `proxy.ts`
|
|
143
|
+
|
|
144
|
+
No Next.js 16, `middleware.ts` foi substituído por `proxy.ts` (runtime Node.js em vez de Edge). Função exportada: `proxy` em vez de `middleware`. Para migrar: `npx @next/codemod@canary middleware-to-proxy .`
|
|
145
|
+
|
|
146
|
+
Para proteção de rotas, preferir Server Components com `redirect()`.
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Receitas
|
|
151
|
+
|
|
152
|
+
Padrões prontos para adotar conforme a feature precisar. **Não são instaladas no scaffold** — usar quando o projeto demandar.
|
|
153
|
+
|
|
154
|
+
### Data Fetching — TanStack Query
|
|
155
|
+
|
|
156
|
+
**Quando:** a feature precisa buscar, cachear ou sincronizar dados do servidor.
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
pnpm add @tanstack/react-query @tanstack/react-query-devtools
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Setup: criar `src/lib/query-client.ts` com `QueryClient` configurado (staleTime, gcTime). Criar `src/components/providers.tsx` com `QueryClientProvider` wrapping children + `ReactQueryDevtools` em dev. Adicionar o provider no `layout.tsx` (como Client Component).
|
|
163
|
+
|
|
164
|
+
Pattern de uso em features:
|
|
165
|
+
|
|
166
|
+
```
|
|
167
|
+
src/features/products/
|
|
168
|
+
├── hooks/
|
|
169
|
+
│ └── use-products.ts ← useQuery + queryKey + fetch function
|
|
170
|
+
├── services/
|
|
171
|
+
│ └── products.service.ts ← fetch functions puras (sem hooks)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Hooks chamam services. Services são funções puras testáveis. Query keys seguem padrão `[feature, ...params]`.
|
|
175
|
+
|
|
176
|
+
### Formulários — React Hook Form + Zod
|
|
177
|
+
|
|
178
|
+
**Quando:** a feature tem formulários com validação.
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
pnpm add react-hook-form @hookform/resolvers
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Zod já está na stack. Usar `zodResolver` com `useForm`. Integrar com componentes `Form` do shadcn/ui (`npx shadcn@latest add form`).
|
|
185
|
+
|
|
186
|
+
Pattern: schema Zod define a validação, `useForm` gerencia o state, shadcn/ui `FormField` renderiza.
|
|
187
|
+
|
|
188
|
+
### Estado Global — Zustand
|
|
189
|
+
|
|
190
|
+
**Quando:** estado precisa ser compartilhado entre features sem prop drilling. Preferir para estado de UI (sidebar aberta, tema, filtros). Para dados do servidor, usar TanStack Query.
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
pnpm add zustand
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Pattern: um store por domínio em `src/features/<nome>/stores/`. Stores exportam hooks (`useCartStore`). Usar slices para stores complexas.
|
|
197
|
+
|
|
198
|
+
### Autenticação — Better Auth
|
|
199
|
+
|
|
200
|
+
**Quando:** a feature precisa de login, registro, sessões ou proteção de rotas.
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
pnpm add better-auth
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Setup: criar `src/lib/auth.ts` (server) com `betterAuth()` configurando database adapter e providers (email/password, Google, GitHub). Criar `src/lib/auth-client.ts` com `createAuthClient()`. Criar API route em `src/app/api/auth/[...all]/route.ts`.
|
|
207
|
+
|
|
208
|
+
Plugins úteis: `twoFactor()`, `magicLink()`, `organization()`.
|
|
209
|
+
|
|
210
|
+
Pattern de proteção: Server Components usam `auth.api.getSession()` + `redirect()`. Client Components usam `authClient.useSession()`.
|
|
211
|
+
|
|
212
|
+
### Banco de Dados — Drizzle ORM
|
|
213
|
+
|
|
214
|
+
**Quando:** a feature precisa persistir dados.
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
pnpm add drizzle-orm postgres
|
|
218
|
+
pnpm add -D drizzle-kit
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Setup: criar `src/db/index.ts` (connection com `postgres` driver). Criar `src/db/schema/` com schemas por domínio. Criar `drizzle.config.ts` apontando para o schema e connection string via `env.ts`, com `out: './src/db/migrations'`.
|
|
222
|
+
|
|
223
|
+
Estrutura:
|
|
224
|
+
|
|
225
|
+
```
|
|
226
|
+
src/db/
|
|
227
|
+
├── index.ts ← connection + export do db
|
|
228
|
+
├── schema/
|
|
229
|
+
│ ├── index.ts ← re-export de todos os schemas
|
|
230
|
+
│ └── users.ts
|
|
231
|
+
└── migrations/ ← geradas pelo drizzle-kit (out: './src/db/migrations')
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Adicionar `DATABASE_URL` ao T3 Env (`src/lib/env.ts`) e `.env.example`.
|
|
235
|
+
|
|
236
|
+
Scripts: `db:generate` (`drizzle-kit generate`), `db:migrate` (`drizzle-kit migrate`), `db:studio` (`drizzle-kit studio`).
|
|
237
|
+
|
|
238
|
+
Pattern: schemas em `src/db/schema/<dominio>.ts`, queries em `src/features/<nome>/services/`.
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## config.json
|
|
243
|
+
|
|
244
|
+
- platform: "web"
|
|
245
|
+
- lang: "typescript"
|
|
246
|
+
- monorepo: false
|