sauron-cli 1.2.0 → 1.4.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/rules/memory.md +156 -0
- package/.agents/skills/wiki/SKILL.md +172 -0
- package/.aider.instructions.md +152 -0
- package/.cursor/rules/sauron-memory.mdc +157 -0
- package/.genesis/prompts/prompt-onboarding-inteligente.md +45 -0
- package/.genesis/prompts/prompt-sauron-vs-openspec-arquitetura.md +106 -0
- package/.github/workflows/ci.yml +27 -0
- package/.sauron/.manifest.json +2 -1
- package/.sauron/wiki/history/implementacao-scanner-inteligente.md +29 -0
- package/.sauron/wiki/history/reestruturacao-arquitetural-core.md +29 -0
- package/.sauron/wiki/history/resiliencia-caminho-templates.md +29 -0
- package/.sauron/wiki/standards/typescript.rules.md +21 -0
- package/.sauron/wiki/summary.json +81 -0
- package/.windsurfrules +160 -0
- package/Evolu/303/247/303/243o Arquitetural do Sauron CLI.md" +97 -0
- package/README.md +40 -5
- package/dist/index.js +1186 -147
- package/package.json +1 -1
- package/templates/.agents/rules/memory.md +68 -68
- package/templates/.agents/skills/wiki/SKILL.md +14 -14
- package/templates/wiki-recipes/nextjs.rules.md +21 -0
- package/templates/wiki-recipes/postgresql.rules.md +20 -0
- package/templates/wiki-recipes/react.rules.md +18 -0
- package/templates/wiki-recipes/tailwindcss.rules.md +18 -0
- package/templates/wiki-recipes/typescript.rules.md +21 -0
package/package.json
CHANGED
|
@@ -2,111 +2,111 @@
|
|
|
2
2
|
trigger: always_on
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
#
|
|
5
|
+
# Project Memory Rule (MANDATORY)
|
|
6
6
|
|
|
7
|
-
>
|
|
8
|
-
>
|
|
7
|
+
> This rule ensures that the Wiki (`.sauron/wiki/`) is the absolute single source of truth for the project.
|
|
8
|
+
> Violating it means losing critical context between sessions.
|
|
9
9
|
|
|
10
10
|
---
|
|
11
11
|
|
|
12
|
-
## 1.
|
|
12
|
+
## 1. READ — Before Taking Action
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Whenever something is asked or a task is initiated:
|
|
15
15
|
|
|
16
|
-
1.
|
|
17
|
-
2.
|
|
18
|
-
3.
|
|
16
|
+
1. Read `.sauron/wiki/summary.json` (the base routing file) first. This file follows a **strict pattern** and is the only reliable source of metadata.
|
|
17
|
+
2. Navigate through the relevant sub-pages using the original name and type (file/folder) information contained in the JSON.
|
|
18
|
+
3. Only resort to exploring the file system if the information **does not exist** in the summary (and update the summary if necessary following the schema in Section 6).
|
|
19
19
|
|
|
20
20
|
---
|
|
21
21
|
|
|
22
|
-
## 2.
|
|
22
|
+
## 2. SYNCHRONIZATION PROTOCOL (CLOUD)
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
The documentation flow follows a three-step cycle to ensure persistence:
|
|
25
25
|
|
|
26
|
-
1. **PULL (Manual)**:
|
|
27
|
-
2. **
|
|
28
|
-
3. **PUSH (Manual)**:
|
|
26
|
+
1. **PULL (Manual)**: Before starting a task, the user executes `sauron pull` to update local documents with the latest cloud version.
|
|
27
|
+
2. **EXECUTION (AI)**: During development, the Agent updates/creates documents in `.sauron/wiki/` in real-time.
|
|
28
|
+
3. **PUSH (Manual)**: Upon completing the task, the user executes `sauron push` to send local updates to the cloud.
|
|
29
29
|
|
|
30
30
|
> [!IMPORTANT]
|
|
31
|
-
>
|
|
31
|
+
> The Agent MUST assume that the `.sauron/wiki/` directory is the final destination and update it diligently, allowing the user to synchronize changes later.
|
|
32
32
|
|
|
33
33
|
---
|
|
34
34
|
|
|
35
|
-
## 3.
|
|
35
|
+
## 3. WRITE — After Delivering (CRITICAL)
|
|
36
36
|
|
|
37
|
-
**
|
|
37
|
+
**After ANY functional delivery, the wiki MUST be updated in the SAME response turn.**
|
|
38
38
|
|
|
39
|
-
###
|
|
39
|
+
### Mandatory Write Triggers
|
|
40
40
|
|
|
41
|
-
|
|
|
41
|
+
| Event | Wiki Action |
|
|
42
42
|
|--------|-------------|
|
|
43
|
-
| **
|
|
44
|
-
| **
|
|
45
|
-
| **
|
|
46
|
-
| **
|
|
47
|
-
| **
|
|
48
|
-
| **
|
|
49
|
-
| **
|
|
50
|
-
| **
|
|
43
|
+
| **External API integration** | Create/update page documenting URL, authentication, payload, response, and error handling. |
|
|
44
|
+
| **New page/route created** | Register in `summary.json` (following the **strict pattern** in Section 6) + create `.md` file. |
|
|
45
|
+
| **Authentication flow changed** | Update the auth page with the full flow, including cookies, tokens, and middleware. |
|
|
46
|
+
| **New functional UI component** | Register in the corresponding module page with props, behavior, and dependencies. |
|
|
47
|
+
| **Architectural decision made** | Document using the "Architectural Decision" format (Problem → Options → Choice → Justification). |
|
|
48
|
+
| **Environment variable added/changed** | Register in the infrastructure page with name, purpose, and example. |
|
|
49
|
+
| **Database schema changed** | Update `module-data-schema.md` with the change. |
|
|
50
|
+
| **Critical bug resolved** | Register root cause and solution in the affected module page. |
|
|
51
51
|
|
|
52
|
-
###
|
|
52
|
+
### Golden Rule
|
|
53
53
|
|
|
54
54
|
```
|
|
55
|
-
❌
|
|
56
|
-
✅
|
|
55
|
+
❌ WRONG: Deliver code → Respond to user → Forget the wiki
|
|
56
|
+
✅ CORRECT: Deliver code → Update wiki → Respond to user
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
Updating the wiki is **part of the delivery**, not an optional subsequent step.
|
|
60
60
|
|
|
61
61
|
---
|
|
62
62
|
|
|
63
|
-
## 4.
|
|
63
|
+
## 4. FORMAT — What to Write
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
- **
|
|
67
|
-
- **
|
|
68
|
-
- **
|
|
69
|
-
- **
|
|
70
|
-
- **
|
|
65
|
+
Each record MUST contain at least:
|
|
66
|
+
- **What was done** (objective description)
|
|
67
|
+
- **Why it was done** (context and motivation)
|
|
68
|
+
- **How it works** (technical details: endpoints, payloads, flows)
|
|
69
|
+
- **Files affected** (list of paths)
|
|
70
|
+
- **Date** (timestamp of the change)
|
|
71
71
|
|
|
72
72
|
---
|
|
73
73
|
|
|
74
|
-
## 6.
|
|
74
|
+
## 6. STRICT STRUCTURE OF SUMMARY.JSON
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
The `.sauron/wiki/summary.json` file is the metadata map that links local files to the server. The CLI requires a strict pattern for the `sauron push` command to work correctly.
|
|
77
77
|
|
|
78
|
-
###
|
|
79
|
-
- **
|
|
80
|
-
- **
|
|
81
|
-
- **
|
|
82
|
-
- **
|
|
83
|
-
- **
|
|
78
|
+
### Summary Golden Rules
|
|
79
|
+
- **NEVER alter IDs**: The fields `id`, `domainId`, and `orgId` are crucial. Removing or changing them will cause duplicate documents to be created on the server instead of updating existing ones.
|
|
80
|
+
- **Maintain Mapping**: The `name` field must be the original title (with spaces and accents). The `slug` and `path` must be generated following normalization logic (lowercase, no accents, spaces become hyphens).
|
|
81
|
+
- **Optimization**: The `contentLength` and `contentHash` (SHA256) fields allow the CLI to skip unchanged files. If you manually edit a file, `push` will detect the change even if you don't update the hash (it recalculates the local hash), but `summary.json` should be kept updated for consistency.
|
|
82
|
+
- **Physical Coupling**: Sauron CLI maps database domains in the cloud based on the local physical subfolder (using the file's parent directory). Files in the wiki root will always belong to the generic domain `.`. Physical organization in folders is mandatory to maintain logical separation in the cloud.
|
|
83
|
+
- **Ignore summary.md**: The `summary.md` file is a special/reserved page. Never add `summary.md` as a `"file"` entry inside `summary.json`, otherwise the CLI will attempt to delete it and fail with a 422 error.
|
|
84
84
|
|
|
85
|
-
### Schema
|
|
85
|
+
### Mandatory Schema
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
The JSON MUST be an **array of objects** strictly following these formats:
|
|
88
88
|
|
|
89
|
-
####
|
|
89
|
+
#### Folder Entry (Domain)
|
|
90
90
|
```json
|
|
91
91
|
{
|
|
92
92
|
"type": "folder",
|
|
93
|
-
"name": "
|
|
94
|
-
"slug": "
|
|
95
|
-
"path": "
|
|
96
|
-
"id": "id
|
|
93
|
+
"name": "Original Title",
|
|
94
|
+
"slug": "original-title",
|
|
95
|
+
"path": "original-title",
|
|
96
|
+
"id": "domain-id"
|
|
97
97
|
}
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
-
####
|
|
100
|
+
#### File Entry (Document)
|
|
101
101
|
```json
|
|
102
102
|
{
|
|
103
103
|
"type": "file",
|
|
104
|
-
"name": "
|
|
105
|
-
"slug": "
|
|
106
|
-
"path": "slug
|
|
107
|
-
"id": "id
|
|
108
|
-
"domainId": "
|
|
109
|
-
"orgId": "id
|
|
104
|
+
"name": "Original Document Title",
|
|
105
|
+
"slug": "original-document-title",
|
|
106
|
+
"path": "domain-slug/original-document-title.md",
|
|
107
|
+
"id": "kb-id",
|
|
108
|
+
"domainId": "parent-domain-id",
|
|
109
|
+
"orgId": "organization-id",
|
|
110
110
|
"contentLength": 1234,
|
|
111
111
|
"contentHash": "sha256-checksum"
|
|
112
112
|
}
|
|
@@ -114,15 +114,15 @@ O JSON deve ser um **array de objetos** seguindo rigorosamente estes formatos:
|
|
|
114
114
|
|
|
115
115
|
---
|
|
116
116
|
|
|
117
|
-
## 7.
|
|
117
|
+
## 7. VALIDATION — Mental Checklist
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
Before finalizing any response involving code, ask yourself:
|
|
120
120
|
|
|
121
|
-
- [ ]
|
|
122
|
-
- [ ]
|
|
123
|
-
- [ ]
|
|
124
|
-
- [ ]
|
|
125
|
-
- [ ]
|
|
126
|
-
- [ ]
|
|
121
|
+
- [ ] Did I create or modify a file? → Wiki needs to know.
|
|
122
|
+
- [ ] Did I connect to an external API? → Wiki needs to document it.
|
|
123
|
+
- [ ] Did I alter the login/session flow? → Wiki MUST reflect it.
|
|
124
|
+
- [ ] Did I create a new page/route? → `summary.json` needs the routing record following the **strict pattern**.
|
|
125
|
+
- [ ] Did I make a technical decision (lib X vs Y, approach A vs B)? → Wiki needs the justification.
|
|
126
|
+
- [ ] Did I add/alter an environment variable? → Wiki needs the record.
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
If any checkbox is `true` and the wiki was not updated, **the task is NOT complete**.
|
|
@@ -31,9 +31,9 @@ priority: MANDATORY
|
|
|
31
31
|
| Property | Requirement |
|
|
32
32
|
|----------|-------------|
|
|
33
33
|
| **Base Directory** | `/.sauron/wiki/` |
|
|
34
|
-
| **Root Routing File** | `summary.json` (
|
|
35
|
-
| **Subdirectories** | `knowledge/`, `modules/`, `manuals/`, `standards/`, `history/` (
|
|
36
|
-
| **Naming Pattern** | `{name}.md` (
|
|
34
|
+
| **Root Routing File** | `summary.json` (inside `/.sauron/wiki/`) |
|
|
35
|
+
| **Subdirectories** | `knowledge/`, `modules/`, `manuals/`, `standards/`, `history/` (mandatory physical folders for domains in Sauron) |
|
|
36
|
+
| **Naming Pattern** | `{name}.md` (no prefixes if they are already inside physical domain subfolders) |
|
|
37
37
|
| **Examples** | `knowledge/architecture.md`, `modules/checkout.md`, `manuals/upholstery.md` |
|
|
38
38
|
|
|
39
39
|
---
|
|
@@ -41,25 +41,25 @@ priority: MANDATORY
|
|
|
41
41
|
## 3. Reference Templates
|
|
42
42
|
|
|
43
43
|
### 3.1 Root Routing File (`summary.json`)
|
|
44
|
-
|
|
44
|
+
The `summary.json` file is the metadata map that links local files to the server. It follows a **strict pattern** (see Section 6 of `memory.md`).
|
|
45
45
|
|
|
46
46
|
```json
|
|
47
47
|
[
|
|
48
48
|
{
|
|
49
49
|
"type": "folder",
|
|
50
|
-
"name": "
|
|
51
|
-
"slug": "
|
|
52
|
-
"path": "
|
|
53
|
-
"id": "UUID-
|
|
50
|
+
"name": "Original Title",
|
|
51
|
+
"slug": "original-title",
|
|
52
|
+
"path": "original-title",
|
|
53
|
+
"id": "UUID-or-ID"
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
56
|
"type": "file",
|
|
57
|
-
"name": "
|
|
58
|
-
"slug": "
|
|
59
|
-
"path": "slug
|
|
60
|
-
"id": "UUID-
|
|
61
|
-
"domainId": "ID
|
|
62
|
-
"orgId": "ID
|
|
57
|
+
"name": "Original Title",
|
|
58
|
+
"slug": "original-title",
|
|
59
|
+
"path": "domain-slug/original-title.md",
|
|
60
|
+
"id": "UUID-or-ID",
|
|
61
|
+
"domainId": "parent-ID",
|
|
62
|
+
"orgId": "organization-ID",
|
|
63
63
|
"contentLength": 1234,
|
|
64
64
|
"contentHash": "sha256-checksum"
|
|
65
65
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Next.js - Arquitetura de Server Components e Roteamento
|
|
2
|
+
|
|
3
|
+
Este documento normatiza a organização lógica e padrões de Server vs Client Components no Next.js (App Router).
|
|
4
|
+
|
|
5
|
+
## 🎯 Regras Obrigatórias para a IA
|
|
6
|
+
|
|
7
|
+
1. **Server Components por Padrão**:
|
|
8
|
+
- Todas as páginas (`page.tsx`) e layouts (`layout.tsx`) devem operar como Server Components por padrão.
|
|
9
|
+
- Busque dados diretamente no servidor (usando `fetch` ou acessando o banco/serviço) em vez de chamar APIs internas via client.
|
|
10
|
+
|
|
11
|
+
2. **Client Components Isolados**:
|
|
12
|
+
- Adicione a diretiva `'use client'` estritamente no topo de arquivos que necessitam de interatividade (hooks como `useState`, `useEffect` ou escutadores de eventos do DOM).
|
|
13
|
+
- Mantenha os Client Components no menor nível possível na árvore de componentes (ex: encapsule um botão interativo em vez de tornar o cabeçalho inteiro client-side).
|
|
14
|
+
|
|
15
|
+
3. **Roteamento Dinâmico**:
|
|
16
|
+
- Utilize a API `Link` nativa de `next/link` para navegação interna, garantindo pré-carregamento.
|
|
17
|
+
- Utilize `useRouter` do `next/navigation` apenas em Client Components e navegações imperativas de evento.
|
|
18
|
+
|
|
19
|
+
## 🚫 Práticas Banidas
|
|
20
|
+
- Executar chamadas do Firebase Client SDK ou APIs internas diretamente em Server Components sem serialização apropriada.
|
|
21
|
+
- Utilização de hooks de estado fora de Client Components.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# PostgreSQL - Diretrizes de Banco de Dados e Queries
|
|
2
|
+
|
|
3
|
+
Este documento normatiza os padrões de modelagem, migrações e consultas SQL.
|
|
4
|
+
|
|
5
|
+
## 🎯 Regras Obrigatórias para a IA
|
|
6
|
+
|
|
7
|
+
1. **Migrações Cautelosas**:
|
|
8
|
+
- Todas as alterações estruturais de banco de dados (DDL) devem passar por arquivos de migração versionados.
|
|
9
|
+
- Evite alterações destrutivas em produção (como remoção de colunas). Prefira a abordagem de depreciação em fases (adiciona nova coluna, migra dados, remove antiga).
|
|
10
|
+
|
|
11
|
+
2. **Indexação Estratégica**:
|
|
12
|
+
- Adicione índices explicitamente em colunas utilizadas em cláusulas `WHERE`, `JOIN` ou ordenações (`ORDER BY`).
|
|
13
|
+
- Evite excesso de índices em colunas com alta taxa de escrita para não degradar a performance de inserts/updates.
|
|
14
|
+
|
|
15
|
+
3. **Consultas Seguras**:
|
|
16
|
+
- Nunca concatene variáveis de entrada diretamente em queries SQL cruas. Utilize sempre parâmetros vinculados (Prepared Statements) para blindagem contra SQL Injection.
|
|
17
|
+
|
|
18
|
+
## 🚫 Práticas Banidas
|
|
19
|
+
- Queries com `SELECT *` em tabelas largas em produção. Especifique as colunas necessárias para reduzir overhead de tráfego de rede.
|
|
20
|
+
- Executar updates ou deletes sem cláusulas `WHERE` explícitas.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# React - Gestão de Estado e Ciclo de Vida
|
|
2
|
+
|
|
3
|
+
Este documento estabelece as diretrizes para a manipulação de componentes e renderização no React.
|
|
4
|
+
|
|
5
|
+
## 🎯 Regras Obrigatórias para a IA
|
|
6
|
+
|
|
7
|
+
1. **Componentes Funcionais Estritos**:
|
|
8
|
+
- Utilize exclusivamente componentes funcionais baseados em Arrow Functions ou declarações de função TypeScript. Componentes baseados em classe estão terminantemente proibidos.
|
|
9
|
+
|
|
10
|
+
2. **Custom Hooks para Lógica**:
|
|
11
|
+
- Separe a lógica de negócio do componente visual. Se um componente possui lógica de fetching, paginação ou hooks complexos, isole-os em um custom hook (`useMyFeature.ts`).
|
|
12
|
+
|
|
13
|
+
3. **Performance e Re-render**:
|
|
14
|
+
- Utilize `useMemo` e `useCallback` estritamente para evitar recomputações pesadas ou manter referências de objetos estáveis passados como dependência em hooks. Evite micro-otimizações desnecessárias.
|
|
15
|
+
|
|
16
|
+
## 🚫 Práticas Banidas
|
|
17
|
+
- Mutação direta de estados (ex: `state.push(item)`). Sempre utilize a função de mutação do `useState` aplicando imutabilidade (`setRawState([...state, item])`).
|
|
18
|
+
- Injeção de lógica pesada de controle diretamente dentro do retorno visual JSX.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Tailwind CSS - Padrões de Estilização Funcional
|
|
2
|
+
|
|
3
|
+
Este documento estabelece as regras de escrita e organização para classes utilitárias do Tailwind CSS.
|
|
4
|
+
|
|
5
|
+
## 🎯 Regras Obrigatórias para a IA
|
|
6
|
+
|
|
7
|
+
1. **Organização de Classes**:
|
|
8
|
+
- Organize as classes utilitárias na ordem padrão: Layout (display, position), Box Model (width, height, padding, margin), Tipografia (font, text), Design Visual (bg, border, shadow), e Estados Interativos/Responsividade (`sm:`, `hover:`).
|
|
9
|
+
|
|
10
|
+
2. **Uso de Variáveis de Tema**:
|
|
11
|
+
- Utilize cores e tokens definidos no arquivo de configuração do Tailwind (`tailwind.config.js`). Evite classes arbitrárias pesadas como `bg-[#ff22aa]` diretamente no HTML.
|
|
12
|
+
|
|
13
|
+
3. **Responsividade Mobile-First**:
|
|
14
|
+
- Desenhe a estrutura móvel como base padrão do componente (sem prefixo) e adicione prefixos como `md:` e `lg:` progressivamente para telas maiores.
|
|
15
|
+
|
|
16
|
+
## 🚫 Práticas Banidas
|
|
17
|
+
- Criação de classes CSS customizadas tradicionais em arquivos separados para resolver problemas que podem ser resolvidos diretamente com classes utilitárias nativas do Tailwind.
|
|
18
|
+
- Misturar estilos in-line JavaScript (`style={{ ... }}`) com classes utilitárias do Tailwind.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# TypeScript - Diretrizes de Qualidade e Tipagem Estrita
|
|
2
|
+
|
|
3
|
+
Este documento normatiza os padrões de tipagem e compilação para o uso do TypeScript no projeto.
|
|
4
|
+
|
|
5
|
+
## 🎯 Regras Obrigatórias para a IA
|
|
6
|
+
|
|
7
|
+
1. **Tipagem Estrita (Strict Mode)**:
|
|
8
|
+
- Nunca utilizar `any` de forma deliberada. Se a tipagem for dinâmica ou desconhecida, prefira `unknown` e realize Type Guarding (assercões de tipo seguras).
|
|
9
|
+
- Ative e respeite `noImplicitAny`, `strictNullChecks` e `noUnusedLocals`.
|
|
10
|
+
|
|
11
|
+
2. **Tipos vs Interfaces**:
|
|
12
|
+
- Utilize `interface` para declarar contratos de objetos públicos, classes, e componentes expostos.
|
|
13
|
+
- Utilize `type` para uniões (`|`), interseções (`&`), tuplas, tipos utilitários ou definições primitivas de alias.
|
|
14
|
+
|
|
15
|
+
3. **Importações Explicitas**:
|
|
16
|
+
- Utilize imports com a extensão `.js` ao compilar para ECMAScript Modules (ESM) nativo no Node.js.
|
|
17
|
+
- Prefira importações nomeadas em vez de imports coringa (`* as module`).
|
|
18
|
+
|
|
19
|
+
## 🚫 Práticas Banidas
|
|
20
|
+
- Desativar checagens com comentários `// @ts-ignore` (use `// @ts-expect-error` apenas com justificativa explícita e em testes).
|
|
21
|
+
- Asserções de tipo coercitivas (`as any` ou `as unknown as Type`).
|