Add BRAIN_DISABLED flag and fix Ollama tool call formatting
Features: - Add BRAIN_DISABLED feature flag to hide all Brain functionality - When enabled, hides Brain banner, status indicator, menu, and commands - Flag location: src/constants/brain.ts Fixes: - Fix Ollama 400 error by properly formatting tool_calls in messages - Update OllamaMessage type to include tool_calls field - Fix Brain menu keyboard not working (add missing modes to isMenuOpen) UI Changes: - Remove "^Tab toggle mode" hint from status bar - Remove "ctrl+t to hide todos" hint from status bar Files modified: - src/constants/brain.ts (add BRAIN_DISABLED flag) - src/types/ollama.ts (add tool_calls to OllamaMessage) - src/providers/ollama/chat.ts (format tool_calls in messages) - src/tui-solid/components/header.tsx (hide Brain UI when disabled) - src/tui-solid/components/status-bar.tsx (remove hints) - src/tui-solid/components/command-menu.tsx (filter brain command) - src/tui-solid/components/input-area.tsx (fix isMenuOpen modes) - src/tui-solid/routes/session.tsx (skip brain menu when disabled) - src/services/brain.ts (early return when disabled) - src/services/chat-tui/initialize.ts (skip brain init when disabled)
This commit is contained in:
@@ -74,7 +74,37 @@ const MODE_PROMPT_BUILDERS: Record<
|
||||
};
|
||||
|
||||
/**
|
||||
* Get git context for prompt building
|
||||
* Execute git command asynchronously
|
||||
*/
|
||||
const execGitCommand = (args: string[]): Promise<string> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const { spawn } = require("child_process");
|
||||
const proc = spawn("git", args, { cwd: process.cwd() });
|
||||
let stdout = "";
|
||||
let stderr = "";
|
||||
|
||||
proc.stdout.on("data", (data: Buffer) => {
|
||||
stdout += data.toString();
|
||||
});
|
||||
|
||||
proc.stderr.on("data", (data: Buffer) => {
|
||||
stderr += data.toString();
|
||||
});
|
||||
|
||||
proc.on("close", (code: number) => {
|
||||
if (code === 0) {
|
||||
resolve(stdout.trim());
|
||||
} else {
|
||||
reject(new Error(stderr || `git exited with code ${code}`));
|
||||
}
|
||||
});
|
||||
|
||||
proc.on("error", reject);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Get git context for prompt building (async, non-blocking)
|
||||
*/
|
||||
export const getGitContext = async (): Promise<{
|
||||
isGitRepo: boolean;
|
||||
@@ -83,16 +113,15 @@ export const getGitContext = async (): Promise<{
|
||||
recentCommits?: string[];
|
||||
}> => {
|
||||
try {
|
||||
const { execSync } = await import("child_process");
|
||||
const branch = execSync("git branch --show-current", {
|
||||
encoding: "utf-8",
|
||||
}).trim();
|
||||
const status =
|
||||
execSync("git status --short", { encoding: "utf-8" }).trim() || "(clean)";
|
||||
const commits = execSync("git log --oneline -5", { encoding: "utf-8" })
|
||||
.trim()
|
||||
.split("\n")
|
||||
.filter(Boolean);
|
||||
// Run all git commands in parallel for faster execution
|
||||
const [branch, status, commits] = await Promise.all([
|
||||
execGitCommand(["branch", "--show-current"]),
|
||||
execGitCommand(["status", "--short"]).then((s) => s || "(clean)"),
|
||||
execGitCommand(["log", "--oneline", "-5"]).then((s) =>
|
||||
s.split("\n").filter(Boolean),
|
||||
),
|
||||
]);
|
||||
|
||||
return { isGitRepo: true, branch, status, recentCommits: commits };
|
||||
} catch {
|
||||
return { isGitRepo: false };
|
||||
|
||||
Reference in New Issue
Block a user