From 2ae463a8fe6a628c9e00a467a8300130c3074bfa Mon Sep 17 00:00:00 2001 From: Askhz <1361267452@qq.com> Date: Mon, 18 May 2026 17:28:16 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20dev.ts=20=E5=92=8C=20build.ts=20?= =?UTF-8?q?=E7=BB=9F=E4=B8=80=E4=BB=8E=20defines.ts=20=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=20feature=20flags?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 之前三个文件各自维护独立的 feature 列表,导致合并时容易漏掉变更 (如 CONTEXT_COLLAPSE 在 defines.ts 已禁用但 build.ts 仍启用)。 现在 dev.ts 和 build.ts 都从 defines.ts 导入 DEFAULT_BUILD_FEATURES, 与上游保持一致的单一定义源模式。 Co-Authored-By: CoStrict-DeepSeek-V4-Pro --- build.ts | 40 ++-------------------------------------- scripts/dev.ts | 34 ++-------------------------------- 2 files changed, 4 insertions(+), 70 deletions(-) diff --git a/build.ts b/build.ts index 4c3717d65..745866950 100644 --- a/build.ts +++ b/build.ts @@ -1,6 +1,6 @@ import { readdir, readFile, writeFile, cp, unlink, mkdir } from 'fs/promises' import { join } from 'path' -import { getMacroDefines } from './scripts/defines.ts' +import { getMacroDefines, DEFAULT_BUILD_FEATURES } from './scripts/defines.ts' const outdir = 'dist' @@ -23,44 +23,8 @@ if (process.env.SKIP_REVIEW_BUILTIN) { } } -// Default features that match the official CLI build. +// Feature flags imported from defines.ts (single source of truth). // Additional features can be enabled via FEATURE_=1 env vars. -const DEFAULT_BUILD_FEATURES = [ - 'AGENT_TRIGGERS_REMOTE', - 'CHICAGO_MCP', - 'VOICE_MODE', - 'SHOT_STATS', - 'PROMPT_CACHE_BREAK_DETECTION', - 'TOKEN_BUDGET', - // P0: local features - 'AGENT_TRIGGERS', - 'ULTRATHINK', - 'BUILTIN_EXPLORE_PLAN_AGENTS', - 'LODESTONE', - // P1: API-dependent features - 'EXTRACT_MEMORIES', - 'VERIFICATION_AGENT', - 'KAIROS_BRIEF', - 'AWAY_SUMMARY', - 'ULTRAPLAN', - // P2: daemon + remote control server - 'DAEMON', - // PR-package restored features - 'WORKFLOW_SCRIPTS', - 'HISTORY_SNIP', - // 'CONTEXT_COLLAPSE', // 已禁用:实现是空壳 stub,启用后会抑制 auto compact 导致上下文管理完全失效 - 'MONITOR_TOOL', - 'FORK_SUBAGENT', -// 'UDS_INBOX', - 'KAIROS', - 'COORDINATOR_MODE', - 'LAN_PIPES', - // 'REVIEW_ARTIFACT', // API 请求无响应,需进一步排查 schema 兼容性 - // P3: poor mode (disable extract_memories + prompt_suggestion) - 'POOR', - // P3: serve mode (HTTP API server) - 'DIRECT_CONNECT', -] // Collect FEATURE_* env vars → Bun.build features const envFeatures = Object.keys(process.env) diff --git a/scripts/dev.ts b/scripts/dev.ts index 3eca62bc6..7a54af2ba 100644 --- a/scripts/dev.ts +++ b/scripts/dev.ts @@ -6,7 +6,7 @@ */ import { join, dirname } from "node:path"; import { fileURLToPath } from "node:url"; -import { getMacroDefines } from "./defines.ts"; +import { getMacroDefines, DEFAULT_BUILD_FEATURES as DEFAULT_FEATURES } from "./defines.ts"; // Resolve project root from this script's location const __filename = fileURLToPath(import.meta.url); @@ -22,37 +22,7 @@ const defineArgs = Object.entries(defines).flatMap(([k, v]) => [ ]); // Bun --feature flags: enable feature() gates at runtime. -// Default features enabled in dev mode. -const DEFAULT_FEATURES = [ - "BUDDY", "TRANSCRIPT_CLASSIFIER", "BRIDGE_MODE", - "AGENT_TRIGGERS_REMOTE", "CHICAGO_MCP", "VOICE_MODE", - "SHOT_STATS", "PROMPT_CACHE_BREAK_DETECTION", "TOKEN_BUDGET", - // P0: local features - "AGENT_TRIGGERS", - "ULTRATHINK", - "BUILTIN_EXPLORE_PLAN_AGENTS", - "LODESTONE", - // P1: API-dependent features - "EXTRACT_MEMORIES", "VERIFICATION_AGENT", - "KAIROS_BRIEF", "AWAY_SUMMARY", "ULTRAPLAN", - // P2: daemon + remote control server - "DAEMON", - // PR-package restored features - "WORKFLOW_SCRIPTS", - "HISTORY_SNIP", - // "CONTEXT_COLLAPSE", // 已禁用:实现是空壳 stub,启用后会抑制 auto compact 导致上下文管理完全失效 - "MONITOR_TOOL", - "FORK_SUBAGENT", - "UDS_INBOX", - "KAIROS", - "COORDINATOR_MODE", - "LAN_PIPES", - // "REVIEW_ARTIFACT", // API 请求无响应,需进一步排查 schema 兼容性 - // P3: poor mode (disable extract_memories + prompt_suggestion) - "POOR", - // P3: serve mode (HTTP API server) - "DIRECT_CONNECT", -]; +// Default features imported from defines.ts (single source of truth). // Any env var matching FEATURE_=1 will also enable that feature. // e.g. FEATURE_PROACTIVE=1 bun run dev