github-issue-tower-defence-management 1.44.2 → 1.44.3
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/CHANGELOG.md +9 -0
- package/README.md +1 -1
- package/bin/adapter/entry-points/cli/index.js +15 -224
- package/bin/adapter/entry-points/cli/index.js.map +1 -1
- package/bin/adapter/entry-points/cli/projectConfig.js +254 -0
- package/bin/adapter/entry-points/cli/projectConfig.js.map +1 -0
- package/bin/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.js +57 -5
- package/bin/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.js.map +1 -1
- package/package.json +1 -1
- package/src/adapter/entry-points/cli/index.ts +15 -329
- package/src/adapter/entry-points/cli/projectConfig.ts +329 -0
- package/src/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.test.ts +144 -5
- package/src/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.ts +78 -5
- package/types/adapter/entry-points/cli/index.d.ts +1 -25
- package/types/adapter/entry-points/cli/index.d.ts.map +1 -1
- package/types/adapter/entry-points/cli/projectConfig.d.ts +26 -0
- package/types/adapter/entry-points/cli/projectConfig.d.ts.map +1 -0
- package/types/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.d.ts.map +1 -1
|
@@ -41,6 +41,7 @@ const __typia_transform__validateReport = __importStar(require("typia/lib/intern
|
|
|
41
41
|
const yaml_1 = __importDefault(require("yaml"));
|
|
42
42
|
const typia_1 = __importDefault(require("typia"));
|
|
43
43
|
const fs_1 = __importDefault(require("fs"));
|
|
44
|
+
const projectConfig_1 = require("../cli/projectConfig");
|
|
44
45
|
const SystemDateRepository_1 = require("../../repositories/SystemDateRepository");
|
|
45
46
|
const LocalStorageRepository_1 = require("../../repositories/LocalStorageRepository");
|
|
46
47
|
const GoogleSpreadsheetRepository_1 = require("../../repositories/GoogleSpreadsheetRepository");
|
|
@@ -362,6 +363,57 @@ class HandleScheduledEventUseCaseHandler {
|
|
|
362
363
|
if (input.disabled) {
|
|
363
364
|
return null;
|
|
364
365
|
}
|
|
366
|
+
const managerToken = input.credentials.manager.github.token;
|
|
367
|
+
const readme = await (0, projectConfig_1.fetchProjectReadme)(input.projectUrl, managerToken);
|
|
368
|
+
const readmeConfig = readme ? (0, projectConfig_1.parseProjectReadmeConfig)(readme) : {};
|
|
369
|
+
const mergedInput = {
|
|
370
|
+
...input,
|
|
371
|
+
allowIssueCacheMinutes: readmeConfig.allowIssueCacheMinutes ?? input.allowIssueCacheMinutes,
|
|
372
|
+
startPreparation: input.startPreparation
|
|
373
|
+
? {
|
|
374
|
+
...input.startPreparation,
|
|
375
|
+
awaitingWorkspaceStatus: readmeConfig.awaitingWorkspaceStatus ??
|
|
376
|
+
input.startPreparation.awaitingWorkspaceStatus,
|
|
377
|
+
preparationStatus: readmeConfig.preparationStatus ??
|
|
378
|
+
input.startPreparation.preparationStatus,
|
|
379
|
+
defaultAgentName: readmeConfig.defaultAgentName ??
|
|
380
|
+
input.startPreparation.defaultAgentName,
|
|
381
|
+
defaultLlmModelName: readmeConfig.defaultLlmModelName ??
|
|
382
|
+
input.startPreparation.defaultLlmModelName,
|
|
383
|
+
defaultLlmAgentName: readmeConfig.defaultLlmAgentName ??
|
|
384
|
+
input.startPreparation.defaultLlmAgentName,
|
|
385
|
+
maximumPreparingIssuesCount: readmeConfig.maximumPreparingIssuesCount ??
|
|
386
|
+
input.startPreparation.maximumPreparingIssuesCount,
|
|
387
|
+
utilizationPercentageThreshold: readmeConfig.utilizationPercentageThreshold ??
|
|
388
|
+
input.startPreparation.utilizationPercentageThreshold,
|
|
389
|
+
allowedIssueAuthors: readmeConfig.allowedIssueAuthors
|
|
390
|
+
? readmeConfig.allowedIssueAuthors
|
|
391
|
+
.split(',')
|
|
392
|
+
.map((s) => s.trim())
|
|
393
|
+
.filter(Boolean)
|
|
394
|
+
: input.startPreparation.allowedIssueAuthors,
|
|
395
|
+
preparationProcessCheckCommand: readmeConfig.preparationProcessCheckCommand ??
|
|
396
|
+
input.startPreparation.preparationProcessCheckCommand,
|
|
397
|
+
codexHomeCandidates: readmeConfig.codexHomeCandidates ??
|
|
398
|
+
input.startPreparation.codexHomeCandidates,
|
|
399
|
+
}
|
|
400
|
+
: input.startPreparation,
|
|
401
|
+
notifyFinishedPreparation: input.notifyFinishedPreparation
|
|
402
|
+
? {
|
|
403
|
+
...input.notifyFinishedPreparation,
|
|
404
|
+
awaitingWorkspaceStatus: readmeConfig.awaitingWorkspaceStatus ??
|
|
405
|
+
input.notifyFinishedPreparation.awaitingWorkspaceStatus,
|
|
406
|
+
preparationStatus: readmeConfig.preparationStatus ??
|
|
407
|
+
input.notifyFinishedPreparation.preparationStatus,
|
|
408
|
+
awaitingQualityCheckStatus: readmeConfig.awaitingQualityCheckStatus ??
|
|
409
|
+
input.notifyFinishedPreparation.awaitingQualityCheckStatus,
|
|
410
|
+
thresholdForAutoReject: readmeConfig.thresholdForAutoReject ??
|
|
411
|
+
input.notifyFinishedPreparation.thresholdForAutoReject,
|
|
412
|
+
workflowBlockerResolvedWebhookUrl: readmeConfig.workflowBlockerResolvedWebhookUrl ??
|
|
413
|
+
input.notifyFinishedPreparation.workflowBlockerResolvedWebhookUrl,
|
|
414
|
+
}
|
|
415
|
+
: input.notifyFinishedPreparation,
|
|
416
|
+
};
|
|
365
417
|
const systemDateRepository = new SystemDateRepository_1.SystemDateRepository();
|
|
366
418
|
const localStorageRepository = new LocalStorageRepository_1.LocalStorageRepository();
|
|
367
419
|
const googleSpreadsheetRepository = new GoogleSpreadsheetRepository_1.GoogleSpreadsheetRepository(localStorageRepository, input.credentials.manager.googleServiceAccount.serviceAccountKey);
|
|
@@ -407,15 +459,15 @@ class HandleScheduledEventUseCaseHandler {
|
|
|
407
459
|
const notifyFinishedIssuePreparationUseCase = new NotifyFinishedIssuePreparationUseCase_1.NotifyFinishedIssuePreparationUseCase(projectRepository, issueRepository, issueCommentRepository, webhookRepository);
|
|
408
460
|
const revertOrphanedPreparationUseCase = new RevertOrphanedPreparationUseCase_1.RevertOrphanedPreparationUseCase(projectRepository, issueRepository, nodeLocalCommandRunner);
|
|
409
461
|
const handleScheduledEventUseCase = new HandleScheduledEventUseCase_1.HandleScheduledEventUseCase(actionAnnouncement, setWorkflowManagementIssueToStoryUseCase, clearPastNextActionUseCase, analyzeProblemByIssueUseCase, analyzeStoriesUseCase, clearDependedIssueURLUseCase, createEstimationIssueUseCase, convertCheckboxToIssueInStoryIssueUseCase, changeStatusByStoryColorUseCase, setNoStoryIssueToStoryUseCase, createNewStoryByLabel, assignNoAssigneeIssueToManagerUseCase, updateIssueStatusByLabelUseCase, startPreparationUseCase, notifyFinishedIssuePreparationUseCase, revertOrphanedPreparationUseCase, systemDateRepository, googleSpreadsheetRepository, projectRepository, issueRepository);
|
|
410
|
-
const result = await handleScheduledEventUseCase.run(
|
|
462
|
+
const result = await handleScheduledEventUseCase.run(mergedInput);
|
|
411
463
|
if (result) {
|
|
412
464
|
const projectId = result.project.id;
|
|
413
465
|
const runtimeConfig = {
|
|
414
466
|
resolvedAt: new Date().toISOString(),
|
|
415
|
-
maximumPreparingIssuesCount:
|
|
416
|
-
utilizationPercentageThreshold:
|
|
417
|
-
allowIssueCacheMinutes:
|
|
418
|
-
thresholdForAutoReject:
|
|
467
|
+
maximumPreparingIssuesCount: mergedInput.startPreparation?.maximumPreparingIssuesCount ?? null,
|
|
468
|
+
utilizationPercentageThreshold: mergedInput.startPreparation?.utilizationPercentageThreshold ?? 90,
|
|
469
|
+
allowIssueCacheMinutes: mergedInput.allowIssueCacheMinutes,
|
|
470
|
+
thresholdForAutoReject: mergedInput.notifyFinishedPreparation?.thresholdForAutoReject ?? 3,
|
|
419
471
|
};
|
|
420
472
|
const finalPath = `${cachePath}/runtimeConfig-${projectId}.json`;
|
|
421
473
|
const tmpPath = `${finalPath}.tmp`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HandleScheduledEventUseCaseHandler.js","sourceRoot":"","sources":["../../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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAA2B,KAAK,EAAE,EAAE,CACjG,CAAC;YACJ,CAAC;YACD,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;gBACnB,OAAO,IAAI,CAAC;YACd,CAAC;
|
|
1
|
+
{"version":3,"file":"HandleScheduledEventUseCaseHandler.js","sourceRoot":"","sources":["../../../../src/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAwB;AACxB,kDAA0B;AAC1B,4CAAoB;AACpB,wDAG8B;AAC9B,kFAA+E;AAC/E,sFAAmF;AACnF,gGAA6F;AAC7F,0FAAuF;AACvF,wFAAqF;AACrF,sFAAmF;AACnF,wGAAqG;AACrG,8GAA2G;AAC3G,sGAAmG;AACnG,gGAA6F;AAC7F,kGAA+F;AAC/F,gIAA6H;AAC7H,oHAAiH;AACjH,wGAAqG;AAIrG,0FAAuF;AACvF,wGAAqG;AACrG,wGAAqG;AACrG,kIAA+H;AAC/H,8GAA2G;AAC3G,0GAAuG;AACvG,wGAAqG;AACrG,0FAAuF;AAEvF,0HAAuH;AACvH,8GAA2G;AAC3G,8FAA2F;AAC3F,sFAAmF;AACnF,oGAAiG;AACjG,0HAAuH;AACvH,gHAA6G;AAC7G,kGAA+F;AAC/F,sFAAmF;AAEnF,MAAa,kCAAkC;IAA/C;QACE,WAAM,GAAG,KAAK,EACZ,cAAsB,EACtB,QAAiB,EAMT,EAAE;YACV,MAAM,iBAAiB,GAAG,YAAE,CAAC,YAAY,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;YAClE,MAAM,KAAK,GAAY,cAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;YAyBrD,IAAI,ijIAAqB,KAAK,CAAC,EAAE,CAAC;gBAChC,MAAM,I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I,IAAI;oBACnE,8BAA8B,EAC5B,WAAW,CAAC,gBAAgB,EAAE,8BAA8B,IAAI,EAAE;oBACpE,sBAAsB,EAAE,WAAW,CAAC,sBAAsB;oBAC1D,sBAAsB,EACpB,WAAW,CAAC,yBAAyB,EAAE,sBAAsB,IAAI,CAAC;iBACrE,CAAC;gBACF,MAAM,SAAS,GAAG,GAAG,SAAS,kBAAkB,SAAS,OAAO,CAAC;gBACjE,MAAM,OAAO,GAAG,GAAG,SAAS,MAAM,CAAC;gBACnC,YAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC7C,YAAE,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC;gBACzD,YAAE,CAAC,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;YACpC,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;IACJ,CAAC;CAAA;AA9QD,gFA8QC"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import YAML from 'yaml';
|
|
3
|
-
import { Command } from 'commander';
|
|
4
2
|
import * as fs from 'fs';
|
|
3
|
+
import { Command } from 'commander';
|
|
5
4
|
import { HandleScheduledEventUseCaseHandler } from '../handlers/HandleScheduledEventUseCaseHandler';
|
|
5
|
+
export {
|
|
6
|
+
ConfigFile,
|
|
7
|
+
loadConfigFile,
|
|
8
|
+
parseProjectReadmeConfig,
|
|
9
|
+
mergeConfigs,
|
|
10
|
+
fetchProjectReadme,
|
|
11
|
+
} from './projectConfig';
|
|
12
|
+
import {
|
|
13
|
+
ConfigFile,
|
|
14
|
+
loadConfigFile,
|
|
15
|
+
parseProjectReadmeConfig,
|
|
16
|
+
mergeConfigs,
|
|
17
|
+
fetchProjectReadme,
|
|
18
|
+
} from './projectConfig';
|
|
6
19
|
import { StartPreparationUseCase } from '../../../domain/usecases/StartPreparationUseCase';
|
|
7
20
|
import { NotifyFinishedIssuePreparationUseCase } from '../../../domain/usecases/NotifyFinishedIssuePreparationUseCase';
|
|
8
21
|
import { LocalStorageRepository } from '../../repositories/LocalStorageRepository';
|
|
@@ -21,27 +34,6 @@ import { FetchWebhookRepository } from '../../repositories/FetchWebhookRepositor
|
|
|
21
34
|
import { RevertOrphanedPreparationUseCase } from '../../../domain/usecases/RevertOrphanedPreparationUseCase';
|
|
22
35
|
import { Project } from '../../../domain/entities/Project';
|
|
23
36
|
|
|
24
|
-
type ConfigFile = {
|
|
25
|
-
projectUrl?: string;
|
|
26
|
-
awaitingWorkspaceStatus?: string;
|
|
27
|
-
preparationStatus?: string;
|
|
28
|
-
defaultAgentName?: string;
|
|
29
|
-
defaultLlmModelName?: string;
|
|
30
|
-
defaultLlmAgentName?: string;
|
|
31
|
-
maximumPreparingIssuesCount?: number;
|
|
32
|
-
allowIssueCacheMinutes?: number;
|
|
33
|
-
utilizationPercentageThreshold?: number;
|
|
34
|
-
allowedIssueAuthors?: string;
|
|
35
|
-
awaitingQualityCheckStatus?: string;
|
|
36
|
-
thresholdForAutoReject?: number;
|
|
37
|
-
workflowBlockerResolvedWebhookUrl?: string;
|
|
38
|
-
projectName?: string;
|
|
39
|
-
preparationProcessCheckCommand?: string;
|
|
40
|
-
codexHomeCandidates?: string[];
|
|
41
|
-
awLogDirectoryPath?: string;
|
|
42
|
-
awLogStaleThresholdMinutes?: number;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
37
|
type StartDaemonOptions = {
|
|
46
38
|
projectUrl?: string;
|
|
47
39
|
awaitingWorkspaceStatus?: string;
|
|
@@ -68,312 +60,6 @@ type NotifyFinishedOptions = {
|
|
|
68
60
|
configFilePath: string;
|
|
69
61
|
};
|
|
70
62
|
|
|
71
|
-
const getStringValue = (
|
|
72
|
-
obj: Record<string, unknown>,
|
|
73
|
-
key: string,
|
|
74
|
-
): string | undefined => {
|
|
75
|
-
const value = obj[key];
|
|
76
|
-
return typeof value === 'string' ? value : undefined;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const getNumberValue = (
|
|
80
|
-
obj: Record<string, unknown>,
|
|
81
|
-
key: string,
|
|
82
|
-
): number | undefined => {
|
|
83
|
-
const value = obj[key];
|
|
84
|
-
return typeof value === 'number' ? value : undefined;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const getStringArrayValue = (
|
|
88
|
-
obj: Record<string, unknown>,
|
|
89
|
-
key: string,
|
|
90
|
-
): string[] | undefined => {
|
|
91
|
-
const value = obj[key];
|
|
92
|
-
if (!Array.isArray(value)) {
|
|
93
|
-
return undefined;
|
|
94
|
-
}
|
|
95
|
-
const strings: string[] = [];
|
|
96
|
-
for (const item of value) {
|
|
97
|
-
if (typeof item !== 'string') {
|
|
98
|
-
return undefined;
|
|
99
|
-
}
|
|
100
|
-
strings.push(item);
|
|
101
|
-
}
|
|
102
|
-
return strings;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
106
|
-
typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
107
|
-
|
|
108
|
-
export const loadConfigFile = (configFilePath: string): ConfigFile => {
|
|
109
|
-
try {
|
|
110
|
-
const content = fs.readFileSync(configFilePath, 'utf-8');
|
|
111
|
-
const parsed: unknown = YAML.parse(content);
|
|
112
|
-
if (!isRecord(parsed)) {
|
|
113
|
-
return {};
|
|
114
|
-
}
|
|
115
|
-
return {
|
|
116
|
-
projectUrl: getStringValue(parsed, 'projectUrl'),
|
|
117
|
-
awaitingWorkspaceStatus: getStringValue(
|
|
118
|
-
parsed,
|
|
119
|
-
'awaitingWorkspaceStatus',
|
|
120
|
-
),
|
|
121
|
-
preparationStatus: getStringValue(parsed, 'preparationStatus'),
|
|
122
|
-
defaultAgentName: getStringValue(parsed, 'defaultAgentName'),
|
|
123
|
-
defaultLlmModelName: getStringValue(parsed, 'defaultLlmModelName'),
|
|
124
|
-
defaultLlmAgentName: getStringValue(parsed, 'defaultLlmAgentName'),
|
|
125
|
-
maximumPreparingIssuesCount: getNumberValue(
|
|
126
|
-
parsed,
|
|
127
|
-
'maximumPreparingIssuesCount',
|
|
128
|
-
),
|
|
129
|
-
allowIssueCacheMinutes: getNumberValue(parsed, 'allowIssueCacheMinutes'),
|
|
130
|
-
utilizationPercentageThreshold: getNumberValue(
|
|
131
|
-
parsed,
|
|
132
|
-
'utilizationPercentageThreshold',
|
|
133
|
-
),
|
|
134
|
-
allowedIssueAuthors: getStringValue(parsed, 'allowedIssueAuthors'),
|
|
135
|
-
awaitingQualityCheckStatus: getStringValue(
|
|
136
|
-
parsed,
|
|
137
|
-
'awaitingQualityCheckStatus',
|
|
138
|
-
),
|
|
139
|
-
thresholdForAutoReject: getNumberValue(parsed, 'thresholdForAutoReject'),
|
|
140
|
-
workflowBlockerResolvedWebhookUrl: getStringValue(
|
|
141
|
-
parsed,
|
|
142
|
-
'workflowBlockerResolvedWebhookUrl',
|
|
143
|
-
),
|
|
144
|
-
projectName: getStringValue(parsed, 'projectName'),
|
|
145
|
-
preparationProcessCheckCommand: getStringValue(
|
|
146
|
-
parsed,
|
|
147
|
-
'preparationProcessCheckCommand',
|
|
148
|
-
),
|
|
149
|
-
codexHomeCandidates: getStringArrayValue(parsed, 'codexHomeCandidates'),
|
|
150
|
-
awLogDirectoryPath: getStringValue(parsed, 'awLogDirectoryPath'),
|
|
151
|
-
awLogStaleThresholdMinutes: getNumberValue(
|
|
152
|
-
parsed,
|
|
153
|
-
'awLogStaleThresholdMinutes',
|
|
154
|
-
),
|
|
155
|
-
};
|
|
156
|
-
} catch (error) {
|
|
157
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
158
|
-
console.error(
|
|
159
|
-
`Failed to load configuration file "${configFilePath}": ${message}`,
|
|
160
|
-
);
|
|
161
|
-
process.exit(1);
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
export const parseProjectReadmeConfig = (readme: string): ConfigFile => {
|
|
166
|
-
const detailsRegex =
|
|
167
|
-
/<details>\s*<summary>config<\/summary>([\s\S]*?)<\/details>/i;
|
|
168
|
-
const match = detailsRegex.exec(readme);
|
|
169
|
-
if (!match) {
|
|
170
|
-
return {};
|
|
171
|
-
}
|
|
172
|
-
const yamlContent = match[1].trim();
|
|
173
|
-
if (!yamlContent) {
|
|
174
|
-
return {};
|
|
175
|
-
}
|
|
176
|
-
try {
|
|
177
|
-
const parsed: unknown = YAML.parse(yamlContent);
|
|
178
|
-
if (!isRecord(parsed)) {
|
|
179
|
-
return {};
|
|
180
|
-
}
|
|
181
|
-
return {
|
|
182
|
-
awaitingWorkspaceStatus: getStringValue(
|
|
183
|
-
parsed,
|
|
184
|
-
'awaitingWorkspaceStatus',
|
|
185
|
-
),
|
|
186
|
-
preparationStatus: getStringValue(parsed, 'preparationStatus'),
|
|
187
|
-
defaultAgentName: getStringValue(parsed, 'defaultAgentName'),
|
|
188
|
-
defaultLlmModelName: getStringValue(parsed, 'defaultLlmModelName'),
|
|
189
|
-
defaultLlmAgentName: getStringValue(parsed, 'defaultLlmAgentName'),
|
|
190
|
-
maximumPreparingIssuesCount: getNumberValue(
|
|
191
|
-
parsed,
|
|
192
|
-
'maximumPreparingIssuesCount',
|
|
193
|
-
),
|
|
194
|
-
allowIssueCacheMinutes: getNumberValue(parsed, 'allowIssueCacheMinutes'),
|
|
195
|
-
utilizationPercentageThreshold: getNumberValue(
|
|
196
|
-
parsed,
|
|
197
|
-
'utilizationPercentageThreshold',
|
|
198
|
-
),
|
|
199
|
-
allowedIssueAuthors: getStringValue(parsed, 'allowedIssueAuthors'),
|
|
200
|
-
awaitingQualityCheckStatus: getStringValue(
|
|
201
|
-
parsed,
|
|
202
|
-
'awaitingQualityCheckStatus',
|
|
203
|
-
),
|
|
204
|
-
thresholdForAutoReject: getNumberValue(parsed, 'thresholdForAutoReject'),
|
|
205
|
-
workflowBlockerResolvedWebhookUrl: getStringValue(
|
|
206
|
-
parsed,
|
|
207
|
-
'workflowBlockerResolvedWebhookUrl',
|
|
208
|
-
),
|
|
209
|
-
preparationProcessCheckCommand: getStringValue(
|
|
210
|
-
parsed,
|
|
211
|
-
'preparationProcessCheckCommand',
|
|
212
|
-
),
|
|
213
|
-
codexHomeCandidates: getStringArrayValue(parsed, 'codexHomeCandidates'),
|
|
214
|
-
awLogDirectoryPath: getStringValue(parsed, 'awLogDirectoryPath'),
|
|
215
|
-
awLogStaleThresholdMinutes: getNumberValue(
|
|
216
|
-
parsed,
|
|
217
|
-
'awLogStaleThresholdMinutes',
|
|
218
|
-
),
|
|
219
|
-
};
|
|
220
|
-
} catch {
|
|
221
|
-
console.warn('Failed to parse YAML from project README config section');
|
|
222
|
-
return {};
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
export const mergeConfigs = (
|
|
227
|
-
configFile: ConfigFile,
|
|
228
|
-
cliOverrides: ConfigFile,
|
|
229
|
-
readmeOverrides: ConfigFile,
|
|
230
|
-
): ConfigFile => ({
|
|
231
|
-
projectUrl: cliOverrides.projectUrl ?? configFile.projectUrl,
|
|
232
|
-
awaitingWorkspaceStatus:
|
|
233
|
-
readmeOverrides.awaitingWorkspaceStatus ??
|
|
234
|
-
cliOverrides.awaitingWorkspaceStatus ??
|
|
235
|
-
configFile.awaitingWorkspaceStatus,
|
|
236
|
-
preparationStatus:
|
|
237
|
-
readmeOverrides.preparationStatus ??
|
|
238
|
-
cliOverrides.preparationStatus ??
|
|
239
|
-
configFile.preparationStatus,
|
|
240
|
-
defaultAgentName:
|
|
241
|
-
readmeOverrides.defaultAgentName ??
|
|
242
|
-
cliOverrides.defaultAgentName ??
|
|
243
|
-
configFile.defaultAgentName,
|
|
244
|
-
defaultLlmModelName:
|
|
245
|
-
readmeOverrides.defaultLlmModelName ??
|
|
246
|
-
cliOverrides.defaultLlmModelName ??
|
|
247
|
-
configFile.defaultLlmModelName,
|
|
248
|
-
defaultLlmAgentName:
|
|
249
|
-
readmeOverrides.defaultLlmAgentName ??
|
|
250
|
-
cliOverrides.defaultLlmAgentName ??
|
|
251
|
-
configFile.defaultLlmAgentName,
|
|
252
|
-
maximumPreparingIssuesCount:
|
|
253
|
-
readmeOverrides.maximumPreparingIssuesCount ??
|
|
254
|
-
cliOverrides.maximumPreparingIssuesCount ??
|
|
255
|
-
configFile.maximumPreparingIssuesCount,
|
|
256
|
-
allowIssueCacheMinutes:
|
|
257
|
-
readmeOverrides.allowIssueCacheMinutes ??
|
|
258
|
-
cliOverrides.allowIssueCacheMinutes ??
|
|
259
|
-
configFile.allowIssueCacheMinutes,
|
|
260
|
-
utilizationPercentageThreshold:
|
|
261
|
-
readmeOverrides.utilizationPercentageThreshold ??
|
|
262
|
-
cliOverrides.utilizationPercentageThreshold ??
|
|
263
|
-
configFile.utilizationPercentageThreshold,
|
|
264
|
-
allowedIssueAuthors:
|
|
265
|
-
readmeOverrides.allowedIssueAuthors ??
|
|
266
|
-
cliOverrides.allowedIssueAuthors ??
|
|
267
|
-
configFile.allowedIssueAuthors,
|
|
268
|
-
awaitingQualityCheckStatus:
|
|
269
|
-
readmeOverrides.awaitingQualityCheckStatus ??
|
|
270
|
-
cliOverrides.awaitingQualityCheckStatus ??
|
|
271
|
-
configFile.awaitingQualityCheckStatus,
|
|
272
|
-
thresholdForAutoReject:
|
|
273
|
-
readmeOverrides.thresholdForAutoReject ??
|
|
274
|
-
cliOverrides.thresholdForAutoReject ??
|
|
275
|
-
configFile.thresholdForAutoReject,
|
|
276
|
-
workflowBlockerResolvedWebhookUrl:
|
|
277
|
-
readmeOverrides.workflowBlockerResolvedWebhookUrl ??
|
|
278
|
-
cliOverrides.workflowBlockerResolvedWebhookUrl ??
|
|
279
|
-
configFile.workflowBlockerResolvedWebhookUrl,
|
|
280
|
-
projectName: configFile.projectName,
|
|
281
|
-
preparationProcessCheckCommand:
|
|
282
|
-
readmeOverrides.preparationProcessCheckCommand ??
|
|
283
|
-
cliOverrides.preparationProcessCheckCommand ??
|
|
284
|
-
configFile.preparationProcessCheckCommand,
|
|
285
|
-
codexHomeCandidates:
|
|
286
|
-
readmeOverrides.codexHomeCandidates ??
|
|
287
|
-
cliOverrides.codexHomeCandidates ??
|
|
288
|
-
configFile.codexHomeCandidates,
|
|
289
|
-
awLogDirectoryPath:
|
|
290
|
-
readmeOverrides.awLogDirectoryPath ??
|
|
291
|
-
cliOverrides.awLogDirectoryPath ??
|
|
292
|
-
configFile.awLogDirectoryPath,
|
|
293
|
-
awLogStaleThresholdMinutes:
|
|
294
|
-
readmeOverrides.awLogStaleThresholdMinutes ??
|
|
295
|
-
cliOverrides.awLogStaleThresholdMinutes ??
|
|
296
|
-
configFile.awLogStaleThresholdMinutes,
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
type GraphqlProjectV2ReadmeResponse = {
|
|
300
|
-
data?: {
|
|
301
|
-
organization?: { projectV2?: { readme?: string | null } };
|
|
302
|
-
user?: { projectV2?: { readme?: string | null } };
|
|
303
|
-
};
|
|
304
|
-
};
|
|
305
|
-
|
|
306
|
-
const isGraphqlProjectV2ReadmeResponse = (
|
|
307
|
-
value: unknown,
|
|
308
|
-
): value is GraphqlProjectV2ReadmeResponse => {
|
|
309
|
-
if (!isRecord(value)) return false;
|
|
310
|
-
const data = value['data'];
|
|
311
|
-
if (data !== undefined && !isRecord(data)) return false;
|
|
312
|
-
return true;
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
export const fetchProjectReadme = async (
|
|
316
|
-
projectUrl: string,
|
|
317
|
-
token: string,
|
|
318
|
-
): Promise<string | null> => {
|
|
319
|
-
try {
|
|
320
|
-
const urlParts = projectUrl.split('/');
|
|
321
|
-
const projectNumber = parseInt(urlParts[urlParts.length - 1], 10);
|
|
322
|
-
const owner = urlParts[urlParts.length - 3];
|
|
323
|
-
|
|
324
|
-
const query = `
|
|
325
|
-
query($owner: String!, $number: Int!) {
|
|
326
|
-
organization(login: $owner) {
|
|
327
|
-
projectV2(number: $number) {
|
|
328
|
-
readme
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
user(login: $owner) {
|
|
332
|
-
projectV2(number: $number) {
|
|
333
|
-
readme
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
`;
|
|
338
|
-
|
|
339
|
-
const response = await fetch('https://api.github.com/graphql', {
|
|
340
|
-
method: 'POST',
|
|
341
|
-
headers: {
|
|
342
|
-
Authorization: `Bearer ${token}`,
|
|
343
|
-
'Content-Type': 'application/json',
|
|
344
|
-
},
|
|
345
|
-
body: JSON.stringify({
|
|
346
|
-
query,
|
|
347
|
-
variables: { owner, number: projectNumber },
|
|
348
|
-
}),
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
if (!response.ok) {
|
|
352
|
-
throw new Error(`GraphQL request failed: ${response.status}`);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
const responseData: unknown = await response.json();
|
|
356
|
-
|
|
357
|
-
if (!isGraphqlProjectV2ReadmeResponse(responseData)) {
|
|
358
|
-
return null;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
const orgReadme = responseData.data?.organization?.projectV2?.readme;
|
|
362
|
-
const userReadme = responseData.data?.user?.projectV2?.readme;
|
|
363
|
-
const readme =
|
|
364
|
-
typeof orgReadme === 'string'
|
|
365
|
-
? orgReadme
|
|
366
|
-
: typeof userReadme === 'string'
|
|
367
|
-
? userReadme
|
|
368
|
-
: null;
|
|
369
|
-
|
|
370
|
-
return readme;
|
|
371
|
-
} catch {
|
|
372
|
-
console.warn('Failed to fetch project README');
|
|
373
|
-
return null;
|
|
374
|
-
}
|
|
375
|
-
};
|
|
376
|
-
|
|
377
63
|
const buildGithubRepositoryParams = (
|
|
378
64
|
localStorageRepository: LocalStorageRepository,
|
|
379
65
|
cachePath: string,
|