@oss-autopilot/core 3.42.5 → 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 (192) hide show
  1. package/dist/cli-pre-action.js +8 -3
  2. package/dist/cli-registry.js +428 -27
  3. package/dist/cli.bundle.cjs +212 -156
  4. package/dist/commands/check-integration.js +5 -1
  5. package/dist/commands/cleanup.d.ts +80 -0
  6. package/dist/commands/cleanup.js +334 -0
  7. package/dist/commands/comments.d.ts +14 -1
  8. package/dist/commands/comments.js +17 -5
  9. package/dist/commands/config.d.ts +2 -0
  10. package/dist/commands/config.js +63 -6
  11. package/dist/commands/daily-dismiss-filter.d.ts +7 -0
  12. package/dist/commands/daily-dismiss-filter.js +17 -1
  13. package/dist/commands/daily-ledger.d.ts +150 -0
  14. package/dist/commands/daily-ledger.js +248 -0
  15. package/dist/commands/daily-recent-prs.d.ts +26 -0
  16. package/dist/commands/daily-recent-prs.js +55 -0
  17. package/dist/commands/daily-render.d.ts +2 -1
  18. package/dist/commands/daily-render.js +4 -1
  19. package/dist/commands/daily.d.ts +5 -1
  20. package/dist/commands/daily.js +83 -93
  21. package/dist/commands/dashboard-cache.d.ts +2 -0
  22. package/dist/commands/dashboard-cache.js +33 -8
  23. package/dist/commands/dashboard-data.js +113 -69
  24. package/dist/commands/dashboard-gist-sync.js +3 -1
  25. package/dist/commands/dashboard-lifecycle.d.ts +36 -8
  26. package/dist/commands/dashboard-lifecycle.js +132 -39
  27. package/dist/commands/dashboard-process.d.ts +49 -1
  28. package/dist/commands/dashboard-process.js +111 -12
  29. package/dist/commands/dashboard-server.js +89 -23
  30. package/dist/commands/detect-formatters.js +1 -0
  31. package/dist/commands/dismiss.js +11 -7
  32. package/dist/commands/doctor.d.ts +15 -1
  33. package/dist/commands/doctor.js +66 -5
  34. package/dist/commands/draft.d.ts +77 -0
  35. package/dist/commands/draft.js +218 -0
  36. package/dist/commands/eval.js +1 -0
  37. package/dist/commands/fork-prune.d.ts +58 -0
  38. package/dist/commands/fork-prune.js +247 -0
  39. package/dist/commands/guidelines.d.ts +69 -2
  40. package/dist/commands/guidelines.js +158 -14
  41. package/dist/commands/index.d.ts +29 -4
  42. package/dist/commands/index.js +20 -3
  43. package/dist/commands/issue-thread.d.ts +46 -0
  44. package/dist/commands/issue-thread.js +123 -0
  45. package/dist/commands/ledger-backfill.d.ts +9 -0
  46. package/dist/commands/ledger-backfill.js +44 -1
  47. package/dist/commands/list-mark-done.d.ts +2 -1
  48. package/dist/commands/list-mark-done.js +3 -1
  49. package/dist/commands/list-move-tier.d.ts +2 -1
  50. package/dist/commands/list-move-tier.js +3 -1
  51. package/dist/commands/local-repos.js +10 -5
  52. package/dist/commands/locate-issue-list.d.ts +40 -17
  53. package/dist/commands/locate-issue-list.js +148 -88
  54. package/dist/commands/move.js +7 -1
  55. package/dist/commands/overnight-handoff.d.ts +17 -7
  56. package/dist/commands/overnight-handoff.js +36 -14
  57. package/dist/commands/overnight-push-prep.d.ts +14 -8
  58. package/dist/commands/overnight-push-prep.js +107 -35
  59. package/dist/commands/overnight-tool-rules.d.ts +54 -0
  60. package/dist/commands/overnight-tool-rules.js +217 -0
  61. package/dist/commands/overnight.d.ts +5 -6
  62. package/dist/commands/overnight.js +61 -140
  63. package/dist/commands/parse-list.js +7 -1
  64. package/dist/commands/policy.d.ts +90 -0
  65. package/dist/commands/policy.js +276 -0
  66. package/dist/commands/pr-create.d.ts +48 -0
  67. package/dist/commands/pr-create.js +200 -0
  68. package/dist/commands/pr-preflight.d.ts +69 -0
  69. package/dist/commands/pr-preflight.js +348 -0
  70. package/dist/commands/repo-vet.d.ts +9 -0
  71. package/dist/commands/repo-vet.js +36 -11
  72. package/dist/commands/scout-bridge.js +18 -8
  73. package/dist/commands/search.js +7 -0
  74. package/dist/commands/setup.d.ts +3 -3
  75. package/dist/commands/setup.js +160 -48
  76. package/dist/commands/skip-add.js +10 -1
  77. package/dist/commands/startup.d.ts +12 -3
  78. package/dist/commands/startup.js +82 -49
  79. package/dist/commands/state-cmd.d.ts +2 -0
  80. package/dist/commands/state-cmd.js +5 -1
  81. package/dist/commands/stats.js +1 -0
  82. package/dist/commands/status.js +6 -0
  83. package/dist/commands/strategy.js +1 -0
  84. package/dist/commands/validation.d.ts +5 -0
  85. package/dist/commands/validation.js +5 -0
  86. package/dist/commands/vet-list.d.ts +6 -0
  87. package/dist/commands/vet-list.js +26 -1
  88. package/dist/commands/vet.d.ts +20 -0
  89. package/dist/commands/vet.js +133 -2
  90. package/dist/commands/work.d.ts +4 -0
  91. package/dist/commands/work.js +34 -11
  92. package/dist/core/__fixtures__/prompt-injection-payloads.js +31 -0
  93. package/dist/core/anti-llm-policy.d.ts +3 -0
  94. package/dist/core/anti-llm-policy.js +3 -0
  95. package/dist/core/auth.js +2 -0
  96. package/dist/core/ci-analysis.d.ts +7 -2
  97. package/dist/core/ci-analysis.js +76 -21
  98. package/dist/core/commit-date.d.ts +45 -0
  99. package/dist/core/commit-date.js +45 -0
  100. package/dist/core/compliance-score.d.ts +3 -0
  101. package/dist/core/compliance-score.js +13 -9
  102. package/dist/core/config-registry.d.ts +27 -2
  103. package/dist/core/config-registry.js +94 -7
  104. package/dist/core/contributing.d.ts +2 -3
  105. package/dist/core/contributing.js +2 -3
  106. package/dist/core/daily-logic.d.ts +30 -5
  107. package/dist/core/daily-logic.js +68 -19
  108. package/dist/core/errors.d.ts +37 -3
  109. package/dist/core/errors.js +54 -5
  110. package/dist/core/fork-prune.d.ts +149 -0
  111. package/dist/core/fork-prune.js +333 -0
  112. package/dist/core/gist-health.d.ts +15 -3
  113. package/dist/core/gist-health.js +8 -0
  114. package/dist/core/gist-state-store.d.ts +24 -4
  115. package/dist/core/gist-state-store.js +98 -51
  116. package/dist/core/github-stats.d.ts +110 -16
  117. package/dist/core/github-stats.js +295 -110
  118. package/dist/core/http-cache.d.ts +0 -10
  119. package/dist/core/http-cache.js +0 -19
  120. package/dist/core/index.d.ts +13 -6
  121. package/dist/core/index.js +16 -6
  122. package/dist/core/issue-conversation.d.ts +8 -2
  123. package/dist/core/issue-conversation.js +31 -12
  124. package/dist/core/local-config.d.ts +95 -0
  125. package/dist/core/local-config.js +270 -0
  126. package/dist/core/merged-pr-notes.d.ts +2 -2
  127. package/dist/core/pacing.d.ts +41 -0
  128. package/dist/core/pacing.js +115 -0
  129. package/dist/core/pagination.d.ts +55 -0
  130. package/dist/core/pagination.js +59 -0
  131. package/dist/core/paths.d.ts +7 -0
  132. package/dist/core/paths.js +9 -0
  133. package/dist/core/pr-assembly.d.ts +2 -0
  134. package/dist/core/pr-assembly.js +6 -2
  135. package/dist/core/pr-graphql.d.ts +53 -4
  136. package/dist/core/pr-graphql.js +87 -14
  137. package/dist/core/pr-monitor.d.ts +35 -12
  138. package/dist/core/pr-monitor.js +110 -26
  139. package/dist/core/pr-preflight.d.ts +154 -0
  140. package/dist/core/pr-preflight.js +753 -0
  141. package/dist/core/pr-quality-rubric.d.ts +0 -6
  142. package/dist/core/pr-quality-rubric.js +0 -8
  143. package/dist/core/pr-template.d.ts +2 -0
  144. package/dist/core/pr-template.js +5 -1
  145. package/dist/core/prose-script.d.ts +72 -0
  146. package/dist/core/prose-script.js +223 -0
  147. package/dist/core/repo-policy.d.ts +111 -0
  148. package/dist/core/repo-policy.js +428 -0
  149. package/dist/core/repo-score-manager.d.ts +66 -0
  150. package/dist/core/repo-score-manager.js +140 -1
  151. package/dist/core/review-analysis.d.ts +49 -21
  152. package/dist/core/review-analysis.js +89 -15
  153. package/dist/core/reviewed-prs-fetch.js +11 -29
  154. package/dist/core/reviewed-prs.js +8 -15
  155. package/dist/core/stale-data.d.ts +78 -0
  156. package/dist/core/stale-data.js +153 -0
  157. package/dist/core/state-persistence.d.ts +62 -27
  158. package/dist/core/state-persistence.js +338 -119
  159. package/dist/core/state-schema.d.ts +152 -210
  160. package/dist/core/state-schema.js +232 -80
  161. package/dist/core/state.d.ts +81 -8
  162. package/dist/core/state.js +239 -46
  163. package/dist/core/status-determination.js +32 -12
  164. package/dist/core/strategy.js +3 -1
  165. package/dist/core/types.d.ts +22 -1
  166. package/dist/core/types.js +1 -0
  167. package/dist/core/untrusted-content.d.ts +30 -11
  168. package/dist/core/untrusted-content.js +95 -42
  169. package/dist/core/urls.d.ts +33 -0
  170. package/dist/core/urls.js +94 -0
  171. package/dist/dashboard/assets/chart-panel-B-nLVgzQ.js +3 -0
  172. package/dist/dashboard/assets/index-5IvMGokL.js +55 -0
  173. package/dist/dashboard/index.html +1 -1
  174. package/dist/formatters/json.d.ts +432 -10
  175. package/dist/formatters/json.js +156 -1
  176. package/package.json +6 -6
  177. package/dist/core/ci-enforced-tools.d.ts +0 -35
  178. package/dist/core/ci-enforced-tools.js +0 -109
  179. package/dist/core/comment-decision.d.ts +0 -79
  180. package/dist/core/comment-decision.js +0 -82
  181. package/dist/core/extraction-categories.d.ts +0 -55
  182. package/dist/core/extraction-categories.js +0 -108
  183. package/dist/core/follow-up-history.d.ts +0 -40
  184. package/dist/core/follow-up-history.js +0 -71
  185. package/dist/core/issue-effort.d.ts +0 -29
  186. package/dist/core/issue-effort.js +0 -47
  187. package/dist/core/maintainer-hints.d.ts +0 -23
  188. package/dist/core/maintainer-hints.js +0 -36
  189. package/dist/core/workflow-state.d.ts +0 -56
  190. package/dist/core/workflow-state.js +0 -101
  191. package/dist/dashboard/assets/chart-panel-DPKNBUts.js +0 -3
  192. package/dist/dashboard/assets/index-B25bZOYX.js +0 -55
@@ -3,31 +3,36 @@
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
  */
9
+ import { execFileSync } from 'node:child_process';
10
10
  import * as fs from 'node:fs';
11
11
  import * as path from 'node:path';
12
12
  import { getStateManager } from '../core/index.js';
13
- import { errorMessage } from '../core/errors.js';
13
+ import { UNATTENDED_ENV, ValidationError, errorMessage } from '../core/errors.js';
14
+ import { isOwnRepo } from '../core/urls.js';
15
+ import { getMachinePath, getMachinePathSource, setMachinePath } from '../core/local-config.js';
14
16
  import { warn } from '../core/logger.js';
15
17
  /**
16
- * Parse issueListPath from a config file's YAML frontmatter.
17
- * @param configContent - Raw content of the config.md file
18
- * @returns The path string or undefined if not found
18
+ * The issue list this machine is configured to use, for commands whose
19
+ * `--list-path` is optional. Workflows call those commands without the flag
20
+ * so a stored path is never pasted into shell text. Resolved by
21
+ * {@link detectIssueListPath}: configured lists only, with its checks; never
22
+ * a file found in the current directory.
19
23
  */
20
- export function parseIssueListPathFromConfig(configContent) {
21
- const match = configContent.match(/^---\n([\s\S]*?)\n---/);
22
- if (!match)
23
- return undefined;
24
- const frontmatter = match[1];
25
- const pathMatch = frontmatter.match(/issueListPath:\s*["']?([^"'\n]+)["']?/);
26
- return pathMatch ? pathMatch[1].trim() : undefined;
24
+ export function configuredIssueListPath() {
25
+ const location = detectIssueListPath();
26
+ if (!location) {
27
+ throw new ValidationError('No usable issue list is configured: none is set, or the configured path is relative, missing, or in a ' +
28
+ 'checkout that is not yours. Set one via `oss-autopilot setup --set issueListPath=<absolute path>` or pass --list-path.');
29
+ }
30
+ return location.path;
27
31
  }
28
32
  /**
29
- * Persist an absolute list/skip path back to state config, but only when it
30
- * differs from what's stored (avoid an autoSave on every run). Upgrading a
33
+ * Persist an absolute list/skip path for this machine (the local settings
34
+ * file, never the synced config: #1950), but only when it differs from the
35
+ * value in effect (avoid a write on every run). Upgrading a
31
36
  * relative/auto-detected value to absolute makes the location stick across
32
37
  * working directories, so `/oss` invoked from anywhere keeps finding the list
33
38
  * and skip file instead of silently no-opping the vet/skip/list-maintenance
@@ -36,10 +41,13 @@ export function parseIssueListPathFromConfig(configContent) {
36
41
  */
37
42
  export function persistConfigPath(key, absolutePath) {
38
43
  try {
39
- const stateManager = getStateManager();
40
- if (stateManager.getState().config[key] !== absolutePath) {
41
- stateManager.updateConfig({ [key]: absolutePath });
42
- }
44
+ const { config } = getStateManager().getState();
45
+ if (getMachinePath(key, config) === absolutePath)
46
+ return;
47
+ // A configured value made absolute keeps the source it had; one that
48
+ // came from the synced config counts as adopted.
49
+ const current = getMachinePathSource(key, config);
50
+ setMachinePath(key, absolutePath, current === undefined || current === 'synced' ? 'adopted' : current);
43
51
  }
44
52
  catch (error) {
45
53
  // Best-effort — the current run still uses the resolved path; the next run
@@ -47,80 +55,132 @@ export function persistConfigPath(key, absolutePath) {
47
55
  warn('startup', `Could not persist absolute ${key}: ${errorMessage(error)}`);
48
56
  }
49
57
  }
58
+ const SET_HINT = 'run `setup --set issueListPath=<absolute path>` to use it';
59
+ /** The issue-list setting in effect, before any check on the file. */
60
+ function configuredIssueList(isQuiet = false) {
61
+ const { config } = getStateManager().getState();
62
+ const value = getMachinePath('issueListPath', config);
63
+ const source = getMachinePathSource('issueListPath', config);
64
+ // A `probe` record was saved without the user confirming it (a build
65
+ // between #1950 and #1933 did that). The synced value, if any, applies.
66
+ if (source === 'probe') {
67
+ if (!isQuiet)
68
+ warn('startup', `issueListPath ${value} was auto-detected and never confirmed; ${SET_HINT}`);
69
+ return config.issueListPath ? { value: config.issueListPath, source: 'synced' } : undefined;
70
+ }
71
+ return value && source ? { value, source } : undefined;
72
+ }
50
73
  /**
51
- * Locate the curated issue-list file: state config first, then the legacy
52
- * config.md frontmatter, then known default paths. Returns undefined when
53
- * no list exists — callers treat that as "user has no curated list".
74
+ * Locate the curated issue-list file this machine is configured to use.
75
+ * Returns undefined when none is configured, or the configured value is
76
+ * relative, missing, or (unless the user set it on this machine) inside
77
+ * someone else's checkout. Callers treat that as "no curated list". A file
78
+ * found in the current directory is never returned here: see
79
+ * {@link suggestIssueListPath} (#1933).
54
80
  *
55
- * All returned paths are ABSOLUTE (#1577): a relative configured value or a
56
- * known-path probe is resolved against CWD once, then persisted, so the vet →
57
- * skip → list-maintenance flow no longer depends on `/oss` running from the
58
- * list's parent directory.
81
+ * @param isForeign - The foreign-checkout check; the long-running dashboard
82
+ * passes a memoized one so polling does not run Git per request (#2012).
59
83
  */
60
- export function detectIssueListPath() {
61
- // When a configured path exists but its file is missing at resolve-time, a
62
- // coincidental probe hit below must NOT overwrite the user's configured value
63
- // in state — it's likely just absent from the current CWD, not wrong.
64
- let configuredButMissing = false;
65
- // 1. Check state.json config (primary)
84
+ export function detectIssueListPath(isForeign = isForeignCheckout) {
85
+ let configured;
66
86
  try {
67
- const stateManager = getStateManager();
68
- const configuredPath = stateManager.getState().config.issueListPath;
69
- if (configuredPath) {
70
- // Resolve a relative configured value against CWD to an absolute path so
71
- // the location is stable no matter where `/oss` runs (#1577).
72
- const resolved = path.resolve(configuredPath);
73
- if (fs.existsSync(resolved)) {
74
- if (resolved !== configuredPath)
75
- persistConfigPath('issueListPath', resolved);
76
- return { path: resolved, source: 'configured' };
77
- }
78
- // A path WAS configured but nothing is there. Surface it prominently
79
- // instead of silently degrading to probes/undefined (#1577): a large
80
- // configured list being ignored is otherwise easy to miss.
81
- configuredButMissing = true;
82
- warn('startup', `Configured issueListPath not found at ${resolved} (cwd ${process.cwd()}); ` +
83
- `falling back to auto-detection. Set an absolute issueListPath, or run from its directory.`);
84
- }
87
+ configured = configuredIssueList();
85
88
  }
86
89
  catch (error) {
87
- // State manager may not be initialized yet — fall through to legacy config.md
88
90
  warn('startup', `Could not read issueListPath from state: ${errorMessage(error)}`);
91
+ return undefined;
92
+ }
93
+ if (!configured)
94
+ return undefined;
95
+ const { value, source } = configured;
96
+ // Resolving a relative value against the current directory would pick up
97
+ // whatever file is there (#1933); setup and config store absolute paths.
98
+ if (!path.isAbsolute(value)) {
99
+ warn('startup', `Ignoring relative issueListPath ${value}; ${SET_HINT}`);
100
+ return undefined;
101
+ }
102
+ if (!fs.existsSync(value)) {
103
+ warn('startup', `Configured issueListPath not found at ${value}.`);
104
+ return undefined;
105
+ }
106
+ // A value the user did not set here (synced, adopted) is checked like a
107
+ // probe hit: it may point into a checkout that is not theirs.
108
+ if (source !== 'set' && isForeign(path.dirname(value))) {
109
+ warn('startup', `Ignoring issueListPath ${value}: its checkout has a remote not owned by you; ${SET_HINT}`);
110
+ return undefined;
111
+ }
112
+ return { path: value, source: 'configured' };
113
+ }
114
+ /** The owner segment of a remote URL on any host (`https://h/o/r`, `ssh://u@h:22/o/r`, `u@h:o/r`). */
115
+ function remoteOwner(url) {
116
+ return (/^[a-z][\w+.-]*:\/\/[^/]+\/([^/]+)\//i.exec(url) ?? /^(?:[^@/]+@)?[^/:]+:([^/]+)\//.exec(url))?.[1];
117
+ }
118
+ /**
119
+ * True when `dir` is inside a Git checkout that has a remote not owned by
120
+ * the configured user (owner path segment, any host, case-insensitive). A
121
+ * fork clone with an `upstream` remote is foreign, and so is a checkout with
122
+ * no remotes or one Git refuses to read. Only Git reporting "not a git
123
+ * repository" means not a checkout (false); a timeout, a spawn failure (no
124
+ * Git) or any other error fails closed as foreign. Reads local Git config
125
+ * only; no network.
126
+ */
127
+ export function isForeignCheckout(dir) {
128
+ const git = (...args) => execFileSync('git', ['-C', dir, ...args], { encoding: 'utf8', timeout: 5000, stdio: ['ignore', 'pipe', 'pipe'] });
129
+ try {
130
+ if (git('rev-parse', '--is-inside-work-tree').trim() !== 'true')
131
+ return false;
132
+ }
133
+ catch (error) {
134
+ // Fail closed: a timeout or spawn failure (code/signal set), "dubious
135
+ // ownership" (a checkout Git will not read) or any other Git error is
136
+ // foreign. Only a plain "not a git repository" exit is not a checkout.
137
+ const { code, signal, stderr } = error;
138
+ return Boolean(code || signal) || !/not a git repository/.test(String(stderr));
139
+ }
140
+ let username = '';
141
+ let urls;
142
+ try {
143
+ username = getStateManager().getState().config.githubUsername;
144
+ urls = git('config', '--get-regexp', String.raw `^remote\..*\.url$`)
145
+ .trim()
146
+ .split('\n')
147
+ .map((line) => line.slice(line.indexOf(' ') + 1));
148
+ }
149
+ catch {
150
+ return true; // no remotes, or git failed inside a checkout
151
+ }
152
+ return !username || urls.some((url) => !isOwnRepo(remoteOwner(url) ?? '', username));
153
+ }
154
+ /**
155
+ * A curated list found at a known path under the current directory, offered
156
+ * for the user to confirm (#1933). Nothing is saved: the prompt layer asks,
157
+ * and a yes is stored with `setup --set issueListPath=<path>`. Until then the
158
+ * file is not used as the list. Offered only when no list is configured, the
159
+ * run is attended, the path has no shell metacharacters, and the current
160
+ * directory is not someone else's checkout (a repository can ship an
161
+ * `issues.md`).
162
+ */
163
+ export function suggestIssueListPath() {
164
+ if (process.env[UNATTENDED_ENV] !== undefined)
165
+ return undefined;
166
+ try {
167
+ if (configuredIssueList(true))
168
+ return undefined;
169
+ }
170
+ catch (error) {
171
+ warn('startup', `Could not read issueListPath from state: ${errorMessage(error)}`);
172
+ return undefined;
173
+ }
174
+ const probe = ['open-source/potential-issue-list.md', 'oss/issue-list.md', 'issues.md'].find((p) => fs.existsSync(p));
175
+ if (!probe)
176
+ return undefined;
177
+ const found = path.resolve(probe);
178
+ // The path goes into a quoted shell command in the prompt layer.
179
+ if (/["$\\`\p{Cc}]/u.test(found))
180
+ return undefined;
181
+ if (isForeignCheckout(process.cwd())) {
182
+ warn('startup', `Found ${found}, not offered because this checkout has a remote not owned by you; ${SET_HINT}`);
183
+ return undefined;
89
184
  }
90
- // 2. Fallback: config.md (legacy — will be removed in future)
91
- const configPath = '.claude/oss-autopilot/config.md';
92
- if (fs.existsSync(configPath)) {
93
- try {
94
- const configContent = fs.readFileSync(configPath, 'utf8');
95
- const configuredPath = parseIssueListPathFromConfig(configContent);
96
- if (configuredPath) {
97
- const resolved = path.resolve(configuredPath);
98
- if (fs.existsSync(resolved)) {
99
- return { path: resolved, source: 'configured' };
100
- }
101
- }
102
- }
103
- catch (error) {
104
- console.error('[STARTUP] Failed to read config:', errorMessage(error));
105
- }
106
- // Legacy config.md missing-file case is intentionally not warned/persisted:
107
- // this branch is slated for removal, and step 1 already covers the primary
108
- // (state.json) configured path (#1577).
109
- }
110
- // 3. Probe known paths. Return the ABSOLUTE path and persist it so the first
111
- // successful detection sticks from any working directory afterwards (#1577).
112
- // But NOT when a path was configured-but-missing: the probe hit is likely
113
- // just absent from the current CWD, so overwriting the user's deliberate
114
- // config with a coincidental probe file would be the silent-wrong-target bug
115
- // #1577 set out to kill.
116
- const probes = ['open-source/potential-issue-list.md', 'oss/issue-list.md', 'issues.md'];
117
- for (const probe of probes) {
118
- if (fs.existsSync(probe)) {
119
- const resolved = path.resolve(probe);
120
- if (!configuredButMissing)
121
- persistConfigPath('issueListPath', resolved);
122
- return { path: resolved, source: 'auto-detected' };
123
- }
124
- }
125
- return undefined;
185
+ return { path: found, source: 'auto-detected' };
126
186
  }
@@ -3,6 +3,8 @@
3
3
  * attention, waiting, shelved, or auto (reset to computed status).
4
4
  */
5
5
  import { getStateManager, maybeCheckpoint } from '../core/index.js';
6
+ import { shelveReasonsOf } from '../core/daily-logic.js';
7
+ import { issueRefKey } from '../core/urls.js';
6
8
  import { ValidationError } from '../core/errors.js';
7
9
  import { PR_URL_PATTERN, validateGitHubUrl, validateUrl } from './validation.js';
8
10
  const MODULE = 'move';
@@ -46,7 +48,11 @@ export async function runMove(options) {
46
48
  }
47
49
  case 'shelved': {
48
50
  const apply = () => stateManager.batch(() => {
49
- stateManager.shelvePR(options.prUrl);
51
+ // Record why the PR needs addressing right now, when the last
52
+ // digest knows it, so only a reason it lacks now unshelves it (#1922).
53
+ const key = issueRefKey(options.prUrl);
54
+ const openPR = stateManager.getState().lastDigest?.openPRs.find((pr) => issueRefKey(pr.url) === key);
55
+ stateManager.shelvePR(options.prUrl, openPR && shelveReasonsOf(openPR));
50
56
  stateManager.clearStatusOverride(options.prUrl);
51
57
  });
52
58
  apply();
@@ -47,13 +47,23 @@ export declare function loadHandoff(dir: string): {
47
47
  record: OvernightRecord;
48
48
  report: string | null;
49
49
  };
50
- /**
51
- * Fetch `branch` from its bundle into a fresh bare repo under a private temp
52
- * dir. The bundle is copied through a checked descriptor first, so the tick
53
- * cannot swap the file between the check and git reading it. The caller
54
- * pushes from `repo` and must call `cleanup`.
55
- */
56
- export declare function importHandoffBundle(dir: string, branch: string): {
50
+ type PrivateRepo = {
57
51
  repo: string;
58
52
  cleanup: () => void;
59
53
  };
54
+ /**
55
+ * The handoff's bundle as a private repo. The bundle is copied through a
56
+ * checked descriptor first, so the tick cannot swap the file between the
57
+ * check and git reading it.
58
+ */
59
+ export declare function importHandoffBundle(dir: string, branch: string): PrivateRepo;
60
+ /**
61
+ * A worktree's branch as a private repo, for a box without the handoff
62
+ * (#1937). The push then never runs in the worktree, whose config the tick
63
+ * could have written (a credential helper, a pre-push hook, an SSH command).
64
+ * Where the push goes is the caller's business: a URL rewrite in the worktree
65
+ * can still change what its remote list shows. `worktree` must be an
66
+ * absolute path.
67
+ */
68
+ export declare function importWorktreeBranch(worktree: string, branch: string): PrivateRepo;
69
+ export {};
@@ -176,23 +176,16 @@ export function loadHandoff(dir) {
176
176
  };
177
177
  }
178
178
  /**
179
- * Fetch `branch` from its bundle into a fresh bare repo under a private temp
180
- * dir. The bundle is copied through a checked descriptor first, so the tick
181
- * cannot swap the file between the check and git reading it. The caller
182
- * pushes from `repo` and must call `cleanup`.
179
+ * Fetch `branch` into a fresh bare repo under a private temp dir, from the
180
+ * source `prepare` returns (it may put files in that dir first). The caller
181
+ * pushes from `repo` and must call `cleanup`. Nothing the tick wrote is the
182
+ * repository Git runs in: no config, hook or alias of its making is read.
183
183
  */
184
- export function importHandoffBundle(dir, branch) {
184
+ function importBranch(branch, prepare) {
185
185
  const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'oss-push-prep-'));
186
186
  const cleanup = () => fs.rmSync(tmp, { recursive: true, force: true });
187
187
  try {
188
- const copy = path.join(tmp, 'in.bundle');
189
- const out = fs.openSync(copy, 'wx', 0o600);
190
- try {
191
- streamUntrusted(path.join(dir, bundleFileFor(branch)), MAX_BUNDLE_BYTES, (c) => fs.writeSync(out, c));
192
- }
193
- finally {
194
- fs.closeSync(out);
195
- }
188
+ const source = prepare(tmp);
196
189
  const repo = path.join(tmp, 'repo.git');
197
190
  gitRun(['init', '-q', '--bare', repo]);
198
191
  gitRun([
@@ -203,7 +196,7 @@ export function importHandoffBundle(dir, branch) {
203
196
  'fetch',
204
197
  '-q',
205
198
  '--no-tags',
206
- copy,
199
+ source,
207
200
  `+refs/heads/${branch}:refs/heads/${branch}`,
208
201
  ]);
209
202
  return { repo, cleanup };
@@ -213,3 +206,32 @@ export function importHandoffBundle(dir, branch) {
213
206
  throw err;
214
207
  }
215
208
  }
209
+ /**
210
+ * The handoff's bundle as a private repo. The bundle is copied through a
211
+ * checked descriptor first, so the tick cannot swap the file between the
212
+ * check and git reading it.
213
+ */
214
+ export function importHandoffBundle(dir, branch) {
215
+ return importBranch(branch, (tmp) => {
216
+ const copy = path.join(tmp, 'in.bundle');
217
+ const out = fs.openSync(copy, 'wx', 0o600);
218
+ try {
219
+ streamUntrusted(path.join(dir, bundleFileFor(branch)), MAX_BUNDLE_BYTES, (c) => fs.writeSync(out, c));
220
+ }
221
+ finally {
222
+ fs.closeSync(out);
223
+ }
224
+ return copy;
225
+ });
226
+ }
227
+ /**
228
+ * A worktree's branch as a private repo, for a box without the handoff
229
+ * (#1937). The push then never runs in the worktree, whose config the tick
230
+ * could have written (a credential helper, a pre-push hook, an SSH command).
231
+ * Where the push goes is the caller's business: a URL rewrite in the worktree
232
+ * can still change what its remote list shows. `worktree` must be an
233
+ * absolute path.
234
+ */
235
+ export function importWorktreeBranch(worktree, branch) {
236
+ return importBranch(branch, () => worktree);
237
+ }
@@ -8,22 +8,26 @@
8
8
  * thing in the overnight pipeline that pushes. Three gates, all enforced in
9
9
  * code rather than by convention:
10
10
  *
11
- * 1. The push target is resolved from the worktree's actual remotes: the one
12
- * whose parsed URL owner equals the authenticated login. Remote names are
13
- * never trusted.
14
- * 2. That repo must be a fork (`GET /repos/{owner}/{repo}` says `fork: true`),
15
- * so the user's own source repos never grow `prep/*` branches.
11
+ * 1. The push target is the repository GitHub names: the PR's head repo, or
12
+ * `<login>/<repo>` for an issue. The worktree must hold a remote whose
13
+ * parsed URL names that same repo; remote names are never trusted, and
14
+ * neither is the remote's URL, which the worktree's config can rewrite
15
+ * (#1937). The push goes to a URL built from GitHub's answer, keeping only
16
+ * that remote's transport (pickRemote).
17
+ * 2. That repo must be a fork (`GET /repos/{owner}/{repo}` says `fork: true`)
18
+ * of the PR's repo, so the user's own source repos never grow `prep/*`
19
+ * branches.
16
20
  * 3. The ref is always `refs/heads/prep/<branch>` and never `--force`; a
17
21
  * non-fast-forward is a skip with a reason.
18
22
  *
19
23
  * With `OSS_AUTOPILOT_HANDOFF_DIR` set the tick ran as another user, and the
20
24
  * branches arrive as bundles (overnight-handoff.ts). Then there is no
21
- * worktree to read remotes from: the target is the PR's head repo (or
22
- * `<login>/<repo>` for an issue), which must also be a fork of the PR's repo,
23
- * and the push goes out of a private repo filled from the bundle.
25
+ * worktree, so no remote to compare. Either way the push goes out of a
26
+ * private repo, filled from the bundle or from the worktree's branch.
24
27
  */
25
28
  /** The only ref namespace this command ever pushes to. */
26
29
  export declare const PREP_REF_PREFIX = "refs/heads/prep/";
30
+ export declare const GIT_TIMEOUT_MS = 60000;
27
31
  export interface RemoteOwnerRepo {
28
32
  owner: string;
29
33
  repo: string;
@@ -94,5 +98,7 @@ export declare function buildPrepRef(branch: string): string;
94
98
  export declare function prepBranchName(ref: string): string;
95
99
  /** Pure: `<fork>/compare/<pr-head>...prep/<branch>`. */
96
100
  export declare function compareUrlFor(target: RemoteOwnerRepo, prHead: string, prepBranch: string): string;
101
+ /** Run `git -C <worktree> <args>` and return its stdout. Also the runner `cleanup` uses. */
102
+ export declare function git(worktree: string, args: string[], timeoutMs?: number, extraEnv?: Record<string, string>): string;
97
103
  /** Push every prepared branch of the latest overnight run to `prep/*` on the user's fork. */
98
104
  export declare function runOvernightPushPrep(options: OvernightPushPrepOptions): Promise<OvernightPushPrepOutput>;