repowisestage 0.0.50 → 0.0.51

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.
@@ -2524,6 +2524,79 @@ var init_lsp_tools = __esm({
2524
2524
  }
2525
2525
  });
2526
2526
 
2527
+ // ../listener/dist/lsp/telemetry.js
2528
+ var telemetry_exports = {};
2529
+ __export(telemetry_exports, {
2530
+ postLspInstallOutcomes: () => postLspInstallOutcomes
2531
+ });
2532
+ function toOutcomes(results) {
2533
+ return results.map((r) => ({
2534
+ language: r.language,
2535
+ ...r.installMethod ? { installMethod: r.installMethod } : {},
2536
+ installed: r.installed,
2537
+ alreadyPresent: r.alreadyPresent,
2538
+ ...r.skippedNoNpmPackage ? { skipped: "no-install-method" } : {},
2539
+ ...r.error ? { error: r.error.slice(0, 500) } : {}
2540
+ }));
2541
+ }
2542
+ async function postLspInstallOutcomes(input) {
2543
+ if (process.env["REPOWISE_LSP_INSTALL_TELEMETRY_DISABLED"] === "true")
2544
+ return;
2545
+ if (input.results.length === 0)
2546
+ return;
2547
+ const fetchImpl = input.fetchImpl ?? fetch;
2548
+ const url = `${input.apiUrl.replace(/\/+$/, "")}/v1/listeners/lsp-install-outcome`;
2549
+ const body = JSON.stringify({
2550
+ repoId: input.repoId,
2551
+ outcomes: toOutcomes(input.results)
2552
+ });
2553
+ const attempt = async () => {
2554
+ const ctrl = new AbortController();
2555
+ const timer = setTimeout(() => {
2556
+ ctrl.abort();
2557
+ }, REQUEST_TIMEOUT_MS);
2558
+ try {
2559
+ const res = await fetchImpl(url, {
2560
+ method: "POST",
2561
+ headers: {
2562
+ "Content-Type": "application/json",
2563
+ Authorization: `Bearer ${input.authToken}`
2564
+ },
2565
+ body,
2566
+ signal: ctrl.signal
2567
+ });
2568
+ const retriable = res.status >= 500 || res.status === 429;
2569
+ return { ok: res.ok, status: res.status, retriable };
2570
+ } catch {
2571
+ return { ok: false, status: 0, retriable: true };
2572
+ } finally {
2573
+ clearTimeout(timer);
2574
+ }
2575
+ };
2576
+ try {
2577
+ const first = await attempt();
2578
+ if (first.ok)
2579
+ return;
2580
+ if (!first.retriable) {
2581
+ console.warn(`[lsp-telemetry] upload rejected (${first.status.toString()}) \u2014 not retrying`);
2582
+ return;
2583
+ }
2584
+ const second = await attempt();
2585
+ if (!second.ok) {
2586
+ console.warn(`[lsp-telemetry] upload failed after retry (status=${second.status.toString()})`);
2587
+ }
2588
+ } catch (err) {
2589
+ console.warn(`[lsp-telemetry] unexpected failure: ${err instanceof Error ? err.message : String(err)}`);
2590
+ }
2591
+ }
2592
+ var REQUEST_TIMEOUT_MS;
2593
+ var init_telemetry = __esm({
2594
+ "../listener/dist/lsp/telemetry.js"() {
2595
+ "use strict";
2596
+ REQUEST_TIMEOUT_MS = 5e3;
2597
+ }
2598
+ });
2599
+
2527
2600
  // bin/repowise.ts
2528
2601
  import { readFileSync as readFileSync3 } from "fs";
2529
2602
  import { fileURLToPath as fileURLToPath4 } from "url";
@@ -8912,6 +8985,27 @@ async function startListener() {
8912
8985
  console.warn(`[lsp-install] ${r.language} install failed: ${r.error}`);
8913
8986
  }
8914
8987
  }
8988
+ if (lspResults.length > 0) {
8989
+ const { postLspInstallOutcomes: postLspInstallOutcomes2 } = await Promise.resolve().then(() => (init_telemetry(), telemetry_exports));
8990
+ for (const repo of config2.repos) {
8991
+ const apiUrl = repo.apiUrl ?? config2.defaultApiUrl;
8992
+ if (!apiUrl)
8993
+ continue;
8994
+ try {
8995
+ const fresh = await getValidCredentials();
8996
+ if (!fresh)
8997
+ continue;
8998
+ await postLspInstallOutcomes2({
8999
+ apiUrl,
9000
+ authToken: fresh.accessToken,
9001
+ repoId: repo.repoId,
9002
+ results: lspResults
9003
+ });
9004
+ } catch (telErr) {
9005
+ console.warn("[lsp-telemetry] upload skipped:", telErr instanceof Error ? telErr.message : String(telErr));
9006
+ }
9007
+ }
9008
+ }
8915
9009
  } catch (err) {
8916
9010
  console.warn("[lsp-install] Pre-install scan failed:", err instanceof Error ? err.message : String(err));
8917
9011
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repowisestage",
3
- "version": "0.0.50",
3
+ "version": "0.0.51",
4
4
  "type": "module",
5
5
  "description": "AI-optimized codebase context generator",
6
6
  "bin": {