@kud/gh 0.5.0 → 0.6.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/dist/inbox.d.ts CHANGED
@@ -12,6 +12,27 @@
12
12
  * beneath each one. A caller that renders a title and a link was paying for
13
13
  * every check run on every open PR. At 111 a poller gets 45 refreshes an hour.
14
14
  */
15
+ /**
16
+ * How many of your own open PRs to ask for.
17
+ *
18
+ * This is the single biggest lever on the query's cost, because connections
19
+ * MULTIPLY: the health and conversation fragments hang ~80 nodes off each PR
20
+ * (`reviewThreads(first: 50)`, `statusCheckRollup.contexts(first: 20)`,
21
+ * `labels(first: 10)`), so the outer number is a multiplier on all of them.
22
+ * GitHub scores a call by the nodes it could return, not by how many calls you
23
+ * make — which is why batching queries saves nothing here and this saves a lot.
24
+ *
25
+ * It was 100, against ~25,550 total nodes and a measured 111 points. 100 × 80 is
26
+ * 8,000 of those nodes from this one search, and it was 100 for no reason beyond
27
+ * the search API's own maximum — every other search here already asks for 20-30.
28
+ * At 30 this search costs 2,400 nodes instead of 8,000, roughly halving the whole
29
+ * query.
30
+ *
31
+ * `issueCount` is fetched alongside so the cap can never drop rows in silence: a
32
+ * scalar costs nothing, and a host that knows the true total can say what it is
33
+ * not showing.
34
+ */
35
+ export declare const MY_PRS_LIMIT = 30;
15
36
  export type InboxShape = "full" | "minimal";
16
37
  /** A repo-scoped or account-wide inbox. */
17
38
  export type InboxQueryOptions = {
@@ -1 +1 @@
1
- {"version":3,"file":"inbox.d.ts","sourceRoot":"","sources":["../src/inbox.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,SAAS,CAAA;AAE3C,2CAA2C;AAC3C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,2DAA2D;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,8DAA8D;IAC9D,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,UAAU,CAAA;CACnB,CAAA;AA6DD;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAAI,mCAI7B,iBAAsB,WA6FxB,CAAA"}
1
+ {"version":3,"file":"inbox.d.ts","sourceRoot":"","sources":["../src/inbox.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;GAaG;AACH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,YAAY,KAAK,CAAA;AAE9B,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,SAAS,CAAA;AAE3C,2CAA2C;AAC3C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,2DAA2D;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,8DAA8D;IAC9D,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,UAAU,CAAA;CACnB,CAAA;AA6DD;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAAI,mCAI7B,iBAAsB,WAyGxB,CAAA"}
package/dist/inbox.js CHANGED
@@ -5,6 +5,41 @@
5
5
  // Query-only by design. Assembling the result into sections is the surface's
6
6
  // own vocabulary — cockpit splits home from work, a web dashboard may group by
7
7
  // project — so nothing here decides what a section is.
8
+ /**
9
+ * How much of each row to ask for.
10
+ *
11
+ * `full` carries health, conversation and labels — everything `computeHealth`
12
+ * and a conversation line need. `minimal` carries identity only: type, number,
13
+ * title, url, draft, timestamp, repo.
14
+ *
15
+ * This is a cost axis, not a taste one. Measured against GitHub's own
16
+ * `rateLimit { cost }`: the full query costs **111 points** of a 5000/hour
17
+ * budget, at a nodeCount of ~25,550 — because `statusCheckRollup.contexts`
18
+ * appears in five PR fragments and `reviewThreads(first: 50)` multiplies
19
+ * beneath each one. A caller that renders a title and a link was paying for
20
+ * every check run on every open PR. At 111 a poller gets 45 refreshes an hour.
21
+ */
22
+ /**
23
+ * How many of your own open PRs to ask for.
24
+ *
25
+ * This is the single biggest lever on the query's cost, because connections
26
+ * MULTIPLY: the health and conversation fragments hang ~80 nodes off each PR
27
+ * (`reviewThreads(first: 50)`, `statusCheckRollup.contexts(first: 20)`,
28
+ * `labels(first: 10)`), so the outer number is a multiplier on all of them.
29
+ * GitHub scores a call by the nodes it could return, not by how many calls you
30
+ * make — which is why batching queries saves nothing here and this saves a lot.
31
+ *
32
+ * It was 100, against ~25,550 total nodes and a measured 111 points. 100 × 80 is
33
+ * 8,000 of those nodes from this one search, and it was 100 for no reason beyond
34
+ * the search API's own maximum — every other search here already asks for 20-30.
35
+ * At 30 this search costs 2,400 nodes instead of 8,000, roughly halving the whole
36
+ * query.
37
+ *
38
+ * `issueCount` is fetched alongside so the cap can never drop rows in silence: a
39
+ * scalar costs nothing, and a host that knows the true total can say what it is
40
+ * not showing.
41
+ */
42
+ export const MY_PRS_LIMIT = 30;
8
43
  // computeHealth's precedence needs reviewDecision, mergeable and the check
9
44
  // rollup. A fragment that omits them does NOT degrade gracefully — it falls
10
45
  // straight through to whatever token is left, so a PR you already sent back
@@ -78,10 +113,22 @@ export const buildInboxQuery = ({ repo, doneWithinDays = 14, shape = "full", } =
78
113
  const conversation = full ? PR_CONVERSATION : "";
79
114
  const issueConversation = full ? ISSUE_CONVERSATION : "";
80
115
  const issueLabels = full ? ISSUE_LABELS : "";
116
+ /*
117
+ * `rateLimit` is free — it does not count against itself — and it is the only
118
+ * authoritative source for what this query costs. Every estimate made about
119
+ * that on 2026-08-14 was wrong, one of them by 25x, because GraphQL cost is
120
+ * node-count based and nested connections multiply: `reviewThreads(first: 50)`
121
+ * beneath `search(first: 100)` is 5,000 nodes from two lines of query text. A
122
+ * package handing out a 111-point query should hand out the means to see it.
123
+ *
124
+ * (GraphQL has no `/* *\/` comments, only `#`, so this note lives out here.)
125
+ */
81
126
  return `
82
127
  {
128
+ rateLimit { cost nodeCount remaining resetAt }
83
129
  viewer { login }
84
- myPRs: search(query: "${scope}is:pr is:open author:@me", type: ISSUE, first: 100) {
130
+ myPRs: search(query: "${scope}is:pr is:open author:@me", type: ISSUE, first: ${MY_PRS_LIMIT}) {
131
+ issueCount
85
132
  nodes { __typename ... on PullRequest {
86
133
  number title createdAt url headRefName isDraft
87
134
  repository { nameWithOwner }
package/dist/inbox.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"inbox.js","sourceRoot":"","sources":["../src/inbox.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,6EAA6E;AAC7E,qCAAqC;AACrC,EAAE;AACF,6EAA6E;AAC7E,+EAA+E;AAC/E,uDAAuD;AAiCvD,2EAA2E;AAC3E,4EAA4E;AAC5E,4EAA4E;AAC5E,mEAAmE;AACnE,EAAE;AACF,6EAA6E;AAC7E,8EAA8E;AAC9E,8EAA8E;AAC9E,8EAA8E;AAC9E,yBAAyB;AACzB,EAAE;AACF,2EAA2E;AAC3E,8EAA8E;AAC9E,2EAA2E;AAC3E,qBAAqB;AACrB,MAAM,SAAS,GAAG;;;;;YAKN,CAAA;AAEZ,6EAA6E;AAC7E,gFAAgF;AAChF,8EAA8E;AAC9E,2DAA2D;AAC3D,EAAE;AACF,8EAA8E;AAC9E,8EAA8E;AAC9E,4EAA4E;AAC5E,gFAAgF;AAChF,8EAA8E;AAC9E,+DAA+D;AAC/D,MAAM,eAAe,GAAG;;;;;;;8DAOsC,CAAA;AAE9D,MAAM,kBAAkB,GAAG;uFAC4D,CAAA;AAEvF,+EAA+E;AAC/E,qEAAqE;AACrE,MAAM,YAAY,GAAG;2CACsB,CAAA;AAE3C;;;;;GAKG;AACH,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAE,CAChC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AAEvE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EA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AC,QAAQ,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA;IACzC,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,CAAA;IACrC,MAAM,SAAS,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAA;IAE1C;yEACqE;IACrE,MAAM,IAAI,GAAG,KAAK,KAAK,MAAM,CAAA;IAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAA;IACpC,MAAM,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAA;IAChD,MAAM,iBAAiB,GAAG,IAAI,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAA;IACxD,MAAM,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAA;IAE5C;;;;;;;;;OASG;IACH,OAAO;;;;0BAIiB,KAAK,kDAAkD,YAAY;;;;;;QAMrF,MAAM;QACN,YAAY;;;mCAGe,KAAK;;;;;QAKhC,MAAM;QACN,YAAY;;;6BAGS,KAAK;;;;;QAK1B,MAAM;QACN,YAAY;;;6BAGS,KAAK;;;;;UAKxB,iBAAiB;UACjB,WAAW;;;;UAIX,MAAM;UACN,YAAY;;;;+BAIS,KAAK,GAAG,KAAK;;;;;QAKpC,iBAAiB;QACjB,WAAW;;;mCAGgB,KAAK;;;;;QAKhC,iBAAiB;QACjB,WAAW;;;4BAGS,KAAK,GAAG,KAAK;;;;;QAKjC,MAAM;QACN,YAAY;;;iCAGa,KAAK,sCAAsC,SAAS;;;;;;;CAOpF,CAAA;AACD,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kud/gh",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Surface-agnostic GitHub core — gh CLI primitives, PR review comments, health, and webhook logic.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",