@pkgseer/cli 0.4.2 → 0.4.3

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/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  version
4
- } from "./shared/chunk-w4ht5me5.js";
4
+ } from "./shared/chunk-d3mfgdr9.js";
5
5
 
6
6
  // src/cli.ts
7
7
  import { Command } from "commander";
@@ -685,6 +685,13 @@ var FindSymbolDocument = gql`
685
685
  totalMatches
686
686
  hasMore
687
687
  indexedVersion
688
+ diagnostics {
689
+ indexed
690
+ chunkCount
691
+ fileCount
692
+ indexedAt
693
+ hint
694
+ }
688
695
  }
689
696
  }
690
697
  `;
@@ -730,6 +737,7 @@ var SearchSymbolsDocument = gql`
730
737
  indexedAt
731
738
  hint
732
739
  }
740
+ warning
733
741
  }
734
742
  }
735
743
  `;
@@ -767,7 +775,6 @@ var ListSymbolsDocument = gql`
767
775
  path
768
776
  language
769
777
  }
770
- error
771
778
  }
772
779
  }
773
780
  `;
@@ -950,6 +957,13 @@ var ListRepoFilesDocument = gql`
950
957
  total
951
958
  hasMore
952
959
  indexedVersion
960
+ diagnostics {
961
+ indexed
962
+ chunkCount
963
+ fileCount
964
+ indexedAt
965
+ hint
966
+ }
953
967
  }
954
968
  }
955
969
  `;
@@ -977,6 +991,13 @@ var GrepRepoFileDocument = gql`
977
991
  language
978
992
  totalLines
979
993
  indexedVersion
994
+ diagnostics {
995
+ indexed
996
+ chunkCount
997
+ fileCount
998
+ indexedAt
999
+ hint
1000
+ }
980
1001
  }
981
1002
  }
982
1003
  `;
@@ -2441,8 +2462,11 @@ function handleErrors(errors, json) {
2441
2462
  const isNotFound = lower.includes("not found") || lower.includes("does not exist") || lower.includes("unknown");
2442
2463
  const isAuth = lower.includes("unauthorized") || lower.includes("forbidden") || lower.includes("token") || lower.includes("authentication") || lower.includes("permission");
2443
2464
  const isRateLimit = lower.includes("rate limit") || lower.includes("too many requests");
2465
+ const isBeingIndexed = lower.includes("being indexed") || lower.includes("retry with waittimeoutms");
2444
2466
  let hint = "";
2445
- if (isTimeout) {
2467
+ if (isBeingIndexed) {
2468
+ hint = " Hint: package is being indexed. Try again with a longer --wait value (e.g., --wait 30000).";
2469
+ } else if (isTimeout) {
2446
2470
  hint = " Hint: lower the limit or narrow the scope, then retry.";
2447
2471
  } else if (isNotFound) {
2448
2472
  hint = " Hint: verify the name/registry and that the resource exists.";
@@ -2480,14 +2504,20 @@ function formatSeverity(severity) {
2480
2504
  return indicators[severity] || severity;
2481
2505
  }
2482
2506
  function extractGraphQLError(error) {
2483
- if (error && typeof error === "object" && "response" in error && error.response && typeof error.response === "object" && "errors" in error.response && Array.isArray(error.response.errors)) {
2484
- const errors = error.response.errors;
2485
- if (errors.length > 0) {
2486
- const messages = errors.map((e) => e.message).filter((m) => typeof m === "string");
2507
+ if (error && typeof error === "object" && "response" in error && error.response && typeof error.response === "object" && "errors" in error.response) {
2508
+ const respErrors = error.response.errors;
2509
+ if (Array.isArray(respErrors)) {
2510
+ const messages = respErrors.map((e) => e.message).filter((m) => typeof m === "string");
2487
2511
  if (messages.length > 0) {
2488
2512
  return messages.join("; ");
2489
2513
  }
2490
2514
  }
2515
+ if (respErrors && typeof respErrors === "object" && !Array.isArray(respErrors) && "detail" in respErrors) {
2516
+ const detail = respErrors.detail;
2517
+ if (typeof detail === "string") {
2518
+ return detail;
2519
+ }
2520
+ }
2491
2521
  }
2492
2522
  if (error && typeof error === "object" && "errors" in error && Array.isArray(error.errors)) {
2493
2523
  const errors = error.errors;
@@ -2536,6 +2566,10 @@ async function withCliErrorHandling(json, fn) {
2536
2566
  }
2537
2567
  const message = error instanceof Error ? error.message : "Unknown error";
2538
2568
  const lower = message.toLowerCase();
2569
+ if (lower.includes("being indexed") || lower.includes("retry with waittimeoutms")) {
2570
+ outputError(`${message}. Hint: package is being indexed. Try again with a longer --wait value (e.g., --wait 30000).`, json);
2571
+ return;
2572
+ }
2539
2573
  if (lower.includes("-32001") || lower.includes("timeout")) {
2540
2574
  outputError(`${message}. Hint: lower the limit or narrow the scope, then retry.`, json);
2541
2575
  return;
@@ -2886,10 +2920,17 @@ async function codeFilesAction(packageArg, options, deps) {
2886
2920
  outputError(`Package not found: ${parsed.name} in ${parsed.registry}`, options.json ?? false);
2887
2921
  return;
2888
2922
  }
2923
+ const data = result.data.listRepoFiles;
2889
2924
  if (options.json) {
2890
- output(result.data.listRepoFiles, true);
2925
+ output(data, true);
2891
2926
  } else {
2892
- console.log(formatFilesResult(result.data.listRepoFiles));
2927
+ const formatted = formatFilesResult(data);
2928
+ if (data.files.length === 0 && data.diagnostics?.hint) {
2929
+ console.log(`${formatted}
2930
+ Note: ${data.diagnostics.hint}`);
2931
+ } else {
2932
+ console.log(formatted);
2933
+ }
2893
2934
  }
2894
2935
  }
2895
2936
  var FILES_DESCRIPTION = `List files in a package's indexed repository.
@@ -2944,10 +2985,17 @@ async function codeFindAction(packageArg, nameArg, options, deps) {
2944
2985
  outputError(`Package not found: ${parsed.name} in ${parsed.registry}`, options.json ?? false);
2945
2986
  return;
2946
2987
  }
2988
+ const data = result.data.findSymbol;
2947
2989
  if (options.json) {
2948
- output(result.data.findSymbol, true);
2990
+ output(data, true);
2949
2991
  } else {
2950
- console.log(formatFindResult(result.data.findSymbol));
2992
+ const formatted = formatFindResult(data);
2993
+ if (data.symbols.length === 0 && data.diagnostics?.hint) {
2994
+ console.log(`${formatted}
2995
+ Note: ${data.diagnostics.hint}`);
2996
+ } else {
2997
+ console.log(formatted);
2998
+ }
2951
2999
  }
2952
3000
  }
2953
3001
  var FIND_DESCRIPTION = `Find symbols (functions, classes, modules) by name.
@@ -3011,10 +3059,17 @@ async function codeGrepAction(packageArg, filePath, pattern, options, deps) {
3011
3059
  outputError(`Package not found: ${parsed.name} in ${parsed.registry}`, options.json ?? false);
3012
3060
  return;
3013
3061
  }
3062
+ const data = result.data.grepRepoFile;
3014
3063
  if (options.json) {
3015
- output(result.data.grepRepoFile, true);
3064
+ output(data, true);
3016
3065
  } else {
3017
- console.log(formatGrepResult(result.data.grepRepoFile));
3066
+ const formatted = formatGrepResult(data);
3067
+ if (data.matches.length === 0 && data.diagnostics?.hint) {
3068
+ console.log(`${formatted}
3069
+ Note: ${data.diagnostics.hint}`);
3070
+ } else {
3071
+ console.log(formatted);
3072
+ }
3018
3073
  }
3019
3074
  }
3020
3075
  var GREP_DESCRIPTION = `Search for a pattern within a file in a package's repository.
@@ -3124,9 +3179,6 @@ function formatListResult(data) {
3124
3179
  if (data.file) {
3125
3180
  lines.push(`File: ${data.file.path}${data.file.language ? ` (${data.file.language})` : ""}`);
3126
3181
  }
3127
- if (data.error) {
3128
- lines.push(`Warning: ${data.error}`);
3129
- }
3130
3182
  lines.push("");
3131
3183
  for (const symbol of data.symbols) {
3132
3184
  lines.push(formatSymbol(symbol));
@@ -3308,10 +3360,21 @@ async function codeSearchAction(packageArg, query, options, deps) {
3308
3360
  outputError(`Package not found: ${parsed.name} in ${parsed.registry}`, options.json ?? false);
3309
3361
  return;
3310
3362
  }
3363
+ const data = result.data.searchSymbols;
3311
3364
  if (options.json) {
3312
- output(result.data.searchSymbols, true);
3365
+ output(data, true);
3313
3366
  } else {
3314
- console.log(formatSearchResult(result.data.searchSymbols));
3367
+ let formatted = formatSearchResult(data);
3368
+ if (data.warning) {
3369
+ formatted = `Warning: ${data.warning}
3370
+
3371
+ ${formatted}`;
3372
+ }
3373
+ if (data.results.length === 0 && data.diagnostics?.hint) {
3374
+ formatted = `${formatted}
3375
+ Note: ${data.diagnostics.hint}`;
3376
+ }
3377
+ console.log(formatted);
3315
3378
  }
3316
3379
  }
3317
3380
  var SEARCH_DESCRIPTION = `Full-text search within package code.
@@ -6440,10 +6503,30 @@ function toSymbolReferenceInput(ref) {
6440
6503
  }
6441
6504
  function buildHintedMessage(operation, message) {
6442
6505
  const lower = message.toLowerCase();
6506
+ const isBeingIndexed = lower.includes("being indexed") || lower.includes("retry with waittimeoutms");
6507
+ if (isBeingIndexed) {
6508
+ return `Failed to ${operation}: ${message}. ` + "Hint: package is being indexed. Try again with a longer wait_timeout_ms (e.g., 30000).";
6509
+ }
6443
6510
  const isTimeout = lower.includes("-32001") || lower.includes("timeout") || lower.includes("timed out");
6444
6511
  if (isTimeout) {
6445
6512
  return `Failed to ${operation}: ${message}. ` + "Hint: try lowering the limit or narrowing the scope, then retry.";
6446
6513
  }
6514
+ if (lower.includes("graphql error (code: 500)")) {
6515
+ try {
6516
+ const jsonMatch = message.match(/\{.*\}/s);
6517
+ if (jsonMatch) {
6518
+ const parsed = JSON.parse(jsonMatch[0]);
6519
+ const detail = parsed.errors?.detail ?? parsed.detail;
6520
+ if (typeof detail === "string") {
6521
+ return `Failed to ${operation}: ${detail}`;
6522
+ }
6523
+ }
6524
+ } catch {}
6525
+ const detailMatch = message.match(/"detail"\s*:\s*"([^"]+)"/);
6526
+ if (detailMatch?.[1]) {
6527
+ return `Failed to ${operation}: ${detailMatch[1]}`;
6528
+ }
6529
+ }
6447
6530
  return `Failed to ${operation}: ${message}`;
6448
6531
  }
6449
6532
  function handleGraphQLErrors(errors) {
@@ -6452,10 +6535,14 @@ function handleGraphQLErrors(errors) {
6452
6535
  const combined = messages.join(", ");
6453
6536
  const lower = combined.toLowerCase();
6454
6537
  const hasNotFound = lower.includes("not found") || lower.includes("does not exist");
6538
+ const hasBeingIndexed = lower.includes("being indexed") || lower.includes("retry with waittimeoutms");
6455
6539
  const hasTimeout = lower.includes("-32001") || lower.includes("timeout") || lower.includes("timed out");
6456
6540
  if (hasNotFound) {
6457
6541
  return errorResult(`Error: ${combined}. Hint: verify the name/registry and that the resource exists.`);
6458
6542
  }
6543
+ if (hasBeingIndexed) {
6544
+ return errorResult(`Error: ${combined}. Hint: package is being indexed. Try again with a longer wait_timeout_ms (e.g., 30000).`);
6545
+ }
6459
6546
  if (hasTimeout) {
6460
6547
  return errorResult(`Error: ${combined}. Hint: try lowering the limit or narrowing the scope, then retry.`);
6461
6548
  }
@@ -6650,7 +6737,11 @@ function createFindSymbolTool(pkgseerService) {
6650
6737
  if (!result.data.findSymbol) {
6651
6738
  return notFoundError(args.package_name, args.registry);
6652
6739
  }
6653
- return textResult(JSON.stringify(result.data.findSymbol, null, 2));
6740
+ const data = result.data.findSymbol;
6741
+ if (data.symbols.length === 0 && data.diagnostics?.hint) {
6742
+ return textResult(JSON.stringify({ ...data, _hint: data.diagnostics.hint }, null, 2));
6743
+ }
6744
+ return textResult(JSON.stringify(data, null, 2));
6654
6745
  });
6655
6746
  }
6656
6747
  };
@@ -6686,7 +6777,11 @@ function createGrepRepoFileTool(pkgseerService) {
6686
6777
  if (!result.data.grepRepoFile) {
6687
6778
  return notFoundError(args.package_name, args.registry);
6688
6779
  }
6689
- return textResult(JSON.stringify(result.data.grepRepoFile, null, 2));
6780
+ const data = result.data.grepRepoFile;
6781
+ if (data.matches.length === 0 && data.diagnostics?.hint) {
6782
+ return textResult(JSON.stringify({ ...data, _hint: data.diagnostics.hint }, null, 2));
6783
+ }
6784
+ return textResult(JSON.stringify(data, null, 2));
6690
6785
  });
6691
6786
  }
6692
6787
  };
@@ -6745,7 +6840,11 @@ function createListRepoFilesTool(pkgseerService) {
6745
6840
  if (!result.data.listRepoFiles) {
6746
6841
  return notFoundError(args.package_name, args.registry);
6747
6842
  }
6748
- return textResult(JSON.stringify(result.data.listRepoFiles, null, 2));
6843
+ const data = result.data.listRepoFiles;
6844
+ if (data.files.length === 0 && data.diagnostics?.hint) {
6845
+ return textResult(JSON.stringify({ ...data, _hint: data.diagnostics.hint }, null, 2));
6846
+ }
6847
+ return textResult(JSON.stringify(data, null, 2));
6749
6848
  });
6750
6849
  }
6751
6850
  };
@@ -7298,7 +7397,18 @@ function createSearchSymbolsTool(pkgseerService) {
7298
7397
  if (!result.data.searchSymbols) {
7299
7398
  return notFoundError(args.package_name, args.registry);
7300
7399
  }
7301
- return textResult(JSON.stringify(result.data.searchSymbols, null, 2));
7400
+ const data = result.data.searchSymbols;
7401
+ const extra = {};
7402
+ if (data.results.length === 0 && data.diagnostics?.hint) {
7403
+ extra._hint = data.diagnostics.hint;
7404
+ }
7405
+ if (data.warning) {
7406
+ extra._warning = data.warning;
7407
+ }
7408
+ if (Object.keys(extra).length > 0) {
7409
+ return textResult(JSON.stringify({ ...data, ...extra }, null, 2));
7410
+ }
7411
+ return textResult(JSON.stringify(data, null, 2));
7302
7412
  });
7303
7413
  }
7304
7414
  };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  version
3
- } from "./shared/chunk-w4ht5me5.js";
3
+ } from "./shared/chunk-d3mfgdr9.js";
4
4
  export {
5
5
  version
6
6
  };
@@ -1,4 +1,4 @@
1
1
  // package.json
2
- var version = "0.4.2";
2
+ var version = "0.4.3";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pkgseer/cli",
3
3
  "description": "CLI companion for PkgSeer - package intelligence for developers and AI assistants",
4
- "version": "0.4.2",
4
+ "version": "0.4.3",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",