diff --git a/.obsidian/app.json b/.obsidian/app.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/.obsidian/app.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/.obsidian/appearance.json b/.obsidian/appearance.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/.obsidian/appearance.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/.obsidian/core-plugins.json b/.obsidian/core-plugins.json new file mode 100644 index 0000000..639b90d --- /dev/null +++ b/.obsidian/core-plugins.json @@ -0,0 +1,33 @@ +{ + "file-explorer": true, + "global-search": true, + "switcher": true, + "graph": true, + "backlink": true, + "canvas": true, + "outgoing-link": true, + "tag-pane": true, + "footnotes": false, + "properties": true, + "page-preview": true, + "daily-notes": true, + "templates": true, + "note-composer": true, + "command-palette": true, + "slash-command": false, + "editor-status": true, + "bookmarks": true, + "markdown-importer": false, + "zk-prefixer": false, + "random-note": false, + "outline": true, + "word-count": true, + "slides": false, + "audio-recorder": false, + "workspaces": false, + "file-recovery": true, + "publish": false, + "sync": true, + "bases": true, + "webviewer": false +} \ No newline at end of file diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json new file mode 100644 index 0000000..658cf9a --- /dev/null +++ b/.obsidian/workspace.json @@ -0,0 +1,193 @@ +{ + "main": { + "id": "89ee32072433406f", + "type": "split", + "children": [ + { + "id": "21d78959e637e988", + "type": "tabs", + "children": [ + { + "id": "1db1d6b317bc05ae", + "type": "leaf", + "state": { + "type": "markdown", + "state": { + "file": "todo.md", + "mode": "source", + "source": false + }, + "icon": "lucide-file", + "title": "todo" + } + } + ] + } + ], + "direction": "vertical" + }, + "left": { + "id": "6703a701fa3161c8", + "type": "split", + "children": [ + { + "id": "59a1957ef4b6aa34", + "type": "tabs", + "children": [ + { + "id": "af4cfba92021d1c8", + "type": "leaf", + "state": { + "type": "file-explorer", + "state": { + "sortOrder": "alphabetical", + "autoReveal": false, + "showSearch": false, + "searchQuery": "" + }, + "icon": "lucide-folder-closed", + "title": "Files" + } + }, + { + "id": "195ed2a7004c5679", + "type": "leaf", + "state": { + "type": "search", + "state": { + "query": "", + "matchingCase": false, + "explainSearch": false, + "collapseAll": false, + "extraContext": false, + "sortOrder": "alphabetical" + }, + "icon": "lucide-search", + "title": "Search" + } + }, + { + "id": "e0b0a93bee04adf7", + "type": "leaf", + "state": { + "type": "bookmarks", + "state": { + "showSearch": false, + "searchQuery": "" + }, + "icon": "lucide-bookmark", + "title": "Bookmarks" + } + } + ] + } + ], + "direction": "horizontal", + "width": 300 + }, + "right": { + "id": "cdb5787bc7b074a1", + "type": "split", + "children": [ + { + "id": "4f7b084c90edcafa", + "type": "tabs", + "children": [ + { + "id": "87c20e5388b56742", + "type": "leaf", + "state": { + "type": "backlink", + "state": { + "file": "todo.md", + "collapseAll": false, + "extraContext": false, + "sortOrder": "alphabetical", + "showSearch": false, + "searchQuery": "", + "backlinkCollapsed": false, + "unlinkedCollapsed": true + }, + "icon": "links-coming-in", + "title": "Backlinks" + } + }, + { + "id": "d06f3a18f218bb85", + "type": "leaf", + "state": { + "type": "outgoing-link", + "state": { + "file": "todo.md", + "linksCollapsed": false, + "unlinkedCollapsed": true + }, + "icon": "links-going-out", + "title": "Outgoing links" + } + }, + { + "id": "5e8256b0c8cb4527", + "type": "leaf", + "state": { + "type": "tag", + "state": { + "sortOrder": "frequency", + "useHierarchy": true, + "showSearch": false, + "searchQuery": "" + }, + "icon": "lucide-tags", + "title": "Tags" + } + }, + { + "id": "c4c977be0ce05b9d", + "type": "leaf", + "state": { + "type": "all-properties", + "state": { + "sortOrder": "frequency", + "showSearch": false, + "searchQuery": "" + }, + "icon": "lucide-archive", + "title": "All properties" + } + }, + { + "id": "bf5df26d52eb2371", + "type": "leaf", + "state": { + "type": "outline", + "state": { + "file": "todo.md", + "followCursor": false, + "showSearch": false, + "searchQuery": "" + }, + "icon": "lucide-list", + "title": "Outline" + } + } + ] + } + ], + "direction": "horizontal", + "width": 300, + "collapsed": true + }, + "left-ribbon": { + "hiddenItems": { + "switcher:Open quick switcher": false, + "graph:Open graph view": false, + "canvas:Create new canvas": false, + "daily-notes:Open today's daily note": false, + "templates:Insert template": false, + "command-palette:Open command palette": false, + "bases:Create new base": false + } + }, + "active": "1db1d6b317bc05ae", + "lastOpenFiles": [] +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 0cef11b..bd7d533 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ }, "devDependencies": { "@eslint/js": "^10.0.1", - "@types/node": "^26.1.0", + "@types/node": "^26.2.0", "eslint": "^10.6.0", "eslint-config-prettier": "^10.1.8", "eslint-plugin-functional": "^10.0.0", @@ -1084,9 +1084,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "26.1.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-26.1.0.tgz", - "integrity": "sha512-O0A1G3xPGy4w7AgQdAQYUlQ+BKk2Oovw8eRpofyp5KdBZULnbe+WqaOVNrm705SHphCiG4XHsACrSmPu1f+Kgw==", + "version": "26.2.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-26.2.0.tgz", + "integrity": "sha512-5IviulTZeRNp2vAJ514cc/HUlY5nZ9fCbq9DMyC52BrhFZACo3nI0R7qBxhQmo/d27NFe96ur/b7Wwxklda+kg==", "dev": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 8b7d57d..ececac2 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "type": "module", "devDependencies": { "@eslint/js": "^10.0.1", - "@types/node": "^26.1.0", + "@types/node": "^26.2.0", "eslint": "^10.6.0", "eslint-config-prettier": "^10.1.8", "eslint-plugin-functional": "^10.0.0", diff --git a/src/index.ts b/src/index.ts index 3b7f54d..6fd61b4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,8 +8,15 @@ namespace Termos { console.log("termos initialized"); } } - */ +*/ + const message: string = "Hello, World!"; console.log(message); +console.clear(); +process.stdout.write("> "); +process.stdin.on("data", data => { + const input = data.toString().trim(); +}); + //export { Termos }; diff --git a/todo.md b/todo.md new file mode 100644 index 0000000..65b3b6c --- /dev/null +++ b/todo.md @@ -0,0 +1,140 @@ +# 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 diff --git a/tsconfig.json b/tsconfig.json index b84a33c..3470afc 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -23,6 +23,7 @@ "sourceMap": true, "ignoreDeprecations": "6.0", "baseUrl": "./", + "types": ["node"], "paths": { "@tests/*": ["test/*"], "@shell/*": ["src/shell/*"],