Restructure src/ modules with consistent internal organization
Reorganize major src/ directories to follow a consistent pattern with
core/, menu/, submenu/, inputs/, logs/, layout/, feedback/ subdirectories.
Changes by module:
- stores/: Move 5 store files to stores/core/
- utils/: Create core/ (terminal, tools, etc.) and menu/ (progress-bar)
- api/: Create copilot/core/, copilot/auth/, ollama/core/
- providers/: Create core/, copilot/core/, copilot/auth/, ollama/core/, login/core/
- ui/: Create core/, banner/core/, banner/menu/, spinner/core/,
input-editor/core/, components/core/, components/menu/
- tools/: Create core/ for registry.ts and types.ts
- tui-solid/: Reorganize components/ into menu/, submenu/, inputs/,
logs/, modals/, panels/, layout/, feedback/
- commands/: Create core/ for runner.ts and handlers.ts
- services/: Create core/ for agent.ts, permissions.ts, session.ts,
executor.ts, config.ts
All imports updated to use new paths. TypeScript compilation verified.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { appStore } from "@tui/index.ts";
|
||||
import { isQuietTool } from "@utils/tools.ts";
|
||||
import { isQuietTool } from "@utils/core/tools";
|
||||
import type { ToolCallParams } from "@interfaces/ToolCallParams.ts";
|
||||
|
||||
export const onToolCall = (call: ToolCallParams): void => {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
import chalk from "chalk";
|
||||
import { errorMessage, infoMessage, warningMessage } from "@utils/terminal";
|
||||
import { errorMessage, infoMessage, warningMessage } from "@utils/core/terminal";
|
||||
import { agentLoader } from "@services/agent-loader";
|
||||
import type { ChatState } from "@commands/components/chat/state";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { saveSession } from "@services/session";
|
||||
import { saveSession } from "@services/core/session";
|
||||
import { clearConversation } from "@commands/components/chat/history/clear-conversation";
|
||||
import { appStore } from "@tui/index";
|
||||
import { showContextFiles } from "@commands/components/chat/context/show-context-files";
|
||||
@@ -18,7 +18,7 @@ import { switchAgent } from "@commands/components/chat/agents/switch-agent";
|
||||
import { handleMCP } from "@commands/components/chat/mcp/handle-mcp";
|
||||
import { CommandContext } from "@interfaces/commandContext";
|
||||
import type { CommandHandler } from "@/types/commandHandler";
|
||||
import { successMessage } from "@utils/terminal";
|
||||
import { successMessage } from "@utils/core/terminal";
|
||||
|
||||
const COMMAND_REGISTRY: Map<string, CommandHandler> = new Map<
|
||||
string,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { warningMessage, infoMessage } from "@utils/terminal";
|
||||
import { warningMessage, infoMessage } from "@utils/core/terminal";
|
||||
import type { ChatState } from "@commands/components/chat/state";
|
||||
import COMMAND_REGISTRY from "@commands/components/chat/commands/commandsRegistry";
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { resolve } from "path";
|
||||
import { existsSync } from "fs";
|
||||
import fg from "fast-glob";
|
||||
import { errorMessage, warningMessage } from "@utils/terminal";
|
||||
import { errorMessage, warningMessage } from "@utils/core/terminal";
|
||||
import { loadFile } from "@commands/components/chat/context/load-file";
|
||||
import { IGNORE_FOLDERS } from "@constants/paths";
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { readFile, stat } from "fs/promises";
|
||||
import { basename } from "path";
|
||||
import { warningMessage, successMessage, errorMessage } from "@utils/terminal";
|
||||
import { addContextFile } from "@services/session";
|
||||
import { warningMessage, successMessage, errorMessage } from "@utils/core/terminal";
|
||||
import { addContextFile } from "@services/core/session";
|
||||
|
||||
export const loadFile = async (
|
||||
filePath: string,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { basename } from "path";
|
||||
import { warningMessage, successMessage } from "@utils/terminal";
|
||||
import { warningMessage, successMessage } from "@utils/core/terminal";
|
||||
|
||||
export const removeFile = (
|
||||
filename: string,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import chalk from "chalk";
|
||||
import { basename } from "path";
|
||||
import { getCurrentSession } from "@services/session";
|
||||
import { infoMessage, filePath } from "@utils/terminal";
|
||||
import { getCurrentSession } from "@services/core/session";
|
||||
import { infoMessage, filePath } from "@utils/core/terminal";
|
||||
|
||||
export const showContextFiles = (contextFiles: Map<string, string>): void => {
|
||||
const session = getCurrentSession();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { clearMessages } from "@services/session";
|
||||
import { successMessage } from "@utils/terminal";
|
||||
import { clearMessages } from "@services/core/session";
|
||||
import { successMessage } from "@utils/core/terminal";
|
||||
import type { ChatState } from "@commands/components/chat/state";
|
||||
|
||||
export const clearConversation = (state: ChatState): void => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { successMessage, infoMessage } from "@utils/terminal";
|
||||
import { successMessage, infoMessage } from "@utils/core/terminal";
|
||||
import type { ChatState } from "@commands/components/chat/state";
|
||||
|
||||
export const compactHistory = (state: ChatState): void => {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import chalk from "chalk";
|
||||
import { infoMessage, errorMessage, warningMessage } from "@utils/terminal";
|
||||
import { infoMessage, errorMessage, warningMessage } from "@utils/core/terminal";
|
||||
import {
|
||||
createSession,
|
||||
loadSession,
|
||||
getMostRecentSession,
|
||||
findSession,
|
||||
setWorkingDirectory,
|
||||
} from "@services/session";
|
||||
import { getConfig } from "@services/config";
|
||||
} from "@services/core/session";
|
||||
import { getConfig } from "@services/core/config";
|
||||
import type { Provider as ProviderName, ChatSession } from "@/types/index";
|
||||
import { getProvider, getProviderStatus } from "@providers/index.ts";
|
||||
import {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import chalk from "chalk";
|
||||
import { basename, extname } from "path";
|
||||
import { addMessage } from "@services/session";
|
||||
import { initializePermissions } from "@services/permissions";
|
||||
import { createAgent } from "@services/agent";
|
||||
import { infoMessage, errorMessage, warningMessage } from "@utils/terminal";
|
||||
import { addMessage } from "@services/core/session";
|
||||
import { initializePermissions } from "@services/core/permissions";
|
||||
import { createAgent } from "@services/core/agent";
|
||||
import { infoMessage, errorMessage, warningMessage } from "@utils/core/terminal";
|
||||
import { getThinkingMessage } from "@constants/status-messages";
|
||||
import {
|
||||
detectDebuggingRequest,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getConfig } from "@services/config";
|
||||
import { getConfig } from "@services/core/config";
|
||||
import { displayProvidersStatus } from "@providers/index.ts";
|
||||
|
||||
export const showProviders = async (): Promise<void> => {
|
||||
|
||||
@@ -3,8 +3,8 @@ import {
|
||||
warningMessage,
|
||||
successMessage,
|
||||
errorMessage,
|
||||
} from "@utils/terminal";
|
||||
import { getConfig } from "@services/config";
|
||||
} from "@utils/core/terminal";
|
||||
import { getConfig } from "@services/core/config";
|
||||
import { getProvider } from "@providers/index.ts";
|
||||
import { showModels } from "./show-models.ts";
|
||||
import type { ChatState } from "../state.ts";
|
||||
|
||||
@@ -4,8 +4,8 @@ import {
|
||||
warningMessage,
|
||||
infoMessage,
|
||||
successMessage,
|
||||
} from "@utils/terminal";
|
||||
import { getConfig } from "@services/config";
|
||||
} from "@utils/core/terminal";
|
||||
import { getConfig } from "@services/core/config";
|
||||
import {
|
||||
getProvider,
|
||||
getProviderStatus,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import chalk from "chalk";
|
||||
import { basename, extname } from "path";
|
||||
import { initializePermissions } from "@services/permissions";
|
||||
import { createAgent } from "@services/agent";
|
||||
import { initializePermissions } from "@services/core/permissions";
|
||||
import { createAgent } from "@services/core/agent";
|
||||
import type { ChatState } from "@commands/components/chat/state";
|
||||
import { processFileReferences } from "@commands/components/chat/context/process-file-references";
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import chalk from "chalk";
|
||||
import { getSessionSummaries } from "@services/session";
|
||||
import { infoMessage } from "@utils/terminal";
|
||||
import { getSessionSummaries } from "@services/core/session";
|
||||
import { infoMessage } from "@utils/core/terminal";
|
||||
|
||||
export const listSessions = async (): Promise<void> => {
|
||||
const summaries = await getSessionSummaries();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import chalk from "chalk";
|
||||
import { getCurrentSession } from "@services/session";
|
||||
import { warningMessage } from "@utils/terminal";
|
||||
import { getCurrentSession } from "@services/core/session";
|
||||
import { warningMessage } from "@utils/core/terminal";
|
||||
|
||||
export const showSessionInfo = async (): Promise<void> => {
|
||||
const session = getCurrentSession();
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
*/
|
||||
|
||||
import chalk from "chalk";
|
||||
import { usageStore } from "@stores/usage-store";
|
||||
import { getUserInfo } from "@providers/copilot/credentials";
|
||||
import { usageStore } from "@stores/core/usage-store";
|
||||
import { getUserInfo } from "@providers/copilot/auth/credentials";
|
||||
import { getCopilotUsage } from "@providers/copilot/usage";
|
||||
import { getProvider } from "@providers/index";
|
||||
import { renderUsageBar, renderUnlimitedBar } from "@utils/progress-bar";
|
||||
import { renderUsageBar, renderUnlimitedBar } from "@utils/menu/progress-bar";
|
||||
import type { ChatState } from "@commands/components/chat/state";
|
||||
import type { CopilotQuotaDetail } from "@/types/copilot-usage";
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
import os from "os";
|
||||
import { getConfig } from "@services/config";
|
||||
import { getConfig } from "@services/core/config";
|
||||
import { DASHBOARD_TITLE } from "@constants/dashboard";
|
||||
import type { DashboardConfig } from "@/types/dashboard";
|
||||
|
||||
|
||||
@@ -13,14 +13,14 @@ import {
|
||||
import type { ChatServiceState } from "@services/chat-tui-service";
|
||||
import type { ChatTUIOptions } from "@interfaces/ChatTUIOptions";
|
||||
import type { AgentConfig } from "@/types/agent-config";
|
||||
import { getConfig } from "@services/config";
|
||||
import { getConfig } from "@services/core/config";
|
||||
import { getThinkingMessage } from "@constants/status-messages";
|
||||
import {
|
||||
enterFullscreen,
|
||||
registerExitHandlers,
|
||||
exitFullscreen,
|
||||
clearScreen,
|
||||
} from "@utils/terminal";
|
||||
} from "@utils/core/terminal";
|
||||
import { createCallbacks } from "@commands/chat-tui";
|
||||
import { agentLoader } from "@services/agent-loader";
|
||||
import { projectSetupService } from "@services/project-setup-service";
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Command handlers - Route commands to appropriate implementations
|
||||
*/
|
||||
|
||||
import { errorMessage } from "@utils/terminal";
|
||||
import { errorMessage } from "@utils/core/terminal";
|
||||
import { COMMAND_REGISTRY, isValidCommand } from "@commands/handlers/registry";
|
||||
import type { CommandOptions } from "@/types/index";
|
||||
|
||||
6
src/commands/core/index.ts
Normal file
6
src/commands/core/index.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Commands Core - Main command handling
|
||||
*/
|
||||
|
||||
export * from "./runner";
|
||||
export * from "./handlers";
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
errorMessage,
|
||||
failSpinner,
|
||||
headerMessage,
|
||||
} from "@utils/terminal";
|
||||
} from "@utils/core/terminal";
|
||||
import {
|
||||
INTENT_KEYWORDS,
|
||||
CLASSIFICATION_CONFIDENCE,
|
||||
|
||||
@@ -9,8 +9,8 @@ import {
|
||||
hightLigthedJson,
|
||||
headerMessage,
|
||||
infoMessage,
|
||||
} from "@utils/terminal";
|
||||
import { getConfig } from "@services/config";
|
||||
} from "@utils/core/terminal";
|
||||
import { getConfig } from "@services/core/config";
|
||||
import {
|
||||
VALID_CONFIG_KEYS,
|
||||
VALID_PROVIDERS,
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
startSpinner,
|
||||
succeedSpinner,
|
||||
successMessage,
|
||||
} from "@utils/terminal";
|
||||
} from "@utils/core/terminal";
|
||||
import type { CommandOptions } from "@/types/index";
|
||||
|
||||
export const handlePlan = async (options: CommandOptions): Promise<void> => {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Run command handler
|
||||
*/
|
||||
|
||||
import { execute } from "@commands/runner";
|
||||
import { execute } from "@commands/core/runner";
|
||||
import type { CommandOptions } from "@/types/index";
|
||||
|
||||
export const handleRun = async (options: CommandOptions): Promise<void> => {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Serve command handler
|
||||
*/
|
||||
|
||||
import { boxMessage, warningMessage, infoMessage } from "@utils/terminal";
|
||||
import { boxMessage, warningMessage, infoMessage } from "@utils/core/terminal";
|
||||
import type { CommandOptions } from "@/types/index";
|
||||
import { SERVER_INFO } from "@constants/serve";
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ import {
|
||||
errorMessage,
|
||||
headerMessage,
|
||||
filePath,
|
||||
} from "@utils/terminal";
|
||||
import { getConfig } from "@services/config";
|
||||
} from "@utils/core/terminal";
|
||||
import { getConfig } from "@services/core/config";
|
||||
import type { CommandOptions } from "@/types/index";
|
||||
|
||||
export const handleValidate = async (
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
|
||||
import chalk from "chalk";
|
||||
import { errorMessage, infoMessage, successMessage } from "@utils/terminal";
|
||||
import { errorMessage, infoMessage, successMessage } from "@utils/core/terminal";
|
||||
import {
|
||||
initializeMCP,
|
||||
getMCPConfig,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
import chalk from "chalk";
|
||||
import { headerMessage, filePath } from "@utils/terminal";
|
||||
import { headerMessage, filePath } from "@utils/core/terminal";
|
||||
import type { RunnerOptions } from "@/types/runner";
|
||||
|
||||
export const displayHeader = (options: RunnerOptions): void => {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
import chalk from "chalk";
|
||||
import { filePath } from "@utils/terminal";
|
||||
import { filePath } from "@utils/core/terminal";
|
||||
import { STEP_ICONS, DEFAULT_STEP_ICON } from "@constants/runner";
|
||||
import type { ExecutionPlan, PlanStep } from "@/types/index";
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Plan execution utilities
|
||||
*/
|
||||
|
||||
import { failSpinner, succeedSpinner, startSpinner } from "@utils/terminal";
|
||||
import { failSpinner, succeedSpinner, startSpinner } from "@utils/core/terminal";
|
||||
import { RUNNER_DELAYS } from "@constants/runner";
|
||||
import { getStepIcon } from "@commands/runner/display-plan";
|
||||
import { delay } from "@commands/runner/utils";
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
infoMessage,
|
||||
errorMessage,
|
||||
warningMessage,
|
||||
} from "@utils/terminal";
|
||||
} from "@utils/core/terminal";
|
||||
import { RUNNER_DELAYS, RUNNER_MESSAGES } from "@constants/runner";
|
||||
import { displayHeader } from "@commands/runner/display-header";
|
||||
import { displayPlan } from "@commands/runner/display-plan";
|
||||
|
||||
Reference in New Issue
Block a user