Skip to content

Commit 0d27728

Browse files
authored
Add support for rules and MCP configs (#5)
* Add support for rules and MCP configs * Review comments
1 parent 148c9bd commit 0d27728

File tree

6 files changed

+91
-17
lines changed

6 files changed

+91
-17
lines changed

README.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,22 @@ Each example includes a complete workflow file that you can copy to your `.githu
6666

6767
### Inputs
6868

69-
| Input | Description | Required | Example |
70-
| ---------------------- | ----------------------------------------------------- | -------- | ------------------------------------------- |
71-
| `augment_session_auth` | Augment session authentication JSON (store as secret) | No\*\* | `${{ secrets.AUGMENT_SESSION_AUTH }}` |
72-
| `augment_api_token` | API token for Augment services (store as secret) | No\*\* | `${{ secrets.AUGMENT_API_TOKEN }}` |
73-
| `augment_api_url` | Augment API endpoint URL (store as variable) | No\*\* | `${{ vars.AUGMENT_API_URL }}` |
74-
| `github_token` | GitHub token with `repo` and `user:email` scopes. | No | `${{ secrets.GITHUB_TOKEN }}` |
75-
| `instruction` | Direct instruction text for simple commands | No\* | `"Generate PR description"` |
76-
| `instruction_file` | Path to file with detailed instructions | No\* | `/tmp/instruction.txt` |
77-
| `template_directory` | Path to template directory for dynamic instructions | No\* | `.github/templates` |
78-
| `template_name` | Template file name (default: prompt.njk) | No | `pr-review.njk` |
79-
| `pull_number` | PR number for template context extraction | No | `${{ github.event.pull_request.number }}` |
80-
| `repo_name` | Repository name for template context | No | `${{ github.repository }}` |
81-
| `custom_context` | Additional JSON context for templates | No | `'{"priority": "high"}'` |
82-
| `model` | Model to use; passed through to auggie as --model | No | e.g. `sonnet4`, from `auggie --list-models` |
69+
| Input | Description | Required | Example |
70+
| ---------------------- | --------------------------------------------------------------------------------------- | -------- | ------------------------------------------- |
71+
| `augment_session_auth` | Augment session authentication JSON (store as secret) | No\*\* | `${{ secrets.AUGMENT_SESSION_AUTH }}` |
72+
| `augment_api_token` | API token for Augment services (store as secret) | No\*\* | `${{ secrets.AUGMENT_API_TOKEN }}` |
73+
| `augment_api_url` | Augment API endpoint URL (store as variable) | No\*\* | `${{ vars.AUGMENT_API_URL }}` |
74+
| `github_token` | GitHub token with `repo` and `user:email` scopes. | No | `${{ secrets.GITHUB_TOKEN }}` |
75+
| `instruction` | Direct instruction text for simple commands | No\* | `"Generate PR description"` |
76+
| `instruction_file` | Path to file with detailed instructions | No\* | `/tmp/instruction.txt` |
77+
| `template_directory` | Path to template directory for dynamic instructions | No\* | `.github/templates` |
78+
| `template_name` | Template file name (default: prompt.njk) | No | `pr-review.njk` |
79+
| `pull_number` | PR number for template context extraction | No | `${{ github.event.pull_request.number }}` |
80+
| `repo_name` | Repository name for template context | No | `${{ github.repository }}` |
81+
| `custom_context` | Additional JSON context for templates | No | `'{"priority": "high"}'` |
82+
| `model` | Model to use; passed through to auggie as --model | No | e.g. `sonnet4`, from `auggie --list-models` |
83+
| `rules` | JSON array of rules file paths (each forwarded as individual `--rules` flags) | No | `'[".github/augment/rules.md"]'` |
84+
| `mcp_configs` | JSON array of MCP config file paths (each forwarded as individual `--mcp-config` flags) | No | `'[".augment/mcp/config.json"]'` |
8385

8486
\*Either `instruction`, `instruction_file`, or `template_directory` must be provided.
8587

action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ inputs:
4343
model:
4444
description: "Model to use; forwarded to auggie as --model"
4545
required: false
46+
rules:
47+
description: "JSON array of rules file paths. Each entry is forwarded to auggie as an individual --rules flag."
48+
required: false
49+
mcp_configs:
50+
description: "JSON array of MCP config file paths. Each entry is forwarded to auggie as an individual --mcp-config flag."
51+
required: false
4652

4753
runs:
4854
using: "composite"
@@ -74,3 +80,5 @@ runs:
7480
INPUT_REPO_NAME: ${{ inputs.repo_name }}
7581
INPUT_CUSTOM_CONTEXT: ${{ inputs.custom_context }}
7682
INPUT_MODEL: ${{ inputs.model }}
83+
INPUT_RULES: ${{ inputs.rules }}
84+
INPUT_MCP_CONFIGS: ${{ inputs.mcp_configs }}

src/config/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export const INPUT_FIELD_MAP: Record<string, InputField> = {
2525
templateDirectory: { envVar: 'INPUT_TEMPLATE_DIRECTORY', required: false },
2626
templateName: { envVar: 'INPUT_TEMPLATE_NAME', required: false },
2727
model: { envVar: 'INPUT_MODEL', required: false },
28+
rules: { envVar: 'INPUT_RULES', required: false },
29+
mcpConfigs: { envVar: 'INPUT_MCP_CONFIGS', required: false },
2830
};
2931

3032
export const TEMPLATE_CONFIG = {

src/index.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,32 @@ async function runAugmentScript(inputs: ActionInputs): Promise<void> {
119119
}
120120
if (is_file) {
121121
logger.info(`📄 Using instruction file: ${instruction_value}`);
122-
args.push('--instruction-file');
122+
args.push('--instruction-file', instruction_value);
123123
} else {
124124
logger.info('📝 Using direct instruction');
125-
args.push('--instruction');
125+
args.push('--instruction', instruction_value);
126126
}
127-
args.push(instruction_value);
127+
128+
const uniqueRules = Array.from(new Set(inputs.rules ?? [])).filter(rule => rule.length > 0);
129+
if (uniqueRules.length > 0) {
130+
logger.info(`🔧 Applying ${uniqueRules.length} rule file(s)`);
131+
for (const rulePath of uniqueRules) {
132+
logger.info(` - ${rulePath}`);
133+
args.push('--rules', rulePath);
134+
}
135+
}
136+
137+
const uniqueMcpConfigs = Array.from(new Set(inputs.mcpConfigs ?? [])).filter(
138+
config => config.length > 0
139+
);
140+
if (uniqueMcpConfigs.length > 0) {
141+
logger.info(`🧩 Applying ${uniqueMcpConfigs.length} MCP config file(s)`);
142+
for (const configPath of uniqueMcpConfigs) {
143+
logger.info(` - ${configPath}`);
144+
args.push('--mcp-config', configPath);
145+
}
146+
}
147+
128148
await execCommand('auggie', args);
129149
logger.info('✅ Augment Agent completed successfully');
130150
}

src/types/inputs.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ export interface ActionInputs {
2424
customContext?: string | undefined;
2525
pullNumber?: number | undefined;
2626
repoName?: string | undefined;
27+
28+
// Additional configuration inputs
29+
rules?: string[] | undefined;
30+
mcpConfigs?: string[] | undefined;
2731
}
2832

2933
export interface RepoInfo {

src/utils/validation.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,36 @@ import type { ActionInputs, RepoInfo } from '../types/inputs.js';
77
import { logger } from './logger.js';
88
import { ERROR, INPUT_FIELD_MAP } from '../config/constants.js';
99

10+
const createJsonStringArraySchema = (invalidTypeMessage: string, emptyEntryMessage: string) =>
11+
z.preprocess(
12+
value => {
13+
if (value === undefined || value === null) {
14+
return undefined;
15+
}
16+
if (typeof value === 'string') {
17+
const trimmed = value.trim();
18+
if (trimmed.length === 0) {
19+
return undefined;
20+
}
21+
try {
22+
return JSON.parse(trimmed);
23+
} catch {
24+
return value;
25+
}
26+
}
27+
return value;
28+
},
29+
z
30+
.array(
31+
z
32+
.string()
33+
.transform(val => val.trim())
34+
.refine(val => val.length > 0, { message: emptyEntryMessage }),
35+
{ invalid_type_error: invalidTypeMessage }
36+
)
37+
.optional()
38+
);
39+
1040
/**
1141
* Zod schema for action inputs validation
1242
*/
@@ -27,6 +57,14 @@ const ActionInputsSchema = z
2757
.string()
2858
.regex(/^[^\/]+\/[^\/]+$/, ERROR.INPUT.REPO_FORMAT)
2959
.optional(),
60+
rules: createJsonStringArraySchema(
61+
'rules must be a JSON array of strings',
62+
'Rule file paths cannot be empty'
63+
),
64+
mcpConfigs: createJsonStringArraySchema(
65+
'mcp_configs must be a JSON array of strings',
66+
'MCP config file paths cannot be empty'
67+
),
3068
})
3169
.refine(
3270
data => {

0 commit comments

Comments
 (0)