@manfred-kunze-dev/backbone-cli 2.13.0-dev.4 → 2.13.0-dev.6

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
@@ -5,9 +5,15 @@ A command-line interface for the [Backbone AI](https://backbone.manfred-kunze.de
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
+ # Latest stable release
8
9
  npm install -g @manfred-kunze-dev/backbone-cli
10
+
11
+ # Pre-release (dev channel)
12
+ npm install -g @manfred-kunze-dev/backbone-cli@dev
9
13
  ```
10
14
 
15
+ The CLI will notify you when a newer version is available.
16
+
11
17
  ## Quick Start
12
18
 
13
19
  ```bash
@@ -17,9 +23,6 @@ backbone auth login
17
23
  # Create a project
18
24
  backbone projects create -n "My Project"
19
25
 
20
- # Set it as default
21
- backbone config set project <project-id>
22
-
23
26
  # Define a schema and run an extraction
24
27
  backbone schemas create -n "Invoice"
25
28
  backbone extractions create --schema <id> -m gpt-4o --text "Invoice #123, Total: $500"
@@ -44,12 +47,26 @@ backbone auth status # Verify credentials
44
47
  backbone auth logout # Clear stored credentials
45
48
  ```
46
49
 
50
+ ## Contexts
51
+
52
+ The CLI supports kubectl-style contexts for switching between organizations and environments:
53
+
54
+ ```bash
55
+ # Contexts are created automatically via `backbone auth login`
56
+ backbone context list # List all contexts
57
+ backbone context use acme-corp # Switch active context
58
+ backbone context create staging # Create a new context
59
+ backbone context rename old new # Rename a context
60
+ backbone context delete old # Remove a context
61
+ ```
62
+
47
63
  ## Commands
48
64
 
49
65
  | Command | Description |
50
66
  |---------|-------------|
51
67
  | `auth` | Login, logout, and check auth status |
52
68
  | `config` | Get, set, and list configuration values |
69
+ | `context` | Manage CLI contexts for multiple environments |
53
70
  | `projects` | List, create, update, and delete projects |
54
71
  | `schemas` | Manage schemas, versions, labels, validation, and testing |
55
72
  | `prompts` | Manage prompts, versions, labels, compilation, and testing |
@@ -60,6 +77,7 @@ backbone auth logout # Clear stored credentials
60
77
  | `providers` | Manage BYOK AI providers |
61
78
  | `analytics` | View project usage analytics |
62
79
  | `billing` | Check subscription tier and usage limits |
80
+ | `docs` | Browse API documentation from the terminal |
63
81
 
64
82
  ### Global Options
65
83
 
@@ -67,7 +85,6 @@ backbone auth logout # Clear stored credentials
67
85
  |------|-------------|
68
86
  | `--api-key <key>` | Override the API key |
69
87
  | `--base-url <url>` | Override the base URL (default: `https://backbone.manfred-kunze.dev/api`) |
70
- | `--project <id>` | Override the project ID |
71
88
  | `--json` | Output raw JSON instead of formatted tables |
72
89
  | `--no-color` | Disable colored output |
73
90
 
package/dist/index.js CHANGED
@@ -17,6 +17,8 @@ import { makeAnalyticsCommand } from "./commands/analytics.js";
17
17
  import { makeBillingCommand } from "./commands/billing.js";
18
18
  import { makeDocsCommand } from "./commands/docs.js";
19
19
  import { makeContextCommand } from "./commands/context.js";
20
+ import { checkForUpdates } from "./lib/update-notifier.js";
21
+ const updater = checkForUpdates(pkg.version);
20
22
  const program = new Command();
21
23
  program
22
24
  .name("backbone")
@@ -40,5 +42,5 @@ program.addCommand(makeProvidersCommand());
40
42
  program.addCommand(makeAnalyticsCommand());
41
43
  program.addCommand(makeBillingCommand());
42
44
  program.addCommand(makeDocsCommand());
43
- program.parse();
45
+ program.parseAsync().then(() => updater.notify());
44
46
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Check for updates in the background. Call early so the fetch
3
+ * runs concurrently with the actual command, then call `notify()`
4
+ * after the command finishes to print the message (if any).
5
+ */
6
+ export declare function checkForUpdates(currentVersion: string): {
7
+ notify: () => void;
8
+ };
9
+ //# sourceMappingURL=update-notifier.d.ts.map
@@ -0,0 +1,96 @@
1
+ import { homedir } from "node:os";
2
+ import { join } from "node:path";
3
+ import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
4
+ import chalk from "chalk";
5
+ const PKG_NAME = "@manfred-kunze-dev/backbone-cli";
6
+ const CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000; // 1 day
7
+ const CACHE_DIR = join(homedir(), ".config", "backbone");
8
+ const CACHE_FILE = join(CACHE_DIR, "update-check.json");
9
+ function readCache() {
10
+ try {
11
+ return JSON.parse(readFileSync(CACHE_FILE, "utf-8"));
12
+ }
13
+ catch {
14
+ return null;
15
+ }
16
+ }
17
+ function writeCache(data) {
18
+ try {
19
+ mkdirSync(CACHE_DIR, { recursive: true });
20
+ writeFileSync(CACHE_FILE, JSON.stringify(data));
21
+ }
22
+ catch {
23
+ // Ignore write errors
24
+ }
25
+ }
26
+ async function fetchLatestVersion() {
27
+ try {
28
+ const controller = new AbortController();
29
+ const timeout = setTimeout(() => controller.abort(), 3000);
30
+ const res = await fetch(`https://registry.npmjs.org/${PKG_NAME}/latest`, { signal: controller.signal });
31
+ clearTimeout(timeout);
32
+ if (!res.ok)
33
+ return null;
34
+ const data = (await res.json());
35
+ return data.version ?? null;
36
+ }
37
+ catch {
38
+ return null;
39
+ }
40
+ }
41
+ function compareVersions(current, latest) {
42
+ const parse = (v) => v.replace(/^v/, "").split(".").map(Number);
43
+ const [cMaj, cMin, cPat] = parse(current);
44
+ const [lMaj, lMin, lPat] = parse(latest);
45
+ if (lMaj !== cMaj)
46
+ return lMaj > cMaj;
47
+ if (lMin !== cMin)
48
+ return lMin > cMin;
49
+ return lPat > cPat;
50
+ }
51
+ /**
52
+ * Check for updates in the background. Call early so the fetch
53
+ * runs concurrently with the actual command, then call `notify()`
54
+ * after the command finishes to print the message (if any).
55
+ */
56
+ export function checkForUpdates(currentVersion) {
57
+ let message = null;
58
+ // Skip for pre-release versions
59
+ if (currentVersion.includes("-")) {
60
+ return { notify: () => { } };
61
+ }
62
+ const cache = readCache();
63
+ const now = Date.now();
64
+ // Use cached result if recent enough
65
+ if (cache && now - cache.lastCheck < CHECK_INTERVAL_MS) {
66
+ if (compareVersions(currentVersion, cache.latestVersion)) {
67
+ message = formatMessage(currentVersion, cache.latestVersion);
68
+ }
69
+ return { notify: () => message && console.error(message) };
70
+ }
71
+ // Fire off the check in the background
72
+ const pending = fetchLatestVersion().then((latest) => {
73
+ if (latest) {
74
+ writeCache({ lastCheck: now, latestVersion: latest });
75
+ if (compareVersions(currentVersion, latest)) {
76
+ message = formatMessage(currentVersion, latest);
77
+ }
78
+ }
79
+ });
80
+ return {
81
+ notify: async () => {
82
+ await pending;
83
+ if (message)
84
+ console.error(message);
85
+ },
86
+ };
87
+ }
88
+ function formatMessage(current, latest) {
89
+ return [
90
+ "",
91
+ chalk.yellow(`Update available: ${chalk.dim(current)} → ${chalk.green(latest)}`),
92
+ chalk.yellow(`Run ${chalk.cyan(`npm i -g ${PKG_NAME}`)} to update`),
93
+ "",
94
+ ].join("\n");
95
+ }
96
+ //# sourceMappingURL=update-notifier.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manfred-kunze-dev/backbone-cli",
3
- "version": "2.13.0-dev.4",
3
+ "version": "2.13.0-dev.6",
4
4
  "description": "CLI for the Backbone AI platform",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",