@oss-autopilot/core 3.19.0 → 3.19.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.
@@ -17,9 +17,24 @@ export interface IssueListLocation {
17
17
  path: string;
18
18
  source: 'configured' | 'auto-detected';
19
19
  }
20
+ /**
21
+ * Persist an absolute list/skip path back to state config, but only when it
22
+ * differs from what's stored (avoid an autoSave on every run). Upgrading a
23
+ * relative/auto-detected value to absolute makes the location stick across
24
+ * working directories, so `/oss` invoked from anywhere keeps finding the list
25
+ * and skip file instead of silently no-opping the vet/skip/list-maintenance
26
+ * flow (#1577). Shared by the list detection here and the skip-path resolution
27
+ * in startup.ts.
28
+ */
29
+ export declare function persistConfigPath(key: 'issueListPath' | 'skippedIssuesPath', absolutePath: string): void;
20
30
  /**
21
31
  * Locate the curated issue-list file: state config first, then the legacy
22
32
  * config.md frontmatter, then known default paths. Returns undefined when
23
33
  * no list exists — callers treat that as "user has no curated list".
34
+ *
35
+ * All returned paths are ABSOLUTE (#1577): a relative configured value or a
36
+ * known-path probe is resolved against CWD once, then persisted, so the vet →
37
+ * skip → list-maintenance flow no longer depends on `/oss` running from the
38
+ * list's parent directory.
24
39
  */
25
40
  export declare function detectIssueListPath(): IssueListLocation | undefined;
@@ -8,6 +8,7 @@
8
8
  * counts / skipped-issues detection on top of `detectIssueListPath`.
9
9
  */
10
10
  import * as fs from 'node:fs';
11
+ import * as path from 'node:path';
11
12
  import { getStateManager } from '../core/index.js';
12
13
  import { errorMessage } from '../core/errors.js';
13
14
  import { warn } from '../core/logger.js';
@@ -24,18 +25,62 @@ export function parseIssueListPathFromConfig(configContent) {
24
25
  const pathMatch = frontmatter.match(/issueListPath:\s*["']?([^"'\n]+)["']?/);
25
26
  return pathMatch ? pathMatch[1].trim() : undefined;
26
27
  }
28
+ /**
29
+ * Persist an absolute list/skip path back to state config, but only when it
30
+ * differs from what's stored (avoid an autoSave on every run). Upgrading a
31
+ * relative/auto-detected value to absolute makes the location stick across
32
+ * working directories, so `/oss` invoked from anywhere keeps finding the list
33
+ * and skip file instead of silently no-opping the vet/skip/list-maintenance
34
+ * flow (#1577). Shared by the list detection here and the skip-path resolution
35
+ * in startup.ts.
36
+ */
37
+ export function persistConfigPath(key, absolutePath) {
38
+ try {
39
+ const stateManager = getStateManager();
40
+ if (stateManager.getState().config[key] !== absolutePath) {
41
+ stateManager.updateConfig({ [key]: absolutePath });
42
+ }
43
+ }
44
+ catch (error) {
45
+ // Best-effort — the current run still uses the resolved path; the next run
46
+ // just re-detects. Log so the failure is debuggable.
47
+ warn('startup', `Could not persist absolute ${key}: ${errorMessage(error)}`);
48
+ }
49
+ }
27
50
  /**
28
51
  * Locate the curated issue-list file: state config first, then the legacy
29
52
  * config.md frontmatter, then known default paths. Returns undefined when
30
53
  * no list exists — callers treat that as "user has no curated list".
54
+ *
55
+ * All returned paths are ABSOLUTE (#1577): a relative configured value or a
56
+ * known-path probe is resolved against CWD once, then persisted, so the vet →
57
+ * skip → list-maintenance flow no longer depends on `/oss` running from the
58
+ * list's parent directory.
31
59
  */
32
60
  export function detectIssueListPath() {
61
+ // When a configured path exists but its file is missing at resolve-time, a
62
+ // coincidental probe hit below must NOT overwrite the user's configured value
63
+ // in state — it's likely just absent from the current CWD, not wrong.
64
+ let configuredButMissing = false;
33
65
  // 1. Check state.json config (primary)
34
66
  try {
35
67
  const stateManager = getStateManager();
36
68
  const configuredPath = stateManager.getState().config.issueListPath;
37
- if (configuredPath && fs.existsSync(configuredPath)) {
38
- return { path: configuredPath, source: 'configured' };
69
+ if (configuredPath) {
70
+ // Resolve a relative configured value against CWD to an absolute path so
71
+ // the location is stable no matter where `/oss` runs (#1577).
72
+ const resolved = path.resolve(configuredPath);
73
+ if (fs.existsSync(resolved)) {
74
+ if (resolved !== configuredPath)
75
+ persistConfigPath('issueListPath', resolved);
76
+ return { path: resolved, source: 'configured' };
77
+ }
78
+ // A path WAS configured but nothing is there. Surface it prominently
79
+ // instead of silently degrading to probes/undefined (#1577): a large
80
+ // configured list being ignored is otherwise easy to miss.
81
+ configuredButMissing = true;
82
+ warn('startup', `Configured issueListPath not found at ${resolved} (cwd ${process.cwd()}); ` +
83
+ `falling back to auto-detection. Set an absolute issueListPath, or run from its directory.`);
39
84
  }
40
85
  }
41
86
  catch (error) {
@@ -48,19 +93,33 @@ export function detectIssueListPath() {
48
93
  try {
49
94
  const configContent = fs.readFileSync(configPath, 'utf8');
50
95
  const configuredPath = parseIssueListPathFromConfig(configContent);
51
- if (configuredPath && fs.existsSync(configuredPath)) {
52
- return { path: configuredPath, source: 'configured' };
96
+ if (configuredPath) {
97
+ const resolved = path.resolve(configuredPath);
98
+ if (fs.existsSync(resolved)) {
99
+ return { path: resolved, source: 'configured' };
100
+ }
53
101
  }
54
102
  }
55
103
  catch (error) {
56
104
  console.error('[STARTUP] Failed to read config:', errorMessage(error));
57
105
  }
106
+ // Legacy config.md missing-file case is intentionally not warned/persisted:
107
+ // this branch is slated for removal, and step 1 already covers the primary
108
+ // (state.json) configured path (#1577).
58
109
  }
59
- // 3. Probe known paths
110
+ // 3. Probe known paths. Return the ABSOLUTE path and persist it so the first
111
+ // successful detection sticks from any working directory afterwards (#1577).
112
+ // But NOT when a path was configured-but-missing: the probe hit is likely
113
+ // just absent from the current CWD, so overwriting the user's deliberate
114
+ // config with a coincidental probe file would be the silent-wrong-target bug
115
+ // #1577 set out to kill.
60
116
  const probes = ['open-source/potential-issue-list.md', 'oss/issue-list.md', 'issues.md'];
61
117
  for (const probe of probes) {
62
118
  if (fs.existsSync(probe)) {
63
- return { path: probe, source: 'auto-detected' };
119
+ const resolved = path.resolve(probe);
120
+ if (!configuredButMissing)
121
+ persistConfigPath('issueListPath', resolved);
122
+ return { path: resolved, source: 'auto-detected' };
64
123
  }
65
124
  }
66
125
  return undefined;
@@ -16,7 +16,7 @@ import { executeDailyCheck } from './daily.js';
16
16
  import { launchDashboardServer } from './dashboard-lifecycle.js';
17
17
  import { recordBrowserOpened } from './dashboard-process.js';
18
18
  import { parseIssueList } from './parse-list.js';
19
- import { detectIssueListPath } from './locate-issue-list.js';
19
+ import { detectIssueListPath, persistConfigPath } from './locate-issue-list.js';
20
20
  // Path detection moved to locate-issue-list.ts (#1463) so the daily
21
21
  // merge-loop can use it without an import cycle through this module.
22
22
  // Re-exported here for back-compat with existing consumers/tests.
@@ -61,12 +61,25 @@ export function detectIssueList() {
61
61
  }
62
62
  // 5. Detect skipped issues file
63
63
  let skippedIssuesPath;
64
- // Check config first
64
+ // Check config first. A relative skippedIssuesPath is anchored to the issue
65
+ // list's (now absolute) directory — a stable base — not CWD, and upgraded to
66
+ // absolute in config so the skip list isn't silently dropped when /oss runs
67
+ // from a different directory (#1577). Anchoring to the list dir (rather than
68
+ // CWD) avoids baking in a coincidentally-named skipped-issues.md from an
69
+ // unrelated working directory. A multi-segment relative that doesn't resolve
70
+ // here safely falls through to the list-dir default probe below.
65
71
  try {
66
72
  const stateManager = getStateManager();
67
73
  const configuredSkipPath = stateManager.getState().config.skippedIssuesPath;
68
- if (configuredSkipPath && fs.existsSync(configuredSkipPath)) {
69
- skippedIssuesPath = configuredSkipPath;
74
+ if (configuredSkipPath) {
75
+ const resolvedSkip = path.isAbsolute(configuredSkipPath)
76
+ ? configuredSkipPath
77
+ : path.resolve(path.dirname(issueListPath), configuredSkipPath);
78
+ if (fs.existsSync(resolvedSkip)) {
79
+ skippedIssuesPath = resolvedSkip;
80
+ if (resolvedSkip !== configuredSkipPath)
81
+ persistConfigPath('skippedIssuesPath', resolvedSkip);
82
+ }
70
83
  }
71
84
  }
72
85
  catch (err) {
@@ -6,7 +6,7 @@ import * as fs from 'node:fs';
6
6
  import { adaptScoutLinkedPR, buildCandidateLinkedPR, createAutopilotScout } from './scout-bridge.js';
7
7
  import { runParseList, pruneIssueList } from './parse-list.js';
8
8
  import { detectIssueList } from './startup.js';
9
- import { computeSuccessGrade, gradeFromCandidate } from '../core/issue-grading.js';
9
+ import { computeSuccessGrade, gradeFromCandidate, reconcileRecommendation } from '../core/issue-grading.js';
10
10
  import { ValidationError } from '../core/errors.js';
11
11
  import { getStateManager, classifyLinkedPR, getOctokit, requireGitHubToken, parseGitHubUrl, verifyIssuesBatch, } from '../core/index.js';
12
12
  const UNKNOWN_GRADE = computeSuccessGrade({ avgResponseDays: null, mergeRate: null, daysSinceLastCommit: null });
@@ -220,7 +220,7 @@ export async function runVetList(options = {}) {
220
220
  url: candidate.issue.url,
221
221
  labels: candidate.issue.labels,
222
222
  },
223
- recommendation: candidate.recommendation,
223
+ recommendation: reconcileRecommendation(candidate.recommendation, grade),
224
224
  reasonsToApprove: candidate.reasonsToApprove,
225
225
  reasonsToSkip: candidate.reasonsToSkip,
226
226
  projectHealth: candidate.projectHealth,
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { adaptScoutLinkedPR, buildCandidateLinkedPR, createAutopilotScout } from './scout-bridge.js';
6
6
  import { ISSUE_URL_PATTERN, validateGitHubUrl, validateUrl } from './validation.js';
7
- import { gradeFromCandidate } from '../core/issue-grading.js';
7
+ import { gradeFromCandidate, reconcileRecommendation } from '../core/issue-grading.js';
8
8
  import { getStateManager, classifyLinkedPR } from '../core/index.js';
9
9
  /**
10
10
  * Vet a specific GitHub issue for claimability and project health.
@@ -38,7 +38,7 @@ export async function runVet(options) {
38
38
  url: candidate.issue.url,
39
39
  labels: candidate.issue.labels,
40
40
  },
41
- recommendation: candidate.recommendation,
41
+ recommendation: reconcileRecommendation(candidate.recommendation, grade),
42
42
  reasonsToApprove: candidate.reasonsToApprove,
43
43
  reasonsToSkip: candidate.reasonsToSkip,
44
44
  projectHealth: candidate.projectHealth,
@@ -25,6 +25,29 @@ export interface GradeResult {
25
25
  /** Short human-readable explanation of what drove the score. */
26
26
  reason: string;
27
27
  }
28
+ /** Recommendation verdict, mirroring `@oss-scout/core`'s candidate field. */
29
+ export type IssueRecommendation = 'approve' | 'skip' | 'needs_review';
30
+ /**
31
+ * Grade bands are 10/7/4/1. At or above this an "approve" is trustworthy;
32
+ * below it (the bottom band, 1 — "unknown/worst") the grade and an "approve"
33
+ * contradict each other.
34
+ */
35
+ export declare const KEEP_GRADE_THRESHOLD = 4;
36
+ /**
37
+ * Reconcile a scout recommendation with the computed grade (#1575 defect 2).
38
+ * Scout derives "approve" from its own checks without consulting the grade, so
39
+ * an "approve" can coexist with a bottom-band grade. Downgrade such an
40
+ * "approve" to "needs_review" — never a hard skip — so the two signals a caller
41
+ * sees can't flatly contradict. Any non-approve recommendation is returned
42
+ * unchanged.
43
+ *
44
+ * Apply this ONLY where the grade is high-fidelity — i.e. computed from freshly
45
+ * fetched health (the `vet` / `vet-list` surfaces). The `search` and `features`
46
+ * surfaces pass a `checkFailed` health sentinel and grade from history alone, so
47
+ * any repo we lack history with scores the bottom band for missing data, not for
48
+ * being bad; reconciling there would wrongly downgrade well-vetted candidates.
49
+ */
50
+ export declare function reconcileRecommendation(recommendation: IssueRecommendation, grade: GradeResult): IssueRecommendation;
28
51
  /**
29
52
  * Build `GradeSignals` from a vet candidate's project health plus the
30
53
  * optional autopilot-tracked repo score.
@@ -47,6 +70,14 @@ export declare function deriveGradeSignals(params: {
47
70
  projectHealth: {
48
71
  avgIssueResponseDays: number | null;
49
72
  daysSinceLastCommit: number | null;
73
+ /**
74
+ * Repo-intrinsic recent merge rate from `@oss-scout/core`'s
75
+ * `projectHealth.recentMergeRate` (repo-wide merged / closed over 90 days).
76
+ * Preferred over the relationship-derived rate so a healthy repo we've never
77
+ * contributed to grades on its own merits instead of collapsing to F (#248).
78
+ * Absent (undefined/null) until the scout release that supplies it.
79
+ */
80
+ recentMergeRate?: number | null;
50
81
  checkFailed?: boolean;
51
82
  };
52
83
  repoScore: {
@@ -10,6 +10,29 @@
10
10
  * (missing data is treated as a risk, not ignored). This matches the policy
11
11
  * previously described as prose in agents/issue-scout.md.
12
12
  */
13
+ /**
14
+ * Grade bands are 10/7/4/1. At or above this an "approve" is trustworthy;
15
+ * below it (the bottom band, 1 — "unknown/worst") the grade and an "approve"
16
+ * contradict each other.
17
+ */
18
+ export const KEEP_GRADE_THRESHOLD = 4;
19
+ /**
20
+ * Reconcile a scout recommendation with the computed grade (#1575 defect 2).
21
+ * Scout derives "approve" from its own checks without consulting the grade, so
22
+ * an "approve" can coexist with a bottom-band grade. Downgrade such an
23
+ * "approve" to "needs_review" — never a hard skip — so the two signals a caller
24
+ * sees can't flatly contradict. Any non-approve recommendation is returned
25
+ * unchanged.
26
+ *
27
+ * Apply this ONLY where the grade is high-fidelity — i.e. computed from freshly
28
+ * fetched health (the `vet` / `vet-list` surfaces). The `search` and `features`
29
+ * surfaces pass a `checkFailed` health sentinel and grade from history alone, so
30
+ * any repo we lack history with scores the bottom band for missing data, not for
31
+ * being bad; reconciling there would wrongly downgrade well-vetted candidates.
32
+ */
33
+ export function reconcileRecommendation(recommendation, grade) {
34
+ return recommendation === 'approve' && grade.score < KEEP_GRADE_THRESHOLD ? 'needs_review' : recommendation;
35
+ }
13
36
  // Band values, best→worst. A signal always resolves to one of these, so
14
37
  // degradeOneStep can step down the ladder by index.
15
38
  const BANDS = [10, 7, 4, 1];
@@ -90,8 +113,11 @@ export function deriveGradeSignals(params) {
90
113
  const daysSinceLastCommit = healthTrusted
91
114
  ? sanitize(projectHealth.daysSinceLastCommit, 0, Number.MAX_SAFE_INTEGER)
92
115
  : null;
93
- let mergeRate = null;
94
- if (repoScore) {
116
+ // Prefer scout's repo-intrinsic merge rate (#248); fall back to the
117
+ // relationship-derived rate (our own merged/closed counts) when scout didn't
118
+ // supply one, preserving prior behavior for repos with contribution history.
119
+ let mergeRate = healthTrusted ? sanitize(projectHealth.recentMergeRate, 0, 1) : null;
120
+ if (mergeRate === null && repoScore) {
95
121
  const merged = sanitize(repoScore.mergedPRCount, 0, Number.MAX_SAFE_INTEGER);
96
122
  const closed = sanitize(repoScore.closedWithoutMergeCount, 0, Number.MAX_SAFE_INTEGER);
97
123
  if (merged !== null && closed !== null) {
@@ -126,6 +152,10 @@ export function gradeFromCandidate(params) {
126
152
  : {
127
153
  avgIssueResponseDays: ph.avgIssueResponseDays,
128
154
  daysSinceLastCommit: ph.daysSinceLastCommit,
155
+ // Repo-intrinsic recent merge rate (#248). Absent → null →
156
+ // deriveGradeSignals falls back to the relationship-derived rate,
157
+ // preserving prior behavior for repos with contribution history.
158
+ recentMergeRate: ph.recentMergeRate ?? null,
129
159
  checkFailed: false,
130
160
  };
131
161
  return computeSuccessGrade(deriveGradeSignals({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oss-autopilot/core",
3
- "version": "3.19.0",
3
+ "version": "3.19.2",
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.0",
56
56
  "@octokit/plugin-throttling": "^11.0.3",
57
57
  "@octokit/rest": "^22.0.1",
58
- "@oss-scout/core": "^1.3.0",
58
+ "@oss-scout/core": "^1.5.0",
59
59
  "commander": "^15.0.0",
60
60
  "zod": "^4.4.3"
61
61
  },