moshcode 0.58.0 → 0.60.0
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/README.md +299 -6
- package/bin/moshcode.mjs +3 -3
- package/examples/account.mosh +48 -0
- package/examples/aliases.mosh +56 -0
- package/examples/research-desk.mosh +49 -0
- package/package.json +1 -1
- package/prd/0011-herd-agent-protocol.md +391 -0
- package/prd/README.md +1 -0
- package/src/auth.mjs +59 -64
- package/src/cli-schema.mjs +133 -4
- package/src/commands.mjs +389 -39
- package/src/cost-cli.mjs +232 -0
- package/src/cost-pricing.mjs +159 -0
- package/src/cost.mjs +753 -0
- package/src/engines.mjs +32 -0
- package/src/games-breakout.mjs +64 -10
- package/src/games-paddle.mjs +128 -0
- package/src/games-pong.mjs +53 -4
- package/src/games.mjs +164 -12
- package/src/herd-cli.mjs +816 -20
- package/src/herd-eval.mjs +301 -0
- package/src/herd-hooks.mjs +285 -0
- package/src/herd-remote.mjs +365 -0
- package/src/herd-serve.mjs +515 -0
- package/src/herd-state.mjs +167 -10
- package/src/herd-tasks.mjs +377 -0
- package/src/herd.mjs +89 -7
- package/src/templates.mjs +32 -5
- package/src/tools.mjs +43 -0
- package/src/tui.mjs +1 -0
package/src/cli-schema.mjs
CHANGED
|
@@ -95,6 +95,11 @@ export const CORE_CLI_COMMANDS = [
|
|
|
95
95
|
["# driving one without attaching", ""],
|
|
96
96
|
["moshcode herd prompt api \"run the tests\" --wait", "hand it work, block until it lands"],
|
|
97
97
|
["moshcode herd read api --lines 40", "read its screen"],
|
|
98
|
+
["", ""],
|
|
99
|
+
["# what happened while you slept", ""],
|
|
100
|
+
["moshcode herd hooks install claude", "state from the engine, not from its screen"],
|
|
101
|
+
["moshcode herd tasks api", "every prompt, and how long each one waited on you"],
|
|
102
|
+
["moshcode herd remote add research https://agents.do-ai.run/…/production", "a deployed agent, same verbs"],
|
|
98
103
|
],
|
|
99
104
|
seeAlso: ["ps", "attach", "wait", "restore", "start"],
|
|
100
105
|
note: "`start` is for the engines moshcode installs; `run` and `shell` take anything else, "
|
|
@@ -112,6 +117,34 @@ export const CORE_CLI_COMMANDS = [
|
|
|
112
117
|
seeAlso: ["herd", "attach", "wait"],
|
|
113
118
|
note: "state is idle, working, blocked, done or unknown — unknown is a safe answer, not a failure.",
|
|
114
119
|
},
|
|
120
|
+
{
|
|
121
|
+
name: "cost",
|
|
122
|
+
group: "runtime",
|
|
123
|
+
description: "what each session is spending, read from the engines' own logs",
|
|
124
|
+
synopsis: [["moshcode cost [name] [--all] [--since 6h] [--json]", "session, engine, model, tokens, cost"]],
|
|
125
|
+
flags: [
|
|
126
|
+
["--all", "every engine session on disk, herd or not", ""],
|
|
127
|
+
["--since <dur>", "how far back to look (30m, 6h, 3d)", "24h"],
|
|
128
|
+
["--engine <list>", "only these engines, comma-separated", "all"],
|
|
129
|
+
["--watch [secs]", "re-read on an interval until ctrl-c", "10"],
|
|
130
|
+
["--json", "machine-readable", ""],
|
|
131
|
+
],
|
|
132
|
+
examples: [
|
|
133
|
+
["moshcode cost", "what is the herd costing me right now?"],
|
|
134
|
+
["moshcode cost api --json", "one session, with its engine runs broken out"],
|
|
135
|
+
["moshcode cost --all --since 7d", "everything the agents did this week"],
|
|
136
|
+
],
|
|
137
|
+
seeAlso: ["ps", "herd", "attach"],
|
|
138
|
+
note: "the numbers come from each CLI's own session log — claude's ~/.claude/projects transcripts, "
|
|
139
|
+
+ "codex's rollout token counts, opencode's per-message cost, aider's chat history. a figure marked "
|
|
140
|
+
+ "`~` was worked out from published rates and is what the tokens WOULD cost on the api; unmarked "
|
|
141
|
+
+ "figures are the engine's own arithmetic. models with no rate show tokens and no cost — add yours "
|
|
142
|
+
+ "to ~/.moshcode/pricing.json. gemini, kimi, deepseek and openagents log nothing readable, "
|
|
143
|
+
+ "so they report no cost rather than zero.",
|
|
144
|
+
},
|
|
145
|
+
// Everyone who has used a coding agent's own `/usage` types that word first,
|
|
146
|
+
// and tokens-and-spend is exactly what `cost` already answers.
|
|
147
|
+
{ name: "usage", aliasOf: "cost", description: "alias for cost" },
|
|
115
148
|
{
|
|
116
149
|
name: "attach",
|
|
117
150
|
group: "runtime",
|
|
@@ -140,15 +173,25 @@ export const CORE_CLI_COMMANDS = [
|
|
|
140
173
|
name: "wait",
|
|
141
174
|
group: "runtime",
|
|
142
175
|
description: "block until a session is blocked, done, or idle",
|
|
143
|
-
synopsis: [
|
|
176
|
+
synopsis: [
|
|
177
|
+
["moshcode wait <name> [--state blocked,done] [--timeout 30m]", ""],
|
|
178
|
+
["moshcode wait --any <a> <b> …", "the first one there wins"],
|
|
179
|
+
["moshcode wait --all <a> <b> …", "join the whole fan-out"],
|
|
180
|
+
],
|
|
144
181
|
flags: [
|
|
145
182
|
["--state <list>", "states to wait for, comma-separated", "blocked,done"],
|
|
183
|
+
["--any", "return as soon as one of them reaches the state", ""],
|
|
184
|
+
["--all", "return when every one of them has", "implied by naming several"],
|
|
146
185
|
["--timeout <dur>", "give up after this long (30s, 10m, 2h)", "30m"],
|
|
147
186
|
["--json", "machine-readable", ""],
|
|
148
187
|
],
|
|
149
|
-
examples: [
|
|
188
|
+
examples: [
|
|
189
|
+
["moshcode wait api --state blocked --timeout 1h", "exit 0 matched · 2 timed out · 3 gone"],
|
|
190
|
+
["moshcode wait --any api web docs", "--json names the winner"],
|
|
191
|
+
],
|
|
150
192
|
seeAlso: ["herd", "ps"],
|
|
151
|
-
note: "exit codes are the point: 0 matched, 2 timed out, 3 no such session."
|
|
193
|
+
note: "exit codes are the point: 0 matched, 2 timed out, 3 no such session. "
|
|
194
|
+
+ "--any/--all are what fan-in scripts used to spell out as a polling loop; a remote member waits the same way a local one does.",
|
|
152
195
|
},
|
|
153
196
|
{
|
|
154
197
|
name: "restore",
|
|
@@ -874,6 +917,14 @@ export const HERD_VERBS = [
|
|
|
874
917
|
{ name: "status", description: "what the herd is running on, and how many sessions",
|
|
875
918
|
synopsis: [["moshcode herd status [--json]", ""]],
|
|
876
919
|
flags: [["--json", "machine-readable", ""]] },
|
|
920
|
+
{ name: "cost", description: "what each session is spending, from the engines' own logs",
|
|
921
|
+
synopsis: [["moshcode herd cost [name] [--all] [--since 6h] [--json]", ""]],
|
|
922
|
+
flags: [
|
|
923
|
+
["--all", "every engine session on disk, herd or not", ""],
|
|
924
|
+
["--since <dur>", "how far back to look", "24h"],
|
|
925
|
+
["--watch [secs]", "re-read on an interval", "10"],
|
|
926
|
+
["--json", "machine-readable", ""],
|
|
927
|
+
] },
|
|
877
928
|
{ name: "start", description: "start a session and hand the prompt back",
|
|
878
929
|
synopsis: [["moshcode herd start <engine> [--name <slug>] [--agent] [args…]", ""]],
|
|
879
930
|
flags: [
|
|
@@ -930,11 +981,21 @@ export const HERD_VERBS = [
|
|
|
930
981
|
{ name: "send-keys", description: "send raw keys (Enter, Escape, C-c, literal text)",
|
|
931
982
|
synopsis: [["moshcode herd send-keys <name> <keys…>", ""]] },
|
|
932
983
|
{ name: "wait", description: "block until a session reaches a state",
|
|
933
|
-
synopsis: [
|
|
984
|
+
synopsis: [
|
|
985
|
+
["moshcode herd wait <name> [--state blocked,done]", ""],
|
|
986
|
+
["moshcode herd wait --any <a> <b> …", "returns on the first one to get there"],
|
|
987
|
+
["moshcode herd wait --all <a> <b> …", "returns when every one of them has"],
|
|
988
|
+
],
|
|
934
989
|
flags: [
|
|
935
990
|
["--state <list>", "states to wait for", "blocked,done"],
|
|
991
|
+
["--any", "return on the first session to reach the state", ""],
|
|
992
|
+
["--all", "return when every named session has", "implied by naming several"],
|
|
936
993
|
["--timeout <dur>", "give up after this long", "30m"],
|
|
937
994
|
["--json", "machine-readable", ""],
|
|
995
|
+
],
|
|
996
|
+
examples: [
|
|
997
|
+
["moshcode wait --any api web docs", "whichever finishes first"],
|
|
998
|
+
["moshcode wait --all api web --state done", "join the whole fan-out"],
|
|
938
999
|
] },
|
|
939
1000
|
{ name: "restore", description: "rebuild remembered sessions after a reboot",
|
|
940
1001
|
synopsis: [["moshcode herd restore [--resume] [--dry-run]", ""]],
|
|
@@ -955,6 +1016,72 @@ export const HERD_VERBS = [
|
|
|
955
1016
|
{ name: "stop", description: "stop the whole runtime and everything in it",
|
|
956
1017
|
synopsis: [["moshcode herd stop --yes", ""]],
|
|
957
1018
|
flags: [["--yes, -y", "required when sessions are running", ""]] },
|
|
1019
|
+
|
|
1020
|
+
// PRD 0011 — the engine speaks, the herd remembers, and the roster reaches
|
|
1021
|
+
// past this box.
|
|
1022
|
+
{ name: "hooks", description: "install the engine's own lifecycle hooks, so state comes from it and not from its screen",
|
|
1023
|
+
synopsis: [["moshcode herd hooks <install|remove|status> [<engine>|all]", ""]],
|
|
1024
|
+
flags: [
|
|
1025
|
+
["--dry-run", "print the change to the engine's settings file and write nothing", ""],
|
|
1026
|
+
["--json", "machine-readable", ""],
|
|
1027
|
+
],
|
|
1028
|
+
examples: [
|
|
1029
|
+
["moshcode herd hooks install claude", "3 hooks: stop, notification, prompt-submit"],
|
|
1030
|
+
["moshcode herd hooks status", "per-engine, and which events are current"],
|
|
1031
|
+
],
|
|
1032
|
+
note: "the file is merged, never clobbered, and remove takes out only what moshcode put in. "
|
|
1033
|
+
+ "a hook fired outside a herd session does nothing and exits 0, so installing one cannot break an engine you run by hand. "
|
|
1034
|
+
+ "screen rules stay as the fallback." },
|
|
1035
|
+
{ name: "doctor", description: "check the things that actually go wrong: substrate, manifest drift, stale reports, rules.json",
|
|
1036
|
+
synopsis: [["moshcode herd doctor [--json]", ""]],
|
|
1037
|
+
flags: [["--json", "machine-readable, for provisioning scripts", ""]],
|
|
1038
|
+
note: "a broken ~/.moshcode/herd/rules.json is ignored silently everywhere else by design — this is where it gets to be loud." },
|
|
1039
|
+
{ name: "tasks", description: "every prompt submitted to a session, and what came of it",
|
|
1040
|
+
synopsis: [["moshcode herd tasks <session> [--json]", ""]],
|
|
1041
|
+
flags: [["--json", "machine-readable", ""]] },
|
|
1042
|
+
{ name: "task", description: "one task: its state transitions and its output",
|
|
1043
|
+
synopsis: [["moshcode herd task <id> [--json]", ""]],
|
|
1044
|
+
flags: [["--json", "machine-readable", ""]] },
|
|
1045
|
+
{ name: "log", description: "the timestamped state history of a session",
|
|
1046
|
+
synopsis: [["moshcode herd log <session> [--json]", ""]],
|
|
1047
|
+
flags: [["--json", "machine-readable", ""]] },
|
|
1048
|
+
{ name: "stats", description: "time in state, including how long things sat blocked waiting on you",
|
|
1049
|
+
synopsis: [["moshcode herd stats [session] [--json]", ""]],
|
|
1050
|
+
flags: [["--json", "machine-readable", ""]] },
|
|
1051
|
+
{ name: "remote", description: "put a deployed agent on the roster — A2A, or a bare POST endpoint",
|
|
1052
|
+
synopsis: [["moshcode herd remote <list|add|remove|ping|card> [args…]", ""]],
|
|
1053
|
+
flags: [
|
|
1054
|
+
["--kind <a2a|run>", "A2A JSON-RPC, or a plain POST {prompt}", "run"],
|
|
1055
|
+
["--json", "machine-readable", ""],
|
|
1056
|
+
],
|
|
1057
|
+
examples: [
|
|
1058
|
+
["moshcode herd remote add research https://agents.do-ai.run/…/production --kind run", ""],
|
|
1059
|
+
["moshcode herd prompt research \"summarise the week\"", "the same verb as a local session"],
|
|
1060
|
+
],
|
|
1061
|
+
note: "auth comes from MOSHCODE_REMOTE_<NAME>_TOKEN in the environment — never written to the manifest, never synced. "
|
|
1062
|
+
+ "a remote's state is the remote's claim, and `ps` says `remote` in the from column so nobody mistakes it for something this box verified." },
|
|
1063
|
+
{ name: "serve", description: "expose the herd over A2A v0.3.0, behind your moshcode login",
|
|
1064
|
+
synopsis: [["moshcode herd serve [--port 7683] [--bind 127.0.0.1]", ""]],
|
|
1065
|
+
flags: [
|
|
1066
|
+
["--port <n>", "port to listen on", "7683"],
|
|
1067
|
+
["--bind <addr>", "interface to bind", "127.0.0.1"],
|
|
1068
|
+
["--expose-autonomous", "also serve sessions started with --agent", "off"],
|
|
1069
|
+
],
|
|
1070
|
+
note: "message/send is keystrokes into a real pty. there is no unauthenticated mode, loopback included, and sessions "
|
|
1071
|
+
+ "started with --agent are withheld unless you ask for them: an engine with approvals bypassed plus a network prompt "
|
|
1072
|
+
+ "is the worst pairing on the menu." },
|
|
1073
|
+
{ name: "eval", description: "run a dataset through several engines and score them",
|
|
1074
|
+
synopsis: [["moshcode herd eval --dataset <file> --engines a,b [--judge <engine>|rules]", ""]],
|
|
1075
|
+
flags: [
|
|
1076
|
+
["--dataset <file>", "jsonl, json or csv of { prompt, expect | rubric }", ""],
|
|
1077
|
+
["--engines <list>", "engines to compare", ""],
|
|
1078
|
+
["--judge <engine>|rules", "score with an engine, or with the dataset's own patterns", "rules"],
|
|
1079
|
+
["--threshold <0-1>", "the score every engine has to reach", "0.8"],
|
|
1080
|
+
["--keep", "leave the eval sessions running afterwards", ""],
|
|
1081
|
+
["--json", "machine-readable", ""],
|
|
1082
|
+
],
|
|
1083
|
+
note: "exit codes are distinct on purpose: 0 pass, 4 below the threshold, 5 the harness could not run — "
|
|
1084
|
+
+ "CI has to tell a worse agent from a broken box." },
|
|
958
1085
|
];
|
|
959
1086
|
|
|
960
1087
|
export const VERB_TABLES = {
|
|
@@ -994,6 +1121,8 @@ export const PIT_COMMANDS = [
|
|
|
994
1121
|
description: "sessions that keep running when you leave" },
|
|
995
1122
|
{ name: "ps", cli: "ps",
|
|
996
1123
|
description: "what the herd is running, and which one wants you" },
|
|
1124
|
+
{ name: "cost", aliases: ["usage"], args: "[name] [--all]", cli: "cost",
|
|
1125
|
+
description: "what the herd is spending, from the engines' own logs" },
|
|
997
1126
|
{ name: "attach", args: "<name>", cli: "attach",
|
|
998
1127
|
description: "step into a herd session (detach leaves it running)" },
|
|
999
1128
|
{ name: "kill", args: "<name…>", cli: "kill",
|