{"id":26397656,"url":"https://github.com/hissain/ghcs","last_synced_at":"2026-05-17T13:08:24.942Z","repository":{"id":282668957,"uuid":"949299264","full_name":"hissain/ghcs","owner":"hissain","description":"Github code search (ghcs) is a CLI based Github code searching and downloading utility.","archived":false,"fork":false,"pushed_at":"2025-03-16T13:41:50.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-16T13:45:31.345Z","etag":null,"topics":["cli","code-search","github","pip","pypi","python","searching"],"latest_commit_sha":null,"homepage":"https://github.com/hissain/ghcs","language":"Python","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/hissain.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}},"created_at":"2025-03-16T05:58:11.000Z","updated_at":"2025-03-16T13:42:26.000Z","dependencies_parsed_at":"2025-03-16T13:45:31.682Z","dependency_job_id":null,"html_url":"https://github.com/hissain/ghcs","commit_stats":null,"previous_names":["hissain/ghs","hissain/ghcs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hissain%2Fghcs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hissain%2Fghcs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hissain%2Fghcs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hissain%2Fghcs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hissain","download_url":"https://codeload.github.com/hissain/ghcs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244031119,"owners_count":20386534,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["cli","code-search","github","pip","pypi","python","searching"],"created_at":"2025-03-17T12:18:33.429Z","updated_at":"2026-05-17T13:08:19.903Z","avatar_url":"https://github.com/hissain.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GitHub Code Search CLI (ghcs) - With Semantic Code Refinement\n\n`ghcs` is a powerful command-line interface (CLI) tool for searching code on GitHub and downloading matched files. It allows you to search for code snippets using various filters such as language, user, repository, and path. Additionally, `ghcs` enables AI-powered code manipulation and refinement using large language models (LLMs) like Gemini. This makes it especially useful for developers working in CLI-based environments without a graphical user interface (e.g., remote servers).\n\n## Features\n\n- Search GitHub repositories for code using advanced filters (query, user, repository, language, path, etc.).\n- Download matched files directly from GitHub.\n- Extract, modify, enhance, and refine code using AI-powered transformations with models like Gemini.\n- User-friendly CLI interface designed for seamless integration into developer workflows.\n\n## Installation\n\nTo install `ghcs`, use pip:\n\n```bash\npip install ghcs\n```\n\nFor the latest updates, install directly from GitHub:\n\n```bash\npip install git+https://github.com/hissain/ghcs.git\n```\n\n## Usage\n\nTo use `ghcs`, you need a GitHub Personal Access Token, which can be set using the `--token` argument or the `GITHUB_TOKEN` environment variable. For AI-powered code manipulation with `--remark`, you must set the `GEMINI_API_KEY` in your environment.\n\n### Basic Search\n\n```bash\nghcs 'search_term' --token YOUR_GITHUB_TOKEN\n```\n\n```bash\nghcs 'search_term' # When GITHUB_TOKEN is already set in .env\n```\n\n### Search with Filters\n\n```bash\nghcs 'search_term' --user 'username' --repo 'username/repo' --language 'python' --path 'llama/train' --token YOUR_GITHUB_TOKEN --max-results MAX_RESULT_COUNT\n```\n\n### Download Matched Files\n\n```bash\nghcs 'search_term' --download --token YOUR_GITHUB_TOKEN\n```\n\n### AI-Powered Code Extraction \u0026 Refinement\n\nTo extract specific code sections or apply AI-driven transformations on downloaded files:\n\n- Use `--remark` to specify semantic modifications (requires `--download`).\n- The refined code can be printed to the console or saved using `--output-file`.\n\n__Example:__\n\n```bash\nghcs \"LoRA def train()\" --user hissain --download --remark \"Extract the training function for LoRA with proper imports\" --output-file extracted_code.py --verbose\n```\n\n\u003e **Note:** The `GEMINI_API_KEY` must be set in your environment variables or `.env` file to enable the `--remark` feature.\n\n## CLI Arguments\n\n### Positional Arguments\n\n- **query**: Search term as a string (required).\n\n### Optional Arguments\n\n- `-l, --language` : Filter by programming language.\n- `-u, --user` : Search within all repositories of a specific user.\n- `-r, --repo` : Search within a specific repository (e.g., username/repo).\n- `-p, --path` : Restrict search to a specific file path.\n- `-t, --token` : GitHub Personal Access Token (or set `GITHUB_TOKEN` environment variable).\n- `-m, --max-result` : Limit the number of search results.\n- `-d, --download` : Download matched files.\n- `-dd, --download-dir` : Specify the directory for downloaded files.\n- `-v, --verbose` : Enable verbose logging.\n- `-r, --remark` : AI instruction for refining downloaded files.\n- `-o, --output-file` : Output file to save refined code (default: print to console).\n- `-e, --extensions` : Specify file extensions to consider (e.g., `.py,.js`).\n- `-h, --help` : Show help menu and exit.\n\n### Example Commands\n\n```bash\nghcs 'def train(' --language 'python' --user 'hissain' --path 'llama/train' --download --token YOUR_GITHUB_TOKEN --max-results 5\n```\n\n```bash\nghcs 'def train(' -l 'python' -p 'llama/train' -d -m 10\n```\n\n```bash\nghcs \"def train()\" --path llm --max-results 3 --download\n```\n\nWith AI-powered refinement:\n\n```bash\nghcs \"def train LoRA\" --path llm --download --remark \"Extract only the forward pass function\" --output-file forward_pass.py --max-results 5\n```\n\n## API Keys\n\n- **GitHub Token:** Generate a personal access token at [GitHub Tokens](https://github.com/settings/tokens)\n- **Gemini API Key:** Obtain from [Google AI Studio](https://aistudio.google.com/apikey)\n\n## License\n\nThis project is licensed under the MIT License. See the LICENSE file for details.\n\n## Author\n\n**Md. Sazzad Hissain Khan**\n\n- **Email:** hissain.khan@gmail.com\n- **GitHub:** [hissain](https://github.com/hissain)\n\nFeel free to modify and enhance this project as needed!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhissain%2Fghcs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhissain%2Fghcs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhissain%2Fghcs/lists"}