@spec-wave/cli 1.3.0 → 1.4.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 +3 -2
- package/src/commands/code-review.mjs +3 -2
- package/src/commands/decompose.mjs +26 -7
- package/src/commands/generate-bug.mjs +16 -6
- package/src/commands/generate-plan.mjs +21 -11
- package/src/commands/generate-qa-plan.mjs +20 -10
- package/src/commands/generate-spec.mjs +18 -5
- package/src/commands/implement.mjs +91 -47
- package/src/commands/init.mjs +3 -2
- package/src/commands/merge.mjs +14 -6
- package/src/commands/mode.mjs +3 -2
- package/src/commands/order.mjs +29 -19
- package/src/commands/preflight.mjs +3 -2
- package/src/commands/qa-lead.mjs +40 -28
- package/src/commands/qa-run.mjs +68 -52
- package/src/commands/qa.mjs +3 -2
- package/src/commands/repo.mjs +3 -2
- package/src/commands/run.mjs +3 -2
- package/src/commands/uninstall.mjs +3 -2
- package/src/commands/update.mjs +3 -2
- package/src/commands/validate.mjs +3 -2
- package/src/lib/artifact-publish.mjs +3 -2
- package/src/lib/critique.mjs +11 -1
- package/src/lib/doc-source.mjs +3 -2
- package/src/lib/implement-board.mjs +5 -0
- package/src/lib/implement-stream.mjs +87 -0
- package/src/lib/pr-ready.mjs +4 -3
- package/src/lib/story-graph.mjs +9 -2
- package/src/plugin/.claude-plugin/plugin.json +1 -1
- package/src/ports/index.mjs +192 -0
- package/src/ports/tracker.mjs +51 -1
- package/src/ports/types.mjs +29 -0
- package/src/setup/files.mjs +3 -2
package/src/commands/qa-run.mjs
CHANGED
|
@@ -20,11 +20,12 @@ import chalk from 'chalk';
|
|
|
20
20
|
|
|
21
21
|
import { resolveToken } from '../api/auth.mjs';
|
|
22
22
|
import { createGithubTracker } from '../plugins/tracker-github-projects/index.mjs';
|
|
23
|
-
import { createGithubScm
|
|
23
|
+
import { createGithubScm } from '../plugins/scm-github/index.mjs';
|
|
24
|
+
import { resolveScmLink } from '../ports/index.mjs';
|
|
24
25
|
|
|
25
26
|
/** Portas do hub — o QA roda sempre contra o repositório das issues. */
|
|
26
27
|
const trackerDe = (token, owner, repo) => createGithubTracker({ token, owner, repo });
|
|
27
|
-
const scmDe = (token, owner, repo) => createGithubScm({ link:
|
|
28
|
+
const scmDe = (token, owner, repo) => createGithubScm({ link: resolveScmLink({ owner, repo }), token });
|
|
28
29
|
|
|
29
30
|
/** WorkItem → a forma `{number, nodeId, title, labels}` que este arquivo usa. */
|
|
30
31
|
const comoItem = w => w && ({
|
|
@@ -75,8 +76,8 @@ class QaRefusal extends Error {
|
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
async function resolveParentFeature(token, owner, repo, startRef) {
|
|
79
|
-
const tracker = trackerDe(token, owner, repo);
|
|
79
|
+
async function resolveParentFeature(token, owner, repo, startRef, deps = {}) {
|
|
80
|
+
const tracker = deps.tracker ?? (deps.tracker ?? trackerDe(token, owner, repo));
|
|
80
81
|
let current = startRef;
|
|
81
82
|
for (let depth = 0; depth < 5 && current; depth++) {
|
|
82
83
|
const parent = await tracker.getParent({ ref: current });
|
|
@@ -91,9 +92,9 @@ async function resolveParentFeature(token, owner, repo, startRef) {
|
|
|
91
92
|
|
|
92
93
|
// Campos do board, resolvidos uma vez. Best-effort: sem board, os movimentos
|
|
93
94
|
// viram avisos (o veredito e o relatório não dependem dele).
|
|
94
|
-
async function resolveBoard(root, projectToken, token, owner, repo) {
|
|
95
|
+
async function resolveBoard(root, projectToken, token, owner, repo, deps = {}) {
|
|
95
96
|
const { tracker, error } = openTracker({
|
|
96
|
-
token, projectToken, owner, repo, cwd: root || process.cwd(),
|
|
97
|
+
token, projectToken, owner, repo, cwd: root || process.cwd(), tracker: deps.tracker,
|
|
97
98
|
});
|
|
98
99
|
return { tracker, error: error || null };
|
|
99
100
|
}
|
|
@@ -105,9 +106,9 @@ async function readStage(board, number, nodeId) {
|
|
|
105
106
|
.catch(() => null);
|
|
106
107
|
}
|
|
107
108
|
|
|
108
|
-
function headShaOf(root) {
|
|
109
|
+
function headShaOf(root, exec = execSync) {
|
|
109
110
|
try {
|
|
110
|
-
return
|
|
111
|
+
return exec('git rev-parse --short HEAD', {
|
|
111
112
|
cwd: root || process.cwd(), encoding: 'utf-8', stdio: ['ignore', 'pipe', 'ignore'],
|
|
112
113
|
}).trim() || null;
|
|
113
114
|
} catch {
|
|
@@ -123,19 +124,19 @@ function headShaOf(root) {
|
|
|
123
124
|
//
|
|
124
125
|
// Devolve o SHA curto do commit (ou do HEAD, quando não havia nada a commitar
|
|
125
126
|
// — conteúdo idêntico é no-op, não falha), ou null quando o commit falhou.
|
|
126
|
-
function commitLocalPath(root, rel, message) {
|
|
127
|
+
function commitLocalPath(root, rel, message, exec = execSync) {
|
|
127
128
|
const cwd = root || process.cwd();
|
|
128
129
|
try {
|
|
129
|
-
|
|
130
|
-
const staged =
|
|
130
|
+
exec(`git add -A -- ${JSON.stringify(rel)}`, { cwd, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
131
|
+
const staged = exec(`git diff --cached --name-only -- ${JSON.stringify(rel)}`, {
|
|
131
132
|
cwd, encoding: 'utf-8', stdio: ['ignore', 'pipe', 'pipe'],
|
|
132
133
|
}).trim();
|
|
133
134
|
if (staged) {
|
|
134
|
-
|
|
135
|
+
exec(`git commit -m ${JSON.stringify(message)} -- ${JSON.stringify(rel)}`, {
|
|
135
136
|
cwd, stdio: ['ignore', 'pipe', 'pipe'],
|
|
136
137
|
});
|
|
137
138
|
}
|
|
138
|
-
return headShaOf(root) || 'HEAD';
|
|
139
|
+
return headShaOf(root, exec) || 'HEAD';
|
|
139
140
|
} catch (err) {
|
|
140
141
|
console.warn(chalk.yellow(
|
|
141
142
|
`⚠️ ${rel} escrito, mas o commit local falhou (${String(err.message).split('\n')[0]}) — ` +
|
|
@@ -166,7 +167,7 @@ function commitLocalPath(root, rel, message) {
|
|
|
166
167
|
// Exportada para o teste de integração em repositório temporário; `push` é
|
|
167
168
|
// injetável pelo mesmo motivo (o teste não tem remoto).
|
|
168
169
|
export async function publishEvidence({
|
|
169
|
-
root, results, stagingAbs, targetRel, targetAbs, push = pushWithRebase,
|
|
170
|
+
root, results, stagingAbs, targetRel, targetAbs, push = pushWithRebase, exec = execSync,
|
|
170
171
|
}) {
|
|
171
172
|
const cwd = root || process.cwd();
|
|
172
173
|
let copied = 0;
|
|
@@ -203,7 +204,7 @@ export async function publishEvidence({
|
|
|
203
204
|
if (copied === 0 && removed === 0) return null;
|
|
204
205
|
|
|
205
206
|
const sha = commitLocalPath(root, targetRel,
|
|
206
|
-
`docs: evidência visual do QA em ${targetRel} (${copied} arquivo(s)) [spec-wave]
|
|
207
|
+
`docs: evidência visual do QA em ${targetRel} (${copied} arquivo(s)) [spec-wave]`, exec);
|
|
207
208
|
if (!sha) return null;
|
|
208
209
|
if (copied > 0) console.log(`Evidência visual publicada em ${chalk.cyan(targetRel)}/ (${copied} arquivo(s), commit ${sha}).`);
|
|
209
210
|
const pushed = await push({ cwd });
|
|
@@ -213,7 +214,7 @@ export async function publishEvidence({
|
|
|
213
214
|
`${String(pushed.error).split('\n')[0]} — os links do relatório só vão resolver depois do seu push.`
|
|
214
215
|
));
|
|
215
216
|
}
|
|
216
|
-
return headShaOf(root) || sha;
|
|
217
|
+
return headShaOf(root, exec) || sha;
|
|
217
218
|
}
|
|
218
219
|
|
|
219
220
|
function parseOnly(only) {
|
|
@@ -225,8 +226,8 @@ function parseOnly(only) {
|
|
|
225
226
|
return [...new Set(nums)];
|
|
226
227
|
}
|
|
227
228
|
|
|
228
|
-
async function trimmedComments(token, owner, repo, issueNumber, kind) {
|
|
229
|
-
const all = await trackerDe(token, owner, repo).listComments({ ref: { key: String(issueNumber) } }).catch(() => []);
|
|
229
|
+
async function trimmedComments(token, owner, repo, issueNumber, kind, deps = {}) {
|
|
230
|
+
const all = await (deps.tracker ?? (deps.tracker ?? trackerDe(token, owner, repo))).listComments({ ref: { key: String(issueNumber) } }).catch(() => []);
|
|
230
231
|
if (all.length === 0) return { all, groups: [] };
|
|
231
232
|
const items = all.slice(-MAX_COMMENTS).map(c => ({
|
|
232
233
|
// Formas do contrato (`author`, `createdAt`) primeiro, REST crua depois.
|
|
@@ -240,7 +241,18 @@ async function trimmedComments(token, owner, repo, issueNumber, kind) {
|
|
|
240
241
|
return { all, groups: [{ issueNumber, kind, total: all.length, items }] };
|
|
241
242
|
}
|
|
242
243
|
|
|
243
|
-
|
|
244
|
+
/**
|
|
245
|
+
* @param {object} [params]
|
|
246
|
+
* @param {object} [params.deps] seam de teste — `tracker`, `scm`, `exec`, `push`.
|
|
247
|
+
*
|
|
248
|
+
* `trackerDe` é const de TOPO DE MÓDULO, chamada de 20 lugares. A porta viaja
|
|
249
|
+
* no `outcome`, que já é espalhado nas três funções de escrita — um ponto de
|
|
250
|
+
* costura em vez de sete. `deps.exec` é o que impede o teste de RODAR o
|
|
251
|
+
* comando de QA configurado.
|
|
252
|
+
*/
|
|
253
|
+
export async function qaRun({
|
|
254
|
+
issue: issueArg, only: onlyArg, severity: severityArg, dryRun = false, deps = {},
|
|
255
|
+
}) {
|
|
244
256
|
const number = parseInt(String(issueArg).replace('#', ''), 10);
|
|
245
257
|
if (!Number.isInteger(number) || number <= 0) {
|
|
246
258
|
throw new QaRefusal(`Issue inválida: "${issueArg}". Use o número da issue, ex.: 12 ou #12.`);
|
|
@@ -269,7 +281,7 @@ export async function qaRun({ issue: issueArg, only: onlyArg, severity: severity
|
|
|
269
281
|
const token = await resolveToken();
|
|
270
282
|
const projectToken = process.env.PROJECT_TOKEN || token;
|
|
271
283
|
|
|
272
|
-
const issue = comoItem(await trackerDe(token, owner, repo).getWorkItem({ ref: { key: String(number) } }));
|
|
284
|
+
const issue = comoItem(await (deps.tracker ?? trackerDe(token, owner, repo)).getWorkItem({ ref: { key: String(number) } }));
|
|
273
285
|
const type = detectIssueType(issue);
|
|
274
286
|
|
|
275
287
|
// ── Feature dona do plano (Feature/Story) ──────────────────────────────────
|
|
@@ -280,14 +292,14 @@ export async function qaRun({ issue: issueArg, only: onlyArg, severity: severity
|
|
|
280
292
|
labels: labelNames(issue), milestone: issue.milestone || null,
|
|
281
293
|
};
|
|
282
294
|
} else if (type === 'Story') {
|
|
283
|
-
const parent = await resolveParentFeature(token, owner, repo, issue.ref).catch(() => null);
|
|
295
|
+
const parent = await resolveParentFeature(token, owner, repo, issue.ref, deps).catch(() => null);
|
|
284
296
|
if (!parent) {
|
|
285
297
|
throw new QaRefusal(
|
|
286
298
|
`A Story #${number} não tem Feature-pai — o plano de QA é por Feature (D-QA1), ` +
|
|
287
299
|
'e sem ela não há plano a executar. Vincule a Story como sub-issue de uma Feature.'
|
|
288
300
|
);
|
|
289
301
|
}
|
|
290
|
-
const parentIssue = comoItem(await trackerDe(token, owner, repo).getWorkItem({ ref: parent.ref }));
|
|
302
|
+
const parentIssue = comoItem(await (deps.tracker ?? trackerDe(token, owner, repo)).getWorkItem({ ref: parent.ref }));
|
|
291
303
|
feature = {
|
|
292
304
|
number: parent.number, title: parentIssue.title, nodeId: parentIssue.node_id,
|
|
293
305
|
labels: labelNames(parentIssue), milestone: parentIssue.milestone || null,
|
|
@@ -298,7 +310,7 @@ export async function qaRun({ issue: issueArg, only: onlyArg, severity: severity
|
|
|
298
310
|
// item ao Project, que é mutação, e o dry-run promete ZERO escrita. ─────────
|
|
299
311
|
const board = dryRun
|
|
300
312
|
? { tracker: null, error: 'dry-run' }
|
|
301
|
-
: await resolveBoard(root, projectToken, token, owner, repo);
|
|
313
|
+
: await resolveBoard(root, projectToken, token, owner, repo, deps);
|
|
302
314
|
let stage = null;
|
|
303
315
|
if (!dryRun) {
|
|
304
316
|
if (board.error) console.warn(chalk.yellow(`⚠️ ${board.error} — Etapa não verificada e board não será atualizado.`));
|
|
@@ -336,6 +348,7 @@ export async function qaRun({ issue: issueArg, only: onlyArg, severity: severity
|
|
|
336
348
|
if (!existsSync(fileAbs)) {
|
|
337
349
|
const achado = await loadArtifact({
|
|
338
350
|
token, owner, repo, root, pathRel: fileRel, doc: 'bug', issueNumber: number,
|
|
351
|
+
scm: deps.scm ?? null,
|
|
339
352
|
}).catch(() => null);
|
|
340
353
|
if (achado && isAwaitingMerge(achado.state)) {
|
|
341
354
|
const b = awaitingMergeBlock({ pathRel: fileRel, state: achado.state, pr: achado.pr, branch: achado.ref });
|
|
@@ -375,6 +388,7 @@ export async function qaRun({ issue: issueArg, only: onlyArg, severity: severity
|
|
|
375
388
|
evidenceTarget = paths.qaEvidenceDir;
|
|
376
389
|
const plano = await loadArtifact({
|
|
377
390
|
token, owner, repo, root, pathRel: qaPlanRel, doc: 'qa-plan', issueNumber: feature.number,
|
|
391
|
+
scm: deps.scm ?? null,
|
|
378
392
|
}).catch(() => null);
|
|
379
393
|
if (!plano || plano.content == null || plano.state === 'unknown') {
|
|
380
394
|
// `qa-ready` está na Feature (o portão passou), então o plano EXISTE em
|
|
@@ -414,7 +428,7 @@ export async function qaRun({ issue: issueArg, only: onlyArg, severity: severity
|
|
|
414
428
|
// Stories já aprovadas saem do alvo no modo Feature.
|
|
415
429
|
let subStories = [];
|
|
416
430
|
try {
|
|
417
|
-
subStories = (await trackerDe(token, owner, repo).listChildren({ ref: feature.ref ?? { key: String(feature.number), id: feature.nodeId } })).map(comoItem)
|
|
431
|
+
subStories = (await (deps.tracker ?? trackerDe(token, owner, repo)).listChildren({ ref: feature.ref ?? { key: String(feature.number), id: feature.nodeId } })).map(comoItem)
|
|
418
432
|
.filter(s => detectIssueType({ title: s.title, labels: s.labels }) === 'Story');
|
|
419
433
|
} catch (err) {
|
|
420
434
|
console.warn(chalk.yellow(`⚠️ Não foi possível listar as Stories da Feature: ${err.message}.`));
|
|
@@ -458,11 +472,11 @@ export async function qaRun({ issue: issueArg, only: onlyArg, severity: severity
|
|
|
458
472
|
|
|
459
473
|
// ── Estado anterior (relatórios) e contexto ────────────────────────────────
|
|
460
474
|
const { all: allComments, groups: commentGroups } =
|
|
461
|
-
await trimmedComments(token, owner, repo, number, type);
|
|
475
|
+
await trimmedComments(token, owner, repo, number, type, deps);
|
|
462
476
|
const previous = parseLastQaReport(allComments);
|
|
463
477
|
const run = previous.run + 1;
|
|
464
478
|
|
|
465
|
-
const pullRequests = await scmDe(token, owner, repo)
|
|
479
|
+
const pullRequests = await (deps.scm ?? scmDe(token, owner, repo))
|
|
466
480
|
.findPullRequestsReferencing({ ref: issue.ref ?? { key: String(issue.number), id: issue.node_id } })
|
|
467
481
|
.catch(() => []);
|
|
468
482
|
|
|
@@ -533,7 +547,7 @@ export async function qaRun({ issue: issueArg, only: onlyArg, severity: severity
|
|
|
533
547
|
console.log(`\nExecutando: ${chalk.dim(command)}\n`);
|
|
534
548
|
let executorFailed = null;
|
|
535
549
|
try {
|
|
536
|
-
execSync(command, {
|
|
550
|
+
(deps.exec ?? execSync)(command, {
|
|
537
551
|
stdio: 'inherit',
|
|
538
552
|
cwd: root || process.cwd(),
|
|
539
553
|
// §3.1 da spec-qa-lead: a env do PROCESSO vence a `qa.env`, chave a chave
|
|
@@ -590,7 +604,7 @@ export async function qaRun({ issue: issueArg, only: onlyArg, severity: severity
|
|
|
590
604
|
|
|
591
605
|
// headSha = o commit TESTADO (vai no marcador do relatório). O commit da
|
|
592
606
|
// evidência vem depois e só serve os links.
|
|
593
|
-
const headSha = headShaOf(root);
|
|
607
|
+
const headSha = headShaOf(root, deps.exec);
|
|
594
608
|
|
|
595
609
|
// ── Evidência visual → repositório (antes do veredito, nunca o altera) ─────
|
|
596
610
|
let evidenceBase = null;
|
|
@@ -598,6 +612,7 @@ export async function qaRun({ issue: issueArg, only: onlyArg, severity: severity
|
|
|
598
612
|
const evidenceSha = evidenceTarget
|
|
599
613
|
? await publishEvidence({
|
|
600
614
|
root, results, stagingAbs: evidenceAbs, targetRel: evidenceTarget.rel, targetAbs: evidenceTarget.abs,
|
|
615
|
+
push: deps.push, exec: deps.exec,
|
|
601
616
|
})
|
|
602
617
|
: null;
|
|
603
618
|
if (evidenceSha) evidenceBase = { owner, repo, sha: evidenceSha };
|
|
@@ -621,7 +636,7 @@ export async function qaRun({ issue: issueArg, only: onlyArg, severity: severity
|
|
|
621
636
|
|
|
622
637
|
const outcome = {
|
|
623
638
|
token, projectToken, owner, repo, root, config, board, issue, number, type, feature,
|
|
624
|
-
featureStories, evidenceBase,
|
|
639
|
+
featureStories, evidenceBase, deps,
|
|
625
640
|
};
|
|
626
641
|
|
|
627
642
|
let bugs = [];
|
|
@@ -707,7 +722,7 @@ export async function qaRun({ issue: issueArg, only: onlyArg, severity: severity
|
|
|
707
722
|
|
|
708
723
|
async function postReport({
|
|
709
724
|
token, owner, repo, number, type, run, verdict, planSha, headSha, evidenceBase,
|
|
710
|
-
combined, pendingNumbers, bugs, trailer,
|
|
725
|
+
combined, pendingNumbers, bugs, trailer, deps = {},
|
|
711
726
|
}) {
|
|
712
727
|
// Cenário herdado (`--only`) traz links de uma corrida anterior, servidos
|
|
713
728
|
// pelo commit daquela corrida — sem a base desta, cai na branch default.
|
|
@@ -722,7 +737,7 @@ async function postReport({
|
|
|
722
737
|
pendingNumbers,
|
|
723
738
|
trailer,
|
|
724
739
|
});
|
|
725
|
-
await trackerDe(token, owner, repo).addComment({ ref: { key: String(number) }, body: markdown })
|
|
740
|
+
await (deps.tracker ?? trackerDe(token, owner, repo)).addComment({ ref: { key: String(number) }, body: markdown })
|
|
726
741
|
.catch(err => console.warn(chalk.yellow(`⚠️ Falha ao comentar o relatório: ${err.message}`)));
|
|
727
742
|
}
|
|
728
743
|
|
|
@@ -747,7 +762,7 @@ async function stayInQa({ board, issue }) {
|
|
|
747
762
|
// estado que a spec proíbe.
|
|
748
763
|
async function openBugsForFailures({
|
|
749
764
|
token, projectToken, owner, repo, root, board,
|
|
750
|
-
failed, byNumero, severity, headSha, qaPlanRel, feature, evidenceBase,
|
|
765
|
+
failed, byNumero, severity, headSha, qaPlanRel, feature, evidenceBase, deps = {},
|
|
751
766
|
}) {
|
|
752
767
|
const bugs = [];
|
|
753
768
|
const pushFailures = [];
|
|
@@ -758,7 +773,7 @@ async function openBugsForFailures({
|
|
|
758
773
|
|
|
759
774
|
let story = null;
|
|
760
775
|
try {
|
|
761
|
-
story = comoItem(await trackerDe(token, owner, repo).getWorkItem({ ref: { key: String(storyNumber) } }));
|
|
776
|
+
story = comoItem(await (deps.tracker ?? trackerDe(token, owner, repo)).getWorkItem({ ref: { key: String(storyNumber) } }));
|
|
762
777
|
} catch (err) {
|
|
763
778
|
console.warn(chalk.yellow(`⚠️ Não consegui ler a Story #${storyNumber} (${err.message}) — Bug do cenário ${r.numero} NÃO criado.`));
|
|
764
779
|
pushFailures.push({ numero: r.numero, error: `Story #${storyNumber} ilegível: ${err.message}` });
|
|
@@ -767,7 +782,7 @@ async function openBugsForFailures({
|
|
|
767
782
|
|
|
768
783
|
// Idempotência: Bug filho ABERTO com o mesmo marcador de origem → comenta
|
|
769
784
|
// nele em vez de duplicar.
|
|
770
|
-
const children = (await trackerDe(token, owner, repo).listChildren({ ref: story.ref ?? { key: String(story.number), id: story.node_id } }).catch(() => [])).map(comoItem);
|
|
785
|
+
const children = (await (deps.tracker ?? trackerDe(token, owner, repo)).listChildren({ ref: story.ref ?? { key: String(story.number), id: story.node_id } }).catch(() => [])).map(comoItem);
|
|
771
786
|
const existing = children.find(c =>
|
|
772
787
|
detectIssueType({ title: c.title, labels: c.labels }) === 'Bug' &&
|
|
773
788
|
c.state !== 'closed' &&
|
|
@@ -777,7 +792,7 @@ async function openBugsForFailures({
|
|
|
777
792
|
const midia = (r.evidenceFiles || []).length > 0 && evidenceBase
|
|
778
793
|
? `\n\n**Evidência visual:** ${r.evidenceFiles.map(f => `[${f.split('/').pop()}](${evidenceMediaUrl(evidenceBase.owner, evidenceBase.repo, evidenceBase.sha, f)})`).join(' · ')}`
|
|
779
794
|
: '';
|
|
780
|
-
await trackerDe(token, owner, repo).addComment({
|
|
795
|
+
await (deps.tracker ?? trackerDe(token, owner, repo)).addComment({
|
|
781
796
|
ref: { key: String(existing.number) },
|
|
782
797
|
body:
|
|
783
798
|
`🧪 **O cenário ${scenario.numero} da Story #${storyNumber} reprovou de novo** ` +
|
|
@@ -823,12 +838,13 @@ async function openBugsForFailures({
|
|
|
823
838
|
continue;
|
|
824
839
|
}
|
|
825
840
|
const committed = commitLocalPath(root, fileRel,
|
|
826
|
-
`docs: gera ${fileRel} (reprovação de QA, cenário ${scenario.numero} da Story #${storyNumber}) [spec-wave]
|
|
841
|
+
`docs: gera ${fileRel} (reprovação de QA, cenário ${scenario.numero} da Story #${storyNumber}) [spec-wave]`,
|
|
842
|
+
deps.exec);
|
|
827
843
|
if (!committed) {
|
|
828
844
|
pushFailures.push({ numero: r.numero, error: `commit do ${fileRel} falhou` });
|
|
829
845
|
continue;
|
|
830
846
|
}
|
|
831
|
-
const push = await pushWithRebase({ cwd: root || process.cwd() });
|
|
847
|
+
const push = await (deps.push ?? pushWithRebase)({ cwd: root || process.cwd() });
|
|
832
848
|
if (!push.ok) {
|
|
833
849
|
console.warn(chalk.yellow(
|
|
834
850
|
`⚠️ Push do ${fileRel} rejeitado após ${push.attempts} tentativa(s): ` +
|
|
@@ -841,7 +857,7 @@ async function openBugsForFailures({
|
|
|
841
857
|
let created;
|
|
842
858
|
try {
|
|
843
859
|
created = comoItem({
|
|
844
|
-
ref: await trackerDe(token, owner, repo).createWorkItem({
|
|
860
|
+
ref: await (deps.tracker ?? trackerDe(token, owner, repo)).createWorkItem({
|
|
845
861
|
title, body: bodyLines.join('\n'), type: 'Bug', tags: labels,
|
|
846
862
|
milestone: milestone ? { key: String(milestone) } : null,
|
|
847
863
|
}),
|
|
@@ -854,7 +870,7 @@ async function openBugsForFailures({
|
|
|
854
870
|
}
|
|
855
871
|
console.log(`Bug #${created.number} criado para o cenário ${scenario.numero} (filho da Story #${storyNumber}).`);
|
|
856
872
|
|
|
857
|
-
await trackerDe(token, owner, repo).addChild({ parent: story.ref ?? { key: String(story.number), id: story.node_id }, child: created.ref })
|
|
873
|
+
await (deps.tracker ?? trackerDe(token, owner, repo)).addChild({ parent: story.ref ?? { key: String(story.number), id: story.node_id }, child: created.ref })
|
|
858
874
|
.catch(err => console.warn(chalk.yellow(`⚠️ Bug #${created.number} criado, mas não vinculado à Story: ${err.message}`)));
|
|
859
875
|
|
|
860
876
|
// Board: 🧪 QA achou → o Bug nasce em ✅ Ready (triagem já feita pela reprova).
|
|
@@ -877,9 +893,9 @@ async function openBugsForFailures({
|
|
|
877
893
|
|
|
878
894
|
// `bug-approved` direto: reprodução, esperado/obtido e regressão são a
|
|
879
895
|
// execução observada — regerar por IA só introduziria alucinação.
|
|
880
|
-
await trackerDe(token, owner, repo).addTag({ ref: { key: String(created.number) }, tag: LABEL_BUG_APPROVED }).catch(() => {});
|
|
896
|
+
await (deps.tracker ?? trackerDe(token, owner, repo)).addTag({ ref: { key: String(created.number) }, tag: LABEL_BUG_APPROVED }).catch(() => {});
|
|
881
897
|
|
|
882
|
-
await trackerDe(token, owner, repo).addComment({
|
|
898
|
+
await (deps.tracker ?? trackerDe(token, owner, repo)).addComment({
|
|
883
899
|
ref: { key: String(created.number) },
|
|
884
900
|
body:
|
|
885
901
|
`🧪 **Bug aberto pela reprovação de QA** — ${scenario.anchor} da Story #${storyNumber}.\n\n` +
|
|
@@ -898,7 +914,7 @@ async function openBugsForFailures({
|
|
|
898
914
|
// quando todas as Stories liberarem. Guarda dura: Bug filho aberto segura tudo.
|
|
899
915
|
async function applyGreen({
|
|
900
916
|
token, projectToken, owner, repo, board, issue, number, type, feature, combined, byNumero,
|
|
901
|
-
featureStories = [],
|
|
917
|
+
featureStories = [], deps = {},
|
|
902
918
|
}) {
|
|
903
919
|
const move = async (ref, targetStage, itemType) => {
|
|
904
920
|
if (!board.tracker) return false;
|
|
@@ -908,7 +924,7 @@ async function applyGreen({
|
|
|
908
924
|
};
|
|
909
925
|
|
|
910
926
|
if (type === 'Bug') {
|
|
911
|
-
await trackerDe(token, owner, repo).addTag({ ref: { key: String(number) }, tag: LABEL_QA_APPROVED }).catch(() => {});
|
|
927
|
+
await (deps.tracker ?? trackerDe(token, owner, repo)).addTag({ ref: { key: String(number) }, tag: LABEL_QA_APPROVED }).catch(() => {});
|
|
912
928
|
const target = greenTargetStage('Bug');
|
|
913
929
|
try {
|
|
914
930
|
await move(issue.ref, target, 'Bug');
|
|
@@ -920,7 +936,7 @@ async function applyGreen({
|
|
|
920
936
|
}
|
|
921
937
|
|
|
922
938
|
if (type === 'Story') {
|
|
923
|
-
const children = ((await trackerDe(token, owner, repo).listChildren({ ref: issue.ref }).catch(() => [])).map(comoItem))
|
|
939
|
+
const children = ((await (deps.tracker ?? trackerDe(token, owner, repo)).listChildren({ ref: issue.ref }).catch(() => [])).map(comoItem))
|
|
924
940
|
.map(c => ({ ...c, type: detectIssueType({ title: c.title, labels: c.labels }) }));
|
|
925
941
|
const guard = storyCanAdvance({ children });
|
|
926
942
|
if (!guard.ok) {
|
|
@@ -933,7 +949,7 @@ async function applyGreen({
|
|
|
933
949
|
'e rode o `qa` de novo.',
|
|
934
950
|
};
|
|
935
951
|
}
|
|
936
|
-
await trackerDe(token, owner, repo).addTag({ ref: { key: String(number) }, tag: LABEL_QA_APPROVED }).catch(() => {});
|
|
952
|
+
await (deps.tracker ?? trackerDe(token, owner, repo)).addTag({ ref: { key: String(number) }, tag: LABEL_QA_APPROVED }).catch(() => {});
|
|
937
953
|
try {
|
|
938
954
|
await move(issue.ref, STAGE_UAT, 'Story');
|
|
939
955
|
console.log(`Story #${number} → "${STAGE_UAT}" / Status "${PROGRESS_TODO}".`);
|
|
@@ -945,7 +961,7 @@ async function applyGreen({
|
|
|
945
961
|
let featureAdvanced = false;
|
|
946
962
|
if (feature?.nodeId) {
|
|
947
963
|
featureAdvanced = await maybeAdvanceFeature({
|
|
948
|
-
token, projectToken, owner, repo, board, feature, justApproved: number, move,
|
|
964
|
+
token, projectToken, owner, repo, board, feature, justApproved: number, move, deps,
|
|
949
965
|
});
|
|
950
966
|
}
|
|
951
967
|
return {
|
|
@@ -965,14 +981,14 @@ async function applyGreen({
|
|
|
965
981
|
const daStory = combined.filter(r => byNumero.get(r.numero)?.story === story.number);
|
|
966
982
|
if (daStory.length === 0) continue;
|
|
967
983
|
if (!daStory.every(r => r.verdict === 'pass')) continue;
|
|
968
|
-
const children = ((await trackerDe(token, owner, repo).listChildren({ ref: story.ref ?? { key: String(story.number), id: story.nodeId } }).catch(() => [])).map(comoItem))
|
|
984
|
+
const children = ((await (deps.tracker ?? trackerDe(token, owner, repo)).listChildren({ ref: story.ref ?? { key: String(story.number), id: story.nodeId } }).catch(() => [])).map(comoItem))
|
|
969
985
|
.map(c => ({ ...c, type: detectIssueType({ title: c.title, labels: c.labels }) }));
|
|
970
986
|
const guard = storyCanAdvance({ children });
|
|
971
987
|
if (!guard.ok) {
|
|
972
988
|
console.log(chalk.yellow(`Story #${story.number} verde, mas com Bug aberto (${guard.openBugs.map(n => `#${n}`).join(', ')}) — não avança.`));
|
|
973
989
|
continue;
|
|
974
990
|
}
|
|
975
|
-
await trackerDe(token, owner, repo).addTag({ ref: { key: String(story.number) }, tag: LABEL_QA_APPROVED }).catch(() => {});
|
|
991
|
+
await (deps.tracker ?? trackerDe(token, owner, repo)).addTag({ ref: { key: String(story.number) }, tag: LABEL_QA_APPROVED }).catch(() => {});
|
|
976
992
|
try {
|
|
977
993
|
await move(story.ref ?? { key: String(story.number), id: story.nodeId }, STAGE_UAT, 'Story');
|
|
978
994
|
console.log(`Story #${story.number} → "${STAGE_UAT}".`);
|
|
@@ -984,7 +1000,7 @@ async function applyGreen({
|
|
|
984
1000
|
|
|
985
1001
|
const featureAdvanced = await maybeAdvanceFeature({
|
|
986
1002
|
token, projectToken, owner, repo, board, feature,
|
|
987
|
-
justApproved: approvedNow, move,
|
|
1003
|
+
justApproved: approvedNow, move, deps,
|
|
988
1004
|
});
|
|
989
1005
|
return {
|
|
990
1006
|
trailer:
|
|
@@ -998,11 +1014,11 @@ async function applyGreen({
|
|
|
998
1014
|
|
|
999
1015
|
// A Feature avança quando TODAS as Stories têm qa-approved ou já estão em
|
|
1000
1016
|
// Homologação+ — mesma regra do Code Review (spec §6.3).
|
|
1001
|
-
async function maybeAdvanceFeature({ token, projectToken, owner, repo, board, feature, justApproved, move }) {
|
|
1017
|
+
async function maybeAdvanceFeature({ token, projectToken, owner, repo, board, feature, justApproved, move, deps = {} }) {
|
|
1002
1018
|
const aprovadas = new Set(Array.isArray(justApproved) ? justApproved : [justApproved]);
|
|
1003
1019
|
let stories = [];
|
|
1004
1020
|
try {
|
|
1005
|
-
stories = ((await trackerDe(token, owner, repo).listChildren({ ref: feature.ref ?? { key: String(feature.number), id: feature.nodeId } })).map(comoItem))
|
|
1021
|
+
stories = ((await (deps.tracker ?? trackerDe(token, owner, repo)).listChildren({ ref: feature.ref ?? { key: String(feature.number), id: feature.nodeId } })).map(comoItem))
|
|
1006
1022
|
.filter(s => detectIssueType({ title: s.title, labels: s.labels }) === 'Story');
|
|
1007
1023
|
} catch {
|
|
1008
1024
|
return false; // sem a lista, na dúvida a Feature não avança
|
|
@@ -1023,7 +1039,7 @@ async function maybeAdvanceFeature({ token, projectToken, owner, repo, board, fe
|
|
|
1023
1039
|
}
|
|
1024
1040
|
return false;
|
|
1025
1041
|
}
|
|
1026
|
-
await trackerDe(token, owner, repo).addTag({ ref: { key: String(feature.number) }, tag: LABEL_QA_APPROVED }).catch(() => {});
|
|
1042
|
+
await (deps.tracker ?? trackerDe(token, owner, repo)).addTag({ ref: { key: String(feature.number) }, tag: LABEL_QA_APPROVED }).catch(() => {});
|
|
1027
1043
|
try {
|
|
1028
1044
|
await move(feature.ref ?? { key: String(feature.number), id: feature.nodeId }, STAGE_UAT, 'Feature');
|
|
1029
1045
|
console.log(`Feature #${feature.number} → "${STAGE_UAT}".`);
|
package/src/commands/qa.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { resolveToken } from '../api/auth.mjs';
|
|
2
2
|
import { createGithubTracker } from '../plugins/tracker-github-projects/index.mjs';
|
|
3
|
-
import { createGithubScm
|
|
3
|
+
import { createGithubScm } from '../plugins/scm-github/index.mjs';
|
|
4
|
+
import { resolveScmLink } from '../ports/index.mjs';
|
|
4
5
|
import { detectIssueType } from '../lib/issue-type.mjs';
|
|
5
6
|
import { openTracker, advanceToStage } from '../lib/board.mjs';
|
|
6
7
|
import { resolveHubContext, resolvePrRepo } from '../lib/project-root.mjs';
|
|
@@ -54,7 +55,7 @@ export async function qa({ prNumber, prRepo: prRepoOpt, deps = {} }) {
|
|
|
54
55
|
// A porta do PR é a do repositório DELE (RFC-005): `--pr-repo` pode apontar
|
|
55
56
|
// para um repo de código, e o número de PR colide entre repositórios.
|
|
56
57
|
const prScm = deps.scm ?? createGithubScm({
|
|
57
|
-
link:
|
|
58
|
+
link: resolveScmLink({ owner: prRepo.owner, repo: prRepo.repo, role: 'code' }), token,
|
|
58
59
|
});
|
|
59
60
|
const pr = await prScm.getPullRequest({ number: String(prNum) });
|
|
60
61
|
// Mesmo parser e mesma régua do code-review: o vínculo que levou a Story a
|
package/src/commands/repo.mjs
CHANGED
|
@@ -8,7 +8,8 @@ import * as p from '@clack/prompts';
|
|
|
8
8
|
import chalk from 'chalk';
|
|
9
9
|
import { resolveToken } from '../api/auth.mjs';
|
|
10
10
|
import { createGithubTracker } from '../plugins/tracker-github-projects/index.mjs';
|
|
11
|
-
import { createGithubScm
|
|
11
|
+
import { createGithubScm } from '../plugins/scm-github/index.mjs';
|
|
12
|
+
import { resolveScmLink } from '../ports/index.mjs';
|
|
12
13
|
import { resolveHubContext } from '../lib/project-root.mjs';
|
|
13
14
|
import { updateConfig } from '../lib/config-file.mjs';
|
|
14
15
|
import {
|
|
@@ -77,7 +78,7 @@ export async function repoCommand({ action, slug, repo: repoArg, dryRun = false,
|
|
|
77
78
|
// Sonda de ALCANCE, não leitura: o que importa é se o token enxerga o
|
|
78
79
|
// repositório-alvo antes de o hub passar a apontar para ele.
|
|
79
80
|
const alvo = await createGithubScm({
|
|
80
|
-
link:
|
|
81
|
+
link: resolveScmLink({ owner: target.owner, repo: target.repo, role: 'code' }), token,
|
|
81
82
|
}).verify();
|
|
82
83
|
if (!alvo.ok) throw new Error(alvo.problems.join('; '));
|
|
83
84
|
} catch (err) {
|
package/src/commands/run.mjs
CHANGED
|
@@ -21,7 +21,8 @@ import chalk from 'chalk';
|
|
|
21
21
|
|
|
22
22
|
import { resolveToken } from '../api/auth.mjs';
|
|
23
23
|
import { createGithubTracker } from '../plugins/tracker-github-projects/index.mjs';
|
|
24
|
-
import { createGithubScm
|
|
24
|
+
import { createGithubScm } from '../plugins/scm-github/index.mjs';
|
|
25
|
+
import { resolveScmLink } from '../ports/index.mjs';
|
|
25
26
|
import { trackerAvailable } from '../lib/board.mjs';
|
|
26
27
|
import { loadArtifact } from '../lib/doc-source.mjs';
|
|
27
28
|
import { featureDocPaths, bugDocPaths } from '../lib/doc-paths.mjs';
|
|
@@ -341,7 +342,7 @@ async function runForPr({ prNumber, dryRun, yes, only, json }) {
|
|
|
341
342
|
const token = await resolveToken();
|
|
342
343
|
const n = parseInt(prNumber, 10);
|
|
343
344
|
|
|
344
|
-
const scm = createGithubScm({ link:
|
|
345
|
+
const scm = createGithubScm({ link: resolveScmLink({ owner, repo }), token });
|
|
345
346
|
const pr = await scm.getPullRequest({ number: String(n) });
|
|
346
347
|
const reviews = await scm.listPullRequestReviews({ number: String(n) });
|
|
347
348
|
const verdict = reviewVerdict(reviews);
|
|
@@ -5,7 +5,8 @@ import path from 'node:path';
|
|
|
5
5
|
import { resolveToken } from '../api/auth.mjs';
|
|
6
6
|
import { CONFIG_FILE, ALL_LABELS, WORKFLOW_FILES, ISSUE_TEMPLATE_FILES } from '../config.mjs';
|
|
7
7
|
import { createGithubTracker } from '../plugins/tracker-github-projects/index.mjs';
|
|
8
|
-
import { createGithubScm
|
|
8
|
+
import { createGithubScm } from '../plugins/scm-github/index.mjs';
|
|
9
|
+
import { resolveScmLink } from '../ports/index.mjs';
|
|
9
10
|
|
|
10
11
|
const REPO_FILES = [
|
|
11
12
|
...WORKFLOW_FILES.map(f => `.github/workflows/${f}`),
|
|
@@ -82,7 +83,7 @@ export async function uninstall(options = {}) {
|
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
const tracker = createGithubTracker({ token, owner, repo });
|
|
85
|
-
const scm = createGithubScm({ link:
|
|
86
|
+
const scm = createGithubScm({ link: resolveScmLink({ owner, repo }), token });
|
|
86
87
|
|
|
87
88
|
// --- Labels ---
|
|
88
89
|
if (doLabels) {
|
package/src/commands/update.mjs
CHANGED
|
@@ -6,7 +6,8 @@ import path from 'node:path';
|
|
|
6
6
|
import { resolveToken } from '../api/auth.mjs';
|
|
7
7
|
import { CONFIG_FILE, WORKFLOW_FILES, CODE_WORKFLOW_FILES, ISSUE_TEMPLATE_FILES, ALL_LABELS, allLabelsFor } from '../config.mjs';
|
|
8
8
|
import { createGithubTracker } from '../plugins/tracker-github-projects/index.mjs';
|
|
9
|
-
import { createGithubScm
|
|
9
|
+
import { createGithubScm } from '../plugins/scm-github/index.mjs';
|
|
10
|
+
import { resolveScmLink } from '../ports/index.mjs';
|
|
10
11
|
import {
|
|
11
12
|
resolveBranchName, composePrTitle, composePrBody, buildCommitMessage,
|
|
12
13
|
decideConfigInPr, decideSkillInPr, composeConfigCleanupHint, explainGitWriteError,
|
|
@@ -248,7 +249,7 @@ async function buildConfigContent(token, config) {
|
|
|
248
249
|
* revisa, e ele não pode prometer o que falhou.
|
|
249
250
|
*/
|
|
250
251
|
/** Porta de SCM do repositório-alvo. Memoizada por token: `tk` é lazy. */
|
|
251
|
-
const scmDe = (tk, owner, repo) => createGithubScm({ link:
|
|
252
|
+
const scmDe = (tk, owner, repo) => createGithubScm({ link: resolveScmLink({ owner, repo }), token: tk });
|
|
252
253
|
|
|
253
254
|
async function applyLabels(token, owner, repo, labelDiff, forceLabels = false) {
|
|
254
255
|
const tracker = createGithubTracker({ token, owner, repo });
|
|
@@ -15,7 +15,8 @@ import { docBlobUrl } from '../lib/repo-links.mjs';
|
|
|
15
15
|
import { loadArtifact } from '../lib/doc-source.mjs';
|
|
16
16
|
import { awaitingMergeBlock } from '../lib/artifact-pr.mjs';
|
|
17
17
|
import { isAwaitingMerge } from '../lib/doc-source.mjs';
|
|
18
|
-
import { createGithubScm
|
|
18
|
+
import { createGithubScm } from '../plugins/scm-github/index.mjs';
|
|
19
|
+
import { resolveScmLink } from '../ports/index.mjs';
|
|
19
20
|
import { dependencySection } from '../lib/spec-audit.mjs';
|
|
20
21
|
|
|
21
22
|
/**
|
|
@@ -176,7 +177,7 @@ export async function validate({ issueNumber, deps = {} }) {
|
|
|
176
177
|
|
|
177
178
|
const n = parseInt(issueNumber, 10);
|
|
178
179
|
const tracker = deps.tracker ?? createGithubTracker({ token, owner, repo });
|
|
179
|
-
const scm = deps.scm ?? createGithubScm({ link:
|
|
180
|
+
const scm = deps.scm ?? createGithubScm({ link: resolveScmLink({ owner, repo }), token });
|
|
180
181
|
const issue = await tracker.getWorkItem({ ref: { key: String(n) } });
|
|
181
182
|
|
|
182
183
|
// Branch base para a leitura em camadas. Best-effort: sem ela o resolvedor cai
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
// deixaria no clone um arquivo que o usuário não pediu e que colide no `git pull`
|
|
23
23
|
// depois do merge — justamente porque o merge pode trazer as edições do revisor.
|
|
24
24
|
|
|
25
|
-
import { createGithubScm
|
|
25
|
+
import { createGithubScm } from '../plugins/scm-github/index.mjs';
|
|
26
|
+
import { resolveScmLink } from '../ports/index.mjs';
|
|
26
27
|
import { resolveBranchName, explainGitWriteError } from './pr-branch.mjs';
|
|
27
28
|
import {
|
|
28
29
|
artifactBranch, composeArtifactPrTitle, composeArtifactPrBody, artifactCommitMessage,
|
|
@@ -88,7 +89,7 @@ export async function publishArtifact({
|
|
|
88
89
|
// já sabe que só `ensurePullRequest` usa essa credencial. A política de qual
|
|
89
90
|
// token abre PR continua visível aqui, que é onde ela sempre esteve.
|
|
90
91
|
const porta = scm || createGithubScm({
|
|
91
|
-
link:
|
|
92
|
+
link: resolveScmLink({ owner, repo }), token, prToken: resolvePrToken(token),
|
|
92
93
|
});
|
|
93
94
|
|
|
94
95
|
const branch = artifactBranch({ issueNumber, doc });
|
package/src/lib/critique.mjs
CHANGED
|
@@ -922,6 +922,16 @@ export async function runCritique({
|
|
|
922
922
|
kind, spec, specs, plan, techContextYaml, decomposition, qaPlan, bugDoc, bugReport,
|
|
923
923
|
attempt = 1, maxAttempts = DEFAULT_MAX_CRITIQUE_ATTEMPTS,
|
|
924
924
|
model, labels = [], usage, cwd, decisions = null, standalone = false,
|
|
925
|
+
// Seam de teste, no PONTO DO MODELO e não na função inteira: assim o que roda
|
|
926
|
+
// nos testes é a crítica REAL — construção do prompt, `downgradeUnsupportedFindings`
|
|
927
|
+
// e `renderCritiqueMarkdown` — sobre um modelo falso. Trocar a `runCritique`
|
|
928
|
+
// toda deixaria justamente essa lógica sem exercício, e ela é a que produz o
|
|
929
|
+
// TEXTO que vai para a issue.
|
|
930
|
+
//
|
|
931
|
+
// A crítica é a SEGUNDA chamada de modelo do fluxo, e é fácil esquecer dela:
|
|
932
|
+
// costurar só o `generateDocument` deixava `generate-bug` levando 25 s de rede
|
|
933
|
+
// dentro da suíte, pagando um modelo de verdade.
|
|
934
|
+
gerarEstruturado = generateStructured,
|
|
925
935
|
} = {}) {
|
|
926
936
|
const sections = [];
|
|
927
937
|
if (spec) sections.push(`## spec.md\n\n${spec}`);
|
|
@@ -961,7 +971,7 @@ export async function runCritique({
|
|
|
961
971
|
if (decisoesBloco) sections.push(decisoesBloco);
|
|
962
972
|
const userContent = sections.join('\n\n') || '(nenhum documento fornecido)';
|
|
963
973
|
|
|
964
|
-
const report = await
|
|
974
|
+
const report = await gerarEstruturado(buildSystemPrompt(kind, cwd), userContent, {
|
|
965
975
|
action: 'critique',
|
|
966
976
|
temperature: 0,
|
|
967
977
|
schema: {
|
package/src/lib/doc-source.mjs
CHANGED
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
import { existsSync, readFileSync } from 'node:fs';
|
|
21
21
|
import path from 'node:path';
|
|
22
22
|
|
|
23
|
-
import { createGithubScm
|
|
23
|
+
import { createGithubScm } from '../plugins/scm-github/index.mjs';
|
|
24
|
+
import { resolveScmLink } from '../ports/index.mjs';
|
|
24
25
|
import { artifactBranch } from './artifact-pr.mjs';
|
|
25
26
|
|
|
26
27
|
/**
|
|
@@ -93,7 +94,7 @@ export async function loadArtifact({
|
|
|
93
94
|
if (!token || !owner || !repo) {
|
|
94
95
|
return { content: null, state: 'unknown', ref: null, pr: null };
|
|
95
96
|
}
|
|
96
|
-
const porta = scm || createGithubScm({ link:
|
|
97
|
+
const porta = scm || createGithubScm({ link: resolveScmLink({ owner, repo }), token });
|
|
97
98
|
|
|
98
99
|
let naBase;
|
|
99
100
|
try {
|
|
@@ -96,6 +96,10 @@ export function planBoardMoves(phase, {
|
|
|
96
96
|
*/
|
|
97
97
|
export async function applyBoardMoves({
|
|
98
98
|
token, moves, cwd = process.cwd(), log = p.log, dryRun = false,
|
|
99
|
+
// Passthrough de porta, como `loadBoardSnapshot` e `cachedSubIssues`. Sem
|
|
100
|
+
// ele o `implement` não tem teste de caminho fora do dry-run: cada movimento
|
|
101
|
+
// construía a porta real, e a falha era engolida pelo `try` abaixo.
|
|
102
|
+
tracker: trackerInjetado = null,
|
|
99
103
|
}) {
|
|
100
104
|
if (!moves || moves.length === 0) return;
|
|
101
105
|
if (dryRun) {
|
|
@@ -109,6 +113,7 @@ export async function applyBoardMoves({
|
|
|
109
113
|
// src/plugins/tracker-github-projects/index.mjs.
|
|
110
114
|
const { tracker, error } = openTracker({
|
|
111
115
|
token, projectToken: process.env.PROJECT_TOKEN || token, cwd,
|
|
116
|
+
tracker: trackerInjetado,
|
|
112
117
|
});
|
|
113
118
|
if (error) {
|
|
114
119
|
log.warn(`board: ${error} — Etapas não atualizadas.`);
|