jarvis-ai-framework 8.3.0 → 8.6.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 +46 -100
- package/README.md +2 -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-consolidator.agent.md +6 -3
- package/agents/engineering/eng.docs-writer.md +12 -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 +8 -6
- package/bin/commands/docs-archive.js +86 -0
- package/bin/commands/docs-finalize.js +82 -0
- package/bin/commands/docs-migrate.js +107 -0
- package/bin/commands/docs-publish.js +132 -67
- package/bin/commands/docs-sync.js +12 -7
- package/bin/commands/init.js +92 -7
- package/bin/commands/rules.js +136 -0
- package/bin/lib/cli/program.js +65 -4
- package/bin/lib/config/constants.js +60 -39
- package/bin/lib/core/docs-migrate.js +2 -2
- package/bin/lib/core/env-upgrade.js +132 -16
- package/bin/lib/core/profile-filter.js +4 -9
- package/bin/lib/core/scanner.js +10 -4
- package/bin/lib/core/sync-engine.js +184 -51
- package/bin/lib/docs/finish-delivery.js +493 -0
- package/bin/lib/docs/migrate-central.js +229 -0
- package/bin/lib/docs/publish-file.js +176 -46
- package/bin/lib/docs/storage/build-index.js +83 -47
- package/bin/lib/docs/storage/filesystem.js +341 -6
- package/bin/lib/docs/storage/index.js +0 -1
- package/bin/lib/docs/validate-frontmatter.js +34 -2
- 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 +0 -4
- package/rules/engineering/eng-rules.md +0 -4
- package/rules/engineering/eng-security-rules.md +1 -34
- package/rules/engineering/eng.integrations-rules.md +3 -3
- 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 +3 -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 +40 -0
- package/skills/AGENTS.md +12 -8
- package/skills/SKILLS-ROADMAP.md +16 -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/README.md +22 -10
- package/skills/jarvis-docs-central/SKILL.md +78 -43
- package/skills/jarvis-docs-index/SKILL.md +1 -1
- package/skills/jarvis-evolution-architect/SKILL.md +1 -2
- package/skills/jarvis-fork/SKILL.md +6 -11
- package/skills/jarvis-init/SKILL.md +28 -370
- 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 +51 -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 +19 -3
- package/templates/ENV-template.md +0 -59
- package/templates/engineering/AGENTS-template.md +0 -1
- package/templates/engineering/breakdown-subtasks-template.md +76 -447
- package/templates/engineering/central-delivery-template.md +4 -1
- package/templates/engineering/central-feature-template.md +16 -7
- package/templates/engineering/central-home-template.md +31 -0
- package/templates/engineering/central-product-template.md +41 -0
- package/templates/engineering/data-contract-template.md +2 -2
- package/templates/engineering/light-arch-template.md +242 -0
- 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 +2 -6
- package/workflows/engineering/data/data.new-pipeline.md +3 -7
- package/workflows/engineering/eng.breakdown-subtasks.md +9 -239
- package/workflows/engineering/eng.build-tech-spec.md +1 -3
- package/workflows/engineering/eng.create-ard-from-code.md +5 -6
- package/workflows/engineering/eng.create-ard.md +6 -10
- package/workflows/engineering/eng.create-rfc.md +4 -6
- package/workflows/engineering/eng.daily-report.md +0 -2
- package/workflows/engineering/eng.debug.md +1 -5
- package/workflows/engineering/eng.docs.md +2 -5
- package/workflows/engineering/eng.light-arch.md +7 -7
- package/workflows/engineering/eng.plan.md +2 -4
- package/workflows/engineering/eng.pr.md +9 -37
- package/workflows/engineering/eng.pre-pr.md +16 -8
- package/workflows/engineering/eng.review.md +1 -5
- package/workflows/engineering/eng.rpa.robot.md +5 -7
- package/workflows/engineering/eng.spec-consolidate.md +106 -42
- package/workflows/engineering/eng.start.md +16 -86
- package/workflows/engineering/eng.work.md +18 -151
- 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 +1 -4
- package/workflows/engineering/qa/eng.qa-sprint-planning.md +1 -5
- 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 +2 -5
- 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 -227
- 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
|
@@ -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
|
@@ -22,8 +22,12 @@ import { info } from "../../commands/info.js";
|
|
|
22
22
|
import { whoami } from "../../commands/whoami.js";
|
|
23
23
|
import { docsSync } from "../../commands/docs-sync.js";
|
|
24
24
|
import { docsPublish } from "../../commands/docs-publish.js";
|
|
25
|
+
import { docsMigrate } from "../../commands/docs-migrate.js";
|
|
26
|
+
import { docsArchive } from "../../commands/docs-archive.js";
|
|
27
|
+
import { docsFinalize } from "../../commands/docs-finalize.js";
|
|
25
28
|
import { installRtk } from "../../commands/install-rtk.js";
|
|
26
29
|
import { tokens } from "../../commands/tokens.js";
|
|
30
|
+
import { rulesSync } from "../../commands/rules.js";
|
|
27
31
|
import { map } from "../../commands/map.js";
|
|
28
32
|
import { fork } from "../../commands/fork.js";
|
|
29
33
|
import { dailyReport } from "../../commands/daily-report.js";
|
|
@@ -145,12 +149,28 @@ export function buildProgram() {
|
|
|
145
149
|
|
|
146
150
|
const docsPublishCmd = cmd(docs, "publish")
|
|
147
151
|
.description(
|
|
148
|
-
"Publicar
|
|
152
|
+
"Publicar no Central docs, na estrutura por funcionalidade (pasta: copia e regenera o índice; com git: branch + PR)"
|
|
153
|
+
)
|
|
154
|
+
.option("--file <path>", "Caminho do arquivo local (um só; alternativa ao --manifest)")
|
|
155
|
+
.option(
|
|
156
|
+
"--manifest <path>",
|
|
157
|
+
"Manifesto JSON com vários arquivos ([{file, tipo, feature?, taskKey?}]); publica em lote, numa branch e um PR só"
|
|
158
|
+
)
|
|
159
|
+
.option("--slug <chave>", "Nome da branch/commit do lote (ex.: a chave da entrega); só com --manifest")
|
|
160
|
+
.option(
|
|
161
|
+
"--force",
|
|
162
|
+
"Só com --manifest: publica e já finaliza (apaga os originais), sem --archive — zero reversão (Q15, #220)"
|
|
163
|
+
)
|
|
164
|
+
.option(
|
|
165
|
+
"--tipo <tipo>",
|
|
166
|
+
"feature|delivery|product|history|prd|frd|feat|epic|story|task|ard|rfc|spec|swagger|qa-report|discovery"
|
|
149
167
|
)
|
|
150
|
-
.option("--file <path>", "Caminho do arquivo local")
|
|
151
|
-
.option("--tipo <tipo>", "feature|delivery (consolidação do /eng.spec-consolidate)")
|
|
152
168
|
.option("--produto <produto>", "Pasta do produto no Central docs (padrão: WORKSPACE do ENV.md)")
|
|
153
|
-
.option(
|
|
169
|
+
.option(
|
|
170
|
+
"--feature <slug>",
|
|
171
|
+
"Funcionalidade: opcional para feature (se o arquivo seguir feature-{slug}.md); obrigatório para delivery e para os documentos de trabalho"
|
|
172
|
+
)
|
|
173
|
+
.option("--task-key <chave>", "Obrigatório para --tipo history (rodadas, comentários, diário)")
|
|
154
174
|
.option("--squad <squad>", "Override do SQUAD do ENV.md")
|
|
155
175
|
.option(
|
|
156
176
|
"--workspace <workspace>",
|
|
@@ -160,6 +180,39 @@ export function buildProgram() {
|
|
|
160
180
|
docsPublish(toLegacyFlags(options))
|
|
161
181
|
);
|
|
162
182
|
|
|
183
|
+
const docsArchiveCmd = cmd(docs, "archive")
|
|
184
|
+
.description(
|
|
185
|
+
"Arquivar os originais já publicados (decisions/), sem apagar nada; reescreve o manifesto com o hash e o destino"
|
|
186
|
+
)
|
|
187
|
+
.option("--manifest <path>", "O mesmo manifesto do jarvis docs publish")
|
|
188
|
+
.option("--squad <squad>", "Override do SQUAD do ENV.md")
|
|
189
|
+
.option("--produto <produto>", "Override do WORKSPACE do ENV.md");
|
|
190
|
+
withEnvOptions(withLogOptions(docsArchiveCmd)).action((options) =>
|
|
191
|
+
docsArchive(toLegacyFlags(options))
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
const docsFinalizeCmd = cmd(docs, "finalize")
|
|
195
|
+
.description(
|
|
196
|
+
"Apagar os originais já arquivados (--archive antes); irreversível, só os que não mudaram desde então"
|
|
197
|
+
)
|
|
198
|
+
.option("--manifest <path>", "O manifesto já arquivado com --archive")
|
|
199
|
+
.option("--squad <squad>", "Override do SQUAD do ENV.md")
|
|
200
|
+
.option("--produto <produto>", "Override do WORKSPACE do ENV.md")
|
|
201
|
+
.option("--workspace <workspace>", "Mesmo efeito de --produto");
|
|
202
|
+
withEnvOptions(withLogOptions(docsFinalizeCmd)).action((options) =>
|
|
203
|
+
docsFinalize(toLegacyFlags(options))
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
const docsMigrateCmd = cmd(docs, "migrate")
|
|
207
|
+
.description(
|
|
208
|
+
"Migrar o Central docs do layout antigo para a estrutura por funcionalidade (dry-run por padrão)"
|
|
209
|
+
)
|
|
210
|
+
.option("--apply", "Aplica o plano (padrão: só mostra, sem alterar nada)")
|
|
211
|
+
.option("--squad <squad>", "Override do SQUAD do ENV.md");
|
|
212
|
+
withEnvOptions(withLogOptions(docsMigrateCmd)).action((options) =>
|
|
213
|
+
docsMigrate(toLegacyFlags(options))
|
|
214
|
+
);
|
|
215
|
+
|
|
163
216
|
const installRtkCmd = cmd(program, "install-rtk").description(
|
|
164
217
|
"Instalar RTK (token killer — economia 60-90% em tokens de shell)"
|
|
165
218
|
);
|
|
@@ -178,6 +231,14 @@ export function buildProgram() {
|
|
|
178
231
|
.option("--env-file <path>")
|
|
179
232
|
.action((options) => tokens(toLegacyFlags(options)));
|
|
180
233
|
|
|
234
|
+
const rules = cmd(program, "rules").description("Rules da pasta da IDE");
|
|
235
|
+
const rulesSyncCmd = cmd(rules, "sync").description(
|
|
236
|
+
"Filtrar rules/ e rules-on-demand/ da IDE pelo perfil do ENV.md (Passo 8 do /jarvis-init)"
|
|
237
|
+
);
|
|
238
|
+
withEnvOptions(withLogOptions(rulesSyncCmd)).action((options) =>
|
|
239
|
+
rulesSync(toLegacyFlags(options))
|
|
240
|
+
);
|
|
241
|
+
|
|
181
242
|
cmd(program, "fork")
|
|
182
243
|
.description(
|
|
183
244
|
"Overlay de empresa: copia um artefato do core para $IDE/overlays/{COMPANY_PROFILE}/, com carimbo"
|
|
@@ -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>}
|
|
@@ -163,7 +222,7 @@ export const OPENCODE_MODEL_MAP = Object.freeze({
|
|
|
163
222
|
// Anthropic — IDs completos
|
|
164
223
|
"claude-opus-4-6-20250529": "anthropic/claude-opus-4-6",
|
|
165
224
|
"claude-sonnet-4-6-20250514": "anthropic/claude-sonnet-4-6",
|
|
166
|
-
"claude-sonnet-
|
|
225
|
+
"claude-sonnet-5": "anthropic/claude-sonnet-4-6",
|
|
167
226
|
"claude-haiku-4-5-20250414": "anthropic/claude-haiku-4-5-20250414",
|
|
168
227
|
// OpenAI
|
|
169
228
|
"gpt-4o": "openai/gpt-4o",
|
|
@@ -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
|
|
@@ -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 },
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
// Upgrade do ENV.md (`jarvis init --upgrade`): acrescenta as chaves do template que faltam.
|
|
2
2
|
// Regra: só acrescenta. Nenhuma chave existente muda, preenchida, vazia ou com lista de opções.
|
|
3
|
-
//
|
|
3
|
+
// Exceções declaradas (automáticas): `JARVIS_PROJECT=` vazio recebe o valor oficial do template, e
|
|
4
|
+
// as chaves de REMOVED_KEYS (blocos que saíram do template, #209) são apagadas, sem ler o valor.
|
|
4
5
|
// As outras exceções (CENTRAL_DOCS_LOCATION e esvaziar o TOKEN_TASK_MANAGER) pedem confirmação
|
|
5
|
-
// e ficam no Upgrade (C) do skill jarvis-init (item
|
|
6
|
-
import { readFileSync, writeFileSync } from "node:fs";
|
|
6
|
+
// e ficam no Upgrade (C) do skill jarvis-init (item 8). Mesmas regras dos itens 3, 4, 8, 9 e 10.
|
|
7
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
8
|
+
import { join } from "node:path";
|
|
7
9
|
import { detectWorkspaceMode } from "./workspace-mode.js";
|
|
8
10
|
import { getVendor } from "../integrations/cli-runner.js";
|
|
11
|
+
import { resolveLocation } from "../docs/storage/index.js";
|
|
9
12
|
|
|
10
13
|
const KEY_LINE = /^([A-Z][A-Z0-9_]*)=(.*)$/;
|
|
11
14
|
|
|
@@ -31,11 +34,55 @@ function isOptionList(value) {
|
|
|
31
34
|
return /^\[.*\]$/.test(value);
|
|
32
35
|
}
|
|
33
36
|
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
// Blocos que saíram do template (#209): o upgrade apaga as chaves e, quando o bloco fica vazio,
|
|
38
|
+
// a moldura dele. Os comentários são os do template na época; moldura diferente fica.
|
|
39
|
+
const REMOVED_BLOCKS = Object.freeze([
|
|
40
|
+
{
|
|
41
|
+
title: "Mensageria (opcional)",
|
|
42
|
+
keys: ["MESSAGE_BROKER", "MESSAGE_BROKER_URL_API", "MESSAGE_BROKER_API_AUTH"],
|
|
43
|
+
comments: [],
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
title: "Banco de dados (opcional)",
|
|
47
|
+
keys: ["DATABASE", "USER_DATABASE", "PASSWORD_DATABASE", "HOST_DATABASE", "PORT_DATABASE"],
|
|
48
|
+
comments: [],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
title: "Observabilidade (opcional)",
|
|
52
|
+
keys: ["OBSERVABILITY", "TOKEN_OBSERVABILITY", "OBSERVABILITY_ORG"],
|
|
53
|
+
comments: [],
|
|
54
|
+
},
|
|
55
|
+
{ title: "SMTP (opcional)", keys: ["SMTP"], comments: [] },
|
|
56
|
+
{
|
|
57
|
+
title: "Data Engineering (só se HUB=DATA)",
|
|
58
|
+
keys: [
|
|
59
|
+
"DATA_ORCHESTRATOR",
|
|
60
|
+
"DATA_ETL_TOOL",
|
|
61
|
+
"DATA_QUALITY_TOOL",
|
|
62
|
+
"DATA_LAKE",
|
|
63
|
+
"DATA_QUERY_ENGINE",
|
|
64
|
+
"DATA_BI_TOOL",
|
|
65
|
+
"DATA_WAREHOUSE",
|
|
66
|
+
"DATA_REPO",
|
|
67
|
+
],
|
|
68
|
+
comments: [
|
|
69
|
+
"# Obrigatório quando HUB=DATA. Omitir o bloco inteiro se o HUB for outro.",
|
|
70
|
+
"# Vazio se não houver warehouse dedicado.",
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
title: "Code quality (opcional)",
|
|
75
|
+
keys: ["CODE_QUALITY_TOOL", "CODE_QUALITY_URL", "CODE_QUALITY_TOKEN"],
|
|
76
|
+
comments: [
|
|
77
|
+
"# Análise estática / quality gate. Em branco = sem MCP de code quality.",
|
|
78
|
+
"# URL da instância (self-hosted).",
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
]);
|
|
82
|
+
|
|
83
|
+
export const REMOVED_KEYS = Object.freeze(REMOVED_BLOCKS.flatMap((b) => b.keys));
|
|
84
|
+
|
|
85
|
+
const SEPARATOR = /^#\s*=+\s*$/;
|
|
39
86
|
|
|
40
87
|
// Chave existente e vazia que o upgrade preenche com o valor do template (exceção automática).
|
|
41
88
|
const FILL_WHEN_EMPTY = ["JARVIS_PROJECT"];
|
|
@@ -48,15 +95,15 @@ const AXES = ["TASK_MANAGER", "VERSION_CONTROL"];
|
|
|
48
95
|
* @param {string} envText
|
|
49
96
|
* @param {string} templateText
|
|
50
97
|
* @param {{ workspaceDir?: string }} [options] - `workspaceDir`: pasta que contém o `$IDE/`, para detectar o `WORKSPACE_MODE`
|
|
51
|
-
* @returns {{ added: {key: string, value: string}[], filled: {key: string, value: string}[], pending: string[], warnings: string[] }}
|
|
98
|
+
* @returns {{ added: {key: string, value: string}[], filled: {key: string, value: string}[], removed: string[], pending: string[], warnings: string[] }}
|
|
52
99
|
* `filled`: chaves existentes e vazias preenchidas com o valor do template (só `JARVIS_PROJECT`).
|
|
100
|
+
* `removed`: chaves de REMOVED_KEYS presentes no ENV, que o upgrade apaga (só nomes).
|
|
53
101
|
* `pending` e `warnings` trazem só nomes de chave, nunca valores do ENV
|
|
54
102
|
* (exceto o nome do vendor não suportado, em `UNSUPPORTED:{CHAVE}:{vendor}`).
|
|
55
103
|
*/
|
|
56
104
|
export function planEnvUpgrade(envText, templateText, { workspaceDir } = {}) {
|
|
57
105
|
const env = parseEnvEntries(envText);
|
|
58
106
|
const template = parseEnvEntries(templateText);
|
|
59
|
-
const hub = (env.get("HUB") || "").toUpperCase();
|
|
60
107
|
const area = (env.get("AREA") || "").toUpperCase();
|
|
61
108
|
|
|
62
109
|
const added = [];
|
|
@@ -65,8 +112,7 @@ export function planEnvUpgrade(envText, templateText, { workspaceDir } = {}) {
|
|
|
65
112
|
const warnings = [];
|
|
66
113
|
|
|
67
114
|
for (const [key, templateValue] of template) {
|
|
68
|
-
if (env.has(key)) continue;
|
|
69
|
-
if (hub !== "DATA" && isDataOnlyKey(key)) continue;
|
|
115
|
+
if (env.has(key) || REMOVED_KEYS.includes(key)) continue;
|
|
70
116
|
|
|
71
117
|
let value = isOptionList(templateValue) ? "" : templateValue;
|
|
72
118
|
if (key === "PROD_MODE") {
|
|
@@ -87,6 +133,8 @@ export function planEnvUpgrade(envText, templateText, { workspaceDir } = {}) {
|
|
|
87
133
|
|
|
88
134
|
if (env.has("PROD_MODE") && !env.get("PROD_MODE")) pending.push("PROD_MODE");
|
|
89
135
|
|
|
136
|
+
const removed = [...env.keys()].filter((key) => REMOVED_KEYS.includes(key));
|
|
137
|
+
|
|
90
138
|
for (const key of FILL_WHEN_EMPTY) {
|
|
91
139
|
const value = template.get(key);
|
|
92
140
|
if (env.has(key) && !env.get(key) && value && !isOptionList(value)) filled.push({ key, value });
|
|
@@ -106,22 +154,90 @@ export function planEnvUpgrade(envText, templateText, { workspaceDir } = {}) {
|
|
|
106
154
|
warnings.push("CENTRAL_DOCS_REPO");
|
|
107
155
|
}
|
|
108
156
|
|
|
109
|
-
|
|
157
|
+
// Central docs ainda no layout por tipo (product/engineering), anterior à estrutura por
|
|
158
|
+
// funcionalidade (#220): a migração (`jarvis docs migrate`) é oferecida pelo Upgrade (C).
|
|
159
|
+
if (
|
|
160
|
+
workspaceDir &&
|
|
161
|
+
(env.get("CENTRAL_DOCS_STORAGE") || "").trim().toLowerCase() === "filesystem" &&
|
|
162
|
+
env.get("CENTRAL_DOCS_LOCATION") &&
|
|
163
|
+
env.get("SQUAD")
|
|
164
|
+
) {
|
|
165
|
+
const root = resolveLocation(env.get("CENTRAL_DOCS_LOCATION"), workspaceDir);
|
|
166
|
+
const squadDir = join(root, env.get("SQUAD"));
|
|
167
|
+
if (existsSync(join(squadDir, "product")) || existsSync(join(squadDir, "engineering"))) {
|
|
168
|
+
warnings.push("CENTRAL_DOCS_LAYOUT");
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return { added, filled, removed, pending, warnings };
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Apaga do texto do ENV as linhas das chaves pedidas e, nos blocos de REMOVED_BLOCKS que ficaram
|
|
177
|
+
* vazios, a moldura (separador, título, separador), os comentários do template e as linhas em
|
|
178
|
+
* branco logo depois (no fim do arquivo, também as de antes). Moldura com outra coisa dentro
|
|
179
|
+
* (chave ou comentário próprio) fica. Nunca lê o valor das chaves: casa só o nome antes do `=`.
|
|
180
|
+
* @param {string} text
|
|
181
|
+
* @param {string[]} keys
|
|
182
|
+
* @returns {{ text: string, removed: string[] }} `removed`: as chaves que de fato saíram
|
|
183
|
+
*/
|
|
184
|
+
export function removeEnvKeys(text, keys) {
|
|
185
|
+
const wanted = new Set(keys);
|
|
186
|
+
const removed = [];
|
|
187
|
+
let lines = text.split("\n").filter((line) => {
|
|
188
|
+
const m = line.match(/^\s*([A-Z][A-Z0-9_]*)=/);
|
|
189
|
+
if (!m || !wanted.has(m[1])) return true;
|
|
190
|
+
if (!removed.includes(m[1])) removed.push(m[1]);
|
|
191
|
+
return false;
|
|
192
|
+
});
|
|
193
|
+
if (removed.length === 0) return { text, removed };
|
|
194
|
+
|
|
195
|
+
const bare = (line) => line.replace(/\r$/, "").trim();
|
|
196
|
+
// Só os blocos de onde saiu alguma chave: moldura vazia de outro bloco é escolha da pessoa.
|
|
197
|
+
for (const block of REMOVED_BLOCKS.filter((b) => b.keys.some((k) => removed.includes(k)))) {
|
|
198
|
+
const i = lines.findIndex(
|
|
199
|
+
(line, n) =>
|
|
200
|
+
bare(line) === `# ${block.title}` &&
|
|
201
|
+
SEPARATOR.test(bare(lines[n - 1] ?? "")) &&
|
|
202
|
+
SEPARATOR.test(bare(lines[n + 1] ?? ""))
|
|
203
|
+
);
|
|
204
|
+
if (i < 0) continue;
|
|
205
|
+
let j = i + 2;
|
|
206
|
+
while (j < lines.length && (bare(lines[j]) === "" || block.comments.includes(bare(lines[j])))) {
|
|
207
|
+
j++;
|
|
208
|
+
}
|
|
209
|
+
if (j < lines.length && !SEPARATOR.test(bare(lines[j]))) continue;
|
|
210
|
+
if (j < lines.length) {
|
|
211
|
+
lines = [...lines.slice(0, i - 1), ...lines.slice(j)];
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
// Bloco no fim do arquivo: tira também as linhas em branco antes dele e termina numa quebra só.
|
|
215
|
+
let end = i - 1;
|
|
216
|
+
while (end > 0 && bare(lines[end - 1]) === "") end--;
|
|
217
|
+
lines = [...lines.slice(0, end), ""];
|
|
218
|
+
}
|
|
219
|
+
return { text: lines.join("\n"), removed };
|
|
110
220
|
}
|
|
111
221
|
|
|
112
222
|
/**
|
|
113
|
-
* Grava as chaves novas no fim do ENV, num bloco datado,
|
|
114
|
-
* (linha `CHAVE=` vazia). Nenhuma outra linha
|
|
223
|
+
* Grava as chaves novas no fim do ENV, num bloco datado, preenche as chaves de `plan.filled`
|
|
224
|
+
* (linha `CHAVE=` vazia) e apaga as de `plan.removed` (`removeEnvKeys`). Nenhuma outra linha muda.
|
|
115
225
|
* `overrides` troca o valor de chaves novas (ex.: recusa em mover os discoveries).
|
|
116
226
|
* @returns {boolean} true se gravou
|
|
117
227
|
*/
|
|
118
228
|
export function applyEnvUpgrade(envPath, plan, today, overrides = {}) {
|
|
119
229
|
const filled = plan.filled || [];
|
|
120
|
-
|
|
230
|
+
const toRemove = plan.removed || [];
|
|
231
|
+
if (plan.added.length === 0 && filled.length === 0 && toRemove.length === 0) {
|
|
121
232
|
plan.filledApplied = [];
|
|
233
|
+
plan.removedApplied = [];
|
|
122
234
|
return false;
|
|
123
235
|
}
|
|
124
236
|
let text = readFileSync(envPath, "utf-8");
|
|
237
|
+
// `plan.removedApplied`: só as chaves que de fato saíram (para o resumo não mentir).
|
|
238
|
+
const removal = removeEnvKeys(text, toRemove);
|
|
239
|
+
text = removal.text;
|
|
240
|
+
plan.removedApplied = removal.removed;
|
|
125
241
|
// `plan.filledApplied`: só as chaves que de fato mudaram (para o resumo não mentir).
|
|
126
242
|
plan.filledApplied = [];
|
|
127
243
|
for (const { key, value } of filled) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Filtro de rules por perfil (bloco "Applies to").
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* `skills/jarvis-init/
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Usado por `jarvis tokens` e `jarvis rules sync` (Passo 8 do `/jarvis-init`). O fallback em
|
|
5
|
+
* prosa, para quando o CLI não está disponível, é `skills/jarvis-init/assets/rules-sync-manual.md`:
|
|
6
|
+
* ao mudar a lógica aqui, mude lá também. A documentação de autoria (hierarquia, convenções,
|
|
7
|
+
* estrutura de regra) vive em `docs/estrutura/rules.md`.
|
|
8
8
|
*
|
|
9
9
|
* Regras:
|
|
10
10
|
* - Os eixos (HUB, POSITION, AREA, SQUAD e o opcional ARTIFACT_STYLE) são combinados com AND.
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
* - FULLCYCLE (HUB) satisfaz qualquer HUB.
|
|
15
15
|
* - GENERALIST (POSITION) satisfaz qualquer POSITION e qualquer AREA.
|
|
16
16
|
* - Arquivo sem bloco "Applies to" é universal.
|
|
17
|
-
* - `rules/AGENTS.md` nunca é filtrado.
|
|
18
17
|
* - `rtk-rules.md` só entra com RTK habilitado (opt-in).
|
|
19
18
|
* @module core/profile-filter
|
|
20
19
|
*/
|
|
@@ -115,10 +114,6 @@ export function listRulesForProfile(rulesDir, profile, opts = {}) {
|
|
|
115
114
|
const content = readFileSync(file, "utf-8");
|
|
116
115
|
const bytes = Buffer.byteLength(content, "utf-8");
|
|
117
116
|
|
|
118
|
-
if (rel === "AGENTS.md") {
|
|
119
|
-
result.push({ path: rel, bytes });
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
117
|
if (rel.endsWith("rtk-rules.md") && !opts.rtkEnabled) continue;
|
|
123
118
|
if (matchesProfile(parseAppliesTo(content), profile)) {
|
|
124
119
|
result.push({ path: rel, bytes });
|
package/bin/lib/core/scanner.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { getFrameworkRoot } from "../utils/paths.js";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
extractFrontmatterBlock,
|
|
6
|
+
parseFrontmatter,
|
|
7
|
+
readDescription,
|
|
8
|
+
} from "../utils/frontmatter.js";
|
|
5
9
|
|
|
6
10
|
function extractDeps(content) {
|
|
7
11
|
const deps = { rules: [], templates: [], skills: [], agents: [] };
|
|
@@ -37,11 +41,12 @@ function scanDir(dir, type) {
|
|
|
37
41
|
if (existsSync(skillFile)) {
|
|
38
42
|
const content = readFileSync(skillFile, "utf-8");
|
|
39
43
|
const fm = parseFrontmatter(content);
|
|
44
|
+
const description = readDescription(extractFrontmatterBlock(content));
|
|
40
45
|
results.push({
|
|
41
46
|
id: fm.name || entry.name,
|
|
42
47
|
type,
|
|
43
48
|
name: fm.name || entry.name,
|
|
44
|
-
description
|
|
49
|
+
description,
|
|
45
50
|
version: fm.version || "1.0.0",
|
|
46
51
|
deps: extractDeps(content),
|
|
47
52
|
path: skillFile,
|
|
@@ -59,13 +64,14 @@ function scanDir(dir, type) {
|
|
|
59
64
|
|
|
60
65
|
const content = readFileSync(fullPath, "utf-8");
|
|
61
66
|
const fm = parseFrontmatter(content);
|
|
67
|
+
const description = readDescription(extractFrontmatterBlock(content));
|
|
62
68
|
const id = entry.name.replace(".md", "");
|
|
63
69
|
|
|
64
70
|
results.push({
|
|
65
71
|
id,
|
|
66
72
|
type,
|
|
67
|
-
name:
|
|
68
|
-
description
|
|
73
|
+
name: description || id,
|
|
74
|
+
description,
|
|
69
75
|
model: fm.model || fm.recommended_model || "",
|
|
70
76
|
version: fm.version || "1.0.0",
|
|
71
77
|
deps: extractDeps(content),
|