@open-code-review/agents 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/skills/ocr/AGENTS.md +41 -0
- package/skills/ocr/SKILL.md +163 -0
- package/skills/ocr/assets/config.yaml +86 -0
- package/skills/ocr/assets/ocr-gitignore +12 -0
- package/skills/ocr/assets/reviewer-template.md +71 -0
- package/skills/ocr/references/context-discovery.md +197 -0
- package/skills/ocr/references/discourse.md +155 -0
- package/skills/ocr/references/reviewer-task.md +197 -0
- package/skills/ocr/references/reviewers/principal.md +51 -0
- package/skills/ocr/references/reviewers/quality.md +62 -0
- package/skills/ocr/references/reviewers/security.md +60 -0
- package/skills/ocr/references/reviewers/testing.md +64 -0
- package/skills/ocr/references/session-state.md +86 -0
- package/skills/ocr/references/setup-guard.md +158 -0
- package/skills/ocr/references/synthesis.md +296 -0
- package/skills/ocr/references/workflow.md +520 -0
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-code-review/agents",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "AI-native skills, commands, and reviewer personas for Open Code Review",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
|
-
"
|
|
7
|
+
"skills",
|
|
8
8
|
"commands"
|
|
9
9
|
],
|
|
10
10
|
"keywords": [
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Open Code Review - Agent Instructions
|
|
2
|
+
|
|
3
|
+
These instructions are for AI assistants performing code reviews in this project.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
When asked to perform a code review:
|
|
8
|
+
|
|
9
|
+
1. **Read** `SKILL.md` for the Tech Lead role and responsibilities
|
|
10
|
+
2. **Follow** `references/workflow.md` for the 8-phase review process
|
|
11
|
+
3. **Use** reviewer personas from `references/reviewers/` for multi-perspective analysis
|
|
12
|
+
4. **Store** session artifacts in `.ocr/sessions/{timestamp}-{branch}/`
|
|
13
|
+
|
|
14
|
+
## Available Commands
|
|
15
|
+
|
|
16
|
+
| Command | Description |
|
|
17
|
+
|---------|-------------|
|
|
18
|
+
| `/ocr-review` | Start a full code review session |
|
|
19
|
+
| `/ocr-doctor` | Check OCR installation and dependencies |
|
|
20
|
+
| `/ocr-reviewers` | List available reviewer personas |
|
|
21
|
+
| `/ocr-history` | Show past review sessions |
|
|
22
|
+
| `/ocr-show` | Display a specific past review |
|
|
23
|
+
| `/ocr-post` | Post review to GitHub PR |
|
|
24
|
+
|
|
25
|
+
## Review Workflow Summary
|
|
26
|
+
|
|
27
|
+
1. **Context Discovery** - Understand codebase structure and standards
|
|
28
|
+
2. **Change Context** - Analyze the specific changes being reviewed
|
|
29
|
+
3. **Tech Lead Analysis** - Initial assessment and reviewer team selection
|
|
30
|
+
4. **Parallel Reviews** - Each reviewer analyzes from their perspective
|
|
31
|
+
5. **Discourse** - Reviewers discuss and debate findings
|
|
32
|
+
6. **Synthesis** - Aggregate findings into actionable feedback
|
|
33
|
+
7. **Presentation** - Generate final review output
|
|
34
|
+
|
|
35
|
+
## Key Files
|
|
36
|
+
|
|
37
|
+
- `SKILL.md` - Core skill definition and Tech Lead role
|
|
38
|
+
- `references/workflow.md` - Complete 8-phase workflow
|
|
39
|
+
- `references/synthesis.md` - How to synthesize findings
|
|
40
|
+
- `references/discourse.md` - Multi-agent discourse rules
|
|
41
|
+
- `references/reviewers/` - Reviewer persona definitions
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ocr
|
|
3
|
+
description: |
|
|
4
|
+
AI-powered multi-agent code review. Simulates a team of Principal Engineers
|
|
5
|
+
reviewing code from different perspectives. Use when asked to review code,
|
|
6
|
+
check a PR, analyze changes, or perform code review.
|
|
7
|
+
license: Apache-2.0
|
|
8
|
+
compatibility: |
|
|
9
|
+
Designed for Claude Code, Cursor, Windsurf, and other Agent Skills-compatible
|
|
10
|
+
environments. Requires git. Optional: gh CLI for GitHub integration.
|
|
11
|
+
metadata:
|
|
12
|
+
author: spencermarx
|
|
13
|
+
version: "1.0.0"
|
|
14
|
+
repository: https://github.com/spencermarx/open-code-review
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# Open Code Review
|
|
18
|
+
|
|
19
|
+
You are the **Tech Lead** orchestrating a multi-agent code review. Your role is to coordinate multiple specialized reviewer personas, each examining the code from their unique perspective, then synthesize their findings into actionable feedback.
|
|
20
|
+
|
|
21
|
+
## When to Use This Skill
|
|
22
|
+
|
|
23
|
+
Activate when the user:
|
|
24
|
+
- Asks to "review my code" or "review these changes"
|
|
25
|
+
- Mentions "code review", "PR review", or "check my implementation"
|
|
26
|
+
- Wants feedback on code quality, security, architecture, or testing
|
|
27
|
+
- Asks to analyze a commit, branch, or pull request
|
|
28
|
+
|
|
29
|
+
## ⚠️ IMPORTANT: Setup Guard (Run First!)
|
|
30
|
+
|
|
31
|
+
**Before ANY OCR operation**, you MUST validate that OCR is properly set up:
|
|
32
|
+
|
|
33
|
+
1. **Read and execute `references/setup-guard.md`**
|
|
34
|
+
2. If setup validation fails → STOP and show the user the error message
|
|
35
|
+
3. If setup validation passes → Proceed with the requested operation
|
|
36
|
+
|
|
37
|
+
This prevents confusing errors and ensures users know how to fix setup issues.
|
|
38
|
+
|
|
39
|
+
## Quick Start
|
|
40
|
+
|
|
41
|
+
For immediate review of staged changes:
|
|
42
|
+
1. **Run the setup guard** (see above - this is mandatory!)
|
|
43
|
+
2. Read `references/workflow.md` for the complete 8-phase process
|
|
44
|
+
3. Begin with Phase 1: Context Discovery
|
|
45
|
+
4. Follow each phase sequentially
|
|
46
|
+
|
|
47
|
+
## Core Responsibilities
|
|
48
|
+
|
|
49
|
+
As Tech Lead, you must:
|
|
50
|
+
|
|
51
|
+
1. **Gather Requirements** - Accept and analyze any provided specs, proposals, tickets, or context
|
|
52
|
+
2. **Discover Context** - Load `.ocr/config.yaml`, pull OpenSpec context, and discover referenced files
|
|
53
|
+
3. **Understand Changes** - Analyze git diff to understand what changed and why
|
|
54
|
+
4. **Evaluate Against Requirements** - Assess whether changes meet stated requirements
|
|
55
|
+
5. **Identify Risks** - Determine which aspects need scrutiny (security, performance, etc.)
|
|
56
|
+
6. **Assign Reviewers** - Select appropriate reviewer personas based on change type
|
|
57
|
+
7. **Facilitate Discourse** - Let reviewers challenge each other's findings
|
|
58
|
+
8. **Synthesize Review** - Produce unified, prioritized, actionable feedback including requirements assessment
|
|
59
|
+
|
|
60
|
+
## Requirements Context (Flexible Input)
|
|
61
|
+
|
|
62
|
+
Reviewers need context about what the code SHOULD do. Accept requirements **flexibly**—the interface is natural language:
|
|
63
|
+
|
|
64
|
+
- **Inline**: "review this against the requirement that users must be rate-limited"
|
|
65
|
+
- **Document reference**: "see the spec at openspec/changes/add-auth/proposal.md"
|
|
66
|
+
- **Pasted text**: Bug reports, acceptance criteria, Jira descriptions
|
|
67
|
+
- **No explicit requirements**: Proceed with discovered standards + best practices
|
|
68
|
+
|
|
69
|
+
When a user references a document, **read it**. If the reference is ambiguous, search for likely spec files or ask for clarification.
|
|
70
|
+
|
|
71
|
+
**Requirements are propagated to ALL reviewer sub-agents.** Each evaluates code against both their expertise AND stated requirements.
|
|
72
|
+
|
|
73
|
+
## Clarifying Questions (Real Code Review Model)
|
|
74
|
+
|
|
75
|
+
Just like real engineers, you and all reviewers MUST surface clarifying questions:
|
|
76
|
+
|
|
77
|
+
- **Requirements Ambiguity**: "The spec says 'fast response'—what's the target latency?"
|
|
78
|
+
- **Scope Boundaries**: "Should this include rate limiting, or is that out of scope?"
|
|
79
|
+
- **Missing Criteria**: "How should edge case X be handled?"
|
|
80
|
+
- **Intentional Exclusions**: "Was feature Y intentionally left out?"
|
|
81
|
+
|
|
82
|
+
These questions are collected and surfaced prominently in the final synthesis for stakeholder response.
|
|
83
|
+
|
|
84
|
+
## Default Reviewer Team
|
|
85
|
+
|
|
86
|
+
Default team composition (with built-in redundancy):
|
|
87
|
+
|
|
88
|
+
| Reviewer | Count | Focus |
|
|
89
|
+
|----------|-------|-------|
|
|
90
|
+
| **Principal** | 2 | Architecture, patterns, maintainability |
|
|
91
|
+
| **Quality** | 2 | Code style, readability, best practices |
|
|
92
|
+
|
|
93
|
+
Optional reviewers (added based on change type or user request):
|
|
94
|
+
|
|
95
|
+
| Reviewer | Count | When Added |
|
|
96
|
+
|----------|-------|------------|
|
|
97
|
+
| **Security** | 1 | Auth, API, or data handling changes |
|
|
98
|
+
| **Testing** | 1 | Significant logic changes |
|
|
99
|
+
|
|
100
|
+
**Override via natural language**: "add security focus", "use 3 principal reviewers", "include testing"
|
|
101
|
+
|
|
102
|
+
## Reviewer Agency
|
|
103
|
+
|
|
104
|
+
Each reviewer sub-agent has **full agency** to explore the codebase as they see fit—just like a real engineer. They:
|
|
105
|
+
|
|
106
|
+
- Autonomously decide which files to examine beyond the diff
|
|
107
|
+
- Trace upstream and downstream dependencies at will
|
|
108
|
+
- Examine tests, configs, and documentation as needed
|
|
109
|
+
- Use professional judgment to determine relevance
|
|
110
|
+
|
|
111
|
+
Their persona guides their focus area but does NOT limit their exploration. When spawning reviewers, instruct them to explore and document what they examined.
|
|
112
|
+
|
|
113
|
+
## Configuration
|
|
114
|
+
|
|
115
|
+
Review `.ocr/config.yaml` for:
|
|
116
|
+
- `context`: Direct project context injected into all reviews
|
|
117
|
+
- `context_discovery`: OpenSpec integration and reference files to discover
|
|
118
|
+
- `rules`: Per-severity review rules (critical, important, consider)
|
|
119
|
+
- `default_team`: Reviewer team composition
|
|
120
|
+
|
|
121
|
+
## Workflow Summary
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
Phase 1: Context Discovery → Load config, pull OpenSpec context, discover references
|
|
125
|
+
Phase 2: Gather Change Context → git diff, understand intent
|
|
126
|
+
Phase 3: Tech Lead Analysis → Summarize, identify risks, select reviewers
|
|
127
|
+
Phase 4: Spawn Reviewers → Run each reviewer (with redundancy)
|
|
128
|
+
Phase 5: Aggregate Findings → Merge redundant reviewer runs
|
|
129
|
+
Phase 6: Discourse → Reviewers debate findings (skip with --quick)
|
|
130
|
+
Phase 7: Synthesis → Produce final prioritized review
|
|
131
|
+
Phase 8: Present → Display results (optionally post to GitHub)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
For complete workflow details, see `references/workflow.md`.
|
|
135
|
+
|
|
136
|
+
## Session Storage
|
|
137
|
+
|
|
138
|
+
All review artifacts are stored in `.ocr/sessions/{date}-{branch}/`:
|
|
139
|
+
- `context.md` - Change summary
|
|
140
|
+
- `requirements.md` - User-provided requirements/specs (if any)
|
|
141
|
+
- `discovered-standards.md` - Merged project context
|
|
142
|
+
- `reviews/{reviewer}-{n}.md` - Individual reviews
|
|
143
|
+
- `discourse.md` - Discourse results
|
|
144
|
+
- `final.md` - Synthesized final review
|
|
145
|
+
|
|
146
|
+
## Commands
|
|
147
|
+
|
|
148
|
+
Available slash commands (format varies by tool):
|
|
149
|
+
|
|
150
|
+
| Action | Windsurf | Claude Code / Others |
|
|
151
|
+
|--------|----------|---------------------|
|
|
152
|
+
| Run code review | `/ocr-review` | `/ocr:review` |
|
|
153
|
+
| Check installation | `/ocr-doctor` | `/ocr:doctor` |
|
|
154
|
+
| List reviewers | `/ocr-reviewers` | `/ocr:reviewers` |
|
|
155
|
+
| List sessions | `/ocr-history` | `/ocr:history` |
|
|
156
|
+
| Show past review | `/ocr-show` | `/ocr:show` |
|
|
157
|
+
| Post to GitHub | `/ocr-post` | `/ocr:post` |
|
|
158
|
+
|
|
159
|
+
**Why two formats?**
|
|
160
|
+
- **Windsurf** requires flat files with prefix → `/ocr-command`
|
|
161
|
+
- **Claude Code, Cursor, etc.** support subdirectories → `/ocr:command`
|
|
162
|
+
|
|
163
|
+
Both invoke the same underlying functionality.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Open Code Review Configuration
|
|
2
|
+
# This file is installed to .ocr/config.yaml and customized per-project.
|
|
3
|
+
# Context here is injected into every review request.
|
|
4
|
+
|
|
5
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
6
|
+
# PROJECT CONTEXT
|
|
7
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
8
|
+
# Injected into ALL review requests. Keep it tight—focus on what reviewers
|
|
9
|
+
# genuinely need to know that isn't obvious from the code itself.
|
|
10
|
+
|
|
11
|
+
# context: |
|
|
12
|
+
# Tech stack: TypeScript, React, Node.js, PostgreSQL
|
|
13
|
+
# Architecture: Monorepo with NX, ESM only
|
|
14
|
+
# Testing: Jest + React Testing Library, mock only external services
|
|
15
|
+
# Critical constraint: All public APIs must be backwards compatible
|
|
16
|
+
|
|
17
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
18
|
+
# CONTEXT DISCOVERY
|
|
19
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
20
|
+
# Files to read during Phase 1 (Context Discovery). OCR merges these into
|
|
21
|
+
# the review context automatically.
|
|
22
|
+
|
|
23
|
+
context_discovery:
|
|
24
|
+
# OpenSpec integration - pull project context and active specs
|
|
25
|
+
openspec:
|
|
26
|
+
enabled: true
|
|
27
|
+
config: "openspec/config.yaml" # Project conventions from OpenSpec
|
|
28
|
+
specs: "openspec/specs/**/*.md" # Merged specs for architectural context
|
|
29
|
+
active_changes: "openspec/changes/**/*.md" # In-flight change proposals
|
|
30
|
+
|
|
31
|
+
# AI assistant configuration files (auto-detected)
|
|
32
|
+
references:
|
|
33
|
+
- "AGENTS.md"
|
|
34
|
+
- "CLAUDE.md"
|
|
35
|
+
- ".cursorrules"
|
|
36
|
+
- ".windsurfrules"
|
|
37
|
+
- ".github/copilot-instructions.md"
|
|
38
|
+
- "CONTRIBUTING.md"
|
|
39
|
+
|
|
40
|
+
# Additional project-specific files to include
|
|
41
|
+
# additional:
|
|
42
|
+
# - "docs/ARCHITECTURE.md"
|
|
43
|
+
# - "docs/API_STANDARDS.md"
|
|
44
|
+
|
|
45
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
46
|
+
# REVIEW RULES
|
|
47
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
48
|
+
# Per-severity rules for reviewers. Only add what's not obvious.
|
|
49
|
+
|
|
50
|
+
# rules:
|
|
51
|
+
# critical:
|
|
52
|
+
# - Security vulnerabilities (injection, path traversal, secrets in code)
|
|
53
|
+
# - Breaking changes without migration path
|
|
54
|
+
# - Data loss or corruption risks
|
|
55
|
+
# important:
|
|
56
|
+
# - Silent error handling (catch without action)
|
|
57
|
+
# - Missing user-facing error messages
|
|
58
|
+
# - Performance regressions in hot paths
|
|
59
|
+
# consider:
|
|
60
|
+
# - Naming consistency
|
|
61
|
+
# - Documentation gaps
|
|
62
|
+
# - Test coverage for edge cases
|
|
63
|
+
|
|
64
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
65
|
+
# REVIEWER TEAM
|
|
66
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
67
|
+
|
|
68
|
+
default_team:
|
|
69
|
+
principal: 2 # Holistic architecture review
|
|
70
|
+
quality: 2 # Code quality and maintainability
|
|
71
|
+
# security: 1 # Auto-added for auth/API/data changes
|
|
72
|
+
# testing: 1 # Auto-added for logic-heavy changes
|
|
73
|
+
|
|
74
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
75
|
+
# OUTPUT & WORKFLOW
|
|
76
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
77
|
+
|
|
78
|
+
output:
|
|
79
|
+
session_dir: ".ocr/sessions"
|
|
80
|
+
|
|
81
|
+
discourse:
|
|
82
|
+
enabled: true # Set false or use --quick to skip reviewer debate phase
|
|
83
|
+
|
|
84
|
+
github:
|
|
85
|
+
auto_prompt_post: false
|
|
86
|
+
comment_format: "single" # "single" or "inline"
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# OCR Session Directory .gitignore
|
|
2
|
+
# Copy this to .ocr/.gitignore to exclude review sessions from git
|
|
3
|
+
|
|
4
|
+
# Exclude all session data by default
|
|
5
|
+
sessions/
|
|
6
|
+
|
|
7
|
+
# Or selectively include/exclude:
|
|
8
|
+
# sessions/*
|
|
9
|
+
# !sessions/important-review/
|
|
10
|
+
|
|
11
|
+
# Keep the directory structure
|
|
12
|
+
!.gitignore
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# {Reviewer Name} Reviewer
|
|
2
|
+
|
|
3
|
+
You are a **{Role Title}** conducting a code review. {Brief description of expertise and perspective.}
|
|
4
|
+
|
|
5
|
+
## Your Focus Areas
|
|
6
|
+
|
|
7
|
+
- **{Area 1}**: {Description of what you look for}
|
|
8
|
+
- **{Area 2}**: {Description of what you look for}
|
|
9
|
+
- **{Area 3}**: {Description of what you look for}
|
|
10
|
+
- **{Area 4}**: {Description of what you look for}
|
|
11
|
+
|
|
12
|
+
## Your Review Approach
|
|
13
|
+
|
|
14
|
+
1. **{Step 1}** — {How you start your review}
|
|
15
|
+
2. **{Step 2}** — {What you examine next}
|
|
16
|
+
3. **{Step 3}** — {How you evaluate}
|
|
17
|
+
4. **{Step 4}** — {How you conclude}
|
|
18
|
+
|
|
19
|
+
## What You Look For
|
|
20
|
+
|
|
21
|
+
### {Category 1}
|
|
22
|
+
- {Specific thing to check}
|
|
23
|
+
- {Specific thing to check}
|
|
24
|
+
- {Specific thing to check}
|
|
25
|
+
|
|
26
|
+
### {Category 2}
|
|
27
|
+
- {Specific thing to check}
|
|
28
|
+
- {Specific thing to check}
|
|
29
|
+
- {Specific thing to check}
|
|
30
|
+
|
|
31
|
+
### {Category 3}
|
|
32
|
+
- {Specific thing to check}
|
|
33
|
+
- {Specific thing to check}
|
|
34
|
+
- {Specific thing to check}
|
|
35
|
+
|
|
36
|
+
## Your Output Style
|
|
37
|
+
|
|
38
|
+
- **{Guideline 1}** — {Explanation}
|
|
39
|
+
- **{Guideline 2}** — {Explanation}
|
|
40
|
+
- **{Guideline 3}** — {Explanation}
|
|
41
|
+
- **{Guideline 4}** — {Explanation}
|
|
42
|
+
|
|
43
|
+
## Agency Reminder
|
|
44
|
+
|
|
45
|
+
You have **full agency** to explore the codebase. {Specific guidance on what this reviewer should explore beyond the diff.} Document what you explored and why.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Example Custom Reviewers
|
|
50
|
+
|
|
51
|
+
### Performance Engineer
|
|
52
|
+
Focus on: Response times, memory usage, database queries, caching, algorithm efficiency
|
|
53
|
+
|
|
54
|
+
### Accessibility Engineer
|
|
55
|
+
Focus on: WCAG compliance, screen reader support, keyboard navigation, color contrast
|
|
56
|
+
|
|
57
|
+
### DevOps Engineer
|
|
58
|
+
Focus on: Deployment impact, infrastructure changes, monitoring, logging, rollback safety
|
|
59
|
+
|
|
60
|
+
### Domain Expert (e.g., Payments)
|
|
61
|
+
Focus on: Business logic correctness, compliance requirements, edge cases specific to the domain
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Tips for Creating Custom Reviewers
|
|
66
|
+
|
|
67
|
+
1. **Be specific about focus** — Vague reviewers give vague feedback
|
|
68
|
+
2. **Define the mental model** — How should this reviewer think about code?
|
|
69
|
+
3. **List concrete things to check** — Give actionable guidance
|
|
70
|
+
4. **Set output expectations** — What kind of findings matter most?
|
|
71
|
+
5. **Encourage exploration** — Remind them to use their agency
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# Context Discovery
|
|
2
|
+
|
|
3
|
+
Algorithm for building review context from OCR config, OpenSpec, and discovered files.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Context discovery builds a comprehensive review context by:
|
|
8
|
+
1. Reading `.ocr/config.yaml` for project-specific context and rules
|
|
9
|
+
2. Pulling OpenSpec context and specs (if enabled)
|
|
10
|
+
3. Discovering referenced files (AGENTS.md, CLAUDE.md, etc.)
|
|
11
|
+
4. Merging everything with attribution
|
|
12
|
+
|
|
13
|
+
## Discovery Sources (Priority Order)
|
|
14
|
+
|
|
15
|
+
### Priority 1: OCR Config (Highest)
|
|
16
|
+
|
|
17
|
+
Direct context from `.ocr/config.yaml`:
|
|
18
|
+
|
|
19
|
+
```yaml
|
|
20
|
+
context: |
|
|
21
|
+
Tech stack: TypeScript, React, Node.js
|
|
22
|
+
Critical constraint: All public APIs must be backwards compatible
|
|
23
|
+
|
|
24
|
+
rules:
|
|
25
|
+
critical:
|
|
26
|
+
- Security vulnerabilities
|
|
27
|
+
- Breaking changes without migration
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Priority 2: OpenSpec Integration
|
|
31
|
+
|
|
32
|
+
If `context_discovery.openspec.enabled: true`:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
openspec/config.yaml # Project conventions
|
|
36
|
+
openspec/specs/**/*.md # Architectural specs
|
|
37
|
+
openspec/changes/**/*.md # Active change proposals
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Priority 3: Reference Files
|
|
41
|
+
|
|
42
|
+
Files listed in `context_discovery.references`:
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
AGENTS.md
|
|
46
|
+
CLAUDE.md
|
|
47
|
+
.cursorrules
|
|
48
|
+
.windsurfrules
|
|
49
|
+
.github/copilot-instructions.md
|
|
50
|
+
CONTRIBUTING.md
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Priority 4: Additional Files
|
|
54
|
+
|
|
55
|
+
User-configured files in `context_discovery.additional`:
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
docs/ARCHITECTURE.md
|
|
59
|
+
docs/API_STANDARDS.md
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Discovery Algorithm
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
def discover_context():
|
|
66
|
+
config = read_yaml('.ocr/config.yaml')
|
|
67
|
+
discovered = []
|
|
68
|
+
|
|
69
|
+
# Priority 1: OCR config context
|
|
70
|
+
if config.get('context'):
|
|
71
|
+
discovered.append({
|
|
72
|
+
'source': '.ocr/config.yaml (context)',
|
|
73
|
+
'priority': 1,
|
|
74
|
+
'content': config['context']
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
if config.get('rules'):
|
|
78
|
+
discovered.append({
|
|
79
|
+
'source': '.ocr/config.yaml (rules)',
|
|
80
|
+
'priority': 1,
|
|
81
|
+
'content': format_rules(config['rules'])
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
# Priority 2: OpenSpec
|
|
85
|
+
openspec = config.get('context_discovery', {}).get('openspec', {})
|
|
86
|
+
if openspec.get('enabled', True):
|
|
87
|
+
if exists('openspec/config.yaml'):
|
|
88
|
+
os_config = read_yaml('openspec/config.yaml')
|
|
89
|
+
if os_config.get('context'):
|
|
90
|
+
discovered.append({
|
|
91
|
+
'source': 'openspec/config.yaml',
|
|
92
|
+
'priority': 2,
|
|
93
|
+
'content': os_config['context']
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
# Read specs for architectural context
|
|
97
|
+
for spec in glob('openspec/specs/**/*.md'):
|
|
98
|
+
discovered.append({
|
|
99
|
+
'source': spec,
|
|
100
|
+
'priority': 2,
|
|
101
|
+
'content': read(spec)
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
# Priority 3: Reference files
|
|
105
|
+
refs = config.get('context_discovery', {}).get('references', [])
|
|
106
|
+
for file in refs:
|
|
107
|
+
if exists(file):
|
|
108
|
+
discovered.append({
|
|
109
|
+
'source': file,
|
|
110
|
+
'priority': 3,
|
|
111
|
+
'content': read(file)
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
return merge_with_attribution(discovered)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Shell Commands for Discovery
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
# Read OCR config
|
|
121
|
+
cat .ocr/config.yaml
|
|
122
|
+
|
|
123
|
+
# Check OpenSpec
|
|
124
|
+
cat openspec/config.yaml 2>/dev/null
|
|
125
|
+
find openspec/specs -name "*.md" -type f 2>/dev/null
|
|
126
|
+
|
|
127
|
+
# Check reference files
|
|
128
|
+
for f in AGENTS.md CLAUDE.md .cursorrules .windsurfrules CONTRIBUTING.md; do
|
|
129
|
+
[ -f "$f" ] && cat "$f"
|
|
130
|
+
done
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Output Format
|
|
134
|
+
|
|
135
|
+
Save discovered context to session directory:
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
.ocr/sessions/{id}/discovered-standards.md
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Example Output
|
|
142
|
+
|
|
143
|
+
```markdown
|
|
144
|
+
# Discovered Project Standards
|
|
145
|
+
|
|
146
|
+
**Discovery Date**: 2024-01-15
|
|
147
|
+
**Sources Found**: 4
|
|
148
|
+
|
|
149
|
+
## From: .ocr/config.yaml (context)
|
|
150
|
+
|
|
151
|
+
Tech stack: TypeScript, React, Node.js
|
|
152
|
+
Critical constraint: All public APIs must be backwards compatible
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## From: openspec/config.yaml
|
|
157
|
+
|
|
158
|
+
context: |
|
|
159
|
+
Monorepo using NX 22
|
|
160
|
+
ESM only, no CommonJS
|
|
161
|
+
Testing: Jest with React Testing Library
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## From: AGENTS.md
|
|
166
|
+
|
|
167
|
+
# Agent Instructions
|
|
168
|
+
...
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Review Rules (from .ocr/config.yaml)
|
|
173
|
+
|
|
174
|
+
### Critical
|
|
175
|
+
- Security vulnerabilities (injection, path traversal, secrets in code)
|
|
176
|
+
- Breaking changes without migration path
|
|
177
|
+
|
|
178
|
+
### Important
|
|
179
|
+
- Silent error handling (catch without action)
|
|
180
|
+
- Missing user-facing error messages
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## No Context Found
|
|
184
|
+
|
|
185
|
+
If no config exists:
|
|
186
|
+
|
|
187
|
+
1. Use sensible defaults
|
|
188
|
+
2. Suggest configuration:
|
|
189
|
+
```
|
|
190
|
+
💡 Tip: Run `ocr init` to create .ocr/config.yaml for project-specific review context.
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Performance
|
|
194
|
+
|
|
195
|
+
- Cache discovered context in session directory
|
|
196
|
+
- Reuse for all reviewers in same session
|
|
197
|
+
- Only re-discover on new session
|