Skip to content
Open
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
5 changes: 5 additions & 0 deletions .changeset/sharp-trams-smash.md
Original file line number Diff line number Diff line change
@@ -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.
20 changes: 15 additions & 5 deletions packages/tui/src/containers/OverlayContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1239,10 +1239,6 @@ export const OverlayContainer = forwardRef<OverlayContainerHandle, OverlayContai
buffer.setText('');
setInput((prev) => ({ ...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');
Expand All @@ -1256,6 +1252,20 @@ export const OverlayContainer = forwardRef<OverlayContainerHandle, OverlayContai
session.id || undefined
);

// sendMessage: route through InputContainer's full streaming pipeline
// (avoids duplicating processStream logic and deps here)
if (result.type === 'sendMessage' && result.messageToSend) {
setUi((prev) => ({ ...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) => [
Expand Down Expand Up @@ -1308,7 +1318,7 @@ export const OverlayContainer = forwardRef<OverlayContainerHandle, OverlayContai
}));
}
},
[setInput, setUi, setMessages, agent, session.id, buffer]
[setInput, setUi, setMessages, agent, session.id, buffer, onSubmitPromptCommand]
);

const handleLoadIntoInput = useCallback(
Expand Down
25 changes: 25 additions & 0 deletions packages/tui/src/interactive-commands/general-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 '../services/index.js';

/**
* Get the shell rc file path for the given shell
Expand Down Expand Up @@ -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<CommandHandlerResult> => {
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)',
Expand Down