Skip to content

Commit

Permalink
style: modified by hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Realiserad committed Mar 19, 2024
1 parent 3297203 commit 0499ed2
Show file tree
Hide file tree
Showing 19 changed files with 223 additions and 168 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
@Realiserad
@Realiserad
81 changes: 45 additions & 36 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,64 +6,73 @@ labels: type/bug
assignees: Realiserad
---

**📝 Environment**
### 📝 Environment

1. Operating system
1.
Operating system

```shell
> cat /etc/os-release | grep PRETTY
<paste output here>
```
```shell
> cat /etc/os-release | grep PRETTY
<paste output here>
```

2. Version of `fish`
2.
Version of `fish`

```shell
> fish --version
<paste output here>
```
```shell
> fish --version
<paste output here>
```

3. Version of `openai`
3.
Version of `openai`

```shell
> openai --version
<paste output here>
```
```shell
> openai --version
<paste output here>
```

4. Version of `python`
4.
Version of `python`

```shell
> python3 --version
<paste output here>
```
```shell
> python3 --version
<paste output here>
```

5. `fish-ai` configuration
5.
`fish-ai` configuration

```shell
> sed '/api_key/d' ~/.config/fish-ai.ini
<paste output here>
```
```shell
> sed '/api_key/d' ~/.config/fish-ai.ini
<paste output here>
```

**🙉 To reproduce**
### 🙉 To reproduce

Follow these steps to reproduce the bug.

1. Open the terminal `put name of terminal`.
1.
Open the terminal `put name of terminal`.

2. Type the following:
2.
Type the following:

```shell
<paste command here>
```
```shell
<paste command here>
```

3. Press `put keyboard combination`.
3.
Press `put keyboard combination`.

4. *Describe what happens*
4.
*Describe what happens*

**🕊 Expected behavior**
### 🕊 Expected behavior

A clear and concise description of what you expected to happen.

**🖥 Log output (optional)**
### 🖥 Log output (optional)

```shell
> journalctl -f | grep --line-buffered 'python3'
Expand Down
11 changes: 6 additions & 5 deletions .github/ISSUE_TEMPLATE/feature-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ labels: type/feature
assignees: Realiserad
---

**💡 Summary**
### 💡 Summary

A clear and concise summary of what this feature request is about.

**🗨 Details**
### 🗨 Details

Try to explain your usecase, what you are trying to achieve and how `fish-ai` can help.
Try to explain your usecase, what you are trying to achieve and how
`fish-ai` can help.

**📚 References**
### 📚 References

[1] paste link here
[2] paste another link here
[2] paste another link here
56 changes: 28 additions & 28 deletions .github/workflows/badges.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@ jobs:
git-estimate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: '1.22.1'
cache: false
- name: Estimate time spent
run: |
git clone https://github.com/luigitni/git-estimate.git /tmp/git-estimate
cd /tmp/git-estimate
go build git-estimate
go install
cd -
sudo apt install jq jo
HOURS=$(git-estimate -json | jq '.overall.hours | round')
jo -p \
"schemaVersion=1" \
"label=⏳ Time spent" \
"message=$HOURS hours" \
"color=blue" \
"style=for-the-badge" > fish-ai-git-estimate.json
- name: Store result
uses: realiserad/actions-deploy-gist@main
with:
token: ${{ secrets.TOKEN }}
gist_id: ${{ vars.GIST_ID }}
file_path: fish-ai-git-estimate.json
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: '1.22.1'
cache: false
- name: Estimate time spent
run: |
git clone https://github.com/luigitni/git-estimate.git /tmp/git-estimate
cd /tmp/git-estimate
go build git-estimate
go install
cd -
sudo apt install jq jo
HOURS=$(git-estimate -json | jq '.overall.hours | round')
jo -p \
"schemaVersion=1" \
"label=⏳ Time spent" \
"message=$HOURS hours" \
"color=blue" \
"style=for-the-badge" > fish-ai-git-estimate.json
- name: Store result
uses: realiserad/actions-deploy-gist@main
with:
token: ${{ secrets.TOKEN }}
gist_id: ${{ vars.GIST_ID }}
file_path: fish-ai-git-estimate.json
40 changes: 20 additions & 20 deletions .github/workflows/test-tapes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ jobs:
runs-on: ubuntu-latest
if: "${{ !startsWith(github.event.head_commit.message, 'docs: ') && !startsWith(github.event.head_commit.message, 'chore: ') }}"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create configuration file
run: |
cat > tests/azure-openai/fish-ai.ini <<EOF
[fish-ai]
configuration = test
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create configuration file
run: |
cat > tests/azure-openai/fish-ai.ini <<EOF
[fish-ai]
configuration = test
[test]
provider = azure
server = ${{ secrets.AZURE_SERVER }}
azure_deployment = ${{ secrets.AZURE_DEPLOYMENT }}
api_key = ${{ secrets.AZURE_API_KEY }}
EOF
- name: Run test tapes for Azure OpenAI
uses: docker/build-push-action@v5
with:
context: .
file: tests/azure-openai/Dockerfile
push: false
[test]
provider = azure
server = ${{ secrets.AZURE_SERVER }}
azure_deployment = ${{ secrets.AZURE_DEPLOYMENT }}
api_key = ${{ secrets.AZURE_API_KEY }}
EOF
- name: Run test tapes for Azure OpenAI
uses: docker/build-push-action@v5
with:
context: .
file: tests/azure-openai/Dockerfile
push: false
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
fish-ai.ini
fish-ai.ini
5 changes: 2 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
exclude: ^(\.vscode/.+)$
repos:
- repo: https://github.com/hugoh/pre-commit-fish.git
- repo: https://github.com/hugoh/pre-commit-fish
rev: v1.2
hooks:
- id: fish_syntax
Expand All @@ -9,12 +9,11 @@ repos:
rev: v0.39.0
hooks:
- id: markdownlint
args: [--fix]
args: [--fix, --disable=MD041]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
Expand Down
39 changes: 24 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

`fish-ai` adds AI functionality to [Fish shell](https://fishshell.com).

Originally based on [Tom Dörr's `fish.codex` repository](https://github.com/tom-doerr/codex.fish) which
is now outdated, this repository uses the [chat completions API endpoint](https://platform.openai.com/docs/api-reference/chat/create)
and can be hooked up to OpenAI, Azure OpenAI or a self-hosted LLM behind any OpenAI-compatible API.
Originally based on [Tom Dörr's `fish.codex` repository](https://github.com/tom-doerr/codex.fish)
which is now outdated, this repository uses the [chat completions API endpoint](https://platform.openai.com/docs/api-reference/chat/create)
and can be hooked up to OpenAI, Azure OpenAI or a self-hosted LLM behind any
OpenAI-compatible API.

Continuous integration is performed against Azure OpenAI.

Expand All @@ -18,7 +19,9 @@ If you like it, please add a ⭐.

## 👨‍🔧 How to install

1. Create a configuration file called `.config/fish-ai.ini`.
### Create a configuration

Create a configuration file called `.config/fish-ai.ini`.

If you use [a self-hosted LLM](https://github.com/ollama/ollama), e.g. [`codellama`](https://ollama.com/library/codellama):

Expand Down Expand Up @@ -57,13 +60,17 @@ model = <your deployment name>
api_key = <your API key>
```

2. Install the `openai` Python package.
### Install `openai`

Install the `openai` Python package.

```shell
python3 -m pip install -U openai
```

3. Install the plugin itself. You can install it using [`fisher`](https://github.com/jorgebucaran/fisher).
### Install `fish-ai`

Install the plugin itself. You can install it using [`fisher`](https://github.com/jorgebucaran/fisher).

```shell
fisher install realiserad/fish-ai@stable
Expand All @@ -73,19 +80,21 @@ fisher install realiserad/fish-ai@stable

### Transform comments into commands and vice versa

Type a comment (anything starting with `# `), and press **Ctrl + P** to turn it into shell command!
Type a comment (anything starting with `#`), and press **Ctrl + P** to turn it
into shell command!

You can also run it in reverse. Type a command and press **Ctrl + P** to turn it into a comment explaining what the
command does.
You can also run it in reverse. Type a command and press **Ctrl + P** to turn it
into a comment explaining what the command does.

### Autocomplete commands

Begin typing your command and press **Ctrl + Space** to autocomplete at the cursor position.
Begin typing your command and press **Ctrl + Space** to autocomplete at the cursor
position.

### Suggest fixes

If a command fails, you can immediately press **Ctrl + Space** at the command prompt to let
`fish-ai` suggest a fix!
If a command fails, you can immediately press **Ctrl + Space** at the command prompt
to let `fish-ai` suggest a fix!

## 🔨 Development

Expand All @@ -102,10 +111,10 @@ Enable debug logging to syslog by putting `debug = True` in your `fish-ai.ini`.

### Run the tests

[The tests](https://github.com/Realiserad/fish-ai/actions/workflows/test-tapes.yaml) are packaged
into a container and can be executed locally with e.g. `docker`.
[The tests](https://github.com/Realiserad/fish-ai/actions/workflows/test-tapes.yaml)
are packaged into a container and can be executed locally with e.g. `docker`.

```shell
cp ~/.config/fish-ai.ini tests/azure-openai
docker build -f tests/azure-openai/Dockerfile .
```
```
4 changes: 2 additions & 2 deletions functions/_fish_ai_autocomplete.fish
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env fish

function _fish_ai_autocomplete --description "Autocomplete the current command using AI." --argument-names "command" "cursor_position"
function _fish_ai_autocomplete --description "Autocomplete the current command using AI." --argument-names command cursor_position
set dir (dirname (status -f))
set output ("$dir/_fish_ai_autocomplete.py" "$command" "$cursor_position")
echo -n "$output"
end
end
Loading

0 comments on commit 0499ed2

Please sign in to comment.