@reneturcios/greenlight 0.10.0 → 0.11.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.
@@ -0,0 +1,207 @@
1
+ import { type CensusPr } from "./sync.js";
2
+ import { type ClassifiedCheck } from "./ci-triage.js";
3
+ import { authorKindOf } from "./review-triage.js";
4
+ import { type GitOps } from "./autopilot-git.js";
5
+ import { type FeedbackItem, type FeedbackKind } from "./autopilot-triage.js";
6
+ import { type GitRunner } from "./autopilot-fixes.js";
7
+ /** Rene's identity for fix commits. Standing signatory authority, non-legal. */
8
+ export declare const AUTOPILOT_COMMITTER: {
9
+ name: string;
10
+ email: string;
11
+ };
12
+ export interface AutopilotPull {
13
+ owner: string;
14
+ repo: string;
15
+ number: number;
16
+ url: string;
17
+ title: string;
18
+ author: string;
19
+ headSha: string;
20
+ baseRef: string;
21
+ baseSha: string;
22
+ mergeable: boolean | null;
23
+ mergeableState: string | null;
24
+ forkOwner: string;
25
+ forkRepo: string;
26
+ forkBranch: string;
27
+ forkCloneUrl: string;
28
+ }
29
+ export interface PrWatermark {
30
+ lastHeadSha: string;
31
+ lastReviewId: number;
32
+ lastReviewCommentId: number;
33
+ lastIssueCommentId: number;
34
+ checkConclusions: Record<string, string>;
35
+ }
36
+ export interface AutopilotState {
37
+ version: number;
38
+ prs: Record<string, PrWatermark>;
39
+ }
40
+ export declare function defaultAutopilotStatePath(): string;
41
+ export declare function defaultRepliesPath(): string;
42
+ /**
43
+ * Autopilot consumes the v0.10.1 capability ledger (src/capabilities.ts)
44
+ * rather than duplicating it: loadCapabilities reads the canonical
45
+ * ~/.greenlight/capabilities.json shape, prCreateBlockReason answers the
46
+ * skip question, and fix outcomes are appended with autopilot-scoped
47
+ * actions so they never shadow the ledger's pr_create/claim outcomes.
48
+ */
49
+ export declare function recordAutopilotFixOutcome(capsPath: string, repo: string, kind: "dco" | "merge-conflict" | "format", outcome: "ok" | "failed-other", evidence: string, at?: string): void;
50
+ export declare function loadAutopilotState(path: string): AutopilotState;
51
+ export declare function saveAutopilotState(path: string, state: AutopilotState): void;
52
+ export interface AutopilotFix {
53
+ kind: "dco" | "merge-conflict" | "format";
54
+ itemId: string;
55
+ oldHead: string;
56
+ newHead: string;
57
+ detail: string;
58
+ }
59
+ export interface AutopilotPlan {
60
+ itemId: string;
61
+ kind: FeedbackKind;
62
+ title: string;
63
+ plan: string;
64
+ }
65
+ export interface ReplyDraft {
66
+ pr: string;
67
+ itemId: string;
68
+ kind: FeedbackKind;
69
+ draft: string;
70
+ queuedAt: string;
71
+ queuedReason: string;
72
+ }
73
+ export interface PrReport {
74
+ pr: AutopilotPull | null;
75
+ url: string;
76
+ skipped?: string;
77
+ items: FeedbackItem[];
78
+ fixes: AutopilotFix[];
79
+ plans: AutopilotPlan[];
80
+ replyDrafts: number;
81
+ error?: string;
82
+ }
83
+ export interface AutopilotSummary {
84
+ prsScanned: number;
85
+ prsSkippedBlocked: number;
86
+ prsErrored: number;
87
+ itemsFound: number;
88
+ fixesPushed: number;
89
+ plans: number;
90
+ repliesQueued: number;
91
+ itemsByKind: Record<FeedbackKind, number>;
92
+ botVerdicts: {
93
+ real: number;
94
+ falsePositive: number;
95
+ needsHuman: number;
96
+ };
97
+ ciIntroduced: number;
98
+ ciPreExistingOrExternal: number;
99
+ }
100
+ export interface AutopilotRun {
101
+ perPr: PrReport[];
102
+ summary: AutopilotSummary;
103
+ json: Record<string, unknown>;
104
+ markdown: string;
105
+ }
106
+ export interface AutopilotDeps {
107
+ discoverPrs?: (author: string) => Promise<CensusPr[]>;
108
+ fetchPr?: (owner: string, repo: string, number: number) => Promise<AutopilotPull>;
109
+ triageCi?: (prUrl: string) => Promise<{
110
+ checks: ClassifiedCheck[];
111
+ }>;
112
+ fetchReviewSources?: (owner: string, repo: string, number: number, since: {
113
+ reviewId: number;
114
+ reviewCommentId: number;
115
+ issueCommentId: number;
116
+ }) => Promise<{
117
+ reviews: Array<{
118
+ id: number;
119
+ state?: string;
120
+ body?: string;
121
+ user?: {
122
+ login?: string;
123
+ };
124
+ }>;
125
+ reviewComments: Array<{
126
+ id: number;
127
+ body?: string;
128
+ user?: {
129
+ login?: string;
130
+ };
131
+ path?: string;
132
+ line?: number;
133
+ diff_hunk?: string;
134
+ pull_request_review_id?: number;
135
+ }>;
136
+ issueComments: Array<{
137
+ id: number;
138
+ body?: string;
139
+ user?: {
140
+ login?: string;
141
+ };
142
+ }>;
143
+ maxIds: {
144
+ reviewId: number;
145
+ reviewCommentId: number;
146
+ issueCommentId: number;
147
+ };
148
+ }>;
149
+ fetchFileAtHead?: (owner: string, repo: string, headSha: string, path: string) => Promise<string | null>;
150
+ /** PR commit SHAs, oldest first. Defaults to the pulls/commits endpoint. */
151
+ fetchPrCommits?: (owner: string, repo: string, number: number) => Promise<string[]>;
152
+ gitOps?: GitOps;
153
+ gitRunner?: GitRunner;
154
+ runInDir?: (cwd: string, label: string) => Promise<void>;
155
+ cloneFork?: (cloneUrl: string, branch: string, dest: string) => Promise<void>;
156
+ expectedForkOwner?: string;
157
+ }
158
+ export interface AutopilotRunOptions {
159
+ author?: string;
160
+ prs?: string[];
161
+ maxPrs?: number;
162
+ apply?: boolean;
163
+ maxFixes?: number;
164
+ statePath?: string;
165
+ repliesPath?: string;
166
+ capabilitiesPath?: string;
167
+ concurrency?: number;
168
+ deps?: AutopilotDeps;
169
+ }
170
+ /**
171
+ * Draft reply for a fixed item: what a human would post on the PR.
172
+ * Autopilot never posts; these queue in autopilot-replies.json.
173
+ */
174
+ export declare function draftForFix(item: FeedbackItem, fix: AutopilotFix): string;
175
+ /** Draft reply for a rebutted bot finding. */
176
+ export declare function draftForRebuttal(item: FeedbackItem): string;
177
+ /**
178
+ * Mechanical merge of the current base into the fork branch. Local git does
179
+ * the merge computation in a temp clone; the merged tree is committed
180
+ * through the Git Data API and the branch ref fast-forwarded. Returns
181
+ * ok:false with a NEEDS_HUMAN reason whenever a conflict is not mechanical.
182
+ */
183
+ export declare function attemptMergeFix(pr: AutopilotPull, deps: AutopilotDeps, expectedForkOwner: string): Promise<{
184
+ ok: true;
185
+ oldHead: string;
186
+ newHead: string;
187
+ detail: string;
188
+ } | {
189
+ ok: false;
190
+ reason: string;
191
+ }>;
192
+ /** Persist reply drafts to the replies file, appending to any existing queue. */
193
+ export declare function saveReplyDrafts(path: string, drafts: ReplyDraft[]): number;
194
+ export declare function autopilotMarkdown(run: {
195
+ perPr: PrReport[];
196
+ summary: AutopilotSummary;
197
+ }): string;
198
+ export declare function autopilotJson(run: {
199
+ perPr: PrReport[];
200
+ summary: AutopilotSummary;
201
+ }): Record<string, unknown>;
202
+ /**
203
+ * Run Autopilot. Report-only by default; --apply performs fixes.
204
+ * Returns the run with markdown and json renderings.
205
+ */
206
+ export declare function runAutopilot(opts: AutopilotRunOptions): Promise<AutopilotRun>;
207
+ export { authorKindOf as autopilotAuthorKindOf };