Skip to content

Commit

Permalink
docs: Update docs with usage info and fixes related to new glob syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
vlazic committed Jun 21, 2023
1 parent 48579e9 commit 5c64f86
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ build-all: build-linux build-windows build-macos
github-release: clean test build-all
sed -r -i "s/(vlazic\/$(BINARY_NAME)\/releases\/download\/)[^\/]+\//\1v$(new_version)\//g" README.md

npx standard-version --release-as $(new_version)
npx standard-version --commit-all --release-as $(new_version)
git add README.md
git commit --amend --no-edit
git tag -d "v$(new_version)"
git commit --amend --no-edit --message "chore(release): Updated CHANGELOG.md and version refference in README.md"

# git push --follow-tags origin master

@echo "Creating a new GitHub release with the compiled binaries..."
Expand Down
38 changes: 26 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,39 @@
# GPT Project Context

<!-- ![GitHub release (latest by date)](https://img.shields.io/github/v/release/vlazic/gpt-project-context)] -->
![GitHub release (latest by date)](https://img.shields.io/github/v/release/vlazic/gpt-project-context)

`gpt-project-context` is a command-line tool that allows you to swiftly copy specific project files to the clipboard, and then use them as an initial prompt for ChatGPT. This prompt provides a 'context' for ChatGPT, thereby equipping it with an understanding of your project.
`gpt-project-context` is a command-line tool that allows you to swiftly copy the content of specific project files to your clipboard. This content can then be easily pasted into the ChatGPT interface as an initial prompt, providing more accurate and targeted assistance from ChatGPT.

Compared to Github Copilot, `gpt-project-context` offers greater control over context setting, leading to more relevant and precisely targeted assistance.

As the author, I use this tool in all my projects and I'm confident that it will significantly enhance your efficiency while working on your projects as well.
This control enables you to create precise prompts and obtain accurate assistance from ChatGPT, surpassing the capabilities of Github Copilot.

## Usage

### Typicall workflow

My typical workflow with this tool involves the following steps:

1. To obtain a list of files for a specific project, I run the command `gpt-project-context -i '**/*.js,README.md,package.json' -e '**/node_modules/*,**/dist/*'` (for a JavaScript project, for example). This command selects the desired files based on the specified patterns and copies their content to the clipboard.

2. Next, I paste the copied content as the first message in ChatGPT or OpenAI Playground. This sets the initial context for the conversation, providing relevant information about the project to assist ChatGPT in generating accurate responses.

3. I can then ask for assistance with specific tasks or questions, such as writing unit tests or debugging code.

4. After making changes to the project files or progressing further in the development process, I return to step one. This can be done by regenerating the files' content using the `gpt-project-context` command, modifying the initial message in ChatGPT, or starting a new ChatGPT session with an updated project context. This iterative process ensures that ChatGPT always has the most up-to-date information about the project, enabling it to provide accurate and relevant assistance.

![Sequence Diagram](.github/docs/workflow-sequence-diagram.svg)

### Include and Exclude Flags

`gpt-project-context` allows you to customize the files included in the output using the `-i` (include) and `-e` (exclude) flags. The `-i` flag specifies which file patterns to include, while the `-e` flag specifies which file patterns to exclude.
`gpt-project-context` allows you to customize the files included in the output using the `-i` (include) and `-e` (exclude) flags. The `-i` flag specifies which file patterns to include, while the `-e` flag specifies which file patterns to exclude. Use standard Glob syntax for specifying file paths.

All available flags are listed below:

```txt
Usage of gpt-project-context:
-e string
exclude patterns
exclude patterns (Glob syntax)
-i string
include patterns
include patterns (Glob syntax)
-n no action, do not copy or write to clipboard
-o string
output file path
Expand All @@ -34,21 +46,21 @@ Usage of gpt-project-context:
#### Go:

```sh
gpt-project-context -i '*.go,*.md' -e 'bin/*,specific_file.go'
gpt-project-context -i '**/*.go,**/*.md' -e '**/bin/*,**/specific_file.go'
```

#### JavaScript:

```sh
gpt-project-context -i '*.js,README.md,package.json' -e 'node_modules/*,dist/*'
gpt-project-context -i '**/*.js,README.md,package.json' -e '**/node_modules/*,**/dist/*'
```

To use this tool more conveniently in a JavaScript project, add it as an npm run script in your `package.json`:

```json
{
"scripts": {
"context": "gpt-project-context -i '*.js,README.md,package.json' -e 'node_modules/*,dist/*'"
"context": "gpt-project-context -i '**/*.js,README.md,package.json' -e '**/node_modules/*,**/dist/*'"
}
}
```
Expand Down Expand Up @@ -92,7 +104,9 @@ sudo mv gpt-project-context /usr/local/bin/

## Contributing

We welcome any issues and pull requests. If you have any questions, please feel free to open an issue.
We welcome any issues and pull requests.

If you have any questions, please feel free to open an issue.

## License

Expand Down

0 comments on commit 5c64f86

Please sign in to comment.