@circuitwall/github-langchain 0.1.0

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/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # Changelog
2
+
3
+ ## [0.1.0] - 2026-06-13
4
+
5
+ ### Added
6
+ - Initial extraction from Jarela.
7
+ - 22 LangChain tools covering the GitHub REST API (issues, pull requests,
8
+ repo content, code search).
9
+ - `setAuthResolver()` API for pluggable credential resolution.
10
+ - Default env-var resolver (`GITHUB_TOKEN`, then `GH_TOKEN`).
11
+ - `githubFetch()` low-level escape hatch (plus `_ghFetch` alias for
12
+ consumers that ported from Jarela's internal name).
13
+ - Pure helpers `truncate()` and `decodeContentsBlob()` for reuse outside
14
+ the LangChain tool wrappers.
15
+ - Pre-grouped capability arrays (`githubReadTools`, `githubWriteTools`,
16
+ `githubExecuteTools`, `githubTools`).
package/LICENSE ADDED
@@ -0,0 +1,17 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ Copyright 2026 Andrew Ge Wu
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,125 @@
1
+ # @circuitwall/github-langchain
2
+
3
+ LangChain tools for the GitHub REST API — direct REST calls, no MCP, no `gh` CLI, proxy-aware.
4
+
5
+ > Extracted from [Jarela](https://github.com/CircuitWall/jarela). Works in any
6
+ > Node 20+ LangChain.js / LangGraph project. Inherits whatever HTTP proxy +
7
+ > CA bundle the host runtime configures, so it works on locked-down corp
8
+ > networks where the MCP install path is blocked.
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ npm install @circuitwall/github-langchain @langchain/core zod
14
+ ```
15
+
16
+ `@langchain/core` and `zod` are peer dependencies — bring your own version.
17
+
18
+ ## Quick start
19
+
20
+ ```ts
21
+ import {
22
+ setAuthResolver,
23
+ githubGetRepoTool,
24
+ githubSearchIssuesTool,
25
+ githubTools,
26
+ } from "@circuitwall/github-langchain";
27
+
28
+ // Option A: rely on env vars (GITHUB_TOKEN or GH_TOKEN). Nothing to do.
29
+
30
+ // Option B: plug in your own credential source (vault, UI form, …).
31
+ setAuthResolver(() => ({
32
+ token: process.env.MY_GITHUB_TOKEN ?? "",
33
+ }));
34
+
35
+ // Use individual tools …
36
+ const result = await githubGetRepoTool.invoke({
37
+ owner: "CircuitWall",
38
+ repo: "jarela",
39
+ });
40
+
41
+ // … or pass the whole array to a LangGraph agent.
42
+ const agent = await createReactAgent({ llm, tools: [...githubTools] });
43
+ ```
44
+
45
+ ## What's in the box
46
+
47
+ 22 tools covering the GitHub REST API.
48
+
49
+ ### Issues
50
+ - `github_search_issues` — full GitHub search syntax (issues + PRs)
51
+ - `github_get_issue`
52
+ - `github_create_issue`
53
+ - `github_update_issue` — title / body / labels / state
54
+ - `github_add_comment`
55
+ - `github_list_issue_comments`
56
+
57
+ ### Pull requests
58
+ - `github_list_pulls`
59
+ - `github_get_pull` — full detail (mergeable, additions, reviews)
60
+ - `github_create_pull`
61
+ - `github_update_pull`
62
+ - `github_merge_pull` — execute capability
63
+ - `github_request_reviewers`
64
+ - `github_create_review` — APPROVE / REQUEST_CHANGES / COMMENT
65
+ - `github_list_pull_files` — with capped patch text
66
+ - `github_list_pull_reviews`
67
+
68
+ ### Repo content
69
+ - `github_get_repo`
70
+ - `github_list_branches`
71
+ - `github_get_file` — capped UTF-8 read, binary-aware
72
+ - `github_search_code`
73
+
74
+ ## Capability groups
75
+
76
+ For tool-policy systems that need read / write / execute partitions:
77
+
78
+ ```ts
79
+ import {
80
+ githubReadTools, // 11 read-only tools
81
+ githubWriteTools, // 7 mutating tools (issues + PRs)
82
+ githubExecuteTools, // 1 merge tool
83
+ } from "@circuitwall/github-langchain";
84
+ ```
85
+
86
+ `github_merge_pull` is in `execute` (not `write`) because merging a PR
87
+ triggers CI, deploys, and downstream automation — a different blast radius
88
+ than editing an issue title.
89
+
90
+ ## Low-level escape hatch
91
+
92
+ For endpoints not yet wrapped as tools:
93
+
94
+ ```ts
95
+ import { githubFetch, resolveGithubAuthFromEnv } from "@circuitwall/github-langchain";
96
+
97
+ const auth = resolveGithubAuthFromEnv();
98
+ if (!("error" in auth)) {
99
+ const data = await githubFetch(auth, "/user");
100
+ }
101
+ ```
102
+
103
+ ## Pure helpers
104
+
105
+ Exported for reuse outside the LangChain tool wrappers:
106
+
107
+ - `truncate(text, cap)` — pure-fn body capping (`{text, truncated}`)
108
+ - `decodeContentsBlob(content, encoding)` — decode `/contents/{path}` blob,
109
+ detect binary, return `{binary, text?, size_bytes}`
110
+
111
+ ## API notes
112
+
113
+ - **Token scopes:** `repo` covers private + public repo content + issues + PRs;
114
+ `read:org` is needed for team-based reviewer requests. Fine-grained tokens
115
+ must explicitly grant each resource.
116
+ - **Code search rate limits:** GitHub's `/search/code` endpoint has stricter
117
+ limits (10/min unauthenticated, 30/min authenticated) than the rest of the
118
+ REST API.
119
+ - **`mergeable: null`:** On a freshly-pushed PR, GitHub computes mergeability
120
+ asynchronously. The first call to `github_get_pull` may return `null`; call
121
+ again after a few seconds.
122
+
123
+ ## License
124
+
125
+ Apache-2.0