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:
2026-02-02 13:25:38 -05:00
parent 2eadda584a
commit c839fc4d68
114 changed files with 17243 additions and 273 deletions

132
src/constants/skills.ts Normal file
View File

@@ -0,0 +1,132 @@
/**
* Skill System Constants
*
* Constants for skill loading, matching, and execution.
*/
import { join } from "path";
import { DIRS } from "@constants/paths";
/**
* Skill file configuration
*/
export const SKILL_FILE = {
NAME: "SKILL.md",
FRONTMATTER_DELIMITER: "---",
ENCODING: "utf-8",
} as const;
/**
* Skill directories
*/
export const SKILL_DIRS = {
BUILTIN: join(__dirname, "..", "skills"),
USER: join(DIRS.config, "skills"),
PROJECT: ".codetyper/skills",
} as const;
/**
* Skill loading configuration
*/
export const SKILL_LOADING = {
CACHE_TTL_MS: 60000,
MAX_SKILLS: 100,
MAX_FILE_SIZE_BYTES: 100000,
} as const;
/**
* Skill matching configuration
*/
export const SKILL_MATCHING = {
MIN_CONFIDENCE: 0.7,
EXACT_MATCH_BONUS: 0.3,
COMMAND_PREFIX: "/",
FUZZY_THRESHOLD: 0.6,
} as const;
/**
* Default skill metadata values
*/
export const SKILL_DEFAULTS = {
VERSION: "1.0.0",
TRIGGER_TYPE: "command" as const,
AUTO_TRIGGER: false,
REQUIRED_TOOLS: [] as string[],
} as const;
/**
* Skill error messages
*/
export const SKILL_ERRORS = {
NOT_FOUND: (id: string) => `Skill not found: ${id}`,
INVALID_FRONTMATTER: (file: string) => `Invalid frontmatter in: ${file}`,
MISSING_REQUIRED_FIELD: (field: string, file: string) =>
`Missing required field '${field}' in: ${file}`,
LOAD_FAILED: (file: string, error: string) =>
`Failed to load skill from ${file}: ${error}`,
NO_MATCH: "No matching skill found for input",
EXECUTION_FAILED: (id: string, error: string) =>
`Skill execution failed for ${id}: ${error}`,
} as const;
/**
* Skill titles for UI
*/
export const SKILL_TITLES = {
LOADING: (name: string) => `Loading skill: ${name}`,
EXECUTING: (name: string) => `Executing skill: ${name}`,
MATCHED: (name: string, confidence: number) =>
`Matched skill: ${name} (${(confidence * 100).toFixed(0)}%)`,
COMPLETED: (name: string) => `Skill completed: ${name}`,
FAILED: (name: string) => `Skill failed: ${name}`,
} as const;
/**
* Built-in skill IDs
*/
export const BUILTIN_SKILLS = {
COMMIT: "commit",
REVIEW_PR: "review-pr",
EXPLAIN: "explain",
FEATURE_DEV: "feature-dev",
} as const;
/**
* Skill trigger patterns for common commands
*/
export const SKILL_TRIGGER_PATTERNS = {
COMMIT: [
"/commit",
"commit changes",
"commit this",
"git commit",
"make a commit",
],
REVIEW_PR: [
"/review-pr",
"/review",
"review pr",
"review this pr",
"review pull request",
"code review",
],
EXPLAIN: [
"/explain",
"explain this",
"explain code",
"what does this do",
"how does this work",
],
FEATURE_DEV: [
"/feature",
"/feature-dev",
"implement feature",
"new feature",
"build feature",
],
} as const;
/**
* Required fields in skill frontmatter
*/
export const SKILL_REQUIRED_FIELDS = ["id", "name", "description", "triggers"] as const;