{"id":20511303,"url":"https://github.com/intility/cwc","last_synced_at":"2025-04-13T22:42:32.650Z","repository":{"id":228092539,"uuid":"772528221","full_name":"intility/cwc","owner":"intility","description":"Chat with Code CLI tool","archived":false,"fork":false,"pushed_at":"2025-01-13T11:03:09.000Z","size":660,"stargazers_count":13,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-27T13:01:53.922Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/intility.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":"2024-03-15T11:19:59.000Z","updated_at":"2025-02-13T10:47:50.000Z","dependencies_parsed_at":"2024-03-17T04:23:22.815Z","dependency_job_id":"6b04ab1e-347a-47c5-b392-c8818ee85d7f","html_url":"https://github.com/intility/cwc","commit_stats":null,"previous_names":["intility/cwc"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intility%2Fcwc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intility%2Fcwc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intility%2Fcwc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intility%2Fcwc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/intility","download_url":"https://codeload.github.com/intility/cwc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248794565,"owners_count":21162613,"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":[],"created_at":"2024-11-15T20:35:27.675Z","updated_at":"2025-04-13T22:42:32.515Z","avatar_url":"https://github.com/intility.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **C**hat **W**ith **C**ode\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/intility/cwc\"\u003e\n    \u003cimg src=\"docs/assets/yelling_at_code.webp\" alt=\"Logo\"\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n## Overview\n\nChat With Code is yet another command-line application that bridges the gap between coding and conversation. This tool lets you engage with your codebases using natural language prompts, offering a fresh approach to code exploration and problem-solving.\n\n**Why does this tool exist?**\n\nI was frequently disappointed with Github Copilot's chat context discovery, as it often missed relevant files for accurate answers. \nCWC improves this by allowing you to specify include and exclude patterns across your codebase, giving you complete control over \nthe context window during chats. Additionally, its terminal-based operation makes it independent of IDEs like VSCode, \nenhancing flexibility with other text editors not natively supporting Github Copilot.\n\n## Features\n\n- **Interactive Chat Sessions**: Start a dialogue with your codebase to learn about its structure, get summaries of different parts, or even debug issues.\n- **Intelligent Context-Aware Responses**: Powered by OpenAI, Chat With Code understands the context of your project, providing meaningful insights and relevant code snippets.\n- **Customizable File Inclusion**: Filter the files you want the tool to consider using regular expressions, ensuring focused and relevant chat interactions.\n- **Gitignore Awareness**: Exclude files listed in `.gitignore` from the chat context to maintain confidentiality and relevance.\n- **Simplicity**: A simple and intuitive interface that requires minimal setup to get started.\n\n## Installation\n\n### Using homebrew\n\nIntility provides a shared Homebrew tap with all our formulae. Install Chat With Code using:\n\n```sh\nbrew tap intility/tap\nbrew install cwc\n```\n\n### Using Go\n\nIf you have Go installed (version 1.22 or higher), you can install Chat With Code using the following command:\n\n```sh\ngo install github.com/intility/cwc@latest\n```\n\n### Pre-built Binaries\n\nWe also provide pre-built binaries for Windows, macOS, and Linux. You can download them from the [releases page](https://github.com/intility/cwc/releases) on GitHub.\nYou can install the latest release with the following command using a bash shell (git bash or WSL on Windows):\n\n```sh\nbash \u003c(curl -sSL https://raw.githubusercontent.com/intility/cwc/main/scripts/install.sh)\n\n# move the binary to a directory in your PATH\nmv cwc /usr/local/bin\n```\n\n## Getting Started\n\nAfter installing Chat With Code, you're just a few steps away from a conversational coding experience. Get everything up and running with these instructions:\n\n1. **Launch Chat With Code**: Open your terminal and enter `cwc` to start an interactive session with your codebase.\n   If you are not already signed you will be prompted to configure your credentials.\n\n2. **Authenticate**: To enable communication with your code, authenticate using your Azure credentials by executing:\n\n    ```sh\n    cwc login\n    ```\n\n   *For a seamless login experience, follow the non-interactive authentication method below:*\n\n    1. Safeguard your API Key by storing it in a variable (avoid direct command-line input to protect the key from your history logs):\n\n         ```sh\n         read -s API_KEY\n         ```\n\n    2. Authenticate securely using the following command:\n\n         ```sh\n         cwc login \\\n           --api-key=$API_KEY \\\n           --endpoint \"https://your-endpoint.openai.azure.com/\" \\\n           --deployment-name \"gpt-4-turbo\"\n         ```\n\n   \u003e **Security Notice**: Never input your API key directly into the command-line arguments to prevent potential exposure in shell history and process listings. The API key is securely stored in your personal keyring.\n\nAfter completing these steps, you will have established a secure session, ready to explore and interact with your codebase in the most natural way.\n\n![screenshot][screenshot-url]\n\nNeed a more tailored experience? Try customizing your session. Use the `--include`, `--exclude` flag to filter for specific file patterns or `--paths` to set directories included in the session. Discover all the available options with:\n\n```sh\ncwc --help\n```\n\n## Example usage\n\nThe simplest example would be to chat with a single file or output from a command. This use-case is easy using a pipe:\n\n```sh\ncat README.md | cwc \"help me rewrite the getting started section\"\n```\n\nIf you have multiple files you want to include in the context you can provide a regular expression matching your criteria for inclusion using the `-i` flag:\n\n```sh\n# chat across all .go files\ncwc -i \".*.go\"\n\n# chat with README and test files\ncwc -i \"README.md|.*_test.go\"\n```\n\nThe include flag can also be combined with exclusion expressions, these work exactly the same as the inclusion patterns, but takes priority:\n\n```sh\n# chat with all .ts files, excluding a large .ts file\ncwc -i \".*.ts$\" -x \"large_file.ts\"\n```\n\nIn addition to include and exclude expressions you can also scope the search space to a particular directory. Multiple paths can be provided by a comma separated list or by providing multiple instances of the `-p` flag.\n\n```sh\n# chat with everything inside src/ except .tsx files\ncwc -x \".*.tsx\" -p src\n\n# chat with all yaml files in prod and lab\ncwc -i \".*.ya?ml\" -p prod,lab\n```\n\nThe result output from cwc can also be piped to other commands as well. This example automates the creation of a conventional commit based on the current git diff.\n\n```sh\n# generate a commit message for current changes\nCWC_PROMPT=\"please write me a conventional commit for these changes\"\ngit diff HEAD | cwc $CWC_PROMPT | git commit -e --file -\n```\n\n## Configuration\n\nManaging your configuration is simple with the `cwc config` command. This command allows you to view and set configuration options for cwc.\nTo view the current configuration, use:\n\n```sh\ncwc config get\n```\n\nTo set a configuration option, use:\n\n```sh\ncwc config set key1=value1 key2=value2 ...\n```\n\nFor example, to disable the gitignore feature and the git directory exclusion, use:\n\n```sh\ncwc config set useGitignore=false excludeGitDir=false\n```\n\nTo reset the configuration to default values use `cwc login` to re-authenticate.\n\n## Templates\n\n### Overview\n\nChat With Code (CWC) introduces the flexibility of custom templates to enhance the conversational coding experience. Templates are pre-defined system messages and prompts that tailor interactions with your codebase. A template envelops default prompts, system messages and variables, allowing for easier access to common tasks.\n\n### Template Schema\n\nEach template follows a specific YAML schema defined in `templates.yaml`. \nHere's an outline of the schema for a CWC template:\n\n```yaml\ntemplates:\n  - name: template_name\n    description: A brief description of the template's purpose\n    defaultPrompt: An optional default prompt to use if none is provided\n    systemMessage: |\n      The system message that details the instructions and context for the chat session.\n      This message supports placeholders for {{ .Context }} which is the gathered file context,\n      as well as custom variables `{{ .Variables.variableName }}` fed into the session with cli args.\n    variables:\n      - name: variableName\n        description: Description of the variable\n        defaultValue: Default value for the variable\n```\n\n### Placement\n\nTemplates may be placed within the repository or under the user's configuration directory, adhering to the XDG Base Directory Specification:\n\n1. **In the Repository Directory**: To include the templates specifically for a repository, place a `templates.yaml` inside the `.cwc` directory at the root of your repository:\n\n   ```\n   .\n   ├── .cwc\n   │   └── templates.yaml\n   ...\n\n2. **In the User XDG CWC Config Directory**: For global user templates, place the `templates.yaml` within the XDG configuration directory for CWC, which is typically `~/.config/cwc/` on Unix-like systems:\n\n   ```\n   $XDG_CONFIG_HOME/cwc/templates.yaml\n   ```\n\n   If `$XDG_CONFIG_HOME` is not set, it defaults to `~/.config`.\n\n### Example Usage\n\nYou can specify a template using the `-t` flag and pass variables with the `-v` flag in the terminal. These flags allow you to customize the chat session based on the selected template and provided variables.\n\n#### Selecting a Template\n\nTo begin a chat session using a specific template, use the `-t` flag followed by the template name:\n\n```sh\ncwc -t my_template\n```\n\nThis command will start a conversation with the system message and default prompt defined in the template named `my_template`.\n\n#### Passing Variables to a Template\n\nYou can pass variables to a template using the `-v` flag followed by a key-value pair:\n\n```sh\ncwc -t my_template -v personality=\"a helpful assistant\",name=\"Juno\"\n```\n\nHere, the `my_template` template is used. The `personality` variable is set to \"a helpful coding assistant\", and\nthe `name` variable is set to \"Juno\". These variables will be fed into the template's system message where placeholders are specified.\n\nThe template supporting these variables might look like this:\n\n```yaml\nname: my_template\ndescription: A custom template with modifiable personality and name\nsystemMessage: |\n  You are {{ .Variables.personality }} named {{ .Variables.name }}. \n  Using the following context you will be able to help the user.\n\n  Context:\n  {{ .Context }}\n   \n  Please keep in mind your personality when responding to the user.\n  If the user asks for your name, you should respond with {{ .Variables.name }}.\nvariables:\n  - name: personality\n    description: The personality of the assistant. e.g. \"a helpful assistant\"\n    defaultValue: a helpful assistant\n  - name: name\n    description: The name of the assistant. e.g. \"Juno\"\n    defaultValue: Juno\n```\n\n\u003e Notice that the `personality` and `name` variables have default values, which will be used if no value is provided in the `-v` flag.\n\n## Roadmap \n\nThese items may or may not be implemented in the future.\n\n- [ ] tests\n- [ ] support both azure and openai credentials\n- [ ] customizable tools\n\n## Contributing\n\nPlease file an issue if you encounter any problems or have suggestions for improvement. We welcome contributions in the form of pull requests, bug reports, and feature requests.\n\n## License\n\nChat With Code is provided under the MIT License. For more details, see the [LICENSE](LICENSE) file.\n\nIf you encounter any issues or have suggestions for improvement, please open an issue in the project's [issue tracker](https://github.com/intility/chat-with-code/issues).\n\n[banner-photo-url]: ./docs/assets/yelling_at_code.webp\n[screenshot-url]: ./docs/assets/screenshot.png\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintility%2Fcwc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fintility%2Fcwc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintility%2Fcwc/lists"}