@hginsights/hgi 0.1.1 → 0.2.0-rc.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/README.md CHANGED
@@ -28,8 +28,24 @@ npm view @hginsights/hgi dist.attestations # provenance attestation for the p
28
28
 
29
29
  Each release also attaches a CycloneDX SBOM. See [SECURITY.md](SECURITY.md) and [docs/releasing.md](docs/releasing.md).
30
30
 
31
+ ### Upgrading
32
+
33
+ `hgi` has no self-update command. Upgrade it the way you installed it:
34
+
35
+ ```bash
36
+ brew update && brew upgrade hginsights/tap/hgi # Homebrew: refresh the tap first, or brew won't see the new version
37
+ npm install -g @hginsights/hgi@latest # npm: keep the -g, a plain `npm i` installs into the current directory
38
+ # tarball: download the new release and replace the `hgi` on your PATH
39
+ hgi --version
40
+ ```
41
+
42
+ If `hgi --version` still shows the old version, `which -a hgi` lists every copy on your PATH and the first one wins. Keep a single install: run `brew uninstall hgi` or `npm uninstall -g @hginsights/hgi` to remove the one you don't use.
43
+
44
+ `hgi skill install` copies the agent skill, so the copy doesn't change when you upgrade. Run `hgi skill install --force` afterwards to pick up the new version's skill.
45
+
31
46
  ### Troubleshooting
32
47
 
48
+ - **`hgi auth login` ends on a `403 Forbidden` page.** Open a private window (or clear your browser's cookies for phoenix.hginsights.com, or for the host in your `HGI_BASE_URL`), sign in at https://phoenix.hginsights.com (or your `HGI_BASE_URL`) first, then open the URL `hgi auth login` printed in that same window. Sign-in still finishes in the terminal. If `hgi` already timed out, run `hgi auth login` again and open the new URL in that window.
33
49
  - The binary and the npm install both honor `NODE_OPTIONS`. If your shell exports `--require` or `--import` hooks (for example a tracer), `hgi` can fail to start: run `env -u NODE_OPTIONS hgi ...`.
34
50
 
35
51
  ## Quick start
@@ -58,7 +74,10 @@ hgi auth login --no-browser # prints a URL; open it anywhere, then past
58
74
  | `hgi auth logout [--force]` | revoke the session on the server and delete the local credentials |
59
75
  | `hgi tools list [--refresh] [--json]` | the tools the server offers you, with `call`/`run`, required fields, schemas and the MCP version |
60
76
  | `hgi call <tool> --input '<json>'` | run a read-only tool |
77
+ | `hgi call <tool> --ids @file` | run a read-only batch tool over a list of HG ids or domains, one row per line |
61
78
  | `hgi run <tool> --input '<json>'` | run a state-changing tool |
79
+ | `hgi usage [--since <when>] [--by tool\|label\|day\|call]` | what `hgi` spent on this machine, from the local credit ledger (no sign-in needed) |
80
+ | `hgi budget status` / `hgi budget reset` | what this run has spent against `hgi call --max-credits`, and starting the count over (local only) |
62
81
  | `hgi skill install` | copy the agent skill to `~/.claude/skills/hgi` |
63
82
 
64
83
  Options for `call`, `run` and `tools list`:
@@ -69,11 +88,29 @@ Options for `call`, `run` and `tools list`:
69
88
  - `--out <file>`: write the complete result to a new file.
70
89
  - `--meta`: print `{result, credit_cost, mcp_version}`.
71
90
  - `--timeout <seconds>`: per-request timeout (default 120).
91
+ - `--label <label>` (`call` and `run`): tag the call in the credit ledger, for example by pipeline stage. 1 to 64 characters from `A-Z a-z 0-9 . _ : / -`.
92
+
93
+ Options for `call` only (batching):
94
+
95
+ - `--ids @file` / `--ids -`: one HG id or domain per line, from a file or stdin. Blank lines and `#` lines are skipped. A line with a dot is a domain, anything else an HG id.
96
+ - `--ids-column <name>`: with `--ids`, read the file as CSV with a header row and take the ids from that column.
97
+ - `--batch-size <n>`: send fewer ids per call than the tool's limit (its schema's `maxItems`, or 25).
72
98
 
73
99
  Global: `--base-url`, `--debug` (tokens are always masked), `--json-errors`.
74
100
 
75
101
  The credit cost of each call is printed on stderr after it runs (`credit_cost: 3`). There is no price before the call.
76
102
 
103
+ Each call that gets a result back from the server (a success or a tool error) is also recorded in a local credit ledger, and `hgi usage` sums it. A call whose outcome is unknown (the connection failed after it was sent) has no result and is not recorded.
104
+
105
+ ```bash
106
+ hgi call company_enrich --input '{"domain":"acme.com"}' --label enrich
107
+ hgi usage --since 7d # credits and calls by tool, this machine only
108
+ hgi usage --by label --since today
109
+ hgi usage --by call -f csv # one row per call, for a spreadsheet
110
+ ```
111
+
112
+ `hgi usage` shows what `hgi` spent on this machine, not your organization's bill. Calls that cost `0` (a server-side cache hit or a free tool) are counted apart from calls whose cost the server did not report. See [output formats](docs/output-formats.md#hgi-usage) and [security](docs/security.md#the-credit-ledger).
113
+
77
114
  ## Using it from an AI coding agent
78
115
 
79
116
  This repository ships a Claude Code skill: [`skills/hgi/SKILL.md`](skills/hgi/SKILL.md), also reachable at `.claude/skills/hgi/` inside this repo. To use it from any project:
@@ -104,6 +141,17 @@ hgi call company_enrich --input '{"domain":"acme.com"}' --select name,employees
104
141
  hgi call search_companies --input '{"query":"saas"}' -f csv --out saas.csv
105
142
  ```
106
143
 
144
+ ### Looking up a whole list
145
+
146
+ `--ids` splits a list into batches the tool accepts, sends them one at a time, and prints one JSONL row per input line, in your file's order, as soon as each batch returns:
147
+
148
+ ```bash
149
+ hgi call company_spend --ids @hg_ids.txt --input '{"category_names":["CRM"]}' > spend.jsonl
150
+ hgi call company_spend --ids @accounts.csv --ids-column hg_id --input '{"category_names":["CRM"]}'
151
+ ```
152
+
153
+ Each row is `{"input": "<your line>", "result": {...}}` or `{"input": "<your line>", "error": {"code": "not_found", "message": "..."}}`, so joining back to your spreadsheet works even when the server drops leading zeros from ids or you wrote `https://www.Example.com/about`. Duplicate lines are sent once and get their row repeated. Running the same file again sends identical batches. The rest of `--input` is sent with every batch. A failed batch marks its rows with the error, the run continues, and the exit code is 3. Out of credits, an expired sign-in or an unreachable server stops the run at once, with the rows so far kept (see [exit codes](docs/exit-codes.md#partial-output-from---ids)). The total credit cost is printed once at the end.
154
+
107
155
  ## Configuration
108
156
 
109
157
  | Variable | Meaning |
@@ -115,6 +163,9 @@ hgi call search_companies --input '{"query":"saas"}' -f csv --out saas.csv
115
163
  | `NODE_EXTRA_CA_CERTS` | extra CA bundle for corporate TLS inspection |
116
164
  | `XDG_CONFIG_HOME`, `XDG_CACHE_HOME` | move `~/.config/hgi` and `~/.cache/hgi` |
117
165
  | `HGI_CONFIG_DIR`, `HGI_CACHE_DIR` | explicit directories (must not be inside a git working tree) |
166
+ | `HGI_LEDGER` | credit ledger path (default `<config dir>/ledger.jsonl`; must not be inside a git working tree), or `off` to keep no history |
167
+ | `HGI_MAX_CREDITS` | run cap for `hgi call`, same as `--max-credits` (the flag wins). See [Run cap](docs/exit-codes.md#run-cap) |
168
+ | `HGI_BUDGET_ID` | the run a capped `hgi call` counts against (default: the parent process id); when set, also recorded with each call in the credit ledger, to group the calls of one run |
118
169
 
119
170
  `hgi` sends the User-Agent `hgi/<version>` and has no telemetry: it talks only to the server you configure, and sends nothing to HG Insights or anyone else about how you use it.
120
171