From faef281dfa256d7ef649a337888621480ad85d95 Mon Sep 17 00:00:00 2001 From: Anurag Yadav Date: Tue, 24 Feb 2026 20:16:26 +0530 Subject: [PATCH 1/4] feat(cli): add /init command and DEXTO_LOG_LEVEL env var support --- packages/cli/src/index-main.ts | 9 ++++++- .../tui/src/interactive-commands/commands.ts | 1 + .../interactive-commands/general-commands.ts | 25 +++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/index-main.ts b/packages/cli/src/index-main.ts index 1d836284a..f9650420b 100644 --- a/packages/cli/src/index-main.ts +++ b/packages/cli/src/index-main.ts @@ -837,12 +837,19 @@ program // Enrichment adds filesystem paths to storage (schema has in-memory defaults) // Interactive CLI mode: only log to file (console would interfere with chat UI) const isInteractiveCli = opts.mode === 'cli'; + const logLevelEnv = process.env.DEXTO_LOG_LEVEL?.toLowerCase(); + const validLevels = ['debug', 'info', 'warn', 'error'] as const; + const logLevel = validLevels.includes( + logLevelEnv as (typeof validLevels)[number] + ) + ? (logLevelEnv as (typeof validLevels)[number]) + : 'info'; const enrichedConfig = enrichAgentConfig( configWithImageDefaults, resolvedPath, { isInteractiveCli, - logLevel: 'info', // CLI uses info-level logging for visibility + logLevel, // CLI uses info-level logging for visibility } ); diff --git a/packages/tui/src/interactive-commands/commands.ts b/packages/tui/src/interactive-commands/commands.ts index db9ded117..6a5e6ea2c 100644 --- a/packages/tui/src/interactive-commands/commands.ts +++ b/packages/tui/src/interactive-commands/commands.ts @@ -123,6 +123,7 @@ export async function executeCommand( try { // Execute the handler with context const result = await cmd.handler(args, agent, ctx); + agent.logger.info(`[executeCommand] /${command} returned: ${JSON.stringify(result)}`); // If handler returns a string, it's formatted output for ink-cli // If it returns boolean, it's the old behavior (handled or not) return result; diff --git a/packages/tui/src/interactive-commands/general-commands.ts b/packages/tui/src/interactive-commands/general-commands.ts index 78a76d0ba..49e6a01a7 100644 --- a/packages/tui/src/interactive-commands/general-commands.ts +++ b/packages/tui/src/interactive-commands/general-commands.ts @@ -20,6 +20,7 @@ import type { HelpStyledData, ShortcutsStyledData } from '../state/types.js'; import { writeToClipboard } from '../utils/clipboardUtils.js'; import { setExitStats } from './exit-stats.js'; import { triggerExit } from './exit-handler.js'; +import { createSendMessageMarker } from '../../ink-cli/services/index.js'; /** * Get the shell rc file path for the given shell @@ -153,6 +154,30 @@ export function createHelpCommand(getAllCommands: () => CommandDefinition[]): Co * Note: The help command is created separately to avoid circular dependencies */ export const generalCommands: CommandDefinition[] = [ + { + name: 'init', + description: 'Analyze this codebase and create an AGENTS.md file', + usage: '/init', + category: 'General', + handler: async ( + _args: string[], + _agent: DextoAgent, + _ctx: CommandContext + ): Promise => { + const cwd = process.cwd(); + const prompt = `Please analyze this codebase and create an AGENTS.md file at ${cwd}/AGENTS.md containing: +1. Build/lint/test commands - especially for running a single test +2. Code style guidelines including imports, formatting, types, naming conventions, error handling, etc. + +The file you create will be given to agentic coding agents (such as yourself) that operate in this repository. Make it about 150 lines long. + +If there are Cursor rules (in .cursor/rules/ or .cursorrules) or Copilot rules (in .github/copilot-instructions.md), make sure to include them. + +If there is already an AGENTS.md at ${cwd}/AGENTS.md, improve it instead of creating it from scratch.`; + + return createSendMessageMarker(prompt); + }, + }, { name: 'shell', description: 'Execute shell command directly (use !command as shortcut)', From 21090e475a394aa9b828ff7c2f3f6e05493b85e0 Mon Sep 17 00:00:00 2001 From: Anurag Yadav Date: Fri, 6 Mar 2026 15:53:23 +0530 Subject: [PATCH 2/4] refactor(tui): streamline message handling in OverlayContainer and adjust command imports - Removed redundant user message display for executed commands in OverlayContainer. - Added handling for non-streaming commands to show user messages. - Updated command import path in general-commands for consistency. - Removed logging of command execution results in executeCommand function. --- .../tui/src/containers/OverlayContainer.tsx | 20 ++++++++++++++----- .../tui/src/interactive-commands/commands.ts | 1 - .../interactive-commands/general-commands.ts | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/packages/tui/src/containers/OverlayContainer.tsx b/packages/tui/src/containers/OverlayContainer.tsx index e5eaae62e..1ea1acf35 100644 --- a/packages/tui/src/containers/OverlayContainer.tsx +++ b/packages/tui/src/containers/OverlayContainer.tsx @@ -1239,10 +1239,6 @@ export const OverlayContainer = forwardRef ({ ...prev, historyIndex: -1 })); - // Show user message for the executed command - const userMessage = createUserMessage(commandText); - setMessages((prev) => [...prev, userMessage]); - setUi((prev) => ({ ...prev, isProcessing: true, isCancelling: false })); const { CommandService } = await import('../services/CommandService.js'); @@ -1256,6 +1252,20 @@ export const OverlayContainer = forwardRef ({ ...prev, isProcessing: false })); + if (onSubmitPromptCommand) { + await onSubmitPromptCommand(commandText); + } + return; + } + + // Show user message for non-streaming commands + const userMessage = createUserMessage(commandText); + setMessages((prev) => [...prev, userMessage]); + if (result.type === 'output' && result.output) { const output = result.output; setMessages((prev) => [ @@ -1308,7 +1318,7 @@ export const OverlayContainer = forwardRef Date: Fri, 6 Mar 2026 16:08:24 +0530 Subject: [PATCH 3/4] chore(cli): remove redundant DEXTO_LOG_LEVEL handling and add changeset - Remove env var parsing from index-main.ts (factory.ts already handles DEXTO_LOG_LEVEL internally) - Add changeset for /init command --- .changeset/sharp-trams-smash.md | 5 +++++ packages/cli/src/index-main.ts | 9 +-------- 2 files changed, 6 insertions(+), 8 deletions(-) create mode 100644 .changeset/sharp-trams-smash.md diff --git a/.changeset/sharp-trams-smash.md b/.changeset/sharp-trams-smash.md new file mode 100644 index 000000000..6e9357a80 --- /dev/null +++ b/.changeset/sharp-trams-smash.md @@ -0,0 +1,5 @@ +--- +'@dexto/tui': patch +--- + +Add `/init` interactive command that analyzes the codebase and generates an `AGENTS.md` file with build/lint/test commands and code style guidelines. diff --git a/packages/cli/src/index-main.ts b/packages/cli/src/index-main.ts index f9650420b..a0e4227db 100644 --- a/packages/cli/src/index-main.ts +++ b/packages/cli/src/index-main.ts @@ -837,19 +837,12 @@ program // Enrichment adds filesystem paths to storage (schema has in-memory defaults) // Interactive CLI mode: only log to file (console would interfere with chat UI) const isInteractiveCli = opts.mode === 'cli'; - const logLevelEnv = process.env.DEXTO_LOG_LEVEL?.toLowerCase(); - const validLevels = ['debug', 'info', 'warn', 'error'] as const; - const logLevel = validLevels.includes( - logLevelEnv as (typeof validLevels)[number] - ) - ? (logLevelEnv as (typeof validLevels)[number]) - : 'info'; const enrichedConfig = enrichAgentConfig( configWithImageDefaults, resolvedPath, { isInteractiveCli, - logLevel, // CLI uses info-level logging for visibility + logLevel: 'info', } ); From 6b4637d2b0f385314f77bc4a581aba8394a3b2fd Mon Sep 17 00:00:00 2001 From: Anurag Yadav Date: Fri, 6 Mar 2026 16:35:00 +0530 Subject: [PATCH 4/4] chore(cli): restore info-level logging comment --- packages/cli/src/index-main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/index-main.ts b/packages/cli/src/index-main.ts index a0e4227db..1d836284a 100644 --- a/packages/cli/src/index-main.ts +++ b/packages/cli/src/index-main.ts @@ -842,7 +842,7 @@ program resolvedPath, { isInteractiveCli, - logLevel: 'info', + logLevel: 'info', // CLI uses info-level logging for visibility } );