Skip to content

Commit b0dbedd

Browse files
First commit
1 parent ccab63a commit b0dbedd

28 files changed

+1890
-2
lines changed

.editorconfig

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
charset = utf-8
6+
indent_style = tab
7+
indent_size = 4
8+
trim_trailing_whitespace = false
9+
insert_final_newline = true
10+
11+
[*.go]
12+
trim_trailing_whitespace = true
13+
14+
[*.md]
15+
indent_style = space
16+
indent_size = 4
17+
18+
[*.yml]
19+
indent_style = space
20+
indent_size = 2
21+
trim_trailing_whitespace = true
22+
23+
[*.toml]
24+
indent_style = space
25+
indent_size = 2
26+
trim_trailing_whitespace = true

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.go text eol=lf

.github/workflows/build.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: build
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
goreleaser:
13+
runs-on: ubuntu-latest
14+
steps:
15+
-
16+
name: Checkout
17+
uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
20+
-
21+
name: Set up Go
22+
uses: actions/setup-go@v3
23+
with:
24+
go-version-file: 'go.mod'
25+
- name: install syft
26+
run: go install github.com/anchore/syft/cmd/syft@latest
27+
-
28+
name: Run GoReleaser
29+
uses: goreleaser/goreleaser-action@v4
30+
with:
31+
# either 'goreleaser' (default) or 'goreleaser-pro'
32+
distribution: goreleaser
33+
version: latest
34+
args: release --clean
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
38+
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
name: "CodeQL"
7+
8+
on:
9+
push:
10+
branches: [main]
11+
pull_request:
12+
# The branches below must be a subset of the branches above
13+
branches: [main]
14+
schedule:
15+
- cron: '0 20 * * 0'
16+
17+
jobs:
18+
CodeQL-Build:
19+
# CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
20+
runs-on: ubuntu-latest
21+
22+
permissions:
23+
# required for all workflows
24+
security-events: write
25+
26+
# only required for workflows in private repositories
27+
actions: read
28+
contents: read
29+
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v3
33+
34+
# Initializes the CodeQL tools for scanning.
35+
- name: Initialize CodeQL
36+
uses: github/codeql-action/init@v2
37+
# Override language selection by uncommenting this and choosing your languages
38+
with:
39+
languages: go
40+
41+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
42+
# If this step fails, then you should remove it and run the build manually (see below).
43+
- name: Autobuild
44+
uses: github/codeql-action/autobuild@v2
45+
46+
# ℹ️ Command-line programs to run using the OS shell.
47+
# 📚 https://git.io/JvXDl
48+
49+
# ✏️ If the Autobuild fails above, remove it and uncomment the following
50+
# three lines and modify them (or add more) to build your code if your
51+
# project uses a compiled language
52+
53+
#- run: |
54+
# make bootstrap
55+
# make release
56+
57+
- name: Perform CodeQL Analysis
58+
uses: github/codeql-action/analyze@v2

.github/workflows/lint.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: lint
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
8+
permissions:
9+
contents: read
10+
# Optional: allow read access to pull request. Use with `only-new-issues` option.
11+
# pull-requests: read
12+
jobs:
13+
golangci:
14+
name: lint
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
- uses: actions/setup-go@v3
19+
with:
20+
go-version-file: 'go.mod'
21+
- name: golangci-lint
22+
uses: golangci/golangci-lint-action@v3
23+
with:
24+
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
25+
version: latest
26+
27+
# Optional: working directory, useful for monorepos
28+
# working-directory: somedir
29+
30+
# Optional: golangci-lint command line arguments.
31+
args: --enable gosec
32+
33+
# Optional: show only new issues if it's a pull request. The default value is `false`.
34+
# only-new-issues: true
35+
36+
# Optional: if set to true then the all caching functionality will be complete disabled,
37+
# takes precedence over all other caching options.
38+
# skip-cache: true
39+
40+
# Optional: if set to true then the action don't cache or restore ~/go/pkg.
41+
# skip-pkg-cache: true
42+
43+
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
44+
# skip-build-cache: true
45+
- name: testing
46+
run: go test -shuffle on ./...
47+
- name: install govulncheck
48+
run: go install golang.org/x/vuln/cmd/govulncheck@latest
49+
- name: running govulncheck
50+
run: govulncheck ./...

.github/workflows/vulns.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: vulns
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
jobs:
8+
vulns:
9+
name: Vulnerability scanner
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- uses: actions/setup-go@v3
14+
with:
15+
go-version-file: 'go.mod'
16+
- name: install depm
17+
run: go install github.com/goark/depm@latest
18+
- name: WriteGoList
19+
run: depm list --json > go.list
20+
- name: Nancy
21+
uses: sonatype-nexus-community/nancy-github-action@main

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@
1313

1414
# Dependency directories (remove the comment below to include it)
1515
# vendor/
16+
17+
# Other files and directories
18+
*.bak
19+
dist/
20+
.task/
21+
work/

.goreleaser.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
project_name: gpt-cli
2+
release:
3+
github:
4+
owner: goark
5+
name: gpt-cli
6+
7+
builds:
8+
-
9+
env:
10+
- GO111MODULE=on
11+
- CGO_ENABLED=0
12+
goos:
13+
- linux
14+
- darwin
15+
- windows
16+
- freebsd
17+
goarch:
18+
- amd64
19+
- arm64
20+
- riscv64
21+
main: ./
22+
flags:
23+
- -trimpath
24+
ldflags: -s -w -X github.com/goark/gpt-cli/facade.Version=v{{ .Version }}
25+
26+
archives:
27+
-
28+
rlcp: true
29+
format: tar.gz
30+
format_overrides:
31+
- goos: windows
32+
format: zip
33+
name_template: >-
34+
{{ .Binary }}_
35+
{{- .Version }}_
36+
{{- if eq .Os "freebsd" }}FreeBSD
37+
{{- else }}{{ title .Os }}{{ end }}_
38+
{{- if eq .Arch "amd64" }}64bit
39+
{{- else if eq .Arch "386" }}32bit
40+
{{- else if eq .Arch "arm64" }}ARM64
41+
{{- else if eq .Arch "riscv64" }}RISCV
42+
{{- else }}{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ end }}
43+
files:
44+
- LICENSE*
45+
- README*
46+
- dependency.png
47+
48+
changelog:
49+
sort: asc
50+
filters:
51+
exclude:
52+
- docs
53+
- typo
54+
- Merge pull request
55+
- Merge branch
56+
57+
sboms:
58+
- artifacts: archive
59+
60+
snapshot:
61+
name_template: SNAPSHOT-{{ .Commit }}
62+
63+
checksum:
64+
name_template: '{{ .ProjectName }}_{{ .Version }}_checksums.txt'

README.md

Lines changed: 114 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,114 @@
1-
# gpt-cli
2-
CLI tool for GPT powered by OpenAI API
1+
# [gpt-cli] CLI tool for GPT with OpenAI API
2+
3+
[![check vulns](https://github.com/goark/gpt-cli/workflows/vulns/badge.svg)](https://github.com/goark/gpt-cli/actions)
4+
[![lint status](https://github.com/goark/gpt-cli/workflows/lint/badge.svg)](https://github.com/goark/gpt-cli/actions)
5+
[![GitHub license](http://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/goark/gpt-cli/master/LICENSE)
6+
[![GitHub release](https://img.shields.io/github/release/goark/gpt-cli.svg)](https://github.com/goark/gpt-cli/releases/latest)
7+
8+
This package is required Go 1.20 or later.
9+
10+
## Build and Install
11+
12+
```
13+
$ go install github.com/goark/gpt-cli@latest
14+
```
15+
16+
### Binaries
17+
18+
See [latest release](https://github.com/goark/gpt-cli/releases/latest).
19+
20+
## Usage
21+
22+
```
23+
$ gpt-cli -h
24+
CLI tool for GPT with OpenAI API.
25+
26+
Usage:
27+
gpt-cli [flags]
28+
gpt-cli [command]
29+
30+
Available Commands:
31+
chat Chat with GPT-x
32+
help Help about any command
33+
version Print the version number
34+
35+
Flags:
36+
--api-key string OpenAI API key
37+
--config string Config file (default /home/username/.config/gpt-cli/config.yaml)
38+
--debug for debug
39+
-h, --help help for gpt-cli
40+
41+
Use "gpt-cli [command] --help" for more information about a command.
42+
```
43+
44+
### Chat with GPT-x
45+
46+
```
47+
$ gpt-cli chat -h
48+
Chat with GPT-x, input from standard input.
49+
50+
Usage:
51+
gpt-cli chat [flags]
52+
53+
Aliases:
54+
chat, c
55+
56+
Flags:
57+
-c, --clipboard Input message from clipboard
58+
-h, --help help for chat
59+
-i, --interactive Interactive mode
60+
-p, --profile string Path of Profile file (JSON format)
61+
--raw Output raw response (JSON format)
62+
63+
Global Flags:
64+
--api-key string OpenAI API key
65+
--config string Config file (default /home/username/.config/gpt-cli/config.yaml)
66+
--debug for debug
67+
```
68+
69+
### Input form Standard input
70+
71+
```
72+
$ echo hello | gpt-cli c --api-key "your-api-key"
73+
Hello! How can I help you today?
74+
```
75+
76+
### Interactive mode
77+
78+
```
79+
$ gpt-cli c -i --api-key "your-api-key"
80+
81+
Chat> こんにちは
82+
こんにちは!私はAIのアシスタントです。何かお手伝いできることがありますか?
83+
Chat> 科学雑誌の日経サイエンスにChatGPTの特集が載るそうです。どんな内容になるか予想してみましょう。
84+
ChatGPTとは、人工知能による自然言語処理を利用した対話型のチャットボットです。日経サイエンスがChatGPTに特集を組むことから、以下のような予想が考えられます。
85+
86+
1. ChatGPTの機能や特徴の紹介
87+
ChatGPTの性能、動作原理などの詳しい解説や、どのような機能があるのか、どのような場面で活躍するのかなどが紹介される可能性があります。
88+
89+
2. ChatGPTの応用例の紹介
90+
ChatGPTが活用される応用例として、カスタマーサポート、医療支援、人工知能アシスタントなどがあります。特集では、ChatGPTがどのようにこれらの分野で活躍しているのか、具体例を交えて解説されるかもしれません。
91+
92+
3. ChatGPTの進化と今後の展望について
93+
ChatGPTは、自然言語処理分野での革新的な技術であり、今後、ますます進化していくことが期待されています。特集では、今後どのような改良がされ、また、普及の度合いがどこまで広がるのか、その展望についても取り上げられるかもしれません。
94+
Chat> ありがとうございます。雑誌を読むのが楽しみです
95+
どういたしまして。日経サイエンスは、科学技術に関する話題や最新の研究成果などが掲載され、とても興味深く読める雑誌ですね。ChatGPTに特集が組まれるということで、ますます注目が集まりそうですね。楽しみにしていてください。
96+
Chat> q
97+
```
98+
99+
### Save API key to config.yaml file
100+
101+
```yaml:$XDG_CONFIG_HOME/gpt-cli/config.yaml
102+
api-key: your_api_key_string
103+
```
104+
105+
## Modules Requirement Graph
106+
107+
[![dependency.png](./dependency.png)](./dependency.png)
108+
109+
## Reference
110+
111+
- [OpenAI API](https://platform.openai.com/docs/)
112+
- [sashabaranov/go-openai: OpenAI ChatGPT, GPT-3, GPT-4, DALL·E, Whisper API wrapper for Go](https://github.com/sashabaranov/go-openai)
113+
114+
[gpt-cli]: https://github.com/goark/gpt-cli "goark/gpt-cli: CLI tool for GPT with OpenAI API"

0 commit comments

Comments
 (0)