@oss-autopilot/core 3.42.5 → 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 (168) 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/ci-analysis.d.ts +7 -2
  85. package/dist/core/ci-analysis.js +76 -21
  86. package/dist/core/commit-date.d.ts +19 -0
  87. package/dist/core/commit-date.js +17 -0
  88. package/dist/core/config-registry.js +11 -5
  89. package/dist/core/contributing.d.ts +2 -3
  90. package/dist/core/contributing.js +2 -3
  91. package/dist/core/daily-logic.d.ts +27 -5
  92. package/dist/core/daily-logic.js +57 -19
  93. package/dist/core/errors.d.ts +37 -3
  94. package/dist/core/errors.js +54 -5
  95. package/dist/core/gist-health.d.ts +15 -3
  96. package/dist/core/gist-health.js +8 -0
  97. package/dist/core/gist-state-store.d.ts +24 -4
  98. package/dist/core/gist-state-store.js +97 -46
  99. package/dist/core/github-stats.d.ts +104 -16
  100. package/dist/core/github-stats.js +282 -97
  101. package/dist/core/http-cache.d.ts +0 -10
  102. package/dist/core/http-cache.js +0 -19
  103. package/dist/core/index.d.ts +12 -5
  104. package/dist/core/index.js +15 -5
  105. package/dist/core/issue-conversation.d.ts +8 -2
  106. package/dist/core/issue-conversation.js +31 -12
  107. package/dist/core/local-config.d.ts +95 -0
  108. package/dist/core/local-config.js +271 -0
  109. package/dist/core/merged-pr-notes.d.ts +2 -2
  110. package/dist/core/pagination.d.ts +55 -0
  111. package/dist/core/pagination.js +59 -0
  112. package/dist/core/paths.d.ts +7 -0
  113. package/dist/core/paths.js +9 -0
  114. package/dist/core/pr-assembly.js +6 -2
  115. package/dist/core/pr-graphql.d.ts +37 -3
  116. package/dist/core/pr-graphql.js +73 -12
  117. package/dist/core/pr-monitor.d.ts +29 -12
  118. package/dist/core/pr-monitor.js +71 -23
  119. package/dist/core/pr-preflight.d.ts +113 -0
  120. package/dist/core/pr-preflight.js +364 -0
  121. package/dist/core/pr-quality-rubric.d.ts +0 -6
  122. package/dist/core/pr-quality-rubric.js +0 -8
  123. package/dist/core/pr-template.d.ts +2 -0
  124. package/dist/core/pr-template.js +5 -1
  125. package/dist/core/repo-policy.d.ts +105 -0
  126. package/dist/core/repo-policy.js +400 -0
  127. package/dist/core/repo-score-manager.d.ts +48 -0
  128. package/dist/core/repo-score-manager.js +111 -1
  129. package/dist/core/review-analysis.d.ts +34 -19
  130. package/dist/core/review-analysis.js +67 -10
  131. package/dist/core/reviewed-prs-fetch.js +11 -29
  132. package/dist/core/reviewed-prs.js +8 -15
  133. package/dist/core/stale-data.d.ts +41 -0
  134. package/dist/core/stale-data.js +115 -0
  135. package/dist/core/state-persistence.d.ts +62 -27
  136. package/dist/core/state-persistence.js +338 -117
  137. package/dist/core/state-schema.d.ts +113 -210
  138. package/dist/core/state-schema.js +165 -80
  139. package/dist/core/state.d.ts +60 -8
  140. package/dist/core/state.js +192 -46
  141. package/dist/core/status-determination.js +26 -8
  142. package/dist/core/strategy.js +3 -1
  143. package/dist/core/types.d.ts +22 -1
  144. package/dist/core/types.js +1 -0
  145. package/dist/core/untrusted-content.d.ts +30 -11
  146. package/dist/core/untrusted-content.js +77 -42
  147. package/dist/core/urls.d.ts +9 -0
  148. package/dist/core/urls.js +18 -0
  149. package/dist/dashboard/assets/{chart-panel-DPKNBUts.js → chart-panel-C_C1lFTI.js} +1 -1
  150. package/dist/dashboard/assets/{index-B25bZOYX.js → index-B--H66Jk.js} +1 -1
  151. package/dist/dashboard/index.html +1 -1
  152. package/dist/formatters/json.d.ts +262 -6
  153. package/dist/formatters/json.js +77 -1
  154. package/package.json +1 -1
  155. package/dist/core/ci-enforced-tools.d.ts +0 -35
  156. package/dist/core/ci-enforced-tools.js +0 -109
  157. package/dist/core/comment-decision.d.ts +0 -79
  158. package/dist/core/comment-decision.js +0 -82
  159. package/dist/core/extraction-categories.d.ts +0 -55
  160. package/dist/core/extraction-categories.js +0 -108
  161. package/dist/core/follow-up-history.d.ts +0 -40
  162. package/dist/core/follow-up-history.js +0 -71
  163. package/dist/core/issue-effort.d.ts +0 -29
  164. package/dist/core/issue-effort.js +0 -47
  165. package/dist/core/maintainer-hints.d.ts +0 -23
  166. package/dist/core/maintainer-hints.js +0 -36
  167. package/dist/core/workflow-state.d.ts +0 -56
  168. package/dist/core/workflow-state.js +0 -101
@@ -35,6 +35,8 @@ export { runFeatures, MAX_FEATURES_RESULTS } from './features.js';
35
35
  export { runVet } from './vet.js';
36
36
  /** Deterministic availability check: state/stateReason + linked-PR classification (#1353, #1354). */
37
37
  export { runVerifyIssue, type VerifyIssueOptions } from './verify-issue.js';
38
+ /** Read one issue's title, body and comments, each fenced as untrusted content (#1932). */
39
+ export { runIssueThread, type IssueThreadOptions } from './issue-thread.js';
38
40
  /** Re-vet all available issues in a curated issue list for freshness. */
39
41
  export { runVetList } from './vet-list.js';
40
42
  export { runEval, type EvalOutput } from './eval.js';
@@ -57,7 +59,7 @@ export { runComments } from './comments.js';
57
59
  /** Post a comment to a GitHub issue or PR. */
58
60
  export { runPost } from './comments.js';
59
61
  /** Post a claim comment on a GitHub issue. */
60
- export { runClaim } from './comments.js';
62
+ export { runClaim, DEFAULT_CLAIM_MESSAGE } from './comments.js';
61
63
  /** Read or write user configuration (githubUsername, languages, labels, etc). */
62
64
  export { runConfig } from './config.js';
63
65
  /** Initialize with a GitHub username and import open PRs. */
@@ -74,6 +76,8 @@ export { runGuidelinesView } from './guidelines.js';
74
76
  export { runGuidelinesStore } from './guidelines.js';
75
77
  /** Tombstone a guidelines file so subsequent reads return null. */
76
78
  export { runGuidelinesReset } from './guidelines.js';
79
+ /** Read a repo's contribution policy (#1953). `policy set` / `reset` are CLI-only. */
80
+ export { runPolicyGet } from './policy.js';
77
81
  /** Fetch raw PR comment bundles for the host's extract-learnings prompt. */
78
82
  export { runFetchCorpus } from './guidelines.js';
79
83
  /** Show current persistence mode, Gist ID, and sync status. */
@@ -90,11 +94,19 @@ export { runListMoveTier, moveIssueToTier, type Tier, type ListMoveTierOptions,
90
94
  export { runMarkIssueListItemDone, markIssueAsDone, type MarkDoneOptions, type MarkDoneOutput, } from './list-mark-done.js';
91
95
  /** Daily merge-loop reconciliation — auto-mark curated-list entries whose PR merged (#1463). */
92
96
  export { reconcileMergedPRsWithList, findListEntryUrlByPrUrl } from './merge-loop.js';
93
- /** Check if new files are properly referenced/integrated. */
97
+ /**
98
+ * Check if new files are properly referenced/integrated.
99
+ *
100
+ * @deprecated Since #1948; will be removed in the next major version.
101
+ */
94
102
  export { runCheckIntegration } from './check-integration.js';
95
103
  /** System-health diagnostic — verifies tokens, bundle, state, scout, rate limit. */
96
104
  export { runDoctor, type DoctorCheck, type DoctorCheckStatus, type DoctorOutput } from './doctor.js';
97
- /** Detect formatters/linters configured in a local repository (#703). */
105
+ /**
106
+ * Detect formatters/linters configured in a local repository (#703).
107
+ *
108
+ * @deprecated Since #1948; will be removed in the next major version.
109
+ */
98
110
  export { runDetectFormatters } from './detect-formatters.js';
99
111
  /** Scan for locally cloned repos. */
100
112
  export { runLocalRepos } from './local-repos.js';
@@ -102,9 +114,17 @@ export type { DashboardJsonData, DashboardStats, DashboardActionType, ActionRequ
102
114
  export type { ErrorCode } from '../formatters/json.js';
103
115
  export type { DailyOutput, SearchOutput, SearchCandidate, CandidateLinkedPR, FeaturesOutput, FeaturesCandidate, FeaturesHorizon, StartupOutput, StatusOutput, TrackOutput, } from '../formatters/json.js';
104
116
  export type { VetOutput, CommentsOutput, PostOutput, ClaimOutput, VetListOutput, VetListItemStatus, } from '../formatters/json.js';
105
- export type { ConfigOutput, DetectFormattersOutput, ParseIssueListOutput, ParsedIssueItem, CheckIntegrationOutput, LocalReposOutput, } from '../formatters/json.js';
117
+ export type { ConfigOutput, ParseIssueListOutput, ParsedIssueItem, LocalReposOutput } from '../formatters/json.js';
118
+ /**
119
+ * Output types of the deprecated detect-formatters and orphan-files commands.
120
+ *
121
+ * @deprecated Since #1948; will be removed in the next major version.
122
+ */
123
+ export type { DetectFormattersOutput, CheckIntegrationOutput } from '../formatters/json.js';
106
124
  export type { MoveOutput, MoveTarget } from './move.js';
107
125
  export type { GuidelinesListOutput, GuidelinesViewOutput, GuidelinesStoreOutput, GuidelinesResetOutput, FetchCorpusOutput, } from './guidelines.js';
126
+ export type { PolicyGetOutput } from './policy.js';
127
+ export type { RepoPolicySummary } from '../core/repo-policy.js';
108
128
  export type { DismissOutput, UndismissOutput } from './dismiss.js';
109
129
  export type { WorkClaimOptions, WorkClaimOutcome, WorkClaimOutput, WorkFinishOptions, WorkFinishOutput, WorkReleaseOptions, WorkReleaseOutput, WorkListOutput, } from './work.js';
110
130
  export type { InitOutput } from './init.js';
@@ -36,6 +36,8 @@ export { runFeatures, MAX_FEATURES_RESULTS } from './features.js';
36
36
  export { runVet } from './vet.js';
37
37
  /** Deterministic availability check: state/stateReason + linked-PR classification (#1353, #1354). */
38
38
  export { runVerifyIssue } from './verify-issue.js';
39
+ /** Read one issue's title, body and comments, each fenced as untrusted content (#1932). */
40
+ export { runIssueThread } from './issue-thread.js';
39
41
  /** Re-vet all available issues in a curated issue list for freshness. */
40
42
  export { runVetList } from './vet-list.js';
41
43
  export { runEval } from './eval.js';
@@ -60,7 +62,7 @@ export { runComments } from './comments.js';
60
62
  /** Post a comment to a GitHub issue or PR. */
61
63
  export { runPost } from './comments.js';
62
64
  /** Post a claim comment on a GitHub issue. */
63
- export { runClaim } from './comments.js';
65
+ export { runClaim, DEFAULT_CLAIM_MESSAGE } from './comments.js';
64
66
  // ── Configuration & Setup ───────────────────────────────────────────────────
65
67
  /** Read or write user configuration (githubUsername, languages, labels, etc). */
66
68
  export { runConfig } from './config.js';
@@ -79,6 +81,8 @@ export { runGuidelinesView } from './guidelines.js';
79
81
  export { runGuidelinesStore } from './guidelines.js';
80
82
  /** Tombstone a guidelines file so subsequent reads return null. */
81
83
  export { runGuidelinesReset } from './guidelines.js';
84
+ /** Read a repo's contribution policy (#1953). `policy set` / `reset` are CLI-only. */
85
+ export { runPolicyGet } from './policy.js';
82
86
  /** Fetch raw PR comment bundles for the host's extract-learnings prompt. */
83
87
  export { runFetchCorpus } from './guidelines.js';
84
88
  // ── State Persistence ────────────────────────────────────────────────────────
@@ -97,11 +101,19 @@ export { runListMoveTier, moveIssueToTier, } from './list-move-tier.js';
97
101
  export { runMarkIssueListItemDone, markIssueAsDone, } from './list-mark-done.js';
98
102
  /** Daily merge-loop reconciliation — auto-mark curated-list entries whose PR merged (#1463). */
99
103
  export { reconcileMergedPRsWithList, findListEntryUrlByPrUrl } from './merge-loop.js';
100
- /** Check if new files are properly referenced/integrated. */
104
+ /**
105
+ * Check if new files are properly referenced/integrated.
106
+ *
107
+ * @deprecated Since #1948; will be removed in the next major version.
108
+ */
101
109
  export { runCheckIntegration } from './check-integration.js';
102
110
  /** System-health diagnostic — verifies tokens, bundle, state, scout, rate limit. */
103
111
  export { runDoctor } from './doctor.js';
104
- /** Detect formatters/linters configured in a local repository (#703). */
112
+ /**
113
+ * Detect formatters/linters configured in a local repository (#703).
114
+ *
115
+ * @deprecated Since #1948; will be removed in the next major version.
116
+ */
105
117
  export { runDetectFormatters } from './detect-formatters.js';
106
118
  /** Scan for locally cloned repos. */
107
119
  export { runLocalRepos } from './local-repos.js';
@@ -0,0 +1,46 @@
1
+ /**
2
+ * issue-thread command (#1932).
3
+ *
4
+ * The fenced way to read an issue: title, body and every comment reach the
5
+ * agent wrapped in `<github-content>` with author and author association
6
+ * (body and comments fenced here; the title by the CLI action or, on MCP, by
7
+ * the server's `fenceTitlesDeep`). Raw
8
+ * `gh issue view` output passes through no code in this repo, so an agent
9
+ * told to read a thread with it reads stranger-written text unfenced. The
10
+ * unattended implement mode (agents/overnight-preparer.md) reads threads
11
+ * through this command instead.
12
+ */
13
+ import type { IssueThreadOutput } from '../formatters/json.js';
14
+ export interface IssueThreadOptions {
15
+ issueUrl: string;
16
+ }
17
+ /**
18
+ * Per-body character cap, applied before fencing. GitHub allows 65,536
19
+ * characters per body; a thread is read whole by an agent, so one pasted log
20
+ * must not crowd out the rest.
21
+ * ponytail: per-body cap only. Thread length is bounded by the shared
22
+ * pagination cap (1000 comments); add a whole-thread budget if that proves
23
+ * too much for a reader.
24
+ */
25
+ export declare const MAX_ISSUE_THREAD_BODY_CHARS = 20000;
26
+ /**
27
+ * Fence the title of a thread returned by {@link runIssueThread}. The CLI
28
+ * applies this to everything it prints, with or without `--json`.
29
+ */
30
+ export declare function fenceIssueThreadTitle(thread: IssueThreadOutput): IssueThreadOutput;
31
+ /**
32
+ * Fetch one issue's title, body and comments. The body and every comment
33
+ * come back fenced as untrusted content.
34
+ *
35
+ * The `title` comes back RAW, like every other producer's title: the MCP
36
+ * server fences `title` in every tool result (`fenceTitlesDeep`, #1931), so
37
+ * fencing it here too would put a fence inside a fence there. The CLI fences
38
+ * it with {@link fenceIssueThreadTitle}. Any other caller that hands this
39
+ * result to an agent must do the same.
40
+ *
41
+ * Nothing is filtered: bot comments and the user's own comments are part of
42
+ * the discussion an implementer needs. Comments come oldest first.
43
+ *
44
+ * @throws {ValidationError} If the URL is not a valid GitHub issue URL.
45
+ */
46
+ export declare function runIssueThread(options: IssueThreadOptions): Promise<IssueThreadOutput>;
@@ -0,0 +1,123 @@
1
+ /**
2
+ * issue-thread command (#1932).
3
+ *
4
+ * The fenced way to read an issue: title, body and every comment reach the
5
+ * agent wrapped in `<github-content>` with author and author association
6
+ * (body and comments fenced here; the title by the CLI action or, on MCP, by
7
+ * the server's `fenceTitlesDeep`). Raw
8
+ * `gh issue view` output passes through no code in this repo, so an agent
9
+ * told to read a thread with it reads stranger-written text unfenced. The
10
+ * unattended implement mode (agents/overnight-preparer.md) reads threads
11
+ * through this command instead.
12
+ */
13
+ import { getOctokit, parseGitHubUrl, requireGitHubToken } from '../core/index.js';
14
+ import { ValidationError } from '../core/errors.js';
15
+ import { paginateAllDetailed } from '../core/pagination.js';
16
+ import { wrapUntrustedContent } from '../core/untrusted-content.js';
17
+ import { ISSUE_URL_PATTERN, validateGitHubUrl, validateUrl } from './validation.js';
18
+ /**
19
+ * Per-body character cap, applied before fencing. GitHub allows 65,536
20
+ * characters per body; a thread is read whole by an agent, so one pasted log
21
+ * must not crowd out the rest.
22
+ * ponytail: per-body cap only. Thread length is bounded by the shared
23
+ * pagination cap (1000 comments); add a whole-thread budget if that proves
24
+ * too much for a reader.
25
+ */
26
+ export const MAX_ISSUE_THREAD_BODY_CHARS = 20_000;
27
+ /** Cut an over-long body, saying how much was dropped. */
28
+ function capBody(body) {
29
+ if (body.length <= MAX_ISSUE_THREAD_BODY_CHARS)
30
+ return body;
31
+ const dropped = body.length - MAX_ISSUE_THREAD_BODY_CHARS;
32
+ return `${body.slice(0, MAX_ISSUE_THREAD_BODY_CHARS)}\n[truncated: ${dropped} more characters]`;
33
+ }
34
+ /**
35
+ * Fence the title of a thread returned by {@link runIssueThread}. The CLI
36
+ * applies this to everything it prints, with or without `--json`.
37
+ */
38
+ export function fenceIssueThreadTitle(thread) {
39
+ const label = `${thread.owner}/${thread.repo}#${thread.number}`;
40
+ return {
41
+ ...thread,
42
+ title: wrapUntrustedContent(thread.title, label, {
43
+ author: thread.author ?? undefined,
44
+ association: thread.authorAssociation ?? undefined,
45
+ source: 'issue-title',
46
+ }),
47
+ };
48
+ }
49
+ /**
50
+ * Fetch one issue's title, body and comments. The body and every comment
51
+ * come back fenced as untrusted content.
52
+ *
53
+ * The `title` comes back RAW, like every other producer's title: the MCP
54
+ * server fences `title` in every tool result (`fenceTitlesDeep`, #1931), so
55
+ * fencing it here too would put a fence inside a fence there. The CLI fences
56
+ * it with {@link fenceIssueThreadTitle}. Any other caller that hands this
57
+ * result to an agent must do the same.
58
+ *
59
+ * Nothing is filtered: bot comments and the user's own comments are part of
60
+ * the discussion an implementer needs. Comments come oldest first.
61
+ *
62
+ * @throws {ValidationError} If the URL is not a valid GitHub issue URL.
63
+ */
64
+ export async function runIssueThread(options) {
65
+ validateUrl(options.issueUrl);
66
+ validateGitHubUrl(options.issueUrl, ISSUE_URL_PATTERN, 'issue');
67
+ const parsed = parseGitHubUrl(options.issueUrl);
68
+ if (!parsed || parsed.type !== 'issues') {
69
+ throw new ValidationError(`Not a parseable GitHub issue URL: ${options.issueUrl}`);
70
+ }
71
+ const { owner, repo, number: issueNumber } = parsed;
72
+ const octokit = getOctokit(requireGitHubToken());
73
+ const [{ data: issue }, commentsResult] = await Promise.all([
74
+ octokit.issues.get({ owner, repo, issue_number: issueNumber }),
75
+ paginateAllDetailed((page) => octokit.issues.listComments({ owner, repo, page, issue_number: issueNumber, per_page: 100 })),
76
+ ]);
77
+ const label = `${owner}/${repo}#${issueNumber}`;
78
+ const rawBodies = [issue.body ?? '', ...commentsResult.items.map((c) => c.body ?? '')];
79
+ const cappedCount = rawBodies.filter((b) => b.length > MAX_ISSUE_THREAD_BODY_CHARS).length;
80
+ const warnings = [];
81
+ if (commentsResult.truncated) {
82
+ warnings.push({
83
+ phase: 'fetch',
84
+ operation: 'fetch issue comments (truncated)',
85
+ message: `Pagination cap reached fetching comments for ${label}; the newest comments may be missing.`,
86
+ });
87
+ }
88
+ if (cappedCount > 0) {
89
+ warnings.push({
90
+ phase: 'fetch',
91
+ operation: 'cap issue thread bodies',
92
+ message: `${cappedCount} body or comment(s) on ${label} exceeded ${MAX_ISSUE_THREAD_BODY_CHARS} characters and were cut.`,
93
+ });
94
+ }
95
+ const issueAuthor = issue.user?.login;
96
+ return {
97
+ url: issue.html_url,
98
+ owner,
99
+ repo,
100
+ number: issueNumber,
101
+ state: issue.state,
102
+ title: issue.title,
103
+ author: issueAuthor ?? null,
104
+ authorAssociation: issue.author_association ?? null,
105
+ createdAt: issue.created_at,
106
+ body: wrapUntrustedContent(capBody(issue.body ?? ''), label, {
107
+ author: issueAuthor,
108
+ association: issue.author_association,
109
+ source: 'issue-body',
110
+ }),
111
+ comments: commentsResult.items.map((c) => ({
112
+ author: c.user?.login ?? null,
113
+ authorAssociation: c.author_association ?? null,
114
+ createdAt: c.created_at,
115
+ body: wrapUntrustedContent(capBody(c.body ?? ''), label, {
116
+ author: c.user?.login,
117
+ association: c.author_association,
118
+ source: 'issue-comment',
119
+ }),
120
+ })),
121
+ ...(warnings.length > 0 && { warnings }),
122
+ };
123
+ }
@@ -20,10 +20,19 @@
20
20
  * and its sibling archives: an entry whose status line links the PR carries
21
21
  * the vet score as `**Tier (N/10)**`.
22
22
  *
23
+ * Before any of that it adds the merged (#1924) and closed (#1925) PRs the
24
+ * ledgers are missing: the daily run and the dashboard only fetch forward from
25
+ * each ledger's newest entry, so a hole behind it stays until this command
26
+ * walks the full history.
27
+ *
23
28
  * Only missing fields are filled (addMergedPRs/addClosedPRs never overwrite),
24
29
  * so the command is safe to re-run; the weekly eval job runs it first.
25
30
  */
26
31
  export interface LedgerBackfillOutput {
32
+ /** Merged PRs GitHub lists that the ledger did not hold, added in this run (#1924). */
33
+ mergedAdded: number;
34
+ /** Closed-without-merge PRs GitHub lists that the ledger did not hold, added in this run (#1925). */
35
+ closedAdded: number;
27
36
  /** Ledger PRs sent to GitHub because they had not been backfilled yet. */
28
37
  queried: number;
29
38
  /** Entries that gained each field in this run. */
@@ -20,6 +20,11 @@
20
20
  * and its sibling archives: an entry whose status line links the PR carries
21
21
  * the vet score as `**Tier (N/10)**`.
22
22
  *
23
+ * Before any of that it adds the merged (#1924) and closed (#1925) PRs the
24
+ * ledgers are missing: the daily run and the dashboard only fetch forward from
25
+ * each ledger's newest entry, so a hole behind it stays until this command
26
+ * walks the full history.
27
+ *
23
28
  * Only missing fields are filled (addMergedPRs/addClosedPRs never overwrite),
24
29
  * so the command is safe to re-run; the weekly eval job runs it first.
25
30
  */
@@ -27,6 +32,7 @@ import * as fs from 'node:fs';
27
32
  import * as path from 'node:path';
28
33
  import { classifyCloseReason, classifySelfClose } from '../core/close-reason.js';
29
34
  import { errorMessage, isRateLimitOrAuthError } from '../core/errors.js';
35
+ import { fetchClosedPRsSince, fetchMergedPRsSince, } from '../core/github-stats.js';
30
36
  import { getOctokit, requireGitHubToken, getStateManager, parseGitHubUrl } from '../core/index.js';
31
37
  import { isGraphqlRateLimited } from '../core/pr-graphql.js';
32
38
  import { getFirstMaintainerResponseAt, MAINTAINER_RESPONSE_RULE } from '../core/review-analysis.js';
@@ -220,6 +226,28 @@ function countFilled(entries) {
220
226
  pick: entries.filter((e) => e.pick).length,
221
227
  };
222
228
  }
229
+ /**
230
+ * Every merged or closed PR GitHub lists for the user, with no result limit,
231
+ * so holes anywhere in the ledger can be filled (#1924, #1925). Empty with a
232
+ * warning when the walk fails: a partial history is never returned, because
233
+ * storing a recent row without the rows before it would hide them from the
234
+ * daily gap fetch. Rate-limit and auth errors rethrow.
235
+ */
236
+ async function fetchHistory(kind, fetchSince, octokit, config, warnings) {
237
+ let history;
238
+ try {
239
+ history = await fetchSince(octokit, config, undefined, Infinity);
240
+ }
241
+ catch (err) {
242
+ if (isRateLimitOrAuthError(err))
243
+ throw err;
244
+ warnings.push(`${kind} PR history fetch failed, no missing PRs were added: ${errorMessage(err)}`);
245
+ return [];
246
+ }
247
+ if (history.truncated)
248
+ warnings.push(`${kind} PR history could not be walked to the end; no missing PRs were added`);
249
+ return history.prs;
250
+ }
223
251
  export async function runLedgerBackfill(options = {}) {
224
252
  const stateManager = getStateManager();
225
253
  const warnings = [];
@@ -231,6 +259,17 @@ export async function runLedgerBackfill(options = {}) {
231
259
  if (!listPath)
232
260
  warnings.push('no curated issue list found; list vet scores were not imported');
233
261
  const lists = listPath ? readListFiles(listPath, warnings) : [];
262
+ // 0. History: add the merged and closed PRs the ledgers are missing, so the
263
+ // steps below enrich them in the same run.
264
+ const octokit = getOctokit(requireGitHubToken());
265
+ const { config } = stateManager.getState();
266
+ // Merged rows are stored before the closed walk starts, so a rate limit on
267
+ // that walk keeps them; storing them first also keeps a PR that has since
268
+ // merged out of the closed ledger.
269
+ const history = await fetchHistory('merged', fetchMergedPRsSince, octokit, config, warnings);
270
+ const { added: mergedAdded } = stateManager.addMergedPRs(history);
271
+ const closedHistory = await fetchHistory('closed', fetchClosedPRsSince, octokit, config, warnings);
272
+ const { added: closedAdded } = stateManager.addClosedPRs(closedHistory);
234
273
  // 1. GitHub: openedAt, closing issue, close reason, first response, for
235
274
  // entries not yet backfilled, plus one-time re-fetches for fields added
236
275
  // later: selfCloseReason on self-closed entries, and firstMaintainerResponseAt
@@ -245,7 +284,6 @@ export async function runLedgerBackfill(options = {}) {
245
284
  const responses = new Map();
246
285
  let fatal;
247
286
  if (needsFetch.length > 0) {
248
- const octokit = getOctokit(requireGitHubToken());
249
287
  let failedBatches = 0;
250
288
  for (let i = 0; i < needsFetch.length; i += BATCH_SIZE) {
251
289
  try {
@@ -289,6 +327,9 @@ export async function runLedgerBackfill(options = {}) {
289
327
  };
290
328
  };
291
329
  const applyLedger = () => {
330
+ // Again, in case the reload above or a Gist conflict retry dropped them.
331
+ stateManager.addMergedPRs(history);
332
+ stateManager.addClosedPRs(closedHistory);
292
333
  stateManager.addMergedPRs(merged.map((e) => ({ url: e.url, title: e.title, mergedAt: e.mergedAt, ...recovered(e) })));
293
334
  stateManager.addClosedPRs(closed.map((e) => {
294
335
  const node = nodes.get(e.url);
@@ -316,6 +357,8 @@ export async function runLedgerBackfill(options = {}) {
316
357
  if (fatal)
317
358
  throw fatal;
318
359
  return {
360
+ mergedAdded,
361
+ closedAdded,
319
362
  queried: needsFetch.length,
320
363
  filled: {
321
364
  openedAt: after.openedAt - before.openedAt,
@@ -19,7 +19,8 @@ export interface MarkDoneOptions {
19
19
  prUrl: string;
20
20
  /** Free-text trailing status, e.g. "CI passing", "merged". */
21
21
  prStatus: string;
22
- listPath: string;
22
+ /** Defaults to the configured issueListPath. */
23
+ listPath?: string;
23
24
  }
24
25
  export interface MarkDoneOutput {
25
26
  /** True if the line was found and updated. False only when already marked
@@ -18,6 +18,7 @@ import * as fs from 'node:fs';
18
18
  import * as path from 'node:path';
19
19
  import { errorMessage, ValidationError } from '../core/errors.js';
20
20
  import { ENTRY_LINE_RE, ENTRY_MARKER_RE, lineMentionsUrl } from './curated-list.js';
21
+ import { configuredIssueListPath } from './locate-issue-list.js';
21
22
  const STRIKE = '~~';
22
23
  const DONE_PREFIX = ' - **Done**';
23
24
  const REPO_HEADING_RE = /^###\s/;
@@ -159,8 +160,9 @@ export function markIssueAsDone(content, opts) {
159
160
  };
160
161
  }
161
162
  /** Read → transform → write atomically (tmp + rename) so a crash mid-write can't corrupt the file. */
163
+ // eslint-disable-next-line @typescript-eslint/require-await -- async keeps the Promise-returning contract callers rely on; the body has no await yet
162
164
  export async function runMarkIssueListItemDone(options) {
163
- const filePath = path.resolve(options.listPath);
165
+ const filePath = path.resolve(options.listPath ?? configuredIssueListPath());
164
166
  if (!fs.existsSync(filePath)) {
165
167
  throw new Error(`File not found: ${filePath}`);
166
168
  }
@@ -16,7 +16,8 @@ export type Tier = 'pursue' | 'maybe' | 'skip';
16
16
  export interface ListMoveTierOptions {
17
17
  issueUrl: string;
18
18
  tier: Tier;
19
- listPath: string;
19
+ /** Defaults to the configured issueListPath. */
20
+ listPath?: string;
20
21
  }
21
22
  export interface ListMoveTierOutput {
22
23
  /** Whether anything moved (false only when the entry was already in the
@@ -16,6 +16,7 @@ import * as fs from 'node:fs';
16
16
  import * as path from 'node:path';
17
17
  import { errorMessage, ValidationError } from '../core/errors.js';
18
18
  import { ENTRY_LINE_RE, lineMentionsUrl } from './curated-list.js';
19
+ import { configuredIssueListPath } from './locate-issue-list.js';
19
20
  const TIER_HEADERS = {
20
21
  pursue: '## Pursue',
21
22
  maybe: '## Maybe',
@@ -162,8 +163,9 @@ export function moveIssueToTier(content, issueUrl, targetTier) {
162
163
  count: extracted.length,
163
164
  };
164
165
  }
166
+ // eslint-disable-next-line @typescript-eslint/require-await -- async keeps the Promise-returning contract callers rely on; the body has no await yet
165
167
  export async function runListMoveTier(options) {
166
- const filePath = path.resolve(options.listPath);
168
+ const filePath = path.resolve(options.listPath ?? configuredIssueListPath());
167
169
  if (!fs.existsSync(filePath)) {
168
170
  throw new Error(`File not found: ${filePath}`);
169
171
  }
@@ -8,6 +8,7 @@ import * as os from 'node:os';
8
8
  import { execFileSync } from 'node:child_process';
9
9
  import { getStateManager, debug } from '../core/index.js';
10
10
  import { errorMessage } from '../core/errors.js';
11
+ import { getMachineRepoCache, getMachineScanPaths, setMachineRepoCache } from '../core/local-config.js';
11
12
  /** Default directories to scan for local clones */
12
13
  const DEFAULT_SCAN_PATHS = [
13
14
  path.join(os.homedir(), 'Documents', 'oss'),
@@ -122,15 +123,17 @@ export function scanForRepos(scanPaths) {
122
123
  }
123
124
  return repos;
124
125
  }
126
+ // eslint-disable-next-line @typescript-eslint/require-await -- async keeps the Promise-returning contract callers rely on; the body has no await yet
125
127
  export async function runLocalRepos(options) {
126
128
  const stateManager = getStateManager();
127
129
  const state = stateManager.getState();
128
130
  const scanPaths = options.paths?.map((p) => path.resolve(p)) ??
129
- state.config.localRepoScanPaths ??
131
+ getMachineScanPaths(state.config.localRepoScanPaths)?.paths ??
130
132
  DEFAULT_SCAN_PATHS.filter((p) => fs.existsSync(p));
131
133
  // Use cached data unless --scan is specified
132
- if (!options.scan && state.localRepoCache) {
133
- const cache = state.localRepoCache;
134
+ // (this machine's cache: paths from another machine are never returned, #1950)
135
+ const cache = options.scan ? undefined : getMachineRepoCache(state.localRepoCache);
136
+ if (cache) {
134
137
  return {
135
138
  repos: cache.repos,
136
139
  scanPaths: cache.scanPaths,
@@ -139,10 +142,12 @@ export async function runLocalRepos(options) {
139
142
  };
140
143
  }
141
144
  const repos = scanForRepos(scanPaths);
142
- // Cache the results in state
145
+ // Cache the results for this machine, and drop the synced copy an older
146
+ // client left in state: it is a regenerable cache and only bloats the Gist.
143
147
  const cachedAt = new Date().toISOString();
144
148
  try {
145
- stateManager.setLocalRepoCache({ repos, scanPaths, cachedAt });
149
+ setMachineRepoCache({ repos, scanPaths, cachedAt });
150
+ stateManager.clearSyncedLocalRepoCache();
146
151
  }
147
152
  catch (error) {
148
153
  const msg = errorMessage(error);
@@ -3,23 +3,25 @@
3
3
  *
4
4
  * Extracted from `startup.ts` so the daily merge-loop reconciliation can
5
5
  * locate the list without importing `startup.ts` — that would close an
6
- * import cycle (startup → daily → merge-loop → startup). `startup.ts`
7
- * re-exports `parseIssueListPathFromConfig` for back-compat and layers item
8
- * counts / skipped-issues detection on top of `detectIssueListPath`.
6
+ * import cycle (startup → daily → merge-loop → startup). `startup.ts` layers
7
+ * item counts / skipped-issues detection on top of `detectIssueListPath`.
9
8
  */
10
9
  /**
11
- * Parse issueListPath from a config file's YAML frontmatter.
12
- * @param configContent - Raw content of the config.md file
13
- * @returns The path string or undefined if not found
10
+ * The issue list this machine is configured to use, for commands whose
11
+ * `--list-path` is optional. Workflows call those commands without the flag
12
+ * so a stored path is never pasted into shell text. Resolved by
13
+ * {@link detectIssueListPath}: configured lists only, with its checks; never
14
+ * a file found in the current directory.
14
15
  */
15
- export declare function parseIssueListPathFromConfig(configContent: string): string | undefined;
16
+ export declare function configuredIssueListPath(): string;
16
17
  export interface IssueListLocation {
17
18
  path: string;
18
19
  source: 'configured' | 'auto-detected';
19
20
  }
20
21
  /**
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
22
+ * Persist an absolute list/skip path for this machine (the local settings
23
+ * file, never the synced config: #1950), but only when it differs from the
24
+ * value in effect (avoid a write on every run). Upgrading a
23
25
  * relative/auto-detected value to absolute makes the location stick across
24
26
  * working directories, so `/oss` invoked from anywhere keeps finding the list
25
27
  * and skip file instead of silently no-opping the vet/skip/list-maintenance
@@ -28,13 +30,34 @@ export interface IssueListLocation {
28
30
  */
29
31
  export declare function persistConfigPath(key: 'issueListPath' | 'skippedIssuesPath', absolutePath: string): void;
30
32
  /**
31
- * Locate the curated issue-list file: state config first, then the legacy
32
- * config.md frontmatter, then known default paths. Returns undefined when
33
- * no list exists — callers treat that as "user has no curated list".
33
+ * Locate the curated issue-list file this machine is configured to use.
34
+ * Returns undefined when none is configured, or the configured value is
35
+ * relative, missing, or (unless the user set it on this machine) inside
36
+ * someone else's checkout. Callers treat that as "no curated list". A file
37
+ * found in the current directory is never returned here: see
38
+ * {@link suggestIssueListPath} (#1933).
34
39
  *
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.
40
+ * @param isForeign - The foreign-checkout check; the long-running dashboard
41
+ * passes a memoized one so polling does not run Git per request (#2012).
39
42
  */
40
- export declare function detectIssueListPath(): IssueListLocation | undefined;
43
+ export declare function detectIssueListPath(isForeign?: typeof isForeignCheckout): IssueListLocation | undefined;
44
+ /**
45
+ * True when `dir` is inside a Git checkout that has a remote not owned by
46
+ * the configured user (owner path segment, any host, case-insensitive). A
47
+ * fork clone with an `upstream` remote is foreign, and so is a checkout with
48
+ * no remotes or one Git refuses to read. Only Git reporting "not a git
49
+ * repository" means not a checkout (false); a timeout, a spawn failure (no
50
+ * Git) or any other error fails closed as foreign. Reads local Git config
51
+ * only; no network.
52
+ */
53
+ export declare function isForeignCheckout(dir: string): boolean;
54
+ /**
55
+ * A curated list found at a known path under the current directory, offered
56
+ * for the user to confirm (#1933). Nothing is saved: the prompt layer asks,
57
+ * and a yes is stored with `setup --set issueListPath=<path>`. Until then the
58
+ * file is not used as the list. Offered only when no list is configured, the
59
+ * run is attended, the path has no shell metacharacters, and the current
60
+ * directory is not someone else's checkout (a repository can ship an
61
+ * `issues.md`).
62
+ */
63
+ export declare function suggestIssueListPath(): IssueListLocation | undefined;