@westbayberry/dg 1.0.52 → 1.0.53

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.
Files changed (2) hide show
  1. package/dist/index.mjs +100 -54
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -19192,9 +19192,9 @@ function handleContentBlockStart(event, state) {
19192
19192
  function handleContentBlockDelta(event, state, recordOutputs) {
19193
19193
  if (event.type !== "content_block_delta" || !event.delta) return;
19194
19194
  if (typeof event.index === "number" && "partial_json" in event.delta && typeof event.delta.partial_json === "string") {
19195
- const active = state.activeToolBlocks[event.index];
19196
- if (active) {
19197
- active.inputJsonParts.push(event.delta.partial_json);
19195
+ const active2 = state.activeToolBlocks[event.index];
19196
+ if (active2) {
19197
+ active2.inputJsonParts.push(event.delta.partial_json);
19198
19198
  }
19199
19199
  }
19200
19200
  if (recordOutputs && typeof event.delta.text === "string") {
@@ -19203,9 +19203,9 @@ function handleContentBlockDelta(event, state, recordOutputs) {
19203
19203
  }
19204
19204
  function handleContentBlockStop(event, state) {
19205
19205
  if (event.type !== "content_block_stop" || typeof event.index !== "number") return;
19206
- const active = state.activeToolBlocks[event.index];
19207
- if (!active) return;
19208
- const raw = active.inputJsonParts.join("");
19206
+ const active2 = state.activeToolBlocks[event.index];
19207
+ if (!active2) return;
19208
+ const raw = active2.inputJsonParts.join("");
19209
19209
  let parsedInput;
19210
19210
  try {
19211
19211
  parsedInput = raw ? JSON.parse(raw) : {};
@@ -19214,8 +19214,8 @@ function handleContentBlockStop(event, state) {
19214
19214
  }
19215
19215
  state.toolCalls.push({
19216
19216
  type: "tool_use",
19217
- id: active.id,
19218
- name: active.name,
19217
+ id: active2.id,
19218
+ name: active2.name,
19219
19219
  input: parsedInput
19220
19220
  });
19221
19221
  delete state.activeToolBlocks[event.index];
@@ -48378,6 +48378,34 @@ var init_update_check = __esm({
48378
48378
  }
48379
48379
  });
48380
48380
 
48381
+ // src/alt-screen.ts
48382
+ var alt_screen_exports = {};
48383
+ __export(alt_screen_exports, {
48384
+ altScreenActive: () => altScreenActive,
48385
+ enterAltScreen: () => enterAltScreen,
48386
+ leaveAltScreen: () => leaveAltScreen
48387
+ });
48388
+ function enterAltScreen() {
48389
+ if (!process.stdout.isTTY || active) return;
48390
+ process.stdout.write("\x1B[?1049h\x1B[2J\x1B[H");
48391
+ active = true;
48392
+ }
48393
+ function leaveAltScreen() {
48394
+ if (!active) return;
48395
+ process.stdout.write("\x1B[?1049l\x1B[?25h");
48396
+ active = false;
48397
+ }
48398
+ function altScreenActive() {
48399
+ return active;
48400
+ }
48401
+ var active;
48402
+ var init_alt_screen = __esm({
48403
+ "src/alt-screen.ts"() {
48404
+ "use strict";
48405
+ active = false;
48406
+ }
48407
+ });
48408
+
48381
48409
  // node_modules/react/cjs/react.production.min.js
48382
48410
  var require_react_production_min = __commonJS({
48383
48411
  "node_modules/react/cjs/react.production.min.js"(exports) {
@@ -83514,7 +83542,7 @@ async function callAnalyzeAPI(packages, config3, onProgress) {
83514
83542
  const results = [];
83515
83543
  let completed = 0;
83516
83544
  const tTotal = Date.now();
83517
- if (onProgress) onProgress(0, packages.length, batches[0]?.map((p) => p.name) ?? []);
83545
+ if (onProgress) onProgress(0, packages.length, []);
83518
83546
  for (let i = 0; i < batches.length; i++) {
83519
83547
  const batch = batches[i];
83520
83548
  const tBatch = Date.now();
@@ -83522,7 +83550,7 @@ async function callAnalyzeAPI(packages, config3, onProgress) {
83522
83550
  if (process.env.DG_PERF) console.error(`[CLI-PERF] batch ${i + 1}/${batches.length}: ${batch.length} packages \u2192 ${Date.now() - tBatch}ms`);
83523
83551
  completed += batch.length;
83524
83552
  if (onProgress) {
83525
- onProgress(completed, packages.length, batches[i + 1]?.map((p) => p.name) ?? batch.map((p) => p.name));
83553
+ onProgress(completed, packages.length, batch.map((p) => p.name));
83526
83554
  }
83527
83555
  results.push(result);
83528
83556
  }
@@ -83901,6 +83929,10 @@ function initialState(dryRun, firstRun) {
83901
83929
  };
83902
83930
  }
83903
83931
  function reducer(state, action) {
83932
+ if (process.env.DG_DEBUG_WIZARD && action.type !== "scan_progress") {
83933
+ process.stderr.write(`[wizard] action=${action.type} phase=${state.phase}
83934
+ `);
83935
+ }
83904
83936
  switch (action.type) {
83905
83937
  // ── First-run guided tour transitions ──────────────────────────────────
83906
83938
  case "welcome_yes":
@@ -84119,9 +84151,13 @@ function useInit(opts = {}) {
84119
84151
  const projects = state.projects.length > 0 ? state.projects : [{ path: opts.cwd ?? process.cwd() }];
84120
84152
  const allOutcomes = [];
84121
84153
  for (const proj of projects) {
84154
+ if (process.env.DG_DEBUG_WIZARD) process.stderr.write(`[wizard] scanning ${proj.path}
84155
+ `);
84122
84156
  const outcome = await scanFn(proj.path, config3, (p) => {
84123
84157
  dispatch({ type: "scan_progress", progress: p });
84124
84158
  });
84159
+ if (process.env.DG_DEBUG_WIZARD) process.stderr.write(`[wizard] scan done ${proj.path} status=${outcome.status}
84160
+ `);
84125
84161
  allOutcomes.push(outcome);
84126
84162
  }
84127
84163
  const allPackages = allOutcomes.flatMap(
@@ -87239,20 +87275,14 @@ var init_InitApp = __esm({
87239
87275
  const { exit } = use_app_default();
87240
87276
  useTerminalSize();
87241
87277
  const [yesNoCursor, setYesNoCursor] = (0, import_react27.useState)(defaultYesNoCursor(state.phase));
87242
- const altScreenActiveRef = (0, import_react27.useRef)(false);
87278
+ const prevPhaseRef = (0, import_react27.useRef)(state.phase);
87279
+ const [, forceTick] = (0, import_react27.useState)(0);
87243
87280
  (0, import_react27.useEffect)(() => {
87244
- if (!process.stdout.isTTY) return;
87245
- process.stdout.write("\x1B[?1049h");
87246
- process.stdout.write("\x1B[2J\x1B[H");
87247
- altScreenActiveRef.current = true;
87248
- return () => {
87249
- if (altScreenActiveRef.current) {
87250
- process.stdout.write("\x1B[?1049l");
87251
- altScreenActiveRef.current = false;
87252
- }
87253
- process.stdout.write("\x1B[?25h");
87254
- };
87255
- }, []);
87281
+ if (prevPhaseRef.current === "run_scan" && state.phase === "result_first_scan") {
87282
+ Promise.resolve().then(() => forceTick((n) => n + 1));
87283
+ }
87284
+ prevPhaseRef.current = state.phase;
87285
+ }, [state.phase]);
87256
87286
  (0, import_react27.useEffect)(() => {
87257
87287
  if (YES_NO_PHASES.has(state.phase)) {
87258
87288
  setYesNoCursor(defaultYesNoCursor(state.phase));
@@ -87654,8 +87684,7 @@ var init_InitApp = __esm({
87654
87684
  case "run_scan": {
87655
87685
  const p = state.scanProgress;
87656
87686
  if (p && p.total > 0) {
87657
- const currentLabel = p.current.length > 0 ? p.current[0] : void 0;
87658
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ProgressBar, { value: p.done, total: p.total, label: currentLabel });
87687
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ProgressBar, { value: p.done, total: p.total });
87659
87688
  }
87660
87689
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Scene, { mood: "scanning", color: "cyan", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Spinner2, { label: "Scanning..." }) });
87661
87690
  }
@@ -87907,19 +87936,25 @@ async function maybeOfferFirstRunWizard(opts) {
87907
87936
  const { render: render2 } = await init_build2().then(() => build_exports);
87908
87937
  const React21 = await Promise.resolve().then(() => __toESM(require_react()));
87909
87938
  const { InitApp: InitApp2 } = await init_InitApp().then(() => InitApp_exports);
87910
- const { waitUntilExit } = render2(
87911
- React21.createElement(InitApp2, {
87912
- firstRun: true,
87913
- onReachedDone: () => {
87914
- reachedDone = true;
87915
- },
87916
- onScanRan: () => {
87917
- scanRanInWizard = true;
87918
- }
87919
- })
87920
- );
87921
- mounted = true;
87922
- await waitUntilExit();
87939
+ const { enterAltScreen: enterAltScreen2, leaveAltScreen: leaveAltScreen2 } = await Promise.resolve().then(() => (init_alt_screen(), alt_screen_exports));
87940
+ enterAltScreen2();
87941
+ try {
87942
+ const { waitUntilExit } = render2(
87943
+ React21.createElement(InitApp2, {
87944
+ firstRun: true,
87945
+ onReachedDone: () => {
87946
+ reachedDone = true;
87947
+ },
87948
+ onScanRan: () => {
87949
+ scanRanInWizard = true;
87950
+ }
87951
+ })
87952
+ );
87953
+ mounted = true;
87954
+ await waitUntilExit();
87955
+ } finally {
87956
+ leaveAltScreen2();
87957
+ }
87923
87958
  } catch {
87924
87959
  return;
87925
87960
  }
@@ -89735,7 +89770,7 @@ var init_ScoreHeader = __esm({
89735
89770
  });
89736
89771
 
89737
89772
  // src/ui/hooks/useExpandAnimation.ts
89738
- function useExpandAnimation(targetHeight, active, durationMs = 180) {
89773
+ function useExpandAnimation(targetHeight, active2, durationMs = 180) {
89739
89774
  const [visibleLines, setVisibleLines] = (0, import_react32.useState)(0);
89740
89775
  const timerRef = (0, import_react32.useRef)(null);
89741
89776
  (0, import_react32.useEffect)(() => {
@@ -89743,7 +89778,7 @@ function useExpandAnimation(targetHeight, active, durationMs = 180) {
89743
89778
  clearInterval(timerRef.current);
89744
89779
  timerRef.current = null;
89745
89780
  }
89746
- if (!active || targetHeight <= 0) {
89781
+ if (!active2 || targetHeight <= 0) {
89747
89782
  setVisibleLines(0);
89748
89783
  return;
89749
89784
  }
@@ -89766,10 +89801,10 @@ function useExpandAnimation(targetHeight, active, durationMs = 180) {
89766
89801
  timerRef.current = null;
89767
89802
  }
89768
89803
  };
89769
- }, [active, targetHeight, durationMs]);
89804
+ }, [active2, targetHeight, durationMs]);
89770
89805
  return {
89771
- visibleLines: active ? visibleLines : 0,
89772
- isAnimating: active && visibleLines > 0 && visibleLines < targetHeight
89806
+ visibleLines: active2 ? visibleLines : 0,
89807
+ isAnimating: active2 && visibleLines > 0 && visibleLines < targetHeight
89773
89808
  };
89774
89809
  }
89775
89810
  var import_react32;
@@ -90882,7 +90917,7 @@ var init_App2 = __esm({
90882
90917
  (0, import_react35.useEffect)(() => {
90883
90918
  prevPhaseRef.current = state.phase;
90884
90919
  }, [state.phase]);
90885
- const leaveAltScreen = (0, import_react35.useCallback)(() => {
90920
+ const leaveAltScreen2 = (0, import_react35.useCallback)(() => {
90886
90921
  if (altScreenActiveRef.current && process.stdout.isTTY) {
90887
90922
  process.stdout.write("\x1B[?1049l");
90888
90923
  altScreenActiveRef.current = false;
@@ -90900,15 +90935,15 @@ var init_App2 = __esm({
90900
90935
  process.exitCode = 0;
90901
90936
  }
90902
90937
  }
90903
- leaveAltScreen();
90938
+ leaveAltScreen2();
90904
90939
  exit();
90905
- }, [state, config3, exit, leaveAltScreen]);
90940
+ }, [state, config3, exit, leaveAltScreen2]);
90906
90941
  const exitWithMessage = (0, import_react35.useCallback)((message, exitCode) => {
90907
90942
  process.exitCode = exitCode;
90908
- leaveAltScreen();
90943
+ leaveAltScreen2();
90909
90944
  process.stderr.write(message);
90910
90945
  return setTimeout(() => exit(), 0);
90911
- }, [exit, leaveAltScreen]);
90946
+ }, [exit, leaveAltScreen2]);
90912
90947
  (0, import_react35.useEffect)(() => {
90913
90948
  if (state.phase === "empty") {
90914
90949
  const timer = exitWithMessage(`${state.message}
@@ -90936,7 +90971,7 @@ var init_App2 = __esm({
90936
90971
  if (state.phase === "discovering" || state.phase === "scanning") {
90937
90972
  if (input === "q" || key.escape) {
90938
90973
  process.exitCode = 0;
90939
- leaveAltScreen();
90974
+ leaveAltScreen2();
90940
90975
  exit();
90941
90976
  }
90942
90977
  }
@@ -90953,7 +90988,7 @@ var init_App2 = __esm({
90953
90988
  onConfirm: scanSelectedProjects,
90954
90989
  onCancel: () => {
90955
90990
  process.exitCode = 0;
90956
- leaveAltScreen();
90991
+ leaveAltScreen2();
90957
90992
  exit();
90958
90993
  },
90959
90994
  userStatus
@@ -91859,6 +91894,7 @@ init_telemetry();
91859
91894
  init_config();
91860
91895
  init_npm_wrapper();
91861
91896
  init_update_check();
91897
+ init_alt_screen();
91862
91898
  var CLI_VERSION = getVersion();
91863
91899
  initTelemetry(CLI_VERSION);
91864
91900
  function closestCommand(input, commands) {
@@ -91879,9 +91915,14 @@ function closestCommand(input, commands) {
91879
91915
  return bestDist <= 3 ? best : null;
91880
91916
  }
91881
91917
  process.on("SIGINT", () => {
91918
+ leaveAltScreen();
91882
91919
  process.stderr.write("\n");
91883
91920
  process.exit(130);
91884
91921
  });
91922
+ process.on("SIGTERM", () => {
91923
+ leaveAltScreen();
91924
+ process.exit(143);
91925
+ });
91885
91926
  var isInteractive = process.stdout.isTTY === true && !process.env.CI && !process.env.NO_COLOR;
91886
91927
  async function main() {
91887
91928
  const rawCommand = process.argv[2];
@@ -91913,10 +91954,15 @@ async function main() {
91913
91954
  const { render: render3 } = await init_build2().then(() => build_exports);
91914
91955
  const React22 = await Promise.resolve().then(() => __toESM(require_react()));
91915
91956
  const { InitApp: InitApp2 } = await init_InitApp().then(() => InitApp_exports);
91916
- const { waitUntilExit } = render3(
91917
- React22.createElement(InitApp2, { firstRun: true, returning: true })
91918
- );
91919
- await waitUntilExit();
91957
+ enterAltScreen();
91958
+ try {
91959
+ const { waitUntilExit } = render3(
91960
+ React22.createElement(InitApp2, { firstRun: true, returning: true })
91961
+ );
91962
+ await waitUntilExit();
91963
+ } finally {
91964
+ leaveAltScreen();
91965
+ }
91920
91966
  try {
91921
91967
  const { markFirstRunComplete: markFirstRunComplete2 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
91922
91968
  markFirstRunComplete2();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@westbayberry/dg",
3
- "version": "1.0.52",
3
+ "version": "1.0.53",
4
4
  "description": "Supply chain security scanner for npm and Python dependencies — detects malicious packages, typosquatting, dependency confusion, and 26+ attack patterns",
5
5
  "bin": {
6
6
  "dependency-guardian": "dist/index.mjs",