Add PR validation workflow with publish-preview signal - #18
Conversation
- Introduce `absurd` helper in `libs/types.ts` to replace ad-hoc `_exhaustiveCheck: never` patterns across the codebase
- Add `responseParser.ts` in `domain/provider` defining `RawResponse` and `extractResponse`, consolidating all per-provider text extraction logic into one place
- Refactor `anthropic.ts`, `gemini.ts`, and `openai.ts` to return raw API responses and delegate to `extractResponse`, removing duplicated empty-response checks
- Move `resolveProvider.ts` to `domain/provider/authResolver.ts` and replace inline exhaustiveness guards with `absurd`
- Update `prompts.ts` to accept `Maybe<string>` for the custom template instead of `string | undefined`, and fix a typo ("comic" → "commit")
- Update `llm.ts` and `commit.ts` signatures to pass `Maybe<string>` for `customTemplate`, eliminating `??` fallback logic at call sites
- Update imports in `commit.ts` and `model.ts` to use `resolveProvider` from `@/domain/provider/authResolver` instead of `@/app/services/resolveProvider`. - Update imports in `anthropic.ts`, `gemini.ts`, and `openai.ts` to use `extractResponse` from `@/domain/provider/responseParser` instead of `@/app/services/responseExtractor`.
…omain/llm`
- Rename all files under `src/libs/` to `src/utils/`, updating all internal imports accordingly.
- Move `src/app/services/{anthropic,gemini,openai,llm}.ts` to `src/app/llm/`.
- Move `src/domain/provider/{authResolver,responseParser}.ts` to `src/domain/llm/`.
- Update all import paths across the codebase to reflect the new directory structure.
- Move command entry points from `src/app/commands` to `src/cli` and rename `cli.ts` to `cli/parser.ts`. - Relocate infrastructure code (auth, git, llm providers, storage, ui, env) from `src/app` and `src/lib` into `src/infra`. - Rename `src/utils` to `src/libs` and update all related imports across the codebase. - Move LLM routing to `src/domain/llm/router.ts` and rename `domain/commit/model.ts` to `models.ts`. - Extract `selectModelInteractively` into new `src/infra/ui/model-picker.ts` and move `model-selector` component under `src/infra/ui`. - Update all `@/` path imports throughout `index.ts` and source files to reflect the new structure.
- Rename `authResolver.ts` to `auth-resolver.ts` and `responseParser.ts` to `response-parser.ts` for consistent file naming. - Update all import paths in `commit.ts`, `model.ts`, `anthropic.ts`, `gemini.ts`, and `openai.ts` to reflect the new filenames.
- Add Anthropic (Claude) to the AI provider selection during setup. - Document `claude setup-token` auth method alongside API key option. - Move Anthropic from "coming soon" to the supported providers list. - Reorder auth method descriptions to match each provider's options.
- Add a GitHub Actions workflow that runs on pull request open, sync, and reopen events. - Run repository checkout, Node.js setup, dependency installation, typechecking, formatting checks, and project build validation. - Add a preview job that compares `package.json` versions between the PR base and head to detect whether merging will trigger an npm publish. - Reject invalid semver values, non-forward version bumps, and versions that are already published to npm. - Write clear PR step summaries describing whether the merge will publish a new package version or why validation failed.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2ccc1b3358
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7b853c96ad
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Motivation
Another valuable addition to the CI/CD process during PRs, ensuring only valid code gets merged. Enjoy!
What's New
CI/CD PR Validation Workflow
.github/workflows/pr-validate.ymlruns onpull_requestevents (opened,synchronize,reopened).checksrunspnpm run typecheck,pnpm exec prettier . --check, andpnpm run buildwith the sameGOOGLE_CLIENT_ID/GOOGLE_CLIENT_SECRETsecrets used bypublish.yml.publish-previewcomparespackage.jsonversion againstgithub.event.pull_request.base.sha, validates a forward semver bump vianpm install -g semver, and queries the NPM registry for collisions.$GITHUB_STEP_SUMMARY:Will publish on merge,No publish on merge, or failure on invalid/colliding bumps.actions/checkout@v6andactions/setup-node@v6(latest stable majors).Project Layout Restructure
src/app/commands/*→src/cli/*(commit,doctor,model,setup).src/app/cli.ts→src/cli/parser.ts.src/app/services/*→src/infra/llm/*(anthropic,gemini,openai).src/app/services/llm.ts→src/domain/llm/router.ts.src/app/integrations.ts→src/infra/env.ts.src/lib/*→src/infra/*(auth,git,storage,ui).Domain Layer Consolidation
src/domain/llm/response-parser.tscentralizes AI response extraction across providers.src/domain/llm/auth-resolver.tsownsresolveProviderin the domain layer.src/libs/types.ts.src/infra/ui/model-picker.tsfrom other modules.Housekeeping
authResolver.ts→auth-resolver.ts,responseParser.ts→response-parser.ts,model.ts→models.ts.package.jsonversion bumped to0.2.4..claudedirectory added to.gitignore.README.mddocuments Anthropic as a supported provider.PR Validate Flow
graph TD PR[PR opened / updated] --> Checks[Job: checks] PR --> Preview[Job: publish-preview] Checks --> TC[typecheck → prettier check → build] Preview --> Decide{package.json<br/>version changed?} Decide -->|No| NoPub[No publish on merge] Decide -->|Yes, valid bump,<br/>not on NPM| WillPub[Will publish on merge] Decide -->|Invalid bump<br/>or already on NPM| Fail[Fail the check] WillPub -.on merge.-> Publish[publish.yml → NPM] NoPub -.on merge.-> Skip[publish.yml skips] style Checks fill:#e1f5ff style Preview fill:#e1f5ff style WillPub fill:#c8e6c9 style NoPub fill:#fff9c4 style Fail fill:#ffcdd2 style Publish fill:#c8e6c9Testing & Feedback
checksjob runstypecheck,prettier --check, andbuildon every push to this PR.publish-previewreportsNo publish on mergewhilepackage.jsonversion stays at0.2.4; bump the version on a follow-up PR to exercise theWill publish on mergepath.src/app/→src/cli//src/domain//src/infra/restructure (typecheck is the backstop).anthropic,gemini,openai) go through the centralizedresponse-parser.tsandauth-resolver.ts.publish.ymlpublishes0.2.4to NPM as expected.If you find any bugs or have recommendations for improvements, please open an issue and assign it to me.