fix: eliminate 8 as any in MCP handlers, structured output, and stream events+Claude Soul Document 蒸馏 (#1258)

* 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

* docs: add usage note to CLAUDE_PERSONA explaining it's a reference template for YAML config

CodeRabbit noted that CLAUDE_PERSONA has no direct imports. This is
intentional — it's a reference template for users defining custom modes
via ~/.claude/modes/claude.yaml, not a programmatically imported constant.
This commit is contained in:
James F
2026-06-07 20:30:03 +08:00
committed by GitHub
parent be0c65678d
commit 1faedff25d

View File

@@ -5,6 +5,12 @@
* This is NOT the full 70KB training constitution but a 3KB operational * This is NOT the full 70KB training constitution but a 3KB operational
* extract of the character traits and judgment principles that make Claude * extract of the character traits and judgment principles that make Claude
* distinct. Designed to be injected as a mode's systemPrompt. * distinct. Designed to be injected as a mode's systemPrompt.
*
* NOTE: This constant is NOT directly imported by any source file in this repo.
* It serves as a **reference template** for users who define custom modes via
* `~/.claude/modes/claude.yaml`. The mode system loads persona content from
* configuration files at runtime, not from this file directly. Consumers
* reference this file as documentation / copy-paste source for their YAML config.
*/ */
export const CLAUDE_PERSONA = `# Character export const CLAUDE_PERSONA = `# Character