@oss-autopilot/core 3.23.0 → 3.25.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.
@@ -39,6 +39,14 @@ export const THREAD_COMMENTS_CAP = 20;
39
39
  * contexts than this is sent to REST so a failing check beyond the cap can't be
40
40
  * silently dropped and mislabel the PR as passing. */
41
41
  export const CI_CONTEXTS_CAP = 100;
42
+ /**
43
+ * GraphQL reports a GitHub App as `__typename: 'Bot'` with a bare login, where
44
+ * REST reports the same account as `login: 'name[bot]'`. Restore the REST spelling
45
+ * so `isBotAuthor()` and every downstream consumer see one form of the login.
46
+ */
47
+ function restLogin(actor) {
48
+ return actor.__typename === 'Bot' && !actor.login.endsWith('[bot]') ? `${actor.login}[bot]` : actor.login;
49
+ }
42
50
  const PR_FIELDS = `
43
51
  databaseId
44
52
  number
@@ -50,11 +58,11 @@ const PR_FIELDS = `
50
58
  updatedAt
51
59
  comments(last: ${COMMENTS_CAP}) {
52
60
  totalCount
53
- nodes { author { login } body createdAt }
61
+ nodes { author { login __typename } body createdAt }
54
62
  }
55
63
  reviews(last: ${REVIEWS_CAP}) {
56
64
  totalCount
57
- nodes { databaseId state body submittedAt author { login } }
65
+ nodes { databaseId state body submittedAt author { login __typename } }
58
66
  }
59
67
  reviewThreads(last: ${REVIEW_THREADS_CAP}) {
60
68
  totalCount
@@ -65,7 +73,7 @@ const PR_FIELDS = `
65
73
  databaseId
66
74
  body
67
75
  createdAt
68
- author { login }
76
+ author { login __typename }
69
77
  replyTo { databaseId }
70
78
  pullRequestReview { databaseId }
71
79
  }
@@ -164,7 +172,7 @@ export function normalizePRNode(node) {
164
172
  return { kind: 'overflow' };
165
173
  }
166
174
  const comments = node.comments.nodes.map((c) => ({
167
- user: c.author ? { login: c.author.login } : null,
175
+ user: c.author ? { login: restLogin(c.author) } : null,
168
176
  body: c.body,
169
177
  created_at: c.createdAt,
170
178
  }));
@@ -173,7 +181,7 @@ export function normalizePRNode(node) {
173
181
  const reviews = node.reviews.nodes
174
182
  .filter((r) => r.state !== 'PENDING')
175
183
  .map((r) => ({
176
- user: r.author ? { login: r.author.login } : null,
184
+ user: r.author ? { login: restLogin(r.author) } : null,
177
185
  body: r.body,
178
186
  submitted_at: r.submittedAt,
179
187
  state: r.state,
@@ -181,7 +189,7 @@ export function normalizePRNode(node) {
181
189
  }));
182
190
  const reviewComments = node.reviewThreads.nodes.flatMap((thread) => thread.comments.nodes.map((c) => ({
183
191
  id: c.databaseId ?? 0,
184
- user: c.author ? { login: c.author.login } : null,
192
+ user: c.author ? { login: restLogin(c.author) } : null,
185
193
  body: c.body,
186
194
  created_at: c.createdAt,
187
195
  in_reply_to_id: c.replyTo?.databaseId ?? undefined,
@@ -297,6 +297,7 @@ export declare const AgentConfigSchema: z.ZodObject<{
297
297
  vscode: "vscode";
298
298
  }>>;
299
299
  diffToolCustomCommand: z.ZodOptional<z.ZodString>;
300
+ autoExtractLearnings: z.ZodDefault<z.ZodBoolean>;
300
301
  autoFormatBeforePush: z.ZodDefault<z.ZodBoolean>;
301
302
  trustOwnRepoWrites: z.ZodDefault<z.ZodBoolean>;
302
303
  healthCheckFreshnessMinutes: z.ZodDefault<z.ZodNumber>;
@@ -548,6 +549,7 @@ export declare const AgentStateSchema: z.ZodObject<{
548
549
  vscode: "vscode";
549
550
  }>>;
550
551
  diffToolCustomCommand: z.ZodOptional<z.ZodString>;
552
+ autoExtractLearnings: z.ZodDefault<z.ZodBoolean>;
551
553
  autoFormatBeforePush: z.ZodDefault<z.ZodBoolean>;
552
554
  trustOwnRepoWrites: z.ZodDefault<z.ZodBoolean>;
553
555
  healthCheckFreshnessMinutes: z.ZodDefault<z.ZodNumber>;
@@ -235,6 +235,12 @@ export const AgentConfigSchema = z.object({
235
235
  preferredOrgs: z.array(z.string()).default([]),
236
236
  diffTool: DiffToolSchema.default('inline'),
237
237
  diffToolCustomCommand: z.string().optional(),
238
+ /**
239
+ * Extract per-repo learnings from freshly merged PRs automatically at
240
+ * `/oss` startup and in `/oss-overnight` (#1696). When false, `daily`
241
+ * offers the extraction as an `extract_learnings` action-menu item instead.
242
+ */
243
+ autoExtractLearnings: z.boolean().default(true),
238
244
  /**
239
245
  * No effect since the hook was removed in #1642; kept for state-file
240
246
  * compatibility.
@@ -7,6 +7,8 @@ import { AgentState, TrackedIssue, RepoScore, RepoScoreUpdate, DailyDigest, Loca
7
7
  import { type LoadRecoveryInfo } from './state-persistence.js';
8
8
  import type { Stats } from './repo-score-manager.js';
9
9
  import { GistStateStore } from './gist-state-store.js';
10
+ /** Gist file that carries the rendered overnight report across machines (#1698). */
11
+ export declare const OVERNIGHT_REPORT_DOCUMENT = "overnight-report.md";
10
12
  import { type GistHealth } from './gist-health.js';
11
13
  export { acquireLock, releaseLock, atomicWriteFileSync } from './state-persistence.js';
12
14
  export type { LoadRecoveryInfo } from './state-persistence.js';
@@ -371,6 +373,18 @@ export declare class StateManager {
371
373
  * and cull stale entries before calling this; the manager only persists.
372
374
  */
373
375
  setSearchSeen(seen: SearchSeenEntry[]): void;
376
+ /**
377
+ * The rendered morning report as last published to the Gist (#1698), so a
378
+ * machine other than the one that ran overnight can read it. Null in local
379
+ * mode or before the first publish.
380
+ */
381
+ getOvernightReportDocument(): string | null;
382
+ /**
383
+ * Stage the rendered morning report for the next Gist push (#1698).
384
+ * Freeform document, last-write-wins like guidelines. No-op in local mode:
385
+ * the file on disk is the only copy there, which is fine on one machine.
386
+ */
387
+ setOvernightReportDocument(content: string): void;
374
388
  /** Latest overnight run (#1574); `undefined` before the first one. */
375
389
  getLastOvernight(): OvernightRecord | undefined;
376
390
  /** Replace the overnight record (#1574): a new run, or a run plus a recorded branch. */
@@ -11,6 +11,8 @@ import { debug, warn } from './logger.js';
11
11
  import { errorMessage, ConfigurationError, ConcurrencyError, isTransientNetworkError } from './errors.js';
12
12
  import { GistStateStore } from './gist-state-store.js';
13
13
  import * as guidelinesStoreModule from './guidelines-store.js';
14
+ /** Gist file that carries the rendered overnight report across machines (#1698). */
15
+ export const OVERNIGHT_REPORT_DOCUMENT = 'overnight-report.md';
14
16
  import { renderGistWarning } from './gist-health.js';
15
17
  import { getStatePath, getStateCachePath, getGistIdPath } from './paths.js';
16
18
  import { parseGitHubUrl } from './urls.js';
@@ -879,6 +881,23 @@ export class StateManager {
879
881
  this.state.searchSeen = seen;
880
882
  this.autoSave();
881
883
  }
884
+ /**
885
+ * The rendered morning report as last published to the Gist (#1698), so a
886
+ * machine other than the one that ran overnight can read it. Null in local
887
+ * mode or before the first publish.
888
+ */
889
+ getOvernightReportDocument() {
890
+ const content = this.gistStore?.getDocument(OVERNIGHT_REPORT_DOCUMENT) ?? null;
891
+ return content === '' ? null : content;
892
+ }
893
+ /**
894
+ * Stage the rendered morning report for the next Gist push (#1698).
895
+ * Freeform document, last-write-wins like guidelines. No-op in local mode:
896
+ * the file on disk is the only copy there, which is fine on one machine.
897
+ */
898
+ setOvernightReportDocument(content) {
899
+ this.gistStore?.setDocument(OVERNIGHT_REPORT_DOCUMENT, content);
900
+ }
882
901
  /** Latest overnight run (#1574); `undefined` before the first one. */
883
902
  getLastOvernight() {
884
903
  return this.state.lastOvernight;
@@ -147,6 +147,19 @@ export interface DailyOutput {
147
147
  * omit the field entirely so existing consumers and goldens see no change.
148
148
  */
149
149
  listUpdates?: MergedPRListUpdate[];
150
+ /**
151
+ * Recently merged PRs whose learnings the host extracts in the background
152
+ * at startup (#1696). Present only in auto mode with Gist persistence and
153
+ * at least one unextracted merge; see {@link PendingLearnings}.
154
+ */
155
+ pendingLearnings?: PendingLearnings;
156
+ }
157
+ /** Work order for the host's background learnings extraction (#1696). */
158
+ export interface PendingLearnings {
159
+ /** `owner/repo` slugs with at least one unextracted recent merge, sorted. */
160
+ repos: string[];
161
+ /** Total unextracted recently merged PRs across those repos. */
162
+ prCount: number;
150
163
  }
151
164
  /**
152
165
  * Compact version of DailyOutput for reduced JSON payload size (#763).
@@ -178,6 +191,8 @@ export interface CompactDailyOutput {
178
191
  strategySummary?: import('../core/strategy.js').StrategyResult | null;
179
192
  /** Curated-list entries auto-marked done this run (#1463). See {@link DailyOutput.listUpdates}. */
180
193
  listUpdates?: MergedPRListUpdate[];
194
+ /** Background extraction work order (#1696). See {@link DailyOutput.pendingLearnings}. */
195
+ pendingLearnings?: PendingLearnings;
181
196
  }
182
197
  /**
183
198
  * Strip a full DailyOutput down to the compact subset (#763).
@@ -497,6 +512,10 @@ export declare const DailyOutputSchema: z.ZodObject<{
497
512
  listPath: z.ZodString;
498
513
  repoHeadingStruck: z.ZodBoolean;
499
514
  }, z.core.$strip>>>;
515
+ pendingLearnings: z.ZodOptional<z.ZodObject<{
516
+ repos: z.ZodArray<z.ZodString>;
517
+ prCount: z.ZodNumber;
518
+ }, z.core.$strip>>;
500
519
  }, z.core.$strip>;
501
520
  export declare const CompactDailyOutputSchema: z.ZodObject<{
502
521
  digest: z.ZodObject<{
@@ -651,6 +670,10 @@ export declare const CompactDailyOutputSchema: z.ZodObject<{
651
670
  listPath: z.ZodString;
652
671
  repoHeadingStruck: z.ZodBoolean;
653
672
  }, z.core.$strip>>>;
673
+ pendingLearnings: z.ZodOptional<z.ZodObject<{
674
+ repos: z.ZodArray<z.ZodString>;
675
+ prCount: z.ZodNumber;
676
+ }, z.core.$strip>>;
654
677
  }, z.core.$strip>;
655
678
  export declare const SearchOutputSchema: z.ZodObject<{
656
679
  candidates: z.ZodArray<z.ZodObject<{
@@ -1205,6 +1228,17 @@ export declare const LocalReposOutputSchema: z.ZodObject<{
1205
1228
  cachedAt: z.ZodString;
1206
1229
  fromCache: z.ZodBoolean;
1207
1230
  }, z.core.$strip>;
1231
+ /** `overnight report` (#1698): the morning report from wherever it is readable. */
1232
+ export declare const OvernightReportOutputSchema: z.ZodObject<{
1233
+ runAt: z.ZodString;
1234
+ reportPath: z.ZodString;
1235
+ source: z.ZodEnum<{
1236
+ none: "none";
1237
+ local: "local";
1238
+ gist: "gist";
1239
+ }>;
1240
+ content: z.ZodNullable<z.ZodString>;
1241
+ }, z.core.$strip>;
1208
1242
  export declare const OvernightPushPrepOutputSchema: z.ZodObject<{
1209
1243
  dryRun: z.ZodBoolean;
1210
1244
  login: z.ZodString;
@@ -43,6 +43,7 @@ export function toCompactDailyOutput(output) {
43
43
  warnings: output.warnings,
44
44
  strategySummary: output.strategySummary,
45
45
  listUpdates: output.listUpdates,
46
+ pendingLearnings: output.pendingLearnings,
46
47
  };
47
48
  }
48
49
  /**
@@ -294,6 +295,10 @@ export const AttentionSummarySchema = z.object({
294
295
  waiting: z.number().int().nonnegative(),
295
296
  });
296
297
  /** Mirrors {@link MergedPRListUpdate} (#1463). */
298
+ const PendingLearningsSchema = z.object({
299
+ repos: z.array(z.string()),
300
+ prCount: z.number().int().nonnegative(),
301
+ });
297
302
  const MergedPRListUpdateSchema = z.object({
298
303
  prUrl: z.string(),
299
304
  issueUrl: z.string(),
@@ -314,6 +319,7 @@ export const DailyOutputSchema = z.object({
314
319
  warnings: z.array(DailyWarningSchema),
315
320
  strategySummary: StrategyResultSchema.nullable().optional(),
316
321
  listUpdates: z.array(MergedPRListUpdateSchema).optional(),
322
+ pendingLearnings: PendingLearningsSchema.optional(),
317
323
  });
318
324
  export const CompactDailyOutputSchema = z.object({
319
325
  digest: DailyDigestCompactSchema,
@@ -327,6 +333,7 @@ export const CompactDailyOutputSchema = z.object({
327
333
  warnings: z.array(DailyWarningSchema),
328
334
  strategySummary: StrategyResultSchema.nullable().optional(),
329
335
  listUpdates: z.array(MergedPRListUpdateSchema).optional(),
336
+ pendingLearnings: PendingLearningsSchema.optional(),
330
337
  });
331
338
  // ── Search output schema (#1147) ─────────────────────────────────────
332
339
  const SearchPrioritySchema = z.enum(['merged_pr', 'preferred_org', 'starred', 'normal']);
@@ -766,6 +773,13 @@ const PushPrepResultSchema = z.object({
766
773
  compareUrl: z.string().optional(),
767
774
  reason: z.string().optional(),
768
775
  });
776
+ /** `overnight report` (#1698): the morning report from wherever it is readable. */
777
+ export const OvernightReportOutputSchema = z.object({
778
+ runAt: z.string(),
779
+ reportPath: z.string(),
780
+ source: z.enum(['local', 'gist', 'none']),
781
+ content: z.string().nullable(),
782
+ });
769
783
  export const OvernightPushPrepOutputSchema = z.object({
770
784
  dryRun: z.boolean(),
771
785
  login: z.string(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oss-autopilot/core",
3
- "version": "3.23.0",
3
+ "version": "3.25.0",
4
4
  "description": "CLI and core library for managing open source contributions",
5
5
  "type": "module",
6
6
  "bin": {
@@ -55,7 +55,7 @@
55
55
  "@octokit/plugin-retry": "^8.1.1",
56
56
  "@octokit/plugin-throttling": "^11.0.5",
57
57
  "@octokit/rest": "^22.0.1",
58
- "@oss-scout/core": "^1.7.0",
58
+ "@oss-scout/core": "^1.8.0",
59
59
  "commander": "^15.0.0",
60
60
  "zod": "^4.5.4"
61
61
  },