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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ sdk/typescript-sdk/*/.tsbuildinfo
sdk/typescript-sdk/*/dist/
bridge/.tsbuildinfo
bridge/dist/
cli/dist/
build-temp/
*/build-temp/

Expand Down
16 changes: 8 additions & 8 deletions cli/PROGRESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 9 additions & 1 deletion cli/bin/mew.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

20 changes: 16 additions & 4 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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\"",
Expand Down Expand Up @@ -39,7 +49,7 @@
"ws": "^8.18.0"
},
"files": [
"src",
"dist",
"bin",
"templates",
"README.md"
Expand All @@ -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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 <port>', 'Enable HTTP input on port')
.option('--http-bind <address>', 'Bind address (default: 127.0.0.1)')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
1 change: 1 addition & 0 deletions cli/src/commands/agent.js → cli/src/commands/agent.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
const { Command } = require('commander');
const WebSocket = require('ws');

Expand Down
1 change: 1 addition & 0 deletions cli/src/commands/client.js → cli/src/commands/client.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
const { Command } = require('commander');
const WebSocket = require('ws');
const fs = require('fs');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
const { Command } = require('commander');
const WebSocket = require('ws');
const express = require('express');
Expand Down
1 change: 1 addition & 0 deletions cli/src/commands/init.js → cli/src/commands/init.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env node
// @ts-nocheck

const fs = require('fs').promises;
const path = require('path');
Expand Down
1 change: 1 addition & 0 deletions cli/src/commands/space.js → cli/src/commands/space.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
const { Command } = require('commander');
const fs = require('fs');
const path = require('path');
Expand Down
1 change: 1 addition & 0 deletions cli/src/commands/token.js → cli/src/commands/token.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
const { Command } = require('commander');

const token = new Command('token').description('Token management');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Key Bindings Configuration for MEW CLI
*
Expand Down
1 change: 1 addition & 0 deletions cli/src/index.js → cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env node
// @ts-nocheck

const { program } = require('commander');
const fs = require('fs');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Enhanced Input Component for MEW CLI
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Simplified Input Component for debugging
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* useKeypress Hook
*
Expand Down
1 change: 1 addition & 0 deletions cli/src/ui/keyMatchers.js → cli/src/ui/keyMatchers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Key Matchers for Terminal Input
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Slash command schema and autocomplete engine for the MEW CLI.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Text Buffer Implementation for MEW CLI
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Text Utilities for Unicode and Terminal Handling
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Advanced Interactive UI using Ink
*
Expand Down
1 change: 1 addition & 0 deletions cli/src/utils/banner.js → cli/src/utils/banner.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* MEW Protocol Banner
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Interactive Terminal UI
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Message Input Utility
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Participant Resolution Logic
*
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/debug-enhanced-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -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([]);
Expand Down
4 changes: 2 additions & 2 deletions cli/tests/enhanced-input-demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions cli/tests/enhanced-input-unit-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/test-enhanced-input-integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions cli/tests/test-input-standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ===');
Expand Down Expand Up @@ -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));

Expand Down
2 changes: 1 addition & 1 deletion cli/tests/text-buffer-demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down
4 changes: 2 additions & 2 deletions cli/tests/text-buffer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading