@@ -4,14 +4,7 @@ import { existsSync, mkdirSync, readdirSync, readFileSync } from "node:fs";
44import { dirname , join , relative , resolve } from "node:path" ;
55import { fileURLToPath } from "node:url" ;
66import { flushWorkflowActionEvents } from "./action-ledger-runtime.js" ;
7- import {
8- boolArg ,
9- itemNumbersArg ,
10- numberArg ,
11- parseArgs ,
12- stringArg ,
13- type Args ,
14- } from "./clawsweeper-args.js" ;
7+ import { parseArgs , stringArg , type Args } from "./clawsweeper-args.js" ;
158import { dispatchCommand , type CommandHandler } from "./clawsweeper-command-dispatch.js" ;
169import { createDecisionParser } from "./clawsweeper-decision-parser.js" ;
1710import { runText } from "./command.js" ;
@@ -23,7 +16,6 @@ import {
2316 type RepositoryProfile ,
2417} from "./repository-profiles.js" ;
2518import { reviewPullChecksDigestParts } from "./review-checks-digest.js" ;
26- import { coverageTrackedItemIdsFromManifest } from "./review-coverage-manifest.js" ;
2719import {
2820 reviewStructuralQuery ,
2921 reviewStructuralRecordFromGraphql ,
@@ -75,11 +67,9 @@ import {
7567import { createLabelPolicy } from "./clawsweeper-label-policy.js" ;
7668import { createRepositoryLinks } from "./clawsweeper-links.js" ;
7769import { createLocalRangeReviewer } from "./clawsweeper-local-review.js" ;
70+ import { createPlanCommand } from "./clawsweeper-plan-command.js" ;
7871import {
79- DEFAULT_BACKFILL_REVIEW_AGE_MINUTES ,
80- DEFAULT_CODEX_MODEL ,
8172 DEFAULT_REASONING_EFFORT ,
82- DEFAULT_SERVICE_TIER ,
8373 EVENT_GUARDED_OPEN_ACTIONS ,
8474 FRESH_DAYS ,
8575 REVIEW_POLICY_VERSION ,
@@ -1095,57 +1085,15 @@ function securityConcernLocation(concern: SecurityConcern): string {
10951085 return `${ concern . file } ${ concern . line ? `:${ concern . line } ` : "" } ` ;
10961086}
10971087
1098- function planCommand ( args : Args ) : void {
1099- repoFromArgs ( args ) ;
1100- const itemsDir = resolve ( stringArg ( args . items_dir , defaultItemsDir ( ) ) ) ;
1101- const batchSize = numberArg ( args . batch_size , DEFAULT_PLAN_BATCH_SIZE ) ;
1102- const maxPages = numberArg ( args . max_pages , 250 ) ;
1103- const shardCount = numberArg ( args . shard_count , DEFAULT_PLAN_SHARD_COUNT ) ;
1104- const minimumActiveShards = numberArg ( args . min_active_shards , 0 ) ;
1105- const minimumBackfillReviewAgeMs =
1106- numberArg ( args . min_backfill_review_age_minutes , DEFAULT_BACKFILL_REVIEW_AGE_MINUTES ) *
1107- 60 *
1108- 1000 ;
1109- const itemNumbers = itemNumbersArg ( args . item_numbers , args . item_number ) ;
1110- const hasItemNumbersInput = typeof args . item_numbers === "string" && args . item_numbers . trim ( ) ;
1111- const hotIntake = boolArg ( args . hot_intake ) ;
1112- const model = stringArg ( args . codex_model , DEFAULT_CODEX_MODEL ) ;
1113- const reasoningEffort = stringArg ( args . codex_reasoning_effort , DEFAULT_REASONING_EFFORT ) ;
1114- const sandboxMode = stringArg ( args . codex_sandbox , "read-only" ) ;
1115- const serviceTier = stringArg ( args . codex_service_tier , DEFAULT_SERVICE_TIER ) ;
1116- const reviewPolicy = reviewPolicyHash ( { model, reasoningEffort, sandboxMode, serviceTier } ) ;
1117- const coverageManifest = stringArg ( args . coverage_tracked_items_manifest , "" ) . trim ( ) ;
1118- const coverageTrackedItemIds = coverageManifest
1119- ? coverageTrackedItemIdsFromManifest ( resolve ( coverageManifest ) , targetProfile ( ) . slug )
1120- : undefined ;
1121- const planOptions : Parameters < typeof planCandidates > [ 0 ] = {
1122- batchSize,
1123- maxPages,
1124- shardCount,
1125- itemsDir,
1126- reviewPolicy,
1127- minimumActiveShards,
1128- minimumBackfillReviewAgeMs,
1129- ...( coverageTrackedItemIds ? { coverageTrackedItemIds } : { } ) ,
1130- } ;
1131- if ( hasItemNumbersInput || itemNumbers . length > 0 ) planOptions . itemNumbers = itemNumbers ;
1132- if ( hotIntake ) planOptions . hotIntake = true ;
1133- const plan = planCandidates ( planOptions ) ;
1134- console . log (
1135- JSON . stringify (
1136- {
1137- ...plan ,
1138- reviewPolicy,
1139- matrix : plan . shards . map ( ( shard ) => ( {
1140- shard : shard . shard ,
1141- item_numbers : shard . itemNumbers . join ( "," ) || "none" ,
1142- } ) ) ,
1143- } ,
1144- null ,
1145- 2 ,
1146- ) ,
1147- ) ;
1148- }
1088+ const planCommand = createPlanCommand ( {
1089+ defaultBatchSize : DEFAULT_PLAN_BATCH_SIZE ,
1090+ defaultItemsDir,
1091+ defaultShardCount : DEFAULT_PLAN_SHARD_COUNT ,
1092+ planCandidates,
1093+ repoFromArgs,
1094+ reviewPolicyHash,
1095+ targetProfile,
1096+ } ) ;
11491097
11501098// Offline local-range review: synthesize the Item + ItemContext from the local
11511099// git range (merge-base(base, HEAD)..HEAD) so the FULL review (real-behavior
0 commit comments