@agent-api/cli 0.4.13 → 0.4.15

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 CHANGED
@@ -64,6 +64,10 @@ Set `AGENT_TUI_UPDATE_CHECK=0` to disable the startup update notice.
64
64
  ```bash
65
65
  agent-tui
66
66
  agent-api
67
+ agent-api run
68
+ agent-api update
69
+ agent-api version
70
+ agent-api help
67
71
  agent-api auth login
68
72
  agent-api profiles list
69
73
  agent-api agent chat
@@ -71,9 +75,13 @@ agent-api workdir status
71
75
  agent-api doctor
72
76
  ```
73
77
 
78
+ No command defaults to the interactive `run` command. If you provide a bare
79
+ first argument, it must be a command name. Local workdirs are explicit: use
80
+ `agent-tui -w <path>`, `agent-tui run <path>`, or `agent-tui run --workdir <path>`.
81
+
74
82
  ## Interactive Workbench
75
83
 
76
- Launch the first-class TUI from your current directory:
84
+ Launch the first-class TUI without an initial local workdir:
77
85
 
78
86
  ```bash
79
87
  agent-tui
@@ -82,12 +90,13 @@ agent-tui
82
90
  Open a specific local workdir and expose local tools to the agent:
83
91
 
84
92
  ```bash
85
- agent-tui .
86
- agent-tui ./my-workdir
87
- agent-tui /absolute/path/to/my-workdir
93
+ agent-tui -w .
94
+ agent-tui run .
95
+ agent-tui run ./my-workdir
96
+ agent-tui --workdir /absolute/path/to/my-workdir
88
97
  ```
89
98
 
90
- The workdir argument must point to an existing directory. When provided, the
99
+ The workdir option must point to an existing directory. When provided, the
91
100
  workbench automatically turns on local workdir and shell tools in approval mode.
92
101
  CLI chat runs can also expose local `SKILL.md` directories and opt into memory:
93
102
 
@@ -125,9 +134,8 @@ Inside the workbench, configure the agent run dynamically:
125
134
  /switch <name> switch conversation handle
126
135
  ```
127
136
 
128
- The current working directory is loaded as the local workdir. Local workdir
129
- tools are only exposed to the model when you enable local context with
130
- `/context` or start with `--workdir`.
137
+ Local workdir tools are only exposed to the model when you start with `-w`,
138
+ `--workdir`, `run [workdir]`, or enable local context with `/context`.
131
139
 
132
140
  ## Authentication
133
141
 
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { stat } from "node:fs/promises";
4
4
  import { resolve } from "node:path";
5
5
  import { render } from "ink";
6
6
  import React from "react";
7
- import { activeProfile, configureAgentAppRuntime, conversationSummary, deleteConversation, deleteProfile, getConversation, listConversations, listProfiles, loadConfig, loadConversationConfiguration, loginWithAPIKey, loginWithBrowser, normalizeChatOptions, openWorkdir, profileSummary, redactSecret, resolveRuntimeProfile, runAgent, runtime, useProfile, } from "@agent-api/app-engine/core";
7
+ import { activeProfile, configureAgentAppRuntime, conversationSummary, deleteConversation, deleteProfile, checkForUpdate, formatUpdateNotice, getConversation, installUpdate, listConversations, listProfiles, loadConfig, loadConversationConfiguration, loginWithAPIKey, loginWithBrowser, normalizeChatOptions, openWorkdir, profileSummary, redactSecret, resolveRuntimeProfile, runAgent, runtime, useProfile, } from "@agent-api/app-engine/core";
8
8
  import { ChatApp } from "./tui/chat.js";
9
9
  import { cliAuthor, cliName, cliVersion, legacyCliName } from "./runtime.js";
10
10
  configureAgentAppRuntime({
@@ -19,20 +19,59 @@ program
19
19
  .alias("agentsway")
20
20
  .alias("agent-tui")
21
21
  .description("First-class command line interface for Agent API")
22
- .argument("[workdir]", "local workdir to open and expose to the agent")
22
+ .option("-w, --workdir <path>", "shortcut for run with a local workdir")
23
+ .option("--update", "check for and install a CLI update, then exit")
23
24
  .version(cliVersion)
24
25
  .showHelpAfterError()
25
- .showSuggestionAfterError();
26
- program.action(async (workdir) => {
27
- const launchWorkdir = workdir ? await validateLaunchWorkdir(workdir) : undefined;
28
- if (!process.stdin.isTTY) {
29
- program.help();
26
+ .showSuggestionAfterError()
27
+ .addHelpText("after", `
28
+ Command contract:
29
+ No command defaults to "run". A bare first argument is always a command.
30
+ Use "run [workdir]" or "-w, --workdir <path>" to open a local workdir.
31
+
32
+ Examples:
33
+ $ agent-tui
34
+ $ agent-tui -w .
35
+ $ agent-tui run .
36
+ $ agent-tui update
37
+ $ agent-tui agent chat "Summarize this repo" --workdir .
38
+ `);
39
+ program.action(async (options) => {
40
+ if (options.update) {
41
+ await runTopLevelUpdate({ checkOnly: false });
30
42
  return;
31
43
  }
32
- const options = normalizeChatOptions([], launchWorkdir ? { workdir: launchWorkdir } : {});
33
- const app = render(React.createElement(ChatApp, { options }));
34
- await app.waitUntilExit();
35
- clearTerminalAfterTUI();
44
+ await runWorkbench(options);
45
+ });
46
+ program
47
+ .command("run")
48
+ .description("Open the interactive workbench")
49
+ .argument("[workdir]", "local workdir to open and expose to the agent")
50
+ .addHelpText("after", `
51
+ Examples:
52
+ $ agent-tui run
53
+ $ agent-tui run .
54
+ $ agent-tui -w .
55
+ `)
56
+ .action(async function (workdir) {
57
+ const rootOptions = this.parent?.opts() ?? {};
58
+ await runWorkbench({ workdir: resolveRunWorkdir(workdir, rootOptions.workdir) });
59
+ });
60
+ program
61
+ .command("update")
62
+ .description("Check for and install a CLI update")
63
+ .addHelpText("after", `
64
+ Checks npm for the latest ${cliName} package and installs it globally when an
65
+ update is available. Equivalent shortcut: agent-tui --update
66
+ `)
67
+ .action(async () => {
68
+ await runTopLevelUpdate({ checkOnly: false });
69
+ });
70
+ program
71
+ .command("version")
72
+ .description("Print the CLI version")
73
+ .action(() => {
74
+ console.log(cliVersion);
36
75
  });
37
76
  program
38
77
  .command("auth")
@@ -80,6 +119,7 @@ program
80
119
  platform: process.platform,
81
120
  }, null, 2));
82
121
  });
122
+ program.addHelpCommand("help [command]", "Display help for command");
83
123
  program.exitOverride();
84
124
  program.parseAsync(process.argv).catch((error) => {
85
125
  if (error?.code === "commander.helpDisplayed" || error?.code === "commander.version")
@@ -92,6 +132,44 @@ function clearTerminalAfterTUI() {
92
132
  return;
93
133
  process.stdout.write("\x1b[2J\x1b[3J\x1b[H");
94
134
  }
135
+ async function runWorkbench(options) {
136
+ const launchWorkdir = options.workdir ? await validateLaunchWorkdir(options.workdir) : undefined;
137
+ if (!process.stdin.isTTY) {
138
+ program.help();
139
+ return;
140
+ }
141
+ const chatOptions = normalizeChatOptions([], launchWorkdir ? { workdir: launchWorkdir } : {});
142
+ const app = render(React.createElement(ChatApp, { options: chatOptions }));
143
+ await app.waitUntilExit();
144
+ clearTerminalAfterTUI();
145
+ }
146
+ function resolveRunWorkdir(positional, option) {
147
+ if (positional && option)
148
+ throw new Error("Use either run [workdir] or -w/--workdir, not both.");
149
+ return option || positional;
150
+ }
151
+ async function runTopLevelUpdate(options) {
152
+ const result = await checkForUpdate({ timeoutMs: 5_000 });
153
+ if (!result) {
154
+ console.error("Could not check for a CLI update right now.");
155
+ process.exitCode = 1;
156
+ return;
157
+ }
158
+ if (!result.updateAvailable) {
159
+ console.log(`${result.packageName} is already up to date (${result.current}).`);
160
+ return;
161
+ }
162
+ if (options.checkOnly) {
163
+ console.log(formatUpdateNotice(result));
164
+ return;
165
+ }
166
+ console.log(formatUpdateNotice(result));
167
+ console.log("Installing update...");
168
+ const installed = await installUpdate(result);
169
+ console.log(`Updated ${result.packageName}: ${result.current} -> ${result.latest}.`);
170
+ if (installed.output)
171
+ console.log(installed.output);
172
+ }
95
173
  function authLoginCommand() {
96
174
  return new Command("login")
97
175
  .description("Sign in with browser auth or save an API key profile")
package/dist/runtime.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export declare const cliName = "agent-tui";
2
2
  export declare const cliAuthor = "AgentsWay";
3
- export declare const cliVersion = "0.4.13";
3
+ export declare const cliVersion = "0.4.15";
4
4
  export declare const legacyCliName = "agent-api-cli";
package/dist/runtime.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export const cliName = "agent-tui";
2
2
  export const cliAuthor = "AgentsWay";
3
- export const cliVersion = "0.4.13";
3
+ export const cliVersion = "0.4.15";
4
4
  export const legacyCliName = "agent-api-cli";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-api/cli",
3
- "version": "0.4.13",
3
+ "version": "0.4.15",
4
4
  "description": "First-class command line interface for Agent API",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/scalebox-dev/agent-tui#readme",
@@ -35,7 +35,7 @@
35
35
  "test": "npm run sync-version && npm run build && npm run smoke -w @agent-api/app-engine && node --test test/*.test.mjs"
36
36
  },
37
37
  "dependencies": {
38
- "@agent-api/app-engine": "^0.1.13",
38
+ "@agent-api/app-engine": "^0.1.15",
39
39
  "commander": "^14.0.3",
40
40
  "ink": "^6.8.0",
41
41
  "react": "^19.2.7"