Fix/coderabbit nits (#1259)

* fix: eliminate 8 as any in MCP handlers, structured output, and stream events

- Group A: Add : () => AnyObjectSchema type annotations to MCP notification
  schema constants (useIdeSelection, useIdeLogging, usePrompts, channelNotification)
- Group B: Add isStructuredOutputAttachmentMessage type guard for structured
  output attachment payloads (execAgentHook)
- Group C: Add isMessageDeltaStreamEvent type guard for message_delta
  stream event usage extraction (forkedAgent)

These as any casts also exist in the upstream CCB source — this fix provides
real type safety without changing any runtime behavior.

* feat: wire mode persona injection — Claude Soul Document distilled into system prompt

- prompts.ts: add getModePersonaSection() → injects current mode's
  systemPrompt as 'mode_persona' dynamic section (first in order,
  before operational instructions). Previously modes had systemPrompt
  fields but they were never sent to the model.
- modes/personas/claude.ts: 3KB distilled Claude persona from
  Anthropic's leaked Claude 4.5 Opus Soul Document (70KB → operational
  extract): core traits, 7 honesty principles, helpfulness/caution
  balance, collaboration stance, identity stability.
- With custom mode YAML (~/.claude/modes/claude.yaml), 7 modes total
  including the new Claude persona — fully operational at /mode claude.

Co-Authored-By: James Feng <47167674+GhostDragon124@users.noreply.github.com>

* fix: import path convention + reword persona source comment

- prompts.ts: use 'src/modes/store.js' alias instead of relative '../modes/store.js'
  to match the file's existing import convention
- claude.ts: reword JSDoc to say 'based on publicly available reference document'
  instead of 'leaked', addressing CodeRabbit review concern
This commit is contained in:
James F
2026-06-07 20:06:16 +08:00
committed by GitHub
parent a972ed795c
commit be0c65678d
17 changed files with 808735 additions and 41 deletions

View File

@@ -3,9 +3,10 @@ import { logEvent } from 'src/services/analytics/index.js'
import { z } from 'zod/v4'
import type { MCPServerConnection } from '../services/mcp/types.js'
import { getConnectedIdeClient } from '../utils/ide.js'
import type { AnyObjectSchema } from '@modelcontextprotocol/sdk/server/zod-compat.js'
import { lazySchema } from '../utils/lazySchema.js'
const LogEventSchema = lazySchema(() =>
const LogEventSchema: () => AnyObjectSchema = lazySchema(() =>
z.object({
method: z.literal('log_event'),
params: z.object({
@@ -27,7 +28,7 @@ export function useIdeLogging(mcpClients: MCPServerConnection[]): void {
if (ideClient) {
// Register the log event handler
ideClient.client.setNotificationHandler(
LogEventSchema() as any,
LogEventSchema(),
notification => {
const { eventName, eventData } = notification.params
logEvent(

View File

@@ -6,6 +6,7 @@ import type {
MCPServerConnection,
} from '../services/mcp/types.js'
import { getConnectedIdeClient } from '../utils/ide.js'
import type { AnyObjectSchema } from '@modelcontextprotocol/sdk/server/zod-compat.js'
import { lazySchema } from '../utils/lazySchema.js'
export type SelectionPoint = {
line: number
@@ -29,7 +30,7 @@ export type IDESelection = {
}
// Define the selection changed notification schema
const SelectionChangedSchema = lazySchema(() =>
const SelectionChangedSchema: () => AnyObjectSchema = lazySchema(() =>
z.object({
method: z.literal('selection_changed'),
params: z.object({
@@ -110,7 +111,7 @@ export function useIdeSelection(
// Register notification handler for selection_changed events
ideClient.client.setNotificationHandler(
SelectionChangedSchema() as any,
SelectionChangedSchema(),
notification => {
if (currentIDERef.current !== ideClient) {
return

View File

@@ -6,11 +6,12 @@ import { callIdeRpc } from '../services/mcp/client.js';
import type { ConnectedMCPServer, MCPServerConnection } from '../services/mcp/types.js';
import type { PermissionMode } from '../types/permissions.js';
import { CLAUDE_IN_CHROME_MCP_SERVER_NAME, isTrackedClaudeInChromeTabId } from '../utils/claudeInChrome/common.js';
import type { AnyObjectSchema } from '@modelcontextprotocol/sdk/server/zod-compat.js';
import { lazySchema } from '../utils/lazySchema.js';
import { enqueuePendingNotification } from '../utils/messageQueueManager.js';
// Schema for the prompt notification from Chrome extension (JSON-RPC 2.0 format)
const ClaudeInChromePromptNotificationSchema = lazySchema(() =>
const ClaudeInChromePromptNotificationSchema: () => AnyObjectSchema = lazySchema(() =>
z.object({
method: z.literal('notifications/message'),
params: z.object({
@@ -48,7 +49,7 @@ export function usePromptsFromClaudeInChrome(
}
if (mcpClient) {
mcpClient.client.setNotificationHandler(ClaudeInChromePromptNotificationSchema() as any, notification => {
mcpClient.client.setNotificationHandler(ClaudeInChromePromptNotificationSchema(), notification => {
if (mcpClientRef.current !== mcpClient) {
return;
}