@bbcsoftwarefactory/cli 0.1.1 → 1.1.2
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/dist/audit-ledger.d.ts +2 -0
- package/dist/audit-ledger.js +71 -0
- package/dist/bbc-install.d.ts +2 -0
- package/dist/bbc-install.js +1250 -0
- package/dist/bbc.js +87 -3
- package/dist/change-lane/classification.js +3 -1
- package/dist/check-issue-claim.d.ts +2 -0
- package/dist/check-issue-claim.js +146 -0
- package/dist/check-worktree-guard.d.ts +2 -0
- package/dist/check-worktree-guard.js +114 -0
- package/dist/error-scan.d.ts +3 -0
- package/dist/error-scan.js +216 -0
- package/dist/export-public.d.ts +9 -0
- package/dist/export-public.js +274 -0
- package/dist/fetch-issue-attachments.d.ts +22 -0
- package/dist/fetch-issue-attachments.js +325 -0
- package/dist/issue-claim/evaluation.d.ts +66 -0
- package/dist/issue-claim/evaluation.js +259 -0
- package/dist/issue-claim/loaders.d.ts +5 -0
- package/dist/issue-claim/loaders.js +116 -0
- package/dist/list-zed-commands.d.ts +7 -0
- package/dist/list-zed-commands.js +288 -0
- package/dist/plan-issue-triage.d.ts +3 -0
- package/dist/plan-issue-triage.js +404 -0
- package/dist/question-gate/ledger.d.ts +5 -0
- package/dist/question-gate/ledger.js +115 -0
- package/dist/question-gate/rules.d.ts +40 -0
- package/dist/question-gate/rules.js +483 -0
- package/dist/recap/board.d.ts +5 -0
- package/dist/recap/board.js +384 -0
- package/dist/recap/git-and-github.d.ts +11 -0
- package/dist/recap/git-and-github.js +620 -0
- package/dist/recap/report-and-hud.d.ts +2 -0
- package/dist/recap/report-and-hud.js +294 -0
- package/dist/recap/time-and-refs.d.ts +27 -0
- package/dist/recap/time-and-refs.js +148 -0
- package/dist/recap.d.ts +2 -0
- package/dist/recap.js +217 -0
- package/dist/render-workflow.js +12 -14
- package/dist/resolve-containers.d.ts +2 -0
- package/dist/resolve-containers.js +96 -0
- package/dist/review-loop.d.ts +7 -0
- package/dist/review-loop.js +622 -0
- package/dist/save-counts.d.ts +2 -0
- package/dist/save-counts.js +191 -0
- package/dist/summarize-logs.d.ts +2 -0
- package/dist/summarize-logs.js +41 -0
- package/dist/sweep-github.d.ts +10 -0
- package/dist/sweep-github.js +453 -0
- package/dist/sweep-issues.d.ts +56 -0
- package/dist/sweep-issues.js +650 -0
- package/dist/sweep.d.ts +2 -0
- package/dist/sweep.js +301 -0
- package/dist/triage-question.d.ts +2 -0
- package/dist/triage-question.js +189 -0
- package/dist/validate-skills.d.ts +2 -0
- package/dist/validate-skills.js +48 -0
- package/dist/watch-live.d.ts +7 -0
- package/dist/watch-live.js +83 -0
- package/dist/watcher/config.d.ts +11 -0
- package/dist/watcher/config.js +265 -0
- package/dist/watcher/live-classifier.d.ts +52 -0
- package/dist/watcher/live-classifier.js +510 -0
- package/dist/watcher/safe-fs.d.ts +9 -0
- package/dist/watcher/safe-fs.js +159 -0
- package/dist/watcher/stream.d.ts +27 -0
- package/dist/watcher/stream.js +340 -0
- package/dist/watcher/summarizer.d.ts +19 -0
- package/dist/watcher/summarizer.js +121 -0
- package/dist/wave3/process.d.ts +14 -0
- package/dist/wave3/process.js +84 -0
- package/dist/wave4/process.d.ts +14 -0
- package/dist/wave4/process.js +128 -0
- package/dist/workflow/render.d.ts +1 -1
- package/dist/workflow/render.js +1 -1
- package/dist/workflow-auditor/audit.d.ts +27 -0
- package/dist/workflow-auditor/audit.js +583 -0
- package/dist/workflow-auditor/ledger-io.d.ts +5 -0
- package/dist/workflow-auditor/ledger-io.js +99 -0
- package/dist/workflow-auditor/skills-validator.d.ts +10 -0
- package/dist/workflow-auditor/skills-validator.js +533 -0
- package/dist/worktree-guard/evaluation.d.ts +19 -0
- package/dist/worktree-guard/evaluation.js +84 -0
- package/dist/worktree-guard/git.d.ts +3 -0
- package/dist/worktree-guard/git.js +61 -0
- package/package.json +32 -33
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LAYER: Application
|
|
3
|
+
* Contains: GitHub Project v2 board analyzer, sync planner, and sync applier.
|
|
4
|
+
* Rules: Never mutate boards unless explicitly invoked through applyBoardSync without dry-run.
|
|
5
|
+
* BigO: O(n) score:4
|
|
6
|
+
* keywords: [ProjectBoardSync, StatusMismatch, BoardPlan, RepoLabel]
|
|
7
|
+
* GOAL: Summarize Project v2 board alignment and optionally synchronize items, colors, and labels.
|
|
8
|
+
*/
|
|
9
|
+
import { apiJson, graphql } from "./git-and-github.js";
|
|
10
|
+
const STANDARD_STATUS_COLORS = {
|
|
11
|
+
backlog: 'GRAY',
|
|
12
|
+
todo: 'GRAY',
|
|
13
|
+
ready: 'BLUE',
|
|
14
|
+
'in progress': 'YELLOW',
|
|
15
|
+
'in review': 'PURPLE',
|
|
16
|
+
done: 'GREEN',
|
|
17
|
+
};
|
|
18
|
+
const PALETTE_COLORS = ['BLUE', 'PURPLE', 'PINK', 'ORANGE', 'YELLOW', 'GREEN', 'RED'];
|
|
19
|
+
export function inferBoardStatus(item, statusOptions) {
|
|
20
|
+
const byName = new Map();
|
|
21
|
+
for (const opt of statusOptions) {
|
|
22
|
+
if (opt && typeof opt === 'object' && typeof opt.name === 'string' && opt.id) {
|
|
23
|
+
byName.set(opt.name.trim().toLowerCase(), opt);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const state = String(item.state ?? item.github_state ?? '').trim().toLowerCase();
|
|
27
|
+
const isPr = Boolean(item.is_pr ||
|
|
28
|
+
item.merged_at ||
|
|
29
|
+
item.type === 'PullRequest' ||
|
|
30
|
+
String(item.url ?? '').includes('/pull/'));
|
|
31
|
+
const candidates = state === 'closed' || state === 'merged' || item.merged
|
|
32
|
+
? ['done']
|
|
33
|
+
: isPr
|
|
34
|
+
? ['in review', 'in progress', 'ready']
|
|
35
|
+
: ['ready', 'backlog', 'in progress'];
|
|
36
|
+
for (const name of candidates) {
|
|
37
|
+
const found = byName.get(name);
|
|
38
|
+
if (found)
|
|
39
|
+
return found;
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
export function inferRepoLabel(title, existingLabels) {
|
|
44
|
+
const available = new Map();
|
|
45
|
+
for (const lbl of existingLabels) {
|
|
46
|
+
available.set(String(lbl).trim().toLowerCase(), lbl);
|
|
47
|
+
}
|
|
48
|
+
const low = (title ?? '').trim().toLowerCase();
|
|
49
|
+
if (low.startsWith('fix') && available.has('bug'))
|
|
50
|
+
return available.get('bug');
|
|
51
|
+
if (low.startsWith('feat') && available.has('enhancement'))
|
|
52
|
+
return available.get('enhancement');
|
|
53
|
+
if (low.startsWith('docs') && available.has('documentation'))
|
|
54
|
+
return available.get('documentation');
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
function buildFieldColorUpdate(fld) {
|
|
58
|
+
if (fld.dataType !== 'SINGLE_SELECT')
|
|
59
|
+
return null;
|
|
60
|
+
const options = (fld.options ?? []).filter((o) => o !== null && typeof o === 'object' && Boolean(o.id));
|
|
61
|
+
if (options.length === 0)
|
|
62
|
+
return null;
|
|
63
|
+
const fname = String(fld.name ?? '').trim().toLowerCase();
|
|
64
|
+
if (fname === 'status') {
|
|
65
|
+
const newOpts = options.map((opt) => ({
|
|
66
|
+
id: opt.id,
|
|
67
|
+
name: opt.name,
|
|
68
|
+
color: STANDARD_STATUS_COLORS[String(opt.name ?? '').trim().toLowerCase()] ?? opt.color ?? 'GRAY',
|
|
69
|
+
description: opt.description ?? '',
|
|
70
|
+
}));
|
|
71
|
+
const changed = newOpts.some((n, idx) => n.color !== options[idx]?.color);
|
|
72
|
+
return changed ? { field_id: fld.id, field_name: fld.name, options: newOpts } : null;
|
|
73
|
+
}
|
|
74
|
+
if (options.every((o) => (o.color ?? 'GRAY') === 'GRAY')) {
|
|
75
|
+
const newOpts = options.map((opt, idx) => ({
|
|
76
|
+
id: opt.id,
|
|
77
|
+
name: opt.name,
|
|
78
|
+
color: PALETTE_COLORS[idx % PALETTE_COLORS.length],
|
|
79
|
+
description: opt.description ?? '',
|
|
80
|
+
}));
|
|
81
|
+
return { field_id: fld.id, field_name: fld.name, options: newOpts };
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
function buildBoardViewFields(fields, targetView) {
|
|
86
|
+
if (!targetView || targetView.layout !== 'BOARD_LAYOUT')
|
|
87
|
+
return null;
|
|
88
|
+
const byName = new Map();
|
|
89
|
+
for (const f of fields) {
|
|
90
|
+
if (typeof f.id === 'string' && typeof f.name === 'string') {
|
|
91
|
+
byName.set(f.name.trim().toLowerCase(), f.id);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const desired = [];
|
|
95
|
+
for (const key of ['title', 'assignees', 'labels', 'linked pull requests', 'priority']) {
|
|
96
|
+
const id = byName.get(key);
|
|
97
|
+
if (id)
|
|
98
|
+
desired.push(id);
|
|
99
|
+
}
|
|
100
|
+
for (const fld of fields) {
|
|
101
|
+
const name = String(fld.name ?? '').trim().toLowerCase();
|
|
102
|
+
if (fld.dataType === 'SINGLE_SELECT' && !['status', 'priority', 'size'].includes(name)) {
|
|
103
|
+
if (typeof fld.id === 'string' && !desired.includes(fld.id)) {
|
|
104
|
+
desired.push(fld.id);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return desired.length > 0 ? { view_id: targetView.id, visible_field_ids: desired } : null;
|
|
109
|
+
}
|
|
110
|
+
export function summarizeProjectBoard(projectData, activityItems, defaultRepo) {
|
|
111
|
+
if (!projectData || !projectData.available) {
|
|
112
|
+
return {
|
|
113
|
+
available: false,
|
|
114
|
+
gap: projectData?.gap ?? 'Project unavailable',
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
const items = (projectData.items ?? []).filter((it) => it !== null && typeof it === 'object');
|
|
118
|
+
const statusCounts = {};
|
|
119
|
+
const byAssignee = {};
|
|
120
|
+
const boardKeys = new Set();
|
|
121
|
+
const statusMismatches = [];
|
|
122
|
+
for (const it of items) {
|
|
123
|
+
const status = String(it.status ?? 'Sin estado');
|
|
124
|
+
statusCounts[status] = (statusCounts[status] ?? 0) + 1;
|
|
125
|
+
const assignees = Array.isArray(it.assignees) && it.assignees.length > 0 ? it.assignees : ['unassigned'];
|
|
126
|
+
for (const login of assignees) {
|
|
127
|
+
if (!byAssignee[login])
|
|
128
|
+
byAssignee[login] = {};
|
|
129
|
+
byAssignee[login][status] = (byAssignee[login][status] ?? 0) + 1;
|
|
130
|
+
}
|
|
131
|
+
const repo = it.repo;
|
|
132
|
+
const num = it.number;
|
|
133
|
+
if (repo && num !== null && num !== undefined) {
|
|
134
|
+
boardKeys.add(`${repo}#${String(num)}`);
|
|
135
|
+
}
|
|
136
|
+
const ghState = String(it.state ?? '').toUpperCase();
|
|
137
|
+
if ((ghState === 'CLOSED' || ghState === 'MERGED') && status !== 'Done') {
|
|
138
|
+
statusMismatches.push({
|
|
139
|
+
item_id: it.id,
|
|
140
|
+
repo,
|
|
141
|
+
number: num,
|
|
142
|
+
title: it.title ?? '',
|
|
143
|
+
github_state: ghState.toLowerCase(),
|
|
144
|
+
board_status: status,
|
|
145
|
+
url: it.url,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
else if (ghState === 'OPEN' && status === 'Done') {
|
|
149
|
+
statusMismatches.push({
|
|
150
|
+
item_id: it.id,
|
|
151
|
+
repo,
|
|
152
|
+
number: num,
|
|
153
|
+
title: it.title ?? '',
|
|
154
|
+
github_state: 'open',
|
|
155
|
+
board_status: status,
|
|
156
|
+
url: it.url,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const missingFromBoard = [];
|
|
161
|
+
const seenMissing = new Set();
|
|
162
|
+
for (const act of activityItems ?? []) {
|
|
163
|
+
if (!act || typeof act !== 'object')
|
|
164
|
+
continue;
|
|
165
|
+
const repo = act.repo ?? defaultRepo;
|
|
166
|
+
const num = act.number;
|
|
167
|
+
if (!repo || num === null || num === undefined)
|
|
168
|
+
continue;
|
|
169
|
+
const key = `${repo}#${String(num)}`;
|
|
170
|
+
if (boardKeys.has(key) || seenMissing.has(key))
|
|
171
|
+
continue;
|
|
172
|
+
seenMissing.add(key);
|
|
173
|
+
missingFromBoard.push({
|
|
174
|
+
repo,
|
|
175
|
+
number: num,
|
|
176
|
+
title: act.title ?? '',
|
|
177
|
+
state: act.state ?? (act.closed_at ? 'closed' : ''),
|
|
178
|
+
is_pr: Boolean(act.is_pr || act.merged_at || String(act.url ?? '').includes('/pull/')),
|
|
179
|
+
merged_at: act.merged_at ?? null,
|
|
180
|
+
url: act.url ?? null,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
available: true,
|
|
185
|
+
title: projectData.title ?? null,
|
|
186
|
+
url: projectData.url ?? null,
|
|
187
|
+
view: projectData.view ?? null,
|
|
188
|
+
view_name: projectData.view_name ?? null,
|
|
189
|
+
total_items: items.length,
|
|
190
|
+
status_counts: statusCounts,
|
|
191
|
+
by_assignee: byAssignee,
|
|
192
|
+
missing_from_board: missingFromBoard,
|
|
193
|
+
status_mismatches: statusMismatches,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
export function planBoardSync(boardSummary, projectMeta, fixColors = false) {
|
|
197
|
+
const fields = (projectMeta.fields ?? []);
|
|
198
|
+
const statusField = fields.find((f) => String(f.name ?? '').trim().toLowerCase() === 'status');
|
|
199
|
+
const statusOptions = (statusField?.options ?? []);
|
|
200
|
+
const statusFieldId = statusField?.id ?? null;
|
|
201
|
+
const adds = (boardSummary.missing_from_board ?? []).map((miss) => {
|
|
202
|
+
const opt = inferBoardStatus(miss, statusOptions);
|
|
203
|
+
return {
|
|
204
|
+
repo: miss.repo,
|
|
205
|
+
number: miss.number,
|
|
206
|
+
title: miss.title ?? '',
|
|
207
|
+
state: miss.state ?? '',
|
|
208
|
+
is_pr: Boolean(miss.is_pr),
|
|
209
|
+
url: miss.url,
|
|
210
|
+
target_status: opt ? opt.name : null,
|
|
211
|
+
status_option_id: opt ? opt.id : null,
|
|
212
|
+
};
|
|
213
|
+
});
|
|
214
|
+
const moves = [];
|
|
215
|
+
for (const mm of boardSummary.status_mismatches ?? []) {
|
|
216
|
+
if (mm.github_state !== 'closed' && mm.github_state !== 'merged')
|
|
217
|
+
continue;
|
|
218
|
+
const opt = inferBoardStatus({ state: mm.github_state, url: mm.url }, statusOptions);
|
|
219
|
+
if (!opt || opt.name === mm.board_status)
|
|
220
|
+
continue;
|
|
221
|
+
moves.push({
|
|
222
|
+
item_id: mm.item_id,
|
|
223
|
+
repo: mm.repo,
|
|
224
|
+
number: mm.number,
|
|
225
|
+
title: mm.title ?? '',
|
|
226
|
+
from_status: mm.board_status,
|
|
227
|
+
target_status: opt.name,
|
|
228
|
+
status_option_id: opt.id,
|
|
229
|
+
url: mm.url,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
const colorUpdates = fixColors
|
|
233
|
+
? fields.map((f) => buildFieldColorUpdate(f)).filter((u) => u !== null)
|
|
234
|
+
: [];
|
|
235
|
+
const viewUpdate = fixColors
|
|
236
|
+
? buildBoardViewFields(fields, projectMeta.target_view)
|
|
237
|
+
: null;
|
|
238
|
+
return {
|
|
239
|
+
project_id: projectMeta.project_id ?? null,
|
|
240
|
+
status_field_id: statusFieldId,
|
|
241
|
+
adds,
|
|
242
|
+
moves,
|
|
243
|
+
color_updates: colorUpdates,
|
|
244
|
+
view_update: viewUpdate,
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
function resolveContentNodeId(repoSlug, number) {
|
|
248
|
+
if (!repoSlug || !repoSlug.includes('/') || number === null || number === undefined)
|
|
249
|
+
return null;
|
|
250
|
+
const slashIdx = repoSlug.indexOf('/');
|
|
251
|
+
const owner = repoSlug.slice(0, slashIdx);
|
|
252
|
+
const name = repoSlug.slice(slashIdx + 1);
|
|
253
|
+
const q = `query($owner: String!, $name: String!, $number: Int!) {
|
|
254
|
+
repository(owner: $owner, name: $name) {
|
|
255
|
+
issueOrPullRequest(number: $number) {
|
|
256
|
+
... on Issue { id }
|
|
257
|
+
... on PullRequest { id }
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}`;
|
|
261
|
+
const data = graphql(q, { owner, name, number: Number(number) });
|
|
262
|
+
const node = data.repository?.issueOrPullRequest ?? {};
|
|
263
|
+
return typeof node.id === 'string' ? node.id : null;
|
|
264
|
+
}
|
|
265
|
+
export function applyBoardSync(plan, dryRun = false, applyLabels = false) {
|
|
266
|
+
const adds = plan.adds ?? [];
|
|
267
|
+
const moves = plan.moves ?? [];
|
|
268
|
+
const colorUpdates = plan.color_updates ?? [];
|
|
269
|
+
if (dryRun) {
|
|
270
|
+
return {
|
|
271
|
+
dry_run: true,
|
|
272
|
+
planned_adds: adds.length,
|
|
273
|
+
planned_moves: moves.length,
|
|
274
|
+
planned_color_updates: colorUpdates.length,
|
|
275
|
+
planned_view_update: Boolean(plan.view_update),
|
|
276
|
+
adds,
|
|
277
|
+
moves,
|
|
278
|
+
color_updates: colorUpdates.map((c) => c.field_name),
|
|
279
|
+
errors: [],
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
const projectId = plan.project_id;
|
|
283
|
+
const statusFieldId = plan.status_field_id;
|
|
284
|
+
if (!projectId) {
|
|
285
|
+
return { dry_run: false, errors: ['Missing project_id for board sync'] };
|
|
286
|
+
}
|
|
287
|
+
const mAdd = `mutation($p: ID!, $cid: ID!) {
|
|
288
|
+
addProjectV2ItemById(input: {projectId: $p, contentId: $cid}) { item { id } }
|
|
289
|
+
}`;
|
|
290
|
+
const mSet = `mutation($p: ID!, $i: ID!, $f: ID!, $v: String!) {
|
|
291
|
+
updateProjectV2ItemFieldValue(input: {projectId: $p, itemId: $i, fieldId: $f, value: {singleSelectOptionId: $v}}) {
|
|
292
|
+
projectV2Item { id }
|
|
293
|
+
}
|
|
294
|
+
}`;
|
|
295
|
+
const mFld = `mutation($fieldId: ID!, $opts: [ProjectV2SingleSelectFieldOptionInput!]!) {
|
|
296
|
+
updateProjectV2Field(input: {fieldId: $fieldId, singleSelectOptions: $opts}) {
|
|
297
|
+
projectV2Field { ... on ProjectV2SingleSelectField { id } }
|
|
298
|
+
}
|
|
299
|
+
}`;
|
|
300
|
+
const mView = `mutation($viewId: ID!, $fields: [ID!]!) {
|
|
301
|
+
updateProjectV2View(input: {viewId: $viewId, configuration: {visibleFieldIds: $fields}}) {
|
|
302
|
+
projectV2View { id }
|
|
303
|
+
}
|
|
304
|
+
}`;
|
|
305
|
+
const added = [];
|
|
306
|
+
const moved = [];
|
|
307
|
+
const colorsUpdated = [];
|
|
308
|
+
const labelsAdded = [];
|
|
309
|
+
let viewUpdated = false;
|
|
310
|
+
const errors = [];
|
|
311
|
+
for (const cu of colorUpdates) {
|
|
312
|
+
try {
|
|
313
|
+
graphql(mFld, { fieldId: cu.field_id, opts: cu.options });
|
|
314
|
+
colorsUpdated.push(String(cu.field_name));
|
|
315
|
+
}
|
|
316
|
+
catch (error) {
|
|
317
|
+
errors.push(`color ${String(cu.field_name)}: ${error instanceof Error ? error.message : String(error)}`);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
const vu = plan.view_update;
|
|
321
|
+
if (vu) {
|
|
322
|
+
try {
|
|
323
|
+
graphql(mView, { viewId: vu.view_id, fields: vu.visible_field_ids });
|
|
324
|
+
viewUpdated = true;
|
|
325
|
+
}
|
|
326
|
+
catch (error) {
|
|
327
|
+
errors.push(`view: ${error instanceof Error ? error.message : String(error)}`);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
const repoLabelsCache = new Map();
|
|
331
|
+
for (const item of adds) {
|
|
332
|
+
try {
|
|
333
|
+
const cid = resolveContentNodeId(item.repo, item.number);
|
|
334
|
+
if (!cid) {
|
|
335
|
+
errors.push(`node_id not found for ${String(item.repo)}#${String(item.number)}`);
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
const res = graphql(mAdd, { p: projectId, cid });
|
|
339
|
+
const newId = res.addProjectV2ItemById?.item?.id;
|
|
340
|
+
if (newId && statusFieldId && item.status_option_id) {
|
|
341
|
+
graphql(mSet, { p: projectId, i: newId, f: statusFieldId, v: item.status_option_id });
|
|
342
|
+
}
|
|
343
|
+
added.push(`${String(item.repo)}#${String(item.number)} -> ${String(item.target_status)}`);
|
|
344
|
+
if (applyLabels && typeof item.repo === 'string' && item.number !== null && item.number !== undefined) {
|
|
345
|
+
let repoLabels = repoLabelsCache.get(item.repo);
|
|
346
|
+
if (!repoLabels) {
|
|
347
|
+
const rawLbls = apiJson(`repos/${item.repo}/labels?per_page=100`);
|
|
348
|
+
repoLabels = Array.isArray(rawLbls)
|
|
349
|
+
? rawLbls.filter((l) => l !== null && typeof l === 'object' && typeof l.name === 'string').map((l) => l.name)
|
|
350
|
+
: [];
|
|
351
|
+
repoLabelsCache.set(item.repo, repoLabels);
|
|
352
|
+
}
|
|
353
|
+
const lbl = inferRepoLabel(item.title, repoLabels);
|
|
354
|
+
if (lbl) {
|
|
355
|
+
apiJson(`repos/${item.repo}/issues/${String(item.number)}/labels`, 'POST', { labels: [lbl] });
|
|
356
|
+
labelsAdded.push(`${item.repo}#${String(item.number)}:${lbl}`);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
catch (error) {
|
|
361
|
+
errors.push(`add ${String(item.repo)}#${String(item.number)}: ${error instanceof Error ? error.message : String(error)}`);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
for (const mv of moves) {
|
|
365
|
+
if (!mv.item_id || !statusFieldId || !mv.status_option_id)
|
|
366
|
+
continue;
|
|
367
|
+
try {
|
|
368
|
+
graphql(mSet, { p: projectId, i: mv.item_id, f: statusFieldId, v: mv.status_option_id });
|
|
369
|
+
moved.push(`${String(mv.repo)}#${String(mv.number)}: ${String(mv.from_status)} -> ${String(mv.target_status)}`);
|
|
370
|
+
}
|
|
371
|
+
catch (error) {
|
|
372
|
+
errors.push(`move ${String(mv.repo)}#${String(mv.number)}: ${error instanceof Error ? error.message : String(error)}`);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return {
|
|
376
|
+
dry_run: false,
|
|
377
|
+
added,
|
|
378
|
+
moved,
|
|
379
|
+
colors_updated: colorsUpdated,
|
|
380
|
+
view_updated: viewUpdated,
|
|
381
|
+
labels_added: labelsAdded,
|
|
382
|
+
errors,
|
|
383
|
+
};
|
|
384
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ProjectRef, type SinceDate } from './time-and-refs.ts';
|
|
2
|
+
export declare function ghApiJson(endpoint: string, method?: string, body?: unknown): unknown;
|
|
3
|
+
export declare function ghGraphql(query: string, variables?: Record<string, unknown>): Record<string, unknown>;
|
|
4
|
+
declare function ghGraphqlSafe(query: string, variables?: Record<string, unknown>): Record<string, unknown>;
|
|
5
|
+
declare function ghApiJsonSafe(endpoint: string, method?: string, body?: unknown): unknown;
|
|
6
|
+
export { ghApiJsonSafe as apiJson, ghGraphqlSafe as graphql };
|
|
7
|
+
export declare function collectLocalGit(cwd: string, sinceDt: SinceDate, authorPattern?: string): Record<string, unknown>;
|
|
8
|
+
export declare function collectGithub(repo: string | null, allRepos: boolean, sinceDt: SinceDate, userOverride?: string | null): Record<string, unknown>;
|
|
9
|
+
export declare function collectProjectBoard(projectRef: ProjectRef): Record<string, unknown>;
|
|
10
|
+
export declare function collectTeamMembers(org: string | null, usersArg?: string | null): string[];
|
|
11
|
+
export declare function collectTeamRecaps(members: readonly string[], targetRepo: string | null, allRepos: boolean, sinceDt: SinceDate, cachedGh?: Record<string, unknown>): readonly [Record<string, unknown>[], Record<string, unknown>[]];
|