diff --git a/AGENTS.md b/AGENTS.md index d78d0d23..eb1febf7 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -3,14 +3,38 @@ This file provides structured guidance for AI coding assistants and agents working with the **Cozystack** project. -## Agent Documentation +## Activation -| Agent | Purpose | -|-------|---------| -| [overview.md](./docs/agents/overview.md) | Project structure and conventions | -| [contributing.md](./docs/agents/contributing.md) | Commits, pull requests, and git workflow | -| [changelog.md](./docs/agents/changelog.md) | Changelog generation instructions | -| [releasing.md](./docs/agents/releasing.md) | Release process and workflow | +**CRITICAL**: When the user asks you to do something that matches the scope of a documented process, you MUST read the corresponding documentation file and follow the instructions exactly as written. + +- **Commits, PRs, git operations** (e.g., "create a commit", "make a PR", "fix review comments", "rebase", "cherry-pick") + - Read: [`contributing.md`](./docs/agents/contributing.md) + - Action: Read the entire file and follow ALL instructions step-by-step + +- **Changelog generation** (e.g., "generate changelog", "create changelog", "prepare changelog for version X") + - Read: [`changelog.md`](./docs/agents/changelog.md) + - Action: Read the entire file and follow ALL steps in the checklist. Do NOT skip any mandatory steps + +- **Release creation** (e.g., "create release", "prepare release", "tag release", "make a release") + - Read: [`releasing.md`](./docs/agents/releasing.md) + - Action: Read the file and follow the referenced release process in `docs/release.md` + +- **Project structure, conventions, code layout** (e.g., "where should I put X", "what's the convention for Y", "how is the project organized") + - Read: [`overview.md`](./docs/agents/overview.md) + - Action: Read relevant sections to understand project structure and conventions + +- **General questions about contributing** + - Read: [`contributing.md`](./docs/agents/contributing.md) + - Action: Read the file to understand git workflow, commit format, PR process + +**Important rules:** +- ✅ **ONLY read the file if the task matches the documented process scope** - do not read files for tasks that don't match their purpose +- ✅ **ALWAYS read the file FIRST** before starting the task (when applicable) +- ✅ **Follow instructions EXACTLY** as written in the documentation +- ✅ **Do NOT skip mandatory steps** (especially in changelog.md) +- ✅ **Do NOT assume** you know the process - always check the documentation when the task matches +- ❌ **Do NOT read files** for tasks that are outside their documented scope +- 📖 **Note**: [`overview.md`](./docs/agents/overview.md) can be useful as a reference to understand project structure and conventions, even when not explicitly required by the task ## Project Overview diff --git a/docs/agents/contributing.md b/docs/agents/contributing.md index e0519b5c..4a2a7ef9 100644 --- a/docs/agents/contributing.md +++ b/docs/agents/contributing.md @@ -155,6 +155,91 @@ git diff The user will commit and push when ready. +## Code Review Comments + +When asked to fix code review comments, **always work only with unresolved (open) comments**. Resolved comments should be ignored as they have already been addressed. + +### Getting Unresolved Review Comments + +Use GitHub GraphQL API to fetch only unresolved review comments from a pull request: + +```bash +gh api graphql -F owner=cozystack -F repo=cozystack -F pr= -f query=' +query($owner: String!, $repo: String!, $pr: Int!) { + repository(owner: $owner, name: $repo) { + pullRequest(number: $pr) { + reviewThreads(first: 100) { + nodes { + isResolved + comments(first: 100) { + nodes { + id + path + line + author { login } + bodyText + url + createdAt + } + } + } + } + } + } +}' --jq '.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved == false) | .comments.nodes[]' +``` + +### Filtering for Unresolved Comments + +The key filter is `select(.isResolved == false)` which ensures only unresolved review threads are processed. Each thread can contain multiple comments, but if the thread is resolved, all its comments should be ignored. + +### Working with Review Comments + +1. **Fetch unresolved comments** using the GraphQL query above +2. **Parse the results** to identify: + - File path (`path`) + - Line number (`line` or `originalLine`) + - Comment text (`bodyText`) + - Author (`author.login`) +3. **Address each unresolved comment** by: + - Locating the relevant code section + - Making the requested changes + - Ensuring the fix addresses the concern raised +4. **Do NOT process resolved comments** - they have already been handled + +### Example: Compact List of Unresolved Comments + +For a quick overview of unresolved comments: + +```bash +gh api graphql -F owner=cozystack -F repo=cozystack -F pr= -f query=' +query($owner: String!, $repo: String!, $pr: Int!) { + repository(owner: $owner, name: $repo) { + pullRequest(number: $pr) { + reviewThreads(first: 100) { + nodes { + isResolved + comments(first: 100) { + nodes { + path + line + author { login } + bodyText + } + } + } + } + } + } +}' --jq '.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved == false) | .comments.nodes[] | "\(.path):\(.line // "N/A") - \(.author.login): \(.bodyText[:150])"' +``` + +### Important Notes + +- **REST API limitation**: The REST endpoint `/pulls/{pr}/reviews` returns review summaries, not individual review comments. Use GraphQL API for accessing `reviewThreads` with `isResolved` status. +- **Thread-based resolution**: Comments are organized in threads. If a thread is resolved (`isResolved: true`), ignore all comments in that thread. +- **Always filter**: Never process comments from resolved threads, even if they appear in the results. + ### Example Workflow ```bash