Skip to content

Commit 63042e5

Browse files
committed
feat(cli): split sync into push/pull commands and add CI/CD integration
1 parent a8608a9 commit 63042e5

File tree

18 files changed

+505
-219
lines changed

18 files changed

+505
-219
lines changed

.ai-docs.config.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
userName: "" # fallback when git config user.name is empty
2+
mainBranchName: "main"
3+
4+
docBranchNameTemplate: "@ai-docs/{userName}"
5+
docWorktreeDir: ".ai-docs"
6+
7+
aIAgentMemoryContextPath:
8+
Cline: "memory-bank"
9+
Claude: "CLAUDE.md"
10+
Gemini: "GEMINI.md"
11+
Cursor: ".cursor/rules"
12+
13+
ignorePatterns:
14+
- "/memory-bank/"
15+
- "/.ai-memory/"
16+
- "/.gemini/context/"
17+
- "/.cursor/rules/"

.github/workflows/ci.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
name: Build and Test
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Check out code
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Go
19+
uses: actions/setup-go@v5
20+
with:
21+
go-version: '1.24.4'
22+
cache: true
23+
24+
- name: Download dependencies
25+
run: make deps
26+
27+
- name: Build
28+
run: make build
29+
30+
- name: Run tests
31+
run: make test
32+
33+
- name: Check formatting
34+
run: |
35+
make fmt
36+
git diff --exit-code || (echo "Please run 'make fmt' to format code" && exit 1)
37+
38+
lint:
39+
name: Lint
40+
runs-on: ubuntu-latest
41+
42+
steps:
43+
- name: Check out code
44+
uses: actions/checkout@v4
45+
46+
- name: Set up Go
47+
uses: actions/setup-go@v5
48+
with:
49+
go-version: '1.24.4'
50+
cache: true
51+
52+
- name: Install golangci-lint
53+
uses: golangci/golangci-lint-action@v3
54+
with:
55+
version: latest
56+
57+
- name: Run linter
58+
run: make lint
59+
60+
multi-platform-build:
61+
name: Test Multi-Platform Build
62+
runs-on: ubuntu-latest
63+
strategy:
64+
matrix:
65+
os: [linux, darwin, windows]
66+
arch: [amd64, arm64]
67+
exclude:
68+
- os: windows
69+
arch: arm64
70+
71+
steps:
72+
- name: Check out code
73+
uses: actions/checkout@v4
74+
75+
- name: Set up Go
76+
uses: actions/setup-go@v5
77+
with:
78+
go-version: '1.24.4'
79+
cache: true
80+
81+
- name: Build for ${{ matrix.os }}/${{ matrix.arch }}
82+
env:
83+
GOOS: ${{ matrix.os }}
84+
GOARCH: ${{ matrix.arch }}
85+
run: |
86+
output="ai-docs"
87+
if [ "${{ matrix.os }}" = "windows" ]; then
88+
output="ai-docs.exe"
89+
fi
90+
go build -o $output .

.github/workflows/release.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
goreleaser:
13+
name: Release with GoReleaser
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Check out code
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Set up Go
23+
uses: actions/setup-go@v5
24+
with:
25+
go-version: '1.24.4'
26+
cache: true
27+
28+
- name: Run tests before release
29+
run: make test
30+
31+
- name: Run GoReleaser
32+
uses: goreleaser/goreleaser-action@v5
33+
with:
34+
distribution: goreleaser
35+
version: latest
36+
args: release --clean
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# GoReleaser configuration
2+
# Documentation at https://goreleaser.com
3+
4+
before:
5+
hooks:
6+
- go mod tidy
7+
- go generate ./...
8+
9+
builds:
10+
- id: ai-docs
11+
main: ./main.go
12+
binary: ai-docs
13+
env:
14+
- CGO_ENABLED=0
15+
goos:
16+
- linux
17+
- darwin
18+
- windows
19+
goarch:
20+
- amd64
21+
- arm64
22+
ignore:
23+
- goos: windows
24+
goarch: arm64
25+
ldflags:
26+
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}}
27+
28+
archives:
29+
- id: default
30+
name_template: >-
31+
{{ .ProjectName }}_
32+
{{- title .Os }}_
33+
{{- if eq .Arch "amd64" }}x86_64
34+
{{- else if eq .Arch "386" }}i386
35+
{{- else }}{{ .Arch }}{{ end }}
36+
{{- if .Arm }}v{{ .Arm }}{{ end }}
37+
format_overrides:
38+
- goos: windows
39+
format: zip
40+
files:
41+
- README.md
42+
- LICENSE*
43+
- install.sh
44+
45+
checksum:
46+
name_template: 'checksums.txt'
47+
48+
snapshot:
49+
name_template: "{{ incpatch .Version }}-next"
50+
51+
changelog:
52+
sort: asc
53+
use: github
54+
filters:
55+
exclude:
56+
- '^docs:'
57+
- '^test:'
58+
- '^chore:'
59+
- 'typo'
60+
- 'Merge pull request'
61+
- 'Merge branch'
62+
groups:
63+
- title: 'Features'
64+
regexp: '^feat'
65+
order: 0
66+
- title: 'Bug Fixes'
67+
regexp: '^fix'
68+
order: 1
69+
- title: 'Performance'
70+
regexp: '^perf'
71+
order: 2
72+
- title: 'Refactoring'
73+
regexp: '^refactor'
74+
order: 3
75+
- title: 'Others'
76+
order: 999
77+
78+
release:
79+
github:
80+
owner: trknhr
81+
name: ai-docs
82+
draft: false
83+
prerelease: auto
84+
name_template: "v{{.Version}}"
85+
header: |
86+
## AI Docs CLI v{{.Version}}
87+
88+
A Go-based CLI tool that provides a one-command workflow to isolate AI-generated "memory" files onto a dedicated Git branch.
89+
90+
footer: |
91+
## Installation
92+
93+
### Using the install script:
94+
```bash
95+
curl -sSL https://github.com/trknhr/ai-docs/releases/download/v{{.Version}}/install.sh | bash
96+
```
97+
98+
### Manual installation:
99+
Download the appropriate binary for your platform from the assets below.
100+
101+
### Using Go:
102+
```bash
103+
go install github.com/trknhr/ai-docs@v{{.Version}}
104+
```
105+
106+
brews:
107+
- name: ai-docs
108+
homepage: "https://github.com/trknhr/ai-docs"
109+
description: "AI-generated memory files manager for Git"
110+
repository:
111+
owner: trknhr
112+
name: homebrew-tap
113+
branch: main
114+
token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}"
115+
commit_author:
116+
name: goreleaserbot
117+
email: bot@goreleaser.com
118+
commit_msg_template: "Brew formula update for {{ .ProjectName }} version {{ .Tag }}"
119+
folder: Formula
120+
test: |
121+
system "#{bin}/ai-docs", "--version"
122+
install: |
123+
bin.install "ai-docs"

Makefile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,21 @@ deps-update:
9292
init: build
9393
./$(BINARY_NAME) init -v
9494

95-
# Run sync command for testing
95+
# Run sync command for testing (deprecated - use push/pull)
9696
.PHONY: sync
9797
sync: build
9898
./$(BINARY_NAME) sync -v
9999

100+
# Run pull command for testing
101+
.PHONY: pull
102+
pull: build
103+
./$(BINARY_NAME) pull -v
104+
105+
# Run push command for testing
106+
.PHONY: push
107+
push: build
108+
./$(BINARY_NAME) push -v
109+
100110
# Display help
101111
.PHONY: help
102112
help:
@@ -112,7 +122,9 @@ help:
112122
@echo " deps - Download dependencies"
113123
@echo " deps-update - Update dependencies"
114124
@echo " init - Run 'ai-docs init' command"
115-
@echo " sync - Run 'ai-docs sync' command"
125+
@echo " sync - Run 'ai-docs sync' command (deprecated)"
126+
@echo " pull - Run 'ai-docs pull' command"
127+
@echo " push - Run 'ai-docs push' command"
116128
@echo " help - Display this help message"
117129
@echo ""
118130
@echo "Examples:"

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ A Go-based CLI tool that provides a one-command workflow to isolate AI-generated
88
- Sets up a Git worktree for isolated file management
99
- Creates symlinks from project root to worktree
1010
- Automatically updates .gitignore
11-
- Easy sync command to commit and push changes
11+
- Separate pull/push commands for flexible workflow
1212
- Support for multiple AI agents (Cline, Claude, Gemini, Cursor)
1313
- Configuration via YAML, JSON, or TOML
1414

@@ -44,13 +44,21 @@ This command:
4444
7. Adds a worktree at `.mem`
4545
8. Creates symlinks from project root to worktree
4646

47-
### Sync changes
47+
### Push changes
4848

4949
```bash
50-
ai-docs sync [--config path/to/config.yml] [--dry-run] [-v]
50+
ai-docs push [--config path/to/config.yml] [--dry-run] [-v]
5151
```
5252

53-
Commits and pushes any changes in the AI docs worktree.
53+
Copies local AI docs to the worktree, commits and pushes changes to remote.
54+
55+
### Pull changes
56+
57+
```bash
58+
ai-docs pull [--config path/to/config.yml] [--overwrite] [--dry-run] [-v]
59+
```
60+
61+
Pulls latest changes from remote AI docs branch and copies them to your local project. Use `--overwrite` to replace existing local files.
5462

5563
### Clean up
5664

@@ -89,7 +97,7 @@ docDir: "docs/ai" # optional – where to add extra docs
8997
## Requirements
9098
9199
- Git 2.7.0+ (for worktree support)
92-
- Go 1.22+ (for building from source)
100+
- Go 1.24+ (for building from source)
93101
94102
## License
95103

ai-docs

-4.73 MB
Binary file not shown.

ai-docs.config.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

cmd/clean.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ func runClean(cmd *cobra.Command, args []string) error {
3737
if !force {
3838
fmt.Printf("This will remove the worktree at '%s' and the branch '%s'.\n", cfg.DocWorktreeDir, docBranch)
3939
fmt.Print("Are you sure? (y/N): ")
40-
40+
4141
reader := bufio.NewReader(os.Stdin)
4242
response, err := reader.ReadString('\n')
4343
if err != nil {
4444
return fmt.Errorf("failed to read response: %w", err)
4545
}
46-
46+
4747
response = strings.ToLower(strings.TrimSpace(response))
4848
if response != "y" && response != "yes" {
4949
fmt.Println("Clean cancelled")
@@ -108,4 +108,4 @@ func runClean(cmd *cobra.Command, args []string) error {
108108

109109
printSuccess("Clean completed successfully!")
110110
return nil
111-
}
111+
}

0 commit comments

Comments
 (0)