jarvis-ai-framework 8.8.0 → 9.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.md +26 -36
- package/README.md +20 -8
- package/agents/AGENTS.md +8 -14
- package/agents/README.md +17 -25
- package/agents/engineering/eng.agent.md +10 -12
- package/agents/engineering/eng.bug-hunter.md +7 -10
- package/agents/engineering/eng.dev-code-reviewer.md +1 -1
- package/agents/engineering/eng.frontend.agent.md +3 -2
- package/agents/engineering/eng.rpa.agent.md +8 -6
- package/agents/engineering/qa/eng.qa.test-planner.md +2 -2
- package/agents/engineering/qa/eng.qa.testing-engineer.md +10 -97
- package/agents/product/prod.discovery-interviewer.md +1 -1
- package/bin/README.md +10 -10
- package/bin/commands/init.js +30 -43
- package/bin/commands/rules.js +11 -24
- package/bin/commands/tokens.js +20 -42
- package/bin/commands/whoami.js +2 -18
- package/bin/lib/auth/session.js +1 -27
- package/bin/lib/cli/program.js +2 -9
- package/bin/lib/config/constants.js +97 -24
- package/bin/lib/config/ide-config.js +0 -8
- package/bin/lib/core/env-paths.js +2 -2
- package/bin/lib/core/env-upgrade.js +61 -9
- package/bin/lib/core/profile-filter.js +31 -94
- package/bin/lib/core/sync-engine.js +42 -44
- package/bin/lib/core/token-report.js +11 -13
- package/bin/lib/docs/validate-frontmatter.js +0 -42
- package/bin/lib/utils/git-parser.js +0 -5
- package/bin/lib/utils/paths.js +0 -16
- package/package.json +2 -3
- package/rules/artifact-style-rules.md +2 -4
- package/rules/company-overlay-rules.md +0 -2
- package/rules/engineering/eng-rules.md +3 -29
- package/rules/engineering/eng-security-rules.md +0 -15
- package/rules/engineering/eng.integrations-rules.md +3 -12
- package/rules/engineering/eng.skills-rules.md +0 -2
- package/rules/engineering/eng.specializations-rules.md +0 -2
- package/rules/product/prod-rules.md +0 -2
- package/rules/rtk-rules.md +0 -2
- package/rules-on-demand/doc-links-rules.md +5 -7
- package/rules-on-demand/engineering/eng.bump-rules.md +0 -2
- package/rules-on-demand/engineering/eng.gate0-rules.md +0 -2
- package/rules-on-demand/engineering/eng.plan-rules.md +0 -2
- package/rules-on-demand/engineering/eng.pr-rules.md +1 -3
- package/rules-on-demand/engineering/eng.pre-pr-rules.md +2 -4
- package/rules-on-demand/engineering/eng.rpa-rules.md +0 -2
- package/rules-on-demand/engineering/eng.security-rules.md +0 -2
- package/rules-on-demand/engineering/eng.start-rules.md +0 -2
- package/rules-on-demand/engineering/eng.tech-spec-rules.md +5 -6
- package/rules-on-demand/engineering/eng.transitions-rules.md +3 -5
- package/rules-on-demand/engineering/eng.work-rules.md +0 -2
- package/{rules → rules-on-demand}/engineering/frontend/eng.frontend-rules.md +1 -3
- package/rules-on-demand/product/prod.guided-rules.md +2 -4
- package/rules-on-demand/product/prod.spec-common-rules.md +2 -4
- package/{rules → rules-on-demand}/product/prod.spec-rules.md +2 -4
- package/rules-on-demand/warm-up-consume-rules.md +0 -2
- package/skills/AGENTS.md +7 -23
- package/skills/eng-frontend/SKILL.md +2 -0
- package/skills/{eng-backend-arch-c4 → eng-global-arch-c4}/SKILL.md +19 -27
- package/skills/{eng-backend-arch-c4 → eng-global-arch-c4}/references/1-nivel-context.md +1 -1
- package/skills/{eng-backend-arch-c4 → eng-global-arch-c4}/references/2-nivel-container.md +1 -1
- package/skills/{eng-backend-arch-c4 → eng-global-arch-c4}/references/3-nivel-component.md +1 -1
- package/skills/{eng-backend-arch-c4 → eng-global-arch-c4}/references/4-nivel-code.md +1 -1
- package/skills/{eng-backend-arch-c4 → eng-global-arch-c4}/references/5-atualizacao-e-adrs.md +1 -1
- package/skills/eng-global-docs-write/SKILL.md +5 -3
- package/skills/eng-global-tech-spec/SKILL.md +1 -1
- package/skills/eng-global-tech-spec/references/delivery-spec.md +22 -9
- package/skills/eng-global-tech-spec/references/reference-spec.md +1 -1
- package/skills/jarvis-context-detect/SKILL.md +19 -16
- package/skills/jarvis-context-detect/assets/context-profile-template.md +2 -2
- package/skills/jarvis-context-detect/references/cdd-aplicado-a-prompts.md +9 -10
- package/skills/jarvis-create-specialization/assets/skill-especializacao-template.md +0 -1
- package/skills/jarvis-docs-index/SKILL.md +1 -1
- package/skills/jarvis-evolution-architect/references/visao-geral.md +1 -1
- package/skills/jarvis-init/SKILL.md +82 -118
- package/skills/jarvis-init/assets/exemplo-execucao.md +8 -8
- package/skills/jarvis-init/assets/onboarding-checklist.md +0 -1
- package/skills/jarvis-init/assets/rules-sync-manual.md +11 -68
- package/skills/jarvis-init/assets/upgrade.md +7 -7
- package/skills/jarvis-init/assets/validacoes.md +3 -22
- package/taxonomy.md +6 -156
- package/templates/AGENTS.md +16 -16
- package/templates/ENV-template.md +16 -35
- package/templates/engineering/AGENTS-template.md +1 -1
- package/templates/engineering/architecture-template.md +4 -4
- package/templates/engineering/tech-spec-delivery-template.md +88 -4
- package/workflows/AGENTS.md +11 -17
- package/workflows/README.md +10 -23
- package/workflows/engineering/eng.build-tech-spec.md +0 -25
- package/workflows/engineering/eng.create-ard.md +74 -9
- package/workflows/engineering/eng.debug.md +8 -8
- package/workflows/engineering/eng.light-arch.md +2 -3
- package/workflows/engineering/eng.plan.md +11 -7
- package/workflows/engineering/eng.pr.md +2 -1
- package/workflows/engineering/eng.pre-pr.md +5 -2
- package/workflows/engineering/eng.rpa.robot.md +1 -1
- package/workflows/engineering/eng.start.md +2 -2
- package/workflows/engineering/eng.work.md +0 -2
- package/workflows/engineering/frontend/eng.frontend-component.md +1 -1
- package/workflows/engineering/frontend/eng.frontend-perf-audit.md +1 -1
- package/workflows/engineering/frontend/eng.frontend-review.md +2 -2
- package/workflows/product/prod.spec.ard.md +7 -5
- package/workflows/product/prod.spec.breakdown.md +3 -3
- package/workflows/product/prod.spec.clarify.md +2 -0
- package/workflows/product/prod.spec.discovery.md +1 -1
- package/workflows/product/prod.spec.epic.md +2 -2
- package/workflows/product/prod.spec.frd.md +2 -2
- package/workflows/product/prod.spec.issue.md +2 -2
- package/workflows/product/prod.spec.prd.md +2 -2
- package/workflows/taxonomy.md +10 -17
- package/workflows/warm-up.md +1 -1
- package/agents/engineering/data/eng.data-engineer.agent.md +0 -250
- package/agents/engineering/qa/eng.qa.quality-champion-task-agent.md +0 -89
- package/agents/engineering/qa/eng.qa.quality-strategist.md +0 -116
- package/members.md +0 -25
- package/rules/engineering/qa/eng.qa.cypress-standards-rules.md +0 -5
- package/rules-on-demand/engineering/eng.breakdown-subtasks-rules.md +0 -556
- package/rules-on-demand/engineering/qa/eng.qa.cypress-standards-rules.md +0 -259
- package/skills/SKILLS-ROADMAP.md +0 -232
- package/skills/eng-qa-planner/assets/test-coverage-template.md +0 -92
- package/skills/eng-qa-planner/assets/test-patterns.md +0 -178
- package/skills/product-roadmap-report/README.md +0 -303
- package/skills/product-roadmap-report/SKILL.md +0 -208
- package/skills/product-roadmap-report/commands/status.compiled.single.team.md +0 -23
- package/skills/product-roadmap-report/commands/status.list.projects.md +0 -17
- package/skills/product-roadmap-report/commands/status.memory.md +0 -192
- package/skills/product-roadmap-report/commands/status.roadmap.preview.md +0 -94
- package/skills/product-roadmap-report/references/detailed-guide.md +0 -236
- package/skills/product-roadmap-report/rules/status-report-rules.md +0 -44
- package/skills/product-roadmap-report/templates/template-multiple-teams-compiled-status.md +0 -53
- package/skills/product-roadmap-report/templates/template-projects-list.md +0 -23
- package/skills/product-roadmap-report/templates/template-single-team-compiled-status.md +0 -60
- package/skills/product-roadmap-report/templates/template-single-team-status.md +0 -49
- package/skills/product-specs/SKILL.md +0 -52
- package/skills/product-specs-update/SKILL.md +0 -295
- package/templates/engineering/breakdown-subtasks-template.md +0 -211
- package/templates/engineering/data-contract-template.md +0 -135
- package/templates/engineering/data-pipeline-template.md +0 -163
- package/templates/engineering/qa/qa.release-signoff-template.md +0 -54
- package/templates/engineering/qa/qa.sprint-plan-template.md +0 -49
- package/templates/engineering/work-progress-template.md +0 -159
- package/workflows/engineering/data/data.contract.md +0 -210
- package/workflows/engineering/data/data.new-pipeline.md +0 -241
- package/workflows/engineering/eng.breakdown-subtasks.md +0 -201
- package/workflows/engineering/eng.create-ard-from-code.md +0 -240
- package/workflows/engineering/eng.docs.md +0 -48
- package/workflows/engineering/eng.review.md +0 -185
- package/workflows/engineering/qa/eng.qa-refinement-entry.md +0 -88
- package/workflows/engineering/qa/eng.qa-release-signoff.md +0 -108
- package/workflows/engineering/qa/eng.qa-sprint-planning.md +0 -102
- package/workflows/product/prod.roadmap.preview.md +0 -115
- /package/skills/{eng-backend-arch-c4 → eng-global-arch-c4}/assets/example-code.md +0 -0
- /package/skills/{eng-backend-arch-c4 → eng-global-arch-c4}/assets/example-component.md +0 -0
- /package/skills/{eng-backend-arch-c4 → eng-global-arch-c4}/assets/example-container.md +0 -0
- /package/skills/{eng-backend-arch-c4 → eng-global-arch-c4}/assets/example-context.md +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: testing-engineer
|
|
3
|
-
description: Escreve testes unitários e E2E eficazes para código existente
|
|
3
|
+
description: Escreve testes unitários e E2E eficazes para código existente, com a ferramenta de E2E do projeto. Foca em testar comportamento real e encontrar bugs reais. Sinaliza lacunas de implementação que precisam de atenção do agente principal.
|
|
4
4
|
tools: Read, Glob, Grep, LS, Bash, Write, Edit, MultiEdit
|
|
5
5
|
model: sonnet
|
|
6
6
|
---
|
|
@@ -8,7 +8,7 @@ model: sonnet
|
|
|
8
8
|
# Testing Engineer - Engenheiro de Testes
|
|
9
9
|
|
|
10
10
|
Você é um **engenheiro de testes** focado em escrever testes práticos que verificam se o código
|
|
11
|
-
realmente funciona como pretendido — tanto testes unitários quanto E2E
|
|
11
|
+
realmente funciona como pretendido — tanto testes unitários quanto E2E.
|
|
12
12
|
|
|
13
13
|
## Skills Disponíveis
|
|
14
14
|
|
|
@@ -25,94 +25,9 @@ Para detecção automatizada do contexto (calibração contextual do agente):
|
|
|
25
25
|
- Arquivo: `$IDE/skills/jarvis-context-detect/SKILL.md`
|
|
26
26
|
- Uso: `/jarvis-context-detect {TASK_MANAGER_KEY}`
|
|
27
27
|
|
|
28
|
-
> **
|
|
29
|
-
> Consultar `$IDE/rules-on-demand/engineering/qa/eng.qa.cypress-standards-rules.md` para convenções do projeto.
|
|
28
|
+
> **Testes E2E**: a ferramenta do projeto, pela especialização registrada em `QA_SPECIALIZATIONS` (via a base `eng-qa`).
|
|
30
29
|
>
|
|
31
30
|
> **Testes unitários**: linguagem/framework nativo do projeto (TypeScript/Jest, Python/pytest, etc.)
|
|
32
|
-
> A especialização de E2E registrada em `QA_SPECIALIZATIONS` (via a base `eng-qa`) complementa, não substitui Cypress.
|
|
33
|
-
|
|
34
|
-
---
|
|
35
|
-
|
|
36
|
-
## Cypress E2E — Domínio e Debugging
|
|
37
|
-
|
|
38
|
-
> 🔒 **Fonte de verdade de convenções**: `$IDE/rules-on-demand/engineering/qa/eng.qa.cypress-standards-rules.md`
|
|
39
|
-
> Sempre ler antes de sugerir padrões ou gerar código. Para **gerar** uma spec nova, use a especialização de Cypress registrada em `QA_SPECIALIZATIONS` (via a base `eng-qa`); esta seção cobre o julgamento por trás de revisar, debugar e manter specs existentes.
|
|
40
|
-
|
|
41
|
-
### Domínios de Expertise
|
|
42
|
-
|
|
43
|
-
#### Page Objects
|
|
44
|
-
- Estrutura fluent (retorno `this`)
|
|
45
|
-
- Organização por domínio vs. por página
|
|
46
|
-
- Herança e composição entre Page Objects
|
|
47
|
-
- Quando criar vs. quando estender um existente
|
|
48
|
-
|
|
49
|
-
#### Custom Commands
|
|
50
|
-
- Tipagem com TypeScript (`Cypress.Commands.add`)
|
|
51
|
-
- Declaração em `support/index.d.ts`
|
|
52
|
-
- Commands de autenticação via `cy.request` (não via UI)
|
|
53
|
-
- Commands de setup de estado (seed de dados, limpeza)
|
|
54
|
-
|
|
55
|
-
#### Fixtures e Intercepts
|
|
56
|
-
- Estrutura de pastas de fixtures por domínio
|
|
57
|
-
- Tipagem de fixtures com tipos do projeto (`cy.fixture<T>`)
|
|
58
|
-
- Padrões de `cy.intercept` para REST e GraphQL
|
|
59
|
-
- Gestão de aliases e `cy.wait`
|
|
60
|
-
- Estratégia de intercept para diferentes cenários (sucesso, erro, timeout)
|
|
61
|
-
|
|
62
|
-
#### Viewport e Responsividade
|
|
63
|
-
- `cy.viewport()` para testes multi-device
|
|
64
|
-
- Breakpoints a cobrir conforme o projeto
|
|
65
|
-
- Configuração em `cypress.config.ts`
|
|
66
|
-
|
|
67
|
-
#### Configuração e CI
|
|
68
|
-
- `cypress.config.ts` — baseUrl, env, retries, video
|
|
69
|
-
- Estratégia de retries para flakiness (retry ≠ resolver o problema)
|
|
70
|
-
- Paralelização com Cypress Cloud ou via CI nativo
|
|
71
|
-
- Variáveis de ambiente seguras (`Cypress.env()` vs. hardcode)
|
|
72
|
-
- Artefatos de CI: screenshots, vídeos, relatórios
|
|
73
|
-
|
|
74
|
-
### Debugging de Testes Flaky
|
|
75
|
-
|
|
76
|
-
Causas comuns e soluções:
|
|
77
|
-
|
|
78
|
-
| Causa | Sintoma | Solução |
|
|
79
|
-
|-------|---------|---------|
|
|
80
|
-
| Race condition | Teste falha 1 em 5 vezes | Usar `cy.wait('@alias')` em vez de `cy.wait(ms)` |
|
|
81
|
-
| Estado compartilhado | Teste passa isolado, falha em suite | `beforeEach` garante estado limpo |
|
|
82
|
-
| Animação/transição | Clique em elemento não dispara | `.should('be.visible')` antes de `.click()` |
|
|
83
|
-
| Dados dinâmicos | Assertion em texto que muda | Usar `contain` em vez de `eq`, ou mockar dado |
|
|
84
|
-
| API real | Falha intermitente por timeout | Interceptar sempre — nunca depender de API real |
|
|
85
|
-
| Seletor frágil | Falha após deploy de UI | Migrar para `data-testid` |
|
|
86
|
-
|
|
87
|
-
### Para Debugging de Spec Cypress
|
|
88
|
-
|
|
89
|
-
1. Perguntar: o teste falha sempre ou às vezes? (determina se é flaky ou quebrado)
|
|
90
|
-
2. Pedir o erro e o trecho de código relevante
|
|
91
|
-
3. Identificar a causa raiz antes de sugerir solução
|
|
92
|
-
4. Nunca recomendar aumentar retry como solução definitiva
|
|
93
|
-
|
|
94
|
-
### Para Revisão de Spec Cypress
|
|
95
|
-
|
|
96
|
-
Ler a spec fornecida e verificar:
|
|
97
|
-
- Seletores: algum usando classe/id? → migrar para `data-testid`
|
|
98
|
-
- Intercepts: alguma API não interceptada? → adicionar
|
|
99
|
-
- Dependência entre testes: algum `it` depende de outro? → corrigir
|
|
100
|
-
- `cy.wait(ms)` hardcoded? → substituir por alias
|
|
101
|
-
- Page Object ausente? → criar ou indicar onde adicionar
|
|
102
|
-
|
|
103
|
-
### Regras Específicas de Cypress
|
|
104
|
-
|
|
105
|
-
**Nunca**
|
|
106
|
-
- Sugerir `cy.wait({número})` como solução — identificar a causa real da espera
|
|
107
|
-
- Aceitar seletores por classe CSS em specs novas
|
|
108
|
-
- Recomendar retry como fix de flakiness — é um paliativo, não solução
|
|
109
|
-
- Ignorar tipagem TypeScript — fixtures, commands e Page Objects devem ser tipados
|
|
110
|
-
|
|
111
|
-
**Sempre**
|
|
112
|
-
- Ler `eng.qa.cypress-standards-rules.md` antes de qualquer sugestão de padrão
|
|
113
|
-
- Justificar por que uma prática é ruim antes de sugerir a alternativa
|
|
114
|
-
- Verificar se já existe Page Object/command para o domínio antes de criar novo
|
|
115
|
-
- Considerar manutenibilidade: um teste bom é um teste que não falha sem razão
|
|
116
31
|
|
|
117
32
|
---
|
|
118
33
|
|
|
@@ -138,17 +53,15 @@ Se existir `$SESSIONS_DIR/eng/{TASK_MANAGER_KEY}/context.md` (gerado por `/jarvi
|
|
|
138
53
|
| `feature` | Alto - happy path + edge cases + erros | Toda funcionalidade nova |
|
|
139
54
|
| `refactor` | Muito alto - garantir comportamento idêntico | 100% do código refatorado |
|
|
140
55
|
|
|
141
|
-
### Calibração
|
|
56
|
+
### Calibração pela senioridade da área (do context.md ou ENV.md)
|
|
142
57
|
|
|
143
|
-
|
|
|
144
|
-
|
|
145
|
-
|
|
|
146
|
-
|
|
|
147
|
-
|
|
|
148
|
-
| Gestão | `pm`, `tpm`, `gpm` | Foco em impacto de negócio dos testes |
|
|
149
|
-
| Executivo | `cto`, `principal` | Visão estratégica de qualidade |
|
|
58
|
+
| Senioridade | Comportamento |
|
|
59
|
+
|-------------|---------------|
|
|
60
|
+
| `junior` | Explicar padrões AAA, mostrar exemplos, sugerir leituras |
|
|
61
|
+
| `pleno` | Explicar só o que não é óbvio |
|
|
62
|
+
| `senior` | Ser direto, focar em edge cases críticos |
|
|
150
63
|
|
|
151
|
-
> ⚠️
|
|
64
|
+
> ⚠️ Mais de uma área: a menor senioridade; sem valor: `SENIORITY`; sem `SENIORITY`: `pleno`.
|
|
152
65
|
|
|
153
66
|
### Calibração por Urgência (do context.md)
|
|
154
67
|
|
|
@@ -26,7 +26,7 @@ Você é um product manager experiente: **testa a ideia, não a julga**, e econo
|
|
|
26
26
|
### jarvis-docs-central
|
|
27
27
|
O que já foi implementado, quando `CENTRAL_DOCS_STORAGE` estiver configurado. Confiança: sempre.
|
|
28
28
|
|
|
29
|
-
### eng-
|
|
29
|
+
### eng-global-arch-c4
|
|
30
30
|
Arquitetura atual. Confiança: só com a confirmação do usuário; o retorno é **suposição a validar**.
|
|
31
31
|
|
|
32
32
|
### eng-platform
|
package/bin/README.md
CHANGED
|
@@ -27,7 +27,7 @@ bin/
|
|
|
27
27
|
├── config/ # ide-config.js (fonte de verdade de IDEs), constants.js
|
|
28
28
|
├── core/ # scanner.js, sync-engine.js (inclui o RuleResolver do overlay), profile-filter.js, token-report.js, company-profile.js (COMPANY_PROFILE e o default stark-industries)
|
|
29
29
|
├── docs/ # Central docs, por funcionalidade (#220): fetch/publish/migrate/archive/finalize + validação
|
|
30
|
-
│ ├── validate-frontmatter.js # Valida
|
|
30
|
+
│ ├── validate-frontmatter.js # Valida frontmatter (feature, delivery, product, home, history, architecture, plan, light-arch e documentos de trabalho: PRD, FRD, épico, história, tarefa, ARD, RFC, QA, discovery)
|
|
31
31
|
│ ├── fetch-file.js # openStorageFromEnv() + fetchFile() — `docs sync`/`docs fetch`/`docs publish`/`docs migrate`/`docs archive`/`docs finalize`
|
|
32
32
|
│ ├── publish-file.js # tipos, resolveDestPath(), publishFile() e publishFiles() (lote, `--dry-run`, nome com o card, conversão de links) — `docs publish [--manifest]`
|
|
33
33
|
│ ├── session-inventory.js # inventário das sessões (arquivos, entrega, página-índice, pendente) — `docs sessions`
|
|
@@ -38,7 +38,7 @@ bin/
|
|
|
38
38
|
│ └── storage/ # adaptadores (CENTRAL_DOCS_STORAGE): index.js (fábrica), filesystem.js (pasta + git, inclui publishBatch), build-index.js
|
|
39
39
|
├── utils/ # logger.js, ui.js, paths.js, frontmatter.js (inclui readDescription), git-parser.js
|
|
40
40
|
├── flow-map/ # `jarvis map` — grafo de chamadas entre workflows/skills/agents
|
|
41
|
-
├── auth/ # session.js (
|
|
41
|
+
├── auth/ # session.js (resolveUser: identidade por ENV.md, git e SO)
|
|
42
42
|
└── env-loader.js # Resolve e lê o ENV.md ($IDE/ENV.md)
|
|
43
43
|
```
|
|
44
44
|
|
|
@@ -57,11 +57,11 @@ bin/commands/*.js → lógica de negócio pura: async (flags) => {...}
|
|
|
57
57
|
- Trocar de biblioteca de CLI um dia (se um dia fizer sentido) significa reescrever só `program.js`, não os arquivos de `bin/commands/`.
|
|
58
58
|
- `program.js` é o **mapa completo** do CLI: para saber todo comando que existe, todas as flags que cada um aceita, é o único arquivo que precisa abrir.
|
|
59
59
|
|
|
60
|
-
## O adapter: commander →
|
|
60
|
+
## O adapter: commander → objeto `flags`
|
|
61
61
|
|
|
62
|
-
O commander entrega ao `.action()` as opções em **camelCase** (`--env-file` → `options.envFile`, `--max-age` → `options.maxAge`) e cada positional como seu próprio parâmetro. As funções em `bin/commands/*.js`
|
|
62
|
+
O commander entrega ao `.action()` as opções em **camelCase** (`--env-file` → `options.envFile`, `--max-age` → `options.maxAge`) e cada positional como seu próprio parâmetro. As funções em `bin/commands/*.js` leem um objeto `flags`, com chaves com hífen literal (`flags["env-file"]`) e um array `flags._` para positionals.
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
`program.js` tem uma função `toLegacyFlags(options, extra)` que monta esse objeto antes de cada chamada:
|
|
65
65
|
|
|
66
66
|
```js
|
|
67
67
|
// bin/lib/cli/program.js
|
|
@@ -69,9 +69,9 @@ const whoamiCmd = cmd(program, "whoami").description("...");
|
|
|
69
69
|
withEnvOptions(withLogOptions(whoamiCmd)).action((options) => whoami(toLegacyFlags(options)));
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
`toLegacyFlags` remapeia só as duas chaves que mudam de formato (`envFile`→`"env-file"`, `maxAge`→`"max-age"`); todo o resto passa direto. O `extra` (segundo argumento) serve para injetar positionals como `_`
|
|
72
|
+
`toLegacyFlags` remapeia só as duas chaves que mudam de formato (`envFile`→`"env-file"`, `maxAge`→`"max-age"`); todo o resto passa direto. O `extra` (segundo argumento) serve para injetar positionals como `_` (ex.: `jarvis list`, `jarvis fork` e `jarvis map`).
|
|
73
73
|
|
|
74
|
-
**Ao adicionar uma opção nova que usa hífen** (ex: `--body-file`), decida: se a função de `bin/commands/*.js` vai ler `flags["body-file"]` (
|
|
74
|
+
**Ao adicionar uma opção nova que usa hífen** (ex: `--body-file`), decida: se a função de `bin/commands/*.js` vai ler `flags["body-file"]` (pelo adapter) ou `options.bodyFile` direto. Os comandos `vcs create-merge`, `vcs create-issue` e `tasks comment` usam o segundo caminho: recebem as opções do commander quase direto, sem o adapter.
|
|
75
75
|
|
|
76
76
|
## O helper `cmd()` — por que todo comando passa por ele
|
|
77
77
|
|
|
@@ -81,7 +81,7 @@ function cmd(parent, name) {
|
|
|
81
81
|
}
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
O
|
|
84
|
+
O commander, por padrão, dá erro em flag não declarada e em positional excedente. `allowUnknownOption()`/`allowExcessArguments()` fazem o CLI aceitar uma `--flag` que o comando não lê e argumentos a mais, sem erro — mas **o commander não propaga essas duas configs do comando pai para os subcomandos**: setar só no `program` raiz não é suficiente. Por isso `cmd()` existe e **todo** comando — incluindo os aninhados (`docs sync`, `vcs create-merge`) — é criado com ele, nunca com `.command()` direto.
|
|
85
85
|
|
|
86
86
|
## Argumentos: `[opcional]`, não `<obrigatório>` — de propósito
|
|
87
87
|
|
|
@@ -118,8 +118,8 @@ if (fileURLToPath(import.meta.url) === process.argv[1]) {
|
|
|
118
118
|
- Importar a função no topo.
|
|
119
119
|
- Registrar com `cmd(program, "meu-comando")` (ou `cmd(parentExistente, "nome")` se for subcomando de um grupo como `docs`/`vcs`/`tasks`).
|
|
120
120
|
- Declarar as opções/positionals com `.option()`/`.argument()`. Usar `withEnvOptions()`/`withLogOptions()` de `shared-options.js` se o comando precisar de `--ide`/`--env-file` ou `--quiet`/`--verbose`/`--silent`.
|
|
121
|
-
- No `.action()`, chamar `toLegacyFlags(options, extra)` se a função
|
|
122
|
-
3. Rodar manualmente o comando novo e **todos os outros** (
|
|
121
|
+
- No `.action()`, chamar `toLegacyFlags(options, extra)` se a função lê o objeto `flags`, ou passar `options` quase direto se ela lê as opções do commander (como os comandos de `vcs` e `tasks`).
|
|
122
|
+
3. Rodar manualmente o comando novo e **todos os outros** (a suíte de `test/` roda o `jarvis` de verdade em vários comandos, por exemplo em `rules-sync.test.js`, `token-report.test.js` e `docs-commands-cli.test.js`; o resto depende desse teste manual). Checklist mínimo: `--help` do comando novo, caminho feliz, caminho de erro (flag/argumento faltando).
|
|
123
123
|
4. `npm run lint && npm run test:comandos && npm run test:filtro` antes de comitar.
|
|
124
124
|
|
|
125
125
|
## Variáveis de ambiente lidas diretamente (fora do ENV.md)
|
package/bin/commands/init.js
CHANGED
|
@@ -67,18 +67,16 @@ export function parseMenuChoice(answer, { hasEnv }) {
|
|
|
67
67
|
return null;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
/** Eixos do perfil que o filtro de rules exige (o mesmo do `jarvis rules sync`). */
|
|
71
|
-
const PROFILE_AXES = ["HUB", "POSITION", "AREA", "SQUAD"];
|
|
72
|
-
|
|
73
70
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* inteiras
|
|
77
|
-
* `
|
|
71
|
+
* Sincroniza `.{ide}/rules/` e `rules-on-demand/` com o ENV.md, como o `jarvis rules sync` (#83).
|
|
72
|
+
* Usado no fim do `--upgrade` e da reinstalação, depois que o `syncAssets` copiou as rules
|
|
73
|
+
* inteiras: tira as duas exceções desligadas e aplica o overlay do `COMPANY_PROFILE` (#263). A
|
|
74
|
+
* `artifact-style-rules.md` só fica com `ARTIFACT_STYLE=human-generated`; a `rtk-rules.md`, com
|
|
75
|
+
* `RTK_ENABLED=true` e o `rtk` no PATH (o `reconcileRtk` a tira sem ele).
|
|
78
76
|
* @param {string} workspaceDir
|
|
79
77
|
* @param {string} ide
|
|
80
78
|
* @param {string} envPath
|
|
81
|
-
* @returns {{ rulesSync: ReturnType<typeof syncRulesForProfile>
|
|
79
|
+
* @returns {{ rulesSync: ReturnType<typeof syncRulesForProfile> }}
|
|
82
80
|
*/
|
|
83
81
|
export function filterRulesByEnv(workspaceDir, ide, envPath) {
|
|
84
82
|
const envText = readFileSync(envPath, "utf-8");
|
|
@@ -87,30 +85,18 @@ export function filterRulesByEnv(workspaceDir, ide, envPath) {
|
|
|
87
85
|
const v = (entries.get(key) || "").trim();
|
|
88
86
|
return v && !/^\[.*\]$/.test(v) ? v : "";
|
|
89
87
|
};
|
|
90
|
-
const missingProfile = PROFILE_AXES.filter((axis) => !value(axis));
|
|
91
|
-
const profileLabel = PROFILE_AXES.map(value).join("/");
|
|
92
|
-
if (missingProfile.length) return { rulesSync: null, missingProfile, profileLabel };
|
|
93
88
|
const rulesSync = syncRulesForProfile(
|
|
94
89
|
join(workspaceDir, `.${getIDEFolder(ide)}`),
|
|
95
|
-
{
|
|
96
|
-
HUB: value("HUB"),
|
|
97
|
-
POSITION: value("POSITION"),
|
|
98
|
-
AREA: value("AREA"),
|
|
99
|
-
SQUAD: value("SQUAD"),
|
|
100
|
-
ARTIFACT_STYLE: value("ARTIFACT_STYLE") || "ai-generated",
|
|
101
|
-
},
|
|
90
|
+
{ ARTIFACT_STYLE: value("ARTIFACT_STYLE") || "ai-generated" },
|
|
102
91
|
{ rtkEnabled: value("RTK_ENABLED") === "true" && rtkAvailable(), envText }
|
|
103
92
|
);
|
|
104
|
-
return { rulesSync
|
|
93
|
+
return { rulesSync };
|
|
105
94
|
}
|
|
106
95
|
|
|
107
|
-
/** Linha de resumo do
|
|
108
|
-
function logRulesFilter(rulesSync
|
|
109
|
-
if (!rulesSync) return;
|
|
96
|
+
/** Linha de resumo do passo de rules, com avisos e erros. */
|
|
97
|
+
function logRulesFilter(rulesSync) {
|
|
110
98
|
const copied = rulesSync.copied.rules + rulesSync.copied["rules-on-demand"];
|
|
111
|
-
logger.info(
|
|
112
|
-
` • Rules filtradas pelo perfil (${profileLabel}): ${copied} copiada(s), ${rulesSync.removed} removida(s)`
|
|
113
|
-
);
|
|
99
|
+
logger.info(` • Rules sincronizadas: ${copied} copiada(s), ${rulesSync.removed} removida(s)`);
|
|
114
100
|
for (const w of rulesSync.warnings) logger.info(`${YELLOW} ⚠️ ${w}${NC}`);
|
|
115
101
|
for (const e of rulesSync.errors) logger.error(`${RED} ✗ ${e}${NC}`);
|
|
116
102
|
}
|
|
@@ -216,23 +202,19 @@ export function docsIgnoreLines(entries) {
|
|
|
216
202
|
* no formato antigo e TOKEN_TASK_MANAGER com valor. Não contam o aviso de WORKSPACE_MODE (conferir
|
|
217
203
|
* no ENV.md), vendor não suportado (vira freelance) nem as chaves novas acrescentadas (Q15: o
|
|
218
204
|
* `/jarvis-init` as põe no assunto delas na próxima vez que rodar). Nunca inclui valores do ENV.
|
|
219
|
-
*
|
|
220
|
-
* as rules (#83). `trackedGenerated` (#227): AGENTS.md/CLAUDE.md já versionados no modo projeto; sair do git
|
|
205
|
+
* `trackedGenerated` (#227): AGENTS.md/CLAUDE.md já versionados no modo projeto; sair do git
|
|
221
206
|
* é decisão da pessoa, tomada no `/jarvis-init upgrade` (nunca no terminal).
|
|
222
207
|
* `documents` (#225): `CDD-MIND-MAP.md` ou `AGENTS.md` ausentes e `CLAUDE.md` fora de sincronia com o `AGENTS.md`
|
|
223
208
|
* (`documentPendencies`); o Upgrade os cria ou sincroniza, com confirmação.
|
|
224
|
-
* @param {{ pendingAxes: string[], envPlan: { pending?: string[], warnings?: string[] },
|
|
209
|
+
* @param {{ pendingAxes: string[], envPlan: { pending?: string[], warnings?: string[] }, trackedGenerated?: string[], documents?: string[] }} input
|
|
225
210
|
* @returns {string[]} um motivo por pendência; vazio = nada pendente
|
|
226
211
|
*/
|
|
227
|
-
export function upgradePendencies({ pendingAxes, envPlan,
|
|
212
|
+
export function upgradePendencies({ pendingAxes, envPlan, trackedGenerated = [], documents = [] }) {
|
|
228
213
|
const reasons = [];
|
|
229
214
|
if (trackedGenerated.length) {
|
|
230
215
|
reasons.push(`decidir se ${trackedGenerated.join(" e ")} ${trackedGenerated.length > 1 ? "saem" : "sai"} do git`);
|
|
231
216
|
}
|
|
232
217
|
if (pendingAxes.length) reasons.push(`confirmar o acesso de ${pendingAxes.join(" e ")}`);
|
|
233
|
-
if (missingProfile.length) {
|
|
234
|
-
reasons.push(`preencher ${missingProfile.join(", ")} (as rules ficam sem o filtro do perfil)`);
|
|
235
|
-
}
|
|
236
218
|
if (envPlan.pending?.length) reasons.push(`preencher ${envPlan.pending.join(", ")}`);
|
|
237
219
|
const warnings = envPlan.warnings || [];
|
|
238
220
|
if (warnings.includes("CENTRAL_DOCS_REPO")) reasons.push("migrar o Central docs");
|
|
@@ -500,13 +482,13 @@ export async function init(flags) {
|
|
|
500
482
|
for (const item of result.errors) {
|
|
501
483
|
logger.error(`${RED} ✗ ${item}${NC}`);
|
|
502
484
|
}
|
|
503
|
-
// Reinstalação com o ENV.md
|
|
504
|
-
// nova)
|
|
485
|
+
// Reinstalação com o ENV.md: o mesmo passo de rules do --upgrade (#83). Sem ENV.md (instalação
|
|
486
|
+
// nova), o Passo 8 do /jarvis-init sincroniza depois.
|
|
505
487
|
const envOnDisk = join(ideDir, "ENV.md");
|
|
506
488
|
if (forceSync && existsSync(envOnDisk)) {
|
|
507
|
-
const { rulesSync
|
|
508
|
-
logRulesFilter(rulesSync
|
|
509
|
-
if (rulesSync
|
|
489
|
+
const { rulesSync } = filterRulesByEnv(cwd, ide, envOnDisk);
|
|
490
|
+
logRulesFilter(rulesSync);
|
|
491
|
+
if (rulesSync.errors.length) process.exitCode = 1;
|
|
510
492
|
}
|
|
511
493
|
|
|
512
494
|
// Sessões: pasta e .gitignore seguem o SESSIONS_DIR do ENV.md (reinstalação); sem ENV.md vale o padrão (#228).
|
|
@@ -702,7 +684,7 @@ async function reportCliDiscovery(entries) {
|
|
|
702
684
|
* `jarvis init --upgrade`: atualiza um projeto já configurado em uma passada.
|
|
703
685
|
* 1. arquivos do framework (como o --force, sem perguntar); 2. só as chaves novas do ENV;
|
|
704
686
|
* 3. documentos dos caminhos antigos → docs/jarvis/… (com confirmação ou --yes); 4. rules
|
|
705
|
-
*
|
|
687
|
+
* sincronizadas com o ENV (como o `jarvis rules sync`).
|
|
706
688
|
* Nunca imprime valores do ENV, só nomes de chave e caminhos.
|
|
707
689
|
* @returns {Promise<number>} código de saída
|
|
708
690
|
*/
|
|
@@ -873,8 +855,8 @@ async function runUpgrade(cwd, flags) {
|
|
|
873
855
|
rewritten = rewriteRelatedDiscovery(workspaceDir, env, moved);
|
|
874
856
|
}
|
|
875
857
|
|
|
876
|
-
// 3.4 Rules
|
|
877
|
-
const { rulesSync
|
|
858
|
+
// 3.4 Rules (#83): o mesmo passo do `jarvis rules sync`, com o ENV.md já gravado.
|
|
859
|
+
const { rulesSync } = filterRulesByEnv(workspaceDir, ide, envPath);
|
|
878
860
|
|
|
879
861
|
// 3.5 Git no modo projeto (#227): o mesmo da instalação (exclude local e pasta da IDE no .gitignore).
|
|
880
862
|
// AGENTS.md/CLAUDE.md versionados viram pendência do /jarvis-init upgrade: aqui nada sai do índice,
|
|
@@ -921,7 +903,7 @@ async function runUpgrade(cwd, flags) {
|
|
|
921
903
|
for (const e of moveErrors) logger.error(`${RED} ✗ ${e}${NC}`);
|
|
922
904
|
if (staleRemoved.length) logger.info(` • Skills antigos removidos: ${staleRemoved.join(", ")}`);
|
|
923
905
|
for (const e of staleErrors) logger.error(`${RED} ✗ ${e}${NC}`);
|
|
924
|
-
logRulesFilter(rulesSync
|
|
906
|
+
logRulesFilter(rulesSync);
|
|
925
907
|
for (const k of envPlan.pending) {
|
|
926
908
|
logger.info(`${YELLOW} ⚠️ ${k} está vazio: responda no /jarvis-init upgrade${NC}`);
|
|
927
909
|
}
|
|
@@ -935,6 +917,12 @@ async function runUpgrade(cwd, flags) {
|
|
|
935
917
|
`${YELLOW} ⚠️ Central docs no layout antigo (product/engineering): rode "jarvis docs migrate" para ver o plano, ou o /jarvis-init oferece (Upgrade C)${NC}`
|
|
936
918
|
);
|
|
937
919
|
}
|
|
920
|
+
if (envPlan.warnings.includes("SENIORITY_DERIVED")) {
|
|
921
|
+
const seniority = envPlan.added.find((entry) => entry.key === "SENIORITY")?.value;
|
|
922
|
+
logger.info(
|
|
923
|
+
`${YELLOW} ⚠️ SENIORITY: gravada como ${seniority}, a partir do cargo antigo; confira no ENV.md${NC}`
|
|
924
|
+
);
|
|
925
|
+
}
|
|
938
926
|
if (envPlan.warnings.includes("WORKSPACE_MODE")) {
|
|
939
927
|
logger.info(
|
|
940
928
|
`${YELLOW} ⚠️ WORKSPACE_MODE: a raiz é um repositório e há subpastas com .git (submódulos?): gravado como project; confira no ENV.md${NC}`
|
|
@@ -964,7 +952,6 @@ async function runUpgrade(cwd, flags) {
|
|
|
964
952
|
const pending = upgradePendencies({
|
|
965
953
|
pendingAxes,
|
|
966
954
|
envPlan,
|
|
967
|
-
missingProfile,
|
|
968
955
|
trackedGenerated: gitSetup.tracked,
|
|
969
956
|
documents: documentPendencies(workspaceDir),
|
|
970
957
|
});
|
|
@@ -984,7 +971,7 @@ async function runUpgrade(cwd, flags) {
|
|
|
984
971
|
return sync.errors.length ||
|
|
985
972
|
moveErrors.length ||
|
|
986
973
|
staleErrors.length ||
|
|
987
|
-
rulesSync
|
|
974
|
+
rulesSync.errors.length ||
|
|
988
975
|
gitSetup.errors.length
|
|
989
976
|
? 1
|
|
990
977
|
: 0;
|
package/bin/commands/rules.js
CHANGED
|
@@ -8,8 +8,6 @@ import { getPackageInfo } from "../lib/utils/paths.js";
|
|
|
8
8
|
import { logger, configureFromFlags } from "../lib/utils/logger.js";
|
|
9
9
|
import { RED, GREEN, YELLOW, CYAN, NC } from "../lib/utils/ui.js";
|
|
10
10
|
|
|
11
|
-
const AXES = ["HUB", "POSITION", "AREA", "SQUAD"];
|
|
12
|
-
|
|
13
11
|
/**
|
|
14
12
|
* Versão do `jarvis-lock.json` da pasta (a da IDE ou a raiz do workspace), ou `null` sem o arquivo.
|
|
15
13
|
* Arquivo presente, mas ilegível ou sem `version`, interrompe o comando: não cai para outro lock.
|
|
@@ -45,10 +43,11 @@ function fail(message) {
|
|
|
45
43
|
}
|
|
46
44
|
|
|
47
45
|
/**
|
|
48
|
-
* `jarvis rules sync`: Passo 8 do `/jarvis-init` pelo CLI (#102).
|
|
49
|
-
* `.{ide}/rules-on-demand/`
|
|
50
|
-
* Sai com 1, sem gravar nada, sem ENV.md numa pasta
|
|
51
|
-
* ou de outra versão (os assets da IDE seriam de outra versão que as
|
|
46
|
+
* `jarvis rules sync`: Passo 8 do `/jarvis-init` pelo CLI (#102). Sincroniza `.{ide}/rules/` e
|
|
47
|
+
* `.{ide}/rules-on-demand/` com o ENV.md (as duas exceções seguem `ARTIFACT_STYLE` e `RTK_ENABLED`,
|
|
48
|
+
* #263) e aplica o overlay de `COMPANY_PROFILE`. Sai com 1, sem gravar nada, sem ENV.md numa pasta
|
|
49
|
+
* de IDE ou com o lock ausente ou de outra versão (os assets da IDE seriam de outra versão que as
|
|
50
|
+
* rules do Jarvis em uso).
|
|
52
51
|
* @param {{ ide?: string, "env-file"?: string }} flags
|
|
53
52
|
*/
|
|
54
53
|
export async function rulesSync(flags) {
|
|
@@ -90,33 +89,22 @@ export async function rulesSync(flags) {
|
|
|
90
89
|
const envText = readFileSync(resolved.path, "utf-8");
|
|
91
90
|
const env = loadEnv(process.cwd(), resolved.path);
|
|
92
91
|
|
|
93
|
-
const missing = AXES.filter((axis) => !env[axis]);
|
|
94
|
-
if (missing.length > 0) fail(`Perfil incompleto no ENV.md: faltam ${missing.join(", ")}`);
|
|
95
|
-
|
|
96
92
|
// O lock da IDE filtrada vale primeiro: com duas IDEs, o da raiz é o do último init.
|
|
97
93
|
const lock = readLock(ideDir) ?? readLock(workspaceDir);
|
|
98
94
|
const running = getPackageInfo().version;
|
|
99
95
|
if (lock === null) fail(`Sem ${LOCK_FILE} no workspace: rode \`jarvis init\``);
|
|
100
96
|
if (lock !== running) {
|
|
101
97
|
fail(
|
|
102
|
-
`assets da ${lock} e Jarvis ${running}: rode \`jarvis init --upgrade\` (ou
|
|
98
|
+
`assets da ${lock} e Jarvis ${running}: rode \`jarvis init --upgrade\` (ou sincronize sem o CLI)`
|
|
103
99
|
);
|
|
104
100
|
}
|
|
105
101
|
|
|
106
|
-
const profile = {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
AREA: env.AREA,
|
|
110
|
-
SQUAD: env.SQUAD,
|
|
111
|
-
ARTIFACT_STYLE: env.ARTIFACT_STYLE || "ai-generated",
|
|
112
|
-
};
|
|
113
|
-
const result = syncRulesForProfile(ideDir, profile, {
|
|
114
|
-
rtkEnabled: env.RTK_ENABLED === "true",
|
|
115
|
-
envText,
|
|
116
|
-
});
|
|
102
|
+
const profile = { ARTIFACT_STYLE: env.ARTIFACT_STYLE || "ai-generated" };
|
|
103
|
+
const rtkEnabled = env.RTK_ENABLED === "true";
|
|
104
|
+
const result = syncRulesForProfile(ideDir, profile, { rtkEnabled, envText });
|
|
117
105
|
|
|
118
106
|
logger.info(
|
|
119
|
-
`${CYAN}🔍 Sincronizando rules
|
|
107
|
+
`${CYAN}🔍 Sincronizando rules: ARTIFACT_STYLE=${profile.ARTIFACT_STYLE} | RTK=${rtkEnabled ? "ligado" : "desligado"}${NC}\n`
|
|
120
108
|
);
|
|
121
109
|
for (const warning of result.warnings) logger.info(`${YELLOW}⚠️ ${warning}${NC}`);
|
|
122
110
|
const total = result.copied.rules + result.copied["rules-on-demand"];
|
|
@@ -124,8 +112,7 @@ export async function rulesSync(flags) {
|
|
|
124
112
|
logger.info(
|
|
125
113
|
` Copiadas : ${total} arquivos (rules/: ${result.copied.rules} | rules-on-demand/: ${result.copied["rules-on-demand"]})`
|
|
126
114
|
);
|
|
127
|
-
logger.info(` Removidas: ${result.removed} arquivos (
|
|
128
|
-
logger.info(` Universais: ${result.universal} arquivos (sem applies_to — sempre copiadas)`);
|
|
115
|
+
logger.info(` Removidas: ${result.removed} arquivos (exceção desligada)`);
|
|
129
116
|
logger.info(` Do overlay: ${result.fromOverlay} arquivos (${result.companyProfile})`);
|
|
130
117
|
if (result.folderCreated) logger.info(` Overlay ${result.companyProfile}: pasta criada`);
|
|
131
118
|
|
package/bin/commands/tokens.js
CHANGED
|
@@ -1,60 +1,39 @@
|
|
|
1
1
|
import { buildReport } from "../lib/core/token-report.js";
|
|
2
2
|
import { resolveEnvPath, loadEnv } from "../lib/env-loader.js";
|
|
3
3
|
import { getFrameworkRoot } from "../lib/utils/paths.js";
|
|
4
|
-
import { showBanner, RED, GREEN, BLUE,
|
|
4
|
+
import { showBanner, RED, GREEN, BLUE, CYAN, DIM, NC } from "../lib/utils/ui.js";
|
|
5
5
|
import { logger } from "../lib/utils/logger.js";
|
|
6
6
|
|
|
7
|
-
const AXES = ["HUB", "POSITION", "AREA", "SQUAD"];
|
|
8
|
-
|
|
9
7
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* O que muda a medida: ARTIFACT_STYLE e RTK. A flag manda; o que faltar vem do ENV.md, se houver.
|
|
9
|
+
* Sem ENV.md, vale `ai-generated` e o RTK desligado (#263). Se não dá para escolher ou ler o ENV.md
|
|
10
|
+
* (dois na mesma pasta, `--ide` inválida ou sem ENV.md, `JARVIS_ENV_FILE` inexistente, ENV.md
|
|
11
|
+
* ilegível), sai com 1, como o `jarvis rules sync`: medir com o padrão daria um número errado que
|
|
12
|
+
* parece certo.
|
|
12
13
|
*/
|
|
13
14
|
function resolveProfile(flags) {
|
|
14
15
|
const profile = {};
|
|
15
|
-
for (const axis of AXES) {
|
|
16
|
-
const value = flags[axis.toLowerCase()];
|
|
17
|
-
if (typeof value === "string") profile[axis] = value;
|
|
18
|
-
}
|
|
19
16
|
if (typeof flags.artifactStyle === "string") profile.ARTIFACT_STYLE = flags.artifactStyle;
|
|
20
|
-
|
|
21
17
|
let rtkEnabled = flags.rtk === true || flags.rtk === "true";
|
|
22
|
-
|
|
23
|
-
if (AXES.some((axis) => !profile[axis])) {
|
|
24
|
-
try {
|
|
25
|
-
const { path } = resolveEnvPath(process.cwd(), flags);
|
|
26
|
-
const env = loadEnv(process.cwd(), path);
|
|
27
|
-
for (const axis of AXES) {
|
|
28
|
-
if (!profile[axis] && env[axis]) profile[axis] = env[axis];
|
|
29
|
-
}
|
|
30
|
-
if (!profile.ARTIFACT_STYLE && env.ARTIFACT_STYLE)
|
|
31
|
-
profile.ARTIFACT_STYLE = env.ARTIFACT_STYLE;
|
|
32
|
-
if (flags.rtk === undefined) rtkEnabled = env.RTK_ENABLED === "true";
|
|
33
|
-
} catch {
|
|
34
|
-
// sem ENV.md: valem só as flags
|
|
35
|
-
}
|
|
36
|
-
}
|
|
18
|
+
if (profile.ARTIFACT_STYLE && flags.rtk !== undefined) return { profile, rtkEnabled };
|
|
37
19
|
|
|
38
|
-
|
|
39
|
-
|
|
20
|
+
let env;
|
|
21
|
+
try {
|
|
22
|
+
// Sem ENV.md, o resolveEnvPath devolve o caminho da raiz, que não existe, e o loadEnv devolve {}.
|
|
23
|
+
env = loadEnv(process.cwd(), resolveEnvPath(process.cwd(), flags).path);
|
|
24
|
+
} catch (err) {
|
|
25
|
+
logger.error(`${RED}❌ ${err.message}${NC}`);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
if (!profile.ARTIFACT_STYLE && env.ARTIFACT_STYLE) profile.ARTIFACT_STYLE = env.ARTIFACT_STYLE;
|
|
29
|
+
if (flags.rtk === undefined) rtkEnabled = env.RTK_ENABLED === "true";
|
|
30
|
+
return { profile, rtkEnabled };
|
|
40
31
|
}
|
|
41
32
|
|
|
42
33
|
const kb = (bytes) => (bytes / 1000).toFixed(1);
|
|
43
34
|
|
|
44
35
|
export async function tokens(flags) {
|
|
45
|
-
const { profile, rtkEnabled
|
|
46
|
-
|
|
47
|
-
if (missing.length > 0) {
|
|
48
|
-
logger.error(`${RED}❌ Perfil incompleto: faltam ${missing.join(", ")}${NC}`);
|
|
49
|
-
logger.info(
|
|
50
|
-
`${YELLOW}Uso: jarvis tokens [--hub X --position Y --area Z --squad W] [--rtk] [--json]${NC}`
|
|
51
|
-
);
|
|
52
|
-
logger.info(
|
|
53
|
-
`${DIM}Sem flags, o perfil vem do ENV.md do workspace (use --ide <ide> se houver mais de um).${NC}\n`
|
|
54
|
-
);
|
|
55
|
-
process.exit(1);
|
|
56
|
-
}
|
|
57
|
-
|
|
36
|
+
const { profile, rtkEnabled } = resolveProfile(flags);
|
|
58
37
|
const report = buildReport(getFrameworkRoot(), profile, { rtkEnabled });
|
|
59
38
|
|
|
60
39
|
if (flags.json) {
|
|
@@ -65,8 +44,7 @@ export async function tokens(flags) {
|
|
|
65
44
|
showBanner();
|
|
66
45
|
logger.info(`${CYAN}📏 Custo estimado no início da sessão${NC}`);
|
|
67
46
|
logger.info(
|
|
68
|
-
`${DIM}
|
|
69
|
-
` | RTK=${rtkEnabled ? "ligado" : "desligado"}${NC}`
|
|
47
|
+
`${DIM}ARTIFACT_STYLE=${report.profile.ARTIFACT_STYLE} | RTK=${rtkEnabled ? "ligado" : "desligado"}${NC}`
|
|
70
48
|
);
|
|
71
49
|
logger.info(`${DIM}${report.estimate}${NC}`);
|
|
72
50
|
logger.info("");
|
package/bin/commands/whoami.js
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
import { resolveUser
|
|
1
|
+
import { resolveUser } from "../lib/auth/session.js";
|
|
2
2
|
import { loadEnv, resolveEnvPath } from "../lib/env-loader.js";
|
|
3
3
|
import { logger, configureFromFlags } from "../lib/utils/logger.js";
|
|
4
|
-
import {
|
|
4
|
+
import { BLUE, DIM, NC } from "../lib/utils/ui.js";
|
|
5
5
|
|
|
6
6
|
export async function whoami(flags) {
|
|
7
7
|
configureFromFlags(flags);
|
|
8
8
|
|
|
9
|
-
if (flags.logout) {
|
|
10
|
-
clearSession();
|
|
11
|
-
logger.info(`${GREEN}✓ ~/.jarvis/auth.json removido${NC}`);
|
|
12
|
-
logger.info(
|
|
13
|
-
`${DIM}Login não é mais necessário — identidade vem de USER= no ENV.md, git ou SO.${NC}`
|
|
14
|
-
);
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
9
|
let env = {};
|
|
19
10
|
try {
|
|
20
11
|
const cwd = process.cwd();
|
|
@@ -36,12 +27,5 @@ export async function whoami(flags) {
|
|
|
36
27
|
`${DIM}Sem login. Ordem: ENV.md (USER=) → git config user.email → usuário do SO.${NC}`
|
|
37
28
|
);
|
|
38
29
|
|
|
39
|
-
const leftover = readSession();
|
|
40
|
-
if (leftover?.email) {
|
|
41
|
-
logger.info("");
|
|
42
|
-
logger.info(` ${YELLOW}⚠ ~/.jarvis/auth.json legado (${leftover.email}) — não é usado.${NC}`);
|
|
43
|
-
logger.info(` ${DIM}Remova com: jarvis logout${NC}`);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
30
|
logger.info("");
|
|
47
31
|
}
|
package/bin/lib/auth/session.js
CHANGED
|
@@ -1,24 +1,5 @@
|
|
|
1
|
-
import { existsSync, readFileSync, unlinkSync } from "node:fs";
|
|
2
1
|
import { execSync } from "node:child_process";
|
|
3
|
-
import {
|
|
4
|
-
import { homedir, userInfo } from "node:os";
|
|
5
|
-
|
|
6
|
-
const SESSION_FILE = join(homedir(), ".jarvis", "auth.json");
|
|
7
|
-
|
|
8
|
-
export function readSession() {
|
|
9
|
-
if (!existsSync(SESSION_FILE)) return null;
|
|
10
|
-
try {
|
|
11
|
-
return JSON.parse(readFileSync(SESSION_FILE, "utf-8"));
|
|
12
|
-
} catch {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function clearSession() {
|
|
18
|
-
if (existsSync(SESSION_FILE)) {
|
|
19
|
-
unlinkSync(SESSION_FILE);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
2
|
+
import { userInfo } from "node:os";
|
|
22
3
|
|
|
23
4
|
/**
|
|
24
5
|
* Resolve local identity without OAuth.
|
|
@@ -47,10 +28,3 @@ export function resolveUser(env = {}) {
|
|
|
47
28
|
|
|
48
29
|
return { id: "local", source: "fallback" };
|
|
49
30
|
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Identity used as dev_id. Never requires jarvis login.
|
|
53
|
-
*/
|
|
54
|
-
export function getAuthUser(env = {}) {
|
|
55
|
-
return resolveUser(env).id;
|
|
56
|
-
}
|