genaicode 2.41.1 → 2.42.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 +3 -7
- package/dist/agents/pack.d.ts +7 -0
- package/dist/agents/pack.js +35 -13
- package/dist/agents/pack.js.map +1 -1
- package/dist/cli/args.d.ts +20 -5
- package/dist/cli/args.js +109 -24
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/main.d.ts +4 -1
- package/dist/cli/main.js +169 -51
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/update.d.ts +16 -0
- package/dist/cli/update.js +79 -4
- package/dist/cli/update.js.map +1 -1
- package/dist/ui/index.js +84 -84
- package/docs/CHANGELOG.md +18 -0
- package/docs/cli.md +17 -6
- package/package.json +7 -2
package/dist/cli/main.d.ts
CHANGED
|
@@ -30,6 +30,8 @@ export interface CliEnvironment {
|
|
|
30
30
|
loadUi?(): Promise<UiModule>;
|
|
31
31
|
/** What `update` and the daily check use. Defaults to the npm registry and this package. */
|
|
32
32
|
updater?: Partial<UpdateDeps>;
|
|
33
|
+
/** How often `sessions --watch` looks again, in milliseconds. Default: 3 seconds. */
|
|
34
|
+
watchEveryMs?: number;
|
|
33
35
|
/** Shows a desktop notification (`notify test`). Default: `sendNotice()`. */
|
|
34
36
|
notify?(notice: Notice): boolean;
|
|
35
37
|
/** Runs the `--verify` command. Defaults to a shell in the task directory. */
|
|
@@ -44,6 +46,7 @@ export interface UiLaunch {
|
|
|
44
46
|
sessionTools?: readonly McpTool[];
|
|
45
47
|
towerInbox?: TowerInbox;
|
|
46
48
|
waitingOnStart?: boolean;
|
|
49
|
+
startupNotice?: string;
|
|
47
50
|
agent?: string;
|
|
48
51
|
cwd: string;
|
|
49
52
|
model?: string;
|
|
@@ -91,6 +94,6 @@ export declare const EXIT_OK = 0;
|
|
|
91
94
|
export declare const EXIT_FAILED = 1;
|
|
92
95
|
export declare const EXIT_USAGE = 2;
|
|
93
96
|
export declare const EXIT_ABORTED = 130;
|
|
94
|
-
export declare const helpText = "genaicode: run the coding-agent CLIs installed on this machine behind one interface.\n\nUsage:\n genaicode Chat with an agent in this terminal (same as \"chat\")\n genaicode chat [options] Chat with an agent in this terminal\n genaicode tower [chat options] Open the waiting queue and chat about sessions across projects\n genaicode ui [options] Chat with an agent in the browser (local server)\n genaicode agents [--json] List supported agents and whether each is installed\n genaicode sessions [options] List the sessions agents keep on this machine, by project\n genaicode sessions send <id> <text> Send a prompt to a waiting local session in its own agent\n genaicode sessions doctor Check that the agents' session stores still read as expected\n genaicode sessions mcp Serve the session index to an agent as MCP tools (stdio)\n genaicode sessions approve|deny <q> Answer a question a session asks (see \"hooks install --answer\")\n genaicode sessions archive <id...> Put sessions away (--stale: all left for 2 days or more)\n genaicode hooks [install|uninstall] Have agents report what their sessions do (default: status)\n genaicode notify [on|off|test] Desktop notification when a session asks for approval\n genaicode run [options] <prompt...> Run one task (reads the prompt from stdin if omitted)\n genaicode embed [options] [request] Have an agent add genaicode to the project here\n genaicode acp [options] Serve the Agent Client Protocol on stdin/stdout\n genaicode update [options] Update the installed genaicode command\n\nUpdate options (for the command scripts/install.sh installs; npx and npm -g update through npm):\n --check Only say whether a newer version is out\n --version <v> Install this version instead of the latest\n --auto on|off Check daily and update in the background (default: on)\n\nSessions options:\n -a, --agent <name> Only this agent's sessions\n --cloud Also Cursor Cloud Agents (needs CURSOR_API_KEY)\n -w, --waiting Only sessions waiting for you (approvals first), each with the\n command that continues it; the last 7 days unless --since says\n -C, --cwd <dir> Only sessions in this directory or below it\n --since <age> Only sessions active in the last 90m, 12h, 7d, 2w...\n -n, --limit <n> At most this many sessions, newest first (default 30)\n --json One JSON object per session\n --archived Also the sessions put away with \"sessions archive\"\n\n Each line ends with the session id: continue it with\n \"genaicode chat -a <agent> -C <dir> -r <id>\".\n\n \"sessions send <id> <prompt>\" streams the reply. It also reads the prompt from stdin.\n --detach returns when the agent starts; -a chooses the agent's store. --sandbox takes\n read-only, workspace-write or unrestricted. Without it the driver uses its own defaults.\n\n \"sessions archive <id...>\" hides sessions you will not come back to; \"sessions archive --stale\"\n (--older 5d, -a) does it for every one waiting for you or left half way for 2 days or more.\n The agents' own files stay as they are, and a session with any news comes back by itself;\n \"sessions unarchive <id...>\" brings one back. Kept in ~/.genaicode/archived.json.\n\n \"sessions doctor\" (-a, --since, --json, --api) checks each store: how many sessions it lists, how\n many have a prompt and a directory, whether the newest conversations open, and whether the\n agent's CLI is newer than the one the reader was checked with. It prints counts, never what\n was said, and exits 1 when a store reads differently than expected. With --api it also asks\n the agents that can be asked (Codex's app server) and compares; that starts the agent's own\n process, which keeps its state and logs in its home.\n\n \"sessions mcp\" (-a) serves sessions_projects, sessions_list, sessions_read and sessions_waiting\n on stdio. Any agent can use them to find open sessions and see which ones need your attention:\n \"claude mcp add sessions -- npx genaicode sessions mcp\". The agent you give it to reads what\n the other agents' sessions said. \"genaicode chat --sessions\" gives the same tools to the chat.\n In that chat, /waiting [project] refreshes the queue and /read <id> previews a conversation.\n\nHooks options:\n -a, --agent <name> Only this agent (claude, codex, gemini, copilot, cursor); default: all installed\n --answer With \"install\" (Claude Code): questions can also be answered here\n\n \"hooks install\" adds a hook to the agent's own user settings (~/.claude/settings.json,\n ~/.codex/hooks.json, ~/.gemini/settings.json, ~/.cursor/hooks.json,\n ~/.copilot/hooks/genaicode.json; Codex asks you to trust it under /hooks). The agent then tells genaicode\n when a session works, asks for approval or has finished its turn, so \"sessions\" and the\n browser's Sessions view show which ones need you. \"hooks uninstall\" takes it out again.\n\n \"hooks install --answer\" also holds each approval question of Claude Code open for up to 9\n minutes: Claude Code shows its dialog as always, and \"sessions --waiting\" or the browser's\n Sessions view can answer it too (\"sessions approve <q>\", \"sessions deny <q> -m <why>\").\n Whichever answer comes first counts.\n\nNotify options:\n --done With \"on\": also when a session finishes its turn\n\n \"notify on\" has the hooks show a desktop notification (macOS Notification Center, notify-send\n on Linux) when a session asks for approval: the agent, the project's directory name and the\n tool, nothing of what was said. It needs \"genaicode hooks install\". \"notify test\" shows one now.\n\nChat and UI options:\n -a, --agent <name> Agent to start with (default: the first installed one)\n --pack <lead:list> Start a pack, e.g. claude:codex,gemini. Follow its tasks in the chat\n In the tower, Ctrl+G opens approvals and proposed session messages\n --max-parallel <n> Delegated tasks that can run at once with --pack (default: 4)\n -C, --cwd <dir> Directory the agent works in (default: current directory)\n -m, --model <id> Model id passed to the agent CLI\n --effort <level> Reasoning effort, in the agent's own vocabulary\n -r, --resume <id> Continue this agent session\n --from <id> Take over a session of any agent in this directory (ids: \"genaicode\n sessions\"): its own agent resumes it, another one gets a handoff\n -y, --yes Approve every permission request the agent asks for\n --web (chat) Also open the session in the browser\n --port <n> Port for the browser UI, on 127.0.0.1 (default: a free port)\n --no-open (ui) Print the link instead of opening a browser\n --exit-with-stdin (ui) Stop when stdin closes, for apps that start the server\n --mcp <name=url> Give the agent this MCP server (streamable HTTP); repeatable.\n Only agents with MCP support (claude, codex, copilot, antigravity) take it\n --no-artifacts Do not give the agent the publish_artifact tool (pages, images and\n documents it shows in the chat)\n --sessions Give the agent read access to the session index. Ask what needs your\n attention across agents with sessions_waiting\n --max-tokens <n> Token budget for the whole session; prompts stop starting once it is used\n --max-cost <usd> Cost budget for the whole session, for agents that report cost\n --fallback <agents> Agents to switch to when the current one runs out (quota, sign-in,\n missing CLI, crash), e.g. --fallback codex,gemini. /fallback changes it\n\n Each prompt after the first continues the agent's session (claude, codex, cursor,\n opencode, copilot, antigravity). Prompts sent while the agent works wait in a queue. Type /help in\n the chat for commands. The terminal and the browser can show one session: /web in the\n chat opens it in the browser, and Enter in \"genaicode ui\" brings it into the terminal.\n\nRun options:\n -a, --agent <name> Agent to use (default: the first installed one, see \"agents\")\n -C, --cwd <dir> Directory the agent works in (default: current directory)\n -m, --model <id> Model id passed to the agent CLI\n --effort <level> Reasoning effort, in the agent's own vocabulary\n --max-turns <n> Turn limit, where the agent supports one\n -r, --resume <id> Continue the agent session with this id (printed after each run)\n --from <id> Continue a session of another agent: the agent gets a recap of it and\n the transcript to read (ids: \"genaicode sessions\")\n --timeout <sec> Stop the agent after this many seconds\n --verify <command> Shell command that checks the work; on failure its output goes\n back to the agent for another attempt\n --max-repairs <n> Repair attempts after a failed check (default 2)\n --max-tokens <n> Stop the agent past this many tokens (repairs included)\n --max-cost <usd> Stop the agent past this cost in US dollars, for agents that report cost\n --fallback <agents> Agents to run the task on when the agent runs out (quota, sign-in,\n missing CLI, crash), in order, e.g. --fallback codex,gemini\n --json Print agent events as JSON lines instead of text\n\nEmbed options:\n --print Print the agent's instructions instead of starting one\n --ui Follow the agent in the browser instead of this terminal\n -a, -C, -m, --effort, -y, --port, --no-open: as for chat and ui\n\n The agent reads the project and chooses how to wire genaicode in; [request] steers it,\n e.g. \"only the dev panel\". Without a terminal it runs headless like \"run\". The\n instructions also ship as a Claude Code skill: docs/skills/genaicode-embed/SKILL.md.\n\nACP options:\n -a, -m, --effort, -y: as for chat (the host can change agent, effort and approvals)\n\n For editors and other apps that speak ACP (https://agentclientprotocol.com): the app\n starts \"genaicode acp\", opens sessions in its own directories and sends prompts.\n\nThe agent uses its own login, billing, and permission defaults. GenAIcode adds no agent\nloop or sandbox of its own, and no prompts but embed's instructions.\nLibrary API: https://github.com/gtanczyk/genaicode#readme\n\nLooking for the legacy 1.x coding agent?\n Run it: npx genaicode@1\n Source: https://github.com/gtanczyk/genaicode/tree/1.x\n";
|
|
97
|
+
export declare const helpText = "genaicode: run the coding-agent CLIs installed on this machine behind one interface.\n\nUsage:\n genaicode Chat with an agent in this terminal (same as \"chat\")\n genaicode chat [options] Chat with an agent in this terminal\n genaicode tower [chat options] Open the waiting queue and chat about sessions across projects\n genaicode ui [options] Chat with an agent in the browser (local server)\n genaicode agents [--json] List supported agents and whether each is installed\n genaicode sessions [options] List the sessions agents keep on this machine, by project\n genaicode sessions send <id> <text> Send a prompt to a waiting local session in its own agent\n genaicode sessions doctor Check that the agents' session stores still read as expected\n genaicode sessions mcp Serve the session index to an agent as MCP tools (stdio)\n genaicode sessions approve|deny <q> Answer a question a session asks (see \"hooks install --answer\")\n genaicode sessions archive <id...> Put sessions away (--stale: all left for 2 days or more)\n genaicode hooks [install|uninstall] Have agents report what their sessions do (default: status)\n genaicode notify [on|off|test] Desktop notification when a session asks for approval\n genaicode run [options] <prompt...> Run one task (reads the prompt from stdin if omitted)\n genaicode embed [options] [request] Have an agent add genaicode to the project here\n genaicode acp [options] Serve the Agent Client Protocol on stdin/stdout\n genaicode install [options] Install \"genaicode\" as a command that updates itself\n genaicode update [options] Update the installed genaicode command\n\nInstall options (macOS, Linux; same as scripts/install.sh):\n --version <v> Install this version (default: the one running, e.g. via npx)\n --bin-dir <dir> Where the command goes (default: ~/.local/bin)\n --force Replace a \"genaicode\" there that the installer did not write\n\nUpdate options (for the command scripts/install.sh installs; npx and npm -g update through npm):\n --check Only say whether a newer version is out\n --version <v> Install this version instead of the latest\n --auto on|off Check daily and update in the background (default: on)\n\nSessions options:\n -a, --agent <name> Only this agent's sessions\n --cloud Also Cursor Cloud Agents (needs CURSOR_API_KEY)\n -w, --waiting Only sessions waiting for you (approvals first), each with the\n command that continues it; the last 7 days unless --since says\n -C, --cwd <dir> Only sessions in this directory or below it\n --since <age> Only sessions active in the last 90m, 12h, 7d, 2w...\n -n, --limit <n> At most this many sessions, newest first (default 30)\n --json One JSON object per session\n --watch With --waiting --json: stay open and print {\"sessions\":[...]} as one\n line whenever what waits changes (--exit-with-stdin: until stdin closes)\n --archived Also the sessions put away with \"sessions archive\"\n\n Each line ends with the session id: continue it with\n \"genaicode chat -a <agent> -C <dir> -r <id>\".\n\n \"sessions send <id> <prompt>\" streams the reply. It also reads the prompt from stdin.\n --detach returns when the agent starts; -a chooses the agent's store. --sandbox takes\n read-only, workspace-write or unrestricted. Without it the driver uses its own defaults.\n\n \"sessions archive <id...>\" hides sessions you will not come back to; \"sessions archive --stale\"\n (--older 5d, -a) does it for every one waiting for you or left half way for 2 days or more.\n The agents' own files stay as they are, and a session with any news comes back by itself;\n \"sessions unarchive <id...>\" brings one back. Kept in ~/.genaicode/archived.json.\n\n \"sessions doctor\" (-a, --since, --json, --api) checks each store: how many sessions it lists, how\n many have a prompt and a directory, whether the newest conversations open, and whether the\n agent's CLI is newer than the one the reader was checked with. It prints counts, never what\n was said, and exits 1 when a store reads differently than expected. With --api it also asks\n the agents that can be asked (Codex's app server) and compares; that starts the agent's own\n process, which keeps its state and logs in its home.\n\n \"sessions mcp\" (-a) serves sessions_projects, sessions_list, sessions_read and sessions_waiting\n on stdio. Any agent can use them to find open sessions and see which ones need your attention:\n \"claude mcp add sessions -- npx genaicode sessions mcp\". The agent you give it to reads what\n the other agents' sessions said. \"genaicode chat --sessions\" gives the same tools to the chat.\n In that chat, /waiting [project] refreshes the queue and /read <id> previews a conversation.\n\nHooks options:\n -a, --agent <name> Only this agent (claude, codex, gemini, copilot, cursor); default: all installed\n --answer With \"install\" (Claude Code): questions can also be answered here\n\n \"hooks install\" adds a hook to the agent's own user settings (~/.claude/settings.json,\n ~/.codex/hooks.json, ~/.gemini/settings.json, ~/.cursor/hooks.json,\n ~/.copilot/hooks/genaicode.json; Codex asks you to trust it under /hooks). The agent then tells genaicode\n when a session works, asks for approval or has finished its turn, so \"sessions\" and the\n browser's Sessions view show which ones need you. \"hooks uninstall\" takes it out again.\n\n \"hooks install --answer\" also holds each approval question of Claude Code open for up to 9\n minutes: Claude Code shows its dialog as always, and \"sessions --waiting\" or the browser's\n Sessions view can answer it too (\"sessions approve <q>\", \"sessions deny <q> -m <why>\").\n Whichever answer comes first counts.\n\nNotify options:\n --done With \"on\": also when a session finishes its turn\n\n \"notify on\" has the hooks show a desktop notification (macOS Notification Center, notify-send\n on Linux) when a session asks for approval: the agent, the project's directory name and the\n tool, nothing of what was said. It needs \"genaicode hooks install\". \"notify test\" shows one now.\n\nChat and UI options:\n -a, --agent <name> Agent to start with (default: the first installed one; with --pack, the lead)\n --pack [lead:list] Start a pack: omit the value to use all installed agents, or name them\n explicitly, e.g. claude:codex,gemini. Follow its tasks in the chat; in\n the tower, Ctrl+G opens approvals and proposed session messages\n --max-parallel <n> Delegated tasks that can run at once with --pack (default: 4)\n -C, --cwd <dir> Directory the agent works in (default: current directory)\n -m, --model <id> Model id passed to the agent CLI\n --effort <level> Reasoning effort, in the agent's own vocabulary\n -r, --resume <id> Continue this agent session\n --from <id> Take over a session of any agent in this directory (ids: \"genaicode\n sessions\"): its own agent resumes it, another one gets a handoff\n -y, --yes Approve every permission request the agent asks for\n --web (chat) Also open the session in the browser\n --port <n> Port for the browser UI, on 127.0.0.1 (default: a free port)\n --no-open (ui) Print the link instead of opening a browser\n --exit-with-stdin (ui) Stop when stdin closes, for apps that start the server\n --mcp <name=url> Give the agent this MCP server (streamable HTTP); repeatable.\n Only agents with MCP support (claude, codex, copilot, antigravity) take it\n --no-artifacts Do not give the agent the publish_artifact tool (pages, images and\n documents it shows in the chat)\n --sessions Give the agent read access to the session index. Ask what needs your\n attention across agents with sessions_waiting\n --max-tokens <n> Token budget for the whole session; prompts stop starting once it is used\n --max-cost <usd> Cost budget for the whole session, for agents that report cost\n --fallback <agents> Agents to switch to when the current one runs out (quota, sign-in,\n missing CLI, crash), e.g. --fallback codex,gemini. /fallback changes it\n\n Each prompt after the first continues the agent's session (claude, codex, cursor,\n opencode, copilot, antigravity). Prompts sent while the agent works wait in a queue. Type /help in\n the chat for commands. The terminal and the browser can show one session: /web in the\n chat opens it in the browser, and Enter in \"genaicode ui\" brings it into the terminal.\n\nRun options:\n -a, --agent <name> Agent to use (default: the first installed one, see \"agents\")\n -C, --cwd <dir> Directory the agent works in (default: current directory)\n -m, --model <id> Model id passed to the agent CLI\n --effort <level> Reasoning effort, in the agent's own vocabulary\n --max-turns <n> Turn limit, where the agent supports one\n -r, --resume <id> Continue the agent session with this id (printed after each run)\n --from <id> Continue a session of another agent: the agent gets a recap of it and\n the transcript to read (ids: \"genaicode sessions\")\n --timeout <sec> Stop the agent after this many seconds\n --verify <command> Shell command that checks the work; on failure its output goes\n back to the agent for another attempt\n --max-repairs <n> Repair attempts after a failed check (default 2)\n --max-tokens <n> Stop the agent past this many tokens (repairs included)\n --max-cost <usd> Stop the agent past this cost in US dollars, for agents that report cost\n --fallback <agents> Agents to run the task on when the agent runs out (quota, sign-in,\n missing CLI, crash), in order, e.g. --fallback codex,gemini\n --json Print agent events as JSON lines instead of text\n\nEmbed options:\n --print Print the agent's instructions instead of starting one\n --ui Follow the agent in the browser instead of this terminal\n -a, -C, -m, --effort, -y, --port, --no-open: as for chat and ui\n\n The agent reads the project and chooses how to wire genaicode in; [request] steers it,\n e.g. \"only the dev panel\". Without a terminal it runs headless like \"run\". The\n instructions also ship as a Claude Code skill: docs/skills/genaicode-embed/SKILL.md.\n\nACP options:\n -a, -m, --effort, -y: as for chat (the host can change agent, effort and approvals)\n\n For editors and other apps that speak ACP (https://agentclientprotocol.com): the app\n starts \"genaicode acp\", opens sessions in its own directories and sends prompts.\n\nThe agent uses its own login, billing, and permission defaults. GenAIcode adds no agent\nloop or sandbox of its own, and no prompts but embed's instructions.\nLibrary API: https://github.com/gtanczyk/genaicode#readme\n\nLooking for the legacy 1.x coding agent?\n Run it: npx genaicode@1\n Source: https://github.com/gtanczyk/genaicode/tree/1.x\n";
|
|
95
98
|
/** Run the CLI and return its exit code. */
|
|
96
99
|
export declare function main(cli: CliEnvironment): Promise<number>;
|
package/dist/cli/main.js
CHANGED
|
@@ -27,7 +27,7 @@ import { serveAcp } from '../acp/server.js';
|
|
|
27
27
|
import { parseCli, UsageError } from './args.js';
|
|
28
28
|
import { embedPrompt, embedRequest, readEmbedInstructions } from './embed.js';
|
|
29
29
|
import { createRenderer, describeResult } from './render.js';
|
|
30
|
-
import { autoUpdate, backgroundUpdate, defaultUpdateDeps, findInstall,
|
|
30
|
+
import { autoUpdate, backgroundUpdate, defaultUpdateDeps, findInstall, installCommand, shadowingCommand, registerRun, selfInstall, setAutoUpdate, stableCliPath, updateInstall, } from './update.js';
|
|
31
31
|
export const EXIT_OK = 0;
|
|
32
32
|
export const EXIT_FAILED = 1;
|
|
33
33
|
export const EXIT_USAGE = 2;
|
|
@@ -51,8 +51,14 @@ Usage:
|
|
|
51
51
|
genaicode run [options] <prompt...> Run one task (reads the prompt from stdin if omitted)
|
|
52
52
|
genaicode embed [options] [request] Have an agent add genaicode to the project here
|
|
53
53
|
genaicode acp [options] Serve the Agent Client Protocol on stdin/stdout
|
|
54
|
+
genaicode install [options] Install "genaicode" as a command that updates itself
|
|
54
55
|
genaicode update [options] Update the installed genaicode command
|
|
55
56
|
|
|
57
|
+
Install options (macOS, Linux; same as scripts/install.sh):
|
|
58
|
+
--version <v> Install this version (default: the one running, e.g. via npx)
|
|
59
|
+
--bin-dir <dir> Where the command goes (default: ~/.local/bin)
|
|
60
|
+
--force Replace a "genaicode" there that the installer did not write
|
|
61
|
+
|
|
56
62
|
Update options (for the command scripts/install.sh installs; npx and npm -g update through npm):
|
|
57
63
|
--check Only say whether a newer version is out
|
|
58
64
|
--version <v> Install this version instead of the latest
|
|
@@ -67,6 +73,8 @@ Sessions options:
|
|
|
67
73
|
--since <age> Only sessions active in the last 90m, 12h, 7d, 2w...
|
|
68
74
|
-n, --limit <n> At most this many sessions, newest first (default 30)
|
|
69
75
|
--json One JSON object per session
|
|
76
|
+
--watch With --waiting --json: stay open and print {"sessions":[...]} as one
|
|
77
|
+
line whenever what waits changes (--exit-with-stdin: until stdin closes)
|
|
70
78
|
--archived Also the sessions put away with "sessions archive"
|
|
71
79
|
|
|
72
80
|
Each line ends with the session id: continue it with
|
|
@@ -117,9 +125,10 @@ Notify options:
|
|
|
117
125
|
tool, nothing of what was said. It needs "genaicode hooks install". "notify test" shows one now.
|
|
118
126
|
|
|
119
127
|
Chat and UI options:
|
|
120
|
-
-a, --agent <name> Agent to start with (default: the first installed one)
|
|
121
|
-
--pack
|
|
122
|
-
|
|
128
|
+
-a, --agent <name> Agent to start with (default: the first installed one; with --pack, the lead)
|
|
129
|
+
--pack [lead:list] Start a pack: omit the value to use all installed agents, or name them
|
|
130
|
+
explicitly, e.g. claude:codex,gemini. Follow its tasks in the chat; in
|
|
131
|
+
the tower, Ctrl+G opens approvals and proposed session messages
|
|
123
132
|
--max-parallel <n> Delegated tasks that can run at once with --pack (default: 4)
|
|
124
133
|
-C, --cwd <dir> Directory the agent works in (default: current directory)
|
|
125
134
|
-m, --model <id> Model id passed to the agent CLI
|
|
@@ -207,7 +216,7 @@ export async function main(cli) {
|
|
|
207
216
|
command = { kind: 'chat', approveAll: false, open: false, web: false, mcpServers: [] };
|
|
208
217
|
}
|
|
209
218
|
const updater = { ...defaultUpdateDeps(cli.env), ...cli.updater };
|
|
210
|
-
const quick = ['help', 'version', 'update', 'self-install'].includes(command.kind);
|
|
219
|
+
const quick = ['help', 'version', 'update', 'self-install', 'install'].includes(command.kind);
|
|
211
220
|
// Machine-readable output and protocol servers get no banner and start no updater.
|
|
212
221
|
const machine = command.kind === 'acp' || command.kind === 'sessions-mcp' || ('json' in command && command.json);
|
|
213
222
|
if (!quick && !machine)
|
|
@@ -260,6 +269,8 @@ function dispatch(cli, command, agents, updater) {
|
|
|
260
269
|
return runUpdate(cli, updater, command);
|
|
261
270
|
case 'self-install':
|
|
262
271
|
return runSelfInstall(cli, updater, command);
|
|
272
|
+
case 'install':
|
|
273
|
+
return runInstall(cli, updater, command);
|
|
263
274
|
}
|
|
264
275
|
}
|
|
265
276
|
async function runUpdate(cli, deps, options) {
|
|
@@ -271,7 +282,7 @@ async function runUpdate(cli, deps, options) {
|
|
|
271
282
|
if (!install) {
|
|
272
283
|
cli.stderr.write(`This genaicode runs from ${deps.packageRoot}, not from the installed command.\n` +
|
|
273
284
|
'Update it with npm ("npm install -g genaicode@latest", or bump it in your project), ' +
|
|
274
|
-
`or install the command, which updates itself:\n
|
|
285
|
+
`or install the command, which updates itself:\n npx genaicode install\n`);
|
|
275
286
|
return EXIT_FAILED;
|
|
276
287
|
}
|
|
277
288
|
if (options.auto !== undefined) {
|
|
@@ -311,18 +322,7 @@ async function runUpdate(cli, deps, options) {
|
|
|
311
322
|
}
|
|
312
323
|
function runSelfInstall(cli, deps, options) {
|
|
313
324
|
try {
|
|
314
|
-
|
|
315
|
-
packageRoot: deps.packageRoot,
|
|
316
|
-
binDir: options.binDir,
|
|
317
|
-
force: options.force,
|
|
318
|
-
env: cli.env,
|
|
319
|
-
});
|
|
320
|
-
cli.stdout.write(`Installed genaicode ${result.version}: ${result.shim}\n`);
|
|
321
|
-
if (!result.onPath) {
|
|
322
|
-
const dir = dirname(result.shim);
|
|
323
|
-
cli.stdout.write(`${dir} is not on your PATH. Add it to your shell profile (~/.zshrc, ~/.bashrc):\n` +
|
|
324
|
-
` export PATH="${dir}:$PATH"\n`);
|
|
325
|
-
}
|
|
325
|
+
reportInstall(cli, selfInstall({ packageRoot: deps.packageRoot, binDir: options.binDir, force: options.force, env: cli.env }));
|
|
326
326
|
return EXIT_OK;
|
|
327
327
|
}
|
|
328
328
|
catch (error) {
|
|
@@ -330,6 +330,32 @@ function runSelfInstall(cli, deps, options) {
|
|
|
330
330
|
return EXIT_FAILED;
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
|
+
async function runInstall(cli, deps, options) {
|
|
334
|
+
try {
|
|
335
|
+
cli.stderr.write('Installing genaicode with npm (no install scripts)...\n');
|
|
336
|
+
const result = await installCommand(deps, options);
|
|
337
|
+
reportInstall(cli, result);
|
|
338
|
+
const shadow = shadowingCommand(cli.env, dirname(result.shim));
|
|
339
|
+
if (shadow) {
|
|
340
|
+
cli.stdout.write(`Note: "genaicode" on your PATH is ${shadow}, which comes before ${dirname(result.shim)}.\n` +
|
|
341
|
+
'Remove it ("npm uninstall -g genaicode") or put that directory first on PATH.\n');
|
|
342
|
+
}
|
|
343
|
+
cli.stdout.write('Run "genaicode" to start. It checks for updates once a day; "genaicode update --auto off" turns that off.\n');
|
|
344
|
+
return EXIT_OK;
|
|
345
|
+
}
|
|
346
|
+
catch (error) {
|
|
347
|
+
cli.stderr.write(`Install failed: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
348
|
+
return EXIT_FAILED;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
function reportInstall(cli, result) {
|
|
352
|
+
cli.stdout.write(`Installed genaicode ${result.version}: ${result.shim}\n`);
|
|
353
|
+
if (!result.onPath) {
|
|
354
|
+
const dir = dirname(result.shim);
|
|
355
|
+
cli.stdout.write(`${dir} is not on your PATH. Add it to your shell profile (~/.zshrc, ~/.bashrc):\n` +
|
|
356
|
+
` export PATH="${dir}:$PATH"\n`);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
333
359
|
async function runAcp(cli, agents, options) {
|
|
334
360
|
if (options.agent && !agents.some((agent) => agent.name === options.agent)) {
|
|
335
361
|
cli.stderr.write(`Unknown agent "${options.agent}". Known agents: ${agents.map((a) => a.name).join(', ')}.\n`);
|
|
@@ -387,11 +413,10 @@ async function runUi(cli, agents, options, extra = {}) {
|
|
|
387
413
|
const indexed = agentSessionSources(agents);
|
|
388
414
|
let sessionAgents = agents;
|
|
389
415
|
let towerInbox;
|
|
416
|
+
let startupNotice;
|
|
390
417
|
let initial = options.agent;
|
|
391
418
|
if (options.pack) {
|
|
392
419
|
const spec = options.pack;
|
|
393
|
-
if (!knownAgents(cli, agents, [spec.lead, ...spec.members], '--pack'))
|
|
394
|
-
return EXIT_USAGE;
|
|
395
420
|
if (options.mcpServers.some((server) => server.name === 'pack')) {
|
|
396
421
|
cli.stderr.write('--pack already provides an MCP server named "pack". Give the --mcp server another name.\n');
|
|
397
422
|
return EXIT_USAGE;
|
|
@@ -405,10 +430,47 @@ async function runUi(cli, agents, options, extra = {}) {
|
|
|
405
430
|
return agent;
|
|
406
431
|
});
|
|
407
432
|
const member = (name) => packAgents.find((agent) => agent.name === name);
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
433
|
+
let lead;
|
|
434
|
+
let members;
|
|
435
|
+
if ('auto' in spec) {
|
|
436
|
+
const installed = detectAgents(packAgents, cli.env)
|
|
437
|
+
.filter((found) => found.path !== null)
|
|
438
|
+
.map((found) => found.agent);
|
|
439
|
+
if (options.agent !== undefined) {
|
|
440
|
+
if (!knownAgents(cli, agents, [options.agent], '--agent'))
|
|
441
|
+
return EXIT_USAGE;
|
|
442
|
+
lead = member(options.agent);
|
|
443
|
+
}
|
|
444
|
+
else {
|
|
445
|
+
const picked = installed.find((agent) => agent.capabilities.mcp);
|
|
446
|
+
if (!picked) {
|
|
447
|
+
const mcpNames = packAgents
|
|
448
|
+
.filter((agent) => agent.capabilities.mcp)
|
|
449
|
+
.map((agent) => agent.name)
|
|
450
|
+
.join(', ');
|
|
451
|
+
const hint = mcpNames ? ` (needs one of: ${mcpNames})` : '';
|
|
452
|
+
cli.stderr.write(`No installed agent with MCP support found for --pack${hint}.\n`);
|
|
453
|
+
return EXIT_USAGE;
|
|
454
|
+
}
|
|
455
|
+
lead = picked;
|
|
456
|
+
}
|
|
457
|
+
if (!lead.capabilities.mcp) {
|
|
458
|
+
cli.stderr.write(`Agent "${lead.name}" cannot lead a pack because it does not support MCP.\n`);
|
|
459
|
+
return EXIT_USAGE;
|
|
460
|
+
}
|
|
461
|
+
// Every installed agent joins the pack (including the lead).
|
|
462
|
+
members = installed.includes(lead) ? installed : [lead, ...installed];
|
|
463
|
+
startupNotice = `Pack: ${lead.name} leads · members: ${members.map((agent) => agent.name).join(', ')}.`;
|
|
464
|
+
}
|
|
465
|
+
else {
|
|
466
|
+
if (!knownAgents(cli, agents, [spec.lead, ...spec.members], '--pack'))
|
|
467
|
+
return EXIT_USAGE;
|
|
468
|
+
lead = member(spec.lead);
|
|
469
|
+
if (!lead.capabilities.mcp) {
|
|
470
|
+
cli.stderr.write(`Agent "${lead.name}" cannot lead a pack because it does not support MCP.\n`);
|
|
471
|
+
return EXIT_USAGE;
|
|
472
|
+
}
|
|
473
|
+
members = spec.members.map(member);
|
|
412
474
|
}
|
|
413
475
|
if (options.sessions) {
|
|
414
476
|
sessionAgents = packAgents;
|
|
@@ -416,7 +478,7 @@ async function runUi(cli, agents, options, extra = {}) {
|
|
|
416
478
|
}
|
|
417
479
|
const team = pack({
|
|
418
480
|
lead,
|
|
419
|
-
members
|
|
481
|
+
members,
|
|
420
482
|
maxParallel: spec.maxParallel,
|
|
421
483
|
sessionProposalTool: towerInbox?.proposalTool,
|
|
422
484
|
});
|
|
@@ -457,6 +519,7 @@ async function runUi(cli, agents, options, extra = {}) {
|
|
|
457
519
|
...(tools ? { sessionTools: tools } : {}),
|
|
458
520
|
...(towerInbox ? { towerInbox } : {}),
|
|
459
521
|
...(options.kind === 'tower' ? { waitingOnStart: true } : {}),
|
|
522
|
+
...(startupNotice ? { startupNotice } : {}),
|
|
460
523
|
agent: initial,
|
|
461
524
|
cwd: resolve(cli.cwd, options.cwd ?? '.'),
|
|
462
525
|
model: options.model,
|
|
@@ -646,6 +709,55 @@ async function manageHooks(cli, command, updater) {
|
|
|
646
709
|
}
|
|
647
710
|
return failed ? EXIT_FAILED : EXIT_OK;
|
|
648
711
|
}
|
|
712
|
+
const WATCH_EVERY_MS = 3000;
|
|
713
|
+
/**
|
|
714
|
+
* `sessions --waiting --json --watch`: one line `{"sessions":[...]}` now, and again whenever what
|
|
715
|
+
* waits changes. For a program that shows it (the desktop app's menu bar): it reads lines instead
|
|
716
|
+
* of starting the CLI again for every look. Ends on Ctrl-C, or with its stdin when asked to.
|
|
717
|
+
*/
|
|
718
|
+
async function watchWaiting(cli, exitWithStdin, look, withAsks) {
|
|
719
|
+
const stop = new AbortController();
|
|
720
|
+
const end = () => stop.abort();
|
|
721
|
+
cli.signal?.addEventListener('abort', end, { once: true });
|
|
722
|
+
if (cli.signal?.aborted)
|
|
723
|
+
end();
|
|
724
|
+
const input = exitWithStdin ? (cli.input ?? process.stdin) : undefined;
|
|
725
|
+
input?.on('end', end).on('close', end).on('error', end).resume();
|
|
726
|
+
let last;
|
|
727
|
+
let said = '';
|
|
728
|
+
try {
|
|
729
|
+
while (!stop.signal.aborted) {
|
|
730
|
+
const { sessions, questions, errors } = await look();
|
|
731
|
+
if (stop.signal.aborted)
|
|
732
|
+
break;
|
|
733
|
+
// A store that cannot be read is said once, not on every look.
|
|
734
|
+
const trouble = errors.map((error) => `${error.source}: ${error.message}\n`).join('');
|
|
735
|
+
if (trouble !== said)
|
|
736
|
+
cli.stderr.write(trouble);
|
|
737
|
+
said = trouble;
|
|
738
|
+
const line = JSON.stringify({ sessions: sessions.map((session) => withAsks(session, questions)) });
|
|
739
|
+
if (line !== last)
|
|
740
|
+
cli.stdout.write(`${line}\n`);
|
|
741
|
+
last = line;
|
|
742
|
+
// Its own abort listener goes with the timer, so a watch left open for days keeps none.
|
|
743
|
+
await new Promise((done) => {
|
|
744
|
+
const wake = () => {
|
|
745
|
+
clearTimeout(timer);
|
|
746
|
+
stop.signal.removeEventListener('abort', wake);
|
|
747
|
+
done();
|
|
748
|
+
};
|
|
749
|
+
const timer = setTimeout(wake, cli.watchEveryMs ?? WATCH_EVERY_MS);
|
|
750
|
+
stop.signal.addEventListener('abort', wake);
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
finally {
|
|
755
|
+
cli.signal?.removeEventListener('abort', end);
|
|
756
|
+
// Paused again, or a stdin still open would keep the process alive after Ctrl-C.
|
|
757
|
+
input?.off('end', end).off('close', end).off('error', end).pause();
|
|
758
|
+
}
|
|
759
|
+
return EXIT_OK;
|
|
760
|
+
}
|
|
649
761
|
async function showSessions(cli, agents, command) {
|
|
650
762
|
// `--cloud` adds the vendor clouds the environment has a key for.
|
|
651
763
|
const cloud = [];
|
|
@@ -661,37 +773,43 @@ async function showSessions(cli, agents, command) {
|
|
|
661
773
|
cli.stderr.write(`No session store for agent "${command.agent}".\n`);
|
|
662
774
|
return EXIT_USAGE;
|
|
663
775
|
}
|
|
664
|
-
const now = Date.now();
|
|
665
776
|
// What waits is picked from everything listed, so the limit comes after; a week back by default.
|
|
666
777
|
const sinceMs = command.sinceMs ?? (command.waiting ? WAITING_SINCE_MS : undefined);
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
778
|
+
const look = async () => {
|
|
779
|
+
const now = Date.now();
|
|
780
|
+
// Archived sessions may take places in the listing: as many more are read, and left out after.
|
|
781
|
+
const extra = command.archived || command.waiting ? 0 : (await readArchive(cli.env)).size;
|
|
782
|
+
const listing = await listSessions(sources, {
|
|
783
|
+
...(command.waiting ? {} : { limit: command.limit + extra }),
|
|
784
|
+
env: cli.env,
|
|
785
|
+
...(command.cwd !== undefined ? { cwd: resolve(cli.cwd, command.cwd) } : {}),
|
|
786
|
+
...(sinceMs !== undefined ? { since: now - sinceMs } : {}),
|
|
787
|
+
...(cli.signal ? { signal: cli.signal } : {}),
|
|
788
|
+
});
|
|
789
|
+
// Archived sessions stay out unless asked for.
|
|
790
|
+
const listed = command.archived ? listing.sessions : listing.sessions.filter((session) => !session.archived);
|
|
791
|
+
const sessions = (command.waiting ? waitingSessions(listed) : listed).slice(0, command.limit);
|
|
792
|
+
const questions = command.waiting ? await pendingAsks(cli.env) : [];
|
|
793
|
+
return { now, sessions, questions, errors: listing.errors, hidden: listing.sessions.length - listed.length };
|
|
794
|
+
};
|
|
795
|
+
// `--waiting`: with the questions a session holds open for the tower (`hooks install --answer`).
|
|
796
|
+
const withAsks = (session, questions) => {
|
|
797
|
+
const asks = asksForSession(questions, session).map(({ id, tool, preview, at }) => ({
|
|
798
|
+
id,
|
|
799
|
+
...(tool ? { tool } : {}),
|
|
800
|
+
...(preview ? { preview } : {}),
|
|
801
|
+
at,
|
|
802
|
+
}));
|
|
803
|
+
return asks.length ? { ...session, asks } : session;
|
|
804
|
+
};
|
|
805
|
+
if (command.watch)
|
|
806
|
+
return watchWaiting(cli, command.exitWithStdin === true, look, withAsks);
|
|
807
|
+
const { now, sessions, questions, errors, hidden } = await look();
|
|
681
808
|
for (const error of errors)
|
|
682
809
|
cli.stderr.write(`${error.source}: ${error.message}\n`);
|
|
683
|
-
const questions = command.waiting ? await pendingAsks(cli.env) : [];
|
|
684
810
|
if (command.json) {
|
|
685
|
-
for (const session of sessions)
|
|
686
|
-
|
|
687
|
-
const asks = asksForSession(questions, session).map(({ id, tool, preview, at }) => ({
|
|
688
|
-
id,
|
|
689
|
-
...(tool ? { tool } : {}),
|
|
690
|
-
...(preview ? { preview } : {}),
|
|
691
|
-
at,
|
|
692
|
-
}));
|
|
693
|
-
cli.stdout.write(`${JSON.stringify(asks.length ? { ...session, asks } : session)}\n`);
|
|
694
|
-
}
|
|
811
|
+
for (const session of sessions)
|
|
812
|
+
cli.stdout.write(`${JSON.stringify(withAsks(session, questions))}\n`);
|
|
695
813
|
return EXIT_OK;
|
|
696
814
|
}
|
|
697
815
|
if (command.waiting)
|