Skip to content

[scanner] fix: extract text utilities from god-script into scripts/lib/#2526

Merged
kubestellar-hive[bot] merged 1 commit into
masterfrom
scanner/fix-kb-extract-utils
Jun 11, 2026
Merged

[scanner] fix: extract text utilities from god-script into scripts/lib/#2526
kubestellar-hive[bot] merged 1 commit into
masterfrom
scanner/fix-kb-extract-utils

Conversation

@kubestellar-hive

Copy link
Copy Markdown
Contributor

Summary

Extracts 11 pure text-processing functions (345 lines) from the 2036-line generate-cncf-missions.mjs into scripts/lib/text-utils.mjs:

Function Purpose
cleanText Strip PR template boilerplate, HTML comments, image markdown
isGarbageSnippet Detect non-content (Codecov, CI bots, git diffs)
truncateAtWordBoundary Safe text truncation at word boundaries
truncateAtSentenceBoundary Truncation at sentence endings
extractFromNumberedTemplate Extract content from numbered PR templates
extractFromBoldTemplate Extract content from bold-header templates
stripPRTemplate Full PR template stripping
isLikelyEnglish Language detection heuristic
slugify URL-safe slug creation
sanitizeInfraDetails Redact real IPs/hostnames
redactCredentials Redact leaked secrets in scraped content

Result

  • generate-cncf-missions.mjs: 2036 → 1691 lines (-17%)
  • Functions now reusable by generate-platform-missions.mjs and generate-cncf-install-missions.mjs
  • Zero behavior change — same regex patterns and logic

Fixes #2481

…b/text-utils.mjs

Extract 11 pure text-processing functions (345 lines) from the 2036-line
generate-cncf-missions.mjs into a reusable lib module:

  cleanText, isGarbageSnippet, truncateAtWordBoundary,
  truncateAtSentenceBoundary, extractFromNumberedTemplate,
  extractFromBoldTemplate, stripPRTemplate, isLikelyEnglish,
  slugify, sanitizeInfraDetails, redactCredentials

These utilities are now importable by generate-platform-missions.mjs and
generate-cncf-install-missions.mjs without copy-pasting.

Fixes #2481

Signed-off-by: sec-check <sec-check@hive.local>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Jun 11, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jun 11, 2026
Comment on lines +20 to +21
return text
.replace(/<!--[\s\S]*?-->/g, '')
if (lower.includes('for first time contributors') || lower.includes('please ensure your pull request')) return true
if (lower.includes('query performance') && lower.includes('![image]')) return true
if (lower.includes('"tag_name"') || lower.includes('"html_url"') || lower.includes('"created_at"')) return true
if (lower.includes('api.github.com')) return true
export function stripPRTemplate(text) {
if (!text) return ''
let cleaned = text
cleaned = cleaned.replace(/<!--[\s\S]*?-->/g, '')
@kubestellar-hive kubestellar-hive Bot merged commit 95eed19 into master Jun 11, 2026
7 of 9 checks passed
@kubestellar-prow kubestellar-prow Bot deleted the scanner/fix-kb-extract-utils branch June 11, 2026 01:49
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

Check out what's new:

Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copilot dco-signoff: yes Indicates the PR's author has signed the DCO. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[architect] generate-cncf-missions.mjs is a 91KB/2036-line god-script — extract shared utilities into lib/

1 participant