{"id":29017845,"url":"https://github.com/mys1024/cr-asst","last_synced_at":"2026-03-05T23:42:34.198Z","repository":{"id":279621959,"uuid":"937956993","full_name":"mys1024/cr-asst","owner":"mys1024","description":"Review your code changes with AI assistants.","archived":false,"fork":false,"pushed_at":"2025-12-05T08:31:19.000Z","size":862,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-08T16:59:13.715Z","etag":null,"topics":["ai","assistant","cicd","codereview","llm","nodejs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mys1024.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-02-24T07:32:53.000Z","updated_at":"2025-12-05T08:31:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"583f8e06-0d26-496e-8038-362591223893","html_url":"https://github.com/mys1024/cr-asst","commit_stats":null,"previous_names":["mys1024/cr-asst"],"tags_count":31,"template":false,"template_full_name":"mys1024/starter-node","purl":"pkg:github/mys1024/cr-asst","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mys1024%2Fcr-asst","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mys1024%2Fcr-asst/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mys1024%2Fcr-asst/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mys1024%2Fcr-asst/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mys1024","download_url":"https://codeload.github.com/mys1024/cr-asst/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mys1024%2Fcr-asst/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30156180,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T22:39:40.138Z","status":"ssl_error","status_checked_at":"2026-03-05T22:39:24.771Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","assistant","cicd","codereview","llm","nodejs"],"created_at":"2025-06-25T23:07:14.589Z","updated_at":"2026-03-05T23:42:34.167Z","avatar_url":"https://github.com/mys1024.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cr-asst\n\n[![license](https://img.shields.io/github/license/mys1024/cr-asst)](./LICENSE)\n[![npm-version](https://img.shields.io/npm/v/cr-asst?color=%23cb3837)](https://www.npmjs.com/package/cr-asst)\n[![workflow-ci](https://img.shields.io/github/actions/workflow/status/mys1024/cr-asst/ci.yml?label=ci)](https://github.com/mys1024/cr-asst/actions/workflows/ci.yml)\n[![workflow-release](https://img.shields.io/github/actions/workflow/status/mys1024/cr-asst/release.yml?label=release)](https://github.com/mys1024/cr-asst/actions/workflows/release.yml)\n\nEnglish | [中文](./README.zh.md)\n\nReview your code changes with AI assistants.\n\n## Usage\n\n### CLI\n\n#### Print Help\n\n```sh\nnpx cr-asst -h\n```\n\n#### Code Review\n\n```sh\nCOMMAND_TO_GET_CODE_DIFFS | npx cr-asst --model gpt-4 --api-key sk-xxx\n# for example:\ngit log -p master.. | npx cr-asst --model gpt-4 --api-key sk-xxx\n```\n\nIf `cr-asst` is executed directly, it defaults to get code diffs from the latest git commit, except for `package-lock.json`, `pnpm-lock.yaml` and `yarn.lock`.\n\n### API\n\n```javascript\nimport { codeReview } from 'cr-asst';\n\nconst { content } = await codeReview({\n  diffs: 'CODE_DIFFS', // or `diffsCmd: 'COMMAND_TO_GET_CODE_DIFFS'`\n  model: 'gpt-4',\n  apiKey: 'sk-xxx',\n  // other options...\n});\n```\n\nSee [`CodeReviewOptions`](./src/types.ts) for more details.\n\n## Output Example\n\n\u003cdetails\u003e\n\n\u003csummary\u003eexpand\u003c/summary\u003e\n\n```markdown\n# Overall Changes\n\n1. Extracted the completion logic into a separate file (`completion.ts`) to improve modularity and reusability.\n2. Removed the `dryRun` option from `CodeReviewOptions` and updated related code.\n3. Renamed `inputTokens` and `outputTokens` to `promptTokens` and `completionTokens` respectively to align with OpenAI's terminology.\n4. Updated test files and snapshots to reflect the changes in token naming and the removal of the `dryRun` option.\n\n# Overall Review Comments\n\n1. The refactoring improves code organization by separating concerns, making the codebase easier to maintain and extend.\n2. The removal of the `dryRun` option simplifies the API, though it may impact testing. Ensure that alternative testing strategies are in place.\n\n# File-wise Review\n\n1. `src/code_review/completion.ts`\n\n   1. Added a new file to handle the creation and reading of completion streams. This improves modularity by encapsulating the completion logic in a single place.\n\n2. `src/code_review/index.ts`\n\n   1. Updated the `codeReview` function to use the new `createCompletion` function, simplifying the main logic and removing redundant code.\n   2. Removed the `dryRun` option and related logic, making the function more straightforward.\n\n3. `src/code_review/test/__snapshots__/utils.test.ts.snap`\n\n   1. Updated the snapshot to reflect the renaming of `inputTokens` and `outputTokens` to `promptTokens` and `completionTokens`.\n\n4. `src/code_review/test/index.test.ts`\n\n   1. Deleted the test file since it was specific to the `dryRun` option, which has been removed.\n\n5. `src/code_review/test/utils.test.ts`\n\n   1. Updated the test cases to use the new token naming conventions (`promptTokens` and `completionTokens`).\n\n6. `src/code_review/utils.ts`\n\n   1. Updated the utility functions to use the new `CompletionUsage` and `CompletionStats` types, aligning with the changes in the completion logic.\n\n7. `src/types.ts`\n\n   1. Removed the `dryRun` option from `CodeReviewOptions`.\n   2. Updated the `CodeReviewResult` type to use `CompletionStats` and `CompletionUsage` from the new `completion.ts` file, ensuring type consistency across the codebase.\n```\n\n\u003c/details\u003e\n\n## Custom Prompt\n\nYou can use your custom prompt file by specifying the `--prompt-file` option. The custom prompt file should include `$DIFFS`, which `cr-asst` will replace with the actual code diffs during execution.\n\nHere is a simple example of a custom prompt file:\n\n````markdown\nPlease review the following code changes and provide your review comments:\n\n```diff\n$DIFFS\n```\n````\n\n## Environment Variables (CLI Only)\n\n`cr-asst` reads the following environment variables:\n\n| Environment Variable | Description                                                                                   |\n| -------------------- | --------------------------------------------------------------------------------------------- |\n| `CR_MODEL`           | AI model to use for review.                                                                   |\n| `CR_API_KEY`         | API key for the AI service.                                                                   |\n| `CR_BASE_URL`        | Base URL for the AI service API.                                                              |\n| `CR_DIFFS_CMD`       | Command to get code diffs for review.                                                         |\n| `CR_OUTPUT_FILE`     | Save review result to file.                                                                   |\n| `CR_PROMPT_FILE`     | Path to a custom prompt file, or a builtin prompt (options: `en`, `zh-cn`).                   |\n| `CR_PRINT`           | Print review result to stdout.                                                                |\n| `CR_PRINT_REASONING` | Print reasoning to stdout (only available for models that support `reasoning_content` field). |\n| `CR_PRINT_DEBUG`     | Print debug information to stdout.                                                            |\n\nMoreover, `cr-asst` CLI uses [`dotenv`](https://www.npmjs.com/package/dotenv) to load environment variables from `.env` file in the current working directory.\n\n## Integrating with GitHub Actions\n\nYou can use [`cr-asst-action`](https://github.com/mys1024/cr-asst-action) to integrate `cr-asst` with Github Actions.\n\n## License\n\n[MIT](./LICENSE) License \u0026copy; 2025-PRESENT mys1024\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmys1024%2Fcr-asst","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmys1024%2Fcr-asst","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmys1024%2Fcr-asst/lists"}