@oss-autopilot/core 3.21.1 → 3.22.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.
@@ -78,6 +78,14 @@ export function getCacheDir() {
78
78
  }
79
79
  return dir;
80
80
  }
81
+ /** Returns `~/.oss-autopilot/reports`, creating it (overnight morning reports, #1574). */
82
+ export function getReportsDir() {
83
+ const dir = path.join(getDataDir(), 'reports');
84
+ if (!fs.existsSync(dir)) {
85
+ fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
86
+ }
87
+ return dir;
88
+ }
81
89
  /**
82
90
  * Returns the path to the local Gist ID file (`~/.oss-autopilot/gist-id`).
83
91
  *
@@ -108,12 +116,16 @@ export function stateFileExists() {
108
116
  }
109
117
  /**
110
118
  * Read the CLI package version from package.json relative to the running CLI bundle.
111
- * Resolves `../package.json` from `process.argv[1]` (the bundle entry point).
119
+ * Resolves `../package.json` from the real path of `process.argv[1]` (the bundle
120
+ * entry point). An npm install runs the CLI through the `node_modules/.bin/oss-autopilot`
121
+ * symlink, and Node leaves `process.argv[1]` as the symlink, so without `realpathSync`
122
+ * the lookup lands on `node_modules/package.json` and every caller sees `0.0.0` (#1664).
112
123
  * Falls back to '0.0.0' if the file is unreadable.
113
124
  */
114
125
  export function getCLIVersion() {
115
126
  try {
116
- const pkgPath = path.join(path.dirname(process.argv[1]), '..', 'package.json');
127
+ const entry = fs.realpathSync(process.argv[1]);
128
+ const pkgPath = path.join(path.dirname(entry), '..', 'package.json');
117
129
  return JSON.parse(fs.readFileSync(pkgPath, 'utf8')).version;
118
130
  }
119
131
  catch {
@@ -419,6 +419,33 @@ export declare const SearchSeenEntrySchema: z.ZodObject<{
419
419
  url: z.ZodString;
420
420
  lastSeenAt: z.ZodString;
421
421
  }, z.core.$strip>;
422
+ /** One branch an overnight agent prepared locally (#1574). Never pushed by the run. */
423
+ export declare const OvernightPreparedSchema: z.ZodObject<{
424
+ url: z.ZodString;
425
+ branch: z.ZodString;
426
+ worktree: z.ZodOptional<z.ZodString>;
427
+ note: z.ZodOptional<z.ZodString>;
428
+ recordedAt: z.ZodString;
429
+ }, z.core.$strip>;
430
+ /** The latest overnight run (#1574); `startup` surfaces its freshness. */
431
+ export declare const OvernightRecordSchema: z.ZodObject<{
432
+ runAt: z.ZodString;
433
+ reportPath: z.ZodString;
434
+ prepareCount: z.ZodNumber;
435
+ judgmentCount: z.ZodNumber;
436
+ prepared: z.ZodDefault<z.ZodArray<z.ZodObject<{
437
+ url: z.ZodString;
438
+ branch: z.ZodString;
439
+ worktree: z.ZodOptional<z.ZodString>;
440
+ note: z.ZodOptional<z.ZodString>;
441
+ recordedAt: z.ZodString;
442
+ }, z.core.$strip>>>;
443
+ }, z.core.$strip>;
444
+ /** Mirrors oss-scout's `searchRotation` (broad-phase language cursor). */
445
+ export declare const SearchRotationSchema: z.ZodObject<{
446
+ languageOffset: z.ZodDefault<z.ZodNumber>;
447
+ lastRotatedAt: z.ZodOptional<z.ZodString>;
448
+ }, z.core.$strip>;
422
449
  export declare const AgentStateSchema: z.ZodObject<{
423
450
  version: z.ZodLiteral<4>;
424
451
  gistId: z.ZodOptional<z.ZodString>;
@@ -668,6 +695,23 @@ export declare const AgentStateSchema: z.ZodObject<{
668
695
  url: z.ZodString;
669
696
  lastSeenAt: z.ZodString;
670
697
  }, z.core.$strip>>>;
698
+ lastOvernight: z.ZodOptional<z.ZodObject<{
699
+ runAt: z.ZodString;
700
+ reportPath: z.ZodString;
701
+ prepareCount: z.ZodNumber;
702
+ judgmentCount: z.ZodNumber;
703
+ prepared: z.ZodDefault<z.ZodArray<z.ZodObject<{
704
+ url: z.ZodString;
705
+ branch: z.ZodString;
706
+ worktree: z.ZodOptional<z.ZodString>;
707
+ note: z.ZodOptional<z.ZodString>;
708
+ recordedAt: z.ZodString;
709
+ }, z.core.$strip>>>;
710
+ }, z.core.$strip>>;
711
+ searchRotation: z.ZodOptional<z.ZodObject<{
712
+ languageOffset: z.ZodDefault<z.ZodNumber>;
713
+ lastRotatedAt: z.ZodOptional<z.ZodString>;
714
+ }, z.core.$strip>>;
671
715
  }, z.core.$strip>;
672
716
  export type IssueStatus = z.infer<typeof IssueStatusSchema>;
673
717
  export type FetchedPRStatus = z.infer<typeof FetchedPRStatusSchema>;
@@ -675,6 +719,9 @@ export type ProjectCategory = z.infer<typeof ProjectCategorySchema>;
675
719
  export type IssueScope = z.infer<typeof IssueScopeSchema>;
676
720
  export type DiffTool = z.infer<typeof DiffToolSchema>;
677
721
  export type SearchSeenEntry = z.infer<typeof SearchSeenEntrySchema>;
722
+ export type OvernightPrepared = z.infer<typeof OvernightPreparedSchema>;
723
+ export type OvernightRecord = z.infer<typeof OvernightRecordSchema>;
724
+ export type SearchRotation = z.infer<typeof SearchRotationSchema>;
678
725
  export type RepoSignals = z.infer<typeof RepoSignalsSchema>;
679
726
  export type RepoScore = z.infer<typeof RepoScoreSchema>;
680
727
  export type StoredMergedPR = z.infer<typeof StoredMergedPRSchema>;
@@ -236,25 +236,18 @@ export const AgentConfigSchema = z.object({
236
236
  diffTool: DiffToolSchema.default('inline'),
237
237
  diffToolCustomCommand: z.string().optional(),
238
238
  /**
239
- * Opt-in gate for the auto-format-before-push hook (#1045). Default false:
240
- * the hook does nothing on every push unless the user explicitly enables it.
239
+ * No effect since the hook was removed in #1642; kept for state-file
240
+ * compatibility.
241
241
  */
242
242
  autoFormatBeforePush: z.boolean().default(false),
243
243
  /**
244
- * Opt-in gate for own-repo writes in the guard-public-posts hook. Default
245
- * false: every GitHub-mutating command asks for approval. When true, writes
246
- * whose target repo is owned by `githubUsername` skip the ask; anything the
247
- * hook cannot prove is own-repo (forks, other owners, chained commands)
248
- * still asks.
244
+ * No effect since the hook was removed in #1642; kept for state-file
245
+ * compatibility.
249
246
  */
250
247
  trustOwnRepoWrites: z.boolean().default(false),
251
248
  /**
252
- * Threshold (in minutes) for the SessionStart PR health one-liner (#1255).
253
- * The cached digest only refreshes when the user runs `/oss`; SessionStart
254
- * fires every session. Without a freshness gate the line drifts arbitrarily
255
- * stale between runs. When the cache is older than this many minutes (and
256
- * not yet 7 days old, which keeps the existing catch-up nudge), the line is
257
- * suppressed entirely. Default 30 minutes.
249
+ * No effect since the hook was removed in #1642; kept for state-file
250
+ * compatibility.
258
251
  */
259
252
  healthCheckFreshnessMinutes: z.number().int().positive().default(30),
260
253
  /**
@@ -381,6 +374,27 @@ export const SearchSeenEntrySchema = z.object({
381
374
  url: z.string(),
382
375
  lastSeenAt: z.string(),
383
376
  });
377
+ /** One branch an overnight agent prepared locally (#1574). Never pushed by the run. */
378
+ export const OvernightPreparedSchema = z.object({
379
+ url: z.string(),
380
+ branch: z.string(),
381
+ worktree: z.string().optional(),
382
+ note: z.string().optional(),
383
+ recordedAt: z.string(),
384
+ });
385
+ /** The latest overnight run (#1574); `startup` surfaces its freshness. */
386
+ export const OvernightRecordSchema = z.object({
387
+ runAt: z.string(),
388
+ reportPath: z.string(),
389
+ prepareCount: z.number().int().nonnegative(),
390
+ judgmentCount: z.number().int().nonnegative(),
391
+ prepared: z.array(OvernightPreparedSchema).default([]),
392
+ });
393
+ /** Mirrors oss-scout's `searchRotation` (broad-phase language cursor). */
394
+ export const SearchRotationSchema = z.object({
395
+ languageOffset: z.number().int().nonnegative().default(0),
396
+ lastRotatedAt: z.string().optional(),
397
+ });
384
398
  export const AgentStateSchema = z.object({
385
399
  version: z.literal(4),
386
400
  gistId: z.string().optional(),
@@ -431,4 +445,13 @@ export const AgentStateSchema = z.object({
431
445
  * it cannot grow without bound.
432
446
  */
433
447
  searchSeen: z.array(SearchSeenEntrySchema).default([]),
448
+ /** Latest overnight run (#1574). Absent until the first `overnight`. */
449
+ lastOvernight: OvernightRecordSchema.optional(),
450
+ /**
451
+ * Broad-phase language rotation cursor (#1630), oss-scout's `searchRotation`.
452
+ * Scout advances it after every search whose broad phase ran; autopilot runs
453
+ * scout in persistence:'provided', so the advanced cursor is written back
454
+ * here and fed into the next scout state. Absent until the first search.
455
+ */
456
+ searchRotation: SearchRotationSchema.optional(),
434
457
  });
@@ -3,7 +3,7 @@
3
3
  * Thin coordinator that delegates persistence to state-persistence.ts
4
4
  * and scoring logic to repo-score-manager.ts.
5
5
  */
6
- import { AgentState, TrackedIssue, RepoScore, RepoScoreUpdate, DailyDigest, LocalRepoCache, StatusOverride, FetchedPRStatus, StoredMergedPR, StoredClosedPR, SearchSeenEntry } from './types.js';
6
+ import { AgentState, TrackedIssue, RepoScore, RepoScoreUpdate, DailyDigest, LocalRepoCache, StatusOverride, FetchedPRStatus, StoredMergedPR, StoredClosedPR, SearchSeenEntry, OvernightRecord, SearchRotation } from './types.js';
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';
@@ -371,6 +371,14 @@ export declare class StateManager {
371
371
  * and cull stale entries before calling this; the manager only persists.
372
372
  */
373
373
  setSearchSeen(seen: SearchSeenEntry[]): void;
374
+ /** Latest overnight run (#1574); `undefined` before the first one. */
375
+ getLastOvernight(): OvernightRecord | undefined;
376
+ /** Replace the overnight record (#1574): a new run, or a run plus a recorded branch. */
377
+ setLastOvernight(record: OvernightRecord): void;
378
+ /** Broad-phase language rotation cursor (#1630); `undefined` before the first search. */
379
+ getSearchRotation(): SearchRotation | undefined;
380
+ /** Persist the cursor scout advanced during a search (#1630). */
381
+ setSearchRotation(rotation: SearchRotation): void;
374
382
  setStatusOverride(url: string, status: FetchedPRStatus, lastActivityAt: string): void;
375
383
  /**
376
384
  * Remove a manual status override for a PR.
@@ -879,6 +879,24 @@ export class StateManager {
879
879
  this.state.searchSeen = seen;
880
880
  this.autoSave();
881
881
  }
882
+ /** Latest overnight run (#1574); `undefined` before the first one. */
883
+ getLastOvernight() {
884
+ return this.state.lastOvernight;
885
+ }
886
+ /** Replace the overnight record (#1574): a new run, or a run plus a recorded branch. */
887
+ setLastOvernight(record) {
888
+ this.state.lastOvernight = record;
889
+ this.autoSave();
890
+ }
891
+ /** Broad-phase language rotation cursor (#1630); `undefined` before the first search. */
892
+ getSearchRotation() {
893
+ return this.state.searchRotation;
894
+ }
895
+ /** Persist the cursor scout advanced during a search (#1630). */
896
+ setSearchRotation(rotation) {
897
+ this.state.searchRotation = rotation;
898
+ this.autoSave();
899
+ }
882
900
  setStatusOverride(url, status, lastActivityAt) {
883
901
  if (!this.state.config.statusOverrides) {
884
902
  this.state.config.statusOverrides = {};
@@ -2,7 +2,7 @@
2
2
  * Core types for the Open Source Contribution Agent
3
3
  */
4
4
  import type { FetchedPRStatus, RepoSignals, TrackedIssue, IssueVettingResult, IssueScope, DiffTool, AgentConfig, AgentState } from './state-schema.js';
5
- export type { IssueStatus, FetchedPRStatus, ProjectCategory, IssueScope, DiffTool, RepoSignals, RepoScore, StoredMergedPR, StoredClosedPR, AnalyzedIssueConversation, ContributionGuidelines, IssueVettingResult, TrackedIssue, ShelvedPRRef, StatusOverride, AgentConfig, LocalRepoCache, ClosedPR, MergedPR, DailyDigest, AgentState, SearchSeenEntry, } from './state-schema.js';
5
+ export type { IssueStatus, FetchedPRStatus, ProjectCategory, IssueScope, DiffTool, RepoSignals, RepoScore, StoredMergedPR, StoredClosedPR, AnalyzedIssueConversation, ContributionGuidelines, IssueVettingResult, TrackedIssue, ShelvedPRRef, StatusOverride, AgentConfig, LocalRepoCache, ClosedPR, MergedPR, DailyDigest, AgentState, SearchSeenEntry, OvernightPrepared, OvernightRecord, SearchRotation, } from './state-schema.js';
6
6
  /** CI pipeline status for a PR's latest commit. */
7
7
  export type CIStatus = 'passing' | 'failing' | 'pending' | 'unknown';
8
8
  /**
@@ -216,9 +216,9 @@ export declare const StatusOutputSchema: z.ZodObject<{
216
216
  warnings: z.ZodOptional<z.ZodArray<z.ZodObject<{
217
217
  phase: z.ZodEnum<{
218
218
  fetch: "fetch";
219
+ "merge-loop": "merge-loop";
219
220
  "repo-scores": "repo-scores";
220
221
  analytics: "analytics";
221
- "merge-loop": "merge-loop";
222
222
  partition: "partition";
223
223
  "dismiss-filter": "dismiss-filter";
224
224
  "gist-init": "gist-init";
@@ -432,9 +432,9 @@ export declare const DailyOutputSchema: z.ZodObject<{
432
432
  warnings: z.ZodArray<z.ZodObject<{
433
433
  phase: z.ZodEnum<{
434
434
  fetch: "fetch";
435
+ "merge-loop": "merge-loop";
435
436
  "repo-scores": "repo-scores";
436
437
  analytics: "analytics";
437
- "merge-loop": "merge-loop";
438
438
  partition: "partition";
439
439
  "dismiss-filter": "dismiss-filter";
440
440
  "gist-init": "gist-init";
@@ -586,9 +586,9 @@ export declare const CompactDailyOutputSchema: z.ZodObject<{
586
586
  warnings: z.ZodArray<z.ZodObject<{
587
587
  phase: z.ZodEnum<{
588
588
  fetch: "fetch";
589
+ "merge-loop": "merge-loop";
589
590
  "repo-scores": "repo-scores";
590
591
  analytics: "analytics";
591
- "merge-loop": "merge-loop";
592
592
  partition: "partition";
593
593
  "dismiss-filter": "dismiss-filter";
594
594
  "gist-init": "gist-init";
@@ -1063,9 +1063,9 @@ export declare const ComplianceScoreOutputSchema: z.ZodObject<{
1063
1063
  significant_work: "significant_work";
1064
1064
  }>;
1065
1065
  emoji: z.ZodEnum<{
1066
- "\uD83C\uDF1F": "🌟";
1067
1066
  "\u2705": "✅";
1068
1067
  "\u26A0\uFE0F": "⚠️";
1068
+ "\uD83C\uDF1F": "🌟";
1069
1069
  "\u274C": "❌";
1070
1070
  }>;
1071
1071
  checks: z.ZodObject<{
@@ -1283,6 +1283,9 @@ export interface SearchOutput {
1283
1283
  /** Candidates dropped because the authenticated user already has an open PR
1284
1284
  * linked to the issue (#1354). Surfaced as a count so the filter is visible. */
1285
1285
  hiddenOwnPRCount: number;
1286
+ /** Set when the seen-set write could not be pushed to the Gist (#1629);
1287
+ * the local cache has it but the next startup's Gist refetch will drop it. */
1288
+ gistSyncWarning?: string;
1286
1289
  /** Present when rate limits affected the search — either low pre-flight quota or mid-search rate limit hits (#100). */
1287
1290
  rateLimitWarning?: string;
1288
1291
  /**
@@ -1380,6 +1383,12 @@ export interface StartupOutput {
1380
1383
  */
1381
1384
  dashboardBuildErrorTail?: string;
1382
1385
  issueList?: IssueListInfo;
1386
+ /**
1387
+ * Freshness of the latest overnight run (#1574): when it ran, where the
1388
+ * morning report is, and how much it prepared or queued. Absent until the
1389
+ * first `overnight` run.
1390
+ */
1391
+ overnight?: import('../commands/overnight.js').OvernightFreshness;
1383
1392
  }
1384
1393
  /**
1385
1394
  * Compact version of StartupOutput for reduced JSON payload (#763).
@@ -507,8 +507,8 @@ export const InitOutputSchema = z.object({
507
507
  });
508
508
  // ── #1190: plugin → CLI contract ─────────────────────────────────────
509
509
  //
510
- // Pinned shape lets the plugin's session-start hook verify that the bundled
511
- // CLI exposes the subcommands the markdown layer expects. Bumping
510
+ // Pinned shape, checked by cli-registry.docs.test.ts at CI time, so the bundled
511
+ // CLI keeps exposing the subcommands the markdown layer expects. Bumping
512
512
  // `schemaVersion` is a breaking change to that contract.
513
513
  export const ManifestOutputSchema = z.object({
514
514
  schemaVersion: z.literal(1),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oss-autopilot/core",
3
- "version": "3.21.1",
3
+ "version": "3.22.2",
4
4
  "description": "CLI and core library for managing open source contributions",
5
5
  "type": "module",
6
6
  "bin": {
@@ -57,20 +57,20 @@
57
57
  "@octokit/rest": "^22.0.1",
58
58
  "@oss-scout/core": "^1.6.0",
59
59
  "commander": "^15.0.0",
60
- "zod": "^4.4.3"
60
+ "zod": "^4.5.4"
61
61
  },
62
62
  "devDependencies": {
63
- "@types/node": "^26.1.2",
64
- "@vitest/coverage-v8": "^4.1.9",
65
- "esbuild": "^0.28.1",
66
- "tsx": "^4.23.1",
63
+ "@types/node": "^26.4.0",
64
+ "@vitest/coverage-v8": "^4.1.11",
65
+ "esbuild": "^0.28.2",
66
+ "tsx": "^4.23.13",
67
67
  "typedoc": "^0.28.20",
68
68
  "typescript": "^6.0.3",
69
- "vitest": "^4.1.9"
69
+ "vitest": "^4.1.11"
70
70
  },
71
71
  "scripts": {
72
72
  "build": "tsc",
73
- "bundle": "esbuild src/cli.ts --bundle --platform=node --target=node22 --format=cjs --minify --sourcemap --outfile=dist/cli.bundle.cjs",
73
+ "bundle": "node ../../scripts/bundle.mjs src/cli.ts dist/cli.bundle.cjs --sourcemap",
74
74
  "start": "tsx src/cli.ts",
75
75
  "dev": "tsx watch src/cli.ts",
76
76
  "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.tests.json",