githits 0.3.3 → 0.4.1

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/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  version
3
- } from "./shared/chunk-tze0rsay.js";
3
+ } from "./shared/chunk-f2ah8xnh.js";
4
4
  export {
5
5
  version
6
6
  };
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from "node:module";
2
2
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
3
3
  // package.json
4
- var version = "0.3.3";
4
+ var version = "0.4.1";
5
5
 
6
6
  export { __require, version };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  __require,
3
3
  version
4
- } from "./chunk-tze0rsay.js";
4
+ } from "./chunk-f2ah8xnh.js";
5
5
 
6
6
  // src/services/app-config-paths.ts
7
7
  var APP_DIR = "githits";
@@ -169,12 +169,15 @@ class AuthServiceImpl {
169
169
  return url.toString();
170
170
  }
171
171
  startCallbackServer(port, expectedState) {
172
- return new Promise((resolve, reject) => {
173
- let callbackHandled = false;
174
- let resolved = false;
175
- let closeTimer;
176
- const server = createServer((req, res) => {
177
- const url = new URL(req.url ?? "", `http://127.0.0.1:${port}`);
172
+ let closeTimer;
173
+ const server = createServer();
174
+ let callbackHandled = false;
175
+ let resolved = false;
176
+ const result = new Promise((resolve) => {
177
+ server.on("request", (req, res) => {
178
+ const address = server.address();
179
+ const actualPort = typeof address === "object" && address !== null ? address.port : port;
180
+ const url = new URL(req.url ?? "", `http://127.0.0.1:${actualPort}`);
178
181
  if (url.pathname === "/favicon.ico") {
179
182
  res.writeHead(204);
180
183
  res.end();
@@ -209,9 +212,23 @@ class AuthServiceImpl {
209
212
  clearTimeout(closeTimer);
210
213
  closeTimer = setTimeout(() => closeServer(server), 1500);
211
214
  });
212
- server.listen(port, "127.0.0.1");
213
- server.on("error", (err) => {
215
+ });
216
+ return new Promise((resolve, reject) => {
217
+ const onError = (err) => {
214
218
  reject(new Error(`Failed to start callback server: ${err.message}`));
219
+ };
220
+ server.once("error", onError);
221
+ server.listen(port, "127.0.0.1", () => {
222
+ server.off("error", onError);
223
+ server.on("error", () => {});
224
+ resolve({
225
+ result,
226
+ close: async () => {
227
+ if (closeTimer)
228
+ clearTimeout(closeTimer);
229
+ await closeServer(server);
230
+ }
231
+ });
215
232
  });
216
233
  });
217
234
  }
@@ -557,7 +574,18 @@ function sendHtmlResponse(res, statusCode, html) {
557
574
  res.end(html);
558
575
  }
559
576
  function closeServer(server) {
560
- server.close();
577
+ return new Promise((resolve, reject) => {
578
+ if (!server.listening) {
579
+ resolve();
580
+ return;
581
+ }
582
+ server.close((error) => {
583
+ if (error)
584
+ reject(error);
585
+ else
586
+ resolve();
587
+ });
588
+ });
561
589
  }
562
590
  function escapeHtml(text) {
563
591
  return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
@@ -837,13 +865,11 @@ class ClientUpdateRequiredError extends Error {
837
865
  }
838
866
  }
839
867
  function isClientUpdateRequiredGraphQLError(input) {
840
- if (input.code === "CLIENT_UPDATE_REQUIRED") {
841
- return true;
842
- }
843
- const message = input.message;
844
- if (!isGraphQLSchemaMismatchMessage(message)) {
868
+ return input.code === "CLIENT_UPDATE_REQUIRED";
869
+ }
870
+ function isGraphQLSchemaMismatchError(input) {
871
+ if (!isGraphQLSchemaMismatchMessage(input.message))
845
872
  return false;
846
- }
847
873
  return !input.code || input.code === "GRAPHQL_VALIDATION_FAILED" || input.code === "BAD_USER_INPUT";
848
874
  }
849
875
  function isGraphQLSchemaMismatchMessage(message) {
@@ -1499,6 +1525,10 @@ query UnifiedSearch(
1499
1525
  id
1500
1526
  resultType
1501
1527
  targetLabel
1528
+ requestedTargetLabel
1529
+ freshTargetLabel
1530
+ servedTargetLabel
1531
+ freshness
1502
1532
  title
1503
1533
  summary
1504
1534
  score
@@ -1537,6 +1567,9 @@ query UnifiedSearch(
1537
1567
  sourceStatus {
1538
1568
  source
1539
1569
  targetLabel
1570
+ requestedTargetLabel
1571
+ freshTargetLabel
1572
+ servedTargetLabel
1540
1573
  indexingStatus
1541
1574
  codeIndexState
1542
1575
  resultCount
@@ -1558,6 +1591,32 @@ query UnifiedSearch(
1558
1591
  query
1559
1592
  queryWarnings
1560
1593
  sources
1594
+ requestedSources
1595
+ targetMode
1596
+ requestedTargets {
1597
+ registry
1598
+ name
1599
+ version
1600
+ repoUrl
1601
+ gitRef
1602
+ }
1603
+ filters {
1604
+ fileIntent
1605
+ kind
1606
+ category
1607
+ publicOnly
1608
+ pathPrefix
1609
+ }
1610
+ limit
1611
+ offset
1612
+ targets {
1613
+ requested
1614
+ resolvedRequested
1615
+ served
1616
+ freshness
1617
+ indexingRef
1618
+ requestedRefKind
1619
+ }
1561
1620
  expiresAt
1562
1621
  }
1563
1622
  }
@@ -1573,6 +1632,32 @@ query UnifiedSearchStatus($searchRef: String!, $includeResults: Boolean!) {
1573
1632
  query
1574
1633
  queryWarnings
1575
1634
  sources
1635
+ requestedSources
1636
+ targetMode
1637
+ requestedTargets {
1638
+ registry
1639
+ name
1640
+ version
1641
+ repoUrl
1642
+ gitRef
1643
+ }
1644
+ filters {
1645
+ fileIntent
1646
+ kind
1647
+ category
1648
+ publicOnly
1649
+ pathPrefix
1650
+ }
1651
+ limit
1652
+ offset
1653
+ targets {
1654
+ requested
1655
+ resolvedRequested
1656
+ served
1657
+ freshness
1658
+ indexingRef
1659
+ requestedRefKind
1660
+ }
1576
1661
  expiresAt
1577
1662
  results {
1578
1663
  query
@@ -1582,6 +1667,10 @@ query UnifiedSearchStatus($searchRef: String!, $includeResults: Boolean!) {
1582
1667
  id
1583
1668
  resultType
1584
1669
  targetLabel
1670
+ requestedTargetLabel
1671
+ freshTargetLabel
1672
+ servedTargetLabel
1673
+ freshness
1585
1674
  title
1586
1675
  summary
1587
1676
  score
@@ -1620,6 +1709,9 @@ query UnifiedSearchStatus($searchRef: String!, $includeResults: Boolean!) {
1620
1709
  sourceStatus {
1621
1710
  source
1622
1711
  targetLabel
1712
+ requestedTargetLabel
1713
+ freshTargetLabel
1714
+ servedTargetLabel
1623
1715
  indexingStatus
1624
1716
  codeIndexState
1625
1717
  resultCount
@@ -1716,6 +1808,10 @@ var unifiedSearchHitSchema = z2.object({
1716
1808
  id: z2.string(),
1717
1809
  resultType: unifiedSearchResultTypeSchema,
1718
1810
  targetLabel: z2.string(),
1811
+ requestedTargetLabel: z2.string().nullable().optional(),
1812
+ freshTargetLabel: z2.string().nullable().optional(),
1813
+ servedTargetLabel: z2.string().nullable().optional(),
1814
+ freshness: z2.string().nullable().optional(),
1719
1815
  title: z2.string().nullable().optional(),
1720
1816
  summary: z2.string().nullable().optional(),
1721
1817
  score: z2.number().nullable().optional(),
@@ -1734,6 +1830,9 @@ var unifiedSearchPageInfoSchema = z2.object({
1734
1830
  var unifiedSearchSourceStatusSchema = z2.object({
1735
1831
  source: unifiedSearchSourceSchema,
1736
1832
  targetLabel: z2.string(),
1833
+ requestedTargetLabel: z2.string().nullable().optional(),
1834
+ freshTargetLabel: z2.string().nullable().optional(),
1835
+ servedTargetLabel: z2.string().nullable().optional(),
1737
1836
  indexingStatus: z2.string().nullable().optional(),
1738
1837
  codeIndexState: z2.string().nullable().optional(),
1739
1838
  resultCount: z2.number().int().nullable().optional(),
@@ -1762,6 +1861,28 @@ var unifiedSearchSessionStatusSchema = z2.enum([
1762
1861
  "TIMEOUT",
1763
1862
  "FAILED"
1764
1863
  ]);
1864
+ var unifiedSearchFiltersSchema = z2.object({
1865
+ fileIntent: z2.string().nullable().optional(),
1866
+ kind: z2.string().nullable().optional(),
1867
+ category: z2.string().nullable().optional(),
1868
+ publicOnly: z2.boolean().nullable().optional(),
1869
+ pathPrefix: z2.string().nullable().optional()
1870
+ }).nullable().optional();
1871
+ var unifiedSearchProgressTargetSchema = z2.object({
1872
+ requested: z2.string().nullable().optional(),
1873
+ resolvedRequested: z2.string().nullable().optional(),
1874
+ served: z2.string().nullable().optional(),
1875
+ freshness: z2.string().nullable().optional(),
1876
+ indexingRef: z2.string().nullable().optional(),
1877
+ requestedRefKind: z2.string().nullable().optional()
1878
+ });
1879
+ var unifiedSearchRequestedTargetSchema = z2.object({
1880
+ registry: z2.string().nullable().optional(),
1881
+ name: z2.string().nullable().optional(),
1882
+ version: z2.string().nullable().optional(),
1883
+ repoUrl: z2.string().nullable().optional(),
1884
+ gitRef: z2.string().nullable().optional()
1885
+ });
1765
1886
  var unifiedSearchProgressSchema = z2.object({
1766
1887
  searchRef: z2.string(),
1767
1888
  status: unifiedSearchSessionStatusSchema,
@@ -1771,6 +1892,13 @@ var unifiedSearchProgressSchema = z2.object({
1771
1892
  query: z2.string(),
1772
1893
  queryWarnings: z2.array(z2.string()),
1773
1894
  sources: z2.array(unifiedSearchSourceSchema),
1895
+ requestedSources: z2.array(unifiedSearchSourceSchema).nullable().optional(),
1896
+ targetMode: z2.string().nullable().optional(),
1897
+ requestedTargets: z2.array(unifiedSearchRequestedTargetSchema).nullable().optional(),
1898
+ filters: unifiedSearchFiltersSchema,
1899
+ limit: z2.number().int().nullable().optional(),
1900
+ offset: z2.number().int().nullable().optional(),
1901
+ targets: z2.array(unifiedSearchProgressTargetSchema).nullable().optional(),
1774
1902
  expiresAt: z2.string().nullable().optional(),
1775
1903
  results: unifiedSearchResultSchema.nullable().optional()
1776
1904
  });
@@ -2271,6 +2399,15 @@ class CodeNavigationServiceImpl {
2271
2399
  if (isClientUpdateRequiredGraphQLError({ message, code })) {
2272
2400
  return new ClientUpdateRequiredError;
2273
2401
  }
2402
+ if (isGraphQLSchemaMismatchError({ message, code })) {
2403
+ const sanitized = "Backend protocol mismatch. Your CLI may be newer than the server, or the server may require a newer CLI. Run `githits update-check` to verify your installed version. Set GITHITS_DEBUG=code-nav-wire to inspect GraphQL details during local development.";
2404
+ debugLog("code-nav", {
2405
+ event: "graphql-schema-mismatch",
2406
+ code: code ?? "omitted",
2407
+ message
2408
+ });
2409
+ return new CodeNavigationBackendError(isDebugAreaEnabled("code-nav-wire") ? message : sanitized, undefined, code, retryable);
2410
+ }
2274
2411
  switch (code) {
2275
2412
  case "PACKAGE_INDEXING":
2276
2413
  return new CodeNavigationIndexingError(this.createIndexingMessage(indexingRef), indexingRef, parseAvailableVersions(extensions));
@@ -2375,6 +2512,10 @@ class CodeNavigationServiceImpl {
2375
2512
  id: entry.id,
2376
2513
  resultType: entry.resultType,
2377
2514
  targetLabel: entry.targetLabel,
2515
+ requestedTargetLabel: entry.requestedTargetLabel ?? undefined,
2516
+ freshTargetLabel: entry.freshTargetLabel ?? undefined,
2517
+ servedTargetLabel: entry.servedTargetLabel ?? undefined,
2518
+ freshness: entry.freshness ?? undefined,
2378
2519
  title: entry.title ?? undefined,
2379
2520
  summary: entry.summary ?? undefined,
2380
2521
  score: entry.score ?? undefined,
@@ -2413,6 +2554,9 @@ class CodeNavigationServiceImpl {
2413
2554
  sourceStatus: result.sourceStatus.map((entry) => ({
2414
2555
  source: entry.source,
2415
2556
  targetLabel: entry.targetLabel,
2557
+ requestedTargetLabel: entry.requestedTargetLabel ?? undefined,
2558
+ freshTargetLabel: entry.freshTargetLabel ?? undefined,
2559
+ servedTargetLabel: entry.servedTargetLabel ?? undefined,
2416
2560
  indexingStatus: entry.indexingStatus ?? undefined,
2417
2561
  codeIndexState: entry.codeIndexState ?? undefined,
2418
2562
  resultCount: entry.resultCount ?? undefined,
@@ -2436,6 +2580,26 @@ class CodeNavigationServiceImpl {
2436
2580
  query: progress.query,
2437
2581
  queryWarnings: progress.queryWarnings,
2438
2582
  sources: progress.sources,
2583
+ requestedSources: progress.requestedSources ?? undefined,
2584
+ targetMode: normaliseTargetMode(progress.targetMode),
2585
+ requestedTargets: progress.requestedTargets?.map((target) => ({
2586
+ registry: target.registry ? target.registry : undefined,
2587
+ name: target.name ?? undefined,
2588
+ version: target.version ?? undefined,
2589
+ repoUrl: target.repoUrl ?? undefined,
2590
+ gitRef: target.gitRef ?? undefined
2591
+ })),
2592
+ filters: normaliseProgressFilters(progress.filters),
2593
+ limit: progress.limit ?? undefined,
2594
+ offset: progress.offset ?? undefined,
2595
+ targets: progress.targets?.map((target) => ({
2596
+ requested: target.requested ?? undefined,
2597
+ resolvedRequested: target.resolvedRequested ?? undefined,
2598
+ served: target.served ?? undefined,
2599
+ freshness: target.freshness ?? undefined,
2600
+ indexingRef: target.indexingRef ?? undefined,
2601
+ requestedRefKind: normaliseRequestedRefKind(target.requestedRefKind)
2602
+ })),
2439
2603
  expiresAt: progress.expiresAt ?? undefined
2440
2604
  };
2441
2605
  }
@@ -2755,6 +2919,43 @@ function isAuthMessage(message) {
2755
2919
  const lower = message.toLowerCase();
2756
2920
  return lower.includes("unauthorized") || lower.includes("forbidden") || lower.includes("permission") || lower.includes("authentication");
2757
2921
  }
2922
+ function normaliseTargetMode(value) {
2923
+ if (value === "PACKAGES" || value === "REPO" || value === "MIXED") {
2924
+ return value;
2925
+ }
2926
+ return;
2927
+ }
2928
+ function normaliseRequestedRefKind(value) {
2929
+ switch (value) {
2930
+ case "OMITTED_VERSION":
2931
+ case "LATEST_VERSION":
2932
+ case "EXACT_VERSION":
2933
+ case "DEFAULT_BRANCH":
2934
+ case "HEAD":
2935
+ case "BRANCH":
2936
+ case "SHA":
2937
+ return value;
2938
+ default:
2939
+ return;
2940
+ }
2941
+ }
2942
+ function normaliseProgressFilters(filters) {
2943
+ if (!filters)
2944
+ return;
2945
+ const out = {};
2946
+ if (filters.fileIntent)
2947
+ out.fileIntent = filters.fileIntent;
2948
+ if (filters.kind)
2949
+ out.kind = filters.kind;
2950
+ if (filters.category)
2951
+ out.category = filters.category;
2952
+ if (typeof filters.publicOnly === "boolean") {
2953
+ out.publicOnly = filters.publicOnly;
2954
+ }
2955
+ if (filters.pathPrefix)
2956
+ out.pathPrefix = filters.pathPrefix;
2957
+ return Object.keys(out).length > 0 ? out : undefined;
2958
+ }
2758
2959
  function isTargetNotFoundMessage(message) {
2759
2960
  const lower = message.toLowerCase();
2760
2961
  return lower.includes("not found") || lower.includes("unknown package") || lower.includes("no such package") || lower.includes("does not exist");
@@ -4412,6 +4613,15 @@ class PackageIntelligenceServiceImpl {
4412
4613
  if (isClientUpdateRequiredGraphQLError({ message, code })) {
4413
4614
  return new ClientUpdateRequiredError;
4414
4615
  }
4616
+ if (isGraphQLSchemaMismatchError({ message, code })) {
4617
+ const sanitized = "Backend protocol mismatch. Your CLI may be newer than the server, or the server may require a newer CLI. Run `githits update-check` to verify your installed version. Set GITHITS_DEBUG=pkg-graphql to inspect GraphQL details during local development.";
4618
+ debugLog("pkg-graphql", {
4619
+ event: "graphql-schema-mismatch",
4620
+ code: code ?? "omitted",
4621
+ message
4622
+ });
4623
+ return new PackageIntelligenceBackendError(isDebugAreaEnabled("pkg-graphql") ? message : sanitized, undefined, code, retryable);
4624
+ }
4415
4625
  switch (code) {
4416
4626
  case "NOT_FOUND":
4417
4627
  case "PACKAGE_NOT_FOUND":
@@ -4814,7 +5024,7 @@ class PackageIntelligenceServiceImpl {
4814
5024
  return this.normaliseChangelogReport(data, params);
4815
5025
  }
4816
5026
  normaliseChangelogReport(data, params) {
4817
- const source = data.source && data.source.trim() ? data.source : undefined;
5027
+ const source = data.source?.trim() ? data.source : undefined;
4818
5028
  const rawEntries = data.entries ?? [];
4819
5029
  if (!source && rawEntries.length === 0) {
4820
5030
  const target = params.repoUrl ?? (params.registry && params.packageName ? `${params.registry.toLowerCase()}:${params.packageName}` : "package");
@@ -2,8 +2,8 @@ import {
2
2
  createAuthCommandDependencies,
3
3
  createAuthStatusDependencies,
4
4
  createContainer
5
- } from "./chunk-2d202fpq.js";
6
- import"./chunk-tze0rsay.js";
5
+ } from "./chunk-rgvmtzjt.js";
6
+ import"./chunk-f2ah8xnh.js";
7
7
  export {
8
8
  createContainer,
9
9
  createAuthStatusDependencies,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "githits",
3
- "version": "0.3.3",
3
+ "version": "0.4.1",
4
4
  "description": "Code examples from global open source for developers and AI assistants.",
5
5
  "mcpServers": {
6
6
  "githits": {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "githits",
3
3
  "description": "CLI companion for GitHits - code examples from global open source for developers and AI assistants",
4
- "version": "0.3.3",
4
+ "version": "0.4.1",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "githits",
3
- "version": "0.3.3",
3
+ "version": "0.4.1",
4
4
  "description": "Code examples from global open source for developers and AI assistants",
5
5
  "author": {
6
6
  "name": "GitHits"