Files
claude-code/src/query/config.ts
T
Serendipity ed91e47107 feat: 初始化项目结构与核心文件
- 添加项目配置文件(tsconfig.json、bunfig.toml、.gitignore、.env.example)
- 创建文档架构图(00runtime.png 至 08-state-data-flow.png)
- 添加核心工具常量定义(FileEditTool、AgentTool、BashTool 等)
- 实现基础命令框架(help、exit、config、model 等)
- 添加 Ink TUI 组件库和布局引擎
- 包含内存管理、沙箱、shell 工具等基础工具类
- 设置预加载脚本和版本信息
2026-04-02 17:13:04 +08:00

47 lines
1.8 KiB
TypeScript

import { getSessionId } from '../bootstrap/state.js'
import { checkStatsigFeatureGate_CACHED_MAY_BE_STALE } from '../services/analytics/growthbook.js'
import type { SessionId } from '../types/ids.js'
import { isEnvTruthy } from '../utils/envUtils.js'
// -- config
// Immutable values snapshotted once at query() entry. Separating these from
// the per-iteration State struct and the mutable ToolUseContext makes future
// step() extraction tractable — a pure reducer can take (state, event, config)
// where config is plain data.
//
// Intentionally excludes feature() gates — those are tree-shaking boundaries
// and must stay inline at the guarded blocks for dead-code elimination.
export type QueryConfig = {
sessionId: SessionId
// Runtime gates (env/statsig). NOT feature() gates — see above.
gates: {
// Statsig — CACHED_MAY_BE_STALE already admits staleness, so snapshotting
// once per query() call stays within the existing contract.
streamingToolExecution: boolean
emitToolUseSummaries: boolean
isAnt: boolean
fastModeEnabled: boolean
}
}
export function buildQueryConfig(): QueryConfig {
return {
sessionId: getSessionId(),
gates: {
streamingToolExecution: checkStatsigFeatureGate_CACHED_MAY_BE_STALE(
'tengu_streaming_tool_execution2',
),
emitToolUseSummaries: isEnvTruthy(
process.env.CLAUDE_CODE_EMIT_TOOL_USE_SUMMARIES,
),
isAnt: process.env.USER_TYPE === 'ant',
// Inlined from fastMode.ts to avoid pulling its heavy module graph
// (axios, settings, auth, model, oauth, config) into test shards that
// didn't previously load it — changes init order and breaks unrelated tests.
fastModeEnabled: !isEnvTruthy(process.env.CLAUDE_CODE_DISABLE_FAST_MODE),
},
}
}