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

@@ -63,6 +63,7 @@ import { loadMemoryPrompt } from '../memdir/memdir.js'
import { isUndercover } from '../utils/undercover.js'
import { getAntModelOverrideConfig } from '../utils/model/antModels.js'
import { isMcpInstructionsDeltaEnabled } from '../utils/mcpInstructionsDelta.js'
import { getCurrentMode } from 'src/modes/store.js'
// Dead code elimination: conditional imports for feature-gated modules
/* eslint-disable @typescript-eslint/no-require-imports */
@@ -406,6 +407,12 @@ Do not use a colon before tool calls — "Let me read the file:" should be "Let
These instructions do not apply to code or tool calls.`
}
function getModePersonaSection(): string | null {
const mode = getCurrentMode()
if (!mode.systemPrompt) return null
return mode.systemPrompt
}
export async function getSystemPrompt(
tools: Tools,
model: string,
@@ -454,6 +461,7 @@ ${CYBER_RISK_INSTRUCTION}`,
}
const dynamicSections = [
systemPromptSection('mode_persona', () => getModePersonaSection()),
systemPromptSection('session_guidance', () =>
getSessionSpecificGuidanceSection(enabledTools, skillToolCommands),
),