@mocoto/mahoraga 0.15.0 → 0.15.2

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.
Files changed (61) hide show
  1. package/Docs/.obsidian/app.json +7 -0
  2. package/Docs/.obsidian/appearance.json +8 -0
  3. package/Docs/.obsidian/community-plugins.json +28 -0
  4. package/Docs/.obsidian/core-plugins-migration.json +18 -0
  5. package/Docs/.obsidian/core-plugins.json +73 -0
  6. package/Docs/.obsidian/graph.json +22 -0
  7. package/Docs/.obsidian/workspace.json +196 -0
  8. package/Docs/01-arquitetura/ADR-001-estrutura-testes.md +31 -0
  9. package/Docs/01-arquitetura/_index.md +152 -0
  10. package/Docs/02-componentes/_index.md +294 -0
  11. package/Docs/02-componentes/configuracao.md +110 -0
  12. package/Docs/02-componentes/supressao-inline.md +88 -0
  13. package/Docs/03-guias/_index.md +173 -0
  14. package/Docs/03-guias/contribuindo.md +71 -0
  15. package/Docs/03-guias/testes.md +133 -0
  16. package/Docs/04-glossario/_index.md +29 -0
  17. package/Docs/04-glossario/termos.md +247 -0
  18. package/Docs/05-referencias/_index.md +88 -0
  19. package/Docs/06-feedbacks/feedback.md +74 -0
  20. package/Docs/Sem t/303/255tulo.base" +3 -0
  21. package/Docs/Sem t/303/255tulo.md +0 -0
  22. package/Docs/_home.md +140 -0
  23. package/Docs/partials/AVISO-PROVENIENCIA.md +3 -0
  24. package/Docs/templates/ADR.md +24 -0
  25. package/Docs/templates/componente.md +34 -0
  26. package/Docs/templates/guia.md +28 -0
  27. package/README.md +269 -26
  28. package/dist/analysts/detectors/detector-bugs-ml.js +5 -0
  29. package/dist/analysts/js-ts/registrar.js +1 -1
  30. package/dist/analysts/plugins/detector-markdown.js +2 -2
  31. package/dist/analysts/react/analysts/analyst-react-hooks.js +30 -15
  32. package/dist/analysts/react/analysts/analyst-react.js +11 -2
  33. package/dist/analysts/react/detectors/detector-react-best-practices.js +7 -4
  34. package/dist/caretakers/caretaker-imports.js +0 -9
  35. package/dist/cli/commands/command-github-actions.js +0 -27
  36. package/dist/cli/diagnostic/filters.js +1 -4
  37. package/dist/core/config/config.js +2 -3
  38. package/dist/core/config/excludes-padrao.js +3 -2
  39. package/dist/core/messages/en/cli/cli-command-github-actions-messages.js +0 -5
  40. package/dist/core/messages/en/github/index.js +0 -1
  41. package/dist/core/messages/ja/cli/cli-command-github-actions-messages.js +0 -5
  42. package/dist/core/messages/ja/github/index.js +0 -1
  43. package/dist/core/messages/pt/cli/cli-command-github-actions-messages.js +0 -5
  44. package/dist/core/messages/pt/github/index.js +0 -1
  45. package/dist/core/messages/zh/cli/cli-command-github-actions-messages.js +0 -5
  46. package/dist/core/messages/zh/github/index.js +0 -1
  47. package/dist/core/registry/file-registry.js +1 -1
  48. package/dist/node.loader.js +0 -2
  49. package/dist/reports/report-structure.js +2 -8
  50. package/dist/shared/formatters/formatters/commons.js +36 -10
  51. package/dist/shared/formatters/formatters/shell.js +6 -3
  52. package/dist/shared/helpers/magic-constants-whitelist.js +14 -1
  53. package/dist/types/analysts/index.js +1 -1
  54. package/dist/types/processing/filters.js +1 -4
  55. package/package.json +31 -32
  56. package/dist/app/github.js +0 -14
  57. package/dist/app/index.js +0 -1
  58. package/dist/core/messages/en/github/github-app-messages.js +0 -9
  59. package/dist/core/messages/ja/github/github-app-messages.js +0 -9
  60. package/dist/core/messages/pt/github/github-app-messages.js +0 -9
  61. package/dist/core/messages/zh/github/github-app-messages.js +0 -9
@@ -0,0 +1,7 @@
1
+ {
2
+ "enabled": true,
3
+ "alwaysUpdateLinks": true,
4
+ "promptDelete": false,
5
+ "newFileLocation": "current",
6
+ "attachmentFolderPath": "./"
7
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "theme": "system",
3
+ "accentColor": "#6b5bff",
4
+ "cssTheme": "",
5
+ "baseFontSize": 15,
6
+ "showViewHeader": false,
7
+ "nativeMenus": false
8
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "enabled": [
3
+ "obsidian-dataview",
4
+ "templater-obsidian",
5
+ "obsidian-git"
6
+ ],
7
+ "plugins": {
8
+ "obsidian-dataview": {
9
+ "enableDataviewJs": false,
10
+ "renderNullAs": "\\-",
11
+ "taskLinkLocation": "end",
12
+ "taskLinkText": "🔗"
13
+ },
14
+ "templater-obsidian": {
15
+ "templatesFolder": "templates",
16
+ "dateFormat": "YYYY-MM-DD",
17
+ "timeFormat": "HH:mm"
18
+ },
19
+ "obsidian-git": {
20
+ "autoCommitMessage": "docs: auto-sync {{date}}",
21
+ "autoPullInterval": 30,
22
+ "autoPushInterval": 30,
23
+ "autoBackupAfterFileChange": true,
24
+ "gitRemote": "origin",
25
+ "syncMethod": "rebase"
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "mermaid": true,
3
+ "tagPane": true,
4
+ "graphView": true,
5
+ "pagePreview": true,
6
+ "backlink": true,
7
+ "outgoingLink": true,
8
+ "outline": true,
9
+ "starred": false,
10
+ "switcher": true,
11
+ "commandPalette": true,
12
+ "markdownImporter": false,
13
+ "wordCount": true,
14
+ "fileExplorer": true,
15
+ "search": true,
16
+ "bookmarks": true,
17
+ "properties": true
18
+ }
@@ -0,0 +1,73 @@
1
+ {
2
+ "core-plugin-list": [
3
+ "backlink",
4
+ "bookmarks",
5
+ "command-palette",
6
+ "daily-notes",
7
+ "file-explorer",
8
+ "file-recovery",
9
+ "global-search",
10
+ "graph-view",
11
+ "outgoing-link",
12
+ "outline",
13
+ "page-preview",
14
+ "properties",
15
+ "random-note",
16
+ "slash-command",
17
+ "switcher",
18
+ "tag-pane",
19
+ "templates",
20
+ "word-count"
21
+ ],
22
+ "enabled": [
23
+ "backlink",
24
+ "bookmarks",
25
+ "command-palette",
26
+ "daily-notes",
27
+ "file-explorer",
28
+ "file-recovery",
29
+ "global-search",
30
+ "graph-view",
31
+ "outgoing-link",
32
+ "outline",
33
+ "page-preview",
34
+ "properties",
35
+ "random-note",
36
+ "slash-command",
37
+ "switcher",
38
+ "tag-pane",
39
+ "templates",
40
+ "word-count"
41
+ ],
42
+ "file-explorer": true,
43
+ "global-search": true,
44
+ "switcher": true,
45
+ "graph": true,
46
+ "backlink": true,
47
+ "canvas": true,
48
+ "outgoing-link": true,
49
+ "tag-pane": true,
50
+ "footnotes": false,
51
+ "properties": true,
52
+ "page-preview": true,
53
+ "daily-notes": true,
54
+ "templates": true,
55
+ "note-composer": true,
56
+ "command-palette": true,
57
+ "slash-command": false,
58
+ "editor-status": true,
59
+ "bookmarks": true,
60
+ "markdown-importer": false,
61
+ "zk-prefixer": false,
62
+ "random-note": false,
63
+ "outline": true,
64
+ "word-count": true,
65
+ "slides": false,
66
+ "audio-recorder": false,
67
+ "workspaces": false,
68
+ "file-recovery": true,
69
+ "publish": false,
70
+ "sync": true,
71
+ "bases": true,
72
+ "webviewer": false
73
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "collapse-filter": true,
3
+ "search": "",
4
+ "showTags": false,
5
+ "showAttachments": false,
6
+ "hideUnresolved": false,
7
+ "showOrphans": true,
8
+ "collapse-color-groups": true,
9
+ "colorGroups": [],
10
+ "collapse-display": true,
11
+ "showArrow": false,
12
+ "textFadeMultiplier": 0,
13
+ "nodeSizeMultiplier": 1,
14
+ "lineSizeMultiplier": 1,
15
+ "collapse-forces": true,
16
+ "centerStrength": 0.518713248970312,
17
+ "repelStrength": 10,
18
+ "linkStrength": 1,
19
+ "linkDistance": 250,
20
+ "scale": 0.6666666666666666,
21
+ "close": true
22
+ }
@@ -0,0 +1,196 @@
1
+ {
2
+ "main": {
3
+ "id": "38cd0250b80f3c65",
4
+ "type": "split",
5
+ "children": [
6
+ {
7
+ "id": "f49eb26fe94f5853",
8
+ "type": "tabs",
9
+ "children": [
10
+ {
11
+ "id": "8dedf7c146f5cebf",
12
+ "type": "leaf",
13
+ "state": {
14
+ "type": "empty",
15
+ "state": {},
16
+ "icon": "lucide-file",
17
+ "title": "Nova aba"
18
+ }
19
+ }
20
+ ]
21
+ }
22
+ ],
23
+ "direction": "vertical"
24
+ },
25
+ "left": {
26
+ "id": "57192ac9415d99df",
27
+ "type": "split",
28
+ "children": [
29
+ {
30
+ "id": "93e26a2b823d31a6",
31
+ "type": "tabs",
32
+ "children": [
33
+ {
34
+ "id": "eec9025824b684fa",
35
+ "type": "leaf",
36
+ "state": {
37
+ "type": "file-explorer",
38
+ "state": {
39
+ "sortOrder": "alphabetical",
40
+ "autoReveal": false
41
+ },
42
+ "icon": "lucide-folder-closed",
43
+ "title": "Explorador de arquivos"
44
+ }
45
+ },
46
+ {
47
+ "id": "12c861fc6eed8790",
48
+ "type": "leaf",
49
+ "state": {
50
+ "type": "search",
51
+ "state": {
52
+ "query": "",
53
+ "matchingCase": false,
54
+ "explainSearch": false,
55
+ "collapseAll": false,
56
+ "extraContext": false,
57
+ "sortOrder": "alphabetical"
58
+ },
59
+ "icon": "lucide-search",
60
+ "title": "Procurar"
61
+ }
62
+ },
63
+ {
64
+ "id": "741d819feaded626",
65
+ "type": "leaf",
66
+ "state": {
67
+ "type": "bookmarks",
68
+ "state": {},
69
+ "icon": "lucide-bookmark",
70
+ "title": "Marcadores"
71
+ }
72
+ }
73
+ ]
74
+ }
75
+ ],
76
+ "direction": "horizontal",
77
+ "width": 300
78
+ },
79
+ "right": {
80
+ "id": "a4b627412871651f",
81
+ "type": "split",
82
+ "children": [
83
+ {
84
+ "id": "e19dd6dbffcc1cd6",
85
+ "type": "tabs",
86
+ "children": [
87
+ {
88
+ "id": "5009486718136ab8",
89
+ "type": "leaf",
90
+ "state": {
91
+ "type": "backlink",
92
+ "state": {
93
+ "file": "06-feedbacks/feedback.md",
94
+ "collapseAll": false,
95
+ "extraContext": false,
96
+ "sortOrder": "alphabetical",
97
+ "showSearch": false,
98
+ "searchQuery": "",
99
+ "backlinkCollapsed": false,
100
+ "unlinkedCollapsed": true
101
+ },
102
+ "icon": "links-coming-in",
103
+ "title": "Links inversos para feedback"
104
+ }
105
+ },
106
+ {
107
+ "id": "2bbe7040a4c87fa6",
108
+ "type": "leaf",
109
+ "state": {
110
+ "type": "outgoing-link",
111
+ "state": {
112
+ "linksCollapsed": false,
113
+ "unlinkedCollapsed": true
114
+ },
115
+ "icon": "links-going-out",
116
+ "title": "Links de saída"
117
+ }
118
+ },
119
+ {
120
+ "id": "4ea52f6f13c06874",
121
+ "type": "leaf",
122
+ "state": {
123
+ "type": "tag",
124
+ "state": {
125
+ "sortOrder": "frequency",
126
+ "useHierarchy": true,
127
+ "showSearch": false,
128
+ "searchQuery": ""
129
+ },
130
+ "icon": "lucide-tags",
131
+ "title": "Etiquetas"
132
+ }
133
+ },
134
+ {
135
+ "id": "6d51f37d307431c8",
136
+ "type": "leaf",
137
+ "state": {
138
+ "type": "all-properties",
139
+ "state": {
140
+ "sortOrder": "frequency",
141
+ "showSearch": false,
142
+ "searchQuery": ""
143
+ },
144
+ "icon": "lucide-archive",
145
+ "title": "Todas as propriedades"
146
+ }
147
+ },
148
+ {
149
+ "id": "844a6214db033948",
150
+ "type": "leaf",
151
+ "state": {
152
+ "type": "outline",
153
+ "state": {
154
+ "followCursor": false,
155
+ "showSearch": false,
156
+ "searchQuery": ""
157
+ },
158
+ "icon": "lucide-list",
159
+ "title": "Sumário"
160
+ }
161
+ }
162
+ ]
163
+ }
164
+ ],
165
+ "direction": "horizontal",
166
+ "width": 300,
167
+ "collapsed": true
168
+ },
169
+ "left-ribbon": {
170
+ "hiddenItems": {
171
+ "switcher:Abrir a troca rápida": false,
172
+ "graph:Abrir visualização em gráfico": false,
173
+ "canvas:Criar novo canvas": false,
174
+ "daily-notes:Abrir a nota de hoje": false,
175
+ "templates:Inserir modelo": false,
176
+ "command-palette:Abrir paleta de comandos": false,
177
+ "bases:Criar nova base": false
178
+ }
179
+ },
180
+ "active": "eec9025824b684fa",
181
+ "lastOpenFiles": [
182
+ "Sem título.md",
183
+ "Sem título",
184
+ "Sem título.base",
185
+ "02-componentes/_index.md",
186
+ "templates/guia.md",
187
+ "templates/componente.md",
188
+ "templates/ADR.md",
189
+ "04-glossario/termos.md",
190
+ "03-guias/testes.md",
191
+ "03-guias/contribuindo.md",
192
+ "01-arquitetura/ADR-001-estrutura-testes.md",
193
+ "01-arquitetura/_index.md",
194
+ "_home.md"
195
+ ]
196
+ }
@@ -0,0 +1,31 @@
1
+ ---
2
+ Proveniência e Autoria: Este documento integra o projeto @mocoto/mahoraga (licença MIT-0).
3
+ tags: [adr, testes]
4
+ status: aceito
5
+ created: 2026-07-24
6
+ ---
7
+
8
+ # ADR-001: Estrutura de Testes com Vitest
9
+
10
+ ## Contexto
11
+
12
+ O projeto precisava de uma estrutura de testes que suportasse mocking de módulos ES, coverage por diretório, e integração com TypeScript sem transpilação extra.
13
+
14
+ ## Decisão
15
+
16
+ - **Framework:** Vitest v4 com v8 coverage
17
+ - **Mocks globais:** `vi.hoisted()` + `vi.mock()` no topo dos testes
18
+ - **Alias:** `@` → `src/types/index.ts` resolvido via `vitest.config.ts`
19
+ - **Organização:** `tests/` espelha `src/` em estrutura de diretórios
20
+ - **Comandos CLI:** `parseAsync([], { from: 'user' })` sem argv posicionais (Commander v15)
21
+
22
+ ## Consequências
23
+
24
+ - Testes rodam em ~30s (full suite) e ~6s (parciais)
25
+ - 238 test files, 3276 testes
26
+ - Coverage total: ~48% (target: 56%+)
27
+
28
+ ## Alternativas Consideradas
29
+
30
+ - **Jest**: maior ecossistema, mas mais lento e sem ESM nativo
31
+ - **Mocha**: flexível, mas sem built-in coverage e mocking
@@ -0,0 +1,152 @@
1
+ ---
2
+ Proveniência e Autoria: Este documento integra o projeto @mocoto/mahoraga (licença MIT-0).
3
+ tags: [moc, arquitetura]
4
+ created: 2026-07-24
5
+ updated: 2026-07-25
6
+ ---
7
+
8
+ # Arquitetura
9
+
10
+ ## Visão Geral
11
+
12
+ O Mahoraga é organizado em 6 camadas:
13
+
14
+ ### 1. Entry Point (`src/bin/index.ts`)
15
+
16
+ Binário executável (`#!/usr/bin/env node`). Inicializa o loader ESM customizado (aliases em runtime), configura handlers globais de erro, carrega configuração, versão, memória de conversação, registra todos os comandos via `registrarComandos()` e executa `program.parseAsync()`.
17
+
18
+ ### 2. CLI Layer (`src/cli/`)
19
+
20
+ Interface com o usuário via Commander.js. 27 comandos registrados em `commands.ts`, cada um implementado em um arquivo `command-*.ts`. Subcomandos para diagnóstico, guardian, CI/CD, licenças, compliance, manutenção, plugins.
21
+
22
+ ### 3. Core Layer (`src/core/`)
23
+
24
+ Motor central do sistema:
25
+ - **execution/**: Scanner, registry, workers, cache, ambiente, linguagens, schema
26
+ - **config/**: Configuração default, scoring, paths, segurança, filtros
27
+ - **parsing/**: Parsers baseados em Babel (AST) + parsers por linguagem
28
+ - **messages/**: Sistema de i18n com suporte a pt (padrão), en, zh, ja
29
+ - **workers/**: Worker pool para processamento paralelo
30
+ - **corrections/**: Auto-fix engine
31
+
32
+ ### 4. Analysis Layer (`src/analysts/`)
33
+
34
+ Analisadores especializados organizados por domínio:
35
+
36
+ **Detectores gerais** (aplicáveis a qualquer projeto):
37
+ - `detectors/`: 12 detectores: architecture, bugs-ml, code-fragile, dependencies, duplications, monorepo, performance, phantoms, recommendation, security, structure
38
+
39
+ **Analisadores por linguagem** (cada um com analysts/, detectors/, corrections/, scorers/):
40
+ - `js-ts/`, `react/`, `css/`, `css-in-js/`, `html/`, `svg/`, `xml/`, `tailwind/`, `python/`, `shell/`, `sql/`, `go/`, `rust/`, `php/`
41
+
42
+ **Analisadores de CI/CD** (cada um com analysts/, detectors/, corrections/, reports/, scorers/):
43
+ - `github-actions/`, `gitlab-ci/`, `circleci/`, `jenkins/`, `azure-pipelines/`
44
+
45
+ **Infraestrutura:**
46
+ - `registry/`: Autodiscovery de analistas
47
+ - `plugins/`: Sistema de plugins (analyst-formatter, detector-documentation, detector-markdown, detector-node)
48
+ - `corrections/`: Correções automáticas (quick-fixes, auto-fix, alias-imports, pruning, barrels, type-safety)
49
+ - `converters/`: Conversão entre plataformas CI/CD
50
+ - `scorers/`: Engine de pontuação
51
+ - `strategists/`: Estratégias de análise (archetypes, suggestions)
52
+
53
+ ### 5. Service Layer
54
+
55
+ | Módulo | Descrição |
56
+ |--------|-----------|
57
+ | `guardian/` | Pipeline de integridade com GPG (Ed25519). Baseline, snapshot, diff, sentinel, verifier |
58
+ | `licenses/` | Gerenciamento de licenças SPDX. Scanner, normalizer, policy, disclaimer, notice generator |
59
+ | `vulnerabilities/` | Scan de vulnerabilidades via npm audit |
60
+ | `caretakers/` | Transformações automáticas: imports, barrels, pruning, map-reversion, scoring |
61
+ | `reports/` | Relatórios: compliance (ISO 27001, SOC 2), advisor, archetypes, streaming NDJSON, fragments |
62
+
63
+ ### 6. Shared Layer (`src/shared/`)
64
+
65
+ Utilitários compartilhados entre módulos:
66
+ - `formatters/`: Motores de formatação (core, engines, formatters)
67
+ - `persistence/`: Persistência de estado
68
+ - `validation/`: Validação de dados
69
+ - `marketplace/`: Marketplace de analistas
70
+ - `plugins/`: Sistema de plugins
71
+ - `helpers/`: Helpers diversos
72
+
73
+ ### 7. Types (`src/types/`)
74
+
75
+ 14 namespaces de tipos TypeScript: analysts, caretakers, common, core, guardian, licenses, processing, project, scripts, sdk, shared, structure, vulnerabilities.
76
+
77
+ ## Fluxo de Dados
78
+
79
+ ```mermaid
80
+ sequenceDiagram
81
+ actor User
82
+ participant CLI as src/cli/
83
+ participant CORE as src/core/
84
+ participant REG as Registry
85
+ participant ANALYST as Analysts
86
+ participant SVC as Services
87
+
88
+ User->>CLI: mahoraga diagnosticar
89
+ CLI->>CORE: scanRepository()
90
+ CORE->>REG: autodiscover()
91
+ REG-->>CORE: analysts[]
92
+ CORE->>ANALYST: analyze(project)
93
+ ANALYST-->>CORE: results[]
94
+ CORE->>SVC: compliance/generate
95
+ SVC-->>CORE: report
96
+ CORE-->>CLI: aggregated results
97
+ CLI-->>User: formatted output
98
+ ```
99
+
100
+ ## Alias System
101
+
102
+ O projeto usa path aliases estilo `@pasta/arquivo` para todos os imports internos, resolvidos em três níveis:
103
+
104
+ 1. **tsconfig.json**: paths mapping (~160+ entradas)
105
+ 2. **node.loader.ts**: Loader ESM customizado para runtime
106
+ 3. **vitest.config.ts**: Aliases para ambiente de teste
107
+
108
+ ## Decisões Arquiteturais
109
+
110
+ - [[ADR-001-estrutura-testes|ADR-001: Estrutura de Testes com Vitest]]
111
+ - Novos ADRs devem seguir o template em `templates/ADR.md`
112
+
113
+ ## Diagrama de Componentes
114
+
115
+ ```mermaid
116
+ flowchart LR
117
+ subgraph CLI["CLI Layer"]
118
+ CMD[commands.ts]
119
+ GHA[github-actions]
120
+ DIAG[diagnosticar]
121
+ LIC[licencas]
122
+ end
123
+ subgraph CORE["Core"]
124
+ EXEC[execution]
125
+ CONF[config]
126
+ MSG[messages]
127
+ WRK[workers]
128
+ end
129
+ subgraph ANAL["Analysts"]
130
+ LANG[js-ts/react/css/...]
131
+ CICD[gha/gitlab/circle/...]
132
+ DET[detectores]
133
+ CORR[corrections]
134
+ end
135
+ subgraph SVC["Services"]
136
+ GRD[guardian]
137
+ CAR[caretakers]
138
+ RPT[reports]
139
+ end
140
+ CLI --> CORE
141
+ CORE --> ANAL
142
+ CORE --> SVC
143
+ ```
144
+
145
+ ## Temas Arquiteturais
146
+
147
+ - **Modularidade**: Cada módulo tem barrel (`index.ts`) e tipos próprios
148
+ - **Autodiscovery**: Novos analistas são detectados sem registro manual
149
+ - **i18n first**: Mensagens em pt, en, zh, ja desde o design
150
+ - **Plugin system**: Analistas e detectores podem ser estendidos via plugins
151
+ - **Streaming**: NDJSON para projetos grandes (>10k arquivos)
152
+ - **Worker pool**: Processamento paralelo para análise intensiva