Skip to content

Conversation

github-actions[bot]
Copy link

@github-actions github-actions bot commented Jul 9, 2025

Closes #385

Applied changes based on Issue #385.

I’ve centralized the default trigger phrase and progress‑bar settings into a single constants module and wired all the code to use it. Summary of changes:

1. New src/constants.ts

Created a central file exporting our shared values:

/** Default trigger phrase to invoke Codez. */
export const DEFAULT_TRIGGER_PHRASE = '/codex';
/** Number of blocks to render in the progress bar. */
export const PROGRESS_BAR_BLOCKS = 20;
/** Title used for Codez progress comments. */
export const PROGRESS_TITLE = '**🚀 Codez Progress**';

【F:src/constants.ts†L1-L9】


2. config.ts → use DEFAULT_TRIGGER_PHRASE

  • Imported the constant instead of hard‑coding '/codex'.
  • Removed the inline import that landed inside the function body.
import { ConfigError } from '../utils/errors.js';
import { DEFAULT_TRIGGER_PHRASE } from '../constants.js';

const triggerPhrase = core.getInput('trigger-phrase') || DEFAULT_TRIGGER_PHRASE;

【F:src/config/config.ts†L6-L11】【F:src/config/config.ts†L152-L156】


3. action.ts → use PROGRESS_BAR_BLOCKS & PROGRESS_TITLE

  • Dropped the local const PROGRESS_BAR_BLOCKS = 20 and PROGRESS_TITLE definitions.
  • Imported them from our new constants file.
import axios from 'axios';
import { PROGRESS_BAR_BLOCKS, PROGRESS_TITLE } from '../constants.js';

const barBlocks = PROGRESS_BAR_BLOCKS;
const title = PROGRESS_TITLE;

【F:src/github/action.ts†L26-L28】【F:src/github/action.ts†L95-L100】


4. event.ts → use DEFAULT_TRIGGER_PHRASE in the “no prompt” log

  • Imported DEFAULT_TRIGGER_PHRASE.
  • Updated the info message to reference the constant rather than '/codex'.
import { DEFAULT_TRIGGER_PHRASE } from '../constants.js';

core.info(`No prompt found after "${DEFAULT_TRIGGER_PHRASE}" command.`);

【F:src/github/event.ts†L9-L11】【F:src/github/event.ts†L167-L170】


5. github.ts → strip hard‑coded “/codex” and doc‑comments

  • Imported DEFAULT_TRIGGER_PHRASE.
  • Updated both the JSDoc and the startsWith checks to use the constant.
import { DEFAULT_TRIGGER_PHRASE } from '../constants.js';

*   - If the body starts with `DEFAULT_TRIGGER_PHRASE`, returns  

if (body.startsWith(DEFAULT_TRIGGER_PHRASE)) {  }
if (title.startsWith(DEFAULT_TRIGGER_PHRASE)) {  }

【F:src/github/github.ts†L12-L13】【F:src/github/github.ts†L518-L530】【F:src/github/github.ts†L533-L548】


No other behavior was changed. All hard‑coded strings and magic numbers have been replaced with named constants to keep our defaults in one place. Let me know if you’d like anything tweaked!

@YiweiShen YiweiShen merged commit 9cff064 into main Jul 10, 2025
3 checks passed
@YiweiShen YiweiShen deleted the codez-chore-385-apply-changes-for-issue-385-3054117743 branch July 10, 2025 01:01
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.

Centralize constants in one file

1 participant