The old ShellTool used a flat string scanner that couldn't distinguish
quote context from operator context. In practice this produced a long
tail of surprising behaviours that confused AI agents and occasionally
corrupted the virtual filesystem:
* `echo hi 2>&1` wrote 'hi 2' to a file named literally `&1`
* `echo hi >&2` wrote to a file named `&2`
* `cat < in.txt` silently produced no output (input redirection
was unimplemented but not rejected)
* `for f in *.tsx; do ... done` was split into three separate
"command not found" errors
* `echo $HOME`, `echo $(pwd)`, `echo \`pwd\`` all printed
the unexpanded source text
* `# comment`, backslash escapes, brace expansion, tilde, and
arithmetic all fell through as literal characters
Introduce a proper mini-shell in src/lib/shell/:
* tokenizer.ts — POSIX-flavoured lexer that understands single and
double quotes, backslash escapes (including line continuations),
comments, operators, fd-prefixed redirections (IO_NUMBER), and
dollar-led expressions ($VAR, ${...}, $(...), $((...)), backticks).
* parser.ts — recursive-descent parser producing an AST covering
pipelines, and-or lists, sequences, redirections (including `<<`
heredocs and fd duplication like `2>&1`), and the full suite of
compound commands: if/elif/else/fi, for, while, until, case,
subshells, and brace groups.
* expand.ts — word expansion following POSIX ordering: brace
expansion, tilde, parameter, command substitution, arithmetic,
word splitting, pathname expansion, quote removal. Glob patterns
match against the virtual filesystem; unmatched patterns pass
through unchanged.
* executor.ts — AST interpreter that dispatches simple commands to
the existing ShellCommand registry, applies redirections safely
(validateWritePath runs BEFORE any file write so bogus paths can
no longer materialize), evaluates control flow, and tracks exit
status in $? with a safe iteration cap on while/until loops.
* Built-ins: true, false, :, export, unset, exit, test, [.
ShellTool.ts is now a thin integration layer that wires the registry
into a ShellExecutor and formats the final output, keeping its public
API (execute, getCurrentWorkingDirectory, setCurrentWorkingDirectory,
getAvailableCommands) unchanged so existing callers (ChatPane,
Terminal) don't need to change.
Tests:
* All 35 existing ShellTool tests still pass (adjusted two
assertions for the improved error messages).
* Added 29 tokenizer, 19 parser, 24 expander, and 49 end-to-end
tests covering the bash features listed above and confirming that
the data-corrupting redirection bugs are gone.
* Full suite: 1316 passed / 6 skipped, typecheck clean, lint clean,
build clean.
Shakespeare 🎭
Shakespeare is an open-source AI app builder that runs entirely in your browser.
Features
- Use any AI provider OpenAI, Anthropic, OpenRouter, xAI, ZAI, Deepseek, and more
- Buy credits anonymously with Nostr and Lightning ⚡
- Redeem gift cards with shareable links for instant credits
- Runs entirely in the browser No backend required
How it Works
Shakespeare is a React PWA that stores files in IndexedDB with LightningFS. Your browser connects directly to AI providers and git services (through isomorphic-git) to enable you to build and deploy AI apps entirely from your device.
Shakespeare hosts no backend (except for a couple microservices in the services/ directory; these are fully configurable within Shakespeare's settings). All your code and configuration is stored in your browser.
Configure any AI providers and git services you want. Configuration is stored entirely in the browser in localStorage.
You can then push and pull code to syncronize your work across devices.
Shakespeare can work on any type of project. But it is specialized to build React applications in TypeScript, which it compiles in the browser with esbuild-wasm and custom plugins. Any codebase can be worked on, but only compatible projects can be previewed directly in Shakespeare.
Open Source
Shakespeare is proudly Open Source software licensed under the GNU AGPLv3. The purpose of Shakespeare is to provide a free and open platform for building AI applications that respects user privacy and freedom.
Mirrors
Shakespeare is available on the following URLs: