Skip to content

Commit 756037b

Browse files
committed
Improve examples
1 parent fa59113 commit 756037b

File tree

9 files changed

+44
-66
lines changed

9 files changed

+44
-66
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Learn more in the Augment Docs:
1414
1. Install Auggie (Node 22+ required):
1515

1616
```sh
17-
npm install -g @augmentcode/auggie
17+
npm install -g @augmentcode/auggie@latest
1818
```
1919

2020
2. Login:

examples/typescript-sdk/context/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Examples demonstrating the Auggie SDK's context modes and AI-powered code analys
77
1. **Node.js 18+** - Required to run the examples
88
2. **Auggie CLI** - Required for FileSystem Context examples
99
```bash
10-
npm install -g @augmentcode/auggie
10+
npm install -g @augmentcode/auggie@latest
1111
```
1212
3. **Authentication** - Required for all examples
1313
```bash

examples/typescript-sdk/context/file-search-server/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ REST API for semantic file search with AI-powered summarization.
66

77
Install the `auggie` CLI and authenticate:
88
```bash
9-
npm install -g @augmentcode/auggie
9+
npm install -g @augmentcode/auggie@latest
1010
auggie login
1111
```
1212

examples/typescript-sdk/context/github-action-indexer/README.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,36 @@ The installation script will:
6565

6666
### 2. Configure Repository Secrets
6767

68-
Add these secrets to your repository (Settings → Secrets and variables → Actions):
68+
In the GitHub UI, navigate to your repository **Settings → Secrets and variables → Actions** and add these secrets:
6969

7070
| Secret Name | Description | Required |
7171
|-------------|-------------|----------|
72-
| `AUGMENT_API_TOKEN` | Your Augment API token (can be a JSON object with `accessToken` and `tenantURL` fields, or a plain token string) | Yes |
72+
| `AUGMENT_API_TOKEN` | Your Augment API token | Yes |
73+
| `AUGMENT_API_URL` | Your tenant-specific Augment API URL (e.g., `https://your-tenant.api.augmentcode.com/`) | Yes |
74+
75+
**How to get your credentials:**
76+
77+
1. **Using the Auggie CLI** (recommended):
78+
```bash
79+
# Login to Augment
80+
auggie login
81+
82+
# Print your credentials
83+
auggie token print
84+
```
85+
86+
This outputs:
87+
```
88+
TOKEN={"accessToken":"your-token-here","tenantURL":"https://your-tenant.api.augmentcode.com/","scopes":["read","write"]}
89+
```
90+
91+
Extract the values from the JSON:
92+
- `accessToken` → use for `AUGMENT_API_TOKEN`
93+
- `tenantURL` → use for `AUGMENT_API_URL`
94+
95+
2. **From your Augment account**: Contact your Augment administrator or check your account settings for API credentials.
7396

7497
**Note:**
75-
- If using a plain token string, you must also set `AUGMENT_API_URL` as a secret or environment variable
76-
- If your token is a JSON object from `~/.augment/session.json` (with `accessToken` and `tenantURL`), the URL will be extracted automatically
7798
- `GITHUB_TOKEN`, `GITHUB_REPOSITORY`, and `GITHUB_SHA` are automatically provided by GitHub Actions
7899

79100
### 3. Push and Run

examples/typescript-sdk/context/github-action-indexer/install.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ jobs:
209209
run: npm run index
210210
env:
211211
AUGMENT_API_TOKEN: \${{ secrets.AUGMENT_API_TOKEN }}
212+
AUGMENT_API_URL: \${{ secrets.AUGMENT_API_URL }}
212213
GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
213214
MAX_COMMITS: ${settings.maxCommits}
214215
MAX_FILES: ${settings.maxFiles}
@@ -264,6 +265,7 @@ jobs:
264265
run: npm run index
265266
env:
266267
AUGMENT_API_TOKEN: \${{ secrets.AUGMENT_API_TOKEN }}
268+
AUGMENT_API_URL: \${{ secrets.AUGMENT_API_URL }}
267269
GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
268270
MAX_COMMITS: ${settings.maxCommits}
269271
MAX_FILES: ${settings.maxFiles}

examples/typescript-sdk/context/github-action-indexer/src/index.ts

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,18 @@ import { IndexManager } from "./index-manager.js";
88
import type { IndexConfig } from "./types.js";
99

1010
/**
11-
* Parse API token from environment variable
12-
* Handles both plain string tokens and JSON-formatted tokens
11+
* Get API credentials from environment variables
1312
*/
14-
function parseApiToken(): { apiToken: string; apiUrl: string } {
15-
const apiTokenEnv = process.env.AUGMENT_API_TOKEN;
16-
if (!apiTokenEnv) {
13+
function getApiCredentials(): { apiToken: string; apiUrl: string } {
14+
const apiToken = process.env.AUGMENT_API_TOKEN;
15+
if (!apiToken) {
1716
throw new Error("AUGMENT_API_TOKEN environment variable is required");
1817
}
1918

20-
let apiToken: string;
21-
let apiUrl: string | undefined = process.env.AUGMENT_API_URL;
22-
23-
try {
24-
const tokenObj = JSON.parse(apiTokenEnv) as {
25-
accessToken?: string;
26-
tenantURL?: string;
27-
};
28-
if (tokenObj.accessToken) {
29-
apiToken = tokenObj.accessToken;
30-
// Use tenantURL from token if not overridden by env var
31-
if (!apiUrl && tokenObj.tenantURL) {
32-
apiUrl = tokenObj.tenantURL;
33-
}
34-
} else {
35-
apiToken = apiTokenEnv;
36-
}
37-
} catch {
38-
// Not JSON, use as-is
39-
apiToken = apiTokenEnv;
40-
}
41-
19+
const apiUrl = process.env.AUGMENT_API_URL;
4220
if (!apiUrl) {
4321
throw new Error(
44-
"AUGMENT_API_URL environment variable is required. Please set it to your tenant-specific URL (e.g., 'https://your-tenant.api.augmentcode.com') or include tenantURL in your API token JSON."
22+
"AUGMENT_API_URL environment variable is required. Please set it to your tenant-specific URL (e.g., 'https://your-tenant.api.augmentcode.com/')"
4523
);
4624
}
4725

@@ -96,7 +74,7 @@ function loadConfig(): IndexConfig {
9674
throw new Error("GITHUB_TOKEN environment variable is required");
9775
}
9876

99-
const { apiToken, apiUrl } = parseApiToken();
77+
const { apiToken, apiUrl } = getApiCredentials();
10078
const { owner, repo, branch, currentCommit } = parseRepositoryInfo();
10179

10280
return {

examples/typescript-sdk/context/github-action-indexer/src/search.ts

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -73,39 +73,17 @@ async function main(): Promise<void> {
7373
process.exit(1);
7474
}
7575

76-
// Get API token
77-
const apiTokenEnv = process.env.AUGMENT_API_TOKEN;
78-
if (!apiTokenEnv) {
76+
// Get API credentials
77+
const apiToken = process.env.AUGMENT_API_TOKEN;
78+
if (!apiToken) {
7979
console.error("Error: AUGMENT_API_TOKEN environment variable is required");
8080
process.exit(1);
8181
}
8282

83-
// Parse API token - it can be either a JSON object or a plain string
84-
let apiToken: string;
85-
let apiUrl: string | undefined = process.env.AUGMENT_API_URL;
86-
87-
try {
88-
const tokenObj = JSON.parse(apiTokenEnv) as {
89-
accessToken?: string;
90-
tenantURL?: string;
91-
};
92-
if (tokenObj.accessToken) {
93-
apiToken = tokenObj.accessToken;
94-
// Use tenantURL from token if not overridden by env var
95-
if (!apiUrl && tokenObj.tenantURL) {
96-
apiUrl = tokenObj.tenantURL;
97-
}
98-
} else {
99-
apiToken = apiTokenEnv;
100-
}
101-
} catch {
102-
// Not JSON, use as-is
103-
apiToken = apiTokenEnv;
104-
}
105-
83+
const apiUrl = process.env.AUGMENT_API_URL;
10684
if (!apiUrl) {
10785
console.error(
108-
"Error: AUGMENT_API_URL environment variable is required. Please set it to your tenant-specific URL (e.g., 'https://your-tenant.api.augmentcode.com') or include tenantURL in your API token JSON."
86+
"Error: AUGMENT_API_URL environment variable is required. Please set it to your tenant-specific URL (e.g., 'https://your-tenant.api.augmentcode.com/')"
10987
);
11088
process.exit(1);
11189
}

examples/typescript-sdk/context/github-action-indexer/src/types.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ export type IndexConfig = {
4141

4242
/**
4343
* Augment API URL
44-
* Can be provided via AUGMENT_API_URL env var, or extracted from
45-
* a JSON-formatted AUGMENT_API_TOKEN that includes tenantURL field
44+
* Provided via AUGMENT_API_URL env var
4645
*/
4746
apiUrl: string;
4847

examples/typescript-sdk/context/prompt-enhancer-server/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ HTTP server that enhances vague prompts using AI with codebase context.
66

77
Install the `auggie` CLI and authenticate:
88
```bash
9-
npm install -g @augmentcode/auggie
9+
npm install -g @augmentcode/auggie@latest
1010
auggie login
1111
```
1212

0 commit comments

Comments
 (0)