Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ or miss one that does. A test fails the build when it drifts.
<!-- COMMANDS:START -->
| command | group | what it does |
|---|---|---|
| `moshcode agents` | engines | list engines or launch one autonomously |
| `moshcode agents` | engines | list engines, open their agent view, or launch autonomously |
| `moshcode start` | engines | launch an engine with its native defaults |
| `moshcode herd` | runtime | run agent sessions that outlive this terminal |
| `moshcode ps` | runtime | list herd sessions and what each one is doing |
Expand Down Expand Up @@ -107,7 +107,7 @@ use this only in an isolated container, VM, or workspace you trust:
moshcode agents claude # claude agents --dangerously-skip-permissions (agent view)
moshcode agents opencode # opencode --auto (autonomous)
moshcode agents privacycode # privacycode --auto (autonomous)
moshcode agents codex # codex --dangerously-bypass-approvals-and-sandbox (autonomous)
moshcode agents codex # codex --dangerously-bypass-approvals-and-sandbox agents (agent view)
moshcode agents gemini # gemini --approval-mode=yolo (autonomous)
moshcode agents kimi # kimi --yolo (autonomous)
moshcode agents qwen # qwen --approval-mode=yolo (autonomous)
Expand All @@ -116,6 +116,25 @@ moshcode agents aider # aider --yes-always
moshcode agents openagents # openagents (dashboard)
```

Codex's native agents overview requires a CLI with `codex agents` support
(verified with 0.151.0) and, for the local daemon, the managed standalone
installation. `moshcode install codex` / `moshcode upgrade codex` use Codex's
official standalone installer on macOS/Linux; an npm-only install is not enough.
Existing npm installations are preserved. Windows retains npm and requires
`--remote <server>` for the agents overview.
`/agents codex` opens the same live overview of sessions on Codex's shared local
app-server daemon. The approval/sandbox bypass is passed for this invocation;
moshcode does not rewrite your global Codex settings or stop existing sessions.
Additional arguments are forwarded to the native `agents` subcommand, for example
`moshcode agents codex --no-alt-screen`.

For separate conversations, Codex's `/new` starts a fresh chat in the same CLI,
`/resume` reopens a saved chat, and `/fork` branches a conversation while preserving
the original. These commands are distinct from launching parallel subagents:
ask Codex to delegate work, then use its `/agent` or `/subagents` picker to switch
threads. See the [Codex command reference](https://learn.chatgpt.com/docs/developer-commands?surface=cli)
and [subagent guide](https://learn.chatgpt.com/docs/agent-configuration/subagents).

`start` is the explicit raw path. It injects nothing, so the native engine keeps
its normal permission model and receives only your arguments:

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "moshcode",
"version": "0.93.0",
"version": "0.94.0",
"type": "module",
"description": "moshcode \u2014 a metal wrapper for coding engines and native UGig/CoinPay workflow CLIs, with OpenPRD and moshscript",
"repository": {
Expand Down
5 changes: 3 additions & 2 deletions src/cli-schema.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const CORE_CLI_COMMANDS = [
{
name: "agents",
group: "engines",
description: "list engines or launch one autonomously",
description: "list engines, open their agent view, or launch autonomously",
synopsis: [
["moshcode agents", "list engines and their install status"],
["moshcode agents --json", "list engine status as machine-readable JSON"],
Expand All @@ -48,6 +48,7 @@ export const CORE_CLI_COMMANDS = [
["moshcode agents", "which engines are here"],
["moshcode agents --json", "pipe engine status into a script"],
["moshcode agents claude", "claude's agent list"],
["moshcode agents codex", "Codex's shared-daemon agents overview (CLI 0.151.0+)"],
],
seeAlso: ["start", "engines", "install"],
note: "autonomous modes bypass approval prompts — use them in a container or a workspace you trust.",
Expand Down Expand Up @@ -1518,7 +1519,7 @@ export const PIT_COMMANDS = [
{ name: "new", pitOnly: true,
description: "open and switch to another moshcode tab" },
{ name: "agents", aliases: ["agent", "engines"], args: "[name]", cli: "agents",
description: "list engines, or launch one autonomously" },
description: "list engines, open their agent view, or launch autonomously" },
{ name: "start", args: "<engine> [args…]", cli: "start",
description: "raw launch; inject no engine arguments" },
{ name: "herd", args: "[verb] [args…]", cli: "herd",
Expand Down
2 changes: 1 addition & 1 deletion src/commands.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ const COMMANDS = [
cliVerb("run", "run another .mosh file (include)"),
// shortcut: ai() runs an engine headlessly and RETURNS its output (see PRD R17)
aiVerb,
cliVerb("agents", "launch an autonomous agent session (moshcode agents <engine>)"),
cliVerb("agents", "open the native agent view or launch autonomously (moshcode agents <engine>)"),
cliVerb("herd", "drive the herd (moshcode herd <verb>) — see herdStart/herdWait for values"),
cliVerb("ps", "print the herd roster"),
cliVerb("cost", "print what the herd is spending (moshcode cost [name] [--all])"),
Expand Down
15 changes: 12 additions & 3 deletions src/engines.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
//
// `agentsView` (optional) is the exact argv that opens the engine's native
// agent list/view — used by `/agents <name>` when the engine actually has one
// (currently claude). It's the FULL leading args (subcommand + any flags that
// subcommand accepts). Engines without an `agentsView` fall back to
// (currently Claude and Codex). It's the FULL leading args, including root
// flags before the subcommand when required. Engines without an `agentsView` fall back to
// `agentArgs` — an autonomous session with native approvals
// bypassed/auto-approved. Do not use a machine-readable, one-shot list command
// as an agents view: `/agents` promises to hand the terminal to a live session.
Expand Down Expand Up @@ -131,7 +131,16 @@ export const ENGINES = {
desc: "Codex — OpenAI's coding CLI",
bin: "codex",
agentArgs: ["--dangerously-bypass-approvals-and-sandbox"],
install: { cmd: "npm", args: ["install", "-g", "@openai/codex"] },
// Codex 0.151.0+: live shared-daemon session overview. The bypass option
// belongs to the root command, not the `agents` subcommand.
agentsView: ["--dangerously-bypass-approvals-and-sandbox", "agents"],
// The local agents daemon requires the installer-managed standalone
// package; npm alone can launch chats but cannot bootstrap that daemon.
// Windows uses a remote agents server and retains its npm installation.
install: process.platform === "win32"
? { cmd: "npm", args: ["install", "-g", "@openai/codex"] }
: { cmd: "bash", args: ["-o", "pipefail", "-c", "curl -fsSL https://chatgpt.com/codex/install.sh | CODEX_NON_INTERACTIVE=1 sh"] },
binDirs: [path.join(homedir(), ".local", "bin")],
resume: ["resume", "--last"],
state: {
blocked: [/\ballow (?:this )?command\b/i, /\bapprove this (?:command|edit|change)\b/i],
Expand Down
27 changes: 26 additions & 1 deletion test/engines.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
opencode: ["--auto"],
privacycode: ["--auto"],
claude: ["agents", "--dangerously-skip-permissions"],
codex: ["--dangerously-bypass-approvals-and-sandbox"],
codex: ["--dangerously-bypass-approvals-and-sandbox", "agents"],
gemini: ["--approval-mode=yolo"],
kimi: ["--yolo"], // no agents view — kimi has no agent list to land on
qwen: ["--approval-mode=yolo"],
Expand Down Expand Up @@ -136,6 +136,31 @@
});
}

test("Codex installs the managed runtime needed by its local agents daemon", () => {
if (process.platform === "win32") {
assert.deepEqual(ENGINES.codex.install, { cmd: "npm", args: ["install", "-g", "@openai/codex"] });
} else {
assert.equal(ENGINES.codex.install.cmd, "bash");
assert.deepEqual(ENGINES.codex.install.args.slice(0, 3), ["-o", "pipefail", "-c"]);
assert.match(ENGINES.codex.install.args[3], /https:\/\/chatgpt\.com\/codex\/install\.sh/);
assert.match(ENGINES.codex.install.args[3], /CODEX_NON_INTERACTIVE=1 sh$/);
}
assert.ok(ENGINES.codex.binDirs.includes(path.join(homedir(), ".local", "bin")));
});

test("Codex overview keeps the root bypass before agents and preserves native view options", async () => {
const nativeBin = tempDir();
writeEngine(nativeBin, "codex");
const extra = ["--no-alt-screen", "-C", "/tmp/project with spaces", "-c", 'model="gpt-6-astra"'];
const result = await run(["agents", "codex", ...extra], nativeBin);
assert.equal(result.status, 0);
assert.deepEqual(JSON.parse(result.stdout), [
"--dangerously-bypass-approvals-and-sandbox", "agents", ...extra,
]);
assert.deepEqual(ENGINES.codex.agentArgs, ["--dangerously-bypass-approvals-and-sandbox"]);
assert.deepEqual(ENGINES.codex.resume, ["resume", "--last"]);
});

test("bare engine launch remains a raw passthrough", async () => {
const nativeBin = tempDir();
mkdirSync(nativeBin, { recursive: true });
Expand Down
Loading