jarvis-ai-framework 8.5.0 → 8.7.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 +6 -1
- package/README.md +2 -2
- package/agents/engineering/eng.dev-code-reviewer.md +1 -1
- package/agents/engineering/eng.docs-consolidator.agent.md +21 -8
- package/agents/engineering/eng.docs-writer.md +7 -1
- package/bin/README.md +11 -6
- package/bin/commands/daily-report.js +13 -15
- package/bin/commands/docs-archive.js +91 -0
- package/bin/commands/docs-finalize.js +95 -0
- package/bin/commands/docs-migrate.js +107 -0
- package/bin/commands/docs-publish.js +191 -66
- package/bin/commands/docs-sessions.js +89 -0
- package/bin/commands/docs-sync.js +12 -7
- package/bin/commands/init.js +31 -7
- package/bin/lib/cli/program.js +75 -4
- package/bin/lib/config/constants.js +1 -1
- package/bin/lib/core/docs-migrate.js +9 -26
- package/bin/lib/core/env-paths.js +197 -0
- package/bin/lib/core/env-upgrade.js +28 -1
- package/bin/lib/core/sync-engine.js +1 -1
- package/bin/lib/docs/check-links.js +84 -0
- package/bin/lib/docs/finish-delivery.js +644 -0
- package/bin/lib/docs/migrate-central.js +229 -0
- package/bin/lib/docs/publish-file.js +433 -47
- package/bin/lib/docs/rewrite-links.js +230 -0
- package/bin/lib/docs/scan-files.js +110 -0
- package/bin/lib/docs/session-inventory.js +167 -0
- package/bin/lib/docs/storage/build-index.js +83 -47
- package/bin/lib/docs/storage/filesystem.js +496 -6
- package/bin/lib/docs/storage/index.js +11 -2
- package/bin/lib/docs/validate-frontmatter.js +36 -2
- package/package.json +2 -2
- package/rules/engineering/eng-rules.md +1 -1
- package/rules/engineering/eng.integrations-rules.md +1 -1
- package/rules-on-demand/doc-links-rules.md +13 -13
- package/rules-on-demand/engineering/eng.transitions-rules.md +3 -1
- package/rules-on-demand/product/prod.spec-common-rules.md +7 -6
- package/skills/AGENTS.md +1 -1
- package/skills/eng-global-tech-spec/references/reference-spec.md +1 -1
- package/skills/jarvis-docs-central/README.md +31 -12
- package/skills/jarvis-docs-central/SKILL.md +101 -42
- package/skills/jarvis-init/SKILL.md +17 -16
- package/skills/jarvis-init/assets/exemplo-execucao.md +1 -1
- package/skills/jarvis-init/assets/upgrade.md +8 -3
- package/skills/product-specs-update/SKILL.md +1 -1
- package/templates/AGENTS.md +10 -0
- package/templates/ENV-template.md +14 -9
- package/templates/engineering/PR-template.md +1 -1
- package/templates/engineering/architecture-template.md +8 -8
- 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/central-session-template.md +92 -0
- package/templates/engineering/light-arch-template.md +242 -0
- package/templates/engineering/plan-template.md +2 -2
- package/templates/engineering/tech-spec-template.md +6 -5
- package/workflows/engineering/data/data.contract.md +1 -1
- package/workflows/engineering/data/data.new-pipeline.md +1 -1
- package/workflows/engineering/eng.breakdown-subtasks.md +1 -1
- package/workflows/engineering/eng.build-tech-spec.md +1 -1
- package/workflows/engineering/eng.create-ard-from-code.md +6 -5
- package/workflows/engineering/eng.create-ard.md +5 -4
- package/workflows/engineering/eng.create-rfc.md +6 -6
- package/workflows/engineering/eng.daily-report.md +2 -2
- package/workflows/engineering/eng.docs.md +2 -2
- package/workflows/engineering/eng.light-arch.md +7 -4
- package/workflows/engineering/eng.plan.md +1 -1
- package/workflows/engineering/eng.pr.md +2 -2
- package/workflows/engineering/eng.pre-pr.md +4 -4
- package/workflows/engineering/eng.review.md +1 -1
- package/workflows/engineering/eng.rpa.robot.md +1 -1
- package/workflows/engineering/eng.spec-consolidate.md +188 -48
- package/workflows/engineering/eng.start.md +7 -7
- package/workflows/engineering/eng.work.md +8 -2
- package/workflows/engineering/qa/eng.qa-release-signoff.md +1 -1
- package/workflows/engineering/qa/eng.qa-sprint-planning.md +1 -1
- package/workflows/product/prod.spec.discovery.md +1 -1
|
@@ -1,17 +1,142 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join, resolve } from "node:path";
|
|
2
3
|
import { openStorageFromEnv } from "../lib/docs/fetch-file.js";
|
|
3
|
-
import {
|
|
4
|
+
import { docsFolders, expandEnv } from "../lib/core/docs-migrate.js";
|
|
5
|
+
import { EnvPathError, expandEnvPath } from "../lib/core/env-paths.js";
|
|
6
|
+
import { publishFile, publishFiles, VALID_TYPES } from "../lib/docs/publish-file.js";
|
|
7
|
+
import { forceFinalize, isEntryList } from "../lib/docs/finish-delivery.js";
|
|
4
8
|
import { logger, configureFromFlags } from "../lib/utils/logger.js";
|
|
5
9
|
|
|
10
|
+
function openEnvAndStorage(flags) {
|
|
11
|
+
let env;
|
|
12
|
+
let storage;
|
|
13
|
+
let root;
|
|
14
|
+
try {
|
|
15
|
+
({ env, storage, root } = openStorageFromEnv(flags));
|
|
16
|
+
} catch (error) {
|
|
17
|
+
logger.error("❌ Central docs:", error.message);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
if (!storage) {
|
|
21
|
+
logger.error("❌ Central docs desligado (CENTRAL_DOCS_STORAGE vazio no ENV.md).");
|
|
22
|
+
logger.error(" Configure-o com o /jarvis-init.");
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
return { env, storage, root };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function resolveSquadProduto(flags, env) {
|
|
29
|
+
const squad = flags.squad || env.SQUAD;
|
|
30
|
+
const produto = flags.produto || flags.workspace || env.WORKSPACE;
|
|
31
|
+
if (!squad || !produto) {
|
|
32
|
+
logger.error("❌ SQUAD ou WORKSPACE não definidos");
|
|
33
|
+
logger.error(" Defina no ENV.md ou passe --squad <squad> --produto <produto>");
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
return { squad, produto };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function reportPublishError(error, storage, tipo) {
|
|
40
|
+
if (error instanceof EnvPathError) {
|
|
41
|
+
logger.error("\n❌ Caminho do ENV.md inválido (nada foi publicado)\n");
|
|
42
|
+
logger.error(error.message);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
logger.error("\n❌ Erro ao publicar documento\n");
|
|
46
|
+
logger.error(error.message);
|
|
47
|
+
if (error.message.includes("Campos obrigatórios")) {
|
|
48
|
+
logger.error(`\n💡 Verifique o frontmatter do documento: o tipo ${tipo} exige campos específicos.`);
|
|
49
|
+
}
|
|
50
|
+
if (storage.isGit) {
|
|
51
|
+
logger.error(
|
|
52
|
+
"\n💡 Central docs com git: confira se a pasta está limpa (git status), se você tem permissão de push"
|
|
53
|
+
);
|
|
54
|
+
logger.error(" e se a CLI do host está logada (gh auth login, glab auth login).");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
6
58
|
/**
|
|
7
|
-
*
|
|
59
|
+
* Lê um manifesto `[{file, tipo, feature?, taskKey?, relPath?, fromSession?}, …]` (caminhos
|
|
60
|
+
* relativos à pasta do manifesto). Gerado pelo `/eng.spec-consolidate` a partir da listagem
|
|
61
|
+
* "move / fica" (#220). `relPath` (só `history`) preserva subpastas da sessão; `fromSession`
|
|
62
|
+
* marca o arquivo vindo de uma sessão (#229).
|
|
63
|
+
*/
|
|
64
|
+
function readManifest(path) {
|
|
65
|
+
if (!existsSync(path)) {
|
|
66
|
+
logger.error(`❌ Manifesto não encontrado: ${path}`);
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
let entries;
|
|
70
|
+
try {
|
|
71
|
+
entries = JSON.parse(readFileSync(path, "utf-8"));
|
|
72
|
+
} catch (error) {
|
|
73
|
+
logger.error(`❌ Manifesto inválido (${path}): ${error.message}`);
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
if (!isEntryList(entries) || entries.length === 0) {
|
|
77
|
+
logger.error(`❌ Manifesto vazio ou no formato errado: ${path}`);
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
const base = dirname(path);
|
|
81
|
+
return entries.map(({ file, ...rest }) => ({ ...rest, localFile: join(base, file) }));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Pastas que só existem no disco local de quem escreveu (sessões e `docs/jarvis/`): um link para
|
|
86
|
+
* elas, num documento da sessão, não pode virar URL do repositório (#229).
|
|
87
|
+
* @param {Record<string, string>} env - `loadEnv` (variáveis cruas)
|
|
88
|
+
* @param {string} root - Pasta do workspace
|
|
89
|
+
* @returns {string[]} caminhos absolutos
|
|
90
|
+
*/
|
|
91
|
+
function localOnlyDirs(env, root) {
|
|
92
|
+
const expanded = expandEnv(new Map(Object.entries(env || {})));
|
|
93
|
+
const { jarvis } = docsFolders(expanded);
|
|
94
|
+
const sessions = expandEnvPath(env, "SESSIONS_DIR");
|
|
95
|
+
return [jarvis, ".jarvis", sessions].map((dir) => resolve(root, dir));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Grava no manifesto, por entrada, onde o arquivo foi de fato publicado (`publishedAs`, que
|
|
100
|
+
* pode ser um `-vN`, Q6 da #229) e o hash do conteúdo publicado (`publishedHash`): o
|
|
101
|
+
* `--archive` e o `--finalize` usam o nome certo, e o `--force` confere a cópia antes de apagar a
|
|
102
|
+
* sessão. As entradas em memória (`files`) recebem os mesmos campos, para o `--force` do mesmo
|
|
103
|
+
* processo. Só regrava o JSON cru, sem tocar nos outros campos.
|
|
104
|
+
* @param {string} manifestPath
|
|
105
|
+
* @param {Array<Object>} files - Entradas lidas por `readManifest`
|
|
106
|
+
* @param {Array<{destPath: string, hash?: string}>} published - Na ordem das entradas
|
|
107
|
+
*/
|
|
108
|
+
function recordPublished(manifestPath, files, published) {
|
|
109
|
+
if (!Array.isArray(published) || published.length !== files.length) return;
|
|
110
|
+
const raw = JSON.parse(readFileSync(manifestPath, "utf-8"));
|
|
111
|
+
if (!Array.isArray(raw) || raw.length !== files.length) return;
|
|
112
|
+
published.forEach((p, i) => {
|
|
113
|
+
raw[i].publishedAs = p.destPath;
|
|
114
|
+
files[i].publishedAs = p.destPath;
|
|
115
|
+
if (p.hash) {
|
|
116
|
+
raw[i].publishedHash = p.hash;
|
|
117
|
+
files[i].publishedHash = p.hash;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
writeFileSync(manifestPath, JSON.stringify(raw, null, 2));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Publica no Central docs pelo adaptador configurado.
|
|
8
125
|
* Sem `.git` na pasta: copia e regenera o índice. Com `.git`: branch, commit, push e PR.
|
|
9
126
|
*
|
|
10
127
|
* @param {Object} flags - Flags do comando
|
|
11
|
-
* @param {string} flags.file - Caminho do arquivo local
|
|
12
|
-
* @param {string} flags.tipo - feature
|
|
128
|
+
* @param {string} [flags.file] - Caminho do arquivo local (um só; alternativa ao `--manifest`)
|
|
129
|
+
* @param {string} [flags.tipo] - Ver VALID_TYPES (feature, delivery, product, history e os
|
|
130
|
+
* documentos de trabalho ligados a uma entrega consolidada)
|
|
131
|
+
* @param {string} [flags.manifest] - Caminho de um manifesto JSON com vários arquivos (publicação
|
|
132
|
+
* em lote: uma branch e um PR só, em vez de um por arquivo)
|
|
133
|
+
* @param {string} [flags.slug] - Nome da branch/commit do lote (ex.: a chave da entrega)
|
|
134
|
+
* @param {boolean} [flags.dryRun] - Só com --manifest: simula e mostra o que seria publicado (novo, igual, nova versão), sem gravar nada
|
|
13
135
|
* @param {string} [flags.produto] - Pasta do produto (padrão: WORKSPACE do ENV.md)
|
|
14
|
-
* @param {string} [flags.feature] - Slug
|
|
136
|
+
* @param {string} [flags.feature] - Slug da funcionalidade. Opcional para `feature` quando o
|
|
137
|
+
* nome do arquivo segue `feature-{slug}.md`; obrigatório para `delivery` e para os
|
|
138
|
+
* documentos de trabalho (é a funcionalidade dona da pasta `decisions/`)
|
|
139
|
+
* @param {string} [flags.taskKey] - Obrigatório para `--tipo history`
|
|
15
140
|
* @param {string} [flags.squad] - Override do SQUAD do ENV.md
|
|
16
141
|
* @param {string} [flags.workspace] - Override do WORKSPACE (padrão do --produto)
|
|
17
142
|
* @param {string} flags.envFile - Path customizado do ENV.md
|
|
@@ -19,98 +144,98 @@ import { logger, configureFromFlags } from "../lib/utils/logger.js";
|
|
|
19
144
|
export async function docsPublish(flags = {}) {
|
|
20
145
|
configureFromFlags(flags);
|
|
21
146
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
squad: squadOverride,
|
|
28
|
-
workspace: workspaceOverride,
|
|
29
|
-
} = flags;
|
|
147
|
+
if (flags.manifest) {
|
|
148
|
+
return docsPublishManifest(flags);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const { file, tipo, feature, taskKey } = flags;
|
|
30
152
|
|
|
31
153
|
if (!file || !tipo) {
|
|
32
154
|
logger.error("❌ Parâmetros obrigatórios faltando\n");
|
|
33
155
|
logger.error(
|
|
34
|
-
`Uso: jarvis docs publish --file <path> --tipo <${VALID_TYPES.join("|")}> [--produto <produto>] [--feature <slug>] [--squad <squad>]\n`
|
|
156
|
+
`Uso: jarvis docs publish --file <path> --tipo <${VALID_TYPES.join("|")}> [--produto <produto>] [--feature <slug>] [--task-key <chave>] [--squad <squad>]\n` +
|
|
157
|
+
" ou: jarvis docs publish --manifest <path> [--slug <chave>] (publicação em lote)\n"
|
|
35
158
|
);
|
|
159
|
+
logger.error("Normalmente chamado pelo /eng.spec-consolidate, que gera os arquivos na sessão:");
|
|
160
|
+
logger.error(" jarvis docs publish --file .../consolidation/feature-checkout.md --tipo feature");
|
|
36
161
|
logger.error(
|
|
37
|
-
"
|
|
38
|
-
);
|
|
39
|
-
logger.error(
|
|
40
|
-
" jarvis docs publish --file .jarvis/sessions/eng/task-123/consolidation/delivery-2026-10-15-task-123.md --tipo delivery"
|
|
41
|
-
);
|
|
42
|
-
logger.error(
|
|
43
|
-
" jarvis docs publish --file .jarvis/sessions/eng/task-123/consolidation/feature-checkout.md --tipo feature"
|
|
162
|
+
" jarvis docs publish --file .../consolidation/delivery-2026-10-15-task-123.md --tipo delivery --feature checkout"
|
|
44
163
|
);
|
|
45
164
|
process.exit(1);
|
|
46
165
|
}
|
|
47
166
|
|
|
48
|
-
if (WORKING_DOC_TYPES.includes(tipo)) {
|
|
49
|
-
logger.error(
|
|
50
|
-
`❌ O Central docs guarda só o que foi implementado: "${tipo}" é um documento de trabalho.`
|
|
51
|
-
);
|
|
52
|
-
logger.error(" Ele fica em docs/jarvis/. Gere a consolidação com /eng.spec-consolidate.");
|
|
53
|
-
process.exit(1);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
167
|
if (!VALID_TYPES.includes(tipo)) {
|
|
57
168
|
logger.error(`❌ Tipo inválido: ${tipo}`);
|
|
58
169
|
logger.error(`Tipos válidos: ${VALID_TYPES.join(", ")}`);
|
|
59
170
|
process.exit(1);
|
|
60
171
|
}
|
|
61
|
-
|
|
62
172
|
if (!existsSync(file)) {
|
|
63
173
|
logger.error(`❌ Arquivo não encontrado: ${file}`);
|
|
64
174
|
process.exit(1);
|
|
65
175
|
}
|
|
66
176
|
|
|
67
|
-
|
|
68
|
-
|
|
177
|
+
const { env, storage } = openEnvAndStorage(flags);
|
|
178
|
+
const { squad, produto } = resolveSquadProduto(flags, env);
|
|
179
|
+
|
|
180
|
+
logger.info(`📤 Publicando ${tipo.toUpperCase()} (${file})...\n`);
|
|
181
|
+
|
|
69
182
|
try {
|
|
70
|
-
({
|
|
183
|
+
await publishFile({ storage, localFile: file, tipo, squad, produto, feature, taskKey });
|
|
184
|
+
logger.info("");
|
|
185
|
+
logger.info("✅ Publicação concluída!");
|
|
71
186
|
} catch (error) {
|
|
72
|
-
|
|
187
|
+
reportPublishError(error, storage, tipo);
|
|
73
188
|
process.exit(1);
|
|
74
189
|
}
|
|
190
|
+
}
|
|
75
191
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const squad = squadOverride || env.SQUAD;
|
|
83
|
-
const product = produto || workspaceOverride || env.WORKSPACE;
|
|
84
|
-
|
|
85
|
-
if (!squad || !product) {
|
|
86
|
-
logger.error("❌ SQUAD ou WORKSPACE não definidos");
|
|
87
|
-
logger.error(" Defina no ENV.md ou passe --squad <squad> --produto <produto>");
|
|
88
|
-
process.exit(1);
|
|
89
|
-
}
|
|
192
|
+
async function docsPublishManifest(flags) {
|
|
193
|
+
const files = readManifest(flags.manifest);
|
|
194
|
+
const { env, storage, root } = openEnvAndStorage(flags);
|
|
195
|
+
const { squad, produto } = resolveSquadProduto(flags, env);
|
|
90
196
|
|
|
91
|
-
logger.info(`📤 Publicando ${
|
|
197
|
+
logger.info(`📤 Publicando a consolidação em lote (${files.length} arquivo(s))...\n`);
|
|
92
198
|
|
|
93
199
|
try {
|
|
94
|
-
await
|
|
200
|
+
const result = await publishFiles({
|
|
201
|
+
storage,
|
|
202
|
+
squad,
|
|
203
|
+
produto,
|
|
204
|
+
slug: flags.slug,
|
|
205
|
+
files,
|
|
206
|
+
localOnlyDirs: localOnlyDirs(env, root),
|
|
207
|
+
dryRun: Boolean(flags.dryRun),
|
|
208
|
+
});
|
|
209
|
+
if (result.dryRun) return; // simulação: não grava o manifesto nem finaliza
|
|
210
|
+
recordPublished(flags.manifest, files, result.published);
|
|
95
211
|
logger.info("");
|
|
96
212
|
logger.info("✅ Publicação concluída!");
|
|
97
213
|
} catch (error) {
|
|
98
|
-
|
|
99
|
-
|
|
214
|
+
reportPublishError(error, storage, "lote");
|
|
215
|
+
process.exit(1);
|
|
216
|
+
}
|
|
100
217
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
218
|
+
if (!flags.force) return;
|
|
219
|
+
|
|
220
|
+
// --force (Q15, #220): publica e já apaga os originais, sem --archive. Zero reversão.
|
|
221
|
+
logger.info("\n⚠️ --force: finalizando sem arquivar (zero reversão)...");
|
|
222
|
+
const { finalized, rewritten, errors } = forceFinalize({
|
|
223
|
+
entries: files,
|
|
224
|
+
squad,
|
|
225
|
+
produto,
|
|
226
|
+
env,
|
|
227
|
+
workspaceRoot: root,
|
|
228
|
+
root: storage.location,
|
|
229
|
+
});
|
|
230
|
+
logger.info(`🧹 ${finalized.length} original(is) removido(s) (sem cópia em archive/)`);
|
|
231
|
+
for (const f of finalized) logger.info(` - ${f.originalPath}`);
|
|
232
|
+
if (rewritten.length > 0) {
|
|
233
|
+
logger.info(`🔗 ${rewritten.length} referência(s) (related_*) reescrita(s):`);
|
|
234
|
+
for (const r of rewritten) logger.info(` - ${r}`);
|
|
235
|
+
}
|
|
236
|
+
if (errors.length > 0) {
|
|
237
|
+
logger.error(`⚠️ ${errors.length} erro(s) ao finalizar:`);
|
|
238
|
+
for (const e of errors) logger.error(` - ${e}`);
|
|
114
239
|
process.exit(1);
|
|
115
240
|
}
|
|
116
241
|
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { openStorageFromEnv } from "../lib/docs/fetch-file.js";
|
|
3
|
+
import { inventorySessions } from "../lib/docs/session-inventory.js";
|
|
4
|
+
import { EnvPathError, expandEnvPath } from "../lib/core/env-paths.js";
|
|
5
|
+
import { logger, configureFromFlags } from "../lib/utils/logger.js";
|
|
6
|
+
|
|
7
|
+
const sim = (v) => (v === null ? "?" : v ? "sim" : "não");
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Lista as sessões de engenharia, os arquivos de cada uma e se a entrega já está no Central
|
|
11
|
+
* docs (#229). Só lê: não escreve nada nem consulta a rede. É a base do modo "uma sessão por
|
|
12
|
+
* vez" do `/eng.spec-consolidate` (`--sessao {card}` e `--proxima`).
|
|
13
|
+
*
|
|
14
|
+
* @param {Object} flags - Flags do comando
|
|
15
|
+
* @param {boolean} [flags.json] - Saída em JSON (só os dados, em stdout)
|
|
16
|
+
* @param {boolean} [flags.pendentes] - Só as sessões sem página-índice publicada
|
|
17
|
+
* @param {boolean} [flags.proxima] - Imprime só o card da próxima sessão pendente (stdout)
|
|
18
|
+
* @param {string} [flags.squad] - Override do SQUAD do ENV.md
|
|
19
|
+
* @param {string} [flags.produto] - Override do WORKSPACE do ENV.md (pasta do produto)
|
|
20
|
+
* @param {string} [flags.envFile] - Path customizado do ENV.md
|
|
21
|
+
*/
|
|
22
|
+
export async function docsSessions(flags = {}) {
|
|
23
|
+
configureFromFlags(flags);
|
|
24
|
+
|
|
25
|
+
let env;
|
|
26
|
+
let storage;
|
|
27
|
+
let root;
|
|
28
|
+
try {
|
|
29
|
+
({ env, storage, root } = openStorageFromEnv(flags));
|
|
30
|
+
} catch (error) {
|
|
31
|
+
logger.error("❌ Central docs:", error.message);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let sessionsDir;
|
|
36
|
+
try {
|
|
37
|
+
sessionsDir = resolve(root, expandEnvPath(env, "SESSIONS_DIR"), "eng");
|
|
38
|
+
} catch (error) {
|
|
39
|
+
if (!(error instanceof EnvPathError)) throw error;
|
|
40
|
+
logger.error("❌ Central docs:", error.message);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
const squad = flags.squad || env.SQUAD;
|
|
44
|
+
const produto = flags.produto || flags.workspace || env.WORKSPACE;
|
|
45
|
+
const centralRoot = storage?.location ?? null;
|
|
46
|
+
|
|
47
|
+
const all = inventorySessions({ sessionsDir, centralRoot, squad, produto });
|
|
48
|
+
const list = flags.pendentes || flags.proxima ? all.filter((s) => s.pendente) : all;
|
|
49
|
+
|
|
50
|
+
if (flags.proxima) {
|
|
51
|
+
// stdout só com o card: o workflow lê esta saída
|
|
52
|
+
if (list.length > 0) process.stdout.write(`${list[0].card}\n`);
|
|
53
|
+
else console.error("Nenhuma sessão pendente.");
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (flags.json) {
|
|
57
|
+
process.stdout.write(`${JSON.stringify({ sessionsDir, central: centralRoot !== null, sessoes: list }, null, 2)}\n`);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (!centralRoot) {
|
|
62
|
+
logger.warn("⚠️ Central docs desligado: não dá para saber quais sessões já foram entregues ou publicadas.");
|
|
63
|
+
}
|
|
64
|
+
if (all.length === 0) {
|
|
65
|
+
logger.info(`ℹ️ Nenhuma sessão em ${sessionsDir}`);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
logger.info(`📚 Sessões em ${sessionsDir}\n`);
|
|
70
|
+
logger.info("card arquivos bytes entregue publicada faltam");
|
|
71
|
+
for (const s of list) {
|
|
72
|
+
logger.info(
|
|
73
|
+
[
|
|
74
|
+
s.card.padEnd(7),
|
|
75
|
+
String(s.files.length).padStart(8),
|
|
76
|
+
String(s.totalBytes).padStart(7),
|
|
77
|
+
sim(s.delivered).padStart(10),
|
|
78
|
+
sim(s.capituloPublicado).padStart(10),
|
|
79
|
+
` ${s.vazia ? "(vazia)" : s.ausentes.join(", ") || "-"}`,
|
|
80
|
+
].join(" ")
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
const pendentes = all.filter((s) => s.pendente).length;
|
|
84
|
+
const entregues = all.filter((s) => s.delivered).length;
|
|
85
|
+
logger.info(
|
|
86
|
+
`\n${all.length} sessão(ões): ${entregues} com entrega no Central docs, ${pendentes} pendente(s) (sem página-índice publicada).`
|
|
87
|
+
);
|
|
88
|
+
if (pendentes > 0 && centralRoot) logger.info("Próxima: /eng.spec-consolidate --proxima");
|
|
89
|
+
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { openStorageFromEnv } from "../lib/docs/fetch-file.js";
|
|
2
2
|
import { logger, configureFromFlags } from "../lib/utils/logger.js";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
// Contagem pelo link que renderIndex gera (build-index.js): a página da funcionalidade
|
|
5
|
+
// termina em `/{slug}/{slug}.md`; a entrega mora em `/{slug}/deliveries/delivery-*.md`.
|
|
6
|
+
const COUNTED = [
|
|
7
|
+
["feature", "funcionalidade(s)", /\]\(([a-z0-9_-]+)\/\1\/\1\.md\)/gi],
|
|
8
|
+
["delivery", "entrega(s) recente(s)", /\]\([a-z0-9_-]+\/[a-z0-9_-]+\/deliveries\/delivery-[^)]*\.md\)/gi],
|
|
9
|
+
];
|
|
6
10
|
|
|
7
11
|
/**
|
|
8
12
|
* Sincroniza a documentação do Central docs (lê `{SQUAD}/index.md` pelo adaptador).
|
|
@@ -48,15 +52,16 @@ export async function docsSync(flags = {}) {
|
|
|
48
52
|
logger.debug("\n📄 Conteúdo do index.md:\n");
|
|
49
53
|
logger.debug(content);
|
|
50
54
|
|
|
51
|
-
const counts =
|
|
55
|
+
const counts = COUNTED.map(([tipo, label, re]) => [
|
|
52
56
|
tipo,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
label,
|
|
58
|
+
(content.match(re) || []).length,
|
|
59
|
+
]).filter(([, , n]) => n > 0);
|
|
60
|
+
const total = counts.reduce((sum, [, , n]) => sum + n, 0);
|
|
56
61
|
|
|
57
62
|
if (total > 0) {
|
|
58
63
|
logger.info(`📊 ${total} documentos disponíveis:`);
|
|
59
|
-
for (const [
|
|
64
|
+
for (const [, label, n] of counts) logger.info(` - ${n} ${label}`);
|
|
60
65
|
}
|
|
61
66
|
} catch (error) {
|
|
62
67
|
logger.error("❌ Erro ao sincronizar docs:", error.message);
|
package/bin/commands/init.js
CHANGED
|
@@ -32,6 +32,7 @@ import { DEFAULT_COMPANY_PROFILE, isValidCompanyProfile } from "../lib/core/comp
|
|
|
32
32
|
import { checkCli, getVendor } from "../lib/integrations/cli-runner.js";
|
|
33
33
|
import {
|
|
34
34
|
expandEnv,
|
|
35
|
+
docsFolders,
|
|
35
36
|
planDocsMigration,
|
|
36
37
|
applyDocsMigration,
|
|
37
38
|
rewriteRelatedDiscovery,
|
|
@@ -39,6 +40,7 @@ import {
|
|
|
39
40
|
ensureGitignore,
|
|
40
41
|
} from "../lib/core/docs-migrate.js";
|
|
41
42
|
import { rootIsRepo } from "../lib/core/workspace-mode.js";
|
|
43
|
+
import { EnvPathError, checkEnvPaths, planSessionsSetup } from "../lib/core/env-paths.js";
|
|
42
44
|
import { ensureContext7 } from "../lib/core/mcp-config.js";
|
|
43
45
|
|
|
44
46
|
function ask(rl, question) {
|
|
@@ -131,6 +133,7 @@ export function upgradePendencies({ pendingAxes, envPlan, missingProfile = [] })
|
|
|
131
133
|
if (envPlan.pending?.length) reasons.push(`preencher ${envPlan.pending.join(", ")}`);
|
|
132
134
|
const warnings = envPlan.warnings || [];
|
|
133
135
|
if (warnings.includes("CENTRAL_DOCS_REPO")) reasons.push("migrar o Central docs");
|
|
136
|
+
if (warnings.includes("CENTRAL_DOCS_LAYOUT")) reasons.push("migrar o Central docs para a estrutura por funcionalidade");
|
|
134
137
|
if (warnings.includes("TOKEN_TASK_MANAGER")) reasons.push("remover o TOKEN_TASK_MANAGER");
|
|
135
138
|
return reasons;
|
|
136
139
|
}
|
|
@@ -402,13 +405,19 @@ export async function init(flags) {
|
|
|
402
405
|
if (rulesSync?.errors.length) process.exitCode = 1;
|
|
403
406
|
}
|
|
404
407
|
|
|
405
|
-
|
|
406
|
-
for (const area of ["eng", "prod", "qa"]) {
|
|
407
|
-
mkdirSync(join(jarvisRoot, "sessions", area), { recursive: true });
|
|
408
|
-
}
|
|
408
|
+
// Sessões: pasta e .gitignore seguem o SESSIONS_DIR do ENV.md (reinstalação); sem ENV.md vale o padrão (#228).
|
|
409
409
|
// .gitignore só numa raiz versionada (com .git): no modo workspace a raiz não é um repositório.
|
|
410
|
-
|
|
411
|
-
|
|
410
|
+
try {
|
|
411
|
+
const sessionsEnv = existsSync(envOnDisk) ? parseEnvEntries(readFileSync(envOnDisk, "utf-8")) : new Map();
|
|
412
|
+
const sessions = planSessionsSetup({ workspaceDir: cwd, env: sessionsEnv, isRepo: rootIsRepo(cwd) });
|
|
413
|
+
for (const dir of sessions.areaDirs) mkdirSync(dir, { recursive: true });
|
|
414
|
+
for (const line of sessions.gitignore) ensureGitignore(cwd, line);
|
|
415
|
+
for (const warning of sessions.warnings) logger.info(`${YELLOW} ⚠ ${warning}${NC}`);
|
|
416
|
+
} catch (error) {
|
|
417
|
+
if (!(error instanceof EnvPathError)) throw error;
|
|
418
|
+
logger.error(`${RED} ✗ ${error.message}${NC}`);
|
|
419
|
+
logger.error(`${RED} ✗ As pastas de sessão não foram criadas. Corrija o ENV.md e rode o init de novo.${NC}`);
|
|
420
|
+
process.exitCode = 1;
|
|
412
421
|
}
|
|
413
422
|
|
|
414
423
|
logger.info("");
|
|
@@ -592,6 +601,16 @@ async function runUpgrade(cwd, flags) {
|
|
|
592
601
|
}
|
|
593
602
|
const workspaceDir = resolved.root;
|
|
594
603
|
const envPath = resolved.path;
|
|
604
|
+
// 0. Caminhos do ENV.md com `$` sem valor: o upgrade para antes de mexer em qualquer coisa (#228).
|
|
605
|
+
try {
|
|
606
|
+
checkEnvPaths(parseEnvEntries(readFileSync(envPath, "utf-8")));
|
|
607
|
+
} catch (error) {
|
|
608
|
+
if (!(error instanceof EnvPathError)) throw error;
|
|
609
|
+
logger.error(`${RED} ✗ ${error.message}${NC}`);
|
|
610
|
+
logger.error(`${RED} ✗ Upgrade interrompido: nada foi alterado. Corrija o ENV.md e rode de novo.${NC}\n`);
|
|
611
|
+
return 1;
|
|
612
|
+
}
|
|
613
|
+
|
|
595
614
|
const previousVersion = readLockVersion(workspaceDir);
|
|
596
615
|
// Vindo do menu do `init`, o aviso já saiu antes da escolha (Q8): só reaproveita o resultado.
|
|
597
616
|
const { downgrade, running } =
|
|
@@ -650,7 +669,7 @@ async function runUpgrade(cwd, flags) {
|
|
|
650
669
|
if (flags.yes) accepted = true;
|
|
651
670
|
else if (process.stdin.isTTY) {
|
|
652
671
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
653
|
-
const answer = await ask(rl, `Mover para
|
|
672
|
+
const answer = await ask(rl, `Mover para ${docsFolders(env).jarvis}/…? (s/N): `);
|
|
654
673
|
rl.close();
|
|
655
674
|
accepted = answer.trim().toLowerCase() === "s";
|
|
656
675
|
} else {
|
|
@@ -778,6 +797,11 @@ async function runUpgrade(cwd, flags) {
|
|
|
778
797
|
`${YELLOW} ⚠️ Central docs no formato antigo (CENTRAL_DOCS_REPO): a migração é feita pelo /jarvis-init upgrade${NC}`
|
|
779
798
|
);
|
|
780
799
|
}
|
|
800
|
+
if (envPlan.warnings.includes("CENTRAL_DOCS_LAYOUT")) {
|
|
801
|
+
logger.info(
|
|
802
|
+
`${YELLOW} ⚠️ Central docs no layout antigo (product/engineering): rode "jarvis docs migrate" para ver o plano, ou o /jarvis-init oferece (Upgrade C)${NC}`
|
|
803
|
+
);
|
|
804
|
+
}
|
|
781
805
|
if (envPlan.warnings.includes("WORKSPACE_MODE")) {
|
|
782
806
|
logger.info(
|
|
783
807
|
`${YELLOW} ⚠️ WORKSPACE_MODE: a raiz é um repositório e há subpastas com .git (submódulos?): gravado como project; confira no ENV.md${NC}`
|
package/bin/lib/cli/program.js
CHANGED
|
@@ -22,6 +22,10 @@ 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";
|
|
28
|
+
import { docsSessions } from "../../commands/docs-sessions.js";
|
|
25
29
|
import { installRtk } from "../../commands/install-rtk.js";
|
|
26
30
|
import { tokens } from "../../commands/tokens.js";
|
|
27
31
|
import { rulesSync } from "../../commands/rules.js";
|
|
@@ -146,12 +150,32 @@ export function buildProgram() {
|
|
|
146
150
|
|
|
147
151
|
const docsPublishCmd = cmd(docs, "publish")
|
|
148
152
|
.description(
|
|
149
|
-
"Publicar
|
|
153
|
+
"Publicar no Central docs, na estrutura por funcionalidade (pasta: copia e regenera o índice; com git: branch + PR)"
|
|
154
|
+
)
|
|
155
|
+
.option("--file <path>", "Caminho do arquivo local (um só; alternativa ao --manifest)")
|
|
156
|
+
.option(
|
|
157
|
+
"--manifest <path>",
|
|
158
|
+
"Manifesto JSON com vários arquivos ([{file, tipo, feature?, taskKey?, relPath?, fromSession?}]); publica em lote, numa branch e um PR só"
|
|
159
|
+
)
|
|
160
|
+
.option("--slug <chave>", "Nome da branch/commit do lote (ex.: a chave da entrega); só com --manifest")
|
|
161
|
+
.option(
|
|
162
|
+
"--force",
|
|
163
|
+
"Só com --manifest: publica e já finaliza (apaga os originais), sem --archive — zero reversão (Q15, #220)"
|
|
164
|
+
)
|
|
165
|
+
.option(
|
|
166
|
+
"--dry-run",
|
|
167
|
+
"Só com --manifest: simula e mostra o que seria publicado (novo, igual, nova versão, sobrescreve), sem gravar nada nem alterar o manifesto"
|
|
168
|
+
)
|
|
169
|
+
.option(
|
|
170
|
+
"--tipo <tipo>",
|
|
171
|
+
"feature|delivery|product|history|prd|frd|feat|epic|story|task|ard|rfc|spec|swagger|qa-report|discovery|architecture|plan|light-arch"
|
|
150
172
|
)
|
|
151
|
-
.option("--file <path>", "Caminho do arquivo local")
|
|
152
|
-
.option("--tipo <tipo>", "feature|delivery (consolidação do /eng.spec-consolidate)")
|
|
153
173
|
.option("--produto <produto>", "Pasta do produto no Central docs (padrão: WORKSPACE do ENV.md)")
|
|
154
|
-
.option(
|
|
174
|
+
.option(
|
|
175
|
+
"--feature <slug>",
|
|
176
|
+
"Funcionalidade: opcional para feature (se o arquivo seguir feature-{slug}.md); obrigatório para delivery e para os documentos de trabalho"
|
|
177
|
+
)
|
|
178
|
+
.option("--task-key <chave>", "Obrigatório para --tipo history (rodadas, comentários, diário)")
|
|
155
179
|
.option("--squad <squad>", "Override do SQUAD do ENV.md")
|
|
156
180
|
.option(
|
|
157
181
|
"--workspace <workspace>",
|
|
@@ -161,6 +185,53 @@ export function buildProgram() {
|
|
|
161
185
|
docsPublish(toLegacyFlags(options))
|
|
162
186
|
);
|
|
163
187
|
|
|
188
|
+
const docsArchiveCmd = cmd(docs, "archive")
|
|
189
|
+
.description(
|
|
190
|
+
"Arquivar os originais já publicados (decisions/), sem apagar nada; reescreve o manifesto com o hash e o destino"
|
|
191
|
+
)
|
|
192
|
+
.option("--manifest <path>", "O mesmo manifesto do jarvis docs publish")
|
|
193
|
+
.option("--squad <squad>", "Override do SQUAD do ENV.md")
|
|
194
|
+
.option("--produto <produto>", "Override do WORKSPACE do ENV.md");
|
|
195
|
+
withEnvOptions(withLogOptions(docsArchiveCmd)).action((options) =>
|
|
196
|
+
docsArchive(toLegacyFlags(options))
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
const docsSessionsCmd = cmd(docs, "sessions")
|
|
200
|
+
.description(
|
|
201
|
+
"Listar as sessões de engenharia, seus arquivos e se a entrega já está no Central docs (só leitura)"
|
|
202
|
+
)
|
|
203
|
+
.option("--json", "Saída em JSON")
|
|
204
|
+
.option("--pendentes", "Só as sessões sem a página-índice publicada no Central docs")
|
|
205
|
+
.option("--proxima", "Imprime só o card da próxima sessão pendente")
|
|
206
|
+
.option("--squad <squad>", "Override do SQUAD do ENV.md")
|
|
207
|
+
.option("--produto <produto>", "Override do WORKSPACE do ENV.md")
|
|
208
|
+
.option("--workspace <workspace>", "Mesmo efeito de --produto");
|
|
209
|
+
withEnvOptions(withLogOptions(docsSessionsCmd)).action((options) =>
|
|
210
|
+
docsSessions(toLegacyFlags(options))
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
const docsFinalizeCmd = cmd(docs, "finalize")
|
|
214
|
+
.description(
|
|
215
|
+
"Apagar os originais já arquivados (--archive antes); irreversível, só os que não mudaram desde então"
|
|
216
|
+
)
|
|
217
|
+
.option("--manifest <path>", "O manifesto já arquivado com --archive")
|
|
218
|
+
.option("--squad <squad>", "Override do SQUAD do ENV.md")
|
|
219
|
+
.option("--produto <produto>", "Override do WORKSPACE do ENV.md")
|
|
220
|
+
.option("--workspace <workspace>", "Mesmo efeito de --produto");
|
|
221
|
+
withEnvOptions(withLogOptions(docsFinalizeCmd)).action((options) =>
|
|
222
|
+
docsFinalize(toLegacyFlags(options))
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
const docsMigrateCmd = cmd(docs, "migrate")
|
|
226
|
+
.description(
|
|
227
|
+
"Migrar o Central docs do layout antigo para a estrutura por funcionalidade (dry-run por padrão)"
|
|
228
|
+
)
|
|
229
|
+
.option("--apply", "Aplica o plano (padrão: só mostra, sem alterar nada)")
|
|
230
|
+
.option("--squad <squad>", "Override do SQUAD do ENV.md");
|
|
231
|
+
withEnvOptions(withLogOptions(docsMigrateCmd)).action((options) =>
|
|
232
|
+
docsMigrate(toLegacyFlags(options))
|
|
233
|
+
);
|
|
234
|
+
|
|
164
235
|
const installRtkCmd = cmd(program, "install-rtk").description(
|
|
165
236
|
"Instalar RTK (token killer — economia 60-90% em tokens de shell)"
|
|
166
237
|
);
|
|
@@ -222,7 +222,7 @@ export const OPENCODE_MODEL_MAP = Object.freeze({
|
|
|
222
222
|
// Anthropic — IDs completos
|
|
223
223
|
"claude-opus-4-6-20250529": "anthropic/claude-opus-4-6",
|
|
224
224
|
"claude-sonnet-4-6-20250514": "anthropic/claude-sonnet-4-6",
|
|
225
|
-
"claude-sonnet-
|
|
225
|
+
"claude-sonnet-5": "anthropic/claude-sonnet-4-6",
|
|
226
226
|
"claude-haiku-4-5-20250414": "anthropic/claude-haiku-4-5-20250414",
|
|
227
227
|
// OpenAI
|
|
228
228
|
"gpt-4o": "openai/gpt-4o",
|