@wrongstack/tools 1.0.0 → 1.0.2

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 (70) hide show
  1. package/dist/auto-proceed-loop-guard.d.ts +1 -1
  2. package/dist/auto-proceed-loop-guard.js +1 -1
  3. package/dist/bash.js +1 -1
  4. package/dist/builtin.js +15 -15
  5. package/dist/{chunk-VVZPQPTY.js → chunk-3AU6CZWL.js} +4 -2
  6. package/dist/{chunk-N3K2SFEI.js → chunk-52UXXQMP.js} +1408 -200
  7. package/dist/{chunk-NN2SNP2R.js → chunk-6H4ERJP7.js} +137 -21
  8. package/dist/{chunk-DK4J2WMH.js → chunk-7XUEPBNT.js} +2 -2
  9. package/dist/{chunk-IYH4OHBP.js → chunk-DKHMPKDG.js} +2 -2
  10. package/dist/{chunk-NU2IZ72J.js → chunk-DL2ARI4S.js} +7 -5
  11. package/dist/{chunk-M6UV67BH.js → chunk-EL2NJXSK.js} +2 -2
  12. package/dist/{chunk-YEISRT4S.js → chunk-HWXIRVKH.js} +1408 -235
  13. package/dist/{chunk-GKSG5CPH.js → chunk-KVTEIUND.js} +2 -2
  14. package/dist/{chunk-GDDXX27P.js → chunk-MBR5VAB5.js} +2 -2
  15. package/dist/{chunk-KDEXUQY7.js → chunk-MGPR7VG3.js} +261 -258
  16. package/dist/{chunk-YULVUTK5.js → chunk-NFX2IUQA.js} +3 -3
  17. package/dist/{chunk-37QKUQ2Z.js → chunk-NL2S2CXD.js} +1 -1
  18. package/dist/{chunk-ZTCJCYLN.js → chunk-TI5COGLY.js} +49 -6
  19. package/dist/{chunk-CGXTR34H.js → chunk-TU5MTW2S.js} +2 -2
  20. package/dist/{chunk-AB2CAUOP.js → chunk-UCXFTCAI.js} +186 -36
  21. package/dist/{chunk-MK2JK35J.js → chunk-UOYRAS4J.js} +3 -3
  22. package/dist/{chunk-UCYQTZ7F.js → chunk-ZKC5UNGD.js} +56 -2
  23. package/dist/codebase-index/atlas-brief.d.ts +90 -0
  24. package/dist/codebase-index/atlas-export.d.ts +38 -0
  25. package/dist/codebase-index/atlas-projection.d.ts +114 -0
  26. package/dist/codebase-index/atlas-types.d.ts +90 -0
  27. package/dist/codebase-index/background-indexer.d.ts +15 -4
  28. package/dist/codebase-index/codebase-context-tool.d.ts +54 -0
  29. package/dist/codebase-index/concept-enrichment.d.ts +154 -0
  30. package/dist/codebase-index/context-retrieval.d.ts +91 -0
  31. package/dist/codebase-index/embedding-pass.d.ts +95 -0
  32. package/dist/codebase-index/graph-adjacency-cache.d.ts +36 -0
  33. package/dist/codebase-index/graph-rank-pass.d.ts +46 -0
  34. package/dist/codebase-index/graph-rank.d.ts +198 -0
  35. package/dist/codebase-index/index-service.d.ts +15 -1
  36. package/dist/codebase-index/index.d.ts +34 -19
  37. package/dist/codebase-index/index.js +126 -9
  38. package/dist/codebase-index/parser-worker-script.js +3 -3
  39. package/dist/codebase-index/perf-metrics.d.ts +19 -0
  40. package/dist/codebase-index/project-server-protocol.d.ts +2 -0
  41. package/dist/codebase-index/project-server-query-cache.d.ts +4 -0
  42. package/dist/codebase-index/project-server.js +54 -7
  43. package/dist/codebase-index/repo-map-fallback.d.ts +18 -0
  44. package/dist/codebase-index/repo-map-render.d.ts +42 -0
  45. package/dist/codebase-index/repo-map-types.d.ts +21 -0
  46. package/dist/codebase-index/repo-map.d.ts +28 -16
  47. package/dist/codebase-index/schema.d.ts +20 -0
  48. package/dist/codebase-index/worker-protocol.d.ts +47 -1
  49. package/dist/codebase-index/worker.js +11 -5
  50. package/dist/codebase-index/writer-concepts.d.ts +84 -0
  51. package/dist/codebase-index/writer-graph-decorate.d.ts +30 -0
  52. package/dist/codebase-index/writer-graph-reader.d.ts +22 -0
  53. package/dist/codebase-index/writer-rank.d.ts +78 -0
  54. package/dist/codebase-index/writer-schema.d.ts +51 -0
  55. package/dist/codebase-index/writer-vectors.d.ts +53 -0
  56. package/dist/codebase-index/writer.d.ts +59 -0
  57. package/dist/edit.js +7 -7
  58. package/dist/exec.js +1 -1
  59. package/dist/{go-parser-D7ELWQ7F.js → go-parser-QIEXU3P2.js} +4 -2
  60. package/dist/index.d.ts +48 -48
  61. package/dist/index.js +43 -19
  62. package/dist/pack.js +16 -16
  63. package/dist/{parser-dispatch-BDVCJXTV.js → parser-dispatch-37FT3EXQ.js} +4 -4
  64. package/dist/patch.js +7 -7
  65. package/dist/{py-parser-QC6MR4GB.js → py-parser-6GJTGUXK.js} +3 -3
  66. package/dist/read.js +7 -7
  67. package/dist/replace.js +7 -7
  68. package/dist/tool-tier.js +17 -17
  69. package/dist/write.js +7 -7
  70. package/package.json +5 -5
@@ -627,17 +627,51 @@ var bashTool = {
627
627
  const detached = !isWin2;
628
628
  const startedAt = Date.now();
629
629
  if (input.background) {
630
- const child2 = spawn(shell, args, {
631
- cwd: spawnCwd,
632
- env,
633
- stdio: ["ignore", "ignore", "ignore"],
634
- detached: !isWin2,
635
- windowsHide: true
636
- });
630
+ let child2;
631
+ try {
632
+ child2 = spawn(shell, args, {
633
+ cwd: spawnCwd,
634
+ env,
635
+ stdio: ["ignore", "ignore", "ignore"],
636
+ detached: !isWin2,
637
+ windowsHide: true
638
+ });
639
+ } catch (err) {
640
+ registry.afterCall(Date.now() - startedAt, true, bypassBreaker);
641
+ emitProcessStarted({
642
+ parentPid: process.pid,
643
+ command: redactCommand(`${shell} ${args.join(" ")}`),
644
+ args: redactCommand(args.join(" ")).split(" ").filter(Boolean),
645
+ cwd: spawnCwd,
646
+ background: true,
647
+ startedAt: new Date(startedAt).toISOString()
648
+ });
649
+ emitProcessCompleted({
650
+ exitCode: 1,
651
+ durationMs: Date.now() - startedAt,
652
+ stdoutBytes: 0,
653
+ stderrBytes: 0,
654
+ timedOut: false,
655
+ endedAt: (/* @__PURE__ */ new Date()).toISOString()
656
+ });
657
+ yield {
658
+ type: "final",
659
+ output: {
660
+ output: "",
661
+ exit_code: 1,
662
+ timed_out: false,
663
+ pid: null,
664
+ error: `spawn failed: ${err instanceof Error ? err.message : String(err)}`
665
+ }
666
+ };
667
+ return;
668
+ }
637
669
  const pid2 = child2.pid;
638
670
  const stdoutBytes2 = 0;
639
671
  const stderrBytes2 = 0;
640
672
  let telemetryCompleted2 = false;
673
+ let bgErrorOccurred = false;
674
+ let bgSettled = false;
641
675
  emitProcessStarted({
642
676
  ...pid2 !== void 0 ? { pid: pid2 } : {},
643
677
  parentPid: process.pid,
@@ -675,15 +709,33 @@ var bashTool = {
675
709
  child2.on("close", () => registry.unregister(pid2));
676
710
  }
677
711
  child2.on("error", () => {
678
- if (typeof pid2 === "number") registry.unregister(pid2);
712
+ if (bgSettled) return;
713
+ bgErrorOccurred = true;
679
714
  registry.afterCall(Date.now() - startedAt, true, bypassBreaker);
680
715
  completeBackground(1);
681
716
  });
682
717
  child2.on("close", (code, signal) => {
683
- registry.afterCall(Date.now() - startedAt, false, bypassBreaker);
718
+ bgSettled = true;
719
+ if (bgErrorOccurred) return;
720
+ const failed = code !== 0 && code !== null || !!signal;
721
+ registry.afterCall(Date.now() - startedAt, failed, bypassBreaker);
684
722
  completeBackground(code ?? (signal ? 1 : 0), signal ?? void 0);
685
723
  });
686
- if (typeof pid2 === "number") child2.unref();
724
+ if (typeof pid2 !== "number") {
725
+ completeBackground(1);
726
+ yield {
727
+ type: "final",
728
+ output: {
729
+ output: "",
730
+ exit_code: 1,
731
+ timed_out: false,
732
+ pid: null,
733
+ error: "Failed to launch background process: invalid PID"
734
+ }
735
+ };
736
+ return;
737
+ }
738
+ child2.unref();
687
739
  yield {
688
740
  type: "final",
689
741
  output: {
@@ -705,14 +757,46 @@ var bashTool = {
705
757
  });
706
758
  return;
707
759
  }
708
- const child = spawn(shell, args, {
709
- cwd: spawnCwd,
710
- env,
711
- stdio: ["ignore", "pipe", "pipe"],
712
- detached,
713
- windowsHide: true,
714
- ...isWin2 ? {} : { signal: callerSignal }
715
- });
760
+ let child;
761
+ try {
762
+ child = spawn(shell, args, {
763
+ cwd: spawnCwd,
764
+ env,
765
+ stdio: ["ignore", "pipe", "pipe"],
766
+ detached,
767
+ windowsHide: true,
768
+ ...isWin2 ? {} : { signal: callerSignal }
769
+ });
770
+ } catch (err) {
771
+ registry.afterCall(Date.now() - startedAt, true, bypassBreaker);
772
+ emitProcessStarted({
773
+ parentPid: process.pid,
774
+ command: redactCommand(`${shell} ${args.join(" ")}`),
775
+ args: redactCommand(args.join(" ")).split(" ").filter(Boolean),
776
+ cwd: spawnCwd,
777
+ background: false,
778
+ startedAt: new Date(startedAt).toISOString()
779
+ });
780
+ emitProcessCompleted({
781
+ exitCode: 1,
782
+ durationMs: Date.now() - startedAt,
783
+ stdoutBytes: 0,
784
+ stderrBytes: 0,
785
+ timedOut: false,
786
+ endedAt: (/* @__PURE__ */ new Date()).toISOString()
787
+ });
788
+ yield {
789
+ type: "final",
790
+ output: {
791
+ output: "",
792
+ exit_code: 1,
793
+ timed_out: false,
794
+ pid: null,
795
+ error: `spawn failed: ${err instanceof Error ? err.message : String(err)}`
796
+ }
797
+ };
798
+ return;
799
+ }
716
800
  const pid = child.pid;
717
801
  let stdoutBytes = 0;
718
802
  let stderrBytes = 0;
@@ -862,15 +946,21 @@ var bashTool = {
862
946
  const onStderrData = (chunk) => onData(chunk, "stderr");
863
947
  child.stdout?.on("data", onStdoutData);
864
948
  child.stderr?.on("data", onStderrData);
949
+ let fgErrorOccurred = false;
950
+ let sawClose = false;
865
951
  child.on("error", (err) => {
952
+ if (sawClose) return;
953
+ fgErrorOccurred = true;
866
954
  for (const t of timers) clearTimeout(t);
867
955
  registry.afterCall(Date.now() - startedAt, true);
868
956
  completeForeground(1);
869
957
  push({ kind: "error", err });
870
958
  });
871
959
  child.on("close", (code, signal) => {
960
+ sawClose = true;
872
961
  for (const t of timers) clearTimeout(t);
873
962
  if (typeof pid === "number") registry.unregister(pid);
963
+ if (fgErrorOccurred) return;
874
964
  registry.afterCall(Date.now() - startedAt, code !== 0 && code !== null);
875
965
  completeForeground(timedOut ? 124 : code ?? (signal ? 1 : 0), signal ?? void 0);
876
966
  const tail = stdoutDecoder.end() + stderrDecoder.end();
@@ -885,7 +975,33 @@ var bashTool = {
885
975
  while (true) {
886
976
  const c = await next();
887
977
  resumeIfDrained();
888
- if (c.kind === "error") throw c.err;
978
+ if (c.kind === "error") {
979
+ const isAbort = c.err?.code === "ABORT_ERR" || callerSignal.aborted;
980
+ const remainder = flush();
981
+ if (remainder !== null) {
982
+ yield { type: "partial_output", text: remainder };
983
+ }
984
+ const spooled = spool.finalize();
985
+ yield {
986
+ type: "final",
987
+ output: {
988
+ output: normalizeCommandOutput(buf) + (spooled ? spoolNote(spooled) : "") + pipeToShellNote,
989
+ exit_code: isAbort ? 124 : 1,
990
+ timed_out: isAbort,
991
+ pid: pid ?? null,
992
+ error: isAbort ? "Command aborted by user or signal" : c.err.message
993
+ }
994
+ };
995
+ ctx.recordSideEffect?.({
996
+ toolUseId: `bash-${Date.now()}`,
997
+ toolName: "bash",
998
+ ts: (/* @__PURE__ */ new Date()).toISOString(),
999
+ input: { command: redactCommand(input.command) },
1000
+ outcome: isAbort ? "aborted" : `error (${c.err.message})`,
1001
+ risk: "shell"
1002
+ });
1003
+ return;
1004
+ }
889
1005
  if (c.kind === "end") {
890
1006
  const remainder = flush();
891
1007
  if (remainder !== null) {
@@ -930,7 +1046,7 @@ ${hint}` : "") + pipeToShellNote,
930
1046
  child.stderr?.off("data", onStderrData);
931
1047
  child.stdout?.destroy();
932
1048
  child.stderr?.destroy();
933
- if (child.exitCode === null && !child.killed) {
1049
+ if (!sawClose && child.exitCode === null && !child.killed) {
934
1050
  if (typeof pid === "number") registry.kill(pid, { force: true });
935
1051
  else killWithTimeout(child, 2e3);
936
1052
  }
@@ -977,4 +1093,4 @@ export {
977
1093
  checkAndBlockKillCommand,
978
1094
  bashTool
979
1095
  };
980
- //# sourceMappingURL=chunk-NN2SNP2R.js.map
1096
+ //# sourceMappingURL=chunk-6H4ERJP7.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-MSOAX3GC.js";
4
4
  import {
5
5
  enqueueReindex
6
- } from "./chunk-ZTCJCYLN.js";
6
+ } from "./chunk-TI5COGLY.js";
7
7
  import {
8
8
  safeResolveReal,
9
9
  sha256hex,
@@ -518,4 +518,4 @@ Compare this against your old_string and retry with the file's actual text.` : "
518
518
  export {
519
519
  editTool
520
520
  };
521
- //# sourceMappingURL=chunk-DK4J2WMH.js.map
521
+ //# sourceMappingURL=chunk-7XUEPBNT.js.map
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-ZBMANLYH.js";
7
7
  import {
8
8
  enqueueReindex
9
- } from "./chunk-ZTCJCYLN.js";
9
+ } from "./chunk-TI5COGLY.js";
10
10
  import {
11
11
  isBinaryBuffer,
12
12
  safeResolveReal,
@@ -413,4 +413,4 @@ export {
413
413
  replaceTool,
414
414
  __resetRgDetectionForTests
415
415
  };
416
- //# sourceMappingURL=chunk-IYH4OHBP.js.map
416
+ //# sourceMappingURL=chunk-DKHMPKDG.js.map
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  resolvePythonBinary
3
- } from "./chunk-VVZPQPTY.js";
3
+ } from "./chunk-3AU6CZWL.js";
4
4
  import {
5
5
  parseParserBatchOutput,
6
+ recordParserSubprocess,
6
7
  withSpawnGate
7
- } from "./chunk-UCYQTZ7F.js";
8
+ } from "./chunk-ZKC5UNGD.js";
8
9
  import {
9
10
  resolveWin32Command
10
11
  } from "./chunk-KE7A76VC.js";
@@ -646,6 +647,7 @@ function runToolchainChild(binary, args, stdinPayload, timeoutMs) {
646
647
  let stdout = "";
647
648
  let proc;
648
649
  try {
650
+ recordParserSubprocess();
649
651
  proc = spawn(binary, args, { stdio: ["pipe", "pipe", "pipe"], windowsHide: true });
650
652
  } catch {
651
653
  resolve(null);
@@ -828,11 +830,11 @@ async function dispatch(file, content, lang) {
828
830
  return parseSymbols({ file, content, lang });
829
831
  }
830
832
  case "go": {
831
- const { parseSymbols } = await import("./go-parser-D7ELWQ7F.js");
833
+ const { parseSymbols } = await import("./go-parser-QIEXU3P2.js");
832
834
  return parseSymbols({ file, content, lang: "go" });
833
835
  }
834
836
  case "py": {
835
- const { parseSymbols } = await import("./py-parser-QC6MR4GB.js");
837
+ const { parseSymbols } = await import("./py-parser-6GJTGUXK.js");
836
838
  return parseSymbols({ file, content, lang: "py" });
837
839
  }
838
840
  case "rs": {
@@ -889,4 +891,4 @@ export {
889
891
  parseFileContent,
890
892
  parseFilesContent
891
893
  };
892
- //# sourceMappingURL=chunk-NU2IZ72J.js.map
894
+ //# sourceMappingURL=chunk-DL2ARI4S.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  builtinTools
3
- } from "./chunk-AB2CAUOP.js";
3
+ } from "./chunk-UCXFTCAI.js";
4
4
 
5
5
  // src/pack.ts
6
6
  var builtinToolsPack = {
@@ -12,4 +12,4 @@ var builtinToolsPack = {
12
12
  export {
13
13
  builtinToolsPack
14
14
  };
15
- //# sourceMappingURL=chunk-M6UV67BH.js.map
15
+ //# sourceMappingURL=chunk-EL2NJXSK.js.map