@open-code-review/agents 1.3.0 → 1.4.0

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.
@@ -12,6 +12,15 @@ Every OCR session creates files in `.ocr/sessions/{session-id}/`:
12
12
  ├── discovered-standards.md # Merged project context (shared across rounds)
13
13
  ├── requirements.md # User-provided requirements (if any, shared)
14
14
  ├── context.md # Phase 2+3: Change summary + Tech Lead guidance (shared)
15
+ ├── map/ # Code Review Map artifacts (optional)
16
+ │ └── runs/
17
+ │ ├── run-1/ # First map generation
18
+ │ │ ├── topology.md # File categorization and sections
19
+ │ │ ├── flow-analysis.md # Dependency tracing results
20
+ │ │ ├── requirements-mapping.md # Coverage matrix (if requirements)
21
+ │ │ └── map.md # Final map output
22
+ │ └── run-2/ # Subsequent runs (created on re-map)
23
+ │ └── ... # Same structure as run-1
15
24
  └── rounds/ # All round-specific artifacts
16
25
  ├── round-1/ # First review round
17
26
  │ ├── reviews/ # Individual reviewer outputs
@@ -42,19 +51,43 @@ OCR uses a **round-first architecture** where all round-specific artifacts live
42
51
  - Each round has its own `discourse.md` and `final.md`
43
52
  - `state.json` tracks `current_round`; round metadata derived from filesystem
44
53
 
45
- **Shared vs per-round artifacts**:
46
- | Shared (session root) | Per-round (`rounds/round-{n}/`) |
47
- |----------------------|--------------------------------|
48
- | `state.json` | `reviews/*.md` |
49
- | `discovered-standards.md` | `discourse.md` |
50
- | `requirements.md` | `final.md` |
51
- | `context.md` | |
54
+ **Shared vs per-round/run artifacts**:
55
+ | Shared (session root) | Per-round (`rounds/round-{n}/`) | Per-run (`map/runs/run-{n}/`) |
56
+ |----------------------|--------------------------------|-------------------------------|
57
+ | `state.json` | `reviews/*.md` | `topology.md` |
58
+ | `discovered-standards.md` | `discourse.md` | `flow-analysis.md` |
59
+ | `requirements.md` | `final.md` | `requirements-mapping.md` |
60
+ | `context.md` | | `map.md` |
52
61
 
53
62
  **When to use multiple rounds**:
54
63
  - Author addresses feedback and requests re-review
55
64
  - Scope changes mid-review
56
65
  - Different reviewer team composition needed
57
66
 
67
+ ## Map Runs
68
+
69
+ OCR uses a **run-based architecture** for maps, parallel to review rounds.
70
+
71
+ **Run behavior**:
72
+ - First `/ocr-map` creates `map/runs/run-1/` with map artifacts
73
+ - Subsequent `/ocr-map` on same day/branch creates `map/runs/run-{n+1}/`
74
+ - Previous runs are preserved (never overwritten)
75
+ - Each run produces a complete `map.md`
76
+ - `state.json` tracks `current_map_run`; run metadata derived from filesystem
77
+
78
+ **Map artifacts per run**:
79
+ | File | Phase | Description |
80
+ |------|-------|-------------|
81
+ | `topology.md` | 2 | File categorization and section groupings |
82
+ | `flow-analysis.md` | 3 | Upstream/downstream dependency tracing |
83
+ | `requirements-mapping.md` | 4 | Requirements coverage matrix (if requirements provided) |
84
+ | `map.md` | 5 | Final synthesized Code Review Map |
85
+
86
+ **When to use multiple runs**:
87
+ - Changeset has evolved since last map
88
+ - Different requirements context needed
89
+ - Fresh analysis desired after code updates
90
+
58
91
  ## File Specifications
59
92
 
60
93
  ### Required Files
@@ -192,7 +225,7 @@ Must include:
192
225
  - Clarifying Questions section
193
226
  - Individual Reviews table with file references
194
227
 
195
- See `references/synthesis.md` for complete template.
228
+ See `references/final-template.md` for complete template.
196
229
 
197
230
  ## CLI Dependencies
198
231
 
@@ -23,28 +23,38 @@ This means:
23
23
  ```json
24
24
  {
25
25
  "session_id": "{session-id}",
26
+ "workflow_type": "review",
26
27
  "status": "active",
27
28
  "current_phase": "reviews",
28
29
  "phase_number": 4,
29
30
  "current_round": 1,
31
+ "current_map_run": 1,
30
32
  "started_at": "{ISO-8601-TIMESTAMP}",
31
33
  "round_started_at": "{ISO-8601-TIMESTAMP}",
34
+ "map_started_at": "{ISO-8601-TIMESTAMP}",
32
35
  "updated_at": "{ISO-8601-TIMESTAMP}"
33
36
  }
34
37
  ```
35
38
 
36
- **Minimal by design**: Round metadata is derived from the filesystem, not stored in state.json.
39
+ **Minimal by design**: Round and map run metadata is derived from the filesystem, not stored in state.json.
37
40
 
38
41
  **Field descriptions**:
39
- - `started_at`: When the session was created (first `/ocr-review`)
40
- - `round_started_at`: When the current round began (updated when starting round > 1)
42
+ - `workflow_type`: Current workflow type (`"review"` or `"map"`) — enables `ocr progress` to track correct workflow
43
+ - `started_at`: When the session was created (first `/ocr-review` or `/ocr-map`)
44
+ - `round_started_at`: When the current review round began (set when starting round ≥ 1)
45
+ - `map_started_at`: When the current map run began (set when starting a map run)
46
+ - `current_map_run`: Current map run number (only present during map workflow)
41
47
  - `updated_at`: Last modification time (updated at every phase transition)
42
48
 
49
+ **CRITICAL for timing**: When starting a NEW workflow type in an existing session (e.g., starting `/ocr-map` after `/ocr-review`), you MUST set the workflow-specific start time (`map_started_at` or `round_started_at`) to the current timestamp. This ensures `ocr progress` shows accurate elapsed time for each workflow.
50
+
43
51
  **Derived from filesystem** (not stored):
44
52
  - Round count: enumerate `rounds/round-*/` directories
45
53
  - Round completion: check for `final.md` in round directory
46
54
  - Reviewers in round: list files in `rounds/round-{n}/reviews/`
47
55
  - Discourse complete: check for `discourse.md` in round directory
56
+ - Map run count: enumerate `map/runs/run-*/` directories
57
+ - Map run completion: check for `map.md` in run directory
48
58
 
49
59
  **IMPORTANT**: Timestamps MUST be generated dynamically using the current time in ISO 8601 format (e.g., `new Date().toISOString()` → `"2026-01-27T09:45:00.000Z"`). Do NOT copy example timestamps.
50
60
 
@@ -70,6 +80,8 @@ The `ocr progress` command only auto-detects sessions with `status: "active"`. C
70
80
 
71
81
  The Tech Lead MUST update `state.json` at each phase boundary:
72
82
 
83
+ ### Review Phases
84
+
73
85
  | Phase | When to Update | File Created |
74
86
  |-------|---------------|--------------|
75
87
  | context | After writing project standards | `discovered-standards.md` |
@@ -80,24 +92,42 @@ The Tech Lead MUST update `state.json` at each phase boundary:
80
92
  | synthesis | After final review | `rounds/round-{n}/final.md` |
81
93
  | complete | After presenting to user | Set `status: "closed"` |
82
94
 
95
+ ### Map Phases
96
+
97
+ | Phase | When to Update | File Created |
98
+ |-------|---------------|--------------|
99
+ | map-context | After writing project standards | `discovered-standards.md` (shared) |
100
+ | topology | After topology analysis | `map/runs/run-{n}/topology.md` |
101
+ | flow-analysis | After flow analysis | `map/runs/run-{n}/flow-analysis.md` |
102
+ | requirements-mapping | After requirements mapping | `map/runs/run-{n}/requirements-mapping.md` |
103
+ | synthesis | After map generation | `map/runs/run-{n}/map.md` |
104
+ | complete | After presenting map | Keep `status: "active"` (session continues) |
105
+
83
106
  ## Writing State
84
107
 
85
- **CRITICAL**: Always generate timestamps dynamically using the current UTC time in ISO 8601 format.
108
+ **CRITICAL**: Always generate timestamps using a **tool call** never construct them manually.
86
109
 
87
110
  ### Generating Timestamps
88
111
 
112
+ > ⚠️ **NEVER** write timestamps manually (e.g., `"2026-01-29T22:00:00Z"`). Always use a tool call to get the current time. Manual timestamps risk timezone errors, typos, and incorrect elapsed time display.
113
+
114
+ **Required approach**: Use `run_command` tool to execute:
115
+
89
116
  ```bash
90
- # macOS/Linux
117
+ # macOS/Linux — USE THIS
91
118
  date -u +"%Y-%m-%dT%H:%M:%SZ"
92
119
  # Output: 2026-01-27T09:45:00Z
120
+ ```
93
121
 
94
- # Windows (PowerShell)
95
- Get-Date -Format "yyyy-MM-ddTHH:mm:ssZ" -AsUTC
96
-
97
- # Node.js / JavaScript
98
- new Date().toISOString()
122
+ **Example tool call** (do this before writing state.json):
123
+ ```
124
+ run_command: date -u +"%Y-%m-%dT%H:%M:%SZ"
99
125
  ```
100
126
 
127
+ Then use the **exact output** as the timestamp value in state.json.
128
+
129
+ **Why this matters**: The `ocr progress` command calculates elapsed time from these timestamps. If a timestamp is incorrect (wrong timezone, future time, etc.), the progress display will show wrong/counting-down times.
130
+
101
131
  When creating a new session (Phase 1 start):
102
132
 
103
133
  ```json
@@ -117,15 +147,35 @@ When transitioning phases (preserve `started_at`, update `updated_at`):
117
147
  ```json
118
148
  {
119
149
  "session_id": "{session-id}",
150
+ "workflow_type": "review",
120
151
  "status": "active",
121
152
  "current_phase": "reviews",
122
153
  "phase_number": 4,
123
154
  "current_round": 1,
124
155
  "started_at": "{PRESERVE_ORIGINAL}",
156
+ "round_started_at": "{PRESERVE_ORIGINAL}",
157
+ "updated_at": "{CURRENT_ISO_TIMESTAMP}"
158
+ }
159
+ ```
160
+
161
+ When starting a map workflow (new map run or first map in session):
162
+
163
+ ```json
164
+ {
165
+ "session_id": "{session-id}",
166
+ "workflow_type": "map",
167
+ "status": "active",
168
+ "current_phase": "map-context",
169
+ "phase_number": 1,
170
+ "current_map_run": 1,
171
+ "started_at": "{PRESERVE_ORIGINAL_OR_SET_IF_NEW}",
172
+ "map_started_at": "{CURRENT_ISO_TIMESTAMP}",
125
173
  "updated_at": "{CURRENT_ISO_TIMESTAMP}"
126
174
  }
127
175
  ```
128
176
 
177
+ **CRITICAL**: Always set `map_started_at` to `{CURRENT_ISO_TIMESTAMP}` when starting a new map run. This ensures accurate elapsed time tracking even if the session had a prior review workflow.
178
+
129
179
  When closing a session (Phase 8 complete):
130
180
 
131
181
  ```json
@@ -13,8 +13,9 @@ Before starting ANY work, verify the current session state to avoid duplicating
13
13
  ### Step 1: Check for existing session
14
14
 
15
15
  ```bash
16
- # Get current branch
17
- BRANCH=$(git branch --show-current)
16
+ # Get current branch and sanitize for filesystem (replace / with -)
17
+ BRANCH_RAW=$(git branch --show-current)
18
+ BRANCH=$(echo "$BRANCH_RAW" | tr '/' '-')
18
19
  DATE=$(date +%Y-%m-%d)
19
20
  SESSION_DIR=".ocr/sessions/${DATE}-${BRANCH}"
20
21
 
@@ -113,7 +114,13 @@ At **every phase transition**, update `.ocr/sessions/{id}/state.json`:
113
114
 
114
115
  **Minimal schema** — round metadata is derived from filesystem, not stored in state.json.
115
116
 
116
- **CRITICAL**: Generate timestamps dynamically (e.g., `date -u +"%Y-%m-%dT%H:%M:%SZ"` on macOS/Linux). Preserve `started_at` from session creation; set `round_started_at` when starting a new round (> 1); always update `updated_at` with current time.
117
+ > ⚠️ **TIMESTAMP RULE**: Always use `run_command` tool to get timestamps. **Never construct them manually.**
118
+ > ```bash
119
+ > date -u +"%Y-%m-%dT%H:%M:%SZ"
120
+ > ```
121
+ > Use the **exact output** in state.json. Manual timestamps cause incorrect `ocr progress` display.
122
+
123
+ **CRITICAL**: Preserve `started_at` from session creation; set `round_started_at` when starting a new round (> 1); always update `updated_at` with current time.
117
124
 
118
125
  **Status values**: `active` (in progress), `closed` (complete and dismissed)
119
126
 
@@ -315,18 +322,33 @@ See `references/context-discovery.md` for detailed algorithm.
315
322
 
316
323
  ### Steps
317
324
 
318
- 1. Review requirements (if provided):
325
+ 1. **Check for existing map reference** (optional):
326
+
327
+ If user explicitly references an existing map (e.g., "I've already generated a map", "use the map I created", "check the map in this session"):
328
+
329
+ ```bash
330
+ # Check for existing map artifacts
331
+ ls .ocr/sessions/{id}/map/runs/*/map.md 2>/dev/null
332
+ ```
333
+
334
+ - **If found AND user referenced it**: Read the latest `map.md` as supplementary context
335
+ - **If not found**: Inform user no map exists, proceed with standard review
336
+ - **If user did NOT reference a map**: Do NOT automatically use map artifacts
337
+
338
+ > **Note**: Maps are orthogonal tools. Only use if explicitly referenced by user.
339
+
340
+ 2. Review requirements (if provided):
319
341
  - What is the code SUPPOSED to do?
320
342
  - What are the acceptance criteria?
321
343
  - What edge cases are implied?
322
344
 
323
- 2. Analyze the diff to understand:
345
+ 3. Analyze the diff to understand:
324
346
  - What functionality is being added/changed/removed?
325
347
  - Does this align with requirements?
326
348
  - What is the likely intent?
327
349
  - What are the potential risk areas?
328
350
 
329
- 3. Create dynamic guidance for reviewers:
351
+ 4. Create dynamic guidance for reviewers:
330
352
  ```markdown
331
353
  ## Tech Lead Guidance
332
354
 
@@ -360,18 +382,36 @@ See `references/context-discovery.md` for detailed algorithm.
360
382
  - Verify rate limiting is implemented
361
383
  ```
362
384
 
363
- 4. Select reviewers:
385
+ 4. **Read reviewer team from config** (REQUIRED):
386
+
387
+ ```bash
388
+ # MUST read default_team from .ocr/config.yaml - do NOT use hardcoded values
389
+ cat .ocr/config.yaml | grep -A10 'default_team:'
390
+ ```
364
391
 
365
- **Default team** (always spawned):
366
- - 2× Principal (holistic architecture review)
367
- - Quality (code quality review)
392
+ Parse the `default_team` section to determine reviewer counts:
393
+ ```yaml
394
+ # Example config - actual values come from .ocr/config.yaml
395
+ default_team:
396
+ principal: 2 # Spawn principal-1, principal-2
397
+ quality: 2 # Spawn quality-1, quality-2
398
+ # security: 1 # Commented = not spawned by default
399
+ testing: 1 # Spawn testing-1
400
+ ```
401
+
402
+ **Reviewer spawning rules**:
403
+ - For each uncommented entry in `default_team`, spawn N instances
404
+ - `principal: 2` → spawn `principal-1`, `principal-2`
405
+ - `quality: 2` → spawn `quality-1`, `quality-2`
406
+ - `testing: 1` → spawn `testing-1`
407
+ - Commented entries (e.g., `# security: 1`) are NOT spawned unless auto-detected
368
408
 
369
- **Optional reviewers** (added based on change type or user request):
409
+ **Auto-detection** (adds reviewers beyond config):
370
410
  | Change Type | Additional Reviewers |
371
411
  |-------------|---------------------|
372
412
  | Auth/Security changes | + 1× Security |
373
413
  | API changes | + 1× Security |
374
- | Logic changes | + 1× Testing |
414
+ | Logic changes | + 1× Testing (if not in config) |
375
415
  | User says "add security" | + 1× Security |
376
416
 
377
417
  ---
@@ -380,24 +420,40 @@ See `references/context-discovery.md` for detailed algorithm.
380
420
 
381
421
  **Goal**: Run each reviewer independently with configured redundancy.
382
422
 
423
+ > **⚠️ CRITICAL**: Reviewer counts and types come from `.ocr/config.yaml` `default_team` section.
424
+ > Do NOT use hardcoded defaults. Do NOT skip the `-{n}` suffix in filenames.
425
+ > See `references/session-files.md` for authoritative file naming.
426
+
383
427
  ### Steps
384
428
 
385
429
  1. Load reviewer personas from `references/reviewers/`.
386
430
 
387
- 2. Spawn tasks based on default team + detected needs:
388
- ```
389
- # Default team (always)
390
- Spawn Task: principal-1
391
- Spawn Task: principal-2
392
- Spawn Task: quality-1
393
- Spawn Task: quality-2
431
+ 2. **Parse `default_team` from config** (already read in Phase 3):
432
+
433
+ For each reviewer type in config, spawn the specified number of instances:
394
434
 
395
- # Optional (if auth/API/data changes OR user requested)
396
- Spawn Task: security-1
435
+ ```bash
436
+ # Example: If config says principal: 2, quality: 2, testing: 1
437
+ # You MUST spawn exactly these reviewers with numbered suffixes:
438
+
439
+ # From default_team.principal: 2
440
+ → Create: rounds/round-$CURRENT_ROUND/reviews/principal-1.md
441
+ → Create: rounds/round-$CURRENT_ROUND/reviews/principal-2.md
442
+
443
+ # From default_team.quality: 2
444
+ → Create: rounds/round-$CURRENT_ROUND/reviews/quality-1.md
445
+ → Create: rounds/round-$CURRENT_ROUND/reviews/quality-2.md
397
446
 
398
- # Optional (if logic changes OR user requested)
399
- Spawn Task: testing-1
447
+ # From default_team.testing: 1
448
+ Create: rounds/round-$CURRENT_ROUND/reviews/testing-1.md
449
+
450
+ # Auto-detected (if applicable)
451
+ → Create: rounds/round-$CURRENT_ROUND/reviews/security-1.md
400
452
  ```
453
+
454
+ **File naming pattern**: `{type}-{n}.md` where n starts at 1.
455
+
456
+ Examples: `principal-1.md`, `principal-2.md`, `quality-1.md`, `quality-2.md`, `testing-1.md`
401
457
 
402
458
  3. Each task receives:
403
459
  - Reviewer persona (from `references/reviewers/{name}.md`)
@@ -411,12 +467,38 @@ See `references/context-discovery.md` for detailed algorithm.
411
467
 
412
468
  See `references/reviewer-task.md` for the task template.
413
469
 
414
- ### ✅ Phase 4 Checkpoint
470
+ ### ✅ Phase 4 Checkpoint — MANDATORY VALIDATION
471
+
472
+ **Run this validation command before proceeding:**
473
+
474
+ ```bash
475
+ # Set these based on your current session
476
+ SESSION_DIR=".ocr/sessions/$(ls -1t .ocr/sessions/ | head -1)"
477
+ CURRENT_ROUND=$(ls -1d "$SESSION_DIR/rounds/round-"* 2>/dev/null | wc -l | tr -d ' ')
478
+ REVIEWS_DIR="$SESSION_DIR/rounds/round-$CURRENT_ROUND/reviews"
479
+
480
+ echo "Validating: $REVIEWS_DIR"
481
+ ls -la "$REVIEWS_DIR/"
482
+
483
+ # Verify all files match {type}-{n}.md pattern (principal, quality, security, testing)
484
+ for f in "$REVIEWS_DIR/"*.md; do
485
+ if [[ "$(basename "$f")" =~ ^(principal|quality|security|testing)-[0-9]+\.md$ ]]; then
486
+ echo "✓ $(basename "$f")"
487
+ else
488
+ echo "❌ $(basename "$f") does not match {type}-{n}.md pattern"
489
+ exit 1
490
+ fi
491
+ done
492
+
493
+ REVIEWER_COUNT=$(ls -1 "$REVIEWS_DIR/"*.md 2>/dev/null | wc -l | tr -d ' ')
494
+ echo "✓ Found $REVIEWER_COUNT reviewer files"
495
+ ```
415
496
 
416
497
  **STOP and verify before proceeding:**
417
- - [ ] At least 4 review files exist in `rounds/round-{n}/reviews/` directory
418
- - [ ] Each review file contains findings (even if "no issues found")
419
- - [ ] File naming follows `{type}-{n}.md` pattern (e.g., `principal-1.md`, `quality-2.md`)
498
+ - [ ] Review files exist for EACH entry in `default_team` config
499
+ - [ ] File count matches sum of all `default_team` values
500
+ - [ ] All files use `{type}-{n}.md` pattern
501
+ - [ ] Each review file contains findings
420
502
 
421
503
  ---
422
504
 
@@ -477,7 +559,11 @@ See `references/discourse.md` for detailed instructions.
477
559
 
478
560
  ## Phase 7: Synthesis
479
561
 
480
- **Goal**: Produce final prioritized review.
562
+ **Goal**: Produce final prioritized review and save to **`final.md`**.
563
+
564
+ > **File**: `rounds/round-{n}/final.md`
565
+ > **Template**: See `references/final-template.md` for format
566
+ > **Manifest**: See `references/session-files.md` for authoritative file names
481
567
 
482
568
  ### Steps
483
569
 
@@ -511,14 +597,45 @@ See `references/discourse.md` for detailed instructions.
511
597
 
512
598
  These go in a prominent "Clarifying Questions" section for stakeholder response.
513
599
 
514
- 7. Save to `.ocr/sessions/{id}/rounds/round-{current_round}/final.md`.
600
+ 7. **Write the final review file**:
601
+ ```bash
602
+ # OUTPUT FILE - must be exactly this path:
603
+ FINAL_FILE="$SESSION_DIR/rounds/round-$CURRENT_ROUND/final.md"
604
+ ```
605
+
606
+ Save synthesized review to `$FINAL_FILE`.
607
+
608
+ See `references/final-template.md` for the template format.
609
+
610
+ ### ✅ Phase 7 Checkpoint — MANDATORY VALIDATION
515
611
 
516
- See `references/synthesis.md` for template.
612
+ **Run this validation command before proceeding:**
613
+
614
+ ```bash
615
+ # Set these based on your current session
616
+ SESSION_DIR=".ocr/sessions/$(ls -1t .ocr/sessions/ | head -1)"
617
+ CURRENT_ROUND=$(ls -1d "$SESSION_DIR/rounds/round-"* 2>/dev/null | wc -l | tr -d ' ')
618
+ FINAL_FILE="$SESSION_DIR/rounds/round-$CURRENT_ROUND/final.md"
619
+
620
+ # Check file exists
621
+ if [ -f "$FINAL_FILE" ]; then
622
+ echo "✓ final.md exists at $FINAL_FILE"
623
+ else
624
+ echo "❌ final.md not found at $FINAL_FILE"
625
+ exit 1
626
+ fi
517
627
 
518
- ### Phase 7 Checkpoint
628
+ # Check required content
629
+ if grep -q '## Verdict' "$FINAL_FILE"; then
630
+ echo "✓ Contains Verdict section"
631
+ else
632
+ echo "❌ Missing '## Verdict' section"
633
+ exit 1
634
+ fi
635
+ ```
519
636
 
520
637
  **STOP and verify before proceeding:**
521
- - [ ] `rounds/round-{n}/final.md` written to round directory
638
+ - [ ] `rounds/round-{n}/final.md` exists
522
639
  - [ ] Contains prioritized findings (Must Fix, Should Fix, Consider)
523
640
  - [ ] Contains Clarifying Questions section (if any)
524
641
  - [ ] If requirements provided: Contains Requirements Assessment