@oss-autopilot/core 3.42.4 → 3.43.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 (172) hide show
  1. package/dist/cli-pre-action.js +8 -3
  2. package/dist/cli-registry.js +272 -25
  3. package/dist/cli.bundle.cjs +183 -154
  4. package/dist/commands/check-integration.js +1 -0
  5. package/dist/commands/cleanup.d.ts +76 -0
  6. package/dist/commands/cleanup.js +269 -0
  7. package/dist/commands/comments.d.ts +6 -0
  8. package/dist/commands/comments.js +6 -2
  9. package/dist/commands/config.js +37 -5
  10. package/dist/commands/daily-dismiss-filter.d.ts +7 -0
  11. package/dist/commands/daily-dismiss-filter.js +17 -1
  12. package/dist/commands/daily-ledger.d.ts +122 -0
  13. package/dist/commands/daily-ledger.js +225 -0
  14. package/dist/commands/daily-recent-prs.d.ts +26 -0
  15. package/dist/commands/daily-recent-prs.js +55 -0
  16. package/dist/commands/daily.d.ts +2 -1
  17. package/dist/commands/daily.js +59 -89
  18. package/dist/commands/dashboard-cache.d.ts +2 -0
  19. package/dist/commands/dashboard-cache.js +33 -8
  20. package/dist/commands/dashboard-data.js +71 -36
  21. package/dist/commands/dashboard-gist-sync.js +3 -1
  22. package/dist/commands/dashboard-lifecycle.js +1 -1
  23. package/dist/commands/dashboard-process.d.ts +14 -1
  24. package/dist/commands/dashboard-process.js +46 -7
  25. package/dist/commands/dashboard-server.js +89 -23
  26. package/dist/commands/detect-formatters.js +1 -0
  27. package/dist/commands/dismiss.js +5 -2
  28. package/dist/commands/doctor.d.ts +15 -1
  29. package/dist/commands/doctor.js +73 -5
  30. package/dist/commands/draft.d.ts +77 -0
  31. package/dist/commands/draft.js +218 -0
  32. package/dist/commands/eval.js +1 -0
  33. package/dist/commands/guidelines.d.ts +23 -1
  34. package/dist/commands/guidelines.js +49 -4
  35. package/dist/commands/index.d.ts +24 -4
  36. package/dist/commands/index.js +15 -3
  37. package/dist/commands/issue-thread.d.ts +46 -0
  38. package/dist/commands/issue-thread.js +123 -0
  39. package/dist/commands/ledger-backfill.d.ts +9 -0
  40. package/dist/commands/ledger-backfill.js +44 -1
  41. package/dist/commands/list-mark-done.d.ts +2 -1
  42. package/dist/commands/list-mark-done.js +3 -1
  43. package/dist/commands/list-move-tier.d.ts +2 -1
  44. package/dist/commands/list-move-tier.js +3 -1
  45. package/dist/commands/local-repos.js +10 -5
  46. package/dist/commands/locate-issue-list.d.ts +40 -17
  47. package/dist/commands/locate-issue-list.js +148 -88
  48. package/dist/commands/move.js +7 -1
  49. package/dist/commands/overnight-handoff.d.ts +17 -7
  50. package/dist/commands/overnight-handoff.js +36 -14
  51. package/dist/commands/overnight-push-prep.d.ts +13 -8
  52. package/dist/commands/overnight-push-prep.js +106 -34
  53. package/dist/commands/overnight-tool-rules.d.ts +54 -0
  54. package/dist/commands/overnight-tool-rules.js +217 -0
  55. package/dist/commands/overnight.d.ts +5 -6
  56. package/dist/commands/overnight.js +61 -140
  57. package/dist/commands/parse-list.js +7 -1
  58. package/dist/commands/policy.d.ts +86 -0
  59. package/dist/commands/policy.js +263 -0
  60. package/dist/commands/pr-preflight.d.ts +43 -0
  61. package/dist/commands/pr-preflight.js +294 -0
  62. package/dist/commands/repo-vet.d.ts +9 -0
  63. package/dist/commands/repo-vet.js +36 -11
  64. package/dist/commands/scout-bridge.js +18 -8
  65. package/dist/commands/search.js +7 -0
  66. package/dist/commands/setup.d.ts +3 -3
  67. package/dist/commands/setup.js +46 -18
  68. package/dist/commands/skip-add.js +10 -1
  69. package/dist/commands/startup.d.ts +5 -3
  70. package/dist/commands/startup.js +65 -49
  71. package/dist/commands/state-cmd.d.ts +2 -0
  72. package/dist/commands/state-cmd.js +5 -1
  73. package/dist/commands/stats.js +1 -0
  74. package/dist/commands/status.js +1 -0
  75. package/dist/commands/strategy.js +1 -0
  76. package/dist/commands/vet-list.d.ts +6 -0
  77. package/dist/commands/vet-list.js +25 -0
  78. package/dist/commands/vet.d.ts +12 -0
  79. package/dist/commands/vet.js +118 -1
  80. package/dist/core/__fixtures__/prompt-injection-payloads.js +31 -0
  81. package/dist/core/anti-llm-policy.d.ts +3 -0
  82. package/dist/core/anti-llm-policy.js +3 -0
  83. package/dist/core/auth.js +2 -0
  84. package/dist/core/checklist-analysis.js +50 -12
  85. package/dist/core/ci-analysis.d.ts +7 -2
  86. package/dist/core/ci-analysis.js +76 -21
  87. package/dist/core/comment-utils.d.ts +1 -1
  88. package/dist/core/comment-utils.js +7 -1
  89. package/dist/core/commit-date.d.ts +19 -0
  90. package/dist/core/commit-date.js +17 -0
  91. package/dist/core/compliance-score.js +11 -7
  92. package/dist/core/config-registry.js +11 -5
  93. package/dist/core/contributing.d.ts +2 -3
  94. package/dist/core/contributing.js +2 -3
  95. package/dist/core/daily-logic.d.ts +27 -5
  96. package/dist/core/daily-logic.js +57 -19
  97. package/dist/core/errors.d.ts +37 -3
  98. package/dist/core/errors.js +54 -5
  99. package/dist/core/gist-health.d.ts +15 -3
  100. package/dist/core/gist-health.js +8 -0
  101. package/dist/core/gist-state-store.d.ts +24 -4
  102. package/dist/core/gist-state-store.js +97 -46
  103. package/dist/core/github-stats.d.ts +104 -16
  104. package/dist/core/github-stats.js +282 -97
  105. package/dist/core/http-cache.d.ts +0 -10
  106. package/dist/core/http-cache.js +0 -19
  107. package/dist/core/index.d.ts +12 -5
  108. package/dist/core/index.js +15 -5
  109. package/dist/core/issue-conversation.d.ts +8 -2
  110. package/dist/core/issue-conversation.js +31 -12
  111. package/dist/core/local-config.d.ts +95 -0
  112. package/dist/core/local-config.js +271 -0
  113. package/dist/core/merged-pr-notes.d.ts +2 -2
  114. package/dist/core/pagination.d.ts +55 -0
  115. package/dist/core/pagination.js +59 -0
  116. package/dist/core/paths.d.ts +7 -0
  117. package/dist/core/paths.js +9 -0
  118. package/dist/core/pr-assembly.js +6 -2
  119. package/dist/core/pr-graphql.d.ts +37 -3
  120. package/dist/core/pr-graphql.js +73 -12
  121. package/dist/core/pr-monitor.d.ts +29 -12
  122. package/dist/core/pr-monitor.js +71 -23
  123. package/dist/core/pr-preflight.d.ts +113 -0
  124. package/dist/core/pr-preflight.js +364 -0
  125. package/dist/core/pr-quality-rubric.d.ts +0 -6
  126. package/dist/core/pr-quality-rubric.js +0 -8
  127. package/dist/core/pr-template.d.ts +2 -0
  128. package/dist/core/pr-template.js +5 -1
  129. package/dist/core/repo-policy.d.ts +105 -0
  130. package/dist/core/repo-policy.js +400 -0
  131. package/dist/core/repo-score-manager.d.ts +48 -0
  132. package/dist/core/repo-score-manager.js +111 -1
  133. package/dist/core/review-analysis.d.ts +34 -19
  134. package/dist/core/review-analysis.js +74 -19
  135. package/dist/core/reviewed-prs-fetch.js +11 -29
  136. package/dist/core/reviewed-prs.js +8 -15
  137. package/dist/core/stale-data.d.ts +41 -0
  138. package/dist/core/stale-data.js +115 -0
  139. package/dist/core/state-persistence.d.ts +62 -27
  140. package/dist/core/state-persistence.js +338 -117
  141. package/dist/core/state-schema.d.ts +113 -210
  142. package/dist/core/state-schema.js +165 -80
  143. package/dist/core/state.d.ts +60 -8
  144. package/dist/core/state.js +192 -46
  145. package/dist/core/status-determination.js +26 -8
  146. package/dist/core/strategy.js +3 -1
  147. package/dist/core/types.d.ts +22 -1
  148. package/dist/core/types.js +1 -0
  149. package/dist/core/untrusted-content.d.ts +30 -11
  150. package/dist/core/untrusted-content.js +77 -42
  151. package/dist/core/urls.d.ts +9 -0
  152. package/dist/core/urls.js +18 -0
  153. package/dist/dashboard/assets/{chart-panel-DPKNBUts.js → chart-panel-C_C1lFTI.js} +1 -1
  154. package/dist/dashboard/assets/{index-B25bZOYX.js → index-B--H66Jk.js} +1 -1
  155. package/dist/dashboard/index.html +1 -1
  156. package/dist/formatters/json.d.ts +262 -6
  157. package/dist/formatters/json.js +77 -1
  158. package/package.json +1 -1
  159. package/dist/core/ci-enforced-tools.d.ts +0 -35
  160. package/dist/core/ci-enforced-tools.js +0 -109
  161. package/dist/core/comment-decision.d.ts +0 -79
  162. package/dist/core/comment-decision.js +0 -82
  163. package/dist/core/extraction-categories.d.ts +0 -55
  164. package/dist/core/extraction-categories.js +0 -108
  165. package/dist/core/follow-up-history.d.ts +0 -40
  166. package/dist/core/follow-up-history.js +0 -71
  167. package/dist/core/issue-effort.d.ts +0 -29
  168. package/dist/core/issue-effort.js +0 -47
  169. package/dist/core/maintainer-hints.d.ts +0 -23
  170. package/dist/core/maintainer-hints.js +0 -36
  171. package/dist/core/workflow-state.d.ts +0 -56
  172. package/dist/core/workflow-state.js +0 -101
@@ -222,16 +222,22 @@ export const CONFIG_KEY_REGISTRY = [
222
222
  // ── Tooling ──────────────────────────────────────────────────────────
223
223
  {
224
224
  key: 'issueListPath',
225
- description: 'Path to a text file of extra issue URLs to surface.',
225
+ description: 'Path to a text file of extra issue URLs to surface (per machine, not synced).',
226
226
  settableVia: 'both',
227
227
  valueHint: 'filesystem path',
228
228
  },
229
229
  {
230
230
  key: 'skippedIssuesPath',
231
- description: 'Path to the skipped-issues file (entries are permanent).',
231
+ description: 'Path to the skipped-issues file (entries are permanent; per machine, not synced).',
232
232
  settableVia: 'setup',
233
233
  valueHint: 'filesystem path',
234
234
  },
235
+ {
236
+ key: 'localRepoScanPaths',
237
+ description: 'Directories local-repos scans for clones (per machine, not synced). Empty clears it and the defaults apply.',
238
+ settableVia: 'setup',
239
+ valueHint: 'comma-separated list of directory paths',
240
+ },
235
241
  {
236
242
  key: 'diffTool',
237
243
  description: 'Default diff renderer for reviews.',
@@ -265,19 +271,19 @@ export const CONFIG_KEY_REGISTRY = [
265
271
  },
266
272
  {
267
273
  key: 'autoFormatBeforePush',
268
- description: 'No effect. The hook that used this setting was removed in #1642; the key is kept in the schema for state-file compatibility.',
274
+ description: 'Retired: not read by oss-autopilot since #1642. Accepted and stored for compatibility; will be removed in the next major version.',
269
275
  settableVia: 'setup',
270
276
  valueHint: 'true|false',
271
277
  },
272
278
  {
273
279
  key: 'trustOwnRepoWrites',
274
- description: 'No effect. The hook that used this setting was removed in #1642; the key is kept in the schema for state-file compatibility.',
280
+ description: 'Retired: not read by oss-autopilot since #1642. Accepted and stored for compatibility; will be removed in the next major version.',
275
281
  settableVia: 'setup',
276
282
  valueHint: 'true|false',
277
283
  },
278
284
  {
279
285
  key: 'healthCheckFreshnessMinutes',
280
- description: 'No effect. The hook that used this setting was removed in #1642; the key is kept in the schema for state-file compatibility.',
286
+ description: 'Retired: not read by oss-autopilot since #1642. Accepted and stored for compatibility; will be removed in the next major version.',
281
287
  settableVia: 'setup',
282
288
  valueHint: 'positive integer',
283
289
  },
@@ -8,9 +8,8 @@
8
8
  * (#1242), strategy (#1243), and the recent #1252 / #1264 / #1286
9
9
  * extractions.
10
10
  *
11
- * Pure typed helper — no I/O. Callers (the workflow runner, the
12
- * `pr-compliance-checker` agent) read the file themselves and pass
13
- * the contents in. The extraction step is heuristic regex matching
11
+ * Pure typed helper — no I/O. The caller (`derivePolicy` in
12
+ * repo-policy.ts, #1953) reads the file and passes the contents in. The extraction step is heuristic regex matching
14
13
  * over headings + bullet phrases; it intentionally over-recalls
15
14
  * (some false positives) rather than under-recalling.
16
15
  *
@@ -8,9 +8,8 @@
8
8
  * (#1242), strategy (#1243), and the recent #1252 / #1264 / #1286
9
9
  * extractions.
10
10
  *
11
- * Pure typed helper — no I/O. Callers (the workflow runner, the
12
- * `pr-compliance-checker` agent) read the file themselves and pass
13
- * the contents in. The extraction step is heuristic regex matching
11
+ * Pure typed helper — no I/O. The caller (`derivePolicy` in
12
+ * repo-policy.ts, #1953) reads the file and passes the contents in. The extraction step is heuristic regex matching
14
13
  * over headings + bullet phrases; it intentionally over-recalls
15
14
  * (some false positives) rather than under-recalling.
16
15
  *
@@ -10,17 +10,40 @@
10
10
  * - toShelvedPRRef — lightweight projection for digest display
11
11
  *
12
12
  * Rendering functions (formatActionHint, formatBriefSummary, formatSummary,
13
- * printDigest) live in src/commands/daily-render.ts (#1117). This file
14
- * re-exports them at the bottom so existing imports keep working without
15
- * a sweep.
13
+ * printDigest) live in src/commands/daily-render.ts (#1117).
16
14
  */
17
15
  import type { AttentionSummary } from './pr-attention.js';
18
- import type { FetchedPR, FetchedPRStatus, StalenessTier, ActionReason, AgentState, ShelvedPRRef, ComputedRepoSignals, RepoGroup, CommentedIssue, CapacityAssessment, ActionableIssue, ActionMenu, StarFilter } from './types.js';
16
+ import type { FetchedPR, FetchedPRStatus, StalenessTier, ActionReason, AgentState, DailyDigest, ShelvedPRRef, ComputedRepoSignals, RepoGroup, CommentedIssue, CapacityAssessment, ActionableIssue, ActionMenu, StarFilter } from './types.js';
19
17
  /**
20
18
  * Statuses indicating action needed from the contributor.
21
19
  * Used for auto-unshelving shelved PRs.
22
20
  */
23
21
  export declare const CRITICAL_STATUSES: ReadonlySet<FetchedPRStatus>;
22
+ /**
23
+ * The action reasons a shelve record stores and compares (#1922): every
24
+ * reason the PR has while it needs addressing, none when it does not. A PR
25
+ * that carries only a primary reason yields that one.
26
+ */
27
+ export declare function shelveReasonsOf(pr: Pick<FetchedPR, 'status' | 'actionReason' | 'actionReasons'>): string[];
28
+ /**
29
+ * Whether an explicitly shelved PR goes back to active (#1922). It must need
30
+ * addressing, and something must be new since it was shelved: maintainer
31
+ * activity after the shelve, or an action reason not among the recorded ones.
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.
34
+ * A record without reasons (the PR was not in the digest at shelve time)
35
+ * only unshelves on maintainer activity; the daily run then fills the reasons
36
+ * in. Without a shelve record (shelved before `config.shelvedPRInfo` existed)
37
+ * or a known maintainer-activity time, needing addressing alone unshelves it.
38
+ *
39
+ * @param shelvedPRInfo - `config.shelvedPRInfo`, keyed by `issueRefKey`
40
+ */
41
+ export declare function shouldAutoUnshelve(pr: Pick<FetchedPR, 'url' | 'status' | 'actionReason' | 'actionReasons' | 'lastMaintainerActivityAt'>, shelvedPRInfo: AgentState['config']['shelvedPRInfo'] | undefined): boolean;
42
+ /**
43
+ * A PR shelved while it needs addressing stays shelved (#1922): keep it out
44
+ * of the Needs Addressing list the brief and --json output render.
45
+ */
46
+ export declare function withoutShelvedNeedsAddressing(digest: DailyDigest, shelvedPRs: ShelvedPRRef[]): DailyDigest;
24
47
  /**
25
48
  * ActionReason values that indicate high-priority issues blocking capacity.
26
49
  * `incomplete_checklist` is excluded — it's actionable but not blocking.
@@ -208,4 +231,3 @@ export declare function computeActionMenu(actionableIssues: ActionableIssue[], c
208
231
  * dismiss filter.
209
232
  */
210
233
  export declare function isCoveredByDismiss(dismissedAt: string, lastResponseAt: string): boolean;
211
- export { formatActionHint, formatBriefSummary, formatSummary, printDigest } from '../commands/daily-render.js';
@@ -10,15 +10,14 @@
10
10
  * - toShelvedPRRef — lightweight projection for digest display
11
11
  *
12
12
  * Rendering functions (formatActionHint, formatBriefSummary, formatSummary,
13
- * printDigest) live in src/commands/daily-render.ts (#1117). This file
14
- * re-exports them at the bottom so existing imports keep working without
15
- * a sweep.
13
+ * printDigest) live in src/commands/daily-render.ts (#1117).
16
14
  */
17
15
  import { warn } from './logger.js';
18
16
  import { errorMessage } from './errors.js';
19
17
  import { getStateManager } from './state.js';
20
- import { parseGitHubUrl } from './urls.js';
18
+ import { parseGitHubUrl, issueRefKey } from './urls.js';
21
19
  import { MAINTAINER_RESPONSE_RULE } from './review-analysis.js';
20
+ import { FetchedPRStatusSchema, isKnownValue } from './state-schema.js';
22
21
  // ---------------------------------------------------------------------------
23
22
  // Constants
24
23
  // ---------------------------------------------------------------------------
@@ -27,6 +26,53 @@ import { MAINTAINER_RESPONSE_RULE } from './review-analysis.js';
27
26
  * Used for auto-unshelving shelved PRs.
28
27
  */
29
28
  export const CRITICAL_STATUSES = new Set(['needs_addressing']);
29
+ /**
30
+ * The action reasons a shelve record stores and compares (#1922): every
31
+ * reason the PR has while it needs addressing, none when it does not. A PR
32
+ * that carries only a primary reason yields that one.
33
+ */
34
+ export function shelveReasonsOf(pr) {
35
+ if (!CRITICAL_STATUSES.has(pr.status))
36
+ return [];
37
+ if (pr.actionReasons?.length)
38
+ return pr.actionReasons;
39
+ return [pr.actionReason ?? 'needs_addressing'];
40
+ }
41
+ /**
42
+ * Whether an explicitly shelved PR goes back to active (#1922). It must need
43
+ * addressing, and something must be new since it was shelved: maintainer
44
+ * activity after the shelve, or an action reason not among the recorded ones.
45
+ * A PR shelved while it already needed addressing stays shelved until then,
46
+ * also when one of its recorded reasons clears or comes back.
47
+ * A record without reasons (the PR was not in the digest at shelve time)
48
+ * only unshelves on maintainer activity; the daily run then fills the reasons
49
+ * in. Without a shelve record (shelved before `config.shelvedPRInfo` existed)
50
+ * or a known maintainer-activity time, needing addressing alone unshelves it.
51
+ *
52
+ * @param shelvedPRInfo - `config.shelvedPRInfo`, keyed by `issueRefKey`
53
+ */
54
+ export function shouldAutoUnshelve(pr, shelvedPRInfo) {
55
+ if (!CRITICAL_STATUSES.has(pr.status))
56
+ return false;
57
+ const info = shelvedPRInfo?.[issueRefKey(pr.url) ?? pr.url];
58
+ if (!info || !pr.lastMaintainerActivityAt)
59
+ return true;
60
+ const known = info.reasons;
61
+ if (known && shelveReasonsOf(pr).some((reason) => !known.includes(reason)))
62
+ return true;
63
+ const activityMs = Date.parse(pr.lastMaintainerActivityAt);
64
+ const shelvedMs = Date.parse(info.at);
65
+ // An unparseable date resurfaces the PR instead of hiding it.
66
+ return Number.isNaN(activityMs) || Number.isNaN(shelvedMs) || activityMs > shelvedMs;
67
+ }
68
+ /**
69
+ * A PR shelved while it needs addressing stays shelved (#1922): keep it out
70
+ * of the Needs Addressing list the brief and --json output render.
71
+ */
72
+ export function withoutShelvedNeedsAddressing(digest, shelvedPRs) {
73
+ const shelvedUrls = new Set(shelvedPRs.map((ref) => ref.url));
74
+ return { ...digest, needsAddressingPRs: digest.needsAddressingPRs.filter((pr) => !shelvedUrls.has(pr.url)) };
75
+ }
30
76
  /**
31
77
  * ActionReason values that indicate high-priority issues blocking capacity.
32
78
  * `incomplete_checklist` is excluded — it's actionable but not blocking.
@@ -43,7 +89,6 @@ export const STALE_STATUSES = new Set(['dormant', 'approaching_dormant']);
43
89
  // ---------------------------------------------------------------------------
44
90
  // Status overrides
45
91
  // ---------------------------------------------------------------------------
46
- const VALID_OVERRIDE_STATUSES = new Set(['needs_addressing', 'waiting_on_maintainer']);
47
92
  /**
48
93
  * Apply status overrides from state to the PR list.
49
94
  * Overrides are auto-cleared if the PR has new activity since the override was set.
@@ -88,7 +133,8 @@ export function applyStatusOverrides(prs, state, failures) {
88
133
  if (!override) {
89
134
  return pr;
90
135
  }
91
- if (!VALID_OVERRIDE_STATUSES.has(override.status)) {
136
+ // A newer release may write a status this one does not know (#2005).
137
+ if (!isKnownValue(FetchedPRStatusSchema.options, override.status)) {
92
138
  warn('daily-logic', `Invalid override status "${override.status}" for ${pr.url} — ignoring`);
93
139
  return pr;
94
140
  }
@@ -559,8 +605,8 @@ export function computeActionMenu(actionableIssues, capacity, commentedIssues =
559
605
  }
560
606
  // Closed-PR status nudge (#1863) — the user's PR closed without merge and
561
607
  // the linked issue has heard nothing from them since. Routes to
562
- // workflows/closed-pr-status-update.md, which drafts the comment through
563
- // draft-review-post; nothing posts automatically. Self-clears once the
608
+ // workflows/closed-pr-status-update.md, which drafts the comment as a draft
609
+ // file and posts only after approval. Self-clears once the
564
610
  // user comments on the issue or the PR leaves the recently-closed window.
565
611
  if (closedPRStatusCount > 0) {
566
612
  items.push({
@@ -572,7 +618,7 @@ export function computeActionMenu(actionableIssues, capacity, commentedIssues =
572
618
  // Merged-PR notes (#1861) — a maintainer thanked the user or explained a
573
619
  // change at merge time and nobody answered. Routes to
574
620
  // workflows/merged-pr-notes.md, which classifies each note and drafts the
575
- // reply through draft-review-post; nothing posts automatically. Self-clears
621
+ // reply as a draft file, posted only after approval. Self-clears
576
622
  // once the user comments on the PR, dismisses its URL, or the PR leaves
577
623
  // the recently-merged window.
578
624
  if (mergedPRNotesCount > 0) {
@@ -586,8 +632,8 @@ export function computeActionMenu(actionableIssues, capacity, commentedIssues =
586
632
  // the author pushed commits or replied since the user's last review or
587
633
  // comment. Routes to workflows/review-follow-ups.md, which re-reviews the
588
634
  // compare range (or the commit list after a rebase) through review-panel
589
- // and drafts answers through draft-review-post; nothing posts
590
- // automatically. Self-clears once the user reviews or comments again,
635
+ // and drafts answers as draft files; nothing posts without the user's
636
+ // approval. Self-clears once the user reviews or comments again,
591
637
  // dismisses the PR URL, or the PR closes. Never counted in capacity.
592
638
  if (reviewedPRCount > 0) {
593
639
  items.push({
@@ -657,11 +703,3 @@ export function isCoveredByDismiss(dismissedAt, lastResponseAt) {
657
703
  return false;
658
704
  return dismissedMs >= responseMs;
659
705
  }
660
- // ---------------------------------------------------------------------------
661
- // Rendering re-exports (back-compat)
662
- // ---------------------------------------------------------------------------
663
- //
664
- // The actual implementations live in src/commands/daily-render.ts. Existing
665
- // callers that import these from `core/daily-logic` continue to work; new
666
- // callers should import from `commands/daily-render` directly.
667
- export { formatActionHint, formatBriefSummary, formatSummary, printDigest } from '../commands/daily-render.js';
@@ -7,6 +7,7 @@
7
7
  * propagate to the caller via isRateLimitError/isRateLimitOrAuthError.
8
8
  * Other errors degrade gracefully — modules return partial results and log warnings.
9
9
  */
10
+ import type { StateFileIdentity } from './state-persistence.js';
10
11
  /**
11
12
  * Base error for all oss-autopilot errors.
12
13
  */
@@ -69,13 +70,36 @@ export declare class GistCorruptError extends ConfigurationError {
69
70
  *
70
71
  * Library consumers should call `stateManager.reloadIfChanged()` and
71
72
  * re-apply their mutation. The runtime `message` is phrased for CLI
72
- * end-users; the structured `expectedMtimeMs` / `actualMtimeMs` fields
73
- * are for programmatic handling.
73
+ * end-users; the structured fields are for programmatic handling.
74
+ * `expectedMtimeMs` / `actualMtimeMs` stay for compatibility, but the check
75
+ * compares the whole file identity (mtime, inode, size; #2006), so the two
76
+ * mtimes can be equal. `expectedIdentity` / `actualIdentity` carry what was
77
+ * compared; they are undefined when no comparison ran (a lock timeout).
78
+ * An `actualIdentity` with a NaN mtime means the file could not be stat'ed.
74
79
  */
75
80
  export declare class ConcurrencyError extends OssAutopilotError {
76
81
  readonly expectedMtimeMs: number;
77
82
  readonly actualMtimeMs: number;
78
- constructor(expectedMtimeMs: number, actualMtimeMs: number);
83
+ readonly expectedIdentity?: StateFileIdentity | undefined;
84
+ readonly actualIdentity?: StateFileIdentity | undefined;
85
+ constructor(expectedMtimeMs: number, actualMtimeMs: number, message?: string, expectedIdentity?: StateFileIdentity | undefined, actualIdentity?: StateFileIdentity | undefined);
86
+ }
87
+ /**
88
+ * Thrown when the state.json advisory lock stayed held for the whole bounded
89
+ * wait (#1951). The write was not made. A {@link ConcurrencyError} so callers
90
+ * that reload and retry on a writer collision do the same here.
91
+ */
92
+ export declare class StateLockTimeoutError extends ConcurrencyError {
93
+ constructor(lockPath: string, waitedMs: number);
94
+ }
95
+ /**
96
+ * Thrown when stored state (the state file, the Gist, or its local cache)
97
+ * carries a schema version above this release's (#1951). It is not corruption:
98
+ * it is never restored over, replaced by fresh state, or moved aside. A
99
+ * {@link ConfigurationError} because it stays until the user updates.
100
+ */
101
+ export declare class NewerStateVersionError extends ConfigurationError {
102
+ constructor(source: string, version: number, supported: number);
79
103
  }
80
104
  /**
81
105
  * Thrown when a Gist push collides with a concurrent write from another
@@ -105,6 +129,16 @@ export declare const GIST_FILE_SIZE_REMEDY: string;
105
129
  export declare class GistFileSizeError extends ConfigurationError {
106
130
  constructor(message: string);
107
131
  }
132
+ /**
133
+ * The search for the existing state Gist could not settle whether one exists:
134
+ * the Gist list is longer than the search window, or the only Gist carrying
135
+ * the state description is public. A {@link ConfigurationError} because
136
+ * retrying cannot fix it and creating a new Gist would fork state across
137
+ * machines (#1926); the message says which Gist ID to write to the gist-id file.
138
+ */
139
+ export declare class GistDiscoveryError extends ConfigurationError {
140
+ constructor(message: string);
141
+ }
108
142
  /**
109
143
  * Extract a human-readable message from an unknown error value.
110
144
  */
@@ -105,20 +105,56 @@ export class GistCorruptError extends ConfigurationError {
105
105
  *
106
106
  * Library consumers should call `stateManager.reloadIfChanged()` and
107
107
  * re-apply their mutation. The runtime `message` is phrased for CLI
108
- * end-users; the structured `expectedMtimeMs` / `actualMtimeMs` fields
109
- * are for programmatic handling.
108
+ * end-users; the structured fields are for programmatic handling.
109
+ * `expectedMtimeMs` / `actualMtimeMs` stay for compatibility, but the check
110
+ * compares the whole file identity (mtime, inode, size; #2006), so the two
111
+ * mtimes can be equal. `expectedIdentity` / `actualIdentity` carry what was
112
+ * compared; they are undefined when no comparison ran (a lock timeout).
113
+ * An `actualIdentity` with a NaN mtime means the file could not be stat'ed.
110
114
  */
111
115
  export class ConcurrencyError extends OssAutopilotError {
112
116
  expectedMtimeMs;
113
117
  actualMtimeMs;
114
- constructor(expectedMtimeMs, actualMtimeMs) {
115
- super('Another oss-autopilot process wrote state.json concurrently. ' +
116
- 'Re-run the command to retry — the last write wins and no data was lost from the other process.', 'CONCURRENCY_ERROR');
118
+ expectedIdentity;
119
+ actualIdentity;
120
+ constructor(expectedMtimeMs, actualMtimeMs, message = 'Another oss-autopilot process wrote state.json concurrently. ' +
121
+ 'Re-run the command to retry — the last write wins and no data was lost from the other process.', expectedIdentity, actualIdentity) {
122
+ super(message, 'CONCURRENCY_ERROR');
117
123
  this.expectedMtimeMs = expectedMtimeMs;
118
124
  this.actualMtimeMs = actualMtimeMs;
125
+ this.expectedIdentity = expectedIdentity;
126
+ this.actualIdentity = actualIdentity;
119
127
  this.name = 'ConcurrencyError';
120
128
  }
121
129
  }
130
+ /**
131
+ * Thrown when the state.json advisory lock stayed held for the whole bounded
132
+ * wait (#1951). The write was not made. A {@link ConcurrencyError} so callers
133
+ * that reload and retry on a writer collision do the same here.
134
+ */
135
+ export class StateLockTimeoutError extends ConcurrencyError {
136
+ constructor(lockPath, waitedMs) {
137
+ super(0, 0, `State file is locked by another process (waited ${waitedMs} ms). Nothing was written; re-run the command. ` +
138
+ 'A lock left by a crashed process expires after 30 seconds, or after 10 minutes when its PID now belongs ' +
139
+ `to a live process. To clear it by hand, make sure no oss-autopilot process is running and delete ${lockPath}.`);
140
+ this.name = 'StateLockTimeoutError';
141
+ }
142
+ }
143
+ /**
144
+ * Thrown when stored state (the state file, the Gist, or its local cache)
145
+ * carries a schema version above this release's (#1951). It is not corruption:
146
+ * it is never restored over, replaced by fresh state, or moved aside. A
147
+ * {@link ConfigurationError} because it stays until the user updates.
148
+ */
149
+ export class NewerStateVersionError extends ConfigurationError {
150
+ constructor(source, version, supported) {
151
+ super(`The ${source} was written by a newer oss-autopilot release (schema version ${version}; this release ` +
152
+ `reads up to ${supported}). Nothing was changed. Update this client and retry: run ` +
153
+ '`claude plugin update oss-autopilot@oss-autopilot` and restart Claude Code, or install the latest ' +
154
+ '@oss-autopilot packages.');
155
+ this.name = 'NewerStateVersionError';
156
+ }
157
+ }
122
158
  /**
123
159
  * Thrown when a Gist push collides with a concurrent write from another
124
160
  * machine and the in-flight merge attempt also lost the race (#1115).
@@ -157,6 +193,19 @@ export class GistFileSizeError extends ConfigurationError {
157
193
  this.name = 'GistFileSizeError';
158
194
  }
159
195
  }
196
+ /**
197
+ * The search for the existing state Gist could not settle whether one exists:
198
+ * the Gist list is longer than the search window, or the only Gist carrying
199
+ * the state description is public. A {@link ConfigurationError} because
200
+ * retrying cannot fix it and creating a new Gist would fork state across
201
+ * machines (#1926); the message says which Gist ID to write to the gist-id file.
202
+ */
203
+ export class GistDiscoveryError extends ConfigurationError {
204
+ constructor(message) {
205
+ super(message);
206
+ this.name = 'GistDiscoveryError';
207
+ }
208
+ }
160
209
  /**
161
210
  * Extract a human-readable message from an unknown error value.
162
211
  */
@@ -20,8 +20,11 @@
20
20
  * - `bootstrap-degraded`: the manager IS gist-backed, but the bootstrap fell
21
21
  * back to the local cache and the store is disarmed (#1443) — reads may be
22
22
  * stale and pushes fail.
23
+ * - `unknown-mode`: config names a persistence mode a newer release added
24
+ * (#2005). This release runs it local-only, so writes do not sync until the
25
+ * user upgrades. Rendered by {@link renderUnknownModeWarning}.
23
26
  */
24
- export type GistHealthDegradedCause = 'configured-but-local' | 'bootstrap-degraded';
27
+ export type GistHealthDegradedCause = 'configured-but-local' | 'bootstrap-degraded' | 'unknown-mode';
25
28
  /**
26
29
  * Causes {@link renderGistWarning} can name. Superset of
27
30
  * {@link GistHealthDegradedCause}: the process-level bootstrap outcomes are
@@ -35,7 +38,7 @@ export type GistHealthDegradedCause = 'configured-but-local' | 'bootstrap-degrad
35
38
  * reported `'degraded'` (transient network fallback, or a #1443 degraded
36
39
  * bootstrap, which it deliberately conflates at that layer).
37
40
  */
38
- export type GistWarningCause = GistHealthDegradedCause | 'no-token' | 'state-unreadable' | 'init-fallback';
41
+ export type GistWarningCause = Exclude<GistHealthDegradedCause, 'unknown-mode'> | 'no-token' | 'state-unreadable' | 'init-fallback';
39
42
  /**
40
43
  * Snapshot of gist persistence health from the one source of truth
41
44
  * (`StateManager.getGistHealth()`), shaped per #1444.
@@ -48,7 +51,11 @@ export interface GistHealth {
48
51
  * gist-backed with an armed store. Non-null when this process is not
49
52
  * reliably syncing to the Gist. */
50
53
  degraded: null | {
51
- cause: GistHealthDegradedCause;
54
+ cause: 'unknown-mode'; /** The mode as stored. */
55
+ mode: string;
56
+ recoverable: false;
57
+ } | {
58
+ cause: Exclude<GistHealthDegradedCause, 'unknown-mode'>;
52
59
  /** ISO timestamp when the degradation was first observed, when known
53
60
  * (a degraded bootstrap seeds the staleness marker; a
54
61
  * configured-but-local manager has no marker to date it by). */
@@ -79,3 +86,8 @@ export declare function renderGistWarning(cause: GistWarningCause | {
79
86
  }, opts?: {
80
87
  retryHint?: string;
81
88
  }): string;
89
+ /**
90
+ * The warning for a persistence mode a newer release wrote (#2005). This
91
+ * release cannot sync through that mode, so it runs local-only.
92
+ */
93
+ export declare function renderUnknownModeWarning(mode: string): string;
@@ -37,3 +37,11 @@ export function renderGistWarning(cause, opts = {}) {
37
37
  return (`Gist persistence is configured but ${reason}; writes are LOCAL-ONLY and may be ` +
38
38
  `overwritten by the next successful Gist sync.${opts.retryHint ? ` ${opts.retryHint}` : ''}`);
39
39
  }
40
+ /**
41
+ * The warning for a persistence mode a newer release wrote (#2005). This
42
+ * release cannot sync through that mode, so it runs local-only.
43
+ */
44
+ export function renderUnknownModeWarning(mode) {
45
+ return (`Persistence mode '${mode}' is from a newer release; this client runs LOCAL-ONLY and writes will not sync. ` +
46
+ 'Upgrade oss-autopilot.');
47
+ }
@@ -8,9 +8,15 @@
8
8
  * Bootstrap flow:
9
9
  * 1. Check for locally stored Gist ID file (`~/.oss-autopilot/gist-id`)
10
10
  * 2. If found, fetch that Gist directly via `GET /gists/:id`
11
- * 3. If not found locally, search the user's Gists for description `oss-autopilot-state`
11
+ * 3. If there is no local ID, or that Gist is gone (404), search the user's
12
+ * Gists for a private one with description `oss-autopilot-state`
12
13
  * 4. If found via search, store the ID locally and fetch it
13
- * 5. If not found anywhere, create a new private Gist with seed files and store the ID
14
+ * 5. Only when the search ran to the end of the list (a page with no
15
+ * `rel="next"` link) and found nothing, create a new private Gist with seed
16
+ * files and store the ID. A failed search degrades to the local cache; an
17
+ * unfinished or ambiguous one (list longer than the search window, or only
18
+ * a public match) throws
19
+ * {@link GistDiscoveryError}. Neither creates a Gist (#1926).
14
20
  * 6. Cache all Gist file contents in memory for session-scoped reads
15
21
  * 7. Write state to a local cache file for fallback
16
22
  *
@@ -96,6 +102,7 @@ export interface OctokitLike {
96
102
  page: number;
97
103
  }) => Promise<{
98
104
  data: GistListItem[];
105
+ headers?: Record<string, string | undefined>;
99
106
  }>;
100
107
  create: (params: {
101
108
  description: string;
@@ -133,6 +140,8 @@ export interface OctokitLike {
133
140
  interface GistListItem {
134
141
  id: string;
135
142
  description: string | null;
143
+ public: boolean;
144
+ created_at: string;
136
145
  }
137
146
  /** Shape of a full Gist response (subset). */
138
147
  interface GistResponseData {
@@ -321,10 +330,21 @@ export declare class GistStateStore {
321
330
  */
322
331
  private parseStateFromCache;
323
332
  /**
324
- * Search the authenticated user's Gists for one with the well-known description.
325
- * Pages through up to 10 pages (100 Gists per page) to find it.
333
+ * Search the authenticated user's Gists for the private one with the
334
+ * well-known description. Pages through up to 10 pages (100 Gists per page).
335
+ * The list has ended when a response carries no `rel="next"` Link header;
336
+ * page length is not used, since a short page need not be the last.
337
+ *
338
+ * Returns `null` only when the search ran to the end of the list and found
339
+ * no Gist with the description. The callers create a new Gist on `null`, so
340
+ * anything short of that must not read as "no Gist exists" or this machine
341
+ * forks onto an empty one (#1926): API errors propagate, and a list longer
342
+ * than the search window or a public-only match throws
343
+ * {@link GistDiscoveryError}.
326
344
  */
327
345
  private searchForGist;
346
+ /** Pick the oldest of the private state Gists found on a page, warning when there are several. */
347
+ private pickStateGist;
328
348
  /**
329
349
  * Create a new private Gist with seed files and store it in memory.
330
350
  */