hngr 0.1.1 → 0.2.0

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
@@ -13,14 +13,19 @@ hngr --version
13
13
  ## Authenticate
14
14
 
15
15
  ```sh
16
- # Interactive: username and password, then an access token is written to
16
+ # Interactive: username and password against http://10.199.100.24:26434 (the
17
+ # built-in default), then an access token is written to
17
18
  # ~/.config/hngr/config.json (0600).
19
+ hngr auth login
20
+
21
+ # A different deployment. The built-in default is plain http on a private
22
+ # network; any other host needs https:// (or an explicit --insecure).
18
23
  hngr auth login --server https://hangar.example.com
19
24
 
20
25
  # CI or containers: read an existing access token from stdin.
21
26
  printf '%s' "$HANGAR_TOKEN_VALUE" | hngr auth login --token --server https://hangar.example.com
22
27
 
23
- # Or skip the config file entirely.
28
+ # Or skip the config file entirely. HANGAR_URL overrides the built-in default.
24
29
  export HANGAR_URL=https://hangar.example.com
25
30
  export HANGAR_TOKEN=hng_...
26
31
  hngr auth status
@@ -1,4 +1,4 @@
1
- import { _ as writeStoredConfig, d as deleteStoredConfig, f as normalizeServerUrl, h as resolveConnection, m as redactUrl, n as apiGet, p as readStoredConfig, t as apiFetch, u as configFilePath, x as HngrError } from "./http-DpXNrkSL.mjs";
1
+ import { S as HngrError, d as configFilePath, f as deleteStoredConfig, g as resolveConnection, h as redactUrl, m as readStoredConfig, n as apiGet, p as normalizeServerUrl, t as apiFetch, v as writeStoredConfig } from "./http-2HWxLIOq.mjs";
2
2
  import { hostname } from "node:os";
3
3
  import { randomUUID } from "node:crypto";
4
4
  // src/commands/auth.ts
@@ -38,8 +38,8 @@ function canPrompt(ctx) {
38
38
  return ctx.io.stdin.isTTY && ctx.io.stdout.isTTY && ctx.io.prompts !== void 0;
39
39
  }
40
40
  /**
41
- * Enforces https everywhere; http only for localhost, 127.0.0.1 and [::1],
42
- * or with an explicit --insecure.
41
+ * Enforces https everywhere; http only for localhost, 127.0.0.1, [::1], the
42
+ * built-in default, or with an explicit --insecure.
43
43
  */
44
44
  function assertServerUrlAllowed(raw, insecure) {
45
45
  const server = normalizeServerUrl(raw);
@@ -50,7 +50,7 @@ function assertServerUrlAllowed(raw, insecure) {
50
50
  "localhost",
51
51
  "127.0.0.1",
52
52
  "[::1]"
53
- ].includes(url.hostname) || insecure) return server;
53
+ ].includes(url.hostname) || insecure || server === "http://10.199.100.24:26434") return server;
54
54
  throw new HngrError({
55
55
  type: "config",
56
56
  title: `Refusing insecure server URL ${redactUrl(server)}`,
@@ -92,14 +92,7 @@ async function revokePreviousToken(ctx, stored) {
92
92
  async function login(ctx, argv) {
93
93
  if (ctx.env.HANGAR_TOKEN) throw envTokenRefusal();
94
94
  const stored = await readStoredConfig(ctx.env);
95
- let rawServer = ctx.flags.server ?? ctx.env.HANGAR_URL ?? stored?.server;
96
- if (!rawServer && canPrompt(ctx)) rawServer = await ctx.io.prompts?.text("Server URL");
97
- if (!rawServer) throw new HngrError({
98
- type: "config",
99
- title: "No Hangar server configured",
100
- detail: "Pass --server <url>, set HANGAR_URL, or run `hngr auth login` interactively to store one."
101
- });
102
- const server = assertServerUrlAllowed(rawServer, ctx.flags.insecure);
95
+ const server = assertServerUrlAllowed(ctx.flags.server ?? ctx.env.HANGAR_URL ?? stored?.server ?? "http://10.199.100.24:26434", ctx.flags.insecure);
103
96
  if (stored?.token && !ctx.flags.force) try {
104
97
  const me = asStoredPrincipal(await apiGet({
105
98
  server,
@@ -161,7 +161,12 @@ async function readStoredConfig(env) {
161
161
  });
162
162
  }
163
163
  }
164
- const NO_SERVER_DETAIL = "Pass --server <url>, set HANGAR_URL, or run `hngr auth login` to store one in the config file.";
164
+ /**
165
+ * The instance the CLI talks to when `--server`, `HANGAR_URL` and the config
166
+ * file are all absent. Point a deployment elsewhere with any of those.
167
+ */
168
+ const DEFAULT_SERVER_URL = "http://10.199.100.24:26434";
169
+ const INVALID_SERVER_DETAIL = "Pass --server <url>, set HANGAR_URL, or run `hngr auth login` to store one in the config file.";
165
170
  /** Parses and normalizes a server URL (no trailing slash); invalid input is a config error. */
166
171
  function normalizeServerUrl(server) {
167
172
  let url;
@@ -171,7 +176,7 @@ function normalizeServerUrl(server) {
171
176
  throw new HngrError({
172
177
  type: "config",
173
178
  title: `Invalid server URL: ${redactUrl(server)}`,
174
- detail: NO_SERVER_DETAIL
179
+ detail: INVALID_SERVER_DETAIL
175
180
  });
176
181
  }
177
182
  return url.toString().replace(/\/+$/, "");
@@ -209,16 +214,12 @@ async function deleteStoredConfig(env) {
209
214
  }
210
215
  /**
211
216
  * Resolves the server and credentials for one call: `--server` beats
212
- * `HANGAR_URL` beats the config file; `HANGAR_TOKEN` beats a stored token.
217
+ * `HANGAR_URL` beats the config file beats the built-in default; `HANGAR_TOKEN`
218
+ * beats a stored token.
213
219
  */
214
220
  async function resolveConnection(flags, env) {
215
221
  const config = await readStoredConfig(env);
216
- const server = flags.server ?? env.HANGAR_URL ?? config?.server;
217
- if (!server) throw new HngrError({
218
- type: "config",
219
- title: "No Hangar server configured",
220
- detail: NO_SERVER_DETAIL
221
- });
222
+ const server = flags.server ?? env.HANGAR_URL ?? config?.server ?? "http://10.199.100.24:26434";
222
223
  const token = env.HANGAR_TOKEN ?? config?.token;
223
224
  return {
224
225
  server: normalizeServerUrl(server),
@@ -455,4 +456,4 @@ async function apiFetch(connection, options) {
455
456
  signal: options.signal
456
457
  });
457
458
  }
458
- export { renderError as S, writeStoredConfig as _, toHngrError as a, CancelledError as b, redactUrlForDisplay as c, deleteStoredConfig as d, normalizeServerUrl as f, scrubCredentials as g, resolveConnection as h, buildRequestUrl as i, apiErrorFromResponse as l, redactUrl as m, apiGet as n, redactQuery as o, readStoredConfig as p, apiRequest as r, redactSensitive as s, apiFetch as t, configFilePath as u, writeDirectoryAtomically as v, HngrError as x, writeFileAtomically as y };
459
+ export { renderError as C, HngrError as S, scrubCredentials as _, toHngrError as a, writeFileAtomically as b, redactUrlForDisplay as c, configFilePath as d, deleteStoredConfig as f, resolveConnection as g, redactUrl as h, buildRequestUrl as i, apiErrorFromResponse as l, readStoredConfig as m, apiGet as n, redactQuery as o, normalizeServerUrl as p, apiRequest as r, redactSensitive as s, apiFetch as t, DEFAULT_SERVER_URL as u, writeStoredConfig as v, CancelledError as x, writeDirectoryAtomically as y };
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as kebabCase, i as normalizeCommandName, n as COMMANDS, o as COMMAND_ALIASES, r as findCommand, t as commandCatalog } from "./catalog-jU0-wzh3.mjs";
2
- import { S as renderError, b as CancelledError, c as redactUrlForDisplay, h as resolveConnection, i as buildRequestUrl, o as redactQuery, r as apiRequest, s as redactSensitive, x as HngrError } from "./http-DpXNrkSL.mjs";
3
- import { t as collectPages } from "./pagination-DYIwy5ZX.mjs";
2
+ import { C as renderError, S as HngrError, c as redactUrlForDisplay, g as resolveConnection, i as buildRequestUrl, o as redactQuery, r as apiRequest, s as redactSensitive, u as DEFAULT_SERVER_URL, x as CancelledError } from "./http-2HWxLIOq.mjs";
3
+ import { t as collectPages } from "./pagination-BbKLKSw3.mjs";
4
4
  import { createRequire } from "node:module";
5
5
  import { notStrictEqual, strictEqual } from "assert";
6
6
  import { basename, dirname, extname, join, normalize, relative, resolve } from "path";
@@ -5279,7 +5279,7 @@ function isYargsInstance(y) {
5279
5279
  // ../../node_modules/.pnpm/yargs@18.2.0/node_modules/yargs/index.mjs
5280
5280
  const Yargs = YargsFactory(esm_default);
5281
5281
  // package.json
5282
- var version = "0.1.1";
5282
+ var version = "0.2.0";
5283
5283
  // src/generated/completion.ts
5284
5284
  function isCompletionShell(value) {
5285
5285
  return value === "bash" || value === "zsh" || value === "fish";
@@ -6822,7 +6822,7 @@ const USAGE_HINT = "Run 'hngr --help' to list available commands.";
6822
6822
  const GLOBAL_OPTIONS = {
6823
6823
  server: {
6824
6824
  type: "string",
6825
- describe: "Override HANGAR_URL and the configured server for this call",
6825
+ describe: `Override HANGAR_URL and the configured server for this call (default: ${DEFAULT_SERVER_URL})`,
6826
6826
  global: true
6827
6827
  },
6828
6828
  json: {
@@ -6922,13 +6922,13 @@ function buildParser(onMatched) {
6922
6922
  }), (argv) => {
6923
6923
  onMatched({
6924
6924
  argv,
6925
- run: async (ctx, matchedArgv) => (await import("./auth-Bf4n5qaq.mjs")).login(ctx, matchedArgv)
6925
+ run: async (ctx, matchedArgv) => (await import("./auth-BT8HuCif.mjs")).login(ctx, matchedArgv)
6926
6926
  });
6927
6927
  });
6928
6928
  auth.command("logout", "Revoke the stored token and delete the local config", () => {}, (argv) => {
6929
6929
  onMatched({
6930
6930
  argv,
6931
- run: async (ctx) => (await import("./auth-Bf4n5qaq.mjs")).logout(ctx)
6931
+ run: async (ctx) => (await import("./auth-BT8HuCif.mjs")).logout(ctx)
6932
6932
  });
6933
6933
  });
6934
6934
  auth.command("status", "Show credential source, server, principal and token prefix", (status) => status.option("offline", {
@@ -6938,19 +6938,19 @@ function buildParser(onMatched) {
6938
6938
  }), (argv) => {
6939
6939
  onMatched({
6940
6940
  argv,
6941
- run: async (ctx, matchedArgv) => (await import("./auth-Bf4n5qaq.mjs")).status(ctx, matchedArgv)
6941
+ run: async (ctx, matchedArgv) => (await import("./auth-BT8HuCif.mjs")).status(ctx, matchedArgv)
6942
6942
  });
6943
6943
  });
6944
6944
  auth.command("token", "Print the access token to stdout and nothing else", () => {}, (argv) => {
6945
6945
  onMatched({
6946
6946
  argv,
6947
- run: async (ctx) => (await import("./auth-Bf4n5qaq.mjs")).token(ctx)
6947
+ run: async (ctx) => (await import("./auth-BT8HuCif.mjs")).token(ctx)
6948
6948
  });
6949
6949
  });
6950
6950
  auth.command("whoami", "Print the GET /me payload", () => {}, (argv) => {
6951
6951
  onMatched({
6952
6952
  argv,
6953
- run: async (ctx) => (await import("./auth-Bf4n5qaq.mjs")).whoami(ctx)
6953
+ run: async (ctx) => (await import("./auth-BT8HuCif.mjs")).whoami(ctx)
6954
6954
  });
6955
6955
  });
6956
6956
  registerGeneratedAuth(auth, onMatched);
@@ -6984,7 +6984,7 @@ function buildParser(onMatched) {
6984
6984
  }), (argv) => {
6985
6985
  onMatched({
6986
6986
  argv,
6987
- run: async (ctx, matchedArgv) => (await import("./skills-By449rb4.mjs")).add(ctx, matchedArgv)
6987
+ run: async (ctx, matchedArgv) => (await import("./skills-DwoDzsXd.mjs")).add(ctx, matchedArgv)
6988
6988
  });
6989
6989
  });
6990
6990
  skills.command("publish <paths..>", "Publish a local skill directory as a capability or a new version", (publish) => publish.option("namespace", {
@@ -7014,7 +7014,7 @@ function buildParser(onMatched) {
7014
7014
  }), (argv) => {
7015
7015
  onMatched({
7016
7016
  argv,
7017
- run: async (ctx, matchedArgv) => (await import("./skills-By449rb4.mjs")).publish(ctx, matchedArgv)
7017
+ run: async (ctx, matchedArgv) => (await import("./skills-DwoDzsXd.mjs")).publish(ctx, matchedArgv)
7018
7018
  });
7019
7019
  });
7020
7020
  return skills.demandCommand(1);
@@ -7036,7 +7036,7 @@ function buildParser(onMatched) {
7036
7036
  }), (argv) => {
7037
7037
  onMatched({
7038
7038
  argv,
7039
- run: async (ctx, matchedArgv) => (await import("./mcp-bi4OOz5J.mjs")).add(ctx, matchedArgv)
7039
+ run: async (ctx, matchedArgv) => (await import("./mcp-DeWHHgQK.mjs")).add(ctx, matchedArgv)
7040
7040
  });
7041
7041
  });
7042
7042
  mcp.command("publish <paths..>", "Publish an MCP snapshot as a capability or a new version", (publish) => publish.option("namespace", {
@@ -7066,7 +7066,7 @@ function buildParser(onMatched) {
7066
7066
  }), (argv) => {
7067
7067
  onMatched({
7068
7068
  argv,
7069
- run: async (ctx, matchedArgv) => (await import("./mcp-bi4OOz5J.mjs")).publish(ctx, matchedArgv)
7069
+ run: async (ctx, matchedArgv) => (await import("./mcp-DeWHHgQK.mjs")).publish(ctx, matchedArgv)
7070
7070
  });
7071
7071
  });
7072
7072
  return mcp.demandCommand(1);
@@ -1,5 +1,5 @@
1
- import { h as resolveConnection, s as redactSensitive, t as apiFetch, x as HngrError, y as writeFileAtomically } from "./http-DpXNrkSL.mjs";
2
- import { _ as resolveCapabilityVersion, a as failedResult, c as stringValues, f as downloadContent, g as resolveCapability, h as parseCapabilityPath, i as errorBody, l as AGENTS, n as readPublishFlags, o as positionalPaths, p as MCP_KIND, r as runPublish, s as runBatch, t as explicitName, u as findAgentDefinition } from "./publish-DHAZ9BB_.mjs";
1
+ import { S as HngrError, b as writeFileAtomically, g as resolveConnection, s as redactSensitive, t as apiFetch } from "./http-2HWxLIOq.mjs";
2
+ import { _ as resolveCapabilityVersion, a as failedResult, c as stringValues, f as downloadContent, g as resolveCapability, h as parseCapabilityPath, i as errorBody, l as AGENTS, n as readPublishFlags, o as positionalPaths, p as MCP_KIND, r as runPublish, s as runBatch, t as explicitName, u as findAgentDefinition } from "./publish-D7zaQl9x.mjs";
3
3
  import { constants } from "node:fs";
4
4
  import { access, readFile, stat } from "node:fs/promises";
5
5
  import { basename, delimiter, isAbsolute, join, relative, resolve, sep } from "node:path";
@@ -1,4 +1,4 @@
1
- import { x as HngrError } from "./http-DpXNrkSL.mjs";
1
+ import { S as HngrError } from "./http-2HWxLIOq.mjs";
2
2
  // src/pagination.ts
3
3
  function asCursorPage(body, path) {
4
4
  if (body === null || typeof body !== "object" || !Array.isArray(body.items) || !("next_cursor" in body)) throw new HngrError({
@@ -1,5 +1,5 @@
1
- import { a as toHngrError, g as scrubCredentials, h as resolveConnection, i as buildRequestUrl, l as apiErrorFromResponse, m as redactUrl, n as apiGet, x as HngrError } from "./http-DpXNrkSL.mjs";
2
- import { t as collectPages } from "./pagination-DYIwy5ZX.mjs";
1
+ import { S as HngrError, _ as scrubCredentials, a as toHngrError, g as resolveConnection, h as redactUrl, i as buildRequestUrl, l as apiErrorFromResponse, n as apiGet } from "./http-2HWxLIOq.mjs";
2
+ import { t as collectPages } from "./pagination-BbKLKSw3.mjs";
3
3
  import { readFile } from "node:fs/promises";
4
4
  import { homedir } from "node:os";
5
5
  import { join, resolve } from "node:path";
@@ -1,5 +1,5 @@
1
- import { h as resolveConnection, r as apiRequest, v as writeDirectoryAtomically, x as HngrError } from "./http-DpXNrkSL.mjs";
2
- import { _ as resolveCapabilityVersion, a as failedResult, c as stringValues, d as homeDir, f as downloadContent, g as resolveCapability, h as parseCapabilityPath, i as errorBody, l as AGENTS, m as SKILL_KIND, n as readPublishFlags, o as positionalPaths, r as runPublish, s as runBatch, t as explicitName } from "./publish-DHAZ9BB_.mjs";
1
+ import { S as HngrError, g as resolveConnection, r as apiRequest, y as writeDirectoryAtomically } from "./http-2HWxLIOq.mjs";
2
+ import { _ as resolveCapabilityVersion, a as failedResult, c as stringValues, d as homeDir, f as downloadContent, g as resolveCapability, h as parseCapabilityPath, i as errorBody, l as AGENTS, m as SKILL_KIND, n as readPublishFlags, o as positionalPaths, r as runPublish, s as runBatch, t as explicitName } from "./publish-D7zaQl9x.mjs";
3
3
  import { lstat, mkdir, readFile, readdir, rename, rm, symlink, writeFile } from "node:fs/promises";
4
4
  import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
5
5
  import { randomUUID } from "node:crypto";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hngr",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "The Hangar CLI: install skills and MCP servers into coding agents, and drive the Management API.",
5
5
  "keywords": [
6
6
  "hangar",