Skip to content

Commit 3db5c8b

Browse files
committed
Slight re-arrangement
1 parent 119c920 commit 3db5c8b

File tree

5 files changed

+237
-17
lines changed

5 files changed

+237
-17
lines changed

examples/python-sdk/context/github_action_indexer/.github/workflows/index.yml renamed to examples/python-sdk/context/github_action_indexer/.github/workflows/augment-index.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
cache: 'pip'
3737

3838
- name: Install dependencies
39-
run: pip install -r requirements.txt
39+
run: pip install -r augment_indexer/requirements.txt
4040

4141
- name: Restore index state
4242
uses: actions/cache@v4

examples/python-sdk/context/github_action_indexer/README.md

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Test the indexer on any GitHub repository without copying any files. This downlo
5454
cd examples/python-sdk/context
5555

5656
# Install dependencies
57-
pip install -r github_action_indexer/requirements.txt
57+
pip install -r github_action_indexer/augment_indexer/requirements.txt
5858

5959
# Set your credentials (see Prerequisites section above)
6060
export AUGMENT_API_TOKEN="your-token" # From ~/.augment/session.json
@@ -90,28 +90,49 @@ The index state is saved to `.augment-index-state/{branch}/state.json`, so subse
9090

9191
## Option 2: GitHub Actions Setup (Production Use)
9292

93-
For automatic indexing of your repository on every push, copy this code into your own repository.
93+
For automatic indexing of your repository on every push, install the indexer into your repository.
94+
95+
### Quick Install
96+
97+
```bash
98+
# From the auggie repo, install into your target repository
99+
cd examples/python-sdk/context
100+
python -m github_action_indexer install /path/to/your/repo
101+
```
102+
103+
This will:
104+
- Copy the `augment_indexer/` directory (includes `requirements.txt`)
105+
- Create `.github/workflows/augment-index.yml`
106+
- Update `.gitignore`
107+
108+
### Manual Installation
109+
110+
If you prefer to install manually:
94111

95112
1. **Copy the indexer code** to your repository root. The workflow expects the following structure:
96113
```
97114
your-repo/
98-
├── .github/workflows/index.yml
99-
── augment_indexer/
100-
── main.py (and other indexer source files)
101-
└── requirements.txt
115+
├── .github/workflows/augment-index.yml
116+
── augment_indexer/
117+
── main.py (and other indexer source files)
118+
└── requirements.txt
102119
```
103-
Copy the contents of this `github_action_indexer` directory (excluding `.github/`) to your repo root.
104120

105-
2. **Copy the workflow file** from [`.github/workflows/index.yml`](.github/workflows/index.yml) to your repository's `.github/workflows/` directory.
121+
2. **Copy the workflow file** from [`.github/workflows/augment-index.yml`](.github/workflows/augment-index.yml) to your repository's `.github/workflows/` directory.
122+
123+
### Configure Secrets
124+
125+
After installing (either method), add your API credentials to repository secrets:
126+
127+
1. Go to Settings → Secrets and variables → Actions
128+
2. Add `AUGMENT_API_TOKEN` with your Augment API token
129+
3. Add `AUGMENT_API_URL` with your tenant-specific URL (e.g., `https://your-tenant.api.augmentcode.com/`)
106130

107-
3. **Add your API credentials** to repository secrets:
108-
- Go to Settings → Secrets and variables → Actions
109-
- Add `AUGMENT_API_TOKEN` with your Augment API token
110-
- Add `AUGMENT_API_URL` with your tenant-specific URL (e.g., `https://your-tenant.api.augmentcode.com/`)
131+
> **Note:** Do not include quotes around the secret values. Enter the raw values directly (e.g., `https://...` not `"https://..."`).
111132
112-
> **Note:** Do not include quotes around the secret values. Enter the raw values directly (e.g., `https://...` not `"https://..."`).
133+
### Push to trigger indexing
113134

114-
4. **Push to trigger indexing** - The workflow will run automatically on every push to `main`
135+
The workflow will run automatically on every push to `main`
115136

116137
The GitHub Actions cache will persist the index state between runs, enabling incremental updates.
117138

examples/python-sdk/context/github_action_indexer/__main__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
GitHub Action Indexer - CLI entry point
44
55
Usage:
6+
python -m github_action_indexer install /path/to/repo
67
python -m github_action_indexer index
78
python -m github_action_indexer search "query"
89
python -m github_action_indexer search "query" --max-chars 5000
@@ -20,10 +21,12 @@ def main() -> None:
2021
print(" python -m github_action_indexer <command> [args]")
2122
print()
2223
print("Commands:")
24+
print(" install [target_dir] Install the indexer into a repository")
2325
print(" index Index the repository (uses environment variables)")
2426
print(" search <query> Search the indexed repository")
2527
print()
2628
print("Examples:")
29+
print(" python -m github_action_indexer install /path/to/your/repo")
2730
print(" python -m github_action_indexer index")
2831
print(' python -m github_action_indexer search "authentication functions"')
2932
print(' python -m github_action_indexer search "error handling" --max-chars 5000')
@@ -33,7 +36,11 @@ def main() -> None:
3336
# Remove the command from argv so subcommands see correct args
3437
sys.argv = [sys.argv[0]] + sys.argv[2:]
3538

36-
if command == "index":
39+
if command == "install":
40+
from .install import main as install_main
41+
42+
install_main()
43+
elif command == "index":
3744
from .augment_indexer.main import main as index_main
3845

3946
index_main()
@@ -43,7 +50,7 @@ def main() -> None:
4350
search_main()
4451
else:
4552
print(f"Unknown command: {command}")
46-
print("Available commands: index, search")
53+
print("Available commands: install, index, search")
4754
sys.exit(1)
4855

4956

examples/python-sdk/context/github_action_indexer/requirements.txt renamed to examples/python-sdk/context/github_action_indexer/augment_indexer/requirements.txt

File renamed without changes.
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
#!/usr/bin/env python3
2+
"""
3+
GitHub Action Indexer Installation Script
4+
5+
This script helps developers install the Augment GitHub Action Indexer
6+
into their repositories with minimal setup.
7+
8+
Usage:
9+
python install.py /path/to/your/repository
10+
python install.py # installs to current directory
11+
"""
12+
13+
import argparse
14+
import shutil
15+
import sys
16+
from pathlib import Path
17+
18+
# Colors for console output
19+
COLORS = {
20+
"reset": "\033[0m",
21+
"bright": "\033[1m",
22+
"red": "\033[31m",
23+
"green": "\033[32m",
24+
"yellow": "\033[33m",
25+
"blue": "\033[34m",
26+
"cyan": "\033[36m",
27+
}
28+
29+
30+
def colorize(color: str, text: str) -> str:
31+
"""Apply color to text."""
32+
return f"{COLORS.get(color, '')}{text}{COLORS['reset']}"
33+
34+
35+
def log(message: str, color: str = "reset") -> None:
36+
"""Print a colored message."""
37+
print(colorize(color, message))
38+
39+
40+
def log_step(step: str, message: str) -> None:
41+
"""Print a step message."""
42+
log(f"[{step}] {message}", "cyan")
43+
44+
45+
def log_success(message: str) -> None:
46+
"""Print a success message."""
47+
log(f"✅ {message}", "green")
48+
49+
50+
def log_warning(message: str) -> None:
51+
"""Print a warning message."""
52+
log(f"⚠️ {message}", "yellow")
53+
54+
55+
def log_error(message: str) -> None:
56+
"""Print an error message."""
57+
log(f"❌ {message}", "red")
58+
59+
60+
def copy_directory(src: Path, dst: Path) -> None:
61+
"""Copy a directory recursively, excluding __pycache__ and .pyc files."""
62+
if dst.exists():
63+
shutil.rmtree(dst)
64+
65+
def ignore_patterns(directory: str, files: list[str]) -> list[str]:
66+
return [f for f in files if f == "__pycache__" or f.endswith(".pyc")]
67+
68+
shutil.copytree(src, dst, ignore=ignore_patterns)
69+
70+
71+
def update_gitignore(target_dir: Path) -> None:
72+
"""Update .gitignore to include Augment indexer entries."""
73+
gitignore_path = target_dir / ".gitignore"
74+
augment_entry = ".augment-index-state/"
75+
76+
existing_content = ""
77+
if gitignore_path.exists():
78+
existing_content = gitignore_path.read_text()
79+
80+
if augment_entry not in existing_content:
81+
addition = "\n# Augment indexer files\n.augment-index-state/\n"
82+
if existing_content and not existing_content.endswith("\n"):
83+
addition = "\n" + addition
84+
gitignore_path.write_text(existing_content + addition)
85+
log_success("Updated .gitignore")
86+
else:
87+
log_warning(".gitignore already contains Augment indexer entries")
88+
89+
90+
def display_next_steps(target_dir: Path) -> None:
91+
"""Display next steps after installation."""
92+
log("\n" + colorize("bright", "🎉 Installation Complete!"))
93+
log("\nNext steps:\n")
94+
95+
log(colorize("yellow", "1. Set up GitHub repository secrets:"))
96+
log(" Go to your repository Settings > Secrets and variables > Actions")
97+
log(" Add the following secrets:")
98+
log(" • AUGMENT_API_TOKEN - Your Augment API token")
99+
log(" • AUGMENT_API_URL - Your tenant-specific Augment API URL\n")
100+
101+
log(colorize("yellow", "2. Push to trigger the workflow:"))
102+
log(" git add .")
103+
log(' git commit -m "Add Augment GitHub Action Indexer"')
104+
log(" git push\n")
105+
106+
log(colorize("green", "The indexer will automatically run on pushes to main!"))
107+
108+
log(colorize("yellow", "\n(Optional) Test locally first:"))
109+
log(f" cd {target_dir}")
110+
log(" pip install -r augment_indexer/requirements.txt")
111+
log(' export AUGMENT_API_TOKEN="your-token"')
112+
log(' export AUGMENT_API_URL="https://your-tenant.api.augmentcode.com/"')
113+
log(' export GITHUB_TOKEN="your-github-token"')
114+
log(' export GITHUB_REPOSITORY="owner/repo"')
115+
log(' export GITHUB_SHA="$(git rev-parse HEAD)"')
116+
log(" python -m augment_indexer.main")
117+
log(colorize("blue", "\nFor more information, see the documentation at:"))
118+
log("https://github.com/augmentcode/auggie/tree/main/examples/python-sdk/context/github_action_indexer\n")
119+
120+
121+
def main() -> None:
122+
"""Main installation function."""
123+
parser = argparse.ArgumentParser(
124+
description="Install the Augment GitHub Action Indexer into your repository"
125+
)
126+
parser.add_argument(
127+
"target_dir",
128+
nargs="?",
129+
default=".",
130+
help="Target directory to install into (default: current directory)",
131+
)
132+
args = parser.parse_args()
133+
134+
# Resolve paths
135+
script_dir = Path(__file__).parent.resolve()
136+
target_dir = Path(args.target_dir).resolve()
137+
138+
log(colorize("bright", "🚀 Augment GitHub Action Indexer Installation"))
139+
log("This script will set up the Augment GitHub Action Indexer in your repository.\n")
140+
141+
log(colorize("bright", "📁 Target Directory"))
142+
log(f"Installing to: {colorize('cyan', str(target_dir))}\n")
143+
144+
# Check if target directory exists
145+
if not target_dir.exists():
146+
response = input(f"Directory {target_dir} doesn't exist. Create it? (y/N): ")
147+
if not response.lower().startswith("y"):
148+
log("Installation cancelled.")
149+
sys.exit(0)
150+
target_dir.mkdir(parents=True)
151+
log_success(f"Created directory {target_dir}")
152+
153+
# Check if this looks like a git repository
154+
if not (target_dir / ".git").is_dir():
155+
log_warning("This doesn't appear to be a Git repository.")
156+
response = input("Continue anyway? (y/N): ")
157+
if not response.lower().startswith("y"):
158+
log("Installation cancelled.")
159+
sys.exit(0)
160+
161+
try:
162+
# Step 1: Copy augment_indexer directory (includes requirements.txt)
163+
log_step("1", "Copying augment_indexer directory...")
164+
src_indexer = script_dir / "augment_indexer"
165+
dst_indexer = target_dir / "augment_indexer"
166+
copy_directory(src_indexer, dst_indexer)
167+
log_success("Copied augment_indexer/ (includes requirements.txt)")
168+
169+
# Step 2: Copy GitHub workflow
170+
log_step("2", "Creating GitHub workflow...")
171+
src_workflow = script_dir / ".github" / "workflows" / "augment-index.yml"
172+
dst_workflow_dir = target_dir / ".github" / "workflows"
173+
dst_workflow_dir.mkdir(parents=True, exist_ok=True)
174+
dst_workflow = dst_workflow_dir / "augment-index.yml"
175+
shutil.copy(src_workflow, dst_workflow)
176+
log_success("Created .github/workflows/augment-index.yml")
177+
178+
# Step 3: Update .gitignore
179+
log_step("3", "Updating .gitignore...")
180+
update_gitignore(target_dir)
181+
182+
# Display next steps
183+
display_next_steps(target_dir)
184+
185+
except Exception as e:
186+
log_error(f"Installation failed: {e}")
187+
sys.exit(1)
188+
189+
190+
if __name__ == "__main__":
191+
main()
192+

0 commit comments

Comments
 (0)