Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ bun run health
# Check unused exports
bun run check:unused

# Full check (typecheck + lint + test) — run after completing any task
bun run test:all

Comment on lines +61 to +63
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix command description mismatch with actual script behavior.

Line 61 says test:all includes lint, but bun run test:all currently runs only typecheck + test. Please either update the description or include lint in the script to avoid misleading contributors.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CLAUDE.md` around lines 61 - 63, The README line for the "test:all" command
is inaccurate: it claims "typecheck + lint + test" but the actual "test:all"
script only runs typecheck + test; either update the CLAUDE.md description to
match the current behavior or change the "test:all" npm/bun script to include
the lint step. Locate the "test:all" script in package.json (script name
"test:all") and either add the lint invocation into that script (e.g., run the
lint script between typecheck and test) or edit the sentence in CLAUDE.md to
state precisely what "test:all" runs (typecheck + test).

bun run typecheck

# Remote Control Server
Expand Down
43 changes: 1 addition & 42 deletions build.ts
Original file line number Diff line number Diff line change
@@ -1,55 +1,14 @@
import { readdir, readFile, writeFile, cp } from 'fs/promises'
import { join } from 'path'
import { getMacroDefines } from './scripts/defines.ts'
import { DEFAULT_BUILD_FEATURES } from './scripts/defines.ts'

const outdir = 'dist'

// Step 1: Clean output directory
const { rmSync } = await import('fs')
rmSync(outdir, { recursive: true, force: true })

// Default features that match the official CLI build.
// Additional features can be enabled via FEATURE_<NAME>=1 env vars.
const DEFAULT_BUILD_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',
// ACP (Agent Client Protocol) agent mode
'ACP',
// PR-package restored features
'WORKFLOW_SCRIPTS',
'HISTORY_SNIP',
'CONTEXT_COLLAPSE',
'MONITOR_TOOL',
'FORK_SUBAGENT',
// 'UDS_INBOX',
'KAIROS',
'COORDINATOR_MODE',
'LAN_PIPES',
'BG_SESSIONS',
'TEMPLATES',
// 'REVIEW_ARTIFACT', // API 请求无响应,需进一步排查 schema 兼容性
// P3: poor mode (disable extract_memories + prompt_suggestion)
'POOR',
]

// Collect FEATURE_* env vars → Bun.build features
const envFeatures = Object.keys(process.env)
.filter(k => k.startsWith('FEATURE_'))
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"postinstall": "node scripts/run-parallel.mjs scripts/postinstall.cjs scripts/setup-chrome-mcp.mjs",
"docs:dev": "npx mintlify dev",
"typecheck": "tsc --noEmit",
"test:all": "bun run typecheck && bun test",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

test:all is not actually “all” checks right now.

The script omits lint, while docs/CI messaging treat it as full validation. This can let lint regressions pass when developers run only test:all.

Suggested fix
-    "test:all": "bun run typecheck && bun test",
+    "test:all": "bun run typecheck && bun run lint && bun test",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` at line 61, The "test:all" npm script currently only runs
typecheck and tests and should include linting; update the "test:all" entry in
package.json (the "test:all" script) to run lint before typecheck and tests
(e.g., run the existing lint script then typecheck then test) so lint
regressions are caught when developers run test:all; ensure the order is lint ->
typecheck -> test and keep the same execution environment (bun) as other
scripts.

"rcs": "bun run scripts/rcs.ts"
},
"dependencies": {
Expand Down
10 changes: 8 additions & 2 deletions packages/audio-capture-napi/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { createRequire } from 'node:module'

// createRequire works in both Bun and Node.js ESM contexts.
// Needed because this package is "type": "module" but uses require() for
// loading native .node addons — bare require is not available in Node.js ESM.
const nodeRequire = createRequire(import.meta.url)
Comment on lines +1 to +6
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Inspect native addon require handling and build-time defines.
# Expectation: build scripts/comments indicate import.meta.require/direct require
# is the supported analyzable form; createRequire/nodeRequire aliases should be
# explicitly handled before keeping this change.

rg -n -C4 'AUDIO_CAPTURE_NODE_PATH|audio-capture\.node|import\.meta\.require|createRequire|nodeRequire|require\(process\.env' \
  --glob '*.ts' \
  --glob '*.js'

Repository: claude-code-best/claude-code

Length of output: 13385


Bun static analysis requires a direct native addon require call, not one hidden behind a createRequire alias.

The native addon path at line 42-46 documents that AUDIO_CAPTURE_NODE_PATH must remain a direct require() call for Bun to analyze it statically. Using nodeRequire(process.env.AUDIO_CAPTURE_NODE_PATH) breaks this because Bun cannot trace the call through an alias. Additionally, importing createRequire from node:module violates the guideline to use only Bun runtime APIs.

Use import.meta.require instead, which the build system automatically post-processes to Node.js-compatible versions:

-import { createRequire } from 'node:module'
-
-// createRequire works in both Bun and Node.js ESM contexts.
-// Needed because this package is "type": "module" but uses require() for
-// loading native .node addons — bare require is not available in Node.js ESM.
-const nodeRequire = createRequire(import.meta.url)
+// Bun API; build.ts post-processes import.meta.require to Node.js compatibility.
+const nodeRequire = import.meta.require
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/audio-capture-napi/src/index.ts` around lines 1 - 6, The code uses
createRequire and a nodeRequire alias to load the native addon which prevents
Bun's static analysis from seeing the require; remove the import of
createRequire and the nodeRequire variable, and replace uses of
nodeRequire(process.env.AUDIO_CAPTURE_NODE_PATH) with a direct
import.meta.require(process.env.AUDIO_CAPTURE_NODE_PATH) call so
AUDIO_CAPTURE_NODE_PATH remains a direct native-addon require; update any
references to createRequire/nodeRequire in this module (and keep the environment
var name AUDIO_CAPTURE_NODE_PATH) and do not introduce node:module imports.


type AudioCaptureNapi = {
startRecording(
Expand Down Expand Up @@ -41,7 +47,7 @@ function loadModule(): AudioCaptureNapi | null {
if (process.env.AUDIO_CAPTURE_NODE_PATH) {
try {
// eslint-disable-next-line @typescript-eslint/no-require-imports
cachedModule = require(
cachedModule = nodeRequire(
process.env.AUDIO_CAPTURE_NODE_PATH,
) as AudioCaptureNapi
return cachedModule
Expand All @@ -63,7 +69,7 @@ function loadModule(): AudioCaptureNapi | null {
for (const p of fallbacks) {
try {
// eslint-disable-next-line @typescript-eslint/no-require-imports
cachedModule = require(p) as AudioCaptureNapi
cachedModule = nodeRequire(p) as AudioCaptureNapi
return cachedModule
} catch {
// try next
Expand Down
9 changes: 7 additions & 2 deletions packages/color-diff-napi/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@
* getSyntaxTheme always returns the default for the given Claude theme.
*/

import { createRequire } from 'node:module'
import { diffArrays } from 'diff'
import type * as hljsNamespace from 'highlight.js'
import { basename, extname } from 'path'

// createRequire works in both Bun and Node.js ESM contexts.
// Needed because this package is "type": "module" but uses require() for
// lazy loading — bare require is not available in Node.js ESM.
const nodeRequire = createRequire(import.meta.url)

// Lazy: defers loading highlight.js until first render. The full bundle
// registers 190+ language grammars at require time (~50MB, 100-200ms on
// macOS, several× that on Windows). With a top-level import, any caller
Expand All @@ -34,8 +40,7 @@ type HLJSApi = typeof hljsNamespace.default
let cachedHljs: HLJSApi | null = null
function hljs(): HLJSApi {
if (cachedHljs) return cachedHljs
// eslint-disable-next-line @typescript-eslint/no-require-imports
const mod = require('highlight.js')
const mod = nodeRequire('highlight.js')
// highlight.js uses `export =` (CJS). Under bun/ESM the interop wraps it
// in .default; under node CJS the module IS the API. Check at runtime.
cachedHljs = 'default' in mod && mod.default ? mod.default : mod
Expand Down
7 changes: 3 additions & 4 deletions packages/image-processor-napi/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { readFileSync, unlinkSync } from 'node:fs'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Check for node:fs usage patterns and verify if Bun APIs are available

# Search for other node:fs imports in the codebase
echo "=== Checking for node:fs imports ==="
rg -n "from ['\"]node:fs['\"]" --type=ts

# Search for Bun.file usage patterns
echo -e "\n=== Checking Bun.file usage patterns ==="
rg -n "Bun\.file\(" --type=ts -A 2

# Check for readFileSync usage
echo -e "\n=== Checking readFileSync usage ==="
rg -n "readFileSync" --type=ts

Repository: claude-code-best/claude-code

Length of output: 17530


Remove the unused Bun.file() call on line 65.

Line 65 creates a Bun.file(tmpPath) variable that is never used. The immediately following line uses readFileSync(tmpPath) instead. Remove the unused variable assignment.

Relevant code context
const file = Bun.file(tmpPath)
const buffer: Buffer = readFileSync(tmpPath)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/image-processor-napi/src/index.ts` at line 1, Remove the unused
Bun.file call by deleting the variable assignment "const file =
Bun.file(tmpPath)" (the unused symbol file) and keep the existing
readFileSync(tmpPath) usage; ensure no other code references "file" or
Bun.file(tmpPath) in the surrounding logic (e.g., where tmpPath and buffer are
used) so the code compiles without the unused variable.

import sharpModule from 'sharp'

export const sharp = sharpModule
Expand Down Expand Up @@ -62,13 +63,11 @@ return "${tmpPath}"
}

const file = Bun.file(tmpPath)
// Use synchronous read via Node compat
const fs = require('fs')
const buffer: Buffer = fs.readFileSync(tmpPath)
const buffer: Buffer = readFileSync(tmpPath)
Comment on lines 65 to +66
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Remove unused Bun.file() call - dead code detected.

Line 65 declares const file = Bun.file(tmpPath) but this variable is never used. Line 66 immediately uses readFileSync(tmpPath) instead. This suggests an incomplete refactor.

🧹 Proposed fix to remove dead code

Option 1: Remove the unused line (recommended for this synchronous context)

-        const file = Bun.file(tmpPath)
         const buffer: Buffer = readFileSync(tmpPath)

Option 2: Use Bun APIs consistently (if Bun has sync file reading)

If Bun provides synchronous file reading APIs, consider using them instead to align with coding guidelines:

const file = Bun.file(tmpPath)
const buffer = Buffer.from(/* appropriate Bun sync API */)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const file = Bun.file(tmpPath)
// Use synchronous read via Node compat
const fs = require('fs')
const buffer: Buffer = fs.readFileSync(tmpPath)
const buffer: Buffer = readFileSync(tmpPath)
const buffer: Buffer = readFileSync(tmpPath)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/image-processor-napi/src/index.ts` around lines 65 - 66, The code
contains an unused Bun.file(tmpPath) allocation (const file = Bun.file(tmpPath))
that is dead code because the buffer is read with readFileSync(tmpPath) instead;
remove the unused declaration (Bun.file(tmpPath)) or, if you intend to use Bun
APIs, replace the readFileSync usage by the corresponding Bun sync read and
assign to buffer consistently (update references to file, tmpPath, and buffer
accordingly) so there are no unused variables.


// Clean up temp file
try {
fs.unlinkSync(tmpPath)
unlinkSync(tmpPath)
} catch {
// ignore cleanup errors
}
Expand Down
49 changes: 49 additions & 0 deletions scripts/defines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,52 @@ export function getMacroDefines(): Record<string, string> {
"MACRO.VERSION_CHANGELOG": JSON.stringify(""),
};
}

/**
* Default feature flags enabled in both Bun.build and Vite builds.
* Additional features can be enabled via FEATURE_<NAME>=1 env vars.
*
* Used by:
* - build.ts (Bun.build)
* - scripts/vite-plugin-feature-flags.ts (Vite/Rollup)
* - scripts/dev.ts (bun run dev)
*/
export const DEFAULT_BUILD_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',
// ACP (Agent Client Protocol) agent mode
'ACP',
// PR-package restored features
'WORKFLOW_SCRIPTS',
'HISTORY_SNIP',
'CONTEXT_COLLAPSE',
'MONITOR_TOOL',
'FORK_SUBAGENT',
// 'UDS_INBOX',
'KAIROS',
'COORDINATOR_MODE',
'LAN_PIPES',
'BG_SESSIONS',
'TEMPLATES',
// 'REVIEW_ARTIFACT', // API 请求无响应,需进一步排查 schema 兼容性
// P3: poor mode (disable extract_memories + prompt_suggestion)
'POOR',
] as const;
Comment on lines +29 to +67
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Preserve the previous dev-only feature defaults.

DEFAULT_BUILD_FEATURES is now reused by scripts/dev.ts, but Line 58 comments out UDS_INBOX, which the previous dev default list enabled. This silently changes bun run dev behavior. Consider adding a separate dev default list, or re-enable UDS_INBOX if this shared list is intended to preserve dev parity.

Suggested direction
 export const DEFAULT_BUILD_FEATURES = [
     'BUDDY', 'TRANSCRIPT_CLASSIFIER', 'BRIDGE_MODE',
@@
     'POOR',
 ] as const;
+
+export const DEFAULT_DEV_FEATURES = [
+    ...DEFAULT_BUILD_FEATURES,
+    'UDS_INBOX',
+] as const;

Then have scripts/dev.ts consume DEFAULT_DEV_FEATURES instead of DEFAULT_BUILD_FEATURES.

Based on learnings: Dev mode enables all feature flags by default via -d flag injection through scripts/dev.ts.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const DEFAULT_BUILD_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',
// ACP (Agent Client Protocol) agent mode
'ACP',
// PR-package restored features
'WORKFLOW_SCRIPTS',
'HISTORY_SNIP',
'CONTEXT_COLLAPSE',
'MONITOR_TOOL',
'FORK_SUBAGENT',
// 'UDS_INBOX',
'KAIROS',
'COORDINATOR_MODE',
'LAN_PIPES',
'BG_SESSIONS',
'TEMPLATES',
// 'REVIEW_ARTIFACT', // API 请求无响应,需进一步排查 schema 兼容性
// P3: poor mode (disable extract_memories + prompt_suggestion)
'POOR',
] as const;
export const DEFAULT_BUILD_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',
// ACP (Agent Client Protocol) agent mode
'ACP',
// PR-package restored features
'WORKFLOW_SCRIPTS',
'HISTORY_SNIP',
'CONTEXT_COLLAPSE',
'MONITOR_TOOL',
'FORK_SUBAGENT',
// 'UDS_INBOX',
'KAIROS',
'COORDINATOR_MODE',
'LAN_PIPES',
'BG_SESSIONS',
'TEMPLATES',
// 'REVIEW_ARTIFACT', // API 请求无响应,需进一步排查 schema 兼容性
// P3: poor mode (disable extract_memories + prompt_suggestion)
'POOR',
] as const;
export const DEFAULT_DEV_FEATURES = [
...DEFAULT_BUILD_FEATURES,
'UDS_INBOX',
] as const;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/defines.ts` around lines 29 - 67, DEFAULT_BUILD_FEATURES is reused by
scripts/dev.ts but has UDS_INBOX commented out, which changes bun run dev
behavior; restore dev parity by creating a separate constant
DEFAULT_DEV_FEATURES (including UDS_INBOX and any other dev-only flags) and
update scripts/dev.ts to consume DEFAULT_DEV_FEATURES instead of
DEFAULT_BUILD_FEATURES, leaving DEFAULT_BUILD_FEATURES unchanged for production
builds.

38 changes: 3 additions & 35 deletions scripts/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } from "./defines.ts";

// Resolve project root from this script's location
const __filename = fileURLToPath(import.meta.url);
Expand All @@ -22,47 +22,15 @@ 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",
// ACP (Agent Client Protocol) agent mode
"ACP",
// PR-package restored features
"WORKFLOW_SCRIPTS",
"HISTORY_SNIP",
"CONTEXT_COLLAPSE",
"MONITOR_TOOL",
"FORK_SUBAGENT",
"UDS_INBOX",
"KAIROS",
"COORDINATOR_MODE",
"LAN_PIPES",
"BG_SESSIONS",
"TEMPLATES",
// "REVIEW_ARTIFACT", // API 请求无响应,需进一步排查 schema 兼容性
// P3: poor mode (disable extract_memories + prompt_suggestion)
"POOR",
];
// Uses the shared DEFAULT_BUILD_FEATURES list from defines.ts.

// Any env var matching FEATURE_<NAME>=1 will also enable that feature.
// e.g. FEATURE_PROACTIVE=1 bun run dev
const envFeatures = Object.entries(process.env)
.filter(([k]) => k.startsWith("FEATURE_"))
.map(([k]) => k.replace("FEATURE_", ""));

const allFeatures = [...new Set([...DEFAULT_FEATURES, ...envFeatures])];
const allFeatures = [...new Set([...DEFAULT_BUILD_FEATURES, ...envFeatures])];
const featureArgs = allFeatures.flatMap((name) => ["--feature", name]);

// If BUN_INSPECT is set, pass --inspect-wait to the child process
Expand Down
38 changes: 1 addition & 37 deletions scripts/vite-plugin-feature-flags.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,5 @@
import type { Plugin } from "rollup";

/**
* Default features that match the official CLI build.
* Additional features can be enabled via FEATURE_<NAME>=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",
"MONITOR_TOOL",
"FORK_SUBAGENT",
"KAIROS",
"COORDINATOR_MODE",
"LAN_PIPES",
// P3: poor mode
"POOR",
];
import { DEFAULT_BUILD_FEATURES } from "./defines.ts";

/**
* Collect enabled feature flags from defaults + env vars.
Expand Down
6 changes: 6 additions & 0 deletions src/memdir/findRelevantMemories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { logForDebugging } from '../utils/debug.js'
import { errorMessage } from '../utils/errors.js'
import { getDefaultSonnetModel } from '../utils/model/model.js'
import { sideQuery } from '../utils/sideQuery.js'
import type { LangfuseSpan } from '../services/langfuse/index.js'
import { jsonParse } from '../utils/slowOperations.js'
import {
formatMemoryManifest,
Expand Down Expand Up @@ -42,6 +43,7 @@ export async function findRelevantMemories(
signal: AbortSignal,
recentTools: readonly string[] = [],
alreadySurfaced: ReadonlySet<string> = new Set(),
parentSpan?: LangfuseSpan | null,
): Promise<RelevantMemory[]> {
const memories = (await scanMemoryFiles(memoryDir, signal)).filter(
m => !alreadySurfaced.has(m.filePath),
Expand All @@ -55,6 +57,7 @@ export async function findRelevantMemories(
memories,
signal,
recentTools,
parentSpan,
)
const byFilename = new Map(memories.map(m => [m.filename, m]))
const selected = selectedFilenames
Expand All @@ -79,6 +82,7 @@ async function selectRelevantMemories(
memories: MemoryHeader[],
signal: AbortSignal,
recentTools: readonly string[],
parentSpan?: LangfuseSpan | null,
): Promise<string[]> {
const validFilenames = new Set(memories.map(m => m.filename))

Expand Down Expand Up @@ -119,6 +123,8 @@ async function selectRelevantMemories(
},
signal,
querySource: 'memdir_relevance',
optional: true,
parentSpan,
})

const textBlock = result.content.find(block => block.type === 'text')
Expand Down
2 changes: 1 addition & 1 deletion src/services/langfuse/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { initLangfuse, shutdownLangfuse, isLangfuseEnabled, getLangfuseProcessor } from './client.js'
export { createTrace, createSubagentTrace, recordLLMObservation, recordToolObservation, endTrace, createToolBatchSpan, endToolBatchSpan } from './tracing.js'
export { createTrace, createSubagentTrace, createChildSpan, recordLLMObservation, recordToolObservation, endTrace, createToolBatchSpan, endToolBatchSpan } from './tracing.js'
export type { LangfuseSpan } from './tracing.js'
export { sanitizeToolInput, sanitizeToolOutput, sanitizeGlobal } from './sanitize.js'
Loading
Loading