nia-wizard 0.1.29 → 0.1.31

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/dist/bin.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  runWizard,
9
9
  shutdown,
10
10
  track
11
- } from "./chunk-CUR7WEDI.js";
11
+ } from "./chunk-VGEI6AOZ.js";
12
12
 
13
13
  // src/bin.ts
14
14
  import yargs from "yargs";
@@ -9,7 +9,7 @@ var require_package = __commonJS({
9
9
  "package.json"(exports, module) {
10
10
  module.exports = {
11
11
  name: "nia-wizard",
12
- version: "0.1.29",
12
+ version: "0.1.31",
13
13
  description: "CLI wizard to install Nia to your coding agents",
14
14
  packageManager: "pnpm@10.30.3",
15
15
  type: "module",
@@ -3341,6 +3341,7 @@ function dependenciesReady() {
3341
3341
  import { spawnSync as spawnSync5 } from "child_process";
3342
3342
  var NIA_CLI_PACKAGE = "@nozomioai/nia";
3343
3343
  var LATEST_NIA_CLI_PACKAGE = `${NIA_CLI_PACKAGE}@latest`;
3344
+ var API_KEY_PATTERN = /^nk_[A-Za-z0-9_-]+$/;
3344
3345
  function npmCommand() {
3345
3346
  return process.platform === "win32" ? "npm.cmd" : "npm";
3346
3347
  }
@@ -3357,17 +3358,21 @@ function hasCommand(command, args = ["--version"]) {
3357
3358
  const result = spawnSync5(command, args, {
3358
3359
  stdio: "pipe",
3359
3360
  encoding: "utf-8",
3360
- shell: false
3361
+ // On Windows, shell is needed to resolve .cmd shims (npm) via PATHEXT
3362
+ shell: process.platform === "win32"
3361
3363
  });
3362
3364
  debug(`${command} ${args.join(" ")} status`, result.status);
3363
3365
  return result.status === 0;
3364
3366
  }
3365
3367
  function isNiaCliInstalled() {
3366
- return hasCommand(process.platform === "win32" ? "nia.cmd" : "nia");
3368
+ return hasCommand("nia");
3367
3369
  }
3368
3370
  function hasBun() {
3369
3371
  return hasCommand(bunCommand());
3370
3372
  }
3373
+ function validateApiKey(apiKey) {
3374
+ return API_KEY_PATTERN.test(apiKey);
3375
+ }
3371
3376
  function runLatestNia(args) {
3372
3377
  if (hasBun()) {
3373
3378
  const result2 = spawnSync5(bunxCommand(), ["-p", LATEST_NIA_CLI_PACKAGE, "nia", ...args], {
@@ -3378,7 +3383,7 @@ function runLatestNia(args) {
3378
3383
  }
3379
3384
  const result = spawnSync5(npxCommand(), ["-y", "-p", LATEST_NIA_CLI_PACKAGE, "nia", ...args], {
3380
3385
  stdio: "inherit",
3381
- shell: false
3386
+ shell: process.platform === "win32"
3382
3387
  });
3383
3388
  return result.status === 0;
3384
3389
  }
@@ -3398,7 +3403,7 @@ function ensureNiaCliInstalled() {
3398
3403
  }) : spawnSync5(npmCommand(), ["install", "-g", LATEST_NIA_CLI_PACKAGE], {
3399
3404
  stdio: "pipe",
3400
3405
  encoding: "utf-8",
3401
- shell: false
3406
+ shell: process.platform === "win32"
3402
3407
  });
3403
3408
  if (installResult.status !== 0) {
3404
3409
  installSpinner.stop("Failed to install @nozomioai/nia");
@@ -3427,6 +3432,10 @@ function runNiaSkill() {
3427
3432
  return runLatestNia(["skill", "--all"]);
3428
3433
  }
3429
3434
  function runNiaAuthLogin(apiKey) {
3435
+ if (!validateApiKey(apiKey)) {
3436
+ clack_default.log.error("Invalid API key format. Keys should look like `nk_...` and contain only letters, numbers, `_`, or `-`.");
3437
+ return false;
3438
+ }
3430
3439
  return runLatestNia(["auth", "login", "--api-key", apiKey]);
3431
3440
  }
3432
3441
 
@@ -4010,59 +4019,97 @@ function getAgentGuideMarkdown() {
4010
4019
  "",
4011
4020
  "## Goal",
4012
4021
  "",
4013
- "Install the Nia CLI, direct the user to retrieve their API key manually, ask them to paste the key back to you, then finish CLI authentication and skill setup.",
4022
+ "Install the Nia CLI, create an account via the passwordless API, verify the user's email, then finish CLI authentication and skill setup. No browser or manual key creation needed.",
4014
4023
  "",
4015
4024
  "## Steps",
4016
4025
  "",
4017
- "1. Check whether Bun is installed:",
4026
+ "### 1. Ask the user for their details",
4027
+ "",
4028
+ "Before doing anything, ask the user for:",
4029
+ "- **Email address**",
4030
+ "- **Organization name** (e.g. their company or team name)",
4031
+ "",
4032
+ "### 2. Install the Nia CLI",
4033
+ "",
4034
+ "Check whether Bun is installed:",
4018
4035
  "",
4019
4036
  "```bash",
4020
4037
  "bun --version",
4021
4038
  "```",
4022
4039
  "",
4023
- "2. Install `@nozomioai/nia@latest` globally:",
4024
- "",
4025
- "- If `bun --version` succeeds, run:",
4040
+ "If `bun --version` succeeds:",
4026
4041
  "",
4027
4042
  "```bash",
4028
4043
  "bun add -g @nozomioai/nia@latest",
4029
4044
  "```",
4030
4045
  "",
4031
- "- If `bun --version` fails, run:",
4046
+ "If `bun --version` fails:",
4032
4047
  "",
4033
4048
  "```bash",
4034
4049
  "npm install -g @nozomioai/nia@latest",
4035
4050
  "```",
4036
4051
  "",
4037
- "3. Tell the user to open this URL and sign in:",
4052
+ "### 3. Create an account via the API",
4038
4053
  "",
4039
- "`https://app.trynia.ai/api-keys`",
4054
+ "Call the signup endpoint with the user's email and organization name. No password required.",
4040
4055
  "",
4041
- "4. Tell the user to create an API key on that page and copy the `nk_...` token.",
4056
+ "```bash",
4057
+ "curl -s -X POST https://apigcp.trynia.ai/v2/auth/signup \\",
4058
+ ' -H "Content-Type: application/json" \\',
4059
+ ` -d '{"email": "<USER_EMAIL>", "organization_name": "<ORG_NAME>"}'`,
4060
+ "```",
4042
4061
  "",
4043
- "5. Ask the user to paste the API key back into the agent chat or session.",
4062
+ "The response contains:",
4063
+ "- `api_key`: a read-only `nk_...` key (upgraded to full access after verification)",
4064
+ "- `api_key_id`, `user_id`, `organization_id`",
4065
+ "- `verified`: false (until email is verified)",
4044
4066
  "",
4045
- "6. After the user provides the key, configure the CLI:",
4067
+ "A 6-digit verification code is sent to the user's email.",
4068
+ "",
4069
+ "### 4. Ask the user for the verification code",
4070
+ "",
4071
+ "Tell the user to check their email for a 6-digit code from Nia and paste it back.",
4072
+ "",
4073
+ "### 5. Verify the account",
4074
+ "",
4075
+ "Call the verify endpoint with the code and the API key from step 3:",
4076
+ "",
4077
+ "```bash",
4078
+ "curl -s -X POST https://apigcp.trynia.ai/v2/auth/verify \\",
4079
+ ' -H "Content-Type: application/json" \\',
4080
+ ' -H "Authorization: Bearer <nk_api_key>" \\',
4081
+ ` -d '{"code": "<6_DIGIT_CODE>"}'`,
4082
+ "```",
4083
+ "",
4084
+ "On success, the API key is upgraded from read-only to full access.",
4085
+ "",
4086
+ "### 6. Configure the CLI",
4046
4087
  "",
4047
4088
  "```bash",
4048
4089
  "nia auth login --api-key <nk_api_key>",
4049
4090
  "```",
4050
4091
  "",
4051
- "7. Configure Nia skills:",
4092
+ "### 7. Install Nia skills",
4052
4093
  "",
4053
4094
  "```bash",
4054
4095
  "nia skill --all",
4055
4096
  "```",
4056
4097
  "",
4057
- "## Agent Message Template",
4098
+ "## Agent Message Templates",
4099
+ "",
4100
+ "**Asking for details:**",
4101
+ "",
4102
+ "> To set up Nia, I need two things from you:",
4103
+ "> 1. Your **email address**",
4104
+ "> 2. An **organization name** (your company or team name)",
4058
4105
  "",
4059
- "Send the user a message like this:",
4106
+ "**Asking for verification code:**",
4060
4107
  "",
4061
- "> I need your Nia API key to finish setup. Please open https://app.trynia.ai/api-keys, sign in, create a key, and paste the `nk_...` value here. Once you send it, I will finish the setup for you.",
4108
+ "> I've created your Nia account! Check your email for a 6-digit verification code from Nia and paste it here. This upgrades your API key to full access.",
4062
4109
  "",
4063
4110
  "## Expected Result",
4064
4111
  "",
4065
- "`nia` is installed, authenticated with the user-provided API key, and `nia skill --all` has completed."
4112
+ "`nia` is installed, the user's account is created and verified via API, the CLI is authenticated with a full-access API key, and `nia skill --all` has completed."
4066
4113
  ].join("\n");
4067
4114
  }
4068
4115
  function printAgentGuide() {
@@ -4089,4 +4136,4 @@ export {
4089
4136
  getAgentGuideMarkdown,
4090
4137
  printAgentGuide
4091
4138
  };
4092
- //# sourceMappingURL=chunk-CUR7WEDI.js.map
4139
+ //# sourceMappingURL=chunk-VGEI6AOZ.js.map