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

Function dispatchFindingsCommand

src/commit-sweeper.ts:846–915  ·  view source on GitHub ↗
(args: Args)

Source from the content-addressed store, hash-verified

844}
845
846function dispatchFindingsCommand(args: Args): void {
847 const enabled = argString(args, "enabled", "true");
848 if (!boolString(enabled)) {
849 console.log("commit finding dispatch disabled");
850 return;
851 }
852
853 const artifactDir = resolve(argString(args, "artifact_dir", "commit-artifacts"));
854 const repairRepo = argString(args, "repair_repo", "openclaw/clawsweeper");
855 const dispatchMode = argString(args, "dispatch_mode", "workflow_dispatch");
856 const repairWorkflow = argString(args, "repair_workflow", "repair-commit-finding-intake.yml");
857 const reportRepo = argString(
858 args,
859 "report_repo",
860 process.env.GITHUB_REPOSITORY || "openclaw/clawsweeper",
861 );
862 const reportBaseUrl = argString(
863 args,
864 "report_base_url",
865 `https://github.com/${reportRepo}/blob/main`,
866 );
867 const dryRun = argBool(args, "dry_run");
868 const dispatches: CommitFindingDispatch[] = [];
869
870 for (const file of collectMarkdownFiles(artifactDir).filter(isCommitReportPath)) {
871 const markdown = readFileSync(file, "utf8");
872 const { frontMatter } = splitFrontMatter(markdown);
873 if (frontMatter.result !== "findings") continue;
874 const sha = frontMatter.sha;
875 const targetRepo = frontMatter.repository;
876 if (!sha || !/^[0-9a-f]{40}$/i.test(sha) || !targetRepo) continue;
877 const artifactRelativePath = relative(artifactDir, file).replaceAll("\\", "/");
878 const reportPath = `records/${artifactRelativePath}`;
879 dispatches.push({
880 sha: sha.toLowerCase(),
881 targetRepo,
882 reportPath,
883 reportUrl: `${reportBaseUrl.replace(/\/$/, "")}/${reportPath}`,
884 highestSeverity: frontMatter.highest_severity ?? "unknown",
885 checkConclusion: frontMatter.check_conclusion ?? "neutral",
886 });
887 }
888
889 if (!dispatches.length) {
890 console.log("No commit finding reports to dispatch.");
891 return;
892 }
893
894 for (const dispatch of dispatches) {
895 if (dryRun) {
896 if (dispatchMode === "repository_dispatch") {
897 console.log(dispatchPayload(dispatch, reportRepo).trim());
898 } else {
899 const commandArgs = workflowDispatchArgs(dispatch, reportRepo, repairWorkflow).map((arg) =>
900 arg === "PLACEHOLDER" ? repairRepo : arg,
901 );
902 console.log(`gh ${commandArgs.join(" ")}`);
903 }

Callers 1

mainFunction · 0.85

Calls 9

argStringFunction · 0.85
boolStringFunction · 0.85
argBoolFunction · 0.85
collectMarkdownFilesFunction · 0.85
splitFrontMatterFunction · 0.85
dispatchPayloadFunction · 0.85
dispatchCommitFindingFunction · 0.85
workflowDispatchArgsFunction · 0.70
relativeFunction · 0.50

Tested by

no test coverage detected