@oss-autopilot/core 0.44.18 → 0.45.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.
- package/dist/cli-registry.js +78 -0
- package/dist/cli.bundle.cjs +97 -88
- package/dist/cli.bundle.cjs.map +4 -4
- package/dist/commands/dashboard-scripts.js +3 -10
- package/dist/commands/pr-template.d.ts +9 -0
- package/dist/commands/pr-template.js +14 -0
- package/dist/commands/startup.js +18 -3
- package/dist/commands/stats.d.ts +15 -0
- package/dist/commands/stats.js +57 -0
- package/dist/core/github-stats.d.ts +0 -4
- package/dist/core/github-stats.js +1 -9
- package/dist/core/index.d.ts +3 -1
- package/dist/core/index.js +3 -1
- package/dist/core/pr-monitor.js +3 -13
- package/dist/core/pr-template.d.ts +27 -0
- package/dist/core/pr-template.js +65 -0
- package/dist/core/state.d.ts +20 -17
- package/dist/core/state.js +29 -30
- package/dist/core/stats.d.ts +25 -0
- package/dist/core/stats.js +33 -0
- package/dist/core/types.d.ts +2 -2
- package/dist/core/utils.d.ts +16 -0
- package/dist/core/utils.js +45 -0
- package/dist/formatters/json.d.ts +8 -0
- package/package.json +1 -1
package/dist/core/utils.js
CHANGED
|
@@ -444,3 +444,48 @@ export async function getGitHubTokenAsync() {
|
|
|
444
444
|
}
|
|
445
445
|
return null;
|
|
446
446
|
}
|
|
447
|
+
/**
|
|
448
|
+
* GitHub username validation pattern.
|
|
449
|
+
* Usernames must start with an alphanumeric character, can contain hyphens
|
|
450
|
+
* (but not consecutive ones and not at the end), and be 1-39 characters.
|
|
451
|
+
*/
|
|
452
|
+
const GITHUB_USERNAME_RE = /^[a-zA-Z0-9](?:[a-zA-Z0-9]|-(?=[a-zA-Z0-9])){0,38}$/;
|
|
453
|
+
/**
|
|
454
|
+
* Detect the authenticated GitHub username via the `gh` CLI.
|
|
455
|
+
*
|
|
456
|
+
* Runs `gh api user --jq '.login'` asynchronously and validates the result
|
|
457
|
+
* against GitHub's username rules. Never throws — returns `null` on any failure
|
|
458
|
+
* (gh not installed, not authenticated, invalid output, etc.).
|
|
459
|
+
*
|
|
460
|
+
* @returns The GitHub username string, or `null` if detection fails
|
|
461
|
+
*
|
|
462
|
+
* @example
|
|
463
|
+
* const username = await detectGitHubUsername();
|
|
464
|
+
* if (username) {
|
|
465
|
+
* console.log(`Logged in as ${username}`);
|
|
466
|
+
* }
|
|
467
|
+
*/
|
|
468
|
+
export async function detectGitHubUsername() {
|
|
469
|
+
try {
|
|
470
|
+
const login = await new Promise((resolve, reject) => {
|
|
471
|
+
execFile('gh', ['api', 'user', '--jq', '.login'], { encoding: 'utf-8', timeout: 5000 }, (error, stdout) => {
|
|
472
|
+
if (error) {
|
|
473
|
+
reject(error);
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
resolve(stdout.trim());
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
});
|
|
480
|
+
if (login && GITHUB_USERNAME_RE.test(login)) {
|
|
481
|
+
debug(MODULE, `Detected GitHub username: ${login}`);
|
|
482
|
+
return login;
|
|
483
|
+
}
|
|
484
|
+
debug(MODULE, `gh api user returned invalid username: "${login}"`);
|
|
485
|
+
return null;
|
|
486
|
+
}
|
|
487
|
+
catch (err) {
|
|
488
|
+
debug(MODULE, 'detectGitHubUsername failed', err);
|
|
489
|
+
return null;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Provides structured output that can be consumed by scripts and plugins
|
|
4
4
|
*/
|
|
5
5
|
import type { FetchedPR, DailyDigest, AgentState, RepoGroup, CommentedIssue, ShelvedPRRef } from '../core/types.js';
|
|
6
|
+
import type { ContributionStats } from '../core/stats.js';
|
|
6
7
|
import type { PRCheckFailure } from '../core/pr-monitor.js';
|
|
7
8
|
import type { SearchPriority } from '../core/issue-discovery.js';
|
|
8
9
|
export interface JsonOutput<T = unknown> {
|
|
@@ -193,6 +194,8 @@ export interface IssueListInfo {
|
|
|
193
194
|
export interface StartupOutput {
|
|
194
195
|
version: string;
|
|
195
196
|
setupComplete: boolean;
|
|
197
|
+
/** True when username was auto-detected on first run (zero-config). */
|
|
198
|
+
autoDetected?: boolean;
|
|
196
199
|
authError?: string;
|
|
197
200
|
daily?: DailyOutput;
|
|
198
201
|
/** URL of the interactive SPA dashboard server, when running (e.g., "http://localhost:3000") */
|
|
@@ -299,6 +302,11 @@ export interface LocalReposOutput {
|
|
|
299
302
|
cachedAt: string;
|
|
300
303
|
fromCache: boolean;
|
|
301
304
|
}
|
|
305
|
+
/** Output of the stats command */
|
|
306
|
+
export interface StatsOutput extends ContributionStats {
|
|
307
|
+
mergeRateFormatted: string;
|
|
308
|
+
username: string;
|
|
309
|
+
}
|
|
302
310
|
/**
|
|
303
311
|
* Wrap data in a standard JSON output envelope
|
|
304
312
|
*/
|