@oss-autopilot/core 3.27.0 → 3.28.1
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.
- package/dist/cli-pre-action.d.ts +9 -0
- package/dist/cli-pre-action.js +95 -0
- package/dist/cli-registry.js +11 -1
- package/dist/cli.bundle.cjs +116 -113
- package/dist/cli.js +4 -87
- package/dist/commands/comments.js +3 -1
- package/dist/commands/dashboard-lifecycle.d.ts +25 -2
- package/dist/commands/dashboard-lifecycle.js +71 -55
- package/dist/commands/dashboard-server.js +1 -1
- package/dist/commands/dashboard.d.ts +2 -2
- package/dist/commands/dashboard.js +13 -5
- package/dist/commands/overnight-push-prep.js +4 -0
- package/dist/commands/overnight.js +31 -1
- package/dist/commands/parse-list.js +77 -43
- package/dist/commands/startup.d.ts +3 -0
- package/dist/commands/startup.js +7 -3
- package/dist/commands/vet-list.js +4 -2
- package/dist/core/anti-llm-policy.js +10 -0
- package/dist/core/checklist-analysis.d.ts +6 -0
- package/dist/core/checklist-analysis.js +90 -14
- package/dist/core/ci-analysis.js +11 -4
- package/dist/core/errors.d.ts +17 -0
- package/dist/core/errors.js +25 -0
- package/dist/core/paths.d.ts +9 -1
- package/dist/core/paths.js +11 -1
- package/dist/core/pr-monitor.d.ts +2 -2
- package/dist/core/pr-monitor.js +9 -6
- package/dist/core/review-analysis.d.ts +6 -2
- package/dist/core/review-analysis.js +13 -4
- package/dist/core/types.d.ts +1 -1
- package/dist/dashboard/assets/chart-panel-0drzwc3-.js +3 -0
- package/dist/dashboard/assets/confetti.module-BYDB1iN2.js +2 -0
- package/dist/dashboard/assets/index-C0LCGMVi.js +50 -0
- package/dist/dashboard/assets/index-CTiG-vjC.css +1 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-500-normal-CJOVTJB7.woff +0 -0
- package/dist/dashboard/assets/plus-jakarta-sans-latin-400-normal-BDKaGhyp.woff +0 -0
- package/dist/dashboard/assets/plus-jakarta-sans-latin-400-normal-Dhut76fR.woff2 +0 -0
- package/dist/dashboard/assets/plus-jakarta-sans-latin-500-normal-Bf-nb4oT.woff2 +0 -0
- package/dist/dashboard/assets/plus-jakarta-sans-latin-500-normal-DYtqi0QS.woff +0 -0
- package/dist/dashboard/assets/plus-jakarta-sans-latin-600-normal-BR_Ojra4.woff +0 -0
- package/dist/dashboard/assets/plus-jakarta-sans-latin-600-normal-DLTa1BUW.woff2 +0 -0
- package/dist/dashboard/assets/plus-jakarta-sans-latin-700-normal-CfpNZvy6.woff2 +0 -0
- package/dist/dashboard/assets/plus-jakarta-sans-latin-700-normal-DqEcQeE5.woff +0 -0
- package/dist/dashboard/assets/plus-jakarta-sans-latin-800-normal-BRNHt2w0.woff +0 -0
- package/dist/dashboard/assets/plus-jakarta-sans-latin-800-normal-CusIZhrK.woff2 +0 -0
- package/dist/dashboard/favicon.svg +83 -0
- package/dist/dashboard/index.html +54 -0
- package/dist/formatters/json.d.ts +19 -0
- package/dist/formatters/json.js +3 -0
- package/package.json +3 -2
package/dist/cli.js
CHANGED
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
* handlers so only the invoked command's dependencies are evaluated.
|
|
10
10
|
*/
|
|
11
11
|
import { Command } from 'commander';
|
|
12
|
-
import {
|
|
12
|
+
import { getCLIVersion, stateFileExists } from './core/index.js';
|
|
13
13
|
import { commands, handleCommandError } from './cli-registry.js';
|
|
14
|
+
import { installPreAction } from './cli-pre-action.js';
|
|
14
15
|
const VERSION = getCLIVersion();
|
|
15
16
|
const program = new Command();
|
|
16
17
|
program
|
|
@@ -24,92 +25,8 @@ const localOnlySet = new Set(commands.filter((c) => c.localOnly).map((c) => c.na
|
|
|
24
25
|
for (const cmd of commands) {
|
|
25
26
|
cmd.register(program);
|
|
26
27
|
}
|
|
27
|
-
//
|
|
28
|
-
program
|
|
29
|
-
// Enable debug logging if --debug flag is set
|
|
30
|
-
const globalOpts = thisCommand.opts();
|
|
31
|
-
if (globalOpts.debug) {
|
|
32
|
-
enableDebug();
|
|
33
|
-
debug('cli', `Running command: ${actionCommand.name()}`);
|
|
34
|
-
}
|
|
35
|
-
// actionCommand is the command being executed (e.g., 'status', 'daily').
|
|
36
|
-
// For subcommand groups (e.g. `guidelines view`), Commander returns the
|
|
37
|
-
// leaf name `view` — but the registry sets `localOnly` on the parent
|
|
38
|
-
// entry `guidelines`. Walk the parent chain so a `localOnly` ancestor
|
|
39
|
-
// covers all its leaves (#1208 M2). Without this, `guidelines view` —
|
|
40
|
-
// which works fine in local mode (returns storageMode: 'local-unavailable')
|
|
41
|
-
// — would still hit the auth gate and fail.
|
|
42
|
-
let cmd = actionCommand;
|
|
43
|
-
let isLocalOnly = false;
|
|
44
|
-
while (cmd) {
|
|
45
|
-
if (localOnlySet.has(cmd.name())) {
|
|
46
|
-
isLocalOnly = true;
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
cmd = cmd.parent;
|
|
50
|
-
}
|
|
51
|
-
if (!isLocalOnly) {
|
|
52
|
-
const token = await getGitHubTokenAsync();
|
|
53
|
-
if (!token) {
|
|
54
|
-
// Honor --json at the CLI boundary so machine consumers (plugins, MCP
|
|
55
|
-
// stdio harnesses, scripts) get a parseable envelope instead of a
|
|
56
|
-
// stderr blob followed by a non-zero exit. Commander has already parsed
|
|
57
|
-
// the action's own options, so we check both the action command and the
|
|
58
|
-
// raw argv as a fallback (#1056 M20).
|
|
59
|
-
const wantsJson = Boolean(actionCommand.opts().json) || process.argv.includes('--json');
|
|
60
|
-
if (wantsJson) {
|
|
61
|
-
const { outputJsonError } = await import('./formatters/json.js');
|
|
62
|
-
outputJsonError('GitHub authentication required. Install gh CLI and run `gh auth login`, or set GITHUB_TOKEN.', 'AUTH_REQUIRED');
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
console.error('Error: GitHub authentication required.');
|
|
66
|
-
console.error('');
|
|
67
|
-
console.error('Option 1 (Recommended): Install and authenticate GitHub CLI');
|
|
68
|
-
console.error(' Install: https://cli.github.com/');
|
|
69
|
-
console.error(' Then run: gh auth login');
|
|
70
|
-
console.error('');
|
|
71
|
-
console.error('Option 2: Set GITHUB_TOKEN environment variable');
|
|
72
|
-
console.error(' export GITHUB_TOKEN="your-github-token-here"');
|
|
73
|
-
console.error('');
|
|
74
|
-
console.error('Then run your command again.');
|
|
75
|
-
}
|
|
76
|
-
process.exit(1);
|
|
77
|
-
}
|
|
78
|
-
// Activate Gist persistence if configured, before any command runs.
|
|
79
|
-
// Shared helper peeks at the state file and only pre-sets the singleton
|
|
80
|
-
// when Gist mode is the configured persistence (#1000). Hard errors
|
|
81
|
-
// still throw (#1202); the resolving degraded modes are surfaced in the
|
|
82
|
-
// JSON envelope so --json consumers see them too (#1433).
|
|
83
|
-
const { ensureGistPersistence, renderGistWarning } = await import('./core/index.js');
|
|
84
|
-
const status = await ensureGistPersistence(token);
|
|
85
|
-
if (status === 'degraded' || status === 'state-unreadable') {
|
|
86
|
-
const { setEnvelopeGistWarning } = await import('./formatters/json.js');
|
|
87
|
-
// Shared renderer (#1444). 'degraded' is ensureGistPersistence's
|
|
88
|
-
// deliberate conflation of the transient init fallback and a #1443
|
|
89
|
-
// degraded bootstrap — rendered as the init-fallback cause, as before.
|
|
90
|
-
setEnvelopeGistWarning(renderGistWarning(status === 'degraded' ? 'init-fallback' : 'state-unreadable'));
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
// #1431: localOnly skips the AUTH GATE, not gist persistence. Mutating
|
|
95
|
-
// localOnly commands (shelve/move/dismiss/override/...) already call
|
|
96
|
-
// maybeCheckpoint, which silently no-ops when the singleton never
|
|
97
|
-
// bootstrapped — so a gist-configured user's CLI mutations were written
|
|
98
|
-
// local-only with no warning and never reached the Gist. Best-effort
|
|
99
|
-
// bootstrap; the warning semantics live (and are unit-tested) in
|
|
100
|
-
// bootstrapGistBestEffort.
|
|
101
|
-
const { bootstrapGistBestEffort } = await import('./core/index.js');
|
|
102
|
-
const localOnlyWarning = await bootstrapGistBestEffort(getGitHubTokenAsync);
|
|
103
|
-
if (localOnlyWarning) {
|
|
104
|
-
console.error(`Warning: ${localOnlyWarning}`);
|
|
105
|
-
// Also thread it into the JSON envelope: shelve/move/dismiss --json
|
|
106
|
-
// consumers (the agent harness) must see the mutation will not sync —
|
|
107
|
-
// stderr alone is invisible to them (#1433).
|
|
108
|
-
const { setEnvelopeGistWarning } = await import('./formatters/json.js');
|
|
109
|
-
setEnvelopeGistWarning(localOnlyWarning);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
});
|
|
28
|
+
// Debug flag, auth gate and Gist bootstrap (see cli-pre-action.ts).
|
|
29
|
+
installPreAction(program, localOnlySet);
|
|
113
30
|
// First-run detection: if no subcommand was provided and no state file exists,
|
|
114
31
|
// show a quick-start guide and exit before Commander displays generic help.
|
|
115
32
|
const userArgs = process.argv.slice(2);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { getStateManager, getOctokit, parseGitHubUrl, requireGitHubToken, maybeCheckpoint } from '../core/index.js';
|
|
6
6
|
import { wrapUntrustedContent } from '../core/untrusted-content.js';
|
|
7
|
-
import { ValidationError, isRateLimitOrAuthError } from '../core/errors.js';
|
|
7
|
+
import { ValidationError, assertAttended, isRateLimitOrAuthError } from '../core/errors.js';
|
|
8
8
|
import { warn } from '../core/logger.js';
|
|
9
9
|
const MODULE = 'comments';
|
|
10
10
|
import { paginateAllDetailed } from '../core/pagination.js';
|
|
@@ -157,6 +157,7 @@ export async function runComments(options) {
|
|
|
157
157
|
* @throws {ValidationError} If the URL or message is invalid
|
|
158
158
|
*/
|
|
159
159
|
export async function runPost(options) {
|
|
160
|
+
assertAttended('post a comment');
|
|
160
161
|
validateUrl(options.url);
|
|
161
162
|
validateGitHubUrl(options.url, ISSUE_OR_PR_URL_PATTERN, 'issue or PR');
|
|
162
163
|
if (!options.message.trim()) {
|
|
@@ -192,6 +193,7 @@ export async function runPost(options) {
|
|
|
192
193
|
* @throws {ValidationError} If the URL or message is invalid
|
|
193
194
|
*/
|
|
194
195
|
export async function runClaim(options) {
|
|
196
|
+
assertAttended('claim an issue');
|
|
195
197
|
validateUrl(options.issueUrl);
|
|
196
198
|
validateGitHubUrl(options.issueUrl, ISSUE_URL_PATTERN, 'issue');
|
|
197
199
|
const token = requireGitHubToken();
|
|
@@ -15,14 +15,37 @@ export interface LaunchResult {
|
|
|
15
15
|
*/
|
|
16
16
|
lastBrowserOpenedAt?: string;
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* The script to spawn `dashboard serve` with. From the CLI that is argv[1]
|
|
20
|
+
* (cli.bundle.cjs in production, cli.ts in dev). From another host process
|
|
21
|
+
* such as the MCP server, argv[1] is that host's own entry, so use the core
|
|
22
|
+
* CLI bundle that ships beside the dashboard assets instead (#1735).
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveCliEntry(argv1: string, assetsDir: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Stop the running dashboard server if a different CLI version launched it (#548).
|
|
27
|
+
*
|
|
28
|
+
* The server's refresh path re-classifies PRs with its own bundled code and
|
|
29
|
+
* writes the result to state, so an old-version server overwrites whatever a
|
|
30
|
+
* newer `daily` just wrote (#1709). The server cannot detect this itself:
|
|
31
|
+
* plugin updates install into a new versioned directory, so the old server's
|
|
32
|
+
* own package.json never changes. Callers running the current CLI (startup,
|
|
33
|
+
* `daily`) therefore make the check.
|
|
34
|
+
*
|
|
35
|
+
* Returns the running server when it is left up (same or unknown version, or
|
|
36
|
+
* the kill failed), or null when none is running or the stale one was stopped.
|
|
37
|
+
*/
|
|
38
|
+
export declare function stopStaleDashboardServer(): Promise<LaunchResult | null>;
|
|
18
39
|
/**
|
|
19
40
|
* Launch the interactive dashboard SPA server as a detached background process.
|
|
20
41
|
*
|
|
21
42
|
* Returns the server URL if launched successfully, or null if the SPA assets
|
|
22
43
|
* are not available (dashboard is skipped).
|
|
23
44
|
*
|
|
24
|
-
* If a server is already running (detected via PID
|
|
25
|
-
* returns its URL without launching a new one.
|
|
45
|
+
* If a server from the current version is already running (detected via PID
|
|
46
|
+
* file + health probe), returns its URL without launching a new one. A server
|
|
47
|
+
* from another version is stopped first, even when the assets are missing and
|
|
48
|
+
* no replacement can be launched (#1709).
|
|
26
49
|
*/
|
|
27
50
|
export declare function launchDashboardServer(options?: {
|
|
28
51
|
port?: number;
|
|
@@ -4,85 +4,101 @@
|
|
|
4
4
|
* and detecting whether a server is already running.
|
|
5
5
|
*/
|
|
6
6
|
import { spawn } from 'node:child_process';
|
|
7
|
+
import * as fs from 'node:fs';
|
|
8
|
+
import * as path from 'node:path';
|
|
7
9
|
import { findRunningDashboardServer, isDashboardServerRunning, readDashboardServerInfo, removeDashboardServerInfo, } from './dashboard-process.js';
|
|
8
10
|
import { resolveAssetsDir } from './dashboard.js';
|
|
9
11
|
import { getCLIVersion } from '../core/index.js';
|
|
10
12
|
const DEFAULT_PORT = 3000;
|
|
11
13
|
const POLL_INTERVAL_MS = 200;
|
|
12
14
|
const MAX_POLL_ATTEMPTS = 25; // 5 seconds total
|
|
15
|
+
/**
|
|
16
|
+
* The script to spawn `dashboard serve` with. From the CLI that is argv[1]
|
|
17
|
+
* (cli.bundle.cjs in production, cli.ts in dev). From another host process
|
|
18
|
+
* such as the MCP server, argv[1] is that host's own entry, so use the core
|
|
19
|
+
* CLI bundle that ships beside the dashboard assets instead (#1735).
|
|
20
|
+
*/
|
|
21
|
+
export function resolveCliEntry(argv1, assetsDir) {
|
|
22
|
+
if (/^cli\.(?:bundle\.cjs|ts|js)$/.test(path.basename(argv1)))
|
|
23
|
+
return argv1;
|
|
24
|
+
const coreBundle = path.resolve(assetsDir, '../../core/dist/cli.bundle.cjs');
|
|
25
|
+
return fs.existsSync(coreBundle) ? coreBundle : argv1;
|
|
26
|
+
}
|
|
13
27
|
function sleep(ms) {
|
|
14
28
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
15
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Stop the running dashboard server if a different CLI version launched it (#548).
|
|
32
|
+
*
|
|
33
|
+
* The server's refresh path re-classifies PRs with its own bundled code and
|
|
34
|
+
* writes the result to state, so an old-version server overwrites whatever a
|
|
35
|
+
* newer `daily` just wrote (#1709). The server cannot detect this itself:
|
|
36
|
+
* plugin updates install into a new versioned directory, so the old server's
|
|
37
|
+
* own package.json never changes. Callers running the current CLI (startup,
|
|
38
|
+
* `daily`) therefore make the check.
|
|
39
|
+
*
|
|
40
|
+
* Returns the running server when it is left up (same or unknown version, or
|
|
41
|
+
* the kill failed), or null when none is running or the stale one was stopped.
|
|
42
|
+
*/
|
|
43
|
+
export async function stopStaleDashboardServer() {
|
|
44
|
+
const existing = await findRunningDashboardServer();
|
|
45
|
+
if (!existing)
|
|
46
|
+
return null;
|
|
47
|
+
const info = readDashboardServerInfo();
|
|
48
|
+
// PID file disappeared between health check and now (race condition).
|
|
49
|
+
if (!info)
|
|
50
|
+
return null;
|
|
51
|
+
const running = {
|
|
52
|
+
url: existing.url,
|
|
53
|
+
port: existing.port,
|
|
54
|
+
alreadyRunning: true,
|
|
55
|
+
lastBrowserOpenedAt: info.lastBrowserOpenedAt,
|
|
56
|
+
};
|
|
57
|
+
const currentVersion = getCLIVersion();
|
|
58
|
+
if (!info.version || currentVersion === '0.0.0' || info.version === currentVersion) {
|
|
59
|
+
return running;
|
|
60
|
+
}
|
|
61
|
+
console.error(`[DASHBOARD] Dashboard server version mismatch (running: ${info.version}, current: ${currentVersion}). Stopping it...`);
|
|
62
|
+
try {
|
|
63
|
+
process.kill(info.pid, 'SIGTERM');
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
// ESRCH = already exited
|
|
67
|
+
if (err.code !== 'ESRCH') {
|
|
68
|
+
console.error(`[DASHBOARD] Could not kill outdated dashboard (PID ${info.pid}): ${err.message}`);
|
|
69
|
+
// Could not kill old server (e.g. EPERM); report it as running rather
|
|
70
|
+
// than letting the caller attempt a doomed spawn on the same port.
|
|
71
|
+
return running;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
removeDashboardServerInfo();
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
16
77
|
/**
|
|
17
78
|
* Launch the interactive dashboard SPA server as a detached background process.
|
|
18
79
|
*
|
|
19
80
|
* Returns the server URL if launched successfully, or null if the SPA assets
|
|
20
81
|
* are not available (dashboard is skipped).
|
|
21
82
|
*
|
|
22
|
-
* If a server is already running (detected via PID
|
|
23
|
-
* returns its URL without launching a new one.
|
|
83
|
+
* If a server from the current version is already running (detected via PID
|
|
84
|
+
* file + health probe), returns its URL without launching a new one. A server
|
|
85
|
+
* from another version is stopped first, even when the assets are missing and
|
|
86
|
+
* no replacement can be launched (#1709).
|
|
24
87
|
*/
|
|
25
88
|
export async function launchDashboardServer(options) {
|
|
26
89
|
// 1. Check if SPA assets exist
|
|
27
90
|
const assetsDir = resolveAssetsDir();
|
|
28
91
|
if (!assetsDir) {
|
|
92
|
+
await stopStaleDashboardServer();
|
|
29
93
|
return null;
|
|
30
94
|
}
|
|
31
|
-
// 2.
|
|
32
|
-
const
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
// so the dashboard uses the current version's code (#548)
|
|
36
|
-
const info = readDashboardServerInfo();
|
|
37
|
-
const currentVersion = getCLIVersion();
|
|
38
|
-
if (!info) {
|
|
39
|
-
// PID file disappeared between health check and now (race condition).
|
|
40
|
-
// Fall through to launch a new server.
|
|
41
|
-
}
|
|
42
|
-
else if (info.version && currentVersion !== '0.0.0' && info.version !== currentVersion) {
|
|
43
|
-
console.error(`[STARTUP] Dashboard server version mismatch (running: ${info.version}, current: ${currentVersion}). Restarting...`);
|
|
44
|
-
let killed = false;
|
|
45
|
-
try {
|
|
46
|
-
process.kill(info.pid, 'SIGTERM');
|
|
47
|
-
killed = true;
|
|
48
|
-
}
|
|
49
|
-
catch (err) {
|
|
50
|
-
const code = err.code;
|
|
51
|
-
if (code === 'ESRCH') {
|
|
52
|
-
killed = true; // Already exited
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
console.error(`[STARTUP] Could not kill outdated dashboard (PID ${info.pid}): ${err.message}`);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (killed) {
|
|
59
|
-
removeDashboardServerInfo();
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
// Could not kill old server (e.g. EPERM); return it rather than
|
|
63
|
-
// attempting a doomed spawn on the same port.
|
|
64
|
-
return {
|
|
65
|
-
url: existing.url,
|
|
66
|
-
port: existing.port,
|
|
67
|
-
alreadyRunning: true,
|
|
68
|
-
lastBrowserOpenedAt: info?.lastBrowserOpenedAt,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
// Fall through to launch a new server
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
return {
|
|
75
|
-
url: existing.url,
|
|
76
|
-
port: existing.port,
|
|
77
|
-
alreadyRunning: true,
|
|
78
|
-
lastBrowserOpenedAt: info.lastBrowserOpenedAt,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
}
|
|
95
|
+
// 2. Reuse a running server unless it is from a different CLI version
|
|
96
|
+
const running = await stopStaleDashboardServer();
|
|
97
|
+
if (running)
|
|
98
|
+
return running;
|
|
82
99
|
// 3. Launch as detached child process
|
|
83
100
|
const port = options?.port ?? DEFAULT_PORT;
|
|
84
|
-
|
|
85
|
-
const cliPath = process.argv[1];
|
|
101
|
+
const cliPath = resolveCliEntry(process.argv[1], assetsDir);
|
|
86
102
|
const child = spawn('node', [cliPath, 'dashboard', 'serve', '--port', String(port), '--no-open'], {
|
|
87
103
|
detached: true,
|
|
88
104
|
stdio: 'ignore',
|
|
@@ -212,7 +212,7 @@ export async function startDashboardServer(options) {
|
|
|
212
212
|
// cache after the port is bound, so the startup poller sees us in time.
|
|
213
213
|
const initialDigest = gistSync.stateManager.getState().lastDigest;
|
|
214
214
|
if (!initialDigest) {
|
|
215
|
-
throw new Error('No dashboard data available. Run the daily check first:
|
|
215
|
+
throw new Error('No dashboard data available. Run the daily check first: oss-autopilot daily (or /oss in Claude Code)');
|
|
216
216
|
}
|
|
217
217
|
const cache = new DashboardCache(initialDigest, (failures) => gistSync.withPendingGistWarnings(failures));
|
|
218
218
|
// ── Build cached JSON response ───────────────────────────────────────────
|
|
@@ -6,8 +6,8 @@ interface ServeOptions {
|
|
|
6
6
|
open: boolean;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
* Resolve the SPA assets directory
|
|
10
|
-
*
|
|
9
|
+
* Resolve the SPA assets directory. Tries packages/dashboard/dist/ in a
|
|
10
|
+
* checkout (dev via tsx, or the bundle), then the copy shipped in the npm package.
|
|
11
11
|
*/
|
|
12
12
|
export declare function resolveAssetsDir(): string | null;
|
|
13
13
|
export declare function serveDashboard(options: ServeOptions): Promise<void>;
|
|
@@ -5,8 +5,8 @@ import * as fs from 'node:fs';
|
|
|
5
5
|
import * as path from 'node:path';
|
|
6
6
|
import { getGitHubToken } from '../core/index.js';
|
|
7
7
|
/**
|
|
8
|
-
* Resolve the SPA assets directory
|
|
9
|
-
*
|
|
8
|
+
* Resolve the SPA assets directory. Tries packages/dashboard/dist/ in a
|
|
9
|
+
* checkout (dev via tsx, or the bundle), then the copy shipped in the npm package.
|
|
10
10
|
*/
|
|
11
11
|
export function resolveAssetsDir() {
|
|
12
12
|
// Strategy 1: relative to this source file (works in dev with tsx)
|
|
@@ -19,7 +19,15 @@ export function resolveAssetsDir() {
|
|
|
19
19
|
if (fs.existsSync(path.join(bundlePath, 'index.html'))) {
|
|
20
20
|
return bundlePath;
|
|
21
21
|
}
|
|
22
|
-
// Strategy 3:
|
|
22
|
+
// Strategy 3: assets shipped inside the published package. `prepublishOnly`
|
|
23
|
+
// copies packages/dashboard/dist to dist/dashboard, next to the CLI bundle,
|
|
24
|
+
// because @oss-autopilot/dashboard itself is private and never on npm. Kept
|
|
25
|
+
// after the checkout paths so a working tree serves its own fresh build.
|
|
26
|
+
const packagedPath = path.resolve(__dirname, 'dashboard');
|
|
27
|
+
if (fs.existsSync(path.join(packagedPath, 'index.html'))) {
|
|
28
|
+
return packagedPath;
|
|
29
|
+
}
|
|
30
|
+
// Strategy 4: resolve the dashboard package via require.resolve
|
|
23
31
|
try {
|
|
24
32
|
const dashboardPkgPath = require.resolve('@oss-autopilot/dashboard/package.json');
|
|
25
33
|
const dashboardDist = path.join(path.dirname(dashboardPkgPath), 'dist');
|
|
@@ -39,8 +47,8 @@ export async function serveDashboard(options) {
|
|
|
39
47
|
const assetsDir = resolveAssetsDir();
|
|
40
48
|
if (!assetsDir) {
|
|
41
49
|
console.error('Could not find dashboard SPA assets.');
|
|
42
|
-
console.error('
|
|
43
|
-
console.error('
|
|
50
|
+
console.error('From a git checkout, build them: cd packages/dashboard && pnpm run build');
|
|
51
|
+
console.error('From npm, update to the latest @oss-autopilot/core; older releases did not include them.');
|
|
44
52
|
process.exit(1);
|
|
45
53
|
}
|
|
46
54
|
const token = getGitHubToken();
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
import { execFileSync } from 'node:child_process';
|
|
20
20
|
import * as fs from 'node:fs';
|
|
21
21
|
import { errorMessage, getOctokit, getStateManager, isRateLimitError, maybeCheckpoint, parseGitHubUrl, requireGitHubToken, } from '../core/index.js';
|
|
22
|
+
import { assertAttended } from '../core/errors.js';
|
|
22
23
|
import { warn } from '../core/logger.js';
|
|
23
24
|
import { publishReport, writePreparedSection } from './overnight.js';
|
|
24
25
|
const MODULE = 'overnight-push-prep';
|
|
@@ -153,6 +154,9 @@ function skip(entry, reason, target, ref) {
|
|
|
153
154
|
}
|
|
154
155
|
/** Push every prepared branch of the latest overnight run to `prep/*` on the user's fork. */
|
|
155
156
|
export async function runOvernightPushPrep(options) {
|
|
157
|
+
// A scheduler runs this after the model tick has ended, in its own
|
|
158
|
+
// environment. Inside the tick it must not run at all.
|
|
159
|
+
assertAttended('push prepared branches');
|
|
156
160
|
const sm = getStateManager();
|
|
157
161
|
const last = sm.getLastOvernight();
|
|
158
162
|
if (!last)
|
|
@@ -22,6 +22,7 @@ import * as fs from 'node:fs';
|
|
|
22
22
|
import * as os from 'node:os';
|
|
23
23
|
import * as path from 'node:path';
|
|
24
24
|
import { errorMessage, getStateManager, maybeCheckpoint, parseGitHubUrl, requireGitHubToken } from '../core/index.js';
|
|
25
|
+
import { UNATTENDED_ENV } from '../core/errors.js';
|
|
25
26
|
import { warn } from '../core/logger.js';
|
|
26
27
|
import { getReportsDir } from '../core/paths.js';
|
|
27
28
|
import { detectIssueListPath } from './locate-issue-list.js';
|
|
@@ -449,6 +450,30 @@ export const OVERNIGHT_DISALLOWED_TOOLS = [
|
|
|
449
450
|
'Bash(npm deprecate *)',
|
|
450
451
|
'Bash(pnpm publish)',
|
|
451
452
|
'Bash(pnpm publish *)',
|
|
453
|
+
// Direct shell escapes inside the allowed programs (#1728): `npm exec` IS
|
|
454
|
+
// npx, `pnpm dlx`/`pnpm exec` run arbitrary packages, and `node -e` runs
|
|
455
|
+
// arbitrary JS — each can spawn `git push` and void the push denies above.
|
|
456
|
+
// The residual (a repo's own test scripts run arbitrary code) is documented
|
|
457
|
+
// in commands/oss-overnight.md and cannot be closed by tool rules.
|
|
458
|
+
'Bash(npm exec)',
|
|
459
|
+
'Bash(npm exec *)',
|
|
460
|
+
'Bash(npm x)',
|
|
461
|
+
'Bash(npm x *)',
|
|
462
|
+
'Bash(npm * exec *)',
|
|
463
|
+
'Bash(pnpm dlx *)',
|
|
464
|
+
'Bash(pnpm * dlx *)',
|
|
465
|
+
'Bash(pnpm exec)',
|
|
466
|
+
'Bash(pnpm exec *)',
|
|
467
|
+
'Bash(pnpm * exec *)',
|
|
468
|
+
'Bash(node -e *)',
|
|
469
|
+
'Bash(node --eval *)',
|
|
470
|
+
'Bash(node -p *)',
|
|
471
|
+
'Bash(node -pe *)',
|
|
472
|
+
'Bash(node --print *)',
|
|
473
|
+
// The same escapes after a leading flag (`node --no-warnings -e`,
|
|
474
|
+
// `pnpm --dir x exec`), mirroring the `git * push` deny.
|
|
475
|
+
'Bash(node * -e *)',
|
|
476
|
+
'Bash(node * --eval *)',
|
|
452
477
|
'AskUserQuestion',
|
|
453
478
|
].join(',');
|
|
454
479
|
export const OVERNIGHT_ALLOWED_TOOLS = [
|
|
@@ -527,7 +552,12 @@ export function renderLaunchdPlist(options, logPath, settingsPath) {
|
|
|
527
552
|
' <key>EnvironmentVariables</key>',
|
|
528
553
|
// launchd inherits no shell PATH; include the dir of the node that ran
|
|
529
554
|
// `schedule` so a version-manager node resolves for the CLI and tests.
|
|
530
|
-
|
|
555
|
+
' <dict>',
|
|
556
|
+
` <key>PATH</key><string>${xmlEscape(`${path.dirname(process.execPath)}:/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin`)}</string>`,
|
|
557
|
+
// The CLI's own GitHub-writing commands refuse while this is set (see
|
|
558
|
+
// assertAttended): `Bash(node *)` has to stay allowed, so the gate is in code.
|
|
559
|
+
` <key>${UNATTENDED_ENV}</key><string>1</string>`,
|
|
560
|
+
' </dict>',
|
|
531
561
|
'</dict>',
|
|
532
562
|
'</plist>',
|
|
533
563
|
'',
|
|
@@ -51,9 +51,17 @@ function isCompleted(line) {
|
|
|
51
51
|
return true;
|
|
52
52
|
return false;
|
|
53
53
|
}
|
|
54
|
-
/**
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Extract a score from a sub-bullet line. Accepts `Score 8/10` anywhere in the
|
|
56
|
+
* line, or any bare `N/10` / `N.N/10` inside the first bold span
|
|
57
|
+
* (`**Pursue (7/10)**`, `**Vetted 2026-09-16: 7/10, pursue first.**`) (#1730).
|
|
58
|
+
*
|
|
59
|
+
* `strict` (used by the on-disk prune) accepts only `Score N/10` and the pinned
|
|
60
|
+
* `(N/10)` form, so a date-like `3/10` in a span never deletes an entry.
|
|
61
|
+
*/
|
|
62
|
+
function extractScore(line, strict = false) {
|
|
63
|
+
const bare = strict ? /\((\d+(?:\.\d+)?)\/10\)/ : /(?<![\d.])(\d+(?:\.\d+)?)\/10\b/;
|
|
64
|
+
const match = line.match(/Score\s+(\d+(?:\.\d+)?)\/10/i) ?? firstBoldSpan(line)?.match(bare);
|
|
57
65
|
return match ? parseFloat(match[1]) : undefined;
|
|
58
66
|
}
|
|
59
67
|
/**
|
|
@@ -140,6 +148,20 @@ function isSubBulletDeletable(line) {
|
|
|
140
148
|
function isSubBulletInProgress(line) {
|
|
141
149
|
return spanStartsWithKeyword(line, /^(?:In Progress|Waiting|Wait|Post findings first|Ship now|Viable not urgent|PR OPEN|IMPLEMENTED)(?![\p{L}\p{N}])/iu);
|
|
142
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* Check if a sub-bullet's first bold span says the item is blocked on
|
|
153
|
+
* something outside the user's control (#1730). Runs after the terminal /
|
|
154
|
+
* in-progress checks, so a span that STARTS with `Wait` still lands in
|
|
155
|
+
* `completed` as before; this catches `blocked` / `wait` later in the span.
|
|
156
|
+
*/
|
|
157
|
+
function isSubBulletBlocked(line) {
|
|
158
|
+
const span = firstBoldSpan(line);
|
|
159
|
+
return span !== null && /\b(?:blocked|wait(?:ing|s)?)\b/i.test(span);
|
|
160
|
+
}
|
|
161
|
+
/** A `##` section whose items are vetted but blocked (`## Queued ...`, `## Blocked on ...`) (#1730). */
|
|
162
|
+
function isBlockedSection(heading) {
|
|
163
|
+
return /^Queued\b/i.test(heading) || /\bblocked\b/i.test(heading);
|
|
164
|
+
}
|
|
143
165
|
/** Leading-whitespace width with tabs expanded to two columns. */
|
|
144
166
|
function indentWidth(line) {
|
|
145
167
|
return line.match(/^\s*/)[0].replace(/\t/g, ' ').length;
|
|
@@ -149,19 +171,42 @@ export function parseIssueList(content) {
|
|
|
149
171
|
const lines = content.split('\n');
|
|
150
172
|
const available = [];
|
|
151
173
|
const completed = [];
|
|
174
|
+
const blocked = [];
|
|
152
175
|
let currentTier = 'Uncategorized';
|
|
176
|
+
// Heading level that set currentTier. A `###` under a `##` tier is a
|
|
177
|
+
// sub-group (repo heading, blocker note) and must not clobber the tier (#1730).
|
|
178
|
+
let tierLevel = 0;
|
|
179
|
+
let currentGroup;
|
|
180
|
+
let sectionBlocked = false;
|
|
153
181
|
let lastItem = null;
|
|
154
182
|
// Track which array the last item was placed in so sub-bullets can move it
|
|
155
|
-
let
|
|
183
|
+
let lastBucket = null;
|
|
184
|
+
const moveLastItem = (to) => {
|
|
185
|
+
const idx = lastBucket.indexOf(lastItem);
|
|
186
|
+
if (idx !== -1)
|
|
187
|
+
lastBucket.splice(idx, 1);
|
|
188
|
+
to.push(lastItem);
|
|
189
|
+
lastBucket = to;
|
|
190
|
+
};
|
|
156
191
|
// Indentation of the line that created lastItem — a line is a sub-bullet
|
|
157
192
|
// only when indented deeper than its parent (handles wholly-indented lists
|
|
158
193
|
// whose sibling items share the same indent).
|
|
159
194
|
let lastItemIndent = 0;
|
|
160
195
|
for (const line of lines) {
|
|
161
196
|
// Check for section headings (# or ##)
|
|
162
|
-
const headingMatch = line.match(
|
|
197
|
+
const headingMatch = line.match(/^(#{1,3})\s+(.+)/);
|
|
163
198
|
if (headingMatch) {
|
|
164
|
-
|
|
199
|
+
const level = headingMatch[1].length;
|
|
200
|
+
const text = headingMatch[2].trim();
|
|
201
|
+
if (level === 3 && tierLevel === 2) {
|
|
202
|
+
currentGroup = text;
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
currentTier = text;
|
|
206
|
+
tierLevel = level;
|
|
207
|
+
currentGroup = undefined;
|
|
208
|
+
sectionBlocked = isBlockedSection(text);
|
|
209
|
+
}
|
|
165
210
|
lastItem = null;
|
|
166
211
|
continue;
|
|
167
212
|
}
|
|
@@ -186,15 +231,12 @@ export function parseIssueList(content) {
|
|
|
186
231
|
if (score !== undefined) {
|
|
187
232
|
lastItem.score = score;
|
|
188
233
|
}
|
|
189
|
-
// Check if sub-bullet marks item as terminal or
|
|
190
|
-
if (
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
completed.push(lastItem);
|
|
196
|
-
lastItemInAvailable = false;
|
|
197
|
-
}
|
|
234
|
+
// Check if sub-bullet marks item as terminal/in-progress, or blocked
|
|
235
|
+
if (lastBucket !== completed && (isSubBulletTerminal(line) || isSubBulletInProgress(line))) {
|
|
236
|
+
moveLastItem(completed);
|
|
237
|
+
}
|
|
238
|
+
else if (lastBucket === available && isSubBulletBlocked(line)) {
|
|
239
|
+
moveLastItem(blocked);
|
|
198
240
|
}
|
|
199
241
|
continue;
|
|
200
242
|
}
|
|
@@ -208,16 +250,11 @@ export function parseIssueList(content) {
|
|
|
208
250
|
number: ghUrl.number,
|
|
209
251
|
title: title || `#${ghUrl.number}`,
|
|
210
252
|
tier: currentTier,
|
|
253
|
+
...(currentGroup !== undefined ? { group: currentGroup } : {}),
|
|
211
254
|
url: ghUrl.url,
|
|
212
255
|
};
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
lastItemInAvailable = false;
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
available.push(item);
|
|
219
|
-
lastItemInAvailable = true;
|
|
220
|
-
}
|
|
256
|
+
lastBucket = isCompleted(line) ? completed : sectionBlocked ? blocked : available;
|
|
257
|
+
lastBucket.push(item);
|
|
221
258
|
lastItem = item;
|
|
222
259
|
lastItemIndent = indent;
|
|
223
260
|
}
|
|
@@ -229,32 +266,29 @@ export function parseIssueList(content) {
|
|
|
229
266
|
// `available[]`. Curators add a terminal annotation (`**hold**`,
|
|
230
267
|
// `Done`, etc.) on a later occurrence precisely to override an
|
|
231
268
|
// earlier "pursue" line; the terminal classification wins.
|
|
269
|
+
// - Likewise a URL in `blocked[]` is filtered out of `available[]`,
|
|
270
|
+
// and a URL in `completed[]` out of `blocked[]` (#1730).
|
|
232
271
|
// - Within each bucket, the first occurrence is kept (preserves the
|
|
233
272
|
// parse order and the tier of the original entry).
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
const
|
|
246
|
-
const seenCompleted = new Set();
|
|
247
|
-
for (const item of completed) {
|
|
248
|
-
if (seenCompleted.has(item.url))
|
|
249
|
-
continue;
|
|
250
|
-
seenCompleted.add(item.url);
|
|
251
|
-
dedupedCompleted.push(item);
|
|
252
|
-
}
|
|
273
|
+
const dedupe = (items, ...exclude) => {
|
|
274
|
+
const seen = new Set(exclude.flatMap((bucket) => bucket.map((item) => item.url)));
|
|
275
|
+
return items.filter((item) => {
|
|
276
|
+
if (seen.has(item.url))
|
|
277
|
+
return false;
|
|
278
|
+
seen.add(item.url);
|
|
279
|
+
return true;
|
|
280
|
+
});
|
|
281
|
+
};
|
|
282
|
+
const dedupedCompleted = dedupe(completed);
|
|
283
|
+
const dedupedBlocked = dedupe(blocked, completed);
|
|
284
|
+
const dedupedAvailable = dedupe(available, completed, blocked);
|
|
253
285
|
return {
|
|
254
286
|
available: dedupedAvailable,
|
|
255
287
|
completed: dedupedCompleted,
|
|
288
|
+
blocked: dedupedBlocked,
|
|
256
289
|
availableCount: dedupedAvailable.length,
|
|
257
290
|
completedCount: dedupedCompleted.length,
|
|
291
|
+
blockedCount: dedupedBlocked.length,
|
|
258
292
|
};
|
|
259
293
|
}
|
|
260
294
|
/**
|
|
@@ -304,7 +338,7 @@ export function pruneIssueList(content, minScore = 6) {
|
|
|
304
338
|
if (isSubBulletDeletable(lines[j])) {
|
|
305
339
|
shouldRemove = true;
|
|
306
340
|
}
|
|
307
|
-
const score = extractScore(lines[j]);
|
|
341
|
+
const score = extractScore(lines[j], true);
|
|
308
342
|
if (score !== undefined && score < minScore) {
|
|
309
343
|
shouldRemove = true;
|
|
310
344
|
}
|