@oss-autopilot/core 1.17.4 → 3.0.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/README.md +1 -1
- package/dist/cli-registry.js +417 -326
- package/dist/cli.bundle.cjs +99 -96
- package/dist/commands/daily-render.d.ts +39 -0
- package/dist/commands/daily-render.js +189 -0
- package/dist/commands/dashboard-data.js +9 -3
- package/dist/commands/index.d.ts +4 -8
- package/dist/commands/index.js +3 -5
- package/dist/commands/list-move-tier.d.ts +46 -0
- package/dist/commands/list-move-tier.js +192 -0
- package/dist/commands/pr-template.js +2 -1
- package/dist/commands/state-cmd.d.ts +10 -1
- package/dist/commands/state-cmd.js +22 -3
- package/dist/commands/track.d.ts +7 -28
- package/dist/commands/track.js +8 -30
- package/dist/core/auth.d.ts +50 -0
- package/dist/core/auth.js +160 -0
- package/dist/core/concurrency.d.ts +7 -0
- package/dist/core/concurrency.js +9 -0
- package/dist/core/daily-logic.d.ts +10 -42
- package/dist/core/daily-logic.js +14 -201
- package/dist/core/dates.d.ts +37 -0
- package/dist/core/dates.js +60 -0
- package/dist/core/errors.d.ts +14 -0
- package/dist/core/errors.js +22 -0
- package/dist/core/gist-state-store.d.ts +48 -2
- package/dist/core/gist-state-store.js +120 -24
- package/dist/core/github-stats.js +1 -1
- package/dist/core/http-cache.js +1 -1
- package/dist/core/index.d.ts +5 -1
- package/dist/core/index.js +5 -1
- package/dist/core/issue-conversation.js +3 -2
- package/dist/core/paths.d.ts +68 -0
- package/dist/core/paths.js +106 -0
- package/dist/core/pr-monitor.js +3 -1
- package/dist/core/repo-score-manager.js +1 -1
- package/dist/core/state-persistence.js +1 -1
- package/dist/core/state.d.ts +16 -2
- package/dist/core/state.js +42 -7
- package/dist/core/types.d.ts +57 -0
- package/dist/core/urls.d.ts +63 -0
- package/dist/core/urls.js +101 -0
- package/dist/formatters/json.d.ts +464 -74
- package/dist/formatters/json.js +380 -0
- package/package.json +3 -3
- package/dist/commands/read.d.ts +0 -18
- package/dist/commands/read.js +0 -20
- package/dist/core/utils.d.ts +0 -303
- package/dist/core/utils.js +0 -529
package/dist/formatters/json.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* JSON output formatter for CLI --json mode
|
|
3
3
|
* Provides structured output that can be consumed by scripts and plugins
|
|
4
4
|
*/
|
|
5
|
+
import { z } from 'zod';
|
|
5
6
|
/**
|
|
6
7
|
* Strip a full DailyOutput down to the compact subset (#763).
|
|
7
8
|
* Omits summary, repoGroups, and full failures array. Retains a failureCount
|
|
@@ -60,6 +61,351 @@ export function compactRepoGroups(groups) {
|
|
|
60
61
|
prUrls: group.prs.map((pr) => pr.url),
|
|
61
62
|
}));
|
|
62
63
|
}
|
|
64
|
+
export const StatusOutputSchema = z.object({
|
|
65
|
+
stats: z.object({
|
|
66
|
+
mergedPRs: z.number().int().nonnegative(),
|
|
67
|
+
closedPRs: z.number().int().nonnegative(),
|
|
68
|
+
activeIssues: z.number().int().nonnegative(),
|
|
69
|
+
trustedProjects: z.number().int().nonnegative(),
|
|
70
|
+
mergeRate: z.string(),
|
|
71
|
+
needsResponse: z.number().int().nonnegative(),
|
|
72
|
+
}),
|
|
73
|
+
lastRunAt: z.string(),
|
|
74
|
+
offline: z.boolean().optional(),
|
|
75
|
+
lastUpdated: z.string().optional(),
|
|
76
|
+
});
|
|
77
|
+
// ── Daily output schemas (#1146) ─────────────────────────────────────
|
|
78
|
+
//
|
|
79
|
+
// FetchedPR / CommentedIssue / PRCheckFailure are large heterogeneous shapes
|
|
80
|
+
// whose state-schema counterparts already use `z.any()` / pass-through
|
|
81
|
+
// validation. We mirror that here — strict on the wrapper (so drift in
|
|
82
|
+
// top-level keys / category arrays surfaces immediately) and tolerant on the
|
|
83
|
+
// opaque payload entries.
|
|
84
|
+
const FetchedPRPassthroughSchema = z.record(z.string(), z.unknown());
|
|
85
|
+
const CommentedIssuePassthroughSchema = z.record(z.string(), z.unknown());
|
|
86
|
+
const PRCheckFailurePassthroughSchema = z.record(z.string(), z.unknown());
|
|
87
|
+
const ShelvedPRRefStrictSchema = z.object({
|
|
88
|
+
number: z.number(),
|
|
89
|
+
url: z.string(),
|
|
90
|
+
title: z.string(),
|
|
91
|
+
repo: z.string(),
|
|
92
|
+
daysSinceActivity: z.number(),
|
|
93
|
+
status: z.string(),
|
|
94
|
+
});
|
|
95
|
+
const RecentClosedPRSchema = z.object({
|
|
96
|
+
number: z.number(),
|
|
97
|
+
url: z.string(),
|
|
98
|
+
title: z.string(),
|
|
99
|
+
closedAt: z.string(),
|
|
100
|
+
});
|
|
101
|
+
const RecentMergedPRSchema = z.object({
|
|
102
|
+
number: z.number(),
|
|
103
|
+
url: z.string(),
|
|
104
|
+
title: z.string(),
|
|
105
|
+
mergedAt: z.string(),
|
|
106
|
+
});
|
|
107
|
+
const DailyDigestSummarySchemaStrict = z.object({
|
|
108
|
+
totalActivePRs: z.number(),
|
|
109
|
+
totalNeedingAttention: z.number(),
|
|
110
|
+
totalMergedAllTime: z.number(),
|
|
111
|
+
mergeRate: z.number(),
|
|
112
|
+
});
|
|
113
|
+
const DailyDigestCompactSchema = z.object({
|
|
114
|
+
generatedAt: z.string(),
|
|
115
|
+
openPRs: z.array(FetchedPRPassthroughSchema),
|
|
116
|
+
needsAddressingPRs: z.array(z.string()),
|
|
117
|
+
waitingOnMaintainerPRs: z.array(z.string()),
|
|
118
|
+
recentlyClosedPRs: z.array(RecentClosedPRSchema),
|
|
119
|
+
recentlyMergedPRs: z.array(RecentMergedPRSchema),
|
|
120
|
+
shelvedPRs: z.array(ShelvedPRRefStrictSchema),
|
|
121
|
+
autoUnshelvedPRs: z.array(ShelvedPRRefStrictSchema),
|
|
122
|
+
summary: DailyDigestSummarySchemaStrict,
|
|
123
|
+
});
|
|
124
|
+
const CapacityAssessmentSchema = z.object({
|
|
125
|
+
hasCapacity: z.boolean(),
|
|
126
|
+
activePRCount: z.number().int().nonnegative(),
|
|
127
|
+
maxActivePRs: z.number().int().nonnegative(),
|
|
128
|
+
shelvedPRCount: z.number().int().nonnegative(),
|
|
129
|
+
criticalIssueCount: z.number().int().nonnegative(),
|
|
130
|
+
reason: z.string(),
|
|
131
|
+
});
|
|
132
|
+
const ActionableIssueTypeSchema = z.enum([
|
|
133
|
+
'ci_failing',
|
|
134
|
+
'merge_conflict',
|
|
135
|
+
'needs_response',
|
|
136
|
+
'needs_changes',
|
|
137
|
+
'incomplete_checklist',
|
|
138
|
+
]);
|
|
139
|
+
const CompactActionableIssueSchema = z.object({
|
|
140
|
+
type: ActionableIssueTypeSchema,
|
|
141
|
+
prUrl: z.string(),
|
|
142
|
+
label: z.string(),
|
|
143
|
+
isNewContribution: z.boolean(),
|
|
144
|
+
});
|
|
145
|
+
const ActionMenuItemSchema = z.object({
|
|
146
|
+
key: z.string(),
|
|
147
|
+
label: z.string(),
|
|
148
|
+
description: z.string(),
|
|
149
|
+
capacityWarning: z.string().optional(),
|
|
150
|
+
});
|
|
151
|
+
const ActionMenuSchema = z.object({
|
|
152
|
+
items: z.array(ActionMenuItemSchema),
|
|
153
|
+
context: z.object({
|
|
154
|
+
hasActionableIssues: z.boolean(),
|
|
155
|
+
actionableCount: z.number().int().nonnegative(),
|
|
156
|
+
hasCapacity: z.boolean(),
|
|
157
|
+
hasIssueResponses: z.boolean(),
|
|
158
|
+
issueResponseCount: z.number().int().nonnegative(),
|
|
159
|
+
}),
|
|
160
|
+
});
|
|
161
|
+
const CompactRepoGroupSchema = z.object({
|
|
162
|
+
repo: z.string(),
|
|
163
|
+
prUrls: z.array(z.string()),
|
|
164
|
+
});
|
|
165
|
+
const DailyWarningPhaseSchema = z.enum([
|
|
166
|
+
'fetch',
|
|
167
|
+
'repo-scores',
|
|
168
|
+
'analytics',
|
|
169
|
+
'scout-sync',
|
|
170
|
+
'partition',
|
|
171
|
+
'dismiss-filter',
|
|
172
|
+
'gist-checkpoint',
|
|
173
|
+
]);
|
|
174
|
+
const DailyWarningSchema = z.object({
|
|
175
|
+
phase: DailyWarningPhaseSchema,
|
|
176
|
+
operation: z.string(),
|
|
177
|
+
message: z.string(),
|
|
178
|
+
});
|
|
179
|
+
export const DailyOutputSchema = z.object({
|
|
180
|
+
digest: DailyDigestCompactSchema,
|
|
181
|
+
capacity: CapacityAssessmentSchema,
|
|
182
|
+
summary: z.string(),
|
|
183
|
+
briefSummary: z.string(),
|
|
184
|
+
actionableIssues: z.array(CompactActionableIssueSchema),
|
|
185
|
+
actionMenu: ActionMenuSchema,
|
|
186
|
+
commentedIssues: z.array(CommentedIssuePassthroughSchema),
|
|
187
|
+
repoGroups: z.array(CompactRepoGroupSchema),
|
|
188
|
+
failures: z.array(PRCheckFailurePassthroughSchema),
|
|
189
|
+
warnings: z.array(DailyWarningSchema),
|
|
190
|
+
});
|
|
191
|
+
export const CompactDailyOutputSchema = z.object({
|
|
192
|
+
digest: DailyDigestCompactSchema,
|
|
193
|
+
capacity: CapacityAssessmentSchema,
|
|
194
|
+
briefSummary: z.string(),
|
|
195
|
+
actionableIssues: z.array(CompactActionableIssueSchema),
|
|
196
|
+
actionMenu: ActionMenuSchema,
|
|
197
|
+
commentedIssues: z.array(CommentedIssuePassthroughSchema),
|
|
198
|
+
failureCount: z.number().int().nonnegative(),
|
|
199
|
+
warnings: z.array(DailyWarningSchema),
|
|
200
|
+
});
|
|
201
|
+
// ── Search output schema (#1147) ─────────────────────────────────────
|
|
202
|
+
const SearchPrioritySchema = z.enum(['merged_pr', 'preferred_org', 'starred', 'normal']);
|
|
203
|
+
const SearchCandidateSchema = z.object({
|
|
204
|
+
issue: z.object({
|
|
205
|
+
repo: z.string(),
|
|
206
|
+
repoUrl: z.string(),
|
|
207
|
+
number: z.number().int(),
|
|
208
|
+
title: z.string(),
|
|
209
|
+
url: z.string(),
|
|
210
|
+
labels: z.array(z.string()),
|
|
211
|
+
}),
|
|
212
|
+
recommendation: z.enum(['approve', 'skip', 'needs_review']),
|
|
213
|
+
reasonsToApprove: z.array(z.string()),
|
|
214
|
+
reasonsToSkip: z.array(z.string()),
|
|
215
|
+
searchPriority: SearchPrioritySchema,
|
|
216
|
+
viabilityScore: z.number(),
|
|
217
|
+
grade: z.object({
|
|
218
|
+
letter: z.enum(['A', 'B', 'C', 'F']),
|
|
219
|
+
reason: z.string(),
|
|
220
|
+
}),
|
|
221
|
+
repoScore: z
|
|
222
|
+
.object({
|
|
223
|
+
score: z.number(),
|
|
224
|
+
mergedPRCount: z.number().int().nonnegative(),
|
|
225
|
+
closedWithoutMergeCount: z.number().int().nonnegative(),
|
|
226
|
+
isResponsive: z.boolean(),
|
|
227
|
+
lastMergedAt: z.string().optional(),
|
|
228
|
+
})
|
|
229
|
+
.optional(),
|
|
230
|
+
});
|
|
231
|
+
export const SearchOutputSchema = z.object({
|
|
232
|
+
candidates: z.array(SearchCandidateSchema),
|
|
233
|
+
excludedRepos: z.array(z.string()),
|
|
234
|
+
aiPolicyBlocklist: z.array(z.string()),
|
|
235
|
+
rateLimitWarning: z.string().optional(),
|
|
236
|
+
});
|
|
237
|
+
// ── Doctor / skip-add / list-move-tier output schemas (#1148) ────────
|
|
238
|
+
const DoctorCheckSchema = z.object({
|
|
239
|
+
name: z.string(),
|
|
240
|
+
status: z.enum(['ok', 'warning', 'error']),
|
|
241
|
+
message: z.string(),
|
|
242
|
+
remediation: z.string().optional(),
|
|
243
|
+
});
|
|
244
|
+
export const DoctorOutputSchema = z.object({
|
|
245
|
+
checks: z.array(DoctorCheckSchema),
|
|
246
|
+
summary: z.object({
|
|
247
|
+
ok: z.number().int().nonnegative(),
|
|
248
|
+
warnings: z.number().int().nonnegative(),
|
|
249
|
+
errors: z.number().int().nonnegative(),
|
|
250
|
+
}),
|
|
251
|
+
});
|
|
252
|
+
export const SkipAddOutputSchema = z.object({
|
|
253
|
+
added: z.boolean(),
|
|
254
|
+
alreadyPresent: z.boolean(),
|
|
255
|
+
url: z.string(),
|
|
256
|
+
path: z.string(),
|
|
257
|
+
date: z.string().optional(),
|
|
258
|
+
});
|
|
259
|
+
export const ListMoveTierOutputSchema = z.object({
|
|
260
|
+
moved: z.boolean(),
|
|
261
|
+
filePath: z.string(),
|
|
262
|
+
url: z.string(),
|
|
263
|
+
toTier: z.enum(['pursue', 'maybe', 'skip']),
|
|
264
|
+
fromTier: z.string().optional(),
|
|
265
|
+
count: z.number().int().nonnegative(),
|
|
266
|
+
reason: z.string().optional(),
|
|
267
|
+
});
|
|
268
|
+
// ── #1155: Zod coverage for remaining CLI commands ───────────────────
|
|
269
|
+
export const PostOutputSchema = z.object({
|
|
270
|
+
commentUrl: z.string(),
|
|
271
|
+
url: z.string(),
|
|
272
|
+
});
|
|
273
|
+
export const ClaimOutputSchema = z.object({
|
|
274
|
+
commentUrl: z.string(),
|
|
275
|
+
issueUrl: z.string(),
|
|
276
|
+
});
|
|
277
|
+
export const InitOutputSchema = z.object({
|
|
278
|
+
username: z.string(),
|
|
279
|
+
message: z.string(),
|
|
280
|
+
});
|
|
281
|
+
export const CheckSetupOutputSchema = z.object({
|
|
282
|
+
setupComplete: z.boolean(),
|
|
283
|
+
username: z.string(),
|
|
284
|
+
});
|
|
285
|
+
const SetupSetOutputSchema = z.object({
|
|
286
|
+
success: z.literal(true),
|
|
287
|
+
settings: z.record(z.string(), z.string()),
|
|
288
|
+
warnings: z.array(z.string()).optional(),
|
|
289
|
+
});
|
|
290
|
+
const SetupCompleteOutputSchema = z.object({
|
|
291
|
+
setupComplete: z.literal(true),
|
|
292
|
+
config: z.object({
|
|
293
|
+
githubUsername: z.string(),
|
|
294
|
+
maxActivePRs: z.number(),
|
|
295
|
+
dormantThresholdDays: z.number(),
|
|
296
|
+
approachingDormantDays: z.number(),
|
|
297
|
+
languages: z.array(z.string()),
|
|
298
|
+
labels: z.array(z.string()),
|
|
299
|
+
projectCategories: z.array(z.string()),
|
|
300
|
+
preferredOrgs: z.array(z.string()),
|
|
301
|
+
scope: z.array(z.string()),
|
|
302
|
+
persistence: z.enum(['local', 'gist']),
|
|
303
|
+
}),
|
|
304
|
+
});
|
|
305
|
+
const SetupRequiredOutputSchema = z.object({
|
|
306
|
+
setupRequired: z.literal(true),
|
|
307
|
+
prompts: z.array(z.object({
|
|
308
|
+
setting: z.string(),
|
|
309
|
+
prompt: z.string(),
|
|
310
|
+
current: z.union([z.string(), z.number(), z.array(z.string()), z.null()]),
|
|
311
|
+
required: z.boolean().optional(),
|
|
312
|
+
default: z.union([z.string(), z.number(), z.array(z.string())]).optional(),
|
|
313
|
+
type: z.string().optional(),
|
|
314
|
+
})),
|
|
315
|
+
});
|
|
316
|
+
export const SetupOutputSchema = z.union([SetupSetOutputSchema, SetupCompleteOutputSchema, SetupRequiredOutputSchema]);
|
|
317
|
+
const ConfigKeyDefSchema = z.object({}).passthrough();
|
|
318
|
+
const ConfigGetOutputSchema = z.object({
|
|
319
|
+
config: z.record(z.string(), z.unknown()),
|
|
320
|
+
});
|
|
321
|
+
const ConfigSetOutputSchema = z.object({
|
|
322
|
+
success: z.literal(true),
|
|
323
|
+
key: z.string(),
|
|
324
|
+
value: z.string(),
|
|
325
|
+
});
|
|
326
|
+
const ConfigListKeysOutputSchema = z.object({
|
|
327
|
+
keys: z.array(ConfigKeyDefSchema),
|
|
328
|
+
});
|
|
329
|
+
export const ConfigCommandOutputSchema = z.union([
|
|
330
|
+
ConfigGetOutputSchema,
|
|
331
|
+
ConfigSetOutputSchema,
|
|
332
|
+
ConfigListKeysOutputSchema,
|
|
333
|
+
]);
|
|
334
|
+
export const MoveOutputSchema = z.object({
|
|
335
|
+
url: z.string(),
|
|
336
|
+
target: z.enum(['attention', 'waiting', 'shelved', 'auto']),
|
|
337
|
+
description: z.string(),
|
|
338
|
+
});
|
|
339
|
+
export const PRTemplateOutputSchema = z.object({
|
|
340
|
+
template: z.string().nullable(),
|
|
341
|
+
source: z.string().nullable(),
|
|
342
|
+
error: z.string().optional(),
|
|
343
|
+
});
|
|
344
|
+
const ParsedIssueItemSchema = z.object({
|
|
345
|
+
repo: z.string(),
|
|
346
|
+
number: z.number(),
|
|
347
|
+
title: z.string(),
|
|
348
|
+
tier: z.string(),
|
|
349
|
+
url: z.string(),
|
|
350
|
+
score: z.number().optional(),
|
|
351
|
+
});
|
|
352
|
+
export const ParseIssueListOutputSchema = z.object({
|
|
353
|
+
available: z.array(ParsedIssueItemSchema),
|
|
354
|
+
completed: z.array(ParsedIssueItemSchema),
|
|
355
|
+
availableCount: z.number().int().nonnegative(),
|
|
356
|
+
completedCount: z.number().int().nonnegative(),
|
|
357
|
+
});
|
|
358
|
+
const NewFileInfoSchema = z.object({
|
|
359
|
+
path: z.string(),
|
|
360
|
+
referencedBy: z.array(z.string()),
|
|
361
|
+
isIntegrated: z.boolean(),
|
|
362
|
+
suggestedEntryPoints: z.array(z.string()).optional(),
|
|
363
|
+
});
|
|
364
|
+
export const CheckIntegrationOutputSchema = z.object({
|
|
365
|
+
newFiles: z.array(NewFileInfoSchema),
|
|
366
|
+
unreferencedCount: z.number().int().nonnegative(),
|
|
367
|
+
});
|
|
368
|
+
const FormatterNameSchema = z.enum([
|
|
369
|
+
'prettier',
|
|
370
|
+
'eslint',
|
|
371
|
+
'biome',
|
|
372
|
+
'black',
|
|
373
|
+
'ruff',
|
|
374
|
+
'rustfmt',
|
|
375
|
+
'gofmt',
|
|
376
|
+
'clang-format',
|
|
377
|
+
'rubocop',
|
|
378
|
+
]);
|
|
379
|
+
const DetectedFormatterSchema = z.object({
|
|
380
|
+
name: FormatterNameSchema,
|
|
381
|
+
configPath: z.string(),
|
|
382
|
+
fixCommand: z.string(),
|
|
383
|
+
checkCommand: z.string(),
|
|
384
|
+
supportsFileArgs: z.boolean(),
|
|
385
|
+
});
|
|
386
|
+
const CIFormatterDiagnosisSchema = z.object({
|
|
387
|
+
isFormattingFailure: z.boolean(),
|
|
388
|
+
formatter: FormatterNameSchema.optional(),
|
|
389
|
+
fixCommand: z.string().optional(),
|
|
390
|
+
evidence: z.array(z.string()),
|
|
391
|
+
});
|
|
392
|
+
export const DetectFormattersOutputSchema = z.object({
|
|
393
|
+
formatters: z.array(DetectedFormatterSchema),
|
|
394
|
+
packageJsonScripts: z.array(z.object({ name: z.string(), command: z.string() })),
|
|
395
|
+
repoPath: z.string(),
|
|
396
|
+
ciDiagnosis: CIFormatterDiagnosisSchema.optional(),
|
|
397
|
+
});
|
|
398
|
+
const LocalRepoInfoSchema = z.object({
|
|
399
|
+
path: z.string(),
|
|
400
|
+
exists: z.boolean(),
|
|
401
|
+
currentBranch: z.string().nullable(),
|
|
402
|
+
});
|
|
403
|
+
export const LocalReposOutputSchema = z.object({
|
|
404
|
+
repos: z.record(z.string(), LocalRepoInfoSchema),
|
|
405
|
+
scanPaths: z.array(z.string()),
|
|
406
|
+
cachedAt: z.string(),
|
|
407
|
+
fromCache: z.boolean(),
|
|
408
|
+
});
|
|
63
409
|
/**
|
|
64
410
|
* Convert a full StartupOutput to the compact format (#763).
|
|
65
411
|
* Uses destructuring to auto-forward any new fields added to StartupOutput.
|
|
@@ -107,3 +453,37 @@ export function outputJson(data) {
|
|
|
107
453
|
export function outputJsonError(message, errorCode) {
|
|
108
454
|
console.log(JSON.stringify(jsonError(message, errorCode), null, 2));
|
|
109
455
|
}
|
|
456
|
+
/**
|
|
457
|
+
* Validate `data` against a Zod schema and wrap the result in the standard
|
|
458
|
+
* JSON output envelope (#1105 long-term ask from #965).
|
|
459
|
+
*
|
|
460
|
+
* Throws a contract-drift `Error` if `data` doesn't match the schema. The
|
|
461
|
+
* error's message lists the failing field paths so a developer can find the
|
|
462
|
+
* drift quickly. Use this at the `--json` boundary of every CLI command —
|
|
463
|
+
* whenever the producer adds, renames, or drops a field that doesn't match
|
|
464
|
+
* the schema, the test harness fails immediately rather than silently
|
|
465
|
+
* shipping a contract break to consumers (plugin layer, MCP server,
|
|
466
|
+
* downstream scripts).
|
|
467
|
+
*
|
|
468
|
+
* @example
|
|
469
|
+
* import { formatJson, StatusOutputSchema } from '../formatters/json.js';
|
|
470
|
+
* const envelope = formatJson(StatusOutputSchema, await runStatus());
|
|
471
|
+
* console.log(JSON.stringify(envelope, null, 2));
|
|
472
|
+
*/
|
|
473
|
+
export function formatJson(schema, data) {
|
|
474
|
+
const result = schema.safeParse(data);
|
|
475
|
+
if (!result.success) {
|
|
476
|
+
const issues = result.error.issues
|
|
477
|
+
.map((i) => `${i.path.length > 0 ? i.path.join('.') : '<root>'}: ${i.message}`)
|
|
478
|
+
.join('; ');
|
|
479
|
+
throw new Error(`--json contract drift: command output does not match its declared schema. ${issues}`);
|
|
480
|
+
}
|
|
481
|
+
return jsonSuccess(result.data);
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* `outputJson(data)` plus Zod validation. Same throwing semantics as
|
|
485
|
+
* {@link formatJson}; the validated envelope is what gets printed.
|
|
486
|
+
*/
|
|
487
|
+
export function outputJsonValidated(schema, data) {
|
|
488
|
+
console.log(JSON.stringify(formatJson(schema, data), null, 2));
|
|
489
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oss-autopilot/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "CLI and core library for managing open source contributions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"url": "https://github.com/costajohnt/oss-autopilot/issues"
|
|
50
50
|
},
|
|
51
51
|
"engines": {
|
|
52
|
-
"node": ">=
|
|
52
|
+
"node": ">=22.0.0"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@octokit/plugin-throttling": "^11.0.3",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"build": "tsc",
|
|
72
|
-
"bundle": "esbuild src/cli.ts --bundle --platform=node --target=
|
|
72
|
+
"bundle": "esbuild src/cli.ts --bundle --platform=node --target=node22 --format=cjs --minify --sourcemap --outfile=dist/cli.bundle.cjs",
|
|
73
73
|
"start": "tsx src/cli.ts",
|
|
74
74
|
"dev": "tsx watch src/cli.ts",
|
|
75
75
|
"typecheck": "tsc --noEmit",
|
package/dist/commands/read.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Read command
|
|
3
|
-
* In v2, PR read/unread state is not tracked locally.
|
|
4
|
-
* This command is a no-op preserved for backward compatibility.
|
|
5
|
-
*/
|
|
6
|
-
export type ReadOutput = {
|
|
7
|
-
markedAsRead: number;
|
|
8
|
-
all: true;
|
|
9
|
-
message: string;
|
|
10
|
-
} | {
|
|
11
|
-
marked: boolean;
|
|
12
|
-
url: string | undefined;
|
|
13
|
-
message: string;
|
|
14
|
-
};
|
|
15
|
-
export declare function runRead(options: {
|
|
16
|
-
prUrl?: string;
|
|
17
|
-
all?: boolean;
|
|
18
|
-
}): Promise<ReadOutput>;
|
package/dist/commands/read.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Read command
|
|
3
|
-
* In v2, PR read/unread state is not tracked locally.
|
|
4
|
-
* This command is a no-op preserved for backward compatibility.
|
|
5
|
-
*/
|
|
6
|
-
import { ValidationError } from '../core/errors.js';
|
|
7
|
-
import { validateUrl } from './validation.js';
|
|
8
|
-
export async function runRead(options) {
|
|
9
|
-
if (!options.all && !options.prUrl) {
|
|
10
|
-
throw new ValidationError('PR URL or --all flag required');
|
|
11
|
-
}
|
|
12
|
-
if (options.prUrl) {
|
|
13
|
-
validateUrl(options.prUrl);
|
|
14
|
-
}
|
|
15
|
-
// In v2, unread state is not tracked locally — PRs are fetched fresh each run.
|
|
16
|
-
if (options.all) {
|
|
17
|
-
return { markedAsRead: 0, all: true, message: 'In v2, PR read state is not tracked locally.' };
|
|
18
|
-
}
|
|
19
|
-
return { marked: false, url: options.prUrl, message: 'In v2, PR read state is not tracked locally.' };
|
|
20
|
-
}
|