991119491c
## Summary Reverse-engineered the official Claude Code CLI (v2.1.91) buddy/companion system and aligned our implementation to match. ## Changes (7 files) ### Added - `src/buddy/CompanionCard.tsx` (+109) JSX bordered card matching official vc8: rarity header, colored sprite, name, personality, 10-bar stats, last reaction in nested border. - `src/buddy/companionReact.ts` (+156) Reaction system matching official ZUK+Dc8: 45s rate limiting, @-mention detection, transcript builder (12 msgs, 5000 chars), POST buddy_react API. ### Modified - `src/commands/buddy/index.ts` type: local -> local-jsx, description/argumentHint/immediate/isHidden. - `src/commands/buddy/buddy.ts` LocalCommandCall -> LocalJSXCommandCall signature (onDone, context, args). Removed mute/unmute/rehatch (official uses off/on only). /buddy show returns CompanionCard JSX instead of plain text. Pet auto-unmutes. companionMuted writes globalConfig (matches UI read source). - `src/screens/REPL.tsx` (line 2808) globalThis.fireCompanionObserver -> import triggerCompanionReaction. - `src/state/AppStateStore.ts` — comment fix. - `src/types/global.d.ts` — removed fireCompanionObserver declaration. ## Data flow (verified consistent) - companionMuted: saveGlobalConfig() <-> getGlobalConfig() (6 read sites) - companionReaction: setAppState() <-> useAppState() (4 sites) - companionPetAt: setAppState() <-> useAppState() (2 sites) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
82 lines
3.2 KiB
TypeScript
82 lines
3.2 KiB
TypeScript
/**
|
|
* Global declarations for compile-time macros and internal-only identifiers
|
|
* that are eliminated via Bun's MACRO/bundle feature system.
|
|
*/
|
|
|
|
// ============================================================================
|
|
// MACRO — Bun compile-time constants injected via bunfig.toml [define] (dev)
|
|
// and Bun.build({ define }) (production). See bunfig.toml & build.ts.
|
|
declare namespace MACRO {
|
|
export const VERSION: string
|
|
export const BUILD_TIME: string
|
|
export const FEEDBACK_CHANNEL: string
|
|
export const ISSUES_EXPLAINER: string
|
|
export const NATIVE_PACKAGE_URL: string
|
|
export const PACKAGE_URL: string
|
|
export const VERSION_CHANGELOG: string
|
|
}
|
|
|
|
// ============================================================================
|
|
// Internal Anthropic-only identifiers (dead-code eliminated in open-source)
|
|
// These are referenced inside `MACRO(() => ...)` or `false && ...` blocks.
|
|
|
|
// Model resolution (internal)
|
|
declare function resolveAntModel(model: string): import('../utils/model/antModels.js').AntModel | undefined
|
|
declare function getAntModels(): import('../utils/model/antModels.js').AntModel[]
|
|
declare function getAntModelOverrideConfig(): {
|
|
defaultSystemPromptSuffix?: string
|
|
[key: string]: unknown
|
|
} | null
|
|
|
|
// Companion reactions handled by src/buddy/companionReact.ts (direct import)
|
|
|
|
// Metrics (internal)
|
|
type ApiMetricEntry = { ttftMs: number; firstTokenTime: number; lastTokenTime: number; responseLengthBaseline: number; endResponseLength: number }
|
|
declare const apiMetricsRef: React.RefObject<ApiMetricEntry[]> | null
|
|
declare function computeTtftText(metrics: ApiMetricEntry[]): string
|
|
|
|
// Gate/feature system (internal)
|
|
declare const Gates: Record<string, boolean>
|
|
declare function GateOverridesWarning(): JSX.Element | null
|
|
declare function ExperimentEnrollmentNotice(): JSX.Element | null
|
|
|
|
// Hook timing threshold (re-exported from services/tools/toolExecution.ts)
|
|
declare const HOOK_TIMING_DISPLAY_THRESHOLD_MS: number
|
|
|
|
// Ultraplan (internal)
|
|
declare function UltraplanChoiceDialog(props: Record<string, unknown>): JSX.Element | null
|
|
declare function UltraplanLaunchDialog(props: Record<string, unknown>): JSX.Element | null
|
|
declare function launchUltraplan(...args: unknown[]): Promise<string>
|
|
|
|
// T — Generic type parameter leaked from React compiler output
|
|
// (react/compiler-runtime emits compiled JSX that loses generic type params)
|
|
declare type T = unknown
|
|
|
|
// Tungsten (internal)
|
|
declare function TungstenPill(props?: { key?: string; selected?: boolean }): JSX.Element | null
|
|
|
|
// ============================================================================
|
|
// Build-time constants BUILD_TARGET/BUILD_ENV/INTERFACE_TYPE — removed (zero runtime usage)
|
|
|
|
// ============================================================================
|
|
// Ink custom JSX intrinsic elements — see src/types/ink-jsx.d.ts
|
|
|
|
// ============================================================================
|
|
// Bun text/file loaders — allow importing non-TS assets as strings
|
|
declare module '*.md' {
|
|
const content: string
|
|
export default content
|
|
}
|
|
declare module '*.txt' {
|
|
const content: string
|
|
export default content
|
|
}
|
|
declare module '*.html' {
|
|
const content: string
|
|
export default content
|
|
}
|
|
declare module '*.css' {
|
|
const content: string
|
|
export default content
|
|
}
|