5.2 KiB
5.2 KiB
Termos Library — Remaining Work
Phase 6: Async Process & Event System
Processclass: lifecycle, output accumulation, signal queue, SIGKILL, result eventProcessManager: create process, PID generation, event forwarding, cleanupShellintegration: execute, sendInput, event emitter, BoundPID- Fix
asyncdemo command — currently blocking; mustawait io.getSignal() - Write integration tests for:
- Simple command via ProcessManager (events emitted, map cleaned)
- Long-running command waits for signal and exits
- SIGKILL terminates pending process (exit code 137)
- Shell.sendInput routes input to foreground process
- Global keybind overrides process keybind
- Chunked stdout/stderr (large writes split ≤1024 bytes)
- Refactor
echoandcdfully to new CommandFn - Update all existing command tests to async signature
- Remove/replace
serializer.tsstubs - Run full TS + lint + tests clean
Phase 7: Frontend Adapters & REPL
- Browser frontend adapter
- Define
FrontendAdapterinterface (sendInput, onEvent) - Implement DOM terminal renderer (xterm.js or custom)
- Map DOM KeyboardEvents → normalized Input strings
- Subscribe to Shell events (stdout, stderr, result, process)
- Display prompt, cwd, exit code
- Handle keybind routing from UI
- Define
- Node.js frontend adapter
- Raw mode input reading (
process.stdin) - Map ANSI escape sequences → Input strings
- Simple line editor / prompt
- Render stdout/stderr to terminal
- Ctrl+C handling
- Raw mode input reading (
- Tests for both adapters (mocked DOM / fake stdin)
Phase 8: Core Built-in Commands
pwd— print current working directoryls— list directory contentscat— concatenate filesecho— already exists; add-n, escapes laterexport— set environment variableshistory— view/manipulate historyclear— clear screen (emit special event to UI)touch— create empty filemkdir— create directoryrm— remove file/directorymv— move/renamecp— copy file/directorychmod— change permissionschown— change owner/groupless— continuous process with keybinds (paged output)grep— pattern matching (flags, exit codes)- Each command: descriptor + tests + keybinds
Phase 9: Pipelines & Redirection
- Extend parser to recognize
|,>,<,>>,2> - Define pipeline execution model
- Each command in pipeline runs as process
- stdout of one feeds stdin of next
- stderr separate
- Implement redirection
>write to file<read from file>>append2>redirect stderr
- Update
CommandIOwith stdin stream if needed - ProcessManager supports multiple simultaneous processes in pipeline
- Tests for pipelines and redirections
Phase 10: Job Control & Background Processes
- Add
&operator to parser - Jobs table in ShellState or separate
jobsbuilt-infg/bgbuilt-ins- Shell updates
BoundPIDaccordingly - Tests for job control
Phase 11: Session & User Management
- Expand
SessionManagerwithsu,login,logout - Password hashing
- User database serialization/deserialization
- Root permission enforcement in commands
whoami,id,su,passwdbuilt-ins- Tests for session stack and permission boundaries
Phase 12: Shell Scripting & Control Flow
- Parser support for
;,&&,||,if,while,for - Script execution mode (batch)
- Environment variable expansion (
$VAR) - Command substitution (
$(...)) - Exit code propagation in control flow
- Aliases
- Tests for scripting features
Phase 13: Persistence & Serialization
- Finish
serializer.tscorrectly (Zod schemas) - Define stable JSON schema for filesystem tree
serializeFileSystemimplementationdeserializeFileSystemimplementation- Integration with browser storage adapter (IndexedDB)
- Node storage adapter (JSON file)
- Load/save overlay and inode counter
- Tests for round-trip serialization, corruption handling
Phase 14: Configuration & Library API
- Global config object
- max chunk size
- history capacity
- keybind map
- Factory functions for
Shell,FileSystem,Session - Public API barrel (
index.ts) - Documentation (JSDoc, README)
- Error type exports
- Versioning / packaging
Phase 15: Performance & Hardening
- Profile large file operations
- Optimize
resolvePath/traverseTree - Reduce unnecessary object allocations
- Add property-based tests for filesystem operations
- Fuzz parser for malformed input
- Security review (path traversal, permission bypass, signal handling)
Phase 16: Frontend polish (if browser-first)
- Terminal UI component with prompt, history navigation
- Keyboard shortcuts
- Scrollback buffer
- Colorized output (ANSI escape sequences)
- Multi-tab sessions (optional)