@innovatorved/code-lab 0.1.11 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ARCHITECTURE.md CHANGED
@@ -1,4 +1,4 @@
1
- # `@innovatorved/code-lab` Architecture (v0.1.10)
1
+ # `@innovatorved/code-lab` Architecture (v0.1.13)
2
2
 
3
3
  `@innovatorved/code-lab` is an embeddable, browser-native Node.js v22 + Bun v1.1 IDE, POSIX shell, PTY terminal, and virtual execution sandbox with self-contained browser bundles (zero runtime dependencies in `dist/*`; Zod schemas available under `@innovatorved/code-lab/schemas`).
4
4
 
@@ -27,7 +27,7 @@ It is designed around two strictly decoupled layers that can be used together (`
27
27
  │ src/terminal.ts) │ │ (src/runtime.ts) │
28
28
  │ • Recursive-descent AST parser │ │ • Web Worker pool + preemption │
29
29
  │ • Pipes (|), redirects (>, >>, 2>&1) │ │ • In-memory POSIX VFS (/tmp, …) │
30
- │ • 58 POSIX coreutils + git + jq │ │ • Node.js v22 (50 built-in mods)│
30
+ │ • 64 POSIX coreutils + git + jq │ │ • Node.js v22 (50 built-in mods)│
31
31
  │ • Interactive PTY ANSI/256-color │ │ • Bun v1.1 (serve, sqlite, test)│
32
32
  │ • Job table (ps, jobs, fg, bg, kill) │ │ • VirtualPortTable (127.0.0.1) │
33
33
  └───────────────────────────────────────┘ └──────────────────────────────────┘
@@ -69,10 +69,10 @@ It is designed around two strictly decoupled layers that can be used together (`
69
69
 
70
70
  `createPosixShell` implements a complete POSIX shell interpreter inside the browser:
71
71
  - **Lexer & Recursive-Descent AST Parser**: Supports single/double quotes, escape sequences, pipelines (`cmd1 | cmd2 | cmd3`), logical operators (`&&`, `||`, `;`), background execution (`&`), I/O redirection (`>`, `>>`, `<`, `<<<`, `2>`, `2>&1`, `&>`), environment variable expansion (`$VAR`, `${VAR:-default}`, `${VAR:=default}`, `${#VAR}`, `$?`, `$$`), command substitution (`$(...)`), arithmetic expansion (`$((...))`), brace expansion (`{a,b,c}`, `{1..5}`), and globbing (`*`, `?`, `**`).
72
- - **58 Built-in Coreutils**:
72
+ - **64 Built-in Coreutils**:
73
73
  - File & Directory: `ls`, `cat`, `head`, `tail`, `wc`, `cp`, `mv`, `rm`, `mkdir`, `rmdir`, `touch`, `ln`, `pwd`, `cd`, `find`, `tree`, `stat`, `file`, `du`, `df`, `chmod`, `chown`, `mktemp`, `basename`, `dirname`, `realpath`.
74
74
  - Text & Data Processing: `grep`, `sed`, `awk`, `sort`, `uniq`, `cut`, `tr`, `tee`, `xargs`, `diff`, `jq`, `xxd`, `hexdump`, `base64`, `md5sum`, `sha256sum`.
75
- - Networking, Process & Archive: `curl`, `nc`, `ping`, `dig`, `nslookup`, `lsof`, `netstat`, `ss`, `ps`, `top`, `kill`, `jobs`, `fg`, `bg`, `tar`, `gzip`, `gunzip`.
75
+ - Networking, Load Testing, Chaos & Databases: `curl`, `hey` (`ab`, `wrk`), `chaos`, `sqlite3`, `redis-cli`, `nc`, `ping`, `dig`, `nslookup`, `lsof`, `netstat`, `ss`, `ps`, `top`, `kill`, `jobs`, `fg`, `bg`, `tar`, `gzip`, `gunzip`.
76
76
  - Developer Toolchains: `node`, `bun`, `npm`, `pnpm`, `npx`, `bunx`, `tsc`, `git` (`init`, `status`, `add`, `commit`, `log`, `diff`, `branch`, `checkout`, `clone`).
77
77
  - Web Preview: `serve` (built-in static dev server that transpiles TS/TSX/JSX to browser-native ESM and injects a jsDelivr `+esm` import map for bare specifiers).
78
78
 
@@ -128,6 +128,6 @@ Running `bun run build` (`bun run tools/bundle.js`) produces:
128
128
  | **Visual Source Control (SCM)** | Staging, unstaging, diffing, and commit history | `src/scm.ts` (`createGitState`, `computeGitStatus`, `stageFile`, `unstageFile`, `commitChanges`, `computeShortCommitHash`) — Pure TypeScript SCM state machine synced with the POSIX shell `git` command |
129
129
  | **Live Preview & Error Overlay** | Hot/debounced reload, console bridge, runtime error overlay | `src/csp.ts` (`buildPreviewShims`) + `src/workbench.ts` — 300ms debounced VFS-synced auto-reload, `codelab:preview-console` forwarding to terminal logs, and `codelab:preview-error` in-frame overlay |
130
130
 
131
- All 39 test suites (`bun run test:all` and `node tests/run-all.js`) and the Playwright Chromium E2E suite (`bun run test:browser`) verify these modules and end-to-end workbench flows against the built `dist/*` artifacts.
131
+ All 40 test suites (`bun run test:all` and `node tests/run-all.js`) and the Playwright Chromium E2E suite (`bun run test:browser`) verify these modules and end-to-end workbench flows against the built `dist/*` artifacts.
132
132
 
133
133
 
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  > **Note:** This project is in active development. APIs and sandbox internals are stable for production use.
4
4
 
5
- Browser-native code IDE workbench, modular guided challenge engine (`@innovatorved/code-lab/extensions/guided-lab`), POSIX shell with 58 UNIX coreutils, public GitHub repository cloner (`git clone`), and Web Worker execution runtime for **Node.js** and **Bun** (JavaScript & TypeScript) with Zod type safety and zero backend server dependencies.
5
+ Browser-native code IDE workbench, modular guided challenge engine (`@innovatorved/code-lab/extensions/guided-lab`), POSIX shell with 64 UNIX coreutils, public GitHub repository cloner (`git clone`), and Web Worker execution runtime for **Node.js** and **Bun** (JavaScript & TypeScript) with Zod type safety and zero backend server dependencies.
6
6
 
7
7
  - **Live Cloud IDE & GitHub Repo Explorer**: **[https://code-lab-3dr.pages.dev](https://code-lab-3dr.pages.dev)** — Enter any public GitHub repository (`owner/repo` or URL) to clone and run it directly in your browser.
8
8
  - **Built for**: [System Design In Depth](https://system-design-in-depth.vedgupta.in)
@@ -11,12 +11,12 @@ Browser-native code IDE workbench, modular guided challenge engine (`@innovatorv
11
11
 
12
12
  ## Features
13
13
 
14
- - **Modular Architecture (`v0.1.10`)**: Pure, general-purpose browser IDE (`code-lab`) by default with File Explorer, Monaco Editor, and PTY Terminal. Curriculum features (Guided Steps, Mode Switcher, and JS/TS switcher) are encapsulated in an opt-in modular extension (`@innovatorved/code-lab/extensions/guided-lab`).
14
+ - **Modular Architecture (`v0.1.13`)**: Pure, general-purpose browser IDE (`code-lab`) by default with File Explorer, Monaco Editor, and PTY Terminal. Curriculum features (Guided Steps, Mode Switcher, and JS/TS switcher) are encapsulated in an opt-in modular extension (`@innovatorved/code-lab/extensions/guided-lab`).
15
15
  - **End-to-End TypeScript & Zod Type Safety**: Written in TypeScript with strict runtime schemas and inferred types (`z.infer<typeof ...>`) for workbench options, guided labs, runtime execution, and git cloning.
16
16
  - **Public GitHub Repository Cloning (`git clone`)**: Clone any public GitHub repository (`git clone https://github.com/owner/repo` or `git clone owner/repo --branch main` in the terminal, or `await lab.cloneRepo('owner/repo')` via the SDK) directly into `/workspace` with zero authentication required (automatic GitHub Trees API + jsDelivr unlimited fallback). Clone progress (`remote: Enumerating objects…`, `Receiving objects: n%…`) streams into the terminal in real time as it downloads.
17
17
  - **Interactive IDE Workbench**: Multi-file Monaco editor, collapsible hierarchical file tree with drag-and-drop, a workspace **folder switcher** (breadcrumb dropdown that scopes the explorer to any subfolder), decoupled editor tabs, Command Palette (`Cmd+Shift+P`), Quick Open (`Cmd+P`), breadcrumbs, and line-by-line solution diff viewer.
18
18
  - **Interactive PTY Terminal**: Inline prompt (`codelab:/workspace$ `), cursor navigation, history (`Up`/`Down`), `Ctrl+R` reverse-i-search, `Tab` auto-completion, `Ctrl+C` interrupt, `Ctrl+L` clear, and 256-color / TrueColor ANSI support.
19
- - **POSIX Shell & 58 Coreutils**: Full pure-JS AST interpreter supporting pipelines (`|`), redirects (`>`, `>>`, `2>&1`, `<<<`, `<<EOF`), control flow (`if`/`for`/`while`/`case`), functions, arithmetic `$((...))`, brace expansion `{1..5}`, and 58 UNIX commands (`git`, `ls`, `cat`, `grep`, `find`, `sed`, `awk`, `jq`, `tar`, `curl`, `nc`, `lsof`, `tsc`, etc.).
19
+ - **POSIX Shell & 64 Coreutils**: Full pure-JS AST interpreter supporting pipelines (`|`), redirects (`>`, `>>`, `2>&1`, `<<<`, `<<EOF`), control flow (`if`/`for`/`while`/`case`), functions, arithmetic `$((...))`, brace expansion `{1..5}`, and 64 UNIX commands (`git`, `ls`, `cat`, `grep`, `find`, `sed`, `awk`, `jq`, `tar`, `curl`, `hey`, `ab`, `wrk`, `chaos`, `sqlite3`, `redis-cli`, `nc`, `lsof`, `tsc`, etc.).
20
20
  - **Dual Runtime Engines (Node.js v22 & Bun v1.1)**:
21
21
  - **Node.js**: 50 built-in modules (`fs`, `fs/promises`, `http`, `https`, `net`, `stream`, `events`, `crypto`, `zlib`, `vm`, `worker_threads`, `readline`, `module`, `node:test`, `assert`, etc.).
22
22
  - **Bun**: Native `.ts` transpilation, `Bun.serve()`, `Bun.file()`, `Bun.write()`, `Bun.spawn()`, `Bun.password`, `Bun.hash()`, `bun:test`, and VFS-backed `bun:sqlite`.
@@ -122,7 +122,7 @@ Complete documentation is published on the [GitHub Wiki](https://github.com/inno
122
122
  - **[Quick Start](https://github.com/innovatorved/code-lab/wiki/Quick-Start)**: Setup, CDN, and quick examples.
123
123
  - **[Integration Guide](https://github.com/innovatorved/code-lab/wiki/Integration-Guide)**: Embedding in React, Next.js, Vite, and HTML.
124
124
  - **[Workbench Configuration](https://github.com/innovatorved/code-lab/wiki/Workbench-Configuration)**: Complete reference of options, methods, events, and shortcuts.
125
- - **[POSIX Shell & Coreutils](https://github.com/innovatorved/code-lab/wiki/POSIX-Shell-and-Coreutils)**: Pipelines, redirects, background jobs, and 58 UNIX commands.
125
+ - **[POSIX Shell & Coreutils](https://github.com/innovatorved/code-lab/wiki/POSIX-Shell-and-Coreutils)**: Pipelines, redirects, background jobs, and 64 UNIX commands.
126
126
  - **[Runtime APIs (Node & Bun)](https://github.com/innovatorved/code-lab/wiki/Runtime-APIs)**: 50 Node.js built-ins, Bun APIs, `bun:test`, `bun:sqlite`, and npm install.
127
127
  - **[HTTP Servers & Networking](https://github.com/innovatorved/code-lab/wiki/HTTP-Servers-and-Networking)**: Virtual port table, background servers, `curl`, and Port Preview.
128
128
  - **[Headless Runtime](https://github.com/innovatorved/code-lab/wiki/Headless-Runtime)**: Run code and tests programmatically with zero UI.
@@ -146,7 +146,7 @@ bun run tests/test-all-builds.js # 15/15 builds & 226 unit tests
146
146
  bun run tests/test-runtime-advanced.js # Advanced runtime, VFS, HTTP/TCP
147
147
  bun run tests/test-option1-shell-bun-http.js # Shell AST, Bun runtime, curl, ports, npm/pnpm
148
148
  bun run tests/test-frameworks.js # React/Preact/Vue/Angular support + browser preview server
149
- bun run tests/test-coreutils-adversarial.js # Adversarial stress tests on 58 coreutils
149
+ bun run tests/test-coreutils-adversarial.js # Adversarial stress tests on 64 coreutils
150
150
  bun run tests/test-stress-shell.js # Deep pipelines, redirections, large stdout
151
151
  bun run tests/test-workbench-ui.js # Workbench tabs, explorer, shortcuts
152
152
  ```
@@ -154,7 +154,7 @@ bun run tests/test-workbench-ui.js # Workbench tabs, explorer, shortcu
154
154
  Individual suites also run under Node 20, 22 and 24 — CI exercises all three:
155
155
 
156
156
  ```bash
157
- bun run build && node tests/run-all.js # same 39 suites, Node runtime
157
+ bun run build && node tests/run-all.js # same 40 suites, Node runtime
158
158
  ```
159
159
 
160
160
  Suites load the built bundles from `dist/` (never raw TypeScript from `src/`), so
package/dist/code-lab.css CHANGED
@@ -5157,3 +5157,168 @@ code-lab,
5157
5157
  border-top: 1px solid var(--cl-border);
5158
5158
  }
5159
5159
  }
5160
+
5161
+ /* ── System Design SLO Telemetry Bar, Topology Map & Chaos Controls ────────── */
5162
+ .codelab-slo-bar {
5163
+ display: flex;
5164
+ align-items: center;
5165
+ flex-wrap: wrap;
5166
+ gap: 12px;
5167
+ padding: 6px 12px;
5168
+ background: var(--cl-bg-elevated);
5169
+ border: 1px solid var(--cl-border);
5170
+ border-radius: var(--cl-radius-sm, 4px);
5171
+ }
5172
+
5173
+ .codelab-slo-metric {
5174
+ display: inline-flex;
5175
+ align-items: baseline;
5176
+ gap: 5px;
5177
+ font-size: 11.5px;
5178
+ }
5179
+
5180
+ .codelab-slo-label {
5181
+ color: var(--cl-fg-muted);
5182
+ font-size: 10.5px;
5183
+ text-transform: uppercase;
5184
+ letter-spacing: 0.04em;
5185
+ font-weight: 600;
5186
+ }
5187
+
5188
+ .codelab-slo-val {
5189
+ font-family: var(--cl-font-mono);
5190
+ font-weight: 600;
5191
+ color: var(--cl-fg);
5192
+ }
5193
+
5194
+ .codelab-slo-val.is-ok {
5195
+ color: var(--cl-green, #22c55e);
5196
+ }
5197
+
5198
+ .codelab-slo-val.is-warn {
5199
+ color: var(--cl-amber, #f59e0b);
5200
+ }
5201
+
5202
+ .codelab-slo-val.is-err {
5203
+ color: var(--cl-red, #ef4444);
5204
+ }
5205
+
5206
+ .codelab-topo-bar {
5207
+ display: flex;
5208
+ flex-direction: column;
5209
+ gap: 6px;
5210
+ padding: 6px 10px;
5211
+ background: var(--cl-bg-panel);
5212
+ border: 1px solid var(--cl-border);
5213
+ border-radius: var(--cl-radius-sm, 4px);
5214
+ font-size: 11.5px;
5215
+ }
5216
+
5217
+ .codelab-topo-nodes,
5218
+ .codelab-topo-edges {
5219
+ display: flex;
5220
+ align-items: center;
5221
+ flex-wrap: wrap;
5222
+ gap: 8px;
5223
+ }
5224
+
5225
+ .codelab-topo-node {
5226
+ display: inline-flex;
5227
+ align-items: center;
5228
+ gap: 5px;
5229
+ padding: 2px 8px;
5230
+ border-radius: 999px;
5231
+ background: var(--cl-bg-elevated);
5232
+ border: 1px solid var(--cl-border);
5233
+ font-size: 11px;
5234
+ }
5235
+
5236
+ .codelab-topo-node.is-healthy .codelab-port-status-dot {
5237
+ background: var(--cl-green, #22c55e);
5238
+ }
5239
+
5240
+ .codelab-topo-node.is-degraded {
5241
+ border-color: rgba(245, 158, 11, 0.45);
5242
+ }
5243
+
5244
+ .codelab-topo-node.is-degraded .codelab-port-status-dot {
5245
+ background: var(--cl-amber, #f59e0b);
5246
+ }
5247
+
5248
+ .codelab-topo-node.is-crashed {
5249
+ border-color: rgba(239, 68, 68, 0.5);
5250
+ background: rgba(239, 68, 68, 0.08);
5251
+ }
5252
+
5253
+ .codelab-topo-node.is-crashed .codelab-port-status-dot {
5254
+ background: var(--cl-red, #ef4444);
5255
+ }
5256
+
5257
+ .codelab-topo-edge {
5258
+ display: inline-flex;
5259
+ align-items: center;
5260
+ gap: 4px;
5261
+ font-family: var(--cl-font-mono);
5262
+ font-size: 11px;
5263
+ color: var(--cl-fg);
5264
+ padding: 1px 6px;
5265
+ border-radius: 4px;
5266
+ background: var(--cl-bg-elevated);
5267
+ }
5268
+
5269
+ .codelab-topo-edge--err {
5270
+ color: var(--cl-red, #ef4444);
5271
+ border: 1px solid rgba(239, 68, 68, 0.35);
5272
+ }
5273
+
5274
+ .codelab-topo-arrow {
5275
+ color: var(--cl-fg-muted);
5276
+ font-size: 10.5px;
5277
+ }
5278
+
5279
+ .codelab-chaos-badge {
5280
+ display: inline-flex;
5281
+ align-items: center;
5282
+ padding: 1px 5px;
5283
+ border-radius: 4px;
5284
+ font-family: var(--cl-font-mono);
5285
+ font-size: 10px;
5286
+ font-weight: 600;
5287
+ line-height: 1.3;
5288
+ }
5289
+
5290
+ .codelab-chaos-badge--warn {
5291
+ background: rgba(245, 158, 11, 0.16);
5292
+ color: var(--cl-amber, #f59e0b);
5293
+ border: 1px solid rgba(245, 158, 11, 0.35);
5294
+ }
5295
+
5296
+ .codelab-chaos-badge--danger {
5297
+ background: rgba(239, 68, 68, 0.16);
5298
+ color: var(--cl-red, #ef4444);
5299
+ border: 1px solid rgba(239, 68, 68, 0.35);
5300
+ }
5301
+
5302
+ .codelab-port-status--crashed {
5303
+ color: var(--cl-red, #ef4444);
5304
+ }
5305
+
5306
+ .codelab-port-status--crashed .codelab-port-status-dot {
5307
+ background: var(--cl-red, #ef4444);
5308
+ box-shadow: 0 0 6px var(--cl-red, #ef4444);
5309
+ }
5310
+
5311
+ .codelab-chaos-btn-group {
5312
+ display: inline-flex;
5313
+ align-items: center;
5314
+ gap: 4px;
5315
+ margin-right: 6px;
5316
+ padding-right: 6px;
5317
+ border-right: 1px solid var(--cl-border);
5318
+ }
5319
+
5320
+ .codelab-btn--chaos-active {
5321
+ background: rgba(245, 158, 11, 0.18) !important;
5322
+ border-color: rgba(245, 158, 11, 0.5) !important;
5323
+ color: var(--cl-amber, #f59e0b) !important;
5324
+ }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * TypeScript Definitions for @innovatorved/code-lab v0.1.11
2
+ * TypeScript Definitions for @innovatorved/code-lab v0.1.13
3
3
  */
4
4
 
5
5
  export interface CodeLabStep {