@oss-autopilot/core 3.14.3 → 3.14.5
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/dist/commands/search.js
CHANGED
|
@@ -6,6 +6,7 @@ import { adaptScoutLinkedPR, buildCandidateLinkedPR, createAutopilotScout, SEARC
|
|
|
6
6
|
import { classifyLinkedPR, getStateManager } from '../core/index.js';
|
|
7
7
|
import { gradeFromCandidate } from '../core/issue-grading.js';
|
|
8
8
|
import { computeStrategy } from '../core/strategy.js';
|
|
9
|
+
import { refreshStarredReposIfStale } from '../core/starred-repos.js';
|
|
9
10
|
import { debug, warn } from '../core/logger.js';
|
|
10
11
|
const MODULE = 'search';
|
|
11
12
|
/**
|
|
@@ -83,8 +84,15 @@ export async function runSearch(options) {
|
|
|
83
84
|
// means scout searched with an empty skip list, so explicitly-skipped
|
|
84
85
|
// issues may resurface — the envelope must say so, not just stderr.
|
|
85
86
|
const bridgeDiagnostics = {};
|
|
86
|
-
const scout = await createAutopilotScout(bridgeDiagnostics);
|
|
87
87
|
const stateManager = getStateManager();
|
|
88
|
+
// Populate the starred-repo cache before the scout is created. Scout's
|
|
89
|
+
// discovery runs a starred-repo search phase, but it only fires when
|
|
90
|
+
// config.starredRepos is non-empty, and createAutopilotScout snapshots that
|
|
91
|
+
// config into the ScoutState. Without this refresh the starred phase is a
|
|
92
|
+
// silent no-op and discovery recycles the merged-PR repos every run. Fails
|
|
93
|
+
// soft, so a GitHub hiccup never blocks the search.
|
|
94
|
+
await refreshStarredReposIfStale(stateManager);
|
|
95
|
+
const scout = await createAutopilotScout(bridgeDiagnostics);
|
|
88
96
|
// Derive personalization from local history (#1244). `computeStrategy`
|
|
89
97
|
// returns null below the merged-PR floor — in that case we pass nothing
|
|
90
98
|
// and scout falls back to the bridge-built preferences, which derive the
|
|
@@ -489,10 +489,15 @@ export class GistStateStore {
|
|
|
489
489
|
this.lastFetchedEtag = preReadEtag;
|
|
490
490
|
reapplyStaged();
|
|
491
491
|
// Preserve GistCorruptError so callers don't retry against a corrupt
|
|
492
|
-
// remote
|
|
493
|
-
//
|
|
492
|
+
// remote, and let rate-limit errors propagate unchanged so they aren't
|
|
493
|
+
// mistaken for a concurrency conflict — a "refresh + retry" remediation
|
|
494
|
+
// would just hit the same limit (#1510). Any other failure surfaces as
|
|
495
|
+
// a concurrency error — the gist content is still likely fine, the
|
|
496
|
+
// caller can refresh + retry.
|
|
494
497
|
if (readErr instanceof GistCorruptError)
|
|
495
498
|
throw readErr;
|
|
499
|
+
if (isRateLimitError(readErr))
|
|
500
|
+
throw readErr;
|
|
496
501
|
throw new GistConcurrencyError(preReadEtag, null);
|
|
497
502
|
}
|
|
498
503
|
const remoteStateJson = this.cachedFiles.get(STATE_FILE_NAME);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Starred-repo cache refresh.
|
|
3
|
+
*
|
|
4
|
+
* Scout's discovery runs a starred-repo search phase (Phase 1), but it only
|
|
5
|
+
* fires when `config.starredRepos` is non-empty. The autopilot never populated
|
|
6
|
+
* that cache — `init` imports PR history only — so the starred phase was a
|
|
7
|
+
* silent no-op for every user and discovery kept recycling the merged-PR repos.
|
|
8
|
+
* This module fetches the user's stars from GitHub and fills the cache so the
|
|
9
|
+
* phase has input.
|
|
10
|
+
*/
|
|
11
|
+
/** Minimal state surface this refresh needs — keeps it unit-testable. */
|
|
12
|
+
export interface StarredReposState {
|
|
13
|
+
isStarredReposStale(): boolean;
|
|
14
|
+
getStarredRepos(): string[];
|
|
15
|
+
setStarredRepos(repos: string[]): void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Refresh the cached starred-repo list from GitHub when the cache is stale
|
|
19
|
+
* (>24h) or empty, so scout's starred-repo search phase has repos to query.
|
|
20
|
+
*
|
|
21
|
+
* Fails soft: a fetch error logs a warning and leaves the existing cache
|
|
22
|
+
* untouched, so a transient GitHub failure never blocks a search. Returns the
|
|
23
|
+
* number of repos cached after the call (freshly fetched, or the existing list
|
|
24
|
+
* when fresh / on error).
|
|
25
|
+
*/
|
|
26
|
+
export declare function refreshStarredReposIfStale(state: StarredReposState): Promise<number>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Starred-repo cache refresh.
|
|
3
|
+
*
|
|
4
|
+
* Scout's discovery runs a starred-repo search phase (Phase 1), but it only
|
|
5
|
+
* fires when `config.starredRepos` is non-empty. The autopilot never populated
|
|
6
|
+
* that cache — `init` imports PR history only — so the starred phase was a
|
|
7
|
+
* silent no-op for every user and discovery kept recycling the merged-PR repos.
|
|
8
|
+
* This module fetches the user's stars from GitHub and fills the cache so the
|
|
9
|
+
* phase has input.
|
|
10
|
+
*/
|
|
11
|
+
import { getOctokit } from './github.js';
|
|
12
|
+
import { requireGitHubToken } from './auth.js';
|
|
13
|
+
import { debug, warn } from './logger.js';
|
|
14
|
+
const MODULE = 'starred-repos';
|
|
15
|
+
/** Page size for the starred-repos listing (GitHub max is 100). */
|
|
16
|
+
const PER_PAGE = 100;
|
|
17
|
+
/** Cap pages so an account that starred thousands of repos can't stall discovery. */
|
|
18
|
+
const MAX_PAGES = 5;
|
|
19
|
+
/** Page through the authenticated user's stars, collecting `owner/repo` names. */
|
|
20
|
+
async function collectStarredRepoNames(octokit) {
|
|
21
|
+
const repos = [];
|
|
22
|
+
let page = 0;
|
|
23
|
+
for await (const response of octokit.paginate.iterator(octokit.activity.listReposStarredByAuthenticatedUser, {
|
|
24
|
+
per_page: PER_PAGE,
|
|
25
|
+
// Default media type returns the repo object directly (with full_name);
|
|
26
|
+
// the star+timestamp media type would wrap it in { repo, starred_at }.
|
|
27
|
+
headers: { accept: 'application/vnd.github.v3+json' },
|
|
28
|
+
})) {
|
|
29
|
+
for (const repo of response.data) {
|
|
30
|
+
if (repo.full_name)
|
|
31
|
+
repos.push(repo.full_name);
|
|
32
|
+
}
|
|
33
|
+
page += 1;
|
|
34
|
+
if (page >= MAX_PAGES)
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
return repos;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Refresh the cached starred-repo list from GitHub when the cache is stale
|
|
41
|
+
* (>24h) or empty, so scout's starred-repo search phase has repos to query.
|
|
42
|
+
*
|
|
43
|
+
* Fails soft: a fetch error logs a warning and leaves the existing cache
|
|
44
|
+
* untouched, so a transient GitHub failure never blocks a search. Returns the
|
|
45
|
+
* number of repos cached after the call (freshly fetched, or the existing list
|
|
46
|
+
* when fresh / on error).
|
|
47
|
+
*/
|
|
48
|
+
export async function refreshStarredReposIfStale(state) {
|
|
49
|
+
if (!state.isStarredReposStale()) {
|
|
50
|
+
return state.getStarredRepos().length;
|
|
51
|
+
}
|
|
52
|
+
// A missing token is a configuration error, not a transient fetch failure —
|
|
53
|
+
// let it propagate so the caller surfaces the actionable auth message rather
|
|
54
|
+
// than silently degrading to an empty starred phase.
|
|
55
|
+
const token = requireGitHubToken();
|
|
56
|
+
// Only the network fetch is fail-soft: a transient GitHub error must not block
|
|
57
|
+
// the search. Token resolution (above) and the state write (below) stay
|
|
58
|
+
// outside the catch so genuine config/persistence faults aren't masked.
|
|
59
|
+
let repos;
|
|
60
|
+
try {
|
|
61
|
+
repos = await collectStarredRepoNames(getOctokit(token));
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
warn(MODULE, `Failed to refresh starred repos; continuing with cached list (${state.getStarredRepos().length}): ${err instanceof Error ? err.message : String(err)}`);
|
|
65
|
+
return state.getStarredRepos().length;
|
|
66
|
+
}
|
|
67
|
+
// A successful-but-empty response (transient/partial API result) must not wipe
|
|
68
|
+
// a populated cache and then stamp it fresh for 24h — that would silently
|
|
69
|
+
// re-disable the very phase this refresh exists to feed. Keep the old list.
|
|
70
|
+
if (repos.length === 0) {
|
|
71
|
+
debug(MODULE, 'Starred-repo fetch returned 0; keeping existing cache');
|
|
72
|
+
return state.getStarredRepos().length;
|
|
73
|
+
}
|
|
74
|
+
state.setStarredRepos(repos);
|
|
75
|
+
debug(MODULE, `Refreshed starred repos from GitHub: ${repos.length} cached`);
|
|
76
|
+
return repos.length;
|
|
77
|
+
}
|
package/dist/core/state.js
CHANGED
|
@@ -316,10 +316,13 @@ export class StateManager {
|
|
|
316
316
|
// A push that fails after its internal retry means the Gist is no longer
|
|
317
317
|
// the authoritative copy of our in-memory state — surface that as degraded
|
|
318
318
|
// so `state --show`, the daily check, and doctor stop reporting healthy
|
|
319
|
-
// (#1510). A later successful
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
319
|
+
// (#1510). A later successful checkpoint clears it again: without that, a
|
|
320
|
+
// single transient blip would latch a long-lived process (MCP server /
|
|
321
|
+
// dashboard) into "degraded" for its whole lifetime and could trigger an
|
|
322
|
+
// unnecessary re-bootstrap. A thrown GistConcurrencyError is deliberately
|
|
323
|
+
// left untouched here — a concurrent remote write is recoverable (refresh +
|
|
324
|
+
// retry), not a degradation of the Gist itself.
|
|
325
|
+
this.gistDegraded = !pushed;
|
|
323
326
|
return pushed;
|
|
324
327
|
}
|
|
325
328
|
/** Whether this StateManager is backed by a Gist. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oss-autopilot/core",
|
|
3
|
-
"version": "3.14.
|
|
3
|
+
"version": "3.14.5",
|
|
4
4
|
"description": "CLI and core library for managing open source contributions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@octokit/plugin-throttling": "^11.0.3",
|
|
56
56
|
"@octokit/rest": "^22.0.1",
|
|
57
|
-
"@oss-scout/core": "^1.2.
|
|
57
|
+
"@oss-scout/core": "^1.2.1",
|
|
58
58
|
"commander": "^15.0.0",
|
|
59
59
|
"zod": "^4.4.3"
|
|
60
60
|
},
|