@macintacos/caret 0.3.0 → 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.
Files changed (98) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/README.md +49 -14
  3. package/commands/discovery.md +1 -1
  4. package/dist/cli.js +1600 -200
  5. package/opencode/caret.plugin.ts +238 -14
  6. package/opencode/index.ts +8 -0
  7. package/package.json +10 -2
  8. package/ui/dist/assets/{angular-html-B6NJ8Crx.js → angular-html-kKPIob-B.js} +1 -1
  9. package/ui/dist/assets/{angular-ts-FdEJue4l.js → angular-ts-CKjP4O1R.js} +1 -1
  10. package/ui/dist/assets/{apl-8jCzQ5pt.js → apl-DCRQgCPD.js} +1 -1
  11. package/ui/dist/assets/{astro-D6Uv3Zd6.js → astro-BYbWYON5.js} +1 -1
  12. package/ui/dist/assets/{blade-DdLBtQgs.js → blade-CwhP_dxJ.js} +1 -1
  13. package/ui/dist/assets/{c-BtgVJzRT.js → c-CJEVusFw.js} +1 -1
  14. package/ui/dist/assets/{cobol-BOF3ihbS.js → cobol-DIBOqviT.js} +1 -1
  15. package/ui/dist/assets/{coffee-Br1deUOy.js → coffee-BS7TY60J.js} +1 -1
  16. package/ui/dist/assets/{cpp-BuRF7xA8.js → cpp-D1DVYlIO.js} +1 -1
  17. package/ui/dist/assets/{crystal-C2zE7OWx.js → crystal-1wNBwJ9X.js} +1 -1
  18. package/ui/dist/assets/{css-iBwOFG5O.js → css-DcRg7BqA.js} +1 -1
  19. package/ui/dist/assets/{dist-CtqCYfGw.js → dist-BPvuZVb2.js} +1 -1
  20. package/ui/dist/assets/{dist-C4FPvSXr.js → dist-BeSPrXBn.js} +1 -1
  21. package/ui/dist/assets/{dist-DIdA1vYB.js → dist-Bm-_E_MU.js} +1 -1
  22. package/ui/dist/assets/{dist-jmyqwp8P.js → dist-Buh6GXb2.js} +1 -1
  23. package/ui/dist/assets/{dist--moZHrIw.js → dist-C0x7GorT.js} +1 -1
  24. package/ui/dist/assets/{dist-Dm7ikdu5.js → dist-C2049AtS.js} +1 -1
  25. package/ui/dist/assets/{dist-zkfAcw6C.js → dist-C7ysmu-x.js} +1 -1
  26. package/ui/dist/assets/{dist-D2IYj7rL.js → dist-CA76eI1h.js} +1 -1
  27. package/ui/dist/assets/{dist-DhFSo_KF.js → dist-CZ-hU0oG.js} +1 -1
  28. package/ui/dist/assets/{dist-Diqv5yoL.js → dist-Cyz1Y8uV.js} +1 -1
  29. package/ui/dist/assets/{dist-DheG7L5T.js → dist-CzDZ2KMv.js} +1 -1
  30. package/ui/dist/assets/{dist-DXeIzOJW.js → dist-DBvtZoff.js} +1 -1
  31. package/ui/dist/assets/{dist-CDXacocg.js → dist-DNG5YE4w.js} +1 -1
  32. package/ui/dist/assets/{dist-DvWv2GjQ.js → dist-DPr7mnLy.js} +1 -1
  33. package/ui/dist/assets/{dist-DSFoRH4B.js → dist-Dhe__fm5.js} +1 -1
  34. package/ui/dist/assets/{dist-D0u8lgi2.js → dist-afCEYO1j.js} +1 -1
  35. package/ui/dist/assets/{dist-CsIQFmL2.js → dist-fAkxRpOI.js} +1 -1
  36. package/ui/dist/assets/{edge-C8C1WH_b.js → edge-DhG5RI3d.js} +1 -1
  37. package/ui/dist/assets/{elixir-ChioPNrw.js → elixir-k8JKnHNU.js} +1 -1
  38. package/ui/dist/assets/{elm-DrMVy3GL.js → elm-BCt58sPl.js} +1 -1
  39. package/ui/dist/assets/{erb-B3LvCl6V.js → erb-gEaFK19o.js} +1 -1
  40. package/ui/dist/assets/{git-rebase-Bv1Z90mV.js → git-rebase-PGNnuu_q.js} +1 -1
  41. package/ui/dist/assets/{glimmer-js-_Cj2ZxqT.js → glimmer-js-BShMa8kS.js} +1 -1
  42. package/ui/dist/assets/{glimmer-ts-eeir-ofz.js → glimmer-ts-BBjvNufU.js} +1 -1
  43. package/ui/dist/assets/{glsl-Zcj4mBmc.js → glsl-CVu5XUh6.js} +1 -1
  44. package/ui/dist/assets/{graphql-DcI0CImY.js → graphql-CpSUkXDO.js} +1 -1
  45. package/ui/dist/assets/{hack-CRMO6OEY.js → hack-vYYr_EuM.js} +1 -1
  46. package/ui/dist/assets/{haml-vpaJ2U9N.js → haml-aiyqEFS_.js} +1 -1
  47. package/ui/dist/assets/{handlebars-BmRnoKX5.js → handlebars-vKdd7ZE6.js} +1 -1
  48. package/ui/dist/assets/{html-CWopqLKh.js → html-BSDB9v3Y.js} +1 -1
  49. package/ui/dist/assets/{html-derivative-kjil5-1g.js → html-derivative-V8cBpxuT.js} +1 -1
  50. package/ui/dist/assets/{http-BsiD1_wo.js → http-DXSNVmLc.js} +1 -1
  51. package/ui/dist/assets/{hurl-BSOSzca8.js → hurl-eKV70JUb.js} +1 -1
  52. package/ui/dist/assets/{index-anQLM8ZA.js → index-C3YoPLgV.js} +4 -4
  53. package/ui/dist/assets/{java-B3dX7M_O.js → java-DGolWD2l.js} +1 -1
  54. package/ui/dist/assets/{javascript-FM1qUZzw.js → javascript-DcKrb1R6.js} +1 -1
  55. package/ui/dist/assets/{jinja-DVVPq-Qq.js → jinja-O0MduF1V.js} +1 -1
  56. package/ui/dist/assets/{jison-DZjXlKnT.js → jison-BGBc5HtG.js} +1 -1
  57. package/ui/dist/assets/{json-psWWRfU7.js → json-B-Q47BuG.js} +1 -1
  58. package/ui/dist/assets/{jsx-Bv0NBlC9.js → jsx-B__N5PZx.js} +1 -1
  59. package/ui/dist/assets/{julia-DRPZCNs5.js → julia-BfiIt3AD.js} +1 -1
  60. package/ui/dist/assets/{just-CznON7Md.js → just-CN940-eY.js} +1 -1
  61. package/ui/dist/assets/{latex-99tFYwaR.js → latex-wUKEeqEd.js} +1 -1
  62. package/ui/dist/assets/{liquid-8z3tzRYn.js → liquid-D2cnd1Ez.js} +1 -1
  63. package/ui/dist/assets/{lua-BZoKCS17.js → lua-BQiIdljT.js} +1 -1
  64. package/ui/dist/assets/{marko-BU9z-RZr.js → marko-BCqypbre.js} +1 -1
  65. package/ui/dist/assets/{mdc-C38yLzkY.js → mdc-105-eiCZ.js} +1 -1
  66. package/ui/dist/assets/{nginx-UMVInepI.js → nginx-C5dkaLo6.js} +1 -1
  67. package/ui/dist/assets/{nim-Du4jXclQ.js → nim-RJQN31Xa.js} +1 -1
  68. package/ui/dist/assets/{perl-CoEbwzPf.js → perl-DZkWjug_.js} +1 -1
  69. package/ui/dist/assets/{php-ubTDGUam.js → php-OoKYDxlw.js} +1 -1
  70. package/ui/dist/assets/{pug-Bmsmvvm7.js → pug-CDXuXfau.js} +1 -1
  71. package/ui/dist/assets/{qml-YXj-z032.js → qml-BSj8AX1e.js} +1 -1
  72. package/ui/dist/assets/{r-BNkIpWO8.js → r-DlO747T6.js} +1 -1
  73. package/ui/dist/assets/{razor-ZM--hAhl.js → razor-D1gVuaXL.js} +1 -1
  74. package/ui/dist/assets/{regexp-CHr2m78T.js → regexp-CGVqhulu.js} +1 -1
  75. package/ui/dist/assets/{rst-Xx0XAo8H.js → rst-DtURuW7a.js} +1 -1
  76. package/ui/dist/assets/{ruby-BWgyGqGH.js → ruby-Bc3kUlvr.js} +1 -1
  77. package/ui/dist/assets/{sas-CwTmTlh0.js → sas-CFQgZChj.js} +1 -1
  78. package/ui/dist/assets/{scss-DNgS20lR.js → scss-B8cq7hhb.js} +1 -1
  79. package/ui/dist/assets/{shellscript-Dkezxj03.js → shellscript-C_GHS-ym.js} +1 -1
  80. package/ui/dist/assets/{shellsession-D6yCCjOL.js → shellsession-CTplGpC8.js} +1 -1
  81. package/ui/dist/assets/{soy-lzhm7a9Y.js → soy-BgD_ErAN.js} +1 -1
  82. package/ui/dist/assets/{sql-Yo8AWGPM.js → sql-BnGnr4ii.js} +1 -1
  83. package/ui/dist/assets/{stata-D62k9gHq.js → stata-qCQsVpGc.js} +1 -1
  84. package/ui/dist/assets/{surrealql-qp-qEg-3.js → surrealql-BqH_LSaF.js} +1 -1
  85. package/ui/dist/assets/{svelte-DLztoC2n.js → svelte-Bu1vTtJQ.js} +1 -1
  86. package/ui/dist/assets/{templ-Cu6WsZcl.js → templ-B5jQzs9l.js} +1 -1
  87. package/ui/dist/assets/{tex-CqZU9zkk.js → tex-BJ-wZPSn.js} +1 -1
  88. package/ui/dist/assets/{ts-tags-ClqaCWh2.js → ts-tags-DuLm-TvJ.js} +1 -1
  89. package/ui/dist/assets/{tsx-Cj58ow-S.js → tsx-BPiBkGlY.js} +1 -1
  90. package/ui/dist/assets/{twig-CgaKnAdg.js → twig-CdQnHxAS.js} +1 -1
  91. package/ui/dist/assets/{typescript-CKElJ_dH.js → typescript-Dp_zdoqe.js} +1 -1
  92. package/ui/dist/assets/{vue-DtckUkhv.js → vue-BmKvlxSZ.js} +1 -1
  93. package/ui/dist/assets/{vue-html-Cqq7SmCi.js → vue-html-CizabNef.js} +1 -1
  94. package/ui/dist/assets/{vue-vine-Dp4BXiQa.js → vue-vine-JH1Msnx4.js} +1 -1
  95. package/ui/dist/assets/{xml-C3UNSSfc.js → xml-DW7DdZow.js} +1 -1
  96. package/ui/dist/assets/{xsl-BL_LCJsy.js → xsl-6zDkD8bR.js} +1 -1
  97. package/ui/dist/assets/{yaml-CD_CHV62.js → yaml-W1qZ5vOg.js} +1 -1
  98. package/ui/dist/index.html +1 -1
package/dist/cli.js CHANGED
@@ -1049,8 +1049,8 @@ var require_quick_format_unescaped = __commonJS((exports, module) => {
1049
1049
  return '"[Circular]"';
1050
1050
  }
1051
1051
  }
1052
- module.exports = format;
1053
- function format(f, args, opts) {
1052
+ module.exports = format2;
1053
+ function format2(f, args, opts) {
1054
1054
  var ss = opts && opts.stringify || tryStringify;
1055
1055
  var offset = 1;
1056
1056
  if (typeof f === "object" && f !== null) {
@@ -2507,7 +2507,7 @@ var require_thread_stream = __commonJS((exports, module) => {
2507
2507
  var require_transport = __commonJS((exports, module) => {
2508
2508
  var __dirname = "/Users/juliantorres/GitLocal/Play/caret/node_modules/.bun/pino@10.3.1/node_modules/pino/lib";
2509
2509
  var { createRequire } = __require("module");
2510
- var { existsSync: existsSync2 } = __require("fs");
2510
+ var { existsSync: existsSync3 } = __require("fs");
2511
2511
  var getCallers = require_caller();
2512
2512
  var { join: join6, isAbsolute, sep } = __require("path");
2513
2513
  var { fileURLToPath: fileURLToPath2 } = __require("url");
@@ -2581,7 +2581,7 @@ var require_transport = __commonJS((exports, module) => {
2581
2581
  return false;
2582
2582
  }
2583
2583
  }
2584
- return isAbsolute(path) && !existsSync2(path);
2584
+ return isAbsolute(path) && !existsSync3(path);
2585
2585
  }
2586
2586
  function stripQuotes(value) {
2587
2587
  const first = value[0];
@@ -2726,7 +2726,7 @@ var require_transport = __commonJS((exports, module) => {
2726
2726
  // node_modules/.bun/pino@10.3.1/node_modules/pino/lib/tools.js
2727
2727
  var require_tools = __commonJS((exports, module) => {
2728
2728
  var diagChan = __require("diagnostics_channel");
2729
- var format = require_quick_format_unescaped();
2729
+ var format2 = require_quick_format_unescaped();
2730
2730
  var { mapHttpRequest, mapHttpResponse } = require_pino_std_serializers();
2731
2731
  var SonicBoom = require_sonic_boom();
2732
2732
  var onExit = require_on_exit_leak_free();
@@ -2780,13 +2780,13 @@ var require_tools = __commonJS((exports, module) => {
2780
2780
  if (typeof this[msgPrefixSym] === "string" && msg !== undefined && msg !== null) {
2781
2781
  msg = this[msgPrefixSym] + msg;
2782
2782
  }
2783
- this[writeSym](o, format(msg, formatParams, this[formatOptsSym]), level);
2783
+ this[writeSym](o, format2(msg, formatParams, this[formatOptsSym]), level);
2784
2784
  } else {
2785
2785
  let msg = o === undefined ? n.shift() : o;
2786
2786
  if (typeof this[msgPrefixSym] === "string" && msg !== undefined && msg !== null) {
2787
2787
  msg = this[msgPrefixSym] + msg;
2788
2788
  }
2789
- this[writeSym](null, format(msg, n, this[formatOptsSym]), level);
2789
+ this[writeSym](null, format2(msg, n, this[formatOptsSym]), level);
2790
2790
  }
2791
2791
  }
2792
2792
  }
@@ -5650,26 +5650,1343 @@ function fatalDenyLine3(reason) {
5650
5650
  }
5651
5651
 
5652
5652
  // src/adapters/opencode/install.ts
5653
- import { existsSync, readFileSync as readFileSync3 } from "fs";
5653
+ import { existsSync as existsSync2, readFileSync as readFileSync3 } from "fs";
5654
5654
  import { join as join4 } from "path";
5655
5655
 
5656
+ // node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/scanner.js
5657
+ function createScanner(text, ignoreTrivia = false) {
5658
+ const len = text.length;
5659
+ let pos = 0, value = "", tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0;
5660
+ function scanHexDigits(count, exact) {
5661
+ let digits = 0;
5662
+ let value2 = 0;
5663
+ while (digits < count || !exact) {
5664
+ let ch = text.charCodeAt(pos);
5665
+ if (ch >= 48 && ch <= 57) {
5666
+ value2 = value2 * 16 + ch - 48;
5667
+ } else if (ch >= 65 && ch <= 70) {
5668
+ value2 = value2 * 16 + ch - 65 + 10;
5669
+ } else if (ch >= 97 && ch <= 102) {
5670
+ value2 = value2 * 16 + ch - 97 + 10;
5671
+ } else {
5672
+ break;
5673
+ }
5674
+ pos++;
5675
+ digits++;
5676
+ }
5677
+ if (digits < count) {
5678
+ value2 = -1;
5679
+ }
5680
+ return value2;
5681
+ }
5682
+ function setPosition(newPosition) {
5683
+ pos = newPosition;
5684
+ value = "";
5685
+ tokenOffset = 0;
5686
+ token = 16;
5687
+ scanError = 0;
5688
+ }
5689
+ function scanNumber() {
5690
+ let start = pos;
5691
+ if (text.charCodeAt(pos) === 48) {
5692
+ pos++;
5693
+ } else {
5694
+ pos++;
5695
+ while (pos < text.length && isDigit(text.charCodeAt(pos))) {
5696
+ pos++;
5697
+ }
5698
+ }
5699
+ if (pos < text.length && text.charCodeAt(pos) === 46) {
5700
+ pos++;
5701
+ if (pos < text.length && isDigit(text.charCodeAt(pos))) {
5702
+ pos++;
5703
+ while (pos < text.length && isDigit(text.charCodeAt(pos))) {
5704
+ pos++;
5705
+ }
5706
+ } else {
5707
+ scanError = 3;
5708
+ return text.substring(start, pos);
5709
+ }
5710
+ }
5711
+ let end = pos;
5712
+ if (pos < text.length && (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101)) {
5713
+ pos++;
5714
+ if (pos < text.length && text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) {
5715
+ pos++;
5716
+ }
5717
+ if (pos < text.length && isDigit(text.charCodeAt(pos))) {
5718
+ pos++;
5719
+ while (pos < text.length && isDigit(text.charCodeAt(pos))) {
5720
+ pos++;
5721
+ }
5722
+ end = pos;
5723
+ } else {
5724
+ scanError = 3;
5725
+ }
5726
+ }
5727
+ return text.substring(start, end);
5728
+ }
5729
+ function scanString() {
5730
+ let result = "", start = pos;
5731
+ while (true) {
5732
+ if (pos >= len) {
5733
+ result += text.substring(start, pos);
5734
+ scanError = 2;
5735
+ break;
5736
+ }
5737
+ const ch = text.charCodeAt(pos);
5738
+ if (ch === 34) {
5739
+ result += text.substring(start, pos);
5740
+ pos++;
5741
+ break;
5742
+ }
5743
+ if (ch === 92) {
5744
+ result += text.substring(start, pos);
5745
+ pos++;
5746
+ if (pos >= len) {
5747
+ scanError = 2;
5748
+ break;
5749
+ }
5750
+ const ch2 = text.charCodeAt(pos++);
5751
+ switch (ch2) {
5752
+ case 34:
5753
+ result += '"';
5754
+ break;
5755
+ case 92:
5756
+ result += "\\";
5757
+ break;
5758
+ case 47:
5759
+ result += "/";
5760
+ break;
5761
+ case 98:
5762
+ result += "\b";
5763
+ break;
5764
+ case 102:
5765
+ result += "\f";
5766
+ break;
5767
+ case 110:
5768
+ result += `
5769
+ `;
5770
+ break;
5771
+ case 114:
5772
+ result += "\r";
5773
+ break;
5774
+ case 116:
5775
+ result += "\t";
5776
+ break;
5777
+ case 117:
5778
+ const ch3 = scanHexDigits(4, true);
5779
+ if (ch3 >= 0) {
5780
+ result += String.fromCharCode(ch3);
5781
+ } else {
5782
+ scanError = 4;
5783
+ }
5784
+ break;
5785
+ default:
5786
+ scanError = 5;
5787
+ }
5788
+ start = pos;
5789
+ continue;
5790
+ }
5791
+ if (ch >= 0 && ch <= 31) {
5792
+ if (isLineBreak(ch)) {
5793
+ result += text.substring(start, pos);
5794
+ scanError = 2;
5795
+ break;
5796
+ } else {
5797
+ scanError = 6;
5798
+ }
5799
+ }
5800
+ pos++;
5801
+ }
5802
+ return result;
5803
+ }
5804
+ function scanNext() {
5805
+ value = "";
5806
+ scanError = 0;
5807
+ tokenOffset = pos;
5808
+ lineStartOffset = lineNumber;
5809
+ prevTokenLineStartOffset = tokenLineStartOffset;
5810
+ if (pos >= len) {
5811
+ tokenOffset = len;
5812
+ return token = 17;
5813
+ }
5814
+ let code = text.charCodeAt(pos);
5815
+ if (isWhiteSpace(code)) {
5816
+ do {
5817
+ pos++;
5818
+ value += String.fromCharCode(code);
5819
+ code = text.charCodeAt(pos);
5820
+ } while (isWhiteSpace(code));
5821
+ return token = 15;
5822
+ }
5823
+ if (isLineBreak(code)) {
5824
+ pos++;
5825
+ value += String.fromCharCode(code);
5826
+ if (code === 13 && text.charCodeAt(pos) === 10) {
5827
+ pos++;
5828
+ value += `
5829
+ `;
5830
+ }
5831
+ lineNumber++;
5832
+ tokenLineStartOffset = pos;
5833
+ return token = 14;
5834
+ }
5835
+ switch (code) {
5836
+ case 123:
5837
+ pos++;
5838
+ return token = 1;
5839
+ case 125:
5840
+ pos++;
5841
+ return token = 2;
5842
+ case 91:
5843
+ pos++;
5844
+ return token = 3;
5845
+ case 93:
5846
+ pos++;
5847
+ return token = 4;
5848
+ case 58:
5849
+ pos++;
5850
+ return token = 6;
5851
+ case 44:
5852
+ pos++;
5853
+ return token = 5;
5854
+ case 34:
5855
+ pos++;
5856
+ value = scanString();
5857
+ return token = 10;
5858
+ case 47:
5859
+ const start = pos - 1;
5860
+ if (text.charCodeAt(pos + 1) === 47) {
5861
+ pos += 2;
5862
+ while (pos < len) {
5863
+ if (isLineBreak(text.charCodeAt(pos))) {
5864
+ break;
5865
+ }
5866
+ pos++;
5867
+ }
5868
+ value = text.substring(start, pos);
5869
+ return token = 12;
5870
+ }
5871
+ if (text.charCodeAt(pos + 1) === 42) {
5872
+ pos += 2;
5873
+ const safeLength = len - 1;
5874
+ let commentClosed = false;
5875
+ while (pos < safeLength) {
5876
+ const ch = text.charCodeAt(pos);
5877
+ if (ch === 42 && text.charCodeAt(pos + 1) === 47) {
5878
+ pos += 2;
5879
+ commentClosed = true;
5880
+ break;
5881
+ }
5882
+ pos++;
5883
+ if (isLineBreak(ch)) {
5884
+ if (ch === 13 && text.charCodeAt(pos) === 10) {
5885
+ pos++;
5886
+ }
5887
+ lineNumber++;
5888
+ tokenLineStartOffset = pos;
5889
+ }
5890
+ }
5891
+ if (!commentClosed) {
5892
+ pos++;
5893
+ scanError = 1;
5894
+ }
5895
+ value = text.substring(start, pos);
5896
+ return token = 13;
5897
+ }
5898
+ value += String.fromCharCode(code);
5899
+ pos++;
5900
+ return token = 16;
5901
+ case 45:
5902
+ value += String.fromCharCode(code);
5903
+ pos++;
5904
+ if (pos === len || !isDigit(text.charCodeAt(pos))) {
5905
+ return token = 16;
5906
+ }
5907
+ case 48:
5908
+ case 49:
5909
+ case 50:
5910
+ case 51:
5911
+ case 52:
5912
+ case 53:
5913
+ case 54:
5914
+ case 55:
5915
+ case 56:
5916
+ case 57:
5917
+ value += scanNumber();
5918
+ return token = 11;
5919
+ default:
5920
+ while (pos < len && isUnknownContentCharacter(code)) {
5921
+ pos++;
5922
+ code = text.charCodeAt(pos);
5923
+ }
5924
+ if (tokenOffset !== pos) {
5925
+ value = text.substring(tokenOffset, pos);
5926
+ switch (value) {
5927
+ case "true":
5928
+ return token = 8;
5929
+ case "false":
5930
+ return token = 9;
5931
+ case "null":
5932
+ return token = 7;
5933
+ }
5934
+ return token = 16;
5935
+ }
5936
+ value += String.fromCharCode(code);
5937
+ pos++;
5938
+ return token = 16;
5939
+ }
5940
+ }
5941
+ function isUnknownContentCharacter(code) {
5942
+ if (isWhiteSpace(code) || isLineBreak(code)) {
5943
+ return false;
5944
+ }
5945
+ switch (code) {
5946
+ case 125:
5947
+ case 93:
5948
+ case 123:
5949
+ case 91:
5950
+ case 34:
5951
+ case 58:
5952
+ case 44:
5953
+ case 47:
5954
+ return false;
5955
+ }
5956
+ return true;
5957
+ }
5958
+ function scanNextNonTrivia() {
5959
+ let result;
5960
+ do {
5961
+ result = scanNext();
5962
+ } while (result >= 12 && result <= 15);
5963
+ return result;
5964
+ }
5965
+ return {
5966
+ setPosition,
5967
+ getPosition: () => pos,
5968
+ scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
5969
+ getToken: () => token,
5970
+ getTokenValue: () => value,
5971
+ getTokenOffset: () => tokenOffset,
5972
+ getTokenLength: () => pos - tokenOffset,
5973
+ getTokenStartLine: () => lineStartOffset,
5974
+ getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset,
5975
+ getTokenError: () => scanError
5976
+ };
5977
+ }
5978
+ function isWhiteSpace(ch) {
5979
+ return ch === 32 || ch === 9;
5980
+ }
5981
+ function isLineBreak(ch) {
5982
+ return ch === 10 || ch === 13;
5983
+ }
5984
+ function isDigit(ch) {
5985
+ return ch >= 48 && ch <= 57;
5986
+ }
5987
+ var CharacterCodes;
5988
+ (function(CharacterCodes2) {
5989
+ CharacterCodes2[CharacterCodes2["lineFeed"] = 10] = "lineFeed";
5990
+ CharacterCodes2[CharacterCodes2["carriageReturn"] = 13] = "carriageReturn";
5991
+ CharacterCodes2[CharacterCodes2["space"] = 32] = "space";
5992
+ CharacterCodes2[CharacterCodes2["_0"] = 48] = "_0";
5993
+ CharacterCodes2[CharacterCodes2["_1"] = 49] = "_1";
5994
+ CharacterCodes2[CharacterCodes2["_2"] = 50] = "_2";
5995
+ CharacterCodes2[CharacterCodes2["_3"] = 51] = "_3";
5996
+ CharacterCodes2[CharacterCodes2["_4"] = 52] = "_4";
5997
+ CharacterCodes2[CharacterCodes2["_5"] = 53] = "_5";
5998
+ CharacterCodes2[CharacterCodes2["_6"] = 54] = "_6";
5999
+ CharacterCodes2[CharacterCodes2["_7"] = 55] = "_7";
6000
+ CharacterCodes2[CharacterCodes2["_8"] = 56] = "_8";
6001
+ CharacterCodes2[CharacterCodes2["_9"] = 57] = "_9";
6002
+ CharacterCodes2[CharacterCodes2["a"] = 97] = "a";
6003
+ CharacterCodes2[CharacterCodes2["b"] = 98] = "b";
6004
+ CharacterCodes2[CharacterCodes2["c"] = 99] = "c";
6005
+ CharacterCodes2[CharacterCodes2["d"] = 100] = "d";
6006
+ CharacterCodes2[CharacterCodes2["e"] = 101] = "e";
6007
+ CharacterCodes2[CharacterCodes2["f"] = 102] = "f";
6008
+ CharacterCodes2[CharacterCodes2["g"] = 103] = "g";
6009
+ CharacterCodes2[CharacterCodes2["h"] = 104] = "h";
6010
+ CharacterCodes2[CharacterCodes2["i"] = 105] = "i";
6011
+ CharacterCodes2[CharacterCodes2["j"] = 106] = "j";
6012
+ CharacterCodes2[CharacterCodes2["k"] = 107] = "k";
6013
+ CharacterCodes2[CharacterCodes2["l"] = 108] = "l";
6014
+ CharacterCodes2[CharacterCodes2["m"] = 109] = "m";
6015
+ CharacterCodes2[CharacterCodes2["n"] = 110] = "n";
6016
+ CharacterCodes2[CharacterCodes2["o"] = 111] = "o";
6017
+ CharacterCodes2[CharacterCodes2["p"] = 112] = "p";
6018
+ CharacterCodes2[CharacterCodes2["q"] = 113] = "q";
6019
+ CharacterCodes2[CharacterCodes2["r"] = 114] = "r";
6020
+ CharacterCodes2[CharacterCodes2["s"] = 115] = "s";
6021
+ CharacterCodes2[CharacterCodes2["t"] = 116] = "t";
6022
+ CharacterCodes2[CharacterCodes2["u"] = 117] = "u";
6023
+ CharacterCodes2[CharacterCodes2["v"] = 118] = "v";
6024
+ CharacterCodes2[CharacterCodes2["w"] = 119] = "w";
6025
+ CharacterCodes2[CharacterCodes2["x"] = 120] = "x";
6026
+ CharacterCodes2[CharacterCodes2["y"] = 121] = "y";
6027
+ CharacterCodes2[CharacterCodes2["z"] = 122] = "z";
6028
+ CharacterCodes2[CharacterCodes2["A"] = 65] = "A";
6029
+ CharacterCodes2[CharacterCodes2["B"] = 66] = "B";
6030
+ CharacterCodes2[CharacterCodes2["C"] = 67] = "C";
6031
+ CharacterCodes2[CharacterCodes2["D"] = 68] = "D";
6032
+ CharacterCodes2[CharacterCodes2["E"] = 69] = "E";
6033
+ CharacterCodes2[CharacterCodes2["F"] = 70] = "F";
6034
+ CharacterCodes2[CharacterCodes2["G"] = 71] = "G";
6035
+ CharacterCodes2[CharacterCodes2["H"] = 72] = "H";
6036
+ CharacterCodes2[CharacterCodes2["I"] = 73] = "I";
6037
+ CharacterCodes2[CharacterCodes2["J"] = 74] = "J";
6038
+ CharacterCodes2[CharacterCodes2["K"] = 75] = "K";
6039
+ CharacterCodes2[CharacterCodes2["L"] = 76] = "L";
6040
+ CharacterCodes2[CharacterCodes2["M"] = 77] = "M";
6041
+ CharacterCodes2[CharacterCodes2["N"] = 78] = "N";
6042
+ CharacterCodes2[CharacterCodes2["O"] = 79] = "O";
6043
+ CharacterCodes2[CharacterCodes2["P"] = 80] = "P";
6044
+ CharacterCodes2[CharacterCodes2["Q"] = 81] = "Q";
6045
+ CharacterCodes2[CharacterCodes2["R"] = 82] = "R";
6046
+ CharacterCodes2[CharacterCodes2["S"] = 83] = "S";
6047
+ CharacterCodes2[CharacterCodes2["T"] = 84] = "T";
6048
+ CharacterCodes2[CharacterCodes2["U"] = 85] = "U";
6049
+ CharacterCodes2[CharacterCodes2["V"] = 86] = "V";
6050
+ CharacterCodes2[CharacterCodes2["W"] = 87] = "W";
6051
+ CharacterCodes2[CharacterCodes2["X"] = 88] = "X";
6052
+ CharacterCodes2[CharacterCodes2["Y"] = 89] = "Y";
6053
+ CharacterCodes2[CharacterCodes2["Z"] = 90] = "Z";
6054
+ CharacterCodes2[CharacterCodes2["asterisk"] = 42] = "asterisk";
6055
+ CharacterCodes2[CharacterCodes2["backslash"] = 92] = "backslash";
6056
+ CharacterCodes2[CharacterCodes2["closeBrace"] = 125] = "closeBrace";
6057
+ CharacterCodes2[CharacterCodes2["closeBracket"] = 93] = "closeBracket";
6058
+ CharacterCodes2[CharacterCodes2["colon"] = 58] = "colon";
6059
+ CharacterCodes2[CharacterCodes2["comma"] = 44] = "comma";
6060
+ CharacterCodes2[CharacterCodes2["dot"] = 46] = "dot";
6061
+ CharacterCodes2[CharacterCodes2["doubleQuote"] = 34] = "doubleQuote";
6062
+ CharacterCodes2[CharacterCodes2["minus"] = 45] = "minus";
6063
+ CharacterCodes2[CharacterCodes2["openBrace"] = 123] = "openBrace";
6064
+ CharacterCodes2[CharacterCodes2["openBracket"] = 91] = "openBracket";
6065
+ CharacterCodes2[CharacterCodes2["plus"] = 43] = "plus";
6066
+ CharacterCodes2[CharacterCodes2["slash"] = 47] = "slash";
6067
+ CharacterCodes2[CharacterCodes2["formFeed"] = 12] = "formFeed";
6068
+ CharacterCodes2[CharacterCodes2["tab"] = 9] = "tab";
6069
+ })(CharacterCodes || (CharacterCodes = {}));
6070
+
6071
+ // node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/string-intern.js
6072
+ var cachedSpaces = new Array(20).fill(0).map((_, index) => {
6073
+ return " ".repeat(index);
6074
+ });
6075
+ var maxCachedValues = 200;
6076
+ var cachedBreakLinesWithSpaces = {
6077
+ " ": {
6078
+ "\n": new Array(maxCachedValues).fill(0).map((_, index) => {
6079
+ return `
6080
+ ` + " ".repeat(index);
6081
+ }),
6082
+ "\r": new Array(maxCachedValues).fill(0).map((_, index) => {
6083
+ return "\r" + " ".repeat(index);
6084
+ }),
6085
+ "\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
6086
+ return `\r
6087
+ ` + " ".repeat(index);
6088
+ })
6089
+ },
6090
+ "\t": {
6091
+ "\n": new Array(maxCachedValues).fill(0).map((_, index) => {
6092
+ return `
6093
+ ` + "\t".repeat(index);
6094
+ }),
6095
+ "\r": new Array(maxCachedValues).fill(0).map((_, index) => {
6096
+ return "\r" + "\t".repeat(index);
6097
+ }),
6098
+ "\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
6099
+ return `\r
6100
+ ` + "\t".repeat(index);
6101
+ })
6102
+ }
6103
+ };
6104
+ var supportedEols = [`
6105
+ `, "\r", `\r
6106
+ `];
6107
+
6108
+ // node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/format.js
6109
+ function format(documentText, range, options) {
6110
+ let initialIndentLevel;
6111
+ let formatText;
6112
+ let formatTextStart;
6113
+ let rangeStart;
6114
+ let rangeEnd;
6115
+ if (range) {
6116
+ rangeStart = range.offset;
6117
+ rangeEnd = rangeStart + range.length;
6118
+ formatTextStart = rangeStart;
6119
+ while (formatTextStart > 0 && !isEOL(documentText, formatTextStart - 1)) {
6120
+ formatTextStart--;
6121
+ }
6122
+ let endOffset = rangeEnd;
6123
+ while (endOffset < documentText.length && !isEOL(documentText, endOffset)) {
6124
+ endOffset++;
6125
+ }
6126
+ formatText = documentText.substring(formatTextStart, endOffset);
6127
+ initialIndentLevel = computeIndentLevel(formatText, options);
6128
+ } else {
6129
+ formatText = documentText;
6130
+ initialIndentLevel = 0;
6131
+ formatTextStart = 0;
6132
+ rangeStart = 0;
6133
+ rangeEnd = documentText.length;
6134
+ }
6135
+ const eol = getEOL(options, documentText);
6136
+ const eolFastPathSupported = supportedEols.includes(eol);
6137
+ let numberLineBreaks = 0;
6138
+ let indentLevel = 0;
6139
+ let indentValue;
6140
+ if (options.insertSpaces) {
6141
+ indentValue = cachedSpaces[options.tabSize || 4] ?? repeat(cachedSpaces[1], options.tabSize || 4);
6142
+ } else {
6143
+ indentValue = "\t";
6144
+ }
6145
+ const indentType = indentValue === "\t" ? "\t" : " ";
6146
+ let scanner = createScanner(formatText, false);
6147
+ let hasError = false;
6148
+ function newLinesAndIndent() {
6149
+ if (numberLineBreaks > 1) {
6150
+ return repeat(eol, numberLineBreaks) + repeat(indentValue, initialIndentLevel + indentLevel);
6151
+ }
6152
+ const amountOfSpaces = indentValue.length * (initialIndentLevel + indentLevel);
6153
+ if (!eolFastPathSupported || amountOfSpaces > cachedBreakLinesWithSpaces[indentType][eol].length) {
6154
+ return eol + repeat(indentValue, initialIndentLevel + indentLevel);
6155
+ }
6156
+ if (amountOfSpaces <= 0) {
6157
+ return eol;
6158
+ }
6159
+ return cachedBreakLinesWithSpaces[indentType][eol][amountOfSpaces];
6160
+ }
6161
+ function scanNext() {
6162
+ let token = scanner.scan();
6163
+ numberLineBreaks = 0;
6164
+ while (token === 15 || token === 14) {
6165
+ if (token === 14 && options.keepLines) {
6166
+ numberLineBreaks += 1;
6167
+ } else if (token === 14) {
6168
+ numberLineBreaks = 1;
6169
+ }
6170
+ token = scanner.scan();
6171
+ }
6172
+ hasError = token === 16 || scanner.getTokenError() !== 0;
6173
+ return token;
6174
+ }
6175
+ const editOperations = [];
6176
+ function addEdit(text, startOffset, endOffset) {
6177
+ if (!hasError && (!range || startOffset < rangeEnd && endOffset > rangeStart) && documentText.substring(startOffset, endOffset) !== text) {
6178
+ editOperations.push({ offset: startOffset, length: endOffset - startOffset, content: text });
6179
+ }
6180
+ }
6181
+ let firstToken = scanNext();
6182
+ if (options.keepLines && numberLineBreaks > 0) {
6183
+ addEdit(repeat(eol, numberLineBreaks), 0, 0);
6184
+ }
6185
+ if (firstToken !== 17) {
6186
+ let firstTokenStart = scanner.getTokenOffset() + formatTextStart;
6187
+ let initialIndent = indentValue.length * initialIndentLevel < 20 && options.insertSpaces ? cachedSpaces[indentValue.length * initialIndentLevel] : repeat(indentValue, initialIndentLevel);
6188
+ addEdit(initialIndent, formatTextStart, firstTokenStart);
6189
+ }
6190
+ while (firstToken !== 17) {
6191
+ let firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
6192
+ let secondToken = scanNext();
6193
+ let replaceContent = "";
6194
+ let needsLineBreak = false;
6195
+ while (numberLineBreaks === 0 && (secondToken === 12 || secondToken === 13)) {
6196
+ let commentTokenStart = scanner.getTokenOffset() + formatTextStart;
6197
+ addEdit(cachedSpaces[1], firstTokenEnd, commentTokenStart);
6198
+ firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
6199
+ needsLineBreak = secondToken === 12;
6200
+ replaceContent = needsLineBreak ? newLinesAndIndent() : "";
6201
+ secondToken = scanNext();
6202
+ }
6203
+ if (secondToken === 2) {
6204
+ if (firstToken !== 1) {
6205
+ indentLevel--;
6206
+ }
6207
+ if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && firstToken !== 1) {
6208
+ replaceContent = newLinesAndIndent();
6209
+ } else if (options.keepLines) {
6210
+ replaceContent = cachedSpaces[1];
6211
+ }
6212
+ } else if (secondToken === 4) {
6213
+ if (firstToken !== 3) {
6214
+ indentLevel--;
6215
+ }
6216
+ if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && firstToken !== 3) {
6217
+ replaceContent = newLinesAndIndent();
6218
+ } else if (options.keepLines) {
6219
+ replaceContent = cachedSpaces[1];
6220
+ }
6221
+ } else {
6222
+ switch (firstToken) {
6223
+ case 3:
6224
+ case 1:
6225
+ indentLevel++;
6226
+ if (options.keepLines && numberLineBreaks > 0 || !options.keepLines) {
6227
+ replaceContent = newLinesAndIndent();
6228
+ } else {
6229
+ replaceContent = cachedSpaces[1];
6230
+ }
6231
+ break;
6232
+ case 5:
6233
+ if (options.keepLines && numberLineBreaks > 0 || !options.keepLines) {
6234
+ replaceContent = newLinesAndIndent();
6235
+ } else {
6236
+ replaceContent = cachedSpaces[1];
6237
+ }
6238
+ break;
6239
+ case 12:
6240
+ replaceContent = newLinesAndIndent();
6241
+ break;
6242
+ case 13:
6243
+ if (numberLineBreaks > 0) {
6244
+ replaceContent = newLinesAndIndent();
6245
+ } else if (!needsLineBreak) {
6246
+ replaceContent = cachedSpaces[1];
6247
+ }
6248
+ break;
6249
+ case 6:
6250
+ if (options.keepLines && numberLineBreaks > 0) {
6251
+ replaceContent = newLinesAndIndent();
6252
+ } else if (!needsLineBreak) {
6253
+ replaceContent = cachedSpaces[1];
6254
+ }
6255
+ break;
6256
+ case 10:
6257
+ if (options.keepLines && numberLineBreaks > 0) {
6258
+ replaceContent = newLinesAndIndent();
6259
+ } else if (secondToken === 6 && !needsLineBreak) {
6260
+ replaceContent = "";
6261
+ }
6262
+ break;
6263
+ case 7:
6264
+ case 8:
6265
+ case 9:
6266
+ case 11:
6267
+ case 2:
6268
+ case 4:
6269
+ if (options.keepLines && numberLineBreaks > 0) {
6270
+ replaceContent = newLinesAndIndent();
6271
+ } else {
6272
+ if ((secondToken === 12 || secondToken === 13) && !needsLineBreak) {
6273
+ replaceContent = cachedSpaces[1];
6274
+ } else if (secondToken !== 5 && secondToken !== 17) {
6275
+ hasError = true;
6276
+ }
6277
+ }
6278
+ break;
6279
+ case 16:
6280
+ hasError = true;
6281
+ break;
6282
+ }
6283
+ if (numberLineBreaks > 0 && (secondToken === 12 || secondToken === 13)) {
6284
+ replaceContent = newLinesAndIndent();
6285
+ }
6286
+ }
6287
+ if (secondToken === 17) {
6288
+ if (options.keepLines && numberLineBreaks > 0) {
6289
+ replaceContent = newLinesAndIndent();
6290
+ } else {
6291
+ replaceContent = options.insertFinalNewline ? eol : "";
6292
+ }
6293
+ }
6294
+ const secondTokenStart = scanner.getTokenOffset() + formatTextStart;
6295
+ addEdit(replaceContent, firstTokenEnd, secondTokenStart);
6296
+ firstToken = secondToken;
6297
+ }
6298
+ return editOperations;
6299
+ }
6300
+ function repeat(s, count) {
6301
+ let result = "";
6302
+ for (let i = 0;i < count; i++) {
6303
+ result += s;
6304
+ }
6305
+ return result;
6306
+ }
6307
+ function computeIndentLevel(content, options) {
6308
+ let i = 0;
6309
+ let nChars = 0;
6310
+ const tabSize = options.tabSize || 4;
6311
+ while (i < content.length) {
6312
+ let ch = content.charAt(i);
6313
+ if (ch === cachedSpaces[1]) {
6314
+ nChars++;
6315
+ } else if (ch === "\t") {
6316
+ nChars += tabSize;
6317
+ } else {
6318
+ break;
6319
+ }
6320
+ i++;
6321
+ }
6322
+ return Math.floor(nChars / tabSize);
6323
+ }
6324
+ function getEOL(options, text) {
6325
+ for (let i = 0;i < text.length; i++) {
6326
+ const ch = text.charAt(i);
6327
+ if (ch === "\r") {
6328
+ if (i + 1 < text.length && text.charAt(i + 1) === `
6329
+ `) {
6330
+ return `\r
6331
+ `;
6332
+ }
6333
+ return "\r";
6334
+ } else if (ch === `
6335
+ `) {
6336
+ return `
6337
+ `;
6338
+ }
6339
+ }
6340
+ return options && options.eol || `
6341
+ `;
6342
+ }
6343
+ function isEOL(text, offset) {
6344
+ return `\r
6345
+ `.indexOf(text.charAt(offset)) !== -1;
6346
+ }
6347
+
6348
+ // node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/parser.js
6349
+ var ParseOptions;
6350
+ (function(ParseOptions2) {
6351
+ ParseOptions2.DEFAULT = {
6352
+ allowTrailingComma: false
6353
+ };
6354
+ })(ParseOptions || (ParseOptions = {}));
6355
+ function parse2(text, errors = [], options = ParseOptions.DEFAULT) {
6356
+ let currentProperty = null;
6357
+ let currentParent = [];
6358
+ const previousParents = [];
6359
+ function onValue(value) {
6360
+ if (Array.isArray(currentParent)) {
6361
+ currentParent.push(value);
6362
+ } else if (currentProperty !== null) {
6363
+ currentParent[currentProperty] = value;
6364
+ }
6365
+ }
6366
+ const visitor = {
6367
+ onObjectBegin: () => {
6368
+ const object = {};
6369
+ onValue(object);
6370
+ previousParents.push(currentParent);
6371
+ currentParent = object;
6372
+ currentProperty = null;
6373
+ },
6374
+ onObjectProperty: (name) => {
6375
+ currentProperty = name;
6376
+ },
6377
+ onObjectEnd: () => {
6378
+ currentParent = previousParents.pop();
6379
+ },
6380
+ onArrayBegin: () => {
6381
+ const array = [];
6382
+ onValue(array);
6383
+ previousParents.push(currentParent);
6384
+ currentParent = array;
6385
+ currentProperty = null;
6386
+ },
6387
+ onArrayEnd: () => {
6388
+ currentParent = previousParents.pop();
6389
+ },
6390
+ onLiteralValue: onValue,
6391
+ onError: (error, offset, length) => {
6392
+ errors.push({ error, offset, length });
6393
+ }
6394
+ };
6395
+ visit(text, visitor, options);
6396
+ return currentParent[0];
6397
+ }
6398
+ function parseTree(text, errors = [], options = ParseOptions.DEFAULT) {
6399
+ let currentParent = { type: "array", offset: -1, length: -1, children: [], parent: undefined };
6400
+ function ensurePropertyComplete(endOffset) {
6401
+ if (currentParent.type === "property") {
6402
+ currentParent.length = endOffset - currentParent.offset;
6403
+ currentParent = currentParent.parent;
6404
+ }
6405
+ }
6406
+ function onValue(valueNode) {
6407
+ currentParent.children.push(valueNode);
6408
+ return valueNode;
6409
+ }
6410
+ const visitor = {
6411
+ onObjectBegin: (offset) => {
6412
+ currentParent = onValue({ type: "object", offset, length: -1, parent: currentParent, children: [] });
6413
+ },
6414
+ onObjectProperty: (name, offset, length) => {
6415
+ currentParent = onValue({ type: "property", offset, length: -1, parent: currentParent, children: [] });
6416
+ currentParent.children.push({ type: "string", value: name, offset, length, parent: currentParent });
6417
+ },
6418
+ onObjectEnd: (offset, length) => {
6419
+ ensurePropertyComplete(offset + length);
6420
+ currentParent.length = offset + length - currentParent.offset;
6421
+ currentParent = currentParent.parent;
6422
+ ensurePropertyComplete(offset + length);
6423
+ },
6424
+ onArrayBegin: (offset, length) => {
6425
+ currentParent = onValue({ type: "array", offset, length: -1, parent: currentParent, children: [] });
6426
+ },
6427
+ onArrayEnd: (offset, length) => {
6428
+ currentParent.length = offset + length - currentParent.offset;
6429
+ currentParent = currentParent.parent;
6430
+ ensurePropertyComplete(offset + length);
6431
+ },
6432
+ onLiteralValue: (value, offset, length) => {
6433
+ onValue({ type: getNodeType(value), offset, length, parent: currentParent, value });
6434
+ ensurePropertyComplete(offset + length);
6435
+ },
6436
+ onSeparator: (sep, offset, length) => {
6437
+ if (currentParent.type === "property") {
6438
+ if (sep === ":") {
6439
+ currentParent.colonOffset = offset;
6440
+ } else if (sep === ",") {
6441
+ ensurePropertyComplete(offset);
6442
+ }
6443
+ }
6444
+ },
6445
+ onError: (error, offset, length) => {
6446
+ errors.push({ error, offset, length });
6447
+ }
6448
+ };
6449
+ visit(text, visitor, options);
6450
+ const result = currentParent.children[0];
6451
+ if (result) {
6452
+ delete result.parent;
6453
+ }
6454
+ return result;
6455
+ }
6456
+ function findNodeAtLocation(root, path) {
6457
+ if (!root) {
6458
+ return;
6459
+ }
6460
+ let node = root;
6461
+ for (let segment of path) {
6462
+ if (typeof segment === "string") {
6463
+ if (node.type !== "object" || !Array.isArray(node.children)) {
6464
+ return;
6465
+ }
6466
+ let found = false;
6467
+ for (const propertyNode of node.children) {
6468
+ if (Array.isArray(propertyNode.children) && propertyNode.children[0].value === segment && propertyNode.children.length === 2) {
6469
+ node = propertyNode.children[1];
6470
+ found = true;
6471
+ break;
6472
+ }
6473
+ }
6474
+ if (!found) {
6475
+ return;
6476
+ }
6477
+ } else {
6478
+ const index = segment;
6479
+ if (node.type !== "array" || index < 0 || !Array.isArray(node.children) || index >= node.children.length) {
6480
+ return;
6481
+ }
6482
+ node = node.children[index];
6483
+ }
6484
+ }
6485
+ return node;
6486
+ }
6487
+ function visit(text, visitor, options = ParseOptions.DEFAULT) {
6488
+ const _scanner = createScanner(text, false);
6489
+ const _jsonPath = [];
6490
+ let suppressedCallbacks = 0;
6491
+ function toNoArgVisit(visitFunction) {
6492
+ return visitFunction ? () => suppressedCallbacks === 0 && visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
6493
+ }
6494
+ function toOneArgVisit(visitFunction) {
6495
+ return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
6496
+ }
6497
+ function toOneArgVisitWithPath(visitFunction) {
6498
+ return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
6499
+ }
6500
+ function toBeginVisit(visitFunction) {
6501
+ return visitFunction ? () => {
6502
+ if (suppressedCallbacks > 0) {
6503
+ suppressedCallbacks++;
6504
+ } else {
6505
+ let cbReturn = visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice());
6506
+ if (cbReturn === false) {
6507
+ suppressedCallbacks = 1;
6508
+ }
6509
+ }
6510
+ } : () => true;
6511
+ }
6512
+ function toEndVisit(visitFunction) {
6513
+ return visitFunction ? () => {
6514
+ if (suppressedCallbacks > 0) {
6515
+ suppressedCallbacks--;
6516
+ }
6517
+ if (suppressedCallbacks === 0) {
6518
+ visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter());
6519
+ }
6520
+ } : () => true;
6521
+ }
6522
+ const onObjectBegin = toBeginVisit(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toEndVisit(visitor.onObjectEnd), onArrayBegin = toBeginVisit(visitor.onArrayBegin), onArrayEnd = toEndVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
6523
+ const disallowComments = options && options.disallowComments;
6524
+ const allowTrailingComma = options && options.allowTrailingComma;
6525
+ function scanNext() {
6526
+ while (true) {
6527
+ const token = _scanner.scan();
6528
+ switch (_scanner.getTokenError()) {
6529
+ case 4:
6530
+ handleError(14);
6531
+ break;
6532
+ case 5:
6533
+ handleError(15);
6534
+ break;
6535
+ case 3:
6536
+ handleError(13);
6537
+ break;
6538
+ case 1:
6539
+ if (!disallowComments) {
6540
+ handleError(11);
6541
+ }
6542
+ break;
6543
+ case 2:
6544
+ handleError(12);
6545
+ break;
6546
+ case 6:
6547
+ handleError(16);
6548
+ break;
6549
+ }
6550
+ switch (token) {
6551
+ case 12:
6552
+ case 13:
6553
+ if (disallowComments) {
6554
+ handleError(10);
6555
+ } else {
6556
+ onComment();
6557
+ }
6558
+ break;
6559
+ case 16:
6560
+ handleError(1);
6561
+ break;
6562
+ case 15:
6563
+ case 14:
6564
+ break;
6565
+ default:
6566
+ return token;
6567
+ }
6568
+ }
6569
+ }
6570
+ function handleError(error, skipUntilAfter = [], skipUntil2 = []) {
6571
+ onError(error);
6572
+ if (skipUntilAfter.length + skipUntil2.length > 0) {
6573
+ let token = _scanner.getToken();
6574
+ while (token !== 17) {
6575
+ if (skipUntilAfter.indexOf(token) !== -1) {
6576
+ scanNext();
6577
+ break;
6578
+ } else if (skipUntil2.indexOf(token) !== -1) {
6579
+ break;
6580
+ }
6581
+ token = scanNext();
6582
+ }
6583
+ }
6584
+ }
6585
+ function parseString2(isValue) {
6586
+ const value = _scanner.getTokenValue();
6587
+ if (isValue) {
6588
+ onLiteralValue(value);
6589
+ } else {
6590
+ onObjectProperty(value);
6591
+ _jsonPath.push(value);
6592
+ }
6593
+ scanNext();
6594
+ return true;
6595
+ }
6596
+ function parseLiteral() {
6597
+ switch (_scanner.getToken()) {
6598
+ case 11:
6599
+ const tokenValue = _scanner.getTokenValue();
6600
+ let value = Number(tokenValue);
6601
+ if (isNaN(value)) {
6602
+ handleError(2);
6603
+ value = 0;
6604
+ }
6605
+ onLiteralValue(value);
6606
+ break;
6607
+ case 7:
6608
+ onLiteralValue(null);
6609
+ break;
6610
+ case 8:
6611
+ onLiteralValue(true);
6612
+ break;
6613
+ case 9:
6614
+ onLiteralValue(false);
6615
+ break;
6616
+ default:
6617
+ return false;
6618
+ }
6619
+ scanNext();
6620
+ return true;
6621
+ }
6622
+ function parseProperty() {
6623
+ if (_scanner.getToken() !== 10) {
6624
+ handleError(3, [], [2, 5]);
6625
+ return false;
6626
+ }
6627
+ parseString2(false);
6628
+ if (_scanner.getToken() === 6) {
6629
+ onSeparator(":");
6630
+ scanNext();
6631
+ if (!parseValue2()) {
6632
+ handleError(4, [], [2, 5]);
6633
+ }
6634
+ } else {
6635
+ handleError(5, [], [2, 5]);
6636
+ }
6637
+ _jsonPath.pop();
6638
+ return true;
6639
+ }
6640
+ function parseObject() {
6641
+ onObjectBegin();
6642
+ scanNext();
6643
+ let needsComma = false;
6644
+ while (_scanner.getToken() !== 2 && _scanner.getToken() !== 17) {
6645
+ if (_scanner.getToken() === 5) {
6646
+ if (!needsComma) {
6647
+ handleError(4, [], []);
6648
+ }
6649
+ onSeparator(",");
6650
+ scanNext();
6651
+ if (_scanner.getToken() === 2 && allowTrailingComma) {
6652
+ break;
6653
+ }
6654
+ } else if (needsComma) {
6655
+ handleError(6, [], []);
6656
+ }
6657
+ if (!parseProperty()) {
6658
+ handleError(4, [], [2, 5]);
6659
+ }
6660
+ needsComma = true;
6661
+ }
6662
+ onObjectEnd();
6663
+ if (_scanner.getToken() !== 2) {
6664
+ handleError(7, [2], []);
6665
+ } else {
6666
+ scanNext();
6667
+ }
6668
+ return true;
6669
+ }
6670
+ function parseArray2() {
6671
+ onArrayBegin();
6672
+ scanNext();
6673
+ let isFirstElement = true;
6674
+ let needsComma = false;
6675
+ while (_scanner.getToken() !== 4 && _scanner.getToken() !== 17) {
6676
+ if (_scanner.getToken() === 5) {
6677
+ if (!needsComma) {
6678
+ handleError(4, [], []);
6679
+ }
6680
+ onSeparator(",");
6681
+ scanNext();
6682
+ if (_scanner.getToken() === 4 && allowTrailingComma) {
6683
+ break;
6684
+ }
6685
+ } else if (needsComma) {
6686
+ handleError(6, [], []);
6687
+ }
6688
+ if (isFirstElement) {
6689
+ _jsonPath.push(0);
6690
+ isFirstElement = false;
6691
+ } else {
6692
+ _jsonPath[_jsonPath.length - 1]++;
6693
+ }
6694
+ if (!parseValue2()) {
6695
+ handleError(4, [], [4, 5]);
6696
+ }
6697
+ needsComma = true;
6698
+ }
6699
+ onArrayEnd();
6700
+ if (!isFirstElement) {
6701
+ _jsonPath.pop();
6702
+ }
6703
+ if (_scanner.getToken() !== 4) {
6704
+ handleError(8, [4], []);
6705
+ } else {
6706
+ scanNext();
6707
+ }
6708
+ return true;
6709
+ }
6710
+ function parseValue2() {
6711
+ switch (_scanner.getToken()) {
6712
+ case 3:
6713
+ return parseArray2();
6714
+ case 1:
6715
+ return parseObject();
6716
+ case 10:
6717
+ return parseString2(true);
6718
+ default:
6719
+ return parseLiteral();
6720
+ }
6721
+ }
6722
+ scanNext();
6723
+ if (_scanner.getToken() === 17) {
6724
+ if (options.allowEmptyContent) {
6725
+ return true;
6726
+ }
6727
+ handleError(4, [], []);
6728
+ return false;
6729
+ }
6730
+ if (!parseValue2()) {
6731
+ handleError(4, [], []);
6732
+ return false;
6733
+ }
6734
+ if (_scanner.getToken() !== 17) {
6735
+ handleError(9, [], []);
6736
+ }
6737
+ return true;
6738
+ }
6739
+ function getNodeType(value) {
6740
+ switch (typeof value) {
6741
+ case "boolean":
6742
+ return "boolean";
6743
+ case "number":
6744
+ return "number";
6745
+ case "string":
6746
+ return "string";
6747
+ case "object": {
6748
+ if (!value) {
6749
+ return "null";
6750
+ } else if (Array.isArray(value)) {
6751
+ return "array";
6752
+ }
6753
+ return "object";
6754
+ }
6755
+ default:
6756
+ return "null";
6757
+ }
6758
+ }
6759
+
6760
+ // node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/edit.js
6761
+ function setProperty(text, originalPath, value, options) {
6762
+ const path = originalPath.slice();
6763
+ const errors = [];
6764
+ const root = parseTree(text, errors);
6765
+ let parent = undefined;
6766
+ let lastSegment = undefined;
6767
+ while (path.length > 0) {
6768
+ lastSegment = path.pop();
6769
+ parent = findNodeAtLocation(root, path);
6770
+ if (parent === undefined && value !== undefined) {
6771
+ if (typeof lastSegment === "string") {
6772
+ value = { [lastSegment]: value };
6773
+ } else {
6774
+ value = [value];
6775
+ }
6776
+ } else {
6777
+ break;
6778
+ }
6779
+ }
6780
+ if (!parent) {
6781
+ if (value === undefined) {
6782
+ throw new Error("Can not delete in empty document");
6783
+ }
6784
+ return withFormatting(text, { offset: root ? root.offset : 0, length: root ? root.length : 0, content: JSON.stringify(value) }, options);
6785
+ } else if (parent.type === "object" && typeof lastSegment === "string" && Array.isArray(parent.children)) {
6786
+ const existing = findNodeAtLocation(parent, [lastSegment]);
6787
+ if (existing !== undefined) {
6788
+ if (value === undefined) {
6789
+ if (!existing.parent) {
6790
+ throw new Error("Malformed AST");
6791
+ }
6792
+ const propertyIndex = parent.children.indexOf(existing.parent);
6793
+ let removeBegin;
6794
+ let removeEnd = existing.parent.offset + existing.parent.length;
6795
+ if (propertyIndex > 0) {
6796
+ let previous = parent.children[propertyIndex - 1];
6797
+ removeBegin = previous.offset + previous.length;
6798
+ } else {
6799
+ removeBegin = parent.offset + 1;
6800
+ if (parent.children.length > 1) {
6801
+ let next = parent.children[1];
6802
+ removeEnd = next.offset;
6803
+ }
6804
+ }
6805
+ return withFormatting(text, { offset: removeBegin, length: removeEnd - removeBegin, content: "" }, options);
6806
+ } else {
6807
+ return withFormatting(text, { offset: existing.offset, length: existing.length, content: JSON.stringify(value) }, options);
6808
+ }
6809
+ } else {
6810
+ if (value === undefined) {
6811
+ return [];
6812
+ }
6813
+ const newProperty = `${JSON.stringify(lastSegment)}: ${JSON.stringify(value)}`;
6814
+ const index = options.getInsertionIndex ? options.getInsertionIndex(parent.children.map((p) => p.children[0].value)) : parent.children.length;
6815
+ let edit;
6816
+ if (index > 0) {
6817
+ let previous = parent.children[index - 1];
6818
+ edit = { offset: previous.offset + previous.length, length: 0, content: "," + newProperty };
6819
+ } else if (parent.children.length === 0) {
6820
+ edit = { offset: parent.offset + 1, length: 0, content: newProperty };
6821
+ } else {
6822
+ edit = { offset: parent.offset + 1, length: 0, content: newProperty + "," };
6823
+ }
6824
+ return withFormatting(text, edit, options);
6825
+ }
6826
+ } else if (parent.type === "array" && typeof lastSegment === "number" && Array.isArray(parent.children)) {
6827
+ const insertIndex = lastSegment;
6828
+ if (insertIndex === -1) {
6829
+ const newProperty = `${JSON.stringify(value)}`;
6830
+ let edit;
6831
+ if (parent.children.length === 0) {
6832
+ edit = { offset: parent.offset + 1, length: 0, content: newProperty };
6833
+ } else {
6834
+ const previous = parent.children[parent.children.length - 1];
6835
+ edit = { offset: previous.offset + previous.length, length: 0, content: "," + newProperty };
6836
+ }
6837
+ return withFormatting(text, edit, options);
6838
+ } else if (value === undefined && parent.children.length >= 0) {
6839
+ const removalIndex = lastSegment;
6840
+ const toRemove = parent.children[removalIndex];
6841
+ let edit;
6842
+ if (parent.children.length === 1) {
6843
+ edit = { offset: parent.offset + 1, length: parent.length - 2, content: "" };
6844
+ } else if (parent.children.length - 1 === removalIndex) {
6845
+ let previous = parent.children[removalIndex - 1];
6846
+ let offset = previous.offset + previous.length;
6847
+ let parentEndOffset = parent.offset + parent.length;
6848
+ edit = { offset, length: parentEndOffset - 2 - offset, content: "" };
6849
+ } else {
6850
+ edit = { offset: toRemove.offset, length: parent.children[removalIndex + 1].offset - toRemove.offset, content: "" };
6851
+ }
6852
+ return withFormatting(text, edit, options);
6853
+ } else if (value !== undefined) {
6854
+ let edit;
6855
+ const newProperty = `${JSON.stringify(value)}`;
6856
+ if (!options.isArrayInsertion && parent.children.length > lastSegment) {
6857
+ const toModify = parent.children[lastSegment];
6858
+ edit = { offset: toModify.offset, length: toModify.length, content: newProperty };
6859
+ } else if (parent.children.length === 0 || lastSegment === 0) {
6860
+ edit = { offset: parent.offset + 1, length: 0, content: parent.children.length === 0 ? newProperty : newProperty + "," };
6861
+ } else {
6862
+ const index = lastSegment > parent.children.length ? parent.children.length : lastSegment;
6863
+ const previous = parent.children[index - 1];
6864
+ edit = { offset: previous.offset + previous.length, length: 0, content: "," + newProperty };
6865
+ }
6866
+ return withFormatting(text, edit, options);
6867
+ } else {
6868
+ throw new Error(`Can not ${value === undefined ? "remove" : options.isArrayInsertion ? "insert" : "modify"} Array index ${insertIndex} as length is not sufficient`);
6869
+ }
6870
+ } else {
6871
+ throw new Error(`Can not add ${typeof lastSegment !== "number" ? "index" : "property"} to parent of type ${parent.type}`);
6872
+ }
6873
+ }
6874
+ function withFormatting(text, edit, options) {
6875
+ if (!options.formattingOptions) {
6876
+ return [edit];
6877
+ }
6878
+ let newText = applyEdit(text, edit);
6879
+ let begin = edit.offset;
6880
+ let end = edit.offset + edit.content.length;
6881
+ if (edit.length === 0 || edit.content.length === 0) {
6882
+ while (begin > 0 && !isEOL(newText, begin - 1)) {
6883
+ begin--;
6884
+ }
6885
+ while (end < newText.length && !isEOL(newText, end)) {
6886
+ end++;
6887
+ }
6888
+ }
6889
+ const edits = format(newText, { offset: begin, length: end - begin }, { ...options.formattingOptions, keepLines: false });
6890
+ for (let i = edits.length - 1;i >= 0; i--) {
6891
+ const edit2 = edits[i];
6892
+ newText = applyEdit(newText, edit2);
6893
+ begin = Math.min(begin, edit2.offset);
6894
+ end = Math.max(end, edit2.offset + edit2.length);
6895
+ end += edit2.content.length - edit2.length;
6896
+ }
6897
+ const editLength = text.length - (newText.length - end) - begin;
6898
+ return [{ offset: begin, length: editLength, content: newText.substring(begin, end) }];
6899
+ }
6900
+ function applyEdit(text, edit) {
6901
+ return text.substring(0, edit.offset) + edit.content + text.substring(edit.offset + edit.length);
6902
+ }
6903
+
6904
+ // node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/main.js
6905
+ var ScanError;
6906
+ (function(ScanError2) {
6907
+ ScanError2[ScanError2["None"] = 0] = "None";
6908
+ ScanError2[ScanError2["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
6909
+ ScanError2[ScanError2["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
6910
+ ScanError2[ScanError2["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
6911
+ ScanError2[ScanError2["InvalidUnicode"] = 4] = "InvalidUnicode";
6912
+ ScanError2[ScanError2["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
6913
+ ScanError2[ScanError2["InvalidCharacter"] = 6] = "InvalidCharacter";
6914
+ })(ScanError || (ScanError = {}));
6915
+ var SyntaxKind;
6916
+ (function(SyntaxKind2) {
6917
+ SyntaxKind2[SyntaxKind2["OpenBraceToken"] = 1] = "OpenBraceToken";
6918
+ SyntaxKind2[SyntaxKind2["CloseBraceToken"] = 2] = "CloseBraceToken";
6919
+ SyntaxKind2[SyntaxKind2["OpenBracketToken"] = 3] = "OpenBracketToken";
6920
+ SyntaxKind2[SyntaxKind2["CloseBracketToken"] = 4] = "CloseBracketToken";
6921
+ SyntaxKind2[SyntaxKind2["CommaToken"] = 5] = "CommaToken";
6922
+ SyntaxKind2[SyntaxKind2["ColonToken"] = 6] = "ColonToken";
6923
+ SyntaxKind2[SyntaxKind2["NullKeyword"] = 7] = "NullKeyword";
6924
+ SyntaxKind2[SyntaxKind2["TrueKeyword"] = 8] = "TrueKeyword";
6925
+ SyntaxKind2[SyntaxKind2["FalseKeyword"] = 9] = "FalseKeyword";
6926
+ SyntaxKind2[SyntaxKind2["StringLiteral"] = 10] = "StringLiteral";
6927
+ SyntaxKind2[SyntaxKind2["NumericLiteral"] = 11] = "NumericLiteral";
6928
+ SyntaxKind2[SyntaxKind2["LineCommentTrivia"] = 12] = "LineCommentTrivia";
6929
+ SyntaxKind2[SyntaxKind2["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
6930
+ SyntaxKind2[SyntaxKind2["LineBreakTrivia"] = 14] = "LineBreakTrivia";
6931
+ SyntaxKind2[SyntaxKind2["Trivia"] = 15] = "Trivia";
6932
+ SyntaxKind2[SyntaxKind2["Unknown"] = 16] = "Unknown";
6933
+ SyntaxKind2[SyntaxKind2["EOF"] = 17] = "EOF";
6934
+ })(SyntaxKind || (SyntaxKind = {}));
6935
+ var parse3 = parse2;
6936
+ var ParseErrorCode;
6937
+ (function(ParseErrorCode2) {
6938
+ ParseErrorCode2[ParseErrorCode2["InvalidSymbol"] = 1] = "InvalidSymbol";
6939
+ ParseErrorCode2[ParseErrorCode2["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
6940
+ ParseErrorCode2[ParseErrorCode2["PropertyNameExpected"] = 3] = "PropertyNameExpected";
6941
+ ParseErrorCode2[ParseErrorCode2["ValueExpected"] = 4] = "ValueExpected";
6942
+ ParseErrorCode2[ParseErrorCode2["ColonExpected"] = 5] = "ColonExpected";
6943
+ ParseErrorCode2[ParseErrorCode2["CommaExpected"] = 6] = "CommaExpected";
6944
+ ParseErrorCode2[ParseErrorCode2["CloseBraceExpected"] = 7] = "CloseBraceExpected";
6945
+ ParseErrorCode2[ParseErrorCode2["CloseBracketExpected"] = 8] = "CloseBracketExpected";
6946
+ ParseErrorCode2[ParseErrorCode2["EndOfFileExpected"] = 9] = "EndOfFileExpected";
6947
+ ParseErrorCode2[ParseErrorCode2["InvalidCommentToken"] = 10] = "InvalidCommentToken";
6948
+ ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
6949
+ ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
6950
+ ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
6951
+ ParseErrorCode2[ParseErrorCode2["InvalidUnicode"] = 14] = "InvalidUnicode";
6952
+ ParseErrorCode2[ParseErrorCode2["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
6953
+ ParseErrorCode2[ParseErrorCode2["InvalidCharacter"] = 16] = "InvalidCharacter";
6954
+ })(ParseErrorCode || (ParseErrorCode = {}));
6955
+ function modify(text, path, value, options) {
6956
+ return setProperty(text, path, value, options);
6957
+ }
6958
+ function applyEdits(text, edits) {
6959
+ let sortedEdits = edits.slice(0).sort((a, b) => {
6960
+ const diff = a.offset - b.offset;
6961
+ if (diff === 0) {
6962
+ return a.length - b.length;
6963
+ }
6964
+ return diff;
6965
+ });
6966
+ let lastModifiedOffset = text.length;
6967
+ for (let i = sortedEdits.length - 1;i >= 0; i--) {
6968
+ let e = sortedEdits[i];
6969
+ if (e.offset + e.length <= lastModifiedOffset) {
6970
+ text = applyEdit(text, e);
6971
+ } else {
6972
+ throw new Error("Overlapping edit");
6973
+ }
6974
+ lastModifiedOffset = e.offset;
6975
+ }
6976
+ return text;
6977
+ }
6978
+
5656
6979
  // src/adapters/opencode/paths.ts
6980
+ import { existsSync } from "fs";
5657
6981
  import { homedir as homedir3 } from "os";
5658
6982
  import { join as join3 } from "path";
5659
- var PLUGIN_FILENAME = "caret.ts";
5660
- var PLUGIN_DIRNAME = "plugins";
6983
+ var CARET_PACKAGE = "@macintacos/caret";
5661
6984
  var COMMAND_DIRNAME = "commands";
5662
6985
  var COMMAND_NAMESPACE = "caret:";
5663
6986
  function namespacedCommandFilename(sourceName) {
5664
6987
  return `${COMMAND_NAMESPACE}${sourceName}`;
5665
6988
  }
5666
- var CONFIG_FILENAMES = ["config.json", "opencode.json", "opencode.jsonc"];
5667
- var OPENCODE_PLUGIN_DEP = "@opencode-ai/plugin";
5668
- var OPENCODE_PLUGIN_DEP_VERSION = "1.16.2";
5669
- var PACKAGE_JSON_FILENAME = "package.json";
5670
- function packageJsonPath(configDir) {
5671
- return join3(configDir, PACKAGE_JSON_FILENAME);
5672
- }
6989
+ var CONFIG_FILENAMES = ["opencode.jsonc", "opencode.json", "config.json"];
5673
6990
  function opencodeConfigDir() {
5674
6991
  const override = process.env.OPENCODE_CONFIG_DIR?.trim();
5675
6992
  if (override)
@@ -5677,44 +6994,60 @@ function opencodeConfigDir() {
5677
6994
  const xdg = process.env.XDG_CONFIG_HOME?.trim();
5678
6995
  return join3(xdg || join3(homedir3(), ".config"), "opencode");
5679
6996
  }
5680
- function pluginFilePath(configDir) {
5681
- return join3(configDir, PLUGIN_DIRNAME, PLUGIN_FILENAME);
6997
+ function resolveConfigFile(configDir) {
6998
+ for (const name of CONFIG_FILENAMES) {
6999
+ const p = join3(configDir, name);
7000
+ if (existsSync(p))
7001
+ return p;
7002
+ }
7003
+ return join3(configDir, "opencode.json");
5682
7004
  }
5683
7005
  function commandDir(configDir) {
5684
7006
  return join3(configDir, COMMAND_DIRNAME);
5685
7007
  }
7008
+ function opencodeCachePackageDir(pkg = CARET_PACKAGE) {
7009
+ const xdg = process.env.XDG_CACHE_HOME?.trim();
7010
+ const base = xdg || join3(homedir3(), ".cache");
7011
+ return join3(base, "opencode", "node_modules", pkg);
7012
+ }
5686
7013
 
5687
7014
  // src/adapters/opencode/install.ts
5688
- var VERSION_MARKER = /CARET_PLUGIN_VERSION\s*=\s*["']([^"']+)["']/;
5689
7015
  function readOpencodeInstallState() {
5690
7016
  const dir = opencodeConfigDir();
5691
- if (!existsSync(dir)) {
7017
+ if (!existsSync2(dir)) {
5692
7018
  return { pluginVersion: "unknown", pluginEnabled: "unknown", hookInUserSettings: "unknown" };
5693
7019
  }
5694
- const pluginFile = pluginFilePath(dir);
7020
+ const cacheDir = opencodeCachePackageDir();
5695
7021
  return {
5696
- pluginVersion: readPluginVersion2(pluginFile),
5697
- pluginEnabled: existsSync(pluginFile),
5698
- hookInUserSettings: readManualPluginEntry(dir)
7022
+ pluginVersion: readCachedVersion(cacheDir),
7023
+ pluginEnabled: existsSync2(cacheDir),
7024
+ hookInUserSettings: readCaretInPluginArray(dir)
5699
7025
  };
5700
7026
  }
5701
- function readPluginVersion2(path) {
5702
- let text;
7027
+ function readCachedVersion(cachePackageDir) {
5703
7028
  try {
5704
- text = readFileSync3(path, "utf-8");
7029
+ const v = JSON.parse(readFileSync3(join4(cachePackageDir, "package.json"), "utf-8")).version;
7030
+ return typeof v === "string" ? v : "unknown";
5705
7031
  } catch {
5706
7032
  return "unknown";
5707
7033
  }
5708
- return text.match(VERSION_MARKER)?.[1] ?? "unknown";
5709
7034
  }
5710
- function readManualPluginEntry(dir) {
7035
+ function readCaretInPluginArray(dir) {
5711
7036
  let sawConfig = false;
5712
7037
  for (const name of CONFIG_FILENAMES) {
5713
- const json = readJsonFileSync(join4(dir, name));
5714
- if (json === null)
7038
+ const path = join4(dir, name);
7039
+ if (!existsSync2(path))
7040
+ continue;
7041
+ let cfg;
7042
+ try {
7043
+ cfg = parse3(readFileSync3(path, "utf-8"));
7044
+ } catch {
7045
+ continue;
7046
+ }
7047
+ if (cfg === undefined || cfg === null)
5715
7048
  continue;
5716
7049
  sawConfig = true;
5717
- const arr = json.plugin;
7050
+ const arr = cfg.plugin;
5718
7051
  if (Array.isArray(arr) && arr.some((e) => typeof e === "string" && e.includes("caret"))) {
5719
7052
  return true;
5720
7053
  }
@@ -5790,10 +7123,17 @@ import { createHash } from "crypto";
5790
7123
  // package.json
5791
7124
  var package_default = {
5792
7125
  name: "@macintacos/caret",
5793
- version: "0.3.0",
7126
+ version: "0.4.1",
5794
7127
  license: "MIT",
5795
7128
  type: "module",
5796
7129
  description: "A Claude Code plugin that replaces the terminal plan-approval prompt with a local web UI for inline review, annotation, and approval.",
7130
+ main: "./opencode/index.ts",
7131
+ exports: {
7132
+ ".": "./opencode/index.ts"
7133
+ },
7134
+ bin: {
7135
+ caret: "./bin/caret"
7136
+ },
5797
7137
  homepage: "https://github.com/macintacos/caret",
5798
7138
  repository: {
5799
7139
  type: "git",
@@ -5819,7 +7159,6 @@ var package_default = {
5819
7159
  },
5820
7160
  devDependencies: {
5821
7161
  "@happy-dom/global-registrator": "^20.9.0",
5822
- "@opencode-ai/plugin": "^1.16.2",
5823
7162
  "@playwright/test": "^1.60.0",
5824
7163
  "@sveltejs/vite-plugin-svelte": "^7.1.2",
5825
7164
  "@tailwindcss/vite": "^4.3.2",
@@ -5845,10 +7184,12 @@ var package_default = {
5845
7184
  "@commander-js/extra-typings": "^15.0.0",
5846
7185
  "@internationalized/date": "^3.12.2",
5847
7186
  "@lezer/highlight": "^1.2.3",
7187
+ "@opencode-ai/plugin": "^1.16.2",
5848
7188
  "@pierre/diffs": "1.2.7",
5849
7189
  "bits-ui": "^2.18.1",
5850
7190
  clsx: "^2.1.1",
5851
7191
  commander: "^15.0.0",
7192
+ "jsonc-parser": "^3.3.1",
5852
7193
  marked: "^18.0.4",
5853
7194
  pino: "^10.3.1",
5854
7195
  prettier: "3.8.3",
@@ -5989,7 +7330,7 @@ function currentCommit() {
5989
7330
 
5990
7331
  // src/commands/daemon.ts
5991
7332
  import { randomUUID } from "crypto";
5992
- import { existsSync as existsSync3, unlinkSync as unlinkSync3 } from "fs";
7333
+ import { existsSync as existsSync4, unlinkSync as unlinkSync3 } from "fs";
5993
7334
 
5994
7335
  // src/daemon-lifecycle.ts
5995
7336
  import { openSync, unlinkSync } from "fs";
@@ -6401,7 +7742,7 @@ __export(exports_external, {
6401
7742
  pipe: () => pipe,
6402
7743
  partialRecord: () => partialRecord,
6403
7744
  parseAsync: () => parseAsync2,
6404
- parse: () => parse4,
7745
+ parse: () => parse6,
6405
7746
  overwrite: () => _overwrite,
6406
7747
  optional: () => optional,
6407
7748
  object: () => object,
@@ -6603,7 +7944,7 @@ __export(exports_core2, {
6603
7944
  process: () => process2,
6604
7945
  prettifyError: () => prettifyError,
6605
7946
  parseAsync: () => parseAsync,
6606
- parse: () => parse2,
7947
+ parse: () => parse4,
6607
7948
  meta: () => meta,
6608
7949
  locales: () => exports_locales,
6609
7950
  isValidJWT: () => isValidJWT,
@@ -7787,7 +9128,7 @@ var _parse = (_Err) => (schema, value, _ctx, _params) => {
7787
9128
  }
7788
9129
  return result.value;
7789
9130
  };
7790
- var parse2 = /* @__PURE__ */ _parse($ZodRealError);
9131
+ var parse4 = /* @__PURE__ */ _parse($ZodRealError);
7791
9132
  var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
7792
9133
  const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
7793
9134
  let result = schema._zod.run({ value, issues: [] }, ctx);
@@ -10574,10 +11915,10 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
10574
11915
  throw new Error("implement() must be called with a function");
10575
11916
  }
10576
11917
  return function(...args) {
10577
- const parsedArgs = inst._def.input ? parse2(inst._def.input, args) : args;
11918
+ const parsedArgs = inst._def.input ? parse4(inst._def.input, args) : args;
10578
11919
  const result = Reflect.apply(func, this, parsedArgs);
10579
11920
  if (inst._def.output) {
10580
- return parse2(inst._def.output, result);
11921
+ return parse4(inst._def.output, result);
10581
11922
  }
10582
11923
  return result;
10583
11924
  };
@@ -17550,13 +18891,13 @@ function _stringbool(Classes, _params) {
17550
18891
  });
17551
18892
  return codec;
17552
18893
  }
17553
- function _stringFormat(Class2, format, fnOrRegex, _params = {}) {
18894
+ function _stringFormat(Class2, format2, fnOrRegex, _params = {}) {
17554
18895
  const params = normalizeParams(_params);
17555
18896
  const def = {
17556
18897
  ...normalizeParams(_params),
17557
18898
  check: "string_format",
17558
18899
  type: "string",
17559
- format,
18900
+ format: format2,
17560
18901
  fn: typeof fnOrRegex === "function" ? fnOrRegex : (val) => fnOrRegex.test(val),
17561
18902
  ...params
17562
18903
  };
@@ -17929,16 +19270,16 @@ var formatMap = {
17929
19270
  var stringProcessor = (schema, ctx, _json, _params) => {
17930
19271
  const json = _json;
17931
19272
  json.type = "string";
17932
- const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
19273
+ const { minimum, maximum, format: format2, patterns, contentEncoding } = schema._zod.bag;
17933
19274
  if (typeof minimum === "number")
17934
19275
  json.minLength = minimum;
17935
19276
  if (typeof maximum === "number")
17936
19277
  json.maxLength = maximum;
17937
- if (format) {
17938
- json.format = formatMap[format] ?? format;
19278
+ if (format2) {
19279
+ json.format = formatMap[format2] ?? format2;
17939
19280
  if (json.format === "")
17940
19281
  delete json.format;
17941
- if (format === "time") {
19282
+ if (format2 === "time") {
17942
19283
  delete json.format;
17943
19284
  }
17944
19285
  }
@@ -17960,8 +19301,8 @@ var stringProcessor = (schema, ctx, _json, _params) => {
17960
19301
  };
17961
19302
  var numberProcessor = (schema, ctx, _json, _params) => {
17962
19303
  const json = _json;
17963
- const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
17964
- if (typeof format === "string" && format.includes("int"))
19304
+ const { minimum, maximum, format: format2, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
19305
+ if (typeof format2 === "string" && format2.includes("int"))
17965
19306
  json.type = "integer";
17966
19307
  else
17967
19308
  json.type = "number";
@@ -18799,7 +20140,7 @@ var ZodRealError = /* @__PURE__ */ $constructor("ZodError", initializer2, {
18799
20140
  });
18800
20141
 
18801
20142
  // node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/parse.js
18802
- var parse4 = /* @__PURE__ */ _parse(ZodRealError);
20143
+ var parse6 = /* @__PURE__ */ _parse(ZodRealError);
18803
20144
  var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
18804
20145
  var safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
18805
20146
  var safeParseAsync2 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
@@ -18862,7 +20203,7 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
18862
20203
  inst.def = def;
18863
20204
  inst.type = def.type;
18864
20205
  Object.defineProperty(inst, "_def", { value: def });
18865
- inst.parse = (data, params) => parse4(inst, data, params, { callee: inst.parse });
20206
+ inst.parse = (data, params) => parse6(inst, data, params, { callee: inst.parse });
18866
20207
  inst.safeParse = (data, params) => safeParse2(inst, data, params);
18867
20208
  inst.parseAsync = async (data, params) => parseAsync2(inst, data, params, { callee: inst.parseAsync });
18868
20209
  inst.safeParseAsync = async (data, params) => safeParseAsync2(inst, data, params);
@@ -19233,8 +20574,8 @@ var ZodCustomStringFormat = /* @__PURE__ */ $constructor("ZodCustomStringFormat"
19233
20574
  $ZodCustomStringFormat.init(inst, def);
19234
20575
  ZodStringFormat.init(inst, def);
19235
20576
  });
19236
- function stringFormat(format, fnOrRegex, _params = {}) {
19237
- return _stringFormat(ZodCustomStringFormat, format, fnOrRegex, _params);
20577
+ function stringFormat(format2, fnOrRegex, _params = {}) {
20578
+ return _stringFormat(ZodCustomStringFormat, format2, fnOrRegex, _params);
19238
20579
  }
19239
20580
  function hostname2(_params) {
19240
20581
  return _stringFormat(ZodCustomStringFormat, "hostname", exports_regexes.hostname, _params);
@@ -19244,11 +20585,11 @@ function hex2(_params) {
19244
20585
  }
19245
20586
  function hash(alg, params) {
19246
20587
  const enc = params?.enc ?? "hex";
19247
- const format = `${alg}_${enc}`;
19248
- const regex = exports_regexes[format];
20588
+ const format2 = `${alg}_${enc}`;
20589
+ const regex = exports_regexes[format2];
19249
20590
  if (!regex)
19250
- throw new Error(`Unrecognized hash format: ${format}`);
19251
- return _stringFormat(ZodCustomStringFormat, format, regex, params);
20591
+ throw new Error(`Unrecognized hash format: ${format2}`);
20592
+ return _stringFormat(ZodCustomStringFormat, format2, regex, params);
19252
20593
  }
19253
20594
  var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
19254
20595
  $ZodNumber.init(inst, def);
@@ -20303,52 +21644,52 @@ function convertBaseSchema(schema, ctx) {
20303
21644
  case "string": {
20304
21645
  let stringSchema = z.string();
20305
21646
  if (schema.format) {
20306
- const format = schema.format;
20307
- if (format === "email") {
21647
+ const format2 = schema.format;
21648
+ if (format2 === "email") {
20308
21649
  stringSchema = stringSchema.check(z.email());
20309
- } else if (format === "uri" || format === "uri-reference") {
21650
+ } else if (format2 === "uri" || format2 === "uri-reference") {
20310
21651
  stringSchema = stringSchema.check(z.url());
20311
- } else if (format === "uuid" || format === "guid") {
21652
+ } else if (format2 === "uuid" || format2 === "guid") {
20312
21653
  stringSchema = stringSchema.check(z.uuid());
20313
- } else if (format === "date-time") {
21654
+ } else if (format2 === "date-time") {
20314
21655
  stringSchema = stringSchema.check(z.iso.datetime());
20315
- } else if (format === "date") {
21656
+ } else if (format2 === "date") {
20316
21657
  stringSchema = stringSchema.check(z.iso.date());
20317
- } else if (format === "time") {
21658
+ } else if (format2 === "time") {
20318
21659
  stringSchema = stringSchema.check(z.iso.time());
20319
- } else if (format === "duration") {
21660
+ } else if (format2 === "duration") {
20320
21661
  stringSchema = stringSchema.check(z.iso.duration());
20321
- } else if (format === "ipv4") {
21662
+ } else if (format2 === "ipv4") {
20322
21663
  stringSchema = stringSchema.check(z.ipv4());
20323
- } else if (format === "ipv6") {
21664
+ } else if (format2 === "ipv6") {
20324
21665
  stringSchema = stringSchema.check(z.ipv6());
20325
- } else if (format === "mac") {
21666
+ } else if (format2 === "mac") {
20326
21667
  stringSchema = stringSchema.check(z.mac());
20327
- } else if (format === "cidr") {
21668
+ } else if (format2 === "cidr") {
20328
21669
  stringSchema = stringSchema.check(z.cidrv4());
20329
- } else if (format === "cidr-v6") {
21670
+ } else if (format2 === "cidr-v6") {
20330
21671
  stringSchema = stringSchema.check(z.cidrv6());
20331
- } else if (format === "base64") {
21672
+ } else if (format2 === "base64") {
20332
21673
  stringSchema = stringSchema.check(z.base64());
20333
- } else if (format === "base64url") {
21674
+ } else if (format2 === "base64url") {
20334
21675
  stringSchema = stringSchema.check(z.base64url());
20335
- } else if (format === "e164") {
21676
+ } else if (format2 === "e164") {
20336
21677
  stringSchema = stringSchema.check(z.e164());
20337
- } else if (format === "jwt") {
21678
+ } else if (format2 === "jwt") {
20338
21679
  stringSchema = stringSchema.check(z.jwt());
20339
- } else if (format === "emoji") {
21680
+ } else if (format2 === "emoji") {
20340
21681
  stringSchema = stringSchema.check(z.emoji());
20341
- } else if (format === "nanoid") {
21682
+ } else if (format2 === "nanoid") {
20342
21683
  stringSchema = stringSchema.check(z.nanoid());
20343
- } else if (format === "cuid") {
21684
+ } else if (format2 === "cuid") {
20344
21685
  stringSchema = stringSchema.check(z.cuid());
20345
- } else if (format === "cuid2") {
21686
+ } else if (format2 === "cuid2") {
20346
21687
  stringSchema = stringSchema.check(z.cuid2());
20347
- } else if (format === "ulid") {
21688
+ } else if (format2 === "ulid") {
20348
21689
  stringSchema = stringSchema.check(z.ulid());
20349
- } else if (format === "xid") {
21690
+ } else if (format2 === "xid") {
20350
21691
  stringSchema = stringSchema.check(z.xid());
20351
- } else if (format === "ksuid") {
21692
+ } else if (format2 === "ksuid") {
20352
21693
  stringSchema = stringSchema.check(z.ksuid());
20353
21694
  }
20354
21695
  }
@@ -21176,14 +22517,14 @@ async function writeApproveMode(mode, file2 = prefsFile(), log = noopLogger, set
21176
22517
  import { randomBytes } from "crypto";
21177
22518
 
21178
22519
  // src/plan-file.ts
21179
- import { existsSync as existsSync2, statSync as statSync3, writeFileSync as writeFileSync2 } from "fs";
22520
+ import { existsSync as existsSync3, statSync as statSync3, writeFileSync as writeFileSync2 } from "fs";
21180
22521
  function writeCanonicalPlanFile(planFilePath, canonical, log) {
21181
22522
  if (!planFilePath)
21182
22523
  return;
21183
22524
  try {
21184
22525
  if (!planFilePath.endsWith(".md"))
21185
22526
  return;
21186
- if (!existsSync2(planFilePath) || !statSync3(planFilePath).isFile())
22527
+ if (!existsSync3(planFilePath) || !statSync3(planFilePath).isFile())
21187
22528
  return;
21188
22529
  writeFileSync2(planFilePath, canonical);
21189
22530
  } catch (err) {
@@ -28690,7 +30031,7 @@ async function runDaemon(opts) {
28690
30031
  const log = createDaemonLogger(() => svc.current().logging.level, undefined, () => svc.current().logging.redact);
28691
30032
  const cfg = configFile();
28692
30033
  const boot = svc.current();
28693
- log.info("settings", existsSync3(cfg) ? `settings: reading ${cfg}` : `settings: no config at ${cfg}; using defaults`, { settings: boot });
30034
+ log.info("settings", existsSync4(cfg) ? `settings: reading ${cfg}` : `settings: no config at ${cfg}; using defaults`, { settings: boot });
28694
30035
  warnInvalidEnvVars((msg) => log.warn("env", msg));
28695
30036
  const adapter = selectAdapter();
28696
30037
  const store = createStore(reviewsDir(), log);
@@ -28749,7 +30090,7 @@ async function runDaemon(opts) {
28749
30090
  }
28750
30091
 
28751
30092
  // src/commands/discovery.ts
28752
- import { existsSync as existsSync4 } from "fs";
30093
+ import { existsSync as existsSync5 } from "fs";
28753
30094
  import { release } from "os";
28754
30095
 
28755
30096
  // src/discovery.ts
@@ -29027,7 +30368,7 @@ function prodDiscoveryDeps(s) {
29027
30368
  }),
29028
30369
  settings: () => s,
29029
30370
  configPath: configFile(),
29030
- configExists: () => existsSync4(configFile()),
30371
+ configExists: () => existsSync5(configFile()),
29031
30372
  effective: () => ({
29032
30373
  port: getPort(s),
29033
30374
  idleMs: idleMs(s),
@@ -29061,42 +30402,111 @@ async function runDiscoverySubcommand(opts) {
29061
30402
  }
29062
30403
  }
29063
30404
 
30405
+ // src/commands/install-claude.ts
30406
+ var MARKETPLACE_SOURCE = "macintacos/caret";
30407
+ var PLUGIN_REF = "caret@caret";
30408
+ var claudeCli = (args) => {
30409
+ try {
30410
+ const res = Bun.spawnSync(["claude", ...args], { stdout: "pipe", stderr: "pipe" });
30411
+ if (res.exitCode === 0)
30412
+ return { ok: true, detail: "" };
30413
+ const err = new TextDecoder().decode(res.stderr).trim();
30414
+ return { ok: false, detail: err || `claude exited ${res.exitCode}` };
30415
+ } catch (e) {
30416
+ const missing = e instanceof Error && e.code === "ENOENT";
30417
+ return { ok: false, missing, detail: e instanceof Error ? e.message : String(e) };
30418
+ }
30419
+ };
30420
+ function runInstallClaudeTarget(opts, deps = {}) {
30421
+ const run = deps.claude ?? claudeCli;
30422
+ const steps = opts.uninstall ? [["plugin", "uninstall", PLUGIN_REF]] : [
30423
+ ["plugin", "marketplace", "add", MARKETPLACE_SOURCE],
30424
+ ["plugin", "install", PLUGIN_REF, "--scope", "user"],
30425
+ ["plugin", "enable", PLUGIN_REF]
30426
+ ];
30427
+ if (opts.dryRun) {
30428
+ process.stdout.write(`caret: [dry-run] would run for Claude Code:
30429
+ `);
30430
+ for (const s of steps)
30431
+ process.stdout.write(` claude ${s.join(" ")}
30432
+ `);
30433
+ return;
30434
+ }
30435
+ for (const args of steps) {
30436
+ const r = run(args);
30437
+ if (r.ok)
30438
+ continue;
30439
+ if (r.missing) {
30440
+ process.stderr.write(`caret: the \`claude\` CLI was not found. Install Claude Code (https://claude.com/claude-code) and re-run \`caret install --target claude\`, or add caret in Claude Code via \`/plugin marketplace add ${MARKETPLACE_SOURCE}\`.
30441
+ `);
30442
+ return;
30443
+ }
30444
+ if (args[1] !== "install")
30445
+ continue;
30446
+ process.stderr.write(`caret: \`claude ${args.join(" ")}\` failed: ${r.detail}
30447
+ `);
30448
+ return;
30449
+ }
30450
+ const verb = opts.uninstall ? "removed" : "installed";
30451
+ process.stdout.write(`caret: ${verb} caret in Claude Code (${PLUGIN_REF}).
30452
+ `);
30453
+ }
30454
+
29064
30455
  // src/commands/install-opencode.ts
29065
- import { existsSync as existsSync7, readFileSync as readFileSync8, rmSync as rmSync2, writeFileSync as writeFileSync5 } from "fs";
30456
+ import { existsSync as existsSync8, readFileSync as readFileSync8, writeFileSync as writeFileSync5 } from "fs";
29066
30457
  import { join as join10 } from "path";
29067
30458
 
29068
- // src/adapters/opencode/deploy.ts
29069
- import { existsSync as existsSync5, mkdirSync as mkdirSync2, rmSync, writeFileSync as writeFileSync4 } from "fs";
29070
- import { dirname as dirname5 } from "path";
29071
- function renderPlugin(source, opts) {
29072
- return source.replaceAll("__CARET_VERSION__", () => opts.version).replaceAll("__CARET_BIN__", () => opts.binPath);
29073
- }
29074
- function addPluginDependency(existing, pkg, version2) {
29075
- const obj = existing === null ? {} : JSON.parse(existing);
29076
- const deps = isObject2(obj.dependencies) ? obj.dependencies : {};
29077
- obj.dependencies = { ...deps, [pkg]: version2 };
29078
- return `${JSON.stringify(obj, null, 2)}
30459
+ // src/adapters/opencode/config-plugin.ts
30460
+ var FORMATTING = { insertSpaces: true, tabSize: 2 };
30461
+ function pluginArray(text) {
30462
+ const cfg = parse3(text);
30463
+ return Array.isArray(cfg?.plugin) ? cfg.plugin : [];
30464
+ }
30465
+ function packageName(spec) {
30466
+ if (spec.startsWith("@")) {
30467
+ const slash = spec.indexOf("/");
30468
+ if (slash === -1)
30469
+ return spec;
30470
+ const at3 = spec.indexOf("@", slash + 1);
30471
+ return at3 === -1 ? spec : spec.slice(0, at3);
30472
+ }
30473
+ const at2 = spec.indexOf("@");
30474
+ return at2 === -1 ? spec : spec.slice(0, at2);
30475
+ }
30476
+ function entryNames(entry, pkg) {
30477
+ return typeof entry === "string" && packageName(entry) === packageName(pkg);
30478
+ }
30479
+ function addPluginToConfigText(existing, pkg) {
30480
+ const text = existing ?? `{}
29079
30481
  `;
30482
+ const current = parse3(text)?.plugin;
30483
+ if (Array.isArray(current)) {
30484
+ if (current.some((e) => entryNames(e, pkg)))
30485
+ return text;
30486
+ const path = ["plugin", current.length];
30487
+ const edits2 = modify(text, path, pkg, {
30488
+ isArrayInsertion: true,
30489
+ formattingOptions: FORMATTING
30490
+ });
30491
+ return applyEdits(text, edits2);
30492
+ }
30493
+ const edits = modify(text, ["plugin"], [pkg], { formattingOptions: FORMATTING });
30494
+ return applyEdits(text, edits);
29080
30495
  }
29081
- function removePluginDependency(existing, pkg) {
29082
- if (existing === null)
29083
- return null;
29084
- const obj = JSON.parse(existing);
29085
- if (!isObject2(obj.dependencies) || !(pkg in obj.dependencies))
30496
+ function removePluginFromConfigText(existing, pkg) {
30497
+ const arr = pluginArray(existing);
30498
+ if (!arr.some((e) => entryNames(e, pkg)))
29086
30499
  return existing;
29087
- delete obj.dependencies[pkg];
29088
- if (Object.keys(obj.dependencies).length === 0)
29089
- delete obj.dependencies;
29090
- if (Object.keys(obj).length === 0)
29091
- return null;
29092
- return `${JSON.stringify(obj, null, 2)}
29093
- `;
29094
- }
29095
- function isObject2(v2) {
29096
- return typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
30500
+ const next = arr.filter((e) => !entryNames(e, pkg));
30501
+ const edits = modify(existing, ["plugin"], next, { formattingOptions: FORMATTING });
30502
+ return applyEdits(existing, edits);
29097
30503
  }
29098
- function stripNonDefaultExports(source) {
29099
- return source.replace(/^([ \t]*)export (?!default\b)/gm, "$1");
30504
+
30505
+ // src/adapters/opencode/deploy.ts
30506
+ import { existsSync as existsSync6, mkdirSync as mkdirSync2, rmSync, writeFileSync as writeFileSync4 } from "fs";
30507
+ import { dirname as dirname5 } from "path";
30508
+ function renderPlugin(source, opts) {
30509
+ return source.replaceAll("__CARET_VERSION__", () => opts.version).replaceAll("__CARET_BIN__", () => opts.binPath);
29100
30510
  }
29101
30511
  function deployFiles(files, opts) {
29102
30512
  const paths = [];
@@ -29112,7 +30522,7 @@ function deployFiles(files, opts) {
29112
30522
  function removeFiles(targets, opts) {
29113
30523
  const paths = [];
29114
30524
  for (const p of targets) {
29115
- if (!existsSync5(p))
30525
+ if (!existsSync6(p))
29116
30526
  continue;
29117
30527
  if (!opts.dryRun)
29118
30528
  rmSync(p, { force: true });
@@ -29122,7 +30532,7 @@ function removeFiles(targets, opts) {
29122
30532
  }
29123
30533
 
29124
30534
  // src/adapters/opencode/packaging.ts
29125
- import { existsSync as existsSync6, readFileSync as readFileSync7, readdirSync as readdirSync4 } from "fs";
30535
+ import { existsSync as existsSync7, readdirSync as readdirSync4, readFileSync as readFileSync7 } from "fs";
29126
30536
  import { dirname as dirname6, join as join9 } from "path";
29127
30537
  function resolveCaretRoot() {
29128
30538
  const candidates = [];
@@ -29131,13 +30541,12 @@ function resolveCaretRoot() {
29131
30541
  candidates.push(join9(dirname6(script), ".."));
29132
30542
  candidates.push(join9(dirname6(process.execPath), ".."));
29133
30543
  for (const root of candidates) {
29134
- if (existsSync6(join9(root, "opencode", "caret.plugin.ts")))
30544
+ if (existsSync7(join9(root, "opencode", "caret.plugin.ts")))
29135
30545
  return root;
29136
30546
  }
29137
30547
  throw new Error(`caret OpenCode packaging not found (no opencode/caret.plugin.ts under: ${candidates.join(", ") || "(none)"}). The OpenCode plugin source must ship with caret.`);
29138
30548
  }
29139
30549
  function loadOpencodePackaging(root = resolveCaretRoot()) {
29140
- const pluginSource = readFileSync7(join9(root, "opencode", "caret.plugin.ts"), "utf-8");
29141
30550
  const binPath = join9(root, "bin", "caret");
29142
30551
  const commandsDir = join9(root, "opencode", "commands");
29143
30552
  let commands = [];
@@ -29146,105 +30555,95 @@ function loadOpencodePackaging(root = resolveCaretRoot()) {
29146
30555
  } catch {
29147
30556
  commands = [];
29148
30557
  }
29149
- return { pluginSource, binPath, commands };
30558
+ return { binPath, commands };
29150
30559
  }
29151
30560
 
29152
30561
  // src/commands/install-opencode.ts
29153
- function runInstallOpencodeSubcommand(opts, deps = {}) {
30562
+ function runInstallOpencodeTarget(opts, deps = {}) {
29154
30563
  const dir = deps.configDir ?? opencodeConfigDir();
29155
30564
  const pkg = deps.packaging ?? loadOpencodePackaging();
29156
- const pluginPath = pluginFilePath(dir);
30565
+ const configFile2 = resolveConfigFile(dir);
29157
30566
  const commandPaths = pkg.commands.map((c) => join10(commandDir(dir), namespacedCommandFilename(c.name)));
29158
30567
  if (opts.uninstall) {
29159
- const result2 = removeFiles([pluginPath, ...commandPaths], { dryRun: opts.dryRun });
29160
- const manifest2 = uninstallManifest(dir, opts.dryRun);
29161
- printResult("removed", [...result2.paths, ...manifest2], opts.dryRun, dir);
30568
+ const changed2 = editConfig(configFile2, (text) => text === null ? null : removePluginFromConfigText(text, CARET_PACKAGE), opts.dryRun);
30569
+ const removed = removeFiles(commandPaths, { dryRun: opts.dryRun });
30570
+ printResult("removed", [...changed2, ...removed.paths], opts.dryRun, dir);
29162
30571
  return;
29163
30572
  }
29164
- const files = [
29165
- {
29166
- path: pluginPath,
29167
- contents: stripNonDefaultExports(renderPlugin(pkg.pluginSource, { version: VERSION, binPath: pkg.binPath }))
29168
- },
29169
- ...pkg.commands.map((c) => ({
29170
- path: join10(commandDir(dir), namespacedCommandFilename(c.name)),
29171
- contents: renderPlugin(c.contents, { version: VERSION, binPath: pkg.binPath })
29172
- }))
29173
- ];
29174
- const result = deployFiles(files, { dryRun: opts.dryRun });
29175
- const manifest = installManifest(dir, opts.dryRun);
29176
- if (!opts.dryRun)
29177
- ensureDependencyInstalled(dir, deps.installDeps ?? bunInstall);
29178
- printResult("installed", [...result.paths, ...manifest], opts.dryRun, dir);
29179
- }
29180
- function ensureDependencyInstalled(dir, install) {
29181
- const r = install(dir);
29182
- if (r.ok) {
29183
- process.stdout.write(`caret: installed the plugin dependency (${OPENCODE_PLUGIN_DEP}).
29184
- `);
29185
- } else {
29186
- process.stderr.write(`caret: could not auto-install the plugin dependency (${r.detail}). Run \`bun install\` in ${dir} to finish, then restart OpenCode.
29187
- `);
29188
- }
30573
+ const changed = editConfig(configFile2, (text) => addPluginToConfigText(text, CARET_PACKAGE), opts.dryRun);
30574
+ const files = pkg.commands.map((c) => ({
30575
+ path: join10(commandDir(dir), namespacedCommandFilename(c.name)),
30576
+ contents: renderPlugin(c.contents, { version: VERSION, binPath: pkg.binPath })
30577
+ }));
30578
+ const deployed = deployFiles(files, { dryRun: opts.dryRun });
30579
+ printResult("installed", [...changed, ...deployed.paths], opts.dryRun, dir);
29189
30580
  }
29190
- var bunInstall = (configDir2) => {
29191
- try {
29192
- const res = Bun.spawnSync(["bun", "install"], {
29193
- cwd: configDir2,
29194
- stdout: "pipe",
29195
- stderr: "pipe"
29196
- });
29197
- if (res.exitCode === 0)
29198
- return { ok: true, detail: "" };
29199
- const err = new TextDecoder().decode(res.stderr).trim();
29200
- return { ok: false, detail: err || `bun install exited ${res.exitCode}` };
29201
- } catch (e) {
29202
- return { ok: false, detail: e instanceof Error ? e.message : String(e) };
29203
- }
29204
- };
29205
- function installManifest(dir, dryRun) {
29206
- const path = packageJsonPath(dir);
29207
- const existing = existsSync7(path) ? readFileSync8(path, "utf-8") : null;
29208
- let next;
29209
- try {
29210
- next = addPluginDependency(existing, OPENCODE_PLUGIN_DEP, OPENCODE_PLUGIN_DEP_VERSION);
29211
- } catch {
29212
- process.stderr.write(`caret: ${path} is not valid JSON \u2014 leaving it untouched. Add "${OPENCODE_PLUGIN_DEP}": "${OPENCODE_PLUGIN_DEP_VERSION}" to its dependencies so OpenCode can load the plugin.
29213
- `);
30581
+ function editConfig(path, transform2, dryRun) {
30582
+ const existing = existsSync8(path) ? readFileSync8(path, "utf-8") : null;
30583
+ const next = transform2(existing);
30584
+ if (next === null || next === existing)
29214
30585
  return [];
29215
- }
29216
30586
  if (!dryRun)
29217
30587
  writeFileSync5(path, next);
29218
30588
  return [path];
29219
30589
  }
29220
- function uninstallManifest(dir, dryRun) {
29221
- const path = packageJsonPath(dir);
29222
- if (!existsSync7(path))
29223
- return [];
29224
- const existing = readFileSync8(path, "utf-8");
29225
- let next;
29226
- try {
29227
- next = removePluginDependency(existing, OPENCODE_PLUGIN_DEP);
29228
- } catch {
29229
- return [];
29230
- }
29231
- if (next === existing)
29232
- return [];
29233
- if (!dryRun) {
29234
- if (next === null)
29235
- rmSync2(path, { force: true });
29236
- else
29237
- writeFileSync5(path, next);
29238
- }
29239
- return [path];
29240
- }
29241
30590
  function printResult(verb, paths, dryRun, dir) {
29242
- const lead = dryRun ? `[dry-run] would have ${verb}` : `${verb}`;
29243
- process.stdout.write(`caret: ${lead} ${paths.length} OpenCode file(s) under ${dir}:
30591
+ if (paths.length === 0) {
30592
+ const noun = verb === "removed" ? "remove" : "install";
30593
+ process.stdout.write(`caret: nothing to ${noun} for OpenCode under ${dir}.
30594
+ `);
30595
+ return;
30596
+ }
30597
+ const lead = dryRun ? `[dry-run] would have ${verb}` : verb;
30598
+ process.stdout.write(`caret: ${lead} caret in OpenCode (${paths.length} path(s)) under ${dir}:
29244
30599
  `);
29245
30600
  for (const p of paths)
29246
30601
  process.stdout.write(` ${p}
29247
30602
  `);
30603
+ if (verb === "installed" && !dryRun) {
30604
+ process.stdout.write(`caret: restart OpenCode once so it installs and loads the plugin.
30605
+ `);
30606
+ }
30607
+ }
30608
+
30609
+ // src/commands/install.ts
30610
+ var KNOWN_TARGETS = ["opencode", "claude"];
30611
+ function parseTargets(raw) {
30612
+ const parts = (raw ?? "").split(",").map((s) => s.trim()).filter(Boolean);
30613
+ if (parts.length === 0) {
30614
+ return {
30615
+ error: `--target is required (a comma-separated list of: ${KNOWN_TARGETS.join(", ")}).`
30616
+ };
30617
+ }
30618
+ const unknown2 = parts.filter((p) => !KNOWN_TARGETS.includes(p));
30619
+ if (unknown2.length > 0) {
30620
+ return {
30621
+ error: `unknown --target value(s): ${unknown2.join(", ")}. Valid: ${KNOWN_TARGETS.join(", ")}.`
30622
+ };
30623
+ }
30624
+ const targets = [];
30625
+ for (const p of parts)
30626
+ if (!targets.includes(p))
30627
+ targets.push(p);
30628
+ return { targets };
30629
+ }
30630
+ function runInstallSubcommand(opts, deps = {}) {
30631
+ const parsed = parseTargets(opts.target);
30632
+ if ("error" in parsed) {
30633
+ process.stderr.write(`caret: ${parsed.error}
30634
+ `);
30635
+ process.exitCode = 2;
30636
+ return;
30637
+ }
30638
+ const runOpencode = deps.runOpencode ?? ((o) => runInstallOpencodeTarget(o));
30639
+ const runClaude = deps.runClaude ?? ((o) => runInstallClaudeTarget(o));
30640
+ const targetOpts = { uninstall: opts.uninstall, dryRun: opts.dryRun };
30641
+ for (const target of parsed.targets) {
30642
+ if (target === "opencode")
30643
+ runOpencode(targetOpts);
30644
+ else
30645
+ runClaude(targetOpts);
30646
+ }
29248
30647
  }
29249
30648
 
29250
30649
  // src/commands/prewarm.ts
@@ -32878,14 +34277,15 @@ function runProgram(program2, onError) {
32878
34277
 
32879
34278
  // src/cli.ts
32880
34279
  function buildProgram() {
32881
- const program2 = createProgram("caret", "caret hook CLI: daemon | prewarm | review | reconcile | redact | discovery | install-opencode").version(VERSION);
34280
+ const program2 = createProgram("caret", "caret hook CLI: daemon | prewarm | review | reconcile | redact | discovery | install").version(VERSION);
32882
34281
  program2.command("daemon").description("run the review daemon").option("--ephemeral", "bind an OS-assigned port instead of the configured one").action((opts) => runDaemon({ ephemeral: opts.ephemeral ?? false }));
32883
34282
  program2.command("prewarm").description("warm-start the daemon").action(() => runPrewarm());
32884
34283
  program2.command("review").description("review a plan from stdin (ExitPlanMode hook)").action(() => runReviewSubcommand());
32885
34284
  program2.command("reconcile").description("reconcile a terminal plan approval into the daemon (ExitPlanMode PostToolUse hook)").action(() => runReconcileSubcommand());
32886
34285
  program2.command("redact").description("write redacted copies of the logs").action(() => runRedactSubcommand());
32887
34286
  program2.command("discovery").description("print a diagnostics report").option("--json", "emit the machine-readable JSON document").action((opts) => runDiscoverySubcommand({ json: opts.json ?? false }));
32888
- program2.command("install-opencode").description("install (or with --uninstall, remove) caret's OpenCode plugin + commands").option("--uninstall", "remove caret's OpenCode files instead of installing them").option("--dry-run", "print what would change without writing").action((opts) => runInstallOpencodeSubcommand({
34287
+ program2.command("install").description("install caret into a coding agent (--target opencode,claude)").requiredOption("--target <targets>", "comma-separated agents to install into: opencode, claude, or opencode,claude").option("--uninstall", "remove caret from the target(s) instead of installing").option("--dry-run", "print what would change without writing").action((opts) => runInstallSubcommand({
34288
+ target: opts.target,
32889
34289
  uninstall: opts.uninstall ?? false,
32890
34290
  dryRun: opts.dryRun ?? false
32891
34291
  }));