MCPcopy
hub / github.com/openclaw/clawsweeper / applyDecisionsCommand

Function applyDecisionsCommand

src/clawsweeper.ts:16185–17494  ·  view source on GitHub ↗
(args: Args)

Source from the content-addressed store, hash-verified

16183}
16184
16185async function applyDecisionsCommand(args: Args): Promise<void> {
16186 repoFromArgs(args);
16187 const itemsDir = resolve(stringArg(args.items_dir, defaultItemsDir()));
16188 const closedDir = resolve(stringArg(args.closed_dir, defaultClosedDir()));
16189 const plansDir = resolve(stringArg(args.plans_dir, defaultPlansDir()));
16190 const limit = numberArg(args.limit, 20);
16191 const processedLimit = numberArg(args.processed_limit, Math.max(limit * 2, 50));
16192 const minAgeDays = numberArg(args.min_age_days, 0);
16193 const minAgeMinutes = optionalNumberArg(args.min_age_minutes);
16194 const minAgeMs = minAgeMinutes === undefined ? minAgeDays * DAY_MS : minAgeMinutes * 60 * 1000;
16195 const minAgeDescription =
16196 minAgeMinutes === undefined ? `${minAgeDays} days` : `${minAgeMinutes} minutes`;
16197 const applyKind = applyKindArg(args.apply_kind);
16198 const applyCloseReasons = closeReasonsArg(args.apply_close_reasons);
16199 const staleMinAgeDays = numberArg(args.stale_min_age_days, STALE_INSUFFICIENT_INFO_MIN_AGE_DAYS);
16200 const closeDelayMs = numberArg(args.close_delay_ms, 2_000);
16201 const progressEvery = Math.max(1, numberArg(args.progress_every, 10));
16202 const dryRun = boolArg(args.dry_run);
16203 const syncCommentsOnly = boolArg(args.sync_comments_only);
16204 const commentSyncMinAgeDays = numberArg(args.comment_sync_min_age_days, 0);
16205 const maxRuntimeMs = numberArg(args.max_runtime_ms, 0);
16206 const reportPath = resolve(stringArg(args.report_path, join(ROOT, "apply-report.json")));
16207 const artifactDir = resolve(stringArg(args.artifact_dir, join(ROOT, "artifacts", "apply")));
16208 const prCloseCoverageProofRuntime: PrCloseCoverageProofRuntime = {
16209 model: stringArg(args.codex_model, DEFAULT_CODEX_MODEL),
16210 reasoningEffort: stringArg(args.codex_reasoning_effort, DEFAULT_REASONING_EFFORT),
16211 sandboxMode: stringArg(args.codex_sandbox, "read-only"),
16212 serviceTier: stringArg(args.codex_service_tier, DEFAULT_SERVICE_TIER),
16213 timeoutMs: numberArg(args.codex_timeout_ms, 600_000),
16214 workDir: join(artifactDir, "pr-close-coverage-proof"),
16215 rootDir: ROOT,
16216 schemaPath: PR_CLOSE_COVERAGE_PROOF_SCHEMA_PATH,
16217 promptTemplate: prCloseCoverageProofPromptTemplate(),
16218 ...(process.env.CLAWSWEEPER_PROOF_INSPECTION_TOKEN
16219 ? { ghToken: process.env.CLAWSWEEPER_PROOF_INSPECTION_TOKEN }
16220 : {}),
16221 };
16222 const startedAtMs = Date.now();
16223 const requestedItemNumbers = itemNumbersArg(args.item_numbers, args.item_number);
16224 const requestedItemNumberSet = new Set(requestedItemNumbers);
16225 const results: ApplyResult[] = [];
16226 let closedCount = 0;
16227 let processedCount = 0;
16228 throttleHeartbeatContext = () =>
16229 `Progress: ${closedCount}/${limit} fresh closes, ${processedCount}/${processedLimit} processed records in this apply chunk.`;
16230 const logProgress = (message: string): void => {
16231 const counts = results.reduce<Record<string, number>>((accumulator, result) => {
16232 accumulator[result.action] = (accumulator[result.action] ?? 0) + 1;
16233 return accumulator;
16234 }, {});
16235 console.error(
16236 [
16237 `[apply] ${new Date().toISOString()} ${message}`,
16238 `closed=${closedCount}/${limit}`,
16239 `processed=${processedCount}/${processedLimit}`,
16240 `counts=${JSON.stringify(counts)}`,
16241 ].join(" "),
16242 );

Callers 1

mainFunction · 0.85

Calls 15

repoFromArgsFunction · 0.85
defaultItemsDirFunction · 0.85
defaultClosedDirFunction · 0.85
defaultPlansDirFunction · 0.85
optionalNumberArgFunction · 0.85
applyKindArgFunction · 0.85
closeReasonsArgFunction · 0.85
boolArgFunction · 0.85
itemNumbersArgFunction · 0.85
reportEntriesForDirFunction · 0.85
closeReasonFilterTextFunction · 0.85

Tested by

no test coverage detected