@gkoreli/ghx 2.1.11 → 2.1.13

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/README.md +27 -4
  2. package/package.json +7 -7
package/README.md CHANGED
@@ -4,9 +4,23 @@ One command does what takes 3-5 API calls. Batch file reads, code maps, search
4
4
 
5
5
  ## Why
6
6
 
7
- AI agents exploring GitHub face a reliability gap: *"Did I find nothing because nothing exists, or because I used the tool wrong?"* Raw `gh` commands have silent failure modes — `gh search code` wraps in quotes without telling you, `gh api contents/` returns base64, README requires a separate call. The agent can't distinguish "no results" from "wrong flags."
7
+ An agent wants to understand `packages/shadcn/src/utils/` in [shadcn-ui/ui](https://github.com/shadcn-ui/ui):
8
8
 
9
- ghx eliminates this by encoding the right defaults into every command. One call returns enough context to decide the next action.
9
+ **With `gh` CLI** 4 turns, 4 API calls, reads 3 full files (3,761 tokens), sees 3 of 34 files:
10
+ ```
11
+ gh api /repos/shadcn-ui/ui/contents/packages/shadcn/src/utils → JSON with shas, urls, links (480 tokens for a file list)
12
+ gh api /repos/.../get-config.ts --jq '.content' | base64 -d → full file (1,981 tokens — agent only needed exports)
13
+ gh api /repos/.../registries.ts --jq '.content' | base64 -d → full file (676 tokens)
14
+ gh api /repos/.../frameworks.ts --jq '.content' | base64 -d → full file (624 tokens)
15
+ ```
16
+
17
+ **With ghx** — 2 turns, 2 API calls, maps 10 files (3,058 tokens), sees signatures of all 10:
18
+ ```
19
+ ghx read shadcn-ui/ui packages/shadcn/src/utils → directory listing (199 tokens)
20
+ ghx read shadcn-ui/ui "packages/shadcn/src/utils/*.ts" --map → signatures of 10 files (2,859 tokens)
21
+ ```
22
+
23
+ Same token budget. The `gh` agent read 3 full files. The ghx agent saw the structure of 10 — imports, exports, function signatures — and knows which ones to drill into. Pass a file, get content. Pass a directory, get a listing. Pass a glob, get matching files. Same command, always useful output.
10
24
 
11
25
  | Tool | Files per call | Matching context | Programmable | Dependencies |
12
26
  |------|---------------|-----------------|-------------|-------------|
@@ -56,6 +70,11 @@ No install step — npx downloads and caches the binary on first run.
56
70
  ghx explore <owner/repo> # Branch + tree + README in 1 API call
57
71
  ghx explore <owner/repo> <path> # Subdirectory listing
58
72
  ghx read <owner/repo> <f1> [f2] [f3] # Read 1-10 files (GraphQL batching)
73
+ ghx read <owner/repo> <dir> # Directory path → returns file listing
74
+ ghx read <owner/repo> "src/**/*.ts" --map # Glob patterns with structural map
75
+ ghx read <owner/repo> --map <f1> [f2] # Signatures, imports, types (~92% token reduction)
76
+ ghx read <owner/repo> --grep "pat" <f> # Matching lines only (ERE regex, 2 lines context)
77
+ ghx read <owner/repo> --lines 42-80 <f> # Specific line range
59
78
  ghx search "<query>" # Code search with matching lines
60
79
  ghx repos "<query>" # Repo search with README preview
61
80
  ghx tree <owner/repo> [path] # Full recursive tree
@@ -108,9 +127,13 @@ ghx skill --mcp # MCP skill
108
127
 
109
128
  Designed for eager context injection via spawn hooks — the agent always has the latest ghx knowledge without loading it mid-conversation.
110
129
 
130
+ ## How It Was Built
131
+
132
+ 23 agent sessions, 2,500+ conversation turns, 3 rewrites, 12 ADRs. The full story: **[Build the GitHub Exploration Tool, No Mistakes](https://gkoreli.com/how-ghx-was-born)**
133
+
111
134
  ## How It Works
112
135
 
113
- Wraps `gh` CLI with GraphQL batching. `repos` and `explore` batch search + metadata + README into 1 call. `read` uses GraphQL aliases to fetch up to 10 files in 1 call. `search` hits REST `/search/code` with `text_matches` for matching context and 200-char token protection.
136
+ Wraps `gh` CLI with GraphQL batching. `repos` and `explore` batch search + metadata + README into 1 call. `read` uses GraphQL aliases to fetch up to 10 files in 1 call — and if a path is a directory, returns its file listing instead of "not found" (via `... on Tree` inline fragments in the same query, zero extra API calls). Glob patterns (`src/**/*.ts`) auto-expand via tree fetch + [doublestar](https://github.com/bmatcuk/doublestar) matching in 2 API calls. `--grep` uses ERE regex with BRE normalization (agents trained on `grep` write `\|` for alternation — both styles work). `search` hits REST `/search/code` with `text_matches` for matching context and 200-char token protection.
114
137
 
115
138
  Codemode runs JS in a [goja](https://github.com/nicholasgasior/goja) sandbox with esbuild TypeScript transpilation. Tools are injected as synchronous functions on a `codemode` global object. Max 20 tool calls per execution, 64KB code size limit.
116
139
 
@@ -118,7 +141,7 @@ Codemode runs JS in a [goja](https://github.com/nicholasgasior/goja) sandbox wit
118
141
 
119
142
  ```
120
143
  v2/
121
- ├── pkg/ghx/ — core library (Explore, Read, Search, Repos, Tree)
144
+ ├── pkg/ghx/ — core library (Explore, Read, Search, Repos, Tree, Glob)
122
145
  ├── pkg/codemode/ — JS executor (goja sandbox, TS transpilation, type generation)
123
146
  └── cmd/ — CLI frontend (cobra) + MCP server (mcp-go)
124
147
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gkoreli/ghx",
3
- "version": "2.1.11",
3
+ "version": "2.1.13",
4
4
  "description": "Agent-first GitHub code exploration. GraphQL batching, code maps, codemode TypeScript sandbox, MCP server.",
5
5
  "bin": {
6
6
  "ghx": "npm/bin/ghx"
@@ -27,11 +27,11 @@
27
27
  "node": ">=16"
28
28
  },
29
29
  "optionalDependencies": {
30
- "@gkoreli/ghx-darwin-arm64": "2.1.11",
31
- "@gkoreli/ghx-darwin-x64": "2.1.11",
32
- "@gkoreli/ghx-linux-arm64": "2.1.11",
33
- "@gkoreli/ghx-linux-x64": "2.1.11",
34
- "@gkoreli/ghx-win32-arm64": "2.1.11",
35
- "@gkoreli/ghx-win32-x64": "2.1.11"
30
+ "@gkoreli/ghx-darwin-arm64": "2.1.13",
31
+ "@gkoreli/ghx-darwin-x64": "2.1.13",
32
+ "@gkoreli/ghx-linux-arm64": "2.1.13",
33
+ "@gkoreli/ghx-linux-x64": "2.1.13",
34
+ "@gkoreli/ghx-win32-arm64": "2.1.13",
35
+ "@gkoreli/ghx-win32-x64": "2.1.13"
36
36
  }
37
37
  }