@ghx-dev/core 0.4.1 → 0.4.3
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/.claude-plugin/plugin.json +1 -1
- package/.cursor-plugin/hooks/hooks.json +9 -0
- package/.cursor-plugin/plugin.json +25 -0
- package/.cursor-plugin/rules/ghx-batching.mdc +16 -0
- package/.cursor-plugin/rules/ghx-capabilities.mdc +12 -0
- package/.cursor-plugin/rules/prefer-ghx.mdc +14 -0
- package/README.md +25 -6
- package/dist/{chunk-ISLM2HRZ.js → chunk-G3JW3XZK.js} +2 -2
- package/dist/cli/index.js +1 -1
- package/dist/index.js +1 -1
- package/hooks/hooks.json +1 -1
- package/package.json +2 -1
- package/scripts/plugin/ensure-ghx.sh +9 -0
- package/skills/using-ghx/SKILL.md +62 -33
- package/scripts/plugin/setup-env.sh +0 -6
- /package/dist/{chunk-ISLM2HRZ.js.map → chunk-G3JW3XZK.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ghx",
|
|
3
3
|
"description": "Route GitHub operations through deterministic adapters instead of fragile shell scraping. 70+ capabilities covering issues, PRs, repos, releases, and projects — each with validated input, normalized output, and automatic fallback routing.",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.3",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Arye Kogan"
|
|
7
7
|
},
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ghx",
|
|
3
|
+
"description": "Route GitHub operations through deterministic adapters instead of fragile shell scraping. 70+ capabilities covering issues, PRs, repos, releases, and projects — each with validated input, normalized output, and automatic fallback routing.",
|
|
4
|
+
"version": "0.4.3",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Arye Kogan"
|
|
7
|
+
},
|
|
8
|
+
"category": "development",
|
|
9
|
+
"repository": "https://github.com/aryeko/ghx",
|
|
10
|
+
"homepage": "https://github.com/aryeko/ghx",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"github",
|
|
14
|
+
"github-api",
|
|
15
|
+
"ai-agents",
|
|
16
|
+
"agentic",
|
|
17
|
+
"cli",
|
|
18
|
+
"graphql",
|
|
19
|
+
"automation",
|
|
20
|
+
"typescript"
|
|
21
|
+
],
|
|
22
|
+
"logo": "https://raw.githubusercontent.com/aryeko/ghx/main/assets/branding/logos/ghx-logo-icon.svg",
|
|
23
|
+
"skills": "../skills/",
|
|
24
|
+
"rules": "rules/"
|
|
25
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Use ghx chain to batch multiple GitHub operations into a single API call
|
|
3
|
+
alwaysApply: true
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
When performing 2+ GitHub operations, use `ghx chain` with a JSON array of steps instead of sequential `ghx run` calls. This batches operations into fewer API round-trips.
|
|
7
|
+
|
|
8
|
+
Example:
|
|
9
|
+
```bash
|
|
10
|
+
ghx chain --steps - <<'EOF'
|
|
11
|
+
[
|
|
12
|
+
{"task":"pr.view","input":{"owner":"org","name":"repo","number":123}},
|
|
13
|
+
{"task":"pr.reviews.list","input":{"owner":"org","name":"repo","number":123}}
|
|
14
|
+
]
|
|
15
|
+
EOF
|
|
16
|
+
```
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Check ghx capabilities before attempting raw GitHub API calls
|
|
3
|
+
alwaysApply: true
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Before writing custom `gh api` or curl commands, run `ghx capabilities list` or `ghx capabilities explain <id>` to check if ghx already supports the operation. ghx covers 70+ capabilities across issues, PRs, repos, releases, workflows, and projects.
|
|
7
|
+
|
|
8
|
+
Example:
|
|
9
|
+
```bash
|
|
10
|
+
ghx capabilities list --domain pr
|
|
11
|
+
ghx capabilities explain pr.merge
|
|
12
|
+
```
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Prefer ghx CLI over raw gh, gh api, or curl for GitHub operations
|
|
3
|
+
alwaysApply: true
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
When performing any GitHub operation (PRs, issues, reviews, CI checks, releases, labels, comments), use `ghx run` instead of `gh`, `gh api`, or `curl`. ghx provides validated input, structured JSON output, and automatic fallback routing. Always pass `--input` via stdin heredoc to avoid shell quoting issues.
|
|
7
|
+
|
|
8
|
+
Example:
|
|
9
|
+
```bash
|
|
10
|
+
# Instead of: gh pr view 123 --json title,state
|
|
11
|
+
ghx run pr.view --input - <<'EOF'
|
|
12
|
+
{"owner":"org","name":"repo","number":123}
|
|
13
|
+
EOF
|
|
14
|
+
```
|
package/README.md
CHANGED
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
When AI agents use the `gh` CLI directly, they waste thousands of tokens on research, trial-and-error formatting, and guessing JSON parsing paths. **ghx eliminates this waste** by providing a stable, structured execution layer.
|
|
20
20
|
|
|
21
21
|
> **100% success rate, 73% fewer tool calls, 18% fewer active tokens, 54% lower latency** compared to raw CLI usage ([measured across 30 runs](https://github.com/aryeko/ghx/blob/main/docs/eval-report.md) on standard PR workflows with Codex 5.3).
|
|
22
|
+
>
|
|
23
|
+
> Read the full motivation: [AI Agents Shouldn't Relearn GitHub on Every Run](https://plainenglish.io/artificial-intelligence/ai-agents-shouldn-t-relearn-github-on-every-run)
|
|
22
24
|
|
|
23
25
|
```mermaid
|
|
24
26
|
sequenceDiagram
|
|
@@ -59,12 +61,22 @@ Comprehensive documentation is available in the [`docs/`](./docs/) directory:
|
|
|
59
61
|
- **[Architecture](./docs/architecture/README.md)** — System design, execution pipeline, formatters, and GraphQL layer.
|
|
60
62
|
- **[Reference](./docs/reference/README.md)** — API exports, error codes, and a complete table of all 70+ capabilities.
|
|
61
63
|
|
|
62
|
-
##
|
|
64
|
+
## Install
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npm i -g @ghx-dev/core
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
This makes the `ghx` CLI available in your PATH. Then wire it into your agent (see [Agent Integration](#agent-integration) below).
|
|
71
|
+
|
|
72
|
+
For library usage (TypeScript imports), install as a project dependency instead:
|
|
63
73
|
|
|
64
74
|
```bash
|
|
65
75
|
npm install @ghx-dev/core
|
|
66
76
|
```
|
|
67
77
|
|
|
78
|
+
## Quick Start (Library)
|
|
79
|
+
|
|
68
80
|
```ts
|
|
69
81
|
import { createGithubClientFromToken, executeTask } from "@ghx-dev/core"
|
|
70
82
|
|
|
@@ -92,10 +104,10 @@ Use ghx directly from your terminal or add it as an agent skill.
|
|
|
92
104
|
|
|
93
105
|
```bash
|
|
94
106
|
# List all 70+ capabilities
|
|
95
|
-
|
|
107
|
+
ghx capabilities list
|
|
96
108
|
|
|
97
109
|
# Run a capability
|
|
98
|
-
|
|
110
|
+
ghx run pr.view --input '{"owner":"aryeko","name":"ghx","prNumber":42}'
|
|
99
111
|
|
|
100
112
|
# Output is a standard ResultEnvelope:
|
|
101
113
|
# {
|
|
@@ -107,13 +119,20 @@ npx @ghx-dev/core run pr.view --input '{"owner":"aryeko","name":"ghx","number":4
|
|
|
107
119
|
|
|
108
120
|
## Agent Integration
|
|
109
121
|
|
|
110
|
-
|
|
122
|
+
**Claude Code** -- install from the plugin marketplace:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
/plugin marketplace add aryeko/ghx
|
|
126
|
+
/plugin install ghx@ghx-dev
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Cursor, Windsurf, Codex, other agents** -- install the skill:
|
|
111
130
|
|
|
112
131
|
```bash
|
|
113
|
-
|
|
132
|
+
ghx setup --scope user --yes
|
|
114
133
|
```
|
|
115
134
|
|
|
116
|
-
This
|
|
135
|
+
This writes `SKILL.md` to `~/.agents/skills/using-ghx/` which teaches your agent how to use `ghx` for reliable GitHub interactions. See [Agent Setup](./docs/getting-started/agent-setup.md) for platform-specific wiring.
|
|
117
136
|
|
|
118
137
|
## License
|
|
119
138
|
|
|
@@ -833,7 +833,7 @@ function createLogger(config) {
|
|
|
833
833
|
}
|
|
834
834
|
function write(level, msg, ctx) {
|
|
835
835
|
if (levelIndex(level) < minIndex) return;
|
|
836
|
-
const version = true ? "0.4.
|
|
836
|
+
const version = true ? "0.4.3" : "unknown";
|
|
837
837
|
const entry = {
|
|
838
838
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
839
839
|
pid: config.pid,
|
|
@@ -6219,4 +6219,4 @@ export {
|
|
|
6219
6219
|
createGithubClientFromToken,
|
|
6220
6220
|
createGithubClient
|
|
6221
6221
|
};
|
|
6222
|
-
//# sourceMappingURL=chunk-
|
|
6222
|
+
//# sourceMappingURL=chunk-G3JW3XZK.js.map
|
package/dist/cli/index.js
CHANGED
package/dist/index.js
CHANGED
package/hooks/hooks.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ghx-dev/core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Route GitHub operations through deterministic adapters instead of fragile shell scraping. 70+ capabilities covering issues, PRs, repos, releases, and projects — each with validated input, normalized output, and automatic fallback routing.",
|
|
5
5
|
"author": "Arye Kogan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"hooks",
|
|
48
48
|
"scripts/plugin",
|
|
49
49
|
".claude-plugin",
|
|
50
|
+
".cursor-plugin",
|
|
50
51
|
"skills",
|
|
51
52
|
"LICENSE",
|
|
52
53
|
"README.md"
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: using-ghx
|
|
3
|
-
description: Executes GitHub operations via ghx. Use
|
|
3
|
+
description: "Executes GitHub operations via ghx CLI, which batches multiple operations into single API calls and provides structured JSON output for 70+ GitHub capabilities. Use when working with PRs, issues, reviews, CI checks, releases, labels, comments, or any GitHub API operation -- even simple ones like checking PR status or listing issues. Provides richer output than raw gh, gh api, or curl commands."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# ghx CLI Skill
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
ghx provides 70+ GitHub capabilities with structured JSON input/output. It batches operations into single GraphQL round-trips, making it faster than sequential `gh` or `gh api` calls.
|
|
9
|
+
|
|
10
|
+
## Resolving owner and name
|
|
11
|
+
|
|
12
|
+
Most capabilities require `owner` and `name`. Infer from `git remote get-url origin` once at the start and reuse. If no git remote is available, ask the user.
|
|
9
13
|
|
|
10
|
-
|
|
11
|
-
1. `GITHUB_TOKEN` environment variable
|
|
12
|
-
2. `GH_TOKEN` environment variable
|
|
13
|
-
3. Cached token (from previous resolution)
|
|
14
|
-
4. `gh auth token` (requires `gh` CLI authenticated via `gh auth login`)
|
|
14
|
+
## Authentication
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
ghx resolves tokens automatically (env vars `GITHUB_TOKEN`/`GH_TOKEN`, or `gh auth token`). No setup needed if `gh auth login` has been run.
|
|
17
17
|
|
|
18
18
|
## Capabilities
|
|
19
19
|
|
|
@@ -92,7 +92,7 @@ release.update - Update a draft release without publishing it. [owner, name, rel
|
|
|
92
92
|
release.publish - Publish an existing draft release. [owner, name, releaseId, title?, notes?, prerelease?]
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
If you need the full input/output schema for a capability:
|
|
96
96
|
|
|
97
97
|
```bash
|
|
98
98
|
ghx capabilities explain <capability_id>
|
|
@@ -100,7 +100,7 @@ ghx capabilities explain <capability_id>
|
|
|
100
100
|
|
|
101
101
|
## Execute
|
|
102
102
|
|
|
103
|
-
**Always use heredoc — never inline `--input '...'
|
|
103
|
+
**Always use heredoc for input** — never inline `--input '...'`. Inline form breaks with nested quotes and trailing commas in model-generated JSON.
|
|
104
104
|
|
|
105
105
|
```bash
|
|
106
106
|
ghx run <capability_id> --input - <<'EOF'
|
|
@@ -108,28 +108,11 @@ ghx run <capability_id> --input - <<'EOF'
|
|
|
108
108
|
EOF
|
|
109
109
|
```
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
**Result:** `{ ok, data?, pagination? }` on success — `{ ok, error: { code, message } }` on failure.
|
|
112
112
|
|
|
113
|
-
|
|
114
|
-
ghx run pr.reviews.submit --input - <<'EOF'
|
|
115
|
-
{
|
|
116
|
-
"owner": "acme",
|
|
117
|
-
"name": "my-repo",
|
|
118
|
-
"prNumber": 42,
|
|
119
|
-
"event": "REQUEST_CHANGES",
|
|
120
|
-
"body": "Please fix the issues.",
|
|
121
|
-
"comments": [
|
|
122
|
-
{ "path": "src/index.ts", "line": 10, "body": "Off-by-one error here." }
|
|
123
|
-
]
|
|
124
|
-
}
|
|
125
|
-
EOF
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
**Result (compact, default):** `{ ok, data?, pagination? }` on success — `{ ok, error: { code, message } }` on failure.
|
|
129
|
-
|
|
130
|
-
## Chain
|
|
113
|
+
## Chain (batch multiple operations)
|
|
131
114
|
|
|
132
|
-
|
|
115
|
+
When you have two or more **independent** operations, use `ghx chain`. It batches them into as few GraphQL round-trips as possible (typically one), which is significantly faster than running them sequentially. Steps are not transactional — a `"partial"` result is possible if one step fails after others succeed.
|
|
133
116
|
|
|
134
117
|
```bash
|
|
135
118
|
ghx chain --steps - <<'EOF'
|
|
@@ -140,8 +123,54 @@ ghx chain --steps - <<'EOF'
|
|
|
140
123
|
EOF
|
|
141
124
|
```
|
|
142
125
|
|
|
143
|
-
**Result:** `{ status, results[] }`. Each
|
|
126
|
+
**Result:** `{ status, results[] }`. Each element: `{ task, ok, data? }` or `{ task, ok, error: { code, message } }`.
|
|
127
|
+
|
|
128
|
+
**When NOT to chain:** Don't chain when a later step depends on the result of an earlier one. For example, "check CI, then fetch logs only if something failed" requires two sequential calls because the second depends on the first result. Similarly, "create an issue, then label it" needs the issue number from the create step before labeling.
|
|
129
|
+
|
|
130
|
+
## Error handling
|
|
131
|
+
|
|
132
|
+
ghx never throws — errors are always in the response envelope. Check the `ok` field:
|
|
133
|
+
- `ok: true` — success, data is in `data`
|
|
134
|
+
- `ok: false` — failure, details in `error.code` and `error.message`
|
|
135
|
+
|
|
136
|
+
Common error codes: `AUTH`, `NOT_FOUND`, `VALIDATION`, `RATE_LIMIT`, `NETWORK`, `SERVER`.
|
|
137
|
+
|
|
138
|
+
If you get `RATE_LIMIT` or `NETWORK`, retry after a short delay. For `NOT_FOUND`, double-check owner/name/number. For `VALIDATION`, run `ghx capabilities explain <id>` to check the expected schema.
|
|
139
|
+
|
|
140
|
+
## Common workflow patterns
|
|
141
|
+
|
|
142
|
+
### PR merge readiness audit
|
|
143
|
+
Use `ghx chain` with `pr.checks.list`, `pr.threads.list`, and `pr.merge.status` in one call to get all three signals at once.
|
|
144
|
+
|
|
145
|
+
### Review a PR (read diff, check threads, submit review)
|
|
146
|
+
1. `pr.diff.view` — read the full diff
|
|
147
|
+
2. `pr.threads.list` — see existing unresolved review comments
|
|
148
|
+
3. `pr.reviews.submit` — submit your review with inline comments
|
|
149
|
+
|
|
150
|
+
### Respond to all unresolved review threads
|
|
151
|
+
1. `pr.threads.list` — get all unresolved threads (returns `threadId` for each)
|
|
152
|
+
2. `ghx chain` with multiple `pr.threads.reply` steps — reply to each thread in one batch
|
|
153
|
+
|
|
154
|
+
### Check CI status and debug failures (sequential -- don't chain)
|
|
155
|
+
1. `pr.checks.list` — see which checks passed/failed
|
|
156
|
+
2. Only if something failed: `workflow.run.view` — get job details for the failed run
|
|
157
|
+
3. Only if needed: `workflow.job.logs.view` — read the failure logs
|
|
158
|
+
|
|
159
|
+
### Triage an issue (label, assign, comment)
|
|
160
|
+
Use `ghx chain` with `issue.labels.add`, `issue.assignees.add`, and `issue.comments.create` in one call.
|
|
161
|
+
|
|
162
|
+
### Create an issue then configure it (sequential then batch)
|
|
163
|
+
1. `issue.create` — get the new issue number
|
|
164
|
+
2. `ghx chain` with `issue.labels.add`, `issue.assignees.add`, `issue.comments.create` — batch all mutations using the number from step 1
|
|
165
|
+
|
|
166
|
+
### Create a PR from current branch
|
|
167
|
+
1. Infer owner/name from git remote
|
|
168
|
+
2. Get current branch: `git branch --show-current`
|
|
169
|
+
3. `pr.create` with `head` = current branch, `base` = main/master
|
|
144
170
|
|
|
145
|
-
|
|
171
|
+
## Important rules
|
|
146
172
|
|
|
147
|
-
|
|
173
|
+
- Prefer `ghx` over `gh`, `gh api`, or `curl` for any GitHub operation that has a matching capability.
|
|
174
|
+
- Use `ghx chain` when you have 2+ **independent** operations — it is faster and avoids mid-sequence failures.
|
|
175
|
+
- Always use heredoc (`<<'EOF'`) for JSON input, never inline `--input '{...}'`.
|
|
176
|
+
- Infer owner/name from `git remote get-url origin` when in a git repository.
|
|
File without changes
|