Skip to content

Extract shared JS libraries from workflow inline scripts #37

@jdelfino

Description

@jdelfino

Context

All 8 GitHub Actions workflows embed ~1,800 lines of JavaScript inline in YAML. Much of this logic is duplicated across workflows (config parsing, approval checking, fixes parsing, etc.).

Task

Create shared library modules in .github/agent-workflow/scripts/lib/:

Module Purpose Used by
config.js Parse guardrail config YAML section All 5 guardrails
approval.js Check for non-stale PR approval All 5 guardrails
fixes-parser.js Parse Fixes #N from PR body scope, orchestrator, human-review, pr-context
file-patterns.js isTestFile, isCodeFile, isDependencyFile test-ratio, dependencies
commit-validator.js Conventional commit regex validation commits guardrail
scope-matcher.js Extract file paths from text, scope matching scope guardrail
api-patterns.js API surface regex patterns + detection api-surface guardrail
patch-parser.js Parse unified diff line numbers api-surface guardrail
severity.js Detect review comment severity human-review
pr-body.js Idempotent PR body section replacement human-review

Each module exports pure functions (no GitHub API calls). All GitHub API interaction stays in the main scripts.

Also set up package.json with js-yaml as a devDependency and node --test as the test script.

Files

  • .github/agent-workflow/scripts/lib/*.js (10 new files)
  • package.json (new)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions