mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 03:00:44 +00:00
- Set up npm workspaces for three packages: pi-tui, pi-agent, and pi (pods) - Implemented dual TypeScript configuration: - Root tsconfig.json with path mappings for development and type checking - Package-specific tsconfig.build.json for clean production builds - Configured lockstep versioning with sync script for inter-package dependencies - Added comprehensive documentation for development and publishing workflows - All packages at version 0.5.0 ready for npm publishing
98 lines
2 KiB
JavaScript
98 lines
2 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import {
|
|
CombinedAutocompleteProvider,
|
|
Container,
|
|
MarkdownComponent,
|
|
TextComponent,
|
|
TextEditor,
|
|
TUI,
|
|
} from "../src/index.js";
|
|
|
|
// Create TUI manager
|
|
const ui = new TUI();
|
|
ui.configureLogging({
|
|
enabled: true,
|
|
logLevel: "debug",
|
|
logFile: "tui-debug.log",
|
|
});
|
|
|
|
// Create a chat container that will hold messages
|
|
const chatContainer = new Container();
|
|
const editor = new TextEditor();
|
|
|
|
// Set up autocomplete with slash commands
|
|
const autocompleteProvider = new CombinedAutocompleteProvider(
|
|
[
|
|
{ name: "clear", description: "Clear chat history" },
|
|
{ name: "clear-last", description: "Clear last message" },
|
|
{ name: "exit", description: "Exit the application" },
|
|
],
|
|
process.cwd(),
|
|
);
|
|
editor.setAutocompleteProvider(autocompleteProvider);
|
|
|
|
// Add components to UI
|
|
ui.addChild(new TextComponent("Differential Rendering TUI"));
|
|
ui.addChild(chatContainer);
|
|
ui.addChild(editor);
|
|
|
|
// Set focus to the editor (index 2)
|
|
ui.setFocus(editor);
|
|
|
|
// Test with Claude's multiline text
|
|
const testText = `Root level:
|
|
- CLAUDE.md
|
|
- README.md
|
|
- biome.json
|
|
- package.json
|
|
- package-lock.json
|
|
- tsconfig.json
|
|
- tui-debug.log
|
|
|
|
Directories:
|
|
- \`data/\` (JSON test files)
|
|
- \`dist/\`
|
|
- \`docs/\` (markdown documentation)
|
|
- \`node_modules/\`
|
|
- \`src/\` (TypeScript source files)`;
|
|
|
|
// Pre-fill the editor with the test text
|
|
editor.setText(testText);
|
|
|
|
// Handle editor submissions
|
|
editor.onSubmit = (text: string) => {
|
|
text = text.trim();
|
|
|
|
if (text === "/clear") {
|
|
chatContainer.clear();
|
|
ui.requestRender();
|
|
return;
|
|
}
|
|
|
|
if (text === "/clear-last") {
|
|
const count = chatContainer.getChildCount();
|
|
if (count > 0) {
|
|
chatContainer.removeChildAt(count - 1);
|
|
ui.requestRender();
|
|
}
|
|
return;
|
|
}
|
|
|
|
if (text === "/exit") {
|
|
ui.stop();
|
|
return;
|
|
}
|
|
|
|
if (text) {
|
|
// Create new message component and add to chat container
|
|
const message = new MarkdownComponent(text);
|
|
chatContainer.addChild(message);
|
|
|
|
// Manually trigger re-render
|
|
ui.requestRender();
|
|
}
|
|
};
|
|
|
|
// Start the UI
|
|
ui.start();
|