@oss-autopilot/core 3.43.0 → 3.44.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.
Files changed (100) hide show
  1. package/dist/cli-registry.js +160 -6
  2. package/dist/cli.bundle.cjs +207 -180
  3. package/dist/commands/check-integration.js +4 -1
  4. package/dist/commands/cleanup.d.ts +6 -2
  5. package/dist/commands/cleanup.js +72 -7
  6. package/dist/commands/comments.d.ts +8 -1
  7. package/dist/commands/comments.js +11 -3
  8. package/dist/commands/config.d.ts +2 -0
  9. package/dist/commands/config.js +26 -1
  10. package/dist/commands/daily-ledger.d.ts +33 -5
  11. package/dist/commands/daily-ledger.js +36 -13
  12. package/dist/commands/daily-render.d.ts +2 -1
  13. package/dist/commands/daily-render.js +4 -1
  14. package/dist/commands/daily.d.ts +3 -0
  15. package/dist/commands/daily.js +25 -5
  16. package/dist/commands/dashboard-data.js +70 -61
  17. package/dist/commands/dashboard-lifecycle.d.ts +36 -8
  18. package/dist/commands/dashboard-lifecycle.js +131 -38
  19. package/dist/commands/dashboard-process.d.ts +35 -0
  20. package/dist/commands/dashboard-process.js +65 -5
  21. package/dist/commands/dismiss.js +7 -6
  22. package/dist/commands/doctor.js +1 -8
  23. package/dist/commands/fork-prune.d.ts +58 -0
  24. package/dist/commands/fork-prune.js +247 -0
  25. package/dist/commands/guidelines.d.ts +46 -1
  26. package/dist/commands/guidelines.js +111 -12
  27. package/dist/commands/index.d.ts +5 -0
  28. package/dist/commands/index.js +5 -0
  29. package/dist/commands/overnight-push-prep.d.ts +2 -1
  30. package/dist/commands/overnight-push-prep.js +3 -3
  31. package/dist/commands/policy.d.ts +5 -1
  32. package/dist/commands/policy.js +14 -1
  33. package/dist/commands/pr-create.d.ts +48 -0
  34. package/dist/commands/pr-create.js +200 -0
  35. package/dist/commands/pr-preflight.d.ts +28 -2
  36. package/dist/commands/pr-preflight.js +63 -9
  37. package/dist/commands/setup.js +120 -36
  38. package/dist/commands/startup.d.ts +7 -0
  39. package/dist/commands/startup.js +17 -0
  40. package/dist/commands/status.js +5 -0
  41. package/dist/commands/validation.d.ts +5 -0
  42. package/dist/commands/validation.js +5 -0
  43. package/dist/commands/vet-list.js +2 -2
  44. package/dist/commands/vet.d.ts +8 -0
  45. package/dist/commands/vet.js +15 -1
  46. package/dist/commands/work.d.ts +4 -0
  47. package/dist/commands/work.js +34 -11
  48. package/dist/core/commit-date.d.ts +31 -5
  49. package/dist/core/commit-date.js +36 -8
  50. package/dist/core/compliance-score.d.ts +3 -0
  51. package/dist/core/compliance-score.js +13 -9
  52. package/dist/core/config-registry.d.ts +27 -2
  53. package/dist/core/config-registry.js +83 -2
  54. package/dist/core/daily-logic.d.ts +4 -1
  55. package/dist/core/daily-logic.js +13 -2
  56. package/dist/core/fork-prune.d.ts +149 -0
  57. package/dist/core/fork-prune.js +333 -0
  58. package/dist/core/gist-state-store.js +4 -8
  59. package/dist/core/github-stats.d.ts +7 -1
  60. package/dist/core/github-stats.js +15 -15
  61. package/dist/core/index.d.ts +1 -1
  62. package/dist/core/index.js +1 -1
  63. package/dist/core/local-config.js +2 -3
  64. package/dist/core/pacing.d.ts +41 -0
  65. package/dist/core/pacing.js +115 -0
  66. package/dist/core/pr-assembly.d.ts +2 -0
  67. package/dist/core/pr-graphql.d.ts +16 -1
  68. package/dist/core/pr-graphql.js +15 -3
  69. package/dist/core/pr-monitor.d.ts +6 -0
  70. package/dist/core/pr-monitor.js +46 -10
  71. package/dist/core/pr-preflight.d.ts +41 -0
  72. package/dist/core/pr-preflight.js +406 -17
  73. package/dist/core/prose-script.d.ts +72 -0
  74. package/dist/core/prose-script.js +223 -0
  75. package/dist/core/repo-policy.d.ts +8 -2
  76. package/dist/core/repo-policy.js +34 -6
  77. package/dist/core/repo-score-manager.d.ts +18 -0
  78. package/dist/core/repo-score-manager.js +29 -0
  79. package/dist/core/review-analysis.d.ts +15 -2
  80. package/dist/core/review-analysis.js +22 -5
  81. package/dist/core/stale-data.d.ts +44 -7
  82. package/dist/core/stale-data.js +46 -8
  83. package/dist/core/state-persistence.js +2 -4
  84. package/dist/core/state-schema.d.ts +39 -0
  85. package/dist/core/state-schema.js +68 -1
  86. package/dist/core/state.d.ts +21 -0
  87. package/dist/core/state.js +47 -0
  88. package/dist/core/status-determination.js +10 -8
  89. package/dist/core/untrusted-content.d.ts +3 -3
  90. package/dist/core/untrusted-content.js +26 -8
  91. package/dist/core/urls.d.ts +24 -0
  92. package/dist/core/urls.js +76 -0
  93. package/dist/dashboard/assets/chart-panel-B-nLVgzQ.js +3 -0
  94. package/dist/dashboard/assets/index-5IvMGokL.js +55 -0
  95. package/dist/dashboard/index.html +1 -1
  96. package/dist/formatters/json.d.ts +171 -5
  97. package/dist/formatters/json.js +79 -0
  98. package/package.json +6 -6
  99. package/dist/dashboard/assets/chart-panel-C_C1lFTI.js +0 -3
  100. package/dist/dashboard/assets/index-B--H66Jk.js +0 -55
@@ -3,15 +3,43 @@
3
3
  * PR status pipeline (#1919) and the reviewed-PR scan.
4
4
  */
5
5
  /**
6
- * The committer date when the author also committed it (their own amend or
7
- * rebase moved it while Git kept the old author date), the author date when
8
- * someone else rewrote it (a maintainer's rebase does not make the author's
9
- * old work new, and is not the author addressing feedback). Either falls back
10
- * to the other when missing.
6
+ * Whether the author also committed it: their own amend or rebase. Matched on
7
+ * GitHub login, or on the Git email when the author email is linked to no
8
+ * GitHub account (no author login), so an unlinked author's amend still counts.
11
9
  */
12
- export function commitDateOf(c) {
10
+ export function isOwnRewrite(c) {
13
11
  const login = c.authorLogin?.toLowerCase();
14
- const isOwnRewrite = login !== undefined && c.committerLogin?.toLowerCase() === login;
15
- const date = isOwnRewrite ? (c.committerDate ?? c.authorDate) : (c.authorDate ?? c.committerDate);
12
+ if (login)
13
+ return c.committerLogin?.toLowerCase() === login;
14
+ const email = c.authorEmail?.toLowerCase();
15
+ return !!email && c.committerEmail?.toLowerCase() === email;
16
+ }
17
+ /**
18
+ * Whether the commit sits on a different parent than the reviewed commit did
19
+ * (and is not a new commit on top of it): the branch was rebased since the
20
+ * review (#2042). False when any of the three SHAs is unknown.
21
+ */
22
+ export function isRebasedSinceReview(c) {
23
+ const { parentSha, reviewedSha, reviewedParentSha } = c;
24
+ if (!parentSha || !reviewedSha || !reviewedParentSha)
25
+ return false;
26
+ return parentSha !== reviewedParentSha && parentSha !== reviewedSha;
27
+ }
28
+ /**
29
+ * The committer date when the author also committed it (their own amend moved
30
+ * it while Git kept the old author date), the author date when someone else
31
+ * rewrote it (a maintainer's rebase does not make the author's old work new,
32
+ * and is not the author addressing feedback). Either falls back to the other
33
+ * when missing.
34
+ *
35
+ * The author's own rewrite also keeps the author date when it moved the
36
+ * commit onto a new parent since the latest change request: a rebase onto
37
+ * the base branch moves the committer date without touching the review's
38
+ * points, so it must not read as addressing them (#2042). An amend in place
39
+ * keeps the reviewed commit's parent and still counts.
40
+ */
41
+ export function commitDateOf(c) {
42
+ const isAddressingRewrite = isOwnRewrite(c) && !isRebasedSinceReview(c);
43
+ const date = isAddressingRewrite ? (c.committerDate ?? c.authorDate) : (c.authorDate ?? c.committerDate);
16
44
  return date ?? undefined;
17
45
  }
@@ -119,6 +119,9 @@ export declare const RATING_CUTOFFS: {
119
119
  readonly minor: 75;
120
120
  readonly fixFirst: 60;
121
121
  };
122
+ export declare function codeMask(body: string): Uint8Array;
123
+ /** The body has enough prose outside scaffolding and references to describe a change; `pr-preflight` uses it too (#1910). */
124
+ export declare function hasDescription(body: string): boolean;
122
125
  /**
123
126
  * Compute a compliance score from PR metadata, optionally fine-tuned by
124
127
  * repo context (#1245). Pure function — no I/O, no global state.
@@ -35,6 +35,7 @@ const STATUS_TO_FRACTION = {
35
35
  // (#1252). Re-exported so existing consumers of compliance-score
36
36
  // (tests, agent prompts) keep working without touching their imports.
37
37
  import { TITLE_LENGTH_BUDGET, FOCUSED_CHANGES_THRESHOLDS } from './pr-quality-rubric.js';
38
+ import { findClosingRefs } from './urls.js';
38
39
  /** Title byte budget — Conventional Commits style fits comfortably under 72. */
39
40
  export { TITLE_LENGTH_BUDGET } from './pr-quality-rubric.js';
40
41
  /** "Focused changes" thresholds. Source of truth lives in pr-quality-rubric.ts. */
@@ -46,11 +47,10 @@ export const RATING_CUTOFFS = {
46
47
  fixFirst: 60,
47
48
  };
48
49
  /**
49
- * Detect a closing or referencing keyword in the PR body. GitHub's own
50
- * auto-close keyword set: close, closes, closed, fix, fixes, fixed,
51
- * resolve, resolves, resolved.
50
+ * Detect a referencing keyword in the PR body. Closing keywords (GitHub's
51
+ * close, closes, closed, fix, fixes, fixed, resolve, resolves, resolved) are
52
+ * {@link findClosingRefs}.
52
53
  */
53
- const CLOSING_KEYWORDS = /\b(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s+#\d+/i;
54
54
  const REFERENCE_KEYWORDS = /\b(?:relates?\s+to|see|refs?|references?)\s+#\d+/i;
55
55
  const ISSUE_URL = /https?:\/\/github\.com\/[^/]+\/[^/]+\/issues\/\d+/i;
56
56
  /**
@@ -127,7 +127,8 @@ function evaluateLinkedIssues(weight, linkedIssues) {
127
127
  }
128
128
  function checkIssueReference(meta, repoContext) {
129
129
  const weight = WEIGHTS.issueReference;
130
- const hasClosing = CLOSING_KEYWORDS.test(meta.body);
130
+ // A closing keyword in a code span or HTML comment (a template example) links nothing on GitHub.
131
+ const hasClosing = findClosingRefs(meta.body, { markdown: true }).length > 0;
131
132
  // The parser's `linkedIssues` already captures cross-repo (`owner/repo#N`)
132
133
  // and direct-URL references that the same-repo regex misses. Treat any
133
134
  // parsed reference as "a reference exists" so cross-repo links don't
@@ -200,8 +201,8 @@ function inlineSpans(body, from, to) {
200
201
  }
201
202
  return spans;
202
203
  }
203
- // 1 for each character inside code (fenced or inline). Linear time.
204
- function codeMask(body) {
204
+ // 1 for each character inside code (fenced or inline). Linear time. Also used by prose-script.ts.
205
+ export function codeMask(body) {
205
206
  const mask = new Uint8Array(body.length);
206
207
  const fences = fenceSpans(body);
207
208
  const gaps = [];
@@ -245,6 +246,10 @@ function proseOf(body) {
245
246
  .replaceAll(DESCRIPTION_REF, '')
246
247
  .trim());
247
248
  }
249
+ /** The body has enough prose outside scaffolding and references to describe a change; `pr-preflight` uses it too (#1910). */
250
+ export function hasDescription(body) {
251
+ return (proseOf(body).match(/\p{L}/gu)?.length ?? 0) >= 10;
252
+ }
248
253
  // Headings are never required: a sentence or two of what and why is a full
249
254
  // description, and requiring a heading set pads small PRs with filler sections.
250
255
  function checkDescription(meta) {
@@ -253,8 +258,7 @@ function checkDescription(meta) {
253
258
  if (trimmed.length === 0) {
254
259
  return { status: 'fail', weight, detail: 'description is empty' };
255
260
  }
256
- const prose = proseOf(meta.body);
257
- if ((prose.match(/\p{L}/gu)?.length ?? 0) >= 10) {
261
+ if (hasDescription(meta.body)) {
258
262
  return { status: 'pass', weight, detail: 'describes the change' };
259
263
  }
260
264
  return {
@@ -3,7 +3,8 @@
3
3
  *
4
4
  * Keys fall into two CLI surfaces:
5
5
  * - `oss-autopilot setup --set key=value` — direct scalar / list-replace sets
6
- * - `oss-autopilot config <key> <value>` — list mutators (add-/remove-) and aliases
6
+ * - `oss-autopilot config <key> <value>` — list mutators (add-/remove-) and aliases;
7
+ * it also applies `setup` keys by delegating to setup (#1913)
7
8
  *
8
9
  * A key may be settable via one, the other, or both. `auto` means the field is
9
10
  * populated by internal code (e.g. starredRepos is fetched from GitHub), never
@@ -11,12 +12,27 @@
11
12
  *
12
13
  * When adding a new user-configurable state.json field:
13
14
  * 1. Add the field to `AgentConfigSchema` (state-schema.ts).
14
- * 2. Add an entry here.
15
+ * 2. Add an entry here, with its `trust` tier (see {@link ConfigTrust}).
15
16
  * 3. Wire the handler in `commands/setup.ts` and/or `commands/config.ts`.
16
17
  * 4. The registry test (`config-registry.test.ts`) asserts both commands
17
18
  * handle every non-`auto` key.
18
19
  */
19
20
  export type SettableVia = 'setup' | 'config' | 'both' | 'auto';
21
+ /**
22
+ * How far a write of the key has to be trusted (#2035, #2036). Callers that
23
+ * act for someone other than the person at the keyboard (the MCP server)
24
+ * derive what they refuse from this, so a new key is classified where it is
25
+ * defined instead of in a denylist kept somewhere else.
26
+ *
27
+ * - `preference`: shapes what the tool suggests or how it behaves; anyone may set it.
28
+ * - `path`: a file or directory the tool then reads as the user's own input
29
+ * (a value set by the user skips the foreign-checkout check) or rewrites.
30
+ * - `command`: a value a later workflow runs as a command.
31
+ * - `safeguard`: a setting that stops the tool from acting (the AI-policy
32
+ * ban list, the pacing caps, the forks fork-prune keeps); removing a ban or
33
+ * keepForks entry, or raising or clearing a cap, lifts a limit.
34
+ */
35
+ export type ConfigTrust = 'preference' | 'path' | 'command' | 'safeguard';
20
36
  export interface ConfigKeyDef {
21
37
  /** The key as users type it (may differ from the underlying state field, e.g. `dormantDays` → `dormantThresholdDays`). */
22
38
  key: string;
@@ -26,10 +42,19 @@ export interface ConfigKeyDef {
26
42
  settableVia: SettableVia;
27
43
  /** Short hint for the expected value shape (e.g. `"number"`, `"owner/repo"`, `"comma-separated list"`). */
28
44
  valueHint: string;
45
+ /** See {@link ConfigTrust}. Required, so a new key's tier is a choice made where it is added. */
46
+ trust: ConfigTrust;
47
+ /** Values that make a write of this otherwise `preference` key a `command` write (e.g. `diffTool=custom`). */
48
+ commandValues?: readonly string[];
29
49
  }
30
50
  export declare const CONFIG_KEY_REGISTRY: readonly ConfigKeyDef[];
31
51
  export declare function isKnownKey(key: string): boolean;
32
52
  export declare function getKeyDef(key: string): ConfigKeyDef | undefined;
53
+ /**
54
+ * The trust tier of writing `value` to `key` (see {@link ConfigTrust}).
55
+ * Unknown keys read as `preference`; the commands reject them anyway.
56
+ */
57
+ export declare function getKeyTrust(key: string, value?: string): ConfigTrust;
33
58
  /** Keys accepted by the `setup --set` command (includes `both`). */
34
59
  export declare function getSetupKeys(): readonly string[];
35
60
  /** Keys accepted by the `config <key> <value>` command (includes `both`). */
@@ -3,7 +3,8 @@
3
3
  *
4
4
  * Keys fall into two CLI surfaces:
5
5
  * - `oss-autopilot setup --set key=value` — direct scalar / list-replace sets
6
- * - `oss-autopilot config <key> <value>` — list mutators (add-/remove-) and aliases
6
+ * - `oss-autopilot config <key> <value>` — list mutators (add-/remove-) and aliases;
7
+ * it also applies `setup` keys by delegating to setup (#1913)
7
8
  *
8
9
  * A key may be settable via one, the other, or both. `auto` means the field is
9
10
  * populated by internal code (e.g. starredRepos is fetched from GitHub), never
@@ -11,7 +12,7 @@
11
12
  *
12
13
  * When adding a new user-configurable state.json field:
13
14
  * 1. Add the field to `AgentConfigSchema` (state-schema.ts).
14
- * 2. Add an entry here.
15
+ * 2. Add an entry here, with its `trust` tier (see {@link ConfigTrust}).
15
16
  * 3. Wire the handler in `commands/setup.ts` and/or `commands/config.ts`.
16
17
  * 4. The registry test (`config-registry.test.ts`) asserts both commands
17
18
  * handle every non-`auto` key.
@@ -23,6 +24,7 @@ export const CONFIG_KEY_REGISTRY = [
23
24
  description: 'Your GitHub username.',
24
25
  settableVia: 'both',
25
26
  valueHint: 'string',
27
+ trust: 'preference',
26
28
  },
27
29
  // ── Capacity / dormancy ──────────────────────────────────────────────
28
30
  {
@@ -30,36 +32,56 @@ export const CONFIG_KEY_REGISTRY = [
30
32
  description: 'Soft cap on how many active PRs you want to juggle at once. 0 disables the cap.',
31
33
  settableVia: 'setup',
32
34
  valueHint: 'non-negative integer (0 = no limit)',
35
+ trust: 'preference',
33
36
  },
34
37
  {
35
38
  key: 'maxOpenPRsPerRepo',
36
39
  description: 'Discovery leaves out a repo once you have this many open PRs there, and the pre-push check warns. Default 0 (off).',
37
40
  settableVia: 'setup',
38
41
  valueHint: 'non-negative integer (0 = no limit)',
42
+ trust: 'preference',
39
43
  },
40
44
  {
41
45
  key: 'maxOpenPRsColdRepo',
42
46
  description: 'Per-repo open-PR cap while none of your PRs in that repo have merged (default 1). Discovery leaves the repo out and the pre-push check warns. 0 disables.',
43
47
  settableVia: 'setup',
44
48
  valueHint: 'non-negative integer (0 = no limit)',
49
+ trust: 'preference',
45
50
  },
46
51
  {
47
52
  key: 'maxConcurrentImplementations',
48
53
  description: 'How many implementations may run at once across sessions and machines (work claim --kind implementation refuses past it). Default 2; 0 disables the cap.',
49
54
  settableVia: 'setup',
50
55
  valueHint: 'non-negative integer (0 = no limit)',
56
+ trust: 'preference',
57
+ },
58
+ {
59
+ key: 'maxNewPrsPerDay',
60
+ description: 'Optional cap on new PRs to repos you do not own per rolling 24 hours; pr-preflight defers a new PR for an issue past it (one without an issue URL is counted, not deferred). Unset or 0 = no cap. Counted from local state: PRs recorded when the tool opened them plus those the last daily run saw.',
61
+ settableVia: 'setup',
62
+ valueHint: 'non-negative integer (0 or empty = no cap)',
63
+ trust: 'safeguard',
64
+ },
65
+ {
66
+ key: 'maxNewForksPerDay',
67
+ description: 'Optional soft cap on new forks per rolling 24 hours: the first known PR into a repo counts as one new fork, and pr-preflight defers only a PR from a clone with no fork remote of yours. Unset or 0 = no cap.',
68
+ settableVia: 'setup',
69
+ valueHint: 'non-negative integer (0 or empty = no cap)',
70
+ trust: 'safeguard',
51
71
  },
52
72
  {
53
73
  key: 'dormantDays',
54
74
  description: 'Alias for dormantThresholdDays: days of inactivity before a PR is considered dormant.',
55
75
  settableVia: 'setup',
56
76
  valueHint: 'positive integer',
77
+ trust: 'preference',
57
78
  },
58
79
  {
59
80
  key: 'approachingDays',
60
81
  description: 'Alias for approachingDormantDays: days before dormancy threshold at which to warn.',
61
82
  settableVia: 'setup',
62
83
  valueHint: 'positive integer',
84
+ trust: 'preference',
63
85
  },
64
86
  // ── Issue discovery ──────────────────────────────────────────────────
65
87
  {
@@ -67,90 +89,112 @@ export const CONFIG_KEY_REGISTRY = [
67
89
  description: 'Programming languages to filter issue discovery by (whole-list replace).',
68
90
  settableVia: 'setup',
69
91
  valueHint: 'comma-separated list',
92
+ trust: 'preference',
70
93
  },
71
94
  {
72
95
  key: 'labels',
73
96
  description: 'Issue labels to search for (whole-list replace).',
74
97
  settableVia: 'setup',
75
98
  valueHint: 'comma-separated list',
99
+ trust: 'preference',
76
100
  },
77
101
  {
78
102
  key: 'scope',
79
103
  description: 'Issue complexity scope(s) — beginner, intermediate, advanced.',
80
104
  settableVia: 'setup',
81
105
  valueHint: 'comma-separated list of: beginner,intermediate,advanced',
106
+ trust: 'preference',
82
107
  },
83
108
  {
84
109
  key: 'minStars',
85
110
  description: 'Minimum stargazers required for a repo to surface during discovery.',
86
111
  settableVia: 'setup',
87
112
  valueHint: 'non-negative integer',
113
+ trust: 'preference',
88
114
  },
89
115
  {
90
116
  key: 'includeDocIssues',
91
117
  description: 'Whether documentation-only issues should appear in discovery.',
92
118
  settableVia: 'setup',
93
119
  valueHint: 'true|false',
120
+ trust: 'preference',
94
121
  },
95
122
  {
96
123
  key: 'maxIssueAgeDays',
97
124
  description: 'Maximum age (in days) for an issue to be considered in discovery.',
98
125
  settableVia: 'setup',
99
126
  valueHint: 'positive integer',
127
+ trust: 'preference',
100
128
  },
101
129
  {
102
130
  key: 'skipBroadWhenSufficientResults',
103
131
  description: 'Skip the broad discovery phase once this many candidates from new repos are found (0 = always run the broad phase). Affinity/starred-repo candidates do not count toward it.',
104
132
  settableVia: 'setup',
105
133
  valueHint: 'non-negative integer (0 disables)',
134
+ trust: 'preference',
106
135
  },
107
136
  {
108
137
  key: 'complexIssues',
109
138
  description: 'Surface larger issues in repos where you already have a merged PR: only a PR that closes the issue counts as an existing PR, and maintainer-filed issues pass without code in the body.',
110
139
  settableVia: 'setup',
111
140
  valueHint: 'off|warm',
141
+ trust: 'preference',
112
142
  },
113
143
  {
114
144
  key: 'minRepoScoreThreshold',
115
145
  description: 'Minimum repo maintainer-health score required for discovery (0–10).',
116
146
  settableVia: 'setup',
117
147
  valueHint: 'non-negative integer',
148
+ trust: 'preference',
118
149
  },
119
150
  {
120
151
  key: 'projectCategories',
121
152
  description: 'Project categories to prioritize (whole-list replace).',
122
153
  settableVia: 'setup',
123
154
  valueHint: 'comma-separated list of: nonprofit,devtools,infrastructure,web-frameworks,data-ml,education',
155
+ trust: 'preference',
124
156
  },
125
157
  {
126
158
  key: 'preferredOrgs',
127
159
  description: 'GitHub orgs to prioritize during discovery (whole-list replace).',
128
160
  settableVia: 'setup',
129
161
  valueHint: 'comma-separated list',
162
+ trust: 'preference',
130
163
  },
131
164
  {
132
165
  key: 'untrackedOrgs',
133
166
  description: 'GitHub orgs whose PRs are not tracked (e.g. work repos). Discovery is unaffected (whole-list replace).',
134
167
  settableVia: 'setup',
135
168
  valueHint: 'comma-separated list',
169
+ trust: 'preference',
136
170
  },
137
171
  {
138
172
  key: 'aiPolicyBlocklist',
139
173
  description: 'Repos (owner/repo) with anti-AI contribution policies to block from discovery.',
140
174
  settableVia: 'setup',
141
175
  valueHint: 'comma-separated list of owner/repo',
176
+ trust: 'safeguard',
177
+ },
178
+ {
179
+ key: 'keepForks',
180
+ description: 'Forks (owner/repo, or their parent) that fork-prune never deletes (whole-list replace).',
181
+ settableVia: 'setup',
182
+ valueHint: 'comma-separated list of owner/repo',
183
+ trust: 'safeguard',
142
184
  },
143
185
  {
144
186
  key: 'avoidRepos',
145
187
  description: 'Repos (owner/repo) to softly downrank in discovery results — milder than excludeRepos (whole-list replace).',
146
188
  settableVia: 'setup',
147
189
  valueHint: 'comma-separated list of owner/repo',
190
+ trust: 'preference',
148
191
  },
149
192
  {
150
193
  key: 'boostIssueTypes',
151
194
  description: 'Issue label types to softly boost in discovery ranking (whole-list replace).',
152
195
  settableVia: 'setup',
153
196
  valueHint: 'comma-separated list (e.g. bug,good first issue)',
197
+ trust: 'preference',
154
198
  },
155
199
  // ── Exclusion list mutators (config-only) ────────────────────────────
156
200
  {
@@ -158,66 +202,77 @@ export const CONFIG_KEY_REGISTRY = [
158
202
  description: 'Append a language to the discovery languages list.',
159
203
  settableVia: 'config',
160
204
  valueHint: 'string',
205
+ trust: 'preference',
161
206
  },
162
207
  {
163
208
  key: 'add-label',
164
209
  description: 'Append a label to the discovery labels list.',
165
210
  settableVia: 'config',
166
211
  valueHint: 'string',
212
+ trust: 'preference',
167
213
  },
168
214
  {
169
215
  key: 'remove-label',
170
216
  description: 'Remove a label from the discovery labels list.',
171
217
  settableVia: 'config',
172
218
  valueHint: 'string (must already be present)',
219
+ trust: 'preference',
173
220
  },
174
221
  {
175
222
  key: 'add-scope',
176
223
  description: 'Append a scope to the discovery scope list.',
177
224
  settableVia: 'config',
178
225
  valueHint: 'one of: beginner,intermediate,advanced',
226
+ trust: 'preference',
179
227
  },
180
228
  {
181
229
  key: 'remove-scope',
182
230
  description: 'Remove a scope from the discovery scope list.',
183
231
  settableVia: 'config',
184
232
  valueHint: 'one of: beginner,intermediate,advanced',
233
+ trust: 'preference',
185
234
  },
186
235
  {
187
236
  key: 'exclude-repo',
188
237
  description: 'Exclude a specific repo (owner/repo) from discovery.',
189
238
  settableVia: 'config',
190
239
  valueHint: 'owner/repo',
240
+ trust: 'preference',
191
241
  },
192
242
  {
193
243
  key: 'exclude-org',
194
244
  description: 'Exclude an entire org from discovery.',
195
245
  settableVia: 'config',
196
246
  valueHint: 'org name (no slash)',
247
+ trust: 'preference',
197
248
  },
198
249
  {
199
250
  key: 'add-avoid-repo',
200
251
  description: 'Append a repo (owner/repo) to the soft-downrank avoid list.',
201
252
  settableVia: 'config',
202
253
  valueHint: 'owner/repo',
254
+ trust: 'preference',
203
255
  },
204
256
  {
205
257
  key: 'remove-avoid-repo',
206
258
  description: 'Remove a repo from the soft-downrank avoid list.',
207
259
  settableVia: 'config',
208
260
  valueHint: 'owner/repo (must already be present)',
261
+ trust: 'preference',
209
262
  },
210
263
  {
211
264
  key: 'add-boost-issue-type',
212
265
  description: 'Append an issue label type to the discovery ranking boost list.',
213
266
  settableVia: 'config',
214
267
  valueHint: 'issue label (e.g. bug)',
268
+ trust: 'preference',
215
269
  },
216
270
  {
217
271
  key: 'remove-boost-issue-type',
218
272
  description: 'Remove an issue label type from the discovery ranking boost list.',
219
273
  settableVia: 'config',
220
274
  valueHint: 'issue label (must already be present)',
275
+ trust: 'preference',
221
276
  },
222
277
  // ── Tooling ──────────────────────────────────────────────────────────
223
278
  {
@@ -225,30 +280,36 @@ export const CONFIG_KEY_REGISTRY = [
225
280
  description: 'Path to a text file of extra issue URLs to surface (per machine, not synced).',
226
281
  settableVia: 'both',
227
282
  valueHint: 'filesystem path',
283
+ trust: 'path',
228
284
  },
229
285
  {
230
286
  key: 'skippedIssuesPath',
231
287
  description: 'Path to the skipped-issues file (entries are permanent; per machine, not synced).',
232
288
  settableVia: 'setup',
233
289
  valueHint: 'filesystem path',
290
+ trust: 'path',
234
291
  },
235
292
  {
236
293
  key: 'localRepoScanPaths',
237
294
  description: 'Directories local-repos scans for clones (per machine, not synced). Empty clears it and the defaults apply.',
238
295
  settableVia: 'setup',
239
296
  valueHint: 'comma-separated list of directory paths',
297
+ trust: 'path',
240
298
  },
241
299
  {
242
300
  key: 'diffTool',
243
301
  description: 'Default diff renderer for reviews.',
244
302
  settableVia: 'both',
245
303
  valueHint: 'one of: inline,sourcetree,vscode,custom',
304
+ trust: 'preference',
305
+ commandValues: ['custom'],
246
306
  },
247
307
  {
248
308
  key: 'diffToolCustomCommand',
249
309
  description: 'Shell command template used when diffTool=custom.',
250
310
  settableVia: 'both',
251
311
  valueHint: 'shell command with {old}/{new} placeholders',
312
+ trust: 'command',
252
313
  },
253
314
  // ── Behavior ─────────────────────────────────────────────────────────
254
315
  {
@@ -256,42 +317,49 @@ export const CONFIG_KEY_REGISTRY = [
256
317
  description: 'Default merge strategy — squash-merge, prompt, or standard merge.',
257
318
  settableVia: 'setup',
258
319
  valueHint: 'true|false|ask',
320
+ trust: 'preference',
259
321
  },
260
322
  {
261
323
  key: 'persistence',
262
324
  description: 'Where to store state.json — local file or GitHub Gist.',
263
325
  settableVia: 'setup',
264
326
  valueHint: 'one of: local,gist',
327
+ trust: 'preference',
265
328
  },
266
329
  {
267
330
  key: 'autoExtractLearnings',
268
331
  description: 'Extract per-repo learnings from freshly merged PRs automatically at /oss startup and overnight (#1696). false restores the extract_learnings action-menu item.',
269
332
  settableVia: 'setup',
270
333
  valueHint: 'true|false',
334
+ trust: 'preference',
271
335
  },
272
336
  {
273
337
  key: 'autoFormatBeforePush',
274
338
  description: 'Retired: not read by oss-autopilot since #1642. Accepted and stored for compatibility; will be removed in the next major version.',
275
339
  settableVia: 'setup',
276
340
  valueHint: 'true|false',
341
+ trust: 'preference',
277
342
  },
278
343
  {
279
344
  key: 'trustOwnRepoWrites',
280
345
  description: 'Retired: not read by oss-autopilot since #1642. Accepted and stored for compatibility; will be removed in the next major version.',
281
346
  settableVia: 'setup',
282
347
  valueHint: 'true|false',
348
+ trust: 'preference',
283
349
  },
284
350
  {
285
351
  key: 'healthCheckFreshnessMinutes',
286
352
  description: 'Retired: not read by oss-autopilot since #1642. Accepted and stored for compatibility; will be removed in the next major version.',
287
353
  settableVia: 'setup',
288
354
  valueHint: 'positive integer',
355
+ trust: 'preference',
289
356
  },
290
357
  {
291
358
  key: 'reviewMaxPasses',
292
359
  description: 'Convergence cap for the multi-agent review loop in workflows/dispatch-review.md. Optional; falls back to per-mode defaults (5 for diff, 3 for plan) when unset (#1275).',
293
360
  settableVia: 'setup',
294
361
  valueHint: 'positive integer',
362
+ trust: 'preference',
295
363
  },
296
364
  // ── Setup-only completion flag ──────────────────────────────────────
297
365
  {
@@ -299,6 +367,7 @@ export const CONFIG_KEY_REGISTRY = [
299
367
  description: 'Internal marker that initial setup has finished. Normally set by the wizard — `setup --set complete=true` is a manual override.',
300
368
  settableVia: 'setup',
301
369
  valueHint: 'true',
370
+ trust: 'preference',
302
371
  },
303
372
  // ── Auto-managed (listed for auditability; not user-settable) ────────
304
373
  {
@@ -306,12 +375,14 @@ export const CONFIG_KEY_REGISTRY = [
306
375
  description: 'Cache of the user’s starred repos. Refreshed automatically during discovery.',
307
376
  settableVia: 'auto',
308
377
  valueHint: '(managed internally)',
378
+ trust: 'preference',
309
379
  },
310
380
  {
311
381
  key: 'starredReposLastFetched',
312
382
  description: 'Timestamp of the last starredRepos refresh.',
313
383
  settableVia: 'auto',
314
384
  valueHint: '(managed internally)',
385
+ trust: 'preference',
315
386
  },
316
387
  ];
317
388
  const KEY_INDEX = new Map(CONFIG_KEY_REGISTRY.map((def) => [def.key, def]));
@@ -321,6 +392,16 @@ export function isKnownKey(key) {
321
392
  export function getKeyDef(key) {
322
393
  return KEY_INDEX.get(key);
323
394
  }
395
+ /**
396
+ * The trust tier of writing `value` to `key` (see {@link ConfigTrust}).
397
+ * Unknown keys read as `preference`; the commands reject them anyway.
398
+ */
399
+ export function getKeyTrust(key, value) {
400
+ const def = KEY_INDEX.get(key);
401
+ if (value !== undefined && def?.commandValues?.includes(value))
402
+ return 'command';
403
+ return def?.trust ?? 'preference';
404
+ }
324
405
  /** Keys accepted by the `setup --set` command (includes `both`). */
325
406
  export function getSetupKeys() {
326
407
  return CONFIG_KEY_REGISTRY.filter((d) => d.settableVia === 'setup' || d.settableVia === 'both').map((d) => d.key);
@@ -30,7 +30,10 @@ export declare function shelveReasonsOf(pr: Pick<FetchedPR, 'status' | 'actionRe
30
30
  * addressing, and something must be new since it was shelved: maintainer
31
31
  * activity after the shelve, or an action reason not among the recorded ones.
32
32
  * A PR shelved while it already needed addressing stays shelved until then,
33
- * also when one of its recorded reasons clears or comes back.
33
+ * also when one of its recorded reasons clears or comes back. A
34
+ * maintainer-driven reason (needs_response, needs_changes) missing from the
35
+ * record counts only through maintainer activity after the shelve, since the
36
+ * digest the record came from may be older than that activity (#2043).
34
37
  * A record without reasons (the PR was not in the digest at shelve time)
35
38
  * only unshelves on maintainer activity; the daily run then fills the reasons
36
39
  * in. Without a shelve record (shelved before `config.shelvedPRInfo` existed)
@@ -38,12 +38,22 @@ export function shelveReasonsOf(pr) {
38
38
  return pr.actionReasons;
39
39
  return [pr.actionReason ?? 'needs_addressing'];
40
40
  }
41
+ /**
42
+ * Action reasons only a maintainer's comment or review creates. The recorded
43
+ * reasons come from the last digest, which can predate the shelve, so one of
44
+ * these missing from the record proves nothing; it is new only when the
45
+ * maintainer activity behind it came after the shelve (#2043).
46
+ */
47
+ const MAINTAINER_ACTION_REASONS = new Set(['needs_response', 'needs_changes']);
41
48
  /**
42
49
  * Whether an explicitly shelved PR goes back to active (#1922). It must need
43
50
  * addressing, and something must be new since it was shelved: maintainer
44
51
  * activity after the shelve, or an action reason not among the recorded ones.
45
52
  * A PR shelved while it already needed addressing stays shelved until then,
46
- * also when one of its recorded reasons clears or comes back.
53
+ * also when one of its recorded reasons clears or comes back. A
54
+ * maintainer-driven reason (needs_response, needs_changes) missing from the
55
+ * record counts only through maintainer activity after the shelve, since the
56
+ * digest the record came from may be older than that activity (#2043).
47
57
  * A record without reasons (the PR was not in the digest at shelve time)
48
58
  * only unshelves on maintainer activity; the daily run then fills the reasons
49
59
  * in. Without a shelve record (shelved before `config.shelvedPRInfo` existed)
@@ -58,7 +68,8 @@ export function shouldAutoUnshelve(pr, shelvedPRInfo) {
58
68
  if (!info || !pr.lastMaintainerActivityAt)
59
69
  return true;
60
70
  const known = info.reasons;
61
- if (known && shelveReasonsOf(pr).some((reason) => !known.includes(reason)))
71
+ const isNew = (reason) => !MAINTAINER_ACTION_REASONS.has(reason) && !known?.includes(reason);
72
+ if (known && shelveReasonsOf(pr).some((reason) => isNew(reason)))
62
73
  return true;
63
74
  const activityMs = Date.parse(pr.lastMaintainerActivityAt);
64
75
  const shelvedMs = Date.parse(info.at);