@@ -127,9 +127,12 @@ In the TUI shell it's `/prd [idea]`.
127127
128128## moshscript
129129
130- A metal scripting toolkit. Paste dead-simple, readable scripts and run them.
130+ A metal scripting toolkit — ** secretly all JS is legal** . The simple surface
131+ stays dead-simple, but a ` .mosh ` file is real JavaScript under the hood with the
132+ full moshcode command vocabulary injected as globals:
131133
132- ```
134+ ``` js
135+ // alive.mosh — the starter script (unchanged, still works)
133136while (alive) {
134137 code ();
135138 mosh ();
@@ -138,45 +141,139 @@ while (alive) {
138141} // no bugs, only features
139142```
140143
141- ## Run
144+ The secret that it's all JS — no new syntax to learn:
145+
146+ ``` js
147+ // deploy-agents.mosh — real work, still reads like the toy
148+ const engines = [" claude" , " codex" ];
149+ for (const e of engines) {
150+ install (e); // → moshcode install <e>
151+ }
152+ mcp (" install" , " https://mcp.sentry.dev/mcp" ); // fan out across engines
153+ say (` ready to mosh with ${ engines .length } engines` );
154+ agents (" claude" ); // drop into an autonomous session
155+ ```
156+
157+ ### Run
142158
143159``` sh
144- moshcode run examples/alive.mosh # run a script
145- moshcode run - < script .mosh # or pipe/paste from stdin
146- moshcode run --max 5 # bound the while loop (default 3)
147- echo ' say("hi"); notify(); ' | moshcode run -
148- moshcode commands # list built-in commands
149- moshcode help
160+ moshcode run examples/alive.mosh # run a script
161+ moshcode run deploy .mosh --dry-run # narrate without executing
162+ moshcode run alive.mosh --max 5 # bound the while loop (default 3)
163+ moshcode run deploy.mosh staging --fast # extra args reach the script as argv
164+ moshcode run - < script.mosh # pipe/paste from stdin
165+ moshcode commands # list the full vocabulary
150166```
151167
152168No install/build step — it's plain ESM. ` node bin/moshcode.mjs … ` works too.
153169
154- ## moshscript
170+ ### Shebang — self-running scripts
171+
172+ ` .mosh ` files support shebang lines, so ` chmod +x ` makes them run like shell
173+ scripts. The ` moshscript ` executable is installed alongside ` moshcode ` :
174+
175+ ``` js
176+ #! / usr/ bin/ env moshscript
177+ // deploy.mosh — chmod +x it and run it like any shell script
178+ install (" claude" );
179+ agents (" claude" );
180+ ```
155181
156- The whole language:
182+ ``` sh
183+ chmod +x deploy.mosh
184+ ./deploy.mosh # shebang → moshscript → moshcode run
185+ ./deploy.mosh --dry-run staging # args after the file reach the script
186+ ```
187+
188+ ### Commands
189+
190+ ** Local verbs** (moshscript-only, in-process):
191+
192+ | verb | description |
193+ | ---| ---|
194+ | ` code() ` | compile features (no bugs) |
195+ | ` mosh() ` | open the pit + blast the moshcoding playlist |
196+ | ` notify(msg) ` | fire-and-forget ping + approval link on moshcode.sh |
197+ | ` ask(prompt) ` | blocking gate — waits for human reply at moshcode.sh |
198+ | ` say("…") ` | print a line |
199+ | ` sleep(ms) ` | pause for N milliseconds (blocking) |
200+ | ` stop() ` | end the loop (` alive = false ` ) |
201+ | ` repeat() ` | back to the top of the loop |
202+
203+ ** CLI verbs** (each shells out to ` moshcode <name> ...args ` ):
204+
205+ | verb | description |
206+ | ---| ---|
207+ | ` agents(engine) ` | launch an autonomous agent session |
208+ | ` start(engine) ` | raw-launch an engine |
209+ | ` install(target) ` | install an engine or workflow tool |
210+ | ` upgrade(targets…) ` | upgrade moshcode, engines, and tools |
211+ | ` mcp(args…) ` | register/fan out an MCP server |
212+ | ` skill(args…) ` | install a skill across engines |
213+ | ` prd(idea) ` | publish/author an OpenPRD doc |
214+ | ` ugig(args…) ` | drive the ugig workflow CLI |
215+ | ` coinpay(args…) ` | drive the coinpay workflow CLI |
216+ | ` c0mpute(args…) ` | drive the c0mpute workflow CLI |
217+ | ` pwd() ` | print the current repo/location |
218+ | ` run(file) ` | run another .mosh file (include/compose) |
219+
220+ ** Specials** (injected globals, not commands):
221+
222+ | name | description |
223+ | ---| ---|
224+ | ` alive ` | ` true ` while the loop may continue; reads bounded by ` --max ` |
225+ | ` argv ` | positional args passed after the script file |
226+ | ` env ` | ` process.env ` — parameterize scripts from the environment |
227+
228+ ### Human-in-the-loop
229+
230+ - ` notify(msg) ` — fire-and-forget. Pings the operator across configured channels
231+ and surfaces an approval link at ` app.moshcode.sh/approve/:id ` . Returns ` { id, url } ` .
232+ - ` ask(prompt) ` — blocking gate. Same ping + link, then ** blocks** until the
233+ operator opens the link, reads the context, types instructions, and submits.
234+ Resolves with their text (or ` null ` on timeout). Use with ` await ` :
157235
158- - ` while (alive) { … } ` — loops the body while the ` alive ` flag is set (bounded by ` --max ` ).
159- - ` name(args…); ` — call a command. ` // ` comments are ignored.
236+ ``` js
237+ const task = await ask (" what should I work on next?" );
238+ say (` got it: ${ task} ` );
239+ ```
160240
161- Built-in commands: ` code() ` ` mosh() ` ` notify() ` ` repeat() ` ` say("…") ` ` sleep(ms) ` ` stop() ` .
241+ ### Dry run
162242
163- ### notify()
243+ ` --dry-run ` narrates every action without executing it — no engine spawns, no
244+ installs, no network POSTs, no PRD writes:
164245
165- Pings ** moshcoding.com web notifications** , and — if ` MOSHCODE_WEBHOOK_URL ` is set —
166- also POSTs to that webhook. Both are HMAC-signed (` X-Moshcode-Signature ` ) with
167- ` MOSHCODE_WEBHOOK_SECRET ` .
246+ ```
247+ $ moshcode run deploy.mosh --dry-run
248+ 🎸 moshcode — running moshscript (dry run)
249+
250+ ▶ install(claude) → would run: moshcode install claude
251+ ▶ mcp(install, https://mcp.sentry.dev/mcp) → would run: moshcode mcp install …
252+ 💬 ready to mosh with 2 engines
253+ ▶ agents(claude) → would run: moshcode agents claude
254+
255+ ✓ 0 loop(s) — no bugs, only features. 🤘
256+ ```
168257
169258### Add your own commands
170259
260+ The vocabulary is open for extension via the registry:
261+
171262``` js
172- import { defaultCommands } from " moshcode/src/commands.mjs" ;
173- const commands = { ... defaultCommands (), deploy : (ctx ) => ctx .out (" shipping…" ) };
263+ import { moshVocabulary } from " moshcode/src/commands.mjs" ;
264+ import { runScript } from " moshcode/src/runtime.mjs" ;
265+
266+ const commands = moshVocabulary ();
267+ commands .register ({ name: " deploy" , summary: " ship it" , run : (ctx ) => ctx .out (" shipping…" ) });
268+ await runScript (src, { commands });
174269```
175270
176271## Env
177272
178273| var | default | purpose |
179274| ---| ---| ---|
180275| ` MOSHCODE_API ` | ` https://moshcoding.com ` | web-notifications endpoint host |
276+ | ` MOSHCODE_SITE ` | ` https://app.moshcode.sh ` | approval URL base |
181277| ` MOSHCODE_WEBHOOK_URL ` | — | optional extra webhook for ` notify() ` |
182278| ` MOSHCODE_WEBHOOK_SECRET ` | — | signs notify() posts |
279+ | ` MOSHCODE_PLAYLIST ` | Spotify playlist URL | what ` mosh() ` blasts in the browser |
0 commit comments