@spec-wave/cli 1.0.7 → 1.1.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/package.json +1 -1
- package/src/commands/audit.mjs +24 -18
- package/src/commands/code-review.mjs +91 -59
- package/src/commands/decompose.mjs +258 -221
- package/src/commands/doctor.mjs +16 -11
- package/src/commands/generate-bug.mjs +51 -44
- package/src/commands/generate-plan.mjs +83 -63
- package/src/commands/generate-qa-plan.mjs +145 -117
- package/src/commands/generate-spec.mjs +33 -28
- package/src/commands/implement.mjs +155 -79
- package/src/commands/info.mjs +4 -3
- package/src/commands/init.mjs +11 -5
- package/src/commands/install-skill.mjs +19 -0
- package/src/commands/issue.mjs +26 -39
- package/src/commands/merge.mjs +71 -20
- package/src/commands/mode.mjs +11 -6
- package/src/commands/move.mjs +16 -20
- package/src/commands/order.mjs +33 -22
- package/src/commands/preflight.mjs +24 -13
- package/src/commands/qa-lead.mjs +30 -17
- package/src/commands/qa-run.mjs +125 -103
- package/src/commands/qa.mjs +55 -44
- package/src/commands/refresh.mjs +24 -16
- package/src/commands/repair-stage.mjs +29 -16
- package/src/commands/repo.mjs +12 -4
- package/src/commands/run.mjs +23 -11
- package/src/commands/story.mjs +20 -25
- package/src/commands/task.mjs +21 -27
- package/src/commands/triage.mjs +33 -31
- package/src/commands/uninstall.mjs +7 -3
- package/src/commands/update.mjs +31 -22
- package/src/commands/validate.mjs +60 -52
- package/src/commands/workspace.mjs +7 -5
- package/src/config.mjs +7 -1
- package/src/lib/artifact-publish.mjs +20 -18
- package/src/lib/board-policy.mjs +144 -0
- package/src/lib/board.mjs +134 -233
- package/src/lib/cli-ref.mjs +75 -0
- package/src/lib/config-file.mjs +2 -1
- package/src/lib/doc-availability.mjs +10 -3
- package/src/lib/doc-source.mjs +9 -9
- package/src/lib/execution-mode.mjs +5 -3
- package/src/lib/implement-board.mjs +23 -26
- package/src/lib/issue-type.mjs +5 -1
- package/src/lib/plugin-skills.mjs +10 -0
- package/src/lib/pr-ready.mjs +48 -10
- package/src/lib/pr-step.mjs +3 -1
- package/src/lib/qa-exec.mjs +3 -1
- package/src/lib/qa-lead.mjs +11 -3
- package/src/lib/qa-plan-doc.mjs +10 -4
- package/src/lib/qa-report.mjs +2 -1
- package/src/lib/skill-compose.mjs +3 -0
- package/src/lib/spec-audit.mjs +1 -1
- package/src/lib/story-graph.mjs +62 -8
- package/src/lib/usage-report.mjs +8 -5
- package/src/lib/work-item-ref.mjs +176 -0
- package/src/plugin/.claude-plugin/plugin.json +1 -1
- package/src/plugins/scm-github/index.mjs +439 -0
- package/src/plugins/tracker-github-projects/fields.mjs +73 -0
- package/src/plugins/tracker-github-projects/index.mjs +625 -0
- package/src/ports/scm.mjs +197 -0
- package/src/ports/tracker.mjs +239 -0
- package/src/ports/types.mjs +254 -0
- package/src/setup/files.mjs +14 -12
- package/src/setup/labels.mjs +17 -12
- package/src/setup/project.mjs +40 -59
- package/src/templates/workflows/code/code-review.yml +1 -1
- package/src/templates/workflows/code/qa.yml +1 -1
package/src/commands/order.mjs
CHANGED
|
@@ -24,8 +24,7 @@ import path from 'node:path';
|
|
|
24
24
|
import * as p from '@clack/prompts';
|
|
25
25
|
import chalk from 'chalk';
|
|
26
26
|
import { resolveToken } from '../api/auth.mjs';
|
|
27
|
-
import {
|
|
28
|
-
import { listSubIssues } from '../api/github-graphql.mjs';
|
|
27
|
+
import { createGithubTracker } from '../plugins/tracker-github-projects/index.mjs';
|
|
29
28
|
import { detectIssueType } from '../lib/issue-type.mjs';
|
|
30
29
|
import { parseDependencies, orderStories } from '../lib/dependencies.mjs';
|
|
31
30
|
import { loadProjectConfig, selectOpenFeatures } from '../lib/board.mjs';
|
|
@@ -68,14 +67,21 @@ export function featureLabel(feature) {
|
|
|
68
67
|
* @returns {string[]} uma linha de aviso por Story divergente
|
|
69
68
|
*/
|
|
70
69
|
export function milestoneMismatches(featureMilestone, stories = []) {
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
// Aceita as DUAS formas: `key` (MilestoneRef, o que a porta devolve) e
|
|
71
|
+
// `number` (a milestone crua, que ainda chega pelo story-graph). Sem isso a
|
|
72
|
+
// função devolveria [] em silêncio na forma nova — e um aviso que some é
|
|
73
|
+
// pior que um aviso errado, porque ninguém vai procurá-lo.
|
|
74
|
+
const chave = m => (m?.key != null ? String(m.key) : (Number.isInteger(m?.number) ? String(m.number) : null));
|
|
75
|
+
const alvo = chave(featureMilestone);
|
|
76
|
+
if (!alvo) return [];
|
|
77
|
+
const ref = featureMilestone.title || `#${alvo}`;
|
|
73
78
|
const out = [];
|
|
74
79
|
for (const s of stories) {
|
|
75
|
-
|
|
80
|
+
const dela = chave(s?.milestone);
|
|
81
|
+
if (!dela) {
|
|
76
82
|
out.push(`#${s.number} está SEM milestone — a Feature está em "${ref}".`);
|
|
77
|
-
} else if (
|
|
78
|
-
out.push(`#${s.number} está em "${s.milestone.title || `#${
|
|
83
|
+
} else if (dela !== alvo) {
|
|
84
|
+
out.push(`#${s.number} está em "${s.milestone.title || `#${dela}`}", mas a Feature está em "${ref}".`);
|
|
79
85
|
}
|
|
80
86
|
}
|
|
81
87
|
return out;
|
|
@@ -136,7 +142,7 @@ async function orderBoard({ token, owner, repo, root, ttlSec, opts }) {
|
|
|
136
142
|
|
|
137
143
|
let snapshot;
|
|
138
144
|
try {
|
|
139
|
-
snapshot = await loadBoardSnapshot({ token, project, root, refresh: opts.refresh, ttlSec });
|
|
145
|
+
snapshot = await loadBoardSnapshot({ token, owner, repo, project, root, refresh: opts.refresh, ttlSec });
|
|
140
146
|
} catch (err) {
|
|
141
147
|
emitError(opts, `Não foi possível ler os itens do Project: ${err.message}`);
|
|
142
148
|
process.exitCode = 1;
|
|
@@ -317,7 +323,8 @@ export async function order({
|
|
|
317
323
|
// 1. Lê a Feature e valida o tipo (1 chamada — a issue-alvo nunca vem de cache).
|
|
318
324
|
let featureIssue;
|
|
319
325
|
try {
|
|
320
|
-
featureIssue = await
|
|
326
|
+
featureIssue = await createGithubTracker({ token, owner, repo })
|
|
327
|
+
.getWorkItem({ ref: { key: String(featureNumber) } });
|
|
321
328
|
} catch (err) {
|
|
322
329
|
emitError(opts, `Não foi possível ler a issue #${featureNumber}: ${err.message}`);
|
|
323
330
|
process.exitCode = 1;
|
|
@@ -338,7 +345,7 @@ export async function order({
|
|
|
338
345
|
try {
|
|
339
346
|
carga = await loadFeatureStories({
|
|
340
347
|
token, owner, repo, root,
|
|
341
|
-
feature: { number: featureNumber, nodeId: featureIssue.
|
|
348
|
+
feature: { number: featureNumber, nodeId: featureIssue.ref.id, title: featureIssue.title },
|
|
342
349
|
remote, refresh, ttlSec,
|
|
343
350
|
});
|
|
344
351
|
} catch (err) {
|
|
@@ -365,7 +372,7 @@ export async function order({
|
|
|
365
372
|
if (!json) p.log.warn(`${projectError} — Etapas do board não consultadas.`);
|
|
366
373
|
} else {
|
|
367
374
|
try {
|
|
368
|
-
const snapshot = await loadBoardSnapshot({ token, project, root, refresh, ttlSec });
|
|
375
|
+
const snapshot = await loadBoardSnapshot({ token, owner, repo, project, root, refresh, ttlSec });
|
|
369
376
|
for (const s of enriched) stageOf.set(s.number, snapshot.index.get(s.number)?.fields?.Etapa ?? null);
|
|
370
377
|
boardMeta = {
|
|
371
378
|
stages: snapshot.fromCache ? 'cache' : 'board',
|
|
@@ -513,10 +520,11 @@ function commitSyncedFiles(root, filesRel, featureNumber) {
|
|
|
513
520
|
}
|
|
514
521
|
|
|
515
522
|
async function syncDependencies({ token, owner, repo, root, opts, featureNumber }) {
|
|
523
|
+
const tracker = createGithubTracker({ token, owner, repo });
|
|
516
524
|
// Alvos: a Feature pedida, ou as Features abertas do board (--milestone filtra).
|
|
517
525
|
let targets = [];
|
|
518
526
|
if (featureNumber) {
|
|
519
|
-
const issue = await
|
|
527
|
+
const issue = await tracker.getWorkItem({ ref: { key: String(featureNumber) } }).catch((err) => {
|
|
520
528
|
emitError(opts, `Não foi possível ler a issue #${featureNumber}: ${err.message}`);
|
|
521
529
|
return null;
|
|
522
530
|
});
|
|
@@ -526,7 +534,9 @@ async function syncDependencies({ token, owner, repo, root, opts, featureNumber
|
|
|
526
534
|
process.exitCode = 1;
|
|
527
535
|
return;
|
|
528
536
|
}
|
|
529
|
-
|
|
537
|
+
// `ref.id`: o WorkItem da porta não tem `node_id`, e um nodeId ausente faz
|
|
538
|
+
// o plugin pagar um getIssue a mais para reidratar o que já estava aqui.
|
|
539
|
+
targets = [{ number: featureNumber, nodeId: issue.ref?.id, title: issue.title }];
|
|
530
540
|
} else {
|
|
531
541
|
const { project, error } = loadProjectConfig();
|
|
532
542
|
if (error) {
|
|
@@ -535,7 +545,7 @@ async function syncDependencies({ token, owner, repo, root, opts, featureNumber
|
|
|
535
545
|
return;
|
|
536
546
|
}
|
|
537
547
|
// Sync é reconciliação: sempre parte de um snapshot FRESCO.
|
|
538
|
-
const snapshot = await loadBoardSnapshot({ token, project, root, refresh: true });
|
|
548
|
+
const snapshot = await loadBoardSnapshot({ token, owner, repo, project, root, refresh: true });
|
|
539
549
|
let features = selectOpenFeatures(snapshot.items);
|
|
540
550
|
if (opts.milestone) features = filterItemsByMilestone(features, opts.milestone);
|
|
541
551
|
targets = features;
|
|
@@ -544,14 +554,14 @@ async function syncDependencies({ token, owner, repo, root, opts, featureNumber
|
|
|
544
554
|
let synced = 0;
|
|
545
555
|
let untouched = 0;
|
|
546
556
|
for (const feature of targets) {
|
|
547
|
-
const resultado = await syncOneFeature({ token, owner, repo, root, feature });
|
|
557
|
+
const resultado = await syncOneFeature({ token, owner, repo, tracker, root, feature });
|
|
548
558
|
if (resultado === 'synced') synced += 1;
|
|
549
559
|
else if (resultado === 'unchanged') untouched += 1;
|
|
550
560
|
}
|
|
551
561
|
p.outro(`${chalk.green('✓')} sync: ${synced} Feature(s) atualizada(s), ${untouched} já em dia.`);
|
|
552
562
|
}
|
|
553
563
|
|
|
554
|
-
async function syncOneFeature({ token, owner, repo, root, feature }) {
|
|
564
|
+
async function syncOneFeature({ token, owner, repo, tracker, root, feature }) {
|
|
555
565
|
let paths;
|
|
556
566
|
try {
|
|
557
567
|
paths = featureDocPaths(root, { title: feature.title }, 'Feature');
|
|
@@ -578,16 +588,17 @@ async function syncOneFeature({ token, owner, repo, root, feature }) {
|
|
|
578
588
|
|
|
579
589
|
// Leitura VIVA: body ∪ blocked_by, sempre frescos — sync que lê cache
|
|
580
590
|
// reconciliaria o doc com ele mesmo.
|
|
581
|
-
const subs = (await
|
|
582
|
-
|
|
591
|
+
const subs = (await tracker.listChildren({
|
|
592
|
+
ref: { key: String(feature.number), id: feature.nodeId || feature.node_id },
|
|
593
|
+
})).filter(s => detectIssueType(s) === 'Story');
|
|
583
594
|
const remoteEdges = [];
|
|
584
595
|
for (const s of subs) {
|
|
585
|
-
const blockedBy = (await listBlockedBy(
|
|
586
|
-
.map(b => b.
|
|
587
|
-
remoteEdges.push({ number: s.
|
|
596
|
+
const blockedBy = (await tracker.listBlockedBy({ ref: s.ref }).catch(() => []))
|
|
597
|
+
.map(b => Number(b.ref.key));
|
|
598
|
+
remoteEdges.push({ number: Number(s.ref.key), dependsOn: blockedBy });
|
|
588
599
|
}
|
|
589
600
|
const liveDeps = mergeDependencyEdges(
|
|
590
|
-
subs.map(s => ({ number: s.
|
|
601
|
+
subs.map(s => ({ number: Number(s.ref.key), dependsOn: parseDependencies(s.body) })),
|
|
591
602
|
remoteEdges,
|
|
592
603
|
);
|
|
593
604
|
|
|
@@ -20,9 +20,8 @@ import * as p from '@clack/prompts';
|
|
|
20
20
|
import chalk from 'chalk';
|
|
21
21
|
|
|
22
22
|
import { resolveToken } from '../api/auth.mjs';
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
} from '../api/github-rest.mjs';
|
|
23
|
+
import { createGithubTracker } from '../plugins/tracker-github-projects/index.mjs';
|
|
24
|
+
import { createGithubScm, githubLink } from '../plugins/scm-github/index.mjs';
|
|
26
25
|
import { CONFIG_FILE } from '../config.mjs';
|
|
27
26
|
import { inspectPrPublishing, readPrPublishingContext } from './doctor.mjs';
|
|
28
27
|
import { configuredMode, describeModeState, EXECUTION_VARIABLE } from '../lib/execution-mode.mjs';
|
|
@@ -174,7 +173,7 @@ export function inspectPreflight({
|
|
|
174
173
|
|
|
175
174
|
const MARCA = { local: '✓ no disco', remote: '✓ na base', 'pending-pr': '⏳ em PR aberto', 'branch-only': '⚠ em branch sem PR', missing: '· gerar', unknown: '? indeterminado' };
|
|
176
175
|
|
|
177
|
-
export async function preflight({ milestone: milestoneArg, json = false } = {}) {
|
|
176
|
+
export async function preflight({ milestone: milestoneArg, json = false, deps = {} } = {}) {
|
|
178
177
|
const saida = { milestone: null, modo: null, publicacao: null, inventario: null, veredito: null };
|
|
179
178
|
const falhar = (msg) => {
|
|
180
179
|
if (json) console.log(JSON.stringify({ ...saida, erro: msg }, null, 2));
|
|
@@ -199,12 +198,15 @@ export async function preflight({ milestone: milestoneArg, json = false } = {})
|
|
|
199
198
|
return falhar(`Sem token utilizável para ${owner}/${repo}: ${err.message}`);
|
|
200
199
|
}
|
|
201
200
|
|
|
201
|
+
const tracker = deps.tracker ?? createGithubTracker({ token, owner, repo });
|
|
202
|
+
const scm = deps.scm ?? createGithubScm({ link: githubLink({ owner, repo }), token });
|
|
203
|
+
|
|
202
204
|
const s = json ? null : p.spinner();
|
|
203
205
|
s?.start('Consultando o repositório...');
|
|
204
206
|
|
|
205
207
|
let base;
|
|
206
208
|
try {
|
|
207
|
-
base = await
|
|
209
|
+
base = await scm.defaultBranch();
|
|
208
210
|
} catch (err) {
|
|
209
211
|
s?.stop('');
|
|
210
212
|
return falhar(`Não foi possível ler o repositório ${owner}/${repo}: ${err.message}`);
|
|
@@ -213,7 +215,7 @@ export async function preflight({ milestone: milestoneArg, json = false } = {})
|
|
|
213
215
|
// --- Modo de execução: config × variável (o mesmo par que o doctor confere).
|
|
214
216
|
let variable;
|
|
215
217
|
try {
|
|
216
|
-
variable = await
|
|
218
|
+
variable = await scm.getVariable({ name: EXECUTION_VARIABLE });
|
|
217
219
|
} catch {
|
|
218
220
|
variable = undefined; // exige admin — "não deu para ler" não é "ausente"
|
|
219
221
|
}
|
|
@@ -231,7 +233,7 @@ export async function preflight({ milestone: milestoneArg, json = false } = {})
|
|
|
231
233
|
// --- Inventário da milestone.
|
|
232
234
|
let milestones;
|
|
233
235
|
try {
|
|
234
|
-
milestones = await listMilestones(
|
|
236
|
+
milestones = await tracker.listMilestones();
|
|
235
237
|
} catch (err) {
|
|
236
238
|
s?.stop('');
|
|
237
239
|
return falhar(`Não foi possível listar as milestones: ${err.message}`);
|
|
@@ -244,7 +246,7 @@ export async function preflight({ milestone: milestoneArg, json = false } = {})
|
|
|
244
246
|
|
|
245
247
|
let issues;
|
|
246
248
|
try {
|
|
247
|
-
issues = await
|
|
249
|
+
issues = await tracker.listWorkItemsByMilestone({ milestone });
|
|
248
250
|
} catch (err) {
|
|
249
251
|
s?.stop('');
|
|
250
252
|
return falhar(`Não foi possível listar as issues da milestone "${milestone.title}": ${err.message}`);
|
|
@@ -253,24 +255,33 @@ export async function preflight({ milestone: milestoneArg, json = false } = {})
|
|
|
253
255
|
// O estado do spec.md de cada Feature, nas quatro camadas. Uma issue por vez:
|
|
254
256
|
// são até 3 requisições cada, e disparar tudo de uma vez numa milestone de 20
|
|
255
257
|
// Features é o caminho mais curto para o rate limit secundário.
|
|
258
|
+
// `inspectMilestone` é PURA e testada contra a forma da issue crua. Em vez de
|
|
259
|
+
// mudá-la (e o teste junto), a normalização acontece aqui, num lugar só.
|
|
260
|
+
const comoIssue = w => ({
|
|
261
|
+
number: Number(w.ref.key),
|
|
262
|
+
title: w.title,
|
|
263
|
+
state: w.state,
|
|
264
|
+
labels: w.tags,
|
|
265
|
+
});
|
|
266
|
+
|
|
256
267
|
const featureIssues = issues.filter(i => detectIssueType(i) === 'Feature');
|
|
257
268
|
const specStates = {};
|
|
258
269
|
for (const issue of featureIssues) {
|
|
259
270
|
const docs = featureDocPaths(root, issue, 'Feature');
|
|
260
271
|
const estados = await artifactStates({
|
|
261
|
-
token, owner, repo, root, base,
|
|
262
|
-
issueNumber: issue.
|
|
272
|
+
token, owner, repo, root, base, scm,
|
|
273
|
+
issueNumber: issue.ref.key,
|
|
263
274
|
docs: [{ doc: 'spec', pathRel: docs.spec.rel }],
|
|
264
275
|
});
|
|
265
|
-
specStates[issue.
|
|
276
|
+
specStates[issue.ref.key] = estados.spec;
|
|
266
277
|
}
|
|
267
278
|
|
|
268
|
-
const inventario = inspectMilestone({ issues, specStates });
|
|
279
|
+
const inventario = inspectMilestone({ issues: issues.map(comoIssue), specStates });
|
|
269
280
|
const veredito = inspectPreflight({ tokenOk: true, modo, publicacao, inventario });
|
|
270
281
|
s?.stop(`Milestone "${milestone.title}": ${inventario.features.length} Feature(s).`);
|
|
271
282
|
|
|
272
283
|
Object.assign(saida, {
|
|
273
|
-
milestone: { title: milestone.title, number: milestone.
|
|
284
|
+
milestone: { title: milestone.title, number: Number(milestone.key), base },
|
|
274
285
|
modo: { configured: configuredMode(config), variable: variable ?? null, status: modo.status, summary: modo.summary },
|
|
275
286
|
publicacao: { status: publicacao.status, notes: publicacao.notes },
|
|
276
287
|
inventario,
|
package/src/commands/qa-lead.mjs
CHANGED
|
@@ -23,13 +23,13 @@ import { setTimeout as sleep } from 'node:timers/promises';
|
|
|
23
23
|
import chalk from 'chalk';
|
|
24
24
|
|
|
25
25
|
import { resolveToken } from '../api/auth.mjs';
|
|
26
|
-
import {
|
|
27
|
-
addLabel, getIssue, listMilestones, listIssuesByMilestone,
|
|
28
|
-
getMilestone, updateMilestoneDescription, listIssueComments,
|
|
29
|
-
} from '../api/github-rest.mjs';
|
|
26
|
+
import { createGithubTracker } from '../plugins/tracker-github-projects/index.mjs';
|
|
30
27
|
import { detectIssueType } from '../lib/issue-type.mjs';
|
|
31
28
|
import { loadConfig, findConfigPath } from '../lib/project-root.mjs';
|
|
32
29
|
import { loadProjectConfig } from '../lib/board.mjs';
|
|
30
|
+
|
|
31
|
+
/** Porta de tracker do hub — este comando trabalha por TRILHA, sempre no hub. */
|
|
32
|
+
const trackerDe = (token, owner, repo) => createGithubTracker({ token, owner, repo });
|
|
33
33
|
import { featureDocPaths } from '../lib/doc-paths.mjs';
|
|
34
34
|
import { orderStories } from '../lib/dependencies.mjs';
|
|
35
35
|
import { loadFeatureStories, loadBoardSnapshot } from '../lib/story-graph.mjs';
|
|
@@ -47,6 +47,7 @@ import { createExecutionBackend, containerScript } from '../lib/qa-lead-backend.
|
|
|
47
47
|
import { pushWithRebase } from '../lib/git-retry.mjs';
|
|
48
48
|
import { CLI_VERSION } from '../lib/templates.mjs';
|
|
49
49
|
import { CONFIG_FILE, LABEL_QA, LABEL_QA_READY, LABEL_CRITIQUE_FAILED, labelNames } from '../config.mjs';
|
|
50
|
+
import { cliRef } from '../lib/cli-ref.mjs';
|
|
50
51
|
|
|
51
52
|
// Intervalo mínimo entre aplicações de label (§6.1): cada uma dispara um run
|
|
52
53
|
// do Actions, e uma rajada satura a fila.
|
|
@@ -79,7 +80,7 @@ async function bootstrap(milestoneArg) {
|
|
|
79
80
|
if (!configPath) {
|
|
80
81
|
throw new QaLeadRefusal(
|
|
81
82
|
`Repositório não inicializado (sem ${CONFIG_FILE}). ` +
|
|
82
|
-
|
|
83
|
+
`Rode \`npx ${cliRef()} init\` (ou a skill setup) primeiro.`
|
|
83
84
|
);
|
|
84
85
|
}
|
|
85
86
|
const { config, root } = loadConfig();
|
|
@@ -89,7 +90,7 @@ async function bootstrap(milestoneArg) {
|
|
|
89
90
|
}
|
|
90
91
|
const token = await resolveToken();
|
|
91
92
|
|
|
92
|
-
const milestones = await
|
|
93
|
+
const milestones = await trackerDe(token, owner, repo).listMilestones();
|
|
93
94
|
const resolved = resolveMilestoneRef(milestones, milestoneArg);
|
|
94
95
|
if (resolved.error) throw new QaLeadRefusal(resolved.error);
|
|
95
96
|
|
|
@@ -97,15 +98,27 @@ async function bootstrap(milestoneArg) {
|
|
|
97
98
|
return { token, owner, repo, root, config, lead, milestone: resolved.milestone };
|
|
98
99
|
}
|
|
99
100
|
|
|
101
|
+
// Tradução no ponto de leitura: o resto deste arquivo lê a forma antiga
|
|
102
|
+
// (`number`, `node_id`, `labels`) em dezenas de pontos — `byNumber`, o
|
|
103
|
+
// `featureOfStory` e o `addTag({ ref })` entre eles. Converter aqui é o que
|
|
104
|
+
// mantém o `WorkItem` da porta contido na fronteira.
|
|
105
|
+
const comoItem = w => w && ({
|
|
106
|
+
...w,
|
|
107
|
+
number: Number(w.ref.key),
|
|
108
|
+
nodeId: w.ref.id,
|
|
109
|
+
node_id: w.ref.id,
|
|
110
|
+
labels: w.tags || [],
|
|
111
|
+
});
|
|
112
|
+
|
|
100
113
|
// Itens do milestone separados por tipo — SEMPRE por Work Item Type (§4.1):
|
|
101
114
|
// Stories e Bugs herdam o milestone do pai (D5), então filtrar por milestone
|
|
102
115
|
// puro mandaria o Lead abrir container para Task.
|
|
103
116
|
async function milestoneItems({ token, owner, repo, milestone }) {
|
|
104
|
-
const issues = await
|
|
117
|
+
const issues = await trackerDe(token, owner, repo).listWorkItemsByMilestone({ milestone });
|
|
105
118
|
const byType = { Feature: [], Story: [], Bug: [] };
|
|
106
119
|
for (const issue of issues) {
|
|
107
120
|
const type = detectIssueType(issue);
|
|
108
|
-
if (byType[type]) byType[type].push(issue);
|
|
121
|
+
if (byType[type]) byType[type].push(comoItem(issue));
|
|
109
122
|
}
|
|
110
123
|
return byType;
|
|
111
124
|
}
|
|
@@ -194,7 +207,7 @@ async function qaLeadPlan(milestoneArg, { watch = false, dryRun = false } = {})
|
|
|
194
207
|
continue;
|
|
195
208
|
}
|
|
196
209
|
if (applied > 0) await sleep(TRIGGER_INTERVAL_MS);
|
|
197
|
-
await
|
|
210
|
+
await trackerDe(token, owner, repo).addTag({ ref: { key: String(item.feature.number) }, tag: LABEL_QA });
|
|
198
211
|
applied += 1;
|
|
199
212
|
item.state = 'em-voo';
|
|
200
213
|
console.log(`Feature #${item.feature.number}: \`${LABEL_QA}\` aplicada — plano em geração.`);
|
|
@@ -208,7 +221,7 @@ async function qaLeadPlan(milestoneArg, { watch = false, dryRun = false } = {})
|
|
|
208
221
|
await sleep(lead.pollIntervalSec * 1000);
|
|
209
222
|
for (const item of classified) {
|
|
210
223
|
if (item.state !== 'em-voo') continue;
|
|
211
|
-
const issue = await
|
|
224
|
+
const issue = await trackerDe(token, owner, repo).getWorkItem({ ref: { key: String(item.feature.number) } }).catch(() => null);
|
|
212
225
|
if (!issue) continue;
|
|
213
226
|
const { state } = classifyForPlan({ labels: labelNames(issue), hasSpecPlan: true });
|
|
214
227
|
if (state !== 'em-voo') {
|
|
@@ -287,7 +300,7 @@ async function qaLeadRun(milestoneArg, {
|
|
|
287
300
|
// `fresh: true`: o escopo decide O QUE EXECUTA em container — gate de
|
|
288
301
|
// execução não decide com cache. O snapshot fresco fica gravado para os
|
|
289
302
|
// comandos seguintes da sessão.
|
|
290
|
-
boardIndex = (await loadBoardSnapshot({ token, project, root, fresh: true })
|
|
303
|
+
boardIndex = (await loadBoardSnapshot({ token, owner, repo, project, root, fresh: true })
|
|
291
304
|
.catch(() => ({ index: new Map() }))).index;
|
|
292
305
|
} else {
|
|
293
306
|
console.warn(chalk.yellow(`⚠️ ${projectError || 'Project não configurado'} — Etapas não legíveis; Features contarão como fora-do-ciclo.`));
|
|
@@ -334,7 +347,7 @@ async function qaLeadRun(milestoneArg, {
|
|
|
334
347
|
: [];
|
|
335
348
|
const previousBugs = [];
|
|
336
349
|
for (const n of previousBugNumbers) {
|
|
337
|
-
const issue = await
|
|
350
|
+
const issue = await trackerDe(token, owner, repo).getWorkItem({ ref: { key: String(n) } }).catch(() => null);
|
|
338
351
|
if (issue) previousBugs.push(issue);
|
|
339
352
|
}
|
|
340
353
|
const closedBugs = previousBugs.filter(b => b.state === 'closed');
|
|
@@ -355,7 +368,7 @@ async function qaLeadRun(milestoneArg, {
|
|
|
355
368
|
} else {
|
|
356
369
|
const lastResults = new Map();
|
|
357
370
|
for (const t of inCycle) {
|
|
358
|
-
const comments = await
|
|
371
|
+
const comments = await trackerDe(token, owner, repo).listComments({ ref: { key: String(t.feature.number) } }).catch(() => []);
|
|
359
372
|
const parsed = parseLastQaReport(comments);
|
|
360
373
|
lastResults.set(t.feature.number, [...parsed.results.entries()]
|
|
361
374
|
.map(([numero, r]) => ({ numero, verdict: r.verdict })));
|
|
@@ -444,7 +457,7 @@ async function qaLeadRun(milestoneArg, {
|
|
|
444
457
|
while (queue.length > 0) {
|
|
445
458
|
const target = queue.shift();
|
|
446
459
|
const before = parseLastQaReport(
|
|
447
|
-
await
|
|
460
|
+
await trackerDe(token, owner, repo).listComments({ ref: { key: String(target.issue) } }).catch(() => [])).run;
|
|
448
461
|
console.log(`▶ despachando container: qa ${target.issue}${target.only ? ` --only ${target.only.join(',')}` : ''}`);
|
|
449
462
|
const result = await backend.run({
|
|
450
463
|
name: `qa-${target.issue}`,
|
|
@@ -464,7 +477,7 @@ async function qaLeadRun(milestoneArg, {
|
|
|
464
477
|
// container — quem morreu depois de comentar não perde resultado; quem
|
|
465
478
|
// morreu antes vira execucao-abortada (§3.3).
|
|
466
479
|
const parsed = parseLastQaReport(
|
|
467
|
-
await
|
|
480
|
+
await trackerDe(token, owner, repo).listComments({ ref: { key: String(target.issue) } }).catch(() => []));
|
|
468
481
|
const fresh = parsed.run > before ? parsed : null;
|
|
469
482
|
outcomes.set(target.issue, {
|
|
470
483
|
target,
|
|
@@ -694,9 +707,9 @@ async function publishCycle({ token, owner, repo, root, milestone, report }) {
|
|
|
694
707
|
// Bloco delimitado na descrição do milestone — SUBSTITUI o bloco, nunca a
|
|
695
708
|
// descrição (as Release Notes moram no mesmo campo — §4.4).
|
|
696
709
|
try {
|
|
697
|
-
const atual = await
|
|
710
|
+
const atual = await trackerDe(token, owner, repo).getMilestone({ key: milestone.key });
|
|
698
711
|
const description = upsertMilestoneBlock(atual.description, milestoneBlock(report, mdRel));
|
|
699
|
-
await
|
|
712
|
+
await trackerDe(token, owner, repo).setMilestoneDescription({ key: milestone.key, description });
|
|
700
713
|
console.log('Bloco de trilha atualizado na descrição do milestone.');
|
|
701
714
|
} catch (err) {
|
|
702
715
|
console.warn(chalk.yellow(`⚠️ Não consegui atualizar a descrição do milestone: ${err.message}`));
|