@qwen-code/qwen-code 0.18.5 → 0.19.1-nightly.20260624.a234860a4

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 (165) hide show
  1. package/bundled/qc-helper/SKILL.md +13 -5
  2. package/bundled/qc-helper/docs/configuration/_meta.ts +1 -0
  3. package/bundled/qc-helper/docs/configuration/auth.md +68 -48
  4. package/bundled/qc-helper/docs/configuration/model-providers.md +217 -195
  5. package/bundled/qc-helper/docs/configuration/qwen-ignore.md +31 -15
  6. package/bundled/qc-helper/docs/configuration/settings.md +44 -27
  7. package/bundled/qc-helper/docs/configuration/themes.md +7 -4
  8. package/bundled/qc-helper/docs/extension/extension-releasing.md +1 -1
  9. package/bundled/qc-helper/docs/extension/introduction.md +27 -21
  10. package/bundled/qc-helper/docs/features/arena.md +3 -3
  11. package/bundled/qc-helper/docs/features/channels/overview.md +1 -1
  12. package/bundled/qc-helper/docs/features/channels/plugins.md +1 -1
  13. package/bundled/qc-helper/docs/features/commands.md +6 -1
  14. package/bundled/qc-helper/docs/features/headless.md +1 -1
  15. package/bundled/qc-helper/docs/features/mcp.md +33 -14
  16. package/bundled/qc-helper/docs/features/sandbox.md +2 -2
  17. package/bundled/qc-helper/docs/features/tool-use-summaries.md +1 -1
  18. package/bundled/qc-helper/docs/integration-github-action.md +2 -2
  19. package/bundled/qc-helper/docs/overview.md +1 -1
  20. package/bundled/qc-helper/docs/quickstart.md +9 -5
  21. package/bundled/qc-helper/docs/qwen-serve.md +14 -2
  22. package/bundled/qc-helper/docs/support/tos-privacy.md +1 -1
  23. package/chunks/{agent-2TEY55UD.js → agent-6KV474S5.js} +24 -22
  24. package/chunks/{agent-headless-SCUAXEEE.js → agent-headless-XO7MM6JT.js} +24 -22
  25. package/chunks/{anthropicContentGenerator-5S4OMMNL.js → anthropicContentGenerator-7352A7I5.js} +12 -11
  26. package/chunks/artifact-tool-5J4HUZAV.js +675 -0
  27. package/chunks/{askUserQuestion-WHVYL2S2.js → askUserQuestion-HF7HCWDD.js} +20 -7
  28. package/chunks/chunk-22IFUCVR.js +291 -0
  29. package/chunks/{chunk-26ZYKTYZ.js → chunk-2BIF2NVV.js} +2 -2
  30. package/chunks/{chunk-VKILGMZQ.js → chunk-2QDQTWCI.js} +1 -1
  31. package/chunks/{chunk-XGU3ETVO.js → chunk-3BR4OIOE.js} +3 -3
  32. package/chunks/{chunk-LTN3VYMZ.js → chunk-3UALQ56H.js} +1 -1
  33. package/chunks/{chunk-F5E6IKYN.js → chunk-54J4JDWT.js} +619 -135
  34. package/chunks/{chunk-KZGQ3G3Q.js → chunk-76BDT2HH.js} +80 -83
  35. package/chunks/{chunk-VECKCOH6.js → chunk-7QBKO4A6.js} +7118 -5113
  36. package/chunks/{chunk-MSJ2MXJ6.js → chunk-BGUDAULQ.js} +11 -290
  37. package/chunks/{chunk-FH4P6RQA.js → chunk-BNXANYLH.js} +1 -1
  38. package/chunks/{chunk-SIJKWK35.js → chunk-C4JC2FL3.js} +8 -7
  39. package/chunks/{chunk-WE6TNQJU.js → chunk-C4K3FEQ2.js} +36 -0
  40. package/chunks/{chunk-G4BUMVEY.js → chunk-CGEGHF2C.js} +2 -217
  41. package/chunks/chunk-EEEZIVFJ.js +908 -0
  42. package/chunks/chunk-EJYJYJZ2.js +3703 -0
  43. package/chunks/{chunk-ATLUHLZE.js → chunk-EW6C27XX.js} +1 -1
  44. package/chunks/{chunk-42HGOMED.js → chunk-F6XNTYNE.js} +216 -1
  45. package/chunks/{chunk-C6MI2ASN.js → chunk-GZCJS5WH.js} +2 -2
  46. package/chunks/{chunk-KGV3F6UF.js → chunk-HGNSRCRB.js} +1 -1
  47. package/chunks/{chunk-2CNO5W47.js → chunk-HNYTRFAM.js} +171 -5016
  48. package/chunks/{chunk-CX3SGIPK.js → chunk-KBXLIVWQ.js} +2 -2
  49. package/chunks/{chunk-GOMVJKBL.js → chunk-L7U2RI5O.js} +59 -57
  50. package/chunks/{chunk-GBN55AWZ.js → chunk-NKJ6LRCR.js} +2 -2
  51. package/chunks/{chunk-2O3NAOJG.js → chunk-NWLUISRA.js} +1 -1
  52. package/chunks/{chunk-ID533GA3.js → chunk-OTBK43JR.js} +1 -1
  53. package/chunks/{chunk-AE6RQU6F.js → chunk-PRYMDRBV.js} +1 -1
  54. package/chunks/{chunk-KQIKOTQJ.js → chunk-RYLJU2DY.js} +60 -5
  55. package/chunks/{chunk-CTHZVIMD.js → chunk-T2VDEFUU.js} +2 -2
  56. package/chunks/{chunk-C7JA3XCX.js → chunk-TKXRLRTF.js} +5 -5
  57. package/chunks/{chunk-LF6BKGZT.js → chunk-TXVGVZYR.js} +3 -3
  58. package/chunks/{chunk-XU7BKR3B.js → chunk-XU5P23GN.js} +3 -3
  59. package/chunks/{computer-use-OB3C5QG2.js → computer-use-WOKHYISX.js} +24 -22
  60. package/chunks/contextCommand-JSYQAO3O.js +56 -0
  61. package/chunks/{cron-create-THNDTYXU.js → cron-create-A5637KCI.js} +12 -9
  62. package/chunks/{cron-delete-BS5H6TFJ.js → cron-delete-AADOSEOZ.js} +4 -4
  63. package/chunks/{cron-list-7OBVHT7K.js → cron-list-OFCPTT2Y.js} +4 -4
  64. package/chunks/{dist-GKRNVFBH.js → dist-ZBX7LPJZ.js} +2 -1
  65. package/chunks/{edit-GNCLIF67.js → edit-6EN6NO6G.js} +24 -22
  66. package/chunks/{en-S3OQBISC.js → en-7OGNWWME.js} +48 -0
  67. package/chunks/{enter-worktree-E7BNZOGT.js → enter-worktree-XJ4S74CL.js} +24 -22
  68. package/chunks/{enterPlanMode-IA42A5EU.js → enterPlanMode-GQNQIH2V.js} +27 -23
  69. package/chunks/{exit-worktree-QJ2K74UT.js → exit-worktree-6MKLATVB.js} +24 -22
  70. package/chunks/{exitPlanMode-UKKHBUYJ.js → exitPlanMode-YACWA5GO.js} +36 -28
  71. package/chunks/{geminiContentGenerator-ICSDM37U.js → geminiContentGenerator-OLJGOIWO.js} +4 -4
  72. package/chunks/{glob-IGD7LWYX.js → glob-YHSIN2LG.js} +26 -23
  73. package/chunks/{grep-IZM3IVND.js → grep-5EMEAJBO.js} +24 -22
  74. package/chunks/{keychain-token-storage-YHXIWXIB.js → keychain-token-storage-CSYMNRPP.js} +2 -2
  75. package/chunks/{loop-wakeup-SSBWZ64K.js → loop-wakeup-DGSMT4N6.js} +5 -5
  76. package/chunks/{ls-YPFUHZRQ.js → ls-UGRZ4ZOM.js} +6 -6
  77. package/chunks/{lsp-FD6DNVAF.js → lsp-72IJURW3.js} +2 -2
  78. package/chunks/{monitor-ALJNE3R4.js → monitor-ZGXTGINM.js} +24 -22
  79. package/chunks/{notebook-edit-7XRZX55T.js → notebook-edit-O7WO3APR.js} +25 -23
  80. package/chunks/{openaiContentGenerator-FWKITDFJ.js → openaiContentGenerator-N4FCEGU2.js} +12 -15
  81. package/chunks/{qwenContentGenerator-5RPGQZ63.js → qwenContentGenerator-BOAZ7MMG.js} +26 -24
  82. package/chunks/{qwenOAuth2-WZ54YZ4J.js → qwenOAuth2-K4AASPCV.js} +5 -4
  83. package/chunks/{read-file-4WN2DT5N.js → read-file-RB35MI5I.js} +9 -8
  84. package/chunks/{ripGrep-4ZKT6KBQ.js → ripGrep-CWJOA6JG.js} +24 -22
  85. package/chunks/{scheduler-O2E65VDK.js → scheduler-XUBHNI2Z.js} +73 -27
  86. package/chunks/{send-message-FWFTX62Q.js → send-message-URUZ7PLA.js} +24 -4
  87. package/chunks/{serve-3DM6CRGD.js → serve-P356SCA2.js} +618 -92
  88. package/chunks/{shell-ARVZK6RF.js → shell-5TRHTPML.js} +24 -22
  89. package/chunks/{skill-BFUBGA4I.js → skill-RW6N7GHL.js} +11 -10
  90. package/chunks/{src-5YMCDSII.js → src-SPEHQKTK.js} +140 -67
  91. package/chunks/{syntheticOutput-JY5NEDTV.js → syntheticOutput-65FRJGWM.js} +3 -3
  92. package/chunks/{task-create-IGILDV25.js → task-create-IH45HOFT.js} +6 -6
  93. package/chunks/{task-list-KBEJVAAG.js → task-list-FUB6JWSX.js} +5 -5
  94. package/chunks/{task-stop-WFTMQ6AC.js → task-stop-P6IOHQM3.js} +2 -2
  95. package/chunks/{task-update-UIVX7ZEV.js → task-update-RTUT7LJV.js} +6 -6
  96. package/chunks/{team-create-HRBV5ATK.js → team-create-D6GSPXCO.js} +28 -26
  97. package/chunks/{team-delete-LPOXDPVB.js → team-delete-RXGYRMHC.js} +5 -5
  98. package/chunks/{todoWrite-R4RIJKOD.js → todoWrite-O6JK24G6.js} +4 -4
  99. package/chunks/{tool-search-67HI54YA.js → tool-search-6YIMUUVD.js} +9 -8
  100. package/chunks/{web-fetch-JU7SS6KE.js → web-fetch-KUMBROUI.js} +4 -4
  101. package/chunks/{workflow-W4SCLWLU.js → workflow-ML3XFTCN.js} +557 -97
  102. package/chunks/{write-file-TLNXC2NR.js → write-file-VLT6ODLK.js} +24 -22
  103. package/chunks/{zh-QXLZV2PX.js → zh-3RMSEO5M.js} +48 -0
  104. package/chunks/{zh-TW-3OKU7LDA.js → zh-TW-R7WRLTJS.js} +48 -0
  105. package/cli.js +8559 -5100
  106. package/locales/en.js +69 -0
  107. package/locales/zh-TW.js +66 -0
  108. package/locales/zh.js +66 -0
  109. package/package.json +3 -2
  110. package/web-shell/assets/{arc-CRFN10gD.js → arc-DHUeMnnj.js} +1 -1
  111. package/web-shell/assets/{architectureDiagram-3BPJPVTR-IRlu1CpH.js → architectureDiagram-3BPJPVTR-DlX12yyj.js} +1 -1
  112. package/web-shell/assets/{blockDiagram-GPEHLZMM-htIZ6iw8.js → blockDiagram-GPEHLZMM-DTFUXMUT.js} +1 -1
  113. package/web-shell/assets/{c4Diagram-AAUBKEIU-A2GoRq3O.js → c4Diagram-AAUBKEIU-CWdB54fk.js} +1 -1
  114. package/web-shell/assets/channel-C3WhMjjP.js +1 -0
  115. package/web-shell/assets/{chunk-2J33WTMH-CdP2AC6u.js → chunk-2J33WTMH-CF5C5jNR.js} +1 -1
  116. package/web-shell/assets/{chunk-4BX2VUAB-DrA07nW2.js → chunk-4BX2VUAB-Cw7Ydfji.js} +1 -1
  117. package/web-shell/assets/{chunk-55IACEB6-CFGnVU2f.js → chunk-55IACEB6-CnbI1ZCw.js} +1 -1
  118. package/web-shell/assets/{chunk-727SXJPM-BTMkq3Tk.js → chunk-727SXJPM-DmSy00Pe.js} +1 -1
  119. package/web-shell/assets/{chunk-AQP2D5EJ-C9sYg04Z.js → chunk-AQP2D5EJ-DgNgXqBu.js} +1 -1
  120. package/web-shell/assets/{chunk-FMBD7UC4-Cag-cj6I.js → chunk-FMBD7UC4-tz2IvOXv.js} +1 -1
  121. package/web-shell/assets/{chunk-ND2GUHAM-CDSTFoR7.js → chunk-ND2GUHAM-DaBLEBPa.js} +1 -1
  122. package/web-shell/assets/{chunk-QZHKN3VN-CN9Z6oOs.js → chunk-QZHKN3VN-DVCQST3O.js} +1 -1
  123. package/web-shell/assets/classDiagram-4FO5ZUOK-CQ6TXPif.js +1 -0
  124. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-CQ6TXPif.js +1 -0
  125. package/web-shell/assets/{cose-bilkent-S5V4N54A-DuN9j8Du.js → cose-bilkent-S5V4N54A-CAKTcdCQ.js} +1 -1
  126. package/web-shell/assets/{dagre-BM42HDAG-ByCWe45f.js → dagre-BM42HDAG-BdkBwlKg.js} +1 -1
  127. package/web-shell/assets/{diagram-2AECGRRQ-eWyU_pKZ.js → diagram-2AECGRRQ-DYt3G65F.js} +1 -1
  128. package/web-shell/assets/{diagram-5GNKFQAL-0Bfu3Fq5.js → diagram-5GNKFQAL-BWvROWjY.js} +1 -1
  129. package/web-shell/assets/{diagram-KO2AKTUF-B6KBKkQP.js → diagram-KO2AKTUF-BvvgwIaQ.js} +1 -1
  130. package/web-shell/assets/{diagram-LMA3HP47-TToDmeA_.js → diagram-LMA3HP47-E7NLSNKg.js} +1 -1
  131. package/web-shell/assets/{diagram-OG6HWLK6-CQCkC2Yx.js → diagram-OG6HWLK6-CYmUBgpE.js} +1 -1
  132. package/web-shell/assets/{erDiagram-TEJ5UH35-Cm9ls1iB.js → erDiagram-TEJ5UH35-BU5gY30h.js} +1 -1
  133. package/web-shell/assets/{flowDiagram-I6XJVG4X-Dyoz80Pv.js → flowDiagram-I6XJVG4X-V_ZssSZ9.js} +1 -1
  134. package/web-shell/assets/{ganttDiagram-6RSMTGT7-Cfut9yaU.js → ganttDiagram-6RSMTGT7-QIShlsdI.js} +1 -1
  135. package/web-shell/assets/{gitGraphDiagram-PVQCEYII-BCuJdlfD.js → gitGraphDiagram-PVQCEYII-DJxdu2YS.js} +1 -1
  136. package/web-shell/assets/index-BPnhI7gl.css +1 -0
  137. package/web-shell/assets/index-De4rqTsW.js +706 -0
  138. package/web-shell/assets/{infoDiagram-5YYISTIA-CXKxF2VL.js → infoDiagram-5YYISTIA-BqjdrFeO.js} +1 -1
  139. package/web-shell/assets/{ishikawaDiagram-YF4QCWOH-DE7HWSU8.js → ishikawaDiagram-YF4QCWOH-BP_a2YZ2.js} +1 -1
  140. package/web-shell/assets/{journeyDiagram-JHISSGLW-D__YUfds.js → journeyDiagram-JHISSGLW-BXg-S3Lk.js} +1 -1
  141. package/web-shell/assets/{kanban-definition-UN3LZRKU-D82R169M.js → kanban-definition-UN3LZRKU-BksAkdEJ.js} +1 -1
  142. package/web-shell/assets/{linear-DpyMbKqT.js → linear-D2m9-ODE.js} +1 -1
  143. package/web-shell/assets/{mermaid.core-D1KEFDhn.js → mermaid.core-dTtkZp2F.js} +5 -5
  144. package/web-shell/assets/{mindmap-definition-RKZ34NQL-BwVUFGFE.js → mindmap-definition-RKZ34NQL-Bft9my8O.js} +1 -1
  145. package/web-shell/assets/{pieDiagram-4H26LBE5-BO_qoEGx.js → pieDiagram-4H26LBE5-Cw8S-alZ.js} +1 -1
  146. package/web-shell/assets/{quadrantDiagram-W4KKPZXB-Cx0ZaWPo.js → quadrantDiagram-W4KKPZXB-DaDoTMts.js} +1 -1
  147. package/web-shell/assets/{requirementDiagram-4Y6WPE33-BJPXejOA.js → requirementDiagram-4Y6WPE33-Cp5kSpwj.js} +1 -1
  148. package/web-shell/assets/{sankeyDiagram-5OEKKPKP-C1xeIL9i.js → sankeyDiagram-5OEKKPKP-CW8RsJJZ.js} +1 -1
  149. package/web-shell/assets/{sequenceDiagram-3UESZ5HK-CSYKQUjf.js → sequenceDiagram-3UESZ5HK-DTfpIiJK.js} +1 -1
  150. package/web-shell/assets/{stateDiagram-AJRCARHV-d9hiHlAW.js → stateDiagram-AJRCARHV-DixFVzEs.js} +1 -1
  151. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-DZgE04s3.js +1 -0
  152. package/web-shell/assets/{timeline-definition-PNZ67QCA-BhCBkq8k.js → timeline-definition-PNZ67QCA-DYsbXn5l.js} +1 -1
  153. package/web-shell/assets/{vennDiagram-CIIHVFJN-DPPFWp_y.js → vennDiagram-CIIHVFJN-HUpRpuUp.js} +1 -1
  154. package/web-shell/assets/{wardley-L42UT6IY-CcOUIgXY.js → wardley-L42UT6IY-cT3nQH_T.js} +1 -1
  155. package/web-shell/assets/{wardleyDiagram-YWT4CUSO-p7oR5X7r.js → wardleyDiagram-YWT4CUSO-Dmm7J6Qc.js} +1 -1
  156. package/web-shell/assets/{xychartDiagram-2RQKCTM6-Dfr7-SEy.js → xychartDiagram-2RQKCTM6-CX0L5p9C.js} +1 -1
  157. package/web-shell/index.html +3 -3
  158. package/chunks/chunk-77WXWU44.js +0 -26
  159. package/chunks/contextCommand-3327KUC4.js +0 -54
  160. package/web-shell/assets/channel-WwImfsc7.js +0 -1
  161. package/web-shell/assets/classDiagram-4FO5ZUOK-CJKQYFeJ.js +0 -1
  162. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-CJKQYFeJ.js +0 -1
  163. package/web-shell/assets/index-BDZiTAkl.css +0 -1
  164. package/web-shell/assets/index-DaebdpHq.js +0 -516
  165. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-DgReoybQ.js +0 -1
@@ -0,0 +1,908 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import {
4
+ createDebugLogger,
5
+ isNodeError
6
+ } from "./chunk-C4K3FEQ2.js";
7
+ import {
8
+ init_esbuild_shims
9
+ } from "./chunk-A4BMJM77.js";
10
+ import {
11
+ __commonJS,
12
+ __name,
13
+ __toESM
14
+ } from "./chunk-J2S4EL5Y.js";
15
+
16
+ // packages/core/node_modules/ignore/index.js
17
+ var require_ignore = __commonJS({
18
+ "packages/core/node_modules/ignore/index.js"(exports, module) {
19
+ init_esbuild_shims();
20
+ function makeArray(subject) {
21
+ return Array.isArray(subject) ? subject : [subject];
22
+ }
23
+ __name(makeArray, "makeArray");
24
+ var UNDEFINED = void 0;
25
+ var EMPTY = "";
26
+ var SPACE = " ";
27
+ var ESCAPE = "\\";
28
+ var REGEX_TEST_BLANK_LINE = /^\s+$/;
29
+ var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
30
+ var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
31
+ var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
32
+ var REGEX_SPLITALL_CRLF = /\r?\n/g;
33
+ var REGEX_TEST_INVALID_PATH = /^\.{0,2}\/|^\.{1,2}$/;
34
+ var REGEX_TEST_TRAILING_SLASH = /\/$/;
35
+ var SLASH = "/";
36
+ var TMP_KEY_IGNORE = "node-ignore";
37
+ if (typeof Symbol !== "undefined") {
38
+ TMP_KEY_IGNORE = Symbol.for("node-ignore");
39
+ }
40
+ var KEY_IGNORE = TMP_KEY_IGNORE;
41
+ var define = /* @__PURE__ */ __name((object, key, value) => {
42
+ Object.defineProperty(object, key, { value });
43
+ return value;
44
+ }, "define");
45
+ var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
46
+ var RETURN_FALSE = /* @__PURE__ */ __name(() => false, "RETURN_FALSE");
47
+ var sanitizeRange = /* @__PURE__ */ __name((range) => range.replace(
48
+ REGEX_REGEXP_RANGE,
49
+ (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match : EMPTY
50
+ ), "sanitizeRange");
51
+ var cleanRangeBackSlash = /* @__PURE__ */ __name((slashes) => {
52
+ const { length } = slashes;
53
+ return slashes.slice(0, length - length % 2);
54
+ }, "cleanRangeBackSlash");
55
+ var REPLACERS = [
56
+ [
57
+ // Remove BOM
58
+ // TODO:
59
+ // Other similar zero-width characters?
60
+ /^\uFEFF/,
61
+ () => EMPTY
62
+ ],
63
+ // > Trailing spaces are ignored unless they are quoted with backslash ("\")
64
+ [
65
+ // (a\ ) -> (a )
66
+ // (a ) -> (a)
67
+ // (a ) -> (a)
68
+ // (a \ ) -> (a )
69
+ /((?:\\\\)*?)(\\?\s+)$/,
70
+ (_, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE : EMPTY)
71
+ ],
72
+ // Replace (\ ) with ' '
73
+ // (\ ) -> ' '
74
+ // (\\ ) -> '\\ '
75
+ // (\\\ ) -> '\\ '
76
+ [
77
+ /(\\+?)\s/g,
78
+ (_, m1) => {
79
+ const { length } = m1;
80
+ return m1.slice(0, length - length % 2) + SPACE;
81
+ }
82
+ ],
83
+ // Escape metacharacters
84
+ // which is written down by users but means special for regular expressions.
85
+ // > There are 12 characters with special meanings:
86
+ // > - the backslash \,
87
+ // > - the caret ^,
88
+ // > - the dollar sign $,
89
+ // > - the period or dot .,
90
+ // > - the vertical bar or pipe symbol |,
91
+ // > - the question mark ?,
92
+ // > - the asterisk or star *,
93
+ // > - the plus sign +,
94
+ // > - the opening parenthesis (,
95
+ // > - the closing parenthesis ),
96
+ // > - and the opening square bracket [,
97
+ // > - the opening curly brace {,
98
+ // > These special characters are often called "metacharacters".
99
+ [
100
+ /[\\$.|*+(){^]/g,
101
+ (match) => `\\${match}`
102
+ ],
103
+ [
104
+ // > a question mark (?) matches a single character
105
+ /(?!\\)\?/g,
106
+ () => "[^/]"
107
+ ],
108
+ // leading slash
109
+ [
110
+ // > A leading slash matches the beginning of the pathname.
111
+ // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
112
+ // A leading slash matches the beginning of the pathname
113
+ /^\//,
114
+ () => "^"
115
+ ],
116
+ // replace special metacharacter slash after the leading slash
117
+ [
118
+ /\//g,
119
+ () => "\\/"
120
+ ],
121
+ [
122
+ // > A leading "**" followed by a slash means match in all directories.
123
+ // > For example, "**/foo" matches file or directory "foo" anywhere,
124
+ // > the same as pattern "foo".
125
+ // > "**/foo/bar" matches file or directory "bar" anywhere that is directly
126
+ // > under directory "foo".
127
+ // Notice that the '*'s have been replaced as '\\*'
128
+ /^\^*\\\*\\\*\\\//,
129
+ // '**/foo' <-> 'foo'
130
+ () => "^(?:.*\\/)?"
131
+ ],
132
+ // starting
133
+ [
134
+ // there will be no leading '/'
135
+ // (which has been replaced by section "leading slash")
136
+ // If starts with '**', adding a '^' to the regular expression also works
137
+ /^(?=[^^])/,
138
+ /* @__PURE__ */ __name(function startingReplacer() {
139
+ return !/\/(?!$)/.test(this) ? "(?:^|\\/)" : "^";
140
+ }, "startingReplacer")
141
+ ],
142
+ // two globstars
143
+ [
144
+ // Use lookahead assertions so that we could match more than one `'/**'`
145
+ /\\\/\\\*\\\*(?=\\\/|$)/g,
146
+ // Zero, one or several directories
147
+ // should not use '*', or it will be replaced by the next replacer
148
+ // Check if it is not the last `'/**'`
149
+ (_, index, str) => index + 6 < str.length ? "(?:\\/[^\\/]+)*" : "\\/.+"
150
+ ],
151
+ // normal intermediate wildcards
152
+ [
153
+ // Never replace escaped '*'
154
+ // ignore rule '\*' will match the path '*'
155
+ // 'abc.*/' -> go
156
+ // 'abc.*' -> skip this rule,
157
+ // coz trailing single wildcard will be handed by [trailing wildcard]
158
+ /(^|[^\\]+)(\\\*)+(?=.+)/g,
159
+ // '*.js' matches '.js'
160
+ // '*.js' doesn't match 'abc'
161
+ (_, p1, p2) => {
162
+ const unescaped = p2.replace(/\\\*/g, "[^\\/]*");
163
+ return p1 + unescaped;
164
+ }
165
+ ],
166
+ [
167
+ // unescape, revert step 3 except for back slash
168
+ // For example, if a user escape a '\\*',
169
+ // after step 3, the result will be '\\\\\\*'
170
+ /\\\\\\(?=[$.|*+(){^])/g,
171
+ () => ESCAPE
172
+ ],
173
+ [
174
+ // '\\\\' -> '\\'
175
+ /\\\\/g,
176
+ () => ESCAPE
177
+ ],
178
+ [
179
+ // > The range notation, e.g. [a-zA-Z],
180
+ // > can be used to match one of the characters in a range.
181
+ // `\` is escaped by step 3
182
+ /(\\)?\[([^\]/]*?)(\\*)($|\])/g,
183
+ (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` : close === "]" ? endEscape.length % 2 === 0 ? `[${sanitizeRange(range)}${endEscape}]` : "[]" : "[]"
184
+ ],
185
+ // ending
186
+ [
187
+ // 'js' will not match 'js.'
188
+ // 'ab' will not match 'abc'
189
+ /(?:[^*])$/,
190
+ // WTF!
191
+ // https://git-scm.com/docs/gitignore
192
+ // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
193
+ // which re-fixes #24, #38
194
+ // > If there is a separator at the end of the pattern then the pattern
195
+ // > will only match directories, otherwise the pattern can match both
196
+ // > files and directories.
197
+ // 'js*' will not match 'a.js'
198
+ // 'js/' will not match 'a.js'
199
+ // 'js' will match 'a.js' and 'a.js/'
200
+ (match) => /\/$/.test(match) ? `${match}$` : `${match}(?=$|\\/$)`
201
+ ]
202
+ ];
203
+ var REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\\\*$/;
204
+ var MODE_IGNORE = "regex";
205
+ var MODE_CHECK_IGNORE = "checkRegex";
206
+ var UNDERSCORE = "_";
207
+ var TRAILING_WILD_CARD_REPLACERS = {
208
+ [MODE_IGNORE](_, p1) {
209
+ const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
210
+ return `${prefix}(?=$|\\/$)`;
211
+ },
212
+ [MODE_CHECK_IGNORE](_, p1) {
213
+ const prefix = p1 ? `${p1}[^/]*` : "[^/]*";
214
+ return `${prefix}(?=$|\\/$)`;
215
+ }
216
+ };
217
+ var makeRegexPrefix = /* @__PURE__ */ __name((pattern) => REPLACERS.reduce(
218
+ (prev, [matcher, replacer]) => prev.replace(matcher, replacer.bind(pattern)),
219
+ pattern
220
+ ), "makeRegexPrefix");
221
+ var isString = /* @__PURE__ */ __name((subject) => typeof subject === "string", "isString");
222
+ var checkPattern = /* @__PURE__ */ __name((pattern) => pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) && pattern.indexOf("#") !== 0, "checkPattern");
223
+ var splitPattern = /* @__PURE__ */ __name((pattern) => pattern.split(REGEX_SPLITALL_CRLF).filter(Boolean), "splitPattern");
224
+ var IgnoreRule = class {
225
+ static {
226
+ __name(this, "IgnoreRule");
227
+ }
228
+ constructor(pattern, mark, body, ignoreCase, negative, prefix) {
229
+ this.pattern = pattern;
230
+ this.mark = mark;
231
+ this.negative = negative;
232
+ define(this, "body", body);
233
+ define(this, "ignoreCase", ignoreCase);
234
+ define(this, "regexPrefix", prefix);
235
+ }
236
+ get regex() {
237
+ const key = UNDERSCORE + MODE_IGNORE;
238
+ if (this[key]) {
239
+ return this[key];
240
+ }
241
+ return this._make(MODE_IGNORE, key);
242
+ }
243
+ get checkRegex() {
244
+ const key = UNDERSCORE + MODE_CHECK_IGNORE;
245
+ if (this[key]) {
246
+ return this[key];
247
+ }
248
+ return this._make(MODE_CHECK_IGNORE, key);
249
+ }
250
+ _make(mode, key) {
251
+ const str = this.regexPrefix.replace(
252
+ REGEX_REPLACE_TRAILING_WILDCARD,
253
+ // It does not need to bind pattern
254
+ TRAILING_WILD_CARD_REPLACERS[mode]
255
+ );
256
+ const regex = this.ignoreCase ? new RegExp(str, "i") : new RegExp(str);
257
+ return define(this, key, regex);
258
+ }
259
+ };
260
+ var createRule = /* @__PURE__ */ __name(({
261
+ pattern,
262
+ mark
263
+ }, ignoreCase) => {
264
+ let negative = false;
265
+ let body = pattern;
266
+ if (body.indexOf("!") === 0) {
267
+ negative = true;
268
+ body = body.substr(1);
269
+ }
270
+ body = body.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
271
+ const regexPrefix = makeRegexPrefix(body);
272
+ return new IgnoreRule(
273
+ pattern,
274
+ mark,
275
+ body,
276
+ ignoreCase,
277
+ negative,
278
+ regexPrefix
279
+ );
280
+ }, "createRule");
281
+ var RuleManager = class {
282
+ static {
283
+ __name(this, "RuleManager");
284
+ }
285
+ constructor(ignoreCase) {
286
+ this._ignoreCase = ignoreCase;
287
+ this._rules = [];
288
+ }
289
+ _add(pattern) {
290
+ if (pattern && pattern[KEY_IGNORE]) {
291
+ this._rules = this._rules.concat(pattern._rules._rules);
292
+ this._added = true;
293
+ return;
294
+ }
295
+ if (isString(pattern)) {
296
+ pattern = {
297
+ pattern
298
+ };
299
+ }
300
+ if (checkPattern(pattern.pattern)) {
301
+ const rule = createRule(pattern, this._ignoreCase);
302
+ this._added = true;
303
+ this._rules.push(rule);
304
+ }
305
+ }
306
+ // @param {Array<string> | string | Ignore} pattern
307
+ add(pattern) {
308
+ this._added = false;
309
+ makeArray(
310
+ isString(pattern) ? splitPattern(pattern) : pattern
311
+ ).forEach(this._add, this);
312
+ return this._added;
313
+ }
314
+ // Test one single path without recursively checking parent directories
315
+ //
316
+ // - checkUnignored `boolean` whether should check if the path is unignored,
317
+ // setting `checkUnignored` to `false` could reduce additional
318
+ // path matching.
319
+ // - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
320
+ // @returns {TestResult} true if a file is ignored
321
+ test(path3, checkUnignored, mode) {
322
+ let ignored = false;
323
+ let unignored = false;
324
+ let matchedRule;
325
+ this._rules.forEach((rule) => {
326
+ const { negative } = rule;
327
+ if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
328
+ return;
329
+ }
330
+ const matched = rule[mode].test(path3);
331
+ if (!matched) {
332
+ return;
333
+ }
334
+ ignored = !negative;
335
+ unignored = negative;
336
+ matchedRule = negative ? UNDEFINED : rule;
337
+ });
338
+ const ret = {
339
+ ignored,
340
+ unignored
341
+ };
342
+ if (matchedRule) {
343
+ ret.rule = matchedRule;
344
+ }
345
+ return ret;
346
+ }
347
+ };
348
+ var throwError = /* @__PURE__ */ __name((message, Ctor) => {
349
+ throw new Ctor(message);
350
+ }, "throwError");
351
+ var checkPath = /* @__PURE__ */ __name((path3, originalPath, doThrow) => {
352
+ if (!isString(path3)) {
353
+ return doThrow(
354
+ `path must be a string, but got \`${originalPath}\``,
355
+ TypeError
356
+ );
357
+ }
358
+ if (!path3) {
359
+ return doThrow(`path must not be empty`, TypeError);
360
+ }
361
+ if (checkPath.isNotRelative(path3)) {
362
+ const r = "`path.relative()`d";
363
+ return doThrow(
364
+ `path should be a ${r} string, but got "${originalPath}"`,
365
+ RangeError
366
+ );
367
+ }
368
+ return true;
369
+ }, "checkPath");
370
+ var isNotRelative = /* @__PURE__ */ __name((path3) => REGEX_TEST_INVALID_PATH.test(path3), "isNotRelative");
371
+ checkPath.isNotRelative = isNotRelative;
372
+ checkPath.convert = (p) => p;
373
+ var Ignore = class {
374
+ static {
375
+ __name(this, "Ignore");
376
+ }
377
+ constructor({
378
+ ignorecase = true,
379
+ ignoreCase = ignorecase,
380
+ allowRelativePaths = false
381
+ } = {}) {
382
+ define(this, KEY_IGNORE, true);
383
+ this._rules = new RuleManager(ignoreCase);
384
+ this._strictPathCheck = !allowRelativePaths;
385
+ this._initCache();
386
+ }
387
+ _initCache() {
388
+ this._ignoreCache = /* @__PURE__ */ Object.create(null);
389
+ this._testCache = /* @__PURE__ */ Object.create(null);
390
+ }
391
+ add(pattern) {
392
+ if (this._rules.add(pattern)) {
393
+ this._initCache();
394
+ }
395
+ return this;
396
+ }
397
+ // legacy
398
+ addPattern(pattern) {
399
+ return this.add(pattern);
400
+ }
401
+ // @returns {TestResult}
402
+ _test(originalPath, cache, checkUnignored, slices) {
403
+ const path3 = originalPath && checkPath.convert(originalPath);
404
+ checkPath(
405
+ path3,
406
+ originalPath,
407
+ this._strictPathCheck ? throwError : RETURN_FALSE
408
+ );
409
+ return this._t(path3, cache, checkUnignored, slices);
410
+ }
411
+ checkIgnore(path3) {
412
+ if (!REGEX_TEST_TRAILING_SLASH.test(path3)) {
413
+ return this.test(path3);
414
+ }
415
+ const slices = path3.split(SLASH).filter(Boolean);
416
+ slices.pop();
417
+ if (slices.length) {
418
+ const parent = this._t(
419
+ slices.join(SLASH) + SLASH,
420
+ this._testCache,
421
+ true,
422
+ slices
423
+ );
424
+ if (parent.ignored) {
425
+ return parent;
426
+ }
427
+ }
428
+ return this._rules.test(path3, false, MODE_CHECK_IGNORE);
429
+ }
430
+ _t(path3, cache, checkUnignored, slices) {
431
+ if (path3 in cache) {
432
+ return cache[path3];
433
+ }
434
+ if (!slices) {
435
+ slices = path3.split(SLASH).filter(Boolean);
436
+ }
437
+ slices.pop();
438
+ if (!slices.length) {
439
+ return cache[path3] = this._rules.test(path3, checkUnignored, MODE_IGNORE);
440
+ }
441
+ const parent = this._t(
442
+ slices.join(SLASH) + SLASH,
443
+ cache,
444
+ checkUnignored,
445
+ slices
446
+ );
447
+ return cache[path3] = parent.ignored ? parent : this._rules.test(path3, checkUnignored, MODE_IGNORE);
448
+ }
449
+ ignores(path3) {
450
+ return this._test(path3, this._ignoreCache, false).ignored;
451
+ }
452
+ createFilter() {
453
+ return (path3) => !this.ignores(path3);
454
+ }
455
+ filter(paths) {
456
+ return makeArray(paths).filter(this.createFilter());
457
+ }
458
+ // @returns {TestResult}
459
+ test(path3) {
460
+ return this._test(path3, this._testCache, true);
461
+ }
462
+ };
463
+ var factory = /* @__PURE__ */ __name((options) => new Ignore(options), "factory");
464
+ var isPathValid = /* @__PURE__ */ __name((path3) => checkPath(path3 && checkPath.convert(path3), path3, RETURN_FALSE), "isPathValid");
465
+ var setupWindows = /* @__PURE__ */ __name(() => {
466
+ const makePosix = /* @__PURE__ */ __name((str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/"), "makePosix");
467
+ checkPath.convert = makePosix;
468
+ const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
469
+ checkPath.isNotRelative = (path3) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path3) || isNotRelative(path3);
470
+ }, "setupWindows");
471
+ if (
472
+ // Detect `process` so that it can run in browsers.
473
+ typeof process !== "undefined" && process.platform === "win32"
474
+ ) {
475
+ setupWindows();
476
+ }
477
+ module.exports = factory;
478
+ factory.default = factory;
479
+ module.exports.isPathValid = isPathValid;
480
+ define(module.exports, Symbol.for("setupWindows"), setupWindows);
481
+ }
482
+ });
483
+
484
+ // packages/core/src/utils/workspaceContext.ts
485
+ init_esbuild_shims();
486
+ import * as fs from "node:fs";
487
+ import * as path from "node:path";
488
+ import * as process2 from "node:process";
489
+ var debugLogger = createDebugLogger("WORKSPACE");
490
+ var WorkspaceContext = class _WorkspaceContext {
491
+ static {
492
+ __name(this, "WorkspaceContext");
493
+ }
494
+ directories = /* @__PURE__ */ new Set();
495
+ initialDirectories;
496
+ onDirectoriesChangedListeners = /* @__PURE__ */ new Set();
497
+ /**
498
+ * Memoized realpath results. Every workspace-bounded tool call ultimately
499
+ * routes through {@link fullyResolvedPath} → `fs.realpathSync`; without
500
+ * this cache the same path gets re-resolved on every Read/Glob/Grep/Ls
501
+ * invocation. Bounded so long sessions touching many files don't grow
502
+ * without limit; FIFO eviction is good enough — the working set tends to
503
+ * be the small set of paths the model is actively manipulating.
504
+ */
505
+ resolvedPathCache = /* @__PURE__ */ new Map();
506
+ static RESOLVED_PATH_CACHE_MAX = 1024;
507
+ /**
508
+ * Creates a new WorkspaceContext with the given initial directory and optional additional directories.
509
+ * @param directory The initial working directory (usually cwd)
510
+ * @param additionalDirectories Optional array of additional directories to include
511
+ */
512
+ constructor(directory, additionalDirectories = []) {
513
+ this.addDirectory(directory);
514
+ this.initialDirectories = new Set(this.directories);
515
+ for (const additionalDirectory of additionalDirectories) {
516
+ this.addDirectory(additionalDirectory);
517
+ }
518
+ }
519
+ /**
520
+ * Registers a listener that is called when the workspace directories change.
521
+ * @param listener The listener to call.
522
+ * @returns A function to unsubscribe the listener.
523
+ */
524
+ onDirectoriesChanged(listener) {
525
+ this.onDirectoriesChangedListeners.add(listener);
526
+ return () => {
527
+ this.onDirectoriesChangedListeners.delete(listener);
528
+ };
529
+ }
530
+ notifyDirectoriesChanged() {
531
+ for (const listener of [...this.onDirectoriesChangedListeners]) {
532
+ try {
533
+ listener();
534
+ } catch (e) {
535
+ debugLogger.error("Error in WorkspaceContext listener:", e);
536
+ }
537
+ }
538
+ }
539
+ /**
540
+ * Adds a directory to the workspace.
541
+ * @param directory The directory path to add (can be relative or absolute)
542
+ * @param basePath Optional base path for resolving relative paths (defaults to cwd)
543
+ */
544
+ addDirectory(directory, basePath = process2.cwd()) {
545
+ try {
546
+ const resolved = _WorkspaceContext.resolveAndValidateDir(
547
+ directory,
548
+ basePath
549
+ );
550
+ if (this.directories.has(resolved)) {
551
+ return;
552
+ }
553
+ this.directories.add(resolved);
554
+ this.notifyDirectoriesChanged();
555
+ } catch (err) {
556
+ debugLogger.warn(
557
+ `Skipping unreadable directory: ${directory} (${err instanceof Error ? err.message : String(err)})`
558
+ );
559
+ }
560
+ }
561
+ static resolveAndValidateDir(directory, basePath = process2.cwd()) {
562
+ const absolutePath = path.isAbsolute(directory) ? directory : path.resolve(basePath, directory);
563
+ if (!fs.existsSync(absolutePath)) {
564
+ throw new Error(`Directory does not exist: ${absolutePath}`);
565
+ }
566
+ const stats = fs.statSync(absolutePath);
567
+ if (!stats.isDirectory()) {
568
+ throw new Error(`Path is not a directory: ${absolutePath}`);
569
+ }
570
+ return fs.realpathSync(absolutePath);
571
+ }
572
+ static resolveRootDirectories(directory, additionalDirectories = []) {
573
+ const primaryDirectory = _WorkspaceContext.resolveAndValidateDir(directory);
574
+ const directories = /* @__PURE__ */ new Set([primaryDirectory]);
575
+ for (const additionalDirectory of additionalDirectories) {
576
+ directories.add(
577
+ _WorkspaceContext.resolveAndValidateDir(additionalDirectory)
578
+ );
579
+ }
580
+ return {
581
+ directories,
582
+ initialDirectories: /* @__PURE__ */ new Set([primaryDirectory])
583
+ };
584
+ }
585
+ /**
586
+ * Gets a copy of all workspace directories.
587
+ * @returns Array of absolute directory paths
588
+ */
589
+ getDirectories() {
590
+ return Array.from(this.directories);
591
+ }
592
+ getInitialDirectories() {
593
+ return Array.from(this.initialDirectories);
594
+ }
595
+ /**
596
+ * Removes a directory from the workspace.
597
+ * Cannot remove initial directories (those set at construction time).
598
+ * @param directory The directory path to remove
599
+ * @returns True if the directory was removed, false if not found or is an initial directory
600
+ */
601
+ removeDirectory(directory) {
602
+ let resolved;
603
+ try {
604
+ resolved = _WorkspaceContext.resolveAndValidateDir(directory);
605
+ } catch {
606
+ resolved = path.isAbsolute(directory) ? directory : path.resolve(process2.cwd(), directory);
607
+ }
608
+ if (this.initialDirectories.has(resolved)) {
609
+ debugLogger.warn(`Cannot remove initial directory: ${resolved}`);
610
+ return false;
611
+ }
612
+ if (!this.directories.has(resolved)) {
613
+ return false;
614
+ }
615
+ this.directories.delete(resolved);
616
+ this.notifyDirectoriesChanged();
617
+ return true;
618
+ }
619
+ /**
620
+ * Checks whether a directory is an initial (non-removable) directory.
621
+ */
622
+ isInitialDirectory(directory) {
623
+ try {
624
+ const resolved = _WorkspaceContext.resolveAndValidateDir(directory);
625
+ return this.initialDirectories.has(resolved);
626
+ } catch {
627
+ const absolutePath = path.isAbsolute(directory) ? directory : path.resolve(process2.cwd(), directory);
628
+ return this.initialDirectories.has(absolutePath);
629
+ }
630
+ }
631
+ setDirectories(directories) {
632
+ const newDirectories = /* @__PURE__ */ new Set();
633
+ for (const dir of directories) {
634
+ newDirectories.add(_WorkspaceContext.resolveAndValidateDir(dir));
635
+ }
636
+ if (newDirectories.size !== this.directories.size || ![...newDirectories].every((d) => this.directories.has(d))) {
637
+ this.directories = newDirectories;
638
+ this.notifyDirectoriesChanged();
639
+ }
640
+ }
641
+ applyRootDirectories(resolved) {
642
+ const newDirectories = new Set(resolved.directories);
643
+ const newInitialDirectories = new Set(resolved.initialDirectories);
644
+ for (const existing of this.directories) {
645
+ if (!this.initialDirectories.has(existing)) {
646
+ newDirectories.add(existing);
647
+ }
648
+ }
649
+ const directoriesChanged = newDirectories.size !== this.directories.size || ![...newDirectories].every((d) => this.directories.has(d));
650
+ const initialDirectoriesChanged = newInitialDirectories.size !== this.initialDirectories.size || ![...newInitialDirectories].every((d) => this.initialDirectories.has(d));
651
+ this.directories = newDirectories;
652
+ this.initialDirectories = newInitialDirectories;
653
+ this.resolvedPathCache.clear();
654
+ if (directoriesChanged || initialDirectoriesChanged) {
655
+ this.notifyDirectoriesChanged();
656
+ }
657
+ }
658
+ /**
659
+ * Checks if a given path is within any of the workspace directories.
660
+ * @param pathToCheck The path to validate
661
+ * @returns True if the path is within the workspace, false otherwise
662
+ */
663
+ isPathWithinWorkspace(pathToCheck) {
664
+ try {
665
+ const fullyResolvedPath = this.fullyResolvedPath(pathToCheck);
666
+ for (const dir of this.directories) {
667
+ if (isPathWithinRoot(fullyResolvedPath, dir)) {
668
+ return true;
669
+ }
670
+ }
671
+ return false;
672
+ } catch (_error) {
673
+ return false;
674
+ }
675
+ }
676
+ /**
677
+ * Fully resolves a path, including symbolic links.
678
+ * If the path does not exist, it returns the fully resolved path as it would be
679
+ * if it did exist.
680
+ *
681
+ * Result is memoized in {@link resolvedPathCache}. Filesystem-state cache:
682
+ * if a file is renamed / a symlink is retargeted mid-session the cache
683
+ * goes stale, which is the same correctness profile as any single
684
+ * `realpathSync` call (it captures a moment in time). The win is cutting
685
+ * 8+ syscalls per tool-heavy prompt down to 1.
686
+ */
687
+ fullyResolvedPath(pathToCheck) {
688
+ const cached = this.resolvedPathCache.get(pathToCheck);
689
+ if (cached !== void 0) {
690
+ return cached;
691
+ }
692
+ let resolved;
693
+ try {
694
+ resolved = fs.realpathSync(pathToCheck);
695
+ } catch (e) {
696
+ if (isNodeError(e) && e.code === "ENOENT" && e.path && // realpathSync does not set e.path correctly for symlinks to
697
+ // non-existent files.
698
+ !this.isFileSymlink(e.path)) {
699
+ resolved = e.path;
700
+ } else {
701
+ throw e;
702
+ }
703
+ }
704
+ if (this.resolvedPathCache.size >= _WorkspaceContext.RESOLVED_PATH_CACHE_MAX) {
705
+ const oldest = this.resolvedPathCache.keys().next().value;
706
+ if (oldest !== void 0) this.resolvedPathCache.delete(oldest);
707
+ }
708
+ this.resolvedPathCache.set(pathToCheck, resolved);
709
+ return resolved;
710
+ }
711
+ /**
712
+ * Checks if a file path is a symbolic link that points to a file.
713
+ */
714
+ isFileSymlink(filePath) {
715
+ try {
716
+ return !fs.readlinkSync(filePath).endsWith("/");
717
+ } catch (_error) {
718
+ return false;
719
+ }
720
+ }
721
+ };
722
+ function isPathWithinRoot(pathToCheck, rootDirectory) {
723
+ const relative3 = path.relative(rootDirectory, pathToCheck);
724
+ return !relative3.startsWith(`..${path.sep}`) && relative3 !== ".." && !path.isAbsolute(relative3);
725
+ }
726
+ __name(isPathWithinRoot, "isPathWithinRoot");
727
+
728
+ // packages/core/src/utils/qwenIgnoreParser.ts
729
+ init_esbuild_shims();
730
+ var import_ignore = __toESM(require_ignore(), 1);
731
+ import * as fs2 from "node:fs";
732
+ import * as path2 from "node:path";
733
+ var QWEN_IGNORE_FILE_NAME = ".qwenignore";
734
+ var debugLogger2 = createDebugLogger("QWEN_IGNORE");
735
+ var DEFAULT_QWEN_CUSTOM_IGNORE_FILE_NAMES = [
736
+ ".agentignore",
737
+ ".aiignore"
738
+ ];
739
+ function normalizeQwenCustomIgnoreFileNames(ignoreFileNames = DEFAULT_QWEN_CUSTOM_IGNORE_FILE_NAMES) {
740
+ const normalized = [];
741
+ const seen = /* @__PURE__ */ new Set();
742
+ for (const ignoreFileName of ignoreFileNames) {
743
+ const candidate = ignoreFileName.trim().replace(/\\/g, "/");
744
+ const skipReason = getCustomIgnoreFileNameSkipReason(candidate);
745
+ if (skipReason) {
746
+ debugLogger2.debug(
747
+ `Skipping customIgnoreFiles entry "${ignoreFileName}": ${skipReason}`
748
+ );
749
+ continue;
750
+ }
751
+ if (seen.has(candidate)) {
752
+ debugLogger2.debug(
753
+ `Skipping customIgnoreFiles entry "${ignoreFileName}": duplicate`
754
+ );
755
+ continue;
756
+ }
757
+ normalized.push(candidate);
758
+ seen.add(candidate);
759
+ }
760
+ return normalized;
761
+ }
762
+ __name(normalizeQwenCustomIgnoreFileNames, "normalizeQwenCustomIgnoreFileNames");
763
+ function getCustomIgnoreFileNameSkipReason(candidate) {
764
+ if (candidate === "") {
765
+ return "empty path";
766
+ }
767
+ if (path2.isAbsolute(candidate) || candidate.startsWith("/")) {
768
+ return "absolute paths are not allowed";
769
+ }
770
+ if (candidate.includes("\0")) {
771
+ return "null bytes are not allowed";
772
+ }
773
+ if (candidate === QWEN_IGNORE_FILE_NAME) {
774
+ return ".qwenignore is always included";
775
+ }
776
+ if (candidate.split("/").includes("..")) {
777
+ return "parent directory segments are not allowed";
778
+ }
779
+ return null;
780
+ }
781
+ __name(getCustomIgnoreFileNameSkipReason, "getCustomIgnoreFileNameSkipReason");
782
+ function getQwenIgnoreFileNames(customIgnoreFileNames) {
783
+ return [
784
+ QWEN_IGNORE_FILE_NAME,
785
+ ...normalizeQwenCustomIgnoreFileNames(customIgnoreFileNames)
786
+ ];
787
+ }
788
+ __name(getQwenIgnoreFileNames, "getQwenIgnoreFileNames");
789
+ function formatQwenIgnoreFileNames(customIgnoreFileNames) {
790
+ return getQwenIgnoreFileNames(customIgnoreFileNames).join(", ");
791
+ }
792
+ __name(formatQwenIgnoreFileNames, "formatQwenIgnoreFileNames");
793
+ var QwenIgnoreParser = class {
794
+ static {
795
+ __name(this, "QwenIgnoreParser");
796
+ }
797
+ projectRoot;
798
+ patterns = [];
799
+ ignoreFileNames;
800
+ sourceIgnorers = [];
801
+ constructor(projectRoot, customIgnoreFileNames) {
802
+ this.projectRoot = path2.resolve(projectRoot);
803
+ this.ignoreFileNames = getQwenIgnoreFileNames(customIgnoreFileNames);
804
+ this.loadPatterns();
805
+ }
806
+ loadPatterns() {
807
+ for (const ignoreFileName of this.ignoreFileNames) {
808
+ const patternsFilePath = path2.join(this.projectRoot, ignoreFileName);
809
+ let content;
810
+ try {
811
+ content = fs2.readFileSync(patternsFilePath, "utf-8");
812
+ } catch (_error) {
813
+ const error = _error;
814
+ if (error.code !== "ENOENT") {
815
+ debugLogger2.debug(
816
+ `Failed to read ${patternsFilePath}: ${error.message}`
817
+ );
818
+ }
819
+ continue;
820
+ }
821
+ const patterns = (content ?? "").split("\n").map((p) => p.trim()).filter((p) => p !== "" && !p.startsWith("#"));
822
+ if (patterns.length > 0) {
823
+ const sourceIgnorer = (0, import_ignore.default)();
824
+ sourceIgnorer.add(patterns);
825
+ this.sourceIgnorers.push({
826
+ ignoreFileName,
827
+ ignorer: sourceIgnorer
828
+ });
829
+ }
830
+ this.patterns.push(...patterns);
831
+ }
832
+ }
833
+ isIgnored(filePath) {
834
+ if (this.patterns.length === 0) {
835
+ return false;
836
+ }
837
+ const normalizedPath = this.normalizePathForIgnore(filePath);
838
+ if (!normalizedPath) {
839
+ return false;
840
+ }
841
+ return this.sourceIgnorers.some(
842
+ ({ ignorer }) => ignorer.ignores(normalizedPath)
843
+ );
844
+ }
845
+ getIgnoreFileNameForPath(filePath) {
846
+ const normalizedPath = this.normalizePathForIgnore(filePath);
847
+ if (!normalizedPath) {
848
+ return void 0;
849
+ }
850
+ return this.sourceIgnorers.find(
851
+ ({ ignorer }) => ignorer.ignores(normalizedPath)
852
+ )?.ignoreFileName;
853
+ }
854
+ normalizePathForIgnore(filePath) {
855
+ if (!filePath || typeof filePath !== "string") {
856
+ return null;
857
+ }
858
+ if (filePath.startsWith("\\") || filePath === "/" || filePath.includes("\0")) {
859
+ return null;
860
+ }
861
+ const resolved = path2.resolve(this.projectRoot, filePath);
862
+ const relativePath = path2.relative(this.projectRoot, resolved);
863
+ if (relativePath === "" || !isPathWithinRoot(resolved, this.projectRoot)) {
864
+ return null;
865
+ }
866
+ const normalizedPath = relativePath.replace(/\\/g, "/");
867
+ if (normalizedPath.startsWith("/") || normalizedPath === "") {
868
+ return null;
869
+ }
870
+ return normalizedPath;
871
+ }
872
+ getPatterns() {
873
+ return this.patterns;
874
+ }
875
+ getIgnoreFileNames() {
876
+ return this.ignoreFileNames;
877
+ }
878
+ };
879
+
880
+ // packages/core/src/config/constants.ts
881
+ init_esbuild_shims();
882
+ var DEFAULT_MEMORY_FILE_FILTERING_OPTIONS = {
883
+ respectGitIgnore: false,
884
+ respectQwenIgnore: true,
885
+ customIgnoreFiles: [...DEFAULT_QWEN_CUSTOM_IGNORE_FILE_NAMES]
886
+ };
887
+ var DEFAULT_FILE_FILTERING_OPTIONS = {
888
+ respectGitIgnore: true,
889
+ respectQwenIgnore: true,
890
+ customIgnoreFiles: [...DEFAULT_QWEN_CUSTOM_IGNORE_FILE_NAMES]
891
+ };
892
+
893
+ export {
894
+ require_ignore,
895
+ WorkspaceContext,
896
+ isPathWithinRoot,
897
+ DEFAULT_QWEN_CUSTOM_IGNORE_FILE_NAMES,
898
+ getQwenIgnoreFileNames,
899
+ formatQwenIgnoreFileNames,
900
+ QwenIgnoreParser,
901
+ DEFAULT_MEMORY_FILE_FILTERING_OPTIONS,
902
+ DEFAULT_FILE_FILTERING_OPTIONS
903
+ };
904
+ /**
905
+ * @license
906
+ * Copyright 2025 Google LLC
907
+ * SPDX-License-Identifier: Apache-2.0
908
+ */