Guidance for AI coding agents working on this repository. Applies to all files unless a nested AGENTS.md overrides it.
- Azure DevOps pipeline task for OpenCode AI.
- Two execution modes:
- command (
/oc,/opencode): clone PR branch, run agent, commit/push changes, reply to comment. - review (
/oc-review,/opencode-review): read-only code review, post inline comments and summary thread.
- command (
- Headless review allowed when mode explicitly set to
reviewwithout thread/comment IDs. - Cross-platform; Node.js ESM; TypeScript source under
src/.
- Install deps:
npm install. - Build TypeScript:
npm run build. - Bundle task artifacts:
npm run build:task. - Lint:
npm run lint(uselint:fixto autofix). - Format:
npm run format(orformat:check). - Package VSIX:
npm run package(orpackage:devfor private). - Debug local flow:
npm run debug(runssrc/debug.ts).
modeinput optional; auto-detected from comment ifthreadId+commentIdprovided.commandmode requires trigger comment containing/ocor/opencode.reviewmode trigger:/oc-reviewor/opencode-review.- Explicit
modebypasses trigger validation; for headless review also omitthreadId/commentId. - Summary threads use prefix
## OpenCode Review Summaryand are closed (status fixed).
- Azure DevOps PAT passed via task input
pat. reviewEnvexported to child processes for review tools:AZURE_DEVOPS_ORG,AZURE_DEVOPS_PROJECT,AZURE_DEVOPS_REPO_ID,AZURE_DEVOPS_PR_ID,AZURE_DEVOPS_PAT.
- Avoid adding secrets to code or repo.
src/index.ts: entry; reads inputs, resolves mode, dispatches to command/review.src/common.ts: shared types/utilities; mode detection; PR context builder; workspace cleanup.src/opencode.ts: OpenCode server/client lifecycle; spawns CLI; streams events.src/git.ts: clone/setup/commit/push helpers.src/command.ts: command-mode implementation.src/code-review.ts: review-mode implementation and summary thread posting.src/azure-devops-api.ts: REST calls for PR data and thread creation.src/prompts/code-review-prompt.ts: review prompt builder.src/scripts/add-review-comment.mjs: cross-platform inline comment helper (Node fetch).tasks/opencode/task.json: pipeline task manifest.
- Preferred workflow:
npm run lint->npm run build->npm run build:task->npm run package. build:taskusesbuild-task.js(esbuild) and copiessrc/scripts/add-review-comment.mjsintotasks/opencode.- Clean artifacts:
npm run clean.
semi: false; no semicolons.singleQuote: false; use double quotes.printWidth: 100.tabWidth: 2, spaces only.arrowParens: always.endOfLine: lf.
- Parser:
@typescript-eslint/parser; plugins:@typescript-eslint,prettier. - Base:
@typescript-eslint/recommended+prettier/prettiererror. - Warnings:
no-explicit-any,explicit-function-return-type,no-unused-vars(warn; tests rule unused is error with_ignore). no-consoleallowed.- Ignore:
dist/,node_modules/,coverage/,*.vsix, common config files.
- UTF-8; LF; trim trailing whitespace; insert final newline.
- Indent: 2 spaces for
*.{js,ts,json}. - Markdown keeps trailing spaces (for formatting only when needed).
target/lib/module: ES2022.moduleResolution: bundler.rootDir: src,outDir: dist.- Strict mode on;
noFallthroughCasesInSwitch,noUncheckedIndexedAccess,noImplicitOverride. esModuleInterop: true,skipLibCheck: true.- Source maps + declaration + declarationMap enabled.
- Use ESM with explicit
.jsextensions for local imports. - Order suggestion: Node built-ins, external deps, local modules.
- Type-only imports allowed; keep them near related runtime imports.
- Prefer named exports; default only when file semantics demand.
- Types/interfaces:
PascalCase. - Functions, variables, properties:
camelCase. - Constants:
UPPER_SNAKEonly when truly constant across module. - Files:
kebab-case.tsor descriptive names aligned to module purpose.
- Throw descriptive
Errorwith actionable message; avoid silent failures. - Validate inputs early (
getRequiredInput,getRequiredVariable). - Use
console.logfor progress;console.warnfor non-fatal issues; prefer clear, concise messages. - When posting errors to PR threads, include human-readable summary.
skipClonetrue requiresworkspacePathprovided.cleanupWorkspaceis best-effort; handles locked dirs gracefully.- Commits/pushes handled by
git.ts; ensure author config set before committing.
- Review prompt built in
src/prompts/code-review-prompt.tswith PR data context. - Summary thread posted closed to avoid clutter; contains
## OpenCode Review Summaryheader. - Inline comments can be added via
src/scripts/add-review-comment.mjs(requires env vars above).
- Use
npm run debugto runsrc/debug.ts(untracked by default) viatsxfor local experiments. - Ensure required env vars/pat are set when calling APIs.
- Jest removed; no test suite currently. Do not add tests unless requested.
- If adding tests later, align with existing lint/prettier/editorconfig settings.
- Keep changes minimal and scoped to the task.
- Follow existing patterns before introducing new ones.
- Avoid introducing new dependencies without necessity.
- Do not commit secrets or sample secrets.
- Command mode replies to triggering comment after actions.
- Review mode posts new PR thread; headless review allowed when
mode=reviewand no thread/comment IDs. - Comment footer includes pipeline link when
organizationandbuildIdprovided.
npm run packagebuilds task and creates.vsixviatfx.package:devsetspublic: falsein manifest override.publishusestfx extension publish(requires proper auth context).
- Never log PATs or sensitive values.
- Rely on environment variables/task inputs; do not hardcode credentials.
- Obey this AGENTS.md for all touched files.
- Prefer surgical edits; avoid noisy reformatting outside your changes.
- Provide concise summaries and mention any skipped validations/tests.
- File kept around ~150 lines for readability. Adjust with care if updating.