@open-code-review/agents 1.4.0 → 1.5.1

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.
@@ -2,7 +2,9 @@
2
2
 
3
3
  Complete 8-phase process for multi-agent code review.
4
4
 
5
- > ⚠️ **CRITICAL**: You MUST update `state.json` **BEFORE starting work** on each phase. The `ocr progress` CLI reads this file for real-time tracking. Update the `current_phase` and `phase_number` immediately when transitioning—do not wait until the phase is complete.
5
+ > **CRITICAL**: You MUST call `ocr state transition` **BEFORE starting work** on each phase. The `ocr progress` CLI reads session state for real-time tracking. Transition the `current_phase` and `phase_number` immediately when entering a new phase—do not wait until the phase is complete.
6
+
7
+ > **PREREQUISITE**: The `ocr` CLI must be installed (`npm install -g @open-code-review/cli`) or accessible via `npx`. Every phase transition calls `ocr state transition`, which requires the CLI.
6
8
 
7
9
  ---
8
10
 
@@ -34,7 +36,11 @@ Then proceed to Phase 1.
34
36
 
35
37
  ### Step 3: If session exists, verify state matches files
36
38
 
37
- Read `state.json` and verify actual files exist (see `references/session-files.md` for authoritative names):
39
+ Use `ocr state show` to read current state and verify actual files exist (see `references/session-files.md` for authoritative names):
40
+
41
+ ```bash
42
+ ocr state show
43
+ ```
38
44
 
39
45
  | Phase Complete? | File check |
40
46
  |-----------------|------------|
@@ -45,7 +51,7 @@ Read `state.json` and verify actual files exist (see `references/session-files.m
45
51
  | discourse | `rounds/round-{current_round}/discourse.md` exists |
46
52
  | synthesis | `rounds/round-{current_round}/final.md` exists |
47
53
 
48
- > **Note**: Phase completion is derived from filesystem (file existence). The `current_phase` field in `state.json` indicates which phase is active, not what's complete.
54
+ > **Note**: Phase completion is derived from filesystem (file existence). The `current_phase` field in the session state indicates which phase is active, not what's complete.
49
55
 
50
56
  ### Step 3b: Round Resolution Algorithm
51
57
 
@@ -62,7 +68,7 @@ else
62
68
  # Find highest round number
63
69
  HIGHEST=$(ls -1 "$ROUNDS_DIR" | grep -E '^round-[0-9]+$' | sed 's/round-//' | sort -n | tail -1)
64
70
  HIGHEST=${HIGHEST:-0}
65
-
71
+
66
72
  # Check if highest round is complete (has final.md)
67
73
  if [ -f "$ROUNDS_DIR/round-$HIGHEST/final.md" ]; then
68
74
  # Start new round
@@ -75,57 +81,40 @@ else
75
81
  fi
76
82
  ```
77
83
 
78
- Update `state.json` with `current_round` value. **When starting a new round (CURRENT_ROUND > 1), also set `round_started_at` to the current timestamp** so the CLI progress timer shows elapsed time for the current round, not the entire session.
84
+ When starting a new round (CURRENT_ROUND > 1), pass the `--current-round` flag to `ocr state transition` so the CLI progress timer shows elapsed time for the current round, not the entire session.
79
85
 
80
86
  ### Step 4: Determine resume point
81
87
 
82
- - **state.json missing, files exist**: Recreate `state.json` based on file existence
83
- - **state.json exists, files match**: Resume from `current_phase`
84
- - **state.json and files mismatch**: Ask user which to trust
88
+ - **No state in SQLite, files exist**: Use `ocr state init` to recreate the session, then `ocr state transition` to set the correct phase based on file existence
89
+ - **State exists, files match**: Resume from `current_phase` shown by `ocr state show`
90
+ - **State and files mismatch**: Ask user which to trust
85
91
  - **No session exists**: Create session directory and start Phase 1
86
92
 
87
93
  ### Step 5: Report to user
88
94
 
89
95
  Before proceeding, tell the user:
90
96
  ```
91
- 📍 Session: {session_id}
92
- 📊 Current phase: {current_phase} (Phase {phase_number}/8)
93
- 🔄 Action: [Starting fresh | Resuming from Phase X]
97
+ Session: {session_id}
98
+ Current phase: {current_phase} (Phase {phase_number}/8)
99
+ Action: [Starting fresh | Resuming from Phase X]
94
100
  ```
95
101
 
96
102
  ---
97
103
 
98
104
  ## State Tracking
99
105
 
100
- At **every phase transition**, update `.ocr/sessions/{id}/state.json`:
101
-
102
- ```json
103
- {
104
- "session_id": "{id}",
105
- "status": "active",
106
- "current_phase": "reviews",
107
- "phase_number": 4,
108
- "current_round": 1,
109
- "started_at": "{PRESERVE_ORIGINAL}",
110
- "round_started_at": "{CURRENT_ISO_TIMESTAMP}",
111
- "updated_at": "{CURRENT_ISO_TIMESTAMP}"
112
- }
113
- ```
114
-
115
- **Minimal schema** — round metadata is derived from filesystem, not stored in state.json.
116
-
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.
106
+ At **every phase transition**, call `ocr state transition`:
122
107
 
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.
108
+ ```bash
109
+ ocr state transition --phase "reviews" --phase-number 4 --current-round 1
110
+ ```
124
111
 
125
- **Status values**: `active` (in progress), `closed` (complete and dismissed)
112
+ This updates the session in SQLite and logs an orchestration event.
126
113
 
127
114
  **Phase values**: `context`, `change-context`, `analysis`, `reviews`, `aggregation`, `discourse`, `synthesis`, `complete`
128
115
 
116
+ **Status values**: `active` (in progress), `closed` (complete — set via `ocr state close`)
117
+
129
118
  ## Artifact Checklist
130
119
 
131
120
  > **See `references/session-files.md` for the authoritative file manifest.**
@@ -134,14 +123,14 @@ Before proceeding to each phase, verify the required artifacts exist:
134
123
 
135
124
  | Phase | Required Before Starting | Artifact to Create |
136
125
  |-------|-------------------------|-------------------|
137
- | 1 | Session directory created | `state.json`, `discovered-standards.md`, `requirements.md` (if provided) |
138
- | 2 | `discovered-standards.md` exists | `context.md`, `rounds/round-1/reviews/` directory, update `state.json` |
139
- | 3 | `context.md` exists | Update `context.md` with Tech Lead guidance, update `state.json` |
140
- | 4 | `context.md` exists | `rounds/round-{n}/reviews/{type}-{n}.md` for each reviewer, update `state.json` |
141
- | 5 | ≥2 files in `rounds/round-{n}/reviews/` | Aggregated findings (inline), update `state.json` |
142
- | 6 | Reviews complete | `rounds/round-{n}/discourse.md`, update `state.json` |
143
- | 7 | `rounds/round-{n}/discourse.md` exists | `rounds/round-{n}/final.md`, update `state.json` |
144
- | 8 | `rounds/round-{n}/final.md` exists | Present to user, set `status: "closed"` and `current_phase: "complete"` |
126
+ | 1 | Session directory created | `discovered-standards.md`, `requirements.md` (if provided); call `ocr state init` |
127
+ | 2 | `discovered-standards.md` exists | `context.md`, `rounds/round-1/reviews/` directory; call `ocr state transition` |
128
+ | 3 | `context.md` exists | Update `context.md` with Tech Lead guidance; call `ocr state transition` |
129
+ | 4 | `context.md` exists | `rounds/round-{n}/reviews/{type}-{n}.md` for each reviewer; call `ocr state transition` |
130
+ | 5 | ≥2 files in `rounds/round-{n}/reviews/` | Aggregated findings (inline); call `ocr state transition` |
131
+ | 6 | Reviews complete | `rounds/round-{n}/discourse.md`; call `ocr state transition` |
132
+ | 7 | `rounds/round-{n}/discourse.md` exists | `rounds/round-{n}/final.md`; call `ocr state transition` |
133
+ | 8 | `rounds/round-{n}/final.md` exists | Present to user; call `ocr state close` |
145
134
 
146
135
  **NEVER skip directly to `final.md`** — this breaks progress tracking.
147
136
 
@@ -162,6 +151,20 @@ This location is consistent regardless of how OCR is installed (CLI or plugin),
162
151
 
163
152
  **Goal**: Build review context from config + discovered files + user requirements.
164
153
 
154
+ **State**: Call `ocr state init` to create the session, then `ocr state transition --phase "context" --phase-number 1`:
155
+
156
+ ```bash
157
+ # Initialize the session in SQLite
158
+ ocr state init \
159
+ --session-id "$SESSION_ID" \
160
+ --branch "$BRANCH" \
161
+ --workflow-type review \
162
+ --session-dir "$SESSION_DIR"
163
+
164
+ # Transition to context phase
165
+ ocr state transition --phase "context" --phase-number 1
166
+ ```
167
+
165
168
  ### Steps
166
169
 
167
170
  **1a. Load OCR Configuration**
@@ -234,7 +237,7 @@ If requirements provided, save to `requirements.md` in session directory.
234
237
  ## OCR Config Context
235
238
  [content from .ocr/config.yaml context field]
236
239
 
237
- ## OpenSpec Context
240
+ ## OpenSpec Context
238
241
  [content from openspec/config.yaml]
239
242
 
240
243
  ## From: AGENTS.md
@@ -249,7 +252,7 @@ If requirements provided, save to `requirements.md` in session directory.
249
252
 
250
253
  See `references/context-discovery.md` for detailed algorithm.
251
254
 
252
- ### Phase 1 Checkpoint
255
+ ### Phase 1 Checkpoint
253
256
 
254
257
  **STOP and verify before proceeding:**
255
258
  - [ ] `discovered-standards.md` written to session directory
@@ -261,6 +264,8 @@ See `references/context-discovery.md` for detailed algorithm.
261
264
 
262
265
  **Goal**: Understand what changed and why.
263
266
 
267
+ **State**: Call `ocr state transition --phase "change-context" --phase-number 2`
268
+
264
269
  ### Steps
265
270
 
266
271
  1. Identify the review target:
@@ -273,13 +278,13 @@ See `references/context-discovery.md` for detailed algorithm.
273
278
  ```bash
274
279
  # Get the diff
275
280
  git diff --cached > /tmp/ocr-diff.txt
276
-
281
+
277
282
  # Get recent commit messages for intent
278
283
  git log --oneline -10
279
-
284
+
280
285
  # Get branch name
281
286
  git branch --show-current
282
-
287
+
283
288
  # List affected files
284
289
  git diff --cached --name-only
285
290
  ```
@@ -293,21 +298,21 @@ See `references/context-discovery.md` for detailed algorithm.
293
298
  4. Save context to `context.md`:
294
299
  ```markdown
295
300
  # Review Context
296
-
301
+
297
302
  **Session**: {SESSION_ID}
298
303
  **Target**: staged changes
299
304
  **Branch**: {branch}
300
305
  **Files**: {count} files changed
301
-
306
+
302
307
  ## Change Summary
303
308
  [Brief description of what changed]
304
-
309
+
305
310
  ## Affected Files
306
311
  - path/to/file1.ts
307
312
  - path/to/file2.ts
308
313
  ```
309
314
 
310
- ### Phase 2 Checkpoint
315
+ ### Phase 2 Checkpoint
311
316
 
312
317
  **STOP and verify before proceeding:**
313
318
  - [ ] Session directory created: `.ocr/sessions/{id}/`
@@ -320,21 +325,23 @@ See `references/context-discovery.md` for detailed algorithm.
320
325
 
321
326
  **Goal**: Summarize changes, analyze against requirements, identify risks, select reviewers.
322
327
 
328
+ **State**: Call `ocr state transition --phase "analysis" --phase-number 3`
329
+
323
330
  ### Steps
324
331
 
325
332
  1. **Check for existing map reference** (optional):
326
-
333
+
327
334
  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
-
335
+
329
336
  ```bash
330
337
  # Check for existing map artifacts
331
338
  ls .ocr/sessions/{id}/map/runs/*/map.md 2>/dev/null
332
339
  ```
333
-
340
+
334
341
  - **If found AND user referenced it**: Read the latest `map.md` as supplementary context
335
342
  - **If not found**: Inform user no map exists, proceed with standard review
336
343
  - **If user did NOT reference a map**: Do NOT automatically use map artifacts
337
-
344
+
338
345
  > **Note**: Maps are orthogonal tools. Only use if explicitly referenced by user.
339
346
 
340
347
  2. Review requirements (if provided):
@@ -351,30 +358,30 @@ See `references/context-discovery.md` for detailed algorithm.
351
358
  4. Create dynamic guidance for reviewers:
352
359
  ```markdown
353
360
  ## Tech Lead Guidance
354
-
361
+
355
362
  ### Requirements Summary (if provided)
356
363
  The changes should implement OAuth2 authentication per spec...
357
364
  Key acceptance criteria:
358
365
  - Users can log in via Google OAuth
359
366
  - Session tokens expire after 24 hours
360
367
  - Failed logins are rate-limited
361
-
368
+
362
369
  ### Change Summary
363
370
  This PR adds user authentication via OAuth2...
364
-
371
+
365
372
  ### Requirements Assessment
366
- - OAuth login: Implemented
373
+ - OAuth login: Implemented
367
374
  - Token expiry: Not visible in diff - verify implementation
368
375
  - Rate limiting: Not found - may be missing
369
-
376
+
370
377
  ### Clarifying Questions (Tech Lead)
371
378
  - The spec says "fast response" - what's the target latency?
372
379
  - Should this include account lockout after N failures?
373
-
380
+
374
381
  ### Risk Areas
375
382
  - **Security**: New auth flow needs careful review
376
383
  - **Architecture**: New service layer pattern
377
-
384
+
378
385
  ### Focus Points
379
386
  - Validate token handling
380
387
  - Check for proper error handling
@@ -388,7 +395,7 @@ See `references/context-discovery.md` for detailed algorithm.
388
395
  # MUST read default_team from .ocr/config.yaml - do NOT use hardcoded values
389
396
  cat .ocr/config.yaml | grep -A10 'default_team:'
390
397
  ```
391
-
398
+
392
399
  Parse the `default_team` section to determine reviewer counts:
393
400
  ```yaml
394
401
  # Example config - actual values come from .ocr/config.yaml
@@ -398,21 +405,21 @@ See `references/context-discovery.md` for detailed algorithm.
398
405
  # security: 1 # Commented = not spawned by default
399
406
  testing: 1 # Spawn testing-1
400
407
  ```
401
-
408
+
402
409
  **Reviewer spawning rules**:
403
410
  - For each uncommented entry in `default_team`, spawn N instances
404
411
  - `principal: 2` → spawn `principal-1`, `principal-2`
405
- - `quality: 2` → spawn `quality-1`, `quality-2`
412
+ - `quality: 2` → spawn `quality-1`, `quality-2`
406
413
  - `testing: 1` → spawn `testing-1`
407
414
  - Commented entries (e.g., `# security: 1`) are NOT spawned unless auto-detected
408
-
415
+
409
416
  **Auto-detection** (adds reviewers beyond config):
410
417
  | Change Type | Additional Reviewers |
411
418
  |-------------|---------------------|
412
- | Auth/Security changes | + Security |
413
- | API changes | + Security |
414
- | Logic changes | + Testing (if not in config) |
415
- | User says "add security" | + Security |
419
+ | Auth/Security changes | + 1x Security |
420
+ | API changes | + 1x Security |
421
+ | Logic changes | + 1x Testing (if not in config) |
422
+ | User says "add security" | + 1x Security |
416
423
 
417
424
  ---
418
425
 
@@ -420,7 +427,9 @@ See `references/context-discovery.md` for detailed algorithm.
420
427
 
421
428
  **Goal**: Run each reviewer independently with configured redundancy.
422
429
 
423
- > **⚠️ CRITICAL**: Reviewer counts and types come from `.ocr/config.yaml` `default_team` section.
430
+ **State**: Call `ocr state transition --phase "reviews" --phase-number 4 --current-round $CURRENT_ROUND`
431
+
432
+ > **CRITICAL**: Reviewer counts and types come from `.ocr/config.yaml` `default_team` section.
424
433
  > Do NOT use hardcoded defaults. Do NOT skip the `-{n}` suffix in filenames.
425
434
  > See `references/session-files.md` for authoritative file naming.
426
435
 
@@ -429,30 +438,30 @@ See `references/context-discovery.md` for detailed algorithm.
429
438
  1. Load reviewer personas from `references/reviewers/`.
430
439
 
431
440
  2. **Parse `default_team` from config** (already read in Phase 3):
432
-
441
+
433
442
  For each reviewer type in config, spawn the specified number of instances:
434
-
443
+
435
444
  ```bash
436
445
  # Example: If config says principal: 2, quality: 2, testing: 1
437
446
  # You MUST spawn exactly these reviewers with numbered suffixes:
438
-
447
+
439
448
  # 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
446
-
449
+ -> Create: rounds/round-$CURRENT_ROUND/reviews/principal-1.md
450
+ -> Create: rounds/round-$CURRENT_ROUND/reviews/principal-2.md
451
+
452
+ # From default_team.quality: 2
453
+ -> Create: rounds/round-$CURRENT_ROUND/reviews/quality-1.md
454
+ -> Create: rounds/round-$CURRENT_ROUND/reviews/quality-2.md
455
+
447
456
  # From default_team.testing: 1
448
- Create: rounds/round-$CURRENT_ROUND/reviews/testing-1.md
449
-
457
+ -> Create: rounds/round-$CURRENT_ROUND/reviews/testing-1.md
458
+
450
459
  # Auto-detected (if applicable)
451
- Create: rounds/round-$CURRENT_ROUND/reviews/security-1.md
460
+ -> Create: rounds/round-$CURRENT_ROUND/reviews/security-1.md
452
461
  ```
453
-
462
+
454
463
  **File naming pattern**: `{type}-{n}.md` where n starts at 1.
455
-
464
+
456
465
  Examples: `principal-1.md`, `principal-2.md`, `quality-1.md`, `quality-2.md`, `testing-1.md`
457
466
 
458
467
  3. Each task receives:
@@ -467,7 +476,7 @@ See `references/context-discovery.md` for detailed algorithm.
467
476
 
468
477
  See `references/reviewer-task.md` for the task template.
469
478
 
470
- ### Phase 4 Checkpoint — MANDATORY VALIDATION
479
+ ### Phase 4 Checkpoint — MANDATORY VALIDATION
471
480
 
472
481
  **Run this validation command before proceeding:**
473
482
 
@@ -483,15 +492,15 @@ ls -la "$REVIEWS_DIR/"
483
492
  # Verify all files match {type}-{n}.md pattern (principal, quality, security, testing)
484
493
  for f in "$REVIEWS_DIR/"*.md; do
485
494
  if [[ "$(basename "$f")" =~ ^(principal|quality|security|testing)-[0-9]+\.md$ ]]; then
486
- echo " $(basename "$f")"
495
+ echo "OK $(basename "$f")"
487
496
  else
488
- echo " $(basename "$f") does not match {type}-{n}.md pattern"
497
+ echo "FAIL $(basename "$f") does not match {type}-{n}.md pattern"
489
498
  exit 1
490
499
  fi
491
500
  done
492
501
 
493
502
  REVIEWER_COUNT=$(ls -1 "$REVIEWS_DIR/"*.md 2>/dev/null | wc -l | tr -d ' ')
494
- echo " Found $REVIEWER_COUNT reviewer files"
503
+ echo "OK Found $REVIEWER_COUNT reviewer files"
495
504
  ```
496
505
 
497
506
  **STOP and verify before proceeding:**
@@ -506,6 +515,8 @@ echo "✓ Found $REVIEWER_COUNT reviewer files"
506
515
 
507
516
  **Goal**: Merge redundant reviewer runs and mark confidence.
508
517
 
518
+ **State**: Call `ocr state transition --phase "aggregation" --phase-number 5 --current-round $CURRENT_ROUND`
519
+
509
520
  ### Steps
510
521
 
511
522
  1. For reviewers with redundancy > 1, compare findings:
@@ -518,10 +529,10 @@ echo "✓ Found $REVIEWER_COUNT reviewer files"
518
529
  3. Create aggregated findings per reviewer:
519
530
  ```markdown
520
531
  ## Security Reviewer (2 runs)
521
-
532
+
522
533
  ### Confirmed Findings (2/2 runs)
523
534
  - SQL injection risk in query builder [VERY HIGH]
524
-
535
+
525
536
  ### Partial Findings (1/2 runs)
526
537
  - Potential timing attack in comparison [MEDIUM]
527
538
  ```
@@ -532,6 +543,8 @@ echo "✓ Found $REVIEWER_COUNT reviewer files"
532
543
 
533
544
  **Goal**: Let reviewers challenge and build on each other's findings.
534
545
 
546
+ **State**: Call `ocr state transition --phase "discourse" --phase-number 6 --current-round $CURRENT_ROUND`
547
+
535
548
  > Skip this phase if `--quick` flag is used.
536
549
 
537
550
  ### Steps
@@ -548,7 +561,7 @@ echo "✓ Found $REVIEWER_COUNT reviewer files"
548
561
 
549
562
  See `references/discourse.md` for detailed instructions.
550
563
 
551
- ### Phase 6 Checkpoint
564
+ ### Phase 6 Checkpoint
552
565
 
553
566
  **STOP and verify before proceeding:**
554
567
  - [ ] `rounds/round-{n}/discourse.md` written to round directory
@@ -561,6 +574,8 @@ See `references/discourse.md` for detailed instructions.
561
574
 
562
575
  **Goal**: Produce final prioritized review and save to **`final.md`**.
563
576
 
577
+ **State**: Call `ocr state transition --phase "synthesis" --phase-number 7 --current-round $CURRENT_ROUND`
578
+
564
579
  > **File**: `rounds/round-{n}/final.md`
565
580
  > **Template**: See `references/final-template.md` for format
566
581
  > **Manifest**: See `references/session-files.md` for authoritative file names
@@ -594,7 +609,7 @@ See `references/discourse.md` for detailed instructions.
594
609
  - Questions about scope boundaries
595
610
  - Questions about edge cases
596
611
  - Questions about intentional exclusions
597
-
612
+
598
613
  These go in a prominent "Clarifying Questions" section for stakeholder response.
599
614
 
600
615
  7. **Write the final review file**:
@@ -602,12 +617,12 @@ See `references/discourse.md` for detailed instructions.
602
617
  # OUTPUT FILE - must be exactly this path:
603
618
  FINAL_FILE="$SESSION_DIR/rounds/round-$CURRENT_ROUND/final.md"
604
619
  ```
605
-
620
+
606
621
  Save synthesized review to `$FINAL_FILE`.
607
622
 
608
623
  See `references/final-template.md` for the template format.
609
624
 
610
- ### Phase 7 Checkpoint — MANDATORY VALIDATION
625
+ ### Phase 7 Checkpoint — MANDATORY VALIDATION
611
626
 
612
627
  **Run this validation command before proceeding:**
613
628
 
@@ -619,17 +634,17 @@ FINAL_FILE="$SESSION_DIR/rounds/round-$CURRENT_ROUND/final.md"
619
634
 
620
635
  # Check file exists
621
636
  if [ -f "$FINAL_FILE" ]; then
622
- echo " final.md exists at $FINAL_FILE"
637
+ echo "OK final.md exists at $FINAL_FILE"
623
638
  else
624
- echo " final.md not found at $FINAL_FILE"
639
+ echo "FAIL final.md not found at $FINAL_FILE"
625
640
  exit 1
626
641
  fi
627
642
 
628
643
  # Check required content
629
644
  if grep -q '## Verdict' "$FINAL_FILE"; then
630
- echo " Contains Verdict section"
645
+ echo "OK Contains Verdict section"
631
646
  else
632
- echo " Missing '## Verdict' section"
647
+ echo "FAIL Missing '## Verdict' section"
633
648
  exit 1
634
649
  fi
635
650
  ```
@@ -646,18 +661,20 @@ fi
646
661
 
647
662
  **Goal**: Display results, optionally post to GitHub, and close the session.
648
663
 
664
+ **State**: Call `ocr state close` after presenting results.
665
+
649
666
  ### Steps
650
667
 
651
668
  1. Display the final review in a clear format:
652
669
  ```markdown
653
670
  # Code Review: {branch}
654
-
671
+
655
672
  ## Summary
656
673
  {X} must-fix, {Y} should-fix, {Z} suggestions
657
-
674
+
658
675
  ## Must Fix
659
676
  ...
660
-
677
+
661
678
  ## Should Fix
662
679
  ...
663
680
  ```
@@ -666,27 +683,22 @@ fi
666
683
  - Check for `gh` CLI: `which gh`
667
684
  - Post as PR comment: `gh pr comment {number} --body-file final.md`
668
685
 
669
- 3. **Close the session** by updating `state.json`:
670
- ```json
671
- {
672
- "session_id": "{id}",
673
- "status": "closed",
674
- "current_phase": "complete",
675
- "phase_number": 8,
676
- "current_round": 1,
677
- "updated_at": "{now}"
678
- }
686
+ 3. **Close the session**:
687
+ ```bash
688
+ ocr state close
679
689
  ```
680
-
681
- > **IMPORTANT**: Setting `status: "closed"` ensures:
690
+
691
+ This sets `status: "closed"` and `current_phase: "complete"` in SQLite.
692
+
693
+ > **IMPORTANT**: Closing the session ensures:
682
694
  > - The `ocr progress` CLI stops showing this session
683
695
  > - The session won't be picked up for resume
684
696
  > - The session remains accessible via `/ocr-history` and `/ocr-show`
685
697
 
686
698
  4. Confirm session saved:
687
699
  ```
688
- Review complete
689
- .ocr/sessions/{id}/rounds/round-{n}/final.md
700
+ Review complete
701
+ -> .ocr/sessions/{id}/rounds/round-{n}/final.md
690
702
  ```
691
703
 
692
704
  ---
@@ -695,11 +707,11 @@ fi
695
707
 
696
708
  | Phase | Command/Action | Output |
697
709
  |-------|---------------|--------|
698
- | 1 | Search for context files | `discovered-standards.md` |
699
- | 2 | git diff, create session | `context.md`, `rounds/round-1/reviews/` |
700
- | 3 | Analyze, select reviewers | guidance in `context.md` |
701
- | 4 | Spawn reviewer tasks | `rounds/round-{n}/reviews/*.md` |
702
- | 5 | Compare redundant runs | aggregated findings |
703
- | 6 | Reviewer discourse | `rounds/round-{n}/discourse.md` |
704
- | 7 | Synthesize and prioritize | `rounds/round-{n}/final.md` |
705
- | 8 | Display/post | Terminal output, GitHub |
710
+ | 1 | `ocr state init` + search for context files | `discovered-standards.md` |
711
+ | 2 | git diff, create session, `ocr state transition` | `context.md`, `rounds/round-1/reviews/` |
712
+ | 3 | Analyze, select reviewers, `ocr state transition` | guidance in `context.md` |
713
+ | 4 | Spawn reviewer tasks, `ocr state transition` | `rounds/round-{n}/reviews/*.md` |
714
+ | 5 | Compare redundant runs, `ocr state transition` | aggregated findings |
715
+ | 6 | Reviewer discourse, `ocr state transition` | `rounds/round-{n}/discourse.md` |
716
+ | 7 | Synthesize and prioritize, `ocr state transition` | `rounds/round-{n}/final.md` |
717
+ | 8 | Display/post, `ocr state close` | Terminal output, GitHub |