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
15 changes: 15 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,25 @@ jobs:

- run: npm run build

# Publishes `upstash` (the name in package.json), then the same build
# again as @upstash/cli so existing installs keep getting releases.
- name: Publish release candidate
if: github.event.release.prerelease
run: npm publish --access public --tag=canary --provenance

- name: Publish
if: "!github.event.release.prerelease"
run: npm publish --access public --provenance

- name: Rename the package to @upstash/cli
run: |
jq '.name = "@upstash/cli"' package.json > package.tmp.json
mv package.tmp.json package.json

- name: Publish @upstash/cli release candidate
if: github.event.release.prerelease
run: npm publish --access public --tag=canary --provenance

- name: Publish @upstash/cli
if: "!github.event.release.prerelease"
run: npm publish --access public --provenance
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Upstash CLI

[![GitHub release](https://img.shields.io/github/v/release/upstash/cli)](https://github.com/upstash/cli/releases/latest)
[![npm downloads](https://img.shields.io/npm/dw/@upstash/cli.svg)](https://npmjs.org/package/@upstash/cli)
[![npm downloads](https://img.shields.io/npm/dw/upstash.svg)](https://npmjs.org/package/upstash)

Agent-friendly CLI for managing & debugging Upstash resources from your terminal. [Docs](https://upstash.com/docs/agent-resources/cli).

Expand All @@ -10,9 +10,11 @@ Agent-friendly CLI for managing & debugging Upstash resources from your terminal
Requires Node.js 20 or newer.

```bash
npm i -g @upstash/cli
npm i -g upstash
```

The same build is also published as `@upstash/cli`, with the same version, so existing installs keep working.

For agents, pair the CLI with the [Upstash Skill](https://docs.upstash.com/agent-resources/skills), it bundles Upstash docs alongside docs for the `upstash` CLI.

```bash
Expand All @@ -24,9 +26,11 @@ npx skills add upstash/skills
One command wires Upstash into your coding agents:

```bash
npx @upstash/cli setup
npx upstash
```

With no arguments in a terminal, `upstash` runs `upstash setup`. From an agent or a script, a bare `upstash` prints the help instead, so run `upstash setup` explicitly there.

It picks the best install path per agent:

| Agent | What gets installed |
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@upstash/cli",
"name": "upstash",
"version": "0.0.0",
"description": "Agent-friendly CLI for Upstash",
"repository": {
Expand Down
5 changes: 4 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { registerStartRedis } from "./commands/start-redis.js";
import { registerTelemetry } from "./commands/telemetry.js";
import { registerSetup } from "./commands/setup.js";
import { handleError } from "./output.js";
import { withDefaultCommand } from "./default-command.js";
import dotenv from "dotenv";

// Pre-scan argv for --env-path before Commander parses, so dotenv loads
Expand Down Expand Up @@ -53,4 +54,6 @@ registerSearch(program);
registerQStash(program);
registerBlob(program);

program.parseAsync().catch(handleError);
const interactive = Boolean(process.stdin.isTTY && process.stdout.isTTY);
const args = withDefaultCommand(process.argv.slice(2), interactive);
program.parseAsync(args, { from: "user" }).catch(handleError);
9 changes: 9 additions & 0 deletions src/default-command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* A bare `upstash` in a terminal is the agent setup entry point, so
* `npx upstash` connects your coding agents. Outside a terminal (an agent, a
* script, CI) it keeps the default help output, so it never rewrites agent
* configs unasked.
*/
export function withDefaultCommand(args: string[], interactive: boolean): string[] {
return args.length === 0 && interactive ? ["setup"] : args;
}
17 changes: 17 additions & 0 deletions tests/unit/default-command.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { describe, expect, it } from "vitest";
import { withDefaultCommand } from "../../src/default-command.js";

describe("bare `upstash`", () => {
it("runs setup in a terminal", () => {
expect(withDefaultCommand([], true)).toEqual(["setup"]);
});

it("keeps the help outside a terminal, so agents never trigger setup", () => {
expect(withDefaultCommand([], false)).toEqual([]);
});

it("passes every other invocation through unchanged", () => {
expect(withDefaultCommand(["redis", "list"], true)).toEqual(["redis", "list"]);
expect(withDefaultCommand(["--version"], true)).toEqual(["--version"]);
});
});
Loading