From 703da767d589bec949514ede67feadc0efc18cc0 Mon Sep 17 00:00:00 2001 From: "R.J. (Steinert) Corwin" Date: Tue, 30 Sep 2025 08:49:27 -0400 Subject: [PATCH] refactor(cli): convert to typescript sources --- .gitignore | 1 + cli/PROGRESS.md | 16 +++++----- cli/bin/mew.js | 10 +++++- cli/package.json | 20 +++++++++--- .../008-f4x-safe-fifo-input-mechanism.md | 4 +-- .../accepted/009-aud-approval-dialog-ux.md | 2 +- ...ac-slash-command-parameter-architecture.md | 2 +- cli/src/commands/{agent.js => agent.ts} | 1 + cli/src/commands/{client.js => client.ts} | 1 + cli/src/commands/{gateway.js => gateway.ts} | 1 + cli/src/commands/{init.js => init.ts} | 1 + cli/src/commands/{space.js => space.ts} | 1 + cli/src/commands/{token.js => token.ts} | 1 + .../config/{keyBindings.js => keyBindings.ts} | 1 + cli/src/{index.js => index.ts} | 1 + .../{EnhancedInput.js => EnhancedInput.tsx} | 1 + .../{SimpleInput.js => SimpleInput.tsx} | 1 + .../hooks/{useKeypress.js => useKeypress.ts} | 1 + cli/src/ui/{keyMatchers.js => keyMatchers.ts} | 1 + .../{slashCommands.js => slashCommands.ts} | 1 + .../utils/{text-buffer.js => text-buffer.ts} | 1 + .../ui/utils/{textUtils.js => textUtils.ts} | 1 + ...ctive-ui.js => advanced-interactive-ui.ts} | 1 + cli/src/utils/{banner.js => banner.ts} | 1 + .../{interactive-ui.js => interactive-ui.ts} | 1 + .../{message-input.js => message-input.ts} | 1 + ...nt-resolver.js => participant-resolver.ts} | 1 + cli/tests/debug-enhanced-input.js | 2 +- cli/tests/enhanced-input-demo.js | 4 +-- cli/tests/enhanced-input-unit-test.js | 8 ++--- cli/tests/test-enhanced-input-integration.js | 2 +- cli/tests/test-input-standalone.js | 4 +-- cli/tests/text-buffer-demo.js | 2 +- cli/tests/text-buffer.test.js | 4 +-- cli/tests/verify-integration.js | 32 +++++++++---------- cli/tsconfig.json | 13 ++++++++ package-lock.json | 4 ++- tsconfig.json | 3 +- 38 files changed, 105 insertions(+), 48 deletions(-) rename cli/src/commands/{agent.js => agent.ts} (99%) rename cli/src/commands/{client.js => client.ts} (99%) rename cli/src/commands/{gateway.js => gateway.ts} (99%) rename cli/src/commands/{init.js => init.ts} (99%) rename cli/src/commands/{space.js => space.ts} (99%) rename cli/src/commands/{token.js => token.ts} (98%) rename cli/src/config/{keyBindings.js => keyBindings.ts} (99%) rename cli/src/{index.js => index.ts} (99%) rename cli/src/ui/components/{EnhancedInput.js => EnhancedInput.tsx} (99%) rename cli/src/ui/components/{SimpleInput.js => SimpleInput.tsx} (98%) rename cli/src/ui/hooks/{useKeypress.js => useKeypress.ts} (99%) rename cli/src/ui/{keyMatchers.js => keyMatchers.ts} (99%) rename cli/src/ui/utils/{slashCommands.js => slashCommands.ts} (99%) rename cli/src/ui/utils/{text-buffer.js => text-buffer.ts} (99%) rename cli/src/ui/utils/{textUtils.js => textUtils.ts} (99%) rename cli/src/utils/{advanced-interactive-ui.js => advanced-interactive-ui.ts} (99%) rename cli/src/utils/{banner.js => banner.ts} (99%) rename cli/src/utils/{interactive-ui.js => interactive-ui.ts} (99%) rename cli/src/utils/{message-input.js => message-input.ts} (99%) rename cli/src/utils/{participant-resolver.js => participant-resolver.ts} (99%) create mode 100644 cli/tsconfig.json diff --git a/.gitignore b/.gitignore index 9dcecf34..fa3bd27e 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ sdk/typescript-sdk/*/.tsbuildinfo sdk/typescript-sdk/*/dist/ bridge/.tsbuildinfo bridge/dist/ +cli/dist/ build-temp/ */build-temp/ diff --git a/cli/PROGRESS.md b/cli/PROGRESS.md index 80b4c7a0..0311b42a 100644 --- a/cli/PROGRESS.md +++ b/cli/PROGRESS.md @@ -36,14 +36,14 @@ Implemented Milestones 1 and 2 from ADRs 010 and 011 for enhanced terminal input **Objective:** Create the foundation for multi-line text editing with cursor management #### Files Created: -- `/cli/src/ui/utils/text-buffer.js` - Core text buffer implementation (381 lines) +- `/cli/src/ui/utils/text-buffer.ts` - Core text buffer implementation (381 lines) - Multi-line text management - Cursor position tracking - Word navigation logic - Text deletion operations (word, line-to-end, line-to-start) - Line wrapping for display -- `/cli/src/ui/utils/textUtils.js` - Unicode and text utilities (285 lines) +- `/cli/src/ui/utils/textUtils.ts` - Unicode and text utilities (285 lines) - Unicode character width calculation - Emoji detection and handling - CJK (Chinese, Japanese, Korean) wide character support @@ -59,33 +59,33 @@ Implemented Milestones 1 and 2 from ADRs 010 and 011 for enhanced terminal input **Objective:** Integrate enhanced input with keyboard shortcuts into MEW CLI #### Files Created: -- `/cli/src/ui/hooks/useKeypress.js` - Enhanced keyboard input hook (165 lines) +- `/cli/src/ui/hooks/useKeypress.ts` - Enhanced keyboard input hook (165 lines) - Cross-platform key detection - Modifier key support (Ctrl, Alt/Option, Shift) - Special key handling (arrows, home/end, function keys) -- `/cli/src/ui/keyMatchers.js` - Key pattern matching utilities (211 lines) +- `/cli/src/ui/keyMatchers.ts` - Key pattern matching utilities (211 lines) - Pattern matching for key combinations - Platform-specific helpers (Mac vs Linux/Windows) - Common key patterns library -- `/cli/src/config/keyBindings.js` - Configurable key bindings (235 lines) +- `/cli/src/config/keyBindings.ts` - Configurable key bindings (235 lines) - Default key bindings for all operations - Human-readable key combination display - Conflict detection - Customization support -- `/cli/src/ui/components/EnhancedInput.js` - Main input component (393 lines) +- `/cli/src/ui/components/EnhancedInput.tsx` - Main input component (393 lines) - Integration of TextBuffer - Keyboard shortcut handling - History navigation - Autocomplete infrastructure (ready for implementation) - Multi-line mode support -- `/cli/src/ui/components/SimpleInput.js` - Simplified input for debugging (32 lines) +- `/cli/src/ui/components/SimpleInput.tsx` - Simplified input for debugging (32 lines) #### Files Modified: -- `/cli/src/utils/advanced-interactive-ui.js` +- `/cli/src/utils/advanced-interactive-ui.ts` - Integrated EnhancedInput component - Removed old InputComposer - Added command history state management diff --git a/cli/bin/mew.js b/cli/bin/mew.js index c96e0ee1..1aae465f 100755 --- a/cli/bin/mew.js +++ b/cli/bin/mew.js @@ -10,5 +10,13 @@ * - mew token create - Create a test token */ -require('../src/index.js'); +try { + require('../dist/index.js'); +} catch (error) { + if (error && error.code === 'MODULE_NOT_FOUND') { + console.error('The MEW CLI has not been built yet. Please run "npm run build" inside the cli package.'); + process.exit(1); + } + throw error; +} diff --git a/cli/package.json b/cli/package.json index c889a311..09458a47 100644 --- a/cli/package.json +++ b/cli/package.json @@ -5,9 +5,19 @@ "bin": { "mew": "bin/mew.js" }, - "main": "src/index.js", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "exports": { + ".": { + "require": "./dist/index.js", + "types": "./dist/index.d.ts" + } + }, "scripts": { - "test": "node tests/run-tests.js", + "build": "tsc -b", + "clean": "rm -rf dist", + "typecheck": "tsc --noEmit", + "test": "npm run build && node tests/run-tests.js", "lint": "eslint .", "lint:fix": "eslint . --fix", "format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md}\" \"bin/**/*.js\"", @@ -39,7 +49,7 @@ "ws": "^8.18.0" }, "files": [ - "src", + "dist", "bin", "templates", "README.md" @@ -58,10 +68,12 @@ }, "devDependencies": { "@eslint/js": "^9.35.0", + "@types/node": "^20.14.0", "@typescript-eslint/eslint-plugin": "^8.43.0", "@typescript-eslint/parser": "^8.43.0", "eslint": "^9.35.0", "eslint-config-prettier": "^10.1.8", - "prettier": "^3.6.2" + "prettier": "^3.6.2", + "typescript": "^5.5.0" } } diff --git a/cli/spec/draft/decisions/accepted/008-f4x-safe-fifo-input-mechanism.md b/cli/spec/draft/decisions/accepted/008-f4x-safe-fifo-input-mechanism.md index d0560ce9..5c5f7a8b 100644 --- a/cli/spec/draft/decisions/accepted/008-f4x-safe-fifo-input-mechanism.md +++ b/cli/spec/draft/decisions/accepted/008-f4x-safe-fifo-input-mechanism.md @@ -261,7 +261,7 @@ echo '{"kind":"chat"}' > ./messages/001.json # File queue #### Phase 1: HTTP Endpoint (Immediate) ```javascript -// cli/src/utils/message-input.js +// cli/src/utils/message-input.ts const express = require('express'); function setupHttpInput(port, messageHandler) { @@ -306,7 +306,7 @@ function setupHttpInput(port, messageHandler) { #### Phase 2: Update CLI (Immediate) ```javascript -// cli/src/commands/client.js +// cli/src/commands/client.ts program .option('--http-port ', 'Enable HTTP input on port') .option('--http-bind
', 'Bind address (default: 127.0.0.1)') diff --git a/cli/spec/draft/decisions/accepted/009-aud-approval-dialog-ux.md b/cli/spec/draft/decisions/accepted/009-aud-approval-dialog-ux.md index 733f8606..7eb82d27 100644 --- a/cli/spec/draft/decisions/accepted/009-aud-approval-dialog-ux.md +++ b/cli/spec/draft/decisions/accepted/009-aud-approval-dialog-ux.md @@ -587,7 +587,7 @@ This phased approach delivers immediate value while building toward sophisticate ## References -- Current implementation: `/cli/src/utils/advanced-interactive-ui.js` +- Current implementation: `/cli/src/utils/advanced-interactive-ui.ts` - Related issue: TODO.md line "Better fulfill UX" - Similar patterns: VSCode extension approval, Docker Desktop permission dialogs - Terminal UI best practices: https://github.com/vadimdemedes/ink \ No newline at end of file diff --git a/cli/spec/draft/decisions/proposed/013-sac-slash-command-parameter-architecture.md b/cli/spec/draft/decisions/proposed/013-sac-slash-command-parameter-architecture.md index 2206be2b..164ff269 100644 --- a/cli/spec/draft/decisions/proposed/013-sac-slash-command-parameter-architecture.md +++ b/cli/spec/draft/decisions/proposed/013-sac-slash-command-parameter-architecture.md @@ -7,7 +7,7 @@ ## Context The advanced interactive CLI currently exposes slash commands through a static array that only supports fuzzy matching on the -full command string.【F:cli/src/ui/utils/slashCommands.js†L5-L88】【F:cli/src/ui/utils/slashCommands.js†L128-L164】 Once the user +full command string.【F:cli/src/ui/utils/slashCommands.ts†L5-L88】【F:cli/src/ui/utils/slashCommands.ts†L128-L164】 Once the user accepts a suggestion, the CLI inserts the command template verbatim and leaves the operator to fill in every argument manually. This approach breaks down for the new class of envelope-driven commands the CLI must support: diff --git a/cli/src/commands/agent.js b/cli/src/commands/agent.ts similarity index 99% rename from cli/src/commands/agent.js rename to cli/src/commands/agent.ts index e24f572e..d9e4373c 100644 --- a/cli/src/commands/agent.js +++ b/cli/src/commands/agent.ts @@ -1,3 +1,4 @@ +// @ts-nocheck const { Command } = require('commander'); const WebSocket = require('ws'); diff --git a/cli/src/commands/client.js b/cli/src/commands/client.ts similarity index 99% rename from cli/src/commands/client.js rename to cli/src/commands/client.ts index 3400fdf2..c17f294e 100644 --- a/cli/src/commands/client.js +++ b/cli/src/commands/client.ts @@ -1,3 +1,4 @@ +// @ts-nocheck const { Command } = require('commander'); const WebSocket = require('ws'); const fs = require('fs'); diff --git a/cli/src/commands/gateway.js b/cli/src/commands/gateway.ts similarity index 99% rename from cli/src/commands/gateway.js rename to cli/src/commands/gateway.ts index 4b187217..f080acba 100644 --- a/cli/src/commands/gateway.js +++ b/cli/src/commands/gateway.ts @@ -1,3 +1,4 @@ +// @ts-nocheck const { Command } = require('commander'); const WebSocket = require('ws'); const express = require('express'); diff --git a/cli/src/commands/init.js b/cli/src/commands/init.ts similarity index 99% rename from cli/src/commands/init.js rename to cli/src/commands/init.ts index 5daba68b..a803c460 100644 --- a/cli/src/commands/init.js +++ b/cli/src/commands/init.ts @@ -1,4 +1,5 @@ #!/usr/bin/env node +// @ts-nocheck const fs = require('fs').promises; const path = require('path'); diff --git a/cli/src/commands/space.js b/cli/src/commands/space.ts similarity index 99% rename from cli/src/commands/space.js rename to cli/src/commands/space.ts index 07320429..a5b92f73 100644 --- a/cli/src/commands/space.js +++ b/cli/src/commands/space.ts @@ -1,3 +1,4 @@ +// @ts-nocheck const { Command } = require('commander'); const fs = require('fs'); const path = require('path'); diff --git a/cli/src/commands/token.js b/cli/src/commands/token.ts similarity index 98% rename from cli/src/commands/token.js rename to cli/src/commands/token.ts index a889d86e..261dbb76 100644 --- a/cli/src/commands/token.js +++ b/cli/src/commands/token.ts @@ -1,3 +1,4 @@ +// @ts-nocheck const { Command } = require('commander'); const token = new Command('token').description('Token management'); diff --git a/cli/src/config/keyBindings.js b/cli/src/config/keyBindings.ts similarity index 99% rename from cli/src/config/keyBindings.js rename to cli/src/config/keyBindings.ts index ead58801..4ee9f15e 100644 --- a/cli/src/config/keyBindings.js +++ b/cli/src/config/keyBindings.ts @@ -1,3 +1,4 @@ +// @ts-nocheck /** * Key Bindings Configuration for MEW CLI * diff --git a/cli/src/index.js b/cli/src/index.ts similarity index 99% rename from cli/src/index.js rename to cli/src/index.ts index dc2ec517..3f3b7b4a 100644 --- a/cli/src/index.js +++ b/cli/src/index.ts @@ -1,4 +1,5 @@ #!/usr/bin/env node +// @ts-nocheck const { program } = require('commander'); const fs = require('fs'); diff --git a/cli/src/ui/components/EnhancedInput.js b/cli/src/ui/components/EnhancedInput.tsx similarity index 99% rename from cli/src/ui/components/EnhancedInput.js rename to cli/src/ui/components/EnhancedInput.tsx index 69b5f94f..fe5420de 100644 --- a/cli/src/ui/components/EnhancedInput.js +++ b/cli/src/ui/components/EnhancedInput.tsx @@ -1,3 +1,4 @@ +// @ts-nocheck /** * Enhanced Input Component for MEW CLI * diff --git a/cli/src/ui/components/SimpleInput.js b/cli/src/ui/components/SimpleInput.tsx similarity index 98% rename from cli/src/ui/components/SimpleInput.js rename to cli/src/ui/components/SimpleInput.tsx index 67c2e2a4..298b3260 100644 --- a/cli/src/ui/components/SimpleInput.js +++ b/cli/src/ui/components/SimpleInput.tsx @@ -1,3 +1,4 @@ +// @ts-nocheck /** * Simplified Input Component for debugging */ diff --git a/cli/src/ui/hooks/useKeypress.js b/cli/src/ui/hooks/useKeypress.ts similarity index 99% rename from cli/src/ui/hooks/useKeypress.js rename to cli/src/ui/hooks/useKeypress.ts index 31902cb3..05753553 100644 --- a/cli/src/ui/hooks/useKeypress.js +++ b/cli/src/ui/hooks/useKeypress.ts @@ -1,3 +1,4 @@ +// @ts-nocheck /** * useKeypress Hook * diff --git a/cli/src/ui/keyMatchers.js b/cli/src/ui/keyMatchers.ts similarity index 99% rename from cli/src/ui/keyMatchers.js rename to cli/src/ui/keyMatchers.ts index d3a115de..45e59ed4 100644 --- a/cli/src/ui/keyMatchers.js +++ b/cli/src/ui/keyMatchers.ts @@ -1,3 +1,4 @@ +// @ts-nocheck /** * Key Matchers for Terminal Input * diff --git a/cli/src/ui/utils/slashCommands.js b/cli/src/ui/utils/slashCommands.ts similarity index 99% rename from cli/src/ui/utils/slashCommands.js rename to cli/src/ui/utils/slashCommands.ts index 102792f7..05704416 100644 --- a/cli/src/ui/utils/slashCommands.js +++ b/cli/src/ui/utils/slashCommands.ts @@ -1,3 +1,4 @@ +// @ts-nocheck /** * Slash command schema and autocomplete engine for the MEW CLI. * diff --git a/cli/src/ui/utils/text-buffer.js b/cli/src/ui/utils/text-buffer.ts similarity index 99% rename from cli/src/ui/utils/text-buffer.js rename to cli/src/ui/utils/text-buffer.ts index 59e3c326..a0d0d5ef 100644 --- a/cli/src/ui/utils/text-buffer.js +++ b/cli/src/ui/utils/text-buffer.ts @@ -1,3 +1,4 @@ +// @ts-nocheck /** * Text Buffer Implementation for MEW CLI * diff --git a/cli/src/ui/utils/textUtils.js b/cli/src/ui/utils/textUtils.ts similarity index 99% rename from cli/src/ui/utils/textUtils.js rename to cli/src/ui/utils/textUtils.ts index e7c67c3a..7a5e937f 100644 --- a/cli/src/ui/utils/textUtils.js +++ b/cli/src/ui/utils/textUtils.ts @@ -1,3 +1,4 @@ +// @ts-nocheck /** * Text Utilities for Unicode and Terminal Handling * diff --git a/cli/src/utils/advanced-interactive-ui.js b/cli/src/utils/advanced-interactive-ui.ts similarity index 99% rename from cli/src/utils/advanced-interactive-ui.js rename to cli/src/utils/advanced-interactive-ui.ts index 4e694fe4..8a99daa0 100644 --- a/cli/src/utils/advanced-interactive-ui.js +++ b/cli/src/utils/advanced-interactive-ui.ts @@ -1,3 +1,4 @@ +// @ts-nocheck /** * Advanced Interactive UI using Ink * diff --git a/cli/src/utils/banner.js b/cli/src/utils/banner.ts similarity index 99% rename from cli/src/utils/banner.js rename to cli/src/utils/banner.ts index a509b9ac..723ab7f5 100644 --- a/cli/src/utils/banner.js +++ b/cli/src/utils/banner.ts @@ -1,3 +1,4 @@ +// @ts-nocheck /** * MEW Protocol Banner * diff --git a/cli/src/utils/interactive-ui.js b/cli/src/utils/interactive-ui.ts similarity index 99% rename from cli/src/utils/interactive-ui.js rename to cli/src/utils/interactive-ui.ts index ff386552..fa611b9c 100644 --- a/cli/src/utils/interactive-ui.js +++ b/cli/src/utils/interactive-ui.ts @@ -1,3 +1,4 @@ +// @ts-nocheck /** * Interactive Terminal UI * diff --git a/cli/src/utils/message-input.js b/cli/src/utils/message-input.ts similarity index 99% rename from cli/src/utils/message-input.js rename to cli/src/utils/message-input.ts index 68b4548f..8c9bc727 100644 --- a/cli/src/utils/message-input.js +++ b/cli/src/utils/message-input.ts @@ -1,3 +1,4 @@ +// @ts-nocheck /** * Message Input Utility * diff --git a/cli/src/utils/participant-resolver.js b/cli/src/utils/participant-resolver.ts similarity index 99% rename from cli/src/utils/participant-resolver.js rename to cli/src/utils/participant-resolver.ts index 963e990d..e686ff8e 100644 --- a/cli/src/utils/participant-resolver.js +++ b/cli/src/utils/participant-resolver.ts @@ -1,3 +1,4 @@ +// @ts-nocheck /** * Participant Resolution Logic * diff --git a/cli/tests/debug-enhanced-input.js b/cli/tests/debug-enhanced-input.js index 39ddde91..b20ac009 100644 --- a/cli/tests/debug-enhanced-input.js +++ b/cli/tests/debug-enhanced-input.js @@ -6,7 +6,7 @@ const React = require('react'); const { render, Box, Text } = require('ink'); -const EnhancedInput = require('../src/ui/components/EnhancedInput'); +const EnhancedInput = require('../dist/ui/components/EnhancedInput'); function DebugUI() { const [messages, setMessages] = React.useState([]); diff --git a/cli/tests/enhanced-input-demo.js b/cli/tests/enhanced-input-demo.js index 9c01ab84..4f1dc2ac 100644 --- a/cli/tests/enhanced-input-demo.js +++ b/cli/tests/enhanced-input-demo.js @@ -14,8 +14,8 @@ const React = require('react'); const { render, Box, Text } = require('ink'); -const EnhancedInput = require('../src/ui/components/EnhancedInput'); -const { getHelpText } = require('../src/config/keyBindings'); +const EnhancedInput = require('../dist/ui/components/EnhancedInput'); +const { getHelpText } = require('../dist/config/keyBindings'); /** * Demo Application Component diff --git a/cli/tests/enhanced-input-unit-test.js b/cli/tests/enhanced-input-unit-test.js index 9e4cbd9a..431a0f52 100644 --- a/cli/tests/enhanced-input-unit-test.js +++ b/cli/tests/enhanced-input-unit-test.js @@ -6,10 +6,10 @@ * Run with: node tests/enhanced-input-unit-test.js */ -const TextBuffer = require('../src/ui/utils/text-buffer'); -const { matchesKeyCombination } = require('../src/ui/hooks/useKeypress'); -const { matches, matchesAny, KeyPatterns } = require('../src/ui/keyMatchers'); -const { defaultKeyBindings, getBindingDisplay, validateBindings } = require('../src/config/keyBindings'); +const TextBuffer = require('../dist/ui/utils/text-buffer'); +const { matchesKeyCombination } = require('../dist/ui/hooks/useKeypress'); +const { matches, matchesAny, KeyPatterns } = require('../dist/ui/keyMatchers'); +const { defaultKeyBindings, getBindingDisplay, validateBindings } = require('../dist/config/keyBindings'); let testsPassed = 0; let testsFailed = 0; diff --git a/cli/tests/test-enhanced-input-integration.js b/cli/tests/test-enhanced-input-integration.js index a70e88f4..6ca9c71f 100644 --- a/cli/tests/test-enhanced-input-integration.js +++ b/cli/tests/test-enhanced-input-integration.js @@ -12,7 +12,7 @@ const React = require('react'); const { render, Box, Text } = require('ink'); -const EnhancedInput = require('../src/ui/components/EnhancedInput'); +const EnhancedInput = require('../dist/ui/components/EnhancedInput'); // Mock WebSocket for testing class MockWebSocket { diff --git a/cli/tests/test-input-standalone.js b/cli/tests/test-input-standalone.js index bf0b83f7..7b9acc1e 100644 --- a/cli/tests/test-input-standalone.js +++ b/cli/tests/test-input-standalone.js @@ -4,7 +4,7 @@ * Standalone test of input rendering */ -const TextBuffer = require('../src/ui/utils/text-buffer'); +const TextBuffer = require('../dist/ui/utils/text-buffer'); // Test the buffer directly console.log('=== TextBuffer Direct Test ==='); @@ -59,7 +59,7 @@ console.log('\n✅ TextBuffer is working correctly'); // Now test if the key bindings configuration loads console.log('\n=== Key Bindings Test ==='); -const { defaultKeyBindings } = require('../src/config/keyBindings'); +const { defaultKeyBindings } = require('../dist/config/keyBindings'); console.log('Key bindings loaded:', Object.keys(defaultKeyBindings).length, 'bindings'); console.log('Sample bindings:', Object.keys(defaultKeyBindings).slice(0, 5)); diff --git a/cli/tests/text-buffer-demo.js b/cli/tests/text-buffer-demo.js index 9e353714..21cabbe3 100644 --- a/cli/tests/text-buffer-demo.js +++ b/cli/tests/text-buffer-demo.js @@ -18,7 +18,7 @@ */ const readline = require('readline'); -const TextBuffer = require('../src/ui/utils/text-buffer'); +const TextBuffer = require('../dist/ui/utils/text-buffer'); // Create text buffer const buffer = new TextBuffer('Hello World!\nThis is a multi-line text buffer demo.\nTry editing this text.'); diff --git a/cli/tests/text-buffer.test.js b/cli/tests/text-buffer.test.js index b3a173eb..ae97fd5c 100644 --- a/cli/tests/text-buffer.test.js +++ b/cli/tests/text-buffer.test.js @@ -6,8 +6,8 @@ * Run with: node tests/text-buffer.test.js */ -const TextBuffer = require('../src/ui/utils/text-buffer'); -const textUtils = require('../src/ui/utils/textUtils'); +const TextBuffer = require('../dist/ui/utils/text-buffer'); +const textUtils = require('../dist/ui/utils/textUtils'); let testsPassed = 0; let testsFailed = 0; diff --git a/cli/tests/verify-integration.js b/cli/tests/verify-integration.js index 3a6afe96..3d28b556 100644 --- a/cli/tests/verify-integration.js +++ b/cli/tests/verify-integration.js @@ -49,57 +49,57 @@ console.log('=== Enhanced Input Integration Verification ===\n'); // Check all component files exist test('Text buffer exists', () => { assertFileExists( - path.join(__dirname, '../src/ui/utils/text-buffer.js'), + path.join(__dirname, '../dist/ui/utils/text-buffer.js'), 'text-buffer.js' ); }); test('Text utilities exist', () => { assertFileExists( - path.join(__dirname, '../src/ui/utils/textUtils.js'), + path.join(__dirname, '../dist/ui/utils/textUtils.js'), 'textUtils.js' ); }); test('useKeypress hook exists', () => { assertFileExists( - path.join(__dirname, '../src/ui/hooks/useKeypress.js'), + path.join(__dirname, '../dist/ui/hooks/useKeypress.js'), 'useKeypress.js' ); }); test('keyMatchers exists', () => { assertFileExists( - path.join(__dirname, '../src/ui/keyMatchers.js'), + path.join(__dirname, '../dist/ui/keyMatchers.js'), 'keyMatchers.js' ); }); test('keyBindings config exists', () => { assertFileExists( - path.join(__dirname, '../src/config/keyBindings.js'), + path.join(__dirname, '../dist/config/keyBindings.js'), 'keyBindings.js' ); }); test('EnhancedInput component exists', () => { assertFileExists( - path.join(__dirname, '../src/ui/components/EnhancedInput.js'), + path.join(__dirname, '../dist/ui/components/EnhancedInput.js'), 'EnhancedInput.js' ); }); // Check modules can be loaded test('TextBuffer can be imported', () => { - assertExports('../src/ui/utils/text-buffer'); + assertExports('../dist/ui/utils/text-buffer'); }); test('EnhancedInput can be imported', () => { - assertExports('../src/ui/components/EnhancedInput'); + assertExports('../dist/ui/components/EnhancedInput'); }); test('useKeypress exports functions', () => { - const module = require('../src/ui/hooks/useKeypress'); + const module = require('../dist/ui/hooks/useKeypress'); if (!module.useKeypress || !module.matchesKeyCombination) { throw new Error('Missing expected exports'); } @@ -108,7 +108,7 @@ test('useKeypress exports functions', () => { // Check integration with advanced-interactive-ui.js test('advanced-interactive-ui imports EnhancedInput', () => { assertFileContains( - path.join(__dirname, '../src/utils/advanced-interactive-ui.js'), + path.join(__dirname, '../dist/utils/advanced-interactive-ui.js'), "require('../ui/components/EnhancedInput')", 'EnhancedInput import' ); @@ -116,7 +116,7 @@ test('advanced-interactive-ui imports EnhancedInput', () => { test('advanced-interactive-ui uses EnhancedInput', () => { assertFileContains( - path.join(__dirname, '../src/utils/advanced-interactive-ui.js'), + path.join(__dirname, '../dist/utils/advanced-interactive-ui.js'), 'React.createElement(EnhancedInput', 'EnhancedInput usage' ); @@ -124,7 +124,7 @@ test('advanced-interactive-ui uses EnhancedInput', () => { test('Old InputComposer is removed', () => { const content = fs.readFileSync( - path.join(__dirname, '../src/utils/advanced-interactive-ui.js'), + path.join(__dirname, '../dist/utils/advanced-interactive-ui.js'), 'utf8' ); // Check that the old function definition is gone @@ -135,7 +135,7 @@ test('Old InputComposer is removed', () => { test('EnhancedInput has approval dialog compatibility', () => { assertFileContains( - path.join(__dirname, '../src/utils/advanced-interactive-ui.js'), + path.join(__dirname, '../dist/utils/advanced-interactive-ui.js'), 'disabled: pendingOperation !== null', 'Dialog compatibility' ); @@ -143,7 +143,7 @@ test('EnhancedInput has approval dialog compatibility', () => { // Test component functionality test('TextBuffer supports multi-line', () => { - const TextBuffer = require('../src/ui/utils/text-buffer'); + const TextBuffer = require('../dist/ui/utils/text-buffer'); const buffer = new TextBuffer('Line1\nLine2'); if (buffer.lines.length !== 2) { throw new Error('Multi-line not working'); @@ -151,7 +151,7 @@ test('TextBuffer supports multi-line', () => { }); test('TextBuffer supports word navigation', () => { - const TextBuffer = require('../src/ui/utils/text-buffer'); + const TextBuffer = require('../dist/ui/utils/text-buffer'); const buffer = new TextBuffer('Hello World'); buffer.cursorColumn = 0; buffer.move('wordRight'); @@ -161,7 +161,7 @@ test('TextBuffer supports word navigation', () => { }); test('Key bindings include all shortcuts', () => { - const { defaultKeyBindings } = require('../src/config/keyBindings'); + const { defaultKeyBindings } = require('../dist/config/keyBindings'); const required = [ 'MOVE_WORD_LEFT', 'MOVE_WORD_RIGHT', diff --git a/cli/tsconfig.json b/cli/tsconfig.json new file mode 100644 index 00000000..2b95f2fe --- /dev/null +++ b/cli/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "outDir": "dist", + "rootDir": "src", + "composite": true, + "module": "CommonJS", + "moduleResolution": "Node", + "tsBuildInfoFile": "dist/.tsbuildinfo" + }, + "include": ["src/**/*"], + "exclude": ["dist", "tests", "templates"] +} diff --git a/package-lock.json b/package-lock.json index ab585972..225c38bd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -92,11 +92,13 @@ }, "devDependencies": { "@eslint/js": "^9.35.0", + "@types/node": "^20.14.0", "@typescript-eslint/eslint-plugin": "^8.43.0", "@typescript-eslint/parser": "^8.43.0", "eslint": "^9.35.0", "eslint-config-prettier": "^10.1.8", - "prettier": "^3.6.2" + "prettier": "^3.6.2", + "typescript": "^5.5.0" }, "engines": { "node": ">=16.0.0" diff --git a/tsconfig.json b/tsconfig.json index 832c1c80..4720b815 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,6 +6,7 @@ { "path": "./sdk/typescript-sdk/client" }, { "path": "./sdk/typescript-sdk/participant" }, { "path": "./sdk/typescript-sdk/agent" }, - { "path": "./bridge" } + { "path": "./bridge" }, + { "path": "./cli" } ] }