diff --git a/README.md b/README.md index 9b8c3a3..22b33c3 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,28 @@ -# termos +# Termos -terminal emulation library that bases its functionality on the bash shell \ No newline at end of file +Brief description of what this project does. + +## Prerequisites + +- [Node.js](https://nodejs.org/) installed (version 26.2.0 or higher) + +## Installation + +```bash +wget https://git.gornodox.dev/ChaosMaker/termos/archive/unstable-async.zip +unzip -d termos unstable-async.zip +cd termos +npm install +``` + +## Running the project + +```bash +npm run dev +``` + +## Running the test suite + +```bash +npm run test +``` diff --git a/package.json b/package.json index ececac2..2235c49 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,11 @@ { "name": "termos", - "version": "1.0.0", - "description": "terminal emulation library that bases its functionality on the bash shell", + "version": "0.0.1", + "description": "Emulation library for a unix-like operating-system written in pure typescript", "main": "index.ts", "scripts": { - "test": "eslint . && vitest" + "test": "eslint . && vitest", + "dev": "npx tsx src/index.ts" }, "repository": { "type": "git", diff --git a/todo.md b/todo.md deleted file mode 100644 index 65b3b6c..0000000 --- a/todo.md +++ /dev/null @@ -1,140 +0,0 @@ -# Termos Library — Remaining Work - -## Phase 6: Async Process & Event System - -- [x] `Process` class: lifecycle, output accumulation, signal queue, SIGKILL, result event -- [x] `ProcessManager`: create process, PID generation, event forwarding, cleanup -- [x] `Shell` integration: execute, sendInput, event emitter, BoundPID -- [ ] **Fix `async` demo command** — currently blocking; must `await 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 `echo` and `cd` fully to new CommandFn** -- [ ] **Update all existing command tests** to async signature -- [ ] **Remove/replace `serializer.ts` stubs** -- [ ] **Run full TS + lint + tests clean** - -## Phase 7: Frontend Adapters & REPL - -- [ ] **Browser frontend adapter** - - [ ] Define `FrontendAdapter` interface (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 -- [ ] **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 -- [ ] **Tests for both adapters** (mocked DOM / fake stdin) - -## Phase 8: Core Built-in Commands - -- [ ] `pwd` — print current working directory -- [ ] `ls` — list directory contents -- [ ] `cat` — concatenate files -- [ ] `echo` — already exists; add `-n`, escapes later -- [ ] `export` — set environment variables -- [ ] `history` — view/manipulate history -- [ ] `clear` — clear screen (emit special event to UI) -- [ ] `touch` — create empty file -- [ ] `mkdir` — create directory -- [ ] `rm` — remove file/directory -- [ ] `mv` — move/rename -- [ ] `cp` — copy file/directory -- [ ] `chmod` — change permissions -- [ ] `chown` — change owner/group -- [ ] `less` — 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 - - [ ] `>>` append - - [ ] `2>` redirect stderr -- [ ] Update `CommandIO` with 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 -- [ ] `jobs` built-in -- [ ] `fg` / `bg` built-ins -- [ ] Shell updates `BoundPID` accordingly -- [ ] Tests for job control - -## Phase 11: Session & User Management - -- [ ] Expand `SessionManager` with `su`, `login`, `logout` -- [ ] Password hashing -- [ ] User database serialization/deserialization -- [ ] Root permission enforcement in commands -- [ ] `whoami`, `id`, `su`, `passwd` built-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.ts` correctly (Zod schemas) -- [ ] Define stable JSON schema for filesystem tree -- [ ] `serializeFileSystem` implementation -- [ ] `deserializeFileSystem` implementation -- [ ] 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) \ No newline at end of file