Skip to content

feat(code reviewer) Assist users to convert from Custom Instructions to REVIEW.md - #4838

Merged
St0rmz1 merged 9 commits into
mainfrom
feat/code-reviewer-review-md-conversion
Jul 28, 2026
Merged

feat(code reviewer) Assist users to convert from Custom Instructions to REVIEW.md#4838
St0rmz1 merged 9 commits into
mainfrom
feat/code-reviewer-review-md-conversion

Conversation

@St0rmz1

@St0rmz1 St0rmz1 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds an assisted migration from the code reviewer's Custom Instructions to a
REVIEW.md file. From the code review config page, a user with existing Custom
Instructions can open a dialog, pick repositories, and start a cloud agent
session per repo that writes their instructions into REVIEW.md (merging with an
existing file) and opens a pull request. The whole flow is behind a PostHog
feature flag and is only offered to configs that already have Custom Instructions.

Changes

  • New route apps/web/src/app/cloud-agent-fork/review-md/route.ts: a GET that
    authorizes the request, reads the saved Custom Instructions server-side, and
    calls prepareSession to spawn a cloud agent that opens the REVIEW.md PR/MR,
    then redirects into that session. It does not accept the instructions text from
    the caller.
  • Conversion prompt review-md-conversion-prompt.ts: builds the agent prompt.
    The untrusted instructions are fenced with per-request nonce markers and any
    marker-like line in the payload is neutralized, so the text cannot terminate
    its own block or be read as agent instructions.
  • Dialog ReviewMdConversionDialog.tsx and the "Help me automate the conversion"
    button in ReviewConfigForm.tsx: one start link per repo (each opens its own
    session in a new tab to avoid popup blocking). The button gates on the persisted
    Custom Instructions and blocks with a message while there are unsaved edits. The
    dialog shows a heads-up that each conversion is a billable cloud agent session.
  • Feature flag code-review-md-conversion (constant in constants.ts): enforced
    server-side on the route (isFeatureFlagEnabledOrDevelopment) and used to gate
    the button/dialog client-side, wired through both the org and personal
    ReviewAgentPageClient.
  • Security guards on the route: a repo allowlist limited to the caller's fetched
    integration repositories (manually-added config entries are excluded as they are
    unverified client input); a Sec-Fetch-Site CSRF check that fails closed
    (rejects cross-site and missing header); a Redis rate cap keyed per user within
    the org scope, checked after membership is proven and using a window-bucketed key
    so a failed TTL can't strand an actor; and a tightened repo path regex.
  • Shared helper selectable-repositories.ts: buildSelectableRepositories /
    buildAllowedRepositoryFullNames, used by both the config form and the route so
    the offered list and the enforced allowlist derive from the same inputs.
  • Tests: unit coverage for the prompt marker neutralization/nonce and for the
    selectable-repositories helpers.

Verification

  • Manual: exercised the config page (button enable/disable and the unsaved
    edits message), the dialog, and the route through all of its guards
    (auth, feature flag, rate limit, repo allowlist, saved instructions) up to the
    prepareSession call. The final cloud agent session did not complete in local
    dev because the local database was missing a recent migration
    (cli_sessions_v2.total_cost_microdollars), unrelated to this PR. The PostHog
    flag was created (boolean, 100%, client + server). Automated: unit tests for the
    prompt sanitizer and the allowlist helper pass.

Visual Changes

Adds a "Help me automate the conversion" button under Custom Instructions and a
"Convert Custom Instructions to REVIEW.md" dialog (repo picker + per-repo start
links + billing heads-up), gated by the feature flag. Screenshots to be added.

Before After

Reviewer Notes

  • The route is a navigable GET on purpose (one link per repo avoids popup
    blocking); the CSRF fail-closed Sec-Fetch-Site check plus the flag and repo
    allowlist are the mitigations. The worker independently enforces installation
    scope when minting the git token, so an unrelated repo can't be cloned even if
    the web-layer allowlist were bypassed.
  • The instructions are read from the saved config server-side, never from the
    query string, so the endpoint can't be used to inject arbitrary prompt text.
  • Default-on flag at 100% means the audience is limited only by "has Custom
    Instructions"; flip the flag off to kill the flow without a redeploy.

Comment thread apps/web/src/lib/code-reviews/core/selectable-repositories.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

The new commit fixes the previously flagged stale doc comment in selectable-repositories.ts, correctly scoping the sync guarantee to the conversion path only; no new issues found.

Files Reviewed (1 file)
  • apps/web/src/lib/code-reviews/core/selectable-repositories.ts
Previous Review Summary (commit 4f804f4)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 4f804f4)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

A stale doc comment in selectable-repositories.ts overstates a sync guarantee between the UI repo list and the server-enforced allowlist that a later commit in this PR intentionally broke.

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
apps/web/src/lib/code-reviews/core/selectable-repositories.ts 5 Doc comment claims the UI-offered repo list can't drift from the server-enforced allowlist, but route.ts now intentionally excludes manually-added repos from the allowlist while the UI list still includes them for general settings.
Files Reviewed (10 files)
  • apps/web/src/app/(app)/code-reviews/ReviewAgentPageClient.tsx
  • apps/web/src/app/(app)/organizations/[id]/code-reviews/ReviewAgentPageClient.tsx
  • apps/web/src/app/cloud-agent-fork/review-md/route.ts
  • apps/web/src/components/code-reviews/ReviewConfigForm.tsx
  • apps/web/src/components/code-reviews/ReviewMdConversionDialog.tsx
  • apps/web/src/lib/code-reviews/core/constants.ts
  • apps/web/src/lib/code-reviews/core/selectable-repositories.test.ts
  • apps/web/src/lib/code-reviews/core/selectable-repositories.ts - 1 issue
  • apps/web/src/lib/code-reviews/prompts/review-md-conversion-prompt.test.ts
  • apps/web/src/lib/code-reviews/prompts/review-md-conversion-prompt.ts

Fix these issues in Kilo Cloud


Reviewed by claude-sonnet-5 · Input: 20 · Output: 3.8K · Cached: 396.3K

Review guidance: REVIEW.md from base branch main

@St0rmz1
St0rmz1 merged commit ffc1fce into main Jul 28, 2026
15 checks passed
@St0rmz1
St0rmz1 deleted the feat/code-reviewer-review-md-conversion branch July 28, 2026 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants