@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.
- package/dist/cli-pre-action.js +8 -3
- package/dist/cli-registry.js +428 -27
- package/dist/cli.bundle.cjs +212 -156
- package/dist/commands/check-integration.js +5 -1
- package/dist/commands/cleanup.d.ts +80 -0
- package/dist/commands/cleanup.js +334 -0
- package/dist/commands/comments.d.ts +14 -1
- package/dist/commands/comments.js +17 -5
- package/dist/commands/config.d.ts +2 -0
- package/dist/commands/config.js +63 -6
- package/dist/commands/daily-dismiss-filter.d.ts +7 -0
- package/dist/commands/daily-dismiss-filter.js +17 -1
- package/dist/commands/daily-ledger.d.ts +150 -0
- package/dist/commands/daily-ledger.js +248 -0
- package/dist/commands/daily-recent-prs.d.ts +26 -0
- package/dist/commands/daily-recent-prs.js +55 -0
- package/dist/commands/daily-render.d.ts +2 -1
- package/dist/commands/daily-render.js +4 -1
- package/dist/commands/daily.d.ts +5 -1
- package/dist/commands/daily.js +83 -93
- package/dist/commands/dashboard-cache.d.ts +2 -0
- package/dist/commands/dashboard-cache.js +33 -8
- package/dist/commands/dashboard-data.js +113 -69
- package/dist/commands/dashboard-gist-sync.js +3 -1
- package/dist/commands/dashboard-lifecycle.d.ts +36 -8
- package/dist/commands/dashboard-lifecycle.js +132 -39
- package/dist/commands/dashboard-process.d.ts +49 -1
- package/dist/commands/dashboard-process.js +111 -12
- package/dist/commands/dashboard-server.js +89 -23
- package/dist/commands/detect-formatters.js +1 -0
- package/dist/commands/dismiss.js +11 -7
- package/dist/commands/doctor.d.ts +15 -1
- package/dist/commands/doctor.js +66 -5
- package/dist/commands/draft.d.ts +77 -0
- package/dist/commands/draft.js +218 -0
- package/dist/commands/eval.js +1 -0
- package/dist/commands/fork-prune.d.ts +58 -0
- package/dist/commands/fork-prune.js +247 -0
- package/dist/commands/guidelines.d.ts +69 -2
- package/dist/commands/guidelines.js +158 -14
- package/dist/commands/index.d.ts +29 -4
- package/dist/commands/index.js +20 -3
- package/dist/commands/issue-thread.d.ts +46 -0
- package/dist/commands/issue-thread.js +123 -0
- package/dist/commands/ledger-backfill.d.ts +9 -0
- package/dist/commands/ledger-backfill.js +44 -1
- package/dist/commands/list-mark-done.d.ts +2 -1
- package/dist/commands/list-mark-done.js +3 -1
- package/dist/commands/list-move-tier.d.ts +2 -1
- package/dist/commands/list-move-tier.js +3 -1
- package/dist/commands/local-repos.js +10 -5
- package/dist/commands/locate-issue-list.d.ts +40 -17
- package/dist/commands/locate-issue-list.js +148 -88
- package/dist/commands/move.js +7 -1
- package/dist/commands/overnight-handoff.d.ts +17 -7
- package/dist/commands/overnight-handoff.js +36 -14
- package/dist/commands/overnight-push-prep.d.ts +14 -8
- package/dist/commands/overnight-push-prep.js +107 -35
- package/dist/commands/overnight-tool-rules.d.ts +54 -0
- package/dist/commands/overnight-tool-rules.js +217 -0
- package/dist/commands/overnight.d.ts +5 -6
- package/dist/commands/overnight.js +61 -140
- package/dist/commands/parse-list.js +7 -1
- package/dist/commands/policy.d.ts +90 -0
- package/dist/commands/policy.js +276 -0
- package/dist/commands/pr-create.d.ts +48 -0
- package/dist/commands/pr-create.js +200 -0
- package/dist/commands/pr-preflight.d.ts +69 -0
- package/dist/commands/pr-preflight.js +348 -0
- package/dist/commands/repo-vet.d.ts +9 -0
- package/dist/commands/repo-vet.js +36 -11
- package/dist/commands/scout-bridge.js +18 -8
- package/dist/commands/search.js +7 -0
- package/dist/commands/setup.d.ts +3 -3
- package/dist/commands/setup.js +160 -48
- package/dist/commands/skip-add.js +10 -1
- package/dist/commands/startup.d.ts +12 -3
- package/dist/commands/startup.js +82 -49
- package/dist/commands/state-cmd.d.ts +2 -0
- package/dist/commands/state-cmd.js +5 -1
- package/dist/commands/stats.js +1 -0
- package/dist/commands/status.js +6 -0
- package/dist/commands/strategy.js +1 -0
- package/dist/commands/validation.d.ts +5 -0
- package/dist/commands/validation.js +5 -0
- package/dist/commands/vet-list.d.ts +6 -0
- package/dist/commands/vet-list.js +26 -1
- package/dist/commands/vet.d.ts +20 -0
- package/dist/commands/vet.js +133 -2
- package/dist/commands/work.d.ts +4 -0
- package/dist/commands/work.js +34 -11
- package/dist/core/__fixtures__/prompt-injection-payloads.js +31 -0
- package/dist/core/anti-llm-policy.d.ts +3 -0
- package/dist/core/anti-llm-policy.js +3 -0
- package/dist/core/auth.js +2 -0
- package/dist/core/ci-analysis.d.ts +7 -2
- package/dist/core/ci-analysis.js +76 -21
- package/dist/core/commit-date.d.ts +45 -0
- package/dist/core/commit-date.js +45 -0
- package/dist/core/compliance-score.d.ts +3 -0
- package/dist/core/compliance-score.js +13 -9
- package/dist/core/config-registry.d.ts +27 -2
- package/dist/core/config-registry.js +94 -7
- package/dist/core/contributing.d.ts +2 -3
- package/dist/core/contributing.js +2 -3
- package/dist/core/daily-logic.d.ts +30 -5
- package/dist/core/daily-logic.js +68 -19
- package/dist/core/errors.d.ts +37 -3
- package/dist/core/errors.js +54 -5
- package/dist/core/fork-prune.d.ts +149 -0
- package/dist/core/fork-prune.js +333 -0
- package/dist/core/gist-health.d.ts +15 -3
- package/dist/core/gist-health.js +8 -0
- package/dist/core/gist-state-store.d.ts +24 -4
- package/dist/core/gist-state-store.js +98 -51
- package/dist/core/github-stats.d.ts +110 -16
- package/dist/core/github-stats.js +295 -110
- package/dist/core/http-cache.d.ts +0 -10
- package/dist/core/http-cache.js +0 -19
- package/dist/core/index.d.ts +13 -6
- package/dist/core/index.js +16 -6
- package/dist/core/issue-conversation.d.ts +8 -2
- package/dist/core/issue-conversation.js +31 -12
- package/dist/core/local-config.d.ts +95 -0
- package/dist/core/local-config.js +270 -0
- package/dist/core/merged-pr-notes.d.ts +2 -2
- package/dist/core/pacing.d.ts +41 -0
- package/dist/core/pacing.js +115 -0
- package/dist/core/pagination.d.ts +55 -0
- package/dist/core/pagination.js +59 -0
- package/dist/core/paths.d.ts +7 -0
- package/dist/core/paths.js +9 -0
- package/dist/core/pr-assembly.d.ts +2 -0
- package/dist/core/pr-assembly.js +6 -2
- package/dist/core/pr-graphql.d.ts +53 -4
- package/dist/core/pr-graphql.js +87 -14
- package/dist/core/pr-monitor.d.ts +35 -12
- package/dist/core/pr-monitor.js +110 -26
- package/dist/core/pr-preflight.d.ts +154 -0
- package/dist/core/pr-preflight.js +753 -0
- package/dist/core/pr-quality-rubric.d.ts +0 -6
- package/dist/core/pr-quality-rubric.js +0 -8
- package/dist/core/pr-template.d.ts +2 -0
- package/dist/core/pr-template.js +5 -1
- package/dist/core/prose-script.d.ts +72 -0
- package/dist/core/prose-script.js +223 -0
- package/dist/core/repo-policy.d.ts +111 -0
- package/dist/core/repo-policy.js +428 -0
- package/dist/core/repo-score-manager.d.ts +66 -0
- package/dist/core/repo-score-manager.js +140 -1
- package/dist/core/review-analysis.d.ts +49 -21
- package/dist/core/review-analysis.js +89 -15
- package/dist/core/reviewed-prs-fetch.js +11 -29
- package/dist/core/reviewed-prs.js +8 -15
- package/dist/core/stale-data.d.ts +78 -0
- package/dist/core/stale-data.js +153 -0
- package/dist/core/state-persistence.d.ts +62 -27
- package/dist/core/state-persistence.js +338 -119
- package/dist/core/state-schema.d.ts +152 -210
- package/dist/core/state-schema.js +232 -80
- package/dist/core/state.d.ts +81 -8
- package/dist/core/state.js +239 -46
- package/dist/core/status-determination.js +32 -12
- package/dist/core/strategy.js +3 -1
- package/dist/core/types.d.ts +22 -1
- package/dist/core/types.js +1 -0
- package/dist/core/untrusted-content.d.ts +30 -11
- package/dist/core/untrusted-content.js +95 -42
- package/dist/core/urls.d.ts +33 -0
- package/dist/core/urls.js +94 -0
- package/dist/dashboard/assets/chart-panel-B-nLVgzQ.js +3 -0
- package/dist/dashboard/assets/index-5IvMGokL.js +55 -0
- package/dist/dashboard/index.html +1 -1
- package/dist/formatters/json.d.ts +432 -10
- package/dist/formatters/json.js +156 -1
- package/package.json +6 -6
- package/dist/core/ci-enforced-tools.d.ts +0 -35
- package/dist/core/ci-enforced-tools.js +0 -109
- package/dist/core/comment-decision.d.ts +0 -79
- package/dist/core/comment-decision.js +0 -82
- package/dist/core/extraction-categories.d.ts +0 -55
- package/dist/core/extraction-categories.js +0 -108
- package/dist/core/follow-up-history.d.ts +0 -40
- package/dist/core/follow-up-history.js +0 -71
- package/dist/core/issue-effort.d.ts +0 -29
- package/dist/core/issue-effort.js +0 -47
- package/dist/core/maintainer-hints.d.ts +0 -23
- package/dist/core/maintainer-hints.js +0 -36
- package/dist/core/workflow-state.d.ts +0 -56
- package/dist/core/workflow-state.js +0 -101
- package/dist/dashboard/assets/chart-panel-DPKNBUts.js +0 -3
- package/dist/dashboard/assets/index-B25bZOYX.js +0 -55
package/dist/cli-registry.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { errorMessage, resolveErrorCode } from './core/errors.js';
|
|
12
12
|
import { outputJson, outputJsonError, outputJsonValidated } from './formatters/json.js';
|
|
13
|
+
import { pacingLines } from './core/pacing.js';
|
|
13
14
|
/**
|
|
14
15
|
* Shared error handler for CLI action catch blocks. Exported so cli.ts can
|
|
15
16
|
* route preAction-hook rejections (corrupt Gist, missing gist scope, rate
|
|
@@ -45,20 +46,25 @@ export function handleCommandError(err, json) {
|
|
|
45
46
|
* calls `outputJsonValidated` directly — so a drifted shape throws at
|
|
46
47
|
* the `--json` boundary instead of silently shipping (#1105).
|
|
47
48
|
* Commands: manifest, daily, status, strategy, search, features,
|
|
48
|
-
* verify-issue, skip-add, list-move-tier, list-mark-done,
|
|
49
|
+
* verify-issue, issue-thread, skip-add, list-move-tier, list-mark-done,
|
|
49
50
|
* compliance-score, post, claim, config, init, setup, checkSetup,
|
|
50
51
|
* parse-issue-list, orphan-files, doctor, local-repos, move,
|
|
51
|
-
* pr-template, repo-cap, repo-vet, detect-formatters, work (claim/finish/release/list)
|
|
52
|
+
* pr-template, repo-cap, pr-preflight, repo-vet, detect-formatters, work (claim/finish/release/list),
|
|
53
|
+
* dashboard launch,
|
|
54
|
+
* policy (get/set).
|
|
55
|
+
* `pr-create` checks its schema itself after the PR exists and only warns
|
|
56
|
+
* on a mismatch, so a drift never reports a created PR as failed (#2085).
|
|
52
57
|
*
|
|
53
58
|
* 2. **Goldens-only**: no Zod schema exists; the command returns a TS
|
|
54
59
|
* interface and its `*.contract.test.ts` golden snapshot is the only
|
|
55
60
|
* shape gate. Nothing fires at runtime if the producer drifts after
|
|
56
61
|
* the goldens were last updated.
|
|
57
62
|
* Commands: state (show/sync/unlink), vet, vet-list, ledger-backfill, eval, track, comments,
|
|
58
|
-
* startup, dismiss, undismiss, stats, and the
|
|
59
|
-
* guidelines subcommands (list/view/store/reset/fetch-corpus/mark-extracted).
|
|
63
|
+
* startup, dismiss, undismiss, stats, policy reset, and the
|
|
64
|
+
* guidelines subcommands (list/view/store/reset/fetch-corpus/mark-extracted/mark-proposed).
|
|
60
65
|
*
|
|
61
66
|
* (`dashboard serve` is exempt: it has no `--json` mode.)
|
|
67
|
+
* (`draft path` / `draft show` have neither: their shapes are pinned by `commands/draft.test.ts`.)
|
|
62
68
|
*
|
|
63
69
|
* To promote a command to tier 1: export a Zod schema from
|
|
64
70
|
* `formatters/json.ts`, assert it in the command's contract test alongside
|
|
@@ -102,6 +108,10 @@ function printRepos(repos) {
|
|
|
102
108
|
console.log(` ${info.path}`);
|
|
103
109
|
}
|
|
104
110
|
}
|
|
111
|
+
/** Print a deprecation note on stderr for commands kept only for semver (#1948); stdout and `--json` are untouched. */
|
|
112
|
+
function warnDeprecatedCommand(name) {
|
|
113
|
+
console.error(`Warning: \`${name}\` is deprecated and will be removed in the next major version.`);
|
|
114
|
+
}
|
|
105
115
|
export const commands = [
|
|
106
116
|
// ── Manifest (#1190) ───────────────────────────────────────────────────
|
|
107
117
|
// Exposes the registered commands for CLI/plugin contract checks —
|
|
@@ -193,6 +203,9 @@ export const commands = [
|
|
|
193
203
|
console.log(`Closed PRs: ${data.stats.closedPRs}`);
|
|
194
204
|
console.log(`Merge Rate: ${data.stats.mergeRate}`);
|
|
195
205
|
console.log(`Needs Response: ${data.stats.needsResponse}`);
|
|
206
|
+
const pacing = pacingLines(data.pacing ?? null);
|
|
207
|
+
for (const line of pacing)
|
|
208
|
+
console.log(`Pacing: ${line}`);
|
|
196
209
|
if (data.offline) {
|
|
197
210
|
console.log(`\nLast Updated: ${data.lastUpdated || 'Never'}`);
|
|
198
211
|
console.log('(Status reads from local state — no GitHub API calls)');
|
|
@@ -292,7 +305,10 @@ export const commands = [
|
|
|
292
305
|
else {
|
|
293
306
|
// Default: --show
|
|
294
307
|
await executeAction(options, async () => (await import('./commands/state-cmd.js')).runStateShow({ validate: !!options.validate }), (data) => {
|
|
295
|
-
console.log(`\nPersistence: ${data.persistence}`
|
|
308
|
+
console.log(`\nPersistence: ${data.persistence}` +
|
|
309
|
+
(data.storedPersistence
|
|
310
|
+
? ` (stored mode '${data.storedPersistence}' is from a newer release; upgrade oss-autopilot to sync)`
|
|
311
|
+
: ''));
|
|
296
312
|
if (data.gistId)
|
|
297
313
|
console.log(`Gist ID: ${data.gistId}`);
|
|
298
314
|
if (data.gistDegraded)
|
|
@@ -530,6 +546,34 @@ export const commands = [
|
|
|
530
546
|
});
|
|
531
547
|
},
|
|
532
548
|
},
|
|
549
|
+
// ── Issue Thread ───────────────────────────────────────────────────────
|
|
550
|
+
{
|
|
551
|
+
name: 'issue-thread',
|
|
552
|
+
register(program) {
|
|
553
|
+
program
|
|
554
|
+
.command('issue-thread <issue-url>')
|
|
555
|
+
.description('Read an issue title, body and comments, each fenced as untrusted content (#1932)')
|
|
556
|
+
.option('--json', 'Output as JSON')
|
|
557
|
+
.action(async (issueUrl, options) => {
|
|
558
|
+
const { IssueThreadOutputSchema } = await import('./formatters/json.js');
|
|
559
|
+
const { runIssueThread, fenceIssueThreadTitle } = await import('./commands/issue-thread.js');
|
|
560
|
+
await executeAction(options, async () => fenceIssueThreadTitle(await runIssueThread({ issueUrl })), (data) => {
|
|
561
|
+
// Fences stay on in text mode: an agent that drops --json must
|
|
562
|
+
// still get stranger-written text inside its fence.
|
|
563
|
+
console.log(`\n${data.owner}/${data.repo}#${data.number} [${data.state}]: ${data.title}`);
|
|
564
|
+
console.log(`\n${data.body}`);
|
|
565
|
+
for (const comment of data.comments) {
|
|
566
|
+
console.log(`\n${comment.createdAt}\n${comment.body}`);
|
|
567
|
+
}
|
|
568
|
+
if (!data.warnings)
|
|
569
|
+
return;
|
|
570
|
+
for (const warning of data.warnings) {
|
|
571
|
+
console.log(`\nWarning: ${warning.message}`);
|
|
572
|
+
}
|
|
573
|
+
}, IssueThreadOutputSchema);
|
|
574
|
+
});
|
|
575
|
+
},
|
|
576
|
+
},
|
|
533
577
|
// ── Vet List ──────────────────────────────────────────────────────────
|
|
534
578
|
{
|
|
535
579
|
name: 'vet-list',
|
|
@@ -654,7 +698,7 @@ export const commands = [
|
|
|
654
698
|
.command('list-move-tier <issue-url>')
|
|
655
699
|
.description('Move an issue between Pursue / Maybe / Skip sections of a curated list (#1107)')
|
|
656
700
|
.requiredOption('--tier <tier>', 'Target tier: pursue, maybe, or skip')
|
|
657
|
-
.
|
|
701
|
+
.option('--list-path <file>', 'Path to the markdown issue list (defaults to the configured issueListPath)')
|
|
658
702
|
.option('--json', 'Output as JSON')
|
|
659
703
|
.action(async (issueUrl, options) => {
|
|
660
704
|
const { ListMoveTierOutputSchema } = await import('./formatters/json.js');
|
|
@@ -693,7 +737,7 @@ export const commands = [
|
|
|
693
737
|
.description('Mark an issue line in a curated list as done with strikethrough + Done sub-bullet (#1299)')
|
|
694
738
|
.requiredOption('--pr-url <url>', 'PR URL to record on the Done sub-bullet')
|
|
695
739
|
.requiredOption('--pr-status <text>', 'Trailing status, e.g. "merged" or "CI passing"')
|
|
696
|
-
.
|
|
740
|
+
.option('--list-path <file>', 'Path to the markdown issue list (defaults to the configured issueListPath)')
|
|
697
741
|
.option('--json', 'Output as JSON')
|
|
698
742
|
.action(async (issueUrl, options) => {
|
|
699
743
|
const { ListMarkDoneOutputSchema } = await import('./formatters/json.js');
|
|
@@ -772,8 +816,13 @@ export const commands = [
|
|
|
772
816
|
.command('comments <pr-url>')
|
|
773
817
|
.description('Show all comments on a PR')
|
|
774
818
|
.option('--bots', 'Include bot comments')
|
|
819
|
+
.option('--include-own', 'Include your own comments and reviews')
|
|
775
820
|
.option('--json', 'Output as JSON')
|
|
776
|
-
.action((prUrl, options) => executeAction(options, async () => (await import('./commands/comments.js')).runComments({
|
|
821
|
+
.action((prUrl, options) => executeAction(options, async () => (await import('./commands/comments.js')).runComments({
|
|
822
|
+
prUrl,
|
|
823
|
+
showBots: options.bots,
|
|
824
|
+
includeOwn: options.includeOwn,
|
|
825
|
+
}), async (data) => {
|
|
777
826
|
const { formatRelativeTime } = await import('./core/dates.js');
|
|
778
827
|
// Bodies arrive `<github-content>`-fenced for agent consumers
|
|
779
828
|
// (#1372); unwrap for human terminal display.
|
|
@@ -831,25 +880,25 @@ export const commands = [
|
|
|
831
880
|
.command('post <url> [message...]')
|
|
832
881
|
.description('Post a comment to a PR or issue')
|
|
833
882
|
.option('--stdin', 'Read message from stdin')
|
|
883
|
+
.option('--body-file <path>', BODY_FILE_HELP)
|
|
884
|
+
.option('--expect-sha256 <hex>', EXPECT_SHA256_HELP)
|
|
885
|
+
.option('--allow-script-mismatch', ALLOW_SCRIPT_MISMATCH_HELP)
|
|
834
886
|
.option('--json', 'Output as JSON')
|
|
835
887
|
.action(async (url, messageParts, options) => {
|
|
836
888
|
const { PostOutputSchema } = await import('./formatters/json.js');
|
|
837
889
|
await executeAction(options, async () => {
|
|
838
|
-
|
|
839
|
-
if (options.stdin) {
|
|
840
|
-
const chunks = [];
|
|
841
|
-
for await (const chunk of process.stdin) {
|
|
842
|
-
chunks.push(chunk);
|
|
843
|
-
}
|
|
844
|
-
message = Buffer.concat(chunks).toString('utf8').trim();
|
|
845
|
-
}
|
|
846
|
-
else {
|
|
847
|
-
message = messageParts.join(' ');
|
|
848
|
-
}
|
|
890
|
+
const message = await readMessage(options, messageParts);
|
|
849
891
|
const { runPost } = await import('./commands/comments.js');
|
|
850
|
-
return runPost({
|
|
892
|
+
return runPost({
|
|
893
|
+
url,
|
|
894
|
+
message,
|
|
895
|
+
expectSha256: options.expectSha256,
|
|
896
|
+
allowScriptMismatch: options.allowScriptMismatch,
|
|
897
|
+
});
|
|
851
898
|
}, (data) => {
|
|
852
899
|
console.log(`Comment posted: ${data.commentUrl}`);
|
|
900
|
+
if (data.scriptMismatchWarning)
|
|
901
|
+
console.log(`Warning: ${data.scriptMismatchWarning}`);
|
|
853
902
|
}, PostOutputSchema);
|
|
854
903
|
});
|
|
855
904
|
},
|
|
@@ -861,15 +910,26 @@ export const commands = [
|
|
|
861
910
|
program
|
|
862
911
|
.command('claim <issue-url> [message...]')
|
|
863
912
|
.description('Claim an issue by posting a comment')
|
|
913
|
+
.option('--body-file <path>', BODY_FILE_HELP)
|
|
914
|
+
.option('--expect-sha256 <hex>', EXPECT_SHA256_HELP)
|
|
915
|
+
.option('--allow-script-mismatch', ALLOW_SCRIPT_MISMATCH_HELP)
|
|
864
916
|
.option('--json', 'Output as JSON')
|
|
865
917
|
.action(async (issueUrl, messageParts, options) => {
|
|
866
918
|
const { ClaimOutputSchema } = await import('./formatters/json.js');
|
|
867
919
|
await executeAction(options, async () => {
|
|
868
920
|
const { runClaim } = await import('./commands/comments.js');
|
|
869
|
-
|
|
870
|
-
|
|
921
|
+
// No words and no file means the default claim message.
|
|
922
|
+
const message = (await readMessage(options, messageParts)) || undefined;
|
|
923
|
+
return runClaim({
|
|
924
|
+
issueUrl,
|
|
925
|
+
message,
|
|
926
|
+
expectSha256: options.expectSha256,
|
|
927
|
+
allowScriptMismatch: options.allowScriptMismatch,
|
|
928
|
+
});
|
|
871
929
|
}, (data) => {
|
|
872
930
|
console.log(`Issue claimed: ${data.commentUrl}`);
|
|
931
|
+
if (data.scriptMismatchWarning)
|
|
932
|
+
console.log(`Warning: ${data.scriptMismatchWarning}`);
|
|
873
933
|
}, ClaimOutputSchema);
|
|
874
934
|
});
|
|
875
935
|
},
|
|
@@ -893,6 +953,7 @@ export const commands = [
|
|
|
893
953
|
}), (data) => {
|
|
894
954
|
if ('keys' in data) {
|
|
895
955
|
console.log('\nConfig keys\n');
|
|
956
|
+
console.log(' `config <key> <value>` sets every key below except (auto); [setup] and [both] keys also work with `setup --set key=value`.\n');
|
|
896
957
|
for (const def of data.keys) {
|
|
897
958
|
const flag = def.settableVia === 'auto' ? '(auto)' : `[${def.settableVia}]`;
|
|
898
959
|
console.log(` ${def.key.padEnd(28)} ${flag.padEnd(10)} ${def.description}`);
|
|
@@ -906,6 +967,10 @@ export const commands = [
|
|
|
906
967
|
}
|
|
907
968
|
else {
|
|
908
969
|
console.log(`Set ${data.key} to: ${data.value}`);
|
|
970
|
+
if (data.warnings) {
|
|
971
|
+
for (const w of data.warnings)
|
|
972
|
+
console.warn(w);
|
|
973
|
+
}
|
|
909
974
|
}
|
|
910
975
|
}, ConfigCommandOutputSchema);
|
|
911
976
|
});
|
|
@@ -1042,6 +1107,23 @@ export const commands = [
|
|
|
1042
1107
|
handleCommandError(err);
|
|
1043
1108
|
}
|
|
1044
1109
|
});
|
|
1110
|
+
dashboardCmd
|
|
1111
|
+
.command('launch')
|
|
1112
|
+
.description('Start the dashboard server in the background, or reuse the running one')
|
|
1113
|
+
.option('--port <port>', 'Port to try first', '3000')
|
|
1114
|
+
.option('--json', 'Output as JSON')
|
|
1115
|
+
.action(async (options) => {
|
|
1116
|
+
const port = Number(options.port);
|
|
1117
|
+
if (!Number.isSafeInteger(port) || port < 1 || port > 65_535) {
|
|
1118
|
+
handleCommandError(new Error(`Invalid port number: "${options.port}". Must be an integer between 1 and 65535.`), options.json);
|
|
1119
|
+
}
|
|
1120
|
+
const { DashboardLaunchOutputSchema } = await import('./formatters/json.js');
|
|
1121
|
+
const { runDashboardLaunch } = await import('./commands/dashboard-lifecycle.js');
|
|
1122
|
+
await executeAction(options, () => runDashboardLaunch({ port }), (data) => {
|
|
1123
|
+
const note = data.status === 'already_running' ? ' (already running)' : '';
|
|
1124
|
+
console.log(`Dashboard: ${data.url}${note}`);
|
|
1125
|
+
}, DashboardLaunchOutputSchema);
|
|
1126
|
+
});
|
|
1045
1127
|
},
|
|
1046
1128
|
},
|
|
1047
1129
|
// ── Parse Issue List ───────────────────────────────────────────────────
|
|
@@ -1090,10 +1172,11 @@ export const commands = [
|
|
|
1090
1172
|
program
|
|
1091
1173
|
.command('orphan-files')
|
|
1092
1174
|
.alias('check-integration')
|
|
1093
|
-
.description('Detect new files on this branch that no other file references')
|
|
1175
|
+
.description('(deprecated) Detect new files on this branch that no other file references')
|
|
1094
1176
|
.option('--base <branch>', 'Base branch to compare against', 'main')
|
|
1095
1177
|
.option('--json', 'Output as JSON')
|
|
1096
1178
|
.action(async (options) => {
|
|
1179
|
+
warnDeprecatedCommand('orphan-files');
|
|
1097
1180
|
const { CheckIntegrationOutputSchema } = await import('./formatters/json.js');
|
|
1098
1181
|
await executeAction(options, async () => (await import('./commands/check-integration.js')).runCheckIntegration({ base: options.base }), (data) => {
|
|
1099
1182
|
if (data.newFiles.length === 0) {
|
|
@@ -1144,6 +1227,29 @@ export const commands = [
|
|
|
1144
1227
|
});
|
|
1145
1228
|
},
|
|
1146
1229
|
},
|
|
1230
|
+
// ── Cleanup (#1956) ────────────────────────────────────────────────────
|
|
1231
|
+
{
|
|
1232
|
+
name: 'cleanup',
|
|
1233
|
+
localOnly: true,
|
|
1234
|
+
register(program) {
|
|
1235
|
+
program
|
|
1236
|
+
.command('cleanup')
|
|
1237
|
+
.description('List stale overnight worktrees and rejected state copies; --apply removes the safe ones')
|
|
1238
|
+
.option('--apply', 'Remove what the dry run lists (clean, pushed, idle worktrees only)')
|
|
1239
|
+
.option('--json', 'Output as JSON')
|
|
1240
|
+
.action(async (options) => {
|
|
1241
|
+
const { runCleanup, printCleanup } = await import('./commands/cleanup.js');
|
|
1242
|
+
const run = () => {
|
|
1243
|
+
const data = runCleanup({ apply: options.apply === true });
|
|
1244
|
+
// A scheduler or a script only sees the exit code; the output still prints in full.
|
|
1245
|
+
if (data.errors.length > 0)
|
|
1246
|
+
process.exitCode = 1;
|
|
1247
|
+
return Promise.resolve(data);
|
|
1248
|
+
};
|
|
1249
|
+
await executeAction(options, run, printCleanup);
|
|
1250
|
+
});
|
|
1251
|
+
},
|
|
1252
|
+
},
|
|
1147
1253
|
// ── Local Repos ────────────────────────────────────────────────────────
|
|
1148
1254
|
{
|
|
1149
1255
|
name: 'local-repos',
|
|
@@ -1346,6 +1452,7 @@ export const commands = [
|
|
|
1346
1452
|
.description('Drop the claim on a URL, or every claim a session holds (--session, optionally --kind)')
|
|
1347
1453
|
.option('--session <name>', 'Release every claim this session holds')
|
|
1348
1454
|
.option('--kind <kind>', 'With --session: only claims of this kind (implementation or pr)')
|
|
1455
|
+
.option('--pr <url>', 'Record a PR just opened, for the pacing caps (maxNewPrsPerDay, maxNewForksPerDay)')
|
|
1349
1456
|
.option('--json', 'Output as JSON')
|
|
1350
1457
|
.action(async (url, options) => {
|
|
1351
1458
|
const { WorkReleaseOutputSchema } = await import('./formatters/json.js');
|
|
@@ -1354,7 +1461,10 @@ export const commands = [
|
|
|
1354
1461
|
url,
|
|
1355
1462
|
session: options.session,
|
|
1356
1463
|
kind: options.kind,
|
|
1464
|
+
pr: options.pr,
|
|
1357
1465
|
}), (data) => {
|
|
1466
|
+
if (data.recordedPR)
|
|
1467
|
+
console.log(`Recorded new PR ${data.recordedPR} for the pacing caps.`);
|
|
1358
1468
|
const lines = data.released.map((u) => ' ' + u).join('\n');
|
|
1359
1469
|
console.log(data.released.length === 0
|
|
1360
1470
|
? 'No live claims matched; nothing released.'
|
|
@@ -1435,6 +1545,123 @@ export const commands = [
|
|
|
1435
1545
|
});
|
|
1436
1546
|
},
|
|
1437
1547
|
},
|
|
1548
|
+
// ── Fork Prune (#1912) ───────────────────────────────────────────────
|
|
1549
|
+
{
|
|
1550
|
+
name: 'fork-prune',
|
|
1551
|
+
register(program) {
|
|
1552
|
+
program
|
|
1553
|
+
.command('fork-prune')
|
|
1554
|
+
.description('List your forks that back no open PR and hold no unmerged work of yours (dry run); --apply deletes exactly the set a dry run printed')
|
|
1555
|
+
.option('--apply', 'Delete the prunable forks. Needs --expect from a dry run and the delete_repo token scope; refused when the set changed since that dry run, and each fork is re-checked right before its delete')
|
|
1556
|
+
.option('--expect <digest>', 'The setDigest a dry run printed: apply refuses unless the prunable set still matches it')
|
|
1557
|
+
.option('--json', 'Output as JSON')
|
|
1558
|
+
.action(async (options) => {
|
|
1559
|
+
const { ForkPruneOutputSchema } = await import('./formatters/json.js');
|
|
1560
|
+
const { runForkPrune, printForkPrune } = await import('./commands/fork-prune.js');
|
|
1561
|
+
const run = async () => {
|
|
1562
|
+
const data = await runForkPrune({
|
|
1563
|
+
apply: options.apply === true,
|
|
1564
|
+
expect: options.expect,
|
|
1565
|
+
// Text mode prints each delete as it happens; --json keeps the single envelope.
|
|
1566
|
+
...(!options.json && { onDeleted: (repo) => console.log(`Deleted ${repo}`) }),
|
|
1567
|
+
});
|
|
1568
|
+
// A stopped apply (a delete refused) still prints what it did, then fails the command.
|
|
1569
|
+
if (data.error)
|
|
1570
|
+
process.exitCode = 1;
|
|
1571
|
+
return data;
|
|
1572
|
+
};
|
|
1573
|
+
await executeAction(options, run, printForkPrune, ForkPruneOutputSchema);
|
|
1574
|
+
});
|
|
1575
|
+
},
|
|
1576
|
+
},
|
|
1577
|
+
// ── PR Preflight (#1952) ─────────────────────────────────────────────
|
|
1578
|
+
{
|
|
1579
|
+
name: 'pr-preflight',
|
|
1580
|
+
// Skips the auth gate, not GitHub: without a token the network checks come back `skipped`.
|
|
1581
|
+
localOnly: true,
|
|
1582
|
+
register(program) {
|
|
1583
|
+
program
|
|
1584
|
+
.command('pr-preflight [issue]')
|
|
1585
|
+
.description('Gate before opening a PR: upstream drift, base and head branch, working tree, competing work on the issue, repo cap')
|
|
1586
|
+
.option('--dir <path>', 'Local clone or worktree to check (default: current directory)')
|
|
1587
|
+
.option('--base <branch>', 'Branch the PR will target (default: the upstream default branch)')
|
|
1588
|
+
.option('--fetch', 'Fetch the upstream target branch first instead of reporting a stale ref')
|
|
1589
|
+
.option('--local', 'Skip every GitHub read: local checks and numbers only')
|
|
1590
|
+
.option('--body-file <path>', 'Staged PR body (a file in the draft directory) to check for a description and the disclosure rule')
|
|
1591
|
+
.option('--title-file <path>', 'Staged PR title (a file in the draft directory) to check for a WIP marker')
|
|
1592
|
+
.option('--template-file <path>', "The repo's PR template (a file in the draft directory); body lines copied from it are not a description")
|
|
1593
|
+
.option('--draft', 'The PR will be opened as a draft, which may keep a WIP title')
|
|
1594
|
+
.option('--allow-script-mismatch', ALLOW_SCRIPT_MISMATCH_HELP)
|
|
1595
|
+
.option('--json', 'Output as JSON')
|
|
1596
|
+
.action(async (issue, options) => {
|
|
1597
|
+
const { PrPreflightOutputSchema } = await import('./formatters/json.js');
|
|
1598
|
+
const { runPrPreflight, printPrPreflight } = await import('./commands/pr-preflight.js');
|
|
1599
|
+
const run = async () => {
|
|
1600
|
+
const data = await runPrPreflight({
|
|
1601
|
+
issue,
|
|
1602
|
+
dir: options.dir,
|
|
1603
|
+
base: options.base,
|
|
1604
|
+
fetch: options.fetch === true,
|
|
1605
|
+
local: options.local === true,
|
|
1606
|
+
bodyFile: options.bodyFile,
|
|
1607
|
+
titleFile: options.titleFile,
|
|
1608
|
+
templateFile: options.templateFile,
|
|
1609
|
+
draft: options.draft === true,
|
|
1610
|
+
allowScriptMismatch: options.allowScriptMismatch === true,
|
|
1611
|
+
});
|
|
1612
|
+
// A caller that only sees the exit code still stops on a failed gate; the output prints in full.
|
|
1613
|
+
if (data.verdict === 'fail')
|
|
1614
|
+
process.exitCode = 1;
|
|
1615
|
+
return data;
|
|
1616
|
+
};
|
|
1617
|
+
await executeAction(options, run, printPrPreflight, PrPreflightOutputSchema);
|
|
1618
|
+
});
|
|
1619
|
+
},
|
|
1620
|
+
},
|
|
1621
|
+
// ── PR Create (#2085) ───────────────────────────────────────────────
|
|
1622
|
+
{
|
|
1623
|
+
name: 'pr-create',
|
|
1624
|
+
register(program) {
|
|
1625
|
+
program
|
|
1626
|
+
.command('pr-create [issue]')
|
|
1627
|
+
.description('Run the PR preflight checks on the staged title and body, then open the PR with exactly that title, body and draft value; nothing is created on a failed check')
|
|
1628
|
+
.requiredOption('--head <head>', 'The PR head: <fork-owner>:<branch>, or <branch> in the same repo')
|
|
1629
|
+
.requiredOption('--title-file <path>', 'Staged PR title (a file in the draft directory)')
|
|
1630
|
+
.requiredOption('--body-file <path>', 'Staged PR body (a file in the draft directory)')
|
|
1631
|
+
.option('--template-file <path>', "The repo's PR template (a file in the draft directory); body lines copied from it are not a description")
|
|
1632
|
+
.option('--dir <path>', 'Local clone or worktree with the head branch checked out (default: current directory)')
|
|
1633
|
+
.option('--base <branch>', 'Branch the PR will target (default: the upstream default branch)')
|
|
1634
|
+
.option('--draft', 'Open the PR as a draft, which may keep a WIP title')
|
|
1635
|
+
.option('--allow-script-mismatch', ALLOW_SCRIPT_MISMATCH_HELP)
|
|
1636
|
+
.option('--accept <keys>', 'Comma-separated <id>:<state> keys the user agreed to, as a refusal prints them in brackets (repo-cap:warn, competing-work:at-risk); a competing-work fail only by its exact verdict')
|
|
1637
|
+
.option('--json', 'Output as JSON')
|
|
1638
|
+
.action(async (issue, options) => {
|
|
1639
|
+
const { PrCreateOutputSchema } = await import('./formatters/json.js');
|
|
1640
|
+
const { runPrCreate, printPrCreate } = await import('./commands/pr-create.js');
|
|
1641
|
+
const { readDraft } = await import('./commands/draft.js');
|
|
1642
|
+
const run = async () => runPrCreate({
|
|
1643
|
+
issue,
|
|
1644
|
+
dir: options.dir,
|
|
1645
|
+
base: options.base,
|
|
1646
|
+
head: options.head,
|
|
1647
|
+
title: readDraft(options.titleFile).content,
|
|
1648
|
+
body: readDraft(options.bodyFile).content,
|
|
1649
|
+
template: options.templateFile === undefined ? undefined : readDraft(options.templateFile).content,
|
|
1650
|
+
draft: options.draft === true,
|
|
1651
|
+
allowScriptMismatch: options.allowScriptMismatch === true,
|
|
1652
|
+
accept: options.accept?.split(',').map((id) => id.trim()),
|
|
1653
|
+
});
|
|
1654
|
+
// The PR exists once run() returns, so a shape mismatch warns instead of reporting a failure.
|
|
1655
|
+
const checked = async () => {
|
|
1656
|
+
const data = await run();
|
|
1657
|
+
if (!PrCreateOutputSchema.safeParse(data).success)
|
|
1658
|
+
console.warn('Warning: pr-create output drifted from its schema');
|
|
1659
|
+
return data;
|
|
1660
|
+
};
|
|
1661
|
+
await executeAction(options, checked, printPrCreate);
|
|
1662
|
+
});
|
|
1663
|
+
},
|
|
1664
|
+
},
|
|
1438
1665
|
// ── Repo Vet (#1271) ────────────────────────────────────────────────
|
|
1439
1666
|
{
|
|
1440
1667
|
name: 'repo-vet',
|
|
@@ -1475,10 +1702,11 @@ export const commands = [
|
|
|
1475
1702
|
register(program) {
|
|
1476
1703
|
program
|
|
1477
1704
|
.command('detect-formatters [repo-path]')
|
|
1478
|
-
.description('Detect formatters and linters configured in a repository')
|
|
1705
|
+
.description('(deprecated) Detect formatters and linters configured in a repository')
|
|
1479
1706
|
.option('--ci-log <path>', 'Analyze CI log file for formatting failures')
|
|
1480
1707
|
.option('--json', 'Output as JSON')
|
|
1481
1708
|
.action(async (repoPath, options) => {
|
|
1709
|
+
warnDeprecatedCommand('detect-formatters');
|
|
1482
1710
|
const { DetectFormattersOutputSchema } = await import('./formatters/json.js');
|
|
1483
1711
|
await executeAction(options, async () => (await import('./commands/detect-formatters.js')).runDetectFormatters({
|
|
1484
1712
|
repoPath,
|
|
@@ -1699,6 +1927,44 @@ Load it with:
|
|
|
1699
1927
|
});
|
|
1700
1928
|
},
|
|
1701
1929
|
},
|
|
1930
|
+
// ── Draft files (#1930) ────────────────────────────────────────────────
|
|
1931
|
+
// Local-only and read-only: where to stage text for the user's approval,
|
|
1932
|
+
// and one read that yields both the text to show and the hash to pass back.
|
|
1933
|
+
{
|
|
1934
|
+
name: 'draft',
|
|
1935
|
+
localOnly: true,
|
|
1936
|
+
register(program) {
|
|
1937
|
+
const group = program
|
|
1938
|
+
.command('draft')
|
|
1939
|
+
.description('Stage text for approval in the owner-only draft directory (~/.oss-autopilot/tmp)');
|
|
1940
|
+
group
|
|
1941
|
+
.command('path <name>')
|
|
1942
|
+
.description('Print the path for a draft file name, creating the draft directory (mode 0700) if needed')
|
|
1943
|
+
.option('--json', 'Output as JSON')
|
|
1944
|
+
.action(async (name, options) => {
|
|
1945
|
+
await executeAction(options, async () => {
|
|
1946
|
+
const { runDraftPath } = await import('./commands/draft.js');
|
|
1947
|
+
return runDraftPath({ name });
|
|
1948
|
+
}, (data) => {
|
|
1949
|
+
console.log(data.path);
|
|
1950
|
+
});
|
|
1951
|
+
});
|
|
1952
|
+
group
|
|
1953
|
+
.command('show <file>')
|
|
1954
|
+
.description('Read a draft once and return its text with the SHA-256 to pass back as --expect-sha256')
|
|
1955
|
+
.option('--untrusted', "Wrap the text in the untrusted-content fence (text distilled from other people's writing)")
|
|
1956
|
+
.option('--json', 'Output as JSON')
|
|
1957
|
+
.action(async (file, options) => {
|
|
1958
|
+
await executeAction(options, async () => {
|
|
1959
|
+
const { runDraftShow } = await import('./commands/draft.js');
|
|
1960
|
+
return runDraftShow({ file, untrusted: options.untrusted === true });
|
|
1961
|
+
}, (data) => {
|
|
1962
|
+
console.log(data.content);
|
|
1963
|
+
console.log(`\nsha256: ${data.sha256}`);
|
|
1964
|
+
});
|
|
1965
|
+
});
|
|
1966
|
+
},
|
|
1967
|
+
},
|
|
1702
1968
|
// ── Guidelines (#867) ──────────────────────────────────────────────────
|
|
1703
1969
|
{
|
|
1704
1970
|
name: 'guidelines',
|
|
@@ -1746,14 +2012,19 @@ Load it with:
|
|
|
1746
2012
|
});
|
|
1747
2013
|
group
|
|
1748
2014
|
.command('store')
|
|
1749
|
-
.description('Persist per-repo guidelines (overwrites). Reads markdown content from --content or stdin.')
|
|
2015
|
+
.description('Persist per-repo guidelines (overwrites). Reads markdown content from --from-file, --content or stdin.')
|
|
1750
2016
|
.requiredOption('--repo <owner/repo>', 'Repository identifier')
|
|
2017
|
+
.option('--from-file <path>', 'Read the markdown from a draft file (see `draft path`). Needs --expect-sha256; not with --content.')
|
|
1751
2018
|
.option('--content <markdown>', 'Markdown content. If omitted, reads from stdin.')
|
|
2019
|
+
.option('--expect-sha256 <hex>', EXPECT_SHA256_HELP)
|
|
2020
|
+
.option('--reviewed', 'Assert the user saw this exact text and approved it. Required; refused when unattended.')
|
|
1752
2021
|
.option('--json', 'Output as JSON')
|
|
1753
2022
|
.action(async (options) => {
|
|
1754
2023
|
await executeAction(options, async () => {
|
|
1755
|
-
const content =
|
|
1756
|
-
|
|
2024
|
+
const content = await readGuidelinesContent(options);
|
|
2025
|
+
const { repo, reviewed = false, expectSha256 } = options;
|
|
2026
|
+
const { runGuidelinesStore } = await import('./commands/guidelines.js');
|
|
2027
|
+
return runGuidelinesStore({ repo, content, reviewed, expectSha256 });
|
|
1757
2028
|
}, (data) => {
|
|
1758
2029
|
console.log(`Stored ${data.byteSize} bytes of guidelines for ${data.repo}.`);
|
|
1759
2030
|
});
|
|
@@ -1768,6 +2039,19 @@ Load it with:
|
|
|
1768
2039
|
console.log(`Marked ${data.marked} PR(s) in ${data.repo} as extracted.`);
|
|
1769
2040
|
});
|
|
1770
2041
|
});
|
|
2042
|
+
group
|
|
2043
|
+
.command('mark-proposed')
|
|
2044
|
+
.description('Record that the guideline proposal file for a repo waits for review on this machine, so other machines do not re-extract it (#2041)')
|
|
2045
|
+
.requiredOption('--repo <owner/repo>', 'Repository identifier')
|
|
2046
|
+
.option('--json', 'Output as JSON')
|
|
2047
|
+
.action(async (options) => {
|
|
2048
|
+
await executeAction(options, async () => {
|
|
2049
|
+
const { runMarkProposed } = await import('./commands/guidelines.js');
|
|
2050
|
+
return runMarkProposed({ repo: options.repo });
|
|
2051
|
+
}, (data) => {
|
|
2052
|
+
console.log(`Marked ${data.marked} PR(s) in ${data.repo} as proposed (${data.path}).`);
|
|
2053
|
+
});
|
|
2054
|
+
});
|
|
1771
2055
|
group
|
|
1772
2056
|
.command('reset')
|
|
1773
2057
|
.description('Tombstone the guidelines file for a repo (subsequent reads return null)')
|
|
@@ -1801,7 +2085,124 @@ Load it with:
|
|
|
1801
2085
|
});
|
|
1802
2086
|
},
|
|
1803
2087
|
},
|
|
2088
|
+
// ── Repo contribution policy (#1953) ─────────────────────────────────
|
|
2089
|
+
{
|
|
2090
|
+
name: 'policy',
|
|
2091
|
+
// State only: no GitHub call.
|
|
2092
|
+
localOnly: true,
|
|
2093
|
+
register(program) {
|
|
2094
|
+
const group = program
|
|
2095
|
+
.command('policy')
|
|
2096
|
+
.description('Per-repo contribution policy: AI policy, disclosure, CLA, commit rules, PR gate (#1953)');
|
|
2097
|
+
group
|
|
2098
|
+
.command('get')
|
|
2099
|
+
.description('Show the policy that applies to a repo (aiPolicyBlocklist read as a ban; quoted repo text fenced)')
|
|
2100
|
+
.requiredOption('--repo <owner/repo>', 'Repository identifier')
|
|
2101
|
+
.option('--json', 'Output as JSON')
|
|
2102
|
+
.action(async (options) => {
|
|
2103
|
+
const { PolicyGetOutputSchema } = await import('./formatters/json.js');
|
|
2104
|
+
const { runPolicyGet } = await import('./commands/policy.js');
|
|
2105
|
+
await executeAction(options, () => runPolicyGet({ repo: options.repo }), printPolicy, PolicyGetOutputSchema);
|
|
2106
|
+
});
|
|
2107
|
+
group
|
|
2108
|
+
.command('set')
|
|
2109
|
+
.description('Record the policy you confirmed for a repo (merged over what is stored; refused when unattended)')
|
|
2110
|
+
.requiredOption('--repo <owner/repo>', 'Repository identifier')
|
|
2111
|
+
.option('--ai-policy <value>', 'allowed | disclosure-required | banned | unknown')
|
|
2112
|
+
.option('--disclosure-text <text>', 'The disclosure line to put in the PR body; pr-preflight checks the body for it')
|
|
2113
|
+
.option('--cla <value>', 'none | required | unknown')
|
|
2114
|
+
.option('--pr-gate <value>', 'none | claim-first | maintainer-label | collaborators-only | unknown')
|
|
2115
|
+
.option('--gate-label <name>', 'The issue label a maintainer-label gate waits for; pr-preflight passes only on this exact label ("" clears)')
|
|
2116
|
+
.option('--commit-rules <ids>', 'Comma-separated: conventional-commits, dco-signoff, no-closing-keyword-in-commit ("" clears)')
|
|
2117
|
+
.option('--max-open-ai-prs <n>', 'Open AI-assisted PRs the repo allows at once (0 clears)', Number)
|
|
2118
|
+
.option('--source <text>', 'Where the rule came from, e.g. a maintainer comment (stored as a short quote)')
|
|
2119
|
+
.option('--json', 'Output as JSON')
|
|
2120
|
+
.action(async (options) => {
|
|
2121
|
+
const { PolicyGetOutputSchema } = await import('./formatters/json.js');
|
|
2122
|
+
const { runPolicySet } = await import('./commands/policy.js');
|
|
2123
|
+
// Commander camel-cases --max-open-ai-prs as maxOpenAiPrs.
|
|
2124
|
+
const { maxOpenAiPrs, ...rest } = options;
|
|
2125
|
+
await executeAction(options, () => runPolicySet({ ...rest, maxOpenAiPRs: maxOpenAiPrs }), (data) => {
|
|
2126
|
+
printPolicy(data);
|
|
2127
|
+
const change = { added: ` Added ${data.repo} to`, removed: ` Removed ${data.repo} from` };
|
|
2128
|
+
if (data.blocklistChange)
|
|
2129
|
+
console.log(`${change[data.blocklistChange]} aiPolicyBlocklist.`);
|
|
2130
|
+
if (data.policy?.blocklisted && data.blocklistChange === undefined) {
|
|
2131
|
+
console.log(' Banned by aiPolicyBlocklist; set --ai-policy to another value to take it off the list.');
|
|
2132
|
+
}
|
|
2133
|
+
}, PolicyGetOutputSchema);
|
|
2134
|
+
});
|
|
2135
|
+
group
|
|
2136
|
+
.command('reset')
|
|
2137
|
+
.description('Delete the stored policy for a repo (refused when unattended)')
|
|
2138
|
+
.requiredOption('--repo <owner/repo>', 'Repository identifier')
|
|
2139
|
+
.option('--json', 'Output as JSON')
|
|
2140
|
+
.action(async (options) => {
|
|
2141
|
+
const { runPolicyReset } = await import('./commands/policy.js');
|
|
2142
|
+
await executeAction(options, () => runPolicyReset({ repo: options.repo }), (data) => {
|
|
2143
|
+
console.log(data.deleted ? `Deleted the policy for ${data.repo}.` : `No policy stored for ${data.repo}.`);
|
|
2144
|
+
});
|
|
2145
|
+
});
|
|
2146
|
+
},
|
|
2147
|
+
},
|
|
1804
2148
|
];
|
|
2149
|
+
const BODY_FILE_HELP = 'Read the message from a draft file (see `draft path`). Needs --expect-sha256; not with --stdin or positional words.';
|
|
2150
|
+
const EXPECT_SHA256_HELP = 'Fail before doing anything unless the text hashes to this SHA-256 (from `draft show`)';
|
|
2151
|
+
const ALLOW_SCRIPT_MISMATCH_HELP = "Proceed when the text's script differs from the repo's README and CONTRIBUTING; the mismatch is reported as a warning";
|
|
2152
|
+
/** The message for `post` / `claim`: an approved draft file, stdin (trimmed), or the positional words. */
|
|
2153
|
+
async function readMessage(options, parts) {
|
|
2154
|
+
if (options.bodyFile !== undefined) {
|
|
2155
|
+
const { readApprovedDraft } = await import('./commands/draft.js');
|
|
2156
|
+
return readApprovedDraft({
|
|
2157
|
+
file: options.bodyFile,
|
|
2158
|
+
flag: '--body-file',
|
|
2159
|
+
expectSha256: options.expectSha256,
|
|
2160
|
+
hasOtherInput: options.stdin === true || parts.length > 0,
|
|
2161
|
+
});
|
|
2162
|
+
}
|
|
2163
|
+
if (options.stdin) {
|
|
2164
|
+
const chunks = [];
|
|
2165
|
+
for await (const chunk of process.stdin) {
|
|
2166
|
+
chunks.push(chunk);
|
|
2167
|
+
}
|
|
2168
|
+
return Buffer.concat(chunks).toString('utf8').trim();
|
|
2169
|
+
}
|
|
2170
|
+
return parts.join(' ');
|
|
2171
|
+
}
|
|
2172
|
+
async function readGuidelinesContent(options) {
|
|
2173
|
+
if (options.fromFile !== undefined) {
|
|
2174
|
+
const { readApprovedDraft } = await import('./commands/draft.js');
|
|
2175
|
+
return readApprovedDraft({
|
|
2176
|
+
file: options.fromFile,
|
|
2177
|
+
flag: '--from-file',
|
|
2178
|
+
expectSha256: options.expectSha256,
|
|
2179
|
+
hasOtherInput: options.content !== undefined,
|
|
2180
|
+
});
|
|
2181
|
+
}
|
|
2182
|
+
return options.content ?? readStdin();
|
|
2183
|
+
}
|
|
2184
|
+
/** Text mode for `policy get` / `policy set`. Quoted repo text stays fenced. */
|
|
2185
|
+
function printPolicy(data) {
|
|
2186
|
+
const { policy } = data;
|
|
2187
|
+
if (!policy) {
|
|
2188
|
+
console.log(`No contribution policy recorded for ${data.repo}.`);
|
|
2189
|
+
return;
|
|
2190
|
+
}
|
|
2191
|
+
const reviewed = policy.reviewedByUser ? 'set by you' : 'read from repo docs, not reviewed';
|
|
2192
|
+
console.log(`\n${data.repo} (${reviewed}, ${policy.updatedAt.slice(0, 10)})`);
|
|
2193
|
+
console.log(` AI policy: ${policy.aiPolicy}${policy.blocklisted ? ' (aiPolicyBlocklist)' : ''}`);
|
|
2194
|
+
console.log(` CLA: ${policy.cla} PR gate: ${policy.prGate}`);
|
|
2195
|
+
if (policy.commitRules.length > 0)
|
|
2196
|
+
console.log(` Commit rules: ${policy.commitRules.join(', ')}`);
|
|
2197
|
+
if (policy.maxOpenAiPRs !== undefined)
|
|
2198
|
+
console.log(` Max open AI-assisted PRs: ${policy.maxOpenAiPRs}`);
|
|
2199
|
+
if (policy.disclosureText)
|
|
2200
|
+
console.log(` Disclosure: ${policy.disclosureText}`);
|
|
2201
|
+
if (policy.gateLabel)
|
|
2202
|
+
console.log(` Gate label: ${policy.gateLabel}`);
|
|
2203
|
+
if (policy.sources)
|
|
2204
|
+
console.log(` Sources: ${policy.sources}`);
|
|
2205
|
+
}
|
|
1805
2206
|
/** Read full stdin content. Used when `guidelines store` content isn't passed inline. */
|
|
1806
2207
|
async function readStdin() {
|
|
1807
2208
|
if (process.stdin.isTTY) {
|