moshscript: account verbs, aliases, read verbs, and the newer CLI surface - #407
Merged
Conversation
…face The vocabulary had drifted behind the CLI: 43 verbs against 54 commands, with no way for a script to authenticate, reach the pit's aliases, or read a tool's output as anything but exit codes. Account (login/whoami/requireLogin/logout). Local rather than cliVerbs for the same reason the herd is: `moshcode whoami` prints, and a script needs to branch on the answer. src/auth.mjs grows identity() — the verified account as a value — and whoami() renders it, so the CLI and a script can never disagree about what "logged in" means. requireLogin() is the gate and the one verb here that throws: everything downstream would fail one call at a time and much less legibly. login() is idempotent so a re-run never throws a browser tab at someone already signed in, and returns its failure rather than throwing (R8). Aliases (alias/unalias/runAlias) read and write the pit's own store, so the operator's vocabulary and moshcode's stay one thing. Expansion is the pit's rule — leading `/` is a moshcode command, else a shell line, arguments appended. Read verbs (stocksRead/cryptoRead/newsRead) call the same advis0r/feed layer the printed commands render from and return parsed data, so a script can rank and threshold instead of scraping stdout. Plus 15 CLI verbs for surfaces added since: stocks, crypto, advisor, news, rss, plugin, engines, tools, dns, doh, site, serve, template, save, load. 43 → 68. Three worked examples, all safe under --dry-run. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ThreatCrush Security Scan53 finding(s) HIGH/CRITICAL: 5 | MEDIUM: 42 | LOW: 6
…and 3 more. Full results in the Security tab. Snippets are redacted; ThreatCrush never prints matched credential material. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The moshscript vocabulary had drifted behind the CLI — 43 verbs against 54 commands — with no way for a script to authenticate, reach the pit's aliases, or read a tool's output as anything but an exit code.
Account
login(),whoami(),requireLogin(),logout(). Local verbs rather thancliVerbs for the same reason the herd is:moshcode whoamiprints, and a script needs to branch on the answer.src/auth.mjsgrowsidentity()— the verified account as a value — andwhoami()now renders it. One verified-identity implementation, two callers, so the CLI and a script can never disagree about what "logged in" means.requireLogin()is the gate, and the one verb here that throws — everything downstream would otherwise fail one call at a time, later and less legibly.login()is idempotent ({ already: true }), so a script you re-run all day never throws a browser tab at someone already signed in, and returns its failure rather than throwing (R8).Aliases
alias(),unalias(),runAlias()read and write the pit's own store, so the operator's vocabulary and moshcode's stay one thing rather than two. Expansion follows the pit's rule — leading/is a moshcode command, anything else a shell line, arguments appended rather than substituted.Read verbs
stocksRead(),cryptoRead(),newsRead()call the same advis0r/feed layer the printed commands render from and hand back parsed data, so a script can rank and threshold instead of scraping stdout. A failed lookup returnsnull, not a throw.Plus the surfaces added since
15 CLI verbs:
stocks,crypto,advisor,news,rss,plugin,engines,tools,dns,doh,site,serve,template,save,load. 43 → 68 verbs.Examples
account.mosh,aliases.mosh,research-desk.mosh— all safe under--dry-run, all verified to run.Testing
test/commands-account-alias.test.mjsmoshcode commandsandmoshcode help <verb>render every new verb--dry-run🤖 Generated with Claude Code