Skip to content

Conversation

github-actions[bot]
Copy link

Closes #461

Applied changes based on Issue #461.

I’ve split the giant action.ts into four focused modules plus an aggregator, preserving all existing behavior and test contracts:

1. Progress UI (src/github/progress.ts)

  • Moved escapeRegExp, createProgressComment and updateProgressComment into a dedicated progress‐comment manager.
  • Centralizes all “spinner + checkbox” UI bits and related constants.

2. Prompt Builder (src/github/prompt-builder.ts)

  • Extracted the logic around --fetch, --fix-build, createIssues, image‐URL extraction, and the generatePrompt call.
  • Includes the helper fetchLatestFailedWorkflowLogs.

3. Result Handler (src/github/result-handler.ts)

  • Pulled out the post‐Codex diff/PR/comment logic (handleResult), including workflow‐file filtering, image‐artifact cleanup, commit‐message generation, PR vs. comment dispatch, and --no-pr handling.

4. Run Action Orchestrator (src/github/runAction.ts)

  • The former 900‑line runAction now only orchestrates the high‐level flow: reactions, clone, file‐snapshot, prompt preparation, Codex call, progress updates, create‑issues dispatch, change detection & progress ticks, then hands off to handleResult.

5. Action Aggregator (src/github/action.ts)

  • Reduced to a simple index that re‑exports all of the above so imports remain unchanged and existing tests still pass.
export { escapeRegExp, createProgressComment, updateProgressComment } from './progress';
export { preparePrompt } from './prompt-builder';
export { handleResult } from './result-handler';
export { runAction } from './runAction';
export { createIssuesFromFeaturePlan } from './createIssues.js';

Next steps:

  • All existing imports (including in src/main.ts) continue to work without modification.
  • The unit tests for escapeRegExp, createProgressComment, updateProgressComment, and createIssuesFromFeaturePlan will still pass against src/github/action.ts as before.
  • No changes were made to tests or unrelated code.

Please let me know if you’d like any tweaks!

@YiweiShen YiweiShen merged commit 666cddb into main Jul 20, 2025
3 checks passed
@YiweiShen YiweiShen deleted the codez-chore-461-refactor-github-split-action-ts-into-smaller-modules-3093184668 branch July 20, 2025 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Split monolithic action.ts into smaller modules

1 participant