boxsafe 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/.directory +2 -0
- package/.env.example +3 -0
- package/AUDIT_LANG.md +45 -0
- package/BOXSAFE_VERSION_NOTES.md +14 -0
- package/README.md +4 -0
- package/TODO.md +130 -0
- package/adapters/index.ts +27 -0
- package/adapters/primary/cli-adapter.ts +56 -0
- package/adapters/secondary/filesystem/node-filesystem.ts +307 -0
- package/adapters/secondary/system/configuration.ts +147 -0
- package/ai/caller.ts +42 -0
- package/ai/label.ts +33 -0
- package/ai/modelConfig.ts +236 -0
- package/ai/provider.ts +111 -0
- package/boxsafe.config.json +68 -0
- package/core/auth/dasktop/cred/CRED.md +112 -0
- package/core/auth/dasktop/cred/credLinux.ts +82 -0
- package/core/auth/dasktop/cred/credWin.ts +2 -0
- package/core/config/defaults/boxsafeDefaults.ts +67 -0
- package/core/config/defaults/index.ts +1 -0
- package/core/config/loadConfig.ts +133 -0
- package/core/loop/about.md +13 -0
- package/core/loop/boxConfig.ts +20 -0
- package/core/loop/buildExecCommand.ts +76 -0
- package/core/loop/cmd/execode.ts +121 -0
- package/core/loop/cmd/test.js +3 -0
- package/core/loop/execLoop.ts +341 -0
- package/core/loop/git/VERSIONING.md +17 -0
- package/core/loop/git/commands.ts +11 -0
- package/core/loop/git/gitClient.ts +78 -0
- package/core/loop/git/index.ts +99 -0
- package/core/loop/git/runVersionControlRunner.ts +33 -0
- package/core/loop/initNavigator.ts +44 -0
- package/core/loop/initTasksManager.ts +35 -0
- package/core/loop/runValidation.ts +25 -0
- package/core/loop/tasks/AGENT-TASKS.md +36 -0
- package/core/loop/tasks/index.ts +96 -0
- package/core/loop/toolCalls.ts +168 -0
- package/core/loop/toolDispatcher.ts +146 -0
- package/core/loop/traceLogger.ts +106 -0
- package/core/loop/types.ts +26 -0
- package/core/loop/versionControlAdapter.ts +36 -0
- package/core/loop/waterfall.ts +404 -0
- package/core/loop/writeArtifactAtomically.ts +13 -0
- package/core/navigate/NAVIGATE.md +186 -0
- package/core/navigate/about.md +128 -0
- package/core/navigate/examples.ts +367 -0
- package/core/navigate/handler.ts +148 -0
- package/core/navigate/index.ts +32 -0
- package/core/navigate/navigate.test.ts +372 -0
- package/core/navigate/navigator.ts +437 -0
- package/core/navigate/types.ts +132 -0
- package/core/navigate/utils.ts +146 -0
- package/core/paths/paths.ts +33 -0
- package/core/ports/index.ts +271 -0
- package/core/segments/CONVENTIONS.md +30 -0
- package/core/segments/loop/index.ts +18 -0
- package/core/segments/map.ts +56 -0
- package/core/segments/navigate/index.ts +20 -0
- package/core/segments/versionControl/index.ts +18 -0
- package/core/util/logger.ts +128 -0
- package/docs/AGENT-TASKS.md +36 -0
- package/docs/ARQUITETURA_CORRECAO.md +121 -0
- package/docs/CONVENTIONS.md +30 -0
- package/docs/CRED.md +112 -0
- package/docs/L_RAG.md +567 -0
- package/docs/NAVIGATE.md +186 -0
- package/docs/PRIMARY_ACTORS.md +78 -0
- package/docs/SECONDARY_ACTORS.md +174 -0
- package/docs/VERSIONING.md +17 -0
- package/docs/boxsafe.config.md +472 -0
- package/eslint.config.mts +15 -0
- package/main.ts +53 -0
- package/memo/generated/codelog.md +13 -0
- package/memo/state/tasks/state.json +6 -0
- package/memo/state/tasks/tasks/task_001.md +2 -0
- package/memo/states-logs/logs.txt +7 -0
- package/memo/states-logs/trace-mljvrxvi-9g0k4q.jsonl +11 -0
- package/memo/states-logs/trace-mljvvc9j-pe9ekj.jsonl +11 -0
- package/memo/states-logs/trace-mljvvm1c-wbnqzp.jsonl +11 -0
- package/memo/states-logs/trace-mljxecwn-9xh3nw.jsonl +11 -0
- package/memo/states-logs/trace-mljxqkfm-ipijik.jsonl +11 -0
- package/memo/states-logs/trace-mljxwtrw-3fanky.jsonl +11 -0
- package/memo/states-logs/trace-mljxzen3-m8iinh.jsonl +11 -0
- package/memo/states-logs/trace-mljyucef-td6odn.jsonl +11 -0
- package/memo/states-logs/trace-mljyuprw-b1a6f4.jsonl +11 -0
- package/memo/states-logs/trace-mljyvefl-b6yoce.jsonl +11 -0
- package/memo/states-logs/trace-mljyxjo4-n7ibj2.jsonl +13 -0
- package/memo/states-logs/trace-mljziez5-8drqtn.jsonl +13 -0
- package/memo/states-logs/trace-mljziulp-dtd03z.jsonl +13 -0
- package/memo/states-logs/trace-mljzjwrq-1p2krb.jsonl +13 -0
- package/memo/states-logs/trace-mljzl0i7-b1cqa6.jsonl +13 -0
- package/memo/states-logs/trace-mljzmlk6-7kdyls.jsonl +13 -0
- package/memo/states-logs/trace-mlk0oj25-xa3dcu.jsonl +13 -0
- package/memo/states-logs/trace-mlk1x59q-713huj.jsonl +14 -0
- package/memo/states-logs/trace-mlk22dz8-7fd6hq.jsonl +14 -0
- package/memo/states-logs/trace-mlk241uy-wmx907.jsonl +14 -0
- package/memo/states-logs/trace-mlk2bf5r-yoh1vg.jsonl +15 -0
- package/package.json +44 -0
- package/pnpm-workspace.yaml +4 -0
- package/prompt_improvement_example.md +55 -0
- package/remove.txt +1 -0
- package/tests/adapters.test.ts +128 -0
- package/tests/extractCode.test.ts +26 -0
- package/tests/integration.test.ts +83 -0
- package/tests/loadConfig.test.ts +25 -0
- package/tests/navigatorBoundary.test.ts +17 -0
- package/tests/ports.test.ts +84 -0
- package/tests/runAllTests.ts +49 -0
- package/tests/toolCalls.test.ts +149 -0
- package/tests/waterfall.test.ts +52 -0
- package/tsconfig.json +32 -0
- package/tsup.config.ts +17 -0
- package/types.d.ts +96 -0
- package/util/ANSI.ts +29 -0
- package/util/extractCode.ts +217 -0
- package/util/extractToolCalls.ts +80 -0
- package/util/logger.ts +125 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Correção da Arquitetura Hexagonal - Estrutura Correta
|
|
2
|
+
|
|
3
|
+
## Erro Conceitual Corrigido
|
|
4
|
+
|
|
5
|
+
Você estava **ABSOLUTAMENTE CORRETO**! Cometi um erro fundamental ao colocar adapters dentro do core.
|
|
6
|
+
|
|
7
|
+
## Estrutura ERRADA (que eu criei inicialmente):
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
core/
|
|
11
|
+
├── ports/ ✓ Correto
|
|
12
|
+
├── adapters/ ✗ ERRADO - adapters ficam FORA do core
|
|
13
|
+
└── domain/ ✓ Correto
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Estrutura CORRETA (arquitetura hexagonal propriamente dita):
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
src/
|
|
20
|
+
├── core/ ← Apenas domínio puro + interfaces
|
|
21
|
+
│ ├── domain/ ← Lógica de negócio do BoxSafe
|
|
22
|
+
│ └── ports/ ← Interfaces/Contratos (sem implementação)
|
|
23
|
+
├── adapters/ ← FORA do core - implementações concretas
|
|
24
|
+
│ ├── primary/ ← Adaptam Primary Actors (CLI, Web, IDE)
|
|
25
|
+
│ │ └── cli-adapter.ts
|
|
26
|
+
│ └── secondary/ ← Adaptam Secondary Actors (FS, AI, Git)
|
|
27
|
+
│ ├── system/
|
|
28
|
+
│ │ └── configuration.ts
|
|
29
|
+
│ └── filesystem/
|
|
30
|
+
│ └── node-filesystem.ts
|
|
31
|
+
└── infrastructure/ ← Configuração, setup, etc.
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Por Que Adapters Ficam FORA do Core?
|
|
35
|
+
|
|
36
|
+
### 1. **Princípio da Inversão de Dependência**
|
|
37
|
+
```typescript
|
|
38
|
+
// ERRADO - Core depende de implementações
|
|
39
|
+
core/
|
|
40
|
+
├── adapters/ ← Implementações concretas DENTRO do core
|
|
41
|
+
└── ports/
|
|
42
|
+
|
|
43
|
+
// CORRETO - Core depende apenas de abstrações
|
|
44
|
+
core/
|
|
45
|
+
└── ports/ ← Apenas interfaces
|
|
46
|
+
|
|
47
|
+
adapters/ ← Implementações concretas FORA do core
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 2. **Core Deve Ser Puro**
|
|
51
|
+
O core contém apenas:
|
|
52
|
+
- **Regras de negócio** (domain logic)
|
|
53
|
+
- **Interfaces** (ports)
|
|
54
|
+
- **Entidades** do domínio
|
|
55
|
+
|
|
56
|
+
**NUNCA** contém:
|
|
57
|
+
- Implementações concretas
|
|
58
|
+
- Dependências externas
|
|
59
|
+
- Detalhes de infraestrutura
|
|
60
|
+
|
|
61
|
+
### 3. **Adapters São Infraestrutura**
|
|
62
|
+
Adapters são código de **glue** que conecta:
|
|
63
|
+
- **Primary Actors** → **Core** (Primary Adapters)
|
|
64
|
+
- **Core** → **Secondary Actors** (Secondary Adapters)
|
|
65
|
+
|
|
66
|
+
## Fluxo Correto na Arquitetura Hexagonal
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
┌─────────────────────────────────────┐
|
|
70
|
+
│ Primary Actors │
|
|
71
|
+
│ (CLI, Web, IDE) │
|
|
72
|
+
├─────────────────────────────────────┤
|
|
73
|
+
│ PRIMARY ADAPTERS │ ← FORA do core
|
|
74
|
+
│ ┌─────────────────────────┐ │
|
|
75
|
+
│ │ CLIAdapter │ │
|
|
76
|
+
│ │ implements ISystem │ │
|
|
77
|
+
│ │ ExecutionPort │ │
|
|
78
|
+
│ └─────────────────────────┘ │
|
|
79
|
+
├─────────────────────────────────────┤
|
|
80
|
+
│ CORE │ ← Puro, apenas interfaces
|
|
81
|
+
│ ┌─────────────────────────────────┐ │
|
|
82
|
+
│ │ PORTS │ │
|
|
83
|
+
│ │ ISystemExecutionPort │ │
|
|
84
|
+
│ │ IFileSystemPort │ │
|
|
85
|
+
│ │ IAIModelPort │ │
|
|
86
|
+
│ └─────────────────────────────────┘ │
|
|
87
|
+
│ ┌─────────────────────────────────┐ │
|
|
88
|
+
│ │ DOMAIN LOGIC │ │
|
|
89
|
+
│ │ (regras do BoxSafe) │ │
|
|
90
|
+
│ └─────────────────────────────────┘ │
|
|
91
|
+
├─────────────────────────────────────┤
|
|
92
|
+
│ SECONDARY ADAPTERS │ ← FORA do core
|
|
93
|
+
│ ┌─────────┬─────────────────────┐ │
|
|
94
|
+
│ │ FileSystem│ AI Model │ │
|
|
95
|
+
│ │ Adapter │ Adapter │ │
|
|
96
|
+
│ └─────────┴─────────────────────┘ │
|
|
97
|
+
├─────────────────────────────────────┤
|
|
98
|
+
│ Secondary Actors │
|
|
99
|
+
│ (FileSystem, AI, Git, etc.) │
|
|
100
|
+
└─────────────────────────────────────┘
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Benefícios da Estrutura Correta
|
|
104
|
+
|
|
105
|
+
1. **Core Isolado**: Pode ser testado sem dependências externas
|
|
106
|
+
2. **Flexibilidade**: Fácil trocar adapters sem afetar o core
|
|
107
|
+
3. **Manutenibilidade**: Mudanças na infra não afetam o domínio
|
|
108
|
+
4. **Reusabilidade**: Core pode ser usado com diferentes tecnologias
|
|
109
|
+
|
|
110
|
+
## Ação Corretiva Executada
|
|
111
|
+
|
|
112
|
+
1. ✅ Movido `core/adapters/` → `adapters/`
|
|
113
|
+
2. ✅ Separado em `adapters/primary/` e `adapters/secondary/`
|
|
114
|
+
3. ✅ Mantido `core/ports/` com apenas interfaces
|
|
115
|
+
4. ✅ Criado `adapters/index.ts` para export centralizado
|
|
116
|
+
|
|
117
|
+
## Conclusão
|
|
118
|
+
|
|
119
|
+
Sua observação estava **100% correta**. A arquitetura hexagonal exige que adapters fiquem **fora do core** para manter o domínio puro e desacoplado de detalhes de infraestrutura.
|
|
120
|
+
|
|
121
|
+
Obrigado pela correção! Isso melhora significativamente a qualidade da arquitetura.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Segments (skills) conventions
|
|
2
|
+
|
|
3
|
+
## Folder layout
|
|
4
|
+
|
|
5
|
+
Each segment must live in its own folder:
|
|
6
|
+
|
|
7
|
+
- `core/sgmnt/<segment>/index.ts`
|
|
8
|
+
|
|
9
|
+
`index.ts` must export a factory function:
|
|
10
|
+
|
|
11
|
+
- `create<SegmentName>Segment(BSConfig)`
|
|
12
|
+
|
|
13
|
+
The factory returns an object with the same shape used by `core/sgmnt/map.ts`:
|
|
14
|
+
|
|
15
|
+
- `handler: (args?: any) => Promise<any>`
|
|
16
|
+
- `meta: { description: string; implemented: boolean; config?: any }`
|
|
17
|
+
|
|
18
|
+
## map.ts responsibilities
|
|
19
|
+
|
|
20
|
+
`core/sgmnt/map.ts` is the composer:
|
|
21
|
+
|
|
22
|
+
- loads config (`loadBoxSafeConfig`)
|
|
23
|
+
- instantiates each segment via its factory
|
|
24
|
+
- exposes `{ routes, runSegment, BSConfig }`
|
|
25
|
+
|
|
26
|
+
## Adding a new segment
|
|
27
|
+
|
|
28
|
+
1. Create folder `core/sgmnt/<segment>/`
|
|
29
|
+
2. Implement `index.ts` exporting `create<SegmentName>Segment`
|
|
30
|
+
3. Register it inside `core/sgmnt/map.ts` under `routes`.
|
package/docs/CRED.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Credenciais Linux (credLinux)
|
|
2
|
+
|
|
3
|
+
Módulo para gerenciar credenciais usando o **secret-tool** do Linux (keyring nativo).
|
|
4
|
+
|
|
5
|
+
## Requisitos
|
|
6
|
+
|
|
7
|
+
- Linux com `secret-tool` instalado (já vem na maioria das distros)
|
|
8
|
+
- Funciona em qualquer desktop environment (GNOME, KDE, XFCE, etc.)
|
|
9
|
+
|
|
10
|
+
## Importação
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import { saveCredLinux, getCredLinux, deleteCredLinux } from '@memo/desktop/pass';
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Funções
|
|
17
|
+
|
|
18
|
+
### `saveCredLinux()`
|
|
19
|
+
|
|
20
|
+
Salva uma credencial no keyring do sistema.
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
const success = await saveCredLinux({
|
|
24
|
+
password: 'minha-senha-secreta',
|
|
25
|
+
label: 'GitHub Token',
|
|
26
|
+
account: 'gh-token',
|
|
27
|
+
service: 'meu-app' // opcional, default: 'box-safe'
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Retorna: true (sucesso) | false (erro)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### `getCredLinux()`
|
|
34
|
+
|
|
35
|
+
Recupera uma credencial salva.
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
const token = await getCredLinux({
|
|
39
|
+
account: 'gh-token',
|
|
40
|
+
service: 'meu-app' // opcional, default: 'box-safe'
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Retorna: string (senha) | null (não encontrada)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### `deleteCredLinux()`
|
|
47
|
+
|
|
48
|
+
Remove uma credencial do keyring.
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
const deleted = await deleteCredLinux({
|
|
52
|
+
account: 'gh-token',
|
|
53
|
+
service: 'meu-app' // opcional, default: 'box-safe'
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Retorna: true (sucesso) | false (erro)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Exemplo Completo
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
// Salvar API key
|
|
63
|
+
await saveCredLinux({
|
|
64
|
+
password: 'sk-xxxxxxxxxxxxx',
|
|
65
|
+
label: 'OpenAI API Key',
|
|
66
|
+
account: 'openai-key'
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Usar depois
|
|
70
|
+
const apiKey = await getCredLinux({ account: 'openai-key' });
|
|
71
|
+
if (apiKey) {
|
|
72
|
+
console.log('Key encontrada:', apiKey);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Limpar quando não precisar mais
|
|
76
|
+
await deleteCredLinux({ account: 'openai-key' });
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Parâmetros
|
|
80
|
+
|
|
81
|
+
### CredentialArgs (save)
|
|
82
|
+
- `password`: senha/token a salvar
|
|
83
|
+
- `label`: descrição amigável (aparece na GUI do keyring)
|
|
84
|
+
- `account`: identificador único da credencial
|
|
85
|
+
- `service`: (opcional) nome do app/serviço (default: `box-safe`)
|
|
86
|
+
|
|
87
|
+
### LookupArgs (get/delete)
|
|
88
|
+
- `account`: identificador da credencial
|
|
89
|
+
- `service`: (opcional) nome do app/serviço (default: `box-safe`)
|
|
90
|
+
|
|
91
|
+
## Onde ficam salvos?
|
|
92
|
+
|
|
93
|
+
As credenciais são criptografadas e salvas em:
|
|
94
|
+
```
|
|
95
|
+
~/.local/share/keyrings/
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Você pode visualizar usando `seahorse` (GNOME) ou a GUI do seu keyring.
|
|
99
|
+
|
|
100
|
+
## Logs
|
|
101
|
+
|
|
102
|
+
O módulo só loga erros no console. Se algo falhar:
|
|
103
|
+
- `saveCredLinux`: retorna `false`
|
|
104
|
+
- `getCredLinux`: retorna `null`
|
|
105
|
+
- `deleteCredLinux`: retorna `false`
|
|
106
|
+
|
|
107
|
+
Tratamento de erro fica por sua conta.
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
## WINDOWS
|
|
111
|
+
for windows we use keytar
|
|
112
|
+
|