jarvis-ai-framework 8.2.0 → 8.5.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 +43 -99
- package/README.md +13 -2
- package/agents/README.md +1 -0
- package/agents/engineering/data/eng.data-engineer.agent.md +8 -44
- package/agents/engineering/eng.agent.md +5 -80
- package/agents/engineering/eng.bug-hunter.md +1 -10
- package/agents/engineering/eng.dev-code-reviewer.md +1 -1
- package/agents/engineering/eng.docs-writer.md +6 -87
- package/agents/engineering/eng.rpa.agent.md +6 -30
- package/agents/engineering/qa/eng.qa.test-architect.md +1 -33
- package/agents/engineering/qa/eng.qa.test-planner.md +3 -143
- package/agents/engineering/qa/eng.qa.testing-engineer.md +4 -53
- package/bin/README.md +4 -4
- package/bin/commands/fork.js +562 -0
- package/bin/commands/init.js +147 -7
- package/bin/commands/rules.js +136 -0
- package/bin/lib/cli/program.js +36 -0
- package/bin/lib/config/constants.js +59 -38
- package/bin/lib/core/company-profile.js +92 -0
- package/bin/lib/core/docs-migrate.js +2 -2
- package/bin/lib/core/env-upgrade.js +114 -15
- package/bin/lib/core/profile-filter.js +4 -9
- package/bin/lib/core/scanner.js +10 -4
- package/bin/lib/core/sync-engine.js +343 -47
- package/bin/lib/utils/frontmatter.js +36 -2
- package/package.json +2 -2
- package/rules/artifact-style-rules.md +1 -1
- package/rules/company-overlay-rules.md +11 -0
- package/rules/engineering/eng-rules.md +0 -4
- package/rules/engineering/eng-security-rules.md +1 -34
- package/rules/engineering/eng.integrations-rules.md +2 -2
- package/rules/engineering/eng.skills-rules.md +1 -1
- package/rules/engineering/eng.specializations-rules.md +1 -1
- package/rules/engineering/frontend/eng.frontend-rules.md +0 -3
- package/rules/engineering/qa/eng.qa.cypress-standards-rules.md +2 -256
- package/rules/product/prod-rules.md +9 -54
- package/rules/product/prod.spec-rules.md +1 -0
- package/rules/rtk-rules.md +0 -4
- package/rules-on-demand/engineering/eng.breakdown-subtasks-rules.md +3 -199
- package/{rules → rules-on-demand}/engineering/eng.bump-rules.md +0 -6
- package/rules-on-demand/engineering/eng.gate0-rules.md +56 -0
- package/rules-on-demand/engineering/eng.plan-rules.md +2 -49
- package/rules-on-demand/engineering/eng.pr-rules.md +29 -150
- package/rules-on-demand/engineering/eng.pre-pr-rules.md +5 -50
- package/{rules/engineering/rpa → rules-on-demand/engineering}/eng.rpa-rules.md +46 -10
- package/rules-on-demand/engineering/eng.security-rules.md +36 -0
- package/rules-on-demand/engineering/eng.start-rules.md +9 -3
- package/rules-on-demand/engineering/eng.tech-spec-rules.md +28 -473
- package/rules-on-demand/engineering/eng.transitions-rules.md +2 -1
- package/rules-on-demand/engineering/eng.work-rules.md +1 -48
- package/rules-on-demand/engineering/qa/eng.qa.cypress-standards-rules.md +259 -0
- package/rules-on-demand/product/prod.spec-common-rules.md +39 -0
- package/skills/AGENTS.md +15 -8
- package/skills/SKILLS-ROADMAP.md +21 -18
- package/skills/eng-ai/SKILL.md +5 -9
- package/skills/eng-automation/SKILL.md +7 -11
- package/skills/eng-backend/SKILL.md +4 -8
- package/skills/eng-backend-arch-c4/SKILL.md +18 -82
- package/skills/eng-backend-arch-c4/references/1-nivel-context.md +16 -0
- package/skills/eng-backend-arch-c4/references/2-nivel-container.md +17 -0
- package/skills/eng-backend-arch-c4/references/3-nivel-component.md +15 -0
- package/skills/eng-backend-arch-c4/references/4-nivel-code.md +12 -0
- package/skills/eng-backend-arch-c4/references/5-atualizacao-e-adrs.md +27 -0
- package/skills/eng-backend-microservices-trace/SKILL.md +4 -6
- package/skills/eng-backend-nestjs/SKILL.md +8 -57
- package/skills/eng-backend-nestjs/references/5-testes.md +13 -0
- package/skills/eng-backend-nestjs/references/6-problemas-comuns.md +37 -0
- package/skills/eng-data/SKILL.md +6 -10
- package/skills/eng-frontend/SKILL.md +6 -9
- package/skills/eng-global-branch/SKILL.md +124 -0
- package/skills/eng-global-docs-write/SKILL.md +1 -1
- package/skills/eng-global-investigation/SKILL.md +5 -6
- package/skills/eng-global-pr/SKILL.md +3 -17
- package/skills/eng-global-task-comment/SKILL.md +5 -2
- package/skills/eng-global-tech-spec/SKILL.md +4 -6
- package/skills/eng-global-tech-spec/references/delivery-spec.md +11 -179
- package/skills/eng-platform/SKILL.md +8 -14
- package/skills/eng-qa/SKILL.md +6 -11
- package/skills/eng-qa-planner/SKILL.md +0 -1
- package/skills/jarvis-context-detect/SKILL.md +29 -2
- package/skills/jarvis-context-detect/assets/context-profile-template.md +1 -1
- package/{templates → skills/jarvis-context-detect/references}/cdd-aplicado-a-prompts.md +1 -1
- package/skills/jarvis-context-detect/references/eng.work.md +28 -0
- package/skills/jarvis-create-specialization/SKILL.md +5 -9
- package/skills/jarvis-docs-central/SKILL.md +1 -2
- package/skills/jarvis-docs-index/SKILL.md +1 -1
- package/skills/jarvis-evolution-architect/SKILL.md +1 -2
- package/skills/jarvis-fork/SKILL.md +179 -0
- package/skills/jarvis-init/SKILL.md +31 -364
- package/skills/jarvis-init/assets/exemplo-execucao.md +46 -0
- package/skills/jarvis-init/assets/mcp-configs.md +0 -91
- package/skills/jarvis-init/assets/rules-sync-manual.md +100 -0
- package/skills/jarvis-init/assets/setup-guide.md +0 -1
- package/skills/jarvis-init/assets/upgrade.md +46 -0
- package/skills/jarvis-init/assets/validacoes.md +56 -0
- package/skills/jarvis-list-specializations/SKILL.md +4 -8
- package/skills/jarvis-report-issue/SKILL.md +1 -2
- package/skills/product-roadmap-report/SKILL.md +3 -2
- package/skills/product-specs/SKILL.md +1 -3
- package/skills/product-specs-update/SKILL.md +0 -1
- package/templates/AGENTS.md +9 -3
- package/templates/ENV-template.md +11 -57
- package/templates/engineering/AGENTS-template.md +0 -1
- package/templates/engineering/breakdown-subtasks-template.md +76 -447
- package/templates/engineering/data-contract-template.md +2 -2
- package/templates/engineering/qa/qa.test-coverage-report-template.md +62 -0
- package/templates/engineering/qa/qa.test-strategy-template.md +41 -0
- package/templates/engineering/qa/qa.test-suite-report-template.md +27 -0
- package/workflows/AGENTS.md +27 -36
- package/workflows/README.md +2 -11
- package/workflows/engineering/data/data.contract.md +1 -5
- package/workflows/engineering/data/data.new-pipeline.md +2 -6
- package/workflows/engineering/eng.breakdown-subtasks.md +8 -238
- package/workflows/engineering/eng.build-tech-spec.md +0 -2
- package/workflows/engineering/eng.create-ard-from-code.md +0 -2
- package/workflows/engineering/eng.create-ard.md +2 -7
- package/workflows/engineering/eng.create-rfc.md +2 -4
- package/workflows/engineering/eng.daily-report.md +0 -2
- package/workflows/engineering/eng.debug.md +1 -5
- package/workflows/engineering/eng.docs.md +1 -4
- package/workflows/engineering/eng.light-arch.md +0 -3
- package/workflows/engineering/eng.plan.md +1 -3
- package/workflows/engineering/eng.pr.md +8 -36
- package/workflows/engineering/eng.pre-pr.md +15 -7
- package/workflows/engineering/eng.review.md +0 -4
- package/workflows/engineering/eng.rpa.robot.md +4 -6
- package/workflows/engineering/eng.spec-consolidate.md +0 -2
- package/workflows/engineering/eng.start.md +14 -84
- package/workflows/engineering/eng.work.md +10 -149
- package/workflows/engineering/frontend/eng.frontend-component.md +1 -5
- package/workflows/engineering/frontend/eng.frontend-perf-audit.md +1 -4
- package/workflows/engineering/frontend/eng.frontend-review.md +1 -5
- package/workflows/engineering/qa/eng.qa-refinement-entry.md +0 -2
- package/workflows/engineering/qa/eng.qa-release-signoff.md +0 -3
- package/workflows/engineering/qa/eng.qa-sprint-planning.md +0 -4
- package/workflows/product/prod.roadmap.preview.md +0 -3
- package/workflows/product/prod.spec.ard.md +1 -4
- package/workflows/product/prod.spec.breakdown.md +4 -11
- package/workflows/product/prod.spec.clarify.md +1 -4
- package/workflows/product/prod.spec.discovery.md +1 -4
- package/workflows/product/prod.spec.epic.md +4 -18
- package/workflows/product/prod.spec.frd.md +5 -31
- package/workflows/product/prod.spec.issue.md +2 -3
- package/workflows/product/prod.spec.md +0 -3
- package/workflows/product/prod.spec.prd.md +6 -36
- package/workflows/warm-up.md +1 -4
- package/rules/AGENTS.md +0 -226
- package/rules/engineering/data/data-rules.md +0 -200
- package/rules/engineering/eng.docs-scraping-rules.md +0 -64
- package/rules/product/README.md +0 -27
- package/skills/eng-backend-rabbitmq/SKILL.md +0 -380
- package/skills/eng-backend-rabbitmq/references/1-referencia-endpoints.md +0 -28
- package/skills/eng-backend-rabbitmq/references/2-codigo-consumer-producer.md +0 -90
- package/skills/eng-backend-rabbitmq/references/3-arquiteturas-comuns.md +0 -101
- package/skills/eng-backend-rabbitmq/references/4-troubleshooting.md +0 -93
- package/skills/product-roadmap-report/rules/detailed-guide.md +0 -237
- package/templates/engineering/CONTACTS-template.md +0 -135
- package/templates/engineering/swagger-template.md +0 -145
- package/workflows/all-tools.md +0 -17
package/bin/commands/init.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, realpathSync } from "node:fs";
|
|
2
2
|
import { join, dirname, basename, resolve, sep } from "node:path";
|
|
3
3
|
import { createInterface } from "node:readline";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
syncAssets,
|
|
6
|
+
applyRuleOverlay,
|
|
7
|
+
syncRulesForProfile,
|
|
8
|
+
rtkAvailable,
|
|
9
|
+
} from "../lib/core/sync-engine.js";
|
|
5
10
|
import { discoverAll } from "../lib/core/scanner.js";
|
|
6
11
|
import {
|
|
7
12
|
IDES,
|
|
@@ -23,6 +28,7 @@ import {
|
|
|
23
28
|
removeStaleSkills,
|
|
24
29
|
} from "../lib/core/stale-skills.js";
|
|
25
30
|
import { parseEnvEntries, planEnvUpgrade, applyEnvUpgrade } from "../lib/core/env-upgrade.js";
|
|
31
|
+
import { DEFAULT_COMPANY_PROFILE, isValidCompanyProfile } from "../lib/core/company-profile.js";
|
|
26
32
|
import { checkCli, getVendor } from "../lib/integrations/cli-runner.js";
|
|
27
33
|
import {
|
|
28
34
|
expandEnv,
|
|
@@ -57,18 +63,71 @@ export function parseMenuChoice(answer, { hasEnv }) {
|
|
|
57
63
|
return null;
|
|
58
64
|
}
|
|
59
65
|
|
|
66
|
+
/** Eixos do perfil que o filtro de rules exige (o mesmo do `jarvis rules sync`). */
|
|
67
|
+
const PROFILE_AXES = ["HUB", "POSITION", "AREA", "SQUAD"];
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Filtra `.{ide}/rules/` e `rules-on-demand/` pelo perfil do ENV.md, como o `jarvis rules sync`
|
|
71
|
+
* (#83). Usado no fim do `--upgrade` e da reinstalação, depois que o `syncAssets` copiou as rules
|
|
72
|
+
* inteiras. Sem os 4 eixos (vazios ou com o exemplo `[...]` do template), não filtra. A
|
|
73
|
+
* `rtk-rules.md` só entra com `RTK_ENABLED=true` e o `rtk` no PATH (o `reconcileRtk` a tira sem ele).
|
|
74
|
+
* @param {string} workspaceDir
|
|
75
|
+
* @param {string} ide
|
|
76
|
+
* @param {string} envPath
|
|
77
|
+
* @returns {{ rulesSync: ReturnType<typeof syncRulesForProfile> | null, missingProfile: string[], profileLabel: string }}
|
|
78
|
+
*/
|
|
79
|
+
export function filterRulesByEnv(workspaceDir, ide, envPath) {
|
|
80
|
+
const envText = readFileSync(envPath, "utf-8");
|
|
81
|
+
const entries = parseEnvEntries(envText);
|
|
82
|
+
const value = (key) => {
|
|
83
|
+
const v = (entries.get(key) || "").trim();
|
|
84
|
+
return v && !/^\[.*\]$/.test(v) ? v : "";
|
|
85
|
+
};
|
|
86
|
+
const missingProfile = PROFILE_AXES.filter((axis) => !value(axis));
|
|
87
|
+
const profileLabel = PROFILE_AXES.map(value).join("/");
|
|
88
|
+
if (missingProfile.length) return { rulesSync: null, missingProfile, profileLabel };
|
|
89
|
+
const rulesSync = syncRulesForProfile(
|
|
90
|
+
join(workspaceDir, `.${getIDEFolder(ide)}`),
|
|
91
|
+
{
|
|
92
|
+
HUB: value("HUB"),
|
|
93
|
+
POSITION: value("POSITION"),
|
|
94
|
+
AREA: value("AREA"),
|
|
95
|
+
SQUAD: value("SQUAD"),
|
|
96
|
+
ARTIFACT_STYLE: value("ARTIFACT_STYLE") || "ai-generated",
|
|
97
|
+
},
|
|
98
|
+
{ rtkEnabled: value("RTK_ENABLED") === "true" && rtkAvailable(), envText }
|
|
99
|
+
);
|
|
100
|
+
return { rulesSync, missingProfile, profileLabel };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Linha de resumo do filtro de rules, com avisos e erros (nada sem filtro). */
|
|
104
|
+
function logRulesFilter(rulesSync, profileLabel) {
|
|
105
|
+
if (!rulesSync) return;
|
|
106
|
+
const copied = rulesSync.copied.rules + rulesSync.copied["rules-on-demand"];
|
|
107
|
+
logger.info(
|
|
108
|
+
` • Rules filtradas pelo perfil (${profileLabel}): ${copied} copiada(s), ${rulesSync.removed} removida(s)`
|
|
109
|
+
);
|
|
110
|
+
for (const w of rulesSync.warnings) logger.info(`${YELLOW} ⚠️ ${w}${NC}`);
|
|
111
|
+
for (const e of rulesSync.errors) logger.error(`${RED} ✗ ${e}${NC}`);
|
|
112
|
+
}
|
|
113
|
+
|
|
60
114
|
/**
|
|
61
115
|
* O que ainda pede o `/jarvis-init upgrade` na IDE depois do `jarvis init --upgrade` (#189, Q4).
|
|
62
116
|
* Só as pendências que o terminal não resolve: eixo sem forma de acesso, chave vazia, Central docs
|
|
63
117
|
* no formato antigo e TOKEN_TASK_MANAGER com valor. Não contam o aviso de WORKSPACE_MODE (conferir
|
|
64
118
|
* no ENV.md), vendor não suportado (vira freelance) nem as chaves novas acrescentadas (Q15: o
|
|
65
119
|
* `/jarvis-init` as põe no assunto delas na próxima vez que rodar). Nunca inclui valores do ENV.
|
|
66
|
-
*
|
|
120
|
+
* Eixo do perfil vazio (HUB, POSITION, AREA, SQUAD) também conta: sem ele, o upgrade não filtra
|
|
121
|
+
* as rules (#83).
|
|
122
|
+
* @param {{ pendingAxes: string[], envPlan: { pending?: string[], warnings?: string[] }, missingProfile?: string[] }} input
|
|
67
123
|
* @returns {string[]} um motivo por pendência; vazio = nada pendente
|
|
68
124
|
*/
|
|
69
|
-
export function upgradePendencies({ pendingAxes, envPlan }) {
|
|
125
|
+
export function upgradePendencies({ pendingAxes, envPlan, missingProfile = [] }) {
|
|
70
126
|
const reasons = [];
|
|
71
127
|
if (pendingAxes.length) reasons.push(`confirmar o acesso de ${pendingAxes.join(" e ")}`);
|
|
128
|
+
if (missingProfile.length) {
|
|
129
|
+
reasons.push(`preencher ${missingProfile.join(", ")} (as rules ficam sem o filtro do perfil)`);
|
|
130
|
+
}
|
|
72
131
|
if (envPlan.pending?.length) reasons.push(`preencher ${envPlan.pending.join(", ")}`);
|
|
73
132
|
const warnings = envPlan.warnings || [];
|
|
74
133
|
if (warnings.includes("CENTRAL_DOCS_REPO")) reasons.push("migrar o Central docs");
|
|
@@ -76,6 +135,32 @@ export function upgradePendencies({ pendingAxes, envPlan }) {
|
|
|
76
135
|
return reasons;
|
|
77
136
|
}
|
|
78
137
|
|
|
138
|
+
/**
|
|
139
|
+
* Pergunta do perfil de empresa no `--upgrade` (#199). Pura: recebe o `ask` (uma pergunta → a
|
|
140
|
+
* resposta) e o `warn` (um aviso na hora), e devolve o perfil próprio ou `null` para o default.
|
|
141
|
+
* Enter = default; nome inválido é perguntado mais uma vez; inválido de novo = default, com aviso.
|
|
142
|
+
* Testável sem terminal.
|
|
143
|
+
* @param {(question: string) => Promise<string>} ask
|
|
144
|
+
* @param {{ defaultProfile?: string, warn?: (message: string) => void }} [opts]
|
|
145
|
+
* @returns {Promise<string | null>}
|
|
146
|
+
*/
|
|
147
|
+
export async function promptCompanyProfile(
|
|
148
|
+
ask,
|
|
149
|
+
{ defaultProfile = DEFAULT_COMPANY_PROFILE, warn = () => {} } = {}
|
|
150
|
+
) {
|
|
151
|
+
const prompt = `Perfil de empresa (COMPANY_PROFILE) [Enter = ${defaultProfile}]: `;
|
|
152
|
+
let answer = (await ask(prompt)).trim();
|
|
153
|
+
if (answer && !isValidCompanyProfile(answer)) {
|
|
154
|
+
warn(
|
|
155
|
+
"Nome inválido: use letras minúsculas, números e hífen, e não o nome de uma pasta do core. Tente de novo ou Enter para o default."
|
|
156
|
+
);
|
|
157
|
+
answer = (await ask(prompt)).trim();
|
|
158
|
+
}
|
|
159
|
+
if (answer && isValidCompanyProfile(answer)) return answer === defaultProfile ? null : answer;
|
|
160
|
+
if (answer) warn(`Nome inválido de novo: gravando o default ${defaultProfile}.`);
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
|
|
79
164
|
/**
|
|
80
165
|
* Leitor de linhas que não perde resposta: guarda as linhas que chegam antes da pergunta
|
|
81
166
|
* (pipe com várias linhas, como `printf 's\n3\n'`) e devolve `null` quando a entrada fecha
|
|
@@ -308,6 +393,14 @@ export async function init(flags) {
|
|
|
308
393
|
for (const item of result.errors) {
|
|
309
394
|
logger.error(`${RED} ✗ ${item}${NC}`);
|
|
310
395
|
}
|
|
396
|
+
// Reinstalação com o ENV.md preenchido: o mesmo filtro do --upgrade (#83). Sem ENV.md (instalação
|
|
397
|
+
// nova) ou sem os 4 eixos, o Passo 8 do /jarvis-init filtra depois.
|
|
398
|
+
const envOnDisk = join(ideDir, "ENV.md");
|
|
399
|
+
if (forceSync && existsSync(envOnDisk)) {
|
|
400
|
+
const { rulesSync, profileLabel } = filterRulesByEnv(cwd, ide, envOnDisk);
|
|
401
|
+
logRulesFilter(rulesSync, profileLabel);
|
|
402
|
+
if (rulesSync?.errors.length) process.exitCode = 1;
|
|
403
|
+
}
|
|
311
404
|
|
|
312
405
|
const jarvisRoot = join(cwd, ".jarvis");
|
|
313
406
|
for (const area of ["eng", "prod", "qa"]) {
|
|
@@ -475,7 +568,8 @@ async function reportCliDiscovery(entries) {
|
|
|
475
568
|
/**
|
|
476
569
|
* `jarvis init --upgrade`: atualiza um projeto já configurado em uma passada.
|
|
477
570
|
* 1. arquivos do framework (como o --force, sem perguntar); 2. só as chaves novas do ENV;
|
|
478
|
-
* 3. documentos dos caminhos antigos → docs/jarvis/… (com confirmação ou --yes).
|
|
571
|
+
* 3. documentos dos caminhos antigos → docs/jarvis/… (com confirmação ou --yes); 4. rules
|
|
572
|
+
* filtradas pelo perfil do ENV (como o `jarvis rules sync`), só com os 4 eixos preenchidos.
|
|
479
573
|
* Nunca imprime valores do ENV, só nomes de chave e caminhos.
|
|
480
574
|
* @returns {Promise<number>} código de saída
|
|
481
575
|
*/
|
|
@@ -533,7 +627,7 @@ async function runUpgrade(cwd, flags) {
|
|
|
533
627
|
for (const item of sync.errors) logger.error(`${RED} ✗ ${item}${NC}`);
|
|
534
628
|
setupMcp(workspaceDir, ide);
|
|
535
629
|
|
|
536
|
-
// 2. Variáveis novas (só
|
|
630
|
+
// 2. Variáveis novas (acrescenta; apaga só as que saíram do template, REMOVED_KEYS)
|
|
537
631
|
const envText = readFileSync(envPath, "utf-8");
|
|
538
632
|
const templateText = readFileSync(
|
|
539
633
|
join(getFrameworkRoot(), "templates", "ENV-template.md"),
|
|
@@ -564,11 +658,40 @@ async function runUpgrade(cwd, flags) {
|
|
|
564
658
|
}
|
|
565
659
|
}
|
|
566
660
|
|
|
661
|
+
// 3.2 Perfil de empresa (#199): a chave nova nasce com o default; com terminal e sem --yes,
|
|
662
|
+
// pergunta. Só o nome da chave e "default/definido" saem no resumo, nunca o valor.
|
|
663
|
+
let companyProfile = null;
|
|
664
|
+
if (addedKeys.includes("COMPANY_PROFILE")) {
|
|
665
|
+
if (!flags.yes && process.stdin.isTTY) {
|
|
666
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
667
|
+
companyProfile = await promptCompanyProfile((q) => ask(rl, q), {
|
|
668
|
+
warn: (m) => logger.info(`${YELLOW} ${m}${NC}`),
|
|
669
|
+
});
|
|
670
|
+
rl.close();
|
|
671
|
+
} else if (!flags.yes) {
|
|
672
|
+
logger.info(
|
|
673
|
+
`${DIM} Sem terminal interativo e sem --yes: COMPANY_PROFILE fica no default ${DEFAULT_COMPANY_PROFILE}.${NC}`
|
|
674
|
+
);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
|
|
567
678
|
const overrides =
|
|
568
679
|
docsPlan.moves.length > 0 && !accepted ? declineEnvValues(docsPlan, addedKeys, env) : {};
|
|
680
|
+
if (companyProfile) overrides.COMPANY_PROFILE = companyProfile;
|
|
569
681
|
const today = new Date().toISOString().slice(0, 10);
|
|
570
682
|
applyEnvUpgrade(envPath, envPlan, today, overrides);
|
|
571
683
|
|
|
684
|
+
// 3.3 Perfil respondido agora: o sync acima rodou com o default. Reaplica o overlay do perfil
|
|
685
|
+
// gravado (pasta dele criada, rules dele por cima). A pasta do default criada antes fica: todo
|
|
686
|
+
// workspace a tem, e o upgrade não apaga nada em overlays/.
|
|
687
|
+
if (companyProfile) {
|
|
688
|
+
const again = { copied: [], skipped: [], errors: [] };
|
|
689
|
+
applyRuleOverlay(join(workspaceDir, `.${getIDEFolder(ide)}`), again);
|
|
690
|
+
for (const item of again.copied) logger.info(`${BLUE} ↳ ${item}${NC}`);
|
|
691
|
+
for (const item of again.skipped) logger.info(`${DIM} ↳ ${item}${NC}`);
|
|
692
|
+
for (const e of again.errors) logger.error(`${RED} ✗ ${e}${NC}`);
|
|
693
|
+
}
|
|
694
|
+
|
|
572
695
|
// 3.1 Skills instalados que saíram do framework: só lista; remove com confirmação ou --remove-stale
|
|
573
696
|
const ideSkillsDir = join(workspaceDir, `.${getIDEFolder(ide)}`, "skills");
|
|
574
697
|
const stale = findStaleSkills({
|
|
@@ -607,6 +730,9 @@ async function runUpgrade(cwd, flags) {
|
|
|
607
730
|
rewritten = rewriteRelatedDiscovery(workspaceDir, env, moved);
|
|
608
731
|
}
|
|
609
732
|
|
|
733
|
+
// 3.4 Rules do perfil (#83): o mesmo filtro do `jarvis rules sync`, com o ENV.md já gravado.
|
|
734
|
+
const { rulesSync, missingProfile, profileLabel } = filterRulesByEnv(workspaceDir, ide, envPath);
|
|
735
|
+
|
|
610
736
|
// 4. Resumo (só nomes de chave e caminhos)
|
|
611
737
|
const pkg = getPackageInfo();
|
|
612
738
|
logger.info("");
|
|
@@ -619,6 +745,17 @@ async function runUpgrade(cwd, flags) {
|
|
|
619
745
|
logger.info(
|
|
620
746
|
` • ENV.md: ${addedKeys.length ? `+ ${addedKeys.join(", ")}` : "nenhuma variável nova"}`
|
|
621
747
|
);
|
|
748
|
+
// Só os nomes: o valor das chaves apagadas nunca é lido (#209).
|
|
749
|
+
if (envPlan.removedApplied?.length) {
|
|
750
|
+
logger.info(
|
|
751
|
+
` • ENV.md: removidas (não são mais usadas): ${envPlan.removedApplied.join(", ")}`
|
|
752
|
+
);
|
|
753
|
+
}
|
|
754
|
+
if (addedKeys.includes("COMPANY_PROFILE")) {
|
|
755
|
+
logger.info(
|
|
756
|
+
` • COMPANY_PROFILE: ${companyProfile ? "definido" : `default (${DEFAULT_COMPANY_PROFILE})`}`
|
|
757
|
+
);
|
|
758
|
+
}
|
|
622
759
|
if (Object.keys(overrides).length) {
|
|
623
760
|
logger.info(` • Mantidos no caminho antigo: ${Object.keys(overrides).join(", ")}`);
|
|
624
761
|
}
|
|
@@ -632,6 +769,7 @@ async function runUpgrade(cwd, flags) {
|
|
|
632
769
|
for (const e of moveErrors) logger.error(`${RED} ✗ ${e}${NC}`);
|
|
633
770
|
if (staleRemoved.length) logger.info(` • Skills antigos removidos: ${staleRemoved.join(", ")}`);
|
|
634
771
|
for (const e of staleErrors) logger.error(`${RED} ✗ ${e}${NC}`);
|
|
772
|
+
logRulesFilter(rulesSync, profileLabel);
|
|
635
773
|
for (const k of envPlan.pending) {
|
|
636
774
|
logger.info(`${YELLOW} ⚠️ ${k} está vazio: responda no /jarvis-init upgrade${NC}`);
|
|
637
775
|
}
|
|
@@ -666,12 +804,14 @@ async function runUpgrade(cwd, flags) {
|
|
|
666
804
|
const access = (futureEntries.get(`${key}_ACCESS`) || "").trim();
|
|
667
805
|
return getVendor(futureEntries.get(key)) && (!access || /^\[.*\]$/.test(access));
|
|
668
806
|
});
|
|
669
|
-
const pending = upgradePendencies({ pendingAxes, envPlan });
|
|
807
|
+
const pending = upgradePendencies({ pendingAxes, envPlan, missingProfile });
|
|
670
808
|
logger.info("");
|
|
671
809
|
logger.info(
|
|
672
810
|
pending.length
|
|
673
811
|
? `${CYAN}➡️ Agora rode ${BOLD}/jarvis-init upgrade${NC}${CYAN} na IDE: ${pending.join("; ")}.${NC}\n`
|
|
674
812
|
: `${GREEN}✓ Nada pendente na IDE.${NC}\n`
|
|
675
813
|
);
|
|
676
|
-
return sync.errors.length || moveErrors.length || staleErrors.length
|
|
814
|
+
return sync.errors.length || moveErrors.length || staleErrors.length || rulesSync?.errors.length
|
|
815
|
+
? 1
|
|
816
|
+
: 0;
|
|
677
817
|
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { basename, dirname, join } from "node:path";
|
|
3
|
+
import { resolveEnvPath, loadEnv } from "../lib/env-loader.js";
|
|
4
|
+
import { syncRulesForProfile } from "../lib/core/sync-engine.js";
|
|
5
|
+
import { getIDEFolder, getIDEValues } from "../lib/config/ide-config.js";
|
|
6
|
+
import { LOCK_FILE } from "../lib/config/constants.js";
|
|
7
|
+
import { getPackageInfo } from "../lib/utils/paths.js";
|
|
8
|
+
import { logger, configureFromFlags } from "../lib/utils/logger.js";
|
|
9
|
+
import { RED, GREEN, YELLOW, CYAN, NC } from "../lib/utils/ui.js";
|
|
10
|
+
|
|
11
|
+
const AXES = ["HUB", "POSITION", "AREA", "SQUAD"];
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Versão do `jarvis-lock.json` da pasta (a da IDE ou a raiz do workspace), ou `null` sem o arquivo.
|
|
15
|
+
* Arquivo presente, mas ilegível ou sem `version`, interrompe o comando: não cai para outro lock.
|
|
16
|
+
* @param {string} dir
|
|
17
|
+
*/
|
|
18
|
+
function readLock(dir) {
|
|
19
|
+
const lockPath = join(dir, LOCK_FILE);
|
|
20
|
+
if (!existsSync(lockPath)) return null;
|
|
21
|
+
let version;
|
|
22
|
+
try {
|
|
23
|
+
version = JSON.parse(readFileSync(lockPath, "utf-8")).version;
|
|
24
|
+
} catch {
|
|
25
|
+
// tratado abaixo
|
|
26
|
+
}
|
|
27
|
+
if (!version) fail(`${lockPath} ilegível ou sem versão: rode \`jarvis init --upgrade\``);
|
|
28
|
+
return version;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Pasta (o `cwd` ou uma acima) que tem a pasta `folder` da IDE, ou `null`. */
|
|
32
|
+
function findWorkspaceWith(folder) {
|
|
33
|
+
for (let dir = process.cwd(); ; dir = dirname(dir)) {
|
|
34
|
+
if (existsSync(join(dir, folder))) return dir;
|
|
35
|
+
if (dirname(dir) === dir) return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function fail(message) {
|
|
40
|
+
logger.error(`${RED}❌ ${message}${NC}`);
|
|
41
|
+
logger.info(
|
|
42
|
+
`${YELLOW}Sem o comando, o /jarvis-init segue skills/jarvis-init/assets/rules-sync-manual.md.${NC}\n`
|
|
43
|
+
);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* `jarvis rules sync`: Passo 8 do `/jarvis-init` pelo CLI (#102). Filtra `.{ide}/rules/` e
|
|
49
|
+
* `.{ide}/rules-on-demand/` pelo perfil do ENV.md e aplica o overlay de `COMPANY_PROFILE`.
|
|
50
|
+
* Sai com 1, sem gravar nada, sem ENV.md numa pasta de IDE, com eixo faltando ou com o lock ausente
|
|
51
|
+
* ou de outra versão (os assets da IDE seriam de outra versão que as rules do Jarvis em uso).
|
|
52
|
+
* @param {{ ide?: string, "env-file"?: string }} flags
|
|
53
|
+
*/
|
|
54
|
+
export async function rulesSync(flags) {
|
|
55
|
+
configureFromFlags(flags);
|
|
56
|
+
|
|
57
|
+
let resolved;
|
|
58
|
+
try {
|
|
59
|
+
resolved = resolveEnvPath(process.cwd(), flags);
|
|
60
|
+
} catch (err) {
|
|
61
|
+
fail(err.message);
|
|
62
|
+
}
|
|
63
|
+
// Sem --ide, a pasta filtrada é a do ENV.md. Fora de uma pasta de IDE (o fallback legado do
|
|
64
|
+
// resolveEnvPath, ou um --env-file/JARVIS_ENV_FILE em outro lugar), o comando gravaria rules ali.
|
|
65
|
+
// Com --ide, o ENV.md pode vir de fora de uma IDE (o workspace é então a pasta, o cwd ou uma
|
|
66
|
+
// acima, que tem a .{ide}/), mas não da pasta de outra IDE.
|
|
67
|
+
const ideFolders = getIDEValues().map((ide) => `.${getIDEFolder(ide)}`);
|
|
68
|
+
const envFolder = basename(dirname(resolved.path));
|
|
69
|
+
if (!flags.ide && !ideFolders.includes(envFolder)) {
|
|
70
|
+
fail(
|
|
71
|
+
`ENV.md não encontrado na pasta de uma IDE (${resolved.path}): rode \`jarvis init\` ou passe --ide`
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
const ideFolder = flags.ide ? `.${getIDEFolder(flags.ide)}` : envFolder;
|
|
75
|
+
if (ideFolders.includes(envFolder) && envFolder !== ideFolder) {
|
|
76
|
+
fail(
|
|
77
|
+
`ENV.md de outra IDE (${envFolder}/) com --ide ${flags.ide}: use o ENV.md de ${ideFolder}/`
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
let workspaceDir = dirname(dirname(resolved.path));
|
|
81
|
+
if (!ideFolders.includes(envFolder)) {
|
|
82
|
+
workspaceDir = findWorkspaceWith(ideFolder);
|
|
83
|
+
if (workspaceDir === null) {
|
|
84
|
+
fail(
|
|
85
|
+
`Pasta ${ideFolder}/ não encontrada a partir de ${process.cwd()}: rode o comando na pasta do workspace`
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const ideDir = join(workspaceDir, ideFolder);
|
|
90
|
+
const envText = readFileSync(resolved.path, "utf-8");
|
|
91
|
+
const env = loadEnv(process.cwd(), resolved.path);
|
|
92
|
+
|
|
93
|
+
const missing = AXES.filter((axis) => !env[axis]);
|
|
94
|
+
if (missing.length > 0) fail(`Perfil incompleto no ENV.md: faltam ${missing.join(", ")}`);
|
|
95
|
+
|
|
96
|
+
// O lock da IDE filtrada vale primeiro: com duas IDEs, o da raiz é o do último init.
|
|
97
|
+
const lock = readLock(ideDir) ?? readLock(workspaceDir);
|
|
98
|
+
const running = getPackageInfo().version;
|
|
99
|
+
if (lock === null) fail(`Sem ${LOCK_FILE} no workspace: rode \`jarvis init\``);
|
|
100
|
+
if (lock !== running) {
|
|
101
|
+
fail(
|
|
102
|
+
`assets da ${lock} e Jarvis ${running}: rode \`jarvis init --upgrade\` (ou siga sem filtrar pelo CLI)`
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const profile = {
|
|
107
|
+
HUB: env.HUB,
|
|
108
|
+
POSITION: env.POSITION,
|
|
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
|
+
});
|
|
117
|
+
|
|
118
|
+
logger.info(
|
|
119
|
+
`${CYAN}🔍 Sincronizando rules para o perfil: HUB=${profile.HUB} | POSITION=${profile.POSITION} | AREA=${profile.AREA} | SQUAD=${profile.SQUAD} | ARTIFACT_STYLE=${profile.ARTIFACT_STYLE}${NC}\n`
|
|
120
|
+
);
|
|
121
|
+
for (const warning of result.warnings) logger.info(`${YELLOW}⚠️ ${warning}${NC}`);
|
|
122
|
+
const total = result.copied.rules + result.copied["rules-on-demand"];
|
|
123
|
+
logger.info(`${GREEN}✅ Rules sincronizadas:${NC}`);
|
|
124
|
+
logger.info(
|
|
125
|
+
` Copiadas : ${total} arquivos (rules/: ${result.copied.rules} | rules-on-demand/: ${result.copied["rules-on-demand"]})`
|
|
126
|
+
);
|
|
127
|
+
logger.info(` Removidas: ${result.removed} arquivos (não batem com o perfil)`);
|
|
128
|
+
logger.info(` Universais: ${result.universal} arquivos (sem applies_to — sempre copiadas)`);
|
|
129
|
+
logger.info(` Do overlay: ${result.fromOverlay} arquivos (${result.companyProfile})`);
|
|
130
|
+
if (result.folderCreated) logger.info(` Overlay ${result.companyProfile}: pasta criada`);
|
|
131
|
+
|
|
132
|
+
if (result.errors.length > 0) {
|
|
133
|
+
for (const error of result.errors) logger.error(`${RED} ✗ ${error}${NC}`);
|
|
134
|
+
process.exit(1);
|
|
135
|
+
}
|
|
136
|
+
}
|
package/bin/lib/cli/program.js
CHANGED
|
@@ -24,7 +24,9 @@ import { docsSync } from "../../commands/docs-sync.js";
|
|
|
24
24
|
import { docsPublish } from "../../commands/docs-publish.js";
|
|
25
25
|
import { installRtk } from "../../commands/install-rtk.js";
|
|
26
26
|
import { tokens } from "../../commands/tokens.js";
|
|
27
|
+
import { rulesSync } from "../../commands/rules.js";
|
|
27
28
|
import { map } from "../../commands/map.js";
|
|
29
|
+
import { fork } from "../../commands/fork.js";
|
|
28
30
|
import { dailyReport } from "../../commands/daily-report.js";
|
|
29
31
|
import { runCreateMerge } from "../vcs/create-merge.js";
|
|
30
32
|
import { runCreateIssue } from "../vcs/create-issue.js";
|
|
@@ -177,6 +179,40 @@ export function buildProgram() {
|
|
|
177
179
|
.option("--env-file <path>")
|
|
178
180
|
.action((options) => tokens(toLegacyFlags(options)));
|
|
179
181
|
|
|
182
|
+
const rules = cmd(program, "rules").description("Rules da pasta da IDE");
|
|
183
|
+
const rulesSyncCmd = cmd(rules, "sync").description(
|
|
184
|
+
"Filtrar rules/ e rules-on-demand/ da IDE pelo perfil do ENV.md (Passo 8 do /jarvis-init)"
|
|
185
|
+
);
|
|
186
|
+
withEnvOptions(withLogOptions(rulesSyncCmd)).action((options) =>
|
|
187
|
+
rulesSync(toLegacyFlags(options))
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
cmd(program, "fork")
|
|
191
|
+
.description(
|
|
192
|
+
"Overlay de empresa: copia um artefato do core para $IDE/overlays/{COMPANY_PROFILE}/, com carimbo"
|
|
193
|
+
)
|
|
194
|
+
.argument(
|
|
195
|
+
"[nome]",
|
|
196
|
+
"Workflow, skill ou agente pelo nome, ou rules/…, rules-on-demand/…, templates/… por caminho"
|
|
197
|
+
)
|
|
198
|
+
.option(
|
|
199
|
+
"--list",
|
|
200
|
+
"Lista o que está forkado no overlay ativo (só lista; não compara com o core)"
|
|
201
|
+
)
|
|
202
|
+
.option(
|
|
203
|
+
"--update",
|
|
204
|
+
"Recarimba o fork com a versão atual do core (forked_from); o conteúdo não muda"
|
|
205
|
+
)
|
|
206
|
+
.option(
|
|
207
|
+
"--diff",
|
|
208
|
+
"Com --update: só mostra o diff fork × core atual, por seção (🔴 em possível mudança de contrato), sem gravar"
|
|
209
|
+
)
|
|
210
|
+
.option("--delete", "Remove o fork do overlay; rules voltam à versão do core na IDE")
|
|
211
|
+
.option("--candidate", "Marca o fork como candidato a core (core_candidate: true)")
|
|
212
|
+
.option("--ide <ide>")
|
|
213
|
+
.option("--env-file <path>")
|
|
214
|
+
.action((nome, options) => fork(toLegacyFlags(options, { _: [nome].filter(Boolean) })));
|
|
215
|
+
|
|
180
216
|
cmd(program, "map")
|
|
181
217
|
.description("Mapa de chamadas de um workflow, skill ou agente")
|
|
182
218
|
.argument("[name]", "Nome do workflow, skill ou agente")
|
|
@@ -83,6 +83,9 @@ export const OBSOLETE_PATHS = Object.freeze([
|
|
|
83
83
|
"rules/engineering/eng.pre-pr-rules.md",
|
|
84
84
|
"rules/engineering/eng.tech-spec-rules.md",
|
|
85
85
|
"rules/engineering/eng.breakdown-subtasks-rules.md",
|
|
86
|
+
"rules/engineering/eng.bump-rules.md",
|
|
87
|
+
"rules/engineering/eng.docs-scraping-rules.md",
|
|
88
|
+
"rules/engineering/rpa",
|
|
86
89
|
// Consolidação de QA (removidos): área QA ficou só com eng-qa (base) e eng-qa-planner
|
|
87
90
|
"skills/eng-qa-test-plan",
|
|
88
91
|
"skills/eng-qa-gate",
|
|
@@ -143,8 +146,64 @@ export const OBSOLETE_PATHS = Object.freeze([
|
|
|
143
146
|
"skills/eng-frontend-microfrontend",
|
|
144
147
|
// eng.bug-audit (removido): virou o caso "varrer" do /eng.debug (#168)
|
|
145
148
|
"workflows/engineering/eng.bug-audit.md",
|
|
149
|
+
// eng-backend-rabbitmq e data-rules (removidos na limpeza do ENV.md, #209): o skill operava o
|
|
150
|
+
// broker pelas variáveis MESSAGE_BROKER_*; a rule fixava uma stack de dados que a base eng-data
|
|
151
|
+
// já cobre de forma neutra. No Kiro, a rule vira steering/{nome} e o skill, steering/skills/.
|
|
152
|
+
"skills/eng-backend-rabbitmq",
|
|
153
|
+
"steering/skills/skill-eng-backend-rabbitmq.md",
|
|
154
|
+
"rules/engineering/data/data-rules.md",
|
|
155
|
+
"steering/data-rules.md",
|
|
156
|
+
// Cópias do Kiro (steering/{nome}) das rules que saíram de rules/ no #133 (bump e rpa, com a
|
|
157
|
+
// docs-scraping fundida); rules-on-demand/ não vira steering, então nada válido tem esses nomes.
|
|
158
|
+
"steering/eng.bump-rules.md",
|
|
159
|
+
"steering/eng.docs-scraping-rules.md",
|
|
160
|
+
"steering/eng.rpa-rules.md",
|
|
161
|
+
// rules/AGENTS.md e rules/product/README.md (issue #84): conteúdo de autoria movido
|
|
162
|
+
// para docs/estrutura/rules.md; rules/product/README.md era órfão, sem referências
|
|
163
|
+
"rules/AGENTS.md",
|
|
164
|
+
"rules/product/README.md",
|
|
165
|
+
// Documentação de pasta e all-tools (issue #89): deixaram de ser copiados para a IDE (ver
|
|
166
|
+
// SYNC_EXCLUDE). O nome da pasta de workflows varia por IDE (commands, workflows, steering).
|
|
167
|
+
"commands/AGENTS.md",
|
|
168
|
+
"commands/README.md",
|
|
169
|
+
"commands/all-tools.md",
|
|
170
|
+
"workflows/AGENTS.md",
|
|
171
|
+
"workflows/README.md",
|
|
172
|
+
"workflows/all-tools.md",
|
|
173
|
+
"steering/AGENTS.md",
|
|
174
|
+
"steering/README.md",
|
|
175
|
+
"steering/all-tools.md",
|
|
176
|
+
"skills/AGENTS.md",
|
|
177
|
+
"skills/SKILLS-ROADMAP.md",
|
|
178
|
+
"skills/jarvis-docs-central/README.md",
|
|
179
|
+
"skills/product-roadmap-report/README.md",
|
|
180
|
+
"agents/AGENTS.md",
|
|
181
|
+
"agents/README.md",
|
|
182
|
+
// product-roadmap-report (issue #91): rules/detailed-guide.md era cópia de references/detailed-guide.md
|
|
183
|
+
// (a mantida), com uma linha de plugin externo inexistente
|
|
184
|
+
"skills/product-roadmap-report/rules/detailed-guide.md",
|
|
185
|
+
// templates sem consumidor (issue #92): swagger e CONTACTS apagados; o ensaio CDD foi para
|
|
186
|
+
// skills/jarvis-context-detect/references/
|
|
187
|
+
"templates/engineering/swagger-template.md",
|
|
188
|
+
"templates/engineering/CONTACTS-template.md",
|
|
189
|
+
"templates/cdd-aplicado-a-prompts.md",
|
|
146
190
|
]);
|
|
147
191
|
|
|
192
|
+
/**
|
|
193
|
+
* Arquivos de documentação de pasta que ficam só no repositório do framework e não são
|
|
194
|
+
* copiados para a IDE. Por pasta de `SYNC_DIRS`, expressões aplicadas ao caminho relativo
|
|
195
|
+
* (com `/`) dentro dela. `workflows/` vira `commands/` ou `steering/` conforme a IDE e é
|
|
196
|
+
* achatado depois da cópia; barrar na origem evita que um README aninhado sobrescreva outro.
|
|
197
|
+
* Em `skills/` todo `*.md` da raiz sai (skill é sempre uma pasta); em `agents/` só os nomes de
|
|
198
|
+
* documentação, porque um agent pode ficar direto na raiz da pasta.
|
|
199
|
+
* @constant {Readonly<Record<string, ReadonlyArray<RegExp>>>}
|
|
200
|
+
*/
|
|
201
|
+
export const SYNC_EXCLUDE = Object.freeze({
|
|
202
|
+
workflows: Object.freeze([/(^|\/)(AGENTS|README)\.md$/]),
|
|
203
|
+
skills: Object.freeze([/^[^/]+\.md$/, /^[^/]+\/README\.md$/]),
|
|
204
|
+
agents: Object.freeze([/^(AGENTS|README)\.md$/]),
|
|
205
|
+
});
|
|
206
|
+
|
|
148
207
|
/**
|
|
149
208
|
* Arquivos da raiz que devem ser sincronizados
|
|
150
209
|
* @constant {ReadonlyArray<string>}
|
|
@@ -193,44 +252,6 @@ export const OPENCODE_DEFAULT_PERMISSIONS = Object.freeze({
|
|
|
193
252
|
task: "allow",
|
|
194
253
|
});
|
|
195
254
|
|
|
196
|
-
/**
|
|
197
|
-
* Campos de frontmatter Jarvis-only que devem ser removidos para OpenCode commands
|
|
198
|
-
* @constant {ReadonlyArray<string>}
|
|
199
|
-
*/
|
|
200
|
-
export const OPENCODE_STRIP_FIELDS = Object.freeze([
|
|
201
|
-
"auto_execution_mode",
|
|
202
|
-
"rules_file",
|
|
203
|
-
"template_file",
|
|
204
|
-
"model_tier",
|
|
205
|
-
"model_justification",
|
|
206
|
-
"recommended_model",
|
|
207
|
-
"env_file",
|
|
208
|
-
"globs",
|
|
209
|
-
]);
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Campos de frontmatter Jarvis-only que devem ser removidos para steering files Kiro
|
|
213
|
-
* @constant {ReadonlyArray<string>}
|
|
214
|
-
*/
|
|
215
|
-
export const KIRO_STRIP_FIELDS = Object.freeze([
|
|
216
|
-
"trigger",
|
|
217
|
-
"auto_execution_mode",
|
|
218
|
-
"rules_file",
|
|
219
|
-
"template_file",
|
|
220
|
-
"model_tier",
|
|
221
|
-
"model_justification",
|
|
222
|
-
"recommended_model",
|
|
223
|
-
"env_file",
|
|
224
|
-
"globs",
|
|
225
|
-
"agent",
|
|
226
|
-
"allowed-tools",
|
|
227
|
-
"disable-model-invocation",
|
|
228
|
-
"compatibility",
|
|
229
|
-
"license",
|
|
230
|
-
"metadata",
|
|
231
|
-
"argument-hint",
|
|
232
|
-
]);
|
|
233
|
-
|
|
234
255
|
/**
|
|
235
256
|
* Mapeamento de HUB Jarvis para fileMatchPattern do Kiro
|
|
236
257
|
* Usado para gerar steering files de rules com inclusion: fileMatch
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Perfil de empresa (`COMPANY_PROFILE`, #199): nome do overlay ativo em
|
|
3
|
+
* `$IDE/overlays/{perfil}/`. A chave nunca fica vazia: o default é `stark-industries`,
|
|
4
|
+
* o overlay padrão do Jarvis. Um nome fora do padrão ou igual a uma pasta do core cai
|
|
5
|
+
* no default, com aviso. Este módulo só decide o nome; quem lê e grava arquivos é quem o chama.
|
|
6
|
+
* @module core/company-profile
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** @constant {string} Perfil default: o overlay padrão de todo workspace */
|
|
10
|
+
export const DEFAULT_COMPANY_PROFILE = "stark-industries";
|
|
11
|
+
|
|
12
|
+
/** @constant {RegExp} Mesmo padrão dos nomes de skill (minúsculas, números e hífen) */
|
|
13
|
+
export const COMPANY_PROFILE_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Pastas do core que um perfil não pode usar como nome: o overlay espelha estas pastas,
|
|
17
|
+
* e `overlays/rules/` ficaria ambíguo com `rules/`.
|
|
18
|
+
* @constant {ReadonlyArray<string>}
|
|
19
|
+
*/
|
|
20
|
+
export const CORE_FOLDERS = Object.freeze([
|
|
21
|
+
"agents",
|
|
22
|
+
"skills",
|
|
23
|
+
"workflows",
|
|
24
|
+
"commands",
|
|
25
|
+
"rules",
|
|
26
|
+
"rules-on-demand",
|
|
27
|
+
"templates",
|
|
28
|
+
"scripts",
|
|
29
|
+
"overlays",
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @param {string} name
|
|
34
|
+
* @returns {boolean} true se o nome serve como perfil (padrão e fora das pastas do core)
|
|
35
|
+
*/
|
|
36
|
+
export function isValidCompanyProfile(name) {
|
|
37
|
+
return COMPANY_PROFILE_PATTERN.test(name) && !CORE_FOLDERS.includes(name);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Resolve o perfil ativo a partir do valor lido do `ENV.md` (já sem aspas e comentário).
|
|
42
|
+
* Vazio ou ausente → default com aviso ℹ️ (ENV editado à mão ou anterior à #199);
|
|
43
|
+
* inválido → default com aviso ⚠️. O aviso vai no retorno, nunca em log: quem chama decide.
|
|
44
|
+
* @param {string | undefined | null} raw - valor de `COMPANY_PROFILE`
|
|
45
|
+
* @returns {{ profile: string, warning: string | null, isDefault: boolean }}
|
|
46
|
+
*/
|
|
47
|
+
export function resolveCompanyProfile(raw) {
|
|
48
|
+
const value = (raw ?? "").trim();
|
|
49
|
+
if (!value) {
|
|
50
|
+
return {
|
|
51
|
+
profile: DEFAULT_COMPANY_PROFILE,
|
|
52
|
+
isDefault: true,
|
|
53
|
+
warning:
|
|
54
|
+
raw === undefined || raw === null
|
|
55
|
+
? null
|
|
56
|
+
: `ℹ️ COMPANY_PROFILE vazio: usando o perfil default ${DEFAULT_COMPANY_PROFILE}. Rode /jarvis-init para definir um perfil próprio.`,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
if (CORE_FOLDERS.includes(value)) {
|
|
60
|
+
return {
|
|
61
|
+
profile: DEFAULT_COMPANY_PROFILE,
|
|
62
|
+
isDefault: true,
|
|
63
|
+
warning: `⚠️ COMPANY_PROFILE não pode ser o nome de uma pasta do core (${CORE_FOLDERS.join(", ")}). Usando o perfil default ${DEFAULT_COMPANY_PROFILE}.`,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
if (!COMPANY_PROFILE_PATTERN.test(value)) {
|
|
67
|
+
return {
|
|
68
|
+
profile: DEFAULT_COMPANY_PROFILE,
|
|
69
|
+
isDefault: true,
|
|
70
|
+
warning: `⚠️ COMPANY_PROFILE "${value}" inválido (use letras minúsculas, números e hífen). Usando o perfil default ${DEFAULT_COMPANY_PROFILE}.`,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
return { profile: value, isDefault: value === DEFAULT_COMPANY_PROFILE, warning: null };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Lê `COMPANY_PROFILE=` de um texto de `ENV.md` (primeira ocorrência, sem aspas nem comentário
|
|
78
|
+
* de fim de linha) e resolve o perfil. ENV.md sem a chave (anterior à #199) → default com o ℹ️,
|
|
79
|
+
* como a chave vazia; sem ENV.md (`envText` ausente, primeiro `jarvis init`) → default sem aviso.
|
|
80
|
+
* @param {string | undefined} envText
|
|
81
|
+
* @returns {{ profile: string, warning: string | null, isDefault: boolean }}
|
|
82
|
+
*/
|
|
83
|
+
export function readCompanyProfile(envText) {
|
|
84
|
+
if (envText === undefined || envText === null) return resolveCompanyProfile(undefined);
|
|
85
|
+
const match = /^[ \t]*COMPANY_PROFILE=(.*)$/m.exec(envText);
|
|
86
|
+
if (!match) return resolveCompanyProfile("");
|
|
87
|
+
const raw = match[1]
|
|
88
|
+
.replace(/\s+#.*$/, "")
|
|
89
|
+
.trim()
|
|
90
|
+
.replace(/^["']|["']$/g, "");
|
|
91
|
+
return resolveCompanyProfile(raw);
|
|
92
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Documentos de trabalho nos caminhos antigos → docs/jarvis/… (`jarvis init --upgrade`).
|
|
2
|
-
// Mesmas regras do item
|
|
2
|
+
// Mesmas regras do item 7 do Upgrade (C) do skill jarvis-init: conflito no destino pula,
|
|
3
3
|
// pasta antiga removida só se ficar vazia, `git mv` quando versionado, `related_discovery`
|
|
4
4
|
// reescrito pelo nome do arquivo e, na recusa, só chaves novas recebem o caminho antigo.
|
|
5
5
|
import {
|
|
@@ -73,7 +73,7 @@ function listFiles(dir) {
|
|
|
73
73
|
return files;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
/** Pares pasta antiga → pasta nova, na ordem do item
|
|
76
|
+
/** Pares pasta antiga → pasta nova, na ordem do item 7 + discoveries. */
|
|
77
77
|
function sourcePairs(f) {
|
|
78
78
|
const pairs = [
|
|
79
79
|
{ from: `${f.docs}/product`, to: f.prod, discoveriesSub: true },
|