@ghx-dev/core 0.4.1 → 0.4.2

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.
@@ -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.1",
4
+ "version": "0.4.2",
5
5
  "author": {
6
6
  "name": "Arye Kogan"
7
7
  },
@@ -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.1" : "unknown";
836
+ const version = true ? "0.4.2" : "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-ISLM2HRZ.js.map
6222
+ //# sourceMappingURL=chunk-EJZDHUZK.js.map
package/dist/cli/index.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  invalidateTokenCache,
11
11
  listCapabilities,
12
12
  resolveGithubToken
13
- } from "../chunk-ISLM2HRZ.js";
13
+ } from "../chunk-EJZDHUZK.js";
14
14
  import "../chunk-H7CLZHRO.js";
15
15
  import "../chunk-NQ53ETYV.js";
16
16
  import "../chunk-TGL33GEA.js";
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  listCapabilities,
13
13
  listOperationCards,
14
14
  resolveGithubToken
15
- } from "./chunk-ISLM2HRZ.js";
15
+ } from "./chunk-EJZDHUZK.js";
16
16
  import "./chunk-H7CLZHRO.js";
17
17
  import "./chunk-NQ53ETYV.js";
18
18
  import "./chunk-TGL33GEA.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ghx-dev/core",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
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",
@@ -1,19 +1,19 @@
1
1
  ---
2
2
  name: using-ghx
3
- description: Executes GitHub operations via ghx. Use for all GitHub interactions instead of raw gh or gh api commands.
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
- ## Authentication
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
- ghx automatically resolves your GitHub token. It checks (in order):
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
- If you are authenticated via `gh auth login`, ghx works out of the box with no extra configuration.
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
- Only if the full input/output schema of a specific capability needed:
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 '...'`.** Inline form breaks with nested quotes and trailing commas in model-generated JSON.
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
- Example (submitting a review with inline comments):
111
+ **Result:** `{ ok, data?, pagination? }` on success — `{ ok, error: { code, message } }` on failure.
112
112
 
113
- ```bash
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
- Use `ghx chain` when you have two or more operations to run. It batches steps into as few GraphQL round-trips as possible (typically one) reducing latency and avoiding mid-sequence failures. Steps are not transactional; a `"partial"` result is possible if one step fails after another has already succeeded.
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 result: `{ task, ok, data? }` on success — `{ task, ok, error: { code, message } }` on failure.
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
- **CRITICAL:** Do not use `gh api` or any other raw `gh` commands unless no matching ghx capability exists. Always try `ghx` first.
171
+ ## Important rules
146
172
 
147
- **IMPORTANT:** Always use `ghx chain` when you have two or more operations to execute in a single call!
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.