@1db/cli 0.1.0 → 0.1.1

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/bin/1db.mjs CHANGED
@@ -2,6 +2,7 @@
2
2
  // 1DB CLI: zero dependencies, talks to the agent API (/v1/agent/*) with an
3
3
  // agent token. Run `1db help` for commands.
4
4
  import {
5
+ CMD,
5
6
  CliError,
6
7
  api,
7
8
  bold,
@@ -50,7 +51,7 @@ const commands = {
50
51
  async websites({ flags }) {
51
52
  const { websites } = await api("/v1/agent/websites");
52
53
  if (flags.json) return json(websites);
53
- if (websites.length === 0) return print("No websites yet. Add one with `1db init <domain>`.");
54
+ if (websites.length === 0) return print(`No websites yet. Add one with \`${CMD} init <domain>\`.`);
54
55
  table(websites, ["slug", "name", "domain", "framework"]);
55
56
  },
56
57
 
@@ -104,10 +105,10 @@ const commands = {
104
105
  },
105
106
 
106
107
  async mcp({ flags }) {
107
- if (!settings().token) throw new CliError("Not logged in. Run `1db login` first.");
108
+ if (!settings().token) throw new CliError(`Not logged in. Run \`${CMD} login\` first.`);
108
109
  if (flags.install) return installMcp();
109
110
  printMcpCommand();
110
- print(dim("\nOr run `1db mcp --install` to do it for you."));
111
+ print(dim(`\nOr run \`${CMD} mcp --install\` to do it for you.`));
111
112
  },
112
113
 
113
114
  /** One step for a new machine: sign in, then add the MCP server to Claude Code. */
@@ -165,7 +166,7 @@ function writeCredentials(result, flags) {
165
166
  const [name = "help", ...rest] = process.argv.slice(2);
166
167
  const command = commands[name === "--help" || name === "-h" ? "help" : name];
167
168
  if (!command) {
168
- console.error(`Unknown command "${name}". Run \`1db help\`.`);
169
+ console.error(`Unknown command "${name}". Run \`${CMD} help\`.`);
169
170
  process.exit(1);
170
171
  }
171
172
  try {
package/lib/core.mjs CHANGED
@@ -8,6 +8,8 @@ export const DEFAULT_API_URL = "https://gallant-goshawk-513.convex.site";
8
8
  export const DEFAULT_APP_URL = "https://www.1-db.com";
9
9
  export const CONFIG_DIR = join(process.env.XDG_CONFIG_HOME || join(homedir(), ".config"), "1db");
10
10
  export const CONFIG_FILE = join(CONFIG_DIR, "config.json");
11
+ // How to name a command in hints: npx runs us with npm_command=exec, a global install as plain 1db.
12
+ export const CMD = process.env.npm_command === "exec" ? "npx @1db/cli" : "1db";
11
13
 
12
14
  // ---------- config ----------
13
15
  export function readConfig() {
@@ -58,7 +60,7 @@ export class CliError extends Error {}
58
60
 
59
61
  export async function api(path, { method = "GET", body } = {}) {
60
62
  const { token, apiUrl } = settings();
61
- if (!token) throw new CliError("Not logged in. Run `1db login` (or set ONEDB_TOKEN).");
63
+ if (!token) throw new CliError(`Not logged in. Run \`${CMD} login\` (or set ONEDB_TOKEN).`);
62
64
  let res;
63
65
  try {
64
66
  res = await fetch(`${apiUrl}${path}`, {
package/lib/login.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  import { hostname } from "node:os";
3
3
  import { createInterface } from "node:readline/promises";
4
4
  import { execFileSync, spawn } from "node:child_process";
5
- import { CliError, CONFIG_FILE, api, bold, dim, green, print, readConfig, settings, writeConfig } from "./core.mjs";
5
+ import { CMD, CliError, CONFIG_FILE, api, bold, dim, green, print, readConfig, settings, writeConfig } from "./core.mjs";
6
6
 
7
7
  // ---------- login ----------
8
8
  export function openBrowser(url) {
@@ -45,7 +45,7 @@ export async function browserLogin() {
45
45
  if (result.status === "denied") throw new CliError("Sign-in was denied in the browser.");
46
46
  if (result.status === "expired") break;
47
47
  }
48
- throw new CliError("The sign-in code expired. Run `1db login` again.");
48
+ throw new CliError(`The sign-in code expired. Run \`${CMD} login\` again.`);
49
49
  }
50
50
 
51
51
  export async function promptToken() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1db/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Connect websites to 1DB from your terminal or an AI agent: onboard a domain, get its lead keys, send and list leads.",
5
5
  "type": "module",
6
6
  "bin": {