@freesyntax/notch-cli 0.4.1 → 0.4.2

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.
Files changed (2) hide show
  1. package/dist/index.js +45 -25
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -22,6 +22,12 @@ import path from "path";
22
22
 
23
23
  // src/providers/registry.ts
24
24
  import { createOpenAI } from "@ai-sdk/openai";
25
+ var MissingApiKeyError = class extends Error {
26
+ constructor() {
27
+ super("NOTCH_API_KEY is not set");
28
+ this.name = "MissingApiKeyError";
29
+ }
30
+ };
25
31
  var MODEL_CATALOG = {
26
32
  "notch-cinder": {
27
33
  id: "notch-cinder",
@@ -74,9 +80,7 @@ function resolveModel(config) {
74
80
  const baseUrl = config.baseUrl ?? process.env.NOTCH_BASE_URL ?? info.baseUrl;
75
81
  const apiKey = config.apiKey ?? process.env.NOTCH_API_KEY;
76
82
  if (!apiKey) {
77
- throw new Error(
78
- "NOTCH_API_KEY is not set. Set it via the NOTCH_API_KEY environment variable or --api-key flag."
79
- );
83
+ throw new MissingApiKeyError();
80
84
  }
81
85
  const provider = createOpenAI({
82
86
  apiKey,
@@ -2787,26 +2791,18 @@ function formatThemeList(activeId) {
2787
2791
 
2788
2792
  // src/ui/banner.ts
2789
2793
  var MANTIS = [
2790
- " \u25C9\u2588\u2580\u2580\u2580\u2580\u2588\u25C9",
2791
- // head + eyes
2792
- " \u2580\u2588\u2584\u2584\u2588\u2580",
2793
- // jaw
2794
- " \u2590\u258C",
2795
- // thin neck
2796
- " \u2588\u2580 \u2590\u258C \u2580\u2588",
2797
- // forelegs out
2798
- " \u2580\u2588\u2584\u2588\u2588\u2584\u2588\u2580",
2799
- // forelegs folding (prayer)
2800
- " \u2590\u2588\u2588\u258C",
2801
- // thorax
2802
- " \u2590\u2588\u2588\u258C",
2803
- // abdomen
2804
- " \u2590\u2588\u2588\u258C",
2805
- // abdomen
2806
- " \u2584\u2580 \u2580\u2584",
2807
- // legs splay
2808
- " \u2580 \u2580"
2809
- // feet
2794
+ " \u2571\u25C9\u25C9\u2572",
2795
+ // ╱◉◉╲ antennae + eyes
2796
+ " \u2588\u2588\u2588",
2797
+ // ███ head
2798
+ " \u2590\u2588\u258C",
2799
+ // ▐█▌ neck
2800
+ " \u2584\u2580\u2590\u2588\u258C\u2580\u2584",
2801
+ // ▄▀▐█▌▀▄ prayer arms
2802
+ " \u2590\u2588\u258C",
2803
+ // ▐█▌ abdomen
2804
+ " \u2580\u2580 \u2580\u2580"
2805
+ // ▀▀ ▀▀ feet
2810
2806
  ];
2811
2807
  var LOGO_INLINE = [
2812
2808
  " \u2588\u2588\u2584 \u2588 \u2584\u2580\u2580\u2584 \u2580\u2588\u2580 \u2584\u2580\u2580\u2584 \u2588 \u2588",
@@ -2815,7 +2811,7 @@ var LOGO_INLINE = [
2815
2811
  ];
2816
2812
  function colorMantis(line) {
2817
2813
  const t = theme();
2818
- return line.replace(/\u25c9/g, t.mascotAccent("\u25C9")).replace(/[\u2588]/g, (ch) => t.mascot(ch)).replace(/[\u2584\u2580]/g, (ch) => t.mascot(ch)).replace(/\u2590/g, t.mascot("\u2590")).replace(/\u258c/g, t.mascot("\u258C"));
2814
+ return line.replace(/[\u2571\u2572]/g, (ch) => t.mascot(ch)).replace(/\u25c9/g, t.mascotAccent("\u25C9")).replace(/[\u2588]/g, (ch) => t.mascot(ch)).replace(/[\u2584\u2580]/g, (ch) => t.mascot(ch)).replace(/\u2590/g, t.mascot("\u2590")).replace(/\u258c/g, t.mascot("\u258C"));
2819
2815
  }
2820
2816
  function printBanner(version, modelLabel, modelId, modelSize, project) {
2821
2817
  const t = theme();
@@ -3896,7 +3892,31 @@ async function main() {
3896
3892
  setTheme(config.theme);
3897
3893
  }
3898
3894
  let activeModelId = config.models.chat.model;
3899
- let model = resolveModel(config.models.chat);
3895
+ let model;
3896
+ try {
3897
+ model = resolveModel(config.models.chat);
3898
+ } catch (err) {
3899
+ if (err instanceof MissingApiKeyError) {
3900
+ console.log("");
3901
+ console.log(" \x1B[1m\x1B[36m\u26A1 Welcome to Notch CLI\x1B[0m");
3902
+ console.log("");
3903
+ console.log(" To get started, you need a Notch API key.");
3904
+ console.log("");
3905
+ console.log(" \x1B[1mOption 1:\x1B[0m Log in via browser (recommended)");
3906
+ console.log(" \x1B[33m$ notch login\x1B[0m");
3907
+ console.log("");
3908
+ console.log(" \x1B[1mOption 2:\x1B[0m Set your API key directly");
3909
+ console.log(" \x1B[33m$ export NOTCH_API_KEY=your-key-here\x1B[0m");
3910
+ console.log("");
3911
+ console.log(" \x1B[1mOption 3:\x1B[0m Pass it inline");
3912
+ console.log(" \x1B[33m$ notch --api-key your-key-here\x1B[0m");
3913
+ console.log("");
3914
+ console.log(" Get your key at: \x1B[4mhttps://freesyntax.com/settings\x1B[0m");
3915
+ console.log("");
3916
+ process.exit(0);
3917
+ }
3918
+ throw err;
3919
+ }
3900
3920
  const info = MODEL_CATALOG[activeModelId];
3901
3921
  printBanner(VERSION, info.label, info.id, info.size, config.projectRoot);
3902
3922
  checkForUpdates(VERSION).then((msg) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@freesyntax/notch-cli",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Notch CLI — AI-powered coding assistant by Driftrail",
5
5
  "type": "module",
6
6
  "bin": {