@ghx-dev/core 0.2.0 → 0.2.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.
Files changed (161) hide show
  1. package/.claude-plugin/plugin.json +2 -2
  2. package/README.md +68 -224
  3. package/dist/cards/issue.assignees.add.yaml +1 -0
  4. package/dist/cards/issue.assignees.remove.yaml +1 -0
  5. package/dist/cards/issue.assignees.set.yaml +1 -0
  6. package/dist/cards/issue.close.yaml +1 -0
  7. package/dist/cards/issue.comments.create.yaml +1 -0
  8. package/dist/cards/issue.comments.list.yaml +1 -0
  9. package/dist/cards/issue.create.yaml +1 -0
  10. package/dist/cards/issue.delete.yaml +1 -0
  11. package/dist/cards/issue.labels.add.yaml +1 -0
  12. package/dist/cards/issue.labels.remove.yaml +1 -0
  13. package/dist/cards/issue.labels.set.yaml +1 -0
  14. package/dist/cards/issue.list.yaml +1 -0
  15. package/dist/cards/issue.milestone.clear.yaml +1 -0
  16. package/dist/cards/issue.milestone.set.yaml +1 -0
  17. package/dist/cards/issue.relations.blocked_by.add.yaml +1 -0
  18. package/dist/cards/issue.relations.blocked_by.remove.yaml +1 -0
  19. package/dist/cards/issue.relations.parent.remove.yaml +1 -0
  20. package/dist/cards/issue.relations.parent.set.yaml +1 -0
  21. package/dist/cards/issue.relations.prs.list.yaml +1 -0
  22. package/dist/cards/issue.relations.view.yaml +1 -0
  23. package/dist/cards/issue.reopen.yaml +1 -0
  24. package/dist/cards/issue.update.yaml +1 -0
  25. package/dist/cards/issue.view.yaml +1 -0
  26. package/dist/cards/pr.assignees.add.yaml +6 -2
  27. package/dist/cards/pr.assignees.remove.yaml +6 -2
  28. package/dist/cards/pr.branch.update.yaml +6 -2
  29. package/dist/cards/pr.create.yaml +7 -3
  30. package/dist/cards/pr.diff.files.yaml +1 -0
  31. package/dist/cards/pr.list.yaml +1 -0
  32. package/dist/cards/pr.merge.status.yaml +1 -0
  33. package/dist/cards/pr.merge.yaml +9 -3
  34. package/dist/cards/pr.reviews.list.yaml +1 -0
  35. package/dist/cards/pr.reviews.request.yaml +6 -3
  36. package/dist/cards/pr.reviews.submit.yaml +1 -0
  37. package/dist/cards/pr.threads.list.yaml +1 -0
  38. package/dist/cards/pr.threads.reply.yaml +1 -0
  39. package/dist/cards/pr.threads.resolve.yaml +1 -0
  40. package/dist/cards/pr.threads.unresolve.yaml +1 -0
  41. package/dist/cards/pr.update.yaml +7 -2
  42. package/dist/cards/pr.view.yaml +1 -0
  43. package/dist/cards/project_v2.fields.list.yaml +18 -2
  44. package/dist/cards/project_v2.items.field.update.yaml +8 -5
  45. package/dist/cards/project_v2.items.issue.add.yaml +9 -5
  46. package/dist/cards/project_v2.items.issue.remove.yaml +8 -5
  47. package/dist/cards/project_v2.items.list.yaml +8 -2
  48. package/dist/cards/project_v2.org.view.yaml +6 -2
  49. package/dist/cards/project_v2.user.view.yaml +6 -2
  50. package/dist/cards/release.list.yaml +8 -3
  51. package/dist/cards/release.view.yaml +8 -4
  52. package/dist/cards/repo.issue_types.list.yaml +7 -3
  53. package/dist/cards/repo.labels.list.yaml +7 -2
  54. package/dist/cards/repo.view.yaml +1 -0
  55. package/dist/chunk-7HUKYNI2.js +536 -0
  56. package/dist/chunk-7HUKYNI2.js.map +1 -0
  57. package/dist/{chunk-HEHONZTO.js → chunk-C2KRRSSX.js} +1 -1
  58. package/dist/chunk-C2KRRSSX.js.map +1 -0
  59. package/dist/chunk-GQO6BHJV.js +98 -0
  60. package/dist/chunk-GQO6BHJV.js.map +1 -0
  61. package/dist/chunk-H7CLZHRO.js +280 -0
  62. package/dist/chunk-H7CLZHRO.js.map +1 -0
  63. package/dist/chunk-NQ53ETYV.js +128 -0
  64. package/dist/chunk-NQ53ETYV.js.map +1 -0
  65. package/dist/{chunk-BIWBJA2F.js → chunk-OQWLEFAH.js} +220 -12
  66. package/dist/chunk-OQWLEFAH.js.map +1 -0
  67. package/dist/{chunk-Q7RCIK2C.js → chunk-Q2NW7DJE.js} +167 -62
  68. package/dist/chunk-Q2NW7DJE.js.map +1 -0
  69. package/dist/{pr-queries-UOEOXIJQ.js → chunk-QRHKAMRY.js} +11 -131
  70. package/dist/chunk-QRHKAMRY.js.map +1 -0
  71. package/dist/{chunk-3P3KHWFU.js → chunk-T3L2VDOS.js} +1080 -727
  72. package/dist/chunk-T3L2VDOS.js.map +1 -0
  73. package/dist/{issue-queries-GRA4MKPD.js → chunk-TGL33GEA.js} +7 -83
  74. package/dist/chunk-TGL33GEA.js.map +1 -0
  75. package/dist/chunk-ZGBVX2VG.js +32 -0
  76. package/dist/chunk-ZGBVX2VG.js.map +1 -0
  77. package/dist/cli/index.js +80 -15
  78. package/dist/cli/index.js.map +1 -1
  79. package/dist/core/registry/cards/issue.assignees.add.yaml +1 -0
  80. package/dist/core/registry/cards/issue.assignees.remove.yaml +1 -0
  81. package/dist/core/registry/cards/issue.assignees.set.yaml +1 -0
  82. package/dist/core/registry/cards/issue.close.yaml +1 -0
  83. package/dist/core/registry/cards/issue.comments.create.yaml +1 -0
  84. package/dist/core/registry/cards/issue.comments.list.yaml +1 -0
  85. package/dist/core/registry/cards/issue.create.yaml +1 -0
  86. package/dist/core/registry/cards/issue.delete.yaml +1 -0
  87. package/dist/core/registry/cards/issue.labels.add.yaml +1 -0
  88. package/dist/core/registry/cards/issue.labels.remove.yaml +1 -0
  89. package/dist/core/registry/cards/issue.labels.set.yaml +1 -0
  90. package/dist/core/registry/cards/issue.list.yaml +1 -0
  91. package/dist/core/registry/cards/issue.milestone.clear.yaml +1 -0
  92. package/dist/core/registry/cards/issue.milestone.set.yaml +1 -0
  93. package/dist/core/registry/cards/issue.relations.blocked_by.add.yaml +1 -0
  94. package/dist/core/registry/cards/issue.relations.blocked_by.remove.yaml +1 -0
  95. package/dist/core/registry/cards/issue.relations.parent.remove.yaml +1 -0
  96. package/dist/core/registry/cards/issue.relations.parent.set.yaml +1 -0
  97. package/dist/core/registry/cards/issue.relations.prs.list.yaml +1 -0
  98. package/dist/core/registry/cards/issue.relations.view.yaml +1 -0
  99. package/dist/core/registry/cards/issue.reopen.yaml +1 -0
  100. package/dist/core/registry/cards/issue.update.yaml +1 -0
  101. package/dist/core/registry/cards/issue.view.yaml +1 -0
  102. package/dist/core/registry/cards/pr.assignees.add.yaml +6 -2
  103. package/dist/core/registry/cards/pr.assignees.remove.yaml +6 -2
  104. package/dist/core/registry/cards/pr.branch.update.yaml +6 -2
  105. package/dist/core/registry/cards/pr.create.yaml +7 -3
  106. package/dist/core/registry/cards/pr.diff.files.yaml +1 -0
  107. package/dist/core/registry/cards/pr.list.yaml +1 -0
  108. package/dist/core/registry/cards/pr.merge.status.yaml +1 -0
  109. package/dist/core/registry/cards/pr.merge.yaml +9 -3
  110. package/dist/core/registry/cards/pr.reviews.list.yaml +1 -0
  111. package/dist/core/registry/cards/pr.reviews.request.yaml +6 -3
  112. package/dist/core/registry/cards/pr.reviews.submit.yaml +1 -0
  113. package/dist/core/registry/cards/pr.threads.list.yaml +1 -0
  114. package/dist/core/registry/cards/pr.threads.reply.yaml +1 -0
  115. package/dist/core/registry/cards/pr.threads.resolve.yaml +1 -0
  116. package/dist/core/registry/cards/pr.threads.unresolve.yaml +1 -0
  117. package/dist/core/registry/cards/pr.update.yaml +7 -2
  118. package/dist/core/registry/cards/pr.view.yaml +1 -0
  119. package/dist/core/registry/cards/project_v2.fields.list.yaml +18 -2
  120. package/dist/core/registry/cards/project_v2.items.field.update.yaml +8 -5
  121. package/dist/core/registry/cards/project_v2.items.issue.add.yaml +9 -5
  122. package/dist/core/registry/cards/project_v2.items.issue.remove.yaml +8 -5
  123. package/dist/core/registry/cards/project_v2.items.list.yaml +8 -2
  124. package/dist/core/registry/cards/project_v2.org.view.yaml +6 -2
  125. package/dist/core/registry/cards/project_v2.user.view.yaml +6 -2
  126. package/dist/core/registry/cards/release.list.yaml +8 -3
  127. package/dist/core/registry/cards/release.view.yaml +8 -4
  128. package/dist/core/registry/cards/repo.issue_types.list.yaml +7 -3
  129. package/dist/core/registry/cards/repo.labels.list.yaml +7 -2
  130. package/dist/core/registry/cards/repo.view.yaml +1 -0
  131. package/dist/index.d.ts +457 -0
  132. package/dist/index.js +12 -4
  133. package/dist/index.js.map +1 -1
  134. package/dist/{issue-mutations-FJNZW7L5.js → issue-mutations-DIWPF3JH.js} +98 -121
  135. package/dist/issue-mutations-DIWPF3JH.js.map +1 -0
  136. package/dist/issue-queries-YQL65J7X.js +93 -0
  137. package/dist/issue-queries-YQL65J7X.js.map +1 -0
  138. package/dist/{pr-mutations-UG67YOF5.js → pr-mutations-BVHDCAPR.js} +235 -95
  139. package/dist/pr-mutations-BVHDCAPR.js.map +1 -0
  140. package/dist/pr-queries-NUL2UZJB.js +143 -0
  141. package/dist/pr-queries-NUL2UZJB.js.map +1 -0
  142. package/dist/project-3ZSPVIOC.js +429 -0
  143. package/dist/project-3ZSPVIOC.js.map +1 -0
  144. package/dist/release-IQCWD655.js +57 -0
  145. package/dist/release-IQCWD655.js.map +1 -0
  146. package/dist/repo-JF47JAZG.js +82 -0
  147. package/dist/repo-JF47JAZG.js.map +1 -0
  148. package/package.json +9 -9
  149. package/skills/using-ghx/SKILL.md +78 -10
  150. package/dist/chunk-3P3KHWFU.js.map +0 -1
  151. package/dist/chunk-BIWBJA2F.js.map +0 -1
  152. package/dist/chunk-HEHONZTO.js.map +0 -1
  153. package/dist/chunk-Q7RCIK2C.js.map +0 -1
  154. package/dist/chunk-TDABI6C7.js +0 -167
  155. package/dist/chunk-TDABI6C7.js.map +0 -1
  156. package/dist/issue-mutations-FJNZW7L5.js.map +0 -1
  157. package/dist/issue-queries-GRA4MKPD.js.map +0 -1
  158. package/dist/pr-mutations-UG67YOF5.js.map +0 -1
  159. package/dist/pr-queries-UOEOXIJQ.js.map +0 -1
  160. package/dist/repo-JDUHFPZF.js +0 -66
  161. package/dist/repo-JDUHFPZF.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ghx",
3
- "description": "GitHub execution router for AI agents — 66 capabilities with deterministic routing and normalized output",
4
- "version": "0.2.0",
3
+ "description": "GitHub execution router for AI agents — 70 capabilities with deterministic routing and normalized output",
4
+ "version": "0.2.2",
5
5
  "author": {
6
6
  "name": "Arye Kogan"
7
7
  },
package/README.md CHANGED
@@ -1,276 +1,120 @@
1
- # @ghx-dev/core
1
+ <h1 align="center">@ghx-dev/core</h1>
2
2
 
3
3
  <p align="center">
4
4
  <img src="https://raw.githubusercontent.com/aryeko/ghx/main/assets/branding/social/ghx-social-dark-1280x640.png" alt="ghx social preview" width="480">
5
5
  </p>
6
6
 
7
+ <p align="center">
8
+ A typed GitHub execution router that gives AI agents deterministic, token-efficient access to the GitHub API.
9
+ </p>
10
+
7
11
  [![npm version](https://img.shields.io/npm/v/%40ghx-dev%2Fcore)](https://www.npmjs.com/package/@ghx-dev/core)
8
12
  [![npm downloads](https://img.shields.io/npm/dm/%40ghx-dev%2Fcore)](https://www.npmjs.com/package/@ghx-dev/core)
9
13
  [![CI (main)](https://github.com/aryeko/ghx/actions/workflows/ci-main.yml/badge.svg)](https://github.com/aryeko/ghx/actions/workflows/ci-main.yml)
10
14
  [![codecov](https://codecov.io/gh/aryeko/ghx/graph/badge.svg?token=KBIGR138V7)](https://codecov.io/gh/aryeko/ghx)
11
15
  [![License](https://img.shields.io/npm/l/%40ghx-dev%2Fcore)](https://github.com/aryeko/ghx/blob/main/LICENSE)
12
16
 
13
- Typed GitHub execution router for AI agents. Deterministic routing across CLI and GraphQL, runtime schema validation, and a stable result envelope -- so agents stop wasting tokens re-discovering GitHub API surfaces.
14
-
15
- ## Why ghx
16
-
17
- Agents instructed to "use `gh` CLI" for common PR and issue operations waste significant tokens on research, trial-and-error, and output parsing. Benchmarked across 27 runs on standard PR workflows:
18
-
19
- | Metric | Improvement |
20
- |---|---|
21
- | Active tokens | **-37%** fewer tokens consumed |
22
- | Latency | **-32%** faster end-to-end |
23
- | Tool calls | **-33%** fewer tool invocations |
24
- | Success rate | **100%** (zero regressions) |
25
-
26
- ghx eliminates the discovery phase: agents call typed capabilities, get validated results back in a stable envelope.
27
-
28
- ## Installation
29
-
30
- Requirements: Node.js `22+`, `gh` CLI authenticated (`gh auth status`).
31
-
32
- ```bash
33
- npm install @ghx-dev/core
17
+ ## Why ghx?
18
+
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
+
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
+ ```mermaid
24
+ sequenceDiagram
25
+ participant Agent
26
+ participant ghx as ghx
27
+ participant GH as GitHub API
28
+
29
+ %% Agent requests a typed execution
30
+ Agent->>ghx: executeTask("pr.view", { owner, name, prNumber })
31
+
32
+ %% ghx routing engine takes over
33
+ Note over ghx: 1. Validate input schema<br/>2. Select optimal route (GraphQL/CLI)<br/>3. Run preflight checks
34
+ ghx->>GH: typed GraphQL request
35
+ GH-->>ghx: response
36
+ Note over ghx: normalize errors & structure
37
+
38
+ %% Stable envelope returned
39
+ ghx-->>Agent: ResultEnvelope { ok: true, data: { ... } }
34
40
  ```
35
41
 
36
- Alternative package managers:
37
-
38
- ```bash
39
- pnpm add @ghx-dev/core
40
- # or
41
- yarn add @ghx-dev/core
42
- ```
42
+ ## Features
43
43
 
44
- Or run directly without installing:
44
+ - **70+ Declarative Capabilities**: PRs, issues, labels, workflows, projects, releases — all defined by versioned YAML operation cards.
45
+ - **Deterministic Routing**: The agent doesn't choose CLI vs. GraphQL. ghx evaluates suitability rules and picks the optimal route automatically, with built-in fallbacks.
46
+ - **Stable Result Envelope**: No try/catch needed. Every execution returns `{ ok, data, error, meta }`. Errors are mapped to standard codes (`AUTH`, `RATE_LIMIT`, `NOT_FOUND`, etc.).
47
+ - **Chaining & Batching**: Execute multiple steps (`add label`, `add assignee`, `comment`) in one call. ghx resolves node IDs and batches them into a single network request.
48
+ - **Type Safety**: Full TypeScript schemas for inputs and outputs (via generated GraphQL types).
45
49
 
46
- ```bash
47
- npx @ghx-dev/core capabilities list
48
- ```
50
+ ## Documentation
49
51
 
50
- Global CLI install:
52
+ Comprehensive documentation is available in the [`docs/`](./docs/) directory:
51
53
 
52
- ```bash
53
- npm i -g @ghx-dev/core
54
- ```
54
+ - **[Getting Started](./docs/getting-started/README.md)** — Installation, why ghx, and use case diagrams.
55
+ - [Library Quickstart](./docs/getting-started/library-quickstart.md)
56
+ - [CLI Quickstart](./docs/getting-started/cli-quickstart.md)
57
+ - [Agent Setup](./docs/getting-started/agent-setup.md)
58
+ - **[Concepts](./docs/concepts/README.md)** — How ghx works internally (Routing Engine, Operation Cards, Result Envelope, Chaining).
59
+ - **[Architecture](./docs/architecture/README.md)** — System design, execution pipeline, formatters, and GraphQL layer.
60
+ - **[Reference](./docs/reference/README.md)** — API exports, error codes, and a complete table of all 70+ capabilities.
55
61
 
56
- ## Quick Start (CLI)
57
-
58
- Set `GITHUB_TOKEN` or `GH_TOKEN` in your environment, then:
62
+ ## Quick Start (Library)
59
63
 
60
64
  ```bash
61
- npx @ghx-dev/core capabilities list
62
- npx @ghx-dev/core capabilities explain repo.view
63
- npx @ghx-dev/core run repo.view --input '{"owner":"aryeko","name":"ghx"}'
64
- ```
65
-
66
- If installed globally, replace `npx @ghx-dev/core` with `ghx`.
67
-
68
- Every capability returns a stable envelope:
69
-
70
- ```json
71
- {
72
- "ok": true,
73
- "data": {
74
- "id": "R_kgDOOx...",
75
- "name": "ghx",
76
- "nameWithOwner": "aryeko/ghx"
77
- },
78
- "error": null,
79
- "meta": {
80
- "capability_id": "repo.view",
81
- "route_used": "cli",
82
- "reason": "CARD_PREFERRED"
83
- }
84
- }
65
+ npm install @ghx-dev/core
85
66
  ```
86
67
 
87
- ## Quick Start (Library API)
88
-
89
68
  ```ts
90
69
  import { createGithubClientFromToken, executeTask } from "@ghx-dev/core"
91
70
 
92
71
  const token = process.env.GITHUB_TOKEN!
93
72
  const githubClient = createGithubClientFromToken(token)
94
73
 
74
+ // Execute a task: input is validated, optimal route is chosen
95
75
  const result = await executeTask(
96
76
  { task: "repo.view", input: { owner: "aryeko", name: "ghx" } },
97
77
  { githubClient, githubToken: token },
98
78
  )
99
79
 
100
80
  if (result.ok) {
101
- console.log(result.data)
81
+ console.log("Success:", result.data.nameWithOwner)
82
+ console.log("Route used:", result.meta.route_used) // e.g. "graphql"
102
83
  } else {
103
- console.error(result.error?.code, result.error?.message)
84
+ console.error("Failed:", result.error.code) // e.g. "NOT_FOUND"
85
+ console.error("Retryable?", result.error.retryable)
104
86
  }
105
87
  ```
106
88
 
107
- Need a custom GraphQL transport? Use `createGithubClient(transport)` instead -- see the [advanced usage section](#custom-graphql-transport).
108
-
109
- ## Agent Onboarding
89
+ ## Quick Start (CLI)
110
90
 
111
- Install ghx as a project skill for Claude Code:
91
+ Use ghx directly from your terminal or add it as an agent skill.
112
92
 
113
93
  ```bash
114
- npx @ghx-dev/core setup --scope project --yes
115
- npx @ghx-dev/core setup --scope project --verify
116
- ```
117
-
118
- ### Setup Skill Source
119
-
120
- The canonical setup skill content is stored in:
121
-
122
- - `skills/using-ghx/SKILL.md` (package root)
123
-
124
- During build/publish it is copied to:
125
-
126
- - `dist/skills/using-ghx/SKILL.md`
127
-
128
- `ghx setup` writes this content to `.agents/skills/ghx/SKILL.md` in user or project scope.
129
-
130
- ## Agent Tools
131
-
132
- ```ts
133
- import {
134
- createExecuteTool,
135
- createGithubClientFromToken,
136
- executeTask,
137
- explainCapability,
138
- listCapabilities,
139
- } from "@ghx-dev/core"
140
-
141
- // Wire the execute tool to the real engine
142
- const token = process.env.GITHUB_TOKEN!
143
- const githubClient = createGithubClientFromToken(token)
144
-
145
- const tool = createExecuteTool({
146
- executeTask: (request) => executeTask(request, { githubClient, githubToken: token }),
147
- })
148
-
149
- // Discover and execute capabilities
150
- console.log(listCapabilities())
151
- console.log(explainCapability("repo.view"))
152
- const result = await tool.execute("repo.view", { owner: "aryeko", name: "ghx" })
153
- ```
154
-
155
- ## 69 Capabilities
156
-
157
- **Repository** -- `repo.view`, `repo.labels.list`, `repo.issue_types.list`
158
-
159
- **Issues** -- `issue.view`, `issue.list`, `issue.comments.list`, `issue.create`, `issue.update`, `issue.close`, `issue.reopen`, `issue.delete`, `issue.labels.update`, `issue.assignees.update`, `issue.milestone.set`, `issue.comments.create`, `issue.linked_prs.list`, `issue.relations.get`, `issue.parent.set`, `issue.parent.remove`, `issue.blocked_by.add`, `issue.blocked_by.remove`
160
-
161
- **Pull Requests (read)** -- `pr.view`, `pr.list`, `pr.threads.list`, `pr.reviews.list`, `pr.diff.files`, `pr.checks.list`, `pr.merge.status`
162
-
163
- **Pull Requests (execute)** -- `pr.threads.reply`, `pr.threads.resolve`, `pr.threads.unresolve`, `pr.update`, `pr.reviews.submit`, `pr.reviews.request`, `pr.merge`, `pr.checks.rerun.failed`, `pr.checks.rerun.all`, `pr.branch.update`, `pr.assignees.add`, `pr.assignees.remove`
164
-
165
- **CI Diagnostics** -- `workflow.runs.list`, `workflow.job.logs.get`
166
-
167
- **Releases** -- `release.list`, `release.get`, `release.create_draft`, `release.update`, `release.publish_draft`
168
-
169
- **Workflow Controls** -- `workflow.list`, `workflow.get`, `workflow_dispatch.run`, `workflow_run.view`, `workflow_run.rerun_failed`, `workflow_run.rerun_all`, `workflow_run.cancel`, `workflow_run.artifacts.list`
170
-
171
- **Projects v2** -- `project_v2.org.get`, `project_v2.user.get`, `project_v2.fields.list`, `project_v2.items.list`, `project_v2.item.add_issue`, `project_v2.item.field.update`
172
-
173
- For exact input/output contracts, see the [operation card registry](https://github.com/aryeko/ghx/tree/main/packages/core/src/core/registry/cards).
174
-
175
- ## Result Envelope
94
+ # List all 70+ capabilities
95
+ npx @ghx-dev/core capabilities list
176
96
 
177
- All execution paths resolve to:
97
+ # Run a capability
98
+ npx @ghx-dev/core run pr.view --input '{"owner":"aryeko","name":"ghx","number":42}'
178
99
 
179
- ```ts
180
- type ResultEnvelope<TData = unknown> = {
181
- ok: boolean
182
- data?: TData
183
- error?: {
184
- code: string // AUTH, NOT_FOUND, RATE_LIMIT, VALIDATION, ...
185
- message: string
186
- retryable: boolean
187
- details?: Record<string, unknown>
188
- }
189
- meta: {
190
- capability_id: string
191
- route_used?: "cli" | "graphql" | "rest"
192
- reason?: string
193
- attempts?: Array<{
194
- route: "cli" | "graphql" | "rest"
195
- status: "success" | "error" | "skipped"
196
- error_code?: string
197
- duration_ms?: number
198
- }>
199
- }
200
- }
100
+ # Output is a standard ResultEnvelope:
101
+ # {
102
+ # "ok": true,
103
+ # "data": { ... },
104
+ # "meta": { "capability_id": "pr.view", "route_used": "graphql", ... }
105
+ # }
201
106
  ```
202
107
 
203
- ## Environment Variables
108
+ ## Agent Integration
204
109
 
205
- - `GITHUB_TOKEN` or `GH_TOKEN` (required)
206
- - `GITHUB_GRAPHQL_URL` (optional; override GraphQL endpoint)
207
- - `GH_HOST` (optional; derives enterprise GraphQL endpoint)
110
+ To install the `ghx` skill for Claude Code:
208
111
 
209
- ## Security and Permissions
210
-
211
- - Start with least privilege and grant only what your capability set needs.
212
- - For quick local testing, a classic PAT with `repo` scope is the simplest route.
213
- - For production agents, prefer fine-grained tokens with read permissions first (`Metadata`, `Contents`, `Pull requests`, `Issues`, `Actions`, `Projects`) and add writes only where needed.
214
-
215
- ## Compatibility
216
-
217
- - Node.js `22+`
218
- - GitHub Cloud and GitHub Enterprise hosts (`GH_HOST` supported)
219
- - Route adapters: CLI and GraphQL
220
-
221
- ## Public Exports
222
-
223
- Root (`@ghx-dev/core`):
224
-
225
- - `executeTask` -- run a capability
226
- - `createGithubClientFromToken` -- create a client from a token string
227
- - `createGithubClient`, `createGraphqlClient` -- create clients from a custom transport
228
- - `listOperationCards`, `getOperationCard` -- inspect capability registry
229
- - `createSafeCliCommandRunner` -- custom CLI execution
230
- - Types: `TaskRequest`, `ResultEnvelope`, `ResultError`, `ResultMeta`, `AttemptMeta`, `RouteSource`, `RouteReasonCode`, `TokenClientOptions`
231
-
232
- Subpaths:
233
-
234
- - `@ghx-dev/core/cli` -- CLI entrypoint
235
-
236
- ## Custom GraphQL Transport
237
-
238
- For full control over the GraphQL layer, pass your own transport to `createGithubClient`:
239
-
240
- ```ts
241
- import { createGithubClient, executeTask } from "@ghx-dev/core"
242
-
243
- const githubClient = createGithubClient({
244
- async execute<TData>(query: string, variables?: Record<string, unknown>): Promise<TData> {
245
- const response = await fetch("https://api.github.com/graphql", {
246
- method: "POST",
247
- headers: {
248
- "content-type": "application/json",
249
- authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
250
- },
251
- body: JSON.stringify({ query, variables: variables ?? {} }),
252
- })
253
- const payload = (await response.json()) as { data?: TData; errors?: Array<{ message?: string }> }
254
- if (payload.errors?.length) throw new Error(payload.errors[0]?.message ?? "GraphQL error")
255
- if (payload.data === undefined) throw new Error("GraphQL response missing data")
256
- return payload.data
257
- },
258
- })
259
-
260
- const result = await executeTask(
261
- { task: "repo.view", input: { owner: "aryeko", name: "ghx" } },
262
- { githubClient, githubToken: process.env.GITHUB_TOKEN },
263
- )
112
+ ```bash
113
+ npx @ghx-dev/core setup --scope project --yes
264
114
  ```
265
115
 
266
- ## Documentation
267
-
268
- - [Documentation Hub](https://github.com/aryeko/ghx/blob/main/docs/README.md)
269
- - [Architecture](https://github.com/aryeko/ghx/blob/main/docs/architecture/README.md)
270
- - [Capabilities Reference](https://github.com/aryeko/ghx/blob/main/docs/capabilities/README.md)
271
- - [Operation Cards](https://github.com/aryeko/ghx/blob/main/docs/architecture/operation-cards.md)
272
- - [Publishing Guide](https://github.com/aryeko/ghx/blob/main/docs/contributing/publishing.md)
116
+ This installs `.agents/skills/ghx/SKILL.md` which teaches Claude how to use `npx @ghx-dev/core` for reliable GitHub interactions.
273
117
 
274
118
  ## License
275
119
 
276
- MIT - https://github.com/aryeko/ghx/blob/main/LICENSE
120
+ MIT
@@ -27,6 +27,7 @@ routing:
27
27
  fallbacks: [cli]
28
28
  graphql:
29
29
  operationName: IssueAssigneesAdd
30
+ operationType: mutation
30
31
  documentPath: src/gql/operations/issue-assignees-add.graphql
31
32
  resolution:
32
33
  lookup:
@@ -27,6 +27,7 @@ routing:
27
27
  fallbacks: [cli]
28
28
  graphql:
29
29
  operationName: IssueAssigneesRemove
30
+ operationType: mutation
30
31
  documentPath: src/gql/operations/issue-assignees-remove.graphql
31
32
  resolution:
32
33
  lookup:
@@ -26,6 +26,7 @@ routing:
26
26
  fallbacks: []
27
27
  graphql:
28
28
  operationName: IssueAssigneesUpdate
29
+ operationType: mutation
29
30
  documentPath: src/gql/operations/issue-assignees-update.graphql
30
31
  resolution:
31
32
  lookup:
@@ -23,6 +23,7 @@ routing:
23
23
  fallbacks: []
24
24
  graphql:
25
25
  operationName: IssueClose
26
+ operationType: mutation
26
27
  documentPath: src/gql/operations/issue-close.graphql
27
28
  resolution:
28
29
  lookup:
@@ -23,6 +23,7 @@ routing:
23
23
  fallbacks: []
24
24
  graphql:
25
25
  operationName: IssueCommentCreate
26
+ operationType: mutation
26
27
  documentPath: src/gql/operations/issue-comment-create.graphql
27
28
  resolution:
28
29
  lookup:
@@ -43,6 +43,7 @@ routing:
43
43
  - CLI fallback uses gh api graphql with bounded cursor pagination for comments.
44
44
  graphql:
45
45
  operationName: IssueCommentsList
46
+ operationType: query
46
47
  documentPath: src/gql/operations/issue-comments-list.graphql
47
48
  cli:
48
49
  command: api graphql
@@ -25,6 +25,7 @@ routing:
25
25
  fallbacks: []
26
26
  graphql:
27
27
  operationName: IssueCreate
28
+ operationType: mutation
28
29
  documentPath: src/gql/operations/issue-create.graphql
29
30
  resolution:
30
31
  lookup:
@@ -22,6 +22,7 @@ routing:
22
22
  fallbacks: []
23
23
  graphql:
24
24
  operationName: IssueDelete
25
+ operationType: mutation
25
26
  documentPath: src/gql/operations/issue-delete.graphql
26
27
  resolution:
27
28
  lookup:
@@ -27,6 +27,7 @@ routing:
27
27
  fallbacks: []
28
28
  graphql:
29
29
  operationName: IssueLabelsAdd
30
+ operationType: mutation
30
31
  documentPath: src/gql/operations/issue-labels-add.graphql
31
32
  resolution:
32
33
  lookup:
@@ -27,6 +27,7 @@ routing:
27
27
  fallbacks: [cli]
28
28
  graphql:
29
29
  operationName: IssueLabelsRemove
30
+ operationType: mutation
30
31
  documentPath: src/gql/operations/issue-labels-remove.graphql
31
32
  resolution:
32
33
  lookup:
@@ -26,6 +26,7 @@ routing:
26
26
  fallbacks: []
27
27
  graphql:
28
28
  operationName: IssueLabelsUpdate
29
+ operationType: mutation
29
30
  documentPath: src/gql/operations/issue-labels-update.graphql
30
31
  resolution:
31
32
  lookup:
@@ -42,6 +42,7 @@ routing:
42
42
  - Prefer CLI for low-latency structured fetches when gh authentication is available.
43
43
  graphql:
44
44
  operationName: IssueList
45
+ operationType: query
45
46
  documentPath: src/gql/operations/issue-list.graphql
46
47
  cli:
47
48
  command: issue list
@@ -21,6 +21,7 @@ routing:
21
21
  fallbacks: [cli]
22
22
  graphql:
23
23
  operationName: IssueMilestoneSet
24
+ operationType: mutation
24
25
  documentPath: src/gql/operations/issue-milestone-set.graphql
25
26
  resolution:
26
27
  lookup:
@@ -23,6 +23,7 @@ routing:
23
23
  fallbacks: []
24
24
  graphql:
25
25
  operationName: IssueMilestoneSet
26
+ operationType: mutation
26
27
  documentPath: src/gql/operations/issue-milestone-set.graphql
27
28
  resolution:
28
29
  lookup:
@@ -21,4 +21,5 @@ routing:
21
21
  fallbacks: []
22
22
  graphql:
23
23
  operationName: IssueBlockedByAdd
24
+ operationType: mutation
24
25
  documentPath: src/gql/operations/issue-blocked-by-add.graphql
@@ -21,4 +21,5 @@ routing:
21
21
  fallbacks: []
22
22
  graphql:
23
23
  operationName: IssueBlockedByRemove
24
+ operationType: mutation
24
25
  documentPath: src/gql/operations/issue-blocked-by-remove.graphql
@@ -19,6 +19,7 @@ routing:
19
19
  fallbacks: []
20
20
  graphql:
21
21
  operationName: IssueParentRemove
22
+ operationType: mutation
22
23
  documentPath: src/gql/operations/issue-parent-remove.graphql
23
24
  resolution:
24
25
  lookup:
@@ -21,4 +21,5 @@ routing:
21
21
  fallbacks: []
22
22
  graphql:
23
23
  operationName: IssueParentSet
24
+ operationType: mutation
24
25
  documentPath: src/gql/operations/issue-parent-set.graphql
@@ -31,4 +31,5 @@ routing:
31
31
  fallbacks: []
32
32
  graphql:
33
33
  operationName: IssueLinkedPrsList
34
+ operationType: query
34
35
  documentPath: src/gql/operations/issue-linked-prs-list.graphql
@@ -51,4 +51,5 @@ routing:
51
51
  fallbacks: []
52
52
  graphql:
53
53
  operationName: IssueRelationsGet
54
+ operationType: query
54
55
  documentPath: src/gql/operations/issue-relations-get.graphql
@@ -23,6 +23,7 @@ routing:
23
23
  fallbacks: []
24
24
  graphql:
25
25
  operationName: IssueReopen
26
+ operationType: mutation
26
27
  documentPath: src/gql/operations/issue-reopen.graphql
27
28
  resolution:
28
29
  lookup:
@@ -26,6 +26,7 @@ routing:
26
26
  fallbacks: []
27
27
  graphql:
28
28
  operationName: IssueUpdate
29
+ operationType: mutation
29
30
  documentPath: src/gql/operations/issue-update.graphql
30
31
  resolution:
31
32
  lookup:
@@ -28,6 +28,7 @@ routing:
28
28
  - Prefer GraphQL for structured fetch; CLI fallback if gh auth unavailable.
29
29
  graphql:
30
30
  operationName: IssueView
31
+ operationType: query
31
32
  documentPath: src/gql/operations/issue-view.graphql
32
33
  cli:
33
34
  command: issue view
@@ -23,7 +23,11 @@ output_schema:
23
23
  items: { type: string }
24
24
  additionalProperties: false
25
25
  routing:
26
- preferred: cli
27
- fallbacks: []
26
+ preferred: graphql
27
+ fallbacks: [cli]
28
+ graphql:
29
+ operationName: PrAssigneesAdd
30
+ operationType: mutation
31
+ documentPath: src/gql/operations/pr-assignees-add.graphql
28
32
  cli:
29
33
  command: pr edit
@@ -23,7 +23,11 @@ output_schema:
23
23
  items: { type: string }
24
24
  additionalProperties: false
25
25
  routing:
26
- preferred: cli
27
- fallbacks: []
26
+ preferred: graphql
27
+ fallbacks: [cli]
28
+ graphql:
29
+ operationName: PrAssigneesRemove
30
+ operationType: mutation
31
+ documentPath: src/gql/operations/pr-assignees-remove.graphql
28
32
  cli:
29
33
  command: pr edit
@@ -17,7 +17,11 @@ output_schema:
17
17
  updated: { type: boolean }
18
18
  additionalProperties: false
19
19
  routing:
20
- preferred: cli
21
- fallbacks: []
20
+ preferred: graphql
21
+ fallbacks: [cli]
22
+ graphql:
23
+ operationName: PrBranchUpdate
24
+ operationType: mutation
25
+ documentPath: src/gql/operations/pr-branch-update.graphql
22
26
  cli:
23
27
  command: pr update-branch
@@ -3,7 +3,7 @@ version: "1.0.0"
3
3
  description: Create a pull request.
4
4
  input_schema:
5
5
  type: object
6
- required: [owner, name, title, head]
6
+ required: [owner, name, title, head, base]
7
7
  properties:
8
8
  owner: { type: string, minLength: 1 }
9
9
  name: { type: string, minLength: 1 }
@@ -24,7 +24,11 @@ output_schema:
24
24
  draft: { type: boolean }
25
25
  additionalProperties: false
26
26
  routing:
27
- preferred: cli
28
- fallbacks: []
27
+ preferred: graphql
28
+ fallbacks: [cli]
29
+ graphql:
30
+ operationName: PrCreate
31
+ operationType: mutation
32
+ documentPath: src/gql/operations/pr-create.graphql
29
33
  cli:
30
34
  command: pr create
@@ -38,6 +38,7 @@ routing:
38
38
  fallbacks: []
39
39
  graphql:
40
40
  operationName: PrDiffListFiles
41
+ operationType: query
41
42
  documentPath: src/gql/operations/pr-diff-list-files.graphql
42
43
  cli:
43
44
  command: pr view
@@ -42,6 +42,7 @@ routing:
42
42
  - Prefer CLI for low-latency structured fetches when gh authentication is available.
43
43
  graphql:
44
44
  operationName: PrList
45
+ operationType: query
45
46
  documentPath: src/gql/operations/pr-list.graphql
46
47
  cli:
47
48
  command: pr list
@@ -24,6 +24,7 @@ routing:
24
24
  fallbacks: [cli]
25
25
  graphql:
26
26
  operationName: PrMergeStatus
27
+ operationType: query
27
28
  documentPath: src/gql/operations/pr-merge-status.graphql
28
29
  cli:
29
30
  command: pr view