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,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Migra o Central docs do layout antigo (`{squad}/product/{produto}/feature-*.md`,
|
|
3
|
+
* `{squad}/engineering/{produto}/delivery-*.md`) para a estrutura por funcionalidade
|
|
4
|
+
* (`{squad}/{produto}/{funcionalidade}/…`, Q2 e Q6 da #220). Só move e reorganiza: **nunca**
|
|
5
|
+
* reescreve conteúdo. `planCentralMigration` é puro (não toca em nada, é o que roda por padrão,
|
|
6
|
+
* dry-run); `applyCentralMigration` guarda uma cópia de cada arquivo antes de mover (Q6: a
|
|
7
|
+
* migração deixa rastro, mesmo sem git no Central docs) e nunca sobrescreve um destino que já
|
|
8
|
+
* exista. Entrega citada por mais de um `feature-*.md` (Q9) não é movida: entra em `needsSplit`,
|
|
9
|
+
* para o `/jarvis-init` acionar o agente (Q17, Q21).
|
|
10
|
+
* @module docs/migrate-central
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
existsSync,
|
|
15
|
+
readdirSync,
|
|
16
|
+
statSync,
|
|
17
|
+
mkdirSync,
|
|
18
|
+
renameSync,
|
|
19
|
+
readFileSync,
|
|
20
|
+
cpSync,
|
|
21
|
+
rmdirSync,
|
|
22
|
+
appendFileSync,
|
|
23
|
+
writeFileSync,
|
|
24
|
+
} from "node:fs";
|
|
25
|
+
import { dirname, join, relative } from "node:path";
|
|
26
|
+
import { parseFrontmatter } from "../utils/frontmatter.js";
|
|
27
|
+
|
|
28
|
+
function listDirs(dir) {
|
|
29
|
+
if (!existsSync(dir)) return [];
|
|
30
|
+
return readdirSync(dir)
|
|
31
|
+
.filter((name) => statSync(join(dir, name)).isDirectory())
|
|
32
|
+
.sort();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function listFiles(dir) {
|
|
36
|
+
if (!existsSync(dir)) return [];
|
|
37
|
+
return readdirSync(dir)
|
|
38
|
+
.filter((name) => statSync(join(dir, name)).isFile())
|
|
39
|
+
.sort();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function slugOfFeatureFile(name) {
|
|
43
|
+
if (!name.startsWith("feature-") || !name.endsWith(".md") || name.endsWith(".public.md")) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
return name.slice("feature-".length, name.length - ".md".length);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Calcula o plano de migração de um squad. Não lê nem escreve fora da pasta do Central docs,
|
|
51
|
+
* e não altera nada (dry-run).
|
|
52
|
+
*
|
|
53
|
+
* @param {string} root - Pasta do Central docs
|
|
54
|
+
* @param {string} squad
|
|
55
|
+
* @returns {{
|
|
56
|
+
* moves: Array<{from: string, to: string, kind: "feature"|"delivery", produto: string, feature: string}>,
|
|
57
|
+
* needsSplit: Array<{from: string, produto: string, delivery: string, features: string[]}>,
|
|
58
|
+
* skipped: Array<{from: string, reason: "conflito"|"sem funcionalidade"}>,
|
|
59
|
+
* }}
|
|
60
|
+
*/
|
|
61
|
+
export function planCentralMigration(root, squad) {
|
|
62
|
+
const squadDir = join(root, squad);
|
|
63
|
+
const productDir = join(squadDir, "product");
|
|
64
|
+
const engineeringDir = join(squadDir, "engineering");
|
|
65
|
+
|
|
66
|
+
const moves = [];
|
|
67
|
+
const skipped = [];
|
|
68
|
+
const needsSplit = [];
|
|
69
|
+
// "delivery-x.md" -> Set<"{produto}::{slug}"> — o produto junto do slug (#220 item 10):
|
|
70
|
+
// sem isso, uma entrega ia para o produto da pasta engineering/, que pode não ser o produto
|
|
71
|
+
// onde a funcionalidade dona de fato está em product/.
|
|
72
|
+
const ownersByDelivery = new Map();
|
|
73
|
+
|
|
74
|
+
for (const produto of listDirs(productDir)) {
|
|
75
|
+
for (const file of listFiles(join(productDir, produto))) {
|
|
76
|
+
const slug = slugOfFeatureFile(file);
|
|
77
|
+
if (!slug) continue;
|
|
78
|
+
|
|
79
|
+
const from = `${squad}/product/${produto}/${file}`;
|
|
80
|
+
const to = `${squad}/${produto}/${slug}/${slug}.md`;
|
|
81
|
+
if (existsSync(join(root, to))) {
|
|
82
|
+
skipped.push({ from, reason: "conflito" });
|
|
83
|
+
} else {
|
|
84
|
+
moves.push({ from, to, kind: "feature", produto, feature: slug });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Vínculo entrega → funcionalidade: last_delivery e as citações de delivery-*.md no
|
|
88
|
+
// corpo (ex.: a tabela "Histórico de entregas"). A mesma entrega citada por mais de uma
|
|
89
|
+
// funcionalidade entra em needsSplit (Q9) — ela não é movida automaticamente.
|
|
90
|
+
const content = readFileSync(join(productDir, produto, file), "utf-8");
|
|
91
|
+
const meta = parseFrontmatter(content);
|
|
92
|
+
const cited = new Set();
|
|
93
|
+
if (meta.last_delivery) cited.add(meta.last_delivery.trim());
|
|
94
|
+
for (const m of content.matchAll(/delivery-[\w.-]+\.md/g)) cited.add(m[0]);
|
|
95
|
+
for (const name of cited) {
|
|
96
|
+
if (!ownersByDelivery.has(name)) ownersByDelivery.set(name, new Set());
|
|
97
|
+
ownersByDelivery.get(name).add(`${produto}::${slug}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
for (const produtoEngenharia of listDirs(engineeringDir)) {
|
|
103
|
+
for (const file of listFiles(join(engineeringDir, produtoEngenharia))) {
|
|
104
|
+
if (!file.startsWith("delivery-") || !file.endsWith(".md") || file.endsWith(".public.md")) {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
const from = `${squad}/engineering/${produtoEngenharia}/${file}`;
|
|
108
|
+
const owners = [...(ownersByDelivery.get(file) || [])].sort();
|
|
109
|
+
|
|
110
|
+
if (owners.length === 0) {
|
|
111
|
+
skipped.push({ from, reason: "sem funcionalidade" });
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (owners.length > 1) {
|
|
115
|
+
needsSplit.push({
|
|
116
|
+
from,
|
|
117
|
+
produto: produtoEngenharia,
|
|
118
|
+
delivery: file,
|
|
119
|
+
features: owners.map((o) => o.split("::")[1]),
|
|
120
|
+
});
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// O produto é o da funcionalidade dona (de product/), não o da pasta engineering/ onde
|
|
125
|
+
// a entrega estava: os dois podem divergir (#220 item 10).
|
|
126
|
+
const [produtoDaFeature, slugDaFeature] = owners[0].split("::");
|
|
127
|
+
const to = `${squad}/${produtoDaFeature}/${slugDaFeature}/deliveries/${file}`;
|
|
128
|
+
if (existsSync(join(root, to))) {
|
|
129
|
+
skipped.push({ from, reason: "conflito" });
|
|
130
|
+
} else {
|
|
131
|
+
moves.push({ from, to, kind: "delivery", produto: produtoDaFeature, feature: slugDaFeature });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return { moves, needsSplit, skipped };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Remove `dir` se estiver vazio, depois o pai, subindo até (sem incluir) `stopAt`. Usado para
|
|
141
|
+
* não deixar `product/{produto}/` e `engineering/{produto}/` (e as pastas `product`/`engineering`
|
|
142
|
+
* do squad) vazias depois da migração — senão poluem o índice e o aviso `CENTRAL_DOCS_LAYOUT`
|
|
143
|
+
* do Upgrade continua disparando mesmo com a migração completa (#220 item 9).
|
|
144
|
+
* @param {string} dir
|
|
145
|
+
* @param {string} stopAt - Pasta onde parar (exclusive); nunca removida
|
|
146
|
+
*/
|
|
147
|
+
function removeEmptyDirsUpward(dir, stopAt) {
|
|
148
|
+
let current = dir;
|
|
149
|
+
while (true) {
|
|
150
|
+
const rel = relative(stopAt, current);
|
|
151
|
+
if (rel === "" || rel.startsWith("..")) break; // chegou em stopAt ou saiu dela
|
|
152
|
+
if (!existsSync(current)) break;
|
|
153
|
+
try {
|
|
154
|
+
if (readdirSync(current).length > 0) break;
|
|
155
|
+
rmdirSync(current);
|
|
156
|
+
} catch {
|
|
157
|
+
break; // não vazia por uma corrida, ou sem permissão: deixa como está
|
|
158
|
+
}
|
|
159
|
+
current = dirname(current);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Garante `.migration-backup/` no `.gitignore` do Central docs (#220 item 7): a cópia de
|
|
165
|
+
* segurança não é um documento publicado, e com `.git` ela não deveria entrar nos commits da
|
|
166
|
+
* migração.
|
|
167
|
+
* @param {string} root
|
|
168
|
+
*/
|
|
169
|
+
function ensureBackupIgnored(root) {
|
|
170
|
+
const gitignore = join(root, ".gitignore");
|
|
171
|
+
const line = ".migration-backup/";
|
|
172
|
+
if (!existsSync(gitignore)) {
|
|
173
|
+
writeFileSync(gitignore, `${line}\n`);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const content = readFileSync(gitignore, "utf-8");
|
|
177
|
+
if (!content.split("\n").some((l) => l.trim() === line)) {
|
|
178
|
+
appendFileSync(gitignore, `${content.endsWith("\n") || content === "" ? "" : "\n"}${line}\n`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Aplica o plano: guarda uma cópia de cada arquivo em `{root}/.migration-backup/{timestamp}/`
|
|
184
|
+
* antes de mover (Q6), e move com `rename` (o Central docs pode não ser um repositório git —
|
|
185
|
+
* Q14). Não sobrescreve: um destino já existente foi marcado `skipped` pelo plano e não chega
|
|
186
|
+
* aqui com `moves`. Remove as pastas de origem (`product/{produto}`, `engineering/{produto}`,
|
|
187
|
+
* e `product`/`engineering` do squad) que ficarem vazias (#220 item 9).
|
|
188
|
+
*
|
|
189
|
+
* @param {string} root - Pasta do Central docs
|
|
190
|
+
* @param {{moves: Array<{from: string, to: string}>}} plan - De `planCentralMigration`
|
|
191
|
+
* @param {string} [timestamp] - Para o nome da pasta de backup (testável); padrão: agora
|
|
192
|
+
* @returns {{moved: Array, backupDir: string, errors: string[]}}
|
|
193
|
+
*/
|
|
194
|
+
export function applyCentralMigration(root, plan, timestamp = new Date().toISOString().replace(/[:.]/g, "-")) {
|
|
195
|
+
const backupDir = join(root, ".migration-backup", timestamp);
|
|
196
|
+
const moved = [];
|
|
197
|
+
const errors = [];
|
|
198
|
+
const emptiedCandidates = new Set();
|
|
199
|
+
|
|
200
|
+
for (const m of plan.moves) {
|
|
201
|
+
const fromAbs = join(root, m.from);
|
|
202
|
+
const toAbs = join(root, m.to);
|
|
203
|
+
try {
|
|
204
|
+
if (existsSync(toAbs)) {
|
|
205
|
+
errors.push(`${m.from}: destino já existe (${m.to}), não sobrescrito`);
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
const backupAbs = join(backupDir, m.from);
|
|
209
|
+
mkdirSync(dirname(backupAbs), { recursive: true });
|
|
210
|
+
cpSync(fromAbs, backupAbs);
|
|
211
|
+
|
|
212
|
+
mkdirSync(dirname(toAbs), { recursive: true });
|
|
213
|
+
renameSync(fromAbs, toAbs);
|
|
214
|
+
moved.push(m);
|
|
215
|
+
emptiedCandidates.add(dirname(fromAbs));
|
|
216
|
+
} catch (err) {
|
|
217
|
+
errors.push(`${m.from}: ${err.message.split("\n")[0]}`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (moved.length > 0) {
|
|
222
|
+
ensureBackupIgnored(root);
|
|
223
|
+
}
|
|
224
|
+
for (const dir of emptiedCandidates) {
|
|
225
|
+
removeEmptyDirsUpward(dir, root);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return { moved, backupDir: relative(root, backupDir), errors };
|
|
229
|
+
}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview Publica no Central docs, pelo adaptador configurado
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* `
|
|
6
|
-
* `
|
|
7
|
-
*
|
|
2
|
+
* @fileoverview Publica no Central docs, pelo adaptador configurado (`CENTRAL_DOCS_STORAGE`),
|
|
3
|
+
* na estrutura por funcionalidade (`{squad}/{produto}/{funcionalidade}/…`, seção 7 do
|
|
4
|
+
* `architecture.md` da #220):
|
|
5
|
+
* - `feature`: a página da funcionalidade (`{funcionalidade}/{funcionalidade}.md`);
|
|
6
|
+
* - `delivery`: o registro de uma entrega (`{funcionalidade}/deliveries/delivery-*.md`);
|
|
7
|
+
* - `product`: a página do produto, o conteúdo transversal a várias funcionalidades (`{produto}.md`);
|
|
8
|
+
* - `history`: rodadas, comentários e diário de uma entrega (`history/{task_key}/…`);
|
|
9
|
+
* - `home`: a página inicial do squad (`{squad}/home.md`), editável — o adaptador cria uma vez
|
|
10
|
+
* e nunca sobrescreve (Q16 da #220);
|
|
11
|
+
* - os tipos de `DECISION_DOC_TYPES` (prd, frd, feat, epic, story, task, ard, rfc, spec, swagger,
|
|
12
|
+
* qa-report, discovery): os documentos de trabalho **ligados a uma entrega consolidada**
|
|
13
|
+
* (`{funcionalidade}/decisions/…`) — quem decide o vínculo é o `/eng.spec-consolidate`, não
|
|
14
|
+
* este módulo.
|
|
15
|
+
* O índice do squad é regenerado a cada publicação.
|
|
8
16
|
* @module docs/publish-file
|
|
9
17
|
*/
|
|
10
18
|
|
|
@@ -12,14 +20,15 @@ import { basename, extname } from "node:path";
|
|
|
12
20
|
import { validateFrontmatter } from "./validate-frontmatter.js";
|
|
13
21
|
import { logger } from "../utils/logger.js";
|
|
14
22
|
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Documentos de trabalho (decisões de origem: PRD, FRD, épico, história, tarefa, ARD, RFC,
|
|
25
|
+
* SPEC, swagger, relatório de QA, discovery). Antes da v4.0.0 todos entravam no Central docs;
|
|
26
|
+
* de 4.0.0 até aqui, nenhum entrava. Agora voltam a entrar, mas só em `decisions/`, e só o que
|
|
27
|
+
* já está ligado a uma entrega consolidada (Q1 da #220) — o que não está ligado fica em
|
|
28
|
+
* `docs/jarvis/`, sem passar por aqui.
|
|
29
|
+
* @constant {ReadonlyArray<string>}
|
|
30
|
+
*/
|
|
31
|
+
export const DECISION_DOC_TYPES = Object.freeze([
|
|
23
32
|
"prd",
|
|
24
33
|
"frd",
|
|
25
34
|
"feat",
|
|
@@ -31,14 +40,30 @@ export const WORKING_DOC_TYPES = Object.freeze([
|
|
|
31
40
|
"spec",
|
|
32
41
|
"swagger",
|
|
33
42
|
"qa-report",
|
|
43
|
+
"discovery",
|
|
34
44
|
]);
|
|
35
45
|
|
|
36
46
|
/** @constant {ReadonlyArray<string>} Tipos aceitos pelo `jarvis docs publish` */
|
|
37
|
-
export const VALID_TYPES = Object.freeze(
|
|
47
|
+
export const VALID_TYPES = Object.freeze([
|
|
48
|
+
"feature",
|
|
49
|
+
"delivery",
|
|
50
|
+
"product",
|
|
51
|
+
"history",
|
|
52
|
+
"home",
|
|
53
|
+
...DECISION_DOC_TYPES,
|
|
54
|
+
]);
|
|
38
55
|
|
|
39
|
-
|
|
56
|
+
/** @constant {RegExp} Formato aceito por squad, produto, feature, slug e task key (exportado para `docs-migrate.js`, #220) */
|
|
57
|
+
export const SEGMENT = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
40
58
|
|
|
41
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Valida um segmento de caminho (squad, produto, feature…) contra `SEGMENT`.
|
|
61
|
+
* Exportado para outros comandos (`docs-migrate.js`) validarem antes de montar caminhos.
|
|
62
|
+
* @param {string} label - Nome do campo, para a mensagem de erro
|
|
63
|
+
* @param {string} value
|
|
64
|
+
* @throws {Error} valor vazio ou fora do formato
|
|
65
|
+
*/
|
|
66
|
+
export function assertSegment(label, value) {
|
|
42
67
|
if (!value || !SEGMENT.test(value)) {
|
|
43
68
|
throw new Error(
|
|
44
69
|
`${label} inválido: "${value ?? ""}" (use letras, números, "-" ou "_", sem "/" nem "..")`
|
|
@@ -47,50 +72,92 @@ function assertSegment(label, value) {
|
|
|
47
72
|
}
|
|
48
73
|
|
|
49
74
|
/**
|
|
50
|
-
* Calcula o destino do documento no Central docs.
|
|
51
|
-
* O nome é o do arquivo local quando ele já segue `{tipo}-…` (ex: `feature-checkout.md`,
|
|
52
|
-
* `delivery-2026-10-15-task-123.md`); senão vem de `--feature` (`{tipo}-{feature}.md`).
|
|
75
|
+
* Calcula o destino do documento no Central docs, pela estrutura por funcionalidade.
|
|
53
76
|
*
|
|
54
77
|
* @param {Object} p
|
|
55
78
|
* @param {string} p.tipo
|
|
56
79
|
* @param {string} p.squad
|
|
57
80
|
* @param {string} p.produto - Padrão: WORKSPACE (o caller resolve)
|
|
58
81
|
* @param {string} p.localFile
|
|
59
|
-
* @param {string} [p.feature]
|
|
60
|
-
*
|
|
82
|
+
* @param {string} [p.feature] - Slug da funcionalidade. Para `feature`, só é preciso quando o
|
|
83
|
+
* nome do arquivo não segue `feature-{slug}.md`. Para `delivery` e para os tipos de
|
|
84
|
+
* `DECISION_DOC_TYPES`, é sempre obrigatório: é a funcionalidade dona da pasta.
|
|
85
|
+
* @param {string} [p.taskKey] - Obrigatório para o tipo `history` (chave da entrega/sessão).
|
|
86
|
+
* @returns {{ destPath: string, area: string, fileName: string }}
|
|
61
87
|
*/
|
|
62
|
-
export function resolveDestPath({ tipo, squad, produto, localFile, feature }) {
|
|
63
|
-
|
|
64
|
-
if (!area && WORKING_DOC_TYPES.includes(tipo)) {
|
|
65
|
-
throw new Error(
|
|
66
|
-
`O Central docs guarda só o que foi implementado: "${tipo}" é um documento de trabalho e fica em docs/jarvis/.\n` +
|
|
67
|
-
"Gere a consolidação com /eng.spec-consolidate (tipos: feature, delivery)."
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
if (!area) {
|
|
88
|
+
export function resolveDestPath({ tipo, squad, produto, localFile, feature, taskKey }) {
|
|
89
|
+
if (!VALID_TYPES.includes(tipo)) {
|
|
71
90
|
throw new Error(`Tipo inválido: ${tipo}\nTipos válidos: ${VALID_TYPES.join(", ")}`);
|
|
72
91
|
}
|
|
73
92
|
assertSegment("Squad", squad);
|
|
93
|
+
|
|
94
|
+
if (tipo === "home") {
|
|
95
|
+
return { destPath: `${squad}/home.md`, area: "home", fileName: "home.md" };
|
|
96
|
+
}
|
|
97
|
+
|
|
74
98
|
assertSegment("Produto", produto);
|
|
75
99
|
|
|
76
100
|
const local = basename(localFile);
|
|
77
101
|
const ext = extname(local).toLowerCase() || ".md";
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
102
|
+
|
|
103
|
+
if (tipo === "product") {
|
|
104
|
+
const fileName = `${produto}.md`;
|
|
105
|
+
return { destPath: `${squad}/${produto}/${fileName}`, area: "product", fileName };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (tipo === "history") {
|
|
109
|
+
if (!taskKey) {
|
|
110
|
+
throw new Error(
|
|
111
|
+
'O tipo "history" precisa de --task-key <chave> (rodadas, comentários e diário da entrega).'
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
assertSegment("Task key", taskKey);
|
|
115
|
+
return {
|
|
116
|
+
destPath: `${squad}/${produto}/history/${taskKey}/${local}`,
|
|
117
|
+
area: "history",
|
|
118
|
+
fileName: local,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (tipo === "feature") {
|
|
123
|
+
const prefix = "feature-";
|
|
124
|
+
const slug =
|
|
125
|
+
feature ||
|
|
126
|
+
(local.toLowerCase().startsWith(prefix) ? local.slice(prefix.length, local.length - extname(local).length) : null);
|
|
127
|
+
if (!slug) {
|
|
128
|
+
throw new Error(
|
|
129
|
+
`O arquivo "${local}" não segue o padrão feature-{slug}.md.\n` +
|
|
130
|
+
"Renomeie o arquivo ou informe --feature <slug>."
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
assertSegment("Feature", slug);
|
|
134
|
+
const fileName = `${slug}${ext}`;
|
|
135
|
+
return { destPath: `${squad}/${produto}/${slug}/${fileName}`, area: "feature", fileName };
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// delivery e os tipos de decisão (DECISION_DOC_TYPES) vivem dentro da funcionalidade dona
|
|
139
|
+
if (!feature) {
|
|
87
140
|
throw new Error(
|
|
88
|
-
|
|
89
|
-
|
|
141
|
+
tipo === "delivery"
|
|
142
|
+
? 'O tipo "delivery" precisa de --feature <slug> (a funcionalidade da entrega).'
|
|
143
|
+
: `O tipo "${tipo}" precisa de --feature <slug> (a funcionalidade a que este documento está ligado).`
|
|
90
144
|
);
|
|
91
145
|
}
|
|
146
|
+
assertSegment("Feature", feature);
|
|
92
147
|
|
|
93
|
-
|
|
148
|
+
if (tipo === "delivery") {
|
|
149
|
+
return {
|
|
150
|
+
destPath: `${squad}/${produto}/${feature}/deliveries/${local}`,
|
|
151
|
+
area: "delivery",
|
|
152
|
+
fileName: local,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return {
|
|
157
|
+
destPath: `${squad}/${produto}/${feature}/decisions/${local}`,
|
|
158
|
+
area: "decision",
|
|
159
|
+
fileName: local,
|
|
160
|
+
};
|
|
94
161
|
}
|
|
95
162
|
|
|
96
163
|
/**
|
|
@@ -101,16 +168,17 @@ export function resolveDestPath({ tipo, squad, produto, localFile, feature }) {
|
|
|
101
168
|
* @param {string} opts.squad
|
|
102
169
|
* @param {string} opts.produto
|
|
103
170
|
* @param {string} [opts.feature]
|
|
171
|
+
* @param {string} [opts.taskKey]
|
|
104
172
|
* @returns {Promise<{ destPath: string, indexPath: string, sha?: string, branch?: string, mr?: Object }>}
|
|
105
173
|
*/
|
|
106
|
-
export async function publishFile({ storage, localFile, tipo, squad, produto, feature }) {
|
|
174
|
+
export async function publishFile({ storage, localFile, tipo, squad, produto, feature, taskKey }) {
|
|
107
175
|
if (!storage) {
|
|
108
176
|
throw new Error(
|
|
109
177
|
"Central docs desligado (CENTRAL_DOCS_STORAGE vazio). Configure-o no /jarvis-init."
|
|
110
178
|
);
|
|
111
179
|
}
|
|
112
180
|
|
|
113
|
-
const { destPath } = resolveDestPath({ tipo, squad, produto, localFile, feature });
|
|
181
|
+
const { destPath } = resolveDestPath({ tipo, squad, produto, localFile, feature, taskKey });
|
|
114
182
|
|
|
115
183
|
logger.info("Validando frontmatter...");
|
|
116
184
|
validateFrontmatter(localFile, tipo);
|
|
@@ -124,7 +192,69 @@ export async function publishFile({ storage, localFile, tipo, squad, produto, fe
|
|
|
124
192
|
|
|
125
193
|
const result = await storage.publish({ localFile, destPath, squad, tipo });
|
|
126
194
|
|
|
127
|
-
|
|
195
|
+
if (result.skipped) {
|
|
196
|
+
logger.info(`ℹ️ ${destPath} já existe e não foi sobrescrito.`);
|
|
197
|
+
} else {
|
|
198
|
+
logger.info(`✅ Publicado em ${destPath}`);
|
|
199
|
+
}
|
|
200
|
+
logger.info(`🗂️ Índice regenerado: ${result.indexPath}`);
|
|
201
|
+
if (result.mr) {
|
|
202
|
+
logger.info(`🔀 Pull/Merge Request: ${result.mr.url}`);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return result;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Publica vários arquivos de uma entrega numa operação só (a listagem "move / fica" do
|
|
210
|
+
* `/eng.spec-consolidate`, #220): uma cópia cada, um índice regenerado no fim e, com `.git`,
|
|
211
|
+
* uma branch e um PR para a entrega inteira — não um por arquivo.
|
|
212
|
+
*
|
|
213
|
+
* @param {Object} opts
|
|
214
|
+
* @param {Object} opts.storage - Adaptador (`getStorage`)
|
|
215
|
+
* @param {string} opts.squad
|
|
216
|
+
* @param {string} opts.produto
|
|
217
|
+
* @param {string} [opts.slug] - Nome da branch/commit (ex.: a chave da entrega)
|
|
218
|
+
* @param {Array<{localFile: string, tipo: string, feature?: string, taskKey?: string}>} opts.files
|
|
219
|
+
* @returns {Promise<{ published: Array<{destPath: string, skipped?: boolean}>, indexPath: string, sha?: string, branch?: string, mr?: Object }>}
|
|
220
|
+
*/
|
|
221
|
+
export async function publishFiles({ storage, squad, produto, slug, files }) {
|
|
222
|
+
if (!storage) {
|
|
223
|
+
throw new Error(
|
|
224
|
+
"Central docs desligado (CENTRAL_DOCS_STORAGE vazio). Configure-o no /jarvis-init."
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
if (!files || files.length === 0) {
|
|
228
|
+
throw new Error("Nenhum arquivo para publicar (manifesto vazio).");
|
|
229
|
+
}
|
|
230
|
+
if (slug) assertSegment("Slug", slug);
|
|
231
|
+
|
|
232
|
+
const resolved = files.map((f) => {
|
|
233
|
+
logger.info(`Validando frontmatter de ${f.localFile}...`);
|
|
234
|
+
validateFrontmatter(f.localFile, f.tipo);
|
|
235
|
+
const { destPath } = resolveDestPath({
|
|
236
|
+
tipo: f.tipo,
|
|
237
|
+
squad,
|
|
238
|
+
produto,
|
|
239
|
+
localFile: f.localFile,
|
|
240
|
+
feature: f.feature,
|
|
241
|
+
taskKey: f.taskKey,
|
|
242
|
+
});
|
|
243
|
+
return { localFile: f.localFile, destPath, tipo: f.tipo };
|
|
244
|
+
});
|
|
245
|
+
logger.info("✅ Frontmatter válido em todos os arquivos");
|
|
246
|
+
|
|
247
|
+
logger.info("");
|
|
248
|
+
logger.info("📋 Resumo da Publicação (lote):");
|
|
249
|
+
logger.info(` Armazenamento: ${storage.kind}${storage.isGit ? " (git)" : ""}`);
|
|
250
|
+
for (const r of resolved) logger.info(` - ${r.destPath}`);
|
|
251
|
+
logger.info("");
|
|
252
|
+
|
|
253
|
+
const result = await storage.publishBatch({ files: resolved, squad, slug });
|
|
254
|
+
|
|
255
|
+
for (const p of result.published) {
|
|
256
|
+
logger.info(p.skipped ? `ℹ️ ${p.destPath} já existe e não foi sobrescrito.` : `✅ Publicado em ${p.destPath}`);
|
|
257
|
+
}
|
|
128
258
|
logger.info(`🗂️ Índice regenerado: ${result.indexPath}`);
|
|
129
259
|
if (result.mr) {
|
|
130
260
|
logger.info(`🔀 Pull/Merge Request: ${result.mr.url}`);
|