Skip to content

Commit 3ef5ca7

Browse files
committed
clean up config
1 parent 5d4e0b8 commit 3ef5ca7

File tree

6 files changed

+12
-19
lines changed

6 files changed

+12
-19
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ DEBUG=false
1616

1717
# Amp Configuration
1818
AMP_API_KEY=
19-
AMP_SERVER_URL=https://ampcode.com
19+
# AMP_SERVER_URL=https://ampcode.com # Optional, defaults to https://ampcode.com

.github/workflows/review.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
uses: docker://ghcr.io/sourcegraph/cra-github:latest
2525
env:
2626
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27-
AMP_SERVER_URL: ${{ vars.AMP_SERVER_URL }}
27+
AMP_SERVER_URL: ${{ vars.AMP_SERVER_URL }} # Optional, defaults to https://ampcode.com
2828
AMP_API_KEY: ${{ secrets.AMP_API_KEY }}
2929
with:
3030
args: node /app/dist/bin/review-action.js

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ The simplest way to add code reviews to any repository:
3232

3333
2. **Configure repository settings**:
3434
- Go to your repo → Settings → Secrets and variables → Actions
35-
- Add **Variable**: `AMP_SERVER_URL` = `https://ampcode.com`
3635
- Add **Secret**: `AMP_API_KEY` = your Amp API key
36+
- (Optional) Add **Variable**: `AMP_SERVER_URL` = `https://ampcode.com` (defaults to https://ampcode.com if not set)
3737

3838
3. **Create a pull request** - reviews will run automatically!
3939

config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ server:
2323

2424
amp:
2525
command: "npx --yes @sourcegraph/amp@latest"
26-
server_url: "${AMP_SERVER_URL}"
27-
settings:
28-
amp.url: "${AMP_SERVER_URL}"
26+
server_url: "${AMP_SERVER_URL:-https://ampcode.com}"
2927

3028
prompt_template: |
3129
Review this code diff as a senior developer. Look for bugs, clear logic errors, and code quality problems.
@@ -46,7 +44,9 @@ amp:
4644
Diff to review:
4745
__DIFF_CONTENT__
4846
49-
Use the tools available in the toolbox (prefixed with tb__) while performing your review. Read any existing PR comments before leaving new comments.
47+
IMPORTANT: Always use the tools available in the toolbox (prefixed with tb__) to leave comments while performing your review.
48+
49+
Read any existing PR comments before leaving new comments.
5050
5151
Review the diff content to identify issues. If you find any issues, leave specific inline comments for each issue found.
5252

src/config.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ const ConfigSchema = z.object({
3030
amp: z.object({
3131
command: z.string(),
3232
server_url: z.string(),
33-
settings: z.object({
34-
'amp.url': z.string(),
35-
}),
33+
settings: z.record(z.any()).optional(),
3634
prompt_template: z.string(),
3735
}),
3836
});
@@ -64,10 +62,13 @@ class ConfigLoader {
6462

6563
private processEnvVars(obj: unknown): unknown {
6664
if (typeof obj === 'string') {
67-
return obj.replace(/\$\{([^}]+)\}/g, (_, envVar) => {
65+
return obj.replace(/\$\{([^}]+)\}/g, (_, envVarExpr) => {
66+
const [envVar, defaultValue] = envVarExpr.split(':-');
6867
const value = process.env[envVar];
6968
if (value) {
7069
return value;
70+
} else if (defaultValue !== undefined) {
71+
return defaultValue;
7172
} else {
7273
console.warn(`Environment variable ${envVar} not found, keeping placeholder`);
7374
return `\${${envVar}}`;

src/review/reviewer.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export const reviewDiff = async (
2020
const tempDir = tmpdir();
2121
const promptFilePath = join(tempDir, `amp-prompt-${uuidv4()}.txt`);
2222
const resultFilePath = join(tempDir, `amp-result-${uuidv4()}.txt`);
23-
const settingsFilePath = join(tempDir, `amp-settings-${uuidv4()}.json`);
2423

2524
try {
2625
// Create prompt content
@@ -42,18 +41,11 @@ export const reviewDiff = async (
4241
const commentsFileName = `comments-${installationId}-${uuidv4()}.jsonl`;
4342
const commentsFilePath = join(tempDir, commentsFileName);
4443

45-
// Write settings to file
46-
const settings = {
47-
...ampConfig.settings
48-
};
49-
50-
writeFileSync(settingsFilePath, JSON.stringify(settings, null, 2), 'utf8');
5144

5245
const threadId = await newThread(tempDir);
5346
const result = await execute({
5447
promptFilePath,
5548
resultFilePath,
56-
settingsFilePath,
5749
folderPath: tempDir,
5850
debug: true,
5951
logging: true,

0 commit comments

Comments
 (0)