Skip to content

Commit 14740e4

Browse files
author
Martin
committed
feat: update README to clarify OpenCode AI functionality and usage instructions
1 parent 94ac1c7 commit 14740e4

1 file changed

Lines changed: 66 additions & 89 deletions

File tree

README.md

Lines changed: 66 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
# OpenCode Azure DevOps Extension
22

3-
Azure DevOps pipeline task for running [OpenCode](https://opencode.ai) AI agents in your pipeline.
3+
Azure DevOps pipeline task for running [OpenCode AI](https://opencode.ai) code reviews and automation in your CI/CD pipelines.
44

5-
Run AI powered code reviews on pull requests automatically or mention /opencode in your comment, and opencode will execute tasks within your Azure DevOps pipeline.
5+
## Features
66

7-
## What it does
7+
- **Automated Code Review** - Run AI code reviews automatically on every PR update via build validation
8+
- **Use any Agent** - Define custom [OpenCode agents](https://opencode.ai/docs/agents) for specialized reviews or tasks
9+
- **Flexible Models** - Use OpenAI, Anthropic, GitHub Copilot, or any OpenCode-supported provider
810

9-
- Run AI powered code reviews on pull requests automatically using review mode and Azure Devops validation builds.
10-
- Mention `/opencode-review` or `/oc-review` in your PR comment to trigger a code review.
11-
- Mention `/opencode` or `/oc` in your PR comment, and opencode will execute tasks within your Azure DevOps pipeline.
11+
## Coming Soon
1212

13-
## Install the extension
13+
- **Comment-Triggered Commands** - Execute AI code review or any command on-demand via PR comments
1414

15-
- From Marketplace: install into your organization and add the task `OpenCodeAgent@1` to a pipeline.
15+
## Quick Start: PR Code Reviews
1616

17-
## Code review as PR build validation pipeline
17+
The recommended setup is to use **review mode** as a PR build validation policy. This automatically reviews every pull request.
1818

19-
Run automated AI driven code review on every PR update.
20-
Create a pipeline with the following YAML and set it as a PR build validation policy:
19+
### 1. Create a Review Pipeline
2120

2221
```yaml
22+
# Triggered automatically by PR build validation policy
2323
trigger: none
24+
2425
pool:
2526
vmImage: ubuntu-latest
2627

@@ -35,95 +36,71 @@ steps:
3536
echo "##vso[task.prependpath]$HOME/.opencode/bin"
3637
displayName: Install OpenCode
3738
38-
- task: OpenCodeAgent@1
39-
displayName: OpenCode PR Agent
40-
inputs:
41-
mode: review
42-
pat: "your-personal-access-token" # or use $(System.AccessToken)
43-
providerID: opencode
44-
modelID: glm-4.7-free
45-
```
46-
47-
Notes:
48-
49-
- Use a PAT with `Code (read and write)` and `Pull Requests (read and write)` scopes. You can also use `$(System.AccessToken)` if the build service identity has the required scopes.
50-
51-
## Provide custom review instructions
52-
53-
Use the `reviewPrompt` input to customize the review instructions. For example, to focus on security issues:
54-
55-
```yaml
56-
steps:
57-
- task: OpenCodeAgent@1
58-
displayName: "OpenCode Security Review"
59-
inputs:
60-
mode: "review"
61-
pat: "$(System.AccessToken)"
62-
providerID: "anthropic"
63-
modelID: "claude-sonnet-4"
64-
reviewPrompt: |
65-
Review this pull request for security vulnerabilities, focusing on:
66-
- SQL injection and XSS attacks
67-
- Hardcoded secrets or API keys
68-
- Insecure authentication patterns
69-
- Missing input validation
70-
71-
Be strict and flag all potential issues.
72-
env:
73-
ANTHROPIC_API_KEY: $(AnthropicApiKey)
39+
- task: OpenCodeAgent@0
40+
displayName: Security Review
41+
inputs:
42+
mode: review
43+
agent: code-review # use any available agent
44+
pat: $(System.AccessToken)
45+
model: opencode/claude-opus-4-5
46+
reviewPrompt: | # optional, if not provided, default prompt is used
47+
Focus on security vulnerabilities:
48+
- SQL injection and XSS attacks
49+
- Hardcoded secrets or API keys
50+
- Insecure authentication/authorization
51+
- Missing input validation
52+
- Unsafe deserialization
53+
env:
54+
OPENCODE_API_KEY: $(AnthropicApiKey)
55+
OPENCODE_PERMISSION: '{"bash": "deny"}'
7456
```
7557
76-
The script execution instructions and PR context are always included automatically—you only need to specify what to review.
58+
### 2. Configure Build Validation Policy
7759
78-
## Comment-triggered command mode (webhook + custom app)
60+
1. Go to **Project Settings** → **Repositories** → Select your repo → **Policies**
61+
2. Under **Branch Policies** for your main branch, add **Build validation**
62+
3. Select the pipeline you created above
63+
4. Set **Trigger** to "Automatic"
64+
5. Set **Policy requirement** to "Optional" (recommended for initial testing)
7965
80-
Want to run opencode on demand via PR comments the same way as on Github actions? To automate:
66+
## Authentication
8167
82-
1. Create a pipeline that uses the following YAML (similar to above but with parameters for IDs):
83-
2. Create an Azure DevOps service hook for PR comments and point it to **your** custom application.
84-
3. Your application must parse the webhook payload and invoke the pipeline above, passing all required parameters.
68+
The task requires a PAT with these scopes:
8569
86-
```yaml
87-
parameters:
88-
- name: commentUrl
89-
type: string
90-
- name: project
91-
type: string
92-
93-
pool:
94-
vmImage: "ubuntu-latest"
70+
| Scope | Permission | Why |
71+
| ------------------------ | ------------ | --------------------------------------------------------------------------------- |
72+
| **Code** | Read & Write | Read PR code; commit fixes in command mode (read-only sufficient for review mode) |
73+
| **Pull Request Threads** | Read & Write | Post review comments and threads |
9574
96-
steps:
97-
- script: |
98-
curl -fsSL https://bun.sh/install | bash
99-
echo "##vso[task.prependpath]$HOME/.bun/bin"
100-
displayName: Install Bun
75+
**Recommended:** Use `$(System.AccessToken)` and grant the build service identity the required permissions:
10176

102-
- script: |
103-
curl -fsSL https://opencode.ai/install | bash
104-
echo "##vso[task.prependpath]$HOME/.opencode/bin"
105-
displayName: Install OpenCode
77+
1. Go to **Project Settings** → **Repositories** → Your Repo → **Security**
78+
2. Find **`{Project} Build Service ({Organization})`**
79+
3. Grant:
80+
- **Contribute**: Allow (for reading code)
81+
- **Contribute to pull requests**: Allow (for posting comments)
10682

107-
- task: OpenCodeAgent@1
108-
displayName: "OpenCode AI agent"
109-
inputs:
110-
commentUrl: "${{ parameters.commentUrl }}"
111-
project: "${{ parameters.project }}"
112-
pat: "your-personal-access-token" # or use $(System.AccessToken)
113-
providerID: "github-copilot"
114-
modelID: "gpt-4.1"
115-
agent: "build"
116-
```
83+
## Task Inputs Reference
11784

118-
The `commentUrl` parameter should be in the format:
85+
| Input | Required | Default | Description |
86+
| --------------- | -------- | ----------- | ------------------------------------------------------------------------------------------ |
87+
| `mode` | No | Auto-detect | `review` = code review, `command` = execute user command, empty = auto-detect from comment |
88+
| `pat` | Yes | - | Azure DevOps PAT or `$(System.AccessToken)` |
89+
| `model` | Yes | - | Model to use: `opencode/glm-4.7-free`, `anthropic/claude-opus-4-5` etc. |
90+
| `agent` | No | - | OpenCode agent to use |
91+
| `reviewPrompt` | No | - | Custom review instructions (review mode only) |
92+
| `commentUrl` | No | - | PR comment URL (command mode only) |
93+
| `organization` | No | Auto-detect | Azure DevOps organization name |
94+
| `project` | No | Auto-detect | Azure DevOps project name |
95+
| `skipClone` | No | `false` | Skip git clone (use existing workspace) |
96+
| `workspacePath` | No | Auto | Custom workspace path |
11997

120-
```
121-
https://dev.azure.com/{org}/_apis/git/repositories/{repoId}/pullRequests/{prId}/threads/{threadId}/comments/{commentId}
122-
```
98+
## Support & Contributing
12399

124-
The task automatically extracts `organization`, `repositoryId`, `pullRequestId`, `threadId`, and `commentId` from this URL. You can override `organization`, `repositoryId`, or `pullRequestId` with explicit inputs if needed.
100+
- **Issues:** [GitHub Issues](https://github.com/trojanmartin/opencode-azdo-extension/issues)
101+
- **Documentation:** [OpenCode Docs](https://opencode.ai/docs)
102+
- **Source:** [GitHub Repository](https://github.com/trojanmartin/opencode-azdo-extension)
125103

126-
## Support
104+
## License
127105

128-
- Issues and questions: open an issue in this repository.
129-
- Hosted trigger app: coming soon as an optional paid service.
106+
MIT

0 commit comments

Comments
 (0)