Skip to content

Commit 47ca48e

Browse files
committed
Add dev and deploy commands to agents CLI
Introduces 'dev' and 'deploy' stub commands to the agents CLI, updates tests for comprehensive coverage of these commands, and adds 'create' as an alias for 'init'. Help output and command descriptions are updated accordingly.
1 parent c8004b4 commit 47ca48e

File tree

3 files changed

+105
-2
lines changed

3 files changed

+105
-2
lines changed

.changeset/soft-beds-rescue.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,11 @@
44

55
Add CLI entry point and tests for agents package
66

7-
Introduces a new CLI for the agents package using yargs, with 'init' and 'mcp' commands stubbed. Adds CLI test suite and configuration for Vitest, updates package.json to register the CLI binary, and includes related dependencies.
7+
Introduces a new CLI for the agents package using yargs with the following commands (currently stubs, not yet implemented):
8+
9+
- `init` / `create` - Initialize an agents project
10+
- `dev` - Start development server
11+
- `deploy` - Deploy agents to Cloudflare
12+
- `mcp` - The agents mcp server
13+
14+
Adds CLI test suite with comprehensive coverage for all commands and configurations. Updates package.json to register the CLI binary, adds test scripts for CLI testing, and includes yargs dependencies.

packages/agents/src/cli-tests/cli.test.ts

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,22 @@ describe("agents CLI", () => {
5858
expect(exitCode).toBe(0);
5959
});
6060

61+
it("should execute create alias command", async () => {
62+
const cli = createCli(["node", "cli.js", "create"]).exitProcess(false);
63+
try {
64+
await cli.parse();
65+
} catch (error) {
66+
// process.exit throws, which is expected
67+
if ((error as Error).message === "process.exit(0)") {
68+
// This is expected, continue
69+
} else {
70+
throw error;
71+
}
72+
}
73+
expect(consoleOutput).toContain("agents init: not implemented yet");
74+
expect(exitCode).toBe(0);
75+
});
76+
6177
it("should show init in help", async () => {
6278
const cli = createCli(["node", "cli.js", "init", "--help"]);
6379
try {
@@ -71,6 +87,66 @@ describe("agents CLI", () => {
7187
});
7288
});
7389

90+
describe("dev command", () => {
91+
it("should execute dev command", async () => {
92+
const cli = createCli(["node", "cli.js", "dev"]).exitProcess(false);
93+
try {
94+
await cli.parse();
95+
} catch (error) {
96+
// process.exit throws, which is expected
97+
if ((error as Error).message === "process.exit(0)") {
98+
// This is expected, continue
99+
} else {
100+
throw error;
101+
}
102+
}
103+
expect(consoleOutput).toContain("agents dev: not implemented yet");
104+
expect(exitCode).toBe(0);
105+
});
106+
107+
it("should show dev in help", async () => {
108+
const cli = createCli(["node", "cli.js", "dev", "--help"]);
109+
try {
110+
await cli.parse();
111+
} catch (error) {
112+
// process.exit throws, which is expected for help
113+
expect((error as Error).message).toBe("process.exit(0)");
114+
}
115+
const allOutput = [...consoleOutput, ...consoleError].join("\n");
116+
expect(allOutput).toContain("Start development server");
117+
});
118+
});
119+
120+
describe("deploy command", () => {
121+
it("should execute deploy command", async () => {
122+
const cli = createCli(["node", "cli.js", "deploy"]).exitProcess(false);
123+
try {
124+
await cli.parse();
125+
} catch (error) {
126+
// process.exit throws, which is expected
127+
if ((error as Error).message === "process.exit(0)") {
128+
// This is expected, continue
129+
} else {
130+
throw error;
131+
}
132+
}
133+
expect(consoleOutput).toContain("agents deploy: not implemented yet");
134+
expect(exitCode).toBe(0);
135+
});
136+
137+
it("should show deploy in help", async () => {
138+
const cli = createCli(["node", "cli.js", "deploy", "--help"]);
139+
try {
140+
await cli.parse();
141+
} catch (error) {
142+
// process.exit throws, which is expected for help
143+
expect((error as Error).message).toBe("process.exit(0)");
144+
}
145+
const allOutput = [...consoleOutput, ...consoleError].join("\n");
146+
expect(allOutput).toContain("Deploy agents to Cloudflare");
147+
});
148+
});
149+
74150
describe("mcp command", () => {
75151
it("should execute mcp command", async () => {
76152
const cli = createCli(["node", "cli.js", "mcp"]).exitProcess(false);
@@ -114,6 +190,8 @@ describe("agents CLI", () => {
114190
expect(allOutput).toContain("agents");
115191
expect(allOutput).toContain("Commands:");
116192
expect(allOutput).toContain("init");
193+
expect(allOutput).toContain("dev");
194+
expect(allOutput).toContain("deploy");
117195
expect(allOutput).toContain("mcp");
118196
});
119197

packages/agents/src/cli.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,32 @@ export function createCli(argv = process.argv) {
99
.scriptName("agents")
1010
.usage("$0 <command> [options]")
1111
.command(
12-
"init",
12+
["init", "create"],
1313
"Initialize an agents project",
1414
(cmd) => cmd,
1515
async () => {
1616
console.log("agents init: not implemented yet");
1717
process.exit(0);
1818
}
1919
)
20+
.command(
21+
"dev",
22+
"Start development server",
23+
(cmd) => cmd,
24+
async () => {
25+
console.log("agents dev: not implemented yet");
26+
process.exit(0);
27+
}
28+
)
29+
.command(
30+
"deploy",
31+
"Deploy agents to Cloudflare",
32+
(cmd) => cmd,
33+
async () => {
34+
console.log("agents deploy: not implemented yet");
35+
process.exit(0);
36+
}
37+
)
2038
.command(
2139
"mcp",
2240
"The agents mcp server",

0 commit comments

Comments
 (0)